pss.c 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282
  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 fireware 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 int 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. return 1;
  210. }
  211. static int set_dma(pss_confdata * devc, int dev, int dma)
  212. {
  213. static unsigned short dma_bits[8] =
  214. {
  215. 0x0001, 0x0002, 0x0000, 0x0003,
  216. 0x0000, 0x0005, 0x0006, 0x0007
  217. };
  218. unsigned short tmp, bits;
  219. if (dma < 0 || dma > 7)
  220. return 0;
  221. tmp = inw(REG(dev)) & ~0x07; /* Load confreg, mask DMA bits out */
  222. if ((bits = dma_bits[dma]) == 0 && dma != 4)
  223. {
  224. printk(KERN_ERR "PSS: Invalid DMA %d\n", dma);
  225. return 0;
  226. }
  227. outw(tmp | bits, REG(dev));
  228. return 1;
  229. }
  230. static int pss_reset_dsp(pss_confdata * devc)
  231. {
  232. unsigned long i, limit = jiffies + HZ/10;
  233. outw(0x2000, REG(PSS_CONTROL));
  234. for (i = 0; i < 32768 && (limit-jiffies >= 0); i++)
  235. inw(REG(PSS_CONTROL));
  236. outw(0x0000, REG(PSS_CONTROL));
  237. return 1;
  238. }
  239. static int pss_put_dspword(pss_confdata * devc, unsigned short word)
  240. {
  241. int i, val;
  242. for (i = 0; i < 327680; i++)
  243. {
  244. val = inw(REG(PSS_STATUS));
  245. if (val & PSS_WRITE_EMPTY)
  246. {
  247. outw(word, REG(PSS_DATA));
  248. return 1;
  249. }
  250. }
  251. return 0;
  252. }
  253. static int pss_get_dspword(pss_confdata * devc, unsigned short *word)
  254. {
  255. int i, val;
  256. for (i = 0; i < 327680; i++)
  257. {
  258. val = inw(REG(PSS_STATUS));
  259. if (val & PSS_READ_FULL)
  260. {
  261. *word = inw(REG(PSS_DATA));
  262. return 1;
  263. }
  264. }
  265. return 0;
  266. }
  267. static int pss_download_boot(pss_confdata * devc, unsigned char *block, int size, int flags)
  268. {
  269. int i, val, count;
  270. unsigned long limit;
  271. if (flags & CPF_FIRST)
  272. {
  273. /*_____ Warn DSP software that a boot is coming */
  274. outw(0x00fe, REG(PSS_DATA));
  275. limit = jiffies + HZ/10;
  276. for (i = 0; i < 32768 && time_before(jiffies, limit); i++)
  277. if (inw(REG(PSS_DATA)) == 0x5500)
  278. break;
  279. outw(*block++, REG(PSS_DATA));
  280. pss_reset_dsp(devc);
  281. }
  282. count = 1;
  283. while ((flags&CPF_LAST) || count<size )
  284. {
  285. int j;
  286. for (j = 0; j < 327670; j++)
  287. {
  288. /*_____ Wait for BG to appear */
  289. if (inw(REG(PSS_STATUS)) & PSS_FLAG3)
  290. break;
  291. }
  292. if (j == 327670)
  293. {
  294. /* It's ok we timed out when the file was empty */
  295. if (count >= size && flags & CPF_LAST)
  296. break;
  297. else
  298. {
  299. printk("\n");
  300. printk(KERN_ERR "PSS: Download timeout problems, byte %d=%d\n", count, size);
  301. return 0;
  302. }
  303. }
  304. /*_____ Send the next byte */
  305. if (count >= size)
  306. {
  307. /* If not data in block send 0xffff */
  308. outw (0xffff, REG (PSS_DATA));
  309. }
  310. else
  311. {
  312. /*_____ Send the next byte */
  313. outw (*block++, REG (PSS_DATA));
  314. };
  315. count++;
  316. }
  317. if (flags & CPF_LAST)
  318. {
  319. /*_____ Why */
  320. outw(0, REG(PSS_DATA));
  321. limit = jiffies + HZ/10;
  322. for (i = 0; i < 32768 && (limit - jiffies >= 0); i++)
  323. val = inw(REG(PSS_STATUS));
  324. limit = jiffies + HZ/10;
  325. for (i = 0; i < 32768 && (limit-jiffies >= 0); i++)
  326. {
  327. val = inw(REG(PSS_STATUS));
  328. if (val & 0x4000)
  329. break;
  330. }
  331. /* now read the version */
  332. for (i = 0; i < 32000; i++)
  333. {
  334. val = inw(REG(PSS_STATUS));
  335. if (val & PSS_READ_FULL)
  336. break;
  337. }
  338. if (i == 32000)
  339. return 0;
  340. val = inw(REG(PSS_DATA));
  341. /* printk( "<PSS: microcode version %d.%d loaded>", val/16, val % 16); */
  342. }
  343. return 1;
  344. }
  345. /* Mixer */
  346. static void set_master_volume(pss_confdata *devc, int left, int right)
  347. {
  348. static unsigned char log_scale[101] = {
  349. 0xdb, 0xe0, 0xe3, 0xe5, 0xe7, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xed, 0xee,
  350. 0xef, 0xef, 0xf0, 0xf0, 0xf1, 0xf1, 0xf2, 0xf2, 0xf2, 0xf3, 0xf3, 0xf3,
  351. 0xf4, 0xf4, 0xf4, 0xf5, 0xf5, 0xf5, 0xf5, 0xf6, 0xf6, 0xf6, 0xf6, 0xf7,
  352. 0xf7, 0xf7, 0xf7, 0xf7, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf9, 0xf9, 0xf9,
  353. 0xf9, 0xf9, 0xf9, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfb, 0xfb,
  354. 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc, 0xfc,
  355. 0xfc, 0xfc, 0xfc, 0xfc, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd, 0xfd,
  356. 0xfd, 0xfd, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
  357. 0xfe, 0xfe, 0xff, 0xff, 0xff
  358. };
  359. pss_write(devc, 0x0010);
  360. pss_write(devc, log_scale[left] | 0x0000);
  361. pss_write(devc, 0x0010);
  362. pss_write(devc, log_scale[right] | 0x0100);
  363. }
  364. static void set_synth_volume(pss_confdata *devc, int volume)
  365. {
  366. int vol = ((0x8000*volume)/100L);
  367. pss_write(devc, 0x0080);
  368. pss_write(devc, vol);
  369. pss_write(devc, 0x0081);
  370. pss_write(devc, vol);
  371. }
  372. static void set_bass(pss_confdata *devc, int level)
  373. {
  374. int vol = (int)(((0xfd - 0xf0) * level)/100L) + 0xf0;
  375. pss_write(devc, 0x0010);
  376. pss_write(devc, vol | 0x0200);
  377. };
  378. static void set_treble(pss_confdata *devc, int level)
  379. {
  380. int vol = (((0xfd - 0xf0) * level)/100L) + 0xf0;
  381. pss_write(devc, 0x0010);
  382. pss_write(devc, vol | 0x0300);
  383. };
  384. static void pss_mixer_reset(pss_confdata *devc)
  385. {
  386. set_master_volume(devc, 33, 33);
  387. set_bass(devc, 50);
  388. set_treble(devc, 50);
  389. set_synth_volume(devc, 30);
  390. pss_write (devc, 0x0010);
  391. pss_write (devc, 0x0800 | 0xce); /* Stereo */
  392. if(pss_mixer)
  393. {
  394. devc->mixer.volume_l = devc->mixer.volume_r = 33;
  395. devc->mixer.bass = 50;
  396. devc->mixer.treble = 50;
  397. devc->mixer.synth = 30;
  398. }
  399. }
  400. static int set_volume_mono(unsigned __user *p, int *aleft)
  401. {
  402. int left;
  403. unsigned volume;
  404. if (get_user(volume, p))
  405. return -EFAULT;
  406. left = volume & 0xff;
  407. if (left > 100)
  408. left = 100;
  409. *aleft = left;
  410. return 0;
  411. }
  412. static int set_volume_stereo(unsigned __user *p, int *aleft, int *aright)
  413. {
  414. int left, right;
  415. unsigned volume;
  416. if (get_user(volume, p))
  417. return -EFAULT;
  418. left = volume & 0xff;
  419. if (left > 100)
  420. left = 100;
  421. right = (volume >> 8) & 0xff;
  422. if (right > 100)
  423. right = 100;
  424. *aleft = left;
  425. *aright = right;
  426. return 0;
  427. }
  428. static int ret_vol_mono(int left)
  429. {
  430. return ((left << 8) | left);
  431. }
  432. static int ret_vol_stereo(int left, int right)
  433. {
  434. return ((right << 8) | left);
  435. }
  436. static int call_ad_mixer(pss_confdata *devc,unsigned int cmd, void __user *arg)
  437. {
  438. if (devc->ad_mixer_dev != NO_WSS_MIXER)
  439. return mixer_devs[devc->ad_mixer_dev]->ioctl(devc->ad_mixer_dev, cmd, arg);
  440. else
  441. return -EINVAL;
  442. }
  443. static int pss_mixer_ioctl (int dev, unsigned int cmd, void __user *arg)
  444. {
  445. pss_confdata *devc = mixer_devs[dev]->devc;
  446. int cmdf = cmd & 0xff;
  447. if ((cmdf != SOUND_MIXER_VOLUME) && (cmdf != SOUND_MIXER_BASS) &&
  448. (cmdf != SOUND_MIXER_TREBLE) && (cmdf != SOUND_MIXER_SYNTH) &&
  449. (cmdf != SOUND_MIXER_DEVMASK) && (cmdf != SOUND_MIXER_STEREODEVS) &&
  450. (cmdf != SOUND_MIXER_RECMASK) && (cmdf != SOUND_MIXER_CAPS) &&
  451. (cmdf != SOUND_MIXER_RECSRC))
  452. {
  453. return call_ad_mixer(devc, cmd, arg);
  454. }
  455. if (((cmd >> 8) & 0xff) != 'M')
  456. return -EINVAL;
  457. if (_SIOC_DIR (cmd) & _SIOC_WRITE)
  458. {
  459. switch (cmdf)
  460. {
  461. case SOUND_MIXER_RECSRC:
  462. if (devc->ad_mixer_dev != NO_WSS_MIXER)
  463. return call_ad_mixer(devc, cmd, arg);
  464. else
  465. {
  466. int v;
  467. if (get_user(v, (int __user *)arg))
  468. return -EFAULT;
  469. if (v != 0)
  470. return -EINVAL;
  471. return 0;
  472. }
  473. case SOUND_MIXER_VOLUME:
  474. if (set_volume_stereo(arg,
  475. &devc->mixer.volume_l,
  476. &devc->mixer.volume_r))
  477. return -EFAULT;
  478. set_master_volume(devc, devc->mixer.volume_l,
  479. devc->mixer.volume_r);
  480. return ret_vol_stereo(devc->mixer.volume_l,
  481. devc->mixer.volume_r);
  482. case SOUND_MIXER_BASS:
  483. if (set_volume_mono(arg, &devc->mixer.bass))
  484. return -EFAULT;
  485. set_bass(devc, devc->mixer.bass);
  486. return ret_vol_mono(devc->mixer.bass);
  487. case SOUND_MIXER_TREBLE:
  488. if (set_volume_mono(arg, &devc->mixer.treble))
  489. return -EFAULT;
  490. set_treble(devc, devc->mixer.treble);
  491. return ret_vol_mono(devc->mixer.treble);
  492. case SOUND_MIXER_SYNTH:
  493. if (set_volume_mono(arg, &devc->mixer.synth))
  494. return -EFAULT;
  495. set_synth_volume(devc, devc->mixer.synth);
  496. return ret_vol_mono(devc->mixer.synth);
  497. default:
  498. return -EINVAL;
  499. }
  500. }
  501. else
  502. {
  503. int val, and_mask = 0, or_mask = 0;
  504. /*
  505. * Return parameters
  506. */
  507. switch (cmdf)
  508. {
  509. case SOUND_MIXER_DEVMASK:
  510. if (call_ad_mixer(devc, cmd, arg) == -EINVAL)
  511. break;
  512. and_mask = ~0;
  513. or_mask = SOUND_MASK_VOLUME | SOUND_MASK_BASS | SOUND_MASK_TREBLE | SOUND_MASK_SYNTH;
  514. break;
  515. case SOUND_MIXER_STEREODEVS:
  516. if (call_ad_mixer(devc, cmd, arg) == -EINVAL)
  517. break;
  518. and_mask = ~0;
  519. or_mask = SOUND_MASK_VOLUME;
  520. break;
  521. case SOUND_MIXER_RECMASK:
  522. if (devc->ad_mixer_dev != NO_WSS_MIXER)
  523. return call_ad_mixer(devc, cmd, arg);
  524. break;
  525. case SOUND_MIXER_CAPS:
  526. if (devc->ad_mixer_dev != NO_WSS_MIXER)
  527. return call_ad_mixer(devc, cmd, arg);
  528. or_mask = SOUND_CAP_EXCL_INPUT;
  529. break;
  530. case SOUND_MIXER_RECSRC:
  531. if (devc->ad_mixer_dev != NO_WSS_MIXER)
  532. return call_ad_mixer(devc, cmd, arg);
  533. break;
  534. case SOUND_MIXER_VOLUME:
  535. or_mask = ret_vol_stereo(devc->mixer.volume_l, devc->mixer.volume_r);
  536. break;
  537. case SOUND_MIXER_BASS:
  538. or_mask = ret_vol_mono(devc->mixer.bass);
  539. break;
  540. case SOUND_MIXER_TREBLE:
  541. or_mask = ret_vol_mono(devc->mixer.treble);
  542. break;
  543. case SOUND_MIXER_SYNTH:
  544. or_mask = ret_vol_mono(devc->mixer.synth);
  545. break;
  546. default:
  547. return -EINVAL;
  548. }
  549. if (get_user(val, (int __user *)arg))
  550. return -EFAULT;
  551. val &= and_mask;
  552. val |= or_mask;
  553. if (put_user(val, (int __user *)arg))
  554. return -EFAULT;
  555. return val;
  556. }
  557. }
  558. static struct mixer_operations pss_mixer_operations =
  559. {
  560. .owner = THIS_MODULE,
  561. .id = "SOUNDPORT",
  562. .name = "PSS-AD1848",
  563. .ioctl = pss_mixer_ioctl
  564. };
  565. static void disable_all_emulations(void)
  566. {
  567. outw(0x0000, REG(CONF_PSS)); /* 0x0400 enables joystick */
  568. outw(0x0000, REG(CONF_WSS));
  569. outw(0x0000, REG(CONF_SB));
  570. outw(0x0000, REG(CONF_MIDI));
  571. outw(0x0000, REG(CONF_CDROM));
  572. }
  573. static void configure_nonsound_components(void)
  574. {
  575. /* Configure Joystick port */
  576. if(pss_enable_joystick)
  577. {
  578. outw(0x0400, REG(CONF_PSS)); /* 0x0400 enables joystick */
  579. printk(KERN_INFO "PSS: joystick enabled.\n");
  580. }
  581. else
  582. {
  583. printk(KERN_INFO "PSS: joystick port not enabled.\n");
  584. }
  585. /* Configure CDROM port */
  586. if(pss_cdrom_port == -1) /* If cdrom port enablation wasn't requested */
  587. {
  588. printk(KERN_INFO "PSS: CDROM port not enabled.\n");
  589. }
  590. else if(check_region(pss_cdrom_port, 2))
  591. {
  592. printk(KERN_ERR "PSS: CDROM I/O port conflict.\n");
  593. }
  594. else if(!set_io_base(devc, CONF_CDROM, pss_cdrom_port))
  595. {
  596. printk(KERN_ERR "PSS: CDROM I/O port could not be set.\n");
  597. }
  598. else /* CDROM port successfully configured */
  599. {
  600. printk(KERN_INFO "PSS: CDROM I/O port set to 0x%x.\n", pss_cdrom_port);
  601. }
  602. }
  603. static int __init attach_pss(struct address_info *hw_config)
  604. {
  605. unsigned short id;
  606. char tmp[100];
  607. devc->base = hw_config->io_base;
  608. devc->irq = hw_config->irq;
  609. devc->dma = hw_config->dma;
  610. devc->osp = hw_config->osp;
  611. devc->ad_mixer_dev = NO_WSS_MIXER;
  612. if (!probe_pss(hw_config))
  613. return 0;
  614. id = inw(REG(PSS_ID)) & 0x00ff;
  615. /*
  616. * Disable all emulations. Will be enabled later (if required).
  617. */
  618. disable_all_emulations();
  619. #ifdef YOU_REALLY_WANT_TO_ALLOCATE_THESE_RESOURCES
  620. if (sound_alloc_dma(hw_config->dma, "PSS"))
  621. {
  622. printk("pss.c: Can't allocate DMA channel.\n");
  623. release_region(hw_config->io_base, 0x10);
  624. release_region(hw_config->io_base+0x10, 0x9);
  625. return 0;
  626. }
  627. if (!set_irq(devc, CONF_PSS, devc->irq))
  628. {
  629. printk("PSS: IRQ allocation error.\n");
  630. release_region(hw_config->io_base, 0x10);
  631. release_region(hw_config->io_base+0x10, 0x9);
  632. return 0;
  633. }
  634. if (!set_dma(devc, CONF_PSS, devc->dma))
  635. {
  636. printk(KERN_ERR "PSS: DMA allocation error\n");
  637. release_region(hw_config->io_base, 0x10);
  638. release_region(hw_config->io_base+0x10, 0x9);
  639. return 0;
  640. }
  641. #endif
  642. configure_nonsound_components();
  643. pss_initialized = 1;
  644. sprintf(tmp, "ECHO-PSS Rev. %d", id);
  645. conf_printf(tmp, hw_config);
  646. return 1;
  647. }
  648. static int __init probe_pss_mpu(struct address_info *hw_config)
  649. {
  650. struct resource *ports;
  651. int timeout;
  652. if (!pss_initialized)
  653. return 0;
  654. ports = request_region(hw_config->io_base, 2, "mpu401");
  655. if (!ports) {
  656. printk(KERN_ERR "PSS: MPU I/O port conflict\n");
  657. return 0;
  658. }
  659. if (!set_io_base(devc, CONF_MIDI, hw_config->io_base)) {
  660. printk(KERN_ERR "PSS: MIDI base could not be set.\n");
  661. goto fail;
  662. }
  663. if (!set_irq(devc, CONF_MIDI, hw_config->irq)) {
  664. printk(KERN_ERR "PSS: MIDI IRQ allocation error.\n");
  665. goto fail;
  666. }
  667. if (!pss_synthLen) {
  668. printk(KERN_ERR "PSS: Can't enable MPU. MIDI synth microcode not available.\n");
  669. goto fail;
  670. }
  671. if (!pss_download_boot(devc, pss_synth, pss_synthLen, CPF_FIRST | CPF_LAST)) {
  672. printk(KERN_ERR "PSS: Unable to load MIDI synth microcode to DSP.\n");
  673. goto fail;
  674. }
  675. /*
  676. * Finally wait until the DSP algorithm has initialized itself and
  677. * deactivates receive interrupt.
  678. */
  679. for (timeout = 900000; timeout > 0; timeout--)
  680. {
  681. if ((inb(hw_config->io_base + 1) & 0x80) == 0) /* Input data avail */
  682. inb(hw_config->io_base); /* Discard it */
  683. else
  684. break; /* No more input */
  685. }
  686. if (!probe_mpu401(hw_config, ports))
  687. goto fail;
  688. attach_mpu401(hw_config, THIS_MODULE); /* Slot 1 */
  689. if (hw_config->slots[1] != -1) /* The MPU driver installed itself */
  690. midi_devs[hw_config->slots[1]]->coproc = &pss_coproc_operations;
  691. return 1;
  692. fail:
  693. release_region(hw_config->io_base, 2);
  694. return 0;
  695. }
  696. static int pss_coproc_open(void *dev_info, int sub_device)
  697. {
  698. switch (sub_device)
  699. {
  700. case COPR_MIDI:
  701. if (pss_synthLen == 0)
  702. {
  703. printk(KERN_ERR "PSS: MIDI synth microcode not available.\n");
  704. return -EIO;
  705. }
  706. if (nonstandard_microcode)
  707. if (!pss_download_boot(devc, pss_synth, pss_synthLen, CPF_FIRST | CPF_LAST))
  708. {
  709. printk(KERN_ERR "PSS: Unable to load MIDI synth microcode to DSP.\n");
  710. return -EIO;
  711. }
  712. nonstandard_microcode = 0;
  713. break;
  714. default:
  715. break;
  716. }
  717. return 0;
  718. }
  719. static void pss_coproc_close(void *dev_info, int sub_device)
  720. {
  721. return;
  722. }
  723. static void pss_coproc_reset(void *dev_info)
  724. {
  725. if (pss_synthLen)
  726. if (!pss_download_boot(devc, pss_synth, pss_synthLen, CPF_FIRST | CPF_LAST))
  727. {
  728. printk(KERN_ERR "PSS: Unable to load MIDI synth microcode to DSP.\n");
  729. }
  730. nonstandard_microcode = 0;
  731. }
  732. static int download_boot_block(void *dev_info, copr_buffer * buf)
  733. {
  734. if (buf->len <= 0 || buf->len > sizeof(buf->data))
  735. return -EINVAL;
  736. if (!pss_download_boot(devc, buf->data, buf->len, buf->flags))
  737. {
  738. printk(KERN_ERR "PSS: Unable to load microcode block to DSP.\n");
  739. return -EIO;
  740. }
  741. nonstandard_microcode = 1; /* The MIDI microcode has been overwritten */
  742. return 0;
  743. }
  744. static int pss_coproc_ioctl(void *dev_info, unsigned int cmd, void __user *arg, int local)
  745. {
  746. copr_buffer *buf;
  747. copr_msg *mbuf;
  748. copr_debug_buf dbuf;
  749. unsigned short tmp;
  750. unsigned long flags;
  751. unsigned short *data;
  752. int i, err;
  753. /* printk( "PSS coproc ioctl %x %x %d\n", cmd, arg, local); */
  754. switch (cmd)
  755. {
  756. case SNDCTL_COPR_RESET:
  757. pss_coproc_reset(dev_info);
  758. return 0;
  759. case SNDCTL_COPR_LOAD:
  760. buf = (copr_buffer *) vmalloc(sizeof(copr_buffer));
  761. if (buf == NULL)
  762. return -ENOSPC;
  763. if (copy_from_user(buf, arg, sizeof(copr_buffer))) {
  764. vfree(buf);
  765. return -EFAULT;
  766. }
  767. err = download_boot_block(dev_info, buf);
  768. vfree(buf);
  769. return err;
  770. case SNDCTL_COPR_SENDMSG:
  771. mbuf = (copr_msg *)vmalloc(sizeof(copr_msg));
  772. if (mbuf == NULL)
  773. return -ENOSPC;
  774. if (copy_from_user(mbuf, arg, sizeof(copr_msg))) {
  775. vfree(mbuf);
  776. return -EFAULT;
  777. }
  778. data = (unsigned short *)(mbuf->data);
  779. spin_lock_irqsave(&lock, flags);
  780. for (i = 0; i < mbuf->len; i++) {
  781. if (!pss_put_dspword(devc, *data++)) {
  782. spin_unlock_irqrestore(&lock,flags);
  783. mbuf->len = i; /* feed back number of WORDs sent */
  784. err = copy_to_user(arg, mbuf, sizeof(copr_msg));
  785. vfree(mbuf);
  786. return err ? -EFAULT : -EIO;
  787. }
  788. }
  789. spin_unlock_irqrestore(&lock,flags);
  790. vfree(mbuf);
  791. return 0;
  792. case SNDCTL_COPR_RCVMSG:
  793. err = 0;
  794. mbuf = (copr_msg *)vmalloc(sizeof(copr_msg));
  795. if (mbuf == NULL)
  796. return -ENOSPC;
  797. data = (unsigned short *)mbuf->data;
  798. spin_lock_irqsave(&lock, flags);
  799. for (i = 0; i < sizeof(mbuf->data)/sizeof(unsigned short); i++) {
  800. mbuf->len = i; /* feed back number of WORDs read */
  801. if (!pss_get_dspword(devc, data++)) {
  802. if (i == 0)
  803. err = -EIO;
  804. break;
  805. }
  806. }
  807. spin_unlock_irqrestore(&lock,flags);
  808. if (copy_to_user(arg, mbuf, sizeof(copr_msg)))
  809. err = -EFAULT;
  810. vfree(mbuf);
  811. return err;
  812. case SNDCTL_COPR_RDATA:
  813. if (copy_from_user(&dbuf, arg, sizeof(dbuf)))
  814. return -EFAULT;
  815. spin_lock_irqsave(&lock, flags);
  816. if (!pss_put_dspword(devc, 0x00d0)) {
  817. spin_unlock_irqrestore(&lock,flags);
  818. return -EIO;
  819. }
  820. if (!pss_put_dspword(devc, (unsigned short)(dbuf.parm1 & 0xffff))) {
  821. spin_unlock_irqrestore(&lock,flags);
  822. return -EIO;
  823. }
  824. if (!pss_get_dspword(devc, &tmp)) {
  825. spin_unlock_irqrestore(&lock,flags);
  826. return -EIO;
  827. }
  828. dbuf.parm1 = tmp;
  829. spin_unlock_irqrestore(&lock,flags);
  830. if (copy_to_user(arg, &dbuf, sizeof(dbuf)))
  831. return -EFAULT;
  832. return 0;
  833. case SNDCTL_COPR_WDATA:
  834. if (copy_from_user(&dbuf, arg, sizeof(dbuf)))
  835. return -EFAULT;
  836. spin_lock_irqsave(&lock, flags);
  837. if (!pss_put_dspword(devc, 0x00d1)) {
  838. spin_unlock_irqrestore(&lock,flags);
  839. return -EIO;
  840. }
  841. if (!pss_put_dspword(devc, (unsigned short) (dbuf.parm1 & 0xffff))) {
  842. spin_unlock_irqrestore(&lock,flags);
  843. return -EIO;
  844. }
  845. tmp = (unsigned int)dbuf.parm2 & 0xffff;
  846. if (!pss_put_dspword(devc, tmp)) {
  847. spin_unlock_irqrestore(&lock,flags);
  848. return -EIO;
  849. }
  850. spin_unlock_irqrestore(&lock,flags);
  851. return 0;
  852. case SNDCTL_COPR_WCODE:
  853. if (copy_from_user(&dbuf, arg, sizeof(dbuf)))
  854. return -EFAULT;
  855. spin_lock_irqsave(&lock, flags);
  856. if (!pss_put_dspword(devc, 0x00d3)) {
  857. spin_unlock_irqrestore(&lock,flags);
  858. return -EIO;
  859. }
  860. if (!pss_put_dspword(devc, (unsigned short)(dbuf.parm1 & 0xffff))) {
  861. spin_unlock_irqrestore(&lock,flags);
  862. return -EIO;
  863. }
  864. tmp = (unsigned int)dbuf.parm2 & 0x00ff;
  865. if (!pss_put_dspword(devc, tmp)) {
  866. spin_unlock_irqrestore(&lock,flags);
  867. return -EIO;
  868. }
  869. tmp = ((unsigned int)dbuf.parm2 >> 8) & 0xffff;
  870. if (!pss_put_dspword(devc, tmp)) {
  871. spin_unlock_irqrestore(&lock,flags);
  872. return -EIO;
  873. }
  874. spin_unlock_irqrestore(&lock,flags);
  875. return 0;
  876. case SNDCTL_COPR_RCODE:
  877. if (copy_from_user(&dbuf, arg, sizeof(dbuf)))
  878. return -EFAULT;
  879. spin_lock_irqsave(&lock, flags);
  880. if (!pss_put_dspword(devc, 0x00d2)) {
  881. spin_unlock_irqrestore(&lock,flags);
  882. return -EIO;
  883. }
  884. if (!pss_put_dspword(devc, (unsigned short)(dbuf.parm1 & 0xffff))) {
  885. spin_unlock_irqrestore(&lock,flags);
  886. return -EIO;
  887. }
  888. if (!pss_get_dspword(devc, &tmp)) { /* Read MSB */
  889. spin_unlock_irqrestore(&lock,flags);
  890. return -EIO;
  891. }
  892. dbuf.parm1 = tmp << 8;
  893. if (!pss_get_dspword(devc, &tmp)) { /* Read LSB */
  894. spin_unlock_irqrestore(&lock,flags);
  895. return -EIO;
  896. }
  897. dbuf.parm1 |= tmp & 0x00ff;
  898. spin_unlock_irqrestore(&lock,flags);
  899. if (copy_to_user(arg, &dbuf, sizeof(dbuf)))
  900. return -EFAULT;
  901. return 0;
  902. default:
  903. return -EINVAL;
  904. }
  905. return -EINVAL;
  906. }
  907. static coproc_operations pss_coproc_operations =
  908. {
  909. "ADSP-2115",
  910. THIS_MODULE,
  911. pss_coproc_open,
  912. pss_coproc_close,
  913. pss_coproc_ioctl,
  914. pss_coproc_reset,
  915. &pss_data
  916. };
  917. static int __init probe_pss_mss(struct address_info *hw_config)
  918. {
  919. volatile int timeout;
  920. struct resource *ports;
  921. int my_mix = -999; /* gcc shut up */
  922. if (!pss_initialized)
  923. return 0;
  924. if (!request_region(hw_config->io_base, 4, "WSS config")) {
  925. printk(KERN_ERR "PSS: WSS I/O port conflicts.\n");
  926. return 0;
  927. }
  928. ports = request_region(hw_config->io_base + 4, 4, "ad1848");
  929. if (!ports) {
  930. printk(KERN_ERR "PSS: WSS I/O port conflicts.\n");
  931. release_region(hw_config->io_base, 4);
  932. return 0;
  933. }
  934. if (!set_io_base(devc, CONF_WSS, hw_config->io_base)) {
  935. printk("PSS: WSS base not settable.\n");
  936. goto fail;
  937. }
  938. if (!set_irq(devc, CONF_WSS, hw_config->irq)) {
  939. printk("PSS: WSS IRQ allocation error.\n");
  940. goto fail;
  941. }
  942. if (!set_dma(devc, CONF_WSS, hw_config->dma)) {
  943. printk(KERN_ERR "PSS: WSS DMA allocation error\n");
  944. goto fail;
  945. }
  946. /*
  947. * For some reason the card returns 0xff in the WSS status register
  948. * immediately after boot. Probably MIDI+SB emulation algorithm
  949. * downloaded to the ADSP2115 spends some time initializing the card.
  950. * Let's try to wait until it finishes this task.
  951. */
  952. for (timeout = 0; timeout < 100000 && (inb(hw_config->io_base + WSS_INDEX) &
  953. WSS_INITIALIZING); timeout++)
  954. ;
  955. outb((0x0b), hw_config->io_base + WSS_INDEX); /* Required by some cards */
  956. for (timeout = 0; (inb(hw_config->io_base + WSS_DATA) & WSS_AUTOCALIBRATION) &&
  957. (timeout < 100000); timeout++)
  958. ;
  959. if (!probe_ms_sound(hw_config, ports))
  960. goto fail;
  961. devc->ad_mixer_dev = NO_WSS_MIXER;
  962. if (pss_mixer)
  963. {
  964. if ((my_mix = sound_install_mixer (MIXER_DRIVER_VERSION,
  965. "PSS-SPEAKERS and AD1848 (through MSS audio codec)",
  966. &pss_mixer_operations,
  967. sizeof (struct mixer_operations),
  968. devc)) < 0)
  969. {
  970. printk(KERN_ERR "Could not install PSS mixer\n");
  971. goto fail;
  972. }
  973. }
  974. pss_mixer_reset(devc);
  975. attach_ms_sound(hw_config, ports, THIS_MODULE); /* Slot 0 */
  976. if (hw_config->slots[0] != -1)
  977. {
  978. /* The MSS driver installed itself */
  979. audio_devs[hw_config->slots[0]]->coproc = &pss_coproc_operations;
  980. if (pss_mixer && (num_mixers == (my_mix + 2)))
  981. {
  982. /* The MSS mixer installed */
  983. devc->ad_mixer_dev = audio_devs[hw_config->slots[0]]->mixer_dev;
  984. }
  985. }
  986. return 1;
  987. fail:
  988. release_region(hw_config->io_base + 4, 4);
  989. release_region(hw_config->io_base, 4);
  990. return 0;
  991. }
  992. static inline void __exit unload_pss(struct address_info *hw_config)
  993. {
  994. release_region(hw_config->io_base, 0x10);
  995. release_region(hw_config->io_base+0x10, 0x9);
  996. }
  997. static inline void __exit unload_pss_mpu(struct address_info *hw_config)
  998. {
  999. unload_mpu401(hw_config);
  1000. }
  1001. static inline void __exit unload_pss_mss(struct address_info *hw_config)
  1002. {
  1003. unload_ms_sound(hw_config);
  1004. }
  1005. static struct address_info cfg;
  1006. static struct address_info cfg2;
  1007. static struct address_info cfg_mpu;
  1008. static int pss_io __initdata = -1;
  1009. static int mss_io __initdata = -1;
  1010. static int mss_irq __initdata = -1;
  1011. static int mss_dma __initdata = -1;
  1012. static int mpu_io __initdata = -1;
  1013. static int mpu_irq __initdata = -1;
  1014. static int pss_no_sound = 0; /* Just configure non-sound components */
  1015. static int pss_keep_settings = 1; /* Keep hardware settings at module exit */
  1016. static char *pss_firmware = "/etc/sound/pss_synth";
  1017. module_param(pss_io, int, 0);
  1018. MODULE_PARM_DESC(pss_io, "Set i/o base of PSS card (probably 0x220 or 0x240)");
  1019. module_param(mss_io, int, 0);
  1020. 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)");
  1021. module_param(mss_irq, int, 0);
  1022. MODULE_PARM_DESC(mss_irq, "Set WSS (audio) IRQ (3, 5, 7, 9, 10, 11, 12)");
  1023. module_param(mss_dma, int, 0);
  1024. MODULE_PARM_DESC(mss_dma, "Set WSS (audio) DMA (0, 1, 3)");
  1025. module_param(mpu_io, int, 0);
  1026. 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)");
  1027. module_param(mpu_irq, int, 0);
  1028. MODULE_PARM_DESC(mpu_irq, "Set MIDI IRQ (3, 5, 7, 9, 10, 11, 12)");
  1029. module_param(pss_cdrom_port, int, 0);
  1030. MODULE_PARM_DESC(pss_cdrom_port, "Set the PSS CDROM port i/o base (0x340 or other)");
  1031. module_param(pss_enable_joystick, bool, 0);
  1032. MODULE_PARM_DESC(pss_enable_joystick, "Enables the PSS joystick port (1 to enable, 0 to disable)");
  1033. module_param(pss_no_sound, bool, 0);
  1034. MODULE_PARM_DESC(pss_no_sound, "Configure sound compoents (0 - no, 1 - yes)");
  1035. module_param(pss_keep_settings, bool, 0);
  1036. MODULE_PARM_DESC(pss_keep_settings, "Keep hardware setting at driver unloading (0 - no, 1 - yes)");
  1037. module_param(pss_firmware, charp, 0);
  1038. MODULE_PARM_DESC(pss_firmware, "Location of the firmware file (default - /etc/sound/pss_synth)");
  1039. module_param(pss_mixer, bool, 0);
  1040. 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.");
  1041. MODULE_AUTHOR("Hannu Savolainen, Vladimir Michl");
  1042. 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).");
  1043. MODULE_LICENSE("GPL");
  1044. static int fw_load = 0;
  1045. static int pssmpu = 0, pssmss = 0;
  1046. /*
  1047. * Load a PSS sound card module
  1048. */
  1049. static int __init init_pss(void)
  1050. {
  1051. if(pss_no_sound) /* If configuring only nonsound components */
  1052. {
  1053. cfg.io_base = pss_io;
  1054. if(!probe_pss(&cfg))
  1055. return -ENODEV;
  1056. printk(KERN_INFO "ECHO-PSS Rev. %d\n", inw(REG(PSS_ID)) & 0x00ff);
  1057. printk(KERN_INFO "PSS: loading in no sound mode.\n");
  1058. disable_all_emulations();
  1059. configure_nonsound_components();
  1060. release_region(pss_io, 0x10);
  1061. release_region(pss_io + 0x10, 0x9);
  1062. return 0;
  1063. }
  1064. cfg.io_base = pss_io;
  1065. cfg2.io_base = mss_io;
  1066. cfg2.irq = mss_irq;
  1067. cfg2.dma = mss_dma;
  1068. cfg_mpu.io_base = mpu_io;
  1069. cfg_mpu.irq = mpu_irq;
  1070. if (cfg.io_base == -1 || cfg2.io_base == -1 || cfg2.irq == -1 || cfg.dma == -1) {
  1071. printk(KERN_INFO "pss: mss_io, mss_dma, mss_irq and pss_io must be set.\n");
  1072. return -EINVAL;
  1073. }
  1074. if (!pss_synth) {
  1075. fw_load = 1;
  1076. pss_synthLen = mod_firmware_load(pss_firmware, (void *) &pss_synth);
  1077. }
  1078. if (!attach_pss(&cfg))
  1079. return -ENODEV;
  1080. /*
  1081. * Attach stuff
  1082. */
  1083. if (probe_pss_mpu(&cfg_mpu))
  1084. pssmpu = 1;
  1085. if (probe_pss_mss(&cfg2))
  1086. pssmss = 1;
  1087. return 0;
  1088. }
  1089. static void __exit cleanup_pss(void)
  1090. {
  1091. if(!pss_no_sound)
  1092. {
  1093. if(fw_load && pss_synth)
  1094. vfree(pss_synth);
  1095. if(pssmss)
  1096. unload_pss_mss(&cfg2);
  1097. if(pssmpu)
  1098. unload_pss_mpu(&cfg_mpu);
  1099. unload_pss(&cfg);
  1100. }
  1101. if(!pss_keep_settings) /* Keep hardware settings if asked */
  1102. {
  1103. disable_all_emulations();
  1104. printk(KERN_INFO "Resetting PSS sound card configurations.\n");
  1105. }
  1106. }
  1107. module_init(init_pss);
  1108. module_exit(cleanup_pss);
  1109. #ifndef MODULE
  1110. static int __init setup_pss(char *str)
  1111. {
  1112. /* io, mss_io, mss_irq, mss_dma, mpu_io, mpu_irq */
  1113. int ints[7];
  1114. str = get_options(str, ARRAY_SIZE(ints), ints);
  1115. pss_io = ints[1];
  1116. mss_io = ints[2];
  1117. mss_irq = ints[3];
  1118. mss_dma = ints[4];
  1119. mpu_io = ints[5];
  1120. mpu_irq = ints[6];
  1121. return 1;
  1122. }
  1123. __setup("pss=", setup_pss);
  1124. #endif