Linux kernel & device driver programming

Cross-Referenced Linux and Device Driver Code

[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ]
Version: [ 2.6.11.8 ] [ 2.6.25 ] [ 2.6.25.8 ] [ 2.6.31.13 ] Architecture: [ i386 ]

Diff markup

Differences between /linux/sound/isa/sb/sb16_main.c (Version 2.6.31.13) and /linux/sound/isa/sb/sb16_main.c (Version 2.6.25)


  1 /*                                                  1 /*
  2  *  Copyright (c) by Jaroslav Kysela <perex@pe      2  *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
  3  *  Routines for control of 16-bit SoundBlaste      3  *  Routines for control of 16-bit SoundBlaster cards and clones
  4  *  Note: This is very ugly hardware which use      4  *  Note: This is very ugly hardware which uses one 8-bit DMA channel and
  5  *        second 16-bit DMA channel. Unfortuna      5  *        second 16-bit DMA channel. Unfortunately 8-bit DMA channel can't
  6  *        transfer 16-bit samples and 16-bit D      6  *        transfer 16-bit samples and 16-bit DMA channels can't transfer
  7  *        8-bit samples. This make full duplex      7  *        8-bit samples. This make full duplex more complicated than
  8  *        can be... People, don't buy these so      8  *        can be... People, don't buy these soundcards for full 16-bit
  9  *        duplex!!!                                 9  *        duplex!!!
 10  *  Note: 16-bit wide is assigned to first dir     10  *  Note: 16-bit wide is assigned to first direction which made request.
 11  *        With full duplex - playback is prefe     11  *        With full duplex - playback is preferred with abstract layer.
 12  *                                                 12  *
 13  *  Note: Some chip revisions have hardware bu     13  *  Note: Some chip revisions have hardware bug. Changing capture
 14  *        channel from full-duplex 8bit DMA to     14  *        channel from full-duplex 8bit DMA to 16bit DMA will block
 15  *        16bit DMA transfers from DSP chip (c     15  *        16bit DMA transfers from DSP chip (capture) until 8bit transfer
 16  *        to DSP chip (playback) starts. This      16  *        to DSP chip (playback) starts. This bug can be avoided with
 17  *        "16bit DMA Allocation" setting set t     17  *        "16bit DMA Allocation" setting set to Playback or Capture.
 18  *                                                 18  *
 19  *                                                 19  *
 20  *   This program is free software; you can re     20  *   This program is free software; you can redistribute it and/or modify
 21  *   it under the terms of the GNU General Pub     21  *   it under the terms of the GNU General Public License as published by
 22  *   the Free Software Foundation; either vers     22  *   the Free Software Foundation; either version 2 of the License, or
 23  *   (at your option) any later version.           23  *   (at your option) any later version.
 24  *                                                 24  *
 25  *   This program is distributed in the hope t     25  *   This program is distributed in the hope that it will be useful,
 26  *   but WITHOUT ANY WARRANTY; without even th     26  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 27  *   MERCHANTABILITY or FITNESS FOR A PARTICUL     27  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 28  *   GNU General Public License for more detai     28  *   GNU General Public License for more details.
 29  *                                                 29  *
 30  *   You should have received a copy of the GN     30  *   You should have received a copy of the GNU General Public License
 31  *   along with this program; if not, write to     31  *   along with this program; if not, write to the Free Software
 32  *   Foundation, Inc., 59 Temple Place, Suite      32  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 33  *                                                 33  *
 34  */                                                34  */
 35                                                    35 
 36 #include <asm/io.h>                                36 #include <asm/io.h>
 37 #include <asm/dma.h>                               37 #include <asm/dma.h>
 38 #include <linux/init.h>                            38 #include <linux/init.h>
 39 #include <linux/time.h>                            39 #include <linux/time.h>
 40 #include <sound/core.h>                            40 #include <sound/core.h>
 41 #include <sound/sb.h>                              41 #include <sound/sb.h>
 42 #include <sound/sb16_csp.h>                        42 #include <sound/sb16_csp.h>
 43 #include <sound/mpu401.h>                          43 #include <sound/mpu401.h>
 44 #include <sound/control.h>                         44 #include <sound/control.h>
 45 #include <sound/info.h>                            45 #include <sound/info.h>
 46                                                    46 
 47 MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz     47 MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
 48 MODULE_DESCRIPTION("Routines for control of 16     48 MODULE_DESCRIPTION("Routines for control of 16-bit SoundBlaster cards and clones");
 49 MODULE_LICENSE("GPL");                             49 MODULE_LICENSE("GPL");
 50                                                    50 
 51 #ifdef CONFIG_SND_SB16_CSP                         51 #ifdef CONFIG_SND_SB16_CSP
 52 static void snd_sb16_csp_playback_prepare(stru     52 static void snd_sb16_csp_playback_prepare(struct snd_sb *chip, struct snd_pcm_runtime *runtime)
 53 {                                                  53 {
 54         if (chip->hardware == SB_HW_16CSP) {       54         if (chip->hardware == SB_HW_16CSP) {
 55                 struct snd_sb_csp *csp = chip-     55                 struct snd_sb_csp *csp = chip->csp;
 56                                                    56 
 57                 if (csp->running & SNDRV_SB_CS     57                 if (csp->running & SNDRV_SB_CSP_ST_LOADED) {
 58                         /* manually loaded cod     58                         /* manually loaded codec */
 59                         if ((csp->mode & SNDRV     59                         if ((csp->mode & SNDRV_SB_CSP_MODE_DSP_WRITE) &&
 60                             ((1U << runtime->f     60                             ((1U << runtime->format) == csp->acc_format)) {
 61                                 /* Supported r     61                                 /* Supported runtime PCM format for playback */
 62                                 if (csp->ops.c     62                                 if (csp->ops.csp_use(csp) == 0) {
 63                                         /* If      63                                         /* If CSP was successfully acquired */
 64                                         goto _     64                                         goto __start_CSP;
 65                                 }                  65                                 }
 66                         } else if ((csp->mode      66                         } else if ((csp->mode & SNDRV_SB_CSP_MODE_QSOUND) && (csp->q_enabled)) {
 67                                 /* QSound deco     67                                 /* QSound decoder is loaded and enabled */
 68                                 if ((1 << runt     68                                 if ((1 << runtime->format) & (SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_U8 |
 69                                                    69                                                               SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_U16_LE)) {
 70                                         /* Onl     70                                         /* Only for simple PCM formats */
 71                                         if (cs     71                                         if (csp->ops.csp_use(csp) == 0) {
 72                                                    72                                                 /* If CSP was successfully acquired */
 73                                                    73                                                 goto __start_CSP;
 74                                         }          74                                         }
 75                                 }                  75                                 }
 76                         }                          76                         }
 77                 } else if (csp->ops.csp_use(cs     77                 } else if (csp->ops.csp_use(csp) == 0) {
 78                         /* Acquire CSP and try     78                         /* Acquire CSP and try to autoload hardware codec */
 79                         if (csp->ops.csp_autol     79                         if (csp->ops.csp_autoload(csp, runtime->format, SNDRV_SB_CSP_MODE_DSP_WRITE)) {
 80                                 /* Unsupported     80                                 /* Unsupported format, release CSP */
 81                                 csp->ops.csp_u     81                                 csp->ops.csp_unuse(csp);
 82                         } else {                   82                         } else {
 83                       __start_CSP:                 83                       __start_CSP:
 84                                 /* Try to star     84                                 /* Try to start CSP */
 85                                 if (csp->ops.c     85                                 if (csp->ops.csp_start(csp, (chip->mode & SB_MODE_PLAYBACK_16) ?
 86                                                    86                                                        SNDRV_SB_CSP_SAMPLE_16BIT : SNDRV_SB_CSP_SAMPLE_8BIT,
 87                                                    87                                                        (runtime->channels > 1) ?
 88                                                    88                                                        SNDRV_SB_CSP_STEREO : SNDRV_SB_CSP_MONO)) {
 89                                         /* Fai     89                                         /* Failed, release CSP */
 90                                         csp->o     90                                         csp->ops.csp_unuse(csp);
 91                                 } else {           91                                 } else {
 92                                         /* Suc     92                                         /* Success, CSP acquired and running */
 93                                         chip->     93                                         chip->open = SNDRV_SB_CSP_MODE_DSP_WRITE;
 94                                 }                  94                                 }
 95                         }                          95                         }
 96                 }                                  96                 }
 97         }                                          97         }
 98 }                                                  98 }
 99                                                    99 
100 static void snd_sb16_csp_capture_prepare(struc    100 static void snd_sb16_csp_capture_prepare(struct snd_sb *chip, struct snd_pcm_runtime *runtime)
101 {                                                 101 {
102         if (chip->hardware == SB_HW_16CSP) {      102         if (chip->hardware == SB_HW_16CSP) {
103                 struct snd_sb_csp *csp = chip-    103                 struct snd_sb_csp *csp = chip->csp;
104                                                   104 
105                 if (csp->running & SNDRV_SB_CS    105                 if (csp->running & SNDRV_SB_CSP_ST_LOADED) {
106                         /* manually loaded cod    106                         /* manually loaded codec */
107                         if ((csp->mode & SNDRV    107                         if ((csp->mode & SNDRV_SB_CSP_MODE_DSP_READ) &&
108                             ((1U << runtime->f    108                             ((1U << runtime->format) == csp->acc_format)) {
109                                 /* Supported r    109                                 /* Supported runtime PCM format for capture */
110                                 if (csp->ops.c    110                                 if (csp->ops.csp_use(csp) == 0) {
111                                         /* If     111                                         /* If CSP was successfully acquired */
112                                         goto _    112                                         goto __start_CSP;
113                                 }                 113                                 }
114                         }                         114                         }
115                 } else if (csp->ops.csp_use(cs    115                 } else if (csp->ops.csp_use(csp) == 0) {
116                         /* Acquire CSP and try    116                         /* Acquire CSP and try to autoload hardware codec */
117                         if (csp->ops.csp_autol    117                         if (csp->ops.csp_autoload(csp, runtime->format, SNDRV_SB_CSP_MODE_DSP_READ)) {
118                                 /* Unsupported    118                                 /* Unsupported format, release CSP */
119                                 csp->ops.csp_u    119                                 csp->ops.csp_unuse(csp);
120                         } else {                  120                         } else {
121                       __start_CSP:                121                       __start_CSP:
122                                 /* Try to star    122                                 /* Try to start CSP */
123                                 if (csp->ops.c    123                                 if (csp->ops.csp_start(csp, (chip->mode & SB_MODE_CAPTURE_16) ?
124                                                   124                                                        SNDRV_SB_CSP_SAMPLE_16BIT : SNDRV_SB_CSP_SAMPLE_8BIT,
125                                                   125                                                        (runtime->channels > 1) ?
126                                                   126                                                        SNDRV_SB_CSP_STEREO : SNDRV_SB_CSP_MONO)) {
127                                         /* Fai    127                                         /* Failed, release CSP */
128                                         csp->o    128                                         csp->ops.csp_unuse(csp);
129                                 } else {          129                                 } else {
130                                         /* Suc    130                                         /* Success, CSP acquired and running */
131                                         chip->    131                                         chip->open = SNDRV_SB_CSP_MODE_DSP_READ;
132                                 }                 132                                 }
133                         }                         133                         }
134                 }                                 134                 }
135         }                                         135         }
136 }                                                 136 }
137                                                   137 
138 static void snd_sb16_csp_update(struct snd_sb     138 static void snd_sb16_csp_update(struct snd_sb *chip)
139 {                                                 139 {
140         if (chip->hardware == SB_HW_16CSP) {      140         if (chip->hardware == SB_HW_16CSP) {
141                 struct snd_sb_csp *csp = chip-    141                 struct snd_sb_csp *csp = chip->csp;
142                                                   142 
143                 if (csp->qpos_changed) {          143                 if (csp->qpos_changed) {
144                         spin_lock(&chip->reg_l    144                         spin_lock(&chip->reg_lock);
145                         csp->ops.csp_qsound_tr    145                         csp->ops.csp_qsound_transfer (csp);
146                         spin_unlock(&chip->reg    146                         spin_unlock(&chip->reg_lock);
147                 }                                 147                 }
148         }                                         148         }
149 }                                                 149 }
150                                                   150 
151 static void snd_sb16_csp_playback_open(struct     151 static void snd_sb16_csp_playback_open(struct snd_sb *chip, struct snd_pcm_runtime *runtime)
152 {                                                 152 {
153         /* CSP decoders (QSound excluded) supp    153         /* CSP decoders (QSound excluded) support only 16bit transfers */
154         if (chip->hardware == SB_HW_16CSP) {      154         if (chip->hardware == SB_HW_16CSP) {
155                 struct snd_sb_csp *csp = chip-    155                 struct snd_sb_csp *csp = chip->csp;
156                                                   156 
157                 if (csp->running & SNDRV_SB_CS    157                 if (csp->running & SNDRV_SB_CSP_ST_LOADED) {
158                         /* manually loaded cod    158                         /* manually loaded codec */
159                         if (csp->mode & SNDRV_    159                         if (csp->mode & SNDRV_SB_CSP_MODE_DSP_WRITE) {
160                                 runtime->hw.fo    160                                 runtime->hw.formats |= csp->acc_format;
161                         }                         161                         }
162                 } else {                          162                 } else {
163                         /* autoloaded codecs *    163                         /* autoloaded codecs */
164                         runtime->hw.formats |=    164                         runtime->hw.formats |= SNDRV_PCM_FMTBIT_MU_LAW | SNDRV_PCM_FMTBIT_A_LAW |
165                                                   165                                                SNDRV_PCM_FMTBIT_IMA_ADPCM;
166                 }                                 166                 }
167         }                                         167         }
168 }                                                 168 }
169                                                   169 
170 static void snd_sb16_csp_playback_close(struct    170 static void snd_sb16_csp_playback_close(struct snd_sb *chip)
171 {                                                 171 {
172         if ((chip->hardware == SB_HW_16CSP) &&    172         if ((chip->hardware == SB_HW_16CSP) && (chip->open == SNDRV_SB_CSP_MODE_DSP_WRITE)) {
173                 struct snd_sb_csp *csp = chip-    173                 struct snd_sb_csp *csp = chip->csp;
174                                                   174 
175                 if (csp->ops.csp_stop(csp) ==     175                 if (csp->ops.csp_stop(csp) == 0) {
176                         csp->ops.csp_unuse(csp    176                         csp->ops.csp_unuse(csp);
177                         chip->open = 0;           177                         chip->open = 0;
178                 }                                 178                 }
179         }                                         179         }
180 }                                                 180 }
181                                                   181 
182 static void snd_sb16_csp_capture_open(struct s    182 static void snd_sb16_csp_capture_open(struct snd_sb *chip, struct snd_pcm_runtime *runtime)
183 {                                                 183 {
184         /* CSP coders support only 16bit trans    184         /* CSP coders support only 16bit transfers */
185         if (chip->hardware == SB_HW_16CSP) {      185         if (chip->hardware == SB_HW_16CSP) {
186                 struct snd_sb_csp *csp = chip-    186                 struct snd_sb_csp *csp = chip->csp;
187                                                   187 
188                 if (csp->running & SNDRV_SB_CS    188                 if (csp->running & SNDRV_SB_CSP_ST_LOADED) {
189                         /* manually loaded cod    189                         /* manually loaded codec */
190                         if (csp->mode & SNDRV_    190                         if (csp->mode & SNDRV_SB_CSP_MODE_DSP_READ) {
191                                 runtime->hw.fo    191                                 runtime->hw.formats |= csp->acc_format;
192                         }                         192                         }
193                 } else {                          193                 } else {
194                         /* autoloaded codecs *    194                         /* autoloaded codecs */
195                         runtime->hw.formats |=    195                         runtime->hw.formats |= SNDRV_PCM_FMTBIT_MU_LAW | SNDRV_PCM_FMTBIT_A_LAW |
196                                                   196                                                SNDRV_PCM_FMTBIT_IMA_ADPCM;
197                 }                                 197                 }
198         }                                         198         }
199 }                                                 199 }
200                                                   200 
201 static void snd_sb16_csp_capture_close(struct     201 static void snd_sb16_csp_capture_close(struct snd_sb *chip)
202 {                                                 202 {
203         if ((chip->hardware == SB_HW_16CSP) &&    203         if ((chip->hardware == SB_HW_16CSP) && (chip->open == SNDRV_SB_CSP_MODE_DSP_READ)) {
204                 struct snd_sb_csp *csp = chip-    204                 struct snd_sb_csp *csp = chip->csp;
205                                                   205 
206                 if (csp->ops.csp_stop(csp) ==     206                 if (csp->ops.csp_stop(csp) == 0) {
207                         csp->ops.csp_unuse(csp    207                         csp->ops.csp_unuse(csp);
208                         chip->open = 0;           208                         chip->open = 0;
209                 }                                 209                 }
210         }                                         210         }
211 }                                                 211 }
212 #else                                             212 #else
213 #define snd_sb16_csp_playback_prepare(chip, ru    213 #define snd_sb16_csp_playback_prepare(chip, runtime)    /*nop*/
214 #define snd_sb16_csp_capture_prepare(chip, run    214 #define snd_sb16_csp_capture_prepare(chip, runtime)     /*nop*/
215 #define snd_sb16_csp_update(chip)                 215 #define snd_sb16_csp_update(chip)                       /*nop*/
216 #define snd_sb16_csp_playback_open(chip, runti    216 #define snd_sb16_csp_playback_open(chip, runtime)       /*nop*/
217 #define snd_sb16_csp_playback_close(chip)         217 #define snd_sb16_csp_playback_close(chip)               /*nop*/
218 #define snd_sb16_csp_capture_open(chip, runtim    218 #define snd_sb16_csp_capture_open(chip, runtime)        /*nop*/
219 #define snd_sb16_csp_capture_close(chip)          219 #define snd_sb16_csp_capture_close(chip)                /*nop*/
220 #endif                                            220 #endif
221                                                   221 
222                                                   222 
223 static void snd_sb16_setup_rate(struct snd_sb     223 static void snd_sb16_setup_rate(struct snd_sb *chip,
224                                 unsigned short    224                                 unsigned short rate,
225                                 int channel)      225                                 int channel)
226 {                                                 226 {
227         unsigned long flags;                      227         unsigned long flags;
228                                                   228 
229         spin_lock_irqsave(&chip->reg_lock, fla    229         spin_lock_irqsave(&chip->reg_lock, flags);
230         if (chip->mode & (channel == SNDRV_PCM    230         if (chip->mode & (channel == SNDRV_PCM_STREAM_PLAYBACK ? SB_MODE_PLAYBACK_16 : SB_MODE_CAPTURE_16))
231                 snd_sb_ack_16bit(chip);           231                 snd_sb_ack_16bit(chip);
232         else                                      232         else
233                 snd_sb_ack_8bit(chip);            233                 snd_sb_ack_8bit(chip);
234         if (!(chip->mode & SB_RATE_LOCK)) {       234         if (!(chip->mode & SB_RATE_LOCK)) {
235                 chip->locked_rate = rate;         235                 chip->locked_rate = rate;
236                 snd_sbdsp_command(chip, SB_DSP    236                 snd_sbdsp_command(chip, SB_DSP_SAMPLE_RATE_IN);
237                 snd_sbdsp_command(chip, rate >    237                 snd_sbdsp_command(chip, rate >> 8);
238                 snd_sbdsp_command(chip, rate &    238                 snd_sbdsp_command(chip, rate & 0xff);
239                 snd_sbdsp_command(chip, SB_DSP    239                 snd_sbdsp_command(chip, SB_DSP_SAMPLE_RATE_OUT);
240                 snd_sbdsp_command(chip, rate >    240                 snd_sbdsp_command(chip, rate >> 8);
241                 snd_sbdsp_command(chip, rate &    241                 snd_sbdsp_command(chip, rate & 0xff);
242         }                                         242         }
243         spin_unlock_irqrestore(&chip->reg_lock    243         spin_unlock_irqrestore(&chip->reg_lock, flags);
244 }                                                 244 }
245                                                   245 
246 static int snd_sb16_hw_params(struct snd_pcm_s    246 static int snd_sb16_hw_params(struct snd_pcm_substream *substream,
247                               struct snd_pcm_h    247                               struct snd_pcm_hw_params *hw_params)
248 {                                                 248 {
249         return snd_pcm_lib_malloc_pages(substr    249         return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
250 }                                                 250 }
251                                                   251 
252 static int snd_sb16_hw_free(struct snd_pcm_sub    252 static int snd_sb16_hw_free(struct snd_pcm_substream *substream)
253 {                                                 253 {
254         snd_pcm_lib_free_pages(substream);        254         snd_pcm_lib_free_pages(substream);
255         return 0;                                 255         return 0;
256 }                                                 256 }
257                                                   257 
258 static int snd_sb16_playback_prepare(struct sn    258 static int snd_sb16_playback_prepare(struct snd_pcm_substream *substream)
259 {                                                 259 {
260         unsigned long flags;                      260         unsigned long flags;
261         struct snd_sb *chip = snd_pcm_substrea    261         struct snd_sb *chip = snd_pcm_substream_chip(substream);
262         struct snd_pcm_runtime *runtime = subs    262         struct snd_pcm_runtime *runtime = substream->runtime;
263         unsigned char format;                     263         unsigned char format;
264         unsigned int size, count, dma;            264         unsigned int size, count, dma;
265                                                   265 
266         snd_sb16_csp_playback_prepare(chip, ru    266         snd_sb16_csp_playback_prepare(chip, runtime);
267         if (snd_pcm_format_unsigned(runtime->f    267         if (snd_pcm_format_unsigned(runtime->format) > 0) {
268                 format = runtime->channels > 1    268                 format = runtime->channels > 1 ? SB_DSP4_MODE_UNS_STEREO : SB_DSP4_MODE_UNS_MONO;
269         } else {                                  269         } else {
270                 format = runtime->channels > 1    270                 format = runtime->channels > 1 ? SB_DSP4_MODE_SIGN_STEREO : SB_DSP4_MODE_SIGN_MONO;
271         }                                         271         }
272                                                   272 
273         snd_sb16_setup_rate(chip, runtime->rat    273         snd_sb16_setup_rate(chip, runtime->rate, SNDRV_PCM_STREAM_PLAYBACK);
274         size = chip->p_dma_size = snd_pcm_lib_    274         size = chip->p_dma_size = snd_pcm_lib_buffer_bytes(substream);
275         dma = (chip->mode & SB_MODE_PLAYBACK_8    275         dma = (chip->mode & SB_MODE_PLAYBACK_8) ? chip->dma8 : chip->dma16;
276         snd_dma_program(dma, runtime->dma_addr    276         snd_dma_program(dma, runtime->dma_addr, size, DMA_MODE_WRITE | DMA_AUTOINIT);
277                                                   277 
278         count = snd_pcm_lib_period_bytes(subst    278         count = snd_pcm_lib_period_bytes(substream);
279         spin_lock_irqsave(&chip->reg_lock, fla    279         spin_lock_irqsave(&chip->reg_lock, flags);
280         if (chip->mode & SB_MODE_PLAYBACK_16)     280         if (chip->mode & SB_MODE_PLAYBACK_16) {
281                 count >>= 1;                      281                 count >>= 1;
282                 count--;                          282                 count--;
283                 snd_sbdsp_command(chip, SB_DSP    283                 snd_sbdsp_command(chip, SB_DSP4_OUT16_AI);
284                 snd_sbdsp_command(chip, format    284                 snd_sbdsp_command(chip, format);
285                 snd_sbdsp_command(chip, count     285                 snd_sbdsp_command(chip, count & 0xff);
286                 snd_sbdsp_command(chip, count     286                 snd_sbdsp_command(chip, count >> 8);
287                 snd_sbdsp_command(chip, SB_DSP    287                 snd_sbdsp_command(chip, SB_DSP_DMA16_OFF);
288         } else {                                  288         } else {
289                 count--;                          289                 count--;
290                 snd_sbdsp_command(chip, SB_DSP    290                 snd_sbdsp_command(chip, SB_DSP4_OUT8_AI);
291                 snd_sbdsp_command(chip, format    291                 snd_sbdsp_command(chip, format);
292                 snd_sbdsp_command(chip, count     292                 snd_sbdsp_command(chip, count & 0xff);
293                 snd_sbdsp_command(chip, count     293                 snd_sbdsp_command(chip, count >> 8);
294                 snd_sbdsp_command(chip, SB_DSP    294                 snd_sbdsp_command(chip, SB_DSP_DMA8_OFF);
295         }                                         295         }
296         spin_unlock_irqrestore(&chip->reg_lock    296         spin_unlock_irqrestore(&chip->reg_lock, flags);
297         return 0;                                 297         return 0;
298 }                                                 298 }
299                                                   299 
300 static int snd_sb16_playback_trigger(struct sn    300 static int snd_sb16_playback_trigger(struct snd_pcm_substream *substream,
301                                      int cmd)     301                                      int cmd)
302 {                                                 302 {
303         struct snd_sb *chip = snd_pcm_substrea    303         struct snd_sb *chip = snd_pcm_substream_chip(substream);
304         int result = 0;                           304         int result = 0;
305                                                   305 
306         spin_lock(&chip->reg_lock);               306         spin_lock(&chip->reg_lock);
307         switch (cmd) {                            307         switch (cmd) {
308         case SNDRV_PCM_TRIGGER_START:             308         case SNDRV_PCM_TRIGGER_START:
309         case SNDRV_PCM_TRIGGER_RESUME:            309         case SNDRV_PCM_TRIGGER_RESUME:
310                 chip->mode |= SB_RATE_LOCK_PLA    310                 chip->mode |= SB_RATE_LOCK_PLAYBACK;
311                 snd_sbdsp_command(chip, chip->    311                 snd_sbdsp_command(chip, chip->mode & SB_MODE_PLAYBACK_16 ? SB_DSP_DMA16_ON : SB_DSP_DMA8_ON);
312                 break;                            312                 break;
313         case SNDRV_PCM_TRIGGER_STOP:              313         case SNDRV_PCM_TRIGGER_STOP:
314         case SNDRV_PCM_TRIGGER_SUSPEND:           314         case SNDRV_PCM_TRIGGER_SUSPEND:
315                 snd_sbdsp_command(chip, chip->    315                 snd_sbdsp_command(chip, chip->mode & SB_MODE_PLAYBACK_16 ? SB_DSP_DMA16_OFF : SB_DSP_DMA8_OFF);
316                 /* next two lines are needed f    316                 /* next two lines are needed for some types of DSP4 (SB AWE 32 - 4.13) */
317                 if (chip->mode & SB_RATE_LOCK_    317                 if (chip->mode & SB_RATE_LOCK_CAPTURE)
318                         snd_sbdsp_command(chip    318                         snd_sbdsp_command(chip, chip->mode & SB_MODE_CAPTURE_16 ? SB_DSP_DMA16_ON : SB_DSP_DMA8_ON);
319                 chip->mode &= ~SB_RATE_LOCK_PL    319                 chip->mode &= ~SB_RATE_LOCK_PLAYBACK;
320                 break;                            320                 break;
321         default:                                  321         default:
322                 result = -EINVAL;                 322                 result = -EINVAL;
323         }                                         323         }
324         spin_unlock(&chip->reg_lock);             324         spin_unlock(&chip->reg_lock);
325         return result;                            325         return result;
326 }                                                 326 }
327                                                   327 
328 static int snd_sb16_capture_prepare(struct snd    328 static int snd_sb16_capture_prepare(struct snd_pcm_substream *substream)
329 {                                                 329 {
330         unsigned long flags;                      330         unsigned long flags;
331         struct snd_sb *chip = snd_pcm_substrea    331         struct snd_sb *chip = snd_pcm_substream_chip(substream);
332         struct snd_pcm_runtime *runtime = subs    332         struct snd_pcm_runtime *runtime = substream->runtime;
333         unsigned char format;                     333         unsigned char format;
334         unsigned int size, count, dma;            334         unsigned int size, count, dma;
335                                                   335 
336         snd_sb16_csp_capture_prepare(chip, run    336         snd_sb16_csp_capture_prepare(chip, runtime);
337         if (snd_pcm_format_unsigned(runtime->f    337         if (snd_pcm_format_unsigned(runtime->format) > 0) {
338                 format = runtime->channels > 1    338                 format = runtime->channels > 1 ? SB_DSP4_MODE_UNS_STEREO : SB_DSP4_MODE_UNS_MONO;
339         } else {                                  339         } else {
340                 format = runtime->channels > 1    340                 format = runtime->channels > 1 ? SB_DSP4_MODE_SIGN_STEREO : SB_DSP4_MODE_SIGN_MONO;
341         }                                         341         }
342         snd_sb16_setup_rate(chip, runtime->rat    342         snd_sb16_setup_rate(chip, runtime->rate, SNDRV_PCM_STREAM_CAPTURE);
343         size = chip->c_dma_size = snd_pcm_lib_    343         size = chip->c_dma_size = snd_pcm_lib_buffer_bytes(substream);
344         dma = (chip->mode & SB_MODE_CAPTURE_8)    344         dma = (chip->mode & SB_MODE_CAPTURE_8) ? chip->dma8 : chip->dma16;
345         snd_dma_program(dma, runtime->dma_addr    345         snd_dma_program(dma, runtime->dma_addr, size, DMA_MODE_READ | DMA_AUTOINIT);
346                                                   346 
347         count = snd_pcm_lib_period_bytes(subst    347         count = snd_pcm_lib_period_bytes(substream);
348         spin_lock_irqsave(&chip->reg_lock, fla    348         spin_lock_irqsave(&chip->reg_lock, flags);
349         if (chip->mode & SB_MODE_CAPTURE_16) {    349         if (chip->mode & SB_MODE_CAPTURE_16) {
350                 count >>= 1;                      350                 count >>= 1;
351                 count--;                          351                 count--;
352                 snd_sbdsp_command(chip, SB_DSP    352                 snd_sbdsp_command(chip, SB_DSP4_IN16_AI);
353                 snd_sbdsp_command(chip, format    353                 snd_sbdsp_command(chip, format);
354                 snd_sbdsp_command(chip, count     354                 snd_sbdsp_command(chip, count & 0xff);
355                 snd_sbdsp_command(chip, count     355                 snd_sbdsp_command(chip, count >> 8);
356                 snd_sbdsp_command(chip, SB_DSP    356                 snd_sbdsp_command(chip, SB_DSP_DMA16_OFF);
357         } else {                                  357         } else {
358                 count--;                          358                 count--;
359                 snd_sbdsp_command(chip, SB_DSP    359                 snd_sbdsp_command(chip, SB_DSP4_IN8_AI);
360                 snd_sbdsp_command(chip, format    360                 snd_sbdsp_command(chip, format);
361                 snd_sbdsp_command(chip, count     361                 snd_sbdsp_command(chip, count & 0xff);
362                 snd_sbdsp_command(chip, count     362                 snd_sbdsp_command(chip, count >> 8);
363                 snd_sbdsp_command(chip, SB_DSP    363                 snd_sbdsp_command(chip, SB_DSP_DMA8_OFF);
364         }                                         364         }
365         spin_unlock_irqrestore(&chip->reg_lock    365         spin_unlock_irqrestore(&chip->reg_lock, flags);
366         return 0;                                 366         return 0;
367 }                                                 367 }
368                                                   368 
369 static int snd_sb16_capture_trigger(struct snd    369 static int snd_sb16_capture_trigger(struct snd_pcm_substream *substream,
370                                     int cmd)      370                                     int cmd)
371 {                                                 371 {
372         struct snd_sb *chip = snd_pcm_substrea    372         struct snd_sb *chip = snd_pcm_substream_chip(substream);
373         int result = 0;                           373         int result = 0;
374                                                   374 
375         spin_lock(&chip->reg_lock);               375         spin_lock(&chip->reg_lock);
376         switch (cmd) {                            376         switch (cmd) {
377         case SNDRV_PCM_TRIGGER_START:             377         case SNDRV_PCM_TRIGGER_START:
378         case SNDRV_PCM_TRIGGER_RESUME:            378         case SNDRV_PCM_TRIGGER_RESUME:
379                 chip->mode |= SB_RATE_LOCK_CAP    379                 chip->mode |= SB_RATE_LOCK_CAPTURE;
380                 snd_sbdsp_command(chip, chip->    380                 snd_sbdsp_command(chip, chip->mode & SB_MODE_CAPTURE_16 ? SB_DSP_DMA16_ON : SB_DSP_DMA8_ON);
381                 break;                            381                 break;
382         case SNDRV_PCM_TRIGGER_STOP:              382         case SNDRV_PCM_TRIGGER_STOP:
383         case SNDRV_PCM_TRIGGER_SUSPEND:           383         case SNDRV_PCM_TRIGGER_SUSPEND:
384                 snd_sbdsp_command(chip, chip->    384                 snd_sbdsp_command(chip, chip->mode & SB_MODE_CAPTURE_16 ? SB_DSP_DMA16_OFF : SB_DSP_DMA8_OFF);
385                 /* next two lines are needed f    385                 /* next two lines are needed for some types of DSP4 (SB AWE 32 - 4.13) */
386                 if (chip->mode & SB_RATE_LOCK_    386                 if (chip->mode & SB_RATE_LOCK_PLAYBACK)
387                         snd_sbdsp_command(chip    387                         snd_sbdsp_command(chip, chip->mode & SB_MODE_PLAYBACK_16 ? SB_DSP_DMA16_ON : SB_DSP_DMA8_ON);
388                 chip->mode &= ~SB_RATE_LOCK_CA    388                 chip->mode &= ~SB_RATE_LOCK_CAPTURE;
389                 break;                            389                 break;
390         default:                                  390         default:
391                 result = -EINVAL;                 391                 result = -EINVAL;
392         }                                         392         }
393         spin_unlock(&chip->reg_lock);             393         spin_unlock(&chip->reg_lock);
394         return result;                            394         return result;
395 }                                                 395 }
396                                                   396 
397 irqreturn_t snd_sb16dsp_interrupt(int irq, voi    397 irqreturn_t snd_sb16dsp_interrupt(int irq, void *dev_id)
398 {                                                 398 {
399         struct snd_sb *chip = dev_id;             399         struct snd_sb *chip = dev_id;
400         unsigned char status;                     400         unsigned char status;
401         int ok;                                   401         int ok;
402                                                   402 
403         spin_lock(&chip->mixer_lock);             403         spin_lock(&chip->mixer_lock);
404         status = snd_sbmixer_read(chip, SB_DSP    404         status = snd_sbmixer_read(chip, SB_DSP4_IRQSTATUS);
405         spin_unlock(&chip->mixer_lock);           405         spin_unlock(&chip->mixer_lock);
406         if ((status & SB_IRQTYPE_MPUIN) && chi    406         if ((status & SB_IRQTYPE_MPUIN) && chip->rmidi_callback)
407                 chip->rmidi_callback(irq, chip    407                 chip->rmidi_callback(irq, chip->rmidi->private_data);
408         if (status & SB_IRQTYPE_8BIT) {           408         if (status & SB_IRQTYPE_8BIT) {
409                 ok = 0;                           409                 ok = 0;
410                 if (chip->mode & SB_MODE_PLAYB    410                 if (chip->mode & SB_MODE_PLAYBACK_8) {
411                         snd_pcm_period_elapsed    411                         snd_pcm_period_elapsed(chip->playback_substream);
412                         snd_sb16_csp_update(ch    412                         snd_sb16_csp_update(chip);
413                         ok++;                     413                         ok++;
414                 }                                 414                 }
415                 if (chip->mode & SB_MODE_CAPTU    415                 if (chip->mode & SB_MODE_CAPTURE_8) {
416                         snd_pcm_period_elapsed    416                         snd_pcm_period_elapsed(chip->capture_substream);
417                         ok++;                     417                         ok++;
418                 }                                 418                 }
419                 spin_lock(&chip->reg_lock);       419                 spin_lock(&chip->reg_lock);
420                 if (!ok)                          420                 if (!ok)
421                         snd_sbdsp_command(chip    421                         snd_sbdsp_command(chip, SB_DSP_DMA8_OFF);
422                 snd_sb_ack_8bit(chip);            422                 snd_sb_ack_8bit(chip);
423                 spin_unlock(&chip->reg_lock);     423                 spin_unlock(&chip->reg_lock);
424         }                                         424         }
425         if (status & SB_IRQTYPE_16BIT) {          425         if (status & SB_IRQTYPE_16BIT) {
426                 ok = 0;                           426                 ok = 0;
427                 if (chip->mode & SB_MODE_PLAYB    427                 if (chip->mode & SB_MODE_PLAYBACK_16) {
428                         snd_pcm_period_elapsed    428                         snd_pcm_period_elapsed(chip->playback_substream);
429                         snd_sb16_csp_update(ch    429                         snd_sb16_csp_update(chip);
430                         ok++;                     430                         ok++;
431                 }                                 431                 }
432                 if (chip->mode & SB_MODE_CAPTU    432                 if (chip->mode & SB_MODE_CAPTURE_16) {
433                         snd_pcm_period_elapsed    433                         snd_pcm_period_elapsed(chip->capture_substream);
434                         ok++;                     434                         ok++;
435                 }                                 435                 }
436                 spin_lock(&chip->reg_lock);       436                 spin_lock(&chip->reg_lock);
437                 if (!ok)                          437                 if (!ok)
438                         snd_sbdsp_command(chip    438                         snd_sbdsp_command(chip, SB_DSP_DMA16_OFF);
439                 snd_sb_ack_16bit(chip);           439                 snd_sb_ack_16bit(chip);
440                 spin_unlock(&chip->reg_lock);     440                 spin_unlock(&chip->reg_lock);
441         }                                         441         }
442         return IRQ_HANDLED;                       442         return IRQ_HANDLED;
443 }                                                 443 }
444                                                   444 
445 /*                                                445 /*
446                                                   446 
447  */                                               447  */
448                                                   448 
449 static snd_pcm_uframes_t snd_sb16_playback_poi    449 static snd_pcm_uframes_t snd_sb16_playback_pointer(struct snd_pcm_substream *substream)
450 {                                                 450 {
451         struct snd_sb *chip = snd_pcm_substrea    451         struct snd_sb *chip = snd_pcm_substream_chip(substream);
452         unsigned int dma;                         452         unsigned int dma;
453         size_t ptr;                               453         size_t ptr;
454                                                   454 
455         dma = (chip->mode & SB_MODE_PLAYBACK_8    455         dma = (chip->mode & SB_MODE_PLAYBACK_8) ? chip->dma8 : chip->dma16;
456         ptr = snd_dma_pointer(dma, chip->p_dma    456         ptr = snd_dma_pointer(dma, chip->p_dma_size);
457         return bytes_to_frames(substream->runt    457         return bytes_to_frames(substream->runtime, ptr);
458 }                                                 458 }
459                                                   459 
460 static snd_pcm_uframes_t snd_sb16_capture_poin    460 static snd_pcm_uframes_t snd_sb16_capture_pointer(struct snd_pcm_substream *substream)
461 {                                                 461 {
462         struct snd_sb *chip = snd_pcm_substrea    462         struct snd_sb *chip = snd_pcm_substream_chip(substream);
463         unsigned int dma;                         463         unsigned int dma;
464         size_t ptr;                               464         size_t ptr;
465                                                   465 
466         dma = (chip->mode & SB_MODE_CAPTURE_8)    466         dma = (chip->mode & SB_MODE_CAPTURE_8) ? chip->dma8 : chip->dma16;
467         ptr = snd_dma_pointer(dma, chip->c_dma    467         ptr = snd_dma_pointer(dma, chip->c_dma_size);
468         return bytes_to_frames(substream->runt    468         return bytes_to_frames(substream->runtime, ptr);
469 }                                                 469 }
470                                                   470 
471 /*                                                471 /*
472                                                   472 
473  */                                               473  */
474                                                   474 
475 static struct snd_pcm_hardware snd_sb16_playba    475 static struct snd_pcm_hardware snd_sb16_playback =
476 {                                                 476 {
477         .info =                 (SNDRV_PCM_INF    477         .info =                 (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
478                                  SNDRV_PCM_INF    478                                  SNDRV_PCM_INFO_MMAP_VALID),
479         .formats =              0,                479         .formats =              0,
480         .rates =                SNDRV_PCM_RATE    480         .rates =                SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_44100,
481         .rate_min =             4000,             481         .rate_min =             4000,
482         .rate_max =             44100,            482         .rate_max =             44100,
483         .channels_min =         1,                483         .channels_min =         1,
484         .channels_max =         2,                484         .channels_max =         2,
485         .buffer_bytes_max =     (128*1024),       485         .buffer_bytes_max =     (128*1024),
486         .period_bytes_min =     64,               486         .period_bytes_min =     64,
487         .period_bytes_max =     (128*1024),       487         .period_bytes_max =     (128*1024),
488         .periods_min =          1,                488         .periods_min =          1,
489         .periods_max =          1024,             489         .periods_max =          1024,
490         .fifo_size =            0,                490         .fifo_size =            0,
491 };                                                491 };
492                                                   492 
493 static struct snd_pcm_hardware snd_sb16_captur    493 static struct snd_pcm_hardware snd_sb16_capture =
494 {                                                 494 {
495         .info =                 (SNDRV_PCM_INF    495         .info =                 (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
496                                  SNDRV_PCM_INF    496                                  SNDRV_PCM_INFO_MMAP_VALID),
497         .formats =              0,                497         .formats =              0,
498         .rates =                SNDRV_PCM_RATE    498         .rates =                SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_44100,
499         .rate_min =             4000,             499         .rate_min =             4000,
500         .rate_max =             44100,            500         .rate_max =             44100,
501         .channels_min =         1,                501         .channels_min =         1,
502         .channels_max =         2,                502         .channels_max =         2,
503         .buffer_bytes_max =     (128*1024),       503         .buffer_bytes_max =     (128*1024),
504         .period_bytes_min =     64,               504         .period_bytes_min =     64,
505         .period_bytes_max =     (128*1024),       505         .period_bytes_max =     (128*1024),
506         .periods_min =          1,                506         .periods_min =          1,
507         .periods_max =          1024,             507         .periods_max =          1024,
508         .fifo_size =            0,                508         .fifo_size =            0,
509 };                                                509 };
510                                                   510 
511 /*                                                511 /*
512  *  open/close                                    512  *  open/close
513  */                                               513  */
514                                                   514 
515 static int snd_sb16_playback_open(struct snd_p    515 static int snd_sb16_playback_open(struct snd_pcm_substream *substream)
516 {                                                 516 {
517         unsigned long flags;                      517         unsigned long flags;
518         struct snd_sb *chip = snd_pcm_substrea    518         struct snd_sb *chip = snd_pcm_substream_chip(substream);
519         struct snd_pcm_runtime *runtime = subs    519         struct snd_pcm_runtime *runtime = substream->runtime;
520                                                   520 
521         spin_lock_irqsave(&chip->open_lock, fl    521         spin_lock_irqsave(&chip->open_lock, flags);
522         if (chip->mode & SB_MODE_PLAYBACK) {      522         if (chip->mode & SB_MODE_PLAYBACK) {
523                 spin_unlock_irqrestore(&chip->    523                 spin_unlock_irqrestore(&chip->open_lock, flags);
524                 return -EAGAIN;                   524                 return -EAGAIN;
525         }                                         525         }
526         runtime->hw = snd_sb16_playback;          526         runtime->hw = snd_sb16_playback;
527                                                   527 
528         /* skip if 16 bit DMA was reserved for    528         /* skip if 16 bit DMA was reserved for capture */
529         if (chip->force_mode16 & SB_MODE_CAPTU    529         if (chip->force_mode16 & SB_MODE_CAPTURE_16)
530                 goto __skip_16bit;                530                 goto __skip_16bit;
531                                                   531 
532         if (chip->dma16 >= 0 && !(chip->mode &    532         if (chip->dma16 >= 0 && !(chip->mode & SB_MODE_CAPTURE_16)) {
533                 chip->mode |= SB_MODE_PLAYBACK    533                 chip->mode |= SB_MODE_PLAYBACK_16;
534                 runtime->hw.formats = SNDRV_PC    534                 runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_U16_LE;
535                 /* Vibra16X hack */               535                 /* Vibra16X hack */
536                 if (chip->dma16 <= 3) {           536                 if (chip->dma16 <= 3) {
537                         runtime->hw.buffer_byt    537                         runtime->hw.buffer_bytes_max =
538                         runtime->hw.period_byt    538                         runtime->hw.period_bytes_max = 64 * 1024;
539                 } else {                          539                 } else {
540                         snd_sb16_csp_playback_    540                         snd_sb16_csp_playback_open(chip, runtime);
541                 }                                 541                 }
542                 goto __open_ok;                   542                 goto __open_ok;
543         }                                         543         }
544                                                   544 
545       __skip_16bit:                               545       __skip_16bit:
546         if (chip->dma8 >= 0 && !(chip->mode &     546         if (chip->dma8 >= 0 && !(chip->mode & SB_MODE_CAPTURE_8)) {
547                 chip->mode |= SB_MODE_PLAYBACK    547                 chip->mode |= SB_MODE_PLAYBACK_8;
548                 /* DSP v 4.xx can transfer 16b    548                 /* DSP v 4.xx can transfer 16bit data through 8bit DMA channel, SBHWPG 2-7 */
549                 if (chip->dma16 < 0) {            549                 if (chip->dma16 < 0) {
550                         runtime->hw.formats =     550                         runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_U16_LE;
551                         chip->mode |= SB_MODE_    551                         chip->mode |= SB_MODE_PLAYBACK_16;
552                 } else {                          552                 } else {
553                         runtime->hw.formats =     553                         runtime->hw.formats = SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S8;
554                 }                                 554                 }
555                 runtime->hw.buffer_bytes_max =    555                 runtime->hw.buffer_bytes_max =
556                 runtime->hw.period_bytes_max =    556                 runtime->hw.period_bytes_max = 64 * 1024;
557                 goto __open_ok;                   557                 goto __open_ok;
558         }                                         558         }
559         spin_unlock_irqrestore(&chip->open_loc    559         spin_unlock_irqrestore(&chip->open_lock, flags);
560         return -EAGAIN;                           560         return -EAGAIN;
561                                                   561 
562       __open_ok:                                  562       __open_ok:
563         if (chip->hardware == SB_HW_ALS100)       563         if (chip->hardware == SB_HW_ALS100)
564                 runtime->hw.rate_max = 48000;     564                 runtime->hw.rate_max = 48000;
565         if (chip->hardware == SB_HW_CS5530) {     565         if (chip->hardware == SB_HW_CS5530) {
566                 runtime->hw.buffer_bytes_max =    566                 runtime->hw.buffer_bytes_max = 32 * 1024;
567                 runtime->hw.periods_min = 2;      567                 runtime->hw.periods_min = 2;
568                 runtime->hw.rate_min = 44100;     568                 runtime->hw.rate_min = 44100;
569         }                                         569         }
570         if (chip->mode & SB_RATE_LOCK)            570         if (chip->mode & SB_RATE_LOCK)
571                 runtime->hw.rate_min = runtime    571                 runtime->hw.rate_min = runtime->hw.rate_max = chip->locked_rate;
572         chip->playback_substream = substream;     572         chip->playback_substream = substream;
573         spin_unlock_irqrestore(&chip->open_loc    573         spin_unlock_irqrestore(&chip->open_lock, flags);
574         return 0;                                 574         return 0;
575 }                                                 575 }
576                                                   576 
577 static int snd_sb16_playback_close(struct snd_    577 static int snd_sb16_playback_close(struct snd_pcm_substream *substream)
578 {                                                 578 {
579         unsigned long flags;                      579         unsigned long flags;
580         struct snd_sb *chip = snd_pcm_substrea    580         struct snd_sb *chip = snd_pcm_substream_chip(substream);
581                                                   581 
582         snd_sb16_csp_playback_close(chip);        582         snd_sb16_csp_playback_close(chip);
583         spin_lock_irqsave(&chip->open_lock, fl    583         spin_lock_irqsave(&chip->open_lock, flags);
584         chip->playback_substream = NULL;          584         chip->playback_substream = NULL;
585         chip->mode &= ~SB_MODE_PLAYBACK;          585         chip->mode &= ~SB_MODE_PLAYBACK;
586         spin_unlock_irqrestore(&chip->open_loc    586         spin_unlock_irqrestore(&chip->open_lock, flags);
587         return 0;                                 587         return 0;
588 }                                                 588 }
589                                                   589 
590 static int snd_sb16_capture_open(struct snd_pc    590 static int snd_sb16_capture_open(struct snd_pcm_substream *substream)
591 {                                                 591 {
592         unsigned long flags;                      592         unsigned long flags;
593         struct snd_sb *chip = snd_pcm_substrea    593         struct snd_sb *chip = snd_pcm_substream_chip(substream);
594         struct snd_pcm_runtime *runtime = subs    594         struct snd_pcm_runtime *runtime = substream->runtime;
595                                                   595 
596         spin_lock_irqsave(&chip->open_lock, fl    596         spin_lock_irqsave(&chip->open_lock, flags);
597         if (chip->mode & SB_MODE_CAPTURE) {       597         if (chip->mode & SB_MODE_CAPTURE) {
598                 spin_unlock_irqrestore(&chip->    598                 spin_unlock_irqrestore(&chip->open_lock, flags);
599                 return -EAGAIN;                   599                 return -EAGAIN;
600         }                                         600         }
601         runtime->hw = snd_sb16_capture;           601         runtime->hw = snd_sb16_capture;
602                                                   602 
603         /* skip if 16 bit DMA was reserved for    603         /* skip if 16 bit DMA was reserved for playback */
604         if (chip->force_mode16 & SB_MODE_PLAYB    604         if (chip->force_mode16 & SB_MODE_PLAYBACK_16)
605                 goto __skip_16bit;                605                 goto __skip_16bit;
606                                                   606 
607         if (chip->dma16 >= 0 && !(chip->mode &    607         if (chip->dma16 >= 0 && !(chip->mode & SB_MODE_PLAYBACK_16)) {
608                 chip->mode |= SB_MODE_CAPTURE_    608                 chip->mode |= SB_MODE_CAPTURE_16;
609                 runtime->hw.formats = SNDRV_PC    609                 runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_U16_LE;
610                 /* Vibra16X hack */               610                 /* Vibra16X hack */
611                 if (chip->dma16 <= 3) {           611                 if (chip->dma16 <= 3) {
612                         runtime->hw.buffer_byt    612                         runtime->hw.buffer_bytes_max =
613                         runtime->hw.period_byt    613                         runtime->hw.period_bytes_max = 64 * 1024;
614                 } else {                          614                 } else {
615                         snd_sb16_csp_capture_o    615                         snd_sb16_csp_capture_open(chip, runtime);
616                 }                                 616                 }
617                 goto __open_ok;                   617                 goto __open_ok;
618         }                                         618         }
619                                                   619 
620       __skip_16bit:                               620       __skip_16bit:
621         if (chip->dma8 >= 0 && !(chip->mode &     621         if (chip->dma8 >= 0 && !(chip->mode & SB_MODE_PLAYBACK_8)) {
622                 chip->mode |= SB_MODE_CAPTURE_    622                 chip->mode |= SB_MODE_CAPTURE_8;
623                 /* DSP v 4.xx can transfer 16b    623                 /* DSP v 4.xx can transfer 16bit data through 8bit DMA channel, SBHWPG 2-7 */
624                 if (chip->dma16 < 0) {            624                 if (chip->dma16 < 0) {
625                         runtime->hw.formats =     625                         runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_U16_LE;
626                         chip->mode |= SB_MODE_    626                         chip->mode |= SB_MODE_CAPTURE_16;
627                 } else {                          627                 } else {
628                         runtime->hw.formats =     628                         runtime->hw.formats = SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S8;
629                 }                                 629                 }
630                 runtime->hw.buffer_bytes_max =    630                 runtime->hw.buffer_bytes_max =
631                 runtime->hw.period_bytes_max =    631                 runtime->hw.period_bytes_max = 64 * 1024;
632                 goto __open_ok;                   632                 goto __open_ok;
633         }                                         633         }
634         spin_unlock_irqrestore(&chip->open_loc    634         spin_unlock_irqrestore(&chip->open_lock, flags);
635         return -EAGAIN;                           635         return -EAGAIN;
636                                                   636 
637       __open_ok:                                  637       __open_ok:
638         if (chip->hardware == SB_HW_ALS100)       638         if (chip->hardware == SB_HW_ALS100)
639                 runtime->hw.rate_max = 48000;     639                 runtime->hw.rate_max = 48000;
640         if (chip->hardware == SB_HW_CS5530) {     640         if (chip->hardware == SB_HW_CS5530) {
641                 runtime->hw.buffer_bytes_max =    641                 runtime->hw.buffer_bytes_max = 32 * 1024;
642                 runtime->hw.periods_min = 2;      642                 runtime->hw.periods_min = 2;
643                 runtime->hw.rate_min = 44100;     643                 runtime->hw.rate_min = 44100;
644         }                                         644         }
645         if (chip->mode & SB_RATE_LOCK)            645         if (chip->mode & SB_RATE_LOCK)
646                 runtime->hw.rate_min = runtime    646                 runtime->hw.rate_min = runtime->hw.rate_max = chip->locked_rate;
647         chip->capture_substream = substream;      647         chip->capture_substream = substream;
648         spin_unlock_irqrestore(&chip->open_loc    648         spin_unlock_irqrestore(&chip->open_lock, flags);
649         return 0;                                 649         return 0;
650 }                                                 650 }
651                                                   651 
652 static int snd_sb16_capture_close(struct snd_p    652 static int snd_sb16_capture_close(struct snd_pcm_substream *substream)
653 {                                                 653 {
654         unsigned long flags;                      654         unsigned long flags;
655         struct snd_sb *chip = snd_pcm_substrea    655         struct snd_sb *chip = snd_pcm_substream_chip(substream);
656                                                   656 
657         snd_sb16_csp_capture_close(chip);         657         snd_sb16_csp_capture_close(chip);
658         spin_lock_irqsave(&chip->open_lock, fl    658         spin_lock_irqsave(&chip->open_lock, flags);
659         chip->capture_substream = NULL;           659         chip->capture_substream = NULL;
660         chip->mode &= ~SB_MODE_CAPTURE;           660         chip->mode &= ~SB_MODE_CAPTURE;
661         spin_unlock_irqrestore(&chip->open_loc    661         spin_unlock_irqrestore(&chip->open_lock, flags);
662         return 0;                                 662         return 0;
663 }                                                 663 }
664                                                   664 
665 /*                                                665 /*
666  *  DMA control interface                         666  *  DMA control interface
667  */                                               667  */
668                                                   668 
669 static int snd_sb16_set_dma_mode(struct snd_sb    669 static int snd_sb16_set_dma_mode(struct snd_sb *chip, int what)
670 {                                                 670 {
671         if (chip->dma8 < 0 || chip->dma16 < 0)    671         if (chip->dma8 < 0 || chip->dma16 < 0) {
672                 if (snd_BUG_ON(what))          !! 672                 snd_assert(what == 0, return -EINVAL);
673                         return -EINVAL;        << 
674                 return 0;                         673                 return 0;
675         }                                         674         }
676         if (what == 0) {                          675         if (what == 0) {
677                 chip->force_mode16 = 0;           676                 chip->force_mode16 = 0;
678         } else if (what == 1) {                   677         } else if (what == 1) {
679                 chip->force_mode16 = SB_MODE_P    678                 chip->force_mode16 = SB_MODE_PLAYBACK_16;
680         } else if (what == 2) {                   679         } else if (what == 2) {
681                 chip->force_mode16 = SB_MODE_C    680                 chip->force_mode16 = SB_MODE_CAPTURE_16;
682         } else {                                  681         } else {
683                 return -EINVAL;                   682                 return -EINVAL;
684         }                                         683         }
685         return 0;                                 684         return 0;
686 }                                                 685 }
687                                                   686 
688 static int snd_sb16_get_dma_mode(struct snd_sb    687 static int snd_sb16_get_dma_mode(struct snd_sb *chip)
689 {                                                 688 {
690         if (chip->dma8 < 0 || chip->dma16 < 0)    689         if (chip->dma8 < 0 || chip->dma16 < 0)
691                 return 0;                         690                 return 0;
692         switch (chip->force_mode16) {             691         switch (chip->force_mode16) {
693         case SB_MODE_PLAYBACK_16:                 692         case SB_MODE_PLAYBACK_16:
694                 return 1;                         693                 return 1;
695         case SB_MODE_CAPTURE_16:                  694         case SB_MODE_CAPTURE_16:
696                 return 2;                         695                 return 2;
697         default:                                  696         default:
698                 return 0;                         697                 return 0;
699         }                                         698         }
700 }                                                 699 }
701                                                   700 
702 static int snd_sb16_dma_control_info(struct sn    701 static int snd_sb16_dma_control_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
703 {                                                 702 {
704         static char *texts[3] = {                 703         static char *texts[3] = {
705                 "Auto", "Playback", "Capture"     704                 "Auto", "Playback", "Capture"
706         };                                        705         };
707                                                   706 
708         uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUM    707         uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
709         uinfo->count = 1;                         708         uinfo->count = 1;
710         uinfo->value.enumerated.items = 3;        709         uinfo->value.enumerated.items = 3;
711         if (uinfo->value.enumerated.item > 2)     710         if (uinfo->value.enumerated.item > 2)
712                 uinfo->value.enumerated.item =    711                 uinfo->value.enumerated.item = 2;
713         strcpy(uinfo->value.enumerated.name, t    712         strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
714         return 0;                                 713         return 0;
715 }                                                 714 }
716                                                   715 
717 static int snd_sb16_dma_control_get(struct snd    716 static int snd_sb16_dma_control_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
718 {                                                 717 {
719         struct snd_sb *chip = snd_kcontrol_chi    718         struct snd_sb *chip = snd_kcontrol_chip(kcontrol);
720         unsigned long flags;                      719         unsigned long flags;
721                                                   720         
722         spin_lock_irqsave(&chip->reg_lock, fla    721         spin_lock_irqsave(&chip->reg_lock, flags);
723         ucontrol->value.enumerated.item[0] = s    722         ucontrol->value.enumerated.item[0] = snd_sb16_get_dma_mode(chip);
724         spin_unlock_irqrestore(&chip->reg_lock    723         spin_unlock_irqrestore(&chip->reg_lock, flags);
725         return 0;                                 724         return 0;
726 }                                                 725 }
727                                                   726 
728 static int snd_sb16_dma_control_put(struct snd    727 static int snd_sb16_dma_control_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
729 {                                                 728 {
730         struct snd_sb *chip = snd_kcontrol_chi    729         struct snd_sb *chip = snd_kcontrol_chip(kcontrol);
731         unsigned long flags;                      730         unsigned long flags;
732         unsigned char nval, oval;                 731         unsigned char nval, oval;
733         int change;                               732         int change;
734                                                   733         
735         if ((nval = ucontrol->value.enumerated    734         if ((nval = ucontrol->value.enumerated.item[0]) > 2)
736                 return -EINVAL;                   735                 return -EINVAL;
737         spin_lock_irqsave(&chip->reg_lock, fla    736         spin_lock_irqsave(&chip->reg_lock, flags);
738         oval = snd_sb16_get_dma_mode(chip);       737         oval = snd_sb16_get_dma_mode(chip);
739         change = nval != oval;                    738         change = nval != oval;
740         snd_sb16_set_dma_mode(chip, nval);        739         snd_sb16_set_dma_mode(chip, nval);
741         spin_unlock_irqrestore(&chip->reg_lock    740         spin_unlock_irqrestore(&chip->reg_lock, flags);
742         return change;                            741         return change;
743 }                                                 742 }
744                                                   743 
745 static struct snd_kcontrol_new snd_sb16_dma_co    744 static struct snd_kcontrol_new snd_sb16_dma_control = {
746         .iface = SNDRV_CTL_ELEM_IFACE_CARD,       745         .iface = SNDRV_CTL_ELEM_IFACE_CARD,
747         .name = "16-bit DMA Allocation",          746         .name = "16-bit DMA Allocation",
748         .info = snd_sb16_dma_control_info,        747         .info = snd_sb16_dma_control_info,
749         .get = snd_sb16_dma_control_get,          748         .get = snd_sb16_dma_control_get,
750         .put = snd_sb16_dma_control_put           749         .put = snd_sb16_dma_control_put
751 };                                                750 };
752                                                   751 
753 /*                                                752 /*
754  *  Initialization part                           753  *  Initialization part
755  */                                               754  */
756                                                   755  
757 int snd_sb16dsp_configure(struct snd_sb * chip    756 int snd_sb16dsp_configure(struct snd_sb * chip)
758 {                                                 757 {
759         unsigned long flags;                      758         unsigned long flags;
760         unsigned char irqreg = 0, dmareg = 0,     759         unsigned char irqreg = 0, dmareg = 0, mpureg;
761         unsigned char realirq, realdma, realmp    760         unsigned char realirq, realdma, realmpureg;
762         /* note: mpu register should be presen    761         /* note: mpu register should be present only on SB16 Vibra soundcards */
763                                                   762 
764         // printk(KERN_DEBUG "codec->irq=%i, c    763         // printk(KERN_DEBUG "codec->irq=%i, codec->dma8=%i, codec->dma16=%i\n", chip->irq, chip->dma8, chip->dma16);
765         spin_lock_irqsave(&chip->mixer_lock, f    764         spin_lock_irqsave(&chip->mixer_lock, flags);
766         mpureg = snd_sbmixer_read(chip, SB_DSP    765         mpureg = snd_sbmixer_read(chip, SB_DSP4_MPUSETUP) & ~0x06;
767         spin_unlock_irqrestore(&chip->mixer_lo    766         spin_unlock_irqrestore(&chip->mixer_lock, flags);
768         switch (chip->irq) {                      767         switch (chip->irq) {
769         case 2:                                   768         case 2:
770         case 9:                                   769         case 9:
771                 irqreg |= SB_IRQSETUP_IRQ9;       770                 irqreg |= SB_IRQSETUP_IRQ9;
772                 break;                            771                 break;
773         case 5:                                   772         case 5:
774                 irqreg |= SB_IRQSETUP_IRQ5;       773                 irqreg |= SB_IRQSETUP_IRQ5;
775                 break;                            774                 break;
776         case 7:                                   775         case 7:
777                 irqreg |= SB_IRQSETUP_IRQ7;       776                 irqreg |= SB_IRQSETUP_IRQ7;
778                 break;                            777                 break;
779         case 10:                                  778         case 10:
780                 irqreg |= SB_IRQSETUP_IRQ10;      779                 irqreg |= SB_IRQSETUP_IRQ10;
781                 break;                            780                 break;
782         default:                                  781         default:
783                 return -EINVAL;                   782                 return -EINVAL;
784         }                                         783         }
785         if (chip->dma8 >= 0) {                    784         if (chip->dma8 >= 0) {
786                 switch (chip->dma8) {             785                 switch (chip->dma8) {
787                 case 0:                           786                 case 0:
788                         dmareg |= SB_DMASETUP_    787                         dmareg |= SB_DMASETUP_DMA0;
789                         break;                    788                         break;
790                 case 1:                           789                 case 1:
791                         dmareg |= SB_DMASETUP_    790                         dmareg |= SB_DMASETUP_DMA1;
792                         break;                    791                         break;
793                 case 3:                           792                 case 3:
794                         dmareg |= SB_DMASETUP_    793                         dmareg |= SB_DMASETUP_DMA3;
795                         break;                    794                         break;
796                 default:                          795                 default:
797                         return -EINVAL;           796                         return -EINVAL;
798                 }                                 797                 }
799         }                                         798         }
800         if (chip->dma16 >= 0 && chip->dma16 !=    799         if (chip->dma16 >= 0 && chip->dma16 != chip->dma8) {
801                 switch (chip->dma16) {            800                 switch (chip->dma16) {
802                 case 5:                           801                 case 5:
803                         dmareg |= SB_DMASETUP_    802                         dmareg |= SB_DMASETUP_DMA5;
804                         break;                    803                         break;
805                 case 6:                           804                 case 6:
806                         dmareg |= SB_DMASETUP_    805                         dmareg |= SB_DMASETUP_DMA6;
807                         break;                    806                         break;
808                 case 7:                           807                 case 7:
809                         dmareg |= SB_DMASETUP_    808                         dmareg |= SB_DMASETUP_DMA7;
810                         break;                    809                         break;
811                 default:                          810                 default:
812                         return -EINVAL;           811                         return -EINVAL;
813                 }                                 812                 }
814         }                                         813         }
815         switch (chip->mpu_port) {                 814         switch (chip->mpu_port) {
816         case 0x300:                               815         case 0x300:
817                 mpureg |= 0x04;                   816                 mpureg |= 0x04;
818                 break;                            817                 break;
819         case 0x330:                               818         case 0x330:
820                 mpureg |= 0x00;                   819                 mpureg |= 0x00;
821                 break;                            820                 break;
822         default:                                  821         default:
823                 mpureg |= 0x02; /* disable MPU    822                 mpureg |= 0x02; /* disable MPU */
824         }                                         823         }
825         spin_lock_irqsave(&chip->mixer_lock, f    824         spin_lock_irqsave(&chip->mixer_lock, flags);
826                                                   825 
827         snd_sbmixer_write(chip, SB_DSP4_IRQSET    826         snd_sbmixer_write(chip, SB_DSP4_IRQSETUP, irqreg);
828         realirq = snd_sbmixer_read(chip, SB_DS    827         realirq = snd_sbmixer_read(chip, SB_DSP4_IRQSETUP);
829                                                   828 
830         snd_sbmixer_write(chip, SB_DSP4_DMASET    829         snd_sbmixer_write(chip, SB_DSP4_DMASETUP, dmareg);
831         realdma = snd_sbmixer_read(chip, SB_DS    830         realdma = snd_sbmixer_read(chip, SB_DSP4_DMASETUP);
832                                                   831 
833         snd_sbmixer_write(chip, SB_DSP4_MPUSET    832         snd_sbmixer_write(chip, SB_DSP4_MPUSETUP, mpureg);
834         realmpureg = snd_sbmixer_read(chip, SB    833         realmpureg = snd_sbmixer_read(chip, SB_DSP4_MPUSETUP);
835                                                   834 
836         spin_unlock_irqrestore(&chip->mixer_lo    835         spin_unlock_irqrestore(&chip->mixer_lock, flags);
837         if ((~realirq) & irqreg || (~realdma)     836         if ((~realirq) & irqreg || (~realdma) & dmareg) {
838                 snd_printk(KERN_ERR "SB16 [0x%    837                 snd_printk(KERN_ERR "SB16 [0x%lx]: unable to set DMA & IRQ (PnP device?)\n", chip->port);
839                 snd_printk(KERN_ERR "SB16 [0x%    838                 snd_printk(KERN_ERR "SB16 [0x%lx]: wanted: irqreg=0x%x, dmareg=0x%x, mpureg = 0x%x\n", chip->port, realirq, realdma, realmpureg);
840                 snd_printk(KERN_ERR "SB16 [0x%    839                 snd_printk(KERN_ERR "SB16 [0x%lx]:    got: irqreg=0x%x, dmareg=0x%x, mpureg = 0x%x\n", chip->port, irqreg, dmareg, mpureg);
841                 return -ENODEV;                   840                 return -ENODEV;
842         }                                         841         }
843         return 0;                                 842         return 0;
844 }                                                 843 }
845                                                   844 
846 static struct snd_pcm_ops snd_sb16_playback_op    845 static struct snd_pcm_ops snd_sb16_playback_ops = {
847         .open =         snd_sb16_playback_open    846         .open =         snd_sb16_playback_open,
848         .close =        snd_sb16_playback_clos    847         .close =        snd_sb16_playback_close,
849         .ioctl =        snd_pcm_lib_ioctl,        848         .ioctl =        snd_pcm_lib_ioctl,
850         .hw_params =    snd_sb16_hw_params,       849         .hw_params =    snd_sb16_hw_params,
851         .hw_free =      snd_sb16_hw_free,         850         .hw_free =      snd_sb16_hw_free,
852         .prepare =      snd_sb16_playback_prep    851         .prepare =      snd_sb16_playback_prepare,
853         .trigger =      snd_sb16_playback_trig    852         .trigger =      snd_sb16_playback_trigger,
854         .pointer =      snd_sb16_playback_poin    853         .pointer =      snd_sb16_playback_pointer,
855 };                                                854 };
856                                                   855 
857 static struct snd_pcm_ops snd_sb16_capture_ops    856 static struct snd_pcm_ops snd_sb16_capture_ops = {
858         .open =         snd_sb16_capture_open,    857         .open =         snd_sb16_capture_open,
859         .close =        snd_sb16_capture_close    858         .close =        snd_sb16_capture_close,
860         .ioctl =        snd_pcm_lib_ioctl,        859         .ioctl =        snd_pcm_lib_ioctl,
861         .hw_params =    snd_sb16_hw_params,       860         .hw_params =    snd_sb16_hw_params,
862         .hw_free =      snd_sb16_hw_free,         861         .hw_free =      snd_sb16_hw_free,
863         .prepare =      snd_sb16_capture_prepa    862         .prepare =      snd_sb16_capture_prepare,
864         .trigger =      snd_sb16_capture_trigg    863         .trigger =      snd_sb16_capture_trigger,
865         .pointer =      snd_sb16_capture_point    864         .pointer =      snd_sb16_capture_pointer,
866 };                                                865 };
867                                                   866 
868 int snd_sb16dsp_pcm(struct snd_sb * chip, int     867 int snd_sb16dsp_pcm(struct snd_sb * chip, int device, struct snd_pcm ** rpcm)
869 {                                                 868 {
870         struct snd_card *card = chip->card;       869         struct snd_card *card = chip->card;
871         struct snd_pcm *pcm;                      870         struct snd_pcm *pcm;
872         int err;                                  871         int err;
873                                                   872 
874         if (rpcm)                                 873         if (rpcm)
875                 *rpcm = NULL;                     874                 *rpcm = NULL;
876         if ((err = snd_pcm_new(card, "SB16 DSP    875         if ((err = snd_pcm_new(card, "SB16 DSP", device, 1, 1, &pcm)) < 0)
877                 return err;                       876                 return err;
878         sprintf(pcm->name, "DSP v%i.%i", chip-    877         sprintf(pcm->name, "DSP v%i.%i", chip->version >> 8, chip->version & 0xff);
879         pcm->info_flags = SNDRV_PCM_INFO_JOINT    878         pcm->info_flags = SNDRV_PCM_INFO_JOINT_DUPLEX;
880         pcm->private_data = chip;                 879         pcm->private_data = chip;
881                                                   880 
882         snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_    881         snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_sb16_playback_ops);
883         snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_    882         snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_sb16_capture_ops);
884                                                   883 
885         if (chip->dma16 >= 0 && chip->dma8 !=     884         if (chip->dma16 >= 0 && chip->dma8 != chip->dma16)
886                 snd_ctl_add(card, snd_ctl_new1    885                 snd_ctl_add(card, snd_ctl_new1(&snd_sb16_dma_control, chip));
887         else                                      886         else
888                 pcm->info_flags = SNDRV_PCM_IN    887                 pcm->info_flags = SNDRV_PCM_INFO_HALF_DUPLEX;
889                                                   888 
890         snd_pcm_lib_preallocate_pages_for_all(    889         snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
891                                                   890                                               snd_dma_isa_data(),
892                                                   891                                               64*1024, 128*1024);
893                                                   892 
894         if (rpcm)                                 893         if (rpcm)
895                 *rpcm = pcm;                      894                 *rpcm = pcm;
896         return 0;                                 895         return 0;
897 }                                                 896 }
898                                                   897 
899 const struct snd_pcm_ops *snd_sb16dsp_get_pcm_    898 const struct snd_pcm_ops *snd_sb16dsp_get_pcm_ops(int direction)
900 {                                                 899 {
901         return direction == SNDRV_PCM_STREAM_P    900         return direction == SNDRV_PCM_STREAM_PLAYBACK ?
902                 &snd_sb16_playback_ops : &snd_    901                 &snd_sb16_playback_ops : &snd_sb16_capture_ops;
903 }                                                 902 }
904                                                   903 
905 EXPORT_SYMBOL(snd_sb16dsp_pcm);                   904 EXPORT_SYMBOL(snd_sb16dsp_pcm);
906 EXPORT_SYMBOL(snd_sb16dsp_get_pcm_ops);           905 EXPORT_SYMBOL(snd_sb16dsp_get_pcm_ops);
907 EXPORT_SYMBOL(snd_sb16dsp_configure);             906 EXPORT_SYMBOL(snd_sb16dsp_configure);
908 EXPORT_SYMBOL(snd_sb16dsp_interrupt);             907 EXPORT_SYMBOL(snd_sb16dsp_interrupt);
909                                                   908 
910 /*                                                909 /*
911  *  INIT part                                     910  *  INIT part
912  */                                               911  */
913                                                   912 
914 static int __init alsa_sb16_init(void)            913 static int __init alsa_sb16_init(void)
915 {                                                 914 {
916         return 0;                                 915         return 0;
917 }                                                 916 }
918                                                   917 
919 static void __exit alsa_sb16_exit(void)           918 static void __exit alsa_sb16_exit(void)
920 {                                                 919 {
921 }                                                 920 }
922                                                   921 
923 module_init(alsa_sb16_init)                       922 module_init(alsa_sb16_init)
924 module_exit(alsa_sb16_exit)                       923 module_exit(alsa_sb16_exit)
925                                                   924 
  This page was automatically generated by the LXR engine.