diff options
Diffstat (limited to 'sound/sparc/dbri.c')
| -rw-r--r-- | sound/sparc/dbri.c | 581 |
1 files changed, 297 insertions, 284 deletions
diff --git a/sound/sparc/dbri.c b/sound/sparc/dbri.c index e07085a7cfc3..376b98691c96 100644 --- a/sound/sparc/dbri.c +++ b/sound/sparc/dbri.c | |||
| @@ -8,18 +8,18 @@ | |||
| 8 | * Copyright (C) 1997 Rudolf Koenig (rfkoenig@immd4.informatik.uni-erlangen.de) | 8 | * Copyright (C) 1997 Rudolf Koenig (rfkoenig@immd4.informatik.uni-erlangen.de) |
| 9 | * Copyright (C) 1998, 1999 Brent Baccala (baccala@freesoft.org) | 9 | * Copyright (C) 1998, 1999 Brent Baccala (baccala@freesoft.org) |
| 10 | * | 10 | * |
| 11 | * This is the lowlevel driver for the DBRI & MMCODEC duo used for ISDN & AUDIO | 11 | * This is the low level driver for the DBRI & MMCODEC duo used for ISDN & AUDIO |
| 12 | * on Sun SPARCstation 10, 20, LX and Voyager models. | 12 | * on Sun SPARCStation 10, 20, LX and Voyager models. |
| 13 | * | 13 | * |
| 14 | * - DBRI: AT&T T5900FX Dual Basic Rates ISDN Interface. It is a 32 channel | 14 | * - DBRI: AT&T T5900FX Dual Basic Rates ISDN Interface. It is a 32 channel |
| 15 | * data time multiplexer with ISDN support (aka T7259) | 15 | * data time multiplexer with ISDN support (aka T7259) |
| 16 | * Interfaces: SBus,ISDN NT & TE, CHI, 4 bits parallel. | 16 | * Interfaces: SBus,ISDN NT & TE, CHI, 4 bits parallel. |
| 17 | * CHI: (spelled ki) Concentration Highway Interface (AT&T or Intel bus ?). | 17 | * CHI: (spelled ki) Concentration Highway Interface (AT&T or Intel bus ?). |
| 18 | * Documentation: | 18 | * Documentation: |
| 19 | * - "STP 4000SBus Dual Basic Rate ISDN (DBRI) Tranceiver" from | 19 | * - "STP 4000SBus Dual Basic Rate ISDN (DBRI) Transceiver" from |
| 20 | * Sparc Technology Business (courtesy of Sun Support) | 20 | * Sparc Technology Business (courtesy of Sun Support) |
| 21 | * - Data sheet of the T7903, a newer but very similar ISA bus equivalent | 21 | * - Data sheet of the T7903, a newer but very similar ISA bus equivalent |
| 22 | * available from the Lucent (formarly AT&T microelectronics) home | 22 | * available from the Lucent (formerly AT&T microelectronics) home |
| 23 | * page. | 23 | * page. |
| 24 | * - http://www.freesoft.org/Linux/DBRI/ | 24 | * - http://www.freesoft.org/Linux/DBRI/ |
| 25 | * - MMCODEC: Crystal Semiconductor CS4215 16 bit Multimedia Audio Codec | 25 | * - MMCODEC: Crystal Semiconductor CS4215 16 bit Multimedia Audio Codec |
| @@ -27,21 +27,21 @@ | |||
| 27 | * Documentation: from the Crystal Semiconductor home page. | 27 | * Documentation: from the Crystal Semiconductor home page. |
| 28 | * | 28 | * |
| 29 | * The DBRI is a 32 pipe machine, each pipe can transfer some bits between | 29 | * The DBRI is a 32 pipe machine, each pipe can transfer some bits between |
| 30 | * memory and a serial device (long pipes, nr 0-15) or between two serial | 30 | * memory and a serial device (long pipes, no. 0-15) or between two serial |
| 31 | * devices (short pipes, nr 16-31), or simply send a fixed data to a serial | 31 | * devices (short pipes, no. 16-31), or simply send a fixed data to a serial |
| 32 | * device (short pipes). | 32 | * device (short pipes). |
| 33 | * A timeslot defines the bit-offset and nr of bits read from a serial device. | 33 | * A timeslot defines the bit-offset and no. of bits read from a serial device. |
| 34 | * The timeslots are linked to 6 circular lists, one for each direction for | 34 | * The timeslots are linked to 6 circular lists, one for each direction for |
| 35 | * each serial device (NT,TE,CHI). A timeslot is associated to 1 or 2 pipes | 35 | * each serial device (NT,TE,CHI). A timeslot is associated to 1 or 2 pipes |
| 36 | * (the second one is a monitor/tee pipe, valid only for serial input). | 36 | * (the second one is a monitor/tee pipe, valid only for serial input). |
| 37 | * | 37 | * |
| 38 | * The mmcodec is connected via the CHI bus and needs the data & some | 38 | * The mmcodec is connected via the CHI bus and needs the data & some |
| 39 | * parameters (volume, output selection) timemultiplexed in 8 byte | 39 | * parameters (volume, output selection) time multiplexed in 8 byte |
| 40 | * chunks. It also has a control mode, which serves for audio format setting. | 40 | * chunks. It also has a control mode, which serves for audio format setting. |
| 41 | * | 41 | * |
| 42 | * Looking at the CS4215 data sheet it is easy to set up 2 or 4 codecs on | 42 | * Looking at the CS4215 data sheet it is easy to set up 2 or 4 codecs on |
| 43 | * the same CHI bus, so I thought perhaps it is possible to use the onboard | 43 | * the same CHI bus, so I thought perhaps it is possible to use the on-board |
| 44 | * & the speakerbox codec simultanously, giving 2 (not very independent :-) | 44 | * & the speakerbox codec simultaneously, giving 2 (not very independent :-) |
| 45 | * audio devices. But the SUN HW group decided against it, at least on my | 45 | * audio devices. But the SUN HW group decided against it, at least on my |
| 46 | * LX the speakerbox connector has at least 1 pin missing and 1 wrongly | 46 | * LX the speakerbox connector has at least 1 pin missing and 1 wrongly |
| 47 | * connected. | 47 | * connected. |
| @@ -56,6 +56,8 @@ | |||
| 56 | #include <sound/driver.h> | 56 | #include <sound/driver.h> |
| 57 | #include <linux/interrupt.h> | 57 | #include <linux/interrupt.h> |
| 58 | #include <linux/delay.h> | 58 | #include <linux/delay.h> |
| 59 | #include <linux/irq.h> | ||
| 60 | #include <linux/io.h> | ||
| 59 | 61 | ||
| 60 | #include <sound/core.h> | 62 | #include <sound/core.h> |
| 61 | #include <sound/pcm.h> | 63 | #include <sound/pcm.h> |
| @@ -64,8 +66,7 @@ | |||
| 64 | #include <sound/control.h> | 66 | #include <sound/control.h> |
| 65 | #include <sound/initval.h> | 67 | #include <sound/initval.h> |
| 66 | 68 | ||
| 67 | #include <asm/irq.h> | 69 | #include <linux/of.h> |
| 68 | #include <asm/io.h> | ||
| 69 | #include <asm/sbus.h> | 70 | #include <asm/sbus.h> |
| 70 | #include <asm/atomic.h> | 71 | #include <asm/atomic.h> |
| 71 | 72 | ||
| @@ -76,7 +77,8 @@ MODULE_SUPPORTED_DEVICE("{{Sun,DBRI}}"); | |||
| 76 | 77 | ||
| 77 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ | 78 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ |
| 78 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ | 79 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ |
| 79 | static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ | 80 | /* Enable this card */ |
| 81 | static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; | ||
| 80 | 82 | ||
| 81 | module_param_array(index, int, NULL, 0444); | 83 | module_param_array(index, int, NULL, 0444); |
| 82 | MODULE_PARM_DESC(index, "Index value for Sun DBRI soundcard."); | 84 | MODULE_PARM_DESC(index, "Index value for Sun DBRI soundcard."); |
| @@ -104,7 +106,7 @@ static char *cmds[] = { | |||
| 104 | "SSP", "CHI", "NT", "TE", "CDEC", "TEST", "CDM", "RESRV" | 106 | "SSP", "CHI", "NT", "TE", "CDEC", "TEST", "CDM", "RESRV" |
| 105 | }; | 107 | }; |
| 106 | 108 | ||
| 107 | #define dprintk(a, x...) if(dbri_debug & a) printk(KERN_DEBUG x) | 109 | #define dprintk(a, x...) if (dbri_debug & a) printk(KERN_DEBUG x) |
| 108 | 110 | ||
| 109 | #else | 111 | #else |
| 110 | #define dprintk(a, x...) do { } while (0) | 112 | #define dprintk(a, x...) do { } while (0) |
| @@ -131,7 +133,7 @@ struct cs4215 { | |||
| 131 | }; | 133 | }; |
| 132 | 134 | ||
| 133 | /* | 135 | /* |
| 134 | * Control mode first | 136 | * Control mode first |
| 135 | */ | 137 | */ |
| 136 | 138 | ||
| 137 | /* Time Slot 1, Status register */ | 139 | /* Time Slot 1, Status register */ |
| @@ -219,7 +221,7 @@ static struct { | |||
| 219 | /* Time Slot 7, Input Setting */ | 221 | /* Time Slot 7, Input Setting */ |
| 220 | #define CS4215_LG(v) v /* Left Gain Setting 0xf: 22.5 dB */ | 222 | #define CS4215_LG(v) v /* Left Gain Setting 0xf: 22.5 dB */ |
| 221 | #define CS4215_IS (1<<4) /* Input Select: 1=Microphone, 0=Line */ | 223 | #define CS4215_IS (1<<4) /* Input Select: 1=Microphone, 0=Line */ |
| 222 | #define CS4215_OVR (1<<5) /* 1: Overrange condition occurred */ | 224 | #define CS4215_OVR (1<<5) /* 1: Over range condition occurred */ |
| 223 | #define CS4215_PIO0 (1<<6) /* Parallel I/O 0 */ | 225 | #define CS4215_PIO0 (1<<6) /* Parallel I/O 0 */ |
| 224 | #define CS4215_PIO1 (1<<7) | 226 | #define CS4215_PIO1 (1<<7) |
| 225 | 227 | ||
| @@ -232,12 +234,12 @@ static struct { | |||
| 232 | ****************************************************************************/ | 234 | ****************************************************************************/ |
| 233 | 235 | ||
| 234 | /* DBRI main registers */ | 236 | /* DBRI main registers */ |
| 235 | #define REG0 0x00UL /* Status and Control */ | 237 | #define REG0 0x00 /* Status and Control */ |
| 236 | #define REG1 0x04UL /* Mode and Interrupt */ | 238 | #define REG1 0x04 /* Mode and Interrupt */ |
| 237 | #define REG2 0x08UL /* Parallel IO */ | 239 | #define REG2 0x08 /* Parallel IO */ |
| 238 | #define REG3 0x0cUL /* Test */ | 240 | #define REG3 0x0c /* Test */ |
| 239 | #define REG8 0x20UL /* Command Queue Pointer */ | 241 | #define REG8 0x20 /* Command Queue Pointer */ |
| 240 | #define REG9 0x24UL /* Interrupt Queue Pointer */ | 242 | #define REG9 0x24 /* Interrupt Queue Pointer */ |
| 241 | 243 | ||
| 242 | #define DBRI_NO_CMDS 64 | 244 | #define DBRI_NO_CMDS 64 |
| 243 | #define DBRI_INT_BLK 64 | 245 | #define DBRI_INT_BLK 64 |
| @@ -285,7 +287,7 @@ struct dbri_pipe { | |||
| 285 | /* Per stream (playback or record) information */ | 287 | /* Per stream (playback or record) information */ |
| 286 | struct dbri_streaminfo { | 288 | struct dbri_streaminfo { |
| 287 | struct snd_pcm_substream *substream; | 289 | struct snd_pcm_substream *substream; |
| 288 | u32 dvma_buffer; /* Device view of Alsa DMA buffer */ | 290 | u32 dvma_buffer; /* Device view of ALSA DMA buffer */ |
| 289 | int size; /* Size of DMA buffer */ | 291 | int size; /* Size of DMA buffer */ |
| 290 | size_t offset; /* offset in user buffer */ | 292 | size_t offset; /* offset in user buffer */ |
| 291 | int pipe; /* Data pipe used */ | 293 | int pipe; /* Data pipe used */ |
| @@ -295,8 +297,6 @@ struct dbri_streaminfo { | |||
| 295 | 297 | ||
| 296 | /* This structure holds the information for both chips (DBRI & CS4215) */ | 298 | /* This structure holds the information for both chips (DBRI & CS4215) */ |
| 297 | struct snd_dbri { | 299 | struct snd_dbri { |
| 298 | struct snd_card *card; /* ALSA card */ | ||
| 299 | |||
| 300 | int regs_size, irq; /* Needed for unload */ | 300 | int regs_size, irq; /* Needed for unload */ |
| 301 | struct sbus_dev *sdev; /* SBUS device info */ | 301 | struct sbus_dev *sdev; /* SBUS device info */ |
| 302 | spinlock_t lock; | 302 | spinlock_t lock; |
| @@ -317,8 +317,6 @@ struct snd_dbri { | |||
| 317 | struct cs4215 mm; /* mmcodec special info */ | 317 | struct cs4215 mm; /* mmcodec special info */ |
| 318 | /* per stream (playback/record) info */ | 318 | /* per stream (playback/record) info */ |
| 319 | struct dbri_streaminfo stream_info[DBRI_NO_STREAMS]; | 319 | struct dbri_streaminfo stream_info[DBRI_NO_STREAMS]; |
| 320 | |||
| 321 | struct snd_dbri *next; | ||
| 322 | }; | 320 | }; |
| 323 | 321 | ||
| 324 | #define DBRI_MAX_VOLUME 63 /* Output volume */ | 322 | #define DBRI_MAX_VOLUME 63 /* Output volume */ |
| @@ -341,11 +339,11 @@ struct snd_dbri { | |||
| 341 | /* DBRI Reg1 - Mode and Interrupt Register - defines. (Page 18) */ | 339 | /* DBRI Reg1 - Mode and Interrupt Register - defines. (Page 18) */ |
| 342 | #define D_LITTLE_END (1<<8) /* Byte Order */ | 340 | #define D_LITTLE_END (1<<8) /* Byte Order */ |
| 343 | #define D_BIG_END (0<<8) /* Byte Order */ | 341 | #define D_BIG_END (0<<8) /* Byte Order */ |
| 344 | #define D_MRR (1<<4) /* Multiple Error Ack on SBus (readonly) */ | 342 | #define D_MRR (1<<4) /* Multiple Error Ack on SBus (read only) */ |
| 345 | #define D_MLE (1<<3) /* Multiple Late Error on SBus (readonly) */ | 343 | #define D_MLE (1<<3) /* Multiple Late Error on SBus (read only) */ |
| 346 | #define D_LBG (1<<2) /* Lost Bus Grant on SBus (readonly) */ | 344 | #define D_LBG (1<<2) /* Lost Bus Grant on SBus (read only) */ |
| 347 | #define D_MBE (1<<1) /* Burst Error on SBus (readonly) */ | 345 | #define D_MBE (1<<1) /* Burst Error on SBus (read only) */ |
| 348 | #define D_IR (1<<0) /* Interrupt Indicator (readonly) */ | 346 | #define D_IR (1<<0) /* Interrupt Indicator (read only) */ |
| 349 | 347 | ||
| 350 | /* DBRI Reg2 - Parallel IO Register - defines. (Page 18) */ | 348 | /* DBRI Reg2 - Parallel IO Register - defines. (Page 18) */ |
| 351 | #define D_ENPIO3 (1<<7) /* Enable Pin 3 */ | 349 | #define D_ENPIO3 (1<<7) /* Enable Pin 3 */ |
| @@ -376,11 +374,11 @@ struct snd_dbri { | |||
| 376 | #define D_CDM 0xe /* CHI Data mode command */ | 374 | #define D_CDM 0xe /* CHI Data mode command */ |
| 377 | 375 | ||
| 378 | /* Special bits for some commands */ | 376 | /* Special bits for some commands */ |
| 379 | #define D_PIPE(v) ((v)<<0) /* Pipe Nr: 0-15 long, 16-21 short */ | 377 | #define D_PIPE(v) ((v)<<0) /* Pipe No.: 0-15 long, 16-21 short */ |
| 380 | 378 | ||
| 381 | /* Setup Data Pipe */ | 379 | /* Setup Data Pipe */ |
| 382 | /* IRM */ | 380 | /* IRM */ |
| 383 | #define D_SDP_2SAME (1<<18) /* Report 2nd time in a row value rcvd */ | 381 | #define D_SDP_2SAME (1<<18) /* Report 2nd time in a row value received */ |
| 384 | #define D_SDP_CHANGE (2<<18) /* Report any changes */ | 382 | #define D_SDP_CHANGE (2<<18) /* Report any changes */ |
| 385 | #define D_SDP_EVERY (3<<18) /* Report any changes */ | 383 | #define D_SDP_EVERY (3<<18) /* Report any changes */ |
| 386 | #define D_SDP_EOL (1<<17) /* EOL interrupt enable */ | 384 | #define D_SDP_EOL (1<<17) /* EOL interrupt enable */ |
| @@ -419,7 +417,7 @@ struct snd_dbri { | |||
| 419 | #define D_TS_NONCONTIG (3<<10) /* Non contiguous mode */ | 417 | #define D_TS_NONCONTIG (3<<10) /* Non contiguous mode */ |
| 420 | #define D_TS_ANCHOR (7<<10) /* Starting short pipes */ | 418 | #define D_TS_ANCHOR (7<<10) /* Starting short pipes */ |
| 421 | #define D_TS_MON(v) ((v)<<5) /* Monitor Pipe */ | 419 | #define D_TS_MON(v) ((v)<<5) /* Monitor Pipe */ |
| 422 | #define D_TS_NEXT(v) ((v)<<0) /* Pipe Nr: 0-15 long, 16-21 short */ | 420 | #define D_TS_NEXT(v) ((v)<<0) /* Pipe no.: 0-15 long, 16-21 short */ |
| 423 | 421 | ||
| 424 | /* Concentration Highway Interface Modes */ | 422 | /* Concentration Highway Interface Modes */ |
| 425 | #define D_CHI_CHICM(v) ((v)<<16) /* Clock mode */ | 423 | #define D_CHI_CHICM(v) ((v)<<16) /* Clock mode */ |
| @@ -435,7 +433,7 @@ struct snd_dbri { | |||
| 435 | #define D_NT_NBF (1<<16) /* Number of bad frames to loose framing */ | 433 | #define D_NT_NBF (1<<16) /* Number of bad frames to loose framing */ |
| 436 | #define D_NT_IRM_IMM (1<<15) /* Interrupt Report & Mask: Immediate */ | 434 | #define D_NT_IRM_IMM (1<<15) /* Interrupt Report & Mask: Immediate */ |
| 437 | #define D_NT_IRM_EN (1<<14) /* Interrupt Report & Mask: Enable */ | 435 | #define D_NT_IRM_EN (1<<14) /* Interrupt Report & Mask: Enable */ |
| 438 | #define D_NT_ISNT (1<<13) /* Configfure interface as NT */ | 436 | #define D_NT_ISNT (1<<13) /* Configure interface as NT */ |
| 439 | #define D_NT_FT (1<<12) /* Fixed Timing */ | 437 | #define D_NT_FT (1<<12) /* Fixed Timing */ |
| 440 | #define D_NT_EZ (1<<11) /* Echo Channel is Zeros */ | 438 | #define D_NT_EZ (1<<11) /* Echo Channel is Zeros */ |
| 441 | #define D_NT_IFA (1<<10) /* Inhibit Final Activation */ | 439 | #define D_NT_IFA (1<<10) /* Inhibit Final Activation */ |
| @@ -455,7 +453,7 @@ struct snd_dbri { | |||
| 455 | #define D_TEST_RAM(v) ((v)<<16) /* RAM Pointer */ | 453 | #define D_TEST_RAM(v) ((v)<<16) /* RAM Pointer */ |
| 456 | #define D_TEST_SIZE(v) ((v)<<11) /* */ | 454 | #define D_TEST_SIZE(v) ((v)<<11) /* */ |
| 457 | #define D_TEST_ROMONOFF 0x5 /* Toggle ROM opcode monitor on/off */ | 455 | #define D_TEST_ROMONOFF 0x5 /* Toggle ROM opcode monitor on/off */ |
| 458 | #define D_TEST_PROC 0x6 /* MicroProcessor test */ | 456 | #define D_TEST_PROC 0x6 /* Microprocessor test */ |
| 459 | #define D_TEST_SER 0x7 /* Serial-Controller test */ | 457 | #define D_TEST_SER 0x7 /* Serial-Controller test */ |
| 460 | #define D_TEST_RAMREAD 0x8 /* Copy from Ram to system memory */ | 458 | #define D_TEST_RAMREAD 0x8 /* Copy from Ram to system memory */ |
| 461 | #define D_TEST_RAMWRITE 0x9 /* Copy into Ram from system memory */ | 459 | #define D_TEST_RAMWRITE 0x9 /* Copy into Ram from system memory */ |
| @@ -464,12 +462,12 @@ struct snd_dbri { | |||
| 464 | #define D_TEST_DUMP 0xe /* ROM Dump */ | 462 | #define D_TEST_DUMP 0xe /* ROM Dump */ |
| 465 | 463 | ||
| 466 | /* CHI Data Mode */ | 464 | /* CHI Data Mode */ |
| 467 | #define D_CDM_THI (1<<8) /* Transmit Data on CHIDR Pin */ | 465 | #define D_CDM_THI (1 << 8) /* Transmit Data on CHIDR Pin */ |
| 468 | #define D_CDM_RHI (1<<7) /* Receive Data on CHIDX Pin */ | 466 | #define D_CDM_RHI (1 << 7) /* Receive Data on CHIDX Pin */ |
| 469 | #define D_CDM_RCE (1<<6) /* Receive on Rising Edge of CHICK */ | 467 | #define D_CDM_RCE (1 << 6) /* Receive on Rising Edge of CHICK */ |
| 470 | #define D_CDM_XCE (1<<2) /* Transmit Data on Rising Edge of CHICK */ | 468 | #define D_CDM_XCE (1 << 2) /* Transmit Data on Rising Edge of CHICK */ |
| 471 | #define D_CDM_XEN (1<<1) /* Transmit Highway Enable */ | 469 | #define D_CDM_XEN (1 << 1) /* Transmit Highway Enable */ |
| 472 | #define D_CDM_REN (1<<0) /* Receive Highway Enable */ | 470 | #define D_CDM_REN (1 << 0) /* Receive Highway Enable */ |
| 473 | 471 | ||
| 474 | /* The Interrupts */ | 472 | /* The Interrupts */ |
| 475 | #define D_INTR_BRDY 1 /* Buffer Ready for processing */ | 473 | #define D_INTR_BRDY 1 /* Buffer Ready for processing */ |
| @@ -493,9 +491,9 @@ struct snd_dbri { | |||
| 493 | #define D_INTR_CHI 36 | 491 | #define D_INTR_CHI 36 |
| 494 | #define D_INTR_CMD 38 | 492 | #define D_INTR_CMD 38 |
| 495 | 493 | ||
| 496 | #define D_INTR_GETCHAN(v) (((v)>>24) & 0x3f) | 494 | #define D_INTR_GETCHAN(v) (((v) >> 24) & 0x3f) |
| 497 | #define D_INTR_GETCODE(v) (((v)>>20) & 0xf) | 495 | #define D_INTR_GETCODE(v) (((v) >> 20) & 0xf) |
| 498 | #define D_INTR_GETCMD(v) (((v)>>16) & 0xf) | 496 | #define D_INTR_GETCMD(v) (((v) >> 16) & 0xf) |
| 499 | #define D_INTR_GETVAL(v) ((v) & 0xffff) | 497 | #define D_INTR_GETVAL(v) ((v) & 0xffff) |
| 500 | #define D_INTR_GETRVAL(v) ((v) & 0xfffff) | 498 | #define D_INTR_GETRVAL(v) ((v) & 0xfffff) |
| 501 | 499 | ||
| @@ -533,43 +531,42 @@ struct snd_dbri { | |||
| 533 | #define D_P_31 31 /* */ | 531 | #define D_P_31 31 /* */ |
| 534 | 532 | ||
| 535 | /* Transmit descriptor defines */ | 533 | /* Transmit descriptor defines */ |
| 536 | #define DBRI_TD_F (1<<31) /* End of Frame */ | 534 | #define DBRI_TD_F (1 << 31) /* End of Frame */ |
| 537 | #define DBRI_TD_D (1<<30) /* Do not append CRC */ | 535 | #define DBRI_TD_D (1 << 30) /* Do not append CRC */ |
| 538 | #define DBRI_TD_CNT(v) ((v)<<16) /* Number of valid bytes in the buffer */ | 536 | #define DBRI_TD_CNT(v) ((v) << 16) /* Number of valid bytes in the buffer */ |
| 539 | #define DBRI_TD_B (1<<15) /* Final interrupt */ | 537 | #define DBRI_TD_B (1 << 15) /* Final interrupt */ |
| 540 | #define DBRI_TD_M (1<<14) /* Marker interrupt */ | 538 | #define DBRI_TD_M (1 << 14) /* Marker interrupt */ |
| 541 | #define DBRI_TD_I (1<<13) /* Transmit Idle Characters */ | 539 | #define DBRI_TD_I (1 << 13) /* Transmit Idle Characters */ |
| 542 | #define DBRI_TD_FCNT(v) (v) /* Flag Count */ | 540 | #define DBRI_TD_FCNT(v) (v) /* Flag Count */ |
| 543 | #define DBRI_TD_UNR (1<<3) /* Underrun: transmitter is out of data */ | 541 | #define DBRI_TD_UNR (1 << 3) /* Underrun: transmitter is out of data */ |
| 544 | #define DBRI_TD_ABT (1<<2) /* Abort: frame aborted */ | 542 | #define DBRI_TD_ABT (1 << 2) /* Abort: frame aborted */ |
| 545 | #define DBRI_TD_TBC (1<<0) /* Transmit buffer Complete */ | 543 | #define DBRI_TD_TBC (1 << 0) /* Transmit buffer Complete */ |
| 546 | #define DBRI_TD_STATUS(v) ((v)&0xff) /* Transmit status */ | 544 | #define DBRI_TD_STATUS(v) ((v) & 0xff) /* Transmit status */ |
| 547 | /* Maximum buffer size per TD: almost 8Kb */ | 545 | /* Maximum buffer size per TD: almost 8KB */ |
| 548 | #define DBRI_TD_MAXCNT ((1 << 13) - 4) | 546 | #define DBRI_TD_MAXCNT ((1 << 13) - 4) |
| 549 | 547 | ||
| 550 | /* Receive descriptor defines */ | 548 | /* Receive descriptor defines */ |
| 551 | #define DBRI_RD_F (1<<31) /* End of Frame */ | 549 | #define DBRI_RD_F (1 << 31) /* End of Frame */ |
| 552 | #define DBRI_RD_C (1<<30) /* Completed buffer */ | 550 | #define DBRI_RD_C (1 << 30) /* Completed buffer */ |
| 553 | #define DBRI_RD_B (1<<15) /* Final interrupt */ | 551 | #define DBRI_RD_B (1 << 15) /* Final interrupt */ |
| 554 | #define DBRI_RD_M (1<<14) /* Marker interrupt */ | 552 | #define DBRI_RD_M (1 << 14) /* Marker interrupt */ |
| 555 | #define DBRI_RD_BCNT(v) (v) /* Buffer size */ | 553 | #define DBRI_RD_BCNT(v) (v) /* Buffer size */ |
| 556 | #define DBRI_RD_CRC (1<<7) /* 0: CRC is correct */ | 554 | #define DBRI_RD_CRC (1 << 7) /* 0: CRC is correct */ |
| 557 | #define DBRI_RD_BBC (1<<6) /* 1: Bad Byte received */ | 555 | #define DBRI_RD_BBC (1 << 6) /* 1: Bad Byte received */ |
| 558 | #define DBRI_RD_ABT (1<<5) /* Abort: frame aborted */ | 556 | #define DBRI_RD_ABT (1 << 5) /* Abort: frame aborted */ |
| 559 | #define DBRI_RD_OVRN (1<<3) /* Overrun: data lost */ | 557 | #define DBRI_RD_OVRN (1 << 3) /* Overrun: data lost */ |
| 560 | #define DBRI_RD_STATUS(v) ((v)&0xff) /* Receive status */ | 558 | #define DBRI_RD_STATUS(v) ((v) & 0xff) /* Receive status */ |
| 561 | #define DBRI_RD_CNT(v) (((v)>>16)&0x1fff) /* Valid bytes in the buffer */ | 559 | #define DBRI_RD_CNT(v) (((v) >> 16) & 0x1fff) /* Valid bytes in the buffer */ |
| 562 | 560 | ||
| 563 | /* stream_info[] access */ | 561 | /* stream_info[] access */ |
| 564 | /* Translate the ALSA direction into the array index */ | 562 | /* Translate the ALSA direction into the array index */ |
| 565 | #define DBRI_STREAMNO(substream) \ | 563 | #define DBRI_STREAMNO(substream) \ |
| 566 | (substream->stream == \ | 564 | (substream->stream == \ |
| 567 | SNDRV_PCM_STREAM_PLAYBACK? DBRI_PLAY: DBRI_REC) | 565 | SNDRV_PCM_STREAM_PLAYBACK ? DBRI_PLAY: DBRI_REC) |
| 568 | 566 | ||
| 569 | /* Return a pointer to dbri_streaminfo */ | 567 | /* Return a pointer to dbri_streaminfo */ |
| 570 | #define DBRI_STREAM(dbri, substream) &dbri->stream_info[DBRI_STREAMNO(substream)] | 568 | #define DBRI_STREAM(dbri, substream) \ |
| 571 | 569 | &dbri->stream_info[DBRI_STREAMNO(substream)] | |
| 572 | static struct snd_dbri *dbri_list; /* All DBRI devices */ | ||
| 573 | 570 | ||
| 574 | /* | 571 | /* |
| 575 | * Short data pipes transmit LSB first. The CS4215 receives MSB first. Grrr. | 572 | * Short data pipes transmit LSB first. The CS4215 receives MSB first. Grrr. |
| @@ -609,21 +606,21 @@ The list is terminated with a WAIT command, which generates a | |||
| 609 | CPU interrupt to signal completion. | 606 | CPU interrupt to signal completion. |
| 610 | 607 | ||
| 611 | Since the DBRI can run in parallel with the CPU, several means of | 608 | Since the DBRI can run in parallel with the CPU, several means of |
| 612 | synchronization present themselves. The method implemented here is only | 609 | synchronization present themselves. The method implemented here uses |
| 613 | use of the dbri_cmdwait() to wait for execution of batch of sent commands. | 610 | the dbri_cmdwait() to wait for execution of batch of sent commands. |
| 614 | 611 | ||
| 615 | A circular command buffer is used here. A new command is being added | 612 | A circular command buffer is used here. A new command is being added |
| 616 | while another can be executed. The scheme works by adding two WAIT commands | 613 | while another can be executed. The scheme works by adding two WAIT commands |
| 617 | after each sent batch of commands. When the next batch is prepared it is | 614 | after each sent batch of commands. When the next batch is prepared it is |
| 618 | added after the WAIT commands then the WAITs are replaced with single JUMP | 615 | added after the WAIT commands then the WAITs are replaced with single JUMP |
| 619 | command to the new batch. The the DBRI is forced to reread the last WAIT | 616 | command to the new batch. The the DBRI is forced to reread the last WAIT |
| 620 | command (replaced by the JUMP by then). If the DBRI is still executing | 617 | command (replaced by the JUMP by then). If the DBRI is still executing |
| 621 | previous commands the request to reread the WAIT command is ignored. | 618 | previous commands the request to reread the WAIT command is ignored. |
| 622 | 619 | ||
| 623 | Every time a routine wants to write commands to the DBRI, it must | 620 | Every time a routine wants to write commands to the DBRI, it must |
| 624 | first call dbri_cmdlock() and get pointer to a free space in | 621 | first call dbri_cmdlock() and get pointer to a free space in |
| 625 | dbri->dma->cmd buffer. After this, the commands can be written to | 622 | dbri->dma->cmd buffer. After this, the commands can be written to |
| 626 | the buffer, and dbri_cmdsend() is called with the final pointer value | 623 | the buffer, and dbri_cmdsend() is called with the final pointer value |
| 627 | to send them to the DBRI. | 624 | to send them to the DBRI. |
| 628 | 625 | ||
| 629 | */ | 626 | */ |
| @@ -646,18 +643,17 @@ static void dbri_cmdwait(struct snd_dbri *dbri) | |||
| 646 | } | 643 | } |
| 647 | spin_unlock_irqrestore(&dbri->lock, flags); | 644 | spin_unlock_irqrestore(&dbri->lock, flags); |
| 648 | 645 | ||
| 649 | if (maxloops == 0) { | 646 | if (maxloops == 0) |
| 650 | printk(KERN_ERR "DBRI: Chip never completed command buffer\n"); | 647 | printk(KERN_ERR "DBRI: Chip never completed command buffer\n"); |
| 651 | } else { | 648 | else |
| 652 | dprintk(D_CMD, "Chip completed command buffer (%d)\n", | 649 | dprintk(D_CMD, "Chip completed command buffer (%d)\n", |
| 653 | MAXLOOPS - maxloops - 1); | 650 | MAXLOOPS - maxloops - 1); |
| 654 | } | ||
| 655 | } | 651 | } |
| 656 | /* | 652 | /* |
| 657 | * Lock the command queue and returns pointer to a space for len cmd words | 653 | * Lock the command queue and return pointer to space for len cmd words |
| 658 | * It locks the cmdlock spinlock. | 654 | * It locks the cmdlock spinlock. |
| 659 | */ | 655 | */ |
| 660 | static s32 *dbri_cmdlock(struct snd_dbri * dbri, int len) | 656 | static s32 *dbri_cmdlock(struct snd_dbri *dbri, int len) |
| 661 | { | 657 | { |
| 662 | /* Space for 2 WAIT cmds (replaced later by 1 JUMP cmd) */ | 658 | /* Space for 2 WAIT cmds (replaced later by 1 JUMP cmd) */ |
| 663 | len += 2; | 659 | len += 2; |
| @@ -680,7 +676,7 @@ static s32 *dbri_cmdlock(struct snd_dbri * dbri, int len) | |||
| 680 | * | 676 | * |
| 681 | * Lock must be held before calling this. | 677 | * Lock must be held before calling this. |
| 682 | */ | 678 | */ |
| 683 | static void dbri_cmdsend(struct snd_dbri * dbri, s32 * cmd,int len) | 679 | static void dbri_cmdsend(struct snd_dbri *dbri, s32 *cmd, int len) |
| 684 | { | 680 | { |
| 685 | s32 tmp, addr; | 681 | s32 tmp, addr; |
| 686 | static int wait_id = 0; | 682 | static int wait_id = 0; |
| @@ -700,16 +696,17 @@ static void dbri_cmdsend(struct snd_dbri * dbri, s32 * cmd,int len) | |||
| 700 | s32 *ptr; | 696 | s32 *ptr; |
| 701 | 697 | ||
| 702 | for (ptr = dbri->cmdptr; ptr < cmd+2; ptr++) | 698 | for (ptr = dbri->cmdptr; ptr < cmd+2; ptr++) |
| 703 | dprintk(D_CMD, "cmd: %lx:%08x\n", (unsigned long)ptr, *ptr); | 699 | dprintk(D_CMD, "cmd: %lx:%08x\n", |
| 700 | (unsigned long)ptr, *ptr); | ||
| 704 | } else { | 701 | } else { |
| 705 | s32 *ptr = dbri->cmdptr; | 702 | s32 *ptr = dbri->cmdptr; |
| 706 | 703 | ||
| 707 | dprintk(D_CMD, "cmd: %lx:%08x\n", (unsigned long)ptr, *ptr); | 704 | dprintk(D_CMD, "cmd: %lx:%08x\n", (unsigned long)ptr, *ptr); |
| 708 | ptr++; | 705 | ptr++; |
| 709 | dprintk(D_CMD, "cmd: %lx:%08x\n", (unsigned long)ptr, *ptr); | 706 | dprintk(D_CMD, "cmd: %lx:%08x\n", (unsigned long)ptr, *ptr); |
| 710 | for (ptr = dbri->dma->cmd; ptr < cmd+2; ptr++) { | 707 | for (ptr = dbri->dma->cmd; ptr < cmd+2; ptr++) |
| 711 | dprintk(D_CMD, "cmd: %lx:%08x\n", (unsigned long)ptr, *ptr); | 708 | dprintk(D_CMD, "cmd: %lx:%08x\n", |
| 712 | } | 709 | (unsigned long)ptr, *ptr); |
| 713 | } | 710 | } |
| 714 | #endif | 711 | #endif |
| 715 | 712 | ||
| @@ -723,7 +720,7 @@ static void dbri_cmdsend(struct snd_dbri * dbri, s32 * cmd,int len) | |||
| 723 | } | 720 | } |
| 724 | 721 | ||
| 725 | /* Lock must be held when calling this */ | 722 | /* Lock must be held when calling this */ |
| 726 | static void dbri_reset(struct snd_dbri * dbri) | 723 | static void dbri_reset(struct snd_dbri *dbri) |
| 727 | { | 724 | { |
| 728 | int i; | 725 | int i; |
| 729 | u32 tmp; | 726 | u32 tmp; |
| @@ -746,7 +743,7 @@ static void dbri_reset(struct snd_dbri * dbri) | |||
| 746 | } | 743 | } |
| 747 | 744 | ||
| 748 | /* Lock must not be held before calling this */ | 745 | /* Lock must not be held before calling this */ |
| 749 | static void dbri_initialize(struct snd_dbri * dbri) | 746 | static void __devinit dbri_initialize(struct snd_dbri *dbri) |
| 750 | { | 747 | { |
| 751 | s32 *cmd; | 748 | s32 *cmd; |
| 752 | u32 dma_addr; | 749 | u32 dma_addr; |
| @@ -763,7 +760,7 @@ static void dbri_initialize(struct snd_dbri * dbri) | |||
| 763 | 760 | ||
| 764 | spin_lock_init(&dbri->cmdlock); | 761 | spin_lock_init(&dbri->cmdlock); |
| 765 | /* | 762 | /* |
| 766 | * Initialize the interrupt ringbuffer. | 763 | * Initialize the interrupt ring buffer. |
| 767 | */ | 764 | */ |
| 768 | dma_addr = dbri->dma_dvma + dbri_dma_off(intr, 0); | 765 | dma_addr = dbri->dma_dvma + dbri_dma_off(intr, 0); |
| 769 | dbri->dma->intr[0] = dma_addr; | 766 | dbri->dma->intr[0] = dma_addr; |
| @@ -801,7 +798,7 @@ list ordering, among other things. The transmit and receive functions | |||
| 801 | here interface closely with the transmit and receive interrupt code. | 798 | here interface closely with the transmit and receive interrupt code. |
| 802 | 799 | ||
| 803 | */ | 800 | */ |
| 804 | static int pipe_active(struct snd_dbri * dbri, int pipe) | 801 | static inline int pipe_active(struct snd_dbri *dbri, int pipe) |
| 805 | { | 802 | { |
| 806 | return ((pipe >= 0) && (dbri->pipes[pipe].desc != -1)); | 803 | return ((pipe >= 0) && (dbri->pipes[pipe].desc != -1)); |
| 807 | } | 804 | } |
| @@ -811,20 +808,22 @@ static int pipe_active(struct snd_dbri * dbri, int pipe) | |||
| 811 | * Called on an in-use pipe to clear anything being transmitted or received | 808 | * Called on an in-use pipe to clear anything being transmitted or received |
| 812 | * Lock must be held before calling this. | 809 | * Lock must be held before calling this. |
| 813 | */ | 810 | */ |
| 814 | static void reset_pipe(struct snd_dbri * dbri, int pipe) | 811 | static void reset_pipe(struct snd_dbri *dbri, int pipe) |
| 815 | { | 812 | { |
| 816 | int sdp; | 813 | int sdp; |
| 817 | int desc; | 814 | int desc; |
| 818 | s32 *cmd; | 815 | s32 *cmd; |
| 819 | 816 | ||
| 820 | if (pipe < 0 || pipe > DBRI_MAX_PIPE) { | 817 | if (pipe < 0 || pipe > DBRI_MAX_PIPE) { |
| 821 | printk(KERN_ERR "DBRI: reset_pipe called with illegal pipe number\n"); | 818 | printk(KERN_ERR "DBRI: reset_pipe called with " |
| 819 | "illegal pipe number\n"); | ||
| 822 | return; | 820 | return; |
| 823 | } | 821 | } |
| 824 | 822 | ||
| 825 | sdp = dbri->pipes[pipe].sdp; | 823 | sdp = dbri->pipes[pipe].sdp; |
| 826 | if (sdp == 0) { | 824 | if (sdp == 0) { |
| 827 | printk(KERN_ERR "DBRI: reset_pipe called on uninitialized pipe\n"); | 825 | printk(KERN_ERR "DBRI: reset_pipe called " |
| 826 | "on uninitialized pipe\n"); | ||
| 828 | return; | 827 | return; |
| 829 | } | 828 | } |
| 830 | 829 | ||
| @@ -835,9 +834,10 @@ static void reset_pipe(struct snd_dbri * dbri, int pipe) | |||
| 835 | dbri_cmdsend(dbri, cmd, 3); | 834 | dbri_cmdsend(dbri, cmd, 3); |
| 836 | 835 | ||
| 837 | desc = dbri->pipes[pipe].first_desc; | 836 | desc = dbri->pipes[pipe].first_desc; |
| 838 | if ( desc >= 0) | 837 | if (desc >= 0) |
| 839 | do { | 838 | do { |
| 840 | dbri->dma->desc[desc].nda = dbri->dma->desc[desc].ba = 0; | 839 | dbri->dma->desc[desc].ba = 0; |
| 840 | dbri->dma->desc[desc].nda = 0; | ||
| 841 | desc = dbri->next_desc[desc]; | 841 | desc = dbri->next_desc[desc]; |
| 842 | } while (desc != -1 && desc != dbri->pipes[pipe].first_desc); | 842 | } while (desc != -1 && desc != dbri->pipes[pipe].first_desc); |
| 843 | 843 | ||
| @@ -848,15 +848,17 @@ static void reset_pipe(struct snd_dbri * dbri, int pipe) | |||
| 848 | /* | 848 | /* |
| 849 | * Lock must be held before calling this. | 849 | * Lock must be held before calling this. |
| 850 | */ | 850 | */ |
| 851 | static void setup_pipe(struct snd_dbri * dbri, int pipe, int sdp) | 851 | static void setup_pipe(struct snd_dbri *dbri, int pipe, int sdp) |
| 852 | { | 852 | { |
| 853 | if (pipe < 0 || pipe > DBRI_MAX_PIPE) { | 853 | if (pipe < 0 || pipe > DBRI_MAX_PIPE) { |
| 854 | printk(KERN_ERR "DBRI: setup_pipe called with illegal pipe number\n"); | 854 | printk(KERN_ERR "DBRI: setup_pipe called " |
| 855 | "with illegal pipe number\n"); | ||
| 855 | return; | 856 | return; |
| 856 | } | 857 | } |
| 857 | 858 | ||
| 858 | if ((sdp & 0xf800) != sdp) { | 859 | if ((sdp & 0xf800) != sdp) { |
| 859 | printk(KERN_ERR "DBRI: setup_pipe called with strange SDP value\n"); | 860 | printk(KERN_ERR "DBRI: setup_pipe called " |
| 861 | "with strange SDP value\n"); | ||
| 860 | /* sdp &= 0xf800; */ | 862 | /* sdp &= 0xf800; */ |
| 861 | } | 863 | } |
| 862 | 864 | ||
| @@ -877,25 +879,26 @@ static void setup_pipe(struct snd_dbri * dbri, int pipe, int sdp) | |||
| 877 | /* | 879 | /* |
| 878 | * Lock must be held before calling this. | 880 | * Lock must be held before calling this. |
| 879 | */ | 881 | */ |
| 880 | static void link_time_slot(struct snd_dbri * dbri, int pipe, | 882 | static void link_time_slot(struct snd_dbri *dbri, int pipe, |
| 881 | int prevpipe, int nextpipe, | 883 | int prevpipe, int nextpipe, |
| 882 | int length, int cycle) | 884 | int length, int cycle) |
| 883 | { | 885 | { |
| 884 | s32 *cmd; | 886 | s32 *cmd; |
| 885 | int val; | 887 | int val; |
| 886 | 888 | ||
| 887 | if (pipe < 0 || pipe > DBRI_MAX_PIPE | 889 | if (pipe < 0 || pipe > DBRI_MAX_PIPE |
| 888 | || prevpipe < 0 || prevpipe > DBRI_MAX_PIPE | 890 | || prevpipe < 0 || prevpipe > DBRI_MAX_PIPE |
| 889 | || nextpipe < 0 || nextpipe > DBRI_MAX_PIPE) { | 891 | || nextpipe < 0 || nextpipe > DBRI_MAX_PIPE) { |
| 890 | printk(KERN_ERR | 892 | printk(KERN_ERR |
| 891 | "DBRI: link_time_slot called with illegal pipe number\n"); | 893 | "DBRI: link_time_slot called with illegal pipe number\n"); |
| 892 | return; | 894 | return; |
| 893 | } | 895 | } |
| 894 | 896 | ||
| 895 | if (dbri->pipes[pipe].sdp == 0 | 897 | if (dbri->pipes[pipe].sdp == 0 |
| 896 | || dbri->pipes[prevpipe].sdp == 0 | 898 | || dbri->pipes[prevpipe].sdp == 0 |
| 897 | || dbri->pipes[nextpipe].sdp == 0) { | 899 | || dbri->pipes[nextpipe].sdp == 0) { |
| 898 | printk(KERN_ERR "DBRI: link_time_slot called on uninitialized pipe\n"); | 900 | printk(KERN_ERR "DBRI: link_time_slot called " |
| 901 | "on uninitialized pipe\n"); | ||
| 899 | return; | 902 | return; |
| 900 | } | 903 | } |
| 901 | 904 | ||
| @@ -935,17 +938,17 @@ static void link_time_slot(struct snd_dbri * dbri, int pipe, | |||
| 935 | /* | 938 | /* |
| 936 | * Lock must be held before calling this. | 939 | * Lock must be held before calling this. |
| 937 | */ | 940 | */ |
| 938 | static void unlink_time_slot(struct snd_dbri * dbri, int pipe, | 941 | static void unlink_time_slot(struct snd_dbri *dbri, int pipe, |
| 939 | enum in_or_out direction, int prevpipe, | 942 | enum in_or_out direction, int prevpipe, |
| 940 | int nextpipe) | 943 | int nextpipe) |
| 941 | { | 944 | { |
| 942 | s32 *cmd; | 945 | s32 *cmd; |
| 943 | int val; | 946 | int val; |
| 944 | 947 | ||
| 945 | if (pipe < 0 || pipe > DBRI_MAX_PIPE | 948 | if (pipe < 0 || pipe > DBRI_MAX_PIPE |
| 946 | || prevpipe < 0 || prevpipe > DBRI_MAX_PIPE | 949 | || prevpipe < 0 || prevpipe > DBRI_MAX_PIPE |
| 947 | || nextpipe < 0 || nextpipe > DBRI_MAX_PIPE) { | 950 | || nextpipe < 0 || nextpipe > DBRI_MAX_PIPE) { |
| 948 | printk(KERN_ERR | 951 | printk(KERN_ERR |
| 949 | "DBRI: unlink_time_slot called with illegal pipe number\n"); | 952 | "DBRI: unlink_time_slot called with illegal pipe number\n"); |
| 950 | return; | 953 | return; |
| 951 | } | 954 | } |
| @@ -985,7 +988,7 @@ static void unlink_time_slot(struct snd_dbri * dbri, int pipe, | |||
| 985 | * | 988 | * |
| 986 | * Lock must not be held before calling it. | 989 | * Lock must not be held before calling it. |
| 987 | */ | 990 | */ |
| 988 | static void xmit_fixed(struct snd_dbri * dbri, int pipe, unsigned int data) | 991 | static void xmit_fixed(struct snd_dbri *dbri, int pipe, unsigned int data) |
| 989 | { | 992 | { |
| 990 | s32 *cmd; | 993 | s32 *cmd; |
| 991 | unsigned long flags; | 994 | unsigned long flags; |
| @@ -996,7 +999,8 @@ static void xmit_fixed(struct snd_dbri * dbri, int pipe, unsigned int data) | |||
| 996 | } | 999 | } |
| 997 | 1000 | ||
| 998 | if (D_SDP_MODE(dbri->pipes[pipe].sdp) == 0) { | 1001 | if (D_SDP_MODE(dbri->pipes[pipe].sdp) == 0) { |
| 999 | printk(KERN_ERR "DBRI: xmit_fixed: Uninitialized pipe %d\n", pipe); | 1002 | printk(KERN_ERR "DBRI: xmit_fixed: " |
| 1003 | "Uninitialized pipe %d\n", pipe); | ||
| 1000 | return; | 1004 | return; |
| 1001 | } | 1005 | } |
| 1002 | 1006 | ||
| @@ -1006,7 +1010,8 @@ static void xmit_fixed(struct snd_dbri * dbri, int pipe, unsigned int data) | |||
| 1006 | } | 1010 | } |
| 1007 | 1011 | ||
| 1008 | if (!(dbri->pipes[pipe].sdp & D_SDP_TO_SER)) { | 1012 | if (!(dbri->pipes[pipe].sdp & D_SDP_TO_SER)) { |
| 1009 | printk(KERN_ERR "DBRI: xmit_fixed: Called on receive pipe %d\n", pipe); | 1013 | printk(KERN_ERR "DBRI: xmit_fixed: Called on receive pipe %d\n", |
| 1014 | pipe); | ||
| 1010 | return; | 1015 | return; |
| 1011 | } | 1016 | } |
| 1012 | 1017 | ||
| @@ -1028,20 +1033,23 @@ static void xmit_fixed(struct snd_dbri * dbri, int pipe, unsigned int data) | |||
| 1028 | 1033 | ||
| 1029 | } | 1034 | } |
| 1030 | 1035 | ||
| 1031 | static void recv_fixed(struct snd_dbri * dbri, int pipe, volatile __u32 * ptr) | 1036 | static void recv_fixed(struct snd_dbri *dbri, int pipe, volatile __u32 *ptr) |
| 1032 | { | 1037 | { |
| 1033 | if (pipe < 16 || pipe > DBRI_MAX_PIPE) { | 1038 | if (pipe < 16 || pipe > DBRI_MAX_PIPE) { |
| 1034 | printk(KERN_ERR "DBRI: recv_fixed called with illegal pipe number\n"); | 1039 | printk(KERN_ERR "DBRI: recv_fixed called with " |
| 1040 | "illegal pipe number\n"); | ||
| 1035 | return; | 1041 | return; |
| 1036 | } | 1042 | } |
| 1037 | 1043 | ||
| 1038 | if (D_SDP_MODE(dbri->pipes[pipe].sdp) != D_SDP_FIXED) { | 1044 | if (D_SDP_MODE(dbri->pipes[pipe].sdp) != D_SDP_FIXED) { |
| 1039 | printk(KERN_ERR "DBRI: recv_fixed called on non-fixed pipe %d\n", pipe); | 1045 | printk(KERN_ERR "DBRI: recv_fixed called on " |
| 1046 | "non-fixed pipe %d\n", pipe); | ||
| 1040 | return; | 1047 | return; |
| 1041 | } | 1048 | } |
| 1042 | 1049 | ||
| 1043 | if (dbri->pipes[pipe].sdp & D_SDP_TO_SER) { | 1050 | if (dbri->pipes[pipe].sdp & D_SDP_TO_SER) { |
| 1044 | printk(KERN_ERR "DBRI: recv_fixed called on transmit pipe %d\n", pipe); | 1051 | printk(KERN_ERR "DBRI: recv_fixed called on " |
| 1052 | "transmit pipe %d\n", pipe); | ||
| 1045 | return; | 1053 | return; |
| 1046 | } | 1054 | } |
| 1047 | 1055 | ||
| @@ -1064,7 +1072,7 @@ static void recv_fixed(struct snd_dbri * dbri, int pipe, volatile __u32 * ptr) | |||
| 1064 | * | 1072 | * |
| 1065 | * Lock must be held before calling this. | 1073 | * Lock must be held before calling this. |
| 1066 | */ | 1074 | */ |
| 1067 | static int setup_descs(struct snd_dbri * dbri, int streamno, unsigned int period) | 1075 | static int setup_descs(struct snd_dbri *dbri, int streamno, unsigned int period) |
| 1068 | { | 1076 | { |
| 1069 | struct dbri_streaminfo *info = &dbri->stream_info[streamno]; | 1077 | struct dbri_streaminfo *info = &dbri->stream_info[streamno]; |
| 1070 | __u32 dvma_buffer; | 1078 | __u32 dvma_buffer; |
| @@ -1089,21 +1097,23 @@ static int setup_descs(struct snd_dbri * dbri, int streamno, unsigned int period | |||
| 1089 | 1097 | ||
| 1090 | if (streamno == DBRI_PLAY) { | 1098 | if (streamno == DBRI_PLAY) { |
| 1091 | if (!(dbri->pipes[info->pipe].sdp & D_SDP_TO_SER)) { | 1099 | if (!(dbri->pipes[info->pipe].sdp & D_SDP_TO_SER)) { |
| 1092 | printk(KERN_ERR "DBRI: setup_descs: Called on receive pipe %d\n", | 1100 | printk(KERN_ERR "DBRI: setup_descs: " |
| 1093 | info->pipe); | 1101 | "Called on receive pipe %d\n", info->pipe); |
| 1094 | return -2; | 1102 | return -2; |
| 1095 | } | 1103 | } |
| 1096 | } else { | 1104 | } else { |
| 1097 | if (dbri->pipes[info->pipe].sdp & D_SDP_TO_SER) { | 1105 | if (dbri->pipes[info->pipe].sdp & D_SDP_TO_SER) { |
| 1098 | printk(KERN_ERR | 1106 | printk(KERN_ERR |
| 1099 | "DBRI: setup_descs: Called on transmit pipe %d\n", | 1107 | "DBRI: setup_descs: Called on transmit pipe %d\n", |
| 1100 | info->pipe); | 1108 | info->pipe); |
| 1101 | return -2; | 1109 | return -2; |
| 1102 | } | 1110 | } |
| 1103 | /* Should be able to queue multiple buffers to receive on a pipe */ | 1111 | /* Should be able to queue multiple buffers |
| 1112 | * to receive on a pipe | ||
| 1113 | */ | ||
| 1104 | if (pipe_active(dbri, info->pipe)) { | 1114 | if (pipe_active(dbri, info->pipe)) { |
| 1105 | printk(KERN_ERR "DBRI: recv_on_pipe: Called on active pipe %d\n", | 1115 | printk(KERN_ERR "DBRI: recv_on_pipe: " |
| 1106 | info->pipe); | 1116 | "Called on active pipe %d\n", info->pipe); |
| 1107 | return -2; | 1117 | return -2; |
| 1108 | } | 1118 | } |
| 1109 | 1119 | ||
| @@ -1113,11 +1123,13 @@ static int setup_descs(struct snd_dbri * dbri, int streamno, unsigned int period | |||
| 1113 | 1123 | ||
| 1114 | /* Free descriptors if pipe has any */ | 1124 | /* Free descriptors if pipe has any */ |
| 1115 | desc = dbri->pipes[info->pipe].first_desc; | 1125 | desc = dbri->pipes[info->pipe].first_desc; |
| 1116 | if ( desc >= 0) | 1126 | if (desc >= 0) |
| 1117 | do { | 1127 | do { |
| 1118 | dbri->dma->desc[desc].nda = dbri->dma->desc[desc].ba = 0; | 1128 | dbri->dma->desc[desc].ba = 0; |
| 1129 | dbri->dma->desc[desc].nda = 0; | ||
| 1119 | desc = dbri->next_desc[desc]; | 1130 | desc = dbri->next_desc[desc]; |
| 1120 | } while (desc != -1 && desc != dbri->pipes[info->pipe].first_desc); | 1131 | } while (desc != -1 && |
| 1132 | desc != dbri->pipes[info->pipe].first_desc); | ||
| 1121 | 1133 | ||
| 1122 | dbri->pipes[info->pipe].desc = -1; | 1134 | dbri->pipes[info->pipe].desc = -1; |
| 1123 | dbri->pipes[info->pipe].first_desc = -1; | 1135 | dbri->pipes[info->pipe].first_desc = -1; |
| @@ -1130,6 +1142,7 @@ static int setup_descs(struct snd_dbri * dbri, int streamno, unsigned int period | |||
| 1130 | if (!dbri->dma->desc[desc].ba) | 1142 | if (!dbri->dma->desc[desc].ba) |
| 1131 | break; | 1143 | break; |
| 1132 | } | 1144 | } |
| 1145 | |||
| 1133 | if (desc == DBRI_NO_DESCS) { | 1146 | if (desc == DBRI_NO_DESCS) { |
| 1134 | printk(KERN_ERR "DBRI: setup_descs: No descriptors\n"); | 1147 | printk(KERN_ERR "DBRI: setup_descs: No descriptors\n"); |
| 1135 | return -1; | 1148 | return -1; |
| @@ -1150,8 +1163,7 @@ static int setup_descs(struct snd_dbri * dbri, int streamno, unsigned int period | |||
| 1150 | if (streamno == DBRI_PLAY) { | 1163 | if (streamno == DBRI_PLAY) { |
| 1151 | dbri->dma->desc[desc].word1 = DBRI_TD_CNT(mylen); | 1164 | dbri->dma->desc[desc].word1 = DBRI_TD_CNT(mylen); |
| 1152 | dbri->dma->desc[desc].word4 = 0; | 1165 | dbri->dma->desc[desc].word4 = 0; |
| 1153 | dbri->dma->desc[desc].word1 |= | 1166 | dbri->dma->desc[desc].word1 |= DBRI_TD_F | DBRI_TD_B; |
| 1154 | DBRI_TD_F | DBRI_TD_B; | ||
| 1155 | } else { | 1167 | } else { |
| 1156 | dbri->dma->desc[desc].word1 = 0; | 1168 | dbri->dma->desc[desc].word1 = 0; |
| 1157 | dbri->dma->desc[desc].word4 = | 1169 | dbri->dma->desc[desc].word4 = |
| @@ -1172,7 +1184,8 @@ static int setup_descs(struct snd_dbri * dbri, int streamno, unsigned int period | |||
| 1172 | } | 1184 | } |
| 1173 | 1185 | ||
| 1174 | if (first_desc == -1 || last_desc == -1) { | 1186 | if (first_desc == -1 || last_desc == -1) { |
| 1175 | printk(KERN_ERR "DBRI: setup_descs: Not enough descriptors available\n"); | 1187 | printk(KERN_ERR "DBRI: setup_descs: " |
| 1188 | " Not enough descriptors available\n"); | ||
| 1176 | return -1; | 1189 | return -1; |
| 1177 | } | 1190 | } |
| 1178 | 1191 | ||
| @@ -1183,14 +1196,14 @@ static int setup_descs(struct snd_dbri * dbri, int streamno, unsigned int period | |||
| 1183 | dbri->pipes[info->pipe].desc = first_desc; | 1196 | dbri->pipes[info->pipe].desc = first_desc; |
| 1184 | 1197 | ||
| 1185 | #ifdef DBRI_DEBUG | 1198 | #ifdef DBRI_DEBUG |
| 1186 | for (desc = first_desc; desc != -1; ) { | 1199 | for (desc = first_desc; desc != -1;) { |
| 1187 | dprintk(D_DESC, "DESC %d: %08x %08x %08x %08x\n", | 1200 | dprintk(D_DESC, "DESC %d: %08x %08x %08x %08x\n", |
| 1188 | desc, | 1201 | desc, |
| 1189 | dbri->dma->desc[desc].word1, | 1202 | dbri->dma->desc[desc].word1, |
| 1190 | dbri->dma->desc[desc].ba, | 1203 | dbri->dma->desc[desc].ba, |
| 1191 | dbri->dma->desc[desc].nda, dbri->dma->desc[desc].word4); | 1204 | dbri->dma->desc[desc].nda, dbri->dma->desc[desc].word4); |
| 1192 | desc = dbri->next_desc[desc]; | 1205 | desc = dbri->next_desc[desc]; |
| 1193 | if ( desc == first_desc ) | 1206 | if (desc == first_desc) |
| 1194 | break; | 1207 | break; |
| 1195 | } | 1208 | } |
| 1196 | #endif | 1209 | #endif |
| @@ -1213,7 +1226,8 @@ enum master_or_slave { CHImaster, CHIslave }; | |||
| 1213 | /* | 1226 | /* |
| 1214 | * Lock must not be held before calling it. | 1227 | * Lock must not be held before calling it. |
| 1215 | */ | 1228 | */ |
| 1216 | static void reset_chi(struct snd_dbri * dbri, enum master_or_slave master_or_slave, | 1229 | static void reset_chi(struct snd_dbri *dbri, |
| 1230 | enum master_or_slave master_or_slave, | ||
| 1217 | int bits_per_frame) | 1231 | int bits_per_frame) |
| 1218 | { | 1232 | { |
| 1219 | s32 *cmd; | 1233 | s32 *cmd; |
| @@ -1222,7 +1236,7 @@ static void reset_chi(struct snd_dbri * dbri, enum master_or_slave master_or_sla | |||
| 1222 | /* Set CHI Anchor: Pipe 16 */ | 1236 | /* Set CHI Anchor: Pipe 16 */ |
| 1223 | 1237 | ||
| 1224 | cmd = dbri_cmdlock(dbri, 4); | 1238 | cmd = dbri_cmdlock(dbri, 4); |
| 1225 | val = D_DTS_VO | D_DTS_VI | D_DTS_INS | 1239 | val = D_DTS_VO | D_DTS_VI | D_DTS_INS |
| 1226 | | D_DTS_PRVIN(16) | D_PIPE(16) | D_DTS_PRVOUT(16); | 1240 | | D_DTS_PRVIN(16) | D_PIPE(16) | D_DTS_PRVOUT(16); |
| 1227 | *(cmd++) = DBRI_CMD(D_DTS, 0, val); | 1241 | *(cmd++) = DBRI_CMD(D_DTS, 0, val); |
| 1228 | *(cmd++) = D_TS_ANCHOR | D_TS_NEXT(16); | 1242 | *(cmd++) = D_TS_ANCHOR | D_TS_NEXT(16); |
| @@ -1246,15 +1260,16 @@ static void reset_chi(struct snd_dbri * dbri, enum master_or_slave master_or_sla | |||
| 1246 | } else { | 1260 | } else { |
| 1247 | /* Setup DBRI for CHI Master - generate clock, FS | 1261 | /* Setup DBRI for CHI Master - generate clock, FS |
| 1248 | * | 1262 | * |
| 1249 | * BPF = bits per 8 kHz frame | 1263 | * BPF = bits per 8 kHz frame |
| 1250 | * 12.288 MHz / CHICM_divisor = clock rate | 1264 | * 12.288 MHz / CHICM_divisor = clock rate |
| 1251 | * FD = 1 - drive CHIFS on rising edge of CHICK | 1265 | * FD = 1 - drive CHIFS on rising edge of CHICK |
| 1252 | */ | 1266 | */ |
| 1253 | int clockrate = bits_per_frame * 8; | 1267 | int clockrate = bits_per_frame * 8; |
| 1254 | int divisor = 12288 / clockrate; | 1268 | int divisor = 12288 / clockrate; |
| 1255 | 1269 | ||
| 1256 | if (divisor > 255 || divisor * clockrate != 12288) | 1270 | if (divisor > 255 || divisor * clockrate != 12288) |
| 1257 | printk(KERN_ERR "DBRI: illegal bits_per_frame in setup_chi\n"); | 1271 | printk(KERN_ERR "DBRI: illegal bits_per_frame " |
| 1272 | "in setup_chi\n"); | ||
| 1258 | 1273 | ||
| 1259 | *(cmd++) = DBRI_CMD(D_CHI, 0, D_CHI_CHICM(divisor) | D_CHI_FD | 1274 | *(cmd++) = DBRI_CMD(D_CHI, 0, D_CHI_CHICM(divisor) | D_CHI_FD |
| 1260 | | D_CHI_BPF(bits_per_frame)); | 1275 | | D_CHI_BPF(bits_per_frame)); |
| @@ -1288,7 +1303,7 @@ to the DBRI via the CHI interface and few of the DBRI's PIO pins. | |||
| 1288 | * Lock must not be held before calling it. | 1303 | * Lock must not be held before calling it. |
| 1289 | 1304 | ||
| 1290 | */ | 1305 | */ |
| 1291 | static void cs4215_setup_pipes(struct snd_dbri * dbri) | 1306 | static __devinit void cs4215_setup_pipes(struct snd_dbri *dbri) |
| 1292 | { | 1307 | { |
| 1293 | unsigned long flags; | 1308 | unsigned long flags; |
| 1294 | 1309 | ||
| @@ -1303,9 +1318,9 @@ static void cs4215_setup_pipes(struct snd_dbri * dbri) | |||
| 1303 | * not relevant for us (only for doublechecking). | 1318 | * not relevant for us (only for doublechecking). |
| 1304 | * | 1319 | * |
| 1305 | * Control mode: | 1320 | * Control mode: |
| 1306 | * Pipe 17: Send timeslots 1-4 (slots 5-8 are readonly) | 1321 | * Pipe 17: Send timeslots 1-4 (slots 5-8 are read only) |
| 1307 | * Pipe 18: Receive timeslot 1 (clb). | 1322 | * Pipe 18: Receive timeslot 1 (clb). |
| 1308 | * Pipe 19: Receive timeslot 7 (version). | 1323 | * Pipe 19: Receive timeslot 7 (version). |
| 1309 | */ | 1324 | */ |
| 1310 | 1325 | ||
| 1311 | setup_pipe(dbri, 4, D_SDP_MEM | D_SDP_TO_SER | D_SDP_MSB); | 1326 | setup_pipe(dbri, 4, D_SDP_MEM | D_SDP_TO_SER | D_SDP_MSB); |
| @@ -1321,7 +1336,7 @@ static void cs4215_setup_pipes(struct snd_dbri * dbri) | |||
| 1321 | dbri_cmdwait(dbri); | 1336 | dbri_cmdwait(dbri); |
| 1322 | } | 1337 | } |
| 1323 | 1338 | ||
| 1324 | static int cs4215_init_data(struct cs4215 *mm) | 1339 | static __devinit int cs4215_init_data(struct cs4215 *mm) |
| 1325 | { | 1340 | { |
| 1326 | /* | 1341 | /* |
| 1327 | * No action, memory resetting only. | 1342 | * No action, memory resetting only. |
| @@ -1355,7 +1370,7 @@ static int cs4215_init_data(struct cs4215 *mm) | |||
| 1355 | return 0; | 1370 | return 0; |
| 1356 | } | 1371 | } |
| 1357 | 1372 | ||
| 1358 | static void cs4215_setdata(struct snd_dbri * dbri, int muted) | 1373 | static void cs4215_setdata(struct snd_dbri *dbri, int muted) |
| 1359 | { | 1374 | { |
| 1360 | if (muted) { | 1375 | if (muted) { |
| 1361 | dbri->mm.data[0] |= 63; | 1376 | dbri->mm.data[0] |= 63; |
| @@ -1387,7 +1402,7 @@ static void cs4215_setdata(struct snd_dbri * dbri, int muted) | |||
| 1387 | /* | 1402 | /* |
| 1388 | * Set the CS4215 to data mode. | 1403 | * Set the CS4215 to data mode. |
| 1389 | */ | 1404 | */ |
| 1390 | static void cs4215_open(struct snd_dbri * dbri) | 1405 | static void cs4215_open(struct snd_dbri *dbri) |
| 1391 | { | 1406 | { |
| 1392 | int data_width; | 1407 | int data_width; |
| 1393 | u32 tmp; | 1408 | u32 tmp; |
| @@ -1452,7 +1467,7 @@ static void cs4215_open(struct snd_dbri * dbri) | |||
| 1452 | /* | 1467 | /* |
| 1453 | * Send the control information (i.e. audio format) | 1468 | * Send the control information (i.e. audio format) |
| 1454 | */ | 1469 | */ |
| 1455 | static int cs4215_setctrl(struct snd_dbri * dbri) | 1470 | static int cs4215_setctrl(struct snd_dbri *dbri) |
| 1456 | { | 1471 | { |
| 1457 | int i, val; | 1472 | int i, val; |
| 1458 | u32 tmp; | 1473 | u32 tmp; |
| @@ -1502,9 +1517,9 @@ static int cs4215_setctrl(struct snd_dbri * dbri) | |||
| 1502 | 1517 | ||
| 1503 | /* | 1518 | /* |
| 1504 | * Control mode: | 1519 | * Control mode: |
| 1505 | * Pipe 17: Send timeslots 1-4 (slots 5-8 are readonly) | 1520 | * Pipe 17: Send timeslots 1-4 (slots 5-8 are read only) |
| 1506 | * Pipe 18: Receive timeslot 1 (clb). | 1521 | * Pipe 18: Receive timeslot 1 (clb). |
| 1507 | * Pipe 19: Receive timeslot 7 (version). | 1522 | * Pipe 19: Receive timeslot 7 (version). |
| 1508 | */ | 1523 | */ |
| 1509 | 1524 | ||
| 1510 | link_time_slot(dbri, 17, 16, 16, 32, dbri->mm.offset); | 1525 | link_time_slot(dbri, 17, 16, 16, 32, dbri->mm.offset); |
| @@ -1522,9 +1537,9 @@ static int cs4215_setctrl(struct snd_dbri * dbri) | |||
| 1522 | sbus_writel(tmp, dbri->regs + REG0); | 1537 | sbus_writel(tmp, dbri->regs + REG0); |
| 1523 | spin_unlock_irqrestore(&dbri->lock, flags); | 1538 | spin_unlock_irqrestore(&dbri->lock, flags); |
| 1524 | 1539 | ||
| 1525 | for (i = 10; ((dbri->mm.status & 0xe4) != 0x20); --i) { | 1540 | for (i = 10; ((dbri->mm.status & 0xe4) != 0x20); --i) |
| 1526 | msleep_interruptible(1); | 1541 | msleep_interruptible(1); |
| 1527 | } | 1542 | |
| 1528 | if (i == 0) { | 1543 | if (i == 0) { |
| 1529 | dprintk(D_MM, "CS4215 didn't respond to CLB (0x%02x)\n", | 1544 | dprintk(D_MM, "CS4215 didn't respond to CLB (0x%02x)\n", |
| 1530 | dbri->mm.status); | 1545 | dbri->mm.status); |
| @@ -1556,7 +1571,7 @@ static int cs4215_setctrl(struct snd_dbri * dbri) | |||
| 1556 | * As part of the process we resend the settings for the data | 1571 | * As part of the process we resend the settings for the data |
| 1557 | * timeslots as well. | 1572 | * timeslots as well. |
| 1558 | */ | 1573 | */ |
| 1559 | static int cs4215_prepare(struct snd_dbri * dbri, unsigned int rate, | 1574 | static int cs4215_prepare(struct snd_dbri *dbri, unsigned int rate, |
| 1560 | snd_pcm_format_t format, unsigned int channels) | 1575 | snd_pcm_format_t format, unsigned int channels) |
| 1561 | { | 1576 | { |
| 1562 | int freq_idx; | 1577 | int freq_idx; |
| @@ -1613,7 +1628,7 @@ static int cs4215_prepare(struct snd_dbri * dbri, unsigned int rate, | |||
| 1613 | /* | 1628 | /* |
| 1614 | * | 1629 | * |
| 1615 | */ | 1630 | */ |
| 1616 | static int cs4215_init(struct snd_dbri * dbri) | 1631 | static __devinit int cs4215_init(struct snd_dbri *dbri) |
| 1617 | { | 1632 | { |
| 1618 | u32 reg2 = sbus_readl(dbri->regs + REG2); | 1633 | u32 reg2 = sbus_readl(dbri->regs + REG2); |
| 1619 | dprintk(D_MM, "cs4215_init: reg2=0x%x\n", reg2); | 1634 | dprintk(D_MM, "cs4215_init: reg2=0x%x\n", reg2); |
| @@ -1674,7 +1689,7 @@ interrupts are disabled. | |||
| 1674 | 1689 | ||
| 1675 | /* xmit_descs() | 1690 | /* xmit_descs() |
| 1676 | * | 1691 | * |
| 1677 | * Starts transmiting the current TD's for recording/playing. | 1692 | * Starts transmitting the current TD's for recording/playing. |
| 1678 | * For playback, ALSA has filled the DMA memory with new data (we hope). | 1693 | * For playback, ALSA has filled the DMA memory with new data (we hope). |
| 1679 | */ | 1694 | */ |
| 1680 | static void xmit_descs(struct snd_dbri *dbri) | 1695 | static void xmit_descs(struct snd_dbri *dbri) |
| @@ -1701,7 +1716,8 @@ static void xmit_descs(struct snd_dbri *dbri) | |||
| 1701 | *(cmd++) = DBRI_CMD(D_SDP, 0, | 1716 | *(cmd++) = DBRI_CMD(D_SDP, 0, |
| 1702 | dbri->pipes[info->pipe].sdp | 1717 | dbri->pipes[info->pipe].sdp |
| 1703 | | D_SDP_P | D_SDP_EVERY | D_SDP_C); | 1718 | | D_SDP_P | D_SDP_EVERY | D_SDP_C); |
| 1704 | *(cmd++) = dbri->dma_dvma + dbri_dma_off(desc, first_td); | 1719 | *(cmd++) = dbri->dma_dvma + |
| 1720 | dbri_dma_off(desc, first_td); | ||
| 1705 | dbri_cmdsend(dbri, cmd, 2); | 1721 | dbri_cmdsend(dbri, cmd, 2); |
| 1706 | 1722 | ||
| 1707 | /* Reset our admin of the pipe. */ | 1723 | /* Reset our admin of the pipe. */ |
| @@ -1722,7 +1738,8 @@ static void xmit_descs(struct snd_dbri *dbri) | |||
| 1722 | *(cmd++) = DBRI_CMD(D_SDP, 0, | 1738 | *(cmd++) = DBRI_CMD(D_SDP, 0, |
| 1723 | dbri->pipes[info->pipe].sdp | 1739 | dbri->pipes[info->pipe].sdp |
| 1724 | | D_SDP_P | D_SDP_EVERY | D_SDP_C); | 1740 | | D_SDP_P | D_SDP_EVERY | D_SDP_C); |
| 1725 | *(cmd++) = dbri->dma_dvma + dbri_dma_off(desc, first_td); | 1741 | *(cmd++) = dbri->dma_dvma + |
| 1742 | dbri_dma_off(desc, first_td); | ||
| 1726 | dbri_cmdsend(dbri, cmd, 2); | 1743 | dbri_cmdsend(dbri, cmd, 2); |
| 1727 | 1744 | ||
| 1728 | /* Reset our admin of the pipe. */ | 1745 | /* Reset our admin of the pipe. */ |
| @@ -1747,15 +1764,12 @@ static void xmit_descs(struct snd_dbri *dbri) | |||
| 1747 | * | 1764 | * |
| 1748 | */ | 1765 | */ |
| 1749 | 1766 | ||
| 1750 | static void transmission_complete_intr(struct snd_dbri * dbri, int pipe) | 1767 | static void transmission_complete_intr(struct snd_dbri *dbri, int pipe) |
| 1751 | { | 1768 | { |
| 1752 | struct dbri_streaminfo *info; | 1769 | struct dbri_streaminfo *info = &dbri->stream_info[DBRI_PLAY]; |
| 1753 | int td; | 1770 | int td = dbri->pipes[pipe].desc; |
| 1754 | int status; | 1771 | int status; |
| 1755 | 1772 | ||
| 1756 | info = &dbri->stream_info[DBRI_PLAY]; | ||
| 1757 | |||
| 1758 | td = dbri->pipes[pipe].desc; | ||
| 1759 | while (td >= 0) { | 1773 | while (td >= 0) { |
| 1760 | if (td >= DBRI_NO_DESCS) { | 1774 | if (td >= DBRI_NO_DESCS) { |
| 1761 | printk(KERN_ERR "DBRI: invalid td on pipe %d\n", pipe); | 1775 | printk(KERN_ERR "DBRI: invalid td on pipe %d\n", pipe); |
| @@ -1763,9 +1777,8 @@ static void transmission_complete_intr(struct snd_dbri * dbri, int pipe) | |||
| 1763 | } | 1777 | } |
| 1764 | 1778 | ||
| 1765 | status = DBRI_TD_STATUS(dbri->dma->desc[td].word4); | 1779 | status = DBRI_TD_STATUS(dbri->dma->desc[td].word4); |
| 1766 | if (!(status & DBRI_TD_TBC)) { | 1780 | if (!(status & DBRI_TD_TBC)) |
| 1767 | break; | 1781 | break; |
| 1768 | } | ||
| 1769 | 1782 | ||
| 1770 | dprintk(D_INT, "TD %d, status 0x%02x\n", td, status); | 1783 | dprintk(D_INT, "TD %d, status 0x%02x\n", td, status); |
| 1771 | 1784 | ||
| @@ -1777,15 +1790,12 @@ static void transmission_complete_intr(struct snd_dbri * dbri, int pipe) | |||
| 1777 | } | 1790 | } |
| 1778 | 1791 | ||
| 1779 | /* Notify ALSA */ | 1792 | /* Notify ALSA */ |
| 1780 | if (spin_is_locked(&dbri->lock)) { | 1793 | spin_unlock(&dbri->lock); |
| 1781 | spin_unlock(&dbri->lock); | 1794 | snd_pcm_period_elapsed(info->substream); |
| 1782 | snd_pcm_period_elapsed(info->substream); | 1795 | spin_lock(&dbri->lock); |
| 1783 | spin_lock(&dbri->lock); | ||
| 1784 | } else | ||
| 1785 | snd_pcm_period_elapsed(info->substream); | ||
| 1786 | } | 1796 | } |
| 1787 | 1797 | ||
| 1788 | static void reception_complete_intr(struct snd_dbri * dbri, int pipe) | 1798 | static void reception_complete_intr(struct snd_dbri *dbri, int pipe) |
| 1789 | { | 1799 | { |
| 1790 | struct dbri_streaminfo *info; | 1800 | struct dbri_streaminfo *info; |
| 1791 | int rd = dbri->pipes[pipe].desc; | 1801 | int rd = dbri->pipes[pipe].desc; |
| @@ -1809,15 +1819,12 @@ static void reception_complete_intr(struct snd_dbri * dbri, int pipe) | |||
| 1809 | rd, DBRI_RD_STATUS(status), DBRI_RD_CNT(status)); | 1819 | rd, DBRI_RD_STATUS(status), DBRI_RD_CNT(status)); |
| 1810 | 1820 | ||
| 1811 | /* Notify ALSA */ | 1821 | /* Notify ALSA */ |
| 1812 | if (spin_is_locked(&dbri->lock)) { | 1822 | spin_unlock(&dbri->lock); |
| 1813 | spin_unlock(&dbri->lock); | 1823 | snd_pcm_period_elapsed(info->substream); |
| 1814 | snd_pcm_period_elapsed(info->substream); | 1824 | spin_lock(&dbri->lock); |
| 1815 | spin_lock(&dbri->lock); | ||
| 1816 | } else | ||
| 1817 | snd_pcm_period_elapsed(info->substream); | ||
| 1818 | } | 1825 | } |
| 1819 | 1826 | ||
| 1820 | static void dbri_process_one_interrupt(struct snd_dbri * dbri, int x) | 1827 | static void dbri_process_one_interrupt(struct snd_dbri *dbri, int x) |
| 1821 | { | 1828 | { |
| 1822 | int val = D_INTR_GETVAL(x); | 1829 | int val = D_INTR_GETVAL(x); |
| 1823 | int channel = D_INTR_GETCHAN(x); | 1830 | int channel = D_INTR_GETCHAN(x); |
| @@ -1889,7 +1896,7 @@ static void dbri_process_one_interrupt(struct snd_dbri * dbri, int x) | |||
| 1889 | * right now). Non-zero words require processing and are handed off | 1896 | * right now). Non-zero words require processing and are handed off |
| 1890 | * to dbri_process_one_interrupt AFTER advancing the pointer. | 1897 | * to dbri_process_one_interrupt AFTER advancing the pointer. |
| 1891 | */ | 1898 | */ |
| 1892 | static void dbri_process_interrupt_buffer(struct snd_dbri * dbri) | 1899 | static void dbri_process_interrupt_buffer(struct snd_dbri *dbri) |
| 1893 | { | 1900 | { |
| 1894 | s32 x; | 1901 | s32 x; |
| 1895 | 1902 | ||
| @@ -1965,20 +1972,20 @@ static irqreturn_t snd_dbri_interrupt(int irq, void *dev_id) | |||
| 1965 | PCM Interface | 1972 | PCM Interface |
| 1966 | ****************************************************************************/ | 1973 | ****************************************************************************/ |
| 1967 | static struct snd_pcm_hardware snd_dbri_pcm_hw = { | 1974 | static struct snd_pcm_hardware snd_dbri_pcm_hw = { |
| 1968 | .info = (SNDRV_PCM_INFO_MMAP | | 1975 | .info = SNDRV_PCM_INFO_MMAP | |
| 1969 | SNDRV_PCM_INFO_INTERLEAVED | | 1976 | SNDRV_PCM_INFO_INTERLEAVED | |
| 1970 | SNDRV_PCM_INFO_BLOCK_TRANSFER | | 1977 | SNDRV_PCM_INFO_BLOCK_TRANSFER | |
| 1971 | SNDRV_PCM_INFO_MMAP_VALID), | 1978 | SNDRV_PCM_INFO_MMAP_VALID, |
| 1972 | .formats = SNDRV_PCM_FMTBIT_MU_LAW | | 1979 | .formats = SNDRV_PCM_FMTBIT_MU_LAW | |
| 1973 | SNDRV_PCM_FMTBIT_A_LAW | | 1980 | SNDRV_PCM_FMTBIT_A_LAW | |
| 1974 | SNDRV_PCM_FMTBIT_U8 | | 1981 | SNDRV_PCM_FMTBIT_U8 | |
| 1975 | SNDRV_PCM_FMTBIT_S16_BE, | 1982 | SNDRV_PCM_FMTBIT_S16_BE, |
| 1976 | .rates = SNDRV_PCM_RATE_8000_48000 | SNDRV_PCM_RATE_5512, | 1983 | .rates = SNDRV_PCM_RATE_8000_48000 | SNDRV_PCM_RATE_5512, |
| 1977 | .rate_min = 5512, | 1984 | .rate_min = 5512, |
| 1978 | .rate_max = 48000, | 1985 | .rate_max = 48000, |
| 1979 | .channels_min = 1, | 1986 | .channels_min = 1, |
| 1980 | .channels_max = 2, | 1987 | .channels_max = 2, |
| 1981 | .buffer_bytes_max = (64 * 1024), | 1988 | .buffer_bytes_max = 64 * 1024, |
| 1982 | .period_bytes_min = 1, | 1989 | .period_bytes_min = 1, |
| 1983 | .period_bytes_max = DBRI_TD_MAXCNT, | 1990 | .period_bytes_max = DBRI_TD_MAXCNT, |
| 1984 | .periods_min = 1, | 1991 | .periods_min = 1, |
| @@ -2011,7 +2018,8 @@ static int snd_hw_rule_channels(struct snd_pcm_hw_params *params, | |||
| 2011 | 2018 | ||
| 2012 | snd_interval_any(&ch); | 2019 | snd_interval_any(&ch); |
| 2013 | if (!(f->bits[0] & SNDRV_PCM_FMTBIT_S16_BE)) { | 2020 | if (!(f->bits[0] & SNDRV_PCM_FMTBIT_S16_BE)) { |
| 2014 | ch.min = ch.max = 1; | 2021 | ch.min = 1; |
| 2022 | ch.max = 1; | ||
| 2015 | ch.integer = 1; | 2023 | ch.integer = 1; |
| 2016 | return snd_interval_refine(c, &ch); | 2024 | return snd_interval_refine(c, &ch); |
| 2017 | } | 2025 | } |
| @@ -2035,14 +2043,14 @@ static int snd_dbri_open(struct snd_pcm_substream *substream) | |||
| 2035 | info->pipe = -1; | 2043 | info->pipe = -1; |
| 2036 | spin_unlock_irqrestore(&dbri->lock, flags); | 2044 | spin_unlock_irqrestore(&dbri->lock, flags); |
| 2037 | 2045 | ||
| 2038 | snd_pcm_hw_rule_add(runtime,0,SNDRV_PCM_HW_PARAM_CHANNELS, | 2046 | snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, |
| 2039 | snd_hw_rule_format, NULL, SNDRV_PCM_HW_PARAM_FORMAT, | 2047 | snd_hw_rule_format, NULL, SNDRV_PCM_HW_PARAM_FORMAT, |
| 2040 | -1); | 2048 | -1); |
| 2041 | snd_pcm_hw_rule_add(runtime,0,SNDRV_PCM_HW_PARAM_FORMAT, | 2049 | snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_FORMAT, |
| 2042 | snd_hw_rule_channels, NULL, | 2050 | snd_hw_rule_channels, NULL, |
| 2043 | SNDRV_PCM_HW_PARAM_CHANNELS, | 2051 | SNDRV_PCM_HW_PARAM_CHANNELS, |
| 2044 | -1); | 2052 | -1); |
| 2045 | 2053 | ||
| 2046 | cs4215_open(dbri); | 2054 | cs4215_open(dbri); |
| 2047 | 2055 | ||
| 2048 | return 0; | 2056 | return 0; |
| @@ -2145,7 +2153,7 @@ static int snd_dbri_prepare(struct snd_pcm_substream *substream) | |||
| 2145 | spin_lock_irq(&dbri->lock); | 2153 | spin_lock_irq(&dbri->lock); |
| 2146 | info->offset = 0; | 2154 | info->offset = 0; |
| 2147 | 2155 | ||
| 2148 | /* Setup the all the transmit/receive desciptors to cover the | 2156 | /* Setup the all the transmit/receive descriptors to cover the |
| 2149 | * whole DMA buffer. | 2157 | * whole DMA buffer. |
| 2150 | */ | 2158 | */ |
| 2151 | ret = setup_descs(dbri, DBRI_STREAMNO(substream), | 2159 | ret = setup_descs(dbri, DBRI_STREAMNO(substream), |
| @@ -2205,12 +2213,12 @@ static struct snd_pcm_ops snd_dbri_ops = { | |||
| 2205 | .pointer = snd_dbri_pointer, | 2213 | .pointer = snd_dbri_pointer, |
| 2206 | }; | 2214 | }; |
| 2207 | 2215 | ||
| 2208 | static int __devinit snd_dbri_pcm(struct snd_dbri * dbri) | 2216 | static int __devinit snd_dbri_pcm(struct snd_card *card) |
| 2209 | { | 2217 | { |
| 2210 | struct snd_pcm *pcm; | 2218 | struct snd_pcm *pcm; |
| 2211 | int err; | 2219 | int err; |
| 2212 | 2220 | ||
| 2213 | if ((err = snd_pcm_new(dbri->card, | 2221 | if ((err = snd_pcm_new(card, |
| 2214 | /* ID */ "sun_dbri", | 2222 | /* ID */ "sun_dbri", |
| 2215 | /* device */ 0, | 2223 | /* device */ 0, |
| 2216 | /* playback count */ 1, | 2224 | /* playback count */ 1, |
| @@ -2221,16 +2229,15 @@ static int __devinit snd_dbri_pcm(struct snd_dbri * dbri) | |||
| 2221 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_dbri_ops); | 2229 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_dbri_ops); |
| 2222 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_dbri_ops); | 2230 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_dbri_ops); |
| 2223 | 2231 | ||
| 2224 | pcm->private_data = dbri; | 2232 | pcm->private_data = card->private_data; |
| 2225 | pcm->info_flags = 0; | 2233 | pcm->info_flags = 0; |
| 2226 | strcpy(pcm->name, dbri->card->shortname); | 2234 | strcpy(pcm->name, card->shortname); |
| 2227 | 2235 | ||
| 2228 | if ((err = snd_pcm_lib_preallocate_pages_for_all(pcm, | 2236 | if ((err = snd_pcm_lib_preallocate_pages_for_all(pcm, |
| 2229 | SNDRV_DMA_TYPE_CONTINUOUS, | 2237 | SNDRV_DMA_TYPE_CONTINUOUS, |
| 2230 | snd_dma_continuous_data(GFP_KERNEL), | 2238 | snd_dma_continuous_data(GFP_KERNEL), |
| 2231 | 64 * 1024, 64 * 1024)) < 0) { | 2239 | 64 * 1024, 64 * 1024)) < 0) |
| 2232 | return err; | 2240 | return err; |
| 2233 | } | ||
| 2234 | 2241 | ||
| 2235 | return 0; | 2242 | return 0; |
| 2236 | } | 2243 | } |
| @@ -2245,11 +2252,10 @@ static int snd_cs4215_info_volume(struct snd_kcontrol *kcontrol, | |||
| 2245 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; | 2252 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; |
| 2246 | uinfo->count = 2; | 2253 | uinfo->count = 2; |
| 2247 | uinfo->value.integer.min = 0; | 2254 | uinfo->value.integer.min = 0; |
| 2248 | if (kcontrol->private_value == DBRI_PLAY) { | 2255 | if (kcontrol->private_value == DBRI_PLAY) |
| 2249 | uinfo->value.integer.max = DBRI_MAX_VOLUME; | 2256 | uinfo->value.integer.max = DBRI_MAX_VOLUME; |
| 2250 | } else { | 2257 | else |
| 2251 | uinfo->value.integer.max = DBRI_MAX_GAIN; | 2258 | uinfo->value.integer.max = DBRI_MAX_GAIN; |
| 2252 | } | ||
| 2253 | return 0; | 2259 | return 0; |
| 2254 | } | 2260 | } |
| 2255 | 2261 | ||
| @@ -2271,7 +2277,8 @@ static int snd_cs4215_put_volume(struct snd_kcontrol *kcontrol, | |||
| 2271 | struct snd_ctl_elem_value *ucontrol) | 2277 | struct snd_ctl_elem_value *ucontrol) |
| 2272 | { | 2278 | { |
| 2273 | struct snd_dbri *dbri = snd_kcontrol_chip(kcontrol); | 2279 | struct snd_dbri *dbri = snd_kcontrol_chip(kcontrol); |
| 2274 | struct dbri_streaminfo *info = &dbri->stream_info[kcontrol->private_value]; | 2280 | struct dbri_streaminfo *info = |
| 2281 | &dbri->stream_info[kcontrol->private_value]; | ||
| 2275 | int changed = 0; | 2282 | int changed = 0; |
| 2276 | 2283 | ||
| 2277 | if (info->left_gain != ucontrol->value.integer.value[0]) { | 2284 | if (info->left_gain != ucontrol->value.integer.value[0]) { |
| @@ -2282,7 +2289,7 @@ static int snd_cs4215_put_volume(struct snd_kcontrol *kcontrol, | |||
| 2282 | info->right_gain = ucontrol->value.integer.value[1]; | 2289 | info->right_gain = ucontrol->value.integer.value[1]; |
| 2283 | changed = 1; | 2290 | changed = 1; |
| 2284 | } | 2291 | } |
| 2285 | if (changed == 1) { | 2292 | if (changed) { |
| 2286 | /* First mute outputs, and wait 1/8000 sec (125 us) | 2293 | /* First mute outputs, and wait 1/8000 sec (125 us) |
| 2287 | * to make sure this takes. This avoids clicking noises. | 2294 | * to make sure this takes. This avoids clicking noises. |
| 2288 | */ | 2295 | */ |
| @@ -2316,18 +2323,16 @@ static int snd_cs4215_get_single(struct snd_kcontrol *kcontrol, | |||
| 2316 | int invert = (kcontrol->private_value >> 24) & 1; | 2323 | int invert = (kcontrol->private_value >> 24) & 1; |
| 2317 | snd_assert(dbri != NULL, return -EINVAL); | 2324 | snd_assert(dbri != NULL, return -EINVAL); |
| 2318 | 2325 | ||
| 2319 | if (elem < 4) { | 2326 | if (elem < 4) |
| 2320 | ucontrol->value.integer.value[0] = | 2327 | ucontrol->value.integer.value[0] = |
| 2321 | (dbri->mm.data[elem] >> shift) & mask; | 2328 | (dbri->mm.data[elem] >> shift) & mask; |
| 2322 | } else { | 2329 | else |
| 2323 | ucontrol->value.integer.value[0] = | 2330 | ucontrol->value.integer.value[0] = |
| 2324 | (dbri->mm.ctrl[elem - 4] >> shift) & mask; | 2331 | (dbri->mm.ctrl[elem - 4] >> shift) & mask; |
| 2325 | } | ||
| 2326 | 2332 | ||
| 2327 | if (invert == 1) { | 2333 | if (invert == 1) |
| 2328 | ucontrol->value.integer.value[0] = | 2334 | ucontrol->value.integer.value[0] = |
| 2329 | mask - ucontrol->value.integer.value[0]; | 2335 | mask - ucontrol->value.integer.value[0]; |
| 2330 | } | ||
| 2331 | return 0; | 2336 | return 0; |
| 2332 | } | 2337 | } |
| 2333 | 2338 | ||
| @@ -2378,11 +2383,12 @@ static int snd_cs4215_put_single(struct snd_kcontrol *kcontrol, | |||
| 2378 | timeslots. Shift is the bit offset in the timeslot, mask defines the | 2383 | timeslots. Shift is the bit offset in the timeslot, mask defines the |
| 2379 | number of bits. invert is a boolean for use with attenuation. | 2384 | number of bits. invert is a boolean for use with attenuation. |
| 2380 | */ | 2385 | */ |
| 2381 | #define CS4215_SINGLE(xname, entry, shift, mask, invert) \ | 2386 | #define CS4215_SINGLE(xname, entry, shift, mask, invert) \ |
| 2382 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ | 2387 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ |
| 2383 | .info = snd_cs4215_info_single, \ | 2388 | .info = snd_cs4215_info_single, \ |
| 2384 | .get = snd_cs4215_get_single, .put = snd_cs4215_put_single, \ | 2389 | .get = snd_cs4215_get_single, .put = snd_cs4215_put_single, \ |
| 2385 | .private_value = entry | (shift << 8) | (mask << 16) | (invert << 24) }, | 2390 | .private_value = (entry) | ((shift) << 8) | ((mask) << 16) | \ |
| 2391 | ((invert) << 24) }, | ||
| 2386 | 2392 | ||
| 2387 | static struct snd_kcontrol_new dbri_controls[] __devinitdata = { | 2393 | static struct snd_kcontrol_new dbri_controls[] __devinitdata = { |
| 2388 | { | 2394 | { |
| @@ -2411,19 +2417,20 @@ static struct snd_kcontrol_new dbri_controls[] __devinitdata = { | |||
| 2411 | CS4215_SINGLE("Mic boost", 4, 4, 1, 1) | 2417 | CS4215_SINGLE("Mic boost", 4, 4, 1, 1) |
| 2412 | }; | 2418 | }; |
| 2413 | 2419 | ||
| 2414 | static int __init snd_dbri_mixer(struct snd_dbri * dbri) | 2420 | static int __devinit snd_dbri_mixer(struct snd_card *card) |
| 2415 | { | 2421 | { |
| 2416 | struct snd_card *card; | ||
| 2417 | int idx, err; | 2422 | int idx, err; |
| 2423 | struct snd_dbri *dbri; | ||
| 2418 | 2424 | ||
| 2419 | snd_assert(dbri != NULL && dbri->card != NULL, return -EINVAL); | 2425 | snd_assert(card != NULL && card->private_data != NULL, return -EINVAL); |
| 2426 | dbri = card->private_data; | ||
| 2420 | 2427 | ||
| 2421 | card = dbri->card; | ||
| 2422 | strcpy(card->mixername, card->shortname); | 2428 | strcpy(card->mixername, card->shortname); |
| 2423 | 2429 | ||
| 2424 | for (idx = 0; idx < ARRAY_SIZE(dbri_controls); idx++) { | 2430 | for (idx = 0; idx < ARRAY_SIZE(dbri_controls); idx++) { |
| 2425 | if ((err = snd_ctl_add(card, | 2431 | err = snd_ctl_add(card, |
| 2426 | snd_ctl_new1(&dbri_controls[idx], dbri))) < 0) | 2432 | snd_ctl_new1(&dbri_controls[idx], dbri)); |
| 2433 | if (err < 0) | ||
| 2427 | return err; | 2434 | return err; |
| 2428 | } | 2435 | } |
| 2429 | 2436 | ||
| @@ -2438,7 +2445,8 @@ static int __init snd_dbri_mixer(struct snd_dbri * dbri) | |||
| 2438 | /**************************************************************************** | 2445 | /**************************************************************************** |
| 2439 | /proc interface | 2446 | /proc interface |
| 2440 | ****************************************************************************/ | 2447 | ****************************************************************************/ |
| 2441 | static void dbri_regs_read(struct snd_info_entry * entry, struct snd_info_buffer *buffer) | 2448 | static void dbri_regs_read(struct snd_info_entry *entry, |
| 2449 | struct snd_info_buffer *buffer) | ||
| 2442 | { | 2450 | { |
| 2443 | struct snd_dbri *dbri = entry->private_data; | 2451 | struct snd_dbri *dbri = entry->private_data; |
| 2444 | 2452 | ||
| @@ -2449,7 +2457,7 @@ static void dbri_regs_read(struct snd_info_entry * entry, struct snd_info_buffer | |||
| 2449 | } | 2457 | } |
| 2450 | 2458 | ||
| 2451 | #ifdef DBRI_DEBUG | 2459 | #ifdef DBRI_DEBUG |
| 2452 | static void dbri_debug_read(struct snd_info_entry * entry, | 2460 | static void dbri_debug_read(struct snd_info_entry *entry, |
| 2453 | struct snd_info_buffer *buffer) | 2461 | struct snd_info_buffer *buffer) |
| 2454 | { | 2462 | { |
| 2455 | struct snd_dbri *dbri = entry->private_data; | 2463 | struct snd_dbri *dbri = entry->private_data; |
| @@ -2463,7 +2471,8 @@ static void dbri_debug_read(struct snd_info_entry * entry, | |||
| 2463 | "Pipe %d: %s SDP=0x%x desc=%d, " | 2471 | "Pipe %d: %s SDP=0x%x desc=%d, " |
| 2464 | "len=%d next %d\n", | 2472 | "len=%d next %d\n", |
| 2465 | pipe, | 2473 | pipe, |
| 2466 | ((pptr->sdp & D_SDP_TO_SER) ? "output" : "input"), | 2474 | (pptr->sdp & D_SDP_TO_SER) ? "output" : |
| 2475 | "input", | ||
| 2467 | pptr->sdp, pptr->desc, | 2476 | pptr->sdp, pptr->desc, |
| 2468 | pptr->length, pptr->nextpipe); | 2477 | pptr->length, pptr->nextpipe); |
| 2469 | } | 2478 | } |
| @@ -2471,15 +2480,16 @@ static void dbri_debug_read(struct snd_info_entry * entry, | |||
| 2471 | } | 2480 | } |
| 2472 | #endif | 2481 | #endif |
| 2473 | 2482 | ||
| 2474 | void snd_dbri_proc(struct snd_dbri * dbri) | 2483 | void __devinit snd_dbri_proc(struct snd_card *card) |
| 2475 | { | 2484 | { |
| 2485 | struct snd_dbri *dbri = card->private_data; | ||
| 2476 | struct snd_info_entry *entry; | 2486 | struct snd_info_entry *entry; |
| 2477 | 2487 | ||
| 2478 | if (! snd_card_proc_new(dbri->card, "regs", &entry)) | 2488 | if (!snd_card_proc_new(card, "regs", &entry)) |
| 2479 | snd_info_set_text_ops(entry, dbri, dbri_regs_read); | 2489 | snd_info_set_text_ops(entry, dbri, dbri_regs_read); |
| 2480 | 2490 | ||
| 2481 | #ifdef DBRI_DEBUG | 2491 | #ifdef DBRI_DEBUG |
| 2482 | if (! snd_card_proc_new(dbri->card, "debug", &entry)) { | 2492 | if (!snd_card_proc_new(card, "debug", &entry)) { |
| 2483 | snd_info_set_text_ops(entry, dbri, dbri_debug_read); | 2493 | snd_info_set_text_ops(entry, dbri, dbri_debug_read); |
| 2484 | entry->mode = S_IFREG | S_IRUGO; /* Readable only. */ | 2494 | entry->mode = S_IFREG | S_IRUGO; /* Readable only. */ |
| 2485 | } | 2495 | } |
| @@ -2491,19 +2501,18 @@ void snd_dbri_proc(struct snd_dbri * dbri) | |||
| 2491 | **************************** Initialization ******************************** | 2501 | **************************** Initialization ******************************** |
| 2492 | **************************************************************************** | 2502 | **************************************************************************** |
| 2493 | */ | 2503 | */ |
| 2494 | static void snd_dbri_free(struct snd_dbri * dbri); | 2504 | static void snd_dbri_free(struct snd_dbri *dbri); |
| 2495 | 2505 | ||
| 2496 | static int __init snd_dbri_create(struct snd_card *card, | 2506 | static int __devinit snd_dbri_create(struct snd_card *card, |
| 2497 | struct sbus_dev *sdev, | 2507 | struct sbus_dev *sdev, |
| 2498 | struct linux_prom_irqs *irq, int dev) | 2508 | int irq, int dev) |
| 2499 | { | 2509 | { |
| 2500 | struct snd_dbri *dbri = card->private_data; | 2510 | struct snd_dbri *dbri = card->private_data; |
| 2501 | int err; | 2511 | int err; |
| 2502 | 2512 | ||
| 2503 | spin_lock_init(&dbri->lock); | 2513 | spin_lock_init(&dbri->lock); |
| 2504 | dbri->card = card; | ||
| 2505 | dbri->sdev = sdev; | 2514 | dbri->sdev = sdev; |
| 2506 | dbri->irq = irq->pri; | 2515 | dbri->irq = irq; |
| 2507 | 2516 | ||
| 2508 | dbri->dma = sbus_alloc_consistent(sdev, sizeof(struct dbri_dma), | 2517 | dbri->dma = sbus_alloc_consistent(sdev, sizeof(struct dbri_dma), |
| 2509 | &dbri->dma_dvma); | 2518 | &dbri->dma_dvma); |
| @@ -2541,13 +2550,10 @@ static int __init snd_dbri_create(struct snd_card *card, | |||
| 2541 | return err; | 2550 | return err; |
| 2542 | } | 2551 | } |
| 2543 | 2552 | ||
| 2544 | dbri->next = dbri_list; | ||
| 2545 | dbri_list = dbri; | ||
| 2546 | |||
| 2547 | return 0; | 2553 | return 0; |
| 2548 | } | 2554 | } |
| 2549 | 2555 | ||
| 2550 | static void snd_dbri_free(struct snd_dbri * dbri) | 2556 | static void snd_dbri_free(struct snd_dbri *dbri) |
| 2551 | { | 2557 | { |
| 2552 | dprintk(D_GEN, "snd_dbri_free\n"); | 2558 | dprintk(D_GEN, "snd_dbri_free\n"); |
| 2553 | dbri_reset(dbri); | 2559 | dbri_reset(dbri); |
| @@ -2563,20 +2569,19 @@ static void snd_dbri_free(struct snd_dbri * dbri) | |||
| 2563 | (void *)dbri->dma, dbri->dma_dvma); | 2569 | (void *)dbri->dma, dbri->dma_dvma); |
| 2564 | } | 2570 | } |
| 2565 | 2571 | ||
| 2566 | static int __init dbri_attach(int prom_node, struct sbus_dev *sdev) | 2572 | static int __devinit dbri_probe(struct of_device *of_dev, |
| 2573 | const struct of_device_id *match) | ||
| 2567 | { | 2574 | { |
| 2575 | struct sbus_dev *sdev = to_sbus_device(&of_dev->dev); | ||
| 2568 | struct snd_dbri *dbri; | 2576 | struct snd_dbri *dbri; |
| 2569 | struct linux_prom_irqs irq; | 2577 | int irq; |
| 2570 | struct resource *rp; | 2578 | struct resource *rp; |
| 2571 | struct snd_card *card; | 2579 | struct snd_card *card; |
| 2572 | static int dev = 0; | 2580 | static int dev = 0; |
| 2573 | int err; | 2581 | int err; |
| 2574 | 2582 | ||
| 2575 | if (sdev->prom_name[9] < 'e') { | 2583 | dprintk(D_GEN, "DBRI: Found %s in SBUS slot %d\n", |
| 2576 | printk(KERN_ERR "DBRI: unsupported chip version %c found.\n", | 2584 | sdev->prom_name, sdev->slot); |
| 2577 | sdev->prom_name[9]); | ||
| 2578 | return -EIO; | ||
| 2579 | } | ||
| 2580 | 2585 | ||
| 2581 | if (dev >= SNDRV_CARDS) | 2586 | if (dev >= SNDRV_CARDS) |
| 2582 | return -ENODEV; | 2587 | return -ENODEV; |
| @@ -2585,9 +2590,9 @@ static int __init dbri_attach(int prom_node, struct sbus_dev *sdev) | |||
| 2585 | return -ENOENT; | 2590 | return -ENOENT; |
| 2586 | } | 2591 | } |
| 2587 | 2592 | ||
| 2588 | err = prom_getproperty(prom_node, "intr", (char *)&irq, sizeof(irq)); | 2593 | irq = sdev->irqs[0]; |
| 2589 | if (err < 0) { | 2594 | if (irq <= 0) { |
| 2590 | printk(KERN_ERR "DBRI-%d: Firmware node lacks IRQ property.\n", dev); | 2595 | printk(KERN_ERR "DBRI-%d: No IRQ.\n", dev); |
| 2591 | return -ENODEV; | 2596 | return -ENODEV; |
| 2592 | } | 2597 | } |
| 2593 | 2598 | ||
| @@ -2601,24 +2606,29 @@ static int __init dbri_attach(int prom_node, struct sbus_dev *sdev) | |||
| 2601 | rp = &sdev->resource[0]; | 2606 | rp = &sdev->resource[0]; |
| 2602 | sprintf(card->longname, "%s at 0x%02lx:0x%016Lx, irq %d", | 2607 | sprintf(card->longname, "%s at 0x%02lx:0x%016Lx, irq %d", |
| 2603 | card->shortname, | 2608 | card->shortname, |
| 2604 | rp->flags & 0xffL, (unsigned long long)rp->start, irq.pri); | 2609 | rp->flags & 0xffL, (unsigned long long)rp->start, irq); |
| 2605 | 2610 | ||
| 2606 | if ((err = snd_dbri_create(card, sdev, &irq, dev)) < 0) { | 2611 | err = snd_dbri_create(card, sdev, irq, dev); |
| 2612 | if (err < 0) { | ||
| 2607 | snd_card_free(card); | 2613 | snd_card_free(card); |
| 2608 | return err; | 2614 | return err; |
| 2609 | } | 2615 | } |
| 2610 | 2616 | ||
| 2611 | dbri = card->private_data; | 2617 | dbri = card->private_data; |
| 2612 | if ((err = snd_dbri_pcm(dbri)) < 0) | 2618 | err = snd_dbri_pcm(card); |
| 2619 | if (err < 0) | ||
| 2613 | goto _err; | 2620 | goto _err; |
| 2614 | 2621 | ||
| 2615 | if ((err = snd_dbri_mixer(dbri)) < 0) | 2622 | err = snd_dbri_mixer(card); |
| 2623 | if (err < 0) | ||
| 2616 | goto _err; | 2624 | goto _err; |
| 2617 | 2625 | ||
| 2618 | /* /proc file handling */ | 2626 | /* /proc file handling */ |
| 2619 | snd_dbri_proc(dbri); | 2627 | snd_dbri_proc(card); |
| 2628 | dev_set_drvdata(&of_dev->dev, card); | ||
| 2620 | 2629 | ||
| 2621 | if ((err = snd_card_register(card)) < 0) | 2630 | err = snd_card_register(card); |
| 2631 | if (err < 0) | ||
| 2622 | goto _err; | 2632 | goto _err; |
| 2623 | 2633 | ||
| 2624 | printk(KERN_INFO "audio%d at %p (irq %d) is DBRI(%c)+CS4215(%d)\n", | 2634 | printk(KERN_INFO "audio%d at %p (irq %d) is DBRI(%c)+CS4215(%d)\n", |
| @@ -2628,49 +2638,52 @@ static int __init dbri_attach(int prom_node, struct sbus_dev *sdev) | |||
| 2628 | 2638 | ||
| 2629 | return 0; | 2639 | return 0; |
| 2630 | 2640 | ||
| 2631 | _err: | 2641 | _err: |
| 2632 | snd_dbri_free(dbri); | 2642 | snd_dbri_free(dbri); |
| 2633 | snd_card_free(card); | 2643 | snd_card_free(card); |
| 2634 | return err; | 2644 | return err; |
| 2635 | } | 2645 | } |
| 2636 | 2646 | ||
| 2637 | /* Probe for the dbri chip and then attach the driver. */ | 2647 | static int __devexit dbri_remove(struct of_device *dev) |
| 2638 | static int __init dbri_init(void) | ||
| 2639 | { | 2648 | { |
| 2640 | struct sbus_bus *sbus; | 2649 | struct snd_card *card = dev_get_drvdata(&dev->dev); |
| 2641 | struct sbus_dev *sdev; | ||
| 2642 | int found = 0; | ||
| 2643 | |||
| 2644 | /* Probe each SBUS for the DBRI chip(s). */ | ||
| 2645 | for_all_sbusdev(sdev, sbus) { | ||
| 2646 | /* | ||
| 2647 | * The version is coded in the last character | ||
| 2648 | */ | ||
| 2649 | if (!strncmp(sdev->prom_name, "SUNW,DBRI", 9)) { | ||
| 2650 | dprintk(D_GEN, "DBRI: Found %s in SBUS slot %d\n", | ||
| 2651 | sdev->prom_name, sdev->slot); | ||
| 2652 | 2650 | ||
| 2653 | if (dbri_attach(sdev->prom_node, sdev) == 0) | 2651 | snd_dbri_free(card->private_data); |
| 2654 | found++; | 2652 | snd_card_free(card); |
| 2655 | } | 2653 | |
| 2656 | } | 2654 | dev_set_drvdata(&dev->dev, NULL); |
| 2655 | |||
| 2656 | return 0; | ||
| 2657 | } | ||
| 2658 | |||
| 2659 | static struct of_device_id dbri_match[] = { | ||
| 2660 | { | ||
| 2661 | .name = "SUNW,DBRIe", | ||
| 2662 | }, | ||
| 2663 | { | ||
| 2664 | .name = "SUNW,DBRIf", | ||
| 2665 | }, | ||
| 2666 | {}, | ||
| 2667 | }; | ||
| 2668 | |||
| 2669 | MODULE_DEVICE_TABLE(of, dbri_match); | ||
| 2670 | |||
| 2671 | static struct of_platform_driver dbri_sbus_driver = { | ||
| 2672 | .name = "dbri", | ||
| 2673 | .match_table = dbri_match, | ||
| 2674 | .probe = dbri_probe, | ||
| 2675 | .remove = __devexit_p(dbri_remove), | ||
| 2676 | }; | ||
| 2657 | 2677 | ||
| 2658 | return (found > 0) ? 0 : -EIO; | 2678 | /* Probe for the dbri chip and then attach the driver. */ |
| 2679 | static int __init dbri_init(void) | ||
| 2680 | { | ||
| 2681 | return of_register_driver(&dbri_sbus_driver, &sbus_bus_type); | ||
| 2659 | } | 2682 | } |
| 2660 | 2683 | ||
| 2661 | static void __exit dbri_exit(void) | 2684 | static void __exit dbri_exit(void) |
| 2662 | { | 2685 | { |
| 2663 | struct snd_dbri *this = dbri_list; | 2686 | of_unregister_driver(&dbri_sbus_driver); |
| 2664 | |||
| 2665 | while (this != NULL) { | ||
| 2666 | struct snd_dbri *next = this->next; | ||
| 2667 | struct snd_card *card = this->card; | ||
| 2668 | |||
| 2669 | snd_dbri_free(this); | ||
| 2670 | snd_card_free(card); | ||
| 2671 | this = next; | ||
| 2672 | } | ||
| 2673 | dbri_list = NULL; | ||
| 2674 | } | 2687 | } |
| 2675 | 2688 | ||
| 2676 | module_init(dbri_init); | 2689 | module_init(dbri_init); |
