sscape.c 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * Low-level ALSA driver for the ENSONIQ SoundScape
  4. * Copyright (c) by Chris Rankin
  5. *
  6. * This driver was written in part using information obtained from
  7. * the OSS/Free SoundScape driver, written by Hannu Savolainen.
  8. */
  9. #include <linux/init.h>
  10. #include <linux/err.h>
  11. #include <linux/io.h>
  12. #include <linux/isa.h>
  13. #include <linux/delay.h>
  14. #include <linux/firmware.h>
  15. #include <linux/pnp.h>
  16. #include <linux/spinlock.h>
  17. #include <linux/module.h>
  18. #include <asm/dma.h>
  19. #include <sound/core.h>
  20. #include <sound/wss.h>
  21. #include <sound/mpu401.h>
  22. #include <sound/initval.h>
  23. MODULE_AUTHOR("Chris Rankin");
  24. MODULE_DESCRIPTION("ENSONIQ SoundScape driver");
  25. MODULE_LICENSE("GPL");
  26. MODULE_FIRMWARE("sndscape.co0");
  27. MODULE_FIRMWARE("sndscape.co1");
  28. MODULE_FIRMWARE("sndscape.co2");
  29. MODULE_FIRMWARE("sndscape.co3");
  30. MODULE_FIRMWARE("sndscape.co4");
  31. MODULE_FIRMWARE("scope.cod");
  32. static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
  33. static char* id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
  34. static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;
  35. static long wss_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;
  36. static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ;
  37. static int mpu_irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ;
  38. static int dma[SNDRV_CARDS] = SNDRV_DEFAULT_DMA;
  39. static int dma2[SNDRV_CARDS] = SNDRV_DEFAULT_DMA;
  40. static bool joystick[SNDRV_CARDS];
  41. module_param_array(index, int, NULL, 0444);
  42. MODULE_PARM_DESC(index, "Index number for SoundScape soundcard");
  43. module_param_array(id, charp, NULL, 0444);
  44. MODULE_PARM_DESC(id, "Description for SoundScape card");
  45. module_param_hw_array(port, long, ioport, NULL, 0444);
  46. MODULE_PARM_DESC(port, "Port # for SoundScape driver.");
  47. module_param_hw_array(wss_port, long, ioport, NULL, 0444);
  48. MODULE_PARM_DESC(wss_port, "WSS Port # for SoundScape driver.");
  49. module_param_hw_array(irq, int, irq, NULL, 0444);
  50. MODULE_PARM_DESC(irq, "IRQ # for SoundScape driver.");
  51. module_param_hw_array(mpu_irq, int, irq, NULL, 0444);
  52. MODULE_PARM_DESC(mpu_irq, "MPU401 IRQ # for SoundScape driver.");
  53. module_param_hw_array(dma, int, dma, NULL, 0444);
  54. MODULE_PARM_DESC(dma, "DMA # for SoundScape driver.");
  55. module_param_hw_array(dma2, int, dma, NULL, 0444);
  56. MODULE_PARM_DESC(dma2, "DMA2 # for SoundScape driver.");
  57. module_param_array(joystick, bool, NULL, 0444);
  58. MODULE_PARM_DESC(joystick, "Enable gameport.");
  59. #ifdef CONFIG_PNP
  60. static int isa_registered;
  61. static int pnp_registered;
  62. static const struct pnp_card_device_id sscape_pnpids[] = {
  63. { .id = "ENS3081", .devs = { { "ENS0000" } } }, /* Soundscape PnP */
  64. { .id = "ENS4081", .devs = { { "ENS1011" } } }, /* VIVO90 */
  65. { .id = "" } /* end */
  66. };
  67. MODULE_DEVICE_TABLE(pnp_card, sscape_pnpids);
  68. #endif
  69. #define HOST_CTRL_IO(i) ((i) + 2)
  70. #define HOST_DATA_IO(i) ((i) + 3)
  71. #define ODIE_ADDR_IO(i) ((i) + 4)
  72. #define ODIE_DATA_IO(i) ((i) + 5)
  73. #define CODEC_IO(i) ((i) + 8)
  74. #define IC_ODIE 1
  75. #define IC_OPUS 2
  76. #define RX_READY 0x01
  77. #define TX_READY 0x02
  78. #define CMD_ACK 0x80
  79. #define CMD_SET_MIDI_VOL 0x84
  80. #define CMD_GET_MIDI_VOL 0x85
  81. #define CMD_XXX_MIDI_VOL 0x86
  82. #define CMD_SET_EXTMIDI 0x8a
  83. #define CMD_GET_EXTMIDI 0x8b
  84. #define CMD_SET_MT32 0x8c
  85. #define CMD_GET_MT32 0x8d
  86. enum GA_REG {
  87. GA_INTSTAT_REG = 0,
  88. GA_INTENA_REG,
  89. GA_DMAA_REG,
  90. GA_DMAB_REG,
  91. GA_INTCFG_REG,
  92. GA_DMACFG_REG,
  93. GA_CDCFG_REG,
  94. GA_SMCFGA_REG,
  95. GA_SMCFGB_REG,
  96. GA_HMCTL_REG
  97. };
  98. #define DMA_8BIT 0x80
  99. enum card_type {
  100. MEDIA_FX, /* Sequoia S-1000 */
  101. SSCAPE, /* Sequoia S-2000 */
  102. SSCAPE_PNP,
  103. SSCAPE_VIVO,
  104. };
  105. struct soundscape {
  106. spinlock_t lock;
  107. unsigned io_base;
  108. int ic_type;
  109. enum card_type type;
  110. struct resource *io_res;
  111. struct resource *wss_res;
  112. struct snd_wss *chip;
  113. unsigned char midi_vol;
  114. };
  115. #define INVALID_IRQ ((unsigned)-1)
  116. static inline struct soundscape *get_card_soundscape(struct snd_card *c)
  117. {
  118. return (struct soundscape *) (c->private_data);
  119. }
  120. /*
  121. * Allocates some kernel memory that we can use for DMA.
  122. * I think this means that the memory has to map to
  123. * contiguous pages of physical memory.
  124. */
  125. static struct snd_dma_buffer *get_dmabuf(struct soundscape *s,
  126. struct snd_dma_buffer *buf,
  127. unsigned long size)
  128. {
  129. if (buf) {
  130. if (snd_dma_alloc_pages_fallback(SNDRV_DMA_TYPE_DEV,
  131. s->chip->card->dev,
  132. size, buf) < 0) {
  133. snd_printk(KERN_ERR "sscape: Failed to allocate "
  134. "%lu bytes for DMA\n",
  135. size);
  136. return NULL;
  137. }
  138. }
  139. return buf;
  140. }
  141. /*
  142. * Release the DMA-able kernel memory ...
  143. */
  144. static void free_dmabuf(struct snd_dma_buffer *buf)
  145. {
  146. if (buf && buf->area)
  147. snd_dma_free_pages(buf);
  148. }
  149. /*
  150. * This function writes to the SoundScape's control registers,
  151. * but doesn't do any locking. It's up to the caller to do that.
  152. * This is why this function is "unsafe" ...
  153. */
  154. static inline void sscape_write_unsafe(unsigned io_base, enum GA_REG reg,
  155. unsigned char val)
  156. {
  157. outb(reg, ODIE_ADDR_IO(io_base));
  158. outb(val, ODIE_DATA_IO(io_base));
  159. }
  160. /*
  161. * Write to the SoundScape's control registers, and do the
  162. * necessary locking ...
  163. */
  164. static void sscape_write(struct soundscape *s, enum GA_REG reg,
  165. unsigned char val)
  166. {
  167. unsigned long flags;
  168. spin_lock_irqsave(&s->lock, flags);
  169. sscape_write_unsafe(s->io_base, reg, val);
  170. spin_unlock_irqrestore(&s->lock, flags);
  171. }
  172. /*
  173. * Read from the SoundScape's control registers, but leave any
  174. * locking to the caller. This is why the function is "unsafe" ...
  175. */
  176. static inline unsigned char sscape_read_unsafe(unsigned io_base,
  177. enum GA_REG reg)
  178. {
  179. outb(reg, ODIE_ADDR_IO(io_base));
  180. return inb(ODIE_DATA_IO(io_base));
  181. }
  182. /*
  183. * Puts the SoundScape into "host" mode, as compared to "MIDI" mode
  184. */
  185. static inline void set_host_mode_unsafe(unsigned io_base)
  186. {
  187. outb(0x0, HOST_CTRL_IO(io_base));
  188. }
  189. /*
  190. * Puts the SoundScape into "MIDI" mode, as compared to "host" mode
  191. */
  192. static inline void set_midi_mode_unsafe(unsigned io_base)
  193. {
  194. outb(0x3, HOST_CTRL_IO(io_base));
  195. }
  196. /*
  197. * Read the SoundScape's host-mode control register, but leave
  198. * any locking issues to the caller ...
  199. */
  200. static inline int host_read_unsafe(unsigned io_base)
  201. {
  202. int data = -1;
  203. if ((inb(HOST_CTRL_IO(io_base)) & RX_READY) != 0)
  204. data = inb(HOST_DATA_IO(io_base));
  205. return data;
  206. }
  207. /*
  208. * Read the SoundScape's host-mode control register, performing
  209. * a limited amount of busy-waiting if the register isn't ready.
  210. * Also leaves all locking-issues to the caller ...
  211. */
  212. static int host_read_ctrl_unsafe(unsigned io_base, unsigned timeout)
  213. {
  214. int data;
  215. while (((data = host_read_unsafe(io_base)) < 0) && (timeout != 0)) {
  216. udelay(100);
  217. --timeout;
  218. } /* while */
  219. return data;
  220. }
  221. /*
  222. * Write to the SoundScape's host-mode control registers, but
  223. * leave any locking issues to the caller ...
  224. */
  225. static inline int host_write_unsafe(unsigned io_base, unsigned char data)
  226. {
  227. if ((inb(HOST_CTRL_IO(io_base)) & TX_READY) != 0) {
  228. outb(data, HOST_DATA_IO(io_base));
  229. return 1;
  230. }
  231. return 0;
  232. }
  233. /*
  234. * Write to the SoundScape's host-mode control registers, performing
  235. * a limited amount of busy-waiting if the register isn't ready.
  236. * Also leaves all locking-issues to the caller ...
  237. */
  238. static int host_write_ctrl_unsafe(unsigned io_base, unsigned char data,
  239. unsigned timeout)
  240. {
  241. int err;
  242. while (!(err = host_write_unsafe(io_base, data)) && (timeout != 0)) {
  243. udelay(100);
  244. --timeout;
  245. } /* while */
  246. return err;
  247. }
  248. /*
  249. * Check that the MIDI subsystem is operational. If it isn't,
  250. * then we will hang the computer if we try to use it ...
  251. *
  252. * NOTE: This check is based upon observation, not documentation.
  253. */
  254. static inline int verify_mpu401(const struct snd_mpu401 *mpu)
  255. {
  256. return ((inb(MPU401C(mpu)) & 0xc0) == 0x80);
  257. }
  258. /*
  259. * This is apparently the standard way to initialise an MPU-401
  260. */
  261. static inline void initialise_mpu401(const struct snd_mpu401 *mpu)
  262. {
  263. outb(0, MPU401D(mpu));
  264. }
  265. /*
  266. * Tell the SoundScape to activate the AD1845 chip (I think).
  267. * The AD1845 detection fails if we *don't* do this, so I
  268. * think that this is a good idea ...
  269. */
  270. static void activate_ad1845_unsafe(unsigned io_base)
  271. {
  272. unsigned char val = sscape_read_unsafe(io_base, GA_HMCTL_REG);
  273. sscape_write_unsafe(io_base, GA_HMCTL_REG, (val & 0xcf) | 0x10);
  274. sscape_write_unsafe(io_base, GA_CDCFG_REG, 0x80);
  275. }
  276. /*
  277. * Tell the SoundScape to begin a DMA transfer using the given channel.
  278. * All locking issues are left to the caller.
  279. */
  280. static void sscape_start_dma_unsafe(unsigned io_base, enum GA_REG reg)
  281. {
  282. sscape_write_unsafe(io_base, reg,
  283. sscape_read_unsafe(io_base, reg) | 0x01);
  284. sscape_write_unsafe(io_base, reg,
  285. sscape_read_unsafe(io_base, reg) & 0xfe);
  286. }
  287. /*
  288. * Wait for a DMA transfer to complete. This is a "limited busy-wait",
  289. * and all locking issues are left to the caller.
  290. */
  291. static int sscape_wait_dma_unsafe(unsigned io_base, enum GA_REG reg,
  292. unsigned timeout)
  293. {
  294. while (!(sscape_read_unsafe(io_base, reg) & 0x01) && (timeout != 0)) {
  295. udelay(100);
  296. --timeout;
  297. } /* while */
  298. return sscape_read_unsafe(io_base, reg) & 0x01;
  299. }
  300. /*
  301. * Wait for the On-Board Processor to return its start-up
  302. * acknowledgement sequence. This wait is too long for
  303. * us to perform "busy-waiting", and so we must sleep.
  304. * This in turn means that we must not be holding any
  305. * spinlocks when we call this function.
  306. */
  307. static int obp_startup_ack(struct soundscape *s, unsigned timeout)
  308. {
  309. unsigned long end_time = jiffies + msecs_to_jiffies(timeout);
  310. do {
  311. unsigned long flags;
  312. int x;
  313. spin_lock_irqsave(&s->lock, flags);
  314. x = host_read_unsafe(s->io_base);
  315. spin_unlock_irqrestore(&s->lock, flags);
  316. if (x == 0xfe || x == 0xff)
  317. return 1;
  318. msleep(10);
  319. } while (time_before(jiffies, end_time));
  320. return 0;
  321. }
  322. /*
  323. * Wait for the host to return its start-up acknowledgement
  324. * sequence. This wait is too long for us to perform
  325. * "busy-waiting", and so we must sleep. This in turn means
  326. * that we must not be holding any spinlocks when we call
  327. * this function.
  328. */
  329. static int host_startup_ack(struct soundscape *s, unsigned timeout)
  330. {
  331. unsigned long end_time = jiffies + msecs_to_jiffies(timeout);
  332. do {
  333. unsigned long flags;
  334. int x;
  335. spin_lock_irqsave(&s->lock, flags);
  336. x = host_read_unsafe(s->io_base);
  337. spin_unlock_irqrestore(&s->lock, flags);
  338. if (x == 0xfe)
  339. return 1;
  340. msleep(10);
  341. } while (time_before(jiffies, end_time));
  342. return 0;
  343. }
  344. /*
  345. * Upload a byte-stream into the SoundScape using DMA channel A.
  346. */
  347. static int upload_dma_data(struct soundscape *s, const unsigned char *data,
  348. size_t size)
  349. {
  350. unsigned long flags;
  351. struct snd_dma_buffer dma;
  352. int ret;
  353. unsigned char val;
  354. if (!get_dmabuf(s, &dma, PAGE_ALIGN(32 * 1024)))
  355. return -ENOMEM;
  356. spin_lock_irqsave(&s->lock, flags);
  357. /*
  358. * Reset the board ...
  359. */
  360. val = sscape_read_unsafe(s->io_base, GA_HMCTL_REG);
  361. sscape_write_unsafe(s->io_base, GA_HMCTL_REG, val & 0x3f);
  362. /*
  363. * Enable the DMA channels and configure them ...
  364. */
  365. val = (s->chip->dma1 << 4) | DMA_8BIT;
  366. sscape_write_unsafe(s->io_base, GA_DMAA_REG, val);
  367. sscape_write_unsafe(s->io_base, GA_DMAB_REG, 0x20);
  368. /*
  369. * Take the board out of reset ...
  370. */
  371. val = sscape_read_unsafe(s->io_base, GA_HMCTL_REG);
  372. sscape_write_unsafe(s->io_base, GA_HMCTL_REG, val | 0x80);
  373. /*
  374. * Upload the firmware to the SoundScape
  375. * board through the DMA channel ...
  376. */
  377. while (size != 0) {
  378. unsigned long len;
  379. len = min(size, dma.bytes);
  380. memcpy(dma.area, data, len);
  381. data += len;
  382. size -= len;
  383. snd_dma_program(s->chip->dma1, dma.addr, len, DMA_MODE_WRITE);
  384. sscape_start_dma_unsafe(s->io_base, GA_DMAA_REG);
  385. if (!sscape_wait_dma_unsafe(s->io_base, GA_DMAA_REG, 5000)) {
  386. /*
  387. * Don't forget to release this spinlock we're holding
  388. */
  389. spin_unlock_irqrestore(&s->lock, flags);
  390. snd_printk(KERN_ERR
  391. "sscape: DMA upload has timed out\n");
  392. ret = -EAGAIN;
  393. goto _release_dma;
  394. }
  395. } /* while */
  396. set_host_mode_unsafe(s->io_base);
  397. outb(0x0, s->io_base);
  398. /*
  399. * Boot the board ... (I think)
  400. */
  401. val = sscape_read_unsafe(s->io_base, GA_HMCTL_REG);
  402. sscape_write_unsafe(s->io_base, GA_HMCTL_REG, val | 0x40);
  403. spin_unlock_irqrestore(&s->lock, flags);
  404. /*
  405. * If all has gone well, then the board should acknowledge
  406. * the new upload and tell us that it has rebooted OK. We
  407. * give it 5 seconds (max) ...
  408. */
  409. ret = 0;
  410. if (!obp_startup_ack(s, 5000)) {
  411. snd_printk(KERN_ERR "sscape: No response "
  412. "from on-board processor after upload\n");
  413. ret = -EAGAIN;
  414. } else if (!host_startup_ack(s, 5000)) {
  415. snd_printk(KERN_ERR
  416. "sscape: SoundScape failed to initialise\n");
  417. ret = -EAGAIN;
  418. }
  419. _release_dma:
  420. /*
  421. * NOTE!!! We are NOT holding any spinlocks at this point !!!
  422. */
  423. sscape_write(s, GA_DMAA_REG, (s->ic_type == IC_OPUS ? 0x40 : 0x70));
  424. free_dmabuf(&dma);
  425. return ret;
  426. }
  427. /*
  428. * Upload the bootblock(?) into the SoundScape. The only
  429. * purpose of this block of code seems to be to tell
  430. * us which version of the microcode we should be using.
  431. */
  432. static int sscape_upload_bootblock(struct snd_card *card)
  433. {
  434. struct soundscape *sscape = get_card_soundscape(card);
  435. unsigned long flags;
  436. const struct firmware *init_fw = NULL;
  437. int data = 0;
  438. int ret;
  439. ret = request_firmware(&init_fw, "scope.cod", card->dev);
  440. if (ret < 0) {
  441. snd_printk(KERN_ERR "sscape: Error loading scope.cod");
  442. return ret;
  443. }
  444. ret = upload_dma_data(sscape, init_fw->data, init_fw->size);
  445. release_firmware(init_fw);
  446. spin_lock_irqsave(&sscape->lock, flags);
  447. if (ret == 0)
  448. data = host_read_ctrl_unsafe(sscape->io_base, 100);
  449. if (data & 0x10)
  450. sscape_write_unsafe(sscape->io_base, GA_SMCFGA_REG, 0x2f);
  451. spin_unlock_irqrestore(&sscape->lock, flags);
  452. data &= 0xf;
  453. if (ret == 0 && data > 7) {
  454. snd_printk(KERN_ERR
  455. "sscape: timeout reading firmware version\n");
  456. ret = -EAGAIN;
  457. }
  458. return (ret == 0) ? data : ret;
  459. }
  460. /*
  461. * Upload the microcode into the SoundScape.
  462. */
  463. static int sscape_upload_microcode(struct snd_card *card, int version)
  464. {
  465. struct soundscape *sscape = get_card_soundscape(card);
  466. const struct firmware *init_fw = NULL;
  467. char name[14];
  468. int err;
  469. snprintf(name, sizeof(name), "sndscape.co%d", version);
  470. err = request_firmware(&init_fw, name, card->dev);
  471. if (err < 0) {
  472. snd_printk(KERN_ERR "sscape: Error loading sndscape.co%d",
  473. version);
  474. return err;
  475. }
  476. err = upload_dma_data(sscape, init_fw->data, init_fw->size);
  477. if (err == 0)
  478. snd_printk(KERN_INFO "sscape: MIDI firmware loaded %zu KBs\n",
  479. init_fw->size >> 10);
  480. release_firmware(init_fw);
  481. return err;
  482. }
  483. /*
  484. * Mixer control for the SoundScape's MIDI device.
  485. */
  486. static int sscape_midi_info(struct snd_kcontrol *ctl,
  487. struct snd_ctl_elem_info *uinfo)
  488. {
  489. uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
  490. uinfo->count = 1;
  491. uinfo->value.integer.min = 0;
  492. uinfo->value.integer.max = 127;
  493. return 0;
  494. }
  495. static int sscape_midi_get(struct snd_kcontrol *kctl,
  496. struct snd_ctl_elem_value *uctl)
  497. {
  498. struct snd_wss *chip = snd_kcontrol_chip(kctl);
  499. struct snd_card *card = chip->card;
  500. register struct soundscape *s = get_card_soundscape(card);
  501. unsigned long flags;
  502. spin_lock_irqsave(&s->lock, flags);
  503. uctl->value.integer.value[0] = s->midi_vol;
  504. spin_unlock_irqrestore(&s->lock, flags);
  505. return 0;
  506. }
  507. static int sscape_midi_put(struct snd_kcontrol *kctl,
  508. struct snd_ctl_elem_value *uctl)
  509. {
  510. struct snd_wss *chip = snd_kcontrol_chip(kctl);
  511. struct snd_card *card = chip->card;
  512. struct soundscape *s = get_card_soundscape(card);
  513. unsigned long flags;
  514. int change;
  515. unsigned char new_val;
  516. spin_lock_irqsave(&s->lock, flags);
  517. new_val = uctl->value.integer.value[0] & 127;
  518. /*
  519. * We need to put the board into HOST mode before we
  520. * can send any volume-changing HOST commands ...
  521. */
  522. set_host_mode_unsafe(s->io_base);
  523. /*
  524. * To successfully change the MIDI volume setting, you seem to
  525. * have to write a volume command, write the new volume value,
  526. * and then perform another volume-related command. Perhaps the
  527. * first command is an "open" and the second command is a "close"?
  528. */
  529. if (s->midi_vol == new_val) {
  530. change = 0;
  531. goto __skip_change;
  532. }
  533. change = host_write_ctrl_unsafe(s->io_base, CMD_SET_MIDI_VOL, 100)
  534. && host_write_ctrl_unsafe(s->io_base, new_val, 100)
  535. && host_write_ctrl_unsafe(s->io_base, CMD_XXX_MIDI_VOL, 100)
  536. && host_write_ctrl_unsafe(s->io_base, new_val, 100);
  537. s->midi_vol = new_val;
  538. __skip_change:
  539. /*
  540. * Take the board out of HOST mode and back into MIDI mode ...
  541. */
  542. set_midi_mode_unsafe(s->io_base);
  543. spin_unlock_irqrestore(&s->lock, flags);
  544. return change;
  545. }
  546. static const struct snd_kcontrol_new midi_mixer_ctl = {
  547. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  548. .name = "MIDI",
  549. .info = sscape_midi_info,
  550. .get = sscape_midi_get,
  551. .put = sscape_midi_put
  552. };
  553. /*
  554. * The SoundScape can use two IRQs from a possible set of four.
  555. * These IRQs are encoded as bit patterns so that they can be
  556. * written to the control registers.
  557. */
  558. static unsigned get_irq_config(int sscape_type, int irq)
  559. {
  560. static const int valid_irq[] = { 9, 5, 7, 10 };
  561. static const int old_irq[] = { 9, 7, 5, 15 };
  562. unsigned cfg;
  563. if (sscape_type == MEDIA_FX) {
  564. for (cfg = 0; cfg < ARRAY_SIZE(old_irq); ++cfg)
  565. if (irq == old_irq[cfg])
  566. return cfg;
  567. } else {
  568. for (cfg = 0; cfg < ARRAY_SIZE(valid_irq); ++cfg)
  569. if (irq == valid_irq[cfg])
  570. return cfg;
  571. }
  572. return INVALID_IRQ;
  573. }
  574. /*
  575. * Perform certain arcane port-checks to see whether there
  576. * is a SoundScape board lurking behind the given ports.
  577. */
  578. static int detect_sscape(struct soundscape *s, long wss_io)
  579. {
  580. unsigned long flags;
  581. unsigned d;
  582. int retval = 0;
  583. spin_lock_irqsave(&s->lock, flags);
  584. /*
  585. * The following code is lifted from the original OSS driver,
  586. * and as I don't have a datasheet I cannot really comment
  587. * on what it is doing...
  588. */
  589. if ((inb(HOST_CTRL_IO(s->io_base)) & 0x78) != 0)
  590. goto _done;
  591. d = inb(ODIE_ADDR_IO(s->io_base)) & 0xf0;
  592. if ((d & 0x80) != 0)
  593. goto _done;
  594. if (d == 0)
  595. s->ic_type = IC_ODIE;
  596. else if ((d & 0x60) != 0)
  597. s->ic_type = IC_OPUS;
  598. else
  599. goto _done;
  600. outb(0xfa, ODIE_ADDR_IO(s->io_base));
  601. if ((inb(ODIE_ADDR_IO(s->io_base)) & 0x9f) != 0x0a)
  602. goto _done;
  603. outb(0xfe, ODIE_ADDR_IO(s->io_base));
  604. if ((inb(ODIE_ADDR_IO(s->io_base)) & 0x9f) != 0x0e)
  605. goto _done;
  606. outb(0xfe, ODIE_ADDR_IO(s->io_base));
  607. d = inb(ODIE_DATA_IO(s->io_base));
  608. if (s->type != SSCAPE_VIVO && (d & 0x9f) != 0x0e)
  609. goto _done;
  610. if (s->ic_type == IC_OPUS)
  611. activate_ad1845_unsafe(s->io_base);
  612. if (s->type == SSCAPE_VIVO)
  613. wss_io += 4;
  614. d = sscape_read_unsafe(s->io_base, GA_HMCTL_REG);
  615. sscape_write_unsafe(s->io_base, GA_HMCTL_REG, d | 0xc0);
  616. /* wait for WSS codec */
  617. for (d = 0; d < 500; d++) {
  618. if ((inb(wss_io) & 0x80) == 0)
  619. break;
  620. spin_unlock_irqrestore(&s->lock, flags);
  621. msleep(1);
  622. spin_lock_irqsave(&s->lock, flags);
  623. }
  624. if ((inb(wss_io) & 0x80) != 0)
  625. goto _done;
  626. if (inb(wss_io + 2) == 0xff)
  627. goto _done;
  628. d = sscape_read_unsafe(s->io_base, GA_HMCTL_REG) & 0x3f;
  629. sscape_write_unsafe(s->io_base, GA_HMCTL_REG, d);
  630. if ((inb(wss_io) & 0x80) != 0)
  631. s->type = MEDIA_FX;
  632. d = sscape_read_unsafe(s->io_base, GA_HMCTL_REG);
  633. sscape_write_unsafe(s->io_base, GA_HMCTL_REG, d | 0xc0);
  634. /* wait for WSS codec */
  635. for (d = 0; d < 500; d++) {
  636. if ((inb(wss_io) & 0x80) == 0)
  637. break;
  638. spin_unlock_irqrestore(&s->lock, flags);
  639. msleep(1);
  640. spin_lock_irqsave(&s->lock, flags);
  641. }
  642. /*
  643. * SoundScape successfully detected!
  644. */
  645. retval = 1;
  646. _done:
  647. spin_unlock_irqrestore(&s->lock, flags);
  648. return retval;
  649. }
  650. /*
  651. * ALSA callback function, called when attempting to open the MIDI device.
  652. * Check that the MIDI firmware has been loaded, because we don't want
  653. * to crash the machine. Also check that someone isn't using the hardware
  654. * IOCTL device.
  655. */
  656. static int mpu401_open(struct snd_mpu401 *mpu)
  657. {
  658. if (!verify_mpu401(mpu)) {
  659. snd_printk(KERN_ERR "sscape: MIDI disabled, "
  660. "please load firmware\n");
  661. return -ENODEV;
  662. }
  663. return 0;
  664. }
  665. /*
  666. * Initialise an MPU-401 subdevice for MIDI support on the SoundScape.
  667. */
  668. static int create_mpu401(struct snd_card *card, int devnum,
  669. unsigned long port, int irq)
  670. {
  671. struct soundscape *sscape = get_card_soundscape(card);
  672. struct snd_rawmidi *rawmidi;
  673. int err;
  674. err = snd_mpu401_uart_new(card, devnum, MPU401_HW_MPU401, port,
  675. MPU401_INFO_INTEGRATED, irq, &rawmidi);
  676. if (err == 0) {
  677. struct snd_mpu401 *mpu = rawmidi->private_data;
  678. mpu->open_input = mpu401_open;
  679. mpu->open_output = mpu401_open;
  680. mpu->private_data = sscape;
  681. initialise_mpu401(mpu);
  682. }
  683. return err;
  684. }
  685. /*
  686. * Create an AD1845 PCM subdevice on the SoundScape. The AD1845
  687. * is very much like a CS4231, with a few extra bits. We will
  688. * try to support at least some of the extra bits by overriding
  689. * some of the CS4231 callback.
  690. */
  691. static int create_ad1845(struct snd_card *card, unsigned port,
  692. int irq, int dma1, int dma2)
  693. {
  694. register struct soundscape *sscape = get_card_soundscape(card);
  695. struct snd_wss *chip;
  696. int err;
  697. int codec_type = WSS_HW_DETECT;
  698. switch (sscape->type) {
  699. case MEDIA_FX:
  700. case SSCAPE:
  701. /*
  702. * There are some freak examples of early Soundscape cards
  703. * with CS4231 instead of AD1848/CS4248. Unfortunately, the
  704. * CS4231 works only in CS4248 compatibility mode on
  705. * these cards so force it.
  706. */
  707. if (sscape->ic_type != IC_OPUS)
  708. codec_type = WSS_HW_AD1848;
  709. break;
  710. case SSCAPE_VIVO:
  711. port += 4;
  712. break;
  713. default:
  714. break;
  715. }
  716. err = snd_wss_create(card, port, -1, irq, dma1, dma2,
  717. codec_type, WSS_HWSHARE_DMA1, &chip);
  718. if (!err) {
  719. unsigned long flags;
  720. if (sscape->type != SSCAPE_VIVO) {
  721. /*
  722. * The input clock frequency on the SoundScape must
  723. * be 14.31818 MHz, because we must set this register
  724. * to get the playback to sound correct ...
  725. */
  726. snd_wss_mce_up(chip);
  727. spin_lock_irqsave(&chip->reg_lock, flags);
  728. snd_wss_out(chip, AD1845_CLOCK, 0x20);
  729. spin_unlock_irqrestore(&chip->reg_lock, flags);
  730. snd_wss_mce_down(chip);
  731. }
  732. err = snd_wss_pcm(chip, 0);
  733. if (err < 0) {
  734. snd_printk(KERN_ERR "sscape: No PCM device "
  735. "for AD1845 chip\n");
  736. goto _error;
  737. }
  738. err = snd_wss_mixer(chip);
  739. if (err < 0) {
  740. snd_printk(KERN_ERR "sscape: No mixer device "
  741. "for AD1845 chip\n");
  742. goto _error;
  743. }
  744. if (chip->hardware != WSS_HW_AD1848) {
  745. err = snd_wss_timer(chip, 0);
  746. if (err < 0) {
  747. snd_printk(KERN_ERR "sscape: No timer device "
  748. "for AD1845 chip\n");
  749. goto _error;
  750. }
  751. }
  752. if (sscape->type != SSCAPE_VIVO) {
  753. err = snd_ctl_add(card,
  754. snd_ctl_new1(&midi_mixer_ctl, chip));
  755. if (err < 0) {
  756. snd_printk(KERN_ERR "sscape: Could not create "
  757. "MIDI mixer control\n");
  758. goto _error;
  759. }
  760. }
  761. sscape->chip = chip;
  762. }
  763. _error:
  764. return err;
  765. }
  766. /*
  767. * Create an ALSA soundcard entry for the SoundScape, using
  768. * the given list of port, IRQ and DMA resources.
  769. */
  770. static int create_sscape(int dev, struct snd_card *card)
  771. {
  772. struct soundscape *sscape = get_card_soundscape(card);
  773. unsigned dma_cfg;
  774. unsigned irq_cfg;
  775. unsigned mpu_irq_cfg;
  776. struct resource *io_res;
  777. struct resource *wss_res;
  778. unsigned long flags;
  779. int err;
  780. int val;
  781. const char *name;
  782. /*
  783. * Grab IO ports that we will need to probe so that we
  784. * can detect and control this hardware ...
  785. */
  786. io_res = devm_request_region(card->dev, port[dev], 8, "SoundScape");
  787. if (!io_res) {
  788. snd_printk(KERN_ERR
  789. "sscape: can't grab port 0x%lx\n", port[dev]);
  790. return -EBUSY;
  791. }
  792. wss_res = NULL;
  793. if (sscape->type == SSCAPE_VIVO) {
  794. wss_res = devm_request_region(card->dev, wss_port[dev], 4,
  795. "SoundScape");
  796. if (!wss_res) {
  797. snd_printk(KERN_ERR "sscape: can't grab port 0x%lx\n",
  798. wss_port[dev]);
  799. return -EBUSY;
  800. }
  801. }
  802. /*
  803. * Grab one DMA channel ...
  804. */
  805. err = snd_devm_request_dma(card->dev, dma[dev], "SoundScape");
  806. if (err < 0) {
  807. snd_printk(KERN_ERR "sscape: can't grab DMA %d\n", dma[dev]);
  808. return err;
  809. }
  810. spin_lock_init(&sscape->lock);
  811. sscape->io_res = io_res;
  812. sscape->wss_res = wss_res;
  813. sscape->io_base = port[dev];
  814. if (!detect_sscape(sscape, wss_port[dev])) {
  815. printk(KERN_ERR "sscape: hardware not detected at 0x%x\n",
  816. sscape->io_base);
  817. return -ENODEV;
  818. }
  819. switch (sscape->type) {
  820. case MEDIA_FX:
  821. name = "MediaFX/SoundFX";
  822. break;
  823. case SSCAPE:
  824. name = "Soundscape";
  825. break;
  826. case SSCAPE_PNP:
  827. name = "Soundscape PnP";
  828. break;
  829. case SSCAPE_VIVO:
  830. name = "Soundscape VIVO";
  831. break;
  832. default:
  833. name = "unknown Soundscape";
  834. break;
  835. }
  836. printk(KERN_INFO "sscape: %s card detected at 0x%x, using IRQ %d, DMA %d\n",
  837. name, sscape->io_base, irq[dev], dma[dev]);
  838. /*
  839. * Check that the user didn't pass us garbage data ...
  840. */
  841. irq_cfg = get_irq_config(sscape->type, irq[dev]);
  842. if (irq_cfg == INVALID_IRQ) {
  843. snd_printk(KERN_ERR "sscape: Invalid IRQ %d\n", irq[dev]);
  844. return -ENXIO;
  845. }
  846. mpu_irq_cfg = get_irq_config(sscape->type, mpu_irq[dev]);
  847. if (mpu_irq_cfg == INVALID_IRQ) {
  848. snd_printk(KERN_ERR "sscape: Invalid IRQ %d\n", mpu_irq[dev]);
  849. return -ENXIO;
  850. }
  851. /*
  852. * Tell the on-board devices where their resources are (I think -
  853. * I can't be sure without a datasheet ... So many magic values!)
  854. */
  855. spin_lock_irqsave(&sscape->lock, flags);
  856. sscape_write_unsafe(sscape->io_base, GA_SMCFGA_REG, 0x2e);
  857. sscape_write_unsafe(sscape->io_base, GA_SMCFGB_REG, 0x00);
  858. /*
  859. * Enable and configure the DMA channels ...
  860. */
  861. sscape_write_unsafe(sscape->io_base, GA_DMACFG_REG, 0x50);
  862. dma_cfg = (sscape->ic_type == IC_OPUS ? 0x40 : 0x70);
  863. sscape_write_unsafe(sscape->io_base, GA_DMAA_REG, dma_cfg);
  864. sscape_write_unsafe(sscape->io_base, GA_DMAB_REG, 0x20);
  865. mpu_irq_cfg |= mpu_irq_cfg << 2;
  866. val = sscape_read_unsafe(sscape->io_base, GA_HMCTL_REG) & 0xF7;
  867. if (joystick[dev])
  868. val |= 8;
  869. sscape_write_unsafe(sscape->io_base, GA_HMCTL_REG, val | 0x10);
  870. sscape_write_unsafe(sscape->io_base, GA_INTCFG_REG, 0xf0 | mpu_irq_cfg);
  871. sscape_write_unsafe(sscape->io_base,
  872. GA_CDCFG_REG, 0x09 | DMA_8BIT
  873. | (dma[dev] << 4) | (irq_cfg << 1));
  874. /*
  875. * Enable the master IRQ ...
  876. */
  877. sscape_write_unsafe(sscape->io_base, GA_INTENA_REG, 0x80);
  878. spin_unlock_irqrestore(&sscape->lock, flags);
  879. /*
  880. * We have now enabled the codec chip, and so we should
  881. * detect the AD1845 device ...
  882. */
  883. err = create_ad1845(card, wss_port[dev], irq[dev],
  884. dma[dev], dma2[dev]);
  885. if (err < 0) {
  886. snd_printk(KERN_ERR
  887. "sscape: No AD1845 device at 0x%lx, IRQ %d\n",
  888. wss_port[dev], irq[dev]);
  889. return err;
  890. }
  891. strcpy(card->driver, "SoundScape");
  892. strcpy(card->shortname, name);
  893. snprintf(card->longname, sizeof(card->longname),
  894. "%s at 0x%lx, IRQ %d, DMA1 %d, DMA2 %d\n",
  895. name, sscape->chip->port, sscape->chip->irq,
  896. sscape->chip->dma1, sscape->chip->dma2);
  897. #define MIDI_DEVNUM 0
  898. if (sscape->type != SSCAPE_VIVO) {
  899. err = sscape_upload_bootblock(card);
  900. if (err >= 0)
  901. err = sscape_upload_microcode(card, err);
  902. if (err == 0) {
  903. err = create_mpu401(card, MIDI_DEVNUM, port[dev],
  904. mpu_irq[dev]);
  905. if (err < 0) {
  906. snd_printk(KERN_ERR "sscape: Failed to create "
  907. "MPU-401 device at 0x%lx\n",
  908. port[dev]);
  909. return err;
  910. }
  911. /*
  912. * Initialize mixer
  913. */
  914. spin_lock_irqsave(&sscape->lock, flags);
  915. sscape->midi_vol = 0;
  916. host_write_ctrl_unsafe(sscape->io_base,
  917. CMD_SET_MIDI_VOL, 100);
  918. host_write_ctrl_unsafe(sscape->io_base,
  919. sscape->midi_vol, 100);
  920. host_write_ctrl_unsafe(sscape->io_base,
  921. CMD_XXX_MIDI_VOL, 100);
  922. host_write_ctrl_unsafe(sscape->io_base,
  923. sscape->midi_vol, 100);
  924. host_write_ctrl_unsafe(sscape->io_base,
  925. CMD_SET_EXTMIDI, 100);
  926. host_write_ctrl_unsafe(sscape->io_base,
  927. 0, 100);
  928. host_write_ctrl_unsafe(sscape->io_base, CMD_ACK, 100);
  929. set_midi_mode_unsafe(sscape->io_base);
  930. spin_unlock_irqrestore(&sscape->lock, flags);
  931. }
  932. }
  933. return 0;
  934. }
  935. static int snd_sscape_match(struct device *pdev, unsigned int i)
  936. {
  937. /*
  938. * Make sure we were given ALL of the other parameters.
  939. */
  940. if (port[i] == SNDRV_AUTO_PORT)
  941. return 0;
  942. if (irq[i] == SNDRV_AUTO_IRQ ||
  943. mpu_irq[i] == SNDRV_AUTO_IRQ ||
  944. dma[i] == SNDRV_AUTO_DMA) {
  945. printk(KERN_INFO
  946. "sscape: insufficient parameters, "
  947. "need IO, IRQ, MPU-IRQ and DMA\n");
  948. return 0;
  949. }
  950. return 1;
  951. }
  952. static int snd_sscape_probe(struct device *pdev, unsigned int dev)
  953. {
  954. struct snd_card *card;
  955. struct soundscape *sscape;
  956. int ret;
  957. ret = snd_devm_card_new(pdev, index[dev], id[dev], THIS_MODULE,
  958. sizeof(struct soundscape), &card);
  959. if (ret < 0)
  960. return ret;
  961. sscape = get_card_soundscape(card);
  962. sscape->type = SSCAPE;
  963. dma[dev] &= 0x03;
  964. ret = create_sscape(dev, card);
  965. if (ret < 0)
  966. return ret;
  967. ret = snd_card_register(card);
  968. if (ret < 0) {
  969. snd_printk(KERN_ERR "sscape: Failed to register sound card\n");
  970. return ret;
  971. }
  972. dev_set_drvdata(pdev, card);
  973. return 0;
  974. }
  975. #define DEV_NAME "sscape"
  976. static struct isa_driver snd_sscape_driver = {
  977. .match = snd_sscape_match,
  978. .probe = snd_sscape_probe,
  979. /* FIXME: suspend/resume */
  980. .driver = {
  981. .name = DEV_NAME
  982. },
  983. };
  984. #ifdef CONFIG_PNP
  985. static inline int get_next_autoindex(int i)
  986. {
  987. while (i < SNDRV_CARDS && port[i] != SNDRV_AUTO_PORT)
  988. ++i;
  989. return i;
  990. }
  991. static int sscape_pnp_detect(struct pnp_card_link *pcard,
  992. const struct pnp_card_device_id *pid)
  993. {
  994. static int idx = 0;
  995. struct pnp_dev *dev;
  996. struct snd_card *card;
  997. struct soundscape *sscape;
  998. int ret;
  999. /*
  1000. * Allow this function to fail *quietly* if all the ISA PnP
  1001. * devices were configured using module parameters instead.
  1002. */
  1003. idx = get_next_autoindex(idx);
  1004. if (idx >= SNDRV_CARDS)
  1005. return -ENOSPC;
  1006. /*
  1007. * Check that we still have room for another sound card ...
  1008. */
  1009. dev = pnp_request_card_device(pcard, pid->devs[0].id, NULL);
  1010. if (!dev)
  1011. return -ENODEV;
  1012. if (!pnp_is_active(dev)) {
  1013. if (pnp_activate_dev(dev) < 0) {
  1014. snd_printk(KERN_INFO "sscape: device is inactive\n");
  1015. return -EBUSY;
  1016. }
  1017. }
  1018. /*
  1019. * Create a new ALSA sound card entry, in anticipation
  1020. * of detecting our hardware ...
  1021. */
  1022. ret = snd_devm_card_new(&pcard->card->dev,
  1023. index[idx], id[idx], THIS_MODULE,
  1024. sizeof(struct soundscape), &card);
  1025. if (ret < 0)
  1026. return ret;
  1027. sscape = get_card_soundscape(card);
  1028. /*
  1029. * Identify card model ...
  1030. */
  1031. if (!strncmp("ENS4081", pid->id, 7))
  1032. sscape->type = SSCAPE_VIVO;
  1033. else
  1034. sscape->type = SSCAPE_PNP;
  1035. /*
  1036. * Read the correct parameters off the ISA PnP bus ...
  1037. */
  1038. port[idx] = pnp_port_start(dev, 0);
  1039. irq[idx] = pnp_irq(dev, 0);
  1040. mpu_irq[idx] = pnp_irq(dev, 1);
  1041. dma[idx] = pnp_dma(dev, 0) & 0x03;
  1042. if (sscape->type == SSCAPE_PNP) {
  1043. dma2[idx] = dma[idx];
  1044. wss_port[idx] = CODEC_IO(port[idx]);
  1045. } else {
  1046. wss_port[idx] = pnp_port_start(dev, 1);
  1047. dma2[idx] = pnp_dma(dev, 1);
  1048. }
  1049. ret = create_sscape(idx, card);
  1050. if (ret < 0)
  1051. return ret;
  1052. ret = snd_card_register(card);
  1053. if (ret < 0) {
  1054. snd_printk(KERN_ERR "sscape: Failed to register sound card\n");
  1055. return ret;
  1056. }
  1057. pnp_set_card_drvdata(pcard, card);
  1058. ++idx;
  1059. return 0;
  1060. }
  1061. static struct pnp_card_driver sscape_pnpc_driver = {
  1062. .flags = PNP_DRIVER_RES_DO_NOT_CHANGE,
  1063. .name = "sscape",
  1064. .id_table = sscape_pnpids,
  1065. .probe = sscape_pnp_detect,
  1066. };
  1067. #endif /* CONFIG_PNP */
  1068. static int __init sscape_init(void)
  1069. {
  1070. int err;
  1071. err = isa_register_driver(&snd_sscape_driver, SNDRV_CARDS);
  1072. #ifdef CONFIG_PNP
  1073. if (!err)
  1074. isa_registered = 1;
  1075. err = pnp_register_card_driver(&sscape_pnpc_driver);
  1076. if (!err)
  1077. pnp_registered = 1;
  1078. if (isa_registered)
  1079. err = 0;
  1080. #endif
  1081. return err;
  1082. }
  1083. static void __exit sscape_exit(void)
  1084. {
  1085. #ifdef CONFIG_PNP
  1086. if (pnp_registered)
  1087. pnp_unregister_card_driver(&sscape_pnpc_driver);
  1088. if (isa_registered)
  1089. #endif
  1090. isa_unregister_driver(&snd_sscape_driver);
  1091. }
  1092. module_init(sscape_init);
  1093. module_exit(sscape_exit);