Page 1 of 1

Hd-Audio corb/rirb problem

Posted: Tue Aug 24, 2021 10:26 am
by Kamal123
Hi, currently writing hd-audio driver. I have passed the reset process, my driver resets the controller and take it out of reset mode. It also setup corb and rirb. But the problem is I can send command but I receive 0 response, tested in virtual box latest version and qemu.
I iterate through statests register for codec. I found only one codec in vbox and it's fine. But I couldn't received any response in rirb buffer.
My code- https://github.com/manaskamal/aurora-xe ... da/hda.cpp

Re: Hd-Audio corb/rirb problem

Posted: Tue Aug 24, 2021 11:11 am
by Klakap

Code: Select all

rirb_base = (uintptr_t)get_physical_address((uint64_t)_ihd_audio.rirb);
_aud_outl_(RIRBLBASE, rirb_base);
_aud_outl_(RIRBUBASE, rirb_base >> 32);
CORB/RIRB is memory aligned, LBASE register has first 7 bits hardwired to zero.

Code: Select all

_aud_outw_ (CORBRP, 0x8000);

_aud_outw_ (CORBRP, 0x0);
You have to wait a little between these commands, and you have to be sure that CORB RP set bit 15 after first command and that bit 15 is clear after second command.

Also it is important that in RIRB you receive 8 bytes, from whose is first dword response to verb.

Re: Hd-Audio corb/rirb problem

Posted: Thu Aug 26, 2021 3:16 am
by Kamal123
Klakap wrote:

Code: Select all

rirb_base = (uintptr_t)get_physical_address((uint64_t)_ihd_audio.rirb);
_aud_outl_(RIRBLBASE, rirb_base);
_aud_outl_(RIRBUBASE, rirb_base >> 32);
CORB/RIRB is memory aligned, LBASE register has first 7 bits hardwired to zero.

Code: Select all

_aud_outw_ (CORBRP, 0x8000);

_aud_outw_ (CORBRP, 0x0);
You have to wait a little between these commands, and you have to be sure that CORB RP set bit 15 after first command and that bit 15 is clear after second command.

Also it is important that in RIRB you receive 8 bytes, from whose is first dword response to verb.

Thank you so much for your reply, It's still not working, I get 0 response. If I use immediate commands interface, I get response only in qemu not in virtual box.

Re: Hd-Audio corb/rirb problem

Posted: Thu Aug 26, 2021 4:58 am
by Klakap
Because you set CORB write pointer to 0, you have to write first command to CORB entry 1, then increase CORB write pointer to 1 and read response from RIRB entry 1. (by CORB entry 1 I mean CORB_MEMORY+4 bytes and by RIRB entry 1 RIRB_MEMORY+8 bytes)

Re: Hd-Audio corb/rirb problem

Posted: Thu Aug 26, 2021 10:20 pm
by Kamal123
Klakap wrote:Because you set CORB write pointer to 0, you have to write first command to CORB entry 1, then increase CORB write pointer to 1 and read response from RIRB entry 1. (by CORB entry 1 I mean CORB_MEMORY+4 bytes and by RIRB entry 1 RIRB_MEMORY+8 bytes)
Thank you so much for pointing my mistake, now I get response from hd audio controller. In qemu I found one audio output, and in virtual box I found three audio output.

Re: Hd-Audio corb/rirb problem

Posted: Thu Aug 26, 2021 10:28 pm
by Kamal123
Kamal123 wrote:
Klakap wrote:Because you set CORB write pointer to 0, you have to write first command to CORB entry 1, then increase CORB write pointer to 1 and read response from RIRB entry 1. (by CORB entry 1 I mean CORB_MEMORY+4 bytes and by RIRB entry 1 RIRB_MEMORY+8 bytes)
Thank you so much for pointing my mistake, now I get response from hd audio controller. In qemu I found one audio output, and in virtual box I found three audio output.
Sorry!!..again I was doing wrong, I was not iterating through num_widgets. Now I get one audio output, one audio input and two pin complex in qemu and one audio output in virtual box. Once again, thank you so much

Re: Hd-Audio corb/rirb problem

Posted: Fri Aug 27, 2021 1:14 pm
by Kamal123
Hi, i found a problem with virtual box, seems that virtual box don't update corb read pointer.. I send verb after increasing the corb write pointer. But virtual box keeps the corb read pointer in between 0 and 1.

Re: Hd-Audio corb/rirb problem

Posted: Fri Aug 27, 2021 11:37 pm
by Kamal123
Ok, it's working now, corb dma engine was not started properly, I was using _aud_outl_ instead of _aud_outb_, since corbctl is 1 byte in size. Now, I am getting list of widgets in virtual box, with vendor I'd 8384.
My code -> https://github.com/manaskamal/aurora-xe ... da/hda.cpp