als4000.c 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * card-als4000.c - driver for Avance Logic ALS4000 based soundcards.
  4. * Copyright (C) 2000 by Bart Hartgers <[email protected]>,
  5. * Jaroslav Kysela <[email protected]>
  6. * Copyright (C) 2002, 2008 by Andreas Mohr <[email protected]>
  7. *
  8. * Framework borrowed from Massimo Piccioni's card-als100.c.
  9. *
  10. * NOTES
  11. *
  12. * Since Avance does not provide any meaningful documentation, and I
  13. * bought an ALS4000 based soundcard, I was forced to base this driver
  14. * on reverse engineering.
  15. *
  16. * Note: this is no longer true (thank you!):
  17. * pretty verbose chip docu (ALS4000a.PDF) can be found on the ALSA web site.
  18. * Page numbers stated anywhere below with the "SPECS_PAGE:" tag
  19. * refer to: ALS4000a.PDF specs Ver 1.0, May 28th, 1998.
  20. *
  21. * The ALS4000 seems to be the PCI-cousin of the ALS100. It contains an
  22. * ALS100-like SB DSP/mixer, an OPL3 synth, a MPU401 and a gameport
  23. * interface. These subsystems can be mapped into ISA io-port space,
  24. * using the PCI-interface. In addition, the PCI-bit provides DMA and IRQ
  25. * services to the subsystems.
  26. *
  27. * While ALS4000 is very similar to a SoundBlaster, the differences in
  28. * DMA and capturing require more changes to the SoundBlaster than
  29. * desirable, so I made this separate driver.
  30. *
  31. * The ALS4000 can do real full duplex playback/capture.
  32. *
  33. * FMDAC:
  34. * - 0x4f -> port 0x14
  35. * - port 0x15 |= 1
  36. *
  37. * Enable/disable 3D sound:
  38. * - 0x50 -> port 0x14
  39. * - change bit 6 (0x40) of port 0x15
  40. *
  41. * Set QSound:
  42. * - 0xdb -> port 0x14
  43. * - set port 0x15:
  44. * 0x3e (mode 3), 0x3c (mode 2), 0x3a (mode 1), 0x38 (mode 0)
  45. *
  46. * Set KSound:
  47. * - value -> some port 0x0c0d
  48. *
  49. * ToDo:
  50. * - by default, don't enable legacy game and use PCI game I/O
  51. * - power management? (card can do voice wakeup according to datasheet!!)
  52. */
  53. #include <linux/io.h>
  54. #include <linux/init.h>
  55. #include <linux/pci.h>
  56. #include <linux/gameport.h>
  57. #include <linux/module.h>
  58. #include <linux/dma-mapping.h>
  59. #include <sound/core.h>
  60. #include <sound/pcm.h>
  61. #include <sound/rawmidi.h>
  62. #include <sound/mpu401.h>
  63. #include <sound/opl3.h>
  64. #include <sound/sb.h>
  65. #include <sound/initval.h>
  66. MODULE_AUTHOR("Bart Hartgers <[email protected]>, Andreas Mohr");
  67. MODULE_DESCRIPTION("Avance Logic ALS4000");
  68. MODULE_LICENSE("GPL");
  69. #if IS_REACHABLE(CONFIG_GAMEPORT)
  70. #define SUPPORT_JOYSTICK 1
  71. #endif
  72. static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
  73. static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
  74. static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
  75. #ifdef SUPPORT_JOYSTICK
  76. static int joystick_port[SNDRV_CARDS];
  77. #endif
  78. module_param_array(index, int, NULL, 0444);
  79. MODULE_PARM_DESC(index, "Index value for ALS4000 soundcard.");
  80. module_param_array(id, charp, NULL, 0444);
  81. MODULE_PARM_DESC(id, "ID string for ALS4000 soundcard.");
  82. module_param_array(enable, bool, NULL, 0444);
  83. MODULE_PARM_DESC(enable, "Enable ALS4000 soundcard.");
  84. #ifdef SUPPORT_JOYSTICK
  85. module_param_hw_array(joystick_port, int, ioport, NULL, 0444);
  86. MODULE_PARM_DESC(joystick_port, "Joystick port address for ALS4000 soundcard. (0 = disabled)");
  87. #endif
  88. struct snd_card_als4000 {
  89. /* most frequent access first */
  90. unsigned long iobase;
  91. struct pci_dev *pci;
  92. struct snd_sb *chip;
  93. #ifdef SUPPORT_JOYSTICK
  94. struct gameport *gameport;
  95. #endif
  96. };
  97. static const struct pci_device_id snd_als4000_ids[] = {
  98. { 0x4005, 0x4000, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* ALS4000 */
  99. { 0, }
  100. };
  101. MODULE_DEVICE_TABLE(pci, snd_als4000_ids);
  102. enum als4k_iobase_t {
  103. /* IOx: B == Byte, W = Word, D = DWord; SPECS_PAGE: 37 */
  104. ALS4K_IOD_00_AC97_ACCESS = 0x00,
  105. ALS4K_IOW_04_AC97_READ = 0x04,
  106. ALS4K_IOB_06_AC97_STATUS = 0x06,
  107. ALS4K_IOB_07_IRQSTATUS = 0x07,
  108. ALS4K_IOD_08_GCR_DATA = 0x08,
  109. ALS4K_IOB_0C_GCR_INDEX = 0x0c,
  110. ALS4K_IOB_0E_IRQTYPE_SB_CR1E_MPU = 0x0e,
  111. ALS4K_IOB_10_ADLIB_ADDR0 = 0x10,
  112. ALS4K_IOB_11_ADLIB_ADDR1 = 0x11,
  113. ALS4K_IOB_12_ADLIB_ADDR2 = 0x12,
  114. ALS4K_IOB_13_ADLIB_ADDR3 = 0x13,
  115. ALS4K_IOB_14_MIXER_INDEX = 0x14,
  116. ALS4K_IOB_15_MIXER_DATA = 0x15,
  117. ALS4K_IOB_16_ESP_RESET = 0x16,
  118. ALS4K_IOB_16_ACK_FOR_CR1E = 0x16, /* 2nd function */
  119. ALS4K_IOB_18_OPL_ADDR0 = 0x18,
  120. ALS4K_IOB_19_OPL_ADDR1 = 0x19,
  121. ALS4K_IOB_1A_ESP_RD_DATA = 0x1a,
  122. ALS4K_IOB_1C_ESP_CMD_DATA = 0x1c,
  123. ALS4K_IOB_1C_ESP_WR_STATUS = 0x1c, /* 2nd function */
  124. ALS4K_IOB_1E_ESP_RD_STATUS8 = 0x1e,
  125. ALS4K_IOB_1F_ESP_RD_STATUS16 = 0x1f,
  126. ALS4K_IOB_20_ESP_GAMEPORT_200 = 0x20,
  127. ALS4K_IOB_21_ESP_GAMEPORT_201 = 0x21,
  128. ALS4K_IOB_30_MIDI_DATA = 0x30,
  129. ALS4K_IOB_31_MIDI_STATUS = 0x31,
  130. ALS4K_IOB_31_MIDI_COMMAND = 0x31, /* 2nd function */
  131. };
  132. enum als4k_iobase_0e_t {
  133. ALS4K_IOB_0E_MPU_IRQ = 0x10,
  134. ALS4K_IOB_0E_CR1E_IRQ = 0x40,
  135. ALS4K_IOB_0E_SB_DMA_IRQ = 0x80,
  136. };
  137. enum als4k_gcr_t { /* all registers 32bit wide; SPECS_PAGE: 38 to 42 */
  138. ALS4K_GCR8C_MISC_CTRL = 0x8c,
  139. ALS4K_GCR90_TEST_MODE_REG = 0x90,
  140. ALS4K_GCR91_DMA0_ADDR = 0x91,
  141. ALS4K_GCR92_DMA0_MODE_COUNT = 0x92,
  142. ALS4K_GCR93_DMA1_ADDR = 0x93,
  143. ALS4K_GCR94_DMA1_MODE_COUNT = 0x94,
  144. ALS4K_GCR95_DMA3_ADDR = 0x95,
  145. ALS4K_GCR96_DMA3_MODE_COUNT = 0x96,
  146. ALS4K_GCR99_DMA_EMULATION_CTRL = 0x99,
  147. ALS4K_GCRA0_FIFO1_CURRENT_ADDR = 0xa0,
  148. ALS4K_GCRA1_FIFO1_STATUS_BYTECOUNT = 0xa1,
  149. ALS4K_GCRA2_FIFO2_PCIADDR = 0xa2,
  150. ALS4K_GCRA3_FIFO2_COUNT = 0xa3,
  151. ALS4K_GCRA4_FIFO2_CURRENT_ADDR = 0xa4,
  152. ALS4K_GCRA5_FIFO1_STATUS_BYTECOUNT = 0xa5,
  153. ALS4K_GCRA6_PM_CTRL = 0xa6,
  154. ALS4K_GCRA7_PCI_ACCESS_STORAGE = 0xa7,
  155. ALS4K_GCRA8_LEGACY_CFG1 = 0xa8,
  156. ALS4K_GCRA9_LEGACY_CFG2 = 0xa9,
  157. ALS4K_GCRFF_DUMMY_SCRATCH = 0xff,
  158. };
  159. enum als4k_gcr8c_t {
  160. ALS4K_GCR8C_IRQ_MASK_CTRL_ENABLE = 0x8000,
  161. ALS4K_GCR8C_CHIP_REV_MASK = 0xf0000
  162. };
  163. static inline void snd_als4k_iobase_writeb(unsigned long iobase,
  164. enum als4k_iobase_t reg,
  165. u8 val)
  166. {
  167. outb(val, iobase + reg);
  168. }
  169. static inline void snd_als4k_iobase_writel(unsigned long iobase,
  170. enum als4k_iobase_t reg,
  171. u32 val)
  172. {
  173. outl(val, iobase + reg);
  174. }
  175. static inline u8 snd_als4k_iobase_readb(unsigned long iobase,
  176. enum als4k_iobase_t reg)
  177. {
  178. return inb(iobase + reg);
  179. }
  180. static inline u32 snd_als4k_iobase_readl(unsigned long iobase,
  181. enum als4k_iobase_t reg)
  182. {
  183. return inl(iobase + reg);
  184. }
  185. static inline void snd_als4k_gcr_write_addr(unsigned long iobase,
  186. enum als4k_gcr_t reg,
  187. u32 val)
  188. {
  189. snd_als4k_iobase_writeb(iobase, ALS4K_IOB_0C_GCR_INDEX, reg);
  190. snd_als4k_iobase_writel(iobase, ALS4K_IOD_08_GCR_DATA, val);
  191. }
  192. static inline void snd_als4k_gcr_write(struct snd_sb *sb,
  193. enum als4k_gcr_t reg,
  194. u32 val)
  195. {
  196. snd_als4k_gcr_write_addr(sb->alt_port, reg, val);
  197. }
  198. static inline u32 snd_als4k_gcr_read_addr(unsigned long iobase,
  199. enum als4k_gcr_t reg)
  200. {
  201. /* SPECS_PAGE: 37/38 */
  202. snd_als4k_iobase_writeb(iobase, ALS4K_IOB_0C_GCR_INDEX, reg);
  203. return snd_als4k_iobase_readl(iobase, ALS4K_IOD_08_GCR_DATA);
  204. }
  205. static inline u32 snd_als4k_gcr_read(struct snd_sb *sb, enum als4k_gcr_t reg)
  206. {
  207. return snd_als4k_gcr_read_addr(sb->alt_port, reg);
  208. }
  209. enum als4k_cr_t { /* all registers 8bit wide; SPECS_PAGE: 20 to 23 */
  210. ALS4K_CR0_SB_CONFIG = 0x00,
  211. ALS4K_CR2_MISC_CONTROL = 0x02,
  212. ALS4K_CR3_CONFIGURATION = 0x03,
  213. ALS4K_CR17_FIFO_STATUS = 0x17,
  214. ALS4K_CR18_ESP_MAJOR_VERSION = 0x18,
  215. ALS4K_CR19_ESP_MINOR_VERSION = 0x19,
  216. ALS4K_CR1A_MPU401_UART_MODE_CONTROL = 0x1a,
  217. ALS4K_CR1C_FIFO2_BLOCK_LENGTH_LO = 0x1c,
  218. ALS4K_CR1D_FIFO2_BLOCK_LENGTH_HI = 0x1d,
  219. ALS4K_CR1E_FIFO2_CONTROL = 0x1e, /* secondary PCM FIFO (recording) */
  220. ALS4K_CR3A_MISC_CONTROL = 0x3a,
  221. ALS4K_CR3B_CRC32_BYTE0 = 0x3b, /* for testing, activate via CR3A */
  222. ALS4K_CR3C_CRC32_BYTE1 = 0x3c,
  223. ALS4K_CR3D_CRC32_BYTE2 = 0x3d,
  224. ALS4K_CR3E_CRC32_BYTE3 = 0x3e,
  225. };
  226. enum als4k_cr0_t {
  227. ALS4K_CR0_DMA_CONTIN_MODE_CTRL = 0x02, /* IRQ/FIFO controlled for 0/1 */
  228. ALS4K_CR0_DMA_90H_MODE_CTRL = 0x04, /* IRQ/FIFO controlled for 0/1 */
  229. ALS4K_CR0_MX80_81_REG_WRITE_ENABLE = 0x80,
  230. };
  231. static inline void snd_als4_cr_write(struct snd_sb *chip,
  232. enum als4k_cr_t reg,
  233. u8 data)
  234. {
  235. /* Control Register is reg | 0xc0 (bit 7, 6 set) on sbmixer_index
  236. * NOTE: assumes chip->mixer_lock to be locked externally already!
  237. * SPECS_PAGE: 6 */
  238. snd_sbmixer_write(chip, reg | 0xc0, data);
  239. }
  240. static inline u8 snd_als4_cr_read(struct snd_sb *chip,
  241. enum als4k_cr_t reg)
  242. {
  243. /* NOTE: assumes chip->mixer_lock to be locked externally already! */
  244. return snd_sbmixer_read(chip, reg | 0xc0);
  245. }
  246. static void snd_als4000_set_rate(struct snd_sb *chip, unsigned int rate)
  247. {
  248. if (!(chip->mode & SB_RATE_LOCK)) {
  249. snd_sbdsp_command(chip, SB_DSP_SAMPLE_RATE_OUT);
  250. snd_sbdsp_command(chip, rate>>8);
  251. snd_sbdsp_command(chip, rate);
  252. }
  253. }
  254. static inline void snd_als4000_set_capture_dma(struct snd_sb *chip,
  255. dma_addr_t addr, unsigned size)
  256. {
  257. /* SPECS_PAGE: 40 */
  258. snd_als4k_gcr_write(chip, ALS4K_GCRA2_FIFO2_PCIADDR, addr);
  259. snd_als4k_gcr_write(chip, ALS4K_GCRA3_FIFO2_COUNT, (size-1));
  260. }
  261. static inline void snd_als4000_set_playback_dma(struct snd_sb *chip,
  262. dma_addr_t addr,
  263. unsigned size)
  264. {
  265. /* SPECS_PAGE: 38 */
  266. snd_als4k_gcr_write(chip, ALS4K_GCR91_DMA0_ADDR, addr);
  267. snd_als4k_gcr_write(chip, ALS4K_GCR92_DMA0_MODE_COUNT,
  268. (size-1)|0x180000);
  269. }
  270. #define ALS4000_FORMAT_SIGNED (1<<0)
  271. #define ALS4000_FORMAT_16BIT (1<<1)
  272. #define ALS4000_FORMAT_STEREO (1<<2)
  273. static int snd_als4000_get_format(struct snd_pcm_runtime *runtime)
  274. {
  275. int result;
  276. result = 0;
  277. if (snd_pcm_format_signed(runtime->format))
  278. result |= ALS4000_FORMAT_SIGNED;
  279. if (snd_pcm_format_physical_width(runtime->format) == 16)
  280. result |= ALS4000_FORMAT_16BIT;
  281. if (runtime->channels > 1)
  282. result |= ALS4000_FORMAT_STEREO;
  283. return result;
  284. }
  285. /* structure for setting up playback */
  286. static const struct {
  287. unsigned char dsp_cmd, dma_on, dma_off, format;
  288. } playback_cmd_vals[]={
  289. /* ALS4000_FORMAT_U8_MONO */
  290. { SB_DSP4_OUT8_AI, SB_DSP_DMA8_ON, SB_DSP_DMA8_OFF, SB_DSP4_MODE_UNS_MONO },
  291. /* ALS4000_FORMAT_S8_MONO */
  292. { SB_DSP4_OUT8_AI, SB_DSP_DMA8_ON, SB_DSP_DMA8_OFF, SB_DSP4_MODE_SIGN_MONO },
  293. /* ALS4000_FORMAT_U16L_MONO */
  294. { SB_DSP4_OUT16_AI, SB_DSP_DMA16_ON, SB_DSP_DMA16_OFF, SB_DSP4_MODE_UNS_MONO },
  295. /* ALS4000_FORMAT_S16L_MONO */
  296. { SB_DSP4_OUT16_AI, SB_DSP_DMA16_ON, SB_DSP_DMA16_OFF, SB_DSP4_MODE_SIGN_MONO },
  297. /* ALS4000_FORMAT_U8_STEREO */
  298. { SB_DSP4_OUT8_AI, SB_DSP_DMA8_ON, SB_DSP_DMA8_OFF, SB_DSP4_MODE_UNS_STEREO },
  299. /* ALS4000_FORMAT_S8_STEREO */
  300. { SB_DSP4_OUT8_AI, SB_DSP_DMA8_ON, SB_DSP_DMA8_OFF, SB_DSP4_MODE_SIGN_STEREO },
  301. /* ALS4000_FORMAT_U16L_STEREO */
  302. { SB_DSP4_OUT16_AI, SB_DSP_DMA16_ON, SB_DSP_DMA16_OFF, SB_DSP4_MODE_UNS_STEREO },
  303. /* ALS4000_FORMAT_S16L_STEREO */
  304. { SB_DSP4_OUT16_AI, SB_DSP_DMA16_ON, SB_DSP_DMA16_OFF, SB_DSP4_MODE_SIGN_STEREO },
  305. };
  306. #define playback_cmd(chip) (playback_cmd_vals[(chip)->playback_format])
  307. /* structure for setting up capture */
  308. enum { CMD_WIDTH8=0x04, CMD_SIGNED=0x10, CMD_MONO=0x80, CMD_STEREO=0xA0 };
  309. static const unsigned char capture_cmd_vals[]=
  310. {
  311. CMD_WIDTH8|CMD_MONO, /* ALS4000_FORMAT_U8_MONO */
  312. CMD_WIDTH8|CMD_SIGNED|CMD_MONO, /* ALS4000_FORMAT_S8_MONO */
  313. CMD_MONO, /* ALS4000_FORMAT_U16L_MONO */
  314. CMD_SIGNED|CMD_MONO, /* ALS4000_FORMAT_S16L_MONO */
  315. CMD_WIDTH8|CMD_STEREO, /* ALS4000_FORMAT_U8_STEREO */
  316. CMD_WIDTH8|CMD_SIGNED|CMD_STEREO, /* ALS4000_FORMAT_S8_STEREO */
  317. CMD_STEREO, /* ALS4000_FORMAT_U16L_STEREO */
  318. CMD_SIGNED|CMD_STEREO, /* ALS4000_FORMAT_S16L_STEREO */
  319. };
  320. #define capture_cmd(chip) (capture_cmd_vals[(chip)->capture_format])
  321. static int snd_als4000_capture_prepare(struct snd_pcm_substream *substream)
  322. {
  323. struct snd_sb *chip = snd_pcm_substream_chip(substream);
  324. struct snd_pcm_runtime *runtime = substream->runtime;
  325. unsigned long size;
  326. unsigned count;
  327. chip->capture_format = snd_als4000_get_format(runtime);
  328. size = snd_pcm_lib_buffer_bytes(substream);
  329. count = snd_pcm_lib_period_bytes(substream);
  330. if (chip->capture_format & ALS4000_FORMAT_16BIT)
  331. count >>= 1;
  332. count--;
  333. spin_lock_irq(&chip->reg_lock);
  334. snd_als4000_set_rate(chip, runtime->rate);
  335. snd_als4000_set_capture_dma(chip, runtime->dma_addr, size);
  336. spin_unlock_irq(&chip->reg_lock);
  337. spin_lock_irq(&chip->mixer_lock);
  338. snd_als4_cr_write(chip, ALS4K_CR1C_FIFO2_BLOCK_LENGTH_LO, count & 0xff);
  339. snd_als4_cr_write(chip, ALS4K_CR1D_FIFO2_BLOCK_LENGTH_HI, count >> 8);
  340. spin_unlock_irq(&chip->mixer_lock);
  341. return 0;
  342. }
  343. static int snd_als4000_playback_prepare(struct snd_pcm_substream *substream)
  344. {
  345. struct snd_sb *chip = snd_pcm_substream_chip(substream);
  346. struct snd_pcm_runtime *runtime = substream->runtime;
  347. unsigned long size;
  348. unsigned count;
  349. chip->playback_format = snd_als4000_get_format(runtime);
  350. size = snd_pcm_lib_buffer_bytes(substream);
  351. count = snd_pcm_lib_period_bytes(substream);
  352. if (chip->playback_format & ALS4000_FORMAT_16BIT)
  353. count >>= 1;
  354. count--;
  355. /* FIXME: from second playback on, there's a lot more clicks and pops
  356. * involved here than on first playback. Fiddling with
  357. * tons of different settings didn't help (DMA, speaker on/off,
  358. * reordering, ...). Something seems to get enabled on playback
  359. * that I haven't found out how to disable again, which then causes
  360. * the switching pops to reach the speakers the next time here. */
  361. spin_lock_irq(&chip->reg_lock);
  362. snd_als4000_set_rate(chip, runtime->rate);
  363. snd_als4000_set_playback_dma(chip, runtime->dma_addr, size);
  364. /* SPEAKER_ON not needed, since dma_on seems to also enable speaker */
  365. /* snd_sbdsp_command(chip, SB_DSP_SPEAKER_ON); */
  366. snd_sbdsp_command(chip, playback_cmd(chip).dsp_cmd);
  367. snd_sbdsp_command(chip, playback_cmd(chip).format);
  368. snd_sbdsp_command(chip, count & 0xff);
  369. snd_sbdsp_command(chip, count >> 8);
  370. snd_sbdsp_command(chip, playback_cmd(chip).dma_off);
  371. spin_unlock_irq(&chip->reg_lock);
  372. return 0;
  373. }
  374. static int snd_als4000_capture_trigger(struct snd_pcm_substream *substream, int cmd)
  375. {
  376. struct snd_sb *chip = snd_pcm_substream_chip(substream);
  377. int result = 0;
  378. /* FIXME race condition in here!!!
  379. chip->mode non-atomic update gets consistently protected
  380. by reg_lock always, _except_ for this place!!
  381. Probably need to take reg_lock as outer (or inner??) lock, too.
  382. (or serialize both lock operations? probably not, though... - racy?)
  383. */
  384. spin_lock(&chip->mixer_lock);
  385. switch (cmd) {
  386. case SNDRV_PCM_TRIGGER_START:
  387. case SNDRV_PCM_TRIGGER_RESUME:
  388. chip->mode |= SB_RATE_LOCK_CAPTURE;
  389. snd_als4_cr_write(chip, ALS4K_CR1E_FIFO2_CONTROL,
  390. capture_cmd(chip));
  391. break;
  392. case SNDRV_PCM_TRIGGER_STOP:
  393. case SNDRV_PCM_TRIGGER_SUSPEND:
  394. chip->mode &= ~SB_RATE_LOCK_CAPTURE;
  395. snd_als4_cr_write(chip, ALS4K_CR1E_FIFO2_CONTROL,
  396. capture_cmd(chip));
  397. break;
  398. default:
  399. result = -EINVAL;
  400. break;
  401. }
  402. spin_unlock(&chip->mixer_lock);
  403. return result;
  404. }
  405. static int snd_als4000_playback_trigger(struct snd_pcm_substream *substream, int cmd)
  406. {
  407. struct snd_sb *chip = snd_pcm_substream_chip(substream);
  408. int result = 0;
  409. spin_lock(&chip->reg_lock);
  410. switch (cmd) {
  411. case SNDRV_PCM_TRIGGER_START:
  412. case SNDRV_PCM_TRIGGER_RESUME:
  413. chip->mode |= SB_RATE_LOCK_PLAYBACK;
  414. snd_sbdsp_command(chip, playback_cmd(chip).dma_on);
  415. break;
  416. case SNDRV_PCM_TRIGGER_STOP:
  417. case SNDRV_PCM_TRIGGER_SUSPEND:
  418. snd_sbdsp_command(chip, playback_cmd(chip).dma_off);
  419. chip->mode &= ~SB_RATE_LOCK_PLAYBACK;
  420. break;
  421. default:
  422. result = -EINVAL;
  423. break;
  424. }
  425. spin_unlock(&chip->reg_lock);
  426. return result;
  427. }
  428. static snd_pcm_uframes_t snd_als4000_capture_pointer(struct snd_pcm_substream *substream)
  429. {
  430. struct snd_sb *chip = snd_pcm_substream_chip(substream);
  431. unsigned int result;
  432. spin_lock(&chip->reg_lock);
  433. result = snd_als4k_gcr_read(chip, ALS4K_GCRA4_FIFO2_CURRENT_ADDR);
  434. spin_unlock(&chip->reg_lock);
  435. result &= 0xffff;
  436. return bytes_to_frames( substream->runtime, result );
  437. }
  438. static snd_pcm_uframes_t snd_als4000_playback_pointer(struct snd_pcm_substream *substream)
  439. {
  440. struct snd_sb *chip = snd_pcm_substream_chip(substream);
  441. unsigned result;
  442. spin_lock(&chip->reg_lock);
  443. result = snd_als4k_gcr_read(chip, ALS4K_GCRA0_FIFO1_CURRENT_ADDR);
  444. spin_unlock(&chip->reg_lock);
  445. result &= 0xffff;
  446. return bytes_to_frames( substream->runtime, result );
  447. }
  448. /* FIXME: this IRQ routine doesn't really support IRQ sharing (we always
  449. * return IRQ_HANDLED no matter whether we actually had an IRQ flag or not).
  450. * ALS4000a.PDF writes that while ACKing IRQ in PCI block will *not* ACK
  451. * the IRQ in the SB core, ACKing IRQ in SB block *will* ACK the PCI IRQ
  452. * register (alt_port + ALS4K_IOB_0E_IRQTYPE_SB_CR1E_MPU). Probably something
  453. * could be optimized here to query/write one register only...
  454. * And even if both registers need to be queried, then there's still the
  455. * question of whether it's actually correct to ACK PCI IRQ before reading
  456. * SB IRQ like we do now, since ALS4000a.PDF mentions that PCI IRQ will *clear*
  457. * SB IRQ status.
  458. * (hmm, SPECS_PAGE: 38 mentions it the other way around!)
  459. * And do we *really* need the lock here for *reading* SB_DSP4_IRQSTATUS??
  460. * */
  461. static irqreturn_t snd_als4000_interrupt(int irq, void *dev_id)
  462. {
  463. struct snd_sb *chip = dev_id;
  464. unsigned pci_irqstatus;
  465. unsigned sb_irqstatus;
  466. /* find out which bit of the ALS4000 PCI block produced the interrupt,
  467. SPECS_PAGE: 38, 5 */
  468. pci_irqstatus = snd_als4k_iobase_readb(chip->alt_port,
  469. ALS4K_IOB_0E_IRQTYPE_SB_CR1E_MPU);
  470. if ((pci_irqstatus & ALS4K_IOB_0E_SB_DMA_IRQ)
  471. && (chip->playback_substream)) /* playback */
  472. snd_pcm_period_elapsed(chip->playback_substream);
  473. if ((pci_irqstatus & ALS4K_IOB_0E_CR1E_IRQ)
  474. && (chip->capture_substream)) /* capturing */
  475. snd_pcm_period_elapsed(chip->capture_substream);
  476. if ((pci_irqstatus & ALS4K_IOB_0E_MPU_IRQ)
  477. && (chip->rmidi)) /* MPU401 interrupt */
  478. snd_mpu401_uart_interrupt(irq, chip->rmidi->private_data);
  479. /* ACK the PCI block IRQ */
  480. snd_als4k_iobase_writeb(chip->alt_port,
  481. ALS4K_IOB_0E_IRQTYPE_SB_CR1E_MPU, pci_irqstatus);
  482. spin_lock(&chip->mixer_lock);
  483. /* SPECS_PAGE: 20 */
  484. sb_irqstatus = snd_sbmixer_read(chip, SB_DSP4_IRQSTATUS);
  485. spin_unlock(&chip->mixer_lock);
  486. if (sb_irqstatus & SB_IRQTYPE_8BIT)
  487. snd_sb_ack_8bit(chip);
  488. if (sb_irqstatus & SB_IRQTYPE_16BIT)
  489. snd_sb_ack_16bit(chip);
  490. if (sb_irqstatus & SB_IRQTYPE_MPUIN)
  491. inb(chip->mpu_port);
  492. if (sb_irqstatus & ALS4K_IRQTYPE_CR1E_DMA)
  493. snd_als4k_iobase_readb(chip->alt_port,
  494. ALS4K_IOB_16_ACK_FOR_CR1E);
  495. /* dev_dbg(chip->card->dev, "als4000: irq 0x%04x 0x%04x\n",
  496. pci_irqstatus, sb_irqstatus); */
  497. /* only ack the things we actually handled above */
  498. return IRQ_RETVAL(
  499. (pci_irqstatus & (ALS4K_IOB_0E_SB_DMA_IRQ|ALS4K_IOB_0E_CR1E_IRQ|
  500. ALS4K_IOB_0E_MPU_IRQ))
  501. || (sb_irqstatus & (SB_IRQTYPE_8BIT|SB_IRQTYPE_16BIT|
  502. SB_IRQTYPE_MPUIN|ALS4K_IRQTYPE_CR1E_DMA))
  503. );
  504. }
  505. /*****************************************************************/
  506. static const struct snd_pcm_hardware snd_als4000_playback =
  507. {
  508. .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
  509. SNDRV_PCM_INFO_MMAP_VALID),
  510. .formats = SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_U8 |
  511. SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_U16_LE, /* formats */
  512. .rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_48000,
  513. .rate_min = 4000,
  514. .rate_max = 48000,
  515. .channels_min = 1,
  516. .channels_max = 2,
  517. .buffer_bytes_max = 65536,
  518. .period_bytes_min = 64,
  519. .period_bytes_max = 65536,
  520. .periods_min = 1,
  521. .periods_max = 1024,
  522. .fifo_size = 0
  523. };
  524. static const struct snd_pcm_hardware snd_als4000_capture =
  525. {
  526. .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
  527. SNDRV_PCM_INFO_MMAP_VALID),
  528. .formats = SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_U8 |
  529. SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_U16_LE, /* formats */
  530. .rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_48000,
  531. .rate_min = 4000,
  532. .rate_max = 48000,
  533. .channels_min = 1,
  534. .channels_max = 2,
  535. .buffer_bytes_max = 65536,
  536. .period_bytes_min = 64,
  537. .period_bytes_max = 65536,
  538. .periods_min = 1,
  539. .periods_max = 1024,
  540. .fifo_size = 0
  541. };
  542. /*****************************************************************/
  543. static int snd_als4000_playback_open(struct snd_pcm_substream *substream)
  544. {
  545. struct snd_sb *chip = snd_pcm_substream_chip(substream);
  546. struct snd_pcm_runtime *runtime = substream->runtime;
  547. chip->playback_substream = substream;
  548. runtime->hw = snd_als4000_playback;
  549. return 0;
  550. }
  551. static int snd_als4000_playback_close(struct snd_pcm_substream *substream)
  552. {
  553. struct snd_sb *chip = snd_pcm_substream_chip(substream);
  554. chip->playback_substream = NULL;
  555. return 0;
  556. }
  557. static int snd_als4000_capture_open(struct snd_pcm_substream *substream)
  558. {
  559. struct snd_sb *chip = snd_pcm_substream_chip(substream);
  560. struct snd_pcm_runtime *runtime = substream->runtime;
  561. chip->capture_substream = substream;
  562. runtime->hw = snd_als4000_capture;
  563. return 0;
  564. }
  565. static int snd_als4000_capture_close(struct snd_pcm_substream *substream)
  566. {
  567. struct snd_sb *chip = snd_pcm_substream_chip(substream);
  568. chip->capture_substream = NULL;
  569. return 0;
  570. }
  571. /******************************************************************/
  572. static const struct snd_pcm_ops snd_als4000_playback_ops = {
  573. .open = snd_als4000_playback_open,
  574. .close = snd_als4000_playback_close,
  575. .prepare = snd_als4000_playback_prepare,
  576. .trigger = snd_als4000_playback_trigger,
  577. .pointer = snd_als4000_playback_pointer
  578. };
  579. static const struct snd_pcm_ops snd_als4000_capture_ops = {
  580. .open = snd_als4000_capture_open,
  581. .close = snd_als4000_capture_close,
  582. .prepare = snd_als4000_capture_prepare,
  583. .trigger = snd_als4000_capture_trigger,
  584. .pointer = snd_als4000_capture_pointer
  585. };
  586. static int snd_als4000_pcm(struct snd_sb *chip, int device)
  587. {
  588. struct snd_pcm *pcm;
  589. int err;
  590. err = snd_pcm_new(chip->card, "ALS4000 DSP", device, 1, 1, &pcm);
  591. if (err < 0)
  592. return err;
  593. pcm->private_data = chip;
  594. pcm->info_flags = SNDRV_PCM_INFO_JOINT_DUPLEX;
  595. snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_als4000_playback_ops);
  596. snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_als4000_capture_ops);
  597. snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV,
  598. &chip->pci->dev, 64*1024, 64*1024);
  599. chip->pcm = pcm;
  600. return 0;
  601. }
  602. /******************************************************************/
  603. static void snd_als4000_set_addr(unsigned long iobase,
  604. unsigned int sb_io,
  605. unsigned int mpu_io,
  606. unsigned int opl_io,
  607. unsigned int game_io)
  608. {
  609. u32 cfg1 = 0;
  610. u32 cfg2 = 0;
  611. if (mpu_io > 0)
  612. cfg2 |= (mpu_io | 1) << 16;
  613. if (sb_io > 0)
  614. cfg2 |= (sb_io | 1);
  615. if (game_io > 0)
  616. cfg1 |= (game_io | 1) << 16;
  617. if (opl_io > 0)
  618. cfg1 |= (opl_io | 1);
  619. snd_als4k_gcr_write_addr(iobase, ALS4K_GCRA8_LEGACY_CFG1, cfg1);
  620. snd_als4k_gcr_write_addr(iobase, ALS4K_GCRA9_LEGACY_CFG2, cfg2);
  621. }
  622. static void snd_als4000_configure(struct snd_sb *chip)
  623. {
  624. u8 tmp;
  625. int i;
  626. /* do some more configuration */
  627. spin_lock_irq(&chip->mixer_lock);
  628. tmp = snd_als4_cr_read(chip, ALS4K_CR0_SB_CONFIG);
  629. snd_als4_cr_write(chip, ALS4K_CR0_SB_CONFIG,
  630. tmp|ALS4K_CR0_MX80_81_REG_WRITE_ENABLE);
  631. /* always select DMA channel 0, since we do not actually use DMA
  632. * SPECS_PAGE: 19/20 */
  633. snd_sbmixer_write(chip, SB_DSP4_DMASETUP, SB_DMASETUP_DMA0);
  634. snd_als4_cr_write(chip, ALS4K_CR0_SB_CONFIG,
  635. tmp & ~ALS4K_CR0_MX80_81_REG_WRITE_ENABLE);
  636. spin_unlock_irq(&chip->mixer_lock);
  637. spin_lock_irq(&chip->reg_lock);
  638. /* enable interrupts */
  639. snd_als4k_gcr_write(chip, ALS4K_GCR8C_MISC_CTRL,
  640. ALS4K_GCR8C_IRQ_MASK_CTRL_ENABLE);
  641. /* SPECS_PAGE: 39 */
  642. for (i = ALS4K_GCR91_DMA0_ADDR; i <= ALS4K_GCR96_DMA3_MODE_COUNT; ++i)
  643. snd_als4k_gcr_write(chip, i, 0);
  644. /* enable burst mode to prevent dropouts during high PCI bus usage */
  645. snd_als4k_gcr_write(chip, ALS4K_GCR99_DMA_EMULATION_CTRL,
  646. (snd_als4k_gcr_read(chip, ALS4K_GCR99_DMA_EMULATION_CTRL) & ~0x07) | 0x04);
  647. spin_unlock_irq(&chip->reg_lock);
  648. }
  649. #ifdef SUPPORT_JOYSTICK
  650. static int snd_als4000_create_gameport(struct snd_card_als4000 *acard, int dev)
  651. {
  652. struct gameport *gp;
  653. struct resource *r;
  654. int io_port;
  655. if (joystick_port[dev] == 0)
  656. return -ENODEV;
  657. if (joystick_port[dev] == 1) { /* auto-detect */
  658. for (io_port = 0x200; io_port <= 0x218; io_port += 8) {
  659. r = devm_request_region(&acard->pci->dev, io_port, 8,
  660. "ALS4000 gameport");
  661. if (r)
  662. break;
  663. }
  664. } else {
  665. io_port = joystick_port[dev];
  666. r = devm_request_region(&acard->pci->dev, io_port, 8,
  667. "ALS4000 gameport");
  668. }
  669. if (!r) {
  670. dev_warn(&acard->pci->dev, "cannot reserve joystick ports\n");
  671. return -EBUSY;
  672. }
  673. acard->gameport = gp = gameport_allocate_port();
  674. if (!gp) {
  675. dev_err(&acard->pci->dev, "cannot allocate memory for gameport\n");
  676. return -ENOMEM;
  677. }
  678. gameport_set_name(gp, "ALS4000 Gameport");
  679. gameport_set_phys(gp, "pci%s/gameport0", pci_name(acard->pci));
  680. gameport_set_dev_parent(gp, &acard->pci->dev);
  681. gp->io = io_port;
  682. /* Enable legacy joystick port */
  683. snd_als4000_set_addr(acard->iobase, 0, 0, 0, 1);
  684. gameport_register_port(acard->gameport);
  685. return 0;
  686. }
  687. static void snd_als4000_free_gameport(struct snd_card_als4000 *acard)
  688. {
  689. if (acard->gameport) {
  690. gameport_unregister_port(acard->gameport);
  691. acard->gameport = NULL;
  692. /* disable joystick */
  693. snd_als4000_set_addr(acard->iobase, 0, 0, 0, 0);
  694. }
  695. }
  696. #else
  697. static inline int snd_als4000_create_gameport(struct snd_card_als4000 *acard, int dev) { return -ENOSYS; }
  698. static inline void snd_als4000_free_gameport(struct snd_card_als4000 *acard) { }
  699. #endif
  700. static void snd_card_als4000_free( struct snd_card *card )
  701. {
  702. struct snd_card_als4000 *acard = card->private_data;
  703. /* make sure that interrupts are disabled */
  704. snd_als4k_gcr_write_addr(acard->iobase, ALS4K_GCR8C_MISC_CTRL, 0);
  705. /* free resources */
  706. snd_als4000_free_gameport(acard);
  707. }
  708. static int __snd_card_als4000_probe(struct pci_dev *pci,
  709. const struct pci_device_id *pci_id)
  710. {
  711. static int dev;
  712. struct snd_card *card;
  713. struct snd_card_als4000 *acard;
  714. unsigned long iobase;
  715. struct snd_sb *chip;
  716. struct snd_opl3 *opl3;
  717. unsigned short word;
  718. int err;
  719. if (dev >= SNDRV_CARDS)
  720. return -ENODEV;
  721. if (!enable[dev]) {
  722. dev++;
  723. return -ENOENT;
  724. }
  725. /* enable PCI device */
  726. err = pcim_enable_device(pci);
  727. if (err < 0)
  728. return err;
  729. /* check, if we can restrict PCI DMA transfers to 24 bits */
  730. if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(24))) {
  731. dev_err(&pci->dev, "architecture does not support 24bit PCI busmaster DMA\n");
  732. return -ENXIO;
  733. }
  734. err = pci_request_regions(pci, "ALS4000");
  735. if (err < 0)
  736. return err;
  737. iobase = pci_resource_start(pci, 0);
  738. pci_read_config_word(pci, PCI_COMMAND, &word);
  739. pci_write_config_word(pci, PCI_COMMAND, word | PCI_COMMAND_IO);
  740. pci_set_master(pci);
  741. err = snd_devm_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
  742. sizeof(*acard) /* private_data: acard */,
  743. &card);
  744. if (err < 0)
  745. return err;
  746. acard = card->private_data;
  747. acard->pci = pci;
  748. acard->iobase = iobase;
  749. card->private_free = snd_card_als4000_free;
  750. /* disable all legacy ISA stuff */
  751. snd_als4000_set_addr(acard->iobase, 0, 0, 0, 0);
  752. err = snd_sbdsp_create(card,
  753. iobase + ALS4K_IOB_10_ADLIB_ADDR0,
  754. pci->irq,
  755. /* internally registered as IRQF_SHARED in case of ALS4000 SB */
  756. snd_als4000_interrupt,
  757. -1,
  758. -1,
  759. SB_HW_ALS4000,
  760. &chip);
  761. if (err < 0)
  762. return err;
  763. acard->chip = chip;
  764. chip->pci = pci;
  765. chip->alt_port = iobase;
  766. snd_als4000_configure(chip);
  767. strcpy(card->driver, "ALS4000");
  768. strcpy(card->shortname, "Avance Logic ALS4000");
  769. sprintf(card->longname, "%s at 0x%lx, irq %i",
  770. card->shortname, chip->alt_port, chip->irq);
  771. err = snd_mpu401_uart_new(card, 0, MPU401_HW_ALS4000,
  772. iobase + ALS4K_IOB_30_MIDI_DATA,
  773. MPU401_INFO_INTEGRATED |
  774. MPU401_INFO_IRQ_HOOK,
  775. -1, &chip->rmidi);
  776. if (err < 0) {
  777. dev_err(&pci->dev, "no MPU-401 device at 0x%lx?\n",
  778. iobase + ALS4K_IOB_30_MIDI_DATA);
  779. return err;
  780. }
  781. /* FIXME: ALS4000 has interesting MPU401 configuration features
  782. * at ALS4K_CR1A_MPU401_UART_MODE_CONTROL
  783. * (pass-thru / UART switching, fast MIDI clock, etc.),
  784. * however there doesn't seem to be an ALSA API for this...
  785. * SPECS_PAGE: 21 */
  786. err = snd_als4000_pcm(chip, 0);
  787. if (err < 0)
  788. return err;
  789. err = snd_sbmixer_new(chip);
  790. if (err < 0)
  791. return err;
  792. if (snd_opl3_create(card,
  793. iobase + ALS4K_IOB_10_ADLIB_ADDR0,
  794. iobase + ALS4K_IOB_12_ADLIB_ADDR2,
  795. OPL3_HW_AUTO, 1, &opl3) < 0) {
  796. dev_err(&pci->dev, "no OPL device at 0x%lx-0x%lx?\n",
  797. iobase + ALS4K_IOB_10_ADLIB_ADDR0,
  798. iobase + ALS4K_IOB_12_ADLIB_ADDR2);
  799. } else {
  800. err = snd_opl3_hwdep_new(opl3, 0, 1, NULL);
  801. if (err < 0)
  802. return err;
  803. }
  804. snd_als4000_create_gameport(acard, dev);
  805. err = snd_card_register(card);
  806. if (err < 0)
  807. return err;
  808. pci_set_drvdata(pci, card);
  809. dev++;
  810. return 0;
  811. }
  812. static int snd_card_als4000_probe(struct pci_dev *pci,
  813. const struct pci_device_id *pci_id)
  814. {
  815. return snd_card_free_on_error(&pci->dev, __snd_card_als4000_probe(pci, pci_id));
  816. }
  817. #ifdef CONFIG_PM_SLEEP
  818. static int snd_als4000_suspend(struct device *dev)
  819. {
  820. struct snd_card *card = dev_get_drvdata(dev);
  821. struct snd_card_als4000 *acard = card->private_data;
  822. struct snd_sb *chip = acard->chip;
  823. snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
  824. snd_sbmixer_suspend(chip);
  825. return 0;
  826. }
  827. static int snd_als4000_resume(struct device *dev)
  828. {
  829. struct snd_card *card = dev_get_drvdata(dev);
  830. struct snd_card_als4000 *acard = card->private_data;
  831. struct snd_sb *chip = acard->chip;
  832. snd_als4000_configure(chip);
  833. snd_sbdsp_reset(chip);
  834. snd_sbmixer_resume(chip);
  835. #ifdef SUPPORT_JOYSTICK
  836. if (acard->gameport)
  837. snd_als4000_set_addr(acard->iobase, 0, 0, 0, 1);
  838. #endif
  839. snd_power_change_state(card, SNDRV_CTL_POWER_D0);
  840. return 0;
  841. }
  842. static SIMPLE_DEV_PM_OPS(snd_als4000_pm, snd_als4000_suspend, snd_als4000_resume);
  843. #define SND_ALS4000_PM_OPS &snd_als4000_pm
  844. #else
  845. #define SND_ALS4000_PM_OPS NULL
  846. #endif /* CONFIG_PM_SLEEP */
  847. static struct pci_driver als4000_driver = {
  848. .name = KBUILD_MODNAME,
  849. .id_table = snd_als4000_ids,
  850. .probe = snd_card_als4000_probe,
  851. .driver = {
  852. .pm = SND_ALS4000_PM_OPS,
  853. },
  854. };
  855. module_pci_driver(als4000_driver);