History

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6: (308 commits) ALSA: sound/pci/asihpi: check adapter index in hpi_ioctl ALSA: aloop - Fix possible IRQ lock inversion ALSA: sound/core: merge list_del()/list_add_tail() to list_move_tail() ALSA: ctxfi - use list_move() instead of list_del()/list_add() combination ALSA: firewire - msleep needs delay.h ALSA: firewire-lib, firewire-speakers: handle packet queueing errors ALSA: firewire-lib: allocate DMA buffer separately ALSA: firewire-lib: use no-info SYT for packets without SYT sample ALSA: add LaCie FireWire Speakers/Griffin FireWave Surround driver ALSA: hda - Remove an unused variable in patch_realtek.c ALSA: hda - pin-adc-mux-dmic auto-configuration of 92HD8X codecs ALSA: hda - fix digital mic selection in mixer on 92HD8X codecs ALSA: hda - Move default input-src selection to init part ALSA: hda - Initialize special cases for input src in init phase ALSA: ctxfi - Clear input settings before initialization ALSA: ctxfi - Fix SPDIF status retrieval ALSA: ctxfi - Fix incorrect SPDIF status bit mask ALSA: ctxfi - Fix microphone boost codes/comments ALSA: atiixp - Fix wrong time-out checks during ac-link reset ALSA: intel8x0m: append 'm' to "r_intel8x0" ...

Linus Torvalds committed 15 years ago

Commit d3e458d2 parents f2e1fbb d351cf4254 files · +27080 −9623Browse files

Unified · Split

254 files
  1. arch/arm/mach-shmobile/board-ag5evm.c +0 −10
  2. arch/arm/mach-shmobile/board-ap4evb.c +7 −6
  3. arch/arm/mach-shmobile/board-mackerel.c +7 −6
  4. arch/sh/boards/mach-ecovec24/setup.c +1 −5
  5. arch/sh/boards/mach-se/7724/setup.c +1 −5
  6. drivers/firewire/core-iso.c +1 −0
  7. drivers/firewire/core.h +0 −3
  8. include/linux/firewire.h +7 −0
  9. include/linux/mfd/wm8994/pdata.h +10 −2
  10. include/linux/mfd/wm8994/registers.h +2 −0
  11. include/sound/ac97_codec.h +5 −0
  12. include/sound/control.h +2 −0
  13. include/sound/cs4271.h +24 −0
  14. include/sound/hdspm.h +137 −42
  15. include/sound/mixer_oss.h +3 −0
  16. include/sound/pcm.h +46 −45
  17. include/sound/sh_fsi.h +19 −57
  18. include/sound/soc-dapm.h +16 −0
  19. include/sound/soc.h +135 −12
  20. include/sound/tlv320aic32x4.h +31 −0
  21. include/sound/version.h +1 −1
  22. include/sound/wm8903.h +19 −1
  23. include/sound/wm9081.h +6 −3
  24. include/trace/events/asoc.h +25 −0
  25. sound/Kconfig +2 −0
  26. sound/Makefile +1 −1
  27. sound/core/control.c +56 −12
  28. sound/core/device.c +4 −3
  29. sound/core/memalloc.c +2 −1
  30. sound/core/oss/linear.c +4 −3
  31. sound/core/oss/mixer_oss.c +6 −4
  32. sound/core/oss/mulaw.c +1 −1
  33. sound/core/oss/pcm_oss.c +28 −23
  34. sound/core/oss/pcm_plugin.c +22 −18
  35. sound/core/oss/pcm_plugin.h +6 −5
  36. sound/core/oss/route.c +3 −3
  37. sound/core/pcm.c +5 −5
  38. sound/core/pcm_misc.c +19 −16
  39. sound/core/pcm_native.c +1 −1
  40. sound/core/seq/seq_clientmgr.c +2 −5
  41. sound/core/seq/seq_memory.c +3 −3
  42. sound/core/seq/seq_memory.h +4 −0
  43. sound/core/seq/seq_ports.c +1 −1
  44. sound/core/timer.c +3 −5
  45. sound/core/vmaster.c +1 −1
  46. sound/drivers/aloop.c +9 −10
  47. sound/firewire/Kconfig +25 −0
  48. sound/firewire/Makefile +6 −0
  49. sound/firewire/amdtp.c +562 −0
  50. sound/firewire/amdtp.h +169 −0
  51. sound/firewire/cmp.c +308 −0
  52. sound/firewire/cmp.h +41 −0
  53. sound/firewire/fcp.c +224 −0
  54. sound/firewire/fcp.h +12 −0
  55. sound/firewire/iso-resources.c +232 −0
  56. sound/firewire/iso-resources.h +39 −0
  57. sound/firewire/lib.c +85 −0
  58. sound/firewire/lib.h +19 −0
  59. sound/firewire/packets-buffer.c +74 −0
  60. sound/firewire/packets-buffer.h +26 −0
  61. sound/firewire/speakers.c +858 −0
  62. sound/oss/soundcard.c +20 −36
  63. sound/pci/Kconfig +9 −3
  64. sound/pci/ac97/ac97_codec.c +56 −34
  65. sound/pci/ac97/ac97_patch.c +52 −0
  66. sound/pci/asihpi/asihpi.c +386 −388
  67. sound/pci/asihpi/hpi.h +448 −766
  68. sound/pci/asihpi/hpi6000.c +137 −162
  69. sound/pci/asihpi/hpi6205.c +250 −353
  70. sound/pci/asihpi/hpi6205.h +2 −5
  71. sound/pci/asihpi/hpi_internal.h +530 −588
  72. sound/pci/asihpi/hpicmn.c +265 −215
  73. sound/pci/asihpi/hpicmn.h +11 −13
  74. sound/pci/asihpi/hpidebug.c +5 −152
  75. sound/pci/asihpi/hpidebug.h +20 −303
  76. sound/pci/asihpi/hpidspcd.c +20 −17
  77. sound/pci/asihpi/hpidspcd.h +1 −1
  78. sound/pci/asihpi/hpifunc.c +725 −1773
  79. sound/pci/asihpi/hpimsginit.c +2 −16
  80. sound/pci/asihpi/hpimsginit.h +9 −3
  81. sound/pci/asihpi/hpimsgx.c +51 −152
  82. sound/pci/asihpi/hpioctl.c +46 −44
  83. sound/pci/asihpi/hpios.h +4 −6
  84. sound/pci/atiixp.c +1 −1
  85. sound/pci/atiixp_modem.c +1 −1
  86. sound/pci/au88x0/au88x0_eq.c +2 −1
  87. sound/pci/azt3328.c +402 −48
  88. sound/pci/ctxfi/ctatc.c +1 −1
  89. sound/pci/ctxfi/ctdaio.c +2 −0
  90. sound/pci/ctxfi/cthw20k2.c +18 −10
  91. sound/pci/ctxfi/ctmixer.c +5 −14
  92. sound/pci/ctxfi/ctvmem.c +1 −2
  93. sound/pci/emu10k1/emu10k1_main.c +1 −1
  94. sound/pci/hda/hda_codec.c +105 −0
  95. sound/pci/hda/hda_codec.h +5 −0
  96. sound/pci/hda/hda_intel.c +5 −2
  97. sound/pci/hda/hda_local.h +24 −0
  98. sound/pci/hda/patch_analog.c +10 −107
  99. sound/pci/hda/patch_conexant.c +14 −110
  100. sound/pci/hda/patch_hdmi.c +13 −9
  101. sound/pci/hda/patch_realtek.c +80 −126
  102. sound/pci/hda/patch_sigmatel.c +162 −156
  103. sound/pci/intel8x0m.c +54 −53
  104. sound/pci/rme9652/hdspm.c +3352 −1114
  105. sound/ppc/pmac.c +5 −1
  106. sound/soc/Kconfig +2 −0
  107. sound/soc/Makefile +2 −0
  108. sound/soc/codecs/Kconfig +33 −1
  109. sound/soc/codecs/Makefile +17 −1
  110. sound/soc/codecs/ak4104.c +0 −1
  111. sound/soc/codecs/ak4642.c +24 −0
  112. sound/soc/codecs/cs4270.c +3 −5
  113. sound/soc/codecs/cs4271.c +667 −0
  114. sound/soc/codecs/dfbmcs320.c +72 −0
  115. sound/soc/codecs/lm4857.c +276 −0
  116. sound/soc/codecs/max98088.c +1 −1
  117. sound/soc/codecs/max9850.c +389 −0
  118. sound/soc/codecs/max9850.h +38 −0
  119. sound/soc/codecs/sgtl5000.c +1513 −0
  120. sound/soc/codecs/sgtl5000.h +400 −0
  121. sound/soc/codecs/sn95031.c +949 −0
  122. sound/soc/codecs/sn95031.h +132 −0
  123. sound/soc/codecs/tlv320aic32x4.c +794 −0
  124. sound/soc/codecs/tlv320aic32x4.h +143 −0
  125. sound/soc/codecs/tlv320dac33.c +1 −0
  126. sound/soc/codecs/twl6040.c +2 −2
  127. sound/soc/codecs/wm2000.c +7 −7
  128. sound/soc/codecs/wm8523.c +4 −4
  129. sound/soc/codecs/wm8741.c +8 −5
  130. sound/soc/codecs/wm8753.c +121 −175
  131. sound/soc/codecs/wm8804.c +1 −1
  132. sound/soc/codecs/wm8900.c +1 −1
  133. sound/soc/codecs/wm8903.c +459 −182
  134. sound/soc/codecs/wm8903.h +8 −0
  135. sound/soc/codecs/wm8904.c +27 −16
  136. sound/soc/codecs/wm8955.c +19 −8
  137. sound/soc/codecs/wm8961.c +1 −1
  138. sound/soc/codecs/wm8962.c +23 −13
  139. sound/soc/codecs/wm8978.c +4 −3
  140. sound/soc/codecs/wm8991.c +1427 −0
  141. sound/soc/codecs/wm8991.h +833 −0
  142. sound/soc/codecs/wm8993.c +1 −1
  143. sound/soc/codecs/wm8994-tables.c +6 −6
  144. sound/soc/codecs/wm8994.c +65 −62
  145. sound/soc/codecs/wm8994.h +1 −1
  146. sound/soc/codecs/wm8995.c +98 −5
  147. sound/soc/codecs/wm9081.c +37 −47
  148. sound/soc/codecs/wm9090.c +26 −19
  149. sound/soc/codecs/wm_hubs.c +2 −1
  150. sound/soc/davinci/davinci-i2s.c +19 −9
  151. sound/soc/davinci/davinci-mcasp.c +20 −9
  152. sound/soc/ep93xx/Kconfig +9 −0
  153. sound/soc/ep93xx/Makefile +2 −0
  154. sound/soc/ep93xx/edb93xx.c +142 −0
  155. sound/soc/ep93xx/ep93xx-ac97.c +0 −1
  156. sound/soc/ep93xx/ep93xx-i2s.c +17 −14
  157. sound/soc/ep93xx/ep93xx-pcm.c +2 −2
  158. sound/soc/fsl/mpc8610_hpcd.c +2 −4
  159. sound/soc/fsl/p1022_ds.c +2 −4
  160. sound/soc/imx/Kconfig +10 −0
  161. sound/soc/imx/Makefile +2 −0
  162. sound/soc/imx/imx-ssi.c +4 −1
  163. sound/soc/imx/mx27vis-aic32x4.c +137 −0
  164. sound/soc/mid-x86/Kconfig +14 −0
  165. sound/soc/mid-x86/Makefile +5 −0
  166. sound/soc/mid-x86/mfld_machine.c +452 −0
  167. sound/soc/mid-x86/sst_platform.c +474 −0
  168. sound/soc/mid-x86/sst_platform.h +63 −0
  169. sound/soc/omap/Kconfig +1 −0
  170. sound/soc/omap/rx51.c +123 −8
  171. sound/soc/pxa/raumfeld.c +10 −10
  172. sound/soc/pxa/tosa.c +2 −2
  173. sound/soc/pxa/z2.c +6 −1
  174. sound/soc/pxa/zylonite.c +4 −5
  175. sound/soc/samsung/Kconfig +6 −13
  176. sound/soc/samsung/Makefile +0 −2
  177. sound/soc/samsung/ac97.c +4 −4
  178. sound/soc/samsung/ac97.h +0 −21
  179. sound/soc/samsung/dma.c +5 −8
  180. sound/soc/samsung/dma.h +0 −8
  181. sound/soc/samsung/goni_wm8994.c +1 −9
  182. sound/soc/samsung/h1940_uda1380.c +0 −9
  183. sound/soc/samsung/i2s.c +1 −2
  184. sound/soc/samsung/jive_wm8750.c +0 −11
  185. sound/soc/samsung/lm4857.h +0 −32
  186. sound/soc/samsung/ln2440sbc_alc650.c +0 −7
  187. sound/soc/samsung/neo1973_gta02_wm8753.c +0 −504
  188. sound/soc/samsung/neo1973_wm8753.c +234 −401
  189. sound/soc/samsung/pcm.c +108 −10
  190. sound/soc/samsung/pcm.h +0 −107
  191. sound/soc/samsung/rx1950_uda1380.c +0 −11
  192. sound/soc/samsung/s3c-i2s-v2.c +1 −2
  193. sound/soc/samsung/s3c2412-i2s.c +1 −11
  194. sound/soc/samsung/s3c24xx-i2s.c +1 −13
  195. sound/soc/samsung/s3c24xx_simtec.c +0 −7
  196. sound/soc/samsung/s3c24xx_simtec_hermes.c +0 −10
  197. sound/soc/samsung/s3c24xx_simtec_tlv320aic23.c +0 −12
  198. sound/soc/samsung/s3c24xx_uda134x.c +1 −8
  199. sound/soc/samsung/smartq_wm8987.c +0 −6
  200. sound/soc/samsung/smdk2443_wm9710.c +0 −7
  201. sound/soc/samsung/smdk_spdif.c +0 −5
  202. sound/soc/samsung/smdk_wm8580.c +1 −6
  203. sound/soc/samsung/smdk_wm9713.c +0 −5
  204. sound/soc/samsung/spdif.c +1 −2
  205. sound/soc/sh/fsi-ak4642.c +20 −4
  206. sound/soc/sh/fsi-da7210.c +11 −2
  207. sound/soc/sh/fsi-hdmi.c +72 −5
  208. sound/soc/sh/fsi.c +114 −89
  209. sound/soc/soc-cache.c +188 −198
  210. sound/soc/soc-core.c +372 −176
  211. sound/soc/soc-dapm.c +172 −85
  212. sound/soc/soc-jack.c +56 −2
  213. sound/soc/soc-utils.c +3 −20
  214. sound/soc/tegra/Kconfig +26 −0
  215. sound/soc/tegra/Makefile +15 −0
  216. sound/soc/tegra/harmony.c +393 −0
  217. sound/soc/tegra/tegra_asoc_utils.c +155 −0
  218. sound/soc/tegra/tegra_asoc_utils.h +45 −0
  219. sound/soc/tegra/tegra_das.c +265 −0
  220. sound/soc/tegra/tegra_das.h +135 −0
  221. sound/soc/tegra/tegra_i2s.c +503 −0
  222. sound/soc/tegra/tegra_i2s.h +165 −0
  223. sound/soc/tegra/tegra_pcm.c +404 −0
  224. sound/soc/tegra/tegra_pcm.h +55 −0
  225. sound/sound_core.c +3 −0
  226. sound/usb/6fire/Makefile +3 −0
  227. sound/usb/6fire/chip.c +232 −0
  228. sound/usb/6fire/chip.h +32 −0
  229. sound/usb/6fire/comm.c +176 −0
  230. sound/usb/6fire/comm.h +44 −0
  231. sound/usb/6fire/common.h +30 −0
  232. sound/usb/6fire/control.c +275 −0
  233. sound/usb/6fire/control.h +37 −0
  234. sound/usb/6fire/firmware.c +426 −0
  235. sound/usb/6fire/firmware.h +27 −0
  236. sound/usb/6fire/midi.c +203 −0
  237. sound/usb/6fire/midi.h +46 −0
  238. sound/usb/6fire/pcm.c +688 −0
  239. sound/usb/6fire/pcm.h +76 −0
  240. sound/usb/Kconfig +17 −0
  241. sound/usb/Makefile +1 −1
  242. sound/usb/caiaq/audio.c +1 −0
  243. sound/usb/caiaq/device.c +6 −0
  244. sound/usb/caiaq/device.h +1 −0
  245. sound/usb/card.c +55 −9
  246. sound/usb/midi.c +8 −0
  247. sound/usb/mixer.c +61 −4
  248. sound/usb/mixer.h +2 −0
  249. sound/usb/mixer_quirks.c +161 −13
  250. sound/usb/pcm.c +15 −5
  251. sound/usb/power.h +17 −0
  252. sound/usb/quirks-table.h +14 −0
  253. sound/usb/quirks.c +45 −11
  254. sound/usb/usbaudio.h +5 −1
arch/arm/mach-shmobile/board-ag5evm.c+0−10
@@ -119,13 +119,6 @@ static struct platform_device keysc_device = { · 118 unmodified lines
119119 };
120120
121121 /* FSI A */
122−static struct sh_fsi_platform_info fsi_info = {
123− .porta_flags = SH_FSI_OUT_SLAVE_MODE |
124− SH_FSI_IN_SLAVE_MODE |
125− SH_FSI_OFMT(I2S) |
126− SH_FSI_IFMT(I2S),
127−};
128−
129122 static struct resource fsi_resources[] = {
130123 [0] = {
131124 .name = "FSI",
@@ -144,9 +137,6 @@ static struct platform_device fsi_device = { · 12 unmodified lines
144137 .id = -1,
145138 .num_resources = ARRAY_SIZE(fsi_resources),
146139 .resource = fsi_resources,
147− .dev = {
148− .platform_data = &fsi_info,
149− },
150140 };
151141
152142 static struct resource sh_mmcif_resources[] = {
arch/arm/mach-shmobile/board-ap4evb.c+7−6
@@ -673,16 +673,12 @@ static int fsi_set_rate(struct device *dev, int is_porta, int rate, int enable) · 672 unmodified lines
673673 }
674674
675675 static struct sh_fsi_platform_info fsi_info = {
676− .porta_flags = SH_FSI_BRS_INV |
677− SH_FSI_OUT_SLAVE_MODE |
678− SH_FSI_IN_SLAVE_MODE |
679− SH_FSI_OFMT(PCM) |
680− SH_FSI_IFMT(PCM),
676+ .porta_flags = SH_FSI_BRS_INV,
681677
682678 .portb_flags = SH_FSI_BRS_INV |
683679 SH_FSI_BRM_INV |
684680 SH_FSI_LRS_INV |
685− SH_FSI_OFMT(SPDIF),
681+ SH_FSI_FMT_SPDIF,
686682 .set_rate = fsi_set_rate,
687683 };
688684
@@ -783,6 +779,10 @@ static struct platform_device hdmi_device = { · 94 unmodified lines
783779 },
784780 };
785781
782+static struct platform_device fsi_hdmi_device = {
783+ .name = "sh_fsi2_b_hdmi",
784+};
785+
786786 static long ap4evb_clk_optimize(unsigned long target, unsigned long *best_freq,
787787 unsigned long *parent_freq)
788788 {
@@ -936,6 +936,7 @@ static struct platform_device *ap4evb_devices[] __initdata = { · 147 unmodified lines
936936 &usb1_host_device,
937937 &fsi_device,
938938 &fsi_ak4643_device,
939+ &fsi_hdmi_device,
939940 &sh_mmcif_device,
940941 &lcdc1_device,
941942 &lcdc_device,
arch/arm/mach-shmobile/board-mackerel.c+7−6
@@ -399,6 +399,10 @@ static struct platform_device hdmi_device = { · 398 unmodified lines
399399 },
400400 };
401401
402+static struct platform_device fsi_hdmi_device = {
403+ .name = "sh_fsi2_b_hdmi",
404+};
405+
402406 static int __init hdmi_init_pm_clock(void)
403407 {
404408 struct clk *hdmi_ick = clk_get(&hdmi_device.dev, "ick");
@@ -609,16 +613,12 @@ fsi_set_rate_end: · 204 unmodified lines
609613 }
610614
611615 static struct sh_fsi_platform_info fsi_info = {
612− .porta_flags = SH_FSI_BRS_INV |
613− SH_FSI_OUT_SLAVE_MODE |
614− SH_FSI_IN_SLAVE_MODE |
615− SH_FSI_OFMT(PCM) |
616− SH_FSI_IFMT(PCM),
616+ .porta_flags = SH_FSI_BRS_INV,
617617
618618 .portb_flags = SH_FSI_BRS_INV |
619619 SH_FSI_BRM_INV |
620620 SH_FSI_LRS_INV |
621− SH_FSI_OFMT(SPDIF),
621+ SH_FSI_FMT_SPDIF,
622622
623623 .set_rate = fsi_set_rate,
624624 };
@@ -921,6 +921,7 @@ static struct platform_device *mackerel_devices[] __initdata = { · 296 unmodified lines
921921 &leds_device,
922922 &fsi_device,
923923 &fsi_ak4643_device,
924+ &fsi_hdmi_device,
924925 &sdhi0_device,
925926 #if !defined(CONFIG_MMC_SH_MMCIF)
926927 &sdhi1_device,
arch/sh/boards/mach-ecovec24/setup.c+1−5
@@ -725,11 +725,7 @@ static struct platform_device camera_devices[] = { · 724 unmodified lines
725725
726726 /* FSI */
727727 static struct sh_fsi_platform_info fsi_info = {
728− .portb_flags = SH_FSI_BRS_INV |
729− SH_FSI_OUT_SLAVE_MODE |
730− SH_FSI_IN_SLAVE_MODE |
731− SH_FSI_OFMT(I2S) |
732− SH_FSI_IFMT(I2S),
728+ .portb_flags = SH_FSI_BRS_INV,
733729 };
734730
735731 static struct resource fsi_resources[] = {
arch/sh/boards/mach-se/7724/setup.c+1−5
@@ -286,11 +286,7 @@ static struct platform_device ceu1_device = { · 285 unmodified lines
286286 /* FSI */
287287 /* change J20, J21, J22 pin to 1-2 connection to use slave mode */
288288 static struct sh_fsi_platform_info fsi_info = {
289− .porta_flags = SH_FSI_BRS_INV |
290− SH_FSI_OUT_SLAVE_MODE |
291− SH_FSI_IN_SLAVE_MODE |
292− SH_FSI_OFMT(PCM) |
293− SH_FSI_IFMT(PCM),
289+ .porta_flags = SH_FSI_BRS_INV,
294290 };
295291
296292 static struct resource fsi_resources[] = {
drivers/firewire/core-iso.c+1−0
@@ -362,3 +362,4 @@ void fw_iso_resource_manage(struct fw_card *card, int generation, · 361 unmodified lines
362362 *channel = ret;
363363 }
364364 }
365+EXPORT_SYMBOL(fw_iso_resource_manage);
drivers/firewire/core.h+0−3
@@ -147,9 +147,6 @@ void fw_node_event(struct fw_card *card, struct fw_node *node, int event); · 146 unmodified lines
147147 /* -iso */
148148
149149 int fw_iso_buffer_map(struct fw_iso_buffer *buffer, struct vm_area_struct *vma);
150−void fw_iso_resource_manage(struct fw_card *card, int generation,
151− u64 channels_mask, int *channel, int *bandwidth,
152− bool allocate, __be32 buffer[2]);
153150
154151
155152 /* -topology */
include/linux/firewire.h+7−0
@@ -42,6 +42,10 @@ · 41 unmodified lines
4242 #define CSR_BROADCAST_CHANNEL 0x234
4343 #define CSR_CONFIG_ROM 0x400
4444 #define CSR_CONFIG_ROM_END 0x800
45+#define CSR_OMPR 0x900
46+#define CSR_OPCR(i) (0x904 + (i) * 4)
47+#define CSR_IMPR 0x980
48+#define CSR_IPCR(i) (0x984 + (i) * 4)
4549 #define CSR_FCP_COMMAND 0xB00
4650 #define CSR_FCP_RESPONSE 0xD00
4751 #define CSR_FCP_END 0xF00
@@ -441,5 +445,8 @@ int fw_iso_context_start(struct fw_iso_context *ctx, · 393 unmodified lines
441445 int cycle, int sync, int tags);
442446 int fw_iso_context_stop(struct fw_iso_context *ctx);
443447 void fw_iso_context_destroy(struct fw_iso_context *ctx);
448+void fw_iso_resource_manage(struct fw_card *card, int generation,
449+ u64 channels_mask, int *channel, int *bandwidth,
450+ bool allocate, __be32 buffer[2]);
444451
445452 #endif /* _LINUX_FIREWIRE_H */
include/linux/mfd/wm8994/pdata.h+10−2
@@ -103,13 +103,21 @@ struct wm8994_pdata { · 102 unmodified lines
103103 unsigned int lineout1fb:1;
104104 unsigned int lineout2fb:1;
105105
106− /* Microphone biases: 0=0.9*AVDD1 1=0.65*AVVD1 */
106+ /* IRQ for microphone detection if brought out directly as a
107+ * signal.
108+ */
109+ int micdet_irq;
110+
111+ /* WM8994 microphone biases: 0=0.9*AVDD1 1=0.65*AVVD1 */
107112 unsigned int micbias1_lvl:1;
108113 unsigned int micbias2_lvl:1;
109114
110− /* Jack detect threashold levels, see datasheet for values */
115+ /* WM8994 jack detect threashold levels, see datasheet for values */
111116 unsigned int jd_scthr:2;
112117 unsigned int jd_thr:2;
118+
119+ /* WM8958 microphone bias configuration */
120+ int micbias[2];
113121 };
114122
115123 #endif
include/linux/mfd/wm8994/registers.h+2−0
@@ -63,6 +63,8 @@ · 62 unmodified lines
6363 #define WM8994_MICBIAS 0x3A
6464 #define WM8994_LDO_1 0x3B
6565 #define WM8994_LDO_2 0x3C
66+#define WM8958_MICBIAS1 0x3D
67+#define WM8958_MICBIAS2 0x3E
6668 #define WM8994_CHARGE_PUMP_1 0x4C
6769 #define WM8958_CHARGE_PUMP_2 0x4D
6870 #define WM8994_CLASS_W_1 0x51
include/sound/ac97_codec.h+5−0
@@ -96,6 +96,10 @@ · 95 unmodified lines
9696 #define AC97_FUNC_INFO 0x68 /* Function Information */
9797 #define AC97_SENSE_INFO 0x6a /* Sense Details */
9898
99+/* volume controls */
100+#define AC97_MUTE_MASK_MONO 0x8000
101+#define AC97_MUTE_MASK_STEREO 0x8080
102+
99103 /* slot allocation */
100104 #define AC97_SLOT_TAG 0
101105 #define AC97_SLOT_CMD_ADDR 1
@@ -138,6 +142,7 @@ · 36 unmodified lines
138142 #define AC97_BC_18BIT_ADC 0x0100 /* 18-bit ADC resolution */
139143 #define AC97_BC_20BIT_ADC 0x0200 /* 20-bit ADC resolution */
140144 #define AC97_BC_ADC_MASK 0x0300
145+#define AC97_BC_3D_TECH_ID_MASK 0x7c00 /* Per-vendor ID of 3D enhancement */
141146
142147 /* general purpose */
143148 #define AC97_GP_DRSS_MASK 0x0c00 /* double rate slot select */
include/sound/control.h+2−0
@@ -115,6 +115,8 @@ int snd_ctl_add(struct snd_card * card, struct snd_kcontrol * kcontrol); · 114 unmodified lines
115115 int snd_ctl_remove(struct snd_card * card, struct snd_kcontrol * kcontrol);
116116 int snd_ctl_remove_id(struct snd_card * card, struct snd_ctl_elem_id *id);
117117 int snd_ctl_rename_id(struct snd_card * card, struct snd_ctl_elem_id *src_id, struct snd_ctl_elem_id *dst_id);
118+int snd_ctl_activate_id(struct snd_card *card, struct snd_ctl_elem_id *id,
119+ int active);
118120 struct snd_kcontrol *snd_ctl_find_numid(struct snd_card * card, unsigned int numid);
119121 struct snd_kcontrol *snd_ctl_find_id(struct snd_card * card, struct snd_ctl_elem_id *id);
120122
include/sound/cs4271.h+24−0
@@ -0,0 +1,24 @@
1+/*
2+ * Definitions for CS4271 ASoC codec driver
3+ *
4+ * Copyright (c) 2010 Alexander Sverdlin <subaparts@yandex.ru>
5+ *
6+ * This program is free software; you can redistribute it and/or
7+ * modify it under the terms of the GNU General Public License
8+ * as published by the Free Software Foundation; either version 2
9+ * of the License, or (at your option) any later version.
10+ *
11+ * This program is distributed in the hope that it will be useful,
12+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+ * GNU General Public License for more details.
15+ */
16+
17+#ifndef __CS4271_H
18+#define __CS4271_H
19+
20+struct cs4271_platform_data {
21+ int gpio_nreset; /* GPIO driving Reset pin, if any */
22+};
23+
24+#endif /* __CS4271_H */
include/sound/hdspm.h+137−42
@@ -3,8 +3,8 @@ · 2 unmodified lines
33 /*
44 * Copyright (C) 2003 Winfried Ritsch (IEM)
55 * based on hdsp.h from Thomas Charbonnel (thomas@undata.org)
6− *
7− *
6+ *
7+ *
88 * This program is free software; you can redistribute it and/or modify
99 * it under the terms of the GNU General Public License as published by
1010 * the Free Software Foundation; either version 2 of the License, or
@@ -23,50 +23,41 @@ · 12 unmodified lines
2323 /* Maximum channels is 64 even on 56Mode you have 64playbacks to matrix */
2424 #define HDSPM_MAX_CHANNELS 64
2525
26−/* -------------------- IOCTL Peak/RMS Meters -------------------- */
27−
28−/* peam rms level structure like we get from hardware
29−
30− maybe in future we can memory map it so I just copy it
31− to user on ioctl call now an dont change anything
32− rms are made out of low and high values
33− where (long) ????_rms = (????_rms_l >> 8) + ((????_rms_h & 0xFFFFFF00)<<24)
34− (i asume so from the code)
35−*/
36−
37−struct hdspm_peak_rms {
38−
39− unsigned int level_offset[1024];
26+enum hdspm_io_type {
27+ MADI,
28+ MADIface,
29+ AIO,
30+ AES32,
31+ RayDAT
32+};
4033
41− unsigned int input_peak[64];
42− unsigned int playback_peak[64];
43− unsigned int output_peak[64];
44− unsigned int xxx_peak[64]; /* not used */
34+enum hdspm_speed {
35+ ss,
36+ ds,
37+ qs
38+};
4539
46− unsigned int reserved[256]; /* not used */
40+/* -------------------- IOCTL Peak/RMS Meters -------------------- */
4741
48− unsigned int input_rms_l[64];
49− unsigned int playback_rms_l[64];
50− unsigned int output_rms_l[64];
51− unsigned int xxx_rms_l[64]; /* not used */
42+struct hdspm_peak_rms {
43+ uint32_t input_peaks[64];
44+ uint32_t playback_peaks[64];
45+ uint32_t output_peaks[64];
5246
53− unsigned int input_rms_h[64];
54− unsigned int playback_rms_h[64];
55− unsigned int output_rms_h[64];
56− unsigned int xxx_rms_h[64]; /* not used */
57−};
47+ uint64_t input_rms[64];
48+ uint64_t playback_rms[64];
49+ uint64_t output_rms[64];
5850
59−struct hdspm_peak_rms_ioctl {
60− struct hdspm_peak_rms *peak;
51+ uint8_t speed; /* enum {ss, ds, qs} */
52+ int status2;
6153 };
6254
63−/* use indirect access due to the limit of ioctl bit size */
6455 #define SNDRV_HDSPM_IOCTL_GET_PEAK_RMS \
65− _IOR('H', 0x40, struct hdspm_peak_rms_ioctl)
56+ _IOR('H', 0x42, struct hdspm_peak_rms)
6657
6758 /* ------------ CONFIG block IOCTL ---------------------- */
6859
69−struct hdspm_config_info {
60+struct hdspm_config {
7061 unsigned char pref_sync_ref;
7162 unsigned char wordclock_sync_check;
7263 unsigned char madi_sync_check;
@@ -80,18 +71,121 @@ struct hdspm_config_info { · 7 unmodified lines
8071 unsigned int analog_out;
8172 };
8273
83−#define SNDRV_HDSPM_IOCTL_GET_CONFIG_INFO \
84− _IOR('H', 0x41, struct hdspm_config_info)
74+#define SNDRV_HDSPM_IOCTL_GET_CONFIG \
75+ _IOR('H', 0x41, struct hdspm_config)
76+
77+/**
78+ * If there's a TCO (TimeCode Option) board installed,
79+ * there are further options and status data available.
80+ * The hdspm_ltc structure contains the current SMPTE
81+ * timecode and some status information and can be
82+ * obtained via SNDRV_HDSPM_IOCTL_GET_LTC or in the
83+ * hdspm_status struct.
84+ **/
85+
86+enum hdspm_ltc_format {
87+ format_invalid,
88+ fps_24,
89+ fps_25,
90+ fps_2997,
91+ fps_30
92+};
93+
94+enum hdspm_ltc_frame {
95+ frame_invalid,
96+ drop_frame,
97+ full_frame
98+};
99+
100+enum hdspm_ltc_input_format {
101+ ntsc,
102+ pal,
103+ no_video
104+};
105+
106+struct hdspm_ltc {
107+ unsigned int ltc;
85108
109+ enum hdspm_ltc_format format;
110+ enum hdspm_ltc_frame frame;
111+ enum hdspm_ltc_input_format input_format;
112+};
113+
114+#define SNDRV_HDSPM_IOCTL_GET_LTC _IOR('H', 0x46, struct hdspm_mixer_ioctl)
115+
116+/**
117+ * The status data reflects the device's current state
118+ * as determined by the card's configuration and
119+ * connection status.
120+ **/
121+
122+enum hdspm_sync {
123+ hdspm_sync_no_lock = 0,
124+ hdspm_sync_lock = 1,
125+ hdspm_sync_sync = 2
126+};
86127
87−/* get Soundcard Version */
128+enum hdspm_madi_input {
129+ hdspm_input_optical = 0,
130+ hdspm_input_coax = 1
131+};
132+
133+enum hdspm_madi_channel_format {
134+ hdspm_format_ch_64 = 0,
135+ hdspm_format_ch_56 = 1
136+};
137+
138+enum hdspm_madi_frame_format {
139+ hdspm_frame_48 = 0,
140+ hdspm_frame_96 = 1
141+};
142+
143+enum hdspm_syncsource {
144+ syncsource_wc = 0,
145+ syncsource_madi = 1,
146+ syncsource_tco = 2,
147+ syncsource_sync = 3,
148+ syncsource_none = 4
149+};
150+
151+struct hdspm_status {
152+ uint8_t card_type; /* enum hdspm_io_type */
153+ enum hdspm_syncsource autosync_source;
154+
155+ uint64_t card_clock;
156+ uint32_t master_period;
157+
158+ union {
159+ struct {
160+ uint8_t sync_wc; /* enum hdspm_sync */
161+ uint8_t sync_madi; /* enum hdspm_sync */
162+ uint8_t sync_tco; /* enum hdspm_sync */
163+ uint8_t sync_in; /* enum hdspm_sync */
164+ uint8_t madi_input; /* enum hdspm_madi_input */
165+ uint8_t channel_format; /* enum hdspm_madi_channel_format */
166+ uint8_t frame_format; /* enum hdspm_madi_frame_format */
167+ } madi;
168+ } card_specific;
169+};
170+
171+#define SNDRV_HDSPM_IOCTL_GET_STATUS \
172+ _IOR('H', 0x47, struct hdspm_status)
173+
174+/**
175+ * Get information about the card and its add-ons.
176+ **/
177+
178+#define HDSPM_ADDON_TCO 1
88179
89180 struct hdspm_version {
181+ uint8_t card_type; /* enum hdspm_io_type */
182+ char cardname[20];
183+ unsigned int serial;
90184 unsigned short firmware_rev;
185+ int addons;
91186 };
92187
93−#define SNDRV_HDSPM_IOCTL_GET_VERSION _IOR('H', 0x43, struct hdspm_version)
94−
188+#define SNDRV_HDSPM_IOCTL_GET_VERSION _IOR('H', 0x48, struct hdspm_version)
95189
96190 /* ------------- get Matrix Mixer IOCTL --------------- */
97191
@@ -103,7 +197,7 @@ struct hdspm_version { · 5 unmodified lines
103197 /* equivalent to hardware definition, maybe for future feature of mmap of
104198 * them
105199 */
106−/* each of 64 outputs has 64 infader and 64 outfader:
200+/* each of 64 outputs has 64 infader and 64 outfader:
107201 Ins to Outs mixer[out].in[in], Outstreams to Outs mixer[out].pb[pb] */
108202
109203 #define HDSPM_MIXER_CHANNELS HDSPM_MAX_CHANNELS
@@ -131,4 +225,5 @@ typedef struct hdspm_version hdspm_version_t; · 21 unmodified lines
131225 typedef struct hdspm_channelfader snd_hdspm_channelfader_t;
132226 typedef struct hdspm_mixer hdspm_mixer_t;
133227
134−#endif /* __SOUND_HDSPM_H */
228+
229+#endif
include/sound/mixer_oss.h+3−0
@@ -73,6 +73,9 @@ struct snd_mixer_oss_file { · 72 unmodified lines
7373 struct snd_mixer_oss *mixer;
7474 };
7575
76+int snd_mixer_oss_ioctl_card(struct snd_card *card,
77+ unsigned int cmd, unsigned long arg);
78+
7679 #endif /* CONFIG_SND_MIXER_OSS */
7780
7881 #endif /* __SOUND_MIXER_OSS_H */
include/sound/pcm.h+46−45
@@ -136,48 +136,49 @@ struct snd_pcm_ops { · 135 unmodified lines
136136 SNDRV_PCM_RATE_88200|SNDRV_PCM_RATE_96000)
137137 #define SNDRV_PCM_RATE_8000_192000 (SNDRV_PCM_RATE_8000_96000|SNDRV_PCM_RATE_176400|\
138138 SNDRV_PCM_RATE_192000)
139−#define SNDRV_PCM_FMTBIT_S8 (1ULL << SNDRV_PCM_FORMAT_S8)
140−#define SNDRV_PCM_FMTBIT_U8 (1ULL << SNDRV_PCM_FORMAT_U8)
141−#define SNDRV_PCM_FMTBIT_S16_LE (1ULL << SNDRV_PCM_FORMAT_S16_LE)
142−#define SNDRV_PCM_FMTBIT_S16_BE (1ULL << SNDRV_PCM_FORMAT_S16_BE)
143−#define SNDRV_PCM_FMTBIT_U16_LE (1ULL << SNDRV_PCM_FORMAT_U16_LE)
144−#define SNDRV_PCM_FMTBIT_U16_BE (1ULL << SNDRV_PCM_FORMAT_U16_BE)
145−#define SNDRV_PCM_FMTBIT_S24_LE (1ULL << SNDRV_PCM_FORMAT_S24_LE)
146−#define SNDRV_PCM_FMTBIT_S24_BE (1ULL << SNDRV_PCM_FORMAT_S24_BE)
147−#define SNDRV_PCM_FMTBIT_U24_LE (1ULL << SNDRV_PCM_FORMAT_U24_LE)
148−#define SNDRV_PCM_FMTBIT_U24_BE (1ULL << SNDRV_PCM_FORMAT_U24_BE)
149−#define SNDRV_PCM_FMTBIT_S32_LE (1ULL << SNDRV_PCM_FORMAT_S32_LE)
150−#define SNDRV_PCM_FMTBIT_S32_BE (1ULL << SNDRV_PCM_FORMAT_S32_BE)
151−#define SNDRV_PCM_FMTBIT_U32_LE (1ULL << SNDRV_PCM_FORMAT_U32_LE)
152−#define SNDRV_PCM_FMTBIT_U32_BE (1ULL << SNDRV_PCM_FORMAT_U32_BE)
153−#define SNDRV_PCM_FMTBIT_FLOAT_LE (1ULL << SNDRV_PCM_FORMAT_FLOAT_LE)
154−#define SNDRV_PCM_FMTBIT_FLOAT_BE (1ULL << SNDRV_PCM_FORMAT_FLOAT_BE)
155−#define SNDRV_PCM_FMTBIT_FLOAT64_LE (1ULL << SNDRV_PCM_FORMAT_FLOAT64_LE)
156−#define SNDRV_PCM_FMTBIT_FLOAT64_BE (1ULL << SNDRV_PCM_FORMAT_FLOAT64_BE)
157−#define SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE (1ULL << SNDRV_PCM_FORMAT_IEC958_SUBFRAME_LE)
158−#define SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_BE (1ULL << SNDRV_PCM_FORMAT_IEC958_SUBFRAME_BE)
159−#define SNDRV_PCM_FMTBIT_MU_LAW (1ULL << SNDRV_PCM_FORMAT_MU_LAW)
160−#define SNDRV_PCM_FMTBIT_A_LAW (1ULL << SNDRV_PCM_FORMAT_A_LAW)
161−#define SNDRV_PCM_FMTBIT_IMA_ADPCM (1ULL << SNDRV_PCM_FORMAT_IMA_ADPCM)
162−#define SNDRV_PCM_FMTBIT_MPEG (1ULL << SNDRV_PCM_FORMAT_MPEG)
163−#define SNDRV_PCM_FMTBIT_GSM (1ULL << SNDRV_PCM_FORMAT_GSM)
164−#define SNDRV_PCM_FMTBIT_SPECIAL (1ULL << SNDRV_PCM_FORMAT_SPECIAL)
165−#define SNDRV_PCM_FMTBIT_S24_3LE (1ULL << SNDRV_PCM_FORMAT_S24_3LE)
166−#define SNDRV_PCM_FMTBIT_U24_3LE (1ULL << SNDRV_PCM_FORMAT_U24_3LE)
167−#define SNDRV_PCM_FMTBIT_S24_3BE (1ULL << SNDRV_PCM_FORMAT_S24_3BE)
168−#define SNDRV_PCM_FMTBIT_U24_3BE (1ULL << SNDRV_PCM_FORMAT_U24_3BE)
169−#define SNDRV_PCM_FMTBIT_S20_3LE (1ULL << SNDRV_PCM_FORMAT_S20_3LE)
170−#define SNDRV_PCM_FMTBIT_U20_3LE (1ULL << SNDRV_PCM_FORMAT_U20_3LE)
171−#define SNDRV_PCM_FMTBIT_S20_3BE (1ULL << SNDRV_PCM_FORMAT_S20_3BE)
172−#define SNDRV_PCM_FMTBIT_U20_3BE (1ULL << SNDRV_PCM_FORMAT_U20_3BE)
173−#define SNDRV_PCM_FMTBIT_S18_3LE (1ULL << SNDRV_PCM_FORMAT_S18_3LE)
174−#define SNDRV_PCM_FMTBIT_U18_3LE (1ULL << SNDRV_PCM_FORMAT_U18_3LE)
175−#define SNDRV_PCM_FMTBIT_S18_3BE (1ULL << SNDRV_PCM_FORMAT_S18_3BE)
176−#define SNDRV_PCM_FMTBIT_U18_3BE (1ULL << SNDRV_PCM_FORMAT_U18_3BE)
177−#define SNDRV_PCM_FMTBIT_G723_24 (1ULL << SNDRV_PCM_FORMAT_G723_24)
178−#define SNDRV_PCM_FMTBIT_G723_24_1B (1ULL << SNDRV_PCM_FORMAT_G723_24_1B)
179−#define SNDRV_PCM_FMTBIT_G723_40 (1ULL << SNDRV_PCM_FORMAT_G723_40)
180−#define SNDRV_PCM_FMTBIT_G723_40_1B (1ULL << SNDRV_PCM_FORMAT_G723_40_1B)
139+#define _SNDRV_PCM_FMTBIT(fmt) (1ULL << (__force int)SNDRV_PCM_FORMAT_##fmt)
140+#define SNDRV_PCM_FMTBIT_S8 _SNDRV_PCM_FMTBIT(S8)
141+#define SNDRV_PCM_FMTBIT_U8 _SNDRV_PCM_FMTBIT(U8)
142+#define SNDRV_PCM_FMTBIT_S16_LE _SNDRV_PCM_FMTBIT(S16_LE)
143+#define SNDRV_PCM_FMTBIT_S16_BE _SNDRV_PCM_FMTBIT(S16_BE)
144+#define SNDRV_PCM_FMTBIT_U16_LE _SNDRV_PCM_FMTBIT(U16_LE)
145+#define SNDRV_PCM_FMTBIT_U16_BE _SNDRV_PCM_FMTBIT(U16_BE)
146+#define SNDRV_PCM_FMTBIT_S24_LE _SNDRV_PCM_FMTBIT(S24_LE)
147+#define SNDRV_PCM_FMTBIT_S24_BE _SNDRV_PCM_FMTBIT(S24_BE)
148+#define SNDRV_PCM_FMTBIT_U24_LE _SNDRV_PCM_FMTBIT(U24_LE)
149+#define SNDRV_PCM_FMTBIT_U24_BE _SNDRV_PCM_FMTBIT(U24_BE)
150+#define SNDRV_PCM_FMTBIT_S32_LE _SNDRV_PCM_FMTBIT(S32_LE)
151+#define SNDRV_PCM_FMTBIT_S32_BE _SNDRV_PCM_FMTBIT(S32_BE)
152+#define SNDRV_PCM_FMTBIT_U32_LE _SNDRV_PCM_FMTBIT(U32_LE)
153+#define SNDRV_PCM_FMTBIT_U32_BE _SNDRV_PCM_FMTBIT(U32_BE)
154+#define SNDRV_PCM_FMTBIT_FLOAT_LE _SNDRV_PCM_FMTBIT(FLOAT_LE)
155+#define SNDRV_PCM_FMTBIT_FLOAT_BE _SNDRV_PCM_FMTBIT(FLOAT_BE)
156+#define SNDRV_PCM_FMTBIT_FLOAT64_LE _SNDRV_PCM_FMTBIT(FLOAT64_LE)
157+#define SNDRV_PCM_FMTBIT_FLOAT64_BE _SNDRV_PCM_FMTBIT(FLOAT64_BE)
158+#define SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE _SNDRV_PCM_FMTBIT(IEC958_SUBFRAME_LE)
159+#define SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_BE _SNDRV_PCM_FMTBIT(IEC958_SUBFRAME_BE)
160+#define SNDRV_PCM_FMTBIT_MU_LAW _SNDRV_PCM_FMTBIT(MU_LAW)
161+#define SNDRV_PCM_FMTBIT_A_LAW _SNDRV_PCM_FMTBIT(A_LAW)
162+#define SNDRV_PCM_FMTBIT_IMA_ADPCM _SNDRV_PCM_FMTBIT(IMA_ADPCM)
163+#define SNDRV_PCM_FMTBIT_MPEG _SNDRV_PCM_FMTBIT(MPEG)
164+#define SNDRV_PCM_FMTBIT_GSM _SNDRV_PCM_FMTBIT(GSM)
165+#define SNDRV_PCM_FMTBIT_SPECIAL _SNDRV_PCM_FMTBIT(SPECIAL)
166+#define SNDRV_PCM_FMTBIT_S24_3LE _SNDRV_PCM_FMTBIT(S24_3LE)
167+#define SNDRV_PCM_FMTBIT_U24_3LE _SNDRV_PCM_FMTBIT(U24_3LE)
168+#define SNDRV_PCM_FMTBIT_S24_3BE _SNDRV_PCM_FMTBIT(S24_3BE)
169+#define SNDRV_PCM_FMTBIT_U24_3BE _SNDRV_PCM_FMTBIT(U24_3BE)
170+#define SNDRV_PCM_FMTBIT_S20_3LE _SNDRV_PCM_FMTBIT(S20_3LE)
171+#define SNDRV_PCM_FMTBIT_U20_3LE _SNDRV_PCM_FMTBIT(U20_3LE)
172+#define SNDRV_PCM_FMTBIT_S20_3BE _SNDRV_PCM_FMTBIT(S20_3BE)
173+#define SNDRV_PCM_FMTBIT_U20_3BE _SNDRV_PCM_FMTBIT(U20_3BE)
174+#define SNDRV_PCM_FMTBIT_S18_3LE _SNDRV_PCM_FMTBIT(S18_3LE)
175+#define SNDRV_PCM_FMTBIT_U18_3LE _SNDRV_PCM_FMTBIT(U18_3LE)
176+#define SNDRV_PCM_FMTBIT_S18_3BE _SNDRV_PCM_FMTBIT(S18_3BE)
177+#define SNDRV_PCM_FMTBIT_U18_3BE _SNDRV_PCM_FMTBIT(U18_3BE)
178+#define SNDRV_PCM_FMTBIT_G723_24 _SNDRV_PCM_FMTBIT(G723_24)
179+#define SNDRV_PCM_FMTBIT_G723_24_1B _SNDRV_PCM_FMTBIT(G723_24_1B)
180+#define SNDRV_PCM_FMTBIT_G723_40 _SNDRV_PCM_FMTBIT(G723_40)
181+#define SNDRV_PCM_FMTBIT_G723_40_1B _SNDRV_PCM_FMTBIT(G723_40_1B)
181182
182183 #ifdef SNDRV_LITTLE_ENDIAN
183184 #define SNDRV_PCM_FMTBIT_S16 SNDRV_PCM_FMTBIT_S16_LE
@@ -490,7 +491,7 @@ int snd_pcm_info_user(struct snd_pcm_substream *substream, · 306 unmodified lines
490491 int snd_pcm_status(struct snd_pcm_substream *substream,
491492 struct snd_pcm_status *status);
492493 int snd_pcm_start(struct snd_pcm_substream *substream);
493−int snd_pcm_stop(struct snd_pcm_substream *substream, int status);
494+int snd_pcm_stop(struct snd_pcm_substream *substream, snd_pcm_state_t status);
494495 int snd_pcm_drain_done(struct snd_pcm_substream *substream);
495496 #ifdef CONFIG_PM
496497 int snd_pcm_suspend(struct snd_pcm_substream *substream);
@@ -748,8 +749,8 @@ static inline const struct snd_interval *hw_param_interval_c(const struct snd_pc · 251 unmodified lines
748749 return &params->intervals[var - SNDRV_PCM_HW_PARAM_FIRST_INTERVAL];
749750 }
750751
751−#define params_access(p) snd_mask_min(hw_param_mask((p), SNDRV_PCM_HW_PARAM_ACCESS))
752−#define params_format(p) snd_mask_min(hw_param_mask((p), SNDRV_PCM_HW_PARAM_FORMAT))
752+#define params_access(p) ((__force snd_pcm_access_t)snd_mask_min(hw_param_mask((p), SNDRV_PCM_HW_PARAM_ACCESS)))
753+#define params_format(p) ((__force snd_pcm_format_t)snd_mask_min(hw_param_mask((p), SNDRV_PCM_HW_PARAM_FORMAT)))
753754 #define params_subformat(p) snd_mask_min(hw_param_mask((p), SNDRV_PCM_HW_PARAM_SUBFORMAT))
754755 #define params_channels(p) hw_param_interval((p), SNDRV_PCM_HW_PARAM_CHANNELS)->min
755756 #define params_rate(p) hw_param_interval((p), SNDRV_PCM_HW_PARAM_RATE)->min
include/sound/sh_fsi.h+19−57
@@ -15,67 +15,29 @@ · 14 unmodified lines
1515 #define FSI_PORT_A 0
1616 #define FSI_PORT_B 1
1717
18−/* flags format
19−
20− * 0xABCDEEFF
21− *
22− * A: channel size for TDM (input)
23− * B: channel size for TDM (ooutput)
24− * C: inversion
25− * D: mode
26− * E: input format
27− * F: output format
28− */
29−
3018 #include <linux/clk.h>
3119 #include <sound/soc.h>
3220
33−/* TDM channel */
34−#define SH_FSI_SET_CH_I(x) ((x & 0xF) << 28)
35−#define SH_FSI_SET_CH_O(x) ((x & 0xF) << 24)
36−
37−#define SH_FSI_CH_IMASK 0xF0000000
38−#define SH_FSI_CH_OMASK 0x0F000000
39−#define SH_FSI_GET_CH_I(x) ((x & SH_FSI_CH_IMASK) >> 28)
40−#define SH_FSI_GET_CH_O(x) ((x & SH_FSI_CH_OMASK) >> 24)
41−
42−/* clock inversion */
43−#define SH_FSI_INVERSION_MASK 0x00F00000
44−#define SH_FSI_LRM_INV (1 << 20)
45−#define SH_FSI_BRM_INV (1 << 21)
46−#define SH_FSI_LRS_INV (1 << 22)
47−#define SH_FSI_BRS_INV (1 << 23)
48−
49−/* mode */
50−#define SH_FSI_MODE_MASK 0x000F0000
51−#define SH_FSI_IN_SLAVE_MODE (1 << 16) /* default master mode */
52−#define SH_FSI_OUT_SLAVE_MODE (1 << 17) /* default master mode */
53−
54−/* DI format */
55−#define SH_FSI_FMT_MASK 0x000000FF
56−#define SH_FSI_IFMT(x) (((SH_FSI_FMT_ ## x) & SH_FSI_FMT_MASK) << 8)
57−#define SH_FSI_OFMT(x) (((SH_FSI_FMT_ ## x) & SH_FSI_FMT_MASK) << 0)
58−#define SH_FSI_GET_IFMT(x) ((x >> 8) & SH_FSI_FMT_MASK)
59−#define SH_FSI_GET_OFMT(x) ((x >> 0) & SH_FSI_FMT_MASK)
60−
61−#define SH_FSI_FMT_MONO 0
62−#define SH_FSI_FMT_MONO_DELAY 1
63−#define SH_FSI_FMT_PCM 2
64−#define SH_FSI_FMT_I2S 3
65−#define SH_FSI_FMT_TDM 4
66−#define SH_FSI_FMT_TDM_DELAY 5
67−#define SH_FSI_FMT_SPDIF 6
68−
69−
70−#define SH_FSI_IFMT_TDM_CH(x) \
71− (SH_FSI_IFMT(TDM) | SH_FSI_SET_CH_I(x))
72−#define SH_FSI_IFMT_TDM_DELAY_CH(x) \
73− (SH_FSI_IFMT(TDM_DELAY) | SH_FSI_SET_CH_I(x))
21+/*
22+ * flags format
23+ *
24+ * 0x000000BA
25+ *
26+ * A: inversion
27+ * B: format mode
28+ */
7429
75−#define SH_FSI_OFMT_TDM_CH(x) \
76− (SH_FSI_OFMT(TDM) | SH_FSI_SET_CH_O(x))
77−#define SH_FSI_OFMT_TDM_DELAY_CH(x) \
78− (SH_FSI_OFMT(TDM_DELAY) | SH_FSI_SET_CH_O(x))
30+/* A: clock inversion */
31+#define SH_FSI_INVERSION_MASK 0x0000000F
32+#define SH_FSI_LRM_INV (1 << 0)
33+#define SH_FSI_BRM_INV (1 << 1)
34+#define SH_FSI_LRS_INV (1 << 2)
35+#define SH_FSI_BRS_INV (1 << 3)
36+
37+/* B: format mode */
38+#define SH_FSI_FMT_MASK 0x000000F0
39+#define SH_FSI_FMT_DAI (0 << 4)
40+#define SH_FSI_FMT_SPDIF (1 << 4)
7941
8042
8143 /*
include/sound/soc-dapm.h+16−0
@@ -157,6 +157,18 @@ · 156 unmodified lines
157157 .invert = winvert, .kcontrols = wcontrols, .num_kcontrols = 1, \
158158 .event = wevent, .event_flags = wflags}
159159
160+/* additional sequencing control within an event type */
161+#define SND_SOC_DAPM_PGA_S(wname, wsubseq, wreg, wshift, winvert, \
162+ wevent, wflags) \
163+{ .id = snd_soc_dapm_pga, .name = wname, .reg = wreg, .shift = wshift, \
164+ .invert = winvert, .event = wevent, .event_flags = wflags, \
165+ .subseq = wsubseq}
166+#define SND_SOC_DAPM_SUPPLY_S(wname, wsubseq, wreg, wshift, winvert, wevent, \
167+ wflags) \
168+{ .id = snd_soc_dapm_supply, .name = wname, .reg = wreg, \
169+ .shift = wshift, .invert = winvert, .event = wevent, \
170+ .event_flags = wflags, .subseq = wsubseq}
171+
160172 /* Simplified versions of above macros, assuming wncontrols = ARRAY_SIZE(wcontrols) */
161173 #define SOC_PGA_E_ARRAY(wname, wreg, wshift, winvert, wcontrols, \
162174 wevent, wflags) \
@@ -450,6 +462,7 @@ struct snd_soc_dapm_widget { · 287 unmodified lines
450462 unsigned char ext:1; /* has external widgets */
451463 unsigned char force:1; /* force state */
452464 unsigned char ignore_suspend:1; /* kept enabled over suspend */
465+ int subseq; /* sort within widget type */
453466
454467 int (*power_check)(struct snd_soc_dapm_widget *w);
455468
@@ -487,6 +500,9 @@ struct snd_soc_dapm_context { · 31 unmodified lines
487500
488501 struct snd_soc_dapm_update *update;
489502
503+ void (*seq_notifier)(struct snd_soc_dapm_context *,
504+ enum snd_soc_dapm_type, int);
505+
490506 struct device *dev; /* from parent - for debug */
491507 struct snd_soc_codec *codec; /* parent codec */
492508 struct snd_soc_card *card; /* parent card */
include/sound/soc.h+135−12
@@ -234,6 +234,7 @@ struct snd_soc_codec; · 233 unmodified lines
234234 struct snd_soc_codec_driver;
235235 struct soc_enum;
236236 struct snd_soc_jack;
237+struct snd_soc_jack_zone;
237238 struct snd_soc_jack_pin;
238239 struct snd_soc_cache_ops;
239240 #include <sound/soc-dapm.h>
@@ -258,6 +259,16 @@ enum snd_soc_compress_type { · 18 unmodified lines
258259 SND_SOC_RBTREE_COMPRESSION
259260 };
260261
262+int snd_soc_codec_set_sysclk(struct snd_soc_codec *codec, int clk_id,
263+ unsigned int freq, int dir);
264+int snd_soc_codec_set_pll(struct snd_soc_codec *codec, int pll_id, int source,
265+ unsigned int freq_in, unsigned int freq_out);
266+
267+int snd_soc_register_card(struct snd_soc_card *card);
268+int snd_soc_unregister_card(struct snd_soc_card *card);
269+int snd_soc_suspend(struct device *dev);
270+int snd_soc_resume(struct device *dev);
271+int snd_soc_poweroff(struct device *dev);
261272 int snd_soc_register_platform(struct device *dev,
262273 struct snd_soc_platform_driver *platform_drv);
263274 void snd_soc_unregister_platform(struct device *dev);
@@ -265,7 +276,8 @@ int snd_soc_register_codec(struct device *dev, · 1 unmodified line
265276 const struct snd_soc_codec_driver *codec_drv,
266277 struct snd_soc_dai_driver *dai_drv, int num_dai);
267278 void snd_soc_unregister_codec(struct device *dev);
268−int snd_soc_codec_volatile_register(struct snd_soc_codec *codec, int reg);
279+int snd_soc_codec_volatile_register(struct snd_soc_codec *codec,
280+ unsigned int reg);
269281 int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec,
270282 int addr_bits, int data_bits,
271283 enum snd_soc_control_type control);
@@ -276,6 +288,10 @@ int snd_soc_cache_write(struct snd_soc_codec *codec, · 4 unmodified lines
276288 unsigned int reg, unsigned int value);
277289 int snd_soc_cache_read(struct snd_soc_codec *codec,
278290 unsigned int reg, unsigned int *value);
291+int snd_soc_default_volatile_register(struct snd_soc_codec *codec,
292+ unsigned int reg);
293+int snd_soc_default_readable_register(struct snd_soc_codec *codec,
294+ unsigned int reg);
279295
280296 /* Utility functions to get clock rates from various things */
281297 int snd_soc_calc_frame_size(int sample_size, int channels, int tdm_slots);
@@ -297,6 +313,9 @@ void snd_soc_jack_notifier_register(struct snd_soc_jack *jack, · 15 unmodified lines
297313 struct notifier_block *nb);
298314 void snd_soc_jack_notifier_unregister(struct snd_soc_jack *jack,
299315 struct notifier_block *nb);
316+int snd_soc_jack_add_zones(struct snd_soc_jack *jack, int count,
317+ struct snd_soc_jack_zone *zones);
318+int snd_soc_jack_get_type(struct snd_soc_jack *jack, int micbias_voltage);
300319 #ifdef CONFIG_GPIOLIB
301320 int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count,
302321 struct snd_soc_jack_gpio *gpios);
@@ -321,7 +340,8 @@ void snd_soc_free_ac97_codec(struct snd_soc_codec *codec); · 18 unmodified lines
321340 *Controls
322341 */
323342 struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template,
324− void *data, char *long_name);
343+ void *data, char *long_name,
344+ const char *prefix);
325345 int snd_soc_add_controls(struct snd_soc_codec *codec,
326346 const struct snd_kcontrol_new *controls, int num_controls);
327347 int snd_soc_info_enum_double(struct snd_kcontrol *kcontrol,
@@ -366,6 +386,22 @@ int snd_soc_get_volsw_2r_sx(struct snd_kcontrol *kcontrol, · 38 unmodified lines
366386 int snd_soc_put_volsw_2r_sx(struct snd_kcontrol *kcontrol,
367387 struct snd_ctl_elem_value *ucontrol);
368388
389+/**
390+ * struct snd_soc_reg_access - Describes whether a given register is
391+ * readable, writable or volatile.
392+ *
393+ * @reg: the register number
394+ * @read: whether this register is readable
395+ * @write: whether this register is writable
396+ * @vol: whether this register is volatile
397+ */
398+struct snd_soc_reg_access {
399+ u16 reg;
400+ u16 read;
401+ u16 write;
402+ u16 vol;
403+};
404+
369405 /**
370406 * struct snd_soc_jack_pin - Describes a pin to update based on jack detection
371407 *
@@ -380,6 +416,24 @@ struct snd_soc_jack_pin { · 8 unmodified lines
380416 bool invert;
381417 };
382418
419+/**
420+ * struct snd_soc_jack_zone - Describes voltage zones of jack detection
421+ *
422+ * @min_mv: start voltage in mv
423+ * @max_mv: end voltage in mv
424+ * @jack_type: type of jack that is expected for this voltage
425+ * @debounce_time: debounce_time for jack, codec driver should wait for this
426+ * duration before reading the adc for voltages
427+ * @:list: list container
428+ */
429+struct snd_soc_jack_zone {
430+ unsigned int min_mv;
431+ unsigned int max_mv;
432+ unsigned int jack_type;
433+ unsigned int debounce_time;
434+ struct list_head list;
435+};
436+
383437 /**
384438 * struct snd_soc_jack_gpio - Describes a gpio pin for jack detection
385439 *
@@ -388,6 +442,10 @@ struct snd_soc_jack_pin { · 2 unmodified lines
388442 * @report: value to report when jack detected
389443 * @invert: report presence in low state
390444 * @debouce_time: debouce time in ms
445+ * @wake: enable as wake source
446+ * @jack_status_check: callback function which overrides the detection
447+ * to provide more complex checks (eg, reading an
448+ * ADC).
391449 */
392450 #ifdef CONFIG_GPIOLIB
393451 struct snd_soc_jack_gpio {
@@ -396,6 +454,8 @@ struct snd_soc_jack_gpio { · 2 unmodified lines
396454 int report;
397455 int invert;
398456 int debounce_time;
457+ bool wake;
458+
399459 struct snd_soc_jack *jack;
400460 struct delayed_work work;
401461
@@ -409,6 +469,7 @@ struct snd_soc_jack { · 7 unmodified lines
409469 struct list_head pins;
410470 int status;
411471 struct blocking_notifier_head notifier;
472+ struct list_head jack_zones;
412473 };
413474
414475 /* SoC PCM stream information */
@@ -459,18 +520,22 @@ struct snd_soc_codec { · 44 unmodified lines
459520 struct list_head card_list;
460521 int num_dai;
461522 enum snd_soc_compress_type compress_type;
523+ size_t reg_size; /* reg_cache_size * reg_word_size */
524+ int (*volatile_register)(struct snd_soc_codec *, unsigned int);
525+ int (*readable_register)(struct snd_soc_codec *, unsigned int);
462526
463527 /* runtime */
464528 struct snd_ac97 *ac97; /* for ad-hoc ac97 devices */
465529 unsigned int active;
466− unsigned int cache_only:1; /* Suppress writes to hardware */
467− unsigned int cache_sync:1; /* Cache needs to be synced to hardware */
530+ unsigned int cache_bypass:1; /* Suppress access to the cache */
468531 unsigned int suspended:1; /* Codec is in suspend PM state */
469532 unsigned int probed:1; /* Codec has been probed */
470533 unsigned int ac97_registered:1; /* Codec has been AC97 registered */
471534 unsigned int ac97_created:1; /* Codec has been created by SoC */
472535 unsigned int sysfs_registered:1; /* codec has been sysfs registered */
473536 unsigned int cache_init:1; /* codec cache has been initialized */
537+ u32 cache_only; /* Suppress writes to hardware */
538+ u32 cache_sync; /* Cache needs to be synced to hardware */
474539
475540 /* codec IO */
476541 void *control_data; /* codec control (i2c/3wire) data */
@@ -503,22 +568,39 @@ struct snd_soc_codec_driver { · 26 unmodified lines
503568 pm_message_t state);
504569 int (*resume)(struct snd_soc_codec *);
505570
571+ /* Default DAPM setup, added after probe() is run */
572+ const struct snd_soc_dapm_widget *dapm_widgets;
573+ int num_dapm_widgets;
574+ const struct snd_soc_dapm_route *dapm_routes;
575+ int num_dapm_routes;
576+
577+ /* codec wide operations */
578+ int (*set_sysclk)(struct snd_soc_codec *codec,
579+ int clk_id, unsigned int freq, int dir);
580+ int (*set_pll)(struct snd_soc_codec *codec, int pll_id, int source,
581+ unsigned int freq_in, unsigned int freq_out);
582+
506583 /* codec IO */
507584 unsigned int (*read)(struct snd_soc_codec *, unsigned int);
508585 int (*write)(struct snd_soc_codec *, unsigned int, unsigned int);
509586 int (*display_register)(struct snd_soc_codec *, char *,
510587 size_t, unsigned int);
511− int (*volatile_register)(unsigned int);
512− int (*readable_register)(unsigned int);
588+ int (*volatile_register)(struct snd_soc_codec *, unsigned int);
589+ int (*readable_register)(struct snd_soc_codec *, unsigned int);
513590 short reg_cache_size;
514591 short reg_cache_step;
515592 short reg_word_size;
516593 const void *reg_cache_default;
594+ short reg_access_size;
595+ const struct snd_soc_reg_access *reg_access_default;
517596 enum snd_soc_compress_type compress_type;
518597
519598 /* codec bias level */
520599 int (*set_bias_level)(struct snd_soc_codec *,
521600 enum snd_soc_bias_level level);
601+
602+ void (*seq_notifier)(struct snd_soc_dapm_context *,
603+ enum snd_soc_dapm_type, int);
522604 };
523605
524606 /* SoC platform interface */
@@ -617,15 +699,16 @@ struct snd_soc_card { · 92 unmodified lines
617699
618700 bool instantiated;
619701
620− int (*probe)(struct platform_device *pdev);
621− int (*remove)(struct platform_device *pdev);
702+ int (*probe)(struct snd_soc_card *card);
703+ int (*late_probe)(struct snd_soc_card *card);
704+ int (*remove)(struct snd_soc_card *card);
622705
623706 /* the pre and post PM functions are used to do any PM work before and
624707 * after the codec and DAI's do any PM work. */
625− int (*suspend_pre)(struct platform_device *pdev, pm_message_t state);
626− int (*suspend_post)(struct platform_device *pdev, pm_message_t state);
627− int (*resume_pre)(struct platform_device *pdev);
628− int (*resume_post)(struct platform_device *pdev);
708+ int (*suspend_pre)(struct snd_soc_card *card);
709+ int (*suspend_post)(struct snd_soc_card *card);
710+ int (*resume_pre)(struct snd_soc_card *card);
711+ int (*resume_post)(struct snd_soc_card *card);
629712
630713 /* callbacks */
631714 int (*set_bias_level)(struct snd_soc_card *,
@@ -654,6 +737,14 @@ struct snd_soc_card { · 22 unmodified lines
654737 struct snd_soc_pcm_runtime *rtd_aux;
655738 int num_aux_rtd;
656739
740+ /*
741+ * Card-specific routes and widgets.
742+ */
743+ struct snd_soc_dapm_widget *dapm_widgets;
744+ int num_dapm_widgets;
745+ struct snd_soc_dapm_route *dapm_routes;
746+ int num_dapm_routes;
747+
657748 struct work_struct deferred_resume_work;
658749
659750 /* lists of probed devices belonging to this card */
@@ -665,11 +756,16 @@ struct snd_soc_card { · 5 unmodified lines
665756 struct list_head paths;
666757 struct list_head dapm_list;
667758
759+ /* Generic DAPM context for the card */
760+ struct snd_soc_dapm_context dapm;
761+
668762 #ifdef CONFIG_DEBUG_FS
669763 struct dentry *debugfs_card_root;
670764 struct dentry *debugfs_pop_time;
671765 #endif
672766 u32 pop_time;
767+
768+ void *drvdata;
673769 };
674770
675771 /* SoC machine DAI configuration, glues a codec and cpu DAI together */
@@ -721,6 +817,17 @@ unsigned int snd_soc_write(struct snd_soc_codec *codec, · 45 unmodified lines
721817
722818 /* device driver data */
723819
820+static inline void snd_soc_card_set_drvdata(struct snd_soc_card *card,
821+ void *data)
822+{
823+ card->drvdata = data;
824+}
825+
826+static inline void *snd_soc_card_get_drvdata(struct snd_soc_card *card)
827+{
828+ return card->drvdata;
829+}
830+
724831 static inline void snd_soc_codec_set_drvdata(struct snd_soc_codec *codec,
725832 void *data)
726833 {
@@ -754,6 +861,22 @@ static inline void *snd_soc_pcm_get_drvdata(struct snd_soc_pcm_runtime *rtd) · 27 unmodified lines
754861 return dev_get_drvdata(&rtd->dev);
755862 }
756863
864+static inline void snd_soc_initialize_card_lists(struct snd_soc_card *card)
865+{
866+ INIT_LIST_HEAD(&card->dai_dev_list);
867+ INIT_LIST_HEAD(&card->codec_dev_list);
868+ INIT_LIST_HEAD(&card->platform_dev_list);
869+ INIT_LIST_HEAD(&card->widgets);
870+ INIT_LIST_HEAD(&card->paths);
871+ INIT_LIST_HEAD(&card->dapm_list);
872+}
873+
757874 #include <sound/soc-dai.h>
758875
876+#ifdef CONFIG_DEBUG_FS
877+extern struct dentry *snd_soc_debugfs_root;
878+#endif
879+
880+extern const struct dev_pm_ops snd_soc_pm_ops;
881+
759882 #endif
include/sound/tlv320aic32x4.h+31−0
@@ -0,0 +1,31 @@
1+/*
2+ * tlv320aic32x4.h -- TLV320AIC32X4 Soc Audio driver platform data
3+ *
4+ * Copyright 2011 Vista Silicon S.L.
5+ *
6+ * Author: Javier Martin <javier.martin@vista-silicon.com>
7+ *
8+ * This program is free software; you can redistribute it and/or modify
9+ * it under the terms of the GNU General Public License version 2 as
10+ * published by the Free Software Foundation.
11+ */
12+
13+#ifndef _AIC32X4_PDATA_H
14+#define _AIC32X4_PDATA_H
15+
16+#define AIC32X4_PWR_MICBIAS_2075_LDOIN 0x00000001
17+#define AIC32X4_PWR_AVDD_DVDD_WEAK_DISABLE 0x00000002
18+#define AIC32X4_PWR_AIC32X4_LDO_ENABLE 0x00000004
19+#define AIC32X4_PWR_CMMODE_LDOIN_RANGE_18_36 0x00000008
20+#define AIC32X4_PWR_CMMODE_HP_LDOIN_POWERED 0x00000010
21+
22+#define AIC32X4_MICPGA_ROUTE_LMIC_IN2R_10K 0x00000001
23+#define AIC32X4_MICPGA_ROUTE_RMIC_IN1L_10K 0x00000002
24+
25+struct aic32x4_pdata {
26+ u32 power_cfg;
27+ u32 micpga_routing;
28+ bool swapdacs;
29+};
30+
31+#endif
include/sound/version.h+1−1
@@ -1,3 +1,3 @@
11 /* include/version.h */
2−#define CONFIG_SND_VERSION "1.0.23"
2+#define CONFIG_SND_VERSION "1.0.24"
33 #define CONFIG_SND_DATE ""
include/sound/wm8903.h+19−1
@@ -32,6 +32,21 @@ · 31 unmodified lines
3232 #define WM8903_MICBIAS_ENA_SHIFT 0 /* MICBIAS_ENA */
3333 #define WM8903_MICBIAS_ENA_WIDTH 1 /* MICBIAS_ENA */
3434
35+/*
36+ * WM8903_GPn_FN values
37+ *
38+ * See datasheets for list of valid values per pin
39+ */
40+#define WM8903_GPn_FN_GPIO_OUTPUT 0
41+#define WM8903_GPn_FN_BCLK 1
42+#define WM8903_GPn_FN_IRQ_OUTPT 2
43+#define WM8903_GPn_FN_GPIO_INPUT 3
44+#define WM8903_GPn_FN_MICBIAS_CURRENT_DETECT 4
45+#define WM8903_GPn_FN_MICBIAS_SHORT_DETECT 5
46+#define WM8903_GPn_FN_DMIC_LR_CLK_OUTPUT 6
47+#define WM8903_GPn_FN_FLL_LOCK_OUTPUT 8
48+#define WM8903_GPn_FN_FLL_CLOCK_OUTPUT 9
49+
3550 /*
3651 * R116 (0x74) - GPIO Control 1
3752 */
@@ -227,6 +242,8 @@ · 189 unmodified lines
227242 #define WM8903_GP5_DB_SHIFT 0 /* GP5_DB */
228243 #define WM8903_GP5_DB_WIDTH 1 /* GP5_DB */
229244
245+#define WM8903_NUM_GPIO 5
246+
230247 struct wm8903_platform_data {
231248 bool irq_active_low; /* Set if IRQ active low, default high */
232249
@@ -239,7 +256,8 @@ struct wm8903_platform_data { · 6 unmodified lines
239256
240257 int micdet_delay; /* Delay after microphone detection (ms) */
241258
242− u32 gpio_cfg[5]; /* Default register values for GPIO pin mux */
259+ int gpio_base;
260+ u32 gpio_cfg[WM8903_NUM_GPIO]; /* Default register values for GPIO pin mux */
243261 };
244262
245263 #endif
include/sound/wm9081.h+6−3
@@ -17,9 +17,12 @@ struct wm9081_retune_mobile_setting { · 16 unmodified lines
1717 u16 config[20];
1818 };
1919
20−struct wm9081_retune_mobile_config {
21− struct wm9081_retune_mobile_setting *configs;
22− int num_configs;
20+struct wm9081_pdata {
21+ bool irq_high; /* IRQ is active high */
22+ bool irq_cmos; /* IRQ is in CMOS mode */
23+
24+ struct wm9081_retune_mobile_setting *retune_configs;
25+ int num_retune_configs;
2326 };
2427
2528 #endif
include/trace/events/asoc.h+25−0
@@ -229,6 +229,31 @@ TRACE_EVENT(snd_soc_jack_notify, · 228 unmodified lines
229229 TP_printk("jack=%s %x", __get_str(name), (int)__entry->val)
230230 );
231231
232+TRACE_EVENT(snd_soc_cache_sync,
233+
234+ TP_PROTO(struct snd_soc_codec *codec, const char *type,
235+ const char *status),
236+
237+ TP_ARGS(codec, type, status),
238+
239+ TP_STRUCT__entry(
240+ __string( name, codec->name )
241+ __string( status, status )
242+ __string( type, type )
243+ __field( int, id )
244+ ),
245+
246+ TP_fast_assign(
247+ __assign_str(name, codec->name);
248+ __assign_str(status, status);
249+ __assign_str(type, type);
250+ __entry->id = codec->id;
251+ ),
252+
253+ TP_printk("codec=%s.%d type=%s status=%s", __get_str(name),
254+ (int)__entry->id, __get_str(type), __get_str(status))
255+);
256+
232257 #endif /* _TRACE_ASOC_H */
233258
234259 /* This part must be outside protection */
sound/Kconfig+2−0
@@ -97,6 +97,8 @@ source "sound/sh/Kconfig" · 96 unmodified lines
9797 # here assuming USB is defined before ALSA
9898 source "sound/usb/Kconfig"
9999
100+source "sound/firewire/Kconfig"
101+
100102 # the following will depend on the order of config.
101103 # here assuming PCMCIA is defined before ALSA
102104 source "sound/pcmcia/Kconfig"
sound/Makefile+1−1
@@ -6,7 +6,7 @@ obj-$(CONFIG_SOUND_PRIME) += sound_firmware.o · 5 unmodified lines
66 obj-$(CONFIG_SOUND_PRIME) += oss/
77 obj-$(CONFIG_DMASOUND) += oss/
88 obj-$(CONFIG_SND) += core/ i2c/ drivers/ isa/ pci/ ppc/ arm/ sh/ synth/ usb/ \
9− sparc/ spi/ parisc/ pcmcia/ mips/ soc/ atmel/
9+ firewire/ sparc/ spi/ parisc/ pcmcia/ mips/ soc/ atmel/
1010 obj-$(CONFIG_SND_AOA) += aoa/
1111
1212 # This one must be compilable even if sound is configured out
sound/core/control.c+56−12
@@ -279,33 +279,31 @@ void snd_ctl_free_one(struct snd_kcontrol *kcontrol) · 278 unmodified lines
279279
280280 EXPORT_SYMBOL(snd_ctl_free_one);
281281
282−static unsigned int snd_ctl_hole_check(struct snd_card *card,
283− unsigned int count)
282+static bool snd_ctl_remove_numid_conflict(struct snd_card *card,
283+ unsigned int count)
284284 {
285285 struct snd_kcontrol *kctl;
286286
287287 list_for_each_entry(kctl, &card->controls, list) {
288− if ((kctl->id.numid <= card->last_numid &&
289− kctl->id.numid + kctl->count > card->last_numid) ||
290− (kctl->id.numid <= card->last_numid + count - 1 &&
291− kctl->id.numid + kctl->count > card->last_numid + count - 1))
292− return card->last_numid = kctl->id.numid + kctl->count - 1;
288+ if (kctl->id.numid < card->last_numid + 1 + count &&
289+ kctl->id.numid + kctl->count > card->last_numid + 1) {
290+ card->last_numid = kctl->id.numid + kctl->count - 1;
291+ return true;
292+ }
293293 }
294− return card->last_numid;
294+ return false;
295295 }
296296
297297 static int snd_ctl_find_hole(struct snd_card *card, unsigned int count)
298298 {
299− unsigned int last_numid, iter = 100000;
299+ unsigned int iter = 100000;
300300
301− last_numid = card->last_numid;
302− while (last_numid != snd_ctl_hole_check(card, count)) {
301+ while (snd_ctl_remove_numid_conflict(card, count)) {
303302 if (--iter == 0) {
304303 /* this situation is very unlikely */
305304 snd_printk(KERN_ERR "unable to allocate new control numid\n");
306305 return -ENOMEM;
307306 }
308− last_numid = card->last_numid;
309307 }
310308 return 0;
311309 }
@@ -465,6 +463,52 @@ error: · 153 unmodified lines
465463 return ret;
466464 }
467465
466+/**
467+ * snd_ctl_activate_id - activate/inactivate the control of the given id
468+ * @card: the card instance
469+ * @id: the control id to activate/inactivate
470+ * @active: non-zero to activate
471+ *
472+ * Finds the control instance with the given id, and activate or
473+ * inactivate the control together with notification, if changed.
474+ *
475+ * Returns 0 if unchanged, 1 if changed, or a negative error code on failure.
476+ */
477+int snd_ctl_activate_id(struct snd_card *card, struct snd_ctl_elem_id *id,
478+ int active)
479+{
480+ struct snd_kcontrol *kctl;
481+ struct snd_kcontrol_volatile *vd;
482+ unsigned int index_offset;
483+ int ret;
484+
485+ down_write(&card->controls_rwsem);
486+ kctl = snd_ctl_find_id(card, id);
487+ if (kctl == NULL) {
488+ ret = -ENOENT;
489+ goto unlock;
490+ }
491+ index_offset = snd_ctl_get_ioff(kctl, &kctl->id);
492+ vd = &kctl->vd[index_offset];
493+ ret = 0;
494+ if (active) {
495+ if (!(vd->access & SNDRV_CTL_ELEM_ACCESS_INACTIVE))
496+ goto unlock;
497+ vd->access &= ~SNDRV_CTL_ELEM_ACCESS_INACTIVE;
498+ } else {
499+ if (vd->access & SNDRV_CTL_ELEM_ACCESS_INACTIVE)
500+ goto unlock;
501+ vd->access |= SNDRV_CTL_ELEM_ACCESS_INACTIVE;
502+ }
503+ ret = 1;
504+ unlock:
505+ up_write(&card->controls_rwsem);
506+ if (ret > 0)
507+ snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_INFO, id);
508+ return ret;
509+}
510+EXPORT_SYMBOL_GPL(snd_ctl_activate_id);
511+
468512 /**
469513 * snd_ctl_rename_id - replace the id of a control on the card
470514 * @card: the card instance
sound/core/device.c+4−3
@@ -225,15 +225,16 @@ int snd_device_free_all(struct snd_card *card, snd_device_cmd_t cmd) · 224 unmodified lines
225225 {
226226 struct snd_device *dev;
227227 int err;
228− unsigned int range_low, range_high;
228+ unsigned int range_low, range_high, type;
229229
230230 if (snd_BUG_ON(!card))
231231 return -ENXIO;
232− range_low = cmd * SNDRV_DEV_TYPE_RANGE_SIZE;
232+ range_low = (__force unsigned int)cmd * SNDRV_DEV_TYPE_RANGE_SIZE;
233233 range_high = range_low + SNDRV_DEV_TYPE_RANGE_SIZE - 1;
234234 __again:
235235 list_for_each_entry(dev, &card->devices, list) {
236− if (dev->type >= range_low && dev->type <= range_high) {
236+ type = (__force unsigned int)dev->type;
237+ if (type >= range_low && type <= range_high) {
237238 if ((err = snd_device_free(card, dev->device_data)) < 0)
238239 return err;
239240 goto __again;
sound/core/memalloc.c+2−1
@@ -192,7 +192,8 @@ int snd_dma_alloc_pages(int type, struct device *device, size_t size, · 191 unmodified lines
192192 dmab->bytes = 0;
193193 switch (type) {
194194 case SNDRV_DMA_TYPE_CONTINUOUS:
195− dmab->area = snd_malloc_pages(size, (unsigned long)device);
195+ dmab->area = snd_malloc_pages(size,
196+ (__force gfp_t)(unsigned long)device);
196197 dmab->addr = 0;
197198 break;
198199 #ifdef CONFIG_HAS_DMA
sound/core/oss/linear.c+4−3
@@ -114,7 +114,8 @@ static snd_pcm_sframes_t linear_transfer(struct snd_pcm_plugin *plugin, · 113 unmodified lines
114114 return frames;
115115 }
116116
117−static void init_data(struct linear_priv *data, int src_format, int dst_format)
117+static void init_data(struct linear_priv *data,
118+ snd_pcm_format_t src_format, snd_pcm_format_t dst_format)
118119 {
119120 int src_le, dst_le, src_bytes, dst_bytes;
120121
@@ -140,9 +141,9 @@ static void init_data(struct linear_priv *data, int src_format, int dst_format) · 19 unmodified lines
140141 if (snd_pcm_format_signed(src_format) !=
141142 snd_pcm_format_signed(dst_format)) {
142143 if (dst_le)
143− data->flip = cpu_to_le32(0x80000000);
144+ data->flip = (__force u32)cpu_to_le32(0x80000000);
144145 else
145− data->flip = cpu_to_be32(0x80000000);
146+ data->flip = (__force u32)cpu_to_be32(0x80000000);
146147 }
147148 }
148149
sound/core/oss/mixer_oss.c+6−4
@@ -190,9 +190,10 @@ static int snd_mixer_oss_get_recsrc(struct snd_mixer_oss_file *fmixer) · 189 unmodified lines
190190 return -EIO;
191191 if (mixer->put_recsrc && mixer->get_recsrc) { /* exclusive */
192192 int err;
193− if ((err = mixer->get_recsrc(fmixer, &result)) < 0)
193+ unsigned int index;
194+ if ((err = mixer->get_recsrc(fmixer, &index)) < 0)
194195 return err;
195− result = 1 << result;
196+ result = 1 << index;
196197 } else {
197198 struct snd_mixer_oss_slot *pslot;
198199 int chn;
@@ -214,6 +215,7 @@ static int snd_mixer_oss_set_recsrc(struct snd_mixer_oss_file *fmixer, int recsr · 15 unmodified lines
214215 struct snd_mixer_oss *mixer = fmixer->mixer;
215216 struct snd_mixer_oss_slot *pslot;
216217 int chn, active;
218+ unsigned int index;
217219 int result = 0;
218220
219221 if (mixer == NULL)
@@ -222,8 +224,8 @@ static int snd_mixer_oss_set_recsrc(struct snd_mixer_oss_file *fmixer, int recsr · 2 unmodified lines
222224 if (recsrc & ~mixer->oss_recsrc)
223225 recsrc &= ~mixer->oss_recsrc;
224226 mixer->put_recsrc(fmixer, ffz(~recsrc));
225− mixer->get_recsrc(fmixer, &result);
226− result = 1 << result;
227+ mixer->get_recsrc(fmixer, &index);
228+ result = 1 << index;
227229 }
228230 for (chn = 0; chn < 31; chn++) {
229231 pslot = &mixer->slots[chn];
sound/core/oss/mulaw.c+1−1
@@ -274,7 +274,7 @@ static snd_pcm_sframes_t mulaw_transfer(struct snd_pcm_plugin *plugin, · 273 unmodified lines
274274 return frames;
275275 }
276276
277−static void init_data(struct mulaw_priv *data, int format)
277+static void init_data(struct mulaw_priv *data, snd_pcm_format_t format)
278278 {
279279 #ifdef SNDRV_LITTLE_ENDIAN
280280 data->cvt_endian = snd_pcm_format_big_endian(format) > 0;
sound/core/oss/pcm_oss.c+28−23
@@ -41,6 +41,7 @@ · 40 unmodified lines
4141 #include <sound/info.h>
4242 #include <linux/soundcard.h>
4343 #include <sound/initval.h>
44+#include <sound/mixer_oss.h>
4445
4546 #define OSS_ALSAEMULVER _SIOR ('M', 249, int)
4647
@@ -60,7 +61,6 @@ MODULE_PARM_DESC(nonblock_open, "Don't block opening busy PCM devices."); · 13 unmodified lines
6061 MODULE_ALIAS_SNDRV_MINOR(SNDRV_MINOR_OSS_PCM);
6162 MODULE_ALIAS_SNDRV_MINOR(SNDRV_MINOR_OSS_PCM1);
6263
63−extern int snd_mixer_oss_ioctl_card(struct snd_card *card, unsigned int cmd, unsigned long arg);
6464 static int snd_pcm_oss_get_rate(struct snd_pcm_oss_file *pcm_oss_file);
6565 static int snd_pcm_oss_get_channels(struct snd_pcm_oss_file *pcm_oss_file);
6666 static int snd_pcm_oss_get_format(struct snd_pcm_oss_file *pcm_oss_file);
@@ -656,7 +656,7 @@ snd_pcm_uframes_t get_hw_ptr_period(struct snd_pcm_runtime *runtime) · 589 unmodified lines
656656 #define AFMT_AC3 0x00000400
657657 #define AFMT_VORBIS 0x00000800
658658
659−static int snd_pcm_oss_format_from(int format)
659+static snd_pcm_format_t snd_pcm_oss_format_from(int format)
660660 {
661661 switch (format) {
662662 case AFMT_MU_LAW: return SNDRV_PCM_FORMAT_MU_LAW;
@@ -680,7 +680,7 @@ static int snd_pcm_oss_format_from(int format) · 17 unmodified lines
680680 }
681681 }
682682
683−static int snd_pcm_oss_format_to(int format)
683+static int snd_pcm_oss_format_to(snd_pcm_format_t format)
684684 {
685685 switch (format) {
686686 case SNDRV_PCM_FORMAT_MU_LAW: return AFMT_MU_LAW;
@@ -843,7 +843,8 @@ static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream) · 156 unmodified lines
843843 size_t oss_frame_size;
844844 int err;
845845 int direct;
846− int format, sformat, n;
846+ snd_pcm_format_t format, sformat;
847+ int n;
847848 struct snd_mask sformat_mask;
848849 struct snd_mask mask;
849850
@@ -868,11 +869,11 @@ static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream) · 18 unmodified lines
868869 _snd_pcm_hw_param_min(sparams, SNDRV_PCM_HW_PARAM_PERIODS, 2, 0);
869870 snd_mask_none(&mask);
870871 if (atomic_read(&substream->mmap_count))
871− snd_mask_set(&mask, SNDRV_PCM_ACCESS_MMAP_INTERLEAVED);
872+ snd_mask_set(&mask, (__force int)SNDRV_PCM_ACCESS_MMAP_INTERLEAVED);
872873 else {
873− snd_mask_set(&mask, SNDRV_PCM_ACCESS_RW_INTERLEAVED);
874+ snd_mask_set(&mask, (__force int)SNDRV_PCM_ACCESS_RW_INTERLEAVED);
874875 if (!direct)
875− snd_mask_set(&mask, SNDRV_PCM_ACCESS_RW_NONINTERLEAVED);
876+ snd_mask_set(&mask, (__force int)SNDRV_PCM_ACCESS_RW_NONINTERLEAVED);
876877 }
877878 err = snd_pcm_hw_param_mask(substream, sparams, SNDRV_PCM_HW_PARAM_ACCESS, &mask);
878879 if (err < 0) {
@@ -891,19 +892,22 @@ static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream) · 12 unmodified lines
891892 else
892893 sformat = snd_pcm_plug_slave_format(format, &sformat_mask);
893894
894− if (sformat < 0 || !snd_mask_test(&sformat_mask, sformat)) {
895− for (sformat = 0; sformat <= SNDRV_PCM_FORMAT_LAST; sformat++) {
896− if (snd_mask_test(&sformat_mask, sformat) &&
895+ if ((__force int)sformat < 0 ||
896+ !snd_mask_test(&sformat_mask, (__force int)sformat)) {
897+ for (sformat = (__force snd_pcm_format_t)0;
898+ (__force int)sformat <= (__force int)SNDRV_PCM_FORMAT_LAST;
899+ sformat = (__force snd_pcm_format_t)((__force int)sformat + 1)) {
900+ if (snd_mask_test(&sformat_mask, (__force int)sformat) &&
897901 snd_pcm_oss_format_to(sformat) >= 0)
898902 break;
899903 }
900− if (sformat > SNDRV_PCM_FORMAT_LAST) {
904+ if ((__force int)sformat > (__force int)SNDRV_PCM_FORMAT_LAST) {
901905 snd_printd("Cannot find a format!!!\n");
902906 err = -EINVAL;
903907 goto failure;
904908 }
905909 }
906− err = _snd_pcm_hw_param_set(sparams, SNDRV_PCM_HW_PARAM_FORMAT, sformat, 0);
910+ err = _snd_pcm_hw_param_set(sparams, SNDRV_PCM_HW_PARAM_FORMAT, (__force int)sformat, 0);
907911 if (err < 0)
908912 goto failure;
909913
@@ -912,9 +916,9 @@ static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream) · 2 unmodified lines
912916 } else {
913917 _snd_pcm_hw_params_any(params);
914918 _snd_pcm_hw_param_set(params, SNDRV_PCM_HW_PARAM_ACCESS,
915− SNDRV_PCM_ACCESS_RW_INTERLEAVED, 0);
919+ (__force int)SNDRV_PCM_ACCESS_RW_INTERLEAVED, 0);
916920 _snd_pcm_hw_param_set(params, SNDRV_PCM_HW_PARAM_FORMAT,
917− snd_pcm_oss_format_from(runtime->oss.format), 0);
921+ (__force int)snd_pcm_oss_format_from(runtime->oss.format), 0);
918922 _snd_pcm_hw_param_set(params, SNDRV_PCM_HW_PARAM_CHANNELS,
919923 runtime->oss.channels, 0);
920924 _snd_pcm_hw_param_set(params, SNDRV_PCM_HW_PARAM_RATE,
@@ -1185,10 +1189,10 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const · 264 unmodified lines
11851189 if (in_kernel) {
11861190 mm_segment_t fs;
11871191 fs = snd_enter_user();
1188− ret = snd_pcm_lib_write(substream, (void __user *)ptr, frames);
1192+ ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
11891193 snd_leave_user(fs);
11901194 } else {
1191− ret = snd_pcm_lib_write(substream, (void __user *)ptr, frames);
1195+ ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
11921196 }
11931197 if (ret != -EPIPE && ret != -ESTRPIPE)
11941198 break;
@@ -1230,10 +1234,10 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p · 35 unmodified lines
12301234 if (in_kernel) {
12311235 mm_segment_t fs;
12321236 fs = snd_enter_user();
1233− ret = snd_pcm_lib_read(substream, (void __user *)ptr, frames);
1237+ ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
12341238 snd_leave_user(fs);
12351239 } else {
1236− ret = snd_pcm_lib_read(substream, (void __user *)ptr, frames);
1240+ ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
12371241 }
12381242 if (ret == -EPIPE) {
12391243 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
@@ -1333,7 +1337,7 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha · 93 unmodified lines
13331337 struct snd_pcm_plugin_channel *channels;
13341338 size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8;
13351339 if (!in_kernel) {
1336− if (copy_from_user(runtime->oss.buffer, (const char __user *)buf, bytes))
1340+ if (copy_from_user(runtime->oss.buffer, (const char __force __user *)buf, bytes))
13371341 return -EFAULT;
13381342 buf = runtime->oss.buffer;
13391343 }
@@ -1429,7 +1433,7 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf, · 89 unmodified lines
14291433 struct snd_pcm_runtime *runtime = substream->runtime;
14301434 snd_pcm_sframes_t frames, frames1;
14311435 #ifdef CONFIG_SND_PCM_OSS_PLUGINS
1432− char __user *final_dst = (char __user *)buf;
1436+ char __user *final_dst = (char __force __user *)buf;
14331437 if (runtime->oss.plugin_first) {
14341438 struct snd_pcm_plugin_channel *channels;
14351439 size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8;
@@ -1549,6 +1553,7 @@ static int snd_pcm_oss_sync1(struct snd_pcm_substream *substream, size_t size) · 113 unmodified lines
15491553 {
15501554 struct snd_pcm_runtime *runtime;
15511555 ssize_t result = 0;
1556+ snd_pcm_state_t state;
15521557 long res;
15531558 wait_queue_t wait;
15541559
@@ -1570,9 +1575,9 @@ static int snd_pcm_oss_sync1(struct snd_pcm_substream *substream, size_t size) · 15 unmodified lines
15701575 result = 0;
15711576 set_current_state(TASK_INTERRUPTIBLE);
15721577 snd_pcm_stream_lock_irq(substream);
1573− res = runtime->status->state;
1578+ state = runtime->status->state;
15741579 snd_pcm_stream_unlock_irq(substream);
1575− if (res != SNDRV_PCM_STATE_RUNNING) {
1580+ if (state != SNDRV_PCM_STATE_RUNNING) {
15761581 set_current_state(TASK_RUNNING);
15771582 break;
15781583 }
@@ -1658,7 +1663,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file) · 79 unmodified lines
16581663 size1);
16591664 size1 /= runtime->channels; /* frames */
16601665 fs = snd_enter_user();
1661− snd_pcm_lib_write(substream, (void __user *)runtime->oss.buffer, size1);
1666+ snd_pcm_lib_write(substream, (void __force __user *)runtime->oss.buffer, size1);
16621667 snd_leave_user(fs);
16631668 }
16641669 } else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) {
sound/core/oss/pcm_plugin.c+22−18
@@ -264,7 +264,7 @@ snd_pcm_sframes_t snd_pcm_plug_slave_size(struct snd_pcm_substream *plug, snd_pc · 263 unmodified lines
264264 return frames;
265265 }
266266
267−static int snd_pcm_plug_formats(struct snd_mask *mask, int format)
267+static int snd_pcm_plug_formats(struct snd_mask *mask, snd_pcm_format_t format)
268268 {
269269 struct snd_mask formats = *mask;
270270 u64 linfmts = (SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S8 |
@@ -276,16 +276,16 @@ static int snd_pcm_plug_formats(struct snd_mask *mask, int format) · 5 unmodified lines
276276 SNDRV_PCM_FMTBIT_U24_3BE | SNDRV_PCM_FMTBIT_S24_3BE |
277277 SNDRV_PCM_FMTBIT_U32_LE | SNDRV_PCM_FMTBIT_S32_LE |
278278 SNDRV_PCM_FMTBIT_U32_BE | SNDRV_PCM_FMTBIT_S32_BE);
279− snd_mask_set(&formats, SNDRV_PCM_FORMAT_MU_LAW);
279+ snd_mask_set(&formats, (__force int)SNDRV_PCM_FORMAT_MU_LAW);
280280
281281 if (formats.bits[0] & (u32)linfmts)
282282 formats.bits[0] |= (u32)linfmts;
283283 if (formats.bits[1] & (u32)(linfmts >> 32))
284284 formats.bits[1] |= (u32)(linfmts >> 32);
285− return snd_mask_test(&formats, format);
285+ return snd_mask_test(&formats, (__force int)format);
286286 }
287287
288−static int preferred_formats[] = {
288+static snd_pcm_format_t preferred_formats[] = {
289289 SNDRV_PCM_FORMAT_S16_LE,
290290 SNDRV_PCM_FORMAT_S16_BE,
291291 SNDRV_PCM_FORMAT_U16_LE,
@@ -306,24 +306,25 @@ static int preferred_formats[] = { · 14 unmodified lines
306306 SNDRV_PCM_FORMAT_U8
307307 };
308308
309−int snd_pcm_plug_slave_format(int format, struct snd_mask *format_mask)
309+snd_pcm_format_t snd_pcm_plug_slave_format(snd_pcm_format_t format,
310+ struct snd_mask *format_mask)
310311 {
311312 int i;
312313
313− if (snd_mask_test(format_mask, format))
314+ if (snd_mask_test(format_mask, (__force int)format))
314315 return format;
315− if (! snd_pcm_plug_formats(format_mask, format))
316− return -EINVAL;
316+ if (!snd_pcm_plug_formats(format_mask, format))
317+ return (__force snd_pcm_format_t)-EINVAL;
317318 if (snd_pcm_format_linear(format)) {
318319 unsigned int width = snd_pcm_format_width(format);
319320 int unsignd = snd_pcm_format_unsigned(format) > 0;
320321 int big = snd_pcm_format_big_endian(format) > 0;
321322 unsigned int badness, best = -1;
322− int best_format = -1;
323+ snd_pcm_format_t best_format = (__force snd_pcm_format_t)-1;
323324 for (i = 0; i < ARRAY_SIZE(preferred_formats); i++) {
324− int f = preferred_formats[i];
325+ snd_pcm_format_t f = preferred_formats[i];
325326 unsigned int w;
326− if (!snd_mask_test(format_mask, f))
327+ if (!snd_mask_test(format_mask, (__force int)f))
327328 continue;
328329 w = snd_pcm_format_width(f);
329330 if (w >= width)
@@ -337,17 +338,20 @@ int snd_pcm_plug_slave_format(int format, struct snd_mask *format_mask) · 7 unmodified lines
337338 best = badness;
338339 }
339340 }
340− return best_format >= 0 ? best_format : -EINVAL;
341+ if ((__force int)best_format >= 0)
342+ return best_format;
343+ else
344+ return (__force snd_pcm_format_t)-EINVAL;
341345 } else {
342346 switch (format) {
343347 case SNDRV_PCM_FORMAT_MU_LAW:
344348 for (i = 0; i < ARRAY_SIZE(preferred_formats); ++i) {
345− int format1 = preferred_formats[i];
346− if (snd_mask_test(format_mask, format1))
349+ snd_pcm_format_t format1 = preferred_formats[i];
350+ if (snd_mask_test(format_mask, (__force int)format1))
347351 return format1;
348352 }
349353 default:
350− return -EINVAL;
354+ return (__force snd_pcm_format_t)-EINVAL;
351355 }
352356 }
353357 }
@@ -359,7 +363,7 @@ int snd_pcm_plug_format_plugins(struct snd_pcm_substream *plug, · 5 unmodified lines
359363 struct snd_pcm_plugin_format tmpformat;
360364 struct snd_pcm_plugin_format dstformat;
361365 struct snd_pcm_plugin_format srcformat;
362− int src_access, dst_access;
366+ snd_pcm_access_t src_access, dst_access;
363367 struct snd_pcm_plugin *plugin = NULL;
364368 int err;
365369 int stream = snd_pcm_plug_stream(plug);
@@ -641,7 +645,7 @@ snd_pcm_sframes_t snd_pcm_plug_read_transfer(struct snd_pcm_substream *plug, str · 275 unmodified lines
641645 }
642646
643647 int snd_pcm_area_silence(const struct snd_pcm_channel_area *dst_area, size_t dst_offset,
644− size_t samples, int format)
648+ size_t samples, snd_pcm_format_t format)
645649 {
646650 /* FIXME: sub byte resolution and odd dst_offset */
647651 unsigned char *dst;
@@ -688,7 +692,7 @@ int snd_pcm_area_silence(const struct snd_pcm_channel_area *dst_area, size_t dst · 40 unmodified lines
688692
689693 int snd_pcm_area_copy(const struct snd_pcm_channel_area *src_area, size_t src_offset,
690694 const struct snd_pcm_channel_area *dst_area, size_t dst_offset,
691− size_t samples, int format)
695+ size_t samples, snd_pcm_format_t format)
692696 {
693697 /* FIXME: sub byte resolution and odd dst_offset */
694698 char *src, *dst;
sound/core/oss/pcm_plugin.h+6−5
@@ -46,7 +46,7 @@ struct snd_pcm_plugin_channel { · 45 unmodified lines
4646 };
4747
4848 struct snd_pcm_plugin_format {
49− int format;
49+ snd_pcm_format_t format;
5050 unsigned int rate;
5151 unsigned int channels;
5252 };
@@ -58,7 +58,7 @@ struct snd_pcm_plugin { · 5 unmodified lines
5858 struct snd_pcm_plugin_format dst_format; /* destination format */
5959 int src_width; /* sample width in bits */
6060 int dst_width; /* sample width in bits */
61− int access;
61+ snd_pcm_access_t access;
6262 snd_pcm_sframes_t (*src_frames)(struct snd_pcm_plugin *plugin, snd_pcm_uframes_t dst_frames);
6363 snd_pcm_sframes_t (*dst_frames)(struct snd_pcm_plugin *plugin, snd_pcm_uframes_t src_frames);
6464 snd_pcm_sframes_t (*client_channels)(struct snd_pcm_plugin *plugin,
@@ -125,7 +125,8 @@ int snd_pcm_plug_format_plugins(struct snd_pcm_substream *substream, · 60 unmodified lines
125125 struct snd_pcm_hw_params *params,
126126 struct snd_pcm_hw_params *slave_params);
127127
128−int snd_pcm_plug_slave_format(int format, struct snd_mask *format_mask);
128+snd_pcm_format_t snd_pcm_plug_slave_format(snd_pcm_format_t format,
129+ struct snd_mask *format_mask);
129130
130131 int snd_pcm_plugin_append(struct snd_pcm_plugin *plugin);
131132
@@ -146,12 +147,12 @@ snd_pcm_sframes_t snd_pcm_plugin_client_channels(struct snd_pcm_plugin *plugin, · 14 unmodified lines
146147
147148 int snd_pcm_area_silence(const struct snd_pcm_channel_area *dst_channel,
148149 size_t dst_offset,
149− size_t samples, int format);
150+ size_t samples, snd_pcm_format_t format);
150151 int snd_pcm_area_copy(const struct snd_pcm_channel_area *src_channel,
151152 size_t src_offset,
152153 const struct snd_pcm_channel_area *dst_channel,
153154 size_t dst_offset,
154− size_t samples, int format);
155+ size_t samples, snd_pcm_format_t format);
155156
156157 void *snd_pcm_plug_buf_alloc(struct snd_pcm_substream *plug, snd_pcm_uframes_t size);
157158 void snd_pcm_plug_buf_unlock(struct snd_pcm_substream *plug, void *ptr);
sound/core/oss/route.c+3−3
@@ -25,7 +25,7 @@ · 24 unmodified lines
2525 #include "pcm_plugin.h"
2626
2727 static void zero_areas(struct snd_pcm_plugin_channel *dvp, int ndsts,
28− snd_pcm_uframes_t frames, int format)
28+ snd_pcm_uframes_t frames, snd_pcm_format_t format)
2929 {
3030 int dst = 0;
3131 for (; dst < ndsts; ++dst) {
@@ -38,7 +38,7 @@ static void zero_areas(struct snd_pcm_plugin_channel *dvp, int ndsts, · 6 unmodified lines
3838
3939 static inline void copy_area(const struct snd_pcm_plugin_channel *src_channel,
4040 struct snd_pcm_plugin_channel *dst_channel,
41− snd_pcm_uframes_t frames, int format)
41+ snd_pcm_uframes_t frames, snd_pcm_format_t format)
4242 {
4343 dst_channel->enabled = 1;
4444 snd_pcm_area_copy(&src_channel->area, 0, &dst_channel->area, 0, frames, format);
@@ -51,7 +51,7 @@ static snd_pcm_sframes_t route_transfer(struct snd_pcm_plugin *plugin, · 6 unmodified lines
5151 {
5252 int nsrcs, ndsts, dst;
5353 struct snd_pcm_plugin_channel *dvp;
54− int format;
54+ snd_pcm_format_t format;
5555
5656 if (snd_BUG_ON(!plugin || !src_channels || !dst_channels))
5757 return -ENXIO;
sound/core/pcm.c+5−5
@@ -211,9 +211,9 @@ static char *snd_pcm_format_names[] = { · 210 unmodified lines
211211
212212 const char *snd_pcm_format_name(snd_pcm_format_t format)
213213 {
214− if (format >= ARRAY_SIZE(snd_pcm_format_names))
214+ if ((__force unsigned int)format >= ARRAY_SIZE(snd_pcm_format_names))
215215 return "Unknown";
216− return snd_pcm_format_names[format];
216+ return snd_pcm_format_names[(__force unsigned int)format];
217217 }
218218 EXPORT_SYMBOL_GPL(snd_pcm_format_name);
219219
@@ -269,12 +269,12 @@ static const char *snd_pcm_stream_name(int stream) · 49 unmodified lines
269269
270270 static const char *snd_pcm_access_name(snd_pcm_access_t access)
271271 {
272− return snd_pcm_access_names[access];
272+ return snd_pcm_access_names[(__force int)access];
273273 }
274274
275275 static const char *snd_pcm_subformat_name(snd_pcm_subformat_t subformat)
276276 {
277− return snd_pcm_subformat_names[subformat];
277+ return snd_pcm_subformat_names[(__force int)subformat];
278278 }
279279
280280 static const char *snd_pcm_tstamp_mode_name(int mode)
@@ -284,7 +284,7 @@ static const char *snd_pcm_tstamp_mode_name(int mode) · 3 unmodified lines
284284
285285 static const char *snd_pcm_state_name(snd_pcm_state_t state)
286286 {
287− return snd_pcm_state_names[state];
287+ return snd_pcm_state_names[(__force int)state];
288288 }
289289
290290 #if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE)
sound/core/pcm_misc.c+19−16
@@ -35,7 +35,10 @@ struct pcm_format_data { · 34 unmodified lines
3535 unsigned char silence[8]; /* silence data to fill */
3636 };
3737
38−static struct pcm_format_data pcm_formats[SNDRV_PCM_FORMAT_LAST+1] = {
38+/* we do lots of calculations on snd_pcm_format_t; shut up sparse */
39+#define INT __force int
40+
41+static struct pcm_format_data pcm_formats[(INT)SNDRV_PCM_FORMAT_LAST+1] = {
3942 [SNDRV_PCM_FORMAT_S8] = {
4043 .width = 8, .phys = 8, .le = -1, .signd = 1,
4144 .silence = {},
@@ -215,9 +218,9 @@ static struct pcm_format_data pcm_formats[SNDRV_PCM_FORMAT_LAST+1] = { · 173 unmodified lines
215218 int snd_pcm_format_signed(snd_pcm_format_t format)
216219 {
217220 int val;
218− if (format < 0 || format > SNDRV_PCM_FORMAT_LAST)
221+ if ((INT)format < 0 || (INT)format > (INT)SNDRV_PCM_FORMAT_LAST)
219222 return -EINVAL;
220− if ((val = pcm_formats[format].signd) < 0)
223+ if ((val = pcm_formats[(INT)format].signd) < 0)
221224 return -EINVAL;
222225 return val;
223226 }
@@ -266,9 +269,9 @@ EXPORT_SYMBOL(snd_pcm_format_linear); · 42 unmodified lines
266269 int snd_pcm_format_little_endian(snd_pcm_format_t format)
267270 {
268271 int val;
269− if (format < 0 || format > SNDRV_PCM_FORMAT_LAST)
272+ if ((INT)format < 0 || (INT)format > (INT)SNDRV_PCM_FORMAT_LAST)
270273 return -EINVAL;
271− if ((val = pcm_formats[format].le) < 0)
274+ if ((val = pcm_formats[(INT)format].le) < 0)
272275 return -EINVAL;
273276 return val;
274277 }
@@ -304,9 +307,9 @@ EXPORT_SYMBOL(snd_pcm_format_big_endian); · 29 unmodified lines
304307 int snd_pcm_format_width(snd_pcm_format_t format)
305308 {
306309 int val;
307− if (format < 0 || format > SNDRV_PCM_FORMAT_LAST)
310+ if ((INT)format < 0 || (INT)format > (INT)SNDRV_PCM_FORMAT_LAST)
308311 return -EINVAL;
309− if ((val = pcm_formats[format].width) == 0)
312+ if ((val = pcm_formats[(INT)format].width) == 0)
310313 return -EINVAL;
311314 return val;
312315 }
@@ -323,9 +326,9 @@ EXPORT_SYMBOL(snd_pcm_format_width); · 10 unmodified lines
323326 int snd_pcm_format_physical_width(snd_pcm_format_t format)
324327 {
325328 int val;
326− if (format < 0 || format > SNDRV_PCM_FORMAT_LAST)
329+ if ((INT)format < 0 || (INT)format > (INT)SNDRV_PCM_FORMAT_LAST)
327330 return -EINVAL;
328− if ((val = pcm_formats[format].phys) == 0)
331+ if ((val = pcm_formats[(INT)format].phys) == 0)
329332 return -EINVAL;
330333 return val;
331334 }
@@ -358,11 +361,11 @@ EXPORT_SYMBOL(snd_pcm_format_size); · 26 unmodified lines
358361 */
359362 const unsigned char *snd_pcm_format_silence_64(snd_pcm_format_t format)
360363 {
361− if (format < 0 || format > SNDRV_PCM_FORMAT_LAST)
364+ if ((INT)format < 0 || (INT)format > (INT)SNDRV_PCM_FORMAT_LAST)
362365 return NULL;
363− if (! pcm_formats[format].phys)
366+ if (! pcm_formats[(INT)format].phys)
364367 return NULL;
365− return pcm_formats[format].silence;
368+ return pcm_formats[(INT)format].silence;
366369 }
367370
368371 EXPORT_SYMBOL(snd_pcm_format_silence_64);
@@ -382,16 +385,16 @@ int snd_pcm_format_set_silence(snd_pcm_format_t format, void *data, unsigned int · 13 unmodified lines
382385 int width;
383386 unsigned char *dst, *pat;
384387
385− if (format < 0 || format > SNDRV_PCM_FORMAT_LAST)
388+ if ((INT)format < 0 || (INT)format > (INT)SNDRV_PCM_FORMAT_LAST)
386389 return -EINVAL;
387390 if (samples == 0)
388391 return 0;
389− width = pcm_formats[format].phys; /* physical width */
390− pat = pcm_formats[format].silence;
392+ width = pcm_formats[(INT)format].phys; /* physical width */
393+ pat = pcm_formats[(INT)format].silence;
391394 if (! width)
392395 return -EINVAL;
393396 /* signed or 1 byte data */
394− if (pcm_formats[format].signd == 1 || width <= 8) {
397+ if (pcm_formats[(INT)format].signd == 1 || width <= 8) {
395398 unsigned int bytes = samples * width / 8;
396399 memset(data, *pat, bytes);
397400 return 0;
sound/core/pcm_native.c+1−1
@@ -941,7 +941,7 @@ static struct action_ops snd_pcm_action_stop = { · 940 unmodified lines
941941 *
942942 * The state of each stream is then changed to the given state unconditionally.
943943 */
944−int snd_pcm_stop(struct snd_pcm_substream *substream, int state)
944+int snd_pcm_stop(struct snd_pcm_substream *substream, snd_pcm_state_t state)
945945 {
946946 return snd_pcm_action(&snd_pcm_action_stop, substream, state);
947947 }
sound/core/seq/seq_clientmgr.c+2−5
@@ -1052,7 +1052,7 @@ static ssize_t snd_seq_write(struct file *file, const char __user *buf, · 1051 unmodified lines
10521052 } else {
10531053 #ifdef CONFIG_COMPAT
10541054 if (client->convert32 && snd_seq_ev_is_varusr(&event)) {
1055− void *ptr = compat_ptr(event.data.raw32.d[1]);
1055+ void *ptr = (void __force *)compat_ptr(event.data.raw32.d[1]);
10561056 event.data.ext.ptr = ptr;
10571057 }
10581058 #endif
@@ -2407,7 +2407,7 @@ int snd_seq_kernel_client_ctl(int clientid, unsigned int cmd, void *arg) · 1348 unmodified lines
24072407 if (client == NULL)
24082408 return -ENXIO;
24092409 fs = snd_enter_user();
2410− result = snd_seq_do_ioctl(client, cmd, (void __user *)arg);
2410+ result = snd_seq_do_ioctl(client, cmd, (void __force __user *)arg);
24112411 snd_leave_user(fs);
24122412 return result;
24132413 }
@@ -2497,9 +2497,6 @@ static void snd_seq_info_dump_ports(struct snd_info_buffer *buffer, · 83 unmodified lines
24972497 }
24982498
24992499
2500−void snd_seq_info_pool(struct snd_info_buffer *buffer,
2501− struct snd_seq_pool *pool, char *space);
2502−
25032500 /* exported to seq_info.c */
25042501 void snd_seq_info_clients_read(struct snd_info_entry *entry,
25052502 struct snd_info_buffer *buffer)
sound/core/seq/seq_memory.c+3−3
@@ -86,7 +86,7 @@ int snd_seq_dump_var_event(const struct snd_seq_event *event, · 85 unmodified lines
8686
8787 if (event->data.ext.len & SNDRV_SEQ_EXT_USRPTR) {
8888 char buf[32];
89− char __user *curptr = (char __user *)event->data.ext.ptr;
89+ char __user *curptr = (char __force __user *)event->data.ext.ptr;
9090 while (len > 0) {
9191 int size = sizeof(buf);
9292 if (len < size)
@@ -157,7 +157,7 @@ int snd_seq_expand_var_event(const struct snd_seq_event *event, int count, char · 64 unmodified lines
157157 if (event->data.ext.len & SNDRV_SEQ_EXT_USRPTR) {
158158 if (! in_kernel)
159159 return -EINVAL;
160− if (copy_from_user(buf, (void __user *)event->data.ext.ptr, len))
160+ if (copy_from_user(buf, (void __force __user *)event->data.ext.ptr, len))
161161 return -EFAULT;
162162 return newlen;
163163 }
@@ -343,7 +343,7 @@ int snd_seq_event_dup(struct snd_seq_pool *pool, struct snd_seq_event *event, · 179 unmodified lines
343343 tmp->event = src->event;
344344 src = src->next;
345345 } else if (is_usrptr) {
346− if (copy_from_user(&tmp->event, (char __user *)buf, size)) {
346+ if (copy_from_user(&tmp->event, (char __force __user *)buf, size)) {
347347 err = -EFAULT;
348348 goto __error;
349349 }
sound/core/seq/seq_memory.h+4−0
@@ -24,6 +24,8 @@ · 23 unmodified lines
2424 #include <sound/seq_kernel.h>
2525 #include <linux/poll.h>
2626
27+struct snd_info_buffer;
28+
2729 /* container for sequencer event (internal use) */
2830 struct snd_seq_event_cell {
2931 struct snd_seq_event event;
@@ -99,5 +101,7 @@ void snd_sequencer_memory_done(void); · 69 unmodified lines
99101 /* polling */
100102 int snd_seq_pool_poll_wait(struct snd_seq_pool *pool, struct file *file, poll_table *wait);
101103
104+void snd_seq_info_pool(struct snd_info_buffer *buffer,
105+ struct snd_seq_pool *pool, char *space);
102106
103107 #endif
sound/core/seq/seq_ports.c+1−1
@@ -412,7 +412,7 @@ int snd_seq_get_port_info(struct snd_seq_client_port * port, · 411 unmodified lines
412412 * initialization or termination of devices (see seq_midi.c).
413413 *
414414 * If callback_all option is set, the callback function is invoked
415− * at each connnection/disconnection.
415+ * at each connection/disconnection.
416416 */
417417
418418 static int subscribe_port(struct snd_seq_client *client,
sound/core/timer.c+3−5
@@ -186,9 +186,8 @@ static void snd_timer_check_slave(struct snd_timer_instance *slave) · 185 unmodified lines
186186 list_for_each_entry(master, &timer->open_list_head, open_list) {
187187 if (slave->slave_class == master->slave_class &&
188188 slave->slave_id == master->slave_id) {
189− list_del(&slave->open_list);
190− list_add_tail(&slave->open_list,
191− &master->slave_list_head);
189+ list_move_tail(&slave->open_list,
190+ &master->slave_list_head);
192191 spin_lock_irq(&slave_active_lock);
193192 slave->master = master;
194193 slave->timer = master->timer;
@@ -414,8 +413,7 @@ static void snd_timer_notify1(struct snd_timer_instance *ti, int event) · 219 unmodified lines
414413 static int snd_timer_start1(struct snd_timer *timer, struct snd_timer_instance *timeri,
415414 unsigned long sticks)
416415 {
417− list_del(&timeri->active_list);
418− list_add_tail(&timeri->active_list, &timer->active_list_head);
416+ list_move_tail(&timeri->active_list, &timer->active_list_head);
419417 if (timer->running) {
420418 if (timer->hw.flags & SNDRV_TIMER_HW_SLAVE)
421419 goto __start_now;
sound/core/vmaster.c+1−1
@@ -18,7 +18,7 @@ · 17 unmodified lines
1818 * a subset of information returned via ctl info callback
1919 */
2020 struct link_ctl_info {
21− int type; /* value type */
21+ snd_ctl_elem_type_t type; /* value type */
2222 int count; /* item count */
2323 int min_val, max_val; /* min, max values */
2424 };
sound/drivers/aloop.c+9−10
@@ -482,8 +482,9 @@ static unsigned int loopback_pos_update(struct loopback_cable *cable) · 481 unmodified lines
482482 cable->streams[SNDRV_PCM_STREAM_CAPTURE];
483483 unsigned long delta_play = 0, delta_capt = 0;
484484 unsigned int running;
485+ unsigned long flags;
485486
486− spin_lock(&cable->lock);
487+ spin_lock_irqsave(&cable->lock, flags);
487488 running = cable->running ^ cable->pause;
488489 if (running & (1 << SNDRV_PCM_STREAM_PLAYBACK)) {
489490 delta_play = jiffies - dpcm_play->last_jiffies;
@@ -495,10 +496,8 @@ static unsigned int loopback_pos_update(struct loopback_cable *cable) · 5 unmodified lines
495496 dpcm_capt->last_jiffies += delta_capt;
496497 }
497498
498− if (delta_play == 0 && delta_capt == 0) {
499− spin_unlock(&cable->lock);
500− return running;
501− }
499+ if (delta_play == 0 && delta_capt == 0)
500+ goto unlock;
502501
503502 if (delta_play > delta_capt) {
504503 loopback_bytepos_update(dpcm_play, delta_play - delta_capt,
@@ -510,14 +509,14 @@ static unsigned int loopback_pos_update(struct loopback_cable *cable) · 5 unmodified lines
510509 delta_capt = delta_play;
511510 }
512511
513− if (delta_play == 0 && delta_capt == 0) {
514− spin_unlock(&cable->lock);
515− return running;
516− }
512+ if (delta_play == 0 && delta_capt == 0)
513+ goto unlock;
514+
517515 /* note delta_capt == delta_play at this moment */
518516 loopback_bytepos_update(dpcm_capt, delta_capt, BYTEPOS_UPDATE_COPY);
519517 loopback_bytepos_update(dpcm_play, delta_play, BYTEPOS_UPDATE_POSONLY);
520− spin_unlock(&cable->lock);
518+ unlock:
519+ spin_unlock_irqrestore(&cable->lock, flags);
521520 return running;
522521 }
523522
sound/firewire/Kconfig+25−0
@@ -0,0 +1,25 @@
1+menuconfig SND_FIREWIRE
2+ bool "FireWire sound devices"
3+ depends on FIREWIRE
4+ default y
5+ help
6+ Support for IEEE-1394/FireWire/iLink sound devices.
7+
8+if SND_FIREWIRE && FIREWIRE
9+
10+config SND_FIREWIRE_LIB
11+ tristate
12+ depends on SND_PCM
13+
14+config SND_FIREWIRE_SPEAKERS
15+ tristate "FireWire speakers"
16+ select SND_PCM
17+ select SND_FIREWIRE_LIB
18+ help
19+ Say Y here to include support for the Griffin FireWave Surround
20+ and the LaCie FireWire Speakers.
21+
22+ To compile this driver as a module, choose M here: the module
23+ will be called snd-firewire-speakers.
24+
25+endif # SND_FIREWIRE
sound/firewire/Makefile+6−0
@@ -0,0 +1,6 @@
1+snd-firewire-lib-objs := lib.o iso-resources.o packets-buffer.o \
2+ fcp.o cmp.o amdtp.o
3+snd-firewire-speakers-objs := speakers.o
4+
5+obj-$(CONFIG_SND_FIREWIRE_LIB) += snd-firewire-lib.o
6+obj-$(CONFIG_SND_FIREWIRE_SPEAKERS) += snd-firewire-speakers.o
sound/firewire/amdtp.c+562−0
@@ -0,0 +1,562 @@
1+/*
2+ * Audio and Music Data Transmission Protocol (IEC 61883-6) streams
3+ * with Common Isochronous Packet (IEC 61883-1) headers
4+ *
5+ * Copyright (c) Clemens Ladisch <clemens@ladisch.de>
6+ * Licensed under the terms of the GNU General Public License, version 2.
7+ */
8+
9+#include <linux/device.h>
10+#include <linux/err.h>
11+#include <linux/firewire.h>
12+#include <linux/module.h>
13+#include <linux/slab.h>
14+#include <sound/pcm.h>
15+#include "amdtp.h"
16+
17+#define TICKS_PER_CYCLE 3072
18+#define CYCLES_PER_SECOND 8000
19+#define TICKS_PER_SECOND (TICKS_PER_CYCLE * CYCLES_PER_SECOND)
20+
21+#define TRANSFER_DELAY_TICKS 0x2e00 /* 479.17 µs */
22+
23+#define TAG_CIP 1
24+
25+#define CIP_EOH (1u << 31)
26+#define CIP_FMT_AM (0x10 << 24)
27+#define AMDTP_FDF_AM824 (0 << 19)
28+#define AMDTP_FDF_SFC_SHIFT 16
29+
30+/* TODO: make these configurable */
31+#define INTERRUPT_INTERVAL 16
32+#define QUEUE_LENGTH 48
33+
34+/**
35+ * amdtp_out_stream_init - initialize an AMDTP output stream structure
36+ * @s: the AMDTP output stream to initialize
37+ * @unit: the target of the stream
38+ * @flags: the packet transmission method to use
39+ */
40+int amdtp_out_stream_init(struct amdtp_out_stream *s, struct fw_unit *unit,
41+ enum cip_out_flags flags)
42+{
43+ if (flags != CIP_NONBLOCKING)
44+ return -EINVAL;
45+
46+ s->unit = fw_unit_get(unit);
47+ s->flags = flags;
48+ s->context = ERR_PTR(-1);
49+ mutex_init(&s->mutex);
50+ s->packet_index = 0;
51+
52+ return 0;
53+}
54+EXPORT_SYMBOL(amdtp_out_stream_init);
55+
56+/**
57+ * amdtp_out_stream_destroy - free stream resources
58+ * @s: the AMDTP output stream to destroy
59+ */
60+void amdtp_out_stream_destroy(struct amdtp_out_stream *s)
61+{
62+ WARN_ON(!IS_ERR(s->context));
63+ mutex_destroy(&s->mutex);
64+ fw_unit_put(s->unit);
65+}
66+EXPORT_SYMBOL(amdtp_out_stream_destroy);
67+
68+/**
69+ * amdtp_out_stream_set_rate - set the sample rate
70+ * @s: the AMDTP output stream to configure
71+ * @rate: the sample rate
72+ *
73+ * The sample rate must be set before the stream is started, and must not be
74+ * changed while the stream is running.
75+ */
76+void amdtp_out_stream_set_rate(struct amdtp_out_stream *s, unsigned int rate)
77+{
78+ static const struct {
79+ unsigned int rate;
80+ unsigned int syt_interval;
81+ } rate_info[] = {
82+ [CIP_SFC_32000] = { 32000, 8, },
83+ [CIP_SFC_44100] = { 44100, 8, },
84+ [CIP_SFC_48000] = { 48000, 8, },
85+ [CIP_SFC_88200] = { 88200, 16, },
86+ [CIP_SFC_96000] = { 96000, 16, },
87+ [CIP_SFC_176400] = { 176400, 32, },
88+ [CIP_SFC_192000] = { 192000, 32, },
89+ };
90+ unsigned int sfc;
91+
92+ if (WARN_ON(!IS_ERR(s->context)))
93+ return;
94+
95+ for (sfc = 0; sfc < ARRAY_SIZE(rate_info); ++sfc)
96+ if (rate_info[sfc].rate == rate) {
97+ s->sfc = sfc;
98+ s->syt_interval = rate_info[sfc].syt_interval;
99+ return;
100+ }
101+ WARN_ON(1);
102+}
103+EXPORT_SYMBOL(amdtp_out_stream_set_rate);
104+
105+/**
106+ * amdtp_out_stream_get_max_payload - get the stream's packet size
107+ * @s: the AMDTP output stream
108+ *
109+ * This function must not be called before the stream has been configured
110+ * with amdtp_out_stream_set_hw_params(), amdtp_out_stream_set_pcm(), and
111+ * amdtp_out_stream_set_midi().
112+ */
113+unsigned int amdtp_out_stream_get_max_payload(struct amdtp_out_stream *s)
114+{
115+ static const unsigned int max_data_blocks[] = {
116+ [CIP_SFC_32000] = 4,
117+ [CIP_SFC_44100] = 6,
118+ [CIP_SFC_48000] = 6,
119+ [CIP_SFC_88200] = 12,
120+ [CIP_SFC_96000] = 12,
121+ [CIP_SFC_176400] = 23,
122+ [CIP_SFC_192000] = 24,
123+ };
124+
125+ s->data_block_quadlets = s->pcm_channels;
126+ s->data_block_quadlets += DIV_ROUND_UP(s->midi_ports, 8);
127+
128+ return 8 + max_data_blocks[s->sfc] * 4 * s->data_block_quadlets;
129+}
130+EXPORT_SYMBOL(amdtp_out_stream_get_max_payload);
131+
132+static void amdtp_write_s16(struct amdtp_out_stream *s,
133+ struct snd_pcm_substream *pcm,
134+ __be32 *buffer, unsigned int frames);
135+static void amdtp_write_s32(struct amdtp_out_stream *s,
136+ struct snd_pcm_substream *pcm,
137+ __be32 *buffer, unsigned int frames);
138+
139+/**
140+ * amdtp_out_stream_set_pcm_format - set the PCM format
141+ * @s: the AMDTP output stream to configure
142+ * @format: the format of the ALSA PCM device
143+ *
144+ * The sample format must be set before the stream is started, and must not be
145+ * changed while the stream is running.
146+ */
147+void amdtp_out_stream_set_pcm_format(struct amdtp_out_stream *s,
148+ snd_pcm_format_t format)
149+{
150+ if (WARN_ON(!IS_ERR(s->context)))
151+ return;
152+
153+ switch (format) {
154+ default:
155+ WARN_ON(1);
156+ /* fall through */
157+ case SNDRV_PCM_FORMAT_S16:
158+ s->transfer_samples = amdtp_write_s16;
159+ break;
160+ case SNDRV_PCM_FORMAT_S32:
161+ s->transfer_samples = amdtp_write_s32;
162+ break;
163+ }
164+}
165+EXPORT_SYMBOL(amdtp_out_stream_set_pcm_format);
166+
167+static unsigned int calculate_data_blocks(struct amdtp_out_stream *s)
168+{
169+ unsigned int phase, data_blocks;
170+
171+ if (!cip_sfc_is_base_44100(s->sfc)) {
172+ /* Sample_rate / 8000 is an integer, and precomputed. */
173+ data_blocks = s->data_block_state;
174+ } else {
175+ phase = s->data_block_state;
176+
177+ /*
178+ * This calculates the number of data blocks per packet so that
179+ * 1) the overall rate is correct and exactly synchronized to
180+ * the bus clock, and
181+ * 2) packets with a rounded-up number of blocks occur as early
182+ * as possible in the sequence (to prevent underruns of the
183+ * device's buffer).
184+ */
185+ if (s->sfc == CIP_SFC_44100)
186+ /* 6 6 5 6 5 6 5 ... */
187+ data_blocks = 5 + ((phase & 1) ^
188+ (phase == 0 || phase >= 40));
189+ else
190+ /* 12 11 11 11 11 ... or 23 22 22 22 22 ... */
191+ data_blocks = 11 * (s->sfc >> 1) + (phase == 0);
192+ if (++phase >= (80 >> (s->sfc >> 1)))
193+ phase = 0;
194+ s->data_block_state = phase;
195+ }
196+
197+ return data_blocks;
198+}
199+
200+static unsigned int calculate_syt(struct amdtp_out_stream *s,
201+ unsigned int cycle)
202+{
203+ unsigned int syt_offset, phase, index, syt;
204+
205+ if (s->last_syt_offset < TICKS_PER_CYCLE) {
206+ if (!cip_sfc_is_base_44100(s->sfc))
207+ syt_offset = s->last_syt_offset + s->syt_offset_state;
208+ else {
209+ /*
210+ * The time, in ticks, of the n'th SYT_INTERVAL sample is:
211+ * n * SYT_INTERVAL * 24576000 / sample_rate
212+ * Modulo TICKS_PER_CYCLE, the difference between successive
213+ * elements is about 1386.23. Rounding the results of this
214+ * formula to the SYT precision results in a sequence of
215+ * differences that begins with:
216+ * 1386 1386 1387 1386 1386 1386 1387 1386 1386 1386 1387 ...
217+ * This code generates _exactly_ the same sequence.
218+ */
219+ phase = s->syt_offset_state;
220+ index = phase % 13;
221+ syt_offset = s->last_syt_offset;
222+ syt_offset += 1386 + ((index && !(index & 3)) ||
223+ phase == 146);
224+ if (++phase >= 147)
225+ phase = 0;
226+ s->syt_offset_state = phase;
227+ }
228+ } else
229+ syt_offset = s->last_syt_offset - TICKS_PER_CYCLE;
230+ s->last_syt_offset = syt_offset;
231+
232+ if (syt_offset < TICKS_PER_CYCLE) {
233+ syt_offset += TRANSFER_DELAY_TICKS - TICKS_PER_CYCLE;
234+ syt = (cycle + syt_offset / TICKS_PER_CYCLE) << 12;
235+ syt += syt_offset % TICKS_PER_CYCLE;
236+
237+ return syt & 0xffff;
238+ } else {
239+ return 0xffff; /* no info */
240+ }
241+}
242+
243+static void amdtp_write_s32(struct amdtp_out_stream *s,
244+ struct snd_pcm_substream *pcm,
245+ __be32 *buffer, unsigned int frames)
246+{
247+ struct snd_pcm_runtime *runtime = pcm->runtime;
248+ unsigned int channels, remaining_frames, frame_step, i, c;
249+ const u32 *src;
250+
251+ channels = s->pcm_channels;
252+ src = (void *)runtime->dma_area +
253+ s->pcm_buffer_pointer * (runtime->frame_bits / 8);
254+ remaining_frames = runtime->buffer_size - s->pcm_buffer_pointer;
255+ frame_step = s->data_block_quadlets - channels;
256+
257+ for (i = 0; i < frames; ++i) {
258+ for (c = 0; c < channels; ++c) {
259+ *buffer = cpu_to_be32((*src >> 8) | 0x40000000);
260+ src++;
261+ buffer++;
262+ }
263+ buffer += frame_step;
264+ if (--remaining_frames == 0)
265+ src = (void *)runtime->dma_area;
266+ }
267+}
268+
269+static void amdtp_write_s16(struct amdtp_out_stream *s,
270+ struct snd_pcm_substream *pcm,
271+ __be32 *buffer, unsigned int frames)
272+{
273+ struct snd_pcm_runtime *runtime = pcm->runtime;
274+ unsigned int channels, remaining_frames, frame_step, i, c;
275+ const u16 *src;
276+
277+ channels = s->pcm_channels;
278+ src = (void *)runtime->dma_area +
279+ s->pcm_buffer_pointer * (runtime->frame_bits / 8);
280+ remaining_frames = runtime->buffer_size - s->pcm_buffer_pointer;
281+ frame_step = s->data_block_quadlets - channels;
282+
283+ for (i = 0; i < frames; ++i) {
284+ for (c = 0; c < channels; ++c) {
285+ *buffer = cpu_to_be32((*src << 8) | 0x40000000);
286+ src++;
287+ buffer++;
288+ }
289+ buffer += frame_step;
290+ if (--remaining_frames == 0)
291+ src = (void *)runtime->dma_area;
292+ }
293+}
294+
295+static void amdtp_fill_pcm_silence(struct amdtp_out_stream *s,
296+ __be32 *buffer, unsigned int frames)
297+{
298+ unsigned int i, c;
299+
300+ for (i = 0; i < frames; ++i) {
301+ for (c = 0; c < s->pcm_channels; ++c)
302+ buffer[c] = cpu_to_be32(0x40000000);
303+ buffer += s->data_block_quadlets;
304+ }
305+}
306+
307+static void amdtp_fill_midi(struct amdtp_out_stream *s,
308+ __be32 *buffer, unsigned int frames)
309+{
310+ unsigned int i;
311+
312+ for (i = 0; i < frames; ++i)
313+ buffer[s->pcm_channels + i * s->data_block_quadlets] =
314+ cpu_to_be32(0x80000000);
315+}
316+
317+static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle)
318+{
319+ __be32 *buffer;
320+ unsigned int index, data_blocks, syt, ptr;
321+ struct snd_pcm_substream *pcm;
322+ struct fw_iso_packet packet;
323+ int err;
324+
325+ if (s->packet_index < 0)
326+ return;
327+ index = s->packet_index;
328+
329+ data_blocks = calculate_data_blocks(s);
330+ syt = calculate_syt(s, cycle);
331+
332+ buffer = s->buffer.packets[index].buffer;
333+ buffer[0] = cpu_to_be32(ACCESS_ONCE(s->source_node_id_field) |
334+ (s->data_block_quadlets << 16) |
335+ s->data_block_counter);
336+ buffer[1] = cpu_to_be32(CIP_EOH | CIP_FMT_AM | AMDTP_FDF_AM824 |
337+ (s->sfc << AMDTP_FDF_SFC_SHIFT) | syt);
338+ buffer += 2;
339+
340+ pcm = ACCESS_ONCE(s->pcm);
341+ if (pcm)
342+ s->transfer_samples(s, pcm, buffer, data_blocks);
343+ else
344+ amdtp_fill_pcm_silence(s, buffer, data_blocks);
345+ if (s->midi_ports)
346+ amdtp_fill_midi(s, buffer, data_blocks);
347+
348+ s->data_block_counter = (s->data_block_counter + data_blocks) & 0xff;
349+
350+ packet.payload_length = 8 + data_blocks * 4 * s->data_block_quadlets;
351+ packet.interrupt = IS_ALIGNED(index + 1, INTERRUPT_INTERVAL);
352+ packet.skip = 0;
353+ packet.tag = TAG_CIP;
354+ packet.sy = 0;
355+ packet.header_length = 0;
356+
357+ err = fw_iso_context_queue(s->context, &packet, &s->buffer.iso_buffer,
358+ s->buffer.packets[index].offset);
359+ if (err < 0) {
360+ dev_err(&s->unit->device, "queueing error: %d\n", err);
361+ s->packet_index = -1;
362+ amdtp_out_stream_pcm_abort(s);
363+ return;
364+ }
365+
366+ if (++index >= QUEUE_LENGTH)
367+ index = 0;
368+ s->packet_index = index;
369+
370+ if (pcm) {
371+ ptr = s->pcm_buffer_pointer + data_blocks;
372+ if (ptr >= pcm->runtime->buffer_size)
373+ ptr -= pcm->runtime->buffer_size;
374+ ACCESS_ONCE(s->pcm_buffer_pointer) = ptr;
375+
376+ s->pcm_period_pointer += data_blocks;
377+ if (s->pcm_period_pointer >= pcm->runtime->period_size) {
378+ s->pcm_period_pointer -= pcm->runtime->period_size;
379+ snd_pcm_period_elapsed(pcm);
380+ }
381+ }
382+}
383+
384+static void out_packet_callback(struct fw_iso_context *context, u32 cycle,
385+ size_t header_length, void *header, void *data)
386+{
387+ struct amdtp_out_stream *s = data;
388+ unsigned int i, packets = header_length / 4;
389+
390+ /*
391+ * Compute the cycle of the last queued packet.
392+ * (We need only the four lowest bits for the SYT, so we can ignore
393+ * that bits 0-11 must wrap around at 3072.)
394+ */
395+ cycle += QUEUE_LENGTH - packets;
396+
397+ for (i = 0; i < packets; ++i)
398+ queue_out_packet(s, ++cycle);
399+}
400+
401+static int queue_initial_skip_packets(struct amdtp_out_stream *s)
402+{
403+ struct fw_iso_packet skip_packet = {
404+ .skip = 1,
405+ };
406+ unsigned int i;
407+ int err;
408+
409+ for (i = 0; i < QUEUE_LENGTH; ++i) {
410+ skip_packet.interrupt = IS_ALIGNED(s->packet_index + 1,
411+ INTERRUPT_INTERVAL);
412+ err = fw_iso_context_queue(s->context, &skip_packet, NULL, 0);
413+ if (err < 0)
414+ return err;
415+ if (++s->packet_index >= QUEUE_LENGTH)
416+ s->packet_index = 0;
417+ }
418+
419+ return 0;
420+}
421+
422+/**
423+ * amdtp_out_stream_start - start sending packets
424+ * @s: the AMDTP output stream to start
425+ * @channel: the isochronous channel on the bus
426+ * @speed: firewire speed code
427+ *
428+ * The stream cannot be started until it has been configured with
429+ * amdtp_out_stream_set_hw_params(), amdtp_out_stream_set_pcm(), and
430+ * amdtp_out_stream_set_midi(); and it must be started before any
431+ * PCM or MIDI device can be started.
432+ */
433+int amdtp_out_stream_start(struct amdtp_out_stream *s, int channel, int speed)
434+{
435+ static const struct {
436+ unsigned int data_block;
437+ unsigned int syt_offset;
438+ } initial_state[] = {
439+ [CIP_SFC_32000] = { 4, 3072 },
440+ [CIP_SFC_48000] = { 6, 1024 },
441+ [CIP_SFC_96000] = { 12, 1024 },
442+ [CIP_SFC_192000] = { 24, 1024 },
443+ [CIP_SFC_44100] = { 0, 67 },
444+ [CIP_SFC_88200] = { 0, 67 },
445+ [CIP_SFC_176400] = { 0, 67 },
446+ };
447+ int err;
448+
449+ mutex_lock(&s->mutex);
450+
451+ if (WARN_ON(!IS_ERR(s->context) ||
452+ (!s->pcm_channels && !s->midi_ports))) {
453+ err = -EBADFD;
454+ goto err_unlock;
455+ }
456+
457+ s->data_block_state = initial_state[s->sfc].data_block;
458+ s->syt_offset_state = initial_state[s->sfc].syt_offset;
459+ s->last_syt_offset = TICKS_PER_CYCLE;
460+
461+ err = iso_packets_buffer_init(&s->buffer, s->unit, QUEUE_LENGTH,
462+ amdtp_out_stream_get_max_payload(s),
463+ DMA_TO_DEVICE);
464+ if (err < 0)
465+ goto err_unlock;
466+
467+ s->context = fw_iso_context_create(fw_parent_device(s->unit)->card,
468+ FW_ISO_CONTEXT_TRANSMIT,
469+ channel, speed, 0,
470+ out_packet_callback, s);
471+ if (IS_ERR(s->context)) {
472+ err = PTR_ERR(s->context);
473+ if (err == -EBUSY)
474+ dev_err(&s->unit->device,
475+ "no free output stream on this controller\n");
476+ goto err_buffer;
477+ }
478+
479+ amdtp_out_stream_update(s);
480+
481+ s->packet_index = 0;
482+ s->data_block_counter = 0;
483+ err = queue_initial_skip_packets(s);
484+ if (err < 0)
485+ goto err_context;
486+
487+ err = fw_iso_context_start(s->context, -1, 0, 0);
488+ if (err < 0)
489+ goto err_context;
490+
491+ mutex_unlock(&s->mutex);
492+
493+ return 0;
494+
495+err_context:
496+ fw_iso_context_destroy(s->context);
497+ s->context = ERR_PTR(-1);
498+err_buffer:
499+ iso_packets_buffer_destroy(&s->buffer, s->unit);
500+err_unlock:
501+ mutex_unlock(&s->mutex);
502+
503+ return err;
504+}
505+EXPORT_SYMBOL(amdtp_out_stream_start);
506+
507+/**
508+ * amdtp_out_stream_update - update the stream after a bus reset
509+ * @s: the AMDTP output stream
510+ */
511+void amdtp_out_stream_update(struct amdtp_out_stream *s)
512+{
513+ ACCESS_ONCE(s->source_node_id_field) =
514+ (fw_parent_device(s->unit)->card->node_id & 0x3f) << 24;
515+}
516+EXPORT_SYMBOL(amdtp_out_stream_update);
517+
518+/**
519+ * amdtp_out_stream_stop - stop sending packets
520+ * @s: the AMDTP output stream to stop
521+ *
522+ * All PCM and MIDI devices of the stream must be stopped before the stream
523+ * itself can be stopped.
524+ */
525+void amdtp_out_stream_stop(struct amdtp_out_stream *s)
526+{
527+ mutex_lock(&s->mutex);
528+
529+ if (IS_ERR(s->context)) {
530+ mutex_unlock(&s->mutex);
531+ return;
532+ }
533+
534+ fw_iso_context_stop(s->context);
535+ fw_iso_context_destroy(s->context);
536+ s->context = ERR_PTR(-1);
537+ iso_packets_buffer_destroy(&s->buffer, s->unit);
538+
539+ mutex_unlock(&s->mutex);
540+}
541+EXPORT_SYMBOL(amdtp_out_stream_stop);
542+
543+/**
544+ * amdtp_out_stream_pcm_abort - abort the running PCM device
545+ * @s: the AMDTP stream about to be stopped
546+ *
547+ * If the isochronous stream needs to be stopped asynchronously, call this
548+ * function first to stop the PCM device.
549+ */
550+void amdtp_out_stream_pcm_abort(struct amdtp_out_stream *s)
551+{
552+ struct snd_pcm_substream *pcm;
553+
554+ pcm = ACCESS_ONCE(s->pcm);
555+ if (pcm) {
556+ snd_pcm_stream_lock_irq(pcm);
557+ if (snd_pcm_running(pcm))
558+ snd_pcm_stop(pcm, SNDRV_PCM_STATE_XRUN);
559+ snd_pcm_stream_unlock_irq(pcm);
560+ }
561+}
562+EXPORT_SYMBOL(amdtp_out_stream_pcm_abort);
sound/firewire/amdtp.h+169−0
@@ -0,0 +1,169 @@
1+#ifndef SOUND_FIREWIRE_AMDTP_H_INCLUDED
2+#define SOUND_FIREWIRE_AMDTP_H_INCLUDED
3+
4+#include <linux/mutex.h>
5+#include <linux/spinlock.h>
6+#include "packets-buffer.h"
7+
8+/**
9+ * enum cip_out_flags - describes details of the streaming protocol
10+ * @CIP_NONBLOCKING: In non-blocking mode, each packet contains
11+ * sample_rate/8000 samples, with rounding up or down to adjust
12+ * for clock skew and left-over fractional samples. This should
13+ * be used if supported by the device.
14+ */
15+enum cip_out_flags {
16+ CIP_NONBLOCKING = 0,
17+};
18+
19+/**
20+ * enum cip_sfc - a stream's sample rate
21+ */
22+enum cip_sfc {
23+ CIP_SFC_32000 = 0,
24+ CIP_SFC_44100 = 1,
25+ CIP_SFC_48000 = 2,
26+ CIP_SFC_88200 = 3,
27+ CIP_SFC_96000 = 4,
28+ CIP_SFC_176400 = 5,
29+ CIP_SFC_192000 = 6,
30+};
31+
32+#define AMDTP_OUT_PCM_FORMAT_BITS (SNDRV_PCM_FMTBIT_S16 | \
33+ SNDRV_PCM_FMTBIT_S32)
34+
35+struct fw_unit;
36+struct fw_iso_context;
37+struct snd_pcm_substream;
38+
39+struct amdtp_out_stream {
40+ struct fw_unit *unit;
41+ enum cip_out_flags flags;
42+ struct fw_iso_context *context;
43+ struct mutex mutex;
44+
45+ enum cip_sfc sfc;
46+ unsigned int data_block_quadlets;
47+ unsigned int pcm_channels;
48+ unsigned int midi_ports;
49+ void (*transfer_samples)(struct amdtp_out_stream *s,
50+ struct snd_pcm_substream *pcm,
51+ __be32 *buffer, unsigned int frames);
52+
53+ unsigned int syt_interval;
54+ unsigned int source_node_id_field;
55+ struct iso_packets_buffer buffer;
56+
57+ struct snd_pcm_substream *pcm;
58+
59+ int packet_index;
60+ unsigned int data_block_counter;
61+
62+ unsigned int data_block_state;
63+
64+ unsigned int last_syt_offset;
65+ unsigned int syt_offset_state;
66+
67+ unsigned int pcm_buffer_pointer;
68+ unsigned int pcm_period_pointer;
69+};
70+
71+int amdtp_out_stream_init(struct amdtp_out_stream *s, struct fw_unit *unit,
72+ enum cip_out_flags flags);
73+void amdtp_out_stream_destroy(struct amdtp_out_stream *s);
74+
75+void amdtp_out_stream_set_rate(struct amdtp_out_stream *s, unsigned int rate);
76+unsigned int amdtp_out_stream_get_max_payload(struct amdtp_out_stream *s);
77+
78+int amdtp_out_stream_start(struct amdtp_out_stream *s, int channel, int speed);
79+void amdtp_out_stream_update(struct amdtp_out_stream *s);
80+void amdtp_out_stream_stop(struct amdtp_out_stream *s);
81+
82+void amdtp_out_stream_set_pcm_format(struct amdtp_out_stream *s,
83+ snd_pcm_format_t format);
84+void amdtp_out_stream_pcm_abort(struct amdtp_out_stream *s);
85+
86+/**
87+ * amdtp_out_stream_set_pcm - configure format of PCM samples
88+ * @s: the AMDTP output stream to be configured
89+ * @pcm_channels: the number of PCM samples in each data block, to be encoded
90+ * as AM824 multi-bit linear audio
91+ *
92+ * This function must not be called while the stream is running.
93+ */
94+static inline void amdtp_out_stream_set_pcm(struct amdtp_out_stream *s,
95+ unsigned int pcm_channels)
96+{
97+ s->pcm_channels = pcm_channels;
98+}
99+
100+/**
101+ * amdtp_out_stream_set_midi - configure format of MIDI data
102+ * @s: the AMDTP output stream to be configured
103+ * @midi_ports: the number of MIDI ports (i.e., MPX-MIDI Data Channels)
104+ *
105+ * This function must not be called while the stream is running.
106+ */
107+static inline void amdtp_out_stream_set_midi(struct amdtp_out_stream *s,
108+ unsigned int midi_ports)
109+{
110+ s->midi_ports = midi_ports;
111+}
112+
113+/**
114+ * amdtp_out_streaming_error - check for streaming error
115+ * @s: the AMDTP output stream
116+ *
117+ * If this function returns true, the stream's packet queue has stopped due to
118+ * an asynchronous error.
119+ */
120+static inline bool amdtp_out_streaming_error(struct amdtp_out_stream *s)
121+{
122+ return s->packet_index < 0;
123+}
124+
125+/**
126+ * amdtp_out_stream_pcm_prepare - prepare PCM device for running
127+ * @s: the AMDTP output stream
128+ *
129+ * This function should be called from the PCM device's .prepare callback.
130+ */
131+static inline void amdtp_out_stream_pcm_prepare(struct amdtp_out_stream *s)
132+{
133+ s->pcm_buffer_pointer = 0;
134+ s->pcm_period_pointer = 0;
135+}
136+
137+/**
138+ * amdtp_out_stream_pcm_trigger - start/stop playback from a PCM device
139+ * @s: the AMDTP output stream
140+ * @pcm: the PCM device to be started, or %NULL to stop the current device
141+ *
142+ * Call this function on a running isochronous stream to enable the actual
143+ * transmission of PCM data. This function should be called from the PCM
144+ * device's .trigger callback.
145+ */
146+static inline void amdtp_out_stream_pcm_trigger(struct amdtp_out_stream *s,
147+ struct snd_pcm_substream *pcm)
148+{
149+ ACCESS_ONCE(s->pcm) = pcm;
150+}
151+
152+/**
153+ * amdtp_out_stream_pcm_pointer - get the PCM buffer position
154+ * @s: the AMDTP output stream that transports the PCM data
155+ *
156+ * Returns the current buffer position, in frames.
157+ */
158+static inline unsigned long
159+amdtp_out_stream_pcm_pointer(struct amdtp_out_stream *s)
160+{
161+ return ACCESS_ONCE(s->pcm_buffer_pointer);
162+}
163+
164+static inline bool cip_sfc_is_base_44100(enum cip_sfc sfc)
165+{
166+ return sfc & 1;
167+}
168+
169+#endif
sound/firewire/cmp.c+308−0
@@ -0,0 +1,308 @@
1+/*
2+ * Connection Management Procedures (IEC 61883-1) helper functions
3+ *
4+ * Copyright (c) Clemens Ladisch <clemens@ladisch.de>
5+ * Licensed under the terms of the GNU General Public License, version 2.
6+ */
7+
8+#include <linux/device.h>
9+#include <linux/firewire.h>
10+#include <linux/firewire-constants.h>
11+#include <linux/module.h>
12+#include <linux/sched.h>
13+#include "lib.h"
14+#include "iso-resources.h"
15+#include "cmp.h"
16+
17+#define IMPR_SPEED_MASK 0xc0000000
18+#define IMPR_SPEED_SHIFT 30
19+#define IMPR_XSPEED_MASK 0x00000060
20+#define IMPR_XSPEED_SHIFT 5
21+#define IMPR_PLUGS_MASK 0x0000001f
22+
23+#define IPCR_ONLINE 0x80000000
24+#define IPCR_BCAST_CONN 0x40000000
25+#define IPCR_P2P_CONN_MASK 0x3f000000
26+#define IPCR_P2P_CONN_SHIFT 24
27+#define IPCR_CHANNEL_MASK 0x003f0000
28+#define IPCR_CHANNEL_SHIFT 16
29+
30+enum bus_reset_handling {
31+ ABORT_ON_BUS_RESET,
32+ SUCCEED_ON_BUS_RESET,
33+};
34+
35+static __attribute__((format(printf, 2, 3)))
36+void cmp_error(struct cmp_connection *c, const char *fmt, ...)
37+{
38+ va_list va;
39+
40+ va_start(va, fmt);
41+ dev_err(&c->resources.unit->device, "%cPCR%u: %pV",
42+ 'i', c->pcr_index, &(struct va_format){ fmt, &va });
43+ va_end(va);
44+}
45+
46+static int pcr_modify(struct cmp_connection *c,
47+ __be32 (*modify)(struct cmp_connection *c, __be32 old),
48+ int (*check)(struct cmp_connection *c, __be32 pcr),
49+ enum bus_reset_handling bus_reset_handling)
50+{
51+ struct fw_device *device = fw_parent_device(c->resources.unit);
52+ __be32 *buffer = c->resources.buffer;
53+ int generation = c->resources.generation;
54+ int rcode, errors = 0;
55+ __be32 old_arg;
56+ int err;
57+
58+ buffer[0] = c->last_pcr_value;
59+ for (;;) {
60+ old_arg = buffer[0];
61+ buffer[1] = modify(c, buffer[0]);
62+
63+ rcode = fw_run_transaction(
64+ device->card, TCODE_LOCK_COMPARE_SWAP,
65+ device->node_id, generation, device->max_speed,
66+ CSR_REGISTER_BASE + CSR_IPCR(c->pcr_index),
67+ buffer, 8);
68+
69+ if (rcode == RCODE_COMPLETE) {
70+ if (buffer[0] == old_arg) /* success? */
71+ break;
72+
73+ if (check) {
74+ err = check(c, buffer[0]);
75+ if (err < 0)
76+ return err;
77+ }
78+ } else if (rcode == RCODE_GENERATION)
79+ goto bus_reset;
80+ else if (rcode_is_permanent_error(rcode) || ++errors >= 3)
81+ goto io_error;
82+ }
83+ c->last_pcr_value = buffer[1];
84+
85+ return 0;
86+
87+io_error:
88+ cmp_error(c, "transaction failed: %s\n", rcode_string(rcode));
89+ return -EIO;
90+
91+bus_reset:
92+ return bus_reset_handling == ABORT_ON_BUS_RESET ? -EAGAIN : 0;
93+}
94+
95+
96+/**
97+ * cmp_connection_init - initializes a connection manager
98+ * @c: the connection manager to initialize
99+ * @unit: a unit of the target device
100+ * @ipcr_index: the index of the iPCR on the target device
101+ */
102+int cmp_connection_init(struct cmp_connection *c,
103+ struct fw_unit *unit,
104+ unsigned int ipcr_index)
105+{
106+ __be32 impr_be;
107+ u32 impr;
108+ int err;
109+
110+ err = snd_fw_transaction(unit, TCODE_READ_QUADLET_REQUEST,
111+ CSR_REGISTER_BASE + CSR_IMPR,
112+ &impr_be, 4);
113+ if (err < 0)
114+ return err;
115+ impr = be32_to_cpu(impr_be);
116+
117+ if (ipcr_index >= (impr & IMPR_PLUGS_MASK))
118+ return -EINVAL;
119+
120+ err = fw_iso_resources_init(&c->resources, unit);
121+ if (err < 0)
122+ return err;
123+
124+ c->connected = false;
125+ mutex_init(&c->mutex);
126+ c->last_pcr_value = cpu_to_be32(0x80000000);
127+ c->pcr_index = ipcr_index;
128+ c->max_speed = (impr & IMPR_SPEED_MASK) >> IMPR_SPEED_SHIFT;
129+ if (c->max_speed == SCODE_BETA)
130+ c->max_speed += (impr & IMPR_XSPEED_MASK) >> IMPR_XSPEED_SHIFT;
131+
132+ return 0;
133+}
134+EXPORT_SYMBOL(cmp_connection_init);
135+
136+/**
137+ * cmp_connection_destroy - free connection manager resources
138+ * @c: the connection manager
139+ */
140+void cmp_connection_destroy(struct cmp_connection *c)
141+{
142+ WARN_ON(c->connected);
143+ mutex_destroy(&c->mutex);
144+ fw_iso_resources_destroy(&c->resources);
145+}
146+EXPORT_SYMBOL(cmp_connection_destroy);
147+
148+
149+static __be32 ipcr_set_modify(struct cmp_connection *c, __be32 ipcr)
150+{
151+ ipcr &= ~cpu_to_be32(IPCR_BCAST_CONN |
152+ IPCR_P2P_CONN_MASK |
153+ IPCR_CHANNEL_MASK);
154+ ipcr |= cpu_to_be32(1 << IPCR_P2P_CONN_SHIFT);
155+ ipcr |= cpu_to_be32(c->resources.channel << IPCR_CHANNEL_SHIFT);
156+
157+ return ipcr;
158+}
159+
160+static int ipcr_set_check(struct cmp_connection *c, __be32 ipcr)
161+{
162+ if (ipcr & cpu_to_be32(IPCR_BCAST_CONN |
163+ IPCR_P2P_CONN_MASK)) {
164+ cmp_error(c, "plug is already in use\n");
165+ return -EBUSY;
166+ }
167+ if (!(ipcr & cpu_to_be32(IPCR_ONLINE))) {
168+ cmp_error(c, "plug is not on-line\n");
169+ return -ECONNREFUSED;
170+ }
171+
172+ return 0;
173+}
174+
175+/**
176+ * cmp_connection_establish - establish a connection to the target
177+ * @c: the connection manager
178+ * @max_payload_bytes: the amount of data (including CIP headers) per packet
179+ *
180+ * This function establishes a point-to-point connection from the local
181+ * computer to the target by allocating isochronous resources (channel and
182+ * bandwidth) and setting the target's input plug control register. When this
183+ * function succeeds, the caller is responsible for starting transmitting
184+ * packets.
185+ */
186+int cmp_connection_establish(struct cmp_connection *c,
187+ unsigned int max_payload_bytes)
188+{
189+ int err;
190+
191+ if (WARN_ON(c->connected))
192+ return -EISCONN;
193+
194+ c->speed = min(c->max_speed,
195+ fw_parent_device(c->resources.unit)->max_speed);
196+
197+ mutex_lock(&c->mutex);
198+
199+retry_after_bus_reset:
200+ err = fw_iso_resources_allocate(&c->resources,
201+ max_payload_bytes, c->speed);
202+ if (err < 0)
203+ goto err_mutex;
204+
205+ err = pcr_modify(c, ipcr_set_modify, ipcr_set_check,
206+ ABORT_ON_BUS_RESET);
207+ if (err == -EAGAIN) {
208+ fw_iso_resources_free(&c->resources);
209+ goto retry_after_bus_reset;
210+ }
211+ if (err < 0)
212+ goto err_resources;
213+
214+ c->connected = true;
215+
216+ mutex_unlock(&c->mutex);
217+
218+ return 0;
219+
220+err_resources:
221+ fw_iso_resources_free(&c->resources);
222+err_mutex:
223+ mutex_unlock(&c->mutex);
224+
225+ return err;
226+}
227+EXPORT_SYMBOL(cmp_connection_establish);
228+
229+/**
230+ * cmp_connection_update - update the connection after a bus reset
231+ * @c: the connection manager
232+ *
233+ * This function must be called from the driver's .update handler to reestablish
234+ * any connection that might have been active.
235+ *
236+ * Returns zero on success, or a negative error code. On an error, the
237+ * connection is broken and the caller must stop transmitting iso packets.
238+ */
239+int cmp_connection_update(struct cmp_connection *c)
240+{
241+ int err;
242+
243+ mutex_lock(&c->mutex);
244+
245+ if (!c->connected) {
246+ mutex_unlock(&c->mutex);
247+ return 0;
248+ }
249+
250+ err = fw_iso_resources_update(&c->resources);
251+ if (err < 0)
252+ goto err_unconnect;
253+
254+ err = pcr_modify(c, ipcr_set_modify, ipcr_set_check,
255+ SUCCEED_ON_BUS_RESET);
256+ if (err < 0)
257+ goto err_resources;
258+
259+ mutex_unlock(&c->mutex);
260+
261+ return 0;
262+
263+err_resources:
264+ fw_iso_resources_free(&c->resources);
265+err_unconnect:
266+ c->connected = false;
267+ mutex_unlock(&c->mutex);
268+
269+ return err;
270+}
271+EXPORT_SYMBOL(cmp_connection_update);
272+
273+
274+static __be32 ipcr_break_modify(struct cmp_connection *c, __be32 ipcr)
275+{
276+ return ipcr & ~cpu_to_be32(IPCR_BCAST_CONN | IPCR_P2P_CONN_MASK);
277+}
278+
279+/**
280+ * cmp_connection_break - break the connection to the target
281+ * @c: the connection manager
282+ *
283+ * This function deactives the connection in the target's input plug control
284+ * register, and frees the isochronous resources of the connection. Before
285+ * calling this function, the caller should cease transmitting packets.
286+ */
287+void cmp_connection_break(struct cmp_connection *c)
288+{
289+ int err;
290+
291+ mutex_lock(&c->mutex);
292+
293+ if (!c->connected) {
294+ mutex_unlock(&c->mutex);
295+ return;
296+ }
297+
298+ err = pcr_modify(c, ipcr_break_modify, NULL, SUCCEED_ON_BUS_RESET);
299+ if (err < 0)
300+ cmp_error(c, "plug is still connected\n");
301+
302+ fw_iso_resources_free(&c->resources);
303+
304+ c->connected = false;
305+
306+ mutex_unlock(&c->mutex);
307+}
308+EXPORT_SYMBOL(cmp_connection_break);
sound/firewire/cmp.h+41−0
@@ -0,0 +1,41 @@
1+#ifndef SOUND_FIREWIRE_CMP_H_INCLUDED
2+#define SOUND_FIREWIRE_CMP_H_INCLUDED
3+
4+#include <linux/mutex.h>
5+#include <linux/types.h>
6+#include "iso-resources.h"
7+
8+struct fw_unit;
9+
10+/**
11+ * struct cmp_connection - manages an isochronous connection to a device
12+ * @speed: the connection's actual speed
13+ *
14+ * This structure manages (using CMP) an isochronous stream from the local
15+ * computer to a device's input plug (iPCR).
16+ *
17+ * There is no corresponding oPCR created on the local computer, so it is not
18+ * possible to overlay connections on top of this one.
19+ */
20+struct cmp_connection {
21+ int speed;
22+ /* private: */
23+ bool connected;
24+ struct mutex mutex;
25+ struct fw_iso_resources resources;
26+ __be32 last_pcr_value;
27+ unsigned int pcr_index;
28+ unsigned int max_speed;
29+};
30+
31+int cmp_connection_init(struct cmp_connection *connection,
32+ struct fw_unit *unit,
33+ unsigned int ipcr_index);
34+void cmp_connection_destroy(struct cmp_connection *connection);
35+
36+int cmp_connection_establish(struct cmp_connection *connection,
37+ unsigned int max_payload);
38+int cmp_connection_update(struct cmp_connection *connection);
39+void cmp_connection_break(struct cmp_connection *connection);
40+
41+#endif
sound/firewire/fcp.c+224−0
@@ -0,0 +1,224 @@
1+/*
2+ * Function Control Protocol (IEC 61883-1) helper functions
3+ *
4+ * Copyright (c) Clemens Ladisch <clemens@ladisch.de>
5+ * Licensed under the terms of the GNU General Public License, version 2.
6+ */
7+
8+#include <linux/device.h>
9+#include <linux/firewire.h>
10+#include <linux/firewire-constants.h>
11+#include <linux/list.h>
12+#include <linux/module.h>
13+#include <linux/sched.h>
14+#include <linux/spinlock.h>
15+#include <linux/wait.h>
16+#include <linux/delay.h>
17+#include "fcp.h"
18+#include "lib.h"
19+
20+#define CTS_AVC 0x00
21+
22+#define ERROR_RETRIES 3
23+#define ERROR_DELAY_MS 5
24+#define FCP_TIMEOUT_MS 125
25+
26+static DEFINE_SPINLOCK(transactions_lock);
27+static LIST_HEAD(transactions);
28+
29+enum fcp_state {
30+ STATE_PENDING,
31+ STATE_BUS_RESET,
32+ STATE_COMPLETE,
33+};
34+
35+struct fcp_transaction {
36+ struct list_head list;
37+ struct fw_unit *unit;
38+ void *response_buffer;
39+ unsigned int response_size;
40+ unsigned int response_match_bytes;
41+ enum fcp_state state;
42+ wait_queue_head_t wait;
43+};
44+
45+/**
46+ * fcp_avc_transaction - send an AV/C command and wait for its response
47+ * @unit: a unit on the target device
48+ * @command: a buffer containing the command frame; must be DMA-able
49+ * @command_size: the size of @command
50+ * @response: a buffer for the response frame
51+ * @response_size: the maximum size of @response
52+ * @response_match_bytes: a bitmap specifying the bytes used to detect the
53+ * correct response frame
54+ *
55+ * This function sends a FCP command frame to the target and waits for the
56+ * corresponding response frame to be returned.
57+ *
58+ * Because it is possible for multiple FCP transactions to be active at the
59+ * same time, the correct response frame is detected by the value of certain
60+ * bytes. These bytes must be set in @response before calling this function,
61+ * and the corresponding bits must be set in @response_match_bytes.
62+ *
63+ * @command and @response can point to the same buffer.
64+ *
65+ * Asynchronous operation (INTERIM, NOTIFY) is not supported at the moment.
66+ *
67+ * Returns the actual size of the response frame, or a negative error code.
68+ */
69+int fcp_avc_transaction(struct fw_unit *unit,
70+ const void *command, unsigned int command_size,
71+ void *response, unsigned int response_size,
72+ unsigned int response_match_bytes)
73+{
74+ struct fcp_transaction t;
75+ int tcode, ret, tries = 0;
76+
77+ t.unit = unit;
78+ t.response_buffer = response;
79+ t.response_size = response_size;
80+ t.response_match_bytes = response_match_bytes;
81+ t.state = STATE_PENDING;
82+ init_waitqueue_head(&t.wait);
83+
84+ spin_lock_irq(&transactions_lock);
85+ list_add_tail(&t.list, &transactions);
86+ spin_unlock_irq(&transactions_lock);
87+
88+ for (;;) {
89+ tcode = command_size == 4 ? TCODE_WRITE_QUADLET_REQUEST
90+ : TCODE_WRITE_BLOCK_REQUEST;
91+ ret = snd_fw_transaction(t.unit, tcode,
92+ CSR_REGISTER_BASE + CSR_FCP_COMMAND,
93+ (void *)command, command_size);
94+ if (ret < 0)
95+ break;
96+
97+ wait_event_timeout(t.wait, t.state != STATE_PENDING,
98+ msecs_to_jiffies(FCP_TIMEOUT_MS));
99+
100+ if (t.state == STATE_COMPLETE) {
101+ ret = t.response_size;
102+ break;
103+ } else if (t.state == STATE_BUS_RESET) {
104+ msleep(ERROR_DELAY_MS);
105+ } else if (++tries >= ERROR_RETRIES) {
106+ dev_err(&t.unit->device, "FCP command timed out\n");
107+ ret = -EIO;
108+ break;
109+ }
110+ }
111+
112+ spin_lock_irq(&transactions_lock);
113+ list_del(&t.list);
114+ spin_unlock_irq(&transactions_lock);
115+
116+ return ret;
117+}
118+EXPORT_SYMBOL(fcp_avc_transaction);
119+
120+/**
121+ * fcp_bus_reset - inform the target handler about a bus reset
122+ * @unit: the unit that might be used by fcp_avc_transaction()
123+ *
124+ * This function must be called from the driver's .update handler to inform
125+ * the FCP transaction handler that a bus reset has happened. Any pending FCP
126+ * transactions are retried.
127+ */
128+void fcp_bus_reset(struct fw_unit *unit)
129+{
130+ struct fcp_transaction *t;
131+
132+ spin_lock_irq(&transactions_lock);
133+ list_for_each_entry(t, &transactions, list) {
134+ if (t->unit == unit &&
135+ t->state == STATE_PENDING) {
136+ t->state = STATE_BUS_RESET;
137+ wake_up(&t->wait);
138+ }
139+ }
140+ spin_unlock_irq(&transactions_lock);
141+}
142+EXPORT_SYMBOL(fcp_bus_reset);
143+
144+/* checks whether the response matches the masked bytes in response_buffer */
145+static bool is_matching_response(struct fcp_transaction *transaction,
146+ const void *response, size_t length)
147+{
148+ const u8 *p1, *p2;
149+ unsigned int mask, i;
150+
151+ p1 = response;
152+ p2 = transaction->response_buffer;
153+ mask = transaction->response_match_bytes;
154+
155+ for (i = 0; ; ++i) {
156+ if ((mask & 1) && p1[i] != p2[i])
157+ return false;
158+ mask >>= 1;
159+ if (!mask)
160+ return true;
161+ if (--length == 0)
162+ return false;
163+ }
164+}
165+
166+static void fcp_response(struct fw_card *card, struct fw_request *request,
167+ int tcode, int destination, int source,
168+ int generation, unsigned long long offset,
169+ void *data, size_t length, void *callback_data)
170+{
171+ struct fcp_transaction *t;
172+ unsigned long flags;
173+
174+ if (length < 1 || (*(const u8 *)data & 0xf0) != CTS_AVC)
175+ return;
176+
177+ spin_lock_irqsave(&transactions_lock, flags);
178+ list_for_each_entry(t, &transactions, list) {
179+ struct fw_device *device = fw_parent_device(t->unit);
180+ if (device->card != card ||
181+ device->generation != generation)
182+ continue;
183+ smp_rmb(); /* node_id vs. generation */
184+ if (device->node_id != source)
185+ continue;
186+
187+ if (t->state == STATE_PENDING &&
188+ is_matching_response(t, data, length)) {
189+ t->state = STATE_COMPLETE;
190+ t->response_size = min((unsigned int)length,
191+ t->response_size);
192+ memcpy(t->response_buffer, data, t->response_size);
193+ wake_up(&t->wait);
194+ }
195+ }
196+ spin_unlock_irqrestore(&transactions_lock, flags);
197+}
198+
199+static struct fw_address_handler response_register_handler = {
200+ .length = 0x200,
201+ .address_callback = fcp_response,
202+};
203+
204+static int __init fcp_module_init(void)
205+{
206+ static const struct fw_address_region response_register_region = {
207+ .start = CSR_REGISTER_BASE + CSR_FCP_RESPONSE,
208+ .end = CSR_REGISTER_BASE + CSR_FCP_END,
209+ };
210+
211+ fw_core_add_address_handler(&response_register_handler,
212+ &response_register_region);
213+
214+ return 0;
215+}
216+
217+static void __exit fcp_module_exit(void)
218+{
219+ WARN_ON(!list_empty(&transactions));
220+ fw_core_remove_address_handler(&response_register_handler);
221+}
222+
223+module_init(fcp_module_init);
224+module_exit(fcp_module_exit);
sound/firewire/fcp.h+12−0
@@ -0,0 +1,12 @@
1+#ifndef SOUND_FIREWIRE_FCP_H_INCLUDED
2+#define SOUND_FIREWIRE_FCP_H_INCLUDED
3+
4+struct fw_unit;
5+
6+int fcp_avc_transaction(struct fw_unit *unit,
7+ const void *command, unsigned int command_size,
8+ void *response, unsigned int response_size,
9+ unsigned int response_match_bytes);
10+void fcp_bus_reset(struct fw_unit *unit);
11+
12+#endif
sound/firewire/iso-resources.c+232−0
@@ -0,0 +1,232 @@
1+/*
2+ * isochronous resources helper functions
3+ *
4+ * Copyright (c) Clemens Ladisch <clemens@ladisch.de>
5+ * Licensed under the terms of the GNU General Public License, version 2.
6+ */
7+
8+#include <linux/device.h>
9+#include <linux/firewire.h>
10+#include <linux/firewire-constants.h>
11+#include <linux/jiffies.h>
12+#include <linux/mutex.h>
13+#include <linux/sched.h>
14+#include <linux/slab.h>
15+#include <linux/spinlock.h>
16+#include "iso-resources.h"
17+
18+/**
19+ * fw_iso_resources_init - initializes a &struct fw_iso_resources
20+ * @r: the resource manager to initialize
21+ * @unit: the device unit for which the resources will be needed
22+ *
23+ * If the device does not support all channel numbers, change @r->channels_mask
24+ * after calling this function.
25+ */
26+int fw_iso_resources_init(struct fw_iso_resources *r, struct fw_unit *unit)
27+{
28+ r->buffer = kmalloc(2 * 4, GFP_KERNEL);
29+ if (!r->buffer)
30+ return -ENOMEM;
31+
32+ r->channels_mask = ~0uLL;
33+ r->unit = fw_unit_get(unit);
34+ mutex_init(&r->mutex);
35+ r->allocated = false;
36+
37+ return 0;
38+}
39+
40+/**
41+ * fw_iso_resources_destroy - destroy a resource manager
42+ * @r: the resource manager that is no longer needed
43+ */
44+void fw_iso_resources_destroy(struct fw_iso_resources *r)
45+{
46+ WARN_ON(r->allocated);
47+ kfree(r->buffer);
48+ mutex_destroy(&r->mutex);
49+ fw_unit_put(r->unit);
50+}
51+
52+static unsigned int packet_bandwidth(unsigned int max_payload_bytes, int speed)
53+{
54+ unsigned int bytes, s400_bytes;
55+
56+ /* iso packets have three header quadlets and quadlet-aligned payload */
57+ bytes = 3 * 4 + ALIGN(max_payload_bytes, 4);
58+
59+ /* convert to bandwidth units (quadlets at S1600 = bytes at S400) */
60+ if (speed <= SCODE_400)
61+ s400_bytes = bytes * (1 << (SCODE_400 - speed));
62+ else
63+ s400_bytes = DIV_ROUND_UP(bytes, 1 << (speed - SCODE_400));
64+
65+ return s400_bytes;
66+}
67+
68+static int current_bandwidth_overhead(struct fw_card *card)
69+{
70+ /*
71+ * Under the usual pessimistic assumption (cable length 4.5 m), the
72+ * isochronous overhead for N cables is 1.797 µs + N * 0.494 µs, or
73+ * 88.3 + N * 24.3 in bandwidth units.
74+ *
75+ * The calculation below tries to deduce N from the current gap count.
76+ * If the gap count has been optimized by measuring the actual packet
77+ * transmission time, this derived overhead should be near the actual
78+ * overhead as well.
79+ */
80+ return card->gap_count < 63 ? card->gap_count * 97 / 10 + 89 : 512;
81+}
82+
83+static int wait_isoch_resource_delay_after_bus_reset(struct fw_card *card)
84+{
85+ for (;;) {
86+ s64 delay = (card->reset_jiffies + HZ) - get_jiffies_64();
87+ if (delay <= 0)
88+ return 0;
89+ if (schedule_timeout_interruptible(delay) > 0)
90+ return -ERESTARTSYS;
91+ }
92+}
93+
94+/**
95+ * fw_iso_resources_allocate - allocate isochronous channel and bandwidth
96+ * @r: the resource manager
97+ * @max_payload_bytes: the amount of data (including CIP headers) per packet
98+ * @speed: the speed (e.g., SCODE_400) at which the packets will be sent
99+ *
100+ * This function allocates one isochronous channel and enough bandwidth for the
101+ * specified packet size.
102+ *
103+ * Returns the channel number that the caller must use for streaming, or
104+ * a negative error code. Due to potentionally long delays, this function is
105+ * interruptible and can return -ERESTARTSYS. On success, the caller is
106+ * responsible for calling fw_iso_resources_update() on bus resets, and
107+ * fw_iso_resources_free() when the resources are not longer needed.
108+ */
109+int fw_iso_resources_allocate(struct fw_iso_resources *r,
110+ unsigned int max_payload_bytes, int speed)
111+{
112+ struct fw_card *card = fw_parent_device(r->unit)->card;
113+ int bandwidth, channel, err;
114+
115+ if (WARN_ON(r->allocated))
116+ return -EBADFD;
117+
118+ r->bandwidth = packet_bandwidth(max_payload_bytes, speed);
119+
120+retry_after_bus_reset:
121+ spin_lock_irq(&card->lock);
122+ r->generation = card->generation;
123+ r->bandwidth_overhead = current_bandwidth_overhead(card);
124+ spin_unlock_irq(&card->lock);
125+
126+ err = wait_isoch_resource_delay_after_bus_reset(card);
127+ if (err < 0)
128+ return err;
129+
130+ mutex_lock(&r->mutex);
131+
132+ bandwidth = r->bandwidth + r->bandwidth_overhead;
133+ fw_iso_resource_manage(card, r->generation, r->channels_mask,
134+ &channel, &bandwidth, true, r->buffer);
135+ if (channel == -EAGAIN) {
136+ mutex_unlock(&r->mutex);
137+ goto retry_after_bus_reset;
138+ }
139+ if (channel >= 0) {
140+ r->channel = channel;
141+ r->allocated = true;
142+ } else {
143+ if (channel == -EBUSY)
144+ dev_err(&r->unit->device,
145+ "isochronous resources exhausted\n");
146+ else
147+ dev_err(&r->unit->device,
148+ "isochronous resource allocation failed\n");
149+ }
150+
151+ mutex_unlock(&r->mutex);
152+
153+ return channel;
154+}
155+
156+/**
157+ * fw_iso_resources_update - update resource allocations after a bus reset
158+ * @r: the resource manager
159+ *
160+ * This function must be called from the driver's .update handler to reallocate
161+ * any resources that were allocated before the bus reset. It is safe to call
162+ * this function if no resources are currently allocated.
163+ *
164+ * Returns a negative error code on failure. If this happens, the caller must
165+ * stop streaming.
166+ */
167+int fw_iso_resources_update(struct fw_iso_resources *r)
168+{
169+ struct fw_card *card = fw_parent_device(r->unit)->card;
170+ int bandwidth, channel;
171+
172+ mutex_lock(&r->mutex);
173+
174+ if (!r->allocated) {
175+ mutex_unlock(&r->mutex);
176+ return 0;
177+ }
178+
179+ spin_lock_irq(&card->lock);
180+ r->generation = card->generation;
181+ r->bandwidth_overhead = current_bandwidth_overhead(card);
182+ spin_unlock_irq(&card->lock);
183+
184+ bandwidth = r->bandwidth + r->bandwidth_overhead;
185+
186+ fw_iso_resource_manage(card, r->generation, 1uLL << r->channel,
187+ &channel, &bandwidth, true, r->buffer);
188+ /*
189+ * When another bus reset happens, pretend that the allocation
190+ * succeeded; we will try again for the new generation later.
191+ */
192+ if (channel < 0 && channel != -EAGAIN) {
193+ r->allocated = false;
194+ if (channel == -EBUSY)
195+ dev_err(&r->unit->device,
196+ "isochronous resources exhausted\n");
197+ else
198+ dev_err(&r->unit->device,
199+ "isochronous resource allocation failed\n");
200+ }
201+
202+ mutex_unlock(&r->mutex);
203+
204+ return channel;
205+}
206+
207+/**
208+ * fw_iso_resources_free - frees allocated resources
209+ * @r: the resource manager
210+ *
211+ * This function deallocates the channel and bandwidth, if allocated.
212+ */
213+void fw_iso_resources_free(struct fw_iso_resources *r)
214+{
215+ struct fw_card *card = fw_parent_device(r->unit)->card;
216+ int bandwidth, channel;
217+
218+ mutex_lock(&r->mutex);
219+
220+ if (r->allocated) {
221+ bandwidth = r->bandwidth + r->bandwidth_overhead;
222+ fw_iso_resource_manage(card, r->generation, 1uLL << r->channel,
223+ &channel, &bandwidth, false, r->buffer);
224+ if (channel < 0)
225+ dev_err(&r->unit->device,
226+ "isochronous resource deallocation failed\n");
227+
228+ r->allocated = false;
229+ }
230+
231+ mutex_unlock(&r->mutex);
232+}
sound/firewire/iso-resources.h+39−0
@@ -0,0 +1,39 @@
1+#ifndef SOUND_FIREWIRE_ISO_RESOURCES_H_INCLUDED
2+#define SOUND_FIREWIRE_ISO_RESOURCES_H_INCLUDED
3+
4+#include <linux/mutex.h>
5+#include <linux/types.h>
6+
7+struct fw_unit;
8+
9+/**
10+ * struct fw_iso_resources - manages channel/bandwidth allocation
11+ * @channels_mask: if the device does not support all channel numbers, set this
12+ * bit mask to something else than the default (all ones)
13+ *
14+ * This structure manages (de)allocation of isochronous resources (channel and
15+ * bandwidth) for one isochronous stream.
16+ */
17+struct fw_iso_resources {
18+ u64 channels_mask;
19+ /* private: */
20+ struct fw_unit *unit;
21+ struct mutex mutex;
22+ unsigned int channel;
23+ unsigned int bandwidth; /* in bandwidth units, without overhead */
24+ unsigned int bandwidth_overhead;
25+ int generation; /* in which allocation is valid */
26+ bool allocated;
27+ __be32 *buffer;
28+};
29+
30+int fw_iso_resources_init(struct fw_iso_resources *r,
31+ struct fw_unit *unit);
32+void fw_iso_resources_destroy(struct fw_iso_resources *r);
33+
34+int fw_iso_resources_allocate(struct fw_iso_resources *r,
35+ unsigned int max_payload_bytes, int speed);
36+int fw_iso_resources_update(struct fw_iso_resources *r);
37+void fw_iso_resources_free(struct fw_iso_resources *r);
38+
39+#endif
sound/firewire/lib.c+85−0
@@ -0,0 +1,85 @@
1+/*
2+ * miscellaneous helper functions
3+ *
4+ * Copyright (c) Clemens Ladisch <clemens@ladisch.de>
5+ * Licensed under the terms of the GNU General Public License, version 2.
6+ */
7+
8+#include <linux/delay.h>
9+#include <linux/device.h>
10+#include <linux/firewire.h>
11+#include <linux/module.h>
12+#include "lib.h"
13+
14+#define ERROR_RETRY_DELAY_MS 5
15+
16+/**
17+ * rcode_string - convert a firewire result code to a string
18+ * @rcode: the result
19+ */
20+const char *rcode_string(unsigned int rcode)
21+{
22+ static const char *const names[] = {
23+ [RCODE_COMPLETE] = "complete",
24+ [RCODE_CONFLICT_ERROR] = "conflict error",
25+ [RCODE_DATA_ERROR] = "data error",
26+ [RCODE_TYPE_ERROR] = "type error",
27+ [RCODE_ADDRESS_ERROR] = "address error",
28+ [RCODE_SEND_ERROR] = "send error",
29+ [RCODE_CANCELLED] = "cancelled",
30+ [RCODE_BUSY] = "busy",
31+ [RCODE_GENERATION] = "generation",
32+ [RCODE_NO_ACK] = "no ack",
33+ };
34+
35+ if (rcode < ARRAY_SIZE(names) && names[rcode])
36+ return names[rcode];
37+ else
38+ return "unknown";
39+}
40+EXPORT_SYMBOL(rcode_string);
41+
42+/**
43+ * snd_fw_transaction - send a request and wait for its completion
44+ * @unit: the driver's unit on the target device
45+ * @tcode: the transaction code
46+ * @offset: the address in the target's address space
47+ * @buffer: input/output data
48+ * @length: length of @buffer
49+ *
50+ * Submits an asynchronous request to the target device, and waits for the
51+ * response. The node ID and the current generation are derived from @unit.
52+ * On a bus reset or an error, the transaction is retried a few times.
53+ * Returns zero on success, or a negative error code.
54+ */
55+int snd_fw_transaction(struct fw_unit *unit, int tcode,
56+ u64 offset, void *buffer, size_t length)
57+{
58+ struct fw_device *device = fw_parent_device(unit);
59+ int generation, rcode, tries = 0;
60+
61+ for (;;) {
62+ generation = device->generation;
63+ smp_rmb(); /* node_id vs. generation */
64+ rcode = fw_run_transaction(device->card, tcode,
65+ device->node_id, generation,
66+ device->max_speed, offset,
67+ buffer, length);
68+
69+ if (rcode == RCODE_COMPLETE)
70+ return 0;
71+
72+ if (rcode_is_permanent_error(rcode) || ++tries >= 3) {
73+ dev_err(&unit->device, "transaction failed: %s\n",
74+ rcode_string(rcode));
75+ return -EIO;
76+ }
77+
78+ msleep(ERROR_RETRY_DELAY_MS);
79+ }
80+}
81+EXPORT_SYMBOL(snd_fw_transaction);
82+
83+MODULE_DESCRIPTION("FireWire audio helper functions");
84+MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
85+MODULE_LICENSE("GPL v2");
sound/firewire/lib.h+19−0
@@ -0,0 +1,19 @@
1+#ifndef SOUND_FIREWIRE_LIB_H_INCLUDED
2+#define SOUND_FIREWIRE_LIB_H_INCLUDED
3+
4+#include <linux/firewire-constants.h>
5+#include <linux/types.h>
6+
7+struct fw_unit;
8+
9+int snd_fw_transaction(struct fw_unit *unit, int tcode,
10+ u64 offset, void *buffer, size_t length);
11+const char *rcode_string(unsigned int rcode);
12+
13+/* returns true if retrying the transaction would not make sense */
14+static inline bool rcode_is_permanent_error(int rcode)
15+{
16+ return rcode == RCODE_TYPE_ERROR || rcode == RCODE_ADDRESS_ERROR;
17+}
18+
19+#endif
sound/firewire/packets-buffer.c+74−0
@@ -0,0 +1,74 @@
1+/*
2+ * helpers for managing a buffer for many packets
3+ *
4+ * Copyright (c) Clemens Ladisch <clemens@ladisch.de>
5+ * Licensed under the terms of the GNU General Public License, version 2.
6+ */
7+
8+#include <linux/firewire.h>
9+#include <linux/slab.h>
10+#include "packets-buffer.h"
11+
12+/**
13+ * iso_packets_buffer_init - allocates the memory for packets
14+ * @b: the buffer structure to initialize
15+ * @unit: the device at the other end of the stream
16+ * @count: the number of packets
17+ * @packet_size: the (maximum) size of a packet, in bytes
18+ * @direction: %DMA_TO_DEVICE or %DMA_FROM_DEVICE
19+ */
20+int iso_packets_buffer_init(struct iso_packets_buffer *b, struct fw_unit *unit,
21+ unsigned int count, unsigned int packet_size,
22+ enum dma_data_direction direction)
23+{
24+ unsigned int packets_per_page, pages;
25+ unsigned int i, page_index, offset_in_page;
26+ void *p;
27+ int err;
28+
29+ b->packets = kmalloc(count * sizeof(*b->packets), GFP_KERNEL);
30+ if (!b->packets) {
31+ err = -ENOMEM;
32+ goto error;
33+ }
34+
35+ packet_size = L1_CACHE_ALIGN(packet_size);
36+ packets_per_page = PAGE_SIZE / packet_size;
37+ if (WARN_ON(!packets_per_page)) {
38+ err = -EINVAL;
39+ goto error;
40+ }
41+ pages = DIV_ROUND_UP(count, packets_per_page);
42+
43+ err = fw_iso_buffer_init(&b->iso_buffer, fw_parent_device(unit)->card,
44+ pages, direction);
45+ if (err < 0)
46+ goto err_packets;
47+
48+ for (i = 0; i < count; ++i) {
49+ page_index = i / packets_per_page;
50+ p = page_address(b->iso_buffer.pages[page_index]);
51+ offset_in_page = (i % packets_per_page) * packet_size;
52+ b->packets[i].buffer = p + offset_in_page;
53+ b->packets[i].offset = page_index * PAGE_SIZE + offset_in_page;
54+ }
55+
56+ return 0;
57+
58+err_packets:
59+ kfree(b->packets);
60+error:
61+ return err;
62+}
63+
64+/**
65+ * iso_packets_buffer_destroy - frees packet buffer resources
66+ * @b: the buffer structure to free
67+ * @unit: the device at the other end of the stream
68+ */
69+void iso_packets_buffer_destroy(struct iso_packets_buffer *b,
70+ struct fw_unit *unit)
71+{
72+ fw_iso_buffer_destroy(&b->iso_buffer, fw_parent_device(unit)->card);
73+ kfree(b->packets);
74+}
sound/firewire/packets-buffer.h+26−0
@@ -0,0 +1,26 @@
1+#ifndef SOUND_FIREWIRE_PACKETS_BUFFER_H_INCLUDED
2+#define SOUND_FIREWIRE_PACKETS_BUFFER_H_INCLUDED
3+
4+#include <linux/dma-mapping.h>
5+#include <linux/firewire.h>
6+
7+/**
8+ * struct iso_packets_buffer - manages a buffer for many packets
9+ * @iso_buffer: the memory containing the packets
10+ * @packets: an array, with each element pointing to one packet
11+ */
12+struct iso_packets_buffer {
13+ struct fw_iso_buffer iso_buffer;
14+ struct {
15+ void *buffer;
16+ unsigned int offset;
17+ } *packets;
18+};
19+
20+int iso_packets_buffer_init(struct iso_packets_buffer *b, struct fw_unit *unit,
21+ unsigned int count, unsigned int packet_size,
22+ enum dma_data_direction direction);
23+void iso_packets_buffer_destroy(struct iso_packets_buffer *b,
24+ struct fw_unit *unit);
25+
26+#endif
sound/firewire/speakers.c+858−0
@@ -0,0 +1,858 @@
1+/*
2+ * OXFW970-based speakers driver
3+ *
4+ * Copyright (c) Clemens Ladisch <clemens@ladisch.de>
5+ * Licensed under the terms of the GNU General Public License, version 2.
6+ */
7+
8+#include <linux/device.h>
9+#include <linux/firewire.h>
10+#include <linux/firewire-constants.h>
11+#include <linux/module.h>
12+#include <linux/mod_devicetable.h>
13+#include <linux/mutex.h>
14+#include <linux/slab.h>
15+#include <sound/control.h>
16+#include <sound/core.h>
17+#include <sound/initval.h>
18+#include <sound/pcm.h>
19+#include <sound/pcm_params.h>
20+#include "cmp.h"
21+#include "fcp.h"
22+#include "amdtp.h"
23+#include "lib.h"
24+
25+#define OXFORD_FIRMWARE_ID_ADDRESS (CSR_REGISTER_BASE + 0x50000)
26+/* 0x970?vvvv or 0x971?vvvv, where vvvv = firmware version */
27+
28+#define OXFORD_HARDWARE_ID_ADDRESS (CSR_REGISTER_BASE + 0x90020)
29+#define OXFORD_HARDWARE_ID_OXFW970 0x39443841
30+#define OXFORD_HARDWARE_ID_OXFW971 0x39373100
31+
32+#define VENDOR_GRIFFIN 0x001292
33+#define VENDOR_LACIE 0x00d04b
34+
35+#define SPECIFIER_1394TA 0x00a02d
36+#define VERSION_AVC 0x010001
37+
38+struct device_info {
39+ const char *driver_name;
40+ const char *short_name;
41+ const char *long_name;
42+ int (*pcm_constraints)(struct snd_pcm_runtime *runtime);
43+ unsigned int mixer_channels;
44+ u8 mute_fb_id;
45+ u8 volume_fb_id;
46+};
47+
48+struct fwspk {
49+ struct snd_card *card;
50+ struct fw_unit *unit;
51+ const struct device_info *device_info;
52+ struct snd_pcm_substream *pcm;
53+ struct mutex mutex;
54+ struct cmp_connection connection;
55+ struct amdtp_out_stream stream;
56+ bool stream_running;
57+ bool mute;
58+ s16 volume[6];
59+ s16 volume_min;
60+ s16 volume_max;
61+};
62+
63+MODULE_DESCRIPTION("FireWire speakers driver");
64+MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
65+MODULE_LICENSE("GPL v2");
66+
67+static int firewave_rate_constraint(struct snd_pcm_hw_params *params,
68+ struct snd_pcm_hw_rule *rule)
69+{
70+ static unsigned int stereo_rates[] = { 48000, 96000 };
71+ struct snd_interval *channels =
72+ hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
73+ struct snd_interval *rate =
74+ hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
75+
76+ /* two channels work only at 48/96 kHz */
77+ if (snd_interval_max(channels) < 6)
78+ return snd_interval_list(rate, 2, stereo_rates, 0);
79+ return 0;
80+}
81+
82+static int firewave_channels_constraint(struct snd_pcm_hw_params *params,
83+ struct snd_pcm_hw_rule *rule)
84+{
85+ static const struct snd_interval all_channels = { .min = 6, .max = 6 };
86+ struct snd_interval *rate =
87+ hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
88+ struct snd_interval *channels =
89+ hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
90+
91+ /* 32/44.1 kHz work only with all six channels */
92+ if (snd_interval_max(rate) < 48000)
93+ return snd_interval_refine(channels, &all_channels);
94+ return 0;
95+}
96+
97+static int firewave_constraints(struct snd_pcm_runtime *runtime)
98+{
99+ static unsigned int channels_list[] = { 2, 6 };
100+ static struct snd_pcm_hw_constraint_list channels_list_constraint = {
101+ .count = 2,
102+ .list = channels_list,
103+ };
104+ int err;
105+
106+ runtime->hw.rates = SNDRV_PCM_RATE_32000 |
107+ SNDRV_PCM_RATE_44100 |
108+ SNDRV_PCM_RATE_48000 |
109+ SNDRV_PCM_RATE_96000;
110+ runtime->hw.channels_max = 6;
111+
112+ err = snd_pcm_hw_constraint_list(runtime, 0,
113+ SNDRV_PCM_HW_PARAM_CHANNELS,
114+ &channels_list_constraint);
115+ if (err < 0)
116+ return err;
117+ err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
118+ firewave_rate_constraint, NULL,
119+ SNDRV_PCM_HW_PARAM_CHANNELS, -1);
120+ if (err < 0)
121+ return err;
122+ err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
123+ firewave_channels_constraint, NULL,
124+ SNDRV_PCM_HW_PARAM_RATE, -1);
125+ if (err < 0)
126+ return err;
127+
128+ return 0;
129+}
130+
131+static int lacie_speakers_constraints(struct snd_pcm_runtime *runtime)
132+{
133+ runtime->hw.rates = SNDRV_PCM_RATE_32000 |
134+ SNDRV_PCM_RATE_44100 |
135+ SNDRV_PCM_RATE_48000 |
136+ SNDRV_PCM_RATE_88200 |
137+ SNDRV_PCM_RATE_96000;
138+
139+ return 0;
140+}
141+
142+static int fwspk_open(struct snd_pcm_substream *substream)
143+{
144+ static const struct snd_pcm_hardware hardware = {
145+ .info = SNDRV_PCM_INFO_MMAP |
146+ SNDRV_PCM_INFO_MMAP_VALID |
147+ SNDRV_PCM_INFO_BATCH |
148+ SNDRV_PCM_INFO_INTERLEAVED |
149+ SNDRV_PCM_INFO_BLOCK_TRANSFER,
150+ .formats = AMDTP_OUT_PCM_FORMAT_BITS,
151+ .channels_min = 2,
152+ .channels_max = 2,
153+ .buffer_bytes_max = 4 * 1024 * 1024,
154+ .period_bytes_min = 1,
155+ .period_bytes_max = UINT_MAX,
156+ .periods_min = 1,
157+ .periods_max = UINT_MAX,
158+ };
159+ struct fwspk *fwspk = substream->private_data;
160+ struct snd_pcm_runtime *runtime = substream->runtime;
161+ int err;
162+
163+ runtime->hw = hardware;
164+
165+ err = fwspk->device_info->pcm_constraints(runtime);
166+ if (err < 0)
167+ return err;
168+ err = snd_pcm_limit_hw_rates(runtime);
169+ if (err < 0)
170+ return err;
171+
172+ err = snd_pcm_hw_constraint_minmax(runtime,
173+ SNDRV_PCM_HW_PARAM_PERIOD_TIME,
174+ 5000, 8192000);
175+ if (err < 0)
176+ return err;
177+
178+ err = snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24);
179+ if (err < 0)
180+ return err;
181+
182+ return 0;
183+}
184+
185+static int fwspk_close(struct snd_pcm_substream *substream)
186+{
187+ return 0;
188+}
189+
190+static void fwspk_stop_stream(struct fwspk *fwspk)
191+{
192+ if (fwspk->stream_running) {
193+ amdtp_out_stream_stop(&fwspk->stream);
194+ cmp_connection_break(&fwspk->connection);
195+ fwspk->stream_running = false;
196+ }
197+}
198+
199+static int fwspk_set_rate(struct fwspk *fwspk, unsigned int sfc)
200+{
201+ u8 *buf;
202+ int err;
203+
204+ buf = kmalloc(8, GFP_KERNEL);
205+ if (!buf)
206+ return -ENOMEM;
207+
208+ buf[0] = 0x00; /* AV/C, CONTROL */
209+ buf[1] = 0xff; /* unit */
210+ buf[2] = 0x19; /* INPUT PLUG SIGNAL FORMAT */
211+ buf[3] = 0x00; /* plug 0 */
212+ buf[4] = 0x90; /* format: audio */
213+ buf[5] = 0x00 | sfc; /* AM824, frequency */
214+ buf[6] = 0xff; /* SYT (not used) */
215+ buf[7] = 0xff;
216+
217+ err = fcp_avc_transaction(fwspk->unit, buf, 8, buf, 8,
218+ BIT(1) | BIT(2) | BIT(3) | BIT(4) | BIT(5));
219+ if (err < 0)
220+ goto error;
221+ if (err < 6 || buf[0] != 0x09 /* ACCEPTED */) {
222+ dev_err(&fwspk->unit->device, "failed to set sample rate\n");
223+ err = -EIO;
224+ goto error;
225+ }
226+
227+ err = 0;
228+
229+error:
230+ kfree(buf);
231+
232+ return err;
233+}
234+
235+static int fwspk_hw_params(struct snd_pcm_substream *substream,
236+ struct snd_pcm_hw_params *hw_params)
237+{
238+ struct fwspk *fwspk = substream->private_data;
239+ int err;
240+
241+ mutex_lock(&fwspk->mutex);
242+ fwspk_stop_stream(fwspk);
243+ mutex_unlock(&fwspk->mutex);
244+
245+ err = snd_pcm_lib_alloc_vmalloc_buffer(substream,
246+ params_buffer_bytes(hw_params));
247+ if (err < 0)
248+ goto error;
249+
250+ amdtp_out_stream_set_rate(&fwspk->stream, params_rate(hw_params));
251+ amdtp_out_stream_set_pcm(&fwspk->stream, params_channels(hw_params));
252+
253+ amdtp_out_stream_set_pcm_format(&fwspk->stream,
254+ params_format(hw_params));
255+
256+ err = fwspk_set_rate(fwspk, fwspk->stream.sfc);
257+ if (err < 0)
258+ goto err_buffer;
259+
260+ return 0;
261+
262+err_buffer:
263+ snd_pcm_lib_free_vmalloc_buffer(substream);
264+error:
265+ return err;
266+}
267+
268+static int fwspk_hw_free(struct snd_pcm_substream *substream)
269+{
270+ struct fwspk *fwspk = substream->private_data;
271+
272+ mutex_lock(&fwspk->mutex);
273+ fwspk_stop_stream(fwspk);
274+ mutex_unlock(&fwspk->mutex);
275+
276+ return snd_pcm_lib_free_vmalloc_buffer(substream);
277+}
278+
279+static int fwspk_prepare(struct snd_pcm_substream *substream)
280+{
281+ struct fwspk *fwspk = substream->private_data;
282+ int err;
283+
284+ mutex_lock(&fwspk->mutex);
285+
286+ if (amdtp_out_streaming_error(&fwspk->stream))
287+ fwspk_stop_stream(fwspk);
288+
289+ if (!fwspk->stream_running) {
290+ err = cmp_connection_establish(&fwspk->connection,
291+ amdtp_out_stream_get_max_payload(&fwspk->stream));
292+ if (err < 0)
293+ goto err_mutex;
294+
295+ err = amdtp_out_stream_start(&fwspk->stream,
296+ fwspk->connection.resources.channel,
297+ fwspk->connection.speed);
298+ if (err < 0)
299+ goto err_connection;
300+
301+ fwspk->stream_running = true;
302+ }
303+
304+ mutex_unlock(&fwspk->mutex);
305+
306+ amdtp_out_stream_pcm_prepare(&fwspk->stream);
307+
308+ return 0;
309+
310+err_connection:
311+ cmp_connection_break(&fwspk->connection);
312+err_mutex:
313+ mutex_unlock(&fwspk->mutex);
314+
315+ return err;
316+}
317+
318+static int fwspk_trigger(struct snd_pcm_substream *substream, int cmd)
319+{
320+ struct fwspk *fwspk = substream->private_data;
321+ struct snd_pcm_substream *pcm;
322+
323+ switch (cmd) {
324+ case SNDRV_PCM_TRIGGER_START:
325+ pcm = substream;
326+ break;
327+ case SNDRV_PCM_TRIGGER_STOP:
328+ pcm = NULL;
329+ break;
330+ default:
331+ return -EINVAL;
332+ }
333+ amdtp_out_stream_pcm_trigger(&fwspk->stream, pcm);
334+ return 0;
335+}
336+
337+static snd_pcm_uframes_t fwspk_pointer(struct snd_pcm_substream *substream)
338+{
339+ struct fwspk *fwspk = substream->private_data;
340+
341+ return amdtp_out_stream_pcm_pointer(&fwspk->stream);
342+}
343+
344+static int fwspk_create_pcm(struct fwspk *fwspk)
345+{
346+ static struct snd_pcm_ops ops = {
347+ .open = fwspk_open,
348+ .close = fwspk_close,
349+ .ioctl = snd_pcm_lib_ioctl,
350+ .hw_params = fwspk_hw_params,
351+ .hw_free = fwspk_hw_free,
352+ .prepare = fwspk_prepare,
353+ .trigger = fwspk_trigger,
354+ .pointer = fwspk_pointer,
355+ .page = snd_pcm_lib_get_vmalloc_page,
356+ .mmap = snd_pcm_lib_mmap_vmalloc,
357+ };
358+ struct snd_pcm *pcm;
359+ int err;
360+
361+ err = snd_pcm_new(fwspk->card, "OXFW970", 0, 1, 0, &pcm);
362+ if (err < 0)
363+ return err;
364+ pcm->private_data = fwspk;
365+ strcpy(pcm->name, fwspk->device_info->short_name);
366+ fwspk->pcm = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream;
367+ fwspk->pcm->ops = &ops;
368+ return 0;
369+}
370+
371+enum control_action { CTL_READ, CTL_WRITE };
372+enum control_attribute {
373+ CTL_MIN = 0x02,
374+ CTL_MAX = 0x03,
375+ CTL_CURRENT = 0x10,
376+};
377+
378+static int fwspk_mute_command(struct fwspk *fwspk, bool *value,
379+ enum control_action action)
380+{
381+ u8 *buf;
382+ u8 response_ok;
383+ int err;
384+
385+ buf = kmalloc(11, GFP_KERNEL);
386+ if (!buf)
387+ return -ENOMEM;
388+
389+ if (action == CTL_READ) {
390+ buf[0] = 0x01; /* AV/C, STATUS */
391+ response_ok = 0x0c; /* STABLE */
392+ } else {
393+ buf[0] = 0x00; /* AV/C, CONTROL */
394+ response_ok = 0x09; /* ACCEPTED */
395+ }
396+ buf[1] = 0x08; /* audio unit 0 */
397+ buf[2] = 0xb8; /* FUNCTION BLOCK */
398+ buf[3] = 0x81; /* function block type: feature */
399+ buf[4] = fwspk->device_info->mute_fb_id; /* function block ID */
400+ buf[5] = 0x10; /* control attribute: current */
401+ buf[6] = 0x02; /* selector length */
402+ buf[7] = 0x00; /* audio channel number */
403+ buf[8] = 0x01; /* control selector: mute */
404+ buf[9] = 0x01; /* control data length */
405+ if (action == CTL_READ)
406+ buf[10] = 0xff;
407+ else
408+ buf[10] = *value ? 0x70 : 0x60;
409+
410+ err = fcp_avc_transaction(fwspk->unit, buf, 11, buf, 11, 0x3fe);
411+ if (err < 0)
412+ goto error;
413+ if (err < 11) {
414+ dev_err(&fwspk->unit->device, "short FCP response\n");
415+ err = -EIO;
416+ goto error;
417+ }
418+ if (buf[0] != response_ok) {
419+ dev_err(&fwspk->unit->device, "mute command failed\n");
420+ err = -EIO;
421+ goto error;
422+ }
423+ if (action == CTL_READ)
424+ *value = buf[10] == 0x70;
425+
426+ err = 0;
427+
428+error:
429+ kfree(buf);
430+
431+ return err;
432+}
433+
434+static int fwspk_volume_command(struct fwspk *fwspk, s16 *value,
435+ unsigned int channel,
436+ enum control_attribute attribute,
437+ enum control_action action)
438+{
439+ u8 *buf;
440+ u8 response_ok;
441+ int err;
442+
443+ buf = kmalloc(12, GFP_KERNEL);
444+ if (!buf)
445+ return -ENOMEM;
446+
447+ if (action == CTL_READ) {
448+ buf[0] = 0x01; /* AV/C, STATUS */
449+ response_ok = 0x0c; /* STABLE */
450+ } else {
451+ buf[0] = 0x00; /* AV/C, CONTROL */
452+ response_ok = 0x09; /* ACCEPTED */
453+ }
454+ buf[1] = 0x08; /* audio unit 0 */
455+ buf[2] = 0xb8; /* FUNCTION BLOCK */
456+ buf[3] = 0x81; /* function block type: feature */
457+ buf[4] = fwspk->device_info->volume_fb_id; /* function block ID */
458+ buf[5] = attribute; /* control attribute */
459+ buf[6] = 0x02; /* selector length */
460+ buf[7] = channel; /* audio channel number */
461+ buf[8] = 0x02; /* control selector: volume */
462+ buf[9] = 0x02; /* control data length */
463+ if (action == CTL_READ) {
464+ buf[10] = 0xff;
465+ buf[11] = 0xff;
466+ } else {
467+ buf[10] = *value >> 8;
468+ buf[11] = *value;
469+ }
470+
471+ err = fcp_avc_transaction(fwspk->unit, buf, 12, buf, 12, 0x3fe);
472+ if (err < 0)
473+ goto error;
474+ if (err < 12) {
475+ dev_err(&fwspk->unit->device, "short FCP response\n");
476+ err = -EIO;
477+ goto error;
478+ }
479+ if (buf[0] != response_ok) {
480+ dev_err(&fwspk->unit->device, "volume command failed\n");
481+ err = -EIO;
482+ goto error;
483+ }
484+ if (action == CTL_READ)
485+ *value = (buf[10] << 8) | buf[11];
486+
487+ err = 0;
488+
489+error:
490+ kfree(buf);
491+
492+ return err;
493+}
494+
495+static int fwspk_mute_get(struct snd_kcontrol *control,
496+ struct snd_ctl_elem_value *value)
497+{
498+ struct fwspk *fwspk = control->private_data;
499+
500+ value->value.integer.value[0] = !fwspk->mute;
501+
502+ return 0;
503+}
504+
505+static int fwspk_mute_put(struct snd_kcontrol *control,
506+ struct snd_ctl_elem_value *value)
507+{
508+ struct fwspk *fwspk = control->private_data;
509+ bool mute;
510+ int err;
511+
512+ mute = !value->value.integer.value[0];
513+
514+ if (mute == fwspk->mute)
515+ return 0;
516+
517+ err = fwspk_mute_command(fwspk, &mute, CTL_WRITE);
518+ if (err < 0)
519+ return err;
520+ fwspk->mute = mute;
521+
522+ return 1;
523+}
524+
525+static int fwspk_volume_info(struct snd_kcontrol *control,
526+ struct snd_ctl_elem_info *info)
527+{
528+ struct fwspk *fwspk = control->private_data;
529+
530+ info->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
531+ info->count = fwspk->device_info->mixer_channels;
532+ info->value.integer.min = fwspk->volume_min;
533+ info->value.integer.max = fwspk->volume_max;
534+
535+ return 0;
536+}
537+
538+static const u8 channel_map[6] = { 0, 1, 4, 5, 2, 3 };
539+
540+static int fwspk_volume_get(struct snd_kcontrol *control,
541+ struct snd_ctl_elem_value *value)
542+{
543+ struct fwspk *fwspk = control->private_data;
544+ unsigned int i;
545+
546+ for (i = 0; i < fwspk->device_info->mixer_channels; ++i)
547+ value->value.integer.value[channel_map[i]] = fwspk->volume[i];
548+
549+ return 0;
550+}
551+
552+static int fwspk_volume_put(struct snd_kcontrol *control,
553+ struct snd_ctl_elem_value *value)
554+{
555+ struct fwspk *fwspk = control->private_data;
556+ unsigned int i, changed_channels;
557+ bool equal_values = true;
558+ s16 volume;
559+ int err;
560+
561+ for (i = 0; i < fwspk->device_info->mixer_channels; ++i) {
562+ if (value->value.integer.value[i] < fwspk->volume_min ||
563+ value->value.integer.value[i] > fwspk->volume_max)
564+ return -EINVAL;
565+ if (value->value.integer.value[i] !=
566+ value->value.integer.value[0])
567+ equal_values = false;
568+ }
569+
570+ changed_channels = 0;
571+ for (i = 0; i < fwspk->device_info->mixer_channels; ++i)
572+ if (value->value.integer.value[channel_map[i]] !=
573+ fwspk->volume[i])
574+ changed_channels |= 1 << (i + 1);
575+
576+ if (equal_values && changed_channels != 0)
577+ changed_channels = 1 << 0;
578+
579+ for (i = 0; i <= fwspk->device_info->mixer_channels; ++i) {
580+ volume = value->value.integer.value[channel_map[i ? i - 1 : 0]];
581+ if (changed_channels & (1 << i)) {
582+ err = fwspk_volume_command(fwspk, &volume, i,
583+ CTL_CURRENT, CTL_WRITE);
584+ if (err < 0)
585+ return err;
586+ }
587+ if (i > 0)
588+ fwspk->volume[i - 1] = volume;
589+ }
590+
591+ return changed_channels != 0;
592+}
593+
594+static int fwspk_create_mixer(struct fwspk *fwspk)
595+{
596+ static const struct snd_kcontrol_new controls[] = {
597+ {
598+ .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
599+ .name = "PCM Playback Switch",
600+ .info = snd_ctl_boolean_mono_info,
601+ .get = fwspk_mute_get,
602+ .put = fwspk_mute_put,
603+ },
604+ {
605+ .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
606+ .name = "PCM Playback Volume",
607+ .info = fwspk_volume_info,
608+ .get = fwspk_volume_get,
609+ .put = fwspk_volume_put,
610+ },
611+ };
612+ unsigned int i, first_ch;
613+ int err;
614+
615+ err = fwspk_volume_command(fwspk, &fwspk->volume_min,
616+ 0, CTL_MIN, CTL_READ);
617+ if (err < 0)
618+ return err;
619+ err = fwspk_volume_command(fwspk, &fwspk->volume_max,
620+ 0, CTL_MAX, CTL_READ);
621+ if (err < 0)
622+ return err;
623+
624+ err = fwspk_mute_command(fwspk, &fwspk->mute, CTL_READ);
625+ if (err < 0)
626+ return err;
627+
628+ first_ch = fwspk->device_info->mixer_channels == 1 ? 0 : 1;
629+ for (i = 0; i < fwspk->device_info->mixer_channels; ++i) {
630+ err = fwspk_volume_command(fwspk, &fwspk->volume[i],
631+ first_ch + i, CTL_CURRENT, CTL_READ);
632+ if (err < 0)
633+ return err;
634+ }
635+
636+ for (i = 0; i < ARRAY_SIZE(controls); ++i) {
637+ err = snd_ctl_add(fwspk->card,
638+ snd_ctl_new1(&controls[i], fwspk));
639+ if (err < 0)
640+ return err;
641+ }
642+
643+ return 0;
644+}
645+
646+static u32 fwspk_read_firmware_version(struct fw_unit *unit)
647+{
648+ __be32 data;
649+ int err;
650+
651+ err = snd_fw_transaction(unit, TCODE_READ_QUADLET_REQUEST,
652+ OXFORD_FIRMWARE_ID_ADDRESS, &data, 4);
653+ return err >= 0 ? be32_to_cpu(data) : 0;
654+}
655+
656+static void fwspk_card_free(struct snd_card *card)
657+{
658+ struct fwspk *fwspk = card->private_data;
659+ struct fw_device *dev = fw_parent_device(fwspk->unit);
660+
661+ amdtp_out_stream_destroy(&fwspk->stream);
662+ cmp_connection_destroy(&fwspk->connection);
663+ fw_unit_put(fwspk->unit);
664+ fw_device_put(dev);
665+ mutex_destroy(&fwspk->mutex);
666+}
667+
668+static const struct device_info *__devinit fwspk_detect(struct fw_device *dev)
669+{
670+ static const struct device_info griffin_firewave = {
671+ .driver_name = "FireWave",
672+ .short_name = "FireWave",
673+ .long_name = "Griffin FireWave Surround",
674+ .pcm_constraints = firewave_constraints,
675+ .mixer_channels = 6,
676+ .mute_fb_id = 0x01,
677+ .volume_fb_id = 0x02,
678+ };
679+ static const struct device_info lacie_speakers = {
680+ .driver_name = "FWSpeakers",
681+ .short_name = "FireWire Speakers",
682+ .long_name = "LaCie FireWire Speakers",
683+ .pcm_constraints = lacie_speakers_constraints,
684+ .mixer_channels = 1,
685+ .mute_fb_id = 0x01,
686+ .volume_fb_id = 0x01,
687+ };
688+ struct fw_csr_iterator i;
689+ int key, value;
690+
691+ fw_csr_iterator_init(&i, dev->config_rom);
692+ while (fw_csr_iterator_next(&i, &key, &value))
693+ if (key == CSR_VENDOR)
694+ switch (value) {
695+ case VENDOR_GRIFFIN:
696+ return &griffin_firewave;
697+ case VENDOR_LACIE:
698+ return &lacie_speakers;
699+ }
700+
701+ return NULL;
702+}
703+
704+static int __devinit fwspk_probe(struct device *unit_dev)
705+{
706+ struct fw_unit *unit = fw_unit(unit_dev);
707+ struct fw_device *fw_dev = fw_parent_device(unit);
708+ struct snd_card *card;
709+ struct fwspk *fwspk;
710+ u32 firmware;
711+ int err;
712+
713+ err = snd_card_create(-1, NULL, THIS_MODULE, sizeof(*fwspk), &card);
714+ if (err < 0)
715+ return err;
716+ snd_card_set_dev(card, unit_dev);
717+
718+ fwspk = card->private_data;
719+ fwspk->card = card;
720+ mutex_init(&fwspk->mutex);
721+ fw_device_get(fw_dev);
722+ fwspk->unit = fw_unit_get(unit);
723+ fwspk->device_info = fwspk_detect(fw_dev);
724+ if (!fwspk->device_info) {
725+ err = -ENODEV;
726+ goto err_unit;
727+ }
728+
729+ err = cmp_connection_init(&fwspk->connection, unit, 0);
730+ if (err < 0)
731+ goto err_unit;
732+
733+ err = amdtp_out_stream_init(&fwspk->stream, unit, CIP_NONBLOCKING);
734+ if (err < 0)
735+ goto err_connection;
736+
737+ card->private_free = fwspk_card_free;
738+
739+ strcpy(card->driver, fwspk->device_info->driver_name);
740+ strcpy(card->shortname, fwspk->device_info->short_name);
741+ firmware = fwspk_read_firmware_version(unit);
742+ snprintf(card->longname, sizeof(card->longname),
743+ "%s (OXFW%x %04x), GUID %08x%08x at %s, S%d",
744+ fwspk->device_info->long_name,
745+ firmware >> 20, firmware & 0xffff,
746+ fw_dev->config_rom[3], fw_dev->config_rom[4],
747+ dev_name(&unit->device), 100 << fw_dev->max_speed);
748+ strcpy(card->mixername, "OXFW970");
749+
750+ err = fwspk_create_pcm(fwspk);
751+ if (err < 0)
752+ goto error;
753+
754+ err = fwspk_create_mixer(fwspk);
755+ if (err < 0)
756+ goto error;
757+
758+ err = snd_card_register(card);
759+ if (err < 0)
760+ goto error;
761+
762+ dev_set_drvdata(unit_dev, fwspk);
763+
764+ return 0;
765+
766+err_connection:
767+ cmp_connection_destroy(&fwspk->connection);
768+err_unit:
769+ fw_unit_put(fwspk->unit);
770+ fw_device_put(fw_dev);
771+ mutex_destroy(&fwspk->mutex);
772+error:
773+ snd_card_free(card);
774+ return err;
775+}
776+
777+static int __devexit fwspk_remove(struct device *dev)
778+{
779+ struct fwspk *fwspk = dev_get_drvdata(dev);
780+
781+ snd_card_disconnect(fwspk->card);
782+
783+ mutex_lock(&fwspk->mutex);
784+ amdtp_out_stream_pcm_abort(&fwspk->stream);
785+ fwspk_stop_stream(fwspk);
786+ mutex_unlock(&fwspk->mutex);
787+
788+ snd_card_free_when_closed(fwspk->card);
789+
790+ return 0;
791+}
792+
793+static void fwspk_bus_reset(struct fw_unit *unit)
794+{
795+ struct fwspk *fwspk = dev_get_drvdata(&unit->device);
796+
797+ fcp_bus_reset(fwspk->unit);
798+
799+ if (cmp_connection_update(&fwspk->connection) < 0) {
800+ mutex_lock(&fwspk->mutex);
801+ amdtp_out_stream_pcm_abort(&fwspk->stream);
802+ fwspk_stop_stream(fwspk);
803+ mutex_unlock(&fwspk->mutex);
804+ return;
805+ }
806+
807+ amdtp_out_stream_update(&fwspk->stream);
808+}
809+
810+static const struct ieee1394_device_id fwspk_id_table[] = {
811+ {
812+ .match_flags = IEEE1394_MATCH_VENDOR_ID |
813+ IEEE1394_MATCH_MODEL_ID |
814+ IEEE1394_MATCH_SPECIFIER_ID |
815+ IEEE1394_MATCH_VERSION,
816+ .vendor_id = VENDOR_GRIFFIN,
817+ .model_id = 0x00f970,
818+ .specifier_id = SPECIFIER_1394TA,
819+ .version = VERSION_AVC,
820+ },
821+ {
822+ .match_flags = IEEE1394_MATCH_VENDOR_ID |
823+ IEEE1394_MATCH_MODEL_ID |
824+ IEEE1394_MATCH_SPECIFIER_ID |
825+ IEEE1394_MATCH_VERSION,
826+ .vendor_id = VENDOR_LACIE,
827+ .model_id = 0x00f970,
828+ .specifier_id = SPECIFIER_1394TA,
829+ .version = VERSION_AVC,
830+ },
831+ { }
832+};
833+MODULE_DEVICE_TABLE(ieee1394, fwspk_id_table);
834+
835+static struct fw_driver fwspk_driver = {
836+ .driver = {
837+ .owner = THIS_MODULE,
838+ .name = KBUILD_MODNAME,
839+ .bus = &fw_bus_type,
840+ .probe = fwspk_probe,
841+ .remove = __devexit_p(fwspk_remove),
842+ },
843+ .update = fwspk_bus_reset,
844+ .id_table = fwspk_id_table,
845+};
846+
847+static int __init alsa_fwspk_init(void)
848+{
849+ return driver_register(&fwspk_driver.driver);
850+}
851+
852+static void __exit alsa_fwspk_exit(void)
853+{
854+ driver_unregister(&fwspk_driver.driver);
855+}
856+
857+module_init(alsa_fwspk_init);
858+module_exit(alsa_fwspk_exit);
sound/oss/soundcard.c+20−36
@@ -526,31 +526,21 @@ bad: · 525 unmodified lines
526526 }
527527
528528
529−/* These device names follow the official Linux device list,
530− * Documentation/devices.txt. Let us know if there are other
531− * common names we should support for compatibility.
532− * Only those devices not created by the generic code in sound_core.c are
533− * registered here.
534− */
535−static const struct {
536− unsigned short minor;
537− char *name;
538− umode_t mode;
539− int *num;
540−} dev_list[] = { /* list of minor devices */
541−/* seems to be some confusion here -- this device is not in the device list */
542− {SND_DEV_DSP16, "dspW", S_IWUGO | S_IRUSR | S_IRGRP,
543− &num_audiodevs},
544− {SND_DEV_AUDIO, "audio", S_IWUGO | S_IRUSR | S_IRGRP,
545− &num_audiodevs},
546−};
547−
548529 static int dmabuf;
549530 static int dmabug;
550531
551532 module_param(dmabuf, int, 0444);
552533 module_param(dmabug, int, 0444);
553534
535+/* additional minors for compatibility */
536+struct oss_minor_dev {
537+ unsigned short minor;
538+ unsigned int enabled;
539+} dev_list[] = {
540+ { SND_DEV_DSP16 },
541+ { SND_DEV_AUDIO },
542+};
543+
554544 static int __init oss_init(void)
555545 {
556546 int err;
@@ -571,18 +561,12 @@ static int __init oss_init(void) · 14 unmodified lines
571561 sound_dmap_flag = (dmabuf > 0 ? 1 : 0);
572562
573563 for (i = 0; i < ARRAY_SIZE(dev_list); i++) {
574− device_create(sound_class, NULL,
575− MKDEV(SOUND_MAJOR, dev_list[i].minor), NULL,
576− "%s", dev_list[i].name);
577−
578− if (!dev_list[i].num)
579− continue;
580−
581− for (j = 1; j < *dev_list[i].num; j++)
582− device_create(sound_class, NULL,
583− MKDEV(SOUND_MAJOR,
584− dev_list[i].minor + (j*0x10)),
585− NULL, "%s%d", dev_list[i].name, j);
564+ j = 0;
565+ do {
566+ unsigned short minor = dev_list[i].minor + j * 0x10;
567+ if (!register_sound_special(&oss_sound_fops, minor))
568+ dev_list[i].enabled = (1 << j);
569+ } while (++j < num_audiodevs);
586570 }
587571
588572 if (sound_nblocks >= MAX_MEM_BLOCKS - 1)
@@ -596,11 +580,11 @@ static void __exit oss_cleanup(void) · 7 unmodified lines
596580 int i, j;
597581
598582 for (i = 0; i < ARRAY_SIZE(dev_list); i++) {
599− device_destroy(sound_class, MKDEV(SOUND_MAJOR, dev_list[i].minor));
600− if (!dev_list[i].num)
601− continue;
602− for (j = 1; j < *dev_list[i].num; j++)
603− device_destroy(sound_class, MKDEV(SOUND_MAJOR, dev_list[i].minor + (j*0x10)));
583+ j = 0;
584+ do {
585+ if (dev_list[i].enabled & (1 << j))
586+ unregister_sound_special(dev_list[i].minor);
587+ } while (++j < num_audiodevs);
604588 }
605589
606590 unregister_sound_special(1);
sound/pci/Kconfig+9−3
@@ -152,10 +152,16 @@ config SND_AZT3328 · 151 unmodified lines
152152 select SND_MPU401_UART
153153 select SND_PCM
154154 select SND_RAWMIDI
155+ select SND_AC97_CODEC
155156 help
156157 Say Y here to include support for Aztech AZF3328 (PCI168)
157158 soundcards.
158159
160+ Supported features: AC97-"conformant" mixer, MPU401/OPL3, analog I/O
161+ (16bit/8bit, many sample rates [<= 66.2kHz], NO hardware mixing),
162+ Digital Enhanced Game Port, 1.024MHz multimedia sequencer timer,
163+ ext. codec (I2S port), onboard amp (4W/4Ohms/ch), suspend/resume.
164+
159165 To compile this driver as a module, choose M here: the module
160166 will be called snd-azt3328.
161167
@@ -572,13 +578,13 @@ comment "Don't forget to add built-in firmwares for HDSP driver" · 410 unmodified lines
572578 depends on SND_HDSP=y
573579
574580 config SND_HDSPM
575− tristate "RME Hammerfall DSP MADI"
581+ tristate "RME Hammerfall DSP MADI/RayDAT/AIO"
576582 select SND_HWDEP
577583 select SND_RAWMIDI
578584 select SND_PCM
579585 help
580− Say Y here to include support for RME Hammerfall DSP MADI
581− soundcards.
586+ Say Y here to include support for RME Hammerfall DSP MADI,
587+ RayDAT and AIO soundcards.
582588
583589 To compile this driver as a module, choose M here: the module
584590 will be called snd-hdspm.
sound/pci/ac97/ac97_codec.c+56−34
@@ -71,6 +71,12 @@ static const struct ac97_codec_id snd_ac97_codec_id_vendors[] = { · 70 unmodified lines
7171 { 0x414b4d00, 0xffffff00, "Asahi Kasei", NULL, NULL },
7272 { 0x414c4300, 0xffffff00, "Realtek", NULL, NULL },
7373 { 0x414c4700, 0xffffff00, "Realtek", NULL, NULL },
74+/*
75+ * This is an _inofficial_ Aztech Labs entry
76+ * (value might differ from unknown official Aztech ID),
77+ * currently used by the AC97 emulation of the almost-AC97 PCI168 card.
78+ */
79+{ 0x415a5400, 0xffffff00, "Aztech Labs (emulated)", NULL, NULL },
7480 { 0x434d4900, 0xffffff00, "C-Media Electronics", NULL, NULL },
7581 { 0x43525900, 0xffffff00, "Cirrus Logic", NULL, NULL },
7682 { 0x43585400, 0xffffff00, "Conexant", NULL, NULL },
@@ -127,6 +133,7 @@ static const struct ac97_codec_id snd_ac97_codec_ids[] = { · 50 unmodified lines
127133 { 0x414c4781, 0xffffffff, "ALC658D", NULL, NULL }, /* already patched */
128134 { 0x414c4780, 0xfffffff0, "ALC658", patch_alc655, NULL },
129135 { 0x414c4790, 0xfffffff0, "ALC850", patch_alc850, NULL },
136+{ 0x415a5401, 0xffffffff, "AZF3328", patch_aztech_azf3328, NULL },
130137 { 0x434d4941, 0xffffffff, "CMI9738", patch_cm9738, NULL },
131138 { 0x434d4961, 0xffffffff, "CMI9739", patch_cm9739, NULL },
132139 { 0x434d4969, 0xffffffff, "CMI9780", patch_cm9780, NULL },
@@ -590,9 +597,9 @@ static int snd_ac97_put_volsw(struct snd_kcontrol *kcontrol, · 457 unmodified lines
590597 snd_ac97_page_restore(ac97, page_save);
591598 #ifdef CONFIG_SND_AC97_POWER_SAVE
592599 /* check analog mixer power-down */
593− if ((val_mask & 0x8000) &&
600+ if ((val_mask & AC97_PD_EAPD) &&
594601 (kcontrol->private_value & (1<<30))) {
595− if (val & 0x8000)
602+ if (val & AC97_PD_EAPD)
596603 ac97->power_up &= ~(1 << (reg>>1));
597604 else
598605 ac97->power_up |= 1 << (reg>>1);
@@ -1035,20 +1042,20 @@ static int snd_ac97_dev_free(struct snd_device *device) · 436 unmodified lines
10351042
10361043 static int snd_ac97_try_volume_mix(struct snd_ac97 * ac97, int reg)
10371044 {
1038− unsigned short val, mask = 0x8000;
1045+ unsigned short val, mask = AC97_MUTE_MASK_MONO;
10391046
10401047 if (! snd_ac97_valid_reg(ac97, reg))
10411048 return 0;
10421049
10431050 switch (reg) {
10441051 case AC97_MASTER_TONE:
1045− return ac97->caps & 0x04 ? 1 : 0;
1052+ return ac97->caps & AC97_BC_BASS_TREBLE ? 1 : 0;
10461053 case AC97_HEADPHONE:
1047− return ac97->caps & 0x10 ? 1 : 0;
1054+ return ac97->caps & AC97_BC_HEADPHONE ? 1 : 0;
10481055 case AC97_REC_GAIN_MIC:
1049− return ac97->caps & 0x01 ? 1 : 0;
1056+ return ac97->caps & AC97_BC_DEDICATED_MIC ? 1 : 0;
10501057 case AC97_3D_CONTROL:
1051− if (ac97->caps & 0x7c00) {
1058+ if (ac97->caps & AC97_BC_3D_TECH_ID_MASK) {
10521059 val = snd_ac97_read(ac97, reg);
10531060 /* if nonzero - fixed and we can't set it */
10541061 return val == 0;
@@ -1104,7 +1111,10 @@ static void check_volume_resolution(struct snd_ac97 *ac97, int reg, unsigned cha · 49 unmodified lines
11041111 *lo_max = *hi_max = 0;
11051112 for (i = 0 ; i < ARRAY_SIZE(cbit); i++) {
11061113 unsigned short val;
1107− snd_ac97_write(ac97, reg, 0x8080 | cbit[i] | (cbit[i] << 8));
1114+ snd_ac97_write(
1115+ ac97, reg,
1116+ AC97_MUTE_MASK_STEREO | cbit[i] | (cbit[i] << 8)
1117+ );
11081118 /* Do the read twice due to buffers on some ac97 codecs.
11091119 * e.g. The STAC9704 returns exactly what you wrote to the register
11101120 * if you read it immediately. This causes the detect routine to fail.
@@ -1139,14 +1149,14 @@ static void snd_ac97_change_volume_params2(struct snd_ac97 * ac97, int reg, int · 28 unmodified lines
11391149 unsigned short val, val1;
11401150
11411151 *max = 63;
1142− val = 0x8080 | (0x20 << shift);
1152+ val = AC97_MUTE_MASK_STEREO | (0x20 << shift);
11431153 snd_ac97_write(ac97, reg, val);
11441154 val1 = snd_ac97_read(ac97, reg);
11451155 if (val != val1) {
11461156 *max = 31;
11471157 }
11481158 /* reset volume to zero */
1149− snd_ac97_write_cache(ac97, reg, 0x8080);
1159+ snd_ac97_write_cache(ac97, reg, AC97_MUTE_MASK_STEREO);
11501160 }
11511161
11521162 static inline int printable(unsigned int x)
@@ -1183,16 +1193,16 @@ static int snd_ac97_cmute_new_stereo(struct snd_card *card, char *name, int reg, · 30 unmodified lines
11831193 if (! snd_ac97_valid_reg(ac97, reg))
11841194 return 0;
11851195
1186− mute_mask = 0x8000;
1196+ mute_mask = AC97_MUTE_MASK_MONO;
11871197 val = snd_ac97_read(ac97, reg);
11881198 if (check_stereo || (ac97->flags & AC97_STEREO_MUTES)) {
11891199 /* check whether both mute bits work */
1190− val1 = val | 0x8080;
1200+ val1 = val | AC97_MUTE_MASK_STEREO;
11911201 snd_ac97_write(ac97, reg, val1);
11921202 if (val1 == snd_ac97_read(ac97, reg))
1193− mute_mask = 0x8080;
1203+ mute_mask = AC97_MUTE_MASK_STEREO;
11941204 }
1195− if (mute_mask == 0x8080) {
1205+ if (mute_mask == AC97_MUTE_MASK_STEREO) {
11961206 struct snd_kcontrol_new tmp = AC97_DOUBLE(name, reg, 15, 7, 1, 1);
11971207 if (check_amix)
11981208 tmp.private_value |= (1 << 30);
@@ -1268,9 +1278,11 @@ static int snd_ac97_cvol_new(struct snd_card *card, char *name, int reg, unsigne · 69 unmodified lines
12681278 err = snd_ctl_add(card, kctl);
12691279 if (err < 0)
12701280 return err;
1271− snd_ac97_write_cache(ac97, reg,
1272− (snd_ac97_read(ac97, reg) & 0x8080) |
1273− lo_max | (hi_max << 8));
1281+ snd_ac97_write_cache(
1282+ ac97, reg,
1283+ (snd_ac97_read(ac97, reg) & AC97_MUTE_MASK_STEREO)
1284+ | lo_max | (hi_max << 8)
1285+ );
12741286 return 0;
12751287 }
12761288
@@ -1332,7 +1344,7 @@ static int snd_ac97_mixer_build(struct snd_ac97 * ac97) · 55 unmodified lines
13321344 return err;
13331345 }
13341346
1335− ac97->regs[AC97_CENTER_LFE_MASTER] = 0x8080;
1347+ ac97->regs[AC97_CENTER_LFE_MASTER] = AC97_MUTE_MASK_STEREO;
13361348
13371349 /* build center controls */
13381350 if ((snd_ac97_try_volume_mix(ac97, AC97_CENTER_LFE_MASTER))
@@ -1410,8 +1422,12 @@ static int snd_ac97_mixer_build(struct snd_ac97 * ac97) · 71 unmodified lines
14101422 if ((err = snd_ctl_add(card, kctl = snd_ac97_cnew(&snd_ac97_controls_pc_beep[idx], ac97))) < 0)
14111423 return err;
14121424 set_tlv_db_scale(kctl, db_scale_4bit);
1413− snd_ac97_write_cache(ac97, AC97_PC_BEEP,
1414− snd_ac97_read(ac97, AC97_PC_BEEP) | 0x801e);
1425+ snd_ac97_write_cache(
1426+ ac97,
1427+ AC97_PC_BEEP,
1428+ (snd_ac97_read(ac97, AC97_PC_BEEP)
1429+ | AC97_MUTE_MASK_MONO | 0x001e)
1430+ );
14151431 }
14161432
14171433 /* build Phone controls */
@@ -1545,7 +1561,7 @@ static int snd_ac97_mixer_build(struct snd_ac97 * ac97) · 127 unmodified lines
15451561 }
15461562
15471563 /* build Simulated Stereo Enhancement control */
1548− if (ac97->caps & 0x0008) {
1564+ if (ac97->caps & AC97_BC_SIM_STEREO) {
15491565 if ((err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_general[AC97_GENERAL_STEREO_ENHANCEMENT], ac97))) < 0)
15501566 return err;
15511567 }
@@ -1557,7 +1573,7 @@ static int snd_ac97_mixer_build(struct snd_ac97 * ac97) · 5 unmodified lines
15571573 }
15581574
15591575 /* build Loudness control */
1560− if (ac97->caps & 0x0020) {
1576+ if (ac97->caps & AC97_BC_LOUDNESS) {
15611577 if ((err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_general[AC97_GENERAL_LOUDNESS], ac97))) < 0)
15621578 return err;
15631579 }
@@ -2542,8 +2558,8 @@ void snd_ac97_resume(struct snd_ac97 *ac97) · 978 unmodified lines
25422558 schedule_timeout_uninterruptible(1);
25432559 } while (time_after_eq(end_time, jiffies));
25442560 /* FIXME: extra delay */
2545− ac97->bus->ops->write(ac97, AC97_MASTER, 0x8000);
2546− if (snd_ac97_read(ac97, AC97_MASTER) != 0x8000)
2561+ ac97->bus->ops->write(ac97, AC97_MASTER, AC97_MUTE_MASK_MONO);
2562+ if (snd_ac97_read(ac97, AC97_MASTER) != AC97_MUTE_MASK_MONO)
25472563 msleep(250);
25482564 } else {
25492565 end_time = jiffies + msecs_to_jiffies(100);
@@ -2747,12 +2763,12 @@ static int master_mute_sw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem · 197 unmodified lines
27472763 int rshift = (kcontrol->private_value >> 12) & 0x0f;
27482764 unsigned short mask;
27492765 if (shift != rshift)
2750− mask = 0x8080;
2766+ mask = AC97_MUTE_MASK_STEREO;
27512767 else
2752− mask = 0x8000;
2753− snd_ac97_update_bits(ac97, AC97_POWERDOWN, 0x8000,
2768+ mask = AC97_MUTE_MASK_MONO;
2769+ snd_ac97_update_bits(ac97, AC97_POWERDOWN, AC97_PD_EAPD,
27542770 (ac97->regs[AC97_MASTER] & mask) == mask ?
2755− 0x8000 : 0);
2771+ AC97_PD_EAPD : 0);
27562772 }
27572773 return err;
27582774 }
@@ -2765,7 +2781,10 @@ static int tune_mute_led(struct snd_ac97 *ac97) · 6 unmodified lines
27652781 return -ENOENT;
27662782 msw->put = master_mute_sw_put;
27672783 snd_ac97_remove_ctl(ac97, "External Amplifier", NULL);
2768− snd_ac97_update_bits(ac97, AC97_POWERDOWN, 0x8000, 0x8000); /* mute LED on */
2784+ snd_ac97_update_bits(
2785+ ac97, AC97_POWERDOWN,
2786+ AC97_PD_EAPD, AC97_PD_EAPD /* mute LED on */
2787+ );
27692788 ac97->scaps |= AC97_SCAP_EAPD_LED;
27702789 return 0;
27712790 }
@@ -2780,12 +2799,12 @@ static int hp_master_mute_sw_put(struct snd_kcontrol *kcontrol, · 8 unmodified lines
27802799 int rshift = (kcontrol->private_value >> 12) & 0x0f;
27812800 unsigned short mask;
27822801 if (shift != rshift)
2783− mask = 0x8080;
2802+ mask = AC97_MUTE_MASK_STEREO;
27842803 else
2785− mask = 0x8000;
2786− snd_ac97_update_bits(ac97, AC97_POWERDOWN, 0x8000,
2804+ mask = AC97_MUTE_MASK_MONO;
2805+ snd_ac97_update_bits(ac97, AC97_POWERDOWN, AC97_PD_EAPD,
27872806 (ac97->regs[AC97_MASTER] & mask) == mask ?
2788− 0x8000 : 0);
2807+ AC97_PD_EAPD : 0);
27892808 }
27902809 return err;
27912810 }
@@ -2801,7 +2820,10 @@ static int tune_hp_mute_led(struct snd_ac97 *ac97) · 9 unmodified lines
28012820 snd_ac97_remove_ctl(ac97, "External Amplifier", NULL);
28022821 snd_ac97_remove_ctl(ac97, "Headphone Playback", "Switch");
28032822 snd_ac97_remove_ctl(ac97, "Headphone Playback", "Volume");
2804− snd_ac97_update_bits(ac97, AC97_POWERDOWN, 0x8000, 0x8000); /* mute LED on */
2823+ snd_ac97_update_bits(
2824+ ac97, AC97_POWERDOWN,
2825+ AC97_PD_EAPD, AC97_PD_EAPD /* mute LED on */
2826+ );
28052827 return 0;
28062828 }
28072829
sound/pci/ac97/ac97_patch.c+52−0
@@ -26,6 +26,15 @@ · 25 unmodified lines
2626 #include "ac97_local.h"
2727 #include "ac97_patch.h"
2828
29+/*
30+ * Forward declarations
31+ */
32+
33+static struct snd_kcontrol *snd_ac97_find_mixer_ctl(struct snd_ac97 *ac97,
34+ const char *name);
35+static int snd_ac97_add_vmaster(struct snd_ac97 *ac97, char *name,
36+ const unsigned int *tlv, const char **slaves);
37+
2938 /*
3039 * Chip specific initialization
3140 */
@@ -2940,6 +2949,49 @@ static int patch_alc850(struct snd_ac97 *ac97) · 2908 unmodified lines
29402949 return 0;
29412950 }
29422951
2952+static int patch_aztech_azf3328_specific(struct snd_ac97 *ac97)
2953+{
2954+ struct snd_kcontrol *kctl_3d_center =
2955+ snd_ac97_find_mixer_ctl(ac97, "3D Control - Center");
2956+ struct snd_kcontrol *kctl_3d_depth =
2957+ snd_ac97_find_mixer_ctl(ac97, "3D Control - Depth");
2958+
2959+ /*
2960+ * 3D register is different from AC97 standard layout
2961+ * (also do some renaming, to resemble Windows driver naming)
2962+ */
2963+ if (kctl_3d_center) {
2964+ kctl_3d_center->private_value =
2965+ AC97_SINGLE_VALUE(AC97_3D_CONTROL, 1, 0x07, 0);
2966+ snd_ac97_rename_vol_ctl(ac97,
2967+ "3D Control - Center", "3D Control - Width"
2968+ );
2969+ }
2970+ if (kctl_3d_depth)
2971+ kctl_3d_depth->private_value =
2972+ AC97_SINGLE_VALUE(AC97_3D_CONTROL, 8, 0x03, 0);
2973+
2974+ /* Aztech Windows driver calls the
2975+ equivalent control "Modem Playback", thus rename it: */
2976+ snd_ac97_rename_vol_ctl(ac97,
2977+ "Master Mono Playback", "Modem Playback"
2978+ );
2979+ snd_ac97_rename_vol_ctl(ac97,
2980+ "Headphone Playback", "FM Synth Playback"
2981+ );
2982+
2983+ return 0;
2984+}
2985+
2986+static const struct snd_ac97_build_ops patch_aztech_azf3328_ops = {
2987+ .build_specific = patch_aztech_azf3328_specific
2988+};
2989+
2990+static int patch_aztech_azf3328(struct snd_ac97 *ac97)
2991+{
2992+ ac97->build_ops = &patch_aztech_azf3328_ops;
2993+ return 0;
2994+}
29432995
29442996 /*
29452997 * C-Media CM97xx codecs
sound/pci/asihpi/asihpi.c+386−388
@@ -21,6 +21,7 @@ · 20 unmodified lines
2121 * would appreciate it if you grant us the right to use those modifications
2222 * for any purpose including commercial applications.
2323 */
24+
2425 /* >0: print Hw params, timer vars. >1: print stream write/copy sizes */
2526 #define REALLY_VERBOSE_LOGGING 0
2627
@@ -36,16 +37,12 @@ · 9 unmodified lines
3637 #define VPRINTK2(...)
3738 #endif
3839
39−#ifndef ASI_STYLE_NAMES
40−/* not sure how ALSA style name should look */
41−#define ASI_STYLE_NAMES 1
42−#endif
43−
4440 #include "hpi_internal.h"
4541 #include "hpimsginit.h"
4642 #include "hpioctl.h"
4743
4844 #include <linux/pci.h>
45+#include <linux/version.h>
4946 #include <linux/init.h>
5047 #include <linux/jiffies.h>
5148 #include <linux/slab.h>
@@ -85,11 +82,11 @@ MODULE_PARM_DESC(enable_hpi_hwdep, · 33 unmodified lines
8582
8683 /* identify driver */
8784 #ifdef KERNEL_ALSA_BUILD
88−static char *build_info = "built using headers from kernel source";
85+static char *build_info = "Built using headers from kernel source";
8986 module_param(build_info, charp, S_IRUGO);
9087 MODULE_PARM_DESC(build_info, "built using headers from kernel source");
9188 #else
92−static char *build_info = "built within ALSA source";
89+static char *build_info = "Built within ALSA source";
9390 module_param(build_info, charp, S_IRUGO);
9491 MODULE_PARM_DESC(build_info, "built within ALSA source");
9592 #endif
@@ -100,13 +97,14 @@ static const int mixer_dump; · 4 unmodified lines
10097 #define DEFAULT_SAMPLERATE 44100
10198 static int adapter_fs = DEFAULT_SAMPLERATE;
10299
103−static struct hpi_hsubsys *ss; /* handle to HPI audio subsystem */
104−
105100 /* defaults */
106101 #define PERIODS_MIN 2
107−#define PERIOD_BYTES_MIN 2304
102+#define PERIOD_BYTES_MIN 2048
108103 #define BUFFER_BYTES_MAX (512 * 1024)
109104
105+/* convert stream to character */
106+#define SCHR(s) ((s == SNDRV_PCM_STREAM_PLAYBACK) ? 'P' : 'C')
107+
110108 /*#define TIMER_MILLISECONDS 20
111109 #define FORCE_TIMER_JIFFIES ((TIMER_MILLISECONDS * HZ + 999)/1000)
112110 */
@@ -152,11 +150,12 @@ struct snd_card_asihpi_pcm { · 39 unmodified lines
152150 struct timer_list timer;
153151 unsigned int respawn_timer;
154152 unsigned int hpi_buffer_attached;
155− unsigned int pcm_size;
156− unsigned int pcm_count;
153+ unsigned int buffer_bytes;
154+ unsigned int period_bytes;
157155 unsigned int bytes_per_sec;
158− unsigned int pcm_irq_pos; /* IRQ position */
159− unsigned int pcm_buf_pos; /* position in buffer */
156+ unsigned int pcm_buf_host_rw_ofs; /* Host R/W pos */
157+ unsigned int pcm_buf_dma_ofs; /* DMA R/W offset in buffer */
158+ unsigned int pcm_buf_elapsed_dma_ofs; /* DMA R/W offset in buffer */
160159 struct snd_pcm_substream *substream;
161160 u32 h_stream;
162161 struct hpi_format format;
@@ -167,7 +166,6 @@ struct snd_card_asihpi_pcm { · 4 unmodified lines
167166 /* Functions to allow driver to give a buffer to HPI for busmastering */
168167
169168 static u16 hpi_stream_host_buffer_attach(
170− struct hpi_hsubsys *hS,
171169 u32 h_stream, /* handle to outstream. */
172170 u32 size_in_bytes, /* size in bytes of bus mastering buffer */
173171 u32 pci_address
@@ -194,10 +192,7 @@ static u16 hpi_stream_host_buffer_attach( · 20 unmodified lines
194192 return hr.error;
195193 }
196194
197−static u16 hpi_stream_host_buffer_detach(
198− struct hpi_hsubsys *hS,
199− u32 h_stream
200−)
195+static u16 hpi_stream_host_buffer_detach(u32 h_stream)
201196 {
202197 struct hpi_message hm;
203198 struct hpi_response hr;
@@ -218,24 +213,23 @@ static u16 hpi_stream_host_buffer_detach( · 14 unmodified lines
218213 return hr.error;
219214 }
220215
221−static inline u16 hpi_stream_start(struct hpi_hsubsys *hS, u32 h_stream)
216+static inline u16 hpi_stream_start(u32 h_stream)
222217 {
223218 if (hpi_handle_object(h_stream) == HPI_OBJ_OSTREAM)
224− return hpi_outstream_start(hS, h_stream);
219+ return hpi_outstream_start(h_stream);
225220 else
226− return hpi_instream_start(hS, h_stream);
221+ return hpi_instream_start(h_stream);
227222 }
228223
229−static inline u16 hpi_stream_stop(struct hpi_hsubsys *hS, u32 h_stream)
224+static inline u16 hpi_stream_stop(u32 h_stream)
230225 {
231226 if (hpi_handle_object(h_stream) == HPI_OBJ_OSTREAM)
232− return hpi_outstream_stop(hS, h_stream);
227+ return hpi_outstream_stop(h_stream);
233228 else
234− return hpi_instream_stop(hS, h_stream);
229+ return hpi_instream_stop(h_stream);
235230 }
236231
237232 static inline u16 hpi_stream_get_info_ex(
238− struct hpi_hsubsys *hS,
239233 u32 h_stream,
240234 u16 *pw_state,
241235 u32 *pbuffer_size,
@@ -244,42 +238,43 @@ static inline u16 hpi_stream_get_info_ex( · 2 unmodified lines
244238 u32 *pauxiliary_data
245239 )
246240 {
241+ u16 e;
247242 if (hpi_handle_object(h_stream) == HPI_OBJ_OSTREAM)
248− return hpi_outstream_get_info_ex(hS, h_stream, pw_state,
243+ e = hpi_outstream_get_info_ex(h_stream, pw_state,
249244 pbuffer_size, pdata_in_buffer,
250245 psample_count, pauxiliary_data);
251246 else
252− return hpi_instream_get_info_ex(hS, h_stream, pw_state,
247+ e = hpi_instream_get_info_ex(h_stream, pw_state,
253248 pbuffer_size, pdata_in_buffer,
254249 psample_count, pauxiliary_data);
250+ return e;
255251 }
256252
257−static inline u16 hpi_stream_group_add(struct hpi_hsubsys *hS,
253+static inline u16 hpi_stream_group_add(
258254 u32 h_master,
259255 u32 h_stream)
260256 {
261257 if (hpi_handle_object(h_master) == HPI_OBJ_OSTREAM)
262− return hpi_outstream_group_add(hS, h_master, h_stream);
258+ return hpi_outstream_group_add(h_master, h_stream);
263259 else
264− return hpi_instream_group_add(hS, h_master, h_stream);
260+ return hpi_instream_group_add(h_master, h_stream);
265261 }
266262
267−static inline u16 hpi_stream_group_reset(struct hpi_hsubsys *hS,
268− u32 h_stream)
263+static inline u16 hpi_stream_group_reset(u32 h_stream)
269264 {
270265 if (hpi_handle_object(h_stream) == HPI_OBJ_OSTREAM)
271− return hpi_outstream_group_reset(hS, h_stream);
266+ return hpi_outstream_group_reset(h_stream);
272267 else
273− return hpi_instream_group_reset(hS, h_stream);
268+ return hpi_instream_group_reset(h_stream);
274269 }
275270
276−static inline u16 hpi_stream_group_get_map(struct hpi_hsubsys *hS,
271+static inline u16 hpi_stream_group_get_map(
277272 u32 h_stream, u32 *mo, u32 *mi)
278273 {
279274 if (hpi_handle_object(h_stream) == HPI_OBJ_OSTREAM)
280− return hpi_outstream_group_get_map(hS, h_stream, mo, mi);
275+ return hpi_outstream_group_get_map(h_stream, mo, mi);
281276 else
282− return hpi_instream_group_get_map(hS, h_stream, mo, mi);
277+ return hpi_instream_group_get_map(h_stream, mo, mi);
283278 }
284279
285280 static u16 handle_error(u16 err, int line, char *filename)
@@ -299,11 +294,11 @@ static void print_hwparams(struct snd_pcm_hw_params *p) · 13 unmodified lines
299294 {
300295 snd_printd("HWPARAMS \n");
301296 snd_printd("samplerate %d \n", params_rate(p));
302− snd_printd("channels %d \n", params_channels(p));
303− snd_printd("format %d \n", params_format(p));
297+ snd_printd("Channels %d \n", params_channels(p));
298+ snd_printd("Format %d \n", params_format(p));
304299 snd_printd("subformat %d \n", params_subformat(p));
305− snd_printd("buffer bytes %d \n", params_buffer_bytes(p));
306− snd_printd("period bytes %d \n", params_period_bytes(p));
300+ snd_printd("Buffer bytes %d \n", params_buffer_bytes(p));
301+ snd_printd("Period bytes %d \n", params_period_bytes(p));
307302 snd_printd("access %d \n", params_access(p));
308303 snd_printd("period_size %d \n", params_period_size(p));
309304 snd_printd("periods %d \n", params_periods(p));
@@ -335,7 +330,7 @@ static snd_pcm_format_t hpi_to_alsa_formats[] = { · 25 unmodified lines
335330 */
336331 -1
337332 #else
338− /* SNDRV_PCM_FORMAT_S24_3LE */ /* { HPI_FORMAT_PCM24_SIGNED 15 */
333+ /* SNDRV_PCM_FORMAT_S24_3LE */ /* HPI_FORMAT_PCM24_SIGNED 15 */
339334 #endif
340335 };
341336
@@ -378,20 +373,20 @@ static void snd_card_asihpi_pcm_samplerates(struct snd_card_asihpi *asihpi, · 36 unmodified lines
378373 } else {
379374 /* on cards without SRC,
380375 valid rates are determined by sampleclock */
381− err = hpi_mixer_get_control(ss, asihpi->h_mixer,
376+ err = hpi_mixer_get_control(asihpi->h_mixer,
382377 HPI_SOURCENODE_CLOCK_SOURCE, 0, 0, 0,
383378 HPI_CONTROL_SAMPLECLOCK, &h_control);
384379 if (err) {
385380 snd_printk(KERN_ERR
386− "no local sampleclock, err %d\n", err);
381+ "No local sampleclock, err %d\n", err);
387382 }
388383
389384 for (idx = 0; idx < 100; idx++) {
390− if (hpi_sample_clock_query_local_rate(ss,
385+ if (hpi_sample_clock_query_local_rate(
391386 h_control, idx, &sample_rate)) {
392387 if (!idx)
393388 snd_printk(KERN_ERR
394− "local rate query failed\n");
389+ "Local rate query failed\n");
395390
396391 break;
397392 }
@@ -480,10 +475,10 @@ static int snd_card_asihpi_pcm_hw_params(struct snd_pcm_substream *substream, · 82 unmodified lines
480475 format, params_rate(params), 0, 0));
481476
482477 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
483− if (hpi_instream_reset(ss, dpcm->h_stream) != 0)
478+ if (hpi_instream_reset(dpcm->h_stream) != 0)
484479 return -EINVAL;
485480
486− if (hpi_instream_set_format(ss,
481+ if (hpi_instream_set_format(
487482 dpcm->h_stream, &dpcm->format) != 0)
488483 return -EINVAL;
489484 }
@@ -491,10 +486,10 @@ static int snd_card_asihpi_pcm_hw_params(struct snd_pcm_substream *substream, · 1 unmodified line
491486 dpcm->hpi_buffer_attached = 0;
492487 if (card->support_mmap) {
493488
494− err = hpi_stream_host_buffer_attach(ss, dpcm->h_stream,
489+ err = hpi_stream_host_buffer_attach(dpcm->h_stream,
495490 params_buffer_bytes(params), runtime->dma_addr);
496491 if (err == 0) {
497− snd_printd(KERN_INFO
492+ VPRINTK1(KERN_INFO
498493 "stream_host_buffer_attach succeeded %u %lu\n",
499494 params_buffer_bytes(params),
500495 (unsigned long)runtime->dma_addr);
@@ -505,11 +500,11 @@ static int snd_card_asihpi_pcm_hw_params(struct snd_pcm_substream *substream, · 4 unmodified lines
505500 return -ENOMEM;
506501 }
507502
508− err = hpi_stream_get_info_ex(ss, dpcm->h_stream, NULL,
503+ err = hpi_stream_get_info_ex(dpcm->h_stream, NULL,
509504 &dpcm->hpi_buffer_attached,
510505 NULL, NULL, NULL);
511506
512− snd_printd(KERN_INFO "stream_host_buffer_attach status 0x%x\n",
507+ VPRINTK1(KERN_INFO "stream_host_buffer_attach status 0x%x\n",
513508 dpcm->hpi_buffer_attached);
514509 }
515510 bytes_per_sec = params_rate(params) * params_channels(params);
@@ -520,16 +515,32 @@ static int snd_card_asihpi_pcm_hw_params(struct snd_pcm_substream *substream, · 4 unmodified lines
520515 return -EINVAL;
521516
522517 dpcm->bytes_per_sec = bytes_per_sec;
523− dpcm->pcm_size = params_buffer_bytes(params);
524− dpcm->pcm_count = params_period_bytes(params);
525− snd_printd(KERN_INFO "pcm_size=%d, pcm_count=%d, bps=%d\n",
526− dpcm->pcm_size, dpcm->pcm_count, bytes_per_sec);
518+ dpcm->buffer_bytes = params_buffer_bytes(params);
519+ dpcm->period_bytes = params_period_bytes(params);
520+ VPRINTK1(KERN_INFO "buffer_bytes=%d, period_bytes=%d, bps=%d\n",
521+ dpcm->buffer_bytes, dpcm->period_bytes, bytes_per_sec);
527522
528− dpcm->pcm_irq_pos = 0;
529− dpcm->pcm_buf_pos = 0;
530523 return 0;
531524 }
532525
526+static int
527+snd_card_asihpi_hw_free(struct snd_pcm_substream *substream)
528+{
529+ struct snd_pcm_runtime *runtime = substream->runtime;
530+ struct snd_card_asihpi_pcm *dpcm = runtime->private_data;
531+ if (dpcm->hpi_buffer_attached)
532+ hpi_stream_host_buffer_detach(dpcm->h_stream);
533+
534+ snd_pcm_lib_free_pages(substream);
535+ return 0;
536+}
537+
538+static void snd_card_asihpi_runtime_free(struct snd_pcm_runtime *runtime)
539+{
540+ struct snd_card_asihpi_pcm *dpcm = runtime->private_data;
541+ kfree(dpcm);
542+}
543+
533544 static void snd_card_asihpi_pcm_timer_start(struct snd_pcm_substream *
534545 substream)
535546 {
@@ -537,9 +548,9 @@ static void snd_card_asihpi_pcm_timer_start(struct snd_pcm_substream * · 1 unmodified line
537548 struct snd_card_asihpi_pcm *dpcm = runtime->private_data;
538549 int expiry;
539550
540− expiry = (dpcm->pcm_count * HZ / dpcm->bytes_per_sec);
541− /* wait longer the first time, for samples to propagate */
542− expiry = max(expiry, 20);
551+ expiry = HZ / 200;
552+ /*? (dpcm->period_bytes * HZ / dpcm->bytes_per_sec); */
553+ expiry = max(expiry, 1); /* don't let it be zero! */
543554 dpcm->timer.expires = jiffies + expiry;
544555 dpcm->respawn_timer = 1;
545556 add_timer(&dpcm->timer);
@@ -562,37 +573,44 @@ static int snd_card_asihpi_trigger(struct snd_pcm_substream *substream, · 16 unmodified lines
562573 struct snd_pcm_substream *s;
563574 u16 e;
564575
565− snd_printd("trigger %dstream %d\n",
566− substream->stream, substream->number);
576+ VPRINTK1(KERN_INFO "%c%d trigger\n",
577+ SCHR(substream->stream), substream->number);
567578 switch (cmd) {
568579 case SNDRV_PCM_TRIGGER_START:
569580 snd_pcm_group_for_each_entry(s, substream) {
570− struct snd_card_asihpi_pcm *ds;
571− ds = s->runtime->private_data;
581+ struct snd_pcm_runtime *runtime = s->runtime;
582+ struct snd_card_asihpi_pcm *ds = runtime->private_data;
572583
573584 if (snd_pcm_substream_chip(s) != card)
574585 continue;
575586
587+ /* don't link Cap and Play */
588+ if (substream->stream != s->stream)
589+ continue;
590+
576591 if ((s->stream == SNDRV_PCM_STREAM_PLAYBACK) &&
577592 (card->support_mmap)) {
578593 /* How do I know how much valid data is present
579− * in buffer? Just guessing 2 periods, but if
594+ * in buffer? Must be at least one period!
595+ * Guessing 2 periods, but if
580596 * buffer is bigger it may contain even more
581597 * data??
582598 */
583− unsigned int preload = ds->pcm_count * 2;
584− VPRINTK2("preload %d\n", preload);
599+ unsigned int preload = ds->period_bytes * 1;
600+ VPRINTK2(KERN_INFO "%d preload x%x\n", s->number, preload);
585601 hpi_handle_error(hpi_outstream_write_buf(
586− ss, ds->h_stream,
587− &s->runtime->dma_area[0],
602+ ds->h_stream,
603+ &runtime->dma_area[0],
588604 preload,
589605 &ds->format));
606+ ds->pcm_buf_host_rw_ofs = preload;
590607 }
591608
592609 if (card->support_grouping) {
593− VPRINTK1("\t_group %dstream %d\n", s->stream,
610+ VPRINTK1(KERN_INFO "\t%c%d group\n",
611+ SCHR(s->stream),
594612 s->number);
595− e = hpi_stream_group_add(ss,
613+ e = hpi_stream_group_add(
596614 dpcm->h_stream,
597615 ds->h_stream);
598616 if (!e) {
@@ -604,10 +622,12 @@ static int snd_card_asihpi_trigger(struct snd_pcm_substream *substream, · 5 unmodified lines
604622 } else
605623 break;
606624 }
607− snd_printd("start\n");
625+ VPRINTK1(KERN_INFO "start\n");
608626 /* start the master stream */
609627 snd_card_asihpi_pcm_timer_start(substream);
610− hpi_handle_error(hpi_stream_start(ss, dpcm->h_stream));
628+ if ((substream->stream == SNDRV_PCM_STREAM_CAPTURE) ||
629+ !card->support_mmap)
630+ hpi_handle_error(hpi_stream_start(dpcm->h_stream));
611631 break;
612632
613633 case SNDRV_PCM_TRIGGER_STOP:
@@ -615,88 +635,73 @@ static int snd_card_asihpi_trigger(struct snd_pcm_substream *substream, · 1 unmodified line
615635 snd_pcm_group_for_each_entry(s, substream) {
616636 if (snd_pcm_substream_chip(s) != card)
617637 continue;
638+ /* don't link Cap and Play */
639+ if (substream->stream != s->stream)
640+ continue;
618641
619642 /*? workaround linked streams don't
620643 transition to SETUP 20070706*/
621644 s->runtime->status->state = SNDRV_PCM_STATE_SETUP;
622645
623646 if (card->support_grouping) {
624− VPRINTK1("\t_group %dstream %d\n", s->stream,
647+ VPRINTK1(KERN_INFO "\t%c%d group\n",
648+ SCHR(s->stream),
625649 s->number);
626650 snd_pcm_trigger_done(s, substream);
627651 } else
628652 break;
629653 }
630− snd_printd("stop\n");
654+ VPRINTK1(KERN_INFO "stop\n");
631655
632656 /* _prepare and _hwparams reset the stream */
633− hpi_handle_error(hpi_stream_stop(ss, dpcm->h_stream));
657+ hpi_handle_error(hpi_stream_stop(dpcm->h_stream));
634658 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
635659 hpi_handle_error(
636− hpi_outstream_reset(ss, dpcm->h_stream));
660+ hpi_outstream_reset(dpcm->h_stream));
637661
638662 if (card->support_grouping)
639− hpi_handle_error(hpi_stream_group_reset(ss,
640− dpcm->h_stream));
663+ hpi_handle_error(hpi_stream_group_reset(dpcm->h_stream));
641664 break;
642665
643666 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
644− snd_printd("pause release\n");
645− hpi_handle_error(hpi_stream_start(ss, dpcm->h_stream));
667+ VPRINTK1(KERN_INFO "pause release\n");
668+ hpi_handle_error(hpi_stream_start(dpcm->h_stream));
646669 snd_card_asihpi_pcm_timer_start(substream);
647670 break;
648671 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
649− snd_printd("pause\n");
672+ VPRINTK1(KERN_INFO "pause\n");
650673 snd_card_asihpi_pcm_timer_stop(substream);
651− hpi_handle_error(hpi_stream_stop(ss, dpcm->h_stream));
674+ hpi_handle_error(hpi_stream_stop(dpcm->h_stream));
652675 break;
653676 default:
654− snd_printd("\tINVALID\n");
677+ snd_printd(KERN_ERR "\tINVALID\n");
655678 return -EINVAL;
656679 }
657680
658681 return 0;
659682 }
660683
661−static int
662−snd_card_asihpi_hw_free(struct snd_pcm_substream *substream)
663−{
664− struct snd_pcm_runtime *runtime = substream->runtime;
665− struct snd_card_asihpi_pcm *dpcm = runtime->private_data;
666− if (dpcm->hpi_buffer_attached)
667− hpi_stream_host_buffer_detach(ss, dpcm->h_stream);
668−
669− snd_pcm_lib_free_pages(substream);
670− return 0;
671−}
672−
673−static void snd_card_asihpi_runtime_free(struct snd_pcm_runtime *runtime)
674−{
675− struct snd_card_asihpi_pcm *dpcm = runtime->private_data;
676− kfree(dpcm);
677−}
678−
679684 /*algorithm outline
680685 Without linking degenerates to getting single stream pos etc
681686 Without mmap 2nd loop degenerates to snd_pcm_period_elapsed
682687 */
683688 /*
684−buf_pos=get_buf_pos(s);
689+pcm_buf_dma_ofs=get_buf_pos(s);
685690 for_each_linked_stream(s) {
686− buf_pos=get_buf_pos(s);
687− min_buf_pos = modulo_min(min_buf_pos, buf_pos, pcm_size)
688− new_data = min(new_data, calc_new_data(buf_pos,irq_pos)
691+ pcm_buf_dma_ofs=get_buf_pos(s);
692+ min_buf_pos = modulo_min(min_buf_pos, pcm_buf_dma_ofs, buffer_bytes)
693+ new_data = min(new_data, calc_new_data(pcm_buf_dma_ofs,irq_pos)
689694 }
690695 timer.expires = jiffies + predict_next_period_ready(min_buf_pos);
691696 for_each_linked_stream(s) {
692− s->buf_pos = min_buf_pos;
693− if (new_data > pcm_count) {
697+ s->pcm_buf_dma_ofs = min_buf_pos;
698+ if (new_data > period_bytes) {
694699 if (mmap) {
695− irq_pos = (irq_pos + pcm_count) % pcm_size;
700+ irq_pos = (irq_pos + period_bytes) % buffer_bytes;
696701 if (playback) {
697− write(pcm_count);
702+ write(period_bytes);
698703 } else {
699− read(pcm_count);
704+ read(period_bytes);
700705 }
701706 }
702707 snd_pcm_period_elapsed(s);
@@ -724,105 +729,136 @@ static inline unsigned int modulo_min(unsigned int a, unsigned int b, · 21 unmodified lines
724729 static void snd_card_asihpi_timer_function(unsigned long data)
725730 {
726731 struct snd_card_asihpi_pcm *dpcm = (struct snd_card_asihpi_pcm *)data;
727− struct snd_card_asihpi *card = snd_pcm_substream_chip(dpcm->substream);
732+ struct snd_pcm_substream *substream = dpcm->substream;
733+ struct snd_card_asihpi *card = snd_pcm_substream_chip(substream);
728734 struct snd_pcm_runtime *runtime;
729735 struct snd_pcm_substream *s;
730736 unsigned int newdata = 0;
731− unsigned int buf_pos, min_buf_pos = 0;
737+ unsigned int pcm_buf_dma_ofs, min_buf_pos = 0;
732738 unsigned int remdata, xfercount, next_jiffies;
733739 int first = 1;
740+ int loops = 0;
734741 u16 state;
735− u32 buffer_size, data_avail, samples_played, aux;
742+ u32 buffer_size, bytes_avail, samples_played, on_card_bytes;
743+
744+ VPRINTK1(KERN_INFO "%c%d snd_card_asihpi_timer_function\n",
745+ SCHR(substream->stream), substream->number);
736746
737747 /* find minimum newdata and buffer pos in group */
738− snd_pcm_group_for_each_entry(s, dpcm->substream) {
748+ snd_pcm_group_for_each_entry(s, substream) {
739749 struct snd_card_asihpi_pcm *ds = s->runtime->private_data;
740750 runtime = s->runtime;
741751
742752 if (snd_pcm_substream_chip(s) != card)
743753 continue;
744754
745− hpi_handle_error(hpi_stream_get_info_ex(ss,
755+ /* don't link Cap and Play */
756+ if (substream->stream != s->stream)
757+ continue;
758+
759+ hpi_handle_error(hpi_stream_get_info_ex(
746760 ds->h_stream, &state,
747− &buffer_size, &data_avail,
748− &samples_played, &aux));
761+ &buffer_size, &bytes_avail,
762+ &samples_played, &on_card_bytes));
749763
750764 /* number of bytes in on-card buffer */
751− runtime->delay = aux;
752−
753− if (state == HPI_STATE_DRAINED) {
754− snd_printd(KERN_WARNING "outstream %d drained\n",
755− s->number);
756− snd_pcm_stop(s, SNDRV_PCM_STATE_XRUN);
757− return;
758− }
765+ runtime->delay = on_card_bytes;
759766
760767 if (s->stream == SNDRV_PCM_STREAM_PLAYBACK) {
761− buf_pos = frames_to_bytes(runtime, samples_played);
762− } else {
763− buf_pos = data_avail + ds->pcm_irq_pos;
764− }
768+ pcm_buf_dma_ofs = ds->pcm_buf_host_rw_ofs - bytes_avail;
769+ if (state == HPI_STATE_STOPPED) {
770+ if ((bytes_avail == 0) &&
771+ (on_card_bytes < ds->pcm_buf_host_rw_ofs)) {
772+ hpi_handle_error(hpi_stream_start(ds->h_stream));
773+ VPRINTK1(KERN_INFO "P%d start\n", s->number);
774+ }
775+ } else if (state == HPI_STATE_DRAINED) {
776+ VPRINTK1(KERN_WARNING "P%d drained\n",
777+ s->number);
778+ /*snd_pcm_stop(s, SNDRV_PCM_STATE_XRUN);
779+ continue; */
780+ }
781+ } else
782+ pcm_buf_dma_ofs = bytes_avail + ds->pcm_buf_host_rw_ofs;
765783
766784 if (first) {
767785 /* can't statically init min when wrap is involved */
768− min_buf_pos = buf_pos;
769− newdata = (buf_pos - ds->pcm_irq_pos) % ds->pcm_size;
786+ min_buf_pos = pcm_buf_dma_ofs;
787+ newdata = (pcm_buf_dma_ofs - ds->pcm_buf_elapsed_dma_ofs) % ds->buffer_bytes;
770788 first = 0;
771789 } else {
772790 min_buf_pos =
773− modulo_min(min_buf_pos, buf_pos, UINT_MAX+1L);
791+ modulo_min(min_buf_pos, pcm_buf_dma_ofs, UINT_MAX+1L);
774792 newdata = min(
775− (buf_pos - ds->pcm_irq_pos) % ds->pcm_size,
793+ (pcm_buf_dma_ofs - ds->pcm_buf_elapsed_dma_ofs) % ds->buffer_bytes,
776794 newdata);
777795 }
778796
779− VPRINTK1("PB timer hw_ptr x%04lX, appl_ptr x%04lX\n",
797+ VPRINTK1(KERN_INFO "PB timer hw_ptr x%04lX, appl_ptr x%04lX\n",
780798 (unsigned long)frames_to_bytes(runtime,
781799 runtime->status->hw_ptr),
782800 (unsigned long)frames_to_bytes(runtime,
783801 runtime->control->appl_ptr));
784− VPRINTK1("%d S=%d, irq=%04X, pos=x%04X, left=x%04X,"
785− " aux=x%04X space=x%04X\n", s->number,
786− state, ds->pcm_irq_pos, buf_pos, (int)data_avail,
787− (int)aux, buffer_size-data_avail);
802+
803+ VPRINTK1(KERN_INFO "%d %c%d S=%d, rw=%04X, dma=x%04X, left=x%04X,"
804+ " aux=x%04X space=x%04X\n",
805+ loops, SCHR(s->stream), s->number,
806+ state, ds->pcm_buf_host_rw_ofs, pcm_buf_dma_ofs, (int)bytes_avail,
807+ (int)on_card_bytes, buffer_size-bytes_avail);
808+ loops++;
788809 }
810+ pcm_buf_dma_ofs = min_buf_pos;
789811
790− remdata = newdata % dpcm->pcm_count;
791− xfercount = newdata - remdata; /* a multiple of pcm_count */
792− next_jiffies = ((dpcm->pcm_count-remdata) * HZ / dpcm->bytes_per_sec)+1;
793− next_jiffies = max(next_jiffies, 2U * HZ / 1000U);
812+ remdata = newdata % dpcm->period_bytes;
813+ xfercount = newdata - remdata; /* a multiple of period_bytes */
814+ /* come back when on_card_bytes has decreased enough to allow
815+ write to happen, or when data has been consumed to make another
816+ period
817+ */
818+ if (xfercount && (on_card_bytes > dpcm->period_bytes))
819+ next_jiffies = ((on_card_bytes - dpcm->period_bytes) * HZ / dpcm->bytes_per_sec);
820+ else
821+ next_jiffies = ((dpcm->period_bytes - remdata) * HZ / dpcm->bytes_per_sec);
822+
823+ next_jiffies = max(next_jiffies, 1U);
794824 dpcm->timer.expires = jiffies + next_jiffies;
795− VPRINTK1("jif %d buf pos x%04X newdata x%04X xc x%04X\n",
796− next_jiffies, min_buf_pos, newdata, xfercount);
825+ VPRINTK1(KERN_INFO "jif %d buf pos x%04X newdata x%04X xfer x%04X\n",
826+ next_jiffies, pcm_buf_dma_ofs, newdata, xfercount);
797827
798− snd_pcm_group_for_each_entry(s, dpcm->substream) {
828+ snd_pcm_group_for_each_entry(s, substream) {
799829 struct snd_card_asihpi_pcm *ds = s->runtime->private_data;
800− ds->pcm_buf_pos = min_buf_pos;
801830
802− if (xfercount) {
831+ /* don't link Cap and Play */
832+ if (substream->stream != s->stream)
833+ continue;
834+
835+ ds->pcm_buf_dma_ofs = pcm_buf_dma_ofs;
836+
837+ if (xfercount && (on_card_bytes <= ds->period_bytes)) {
803838 if (card->support_mmap) {
804− ds->pcm_irq_pos = ds->pcm_irq_pos + xfercount;
805839 if (s->stream == SNDRV_PCM_STREAM_PLAYBACK) {
806− VPRINTK2("write OS%d x%04x\n",
840+ VPRINTK2(KERN_INFO "P%d write x%04x\n",
807841 s->number,
808− ds->pcm_count);
842+ ds->period_bytes);
809843 hpi_handle_error(
810844 hpi_outstream_write_buf(
811− ss, ds->h_stream,
845+ ds->h_stream,
812846 &s->runtime->
813847 dma_area[0],
814848 xfercount,
815849 &ds->format));
816850 } else {
817− VPRINTK2("read IS%d x%04x\n",
851+ VPRINTK2(KERN_INFO "C%d read x%04x\n",
818852 s->number,
819− dpcm->pcm_count);
853+ xfercount);
820854 hpi_handle_error(
821855 hpi_instream_read_buf(
822− ss, ds->h_stream,
856+ ds->h_stream,
823857 NULL, xfercount));
824858 }
859+ ds->pcm_buf_host_rw_ofs = ds->pcm_buf_host_rw_ofs + xfercount;
825860 } /* else R/W will be handled by read/write callbacks */
861+ ds->pcm_buf_elapsed_dma_ofs = pcm_buf_dma_ofs;
826862 snd_pcm_period_elapsed(s);
827863 }
828864 }
@@ -845,12 +881,12 @@ static int snd_card_asihpi_playback_prepare(struct snd_pcm_substream * · 16 unmodified lines
845881 struct snd_pcm_runtime *runtime = substream->runtime;
846882 struct snd_card_asihpi_pcm *dpcm = runtime->private_data;
847883
848− snd_printd(KERN_INFO "playback prepare %d\n", substream->number);
849−
850− hpi_handle_error(hpi_outstream_reset(ss, dpcm->h_stream));
851− dpcm->pcm_irq_pos = 0;
852− dpcm->pcm_buf_pos = 0;
884+ VPRINTK1(KERN_INFO "playback prepare %d\n", substream->number);
853885
886+ hpi_handle_error(hpi_outstream_reset(dpcm->h_stream));
887+ dpcm->pcm_buf_host_rw_ofs = 0;
888+ dpcm->pcm_buf_dma_ofs = 0;
889+ dpcm->pcm_buf_elapsed_dma_ofs = 0;
854890 return 0;
855891 }
856892
@@ -861,27 +897,8 @@ snd_card_asihpi_playback_pointer(struct snd_pcm_substream *substream) · 4 unmodified lines
861897 struct snd_card_asihpi_pcm *dpcm = runtime->private_data;
862898 snd_pcm_uframes_t ptr;
863899
864− u32 samples_played;
865− u16 err;
866−
867− if (!snd_pcm_stream_linked(substream)) {
868− /* NOTE, can use samples played for playback position here and
869− * in timer fn because it LAGS the actual read pointer, and is a
870− * better representation of actual playout position
871− */
872− err = hpi_outstream_get_info_ex(ss, dpcm->h_stream, NULL,
873− NULL, NULL,
874− &samples_played, NULL);
875− hpi_handle_error(err);
876−
877− dpcm->pcm_buf_pos = frames_to_bytes(runtime, samples_played);
878− }
879− /* else must return most conservative value found in timer func
880− * by looping over all streams
881− */
882−
883− ptr = bytes_to_frames(runtime, dpcm->pcm_buf_pos % dpcm->pcm_size);
884− VPRINTK2("playback_pointer=%04ld\n", (unsigned long)ptr);
900+ ptr = bytes_to_frames(runtime, dpcm->pcm_buf_dma_ofs % dpcm->buffer_bytes);
901+ /* VPRINTK2(KERN_INFO "playback_pointer=x%04lx\n", (unsigned long)ptr); */
885902 return ptr;
886903 }
887904
@@ -898,12 +915,12 @@ static void snd_card_asihpi_playback_format(struct snd_card_asihpi *asihpi, · 10 unmodified lines
898915 /* on cards without SRC, must query at valid rate,
899916 * maybe set by external sync
900917 */
901− err = hpi_mixer_get_control(ss, asihpi->h_mixer,
918+ err = hpi_mixer_get_control(asihpi->h_mixer,
902919 HPI_SOURCENODE_CLOCK_SOURCE, 0, 0, 0,
903920 HPI_CONTROL_SAMPLECLOCK, &h_control);
904921
905922 if (!err)
906− err = hpi_sample_clock_get_sample_rate(ss, h_control,
923+ err = hpi_sample_clock_get_sample_rate(h_control,
907924 &sample_rate);
908925
909926 for (format = HPI_FORMAT_PCM8_UNSIGNED;
@@ -911,7 +928,7 @@ static void snd_card_asihpi_playback_format(struct snd_card_asihpi *asihpi, · 1 unmodified line
911928 err = hpi_format_create(&hpi_format,
912929 2, format, sample_rate, 128000, 0);
913930 if (!err)
914− err = hpi_outstream_query_format(ss, h_stream,
931+ err = hpi_outstream_query_format(h_stream,
915932 &hpi_format);
916933 if (!err && (hpi_to_alsa_formats[format] != -1))
917934 pcmhw->formats |=
@@ -942,7 +959,7 @@ static int snd_card_asihpi_playback_open(struct snd_pcm_substream *substream) · 24 unmodified lines
942959 return -ENOMEM;
943960
944961 err =
945− hpi_outstream_open(ss, card->adapter_index,
962+ hpi_outstream_open(card->adapter_index,
946963 substream->number, &dpcm->h_stream);
947964 hpi_handle_error(err);
948965 if (err)
@@ -998,11 +1015,11 @@ static int snd_card_asihpi_playback_open(struct snd_pcm_substream *substream) · 49 unmodified lines
9981015 snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE,
9991016 card->update_interval_frames);
10001017 snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_SIZE,
1001− card->update_interval_frames * 4, UINT_MAX);
1018+ card->update_interval_frames * 2, UINT_MAX);
10021019
10031020 snd_pcm_set_sync(substream);
10041021
1005− snd_printd(KERN_INFO "playback open\n");
1022+ VPRINTK1(KERN_INFO "playback open\n");
10061023
10071024 return 0;
10081025 }
@@ -1012,8 +1029,8 @@ static int snd_card_asihpi_playback_close(struct snd_pcm_substream *substream) · 3 unmodified lines
10121029 struct snd_pcm_runtime *runtime = substream->runtime;
10131030 struct snd_card_asihpi_pcm *dpcm = runtime->private_data;
10141031
1015− hpi_handle_error(hpi_outstream_close(ss, dpcm->h_stream));
1016− snd_printd(KERN_INFO "playback close\n");
1032+ hpi_handle_error(hpi_outstream_close(dpcm->h_stream));
1033+ VPRINTK1(KERN_INFO "playback close\n");
10171034
10181035 return 0;
10191036 }
@@ -1036,9 +1053,11 @@ static int snd_card_asihpi_playback_copy(struct snd_pcm_substream *substream, · 16 unmodified lines
10361053 VPRINTK2(KERN_DEBUG "playback copy%d %u bytes\n",
10371054 substream->number, len);
10381055
1039− hpi_handle_error(hpi_outstream_write_buf(ss, dpcm->h_stream,
1056+ hpi_handle_error(hpi_outstream_write_buf(dpcm->h_stream,
10401057 runtime->dma_area, len, &dpcm->format));
10411058
1059+ dpcm->pcm_buf_host_rw_ofs = dpcm->pcm_buf_host_rw_ofs + len;
1060+
10421061 return 0;
10431062 }
10441063
@@ -1052,10 +1071,10 @@ static int snd_card_asihpi_playback_silence(struct snd_pcm_substream * · 7 unmodified lines
10521071 struct snd_card_asihpi_pcm *dpcm = runtime->private_data;
10531072
10541073 len = frames_to_bytes(runtime, count);
1055− snd_printd(KERN_INFO "playback silence %u bytes\n", len);
1074+ VPRINTK1(KERN_INFO "playback silence %u bytes\n", len);
10561075
10571076 memset(runtime->dma_area, 0, len);
1058− hpi_handle_error(hpi_outstream_write_buf(ss, dpcm->h_stream,
1077+ hpi_handle_error(hpi_outstream_write_buf(dpcm->h_stream,
10591078 runtime->dma_area, len, &dpcm->format));
10601079 return 0;
10611080 }
@@ -1091,13 +1110,13 @@ snd_card_asihpi_capture_pointer(struct snd_pcm_substream *substream) · 29 unmodified lines
10911110 struct snd_pcm_runtime *runtime = substream->runtime;
10921111 struct snd_card_asihpi_pcm *dpcm = runtime->private_data;
10931112
1094− VPRINTK2("capture pointer %d=%d\n",
1095− substream->number, dpcm->pcm_buf_pos);
1096− /* NOTE Unlike playback can't use actual dwSamplesPlayed
1113+ VPRINTK2(KERN_INFO "capture pointer %d=%d\n",
1114+ substream->number, dpcm->pcm_buf_dma_ofs);
1115+ /* NOTE Unlike playback can't use actual samples_played
10971116 for the capture position, because those samples aren't yet in
10981117 the local buffer available for reading.
10991118 */
1100− return bytes_to_frames(runtime, dpcm->pcm_buf_pos % dpcm->pcm_size);
1119+ return bytes_to_frames(runtime, dpcm->pcm_buf_dma_ofs % dpcm->buffer_bytes);
11011120 }
11021121
11031122 static int snd_card_asihpi_capture_ioctl(struct snd_pcm_substream *substream,
@@ -1111,11 +1130,12 @@ static int snd_card_asihpi_capture_prepare(struct snd_pcm_substream *substream) · 7 unmodified lines
11111130 struct snd_pcm_runtime *runtime = substream->runtime;
11121131 struct snd_card_asihpi_pcm *dpcm = runtime->private_data;
11131132
1114− hpi_handle_error(hpi_instream_reset(ss, dpcm->h_stream));
1115− dpcm->pcm_irq_pos = 0;
1116− dpcm->pcm_buf_pos = 0;
1133+ hpi_handle_error(hpi_instream_reset(dpcm->h_stream));
1134+ dpcm->pcm_buf_host_rw_ofs = 0;
1135+ dpcm->pcm_buf_dma_ofs = 0;
1136+ dpcm->pcm_buf_elapsed_dma_ofs = 0;
11171137
1118− snd_printd("capture prepare %d\n", substream->number);
1138+ VPRINTK1("Capture Prepare %d\n", substream->number);
11191139 return 0;
11201140 }
11211141
@@ -1133,12 +1153,12 @@ static void snd_card_asihpi_capture_format(struct snd_card_asihpi *asihpi, · 11 unmodified lines
11331153
11341154 /* on cards without SRC, must query at valid rate,
11351155 maybe set by external sync */
1136− err = hpi_mixer_get_control(ss, asihpi->h_mixer,
1156+ err = hpi_mixer_get_control(asihpi->h_mixer,
11371157 HPI_SOURCENODE_CLOCK_SOURCE, 0, 0, 0,
11381158 HPI_CONTROL_SAMPLECLOCK, &h_control);
11391159
11401160 if (!err)
1141− err = hpi_sample_clock_get_sample_rate(ss, h_control,
1161+ err = hpi_sample_clock_get_sample_rate(h_control,
11421162 &sample_rate);
11431163
11441164 for (format = HPI_FORMAT_PCM8_UNSIGNED;
@@ -1147,7 +1167,7 @@ static void snd_card_asihpi_capture_format(struct snd_card_asihpi *asihpi, · 2 unmodified lines
11471167 err = hpi_format_create(&hpi_format, 2, format,
11481168 sample_rate, 128000, 0);
11491169 if (!err)
1150− err = hpi_instream_query_format(ss, h_stream,
1170+ err = hpi_instream_query_format(h_stream,
11511171 &hpi_format);
11521172 if (!err)
11531173 pcmhw->formats |=
@@ -1178,11 +1198,11 @@ static int snd_card_asihpi_capture_open(struct snd_pcm_substream *substream) · 24 unmodified lines
11781198 if (dpcm == NULL)
11791199 return -ENOMEM;
11801200
1181− snd_printd("hpi_instream_open adapter %d stream %d\n",
1201+ VPRINTK1("hpi_instream_open adapter %d stream %d\n",
11821202 card->adapter_index, substream->number);
11831203
11841204 err = hpi_handle_error(
1185− hpi_instream_open(ss, card->adapter_index,
1205+ hpi_instream_open(card->adapter_index,
11861206 substream->number, &dpcm->h_stream));
11871207 if (err)
11881208 kfree(dpcm);
@@ -1209,6 +1229,9 @@ static int snd_card_asihpi_capture_open(struct snd_pcm_substream *substream) · 20 unmodified lines
12091229 snd_card_asihpi_capture.info |= SNDRV_PCM_INFO_MMAP |
12101230 SNDRV_PCM_INFO_MMAP_VALID;
12111231
1232+ if (card->support_grouping)
1233+ snd_card_asihpi_capture.info |= SNDRV_PCM_INFO_SYNC_START;
1234+
12121235 runtime->hw = snd_card_asihpi_capture;
12131236
12141237 if (card->support_mmap)
@@ -1231,7 +1254,7 @@ static int snd_card_asihpi_capture_close(struct snd_pcm_substream *substream) · 16 unmodified lines
12311254 {
12321255 struct snd_card_asihpi_pcm *dpcm = substream->runtime->private_data;
12331256
1234− hpi_handle_error(hpi_instream_close(ss, dpcm->h_stream));
1257+ hpi_handle_error(hpi_instream_close(dpcm->h_stream));
12351258 return 0;
12361259 }
12371260
@@ -1241,18 +1264,17 @@ static int snd_card_asihpi_capture_copy(struct snd_pcm_substream *substream, · 3 unmodified lines
12411264 {
12421265 struct snd_pcm_runtime *runtime = substream->runtime;
12431266 struct snd_card_asihpi_pcm *dpcm = runtime->private_data;
1244− u32 data_size;
1267+ u32 len;
12451268
1246− data_size = frames_to_bytes(runtime, count);
1269+ len = frames_to_bytes(runtime, count);
12471270
1248− VPRINTK2("capture copy%d %d bytes\n", substream->number, data_size);
1249− hpi_handle_error(hpi_instream_read_buf(ss, dpcm->h_stream,
1250− runtime->dma_area, data_size));
1271+ VPRINTK2(KERN_INFO "capture copy%d %d bytes\n", substream->number, len);
1272+ hpi_handle_error(hpi_instream_read_buf(dpcm->h_stream,
1273+ runtime->dma_area, len));
12511274
1252− /* Used by capture_pointer */
1253− dpcm->pcm_irq_pos = dpcm->pcm_irq_pos + data_size;
1275+ dpcm->pcm_buf_host_rw_ofs = dpcm->pcm_buf_host_rw_ofs + len;
12541276
1255− if (copy_to_user(dst, runtime->dma_area, data_size))
1277+ if (copy_to_user(dst, runtime->dma_area, len))
12561278 return -EFAULT;
12571279
12581280 return 0;
@@ -1287,7 +1309,7 @@ static int __devinit snd_card_asihpi_pcm_new(struct snd_card_asihpi *asihpi, · 28 unmodified lines
12871309 struct snd_pcm *pcm;
12881310 int err;
12891311
1290− err = snd_pcm_new(asihpi->card, "asihpi PCM", device,
1312+ err = snd_pcm_new(asihpi->card, "Asihpi PCM", device,
12911313 asihpi->num_outstreams, asihpi->num_instreams,
12921314 &pcm);
12931315 if (err < 0)
@@ -1307,7 +1329,7 @@ static int __devinit snd_card_asihpi_pcm_new(struct snd_card_asihpi *asihpi, · 13 unmodified lines
13071329
13081330 pcm->private_data = asihpi;
13091331 pcm->info_flags = 0;
1310− strcpy(pcm->name, "asihpi PCM");
1332+ strcpy(pcm->name, "Asihpi PCM");
13111333
13121334 /*? do we want to emulate MMAP for non-BBM cards?
13131335 Jack doesn't work with ALSAs MMAP emulation - WHY NOT? */
@@ -1330,8 +1352,7 @@ struct hpi_control { · 16 unmodified lines
13301352 char name[44]; /* copied to snd_ctl_elem_id.name[44]; */
13311353 };
13321354
1333−static char *asihpi_tuner_band_names[] =
1334−{
1355+static const char * const asihpi_tuner_band_names[] = {
13351356 "invalid",
13361357 "AM",
13371358 "FM mono",
@@ -1349,70 +1370,36 @@ compile_time_assert( · 11 unmodified lines
13491370 (HPI_TUNER_BAND_LAST+1)),
13501371 assert_tuner_band_names_size);
13511372
1352−#if ASI_STYLE_NAMES
1353−static char *asihpi_src_names[] =
1354−{
1373+static const char * const asihpi_src_names[] = {
13551374 "no source",
1356− "outstream",
1357− "line_in",
1358− "aes_in",
1359− "tuner",
1375+ "PCM",
1376+ "Line",
1377+ "Digital",
1378+ "Tuner",
13601379 "RF",
1361− "clock",
1362− "bitstr",
1363− "mic",
1364− "cobranet",
1365− "analog_in",
1366− "adapter",
1380+ "Clock",
1381+ "Bitstream",
1382+ "Microphone",
1383+ "Cobranet",
1384+ "Analog",
1385+ "Adapter",
13671386 };
1368−#else
1369−static char *asihpi_src_names[] =
1370−{
1371− "no source",
1372− "PCM playback",
1373− "line in",
1374− "digital in",
1375− "tuner",
1376− "RF",
1377− "clock",
1378− "bitstream",
1379− "mic",
1380− "cobranet in",
1381− "analog in",
1382− "adapter",
1383−};
1384−#endif
13851387
13861388 compile_time_assert(
13871389 (ARRAY_SIZE(asihpi_src_names) ==
13881390 (HPI_SOURCENODE_LAST_INDEX-HPI_SOURCENODE_NONE+1)),
13891391 assert_src_names_size);
13901392
1391−#if ASI_STYLE_NAMES
1392−static char *asihpi_dst_names[] =
1393−{
1394− "no destination",
1395− "instream",
1396− "line_out",
1397− "aes_out",
1398− "RF",
1399− "speaker" ,
1400− "cobranet",
1401− "analog_out",
1402−};
1403−#else
1404−static char *asihpi_dst_names[] =
1405−{
1393+static const char * const asihpi_dst_names[] = {
14061394 "no destination",
1407− "PCM capture",
1408− "line out",
1409− "digital out",
1395+ "PCM",
1396+ "Line",
1397+ "Digital",
14101398 "RF",
1411− "speaker",
1412− "cobranet out",
1413− "analog out"
1399+ "Speaker",
1400+ "Cobranet Out",
1401+ "Analog"
14141402 };
1415−#endif
14161403
14171404 compile_time_assert(
14181405 (ARRAY_SIZE(asihpi_dst_names) ==
@@ -1438,30 +1425,45 @@ static void asihpi_ctl_init(struct snd_kcontrol_new *snd_control, · 19 unmodified lines
14381425 struct hpi_control *hpi_ctl,
14391426 char *name)
14401427 {
1428+ char *dir = "";
14411429 memset(snd_control, 0, sizeof(*snd_control));
14421430 snd_control->name = hpi_ctl->name;
14431431 snd_control->private_value = hpi_ctl->h_control;
14441432 snd_control->iface = SNDRV_CTL_ELEM_IFACE_MIXER;
14451433 snd_control->index = 0;
14461434
1435+ if (hpi_ctl->dst_node_type + HPI_DESTNODE_NONE == HPI_DESTNODE_ISTREAM)
1436+ dir = "Capture "; /* On or towards a PCM capture destination*/
1437+ else if ((hpi_ctl->src_node_type + HPI_SOURCENODE_NONE != HPI_SOURCENODE_OSTREAM) &&
1438+ (!hpi_ctl->dst_node_type))
1439+ dir = "Capture "; /* On a source node that is not PCM playback */
1440+ else if (hpi_ctl->src_node_type &&
1441+ (hpi_ctl->src_node_type + HPI_SOURCENODE_NONE != HPI_SOURCENODE_OSTREAM) &&
1442+ (hpi_ctl->dst_node_type))
1443+ dir = "Monitor Playback "; /* Between an input and an output */
1444+ else
1445+ dir = "Playback "; /* PCM Playback source, or output node */
1446+
14471447 if (hpi_ctl->src_node_type && hpi_ctl->dst_node_type)
1448− sprintf(hpi_ctl->name, "%s%d to %s%d %s",
1448+ sprintf(hpi_ctl->name, "%s%d %s%d %s%s",
14491449 asihpi_src_names[hpi_ctl->src_node_type],
14501450 hpi_ctl->src_node_index,
14511451 asihpi_dst_names[hpi_ctl->dst_node_type],
14521452 hpi_ctl->dst_node_index,
1453− name);
1453+ dir, name);
14541454 else if (hpi_ctl->dst_node_type) {
1455− sprintf(hpi_ctl->name, "%s%d %s",
1455+ sprintf(hpi_ctl->name, "%s %d %s%s",
14561456 asihpi_dst_names[hpi_ctl->dst_node_type],
14571457 hpi_ctl->dst_node_index,
1458− name);
1458+ dir, name);
14591459 } else {
1460− sprintf(hpi_ctl->name, "%s%d %s",
1460+ sprintf(hpi_ctl->name, "%s %d %s%s",
14611461 asihpi_src_names[hpi_ctl->src_node_type],
14621462 hpi_ctl->src_node_index,
1463− name);
1463+ dir, name);
14641464 }
1465+ /* printk(KERN_INFO "Adding %s %d to %d ", hpi_ctl->name,
1466+ hpi_ctl->wSrcNodeType, hpi_ctl->wDstNodeType); */
14651467 }
14661468
14671469 /*------------------------------------------------------------
@@ -1478,7 +1480,7 @@ static int snd_asihpi_volume_info(struct snd_kcontrol *kcontrol, · 10 unmodified lines
14781480 short max_gain_mB;
14791481 short step_gain_mB;
14801482
1481− err = hpi_volume_query_range(ss, h_control,
1483+ err = hpi_volume_query_range(h_control,
14821484 &min_gain_mB, &max_gain_mB, &step_gain_mB);
14831485 if (err) {
14841486 max_gain_mB = 0;
@@ -1500,7 +1502,7 @@ static int snd_asihpi_volume_get(struct snd_kcontrol *kcontrol, · 15 unmodified lines
15001502 u32 h_control = kcontrol->private_value;
15011503 short an_gain_mB[HPI_MAX_CHANNELS];
15021504
1503− hpi_handle_error(hpi_volume_get_gain(ss, h_control, an_gain_mB));
1505+ hpi_handle_error(hpi_volume_get_gain(h_control, an_gain_mB));
15041506 ucontrol->value.integer.value[0] = an_gain_mB[0] / VOL_STEP_mB;
15051507 ucontrol->value.integer.value[1] = an_gain_mB[1] / VOL_STEP_mB;
15061508
@@ -1522,7 +1524,7 @@ static int snd_asihpi_volume_put(struct snd_kcontrol *kcontrol, · 15 unmodified lines
15221524 asihpi->mixer_volume[addr][1] != right;
15231525 */
15241526 change = 1;
1525− hpi_handle_error(hpi_volume_set_gain(ss, h_control, an_gain_mB));
1527+ hpi_handle_error(hpi_volume_set_gain(h_control, an_gain_mB));
15261528 return change;
15271529 }
15281530
@@ -1534,7 +1536,7 @@ static int __devinit snd_asihpi_volume_add(struct snd_card_asihpi *asihpi, · 5 unmodified lines
15341536 struct snd_card *card = asihpi->card;
15351537 struct snd_kcontrol_new snd_control;
15361538
1537− asihpi_ctl_init(&snd_control, hpi_ctl, "volume");
1539+ asihpi_ctl_init(&snd_control, hpi_ctl, "Volume");
15381540 snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
15391541 SNDRV_CTL_ELEM_ACCESS_TLV_READ;
15401542 snd_control.info = snd_asihpi_volume_info;
@@ -1558,7 +1560,7 @@ static int snd_asihpi_level_info(struct snd_kcontrol *kcontrol, · 17 unmodified lines
15581560 short step_gain_mB;
15591561
15601562 err =
1561− hpi_level_query_range(ss, h_control, &min_gain_mB,
1563+ hpi_level_query_range(h_control, &min_gain_mB,
15621564 &max_gain_mB, &step_gain_mB);
15631565 if (err) {
15641566 max_gain_mB = 2400;
@@ -1580,7 +1582,7 @@ static int snd_asihpi_level_get(struct snd_kcontrol *kcontrol, · 15 unmodified lines
15801582 u32 h_control = kcontrol->private_value;
15811583 short an_gain_mB[HPI_MAX_CHANNELS];
15821584
1583− hpi_handle_error(hpi_level_get_gain(ss, h_control, an_gain_mB));
1585+ hpi_handle_error(hpi_level_get_gain(h_control, an_gain_mB));
15841586 ucontrol->value.integer.value[0] =
15851587 an_gain_mB[0] / HPI_UNITS_PER_dB;
15861588 ucontrol->value.integer.value[1] =
@@ -1604,7 +1606,7 @@ static int snd_asihpi_level_put(struct snd_kcontrol *kcontrol, · 17 unmodified lines
16041606 asihpi->mixer_level[addr][1] != right;
16051607 */
16061608 change = 1;
1607− hpi_handle_error(hpi_level_set_gain(ss, h_control, an_gain_mB));
1609+ hpi_handle_error(hpi_level_set_gain(h_control, an_gain_mB));
16081610 return change;
16091611 }
16101612
@@ -1617,7 +1619,7 @@ static int __devinit snd_asihpi_level_add(struct snd_card_asihpi *asihpi, · 6 unmodified lines
16171619 struct snd_kcontrol_new snd_control;
16181620
16191621 /* can't use 'volume' cos some nodes have volume as well */
1620− asihpi_ctl_init(&snd_control, hpi_ctl, "level");
1622+ asihpi_ctl_init(&snd_control, hpi_ctl, "Level");
16211623 snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
16221624 SNDRV_CTL_ELEM_ACCESS_TLV_READ;
16231625 snd_control.info = snd_asihpi_level_info;
@@ -1633,12 +1635,8 @@ static int __devinit snd_asihpi_level_add(struct snd_card_asihpi *asihpi, · 9 unmodified lines
16331635 ------------------------------------------------------------*/
16341636
16351637 /* AESEBU format */
1636−static char *asihpi_aesebu_format_names[] =
1637−{
1638− "N/A",
1639− "S/PDIF",
1640− "AES/EBU",
1641−};
1638+static const char * const asihpi_aesebu_format_names[] = {
1639+ "N/A", "S/PDIF", "AES/EBU" };
16421640
16431641 static int snd_asihpi_aesebu_format_info(struct snd_kcontrol *kcontrol,
16441642 struct snd_ctl_elem_info *uinfo)
@@ -1659,12 +1657,12 @@ static int snd_asihpi_aesebu_format_info(struct snd_kcontrol *kcontrol, · 14 unmodified lines
16591657
16601658 static int snd_asihpi_aesebu_format_get(struct snd_kcontrol *kcontrol,
16611659 struct snd_ctl_elem_value *ucontrol,
1662− u16 (*func)(const struct hpi_hsubsys *, u32, u16 *))
1660+ u16 (*func)(u32, u16 *))
16631661 {
16641662 u32 h_control = kcontrol->private_value;
16651663 u16 source, err;
16661664
1667− err = func(ss, h_control, &source);
1665+ err = func(h_control, &source);
16681666
16691667 /* default to N/A */
16701668 ucontrol->value.enumerated.item[0] = 0;
@@ -1681,7 +1679,7 @@ static int snd_asihpi_aesebu_format_get(struct snd_kcontrol *kcontrol, · 10 unmodified lines
16811679
16821680 static int snd_asihpi_aesebu_format_put(struct snd_kcontrol *kcontrol,
16831681 struct snd_ctl_elem_value *ucontrol,
1684− u16 (*func)(const struct hpi_hsubsys *, u32, u16))
1682+ u16 (*func)(u32, u16))
16851683 {
16861684 u32 h_control = kcontrol->private_value;
16871685
@@ -1693,7 +1691,7 @@ static int snd_asihpi_aesebu_format_put(struct snd_kcontrol *kcontrol, · 5 unmodified lines
16931691 if (ucontrol->value.enumerated.item[0] == 2)
16941692 source = HPI_AESEBU_FORMAT_AESEBU;
16951693
1696− if (func(ss, h_control, source) != 0)
1694+ if (func(h_control, source) != 0)
16971695 return -EINVAL;
16981696
16991697 return 1;
@@ -1702,13 +1700,13 @@ static int snd_asihpi_aesebu_format_put(struct snd_kcontrol *kcontrol, · 2 unmodified lines
17021700 static int snd_asihpi_aesebu_rx_format_get(struct snd_kcontrol *kcontrol,
17031701 struct snd_ctl_elem_value *ucontrol) {
17041702 return snd_asihpi_aesebu_format_get(kcontrol, ucontrol,
1705− HPI_AESEBU__receiver_get_format);
1703+ hpi_aesebu_receiver_get_format);
17061704 }
17071705
17081706 static int snd_asihpi_aesebu_rx_format_put(struct snd_kcontrol *kcontrol,
17091707 struct snd_ctl_elem_value *ucontrol) {
17101708 return snd_asihpi_aesebu_format_put(kcontrol, ucontrol,
1711− HPI_AESEBU__receiver_set_format);
1709+ hpi_aesebu_receiver_set_format);
17121710 }
17131711
17141712 static int snd_asihpi_aesebu_rxstatus_info(struct snd_kcontrol *kcontrol,
@@ -1730,8 +1728,8 @@ static int snd_asihpi_aesebu_rxstatus_get(struct snd_kcontrol *kcontrol, · 15 unmodified lines
17301728 u32 h_control = kcontrol->private_value;
17311729 u16 status;
17321730
1733− hpi_handle_error(HPI_AESEBU__receiver_get_error_status(
1734− ss, h_control, &status));
1731+ hpi_handle_error(hpi_aesebu_receiver_get_error_status(
1732+ h_control, &status));
17351733 ucontrol->value.integer.value[0] = status;
17361734 return 0;
17371735 }
@@ -1742,7 +1740,7 @@ static int __devinit snd_asihpi_aesebu_rx_add(struct snd_card_asihpi *asihpi, · 4 unmodified lines
17421740 struct snd_card *card = asihpi->card;
17431741 struct snd_kcontrol_new snd_control;
17441742
1745− asihpi_ctl_init(&snd_control, hpi_ctl, "format");
1743+ asihpi_ctl_init(&snd_control, hpi_ctl, "Format");
17461744 snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE;
17471745 snd_control.info = snd_asihpi_aesebu_format_info;
17481746 snd_control.get = snd_asihpi_aesebu_rx_format_get;
@@ -1752,7 +1750,7 @@ static int __devinit snd_asihpi_aesebu_rx_add(struct snd_card_asihpi *asihpi, · 3 unmodified lines
17521750 if (ctl_add(card, &snd_control, asihpi) < 0)
17531751 return -EINVAL;
17541752
1755− asihpi_ctl_init(&snd_control, hpi_ctl, "status");
1753+ asihpi_ctl_init(&snd_control, hpi_ctl, "Status");
17561754 snd_control.access =
17571755 SNDRV_CTL_ELEM_ACCESS_VOLATILE | SNDRV_CTL_ELEM_ACCESS_READ;
17581756 snd_control.info = snd_asihpi_aesebu_rxstatus_info;
@@ -1764,13 +1762,13 @@ static int __devinit snd_asihpi_aesebu_rx_add(struct snd_card_asihpi *asihpi, · 5 unmodified lines
17641762 static int snd_asihpi_aesebu_tx_format_get(struct snd_kcontrol *kcontrol,
17651763 struct snd_ctl_elem_value *ucontrol) {
17661764 return snd_asihpi_aesebu_format_get(kcontrol, ucontrol,
1767− HPI_AESEBU__transmitter_get_format);
1765+ hpi_aesebu_transmitter_get_format);
17681766 }
17691767
17701768 static int snd_asihpi_aesebu_tx_format_put(struct snd_kcontrol *kcontrol,
17711769 struct snd_ctl_elem_value *ucontrol) {
17721770 return snd_asihpi_aesebu_format_put(kcontrol, ucontrol,
1773− HPI_AESEBU__transmitter_set_format);
1771+ hpi_aesebu_transmitter_set_format);
17741772 }
17751773
17761774
@@ -1780,7 +1778,7 @@ static int __devinit snd_asihpi_aesebu_tx_add(struct snd_card_asihpi *asihpi, · 3 unmodified lines
17801778 struct snd_card *card = asihpi->card;
17811779 struct snd_kcontrol_new snd_control;
17821780
1783− asihpi_ctl_init(&snd_control, hpi_ctl, "format");
1781+ asihpi_ctl_init(&snd_control, hpi_ctl, "Format");
17841782 snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE;
17851783 snd_control.info = snd_asihpi_aesebu_format_info;
17861784 snd_control.get = snd_asihpi_aesebu_tx_format_get;
@@ -1804,7 +1802,7 @@ static int snd_asihpi_tuner_gain_info(struct snd_kcontrol *kcontrol, · 17 unmodified lines
18041802 u16 gain_range[3];
18051803
18061804 for (idx = 0; idx < 3; idx++) {
1807− err = hpi_tuner_query_gain(ss, h_control,
1805+ err = hpi_tuner_query_gain(h_control,
18081806 idx, &gain_range[idx]);
18091807 if (err != 0)
18101808 return err;
@@ -1827,7 +1825,7 @@ static int snd_asihpi_tuner_gain_get(struct snd_kcontrol *kcontrol, · 16 unmodified lines
18271825 u32 h_control = kcontrol->private_value;
18281826 short gain;
18291827
1830− hpi_handle_error(hpi_tuner_get_gain(ss, h_control, &gain));
1828+ hpi_handle_error(hpi_tuner_get_gain(h_control, &gain));
18311829 ucontrol->value.integer.value[0] = gain / HPI_UNITS_PER_dB;
18321830
18331831 return 0;
@@ -1843,7 +1841,7 @@ static int snd_asihpi_tuner_gain_put(struct snd_kcontrol *kcontrol, · 9 unmodified lines
18431841 short gain;
18441842
18451843 gain = (ucontrol->value.integer.value[0]) * HPI_UNITS_PER_dB;
1846− hpi_handle_error(hpi_tuner_set_gain(ss, h_control, gain));
1844+ hpi_handle_error(hpi_tuner_set_gain(h_control, gain));
18471845
18481846 return 1;
18491847 }
@@ -1857,7 +1855,7 @@ static int asihpi_tuner_band_query(struct snd_kcontrol *kcontrol, · 7 unmodified lines
18571855 u32 i;
18581856
18591857 for (i = 0; i < len; i++) {
1860− err = hpi_tuner_query_band(ss,
1858+ err = hpi_tuner_query_band(
18611859 h_control, i, &band_list[i]);
18621860 if (err != 0)
18631861 break;
@@ -1913,7 +1911,7 @@ static int snd_asihpi_tuner_band_get(struct snd_kcontrol *kcontrol, · 49 unmodified lines
19131911 num_bands = asihpi_tuner_band_query(kcontrol, tuner_bands,
19141912 HPI_TUNER_BAND_LAST);
19151913
1916− hpi_handle_error(hpi_tuner_get_band(ss, h_control, &band));
1914+ hpi_handle_error(hpi_tuner_get_band(h_control, &band));
19171915
19181916 ucontrol->value.enumerated.item[0] = -1;
19191917 for (idx = 0; idx < HPI_TUNER_BAND_LAST; idx++)
@@ -1940,7 +1938,7 @@ static int snd_asihpi_tuner_band_put(struct snd_kcontrol *kcontrol, · 20 unmodified lines
19401938 HPI_TUNER_BAND_LAST);
19411939
19421940 band = tuner_bands[ucontrol->value.enumerated.item[0]];
1943− hpi_handle_error(hpi_tuner_set_band(ss, h_control, band));
1941+ hpi_handle_error(hpi_tuner_set_band(h_control, band));
19441942
19451943 return 1;
19461944 }
@@ -1965,7 +1963,7 @@ static int snd_asihpi_tuner_freq_info(struct snd_kcontrol *kcontrol, · 18 unmodified lines
19651963
19661964 for (band_iter = 0; band_iter < num_bands; band_iter++) {
19671965 for (idx = 0; idx < 3; idx++) {
1968− err = hpi_tuner_query_frequency(ss, h_control,
1966+ err = hpi_tuner_query_frequency(h_control,
19691967 idx, tuner_bands[band_iter],
19701968 &temp_freq_range[idx]);
19711969 if (err != 0)
@@ -1998,7 +1996,7 @@ static int snd_asihpi_tuner_freq_get(struct snd_kcontrol *kcontrol, · 26 unmodified lines
19981996 u32 h_control = kcontrol->private_value;
19991997 u32 freq;
20001998
2001− hpi_handle_error(hpi_tuner_get_frequency(ss, h_control, &freq));
1999+ hpi_handle_error(hpi_tuner_get_frequency(h_control, &freq));
20022000 ucontrol->value.integer.value[0] = freq;
20032001
20042002 return 0;
@@ -2011,7 +2009,7 @@ static int snd_asihpi_tuner_freq_put(struct snd_kcontrol *kcontrol, · 6 unmodified lines
20112009 u32 freq;
20122010
20132011 freq = ucontrol->value.integer.value[0];
2014− hpi_handle_error(hpi_tuner_set_frequency(ss, h_control, freq));
2012+ hpi_handle_error(hpi_tuner_set_frequency(h_control, freq));
20152013
20162014 return 1;
20172015 }
@@ -2026,8 +2024,8 @@ static int __devinit snd_asihpi_tuner_add(struct snd_card_asihpi *asihpi, · 8 unmodified lines
20262024 snd_control.private_value = hpi_ctl->h_control;
20272025 snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE;
20282026
2029− if (!hpi_tuner_get_gain(ss, hpi_ctl->h_control, NULL)) {
2030− asihpi_ctl_init(&snd_control, hpi_ctl, "gain");
2027+ if (!hpi_tuner_get_gain(hpi_ctl->h_control, NULL)) {
2028+ asihpi_ctl_init(&snd_control, hpi_ctl, "Gain");
20312029 snd_control.info = snd_asihpi_tuner_gain_info;
20322030 snd_control.get = snd_asihpi_tuner_gain_get;
20332031 snd_control.put = snd_asihpi_tuner_gain_put;
@@ -2036,7 +2034,7 @@ static int __devinit snd_asihpi_tuner_add(struct snd_card_asihpi *asihpi, · 2 unmodified lines
20362034 return -EINVAL;
20372035 }
20382036
2039− asihpi_ctl_init(&snd_control, hpi_ctl, "band");
2037+ asihpi_ctl_init(&snd_control, hpi_ctl, "Band");
20402038 snd_control.info = snd_asihpi_tuner_band_info;
20412039 snd_control.get = snd_asihpi_tuner_band_get;
20422040 snd_control.put = snd_asihpi_tuner_band_put;
@@ -2044,7 +2042,7 @@ static int __devinit snd_asihpi_tuner_add(struct snd_card_asihpi *asihpi, · 1 unmodified line
20442042 if (ctl_add(card, &snd_control, asihpi) < 0)
20452043 return -EINVAL;
20462044
2047− asihpi_ctl_init(&snd_control, hpi_ctl, "freq");
2045+ asihpi_ctl_init(&snd_control, hpi_ctl, "Freq");
20482046 snd_control.info = snd_asihpi_tuner_freq_info;
20492047 snd_control.get = snd_asihpi_tuner_freq_get;
20502048 snd_control.put = snd_asihpi_tuner_freq_put;
@@ -2095,7 +2093,7 @@ static int snd_asihpi_meter_get(struct snd_kcontrol *kcontrol, · 44 unmodified lines
20952093 short an_gain_mB[HPI_MAX_CHANNELS], i;
20962094 u16 err;
20972095
2098− err = hpi_meter_get_peak(ss, h_control, an_gain_mB);
2096+ err = hpi_meter_get_peak(h_control, an_gain_mB);
20992097
21002098 for (i = 0; i < HPI_MAX_CHANNELS; i++) {
21012099 if (err) {
@@ -2120,7 +2118,7 @@ static int __devinit snd_asihpi_meter_add(struct snd_card_asihpi *asihpi, · 18 unmodified lines
21202118 struct snd_card *card = asihpi->card;
21212119 struct snd_kcontrol_new snd_control;
21222120
2123− asihpi_ctl_init(&snd_control, hpi_ctl, "meter");
2121+ asihpi_ctl_init(&snd_control, hpi_ctl, "Meter");
21242122 snd_control.access =
21252123 SNDRV_CTL_ELEM_ACCESS_VOLATILE | SNDRV_CTL_ELEM_ACCESS_READ;
21262124 snd_control.info = snd_asihpi_meter_info;
@@ -2140,7 +2138,7 @@ static int snd_card_asihpi_mux_count_sources(struct snd_kcontrol *snd_control) · 13 unmodified lines
21402138 struct hpi_control hpi_ctl;
21412139 int s, err;
21422140 for (s = 0; s < 32; s++) {
2143− err = hpi_multiplexer_query_source(ss, h_control, s,
2141+ err = hpi_multiplexer_query_source(h_control, s,
21442142 &hpi_ctl.
21452143 src_node_type,
21462144 &hpi_ctl.
@@ -2168,7 +2166,7 @@ static int snd_asihpi_mux_info(struct snd_kcontrol *kcontrol, · 21 unmodified lines
21682166 uinfo->value.enumerated.items - 1;
21692167
21702168 err =
2171− hpi_multiplexer_query_source(ss, h_control,
2169+ hpi_multiplexer_query_source(h_control,
21722170 uinfo->value.enumerated.item,
21732171 &src_node_type, &src_node_index);
21742172
@@ -2186,11 +2184,11 @@ static int snd_asihpi_mux_get(struct snd_kcontrol *kcontrol, · 11 unmodified lines
21862184 u16 src_node_type, src_node_index;
21872185 int s;
21882186
2189− hpi_handle_error(hpi_multiplexer_get_source(ss, h_control,
2187+ hpi_handle_error(hpi_multiplexer_get_source(h_control,
21902188 &source_type, &source_index));
21912189 /* Should cache this search result! */
21922190 for (s = 0; s < 256; s++) {
2193− if (hpi_multiplexer_query_source(ss, h_control, s,
2191+ if (hpi_multiplexer_query_source(h_control, s,
21942192 &src_node_type, &src_node_index))
21952193 break;
21962194
@@ -2201,7 +2199,7 @@ static int snd_asihpi_mux_get(struct snd_kcontrol *kcontrol, · 4 unmodified lines
22012199 }
22022200 }
22032201 snd_printd(KERN_WARNING
2204− "control %x failed to match mux source %hu %hu\n",
2202+ "Control %x failed to match mux source %hu %hu\n",
22052203 h_control, source_type, source_index);
22062204 ucontrol->value.enumerated.item[0] = 0;
22072205 return 0;
@@ -2217,12 +2215,12 @@ static int snd_asihpi_mux_put(struct snd_kcontrol *kcontrol, · 9 unmodified lines
22172215
22182216 change = 1;
22192217
2220− e = hpi_multiplexer_query_source(ss, h_control,
2218+ e = hpi_multiplexer_query_source(h_control,
22212219 ucontrol->value.enumerated.item[0],
22222220 &source_type, &source_index);
22232221 if (!e)
22242222 hpi_handle_error(
2225− hpi_multiplexer_set_source(ss, h_control,
2223+ hpi_multiplexer_set_source(h_control,
22262224 source_type, source_index));
22272225 return change;
22282226 }
@@ -2234,11 +2232,7 @@ static int __devinit snd_asihpi_mux_add(struct snd_card_asihpi *asihpi, · 5 unmodified lines
22342232 struct snd_card *card = asihpi->card;
22352233 struct snd_kcontrol_new snd_control;
22362234
2237−#if ASI_STYLE_NAMES
2238− asihpi_ctl_init(&snd_control, hpi_ctl, "multiplexer");
2239−#else
2240− asihpi_ctl_init(&snd_control, hpi_ctl, "route");
2241−#endif
2235+ asihpi_ctl_init(&snd_control, hpi_ctl, "Route");
22422236 snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE;
22432237 snd_control.info = snd_asihpi_mux_info;
22442238 snd_control.get = snd_asihpi_mux_get;
@@ -2254,33 +2248,38 @@ static int __devinit snd_asihpi_mux_add(struct snd_card_asihpi *asihpi, · 9 unmodified lines
22542248 static int snd_asihpi_cmode_info(struct snd_kcontrol *kcontrol,
22552249 struct snd_ctl_elem_info *uinfo)
22562250 {
2257− static char *mode_names[HPI_CHANNEL_MODE_LAST] = {
2258− "normal", "swap",
2259− "from_left", "from_right",
2260− "to_left", "to_right"
2251+ static const char * const mode_names[HPI_CHANNEL_MODE_LAST + 1] = {
2252+ "invalid",
2253+ "Normal", "Swap",
2254+ "From Left", "From Right",
2255+ "To Left", "To Right"
22612256 };
22622257
22632258 u32 h_control = kcontrol->private_value;
22642259 u16 mode;
22652260 int i;
2261+ u16 mode_map[6];
2262+ int valid_modes = 0;
22662263
22672264 /* HPI channel mode values can be from 1 to 6
22682265 Some adapters only support a contiguous subset
22692266 */
22702267 for (i = 0; i < HPI_CHANNEL_MODE_LAST; i++)
2271− if (hpi_channel_mode_query_mode(
2272− ss, h_control, i, &mode))
2273− break;
2268+ if (!hpi_channel_mode_query_mode(
2269+ h_control, i, &mode)) {
2270+ mode_map[valid_modes] = mode;
2271+ valid_modes++;
2272+ }
22742273
22752274 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
22762275 uinfo->count = 1;
2277− uinfo->value.enumerated.items = i;
2276+ uinfo->value.enumerated.items = valid_modes;
22782277
2279− if (uinfo->value.enumerated.item >= i)
2280− uinfo->value.enumerated.item = i - 1;
2278+ if (uinfo->value.enumerated.item >= valid_modes)
2279+ uinfo->value.enumerated.item = valid_modes - 1;
22812280
22822281 strcpy(uinfo->value.enumerated.name,
2283− mode_names[uinfo->value.enumerated.item]);
2282+ mode_names[mode_map[uinfo->value.enumerated.item]]);
22842283
22852284 return 0;
22862285 }
@@ -2291,7 +2290,7 @@ static int snd_asihpi_cmode_get(struct snd_kcontrol *kcontrol, · 4 unmodified lines
22912290 u32 h_control = kcontrol->private_value;
22922291 u16 mode;
22932292
2294− if (hpi_channel_mode_get(ss, h_control, &mode))
2293+ if (hpi_channel_mode_get(h_control, &mode))
22952294 mode = 1;
22962295
22972296 ucontrol->value.enumerated.item[0] = mode - 1;
@@ -2307,7 +2306,7 @@ static int snd_asihpi_cmode_put(struct snd_kcontrol *kcontrol, · 9 unmodified lines
23072306
23082307 change = 1;
23092308
2310− hpi_handle_error(hpi_channel_mode_set(ss, h_control,
2309+ hpi_handle_error(hpi_channel_mode_set(h_control,
23112310 ucontrol->value.enumerated.item[0] + 1));
23122311 return change;
23132312 }
@@ -2319,7 +2318,7 @@ static int __devinit snd_asihpi_cmode_add(struct snd_card_asihpi *asihpi, · 5 unmodified lines
23192318 struct snd_card *card = asihpi->card;
23202319 struct snd_kcontrol_new snd_control;
23212320
2322− asihpi_ctl_init(&snd_control, hpi_ctl, "channel mode");
2321+ asihpi_ctl_init(&snd_control, hpi_ctl, "Mode");
23232322 snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE;
23242323 snd_control.info = snd_asihpi_cmode_info;
23252324 snd_control.get = snd_asihpi_cmode_get;
@@ -2331,15 +2330,12 @@ static int __devinit snd_asihpi_cmode_add(struct snd_card_asihpi *asihpi, · 5 unmodified lines
23312330 /*------------------------------------------------------------
23322331 Sampleclock source controls
23332332 ------------------------------------------------------------*/
2334−
2335−static char *sampleclock_sources[MAX_CLOCKSOURCES] =
2336− { "N/A", "local PLL", "AES/EBU sync", "word external", "word header",
2337− "SMPTE", "AES/EBU in1", "auto", "network", "invalid",
2338− "prev module",
2339− "AES/EBU in2", "AES/EBU in3", "AES/EBU in4", "AES/EBU in5",
2340− "AES/EBU in6", "AES/EBU in7", "AES/EBU in8"};
2341−
2342−
2333+static char *sampleclock_sources[MAX_CLOCKSOURCES] = {
2334+ "N/A", "Local PLL", "Digital Sync", "Word External", "Word Header",
2335+ "SMPTE", "Digital1", "Auto", "Network", "Invalid",
2336+ "Prev Module",
2337+ "Digital2", "Digital3", "Digital4", "Digital5",
2338+ "Digital6", "Digital7", "Digital8"};
23432339
23442340 static int snd_asihpi_clksrc_info(struct snd_kcontrol *kcontrol,
23452341 struct snd_ctl_elem_info *uinfo)
@@ -2371,11 +2367,11 @@ static int snd_asihpi_clksrc_get(struct snd_kcontrol *kcontrol, · 25 unmodified lines
23712367 int i;
23722368
23732369 ucontrol->value.enumerated.item[0] = 0;
2374− if (hpi_sample_clock_get_source(ss, h_control, &source))
2370+ if (hpi_sample_clock_get_source(h_control, &source))
23752371 source = 0;
23762372
23772373 if (source == HPI_SAMPLECLOCK_SOURCE_AESEBU_INPUT)
2378− if (hpi_sample_clock_get_source_index(ss, h_control, &srcindex))
2374+ if (hpi_sample_clock_get_source_index(h_control, &srcindex))
23792375 srcindex = 0;
23802376
23812377 for (i = 0; i < clkcache->count; i++)
@@ -2402,11 +2398,11 @@ static int snd_asihpi_clksrc_put(struct snd_kcontrol *kcontrol, · 20 unmodified lines
24022398 if (item >= clkcache->count)
24032399 item = clkcache->count-1;
24042400
2405− hpi_handle_error(hpi_sample_clock_set_source(ss,
2401+ hpi_handle_error(hpi_sample_clock_set_source(
24062402 h_control, clkcache->s[item].source));
24072403
24082404 if (clkcache->s[item].source == HPI_SAMPLECLOCK_SOURCE_AESEBU_INPUT)
2409− hpi_handle_error(hpi_sample_clock_set_source_index(ss,
2405+ hpi_handle_error(hpi_sample_clock_set_source_index(
24102406 h_control, clkcache->s[item].index));
24112407 return change;
24122408 }
@@ -2434,7 +2430,7 @@ static int snd_asihpi_clklocal_get(struct snd_kcontrol *kcontrol, · 21 unmodified lines
24342430 u32 rate;
24352431 u16 e;
24362432
2437− e = hpi_sample_clock_get_local_rate(ss, h_control, &rate);
2433+ e = hpi_sample_clock_get_local_rate(h_control, &rate);
24382434 if (!e)
24392435 ucontrol->value.integer.value[0] = rate;
24402436 else
@@ -2452,7 +2448,7 @@ static int snd_asihpi_clklocal_put(struct snd_kcontrol *kcontrol, · 11 unmodified lines
24522448 asihpi->mixer_clkrate[addr][1] != right;
24532449 */
24542450 change = 1;
2455− hpi_handle_error(hpi_sample_clock_set_local_rate(ss, h_control,
2451+ hpi_handle_error(hpi_sample_clock_set_local_rate(h_control,
24562452 ucontrol->value.integer.value[0]));
24572453 return change;
24582454 }
@@ -2476,7 +2472,7 @@ static int snd_asihpi_clkrate_get(struct snd_kcontrol *kcontrol, · 17 unmodified lines
24762472 u32 rate;
24772473 u16 e;
24782474
2479− e = hpi_sample_clock_get_sample_rate(ss, h_control, &rate);
2475+ e = hpi_sample_clock_get_sample_rate(h_control, &rate);
24802476 if (!e)
24812477 ucontrol->value.integer.value[0] = rate;
24822478 else
@@ -2501,7 +2497,7 @@ static int __devinit snd_asihpi_sampleclock_add(struct snd_card_asihpi *asihpi, · 18 unmodified lines
25012497 clkcache->has_local = 0;
25022498
25032499 for (i = 0; i <= HPI_SAMPLECLOCK_SOURCE_LAST; i++) {
2504− if (hpi_sample_clock_query_source(ss, hSC,
2500+ if (hpi_sample_clock_query_source(hSC,
25052501 i, &source))
25062502 break;
25072503 clkcache->s[i].source = source;
@@ -2515,7 +2511,7 @@ static int __devinit snd_asihpi_sampleclock_add(struct snd_card_asihpi *asihpi, · 7 unmodified lines
25152511 if (has_aes_in)
25162512 /* already will have picked up index 0 above */
25172513 for (j = 1; j < 8; j++) {
2518− if (hpi_sample_clock_query_source_index(ss, hSC,
2514+ if (hpi_sample_clock_query_source_index(hSC,
25192515 j, HPI_SAMPLECLOCK_SOURCE_AESEBU_INPUT,
25202516 &source))
25212517 break;
@@ -2528,7 +2524,7 @@ static int __devinit snd_asihpi_sampleclock_add(struct snd_card_asihpi *asihpi, · 6 unmodified lines
25282524 }
25292525 clkcache->count = i;
25302526
2531− asihpi_ctl_init(&snd_control, hpi_ctl, "source");
2527+ asihpi_ctl_init(&snd_control, hpi_ctl, "Source");
25322528 snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE ;
25332529 snd_control.info = snd_asihpi_clksrc_info;
25342530 snd_control.get = snd_asihpi_clksrc_get;
@@ -2538,7 +2534,7 @@ static int __devinit snd_asihpi_sampleclock_add(struct snd_card_asihpi *asihpi, · 3 unmodified lines
25382534
25392535
25402536 if (clkcache->has_local) {
2541− asihpi_ctl_init(&snd_control, hpi_ctl, "local_rate");
2537+ asihpi_ctl_init(&snd_control, hpi_ctl, "Localrate");
25422538 snd_control.access = SNDRV_CTL_ELEM_ACCESS_READWRITE ;
25432539 snd_control.info = snd_asihpi_clklocal_info;
25442540 snd_control.get = snd_asihpi_clklocal_get;
@@ -2549,7 +2545,7 @@ static int __devinit snd_asihpi_sampleclock_add(struct snd_card_asihpi *asihpi, · 4 unmodified lines
25492545 return -EINVAL;
25502546 }
25512547
2552− asihpi_ctl_init(&snd_control, hpi_ctl, "rate");
2548+ asihpi_ctl_init(&snd_control, hpi_ctl, "Rate");
25532549 snd_control.access =
25542550 SNDRV_CTL_ELEM_ACCESS_VOLATILE | SNDRV_CTL_ELEM_ACCESS_READ;
25552551 snd_control.info = snd_asihpi_clkrate_info;
@@ -2571,10 +2567,10 @@ static int __devinit snd_card_asihpi_mixer_new(struct snd_card_asihpi *asihpi) · 15 unmodified lines
25712567
25722568 if (snd_BUG_ON(!asihpi))
25732569 return -EINVAL;
2574− strcpy(card->mixername, "asihpi mixer");
2570+ strcpy(card->mixername, "Asihpi Mixer");
25752571
25762572 err =
2577− hpi_mixer_open(ss, asihpi->adapter_index,
2573+ hpi_mixer_open(asihpi->adapter_index,
25782574 &asihpi->h_mixer);
25792575 hpi_handle_error(err);
25802576 if (err)
@@ -2585,7 +2581,7 @@ static int __devinit snd_card_asihpi_mixer_new(struct snd_card_asihpi *asihpi) · 4 unmodified lines
25852581
25862582 for (idx = 0; idx < 2000; idx++) {
25872583 err = hpi_mixer_get_control_by_index(
2588− ss, asihpi->h_mixer,
2584+ asihpi->h_mixer,
25892585 idx,
25902586 &hpi_ctl.src_node_type,
25912587 &hpi_ctl.src_node_index,
@@ -2597,7 +2593,7 @@ static int __devinit snd_card_asihpi_mixer_new(struct snd_card_asihpi *asihpi) · 5 unmodified lines
25972593 if (err == HPI_ERROR_CONTROL_DISABLED) {
25982594 if (mixer_dump)
25992595 snd_printk(KERN_INFO
2600− "disabled HPI control(%d)\n",
2596+ "Disabled HPI Control(%d)\n",
26012597 idx);
26022598 continue;
26032599 } else
@@ -2662,7 +2658,7 @@ static int __devinit snd_card_asihpi_mixer_new(struct snd_card_asihpi *asihpi) · 58 unmodified lines
26622658 default:
26632659 if (mixer_dump)
26642660 snd_printk(KERN_INFO
2665− "untranslated HPI control"
2661+ "Untranslated HPI Control"
26662662 "(%d) %d %d %d %d %d\n",
26672663 idx,
26682664 hpi_ctl.control_type,
@@ -2712,14 +2708,14 @@ snd_asihpi_proc_read(struct snd_info_entry *entry, · 43 unmodified lines
27122708 version & 0x7,
27132709 ((version >> 13) * 100) + ((version >> 7) & 0x3f));
27142710
2715− err = hpi_mixer_get_control(ss, asihpi->h_mixer,
2711+ err = hpi_mixer_get_control(asihpi->h_mixer,
27162712 HPI_SOURCENODE_CLOCK_SOURCE, 0, 0, 0,
27172713 HPI_CONTROL_SAMPLECLOCK, &h_control);
27182714
27192715 if (!err) {
2720− err = hpi_sample_clock_get_sample_rate(ss,
2716+ err = hpi_sample_clock_get_sample_rate(
27212717 h_control, &rate);
2722− err += hpi_sample_clock_get_source(ss, h_control, &source);
2718+ err += hpi_sample_clock_get_source(h_control, &source);
27232719
27242720 if (!err)
27252721 snd_iprintf(buffer, "sample_clock=%d_hz, source %s\n",
@@ -2841,15 +2837,17 @@ static int __devinit snd_asihpi_probe(struct pci_dev *pci_dev, · 115 unmodified lines
28412837 if (err < 0)
28422838 return err;
28432839 snd_printk(KERN_WARNING
2844− "**** WARNING **** adapter index %d->ALSA index %d\n",
2840+ "**** WARNING **** Adapter index %d->ALSA index %d\n",
28452841 hpi_card->index, card->number);
28462842 }
28472843
2844+ snd_card_set_dev(card, &pci_dev->dev);
2845+
28482846 asihpi = (struct snd_card_asihpi *) card->private_data;
28492847 asihpi->card = card;
2850− asihpi->pci = hpi_card->pci;
2848+ asihpi->pci = pci_dev;
28512849 asihpi->adapter_index = hpi_card->index;
2852− hpi_handle_error(hpi_adapter_get_info(ss,
2850+ hpi_handle_error(hpi_adapter_get_info(
28532851 asihpi->adapter_index,
28542852 &asihpi->num_outstreams,
28552853 &asihpi->num_instreams,
@@ -2859,7 +2857,7 @@ static int __devinit snd_asihpi_probe(struct pci_dev *pci_dev, · 3 unmodified lines
28592857 version = asihpi->version;
28602858 snd_printk(KERN_INFO "adapter ID=%4X index=%d num_outstreams=%d "
28612859 "num_instreams=%d S/N=%d\n"
2862− "hw version %c%d DSP code version %03d\n",
2860+ "Hw Version %c%d DSP code version %03d\n",
28632861 asihpi->type, asihpi->adapter_index,
28642862 asihpi->num_outstreams,
28652863 asihpi->num_instreams, asihpi->serial_number,
@@ -2871,33 +2869,33 @@ static int __devinit snd_asihpi_probe(struct pci_dev *pci_dev, · 5 unmodified lines
28712869 if (pcm_substreams < asihpi->num_instreams)
28722870 pcm_substreams = asihpi->num_instreams;
28732871
2874− err = hpi_adapter_get_property(ss, asihpi->adapter_index,
2872+ err = hpi_adapter_get_property(asihpi->adapter_index,
28752873 HPI_ADAPTER_PROPERTY_CAPS1,
28762874 NULL, &asihpi->support_grouping);
28772875 if (err)
28782876 asihpi->support_grouping = 0;
28792877
2880− err = hpi_adapter_get_property(ss, asihpi->adapter_index,
2878+ err = hpi_adapter_get_property(asihpi->adapter_index,
28812879 HPI_ADAPTER_PROPERTY_CAPS2,
28822880 &asihpi->support_mrx, NULL);
28832881 if (err)
28842882 asihpi->support_mrx = 0;
28852883
2886− err = hpi_adapter_get_property(ss, asihpi->adapter_index,
2884+ err = hpi_adapter_get_property(asihpi->adapter_index,
28872885 HPI_ADAPTER_PROPERTY_INTERVAL,
28882886 NULL, &asihpi->update_interval_frames);
28892887 if (err)
28902888 asihpi->update_interval_frames = 512;
28912889
2892− hpi_handle_error(hpi_instream_open(ss, asihpi->adapter_index,
2890+ hpi_handle_error(hpi_instream_open(asihpi->adapter_index,
28932891 0, &h_stream));
28942892
2895− err = hpi_instream_host_buffer_free(ss, h_stream);
2893+ err = hpi_instream_host_buffer_free(h_stream);
28962894 asihpi->support_mmap = (!err);
28972895
2898− hpi_handle_error(hpi_instream_close(ss, h_stream));
2896+ hpi_handle_error(hpi_instream_close(h_stream));
28992897
2900− err = hpi_adapter_get_property(ss, asihpi->adapter_index,
2898+ err = hpi_adapter_get_property(asihpi->adapter_index,
29012899 HPI_ADAPTER_PROPERTY_CURCHANNELS,
29022900 &asihpi->in_max_chans, &asihpi->out_max_chans);
29032901 if (err) {
@@ -2923,13 +2921,13 @@ static int __devinit snd_asihpi_probe(struct pci_dev *pci_dev, · 19 unmodified lines
29232921 goto __nodev;
29242922 }
29252923
2926− err = hpi_mixer_get_control(ss, asihpi->h_mixer,
2924+ err = hpi_mixer_get_control(asihpi->h_mixer,
29272925 HPI_SOURCENODE_CLOCK_SOURCE, 0, 0, 0,
29282926 HPI_CONTROL_SAMPLECLOCK, &h_control);
29292927
29302928 if (!err)
29312929 err = hpi_sample_clock_set_local_rate(
2932− ss, h_control, adapter_fs);
2930+ h_control, adapter_fs);
29332931
29342932 snd_asihpi_proc_init(asihpi);
29352933
sound/pci/asihpi/hpi.h+448−766
@@ -24,17 +24,10 @@ · 23 unmodified lines
2424
2525 The HPI is a low-level hardware abstraction layer to all
2626 AudioScience digital audio adapters
27−*/
28−/*
29− You must define one operating system that the HPI is to be compiled under
30− HPI_OS_WIN32_USER 32bit Windows
31− HPI_OS_DSP_C6000 DSP TI C6000 (automatically set)
32− HPI_OS_WDM Windows WDM kernel driver
33− HPI_OS_LINUX Linux userspace
34− HPI_OS_LINUX_KERNEL Linux kernel (automatically set)
3527
3628 (C) Copyright AudioScience Inc. 1998-2010
37−******************************************************************************/
29+*/
30+
3831 #ifndef _HPI_H_
3932 #define _HPI_H_
4033 /* HPI Version
@@ -50,20 +43,20 @@ i.e 3.05.02 is a development version · 9 unmodified lines
5043 #define HPI_VER_RELEASE(v) ((int)(v & 0xFF))
5144
5245 /* Use single digits for versions less that 10 to avoid octal. */
53−#define HPI_VER HPI_VERSION_CONSTRUCTOR(4L, 4, 1)
54−#define HPI_VER_STRING "4.04.01"
46+#define HPI_VER HPI_VERSION_CONSTRUCTOR(4L, 6, 0)
47+#define HPI_VER_STRING "4.06.00"
5548
5649 /* Library version as documented in hpi-api-versions.txt */
5750 #define HPI_LIB_VER HPI_VERSION_CONSTRUCTOR(9, 0, 0)
5851
5952 #include <linux/types.h>
60−#define HPI_EXCLUDE_DEPRECATED
53+#define HPI_BUILD_EXCLUDE_DEPRECATED
54+#define HPI_BUILD_KERNEL_MODE
6155
62−/******************************************************************************/
6356 /******************************************************************************/
6457 /******** HPI API DEFINITIONS *****/
6558 /******************************************************************************/
66−/******************************************************************************/
59+
6760 /*******************************************/
6861 /** Audio format types
6962 \ingroup stream
@@ -174,7 +167,6 @@ The range is +1.0 to -1.0, which corresponds to digital fullscale. · 104 unmodified lines
174167 HPI_FORMAT_UNDEFINED = 0xffff
175168 };
176169
177−/******************************************* in/out Stream states */
178170 /*******************************************/
179171 /** Stream States
180172 \ingroup stream
@@ -194,7 +186,7 @@ enum HPI_STREAM_STATES { · 13 unmodified lines
194186 cards to be ready. */
195187 HPI_STATE_WAIT = 6
196188 };
197−/******************************************* mixer source node types */
189+/*******************************************/
198190 /** Source node types
199191 \ingroup mixer
200192 */
@@ -224,7 +216,7 @@ enum HPI_SOURCENODES { · 23 unmodified lines
224216 /* AX6 max sourcenode types = 15 */
225217 };
226218
227−/******************************************* mixer dest node types */
219+/*******************************************/
228220 /** Destination node types
229221 \ingroup mixer
230222 */
@@ -262,11 +254,11 @@ enum HPI_CONTROLS { · 31 unmodified lines
262254 HPI_CONTROL_MUTE = 4, /*mute control - not used at present. */
263255 HPI_CONTROL_MULTIPLEXER = 5, /**< multiplexer control. */
264256
265− HPI_CONTROL_AESEBU_TRANSMITTER = 6, /**< AES/EBU transmitter control. */
266− HPI_CONTROL_AESEBUTX = HPI_CONTROL_AESEBU_TRANSMITTER,
257+ HPI_CONTROL_AESEBU_TRANSMITTER = 6, /**< AES/EBU transmitter control */
258+ HPI_CONTROL_AESEBUTX = 6, /* HPI_CONTROL_AESEBU_TRANSMITTER */
267259
268260 HPI_CONTROL_AESEBU_RECEIVER = 7, /**< AES/EBU receiver control. */
269− HPI_CONTROL_AESEBURX = HPI_CONTROL_AESEBU_RECEIVER,
261+ HPI_CONTROL_AESEBURX = 7, /* HPI_CONTROL_AESEBU_RECEIVER */
270262
271263 HPI_CONTROL_LEVEL = 8, /**< level/trim control - works in d_bu. */
272264 HPI_CONTROL_TUNER = 9, /**< tuner control. */
@@ -281,7 +273,7 @@ enum HPI_CONTROLS { · 8 unmodified lines
281273 HPI_CONTROL_SAMPLECLOCK = 17, /**< sample clock control. */
282274 HPI_CONTROL_MICROPHONE = 18, /**< microphone control. */
283275 HPI_CONTROL_PARAMETRIC_EQ = 19, /**< parametric EQ control. */
284− HPI_CONTROL_EQUALIZER = HPI_CONTROL_PARAMETRIC_EQ,
276+ HPI_CONTROL_EQUALIZER = 19, /*HPI_CONTROL_PARAMETRIC_EQ */
285277
286278 HPI_CONTROL_COMPANDER = 20, /**< compander control. */
287279 HPI_CONTROL_COBRANET = 21, /**< cobranet control. */
@@ -296,10 +288,7 @@ enum HPI_CONTROLS { · 8 unmodified lines
296288 /* WARNING types 256 or greater impact bit packing in all AX6 DSP code */
297289 };
298290
299−/* Shorthand names that match attribute names */
300−
301−/******************************************* ADAPTER ATTRIBUTES ****/
302−
291+/*******************************************/
303292 /** Adapter properties
304293 These are used in HPI_AdapterSetProperty() and HPI_AdapterGetProperty()
305294 \ingroup adapter
@@ -330,12 +319,21 @@ by the driver and is not passed on to the DSP at all. · 24 unmodified lines
330319 Indicates the state of the adapter's SSX2 setting. This setting is stored in
331320 non-volatile memory on the adapter. A typical call sequence would be to use
332321 HPI_ADAPTER_PROPERTY_SSX2_SETTING to set SSX2 on the adapter and then to reload
333−the driver. The driver would query HPI_ADAPTER_PROPERTY_SSX2_SETTING during startup
334−and if SSX2 is set, it would then call HPI_ADAPTER_PROPERTY_ENABLE_SSX2 to enable
335−SSX2 stream mapping within the kernel level of the driver.
322+the driver. The driver would query HPI_ADAPTER_PROPERTY_SSX2_SETTING during
323+startup and if SSX2 is set, it would then call HPI_ADAPTER_PROPERTY_ENABLE_SSX2
324+to enable SSX2 stream mapping within the kernel level of the driver.
336325 */
337326 HPI_ADAPTER_PROPERTY_SSX2_SETTING = 4,
338327
328+/** Enables/disables PCI(e) IRQ.
329+A setting of 0 indicates that no interrupts are being generated. A DSP boot
330+this property is set to 0. Setting to a non-zero value specifies the number
331+of frames of audio that should be processed between interrupts. This property
332+should be set to multiple of the mixer interval as read back from the
333+HPI_ADAPTER_PROPERTY_INTERVAL property.
334+*/
335+ HPI_ADAPTER_PROPERTY_IRQ_RATE = 5,
336+
339337 /** Base number for readonly properties */
340338 HPI_ADAPTER_PROPERTY_READONLYBASE = 256,
341339
@@ -440,21 +438,30 @@ return value is true (1) or false (0). If the current adapter · 98 unmodified lines
440438 mode is MONO SSX2 is disabled, even though this property will
441439 return true.
442440 */
443− HPI_ADAPTER_PROPERTY_SUPPORTS_SSX2 = 271
441+ HPI_ADAPTER_PROPERTY_SUPPORTS_SSX2 = 271,
442+/** Readonly supports PCI(e) IRQ.
443+Indicates that the adapter in it's current mode supports interrupts
444+across the host bus. Note, this does not imply that interrupts are
445+enabled. Instead it indicates that they can be enabled.
446+*/
447+ HPI_ADAPTER_PROPERTY_SUPPORTS_IRQ = 272
444448 };
445449
446450 /** Adapter mode commands
447451
448−Used in wQueryOrSet field of HPI_AdapterSetModeEx().
452+Used in wQueryOrSet parameter of HPI_AdapterSetModeEx().
449453 \ingroup adapter
450454 */
451455 enum HPI_ADAPTER_MODE_CMDS {
456+ /** Set the mode to the given parameter */
452457 HPI_ADAPTER_MODE_SET = 0,
458+ /** Return 0 or error depending whether mode is valid,
459+ but don't set the mode */
453460 HPI_ADAPTER_MODE_QUERY = 1
454461 };
455462
456463 /** Adapter Modes
457− These are used by HPI_AdapterSetModeEx()
464+ These are used by HPI_AdapterSetModeEx()
458465
459466 \warning - more than 16 possible modes breaks
460467 a bitmask in the Windows WAVE DLL
@@ -629,10 +636,13 @@ enum HPI_MIXER_STORE_COMMAND { · 168 unmodified lines
629636 HPI_MIXER_STORE_SAVE_SINGLE = 6
630637 };
631638
632−/************************************* CONTROL ATTRIBUTE VALUES ****/
639+/****************************/
640+/* CONTROL ATTRIBUTE VALUES */
641+/****************************/
642+
633643 /** Used by mixer plugin enable functions
634644
635−E.g. HPI_ParametricEQ_SetState()
645+E.g. HPI_ParametricEq_SetState()
636646 \ingroup mixer
637647 */
638648 enum HPI_SWITCH_STATES {
@@ -641,6 +651,7 @@ enum HPI_SWITCH_STATES { · 2 unmodified lines
641651 };
642652
643653 /* Volume control special gain values */
654+
644655 /** volumes units are 100ths of a dB
645656 \ingroup volume
646657 */
@@ -650,6 +661,11 @@ enum HPI_SWITCH_STATES { · 3 unmodified lines
650661 */
651662 #define HPI_GAIN_OFF (-100 * HPI_UNITS_PER_dB)
652663
664+/** channel mask specifying all channels
665+\ingroup volume
666+*/
667+#define HPI_BITMASK_ALL_CHANNELS (0xFFFFFFFF)
668+
653669 /** value returned for no signal
654670 \ingroup meter
655671 */
@@ -667,7 +683,7 @@ enum HPI_VOLUME_AUTOFADES { · 11 unmodified lines
667683
668684 /** The physical encoding format of the AESEBU I/O.
669685
670−Used in HPI_AESEBU_Transmitter_SetFormat(), HPI_AESEBU_Receiver_SetFormat()
686+Used in HPI_Aesebu_Transmitter_SetFormat(), HPI_Aesebu_Receiver_SetFormat()
671687 along with related Get and Query functions
672688 \ingroup aestx
673689 */
@@ -680,7 +696,7 @@ enum HPI_AESEBU_FORMATS { · 6 unmodified lines
680696
681697 /** AES/EBU error status bits
682698
683−Returned by HPI_AESEBU_Receiver_GetErrorStatus()
699+Returned by HPI_Aesebu_Receiver_GetErrorStatus()
684700 \ingroup aesrx
685701 */
686702 enum HPI_AESEBU_ERRORS {
@@ -767,14 +783,6 @@ enum HPI_TUNER_MODE_VALUES { · 80 unmodified lines
767783 HPI_TUNER_MODE_RDS_RBDS = 2 /**< RDS - RBDS mode */
768784 };
769785
770−/** Tuner Level settings
771−\ingroup tuner
772−*/
773−enum HPI_TUNER_LEVEL {
774− HPI_TUNER_LEVEL_AVERAGE = 0,
775− HPI_TUNER_LEVEL_RAW = 1
776−};
777−
778786 /** Tuner Status Bits
779787
780788 These bitfield values are returned by a call to HPI_Tuner_GetStatus().
@@ -783,13 +791,13 @@ Multiple fields are returned from a single call. · 2 unmodified lines
783791 */
784792 enum HPI_TUNER_STATUS_BITS {
785793 HPI_TUNER_VIDEO_COLOR_PRESENT = 0x0001, /**< video color is present. */
786− HPI_TUNER_VIDEO_IS_60HZ = 0x0020, /**< 60 hz video detected. */
787− HPI_TUNER_VIDEO_HORZ_SYNC_MISSING = 0x0040, /**< video HSYNC is missing. */
788− HPI_TUNER_VIDEO_STATUS_VALID = 0x0100, /**< video status is valid. */
789− HPI_TUNER_PLL_LOCKED = 0x1000, /**< the tuner's PLL is locked. */
790− HPI_TUNER_FM_STEREO = 0x2000, /**< tuner reports back FM stereo. */
791− HPI_TUNER_DIGITAL = 0x0200, /**< tuner reports digital programming. */
792− HPI_TUNER_MULTIPROGRAM = 0x0400 /**< tuner reports multiple programs. */
794+ HPI_TUNER_VIDEO_IS_60HZ = 0x0020, /**< 60 hz video detected. */
795+ HPI_TUNER_VIDEO_HORZ_SYNC_MISSING = 0x0040, /**< video HSYNC is missing. */
796+ HPI_TUNER_VIDEO_STATUS_VALID = 0x0100, /**< video status is valid. */
797+ HPI_TUNER_DIGITAL = 0x0200, /**< tuner reports digital programming. */
798+ HPI_TUNER_MULTIPROGRAM = 0x0400, /**< tuner reports multiple programs. */
799+ HPI_TUNER_PLL_LOCKED = 0x1000, /**< the tuner's PLL is locked. */
800+ HPI_TUNER_FM_STEREO = 0x2000 /**< tuner reports back FM stereo. */
793801 };
794802
795803 /** Channel Modes
@@ -839,7 +847,7 @@ enum HPI_SAMPLECLOCK_SOURCES { · 43 unmodified lines
839847 HPI_SAMPLECLOCK_SOURCE_LAST = 10
840848 };
841849
842−/** Equalizer filter types. Used by HPI_ParametricEQ_SetBand()
850+/** Equalizer filter types. Used by HPI_ParametricEq_SetBand()
843851 \ingroup parmeq
844852 */
845853 enum HPI_FILTER_TYPE {
@@ -882,7 +890,7 @@ enum HPI_ERROR_CODES { · 36 unmodified lines
882890 HPI_ERROR_INVALID_OBJ = 101,
883891 /** Function does not exist. */
884892 HPI_ERROR_INVALID_FUNC = 102,
885− /** The specified object (adapter/Stream) does not exist. */
893+ /** The specified object does not exist. */
886894 HPI_ERROR_INVALID_OBJ_INDEX = 103,
887895 /** Trying to access an object that has not been opened yet. */
888896 HPI_ERROR_OBJ_NOT_OPEN = 104,
@@ -890,8 +898,7 @@ enum HPI_ERROR_CODES { · 1 unmodified line
890898 HPI_ERROR_OBJ_ALREADY_OPEN = 105,
891899 /** PCI, ISA resource not valid. */
892900 HPI_ERROR_INVALID_RESOURCE = 106,
893− /** GetInfo call from SubSysFindAdapters failed. */
894− HPI_ERROR_SUBSYSFINDADAPTERS_GETINFO = 107,
901+ /* HPI_ERROR_SUBSYSFINDADAPTERS_GETINFO= 107 */
895902 /** Default response was never updated with actual error code. */
896903 HPI_ERROR_INVALID_RESPONSE = 108,
897904 /** wSize field of response was not updated,
@@ -899,38 +906,44 @@ enum HPI_ERROR_CODES { · 1 unmodified line
899906 HPI_ERROR_PROCESSING_MESSAGE = 109,
900907 /** The network did not respond in a timely manner. */
901908 HPI_ERROR_NETWORK_TIMEOUT = 110,
902− /** An HPI handle is invalid (uninitialised?). */
909+ /* An HPI handle is invalid (uninitialised?). */
903910 HPI_ERROR_INVALID_HANDLE = 111,
904911 /** A function or attribute has not been implemented yet. */
905912 HPI_ERROR_UNIMPLEMENTED = 112,
906− /** There are too many clients attempting to access a network resource. */
913+ /** There are too many clients attempting
914+ to access a network resource. */
907915 HPI_ERROR_NETWORK_TOO_MANY_CLIENTS = 113,
908− /** Response buffer passed to HPI_Message was smaller than returned response */
916+ /** Response buffer passed to HPI_Message
917+ was smaller than returned response.
918+ wSpecificError field of hpi response contains the required size.
919+ */
909920 HPI_ERROR_RESPONSE_BUFFER_TOO_SMALL = 114,
910921 /** The returned response did not match the sent message */
911922 HPI_ERROR_RESPONSE_MISMATCH = 115,
923+ /** A control setting that should have been cached was not. */
924+ HPI_ERROR_CONTROL_CACHING = 116,
925+ /** A message buffer in the path to the adapter was smaller
926+ than the message size.
927+ wSpecificError field of hpi response contains the actual size.
928+ */
929+ HPI_ERROR_MESSAGE_BUFFER_TOO_SMALL = 117,
912930
913− /** Too many adapters.*/
914− HPI_ERROR_TOO_MANY_ADAPTERS = 200,
931+ /* HPI_ERROR_TOO_MANY_ADAPTERS= 200 */
915932 /** Bad adpater. */
916933 HPI_ERROR_BAD_ADAPTER = 201,
917934 /** Adapter number out of range or not set properly. */
918935 HPI_ERROR_BAD_ADAPTER_NUMBER = 202,
919936 /** 2 adapters with the same adapter number. */
920− HPI_DUPLICATE_ADAPTER_NUMBER = 203,
921− /** DSP code failed to bootload. */
937+ HPI_ERROR_DUPLICATE_ADAPTER_NUMBER = 203,
938+ /** DSP code failed to bootload. (unused?) */
922939 HPI_ERROR_DSP_BOOTLOAD = 204,
923− /** Adapter failed DSP code self test. */
924− HPI_ERROR_DSP_SELFTEST = 205,
925940 /** Couldn't find or open the DSP code file. */
926941 HPI_ERROR_DSP_FILE_NOT_FOUND = 206,
927942 /** Internal DSP hardware error. */
928943 HPI_ERROR_DSP_HARDWARE = 207,
929− /** Could not allocate memory in DOS. */
930− HPI_ERROR_DOS_MEMORY_ALLOC = 208,
931944 /** Could not allocate memory */
932945 HPI_ERROR_MEMORY_ALLOC = 208,
933− /** Failed to correctly load/config PLD .*/
946+ /** Failed to correctly load/config PLD. (unused) */
934947 HPI_ERROR_PLD_LOAD = 209,
935948 /** Unexpected end of file, block length too big etc. */
936949 HPI_ERROR_DSP_FILE_FORMAT = 210,
@@ -939,8 +952,7 @@ enum HPI_ERROR_CODES { · 2 unmodified lines
939952 HPI_ERROR_DSP_FILE_ACCESS_DENIED = 211,
940953 /** First DSP code section header not found in DSP file. */
941954 HPI_ERROR_DSP_FILE_NO_HEADER = 212,
942− /** File read operation on DSP code file failed. */
943− HPI_ERROR_DSP_FILE_READ_ERROR = 213,
955+ /* HPI_ERROR_DSP_FILE_READ_ERROR= 213, */
944956 /** DSP code for adapter family not found. */
945957 HPI_ERROR_DSP_SECTION_NOT_FOUND = 214,
946958 /** Other OS specific error opening DSP file. */
@@ -950,23 +962,21 @@ enum HPI_ERROR_CODES { · 3 unmodified lines
950962 /** DSP code section header had size == 0. */
951963 HPI_ERROR_DSP_FILE_NULL_HEADER = 217,
952964
953− /** Base number for flash errors. */
954− HPI_ERROR_FLASH = 220,
965+ /* HPI_ERROR_FLASH = 220, */
955966
956967 /** Flash has bad checksum */
957− HPI_ERROR_BAD_CHECKSUM = (HPI_ERROR_FLASH + 1),
958− HPI_ERROR_BAD_SEQUENCE = (HPI_ERROR_FLASH + 2),
959− HPI_ERROR_FLASH_ERASE = (HPI_ERROR_FLASH + 3),
960− HPI_ERROR_FLASH_PROGRAM = (HPI_ERROR_FLASH + 4),
961− HPI_ERROR_FLASH_VERIFY = (HPI_ERROR_FLASH + 5),
962− HPI_ERROR_FLASH_TYPE = (HPI_ERROR_FLASH + 6),
963− HPI_ERROR_FLASH_START = (HPI_ERROR_FLASH + 7),
968+ HPI_ERROR_BAD_CHECKSUM = 221,
969+ HPI_ERROR_BAD_SEQUENCE = 222,
970+ HPI_ERROR_FLASH_ERASE = 223,
971+ HPI_ERROR_FLASH_PROGRAM = 224,
972+ HPI_ERROR_FLASH_VERIFY = 225,
973+ HPI_ERROR_FLASH_TYPE = 226,
974+ HPI_ERROR_FLASH_START = 227,
964975
965976 /** Reserved for OEMs. */
966977 HPI_ERROR_RESERVED_1 = 290,
967978
968− /** Stream does not exist. */
969− HPI_ERROR_INVALID_STREAM = 300,
979+ /* HPI_ERROR_INVALID_STREAM = 300 use HPI_ERROR_INVALID_OBJ_INDEX */
970980 /** Invalid compression format. */
971981 HPI_ERROR_INVALID_FORMAT = 301,
972982 /** Invalid format samplerate */
@@ -977,21 +987,19 @@ enum HPI_ERROR_CODES { · 4 unmodified lines
977987 HPI_ERROR_INVALID_BITRATE = 304,
978988 /** Invalid datasize used for stream read/write. */
979989 HPI_ERROR_INVALID_DATASIZE = 305,
980− /** Stream buffer is full during stream write. */
981− HPI_ERROR_BUFFER_FULL = 306,
982− /** Stream buffer is empty during stream read. */
983− HPI_ERROR_BUFFER_EMPTY = 307,
984− /** Invalid datasize used for stream read/write. */
985− HPI_ERROR_INVALID_DATA_TRANSFER = 308,
990+ /* HPI_ERROR_BUFFER_FULL = 306 use HPI_ERROR_INVALID_DATASIZE */
991+ /* HPI_ERROR_BUFFER_EMPTY = 307 use HPI_ERROR_INVALID_DATASIZE */
992+ /** Null data pointer used for stream read/write. */
993+ HPI_ERROR_INVALID_DATA_POINTER = 308,
986994 /** Packet ordering error for stream read/write. */
987995 HPI_ERROR_INVALID_PACKET_ORDER = 309,
988996
989997 /** Object can't do requested operation in its current
990− state, eg set format, change rec mux state while recording.*/
998+ state, eg set format, change rec mux state while recording.*/
991999 HPI_ERROR_INVALID_OPERATION = 310,
9921000
993− /** Where an SRG is shared amongst streams, an incompatible samplerate is one
994− that is different to any currently playing or recording stream. */
1001+ /** Where a SRG is shared amongst streams, an incompatible samplerate
1002+ is one that is different to any currently active stream. */
9951003 HPI_ERROR_INCOMPATIBLE_SAMPLERATE = 311,
9961004 /** Adapter mode is illegal.*/
9971005 HPI_ERROR_BAD_ADAPTER_MODE = 312,
@@ -1004,6 +1012,8 @@ enum HPI_ERROR_CODES { · 6 unmodified lines
10041012 HPI_ERROR_NO_INTERADAPTER_GROUPS = 314,
10051013 /** Streams on different DSPs cannot be grouped. */
10061014 HPI_ERROR_NO_INTERDSP_GROUPS = 315,
1015+ /** Stream wait cancelled before threshold reached. */
1016+ HPI_ERROR_WAIT_CANCELLED = 316,
10071017
10081018 /** Invalid mixer node for this adapter. */
10091019 HPI_ERROR_INVALID_NODE = 400,
@@ -1017,6 +1027,7 @@ enum HPI_ERROR_CODES { · 7 unmodified lines
10171027 HPI_ERROR_CONTROL_DISABLED = 404,
10181028 /** I2C transaction failed due to a missing ACK. */
10191029 HPI_ERROR_CONTROL_I2C_MISSING_ACK = 405,
1030+ HPI_ERROR_I2C_MISSING_ACK = 405,
10201031 /** Control is busy, or coming out of
10211032 reset and cannot be accessed at this time. */
10221033 HPI_ERROR_CONTROL_NOT_READY = 407,
@@ -1027,7 +1038,6 @@ enum HPI_ERROR_CODES { · 4 unmodified lines
10271038 HPI_ERROR_NVMEM_FAIL = 452,
10281039
10291040 /** I2C */
1030− HPI_ERROR_I2C_MISSING_ACK = HPI_ERROR_CONTROL_I2C_MISSING_ACK,
10311041 HPI_ERROR_I2C_BAD_ADR = 460,
10321042
10331043 /** Entity errors */
@@ -1035,6 +1045,7 @@ enum HPI_ERROR_CODES { · 1 unmodified line
10351045 HPI_ERROR_ENTITY_ITEM_COUNT = 471,
10361046 HPI_ERROR_ENTITY_TYPE_INVALID = 472,
10371047 HPI_ERROR_ENTITY_ROLE_INVALID = 473,
1048+ HPI_ERROR_ENTITY_SIZE_MISMATCH = 474,
10381049
10391050 /* AES18 specific errors were 500..507 */
10401051
@@ -1044,11 +1055,18 @@ enum HPI_ERROR_CODES { · 3 unmodified lines
10441055 /** hpioct32.c can't obtain mutex */
10451056 HPI_ERROR_MUTEX_TIMEOUT = 700,
10461057
1047− /** errors from HPI backends have values >= this */
1058+ /** Backend errors used to be greater than this.
1059+ \deprecated Now, all backends return only errors defined here in hpi.h
1060+ */
10481061 HPI_ERROR_BACKEND_BASE = 900,
10491062
1050− /** indicates a cached u16 value is invalid. */
1051− HPI_ERROR_ILLEGAL_CACHE_VALUE = 0xffff
1063+ /** Communication with DSP failed */
1064+ HPI_ERROR_DSP_COMMUNICATION = 900
1065+ /* Note that the dsp communication error is set to this value so that
1066+ it remains compatible with any software that expects such errors
1067+ to be backend errors i.e. >= 900.
1068+ Do not define any new error codes with values > 900.
1069+ */
10521070 };
10531071
10541072 /** \defgroup maximums HPI maximum values
@@ -1075,7 +1093,7 @@ enum HPI_ERROR_CODES { · 20 unmodified lines
10751093
10761094 /**\}*/
10771095
1078−/* ////////////////////////////////////////////////////////////////////// */
1096+/**************/
10791097 /* STRUCTURES */
10801098 #ifndef DISABLE_PRAGMA_PACK1
10811099 #pragma pack(push, 1)
@@ -1092,7 +1110,7 @@ struct hpi_format { · 10 unmodified lines
10921110 /**< Stereo/JointStereo/Mono */
10931111 u16 mode_legacy;
10941112 /**< Legacy ancillary mode or idle bit */
1095− u16 unused; /**< unused */
1113+ u16 unused; /**< Unused */
10961114 u16 channels; /**< 1,2..., (or ancillary mode or idle bit */
10971115 u16 format; /**< HPI_FORMAT_PCM16, _MPEG etc. see #HPI_FORMATS. */
10981116 };
@@ -1106,930 +1124,594 @@ struct hpi_anc_frame { · 7 unmodified lines
11061124 */
11071125 struct hpi_async_event {
11081126 u16 event_type; /**< type of event. \sa async_event */
1109− u16 sequence; /**< sequence number, allows lost event detection */
1110− u32 state; /**< new state */
1111− u32 h_object; /**< handle to the object returning the event. */
1127+ u16 sequence; /**< Sequence number, allows lost event detection */
1128+ u32 state; /**< New state */
1129+ u32 h_object; /**< handle to the object returning the event. */
11121130 union {
11131131 struct {
11141132 u16 index; /**< GPIO bit index. */
11151133 } gpio;
11161134 struct {
11171135 u16 node_index; /**< what node is the control on ? */
1118− u16 node_type; /**< what type of node is the control on ? */
1136+ u16 node_type; /**< what type of node is the control on ? */
11191137 } control;
11201138 } u;
11211139 };
11221140
1123−/*/////////////////////////////////////////////////////////////////////////// */
1124−/* Public HPI Entity related definitions */
1125−
1126−struct hpi_entity;
1127−
1128−enum e_entity_type {
1129− entity_type_null,
1130− entity_type_sequence, /* sequence of potentially heterogeneous TLV entities */
1131−
1132− entity_type_reference, /* refers to a TLV entity or NULL */
1133−
1134− entity_type_int, /* 32 bit */
1135− entity_type_float, /* ieee754 binary 32 bit encoding */
1136− entity_type_double,
1137−
1138− entity_type_cstring,
1139− entity_type_octet,
1140− entity_type_ip4_address,
1141− entity_type_ip6_address,
1142− entity_type_mac_address,
1143−
1144− LAST_ENTITY_TYPE
1145−};
1146−
1147−enum e_entity_role {
1148− entity_role_null,
1149− entity_role_value,
1150− entity_role_classname,
1151−
1152− entity_role_units,
1153− entity_role_flags,
1154− entity_role_range,
1155−
1156− entity_role_mapping,
1157− entity_role_enum,
1158−
1159− entity_role_instance_of,
1160− entity_role_depends_on,
1161− entity_role_member_of_group,
1162− entity_role_value_constraint,
1163− entity_role_parameter_port,
1164−
1165− entity_role_block,
1166− entity_role_node_group,
1167− entity_role_audio_port,
1168− entity_role_clock_port,
1169− LAST_ENTITY_ROLE
1170−};
1171−
11721141 /* skip host side function declarations for
11731142 DSP compile and documentation extraction */
11741143
1175−struct hpi_hsubsys {
1176− int not_really_used;
1177−};
1178−
11791144 #ifndef DISABLE_PRAGMA_PACK1
11801145 #pragma pack(pop)
11811146 #endif
11821147
1183−/*////////////////////////////////////////////////////////////////////////// */
1148+/*****************/
11841149 /* HPI FUNCTIONS */
1150+/*****************/
11851151
1186−/*/////////////////////////// */
1187−/* DATA and FORMAT and STREAM */
1188−
1152+/* Stream */
11891153 u16 hpi_stream_estimate_buffer_size(struct hpi_format *pF,
11901154 u32 host_polling_rate_in_milli_seconds, u32 *recommended_buffer_size);
11911155
1192−/*/////////// */
1193−/* SUB SYSTEM */
1194−struct hpi_hsubsys *hpi_subsys_create(void
1195− );
1196−
1197−void hpi_subsys_free(const struct hpi_hsubsys *ph_subsys);
1198−
1199−u16 hpi_subsys_get_version(const struct hpi_hsubsys *ph_subsys,
1200− u32 *pversion);
1201−
1202−u16 hpi_subsys_get_version_ex(const struct hpi_hsubsys *ph_subsys,
1203− u32 *pversion_ex);
1204−
1205−u16 hpi_subsys_get_info(const struct hpi_hsubsys *ph_subsys, u32 *pversion,
1206− u16 *pw_num_adapters, u16 aw_adapter_list[], u16 list_length);
1207−
1208−u16 hpi_subsys_find_adapters(const struct hpi_hsubsys *ph_subsys,
1209− u16 *pw_num_adapters, u16 aw_adapter_list[], u16 list_length);
1210−
1211−u16 hpi_subsys_get_num_adapters(const struct hpi_hsubsys *ph_subsys,
1212− int *pn_num_adapters);
1213−
1214−u16 hpi_subsys_get_adapter(const struct hpi_hsubsys *ph_subsys, int iterator,
1215− u32 *padapter_index, u16 *pw_adapter_type);
1216−
1217−u16 hpi_subsys_ssx2_bypass(const struct hpi_hsubsys *ph_subsys, u16 bypass);
1156+/*************/
1157+/* SubSystem */
1158+/*************/
12181159
1219−u16 hpi_subsys_set_host_network_interface(const struct hpi_hsubsys *ph_subsys,
1220− const char *sz_interface);
1160+u16 hpi_subsys_get_version_ex(u32 *pversion_ex);
12211161
1222−/*///////// */
1223−/* ADAPTER */
1162+u16 hpi_subsys_get_num_adapters(int *pn_num_adapters);
12241163
1225−u16 hpi_adapter_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index);
1164+u16 hpi_subsys_get_adapter(int iterator, u32 *padapter_index,
1165+ u16 *pw_adapter_type);
12261166
1227−u16 hpi_adapter_close(const struct hpi_hsubsys *ph_subsys, u16 adapter_index);
1167+/***********/
1168+/* Adapter */
1169+/***********/
12281170
1229−u16 hpi_adapter_get_info(const struct hpi_hsubsys *ph_subsys,
1230− u16 adapter_index, u16 *pw_num_outstreams, u16 *pw_num_instreams,
1231− u16 *pw_version, u32 *pserial_number, u16 *pw_adapter_type);
1171+u16 hpi_adapter_open(u16 adapter_index);
12321172
1233−u16 hpi_adapter_get_module_by_index(const struct hpi_hsubsys *ph_subsys,
1234− u16 adapter_index, u16 module_index, u16 *pw_num_outputs,
1235− u16 *pw_num_inputs, u16 *pw_version, u32 *pserial_number,
1236− u16 *pw_module_type, u32 *ph_module);
1173+u16 hpi_adapter_close(u16 adapter_index);
12371174
1238−u16 hpi_adapter_set_mode(const struct hpi_hsubsys *ph_subsys,
1239− u16 adapter_index, u32 adapter_mode);
1175+u16 hpi_adapter_get_info(u16 adapter_index, u16 *pw_num_outstreams,
1176+ u16 *pw_num_instreams, u16 *pw_version, u32 *pserial_number,
1177+ u16 *pw_adapter_type);
12401178
1241−u16 hpi_adapter_set_mode_ex(const struct hpi_hsubsys *ph_subsys,
1242− u16 adapter_index, u32 adapter_mode, u16 query_or_set);
1243−
1244−u16 hpi_adapter_get_mode(const struct hpi_hsubsys *ph_subsys,
1245− u16 adapter_index, u32 *padapter_mode);
1246−
1247−u16 hpi_adapter_get_assert(const struct hpi_hsubsys *ph_subsys,
1248− u16 adapter_index, u16 *assert_present, char *psz_assert,
1249− u16 *pw_line_number);
1250−
1251−u16 hpi_adapter_get_assert_ex(const struct hpi_hsubsys *ph_subsys,
1252− u16 adapter_index, u16 *assert_present, char *psz_assert,
1253− u32 *pline_number, u16 *pw_assert_on_dsp);
1254−
1255−u16 hpi_adapter_test_assert(const struct hpi_hsubsys *ph_subsys,
1256− u16 adapter_index, u16 assert_id);
1257−
1258−u16 hpi_adapter_enable_capability(const struct hpi_hsubsys *ph_subsys,
1259− u16 adapter_index, u16 capability, u32 key);
1260−
1261−u16 hpi_adapter_self_test(const struct hpi_hsubsys *ph_subsys,
1262− u16 adapter_index);
1263−
1264−u16 hpi_adapter_debug_read(const struct hpi_hsubsys *ph_subsys,
1265− u16 adapter_index, u32 dsp_address, char *p_bytes, int *count_bytes);
1266−
1267−u16 hpi_adapter_set_property(const struct hpi_hsubsys *ph_subsys,
1268− u16 adapter_index, u16 property, u16 paramter1, u16 paramter2);
1269−
1270−u16 hpi_adapter_get_property(const struct hpi_hsubsys *ph_subsys,
1271− u16 adapter_index, u16 property, u16 *pw_paramter1,
1272− u16 *pw_paramter2);
1273−
1274−u16 hpi_adapter_enumerate_property(const struct hpi_hsubsys *ph_subsys,
1275− u16 adapter_index, u16 index, u16 what_to_enumerate,
1276− u16 property_index, u32 *psetting);
1277−
1278−/*////////////// */
1279−/* NonVol Memory */
1280−u16 hpi_nv_memory_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index,
1281− u32 *ph_nv_memory, u16 *pw_size_in_bytes);
1282−
1283−u16 hpi_nv_memory_read_byte(const struct hpi_hsubsys *ph_subsys,
1284− u32 h_nv_memory, u16 index, u16 *pw_data);
1285−
1286−u16 hpi_nv_memory_write_byte(const struct hpi_hsubsys *ph_subsys,
1287− u32 h_nv_memory, u16 index, u16 data);
1288−
1289−/*////////////// */
1290−/* Digital I/O */
1291−u16 hpi_gpio_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index,
1292− u32 *ph_gpio, u16 *pw_number_input_bits, u16 *pw_number_output_bits);
1293−
1294−u16 hpi_gpio_read_bit(const struct hpi_hsubsys *ph_subsys, u32 h_gpio,
1295− u16 bit_index, u16 *pw_bit_data);
1296−
1297−u16 hpi_gpio_read_all_bits(const struct hpi_hsubsys *ph_subsys, u32 h_gpio,
1298− u16 aw_all_bit_data[4]
1299− );
1179+u16 hpi_adapter_get_module_by_index(u16 adapter_index, u16 module_index,
1180+ u16 *pw_num_outputs, u16 *pw_num_inputs, u16 *pw_version,
1181+ u32 *pserial_number, u16 *pw_module_type, u32 *ph_module);
13001182
1301−u16 hpi_gpio_write_bit(const struct hpi_hsubsys *ph_subsys, u32 h_gpio,
1302− u16 bit_index, u16 bit_data);
1183+u16 hpi_adapter_set_mode(u16 adapter_index, u32 adapter_mode);
13031184
1304−u16 hpi_gpio_write_status(const struct hpi_hsubsys *ph_subsys, u32 h_gpio,
1305− u16 aw_all_bit_data[4]
1306− );
1185+u16 hpi_adapter_set_mode_ex(u16 adapter_index, u32 adapter_mode,
1186+ u16 query_or_set);
13071187
1308−/**********************/
1309−/* Async Event Object */
1310−/**********************/
1311−u16 hpi_async_event_open(const struct hpi_hsubsys *ph_subsys,
1312− u16 adapter_index, u32 *ph_async);
1188+u16 hpi_adapter_get_mode(u16 adapter_index, u32 *padapter_mode);
13131189
1314−u16 hpi_async_event_close(const struct hpi_hsubsys *ph_subsys, u32 h_async);
1190+u16 hpi_adapter_get_assert2(u16 adapter_index, u16 *p_assert_count,
1191+ char *psz_assert, u32 *p_param1, u32 *p_param2,
1192+ u32 *p_dsp_string_addr, u16 *p_processor_id);
13151193
1316−u16 hpi_async_event_wait(const struct hpi_hsubsys *ph_subsys, u32 h_async,
1317− u16 maximum_events, struct hpi_async_event *p_events,
1318− u16 *pw_number_returned);
1194+u16 hpi_adapter_test_assert(u16 adapter_index, u16 assert_id);
13191195
1320−u16 hpi_async_event_get_count(const struct hpi_hsubsys *ph_subsys,
1321− u32 h_async, u16 *pw_count);
1196+u16 hpi_adapter_enable_capability(u16 adapter_index, u16 capability, u32 key);
13221197
1323−u16 hpi_async_event_get(const struct hpi_hsubsys *ph_subsys, u32 h_async,
1324− u16 maximum_events, struct hpi_async_event *p_events,
1325− u16 *pw_number_returned);
1198+u16 hpi_adapter_self_test(u16 adapter_index);
13261199
1327−/*/////////// */
1328−/* WATCH-DOG */
1329−u16 hpi_watchdog_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index,
1330− u32 *ph_watchdog);
1200+u16 hpi_adapter_debug_read(u16 adapter_index, u32 dsp_address, char *p_bytes,
1201+ int *count_bytes);
13311202
1332−u16 hpi_watchdog_set_time(const struct hpi_hsubsys *ph_subsys, u32 h_watchdog,
1333− u32 time_millisec);
1203+u16 hpi_adapter_set_property(u16 adapter_index, u16 property, u16 paramter1,
1204+ u16 paramter2);
13341205
1335−u16 hpi_watchdog_ping(const struct hpi_hsubsys *ph_subsys, u32 h_watchdog);
1206+u16 hpi_adapter_get_property(u16 adapter_index, u16 property,
1207+ u16 *pw_paramter1, u16 *pw_paramter2);
13361208
1337−/**************/
1338−/* OUT STREAM */
1339−/**************/
1340−u16 hpi_outstream_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index,
1341− u16 outstream_index, u32 *ph_outstream);
1209+u16 hpi_adapter_enumerate_property(u16 adapter_index, u16 index,
1210+ u16 what_to_enumerate, u16 property_index, u32 *psetting);
1211+/*************/
1212+/* OutStream */
1213+/*************/
1214+u16 hpi_outstream_open(u16 adapter_index, u16 outstream_index,
1215+ u32 *ph_outstream);
13421216
1343−u16 hpi_outstream_close(const struct hpi_hsubsys *ph_subsys, u32 h_outstream);
1217+u16 hpi_outstream_close(u32 h_outstream);
13441218
1345−u16 hpi_outstream_get_info_ex(const struct hpi_hsubsys *ph_subsys,
1346− u32 h_outstream, u16 *pw_state, u32 *pbuffer_size, u32 *pdata_to_play,
1347− u32 *psamples_played, u32 *pauxiliary_data_to_play);
1219+u16 hpi_outstream_get_info_ex(u32 h_outstream, u16 *pw_state,
1220+ u32 *pbuffer_size, u32 *pdata_to_play, u32 *psamples_played,
1221+ u32 *pauxiliary_data_to_play);
13481222
1349−u16 hpi_outstream_write_buf(const struct hpi_hsubsys *ph_subsys,
1350− u32 h_outstream, const u8 *pb_write_buf, u32 bytes_to_write,
1351− const struct hpi_format *p_format);
1223+u16 hpi_outstream_write_buf(u32 h_outstream, const u8 *pb_write_buf,
1224+ u32 bytes_to_write, const struct hpi_format *p_format);
13521225
1353−u16 hpi_outstream_start(const struct hpi_hsubsys *ph_subsys, u32 h_outstream);
1226+u16 hpi_outstream_start(u32 h_outstream);
13541227
1355−u16 hpi_outstream_wait_start(const struct hpi_hsubsys *ph_subsys,
1356− u32 h_outstream);
1228+u16 hpi_outstream_wait_start(u32 h_outstream);
13571229
1358−u16 hpi_outstream_stop(const struct hpi_hsubsys *ph_subsys, u32 h_outstream);
1230+u16 hpi_outstream_stop(u32 h_outstream);
13591231
1360−u16 hpi_outstream_sinegen(const struct hpi_hsubsys *ph_subsys,
1361− u32 h_outstream);
1232+u16 hpi_outstream_sinegen(u32 h_outstream);
13621233
1363−u16 hpi_outstream_reset(const struct hpi_hsubsys *ph_subsys, u32 h_outstream);
1234+u16 hpi_outstream_reset(u32 h_outstream);
13641235
1365−u16 hpi_outstream_query_format(const struct hpi_hsubsys *ph_subsys,
1366− u32 h_outstream, struct hpi_format *p_format);
1236+u16 hpi_outstream_query_format(u32 h_outstream, struct hpi_format *p_format);
13671237
1368−u16 hpi_outstream_set_format(const struct hpi_hsubsys *ph_subsys,
1369− u32 h_outstream, struct hpi_format *p_format);
1238+u16 hpi_outstream_set_format(u32 h_outstream, struct hpi_format *p_format);
13701239
1371−u16 hpi_outstream_set_punch_in_out(const struct hpi_hsubsys *ph_subsys,
1372− u32 h_outstream, u32 punch_in_sample, u32 punch_out_sample);
1240+u16 hpi_outstream_set_punch_in_out(u32 h_outstream, u32 punch_in_sample,
1241+ u32 punch_out_sample);
13731242
1374−u16 hpi_outstream_set_velocity(const struct hpi_hsubsys *ph_subsys,
1375− u32 h_outstream, short velocity);
1243+u16 hpi_outstream_set_velocity(u32 h_outstream, short velocity);
13761244
1377−u16 hpi_outstream_ancillary_reset(const struct hpi_hsubsys *ph_subsys,
1378− u32 h_outstream, u16 mode);
1245+u16 hpi_outstream_ancillary_reset(u32 h_outstream, u16 mode);
13791246
1380−u16 hpi_outstream_ancillary_get_info(const struct hpi_hsubsys *ph_subsys,
1381− u32 h_outstream, u32 *pframes_available);
1247+u16 hpi_outstream_ancillary_get_info(u32 h_outstream, u32 *pframes_available);
13821248
1383−u16 hpi_outstream_ancillary_read(const struct hpi_hsubsys *ph_subsys,
1384− u32 h_outstream, struct hpi_anc_frame *p_anc_frame_buffer,
1249+u16 hpi_outstream_ancillary_read(u32 h_outstream,
1250+ struct hpi_anc_frame *p_anc_frame_buffer,
13851251 u32 anc_frame_buffer_size_in_bytes,
13861252 u32 number_of_ancillary_frames_to_read);
13871253
1388−u16 hpi_outstream_set_time_scale(const struct hpi_hsubsys *ph_subsys,
1389− u32 h_outstream, u32 time_scaleX10000);
1254+u16 hpi_outstream_set_time_scale(u32 h_outstream, u32 time_scaleX10000);
13901255
1391−u16 hpi_outstream_host_buffer_allocate(const struct hpi_hsubsys *ph_subsys,
1392− u32 h_outstream, u32 size_in_bytes);
1256+u16 hpi_outstream_host_buffer_allocate(u32 h_outstream, u32 size_in_bytes);
13931257
1394−u16 hpi_outstream_host_buffer_free(const struct hpi_hsubsys *ph_subsys,
1395− u32 h_outstream);
1258+u16 hpi_outstream_host_buffer_free(u32 h_outstream);
13961259
1397−u16 hpi_outstream_group_add(const struct hpi_hsubsys *ph_subsys,
1398− u32 h_outstream, u32 h_stream);
1260+u16 hpi_outstream_group_add(u32 h_outstream, u32 h_stream);
13991261
1400−u16 hpi_outstream_group_get_map(const struct hpi_hsubsys *ph_subsys,
1401− u32 h_outstream, u32 *poutstream_map, u32 *pinstream_map);
1262+u16 hpi_outstream_group_get_map(u32 h_outstream, u32 *poutstream_map,
1263+ u32 *pinstream_map);
14021264
1403−u16 hpi_outstream_group_reset(const struct hpi_hsubsys *ph_subsys,
1404− u32 h_outstream);
1265+u16 hpi_outstream_group_reset(u32 h_outstream);
14051266
1406−/*////////// */
1407−/* IN_STREAM */
1408−u16 hpi_instream_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index,
1409− u16 instream_index, u32 *ph_instream);
1267+/************/
1268+/* InStream */
1269+/************/
1270+u16 hpi_instream_open(u16 adapter_index, u16 instream_index,
1271+ u32 *ph_instream);
14101272
1411−u16 hpi_instream_close(const struct hpi_hsubsys *ph_subsys, u32 h_instream);
1273+u16 hpi_instream_close(u32 h_instream);
14121274
1413−u16 hpi_instream_query_format(const struct hpi_hsubsys *ph_subsys,
1414− u32 h_instream, const struct hpi_format *p_format);
1275+u16 hpi_instream_query_format(u32 h_instream,
1276+ const struct hpi_format *p_format);
14151277
1416−u16 hpi_instream_set_format(const struct hpi_hsubsys *ph_subsys,
1417− u32 h_instream, const struct hpi_format *p_format);
1278+u16 hpi_instream_set_format(u32 h_instream,
1279+ const struct hpi_format *p_format);
14181280
1419−u16 hpi_instream_read_buf(const struct hpi_hsubsys *ph_subsys, u32 h_instream,
1420− u8 *pb_read_buf, u32 bytes_to_read);
1281+u16 hpi_instream_read_buf(u32 h_instream, u8 *pb_read_buf, u32 bytes_to_read);
14211282
1422−u16 hpi_instream_start(const struct hpi_hsubsys *ph_subsys, u32 h_instream);
1283+u16 hpi_instream_start(u32 h_instream);
14231284
1424−u16 hpi_instream_wait_start(const struct hpi_hsubsys *ph_subsys,
1425− u32 h_instream);
1285+u16 hpi_instream_wait_start(u32 h_instream);
14261286
1427−u16 hpi_instream_stop(const struct hpi_hsubsys *ph_subsys, u32 h_instream);
1287+u16 hpi_instream_stop(u32 h_instream);
14281288
1429−u16 hpi_instream_reset(const struct hpi_hsubsys *ph_subsys, u32 h_instream);
1289+u16 hpi_instream_reset(u32 h_instream);
14301290
1431−u16 hpi_instream_get_info_ex(const struct hpi_hsubsys *ph_subsys,
1432− u32 h_instream, u16 *pw_state, u32 *pbuffer_size, u32 *pdata_recorded,
1433− u32 *psamples_recorded, u32 *pauxiliary_data_recorded);
1291+u16 hpi_instream_get_info_ex(u32 h_instream, u16 *pw_state, u32 *pbuffer_size,
1292+ u32 *pdata_recorded, u32 *psamples_recorded,
1293+ u32 *pauxiliary_data_recorded);
14341294
1435−u16 hpi_instream_ancillary_reset(const struct hpi_hsubsys *ph_subsys,
1436− u32 h_instream, u16 bytes_per_frame, u16 mode, u16 alignment,
1437− u16 idle_bit);
1295+u16 hpi_instream_ancillary_reset(u32 h_instream, u16 bytes_per_frame,
1296+ u16 mode, u16 alignment, u16 idle_bit);
14381297
1439−u16 hpi_instream_ancillary_get_info(const struct hpi_hsubsys *ph_subsys,
1440− u32 h_instream, u32 *pframe_space);
1298+u16 hpi_instream_ancillary_get_info(u32 h_instream, u32 *pframe_space);
14411299
1442−u16 hpi_instream_ancillary_write(const struct hpi_hsubsys *ph_subsys,
1443− u32 h_instream, const struct hpi_anc_frame *p_anc_frame_buffer,
1300+u16 hpi_instream_ancillary_write(u32 h_instream,
1301+ const struct hpi_anc_frame *p_anc_frame_buffer,
14441302 u32 anc_frame_buffer_size_in_bytes,
14451303 u32 number_of_ancillary_frames_to_write);
14461304
1447−u16 hpi_instream_host_buffer_allocate(const struct hpi_hsubsys *ph_subsys,
1448− u32 h_instream, u32 size_in_bytes);
1305+u16 hpi_instream_host_buffer_allocate(u32 h_instream, u32 size_in_bytes);
14491306
1450−u16 hpi_instream_host_buffer_free(const struct hpi_hsubsys *ph_subsys,
1451− u32 h_instream);
1307+u16 hpi_instream_host_buffer_free(u32 h_instream);
14521308
1453−u16 hpi_instream_group_add(const struct hpi_hsubsys *ph_subsys,
1454− u32 h_instream, u32 h_stream);
1309+u16 hpi_instream_group_add(u32 h_instream, u32 h_stream);
14551310
1456−u16 hpi_instream_group_get_map(const struct hpi_hsubsys *ph_subsys,
1457− u32 h_instream, u32 *poutstream_map, u32 *pinstream_map);
1311+u16 hpi_instream_group_get_map(u32 h_instream, u32 *poutstream_map,
1312+ u32 *pinstream_map);
14581313
1459−u16 hpi_instream_group_reset(const struct hpi_hsubsys *ph_subsys,
1460− u32 h_instream);
1314+u16 hpi_instream_group_reset(u32 h_instream);
14611315
14621316 /*********/
1463−/* MIXER */
1317+/* Mixer */
14641318 /*********/
1465−u16 hpi_mixer_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index,
1466− u32 *ph_mixer);
1467−
1468−u16 hpi_mixer_close(const struct hpi_hsubsys *ph_subsys, u32 h_mixer);
1469−
1470−u16 hpi_mixer_get_control(const struct hpi_hsubsys *ph_subsys, u32 h_mixer,
1471− u16 src_node_type, u16 src_node_type_index, u16 dst_node_type,
1472− u16 dst_node_type_index, u16 control_type, u32 *ph_control);
1473−
1474−u16 hpi_mixer_get_control_by_index(const struct hpi_hsubsys *ph_subsys,
1475− u32 h_mixer, u16 control_index, u16 *pw_src_node_type,
1476− u16 *pw_src_node_index, u16 *pw_dst_node_type, u16 *pw_dst_node_index,
1477− u16 *pw_control_type, u32 *ph_control);
1478−
1479−u16 hpi_mixer_store(const struct hpi_hsubsys *ph_subsys, u32 h_mixer,
1480− enum HPI_MIXER_STORE_COMMAND command, u16 index);
1481−/*************************/
1482−/* mixer CONTROLS */
1483−/*************************/
1484−/*************************/
1485−/* volume control */
1486−/*************************/
1487−u16 hpi_volume_set_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control,
1488− short an_gain0_01dB[HPI_MAX_CHANNELS]
1319+u16 hpi_mixer_open(u16 adapter_index, u32 *ph_mixer);
1320+
1321+u16 hpi_mixer_close(u32 h_mixer);
1322+
1323+u16 hpi_mixer_get_control(u32 h_mixer, u16 src_node_type,
1324+ u16 src_node_type_index, u16 dst_node_type, u16 dst_node_type_index,
1325+ u16 control_type, u32 *ph_control);
1326+
1327+u16 hpi_mixer_get_control_by_index(u32 h_mixer, u16 control_index,
1328+ u16 *pw_src_node_type, u16 *pw_src_node_index, u16 *pw_dst_node_type,
1329+ u16 *pw_dst_node_index, u16 *pw_control_type, u32 *ph_control);
1330+
1331+u16 hpi_mixer_store(u32 h_mixer, enum HPI_MIXER_STORE_COMMAND command,
1332+ u16 index);
1333+/************/
1334+/* Controls */
1335+/************/
1336+/******************/
1337+/* Volume control */
1338+/******************/
1339+u16 hpi_volume_set_gain(u32 h_control, short an_gain0_01dB[HPI_MAX_CHANNELS]
14891340 );
14901341
1491−u16 hpi_volume_get_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control,
1342+u16 hpi_volume_get_gain(u32 h_control,
14921343 short an_gain0_01dB_out[HPI_MAX_CHANNELS]
14931344 );
14941345
1346+u16 hpi_volume_set_mute(u32 h_control, u32 mute);
1347+
1348+u16 hpi_volume_get_mute(u32 h_control, u32 *mute);
1349+
14951350 #define hpi_volume_get_range hpi_volume_query_range
1496−u16 hpi_volume_query_range(const struct hpi_hsubsys *ph_subsys, u32 h_control,
1497− short *min_gain_01dB, short *max_gain_01dB, short *step_gain_01dB);
1351+u16 hpi_volume_query_range(u32 h_control, short *min_gain_01dB,
1352+ short *max_gain_01dB, short *step_gain_01dB);
14981353
1499−u16 hpi_volume_query_channels(const struct hpi_hsubsys *ph_subsys,
1500− const u32 h_volume, u32 *p_channels);
1354+u16 hpi_volume_query_channels(const u32 h_volume, u32 *p_channels);
15011355
1502−u16 hpi_volume_auto_fade(const struct hpi_hsubsys *ph_subsys, u32 h_control,
1356+u16 hpi_volume_auto_fade(u32 h_control,
15031357 short an_stop_gain0_01dB[HPI_MAX_CHANNELS], u32 duration_ms);
15041358
1505−u16 hpi_volume_auto_fade_profile(const struct hpi_hsubsys *ph_subsys,
1506− u32 h_control, short an_stop_gain0_01dB[HPI_MAX_CHANNELS],
1507− u32 duration_ms, u16 profile);
1359+u16 hpi_volume_auto_fade_profile(u32 h_control,
1360+ short an_stop_gain0_01dB[HPI_MAX_CHANNELS], u32 duration_ms,
1361+ u16 profile);
15081362
1509−/*************************/
1510−/* level control */
1511−/*************************/
1512−u16 hpi_level_query_range(const struct hpi_hsubsys *ph_subsys, u32 h_control,
1513− short *min_gain_01dB, short *max_gain_01dB, short *step_gain_01dB);
1363+/*****************/
1364+/* Level control */
1365+/*****************/
1366+u16 hpi_level_query_range(u32 h_control, short *min_gain_01dB,
1367+ short *max_gain_01dB, short *step_gain_01dB);
15141368
1515−u16 hpi_level_set_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control,
1516− short an_gain0_01dB[HPI_MAX_CHANNELS]
1369+u16 hpi_level_set_gain(u32 h_control, short an_gain0_01dB[HPI_MAX_CHANNELS]
15171370 );
15181371
1519−u16 hpi_level_get_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control,
1372+u16 hpi_level_get_gain(u32 h_control,
15201373 short an_gain0_01dB_out[HPI_MAX_CHANNELS]
15211374 );
15221375
1523−/*************************/
1524−/* meter control */
1525−/*************************/
1526−u16 hpi_meter_query_channels(const struct hpi_hsubsys *ph_subsys,
1527− const u32 h_meter, u32 *p_channels);
1376+/*****************/
1377+/* Meter control */
1378+/*****************/
1379+u16 hpi_meter_query_channels(const u32 h_meter, u32 *p_channels);
15281380
1529−u16 hpi_meter_get_peak(const struct hpi_hsubsys *ph_subsys, u32 h_control,
1381+u16 hpi_meter_get_peak(u32 h_control,
15301382 short an_peak0_01dB_out[HPI_MAX_CHANNELS]
15311383 );
15321384
1533−u16 hpi_meter_get_rms(const struct hpi_hsubsys *ph_subsys, u32 h_control,
1534− short an_peak0_01dB_out[HPI_MAX_CHANNELS]
1385+u16 hpi_meter_get_rms(u32 h_control, short an_peak0_01dB_out[HPI_MAX_CHANNELS]
15351386 );
15361387
1537−u16 hpi_meter_set_peak_ballistics(const struct hpi_hsubsys *ph_subsys,
1538− u32 h_control, u16 attack, u16 decay);
1388+u16 hpi_meter_set_peak_ballistics(u32 h_control, u16 attack, u16 decay);
15391389
1540−u16 hpi_meter_set_rms_ballistics(const struct hpi_hsubsys *ph_subsys,
1541− u32 h_control, u16 attack, u16 decay);
1390+u16 hpi_meter_set_rms_ballistics(u32 h_control, u16 attack, u16 decay);
15421391
1543−u16 hpi_meter_get_peak_ballistics(const struct hpi_hsubsys *ph_subsys,
1544− u32 h_control, u16 *attack, u16 *decay);
1392+u16 hpi_meter_get_peak_ballistics(u32 h_control, u16 *attack, u16 *decay);
15451393
1546−u16 hpi_meter_get_rms_ballistics(const struct hpi_hsubsys *ph_subsys,
1547− u32 h_control, u16 *attack, u16 *decay);
1394+u16 hpi_meter_get_rms_ballistics(u32 h_control, u16 *attack, u16 *decay);
15481395
1549−/*************************/
1550−/* channel mode control */
1551−/*************************/
1552−u16 hpi_channel_mode_query_mode(const struct hpi_hsubsys *ph_subsys,
1553− const u32 h_mode, const u32 index, u16 *pw_mode);
1396+/************************/
1397+/* ChannelMode control */
1398+/************************/
1399+u16 hpi_channel_mode_query_mode(const u32 h_mode, const u32 index,
1400+ u16 *pw_mode);
15541401
1555−u16 hpi_channel_mode_set(const struct hpi_hsubsys *ph_subsys, u32 h_control,
1556− u16 mode);
1402+u16 hpi_channel_mode_set(u32 h_control, u16 mode);
15571403
1558−u16 hpi_channel_mode_get(const struct hpi_hsubsys *ph_subsys, u32 h_control,
1559− u16 *mode);
1404+u16 hpi_channel_mode_get(u32 h_control, u16 *mode);
15601405
1561−/*************************/
1562−/* Tuner control */
1563−/*************************/
1564−u16 hpi_tuner_query_band(const struct hpi_hsubsys *ph_subsys,
1565− const u32 h_tuner, const u32 index, u16 *pw_band);
1406+/*****************/
1407+/* Tuner control */
1408+/*****************/
1409+u16 hpi_tuner_query_band(const u32 h_tuner, const u32 index, u16 *pw_band);
15661410
1567−u16 hpi_tuner_set_band(const struct hpi_hsubsys *ph_subsys, u32 h_control,
1568− u16 band);
1411+u16 hpi_tuner_set_band(u32 h_control, u16 band);
15691412
1570−u16 hpi_tuner_get_band(const struct hpi_hsubsys *ph_subsys, u32 h_control,
1571− u16 *pw_band);
1413+u16 hpi_tuner_get_band(u32 h_control, u16 *pw_band);
15721414
1573−u16 hpi_tuner_query_frequency(const struct hpi_hsubsys *ph_subsys,
1574− const u32 h_tuner, const u32 index, const u16 band, u32 *pfreq);
1415+u16 hpi_tuner_query_frequency(const u32 h_tuner, const u32 index,
1416+ const u16 band, u32 *pfreq);
15751417
1576−u16 hpi_tuner_set_frequency(const struct hpi_hsubsys *ph_subsys,
1577− u32 h_control, u32 freq_ink_hz);
1418+u16 hpi_tuner_set_frequency(u32 h_control, u32 freq_ink_hz);
15781419
1579−u16 hpi_tuner_get_frequency(const struct hpi_hsubsys *ph_subsys,
1580− u32 h_control, u32 *pw_freq_ink_hz);
1420+u16 hpi_tuner_get_frequency(u32 h_control, u32 *pw_freq_ink_hz);
15811421
1582−u16 hpi_tuner_getRF_level(const struct hpi_hsubsys *ph_subsys, u32 h_control,
1583− short *pw_level);
1422+u16 hpi_tuner_get_rf_level(u32 h_control, short *pw_level);
15841423
1585−u16 hpi_tuner_get_rawRF_level(const struct hpi_hsubsys *ph_subsys,
1586− u32 h_control, short *pw_level);
1424+u16 hpi_tuner_get_raw_rf_level(u32 h_control, short *pw_level);
15871425
1588−u16 hpi_tuner_query_gain(const struct hpi_hsubsys *ph_subsys,
1589− const u32 h_tuner, const u32 index, u16 *pw_gain);
1426+u16 hpi_tuner_query_gain(const u32 h_tuner, const u32 index, u16 *pw_gain);
15901427
1591−u16 hpi_tuner_set_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control,
1592− short gain);
1428+u16 hpi_tuner_set_gain(u32 h_control, short gain);
15931429
1594−u16 hpi_tuner_get_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control,
1595− short *pn_gain);
1430+u16 hpi_tuner_get_gain(u32 h_control, short *pn_gain);
15961431
1597−u16 hpi_tuner_get_status(const struct hpi_hsubsys *ph_subsys, u32 h_control,
1598− u16 *pw_status_mask, u16 *pw_status);
1432+u16 hpi_tuner_get_status(u32 h_control, u16 *pw_status_mask, u16 *pw_status);
15991433
1600−u16 hpi_tuner_set_mode(const struct hpi_hsubsys *ph_subsys, u32 h_control,
1601− u32 mode, u32 value);
1434+u16 hpi_tuner_set_mode(u32 h_control, u32 mode, u32 value);
16021435
1603−u16 hpi_tuner_get_mode(const struct hpi_hsubsys *ph_subsys, u32 h_control,
1604− u32 mode, u32 *pn_value);
1436+u16 hpi_tuner_get_mode(u32 h_control, u32 mode, u32 *pn_value);
16051437
1606−u16 hpi_tuner_getRDS(const struct hpi_hsubsys *ph_subsys, u32 h_control,
1607− char *p_rds_data);
1438+u16 hpi_tuner_get_rds(u32 h_control, char *p_rds_data);
16081439
1609−u16 hpi_tuner_query_deemphasis(const struct hpi_hsubsys *ph_subsys,
1610− const u32 h_tuner, const u32 index, const u16 band, u32 *pdeemphasis);
1440+u16 hpi_tuner_query_deemphasis(const u32 h_tuner, const u32 index,
1441+ const u16 band, u32 *pdeemphasis);
16111442
1612−u16 hpi_tuner_set_deemphasis(const struct hpi_hsubsys *ph_subsys,
1613− u32 h_control, u32 deemphasis);
1614−u16 hpi_tuner_get_deemphasis(const struct hpi_hsubsys *ph_subsys,
1615− u32 h_control, u32 *pdeemphasis);
1443+u16 hpi_tuner_set_deemphasis(u32 h_control, u32 deemphasis);
1444+u16 hpi_tuner_get_deemphasis(u32 h_control, u32 *pdeemphasis);
16161445
1617−u16 hpi_tuner_query_program(const struct hpi_hsubsys *ph_subsys,
1618− const u32 h_tuner, u32 *pbitmap_program);
1446+u16 hpi_tuner_query_program(const u32 h_tuner, u32 *pbitmap_program);
16191447
1620−u16 hpi_tuner_set_program(const struct hpi_hsubsys *ph_subsys, u32 h_control,
1621− u32 program);
1448+u16 hpi_tuner_set_program(u32 h_control, u32 program);
16221449
1623−u16 hpi_tuner_get_program(const struct hpi_hsubsys *ph_subsys, u32 h_control,
1624− u32 *pprogram);
1450+u16 hpi_tuner_get_program(u32 h_control, u32 *pprogram);
16251451
1626−u16 hpi_tuner_get_hd_radio_dsp_version(const struct hpi_hsubsys *ph_subsys,
1627− u32 h_control, char *psz_dsp_version, const u32 string_size);
1452+u16 hpi_tuner_get_hd_radio_dsp_version(u32 h_control, char *psz_dsp_version,
1453+ const u32 string_size);
16281454
1629−u16 hpi_tuner_get_hd_radio_sdk_version(const struct hpi_hsubsys *ph_subsys,
1630− u32 h_control, char *psz_sdk_version, const u32 string_size);
1455+u16 hpi_tuner_get_hd_radio_sdk_version(u32 h_control, char *psz_sdk_version,
1456+ const u32 string_size);
16311457
1632−u16 hpi_tuner_get_hd_radio_signal_quality(const struct hpi_hsubsys *ph_subsys,
1633− u32 h_control, u32 *pquality);
1458+u16 hpi_tuner_get_hd_radio_signal_quality(u32 h_control, u32 *pquality);
16341459
1635−u16 hpi_tuner_get_hd_radio_signal_blend(const struct hpi_hsubsys *ph_subsys,
1636− u32 h_control, u32 *pblend);
1460+u16 hpi_tuner_get_hd_radio_signal_blend(u32 h_control, u32 *pblend);
16371461
1638−u16 hpi_tuner_set_hd_radio_signal_blend(const struct hpi_hsubsys *ph_subsys,
1639− u32 h_control, const u32 blend);
1462+u16 hpi_tuner_set_hd_radio_signal_blend(u32 h_control, const u32 blend);
16401463
1641−/****************************/
1642−/* PADs control */
1643−/****************************/
1464+/***************/
1465+/* PAD control */
1466+/***************/
16441467
1645−u16 HPI_PAD__get_channel_name(const struct hpi_hsubsys *ph_subsys,
1646− u32 h_control, char *psz_string, const u32 string_length);
1468+u16 hpi_pad_get_channel_name(u32 h_control, char *psz_string,
1469+ const u32 string_length);
16471470
1648−u16 HPI_PAD__get_artist(const struct hpi_hsubsys *ph_subsys, u32 h_control,
1649− char *psz_string, const u32 string_length);
1471+u16 hpi_pad_get_artist(u32 h_control, char *psz_string,
1472+ const u32 string_length);
16501473
1651−u16 HPI_PAD__get_title(const struct hpi_hsubsys *ph_subsys, u32 h_control,
1652− char *psz_string, const u32 string_length);
1474+u16 hpi_pad_get_title(u32 h_control, char *psz_string,
1475+ const u32 string_length);
16531476
1654−u16 HPI_PAD__get_comment(const struct hpi_hsubsys *ph_subsys, u32 h_control,
1655− char *psz_string, const u32 string_length);
1477+u16 hpi_pad_get_comment(u32 h_control, char *psz_string,
1478+ const u32 string_length);
16561479
1657−u16 HPI_PAD__get_program_type(const struct hpi_hsubsys *ph_subsys,
1658− u32 h_control, u32 *ppTY);
1480+u16 hpi_pad_get_program_type(u32 h_control, u32 *ppTY);
16591481
1660−u16 HPI_PAD__get_rdsPI(const struct hpi_hsubsys *ph_subsys, u32 h_control,
1661− u32 *ppI);
1482+u16 hpi_pad_get_rdsPI(u32 h_control, u32 *ppI);
16621483
1663−u16 HPI_PAD__get_program_type_string(const struct hpi_hsubsys *ph_subsys,
1664− u32 h_control, const u32 data_type, const u32 pTY, char *psz_string,
1665− const u32 string_length);
1484+u16 hpi_pad_get_program_type_string(u32 h_control, const u32 data_type,
1485+ const u32 pTY, char *psz_string, const u32 string_length);
16661486
16671487 /****************************/
16681488 /* AES/EBU Receiver control */
16691489 /****************************/
1670−u16 HPI_AESEBU__receiver_query_format(const struct hpi_hsubsys *ph_subsys,
1671− const u32 h_aes_rx, const u32 index, u16 *pw_format);
1490+u16 hpi_aesebu_receiver_query_format(const u32 h_aes_rx, const u32 index,
1491+ u16 *pw_format);
16721492
1673−u16 HPI_AESEBU__receiver_set_format(const struct hpi_hsubsys *ph_subsys,
1674− u32 h_control, u16 source);
1493+u16 hpi_aesebu_receiver_set_format(u32 h_control, u16 source);
16751494
1676−u16 HPI_AESEBU__receiver_get_format(const struct hpi_hsubsys *ph_subsys,
1677− u32 h_control, u16 *pw_source);
1495+u16 hpi_aesebu_receiver_get_format(u32 h_control, u16 *pw_source);
16781496
1679−u16 HPI_AESEBU__receiver_get_sample_rate(const struct hpi_hsubsys *ph_subsys,
1680− u32 h_control, u32 *psample_rate);
1497+u16 hpi_aesebu_receiver_get_sample_rate(u32 h_control, u32 *psample_rate);
16811498
1682−u16 HPI_AESEBU__receiver_get_user_data(const struct hpi_hsubsys *ph_subsys,
1683− u32 h_control, u16 index, u16 *pw_data);
1499+u16 hpi_aesebu_receiver_get_user_data(u32 h_control, u16 index, u16 *pw_data);
16841500
1685−u16 HPI_AESEBU__receiver_get_channel_status(const struct hpi_hsubsys
1686− *ph_subsys, u32 h_control, u16 index, u16 *pw_data);
1501+u16 hpi_aesebu_receiver_get_channel_status(u32 h_control, u16 index,
1502+ u16 *pw_data);
16871503
1688−u16 HPI_AESEBU__receiver_get_error_status(const struct hpi_hsubsys *ph_subsys,
1689− u32 h_control, u16 *pw_error_data);
1504+u16 hpi_aesebu_receiver_get_error_status(u32 h_control, u16 *pw_error_data);
16901505
16911506 /*******************************/
16921507 /* AES/EBU Transmitter control */
16931508 /*******************************/
1694−u16 HPI_AESEBU__transmitter_set_sample_rate(const struct hpi_hsubsys
1695− *ph_subsys, u32 h_control, u32 sample_rate);
1509+u16 hpi_aesebu_transmitter_set_sample_rate(u32 h_control, u32 sample_rate);
16961510
1697−u16 HPI_AESEBU__transmitter_set_user_data(const struct hpi_hsubsys *ph_subsys,
1698− u32 h_control, u16 index, u16 data);
1511+u16 hpi_aesebu_transmitter_set_user_data(u32 h_control, u16 index, u16 data);
16991512
1700−u16 HPI_AESEBU__transmitter_set_channel_status(const struct hpi_hsubsys
1701− *ph_subsys, u32 h_control, u16 index, u16 data);
1513+u16 hpi_aesebu_transmitter_set_channel_status(u32 h_control, u16 index,
1514+ u16 data);
17021515
1703−u16 HPI_AESEBU__transmitter_get_channel_status(const struct hpi_hsubsys
1704− *ph_subsys, u32 h_control, u16 index, u16 *pw_data);
1516+u16 hpi_aesebu_transmitter_get_channel_status(u32 h_control, u16 index,
1517+ u16 *pw_data);
17051518
1706−u16 HPI_AESEBU__transmitter_query_format(const struct hpi_hsubsys *ph_subsys,
1707− const u32 h_aes_tx, const u32 index, u16 *pw_format);
1519+u16 hpi_aesebu_transmitter_query_format(const u32 h_aes_tx, const u32 index,
1520+ u16 *pw_format);
17081521
1709−u16 HPI_AESEBU__transmitter_set_format(const struct hpi_hsubsys *ph_subsys,
1710− u32 h_control, u16 output_format);
1522+u16 hpi_aesebu_transmitter_set_format(u32 h_control, u16 output_format);
17111523
1712−u16 HPI_AESEBU__transmitter_get_format(const struct hpi_hsubsys *ph_subsys,
1713− u32 h_control, u16 *pw_output_format);
1524+u16 hpi_aesebu_transmitter_get_format(u32 h_control, u16 *pw_output_format);
17141525
17151526 /***********************/
1716−/* multiplexer control */
1527+/* Multiplexer control */
17171528 /***********************/
1718−u16 hpi_multiplexer_set_source(const struct hpi_hsubsys *ph_subsys,
1719− u32 h_control, u16 source_node_type, u16 source_node_index);
1720−
1721−u16 hpi_multiplexer_get_source(const struct hpi_hsubsys *ph_subsys,
1722− u32 h_control, u16 *source_node_type, u16 *source_node_index);
1529+u16 hpi_multiplexer_set_source(u32 h_control, u16 source_node_type,
1530+ u16 source_node_index);
17231531
1724−u16 hpi_multiplexer_query_source(const struct hpi_hsubsys *ph_subsys,
1725− u32 h_control, u16 index, u16 *source_node_type,
1532+u16 hpi_multiplexer_get_source(u32 h_control, u16 *source_node_type,
17261533 u16 *source_node_index);
17271534
1535+u16 hpi_multiplexer_query_source(u32 h_control, u16 index,
1536+ u16 *source_node_type, u16 *source_node_index);
1537+
17281538 /***************/
1729−/* VOX control */
1539+/* Vox control */
17301540 /***************/
1731−u16 hpi_vox_set_threshold(const struct hpi_hsubsys *ph_subsys, u32 h_control,
1732− short an_gain0_01dB);
1541+u16 hpi_vox_set_threshold(u32 h_control, short an_gain0_01dB);
17331542
1734−u16 hpi_vox_get_threshold(const struct hpi_hsubsys *ph_subsys, u32 h_control,
1735− short *an_gain0_01dB);
1543+u16 hpi_vox_get_threshold(u32 h_control, short *an_gain0_01dB);
17361544
17371545 /*********************/
17381546 /* Bitstream control */
17391547 /*********************/
1740−u16 hpi_bitstream_set_clock_edge(const struct hpi_hsubsys *ph_subsys,
1741− u32 h_control, u16 edge_type);
1548+u16 hpi_bitstream_set_clock_edge(u32 h_control, u16 edge_type);
17421549
1743−u16 hpi_bitstream_set_data_polarity(const struct hpi_hsubsys *ph_subsys,
1744− u32 h_control, u16 polarity);
1550+u16 hpi_bitstream_set_data_polarity(u32 h_control, u16 polarity);
17451551
1746−u16 hpi_bitstream_get_activity(const struct hpi_hsubsys *ph_subsys,
1747− u32 h_control, u16 *pw_clk_activity, u16 *pw_data_activity);
1552+u16 hpi_bitstream_get_activity(u32 h_control, u16 *pw_clk_activity,
1553+ u16 *pw_data_activity);
17481554
17491555 /***********************/
17501556 /* SampleClock control */
17511557 /***********************/
17521558
1753−u16 hpi_sample_clock_query_source(const struct hpi_hsubsys *ph_subsys,
1754− const u32 h_clock, const u32 index, u16 *pw_source);
1559+u16 hpi_sample_clock_query_source(const u32 h_clock, const u32 index,
1560+ u16 *pw_source);
17551561
1756−u16 hpi_sample_clock_set_source(const struct hpi_hsubsys *ph_subsys,
1757− u32 h_control, u16 source);
1562+u16 hpi_sample_clock_set_source(u32 h_control, u16 source);
17581563
1759−u16 hpi_sample_clock_get_source(const struct hpi_hsubsys *ph_subsys,
1760− u32 h_control, u16 *pw_source);
1564+u16 hpi_sample_clock_get_source(u32 h_control, u16 *pw_source);
17611565
1762−u16 hpi_sample_clock_query_source_index(const struct hpi_hsubsys *ph_subsys,
1763− const u32 h_clock, const u32 index, const u32 source,
1764− u16 *pw_source_index);
1566+u16 hpi_sample_clock_query_source_index(const u32 h_clock, const u32 index,
1567+ const u32 source, u16 *pw_source_index);
17651568
1766−u16 hpi_sample_clock_set_source_index(const struct hpi_hsubsys *ph_subsys,
1767− u32 h_control, u16 source_index);
1569+u16 hpi_sample_clock_set_source_index(u32 h_control, u16 source_index);
17681570
1769−u16 hpi_sample_clock_get_source_index(const struct hpi_hsubsys *ph_subsys,
1770− u32 h_control, u16 *pw_source_index);
1571+u16 hpi_sample_clock_get_source_index(u32 h_control, u16 *pw_source_index);
17711572
1772−u16 hpi_sample_clock_get_sample_rate(const struct hpi_hsubsys *ph_subsys,
1773− u32 h_control, u32 *psample_rate);
1573+u16 hpi_sample_clock_get_sample_rate(u32 h_control, u32 *psample_rate);
17741574
1775−u16 hpi_sample_clock_query_local_rate(const struct hpi_hsubsys *ph_subsys,
1776− const u32 h_clock, const u32 index, u32 *psource);
1575+u16 hpi_sample_clock_query_local_rate(const u32 h_clock, const u32 index,
1576+ u32 *psource);
17771577
1778−u16 hpi_sample_clock_set_local_rate(const struct hpi_hsubsys *ph_subsys,
1779− u32 h_control, u32 sample_rate);
1578+u16 hpi_sample_clock_set_local_rate(u32 h_control, u32 sample_rate);
17801579
1781−u16 hpi_sample_clock_get_local_rate(const struct hpi_hsubsys *ph_subsys,
1782− u32 h_control, u32 *psample_rate);
1580+u16 hpi_sample_clock_get_local_rate(u32 h_control, u32 *psample_rate);
17831581
1784−u16 hpi_sample_clock_set_auto(const struct hpi_hsubsys *ph_subsys,
1785− u32 h_control, u32 enable);
1582+u16 hpi_sample_clock_set_auto(u32 h_control, u32 enable);
17861583
1787−u16 hpi_sample_clock_get_auto(const struct hpi_hsubsys *ph_subsys,
1788− u32 h_control, u32 *penable);
1584+u16 hpi_sample_clock_get_auto(u32 h_control, u32 *penable);
17891585
1790−u16 hpi_sample_clock_set_local_rate_lock(const struct hpi_hsubsys *ph_subsys,
1791− u32 h_control, u32 lock);
1586+u16 hpi_sample_clock_set_local_rate_lock(u32 h_control, u32 lock);
17921587
1793−u16 hpi_sample_clock_get_local_rate_lock(const struct hpi_hsubsys *ph_subsys,
1794− u32 h_control, u32 *plock);
1588+u16 hpi_sample_clock_get_local_rate_lock(u32 h_control, u32 *plock);
17951589
17961590 /***********************/
17971591 /* Microphone control */
17981592 /***********************/
1799−u16 hpi_microphone_set_phantom_power(const struct hpi_hsubsys *ph_subsys,
1800− u32 h_control, u16 on_off);
1593+u16 hpi_microphone_set_phantom_power(u32 h_control, u16 on_off);
18011594
1802−u16 hpi_microphone_get_phantom_power(const struct hpi_hsubsys *ph_subsys,
1803− u32 h_control, u16 *pw_on_off);
1595+u16 hpi_microphone_get_phantom_power(u32 h_control, u16 *pw_on_off);
18041596
1805−/*******************************
1806− Parametric Equalizer control
1807−*******************************/
1808−u16 hpi_parametricEQ__get_info(const struct hpi_hsubsys *ph_subsys,
1809− u32 h_control, u16 *pw_number_of_bands, u16 *pw_enabled);
1597+/********************************/
1598+/* Parametric Equalizer control */
1599+/********************************/
1600+u16 hpi_parametric_eq_get_info(u32 h_control, u16 *pw_number_of_bands,
1601+ u16 *pw_enabled);
18101602
1811−u16 hpi_parametricEQ__set_state(const struct hpi_hsubsys *ph_subsys,
1812− u32 h_control, u16 on_off);
1603+u16 hpi_parametric_eq_set_state(u32 h_control, u16 on_off);
18131604
1814−u16 hpi_parametricEQ__set_band(const struct hpi_hsubsys *ph_subsys,
1815− u32 h_control, u16 index, u16 type, u32 frequency_hz, short q100,
1816− short gain0_01dB);
1605+u16 hpi_parametric_eq_set_band(u32 h_control, u16 index, u16 type,
1606+ u32 frequency_hz, short q100, short gain0_01dB);
18171607
1818−u16 hpi_parametricEQ__get_band(const struct hpi_hsubsys *ph_subsys,
1819− u32 h_control, u16 index, u16 *pn_type, u32 *pfrequency_hz,
1820− short *pnQ100, short *pn_gain0_01dB);
1608+u16 hpi_parametric_eq_get_band(u32 h_control, u16 index, u16 *pn_type,
1609+ u32 *pfrequency_hz, short *pnQ100, short *pn_gain0_01dB);
18211610
1822−u16 hpi_parametricEQ__get_coeffs(const struct hpi_hsubsys *ph_subsys,
1823− u32 h_control, u16 index, short coeffs[5]
1611+u16 hpi_parametric_eq_get_coeffs(u32 h_control, u16 index, short coeffs[5]
18241612 );
18251613
1826−/*******************************
1827− Compressor Expander control
1828−*******************************/
1829−
1830−u16 hpi_compander_set_enable(const struct hpi_hsubsys *ph_subsys,
1831− u32 h_control, u32 on);
1832−
1833−u16 hpi_compander_get_enable(const struct hpi_hsubsys *ph_subsys,
1834− u32 h_control, u32 *pon);
1835−
1836−u16 hpi_compander_set_makeup_gain(const struct hpi_hsubsys *ph_subsys,
1837− u32 h_control, short makeup_gain0_01dB);
1838−
1839−u16 hpi_compander_get_makeup_gain(const struct hpi_hsubsys *ph_subsys,
1840− u32 h_control, short *pn_makeup_gain0_01dB);
1841−
1842−u16 hpi_compander_set_attack_time_constant(const struct hpi_hsubsys
1843− *ph_subsys, u32 h_control, u32 index, u32 attack);
1844−
1845−u16 hpi_compander_get_attack_time_constant(const struct hpi_hsubsys
1846− *ph_subsys, u32 h_control, u32 index, u32 *pw_attack);
1847−
1848−u16 hpi_compander_set_decay_time_constant(const struct hpi_hsubsys *ph_subsys,
1849− u32 h_control, u32 index, u32 decay);
1850−
1851−u16 hpi_compander_get_decay_time_constant(const struct hpi_hsubsys *ph_subsys,
1852− u32 h_control, u32 index, u32 *pw_decay);
1853−
1854−u16 hpi_compander_set_threshold(const struct hpi_hsubsys *ph_subsys,
1855− u32 h_control, u32 index, short threshold0_01dB);
1856−
1857−u16 hpi_compander_get_threshold(const struct hpi_hsubsys *ph_subsys,
1858− u32 h_control, u32 index, short *pn_threshold0_01dB);
1859−
1860−u16 hpi_compander_set_ratio(const struct hpi_hsubsys *ph_subsys,
1861− u32 h_control, u32 index, u32 ratio100);
1862−
1863−u16 hpi_compander_get_ratio(const struct hpi_hsubsys *ph_subsys,
1864− u32 h_control, u32 index, u32 *pw_ratio100);
1865−
1866−/*******************************
1867− Cobranet HMI control
1868−*******************************/
1869−u16 hpi_cobranet_hmi_write(const struct hpi_hsubsys *ph_subsys, u32 h_control,
1870− u32 hmi_address, u32 byte_count, u8 *pb_data);
1871−
1872−u16 hpi_cobranet_hmi_read(const struct hpi_hsubsys *ph_subsys, u32 h_control,
1873− u32 hmi_address, u32 max_byte_count, u32 *pbyte_count, u8 *pb_data);
1874−
1875−u16 hpi_cobranet_hmi_get_status(const struct hpi_hsubsys *ph_subsys,
1876− u32 h_control, u32 *pstatus, u32 *preadable_size,
1877− u32 *pwriteable_size);
1878−
1879−/*Read the current IP address
1880−*/
1881−u16 hpi_cobranet_getI_paddress(const struct hpi_hsubsys *ph_subsys,
1882− u32 h_control, u32 *pi_paddress);
1883−
1884−/* Write the current IP address
1885−*/
1886−u16 hpi_cobranet_setI_paddress(const struct hpi_hsubsys *ph_subsys,
1887− u32 h_control, u32 i_paddress);
1888−
1889−/* Read the static IP address
1890−*/
1891−u16 hpi_cobranet_get_staticI_paddress(const struct hpi_hsubsys *ph_subsys,
1892− u32 h_control, u32 *pi_paddress);
1614+/*******************************/
1615+/* Compressor Expander control */
1616+/*******************************/
18931617
1894−/* Write the static IP address
1895−*/
1896−u16 hpi_cobranet_set_staticI_paddress(const struct hpi_hsubsys *ph_subsys,
1897− u32 h_control, u32 i_paddress);
1618+u16 hpi_compander_set_enable(u32 h_control, u32 on);
18981619
1899−/* Read the MAC address
1900−*/
1901−u16 hpi_cobranet_getMA_caddress(const struct hpi_hsubsys *ph_subsys,
1902− u32 h_control, u32 *pmAC_MS_bs, u32 *pmAC_LS_bs);
1620+u16 hpi_compander_get_enable(u32 h_control, u32 *pon);
19031621
1904−/*******************************
1905− Tone Detector control
1906−*******************************/
1907−u16 hpi_tone_detector_get_state(const struct hpi_hsubsys *ph_subsys, u32 hC,
1908− u32 *state);
1622+u16 hpi_compander_set_makeup_gain(u32 h_control, short makeup_gain0_01dB);
19091623
1910−u16 hpi_tone_detector_set_enable(const struct hpi_hsubsys *ph_subsys, u32 hC,
1911− u32 enable);
1624+u16 hpi_compander_get_makeup_gain(u32 h_control, short *pn_makeup_gain0_01dB);
19121625
1913−u16 hpi_tone_detector_get_enable(const struct hpi_hsubsys *ph_subsys, u32 hC,
1914− u32 *enable);
1626+u16 hpi_compander_set_attack_time_constant(u32 h_control, u32 index,
1627+ u32 attack);
19151628
1916−u16 hpi_tone_detector_set_event_enable(const struct hpi_hsubsys *ph_subsys,
1917− u32 hC, u32 event_enable);
1629+u16 hpi_compander_get_attack_time_constant(u32 h_control, u32 index,
1630+ u32 *pw_attack);
19181631
1919−u16 hpi_tone_detector_get_event_enable(const struct hpi_hsubsys *ph_subsys,
1920− u32 hC, u32 *event_enable);
1632+u16 hpi_compander_set_decay_time_constant(u32 h_control, u32 index,
1633+ u32 decay);
19211634
1922−u16 hpi_tone_detector_set_threshold(const struct hpi_hsubsys *ph_subsys,
1923− u32 hC, int threshold);
1635+u16 hpi_compander_get_decay_time_constant(u32 h_control, u32 index,
1636+ u32 *pw_decay);
19241637
1925−u16 hpi_tone_detector_get_threshold(const struct hpi_hsubsys *ph_subsys,
1926− u32 hC, int *threshold);
1638+u16 hpi_compander_set_threshold(u32 h_control, u32 index,
1639+ short threshold0_01dB);
19271640
1928−u16 hpi_tone_detector_get_frequency(const struct hpi_hsubsys *ph_subsys,
1929− u32 hC, u32 index, u32 *frequency);
1641+u16 hpi_compander_get_threshold(u32 h_control, u32 index,
1642+ short *pn_threshold0_01dB);
19301643
1931−/*******************************
1932− Silence Detector control
1933−*******************************/
1934−u16 hpi_silence_detector_get_state(const struct hpi_hsubsys *ph_subsys,
1935− u32 hC, u32 *state);
1644+u16 hpi_compander_set_ratio(u32 h_control, u32 index, u32 ratio100);
19361645
1937−u16 hpi_silence_detector_set_enable(const struct hpi_hsubsys *ph_subsys,
1938− u32 hC, u32 enable);
1646+u16 hpi_compander_get_ratio(u32 h_control, u32 index, u32 *pw_ratio100);
19391647
1940−u16 hpi_silence_detector_get_enable(const struct hpi_hsubsys *ph_subsys,
1941− u32 hC, u32 *enable);
1648+/********************/
1649+/* Cobranet control */
1650+/********************/
1651+u16 hpi_cobranet_hmi_write(u32 h_control, u32 hmi_address, u32 byte_count,
1652+ u8 *pb_data);
19421653
1943−u16 hpi_silence_detector_set_event_enable(const struct hpi_hsubsys *ph_subsys,
1944− u32 hC, u32 event_enable);
1654+u16 hpi_cobranet_hmi_read(u32 h_control, u32 hmi_address, u32 max_byte_count,
1655+ u32 *pbyte_count, u8 *pb_data);
19451656
1946−u16 hpi_silence_detector_get_event_enable(const struct hpi_hsubsys *ph_subsys,
1947− u32 hC, u32 *event_enable);
1657+u16 hpi_cobranet_hmi_get_status(u32 h_control, u32 *pstatus,
1658+ u32 *preadable_size, u32 *pwriteable_size);
19481659
1949−u16 hpi_silence_detector_set_delay(const struct hpi_hsubsys *ph_subsys,
1950− u32 hC, u32 delay);
1660+u16 hpi_cobranet_get_ip_address(u32 h_control, u32 *pdw_ip_address);
19511661
1952−u16 hpi_silence_detector_get_delay(const struct hpi_hsubsys *ph_subsys,
1953− u32 hC, u32 *delay);
1662+u16 hpi_cobranet_set_ip_address(u32 h_control, u32 dw_ip_address);
19541663
1955−u16 hpi_silence_detector_set_threshold(const struct hpi_hsubsys *ph_subsys,
1956− u32 hC, int threshold);
1664+u16 hpi_cobranet_get_static_ip_address(u32 h_control, u32 *pdw_ip_address);
19571665
1958−u16 hpi_silence_detector_get_threshold(const struct hpi_hsubsys *ph_subsys,
1959− u32 hC, int *threshold);
1666+u16 hpi_cobranet_set_static_ip_address(u32 h_control, u32 dw_ip_address);
19601667
1961−/*******************************
1962− Universal control
1963−*******************************/
1964−u16 hpi_entity_find_next(struct hpi_entity *container_entity,
1965− enum e_entity_type type, enum e_entity_role role, int recursive_flag,
1966− struct hpi_entity **current_match);
1668+u16 hpi_cobranet_get_macaddress(u32 h_control, u32 *p_mac_msbs,
1669+ u32 *p_mac_lsbs);
19671670
1968−u16 hpi_entity_copy_value_from(struct hpi_entity *entity,
1969− enum e_entity_type type, size_t item_count, void *value_dst_p);
1671+/*************************/
1672+/* Tone Detector control */
1673+/*************************/
1674+u16 hpi_tone_detector_get_state(u32 hC, u32 *state);
19701675
1971−u16 hpi_entity_unpack(struct hpi_entity *entity, enum e_entity_type *type,
1972− size_t *items, enum e_entity_role *role, void **value);
1676+u16 hpi_tone_detector_set_enable(u32 hC, u32 enable);
19731677
1974−u16 hpi_entity_alloc_and_pack(const enum e_entity_type type,
1975− const size_t item_count, const enum e_entity_role role, void *value,
1976− struct hpi_entity **entity);
1678+u16 hpi_tone_detector_get_enable(u32 hC, u32 *enable);
19771679
1978−void hpi_entity_free(struct hpi_entity *entity);
1680+u16 hpi_tone_detector_set_event_enable(u32 hC, u32 event_enable);
19791681
1980−u16 hpi_universal_info(const struct hpi_hsubsys *ph_subsys, u32 hC,
1981− struct hpi_entity **info);
1682+u16 hpi_tone_detector_get_event_enable(u32 hC, u32 *event_enable);
19821683
1983−u16 hpi_universal_get(const struct hpi_hsubsys *ph_subsys, u32 hC,
1984− struct hpi_entity **value);
1684+u16 hpi_tone_detector_set_threshold(u32 hC, int threshold);
19851685
1986−u16 hpi_universal_set(const struct hpi_hsubsys *ph_subsys, u32 hC,
1987− struct hpi_entity *value);
1686+u16 hpi_tone_detector_get_threshold(u32 hC, int *threshold);
19881687
1989−/*/////////// */
1990−/* DSP CLOCK */
1991−/*/////////// */
1992−u16 hpi_clock_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index,
1993− u32 *ph_dsp_clock);
1688+u16 hpi_tone_detector_get_frequency(u32 hC, u32 index, u32 *frequency);
19941689
1995−u16 hpi_clock_set_time(const struct hpi_hsubsys *ph_subsys, u32 h_clock,
1996− u16 hour, u16 minute, u16 second, u16 milli_second);
1690+/****************************/
1691+/* Silence Detector control */
1692+/****************************/
1693+u16 hpi_silence_detector_get_state(u32 hC, u32 *state);
19971694
1998−u16 hpi_clock_get_time(const struct hpi_hsubsys *ph_subsys, u32 h_clock,
1999− u16 *pw_hour, u16 *pw_minute, u16 *pw_second, u16 *pw_milli_second);
1695+u16 hpi_silence_detector_set_enable(u32 hC, u32 enable);
20001696
2001−/*/////////// */
2002−/* PROFILE */
2003−/*/////////// */
2004−u16 hpi_profile_open_all(const struct hpi_hsubsys *ph_subsys,
2005− u16 adapter_index, u16 profile_index, u32 *ph_profile,
2006− u16 *pw_max_profiles);
1697+u16 hpi_silence_detector_get_enable(u32 hC, u32 *enable);
20071698
2008−u16 hpi_profile_get(const struct hpi_hsubsys *ph_subsys, u32 h_profile,
2009− u16 index, u16 *pw_seconds, u32 *pmicro_seconds, u32 *pcall_count,
2010− u32 *pmax_micro_seconds, u32 *pmin_micro_seconds);
1699+u16 hpi_silence_detector_set_event_enable(u32 hC, u32 event_enable);
20111700
2012−u16 hpi_profile_start_all(const struct hpi_hsubsys *ph_subsys, u32 h_profile);
1701+u16 hpi_silence_detector_get_event_enable(u32 hC, u32 *event_enable);
20131702
2014−u16 hpi_profile_stop_all(const struct hpi_hsubsys *ph_subsys, u32 h_profile);
1703+u16 hpi_silence_detector_set_delay(u32 hC, u32 delay);
20151704
2016−u16 hpi_profile_get_name(const struct hpi_hsubsys *ph_subsys, u32 h_profile,
2017− u16 index, char *sz_profile_name, u16 profile_name_length);
1705+u16 hpi_silence_detector_get_delay(u32 hC, u32 *delay);
20181706
2019−u16 hpi_profile_get_utilization(const struct hpi_hsubsys *ph_subsys,
2020− u32 h_profile, u32 *putilization);
1707+u16 hpi_silence_detector_set_threshold(u32 hC, int threshold);
20211708
2022−/*//////////////////// */
2023−/* UTILITY functions */
1709+u16 hpi_silence_detector_get_threshold(u32 hC, int *threshold);
1710+/*********************/
1711+/* Utility functions */
1712+/*********************/
20241713
20251714 u16 hpi_format_create(struct hpi_format *p_format, u16 channels, u16 format,
20261715 u32 sample_rate, u32 bit_rate, u32 attributes);
20271716
2028−/* Until it's verified, this function is for Windows OSs only */
2029−
2030−#endif /*_H_HPI_ */
2031−/*
2032−///////////////////////////////////////////////////////////////////////////////
2033−// See CVS for history. Last complete set in rev 1.146
2034−////////////////////////////////////////////////////////////////////////////////
2035−*/
1717+#endif /*_HPI_H_ */
sound/pci/asihpi/hpi6000.c+137−162
@@ -43,16 +43,17 @@ · 42 unmodified lines
4343 #define HPI_HIF_ERROR_MASK 0x4000
4444
4545 /* HPI6000 specific error codes */
46+#define HPI6000_ERROR_BASE 900 /* not actually used anywhere */
4647
47−#define HPI6000_ERROR_BASE 900
48+/* operational/messaging errors */
4849 #define HPI6000_ERROR_MSG_RESP_IDLE_TIMEOUT 901
49−#define HPI6000_ERROR_MSG_RESP_SEND_MSG_ACK 902
50+
5051 #define HPI6000_ERROR_MSG_RESP_GET_RESP_ACK 903
5152 #define HPI6000_ERROR_MSG_GET_ADR 904
5253 #define HPI6000_ERROR_RESP_GET_ADR 905
5354 #define HPI6000_ERROR_MSG_RESP_BLOCKWRITE32 906
5455 #define HPI6000_ERROR_MSG_RESP_BLOCKREAD32 907
55−#define HPI6000_ERROR_MSG_INVALID_DSP_INDEX 908
56+
5657 #define HPI6000_ERROR_CONTROL_CACHE_PARAMS 909
5758
5859 #define HPI6000_ERROR_SEND_DATA_IDLE_TIMEOUT 911
@@ -62,7 +63,6 @@ · 3 unmodified lines
6263 #define HPI6000_ERROR_SEND_DATA_CMD 915
6364 #define HPI6000_ERROR_SEND_DATA_WRITE 916
6465 #define HPI6000_ERROR_SEND_DATA_IDLECMD 917
65−#define HPI6000_ERROR_SEND_DATA_VERIFY 918
6666
6767 #define HPI6000_ERROR_GET_DATA_IDLE_TIMEOUT 921
6868 #define HPI6000_ERROR_GET_DATA_ACK 922
@@ -76,9 +76,8 @@ · 7 unmodified lines
7676
7777 #define HPI6000_ERROR_MSG_RESP_GETRESPCMD 961
7878 #define HPI6000_ERROR_MSG_RESP_IDLECMD 962
79−#define HPI6000_ERROR_MSG_RESP_BLOCKVERIFY32 963
8079
81−/* adapter init errors */
80+/* Initialisation/bootload errors */
8281 #define HPI6000_ERROR_UNHANDLED_SUBSYS_ID 930
8382
8483 /* can't access PCI2040 */
@@ -210,6 +209,8 @@ static void adapter_get_asserts(struct hpi_adapter_obj *pao, · 125 unmodified lines
210209 static short create_adapter_obj(struct hpi_adapter_obj *pao,
211210 u32 *pos_error_code);
212211
212+static void delete_adapter_obj(struct hpi_adapter_obj *pao);
213+
213214 /* local globals */
214215
215216 static u16 gw_pci_read_asserts; /* used to count PCI2040 errors */
@@ -217,17 +218,7 @@ static u16 gw_pci_write_asserts; /* used to count PCI2040 errors */ · 1 unmodified line
217218
218219 static void subsys_message(struct hpi_message *phm, struct hpi_response *phr)
219220 {
220−
221221 switch (phm->function) {
222− case HPI_SUBSYS_OPEN:
223− case HPI_SUBSYS_CLOSE:
224− case HPI_SUBSYS_GET_INFO:
225− case HPI_SUBSYS_DRIVER_UNLOAD:
226− case HPI_SUBSYS_DRIVER_LOAD:
227− case HPI_SUBSYS_FIND_ADAPTERS:
228− /* messages that should not get here */
229− phr->error = HPI_ERROR_UNIMPLEMENTED;
230− break;
231222 case HPI_SUBSYS_CREATE_ADAPTER:
232223 subsys_create_adapter(phm, phr);
233224 break;
@@ -243,7 +234,6 @@ static void subsys_message(struct hpi_message *phm, struct hpi_response *phr) · 9 unmodified lines
243234 static void control_message(struct hpi_adapter_obj *pao,
244235 struct hpi_message *phm, struct hpi_response *phr)
245236 {
246−
247237 switch (phm->function) {
248238 case HPI_CONTROL_GET_STATE:
249239 if (pao->has_control_cache) {
@@ -251,7 +241,13 @@ static void control_message(struct hpi_adapter_obj *pao, · 1 unmodified line
251241 err = hpi6000_update_control_cache(pao, phm);
252242
253243 if (err) {
254− phr->error = err;
244+ if (err >= HPI_ERROR_BACKEND_BASE) {
245+ phr->error =
246+ HPI_ERROR_CONTROL_CACHING;
247+ phr->specific_error = err;
248+ } else {
249+ phr->error = err;
250+ }
255251 break;
256252 }
257253
@@ -262,16 +258,15 @@ static void control_message(struct hpi_adapter_obj *pao, · 4 unmodified lines
262258 }
263259 hw_message(pao, phm, phr);
264260 break;
265− case HPI_CONTROL_GET_INFO:
266− hw_message(pao, phm, phr);
267− break;
268261 case HPI_CONTROL_SET_STATE:
269262 hw_message(pao, phm, phr);
270− hpi_sync_control_cache(((struct hpi_hw_obj *)pao->priv)->
271− p_cache, phm, phr);
263+ hpi_cmn_control_cache_sync_to_msg(((struct hpi_hw_obj *)pao->
264+ priv)->p_cache, phm, phr);
272265 break;
266+
267+ case HPI_CONTROL_GET_INFO:
273268 default:
274− phr->error = HPI_ERROR_INVALID_FUNC;
269+ hw_message(pao, phm, phr);
275270 break;
276271 }
277272 }
@@ -280,26 +275,12 @@ static void adapter_message(struct hpi_adapter_obj *pao, · 2 unmodified lines
280275 struct hpi_message *phm, struct hpi_response *phr)
281276 {
282277 switch (phm->function) {
283− case HPI_ADAPTER_GET_INFO:
284− hw_message(pao, phm, phr);
285− break;
286278 case HPI_ADAPTER_GET_ASSERT:
287279 adapter_get_asserts(pao, phm, phr);
288280 break;
289− case HPI_ADAPTER_OPEN:
290− case HPI_ADAPTER_CLOSE:
291− case HPI_ADAPTER_TEST_ASSERT:
292− case HPI_ADAPTER_SELFTEST:
293− case HPI_ADAPTER_GET_MODE:
294− case HPI_ADAPTER_SET_MODE:
295− case HPI_ADAPTER_FIND_OBJECT:
296− case HPI_ADAPTER_GET_PROPERTY:
297− case HPI_ADAPTER_SET_PROPERTY:
298− case HPI_ADAPTER_ENUM_PROPERTY:
299− hw_message(pao, phm, phr);
300− break;
281+
301282 default:
302− phr->error = HPI_ERROR_INVALID_FUNC;
283+ hw_message(pao, phm, phr);
303284 break;
304285 }
305286 }
@@ -311,7 +292,7 @@ static void outstream_message(struct hpi_adapter_obj *pao, · 5 unmodified lines
311292 case HPI_OSTREAM_HOSTBUFFER_ALLOC:
312293 case HPI_OSTREAM_HOSTBUFFER_FREE:
313294 /* Don't let these messages go to the HW function because
314− * they're called without allocating the spinlock.
295+ * they're called without locking the spinlock.
315296 * For the HPI6000 adapters the HW would return
316297 * HPI_ERROR_INVALID_FUNC anyway.
317298 */
@@ -331,7 +312,7 @@ static void instream_message(struct hpi_adapter_obj *pao, · 13 unmodified lines
331312 case HPI_ISTREAM_HOSTBUFFER_ALLOC:
332313 case HPI_ISTREAM_HOSTBUFFER_FREE:
333314 /* Don't let these messages go to the HW function because
334− * they're called without allocating the spinlock.
315+ * they're called without locking the spinlock.
335316 * For the HPI6000 adapters the HW would return
336317 * HPI_ERROR_INVALID_FUNC anyway.
337318 */
@@ -355,7 +336,7 @@ void HPI_6000(struct hpi_message *phm, struct hpi_response *phr) · 17 unmodified lines
355336 /* subsytem messages get executed by every HPI. */
356337 /* All other messages are ignored unless the adapter index matches */
357338 /* an adapter in the HPI */
358− HPI_DEBUG_LOG(DEBUG, "O %d,F %x\n", phm->object, phm->function);
339+ /*HPI_DEBUG_LOG(DEBUG, "O %d,F %x\n", phm->wObject, phm->wFunction); */
359340
360341 /* if Dsp has crashed then do not communicate with it any more */
361342 if (phm->object != HPI_OBJ_SUBSYSTEM) {
@@ -433,21 +414,13 @@ static void subsys_create_adapter(struct hpi_message *phm, · 71 unmodified lines
433414 struct hpi_adapter_obj ao;
434415 struct hpi_adapter_obj *pao;
435416 u32 os_error_code;
436− short error = 0;
417+ u16 err = 0;
437418 u32 dsp_index = 0;
438419
439420 HPI_DEBUG_LOG(VERBOSE, "subsys_create_adapter\n");
440421
441422 memset(&ao, 0, sizeof(ao));
442423
443− /* this HPI only creates adapters for TI/PCI2040 based devices */
444− if (phm->u.s.resource.bus_type != HPI_BUS_PCI)
445− return;
446− if (phm->u.s.resource.r.pci->vendor_id != HPI_PCI_VENDOR_ID_TI)
447− return;
448− if (phm->u.s.resource.r.pci->device_id != HPI_PCI_DEV_ID_PCI2040)
449− return;
450−
451424 ao.priv = kzalloc(sizeof(struct hpi_hw_obj), GFP_KERNEL);
452425 if (!ao.priv) {
453426 HPI_DEBUG_LOG(ERROR, "cant get mem for adapter object\n");
@@ -456,16 +429,19 @@ static void subsys_create_adapter(struct hpi_message *phm, · 2 unmodified lines
456429 }
457430
458431 /* create the adapter object based on the resource information */
459− /*? memcpy(&ao.Pci,&phm->u.s.Resource.r.Pci,sizeof(ao.Pci)); */
460432 ao.pci = *phm->u.s.resource.r.pci;
461433
462− error = create_adapter_obj(&ao, &os_error_code);
463− if (!error)
464− error = hpi_add_adapter(&ao);
465− if (error) {
434+ err = create_adapter_obj(&ao, &os_error_code);
435+ if (err) {
436+ delete_adapter_obj(&ao);
437+ if (err >= HPI_ERROR_BACKEND_BASE) {
438+ phr->error = HPI_ERROR_DSP_BOOTLOAD;
439+ phr->specific_error = err;
440+ } else {
441+ phr->error = err;
442+ }
443+
466444 phr->u.s.data = os_error_code;
467− kfree(ao.priv);
468− phr->error = error;
469445 return;
470446 }
471447 /* need to update paParentAdapter */
@@ -473,7 +449,7 @@ static void subsys_create_adapter(struct hpi_message *phm, · 1 unmodified line
473449 if (!pao) {
474450 /* We just added this adapter, why can't we find it!? */
475451 HPI_DEBUG_LOG(ERROR, "lost adapter after boot\n");
476− phr->error = 950;
452+ phr->error = HPI_ERROR_BAD_ADAPTER;
477453 return;
478454 }
479455
@@ -482,9 +458,8 @@ static void subsys_create_adapter(struct hpi_message *phm, · 2 unmodified lines
482458 phw->ado[dsp_index].pa_parent_adapter = pao;
483459 }
484460
485− phr->u.s.aw_adapter_list[ao.index] = ao.adapter_type;
461+ phr->u.s.adapter_type = ao.adapter_type;
486462 phr->u.s.adapter_index = ao.index;
487− phr->u.s.num_adapters++;
488463 phr->error = 0;
489464 }
490465
@@ -492,20 +467,13 @@ static void subsys_delete_adapter(struct hpi_message *phm, · 1 unmodified line
492467 struct hpi_response *phr)
493468 {
494469 struct hpi_adapter_obj *pao = NULL;
495− struct hpi_hw_obj *phw;
496470
497− pao = hpi_find_adapter(phm->adapter_index);
471+ pao = hpi_find_adapter(phm->obj_index);
498472 if (!pao)
499473 return;
500474
501− phw = (struct hpi_hw_obj *)pao->priv;
502−
503− if (pao->has_control_cache)
504− hpi_free_control_cache(phw->p_cache);
505−
475+ delete_adapter_obj(pao);
506476 hpi_delete_adapter(pao);
507− kfree(phw);
508−
509477 phr->error = 0;
510478 }
511479
@@ -519,9 +487,6 @@ static short create_adapter_obj(struct hpi_adapter_obj *pao, · 7 unmodified lines
519487 u32 control_cache_count = 0;
520488 struct hpi_hw_obj *phw = (struct hpi_hw_obj *)pao->priv;
521489
522− /* init error reporting */
523− pao->dsp_crashed = 0;
524−
525490 /* The PCI2040 has the following address map */
526491 /* BAR0 - 4K = HPI control and status registers on PCI2040 (HPI CSR) */
527492 /* BAR1 - 32K = HPI registers on DSP */
@@ -575,36 +540,36 @@ static short create_adapter_obj(struct hpi_adapter_obj *pao, · 47 unmodified lines
575540 /* get info about the adapter by asking the adapter */
576541 /* send a HPI_ADAPTER_GET_INFO message */
577542 {
578− struct hpi_message hM;
579− struct hpi_response hR0; /* response from DSP 0 */
580− struct hpi_response hR1; /* response from DSP 1 */
543+ struct hpi_message hm;
544+ struct hpi_response hr0; /* response from DSP 0 */
545+ struct hpi_response hr1; /* response from DSP 1 */
581546 u16 error = 0;
582547
583548 HPI_DEBUG_LOG(VERBOSE, "send ADAPTER_GET_INFO\n");
584− memset(&hM, 0, sizeof(hM));
585− hM.type = HPI_TYPE_MESSAGE;
586− hM.size = sizeof(struct hpi_message);
587− hM.object = HPI_OBJ_ADAPTER;
588− hM.function = HPI_ADAPTER_GET_INFO;
589− hM.adapter_index = 0;
590− memset(&hR0, 0, sizeof(hR0));
591− memset(&hR1, 0, sizeof(hR1));
592− hR0.size = sizeof(hR0);
593− hR1.size = sizeof(hR1);
594−
595− error = hpi6000_message_response_sequence(pao, 0, &hM, &hR0);
596− if (hR0.error) {
597− HPI_DEBUG_LOG(DEBUG, "message error %d\n", hR0.error);
598− return hR0.error;
549+ memset(&hm, 0, sizeof(hm));
550+ hm.type = HPI_TYPE_MESSAGE;
551+ hm.size = sizeof(struct hpi_message);
552+ hm.object = HPI_OBJ_ADAPTER;
553+ hm.function = HPI_ADAPTER_GET_INFO;
554+ hm.adapter_index = 0;
555+ memset(&hr0, 0, sizeof(hr0));
556+ memset(&hr1, 0, sizeof(hr1));
557+ hr0.size = sizeof(hr0);
558+ hr1.size = sizeof(hr1);
559+
560+ error = hpi6000_message_response_sequence(pao, 0, &hm, &hr0);
561+ if (hr0.error) {
562+ HPI_DEBUG_LOG(DEBUG, "message error %d\n", hr0.error);
563+ return hr0.error;
599564 }
600565 if (phw->num_dsp == 2) {
601− error = hpi6000_message_response_sequence(pao, 1, &hM,
602− &hR1);
566+ error = hpi6000_message_response_sequence(pao, 1, &hm,
567+ &hr1);
603568 if (error)
604569 return error;
605570 }
606− pao->adapter_type = hR0.u.a.adapter_type;
607− pao->index = hR0.u.a.adapter_index;
571+ pao->adapter_type = hr0.u.ax.info.adapter_type;
572+ pao->index = hr0.u.ax.info.adapter_index;
608573 }
609574
610575 memset(&phw->control_cache[0], 0,
@@ -618,22 +583,37 @@ static short create_adapter_obj(struct hpi_adapter_obj *pao, · 7 unmodified lines
618583 control_cache_count =
619584 hpi_read_word(&phw->ado[0],
620585 HPI_HIF_ADDR(control_cache_count));
621− pao->has_control_cache = 1;
622586
623587 phw->p_cache =
624588 hpi_alloc_control_cache(control_cache_count,
625− control_cache_size, (struct hpi_control_cache_info *)
589+ control_cache_size, (unsigned char *)
626590 &phw->control_cache[0]
627591 );
628− if (!phw->p_cache)
629− pao->has_control_cache = 0;
630− } else
631− pao->has_control_cache = 0;
592+ if (phw->p_cache)
593+ pao->has_control_cache = 1;
594+ }
632595
633596 HPI_DEBUG_LOG(DEBUG, "get adapter info ASI%04X index %d\n",
634597 pao->adapter_type, pao->index);
635598 pao->open = 0; /* upon creation the adapter is closed */
636− return 0;
599+
600+ if (phw->p_cache)
601+ phw->p_cache->adap_idx = pao->index;
602+
603+ return hpi_add_adapter(pao);
604+}
605+
606+static void delete_adapter_obj(struct hpi_adapter_obj *pao)
607+{
608+ struct hpi_hw_obj *phw = (struct hpi_hw_obj *)pao->priv;
609+
610+ if (pao->has_control_cache)
611+ hpi_free_control_cache(phw->p_cache);
612+
613+ /* reset DSPs on adapter */
614+ iowrite32(0x0003000F, phw->dw2040_HPICSR + HPI_RESET);
615+
616+ kfree(phw);
637617 }
638618
639619 /************************************************************************/
@@ -645,11 +625,13 @@ static void adapter_get_asserts(struct hpi_adapter_obj *pao, · 5 unmodified lines
645625 #ifndef HIDE_PCI_ASSERTS
646626 /* if we have PCI2040 asserts then collect them */
647627 if ((gw_pci_read_asserts > 0) || (gw_pci_write_asserts > 0)) {
648− phr->u.a.serial_number =
628+ phr->u.ax.assert.p1 =
649629 gw_pci_read_asserts * 100 + gw_pci_write_asserts;
650− phr->u.a.adapter_index = 1; /* assert count */
651− phr->u.a.adapter_type = -1; /* "dsp index" */
652− strcpy(phr->u.a.sz_adapter_assert, "PCI2040 error");
630+ phr->u.ax.assert.p2 = 0;
631+ phr->u.ax.assert.count = 1; /* assert count */
632+ phr->u.ax.assert.dsp_index = -1; /* "dsp index" */
633+ strcpy(phr->u.ax.assert.sz_message, "PCI2040 error");
634+ phr->u.ax.assert.dsp_msg_addr = 0;
653635 gw_pci_read_asserts = 0;
654636 gw_pci_write_asserts = 0;
655637 phr->error = 0;
@@ -686,10 +668,10 @@ static short hpi6000_adapter_boot_load_dsp(struct hpi_adapter_obj *pao, · 30 unmodified lines
686668
687669 /* NOTE don't use wAdapterType in this routine. It is not setup yet */
688670
689− switch (pao->pci.subsys_device_id) {
671+ switch (pao->pci.pci_dev->subsystem_device) {
690672 case 0x5100:
691673 case 0x5110: /* ASI5100 revB or higher with C6711D */
692− case 0x5200: /* ASI5200 PC_ie version of ASI5100 */
674+ case 0x5200: /* ASI5200 PCIe version of ASI5100 */
693675 case 0x6100:
694676 case 0x6200:
695677 boot_load_family = HPI_ADAPTER_FAMILY_ASI(0x6200);
@@ -709,8 +691,9 @@ static short hpi6000_adapter_boot_load_dsp(struct hpi_adapter_obj *pao, · 13 unmodified lines
709691 * note that bits 4..15 are read-only and so should always return zero,
710692 * even though we wrote 1 to them
711693 */
712− for (i = 0; i < 1000; i++)
713− delay = ioread32(phw->dw2040_HPICSR + HPI_RESET);
694+ hpios_delay_micro_seconds(1000);
695+ delay = ioread32(phw->dw2040_HPICSR + HPI_RESET);
696+
714697 if (delay != dw2040_reset) {
715698 HPI_DEBUG_LOG(ERROR, "INIT_PCI2040 %x %x\n", dw2040_reset,
716699 delay);
@@ -743,8 +726,7 @@ static short hpi6000_adapter_boot_load_dsp(struct hpi_adapter_obj *pao, · 26 unmodified lines
743726 dw2040_reset = dw2040_reset & (~0x00000008);
744727 iowrite32(dw2040_reset, phw->dw2040_HPICSR + HPI_RESET);
745728 /*delay to allow DSP to get going */
746− for (i = 0; i < 100; i++)
747− delay = ioread32(phw->dw2040_HPICSR + HPI_RESET);
729+ hpios_delay_micro_seconds(100);
748730
749731 /* loop through all DSPs, downloading DSP code */
750732 for (dsp_index = 0; dsp_index < phw->num_dsp; dsp_index++) {
@@ -783,27 +765,27 @@ static short hpi6000_adapter_boot_load_dsp(struct hpi_adapter_obj *pao, · 32 unmodified lines
783765 */
784766 /* bypass PLL */
785767 hpi_write_word(pdo, 0x01B7C100, 0x0000);
786− for (i = 0; i < 100; i++)
787− delay = ioread32(phw->dw2040_HPICSR +
788− HPI_RESET);
768+ hpios_delay_micro_seconds(100);
789769
790770 /* ** use default of PLL x7 ** */
791771 /* EMIF = 225/3=75MHz */
792772 hpi_write_word(pdo, 0x01B7C120, 0x8002);
773+ hpios_delay_micro_seconds(100);
774+
793775 /* peri = 225/2 */
794776 hpi_write_word(pdo, 0x01B7C11C, 0x8001);
777+ hpios_delay_micro_seconds(100);
778+
795779 /* cpu = 225/1 */
796780 hpi_write_word(pdo, 0x01B7C118, 0x8000);
797− /* ~200us delay */
798− for (i = 0; i < 2000; i++)
799− delay = ioread32(phw->dw2040_HPICSR +
800− HPI_RESET);
781+
782+ /* ~2ms delay */
783+ hpios_delay_micro_seconds(2000);
784+
801785 /* PLL not bypassed */
802786 hpi_write_word(pdo, 0x01B7C100, 0x0001);
803− /* ~200us delay */
804− for (i = 0; i < 2000; i++)
805− delay = ioread32(phw->dw2040_HPICSR +
806− HPI_RESET);
787+ /* ~2ms delay */
788+ hpios_delay_micro_seconds(2000);
807789 }
808790
809791 /* test r/w to internal DSP memory
@@ -927,9 +909,7 @@ static short hpi6000_adapter_boot_load_dsp(struct hpi_adapter_obj *pao, · 117 unmodified lines
927909 }
928910
929911 /* delay a little to allow SDRAM and DSP to "get going" */
930−
931− for (i = 0; i < 1000; i++)
932− delay = ioread32(phw->dw2040_HPICSR + HPI_RESET);
912+ hpios_delay_micro_seconds(1000);
933913
934914 /* test access to SDRAM */
935915 {
@@ -976,7 +956,7 @@ static short hpi6000_adapter_boot_load_dsp(struct hpi_adapter_obj *pao, · 40 unmodified lines
976956
977957 /* write the DSP code down into the DSPs memory */
978958 /*HpiDspCode_Open(nBootLoadFamily,&DspCode,pdwOsErrorCode); */
979− dsp_code.ps_dev = pao->pci.p_os_data;
959+ dsp_code.ps_dev = pao->pci.pci_dev;
980960
981961 error = hpi_dsp_code_open(boot_load_family, &dsp_code,
982962 pos_error_code);
@@ -1073,8 +1053,7 @@ static short hpi6000_adapter_boot_load_dsp(struct hpi_adapter_obj *pao, · 90 unmodified lines
10731053
10741054 /* step 3. Start code by sending interrupt */
10751055 iowrite32(0x00030003, pdo->prHPI_control);
1076− for (i = 0; i < 10000; i++)
1077− delay = ioread32(phw->dw2040_HPICSR + HPI_RESET);
1056+ hpios_delay_micro_seconds(10000);
10781057
10791058 /* wait for a non-zero value in hostcmd -
10801059 * indicating initialization is complete
@@ -1101,7 +1080,7 @@ static short hpi6000_adapter_boot_load_dsp(struct hpi_adapter_obj *pao, · 20 unmodified lines
11011080 * locks up with a bluescreen (NOT GPF or pagefault).
11021081 */
11031082 else
1104− hpios_delay_micro_seconds(1000);
1083+ hpios_delay_micro_seconds(10000);
11051084 }
11061085 if (timeout == 0)
11071086 return HPI6000_ERROR_INIT_NOACK;
@@ -1132,14 +1111,14 @@ static short hpi6000_adapter_boot_load_dsp(struct hpi_adapter_obj *pao, · 24 unmodified lines
11321111 mask = 0xFFFFFF00L;
11331112 /* ASI5100 uses AX6 code, */
11341113 /* but has no PLD r/w register to test */
1135− if (HPI_ADAPTER_FAMILY_ASI(pao->pci.
1136− subsys_device_id) ==
1114+ if (HPI_ADAPTER_FAMILY_ASI(pao->pci.pci_dev->
1115+ subsystem_device) ==
11371116 HPI_ADAPTER_FAMILY_ASI(0x5100))
11381117 mask = 0x00000000L;
11391118 /* ASI5200 uses AX6 code, */
11401119 /* but has no PLD r/w register to test */
1141− if (HPI_ADAPTER_FAMILY_ASI(pao->pci.
1142− subsys_device_id) ==
1120+ if (HPI_ADAPTER_FAMILY_ASI(pao->pci.pci_dev->
1121+ subsystem_device) ==
11431122 HPI_ADAPTER_FAMILY_ASI(0x5200))
11441123 mask = 0x00000000L;
11451124 break;
@@ -1204,7 +1183,7 @@ static u32 hpi_read_word(struct dsp_obj *pdo, u32 address) · 58 unmodified lines
12041183 u32 data = 0;
12051184
12061185 if (hpi_set_address(pdo, address))
1207− return 0; /*? no way to return error */
1186+ return 0; /*? No way to return error */
12081187
12091188 /* take care of errata in revB DSP (2.0.1) */
12101189 data = ioread32(pdo->prHPI_data);
@@ -1340,10 +1319,6 @@ static short hpi6000_message_response_sequence(struct hpi_adapter_obj *pao, · 129 unmodified lines
13401319 u32 *p_data;
13411320 u16 error = 0;
13421321
1343− /* does the DSP we are referencing exist? */
1344− if (dsp_index >= phw->num_dsp)
1345− return HPI6000_ERROR_MSG_INVALID_DSP_INDEX;
1346−
13471322 ack = hpi6000_wait_dsp_ack(pao, dsp_index, HPI_HIF_IDLE);
13481323 if (ack & HPI_HIF_ERROR_MASK) {
13491324 pao->dsp_crashed++;
@@ -1351,9 +1326,7 @@ static short hpi6000_message_response_sequence(struct hpi_adapter_obj *pao, · 1 unmodified line
13511326 }
13521327 pao->dsp_crashed = 0;
13531328
1354− /* send the message */
1355−
1356− /* get the address and size */
1329+ /* get the message address and size */
13571330 if (phw->message_buffer_address_on_dsp == 0) {
13581331 timeout = TIMEOUT;
13591332 do {
@@ -1368,10 +1341,9 @@ static short hpi6000_message_response_sequence(struct hpi_adapter_obj *pao, · 8 unmodified lines
13681341 } else
13691342 address = phw->message_buffer_address_on_dsp;
13701343
1371− /* dwLength = sizeof(struct hpi_message); */
13721344 length = phm->size;
13731345
1374− /* send it */
1346+ /* send the message */
13751347 p_data = (u32 *)phm;
13761348 if (hpi6000_dsp_block_write32(pao, dsp_index, address, p_data,
13771349 (u16)length / 4))
@@ -1385,7 +1357,7 @@ static short hpi6000_message_response_sequence(struct hpi_adapter_obj *pao, · 7 unmodified lines
13851357 if (ack & HPI_HIF_ERROR_MASK)
13861358 return HPI6000_ERROR_MSG_RESP_GET_RESP_ACK;
13871359
1388− /* get the address and size */
1360+ /* get the response address */
13891361 if (phw->response_buffer_address_on_dsp == 0) {
13901362 timeout = TIMEOUT;
13911363 do {
@@ -1409,7 +1381,7 @@ static short hpi6000_message_response_sequence(struct hpi_adapter_obj *pao, · 17 unmodified lines
14091381 if (!timeout)
14101382 length = sizeof(struct hpi_response);
14111383
1412− /* get it */
1384+ /* get the response */
14131385 p_data = (u32 *)phr;
14141386 if (hpi6000_dsp_block_read32(pao, dsp_index, address, p_data,
14151387 (u16)length / 4))
@@ -1805,17 +1777,11 @@ static void hw_message(struct hpi_adapter_obj *pao, struct hpi_message *phm, · 389 unmodified lines
18051777 hpios_dsplock_lock(pao);
18061778 error = hpi6000_message_response_sequence(pao, dsp_index, phm, phr);
18071779
1808− /* maybe an error response */
1809− if (error) {
1810− /* something failed in the HPI/DSP interface */
1811− phr->error = error;
1812− /* just the header of the response is valid */
1813− phr->size = sizeof(struct hpi_response_header);
1780+ if (error) /* something failed in the HPI/DSP interface */
18141781 goto err;
1815− }
18161782
1817− if (phr->error != 0) /* something failed in the DSP */
1818− goto err;
1783+ if (phr->error) /* something failed in the DSP */
1784+ goto out;
18191785
18201786 switch (phm->function) {
18211787 case HPI_OSTREAM_WRITE:
@@ -1827,21 +1793,30 @@ static void hw_message(struct hpi_adapter_obj *pao, struct hpi_message *phm, · 5 unmodified lines
18271793 error = hpi6000_get_data(pao, dsp_index, phm, phr);
18281794 break;
18291795 case HPI_ADAPTER_GET_ASSERT:
1830− phr->u.a.adapter_index = 0; /* dsp 0 default */
1796+ phr->u.ax.assert.dsp_index = 0; /* dsp 0 default */
18311797 if (num_dsp == 2) {
1832− if (!phr->u.a.adapter_type) {
1798+ if (!phr->u.ax.assert.count) {
18331799 /* no assert from dsp 0, check dsp 1 */
18341800 error = hpi6000_message_response_sequence(pao,
18351801 1, phm, phr);
1836− phr->u.a.adapter_index = 1;
1802+ phr->u.ax.assert.dsp_index = 1;
18371803 }
18381804 }
18391805 }
18401806
1841− if (error)
1842− phr->error = error;
1843−
18441807 err:
1808+ if (error) {
1809+ if (error >= HPI_ERROR_BACKEND_BASE) {
1810+ phr->error = HPI_ERROR_DSP_COMMUNICATION;
1811+ phr->specific_error = error;
1812+ } else {
1813+ phr->error = error;
1814+ }
1815+
1816+ /* just the header of the response is valid */
1817+ phr->size = sizeof(struct hpi_response_header);
1818+ }
1819+out:
18451820 hpios_dsplock_unlock(pao);
18461821 return;
18471822 }
sound/pci/asihpi/hpi6205.c+250−353
@@ -38,27 +38,26 @@ · 37 unmodified lines
3838
3939 /*****************************************************************************/
4040 /* HPI6205 specific error codes */
41−#define HPI6205_ERROR_BASE 1000
42−/*#define HPI6205_ERROR_MEM_ALLOC 1001 */
41+#define HPI6205_ERROR_BASE 1000 /* not actually used anywhere */
42+
43+/* operational/messaging errors */
44+#define HPI6205_ERROR_MSG_RESP_IDLE_TIMEOUT 1015
45+#define HPI6205_ERROR_MSG_RESP_TIMEOUT 1016
46+
47+/* initialization/bootload errors */
4348 #define HPI6205_ERROR_6205_NO_IRQ 1002
4449 #define HPI6205_ERROR_6205_INIT_FAILED 1003
45−/*#define HPI6205_ERROR_MISSING_DSPCODE 1004 */
46−#define HPI6205_ERROR_UNKNOWN_PCI_DEVICE 1005
4750 #define HPI6205_ERROR_6205_REG 1006
4851 #define HPI6205_ERROR_6205_DSPPAGE 1007
49−#define HPI6205_ERROR_BAD_DSPINDEX 1008
5052 #define HPI6205_ERROR_C6713_HPIC 1009
5153 #define HPI6205_ERROR_C6713_HPIA 1010
5254 #define HPI6205_ERROR_C6713_PLL 1011
5355 #define HPI6205_ERROR_DSP_INTMEM 1012
5456 #define HPI6205_ERROR_DSP_EXTMEM 1013
5557 #define HPI6205_ERROR_DSP_PLD 1014
56−#define HPI6205_ERROR_MSG_RESP_IDLE_TIMEOUT 1015
57−#define HPI6205_ERROR_MSG_RESP_TIMEOUT 1016
5858 #define HPI6205_ERROR_6205_EEPROM 1017
5959 #define HPI6205_ERROR_DSP_EMIF 1018
6060
61−#define hpi6205_error(dsp_index, err) (err)
6261 /*****************************************************************************/
6362 /* for C6205 PCI i/f */
6463 /* Host Status Register (HSR) bitfields */
@@ -128,9 +127,6 @@ struct hpi_hw_obj { · 63 unmodified lines
128127 u32 outstream_host_buffer_size[HPI_MAX_STREAMS];
129128
130129 struct consistent_dma_area h_control_cache;
131− struct consistent_dma_area h_async_event_buffer;
132−/* struct hpi_control_cache_single *pControlCache; */
133− struct hpi_async_event *p_async_event_buffer;
134130 struct hpi_control_cache *p_cache;
135131 };
136132
@@ -208,8 +204,8 @@ static void instream_start(struct hpi_adapter_obj *pao, · 71 unmodified lines
208204 static u32 boot_loader_read_mem32(struct hpi_adapter_obj *pao, int dsp_index,
209205 u32 address);
210206
211−static u16 boot_loader_write_mem32(struct hpi_adapter_obj *pao, int dsp_index,
212− u32 address, u32 data);
207+static void boot_loader_write_mem32(struct hpi_adapter_obj *pao,
208+ int dsp_index, u32 address, u32 data);
213209
214210 static u16 boot_loader_config_emif(struct hpi_adapter_obj *pao,
215211 int dsp_index);
@@ -229,17 +225,7 @@ static u16 boot_loader_test_pld(struct hpi_adapter_obj *pao, int dsp_index); · 13 unmodified lines
229225
230226 static void subsys_message(struct hpi_message *phm, struct hpi_response *phr)
231227 {
232−
233228 switch (phm->function) {
234− case HPI_SUBSYS_OPEN:
235− case HPI_SUBSYS_CLOSE:
236− case HPI_SUBSYS_GET_INFO:
237− case HPI_SUBSYS_DRIVER_UNLOAD:
238− case HPI_SUBSYS_DRIVER_LOAD:
239− case HPI_SUBSYS_FIND_ADAPTERS:
240− /* messages that should not get here */
241− phr->error = HPI_ERROR_UNIMPLEMENTED;
242− break;
243229 case HPI_SUBSYS_CREATE_ADAPTER:
244230 subsys_create_adapter(phm, phr);
245231 break;
@@ -257,15 +243,22 @@ static void control_message(struct hpi_adapter_obj *pao, · 11 unmodified lines
257243 {
258244
259245 struct hpi_hw_obj *phw = pao->priv;
246+ u16 pending_cache_error = 0;
260247
261248 switch (phm->function) {
262249 case HPI_CONTROL_GET_STATE:
263250 if (pao->has_control_cache) {
264− rmb(); /* make sure we see updates DM_aed from DSP */
265− if (hpi_check_control_cache(phw->p_cache, phm, phr))
251+ rmb(); /* make sure we see updates DMAed from DSP */
252+ if (hpi_check_control_cache(phw->p_cache, phm, phr)) {
266253 break;
254+ } else if (phm->u.c.attribute == HPI_METER_PEAK) {
255+ pending_cache_error =
256+ HPI_ERROR_CONTROL_CACHING;
257+ }
267258 }
268259 hw_message(pao, phm, phr);
260+ if (pending_cache_error && !phr->error)
261+ phr->error = pending_cache_error;
269262 break;
270263 case HPI_CONTROL_GET_INFO:
271264 hw_message(pao, phm, phr);
@@ -273,7 +266,8 @@ static void control_message(struct hpi_adapter_obj *pao, · 1 unmodified line
273266 case HPI_CONTROL_SET_STATE:
274267 hw_message(pao, phm, phr);
275268 if (pao->has_control_cache)
276− hpi_sync_control_cache(phw->p_cache, phm, phr);
269+ hpi_cmn_control_cache_sync_to_msg(phw->p_cache, phm,
270+ phr);
277271 break;
278272 default:
279273 phr->error = HPI_ERROR_INVALID_FUNC;
@@ -296,9 +290,9 @@ static void outstream_message(struct hpi_adapter_obj *pao, · 16 unmodified lines
296290 {
297291
298292 if (phm->obj_index >= HPI_MAX_STREAMS) {
299− phr->error = HPI_ERROR_INVALID_STREAM;
293+ phr->error = HPI_ERROR_INVALID_OBJ_INDEX;
300294 HPI_DEBUG_LOG(WARNING,
301− "message referencing invalid stream %d "
295+ "Message referencing invalid stream %d "
302296 "on adapter index %d\n", phm->obj_index,
303297 phm->adapter_index);
304298 return;
@@ -340,9 +334,9 @@ static void instream_message(struct hpi_adapter_obj *pao, · 35 unmodified lines
340334 {
341335
342336 if (phm->obj_index >= HPI_MAX_STREAMS) {
343− phr->error = HPI_ERROR_INVALID_STREAM;
337+ phr->error = HPI_ERROR_INVALID_OBJ_INDEX;
344338 HPI_DEBUG_LOG(WARNING,
345− "message referencing invalid stream %d "
339+ "Message referencing invalid stream %d "
346340 "on adapter index %d\n", phm->obj_index,
347341 phm->adapter_index);
348342 return;
@@ -385,8 +379,8 @@ void HPI_6205(struct hpi_message *phm, struct hpi_response *phr) · 36 unmodified lines
385379 * All other messages are ignored unless the adapter index matches
386380 * an adapter in the HPI
387381 */
388− HPI_DEBUG_LOG(DEBUG, "HPI obj=%d, func=%d\n", phm->object,
389− phm->function);
382+ /* HPI_DEBUG_LOG(DEBUG, "HPI Obj=%d, Func=%d\n", phm->wObject,
383+ phm->wFunction); */
390384
391385 /* if Dsp has crashed then do not communicate with it any more */
392386 if (phm->object != HPI_OBJ_SUBSYSTEM) {
@@ -411,8 +405,7 @@ void HPI_6205(struct hpi_message *phm, struct hpi_response *phr) · 18 unmodified lines
411405
412406 /* Init default response */
413407 if (phm->function != HPI_SUBSYS_CREATE_ADAPTER)
414− hpi_init_response(phr, phm->object, phm->function,
415− HPI_ERROR_PROCESSING_MESSAGE);
408+ phr->error = HPI_ERROR_PROCESSING_MESSAGE;
416409
417410 HPI_DEBUG_LOG(VERBOSE, "start of switch\n");
418411 switch (phm->type) {
@@ -423,9 +416,6 @@ void HPI_6205(struct hpi_message *phm, struct hpi_response *phr) · 4 unmodified lines
423416 break;
424417
425418 case HPI_OBJ_ADAPTER:
426− phr->size =
427− sizeof(struct hpi_response_header) +
428− sizeof(struct hpi_adapter_res);
429419 adapter_message(pao, phm, phr);
430420 break;
431421
@@ -474,14 +464,6 @@ static void subsys_create_adapter(struct hpi_message *phm, · 42 unmodified lines
474464
475465 memset(&ao, 0, sizeof(ao));
476466
477− /* this HPI only creates adapters for TI/PCI devices */
478− if (phm->u.s.resource.bus_type != HPI_BUS_PCI)
479− return;
480− if (phm->u.s.resource.r.pci->vendor_id != HPI_PCI_VENDOR_ID_TI)
481− return;
482− if (phm->u.s.resource.r.pci->device_id != HPI_PCI_DEV_ID_DSP6205)
483− return;
484−
485467 ao.priv = kzalloc(sizeof(struct hpi_hw_obj), GFP_KERNEL);
486468 if (!ao.priv) {
487469 HPI_DEBUG_LOG(ERROR, "cant get mem for adapter object\n");
@@ -491,18 +473,20 @@ static void subsys_create_adapter(struct hpi_message *phm, · 3 unmodified lines
491473
492474 ao.pci = *phm->u.s.resource.r.pci;
493475 err = create_adapter_obj(&ao, &os_error_code);
494− if (!err)
495− err = hpi_add_adapter(&ao);
496476 if (err) {
497− phr->u.s.data = os_error_code;
498477 delete_adapter_obj(&ao);
499− phr->error = err;
478+ if (err >= HPI_ERROR_BACKEND_BASE) {
479+ phr->error = HPI_ERROR_DSP_BOOTLOAD;
480+ phr->specific_error = err;
481+ } else {
482+ phr->error = err;
483+ }
484+ phr->u.s.data = os_error_code;
500485 return;
501486 }
502487
503− phr->u.s.aw_adapter_list[ao.index] = ao.adapter_type;
488+ phr->u.s.adapter_type = ao.adapter_type;
504489 phr->u.s.adapter_index = ao.index;
505− phr->u.s.num_adapters++;
506490 phr->error = 0;
507491 }
508492
@@ -513,7 +497,7 @@ static void subsys_delete_adapter(struct hpi_message *phm, · 4 unmodified lines
513497 struct hpi_adapter_obj *pao;
514498 struct hpi_hw_obj *phw;
515499
516− pao = hpi_find_adapter(phm->adapter_index);
500+ pao = hpi_find_adapter(phm->obj_index);
517501 if (!pao) {
518502 phr->error = HPI_ERROR_INVALID_OBJ_INDEX;
519503 return;
@@ -526,6 +510,7 @@ static void subsys_delete_adapter(struct hpi_message *phm, · 6 unmodified lines
526510 iowrite32(C6205_HDCR_WARMRESET, phw->prHDCR);
527511
528512 delete_adapter_obj(pao);
513+ hpi_delete_adapter(pao);
529514 phr->error = 0;
530515 }
531516
@@ -538,10 +523,6 @@ static u16 create_adapter_obj(struct hpi_adapter_obj *pao, · 6 unmodified lines
538523 struct hpi_hw_obj *phw = pao->priv;
539524 struct bus_master_interface *interface;
540525 u32 phys_addr;
541−#ifndef HPI6205_NO_HSR_POLL
542− u32 time_out = HPI6205_TIMEOUT;
543− u32 temp1;
544−#endif
545526 int i;
546527 u16 err;
547528
@@ -566,7 +547,7 @@ static u16 create_adapter_obj(struct hpi_adapter_obj *pao, · 18 unmodified lines
566547
567548 if (hpios_locked_mem_alloc(&phw->h_locked_mem,
568549 sizeof(struct bus_master_interface),
569− pao->pci.p_os_data))
550+ pao->pci.pci_dev))
570551 phw->p_interface_buffer = NULL;
571552 else if (hpios_locked_mem_get_virt_addr(&phw->h_locked_mem,
572553 (void *)&phw->p_interface_buffer))
@@ -591,49 +572,29 @@ static u16 create_adapter_obj(struct hpi_adapter_obj *pao, · 18 unmodified lines
591572
592573 /* allow boot load even if mem alloc wont work */
593574 if (!phw->p_interface_buffer)
594− return hpi6205_error(0, HPI_ERROR_MEMORY_ALLOC);
575+ return HPI_ERROR_MEMORY_ALLOC;
595576
596577 interface = phw->p_interface_buffer;
597578
598−#ifndef HPI6205_NO_HSR_POLL
599− /* wait for first interrupt indicating the DSP init is done */
600− time_out = HPI6205_TIMEOUT * 10;
601− temp1 = 0;
602− while (((temp1 & C6205_HSR_INTSRC) == 0) && --time_out)
603− temp1 = ioread32(phw->prHSR);
604−
605− if (temp1 & C6205_HSR_INTSRC)
606− HPI_DEBUG_LOG(INFO,
607− "interrupt confirming DSP code running OK\n");
608− else {
609− HPI_DEBUG_LOG(ERROR,
610− "timed out waiting for interrupt "
611− "confirming DSP code running\n");
612− return hpi6205_error(0, HPI6205_ERROR_6205_NO_IRQ);
613− }
614−
615− /* reset the interrupt */
616− iowrite32(C6205_HSR_INTSRC, phw->prHSR);
617−#endif
618−
619579 /* make sure the DSP has started ok */
620580 if (!wait_dsp_ack(phw, H620_HIF_RESET, HPI6205_TIMEOUT * 10)) {
621581 HPI_DEBUG_LOG(ERROR, "timed out waiting reset state \n");
622− return hpi6205_error(0, HPI6205_ERROR_6205_INIT_FAILED);
582+ return HPI6205_ERROR_6205_INIT_FAILED;
623583 }
624584 /* Note that *pao, *phw are zeroed after allocation,
625585 * so pointers and flags are NULL by default.
626586 * Allocate bus mastering control cache buffer and tell the DSP about it
627587 */
628588 if (interface->control_cache.number_of_controls) {
629− void *p_control_cache_virtual;
589+ u8 *p_control_cache_virtual;
630590
631591 err = hpios_locked_mem_alloc(&phw->h_control_cache,
632592 interface->control_cache.size_in_bytes,
633− pao->pci.p_os_data);
593+ pao->pci.pci_dev);
634594 if (!err)
635595 err = hpios_locked_mem_get_virt_addr(&phw->
636− h_control_cache, &p_control_cache_virtual);
596+ h_control_cache,
597+ (void *)&p_control_cache_virtual);
637598 if (!err) {
638599 memset(p_control_cache_virtual, 0,
639600 interface->control_cache.size_in_bytes);
@@ -642,7 +603,6 @@ static u16 create_adapter_obj(struct hpi_adapter_obj *pao, · 2 unmodified lines
642603 hpi_alloc_control_cache(interface->
643604 control_cache.number_of_controls,
644605 interface->control_cache.size_in_bytes,
645− (struct hpi_control_cache_info *)
646606 p_control_cache_virtual);
647607 if (!phw->p_cache)
648608 err = HPI_ERROR_MEMORY_ALLOC;
@@ -662,78 +622,56 @@ static u16 create_adapter_obj(struct hpi_adapter_obj *pao, · 13 unmodified lines
662622 pao->has_control_cache = 0;
663623 }
664624 }
665− /* allocate bus mastering async buffer and tell the DSP about it */
666− if (interface->async_buffer.b.size) {
667− err = hpios_locked_mem_alloc(&phw->h_async_event_buffer,
668− interface->async_buffer.b.size *
669− sizeof(struct hpi_async_event), pao->pci.p_os_data);
670− if (!err)
671− err = hpios_locked_mem_get_virt_addr
672− (&phw->h_async_event_buffer, (void *)
673− &phw->p_async_event_buffer);
674− if (!err)
675− memset((void *)phw->p_async_event_buffer, 0,
676− interface->async_buffer.b.size *
677− sizeof(struct hpi_async_event));
678− if (!err) {
679− err = hpios_locked_mem_get_phys_addr
680− (&phw->h_async_event_buffer, &phys_addr);
681− interface->async_buffer.physical_address32 =
682− phys_addr;
683− }
684− if (err) {
685− if (hpios_locked_mem_valid(&phw->
686− h_async_event_buffer)) {
687− hpios_locked_mem_free
688− (&phw->h_async_event_buffer);
689− phw->p_async_event_buffer = NULL;
690− }
691− }
692− }
693625 send_dsp_command(phw, H620_HIF_IDLE);
694626
695627 {
696− struct hpi_message hM;
697− struct hpi_response hR;
628+ struct hpi_message hm;
629+ struct hpi_response hr;
698630 u32 max_streams;
699631
700632 HPI_DEBUG_LOG(VERBOSE, "init ADAPTER_GET_INFO\n");
701− memset(&hM, 0, sizeof(hM));
702− hM.type = HPI_TYPE_MESSAGE;
703− hM.size = sizeof(hM);
704− hM.object = HPI_OBJ_ADAPTER;
705− hM.function = HPI_ADAPTER_GET_INFO;
706− hM.adapter_index = 0;
707− memset(&hR, 0, sizeof(hR));
708− hR.size = sizeof(hR);
709−
710− err = message_response_sequence(pao, &hM, &hR);
633+ memset(&hm, 0, sizeof(hm));
634+ hm.type = HPI_TYPE_MESSAGE;
635+ hm.size = sizeof(hm);
636+ hm.object = HPI_OBJ_ADAPTER;
637+ hm.function = HPI_ADAPTER_GET_INFO;
638+ hm.adapter_index = 0;
639+ memset(&hr, 0, sizeof(hr));
640+ hr.size = sizeof(hr);
641+
642+ err = message_response_sequence(pao, &hm, &hr);
711643 if (err) {
712644 HPI_DEBUG_LOG(ERROR, "message transport error %d\n",
713645 err);
714646 return err;
715647 }
716− if (hR.error)
717− return hR.error;
648+ if (hr.error)
649+ return hr.error;
718650
719− pao->adapter_type = hR.u.a.adapter_type;
720− pao->index = hR.u.a.adapter_index;
651+ pao->adapter_type = hr.u.ax.info.adapter_type;
652+ pao->index = hr.u.ax.info.adapter_index;
721653
722− max_streams = hR.u.a.num_outstreams + hR.u.a.num_instreams;
654+ max_streams =
655+ hr.u.ax.info.num_outstreams +
656+ hr.u.ax.info.num_instreams;
723657
724658 hpios_locked_mem_prepare((max_streams * 6) / 10, max_streams,
725− 65536, pao->pci.p_os_data);
659+ 65536, pao->pci.pci_dev);
726660
727661 HPI_DEBUG_LOG(VERBOSE,
728662 "got adapter info type %x index %d serial %d\n",
729− hR.u.a.adapter_type, hR.u.a.adapter_index,
730− hR.u.a.serial_number);
663+ hr.u.ax.info.adapter_type, hr.u.ax.info.adapter_index,
664+ hr.u.ax.info.serial_number);
731665 }
732666
733667 pao->open = 0; /* upon creation the adapter is closed */
734668
669+ if (phw->p_cache)
670+ phw->p_cache->adap_idx = pao->index;
671+
735672 HPI_DEBUG_LOG(INFO, "bootload DSP OK\n");
736− return 0;
673+
674+ return hpi_add_adapter(pao);
737675 }
738676
739677 /** Free memory areas allocated by adapter
@@ -747,11 +685,6 @@ static void delete_adapter_obj(struct hpi_adapter_obj *pao) · 7 unmodified lines
747685
748686 phw = pao->priv;
749687
750− if (hpios_locked_mem_valid(&phw->h_async_event_buffer)) {
751− hpios_locked_mem_free(&phw->h_async_event_buffer);
752− phw->p_async_event_buffer = NULL;
753− }
754−
755688 if (hpios_locked_mem_valid(&phw->h_control_cache)) {
756689 hpios_locked_mem_free(&phw->h_control_cache);
757690 hpi_free_control_cache(phw->p_cache);
@@ -776,12 +709,14 @@ static void delete_adapter_obj(struct hpi_adapter_obj *pao) · 18 unmodified lines
776709 phw->outstream_host_buffer_size[i] = 0;
777710 }
778711
779− hpios_locked_mem_unprepare(pao->pci.p_os_data);
712+ hpios_locked_mem_unprepare(pao->pci.pci_dev);
780713
781− hpi_delete_adapter(pao);
782714 kfree(phw);
783715 }
784716
717+/*****************************************************************************/
718+/* Adapter functions */
719+
785720 /*****************************************************************************/
786721 /* OutStream Host buffer functions */
787722
@@ -824,7 +759,7 @@ static void outstream_host_buffer_allocate(struct hpi_adapter_obj *pao, · 36 unmodified lines
824759
825760 err = hpios_locked_mem_alloc(&phw->outstream_host_buffers
826761 [phm->obj_index], phm->u.d.u.buffer.buffer_size,
827− pao->pci.p_os_data);
762+ pao->pci.pci_dev);
828763
829764 if (err) {
830765 phr->error = HPI_ERROR_INVALID_DATASIZE;
@@ -861,7 +796,7 @@ static void outstream_host_buffer_allocate(struct hpi_adapter_obj *pao, · 30 unmodified lines
861796 if (phm->u.d.u.buffer.buffer_size & (phm->u.d.u.buffer.
862797 buffer_size - 1)) {
863798 HPI_DEBUG_LOG(ERROR,
864− "buffer size must be 2^N not %d\n",
799+ "Buffer size must be 2^N not %d\n",
865800 phm->u.d.u.buffer.buffer_size);
866801 phr->error = HPI_ERROR_INVALID_DATASIZE;
867802 return;
@@ -875,6 +810,7 @@ static void outstream_host_buffer_allocate(struct hpi_adapter_obj *pao, · 7 unmodified lines
875810 status->dSP_index = 0;
876811 status->host_index = status->dSP_index;
877812 status->size_in_bytes = phm->u.d.u.buffer.buffer_size;
813+ status->auxiliary_data_available = 0;
878814
879815 hw_message(pao, phm, phr);
880816
@@ -966,51 +902,6 @@ static void outstream_write(struct hpi_adapter_obj *pao, · 85 unmodified lines
966902 hpi_init_response(phr, phm->object, phm->function, 0);
967903 status = &interface->outstream_host_buffer_status[phm->obj_index];
968904
969− if (phw->flag_outstream_just_reset[phm->obj_index]) {
970− /* First OutStremWrite() call following reset will write data to the
971− adapter's buffers, reducing delay before stream can start. The DSP
972− takes care of setting the stream data format using format information
973− embedded in phm.
974− */
975− int partial_write = 0;
976− unsigned int original_size = 0;
977−
978− phw->flag_outstream_just_reset[phm->obj_index] = 0;
979−
980− /* Send the first buffer to the DSP the old way. */
981− /* Limit size of first transfer - */
982− /* expect that this will not usually be triggered. */
983− if (phm->u.d.u.data.data_size > HPI6205_SIZEOF_DATA) {
984− partial_write = 1;
985− original_size = phm->u.d.u.data.data_size;
986− phm->u.d.u.data.data_size = HPI6205_SIZEOF_DATA;
987− }
988− /* write it */
989− phm->function = HPI_OSTREAM_WRITE;
990− hw_message(pao, phm, phr);
991−
992− if (phr->error)
993− return;
994−
995− /* update status information that the DSP would typically
996− * update (and will update next time the DSP
997− * buffer update task reads data from the host BBM buffer)
998− */
999− status->auxiliary_data_available = phm->u.d.u.data.data_size;
1000− status->host_index += phm->u.d.u.data.data_size;
1001− status->dSP_index += phm->u.d.u.data.data_size;
1002−
1003− /* if we did a full write, we can return from here. */
1004− if (!partial_write)
1005− return;
1006−
1007− /* tweak buffer parameters and let the rest of the */
1008− /* buffer land in internal BBM buffer */
1009− phm->u.d.u.data.data_size =
1010− original_size - HPI6205_SIZEOF_DATA;
1011− phm->u.d.u.data.pb_data += HPI6205_SIZEOF_DATA;
1012− }
1013−
1014905 space_available = outstream_get_space_available(status);
1015906 if (space_available < phm->u.d.u.data.data_size) {
1016907 phr->error = HPI_ERROR_INVALID_DATASIZE;
@@ -1047,6 +938,24 @@ static void outstream_write(struct hpi_adapter_obj *pao, · 30 unmodified lines
1047938 memcpy(p_bbm_data, p_app_data + l_first_write,
1048939 phm->u.d.u.data.data_size - l_first_write);
1049940 }
941+
942+ /*
943+ * This version relies on the DSP code triggering an OStream buffer
944+ * update immediately following a SET_FORMAT call. The host has
945+ * already written data into the BBM buffer, but the DSP won't know
946+ * about it until dwHostIndex is adjusted.
947+ */
948+ if (phw->flag_outstream_just_reset[phm->obj_index]) {
949+ /* Format can only change after reset. Must tell DSP. */
950+ u16 function = phm->function;
951+ phw->flag_outstream_just_reset[phm->obj_index] = 0;
952+ phm->function = HPI_OSTREAM_SET_FORMAT;
953+ hw_message(pao, phm, phr); /* send the format to the DSP */
954+ phm->function = function;
955+ if (phr->error)
956+ return;
957+ }
958+
1050959 status->host_index += phm->u.d.u.data.data_size;
1051960 }
1052961
@@ -1132,7 +1041,7 @@ static void instream_host_buffer_allocate(struct hpi_adapter_obj *pao, · 79 unmodified lines
11321041
11331042 err = hpios_locked_mem_alloc(&phw->instream_host_buffers[phm->
11341043 obj_index], phm->u.d.u.buffer.buffer_size,
1135− pao->pci.p_os_data);
1044+ pao->pci.pci_dev);
11361045
11371046 if (err) {
11381047 phr->error = HPI_ERROR_INVALID_DATASIZE;
@@ -1163,7 +1072,7 @@ static void instream_host_buffer_allocate(struct hpi_adapter_obj *pao, · 24 unmodified lines
11631072 if (phm->u.d.u.buffer.buffer_size & (phm->u.d.u.buffer.
11641073 buffer_size - 1)) {
11651074 HPI_DEBUG_LOG(ERROR,
1166− "buffer size must be 2^N not %d\n",
1075+ "Buffer size must be 2^N not %d\n",
11671076 phm->u.d.u.buffer.buffer_size);
11681077 phr->error = HPI_ERROR_INVALID_DATASIZE;
11691078 return;
@@ -1178,8 +1087,10 @@ static void instream_host_buffer_allocate(struct hpi_adapter_obj *pao, · 8 unmodified lines
11781087 status->dSP_index = 0;
11791088 status->host_index = status->dSP_index;
11801089 status->size_in_bytes = phm->u.d.u.buffer.buffer_size;
1090+ status->auxiliary_data_available = 0;
11811091
11821092 hw_message(pao, phm, phr);
1093+
11831094 if (phr->error
11841095 && hpios_locked_mem_valid(&phw->
11851096 instream_host_buffers[phm->obj_index])) {
@@ -1344,33 +1255,36 @@ static u16 adapter_boot_load_dsp(struct hpi_adapter_obj *pao, · 158 unmodified lines
13441255 struct hpi_hw_obj *phw = pao->priv;
13451256 struct dsp_code dsp_code;
13461257 u16 boot_code_id[HPI6205_MAX_FILES_TO_LOAD];
1347− u16 firmware_id = pao->pci.subsys_device_id;
13481258 u32 temp;
13491259 int dsp = 0, i = 0;
13501260 u16 err = 0;
13511261
13521262 boot_code_id[0] = HPI_ADAPTER_ASI(0x6205);
13531263
1354− /* special cases where firmware_id != subsys ID */
1355− switch (firmware_id) {
1264+ boot_code_id[1] = pao->pci.pci_dev->subsystem_device;
1265+ boot_code_id[1] = HPI_ADAPTER_FAMILY_ASI(boot_code_id[1]);
1266+
1267+ /* fix up cases where bootcode id[1] != subsys id */
1268+ switch (boot_code_id[1]) {
13561269 case HPI_ADAPTER_FAMILY_ASI(0x5000):
1357− boot_code_id[0] = firmware_id;
1358− firmware_id = 0;
1270+ boot_code_id[0] = boot_code_id[1];
1271+ boot_code_id[1] = 0;
13591272 break;
13601273 case HPI_ADAPTER_FAMILY_ASI(0x5300):
13611274 case HPI_ADAPTER_FAMILY_ASI(0x5400):
13621275 case HPI_ADAPTER_FAMILY_ASI(0x6300):
1363− firmware_id = HPI_ADAPTER_FAMILY_ASI(0x6400);
1276+ boot_code_id[1] = HPI_ADAPTER_FAMILY_ASI(0x6400);
13641277 break;
13651278 case HPI_ADAPTER_FAMILY_ASI(0x5600):
13661279 case HPI_ADAPTER_FAMILY_ASI(0x6500):
1367− firmware_id = HPI_ADAPTER_FAMILY_ASI(0x6600);
1280+ boot_code_id[1] = HPI_ADAPTER_FAMILY_ASI(0x6600);
13681281 break;
13691282 case HPI_ADAPTER_FAMILY_ASI(0x8800):
1370− firmware_id = HPI_ADAPTER_FAMILY_ASI(0x8900);
1283+ boot_code_id[1] = HPI_ADAPTER_FAMILY_ASI(0x8900);
1284+ break;
1285+ default:
13711286 break;
13721287 }
1373− boot_code_id[1] = firmware_id;
13741288
13751289 /* reset DSP by writing a 1 to the WARMRESET bit */
13761290 temp = C6205_HDCR_WARMRESET;
@@ -1381,7 +1295,7 @@ static u16 adapter_boot_load_dsp(struct hpi_adapter_obj *pao, · 4 unmodified lines
13811295 temp = ioread32(phw->prHSR);
13821296 if ((temp & (C6205_HSR_CFGERR | C6205_HSR_EEREAD)) !=
13831297 C6205_HSR_EEREAD)
1384− return hpi6205_error(0, HPI6205_ERROR_6205_EEPROM);
1298+ return HPI6205_ERROR_6205_EEPROM;
13851299 temp |= 0x04;
13861300 /* disable PINTA interrupt */
13871301 iowrite32(temp, phw->prHSR);
@@ -1389,27 +1303,27 @@ static u16 adapter_boot_load_dsp(struct hpi_adapter_obj *pao, · 1 unmodified line
13891303 /* check control register reports PCI boot mode */
13901304 temp = ioread32(phw->prHDCR);
13911305 if (!(temp & C6205_HDCR_PCIBOOT))
1392− return hpi6205_error(0, HPI6205_ERROR_6205_REG);
1306+ return HPI6205_ERROR_6205_REG;
13931307
1394− /* try writing a couple of numbers to the DSP page register */
1308+ /* try writing a few numbers to the DSP page register */
13951309 /* and reading them back. */
1396− temp = 1;
1310+ temp = 3;
13971311 iowrite32(temp, phw->prDSPP);
13981312 if ((temp | C6205_DSPP_MAP1) != ioread32(phw->prDSPP))
1399− return hpi6205_error(0, HPI6205_ERROR_6205_DSPPAGE);
1313+ return HPI6205_ERROR_6205_DSPPAGE;
14001314 temp = 2;
14011315 iowrite32(temp, phw->prDSPP);
14021316 if ((temp | C6205_DSPP_MAP1) != ioread32(phw->prDSPP))
1403− return hpi6205_error(0, HPI6205_ERROR_6205_DSPPAGE);
1404− temp = 3;
1317+ return HPI6205_ERROR_6205_DSPPAGE;
1318+ temp = 1;
14051319 iowrite32(temp, phw->prDSPP);
14061320 if ((temp | C6205_DSPP_MAP1) != ioread32(phw->prDSPP))
1407− return hpi6205_error(0, HPI6205_ERROR_6205_DSPPAGE);
1321+ return HPI6205_ERROR_6205_DSPPAGE;
14081322 /* reset DSP page to the correct number */
14091323 temp = 0;
14101324 iowrite32(temp, phw->prDSPP);
14111325 if ((temp | C6205_DSPP_MAP1) != ioread32(phw->prDSPP))
1412− return hpi6205_error(0, HPI6205_ERROR_6205_DSPPAGE);
1326+ return HPI6205_ERROR_6205_DSPPAGE;
14131327 phw->dsp_page = 0;
14141328
14151329 /* release 6713 from reset before 6205 is bootloaded.
@@ -1455,7 +1369,7 @@ static u16 adapter_boot_load_dsp(struct hpi_adapter_obj *pao, · 39 unmodified lines
14551369 return err;
14561370
14571371 /* write the DSP code down into the DSPs memory */
1458− dsp_code.ps_dev = pao->pci.p_os_data;
1372+ dsp_code.ps_dev = pao->pci.pci_dev;
14591373 err = hpi_dsp_code_open(boot_code_id[dsp], &dsp_code,
14601374 pos_error_code);
14611375 if (err)
@@ -1484,10 +1398,8 @@ static u16 adapter_boot_load_dsp(struct hpi_adapter_obj *pao, · 22 unmodified lines
14841398 if (err)
14851399 break;
14861400 for (i = 0; i < (int)length; i++) {
1487− err = boot_loader_write_mem32(pao, dsp,
1488− address, *pcode);
1489− if (err)
1490− break;
1401+ boot_loader_write_mem32(pao, dsp, address,
1402+ *pcode);
14911403 /* dummy read every 4 words */
14921404 /* for 6205 advisory 1.4.4 */
14931405 if (i % 4 == 0)
@@ -1561,7 +1473,7 @@ static u16 adapter_boot_load_dsp(struct hpi_adapter_obj *pao, · 67 unmodified lines
15611473 host_mailbox_address_on_dsp = 0x80000000;
15621474 while ((physicalPC_iaddress != physicalPC_iaddress_verify)
15631475 && time_out--) {
1564− err = boot_loader_write_mem32(pao, 0,
1476+ boot_loader_write_mem32(pao, 0,
15651477 host_mailbox_address_on_dsp,
15661478 physicalPC_iaddress);
15671479 physicalPC_iaddress_verify =
@@ -1631,11 +1543,10 @@ static u32 boot_loader_read_mem32(struct hpi_adapter_obj *pao, int dsp_index, · 63 unmodified lines
16311543 return data;
16321544 }
16331545
1634−static u16 boot_loader_write_mem32(struct hpi_adapter_obj *pao, int dsp_index,
1635− u32 address, u32 data)
1546+static void boot_loader_write_mem32(struct hpi_adapter_obj *pao,
1547+ int dsp_index, u32 address, u32 data)
16361548 {
16371549 struct hpi_hw_obj *phw = pao->priv;
1638− u16 err = 0;
16391550 __iomem u32 *p_data;
16401551 /* u32 dwVerifyData=0; */
16411552
@@ -1675,15 +1586,11 @@ static u16 boot_loader_write_mem32(struct hpi_adapter_obj *pao, int dsp_index, · 33 unmodified lines
16751586
16761587 /* dummy read every 4 words for 6205 advisory 1.4.4 */
16771588 boot_loader_read_mem32(pao, 0, 0);
1678− } else
1679− err = hpi6205_error(dsp_index, HPI6205_ERROR_BAD_DSPINDEX);
1680− return err;
1589+ }
16811590 }
16821591
16831592 static u16 boot_loader_config_emif(struct hpi_adapter_obj *pao, int dsp_index)
16841593 {
1685− u16 err = 0;
1686−
16871594 if (dsp_index == 0) {
16881595 u32 setting;
16891596
@@ -1711,8 +1618,7 @@ static u16 boot_loader_config_emif(struct hpi_adapter_obj *pao, int dsp_index) · 21 unmodified lines
17111618 boot_loader_write_mem32(pao, dsp_index, 0x01800008, setting);
17121619 if (setting != boot_loader_read_mem32(pao, dsp_index,
17131620 0x01800008))
1714− return hpi6205_error(dsp_index,
1715− HPI6205_ERROR_DSP_EMIF);
1621+ return HPI6205_ERROR_DSP_EMIF;
17161622
17171623 /* EMIF CE1 setup - 32 bit async. This is 6713 #1 HPI, */
17181624 /* which occupies D15..0. 6713 starts at 27MHz, so need */
@@ -1725,8 +1631,7 @@ static u16 boot_loader_config_emif(struct hpi_adapter_obj *pao, int dsp_index) · 6 unmodified lines
17251631 boot_loader_write_mem32(pao, dsp_index, 0x01800004, setting);
17261632 if (setting != boot_loader_read_mem32(pao, dsp_index,
17271633 0x01800004))
1728− return hpi6205_error(dsp_index,
1729− HPI6205_ERROR_DSP_EMIF);
1634+ return HPI6205_ERROR_DSP_EMIF;
17301635
17311636 /* EMIF CE2 setup - 32 bit async. This is 6713 #2 HPI, */
17321637 /* which occupies D15..0. 6713 starts at 27MHz, so need */
@@ -1738,8 +1643,7 @@ static u16 boot_loader_config_emif(struct hpi_adapter_obj *pao, int dsp_index) · 5 unmodified lines
17381643 boot_loader_write_mem32(pao, dsp_index, 0x01800010, setting);
17391644 if (setting != boot_loader_read_mem32(pao, dsp_index,
17401645 0x01800010))
1741− return hpi6205_error(dsp_index,
1742− HPI6205_ERROR_DSP_EMIF);
1646+ return HPI6205_ERROR_DSP_EMIF;
17431647
17441648 /* EMIF CE3 setup - 32 bit async. */
17451649 /* This is the PLD on the ASI5000 cards only */
@@ -1750,8 +1654,7 @@ static u16 boot_loader_config_emif(struct hpi_adapter_obj *pao, int dsp_index) · 4 unmodified lines
17501654 boot_loader_write_mem32(pao, dsp_index, 0x01800014, setting);
17511655 if (setting != boot_loader_read_mem32(pao, dsp_index,
17521656 0x01800014))
1753− return hpi6205_error(dsp_index,
1754− HPI6205_ERROR_DSP_EMIF);
1657+ return HPI6205_ERROR_DSP_EMIF;
17551658
17561659 /* set EMIF SDRAM control for 2Mx32 SDRAM (512x32x4 bank) */
17571660 /* need to use this else DSP code crashes? */
@@ -1775,12 +1678,9 @@ static u16 boot_loader_config_emif(struct hpi_adapter_obj *pao, int dsp_index) · 17 unmodified lines
17751678 read_data =
17761679 0xFFF7 & boot_loader_read_mem32(pao, 0, HPICL_ADDR);
17771680 if (write_data != read_data) {
1778− err = hpi6205_error(dsp_index,
1779− HPI6205_ERROR_C6713_HPIC);
17801681 HPI_DEBUG_LOG(ERROR, "HPICL %x %x\n", write_data,
17811682 read_data);
1782−
1783− return err;
1683+ return HPI6205_ERROR_C6713_HPIC;
17841684 }
17851685 /* HPIA - walking ones test */
17861686 write_data = 1;
@@ -1798,11 +1698,9 @@ static u16 boot_loader_config_emif(struct hpi_adapter_obj *pao, int dsp_index) · 11 unmodified lines
17981698 HPIAH_ADDR))
17991699 << 16);
18001700 if (read_data != write_data) {
1801− err = hpi6205_error(dsp_index,
1802− HPI6205_ERROR_C6713_HPIA);
18031701 HPI_DEBUG_LOG(ERROR, "HPIA %x %x\n",
18041702 write_data, read_data);
1805− return err;
1703+ return HPI6205_ERROR_C6713_HPIA;
18061704 }
18071705 write_data = write_data << 1;
18081706 }
@@ -1847,30 +1745,81 @@ static u16 boot_loader_config_emif(struct hpi_adapter_obj *pao, int dsp_index) · 38 unmodified lines
18471745 /* PLL should not be bypassed! */
18481746 if ((boot_loader_read_mem32(pao, dsp_index, 0x01B7C100) & 0xF)
18491747 != 0x0001) {
1850− err = hpi6205_error(dsp_index,
1851− HPI6205_ERROR_C6713_PLL);
1852− return err;
1748+ return HPI6205_ERROR_C6713_PLL;
18531749 }
18541750 /* setup C67x EMIF (note this is the only use of
18551751 BAR1 via BootLoader_WriteMem32) */
18561752 boot_loader_write_mem32(pao, dsp_index, C6713_EMIF_GCTL,
18571753 0x000034A8);
1754+
1755+ /* EMIF CE0 setup - 2Mx32 Sync DRAM
1756+ 31..28 Wr setup
1757+ 27..22 Wr strobe
1758+ 21..20 Wr hold
1759+ 19..16 Rd setup
1760+ 15..14 -
1761+ 13..8 Rd strobe
1762+ 7..4 MTYPE 0011 Sync DRAM 32bits
1763+ 3 Wr hold MSB
1764+ 2..0 Rd hold
1765+ */
18581766 boot_loader_write_mem32(pao, dsp_index, C6713_EMIF_CE0,
18591767 0x00000030);
1768+
1769+ /* EMIF SDRAM Extension
1770+ 0x00
1771+ 31-21 0000b 0000b 000b
1772+ 20 WR2RD = 2cycles-1 = 1b
1773+
1774+ 19-18 WR2DEAC = 3cycle-1 = 10b
1775+ 17 WR2WR = 2cycle-1 = 1b
1776+ 16-15 R2WDQM = 4cycle-1 = 11b
1777+ 14-12 RD2WR = 6cycles-1 = 101b
1778+
1779+ 11-10 RD2DEAC = 4cycle-1 = 11b
1780+ 9 RD2RD = 2cycle-1 = 1b
1781+ 8-7 THZP = 3cycle-1 = 10b
1782+ 6-5 TWR = 2cycle-1 = 01b (tWR = 17ns)
1783+ 4 TRRD = 2cycle = 0b (tRRD = 14ns)
1784+ 3-1 TRAS = 5cycle-1 = 100b (Tras=42ns)
1785+ 1 CAS latency = 3cyc = 1b
1786+ (for Micron 2M32-7 operating at 100MHz)
1787+ */
18601788 boot_loader_write_mem32(pao, dsp_index, C6713_EMIF_SDRAMEXT,
18611789 0x001BDF29);
1790+
1791+ /* EMIF SDRAM control - set up for a 2Mx32 SDRAM (512x32x4 bank)
1792+ 31 - 0b -
1793+ 30 SDBSZ 1b 4 bank
1794+ 29..28 SDRSZ 00b 11 row address pins
1795+
1796+ 27..26 SDCSZ 01b 8 column address pins
1797+ 25 RFEN 1b refersh enabled
1798+ 24 INIT 1b init SDRAM!
1799+
1800+ 23..20 TRCD 0001b (Trcd/Tcyc)-1 = (20/10)-1 = 1
1801+
1802+ 19..16 TRP 0001b (Trp/Tcyc)-1 = (20/10)-1 = 1
1803+
1804+ 15..12 TRC 0110b (Trc/Tcyc)-1 = (70/10)-1 = 6
1805+
1806+ 11..0 - 0000b 0000b 0000b
1807+ */
18621808 boot_loader_write_mem32(pao, dsp_index, C6713_EMIF_SDRAMCTL,
1863− 0x47117000);
1809+ 0x47116000);
1810+
1811+ /* SDRAM refresh timing
1812+ Need 4,096 refresh cycles every 64ms = 15.625us = 1562cycles of 100MHz = 0x61A
1813+ */
18641814 boot_loader_write_mem32(pao, dsp_index,
18651815 C6713_EMIF_SDRAMTIMING, 0x00000410);
18661816
18671817 hpios_delay_micro_seconds(1000);
18681818 } else if (dsp_index == 2) {
18691819 /* DSP 2 is a C6713 */
1820+ }
18701821
1871− } else
1872− err = hpi6205_error(dsp_index, HPI6205_ERROR_BAD_DSPINDEX);
1873− return err;
1822+ return 0;
18741823 }
18751824
18761825 static u16 boot_loader_test_memory(struct hpi_adapter_obj *pao, int dsp_index,
@@ -1896,7 +1845,7 @@ static u16 boot_loader_test_memory(struct hpi_adapter_obj *pao, int dsp_index, · 19 unmodified lines
18961845 test_addr);
18971846 if (data != test_data) {
18981847 HPI_DEBUG_LOG(VERBOSE,
1899− "memtest error details "
1848+ "Memtest error details "
19001849 "%08x %08x %08x %i\n", test_addr,
19011850 test_data, data, dsp_index);
19021851 return 1; /* error */
@@ -1916,7 +1865,7 @@ static u16 boot_loader_test_memory(struct hpi_adapter_obj *pao, int dsp_index, · 13 unmodified lines
19161865 data = boot_loader_read_mem32(pao, dsp_index, test_addr);
19171866 if (data != test_data) {
19181867 HPI_DEBUG_LOG(VERBOSE,
1919− "memtest error details "
1868+ "Memtest error details "
19201869 "%08x %08x %08x %i\n", test_addr, test_data,
19211870 data, dsp_index);
19221871 return 1; /* error */
@@ -1946,8 +1895,8 @@ static u16 boot_loader_test_internal_memory(struct hpi_adapter_obj *pao, · 23 unmodified lines
19461895 /* 64K data mem */
19471896 err = boot_loader_test_memory(pao, dsp_index,
19481897 0x80000000, 0x10000);
1949− } else if ((dsp_index == 1) || (dsp_index == 2)) {
1950− /* DSP 1&2 are a C6713 */
1898+ } else if (dsp_index == 1) {
1899+ /* DSP 1 is a C6713 */
19511900 /* 192K internal mem */
19521901 err = boot_loader_test_memory(pao, dsp_index, 0x00000000,
19531902 0x30000);
@@ -1955,11 +1904,10 @@ static u16 boot_loader_test_internal_memory(struct hpi_adapter_obj *pao, · 1 unmodified line
19551904 /* 64K internal mem / L2 cache */
19561905 err = boot_loader_test_memory(pao, dsp_index,
19571906 0x00030000, 0x10000);
1958− } else
1959− return hpi6205_error(dsp_index, HPI6205_ERROR_BAD_DSPINDEX);
1907+ }
19601908
19611909 if (err)
1962− return hpi6205_error(dsp_index, HPI6205_ERROR_DSP_INTMEM);
1910+ return HPI6205_ERROR_DSP_INTMEM;
19631911 else
19641912 return 0;
19651913 }
@@ -1972,24 +1920,23 @@ static u16 boot_loader_test_external_memory(struct hpi_adapter_obj *pao, · 6 unmodified lines
19721920
19731921 if (dsp_index == 0) {
19741922 /* only test for SDRAM if an ASI5000 card */
1975− if (pao->pci.subsys_device_id == 0x5000) {
1923+ if (pao->pci.pci_dev->subsystem_device == 0x5000) {
19761924 /* DSP 0 is always C6205 */
19771925 dRAM_start_address = 0x00400000;
19781926 dRAM_size = 0x200000;
19791927 /*dwDRAMinc=1024; */
19801928 } else
19811929 return 0;
1982− } else if ((dsp_index == 1) || (dsp_index == 2)) {
1930+ } else if (dsp_index == 1) {
19831931 /* DSP 1 is a C6713 */
19841932 dRAM_start_address = 0x80000000;
19851933 dRAM_size = 0x200000;
19861934 /*dwDRAMinc=1024; */
1987− } else
1988− return hpi6205_error(dsp_index, HPI6205_ERROR_BAD_DSPINDEX);
1935+ }
19891936
19901937 if (boot_loader_test_memory(pao, dsp_index, dRAM_start_address,
19911938 dRAM_size))
1992− return hpi6205_error(dsp_index, HPI6205_ERROR_DSP_EXTMEM);
1939+ return HPI6205_ERROR_DSP_EXTMEM;
19931940 return 0;
19941941 }
19951942
@@ -1998,28 +1945,25 @@ static u16 boot_loader_test_pld(struct hpi_adapter_obj *pao, int dsp_index) · 2 unmodified lines
19981945 u32 data = 0;
19991946 if (dsp_index == 0) {
20001947 /* only test for DSP0 PLD on ASI5000 card */
2001− if (pao->pci.subsys_device_id == 0x5000) {
1948+ if (pao->pci.pci_dev->subsystem_device == 0x5000) {
20021949 /* PLD is located at CE3=0x03000000 */
20031950 data = boot_loader_read_mem32(pao, dsp_index,
20041951 0x03000008);
20051952 if ((data & 0xF) != 0x5)
2006− return hpi6205_error(dsp_index,
2007− HPI6205_ERROR_DSP_PLD);
1953+ return HPI6205_ERROR_DSP_PLD;
20081954 data = boot_loader_read_mem32(pao, dsp_index,
20091955 0x0300000C);
20101956 if ((data & 0xF) != 0xA)
2011− return hpi6205_error(dsp_index,
2012− HPI6205_ERROR_DSP_PLD);
1957+ return HPI6205_ERROR_DSP_PLD;
20131958 }
20141959 } else if (dsp_index == 1) {
20151960 /* DSP 1 is a C6713 */
2016− if (pao->pci.subsys_device_id == 0x8700) {
1961+ if (pao->pci.pci_dev->subsystem_device == 0x8700) {
20171962 /* PLD is located at CE1=0x90000000 */
20181963 data = boot_loader_read_mem32(pao, dsp_index,
20191964 0x90000010);
20201965 if ((data & 0xFF) != 0xAA)
2021− return hpi6205_error(dsp_index,
2022− HPI6205_ERROR_DSP_PLD);
1966+ return HPI6205_ERROR_DSP_PLD;
20231967 /* 8713 - LED on */
20241968 boot_loader_write_mem32(pao, dsp_index, 0x90000000,
20251969 0x02);
@@ -2037,14 +1981,11 @@ static short hpi6205_transfer_data(struct hpi_adapter_obj *pao, u8 *p_data, · 11 unmodified lines
20371981 struct hpi_hw_obj *phw = pao->priv;
20381982 u32 data_transferred = 0;
20391983 u16 err = 0;
2040−#ifndef HPI6205_NO_HSR_POLL
2041− u32 time_out;
2042−#endif
20431984 u32 temp2;
20441985 struct bus_master_interface *interface = phw->p_interface_buffer;
20451986
20461987 if (!p_data)
2047− return HPI_ERROR_INVALID_DATA_TRANSFER;
1988+ return HPI_ERROR_INVALID_DATA_POINTER;
20481989
20491990 data_size &= ~3L; /* round data_size down to nearest 4 bytes */
20501991
@@ -2064,14 +2005,10 @@ static short hpi6205_transfer_data(struct hpi_adapter_obj *pao, u8 *p_data, · 13 unmodified lines
20642005
20652006 interface->transfer_size_in_bytes = this_copy;
20662007
2067−#ifdef HPI6205_NO_HSR_POLL
20682008 /* DSP must change this back to nOperation */
20692009 interface->dsp_ack = H620_HIF_IDLE;
2070−#endif
2071−
20722010 send_dsp_command(phw, operation);
20732011
2074−#ifdef HPI6205_NO_HSR_POLL
20752012 temp2 = wait_dsp_ack(phw, operation, HPI6205_TIMEOUT);
20762013 HPI_DEBUG_LOG(DEBUG, "spun %d times for data xfer of %d\n",
20772014 HPI6205_TIMEOUT - temp2, this_copy);
@@ -2079,45 +2016,11 @@ static short hpi6205_transfer_data(struct hpi_adapter_obj *pao, u8 *p_data, · 1 unmodified line
20792016 if (!temp2) {
20802017 /* timed out */
20812018 HPI_DEBUG_LOG(ERROR,
2082− "timed out waiting for " "state %d got %d\n",
2019+ "Timed out waiting for " "state %d got %d\n",
20832020 operation, interface->dsp_ack);
20842021
20852022 break;
20862023 }
2087−#else
2088− /* spin waiting on the result */
2089− time_out = HPI6205_TIMEOUT;
2090− temp2 = 0;
2091− while ((temp2 == 0) && time_out--) {
2092− /* give 16k bus mastering transfer time to happen */
2093− /*(16k / 132Mbytes/s = 122usec) */
2094− hpios_delay_micro_seconds(20);
2095− temp2 = ioread32(phw->prHSR);
2096− temp2 &= C6205_HSR_INTSRC;
2097− }
2098− HPI_DEBUG_LOG(DEBUG, "spun %d times for data xfer of %d\n",
2099− HPI6205_TIMEOUT - time_out, this_copy);
2100− if (temp2 == C6205_HSR_INTSRC) {
2101− HPI_DEBUG_LOG(VERBOSE,
2102− "interrupt from HIF <data> OK\n");
2103− /*
2104− if(interface->dwDspAck != nOperation) {
2105− HPI_DEBUG_LOG(DEBUG("interface->dwDspAck=%d,
2106− expected %d \n",
2107− interface->dwDspAck,nOperation);
2108− }
2109− */
2110− }
2111−/* need to handle this differently... */
2112− else {
2113− HPI_DEBUG_LOG(ERROR,
2114− "interrupt from HIF <data> BAD\n");
2115− err = HPI_ERROR_DSP_HARDWARE;
2116− }
2117−
2118− /* reset the interrupt from the DSP */
2119− iowrite32(C6205_HSR_INTSRC, phw->prHSR);
2120−#endif
21212024 if (operation == H620_HIF_GET_DATA)
21222025 memcpy(&p_data[data_transferred],
21232026 (void *)&interface->u.b_data[0], this_copy);
@@ -2174,31 +2077,39 @@ static unsigned int message_count; · 50 unmodified lines
21742077 static u16 message_response_sequence(struct hpi_adapter_obj *pao,
21752078 struct hpi_message *phm, struct hpi_response *phr)
21762079 {
2177−#ifndef HPI6205_NO_HSR_POLL
2178− u32 temp2;
2179−#endif
21802080 u32 time_out, time_out2;
21812081 struct hpi_hw_obj *phw = pao->priv;
21822082 struct bus_master_interface *interface = phw->p_interface_buffer;
21832083 u16 err = 0;
21842084
21852085 message_count++;
2086+ if (phm->size > sizeof(interface->u)) {
2087+ phr->error = HPI_ERROR_MESSAGE_BUFFER_TOO_SMALL;
2088+ phr->specific_error = sizeof(interface->u);
2089+ phr->size = sizeof(struct hpi_response_header);
2090+ HPI_DEBUG_LOG(ERROR,
2091+ "message len %d too big for buffer %zd \n", phm->size,
2092+ sizeof(interface->u));
2093+ return 0;
2094+ }
2095+
21862096 /* Assume buffer of type struct bus_master_interface
21872097 is allocated "noncacheable" */
21882098
21892099 if (!wait_dsp_ack(phw, H620_HIF_IDLE, HPI6205_TIMEOUT)) {
21902100 HPI_DEBUG_LOG(DEBUG, "timeout waiting for idle\n");
2191− return hpi6205_error(0, HPI6205_ERROR_MSG_RESP_IDLE_TIMEOUT);
2101+ return HPI6205_ERROR_MSG_RESP_IDLE_TIMEOUT;
21922102 }
2193− interface->u.message_buffer = *phm;
2103+
2104+ memcpy(&interface->u.message_buffer, phm, phm->size);
21942105 /* signal we want a response */
21952106 send_dsp_command(phw, H620_HIF_GET_RESP);
21962107
21972108 time_out2 = wait_dsp_ack(phw, H620_HIF_GET_RESP, HPI6205_TIMEOUT);
21982109
2199− if (time_out2 == 0) {
2110+ if (!time_out2) {
22002111 HPI_DEBUG_LOG(ERROR,
2201− "(%u) timed out waiting for " "GET_RESP state [%x]\n",
2112+ "(%u) Timed out waiting for " "GET_RESP state [%x]\n",
22022113 message_count, interface->dsp_ack);
22032114 } else {
22042115 HPI_DEBUG_LOG(VERBOSE,
@@ -2208,58 +2119,38 @@ static u16 message_response_sequence(struct hpi_adapter_obj *pao, · 3 unmodified lines
22082119 /* spin waiting on HIF interrupt flag (end of msg process) */
22092120 time_out = HPI6205_TIMEOUT;
22102121
2211−#ifndef HPI6205_NO_HSR_POLL
2212− temp2 = 0;
2213− while ((temp2 == 0) && --time_out) {
2214− temp2 = ioread32(phw->prHSR);
2215− temp2 &= C6205_HSR_INTSRC;
2216− hpios_delay_micro_seconds(1);
2217− }
2218− if (temp2 == C6205_HSR_INTSRC) {
2219− rmb(); /* ensure we see latest value for dsp_ack */
2220− if ((interface->dsp_ack != H620_HIF_GET_RESP)) {
2221− HPI_DEBUG_LOG(DEBUG,
2222− "(%u)interface->dsp_ack(0x%x) != "
2223− "H620_HIF_GET_RESP, t=%u\n", message_count,
2224− interface->dsp_ack,
2225− HPI6205_TIMEOUT - time_out);
2226− } else {
2227− HPI_DEBUG_LOG(VERBOSE,
2228− "(%u)int with GET_RESP after %u\n",
2229− message_count, HPI6205_TIMEOUT - time_out);
2122+ /* read the result */
2123+ if (time_out) {
2124+ if (interface->u.response_buffer.size <= phr->size)
2125+ memcpy(phr, &interface->u.response_buffer,
2126+ interface->u.response_buffer.size);
2127+ else {
2128+ HPI_DEBUG_LOG(ERROR,
2129+ "response len %d too big for buffer %d\n",
2130+ interface->u.response_buffer.size, phr->size);
2131+ memcpy(phr, &interface->u.response_buffer,
2132+ sizeof(struct hpi_response_header));
2133+ phr->error = HPI_ERROR_RESPONSE_BUFFER_TOO_SMALL;
2134+ phr->specific_error =
2135+ interface->u.response_buffer.size;
2136+ phr->size = sizeof(struct hpi_response_header);
22302137 }
2231−
2232− } else {
2233− /* can we do anything else in response to the error ? */
2234− HPI_DEBUG_LOG(ERROR,
2235− "interrupt from HIF module BAD (function %x)\n",
2236− phm->function);
22372138 }
2238−
2239− /* reset the interrupt from the DSP */
2240− iowrite32(C6205_HSR_INTSRC, phw->prHSR);
2241−#endif
2242−
2243− /* read the result */
2244− if (time_out != 0)
2245− *phr = interface->u.response_buffer;
2246−
22472139 /* set interface back to idle */
22482140 send_dsp_command(phw, H620_HIF_IDLE);
22492141
2250− if ((time_out == 0) || (time_out2 == 0)) {
2142+ if (!time_out || !time_out2) {
22512143 HPI_DEBUG_LOG(DEBUG, "something timed out!\n");
2252− return hpi6205_error(0, HPI6205_ERROR_MSG_RESP_TIMEOUT);
2144+ return HPI6205_ERROR_MSG_RESP_TIMEOUT;
22532145 }
22542146 /* special case for adapter close - */
22552147 /* wait for the DSP to indicate it is idle */
22562148 if (phm->function == HPI_ADAPTER_CLOSE) {
22572149 if (!wait_dsp_ack(phw, H620_HIF_IDLE, HPI6205_TIMEOUT)) {
22582150 HPI_DEBUG_LOG(DEBUG,
2259− "timeout waiting for idle "
2151+ "Timeout waiting for idle "
22602152 "(on adapter_close)\n");
2261− return hpi6205_error(0,
2262− HPI6205_ERROR_MSG_RESP_IDLE_TIMEOUT);
2153+ return HPI6205_ERROR_MSG_RESP_IDLE_TIMEOUT;
22632154 }
22642155 }
22652156 err = hpi_validate_response(phm, phr);
@@ -2279,7 +2170,13 @@ static void hw_message(struct hpi_adapter_obj *pao, struct hpi_message *phm, · 13 unmodified lines
22792170 /* maybe an error response */
22802171 if (err) {
22812172 /* something failed in the HPI/DSP interface */
2282− phr->error = err;
2173+ if (err >= HPI_ERROR_BACKEND_BASE) {
2174+ phr->error = HPI_ERROR_DSP_COMMUNICATION;
2175+ phr->specific_error = err;
2176+ } else {
2177+ phr->error = err;
2178+ }
2179+
22832180 pao->dsp_crashed++;
22842181
22852182 /* just the header of the response is valid */
sound/pci/asihpi/hpi6205.h+2−5
@@ -25,9 +25,6 @@ Copyright AudioScience, Inc., 2003 · 24 unmodified lines
2525 #ifndef _HPI6205_H_
2626 #define _HPI6205_H_
2727
28−/* transitional conditional compile shared between host and DSP */
29−/* #define HPI6205_NO_HSR_POLL */
30−
3128 #include "hpi_internal.h"
3229
3330 /***********************************************************
@@ -78,8 +75,8 @@ struct bus_master_interface { · 44 unmodified lines
7875 u32 dsp_ack;
7976 u32 transfer_size_in_bytes;
8077 union {
81− struct hpi_message message_buffer;
82− struct hpi_response response_buffer;
78+ struct hpi_message_header message_buffer;
79+ struct hpi_response_header response_buffer;
8380 u8 b_data[HPI6205_SIZEOF_DATA];
8481 } u;
8582 struct controlcache_6205 control_cache;
sound/pci/asihpi/hpi_internal.h+530−588
@@ -28,7 +28,7 @@ HPI internal definitions · 27 unmodified lines
2828 /** maximum number of memory regions mapped to an adapter */
2929 #define HPI_MAX_ADAPTER_MEM_SPACES (2)
3030
31−/* Each OS needs its own hpios.h, or specific define as above */
31+/* Each OS needs its own hpios.h */
3232 #include "hpios.h"
3333
3434 /* physical memory allocation */
@@ -49,7 +49,7 @@ HpiOs_LockedMem_GetPyhsAddr() will always succed on the returned handle. · 14 unmodified lines
4949 */
5050 u16 hpios_locked_mem_alloc(struct consistent_dma_area *p_locked_mem_handle,
5151 /**< memory handle */
52− u32 size, /**< size in bytes to allocate */
52+ u32 size, /**< Size in bytes to allocate */
5353 struct pci_dev *p_os_reference
5454 /**< OS specific data required for memory allocation */
5555 );
@@ -96,41 +96,6 @@ typedef void hpi_handler_func(struct hpi_message *, struct hpi_response *); · 40 unmodified lines
9696 #define compile_time_assert(cond, msg) \
9797 typedef char ASSERT_##msg[(cond) ? 1 : -1]
9898
99−/*/////////////////////////////////////////////////////////////////////////// */
100−/* Private HPI Entity related definitions */
101−
102−#define STR_SIZE_FIELD_MAX 65535U
103−#define STR_TYPE_FIELD_MAX 255U
104−#define STR_ROLE_FIELD_MAX 255U
105−
106−struct hpi_entity_str {
107− u16 size;
108− u8 type;
109− u8 role;
110−};
111−
112−#if defined(_MSC_VER)
113−#pragma warning(push)
114−#pragma warning(disable : 4200)
115−#endif
116−
117−struct hpi_entity {
118− struct hpi_entity_str header;
119−#if ! defined(HPI_OS_DSP_C6000) || (defined(HPI_OS_DSP_C6000) && (__TI_COMPILER_VERSION__ > 6000008))
120− /* DSP C6000 compiler v6.0.8 and lower
121− do not support flexible array member */
122− u8 value[];
123−#else
124− /* NOTE! Using sizeof(struct hpi_entity) will give erroneous results */
125−#define HPI_INTERNAL_WARN_ABOUT_ENTITY_VALUE
126− u8 value[1];
127−#endif
128−};
129−
130−#if defined(_MSC_VER)
131−#pragma warning(pop)
132−#endif
133−
13499 /******************************************* bus types */
135100 enum HPI_BUSES {
136101 HPI_BUS_ISAPNP = 1,
@@ -139,206 +104,155 @@ enum HPI_BUSES { · 2 unmodified lines
139104 HPI_BUS_NET = 4
140105 };
141106
107+enum HPI_SUBSYS_OPTIONS {
108+ /* 0, 256 are invalid, 1..255 reserved for global options */
109+ HPI_SUBSYS_OPT_NET_ENABLE = 257,
110+ HPI_SUBSYS_OPT_NET_BROADCAST = 258,
111+ HPI_SUBSYS_OPT_NET_UNICAST = 259,
112+ HPI_SUBSYS_OPT_NET_ADDR = 260,
113+ HPI_SUBSYS_OPT_NET_MASK = 261,
114+ HPI_SUBSYS_OPT_NET_ADAPTER_ADDRESS_ADD = 262
115+};
116+
117+/** Volume flags
118+*/
119+enum HPI_VOLUME_FLAGS {
120+ /** Set if the volume control is muted */
121+ HPI_VOLUME_FLAG_MUTED = (1 << 0),
122+ /** Set if the volume control has a mute function */
123+ HPI_VOLUME_FLAG_HAS_MUTE = (1 << 1),
124+ /** Set if volume control can do autofading */
125+ HPI_VOLUME_FLAG_HAS_AUTOFADE = (1 << 2)
126+ /* Note Flags >= (1<<8) are for DSP internal use only */
127+};
128+
142129 /******************************************* CONTROL ATTRIBUTES ****/
143130 /* (in order of control type ID */
144131
145132 /* This allows for 255 control types, 256 unique attributes each */
146−#define HPI_CTL_ATTR(ctl, ai) (HPI_CONTROL_##ctl * 0x100 + ai)
133+#define HPI_CTL_ATTR(ctl, ai) ((HPI_CONTROL_##ctl << 8) + ai)
147134
148135 /* Get the sub-index of the attribute for a control type */
149−#define HPI_CTL_ATTR_INDEX(i) (i&0xff)
136+#define HPI_CTL_ATTR_INDEX(i) (i & 0xff)
150137
151138 /* Extract the control from the control attribute */
152−#define HPI_CTL_ATTR_CONTROL(i) (i>>8)
153−
154−/* Generic control attributes. */
155−
156−/** Enable a control.
157−0=disable, 1=enable
158−\note generic to all mixer plugins?
159−*/
160−#define HPI_GENERIC_ENABLE HPI_CTL_ATTR(GENERIC, 1)
139+#define HPI_CTL_ATTR_CONTROL(i) (i >> 8)
161140
162141 /** Enable event generation for a control.
163142 0=disable, 1=enable
164143 \note generic to all controls that can generate events
165144 */
166−#define HPI_GENERIC_EVENT_ENABLE HPI_CTL_ATTR(GENERIC, 2)
167−
168−/* Volume Control attributes */
169−#define HPI_VOLUME_GAIN HPI_CTL_ATTR(VOLUME, 1)
170−#define HPI_VOLUME_AUTOFADE HPI_CTL_ATTR(VOLUME, 2)
171−
172−/** For HPI_ControlQuery() to get the number of channels of a volume control*/
173−#define HPI_VOLUME_NUM_CHANNELS HPI_CTL_ATTR(VOLUME, 6)
174−#define HPI_VOLUME_RANGE HPI_CTL_ATTR(VOLUME, 10)
175−
176−/** Level Control attributes */
177−#define HPI_LEVEL_GAIN HPI_CTL_ATTR(LEVEL, 1)
178−#define HPI_LEVEL_RANGE HPI_CTL_ATTR(LEVEL, 10)
179−
180−/* Meter Control attributes */
181−/** return RMS signal level */
182−#define HPI_METER_RMS HPI_CTL_ATTR(METER, 1)
183−/** return peak signal level */
184−#define HPI_METER_PEAK HPI_CTL_ATTR(METER, 2)
185−/** ballistics for ALL rms meters on adapter */
186−#define HPI_METER_RMS_BALLISTICS HPI_CTL_ATTR(METER, 3)
187−/** ballistics for ALL peak meters on adapter */
188−#define HPI_METER_PEAK_BALLISTICS HPI_CTL_ATTR(METER, 4)
189−
190−/** For HPI_ControlQuery() to get the number of channels of a meter control*/
191−#define HPI_METER_NUM_CHANNELS HPI_CTL_ATTR(METER, 5)
192−
193−/* Multiplexer control attributes */
194−#define HPI_MULTIPLEXER_SOURCE HPI_CTL_ATTR(MULTIPLEXER, 1)
195−#define HPI_MULTIPLEXER_QUERYSOURCE HPI_CTL_ATTR(MULTIPLEXER, 2)
196−
197−/** AES/EBU transmitter control attributes */
198−/** AESEBU or SPDIF */
199−#define HPI_AESEBUTX_FORMAT HPI_CTL_ATTR(AESEBUTX, 1)
200−#define HPI_AESEBUTX_SAMPLERATE HPI_CTL_ATTR(AESEBUTX, 3)
201−#define HPI_AESEBUTX_CHANNELSTATUS HPI_CTL_ATTR(AESEBUTX, 4)
202−#define HPI_AESEBUTX_USERDATA HPI_CTL_ATTR(AESEBUTX, 5)
203−
204−/** AES/EBU receiver control attributes */
205−#define HPI_AESEBURX_FORMAT HPI_CTL_ATTR(AESEBURX, 1)
206−#define HPI_AESEBURX_ERRORSTATUS HPI_CTL_ATTR(AESEBURX, 2)
207−#define HPI_AESEBURX_SAMPLERATE HPI_CTL_ATTR(AESEBURX, 3)
208−#define HPI_AESEBURX_CHANNELSTATUS HPI_CTL_ATTR(AESEBURX, 4)
209−#define HPI_AESEBURX_USERDATA HPI_CTL_ATTR(AESEBURX, 5)
210−
211−/** \defgroup tuner_defs Tuners
212−\{
213−*/
214−/** \defgroup tuner_attrs Tuner control attributes
215−\{
216−*/
217−#define HPI_TUNER_BAND HPI_CTL_ATTR(TUNER, 1)
218−#define HPI_TUNER_FREQ HPI_CTL_ATTR(TUNER, 2)
219−#define HPI_TUNER_LEVEL HPI_CTL_ATTR(TUNER, 3)
220−#define HPI_TUNER_AUDIOMUTE HPI_CTL_ATTR(TUNER, 4)
221−/* use TUNER_STATUS instead */
222−#define HPI_TUNER_VIDEO_STATUS HPI_CTL_ATTR(TUNER, 5)
223−#define HPI_TUNER_GAIN HPI_CTL_ATTR(TUNER, 6)
224−#define HPI_TUNER_STATUS HPI_CTL_ATTR(TUNER, 7)
225−#define HPI_TUNER_MODE HPI_CTL_ATTR(TUNER, 8)
226−/** RDS data. */
227−#define HPI_TUNER_RDS HPI_CTL_ATTR(TUNER, 9)
228−/** Audio pre-emphasis. */
229−#define HPI_TUNER_DEEMPHASIS HPI_CTL_ATTR(TUNER, 10)
230−/** HD Radio tuner program control. */
231−#define HPI_TUNER_PROGRAM HPI_CTL_ATTR(TUNER, 11)
232−/** HD Radio tuner digital signal quality. */
233−#define HPI_TUNER_HDRADIO_SIGNAL_QUALITY HPI_CTL_ATTR(TUNER, 12)
234−/** HD Radio SDK firmware version. */
235−#define HPI_TUNER_HDRADIO_SDK_VERSION HPI_CTL_ATTR(TUNER, 13)
236−/** HD Radio DSP firmware version. */
237−#define HPI_TUNER_HDRADIO_DSP_VERSION HPI_CTL_ATTR(TUNER, 14)
238−/** HD Radio signal blend (force analog, or automatic). */
239−#define HPI_TUNER_HDRADIO_BLEND HPI_CTL_ATTR(TUNER, 15)
240−
241−/** \} */
242−
243−/** \defgroup pads_attrs Tuner PADs control attributes
244−\{
245−*/
246−/** The text string containing the station/channel combination. */
247−#define HPI_PAD_CHANNEL_NAME HPI_CTL_ATTR(PAD, 1)
248−/** The text string containing the artist. */
249−#define HPI_PAD_ARTIST HPI_CTL_ATTR(PAD, 2)
250−/** The text string containing the title. */
251−#define HPI_PAD_TITLE HPI_CTL_ATTR(PAD, 3)
252−/** The text string containing the comment. */
253−#define HPI_PAD_COMMENT HPI_CTL_ATTR(PAD, 4)
254−/** The integer containing the PTY code. */
255−#define HPI_PAD_PROGRAM_TYPE HPI_CTL_ATTR(PAD, 5)
256−/** The integer containing the program identification. */
257−#define HPI_PAD_PROGRAM_ID HPI_CTL_ATTR(PAD, 6)
258−/** The integer containing whether traffic information is supported.
259−Contains either 1 or 0. */
260−#define HPI_PAD_TA_SUPPORT HPI_CTL_ATTR(PAD, 7)
261−/** The integer containing whether traffic announcement is in progress.
262−Contains either 1 or 0. */
263−#define HPI_PAD_TA_ACTIVE HPI_CTL_ATTR(PAD, 8)
264−/** \} */
265−/** \} */
266−
267−/* VOX control attributes */
268−#define HPI_VOX_THRESHOLD HPI_CTL_ATTR(VOX, 1)
269−
270−/*?? channel mode used hpi_multiplexer_source attribute == 1 */
271−#define HPI_CHANNEL_MODE_MODE HPI_CTL_ATTR(CHANNEL_MODE, 1)
272−
273−/** \defgroup channel_modes Channel Modes
274−Used for HPI_ChannelModeSet/Get()
275−\{
145+
146+/** Unique identifiers for every control attribute
276147 */
277−/** Left channel out = left channel in, Right channel out = right channel in. */
278−#define HPI_CHANNEL_MODE_NORMAL 1
279−/** Left channel out = right channel in, Right channel out = left channel in. */
280−#define HPI_CHANNEL_MODE_SWAP 2
281−/** Left channel out = left channel in, Right channel out = left channel in. */
282−#define HPI_CHANNEL_MODE_LEFT_TO_STEREO 3
283−/** Left channel out = right channel in, Right channel out = right channel in.*/
284−#define HPI_CHANNEL_MODE_RIGHT_TO_STEREO 4
285−/** Left channel out = (left channel in + right channel in)/2,
286− Right channel out = mute. */
287−#define HPI_CHANNEL_MODE_STEREO_TO_LEFT 5
288−/** Left channel out = mute,
289− Right channel out = (right channel in + left channel in)/2. */
290−#define HPI_CHANNEL_MODE_STEREO_TO_RIGHT 6
291−#define HPI_CHANNEL_MODE_LAST 6
292−/** \} */
293−
294−/* Bitstream control set attributes */
295−#define HPI_BITSTREAM_DATA_POLARITY HPI_CTL_ATTR(BITSTREAM, 1)
296−#define HPI_BITSTREAM_CLOCK_EDGE HPI_CTL_ATTR(BITSTREAM, 2)
297−#define HPI_BITSTREAM_CLOCK_SOURCE HPI_CTL_ATTR(BITSTREAM, 3)
148+enum HPI_CONTROL_ATTRIBUTES {
149+ HPI_GENERIC_ENABLE = HPI_CTL_ATTR(GENERIC, 1),
150+ HPI_GENERIC_EVENT_ENABLE = HPI_CTL_ATTR(GENERIC, 2),
151+
152+ HPI_VOLUME_GAIN = HPI_CTL_ATTR(VOLUME, 1),
153+ HPI_VOLUME_AUTOFADE = HPI_CTL_ATTR(VOLUME, 2),
154+ HPI_VOLUME_MUTE = HPI_CTL_ATTR(VOLUME, 3),
155+ HPI_VOLUME_GAIN_AND_FLAGS = HPI_CTL_ATTR(VOLUME, 4),
156+ HPI_VOLUME_NUM_CHANNELS = HPI_CTL_ATTR(VOLUME, 6),
157+ HPI_VOLUME_RANGE = HPI_CTL_ATTR(VOLUME, 10),
158+
159+ HPI_METER_RMS = HPI_CTL_ATTR(METER, 1),
160+ HPI_METER_PEAK = HPI_CTL_ATTR(METER, 2),
161+ HPI_METER_RMS_BALLISTICS = HPI_CTL_ATTR(METER, 3),
162+ HPI_METER_PEAK_BALLISTICS = HPI_CTL_ATTR(METER, 4),
163+ HPI_METER_NUM_CHANNELS = HPI_CTL_ATTR(METER, 5),
164+
165+ HPI_MULTIPLEXER_SOURCE = HPI_CTL_ATTR(MULTIPLEXER, 1),
166+ HPI_MULTIPLEXER_QUERYSOURCE = HPI_CTL_ATTR(MULTIPLEXER, 2),
167+
168+ HPI_AESEBUTX_FORMAT = HPI_CTL_ATTR(AESEBUTX, 1),
169+ HPI_AESEBUTX_SAMPLERATE = HPI_CTL_ATTR(AESEBUTX, 3),
170+ HPI_AESEBUTX_CHANNELSTATUS = HPI_CTL_ATTR(AESEBUTX, 4),
171+ HPI_AESEBUTX_USERDATA = HPI_CTL_ATTR(AESEBUTX, 5),
172+
173+ HPI_AESEBURX_FORMAT = HPI_CTL_ATTR(AESEBURX, 1),
174+ HPI_AESEBURX_ERRORSTATUS = HPI_CTL_ATTR(AESEBURX, 2),
175+ HPI_AESEBURX_SAMPLERATE = HPI_CTL_ATTR(AESEBURX, 3),
176+ HPI_AESEBURX_CHANNELSTATUS = HPI_CTL_ATTR(AESEBURX, 4),
177+ HPI_AESEBURX_USERDATA = HPI_CTL_ATTR(AESEBURX, 5),
178+
179+ HPI_LEVEL_GAIN = HPI_CTL_ATTR(LEVEL, 1),
180+ HPI_LEVEL_RANGE = HPI_CTL_ATTR(LEVEL, 10),
181+
182+ HPI_TUNER_BAND = HPI_CTL_ATTR(TUNER, 1),
183+ HPI_TUNER_FREQ = HPI_CTL_ATTR(TUNER, 2),
184+ HPI_TUNER_LEVEL_AVG = HPI_CTL_ATTR(TUNER, 3),
185+ HPI_TUNER_LEVEL_RAW = HPI_CTL_ATTR(TUNER, 4),
186+ HPI_TUNER_SNR = HPI_CTL_ATTR(TUNER, 5),
187+ HPI_TUNER_GAIN = HPI_CTL_ATTR(TUNER, 6),
188+ HPI_TUNER_STATUS = HPI_CTL_ATTR(TUNER, 7),
189+ HPI_TUNER_MODE = HPI_CTL_ATTR(TUNER, 8),
190+ HPI_TUNER_RDS = HPI_CTL_ATTR(TUNER, 9),
191+ HPI_TUNER_DEEMPHASIS = HPI_CTL_ATTR(TUNER, 10),
192+ HPI_TUNER_PROGRAM = HPI_CTL_ATTR(TUNER, 11),
193+ HPI_TUNER_HDRADIO_SIGNAL_QUALITY = HPI_CTL_ATTR(TUNER, 12),
194+ HPI_TUNER_HDRADIO_SDK_VERSION = HPI_CTL_ATTR(TUNER, 13),
195+ HPI_TUNER_HDRADIO_DSP_VERSION = HPI_CTL_ATTR(TUNER, 14),
196+ HPI_TUNER_HDRADIO_BLEND = HPI_CTL_ATTR(TUNER, 15),
197+
198+ HPI_VOX_THRESHOLD = HPI_CTL_ATTR(VOX, 1),
199+
200+ HPI_CHANNEL_MODE_MODE = HPI_CTL_ATTR(CHANNEL_MODE, 1),
201+
202+ HPI_BITSTREAM_DATA_POLARITY = HPI_CTL_ATTR(BITSTREAM, 1),
203+ HPI_BITSTREAM_CLOCK_EDGE = HPI_CTL_ATTR(BITSTREAM, 2),
204+ HPI_BITSTREAM_CLOCK_SOURCE = HPI_CTL_ATTR(BITSTREAM, 3),
205+ HPI_BITSTREAM_ACTIVITY = HPI_CTL_ATTR(BITSTREAM, 4),
206+
207+ HPI_SAMPLECLOCK_SOURCE = HPI_CTL_ATTR(SAMPLECLOCK, 1),
208+ HPI_SAMPLECLOCK_SAMPLERATE = HPI_CTL_ATTR(SAMPLECLOCK, 2),
209+ HPI_SAMPLECLOCK_SOURCE_INDEX = HPI_CTL_ATTR(SAMPLECLOCK, 3),
210+ HPI_SAMPLECLOCK_LOCAL_SAMPLERATE = HPI_CTL_ATTR(SAMPLECLOCK, 4),
211+ HPI_SAMPLECLOCK_AUTO = HPI_CTL_ATTR(SAMPLECLOCK, 5),
212+ HPI_SAMPLECLOCK_LOCAL_LOCK = HPI_CTL_ATTR(SAMPLECLOCK, 6),
213+
214+ HPI_MICROPHONE_PHANTOM_POWER = HPI_CTL_ATTR(MICROPHONE, 1),
215+
216+ HPI_EQUALIZER_NUM_FILTERS = HPI_CTL_ATTR(EQUALIZER, 1),
217+ HPI_EQUALIZER_FILTER = HPI_CTL_ATTR(EQUALIZER, 2),
218+ HPI_EQUALIZER_COEFFICIENTS = HPI_CTL_ATTR(EQUALIZER, 3),
219+
220+ HPI_COMPANDER_PARAMS = HPI_CTL_ATTR(COMPANDER, 1),
221+ HPI_COMPANDER_MAKEUPGAIN = HPI_CTL_ATTR(COMPANDER, 2),
222+ HPI_COMPANDER_THRESHOLD = HPI_CTL_ATTR(COMPANDER, 3),
223+ HPI_COMPANDER_RATIO = HPI_CTL_ATTR(COMPANDER, 4),
224+ HPI_COMPANDER_ATTACK = HPI_CTL_ATTR(COMPANDER, 5),
225+ HPI_COMPANDER_DECAY = HPI_CTL_ATTR(COMPANDER, 6),
226+
227+ HPI_COBRANET_SET = HPI_CTL_ATTR(COBRANET, 1),
228+ HPI_COBRANET_GET = HPI_CTL_ATTR(COBRANET, 2),
229+ HPI_COBRANET_SET_DATA = HPI_CTL_ATTR(COBRANET, 3),
230+ HPI_COBRANET_GET_DATA = HPI_CTL_ATTR(COBRANET, 4),
231+ HPI_COBRANET_GET_STATUS = HPI_CTL_ATTR(COBRANET, 5),
232+ HPI_COBRANET_SEND_PACKET = HPI_CTL_ATTR(COBRANET, 6),
233+ HPI_COBRANET_GET_PACKET = HPI_CTL_ATTR(COBRANET, 7),
234+
235+ HPI_TONEDETECTOR_THRESHOLD = HPI_CTL_ATTR(TONEDETECTOR, 1),
236+ HPI_TONEDETECTOR_STATE = HPI_CTL_ATTR(TONEDETECTOR, 2),
237+ HPI_TONEDETECTOR_FREQUENCY = HPI_CTL_ATTR(TONEDETECTOR, 3),
238+
239+ HPI_SILENCEDETECTOR_THRESHOLD = HPI_CTL_ATTR(SILENCEDETECTOR, 1),
240+ HPI_SILENCEDETECTOR_STATE = HPI_CTL_ATTR(SILENCEDETECTOR, 2),
241+ HPI_SILENCEDETECTOR_DELAY = HPI_CTL_ATTR(SILENCEDETECTOR, 3),
242+
243+ HPI_PAD_CHANNEL_NAME = HPI_CTL_ATTR(PAD, 1),
244+ HPI_PAD_ARTIST = HPI_CTL_ATTR(PAD, 2),
245+ HPI_PAD_TITLE = HPI_CTL_ATTR(PAD, 3),
246+ HPI_PAD_COMMENT = HPI_CTL_ATTR(PAD, 4),
247+ HPI_PAD_PROGRAM_TYPE = HPI_CTL_ATTR(PAD, 5),
248+ HPI_PAD_PROGRAM_ID = HPI_CTL_ATTR(PAD, 6),
249+ HPI_PAD_TA_SUPPORT = HPI_CTL_ATTR(PAD, 7),
250+ HPI_PAD_TA_ACTIVE = HPI_CTL_ATTR(PAD, 8)
251+};
298252
299253 #define HPI_POLARITY_POSITIVE 0
300254 #define HPI_POLARITY_NEGATIVE 1
301255
302−/* Bitstream control get attributes */
303−#define HPI_BITSTREAM_ACTIVITY 1
304−
305−/* SampleClock control attributes */
306−#define HPI_SAMPLECLOCK_SOURCE HPI_CTL_ATTR(SAMPLECLOCK, 1)
307−#define HPI_SAMPLECLOCK_SAMPLERATE HPI_CTL_ATTR(SAMPLECLOCK, 2)
308−#define HPI_SAMPLECLOCK_SOURCE_INDEX HPI_CTL_ATTR(SAMPLECLOCK, 3)
309−#define HPI_SAMPLECLOCK_LOCAL_SAMPLERATE\
310− HPI_CTL_ATTR(SAMPLECLOCK, 4)
311−#define HPI_SAMPLECLOCK_AUTO HPI_CTL_ATTR(SAMPLECLOCK, 5)
312−#define HPI_SAMPLECLOCK_LOCAL_LOCK HPI_CTL_ATTR(SAMPLECLOCK, 6)
313−
314−/* Microphone control attributes */
315−#define HPI_MICROPHONE_PHANTOM_POWER HPI_CTL_ATTR(MICROPHONE, 1)
316−
317−/** Equalizer control attributes */
318−/** Used to get number of filters in an EQ. (Can't set) */
319−#define HPI_EQUALIZER_NUM_FILTERS HPI_CTL_ATTR(EQUALIZER, 1)
320−/** Set/get the filter by type, freq, Q, gain */
321−#define HPI_EQUALIZER_FILTER HPI_CTL_ATTR(EQUALIZER, 2)
322−/** Get the biquad coefficients */
323−#define HPI_EQUALIZER_COEFFICIENTS HPI_CTL_ATTR(EQUALIZER, 3)
324−
325−/* Note compander also uses HPI_GENERIC_ENABLE */
326−#define HPI_COMPANDER_PARAMS HPI_CTL_ATTR(COMPANDER, 1)
327−#define HPI_COMPANDER_MAKEUPGAIN HPI_CTL_ATTR(COMPANDER, 2)
328−#define HPI_COMPANDER_THRESHOLD HPI_CTL_ATTR(COMPANDER, 3)
329−#define HPI_COMPANDER_RATIO HPI_CTL_ATTR(COMPANDER, 4)
330−#define HPI_COMPANDER_ATTACK HPI_CTL_ATTR(COMPANDER, 5)
331−#define HPI_COMPANDER_DECAY HPI_CTL_ATTR(COMPANDER, 6)
332−
333−/* Cobranet control attributes. */
334−#define HPI_COBRANET_SET HPI_CTL_ATTR(COBRANET, 1)
335−#define HPI_COBRANET_GET HPI_CTL_ATTR(COBRANET, 2)
336−#define HPI_COBRANET_SET_DATA HPI_CTL_ATTR(COBRANET, 3)
337−#define HPI_COBRANET_GET_DATA HPI_CTL_ATTR(COBRANET, 4)
338−#define HPI_COBRANET_GET_STATUS HPI_CTL_ATTR(COBRANET, 5)
339−#define HPI_COBRANET_SEND_PACKET HPI_CTL_ATTR(COBRANET, 6)
340−#define HPI_COBRANET_GET_PACKET HPI_CTL_ATTR(COBRANET, 7)
341−
342256 /*------------------------------------------------------------
343257 Cobranet Chip Bridge - copied from HMI.H
344258 ------------------------------------------------------------*/
@@ -395,69 +309,22 @@ Used for HPI_ChannelModeSet/Get() · 50 unmodified lines
395309
396310 #define HPI_ETHERNET_UDP_PORT (44600) /*!< UDP messaging port */
397311
398−/** Base network time out is set to 100 milli-seconds. */
399−#define HPI_ETHERNET_TIMEOUT_MS (100)
400−
401−/** \defgroup tonedet_attr Tonedetector attributes
402−\{
403−Used by HPI_ToneDetector_Set() and HPI_ToneDetector_Get()
404−*/
405−
406−/** Set the threshold level of a tonedetector,
407−Threshold is a -ve number in units of dB/100,
408−*/
409−#define HPI_TONEDETECTOR_THRESHOLD HPI_CTL_ATTR(TONEDETECTOR, 1)
410−
411−/** Get the current state of tonedetection
412−The result is a bitmap of detected tones. pairs of bits represent the left
413−and right channels, with left channel in LSB.
414−The lowest frequency detector state is in the LSB
415−*/
416−#define HPI_TONEDETECTOR_STATE HPI_CTL_ATTR(TONEDETECTOR, 2)
417−
418−/** Get the frequency of a tonedetector band.
419−*/
420−#define HPI_TONEDETECTOR_FREQUENCY HPI_CTL_ATTR(TONEDETECTOR, 3)
421−
422−/**\}*/
312+/** Default network timeout in milli-seconds. */
313+#define HPI_ETHERNET_TIMEOUT_MS 500
423314
424−/** \defgroup silencedet_attr SilenceDetector attributes
425−\{
426−*/
427−
428−/** Get the current state of tonedetection
429−The result is a bitmap with 1s for silent channels. Left channel is in LSB
430−*/
431−#define HPI_SILENCEDETECTOR_STATE \
432− HPI_CTL_ATTR(SILENCEDETECTOR, 2)
433−
434−/** Set the threshold level of a SilenceDetector,
435−Threshold is a -ve number in units of dB/100,
436−*/
437−#define HPI_SILENCEDETECTOR_THRESHOLD \
438− HPI_CTL_ATTR(SILENCEDETECTOR, 1)
439−
440−/** get/set the silence time before the detector triggers
441−*/
442−#define HPI_SILENCEDETECTOR_DELAY \
443− HPI_CTL_ATTR(SILENCEDETECTOR, 3)
444−
445−/**\}*/
446−
447−/* Locked memory buffer alloc/free phases */
448−/** use one message to allocate or free physical memory */
449−#define HPI_BUFFER_CMD_EXTERNAL 0
450−/** alloc physical memory */
451−#define HPI_BUFFER_CMD_INTERNAL_ALLOC 1
452−/** send physical memory address to adapter */
453−#define HPI_BUFFER_CMD_INTERNAL_GRANTADAPTER 2
454−/** notify adapter to stop using physical buffer */
455−#define HPI_BUFFER_CMD_INTERNAL_REVOKEADAPTER 3
456−/** free physical buffer */
457−#define HPI_BUFFER_CMD_INTERNAL_FREE 4
458−
459−/******************************************* CONTROLX ATTRIBUTES ****/
460−/* NOTE: All controlx attributes must be unique, unlike control attributes */
315+/** Locked memory buffer alloc/free phases */
316+enum HPI_BUFFER_CMDS {
317+ /** use one message to allocate or free physical memory */
318+ HPI_BUFFER_CMD_EXTERNAL = 0,
319+ /** alloc physical memory */
320+ HPI_BUFFER_CMD_INTERNAL_ALLOC = 1,
321+ /** send physical memory address to adapter */
322+ HPI_BUFFER_CMD_INTERNAL_GRANTADAPTER = 2,
323+ /** notify adapter to stop using physical buffer */
324+ HPI_BUFFER_CMD_INTERNAL_REVOKEADAPTER = 3,
325+ /** free physical buffer */
326+ HPI_BUFFER_CMD_INTERNAL_FREE = 4
327+};
461328
462329 /*****************************************************************************/
463330 /*****************************************************************************/
@@ -482,6 +349,12 @@ Threshold is a -ve number in units of dB/100, · 18 unmodified lines
482349 #define HPI_USB_W2K_TAG 0x57495341 /* "ASIW" */
483350 #define HPI_USB_LINUX_TAG 0x4C495341 /* "ASIL" */
484351
352+/** Invalid Adapter index
353+Used in HPI messages that are not addressed to a specific adapter
354+Used in DLL to indicate device not present
355+*/
356+#define HPI_ADAPTER_INDEX_INVALID 0xFFFF
357+
485358 /** First 2 hex digits define the adapter family */
486359 #define HPI_ADAPTER_FAMILY_MASK 0xff00
487360 #define HPI_MODULE_FAMILY_MASK 0xfff0
@@ -490,178 +363,185 @@ Threshold is a -ve number in units of dB/100, · 2 unmodified lines
490363 #define HPI_MODULE_FAMILY_ASI(f) (f & HPI_MODULE_FAMILY_MASK)
491364 #define HPI_ADAPTER_ASI(f) (f)
492365
493−/******************************************* message types */
494−#define HPI_TYPE_MESSAGE 1
495−#define HPI_TYPE_RESPONSE 2
496−#define HPI_TYPE_DATA 3
497−#define HPI_TYPE_SSX2BYPASS_MESSAGE 4
498−
499−/******************************************* object types */
500−#define HPI_OBJ_SUBSYSTEM 1
501−#define HPI_OBJ_ADAPTER 2
502−#define HPI_OBJ_OSTREAM 3
503−#define HPI_OBJ_ISTREAM 4
504−#define HPI_OBJ_MIXER 5
505−#define HPI_OBJ_NODE 6
506−#define HPI_OBJ_CONTROL 7
507−#define HPI_OBJ_NVMEMORY 8
508−#define HPI_OBJ_GPIO 9
509−#define HPI_OBJ_WATCHDOG 10
510−#define HPI_OBJ_CLOCK 11
511−#define HPI_OBJ_PROFILE 12
512−#define HPI_OBJ_CONTROLEX 13
513−#define HPI_OBJ_ASYNCEVENT 14
514−
515−#define HPI_OBJ_MAXINDEX 14
516−
517−/******************************************* methods/functions */
518−
519−#define HPI_OBJ_FUNCTION_SPACING 0x100
520−#define HPI_MAKE_INDEX(obj, index) (obj * HPI_OBJ_FUNCTION_SPACING + index)
366+enum HPI_MESSAGE_TYPES {
367+ HPI_TYPE_MESSAGE = 1,
368+ HPI_TYPE_RESPONSE = 2,
369+ HPI_TYPE_DATA = 3,
370+ HPI_TYPE_SSX2BYPASS_MESSAGE = 4
371+};
372+
373+enum HPI_OBJECT_TYPES {
374+ HPI_OBJ_SUBSYSTEM = 1,
375+ HPI_OBJ_ADAPTER = 2,
376+ HPI_OBJ_OSTREAM = 3,
377+ HPI_OBJ_ISTREAM = 4,
378+ HPI_OBJ_MIXER = 5,
379+ HPI_OBJ_NODE = 6,
380+ HPI_OBJ_CONTROL = 7,
381+ HPI_OBJ_NVMEMORY = 8,
382+ HPI_OBJ_GPIO = 9,
383+ HPI_OBJ_WATCHDOG = 10,
384+ HPI_OBJ_CLOCK = 11,
385+ HPI_OBJ_PROFILE = 12,
386+ HPI_OBJ_CONTROLEX = 13,
387+ HPI_OBJ_ASYNCEVENT = 14
388+#define HPI_OBJ_MAXINDEX 14
389+};
390+
391+#define HPI_OBJ_FUNCTION_SPACING 0x100
392+#define HPI_FUNC_ID(obj, i) (HPI_OBJ_##obj * HPI_OBJ_FUNCTION_SPACING + i)
393+
521394 #define HPI_EXTRACT_INDEX(fn) (fn & 0xff)
522395
523−/* SUB-SYSTEM */
524−#define HPI_SUBSYS_OPEN HPI_MAKE_INDEX(HPI_OBJ_SUBSYSTEM, 1)
525−#define HPI_SUBSYS_GET_VERSION HPI_MAKE_INDEX(HPI_OBJ_SUBSYSTEM, 2)
526−#define HPI_SUBSYS_GET_INFO HPI_MAKE_INDEX(HPI_OBJ_SUBSYSTEM, 3)
527−#define HPI_SUBSYS_FIND_ADAPTERS HPI_MAKE_INDEX(HPI_OBJ_SUBSYSTEM, 4)
528−#define HPI_SUBSYS_CREATE_ADAPTER HPI_MAKE_INDEX(HPI_OBJ_SUBSYSTEM, 5)
529−#define HPI_SUBSYS_CLOSE HPI_MAKE_INDEX(HPI_OBJ_SUBSYSTEM, 6)
530−#define HPI_SUBSYS_DELETE_ADAPTER HPI_MAKE_INDEX(HPI_OBJ_SUBSYSTEM, 7)
531−#define HPI_SUBSYS_DRIVER_LOAD HPI_MAKE_INDEX(HPI_OBJ_SUBSYSTEM, 8)
532−#define HPI_SUBSYS_DRIVER_UNLOAD HPI_MAKE_INDEX(HPI_OBJ_SUBSYSTEM, 9)
533−#define HPI_SUBSYS_READ_PORT_8 HPI_MAKE_INDEX(HPI_OBJ_SUBSYSTEM, 10)
534−#define HPI_SUBSYS_WRITE_PORT_8 HPI_MAKE_INDEX(HPI_OBJ_SUBSYSTEM, 11)
535−#define HPI_SUBSYS_GET_NUM_ADAPTERS HPI_MAKE_INDEX(HPI_OBJ_SUBSYSTEM, 12)
536−#define HPI_SUBSYS_GET_ADAPTER HPI_MAKE_INDEX(HPI_OBJ_SUBSYSTEM, 13)
537−#define HPI_SUBSYS_SET_NETWORK_INTERFACE HPI_MAKE_INDEX(HPI_OBJ_SUBSYSTEM, 14)
538−#define HPI_SUBSYS_FUNCTION_COUNT 14
539−/* ADAPTER */
540−#define HPI_ADAPTER_OPEN HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 1)
541−#define HPI_ADAPTER_CLOSE HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 2)
542−#define HPI_ADAPTER_GET_INFO HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 3)
543−#define HPI_ADAPTER_GET_ASSERT HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 4)
544−#define HPI_ADAPTER_TEST_ASSERT HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 5)
545−#define HPI_ADAPTER_SET_MODE HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 6)
546−#define HPI_ADAPTER_GET_MODE HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 7)
547−#define HPI_ADAPTER_ENABLE_CAPABILITY HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 8)
548−#define HPI_ADAPTER_SELFTEST HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 9)
549−#define HPI_ADAPTER_FIND_OBJECT HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 10)
550−#define HPI_ADAPTER_QUERY_FLASH HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 11)
551−#define HPI_ADAPTER_START_FLASH HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 12)
552−#define HPI_ADAPTER_PROGRAM_FLASH HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 13)
553−#define HPI_ADAPTER_SET_PROPERTY HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 14)
554−#define HPI_ADAPTER_GET_PROPERTY HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 15)
555−#define HPI_ADAPTER_ENUM_PROPERTY HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 16)
556−#define HPI_ADAPTER_MODULE_INFO HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 17)
557−#define HPI_ADAPTER_DEBUG_READ HPI_MAKE_INDEX(HPI_OBJ_ADAPTER, 18)
558−#define HPI_ADAPTER_FUNCTION_COUNT 18
559−/* OUTPUT STREAM */
560−#define HPI_OSTREAM_OPEN HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 1)
561−#define HPI_OSTREAM_CLOSE HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 2)
562−#define HPI_OSTREAM_WRITE HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 3)
563−#define HPI_OSTREAM_START HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 4)
564−#define HPI_OSTREAM_STOP HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 5)
565−#define HPI_OSTREAM_RESET HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 6)
566−#define HPI_OSTREAM_GET_INFO HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 7)
567−#define HPI_OSTREAM_QUERY_FORMAT HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 8)
568−#define HPI_OSTREAM_DATA HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 9)
569−#define HPI_OSTREAM_SET_VELOCITY HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 10)
570−#define HPI_OSTREAM_SET_PUNCHINOUT HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 11)
571−#define HPI_OSTREAM_SINEGEN HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 12)
572−#define HPI_OSTREAM_ANC_RESET HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 13)
573−#define HPI_OSTREAM_ANC_GET_INFO HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 14)
574−#define HPI_OSTREAM_ANC_READ HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 15)
575−#define HPI_OSTREAM_SET_TIMESCALE HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 16)
576−#define HPI_OSTREAM_SET_FORMAT HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 17)
577−#define HPI_OSTREAM_HOSTBUFFER_ALLOC HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 18)
578−#define HPI_OSTREAM_HOSTBUFFER_FREE HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 19)
579−#define HPI_OSTREAM_GROUP_ADD HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 20)
580−#define HPI_OSTREAM_GROUP_GETMAP HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 21)
581−#define HPI_OSTREAM_GROUP_RESET HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 22)
582−#define HPI_OSTREAM_HOSTBUFFER_GET_INFO HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 23)
583−#define HPI_OSTREAM_WAIT_START HPI_MAKE_INDEX(HPI_OBJ_OSTREAM, 24)
584−#define HPI_OSTREAM_FUNCTION_COUNT 24
585−/* INPUT STREAM */
586−#define HPI_ISTREAM_OPEN HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 1)
587−#define HPI_ISTREAM_CLOSE HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 2)
588−#define HPI_ISTREAM_SET_FORMAT HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 3)
589−#define HPI_ISTREAM_READ HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 4)
590−#define HPI_ISTREAM_START HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 5)
591−#define HPI_ISTREAM_STOP HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 6)
592−#define HPI_ISTREAM_RESET HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 7)
593−#define HPI_ISTREAM_GET_INFO HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 8)
594−#define HPI_ISTREAM_QUERY_FORMAT HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 9)
595−#define HPI_ISTREAM_ANC_RESET HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 10)
596−#define HPI_ISTREAM_ANC_GET_INFO HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 11)
597−#define HPI_ISTREAM_ANC_WRITE HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 12)
598−#define HPI_ISTREAM_HOSTBUFFER_ALLOC HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 13)
599−#define HPI_ISTREAM_HOSTBUFFER_FREE HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 14)
600−#define HPI_ISTREAM_GROUP_ADD HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 15)
601−#define HPI_ISTREAM_GROUP_GETMAP HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 16)
602−#define HPI_ISTREAM_GROUP_RESET HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 17)
603−#define HPI_ISTREAM_HOSTBUFFER_GET_INFO HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 18)
604−#define HPI_ISTREAM_WAIT_START HPI_MAKE_INDEX(HPI_OBJ_ISTREAM, 19)
605−#define HPI_ISTREAM_FUNCTION_COUNT 19
606−/* MIXER */
396+enum HPI_FUNCTION_IDS {
397+ HPI_SUBSYS_OPEN = HPI_FUNC_ID(SUBSYSTEM, 1),
398+ HPI_SUBSYS_GET_VERSION = HPI_FUNC_ID(SUBSYSTEM, 2),
399+ HPI_SUBSYS_GET_INFO = HPI_FUNC_ID(SUBSYSTEM, 3),
400+ HPI_SUBSYS_FIND_ADAPTERS = HPI_FUNC_ID(SUBSYSTEM, 4),
401+ HPI_SUBSYS_CREATE_ADAPTER = HPI_FUNC_ID(SUBSYSTEM, 5),
402+ HPI_SUBSYS_CLOSE = HPI_FUNC_ID(SUBSYSTEM, 6),
403+ HPI_SUBSYS_DELETE_ADAPTER = HPI_FUNC_ID(SUBSYSTEM, 7),
404+ HPI_SUBSYS_DRIVER_LOAD = HPI_FUNC_ID(SUBSYSTEM, 8),
405+ HPI_SUBSYS_DRIVER_UNLOAD = HPI_FUNC_ID(SUBSYSTEM, 9),
406+ HPI_SUBSYS_READ_PORT_8 = HPI_FUNC_ID(SUBSYSTEM, 10),
407+ HPI_SUBSYS_WRITE_PORT_8 = HPI_FUNC_ID(SUBSYSTEM, 11),
408+ HPI_SUBSYS_GET_NUM_ADAPTERS = HPI_FUNC_ID(SUBSYSTEM, 12),
409+ HPI_SUBSYS_GET_ADAPTER = HPI_FUNC_ID(SUBSYSTEM, 13),
410+ HPI_SUBSYS_SET_NETWORK_INTERFACE = HPI_FUNC_ID(SUBSYSTEM, 14),
411+ HPI_SUBSYS_OPTION_INFO = HPI_FUNC_ID(SUBSYSTEM, 15),
412+ HPI_SUBSYS_OPTION_GET = HPI_FUNC_ID(SUBSYSTEM, 16),
413+ HPI_SUBSYS_OPTION_SET = HPI_FUNC_ID(SUBSYSTEM, 17),
414+#define HPI_SUBSYS_FUNCTION_COUNT 17
415+
416+ HPI_ADAPTER_OPEN = HPI_FUNC_ID(ADAPTER, 1),
417+ HPI_ADAPTER_CLOSE = HPI_FUNC_ID(ADAPTER, 2),
418+ HPI_ADAPTER_GET_INFO = HPI_FUNC_ID(ADAPTER, 3),
419+ HPI_ADAPTER_GET_ASSERT = HPI_FUNC_ID(ADAPTER, 4),
420+ HPI_ADAPTER_TEST_ASSERT = HPI_FUNC_ID(ADAPTER, 5),
421+ HPI_ADAPTER_SET_MODE = HPI_FUNC_ID(ADAPTER, 6),
422+ HPI_ADAPTER_GET_MODE = HPI_FUNC_ID(ADAPTER, 7),
423+ HPI_ADAPTER_ENABLE_CAPABILITY = HPI_FUNC_ID(ADAPTER, 8),
424+ HPI_ADAPTER_SELFTEST = HPI_FUNC_ID(ADAPTER, 9),
425+ HPI_ADAPTER_FIND_OBJECT = HPI_FUNC_ID(ADAPTER, 10),
426+ HPI_ADAPTER_QUERY_FLASH = HPI_FUNC_ID(ADAPTER, 11),
427+ HPI_ADAPTER_START_FLASH = HPI_FUNC_ID(ADAPTER, 12),
428+ HPI_ADAPTER_PROGRAM_FLASH = HPI_FUNC_ID(ADAPTER, 13),
429+ HPI_ADAPTER_SET_PROPERTY = HPI_FUNC_ID(ADAPTER, 14),
430+ HPI_ADAPTER_GET_PROPERTY = HPI_FUNC_ID(ADAPTER, 15),
431+ HPI_ADAPTER_ENUM_PROPERTY = HPI_FUNC_ID(ADAPTER, 16),
432+ HPI_ADAPTER_MODULE_INFO = HPI_FUNC_ID(ADAPTER, 17),
433+ HPI_ADAPTER_DEBUG_READ = HPI_FUNC_ID(ADAPTER, 18),
434+ HPI_ADAPTER_IRQ_QUERY_AND_CLEAR = HPI_FUNC_ID(ADAPTER, 19),
435+ HPI_ADAPTER_IRQ_CALLBACK = HPI_FUNC_ID(ADAPTER, 20),
436+#define HPI_ADAPTER_FUNCTION_COUNT 20
437+
438+ HPI_OSTREAM_OPEN = HPI_FUNC_ID(OSTREAM, 1),
439+ HPI_OSTREAM_CLOSE = HPI_FUNC_ID(OSTREAM, 2),
440+ HPI_OSTREAM_WRITE = HPI_FUNC_ID(OSTREAM, 3),
441+ HPI_OSTREAM_START = HPI_FUNC_ID(OSTREAM, 4),
442+ HPI_OSTREAM_STOP = HPI_FUNC_ID(OSTREAM, 5),
443+ HPI_OSTREAM_RESET = HPI_FUNC_ID(OSTREAM, 6),
444+ HPI_OSTREAM_GET_INFO = HPI_FUNC_ID(OSTREAM, 7),
445+ HPI_OSTREAM_QUERY_FORMAT = HPI_FUNC_ID(OSTREAM, 8),
446+ HPI_OSTREAM_DATA = HPI_FUNC_ID(OSTREAM, 9),
447+ HPI_OSTREAM_SET_VELOCITY = HPI_FUNC_ID(OSTREAM, 10),
448+ HPI_OSTREAM_SET_PUNCHINOUT = HPI_FUNC_ID(OSTREAM, 11),
449+ HPI_OSTREAM_SINEGEN = HPI_FUNC_ID(OSTREAM, 12),
450+ HPI_OSTREAM_ANC_RESET = HPI_FUNC_ID(OSTREAM, 13),
451+ HPI_OSTREAM_ANC_GET_INFO = HPI_FUNC_ID(OSTREAM, 14),
452+ HPI_OSTREAM_ANC_READ = HPI_FUNC_ID(OSTREAM, 15),
453+ HPI_OSTREAM_SET_TIMESCALE = HPI_FUNC_ID(OSTREAM, 16),
454+ HPI_OSTREAM_SET_FORMAT = HPI_FUNC_ID(OSTREAM, 17),
455+ HPI_OSTREAM_HOSTBUFFER_ALLOC = HPI_FUNC_ID(OSTREAM, 18),
456+ HPI_OSTREAM_HOSTBUFFER_FREE = HPI_FUNC_ID(OSTREAM, 19),
457+ HPI_OSTREAM_GROUP_ADD = HPI_FUNC_ID(OSTREAM, 20),
458+ HPI_OSTREAM_GROUP_GETMAP = HPI_FUNC_ID(OSTREAM, 21),
459+ HPI_OSTREAM_GROUP_RESET = HPI_FUNC_ID(OSTREAM, 22),
460+ HPI_OSTREAM_HOSTBUFFER_GET_INFO = HPI_FUNC_ID(OSTREAM, 23),
461+ HPI_OSTREAM_WAIT_START = HPI_FUNC_ID(OSTREAM, 24),
462+ HPI_OSTREAM_WAIT = HPI_FUNC_ID(OSTREAM, 25),
463+#define HPI_OSTREAM_FUNCTION_COUNT 25
464+
465+ HPI_ISTREAM_OPEN = HPI_FUNC_ID(ISTREAM, 1),
466+ HPI_ISTREAM_CLOSE = HPI_FUNC_ID(ISTREAM, 2),
467+ HPI_ISTREAM_SET_FORMAT = HPI_FUNC_ID(ISTREAM, 3),
468+ HPI_ISTREAM_READ = HPI_FUNC_ID(ISTREAM, 4),
469+ HPI_ISTREAM_START = HPI_FUNC_ID(ISTREAM, 5),
470+ HPI_ISTREAM_STOP = HPI_FUNC_ID(ISTREAM, 6),
471+ HPI_ISTREAM_RESET = HPI_FUNC_ID(ISTREAM, 7),
472+ HPI_ISTREAM_GET_INFO = HPI_FUNC_ID(ISTREAM, 8),
473+ HPI_ISTREAM_QUERY_FORMAT = HPI_FUNC_ID(ISTREAM, 9),
474+ HPI_ISTREAM_ANC_RESET = HPI_FUNC_ID(ISTREAM, 10),
475+ HPI_ISTREAM_ANC_GET_INFO = HPI_FUNC_ID(ISTREAM, 11),
476+ HPI_ISTREAM_ANC_WRITE = HPI_FUNC_ID(ISTREAM, 12),
477+ HPI_ISTREAM_HOSTBUFFER_ALLOC = HPI_FUNC_ID(ISTREAM, 13),
478+ HPI_ISTREAM_HOSTBUFFER_FREE = HPI_FUNC_ID(ISTREAM, 14),
479+ HPI_ISTREAM_GROUP_ADD = HPI_FUNC_ID(ISTREAM, 15),
480+ HPI_ISTREAM_GROUP_GETMAP = HPI_FUNC_ID(ISTREAM, 16),
481+ HPI_ISTREAM_GROUP_RESET = HPI_FUNC_ID(ISTREAM, 17),
482+ HPI_ISTREAM_HOSTBUFFER_GET_INFO = HPI_FUNC_ID(ISTREAM, 18),
483+ HPI_ISTREAM_WAIT_START = HPI_FUNC_ID(ISTREAM, 19),
484+ HPI_ISTREAM_WAIT = HPI_FUNC_ID(ISTREAM, 20),
485+#define HPI_ISTREAM_FUNCTION_COUNT 20
486+
607487 /* NOTE:
608488 GET_NODE_INFO, SET_CONNECTION, GET_CONNECTIONS are not currently used */
609−#define HPI_MIXER_OPEN HPI_MAKE_INDEX(HPI_OBJ_MIXER, 1)
610−#define HPI_MIXER_CLOSE HPI_MAKE_INDEX(HPI_OBJ_MIXER, 2)
611−#define HPI_MIXER_GET_INFO HPI_MAKE_INDEX(HPI_OBJ_MIXER, 3)
612−#define HPI_MIXER_GET_NODE_INFO HPI_MAKE_INDEX(HPI_OBJ_MIXER, 4)
613−#define HPI_MIXER_GET_CONTROL HPI_MAKE_INDEX(HPI_OBJ_MIXER, 5)
614−#define HPI_MIXER_SET_CONNECTION HPI_MAKE_INDEX(HPI_OBJ_MIXER, 6)
615−#define HPI_MIXER_GET_CONNECTIONS HPI_MAKE_INDEX(HPI_OBJ_MIXER, 7)
616−#define HPI_MIXER_GET_CONTROL_BY_INDEX HPI_MAKE_INDEX(HPI_OBJ_MIXER, 8)
617−#define HPI_MIXER_GET_CONTROL_ARRAY_BY_INDEX HPI_MAKE_INDEX(HPI_OBJ_MIXER, 9)
618−#define HPI_MIXER_GET_CONTROL_MULTIPLE_VALUES HPI_MAKE_INDEX(HPI_OBJ_MIXER, 10)
619−#define HPI_MIXER_STORE HPI_MAKE_INDEX(HPI_OBJ_MIXER, 11)
620−#define HPI_MIXER_FUNCTION_COUNT 11
621−/* MIXER CONTROLS */
622−#define HPI_CONTROL_GET_INFO HPI_MAKE_INDEX(HPI_OBJ_CONTROL, 1)
623−#define HPI_CONTROL_GET_STATE HPI_MAKE_INDEX(HPI_OBJ_CONTROL, 2)
624−#define HPI_CONTROL_SET_STATE HPI_MAKE_INDEX(HPI_OBJ_CONTROL, 3)
489+ HPI_MIXER_OPEN = HPI_FUNC_ID(MIXER, 1),
490+ HPI_MIXER_CLOSE = HPI_FUNC_ID(MIXER, 2),
491+ HPI_MIXER_GET_INFO = HPI_FUNC_ID(MIXER, 3),
492+ HPI_MIXER_GET_NODE_INFO = HPI_FUNC_ID(MIXER, 4),
493+ HPI_MIXER_GET_CONTROL = HPI_FUNC_ID(MIXER, 5),
494+ HPI_MIXER_SET_CONNECTION = HPI_FUNC_ID(MIXER, 6),
495+ HPI_MIXER_GET_CONNECTIONS = HPI_FUNC_ID(MIXER, 7),
496+ HPI_MIXER_GET_CONTROL_BY_INDEX = HPI_FUNC_ID(MIXER, 8),
497+ HPI_MIXER_GET_CONTROL_ARRAY_BY_INDEX = HPI_FUNC_ID(MIXER, 9),
498+ HPI_MIXER_GET_CONTROL_MULTIPLE_VALUES = HPI_FUNC_ID(MIXER, 10),
499+ HPI_MIXER_STORE = HPI_FUNC_ID(MIXER, 11),
500+ HPI_MIXER_GET_CACHE_INFO = HPI_FUNC_ID(MIXER, 12),
501+#define HPI_MIXER_FUNCTION_COUNT 12
502+
503+ HPI_CONTROL_GET_INFO = HPI_FUNC_ID(CONTROL, 1),
504+ HPI_CONTROL_GET_STATE = HPI_FUNC_ID(CONTROL, 2),
505+ HPI_CONTROL_SET_STATE = HPI_FUNC_ID(CONTROL, 3),
625506 #define HPI_CONTROL_FUNCTION_COUNT 3
626−/* NONVOL MEMORY */
627−#define HPI_NVMEMORY_OPEN HPI_MAKE_INDEX(HPI_OBJ_NVMEMORY, 1)
628−#define HPI_NVMEMORY_READ_BYTE HPI_MAKE_INDEX(HPI_OBJ_NVMEMORY, 2)
629−#define HPI_NVMEMORY_WRITE_BYTE HPI_MAKE_INDEX(HPI_OBJ_NVMEMORY, 3)
507+
508+ HPI_NVMEMORY_OPEN = HPI_FUNC_ID(NVMEMORY, 1),
509+ HPI_NVMEMORY_READ_BYTE = HPI_FUNC_ID(NVMEMORY, 2),
510+ HPI_NVMEMORY_WRITE_BYTE = HPI_FUNC_ID(NVMEMORY, 3),
630511 #define HPI_NVMEMORY_FUNCTION_COUNT 3
631−/* GPIO */
632−#define HPI_GPIO_OPEN HPI_MAKE_INDEX(HPI_OBJ_GPIO, 1)
633−#define HPI_GPIO_READ_BIT HPI_MAKE_INDEX(HPI_OBJ_GPIO, 2)
634−#define HPI_GPIO_WRITE_BIT HPI_MAKE_INDEX(HPI_OBJ_GPIO, 3)
635−#define HPI_GPIO_READ_ALL HPI_MAKE_INDEX(HPI_OBJ_GPIO, 4)
636−#define HPI_GPIO_WRITE_STATUS HPI_MAKE_INDEX(HPI_OBJ_GPIO, 5)
512+
513+ HPI_GPIO_OPEN = HPI_FUNC_ID(GPIO, 1),
514+ HPI_GPIO_READ_BIT = HPI_FUNC_ID(GPIO, 2),
515+ HPI_GPIO_WRITE_BIT = HPI_FUNC_ID(GPIO, 3),
516+ HPI_GPIO_READ_ALL = HPI_FUNC_ID(GPIO, 4),
517+ HPI_GPIO_WRITE_STATUS = HPI_FUNC_ID(GPIO, 5),
637518 #define HPI_GPIO_FUNCTION_COUNT 5
638−/* ASYNC EVENT */
639−#define HPI_ASYNCEVENT_OPEN HPI_MAKE_INDEX(HPI_OBJ_ASYNCEVENT, 1)
640−#define HPI_ASYNCEVENT_CLOSE HPI_MAKE_INDEX(HPI_OBJ_ASYNCEVENT, 2)
641−#define HPI_ASYNCEVENT_WAIT HPI_MAKE_INDEX(HPI_OBJ_ASYNCEVENT, 3)
642−#define HPI_ASYNCEVENT_GETCOUNT HPI_MAKE_INDEX(HPI_OBJ_ASYNCEVENT, 4)
643−#define HPI_ASYNCEVENT_GET HPI_MAKE_INDEX(HPI_OBJ_ASYNCEVENT, 5)
644−#define HPI_ASYNCEVENT_SENDEVENTS HPI_MAKE_INDEX(HPI_OBJ_ASYNCEVENT, 6)
519+
520+ HPI_ASYNCEVENT_OPEN = HPI_FUNC_ID(ASYNCEVENT, 1),
521+ HPI_ASYNCEVENT_CLOSE = HPI_FUNC_ID(ASYNCEVENT, 2),
522+ HPI_ASYNCEVENT_WAIT = HPI_FUNC_ID(ASYNCEVENT, 3),
523+ HPI_ASYNCEVENT_GETCOUNT = HPI_FUNC_ID(ASYNCEVENT, 4),
524+ HPI_ASYNCEVENT_GET = HPI_FUNC_ID(ASYNCEVENT, 5),
525+ HPI_ASYNCEVENT_SENDEVENTS = HPI_FUNC_ID(ASYNCEVENT, 6),
645526 #define HPI_ASYNCEVENT_FUNCTION_COUNT 6
646−/* WATCH-DOG */
647−#define HPI_WATCHDOG_OPEN HPI_MAKE_INDEX(HPI_OBJ_WATCHDOG, 1)
648−#define HPI_WATCHDOG_SET_TIME HPI_MAKE_INDEX(HPI_OBJ_WATCHDOG, 2)
649−#define HPI_WATCHDOG_PING HPI_MAKE_INDEX(HPI_OBJ_WATCHDOG, 3)
650−/* CLOCK */
651−#define HPI_CLOCK_OPEN HPI_MAKE_INDEX(HPI_OBJ_CLOCK, 1)
652−#define HPI_CLOCK_SET_TIME HPI_MAKE_INDEX(HPI_OBJ_CLOCK, 2)
653−#define HPI_CLOCK_GET_TIME HPI_MAKE_INDEX(HPI_OBJ_CLOCK, 3)
654−/* PROFILE */
655−#define HPI_PROFILE_OPEN_ALL HPI_MAKE_INDEX(HPI_OBJ_PROFILE, 1)
656−#define HPI_PROFILE_START_ALL HPI_MAKE_INDEX(HPI_OBJ_PROFILE, 2)
657−#define HPI_PROFILE_STOP_ALL HPI_MAKE_INDEX(HPI_OBJ_PROFILE, 3)
658−#define HPI_PROFILE_GET HPI_MAKE_INDEX(HPI_OBJ_PROFILE, 4)
659−#define HPI_PROFILE_GET_IDLECOUNT HPI_MAKE_INDEX(HPI_OBJ_PROFILE, 5)
660−#define HPI_PROFILE_GET_NAME HPI_MAKE_INDEX(HPI_OBJ_PROFILE, 6)
661−#define HPI_PROFILE_GET_UTILIZATION HPI_MAKE_INDEX(HPI_OBJ_PROFILE, 7)
527+
528+ HPI_WATCHDOG_OPEN = HPI_FUNC_ID(WATCHDOG, 1),
529+ HPI_WATCHDOG_SET_TIME = HPI_FUNC_ID(WATCHDOG, 2),
530+ HPI_WATCHDOG_PING = HPI_FUNC_ID(WATCHDOG, 3),
531+
532+ HPI_CLOCK_OPEN = HPI_FUNC_ID(CLOCK, 1),
533+ HPI_CLOCK_SET_TIME = HPI_FUNC_ID(CLOCK, 2),
534+ HPI_CLOCK_GET_TIME = HPI_FUNC_ID(CLOCK, 3),
535+
536+ HPI_PROFILE_OPEN_ALL = HPI_FUNC_ID(PROFILE, 1),
537+ HPI_PROFILE_START_ALL = HPI_FUNC_ID(PROFILE, 2),
538+ HPI_PROFILE_STOP_ALL = HPI_FUNC_ID(PROFILE, 3),
539+ HPI_PROFILE_GET = HPI_FUNC_ID(PROFILE, 4),
540+ HPI_PROFILE_GET_IDLECOUNT = HPI_FUNC_ID(PROFILE, 5),
541+ HPI_PROFILE_GET_NAME = HPI_FUNC_ID(PROFILE, 6),
542+ HPI_PROFILE_GET_UTILIZATION = HPI_FUNC_ID(PROFILE, 7)
662543 #define HPI_PROFILE_FUNCTION_COUNT 7
663−/* ////////////////////////////////////////////////////////////////////// */
664−/* PRIVATE ATTRIBUTES */
544+};
665545
666546 /* ////////////////////////////////////////////////////////////////////// */
667547 /* STRUCTURES */
@@ -672,18 +552,7 @@ Threshold is a -ve number in units of dB/100, · 4 unmodified lines
672552 /** PCI bus resource */
673553 struct hpi_pci {
674554 u32 __iomem *ap_mem_base[HPI_MAX_ADAPTER_MEM_SPACES];
675− struct pci_dev *p_os_data;
676−
677−#ifndef HPI64BIT /* keep structure size constant */
678− u32 padding[HPI_MAX_ADAPTER_MEM_SPACES + 1];
679−#endif
680− u16 vendor_id;
681− u16 device_id;
682− u16 subsys_vendor_id;
683− u16 subsys_device_id;
684− u16 bus_number;
685− u16 device_number;
686− u32 interrupt;
555+ struct pci_dev *pci_dev;
687556 };
688557
689558 struct hpi_resource {
@@ -702,12 +571,10 @@ struct hpi_resource { · 12 unmodified lines
702571 /** Format info used inside struct hpi_message
703572 Not the same as public API struct hpi_format */
704573 struct hpi_msg_format {
705− u32 sample_rate;
706− /**< 11025, 32000, 44100 ... */
707− u32 bit_rate; /**< for MPEG */
708− u32 attributes;
709− /**< Stereo/JointStereo/Mono */
710− u16 channels; /**< 1,2..., (or ancillary mode or idle bit */
574+ u32 sample_rate; /**< 11025, 32000, 44100 etc. */
575+ u32 bit_rate; /**< for MPEG */
576+ u32 attributes; /**< stereo/joint_stereo/mono */
577+ u16 channels; /**< 1,2..., (or ancillary mode or idle bit */
711578 u16 format; /**< HPI_FORMAT_PCM16, _MPEG etc. see \ref HPI_FORMATS. */
712579 };
713580
@@ -742,7 +609,7 @@ struct hpi_data_compat32 { · 28 unmodified lines
742609 struct hpi_buffer {
743610 /** placehoder for backward compatability (see dwBufferSize) */
744611 struct hpi_msg_format reserved;
745− u32 command; /**< HPI_BUFFER_CMD_xxx*/
612+ u32 command; /**< HPI_BUFFER_CMD_xxx*/
746613 u32 pci_address; /**< PCI physical address of buffer for DSP DMA */
747614 u32 buffer_size; /**< must line up with data_size of HPI_DATA*/
748615 };
@@ -777,30 +644,25 @@ struct hpi_subsys_msg { · 28 unmodified lines
777644
778645 struct hpi_subsys_res {
779646 u32 version;
780− u32 data; /* used to return extended version */
781− u16 num_adapters; /* number of adapters */
647+ u32 data; /* extended version */
648+ u16 num_adapters;
782649 u16 adapter_index;
783− u16 aw_adapter_list[HPI_MAX_ADAPTERS];
784−};
785−
786−struct hpi_adapter_msg {
787− u32 adapter_mode; /* adapter mode */
788− u16 assert_id; /* assert number for "test assert" call
789− object_index for find object call
790− query_or_set for hpi_adapter_set_mode_ex() */
791− u16 object_type; /* for adapter find object call */
650+ u16 adapter_type;
651+ u16 pad16;
792652 };
793653
794654 union hpi_adapterx_msg {
795− struct hpi_adapter_msg adapter;
796655 struct {
797− u32 offset;
798− } query_flash;
656+ u32 dsp_address;
657+ u32 count_bytes;
658+ } debug_read;
799659 struct {
800− u32 offset;
801− u32 length;
802− u32 key;
803− } start_flash;
660+ u32 adapter_mode;
661+ u16 query_or_set;
662+ } mode;
663+ struct {
664+ u16 index;
665+ } module_info;
804666 struct {
805667 u32 checksum;
806668 u16 sequence;
@@ -808,29 +670,42 @@ union hpi_adapterx_msg { · 1 unmodified line
808670 u16 offset; /**< offset from start of msg to data */
809671 u16 unused;
810672 } program_flash;
673+ struct {
674+ u16 index;
675+ u16 what;
676+ u16 property_index;
677+ } property_enum;
811678 struct {
812679 u16 property;
813680 u16 parameter1;
814681 u16 parameter2;
815682 } property_set;
816683 struct {
817− u16 index;
818− u16 what;
819− u16 property_index;
820− } property_enum;
684+ u32 offset;
685+ } query_flash;
821686 struct {
822− u16 index;
823− } module_info;
687+ u32 pad32;
688+ u16 key1;
689+ u16 key2;
690+ } restart;
824691 struct {
825− u32 dsp_address;
826− u32 count_bytes;
827− } debug_read;
692+ u32 offset;
693+ u32 length;
694+ u32 key;
695+ } start_flash;
696+ struct {
697+ u32 pad32;
698+ u16 value;
699+ } test_assert;
700+ struct {
701+ u32 yes;
702+ } irq_query;
828703 };
829704
830705 struct hpi_adapter_res {
831706 u32 serial_number;
832707 u16 adapter_type;
833− u16 adapter_index; /* is this needed? also used for dsp_index */
708+ u16 adapter_index;
834709 u16 num_instreams;
835710 u16 num_outstreams;
836711 u16 num_mixers;
@@ -839,12 +714,18 @@ struct hpi_adapter_res { · 2 unmodified lines
839714 };
840715
841716 union hpi_adapterx_res {
842− struct hpi_adapter_res adapter;
717+ struct hpi_adapter_res info;
843718 struct {
844− u32 checksum;
845− u32 length;
846− u32 version;
847− } query_flash;
719+ u32 p1;
720+ u16 count;
721+ u16 dsp_index;
722+ u32 p2;
723+ u32 dsp_msg_addr;
724+ char sz_message[HPI_STRING_LEN];
725+ } assert;
726+ struct {
727+ u32 adapter_mode;
728+ } mode;
848729 struct {
849730 u16 sequence;
850731 } program_flash;
@@ -852,6 +733,14 @@ union hpi_adapterx_res { · 1 unmodified line
852733 u16 parameter1;
853734 u16 parameter2;
854735 } property_get;
736+ struct {
737+ u32 checksum;
738+ u32 length;
739+ u32 version;
740+ } query_flash;
741+ struct {
742+ u32 yes;
743+ } irq_query;
855744 };
856745
857746 struct hpi_stream_msg {
@@ -863,6 +752,7 @@ struct hpi_stream_msg { · 5 unmodified lines
863752 u32 time_scale;
864753 struct hpi_buffer buffer;
865754 struct hpi_streamid stream;
755+ u32 threshold_bytes;
866756 } u;
867757 };
868758
@@ -911,7 +801,7 @@ struct hpi_stream_res { · 42 unmodified lines
911801 struct hpi_mixer_msg {
912802 u16 control_index;
913803 u16 control_type; /* = HPI_CONTROL_METER _VOLUME etc */
914− u16 padding1; /* maintain alignment of subsequent fields */
804+ u16 padding1; /* Maintain alignment of subsequent fields */
915805 u16 node_type1; /* = HPI_SOURCENODE_LINEIN etc */
916806 u16 node_index1; /* = 0..N */
917807 u16 node_type2;
@@ -949,6 +839,11 @@ union hpi_mixerx_res { · 31 unmodified lines
949839 u32 p_data; /* pointer to data array */
950840 u16 more_to_do; /* indicates if there is more to do */
951841 } gcabi;
842+ struct {
843+ u32 total_controls; /* count of controls in the mixer */
844+ u32 cache_controls; /* count of controls in the cac */
845+ u32 cache_bytes; /* size of cache */
846+ } cache_info;
952847 };
953848
954849 struct hpi_control_msg {
@@ -1000,12 +895,16 @@ union hpi_control_union_res { · 45 unmodified lines
1000895 u32 band;
1001896 u32 frequency;
1002897 u32 gain;
1003− u32 level;
1004898 u32 deemphasis;
1005899 struct {
1006900 u32 data[2];
1007901 u32 bLER;
1008902 } rds;
903+ short s_level;
904+ struct {
905+ u16 value;
906+ u16 mask;
907+ } status;
1009908 } tuner;
1010909 struct {
1011910 char sz_data[8];
@@ -1178,11 +1077,11 @@ struct hpi_profile_res_open { · 166 unmodified lines
11781077 };
11791078
11801079 struct hpi_profile_res_time {
1181− u32 micro_seconds;
1080+ u32 total_tick_count;
11821081 u32 call_count;
1183− u32 max_micro_seconds;
1184− u32 min_micro_seconds;
1185− u16 seconds;
1082+ u32 max_tick_count;
1083+ u32 ticks_per_millisecond;
1084+ u16 profile_interval;
11861085 };
11871086
11881087 struct hpi_profile_res_name {
@@ -1218,7 +1117,6 @@ struct hpi_message { · 29 unmodified lines
12181117 u16 obj_index; /* */
12191118 union {
12201119 struct hpi_subsys_msg s;
1221− struct hpi_adapter_msg a;
12221120 union hpi_adapterx_msg ax;
12231121 struct hpi_stream_msg d;
12241122 struct hpi_mixer_msg m;
@@ -1239,7 +1137,7 @@ struct hpi_message { · 14 unmodified lines
12391137 };
12401138
12411139 #define HPI_MESSAGE_SIZE_BY_OBJECT { \
1242− sizeof(struct hpi_message_header) , /* default, no object type 0 */ \
1140+ sizeof(struct hpi_message_header) , /* Default, no object type 0 */ \
12431141 sizeof(struct hpi_message_header) + sizeof(struct hpi_subsys_msg),\
12441142 sizeof(struct hpi_message_header) + sizeof(union hpi_adapterx_msg),\
12451143 sizeof(struct hpi_message_header) + sizeof(struct hpi_stream_msg),\
@@ -1256,6 +1154,11 @@ struct hpi_message { · 10 unmodified lines
12561154 sizeof(struct hpi_message_header) + sizeof(struct hpi_async_msg) \
12571155 }
12581156
1157+/*
1158+Note that the wSpecificError error field should be inspected and potentially
1159+reported whenever HPI_ERROR_DSP_COMMUNICATION or HPI_ERROR_DSP_BOOTLOAD is
1160+returned in wError.
1161+*/
12591162 struct hpi_response_header {
12601163 u16 size;
12611164 u8 type; /* HPI_TYPE_RESPONSE */
@@ -1277,7 +1180,6 @@ struct hpi_response { · 15 unmodified lines
12771180 u16 specific_error; /* adapter specific error */
12781181 union {
12791182 struct hpi_subsys_res s;
1280− struct hpi_adapter_res a;
12811183 union hpi_adapterx_res ax;
12821184 struct hpi_stream_res d;
12831185 struct hpi_mixer_res m;
@@ -1297,7 +1199,7 @@ struct hpi_response { · 13 unmodified lines
12971199 };
12981200
12991201 #define HPI_RESPONSE_SIZE_BY_OBJECT { \
1300− sizeof(struct hpi_response_header) ,/* default, no object type 0 */ \
1202+ sizeof(struct hpi_response_header) ,/* Default, no object type 0 */ \
13011203 sizeof(struct hpi_response_header) + sizeof(struct hpi_subsys_res),\
13021204 sizeof(struct hpi_response_header) + sizeof(union hpi_adapterx_res),\
13031205 sizeof(struct hpi_response_header) + sizeof(struct hpi_stream_res),\
@@ -1314,7 +1216,7 @@ struct hpi_response { · 10 unmodified lines
13141216 sizeof(struct hpi_response_header) + sizeof(struct hpi_async_res) \
13151217 }
13161218
1317−/*********************** version 1 message/response *****************************/
1219+/*********************** version 1 message/response **************************/
13181220 #define HPINET_ETHERNET_DATA_SIZE (1500)
13191221 #define HPINET_IP_HDR_SIZE (20)
13201222 #define HPINET_IP_DATA_SIZE (HPINET_ETHERNET_DATA_SIZE - HPINET_IP_HDR_SIZE)
@@ -1394,6 +1296,17 @@ struct hpi_res_adapter_program_flash { · 73 unmodified lines
13941296 sizeof(struct hpi_response_header) - sizeof(u16)];
13951297 };
13961298
1299+struct hpi_msg_adapter_debug_read {
1300+ struct hpi_message_header h;
1301+ u32 dsp_address;
1302+ u32 count_bytes;
1303+};
1304+
1305+struct hpi_res_adapter_debug_read {
1306+ struct hpi_response_header h;
1307+ u8 bytes[256];
1308+};
1309+
13971310 #if 1
13981311 #define hpi_message_header_v1 hpi_message_header
13991312 #define hpi_response_header_v1 hpi_response_header
@@ -1414,23 +1327,10 @@ struct hpi_response_header_v1 { · 14 unmodified lines
14141327 };
14151328 #endif
14161329
1417−/* STRV HPI Packet */
1418−struct hpi_msg_strv {
1419− struct hpi_message_header h;
1420− struct hpi_entity strv;
1421−};
1422−
1423−struct hpi_res_strv {
1424− struct hpi_response_header h;
1425− struct hpi_entity strv;
1426−};
1427−#define MIN_STRV_PACKET_SIZE sizeof(struct hpi_res_strv)
1428−
14291330 struct hpi_msg_payload_v0 {
14301331 struct hpi_message_header h;
14311332 union {
14321333 struct hpi_subsys_msg s;
1433− struct hpi_adapter_msg a;
14341334 union hpi_adapterx_msg ax;
14351335 struct hpi_stream_msg d;
14361336 struct hpi_mixer_msg m;
@@ -1451,7 +1351,6 @@ struct hpi_res_payload_v0 { · 14 unmodified lines
14511351 struct hpi_response_header h;
14521352 union {
14531353 struct hpi_subsys_res s;
1454− struct hpi_adapter_res a;
14551354 union hpi_adapterx_res ax;
14561355 struct hpi_stream_res d;
14571356 struct hpi_mixer_res m;
@@ -1471,13 +1370,13 @@ struct hpi_res_payload_v0 { · 13 unmodified lines
14711370 union hpi_message_buffer_v1 {
14721371 struct hpi_message m0; /* version 0 */
14731372 struct hpi_message_header_v1 h;
1474− unsigned char buf[HPI_MAX_PAYLOAD_SIZE];
1373+ u8 buf[HPI_MAX_PAYLOAD_SIZE];
14751374 };
14761375
14771376 union hpi_response_buffer_v1 {
14781377 struct hpi_response r0; /* version 0 */
14791378 struct hpi_response_header_v1 h;
1480− unsigned char buf[HPI_MAX_PAYLOAD_SIZE];
1379+ u8 buf[HPI_MAX_PAYLOAD_SIZE];
14811380 };
14821381
14831382 compile_time_assert((sizeof(union hpi_message_buffer_v1) <=
@@ -1499,6 +1398,11 @@ struct hpi_control_defn { · 15 unmodified lines
14991398 /*////////////////////////////////////////////////////////////////////////// */
15001399 /* declarations for control caching (internal to HPI<->DSP interaction) */
15011400
1401+/** indicates a cached u16 value is invalid. */
1402+#define HPI_CACHE_INVALID_UINT16 0xFFFF
1403+/** indicates a cached short value is invalid. */
1404+#define HPI_CACHE_INVALID_SHORT -32768
1405+
15021406 /** A compact representation of (part of) a controls state.
15031407 Used for efficient transfer of the control state
15041408 between DSP and host or across a network
@@ -1512,58 +1416,104 @@ struct hpi_control_cache_info { · 7 unmodified lines
15121416 u16 control_index;
15131417 };
15141418
1515−struct hpi_control_cache_single {
1419+struct hpi_control_cache_vol {
1420+ struct hpi_control_cache_info i;
1421+ short an_log[2];
1422+ unsigned short flags;
1423+ char padding[2];
1424+};
1425+
1426+struct hpi_control_cache_meter {
1427+ struct hpi_control_cache_info i;
1428+ short an_log_peak[2];
1429+ short an_logRMS[2];
1430+};
1431+
1432+struct hpi_control_cache_channelmode {
1433+ struct hpi_control_cache_info i;
1434+ u16 mode;
1435+ char temp_padding[6];
1436+};
1437+
1438+struct hpi_control_cache_mux {
1439+ struct hpi_control_cache_info i;
1440+ u16 source_node_type;
1441+ u16 source_node_index;
1442+ char temp_padding[4];
1443+};
1444+
1445+struct hpi_control_cache_level {
15161446 struct hpi_control_cache_info i;
1447+ short an_log[2];
1448+ char temp_padding[4];
1449+};
1450+
1451+struct hpi_control_cache_tuner {
1452+ struct hpi_control_cache_info i;
1453+ u32 freq_ink_hz;
1454+ u16 band;
1455+ short s_level_avg;
1456+};
1457+
1458+struct hpi_control_cache_aes3rx {
1459+ struct hpi_control_cache_info i;
1460+ u32 error_status;
1461+ u32 format;
1462+};
1463+
1464+struct hpi_control_cache_aes3tx {
1465+ struct hpi_control_cache_info i;
1466+ u32 format;
1467+ char temp_padding[4];
1468+};
1469+
1470+struct hpi_control_cache_tonedetector {
1471+ struct hpi_control_cache_info i;
1472+ u16 state;
1473+ char temp_padding[6];
1474+};
1475+
1476+struct hpi_control_cache_silencedetector {
1477+ struct hpi_control_cache_info i;
1478+ u32 state;
1479+ char temp_padding[4];
1480+};
1481+
1482+struct hpi_control_cache_sampleclock {
1483+ struct hpi_control_cache_info i;
1484+ u16 source;
1485+ u16 source_index;
1486+ u32 sample_rate;
1487+};
1488+
1489+struct hpi_control_cache_microphone {
1490+ struct hpi_control_cache_info i;
1491+ u16 phantom_state;
1492+ char temp_padding[6];
1493+};
1494+
1495+struct hpi_control_cache_generic {
1496+ struct hpi_control_cache_info i;
1497+ u32 dw1;
1498+ u32 dw2;
1499+};
1500+
1501+struct hpi_control_cache_single {
15171502 union {
1518− struct { /* volume */
1519− short an_log[2];
1520− } v;
1521− struct { /* peak meter */
1522− short an_log_peak[2];
1523− short an_logRMS[2];
1524− } p;
1525− struct { /* channel mode */
1526− u16 mode;
1527− } m;
1528− struct { /* multiplexer */
1529− u16 source_node_type;
1530− u16 source_node_index;
1531− } x;
1532− struct { /* level/trim */
1533− short an_log[2];
1534− } l;
1535− struct { /* tuner - partial caching.
1536− some attributes go to the DSP. */
1537− u32 freq_ink_hz;
1538− u16 band;
1539− u16 level;
1540− } t;
1541− struct { /* AESEBU rx status */
1542− u32 error_status;
1543− u32 source;
1544− } aes3rx;
1545− struct { /* AESEBU tx */
1546− u32 format;
1547− } aes3tx;
1548− struct { /* tone detector */
1549− u16 state;
1550− } tone;
1551− struct { /* silence detector */
1552− u32 state;
1553− u32 count;
1554− } silence;
1555− struct { /* sample clock */
1556− u16 source;
1557− u16 source_index;
1558− u32 sample_rate;
1559− } clk;
1560− struct { /* microphone control */
1561− u16 state;
1562− } phantom_power;
1563− struct { /* generic control */
1564− u32 dw1;
1565− u32 dw2;
1566− } g;
1503+ struct hpi_control_cache_info i;
1504+ struct hpi_control_cache_vol vol;
1505+ struct hpi_control_cache_meter meter;
1506+ struct hpi_control_cache_channelmode mode;
1507+ struct hpi_control_cache_mux mux;
1508+ struct hpi_control_cache_level level;
1509+ struct hpi_control_cache_tuner tuner;
1510+ struct hpi_control_cache_aes3rx aes3rx;
1511+ struct hpi_control_cache_aes3tx aes3tx;
1512+ struct hpi_control_cache_tonedetector tone;
1513+ struct hpi_control_cache_silencedetector silence;
1514+ struct hpi_control_cache_sampleclock clk;
1515+ struct hpi_control_cache_microphone microphone;
1516+ struct hpi_control_cache_generic generic;
15671517 } u;
15681518 };
15691519
@@ -1580,8 +1530,7 @@ struct hpi_control_cache_pad { · 10 unmodified lines
15801530 u32 traffic_anouncement;
15811531 };
15821532
1583−/*/////////////////////////////////////////////////////////////////////////// */
1584−/* declarations for 2^N sized FIFO buffer (internal to HPI<->DSP interaction) */
1533+/* 2^N sized FIFO buffer (internal to HPI<->DSP interaction) */
15851534 struct hpi_fifo_buffer {
15861535 u32 size;
15871536 u32 dSP_index;
@@ -1606,25 +1555,18 @@ u32 hpi_indexes_to_handle(const char c_object, const u16 adapter_index, · 18 unmodified lines
16061555 /*////////////////////////////////////////////////////////////////////////// */
16071556
16081557 /* main HPI entry point */
1609−hpi_handler_func hpi_send_recv;
1610−
1611−/* UDP message */
1612−void hpi_send_recvUDP(struct hpi_message *phm, struct hpi_response *phr,
1613− const unsigned int timeout);
1558+void hpi_send_recv(struct hpi_message *phm, struct hpi_response *phr);
16141559
16151560 /* used in PnP OS/driver */
1616−u16 hpi_subsys_create_adapter(const struct hpi_hsubsys *ph_subsys,
1617− const struct hpi_resource *p_resource, u16 *pw_adapter_index);
1561+u16 hpi_subsys_create_adapter(const struct hpi_resource *p_resource,
1562+ u16 *pw_adapter_index);
16181563
1619−u16 hpi_subsys_delete_adapter(const struct hpi_hsubsys *ph_subsys,
1620− u16 adapter_index);
1564+u16 hpi_subsys_delete_adapter(u16 adapter_index);
16211565
1622−u16 hpi_outstream_host_buffer_get_info(const struct hpi_hsubsys *ph_subsys,
1623− u32 h_outstream, u8 **pp_buffer,
1566+u16 hpi_outstream_host_buffer_get_info(u32 h_outstream, u8 **pp_buffer,
16241567 struct hpi_hostbuffer_status **pp_status);
16251568
1626−u16 hpi_instream_host_buffer_get_info(const struct hpi_hsubsys *ph_subsys,
1627− u32 h_instream, u8 **pp_buffer,
1569+u16 hpi_instream_host_buffer_get_info(u32 h_instream, u8 **pp_buffer,
16281570 struct hpi_hostbuffer_status **pp_status);
16291571
16301572 u16 hpi_adapter_restart(u16 adapter_index);
sound/pci/asihpi/hpicmn.c+265−215
@@ -26,6 +26,8 @@ · 25 unmodified lines
2626
2727 #include "hpi_internal.h"
2828 #include "hpidebug.h"
29+#include "hpimsginit.h"
30+
2931 #include "hpicmn.h"
3032
3133 struct hpi_adapters_list {
@@ -43,14 +45,24 @@ static struct hpi_adapters_list adapters; · 11 unmodified lines
4345 **/
4446 u16 hpi_validate_response(struct hpi_message *phm, struct hpi_response *phr)
4547 {
46− u16 error = 0;
48+ if (phr->type != HPI_TYPE_RESPONSE) {
49+ HPI_DEBUG_LOG(ERROR, "header type %d invalid\n", phr->type);
50+ return HPI_ERROR_INVALID_RESPONSE;
51+ }
4752
48− if ((phr->type != HPI_TYPE_RESPONSE)
49− || (phr->object != phm->object)
50− || (phr->function != phm->function))
51− error = HPI_ERROR_INVALID_RESPONSE;
53+ if (phr->object != phm->object) {
54+ HPI_DEBUG_LOG(ERROR, "header object %d invalid\n",
55+ phr->object);
56+ return HPI_ERROR_INVALID_RESPONSE;
57+ }
58+
59+ if (phr->function != phm->function) {
60+ HPI_DEBUG_LOG(ERROR, "header type %d invalid\n",
61+ phr->function);
62+ return HPI_ERROR_INVALID_RESPONSE;
63+ }
5264
53− return error;
65+ return 0;
5466 }
5567
5668 u16 hpi_add_adapter(struct hpi_adapter_obj *pao)
@@ -66,8 +78,18 @@ u16 hpi_add_adapter(struct hpi_adapter_obj *pao) · 9 unmodified lines
6678 }
6779
6880 if (adapters.adapter[pao->index].adapter_type) {
69− {
70− retval = HPI_DUPLICATE_ADAPTER_NUMBER;
81+ int a;
82+ for (a = HPI_MAX_ADAPTERS - 1; a >= 0; a--) {
83+ if (!adapters.adapter[a].adapter_type) {
84+ HPI_DEBUG_LOG(WARNING,
85+ "ASI%X duplicate index %d moved to %d\n",
86+ pao->adapter_type, pao->index, a);
87+ pao->index = a;
88+ break;
89+ }
90+ }
91+ if (a < 0) {
92+ retval = HPI_ERROR_DUPLICATE_ADAPTER_NUMBER;
7193 goto unlock;
7294 }
7395 }
@@ -76,17 +98,22 @@ u16 hpi_add_adapter(struct hpi_adapter_obj *pao) · 2 unmodified lines
7698 adapters.gw_num_adapters++;
7799
78100 unlock:
79− hpios_alistlock_un_lock(&adapters);
101+ hpios_alistlock_unlock(&adapters);
80102 return retval;
81103 }
82104
83105 void hpi_delete_adapter(struct hpi_adapter_obj *pao)
84106 {
85− memset(pao, 0, sizeof(struct hpi_adapter_obj));
107+ if (!pao->adapter_type) {
108+ HPI_DEBUG_LOG(ERROR, "removing null adapter?\n");
109+ return;
110+ }
86111
87112 hpios_alistlock_lock(&adapters);
88− adapters.gw_num_adapters--; /* dec the number of adapters */
89− hpios_alistlock_un_lock(&adapters);
113+ if (adapters.adapter[pao->index].adapter_type)
114+ adapters.gw_num_adapters--;
115+ memset(&adapters.adapter[pao->index], 0, sizeof(adapters.adapter[0]));
116+ hpios_alistlock_unlock(&adapters);
90117 }
91118
92119 /**
@@ -99,7 +126,7 @@ struct hpi_adapter_obj *hpi_find_adapter(u16 adapter_index) · 6 unmodified lines
99126 struct hpi_adapter_obj *pao = NULL;
100127
101128 if (adapter_index >= HPI_MAX_ADAPTERS) {
102− HPI_DEBUG_LOG(VERBOSE, "find_adapter invalid index %d ",
129+ HPI_DEBUG_LOG(VERBOSE, "find_adapter invalid index %d\n",
103130 adapter_index);
104131 return NULL;
105132 }
@@ -125,51 +152,34 @@ struct hpi_adapter_obj *hpi_find_adapter(u16 adapter_index) · 19 unmodified lines
125152 * wipe an HPI_ADAPTERS_LIST structure.
126153 *
127154 **/
128−static void wipe_adapter_list(void
129− )
155+static void wipe_adapter_list(void)
130156 {
131157 memset(&adapters, 0, sizeof(adapters));
132158 }
133159
134−/**
135−* SubSysGetAdapters fills awAdapterList in an struct hpi_response structure
136−* with all adapters in the given HPI_ADAPTERS_LIST.
137−*
138−*/
139−static void subsys_get_adapters(struct hpi_response *phr)
160+static void subsys_get_adapter(struct hpi_message *phm,
161+ struct hpi_response *phr)
140162 {
141− /* fill in the response adapter array with the position */
142− /* identified by the adapter number/index of the adapters in */
143− /* this HPI */
144− /* i.e. if we have an A120 with it's jumper set to */
145− /* Adapter Number 2 then put an Adapter type A120 in the */
146− /* array in position 1 */
147− /* NOTE: AdapterNumber is 1..N, Index is 0..N-1 */
148−
149− /* input: NONE */
150− /* output: wNumAdapters */
151− /* awAdapter[] */
152− /* */
153−
154− short i;
155− struct hpi_adapter_obj *pao = NULL;
163+ int count = phm->obj_index;
164+ u16 index = 0;
156165
157− HPI_DEBUG_LOG(VERBOSE, "subsys_get_adapters\n");
158−
159− /* for each adapter, place it's type in the position of the array */
160− /* corresponding to it's adapter number */
161− for (i = 0; i < adapters.gw_num_adapters; i++) {
162− pao = &adapters.adapter[i];
163− if (phr->u.s.aw_adapter_list[pao->index] != 0) {
164− phr->error = HPI_DUPLICATE_ADAPTER_NUMBER;
165− phr->specific_error = pao->index;
166− return;
166+ /* find the nCount'th nonzero adapter in array */
167+ for (index = 0; index < HPI_MAX_ADAPTERS; index++) {
168+ if (adapters.adapter[index].adapter_type) {
169+ if (!count)
170+ break;
171+ count--;
167172 }
168− phr->u.s.aw_adapter_list[pao->index] = pao->adapter_type;
169173 }
170174
171− phr->u.s.num_adapters = adapters.gw_num_adapters;
172− phr->error = 0; /* the function completed OK; */
175+ if (index < HPI_MAX_ADAPTERS) {
176+ phr->u.s.adapter_index = adapters.adapter[index].index;
177+ phr->u.s.adapter_type = adapters.adapter[index].adapter_type;
178+ } else {
179+ phr->u.s.adapter_index = 0;
180+ phr->u.s.adapter_type = 0;
181+ phr->error = HPI_ERROR_BAD_ADAPTER_NUMBER;
182+ }
173183 }
174184
175185 static unsigned int control_cache_alloc_check(struct hpi_control_cache *pC)
@@ -178,67 +188,98 @@ static unsigned int control_cache_alloc_check(struct hpi_control_cache *pC) · 2 unmodified lines
178188 int cached = 0;
179189 if (!pC)
180190 return 0;
181− if ((!pC->init) && (pC->p_cache != NULL) && (pC->control_count)
182− && (pC->cache_size_in_bytes)
183− ) {
184− u32 *p_master_cache;
185− pC->init = 1;
186−
187− p_master_cache = (u32 *)pC->p_cache;
188− HPI_DEBUG_LOG(VERBOSE, "check %d controls\n",
191+
192+ if (pC->init)
193+ return pC->init;
194+
195+ if (!pC->p_cache)
196+ return 0;
197+
198+ if (pC->control_count && pC->cache_size_in_bytes) {
199+ char *p_master_cache;
200+ unsigned int byte_count = 0;
201+
202+ p_master_cache = (char *)pC->p_cache;
203+ HPI_DEBUG_LOG(DEBUG, "check %d controls\n",
189204 pC->control_count);
190205 for (i = 0; i < pC->control_count; i++) {
191206 struct hpi_control_cache_info *info =
192207 (struct hpi_control_cache_info *)
193− p_master_cache;
208+ &p_master_cache[byte_count];
209+
210+ if (!info->size_in32bit_words) {
211+ if (!i) {
212+ HPI_DEBUG_LOG(INFO,
213+ "adap %d cache not ready?\n",
214+ pC->adap_idx);
215+ return 0;
216+ }
217+ /* The cache is invalid.
218+ * Minimum valid entry size is
219+ * sizeof(struct hpi_control_cache_info)
220+ */
221+ HPI_DEBUG_LOG(ERROR,
222+ "adap %d zero size cache entry %d\n",
223+ pC->adap_idx, i);
224+ break;
225+ }
194226
195227 if (info->control_type) {
196− pC->p_info[i] = info;
228+ pC->p_info[info->control_index] = info;
197229 cached++;
198− } else
199− pC->p_info[i] = NULL;
230+ } else /* dummy cache entry */
231+ pC->p_info[info->control_index] = NULL;
200232
201− if (info->size_in32bit_words)
202− p_master_cache += info->size_in32bit_words;
203− else
204− p_master_cache +=
205− sizeof(struct
206− hpi_control_cache_single) /
207− sizeof(u32);
233+ byte_count += info->size_in32bit_words * 4;
208234
209235 HPI_DEBUG_LOG(VERBOSE,
210− "cached %d, pinfo %p index %d type %d\n",
211− cached, pC->p_info[i], info->control_index,
212− info->control_type);
236+ "cached %d, pinfo %p index %d type %d size %d\n",
237+ cached, pC->p_info[info->control_index],
238+ info->control_index, info->control_type,
239+ info->size_in32bit_words);
240+
241+ /* quit loop early if whole cache has been scanned.
242+ * dwControlCount is the maximum possible entries
243+ * but some may be absent from the cache
244+ */
245+ if (byte_count >= pC->cache_size_in_bytes)
246+ break;
247+ /* have seen last control index */
248+ if (info->control_index == pC->control_count - 1)
249+ break;
213250 }
214− /*
215− We didn't find anything to cache, so try again later !
216− */
217− if (!cached)
218− pC->init = 0;
251+
252+ if (byte_count != pC->cache_size_in_bytes)
253+ HPI_DEBUG_LOG(WARNING,
254+ "adap %d bytecount %d != cache size %d\n",
255+ pC->adap_idx, byte_count,
256+ pC->cache_size_in_bytes);
257+ else
258+ HPI_DEBUG_LOG(DEBUG,
259+ "adap %d cache good, bytecount == cache size = %d\n",
260+ pC->adap_idx, byte_count);
261+
262+ pC->init = (u16)cached;
219263 }
220264 return pC->init;
221265 }
222266
223267 /** Find a control.
224268 */
225−static short find_control(struct hpi_message *phm,
226− struct hpi_control_cache *p_cache, struct hpi_control_cache_info **pI,
227− u16 *pw_control_index)
269+static short find_control(u16 control_index,
270+ struct hpi_control_cache *p_cache, struct hpi_control_cache_info **pI)
228271 {
229− *pw_control_index = phm->obj_index;
230−
231272 if (!control_cache_alloc_check(p_cache)) {
232273 HPI_DEBUG_LOG(VERBOSE,
233− "control_cache_alloc_check() failed. adap%d ci%d\n",
234− phm->adapter_index, *pw_control_index);
274+ "control_cache_alloc_check() failed %d\n",
275+ control_index);
235276 return 0;
236277 }
237278
238− *pI = p_cache->p_info[*pw_control_index];
279+ *pI = p_cache->p_info[control_index];
239280 if (!*pI) {
240− HPI_DEBUG_LOG(VERBOSE, "uncached adap %d, control %d\n",
241− phm->adapter_index, *pw_control_index);
281+ HPI_DEBUG_LOG(VERBOSE, "Uncached Control %d\n",
282+ control_index);
242283 return 0;
243284 } else {
244285 HPI_DEBUG_LOG(VERBOSE, "find_control() type %d\n",
@@ -247,25 +288,6 @@ static short find_control(struct hpi_message *phm, · 2 unmodified lines
247288 return 1;
248289 }
249290
250−/** Used by the kernel driver to figure out if a buffer needs mapping.
251− */
252−short hpi_check_buffer_mapping(struct hpi_control_cache *p_cache,
253− struct hpi_message *phm, void **p, unsigned int *pN)
254−{
255− *pN = 0;
256− *p = NULL;
257− if ((phm->function == HPI_CONTROL_GET_STATE)
258− && (phm->object == HPI_OBJ_CONTROLEX)
259− ) {
260− u16 control_index;
261− struct hpi_control_cache_info *pI;
262−
263− if (!find_control(phm, p_cache, &pI, &control_index))
264− return 0;
265− }
266− return 0;
267−}
268−
269291 /* allow unified treatment of several string fields within struct */
270292 #define HPICMN_PAD_OFS_AND_SIZE(m) {\
271293 offsetof(struct hpi_control_cache_pad, m), \
@@ -290,13 +312,16 @@ short hpi_check_control_cache(struct hpi_control_cache *p_cache, · 18 unmodified lines
290312 struct hpi_message *phm, struct hpi_response *phr)
291313 {
292314 short found = 1;
293− u16 control_index;
294315 struct hpi_control_cache_info *pI;
295316 struct hpi_control_cache_single *pC;
296317 struct hpi_control_cache_pad *p_pad;
297318
298− if (!find_control(phm, p_cache, &pI, &control_index))
319+ if (!find_control(phm->obj_index, p_cache, &pI)) {
320+ HPI_DEBUG_LOG(VERBOSE,
321+ "HPICMN find_control() failed for adap %d\n",
322+ phm->adapter_index);
299323 return 0;
324+ }
300325
301326 phr->error = 0;
302327
@@ -310,55 +335,79 @@ short hpi_check_control_cache(struct hpi_control_cache *p_cache, · 7 unmodified lines
310335
311336 case HPI_CONTROL_METER:
312337 if (phm->u.c.attribute == HPI_METER_PEAK) {
313− phr->u.c.an_log_value[0] = pC->u.p.an_log_peak[0];
314− phr->u.c.an_log_value[1] = pC->u.p.an_log_peak[1];
338+ phr->u.c.an_log_value[0] = pC->u.meter.an_log_peak[0];
339+ phr->u.c.an_log_value[1] = pC->u.meter.an_log_peak[1];
315340 } else if (phm->u.c.attribute == HPI_METER_RMS) {
316− phr->u.c.an_log_value[0] = pC->u.p.an_logRMS[0];
317− phr->u.c.an_log_value[1] = pC->u.p.an_logRMS[1];
341+ if (pC->u.meter.an_logRMS[0] ==
342+ HPI_CACHE_INVALID_SHORT) {
343+ phr->error =
344+ HPI_ERROR_INVALID_CONTROL_ATTRIBUTE;
345+ phr->u.c.an_log_value[0] = HPI_METER_MINIMUM;
346+ phr->u.c.an_log_value[1] = HPI_METER_MINIMUM;
347+ } else {
348+ phr->u.c.an_log_value[0] =
349+ pC->u.meter.an_logRMS[0];
350+ phr->u.c.an_log_value[1] =
351+ pC->u.meter.an_logRMS[1];
352+ }
318353 } else
319354 found = 0;
320355 break;
321356 case HPI_CONTROL_VOLUME:
322357 if (phm->u.c.attribute == HPI_VOLUME_GAIN) {
323− phr->u.c.an_log_value[0] = pC->u.v.an_log[0];
324− phr->u.c.an_log_value[1] = pC->u.v.an_log[1];
325− } else
358+ phr->u.c.an_log_value[0] = pC->u.vol.an_log[0];
359+ phr->u.c.an_log_value[1] = pC->u.vol.an_log[1];
360+ } else if (phm->u.c.attribute == HPI_VOLUME_MUTE) {
361+ if (pC->u.vol.flags & HPI_VOLUME_FLAG_HAS_MUTE) {
362+ if (pC->u.vol.flags & HPI_VOLUME_FLAG_MUTED)
363+ phr->u.c.param1 =
364+ HPI_BITMASK_ALL_CHANNELS;
365+ else
366+ phr->u.c.param1 = 0;
367+ } else {
368+ phr->error =
369+ HPI_ERROR_INVALID_CONTROL_ATTRIBUTE;
370+ phr->u.c.param1 = 0;
371+ }
372+ } else {
326373 found = 0;
374+ }
327375 break;
328376 case HPI_CONTROL_MULTIPLEXER:
329377 if (phm->u.c.attribute == HPI_MULTIPLEXER_SOURCE) {
330− phr->u.c.param1 = pC->u.x.source_node_type;
331− phr->u.c.param2 = pC->u.x.source_node_index;
378+ phr->u.c.param1 = pC->u.mux.source_node_type;
379+ phr->u.c.param2 = pC->u.mux.source_node_index;
332380 } else {
333381 found = 0;
334382 }
335383 break;
336384 case HPI_CONTROL_CHANNEL_MODE:
337385 if (phm->u.c.attribute == HPI_CHANNEL_MODE_MODE)
338− phr->u.c.param1 = pC->u.m.mode;
386+ phr->u.c.param1 = pC->u.mode.mode;
339387 else
340388 found = 0;
341389 break;
342390 case HPI_CONTROL_LEVEL:
343391 if (phm->u.c.attribute == HPI_LEVEL_GAIN) {
344− phr->u.c.an_log_value[0] = pC->u.l.an_log[0];
345− phr->u.c.an_log_value[1] = pC->u.l.an_log[1];
392+ phr->u.c.an_log_value[0] = pC->u.level.an_log[0];
393+ phr->u.c.an_log_value[1] = pC->u.level.an_log[1];
346394 } else
347395 found = 0;
348396 break;
349397 case HPI_CONTROL_TUNER:
350398 if (phm->u.c.attribute == HPI_TUNER_FREQ)
351− phr->u.c.param1 = pC->u.t.freq_ink_hz;
399+ phr->u.c.param1 = pC->u.tuner.freq_ink_hz;
352400 else if (phm->u.c.attribute == HPI_TUNER_BAND)
353− phr->u.c.param1 = pC->u.t.band;
354− else if ((phm->u.c.attribute == HPI_TUNER_LEVEL)
355− && (phm->u.c.param1 == HPI_TUNER_LEVEL_AVERAGE))
356− if (pC->u.t.level == HPI_ERROR_ILLEGAL_CACHE_VALUE) {
357− phr->u.c.param1 = 0;
401+ phr->u.c.param1 = pC->u.tuner.band;
402+ else if (phm->u.c.attribute == HPI_TUNER_LEVEL_AVG)
403+ if (pC->u.tuner.s_level_avg ==
404+ HPI_CACHE_INVALID_SHORT) {
405+ phr->u.cu.tuner.s_level = 0;
358406 phr->error =
359407 HPI_ERROR_INVALID_CONTROL_ATTRIBUTE;
360408 } else
361− phr->u.c.param1 = pC->u.t.level;
409+ phr->u.cu.tuner.s_level =
410+ pC->u.tuner.s_level_avg;
362411 else
363412 found = 0;
364413 break;
@@ -366,7 +415,7 @@ short hpi_check_control_cache(struct hpi_control_cache *p_cache, · 1 unmodified line
366415 if (phm->u.c.attribute == HPI_AESEBURX_ERRORSTATUS)
367416 phr->u.c.param1 = pC->u.aes3rx.error_status;
368417 else if (phm->u.c.attribute == HPI_AESEBURX_FORMAT)
369− phr->u.c.param1 = pC->u.aes3rx.source;
418+ phr->u.c.param1 = pC->u.aes3rx.format;
370419 else
371420 found = 0;
372421 break;
@@ -385,13 +434,12 @@ short hpi_check_control_cache(struct hpi_control_cache *p_cache, · 12 unmodified lines
385434 case HPI_CONTROL_SILENCEDETECTOR:
386435 if (phm->u.c.attribute == HPI_SILENCEDETECTOR_STATE) {
387436 phr->u.c.param1 = pC->u.silence.state;
388− phr->u.c.param2 = pC->u.silence.count;
389437 } else
390438 found = 0;
391439 break;
392440 case HPI_CONTROL_MICROPHONE:
393441 if (phm->u.c.attribute == HPI_MICROPHONE_PHANTOM_POWER)
394− phr->u.c.param1 = pC->u.phantom_power.state;
442+ phr->u.c.param1 = pC->u.microphone.phantom_state;
395443 else
396444 found = 0;
397445 break;
@@ -400,7 +448,7 @@ short hpi_check_control_cache(struct hpi_control_cache *p_cache, · 2 unmodified lines
400448 phr->u.c.param1 = pC->u.clk.source;
401449 else if (phm->u.c.attribute == HPI_SAMPLECLOCK_SOURCE_INDEX) {
402450 if (pC->u.clk.source_index ==
403− HPI_ERROR_ILLEGAL_CACHE_VALUE) {
451+ HPI_CACHE_INVALID_UINT16) {
404452 phr->u.c.param1 = 0;
405453 phr->error =
406454 HPI_ERROR_INVALID_CONTROL_ATTRIBUTE;
@@ -411,60 +459,63 @@ short hpi_check_control_cache(struct hpi_control_cache *p_cache, · 4 unmodified lines
411459 else
412460 found = 0;
413461 break;
414− case HPI_CONTROL_PAD:
462+ case HPI_CONTROL_PAD:{
463+ struct hpi_control_cache_pad *p_pad;
464+ p_pad = (struct hpi_control_cache_pad *)pI;
415465
416− if (!(p_pad->field_valid_flags & (1 <<
417− HPI_CTL_ATTR_INDEX(phm->u.c.
418− attribute)))) {
419− phr->error = HPI_ERROR_INVALID_CONTROL_ATTRIBUTE;
420− break;
421− }
422−
423− if (phm->u.c.attribute == HPI_PAD_PROGRAM_ID)
424− phr->u.c.param1 = p_pad->pI;
425− else if (phm->u.c.attribute == HPI_PAD_PROGRAM_TYPE)
426− phr->u.c.param1 = p_pad->pTY;
427− else {
428− unsigned int index =
429− HPI_CTL_ATTR_INDEX(phm->u.c.attribute) - 1;
430− unsigned int offset = phm->u.c.param1;
431− unsigned int pad_string_len, field_size;
432− char *pad_string;
433− unsigned int tocopy;
434−
435− HPI_DEBUG_LOG(VERBOSE, "PADS HPI_PADS_ %d\n",
436− phm->u.c.attribute);
437−
438− if (index > ARRAY_SIZE(pad_desc) - 1) {
466+ if (!(p_pad->field_valid_flags & (1 <<
467+ HPI_CTL_ATTR_INDEX(phm->u.c.
468+ attribute)))) {
439469 phr->error =
440470 HPI_ERROR_INVALID_CONTROL_ATTRIBUTE;
441471 break;
442472 }
443473
444− pad_string = ((char *)p_pad) + pad_desc[index].offset;
445− field_size = pad_desc[index].field_size;
446− /* Ensure null terminator */
447− pad_string[field_size - 1] = 0;
448−
449− pad_string_len = strlen(pad_string) + 1;
450−
451− if (offset > pad_string_len) {
452− phr->error = HPI_ERROR_INVALID_CONTROL_VALUE;
453− break;
474+ if (phm->u.c.attribute == HPI_PAD_PROGRAM_ID)
475+ phr->u.c.param1 = p_pad->pI;
476+ else if (phm->u.c.attribute == HPI_PAD_PROGRAM_TYPE)
477+ phr->u.c.param1 = p_pad->pTY;
478+ else {
479+ unsigned int index =
480+ HPI_CTL_ATTR_INDEX(phm->u.c.
481+ attribute) - 1;
482+ unsigned int offset = phm->u.c.param1;
483+ unsigned int pad_string_len, field_size;
484+ char *pad_string;
485+ unsigned int tocopy;
486+
487+ if (index > ARRAY_SIZE(pad_desc) - 1) {
488+ phr->error =
489+ HPI_ERROR_INVALID_CONTROL_ATTRIBUTE;
490+ break;
491+ }
492+
493+ pad_string =
494+ ((char *)p_pad) +
495+ pad_desc[index].offset;
496+ field_size = pad_desc[index].field_size;
497+ /* Ensure null terminator */
498+ pad_string[field_size - 1] = 0;
499+
500+ pad_string_len = strlen(pad_string) + 1;
501+
502+ if (offset > pad_string_len) {
503+ phr->error =
504+ HPI_ERROR_INVALID_CONTROL_VALUE;
505+ break;
506+ }
507+
508+ tocopy = pad_string_len - offset;
509+ if (tocopy > sizeof(phr->u.cu.chars8.sz_data))
510+ tocopy = sizeof(phr->u.cu.chars8.
511+ sz_data);
512+
513+ memcpy(phr->u.cu.chars8.sz_data,
514+ &pad_string[offset], tocopy);
515+
516+ phr->u.cu.chars8.remaining_chars =
517+ pad_string_len - offset - tocopy;
454518 }
455−
456− tocopy = pad_string_len - offset;
457− if (tocopy > sizeof(phr->u.cu.chars8.sz_data))
458− tocopy = sizeof(phr->u.cu.chars8.sz_data);
459−
460− HPI_DEBUG_LOG(VERBOSE,
461− "PADS memcpy(%d), offset %d \n", tocopy,
462− offset);
463− memcpy(phr->u.cu.chars8.sz_data, &pad_string[offset],
464− tocopy);
465−
466− phr->u.cu.chars8.remaining_chars =
467− pad_string_len - offset - tocopy;
468519 }
469520 break;
470521 default:
@@ -472,16 +523,9 @@ short hpi_check_control_cache(struct hpi_control_cache *p_cache, · 1 unmodified line
472523 break;
473524 }
474525
475− if (found)
476− HPI_DEBUG_LOG(VERBOSE,
477− "cached adap %d, ctl %d, type %d, attr %d\n",
478− phm->adapter_index, pI->control_index,
479− pI->control_type, phm->u.c.attribute);
480− else
481− HPI_DEBUG_LOG(VERBOSE,
482− "uncached adap %d, ctl %d, ctl type %d\n",
483− phm->adapter_index, pI->control_index,
484− pI->control_type);
526+ HPI_DEBUG_LOG(VERBOSE, "%s Adap %d, Ctl %d, Type %d, Attr %d\n",
527+ found ? "Cached" : "Uncached", phm->adapter_index,
528+ pI->control_index, pI->control_type, phm->u.c.attribute);
485529
486530 if (found)
487531 phr->size =
@@ -497,18 +541,21 @@ Only update if no error. · 9 unmodified lines
497541 Volume and Level return the limited values in the response, so use these
498542 Multiplexer does so use sent values
499543 */
500−void hpi_sync_control_cache(struct hpi_control_cache *p_cache,
544+void hpi_cmn_control_cache_sync_to_msg(struct hpi_control_cache *p_cache,
501545 struct hpi_message *phm, struct hpi_response *phr)
502546 {
503− u16 control_index;
504547 struct hpi_control_cache_single *pC;
505548 struct hpi_control_cache_info *pI;
506549
507550 if (phr->error)
508551 return;
509552
510− if (!find_control(phm, p_cache, &pI, &control_index))
553+ if (!find_control(phm->obj_index, p_cache, &pI)) {
554+ HPI_DEBUG_LOG(VERBOSE,
555+ "HPICMN find_control() failed for adap %d\n",
556+ phm->adapter_index);
511557 return;
558+ }
512559
513560 /* pC is the default cached control strucure.
514561 May be cast to something else in the following switch statement.
@@ -518,31 +565,36 @@ void hpi_sync_control_cache(struct hpi_control_cache *p_cache, · 3 unmodified lines
518565 switch (pI->control_type) {
519566 case HPI_CONTROL_VOLUME:
520567 if (phm->u.c.attribute == HPI_VOLUME_GAIN) {
521− pC->u.v.an_log[0] = phr->u.c.an_log_value[0];
522− pC->u.v.an_log[1] = phr->u.c.an_log_value[1];
568+ pC->u.vol.an_log[0] = phr->u.c.an_log_value[0];
569+ pC->u.vol.an_log[1] = phr->u.c.an_log_value[1];
570+ } else if (phm->u.c.attribute == HPI_VOLUME_MUTE) {
571+ if (phm->u.c.param1)
572+ pC->u.vol.flags |= HPI_VOLUME_FLAG_MUTED;
573+ else
574+ pC->u.vol.flags &= ~HPI_VOLUME_FLAG_MUTED;
523575 }
524576 break;
525577 case HPI_CONTROL_MULTIPLEXER:
526578 /* mux does not return its setting on Set command. */
527579 if (phm->u.c.attribute == HPI_MULTIPLEXER_SOURCE) {
528− pC->u.x.source_node_type = (u16)phm->u.c.param1;
529− pC->u.x.source_node_index = (u16)phm->u.c.param2;
580+ pC->u.mux.source_node_type = (u16)phm->u.c.param1;
581+ pC->u.mux.source_node_index = (u16)phm->u.c.param2;
530582 }
531583 break;
532584 case HPI_CONTROL_CHANNEL_MODE:
533585 /* mode does not return its setting on Set command. */
534586 if (phm->u.c.attribute == HPI_CHANNEL_MODE_MODE)
535− pC->u.m.mode = (u16)phm->u.c.param1;
587+ pC->u.mode.mode = (u16)phm->u.c.param1;
536588 break;
537589 case HPI_CONTROL_LEVEL:
538590 if (phm->u.c.attribute == HPI_LEVEL_GAIN) {
539− pC->u.v.an_log[0] = phr->u.c.an_log_value[0];
540− pC->u.v.an_log[1] = phr->u.c.an_log_value[1];
591+ pC->u.vol.an_log[0] = phr->u.c.an_log_value[0];
592+ pC->u.vol.an_log[1] = phr->u.c.an_log_value[1];
541593 }
542594 break;
543595 case HPI_CONTROL_MICROPHONE:
544596 if (phm->u.c.attribute == HPI_MICROPHONE_PHANTOM_POWER)
545− pC->u.phantom_power.state = (u16)phm->u.c.param1;
597+ pC->u.microphone.phantom_state = (u16)phm->u.c.param1;
546598 break;
547599 case HPI_CONTROL_AESEBU_TRANSMITTER:
548600 if (phm->u.c.attribute == HPI_AESEBUTX_FORMAT)
@@ -550,7 +602,7 @@ void hpi_sync_control_cache(struct hpi_control_cache *p_cache, · 1 unmodified line
550602 break;
551603 case HPI_CONTROL_AESEBU_RECEIVER:
552604 if (phm->u.c.attribute == HPI_AESEBURX_FORMAT)
553− pC->u.aes3rx.source = phm->u.c.param1;
605+ pC->u.aes3rx.format = phm->u.c.param1;
554606 break;
555607 case HPI_CONTROL_SAMPLECLOCK:
556608 if (phm->u.c.attribute == HPI_SAMPLECLOCK_SOURCE)
@@ -565,59 +617,57 @@ void hpi_sync_control_cache(struct hpi_control_cache *p_cache, · 8 unmodified lines
565617 }
566618 }
567619
568−struct hpi_control_cache *hpi_alloc_control_cache(const u32
569− number_of_controls, const u32 size_in_bytes,
570− struct hpi_control_cache_info *pDSP_control_buffer)
620+struct hpi_control_cache *hpi_alloc_control_cache(const u32 control_count,
621+ const u32 size_in_bytes, u8 *p_dsp_control_buffer)
571622 {
572623 struct hpi_control_cache *p_cache =
573624 kmalloc(sizeof(*p_cache), GFP_KERNEL);
574625 if (!p_cache)
575626 return NULL;
627+
576628 p_cache->p_info =
577− kmalloc(sizeof(*p_cache->p_info) * number_of_controls,
578− GFP_KERNEL);
629+ kmalloc(sizeof(*p_cache->p_info) * control_count, GFP_KERNEL);
579630 if (!p_cache->p_info) {
580631 kfree(p_cache);
581632 return NULL;
582633 }
634+ memset(p_cache->p_info, 0, sizeof(*p_cache->p_info) * control_count);
583635 p_cache->cache_size_in_bytes = size_in_bytes;
584− p_cache->control_count = number_of_controls;
585− p_cache->p_cache =
586− (struct hpi_control_cache_single *)pDSP_control_buffer;
636+ p_cache->control_count = control_count;
637+ p_cache->p_cache = p_dsp_control_buffer;
587638 p_cache->init = 0;
588639 return p_cache;
589640 }
590641
591642 void hpi_free_control_cache(struct hpi_control_cache *p_cache)
592643 {
593− if (p_cache->init) {
644+ if (p_cache) {
594645 kfree(p_cache->p_info);
595− p_cache->p_info = NULL;
596− p_cache->init = 0;
597646 kfree(p_cache);
598647 }
599648 }
600649
601650 static void subsys_message(struct hpi_message *phm, struct hpi_response *phr)
602651 {
652+ hpi_init_response(phr, HPI_OBJ_SUBSYSTEM, phm->function, 0);
603653
604654 switch (phm->function) {
605655 case HPI_SUBSYS_OPEN:
606656 case HPI_SUBSYS_CLOSE:
607657 case HPI_SUBSYS_DRIVER_UNLOAD:
608− phr->error = 0;
609658 break;
610659 case HPI_SUBSYS_DRIVER_LOAD:
611660 wipe_adapter_list();
612661 hpios_alistlock_init(&adapters);
613− phr->error = 0;
614662 break;
615− case HPI_SUBSYS_GET_INFO:
616− subsys_get_adapters(phr);
663+ case HPI_SUBSYS_GET_ADAPTER:
664+ subsys_get_adapter(phm, phr);
665+ break;
666+ case HPI_SUBSYS_GET_NUM_ADAPTERS:
667+ phr->u.s.num_adapters = adapters.gw_num_adapters;
617668 break;
618669 case HPI_SUBSYS_CREATE_ADAPTER:
619670 case HPI_SUBSYS_DELETE_ADAPTER:
620− phr->error = 0;
621671 break;
622672 default:
623673 phr->error = HPI_ERROR_INVALID_FUNC;
sound/pci/asihpi/hpicmn.h+11−13
@@ -33,18 +33,19 @@ struct hpi_adapter_obj { · 32 unmodified lines
3333 };
3434
3535 struct hpi_control_cache {
36− u32 init; /**< indicates whether the
37− structures are initialized */
36+ /** indicates whether the structures are initialized */
37+ u16 init;
38+ u16 adap_idx;
3839 u32 control_count;
3940 u32 cache_size_in_bytes;
40− struct hpi_control_cache_info
41− **p_info; /**< pointer to allocated memory of
42− lookup pointers. */
43− struct hpi_control_cache_single
44− *p_cache; /**< pointer to DSP's control cache. */
41+ /** pointer to allocated memory of lookup pointers. */
42+ struct hpi_control_cache_info **p_info;
43+ /** pointer to DSP's control cache. */
44+ u8 *p_cache;
4545 };
4646
4747 struct hpi_adapter_obj *hpi_find_adapter(u16 adapter_index);
48+
4849 u16 hpi_add_adapter(struct hpi_adapter_obj *pao);
4950
5051 void hpi_delete_adapter(struct hpi_adapter_obj *pao);
@@ -52,13 +53,10 @@ void hpi_delete_adapter(struct hpi_adapter_obj *pao); · 1 unmodified line
5253 short hpi_check_control_cache(struct hpi_control_cache *pC,
5354 struct hpi_message *phm, struct hpi_response *phr);
5455 struct hpi_control_cache *hpi_alloc_control_cache(const u32
55− number_of_controls, const u32 size_in_bytes,
56− struct hpi_control_cache_info
57− *pDSP_control_buffer);
56+ number_of_controls, const u32 size_in_bytes, u8 *pDSP_control_buffer);
5857 void hpi_free_control_cache(struct hpi_control_cache *p_cache);
5958
60−void hpi_sync_control_cache(struct hpi_control_cache *pC,
59+void hpi_cmn_control_cache_sync_to_msg(struct hpi_control_cache *pC,
6160 struct hpi_message *phm, struct hpi_response *phr);
61+
6262 u16 hpi_validate_response(struct hpi_message *phm, struct hpi_response *phr);
63−short hpi_check_buffer_mapping(struct hpi_control_cache *p_cache,
64− struct hpi_message *phm, void **p, unsigned int *pN);
sound/pci/asihpi/hpidebug.c+5−152
@@ -45,161 +45,14 @@ int hpi_debug_level_get(void) · 44 unmodified lines
4545 return hpi_debug_level;
4646 }
4747
48−#ifdef HPIOS_DEBUG_PRINT
49−/* implies OS has no printf-like function */
50−#include <stdarg.h>
51−
52−void hpi_debug_printf(char *fmt, ...)
53−{
54− va_list arglist;
55− char buffer[128];
56−
57− va_start(arglist, fmt);
58−
59− if (buffer[0])
60− HPIOS_DEBUG_PRINT(buffer);
61− va_end(arglist);
62−}
63−#endif
64−
65−struct treenode {
66− void *array;
67− unsigned int num_elements;
68−};
69−
70−#define make_treenode_from_array(nodename, array) \
71−static void *tmp_strarray_##nodename[] = array; \
72−static struct treenode nodename = { \
73− &tmp_strarray_##nodename, \
74− ARRAY_SIZE(tmp_strarray_##nodename) \
75−};
76−
77−#define get_treenode_elem(node_ptr, idx, type) \
78− (&(*((type *)(node_ptr)->array)[idx]))
79−
80−make_treenode_from_array(hpi_control_type_strings, HPI_CONTROL_TYPE_STRINGS)
81−
82− make_treenode_from_array(hpi_subsys_strings, HPI_SUBSYS_STRINGS)
83− make_treenode_from_array(hpi_adapter_strings, HPI_ADAPTER_STRINGS)
84− make_treenode_from_array(hpi_istream_strings, HPI_ISTREAM_STRINGS)
85− make_treenode_from_array(hpi_ostream_strings, HPI_OSTREAM_STRINGS)
86− make_treenode_from_array(hpi_mixer_strings, HPI_MIXER_STRINGS)
87− make_treenode_from_array(hpi_node_strings,
88− {
89− "NODE is invalid object"})
90−
91− make_treenode_from_array(hpi_control_strings, HPI_CONTROL_STRINGS)
92− make_treenode_from_array(hpi_nvmemory_strings, HPI_OBJ_STRINGS)
93− make_treenode_from_array(hpi_digitalio_strings, HPI_DIGITALIO_STRINGS)
94− make_treenode_from_array(hpi_watchdog_strings, HPI_WATCHDOG_STRINGS)
95− make_treenode_from_array(hpi_clock_strings, HPI_CLOCK_STRINGS)
96− make_treenode_from_array(hpi_profile_strings, HPI_PROFILE_STRINGS)
97− make_treenode_from_array(hpi_asyncevent_strings, HPI_ASYNCEVENT_STRINGS)
98−#define HPI_FUNCTION_STRINGS \
99−{ \
100− &hpi_subsys_strings,\
101− &hpi_adapter_strings,\
102− &hpi_ostream_strings,\
103− &hpi_istream_strings,\
104− &hpi_mixer_strings,\
105− &hpi_node_strings,\
106− &hpi_control_strings,\
107− &hpi_nvmemory_strings,\
108− &hpi_digitalio_strings,\
109− &hpi_watchdog_strings,\
110− &hpi_clock_strings,\
111− &hpi_profile_strings,\
112− &hpi_control_strings, \
113− &hpi_asyncevent_strings \
114−}
115− make_treenode_from_array(hpi_function_strings, HPI_FUNCTION_STRINGS)
116−
117− compile_time_assert(HPI_OBJ_MAXINDEX == 14, obj_list_doesnt_match);
118−
119−static char *hpi_function_string(unsigned int function)
120−{
121− unsigned int object;
122− struct treenode *tmp;
123−
124− object = function / HPI_OBJ_FUNCTION_SPACING;
125− function = function - object * HPI_OBJ_FUNCTION_SPACING;
126−
127− if (object == 0 || object == HPI_OBJ_NODE
128− || object > hpi_function_strings.num_elements)
129− return "invalid object";
130−
131− tmp = get_treenode_elem(&hpi_function_strings, object - 1,
132− struct treenode *);
133−
134− if (function == 0 || function > tmp->num_elements)
135− return "invalid function";
136−
137− return get_treenode_elem(tmp, function - 1, char *);
138−}
139−
14048 void hpi_debug_message(struct hpi_message *phm, char *sz_fileline)
14149 {
14250 if (phm) {
143− if ((phm->object <= HPI_OBJ_MAXINDEX) && phm->object) {
144− u16 index = 0;
145− u16 attrib = 0;
146− int is_control = 0;
147−
148− index = phm->obj_index;
149− switch (phm->object) {
150− case HPI_OBJ_ADAPTER:
151− case HPI_OBJ_PROFILE:
152− break;
153− case HPI_OBJ_MIXER:
154− if (phm->function ==
155− HPI_MIXER_GET_CONTROL_BY_INDEX)
156− index = phm->u.m.control_index;
157− break;
158− case HPI_OBJ_OSTREAM:
159− case HPI_OBJ_ISTREAM:
160− break;
161−
162− case HPI_OBJ_CONTROLEX:
163− case HPI_OBJ_CONTROL:
164− if (phm->version == 1)
165− attrib = HPI_CTL_ATTR(UNIVERSAL, 1);
166− else
167− attrib = phm->u.c.attribute;
168− is_control = 1;
169− break;
170− default:
171− break;
172− }
173−
174− if (is_control && (attrib & 0xFF00)) {
175− int control_type = (attrib & 0xFF00) >> 8;
176− int attr_index = HPI_CTL_ATTR_INDEX(attrib);
177− /* note the KERN facility level
178− is in szFileline already */
179− printk("%s adapter %d %s "
180− "ctrl_index x%04x %s %d\n",
181− sz_fileline, phm->adapter_index,
182− hpi_function_string(phm->function),
183− index,
184− get_treenode_elem
185− (&hpi_control_type_strings,
186− control_type, char *),
187− attr_index);
188−
189− } else
190− printk("%s adapter %d %s "
191− "idx x%04x attr x%04x \n",
192− sz_fileline, phm->adapter_index,
193− hpi_function_string(phm->function),
194− index, attrib);
195− } else {
196− printk("adap=%d, invalid obj=%d, func=0x%x\n",
197− phm->adapter_index, phm->object,
198− phm->function);
199− }
200− } else
201− printk(KERN_ERR
202− "NULL message pointer to hpi_debug_message!\n");
51+ printk(KERN_DEBUG "HPI_MSG%d,%d,%d,%d,%d\n", phm->version,
52+ phm->adapter_index, phm->obj_index, phm->function,
53+ phm->u.c.attribute);
54+ }
55+
20356 }
20457
20558 void hpi_debug_data(u16 *pdata, u32 len)
sound/pci/asihpi/hpidebug.h+20−303
@@ -37,7 +37,7 @@ enum { HPI_DEBUG_LEVEL_ERROR = 0, /* always log errors */ · 36 unmodified lines
3737 #define HPI_DEBUG_LEVEL_DEFAULT HPI_DEBUG_LEVEL_NOTICE
3838
3939 /* an OS can define an extra flag string that is appended to
40− the start of each message, eg see hpios_linux.h */
40+ the start of each message, eg see linux kernel hpios.h */
4141
4242 #ifdef SOURCEFILE_NAME
4343 #define FILE_LINE SOURCEFILE_NAME ":" __stringify(__LINE__) " "
@@ -45,18 +45,11 @@ enum { HPI_DEBUG_LEVEL_ERROR = 0, /* always log errors */ · 1 unmodified line
4545 #define FILE_LINE __FILE__ ":" __stringify(__LINE__) " "
4646 #endif
4747
48−#if defined(HPI_DEBUG) && defined(_WINDOWS)
49−#define HPI_DEBUGBREAK() debug_break()
50−#else
51−#define HPI_DEBUGBREAK()
52−#endif
53−
5448 #define HPI_DEBUG_ASSERT(expression) \
5549 do { \
56− if (!(expression)) {\
57− printk(KERN_ERR FILE_LINE\
58− "ASSERT " __stringify(expression));\
59− HPI_DEBUGBREAK();\
50+ if (!(expression)) { \
51+ printk(KERN_ERR FILE_LINE \
52+ "ASSERT " __stringify(expression)); \
6053 } \
6154 } while (0)
6255
@@ -78,28 +71,27 @@ void hpi_debug_message(struct hpi_message *phm, char *sz_fileline); · 15 unmodified lines
7871
7972 void hpi_debug_data(u16 *pdata, u32 len);
8073
81−#define HPI_DEBUG_DATA(pdata, len) \
82− do { \
74+#define HPI_DEBUG_DATA(pdata, len) \
75+ do { \
8376 if (hpi_debug_level >= HPI_DEBUG_LEVEL_VERBOSE) \
8477 hpi_debug_data(pdata, len); \
8578 } while (0)
8679
87−#define HPI_DEBUG_MESSAGE(level, phm) \
88− do { \
89− if (hpi_debug_level >= HPI_DEBUG_LEVEL_##level) { \
90− hpi_debug_message(phm,HPI_DEBUG_FLAG_##level \
91− FILE_LINE __stringify(level));\
92− } \
80+#define HPI_DEBUG_MESSAGE(level, phm) \
81+ do { \
82+ if (hpi_debug_level >= HPI_DEBUG_LEVEL_##level) { \
83+ hpi_debug_message(phm, HPI_DEBUG_FLAG_##level \
84+ FILE_LINE __stringify(level)); \
85+ } \
9386 } while (0)
9487
95−#define HPI_DEBUG_RESPONSE(phr) \
96− do { \
97− if ((hpi_debug_level >= HPI_DEBUG_LEVEL_DEBUG) && (phr->error))\
98− HPI_DEBUG_LOG(ERROR, \
99− "HPI response - error# %d\n", \
100− phr->error); \
101− else if (hpi_debug_level >= HPI_DEBUG_LEVEL_VERBOSE) \
102− HPI_DEBUG_LOG(VERBOSE, "HPI response OK\n");\
88+#define HPI_DEBUG_RESPONSE(phr) \
89+ do { \
90+ if (((hpi_debug_level >= HPI_DEBUG_LEVEL_DEBUG) && \
91+ (phr->error)) ||\
92+ (hpi_debug_level >= HPI_DEBUG_LEVEL_VERBOSE)) \
93+ printk(KERN_DEBUG "HPI_RES%d,%d,%d\n", \
94+ phr->version, phr->error, phr->specific_error); \
10395 } while (0)
10496
10597 #ifndef compile_time_assert
@@ -107,279 +99,4 @@ void hpi_debug_data(u16 *pdata, u32 len); · 1 unmodified line
10799 typedef char msg[(cond) ? 1 : -1]
108100 #endif
109101
110− /* check that size is exactly some number */
111−#define function_count_check(sym, size) \
112− compile_time_assert((sym##_FUNCTION_COUNT) == (size),\
113− strings_match_defs_##sym)
114−
115−/* These strings should be generated using a macro which defines
116− the corresponding symbol values. */
117−#define HPI_OBJ_STRINGS \
118−{ \
119− "HPI_OBJ_SUBSYSTEM", \
120− "HPI_OBJ_ADAPTER", \
121− "HPI_OBJ_OSTREAM", \
122− "HPI_OBJ_ISTREAM", \
123− "HPI_OBJ_MIXER", \
124− "HPI_OBJ_NODE", \
125− "HPI_OBJ_CONTROL", \
126− "HPI_OBJ_NVMEMORY", \
127− "HPI_OBJ_DIGITALIO", \
128− "HPI_OBJ_WATCHDOG", \
129− "HPI_OBJ_CLOCK", \
130− "HPI_OBJ_PROFILE", \
131− "HPI_OBJ_CONTROLEX" \
132−}
133−
134−#define HPI_SUBSYS_STRINGS \
135−{ \
136− "HPI_SUBSYS_OPEN", \
137− "HPI_SUBSYS_GET_VERSION", \
138− "HPI_SUBSYS_GET_INFO", \
139− "HPI_SUBSYS_FIND_ADAPTERS", \
140− "HPI_SUBSYS_CREATE_ADAPTER",\
141− "HPI_SUBSYS_CLOSE", \
142− "HPI_SUBSYS_DELETE_ADAPTER", \
143− "HPI_SUBSYS_DRIVER_LOAD", \
144− "HPI_SUBSYS_DRIVER_UNLOAD", \
145− "HPI_SUBSYS_READ_PORT_8", \
146− "HPI_SUBSYS_WRITE_PORT_8", \
147− "HPI_SUBSYS_GET_NUM_ADAPTERS",\
148− "HPI_SUBSYS_GET_ADAPTER", \
149− "HPI_SUBSYS_SET_NETWORK_INTERFACE"\
150−}
151−function_count_check(HPI_SUBSYS, 14);
152−
153−#define HPI_ADAPTER_STRINGS \
154−{ \
155− "HPI_ADAPTER_OPEN", \
156− "HPI_ADAPTER_CLOSE", \
157− "HPI_ADAPTER_GET_INFO", \
158− "HPI_ADAPTER_GET_ASSERT", \
159− "HPI_ADAPTER_TEST_ASSERT", \
160− "HPI_ADAPTER_SET_MODE", \
161− "HPI_ADAPTER_GET_MODE", \
162− "HPI_ADAPTER_ENABLE_CAPABILITY",\
163− "HPI_ADAPTER_SELFTEST", \
164− "HPI_ADAPTER_FIND_OBJECT", \
165− "HPI_ADAPTER_QUERY_FLASH", \
166− "HPI_ADAPTER_START_FLASH", \
167− "HPI_ADAPTER_PROGRAM_FLASH", \
168− "HPI_ADAPTER_SET_PROPERTY", \
169− "HPI_ADAPTER_GET_PROPERTY", \
170− "HPI_ADAPTER_ENUM_PROPERTY", \
171− "HPI_ADAPTER_MODULE_INFO", \
172− "HPI_ADAPTER_DEBUG_READ" \
173−}
174−
175−function_count_check(HPI_ADAPTER, 18);
176−
177−#define HPI_OSTREAM_STRINGS \
178−{ \
179− "HPI_OSTREAM_OPEN", \
180− "HPI_OSTREAM_CLOSE", \
181− "HPI_OSTREAM_WRITE", \
182− "HPI_OSTREAM_START", \
183− "HPI_OSTREAM_STOP", \
184− "HPI_OSTREAM_RESET", \
185− "HPI_OSTREAM_GET_INFO", \
186− "HPI_OSTREAM_QUERY_FORMAT", \
187− "HPI_OSTREAM_DATA", \
188− "HPI_OSTREAM_SET_VELOCITY", \
189− "HPI_OSTREAM_SET_PUNCHINOUT", \
190− "HPI_OSTREAM_SINEGEN", \
191− "HPI_OSTREAM_ANC_RESET", \
192− "HPI_OSTREAM_ANC_GET_INFO", \
193− "HPI_OSTREAM_ANC_READ", \
194− "HPI_OSTREAM_SET_TIMESCALE",\
195− "HPI_OSTREAM_SET_FORMAT", \
196− "HPI_OSTREAM_HOSTBUFFER_ALLOC", \
197− "HPI_OSTREAM_HOSTBUFFER_FREE", \
198− "HPI_OSTREAM_GROUP_ADD",\
199− "HPI_OSTREAM_GROUP_GETMAP", \
200− "HPI_OSTREAM_GROUP_RESET", \
201− "HPI_OSTREAM_HOSTBUFFER_GET_INFO", \
202− "HPI_OSTREAM_WAIT_START", \
203−}
204−function_count_check(HPI_OSTREAM, 24);
205−
206−#define HPI_ISTREAM_STRINGS \
207−{ \
208− "HPI_ISTREAM_OPEN", \
209− "HPI_ISTREAM_CLOSE", \
210− "HPI_ISTREAM_SET_FORMAT", \
211− "HPI_ISTREAM_READ", \
212− "HPI_ISTREAM_START", \
213− "HPI_ISTREAM_STOP", \
214− "HPI_ISTREAM_RESET", \
215− "HPI_ISTREAM_GET_INFO", \
216− "HPI_ISTREAM_QUERY_FORMAT", \
217− "HPI_ISTREAM_ANC_RESET", \
218− "HPI_ISTREAM_ANC_GET_INFO", \
219− "HPI_ISTREAM_ANC_WRITE", \
220− "HPI_ISTREAM_HOSTBUFFER_ALLOC",\
221− "HPI_ISTREAM_HOSTBUFFER_FREE", \
222− "HPI_ISTREAM_GROUP_ADD", \
223− "HPI_ISTREAM_GROUP_GETMAP", \
224− "HPI_ISTREAM_GROUP_RESET", \
225− "HPI_ISTREAM_HOSTBUFFER_GET_INFO", \
226− "HPI_ISTREAM_WAIT_START", \
227−}
228−function_count_check(HPI_ISTREAM, 19);
229−
230−#define HPI_MIXER_STRINGS \
231−{ \
232− "HPI_MIXER_OPEN", \
233− "HPI_MIXER_CLOSE", \
234− "HPI_MIXER_GET_INFO", \
235− "HPI_MIXER_GET_NODE_INFO", \
236− "HPI_MIXER_GET_CONTROL", \
237− "HPI_MIXER_SET_CONNECTION", \
238− "HPI_MIXER_GET_CONNECTIONS", \
239− "HPI_MIXER_GET_CONTROL_BY_INDEX", \
240− "HPI_MIXER_GET_CONTROL_ARRAY_BY_INDEX", \
241− "HPI_MIXER_GET_CONTROL_MULTIPLE_VALUES", \
242− "HPI_MIXER_STORE", \
243−}
244−function_count_check(HPI_MIXER, 11);
245−
246−#define HPI_CONTROL_STRINGS \
247−{ \
248− "HPI_CONTROL_GET_INFO", \
249− "HPI_CONTROL_GET_STATE", \
250− "HPI_CONTROL_SET_STATE" \
251−}
252−function_count_check(HPI_CONTROL, 3);
253−
254−#define HPI_NVMEMORY_STRINGS \
255−{ \
256− "HPI_NVMEMORY_OPEN", \
257− "HPI_NVMEMORY_READ_BYTE", \
258− "HPI_NVMEMORY_WRITE_BYTE" \
259−}
260−function_count_check(HPI_NVMEMORY, 3);
261−
262−#define HPI_DIGITALIO_STRINGS \
263−{ \
264− "HPI_GPIO_OPEN", \
265− "HPI_GPIO_READ_BIT", \
266− "HPI_GPIO_WRITE_BIT", \
267− "HPI_GPIO_READ_ALL", \
268− "HPI_GPIO_WRITE_STATUS"\
269−}
270−function_count_check(HPI_GPIO, 5);
271−
272−#define HPI_WATCHDOG_STRINGS \
273−{ \
274− "HPI_WATCHDOG_OPEN", \
275− "HPI_WATCHDOG_SET_TIME", \
276− "HPI_WATCHDOG_PING" \
277−}
278−
279−#define HPI_CLOCK_STRINGS \
280−{ \
281− "HPI_CLOCK_OPEN", \
282− "HPI_CLOCK_SET_TIME", \
283− "HPI_CLOCK_GET_TIME" \
284−}
285−
286−#define HPI_PROFILE_STRINGS \
287−{ \
288− "HPI_PROFILE_OPEN_ALL", \
289− "HPI_PROFILE_START_ALL", \
290− "HPI_PROFILE_STOP_ALL", \
291− "HPI_PROFILE_GET", \
292− "HPI_PROFILE_GET_IDLECOUNT", \
293− "HPI_PROFILE_GET_NAME", \
294− "HPI_PROFILE_GET_UTILIZATION" \
295−}
296−function_count_check(HPI_PROFILE, 7);
297−
298−#define HPI_ASYNCEVENT_STRINGS \
299−{ \
300− "HPI_ASYNCEVENT_OPEN",\
301− "HPI_ASYNCEVENT_CLOSE ",\
302− "HPI_ASYNCEVENT_WAIT",\
303− "HPI_ASYNCEVENT_GETCOUNT",\
304− "HPI_ASYNCEVENT_GET",\
305− "HPI_ASYNCEVENT_SENDEVENTS"\
306−}
307−function_count_check(HPI_ASYNCEVENT, 6);
308−
309−#define HPI_CONTROL_TYPE_STRINGS \
310−{ \
311− "null control", \
312− "HPI_CONTROL_CONNECTION", \
313− "HPI_CONTROL_VOLUME", \
314− "HPI_CONTROL_METER", \
315− "HPI_CONTROL_MUTE", \
316− "HPI_CONTROL_MULTIPLEXER", \
317− "HPI_CONTROL_AESEBU_TRANSMITTER", \
318− "HPI_CONTROL_AESEBU_RECEIVER", \
319− "HPI_CONTROL_LEVEL", \
320− "HPI_CONTROL_TUNER", \
321− "HPI_CONTROL_ONOFFSWITCH", \
322− "HPI_CONTROL_VOX", \
323− "HPI_CONTROL_AES18_TRANSMITTER", \
324− "HPI_CONTROL_AES18_RECEIVER", \
325− "HPI_CONTROL_AES18_BLOCKGENERATOR", \
326− "HPI_CONTROL_CHANNEL_MODE", \
327− "HPI_CONTROL_BITSTREAM", \
328− "HPI_CONTROL_SAMPLECLOCK", \
329− "HPI_CONTROL_MICROPHONE", \
330− "HPI_CONTROL_PARAMETRIC_EQ", \
331− "HPI_CONTROL_COMPANDER", \
332− "HPI_CONTROL_COBRANET", \
333− "HPI_CONTROL_TONE_DETECT", \
334− "HPI_CONTROL_SILENCE_DETECT", \
335− "HPI_CONTROL_PAD", \
336− "HPI_CONTROL_SRC" ,\
337− "HPI_CONTROL_UNIVERSAL" \
338−}
339−
340−compile_time_assert((HPI_CONTROL_LAST_INDEX + 1 == 27),
341− controltype_strings_match_defs);
342−
343−#define HPI_SOURCENODE_STRINGS \
344−{ \
345− "no source", \
346− "HPI_SOURCENODE_OSTREAM", \
347− "HPI_SOURCENODE_LINEIN", \
348− "HPI_SOURCENODE_AESEBU_IN", \
349− "HPI_SOURCENODE_TUNER", \
350− "HPI_SOURCENODE_RF", \
351− "HPI_SOURCENODE_CLOCK_SOURCE", \
352− "HPI_SOURCENODE_RAW_BITSTREAM", \
353− "HPI_SOURCENODE_MICROPHONE", \
354− "HPI_SOURCENODE_COBRANET", \
355− "HPI_SOURCENODE_ANALOG", \
356− "HPI_SOURCENODE_ADAPTER" \
357−}
358−
359−compile_time_assert((HPI_SOURCENODE_LAST_INDEX - HPI_SOURCENODE_NONE + 1) ==
360− (12), sourcenode_strings_match_defs);
361−
362−#define HPI_DESTNODE_STRINGS \
363−{ \
364− "no destination", \
365− "HPI_DESTNODE_ISTREAM", \
366− "HPI_DESTNODE_LINEOUT", \
367− "HPI_DESTNODE_AESEBU_OUT", \
368− "HPI_DESTNODE_RF", \
369− "HPI_DESTNODE_SPEAKER", \
370− "HPI_DESTNODE_COBRANET", \
371− "HPI_DESTNODE_ANALOG" \
372−}
373−compile_time_assert((HPI_DESTNODE_LAST_INDEX - HPI_DESTNODE_NONE + 1) == (8),
374− destnode_strings_match_defs);
375−
376−#define HPI_CONTROL_CHANNEL_MODE_STRINGS \
377−{ \
378− "XXX HPI_CHANNEL_MODE_ERROR XXX", \
379− "HPI_CHANNEL_MODE_NORMAL", \
380− "HPI_CHANNEL_MODE_SWAP", \
381− "HPI_CHANNEL_MODE_LEFT_ONLY", \
382− "HPI_CHANNEL_MODE_RIGHT_ONLY" \
383−}
384−
385−#endif /* _HPIDEBUG_H */
102+#endif /* _HPIDEBUG_H_ */
sound/pci/asihpi/hpidspcd.c+20−17
@@ -71,47 +71,50 @@ short hpi_dsp_code_open(u32 adapter, struct dsp_code *ps_dsp_code, · 70 unmodified lines
7171 int err;
7272
7373 sprintf(fw_name, "asihpi/dsp%04x.bin", adapter);
74− HPI_DEBUG_LOG(INFO, "requesting firmware for %s\n", fw_name);
7574
7675 err = request_firmware(&ps_firmware, fw_name,
7776 &ps_dsp_code->ps_dev->dev);
77+
7878 if (err != 0) {
79− HPI_DEBUG_LOG(ERROR, "%d, request_firmware failed for %s\n",
80− err, fw_name);
79+ dev_printk(KERN_ERR, &ps_dsp_code->ps_dev->dev,
80+ "%d, request_firmware failed for %s\n", err,
81+ fw_name);
8182 goto error1;
8283 }
8384 if (ps_firmware->size < sizeof(header)) {
84− HPI_DEBUG_LOG(ERROR, "header size too small %s\n", fw_name);
85+ dev_printk(KERN_ERR, &ps_dsp_code->ps_dev->dev,
86+ "Header size too small %s\n", fw_name);
8587 goto error2;
8688 }
8789 memcpy(&header, ps_firmware->data, sizeof(header));
8890 if (header.adapter != adapter) {
89− HPI_DEBUG_LOG(ERROR, "adapter type incorrect %4x != %4x\n",
90− header.adapter, adapter);
91+ dev_printk(KERN_ERR, &ps_dsp_code->ps_dev->dev,
92+ "Adapter type incorrect %4x != %4x\n", header.adapter,
93+ adapter);
9194 goto error2;
9295 }
9396 if (header.size != ps_firmware->size) {
94− HPI_DEBUG_LOG(ERROR, "code size wrong %d != %ld\n",
95− header.size, (unsigned long)ps_firmware->size);
97+ dev_printk(KERN_ERR, &ps_dsp_code->ps_dev->dev,
98+ "Code size wrong %d != %ld\n", header.size,
99+ (unsigned long)ps_firmware->size);
96100 goto error2;
97101 }
98102
99− if (header.version / 10000 != HPI_VER_DECIMAL / 10000) {
100− HPI_DEBUG_LOG(ERROR,
101− "firmware major version mismatch "
102− "DSP image %d != driver %d\n", header.version,
103+ if (header.version / 100 != HPI_VER_DECIMAL / 100) {
104+ dev_printk(KERN_ERR, &ps_dsp_code->ps_dev->dev,
105+ "Incompatible firmware version "
106+ "DSP image %d != Driver %d\n", header.version,
103107 HPI_VER_DECIMAL);
104108 goto error2;
105109 }
106110
107111 if (header.version != HPI_VER_DECIMAL) {
108− HPI_DEBUG_LOG(WARNING,
109− "version mismatch DSP image %d != driver %d\n",
112+ dev_printk(KERN_WARNING, &ps_dsp_code->ps_dev->dev,
113+ "Firmware: release version mismatch DSP image %d != Driver %d\n",
110114 header.version, HPI_VER_DECIMAL);
111− /* goto error2; still allow driver to load */
112115 }
113116
114− HPI_DEBUG_LOG(INFO, "dsp code %s opened\n", fw_name);
117+ HPI_DEBUG_LOG(DEBUG, "dsp code %s opened\n", fw_name);
115118 ps_dsp_code->ps_firmware = ps_firmware;
116119 ps_dsp_code->block_length = header.size / sizeof(u32);
117120 ps_dsp_code->word_count = sizeof(header) / sizeof(u32);
@@ -148,7 +151,7 @@ void hpi_dsp_code_rewind(struct dsp_code *ps_dsp_code) · 30 unmodified lines
148151 short hpi_dsp_code_read_word(struct dsp_code *ps_dsp_code, u32 *pword)
149152 {
150153 if (ps_dsp_code->word_count + 1 > ps_dsp_code->block_length)
151− return (HPI_ERROR_DSP_FILE_FORMAT);
154+ return HPI_ERROR_DSP_FILE_FORMAT;
152155
153156 *pword = ((u32 *)(ps_dsp_code->ps_firmware->data))[ps_dsp_code->
154157 word_count];
sound/pci/asihpi/hpidspcd.h+1−1
@@ -87,7 +87,7 @@ void hpi_dsp_code_rewind(struct dsp_code *ps_dsp_code); · 86 unmodified lines
8787 */
8888 short hpi_dsp_code_read_word(struct dsp_code *ps_dsp_code,
8989 /**< DSP code descriptor */
90− u32 *pword /**< where to store the read word */
90+ u32 *pword /**< Where to store the read word */
9191 );
9292
9393 /** Get a block of dsp code into an internal buffer, and provide a pointer to
sound/pci/asihpi/hpifunc.c+725−1773
@@ -30,16 +30,25 @@ u32 hpi_indexes_to_handle(const char c_object, const u16 adapter_index, · 29 unmodified lines
3030 return handle.w;
3131 }
3232
33−void hpi_handle_to_indexes(const u32 handle, u16 *pw_adapter_index,
34− u16 *pw_object_index)
33+static u16 hpi_handle_indexes(const u32 h, u16 *p1, u16 *p2)
3534 {
3635 union handle_word uhandle;
37− uhandle.w = handle;
36+ if (!h)
37+ return HPI_ERROR_INVALID_HANDLE;
38+
39+ uhandle.w = h;
40+
41+ *p1 = (u16)uhandle.h.adapter_index;
42+ if (p2)
43+ *p2 = (u16)uhandle.h.obj_index;
44+
45+ return 0;
46+}
3847
39− if (pw_adapter_index)
40− *pw_adapter_index = (u16)uhandle.h.adapter_index;
41− if (pw_object_index)
42− *pw_object_index = (u16)uhandle.h.obj_index;
48+void hpi_handle_to_indexes(const u32 handle, u16 *pw_adapter_index,
49+ u16 *pw_object_index)
50+{
51+ hpi_handle_indexes(handle, pw_adapter_index, pw_object_index);
4352 }
4453
4554 char hpi_handle_object(const u32 handle)
@@ -49,22 +58,6 @@ char hpi_handle_object(const u32 handle) · 3 unmodified lines
4958 return (char)uhandle.h.obj_type;
5059 }
5160
52−#define u32TOINDEX(h, i1) \
53−do {\
54− if (h == 0) \
55− return HPI_ERROR_INVALID_OBJ; \
56− else \
57− hpi_handle_to_indexes(h, i1, NULL); \
58−} while (0)
59−
60−#define u32TOINDEXES(h, i1, i2) \
61−do {\
62− if (h == 0) \
63− return HPI_ERROR_INVALID_OBJ; \
64− else \
65− hpi_handle_to_indexes(h, i1, i2);\
66−} while (0)
67−
6861 void hpi_format_to_msg(struct hpi_msg_format *pMF,
6962 const struct hpi_format *pF)
7063 {
@@ -94,52 +87,13 @@ void hpi_stream_response_to_legacy(struct hpi_stream_res *pSR) · 23 unmodified lines
9487 pSR->u.legacy_stream_info.state = pSR->u.stream_info.state;
9588 }
9689
97−static struct hpi_hsubsys gh_subsys;
98−
99−struct hpi_hsubsys *hpi_subsys_create(void)
100−{
101− struct hpi_message hm;
102− struct hpi_response hr;
103−
104− memset(&gh_subsys, 0, sizeof(struct hpi_hsubsys));
105−
106− {
107− hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM,
108− HPI_SUBSYS_OPEN);
109− hpi_send_recv(&hm, &hr);
110−
111− if (hr.error == 0)
112− return &gh_subsys;
113−
114− }
115− return NULL;
116−}
117−
118−void hpi_subsys_free(const struct hpi_hsubsys *ph_subsys)
119−{
120− struct hpi_message hm;
121− struct hpi_response hr;
122−
123− hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM,
124− HPI_SUBSYS_CLOSE);
125− hpi_send_recv(&hm, &hr);
126−
127−}
128−
129−u16 hpi_subsys_get_version(const struct hpi_hsubsys *ph_subsys, u32 *pversion)
90+static inline void hpi_send_recvV1(struct hpi_message_header *m,
91+ struct hpi_response_header *r)
13092 {
131− struct hpi_message hm;
132− struct hpi_response hr;
133−
134− hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM,
135− HPI_SUBSYS_GET_VERSION);
136− hpi_send_recv(&hm, &hr);
137− *pversion = hr.u.s.version;
138− return hr.error;
93+ hpi_send_recv((struct hpi_message *)m, (struct hpi_response *)r);
13994 }
14095
141−u16 hpi_subsys_get_version_ex(const struct hpi_hsubsys *ph_subsys,
142− u32 *pversion_ex)
96+u16 hpi_subsys_get_version_ex(u32 *pversion_ex)
14397 {
14498 struct hpi_message hm;
14599 struct hpi_response hr;
@@ -151,51 +105,8 @@ u16 hpi_subsys_get_version_ex(const struct hpi_hsubsys *ph_subsys, · 5 unmodified lines
151105 return hr.error;
152106 }
153107
154−u16 hpi_subsys_get_info(const struct hpi_hsubsys *ph_subsys, u32 *pversion,
155− u16 *pw_num_adapters, u16 aw_adapter_list[], u16 list_length)
156−{
157− struct hpi_message hm;
158− struct hpi_response hr;
159− hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM,
160− HPI_SUBSYS_GET_INFO);
161−
162− hpi_send_recv(&hm, &hr);
163−
164− *pversion = hr.u.s.version;
165− if (list_length > HPI_MAX_ADAPTERS)
166− memcpy(aw_adapter_list, &hr.u.s.aw_adapter_list,
167− HPI_MAX_ADAPTERS);
168− else
169− memcpy(aw_adapter_list, &hr.u.s.aw_adapter_list, list_length);
170− *pw_num_adapters = hr.u.s.num_adapters;
171− return hr.error;
172−}
173−
174−u16 hpi_subsys_find_adapters(const struct hpi_hsubsys *ph_subsys,
175− u16 *pw_num_adapters, u16 aw_adapter_list[], u16 list_length)
176−{
177− struct hpi_message hm;
178− struct hpi_response hr;
179− hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM,
180− HPI_SUBSYS_FIND_ADAPTERS);
181−
182− hpi_send_recv(&hm, &hr);
183−
184− if (list_length > HPI_MAX_ADAPTERS) {
185− memcpy(aw_adapter_list, &hr.u.s.aw_adapter_list,
186− HPI_MAX_ADAPTERS * sizeof(u16));
187− memset(&aw_adapter_list[HPI_MAX_ADAPTERS], 0,
188− (list_length - HPI_MAX_ADAPTERS) * sizeof(u16));
189− } else
190− memcpy(aw_adapter_list, &hr.u.s.aw_adapter_list,
191− list_length * sizeof(u16));
192− *pw_num_adapters = hr.u.s.num_adapters;
193−
194− return hr.error;
195−}
196−
197−u16 hpi_subsys_create_adapter(const struct hpi_hsubsys *ph_subsys,
198− const struct hpi_resource *p_resource, u16 *pw_adapter_index)
108+u16 hpi_subsys_create_adapter(const struct hpi_resource *p_resource,
109+ u16 *pw_adapter_index)
199110 {
200111 struct hpi_message hm;
201112 struct hpi_response hr;
@@ -210,20 +121,18 @@ u16 hpi_subsys_create_adapter(const struct hpi_hsubsys *ph_subsys, · 8 unmodified lines
210121 return hr.error;
211122 }
212123
213−u16 hpi_subsys_delete_adapter(const struct hpi_hsubsys *ph_subsys,
214− u16 adapter_index)
124+u16 hpi_subsys_delete_adapter(u16 adapter_index)
215125 {
216126 struct hpi_message hm;
217127 struct hpi_response hr;
218128 hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM,
219129 HPI_SUBSYS_DELETE_ADAPTER);
220− hm.adapter_index = adapter_index;
130+ hm.obj_index = adapter_index;
221131 hpi_send_recv(&hm, &hr);
222132 return hr.error;
223133 }
224134
225−u16 hpi_subsys_get_num_adapters(const struct hpi_hsubsys *ph_subsys,
226− int *pn_num_adapters)
135+u16 hpi_subsys_get_num_adapters(int *pn_num_adapters)
227136 {
228137 struct hpi_message hm;
229138 struct hpi_response hr;
@@ -234,35 +143,22 @@ u16 hpi_subsys_get_num_adapters(const struct hpi_hsubsys *ph_subsys, · 4 unmodified lines
234143 return hr.error;
235144 }
236145
237−u16 hpi_subsys_get_adapter(const struct hpi_hsubsys *ph_subsys, int iterator,
238− u32 *padapter_index, u16 *pw_adapter_type)
146+u16 hpi_subsys_get_adapter(int iterator, u32 *padapter_index,
147+ u16 *pw_adapter_type)
239148 {
240149 struct hpi_message hm;
241150 struct hpi_response hr;
242151 hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM,
243152 HPI_SUBSYS_GET_ADAPTER);
244− hm.adapter_index = (u16)iterator;
153+ hm.obj_index = (u16)iterator;
245154 hpi_send_recv(&hm, &hr);
246155 *padapter_index = (int)hr.u.s.adapter_index;
247− *pw_adapter_type = hr.u.s.aw_adapter_list[0];
248− return hr.error;
249−}
156+ *pw_adapter_type = hr.u.s.adapter_type;
250157
251−u16 hpi_subsys_set_host_network_interface(const struct hpi_hsubsys *ph_subsys,
252− const char *sz_interface)
253−{
254− struct hpi_message hm;
255− struct hpi_response hr;
256− hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM,
257− HPI_SUBSYS_SET_NETWORK_INTERFACE);
258− if (sz_interface == NULL)
259− return HPI_ERROR_INVALID_RESOURCE;
260− hm.u.s.resource.r.net_if = sz_interface;
261− hpi_send_recv(&hm, &hr);
262158 return hr.error;
263159 }
264160
265−u16 hpi_adapter_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index)
161+u16 hpi_adapter_open(u16 adapter_index)
266162 {
267163 struct hpi_message hm;
268164 struct hpi_response hr;
@@ -276,7 +172,7 @@ u16 hpi_adapter_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index) · 7 unmodified lines
276172
277173 }
278174
279−u16 hpi_adapter_close(const struct hpi_hsubsys *ph_subsys, u16 adapter_index)
175+u16 hpi_adapter_close(u16 adapter_index)
280176 {
281177 struct hpi_message hm;
282178 struct hpi_response hr;
@@ -289,15 +185,14 @@ u16 hpi_adapter_close(const struct hpi_hsubsys *ph_subsys, u16 adapter_index) · 6 unmodified lines
289185 return hr.error;
290186 }
291187
292−u16 hpi_adapter_set_mode(const struct hpi_hsubsys *ph_subsys,
293− u16 adapter_index, u32 adapter_mode)
188+u16 hpi_adapter_set_mode(u16 adapter_index, u32 adapter_mode)
294189 {
295− return hpi_adapter_set_mode_ex(ph_subsys, adapter_index, adapter_mode,
190+ return hpi_adapter_set_mode_ex(adapter_index, adapter_mode,
296191 HPI_ADAPTER_MODE_SET);
297192 }
298193
299−u16 hpi_adapter_set_mode_ex(const struct hpi_hsubsys *ph_subsys,
300− u16 adapter_index, u32 adapter_mode, u16 query_or_set)
194+u16 hpi_adapter_set_mode_ex(u16 adapter_index, u32 adapter_mode,
195+ u16 query_or_set)
301196 {
302197 struct hpi_message hm;
303198 struct hpi_response hr;
@@ -305,14 +200,13 @@ u16 hpi_adapter_set_mode_ex(const struct hpi_hsubsys *ph_subsys, · 1 unmodified line
305200 hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER,
306201 HPI_ADAPTER_SET_MODE);
307202 hm.adapter_index = adapter_index;
308− hm.u.a.adapter_mode = adapter_mode;
309− hm.u.a.assert_id = query_or_set;
203+ hm.u.ax.mode.adapter_mode = adapter_mode;
204+ hm.u.ax.mode.query_or_set = query_or_set;
310205 hpi_send_recv(&hm, &hr);
311206 return hr.error;
312207 }
313208
314−u16 hpi_adapter_get_mode(const struct hpi_hsubsys *ph_subsys,
315− u16 adapter_index, u32 *padapter_mode)
209+u16 hpi_adapter_get_mode(u16 adapter_index, u32 *padapter_mode)
316210 {
317211 struct hpi_message hm;
318212 struct hpi_response hr;
@@ -321,13 +215,13 @@ u16 hpi_adapter_get_mode(const struct hpi_hsubsys *ph_subsys, · 2 unmodified lines
321215 hm.adapter_index = adapter_index;
322216 hpi_send_recv(&hm, &hr);
323217 if (padapter_mode)
324− *padapter_mode = hr.u.a.serial_number;
218+ *padapter_mode = hr.u.ax.mode.adapter_mode;
325219 return hr.error;
326220 }
327221
328−u16 hpi_adapter_get_info(const struct hpi_hsubsys *ph_subsys,
329− u16 adapter_index, u16 *pw_num_outstreams, u16 *pw_num_instreams,
330− u16 *pw_version, u32 *pserial_number, u16 *pw_adapter_type)
222+u16 hpi_adapter_get_info(u16 adapter_index, u16 *pw_num_outstreams,
223+ u16 *pw_num_instreams, u16 *pw_version, u32 *pserial_number,
224+ u16 *pw_adapter_type)
331225 {
332226 struct hpi_message hm;
333227 struct hpi_response hr;
@@ -337,18 +231,17 @@ u16 hpi_adapter_get_info(const struct hpi_hsubsys *ph_subsys, · 3 unmodified lines
337231
338232 hpi_send_recv(&hm, &hr);
339233
340− *pw_adapter_type = hr.u.a.adapter_type;
341− *pw_num_outstreams = hr.u.a.num_outstreams;
342− *pw_num_instreams = hr.u.a.num_instreams;
343− *pw_version = hr.u.a.version;
344− *pserial_number = hr.u.a.serial_number;
234+ *pw_adapter_type = hr.u.ax.info.adapter_type;
235+ *pw_num_outstreams = hr.u.ax.info.num_outstreams;
236+ *pw_num_instreams = hr.u.ax.info.num_instreams;
237+ *pw_version = hr.u.ax.info.version;
238+ *pserial_number = hr.u.ax.info.serial_number;
345239 return hr.error;
346240 }
347241
348−u16 hpi_adapter_get_module_by_index(const struct hpi_hsubsys *ph_subsys,
349− u16 adapter_index, u16 module_index, u16 *pw_num_outputs,
350− u16 *pw_num_inputs, u16 *pw_version, u32 *pserial_number,
351− u16 *pw_module_type, u32 *ph_module)
242+u16 hpi_adapter_get_module_by_index(u16 adapter_index, u16 module_index,
243+ u16 *pw_num_outputs, u16 *pw_num_inputs, u16 *pw_version,
244+ u32 *pserial_number, u16 *pw_module_type, u32 *ph_module)
352245 {
353246 struct hpi_message hm;
354247 struct hpi_response hr;
@@ -360,173 +253,18 @@ u16 hpi_adapter_get_module_by_index(const struct hpi_hsubsys *ph_subsys, · 5 unmodified lines
360253
361254 hpi_send_recv(&hm, &hr);
362255
363− *pw_module_type = hr.u.a.adapter_type;
364− *pw_num_outputs = hr.u.a.num_outstreams;
365− *pw_num_inputs = hr.u.a.num_instreams;
366− *pw_version = hr.u.a.version;
367− *pserial_number = hr.u.a.serial_number;
256+ *pw_module_type = hr.u.ax.info.adapter_type;
257+ *pw_num_outputs = hr.u.ax.info.num_outstreams;
258+ *pw_num_inputs = hr.u.ax.info.num_instreams;
259+ *pw_version = hr.u.ax.info.version;
260+ *pserial_number = hr.u.ax.info.serial_number;
368261 *ph_module = 0;
369262
370263 return hr.error;
371264 }
372265
373−u16 hpi_adapter_get_assert(const struct hpi_hsubsys *ph_subsys,
374− u16 adapter_index, u16 *assert_present, char *psz_assert,
375− u16 *pw_line_number)
376−{
377− struct hpi_message hm;
378− struct hpi_response hr;
379− hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER,
380− HPI_ADAPTER_GET_ASSERT);
381− hm.adapter_index = adapter_index;
382− hpi_send_recv(&hm, &hr);
383−
384− *assert_present = 0;
385−
386− if (!hr.error) {
387−
388− *pw_line_number = (u16)hr.u.a.serial_number;
389− if (*pw_line_number) {
390−
391− int i;
392− char *src = (char *)hr.u.a.sz_adapter_assert;
393− char *dst = psz_assert;
394−
395− *assert_present = 1;
396−
397− for (i = 0; i < HPI_STRING_LEN; i++) {
398− char c;
399− c = *src++;
400− *dst++ = c;
401− if (c == 0)
402− break;
403− }
404−
405− }
406− }
407− return hr.error;
408−}
409−
410−u16 hpi_adapter_get_assert_ex(const struct hpi_hsubsys *ph_subsys,
411− u16 adapter_index, u16 *assert_present, char *psz_assert,
412− u32 *pline_number, u16 *pw_assert_on_dsp)
413−{
414− struct hpi_message hm;
415− struct hpi_response hr;
416− hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER,
417− HPI_ADAPTER_GET_ASSERT);
418− hm.adapter_index = adapter_index;
419−
420− hpi_send_recv(&hm, &hr);
421−
422− *assert_present = 0;
423−
424− if (!hr.error) {
425−
426− *pline_number = hr.u.a.serial_number;
427−
428− *assert_present = hr.u.a.adapter_type;
429−
430− *pw_assert_on_dsp = hr.u.a.adapter_index;
431−
432− if (!*assert_present && *pline_number)
433−
434− *assert_present = 1;
435−
436− if (*assert_present) {
437−
438− int i;
439− char *src = (char *)hr.u.a.sz_adapter_assert;
440− char *dst = psz_assert;
441−
442− for (i = 0; i < HPI_STRING_LEN; i++) {
443− char c;
444− c = *src++;
445− *dst++ = c;
446− if (c == 0)
447− break;
448− }
449−
450− } else {
451− *psz_assert = 0;
452− }
453− }
454− return hr.error;
455−}
456−
457−u16 hpi_adapter_test_assert(const struct hpi_hsubsys *ph_subsys,
458− u16 adapter_index, u16 assert_id)
459−{
460− struct hpi_message hm;
461− struct hpi_response hr;
462− hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER,
463− HPI_ADAPTER_TEST_ASSERT);
464− hm.adapter_index = adapter_index;
465− hm.u.a.assert_id = assert_id;
466−
467− hpi_send_recv(&hm, &hr);
468−
469− return hr.error;
470−}
471−
472−u16 hpi_adapter_enable_capability(const struct hpi_hsubsys *ph_subsys,
473− u16 adapter_index, u16 capability, u32 key)
474−{
475− struct hpi_message hm;
476− struct hpi_response hr;
477− hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER,
478− HPI_ADAPTER_ENABLE_CAPABILITY);
479− hm.adapter_index = adapter_index;
480− hm.u.a.assert_id = capability;
481− hm.u.a.adapter_mode = key;
482−
483− hpi_send_recv(&hm, &hr);
484−
485− return hr.error;
486−}
487−
488−u16 hpi_adapter_self_test(const struct hpi_hsubsys *ph_subsys,
489− u16 adapter_index)
490−{
491− struct hpi_message hm;
492− struct hpi_response hr;
493− hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER,
494− HPI_ADAPTER_SELFTEST);
495− hm.adapter_index = adapter_index;
496− hpi_send_recv(&hm, &hr);
497− return hr.error;
498−}
499−
500−u16 hpi_adapter_debug_read(const struct hpi_hsubsys *ph_subsys,
501− u16 adapter_index, u32 dsp_address, char *p_buffer, int *count_bytes)
502−{
503− struct hpi_message hm;
504− struct hpi_response hr;
505− hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER,
506− HPI_ADAPTER_DEBUG_READ);
507−
508− hr.size = sizeof(hr);
509−
510− hm.adapter_index = adapter_index;
511− hm.u.ax.debug_read.dsp_address = dsp_address;
512−
513− if (*count_bytes > (int)sizeof(hr.u.bytes))
514− *count_bytes = sizeof(hr.u.bytes);
515−
516− hm.u.ax.debug_read.count_bytes = *count_bytes;
517−
518− hpi_send_recv(&hm, &hr);
519−
520− if (!hr.error) {
521− *count_bytes = hr.size - 12;
522− memcpy(p_buffer, &hr.u.bytes, *count_bytes);
523− } else
524− *count_bytes = 0;
525− return hr.error;
526−}
527−
528−u16 hpi_adapter_set_property(const struct hpi_hsubsys *ph_subsys,
529− u16 adapter_index, u16 property, u16 parameter1, u16 parameter2)
266+u16 hpi_adapter_set_property(u16 adapter_index, u16 property, u16 parameter1,
267+ u16 parameter2)
530268 {
531269 struct hpi_message hm;
532270 struct hpi_response hr;
@@ -542,9 +280,8 @@ u16 hpi_adapter_set_property(const struct hpi_hsubsys *ph_subsys, · 9 unmodified lines
542280 return hr.error;
543281 }
544282
545−u16 hpi_adapter_get_property(const struct hpi_hsubsys *ph_subsys,
546− u16 adapter_index, u16 property, u16 *pw_parameter1,
547− u16 *pw_parameter2)
283+u16 hpi_adapter_get_property(u16 adapter_index, u16 property,
284+ u16 *pw_parameter1, u16 *pw_parameter2)
548285 {
549286 struct hpi_message hm;
550287 struct hpi_response hr;
@@ -564,9 +301,8 @@ u16 hpi_adapter_get_property(const struct hpi_hsubsys *ph_subsys, · 13 unmodified lines
564301 return hr.error;
565302 }
566303
567−u16 hpi_adapter_enumerate_property(const struct hpi_hsubsys *ph_subsys,
568− u16 adapter_index, u16 index, u16 what_to_enumerate,
569− u16 property_index, u32 *psetting)
304+u16 hpi_adapter_enumerate_property(u16 adapter_index, u16 index,
305+ u16 what_to_enumerate, u16 property_index, u32 *psetting)
570306 {
571307 return 0;
572308 }
@@ -574,7 +310,7 @@ u16 hpi_adapter_enumerate_property(const struct hpi_hsubsys *ph_subsys, · 1 unmodified line
574310 u16 hpi_format_create(struct hpi_format *p_format, u16 channels, u16 format,
575311 u32 sample_rate, u32 bit_rate, u32 attributes)
576312 {
577− u16 error = 0;
313+ u16 err = 0;
578314 struct hpi_msg_format fmt;
579315
580316 switch (channels) {
@@ -586,8 +322,8 @@ u16 hpi_format_create(struct hpi_format *p_format, u16 channels, u16 format, · 5 unmodified lines
586322 case 16:
587323 break;
588324 default:
589− error = HPI_ERROR_INVALID_CHANNELS;
590− return error;
325+ err = HPI_ERROR_INVALID_CHANNELS;
326+ return err;
591327 }
592328 fmt.channels = channels;
593329
@@ -610,17 +346,17 @@ u16 hpi_format_create(struct hpi_format *p_format, u16 channels, u16 format, · 16 unmodified lines
610346 case HPI_FORMAT_OEM2:
611347 break;
612348 default:
613− error = HPI_ERROR_INVALID_FORMAT;
614− return error;
349+ err = HPI_ERROR_INVALID_FORMAT;
350+ return err;
615351 }
616352 fmt.format = format;
617353
618354 if (sample_rate < 8000L) {
619− error = HPI_ERROR_INCOMPATIBLE_SAMPLERATE;
355+ err = HPI_ERROR_INCOMPATIBLE_SAMPLERATE;
620356 sample_rate = 8000L;
621357 }
622358 if (sample_rate > 200000L) {
623− error = HPI_ERROR_INCOMPATIBLE_SAMPLERATE;
359+ err = HPI_ERROR_INCOMPATIBLE_SAMPLERATE;
624360 sample_rate = 200000L;
625361 }
626362 fmt.sample_rate = sample_rate;
@@ -651,10 +387,10 @@ u16 hpi_format_create(struct hpi_format *p_format, u16 channels, u16 format, · 24 unmodified lines
651387 if ((channels == 1)
652388 && (attributes != HPI_MPEG_MODE_DEFAULT)) {
653389 attributes = HPI_MPEG_MODE_DEFAULT;
654− error = HPI_ERROR_INVALID_FORMAT;
390+ err = HPI_ERROR_INVALID_FORMAT;
655391 } else if (attributes > HPI_MPEG_MODE_DUALCHANNEL) {
656392 attributes = HPI_MPEG_MODE_DEFAULT;
657− error = HPI_ERROR_INVALID_FORMAT;
393+ err = HPI_ERROR_INVALID_FORMAT;
658394 }
659395 fmt.attributes = attributes;
660396 break;
@@ -663,7 +399,7 @@ u16 hpi_format_create(struct hpi_format *p_format, u16 channels, u16 format, · 2 unmodified lines
663399 }
664400
665401 hpi_msg_to_format(p_format, &fmt);
666− return error;
402+ return err;
667403 }
668404
669405 u16 hpi_stream_estimate_buffer_size(struct hpi_format *p_format,
@@ -712,8 +448,8 @@ u16 hpi_stream_estimate_buffer_size(struct hpi_format *p_format, · 42 unmodified lines
712448 return 0;
713449 }
714450
715−u16 hpi_outstream_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index,
716− u16 outstream_index, u32 *ph_outstream)
451+u16 hpi_outstream_open(u16 adapter_index, u16 outstream_index,
452+ u32 *ph_outstream)
717453 {
718454 struct hpi_message hm;
719455 struct hpi_response hr;
@@ -733,38 +469,41 @@ u16 hpi_outstream_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index, · 13 unmodified lines
733469 return hr.error;
734470 }
735471
736−u16 hpi_outstream_close(const struct hpi_hsubsys *ph_subsys, u32 h_outstream)
472+u16 hpi_outstream_close(u32 h_outstream)
737473 {
738474 struct hpi_message hm;
739475 struct hpi_response hr;
740476
741477 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
742478 HPI_OSTREAM_HOSTBUFFER_FREE);
743− u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index);
479+ if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
480+ return HPI_ERROR_INVALID_HANDLE;
481+
744482 hpi_send_recv(&hm, &hr);
745483
746484 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
747485 HPI_OSTREAM_GROUP_RESET);
748− u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index);
486+ hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index);
749487 hpi_send_recv(&hm, &hr);
750488
751489 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
752490 HPI_OSTREAM_CLOSE);
753− u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index);
491+ hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index);
754492 hpi_send_recv(&hm, &hr);
755493
756494 return hr.error;
757495 }
758496
759−u16 hpi_outstream_get_info_ex(const struct hpi_hsubsys *ph_subsys,
760− u32 h_outstream, u16 *pw_state, u32 *pbuffer_size, u32 *pdata_to_play,
761− u32 *psamples_played, u32 *pauxiliary_data_to_play)
497+u16 hpi_outstream_get_info_ex(u32 h_outstream, u16 *pw_state,
498+ u32 *pbuffer_size, u32 *pdata_to_play, u32 *psamples_played,
499+ u32 *pauxiliary_data_to_play)
762500 {
763501 struct hpi_message hm;
764502 struct hpi_response hr;
765503 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
766504 HPI_OSTREAM_GET_INFO);
767− u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index);
505+ if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
506+ return HPI_ERROR_INVALID_HANDLE;
768507
769508 hpi_send_recv(&hm, &hr);
770509
@@ -782,15 +521,15 @@ u16 hpi_outstream_get_info_ex(const struct hpi_hsubsys *ph_subsys, · 11 unmodified lines
782521 return hr.error;
783522 }
784523
785−u16 hpi_outstream_write_buf(const struct hpi_hsubsys *ph_subsys,
786− u32 h_outstream, const u8 *pb_data, u32 bytes_to_write,
787− const struct hpi_format *p_format)
524+u16 hpi_outstream_write_buf(u32 h_outstream, const u8 *pb_data,
525+ u32 bytes_to_write, const struct hpi_format *p_format)
788526 {
789527 struct hpi_message hm;
790528 struct hpi_response hr;
791529 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
792530 HPI_OSTREAM_WRITE);
793− u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index);
531+ if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
532+ return HPI_ERROR_INVALID_HANDLE;
794533 hm.u.d.u.data.pb_data = (u8 *)pb_data;
795534 hm.u.d.u.data.data_size = bytes_to_write;
796535
@@ -801,82 +540,85 @@ u16 hpi_outstream_write_buf(const struct hpi_hsubsys *ph_subsys, · 4 unmodified lines
801540 return hr.error;
802541 }
803542
804−u16 hpi_outstream_start(const struct hpi_hsubsys *ph_subsys, u32 h_outstream)
543+u16 hpi_outstream_start(u32 h_outstream)
805544 {
806545 struct hpi_message hm;
807546 struct hpi_response hr;
808547 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
809548 HPI_OSTREAM_START);
810− u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index);
549+ if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
550+ return HPI_ERROR_INVALID_HANDLE;
811551
812552 hpi_send_recv(&hm, &hr);
813553
814554 return hr.error;
815555 }
816556
817−u16 hpi_outstream_wait_start(const struct hpi_hsubsys *ph_subsys,
818− u32 h_outstream)
557+u16 hpi_outstream_wait_start(u32 h_outstream)
819558 {
820559 struct hpi_message hm;
821560 struct hpi_response hr;
822561 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
823562 HPI_OSTREAM_WAIT_START);
824− u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index);
563+ if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
564+ return HPI_ERROR_INVALID_HANDLE;
825565
826566 hpi_send_recv(&hm, &hr);
827567
828568 return hr.error;
829569 }
830570
831−u16 hpi_outstream_stop(const struct hpi_hsubsys *ph_subsys, u32 h_outstream)
571+u16 hpi_outstream_stop(u32 h_outstream)
832572 {
833573 struct hpi_message hm;
834574 struct hpi_response hr;
835575 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
836576 HPI_OSTREAM_STOP);
837− u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index);
577+ if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
578+ return HPI_ERROR_INVALID_HANDLE;
838579
839580 hpi_send_recv(&hm, &hr);
840581
841582 return hr.error;
842583 }
843584
844−u16 hpi_outstream_sinegen(const struct hpi_hsubsys *ph_subsys,
845− u32 h_outstream)
585+u16 hpi_outstream_sinegen(u32 h_outstream)
846586 {
847587 struct hpi_message hm;
848588 struct hpi_response hr;
849589 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
850590 HPI_OSTREAM_SINEGEN);
851− u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index);
591+ if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
592+ return HPI_ERROR_INVALID_HANDLE;
852593
853594 hpi_send_recv(&hm, &hr);
854595
855596 return hr.error;
856597 }
857598
858−u16 hpi_outstream_reset(const struct hpi_hsubsys *ph_subsys, u32 h_outstream)
599+u16 hpi_outstream_reset(u32 h_outstream)
859600 {
860601 struct hpi_message hm;
861602 struct hpi_response hr;
862603 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
863604 HPI_OSTREAM_RESET);
864− u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index);
605+ if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
606+ return HPI_ERROR_INVALID_HANDLE;
865607
866608 hpi_send_recv(&hm, &hr);
867609
868610 return hr.error;
869611 }
870612
871−u16 hpi_outstream_query_format(const struct hpi_hsubsys *ph_subsys,
872− u32 h_outstream, struct hpi_format *p_format)
613+u16 hpi_outstream_query_format(u32 h_outstream, struct hpi_format *p_format)
873614 {
874615 struct hpi_message hm;
875616 struct hpi_response hr;
876617
877618 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
878619 HPI_OSTREAM_QUERY_FORMAT);
879− u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index);
620+ if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
621+ return HPI_ERROR_INVALID_HANDLE;
880622
881623 hpi_format_to_msg(&hm.u.d.u.data.format, p_format);
882624
@@ -885,15 +627,15 @@ u16 hpi_outstream_query_format(const struct hpi_hsubsys *ph_subsys, · 2 unmodified lines
885627 return hr.error;
886628 }
887629
888−u16 hpi_outstream_set_format(const struct hpi_hsubsys *ph_subsys,
889− u32 h_outstream, struct hpi_format *p_format)
630+u16 hpi_outstream_set_format(u32 h_outstream, struct hpi_format *p_format)
890631 {
891632 struct hpi_message hm;
892633 struct hpi_response hr;
893634
894635 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
895636 HPI_OSTREAM_SET_FORMAT);
896− u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index);
637+ if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
638+ return HPI_ERROR_INVALID_HANDLE;
897639
898640 hpi_format_to_msg(&hm.u.d.u.data.format, p_format);
899641
@@ -902,15 +644,15 @@ u16 hpi_outstream_set_format(const struct hpi_hsubsys *ph_subsys, · 2 unmodified lines
902644 return hr.error;
903645 }
904646
905−u16 hpi_outstream_set_velocity(const struct hpi_hsubsys *ph_subsys,
906− u32 h_outstream, short velocity)
647+u16 hpi_outstream_set_velocity(u32 h_outstream, short velocity)
907648 {
908649 struct hpi_message hm;
909650 struct hpi_response hr;
910651
911652 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
912653 HPI_OSTREAM_SET_VELOCITY);
913− u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index);
654+ if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
655+ return HPI_ERROR_INVALID_HANDLE;
914656 hm.u.d.u.velocity = velocity;
915657
916658 hpi_send_recv(&hm, &hr);
@@ -918,15 +660,16 @@ u16 hpi_outstream_set_velocity(const struct hpi_hsubsys *ph_subsys, · 1 unmodified line
918660 return hr.error;
919661 }
920662
921−u16 hpi_outstream_set_punch_in_out(const struct hpi_hsubsys *ph_subsys,
922− u32 h_outstream, u32 punch_in_sample, u32 punch_out_sample)
663+u16 hpi_outstream_set_punch_in_out(u32 h_outstream, u32 punch_in_sample,
664+ u32 punch_out_sample)
923665 {
924666 struct hpi_message hm;
925667 struct hpi_response hr;
926668
927669 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
928670 HPI_OSTREAM_SET_PUNCHINOUT);
929− u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index);
671+ if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
672+ return HPI_ERROR_INVALID_HANDLE;
930673
931674 hm.u.d.u.pio.punch_in_sample = punch_in_sample;
932675 hm.u.d.u.pio.punch_out_sample = punch_out_sample;
@@ -936,29 +679,29 @@ u16 hpi_outstream_set_punch_in_out(const struct hpi_hsubsys *ph_subsys, · 3 unmodified lines
936679 return hr.error;
937680 }
938681
939−u16 hpi_outstream_ancillary_reset(const struct hpi_hsubsys *ph_subsys,
940− u32 h_outstream, u16 mode)
682+u16 hpi_outstream_ancillary_reset(u32 h_outstream, u16 mode)
941683 {
942684 struct hpi_message hm;
943685 struct hpi_response hr;
944686
945687 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
946688 HPI_OSTREAM_ANC_RESET);
947− u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index);
689+ if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
690+ return HPI_ERROR_INVALID_HANDLE;
948691 hm.u.d.u.data.format.channels = mode;
949692 hpi_send_recv(&hm, &hr);
950693 return hr.error;
951694 }
952695
953−u16 hpi_outstream_ancillary_get_info(const struct hpi_hsubsys *ph_subsys,
954− u32 h_outstream, u32 *pframes_available)
696+u16 hpi_outstream_ancillary_get_info(u32 h_outstream, u32 *pframes_available)
955697 {
956698 struct hpi_message hm;
957699 struct hpi_response hr;
958700
959701 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
960702 HPI_OSTREAM_ANC_GET_INFO);
961− u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index);
703+ if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
704+ return HPI_ERROR_INVALID_HANDLE;
962705 hpi_send_recv(&hm, &hr);
963706 if (hr.error == 0) {
964707 if (pframes_available)
@@ -969,8 +712,8 @@ u16 hpi_outstream_ancillary_get_info(const struct hpi_hsubsys *ph_subsys, · 4 unmodified lines
969712 return hr.error;
970713 }
971714
972−u16 hpi_outstream_ancillary_read(const struct hpi_hsubsys *ph_subsys,
973− u32 h_outstream, struct hpi_anc_frame *p_anc_frame_buffer,
715+u16 hpi_outstream_ancillary_read(u32 h_outstream,
716+ struct hpi_anc_frame *p_anc_frame_buffer,
974717 u32 anc_frame_buffer_size_in_bytes,
975718 u32 number_of_ancillary_frames_to_read)
976719 {
@@ -979,7 +722,8 @@ u16 hpi_outstream_ancillary_read(const struct hpi_hsubsys *ph_subsys, · 2 unmodified lines
979722
980723 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
981724 HPI_OSTREAM_ANC_READ);
982− u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index);
725+ if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
726+ return HPI_ERROR_INVALID_HANDLE;
983727 hm.u.d.u.data.pb_data = (u8 *)p_anc_frame_buffer;
984728 hm.u.d.u.data.data_size =
985729 number_of_ancillary_frames_to_read *
@@ -987,19 +731,19 @@ u16 hpi_outstream_ancillary_read(const struct hpi_hsubsys *ph_subsys, · 1 unmodified line
987731 if (hm.u.d.u.data.data_size <= anc_frame_buffer_size_in_bytes)
988732 hpi_send_recv(&hm, &hr);
989733 else
990− hr.error = HPI_ERROR_INVALID_DATA_TRANSFER;
734+ hr.error = HPI_ERROR_INVALID_DATASIZE;
991735 return hr.error;
992736 }
993737
994−u16 hpi_outstream_set_time_scale(const struct hpi_hsubsys *ph_subsys,
995− u32 h_outstream, u32 time_scale)
738+u16 hpi_outstream_set_time_scale(u32 h_outstream, u32 time_scale)
996739 {
997740 struct hpi_message hm;
998741 struct hpi_response hr;
999742
1000743 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
1001744 HPI_OSTREAM_SET_TIMESCALE);
1002− u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index);
745+ if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
746+ return HPI_ERROR_INVALID_HANDLE;
1003747
1004748 hm.u.d.u.time_scale = time_scale;
1005749
@@ -1008,22 +752,21 @@ u16 hpi_outstream_set_time_scale(const struct hpi_hsubsys *ph_subsys, · 2 unmodified lines
1008752 return hr.error;
1009753 }
1010754
1011−u16 hpi_outstream_host_buffer_allocate(const struct hpi_hsubsys *ph_subsys,
1012− u32 h_outstream, u32 size_in_bytes)
755+u16 hpi_outstream_host_buffer_allocate(u32 h_outstream, u32 size_in_bytes)
1013756 {
1014757 struct hpi_message hm;
1015758 struct hpi_response hr;
1016759
1017760 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
1018761 HPI_OSTREAM_HOSTBUFFER_ALLOC);
1019− u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index);
762+ if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
763+ return HPI_ERROR_INVALID_HANDLE;
1020764 hm.u.d.u.data.data_size = size_in_bytes;
1021765 hpi_send_recv(&hm, &hr);
1022766 return hr.error;
1023767 }
1024768
1025−u16 hpi_outstream_host_buffer_get_info(const struct hpi_hsubsys *ph_subsys,
1026− u32 h_outstream, u8 **pp_buffer,
769+u16 hpi_outstream_host_buffer_get_info(u32 h_outstream, u8 **pp_buffer,
1027770 struct hpi_hostbuffer_status **pp_status)
1028771 {
1029772 struct hpi_message hm;
@@ -1031,7 +774,8 @@ u16 hpi_outstream_host_buffer_get_info(const struct hpi_hsubsys *ph_subsys, · 1 unmodified line
1031774
1032775 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
1033776 HPI_OSTREAM_HOSTBUFFER_GET_INFO);
1034− u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index);
777+ if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
778+ return HPI_ERROR_INVALID_HANDLE;
1035779 hpi_send_recv(&hm, &hr);
1036780
1037781 if (hr.error == 0) {
@@ -1043,21 +787,20 @@ u16 hpi_outstream_host_buffer_get_info(const struct hpi_hsubsys *ph_subsys, · 5 unmodified lines
1043787 return hr.error;
1044788 }
1045789
1046−u16 hpi_outstream_host_buffer_free(const struct hpi_hsubsys *ph_subsys,
1047− u32 h_outstream)
790+u16 hpi_outstream_host_buffer_free(u32 h_outstream)
1048791 {
1049792 struct hpi_message hm;
1050793 struct hpi_response hr;
1051794
1052795 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
1053796 HPI_OSTREAM_HOSTBUFFER_FREE);
1054− u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index);
797+ if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
798+ return HPI_ERROR_INVALID_HANDLE;
1055799 hpi_send_recv(&hm, &hr);
1056800 return hr.error;
1057801 }
1058802
1059−u16 hpi_outstream_group_add(const struct hpi_hsubsys *ph_subsys,
1060− u32 h_outstream, u32 h_stream)
803+u16 hpi_outstream_group_add(u32 h_outstream, u32 h_stream)
1061804 {
1062805 struct hpi_message hm;
1063806 struct hpi_response hr;
@@ -1066,22 +809,22 @@ u16 hpi_outstream_group_add(const struct hpi_hsubsys *ph_subsys, · 2 unmodified lines
1066809
1067810 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
1068811 HPI_OSTREAM_GROUP_ADD);
1069− hr.error = 0;
1070− u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index);
812+
813+ if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
814+ return HPI_ERROR_INVALID_HANDLE;
815+
816+ if (hpi_handle_indexes(h_stream, &adapter,
817+ &hm.u.d.u.stream.stream_index))
818+ return HPI_ERROR_INVALID_HANDLE;
819+
1071820 c_obj_type = hpi_handle_object(h_stream);
1072821 switch (c_obj_type) {
1073822 case HPI_OBJ_OSTREAM:
1074− hm.u.d.u.stream.object_type = HPI_OBJ_OSTREAM;
1075− u32TOINDEXES(h_stream, &adapter,
1076− &hm.u.d.u.stream.stream_index);
1077− break;
1078823 case HPI_OBJ_ISTREAM:
1079− hm.u.d.u.stream.object_type = HPI_OBJ_ISTREAM;
1080− u32TOINDEXES(h_stream, &adapter,
1081− &hm.u.d.u.stream.stream_index);
824+ hm.u.d.u.stream.object_type = c_obj_type;
1082825 break;
1083826 default:
1084− return HPI_ERROR_INVALID_STREAM;
827+ return HPI_ERROR_INVALID_OBJ;
1085828 }
1086829 if (adapter != hm.adapter_index)
1087830 return HPI_ERROR_NO_INTERADAPTER_GROUPS;
@@ -1090,15 +833,16 @@ u16 hpi_outstream_group_add(const struct hpi_hsubsys *ph_subsys, · 2 unmodified lines
1090833 return hr.error;
1091834 }
1092835
1093−u16 hpi_outstream_group_get_map(const struct hpi_hsubsys *ph_subsys,
1094− u32 h_outstream, u32 *poutstream_map, u32 *pinstream_map)
836+u16 hpi_outstream_group_get_map(u32 h_outstream, u32 *poutstream_map,
837+ u32 *pinstream_map)
1095838 {
1096839 struct hpi_message hm;
1097840 struct hpi_response hr;
1098841
1099842 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
1100843 HPI_OSTREAM_GROUP_GETMAP);
1101− u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index);
844+ if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
845+ return HPI_ERROR_INVALID_HANDLE;
1102846 hpi_send_recv(&hm, &hr);
1103847
1104848 if (poutstream_map)
@@ -1109,21 +853,20 @@ u16 hpi_outstream_group_get_map(const struct hpi_hsubsys *ph_subsys, · 4 unmodified lines
1109853 return hr.error;
1110854 }
1111855
1112−u16 hpi_outstream_group_reset(const struct hpi_hsubsys *ph_subsys,
1113− u32 h_outstream)
856+u16 hpi_outstream_group_reset(u32 h_outstream)
1114857 {
1115858 struct hpi_message hm;
1116859 struct hpi_response hr;
1117860
1118861 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
1119862 HPI_OSTREAM_GROUP_RESET);
1120− u32TOINDEXES(h_outstream, &hm.adapter_index, &hm.obj_index);
863+ if (hpi_handle_indexes(h_outstream, &hm.adapter_index, &hm.obj_index))
864+ return HPI_ERROR_INVALID_HANDLE;
1121865 hpi_send_recv(&hm, &hr);
1122866 return hr.error;
1123867 }
1124868
1125−u16 hpi_instream_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index,
1126− u16 instream_index, u32 *ph_instream)
869+u16 hpi_instream_open(u16 adapter_index, u16 instream_index, u32 *ph_instream)
1127870 {
1128871 struct hpi_message hm;
1129872 struct hpi_response hr;
@@ -1145,38 +888,40 @@ u16 hpi_instream_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index, · 15 unmodified lines
1145888 return hr.error;
1146889 }
1147890
1148−u16 hpi_instream_close(const struct hpi_hsubsys *ph_subsys, u32 h_instream)
891+u16 hpi_instream_close(u32 h_instream)
1149892 {
1150893 struct hpi_message hm;
1151894 struct hpi_response hr;
1152895
1153896 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1154897 HPI_ISTREAM_HOSTBUFFER_FREE);
1155− u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index);
898+ if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
899+ return HPI_ERROR_INVALID_HANDLE;
1156900 hpi_send_recv(&hm, &hr);
1157901
1158902 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1159903 HPI_ISTREAM_GROUP_RESET);
1160− u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index);
904+ hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index);
1161905 hpi_send_recv(&hm, &hr);
1162906
1163907 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1164908 HPI_ISTREAM_CLOSE);
1165− u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index);
909+ hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index);
1166910 hpi_send_recv(&hm, &hr);
1167911
1168912 return hr.error;
1169913 }
1170914
1171−u16 hpi_instream_query_format(const struct hpi_hsubsys *ph_subsys,
1172− u32 h_instream, const struct hpi_format *p_format)
915+u16 hpi_instream_query_format(u32 h_instream,
916+ const struct hpi_format *p_format)
1173917 {
1174918 struct hpi_message hm;
1175919 struct hpi_response hr;
1176920
1177921 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1178922 HPI_ISTREAM_QUERY_FORMAT);
1179− u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index);
923+ if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
924+ return HPI_ERROR_INVALID_HANDLE;
1180925 hpi_format_to_msg(&hm.u.d.u.data.format, p_format);
1181926
1182927 hpi_send_recv(&hm, &hr);
@@ -1184,15 +929,15 @@ u16 hpi_instream_query_format(const struct hpi_hsubsys *ph_subsys, · 1 unmodified line
1184929 return hr.error;
1185930 }
1186931
1187−u16 hpi_instream_set_format(const struct hpi_hsubsys *ph_subsys,
1188− u32 h_instream, const struct hpi_format *p_format)
932+u16 hpi_instream_set_format(u32 h_instream, const struct hpi_format *p_format)
1189933 {
1190934 struct hpi_message hm;
1191935 struct hpi_response hr;
1192936
1193937 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1194938 HPI_ISTREAM_SET_FORMAT);
1195− u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index);
939+ if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
940+ return HPI_ERROR_INVALID_HANDLE;
1196941 hpi_format_to_msg(&hm.u.d.u.data.format, p_format);
1197942
1198943 hpi_send_recv(&hm, &hr);
@@ -1200,15 +945,15 @@ u16 hpi_instream_set_format(const struct hpi_hsubsys *ph_subsys, · 1 unmodified line
1200945 return hr.error;
1201946 }
1202947
1203−u16 hpi_instream_read_buf(const struct hpi_hsubsys *ph_subsys, u32 h_instream,
1204− u8 *pb_data, u32 bytes_to_read)
948+u16 hpi_instream_read_buf(u32 h_instream, u8 *pb_data, u32 bytes_to_read)
1205949 {
1206950 struct hpi_message hm;
1207951 struct hpi_response hr;
1208952
1209953 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1210954 HPI_ISTREAM_READ);
1211− u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index);
955+ if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
956+ return HPI_ERROR_INVALID_HANDLE;
1212957 hm.u.d.u.data.data_size = bytes_to_read;
1213958 hm.u.d.u.data.pb_data = pb_data;
1214959
@@ -1217,72 +962,76 @@ u16 hpi_instream_read_buf(const struct hpi_hsubsys *ph_subsys, u32 h_instream, · 2 unmodified lines
1217962 return hr.error;
1218963 }
1219964
1220−u16 hpi_instream_start(const struct hpi_hsubsys *ph_subsys, u32 h_instream)
965+u16 hpi_instream_start(u32 h_instream)
1221966 {
1222967 struct hpi_message hm;
1223968 struct hpi_response hr;
1224969
1225970 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1226971 HPI_ISTREAM_START);
1227− u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index);
972+ if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
973+ return HPI_ERROR_INVALID_HANDLE;
1228974
1229975 hpi_send_recv(&hm, &hr);
1230976
1231977 return hr.error;
1232978 }
1233979
1234−u16 hpi_instream_wait_start(const struct hpi_hsubsys *ph_subsys,
1235− u32 h_instream)
980+u16 hpi_instream_wait_start(u32 h_instream)
1236981 {
1237982 struct hpi_message hm;
1238983 struct hpi_response hr;
1239984
1240985 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
1241986 HPI_ISTREAM_WAIT_START);
1242− u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index);
987+ if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
988+ return HPI_ERROR_INVALID_HANDLE;
1243989
1244990 hpi_send_recv(&hm, &hr);
1245991
1246992 return hr.error;
1247993 }
1248994
1249−u16 hpi_instream_stop(const struct hpi_hsubsys *ph_subsys, u32 h_instream)
995+u16 hpi_instream_stop(u32 h_instream)
1250996 {
1251997 struct hpi_message hm;
1252998 struct hpi_response hr;
1253999
12541000 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
12551001 HPI_ISTREAM_STOP);
1256− u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index);
1002+ if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
1003+ return HPI_ERROR_INVALID_HANDLE;
12571004
12581005 hpi_send_recv(&hm, &hr);
12591006
12601007 return hr.error;
12611008 }
12621009
1263−u16 hpi_instream_reset(const struct hpi_hsubsys *ph_subsys, u32 h_instream)
1010+u16 hpi_instream_reset(u32 h_instream)
12641011 {
12651012 struct hpi_message hm;
12661013 struct hpi_response hr;
12671014
12681015 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
12691016 HPI_ISTREAM_RESET);
1270− u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index);
1017+ if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
1018+ return HPI_ERROR_INVALID_HANDLE;
12711019
12721020 hpi_send_recv(&hm, &hr);
12731021
12741022 return hr.error;
12751023 }
12761024
1277−u16 hpi_instream_get_info_ex(const struct hpi_hsubsys *ph_subsys,
1278− u32 h_instream, u16 *pw_state, u32 *pbuffer_size, u32 *pdata_recorded,
1279− u32 *psamples_recorded, u32 *pauxiliary_data_recorded)
1025+u16 hpi_instream_get_info_ex(u32 h_instream, u16 *pw_state, u32 *pbuffer_size,
1026+ u32 *pdata_recorded, u32 *psamples_recorded,
1027+ u32 *pauxiliary_data_recorded)
12801028 {
12811029 struct hpi_message hm;
12821030 struct hpi_response hr;
12831031 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
12841032 HPI_ISTREAM_GET_INFO);
1285− u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index);
1033+ if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
1034+ return HPI_ERROR_INVALID_HANDLE;
12861035
12871036 hpi_send_recv(&hm, &hr);
12881037
@@ -1300,15 +1049,15 @@ u16 hpi_instream_get_info_ex(const struct hpi_hsubsys *ph_subsys, · 11 unmodified lines
13001049 return hr.error;
13011050 }
13021051
1303−u16 hpi_instream_ancillary_reset(const struct hpi_hsubsys *ph_subsys,
1304− u32 h_instream, u16 bytes_per_frame, u16 mode, u16 alignment,
1305− u16 idle_bit)
1052+u16 hpi_instream_ancillary_reset(u32 h_instream, u16 bytes_per_frame,
1053+ u16 mode, u16 alignment, u16 idle_bit)
13061054 {
13071055 struct hpi_message hm;
13081056 struct hpi_response hr;
13091057 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
13101058 HPI_ISTREAM_ANC_RESET);
1311− u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index);
1059+ if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
1060+ return HPI_ERROR_INVALID_HANDLE;
13121061 hm.u.d.u.data.format.attributes = bytes_per_frame;
13131062 hm.u.d.u.data.format.format = (mode << 8) | (alignment & 0xff);
13141063 hm.u.d.u.data.format.channels = idle_bit;
@@ -1316,14 +1065,14 @@ u16 hpi_instream_ancillary_reset(const struct hpi_hsubsys *ph_subsys, · 1 unmodified line
13161065 return hr.error;
13171066 }
13181067
1319−u16 hpi_instream_ancillary_get_info(const struct hpi_hsubsys *ph_subsys,
1320− u32 h_instream, u32 *pframe_space)
1068+u16 hpi_instream_ancillary_get_info(u32 h_instream, u32 *pframe_space)
13211069 {
13221070 struct hpi_message hm;
13231071 struct hpi_response hr;
13241072 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
13251073 HPI_ISTREAM_ANC_GET_INFO);
1326− u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index);
1074+ if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
1075+ return HPI_ERROR_INVALID_HANDLE;
13271076 hpi_send_recv(&hm, &hr);
13281077 if (pframe_space)
13291078 *pframe_space =
@@ -1333,8 +1082,8 @@ u16 hpi_instream_ancillary_get_info(const struct hpi_hsubsys *ph_subsys, · 3 unmodified lines
13331082 return hr.error;
13341083 }
13351084
1336−u16 hpi_instream_ancillary_write(const struct hpi_hsubsys *ph_subsys,
1337− u32 h_instream, const struct hpi_anc_frame *p_anc_frame_buffer,
1085+u16 hpi_instream_ancillary_write(u32 h_instream,
1086+ const struct hpi_anc_frame *p_anc_frame_buffer,
13381087 u32 anc_frame_buffer_size_in_bytes,
13391088 u32 number_of_ancillary_frames_to_write)
13401089 {
@@ -1343,7 +1092,8 @@ u16 hpi_instream_ancillary_write(const struct hpi_hsubsys *ph_subsys, · 2 unmodified lines
13431092
13441093 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
13451094 HPI_ISTREAM_ANC_WRITE);
1346− u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index);
1095+ if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
1096+ return HPI_ERROR_INVALID_HANDLE;
13471097 hm.u.d.u.data.pb_data = (u8 *)p_anc_frame_buffer;
13481098 hm.u.d.u.data.data_size =
13491099 number_of_ancillary_frames_to_write *
@@ -1351,12 +1101,11 @@ u16 hpi_instream_ancillary_write(const struct hpi_hsubsys *ph_subsys, · 1 unmodified line
13511101 if (hm.u.d.u.data.data_size <= anc_frame_buffer_size_in_bytes)
13521102 hpi_send_recv(&hm, &hr);
13531103 else
1354− hr.error = HPI_ERROR_INVALID_DATA_TRANSFER;
1104+ hr.error = HPI_ERROR_INVALID_DATASIZE;
13551105 return hr.error;
13561106 }
13571107
1358−u16 hpi_instream_host_buffer_allocate(const struct hpi_hsubsys *ph_subsys,
1359− u32 h_instream, u32 size_in_bytes)
1108+u16 hpi_instream_host_buffer_allocate(u32 h_instream, u32 size_in_bytes)
13601109 {
13611110
13621111 struct hpi_message hm;
@@ -1364,14 +1113,14 @@ u16 hpi_instream_host_buffer_allocate(const struct hpi_hsubsys *ph_subsys, · 1 unmodified line
13641113
13651114 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
13661115 HPI_ISTREAM_HOSTBUFFER_ALLOC);
1367− u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index);
1116+ if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
1117+ return HPI_ERROR_INVALID_HANDLE;
13681118 hm.u.d.u.data.data_size = size_in_bytes;
13691119 hpi_send_recv(&hm, &hr);
13701120 return hr.error;
13711121 }
13721122
1373−u16 hpi_instream_host_buffer_get_info(const struct hpi_hsubsys *ph_subsys,
1374− u32 h_instream, u8 **pp_buffer,
1123+u16 hpi_instream_host_buffer_get_info(u32 h_instream, u8 **pp_buffer,
13751124 struct hpi_hostbuffer_status **pp_status)
13761125 {
13771126 struct hpi_message hm;
@@ -1379,7 +1128,8 @@ u16 hpi_instream_host_buffer_get_info(const struct hpi_hsubsys *ph_subsys, · 1 unmodified line
13791128
13801129 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
13811130 HPI_ISTREAM_HOSTBUFFER_GET_INFO);
1382− u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index);
1131+ if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
1132+ return HPI_ERROR_INVALID_HANDLE;
13831133 hpi_send_recv(&hm, &hr);
13841134
13851135 if (hr.error == 0) {
@@ -1391,8 +1141,7 @@ u16 hpi_instream_host_buffer_get_info(const struct hpi_hsubsys *ph_subsys, · 5 unmodified lines
13911141 return hr.error;
13921142 }
13931143
1394−u16 hpi_instream_host_buffer_free(const struct hpi_hsubsys *ph_subsys,
1395− u32 h_instream)
1144+u16 hpi_instream_host_buffer_free(u32 h_instream)
13961145 {
13971146
13981147 struct hpi_message hm;
@@ -1400,13 +1149,13 @@ u16 hpi_instream_host_buffer_free(const struct hpi_hsubsys *ph_subsys, · 1 unmodified line
14001149
14011150 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
14021151 HPI_ISTREAM_HOSTBUFFER_FREE);
1403− u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index);
1152+ if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
1153+ return HPI_ERROR_INVALID_HANDLE;
14041154 hpi_send_recv(&hm, &hr);
14051155 return hr.error;
14061156 }
14071157
1408−u16 hpi_instream_group_add(const struct hpi_hsubsys *ph_subsys,
1409− u32 h_instream, u32 h_stream)
1158+u16 hpi_instream_group_add(u32 h_instream, u32 h_stream)
14101159 {
14111160 struct hpi_message hm;
14121161 struct hpi_response hr;
@@ -1416,22 +1165,23 @@ u16 hpi_instream_group_add(const struct hpi_hsubsys *ph_subsys, · 3 unmodified lines
14161165 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
14171166 HPI_ISTREAM_GROUP_ADD);
14181167 hr.error = 0;
1419− u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index);
1168+
1169+ if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
1170+ return HPI_ERROR_INVALID_HANDLE;
1171+
1172+ if (hpi_handle_indexes(h_stream, &adapter,
1173+ &hm.u.d.u.stream.stream_index))
1174+ return HPI_ERROR_INVALID_HANDLE;
1175+
14201176 c_obj_type = hpi_handle_object(h_stream);
14211177
14221178 switch (c_obj_type) {
14231179 case HPI_OBJ_OSTREAM:
1424− hm.u.d.u.stream.object_type = HPI_OBJ_OSTREAM;
1425− u32TOINDEXES(h_stream, &adapter,
1426− &hm.u.d.u.stream.stream_index);
1427− break;
14281180 case HPI_OBJ_ISTREAM:
1429− hm.u.d.u.stream.object_type = HPI_OBJ_ISTREAM;
1430− u32TOINDEXES(h_stream, &adapter,
1431− &hm.u.d.u.stream.stream_index);
1181+ hm.u.d.u.stream.object_type = c_obj_type;
14321182 break;
14331183 default:
1434− return HPI_ERROR_INVALID_STREAM;
1184+ return HPI_ERROR_INVALID_OBJ;
14351185 }
14361186
14371187 if (adapter != hm.adapter_index)
@@ -1441,15 +1191,16 @@ u16 hpi_instream_group_add(const struct hpi_hsubsys *ph_subsys, · 3 unmodified lines
14411191 return hr.error;
14421192 }
14431193
1444−u16 hpi_instream_group_get_map(const struct hpi_hsubsys *ph_subsys,
1445− u32 h_instream, u32 *poutstream_map, u32 *pinstream_map)
1194+u16 hpi_instream_group_get_map(u32 h_instream, u32 *poutstream_map,
1195+ u32 *pinstream_map)
14461196 {
14471197 struct hpi_message hm;
14481198 struct hpi_response hr;
14491199
14501200 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
14511201 HPI_ISTREAM_HOSTBUFFER_FREE);
1452− u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index);
1202+ if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
1203+ return HPI_ERROR_INVALID_HANDLE;
14531204 hpi_send_recv(&hm, &hr);
14541205
14551206 if (poutstream_map)
@@ -1460,21 +1211,20 @@ u16 hpi_instream_group_get_map(const struct hpi_hsubsys *ph_subsys, · 4 unmodified lines
14601211 return hr.error;
14611212 }
14621213
1463−u16 hpi_instream_group_reset(const struct hpi_hsubsys *ph_subsys,
1464− u32 h_instream)
1214+u16 hpi_instream_group_reset(u32 h_instream)
14651215 {
14661216 struct hpi_message hm;
14671217 struct hpi_response hr;
14681218
14691219 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
14701220 HPI_ISTREAM_GROUP_RESET);
1471− u32TOINDEXES(h_instream, &hm.adapter_index, &hm.obj_index);
1221+ if (hpi_handle_indexes(h_instream, &hm.adapter_index, &hm.obj_index))
1222+ return HPI_ERROR_INVALID_HANDLE;
14721223 hpi_send_recv(&hm, &hr);
14731224 return hr.error;
14741225 }
14751226
1476−u16 hpi_mixer_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index,
1477− u32 *ph_mixer)
1227+u16 hpi_mixer_open(u16 adapter_index, u32 *ph_mixer)
14781228 {
14791229 struct hpi_message hm;
14801230 struct hpi_response hr;
@@ -1492,25 +1242,29 @@ u16 hpi_mixer_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index, · 11 unmodified lines
14921242 return hr.error;
14931243 }
14941244
1495−u16 hpi_mixer_close(const struct hpi_hsubsys *ph_subsys, u32 h_mixer)
1245+u16 hpi_mixer_close(u32 h_mixer)
14961246 {
14971247 struct hpi_message hm;
14981248 struct hpi_response hr;
1249+
14991250 hpi_init_message_response(&hm, &hr, HPI_OBJ_MIXER, HPI_MIXER_CLOSE);
1500− u32TOINDEX(h_mixer, &hm.adapter_index);
1251+ if (hpi_handle_indexes(h_mixer, &hm.adapter_index, NULL))
1252+ return HPI_ERROR_INVALID_HANDLE;
1253+
15011254 hpi_send_recv(&hm, &hr);
15021255 return hr.error;
15031256 }
15041257
1505−u16 hpi_mixer_get_control(const struct hpi_hsubsys *ph_subsys, u32 h_mixer,
1506− u16 src_node_type, u16 src_node_type_index, u16 dst_node_type,
1507− u16 dst_node_type_index, u16 control_type, u32 *ph_control)
1258+u16 hpi_mixer_get_control(u32 h_mixer, u16 src_node_type,
1259+ u16 src_node_type_index, u16 dst_node_type, u16 dst_node_type_index,
1260+ u16 control_type, u32 *ph_control)
15081261 {
15091262 struct hpi_message hm;
15101263 struct hpi_response hr;
15111264 hpi_init_message_response(&hm, &hr, HPI_OBJ_MIXER,
15121265 HPI_MIXER_GET_CONTROL);
1513− u32TOINDEX(h_mixer, &hm.adapter_index);
1266+ if (hpi_handle_indexes(h_mixer, &hm.adapter_index, NULL))
1267+ return HPI_ERROR_INVALID_HANDLE;
15141268 hm.u.m.node_type1 = src_node_type;
15151269 hm.u.m.node_index1 = src_node_type_index;
15161270 hm.u.m.node_type2 = dst_node_type;
@@ -1528,16 +1282,16 @@ u16 hpi_mixer_get_control(const struct hpi_hsubsys *ph_subsys, u32 h_mixer, · 11 unmodified lines
15281282 return hr.error;
15291283 }
15301284
1531−u16 hpi_mixer_get_control_by_index(const struct hpi_hsubsys *ph_subsys,
1532− u32 h_mixer, u16 control_index, u16 *pw_src_node_type,
1533− u16 *pw_src_node_index, u16 *pw_dst_node_type, u16 *pw_dst_node_index,
1534− u16 *pw_control_type, u32 *ph_control)
1285+u16 hpi_mixer_get_control_by_index(u32 h_mixer, u16 control_index,
1286+ u16 *pw_src_node_type, u16 *pw_src_node_index, u16 *pw_dst_node_type,
1287+ u16 *pw_dst_node_index, u16 *pw_control_type, u32 *ph_control)
15351288 {
15361289 struct hpi_message hm;
15371290 struct hpi_response hr;
15381291 hpi_init_message_response(&hm, &hr, HPI_OBJ_MIXER,
15391292 HPI_MIXER_GET_CONTROL_BY_INDEX);
1540− u32TOINDEX(h_mixer, &hm.adapter_index);
1293+ if (hpi_handle_indexes(h_mixer, &hm.adapter_index, NULL))
1294+ return HPI_ERROR_INVALID_HANDLE;
15411295 hm.u.m.control_index = control_index;
15421296 hpi_send_recv(&hm, &hr);
15431297
@@ -1562,13 +1316,14 @@ u16 hpi_mixer_get_control_by_index(const struct hpi_hsubsys *ph_subsys, · 18 unmodified lines
15621316 return hr.error;
15631317 }
15641318
1565−u16 hpi_mixer_store(const struct hpi_hsubsys *ph_subsys, u32 h_mixer,
1566− enum HPI_MIXER_STORE_COMMAND command, u16 index)
1319+u16 hpi_mixer_store(u32 h_mixer, enum HPI_MIXER_STORE_COMMAND command,
1320+ u16 index)
15671321 {
15681322 struct hpi_message hm;
15691323 struct hpi_response hr;
15701324 hpi_init_message_response(&hm, &hr, HPI_OBJ_MIXER, HPI_MIXER_STORE);
1571− u32TOINDEX(h_mixer, &hm.adapter_index);
1325+ if (hpi_handle_indexes(h_mixer, &hm.adapter_index, NULL))
1326+ return HPI_ERROR_INVALID_HANDLE;
15721327 hm.u.mx.store.command = command;
15731328 hm.u.mx.store.index = index;
15741329 hpi_send_recv(&hm, &hr);
@@ -1576,16 +1331,16 @@ u16 hpi_mixer_store(const struct hpi_hsubsys *ph_subsys, u32 h_mixer, · 1 unmodified line
15761331 }
15771332
15781333 static
1579−u16 hpi_control_param_set(const struct hpi_hsubsys *ph_subsys,
1580− const u32 h_control, const u16 attrib, const u32 param1,
1581− const u32 param2)
1334+u16 hpi_control_param_set(const u32 h_control, const u16 attrib,
1335+ const u32 param1, const u32 param2)
15821336 {
15831337 struct hpi_message hm;
15841338 struct hpi_response hr;
15851339
15861340 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
15871341 HPI_CONTROL_SET_STATE);
1588− u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
1342+ if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1343+ return HPI_ERROR_INVALID_HANDLE;
15891344 hm.u.c.attribute = attrib;
15901345 hm.u.c.param1 = param1;
15911346 hm.u.c.param2 = param2;
@@ -1601,7 +1356,8 @@ static u16 hpi_control_log_set2(u32 h_control, u16 attrib, short sv0, · 9 unmodified lines
16011356
16021357 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
16031358 HPI_CONTROL_SET_STATE);
1604− u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
1359+ if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1360+ return HPI_ERROR_INVALID_HANDLE;
16051361 hm.u.c.attribute = attrib;
16061362 hm.u.c.an_log_value[0] = sv0;
16071363 hm.u.c.an_log_value[1] = sv1;
@@ -1610,16 +1366,16 @@ static u16 hpi_control_log_set2(u32 h_control, u16 attrib, short sv0, · 2 unmodified lines
16101366 }
16111367
16121368 static
1613−u16 hpi_control_param_get(const struct hpi_hsubsys *ph_subsys,
1614− const u32 h_control, const u16 attrib, u32 param1, u32 param2,
1615− u32 *pparam1, u32 *pparam2)
1369+u16 hpi_control_param_get(const u32 h_control, const u16 attrib, u32 param1,
1370+ u32 param2, u32 *pparam1, u32 *pparam2)
16161371 {
16171372 struct hpi_message hm;
16181373 struct hpi_response hr;
16191374
16201375 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
16211376 HPI_CONTROL_GET_STATE);
1622− u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
1377+ if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1378+ return HPI_ERROR_INVALID_HANDLE;
16231379 hm.u.c.attribute = attrib;
16241380 hm.u.c.param1 = param1;
16251381 hm.u.c.param2 = param2;
@@ -1632,19 +1388,20 @@ u16 hpi_control_param_get(const struct hpi_hsubsys *ph_subsys, · 6 unmodified lines
16321388 return hr.error;
16331389 }
16341390
1635−#define hpi_control_param1_get(s, h, a, p1) \
1636− hpi_control_param_get(s, h, a, 0, 0, p1, NULL)
1637−#define hpi_control_param2_get(s, h, a, p1, p2) \
1638− hpi_control_param_get(s, h, a, 0, 0, p1, p2)
1391+#define hpi_control_param1_get(h, a, p1) \
1392+ hpi_control_param_get(h, a, 0, 0, p1, NULL)
1393+#define hpi_control_param2_get(h, a, p1, p2) \
1394+ hpi_control_param_get(h, a, 0, 0, p1, p2)
16391395
1640−static u16 hpi_control_log_get2(const struct hpi_hsubsys *ph_subsys,
1641− u32 h_control, u16 attrib, short *sv0, short *sv1)
1396+static u16 hpi_control_log_get2(u32 h_control, u16 attrib, short *sv0,
1397+ short *sv1)
16421398 {
16431399 struct hpi_message hm;
16441400 struct hpi_response hr;
16451401 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
16461402 HPI_CONTROL_GET_STATE);
1647− u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
1403+ if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1404+ return HPI_ERROR_INVALID_HANDLE;
16481405 hm.u.c.attribute = attrib;
16491406
16501407 hpi_send_recv(&hm, &hr);
@@ -1655,8 +1412,7 @@ static u16 hpi_control_log_get2(const struct hpi_hsubsys *ph_subsys, · 4 unmodified lines
16551412 }
16561413
16571414 static
1658−u16 hpi_control_query(const struct hpi_hsubsys *ph_subsys,
1659− const u32 h_control, const u16 attrib, const u32 index,
1415+u16 hpi_control_query(const u32 h_control, const u16 attrib, const u32 index,
16601416 const u32 param, u32 *psetting)
16611417 {
16621418 struct hpi_message hm;
@@ -1664,7 +1420,8 @@ u16 hpi_control_query(const struct hpi_hsubsys *ph_subsys, · 1 unmodified line
16641420
16651421 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
16661422 HPI_CONTROL_GET_INFO);
1667− u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
1423+ if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1424+ return HPI_ERROR_INVALID_HANDLE;
16681425
16691426 hm.u.c.attribute = attrib;
16701427 hm.u.c.param1 = index;
@@ -1682,7 +1439,7 @@ static u16 hpi_control_get_string(const u32 h_control, const u16 attribute, · 11 unmodified lines
16821439 unsigned int sub_string_index = 0, j = 0;
16831440 char c = 0;
16841441 unsigned int n = 0;
1685− u16 hE = 0;
1442+ u16 err = 0;
16861443
16871444 if ((string_length < 1) || (string_length > 256))
16881445 return HPI_ERROR_INVALID_CONTROL_VALUE;
@@ -1693,7 +1450,9 @@ static u16 hpi_control_get_string(const u32 h_control, const u16 attribute, · 4 unmodified lines
16931450
16941451 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
16951452 HPI_CONTROL_GET_STATE);
1696− u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
1453+ if (hpi_handle_indexes(h_control, &hm.adapter_index,
1454+ &hm.obj_index))
1455+ return HPI_ERROR_INVALID_HANDLE;
16971456 hm.u.c.attribute = attribute;
16981457 hm.u.c.param1 = sub_string_index;
16991458 hm.u.c.param2 = 0;
@@ -1705,7 +1464,7 @@ static u16 hpi_control_get_string(const u32 h_control, const u16 attribute, · 5 unmodified lines
17051464 return HPI_ERROR_INVALID_CONTROL_VALUE;
17061465
17071466 if (hr.error) {
1708− hE = hr.error;
1467+ err = hr.error;
17091468 break;
17101469 }
17111470 for (j = 0; j < 8; j++) {
@@ -1714,7 +1473,7 @@ static u16 hpi_control_get_string(const u32 h_control, const u16 attribute, · 2 unmodified lines
17141473 n++;
17151474 if (n >= string_length) {
17161475 psz_string[string_length - 1] = 0;
1717− hE = HPI_ERROR_INVALID_CONTROL_VALUE;
1476+ err = HPI_ERROR_INVALID_CONTROL_VALUE;
17181477 break;
17191478 }
17201479 if (c == 0)
@@ -1730,57 +1489,52 @@ static u16 hpi_control_get_string(const u32 h_control, const u16 attribute, · 9 unmodified lines
17301489 if (c == 0)
17311490 break;
17321491 }
1733− return hE;
1492+ return err;
17341493 }
17351494
1736−u16 HPI_AESEBU__receiver_query_format(const struct hpi_hsubsys *ph_subsys,
1737− const u32 h_aes_rx, const u32 index, u16 *pw_format)
1495+u16 hpi_aesebu_receiver_query_format(const u32 h_aes_rx, const u32 index,
1496+ u16 *pw_format)
17381497 {
17391498 u32 qr;
17401499 u16 err;
17411500
1742− err = hpi_control_query(ph_subsys, h_aes_rx, HPI_AESEBURX_FORMAT,
1743− index, 0, &qr);
1501+ err = hpi_control_query(h_aes_rx, HPI_AESEBURX_FORMAT, index, 0, &qr);
17441502 *pw_format = (u16)qr;
17451503 return err;
17461504 }
17471505
1748−u16 HPI_AESEBU__receiver_set_format(const struct hpi_hsubsys *ph_subsys,
1749− u32 h_control, u16 format)
1506+u16 hpi_aesebu_receiver_set_format(u32 h_control, u16 format)
17501507 {
1751− return hpi_control_param_set(ph_subsys, h_control,
1752− HPI_AESEBURX_FORMAT, format, 0);
1508+ return hpi_control_param_set(h_control, HPI_AESEBURX_FORMAT, format,
1509+ 0);
17531510 }
17541511
1755−u16 HPI_AESEBU__receiver_get_format(const struct hpi_hsubsys *ph_subsys,
1756− u32 h_control, u16 *pw_format)
1512+u16 hpi_aesebu_receiver_get_format(u32 h_control, u16 *pw_format)
17571513 {
17581514 u16 err;
17591515 u32 param;
17601516
1761− err = hpi_control_param1_get(ph_subsys, h_control,
1762− HPI_AESEBURX_FORMAT, &param);
1517+ err = hpi_control_param1_get(h_control, HPI_AESEBURX_FORMAT, &param);
17631518 if (!err && pw_format)
17641519 *pw_format = (u16)param;
17651520
17661521 return err;
17671522 }
17681523
1769−u16 HPI_AESEBU__receiver_get_sample_rate(const struct hpi_hsubsys *ph_subsys,
1770− u32 h_control, u32 *psample_rate)
1524+u16 hpi_aesebu_receiver_get_sample_rate(u32 h_control, u32 *psample_rate)
17711525 {
1772− return hpi_control_param1_get(ph_subsys, h_control,
1773− HPI_AESEBURX_SAMPLERATE, psample_rate);
1526+ return hpi_control_param1_get(h_control, HPI_AESEBURX_SAMPLERATE,
1527+ psample_rate);
17741528 }
17751529
1776−u16 HPI_AESEBU__receiver_get_user_data(const struct hpi_hsubsys *ph_subsys,
1777− u32 h_control, u16 index, u16 *pw_data)
1530+u16 hpi_aesebu_receiver_get_user_data(u32 h_control, u16 index, u16 *pw_data)
17781531 {
17791532 struct hpi_message hm;
17801533 struct hpi_response hr;
17811534 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
17821535 HPI_CONTROL_GET_STATE);
1783− u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
1536+ if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1537+ return HPI_ERROR_INVALID_HANDLE;
17841538 hm.u.c.attribute = HPI_AESEBURX_USERDATA;
17851539 hm.u.c.param1 = index;
17861540
@@ -1791,14 +1545,15 @@ u16 HPI_AESEBU__receiver_get_user_data(const struct hpi_hsubsys *ph_subsys, · 4 unmodified lines
17911545 return hr.error;
17921546 }
17931547
1794−u16 HPI_AESEBU__receiver_get_channel_status(const struct hpi_hsubsys
1795− *ph_subsys, u32 h_control, u16 index, u16 *pw_data)
1548+u16 hpi_aesebu_receiver_get_channel_status(u32 h_control, u16 index,
1549+ u16 *pw_data)
17961550 {
17971551 struct hpi_message hm;
17981552 struct hpi_response hr;
17991553 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
18001554 HPI_CONTROL_GET_STATE);
1801− u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
1555+ if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1556+ return HPI_ERROR_INVALID_HANDLE;
18021557 hm.u.c.attribute = HPI_AESEBURX_CHANNELSTATUS;
18031558 hm.u.c.param1 = index;
18041559
@@ -1809,101 +1564,93 @@ u16 HPI_AESEBU__receiver_get_channel_status(const struct hpi_hsubsys · 4 unmodified lines
18091564 return hr.error;
18101565 }
18111566
1812−u16 HPI_AESEBU__receiver_get_error_status(const struct hpi_hsubsys *ph_subsys,
1813− u32 h_control, u16 *pw_error_data)
1567+u16 hpi_aesebu_receiver_get_error_status(u32 h_control, u16 *pw_error_data)
18141568 {
18151569 u32 error_data = 0;
1816− u16 error = 0;
1570+ u16 err = 0;
18171571
1818− error = hpi_control_param1_get(ph_subsys, h_control,
1819− HPI_AESEBURX_ERRORSTATUS, &error_data);
1572+ err = hpi_control_param1_get(h_control, HPI_AESEBURX_ERRORSTATUS,
1573+ &error_data);
18201574 if (pw_error_data)
18211575 *pw_error_data = (u16)error_data;
1822− return error;
1576+ return err;
18231577 }
18241578
1825−u16 HPI_AESEBU__transmitter_set_sample_rate(const struct hpi_hsubsys
1826− *ph_subsys, u32 h_control, u32 sample_rate)
1579+u16 hpi_aesebu_transmitter_set_sample_rate(u32 h_control, u32 sample_rate)
18271580 {
1828− return hpi_control_param_set(ph_subsys, h_control,
1829− HPI_AESEBUTX_SAMPLERATE, sample_rate, 0);
1581+ return hpi_control_param_set(h_control, HPI_AESEBUTX_SAMPLERATE,
1582+ sample_rate, 0);
18301583 }
18311584
1832−u16 HPI_AESEBU__transmitter_set_user_data(const struct hpi_hsubsys *ph_subsys,
1833− u32 h_control, u16 index, u16 data)
1585+u16 hpi_aesebu_transmitter_set_user_data(u32 h_control, u16 index, u16 data)
18341586 {
1835− return hpi_control_param_set(ph_subsys, h_control,
1836− HPI_AESEBUTX_USERDATA, index, data);
1587+ return hpi_control_param_set(h_control, HPI_AESEBUTX_USERDATA, index,
1588+ data);
18371589 }
18381590
1839−u16 HPI_AESEBU__transmitter_set_channel_status(const struct hpi_hsubsys
1840− *ph_subsys, u32 h_control, u16 index, u16 data)
1591+u16 hpi_aesebu_transmitter_set_channel_status(u32 h_control, u16 index,
1592+ u16 data)
18411593 {
1842− return hpi_control_param_set(ph_subsys, h_control,
1843− HPI_AESEBUTX_CHANNELSTATUS, index, data);
1594+ return hpi_control_param_set(h_control, HPI_AESEBUTX_CHANNELSTATUS,
1595+ index, data);
18441596 }
18451597
1846−u16 HPI_AESEBU__transmitter_get_channel_status(const struct hpi_hsubsys
1847− *ph_subsys, u32 h_control, u16 index, u16 *pw_data)
1598+u16 hpi_aesebu_transmitter_get_channel_status(u32 h_control, u16 index,
1599+ u16 *pw_data)
18481600 {
18491601 return HPI_ERROR_INVALID_OPERATION;
18501602 }
18511603
1852−u16 HPI_AESEBU__transmitter_query_format(const struct hpi_hsubsys *ph_subsys,
1853− const u32 h_aes_tx, const u32 index, u16 *pw_format)
1604+u16 hpi_aesebu_transmitter_query_format(const u32 h_aes_tx, const u32 index,
1605+ u16 *pw_format)
18541606 {
18551607 u32 qr;
18561608 u16 err;
18571609
1858− err = hpi_control_query(ph_subsys, h_aes_tx, HPI_AESEBUTX_FORMAT,
1859− index, 0, &qr);
1610+ err = hpi_control_query(h_aes_tx, HPI_AESEBUTX_FORMAT, index, 0, &qr);
18601611 *pw_format = (u16)qr;
18611612 return err;
18621613 }
18631614
1864−u16 HPI_AESEBU__transmitter_set_format(const struct hpi_hsubsys *ph_subsys,
1865− u32 h_control, u16 output_format)
1615+u16 hpi_aesebu_transmitter_set_format(u32 h_control, u16 output_format)
18661616 {
1867− return hpi_control_param_set(ph_subsys, h_control,
1868− HPI_AESEBUTX_FORMAT, output_format, 0);
1617+ return hpi_control_param_set(h_control, HPI_AESEBUTX_FORMAT,
1618+ output_format, 0);
18691619 }
18701620
1871−u16 HPI_AESEBU__transmitter_get_format(const struct hpi_hsubsys *ph_subsys,
1872− u32 h_control, u16 *pw_output_format)
1621+u16 hpi_aesebu_transmitter_get_format(u32 h_control, u16 *pw_output_format)
18731622 {
18741623 u16 err;
18751624 u32 param;
18761625
1877− err = hpi_control_param1_get(ph_subsys, h_control,
1878− HPI_AESEBUTX_FORMAT, &param);
1626+ err = hpi_control_param1_get(h_control, HPI_AESEBUTX_FORMAT, &param);
18791627 if (!err && pw_output_format)
18801628 *pw_output_format = (u16)param;
18811629
18821630 return err;
18831631 }
18841632
1885−u16 hpi_bitstream_set_clock_edge(const struct hpi_hsubsys *ph_subsys,
1886− u32 h_control, u16 edge_type)
1633+u16 hpi_bitstream_set_clock_edge(u32 h_control, u16 edge_type)
18871634 {
1888− return hpi_control_param_set(ph_subsys, h_control,
1889− HPI_BITSTREAM_CLOCK_EDGE, edge_type, 0);
1635+ return hpi_control_param_set(h_control, HPI_BITSTREAM_CLOCK_EDGE,
1636+ edge_type, 0);
18901637 }
18911638
1892−u16 hpi_bitstream_set_data_polarity(const struct hpi_hsubsys *ph_subsys,
1893− u32 h_control, u16 polarity)
1639+u16 hpi_bitstream_set_data_polarity(u32 h_control, u16 polarity)
18941640 {
1895− return hpi_control_param_set(ph_subsys, h_control,
1896− HPI_BITSTREAM_DATA_POLARITY, polarity, 0);
1641+ return hpi_control_param_set(h_control, HPI_BITSTREAM_DATA_POLARITY,
1642+ polarity, 0);
18971643 }
18981644
1899−u16 hpi_bitstream_get_activity(const struct hpi_hsubsys *ph_subsys,
1900− u32 h_control, u16 *pw_clk_activity, u16 *pw_data_activity)
1645+u16 hpi_bitstream_get_activity(u32 h_control, u16 *pw_clk_activity,
1646+ u16 *pw_data_activity)
19011647 {
19021648 struct hpi_message hm;
19031649 struct hpi_response hr;
19041650 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
19051651 HPI_CONTROL_GET_STATE);
1906− u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
1652+ if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1653+ return HPI_ERROR_INVALID_HANDLE;
19071654 hm.u.c.attribute = HPI_BITSTREAM_ACTIVITY;
19081655 hpi_send_recv(&hm, &hr);
19091656 if (pw_clk_activity)
@@ -1913,45 +1660,43 @@ u16 hpi_bitstream_get_activity(const struct hpi_hsubsys *ph_subsys, · 3 unmodified lines
19131660 return hr.error;
19141661 }
19151662
1916−u16 hpi_channel_mode_query_mode(const struct hpi_hsubsys *ph_subsys,
1917− const u32 h_mode, const u32 index, u16 *pw_mode)
1663+u16 hpi_channel_mode_query_mode(const u32 h_mode, const u32 index,
1664+ u16 *pw_mode)
19181665 {
19191666 u32 qr;
19201667 u16 err;
19211668
1922− err = hpi_control_query(ph_subsys, h_mode, HPI_CHANNEL_MODE_MODE,
1923− index, 0, &qr);
1669+ err = hpi_control_query(h_mode, HPI_CHANNEL_MODE_MODE, index, 0, &qr);
19241670 *pw_mode = (u16)qr;
19251671 return err;
19261672 }
19271673
1928−u16 hpi_channel_mode_set(const struct hpi_hsubsys *ph_subsys, u32 h_control,
1929− u16 mode)
1674+u16 hpi_channel_mode_set(u32 h_control, u16 mode)
19301675 {
1931− return hpi_control_param_set(ph_subsys, h_control,
1932− HPI_CHANNEL_MODE_MODE, mode, 0);
1676+ return hpi_control_param_set(h_control, HPI_CHANNEL_MODE_MODE, mode,
1677+ 0);
19331678 }
19341679
1935−u16 hpi_channel_mode_get(const struct hpi_hsubsys *ph_subsys, u32 h_control,
1936− u16 *mode)
1680+u16 hpi_channel_mode_get(u32 h_control, u16 *mode)
19371681 {
19381682 u32 mode32 = 0;
1939− u16 error = hpi_control_param1_get(ph_subsys, h_control,
1683+ u16 err = hpi_control_param1_get(h_control,
19401684 HPI_CHANNEL_MODE_MODE, &mode32);
19411685 if (mode)
19421686 *mode = (u16)mode32;
1943− return error;
1687+ return err;
19441688 }
19451689
1946−u16 hpi_cobranet_hmi_write(const struct hpi_hsubsys *ph_subsys, u32 h_control,
1947− u32 hmi_address, u32 byte_count, u8 *pb_data)
1690+u16 hpi_cobranet_hmi_write(u32 h_control, u32 hmi_address, u32 byte_count,
1691+ u8 *pb_data)
19481692 {
19491693 struct hpi_message hm;
19501694 struct hpi_response hr;
19511695
19521696 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROLEX,
19531697 HPI_CONTROL_SET_STATE);
1954− u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
1698+ if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1699+ return HPI_ERROR_INVALID_HANDLE;
19551700
19561701 hm.u.cx.u.cobranet_data.byte_count = byte_count;
19571702 hm.u.cx.u.cobranet_data.hmi_address = hmi_address;
@@ -1969,15 +1714,16 @@ u16 hpi_cobranet_hmi_write(const struct hpi_hsubsys *ph_subsys, u32 h_control, · 11 unmodified lines
19691714 return hr.error;
19701715 }
19711716
1972−u16 hpi_cobranet_hmi_read(const struct hpi_hsubsys *ph_subsys, u32 h_control,
1973− u32 hmi_address, u32 max_byte_count, u32 *pbyte_count, u8 *pb_data)
1717+u16 hpi_cobranet_hmi_read(u32 h_control, u32 hmi_address, u32 max_byte_count,
1718+ u32 *pbyte_count, u8 *pb_data)
19741719 {
19751720 struct hpi_message hm;
19761721 struct hpi_response hr;
19771722
19781723 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROLEX,
19791724 HPI_CONTROL_GET_STATE);
1980− u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
1725+ if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1726+ return HPI_ERROR_INVALID_HANDLE;
19811727
19821728 hm.u.cx.u.cobranet_data.byte_count = max_byte_count;
19831729 hm.u.cx.u.cobranet_data.hmi_address = hmi_address;
@@ -2008,16 +1754,16 @@ u16 hpi_cobranet_hmi_read(const struct hpi_hsubsys *ph_subsys, u32 h_control, · 24 unmodified lines
20081754 return hr.error;
20091755 }
20101756
2011−u16 hpi_cobranet_hmi_get_status(const struct hpi_hsubsys *ph_subsys,
2012− u32 h_control, u32 *pstatus, u32 *preadable_size,
2013− u32 *pwriteable_size)
1757+u16 hpi_cobranet_hmi_get_status(u32 h_control, u32 *pstatus,
1758+ u32 *preadable_size, u32 *pwriteable_size)
20141759 {
20151760 struct hpi_message hm;
20161761 struct hpi_response hr;
20171762
20181763 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROLEX,
20191764 HPI_CONTROL_GET_STATE);
2020− u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
1765+ if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1766+ return HPI_ERROR_INVALID_HANDLE;
20211767
20221768 hm.u.cx.attribute = HPI_COBRANET_GET_STATUS;
20231769
@@ -2035,177 +1781,176 @@ u16 hpi_cobranet_hmi_get_status(const struct hpi_hsubsys *ph_subsys, · 11 unmodified lines
20351781 return hr.error;
20361782 }
20371783
2038−u16 hpi_cobranet_getI_paddress(const struct hpi_hsubsys *ph_subsys,
2039− u32 h_control, u32 *pi_paddress)
1784+u16 hpi_cobranet_get_ip_address(u32 h_control, u32 *pdw_ip_address)
20401785 {
20411786 u32 byte_count;
20421787 u32 iP;
2043− u16 error;
1788+ u16 err;
20441789
2045− error = hpi_cobranet_hmi_read(ph_subsys, h_control,
1790+ err = hpi_cobranet_hmi_read(h_control,
20461791 HPI_COBRANET_HMI_cobra_ip_mon_currentIP, 4, &byte_count,
20471792 (u8 *)&iP);
20481793
2049− *pi_paddress =
1794+ *pdw_ip_address =
20501795 ((iP & 0xff000000) >> 8) | ((iP & 0x00ff0000) << 8) | ((iP &
20511796 0x0000ff00) >> 8) | ((iP & 0x000000ff) << 8);
20521797
2053− if (error)
2054− *pi_paddress = 0;
1798+ if (err)
1799+ *pdw_ip_address = 0;
20551800
2056− return error;
1801+ return err;
20571802
20581803 }
20591804
2060−u16 hpi_cobranet_setI_paddress(const struct hpi_hsubsys *ph_subsys,
2061− u32 h_control, u32 i_paddress)
1805+u16 hpi_cobranet_set_ip_address(u32 h_control, u32 dw_ip_address)
20621806 {
20631807 u32 iP;
2064− u16 error;
1808+ u16 err;
20651809
2066− iP = ((i_paddress & 0xff000000) >> 8) | ((i_paddress & 0x00ff0000) <<
2067− 8) | ((i_paddress & 0x0000ff00) >> 8) | ((i_paddress &
2068− 0x000000ff) << 8);
1810+ iP = ((dw_ip_address & 0xff000000) >> 8) | ((dw_ip_address &
1811+ 0x00ff0000) << 8) | ((dw_ip_address & 0x0000ff00) >>
1812+ 8) | ((dw_ip_address & 0x000000ff) << 8);
20691813
2070− error = hpi_cobranet_hmi_write(ph_subsys, h_control,
1814+ err = hpi_cobranet_hmi_write(h_control,
20711815 HPI_COBRANET_HMI_cobra_ip_mon_currentIP, 4, (u8 *)&iP);
20721816
2073− return error;
1817+ return err;
20741818
20751819 }
20761820
2077−u16 hpi_cobranet_get_staticI_paddress(const struct hpi_hsubsys *ph_subsys,
2078− u32 h_control, u32 *pi_paddress)
1821+u16 hpi_cobranet_get_static_ip_address(u32 h_control, u32 *pdw_ip_address)
20791822 {
20801823 u32 byte_count;
20811824 u32 iP;
2082− u16 error;
2083− error = hpi_cobranet_hmi_read(ph_subsys, h_control,
1825+ u16 err;
1826+ err = hpi_cobranet_hmi_read(h_control,
20841827 HPI_COBRANET_HMI_cobra_ip_mon_staticIP, 4, &byte_count,
20851828 (u8 *)&iP);
20861829
2087− *pi_paddress =
1830+ *pdw_ip_address =
20881831 ((iP & 0xff000000) >> 8) | ((iP & 0x00ff0000) << 8) | ((iP &
20891832 0x0000ff00) >> 8) | ((iP & 0x000000ff) << 8);
20901833
2091− if (error)
2092− *pi_paddress = 0;
1834+ if (err)
1835+ *pdw_ip_address = 0;
20931836
2094− return error;
1837+ return err;
20951838
20961839 }
20971840
2098−u16 hpi_cobranet_set_staticI_paddress(const struct hpi_hsubsys *ph_subsys,
2099− u32 h_control, u32 i_paddress)
1841+u16 hpi_cobranet_set_static_ip_address(u32 h_control, u32 dw_ip_address)
21001842 {
21011843 u32 iP;
2102− u16 error;
1844+ u16 err;
21031845
2104− iP = ((i_paddress & 0xff000000) >> 8) | ((i_paddress & 0x00ff0000) <<
2105− 8) | ((i_paddress & 0x0000ff00) >> 8) | ((i_paddress &
2106− 0x000000ff) << 8);
1846+ iP = ((dw_ip_address & 0xff000000) >> 8) | ((dw_ip_address &
1847+ 0x00ff0000) << 8) | ((dw_ip_address & 0x0000ff00) >>
1848+ 8) | ((dw_ip_address & 0x000000ff) << 8);
21071849
2108− error = hpi_cobranet_hmi_write(ph_subsys, h_control,
1850+ err = hpi_cobranet_hmi_write(h_control,
21091851 HPI_COBRANET_HMI_cobra_ip_mon_staticIP, 4, (u8 *)&iP);
21101852
2111− return error;
1853+ return err;
21121854
21131855 }
21141856
2115−u16 hpi_cobranet_getMA_caddress(const struct hpi_hsubsys *ph_subsys,
2116− u32 h_control, u32 *pmAC_MS_bs, u32 *pmAC_LS_bs)
1857+u16 hpi_cobranet_get_macaddress(u32 h_control, u32 *p_mac_msbs,
1858+ u32 *p_mac_lsbs)
21171859 {
21181860 u32 byte_count;
2119− u16 error;
2120− u32 mAC;
1861+ u16 err;
1862+ u32 mac;
21211863
2122− error = hpi_cobranet_hmi_read(ph_subsys, h_control,
1864+ err = hpi_cobranet_hmi_read(h_control,
21231865 HPI_COBRANET_HMI_cobra_if_phy_address, 4, &byte_count,
2124− (u8 *)&mAC);
2125− *pmAC_MS_bs =
2126− ((mAC & 0xff000000) >> 8) | ((mAC & 0x00ff0000) << 8) | ((mAC
2127− & 0x0000ff00) >> 8) | ((mAC & 0x000000ff) << 8);
2128− error += hpi_cobranet_hmi_read(ph_subsys, h_control,
2129− HPI_COBRANET_HMI_cobra_if_phy_address + 1, 4, &byte_count,
2130− (u8 *)&mAC);
2131− *pmAC_LS_bs =
2132− ((mAC & 0xff000000) >> 8) | ((mAC & 0x00ff0000) << 8) | ((mAC
2133− & 0x0000ff00) >> 8) | ((mAC & 0x000000ff) << 8);
2134−
2135− if (error) {
2136− *pmAC_MS_bs = 0;
2137− *pmAC_LS_bs = 0;
1866+ (u8 *)&mac);
1867+
1868+ if (!err) {
1869+ *p_mac_msbs =
1870+ ((mac & 0xff000000) >> 8) | ((mac & 0x00ff0000) << 8)
1871+ | ((mac & 0x0000ff00) >> 8) | ((mac & 0x000000ff) <<
1872+ 8);
1873+
1874+ err = hpi_cobranet_hmi_read(h_control,
1875+ HPI_COBRANET_HMI_cobra_if_phy_address + 1, 4,
1876+ &byte_count, (u8 *)&mac);
21381877 }
21391878
2140− return error;
1879+ if (!err) {
1880+ *p_mac_lsbs =
1881+ ((mac & 0xff000000) >> 8) | ((mac & 0x00ff0000) << 8)
1882+ | ((mac & 0x0000ff00) >> 8) | ((mac & 0x000000ff) <<
1883+ 8);
1884+ } else {
1885+ *p_mac_msbs = 0;
1886+ *p_mac_lsbs = 0;
1887+ }
1888+
1889+ return err;
21411890 }
21421891
2143−u16 hpi_compander_set_enable(const struct hpi_hsubsys *ph_subsys,
2144− u32 h_control, u32 enable)
1892+u16 hpi_compander_set_enable(u32 h_control, u32 enable)
21451893 {
2146− return hpi_control_param_set(ph_subsys, h_control, HPI_GENERIC_ENABLE,
2147− enable, 0);
1894+ return hpi_control_param_set(h_control, HPI_GENERIC_ENABLE, enable,
1895+ 0);
21481896 }
21491897
2150−u16 hpi_compander_get_enable(const struct hpi_hsubsys *ph_subsys,
2151− u32 h_control, u32 *enable)
1898+u16 hpi_compander_get_enable(u32 h_control, u32 *enable)
21521899 {
2153− return hpi_control_param1_get(ph_subsys, h_control,
2154− HPI_GENERIC_ENABLE, enable);
1900+ return hpi_control_param1_get(h_control, HPI_GENERIC_ENABLE, enable);
21551901 }
21561902
2157−u16 hpi_compander_set_makeup_gain(const struct hpi_hsubsys *ph_subsys,
2158− u32 h_control, short makeup_gain0_01dB)
1903+u16 hpi_compander_set_makeup_gain(u32 h_control, short makeup_gain0_01dB)
21591904 {
21601905 return hpi_control_log_set2(h_control, HPI_COMPANDER_MAKEUPGAIN,
21611906 makeup_gain0_01dB, 0);
21621907 }
21631908
2164−u16 hpi_compander_get_makeup_gain(const struct hpi_hsubsys *ph_subsys,
2165− u32 h_control, short *makeup_gain0_01dB)
1909+u16 hpi_compander_get_makeup_gain(u32 h_control, short *makeup_gain0_01dB)
21661910 {
2167− return hpi_control_log_get2(ph_subsys, h_control,
2168− HPI_COMPANDER_MAKEUPGAIN, makeup_gain0_01dB, NULL);
1911+ return hpi_control_log_get2(h_control, HPI_COMPANDER_MAKEUPGAIN,
1912+ makeup_gain0_01dB, NULL);
21691913 }
21701914
2171−u16 hpi_compander_set_attack_time_constant(const struct hpi_hsubsys
2172− *ph_subsys, u32 h_control, unsigned int index, u32 attack)
1915+u16 hpi_compander_set_attack_time_constant(u32 h_control, unsigned int index,
1916+ u32 attack)
21731917 {
2174− return hpi_control_param_set(ph_subsys, h_control,
2175− HPI_COMPANDER_ATTACK, attack, index);
1918+ return hpi_control_param_set(h_control, HPI_COMPANDER_ATTACK, attack,
1919+ index);
21761920 }
21771921
2178−u16 hpi_compander_get_attack_time_constant(const struct hpi_hsubsys
2179− *ph_subsys, u32 h_control, unsigned int index, u32 *attack)
1922+u16 hpi_compander_get_attack_time_constant(u32 h_control, unsigned int index,
1923+ u32 *attack)
21801924 {
2181− return hpi_control_param_get(ph_subsys, h_control,
2182− HPI_COMPANDER_ATTACK, 0, index, attack, NULL);
1925+ return hpi_control_param_get(h_control, HPI_COMPANDER_ATTACK, 0,
1926+ index, attack, NULL);
21831927 }
21841928
2185−u16 hpi_compander_set_decay_time_constant(const struct hpi_hsubsys *ph_subsys,
2186− u32 h_control, unsigned int index, u32 decay)
1929+u16 hpi_compander_set_decay_time_constant(u32 h_control, unsigned int index,
1930+ u32 decay)
21871931 {
2188− return hpi_control_param_set(ph_subsys, h_control,
2189− HPI_COMPANDER_DECAY, decay, index);
1932+ return hpi_control_param_set(h_control, HPI_COMPANDER_DECAY, decay,
1933+ index);
21901934 }
21911935
2192−u16 hpi_compander_get_decay_time_constant(const struct hpi_hsubsys *ph_subsys,
2193− u32 h_control, unsigned int index, u32 *decay)
1936+u16 hpi_compander_get_decay_time_constant(u32 h_control, unsigned int index,
1937+ u32 *decay)
21941938 {
2195− return hpi_control_param_get(ph_subsys, h_control,
2196− HPI_COMPANDER_DECAY, 0, index, decay, NULL);
1939+ return hpi_control_param_get(h_control, HPI_COMPANDER_DECAY, 0, index,
1940+ decay, NULL);
21971941
21981942 }
21991943
2200−u16 hpi_compander_set_threshold(const struct hpi_hsubsys *ph_subsys,
2201− u32 h_control, unsigned int index, short threshold0_01dB)
1944+u16 hpi_compander_set_threshold(u32 h_control, unsigned int index,
1945+ short threshold0_01dB)
22021946 {
22031947 struct hpi_message hm;
22041948 struct hpi_response hr;
22051949
22061950 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
22071951 HPI_CONTROL_SET_STATE);
2208− u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
1952+ if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1953+ return HPI_ERROR_INVALID_HANDLE;
22091954 hm.u.c.attribute = HPI_COMPANDER_THRESHOLD;
22101955 hm.u.c.param2 = index;
22111956 hm.u.c.an_log_value[0] = threshold0_01dB;
@@ -2215,15 +1960,16 @@ u16 hpi_compander_set_threshold(const struct hpi_hsubsys *ph_subsys, · 3 unmodified lines
22151960 return hr.error;
22161961 }
22171962
2218−u16 hpi_compander_get_threshold(const struct hpi_hsubsys *ph_subsys,
2219− u32 h_control, unsigned int index, short *threshold0_01dB)
1963+u16 hpi_compander_get_threshold(u32 h_control, unsigned int index,
1964+ short *threshold0_01dB)
22201965 {
22211966 struct hpi_message hm;
22221967 struct hpi_response hr;
22231968
22241969 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
22251970 HPI_CONTROL_GET_STATE);
2226− u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
1971+ if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1972+ return HPI_ERROR_INVALID_HANDLE;
22271973 hm.u.c.attribute = HPI_COMPANDER_THRESHOLD;
22281974 hm.u.c.param2 = index;
22291975
@@ -2233,29 +1979,28 @@ u16 hpi_compander_get_threshold(const struct hpi_hsubsys *ph_subsys, · 3 unmodified lines
22331979 return hr.error;
22341980 }
22351981
2236−u16 hpi_compander_set_ratio(const struct hpi_hsubsys *ph_subsys,
2237− u32 h_control, u32 index, u32 ratio100)
1982+u16 hpi_compander_set_ratio(u32 h_control, u32 index, u32 ratio100)
22381983 {
2239− return hpi_control_param_set(ph_subsys, h_control,
2240− HPI_COMPANDER_RATIO, ratio100, index);
1984+ return hpi_control_param_set(h_control, HPI_COMPANDER_RATIO, ratio100,
1985+ index);
22411986 }
22421987
2243−u16 hpi_compander_get_ratio(const struct hpi_hsubsys *ph_subsys,
2244− u32 h_control, u32 index, u32 *ratio100)
1988+u16 hpi_compander_get_ratio(u32 h_control, u32 index, u32 *ratio100)
22451989 {
2246− return hpi_control_param_get(ph_subsys, h_control,
2247− HPI_COMPANDER_RATIO, 0, index, ratio100, NULL);
1990+ return hpi_control_param_get(h_control, HPI_COMPANDER_RATIO, 0, index,
1991+ ratio100, NULL);
22481992 }
22491993
2250−u16 hpi_level_query_range(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2251− short *min_gain_01dB, short *max_gain_01dB, short *step_gain_01dB)
1994+u16 hpi_level_query_range(u32 h_control, short *min_gain_01dB,
1995+ short *max_gain_01dB, short *step_gain_01dB)
22521996 {
22531997 struct hpi_message hm;
22541998 struct hpi_response hr;
22551999
22562000 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
22572001 HPI_CONTROL_GET_STATE);
2258− u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
2002+ if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
2003+ return HPI_ERROR_INVALID_HANDLE;
22592004 hm.u.c.attribute = HPI_LEVEL_RANGE;
22602005
22612006 hpi_send_recv(&hm, &hr);
@@ -2273,31 +2018,27 @@ u16 hpi_level_query_range(const struct hpi_hsubsys *ph_subsys, u32 h_control, · 11 unmodified lines
22732018 return hr.error;
22742019 }
22752020
2276−u16 hpi_level_set_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2277− short an_gain0_01dB[HPI_MAX_CHANNELS]
2021+u16 hpi_level_set_gain(u32 h_control, short an_gain0_01dB[HPI_MAX_CHANNELS]
22782022 )
22792023 {
22802024 return hpi_control_log_set2(h_control, HPI_LEVEL_GAIN,
22812025 an_gain0_01dB[0], an_gain0_01dB[1]);
22822026 }
22832027
2284−u16 hpi_level_get_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2285− short an_gain0_01dB[HPI_MAX_CHANNELS]
2028+u16 hpi_level_get_gain(u32 h_control, short an_gain0_01dB[HPI_MAX_CHANNELS]
22862029 )
22872030 {
2288− return hpi_control_log_get2(ph_subsys, h_control, HPI_LEVEL_GAIN,
2031+ return hpi_control_log_get2(h_control, HPI_LEVEL_GAIN,
22892032 &an_gain0_01dB[0], &an_gain0_01dB[1]);
22902033 }
22912034
2292−u16 hpi_meter_query_channels(const struct hpi_hsubsys *ph_subsys,
2293− const u32 h_meter, u32 *p_channels)
2035+u16 hpi_meter_query_channels(const u32 h_meter, u32 *p_channels)
22942036 {
2295− return hpi_control_query(ph_subsys, h_meter, HPI_METER_NUM_CHANNELS,
2296− 0, 0, p_channels);
2037+ return hpi_control_query(h_meter, HPI_METER_NUM_CHANNELS, 0, 0,
2038+ p_channels);
22972039 }
22982040
2299−u16 hpi_meter_get_peak(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2300− short an_peakdB[HPI_MAX_CHANNELS]
2041+u16 hpi_meter_get_peak(u32 h_control, short an_peakdB[HPI_MAX_CHANNELS]
23012042 )
23022043 {
23032044 short i = 0;
@@ -2307,7 +2048,8 @@ u16 hpi_meter_get_peak(const struct hpi_hsubsys *ph_subsys, u32 h_control, · 3 unmodified lines
23072048
23082049 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
23092050 HPI_CONTROL_GET_STATE);
2310− u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
2051+ if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
2052+ return HPI_ERROR_INVALID_HANDLE;
23112053 hm.obj_index = hm.obj_index;
23122054 hm.u.c.attribute = HPI_METER_PEAK;
23132055
@@ -2322,8 +2064,7 @@ u16 hpi_meter_get_peak(const struct hpi_hsubsys *ph_subsys, u32 h_control, · 8 unmodified lines
23222064 return hr.error;
23232065 }
23242066
2325−u16 hpi_meter_get_rms(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2326− short an_rmsdB[HPI_MAX_CHANNELS]
2067+u16 hpi_meter_get_rms(u32 h_control, short an_rmsdB[HPI_MAX_CHANNELS]
23272068 )
23282069 {
23292070 short i = 0;
@@ -2333,7 +2074,8 @@ u16 hpi_meter_get_rms(const struct hpi_hsubsys *ph_subsys, u32 h_control, · 3 unmodified lines
23332074
23342075 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
23352076 HPI_CONTROL_GET_STATE);
2336− u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
2077+ if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
2078+ return HPI_ERROR_INVALID_HANDLE;
23372079 hm.u.c.attribute = HPI_METER_RMS;
23382080
23392081 hpi_send_recv(&hm, &hr);
@@ -2348,22 +2090,20 @@ u16 hpi_meter_get_rms(const struct hpi_hsubsys *ph_subsys, u32 h_control, · 8 unmodified lines
23482090 return hr.error;
23492091 }
23502092
2351−u16 hpi_meter_set_rms_ballistics(const struct hpi_hsubsys *ph_subsys,
2352− u32 h_control, u16 attack, u16 decay)
2093+u16 hpi_meter_set_rms_ballistics(u32 h_control, u16 attack, u16 decay)
23532094 {
2354− return hpi_control_param_set(ph_subsys, h_control,
2355− HPI_METER_RMS_BALLISTICS, attack, decay);
2095+ return hpi_control_param_set(h_control, HPI_METER_RMS_BALLISTICS,
2096+ attack, decay);
23562097 }
23572098
2358−u16 hpi_meter_get_rms_ballistics(const struct hpi_hsubsys *ph_subsys,
2359− u32 h_control, u16 *pn_attack, u16 *pn_decay)
2099+u16 hpi_meter_get_rms_ballistics(u32 h_control, u16 *pn_attack, u16 *pn_decay)
23602100 {
23612101 u32 attack;
23622102 u32 decay;
23632103 u16 error;
23642104
2365− error = hpi_control_param2_get(ph_subsys, h_control,
2366− HPI_METER_RMS_BALLISTICS, &attack, &decay);
2105+ error = hpi_control_param2_get(h_control, HPI_METER_RMS_BALLISTICS,
2106+ &attack, &decay);
23672107
23682108 if (pn_attack)
23692109 *pn_attack = (unsigned short)attack;
@@ -2373,22 +2113,21 @@ u16 hpi_meter_get_rms_ballistics(const struct hpi_hsubsys *ph_subsys, · 3 unmodified lines
23732113 return error;
23742114 }
23752115
2376−u16 hpi_meter_set_peak_ballistics(const struct hpi_hsubsys *ph_subsys,
2377− u32 h_control, u16 attack, u16 decay)
2116+u16 hpi_meter_set_peak_ballistics(u32 h_control, u16 attack, u16 decay)
23782117 {
2379− return hpi_control_param_set(ph_subsys, h_control,
2380− HPI_METER_PEAK_BALLISTICS, attack, decay);
2118+ return hpi_control_param_set(h_control, HPI_METER_PEAK_BALLISTICS,
2119+ attack, decay);
23812120 }
23822121
2383−u16 hpi_meter_get_peak_ballistics(const struct hpi_hsubsys *ph_subsys,
2384− u32 h_control, u16 *pn_attack, u16 *pn_decay)
2122+u16 hpi_meter_get_peak_ballistics(u32 h_control, u16 *pn_attack,
2123+ u16 *pn_decay)
23852124 {
23862125 u32 attack;
23872126 u32 decay;
23882127 u16 error;
23892128
2390− error = hpi_control_param2_get(ph_subsys, h_control,
2391− HPI_METER_PEAK_BALLISTICS, &attack, &decay);
2129+ error = hpi_control_param2_get(h_control, HPI_METER_PEAK_BALLISTICS,
2130+ &attack, &decay);
23922131
23932132 if (pn_attack)
23942133 *pn_attack = (short)attack;
@@ -2398,55 +2137,53 @@ u16 hpi_meter_get_peak_ballistics(const struct hpi_hsubsys *ph_subsys, · 3 unmodified lines
23982137 return error;
23992138 }
24002139
2401−u16 hpi_microphone_set_phantom_power(const struct hpi_hsubsys *ph_subsys,
2402− u32 h_control, u16 on_off)
2140+u16 hpi_microphone_set_phantom_power(u32 h_control, u16 on_off)
24032141 {
2404− return hpi_control_param_set(ph_subsys, h_control,
2405− HPI_MICROPHONE_PHANTOM_POWER, (u32)on_off, 0);
2142+ return hpi_control_param_set(h_control, HPI_MICROPHONE_PHANTOM_POWER,
2143+ (u32)on_off, 0);
24062144 }
24072145
2408−u16 hpi_microphone_get_phantom_power(const struct hpi_hsubsys *ph_subsys,
2409− u32 h_control, u16 *pw_on_off)
2146+u16 hpi_microphone_get_phantom_power(u32 h_control, u16 *pw_on_off)
24102147 {
24112148 u16 error = 0;
24122149 u32 on_off = 0;
2413− error = hpi_control_param1_get(ph_subsys, h_control,
2150+ error = hpi_control_param1_get(h_control,
24142151 HPI_MICROPHONE_PHANTOM_POWER, &on_off);
24152152 if (pw_on_off)
24162153 *pw_on_off = (u16)on_off;
24172154 return error;
24182155 }
24192156
2420−u16 hpi_multiplexer_set_source(const struct hpi_hsubsys *ph_subsys,
2421− u32 h_control, u16 source_node_type, u16 source_node_index)
2157+u16 hpi_multiplexer_set_source(u32 h_control, u16 source_node_type,
2158+ u16 source_node_index)
24222159 {
2423− return hpi_control_param_set(ph_subsys, h_control,
2424− HPI_MULTIPLEXER_SOURCE, source_node_type, source_node_index);
2160+ return hpi_control_param_set(h_control, HPI_MULTIPLEXER_SOURCE,
2161+ source_node_type, source_node_index);
24252162 }
24262163
2427−u16 hpi_multiplexer_get_source(const struct hpi_hsubsys *ph_subsys,
2428− u32 h_control, u16 *source_node_type, u16 *source_node_index)
2164+u16 hpi_multiplexer_get_source(u32 h_control, u16 *source_node_type,
2165+ u16 *source_node_index)
24292166 {
24302167 u32 node, index;
2431− u16 error = hpi_control_param2_get(ph_subsys, h_control,
2168+ u16 err = hpi_control_param2_get(h_control,
24322169 HPI_MULTIPLEXER_SOURCE, &node,
24332170 &index);
24342171 if (source_node_type)
24352172 *source_node_type = (u16)node;
24362173 if (source_node_index)
24372174 *source_node_index = (u16)index;
2438− return error;
2175+ return err;
24392176 }
24402177
2441−u16 hpi_multiplexer_query_source(const struct hpi_hsubsys *ph_subsys,
2442− u32 h_control, u16 index, u16 *source_node_type,
2443− u16 *source_node_index)
2178+u16 hpi_multiplexer_query_source(u32 h_control, u16 index,
2179+ u16 *source_node_type, u16 *source_node_index)
24442180 {
24452181 struct hpi_message hm;
24462182 struct hpi_response hr;
24472183 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
24482184 HPI_CONTROL_GET_STATE);
2449− u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
2185+ if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
2186+ return HPI_ERROR_INVALID_HANDLE;
24502187 hm.u.c.attribute = HPI_MULTIPLEXER_QUERYSOURCE;
24512188 hm.u.c.param1 = index;
24522189
@@ -2459,15 +2196,15 @@ u16 hpi_multiplexer_query_source(const struct hpi_hsubsys *ph_subsys, · 6 unmodified lines
24592196 return hr.error;
24602197 }
24612198
2462−u16 hpi_parametricEQ__get_info(const struct hpi_hsubsys *ph_subsys,
2463− u32 h_control, u16 *pw_number_of_bands, u16 *pw_on_off)
2199+u16 hpi_parametric_eq_get_info(u32 h_control, u16 *pw_number_of_bands,
2200+ u16 *pw_on_off)
24642201 {
24652202 u32 oB = 0;
24662203 u32 oO = 0;
24672204 u16 error = 0;
24682205
2469− error = hpi_control_param2_get(ph_subsys, h_control,
2470− HPI_EQUALIZER_NUM_FILTERS, &oO, &oB);
2206+ error = hpi_control_param2_get(h_control, HPI_EQUALIZER_NUM_FILTERS,
2207+ &oO, &oB);
24712208 if (pw_number_of_bands)
24722209 *pw_number_of_bands = (u16)oB;
24732210 if (pw_on_off)
@@ -2475,23 +2212,22 @@ u16 hpi_parametricEQ__get_info(const struct hpi_hsubsys *ph_subsys, · 1 unmodified line
24752212 return error;
24762213 }
24772214
2478−u16 hpi_parametricEQ__set_state(const struct hpi_hsubsys *ph_subsys,
2479− u32 h_control, u16 on_off)
2215+u16 hpi_parametric_eq_set_state(u32 h_control, u16 on_off)
24802216 {
2481− return hpi_control_param_set(ph_subsys, h_control,
2482− HPI_EQUALIZER_NUM_FILTERS, on_off, 0);
2217+ return hpi_control_param_set(h_control, HPI_EQUALIZER_NUM_FILTERS,
2218+ on_off, 0);
24832219 }
24842220
2485−u16 hpi_parametricEQ__get_band(const struct hpi_hsubsys *ph_subsys,
2486− u32 h_control, u16 index, u16 *pn_type, u32 *pfrequency_hz,
2487− short *pnQ100, short *pn_gain0_01dB)
2221+u16 hpi_parametric_eq_get_band(u32 h_control, u16 index, u16 *pn_type,
2222+ u32 *pfrequency_hz, short *pnQ100, short *pn_gain0_01dB)
24882223 {
24892224 struct hpi_message hm;
24902225 struct hpi_response hr;
24912226
24922227 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
24932228 HPI_CONTROL_GET_STATE);
2494− u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
2229+ if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
2230+ return HPI_ERROR_INVALID_HANDLE;
24952231 hm.u.c.attribute = HPI_EQUALIZER_FILTER;
24962232 hm.u.c.param2 = index;
24972233
@@ -2509,16 +2245,16 @@ u16 hpi_parametricEQ__get_band(const struct hpi_hsubsys *ph_subsys, · 11 unmodified lines
25092245 return hr.error;
25102246 }
25112247
2512−u16 hpi_parametricEQ__set_band(const struct hpi_hsubsys *ph_subsys,
2513− u32 h_control, u16 index, u16 type, u32 frequency_hz, short q100,
2514− short gain0_01dB)
2248+u16 hpi_parametric_eq_set_band(u32 h_control, u16 index, u16 type,
2249+ u32 frequency_hz, short q100, short gain0_01dB)
25152250 {
25162251 struct hpi_message hm;
25172252 struct hpi_response hr;
25182253
25192254 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
25202255 HPI_CONTROL_SET_STATE);
2521− u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
2256+ if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
2257+ return HPI_ERROR_INVALID_HANDLE;
25222258
25232259 hm.u.c.param1 = frequency_hz;
25242260 hm.u.c.param2 = (index & 0xFFFFL) + ((u32)type << 16);
@@ -2531,8 +2267,7 @@ u16 hpi_parametricEQ__set_band(const struct hpi_hsubsys *ph_subsys, · 6 unmodified lines
25312267 return hr.error;
25322268 }
25332269
2534−u16 hpi_parametricEQ__get_coeffs(const struct hpi_hsubsys *ph_subsys,
2535− u32 h_control, u16 index, short coeffs[5]
2270+u16 hpi_parametric_eq_get_coeffs(u32 h_control, u16 index, short coeffs[5]
25362271 )
25372272 {
25382273 struct hpi_message hm;
@@ -2540,7 +2275,8 @@ u16 hpi_parametricEQ__get_coeffs(const struct hpi_hsubsys *ph_subsys, · 1 unmodified line
25402275
25412276 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
25422277 HPI_CONTROL_GET_STATE);
2543− u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
2278+ if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
2279+ return HPI_ERROR_INVALID_HANDLE;
25442280 hm.u.c.attribute = HPI_EQUALIZER_COEFFICIENTS;
25452281 hm.u.c.param2 = index;
25462282
@@ -2555,444 +2291,388 @@ u16 hpi_parametricEQ__get_coeffs(const struct hpi_hsubsys *ph_subsys, · 8 unmodified lines
25552291 return hr.error;
25562292 }
25572293
2558−u16 hpi_sample_clock_query_source(const struct hpi_hsubsys *ph_subsys,
2559− const u32 h_clock, const u32 index, u16 *pw_source)
2294+u16 hpi_sample_clock_query_source(const u32 h_clock, const u32 index,
2295+ u16 *pw_source)
25602296 {
25612297 u32 qr;
25622298 u16 err;
25632299
2564− err = hpi_control_query(ph_subsys, h_clock, HPI_SAMPLECLOCK_SOURCE,
2565− index, 0, &qr);
2300+ err = hpi_control_query(h_clock, HPI_SAMPLECLOCK_SOURCE, index, 0,
2301+ &qr);
25662302 *pw_source = (u16)qr;
25672303 return err;
25682304 }
25692305
2570−u16 hpi_sample_clock_set_source(const struct hpi_hsubsys *ph_subsys,
2571− u32 h_control, u16 source)
2306+u16 hpi_sample_clock_set_source(u32 h_control, u16 source)
25722307 {
2573− return hpi_control_param_set(ph_subsys, h_control,
2574− HPI_SAMPLECLOCK_SOURCE, source, 0);
2308+ return hpi_control_param_set(h_control, HPI_SAMPLECLOCK_SOURCE,
2309+ source, 0);
25752310 }
25762311
2577−u16 hpi_sample_clock_get_source(const struct hpi_hsubsys *ph_subsys,
2578− u32 h_control, u16 *pw_source)
2312+u16 hpi_sample_clock_get_source(u32 h_control, u16 *pw_source)
25792313 {
2580− u16 error = 0;
2314+ u16 err = 0;
25812315 u32 source = 0;
2582− error = hpi_control_param1_get(ph_subsys, h_control,
2583− HPI_SAMPLECLOCK_SOURCE, &source);
2584− if (!error)
2316+ err = hpi_control_param1_get(h_control, HPI_SAMPLECLOCK_SOURCE,
2317+ &source);
2318+ if (!err)
25852319 if (pw_source)
25862320 *pw_source = (u16)source;
2587− return error;
2321+ return err;
25882322 }
25892323
2590−u16 hpi_sample_clock_query_source_index(const struct hpi_hsubsys *ph_subsys,
2591− const u32 h_clock, const u32 index, const u32 source,
2592− u16 *pw_source_index)
2324+u16 hpi_sample_clock_query_source_index(const u32 h_clock, const u32 index,
2325+ const u32 source, u16 *pw_source_index)
25932326 {
25942327 u32 qr;
25952328 u16 err;
25962329
2597− err = hpi_control_query(ph_subsys, h_clock,
2598− HPI_SAMPLECLOCK_SOURCE_INDEX, index, source, &qr);
2330+ err = hpi_control_query(h_clock, HPI_SAMPLECLOCK_SOURCE_INDEX, index,
2331+ source, &qr);
25992332 *pw_source_index = (u16)qr;
26002333 return err;
26012334 }
26022335
2603−u16 hpi_sample_clock_set_source_index(const struct hpi_hsubsys *ph_subsys,
2604− u32 h_control, u16 source_index)
2336+u16 hpi_sample_clock_set_source_index(u32 h_control, u16 source_index)
26052337 {
2606− return hpi_control_param_set(ph_subsys, h_control,
2607− HPI_SAMPLECLOCK_SOURCE_INDEX, source_index, 0);
2338+ return hpi_control_param_set(h_control, HPI_SAMPLECLOCK_SOURCE_INDEX,
2339+ source_index, 0);
26082340 }
26092341
2610−u16 hpi_sample_clock_get_source_index(const struct hpi_hsubsys *ph_subsys,
2611− u32 h_control, u16 *pw_source_index)
2342+u16 hpi_sample_clock_get_source_index(u32 h_control, u16 *pw_source_index)
26122343 {
2613− u16 error = 0;
2344+ u16 err = 0;
26142345 u32 source_index = 0;
2615− error = hpi_control_param1_get(ph_subsys, h_control,
2616− HPI_SAMPLECLOCK_SOURCE_INDEX, &source_index);
2617− if (!error)
2346+ err = hpi_control_param1_get(h_control, HPI_SAMPLECLOCK_SOURCE_INDEX,
2347+ &source_index);
2348+ if (!err)
26182349 if (pw_source_index)
26192350 *pw_source_index = (u16)source_index;
2620− return error;
2351+ return err;
26212352 }
26222353
2623−u16 hpi_sample_clock_query_local_rate(const struct hpi_hsubsys *ph_subsys,
2624− const u32 h_clock, const u32 index, u32 *prate)
2354+u16 hpi_sample_clock_query_local_rate(const u32 h_clock, const u32 index,
2355+ u32 *prate)
26252356 {
26262357 u16 err;
2627− err = hpi_control_query(ph_subsys, h_clock,
2628− HPI_SAMPLECLOCK_LOCAL_SAMPLERATE, index, 0, prate);
2358+ err = hpi_control_query(h_clock, HPI_SAMPLECLOCK_LOCAL_SAMPLERATE,
2359+ index, 0, prate);
26292360
26302361 return err;
26312362 }
26322363
2633−u16 hpi_sample_clock_set_local_rate(const struct hpi_hsubsys *ph_subsys,
2634− u32 h_control, u32 sample_rate)
2364+u16 hpi_sample_clock_set_local_rate(u32 h_control, u32 sample_rate)
26352365 {
2636− return hpi_control_param_set(ph_subsys, h_control,
2366+ return hpi_control_param_set(h_control,
26372367 HPI_SAMPLECLOCK_LOCAL_SAMPLERATE, sample_rate, 0);
26382368 }
26392369
2640−u16 hpi_sample_clock_get_local_rate(const struct hpi_hsubsys *ph_subsys,
2641− u32 h_control, u32 *psample_rate)
2370+u16 hpi_sample_clock_get_local_rate(u32 h_control, u32 *psample_rate)
26422371 {
2643− u16 error = 0;
2372+ u16 err = 0;
26442373 u32 sample_rate = 0;
2645− error = hpi_control_param1_get(ph_subsys, h_control,
2374+ err = hpi_control_param1_get(h_control,
26462375 HPI_SAMPLECLOCK_LOCAL_SAMPLERATE, &sample_rate);
2647− if (!error)
2376+ if (!err)
26482377 if (psample_rate)
26492378 *psample_rate = sample_rate;
2650− return error;
2379+ return err;
26512380 }
26522381
2653−u16 hpi_sample_clock_get_sample_rate(const struct hpi_hsubsys *ph_subsys,
2654− u32 h_control, u32 *psample_rate)
2382+u16 hpi_sample_clock_get_sample_rate(u32 h_control, u32 *psample_rate)
26552383 {
2656− u16 error = 0;
2384+ u16 err = 0;
26572385 u32 sample_rate = 0;
2658− error = hpi_control_param1_get(ph_subsys, h_control,
2659− HPI_SAMPLECLOCK_SAMPLERATE, &sample_rate);
2660− if (!error)
2386+ err = hpi_control_param1_get(h_control, HPI_SAMPLECLOCK_SAMPLERATE,
2387+ &sample_rate);
2388+ if (!err)
26612389 if (psample_rate)
26622390 *psample_rate = sample_rate;
2663− return error;
2391+ return err;
26642392 }
26652393
2666−u16 hpi_sample_clock_set_auto(const struct hpi_hsubsys *ph_subsys,
2667− u32 h_control, u32 enable)
2394+u16 hpi_sample_clock_set_auto(u32 h_control, u32 enable)
26682395 {
2669− return hpi_control_param_set(ph_subsys, h_control,
2670− HPI_SAMPLECLOCK_AUTO, enable, 0);
2396+ return hpi_control_param_set(h_control, HPI_SAMPLECLOCK_AUTO, enable,
2397+ 0);
26712398 }
26722399
2673−u16 hpi_sample_clock_get_auto(const struct hpi_hsubsys *ph_subsys,
2674− u32 h_control, u32 *penable)
2400+u16 hpi_sample_clock_get_auto(u32 h_control, u32 *penable)
26752401 {
2676− return hpi_control_param1_get(ph_subsys, h_control,
2677− HPI_SAMPLECLOCK_AUTO, penable);
2402+ return hpi_control_param1_get(h_control, HPI_SAMPLECLOCK_AUTO,
2403+ penable);
26782404 }
26792405
2680−u16 hpi_sample_clock_set_local_rate_lock(const struct hpi_hsubsys *ph_subsys,
2681− u32 h_control, u32 lock)
2406+u16 hpi_sample_clock_set_local_rate_lock(u32 h_control, u32 lock)
26822407 {
2683− return hpi_control_param_set(ph_subsys, h_control,
2684− HPI_SAMPLECLOCK_LOCAL_LOCK, lock, 0);
2408+ return hpi_control_param_set(h_control, HPI_SAMPLECLOCK_LOCAL_LOCK,
2409+ lock, 0);
26852410 }
26862411
2687−u16 hpi_sample_clock_get_local_rate_lock(const struct hpi_hsubsys *ph_subsys,
2688− u32 h_control, u32 *plock)
2412+u16 hpi_sample_clock_get_local_rate_lock(u32 h_control, u32 *plock)
26892413 {
2690− return hpi_control_param1_get(ph_subsys, h_control,
2691− HPI_SAMPLECLOCK_LOCAL_LOCK, plock);
2414+ return hpi_control_param1_get(h_control, HPI_SAMPLECLOCK_LOCAL_LOCK,
2415+ plock);
26922416 }
26932417
2694−u16 hpi_tone_detector_get_frequency(const struct hpi_hsubsys *ph_subsys,
2695− u32 h_control, u32 index, u32 *frequency)
2418+u16 hpi_tone_detector_get_frequency(u32 h_control, u32 index, u32 *frequency)
26962419 {
2697− return hpi_control_param_get(ph_subsys, h_control,
2698− HPI_TONEDETECTOR_FREQUENCY, index, 0, frequency, NULL);
2420+ return hpi_control_param_get(h_control, HPI_TONEDETECTOR_FREQUENCY,
2421+ index, 0, frequency, NULL);
26992422 }
27002423
2701−u16 hpi_tone_detector_get_state(const struct hpi_hsubsys *ph_subsys,
2702− u32 h_control, u32 *state)
2424+u16 hpi_tone_detector_get_state(u32 h_control, u32 *state)
27032425 {
2704− return hpi_control_param1_get(ph_subsys, h_control,
2705− HPI_TONEDETECTOR_STATE, state);
2426+ return hpi_control_param1_get(h_control, HPI_TONEDETECTOR_STATE,
2427+ state);
27062428 }
27072429
2708−u16 hpi_tone_detector_set_enable(const struct hpi_hsubsys *ph_subsys,
2709− u32 h_control, u32 enable)
2430+u16 hpi_tone_detector_set_enable(u32 h_control, u32 enable)
27102431 {
2711− return hpi_control_param_set(ph_subsys, h_control, HPI_GENERIC_ENABLE,
2712− (u32)enable, 0);
2432+ return hpi_control_param_set(h_control, HPI_GENERIC_ENABLE, enable,
2433+ 0);
27132434 }
27142435
2715−u16 hpi_tone_detector_get_enable(const struct hpi_hsubsys *ph_subsys,
2716− u32 h_control, u32 *enable)
2436+u16 hpi_tone_detector_get_enable(u32 h_control, u32 *enable)
27172437 {
2718− return hpi_control_param1_get(ph_subsys, h_control,
2719− HPI_GENERIC_ENABLE, enable);
2438+ return hpi_control_param1_get(h_control, HPI_GENERIC_ENABLE, enable);
27202439 }
27212440
2722−u16 hpi_tone_detector_set_event_enable(const struct hpi_hsubsys *ph_subsys,
2723− u32 h_control, u32 event_enable)
2441+u16 hpi_tone_detector_set_event_enable(u32 h_control, u32 event_enable)
27242442 {
2725− return hpi_control_param_set(ph_subsys, h_control,
2726− HPI_GENERIC_EVENT_ENABLE, (u32)event_enable, 0);
2443+ return hpi_control_param_set(h_control, HPI_GENERIC_EVENT_ENABLE,
2444+ (u32)event_enable, 0);
27272445 }
27282446
2729−u16 hpi_tone_detector_get_event_enable(const struct hpi_hsubsys *ph_subsys,
2730− u32 h_control, u32 *event_enable)
2447+u16 hpi_tone_detector_get_event_enable(u32 h_control, u32 *event_enable)
27312448 {
2732− return hpi_control_param1_get(ph_subsys, h_control,
2733− HPI_GENERIC_EVENT_ENABLE, event_enable);
2449+ return hpi_control_param1_get(h_control, HPI_GENERIC_EVENT_ENABLE,
2450+ event_enable);
27342451 }
27352452
2736−u16 hpi_tone_detector_set_threshold(const struct hpi_hsubsys *ph_subsys,
2737− u32 h_control, int threshold)
2453+u16 hpi_tone_detector_set_threshold(u32 h_control, int threshold)
27382454 {
2739− return hpi_control_param_set(ph_subsys, h_control,
2740− HPI_TONEDETECTOR_THRESHOLD, (u32)threshold, 0);
2455+ return hpi_control_param_set(h_control, HPI_TONEDETECTOR_THRESHOLD,
2456+ (u32)threshold, 0);
27412457 }
27422458
2743−u16 hpi_tone_detector_get_threshold(const struct hpi_hsubsys *ph_subsys,
2744− u32 h_control, int *threshold)
2459+u16 hpi_tone_detector_get_threshold(u32 h_control, int *threshold)
27452460 {
2746− return hpi_control_param1_get(ph_subsys, h_control,
2747− HPI_TONEDETECTOR_THRESHOLD, (u32 *)threshold);
2461+ return hpi_control_param1_get(h_control, HPI_TONEDETECTOR_THRESHOLD,
2462+ (u32 *)threshold);
27482463 }
27492464
2750−u16 hpi_silence_detector_get_state(const struct hpi_hsubsys *ph_subsys,
2751− u32 h_control, u32 *state)
2465+u16 hpi_silence_detector_get_state(u32 h_control, u32 *state)
27522466 {
2753− return hpi_control_param1_get(ph_subsys, h_control,
2754− HPI_SILENCEDETECTOR_STATE, state);
2467+ return hpi_control_param1_get(h_control, HPI_SILENCEDETECTOR_STATE,
2468+ state);
27552469 }
27562470
2757−u16 hpi_silence_detector_set_enable(const struct hpi_hsubsys *ph_subsys,
2758− u32 h_control, u32 enable)
2471+u16 hpi_silence_detector_set_enable(u32 h_control, u32 enable)
27592472 {
2760− return hpi_control_param_set(ph_subsys, h_control, HPI_GENERIC_ENABLE,
2761− (u32)enable, 0);
2473+ return hpi_control_param_set(h_control, HPI_GENERIC_ENABLE, enable,
2474+ 0);
27622475 }
27632476
2764−u16 hpi_silence_detector_get_enable(const struct hpi_hsubsys *ph_subsys,
2765− u32 h_control, u32 *enable)
2477+u16 hpi_silence_detector_get_enable(u32 h_control, u32 *enable)
27662478 {
2767− return hpi_control_param1_get(ph_subsys, h_control,
2768− HPI_GENERIC_ENABLE, enable);
2479+ return hpi_control_param1_get(h_control, HPI_GENERIC_ENABLE, enable);
27692480 }
27702481
2771−u16 hpi_silence_detector_set_event_enable(const struct hpi_hsubsys *ph_subsys,
2772− u32 h_control, u32 event_enable)
2482+u16 hpi_silence_detector_set_event_enable(u32 h_control, u32 event_enable)
27732483 {
2774− return hpi_control_param_set(ph_subsys, h_control,
2775− HPI_GENERIC_EVENT_ENABLE, event_enable, 0);
2484+ return hpi_control_param_set(h_control, HPI_GENERIC_EVENT_ENABLE,
2485+ event_enable, 0);
27762486 }
27772487
2778−u16 hpi_silence_detector_get_event_enable(const struct hpi_hsubsys *ph_subsys,
2779− u32 h_control, u32 *event_enable)
2488+u16 hpi_silence_detector_get_event_enable(u32 h_control, u32 *event_enable)
27802489 {
2781− return hpi_control_param1_get(ph_subsys, h_control,
2782− HPI_GENERIC_EVENT_ENABLE, event_enable);
2490+ return hpi_control_param1_get(h_control, HPI_GENERIC_EVENT_ENABLE,
2491+ event_enable);
27832492 }
27842493
2785−u16 hpi_silence_detector_set_delay(const struct hpi_hsubsys *ph_subsys,
2786− u32 h_control, u32 delay)
2494+u16 hpi_silence_detector_set_delay(u32 h_control, u32 delay)
27872495 {
2788− return hpi_control_param_set(ph_subsys, h_control,
2789− HPI_SILENCEDETECTOR_DELAY, delay, 0);
2496+ return hpi_control_param_set(h_control, HPI_SILENCEDETECTOR_DELAY,
2497+ delay, 0);
27902498 }
27912499
2792−u16 hpi_silence_detector_get_delay(const struct hpi_hsubsys *ph_subsys,
2793− u32 h_control, u32 *delay)
2500+u16 hpi_silence_detector_get_delay(u32 h_control, u32 *delay)
27942501 {
2795− return hpi_control_param1_get(ph_subsys, h_control,
2796− HPI_SILENCEDETECTOR_DELAY, delay);
2502+ return hpi_control_param1_get(h_control, HPI_SILENCEDETECTOR_DELAY,
2503+ delay);
27972504 }
27982505
2799−u16 hpi_silence_detector_set_threshold(const struct hpi_hsubsys *ph_subsys,
2800− u32 h_control, int threshold)
2506+u16 hpi_silence_detector_set_threshold(u32 h_control, int threshold)
28012507 {
2802− return hpi_control_param_set(ph_subsys, h_control,
2803− HPI_SILENCEDETECTOR_THRESHOLD, threshold, 0);
2508+ return hpi_control_param_set(h_control, HPI_SILENCEDETECTOR_THRESHOLD,
2509+ threshold, 0);
28042510 }
28052511
2806−u16 hpi_silence_detector_get_threshold(const struct hpi_hsubsys *ph_subsys,
2807− u32 h_control, int *threshold)
2512+u16 hpi_silence_detector_get_threshold(u32 h_control, int *threshold)
28082513 {
2809− return hpi_control_param1_get(ph_subsys, h_control,
2514+ return hpi_control_param1_get(h_control,
28102515 HPI_SILENCEDETECTOR_THRESHOLD, (u32 *)threshold);
28112516 }
28122517
2813−u16 hpi_tuner_query_band(const struct hpi_hsubsys *ph_subsys,
2814− const u32 h_tuner, const u32 index, u16 *pw_band)
2518+u16 hpi_tuner_query_band(const u32 h_tuner, const u32 index, u16 *pw_band)
28152519 {
28162520 u32 qr;
28172521 u16 err;
28182522
2819− err = hpi_control_query(ph_subsys, h_tuner, HPI_TUNER_BAND, index, 0,
2820− &qr);
2523+ err = hpi_control_query(h_tuner, HPI_TUNER_BAND, index, 0, &qr);
28212524 *pw_band = (u16)qr;
28222525 return err;
28232526 }
28242527
2825−u16 hpi_tuner_set_band(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2826− u16 band)
2528+u16 hpi_tuner_set_band(u32 h_control, u16 band)
28272529 {
2828− return hpi_control_param_set(ph_subsys, h_control, HPI_TUNER_BAND,
2829− band, 0);
2530+ return hpi_control_param_set(h_control, HPI_TUNER_BAND, band, 0);
28302531 }
28312532
2832−u16 hpi_tuner_get_band(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2833− u16 *pw_band)
2533+u16 hpi_tuner_get_band(u32 h_control, u16 *pw_band)
28342534 {
28352535 u32 band = 0;
28362536 u16 error = 0;
28372537
2838− error = hpi_control_param1_get(ph_subsys, h_control, HPI_TUNER_BAND,
2839− &band);
2538+ error = hpi_control_param1_get(h_control, HPI_TUNER_BAND, &band);
28402539 if (pw_band)
28412540 *pw_band = (u16)band;
28422541 return error;
28432542 }
28442543
2845−u16 hpi_tuner_query_frequency(const struct hpi_hsubsys *ph_subsys,
2846− const u32 h_tuner, const u32 index, const u16 band, u32 *pfreq)
2544+u16 hpi_tuner_query_frequency(const u32 h_tuner, const u32 index,
2545+ const u16 band, u32 *pfreq)
28472546 {
2848− return hpi_control_query(ph_subsys, h_tuner, HPI_TUNER_FREQ, index,
2849− band, pfreq);
2547+ return hpi_control_query(h_tuner, HPI_TUNER_FREQ, index, band, pfreq);
28502548 }
28512549
2852−u16 hpi_tuner_set_frequency(const struct hpi_hsubsys *ph_subsys,
2853− u32 h_control, u32 freq_ink_hz)
2550+u16 hpi_tuner_set_frequency(u32 h_control, u32 freq_ink_hz)
28542551 {
2855− return hpi_control_param_set(ph_subsys, h_control, HPI_TUNER_FREQ,
2856− freq_ink_hz, 0);
2552+ return hpi_control_param_set(h_control, HPI_TUNER_FREQ, freq_ink_hz,
2553+ 0);
28572554 }
28582555
2859−u16 hpi_tuner_get_frequency(const struct hpi_hsubsys *ph_subsys,
2860− u32 h_control, u32 *pw_freq_ink_hz)
2556+u16 hpi_tuner_get_frequency(u32 h_control, u32 *pw_freq_ink_hz)
28612557 {
2862− return hpi_control_param1_get(ph_subsys, h_control, HPI_TUNER_FREQ,
2558+ return hpi_control_param1_get(h_control, HPI_TUNER_FREQ,
28632559 pw_freq_ink_hz);
28642560 }
28652561
2866−u16 hpi_tuner_query_gain(const struct hpi_hsubsys *ph_subsys,
2867− const u32 h_tuner, const u32 index, u16 *pw_gain)
2562+u16 hpi_tuner_query_gain(const u32 h_tuner, const u32 index, u16 *pw_gain)
28682563 {
28692564 u32 qr;
28702565 u16 err;
28712566
2872− err = hpi_control_query(ph_subsys, h_tuner, HPI_TUNER_BAND, index, 0,
2873− &qr);
2567+ err = hpi_control_query(h_tuner, HPI_TUNER_BAND, index, 0, &qr);
28742568 *pw_gain = (u16)qr;
28752569 return err;
28762570 }
28772571
2878−u16 hpi_tuner_set_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2879− short gain)
2572+u16 hpi_tuner_set_gain(u32 h_control, short gain)
28802573 {
2881− return hpi_control_param_set(ph_subsys, h_control, HPI_TUNER_GAIN,
2882− gain, 0);
2574+ return hpi_control_param_set(h_control, HPI_TUNER_GAIN, gain, 0);
28832575 }
28842576
2885−u16 hpi_tuner_get_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2886− short *pn_gain)
2577+u16 hpi_tuner_get_gain(u32 h_control, short *pn_gain)
28872578 {
28882579 u32 gain = 0;
28892580 u16 error = 0;
28902581
2891− error = hpi_control_param1_get(ph_subsys, h_control, HPI_TUNER_GAIN,
2892− &gain);
2582+ error = hpi_control_param1_get(h_control, HPI_TUNER_GAIN, &gain);
28932583 if (pn_gain)
28942584 *pn_gain = (u16)gain;
28952585 return error;
28962586 }
28972587
2898−u16 hpi_tuner_getRF_level(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2899− short *pw_level)
2588+u16 hpi_tuner_get_rf_level(u32 h_control, short *pw_level)
29002589 {
29012590 struct hpi_message hm;
29022591 struct hpi_response hr;
29032592
29042593 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
29052594 HPI_CONTROL_GET_STATE);
2906− u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
2907− hm.u.c.attribute = HPI_TUNER_LEVEL;
2908− hm.u.c.param1 = HPI_TUNER_LEVEL_AVERAGE;
2595+ if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
2596+ return HPI_ERROR_INVALID_HANDLE;
2597+ hm.u.cu.attribute = HPI_TUNER_LEVEL_AVG;
29092598 hpi_send_recv(&hm, &hr);
29102599 if (pw_level)
2911− *pw_level = (short)hr.u.c.param1;
2600+ *pw_level = hr.u.cu.tuner.s_level;
29122601 return hr.error;
29132602 }
29142603
2915−u16 hpi_tuner_get_rawRF_level(const struct hpi_hsubsys *ph_subsys,
2916− u32 h_control, short *pw_level)
2604+u16 hpi_tuner_get_raw_rf_level(u32 h_control, short *pw_level)
29172605 {
29182606 struct hpi_message hm;
29192607 struct hpi_response hr;
29202608
29212609 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
29222610 HPI_CONTROL_GET_STATE);
2923− u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
2924− hm.u.c.attribute = HPI_TUNER_LEVEL;
2925− hm.u.c.param1 = HPI_TUNER_LEVEL_RAW;
2611+ if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
2612+ return HPI_ERROR_INVALID_HANDLE;
2613+ hm.u.cu.attribute = HPI_TUNER_LEVEL_RAW;
29262614 hpi_send_recv(&hm, &hr);
29272615 if (pw_level)
2928− *pw_level = (short)hr.u.c.param1;
2616+ *pw_level = hr.u.cu.tuner.s_level;
29292617 return hr.error;
29302618 }
29312619
2932−u16 hpi_tuner_query_deemphasis(const struct hpi_hsubsys *ph_subsys,
2933− const u32 h_tuner, const u32 index, const u16 band, u32 *pdeemphasis)
2620+u16 hpi_tuner_query_deemphasis(const u32 h_tuner, const u32 index,
2621+ const u16 band, u32 *pdeemphasis)
29342622 {
2935− return hpi_control_query(ph_subsys, h_tuner, HPI_TUNER_DEEMPHASIS,
2936− index, band, pdeemphasis);
2623+ return hpi_control_query(h_tuner, HPI_TUNER_DEEMPHASIS, index, band,
2624+ pdeemphasis);
29372625 }
29382626
2939−u16 hpi_tuner_set_deemphasis(const struct hpi_hsubsys *ph_subsys,
2940− u32 h_control, u32 deemphasis)
2627+u16 hpi_tuner_set_deemphasis(u32 h_control, u32 deemphasis)
29412628 {
2942− return hpi_control_param_set(ph_subsys, h_control,
2943− HPI_TUNER_DEEMPHASIS, deemphasis, 0);
2629+ return hpi_control_param_set(h_control, HPI_TUNER_DEEMPHASIS,
2630+ deemphasis, 0);
29442631 }
29452632
2946−u16 hpi_tuner_get_deemphasis(const struct hpi_hsubsys *ph_subsys,
2947− u32 h_control, u32 *pdeemphasis)
2633+u16 hpi_tuner_get_deemphasis(u32 h_control, u32 *pdeemphasis)
29482634 {
2949− return hpi_control_param1_get(ph_subsys, h_control,
2950− HPI_TUNER_DEEMPHASIS, pdeemphasis);
2635+ return hpi_control_param1_get(h_control, HPI_TUNER_DEEMPHASIS,
2636+ pdeemphasis);
29512637 }
29522638
2953−u16 hpi_tuner_query_program(const struct hpi_hsubsys *ph_subsys,
2954− const u32 h_tuner, u32 *pbitmap_program)
2639+u16 hpi_tuner_query_program(const u32 h_tuner, u32 *pbitmap_program)
29552640 {
2956− return hpi_control_query(ph_subsys, h_tuner, HPI_TUNER_PROGRAM, 0, 0,
2641+ return hpi_control_query(h_tuner, HPI_TUNER_PROGRAM, 0, 0,
29572642 pbitmap_program);
29582643 }
29592644
2960−u16 hpi_tuner_set_program(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2961− u32 program)
2645+u16 hpi_tuner_set_program(u32 h_control, u32 program)
29622646 {
2963− return hpi_control_param_set(ph_subsys, h_control, HPI_TUNER_PROGRAM,
2964− program, 0);
2647+ return hpi_control_param_set(h_control, HPI_TUNER_PROGRAM, program,
2648+ 0);
29652649 }
29662650
2967−u16 hpi_tuner_get_program(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2968− u32 *pprogram)
2651+u16 hpi_tuner_get_program(u32 h_control, u32 *pprogram)
29692652 {
2970− return hpi_control_param1_get(ph_subsys, h_control, HPI_TUNER_PROGRAM,
2971− pprogram);
2653+ return hpi_control_param1_get(h_control, HPI_TUNER_PROGRAM, pprogram);
29722654 }
29732655
2974−u16 hpi_tuner_get_hd_radio_dsp_version(const struct hpi_hsubsys *ph_subsys,
2975− u32 h_control, char *psz_dsp_version, const u32 string_size)
2656+u16 hpi_tuner_get_hd_radio_dsp_version(u32 h_control, char *psz_dsp_version,
2657+ const u32 string_size)
29762658 {
29772659 return hpi_control_get_string(h_control,
29782660 HPI_TUNER_HDRADIO_DSP_VERSION, psz_dsp_version, string_size);
29792661 }
29802662
2981−u16 hpi_tuner_get_hd_radio_sdk_version(const struct hpi_hsubsys *ph_subsys,
2982− u32 h_control, char *psz_sdk_version, const u32 string_size)
2663+u16 hpi_tuner_get_hd_radio_sdk_version(u32 h_control, char *psz_sdk_version,
2664+ const u32 string_size)
29832665 {
29842666 return hpi_control_get_string(h_control,
29852667 HPI_TUNER_HDRADIO_SDK_VERSION, psz_sdk_version, string_size);
29862668 }
29872669
2988−u16 hpi_tuner_get_status(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2989− u16 *pw_status_mask, u16 *pw_status)
2670+u16 hpi_tuner_get_status(u32 h_control, u16 *pw_status_mask, u16 *pw_status)
29902671 {
29912672 u32 status = 0;
29922673 u16 error = 0;
29932674
2994− error = hpi_control_param1_get(ph_subsys, h_control, HPI_TUNER_STATUS,
2995− &status);
2675+ error = hpi_control_param1_get(h_control, HPI_TUNER_STATUS, &status);
29962676 if (pw_status) {
29972677 if (!error) {
29982678 *pw_status_mask = (u16)(status >> 16);
@@ -3005,50 +2685,44 @@ u16 hpi_tuner_get_status(const struct hpi_hsubsys *ph_subsys, u32 h_control, · 6 unmodified lines
30052685 return error;
30062686 }
30072687
3008−u16 hpi_tuner_set_mode(const struct hpi_hsubsys *ph_subsys, u32 h_control,
3009− u32 mode, u32 value)
2688+u16 hpi_tuner_set_mode(u32 h_control, u32 mode, u32 value)
30102689 {
3011− return hpi_control_param_set(ph_subsys, h_control, HPI_TUNER_MODE,
3012− mode, value);
2690+ return hpi_control_param_set(h_control, HPI_TUNER_MODE, mode, value);
30132691 }
30142692
3015−u16 hpi_tuner_get_mode(const struct hpi_hsubsys *ph_subsys, u32 h_control,
3016− u32 mode, u32 *pn_value)
2693+u16 hpi_tuner_get_mode(u32 h_control, u32 mode, u32 *pn_value)
30172694 {
3018− return hpi_control_param_get(ph_subsys, h_control, HPI_TUNER_MODE,
3019− mode, 0, pn_value, NULL);
2695+ return hpi_control_param_get(h_control, HPI_TUNER_MODE, mode, 0,
2696+ pn_value, NULL);
30202697 }
30212698
3022−u16 hpi_tuner_get_hd_radio_signal_quality(const struct hpi_hsubsys *ph_subsys,
3023− u32 h_control, u32 *pquality)
2699+u16 hpi_tuner_get_hd_radio_signal_quality(u32 h_control, u32 *pquality)
30242700 {
3025− return hpi_control_param1_get(ph_subsys, h_control,
2701+ return hpi_control_param1_get(h_control,
30262702 HPI_TUNER_HDRADIO_SIGNAL_QUALITY, pquality);
30272703 }
30282704
3029−u16 hpi_tuner_get_hd_radio_signal_blend(const struct hpi_hsubsys *ph_subsys,
3030− u32 h_control, u32 *pblend)
2705+u16 hpi_tuner_get_hd_radio_signal_blend(u32 h_control, u32 *pblend)
30312706 {
3032− return hpi_control_param1_get(ph_subsys, h_control,
3033− HPI_TUNER_HDRADIO_BLEND, pblend);
2707+ return hpi_control_param1_get(h_control, HPI_TUNER_HDRADIO_BLEND,
2708+ pblend);
30342709 }
30352710
3036−u16 hpi_tuner_set_hd_radio_signal_blend(const struct hpi_hsubsys *ph_subsys,
3037− u32 h_control, const u32 blend)
2711+u16 hpi_tuner_set_hd_radio_signal_blend(u32 h_control, const u32 blend)
30382712 {
3039− return hpi_control_param_set(ph_subsys, h_control,
3040− HPI_TUNER_HDRADIO_BLEND, blend, 0);
2713+ return hpi_control_param_set(h_control, HPI_TUNER_HDRADIO_BLEND,
2714+ blend, 0);
30412715 }
30422716
3043−u16 hpi_tuner_getRDS(const struct hpi_hsubsys *ph_subsys, u32 h_control,
3044− char *p_data)
2717+u16 hpi_tuner_get_rds(u32 h_control, char *p_data)
30452718 {
30462719 struct hpi_message hm;
30472720 struct hpi_response hr;
30482721
30492722 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
30502723 HPI_CONTROL_GET_STATE);
3051− u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
2724+ if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
2725+ return HPI_ERROR_INVALID_HANDLE;
30522726 hm.u.c.attribute = HPI_TUNER_RDS;
30532727 hpi_send_recv(&hm, &hr);
30542728 if (p_data) {
@@ -3059,80 +2733,82 @@ u16 hpi_tuner_getRDS(const struct hpi_hsubsys *ph_subsys, u32 h_control, · 4 unmodified lines
30592733 return hr.error;
30602734 }
30612735
3062−u16 HPI_PAD__get_channel_name(const struct hpi_hsubsys *ph_subsys,
3063− u32 h_control, char *psz_string, const u32 data_length)
2736+u16 hpi_pad_get_channel_name(u32 h_control, char *psz_string,
2737+ const u32 data_length)
30642738 {
30652739 return hpi_control_get_string(h_control, HPI_PAD_CHANNEL_NAME,
30662740 psz_string, data_length);
30672741 }
30682742
3069−u16 HPI_PAD__get_artist(const struct hpi_hsubsys *ph_subsys, u32 h_control,
3070− char *psz_string, const u32 data_length)
2743+u16 hpi_pad_get_artist(u32 h_control, char *psz_string, const u32 data_length)
30712744 {
30722745 return hpi_control_get_string(h_control, HPI_PAD_ARTIST, psz_string,
30732746 data_length);
30742747 }
30752748
3076−u16 HPI_PAD__get_title(const struct hpi_hsubsys *ph_subsys, u32 h_control,
3077− char *psz_string, const u32 data_length)
2749+u16 hpi_pad_get_title(u32 h_control, char *psz_string, const u32 data_length)
30782750 {
30792751 return hpi_control_get_string(h_control, HPI_PAD_TITLE, psz_string,
30802752 data_length);
30812753 }
30822754
3083−u16 HPI_PAD__get_comment(const struct hpi_hsubsys *ph_subsys, u32 h_control,
3084− char *psz_string, const u32 data_length)
2755+u16 hpi_pad_get_comment(u32 h_control, char *psz_string,
2756+ const u32 data_length)
30852757 {
30862758 return hpi_control_get_string(h_control, HPI_PAD_COMMENT, psz_string,
30872759 data_length);
30882760 }
30892761
3090−u16 HPI_PAD__get_program_type(const struct hpi_hsubsys *ph_subsys,
3091− u32 h_control, u32 *ppTY)
2762+u16 hpi_pad_get_program_type(u32 h_control, u32 *ppTY)
30922763 {
3093− return hpi_control_param1_get(ph_subsys, h_control,
3094− HPI_PAD_PROGRAM_TYPE, ppTY);
2764+ return hpi_control_param1_get(h_control, HPI_PAD_PROGRAM_TYPE, ppTY);
30952765 }
30962766
3097−u16 HPI_PAD__get_rdsPI(const struct hpi_hsubsys *ph_subsys, u32 h_control,
3098− u32 *ppI)
2767+u16 hpi_pad_get_rdsPI(u32 h_control, u32 *ppI)
30992768 {
3100− return hpi_control_param1_get(ph_subsys, h_control,
3101− HPI_PAD_PROGRAM_ID, ppI);
2769+ return hpi_control_param1_get(h_control, HPI_PAD_PROGRAM_ID, ppI);
31022770 }
31032771
3104−u16 hpi_volume_query_channels(const struct hpi_hsubsys *ph_subsys,
3105− const u32 h_volume, u32 *p_channels)
2772+u16 hpi_volume_query_channels(const u32 h_volume, u32 *p_channels)
31062773 {
3107− return hpi_control_query(ph_subsys, h_volume, HPI_VOLUME_NUM_CHANNELS,
3108− 0, 0, p_channels);
2774+ return hpi_control_query(h_volume, HPI_VOLUME_NUM_CHANNELS, 0, 0,
2775+ p_channels);
31092776 }
31102777
3111−u16 hpi_volume_set_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control,
3112− short an_log_gain[HPI_MAX_CHANNELS]
2778+u16 hpi_volume_set_gain(u32 h_control, short an_log_gain[HPI_MAX_CHANNELS]
31132779 )
31142780 {
31152781 return hpi_control_log_set2(h_control, HPI_VOLUME_GAIN,
31162782 an_log_gain[0], an_log_gain[1]);
31172783 }
31182784
3119−u16 hpi_volume_get_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control,
3120− short an_log_gain[HPI_MAX_CHANNELS]
2785+u16 hpi_volume_get_gain(u32 h_control, short an_log_gain[HPI_MAX_CHANNELS]
31212786 )
31222787 {
3123− return hpi_control_log_get2(ph_subsys, h_control, HPI_VOLUME_GAIN,
2788+ return hpi_control_log_get2(h_control, HPI_VOLUME_GAIN,
31242789 &an_log_gain[0], &an_log_gain[1]);
31252790 }
31262791
3127−u16 hpi_volume_query_range(const struct hpi_hsubsys *ph_subsys, u32 h_control,
3128− short *min_gain_01dB, short *max_gain_01dB, short *step_gain_01dB)
2792+u16 hpi_volume_set_mute(u32 h_control, u32 mute)
2793+{
2794+ return hpi_control_param_set(h_control, HPI_VOLUME_MUTE, mute, 0);
2795+}
2796+
2797+u16 hpi_volume_get_mute(u32 h_control, u32 *mute)
2798+{
2799+ return hpi_control_param1_get(h_control, HPI_VOLUME_MUTE, mute);
2800+}
2801+
2802+u16 hpi_volume_query_range(u32 h_control, short *min_gain_01dB,
2803+ short *max_gain_01dB, short *step_gain_01dB)
31292804 {
31302805 struct hpi_message hm;
31312806 struct hpi_response hr;
31322807
31332808 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
31342809 HPI_CONTROL_GET_STATE);
3135− u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
2810+ if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
2811+ return HPI_ERROR_INVALID_HANDLE;
31362812 hm.u.c.attribute = HPI_VOLUME_RANGE;
31372813
31382814 hpi_send_recv(&hm, &hr);
@@ -3150,16 +2826,17 @@ u16 hpi_volume_query_range(const struct hpi_hsubsys *ph_subsys, u32 h_control, · 11 unmodified lines
31502826 return hr.error;
31512827 }
31522828
3153−u16 hpi_volume_auto_fade_profile(const struct hpi_hsubsys *ph_subsys,
3154− u32 h_control, short an_stop_gain0_01dB[HPI_MAX_CHANNELS],
3155− u32 duration_ms, u16 profile)
2829+u16 hpi_volume_auto_fade_profile(u32 h_control,
2830+ short an_stop_gain0_01dB[HPI_MAX_CHANNELS], u32 duration_ms,
2831+ u16 profile)
31562832 {
31572833 struct hpi_message hm;
31582834 struct hpi_response hr;
31592835
31602836 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
31612837 HPI_CONTROL_SET_STATE);
3162− u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
2838+ if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
2839+ return HPI_ERROR_INVALID_HANDLE;
31632840
31642841 memcpy(hm.u.c.an_log_value, an_stop_gain0_01dB,
31652842 sizeof(short) * HPI_MAX_CHANNELS);
@@ -3173,21 +2850,21 @@ u16 hpi_volume_auto_fade_profile(const struct hpi_hsubsys *ph_subsys, · 7 unmodified lines
31732850 return hr.error;
31742851 }
31752852
3176−u16 hpi_volume_auto_fade(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2853+u16 hpi_volume_auto_fade(u32 h_control,
31772854 short an_stop_gain0_01dB[HPI_MAX_CHANNELS], u32 duration_ms)
31782855 {
3179− return hpi_volume_auto_fade_profile(ph_subsys, h_control,
3180− an_stop_gain0_01dB, duration_ms, HPI_VOLUME_AUTOFADE_LOG);
2856+ return hpi_volume_auto_fade_profile(h_control, an_stop_gain0_01dB,
2857+ duration_ms, HPI_VOLUME_AUTOFADE_LOG);
31812858 }
31822859
3183−u16 hpi_vox_set_threshold(const struct hpi_hsubsys *ph_subsys, u32 h_control,
3184− short an_gain0_01dB)
2860+u16 hpi_vox_set_threshold(u32 h_control, short an_gain0_01dB)
31852861 {
31862862 struct hpi_message hm;
31872863 struct hpi_response hr;
31882864 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
31892865 HPI_CONTROL_SET_STATE);
3190− u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
2866+ if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
2867+ return HPI_ERROR_INVALID_HANDLE;
31912868 hm.u.c.attribute = HPI_VOX_THRESHOLD;
31922869
31932870 hm.u.c.an_log_value[0] = an_gain0_01dB;
@@ -3197,14 +2874,14 @@ u16 hpi_vox_set_threshold(const struct hpi_hsubsys *ph_subsys, u32 h_control, · 3 unmodified lines
31972874 return hr.error;
31982875 }
31992876
3200−u16 hpi_vox_get_threshold(const struct hpi_hsubsys *ph_subsys, u32 h_control,
3201− short *an_gain0_01dB)
2877+u16 hpi_vox_get_threshold(u32 h_control, short *an_gain0_01dB)
32022878 {
32032879 struct hpi_message hm;
32042880 struct hpi_response hr;
32052881 hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
32062882 HPI_CONTROL_GET_STATE);
3207− u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
2883+ if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
2884+ return HPI_ERROR_INVALID_HANDLE;
32082885 hm.u.c.attribute = HPI_VOX_THRESHOLD;
32092886
32102887 hpi_send_recv(&hm, &hr);
@@ -3213,728 +2890,3 @@ u16 hpi_vox_get_threshold(const struct hpi_hsubsys *ph_subsys, u32 h_control, · 2 unmodified lines
32132890
32142891 return hr.error;
32152892 }
3216−
3217−static size_t strv_packet_size = MIN_STRV_PACKET_SIZE;
3218−
3219−static size_t entity_type_to_size[LAST_ENTITY_TYPE] = {
3220− 0,
3221− sizeof(struct hpi_entity),
3222− sizeof(void *),
3223−
3224− sizeof(int),
3225− sizeof(float),
3226− sizeof(double),
3227−
3228− sizeof(char),
3229− sizeof(char),
3230−
3231− 4 * sizeof(char),
3232− 16 * sizeof(char),
3233− 6 * sizeof(char),
3234−};
3235−
3236−static inline size_t hpi_entity_size(struct hpi_entity *entity_ptr)
3237−{
3238− return entity_ptr->header.size;
3239−}
3240−
3241−static inline size_t hpi_entity_header_size(struct hpi_entity *entity_ptr)
3242−{
3243− return sizeof(entity_ptr->header);
3244−}
3245−
3246−static inline size_t hpi_entity_value_size(struct hpi_entity *entity_ptr)
3247−{
3248− return hpi_entity_size(entity_ptr) -
3249− hpi_entity_header_size(entity_ptr);
3250−}
3251−
3252−static inline size_t hpi_entity_item_count(struct hpi_entity *entity_ptr)
3253−{
3254− return hpi_entity_value_size(entity_ptr) /
3255− entity_type_to_size[entity_ptr->header.type];
3256−}
3257−
3258−static inline struct hpi_entity *hpi_entity_ptr_to_next(struct hpi_entity
3259− *entity_ptr)
3260−{
3261− return (void *)(((u8 *)entity_ptr) + hpi_entity_size(entity_ptr));
3262−}
3263−
3264−static inline u16 hpi_entity_check_type(const enum e_entity_type t)
3265−{
3266− if (t >= 0 && t < STR_TYPE_FIELD_MAX)
3267− return 0;
3268− return HPI_ERROR_ENTITY_TYPE_INVALID;
3269−}
3270−
3271−static inline u16 hpi_entity_check_role(const enum e_entity_role r)
3272−{
3273− if (r >= 0 && r < STR_ROLE_FIELD_MAX)
3274− return 0;
3275− return HPI_ERROR_ENTITY_ROLE_INVALID;
3276−}
3277−
3278−static u16 hpi_entity_get_next(struct hpi_entity *entity, int recursive_flag,
3279− void *guard_p, struct hpi_entity **next)
3280−{
3281− HPI_DEBUG_ASSERT(entity != NULL);
3282− HPI_DEBUG_ASSERT(next != NULL);
3283− HPI_DEBUG_ASSERT(hpi_entity_size(entity) != 0);
3284−
3285− if (guard_p <= (void *)entity) {
3286− *next = NULL;
3287− return 0;
3288− }
3289−
3290− if (recursive_flag && entity->header.type == entity_type_sequence)
3291− *next = (struct hpi_entity *)entity->value;
3292− else
3293− *next = (struct hpi_entity *)hpi_entity_ptr_to_next(entity);
3294−
3295− if (guard_p <= (void *)*next) {
3296− *next = NULL;
3297− return 0;
3298− }
3299−
3300− HPI_DEBUG_ASSERT(guard_p >= (void *)hpi_entity_ptr_to_next(*next));
3301− return 0;
3302−}
3303−
3304−u16 hpi_entity_find_next(struct hpi_entity *container_entity,
3305− enum e_entity_type type, enum e_entity_role role, int recursive_flag,
3306− struct hpi_entity **current_match)
3307−{
3308− struct hpi_entity *tmp = NULL;
3309− void *guard_p = NULL;
3310−
3311− HPI_DEBUG_ASSERT(container_entity != NULL);
3312− guard_p = hpi_entity_ptr_to_next(container_entity);
3313−
3314− if (*current_match != NULL)
3315− hpi_entity_get_next(*current_match, recursive_flag, guard_p,
3316− &tmp);
3317− else
3318− hpi_entity_get_next(container_entity, 1, guard_p, &tmp);
3319−
3320− while (tmp) {
3321− u16 err;
3322−
3323− HPI_DEBUG_ASSERT((void *)tmp >= (void *)container_entity);
3324−
3325− if ((!type || tmp->header.type == type) && (!role
3326− || tmp->header.role == role)) {
3327− *current_match = tmp;
3328− return 0;
3329− }
3330−
3331− err = hpi_entity_get_next(tmp, recursive_flag, guard_p,
3332− current_match);
3333− if (err)
3334− return err;
3335−
3336− tmp = *current_match;
3337− }
3338−
3339− *current_match = NULL;
3340− return 0;
3341−}
3342−
3343−void hpi_entity_free(struct hpi_entity *entity)
3344−{
3345− kfree(entity);
3346−}
3347−
3348−static u16 hpi_entity_alloc_and_copy(struct hpi_entity *src,
3349− struct hpi_entity **dst)
3350−{
3351− size_t buf_size;
3352− HPI_DEBUG_ASSERT(dst != NULL);
3353− HPI_DEBUG_ASSERT(src != NULL);
3354−
3355− buf_size = hpi_entity_size(src);
3356− *dst = kmalloc(buf_size, GFP_KERNEL);
3357− if (*dst == NULL)
3358− return HPI_ERROR_MEMORY_ALLOC;
3359− memcpy(*dst, src, buf_size);
3360− return 0;
3361−}
3362−
3363−u16 hpi_universal_info(const struct hpi_hsubsys *ph_subsys, u32 hC,
3364− struct hpi_entity **info)
3365−{
3366− struct hpi_msg_strv hm;
3367− struct hpi_res_strv *phr;
3368− u16 hpi_err;
3369− int remaining_attempts = 2;
3370− size_t resp_packet_size = 1024;
3371−
3372− *info = NULL;
3373−
3374− while (remaining_attempts--) {
3375− phr = kmalloc(resp_packet_size, GFP_KERNEL);
3376− HPI_DEBUG_ASSERT(phr != NULL);
3377−
3378− hpi_init_message_responseV1(&hm.h, (u16)sizeof(hm), &phr->h,
3379− (u16)resp_packet_size, HPI_OBJ_CONTROL,
3380− HPI_CONTROL_GET_INFO);
3381− u32TOINDEXES(hC, &hm.h.adapter_index, &hm.h.obj_index);
3382−
3383− hm.strv.header.size = sizeof(hm.strv);
3384− phr->strv.header.size = resp_packet_size - sizeof(phr->h);
3385−
3386− hpi_send_recv((struct hpi_message *)&hm.h,
3387− (struct hpi_response *)&phr->h);
3388− if (phr->h.error == HPI_ERROR_RESPONSE_BUFFER_TOO_SMALL) {
3389−
3390− HPI_DEBUG_ASSERT(phr->h.specific_error >
3391− MIN_STRV_PACKET_SIZE
3392− && phr->h.specific_error < 1500);
3393− resp_packet_size = phr->h.specific_error;
3394− } else {
3395− remaining_attempts = 0;
3396− if (!phr->h.error)
3397− hpi_entity_alloc_and_copy(&phr->strv, info);
3398− }
3399−
3400− hpi_err = phr->h.error;
3401− kfree(phr);
3402− }
3403−
3404− return hpi_err;
3405−}
3406−
3407−u16 hpi_universal_get(const struct hpi_hsubsys *ph_subsys, u32 hC,
3408− struct hpi_entity **value)
3409−{
3410− struct hpi_msg_strv hm;
3411− struct hpi_res_strv *phr;
3412− u16 hpi_err;
3413− int remaining_attempts = 2;
3414−
3415− *value = NULL;
3416−
3417− while (remaining_attempts--) {
3418− phr = kmalloc(strv_packet_size, GFP_KERNEL);
3419− if (!phr)
3420− return HPI_ERROR_MEMORY_ALLOC;
3421−
3422− hpi_init_message_responseV1(&hm.h, (u16)sizeof(hm), &phr->h,
3423− (u16)strv_packet_size, HPI_OBJ_CONTROL,
3424− HPI_CONTROL_GET_STATE);
3425− u32TOINDEXES(hC, &hm.h.adapter_index, &hm.h.obj_index);
3426−
3427− hm.strv.header.size = sizeof(hm.strv);
3428− phr->strv.header.size = strv_packet_size - sizeof(phr->h);
3429−
3430− hpi_send_recv((struct hpi_message *)&hm.h,
3431− (struct hpi_response *)&phr->h);
3432− if (phr->h.error == HPI_ERROR_RESPONSE_BUFFER_TOO_SMALL) {
3433−
3434− HPI_DEBUG_ASSERT(phr->h.specific_error >
3435− MIN_STRV_PACKET_SIZE
3436− && phr->h.specific_error < 1000);
3437− strv_packet_size = phr->h.specific_error;
3438− } else {
3439− remaining_attempts = 0;
3440− if (!phr->h.error)
3441− hpi_entity_alloc_and_copy(&phr->strv, value);
3442− }
3443−
3444− hpi_err = phr->h.error;
3445− kfree(phr);
3446− }
3447−
3448− return hpi_err;
3449−}
3450−
3451−u16 hpi_universal_set(const struct hpi_hsubsys *ph_subsys, u32 hC,
3452− struct hpi_entity *value)
3453−{
3454− struct hpi_msg_strv *phm;
3455− struct hpi_res_strv hr;
3456−
3457− phm = kmalloc(sizeof(phm->h) + value->header.size, GFP_KERNEL);
3458− HPI_DEBUG_ASSERT(phm != NULL);
3459−
3460− hpi_init_message_responseV1(&phm->h,
3461− sizeof(phm->h) + value->header.size, &hr.h, sizeof(hr),
3462− HPI_OBJ_CONTROL, HPI_CONTROL_SET_STATE);
3463− u32TOINDEXES(hC, &phm->h.adapter_index, &phm->h.obj_index);
3464− hr.strv.header.size = sizeof(hr.strv);
3465−
3466− memcpy(&phm->strv, value, value->header.size);
3467− hpi_send_recv((struct hpi_message *)&phm->h,
3468− (struct hpi_response *)&hr.h);
3469−
3470− return hr.h.error;
3471−}
3472−
3473−u16 hpi_entity_alloc_and_pack(const enum e_entity_type type,
3474− const size_t item_count, const enum e_entity_role role, void *value,
3475− struct hpi_entity **entity)
3476−{
3477− size_t bytes_to_copy, total_size;
3478− u16 hE = 0;
3479− *entity = NULL;
3480−
3481− hE = hpi_entity_check_type(type);
3482− if (hE)
3483− return hE;
3484−
3485− HPI_DEBUG_ASSERT(role > entity_role_null && type < LAST_ENTITY_TYPE);
3486−
3487− bytes_to_copy = entity_type_to_size[type] * item_count;
3488− total_size = hpi_entity_header_size(*entity) + bytes_to_copy;
3489−
3490− HPI_DEBUG_ASSERT(total_size >= hpi_entity_header_size(*entity)
3491− && total_size < STR_SIZE_FIELD_MAX);
3492−
3493− *entity = kmalloc(total_size, GFP_KERNEL);
3494− if (*entity == NULL)
3495− return HPI_ERROR_MEMORY_ALLOC;
3496− memcpy((*entity)->value, value, bytes_to_copy);
3497− (*entity)->header.size =
3498− hpi_entity_header_size(*entity) + bytes_to_copy;
3499− (*entity)->header.type = type;
3500− (*entity)->header.role = role;
3501− return 0;
3502−}
3503−
3504−u16 hpi_entity_copy_value_from(struct hpi_entity *entity,
3505− enum e_entity_type type, size_t item_count, void *value_dst_p)
3506−{
3507− size_t bytes_to_copy;
3508−
3509− if (entity->header.type != type)
3510− return HPI_ERROR_ENTITY_TYPE_MISMATCH;
3511−
3512− if (hpi_entity_item_count(entity) != item_count)
3513− return HPI_ERROR_ENTITY_ITEM_COUNT;
3514−
3515− bytes_to_copy = entity_type_to_size[type] * item_count;
3516− memcpy(value_dst_p, entity->value, bytes_to_copy);
3517− return 0;
3518−}
3519−
3520−u16 hpi_entity_unpack(struct hpi_entity *entity, enum e_entity_type *type,
3521− size_t *item_count, enum e_entity_role *role, void **value)
3522−{
3523− u16 err = 0;
3524− HPI_DEBUG_ASSERT(entity != NULL);
3525−
3526− if (type)
3527− *type = entity->header.type;
3528−
3529− if (role)
3530− *role = entity->header.role;
3531−
3532− if (value)
3533− *value = entity->value;
3534−
3535− if (item_count != NULL) {
3536− if (entity->header.type == entity_type_sequence) {
3537− void *guard_p = hpi_entity_ptr_to_next(entity);
3538− struct hpi_entity *next = NULL;
3539− void *contents = entity->value;
3540−
3541− *item_count = 0;
3542− while (contents < guard_p) {
3543− (*item_count)++;
3544− err = hpi_entity_get_next(contents, 0,
3545− guard_p, &next);
3546− if (next == NULL || err)
3547− break;
3548− contents = next;
3549− }
3550− } else {
3551− *item_count = hpi_entity_item_count(entity);
3552− }
3553− }
3554− return err;
3555−}
3556−
3557−u16 hpi_gpio_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index,
3558− u32 *ph_gpio, u16 *pw_number_input_bits, u16 *pw_number_output_bits)
3559−{
3560− struct hpi_message hm;
3561− struct hpi_response hr;
3562− hpi_init_message_response(&hm, &hr, HPI_OBJ_GPIO, HPI_GPIO_OPEN);
3563− hm.adapter_index = adapter_index;
3564−
3565− hpi_send_recv(&hm, &hr);
3566−
3567− if (hr.error == 0) {
3568− *ph_gpio =
3569− hpi_indexes_to_handle(HPI_OBJ_GPIO, adapter_index, 0);
3570− if (pw_number_input_bits)
3571− *pw_number_input_bits = hr.u.l.number_input_bits;
3572− if (pw_number_output_bits)
3573− *pw_number_output_bits = hr.u.l.number_output_bits;
3574− } else
3575− *ph_gpio = 0;
3576− return hr.error;
3577−}
3578−
3579−u16 hpi_gpio_read_bit(const struct hpi_hsubsys *ph_subsys, u32 h_gpio,
3580− u16 bit_index, u16 *pw_bit_data)
3581−{
3582− struct hpi_message hm;
3583− struct hpi_response hr;
3584− hpi_init_message_response(&hm, &hr, HPI_OBJ_GPIO, HPI_GPIO_READ_BIT);
3585− u32TOINDEX(h_gpio, &hm.adapter_index);
3586− hm.u.l.bit_index = bit_index;
3587−
3588− hpi_send_recv(&hm, &hr);
3589−
3590− *pw_bit_data = hr.u.l.bit_data[0];
3591− return hr.error;
3592−}
3593−
3594−u16 hpi_gpio_read_all_bits(const struct hpi_hsubsys *ph_subsys, u32 h_gpio,
3595− u16 aw_all_bit_data[4]
3596− )
3597−{
3598− struct hpi_message hm;
3599− struct hpi_response hr;
3600− hpi_init_message_response(&hm, &hr, HPI_OBJ_GPIO, HPI_GPIO_READ_ALL);
3601− u32TOINDEX(h_gpio, &hm.adapter_index);
3602−
3603− hpi_send_recv(&hm, &hr);
3604−
3605− if (aw_all_bit_data) {
3606− aw_all_bit_data[0] = hr.u.l.bit_data[0];
3607− aw_all_bit_data[1] = hr.u.l.bit_data[1];
3608− aw_all_bit_data[2] = hr.u.l.bit_data[2];
3609− aw_all_bit_data[3] = hr.u.l.bit_data[3];
3610− }
3611− return hr.error;
3612−}
3613−
3614−u16 hpi_gpio_write_bit(const struct hpi_hsubsys *ph_subsys, u32 h_gpio,
3615− u16 bit_index, u16 bit_data)
3616−{
3617− struct hpi_message hm;
3618− struct hpi_response hr;
3619− hpi_init_message_response(&hm, &hr, HPI_OBJ_GPIO, HPI_GPIO_WRITE_BIT);
3620− u32TOINDEX(h_gpio, &hm.adapter_index);
3621− hm.u.l.bit_index = bit_index;
3622− hm.u.l.bit_data = bit_data;
3623−
3624− hpi_send_recv(&hm, &hr);
3625−
3626− return hr.error;
3627−}
3628−
3629−u16 hpi_gpio_write_status(const struct hpi_hsubsys *ph_subsys, u32 h_gpio,
3630− u16 aw_all_bit_data[4]
3631− )
3632−{
3633− struct hpi_message hm;
3634− struct hpi_response hr;
3635− hpi_init_message_response(&hm, &hr, HPI_OBJ_GPIO,
3636− HPI_GPIO_WRITE_STATUS);
3637− u32TOINDEX(h_gpio, &hm.adapter_index);
3638−
3639− hpi_send_recv(&hm, &hr);
3640−
3641− if (aw_all_bit_data) {
3642− aw_all_bit_data[0] = hr.u.l.bit_data[0];
3643− aw_all_bit_data[1] = hr.u.l.bit_data[1];
3644− aw_all_bit_data[2] = hr.u.l.bit_data[2];
3645− aw_all_bit_data[3] = hr.u.l.bit_data[3];
3646− }
3647− return hr.error;
3648−}
3649−
3650−u16 hpi_async_event_open(const struct hpi_hsubsys *ph_subsys,
3651− u16 adapter_index, u32 *ph_async)
3652−{
3653− struct hpi_message hm;
3654− struct hpi_response hr;
3655− hpi_init_message_response(&hm, &hr, HPI_OBJ_ASYNCEVENT,
3656− HPI_ASYNCEVENT_OPEN);
3657− hm.adapter_index = adapter_index;
3658−
3659− hpi_send_recv(&hm, &hr);
3660−
3661− if (hr.error == 0)
3662−
3663− *ph_async =
3664− hpi_indexes_to_handle(HPI_OBJ_ASYNCEVENT,
3665− adapter_index, 0);
3666− else
3667− *ph_async = 0;
3668− return hr.error;
3669−
3670−}
3671−
3672−u16 hpi_async_event_close(const struct hpi_hsubsys *ph_subsys, u32 h_async)
3673−{
3674− struct hpi_message hm;
3675− struct hpi_response hr;
3676− hpi_init_message_response(&hm, &hr, HPI_OBJ_ASYNCEVENT,
3677− HPI_ASYNCEVENT_OPEN);
3678− u32TOINDEX(h_async, &hm.adapter_index);
3679−
3680− hpi_send_recv(&hm, &hr);
3681−
3682− return hr.error;
3683−}
3684−
3685−u16 hpi_async_event_wait(const struct hpi_hsubsys *ph_subsys, u32 h_async,
3686− u16 maximum_events, struct hpi_async_event *p_events,
3687− u16 *pw_number_returned)
3688−{
3689−
3690− return 0;
3691−}
3692−
3693−u16 hpi_async_event_get_count(const struct hpi_hsubsys *ph_subsys,
3694− u32 h_async, u16 *pw_count)
3695−{
3696− struct hpi_message hm;
3697− struct hpi_response hr;
3698− hpi_init_message_response(&hm, &hr, HPI_OBJ_ASYNCEVENT,
3699− HPI_ASYNCEVENT_GETCOUNT);
3700− u32TOINDEX(h_async, &hm.adapter_index);
3701−
3702− hpi_send_recv(&hm, &hr);
3703−
3704− if (hr.error == 0)
3705− if (pw_count)
3706− *pw_count = hr.u.as.u.count.count;
3707−
3708− return hr.error;
3709−}
3710−
3711−u16 hpi_async_event_get(const struct hpi_hsubsys *ph_subsys, u32 h_async,
3712− u16 maximum_events, struct hpi_async_event *p_events,
3713− u16 *pw_number_returned)
3714−{
3715− struct hpi_message hm;
3716− struct hpi_response hr;
3717− hpi_init_message_response(&hm, &hr, HPI_OBJ_ASYNCEVENT,
3718− HPI_ASYNCEVENT_GET);
3719− u32TOINDEX(h_async, &hm.adapter_index);
3720−
3721− hpi_send_recv(&hm, &hr);
3722− if (!hr.error) {
3723− memcpy(p_events, &hr.u.as.u.event,
3724− sizeof(struct hpi_async_event));
3725− *pw_number_returned = 1;
3726− }
3727−
3728− return hr.error;
3729−}
3730−
3731−u16 hpi_nv_memory_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index,
3732− u32 *ph_nv_memory, u16 *pw_size_in_bytes)
3733−{
3734− struct hpi_message hm;
3735− struct hpi_response hr;
3736− hpi_init_message_response(&hm, &hr, HPI_OBJ_NVMEMORY,
3737− HPI_NVMEMORY_OPEN);
3738− hm.adapter_index = adapter_index;
3739−
3740− hpi_send_recv(&hm, &hr);
3741−
3742− if (hr.error == 0) {
3743− *ph_nv_memory =
3744− hpi_indexes_to_handle(HPI_OBJ_NVMEMORY, adapter_index,
3745− 0);
3746− if (pw_size_in_bytes)
3747− *pw_size_in_bytes = hr.u.n.size_in_bytes;
3748− } else
3749− *ph_nv_memory = 0;
3750− return hr.error;
3751−}
3752−
3753−u16 hpi_nv_memory_read_byte(const struct hpi_hsubsys *ph_subsys,
3754− u32 h_nv_memory, u16 index, u16 *pw_data)
3755−{
3756− struct hpi_message hm;
3757− struct hpi_response hr;
3758− hpi_init_message_response(&hm, &hr, HPI_OBJ_NVMEMORY,
3759− HPI_NVMEMORY_READ_BYTE);
3760− u32TOINDEX(h_nv_memory, &hm.adapter_index);
3761− hm.u.n.address = index;
3762−
3763− hpi_send_recv(&hm, &hr);
3764−
3765− *pw_data = hr.u.n.data;
3766− return hr.error;
3767−}
3768−
3769−u16 hpi_nv_memory_write_byte(const struct hpi_hsubsys *ph_subsys,
3770− u32 h_nv_memory, u16 index, u16 data)
3771−{
3772− struct hpi_message hm;
3773− struct hpi_response hr;
3774− hpi_init_message_response(&hm, &hr, HPI_OBJ_NVMEMORY,
3775− HPI_NVMEMORY_WRITE_BYTE);
3776− u32TOINDEX(h_nv_memory, &hm.adapter_index);
3777− hm.u.n.address = index;
3778− hm.u.n.data = data;
3779−
3780− hpi_send_recv(&hm, &hr);
3781−
3782− return hr.error;
3783−}
3784−
3785−u16 hpi_profile_open_all(const struct hpi_hsubsys *ph_subsys,
3786− u16 adapter_index, u16 profile_index, u32 *ph_profile,
3787− u16 *pw_max_profiles)
3788−{
3789− struct hpi_message hm;
3790− struct hpi_response hr;
3791− hpi_init_message_response(&hm, &hr, HPI_OBJ_PROFILE,
3792− HPI_PROFILE_OPEN_ALL);
3793− hm.adapter_index = adapter_index;
3794− hm.obj_index = profile_index;
3795− hpi_send_recv(&hm, &hr);
3796−
3797− *pw_max_profiles = hr.u.p.u.o.max_profiles;
3798− if (hr.error == 0)
3799− *ph_profile =
3800− hpi_indexes_to_handle(HPI_OBJ_PROFILE, adapter_index,
3801− profile_index);
3802− else
3803− *ph_profile = 0;
3804− return hr.error;
3805−}
3806−
3807−u16 hpi_profile_get(const struct hpi_hsubsys *ph_subsys, u32 h_profile,
3808− u16 bin_index, u16 *pw_seconds, u32 *pmicro_seconds, u32 *pcall_count,
3809− u32 *pmax_micro_seconds, u32 *pmin_micro_seconds)
3810−{
3811− struct hpi_message hm;
3812− struct hpi_response hr;
3813− hpi_init_message_response(&hm, &hr, HPI_OBJ_PROFILE, HPI_PROFILE_GET);
3814− u32TOINDEXES(h_profile, &hm.adapter_index, &hm.obj_index);
3815− hm.u.p.bin_index = bin_index;
3816− hpi_send_recv(&hm, &hr);
3817− if (pw_seconds)
3818− *pw_seconds = hr.u.p.u.t.seconds;
3819− if (pmicro_seconds)
3820− *pmicro_seconds = hr.u.p.u.t.micro_seconds;
3821− if (pcall_count)
3822− *pcall_count = hr.u.p.u.t.call_count;
3823− if (pmax_micro_seconds)
3824− *pmax_micro_seconds = hr.u.p.u.t.max_micro_seconds;
3825− if (pmin_micro_seconds)
3826− *pmin_micro_seconds = hr.u.p.u.t.min_micro_seconds;
3827− return hr.error;
3828−}
3829−
3830−u16 hpi_profile_get_utilization(const struct hpi_hsubsys *ph_subsys,
3831− u32 h_profile, u32 *putilization)
3832−{
3833− struct hpi_message hm;
3834− struct hpi_response hr;
3835− hpi_init_message_response(&hm, &hr, HPI_OBJ_PROFILE,
3836− HPI_PROFILE_GET_UTILIZATION);
3837− u32TOINDEXES(h_profile, &hm.adapter_index, &hm.obj_index);
3838− hpi_send_recv(&hm, &hr);
3839− if (hr.error) {
3840− if (putilization)
3841− *putilization = 0;
3842− } else {
3843− if (putilization)
3844− *putilization = hr.u.p.u.t.call_count;
3845− }
3846− return hr.error;
3847−}
3848−
3849−u16 hpi_profile_get_name(const struct hpi_hsubsys *ph_subsys, u32 h_profile,
3850− u16 bin_index, char *sz_name, u16 name_length)
3851−{
3852− struct hpi_message hm;
3853− struct hpi_response hr;
3854− hpi_init_message_response(&hm, &hr, HPI_OBJ_PROFILE,
3855− HPI_PROFILE_GET_NAME);
3856− u32TOINDEXES(h_profile, &hm.adapter_index, &hm.obj_index);
3857− hm.u.p.bin_index = bin_index;
3858− hpi_send_recv(&hm, &hr);
3859− if (hr.error) {
3860− if (sz_name)
3861− strcpy(sz_name, "??");
3862− } else {
3863− if (sz_name)
3864− memcpy(sz_name, (char *)hr.u.p.u.n.sz_name,
3865− name_length);
3866− }
3867− return hr.error;
3868−}
3869−
3870−u16 hpi_profile_start_all(const struct hpi_hsubsys *ph_subsys, u32 h_profile)
3871−{
3872− struct hpi_message hm;
3873− struct hpi_response hr;
3874− hpi_init_message_response(&hm, &hr, HPI_OBJ_PROFILE,
3875− HPI_PROFILE_START_ALL);
3876− u32TOINDEXES(h_profile, &hm.adapter_index, &hm.obj_index);
3877− hpi_send_recv(&hm, &hr);
3878−
3879− return hr.error;
3880−}
3881−
3882−u16 hpi_profile_stop_all(const struct hpi_hsubsys *ph_subsys, u32 h_profile)
3883−{
3884− struct hpi_message hm;
3885− struct hpi_response hr;
3886− hpi_init_message_response(&hm, &hr, HPI_OBJ_PROFILE,
3887− HPI_PROFILE_STOP_ALL);
3888− u32TOINDEXES(h_profile, &hm.adapter_index, &hm.obj_index);
3889− hpi_send_recv(&hm, &hr);
3890−
3891− return hr.error;
3892−}
3893−
3894−u16 hpi_watchdog_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index,
3895− u32 *ph_watchdog)
3896−{
3897− struct hpi_message hm;
3898− struct hpi_response hr;
3899− hpi_init_message_response(&hm, &hr, HPI_OBJ_WATCHDOG,
3900− HPI_WATCHDOG_OPEN);
3901− hm.adapter_index = adapter_index;
3902−
3903− hpi_send_recv(&hm, &hr);
3904−
3905− if (hr.error == 0)
3906− *ph_watchdog =
3907− hpi_indexes_to_handle(HPI_OBJ_WATCHDOG, adapter_index,
3908− 0);
3909− else
3910− *ph_watchdog = 0;
3911− return hr.error;
3912−}
3913−
3914−u16 hpi_watchdog_set_time(const struct hpi_hsubsys *ph_subsys, u32 h_watchdog,
3915− u32 time_millisec)
3916−{
3917− struct hpi_message hm;
3918− struct hpi_response hr;
3919− hpi_init_message_response(&hm, &hr, HPI_OBJ_WATCHDOG,
3920− HPI_WATCHDOG_SET_TIME);
3921− u32TOINDEX(h_watchdog, &hm.adapter_index);
3922− hm.u.w.time_ms = time_millisec;
3923−
3924− hpi_send_recv(&hm, &hr);
3925−
3926− return hr.error;
3927−}
3928−
3929−u16 hpi_watchdog_ping(const struct hpi_hsubsys *ph_subsys, u32 h_watchdog)
3930−{
3931− struct hpi_message hm;
3932− struct hpi_response hr;
3933− hpi_init_message_response(&hm, &hr, HPI_OBJ_WATCHDOG,
3934− HPI_WATCHDOG_PING);
3935− u32TOINDEX(h_watchdog, &hm.adapter_index);
3936−
3937− hpi_send_recv(&hm, &hr);
3938−
3939− return hr.error;
3940−}
sound/pci/asihpi/hpimsginit.c+2−16
@@ -31,21 +31,6 @@ static u16 res_size[HPI_OBJ_MAXINDEX + 1] = HPI_RESPONSE_SIZE_BY_OBJECT; · 30 unmodified lines
3131 /* Flag to enable alternate message type for SSX2 bypass. */
3232 static u16 gwSSX2_bypass;
3333
34−/** \internal
35− * Used by ASIO driver to disable SSX2 for a single process
36− * \param phSubSys Pointer to HPI subsystem handle.
37− * \param wBypass New bypass setting 0 = off, nonzero = on
38− * \return Previous bypass setting.
39− */
40−u16 hpi_subsys_ssx2_bypass(const struct hpi_hsubsys *ph_subsys, u16 bypass)
41−{
42− u16 old_value = gwSSX2_bypass;
43−
44− gwSSX2_bypass = bypass;
45−
46− return old_value;
47−}
48−
4934 /** \internal
5035 * initialize the HPI message structure
5136 */
@@ -65,7 +50,8 @@ static void hpi_init_message(struct hpi_message *phm, u16 object, · 13 unmodified lines
6550 phm->object = object;
6651 phm->function = function;
6752 phm->version = 0;
68− /* Expect adapter index to be set by caller */
53+ phm->adapter_index = HPI_ADAPTER_INDEX_INVALID;
54+ /* Expect actual adapter index to be set by caller */
6955 }
7056
7157 /** \internal
sound/pci/asihpi/hpimsginit.h+9−3
@@ -21,11 +21,15 @@ · 20 unmodified lines
2121 (C) Copyright AudioScience Inc. 2007
2222 *******************************************************************************/
2323 /* Initialise response headers, or msg/response pairs.
24−Note that it is valid to just init a response e.g. when a lower level is preparing
25−a response to a message.
26−However, when sending a message, a matching response buffer always must be prepared
24+Note that it is valid to just init a response e.g. when a lower level is
25+preparing a response to a message.
26+However, when sending a message, a matching response buffer must always be
27+prepared.
2728 */
2829
30+#ifndef _HPIMSGINIT_H_
31+#define _HPIMSGINIT_H_
32+
2933 void hpi_init_response(struct hpi_response *phr, u16 object, u16 function,
3034 u16 error);
3135
@@ -38,3 +42,5 @@ void hpi_init_responseV1(struct hpi_response_header *phr, u16 size, · 6 unmodified lines
3842 void hpi_init_message_responseV1(struct hpi_message_header *phm, u16 msg_size,
3943 struct hpi_response_header *phr, u16 res_size, u16 object,
4044 u16 function);
45+
46+#endif /* _HPIMSGINIT_H_ */
sound/pci/asihpi/hpimsgx.c+51−152
@@ -23,6 +23,7 @@ Extended Message Function With Response Cacheing · 22 unmodified lines
2323 #define SOURCEFILE_NAME "hpimsgx.c"
2424 #include "hpi_internal.h"
2525 #include "hpimsginit.h"
26+#include "hpicmn.h"
2627 #include "hpimsgx.h"
2728 #include "hpidebug.h"
2829
@@ -42,22 +43,24 @@ static hpi_handler_func *hpi_lookup_entry_point_function(const struct hpi_pci · 13 unmodified lines
4243
4344 for (i = 0; asihpi_pci_tbl[i].vendor != 0; i++) {
4445 if (asihpi_pci_tbl[i].vendor != PCI_ANY_ID
45− && asihpi_pci_tbl[i].vendor != pci_info->vendor_id)
46+ && asihpi_pci_tbl[i].vendor !=
47+ pci_info->pci_dev->vendor)
4648 continue;
4749 if (asihpi_pci_tbl[i].device != PCI_ANY_ID
48− && asihpi_pci_tbl[i].device != pci_info->device_id)
50+ && asihpi_pci_tbl[i].device !=
51+ pci_info->pci_dev->device)
4952 continue;
5053 if (asihpi_pci_tbl[i].subvendor != PCI_ANY_ID
5154 && asihpi_pci_tbl[i].subvendor !=
52− pci_info->subsys_vendor_id)
55+ pci_info->pci_dev->subsystem_vendor)
5356 continue;
5457 if (asihpi_pci_tbl[i].subdevice != PCI_ANY_ID
5558 && asihpi_pci_tbl[i].subdevice !=
56− pci_info->subsys_device_id)
59+ pci_info->pci_dev->subsystem_device)
5760 continue;
5861
59− HPI_DEBUG_LOG(DEBUG, " %x,%lu\n", i,
60− asihpi_pci_tbl[i].driver_data);
62+ /* HPI_DEBUG_LOG(DEBUG, " %x,%lx\n", i,
63+ asihpi_pci_tbl[i].driver_data); */
6164 return (hpi_handler_func *) asihpi_pci_tbl[i].driver_data;
6265 }
6366
@@ -67,21 +70,12 @@ static hpi_handler_func *hpi_lookup_entry_point_function(const struct hpi_pci · 3 unmodified lines
6770 static inline void hw_entry_point(struct hpi_message *phm,
6871 struct hpi_response *phr)
6972 {
70−
71− hpi_handler_func *ep;
72−
73− if (phm->adapter_index < HPI_MAX_ADAPTERS) {
74− ep = (hpi_handler_func *) hpi_entry_points[phm->
75− adapter_index];
76− if (ep) {
77− HPI_DEBUG_MESSAGE(DEBUG, phm);
78− ep(phm, phr);
79− HPI_DEBUG_RESPONSE(phr);
80− return;
81− }
82− }
83− hpi_init_response(phr, phm->object, phm->function,
84− HPI_ERROR_PROCESSING_MESSAGE);
73+ if ((phm->adapter_index < HPI_MAX_ADAPTERS)
74+ && hpi_entry_points[phm->adapter_index])
75+ hpi_entry_points[phm->adapter_index] (phm, phr);
76+ else
77+ hpi_init_response(phr, phm->object, phm->function,
78+ HPI_ERROR_PROCESSING_MESSAGE);
8579 }
8680
8781 static void adapter_open(struct hpi_message *phm, struct hpi_response *phr);
@@ -100,6 +94,7 @@ static void instream_close(struct hpi_message *phm, struct hpi_response *phr, · 12 unmodified lines
10094 void *h_owner);
10195
10296 static void HPIMSGX__reset(u16 adapter_index);
97+
10398 static u16 HPIMSGX__init(struct hpi_message *phm, struct hpi_response *phr);
10499 static void HPIMSGX__cleanup(u16 adapter_index, void *h_owner);
105100
@@ -153,8 +148,6 @@ static struct hpi_stream_response · 47 unmodified lines
153148
154149 static struct hpi_mixer_response rESP_HPI_MIXER_OPEN[HPI_MAX_ADAPTERS];
155150
156−static struct hpi_subsys_response gRESP_HPI_SUBSYS_FIND_ADAPTERS;
157−
158151 static struct adapter_info aDAPTER_INFO[HPI_MAX_ADAPTERS];
159152
160153 /* use these to keep track of opens from user mode apps/DLLs */
@@ -167,6 +160,11 @@ static struct asi_open_state · 6 unmodified lines
167160 static void subsys_message(struct hpi_message *phm, struct hpi_response *phr,
168161 void *h_owner)
169162 {
163+ if (phm->adapter_index != HPI_ADAPTER_INDEX_INVALID)
164+ HPI_DEBUG_LOG(WARNING,
165+ "suspicious adapter index %d in subsys message 0x%x.\n",
166+ phm->adapter_index, phm->function);
167+
170168 switch (phm->function) {
171169 case HPI_SUBSYS_GET_VERSION:
172170 hpi_init_response(phr, HPI_OBJ_SUBSYSTEM,
@@ -204,85 +202,37 @@ static void subsys_message(struct hpi_message *phm, struct hpi_response *phr, · 31 unmodified lines
204202 HPI_SUBSYS_DRIVER_UNLOAD, 0);
205203 return;
206204
207− case HPI_SUBSYS_GET_INFO:
208− HPI_COMMON(phm, phr);
209− break;
210−
211− case HPI_SUBSYS_FIND_ADAPTERS:
212− memcpy(phr, &gRESP_HPI_SUBSYS_FIND_ADAPTERS,
213− sizeof(gRESP_HPI_SUBSYS_FIND_ADAPTERS));
214− break;
215205 case HPI_SUBSYS_GET_NUM_ADAPTERS:
216− memcpy(phr, &gRESP_HPI_SUBSYS_FIND_ADAPTERS,
217− sizeof(gRESP_HPI_SUBSYS_FIND_ADAPTERS));
218− phr->function = HPI_SUBSYS_GET_NUM_ADAPTERS;
219− break;
220206 case HPI_SUBSYS_GET_ADAPTER:
221− {
222− int count = phm->adapter_index;
223− int index = 0;
224− hpi_init_response(phr, HPI_OBJ_SUBSYSTEM,
225− HPI_SUBSYS_GET_ADAPTER, 0);
226−
227− /* This is complicated by the fact that we want to
228− * "skip" 0's in the adapter list.
229− * First, make sure we are pointing to a
230− * non-zero adapter type.
231− */
232− while (gRESP_HPI_SUBSYS_FIND_ADAPTERS.
233− s.aw_adapter_list[index] == 0) {
234− index++;
235− if (index >= HPI_MAX_ADAPTERS)
236− break;
237− }
238− while (count) {
239− /* move on to the next adapter */
240− index++;
241− if (index >= HPI_MAX_ADAPTERS)
242− break;
243− while (gRESP_HPI_SUBSYS_FIND_ADAPTERS.
244− s.aw_adapter_list[index] == 0) {
245− index++;
246− if (index >= HPI_MAX_ADAPTERS)
247− break;
248− }
249− count--;
250− }
207+ HPI_COMMON(phm, phr);
208+ break;
251209
252− if (index < HPI_MAX_ADAPTERS) {
253− phr->u.s.adapter_index = (u16)index;
254− phr->u.s.aw_adapter_list[0] =
255− gRESP_HPI_SUBSYS_FIND_ADAPTERS.
256− s.aw_adapter_list[index];
257− } else {
258− phr->u.s.adapter_index = 0;
259− phr->u.s.aw_adapter_list[0] = 0;
260− phr->error = HPI_ERROR_BAD_ADAPTER_NUMBER;
261− }
262− break;
263− }
264210 case HPI_SUBSYS_CREATE_ADAPTER:
265211 HPIMSGX__init(phm, phr);
266212 break;
213+
267214 case HPI_SUBSYS_DELETE_ADAPTER:
268− HPIMSGX__cleanup(phm->adapter_index, h_owner);
215+ HPIMSGX__cleanup(phm->obj_index, h_owner);
269216 {
270217 struct hpi_message hm;
271218 struct hpi_response hr;
272− /* call to HPI_ADAPTER_CLOSE */
273219 hpi_init_message_response(&hm, &hr, HPI_OBJ_ADAPTER,
274220 HPI_ADAPTER_CLOSE);
275− hm.adapter_index = phm->adapter_index;
221+ hm.adapter_index = phm->obj_index;
276222 hw_entry_point(&hm, &hr);
277223 }
278− hw_entry_point(phm, phr);
279− gRESP_HPI_SUBSYS_FIND_ADAPTERS.s.
280− aw_adapter_list[phm->adapter_index]
281− = 0;
282− hpi_entry_points[phm->adapter_index] = NULL;
224+ if ((phm->obj_index < HPI_MAX_ADAPTERS)
225+ && hpi_entry_points[phm->obj_index]) {
226+ hpi_entry_points[phm->obj_index] (phm, phr);
227+ hpi_entry_points[phm->obj_index] = NULL;
228+ } else
229+ phr->error = HPI_ERROR_INVALID_OBJ_INDEX;
230+
283231 break;
284232 default:
285− hw_entry_point(phm, phr);
233+ /* Must explicitly handle every subsys message in this switch */
234+ hpi_init_response(phr, HPI_OBJ_SUBSYSTEM, phm->function,
235+ HPI_ERROR_INVALID_FUNC);
286236 break;
287237 }
288238 }
@@ -409,33 +359,7 @@ void hpi_send_recv_ex(struct hpi_message *phm, struct hpi_response *phr, · 120 unmodified lines
409359 break;
410360 }
411361 HPI_DEBUG_RESPONSE(phr);
412−#if 1
413− if (phr->error >= HPI_ERROR_BACKEND_BASE) {
414− void *ep = NULL;
415− char *ep_name;
416−
417− HPI_DEBUG_MESSAGE(ERROR, phm);
418−
419− if (phm->adapter_index < HPI_MAX_ADAPTERS)
420− ep = hpi_entry_points[phm->adapter_index];
421−
422− /* Don't need this? Have adapter index in debug info
423− Know at driver load time index->backend mapping */
424− if (ep == HPI_6000)
425− ep_name = "HPI_6000";
426− else if (ep == HPI_6205)
427− ep_name = "HPI_6205";
428− else
429− ep_name = "unknown";
430−
431− HPI_DEBUG_LOG(ERROR, "HPI %s response - error# %d\n", ep_name,
432− phr->error);
433−
434− if (hpi_debug_level >= HPI_DEBUG_LEVEL_VERBOSE)
435− hpi_debug_data((u16 *)phm,
436− sizeof(*phm) / sizeof(u16));
437− }
438−#endif
362+
439363 }
440364
441365 static void adapter_open(struct hpi_message *phm, struct hpi_response *phr)
@@ -484,7 +408,7 @@ static void instream_open(struct hpi_message *phm, struct hpi_response *phr, · 42 unmodified lines
484408 else {
485409 instream_user_open[phm->adapter_index][phm->
486410 obj_index].open_flag = 1;
487− hpios_msgxlock_un_lock(&msgx_lock);
411+ hpios_msgxlock_unlock(&msgx_lock);
488412
489413 /* issue a reset */
490414 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
@@ -509,7 +433,7 @@ static void instream_open(struct hpi_message *phm, struct hpi_response *phr, · 18 unmodified lines
509433 sizeof(rESP_HPI_ISTREAM_OPEN[0][0]));
510434 }
511435 }
512− hpios_msgxlock_un_lock(&msgx_lock);
436+ hpios_msgxlock_unlock(&msgx_lock);
513437 }
514438
515439 static void instream_close(struct hpi_message *phm, struct hpi_response *phr,
@@ -530,7 +454,7 @@ static void instream_close(struct hpi_message *phm, struct hpi_response *phr, · 14 unmodified lines
530454 phm->wAdapterIndex, phm->wObjIndex, hOwner); */
531455 instream_user_open[phm->adapter_index][phm->
532456 obj_index].h_owner = NULL;
533− hpios_msgxlock_un_lock(&msgx_lock);
457+ hpios_msgxlock_unlock(&msgx_lock);
534458 /* issue a reset */
535459 hpi_init_message_response(&hm, &hr, HPI_OBJ_ISTREAM,
536460 HPI_ISTREAM_RESET);
@@ -556,7 +480,7 @@ static void instream_close(struct hpi_message *phm, struct hpi_response *phr, · 19 unmodified lines
556480 obj_index].h_owner);
557481 phr->error = HPI_ERROR_OBJ_NOT_OPEN;
558482 }
559− hpios_msgxlock_un_lock(&msgx_lock);
483+ hpios_msgxlock_unlock(&msgx_lock);
560484 }
561485
562486 static void outstream_open(struct hpi_message *phm, struct hpi_response *phr,
@@ -581,7 +505,7 @@ static void outstream_open(struct hpi_message *phm, struct hpi_response *phr, · 18 unmodified lines
581505 else {
582506 outstream_user_open[phm->adapter_index][phm->
583507 obj_index].open_flag = 1;
584− hpios_msgxlock_un_lock(&msgx_lock);
508+ hpios_msgxlock_unlock(&msgx_lock);
585509
586510 /* issue a reset */
587511 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
@@ -606,7 +530,7 @@ static void outstream_open(struct hpi_message *phm, struct hpi_response *phr, · 18 unmodified lines
606530 sizeof(rESP_HPI_OSTREAM_OPEN[0][0]));
607531 }
608532 }
609− hpios_msgxlock_un_lock(&msgx_lock);
533+ hpios_msgxlock_unlock(&msgx_lock);
610534 }
611535
612536 static void outstream_close(struct hpi_message *phm, struct hpi_response *phr,
@@ -628,7 +552,7 @@ static void outstream_close(struct hpi_message *phm, struct hpi_response *phr, · 15 unmodified lines
628552 phm->wAdapterIndex, phm->wObjIndex, hOwner); */
629553 outstream_user_open[phm->adapter_index][phm->
630554 obj_index].h_owner = NULL;
631− hpios_msgxlock_un_lock(&msgx_lock);
555+ hpios_msgxlock_unlock(&msgx_lock);
632556 /* issue a reset */
633557 hpi_init_message_response(&hm, &hr, HPI_OBJ_OSTREAM,
634558 HPI_OSTREAM_RESET);
@@ -654,7 +578,7 @@ static void outstream_close(struct hpi_message *phm, struct hpi_response *phr, · 19 unmodified lines
654578 obj_index].h_owner);
655579 phr->error = HPI_ERROR_OBJ_NOT_OPEN;
656580 }
657− hpios_msgxlock_un_lock(&msgx_lock);
581+ hpios_msgxlock_unlock(&msgx_lock);
658582 }
659583
660584 static u16 adapter_prepare(u16 adapter)
@@ -683,16 +607,9 @@ static u16 adapter_prepare(u16 adapter) · 22 unmodified lines
683607 if (hr.error)
684608 return hr.error;
685609
686− aDAPTER_INFO[adapter].num_outstreams = hr.u.a.num_outstreams;
687− aDAPTER_INFO[adapter].num_instreams = hr.u.a.num_instreams;
688− aDAPTER_INFO[adapter].type = hr.u.a.adapter_type;
689−
690− gRESP_HPI_SUBSYS_FIND_ADAPTERS.s.aw_adapter_list[adapter] =
691− hr.u.a.adapter_type;
692− gRESP_HPI_SUBSYS_FIND_ADAPTERS.s.num_adapters++;
693− if (gRESP_HPI_SUBSYS_FIND_ADAPTERS.s.num_adapters > HPI_MAX_ADAPTERS)
694− gRESP_HPI_SUBSYS_FIND_ADAPTERS.s.num_adapters =
695− HPI_MAX_ADAPTERS;
610+ aDAPTER_INFO[adapter].num_outstreams = hr.u.ax.info.num_outstreams;
611+ aDAPTER_INFO[adapter].num_instreams = hr.u.ax.info.num_instreams;
612+ aDAPTER_INFO[adapter].type = hr.u.ax.info.adapter_type;
696613
697614 /* call to HPI_OSTREAM_OPEN */
698615 for (i = 0; i < aDAPTER_INFO[adapter].num_outstreams; i++) {
@@ -727,7 +644,7 @@ static u16 adapter_prepare(u16 adapter) · 28 unmodified lines
727644 memcpy(&rESP_HPI_MIXER_OPEN[adapter], &hr,
728645 sizeof(rESP_HPI_MIXER_OPEN[0]));
729646
730− return gRESP_HPI_SUBSYS_FIND_ADAPTERS.h.error;
647+ return 0;
731648 }
732649
733650 static void HPIMSGX__reset(u16 adapter_index)
@@ -737,12 +654,6 @@ static void HPIMSGX__reset(u16 adapter_index) · 3 unmodified lines
737654 struct hpi_response hr;
738655
739656 if (adapter_index == HPIMSGX_ALLADAPTERS) {
740− /* reset all responses to contain errors */
741− hpi_init_response(&hr, HPI_OBJ_SUBSYSTEM,
742− HPI_SUBSYS_FIND_ADAPTERS, 0);
743− memcpy(&gRESP_HPI_SUBSYS_FIND_ADAPTERS, &hr,
744− sizeof(gRESP_HPI_SUBSYS_FIND_ADAPTERS));
745−
746657 for (adapter = 0; adapter < HPI_MAX_ADAPTERS; adapter++) {
747658
748659 hpi_init_response(&hr, HPI_OBJ_ADAPTER,
@@ -783,12 +694,6 @@ static void HPIMSGX__reset(u16 adapter_index) · 34 unmodified lines
783694 rESP_HPI_ISTREAM_OPEN[adapter_index][i].h.error =
784695 HPI_ERROR_INVALID_OBJ;
785696 }
786− if (gRESP_HPI_SUBSYS_FIND_ADAPTERS.
787− s.aw_adapter_list[adapter_index]) {
788− gRESP_HPI_SUBSYS_FIND_ADAPTERS.
789− s.aw_adapter_list[adapter_index] = 0;
790− gRESP_HPI_SUBSYS_FIND_ADAPTERS.s.num_adapters--;
791− }
792697 }
793698 }
794699
@@ -802,15 +707,9 @@ static u16 HPIMSGX__init(struct hpi_message *phm, · 7 unmodified lines
802707 hpi_handler_func *entry_point_func;
803708 struct hpi_response hr;
804709
805− if (gRESP_HPI_SUBSYS_FIND_ADAPTERS.s.num_adapters >= HPI_MAX_ADAPTERS)
806− return HPI_ERROR_BAD_ADAPTER_NUMBER;
807−
808710 /* Init response here so we can pass in previous adapter list */
809711 hpi_init_response(&hr, phm->object, phm->function,
810712 HPI_ERROR_INVALID_OBJ);
811− memcpy(hr.u.s.aw_adapter_list,
812− gRESP_HPI_SUBSYS_FIND_ADAPTERS.s.aw_adapter_list,
813− sizeof(gRESP_HPI_SUBSYS_FIND_ADAPTERS.s.aw_adapter_list));
814713
815714 entry_point_func =
816715 hpi_lookup_entry_point_function(phm->u.s.resource.r.pci);
@@ -860,7 +759,7 @@ static void HPIMSGX__cleanup(u16 adapter_index, void *h_owner) · 43 unmodified lines
860759 struct hpi_response hr;
861760
862761 HPI_DEBUG_LOG(DEBUG,
863− "close adapter %d ostream %d\n",
762+ "Close adapter %d ostream %d\n",
864763 adapter, i);
865764
866765 hpi_init_message_response(&hm, &hr,
@@ -884,7 +783,7 @@ static void HPIMSGX__cleanup(u16 adapter_index, void *h_owner) · 17 unmodified lines
884783 struct hpi_response hr;
885784
886785 HPI_DEBUG_LOG(DEBUG,
887− "close adapter %d istream %d\n",
786+ "Close adapter %d istream %d\n",
888787 adapter, i);
889788
890789 hpi_init_message_response(&hm, &hr,
sound/pci/asihpi/hpioctl.c+46−44
@@ -30,6 +30,7 @@ Common Linux HPI ioctl and module probe/remove functions · 29 unmodified lines
3030 #include <linux/slab.h>
3131 #include <linux/moduleparam.h>
3232 #include <asm/uaccess.h>
33+#include <linux/pci.h>
3334 #include <linux/stringify.h>
3435
3536 #ifdef MODULE_FIRMWARE
@@ -45,7 +46,7 @@ MODULE_FIRMWARE("asihpi/dsp8900.bin"); · 9 unmodified lines
4546 static int prealloc_stream_buf;
4647 module_param(prealloc_stream_buf, int, S_IRUGO);
4748 MODULE_PARM_DESC(prealloc_stream_buf,
48− "preallocate size for per-adapter stream buffer");
49+ "Preallocate size for per-adapter stream buffer");
4950
5051 /* Allow the debug level to be changed after module load.
5152 E.g. echo 2 > /sys/module/asihpi/parameters/hpiDebugLevel
@@ -121,8 +122,8 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg) · 69 unmodified lines
121122 phpi_ioctl_data = (struct hpi_ioctl_linux __user *)arg;
122123
123124 /* Read the message and response pointers from user space. */
124− if (get_user(puhm, &phpi_ioctl_data->phm) ||
125− get_user(puhr, &phpi_ioctl_data->phr)) {
125+ if (get_user(puhm, &phpi_ioctl_data->phm)
126+ || get_user(puhr, &phpi_ioctl_data->phr)) {
126127 err = -EFAULT;
127128 goto out;
128129 }
@@ -135,7 +136,7 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg) · 6 unmodified lines
135136 if (hm->h.size > sizeof(*hm))
136137 hm->h.size = sizeof(*hm);
137138
138− /*printk(KERN_INFO "message size %d\n", hm->h.wSize); */
139+ /* printk(KERN_INFO "message size %d\n", hm->h.wSize); */
139140
140141 uncopied_bytes = copy_from_user(hm, puhm, hm->h.size);
141142 if (uncopied_bytes) {
@@ -155,8 +156,13 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg) · 13 unmodified lines
155156 goto out;
156157 }
157158
159+ if (hm->h.adapter_index >= HPI_MAX_ADAPTERS) {
160+ err = -EINVAL;
161+ goto out;
162+ }
163+
158164 pa = &adapters[hm->h.adapter_index];
159− hr->h.size = 0;
165+ hr->h.size = res_max_size;
160166 if (hm->h.object == HPI_OBJ_SUBSYSTEM) {
161167 switch (hm->h.function) {
162168 case HPI_SUBSYS_CREATE_ADAPTER:
@@ -216,7 +222,7 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg) · 53 unmodified lines
216222 */
217223 if (pa->buffer_size < size) {
218224 HPI_DEBUG_LOG(DEBUG,
219− "realloc adapter %d stream "
225+ "Realloc adapter %d stream "
220226 "buffer from %zd to %d\n",
221227 hm->h.adapter_index,
222228 pa->buffer_size, size);
@@ -259,7 +265,7 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg) · 36 unmodified lines
259265 copy_from_user(pa->p_buffer, ptr, size);
260266 if (uncopied_bytes)
261267 HPI_DEBUG_LOG(WARNING,
262− "missed %d of %d "
268+ "Missed %d of %d "
263269 "bytes from user\n", uncopied_bytes,
264270 size);
265271 }
@@ -271,7 +277,7 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg) · 5 unmodified lines
271277 copy_to_user(ptr, pa->p_buffer, size);
272278 if (uncopied_bytes)
273279 HPI_DEBUG_LOG(WARNING,
274− "missed %d of %d " "bytes to user\n",
280+ "Missed %d of %d " "bytes to user\n",
275281 uncopied_bytes, size);
276282 }
277283
@@ -290,9 +296,9 @@ long asihpi_hpi_ioctl(struct file *file, unsigned int cmd, unsigned long arg) · 12 unmodified lines
290296 if (hr->h.size > res_max_size) {
291297 HPI_DEBUG_LOG(ERROR, "response too big %d %d\n", hr->h.size,
292298 res_max_size);
293− /*HPI_DEBUG_MESSAGE(ERROR, hm); */
294− err = -EFAULT;
295− goto out;
299+ hr->h.error = HPI_ERROR_RESPONSE_BUFFER_TOO_SMALL;
300+ hr->h.specific_error = hr->h.size;
301+ hr->h.size = sizeof(hr->h);
296302 }
297303
298304 uncopied_bytes = copy_to_user(puhr, hr, hr->h.size);
@@ -320,18 +326,26 @@ int __devinit asihpi_adapter_probe(struct pci_dev *pci_dev, · 21 unmodified lines
320326
321327 memset(&adapter, 0, sizeof(adapter));
322328
323− printk(KERN_DEBUG "probe PCI device (%04x:%04x,%04x:%04x,%04x)\n",
324− pci_dev->vendor, pci_dev->device, pci_dev->subsystem_vendor,
329+ dev_printk(KERN_DEBUG, &pci_dev->dev,
330+ "probe %04x:%04x,%04x:%04x,%04x\n", pci_dev->vendor,
331+ pci_dev->device, pci_dev->subsystem_vendor,
325332 pci_dev->subsystem_device, pci_dev->devfn);
326333
334+ if (pci_enable_device(pci_dev) < 0) {
335+ dev_printk(KERN_ERR, &pci_dev->dev,
336+ "pci_enable_device failed, disabling device\n");
337+ return -EIO;
338+ }
339+
340+ pci_set_master(pci_dev); /* also sets latency timer if < 16 */
341+
327342 hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM,
328343 HPI_SUBSYS_CREATE_ADAPTER);
329344 hpi_init_response(&hr, HPI_OBJ_SUBSYSTEM, HPI_SUBSYS_CREATE_ADAPTER,
330345 HPI_ERROR_PROCESSING_MESSAGE);
331346
332− hm.adapter_index = -1; /* an invalid index */
347+ hm.adapter_index = HPI_ADAPTER_INDEX_INVALID;
333348
334− /* fill in HPI_PCI information from kernel provided information */
335349 adapter.pci = pci_dev;
336350
337351 nm = HPI_MAX_ADAPTER_MEM_SPACES;
@@ -359,19 +373,7 @@ int __devinit asihpi_adapter_probe(struct pci_dev *pci_dev, · 21 unmodified lines
359373 pci.ap_mem_base[idx] = adapter.ap_remapped_mem_base[idx];
360374 }
361375
362− /* could replace Pci with direct pointer to pci_dev for linux
363− Instead wrap accessor functions for IDs etc.
364− Would it work for windows?
365− */
366− pci.bus_number = pci_dev->bus->number;
367− pci.vendor_id = (u16)pci_dev->vendor;
368− pci.device_id = (u16)pci_dev->device;
369− pci.subsys_vendor_id = (u16)(pci_dev->subsystem_vendor & 0xffff);
370− pci.subsys_device_id = (u16)(pci_dev->subsystem_device & 0xffff);
371− pci.device_number = pci_dev->devfn;
372− pci.interrupt = pci_dev->irq;
373− pci.p_os_data = pci_dev;
374−
376+ pci.pci_dev = pci_dev;
375377 hm.u.s.resource.bus_type = HPI_BUS_PCI;
376378 hm.u.s.resource.r.pci = &pci;
377379
@@ -392,10 +394,10 @@ int __devinit asihpi_adapter_probe(struct pci_dev *pci_dev, · 14 unmodified lines
392394 }
393395
394396 adapter.index = hr.u.s.adapter_index;
395− adapter.type = hr.u.s.aw_adapter_list[adapter.index];
397+ adapter.type = hr.u.s.adapter_type;
396398 hm.adapter_index = adapter.index;
397399
398− err = hpi_adapter_open(NULL, adapter.index);
400+ err = hpi_adapter_open(adapter.index);
399401 if (err)
400402 goto err;
401403
@@ -407,8 +409,9 @@ int __devinit asihpi_adapter_probe(struct pci_dev *pci_dev, · 5 unmodified lines
407409 mutex_init(&adapters[adapter.index].mutex);
408410 pci_set_drvdata(pci_dev, &adapters[adapter.index]);
409411
410− printk(KERN_INFO "probe found adapter ASI%04X HPI index #%d.\n",
411− adapter.type, adapter.index);
412+ dev_printk(KERN_INFO, &pci_dev->dev,
413+ "probe succeeded for ASI%04X HPI index %d\n", adapter.type,
414+ adapter.index);
412415
413416 return 0;
414417
@@ -439,7 +442,8 @@ void __devexit asihpi_adapter_remove(struct pci_dev *pci_dev) · 24 unmodified lines
439442
440443 hpi_init_message_response(&hm, &hr, HPI_OBJ_SUBSYSTEM,
441444 HPI_SUBSYS_DELETE_ADAPTER);
442− hm.adapter_index = pa->index;
445+ hm.obj_index = pa->index;
446+ hm.adapter_index = HPI_ADAPTER_INDEX_INVALID;
443447 hpi_send_recv_ex(&hm, &hr, HOWNER_KERNEL);
444448
445449 /* unmap PCI memory space, mapped during device init. */
@@ -450,20 +454,18 @@ void __devexit asihpi_adapter_remove(struct pci_dev *pci_dev) · 4 unmodified lines
450454 }
451455 }
452456
453− if (pa->p_buffer) {
454− pa->buffer_size = 0;
457+ if (pa->p_buffer)
455458 vfree(pa->p_buffer);
456− }
457459
458460 pci_set_drvdata(pci_dev, NULL);
459− /*
460− printk(KERN_INFO "PCI device (%04x:%04x,%04x:%04x,%04x),"
461− " HPI index # %d, removed.\n",
462− pci_dev->vendor, pci_dev->device,
463− pci_dev->subsystem_vendor,
464− pci_dev->subsystem_device, pci_dev->devfn,
465− pa->index);
466− */
461+ if (1)
462+ dev_printk(KERN_INFO, &pci_dev->dev,
463+ "remove %04x:%04x,%04x:%04x,%04x," " HPI index %d.\n",
464+ pci_dev->vendor, pci_dev->device,
465+ pci_dev->subsystem_vendor, pci_dev->subsystem_device,
466+ pci_dev->devfn, pa->index);
467+
468+ memset(pa, 0, sizeof(*pa));
467469 }
468470
469471 void __init asihpi_init(void)
sound/pci/asihpi/hpios.h+4−6
@@ -27,9 +27,7 @@ HPI Operating System Specific macros for Linux Kernel driver · 26 unmodified lines
2727 #define HPI_OS_LINUX_KERNEL
2828
2929 #define HPI_OS_DEFINED
30−#define HPI_KERNEL_MODE
31−
32−#define HPI_REASSIGN_DUPLICATE_ADAPTER_IDX
30+#define HPI_BUILD_KERNEL_MODE
3331
3432 #include <linux/io.h>
3533 #include <asm/system.h>
@@ -135,20 +133,20 @@ static inline void cond_unlock(struct hpios_spinlock *l) · 99 unmodified lines
135133
136134 #define hpios_msgxlock_init(obj) spin_lock_init(&(obj)->lock)
137135 #define hpios_msgxlock_lock(obj) cond_lock(obj)
138−#define hpios_msgxlock_un_lock(obj) cond_unlock(obj)
136+#define hpios_msgxlock_unlock(obj) cond_unlock(obj)
139137
140138 #define hpios_dsplock_init(obj) spin_lock_init(&(obj)->dsp_lock.lock)
141139 #define hpios_dsplock_lock(obj) cond_lock(&(obj)->dsp_lock)
142140 #define hpios_dsplock_unlock(obj) cond_unlock(&(obj)->dsp_lock)
143141
144142 #ifdef CONFIG_SND_DEBUG
145−#define HPI_DEBUG
143+#define HPI_BUILD_DEBUG
146144 #endif
147145
148146 #define HPI_ALIST_LOCKING
149147 #define hpios_alistlock_init(obj) spin_lock_init(&((obj)->list_lock.lock))
150148 #define hpios_alistlock_lock(obj) spin_lock(&((obj)->list_lock.lock))
151−#define hpios_alistlock_un_lock(obj) spin_unlock(&((obj)->list_lock.lock))
149+#define hpios_alistlock_unlock(obj) spin_unlock(&((obj)->list_lock.lock))
152150
153151 struct hpi_adapter {
154152 /* mutex prevents contention for one card
sound/pci/atiixp.c+1−1
@@ -522,7 +522,7 @@ static int snd_atiixp_aclink_reset(struct atiixp *chip) · 521 unmodified lines
522522 atiixp_read(chip, CMD);
523523 mdelay(1);
524524 atiixp_update(chip, CMD, ATI_REG_CMD_AC_RESET, ATI_REG_CMD_AC_RESET);
525− if (--timeout) {
525+ if (!--timeout) {
526526 snd_printk(KERN_ERR "atiixp: codec reset timeout\n");
527527 break;
528528 }
sound/pci/atiixp_modem.c+1−1
@@ -498,7 +498,7 @@ static int snd_atiixp_aclink_reset(struct atiixp_modem *chip) · 497 unmodified lines
498498 atiixp_read(chip, CMD);
499499 msleep(1);
500500 atiixp_update(chip, CMD, ATI_REG_CMD_AC_RESET, ATI_REG_CMD_AC_RESET);
501− if (--timeout) {
501+ if (!--timeout) {
502502 snd_printk(KERN_ERR "atiixp-modem: codec reset timeout\n");
503503 break;
504504 }
sound/pci/au88x0/au88x0_eq.c+2−1
@@ -896,7 +896,8 @@ static int __devinit vortex_eq_init(vortex_t * vortex) · 895 unmodified lines
896896 if ((kcontrol =
897897 snd_ctl_new1(&vortex_eq_kcontrol, vortex)) == NULL)
898898 return -ENOMEM;
899− strcpy(kcontrol->id.name, EqBandLabels[i]);
899+ snprintf(kcontrol->id.name, sizeof(kcontrol->id.name),
900+ "%s Playback Volume", EqBandLabels[i]);
900901 kcontrol->private_value = i;
901902 if ((err = snd_ctl_add(vortex->card, kcontrol)) < 0)
902903 return err;
sound/pci/azt3328.c+402−48
@@ -1,6 +1,5 @@
1−/*
2− * azt3328.c - driver for Aztech AZF3328 based soundcards (e.g. PCI168).
3− * Copyright (C) 2002, 2005 - 2010 by Andreas Mohr <andi AT lisas.de>
1+/* azt3328.c - driver for Aztech AZF3328 based soundcards (e.g. PCI168).
2+ * Copyright (C) 2002, 2005 - 2011 by Andreas Mohr <andi AT lisas.de>
43 *
54 * Framework borrowed from Bart Hartgers's als4000.c.
65 * Driver developed on PCI168 AP(W) version (PCI rev. 10, subsystem ID 1801),
@@ -66,6 +65,13 @@ · 59 unmodified lines
6665 * addresses illegally. So far unfortunately it looks like the very flexible
6766 * ALSA AC97 support is still not enough to easily compensate for such a
6867 * grave layout violation despite all tweaks and quirks mechanisms it offers.
68+ * Well, not quite: now ac97 layer is much improved (bus-specific ops!),
69+ * thus I was able to implement support - it's actually working quite well.
70+ * An interesting item might be Aztech AMR 2800-W, since it's an AC97
71+ * modem card which might reveal the Aztech-specific codec ID which
72+ * we might want to pretend, too. Dito PCI168's brother, PCI368,
73+ * where the advertising datasheet says it's AC97-based and has a
74+ * Digital Enhanced Game Port.
6975 * - builtin genuine OPL3 - verified to work fine, 20080506
7076 * - full duplex 16bit playback/record at independent sampling rate
7177 * - MPU401 (+ legacy address support, claimed by one official spec sheet)
@@ -189,6 +195,16 @@ · 117 unmodified lines
189195 #include <sound/mpu401.h>
190196 #include <sound/opl3.h>
191197 #include <sound/initval.h>
198+/*
199+ * Config switch, to use ALSA's AC97 layer instead of old custom mixer crap.
200+ * If the AC97 compatibility parts we needed to implement locally turn out
201+ * to work nicely, then remove the old implementation eventually.
202+ */
203+#define AZF_USE_AC97_LAYER 1
204+
205+#ifdef AZF_USE_AC97_LAYER
206+#include <sound/ac97_codec.h>
207+#endif
192208 #include "azt3328.h"
193209
194210 MODULE_AUTHOR("Andreas Mohr <andi AT lisas.de>");
@@ -328,6 +344,10 @@ struct snd_azf3328 { · 133 unmodified lines
328344 /* playback, recording and I2S out codecs */
329345 struct snd_azf3328_codec_data codecs[3];
330346
347+#ifdef AZF_USE_AC97_LAYER
348+ struct snd_ac97 *ac97;
349+#endif
350+
331351 struct snd_card *card;
332352 struct snd_rawmidi *rmidi;
333353
@@ -506,7 +526,7 @@ snd_azf3328_mixer_inw(const struct snd_azf3328 *chip, unsigned reg) · 172 unmodified lines
506526 #define AZF_MUTE_BIT 0x80
507527
508528 static bool
509−snd_azf3328_mixer_set_mute(const struct snd_azf3328 *chip,
529+snd_azf3328_mixer_mute_control(const struct snd_azf3328 *chip,
510530 unsigned reg, bool do_mute
511531 )
512532 {
@@ -521,6 +541,323 @@ snd_azf3328_mixer_set_mute(const struct snd_azf3328 *chip, · 8 unmodified lines
521541 return (do_mute) ? !updated : updated;
522542 }
523543
544+static inline bool
545+snd_azf3328_mixer_mute_control_master(const struct snd_azf3328 *chip,
546+ bool do_mute
547+)
548+{
549+ return snd_azf3328_mixer_mute_control(
550+ chip,
551+ IDX_MIXER_PLAY_MASTER,
552+ do_mute
553+ );
554+}
555+
556+static inline bool
557+snd_azf3328_mixer_mute_control_pcm(const struct snd_azf3328 *chip,
558+ bool do_mute
559+)
560+{
561+ return snd_azf3328_mixer_mute_control(
562+ chip,
563+ IDX_MIXER_WAVEOUT,
564+ do_mute
565+ );
566+}
567+
568+static inline void
569+snd_azf3328_mixer_reset(const struct snd_azf3328 *chip)
570+{
571+ /* reset (close) mixer:
572+ * first mute master volume, then reset
573+ */
574+ snd_azf3328_mixer_mute_control_master(chip, 1);
575+ snd_azf3328_mixer_outw(chip, IDX_MIXER_RESET, 0x0000);
576+}
577+
578+#ifdef AZF_USE_AC97_LAYER
579+
580+static inline void
581+snd_azf3328_mixer_ac97_map_unsupported(unsigned short reg, const char *mode)
582+{
583+ /* need to add some more or less clever emulation? */
584+ printk(KERN_WARNING
585+ "azt3328: missing %s emulation for AC97 register 0x%02x!\n",
586+ mode, reg);
587+}
588+
589+/*
590+ * Need to have _special_ AC97 mixer hardware register index mapper,
591+ * to compensate for the issue of a rather AC97-incompatible hardware layout.
592+ */
593+#define AZF_REG_MASK 0x3f
594+#define AZF_AC97_REG_UNSUPPORTED 0x8000
595+#define AZF_AC97_REG_REAL_IO_READ 0x4000
596+#define AZF_AC97_REG_REAL_IO_WRITE 0x2000
597+#define AZF_AC97_REG_REAL_IO_RW \
598+ (AZF_AC97_REG_REAL_IO_READ | AZF_AC97_REG_REAL_IO_WRITE)
599+#define AZF_AC97_REG_EMU_IO_READ 0x0400
600+#define AZF_AC97_REG_EMU_IO_WRITE 0x0200
601+#define AZF_AC97_REG_EMU_IO_RW \
602+ (AZF_AC97_REG_EMU_IO_READ | AZF_AC97_REG_EMU_IO_WRITE)
603+static unsigned short
604+snd_azf3328_mixer_ac97_map_reg_idx(unsigned short reg)
605+{
606+ static const struct {
607+ unsigned short azf_reg;
608+ } azf_reg_mapper[] = {
609+ /* Especially when taking into consideration
610+ * mono/stereo-based sequence of azf vs. AC97 control series,
611+ * it's quite obvious that azf simply got rid
612+ * of the AC97_HEADPHONE control at its intended offset,
613+ * thus shifted _all_ controls by one,
614+ * and _then_ simply added it as an FMSYNTH control at the end,
615+ * to make up for the offset.
616+ * This means we'll have to translate indices here as
617+ * needed and then do some tiny AC97 patch action
618+ * (snd_ac97_rename_vol_ctl() etc.) - that's it.
619+ */
620+ { /* AC97_RESET */ IDX_MIXER_RESET
621+ | AZF_AC97_REG_REAL_IO_WRITE
622+ | AZF_AC97_REG_EMU_IO_READ },
623+ { /* AC97_MASTER */ IDX_MIXER_PLAY_MASTER },
624+ /* note large shift: AC97_HEADPHONE to IDX_MIXER_FMSYNTH! */
625+ { /* AC97_HEADPHONE */ IDX_MIXER_FMSYNTH },
626+ { /* AC97_MASTER_MONO */ IDX_MIXER_MODEMOUT },
627+ { /* AC97_MASTER_TONE */ IDX_MIXER_BASSTREBLE },
628+ { /* AC97_PC_BEEP */ IDX_MIXER_PCBEEP },
629+ { /* AC97_PHONE */ IDX_MIXER_MODEMIN },
630+ { /* AC97_MIC */ IDX_MIXER_MIC },
631+ { /* AC97_LINE */ IDX_MIXER_LINEIN },
632+ { /* AC97_CD */ IDX_MIXER_CDAUDIO },
633+ { /* AC97_VIDEO */ IDX_MIXER_VIDEO },
634+ { /* AC97_AUX */ IDX_MIXER_AUX },
635+ { /* AC97_PCM */ IDX_MIXER_WAVEOUT },
636+ { /* AC97_REC_SEL */ IDX_MIXER_REC_SELECT },
637+ { /* AC97_REC_GAIN */ IDX_MIXER_REC_VOLUME },
638+ { /* AC97_REC_GAIN_MIC */ AZF_AC97_REG_EMU_IO_RW },
639+ { /* AC97_GENERAL_PURPOSE */ IDX_MIXER_ADVCTL2 },
640+ { /* AC97_3D_CONTROL */ IDX_MIXER_ADVCTL1 },
641+ };
642+
643+ unsigned short reg_azf = AZF_AC97_REG_UNSUPPORTED;
644+
645+ /* azf3328 supports the low-numbered and low-spec:ed range
646+ of AC97 regs only */
647+ if (reg <= AC97_3D_CONTROL) {
648+ unsigned short reg_idx = reg / 2;
649+ reg_azf = azf_reg_mapper[reg_idx].azf_reg;
650+ /* a translation-only entry means it's real read/write: */
651+ if (!(reg_azf & ~AZF_REG_MASK))
652+ reg_azf |= AZF_AC97_REG_REAL_IO_RW;
653+ } else {
654+ switch (reg) {
655+ case AC97_POWERDOWN:
656+ reg_azf = AZF_AC97_REG_EMU_IO_RW;
657+ break;
658+ case AC97_EXTENDED_ID:
659+ reg_azf = AZF_AC97_REG_EMU_IO_READ;
660+ break;
661+ case AC97_EXTENDED_STATUS:
662+ /* I don't know what the h*ll AC97 layer
663+ * would consult this _extended_ register for
664+ * given a base-AC97-advertised card,
665+ * but let's just emulate it anyway :-P
666+ */
667+ reg_azf = AZF_AC97_REG_EMU_IO_RW;
668+ break;
669+ case AC97_VENDOR_ID1:
670+ case AC97_VENDOR_ID2:
671+ reg_azf = AZF_AC97_REG_EMU_IO_READ;
672+ break;
673+ }
674+ }
675+ return reg_azf;
676+}
677+
678+static const unsigned short
679+azf_emulated_ac97_caps =
680+ AC97_BC_DEDICATED_MIC |
681+ AC97_BC_BASS_TREBLE |
682+ /* Headphone is an FM Synth control here */
683+ AC97_BC_HEADPHONE |
684+ /* no AC97_BC_LOUDNESS! */
685+ /* mask 0x7c00 is
686+ vendor-specific 3D enhancement
687+ vendor indicator.
688+ Since there actually _is_ an
689+ entry for Aztech Labs
690+ (13), make damn sure
691+ to indicate it. */
692+ (13 << 10);
693+
694+static const unsigned short
695+azf_emulated_ac97_powerdown =
696+ /* pretend everything to be active */
697+ AC97_PD_ADC_STATUS |
698+ AC97_PD_DAC_STATUS |
699+ AC97_PD_MIXER_STATUS |
700+ AC97_PD_VREF_STATUS;
701+
702+/*
703+ * Emulated, _inofficial_ vendor ID
704+ * (there might be some devices such as the MR 2800-W
705+ * which could reveal the real Aztech AC97 ID).
706+ * We choose to use "AZT" prefix, and then use 1 to indicate PCI168
707+ * (better don't use 0x68 since there's a PCI368 as well).
708+ */
709+static const unsigned int
710+azf_emulated_ac97_vendor_id = 0x415a5401;
711+
712+static unsigned short
713+snd_azf3328_mixer_ac97_read(struct snd_ac97 *ac97, unsigned short reg_ac97)
714+{
715+ const struct snd_azf3328 *chip = ac97->private_data;
716+ unsigned short reg_azf = snd_azf3328_mixer_ac97_map_reg_idx(reg_ac97);
717+ unsigned short reg_val = 0;
718+ bool unsupported = 0;
719+
720+ snd_azf3328_dbgmixer(
721+ "snd_azf3328_mixer_ac97_read reg_ac97 %u\n",
722+ reg_ac97
723+ );
724+ if (reg_azf & AZF_AC97_REG_UNSUPPORTED)
725+ unsupported = 1;
726+ else {
727+ if (reg_azf & AZF_AC97_REG_REAL_IO_READ)
728+ reg_val = snd_azf3328_mixer_inw(chip,
729+ reg_azf & AZF_REG_MASK);
730+ else {
731+ /*
732+ * Proceed with dummy I/O read,
733+ * to ensure compatible timing where this may matter.
734+ * (ALSA AC97 layer usually doesn't call I/O functions
735+ * due to intelligent I/O caching anyway)
736+ * Choose a mixer register that's thoroughly unrelated
737+ * to common audio (try to minimize distortion).
738+ */
739+ snd_azf3328_mixer_inw(chip, IDX_MIXER_SOMETHING30H);
740+ }
741+
742+ if (reg_azf & AZF_AC97_REG_EMU_IO_READ) {
743+ switch (reg_ac97) {
744+ case AC97_RESET:
745+ reg_val |= azf_emulated_ac97_caps;
746+ break;
747+ case AC97_POWERDOWN:
748+ reg_val |= azf_emulated_ac97_powerdown;
749+ break;
750+ case AC97_EXTENDED_ID:
751+ case AC97_EXTENDED_STATUS:
752+ /* AFAICS we simply can't support anything: */
753+ reg_val |= 0;
754+ break;
755+ case AC97_VENDOR_ID1:
756+ reg_val = azf_emulated_ac97_vendor_id >> 16;
757+ break;
758+ case AC97_VENDOR_ID2:
759+ reg_val = azf_emulated_ac97_vendor_id & 0xffff;
760+ break;
761+ default:
762+ unsupported = 1;
763+ break;
764+ }
765+ }
766+ }
767+ if (unsupported)
768+ snd_azf3328_mixer_ac97_map_unsupported(reg_ac97, "read");
769+
770+ return reg_val;
771+}
772+
773+static void
774+snd_azf3328_mixer_ac97_write(struct snd_ac97 *ac97,
775+ unsigned short reg_ac97, unsigned short val)
776+{
777+ const struct snd_azf3328 *chip = ac97->private_data;
778+ unsigned short reg_azf = snd_azf3328_mixer_ac97_map_reg_idx(reg_ac97);
779+ bool unsupported = 0;
780+
781+ snd_azf3328_dbgmixer(
782+ "snd_azf3328_mixer_ac97_write reg_ac97 %u val %u\n",
783+ reg_ac97, val
784+ );
785+ if (reg_azf & AZF_AC97_REG_UNSUPPORTED)
786+ unsupported = 1;
787+ else {
788+ if (reg_azf & AZF_AC97_REG_REAL_IO_WRITE)
789+ snd_azf3328_mixer_outw(
790+ chip,
791+ reg_azf & AZF_REG_MASK,
792+ val
793+ );
794+ else
795+ if (reg_azf & AZF_AC97_REG_EMU_IO_WRITE) {
796+ switch (reg_ac97) {
797+ case AC97_REC_GAIN_MIC:
798+ case AC97_POWERDOWN:
799+ case AC97_EXTENDED_STATUS:
800+ /*
801+ * Silently swallow these writes.
802+ * Since for most registers our card doesn't
803+ * actually support a comparable feature,
804+ * this is exactly what we should do here.
805+ * The AC97 layer's I/O caching probably
806+ * automatically takes care of all the rest...
807+ * (remembers written values etc.)
808+ */
809+ break;
810+ default:
811+ unsupported = 1;
812+ break;
813+ }
814+ }
815+ }
816+ if (unsupported)
817+ snd_azf3328_mixer_ac97_map_unsupported(reg_ac97, "write");
818+}
819+
820+static int __devinit
821+snd_azf3328_mixer_new(struct snd_azf3328 *chip)
822+{
823+ struct snd_ac97_bus *bus;
824+ struct snd_ac97_template ac97;
825+ static struct snd_ac97_bus_ops ops = {
826+ .write = snd_azf3328_mixer_ac97_write,
827+ .read = snd_azf3328_mixer_ac97_read,
828+ };
829+ int rc;
830+
831+ memset(&ac97, 0, sizeof(ac97));
832+ ac97.scaps = AC97_SCAP_SKIP_MODEM
833+ | AC97_SCAP_AUDIO /* we support audio! */
834+ | AC97_SCAP_NO_SPDIF;
835+ ac97.private_data = chip;
836+ ac97.pci = chip->pci;
837+
838+ /*
839+ * ALSA's AC97 layer has terrible init crackling issues,
840+ * unfortunately, and since it makes use of AC97_RESET,
841+ * there's no use trying to mute Master Playback proactively.
842+ */
843+
844+ rc = snd_ac97_bus(chip->card, 0, &ops, NULL, &bus);
845+ if (!rc)
846+ rc = snd_ac97_mixer(bus, &ac97, &chip->ac97);
847+ /*
848+ * Make sure to complain loudly in case of AC97 init failure,
849+ * since failure may happen quite often,
850+ * due to this card being a very quirky AC97 "lookalike".
851+ */
852+ if (rc)
853+ printk(KERN_ERR "azt3328: AC97 init failed, err %d!\n", rc);
854+
855+ /* If we return an error here, then snd_card_free() should
856+ * free up any ac97 codecs that got created, as well as the bus.
857+ */
858+ return rc;
859+}
860+#else /* AZF_USE_AC97_LAYER */
524861 static void
525862 snd_azf3328_mixer_write_volume_gradually(const struct snd_azf3328 *chip,
526863 unsigned reg,
@@ -945,6 +1282,7 @@ snd_azf3328_mixer_new(struct snd_azf3328 *chip) · 418 unmodified lines
9451282 snd_azf3328_dbgcallleave();
9461283 return 0;
9471284 }
1285+#endif /* AZF_USE_AC97_LAYER */
9481286
9491287 static int
9501288 snd_azf3328_hw_params(struct snd_pcm_substream *substream,
@@ -1233,8 +1571,8 @@ snd_azf3328_pcm_trigger(struct snd_pcm_substream *substream, int cmd) · 282 unmodified lines
12331571 if (is_main_mixer_playback_codec) {
12341572 /* mute WaveOut (avoid clicking during setup) */
12351573 previously_muted =
1236− snd_azf3328_mixer_set_mute(
1237− chip, IDX_MIXER_WAVEOUT, 1
1574+ snd_azf3328_mixer_mute_control_pcm(
1575+ chip, 1
12381576 );
12391577 }
12401578
@@ -1290,8 +1628,8 @@ snd_azf3328_pcm_trigger(struct snd_pcm_substream *substream, int cmd) · 49 unmodified lines
12901628 if (is_main_mixer_playback_codec) {
12911629 /* now unmute WaveOut */
12921630 if (!previously_muted)
1293− snd_azf3328_mixer_set_mute(
1294− chip, IDX_MIXER_WAVEOUT, 0
1631+ snd_azf3328_mixer_mute_control_pcm(
1632+ chip, 0
12951633 );
12961634 }
12971635
@@ -1315,8 +1653,8 @@ snd_azf3328_pcm_trigger(struct snd_pcm_substream *substream, int cmd) · 17 unmodified lines
13151653 if (is_main_mixer_playback_codec) {
13161654 /* mute WaveOut (avoid clicking during setup) */
13171655 previously_muted =
1318− snd_azf3328_mixer_set_mute(
1319− chip, IDX_MIXER_WAVEOUT, 1
1656+ snd_azf3328_mixer_mute_control_pcm(
1657+ chip, 1
13201658 );
13211659 }
13221660
@@ -1341,8 +1679,8 @@ snd_azf3328_pcm_trigger(struct snd_pcm_substream *substream, int cmd) · 18 unmodified lines
13411679 if (is_main_mixer_playback_codec) {
13421680 /* now unmute WaveOut */
13431681 if (!previously_muted)
1344− snd_azf3328_mixer_set_mute(
1345− chip, IDX_MIXER_WAVEOUT, 0
1682+ snd_azf3328_mixer_mute_control_pcm(
1683+ chip, 0
13461684 );
13471685 }
13481686
@@ -2050,11 +2388,7 @@ snd_azf3328_free(struct snd_azf3328 *chip) · 701 unmodified lines
20502388 if (chip->irq < 0)
20512389 goto __end_hw;
20522390
2053− /* reset (close) mixer:
2054− * first mute master volume, then reset
2055− */
2056− snd_azf3328_mixer_set_mute(chip, IDX_MIXER_PLAY_MASTER, 1);
2057− snd_azf3328_mixer_outw(chip, IDX_MIXER_RESET, 0x0000);
2391+ snd_azf3328_mixer_reset(chip);
20582392
20592393 snd_azf3328_timer_stop(chip->timer);
20602394 snd_azf3328_gameport_free(chip);
@@ -2407,6 +2741,55 @@ snd_azf3328_suspend_regs(unsigned long io_addr, unsigned count, u32 *saved_regs) · 346 unmodified lines
24072741 }
24082742 }
24092743
2744+static inline void
2745+snd_azf3328_resume_regs(const u32 *saved_regs,
2746+ unsigned long io_addr,
2747+ unsigned count
2748+)
2749+{
2750+ unsigned reg;
2751+
2752+ for (reg = 0; reg < count; ++reg) {
2753+ outl(*saved_regs, io_addr);
2754+ snd_azf3328_dbgpm("resume: io 0x%04lx: 0x%08x --> 0x%08x\n",
2755+ io_addr, *saved_regs, inl(io_addr));
2756+ ++saved_regs;
2757+ io_addr += sizeof(*saved_regs);
2758+ }
2759+}
2760+
2761+static inline void
2762+snd_azf3328_suspend_ac97(struct snd_azf3328 *chip)
2763+{
2764+#ifdef AZF_USE_AC97_LAYER
2765+ snd_ac97_suspend(chip->ac97);
2766+#else
2767+ snd_azf3328_suspend_regs(chip->mixer_io,
2768+ ARRAY_SIZE(chip->saved_regs_mixer), chip->saved_regs_mixer);
2769+
2770+ /* make sure to disable master volume etc. to prevent looping sound */
2771+ snd_azf3328_mixer_mute_control_master(chip, 1);
2772+ snd_azf3328_mixer_mute_control_pcm(chip, 1);
2773+#endif /* AZF_USE_AC97_LAYER */
2774+}
2775+
2776+static inline void
2777+snd_azf3328_resume_ac97(const struct snd_azf3328 *chip)
2778+{
2779+#ifdef AZF_USE_AC97_LAYER
2780+ snd_ac97_resume(chip->ac97);
2781+#else
2782+ snd_azf3328_resume_regs(chip->saved_regs_mixer, chip->mixer_io,
2783+ ARRAY_SIZE(chip->saved_regs_mixer));
2784+
2785+ /* unfortunately with 32bit transfers, IDX_MIXER_PLAY_MASTER (0x02)
2786+ and IDX_MIXER_RESET (offset 0x00) get touched at the same time,
2787+ resulting in a mixer reset condition persisting until _after_
2788+ master vol was restored. Thus master vol needs an extra restore. */
2789+ outw(((u16 *)chip->saved_regs_mixer)[1], chip->mixer_io + 2);
2790+#endif /* AZF_USE_AC97_LAYER */
2791+}
2792+
24102793 static int
24112794 snd_azf3328_suspend(struct pci_dev *pci, pm_message_t state)
24122795 {
@@ -2420,12 +2803,7 @@ snd_azf3328_suspend(struct pci_dev *pci, pm_message_t state) · 7 unmodified lines
24202803 snd_pcm_suspend_all(chip->pcm[AZF_CODEC_PLAYBACK]);
24212804 snd_pcm_suspend_all(chip->pcm[AZF_CODEC_I2S_OUT]);
24222805
2423− snd_azf3328_suspend_regs(chip->mixer_io,
2424− ARRAY_SIZE(chip->saved_regs_mixer), chip->saved_regs_mixer);
2425−
2426− /* make sure to disable master volume etc. to prevent looping sound */
2427− snd_azf3328_mixer_set_mute(chip, IDX_MIXER_PLAY_MASTER, 1);
2428− snd_azf3328_mixer_set_mute(chip, IDX_MIXER_WAVEOUT, 1);
2806+ snd_azf3328_suspend_ac97(chip);
24292807
24302808 snd_azf3328_suspend_regs(chip->ctrl_io,
24312809 ARRAY_SIZE(chip->saved_regs_ctrl), chip->saved_regs_ctrl);
@@ -2447,23 +2825,6 @@ snd_azf3328_suspend(struct pci_dev *pci, pm_message_t state) · 15 unmodified lines
24472825 return 0;
24482826 }
24492827
2450−static inline void
2451−snd_azf3328_resume_regs(const u32 *saved_regs,
2452− unsigned long io_addr,
2453− unsigned count
2454−)
2455−{
2456− unsigned reg;
2457−
2458− for (reg = 0; reg < count; ++reg) {
2459− outl(*saved_regs, io_addr);
2460− snd_azf3328_dbgpm("resume: io 0x%04lx: 0x%08x --> 0x%08x\n",
2461− io_addr, *saved_regs, inl(io_addr));
2462− ++saved_regs;
2463− io_addr += sizeof(*saved_regs);
2464− }
2465−}
2466−
24672828 static int
24682829 snd_azf3328_resume(struct pci_dev *pci)
24692830 {
@@ -2487,14 +2848,7 @@ snd_azf3328_resume(struct pci_dev *pci) · 17 unmodified lines
24872848 snd_azf3328_resume_regs(chip->saved_regs_opl3, chip->opl3_io,
24882849 ARRAY_SIZE(chip->saved_regs_opl3));
24892850
2490− snd_azf3328_resume_regs(chip->saved_regs_mixer, chip->mixer_io,
2491− ARRAY_SIZE(chip->saved_regs_mixer));
2492−
2493− /* unfortunately with 32bit transfers, IDX_MIXER_PLAY_MASTER (0x02)
2494− and IDX_MIXER_RESET (offset 0x00) get touched at the same time,
2495− resulting in a mixer reset condition persisting until _after_
2496− master vol was restored. Thus master vol needs an extra restore. */
2497− outw(((u16 *)chip->saved_regs_mixer)[1], chip->mixer_io + 2);
2851+ snd_azf3328_resume_ac97(chip);
24982852
24992853 snd_azf3328_resume_regs(chip->saved_regs_ctrl, chip->ctrl_io,
25002854 ARRAY_SIZE(chip->saved_regs_ctrl));
sound/pci/ctxfi/ctatc.c+1−1
@@ -869,7 +869,7 @@ spdif_passthru_playback_setup(struct ct_atc *atc, struct ct_atc_pcm *apcm) · 868 unmodified lines
869869 mutex_lock(&atc->atc_mutex);
870870 dao->ops->get_spos(dao, &status);
871871 if (((status >> 24) & IEC958_AES3_CON_FS) != iec958_con_fs) {
872− status &= ((~IEC958_AES3_CON_FS) << 24);
872+ status &= ~(IEC958_AES3_CON_FS << 24);
873873 status |= (iec958_con_fs << 24);
874874 dao->ops->set_spos(dao, status);
875875 dao->ops->commit_write(dao);
sound/pci/ctxfi/ctdaio.c+2−0
@@ -176,6 +176,7 @@ static int dao_set_left_input(struct dao *dao, struct rsc *input) · 175 unmodified lines
176176 if (!entry)
177177 return -ENOMEM;
178178
179+ dao->ops->clear_left_input(dao);
179180 /* Program master and conjugate resources */
180181 input->ops->master(input);
181182 daio->rscl.ops->master(&daio->rscl);
@@ -204,6 +205,7 @@ static int dao_set_right_input(struct dao *dao, struct rsc *input) · 22 unmodified lines
204205 if (!entry)
205206 return -ENOMEM;
206207
208+ dao->ops->clear_right_input(dao);
207209 /* Program master and conjugate resources */
208210 input->ops->master(input);
209211 daio->rscr.ops->master(&daio->rscr);
sound/pci/ctxfi/cthw20k2.c+18−10
@@ -1307,10 +1307,10 @@ static int hw_pll_init(struct hw *hw, unsigned int rsr) · 1306 unmodified lines
13071307 set_field(&pllctl, PLLCTL_B, 0);
13081308 if (48000 == rsr) {
13091309 set_field(&pllctl, PLLCTL_FD, 16 - 2);
1310− set_field(&pllctl, PLLCTL_RD, 1 - 1);
1310+ set_field(&pllctl, PLLCTL_RD, 1 - 1); /* 3000*16/1 = 48000 */
13111311 } else { /* 44100 */
13121312 set_field(&pllctl, PLLCTL_FD, 147 - 2);
1313− set_field(&pllctl, PLLCTL_RD, 10 - 1);
1313+ set_field(&pllctl, PLLCTL_RD, 10 - 1); /* 3000*147/10 = 44100 */
13141314 }
13151315 hw_write_20kx(hw, PLL_CTL, pllctl);
13161316 mdelay(40);
@@ -1740,6 +1740,10 @@ static int hw_is_adc_input_selected(struct hw *hw, enum ADCSRC type) · 423 unmodified lines
17401740 return data;
17411741 }
17421742
1743+#define MIC_BOOST_0DB 0xCF
1744+#define MIC_BOOST_STEPS_PER_DB 2
1745+#define MIC_BOOST_20DB (MIC_BOOST_0DB + 20 * MIC_BOOST_STEPS_PER_DB)
1746+
17431747 static int hw_adc_input_select(struct hw *hw, enum ADCSRC type)
17441748 {
17451749 u32 data;
@@ -1751,10 +1755,12 @@ static int hw_adc_input_select(struct hw *hw, enum ADCSRC type) · 5 unmodified lines
17511755 hw_write_20kx(hw, GPIO_DATA, data);
17521756 hw20k2_i2c_write(hw, MAKE_WM8775_ADDR(WM8775_ADCMC, 0x101),
17531757 MAKE_WM8775_DATA(0x101)); /* Mic-in */
1754− hw20k2_i2c_write(hw, MAKE_WM8775_ADDR(WM8775_AADCL, 0xE7),
1755− MAKE_WM8775_DATA(0xE7)); /* +12dB boost */
1756− hw20k2_i2c_write(hw, MAKE_WM8775_ADDR(WM8775_AADCR, 0xE7),
1757− MAKE_WM8775_DATA(0xE7)); /* +12dB boost */
1758+ hw20k2_i2c_write(hw,
1759+ MAKE_WM8775_ADDR(WM8775_AADCL, MIC_BOOST_20DB),
1760+ MAKE_WM8775_DATA(MIC_BOOST_20DB)); /* +20dB */
1761+ hw20k2_i2c_write(hw,
1762+ MAKE_WM8775_ADDR(WM8775_AADCR, MIC_BOOST_20DB),
1763+ MAKE_WM8775_DATA(MIC_BOOST_20DB)); /* +20dB */
17581764 break;
17591765 case ADC_LINEIN:
17601766 data &= ~(0x1 << 14);
@@ -1827,10 +1833,12 @@ static int hw_adc_init(struct hw *hw, const struct adc_conf *info) · 66 unmodified lines
18271833
18281834 hw20k2_i2c_write(hw, MAKE_WM8775_ADDR(WM8775_ADCMC, 0x101),
18291835 MAKE_WM8775_DATA(0x101)); /* Mic-in */
1830− hw20k2_i2c_write(hw, MAKE_WM8775_ADDR(WM8775_AADCL, 0xE7),
1831− MAKE_WM8775_DATA(0xE7)); /* +12dB boost */
1832− hw20k2_i2c_write(hw, MAKE_WM8775_ADDR(WM8775_AADCR, 0xE7),
1833− MAKE_WM8775_DATA(0xE7)); /* +12dB boost */
1836+ hw20k2_i2c_write(hw,
1837+ MAKE_WM8775_ADDR(WM8775_AADCL, MIC_BOOST_20DB),
1838+ MAKE_WM8775_DATA(MIC_BOOST_20DB)); /* +20dB */
1839+ hw20k2_i2c_write(hw,
1840+ MAKE_WM8775_ADDR(WM8775_AADCR, MIC_BOOST_20DB),
1841+ MAKE_WM8775_DATA(MIC_BOOST_20DB)); /* +20dB */
18341842 } else if (mux == 2) {
18351843 /* Configures GPIO data to select Line-in */
18361844 data &= ~(0x1 << 14);
sound/pci/ctxfi/ctmixer.c+5−14
@@ -566,19 +566,6 @@ static int ct_spdif_get_mask(struct snd_kcontrol *kcontrol, · 565 unmodified lines
566566 return 0;
567567 }
568568
569−static int ct_spdif_default_get(struct snd_kcontrol *kcontrol,
570− struct snd_ctl_elem_value *ucontrol)
571−{
572− unsigned int status = SNDRV_PCM_DEFAULT_CON_SPDIF;
573−
574− ucontrol->value.iec958.status[0] = (status >> 0) & 0xff;
575− ucontrol->value.iec958.status[1] = (status >> 8) & 0xff;
576− ucontrol->value.iec958.status[2] = (status >> 16) & 0xff;
577− ucontrol->value.iec958.status[3] = (status >> 24) & 0xff;
578−
579− return 0;
580−}
581−
582569 static int ct_spdif_get(struct snd_kcontrol *kcontrol,
583570 struct snd_ctl_elem_value *ucontrol)
584571 {
@@ -586,6 +573,10 @@ static int ct_spdif_get(struct snd_kcontrol *kcontrol, · 1 unmodified line
586573 unsigned int status;
587574
588575 atc->spdif_out_get_status(atc, &status);
576+
577+ if (status == 0)
578+ status = SNDRV_PCM_DEFAULT_CON_SPDIF;
579+
589580 ucontrol->value.iec958.status[0] = (status >> 0) & 0xff;
590581 ucontrol->value.iec958.status[1] = (status >> 8) & 0xff;
591582 ucontrol->value.iec958.status[2] = (status >> 16) & 0xff;
@@ -629,7 +620,7 @@ static struct snd_kcontrol_new iec958_default_ctl = { · 37 unmodified lines
629620 .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, DEFAULT),
630621 .count = 1,
631622 .info = ct_spdif_info,
632− .get = ct_spdif_default_get,
623+ .get = ct_spdif_get,
633624 .put = ct_spdif_put,
634625 .private_value = MIXER_IEC958_DEFAULT
635626 };
sound/pci/ctxfi/ctvmem.c+1−2
@@ -52,8 +52,7 @@ get_vm_block(struct ct_vm *vm, unsigned int size) · 51 unmodified lines
5252
5353 if (entry->size == size) {
5454 /* Move the vm node from unused list to used list directly */
55− list_del(&entry->list);
56− list_add(&entry->list, &vm->used);
55+ list_move(&entry->list, &vm->used);
5756 vm->size -= size;
5857 block = entry;
5958 goto out;
sound/pci/emu10k1/emu10k1_main.c+1−1
@@ -926,7 +926,7 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 *emu) · 925 unmodified lines
926926 snd_emu1010_fpga_write(emu, EMU_HANA_MIDI_IN, 0x19);
927927 /* Unknown. */
928928 snd_emu1010_fpga_write(emu, EMU_HANA_MIDI_OUT, 0x0c);
929− /* IRQ Enable: Alll on */
929+ /* IRQ Enable: All on */
930930 /* snd_emu1010_fpga_write(emu, 0x09, 0x0f ); */
931931 /* IRQ Enable: All off */
932932 snd_emu1010_fpga_write(emu, EMU_HANA_IRQ_ENABLE, 0x00);
sound/pci/hda/hda_codec.c+105−0
@@ -29,6 +29,7 @@ · 28 unmodified lines
2929 #include <sound/asoundef.h>
3030 #include <sound/tlv.h>
3131 #include <sound/initval.h>
32+#include <sound/jack.h>
3233 #include "hda_local.h"
3334 #include "hda_beep.h"
3435 #include <sound/hda_hwdep.h>
@@ -4959,5 +4960,109 @@ void snd_print_pcm_bits(int pcm, char *buf, int buflen) · 4924 unmodified lines
49594960 }
49604961 EXPORT_SYMBOL_HDA(snd_print_pcm_bits);
49614962
4963+#ifdef CONFIG_SND_HDA_INPUT_JACK
4964+/*
4965+ * Input-jack notification support
4966+ */
4967+struct hda_jack_item {
4968+ hda_nid_t nid;
4969+ int type;
4970+ struct snd_jack *jack;
4971+};
4972+
4973+static const char *get_jack_default_name(struct hda_codec *codec, hda_nid_t nid,
4974+ int type)
4975+{
4976+ switch (type) {
4977+ case SND_JACK_HEADPHONE:
4978+ return "Headphone";
4979+ case SND_JACK_MICROPHONE:
4980+ return "Mic";
4981+ case SND_JACK_LINEOUT:
4982+ return "Line-out";
4983+ case SND_JACK_HEADSET:
4984+ return "Headset";
4985+ default:
4986+ return "Misc";
4987+ }
4988+}
4989+
4990+static void hda_free_jack_priv(struct snd_jack *jack)
4991+{
4992+ struct hda_jack_item *jacks = jack->private_data;
4993+ jacks->nid = 0;
4994+ jacks->jack = NULL;
4995+}
4996+
4997+int snd_hda_input_jack_add(struct hda_codec *codec, hda_nid_t nid, int type,
4998+ const char *name)
4999+{
5000+ struct hda_jack_item *jack;
5001+ int err;
5002+
5003+ snd_array_init(&codec->jacks, sizeof(*jack), 32);
5004+ jack = snd_array_new(&codec->jacks);
5005+ if (!jack)
5006+ return -ENOMEM;
5007+
5008+ jack->nid = nid;
5009+ jack->type = type;
5010+ if (!name)
5011+ name = get_jack_default_name(codec, nid, type);
5012+ err = snd_jack_new(codec->bus->card, name, type, &jack->jack);
5013+ if (err < 0) {
5014+ jack->nid = 0;
5015+ return err;
5016+ }
5017+ jack->jack->private_data = jack;
5018+ jack->jack->private_free = hda_free_jack_priv;
5019+ return 0;
5020+}
5021+EXPORT_SYMBOL_HDA(snd_hda_input_jack_add);
5022+
5023+void snd_hda_input_jack_report(struct hda_codec *codec, hda_nid_t nid)
5024+{
5025+ struct hda_jack_item *jacks = codec->jacks.list;
5026+ int i;
5027+
5028+ if (!jacks)
5029+ return;
5030+
5031+ for (i = 0; i < codec->jacks.used; i++, jacks++) {
5032+ unsigned int pin_ctl;
5033+ unsigned int present;
5034+ int type;
5035+
5036+ if (jacks->nid != nid)
5037+ continue;
5038+ present = snd_hda_jack_detect(codec, nid);
5039+ type = jacks->type;
5040+ if (type == (SND_JACK_HEADPHONE | SND_JACK_LINEOUT)) {
5041+ pin_ctl = snd_hda_codec_read(codec, nid, 0,
5042+ AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
5043+ type = (pin_ctl & AC_PINCTL_HP_EN) ?
5044+ SND_JACK_HEADPHONE : SND_JACK_LINEOUT;
5045+ }
5046+ snd_jack_report(jacks->jack, present ? type : 0);
5047+ }
5048+}
5049+EXPORT_SYMBOL_HDA(snd_hda_input_jack_report);
5050+
5051+/* free jack instances manually when clearing/reconfiguring */
5052+void snd_hda_input_jack_free(struct hda_codec *codec)
5053+{
5054+ if (!codec->bus->shutdown && codec->jacks.list) {
5055+ struct hda_jack_item *jacks = codec->jacks.list;
5056+ int i;
5057+ for (i = 0; i < codec->jacks.used; i++, jacks++) {
5058+ if (jacks->jack)
5059+ snd_device_free(codec->bus->card, jacks->jack);
5060+ }
5061+ }
5062+ snd_array_free(&codec->jacks);
5063+}
5064+EXPORT_SYMBOL_HDA(snd_hda_input_jack_free);
5065+#endif /* CONFIG_SND_HDA_INPUT_JACK */
5066+
49625067 MODULE_DESCRIPTION("HDA codec core");
49635068 MODULE_LICENSE("GPL");
sound/pci/hda/hda_codec.h+5−0
@@ -866,6 +866,11 @@ struct hda_codec { · 865 unmodified lines
866866 /* codec-specific additional proc output */
867867 void (*proc_widget_hook)(struct snd_info_buffer *buffer,
868868 struct hda_codec *codec, hda_nid_t nid);
869+
870+#ifdef CONFIG_SND_HDA_INPUT_JACK
871+ /* jack detection */
872+ struct snd_array jacks;
873+#endif
869874 };
870875
871876 /* direction */
sound/pci/hda/hda_intel.c+5−2
@@ -1052,9 +1052,12 @@ static void azx_init_pci(struct azx *chip) · 1051 unmodified lines
10521052 /* Clear bits 0-2 of PCI register TCSEL (at offset 0x44)
10531053 * TCSEL == Traffic Class Select Register, which sets PCI express QOS
10541054 * Ensuring these bits are 0 clears playback static on some HD Audio
1055− * codecs
1055+ * codecs.
1056+ * The PCI register TCSEL is defined in the Intel manuals.
10561057 */
1057− update_pci_byte(chip->pci, ICH6_PCIREG_TCSEL, 0x07, 0);
1058+ if (chip->driver_type != AZX_DRIVER_ATI &&
1059+ chip->driver_type != AZX_DRIVER_ATIHDMI)
1060+ update_pci_byte(chip->pci, ICH6_PCIREG_TCSEL, 0x07, 0);
10581061
10591062 switch (chip->driver_type) {
10601063 case AZX_DRIVER_ATI:
sound/pci/hda/hda_local.h+24−0
@@ -656,4 +656,28 @@ static inline void snd_hda_eld_proc_free(struct hda_codec *codec, · 655 unmodified lines
656656 #define SND_PRINT_CHANNEL_ALLOCATION_ADVISED_BUFSIZE 80
657657 void snd_print_channel_allocation(int spk_alloc, char *buf, int buflen);
658658
659+/*
660+ * Input-jack notification support
661+ */
662+#ifdef CONFIG_SND_HDA_INPUT_JACK
663+int snd_hda_input_jack_add(struct hda_codec *codec, hda_nid_t nid, int type,
664+ const char *name);
665+void snd_hda_input_jack_report(struct hda_codec *codec, hda_nid_t nid);
666+void snd_hda_input_jack_free(struct hda_codec *codec);
667+#else /* CONFIG_SND_HDA_INPUT_JACK */
668+static inline int snd_hda_input_jack_add(struct hda_codec *codec,
669+ hda_nid_t nid, int type,
670+ const char *name)
671+{
672+ return 0;
673+}
674+static inline void snd_hda_input_jack_report(struct hda_codec *codec,
675+ hda_nid_t nid)
676+{
677+}
678+static inline void snd_hda_input_jack_free(struct hda_codec *codec)
679+{
680+}
681+#endif /* CONFIG_SND_HDA_INPUT_JACK */
682+
659683 #endif /* __SOUND_HDA_LOCAL_H */
sound/pci/hda/patch_analog.c+10−107
@@ -30,10 +30,10 @@ · 29 unmodified lines
3030 #include "hda_beep.h"
3131
3232 struct ad198x_spec {
33− struct snd_kcontrol_new *mixers[5];
33+ struct snd_kcontrol_new *mixers[6];
3434 int num_mixers;
3535 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
36− const struct hda_verb *init_verbs[5]; /* initialization verbs
36+ const struct hda_verb *init_verbs[6]; /* initialization verbs
3737 * don't forget NULL termination!
3838 */
3939 unsigned int num_init_verbs;
@@ -331,36 +331,11 @@ static int ad198x_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, · 291 unmodified lines
331331 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
332332 }
333333
334−static int ad198x_alt_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
335− struct hda_codec *codec,
336− unsigned int stream_tag,
337− unsigned int format,
338− struct snd_pcm_substream *substream)
339−{
340− struct ad198x_spec *spec = codec->spec;
341− snd_hda_codec_setup_stream(codec, spec->alt_dac_nid[0], stream_tag,
342− 0, format);
343− return 0;
344−}
345−
346−static int ad198x_alt_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
347− struct hda_codec *codec,
348− struct snd_pcm_substream *substream)
349−{
350− struct ad198x_spec *spec = codec->spec;
351− snd_hda_codec_cleanup_stream(codec, spec->alt_dac_nid[0]);
352− return 0;
353−}
354−
355334 static struct hda_pcm_stream ad198x_pcm_analog_alt_playback = {
356335 .substreams = 1,
357336 .channels_min = 2,
358337 .channels_max = 2,
359338 /* NID is set in ad198x_build_pcms */
360− .ops = {
361− .prepare = ad198x_alt_playback_pcm_prepare,
362− .cleanup = ad198x_alt_playback_pcm_cleanup
363− },
364339 };
365340
366341 /*
@@ -2239,29 +2214,6 @@ static struct snd_kcontrol_new ad1988_6stack_mixers2[] = { · 1872 unmodified lines
22392214 static struct snd_kcontrol_new ad1988_6stack_fp_mixers[] = {
22402215 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
22412216
2242− HDA_BIND_MUTE("Front Playback Switch", 0x29, 2, HDA_INPUT),
2243− HDA_BIND_MUTE("Surround Playback Switch", 0x2a, 2, HDA_INPUT),
2244− HDA_BIND_MUTE_MONO("Center Playback Switch", 0x27, 1, 2, HDA_INPUT),
2245− HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x27, 2, 2, HDA_INPUT),
2246− HDA_BIND_MUTE("Side Playback Switch", 0x28, 2, HDA_INPUT),
2247− HDA_BIND_MUTE("Headphone Playback Switch", 0x22, 2, HDA_INPUT),
2248− HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT),
2249−
2250− HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT),
2251− HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT),
2252− HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x0, HDA_INPUT),
2253− HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x0, HDA_INPUT),
2254− HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT),
2255− HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT),
2256− HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x4, HDA_INPUT),
2257− HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x4, HDA_INPUT),
2258−
2259− HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT),
2260− HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT),
2261−
2262− HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x39, 0x0, HDA_OUTPUT),
2263− HDA_CODEC_VOLUME("Mic Boost Volume", 0x3c, 0x0, HDA_OUTPUT),
2264−
22652217 { } /* end */
22662218 };
22672219
@@ -2545,11 +2497,6 @@ static struct hda_verb ad1988_6stack_init_verbs[] = { · 277 unmodified lines
25452497 };
25462498
25472499 static struct hda_verb ad1988_6stack_fp_init_verbs[] = {
2548− /* Front, Surround, CLFE, side DAC; unmute as default */
2549− {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2550− {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2551− {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2552− {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
25532500 /* Headphone; unmute as default */
25542501 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
25552502 /* Port-A front headphon path */
@@ -2558,50 +2505,6 @@ static struct hda_verb ad1988_6stack_fp_init_verbs[] = { · 2 unmodified lines
25582505 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
25592506 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
25602507 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2561− /* Port-D line-out path */
2562− {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2563− {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2564− {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2565− {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2566− /* Port-F surround path */
2567− {0x2a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2568− {0x2a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2569− {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2570− {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2571− /* Port-G CLFE path */
2572− {0x27, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2573− {0x27, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2574− {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2575− {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2576− /* Port-H side path */
2577− {0x28, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2578− {0x28, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2579− {0x25, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2580− {0x25, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2581− /* Mono out path */
2582− {0x36, AC_VERB_SET_CONNECT_SEL, 0x1}, /* DAC1:04h */
2583− {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2584− {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2585− {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2586− {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb01f}, /* unmute, 0dB */
2587− /* Port-B front mic-in path */
2588− {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2589− {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2590− {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2591− /* Port-C line-in path */
2592− {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2593− {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2594− {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2595− {0x33, AC_VERB_SET_CONNECT_SEL, 0x0},
2596− /* Port-E mic-in path */
2597− {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2598− {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2599− {0x3c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2600− {0x34, AC_VERB_SET_CONNECT_SEL, 0x0},
2601− /* Analog CD Input */
2602− {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2603− /* Analog Mix output amp */
2604− {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x1f}, /* 0dB */
26052508
26062509 { }
26072510 };
@@ -3316,20 +3219,20 @@ static int patch_ad1988(struct hda_codec *codec) · 708 unmodified lines
33163219 spec->mixers[0] = ad1988_6stack_mixers1_rev2;
33173220 else
33183221 spec->mixers[0] = ad1988_6stack_mixers1;
3222+ spec->mixers[1] = ad1988_6stack_mixers2;
3223+ spec->num_init_verbs = 1;
3224+ spec->init_verbs[0] = ad1988_6stack_init_verbs;
33193225 if (board_config == AD1988_6STACK_DIG_FP) {
3320− spec->mixers[1] = ad1988_6stack_fp_mixers;
3226+ spec->num_mixers++;
3227+ spec->mixers[2] = ad1988_6stack_fp_mixers;
3228+ spec->num_init_verbs++;
3229+ spec->init_verbs[1] = ad1988_6stack_fp_init_verbs;
33213230 spec->slave_vols = ad1988_6stack_fp_slave_vols;
33223231 spec->slave_sws = ad1988_6stack_fp_slave_sws;
33233232 spec->alt_dac_nid = ad1988_alt_dac_nid;
33243233 spec->stream_analog_alt_playback =
33253234 &ad198x_pcm_analog_alt_playback;
3326− } else
3327− spec->mixers[1] = ad1988_6stack_mixers2;
3328− spec->num_init_verbs = 1;
3329− if (board_config == AD1988_6STACK_DIG_FP)
3330− spec->init_verbs[0] = ad1988_6stack_fp_init_verbs;
3331− else
3332− spec->init_verbs[0] = ad1988_6stack_init_verbs;
3235+ }
33333236 if ((board_config == AD1988_6STACK_DIG) ||
33343237 (board_config == AD1988_6STACK_DIG_FP)) {
33353238 spec->multiout.dig_out_nid = AD1988_SPDIF_OUT;
sound/pci/hda/patch_conexant.c+14−110
@@ -49,14 +49,6 @@ · 48 unmodified lines
4949 #define AUTO_MIC_PORTB (1 << 1)
5050 #define AUTO_MIC_PORTC (1 << 2)
5151
52−struct conexant_jack {
53−
54− hda_nid_t nid;
55− int type;
56− struct snd_jack *jack;
57−
58−};
59−
6052 struct pin_dac_pair {
6153 hda_nid_t pin;
6254 hda_nid_t dac;
@@ -111,9 +103,6 @@ struct conexant_spec { · 48 unmodified lines
111103
112104 unsigned int spdif_route;
113105
114− /* jack detection */
115− struct snd_array jacks;
116−
117106 /* dynamic controls, init_verbs and input_mux */
118107 struct auto_pin_cfg autocfg;
119108 struct hda_input_mux private_imux;
@@ -393,71 +382,9 @@ static int conexant_mux_enum_put(struct snd_kcontrol *kcontrol, · 273 unmodified lines
393382 &spec->cur_mux[adc_idx]);
394383 }
395384
396−#ifdef CONFIG_SND_HDA_INPUT_JACK
397−static void conexant_free_jack_priv(struct snd_jack *jack)
398−{
399− struct conexant_jack *jacks = jack->private_data;
400− jacks->nid = 0;
401− jacks->jack = NULL;
402−}
403−
404−static int conexant_add_jack(struct hda_codec *codec,
405− hda_nid_t nid, int type)
406−{
407− struct conexant_spec *spec;
408− struct conexant_jack *jack;
409− const char *name;
410− int i, err;
411−
412− spec = codec->spec;
413− snd_array_init(&spec->jacks, sizeof(*jack), 32);
414−
415− jack = spec->jacks.list;
416− for (i = 0; i < spec->jacks.used; i++, jack++)
417− if (jack->nid == nid)
418− return 0 ; /* already present */
419−
420− jack = snd_array_new(&spec->jacks);
421− name = (type == SND_JACK_HEADPHONE) ? "Headphone" : "Mic" ;
422−
423− if (!jack)
424− return -ENOMEM;
425−
426− jack->nid = nid;
427− jack->type = type;
428−
429− err = snd_jack_new(codec->bus->card, name, type, &jack->jack);
430− if (err < 0)
431− return err;
432− jack->jack->private_data = jack;
433− jack->jack->private_free = conexant_free_jack_priv;
434− return 0;
435−}
436−
437−static void conexant_report_jack(struct hda_codec *codec, hda_nid_t nid)
438−{
439− struct conexant_spec *spec = codec->spec;
440− struct conexant_jack *jacks = spec->jacks.list;
441−
442− if (jacks) {
443− int i;
444− for (i = 0; i < spec->jacks.used; i++) {
445− if (jacks->nid == nid) {
446− unsigned int present;
447− present = snd_hda_jack_detect(codec, nid);
448−
449− present = (present) ? jacks->type : 0 ;
450−
451− snd_jack_report(jacks->jack,
452− present);
453− }
454− jacks++;
455− }
456− }
457−}
458−
459385 static int conexant_init_jacks(struct hda_codec *codec)
460386 {
387+#ifdef CONFIG_SND_HDA_INPUT_JACK
461388 struct conexant_spec *spec = codec->spec;
462389 int i;
463390
@@ -469,15 +396,15 @@ static int conexant_init_jacks(struct hda_codec *codec) · 5 unmodified lines
469396 int err = 0;
470397 switch (hv->param ^ AC_USRSP_EN) {
471398 case CONEXANT_HP_EVENT:
472− err = conexant_add_jack(codec, hv->nid,
473− SND_JACK_HEADPHONE);
474− conexant_report_jack(codec, hv->nid);
399+ err = snd_hda_input_jack_add(codec, hv->nid,
400+ SND_JACK_HEADPHONE, NULL);
401+ snd_hda_input_jack_report(codec, hv->nid);
475402 break;
476403 case CXT5051_PORTC_EVENT:
477404 case CONEXANT_MIC_EVENT:
478− err = conexant_add_jack(codec, hv->nid,
479− SND_JACK_MICROPHONE);
480− conexant_report_jack(codec, hv->nid);
405+ err = snd_hda_input_jack_add(codec, hv->nid,
406+ SND_JACK_MICROPHONE, NULL);
407+ snd_hda_input_jack_report(codec, hv->nid);
481408 break;
482409 }
483410 if (err < 0)
@@ -485,19 +412,9 @@ static int conexant_init_jacks(struct hda_codec *codec) · 1 unmodified line
485412 ++hv;
486413 }
487414 }
488− return 0;
489−
490−}
491−#else
492−static inline void conexant_report_jack(struct hda_codec *codec, hda_nid_t nid)
493−{
494−}
495−
496−static inline int conexant_init_jacks(struct hda_codec *codec)
497−{
415+#endif /* CONFIG_SND_HDA_INPUT_JACK */
498416 return 0;
499417 }
500−#endif
501418
502419 static int conexant_init(struct hda_codec *codec)
503420 {
@@ -511,18 +428,7 @@ static int conexant_init(struct hda_codec *codec) · 7 unmodified lines
511428
512429 static void conexant_free(struct hda_codec *codec)
513430 {
514−#ifdef CONFIG_SND_HDA_INPUT_JACK
515− struct conexant_spec *spec = codec->spec;
516− if (spec->jacks.list) {
517− struct conexant_jack *jacks = spec->jacks.list;
518− int i;
519− for (i = 0; i < spec->jacks.used; i++, jacks++) {
520− if (jacks->jack)
521− snd_device_free(codec->bus->card, jacks->jack);
522− }
523− snd_array_free(&spec->jacks);
524− }
525−#endif
431+ snd_hda_input_jack_free(codec);
526432 snd_hda_detach_beep_device(codec);
527433 kfree(codec->spec);
528434 }
@@ -1787,7 +1693,7 @@ static void cxt5051_hp_unsol_event(struct hda_codec *codec, · 1258 unmodified lines
17871693 cxt5051_portc_automic(codec);
17881694 break;
17891695 }
1790− conexant_report_jack(codec, nid);
1696+ snd_hda_input_jack_report(codec, nid);
17911697 }
17921698
17931699 static struct snd_kcontrol_new cxt5051_playback_mixers[] = {
@@ -1959,10 +1865,8 @@ static void cxt5051_init_mic_port(struct hda_codec *codec, hda_nid_t nid, · 165 unmodified lines
19591865 snd_hda_codec_write(codec, nid, 0,
19601866 AC_VERB_SET_UNSOLICITED_ENABLE,
19611867 AC_USRSP_EN | event);
1962−#ifdef CONFIG_SND_HDA_INPUT_JACK
1963− conexant_add_jack(codec, nid, SND_JACK_MICROPHONE);
1964− conexant_report_jack(codec, nid);
1965−#endif
1868+ snd_hda_input_jack_add(codec, nid, SND_JACK_MICROPHONE, NULL);
1869+ snd_hda_input_jack_report(codec, nid);
19661870 }
19671871
19681872 static struct hda_verb cxt5051_ideapad_init_verbs[] = {
@@ -3477,11 +3381,11 @@ static void cx_auto_unsol_event(struct hda_codec *codec, unsigned int res) · 1508 unmodified lines
34773381 switch (res >> 26) {
34783382 case CONEXANT_HP_EVENT:
34793383 cx_auto_hp_automute(codec);
3480− conexant_report_jack(codec, nid);
3384+ snd_hda_input_jack_report(codec, nid);
34813385 break;
34823386 case CONEXANT_MIC_EVENT:
34833387 cx_auto_automic(codec);
3484− conexant_report_jack(codec, nid);
3388+ snd_hda_input_jack_report(codec, nid);
34853389 break;
34863390 }
34873391 }
sound/pci/hda/patch_hdmi.c+13−9
@@ -110,6 +110,12 @@ struct dp_audio_infoframe { · 109 unmodified lines
110110 u8 LFEPBL01_LSV36_DM_INH7;
111111 };
112112
113+union audio_infoframe {
114+ struct hdmi_audio_infoframe hdmi;
115+ struct dp_audio_infoframe dp;
116+ u8 bytes[0];
117+};
118+
113119 /*
114120 * CEA speaker placement:
115121 *
@@ -620,8 +626,7 @@ static void hdmi_setup_audio_infoframe(struct hda_codec *codec, hda_nid_t nid, · 504 unmodified lines
620626 int channels = substream->runtime->channels;
621627 int ca;
622628 int i;
623− u8 ai[max(sizeof(struct hdmi_audio_infoframe),
624− sizeof(struct dp_audio_infoframe))];
629+ union audio_infoframe ai;
625630
626631 ca = hdmi_channel_allocation(codec, nid, channels);
627632
@@ -633,11 +638,10 @@ static void hdmi_setup_audio_infoframe(struct hda_codec *codec, hda_nid_t nid, · 5 unmodified lines
633638
634639 pin_nid = spec->pin[i];
635640
636− memset(ai, 0, sizeof(ai));
641+ memset(&ai, 0, sizeof(ai));
637642 if (spec->sink_eld[i].conn_type == 0) { /* HDMI */
638− struct hdmi_audio_infoframe *hdmi_ai;
643+ struct hdmi_audio_infoframe *hdmi_ai = &ai.hdmi;
639644
640− hdmi_ai = (struct hdmi_audio_infoframe *)ai;
641645 hdmi_ai->type = 0x84;
642646 hdmi_ai->ver = 0x01;
643647 hdmi_ai->len = 0x0a;
@@ -645,9 +649,8 @@ static void hdmi_setup_audio_infoframe(struct hda_codec *codec, hda_nid_t nid, · 1 unmodified line
645649 hdmi_ai->CA = ca;
646650 hdmi_checksum_audio_infoframe(hdmi_ai);
647651 } else if (spec->sink_eld[i].conn_type == 1) { /* DisplayPort */
648− struct dp_audio_infoframe *dp_ai;
652+ struct dp_audio_infoframe *dp_ai = &ai.dp;
649653
650− dp_ai = (struct dp_audio_infoframe *)ai;
651654 dp_ai->type = 0x84;
652655 dp_ai->len = 0x1b;
653656 dp_ai->ver = 0x11 << 2;
@@ -664,7 +667,8 @@ static void hdmi_setup_audio_infoframe(struct hda_codec *codec, hda_nid_t nid, · 10 unmodified lines
664667 * sizeof(*dp_ai) to avoid partial match/update problems when
665668 * the user switches between HDMI/DP monitors.
666669 */
667− if (!hdmi_infoframe_uptodate(codec, pin_nid, ai, sizeof(ai))) {
670+ if (!hdmi_infoframe_uptodate(codec, pin_nid, ai.bytes,
671+ sizeof(ai))) {
668672 snd_printdd("hdmi_setup_audio_infoframe: "
669673 "cvt=%d pin=%d channels=%d\n",
670674 nid, pin_nid,
@@ -672,7 +676,7 @@ static void hdmi_setup_audio_infoframe(struct hda_codec *codec, hda_nid_t nid, · 1 unmodified line
672676 hdmi_setup_channel_mapping(codec, pin_nid, ca);
673677 hdmi_stop_infoframe_trans(codec, pin_nid);
674678 hdmi_fill_audio_infoframe(codec, pin_nid,
675− ai, sizeof(ai));
679+ ai.bytes, sizeof(ai));
676680 hdmi_start_infoframe_trans(codec, pin_nid);
677681 }
678682 }
sound/pci/hda/patch_realtek.c+80−126
@@ -282,12 +282,6 @@ struct alc_mic_route { · 281 unmodified lines
282282 unsigned char amix_idx;
283283 };
284284
285−struct alc_jack {
286− hda_nid_t nid;
287− int type;
288− struct snd_jack *jack;
289−};
290−
291285 #define MUX_IDX_UNDEF ((unsigned char)-1)
292286
293287 struct alc_customize_define {
@@ -366,9 +360,6 @@ struct alc_spec { · 72 unmodified lines
366360 /* PCM information */
367361 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
368362
369− /* jack detection */
370− struct snd_array jacks;
371−
372363 /* dynamic controls, init_verbs and input_mux */
373364 struct auto_pin_cfg autocfg;
374365 struct alc_customize_define cdefine;
@@ -394,6 +385,7 @@ struct alc_spec { · 19 unmodified lines
394385 /* other flags */
395386 unsigned int no_analog :1; /* digital I/O only */
396387 unsigned int dual_adc_switch:1; /* switch ADCs (for ALC275) */
388+ unsigned int single_input_src:1;
397389 int init_amp;
398390 int codec_variant; /* flag for other variants */
399391
@@ -1032,94 +1024,32 @@ static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid, · 632 unmodified lines
10321024 alc_fix_pll(codec);
10331025 }
10341026
1035−#ifdef CONFIG_SND_HDA_INPUT_JACK
1036−static void alc_free_jack_priv(struct snd_jack *jack)
1037−{
1038− struct alc_jack *jacks = jack->private_data;
1039− jacks->nid = 0;
1040− jacks->jack = NULL;
1041−}
1042−
1043−static int alc_add_jack(struct hda_codec *codec,
1044− hda_nid_t nid, int type)
1045−{
1046− struct alc_spec *spec;
1047− struct alc_jack *jack;
1048− const char *name;
1049− int err;
1050−
1051− spec = codec->spec;
1052− snd_array_init(&spec->jacks, sizeof(*jack), 32);
1053− jack = snd_array_new(&spec->jacks);
1054− if (!jack)
1055− return -ENOMEM;
1056−
1057− jack->nid = nid;
1058− jack->type = type;
1059− name = (type == SND_JACK_HEADPHONE) ? "Headphone" : "Mic" ;
1060−
1061− err = snd_jack_new(codec->bus->card, name, type, &jack->jack);
1062− if (err < 0)
1063− return err;
1064− jack->jack->private_data = jack;
1065− jack->jack->private_free = alc_free_jack_priv;
1066− return 0;
1067−}
1068−
1069−static void alc_report_jack(struct hda_codec *codec, hda_nid_t nid)
1070−{
1071− struct alc_spec *spec = codec->spec;
1072− struct alc_jack *jacks = spec->jacks.list;
1073−
1074− if (jacks) {
1075− int i;
1076− for (i = 0; i < spec->jacks.used; i++) {
1077− if (jacks->nid == nid) {
1078− unsigned int present;
1079− present = snd_hda_jack_detect(codec, nid);
1080−
1081− present = (present) ? jacks->type : 0;
1082−
1083− snd_jack_report(jacks->jack, present);
1084− }
1085− jacks++;
1086− }
1087− }
1088−}
1089−
10901027 static int alc_init_jacks(struct hda_codec *codec)
10911028 {
1029+#ifdef CONFIG_SND_HDA_INPUT_JACK
10921030 struct alc_spec *spec = codec->spec;
10931031 int err;
10941032 unsigned int hp_nid = spec->autocfg.hp_pins[0];
10951033 unsigned int mic_nid = spec->ext_mic.pin;
10961034
10971035 if (hp_nid) {
1098− err = alc_add_jack(codec, hp_nid, SND_JACK_HEADPHONE);
1036+ err = snd_hda_input_jack_add(codec, hp_nid,
1037+ SND_JACK_HEADPHONE, NULL);
10991038 if (err < 0)
11001039 return err;
1101− alc_report_jack(codec, hp_nid);
1040+ snd_hda_input_jack_report(codec, hp_nid);
11021041 }
11031042
11041043 if (mic_nid) {
1105− err = alc_add_jack(codec, mic_nid, SND_JACK_MICROPHONE);
1044+ err = snd_hda_input_jack_add(codec, mic_nid,
1045+ SND_JACK_MICROPHONE, NULL);
11061046 if (err < 0)
11071047 return err;
1108− alc_report_jack(codec, mic_nid);
1048+ snd_hda_input_jack_report(codec, mic_nid);
11091049 }
1110−
1111− return 0;
1112−}
1113−#else
1114−static inline void alc_report_jack(struct hda_codec *codec, hda_nid_t nid)
1115−{
1116−}
1117−
1118−static inline int alc_init_jacks(struct hda_codec *codec)
1119−{
1050+#endif /* CONFIG_SND_HDA_INPUT_JACK */
11201051 return 0;
11211052 }
1122−#endif
11231053
11241054 static void alc_automute_speaker(struct hda_codec *codec, int pinctl)
11251055 {
@@ -1133,7 +1063,7 @@ static void alc_automute_speaker(struct hda_codec *codec, int pinctl) · 7 unmodified lines
11331063 nid = spec->autocfg.hp_pins[i];
11341064 if (!nid)
11351065 break;
1136− alc_report_jack(codec, nid);
1066+ snd_hda_input_jack_report(codec, nid);
11371067 spec->jack_present |= snd_hda_jack_detect(codec, nid);
11381068 }
11391069
@@ -1240,7 +1170,7 @@ static void alc_mic_automute(struct hda_codec *codec) · 100 unmodified lines
12401170 AC_VERB_SET_CONNECT_SEL,
12411171 alive->mux_idx);
12421172 }
1243− alc_report_jack(codec, spec->ext_mic.pin);
1173+ snd_hda_input_jack_report(codec, spec->ext_mic.pin);
12441174
12451175 /* FIXME: analog mixer */
12461176 }
@@ -2292,13 +2222,13 @@ static struct snd_kcontrol_new alc888_acer_aspire_4930g_mixer[] = { · 1045 unmodified lines
22922222 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
22932223 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
22942224 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2295− HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0f, 2, 0x0,
2225+ HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
22962226 HDA_OUTPUT),
2297− HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0f, 2, 2, HDA_INPUT),
2298− HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0f, 1, 0x0, HDA_OUTPUT),
2299− HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0f, 1, 2, HDA_INPUT),
2300− HDA_CODEC_VOLUME("Side Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2301− HDA_BIND_MUTE("Side Playback Switch", 0x0e, 2, HDA_INPUT),
2227+ HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2228+ HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2229+ HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2230+ HDA_CODEC_VOLUME_MONO("Internal LFE Playback Volume", 0x0f, 1, 0x0, HDA_OUTPUT),
2231+ HDA_BIND_MUTE_MONO("Internal LFE Playback Switch", 0x0f, 1, 2, HDA_INPUT),
23022232 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
23032233 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
23042234 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
@@ -2309,7 +2239,6 @@ static struct snd_kcontrol_new alc888_acer_aspire_4930g_mixer[] = { · 4 unmodified lines
23092239 { } /* end */
23102240 };
23112241
2312−
23132242 static struct snd_kcontrol_new alc889_acer_aspire_8930g_mixer[] = {
23142243 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
23152244 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
@@ -3919,6 +3848,8 @@ static struct hda_amp_list alc880_lg_loopbacks[] = { · 1603 unmodified lines
39193848 * Common callbacks
39203849 */
39213850
3851+static void alc_init_special_input_src(struct hda_codec *codec);
3852+
39223853 static int alc_init(struct hda_codec *codec)
39233854 {
39243855 struct alc_spec *spec = codec->spec;
@@ -3929,6 +3860,7 @@ static int alc_init(struct hda_codec *codec) · 4 unmodified lines
39293860
39303861 for (i = 0; i < spec->num_init_verbs; i++)
39313862 snd_hda_sequence_write(codec, spec->init_verbs[i]);
3863+ alc_init_special_input_src(codec);
39323864
39333865 if (spec->init_hook)
39343866 spec->init_hook(codec);
@@ -4284,6 +4216,7 @@ static void alc_free(struct hda_codec *codec) · 349 unmodified lines
42844216 return;
42854217
42864218 alc_shutup(codec);
4219+ snd_hda_input_jack_free(codec);
42874220 alc_free_kctls(codec);
42884221 kfree(spec);
42894222 snd_hda_detach_beep_device(codec);
@@ -4702,7 +4635,7 @@ static struct snd_pci_quirk alc880_cfg_tbl[] = { · 412 unmodified lines
47024635 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
47034636 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
47044637 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
4705− SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
4638+ SND_PCI_QUIRK(0x1584, 0x9054, "Uniwill", ALC880_F1734),
47064639 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
47074640 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
47084641 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
@@ -5151,7 +5084,9 @@ static const char *alc_get_line_out_pfx(const struct auto_pin_cfg *cfg, · 442 unmodified lines
51515084
51525085 switch (cfg->line_out_type) {
51535086 case AUTO_PIN_SPEAKER_OUT:
5154− return "Speaker";
5087+ if (cfg->line_outs == 1)
5088+ return "Speaker";
5089+ break;
51555090 case AUTO_PIN_HP_OUT:
51565091 return "Headphone";
51575092 default:
@@ -5205,16 +5140,19 @@ static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec, · 47 unmodified lines
52055140 return err;
52065141 } else {
52075142 const char *name = pfx;
5208− if (!name)
5143+ int index = i;
5144+ if (!name) {
52095145 name = chname[i];
5146+ index = 0;
5147+ }
52105148 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
5211− name, i,
5149+ name, index,
52125150 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
52135151 HDA_OUTPUT));
52145152 if (err < 0)
52155153 return err;
52165154 err = __add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
5217− name, i,
5155+ name, index,
52185156 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
52195157 HDA_INPUT));
52205158 if (err < 0)
@@ -5585,6 +5523,7 @@ static void fixup_single_adc(struct hda_codec *codec) · 364 unmodified lines
55855523 spec->capsrc_nids += i;
55865524 spec->adc_nids += i;
55875525 spec->num_adc_nids = 1;
5526+ spec->single_input_src = 1;
55885527 }
55895528 }
55905529
@@ -5596,6 +5535,16 @@ static void fixup_dual_adc_switch(struct hda_codec *codec) · 5 unmodified lines
55965535 init_capsrc_for_pin(codec, spec->int_mic.pin);
55975536 }
55985537
5538+/* initialize some special cases for input sources */
5539+static void alc_init_special_input_src(struct hda_codec *codec)
5540+{
5541+ struct alc_spec *spec = codec->spec;
5542+ if (spec->dual_adc_switch)
5543+ fixup_dual_adc_switch(codec);
5544+ else if (spec->single_input_src)
5545+ init_capsrc_for_pin(codec, spec->autocfg.inputs[0].pin);
5546+}
5547+
55995548 static void set_capture_mixer(struct hda_codec *codec)
56005549 {
56015550 struct alc_spec *spec = codec->spec;
@@ -5611,7 +5560,7 @@ static void set_capture_mixer(struct hda_codec *codec) · 9 unmodified lines
56115560 int mux = 0;
56125561 int num_adcs = spec->num_adc_nids;
56135562 if (spec->dual_adc_switch)
5614− fixup_dual_adc_switch(codec);
5563+ num_adcs = 1;
56155564 else if (spec->auto_mic)
56165565 fixup_automic_adc(codec);
56175566 else if (spec->input_mux) {
@@ -5620,8 +5569,6 @@ static void set_capture_mixer(struct hda_codec *codec) · 2 unmodified lines
56205569 else if (spec->input_mux->num_items == 1)
56215570 fixup_single_adc(codec);
56225571 }
5623− if (spec->dual_adc_switch)
5624− num_adcs = 1;
56255572 spec->cap_mixer = caps[mux][num_adcs - 1];
56265573 }
56275574 }
@@ -10748,6 +10695,7 @@ static struct alc_config_preset alc882_presets[] = { · 5120 unmodified lines
1074810695 */
1074910696 enum {
1075010697 PINFIX_ABIT_AW9D_MAX,
10698+ PINFIX_LENOVO_Y530,
1075110699 PINFIX_PB_M5210,
1075210700 PINFIX_ACER_ASPIRE_7736,
1075310701 };
@@ -10762,6 +10710,14 @@ static const struct alc_fixup alc882_fixups[] = { · 8 unmodified lines
1076210710 { }
1076310711 }
1076410712 },
10713+ [PINFIX_LENOVO_Y530] = {
10714+ .type = ALC_FIXUP_PINS,
10715+ .v.pins = (const struct alc_pincfg[]) {
10716+ { 0x15, 0x99130112 }, /* rear int speakers */
10717+ { 0x16, 0x99130111 }, /* subwoofer */
10718+ { }
10719+ }
10720+ },
1076510721 [PINFIX_PB_M5210] = {
1076610722 .type = ALC_FIXUP_VERBS,
1076710723 .v.verbs = (const struct hda_verb[]) {
@@ -10777,6 +10733,7 @@ static const struct alc_fixup alc882_fixups[] = { · 9 unmodified lines
1077710733
1077810734 static struct snd_pci_quirk alc882_fixup_tbl[] = {
1077910735 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", PINFIX_PB_M5210),
10736+ SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", PINFIX_LENOVO_Y530),
1078010737 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
1078110738 SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", PINFIX_ACER_ASPIRE_7736),
1078210739 {}
@@ -10829,23 +10786,28 @@ static void alc882_auto_init_hp_out(struct hda_codec *codec) · 46 unmodified lines
1082910786 hda_nid_t pin, dac;
1083010787 int i;
1083110788
10832− for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
10833− pin = spec->autocfg.hp_pins[i];
10834− if (!pin)
10835− break;
10836− dac = spec->multiout.hp_nid;
10837− if (!dac)
10838− dac = spec->multiout.dac_nids[0]; /* to front */
10839− alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, dac);
10789+ if (spec->autocfg.line_out_type != AUTO_PIN_HP_OUT) {
10790+ for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
10791+ pin = spec->autocfg.hp_pins[i];
10792+ if (!pin)
10793+ break;
10794+ dac = spec->multiout.hp_nid;
10795+ if (!dac)
10796+ dac = spec->multiout.dac_nids[0]; /* to front */
10797+ alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, dac);
10798+ }
1084010799 }
10841− for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
10842− pin = spec->autocfg.speaker_pins[i];
10843− if (!pin)
10844− break;
10845− dac = spec->multiout.extra_out_nid[0];
10846− if (!dac)
10847− dac = spec->multiout.dac_nids[0]; /* to front */
10848− alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, dac);
10800+
10801+ if (spec->autocfg.line_out_type != AUTO_PIN_SPEAKER_OUT) {
10802+ for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
10803+ pin = spec->autocfg.speaker_pins[i];
10804+ if (!pin)
10805+ break;
10806+ dac = spec->multiout.extra_out_nid[0];
10807+ if (!dac)
10808+ dac = spec->multiout.dac_nids[0]; /* to front */
10809+ alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, dac);
10810+ }
1084910811 }

78 more lines aren’t shown here.

sound/pci/hda/patch_sigmatel.c+162−156

This diff is large: its 504 lines aren’t shown here.

sound/pci/intel8x0m.c+54−53

This diff is large: its 370 lines aren’t shown here.

sound/pci/rme9652/hdspm.c+3352−1114

This diff is large: its 6063 lines aren’t shown here.

sound/ppc/pmac.c+5−1

This diff is large: its 13 lines aren’t shown here.

sound/soc/Kconfig+2−0

This diff is large: its 13 lines aren’t shown here.

sound/soc/Makefile+2−0

This diff is large: its 14 lines aren’t shown here.

sound/soc/codecs/Kconfig+33−1

This diff is large: its 107 lines aren’t shown here.

sound/soc/codecs/Makefile+17−1

This diff is large: its 89 lines aren’t shown here.

sound/soc/codecs/ak4104.c+0−1

This diff is large: its 8 lines aren’t shown here.

sound/soc/codecs/ak4642.c+24−0

This diff is large: its 38 lines aren’t shown here.

sound/soc/codecs/cs4270.c+3−5

This diff is large: its 33 lines aren’t shown here.

sound/soc/codecs/cs4271.c+667−0

This diff is large: its 668 lines aren’t shown here.

sound/soc/codecs/dfbmcs320.c+72−0

This diff is large: its 73 lines aren’t shown here.

sound/soc/codecs/lm4857.c+276−0

This diff is large: its 277 lines aren’t shown here.

sound/soc/codecs/max98088.c+1−1

This diff is large: its 9 lines aren’t shown here.

sound/soc/codecs/max9850.c+389−0

This diff is large: its 390 lines aren’t shown here.

sound/soc/codecs/max9850.h+38−0

This diff is large: its 39 lines aren’t shown here.

sound/soc/codecs/sgtl5000.c+1513−0

This diff is large: its 1514 lines aren’t shown here.

sound/soc/codecs/sgtl5000.h+400−0

This diff is large: its 401 lines aren’t shown here.

sound/soc/codecs/sn95031.c+949−0

This diff is large: its 950 lines aren’t shown here.

sound/soc/codecs/sn95031.h+132−0

This diff is large: its 133 lines aren’t shown here.

sound/soc/codecs/tlv320aic32x4.c+794−0

This diff is large: its 795 lines aren’t shown here.

sound/soc/codecs/tlv320aic32x4.h+143−0

This diff is large: its 144 lines aren’t shown here.

sound/soc/codecs/tlv320dac33.c+1−0

This diff is large: its 8 lines aren’t shown here.

sound/soc/codecs/twl6040.c+2−2

This diff is large: its 11 lines aren’t shown here.

sound/soc/codecs/wm2000.c+7−7

This diff is large: its 44 lines aren’t shown here.

sound/soc/codecs/wm8523.c+4−4

This diff is large: its 29 lines aren’t shown here.

sound/soc/codecs/wm8741.c+8−5

This diff is large: its 27 lines aren’t shown here.

sound/soc/codecs/wm8753.c+121−175

This diff is large: its 469 lines aren’t shown here.

sound/soc/codecs/wm8804.c+1−1

This diff is large: its 9 lines aren’t shown here.

sound/soc/codecs/wm8900.c+1−1

This diff is large: its 9 lines aren’t shown here.

sound/soc/codecs/wm8903.c+459−182

This diff is large: its 897 lines aren’t shown here.

sound/soc/codecs/wm8903.h+8−0

This diff is large: its 15 lines aren’t shown here.

sound/soc/codecs/wm8904.c+27−16

This diff is large: its 66 lines aren’t shown here.

sound/soc/codecs/wm8955.c+19−8

This diff is large: its 36 lines aren’t shown here.

sound/soc/codecs/wm8961.c+1−1

This diff is large: its 9 lines aren’t shown here.

sound/soc/codecs/wm8962.c+23−13

This diff is large: its 64 lines aren’t shown here.

sound/soc/codecs/wm8978.c+4−3

This diff is large: its 28 lines aren’t shown here.

sound/soc/codecs/wm8991.c+1427−0

This diff is large: its 1428 lines aren’t shown here.

sound/soc/codecs/wm8991.h+833−0

This diff is large: its 834 lines aren’t shown here.

sound/soc/codecs/wm8993.c+1−1

This diff is large: its 9 lines aren’t shown here.

sound/soc/codecs/wm8994-tables.c+6−6

This diff is large: its 33 lines aren’t shown here.

sound/soc/codecs/wm8994.c+65−62

This diff is large: its 260 lines aren’t shown here.

sound/soc/codecs/wm8994.h+1−1

This diff is large: its 8 lines aren’t shown here.

sound/soc/codecs/wm8995.c+98−5

This diff is large: its 189 lines aren’t shown here.

sound/soc/codecs/wm9081.c+37−47

This diff is large: its 206 lines aren’t shown here.

sound/soc/codecs/wm9090.c+26−19

This diff is large: its 73 lines aren’t shown here.

sound/soc/codecs/wm_hubs.c+2−1

This diff is large: its 10 lines aren’t shown here.

sound/soc/davinci/davinci-i2s.c+19−9

This diff is large: its 79 lines aren’t shown here.

sound/soc/davinci/davinci-mcasp.c+20−9

This diff is large: its 85 lines aren’t shown here.

sound/soc/ep93xx/Kconfig+9−0

This diff is large: its 13 lines aren’t shown here.

sound/soc/ep93xx/Makefile+2−0

This diff is large: its 9 lines aren’t shown here.

sound/soc/ep93xx/edb93xx.c+142−0

This diff is large: its 143 lines aren’t shown here.

sound/soc/ep93xx/ep93xx-ac97.c+0−1

This diff is large: its 8 lines aren’t shown here.

sound/soc/ep93xx/ep93xx-i2s.c+17−14

This diff is large: its 77 lines aren’t shown here.

sound/soc/ep93xx/ep93xx-pcm.c+2−2

This diff is large: its 12 lines aren’t shown here.

sound/soc/fsl/mpc8610_hpcd.c+2−4

This diff is large: its 22 lines aren’t shown here.

sound/soc/fsl/p1022_ds.c+2−4

This diff is large: its 22 lines aren’t shown here.

sound/soc/imx/Kconfig+10−0

This diff is large: its 17 lines aren’t shown here.

sound/soc/imx/Makefile+2−0

This diff is large: its 11 lines aren’t shown here.

sound/soc/imx/imx-ssi.c+4−1

This diff is large: its 19 lines aren’t shown here.

sound/soc/imx/mx27vis-aic32x4.c+137−0

This diff is large: its 138 lines aren’t shown here.

sound/soc/mid-x86/Kconfig+14−0

This diff is large: its 15 lines aren’t shown here.

sound/soc/mid-x86/Makefile+5−0

This diff is large: its 6 lines aren’t shown here.

sound/soc/mid-x86/mfld_machine.c+452−0

This diff is large: its 453 lines aren’t shown here.

sound/soc/mid-x86/sst_platform.c+474−0

This diff is large: its 475 lines aren’t shown here.

sound/soc/mid-x86/sst_platform.h+63−0

This diff is large: its 64 lines aren’t shown here.

sound/soc/omap/Kconfig+1−0

This diff is large: its 8 lines aren’t shown here.

sound/soc/omap/rx51.c+123−8

This diff is large: its 260 lines aren’t shown here.

sound/soc/pxa/raumfeld.c+10−10

This diff is large: its 44 lines aren’t shown here.

sound/soc/pxa/tosa.c+2−2

This diff is large: its 18 lines aren’t shown here.

sound/soc/pxa/z2.c+6−1

This diff is large: its 21 lines aren’t shown here.

sound/soc/pxa/zylonite.c+4−5

This diff is large: its 37 lines aren’t shown here.

sound/soc/samsung/Kconfig+6−13

This diff is large: its 30 lines aren’t shown here.

sound/soc/samsung/Makefile+0−2

This diff is large: its 16 lines aren’t shown here.

sound/soc/samsung/ac97.c+4−4

This diff is large: its 29 lines aren’t shown here.

sound/soc/samsung/ac97.h+0−21

This diff is large: its 22 lines aren’t shown here.

sound/soc/samsung/dma.c+5−8

This diff is large: its 38 lines aren’t shown here.

sound/soc/samsung/dma.h+0−8

This diff is large: its 20 lines aren’t shown here.

sound/soc/samsung/goni_wm8994.c+1−9

This diff is large: its 23 lines aren’t shown here.

sound/soc/samsung/h1940_uda1380.c+0−9

This diff is large: its 26 lines aren’t shown here.

sound/soc/samsung/i2s.c+1−2

This diff is large: its 11 lines aren’t shown here.

sound/soc/samsung/jive_wm8750.c+0−11

This diff is large: its 23 lines aren’t shown here.

sound/soc/samsung/lm4857.h+0−32

This diff is large: its 33 lines aren’t shown here.

sound/soc/samsung/ln2440sbc_alc650.c+0−7

This diff is large: its 16 lines aren’t shown here.

sound/soc/samsung/neo1973_gta02_wm8753.c+0−504

This diff is large: its 505 lines aren’t shown here.

sound/soc/samsung/neo1973_wm8753.c+234−401

This diff is large: its 802 lines aren’t shown here.

sound/soc/samsung/pcm.c+108−10

This diff is large: its 136 lines aren’t shown here.

sound/soc/samsung/pcm.h+0−107

This diff is large: its 117 lines aren’t shown here.

sound/soc/samsung/rx1950_uda1380.c+0−11

This diff is large: its 27 lines aren’t shown here.

sound/soc/samsung/s3c-i2s-v2.c+1−2

This diff is large: its 11 lines aren’t shown here.

sound/soc/samsung/s3c2412-i2s.c+1−11

This diff is large: its 32 lines aren’t shown here.

sound/soc/samsung/s3c24xx-i2s.c+1−13

This diff is large: its 30 lines aren’t shown here.

sound/soc/samsung/s3c24xx_simtec.c+0−7

This diff is large: its 21 lines aren’t shown here.

sound/soc/samsung/s3c24xx_simtec_hermes.c+0−10

This diff is large: its 19 lines aren’t shown here.

sound/soc/samsung/s3c24xx_simtec_tlv320aic23.c+0−12

This diff is large: its 23 lines aren’t shown here.

sound/soc/samsung/s3c24xx_uda134x.c+1−8

This diff is large: its 24 lines aren’t shown here.

sound/soc/samsung/smartq_wm8987.c+0−6

This diff is large: its 21 lines aren’t shown here.

sound/soc/samsung/smdk2443_wm9710.c+0−7

This diff is large: its 16 lines aren’t shown here.

sound/soc/samsung/smdk_spdif.c+0−5

This diff is large: its 16 lines aren’t shown here.

sound/soc/samsung/smdk_wm8580.c+1−6

This diff is large: its 19 lines aren’t shown here.

sound/soc/samsung/smdk_wm9713.c+0−5

This diff is large: its 14 lines aren’t shown here.

sound/soc/samsung/spdif.c+1−2

This diff is large: its 11 lines aren’t shown here.

sound/soc/sh/fsi-ak4642.c+20−4

This diff is large: its 103 lines aren’t shown here.

sound/soc/sh/fsi-da7210.c+11−2

This diff is large: its 23 lines aren’t shown here.

sound/soc/sh/fsi-hdmi.c+72−5

This diff is large: its 114 lines aren’t shown here.

sound/soc/sh/fsi.c+114−89

This diff is large: its 350 lines aren’t shown here.

sound/soc/soc-cache.c+188−198

This diff is large: its 627 lines aren’t shown here.

sound/soc/soc-core.c+372−176

This diff is large: its 1012 lines aren’t shown here.

sound/soc/soc-dapm.c+172−85

This diff is large: its 494 lines aren’t shown here.

sound/soc/soc-jack.c+56−2

This diff is large: its 93 lines aren’t shown here.

sound/soc/soc-utils.c+3−20

This diff is large: its 30 lines aren’t shown here.

sound/soc/tegra/Kconfig+26−0

This diff is large: its 27 lines aren’t shown here.

sound/soc/tegra/Makefile+15−0

This diff is large: its 16 lines aren’t shown here.

sound/soc/tegra/harmony.c+393−0

This diff is large: its 394 lines aren’t shown here.

sound/soc/tegra/tegra_asoc_utils.c+155−0

This diff is large: its 156 lines aren’t shown here.

sound/soc/tegra/tegra_asoc_utils.h+45−0

This diff is large: its 46 lines aren’t shown here.

sound/soc/tegra/tegra_das.c+265−0

This diff is large: its 266 lines aren’t shown here.

sound/soc/tegra/tegra_das.h+135−0

This diff is large: its 136 lines aren’t shown here.

sound/soc/tegra/tegra_i2s.c+503−0

This diff is large: its 504 lines aren’t shown here.

sound/soc/tegra/tegra_i2s.h+165−0

This diff is large: its 166 lines aren’t shown here.

sound/soc/tegra/tegra_pcm.c+404−0

This diff is large: its 405 lines aren’t shown here.

sound/soc/tegra/tegra_pcm.h+55−0

This diff is large: its 56 lines aren’t shown here.

sound/sound_core.c+3−0

This diff is large: its 10 lines aren’t shown here.

sound/usb/6fire/Makefile+3−0

This diff is large: its 4 lines aren’t shown here.

sound/usb/6fire/chip.c+232−0

This diff is large: its 233 lines aren’t shown here.

sound/usb/6fire/chip.h+32−0

This diff is large: its 33 lines aren’t shown here.

sound/usb/6fire/comm.c+176−0

This diff is large: its 177 lines aren’t shown here.

sound/usb/6fire/comm.h+44−0

This diff is large: its 45 lines aren’t shown here.

sound/usb/6fire/common.h+30−0

This diff is large: its 31 lines aren’t shown here.

sound/usb/6fire/control.c+275−0

This diff is large: its 276 lines aren’t shown here.

sound/usb/6fire/control.h+37−0

This diff is large: its 38 lines aren’t shown here.

sound/usb/6fire/firmware.c+426−0

This diff is large: its 427 lines aren’t shown here.

sound/usb/6fire/firmware.h+27−0

This diff is large: its 28 lines aren’t shown here.

sound/usb/6fire/midi.c+203−0

This diff is large: its 204 lines aren’t shown here.

sound/usb/6fire/midi.h+46−0

This diff is large: its 47 lines aren’t shown here.

sound/usb/6fire/pcm.c+688−0

This diff is large: its 689 lines aren’t shown here.

sound/usb/6fire/pcm.h+76−0

This diff is large: its 77 lines aren’t shown here.

sound/usb/Kconfig+17−0

This diff is large: its 30 lines aren’t shown here.

sound/usb/Makefile+1−1

This diff is large: its 6 lines aren’t shown here.

sound/usb/caiaq/audio.c+1−0

This diff is large: its 8 lines aren’t shown here.

sound/usb/caiaq/device.c+6−0

This diff is large: its 20 lines aren’t shown here.

sound/usb/caiaq/device.h+1−0

This diff is large: its 8 lines aren’t shown here.

sound/usb/card.c+55−9

This diff is large: its 140 lines aren’t shown here.

sound/usb/midi.c+8−0

This diff is large: its 37 lines aren’t shown here.

sound/usb/mixer.c+61−4

This diff is large: its 163 lines aren’t shown here.

sound/usb/mixer.h+2−0

This diff is large: its 8 lines aren’t shown here.

sound/usb/mixer_quirks.c+161−13

This diff is large: its 200 lines aren’t shown here.

sound/usb/pcm.c+15−5

This diff is large: its 77 lines aren’t shown here.

sound/usb/power.h+17−0

This diff is large: its 18 lines aren’t shown here.

sound/usb/quirks-table.h+14−0

This diff is large: its 21 lines aren’t shown here.

sound/usb/quirks.c+45−11

This diff is large: its 80 lines aren’t shown here.

sound/usb/usbaudio.h+5−1

This diff is large: its 16 lines aren’t shown here.