pss.c 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266
  1. /*
  2. * sound/oss/pss.c
  3. *
  4. * The low level driver for the Personal Sound System (ECHO ESC614).
  5. *
  6. *
  7. * Copyright (C) by Hannu Savolainen 1993-1997
  8. *
  9. * OSS/Free for Linux is distributed under the GNU GENERAL PUBLIC LICENSE (GPL)
  10. * Version 2 (June 1991). See the "COPYING" file distributed with this software
  11. * for more info.
  12. *
  13. *
  14. * Thomas Sailer ioctl code reworked (vmalloc/vfree removed)
  15. * Alan Cox modularisation, clean up.
  16. *
  17. * 98-02-21: Vladimir Michl <vladimir.michl@upol.cz>
  18. * Added mixer device for Beethoven ADSP-16 (master volume,
  19. * bass, treble, synth), only for speakers.
  20. * Fixed bug in pss_write (exchange parameters)
  21. * Fixed config port of SB
  22. * Requested two regions for PSS (PSS mixer, PSS config)
  23. * Modified pss_download_boot
  24. * To probe_pss_mss added test for initialize AD1848
  25. * 98-05-28: Vladimir Michl <vladimir.michl@upol.cz>
  26. * Fixed computation of mixer volumes
  27. * 04-05-1999: Anthony Barbachan <barbcode@xmen.cis.fordham.edu>
  28. * Added code that allows the user to enable his cdrom and/or
  29. * joystick through the module parameters pss_cdrom_port and
  30. * pss_enable_joystick. pss_cdrom_port takes a port address as its
  31. * argument. pss_enable_joystick takes either a 0 or a non-0 as its
  32. * argument.
  33. * 04-06-1999: Anthony Barbachan <barbcode@xmen.cis.fordham.edu>
  34. * Separated some code into new functions for easier reuse.
  35. * Cleaned up and streamlined new code. Added code to allow a user
  36. * to only use this driver for enabling non-sound components
  37. * through the new module parameter pss_no_sound (flag). Added
  38. * code that would allow a user to decide whether the driver should
  39. * reset the configured hardware settings for the PSS board through
  40. * the module parameter pss_keep_settings (flag). This flag will
  41. * allow a user to free up resources in use by this card if needbe,
  42. * furthermore it allows him to use this driver to just enable the
  43. * emulations and then be unloaded as it is no longer needed. Both
  44. * new settings are only available to this driver if compiled as a
  45. * module. The default settings of all new parameters are set to
  46. * load the driver as it did in previous versions.
  47. * 04-07-1999: Anthony Barbachan <barbcode@xmen.cis.fordham.edu>
  48. * Added module parameter pss_firmware to allow the user to tell
  49. * the driver where the firmware file is located. The default
  50. * setting is the previous hardcoded setting "/etc/sound/pss_synth".
  51. * 00-03-03: Christoph Hellwig <chhellwig@infradead.org>
  52. * Adapted to module_init/module_exit
  53. * 11-10-2000: Bartlomiej Zolnierkiewicz <bkz@linux-ide.org>
  54. * Added __init to probe_pss(), attach_pss() and probe_pss_mpu()
  55. * 02-Jan-2001: Chris Rankin
  56. * Specify that this module owns the coprocessor
  57. */
  58. #include <linux/init.h>
  59. #include <linux/module.h>
  60. #include <linux/spinlock.h>
  61. #include "sound_config.h"
  62. #include "sound_firmware.h"
  63. #include "ad1848.h"
  64. #include "mpu401.h"
  65. /*
  66. * PSS registers.
  67. */
  68. #define REG(x) (devc->base+x)
  69. #define PSS_DATA 0
  70. #define PSS_STATUS 2
  71. #define PSS_CONTROL 2
  72. #define PSS_ID 4
  73. #define PSS_IRQACK 4
  74. #define PSS_PIO 0x1a
  75. /*
  76. * Config registers
  77. */
  78. #define CONF_PSS 0x10
  79. #define CONF_WSS 0x12
  80. #define CONF_SB 0x14
  81. #define CONF_CDROM 0x16
  82. #define CONF_MIDI 0x18
  83. /*
  84. * Status bits.
  85. */
  86. #define PSS_FLAG3 0x0800
  87. #define PSS_FLAG2 0x0400
  88. #define PSS_FLAG1 0x1000
  89. #define PSS_FLAG0 0x0800
  90. #define PSS_WRITE_EMPTY 0x8000
  91. #define PSS_READ_FULL 0x4000
  92. /*
  93. * WSS registers
  94. */
  95. #define WSS_INDEX 4
  96. #define WSS_DATA 5
  97. /*
  98. * WSS status bits
  99. */
  100. #define WSS_INITIALIZING 0x80
  101. #define WSS_AUTOCALIBRATION 0x20
  102. #define NO_WSS_MIXER -1
  103. #include "coproc.h"
  104. #include "pss_boot.h"
  105. /* If compiled into kernel, it enable or disable pss mixer */
  106. #ifdef CONFIG_PSS_MIXER
  107. static int pss_mixer = 1;
  108. #else
  109. static int pss_mixer;
  110. #endif
  111. typedef struct pss_mixerdata {
  112. unsigned int volume_l;
  113. unsigned int volume_r;
  114. unsigned int bass;
  115. unsigned int treble;
  116. unsigned int synth;
  117. } pss_mixerdata;
  118. typedef struct pss_confdata {
  119. int base;
  120. int irq;
  121. int dma;
  122. int *osp;
  123. pss_mixerdata mixer;
  124. int ad_mixer_dev;
  125. } pss_confdata;
  126. static pss_confdata pss_data;
  127. static pss_confdata *devc = &pss_data;
  128. static DEFINE_SPINLOCK(lock);
  129. static int pss_initialized;
  130. static int nonstandard_microcode;
  131. static int pss_cdrom_port = -1; /* Parameter for the PSS cdrom port */
  132. static int pss_enable_joystick; /* Parameter for enabling the joystick */
  133. static coproc_operations pss_coproc_operations;
  134. static void pss_write(pss_confdata *devc, int data)
  135. {
  136. unsigned long i, limit;
  137. limit = jiffies + HZ/10; /* The timeout is 0.1 seconds */
  138. /*
  139. * Note! the i<5000000 is an emergency exit. The dsp_command() is sometimes
  140. * called while interrupts are disabled. This means that the timer is
  141. * disabled also. However the timeout situation is a abnormal condition.
  142. * Normally the DSP should be ready to accept commands after just couple of
  143. * loops.
  144. */
  145. for (i = 0; i < 5000000 && time_before(jiffies, limit); i++)
  146. {
  147. if (inw(REG(PSS_STATUS)) & PSS_WRITE_EMPTY)
  148. {
  149. outw(data, REG(PSS_DATA));
  150. return;
  151. }
  152. }
  153. printk(KERN_WARNING "PSS: DSP Command (%04x) Timeout.\n", data);
  154. }
  155. static int __init probe_pss(struct address_info *hw_config)
  156. {
  157. unsigned short id;
  158. int irq, dma;
  159. devc->base = hw_config->io_base;
  160. irq = devc->irq = hw_config->irq;
  161. dma = devc->dma = hw_config->dma;
  162. devc->osp = hw_config->osp;
  163. if (devc->base != 0x220 && devc->base != 0x240)
  164. if (devc->base != 0x230 && devc->base != 0x250) /* Some cards use these */
  165. return 0;
  166. if (!request_region(devc->base, 0x10, "PSS mixer, SB emulation")) {
  167. printk(KERN_ERR "PSS: I/O port conflict\n");
  168. return 0;
  169. }
  170. id = inw(REG(PSS_ID));
  171. if ((id >> 8) != 'E') {
  172. printk(KERN_ERR "No PSS signature detected at 0x%x (0x%x)\n", devc->base, id);
  173. release_region(devc->base, 0x10);
  174. return 0;
  175. }
  176. if (!request_region(devc->base + 0x10, 0x9, "PSS config")) {
  177. printk(KERN_ERR "PSS: I/O port conflict\n");
  178. release_region(devc->base, 0x10);
  179. return 0;
  180. }
  181. return 1;
  182. }
  183. static int set_irq(pss_confdata * devc, int dev, int irq)
  184. {
  185. static unsigned short irq_bits[16] =
  186. {
  187. 0x0000, 0x0000, 0x0000, 0x0008,
  188. 0x0000, 0x0010, 0x0000, 0x0018,
  189. 0x0000, 0x0020, 0x0028, 0x0030,
  190. 0x0038, 0x0000, 0x0000, 0x0000
  191. };
  192. unsigned short tmp, bits;
  193. if (irq < 0 || irq > 15)
  194. return 0;
  195. tmp = inw(REG(dev)) & ~0x38; /* Load confreg, mask IRQ bits out */
  196. if ((bits = irq_bits[irq]) == 0 && irq != 0)
  197. {
  198. printk(KERN_ERR "PSS: Invalid IRQ %d\n", irq);
  199. return 0;
  200. }
  201. outw(tmp | bits, REG(dev));
  202. return 1;
  203. }
  204. static void set_io_base(pss_confdata * devc, int dev, int base)
  205. {
  206. unsigned short tmp = inw(REG(dev)) & 0x003f;
  207. unsigned short bits = (base & 0x0ffc) << 4;
  208. outw(bits | tmp, REG(dev));
  209. }
  210. static int set_dma(pss_confdata * devc, int dev, int dma)
  211. {
  212. static unsigned short dma_bits[8] =
  213. {
  214. 0x0001, 0x0002, 0x0000, 0x0003,
  215. 0x0000, 0x0005, 0x0006, 0x0007
  216. };
  217. unsigned short tmp, bits;
  218. if (dma < 0 || dma > 7)
  219. return 0;
  220. tmp = inw(REG(dev)) & ~0x07; /* Load confreg, mask DMA bits out */
  221. if ((bits = dma_bits[dma]) == 0 && dma != 4)
  222. {
  223. printk(KERN_ERR "PSS: Invalid DMA %d\n", dma);
  224. return 0;
  225. }
  226. outw(tmp | bits, REG(dev));
  227. return 1;
  228. }
  229. static int pss_reset_dsp(pss_confdata * devc)
  230. {
  231. unsigned long i, limit = jiffies + HZ/10;
  232. outw(0x2000, REG(PSS_CONTROL));
  233. for (i = 0; i < 32768 && (limit-jiffies >= 0); i++)
  234. inw(REG(PSS_CONTROL));
  235. outw(0x0000, REG(PSS_CONTROL));
  236. return 1;
  237. }
  238. static int pss_put_dspword(pss_confdata * devc, unsigned short word)
  239. {
  240. int i, val;
  241. for (i = 0; i < 327680; i++)
  242. {
  243. val = inw(REG(PSS_STATUS));
  244. if (val & PSS_WRITE_EMPTY)
  245. {
  246. outw(word, REG(PSS_DATA));
  247. return 1;
  248. }
  249. }
  250. return 0;
  251. }
  252. static int pss_get_dspword(pss_confdata * devc, unsigned short *word)
  253. {
  254. int i, val;
  255. for (i = 0; i < 327680; i++)
  256. {
  257. val = inw(REG(PSS_STATUS));
  258. if (val & PSS_READ_FULL)
  259. {
  260. *word = inw(REG(PSS_DATA));
  261. return 1;
  262. }
  263. }
  264. return 0;
  265. }
  266. static int pss_download_boot(pss_confdata * devc, unsigned char *block, int size, int flags)
  267. {
  268. int i, val, count;
  269. unsigned long limit;
  270. if (flags & CPF_FIRST)
  271. {
  272. /*_____ Warn DSP software that a boot is coming */
  273. outw(0x00fe, REG(PSS_DATA));
  274. limit = jiffies + HZ/10;
  275. for (i = 0; i < 32768 && time_before(jiffies, limit); i++)
  276. if (inw(REG(PSS_DATA)) == 0x5500)
  277. break;
  278. outw(*block++, REG(PSS_DATA));
  279. pss_reset_dsp(devc);
  280. }
  281. count = 1;
  282. while ((flags&CPF_LAST) || count<size )
  283. {
  284. int j;
  285. for (j = 0; j < 327670; j++)
  286. {
  287. /*_____ Wait for BG to appear */
  288. if (inw(REG(PSS_STATUS)) & PSS_FLAG3)
  289. break;
  290. }
  291. if (j == 327670)
  292. {
  293. /* It's ok we timed out when the file was empty */
  294. if (count >= size && flags & CPF_LAST)
  295. break;
  296. else
  297. {
  298. printk("\n");
  299. printk(KERN_ERR "PSS: Download timeout problems, byte %d=%d\n", count, size);
  300. return 0;
  301. }
  302. }
  303. /*_____ Send the next byte */
  304. if (count >= size)
  305. {
  306. /* If not data in block send 0xffff */
  307. outw (0xffff, REG (PSS_DATA));
  308. }
  309. else
  310. {
  311. /*_____ Send the next byte */
  312. outw (*block++, REG (PSS_DATA));
  313. };
  314. count++;
  315. }
  316. if (flags & CPF_LAST)
  317. {
  318. /*_____ Why */
  319. outw(0, REG(PSS_DATA));
  320. limit = jiffies + HZ/10;
  321. for (i = 0; i < 32768 && (limit - jiffies >= 0); i++)
  322. val = inw(REG(PSS_STATUS));
  323. limit = jiffies + HZ/10;
  324. for (i = 0; i < 32768 && (limit-jiffies >= 0); i++)
  325. {
  326. val = inw(REG(PSS_STATUS));
  327. if (val & 0x4000)
  328. break;
  329. }
  330. /* now read the version */
  331. for (i = 0; i < 32000; i++)
  332. {
  333. val = inw(REG(PSS_STATUS));
  334. if (val & PSS_READ_FULL)
  335. break;
  336. }
  337. if (i == 32000)
  338. return 0;
  339. val = inw(REG(PSS_DATA));
  340. /* printk( "<PSS: microcode version %d.%d loaded>", val/16, val % 16); */
  341. }
  342. return 1;
  343. }
  344. /* Mixer */
  345. static void set_master_volume(pss_confdata *devc, int left, int right)
  346. {
  347. static unsigned char log_scale[101] = {
  348. 0xdb, 0xe0, 0xe3, 0xe5, 0xe7, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xed, 0xee,
  349. 0xef, 0xef, 0xf0, 0xf0, 0xf1, 0xf1, 0xf2, 0xf2, 0xf2, 0xf3, 0xf3, 0xf3,
  350. 0xf4, 0xf4, 0xf4, 0xf5, 0xf5, 0xf5, 0xf5, 0xf6, 0xf6, 0xf6, 0xf6, 0xf7,
  351. 0xf7, 0xf7, 0xf7, 0xf7, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf9, 0xf9, 0xf9,
  352. 0xf9, 0xf9, 0xf9, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfb, 0xfb,
  353. 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc,
  354. 0xfc, 0xfc, 0xfc, 0xfc, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd,
  355. 0xfd, 0xfd, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
  356. 0xfe, 0xfe, 0xff, 0xff, 0xff
  357. };
  358. pss_write(devc, 0x0010);
  359. pss_write(devc, log_scale[left] | 0x0000);
  360. pss_write(devc, 0x0010);
  361. pss_write(devc, log_scale[right] | 0x0100);
  362. }
  363. static void set_synth_volume(pss_confdata *devc, int volume)
  364. {
  365. int vol = ((0x8000*volume)/100L);
  366. pss_write(devc, 0x0080);
  367. pss_write(devc, vol);
  368. pss_write(devc, 0x0081);
  369. pss_write(devc, vol);
  370. }
  371. static void set_bass(pss_confdata *devc, int level)
  372. {
  373. int vol = (int)(((0xfd - 0xf0) * level)/100L) + 0xf0;
  374. pss_write(devc, 0x0010);
  375. pss_write(devc, vol | 0x0200);
  376. };
  377. static void set_treble(pss_confdata *devc, int level)
  378. {
  379. int vol = (((0xfd - 0xf0) * level)/100L) + 0xf0;
  380. pss_write(devc, 0x0010);
  381. pss_write(devc, vol | 0x0300);
  382. };
  383. static void pss_mixer_reset(pss_confdata *devc)
  384. {
  385. set_master_volume(devc, 33, 33);
  386. set_bass(devc, 50);
  387. set_treble(devc, 50);
  388. set_synth_volume(devc, 30);
  389. pss_write (devc, 0x0010);
  390. pss_write (devc, 0x0800 | 0xce); /* Stereo */
  391. if(pss_mixer)
  392. {
  393. devc->mixer.volume_l = devc->mixer.volume_r = 33;
  394. devc->mixer.bass = 50;
  395. devc->mixer.treble = 50;
  396. devc->mixer.synth = 30;
  397. }
  398. }
  399. static int set_volume_mono(unsigned __user *p, unsigned int *aleft)
  400. {
  401. unsigned int left, volume;
  402. if (get_user(volume, p))
  403. return -EFAULT;
  404. left = volume & 0xff;
  405. if (left > 100)
  406. left = 100;
  407. *aleft = left;
  408. return 0;
  409. }
  410. static int set_volume_stereo(unsigned __user *p,
  411. unsigned int *aleft,
  412. unsigned int *aright)
  413. {
  414. unsigned int left, right, volume;
  415. if (get_user(volume, p))
  416. return -EFAULT;
  417. left = volume & 0xff;
  418. if (left > 100)
  419. left = 100;
  420. right = (volume >> 8) & 0xff;
  421. if (right > 100)
  422. right = 100;
  423. *aleft = left;
  424. *aright = right;
  425. return 0;
  426. }
  427. static int ret_vol_mono(int left)
  428. {
  429. return ((left << 8) | left);
  430. }
  431. static int ret_vol_stereo(int left, int right)
  432. {
  433. return ((right << 8) | left);
  434. }
  435. static int call_ad_mixer(pss_confdata *devc,unsigned int cmd, void __user *arg)
  436. {
  437. if (devc->ad_mixer_dev != NO_WSS_MIXER)
  438. return mixer_devs[devc->ad_mixer_dev]->ioctl(devc->ad_mixer_dev, cmd, arg);
  439. else
  440. return -EINVAL;
  441. }
  442. static int pss_mixer_ioctl (int dev, unsigned int cmd, void __user *arg)
  443. {
  444. pss_confdata *devc = mixer_devs[dev]->devc;
  445. int cmdf = cmd & 0xff;
  446. if ((cmdf != SOUND_MIXER_VOLUME) && (cmdf != SOUND_MIXER_BASS) &&
  447. (cmdf != SOUND_MIXER_TREBLE) && (cmdf != SOUND_MIXER_SYNTH) &&
  448. (cmdf != SOUND_MIXER_DEVMASK) && (cmdf != SOUND_MIXER_STEREODEVS) &&
  449. (cmdf != SOUND_MIXER_RECMASK) && (cmdf != SOUND_MIXER_CAPS) &&
  450. (cmdf != SOUND_MIXER_RECSRC))
  451. {
  452. return call_ad_mixer(devc, cmd, arg);
  453. }
  454. if (((cmd >> 8) & 0xff) != 'M')
  455. return -EINVAL;
  456. if (_SIOC_DIR (cmd) & _SIOC_WRITE)
  457. {
  458. switch (cmdf)
  459. {
  460. case SOUND_MIXER_RECSRC:
  461. if (devc->ad_mixer_dev != NO_WSS_MIXER)
  462. return call_ad_mixer(devc, cmd, arg);
  463. else
  464. {
  465. int v;
  466. if (get_user(v, (int __user *)arg))
  467. return -EFAULT;
  468. if (v != 0)
  469. return -EINVAL;
  470. return 0;
  471. }
  472. case SOUND_MIXER_VOLUME:
  473. if (set_volume_stereo(arg,
  474. &devc->mixer.volume_l,
  475. &devc->mixer.volume_r))
  476. return -EFAULT;
  477. set_master_volume(devc, devc->mixer.volume_l,
  478. devc->mixer.volume_r);
  479. return ret_vol_stereo(devc->mixer.volume_l,
  480. devc->mixer.volume_r);
  481. case SOUND_MIXER_BASS:
  482. if (set_volume_mono(arg, &devc->mixer.bass))
  483. return -EFAULT;
  484. set_bass(devc, devc->mixer.bass);
  485. return ret_vol_mono(devc->mixer.bass);
  486. case SOUND_MIXER_TREBLE:
  487. if (set_volume_mono(arg, &devc->mixer.treble))
  488. return -EFAULT;
  489. set_treble(devc, devc->mixer.treble);
  490. return ret_vol_mono(devc->mixer.treble);
  491. case SOUND_MIXER_SYNTH:
  492. if (set_volume_mono(arg, &devc->mixer.synth))
  493. return -EFAULT;
  494. set_synth_volume(devc, devc->mixer.synth);
  495. return ret_vol_mono(devc->mixer.synth);
  496. default:
  497. return -EINVAL;
  498. }
  499. }
  500. else
  501. {
  502. int val, and_mask = 0, or_mask = 0;
  503. /*
  504. * Return parameters
  505. */
  506. switch (cmdf)
  507. {
  508. case SOUND_MIXER_DEVMASK:
  509. if (call_ad_mixer(devc, cmd, arg) == -EINVAL)
  510. break;
  511. and_mask = ~0;
  512. or_mask = SOUND_MASK_VOLUME | SOUND_MASK_BASS | SOUND_MASK_TREBLE | SOUND_MASK_SYNTH;
  513. break;
  514. case SOUND_MIXER_STEREODEVS:
  515. if (call_ad_mixer(devc, cmd, arg) == -EINVAL)
  516. break;
  517. and_mask = ~0;
  518. or_mask = SOUND_MASK_VOLUME;
  519. break;
  520. case SOUND_MIXER_RECMASK:
  521. if (devc->ad_mixer_dev != NO_WSS_MIXER)
  522. return call_ad_mixer(devc, cmd, arg);
  523. break;
  524. case SOUND_MIXER_CAPS:
  525. if (devc->ad_mixer_dev != NO_WSS_MIXER)
  526. return call_ad_mixer(devc, cmd, arg);
  527. or_mask = SOUND_CAP_EXCL_INPUT;
  528. break;
  529. case SOUND_MIXER_RECSRC:
  530. if (devc->ad_mixer_dev != NO_WSS_MIXER)
  531. return call_ad_mixer(devc, cmd, arg);
  532. break;
  533. case SOUND_MIXER_VOLUME:
  534. or_mask = ret_vol_stereo(devc->mixer.volume_l, devc->mixer.volume_r);
  535. break;
  536. case SOUND_MIXER_BASS:
  537. or_mask = ret_vol_mono(devc->mixer.bass);
  538. break;
  539. case SOUND_MIXER_TREBLE:
  540. or_mask = ret_vol_mono(devc->mixer.treble);
  541. break;
  542. case SOUND_MIXER_SYNTH:
  543. or_mask = ret_vol_mono(devc->mixer.synth);
  544. break;
  545. default:
  546. return -EINVAL;
  547. }
  548. if (get_user(val, (int __user *)arg))
  549. return -EFAULT;
  550. val &= and_mask;
  551. val |= or_mask;
  552. if (put_user(val, (int __user *)arg))
  553. return -EFAULT;
  554. return val;
  555. }
  556. }
  557. static struct mixer_operations pss_mixer_operations =
  558. {
  559. .owner = THIS_MODULE,
  560. .id = "SOUNDPORT",
  561. .name = "PSS-AD1848",
  562. .ioctl = pss_mixer_ioctl
  563. };
  564. static void disable_all_emulations(void)
  565. {
  566. outw(0x0000, REG(CONF_PSS)); /* 0x0400 enables joystick */
  567. outw(0x0000, REG(CONF_WSS));
  568. outw(0x0000, REG(CONF_SB));
  569. outw(0x0000, REG(CONF_MIDI));
  570. outw(0x0000, REG(CONF_CDROM));
  571. }
  572. static void configure_nonsound_components(void)
  573. {
  574. /* Configure Joystick port */
  575. if(pss_enable_joystick)
  576. {
  577. outw(0x0400, REG(CONF_PSS)); /* 0x0400 enables joystick */
  578. printk(KERN_INFO "PSS: joystick enabled.\n");
  579. }
  580. else
  581. {
  582. printk(KERN_INFO "PSS: joystick port not enabled.\n");
  583. }
  584. /* Configure CDROM port */
  585. if (pss_cdrom_port == -1) { /* If cdrom port enablation wasn't requested */
  586. printk(KERN_INFO "PSS: CDROM port not enabled.\n");
  587. } else if (check_region(pss_cdrom_port, 2)) {
  588. printk(KERN_ERR "PSS: CDROM I/O port conflict.\n");
  589. } else {
  590. set_io_base(devc, CONF_CDROM, pss_cdrom_port);
  591. printk(KERN_INFO "PSS: CDROM I/O port set to 0x%x.\n", pss_cdrom_port);
  592. }
  593. }
  594. static int __init attach_pss(struct address_info *hw_config)
  595. {
  596. unsigned short id;
  597. char tmp[100];
  598. devc->base = hw_config->io_base;
  599. devc->irq = hw_config->irq;
  600. devc->dma = hw_config->dma;
  601. devc->osp = hw_config->osp;
  602. devc->ad_mixer_dev = NO_WSS_MIXER;
  603. if (!probe_pss(hw_config))
  604. return 0;
  605. id = inw(REG(PSS_ID)) & 0x00ff;
  606. /*
  607. * Disable all emulations. Will be enabled later (if required).
  608. */
  609. disable_all_emulations();
  610. #ifdef YOU_REALLY_WANT_TO_ALLOCATE_THESE_RESOURCES
  611. if (sound_alloc_dma(hw_config->dma, "PSS"))
  612. {
  613. printk("pss.c: Can't allocate DMA channel.\n");
  614. release_region(hw_config->io_base, 0x10);
  615. release_region(hw_config->io_base+0x10, 0x9);
  616. return 0;
  617. }
  618. if (!set_irq(devc, CONF_PSS, devc->irq))
  619. {
  620. printk("PSS: IRQ allocation error.\n");
  621. release_region(hw_config->io_base, 0x10);
  622. release_region(hw_config->io_base+0x10, 0x9);
  623. return 0;
  624. }
  625. if (!set_dma(devc, CONF_PSS, devc->dma))
  626. {
  627. printk(KERN_ERR "PSS: DMA allocation error\n");
  628. release_region(hw_config->io_base, 0x10);
  629. release_region(hw_config->io_base+0x10, 0x9);
  630. return 0;
  631. }
  632. #endif
  633. configure_nonsound_components();
  634. pss_initialized = 1;
  635. sprintf(tmp, "ECHO-PSS Rev. %d", id);
  636. conf_printf(tmp, hw_config);
  637. return 1;
  638. }
  639. static int __init probe_pss_mpu(struct address_info *hw_config)
  640. {
  641. struct resource *ports;
  642. int timeout;
  643. if (!pss_initialized)
  644. return 0;
  645. ports = request_region(hw_config->io_base, 2, "mpu401");
  646. if (!ports) {
  647. printk(KERN_ERR "PSS: MPU I/O port conflict\n");
  648. return 0;
  649. }
  650. set_io_base(devc, CONF_MIDI, hw_config->io_base);
  651. if (!set_irq(devc, CONF_MIDI, hw_config->irq)) {
  652. printk(KERN_ERR "PSS: MIDI IRQ allocation error.\n");
  653. goto fail;
  654. }
  655. if (!pss_synthLen) {
  656. printk(KERN_ERR "PSS: Can't enable MPU. MIDI synth microcode not available.\n");
  657. goto fail;
  658. }
  659. if (!pss_download_boot(devc, pss_synth, pss_synthLen, CPF_FIRST | CPF_LAST)) {
  660. printk(KERN_ERR "PSS: Unable to load MIDI synth microcode to DSP.\n");
  661. goto fail;
  662. }
  663. /*
  664. * Finally wait until the DSP algorithm has initialized itself and
  665. * deactivates receive interrupt.
  666. */
  667. for (timeout = 900000; timeout > 0; timeout--)
  668. {
  669. if ((inb(hw_config->io_base + 1) & 0x80) == 0) /* Input data avail */
  670. inb(hw_config->io_base); /* Discard it */
  671. else
  672. break; /* No more input */
  673. }
  674. if (!probe_mpu401(hw_config, ports))
  675. goto fail;
  676. attach_mpu401(hw_config, THIS_MODULE); /* Slot 1 */
  677. if (hw_config->slots[1] != -1) /* The MPU driver installed itself */
  678. midi_devs[hw_config->slots[1]]->coproc = &pss_coproc_operations;
  679. return 1;
  680. fail:
  681. release_region(hw_config->io_base, 2);
  682. return 0;
  683. }
  684. static int pss_coproc_open(void *dev_info, int sub_device)
  685. {
  686. switch (sub_device)
  687. {
  688. case COPR_MIDI:
  689. if (pss_synthLen == 0)
  690. {
  691. printk(KERN_ERR "PSS: MIDI synth microcode not available.\n");
  692. return -EIO;
  693. }
  694. if (nonstandard_microcode)
  695. if (!pss_download_boot(devc, pss_synth, pss_synthLen, CPF_FIRST | CPF_LAST))
  696. {
  697. printk(KERN_ERR "PSS: Unable to load MIDI synth microcode to DSP.\n");
  698. return -EIO;
  699. }
  700. nonstandard_microcode = 0;
  701. break;
  702. default:
  703. break;
  704. }
  705. return 0;
  706. }
  707. static void pss_coproc_close(void *dev_info, int sub_device)
  708. {
  709. return;
  710. }
  711. static void pss_coproc_reset(void *dev_info)
  712. {
  713. if (pss_synthLen)
  714. if (!pss_download_boot(devc, pss_synth, pss_synthLen, CPF_FIRST | CPF_LAST))
  715. {
  716. printk(KERN_ERR "PSS: Unable to load MIDI synth microcode to DSP.\n");
  717. }
  718. nonstandard_microcode = 0;
  719. }
  720. static int download_boot_block(void *dev_info, copr_buffer * buf)
  721. {
  722. if (buf->len <= 0 || buf->len > sizeof(buf->data))
  723. return -EINVAL;
  724. if (!pss_download_boot(devc, buf->data, buf->len, buf->flags))
  725. {
  726. printk(KERN_ERR "PSS: Unable to load microcode block to DSP.\n");
  727. return -EIO;
  728. }
  729. nonstandard_microcode = 1; /* The MIDI microcode has been overwritten */
  730. return 0;
  731. }
  732. static int pss_coproc_ioctl(void *dev_info, unsigned int cmd, void __user *arg, int local)
  733. {
  734. copr_buffer *buf;
  735. copr_msg *mbuf;
  736. copr_debug_buf dbuf;
  737. unsigned short tmp;
  738. unsigned long flags;
  739. unsigned short *data;
  740. int i, err;
  741. /* printk( "PSS coproc ioctl %x %x %d\n", cmd, arg, local); */
  742. switch (cmd)
  743. {
  744. case SNDCTL_COPR_RESET:
  745. pss_coproc_reset(dev_info);
  746. return 0;
  747. case SNDCTL_COPR_LOAD:
  748. buf = (copr_buffer *) vmalloc(sizeof(copr_buffer));
  749. if (buf == NULL)
  750. return -ENOSPC;
  751. if (copy_from_user(buf, arg, sizeof(copr_buffer))) {
  752. vfree(buf);
  753. return -EFAULT;
  754. }
  755. err = download_boot_block(dev_info, buf);
  756. vfree(buf);
  757. return err;
  758. case SNDCTL_COPR_SENDMSG:
  759. mbuf = (copr_msg *)vmalloc(sizeof(copr_msg));
  760. if (mbuf == NULL)
  761. return -ENOSPC;
  762. if (copy_from_user(mbuf, arg, sizeof(copr_msg))) {
  763. vfree(mbuf);
  764. return -EFAULT;
  765. }
  766. data = (unsigned short *)(mbuf->data);
  767. spin_lock_irqsave(&lock, flags);
  768. for (i = 0; i < mbuf->len; i++) {
  769. if (!pss_put_dspword(devc, *data++)) {
  770. spin_unlock_irqrestore(&lock,flags);
  771. mbuf->len = i; /* feed back number of WORDs sent */
  772. err = copy_to_user(arg, mbuf, sizeof(copr_msg));
  773. vfree(mbuf);
  774. return err ? -EFAULT : -EIO;
  775. }
  776. }
  777. spin_unlock_irqrestore(&lock,flags);
  778. vfree(mbuf);
  779. return 0;
  780. case SNDCTL_COPR_RCVMSG:
  781. err = 0;
  782. mbuf = (copr_msg *)vmalloc(sizeof(copr_msg));
  783. if (mbuf == NULL)
  784. return -ENOSPC;
  785. data = (unsigned short *)mbuf->data;
  786. spin_lock_irqsave(&lock, flags);
  787. for (i = 0; i < sizeof(mbuf->data)/sizeof(unsigned short); i++) {
  788. mbuf->len = i; /* feed back number of WORDs read */
  789. if (!pss_get_dspword(devc, data++)) {
  790. if (i == 0)
  791. err = -EIO;
  792. break;
  793. }
  794. }
  795. spin_unlock_irqrestore(&lock,flags);
  796. if (copy_to_user(arg, mbuf, sizeof(copr_msg)))
  797. err = -EFAULT;
  798. vfree(mbuf);
  799. return err;
  800. case SNDCTL_COPR_RDATA:
  801. if (copy_from_user(&dbuf, arg, sizeof(dbuf)))
  802. return -EFAULT;
  803. spin_lock_irqsave(&lock, flags);
  804. if (!pss_put_dspword(devc, 0x00d0)) {
  805. spin_unlock_irqrestore(&lock,flags);
  806. return -EIO;
  807. }
  808. if (!pss_put_dspword(devc, (unsigned short)(dbuf.parm1 & 0xffff))) {
  809. spin_unlock_irqrestore(&lock,flags);
  810. return -EIO;
  811. }
  812. if (!pss_get_dspword(devc, &tmp)) {
  813. spin_unlock_irqrestore(&lock,flags);
  814. return -EIO;
  815. }
  816. dbuf.parm1 = tmp;
  817. spin_unlock_irqrestore(&lock,flags);
  818. if (copy_to_user(arg, &dbuf, sizeof(dbuf)))
  819. return -EFAULT;
  820. return 0;
  821. case SNDCTL_COPR_WDATA:
  822. if (copy_from_user(&dbuf, arg, sizeof(dbuf)))
  823. return -EFAULT;
  824. spin_lock_irqsave(&lock, flags);
  825. if (!pss_put_dspword(devc, 0x00d1)) {
  826. spin_unlock_irqrestore(&lock,flags);
  827. return -EIO;
  828. }
  829. if (!pss_put_dspword(devc, (unsigned short) (dbuf.parm1 & 0xffff))) {
  830. spin_unlock_irqrestore(&lock,flags);
  831. return -EIO;
  832. }
  833. tmp = (unsigned int)dbuf.parm2 & 0xffff;
  834. if (!pss_put_dspword(devc, tmp)) {
  835. spin_unlock_irqrestore(&lock,flags);
  836. return -EIO;
  837. }
  838. spin_unlock_irqrestore(&lock,flags);
  839. return 0;
  840. case SNDCTL_COPR_WCODE:
  841. if (copy_from_user(&dbuf, arg, sizeof(dbuf)))
  842. return -EFAULT;
  843. spin_lock_irqsave(&lock, flags);
  844. if (!pss_put_dspword(devc, 0x00d3)) {
  845. spin_unlock_irqrestore(&lock,flags);
  846. return -EIO;
  847. }
  848. if (!pss_put_dspword(devc, (unsigned short)(dbuf.parm1 & 0xffff))) {
  849. spin_unlock_irqrestore(&lock,flags);
  850. return -EIO;
  851. }
  852. tmp = (unsigned int)dbuf.parm2 & 0x00ff;
  853. if (!pss_put_dspword(devc, tmp)) {
  854. spin_unlock_irqrestore(&lock,flags);
  855. return -EIO;
  856. }
  857. tmp = ((unsigned int)dbuf.parm2 >> 8) & 0xffff;
  858. if (!pss_put_dspword(devc, tmp)) {
  859. spin_unlock_irqrestore(&lock,flags);
  860. return -EIO;
  861. }
  862. spin_unlock_irqrestore(&lock,flags);
  863. return 0;
  864. case SNDCTL_COPR_RCODE:
  865. if (copy_from_user(&dbuf, arg, sizeof(dbuf)))
  866. return -EFAULT;
  867. spin_lock_irqsave(&lock, flags);
  868. if (!pss_put_dspword(devc, 0x00d2)) {
  869. spin_unlock_irqrestore(&lock,flags);
  870. return -EIO;
  871. }
  872. if (!pss_put_dspword(devc, (unsigned short)(dbuf.parm1 & 0xffff))) {
  873. spin_unlock_irqrestore(&lock,flags);
  874. return -EIO;
  875. }
  876. if (!pss_get_dspword(devc, &tmp)) { /* Read MSB */
  877. spin_unlock_irqrestore(&lock,flags);
  878. return -EIO;
  879. }
  880. dbuf.parm1 = tmp << 8;
  881. if (!pss_get_dspword(devc, &tmp)) { /* Read LSB */
  882. spin_unlock_irqrestore(&lock,flags);
  883. return -EIO;
  884. }
  885. dbuf.parm1 |= tmp & 0x00ff;
  886. spin_unlock_irqrestore(&lock,flags);
  887. if (copy_to_user(arg, &dbuf, sizeof(dbuf)))
  888. return -EFAULT;
  889. return 0;
  890. default:
  891. return -EINVAL;
  892. }
  893. return -EINVAL;
  894. }
  895. static coproc_operations pss_coproc_operations =
  896. {
  897. "ADSP-2115",
  898. THIS_MODULE,
  899. pss_coproc_open,
  900. pss_coproc_close,
  901. pss_coproc_ioctl,
  902. pss_coproc_reset,
  903. &pss_data
  904. };
  905. static int __init probe_pss_mss(struct address_info *hw_config)
  906. {
  907. volatile int timeout;
  908. struct resource *ports;
  909. int my_mix = -999; /* gcc shut up */
  910. if (!pss_initialized)
  911. return 0;
  912. if (!request_region(hw_config->io_base, 4, "WSS config")) {
  913. printk(KERN_ERR "PSS: WSS I/O port conflicts.\n");
  914. return 0;
  915. }
  916. ports = request_region(hw_config->io_base + 4, 4, "ad1848");
  917. if (!ports) {
  918. printk(KERN_ERR "PSS: WSS I/O port conflicts.\n");
  919. release_region(hw_config->io_base, 4);
  920. return 0;
  921. }
  922. set_io_base(devc, CONF_WSS, hw_config->io_base);
  923. if (!set_irq(devc, CONF_WSS, hw_config->irq)) {
  924. printk("PSS: WSS IRQ allocation error.\n");
  925. goto fail;
  926. }
  927. if (!set_dma(devc, CONF_WSS, hw_config->dma)) {
  928. printk(KERN_ERR "PSS: WSS DMA allocation error\n");
  929. goto fail;
  930. }
  931. /*
  932. * For some reason the card returns 0xff in the WSS status register
  933. * immediately after boot. Probably MIDI+SB emulation algorithm
  934. * downloaded to the ADSP2115 spends some time initializing the card.
  935. * Let's try to wait until it finishes this task.
  936. */
  937. for (timeout = 0; timeout < 100000 && (inb(hw_config->io_base + WSS_INDEX) &
  938. WSS_INITIALIZING); timeout++)
  939. ;
  940. outb((0x0b), hw_config->io_base + WSS_INDEX); /* Required by some cards */
  941. for (timeout = 0; (inb(hw_config->io_base + WSS_DATA) & WSS_AUTOCALIBRATION) &&
  942. (timeout < 100000); timeout++)
  943. ;
  944. if (!probe_ms_sound(hw_config, ports))
  945. goto fail;
  946. devc->ad_mixer_dev = NO_WSS_MIXER;
  947. if (pss_mixer)
  948. {
  949. if ((my_mix = sound_install_mixer (MIXER_DRIVER_VERSION,
  950. "PSS-SPEAKERS and AD1848 (through MSS audio codec)",
  951. &pss_mixer_operations,
  952. sizeof (struct mixer_operations),
  953. devc)) < 0)
  954. {
  955. printk(KERN_ERR "Could not install PSS mixer\n");
  956. goto fail;
  957. }
  958. }
  959. pss_mixer_reset(devc);
  960. attach_ms_sound(hw_config, ports, THIS_MODULE); /* Slot 0 */
  961. if (hw_config->slots[0] != -1)
  962. {
  963. /* The MSS driver installed itself */
  964. audio_devs[hw_config->slots[0]]->coproc = &pss_coproc_operations;
  965. if (pss_mixer && (num_mixers == (my_mix + 2)))
  966. {
  967. /* The MSS mixer installed */
  968. devc->ad_mixer_dev = audio_devs[hw_config->slots[0]]->mixer_dev;
  969. }
  970. }
  971. return 1;
  972. fail:
  973. release_region(hw_config->io_base + 4, 4);
  974. release_region(hw_config->io_base, 4);
  975. return 0;
  976. }
  977. static inline void __exit unload_pss(struct address_info *hw_config)
  978. {
  979. release_region(hw_config->io_base, 0x10);
  980. release_region(hw_config->io_base+0x10, 0x9);
  981. }
  982. static inline void __exit unload_pss_mpu(struct address_info *hw_config)
  983. {
  984. unload_mpu401(hw_config);
  985. }
  986. static inline void __exit unload_pss_mss(struct address_info *hw_config)
  987. {
  988. unload_ms_sound(hw_config);
  989. }
  990. static struct address_info cfg;
  991. static struct address_info cfg2;
  992. static struct address_info cfg_mpu;
  993. static int pss_io __initdata = -1;
  994. static int mss_io __initdata = -1;
  995. static int mss_irq __initdata = -1;
  996. static int mss_dma __initdata = -1;
  997. static int mpu_io __initdata = -1;
  998. static int mpu_irq __initdata = -1;
  999. static int pss_no_sound = 0; /* Just configure non-sound components */
  1000. static int pss_keep_settings = 1; /* Keep hardware settings at module exit */
  1001. static char *pss_firmware = "/etc/sound/pss_synth";
  1002. module_param(pss_io, int, 0);
  1003. MODULE_PARM_DESC(pss_io, "Set i/o base of PSS card (probably 0x220 or 0x240)");
  1004. module_param(mss_io, int, 0);
  1005. MODULE_PARM_DESC(mss_io, "Set WSS (audio) i/o base (0x530, 0x604, 0xE80, 0xF40, or other. Address must end in 0 or 4 and must be from 0x100 to 0xFF4)");
  1006. module_param(mss_irq, int, 0);
  1007. MODULE_PARM_DESC(mss_irq, "Set WSS (audio) IRQ (3, 5, 7, 9, 10, 11, 12)");
  1008. module_param(mss_dma, int, 0);
  1009. MODULE_PARM_DESC(mss_dma, "Set WSS (audio) DMA (0, 1, 3)");
  1010. module_param(mpu_io, int, 0);
  1011. MODULE_PARM_DESC(mpu_io, "Set MIDI i/o base (0x330 or other. Address must be on 4 location boundaries and must be from 0x100 to 0xFFC)");
  1012. module_param(mpu_irq, int, 0);
  1013. MODULE_PARM_DESC(mpu_irq, "Set MIDI IRQ (3, 5, 7, 9, 10, 11, 12)");
  1014. module_param(pss_cdrom_port, int, 0);
  1015. MODULE_PARM_DESC(pss_cdrom_port, "Set the PSS CDROM port i/o base (0x340 or other)");
  1016. module_param(pss_enable_joystick, bool, 0);
  1017. MODULE_PARM_DESC(pss_enable_joystick, "Enables the PSS joystick port (1 to enable, 0 to disable)");
  1018. module_param(pss_no_sound, bool, 0);
  1019. MODULE_PARM_DESC(pss_no_sound, "Configure sound compoents (0 - no, 1 - yes)");
  1020. module_param(pss_keep_settings, bool, 0);
  1021. MODULE_PARM_DESC(pss_keep_settings, "Keep hardware setting at driver unloading (0 - no, 1 - yes)");
  1022. module_param(pss_firmware, charp, 0);
  1023. MODULE_PARM_DESC(pss_firmware, "Location of the firmware file (default - /etc/sound/pss_synth)");
  1024. module_param(pss_mixer, bool, 0);
  1025. MODULE_PARM_DESC(pss_mixer, "Enable (1) or disable (0) PSS mixer (controlling of output volume, bass, treble, synth volume). The mixer is not available on all PSS cards.");
  1026. MODULE_AUTHOR("Hannu Savolainen, Vladimir Michl");
  1027. MODULE_DESCRIPTION("Module for PSS sound cards (based on AD1848, ADSP-2115 and ESC614). This module includes control of output amplifier and synth volume of the Beethoven ADSP-16 card (this may work with other PSS cards).");
  1028. MODULE_LICENSE("GPL");
  1029. static int fw_load = 0;
  1030. static int pssmpu = 0, pssmss = 0;
  1031. /*
  1032. * Load a PSS sound card module
  1033. */
  1034. static int __init init_pss(void)
  1035. {
  1036. if(pss_no_sound) /* If configuring only nonsound components */
  1037. {
  1038. cfg.io_base = pss_io;
  1039. if(!probe_pss(&cfg))
  1040. return -ENODEV;
  1041. printk(KERN_INFO "ECHO-PSS Rev. %d\n", inw(REG(PSS_ID)) & 0x00ff);
  1042. printk(KERN_INFO "PSS: loading in no sound mode.\n");
  1043. disable_all_emulations();
  1044. configure_nonsound_components();
  1045. release_region(pss_io, 0x10);
  1046. release_region(pss_io + 0x10, 0x9);
  1047. return 0;
  1048. }
  1049. cfg.io_base = pss_io;
  1050. cfg2.io_base = mss_io;
  1051. cfg2.irq = mss_irq;
  1052. cfg2.dma = mss_dma;
  1053. cfg_mpu.io_base = mpu_io;
  1054. cfg_mpu.irq = mpu_irq;
  1055. if (cfg.io_base == -1 || cfg2.io_base == -1 || cfg2.irq == -1 || cfg.dma == -1) {
  1056. printk(KERN_INFO "pss: mss_io, mss_dma, mss_irq and pss_io must be set.\n");
  1057. return -EINVAL;
  1058. }
  1059. if (!pss_synth) {
  1060. fw_load = 1;
  1061. pss_synthLen = mod_firmware_load(pss_firmware, (void *) &pss_synth);
  1062. }
  1063. if (!attach_pss(&cfg))
  1064. return -ENODEV;
  1065. /*
  1066. * Attach stuff
  1067. */
  1068. if (probe_pss_mpu(&cfg_mpu))
  1069. pssmpu = 1;
  1070. if (probe_pss_mss(&cfg2))
  1071. pssmss = 1;
  1072. return 0;
  1073. }
  1074. static void __exit cleanup_pss(void)
  1075. {
  1076. if(!pss_no_sound)
  1077. {
  1078. if(fw_load && pss_synth)
  1079. vfree(pss_synth);
  1080. if(pssmss)
  1081. unload_pss_mss(&cfg2);
  1082. if(pssmpu)
  1083. unload_pss_mpu(&cfg_mpu);
  1084. unload_pss(&cfg);
  1085. }
  1086. if(!pss_keep_settings) /* Keep hardware settings if asked */
  1087. {
  1088. disable_all_emulations();
  1089. printk(KERN_INFO "Resetting PSS sound card configurations.\n");
  1090. }
  1091. }
  1092. module_init(init_pss);
  1093. module_exit(cleanup_pss);
  1094. #ifndef MODULE
  1095. static int __init setup_pss(char *str)
  1096. {
  1097. /* io, mss_io, mss_irq, mss_dma, mpu_io, mpu_irq */
  1098. int ints[7];
  1099. str = get_options(str, ARRAY_SIZE(ints), ints);
  1100. pss_io = ints[1];
  1101. mss_io = ints[2];
  1102. mss_irq = ints[3];
  1103. mss_dma = ints[4];
  1104. mpu_io = ints[5];
  1105. mpu_irq = ints[6];
  1106. return 1;
  1107. }
  1108. __setup("pss=", setup_pss);
  1109. #endif