Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | sound/oss/aedsp16.c |
| 3 | |
| 4 | Audio Excel DSP 16 software configuration routines |
| 5 | Copyright (C) 1995,1996,1997,1998 Riccardo Facchetti (fizban@tin.it) |
| 6 | |
| 7 | This program is free software; you can redistribute it and/or modify |
| 8 | it under the terms of the GNU General Public License as published by |
| 9 | the Free Software Foundation; either version 2 of the License, or |
| 10 | (at your option) any later version. |
| 11 | |
| 12 | This program is distributed in the hope that it will be useful, |
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | GNU General Public License for more details. |
| 16 | |
| 17 | You should have received a copy of the GNU General Public License |
| 18 | along with this program; if not, write to the Free Software |
| 19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 20 | |
| 21 | */ |
| 22 | /* |
| 23 | * Include the main OSS Lite header file. It include all the os, OSS Lite, etc |
| 24 | * headers needed by this source. |
| 25 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | #include <linux/delay.h> |
| 27 | #include <linux/module.h> |
| 28 | #include <linux/init.h> |
| 29 | #include "sound_config.h" |
| 30 | |
| 31 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | |
| 33 | READ THIS |
| 34 | |
| 35 | This module started to configure the Audio Excel DSP 16 Sound Card. |
| 36 | Now works with the SC-6000 (old aedsp16) and new SC-6600 based cards. |
| 37 | |
| 38 | NOTE: I have NO idea about Audio Excel DSP 16 III. If someone owns this |
| 39 | audio card and want to see the kernel support for it, please contact me. |
| 40 | |
| 41 | Audio Excel DSP 16 is an SB pro II, Microsoft Sound System and MPU-401 |
| 42 | compatible card. |
| 43 | It is software-only configurable (no jumpers to hard-set irq/dma/mpu-irq), |
| 44 | so before this module, the only way to configure the DSP under linux was |
| 45 | boot the MS-DOS loading the sound.sys device driver (this driver soft- |
| 46 | configure the sound board hardware by massaging someone of its registers), |
| 47 | and then ctrl-alt-del to boot linux with the DSP configured by the DOS |
| 48 | driver. |
| 49 | |
| 50 | This module works configuring your Audio Excel DSP 16's irq, dma and |
| 51 | mpu-401-irq. The OSS Lite routines rely on the fact that if the |
| 52 | hardware is there, they can detect it. The problem with AEDSP16 is |
| 53 | that no hardware can be found by the probe routines if the sound card |
| 54 | is not configured properly. Sometimes the kernel probe routines can find |
| 55 | an SBPRO even when the card is not configured (this is the standard setup |
| 56 | of the card), but the SBPRO emulation don't work well if the card is not |
| 57 | properly initialized. For this reason |
| 58 | |
| 59 | aedsp16_init_board() |
| 60 | |
| 61 | routine is called before the OSS Lite probe routines try to detect the |
| 62 | hardware. |
| 63 | |
| 64 | NOTE (READ THE NOTE TOO, IT CONTAIN USEFUL INFORMATIONS) |
| 65 | |
| 66 | NOTE: Now it works with SC-6000 and SC-6600 based audio cards. The new cards |
| 67 | have no jumper switch at all. No more WSS or MPU-401 I/O port switches. They |
| 68 | have to be configured by software. |
| 69 | |
| 70 | NOTE: The driver is merged with the new OSS Lite sound driver. It works |
| 71 | as a lowlevel driver. |
| 72 | |
| 73 | The Audio Excel DSP 16 Sound Card emulates both SBPRO and MSS; |
| 74 | the OSS Lite sound driver can be configured for SBPRO and MSS cards |
| 75 | at the same time, but the aedsp16 can't be two cards!! |
| 76 | When we configure it, we have to choose the SBPRO or the MSS emulation |
| 77 | for AEDSP16. We also can install a *REAL* card of the other type (see [1]). |
| 78 | |
| 79 | NOTE: If someone can test the combination AEDSP16+MSS or AEDSP16+SBPRO |
| 80 | please let me know if it works. |
| 81 | |
| 82 | The MPU-401 support can be compiled in together with one of the other |
| 83 | two operating modes. |
| 84 | |
| 85 | NOTE: This is something like plug-and-play: we have only to plug |
| 86 | the AEDSP16 board in the socket, and then configure and compile |
| 87 | a kernel that uses the AEDSP16 software configuration capability. |
| 88 | No jumper setting is needed! |
| 89 | |
| 90 | For example, if you want AEDSP16 to be an SBPro, on irq 10, dma 3 |
| 91 | you have just to make config the OSS Lite package, configuring |
| 92 | the AEDSP16 sound card, then activating the SBPro emulation mode |
| 93 | and at last configuring IRQ and DMA. |
| 94 | Compile the kernel and run it. |
| 95 | |
| 96 | NOTE: This means for SC-6000 cards that you can choose irq and dma, |
| 97 | but not the I/O addresses. To change I/O addresses you have to set |
| 98 | them with jumpers. For SC-6600 cards you have no jumpers so you have |
| 99 | to set up your full card configuration in the make config. |
| 100 | |
| 101 | You can change the irq/dma/mirq settings WITHOUT THE NEED to open |
| 102 | your computer and massage the jumpers (there are no irq/dma/mirq |
| 103 | jumpers to be configured anyway, only I/O BASE values have to be |
| 104 | configured with jumpers) |
| 105 | |
| 106 | For some ununderstandable reason, the card default of irq 7, dma 1, |
| 107 | don't work for me. Seems to be an IRQ or DMA conflict. Under heavy |
| 108 | HDD work, the kernel start to erupt out a lot of messages like: |
| 109 | |
| 110 | 'Sound: DMA timed out - IRQ/DRQ config error?' |
| 111 | |
| 112 | For what I can say, I have NOT any conflict at irq 7 (under linux I'm |
| 113 | using the lp polling driver), and dma line 1 is unused as stated by |
| 114 | /proc/dma. I can suppose this is a bug of AEDSP16. I know my hardware so |
| 115 | I'm pretty sure I have not any conflict, but may be I'm wrong. Who knows! |
| 116 | Anyway a setting of irq 10, dma 3 works really fine. |
| 117 | |
| 118 | NOTE: if someone can use AEDSP16 with irq 7, dma 1, please let me know |
| 119 | the emulation mode, all the installed hardware and the hardware |
| 120 | configuration (irq and dma settings of all the hardware). |
| 121 | |
| 122 | This init module should work with SBPRO+MSS, when one of the two is |
| 123 | the AEDSP16 emulation and the other the real card. (see [1]) |
| 124 | For example: |
| 125 | |
| 126 | AEDSP16 (0x220) in SBPRO emu (0x220) + real MSS + other |
| 127 | AEDSP16 (0x220) in MSS emu + real SBPRO (0x240) + other |
| 128 | |
| 129 | MPU401 should work. (see [2]) |
| 130 | |
| 131 | [1] |
| 132 | --- |
| 133 | Date: Mon, 29 Jul 1997 08:35:40 +0100 |
| 134 | From: Mr S J Greenaway <sjg95@unixfe.rl.ac.uk> |
| 135 | |
| 136 | [...] |
| 137 | Just to let you know got my Audio Excel (emulating a MSS) working |
| 138 | with my original SB16, thanks for the driver! |
| 139 | [...] |
| 140 | --- |
| 141 | |
| 142 | [2] Not tested by me for lack of hardware. |
| 143 | |
| 144 | TODO, WISHES AND TECH |
| 145 | |
| 146 | - About I/O ports allocation - |
| 147 | |
| 148 | Request the 2x0h region (port base) in any case if we are using this card. |
| 149 | |
| 150 | NOTE: the "aedsp16 (base)" string with which we are requesting the aedsp16 |
| 151 | port base region (see code) does not mean necessarily that we are emulating |
| 152 | sbpro. Even if this region is the sbpro I/O ports region, we use this |
| 153 | region to access the control registers of the card, and if emulating |
| 154 | sbpro, I/O sbpro registers too. If we are emulating MSS, the sbpro |
| 155 | registers are not used, in no way, to emulate an sbpro: they are |
| 156 | used only for configuration purposes. |
| 157 | |
| 158 | Started Fri Mar 17 16:13:18 MET 1995 |
| 159 | |
Frederik Schwarzer | 0211a9c | 2008-12-29 22:14:56 +0100 | [diff] [blame] | 160 | v0.1 (ALPHA, was a user-level program called AudioExcelDSP16.c) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | - Initial code. |
| 162 | v0.2 (ALPHA) |
| 163 | - Cleanups. |
| 164 | - Integrated with Linux voxware v 2.90-2 kernel sound driver. |
| 165 | - SoundBlaster Pro mode configuration. |
| 166 | - Microsoft Sound System mode configuration. |
| 167 | - MPU-401 mode configuration. |
| 168 | v0.3 (ALPHA) |
| 169 | - Cleanups. |
| 170 | - Rearranged the code to let aedsp16_init_board be more general. |
| 171 | - Erased the REALLY_SLOW_IO. We don't need it. Erased the linux/io.h |
| 172 | inclusion too. We rely on os.h |
| 173 | - Used the to get a variable |
| 174 | len string (we are not sure about the len of Copyright string). |
| 175 | This works with any SB and compatible. |
| 176 | - Added the code to request_region at device init (should go in |
| 177 | the main body of voxware). |
| 178 | v0.4 (BETA) |
| 179 | - Better configure.c patch for aedsp16 configuration (better |
| 180 | logic of inclusion of AEDSP16 support) |
| 181 | - Modified the conditional compilation to better support more than |
| 182 | one sound card of the emulated type (read the NOTES above) |
| 183 | - Moved the sb init routine from the attach to the very first |
| 184 | probe in sb_card.c |
| 185 | - Rearrangements and cleanups |
| 186 | - Wiped out some unnecessary code and variables: this is kernel |
| 187 | code so it is better save some TEXT and DATA |
| 188 | - Fixed the request_region code. We must allocate the aedsp16 (sbpro) |
| 189 | I/O ports in any case because they are used to access the DSP |
| 190 | configuration registers and we can not allow anyone to get them. |
| 191 | v0.5 |
| 192 | - cleanups on comments |
| 193 | - prep for diffs against v3.0-proto-950402 |
| 194 | v0.6 |
| 195 | - removed the request_region()s when compiling the MODULE sound.o |
| 196 | because we are not allowed (by the actual voxware structure) to |
| 197 | release_region() |
| 198 | v0.7 (pre ALPHA, not distributed) |
| 199 | - started porting this module to kernel 1.3.84. Dummy probe/attach |
| 200 | routines. |
| 201 | v0.8 (ALPHA) |
| 202 | - attached all the init routines. |
| 203 | v0.9 (BETA) |
| 204 | - Integrated with linux-pre2.0.7 |
| 205 | - Integrated with configuration scripts. |
| 206 | - Cleaned up and beautyfied the code. |
| 207 | v0.9.9 (BETA) |
| 208 | - Thanks to Piercarlo Grandi: corrected the conditonal compilation code. |
| 209 | Now only the code configured is compiled in, with some memory saving. |
| 210 | v0.9.10 |
| 211 | - Integration into the sound/lowlevel/ section of the sound driver. |
| 212 | - Re-organized the code. |
| 213 | v0.9.11 (not distributed) |
| 214 | - Rewritten the init interface-routines to initialize the AEDSP16 in |
| 215 | one shot. |
| 216 | - More cosmetics. |
| 217 | - SC-6600 support. |
| 218 | - More soft/hard configuration. |
| 219 | v0.9.12 |
| 220 | - Refined the v0.9.11 code with conditional compilation to distinguish |
| 221 | between SC-6000 and SC-6600 code. |
| 222 | v1.0.0 |
| 223 | - Prep for merging with OSS Lite and Linux kernel 2.1.13 |
| 224 | - Corrected a bug in request/check/release region calls (thanks to the |
| 225 | new kernel exception handling). |
| 226 | v1.1 |
| 227 | - Revamped for integration with new modularized sound drivers: to enhance |
| 228 | the flexibility of modular version, I have removed all the conditional |
| 229 | compilation for SBPRO, MPU and MSS code. Now it is all managed with |
| 230 | the ae_config structure. |
| 231 | v1.2 |
| 232 | - Module informations added. |
| 233 | - Removed aedsp16_delay_10msec(), now using mdelay(10) |
| 234 | - All data and funcs moved to .*.init section. |
| 235 | v1.3 |
| 236 | Arnaldo Carvalho de Melo <acme@conectiva.com.br> - 2000/09/27 |
| 237 | - got rid of check_region |
| 238 | |
| 239 | Known Problems: |
| 240 | - Audio Excel DSP 16 III don't work with this driver. |
| 241 | |
| 242 | Credits: |
| 243 | Many thanks to Gerald Britton <gbritton@CapAccess.org>. He helped me a |
| 244 | lot in testing the 0.9.11 and 0.9.12 versions of this driver. |
| 245 | |
| 246 | */ |
| 247 | |
| 248 | |
| 249 | #define VERSION "1.3" /* Version of Audio Excel DSP 16 driver */ |
| 250 | |
| 251 | #undef AEDSP16_DEBUG /* Define this to 1 to enable debug code */ |
| 252 | #undef AEDSP16_DEBUG_MORE /* Define this to 1 to enable more debug */ |
| 253 | #undef AEDSP16_INFO /* Define this to 1 to enable info code */ |
| 254 | |
| 255 | #if defined(AEDSP16_DEBUG) |
| 256 | # define DBG(x) printk x |
| 257 | # if defined(AEDSP16_DEBUG_MORE) |
| 258 | # define DBG1(x) printk x |
| 259 | # else |
| 260 | # define DBG1(x) |
| 261 | # endif |
| 262 | #else |
| 263 | # define DBG(x) |
| 264 | # define DBG1(x) |
| 265 | #endif |
| 266 | |
| 267 | /* |
| 268 | * Misc definitions |
| 269 | */ |
| 270 | #define TRUE 1 |
| 271 | #define FALSE 0 |
| 272 | |
| 273 | /* |
| 274 | * Region Size for request/check/release region. |
| 275 | */ |
| 276 | #define IOBASE_REGION_SIZE 0x10 |
| 277 | |
| 278 | /* |
| 279 | * Hardware related defaults |
| 280 | */ |
| 281 | #define DEF_AEDSP16_IOB 0x220 /* 0x220(default) 0x240 */ |
| 282 | #define DEF_AEDSP16_IRQ 7 /* 5 7(default) 9 10 11 */ |
| 283 | #define DEF_AEDSP16_MRQ 0 /* 5 7 9 10 0(default), 0 means disable */ |
| 284 | #define DEF_AEDSP16_DMA 1 /* 0 1(default) 3 */ |
| 285 | |
| 286 | /* |
| 287 | * Commands of AEDSP16's DSP (SBPRO+special). |
| 288 | * Some of them are COMMAND_xx, in the future they may change. |
| 289 | */ |
| 290 | #define WRITE_MDIRQ_CFG 0x50 /* Set M&I&DRQ mask (the real config) */ |
| 291 | #define COMMAND_52 0x52 /* */ |
| 292 | #define READ_HARD_CFG 0x58 /* Read Hardware Config (I/O base etc) */ |
| 293 | #define COMMAND_5C 0x5c /* */ |
| 294 | #define COMMAND_60 0x60 /* */ |
| 295 | #define COMMAND_66 0x66 /* */ |
| 296 | #define COMMAND_6C 0x6c /* */ |
| 297 | #define COMMAND_6E 0x6e /* */ |
| 298 | #define COMMAND_88 0x88 /* */ |
| 299 | #define DSP_INIT_MSS 0x8c /* Enable Microsoft Sound System mode */ |
| 300 | #define COMMAND_C5 0xc5 /* */ |
| 301 | #define GET_DSP_VERSION 0xe1 /* Get DSP Version */ |
| 302 | #define GET_DSP_COPYRIGHT 0xe3 /* Get DSP Copyright */ |
| 303 | |
| 304 | /* |
| 305 | * Offsets of AEDSP16 DSP I/O ports. The offset is added to base I/O port |
| 306 | * to have the actual I/O port. |
| 307 | * Register permissions are: |
| 308 | * (wo) == Write Only |
| 309 | * (ro) == Read Only |
| 310 | * (w-) == Write |
| 311 | * (r-) == Read |
| 312 | */ |
| 313 | #define DSP_RESET 0x06 /* offset of DSP RESET (wo) */ |
| 314 | #define DSP_READ 0x0a /* offset of DSP READ (ro) */ |
| 315 | #define DSP_WRITE 0x0c /* offset of DSP WRITE (w-) */ |
| 316 | #define DSP_COMMAND 0x0c /* offset of DSP COMMAND (w-) */ |
| 317 | #define DSP_STATUS 0x0c /* offset of DSP STATUS (r-) */ |
| 318 | #define DSP_DATAVAIL 0x0e /* offset of DSP DATA AVAILABLE (ro) */ |
| 319 | |
| 320 | |
| 321 | #define RETRY 10 /* Various retry values on I/O opera- */ |
| 322 | #define STATUSRETRY 1000 /* tions. Sometimes we have to */ |
| 323 | #define HARDRETRY 500000 /* wait for previous cmd to complete */ |
| 324 | |
| 325 | /* |
| 326 | * Size of character arrays that store name and version of sound card |
| 327 | */ |
| 328 | #define CARDNAMELEN 15 /* Size of the card's name in chars */ |
| 329 | #define CARDVERLEN 2 /* Size of the card's version in chars */ |
| 330 | |
| 331 | #if defined(CONFIG_SC6600) |
| 332 | /* |
| 333 | * Bitmapped flags of hard configuration |
| 334 | */ |
| 335 | /* |
| 336 | * Decode macros (xl == low byte, xh = high byte) |
| 337 | */ |
| 338 | #define IOBASE(xl) ((xl & 0x01)?0x240:0x220) |
| 339 | #define JOY(xl) (xl & 0x02) |
| 340 | #define MPUADDR(xl) ( \ |
| 341 | (xl & 0x0C)?0x330: \ |
| 342 | (xl & 0x08)?0x320: \ |
| 343 | (xl & 0x04)?0x310: \ |
| 344 | 0x300) |
| 345 | #define WSSADDR(xl) ((xl & 0x10)?0xE80:0x530) |
| 346 | #define CDROM(xh) (xh & 0x20) |
| 347 | #define CDROMADDR(xh) (((xh & 0x1F) << 4) + 0x200) |
| 348 | /* |
| 349 | * Encode macros |
| 350 | */ |
| 351 | #define BLDIOBASE(xl, val) { \ |
| 352 | xl &= ~0x01; \ |
| 353 | if (val == 0x240) \ |
| 354 | xl |= 0x01; \ |
| 355 | } |
| 356 | #define BLDJOY(xl, val) { \ |
| 357 | xl &= ~0x02; \ |
| 358 | if (val == 1) \ |
| 359 | xl |= 0x02; \ |
| 360 | } |
| 361 | #define BLDMPUADDR(xl, val) { \ |
| 362 | xl &= ~0x0C; \ |
| 363 | switch (val) { \ |
| 364 | case 0x330: \ |
| 365 | xl |= 0x0C; \ |
| 366 | break; \ |
| 367 | case 0x320: \ |
| 368 | xl |= 0x08; \ |
| 369 | break; \ |
| 370 | case 0x310: \ |
| 371 | xl |= 0x04; \ |
| 372 | break; \ |
| 373 | case 0x300: \ |
| 374 | xl |= 0x00; \ |
| 375 | break; \ |
| 376 | default: \ |
| 377 | xl |= 0x00; \ |
| 378 | break; \ |
| 379 | } \ |
| 380 | } |
| 381 | #define BLDWSSADDR(xl, val) { \ |
| 382 | xl &= ~0x10; \ |
| 383 | if (val == 0xE80) \ |
| 384 | xl |= 0x10; \ |
| 385 | } |
| 386 | #define BLDCDROM(xh, val) { \ |
| 387 | xh &= ~0x20; \ |
| 388 | if (val == 1) \ |
| 389 | xh |= 0x20; \ |
| 390 | } |
| 391 | #define BLDCDROMADDR(xh, val) { \ |
| 392 | int tmp = val; \ |
| 393 | tmp -= 0x200; \ |
| 394 | tmp >>= 4; \ |
| 395 | tmp &= 0x1F; \ |
| 396 | xh |= tmp; \ |
| 397 | xh &= 0x7F; \ |
| 398 | xh |= 0x40; \ |
| 399 | } |
| 400 | #endif /* CONFIG_SC6600 */ |
| 401 | |
| 402 | /* |
| 403 | * Bit mapped flags for calling aedsp16_init_board(), and saving the current |
| 404 | * emulation mode. |
| 405 | */ |
| 406 | #define INIT_NONE (0 ) |
| 407 | #define INIT_SBPRO (1<<0) |
| 408 | #define INIT_MSS (1<<1) |
| 409 | #define INIT_MPU401 (1<<2) |
| 410 | |
| 411 | static int soft_cfg __initdata = 0; /* bitmapped config */ |
| 412 | static int soft_cfg_mss __initdata = 0; /* bitmapped mss config */ |
| 413 | static int ver[CARDVERLEN] __initdata = {0, 0}; /* DSP Ver: |
| 414 | hi->ver[0] lo->ver[1] */ |
| 415 | |
| 416 | #if defined(CONFIG_SC6600) |
| 417 | static int hard_cfg[2] /* lo<-hard_cfg[0] hi<-hard_cfg[1] */ |
| 418 | __initdata = { 0, 0}; |
| 419 | #endif /* CONFIG_SC6600 */ |
| 420 | |
| 421 | #if defined(CONFIG_SC6600) |
| 422 | /* Decoded hard configuration */ |
| 423 | struct d_hcfg { |
| 424 | int iobase; |
| 425 | int joystick; |
| 426 | int mpubase; |
| 427 | int wssbase; |
| 428 | int cdrom; |
| 429 | int cdrombase; |
| 430 | }; |
| 431 | |
| 432 | static struct d_hcfg decoded_hcfg __initdata = {0, }; |
| 433 | |
| 434 | #endif /* CONFIG_SC6600 */ |
| 435 | |
| 436 | /* orVals contain the values to be or'ed */ |
| 437 | struct orVals { |
| 438 | int val; /* irq|mirq|dma */ |
| 439 | int or; /* soft_cfg |= TheStruct.or */ |
| 440 | }; |
| 441 | |
| 442 | /* aedsp16_info contain the audio card configuration */ |
| 443 | struct aedsp16_info { |
| 444 | int base_io; /* base I/O address for accessing card */ |
| 445 | int irq; /* irq value for DSP I/O */ |
| 446 | int mpu_irq; /* irq for mpu401 interface I/O */ |
| 447 | int dma; /* dma value for DSP I/O */ |
| 448 | int mss_base; /* base I/O for Microsoft Sound System */ |
| 449 | int mpu_base; /* base I/O for MPU-401 emulation */ |
| 450 | int init; /* Initialization status of the card */ |
| 451 | }; |
| 452 | |
| 453 | /* |
| 454 | * Magic values that the DSP will eat when configuring irq/mirq/dma |
| 455 | */ |
| 456 | /* DSP IRQ conversion array */ |
| 457 | static struct orVals orIRQ[] __initdata = { |
| 458 | {0x05, 0x28}, |
| 459 | {0x07, 0x08}, |
| 460 | {0x09, 0x10}, |
| 461 | {0x0a, 0x18}, |
| 462 | {0x0b, 0x20}, |
| 463 | {0x00, 0x00} |
| 464 | }; |
| 465 | |
| 466 | /* MPU-401 IRQ conversion array */ |
| 467 | static struct orVals orMIRQ[] __initdata = { |
| 468 | {0x05, 0x04}, |
| 469 | {0x07, 0x44}, |
| 470 | {0x09, 0x84}, |
| 471 | {0x0a, 0xc4}, |
| 472 | {0x00, 0x00} |
| 473 | }; |
| 474 | |
| 475 | /* DMA Channels conversion array */ |
| 476 | static struct orVals orDMA[] __initdata = { |
| 477 | {0x00, 0x01}, |
| 478 | {0x01, 0x02}, |
| 479 | {0x03, 0x03}, |
| 480 | {0x00, 0x00} |
| 481 | }; |
| 482 | |
| 483 | static struct aedsp16_info ae_config = { |
| 484 | DEF_AEDSP16_IOB, |
| 485 | DEF_AEDSP16_IRQ, |
| 486 | DEF_AEDSP16_MRQ, |
| 487 | DEF_AEDSP16_DMA, |
| 488 | -1, |
| 489 | -1, |
| 490 | INIT_NONE |
| 491 | }; |
| 492 | |
| 493 | /* |
| 494 | * Buffers to store audio card informations |
| 495 | */ |
| 496 | static char DSPCopyright[CARDNAMELEN + 1] __initdata = {0, }; |
| 497 | static char DSPVersion[CARDVERLEN + 1] __initdata = {0, }; |
| 498 | |
| 499 | static int __init aedsp16_wait_data(int port) |
| 500 | { |
| 501 | int loop = STATUSRETRY; |
| 502 | unsigned char ret = 0; |
| 503 | |
| 504 | DBG1(("aedsp16_wait_data (0x%x): ", port)); |
| 505 | |
| 506 | do { |
| 507 | ret = inb(port + DSP_DATAVAIL); |
| 508 | /* |
| 509 | * Wait for data available (bit 7 of ret == 1) |
| 510 | */ |
| 511 | } while (!(ret & 0x80) && loop--); |
| 512 | |
| 513 | if (ret & 0x80) { |
| 514 | DBG1(("success.\n")); |
| 515 | return TRUE; |
| 516 | } |
| 517 | |
| 518 | DBG1(("failure.\n")); |
| 519 | return FALSE; |
| 520 | } |
| 521 | |
| 522 | static int __init aedsp16_read(int port) |
| 523 | { |
| 524 | int inbyte; |
| 525 | |
| 526 | DBG((" Read DSP Byte (0x%x): ", port)); |
| 527 | |
| 528 | if (aedsp16_wait_data(port) == FALSE) { |
| 529 | DBG(("failure.\n")); |
| 530 | return -1; |
| 531 | } |
| 532 | |
| 533 | inbyte = inb(port + DSP_READ); |
| 534 | |
| 535 | DBG(("read [0x%x]/{%c}.\n", inbyte, inbyte)); |
| 536 | |
| 537 | return inbyte; |
| 538 | } |
| 539 | |
| 540 | static int __init aedsp16_test_dsp(int port) |
| 541 | { |
| 542 | return ((aedsp16_read(port) == 0xaa) ? TRUE : FALSE); |
| 543 | } |
| 544 | |
| 545 | static int __init aedsp16_dsp_reset(int port) |
| 546 | { |
| 547 | /* |
| 548 | * Reset DSP |
| 549 | */ |
| 550 | |
| 551 | DBG(("Reset DSP:\n")); |
| 552 | |
| 553 | outb(1, (port + DSP_RESET)); |
| 554 | udelay(10); |
| 555 | outb(0, (port + DSP_RESET)); |
| 556 | udelay(10); |
| 557 | udelay(10); |
| 558 | if (aedsp16_test_dsp(port) == TRUE) { |
| 559 | DBG(("success.\n")); |
| 560 | return TRUE; |
| 561 | } else |
| 562 | DBG(("failure.\n")); |
| 563 | return FALSE; |
| 564 | } |
| 565 | |
| 566 | static int __init aedsp16_write(int port, int cmd) |
| 567 | { |
| 568 | unsigned char ret; |
| 569 | int loop = HARDRETRY; |
| 570 | |
| 571 | DBG((" Write DSP Byte (0x%x) [0x%x]: ", port, cmd)); |
| 572 | |
| 573 | do { |
| 574 | ret = inb(port + DSP_STATUS); |
| 575 | /* |
| 576 | * DSP ready to receive data if bit 7 of ret == 0 |
| 577 | */ |
| 578 | if (!(ret & 0x80)) { |
| 579 | outb(cmd, port + DSP_COMMAND); |
| 580 | DBG(("success.\n")); |
| 581 | return 0; |
| 582 | } |
| 583 | } while (loop--); |
| 584 | |
| 585 | DBG(("timeout.\n")); |
| 586 | printk("[AEDSP16] DSP Command (0x%x) timeout.\n", cmd); |
| 587 | |
| 588 | return -1; |
| 589 | } |
| 590 | |
| 591 | #if defined(CONFIG_SC6600) |
| 592 | |
| 593 | #if defined(AEDSP16_INFO) || defined(AEDSP16_DEBUG) |
| 594 | void __init aedsp16_pinfo(void) { |
| 595 | DBG(("\n Base address: %x\n", decoded_hcfg.iobase)); |
| 596 | DBG((" Joystick : %s present\n", decoded_hcfg.joystick?"":" not")); |
| 597 | DBG((" WSS addr : %x\n", decoded_hcfg.wssbase)); |
| 598 | DBG((" MPU-401 addr: %x\n", decoded_hcfg.mpubase)); |
| 599 | DBG((" CDROM : %s present\n", (decoded_hcfg.cdrom!=4)?"":" not")); |
| 600 | DBG((" CDROMADDR : %x\n\n", decoded_hcfg.cdrombase)); |
| 601 | } |
| 602 | #endif |
| 603 | |
| 604 | static void __init aedsp16_hard_decode(void) { |
| 605 | |
| 606 | DBG((" aedsp16_hard_decode: 0x%x, 0x%x\n", hard_cfg[0], hard_cfg[1])); |
| 607 | |
| 608 | /* |
| 609 | * Decode Cfg Bytes. |
| 610 | */ |
| 611 | decoded_hcfg.iobase = IOBASE(hard_cfg[0]); |
| 612 | decoded_hcfg.joystick = JOY(hard_cfg[0]); |
| 613 | decoded_hcfg.wssbase = WSSADDR(hard_cfg[0]); |
| 614 | decoded_hcfg.mpubase = MPUADDR(hard_cfg[0]); |
| 615 | decoded_hcfg.cdrom = CDROM(hard_cfg[1]); |
| 616 | decoded_hcfg.cdrombase = CDROMADDR(hard_cfg[1]); |
| 617 | |
| 618 | #if defined(AEDSP16_INFO) || defined(AEDSP16_DEBUG) |
| 619 | printk(" Original sound card configuration:\n"); |
| 620 | aedsp16_pinfo(); |
| 621 | #endif |
| 622 | |
| 623 | /* |
| 624 | * Now set up the real kernel configuration. |
| 625 | */ |
| 626 | decoded_hcfg.iobase = ae_config.base_io; |
| 627 | decoded_hcfg.wssbase = ae_config.mss_base; |
| 628 | decoded_hcfg.mpubase = ae_config.mpu_base; |
| 629 | |
| 630 | #if defined(CONFIG_SC6600_JOY) |
| 631 | decoded_hcfg.joystick = CONFIG_SC6600_JOY; /* Enable */ |
| 632 | #endif |
| 633 | #if defined(CONFIG_SC6600_CDROM) |
| 634 | decoded_hcfg.cdrom = CONFIG_SC6600_CDROM; /* 4:N-3:I-2:G-1:P-0:S */ |
| 635 | #endif |
| 636 | #if defined(CONFIG_SC6600_CDROMBASE) |
| 637 | decoded_hcfg.cdrombase = CONFIG_SC6600_CDROMBASE; /* 0 Disable */ |
| 638 | #endif |
| 639 | |
| 640 | #if defined(AEDSP16_DEBUG) |
| 641 | DBG((" New Values:\n")); |
| 642 | aedsp16_pinfo(); |
| 643 | #endif |
| 644 | |
| 645 | DBG(("success.\n")); |
| 646 | } |
| 647 | |
| 648 | static void __init aedsp16_hard_encode(void) { |
| 649 | |
| 650 | DBG((" aedsp16_hard_encode: 0x%x, 0x%x\n", hard_cfg[0], hard_cfg[1])); |
| 651 | |
| 652 | hard_cfg[0] = 0; |
| 653 | hard_cfg[1] = 0; |
| 654 | |
| 655 | hard_cfg[0] |= 0x20; |
| 656 | |
| 657 | BLDIOBASE (hard_cfg[0], decoded_hcfg.iobase); |
| 658 | BLDWSSADDR(hard_cfg[0], decoded_hcfg.wssbase); |
| 659 | BLDMPUADDR(hard_cfg[0], decoded_hcfg.mpubase); |
| 660 | BLDJOY(hard_cfg[0], decoded_hcfg.joystick); |
| 661 | BLDCDROM(hard_cfg[1], decoded_hcfg.cdrom); |
| 662 | BLDCDROMADDR(hard_cfg[1], decoded_hcfg.cdrombase); |
| 663 | |
| 664 | #if defined(AEDSP16_DEBUG) |
| 665 | aedsp16_pinfo(); |
| 666 | #endif |
| 667 | |
| 668 | DBG((" aedsp16_hard_encode: 0x%x, 0x%x\n", hard_cfg[0], hard_cfg[1])); |
| 669 | DBG(("success.\n")); |
| 670 | |
| 671 | } |
| 672 | |
| 673 | static int __init aedsp16_hard_write(int port) { |
| 674 | |
| 675 | DBG(("aedsp16_hard_write:\n")); |
| 676 | |
| 677 | if (aedsp16_write(port, COMMAND_6C)) { |
| 678 | printk("[AEDSP16] CMD 0x%x: failed!\n", COMMAND_6C); |
| 679 | DBG(("failure.\n")); |
| 680 | return FALSE; |
| 681 | } |
| 682 | if (aedsp16_write(port, COMMAND_5C)) { |
| 683 | printk("[AEDSP16] CMD 0x%x: failed!\n", COMMAND_5C); |
| 684 | DBG(("failure.\n")); |
| 685 | return FALSE; |
| 686 | } |
| 687 | if (aedsp16_write(port, hard_cfg[0])) { |
| 688 | printk("[AEDSP16] DATA 0x%x: failed!\n", hard_cfg[0]); |
| 689 | DBG(("failure.\n")); |
| 690 | return FALSE; |
| 691 | } |
| 692 | if (aedsp16_write(port, hard_cfg[1])) { |
| 693 | printk("[AEDSP16] DATA 0x%x: failed!\n", hard_cfg[1]); |
| 694 | DBG(("failure.\n")); |
| 695 | return FALSE; |
| 696 | } |
| 697 | if (aedsp16_write(port, COMMAND_C5)) { |
| 698 | printk("[AEDSP16] CMD 0x%x: failed!\n", COMMAND_C5); |
| 699 | DBG(("failure.\n")); |
| 700 | return FALSE; |
| 701 | } |
| 702 | |
| 703 | DBG(("success.\n")); |
| 704 | |
| 705 | return TRUE; |
| 706 | } |
| 707 | |
| 708 | static int __init aedsp16_hard_read(int port) { |
| 709 | |
| 710 | DBG(("aedsp16_hard_read:\n")); |
| 711 | |
| 712 | if (aedsp16_write(port, READ_HARD_CFG)) { |
| 713 | printk("[AEDSP16] CMD 0x%x: failed!\n", READ_HARD_CFG); |
| 714 | DBG(("failure.\n")); |
| 715 | return FALSE; |
| 716 | } |
| 717 | |
| 718 | if ((hard_cfg[0] = aedsp16_read(port)) == -1) { |
| 719 | printk("[AEDSP16] aedsp16_read after CMD 0x%x: failed\n", |
| 720 | READ_HARD_CFG); |
| 721 | DBG(("failure.\n")); |
| 722 | return FALSE; |
| 723 | } |
| 724 | if ((hard_cfg[1] = aedsp16_read(port)) == -1) { |
| 725 | printk("[AEDSP16] aedsp16_read after CMD 0x%x: failed\n", |
| 726 | READ_HARD_CFG); |
| 727 | DBG(("failure.\n")); |
| 728 | return FALSE; |
| 729 | } |
| 730 | if (aedsp16_read(port) == -1) { |
| 731 | printk("[AEDSP16] aedsp16_read after CMD 0x%x: failed\n", |
| 732 | READ_HARD_CFG); |
| 733 | DBG(("failure.\n")); |
| 734 | return FALSE; |
| 735 | } |
| 736 | |
| 737 | DBG(("success.\n")); |
| 738 | |
| 739 | return TRUE; |
| 740 | } |
| 741 | |
| 742 | static int __init aedsp16_ext_cfg_write(int port) { |
| 743 | |
| 744 | int extcfg, val; |
| 745 | |
| 746 | if (aedsp16_write(port, COMMAND_66)) { |
| 747 | printk("[AEDSP16] CMD 0x%x: failed!\n", COMMAND_66); |
| 748 | return FALSE; |
| 749 | } |
| 750 | |
| 751 | extcfg = 7; |
| 752 | if (decoded_hcfg.cdrom != 2) |
| 753 | extcfg = 0x0F; |
| 754 | if ((decoded_hcfg.cdrom == 4) || |
| 755 | (decoded_hcfg.cdrom == 3)) |
| 756 | extcfg &= ~2; |
| 757 | if (decoded_hcfg.cdrombase == 0) |
| 758 | extcfg &= ~2; |
| 759 | if (decoded_hcfg.mpubase == 0) |
| 760 | extcfg &= ~1; |
| 761 | |
| 762 | if (aedsp16_write(port, extcfg)) { |
| 763 | printk("[AEDSP16] Write extcfg: failed!\n"); |
| 764 | return FALSE; |
| 765 | } |
| 766 | if (aedsp16_write(port, 0)) { |
| 767 | printk("[AEDSP16] Write extcfg: failed!\n"); |
| 768 | return FALSE; |
| 769 | } |
| 770 | if (decoded_hcfg.cdrom == 3) { |
| 771 | if (aedsp16_write(port, COMMAND_52)) { |
| 772 | printk("[AEDSP16] CMD 0x%x: failed!\n", COMMAND_52); |
| 773 | return FALSE; |
| 774 | } |
| 775 | if ((val = aedsp16_read(port)) == -1) { |
| 776 | printk("[AEDSP16] aedsp16_read after CMD 0x%x: failed\n" |
| 777 | , COMMAND_52); |
| 778 | return FALSE; |
| 779 | } |
| 780 | val &= 0x7F; |
| 781 | if (aedsp16_write(port, COMMAND_60)) { |
| 782 | printk("[AEDSP16] CMD 0x%x: failed!\n", COMMAND_60); |
| 783 | return FALSE; |
| 784 | } |
| 785 | if (aedsp16_write(port, val)) { |
| 786 | printk("[AEDSP16] Write val: failed!\n"); |
| 787 | return FALSE; |
| 788 | } |
| 789 | } |
| 790 | |
| 791 | return TRUE; |
| 792 | } |
| 793 | |
| 794 | #endif /* CONFIG_SC6600 */ |
| 795 | |
| 796 | static int __init aedsp16_cfg_write(int port) { |
| 797 | if (aedsp16_write(port, WRITE_MDIRQ_CFG)) { |
| 798 | printk("[AEDSP16] CMD 0x%x: failed!\n", WRITE_MDIRQ_CFG); |
| 799 | return FALSE; |
| 800 | } |
| 801 | if (aedsp16_write(port, soft_cfg)) { |
| 802 | printk("[AEDSP16] Initialization of (M)IRQ and DMA: failed!\n"); |
| 803 | return FALSE; |
| 804 | } |
| 805 | return TRUE; |
| 806 | } |
| 807 | |
| 808 | static int __init aedsp16_init_mss(int port) |
| 809 | { |
| 810 | DBG(("aedsp16_init_mss:\n")); |
| 811 | |
| 812 | mdelay(10); |
| 813 | |
| 814 | if (aedsp16_write(port, DSP_INIT_MSS)) { |
| 815 | printk("[AEDSP16] aedsp16_init_mss [0x%x]: failed!\n", |
| 816 | DSP_INIT_MSS); |
| 817 | DBG(("failure.\n")); |
| 818 | return FALSE; |
| 819 | } |
| 820 | |
| 821 | mdelay(10); |
| 822 | |
| 823 | if (aedsp16_cfg_write(port) == FALSE) |
| 824 | return FALSE; |
| 825 | |
| 826 | outb(soft_cfg_mss, ae_config.mss_base); |
| 827 | |
| 828 | DBG(("success.\n")); |
| 829 | |
| 830 | return TRUE; |
| 831 | } |
| 832 | |
| 833 | static int __init aedsp16_setup_board(int port) { |
| 834 | int loop = RETRY; |
| 835 | |
| 836 | #if defined(CONFIG_SC6600) |
| 837 | int val = 0; |
| 838 | |
| 839 | if (aedsp16_hard_read(port) == FALSE) { |
| 840 | printk("[AEDSP16] aedsp16_hard_read: failed!\n"); |
| 841 | return FALSE; |
| 842 | } |
| 843 | |
| 844 | if (aedsp16_write(port, COMMAND_52)) { |
| 845 | printk("[AEDSP16] CMD 0x%x: failed!\n", COMMAND_52); |
| 846 | return FALSE; |
| 847 | } |
| 848 | |
| 849 | if ((val = aedsp16_read(port)) == -1) { |
| 850 | printk("[AEDSP16] aedsp16_read after CMD 0x%x: failed\n", |
| 851 | COMMAND_52); |
| 852 | return FALSE; |
| 853 | } |
| 854 | #endif |
| 855 | |
| 856 | do { |
| 857 | if (aedsp16_write(port, COMMAND_88)) { |
| 858 | printk("[AEDSP16] CMD 0x%x: failed!\n", COMMAND_88); |
| 859 | return FALSE; |
| 860 | } |
| 861 | mdelay(10); |
| 862 | } while ((aedsp16_wait_data(port) == FALSE) && loop--); |
| 863 | |
| 864 | if (aedsp16_read(port) == -1) { |
| 865 | printk("[AEDSP16] aedsp16_read after CMD 0x%x: failed\n", |
| 866 | COMMAND_88); |
| 867 | return FALSE; |
| 868 | } |
| 869 | |
| 870 | #if !defined(CONFIG_SC6600) |
| 871 | if (aedsp16_write(port, COMMAND_5C)) { |
| 872 | printk("[AEDSP16] CMD 0x%x: failed!\n", COMMAND_5C); |
| 873 | return FALSE; |
| 874 | } |
| 875 | #endif |
| 876 | |
| 877 | if (aedsp16_cfg_write(port) == FALSE) |
| 878 | return FALSE; |
| 879 | |
| 880 | #if defined(CONFIG_SC6600) |
| 881 | if (aedsp16_write(port, COMMAND_60)) { |
| 882 | printk("[AEDSP16] CMD 0x%x: failed!\n", COMMAND_60); |
| 883 | return FALSE; |
| 884 | } |
| 885 | if (aedsp16_write(port, val)) { |
| 886 | printk("[AEDSP16] DATA 0x%x: failed!\n", val); |
| 887 | return FALSE; |
| 888 | } |
| 889 | if (aedsp16_write(port, COMMAND_6E)) { |
| 890 | printk("[AEDSP16] CMD 0x%x: failed!\n", COMMAND_6E); |
| 891 | return FALSE; |
| 892 | } |
| 893 | if (aedsp16_write(port, ver[0])) { |
| 894 | printk("[AEDSP16] DATA 0x%x: failed!\n", ver[0]); |
| 895 | return FALSE; |
| 896 | } |
| 897 | if (aedsp16_write(port, ver[1])) { |
| 898 | printk("[AEDSP16] DATA 0x%x: failed!\n", ver[1]); |
| 899 | return FALSE; |
| 900 | } |
| 901 | |
| 902 | if (aedsp16_hard_write(port) == FALSE) { |
| 903 | printk("[AEDSP16] aedsp16_hard_write: failed!\n"); |
| 904 | return FALSE; |
| 905 | } |
| 906 | |
| 907 | if (aedsp16_write(port, COMMAND_5C)) { |
| 908 | printk("[AEDSP16] CMD 0x%x: failed!\n", COMMAND_5C); |
| 909 | return FALSE; |
| 910 | } |
| 911 | |
| 912 | #if defined(THIS_IS_A_THING_I_HAVE_NOT_TESTED_YET) |
| 913 | if (aedsp16_cfg_write(port) == FALSE) |
| 914 | return FALSE; |
| 915 | #endif |
| 916 | |
| 917 | #endif |
| 918 | |
| 919 | return TRUE; |
| 920 | } |
| 921 | |
| 922 | static int __init aedsp16_stdcfg(int port) { |
| 923 | if (aedsp16_write(port, WRITE_MDIRQ_CFG)) { |
| 924 | printk("[AEDSP16] CMD 0x%x: failed!\n", WRITE_MDIRQ_CFG); |
| 925 | return FALSE; |
| 926 | } |
| 927 | /* |
| 928 | * 0x0A == (IRQ 7, DMA 1, MIRQ 0) |
| 929 | */ |
| 930 | if (aedsp16_write(port, 0x0A)) { |
| 931 | printk("[AEDSP16] aedsp16_stdcfg: failed!\n"); |
| 932 | return FALSE; |
| 933 | } |
| 934 | return TRUE; |
| 935 | } |
| 936 | |
| 937 | static int __init aedsp16_dsp_version(int port) |
| 938 | { |
| 939 | int len = 0; |
| 940 | int ret; |
| 941 | |
| 942 | DBG(("Get DSP Version:\n")); |
| 943 | |
| 944 | if (aedsp16_write(ae_config.base_io, GET_DSP_VERSION)) { |
| 945 | printk("[AEDSP16] CMD 0x%x: failed!\n", GET_DSP_VERSION); |
| 946 | DBG(("failed.\n")); |
| 947 | return FALSE; |
| 948 | } |
| 949 | |
| 950 | do { |
| 951 | if ((ret = aedsp16_read(port)) == -1) { |
| 952 | DBG(("failed.\n")); |
| 953 | return FALSE; |
| 954 | } |
| 955 | /* |
| 956 | * We already know how many int are stored (2), so we know when the |
| 957 | * string is finished. |
| 958 | */ |
| 959 | ver[len++] = ret; |
| 960 | } while (len < CARDVERLEN); |
| 961 | sprintf(DSPVersion, "%d.%d", ver[0], ver[1]); |
| 962 | |
| 963 | DBG(("success.\n")); |
| 964 | |
| 965 | return TRUE; |
| 966 | } |
| 967 | |
| 968 | static int __init aedsp16_dsp_copyright(int port) |
| 969 | { |
| 970 | int len = 0; |
| 971 | int ret; |
| 972 | |
| 973 | DBG(("Get DSP Copyright:\n")); |
| 974 | |
| 975 | if (aedsp16_write(ae_config.base_io, GET_DSP_COPYRIGHT)) { |
| 976 | printk("[AEDSP16] CMD 0x%x: failed!\n", GET_DSP_COPYRIGHT); |
| 977 | DBG(("failed.\n")); |
| 978 | return FALSE; |
| 979 | } |
| 980 | |
| 981 | do { |
| 982 | if ((ret = aedsp16_read(port)) == -1) { |
| 983 | /* |
| 984 | * If no more data available, return to the caller, no error if len>0. |
| 985 | * We have no other way to know when the string is finished. |
| 986 | */ |
| 987 | if (len) |
| 988 | break; |
| 989 | else { |
| 990 | DBG(("failed.\n")); |
| 991 | return FALSE; |
| 992 | } |
| 993 | } |
| 994 | |
| 995 | DSPCopyright[len++] = ret; |
| 996 | |
| 997 | } while (len < CARDNAMELEN); |
| 998 | |
| 999 | DBG(("success.\n")); |
| 1000 | |
| 1001 | return TRUE; |
| 1002 | } |
| 1003 | |
| 1004 | static void __init aedsp16_init_tables(void) |
| 1005 | { |
| 1006 | int i = 0; |
| 1007 | |
| 1008 | memset(DSPCopyright, 0, CARDNAMELEN + 1); |
| 1009 | memset(DSPVersion, 0, CARDVERLEN + 1); |
| 1010 | |
| 1011 | for (i = 0; orIRQ[i].or; i++) |
| 1012 | if (orIRQ[i].val == ae_config.irq) { |
| 1013 | soft_cfg |= orIRQ[i].or; |
| 1014 | soft_cfg_mss |= orIRQ[i].or; |
| 1015 | } |
| 1016 | |
| 1017 | for (i = 0; orMIRQ[i].or; i++) |
| 1018 | if (orMIRQ[i].or == ae_config.mpu_irq) |
| 1019 | soft_cfg |= orMIRQ[i].or; |
| 1020 | |
| 1021 | for (i = 0; orDMA[i].or; i++) |
| 1022 | if (orDMA[i].val == ae_config.dma) { |
| 1023 | soft_cfg |= orDMA[i].or; |
| 1024 | soft_cfg_mss |= orDMA[i].or; |
| 1025 | } |
| 1026 | } |
| 1027 | |
| 1028 | static int __init aedsp16_init_board(void) |
| 1029 | { |
| 1030 | aedsp16_init_tables(); |
| 1031 | |
| 1032 | if (aedsp16_dsp_reset(ae_config.base_io) == FALSE) { |
| 1033 | printk("[AEDSP16] aedsp16_dsp_reset: failed!\n"); |
| 1034 | return FALSE; |
| 1035 | } |
| 1036 | if (aedsp16_dsp_copyright(ae_config.base_io) == FALSE) { |
| 1037 | printk("[AEDSP16] aedsp16_dsp_copyright: failed!\n"); |
| 1038 | return FALSE; |
| 1039 | } |
| 1040 | |
| 1041 | /* |
| 1042 | * My AEDSP16 card return SC-6000 in DSPCopyright, so |
| 1043 | * if we have something different, we have to be warned. |
| 1044 | */ |
| 1045 | if (strcmp("SC-6000", DSPCopyright)) |
| 1046 | printk("[AEDSP16] Warning: non SC-6000 audio card!\n"); |
| 1047 | |
| 1048 | if (aedsp16_dsp_version(ae_config.base_io) == FALSE) { |
| 1049 | printk("[AEDSP16] aedsp16_dsp_version: failed!\n"); |
| 1050 | return FALSE; |
| 1051 | } |
| 1052 | |
| 1053 | if (aedsp16_stdcfg(ae_config.base_io) == FALSE) { |
| 1054 | printk("[AEDSP16] aedsp16_stdcfg: failed!\n"); |
| 1055 | return FALSE; |
| 1056 | } |
| 1057 | |
| 1058 | #if defined(CONFIG_SC6600) |
| 1059 | if (aedsp16_hard_read(ae_config.base_io) == FALSE) { |
| 1060 | printk("[AEDSP16] aedsp16_hard_read: failed!\n"); |
| 1061 | return FALSE; |
| 1062 | } |
| 1063 | |
| 1064 | aedsp16_hard_decode(); |
| 1065 | |
| 1066 | aedsp16_hard_encode(); |
| 1067 | |
| 1068 | if (aedsp16_hard_write(ae_config.base_io) == FALSE) { |
| 1069 | printk("[AEDSP16] aedsp16_hard_write: failed!\n"); |
| 1070 | return FALSE; |
| 1071 | } |
| 1072 | |
| 1073 | if (aedsp16_ext_cfg_write(ae_config.base_io) == FALSE) { |
| 1074 | printk("[AEDSP16] aedsp16_ext_cfg_write: failed!\n"); |
| 1075 | return FALSE; |
| 1076 | } |
| 1077 | #endif /* CONFIG_SC6600 */ |
| 1078 | |
| 1079 | if (aedsp16_setup_board(ae_config.base_io) == FALSE) { |
| 1080 | printk("[AEDSP16] aedsp16_setup_board: failed!\n"); |
| 1081 | return FALSE; |
| 1082 | } |
| 1083 | |
| 1084 | if (ae_config.mss_base != -1) { |
| 1085 | if (ae_config.init & INIT_MSS) { |
| 1086 | if (aedsp16_init_mss(ae_config.base_io) == FALSE) { |
| 1087 | printk("[AEDSP16] Can not initialize" |
| 1088 | "Microsoft Sound System mode.\n"); |
| 1089 | return FALSE; |
| 1090 | } |
| 1091 | } |
| 1092 | } |
| 1093 | |
| 1094 | #if !defined(MODULE) || defined(AEDSP16_INFO) || defined(AEDSP16_DEBUG) |
| 1095 | |
| 1096 | printk("Audio Excel DSP 16 init v%s (%s %s) [", |
| 1097 | VERSION, DSPCopyright, |
| 1098 | DSPVersion); |
| 1099 | |
| 1100 | if (ae_config.mpu_base != -1) { |
| 1101 | if (ae_config.init & INIT_MPU401) { |
| 1102 | printk("MPU401"); |
| 1103 | if ((ae_config.init & INIT_MSS) || |
| 1104 | (ae_config.init & INIT_SBPRO)) |
| 1105 | printk(" "); |
| 1106 | } |
| 1107 | } |
| 1108 | |
| 1109 | if (ae_config.mss_base == -1) { |
| 1110 | if (ae_config.init & INIT_SBPRO) { |
| 1111 | printk("SBPro"); |
| 1112 | if (ae_config.init & INIT_MSS) |
| 1113 | printk(" "); |
| 1114 | } |
| 1115 | } |
| 1116 | |
| 1117 | if (ae_config.mss_base != -1) |
| 1118 | if (ae_config.init & INIT_MSS) |
| 1119 | printk("MSS"); |
| 1120 | |
| 1121 | printk("]\n"); |
| 1122 | #endif /* MODULE || AEDSP16_INFO || AEDSP16_DEBUG */ |
| 1123 | |
| 1124 | mdelay(10); |
| 1125 | |
| 1126 | return TRUE; |
| 1127 | } |
| 1128 | |
| 1129 | static int __init init_aedsp16_sb(void) |
| 1130 | { |
| 1131 | DBG(("init_aedsp16_sb: ")); |
| 1132 | |
| 1133 | /* |
| 1134 | * If the card is already init'ed MSS, we can not init it to SBPRO too |
| 1135 | * because the board can not emulate simultaneously MSS and SBPRO. |
| 1136 | */ |
| 1137 | if (ae_config.init & INIT_MSS) |
| 1138 | return FALSE; |
| 1139 | if (ae_config.init & INIT_SBPRO) |
| 1140 | return FALSE; |
| 1141 | |
| 1142 | ae_config.init |= INIT_SBPRO; |
| 1143 | |
| 1144 | DBG(("done.\n")); |
| 1145 | |
| 1146 | return TRUE; |
| 1147 | } |
| 1148 | |
| 1149 | static void uninit_aedsp16_sb(void) |
| 1150 | { |
| 1151 | DBG(("uninit_aedsp16_sb: ")); |
| 1152 | |
| 1153 | ae_config.init &= ~INIT_SBPRO; |
| 1154 | |
| 1155 | DBG(("done.\n")); |
| 1156 | } |
| 1157 | |
| 1158 | static int __init init_aedsp16_mss(void) |
| 1159 | { |
| 1160 | DBG(("init_aedsp16_mss: ")); |
| 1161 | |
| 1162 | /* |
| 1163 | * If the card is already init'ed SBPRO, we can not init it to MSS too |
| 1164 | * because the board can not emulate simultaneously MSS and SBPRO. |
| 1165 | */ |
| 1166 | if (ae_config.init & INIT_SBPRO) |
| 1167 | return FALSE; |
| 1168 | if (ae_config.init & INIT_MSS) |
| 1169 | return FALSE; |
| 1170 | /* |
| 1171 | * We must allocate the CONFIG_AEDSP16_BASE region too because these are the |
| 1172 | * I/O ports to access card's control registers. |
| 1173 | */ |
| 1174 | if (!(ae_config.init & INIT_MPU401)) { |
| 1175 | if (!request_region(ae_config.base_io, IOBASE_REGION_SIZE, |
| 1176 | "aedsp16 (base)")) { |
| 1177 | printk( |
| 1178 | "AEDSP16 BASE I/O port region is already in use.\n"); |
| 1179 | return FALSE; |
| 1180 | } |
| 1181 | } |
| 1182 | |
| 1183 | ae_config.init |= INIT_MSS; |
| 1184 | |
| 1185 | DBG(("done.\n")); |
| 1186 | |
| 1187 | return TRUE; |
| 1188 | } |
| 1189 | |
| 1190 | static void uninit_aedsp16_mss(void) |
| 1191 | { |
| 1192 | DBG(("uninit_aedsp16_mss: ")); |
| 1193 | |
| 1194 | if ((!(ae_config.init & INIT_MPU401)) && |
| 1195 | (ae_config.init & INIT_MSS)) { |
| 1196 | release_region(ae_config.base_io, IOBASE_REGION_SIZE); |
| 1197 | DBG(("AEDSP16 base region released.\n")); |
| 1198 | } |
| 1199 | |
| 1200 | ae_config.init &= ~INIT_MSS; |
| 1201 | DBG(("done.\n")); |
| 1202 | } |
| 1203 | |
| 1204 | static int __init init_aedsp16_mpu(void) |
| 1205 | { |
| 1206 | DBG(("init_aedsp16_mpu: ")); |
| 1207 | |
| 1208 | if (ae_config.init & INIT_MPU401) |
| 1209 | return FALSE; |
| 1210 | |
| 1211 | /* |
| 1212 | * We must request the CONFIG_AEDSP16_BASE region too because these are the I/O |
| 1213 | * ports to access card's control registers. |
| 1214 | */ |
| 1215 | if (!(ae_config.init & (INIT_MSS | INIT_SBPRO))) { |
| 1216 | if (!request_region(ae_config.base_io, IOBASE_REGION_SIZE, |
| 1217 | "aedsp16 (base)")) { |
| 1218 | printk( |
| 1219 | "AEDSP16 BASE I/O port region is already in use.\n"); |
| 1220 | return FALSE; |
| 1221 | } |
| 1222 | } |
| 1223 | |
| 1224 | ae_config.init |= INIT_MPU401; |
| 1225 | |
| 1226 | DBG(("done.\n")); |
| 1227 | |
| 1228 | return TRUE; |
| 1229 | } |
| 1230 | |
| 1231 | static void uninit_aedsp16_mpu(void) |
| 1232 | { |
| 1233 | DBG(("uninit_aedsp16_mpu: ")); |
| 1234 | |
| 1235 | if ((!(ae_config.init & (INIT_MSS | INIT_SBPRO))) && |
| 1236 | (ae_config.init & INIT_MPU401)) { |
| 1237 | release_region(ae_config.base_io, IOBASE_REGION_SIZE); |
| 1238 | DBG(("AEDSP16 base region released.\n")); |
| 1239 | } |
| 1240 | |
| 1241 | ae_config.init &= ~INIT_MPU401; |
| 1242 | |
| 1243 | DBG(("done.\n")); |
| 1244 | } |
| 1245 | |
| 1246 | static int __init init_aedsp16(void) |
| 1247 | { |
| 1248 | int initialized = FALSE; |
| 1249 | |
| 1250 | DBG(("Initializing BASE[0x%x] IRQ[%d] DMA[%d] MIRQ[%d]\n", |
| 1251 | ae_config.base_io,ae_config.irq,ae_config.dma,ae_config.mpu_irq)); |
| 1252 | |
| 1253 | if (ae_config.mss_base == -1) { |
| 1254 | if (init_aedsp16_sb() == FALSE) { |
| 1255 | uninit_aedsp16_sb(); |
| 1256 | } else { |
| 1257 | initialized = TRUE; |
| 1258 | } |
| 1259 | } |
| 1260 | |
| 1261 | if (ae_config.mpu_base != -1) { |
| 1262 | if (init_aedsp16_mpu() == FALSE) { |
| 1263 | uninit_aedsp16_mpu(); |
| 1264 | } else { |
| 1265 | initialized = TRUE; |
| 1266 | } |
| 1267 | } |
| 1268 | |
| 1269 | /* |
| 1270 | * In the sequence of init routines, the MSS init MUST be the last! |
| 1271 | * This because of the special register programming the MSS mode needs. |
| 1272 | * A board reset would disable the MSS mode restoring the default SBPRO |
| 1273 | * mode. |
| 1274 | */ |
| 1275 | if (ae_config.mss_base != -1) { |
| 1276 | if (init_aedsp16_mss() == FALSE) { |
| 1277 | uninit_aedsp16_mss(); |
| 1278 | } else { |
| 1279 | initialized = TRUE; |
| 1280 | } |
| 1281 | } |
| 1282 | |
| 1283 | if (initialized) |
| 1284 | initialized = aedsp16_init_board(); |
| 1285 | return initialized; |
| 1286 | } |
| 1287 | |
| 1288 | static void __exit uninit_aedsp16(void) |
| 1289 | { |
| 1290 | if (ae_config.mss_base != -1) |
| 1291 | uninit_aedsp16_mss(); |
| 1292 | else |
| 1293 | uninit_aedsp16_sb(); |
| 1294 | if (ae_config.mpu_base != -1) |
| 1295 | uninit_aedsp16_mpu(); |
| 1296 | } |
| 1297 | |
| 1298 | static int __initdata io = -1; |
| 1299 | static int __initdata irq = -1; |
| 1300 | static int __initdata dma = -1; |
| 1301 | static int __initdata mpu_irq = -1; |
| 1302 | static int __initdata mss_base = -1; |
| 1303 | static int __initdata mpu_base = -1; |
| 1304 | |
| 1305 | module_param(io, int, 0); |
| 1306 | MODULE_PARM_DESC(io, "I/O base address (0x220 0x240)"); |
| 1307 | module_param(irq, int, 0); |
| 1308 | MODULE_PARM_DESC(irq, "IRQ line (5 7 9 10 11)"); |
| 1309 | module_param(dma, int, 0); |
| 1310 | MODULE_PARM_DESC(dma, "dma line (0 1 3)"); |
| 1311 | module_param(mpu_irq, int, 0); |
| 1312 | MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ line (5 7 9 10 0)"); |
| 1313 | module_param(mss_base, int, 0); |
| 1314 | MODULE_PARM_DESC(mss_base, "MSS emulation I/O base address (0x530 0xE80)"); |
| 1315 | module_param(mpu_base, int, 0); |
| 1316 | MODULE_PARM_DESC(mpu_base,"MPU-401 I/O base address (0x300 0x310 0x320 0x330)"); |
| 1317 | MODULE_AUTHOR("Riccardo Facchetti <fizban@tin.it>"); |
| 1318 | MODULE_DESCRIPTION("Audio Excel DSP 16 Driver Version " VERSION); |
| 1319 | MODULE_LICENSE("GPL"); |
| 1320 | |
| 1321 | static int __init do_init_aedsp16(void) { |
| 1322 | printk("Audio Excel DSP 16 init driver Copyright (C) Riccardo Facchetti 1995-98\n"); |
| 1323 | if (io == -1 || dma == -1 || irq == -1) { |
| 1324 | printk(KERN_INFO "aedsp16: I/O, IRQ and DMA are mandatory\n"); |
| 1325 | return -EINVAL; |
| 1326 | } |
| 1327 | |
| 1328 | ae_config.base_io = io; |
| 1329 | ae_config.irq = irq; |
| 1330 | ae_config.dma = dma; |
| 1331 | |
| 1332 | ae_config.mss_base = mss_base; |
| 1333 | ae_config.mpu_base = mpu_base; |
| 1334 | ae_config.mpu_irq = mpu_irq; |
| 1335 | |
| 1336 | if (init_aedsp16() == FALSE) { |
| 1337 | printk(KERN_ERR "aedsp16: initialization failed\n"); |
| 1338 | /* |
| 1339 | * XXX |
| 1340 | * What error should we return here ? |
| 1341 | */ |
| 1342 | return -EINVAL; |
| 1343 | } |
| 1344 | return 0; |
| 1345 | } |
| 1346 | |
| 1347 | static void __exit cleanup_aedsp16(void) { |
| 1348 | uninit_aedsp16(); |
| 1349 | } |
| 1350 | |
| 1351 | module_init(do_init_aedsp16); |
| 1352 | module_exit(cleanup_aedsp16); |
| 1353 | |
| 1354 | #ifndef MODULE |
| 1355 | static int __init setup_aedsp16(char *str) |
| 1356 | { |
| 1357 | /* io, irq, dma, mss_io, mpu_io, mpu_irq */ |
| 1358 | int ints[7]; |
| 1359 | |
| 1360 | str = get_options(str, ARRAY_SIZE(ints), ints); |
| 1361 | |
| 1362 | io = ints[1]; |
| 1363 | irq = ints[2]; |
| 1364 | dma = ints[3]; |
| 1365 | mss_base = ints[4]; |
| 1366 | mpu_base = ints[5]; |
| 1367 | mpu_irq = ints[6]; |
| 1368 | return 1; |
| 1369 | } |
| 1370 | |
| 1371 | __setup("aedsp16=", setup_aedsp16); |
| 1372 | #endif |