OSDev.org

The Place to Start for Operating System Developers
It is currently Wed Apr 24, 2024 10:14 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: [SOLVED] HD Audio Stream DMA engine not working
PostPosted: Fri Oct 27, 2017 1:36 am 
Offline

Joined: Thu Oct 26, 2017 7:25 pm
Posts: 4
Hello!

I am currently implementing HD Audio driver in my Thinkpad X220i. I have managed to make CORB and RIRB working well. However, I have been stuck in making stream DMA engine work for about two weeks. The problem is that DMA position is 0 and no interrupt has been fired, whereas Link Position in Buffer (LPIB) is changing.

Here is what I did:

1. enumerate PCI devices and find hda controller, Memory space and bus master bits are set in PCI Command register.
2. enable MSI support
3. reset controller
4. setup CORB and RIRB
5. enable interrupt
6. use verbs to find the correct DAC and pin widgets nodes.
7. reset output stream
8. initialize BDLE

*(PULONG64)(bdle+i*16) = 0x1000000+i*0x1000; //data buffer
*(PULONG)(bdle+i*16+8) = 0x800; // length
*(PULONG)(bdle+i*16+0xc) = 1; //IOC

9. set stream id 1 in sd control
10. set stream format 0x4011
11. set CBL 0x800*0x70
12. set LVI 0x6f
13. set BDL Pointer
14. set DMA Position

15. set afg, DAC and pin widgets powerstate
16. set format, stream id and channel for the DAC
17. unmute each widgets
18. turn on HP node

19. enable Interrupt On Completion and start stream

I have dumped some of the registers value in my timer isr. SDLPIB is changing and SDSTS is always 0x20.

GCAP:4401 SSYNC:00000000

SDCTL:0014001E SDSTS:20 SDLPIB:(0000DD34,00015734,00001138...) SDCBL:00038000 SDLVI:006F SDFIFOS:00C0 SDFMT:4011 SDBDPL:03000000 SDBDPU:00000000

Did I set things up correctly or maybe I forget something?

Thank You!


Last edited by SK317 on Sun Oct 29, 2017 12:56 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: HD Audio Stream DMA engine not working
PostPosted: Fri Oct 27, 2017 12:58 pm 
Offline
Member
Member
User avatar

Joined: Wed Oct 27, 2010 4:53 pm
Posts: 1150
Location: Scotland
Your best bet would be to look at other people's code to see what they might be setting that you aren't - you only have to get one thing wrong for the DMA engine not to run. You might find something in this thread: http://forum.osdev.org/viewtopic.php?f=1&t=28944 where someone had a similar problem as a result of not setting some obscure register. If you've gone through all the steps listed there and still can't get it working I'll take a closer look at what you're doing - I haven't worked with HDA for a while and have forgotten a lot of the details, so I'd need to do a bit of revision.

_________________
Help the people of Laos by liking - https://www.facebook.com/TheSBInitiative/?ref=py_c

MSB-OS: http://www.magicschoolbook.com/computing/os-project - direct machine code programming


Top
 Profile  
 
 Post subject: Re: HD Audio Stream DMA engine not working
PostPosted: Fri Oct 27, 2017 5:10 pm 
Offline

Joined: Thu Oct 26, 2017 7:25 pm
Posts: 4
Hi,David, Thanks for your reply. I have gone through HD audio related posts in this forum. For my laptop, I found out that CORB and RIRB are working well in both cases where I reset and did not reset the controller. I also did a test where I chose not to reset stream, but still no luck.
The nodes I used in my test are DAC and HP nodes or DAC and built-in speaker nodes. I really have no idea what could possibly cause this problem.


Top
 Profile  
 
 Post subject: Re: HD Audio Stream DMA engine not working
PostPosted: Sat Oct 28, 2017 1:25 pm 
Offline
Member
Member
User avatar

Joined: Wed Oct 27, 2010 4:53 pm
Posts: 1150
Location: Scotland
Have you tried running KolibriOS on your machine to see if its HDA code works on it?

_________________
Help the people of Laos by liking - https://www.facebook.com/TheSBInitiative/?ref=py_c

MSB-OS: http://www.magicschoolbook.com/computing/os-project - direct machine code programming


Top
 Profile  
 
 Post subject: Re: HD Audio Stream DMA engine not working
PostPosted: Sun Oct 29, 2017 12:52 am 
Offline

Joined: Thu Oct 26, 2017 7:25 pm
Posts: 4
Problem finally solved! David, Thank you for pointing me to the right direction. After I skim through the code of this OS. I clear the bit 0-2 of TCSEL and enable HDA snoop and the sound comes out of the built-in speaker instantly. For my laptop, it doesn't matter whether or not I reset host controller or stream. But it is crucial to set up PCI registers correctly.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 97 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group