Subversion Repositories Kolibri OS

Rev

Rev 188 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1.  
  2. format MS COFF
  3.  
  4.  
  5. include 'proc32.inc'
  6.  
  7. DEBUG       equ 1
  8.  
  9. REMAP_IRQ   equ 0
  10.  
  11. ;irq 0,1,2,8,12,13 íåäîñòóïíû
  12. ;               FEDCBA9876543210
  13. VALID_IRQ   equ 1100111011111000b
  14. ATTCH_IRQ   equ 0000111010101000b
  15.  
  16. IRQ_LINE    equ 0
  17.  
  18. CPU_FREQ    equ  2600d
  19.  
  20. BIT0  EQU 0x00000001
  21. BIT1  EQU 0x00000002
  22. BIT2  EQU 0x00000004
  23. BIT3  EQU 0x00000008
  24. BIT4  EQU 0x00000010
  25. BIT5  EQU 0x00000020
  26. BIT6  EQU 0x00000040
  27. BIT7  EQU 0x00000080
  28. BIT8  EQU 0x00000100
  29. BIT9  EQU 0x00000200
  30. BIT10 EQU 0x00000400
  31. BIT11 EQU 0x00000800
  32. BIT12 EQU 0x00001000
  33. BIT13 EQU 0x00002000
  34. BIT14 EQU 0x00004000
  35. BIT15 EQU 0x00008000
  36. BIT16 EQU 0x00010000
  37. BIT17 EQU 0x00020000
  38. BIT18 EQU 0x00040000
  39. BIT19 EQU 0x00080000
  40. BIT20 EQU 0x00100000
  41. BIT21 EQU 0x00200000
  42. BIT22 EQU 0x00400000
  43. BIT23 EQU 0x00800000
  44. BIT24 EQU 0x00100000
  45. BIT25 EQU 0x02000000
  46. BIT26 EQU 0x04000000
  47. BIT27 EQU 0x08000000
  48. BIT28 EQU 0x10000000
  49. BIT29 EQU 0x20000000
  50. BIT30 EQU 0x40000000
  51. BIT31 EQU 0x80000000
  52.  
  53. VID_INTEL         equ 0x8086
  54. VID_NVIDIA        equ 0x10DE
  55.  
  56. CTRL_ICH          equ 0x2415
  57. CTRL_ICH0         equ 0x2425
  58. CTRL_ICH2         equ 0x2435
  59. CTRL_ICH3         equ 0x2445
  60. CTRL_ICH4         equ 0x24C5
  61. CTRL_ICH5         equ 0x24D5
  62. CTRL_ICH6         equ 0x266E
  63. CTRL_ICH7         equ 0x27DE
  64.  
  65. CTRL_NFORCE       equ 0x01B1
  66. CTRL_NFORCE2      equ 0x006A
  67. CTRL_NFORCE3      equ 0x00DA
  68. CTRL_MCP04        equ 0x003A
  69. CTRL_CK804        equ 0x0059
  70. CTRL_CK8          equ 0x008A
  71. CTRL_CK8S         equ 0x00EA
  72. CTRL_MCP51        equ 0x026B
  73.  
  74.  
  75. PCM_OUT_BDL       equ  0x10      ; PCM out buffer descriptors list
  76. PCM_OUT_CR_REG    equ  0x1b      ; PCM out Control Register
  77. PCM_OUT_LVI_REG   equ  0x15      ; PCM last valid index
  78. PCM_OUT_SR_REG    equ  0x16      ; PCM out Status register
  79. PCM_OUT_PIV_REG   equ  0x1a
  80. PCM_OUT_CIV_REG   equ  0x14      ; PCM out current index
  81.  
  82. PCM_IN_CR_REG     equ  0x0b      ; PCM in Control Register
  83. MC_IN_CR_REG      equ  0x2b      ; MIC in Control Register
  84. RR                equ  BIT1      ; reset registers.  Nukes all regs
  85.  
  86. CODEC_MASTER_VOL_REG            equ     0x02
  87. CODEC_AUX_VOL                   equ     0x04    ;
  88. CODEC_PCM_OUT_REG               equ     18h     ; PCM output volume
  89. CODEC_EXT_AUDIO_REG             equ     28h     ; extended audio
  90. CODEC_EXT_AUDIO_CTRL_REG        equ     2ah     ; extended audio control
  91. CODEC_PCM_FRONT_DACRATE_REG     equ     2ch     ; PCM out sample rate
  92. CODEC_PCM_SURND_DACRATE_REG     equ     2eh     ; surround sound sample rate
  93. CODEC_PCM_LFE_DACRATE_REG       equ     30h     ; LFE sample rate
  94.  
  95. GLOB_CTRL      equ  0x2C        ;   Global Control
  96. CTRL_STAT       equ  0x30        ;   Global Status
  97. CTRL_CAS        equ  0x34        ;   Codec Access Semiphore
  98.  
  99. CAS_FLAG        equ  0x01        ;   Codec Access Semiphore Bit
  100.  
  101. CTRL_ST_CREADY  equ  BIT8+BIT9+BIT28 ;   Primary Codec Ready
  102.  
  103. CTRL_ST_RCS     equ  0x00008000  ;   Read Completion Status
  104.  
  105. CTRL_CNT_CRIE   equ  BIT4+BIT5+BIT6  ;   Codecs Resume Interrupt Enable
  106. CTRL_CNT_AC_OFF equ  0x00000008  ;   ACLINK Off
  107. CTRL_CNT_WARM   equ  0x00000004  ;   AC97 Warm Reset
  108. CTRL_CNT_COLD   equ  0x00000002  ;   AC97 Cold Reset
  109. CTRL_CNT_GIE    equ  0x00000001  ;   GPI Interrupt Enable
  110.  
  111. CODEC_REG_POWERDOWN   equ 0x26
  112. CODEC_REG_ST          equ 0x26
  113.  
  114. DEV_PLAY              equ  1
  115. DEV_STOP              equ  2
  116. DEV_CALLBACK          equ  3
  117. DEV_SET_BUFF          equ  4
  118. DEV_NOTIFY            equ  5
  119. DEV_SET_MASTERVOL     equ  6
  120. DEV_GET_MASTERVOL     equ  7
  121. DEV_GET_INFO          equ  8
  122.  
  123. struc AC_CNTRL              ;AC controller base class
  124. { .bus                dd ?
  125.   .devfn              dd ?
  126.  
  127.   .vendor             dd ?
  128.   .dev_id             dd ?
  129.   .pci_cmd            dd ?
  130.   .pci_stat           dd ?
  131.  
  132.   .codec_io_base      dd ?
  133.   .codec_mem_base     dd ?
  134.  
  135.   .ctrl_io_base       dd ?
  136.   .ctrl_mem_base      dd ?
  137.   .cfg_reg            dd ?
  138.   .int_line           dd ?
  139.  
  140.   .vendor_ids         dd ?    ;vendor id string
  141.   .ctrl_ids           dd ?    ;hub id string
  142.  
  143.   .buffer             dd ?
  144.  
  145.   .notify_pos         dd ?
  146.   .notify_task        dd ?
  147.  
  148.   .lvi_reg            dd ?
  149.   .ctrl_setup         dd ?
  150.   .user_callback      dd ?
  151.   .codec_read16       dd ?
  152.   .codec_write16      dd ?
  153.  
  154.   .ctrl_read8         dd ?
  155.   .ctrl_read16        dd ?
  156.   .ctrl_read32        dd ?
  157.  
  158.   .ctrl_write8        dd ?
  159.   .ctrl_write16       dd ?
  160.   .ctrl_write32       dd ?
  161. }
  162.  
  163. struc CODEC                ;Audio Chip base class
  164. {
  165.   .chip_id            dd ?
  166.   .flags              dd ?
  167.   .status             dd ?
  168.  
  169.   .ac_vendor_ids      dd ?    ;ac vendor id string
  170.   .chip_ids           dd ?    ;chip model string
  171.  
  172.   .shadow_flag        dd ?
  173.                       dd ?
  174.  
  175.   .regs               dw ?     ; codec registers
  176.   .reg_master_vol     dw ?     ;0x02
  177.   .reg_aux_out_vol    dw ?     ;0x04
  178.   .reg_mone_vol       dw ?     ;0x06
  179.   .reg_master_tone    dw ?     ;0x08
  180.   .reg_beep_vol       dw ?     ;0x0A
  181.   .reg_phone_vol      dw ?     ;0x0C
  182.   .reg_mic_vol        dw ?     ;0x0E
  183.   .reg_line_in_vol    dw ?     ;0x10
  184.   .reg_cd_vol         dw ?     ;0x12
  185.   .reg_video_vol      dw ?     ;0x14
  186.   .reg_aux_in_vol     dw ?     ;0x16
  187.   .reg_pcm_out_vol    dw ?     ;0x18
  188.   .reg_rec_select     dw ?     ;0x1A
  189.   .reg_rec_gain       dw ?     ;0x1C
  190.   .reg_rec_gain_mic   dw ?     ;0x1E
  191.   .reg_gen            dw ?     ;0x20
  192.   .reg_3d_ctrl        dw ?     ;0X22
  193.   .reg_page           dw ?     ;0X24
  194.   .reg_powerdown      dw ?     ;0x26
  195.   .reg_ext_audio      dw ?     ;0x28
  196.   .reg_ext_st         dw ?     ;0x2a
  197.   .reg_pcm_front_rate dw ?     ;0x2c
  198.   .reg_pcm_surr_rate  dw ?     ;0x2e
  199.   .reg_lfe_rate       dw ?     ;0x30
  200.   .reg_pcm_in_rate    dw ?     ;0x32
  201.                       dw ?     ;0x34
  202.   .reg_cent_lfe_vol   dw ?     ;0x36
  203.   .reg_surr_vol       dw ?     ;0x38
  204.   .reg_spdif_ctrl     dw ?     ;0x3A
  205.                       dw ?     ;0x3C
  206.                       dw ?     ;0x3E
  207.                       dw ?     ;0x40
  208.                       dw ?     ;0x42
  209.                       dw ?     ;0x44
  210.                       dw ?     ;0x46
  211.                       dw ?     ;0x48
  212.                       dw ?     ;0x4A
  213.                       dw ?     ;0x4C
  214.                       dw ?     ;0x4E
  215.                       dw ?     ;0x50
  216.                       dw ?     ;0x52
  217.                       dw ?     ;0x54
  218.                       dw ?     ;0x56
  219.                       dw ?     ;0x58
  220.                       dw ?     ;0x5A
  221.                       dw ?     ;0x5C
  222.                       dw ?     ;0x5E
  223.   .reg_page_0         dw ?     ;0x60
  224.   .reg_page_1         dw ?     ;0x62
  225.   .reg_page_2         dw ?     ;0x64
  226.   .reg_page_3         dw ?     ;0x66
  227.   .reg_page_4         dw ?     ;0x68
  228.   .reg_page_5         dw ?     ;0x6A
  229.   .reg_page_6         dw ?     ;0x6C
  230.   .reg_page_7         dw ?     ;0x6E
  231.                       dw ?     ;0x70
  232.                       dw ?     ;0x72
  233.                       dw ?     ;0x74
  234.                       dw ?     ;0x76
  235.                       dw ?     ;0x78
  236.                       dw ?     ;0x7A
  237.   .reg_vendor_id_1    dw ?     ;0x7C
  238.   .reg_vendor_id_2    dw ?     ;0x7E
  239.  
  240.  
  241.   .reset              dd ?    ;virual
  242.   .set_master_vol     dd ?
  243. }
  244.  
  245. struc CTRL_INFO
  246. {   .pci_cmd        dd  ?
  247.     .irq            dd  ?
  248.     .glob_cntrl     dd  ?
  249.     .glob_sta       dd  ?
  250.     .codec_io_base  dd  ?
  251.     .ctrl_io_base   dd  ?
  252.     .codec_mem_base dd  ?
  253.     .ctrl_mem_base  dd  ?
  254.     .codec_id       dd  ?
  255. }
  256.  
  257. struc IOCTL
  258. {  .handle           dd ?
  259.    .io_code          dd ?
  260.    .input            dd ?
  261.    .inp_size         dd ?
  262.    .output           dd ?
  263.    .out_size         dd ?
  264. }
  265.  
  266. virtual at 0
  267.   IOCTL IOCTL
  268. end virtual
  269.  
  270. EVENT_NOTIFY          equ 0x00000200
  271.  
  272. OS_BASE               equ 0;  0x80400000
  273. new_app_base          equ 0x60400000;   0x01000000
  274. PROC_BASE             equ OS_BASE+0x0080000
  275.  
  276. public START
  277. public STOP
  278. public service_proc
  279.  
  280. extrn AttachIntHandler
  281. extrn SysMsgBoardStr
  282. extrn PciApi
  283. extrn PciRead32
  284. extrn PciRead8
  285. extrn PciWrite8
  286. extrn AllocKernelSpace
  287. extrn MapPage
  288. extrn RegService
  289. extrn KernelAlloc
  290. extrn GetPgAddr
  291. extrn GetCurrentTask
  292.  
  293. section '.flat' code readable align 16
  294.  
  295. START:
  296.      if DEBUG
  297.            mov esi, msgInit
  298.            call SysMsgBoardStr
  299.      end if
  300.  
  301.            call detect_controller
  302.            test eax, eax
  303.            jz .fail
  304.  
  305.      if DEBUG
  306.            mov esi,[ctrl.vendor_ids]
  307.            call SysMsgBoardStr
  308.            mov    esi, [ctrl.ctrl_ids]
  309.            call SysMsgBoardStr
  310.  
  311.      end if
  312.  
  313.            call init_controller
  314.            test eax, eax
  315.            jz .fail
  316.  
  317.      if DEBUG
  318.            mov esi, msgInitCodec
  319.            call SysMsgBoardStr
  320.      end if
  321.  
  322.            call init_codec
  323.            test eax, eax
  324.            jz .fail
  325.  
  326.      if DEBUG
  327.            mov esi, [codec.ac_vendor_ids]
  328.            call SysMsgBoardStr
  329.  
  330.            mov esi, [codec.chip_ids]
  331.            call SysMsgBoardStr
  332.      end if
  333.  
  334.            call reset_controller
  335.            call setup_codec
  336.  
  337.            mov esi, msgPrimBuff
  338.            call SysMsgBoardStr
  339.  
  340.            call create_primary_buff
  341.  
  342. ;     if REMAP_IRQ
  343.  
  344. ;           call get_LPC_bus
  345. ;           cmp eax, -1
  346. ;           jz .fail
  347.  
  348. ;           mov [lpc_bus], 0  ;eax
  349. ;           call remap_irq
  350. ;     end if
  351.  
  352.            mov eax, VALID_IRQ
  353.            mov ebx, [ctrl.int_line]
  354.            mov esi, msgInvIRQ
  355.            bt eax, ebx
  356.            jnc .fail
  357.            mov eax, ATTCH_IRQ
  358.            mov esi, msgAttchIRQ
  359.            bt eax, ebx
  360.            jnc .fail
  361.  
  362.            stdcall AttachIntHandler, ebx, ac97_irq
  363.            stdcall RegService, sz_sound_srv, service_proc
  364.            ret
  365. .fail:
  366.      if DEBUG
  367.            mov esi, msgFail
  368.            call SysMsgBoardStr
  369.      end if
  370.            xor eax, eax
  371. STOP:
  372.            ret
  373.  
  374. handle     equ  IOCTL.handle
  375. io_code    equ  IOCTL.io_code
  376. input      equ  IOCTL.input
  377. inp_size   equ  IOCTL.inp_size
  378. output     equ  IOCTL.output
  379. out_size   equ  IOCTL.out_size
  380.  
  381. align 4
  382. proc service_proc stdcall, ioctl:dword
  383.  
  384.            mov edi, [ioctl]
  385.            mov eax, [edi+io_code]
  386.            cmp eax, DEV_PLAY
  387.            jne @F
  388.      if DEBUG
  389.            mov esi, msgPlay
  390.            call SysMsgBoardStr
  391.      end if
  392.            call play
  393.            ret
  394. @@:
  395.            cmp eax, DEV_STOP
  396.            jne @F
  397.      if DEBUG
  398.            mov esi, msgStop
  399.            call SysMsgBoardStr
  400.      end if
  401.            call stop
  402.            ret
  403. @@:
  404.            cmp eax, DEV_CALLBACK
  405.            jne @F
  406.            mov ebx, [edi+input]
  407.            stdcall set_callback, [ebx]
  408.            ret
  409. @@:
  410.            cmp eax, DEV_SET_MASTERVOL
  411.            jne @F
  412.            mov ebx, [edi+input]
  413.            stdcall set_master_vol, [ebx]
  414.            ret
  415. @@:
  416.            cmp eax, DEV_GET_MASTERVOL
  417.            jne @F
  418.            mov ebx, [edi+output]
  419.            test ebx, ebx
  420.            jz .fail
  421.  
  422.            stdcall get_master_vol, ebx
  423.            ret
  424. @@:
  425.            cmp eax, DEV_GET_INFO
  426.            jne @F
  427.            mov ebx, [edi+output]
  428.            stdcall get_dev_info, ebx
  429.            ret
  430. @@:
  431. .fail:
  432.            xor eax, eax
  433.            ret
  434. endp
  435.  
  436. restore   handle
  437. restore   io_code
  438. restore   input
  439. restore   inp_size
  440. restore   output
  441. restore   out_size
  442.  
  443.  
  444. align 4
  445. proc remap_irq                         ;for Intel chipsets ONLY !!!
  446.            mov eax, VALID_IRQ
  447.            bt eax, IRQ_LINE
  448.            jnc .exit
  449.  
  450.            mov edx, 0x4D0
  451.            in ax,dx
  452.            bts ax, IRQ_LINE
  453.            out dx, aX
  454.  
  455.            stdcall PciWrite8, dword 0, dword 0xF8, dword 0x61, dword IRQ_LINE
  456.            mov [ctrl.int_line], IRQ_LINE
  457.  
  458. .exit:
  459.            ret
  460. endp
  461.  
  462. align 4
  463. proc ac97_irq
  464.  
  465. ;     if DEBUG
  466. ;           mov esi, msgIRQ
  467. ;           call SysMsgBoardStr
  468. ;     end if
  469.  
  470.            mov edx, PCM_OUT_CR_REG
  471.            mov al, 0x14
  472.            call [ctrl.ctrl_write8]
  473.  
  474.            mov ax, 0x1c
  475.            mov edx, PCM_OUT_SR_REG
  476.            call [ctrl.ctrl_write16]
  477.  
  478.            mov edx, PCM_OUT_CIV_REG
  479.            call [ctrl.ctrl_read8]
  480.  
  481.            and eax, 0x1F
  482.            cmp eax, [civ_val]
  483.            je .skip
  484.  
  485.            mov [civ_val], eax
  486.            dec eax
  487.            and eax, 0x1F
  488.            mov [ctrl.lvi_reg], eax
  489.  
  490.            mov edx, PCM_OUT_LVI_REG
  491.            call [ctrl.ctrl_write8]
  492.  
  493.            mov edx, PCM_OUT_CR_REG
  494.            mov ax, 0x1D
  495.            call [ctrl.ctrl_write8]
  496.  
  497.            mov eax, [civ_val]
  498.            add eax, 2
  499.            and eax, 31
  500.            mov ebx, dword [buff_list+eax*4]
  501.  
  502.            cmp [ctrl.user_callback], 0
  503.            je @f
  504.  
  505.            stdcall [ctrl.user_callback], ebx
  506. @@:
  507.            ret
  508.  
  509. .skip:
  510.            mov edx, PCM_OUT_CR_REG
  511.            mov ax, 0x1D
  512.            call [ctrl.ctrl_write8]
  513.            ret
  514. endp
  515.  
  516. align 4
  517. proc create_primary_buff
  518.  
  519.            stdcall KernelAlloc, 0x10000
  520.            mov [ctrl.buffer], eax
  521.  
  522.            mov edi, eax
  523.            mov ecx, 0x10000/4
  524.            xor eax, eax
  525.            cld
  526.            rep stosd
  527.  
  528.            stdcall GetPgAddr, [ctrl.buffer]
  529.  
  530.            mov ebx, 0xC0002000
  531.            mov ecx, 4
  532.            mov edi, pcmout_bdl
  533. @@:
  534.            mov [edi], eax
  535.            mov [edi+4], ebx
  536.  
  537.            mov [edi+32], eax
  538.            mov [edi+4+32], ebx
  539.  
  540.            mov [edi+64], eax
  541.            mov [edi+4+64], ebx
  542.  
  543.            mov [edi+96], eax
  544.            mov [edi+4+96], ebx
  545.  
  546.            mov [edi+128], eax
  547.            mov [edi+4+128], ebx
  548.  
  549.            mov [edi+160], eax
  550.            mov [edi+4+160], ebx
  551.  
  552.            mov [edi+192], eax
  553.            mov [edi+4+192], ebx
  554.  
  555.            mov [edi+224], eax
  556.            mov [edi+4+224], ebx
  557.  
  558.            add eax, 0x4000
  559.            add edi, 8
  560.            loop @B
  561.  
  562.            mov edi, buff_list
  563.            mov eax, [ctrl.buffer]
  564.            mov ecx, 4
  565. @@:
  566.            mov [edi], eax
  567.            mov [edi+16], eax
  568.            mov [edi+32], eax
  569.            mov [edi+48], eax
  570.            mov [edi+64], eax
  571.            mov [edi+80], eax
  572.            mov [edi+96], eax
  573.            mov [edi+112], eax
  574.  
  575.            add eax, 0x4000
  576.            add edi, 4
  577.            loop @B
  578.  
  579.            mov ecx, pcmout_bdl
  580.            stdcall GetPgAddr, ecx
  581.            and ecx, 0xFFF
  582.            add eax, ecx
  583.  
  584.            mov edx, PCM_OUT_BDL
  585.            call [ctrl.ctrl_write32]
  586.  
  587.            mov eax, 16
  588.            mov [ctrl.lvi_reg], eax
  589.            mov edx, PCM_OUT_LVI_REG
  590.            call [ctrl.ctrl_write8]
  591.  
  592.            ret
  593. endp
  594.  
  595. align 4
  596. proc detect_controller
  597.            locals
  598.              last_bus dd ?
  599.              bus      dd ?
  600.              devfn    dd ?
  601.            endl
  602.  
  603.            xor eax, eax
  604.            mov [bus], eax
  605.            inc eax
  606.            call PciApi
  607.            cmp eax, -1
  608.            je .err
  609.  
  610.            mov [last_bus], eax
  611.  
  612. .next_bus:
  613.            and [devfn], 0
  614. .next_dev:
  615.            stdcall PciRead32, [bus], [devfn], dword 0
  616.            test eax, eax
  617.            jz .next
  618.            cmp eax, -1
  619.            je .next
  620.  
  621.            mov edi, devices
  622. @@:
  623.            mov ebx, [edi]
  624.            test ebx, ebx
  625.            jz .next
  626.  
  627.            cmp eax, ebx
  628.            je .found
  629.            add edi, 12
  630.            jmp @B
  631.  
  632. .next:     inc [devfn]
  633.            cmp [devfn], 256
  634.            jb  .next_dev
  635.            mov eax, [bus]
  636.            inc eax
  637.            mov [bus], eax
  638.            cmp eax, [last_bus]
  639.            jna .next_bus
  640.            xor eax, eax
  641.            ret
  642. .found:
  643.            mov ebx, [bus]
  644.            mov [ctrl.bus], ebx
  645.  
  646.            mov ecx, [devfn]
  647.            mov [ctrl.devfn], ecx
  648.  
  649.            mov edx, eax
  650.            and edx, 0xFFFF
  651.            mov [ctrl.vendor], edx
  652.            shr eax, 16
  653.            mov [ctrl.dev_id], eax
  654.  
  655.            mov ebx, [edi+4]
  656.            mov [ctrl.ctrl_ids], ebx
  657.            mov esi, [edi+8]
  658.            mov [ctrl.ctrl_setup], esi
  659.  
  660.            cmp ebx, VID_INTEL
  661.            jne @F
  662.            mov [ctrl.vendor_ids], msg_Intel
  663.            ret
  664. @@:
  665.            cmp ebx, VID_NVIDIA
  666.            jne @F
  667.            mov [ctrl.vendor_ids], msg_NVidia
  668. @@:
  669.            mov [ctrl.vendor_ids], 0     ;something  wrong ?
  670.            ret
  671. .err:
  672.            xor eax, eax
  673.            ret
  674. endp
  675.  
  676. align 4
  677. proc get_LPC_bus                ;for Intel chipsets ONLY !!!
  678.            locals
  679.              last_bus dd ?
  680.              bus      dd ?
  681.            endl
  682.  
  683.            xor eax, eax
  684.            mov [bus], eax
  685.            inc eax
  686.            call [PciApi]
  687.            cmp eax, -1
  688.            je .err
  689.  
  690.            mov [last_bus], eax
  691. .next_bus:
  692.            stdcall PciRead32, [bus], dword 0xF8, dword 0
  693.            test eax, eax
  694.            jz .next
  695.            cmp eax, -1
  696.            je .next
  697.  
  698.            cmp eax, 0x24D08086
  699.            je .found
  700. .next:
  701.            mov eax, [bus]
  702.            inc eax
  703.            cmp eax, [last_bus]
  704.            mov [bus], eax
  705.            jna .next_bus
  706. .err:
  707.            xor eax, eax
  708.            dec eax
  709.            ret
  710. .found:
  711.            mov eax, [bus]
  712.            ret
  713. endp
  714.  
  715. align 4
  716. proc init_controller
  717.  
  718.            stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 4
  719.            mov ebx, eax
  720.            and eax, 0xFFFF
  721.            mov [ctrl.pci_cmd], eax
  722.            shr ebx, 16
  723.            mov [ctrl.pci_stat], ebx
  724.  
  725.            stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x10
  726.            and eax,0xFFFE
  727.            mov [ctrl.codec_io_base], eax
  728.  
  729.            stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x14
  730.            and eax, 0xFFC0
  731.            mov [ctrl.ctrl_io_base], eax
  732.  
  733.            stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x18
  734.            mov [ctrl.codec_mem_base], eax
  735.  
  736.            stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x1C
  737.            mov [ctrl.ctrl_mem_base], eax
  738.  
  739.            stdcall PciRead32, [ctrl.bus], [ctrl.devfn], dword 0x3C
  740.            and eax, 0xFF
  741.            mov [ctrl.int_line], eax
  742.  
  743.            stdcall PciRead8, [ctrl.bus], [ctrl.devfn], dword 0x41
  744.            and eax, 0xFF
  745.            mov [ctrl.cfg_reg], eax
  746.  
  747.            call [ctrl.ctrl_setup]
  748.            xor eax, eax
  749.            inc eax
  750.            ret
  751. endp
  752.  
  753. align 4
  754. proc set_ICH
  755.            mov [ctrl.codec_read16],  codec_io_r16    ;virtual
  756.            mov [ctrl.codec_write16], codec_io_w16    ;virtual
  757.  
  758.            mov [ctrl.ctrl_read8 ],  ctrl_io_r8       ;virtual
  759.            mov [ctrl.ctrl_read16],  ctrl_io_r16      ;virtual
  760.            mov [ctrl.ctrl_read32],  ctrl_io_r32      ;virtual
  761.  
  762.            mov [ctrl.ctrl_write8 ], ctrl_io_w8       ;virtual
  763.            mov [ctrl.ctrl_write16], ctrl_io_w16      ;virtual
  764.            mov [ctrl.ctrl_write32], ctrl_io_w32      ;virtual
  765.            ret
  766. endp
  767.  
  768. PG_SW                equ 0x003
  769. PG_NOCACHE           equ 0x018
  770.  
  771. align 4
  772. proc set_ICH4
  773.            stdcall AllocKernelSpace, dword 0x2000
  774.            mov edi, eax
  775.            stdcall MapPage, edi,[ctrl.codec_mem_base],PG_SW+PG_NOCACHE
  776.            mov [ctrl.codec_mem_base], edi
  777.            add edi, 0x1000
  778.            stdcall MapPage, edi, [ctrl.ctrl_mem_base],PG_SW+PG_NOCACHE
  779.            mov [ctrl.ctrl_mem_base], edi
  780.  
  781.            mov [ctrl.codec_read16],  codec_mem_r16    ;virtual
  782.            mov [ctrl.codec_write16], codec_mem_w16    ;virtual
  783.  
  784.            mov [ctrl.ctrl_read8 ],  ctrl_mem_r8       ;virtual
  785.            mov [ctrl.ctrl_read16],  ctrl_mem_r16      ;virtual
  786.            mov [ctrl.ctrl_read32],  ctrl_mem_r32      ;virtual
  787.  
  788.            mov [ctrl.ctrl_write8 ], ctrl_mem_w8       ;virtual
  789.            mov [ctrl.ctrl_write16], ctrl_mem_w16      ;virtual
  790.            mov [ctrl.ctrl_write32], ctrl_mem_w32      ;virtual
  791.            ret
  792. endp
  793.  
  794. align 4
  795. proc reset_controller
  796.  
  797.            xor eax, eax
  798.            mov edx, PCM_IN_CR_REG
  799.            call [ctrl.ctrl_write8]
  800.  
  801.            mov edx, PCM_OUT_CR_REG
  802.            call [ctrl.ctrl_write8]
  803.  
  804.            mov edx, MC_IN_CR_REG
  805.            call [ctrl.ctrl_write8]
  806.  
  807.            mov eax, RR
  808.            mov edx, PCM_IN_CR_REG
  809.            call [ctrl.ctrl_write8]
  810.  
  811.            mov edx, PCM_OUT_CR_REG
  812.            call [ctrl.ctrl_write8]
  813.  
  814.            mov  edx, MC_IN_CR_REG
  815.            call [ctrl.ctrl_write8]
  816.  
  817.            ret
  818. endp
  819.  
  820. align 4
  821. proc init_codec
  822.            locals
  823.              counter dd ?
  824.            endl
  825.  
  826.            call reset_codec
  827.            and eax, eax
  828.            jz .err
  829.  
  830.            xor edx, edx                   ;ac_reg_0
  831.            call [ctrl.codec_write16]
  832.  
  833.            xor eax, eax
  834.            mov edx, CODEC_REG_POWERDOWN
  835.            call [ctrl.codec_write16]
  836.  
  837.            mov [counter], 200       ; total 200*5 ms = 1s
  838. .wait:
  839.            mov edx, CODEC_REG_POWERDOWN
  840.            call [ctrl.codec_read16]
  841.            and eax, 0x0F
  842.            cmp eax, 0x0F
  843.            jz .ready
  844.  
  845.            mov eax, 5000          ; wait 5 ms
  846.            call StallExec
  847.            sub [counter] , 1
  848.            jnz .wait
  849. .err:
  850.            xor eax, eax        ; timeout error
  851.            ret
  852. .ready:
  853.            call detect_codec
  854.  
  855.            xor eax, eax
  856.            inc eax
  857.            ret
  858. endp
  859.  
  860. align 4
  861. proc reset_codec
  862.            mov edx, GLOB_CTRL
  863.            call [ctrl.ctrl_read32]
  864.  
  865.            test eax, 0x02
  866.            jz .cold
  867.  
  868.            call warm_reset
  869.            jnc .ok
  870. .cold:
  871.            call cold_reset
  872.            jnc .ok
  873.  
  874.      if DEBUG
  875.            mov esi, msgCFail
  876.            call SysMsgBoardStr
  877.      end if
  878.            xor eax, eax            ; timeout error
  879.            ret
  880. .ok:
  881.      if DEBUG
  882.            mov esi, msgResetOk
  883.            call SysMsgBoardStr
  884.      end if
  885.  
  886.            xor eax, eax
  887.            inc eax
  888.            ret
  889. endp
  890.  
  891. align 4
  892. proc warm_reset
  893.            locals
  894.              counter dd ?
  895.            endl
  896.  
  897.            mov eax, 0x06
  898.            mov edx, GLOB_CTRL
  899.            call [ctrl.ctrl_write32]
  900.  
  901.      if DEBUG
  902.            mov esi, msgWarm
  903.            call SysMsgBoardStr
  904.      end if
  905.  
  906.            mov [counter], 10       ; total 10*100 ms = 1s
  907. .wait:
  908.            mov eax, 100000         ; wait 100 ms
  909.            call StallExec
  910.  
  911.            mov edx, GLOB_CTRL
  912.            call [ctrl.ctrl_read32]
  913.            test eax, 4
  914.            jz .ok
  915.            sub [counter], 1
  916.            jnz .wait
  917.  
  918.      if DEBUG
  919.            mov esi, msgWRFail
  920.            call SysMsgBoardStr
  921.      end if
  922.  
  923.            stc
  924.            ret
  925. .ok:
  926.            mov edx, CTRL_STAT
  927.            call [ctrl.ctrl_read32]
  928.            and eax, CTRL_ST_CREADY
  929.            jz .fail
  930.            clc
  931.            ret
  932. .fail:
  933.            stc
  934.            ret
  935. endp
  936.  
  937. align 4
  938. proc cold_reset
  939.            locals
  940.              counter dd ?
  941.            endl
  942.  
  943.            xor eax, eax
  944.            mov edx, GLOB_CTRL
  945.            call [ctrl.ctrl_write32]
  946.  
  947.      if DEBUG
  948.            mov esi, msgCold
  949.            call SysMsgBoardStr
  950.      end if
  951.  
  952.            mov eax, 1000000        ; wait 1 s
  953.            call StallExec
  954.  
  955.            mov eax, 2
  956.            mov edx, GLOB_CTRL
  957.            call [ctrl.ctrl_write32]
  958.  
  959.            mov [counter], 10       ; total 10*100 ms = 1s
  960. .wait:
  961.            mov eax, 100000         ; wait 100 ms
  962.            call StallExec
  963.  
  964.            mov edx, GLOB_CTRL
  965.            call [ctrl.ctrl_read32]
  966.            test eax, 4
  967.            jz .ok
  968.            sub [counter], 1
  969.            jnz .wait
  970.  
  971.      if DEBUG
  972.            mov esi, msgCRFail
  973.            call SysMsgBoardStr
  974.      end if
  975.            stc
  976.            ret
  977. .ok:
  978.            mov edx, CTRL_STAT
  979.            call [ctrl.ctrl_read32]
  980.            and eax, CTRL_ST_CREADY
  981.            jz .fail
  982.            clc
  983.            ret
  984. .fail:
  985.            stc
  986.            ret
  987. endp
  988.  
  989. align 4
  990. proc play
  991.  
  992.            mov eax, 16
  993.            mov [ctrl.lvi_reg], eax
  994.            mov edx, PCM_OUT_LVI_REG
  995.            call [ctrl.ctrl_write8]
  996.  
  997.            mov edx, PCM_OUT_CR_REG
  998.            mov ax, 0x1D
  999.            call [ctrl.ctrl_write8]
  1000.            ret
  1001. endp
  1002.  
  1003. align 4
  1004. proc stop
  1005.            mov edx, PCM_OUT_CR_REG
  1006.            mov ax, 0x14
  1007.            call [ctrl.ctrl_write8]
  1008.  
  1009.            mov eax, 16
  1010.            mov [ctrl.lvi_reg], eax
  1011.            mov edx, PCM_OUT_LVI_REG
  1012.            call [ctrl.ctrl_write8]
  1013.  
  1014.            ret
  1015. endp
  1016.  
  1017. align 4
  1018. proc get_dev_info stdcall, p_info:dword
  1019.            virtual at esi
  1020.              CTRL_INFO CTRL_INFO
  1021.            end virtual
  1022.  
  1023.            mov esi, [p_info]
  1024.            mov eax, [ctrl.int_line]
  1025.            mov ebx, [ctrl.codec_io_base]
  1026.            mov ecx, [ctrl.ctrl_io_base]
  1027.            mov edx, [ctrl.codec_mem_base]
  1028.            mov edi, [ctrl.ctrl_mem_base]
  1029.  
  1030.            mov [CTRL_INFO.irq], eax
  1031.            mov [CTRL_INFO.codec_io_base], ebx
  1032.            mov [CTRL_INFO.ctrl_io_base], ecx
  1033.            mov [CTRL_INFO.codec_mem_base], edx
  1034.            mov [CTRL_INFO.ctrl_mem_base], edi
  1035.  
  1036.            mov eax, [codec.chip_id]
  1037.            mov [CTRL_INFO.codec_id], eax
  1038.  
  1039.            mov edx, GLOB_CTRL
  1040.            call [ctrl.ctrl_read32]
  1041.            mov [CTRL_INFO.glob_cntrl], eax
  1042.  
  1043.            mov edx, CTRL_STAT
  1044.            call [ctrl.ctrl_read32]
  1045.            mov [CTRL_INFO.glob_sta], eax
  1046.  
  1047.            mov ebx, [ctrl.pci_cmd]
  1048.            mov [CTRL_INFO.pci_cmd], ebx
  1049.  
  1050.            ret
  1051. endp
  1052.  
  1053. align 4
  1054. proc set_callback stdcall, handler:dword
  1055.            mov eax, [handler]
  1056.            mov [ctrl.user_callback], eax
  1057.            ret
  1058. endp
  1059.  
  1060. align 4
  1061. proc codec_read stdcall, ac_reg:dword      ; reg = edx, reval = eax
  1062.  
  1063.            mov edx, [ac_reg]
  1064.  
  1065.            mov ebx, edx
  1066.            shr ebx, 1
  1067.            bt [codec.shadow_flag], ebx
  1068.            jc .use_shadow
  1069.  
  1070.            call [ctrl.codec_read16]  ;change edx !!!
  1071.            mov ecx, eax
  1072.  
  1073.            mov edx, CTRL_STAT
  1074.            call [ctrl.ctrl_read32]
  1075.            test eax, CTRL_ST_RCS
  1076.            jz .read_ok
  1077.  
  1078.            mov edx, CTRL_STAT
  1079.            call [ctrl.ctrl_write32]
  1080.            xor eax,eax
  1081.            not eax              ;timeout
  1082.            ret
  1083. .read_ok:
  1084.            mov edx, [ac_reg]
  1085.            mov [codec.regs+edx], cx
  1086.            bts [codec.shadow_flag], ebx
  1087.            mov eax, ecx
  1088.            ret
  1089. .use_shadow:
  1090.            movzx eax, word [codec.regs+edx]
  1091.            ret
  1092. endp
  1093.  
  1094. align 4
  1095. proc codec_write stdcall, ac_reg:dword
  1096.            push eax
  1097.            call check_semafore
  1098.            and eax, eax
  1099.            jz .err
  1100.            pop eax
  1101.  
  1102.            mov esi, [ac_reg]
  1103.            mov edx, esi
  1104.            call [ctrl.codec_write16]
  1105.            mov [codec.regs+esi], ax
  1106.            shr esi, 1
  1107.            bts [codec.shadow_flag], esi
  1108.            ret
  1109. .err:
  1110.            pop eax
  1111.            ret
  1112. endp
  1113.  
  1114. align 4
  1115. proc codec_check_ready
  1116.  
  1117.           mov edx, CTRL_ST
  1118.           call [ctrl.ctrl_read32]
  1119.           and eax, CTRL_ST_CREADY
  1120.           jz .not_ready
  1121.  
  1122.           xor eax, wax
  1123.           inc eax
  1124.           ret
  1125.  
  1126. align 4
  1127. .not_ready:
  1128.           xor eax, eax
  1129.           ret
  1130. endp
  1131.  
  1132. align 4
  1133. proc check_semafore
  1134.            local counter:DWORD
  1135.  
  1136.            mov [counter], 100
  1137. .l1:
  1138.            mov edx, CTRL_CAS
  1139.            call [ctrl.ctrl_read8]
  1140.            and eax, CAS_FLAG
  1141.            jz .ok
  1142.  
  1143.            mov eax, 1
  1144.            call StallExec
  1145.            sub [counter], 1
  1146.            jnz .l1
  1147.            xor eax, eax
  1148.            ret
  1149. align 4
  1150. .ok:
  1151.            xor eax,eax
  1152.            inc eax
  1153.            ret
  1154. endp
  1155.  
  1156. align 4
  1157. proc StallExec
  1158.            push ecx
  1159.            push edx
  1160.            push ebx
  1161.            push eax
  1162.  
  1163.            mov ecx, CPU_FREQ
  1164.            mul ecx
  1165.            mov ebx, eax       ;low
  1166.            mov ecx, edx       ;high
  1167.            rdtsc
  1168.            add ebx, eax
  1169.            adc ecx,edx
  1170. @@:
  1171.            rdtsc
  1172.            sub eax, ebx
  1173.            sbb edx, ecx
  1174.            jb @B
  1175.  
  1176.            pop eax
  1177.            pop ebx
  1178.            pop edx
  1179.            pop ecx
  1180.            ret
  1181. endp
  1182.  
  1183. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1184. ;          CONTROLLER IO functions
  1185. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1186.  
  1187. align 4
  1188. proc codec_io_r16
  1189.         add edx, [ctrl.codec_io_base]
  1190.         in  ax, dx
  1191.         ret
  1192. endp
  1193.  
  1194. align 4
  1195. proc codec_io_w16
  1196.         add edx, [ctrl.codec_io_base]
  1197.         out dx, ax
  1198.         ret
  1199. endp
  1200.  
  1201. align 4
  1202. proc ctrl_io_r8
  1203.         add edx, [ctrl.ctrl_io_base]
  1204.         in  al, dx
  1205.         ret
  1206. endp
  1207.  
  1208. align 4
  1209. proc ctrl_io_r16
  1210.         add edx, [ctrl.ctrl_io_base]
  1211.         in  ax, dx
  1212.         ret
  1213. endp
  1214.  
  1215. align 4
  1216. proc ctrl_io_r32
  1217.         add edx, [ctrl.ctrl_io_base]
  1218.         in  eax, dx
  1219.         ret
  1220. endp
  1221.  
  1222. align 4
  1223. proc ctrl_io_w8
  1224.         add edx, [ctrl.ctrl_io_base]
  1225.         out dx, al
  1226.         ret
  1227. endp
  1228.  
  1229. align 4
  1230. proc ctrl_io_w16
  1231.         add edx, [ctrl.ctrl_io_base]
  1232.         out dx, ax
  1233.         ret
  1234. endp
  1235.  
  1236. align 4
  1237. proc ctrl_io_w32
  1238.         add edx, [ctrl.ctrl_io_base]
  1239.         out dx, eax
  1240.         ret
  1241. endp
  1242.  
  1243. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1244. ;         MEMORY MAPPED IO    (os depended)
  1245. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1246.  
  1247. align 4
  1248. proc codec_mem_r16
  1249.         add edx, [ctrl.codec_mem_base]
  1250.         mov ax, word [edx]
  1251.         ret
  1252. endp
  1253.  
  1254. align 4
  1255. proc codec_mem_w16
  1256.         add edx, [ctrl.codec_mem_base]
  1257.         mov word [edx], ax
  1258.         ret
  1259. endp
  1260.  
  1261. align 4
  1262. proc ctrl_mem_r8
  1263.         add edx, [ctrl.ctrl_mem_base]
  1264.         mov al, [edx]
  1265.         ret
  1266. endp
  1267.  
  1268. align 4
  1269. proc ctrl_mem_r16
  1270.         add edx, [ctrl.ctrl_mem_base]
  1271.         mov ax, [edx]
  1272.         ret
  1273. endp
  1274.  
  1275. align 4
  1276. proc ctrl_mem_r32
  1277.         add edx, [ctrl.ctrl_mem_base]
  1278.         mov eax, [edx]
  1279.         ret
  1280. endp
  1281.  
  1282. align 4
  1283. proc ctrl_mem_w8
  1284.         add edx, [ctrl.ctrl_mem_base]
  1285.         mov [edx], al
  1286.  
  1287.         ret
  1288. endp
  1289.  
  1290. align 4
  1291. proc ctrl_mem_w16
  1292.         add edx, [ctrl.ctrl_mem_base]
  1293.         mov [edx], ax
  1294.         ret
  1295. endp
  1296.  
  1297. align 4
  1298. proc ctrl_mem_w32
  1299.         add edx, [ctrl.ctrl_mem_base]
  1300.         mov [edx], eax
  1301.         ret
  1302. endp
  1303.  
  1304.  
  1305. include "codec.inc"
  1306.  
  1307. align 4
  1308. devices dd (CTRL_ICH  shl 16)+VID_INTEL,msg_ICH, set_ICH
  1309.         dd (CTRL_ICH0 shl 16)+VID_INTEL,msg_ICH0,set_ICH
  1310.         dd (CTRL_ICH2 shl 16)+VID_INTEL,msg_ICH2,set_ICH
  1311.         dd (CTRL_ICH3 shl 16)+VID_INTEL,msg_ICH3,set_ICH
  1312.         dd (CTRL_ICH4 shl 16)+VID_INTEL,msg_ICH4,set_ICH4
  1313.         dd (CTRL_ICH5 shl 16)+VID_INTEL,msg_ICH5,set_ICH4
  1314.         dd (CTRL_ICH6 shl 16)+VID_INTEL,msg_ICH6,set_ICH4
  1315.         dd (CTRL_ICH7 shl 16)+VID_INTEL,msg_ICH7,set_ICH4
  1316.  
  1317.         dd (CTRL_NFORCE  shl 16)+VID_NVIDIA,msg_NForce, set_ICH
  1318.         dd (CTRL_NFORCE2 shl 16)+VID_NVIDIA,msg_NForce2,set_ICH
  1319.         dd (CTRL_NFORCE3 shl 16)+VID_NVIDIA,msg_NForce3,set_ICH
  1320.         dd (CTRL_MCP04   shl 16)+VID_NVIDIA,msg_MCP04,set_ICH
  1321.         dd (CTRL_CK804   shl 16)+VID_NVIDIA,msg_CK804,set_ICH
  1322.         dd (CTRL_CK8     shl 16)+VID_NVIDIA,msg_CK8,set_ICH
  1323.         dd (CTRL_CK8S    shl 16)+VID_NVIDIA,msg_CK8S,set_ICH
  1324.         dd (CTRL_MCP51   shl 16)+VID_NVIDIA,msg_MCP51,set_ICH
  1325.  
  1326.         dd 0    ;terminator
  1327.  
  1328. msg_ICH      db 'Intel ICH',  13,10, 0
  1329. msg_ICH0     db 'Intel ICH0', 13,10, 0
  1330. msg_ICH2     db 'Intel ICH2', 13,10, 0
  1331. msg_ICH3     db 'Intel ICH3', 13,10, 0
  1332. msg_ICH4     db 'Intel ICH4', 13,10, 0
  1333. msg_ICH5     db 'Intel ICH5', 13,10, 0
  1334. msg_ICH6     db 'Intel ICH6', 13,10, 0
  1335. msg_ICH7     db 'Intel ICH7', 13,10, 0
  1336. msg_Intel    db 'Intel Corp. ', 0
  1337.  
  1338. msg_NForce   db 'NForce',      13,10, 0
  1339. msg_NForce2  db 'NForce 2',    13,10, 0
  1340. msg_NForce3  db 'NForce 3',    13,10, 0
  1341. msg_MCP04    db 'NForce MCP04',13,10, 0
  1342. msg_CK804    db 'NForce CK804',13,10, 0
  1343. msg_CK8      db 'NForce CK8',  13,10, 0
  1344. msg_CK8S     db 'NForce CK8S', 13,10, 0
  1345. msg_MCP51    db 'NForce MCP51',13,10, 0
  1346.  
  1347. msg_NVidia   db 'NVidia', 0
  1348.  
  1349. szKernel            db 'KERNEL', 0
  1350. sz_sound_srv        db 'SOUND',0
  1351.  
  1352. msgInit      db 'detect hardware...',13,10,0
  1353. msgFail      db 'device not found',13,10,0
  1354. msgAttchIRQ  db 'IRQ line not supported', 13,10, 0
  1355. msgInvIRQ    db 'IRQ line not assigned or invalid', 13,10, 0
  1356. msgPlay      db 'start play', 13,10,0
  1357. msgStop      db 'stop play',  13,10,0
  1358. msgNotify    db 'call notify',13,10,0
  1359. msgIRQ       db 'AC97 IRQ', 13,10,0
  1360. msgInitCtrl  db 'init controller',13,10,0
  1361. msgInitCodec db 'init codec',13,10,0
  1362. msgPrimBuff  db 'create primary buffer',13,10,0
  1363. msgReg       db 'set service handler',13,10,0
  1364. msgOk        db 'service installed',13,10,0
  1365. msgCold      db 'cold reset',13,10,0
  1366. msgWarm      db 'warm reset',13,10,0
  1367. msgWRFail    db 'warm reset failed',13,10,0
  1368. msgCRFail    db 'cold reset failed',13,10,0
  1369. msgCFail     db 'codec not ready',13,10,0
  1370. msgResetOk   db 'reset complete',13,10,0
  1371.  
  1372. section '.data' data readable writable align 16
  1373.  
  1374. pcmout_bdl       rq 32
  1375. buff_list        rd 32
  1376.  
  1377. codec CODEC
  1378. ctrl AC_CNTRL
  1379.  
  1380. lpc_bus  rd 1
  1381. civ_val  rd 1
  1382.  
  1383.  
  1384.