Currently I am working on the HD-Audio(HDA) driver and I am using VirtualBox(version:4.1.18).
It is useful to discuss/publish the HDA-related features of Virtualbox and I also have a few questions.
It will be a long post.
The stuff I have been using:
- High Definition Audio Specification Revision 1.0a June 17, 2010 (Intel)
- http://wiki.osdev.org/Intel_High_Definition_Audio
- KolibriOS' code
- http://www.pcidatabase.com/search.php?d ... definition
- http://www.pcidatabase.com/vendor_details.php?id=1302
List of PCI-devices in Virtualbox:
Code: Select all
b d f DId VId Cl SubCl
00 00 00 1237 8086 06 00 PCI & Memory
00 01 00 7000 8086 06 01 PCI-to-ISA
00 01 01 7111 8086 01 01 IDE Controller
00 02 00 BEEF 80EE 03 00 VB Graphics Adapter
00 03 00 100E 8086 02 00 Pro1000/MT
00 04 00 CAFE 80EE 08 80 VB Guest Service D.
00 05 00 2668 8086 04 03 HD AUDIO (ICH6) *********
00 06 00 003F 106B 0C 03 SCSI Controller
00 07 00 7113 8086 06 80 Power Mgmt Controller
00 0B 00 265C 8086 0C 03 EHCI Controller
00 0D 00 2829 8086 01 06 AHCI Controller
I decided not to continue with step5 but first see if I can have a DMA-engine running (or a stream), as it is suggested by the wiki-page.
This is how I start a stream:
stream_reset (I call stream_reset from kernel right after boot):
1. clear RUN-bit and interrupts in SD0CTL (0x80)
2. set reset-bit(bit0) in SD0CTL
3. wait 10 ms
4. check in loop if bit0 is 1 in SD0CTL
5. wait 10 ms
6. clear reset-bit(bit0) in SD0CTL
7. wait 10 ms
8. check in loop if bit0 is 0 in SD0CTL
9. wait 10 ms
Perhaps the 10-ms-delays are not necessary.
I have commands audio_play and audioinfo; audioinfo prints the DMApositions(page 55 in spec) and contents of the controller-registers.
audio_play:
1. clear RUN-bit and interrupts in SD0CTL
2. set stream as output and streamId to 1 in SD0CTL
3. set stream format in SD0FMT to 0x4310 (I have a 11.025KHz, bits16, channelsNum=1; wav(PCM))
4. set LVI to 1
5. set BDL to address BDL_BUFF(0x170000) and set the two entries (LVI is 1):
entry1:
[BDL_BUFF] <-- 0x8F5000 (address of wav(PCM)-data)
[BDL_BUFF+4] <-- 0
[BDL_BUFF+8] <-- 88889 (length of PCM-data)
[BDL_BUFF+12] <-- 0 (no IOC)
entry2:
[BDL_BUFF+16] <-- 0x8F5000 (address of wav(PCM)-data)
[BDL_BUFF+16+4] <-- 0
[BDL_BUFF+16+8] <-- 88889 (length of PCM-data)
[BDL_BUFF+16+12] <-- 0 (no IOC)
6. set DPLBASE to 0x160000, and set bit0 to 1, to have the ctrller to write DMApositions
7. start stream: clear interrupts in SD0CTL and set bit1 to 1.
I use a short wav(PCM) for both entries. I hope it is not the problem.
Calling the command audioinfo prints (data in HEX; register-names from page 25-27 in spec):
DMA positions:
00000000
00000000
00000000
00000000
Registers:
GCAP:4401 VMIN:00 VMAJ:01 OUTPAY:003C INPAY:001D GCTL:00000001 WAKEEN:0000 STATESTS:0001 GSTS:0000 OUTSTRMPAY:00FF INSTRMPAY:00FF INTCTL:00000000
INTSTS:C0000000 WALCLK:0126C13D SSYNC:000000FF CORBLBASE:00140000 CORBUBASE:00000000 CORBWP:0000CORBRP:0000 CORBCTL:02 CORBSTS:00 CORBSIZE:42
RIRBLBASE:00150000 RIRBUBASE:00000000 RIRBWP:0000 RINTCNT:0000 RIRBCTL:02 RIRBSTS:00 RIRBSIZE:42 ICOI: 00000000 ICII:0000000 ICIS:0000
DPIBLBASE:00160001 DPIBUBASE:00000000 SD0CTL:00140002 SD0STS:00 SD0LPIB:00000000 SD0CBL:00000000 SD0LVI:0001 SD0FIFOD:0077 SD0FMT:4310
SD0BDPL:00170000 SD0BDPU:00000000
As it can be seen, SD0CTL is 0x00140002 instead of 0x00180002 because it is not a bidirectional engine, so bit19 is RO and bit18 is also RO set to 1.
The problem is that the DMA-positions are zero.
The audioinfo command prints [DPLBASE+0], [DPLBASE+8], +16, +24 (DPLBASE contains 0x160000).
Questions:
Is my stream-related code correct (or something is missing)?
When should I use the Power-State of the widgets? (page 151 in spec)
Flush(GCTL 0x08; GSTS 0x10) shouldn't be used after starting a stream? (KolibriOS doesn't seem to use it)
Can be useful info (Virtualbox):
Codecs-info:
VenId/DevId: 83847680 (VenId:0x8384, DevId: 0x7680)
RevId: 00103401
FG-NUM: 00010001 (starts from 1 and totalnum is 1)
AFG Node Id: 01
AFG Node widgets: 00000002 0000001A (starts from 2 and there are 1A widgets)
Widget-data (step4 of wiki-page) (data in hex):
Code: Select all
WId WCAPS PinCaps InpAmCaps OutpAmCaps ConnlistLen KnobCaps ConfDef ConnlistEntry
; Audio-output
02 000D0C05 0 0 0 0 0 0 0
03 000D0C05 0 0 0 0 0 0 0
04 000D0C05 0 0 0 0 0 0 0
05 000D0C05 0 0 0 0 0 0 0
08 00040211 0 0 0 0 0 0 0
1A 00030201 0 0 0 0 0 0 0
; Audio-input
06 001D0541 0 0 0 00000001 0 0 00000017
07 001D0541 0 0 0 00000001 0 0 00000018
09 001D0541 0 0 0 00000001 0 0 00000011
; Audio-selector
12 0030010D 0 0 00270400 00000007 0 0 0B0F150E
13 0030010D 0 0 00270400 00000007 0 0 0B0F150E
17 00300903 0 0 0 00000001 0 0 00000012
18 00300903 0 0 0 00000001 0 0 00000013
; Pin-complex
0A 00400181 0000173F 0 0 00000001 0 02214020 00000002
0B 00400181 00001737 0 0 00000001 0 11111011 00000004
0C 00400181 00001737 0 0 00000001 0 11114010 00000003
0D 00400181 00001737 0 0 00000001 0 02A19050 00000002
0E 00400081 00000034 0 0 0 0 01013040 0
0F 00400185 00000034 0 0 00000001 0 10116012 00000005
10 00400301 00000010 0 0 00000003 0 01481030 00191708
11 00430681 00010024 0 0 0 0 01C61060 0
15 00400001 00000020 0 0 0 0 90330070 0
1B 00400301 00000010 0 0 00000001 0 4000000F 0000001A
; Volume-knob
16 00600000 0 0 0 00000004 000000FF 0 05040302
; Beep-gen
14 0070000C 0 0 00170303 0 0 0 0
; Vendor-defined
19 00F30201 0 0 0 0 0 0 0