diff options
Diffstat (limited to 'sound/isa/sb/sb8_main.c')
-rw-r--r-- | sound/isa/sb/sb8_main.c | 117 |
1 files changed, 101 insertions, 16 deletions
diff --git a/sound/isa/sb/sb8_main.c b/sound/isa/sb/sb8_main.c index 658d55769c9c..3222aed5fac6 100644 --- a/sound/isa/sb/sb8_main.c +++ b/sound/isa/sb/sb8_main.c | |||
@@ -106,9 +106,21 @@ static int snd_sb8_playback_prepare(struct snd_pcm_substream *substream) | |||
106 | struct snd_sb *chip = snd_pcm_substream_chip(substream); | 106 | struct snd_sb *chip = snd_pcm_substream_chip(substream); |
107 | struct snd_pcm_runtime *runtime = substream->runtime; | 107 | struct snd_pcm_runtime *runtime = substream->runtime; |
108 | unsigned int mixreg, rate, size, count; | 108 | unsigned int mixreg, rate, size, count; |
109 | unsigned char format; | ||
110 | unsigned char stereo = runtime->channels > 1; | ||
111 | int dma; | ||
109 | 112 | ||
110 | rate = runtime->rate; | 113 | rate = runtime->rate; |
111 | switch (chip->hardware) { | 114 | switch (chip->hardware) { |
115 | case SB_HW_JAZZ16: | ||
116 | if (runtime->format == SNDRV_PCM_FORMAT_S16_LE) { | ||
117 | if (chip->mode & SB_MODE_CAPTURE_16) | ||
118 | return -EBUSY; | ||
119 | else | ||
120 | chip->mode |= SB_MODE_PLAYBACK_16; | ||
121 | } | ||
122 | chip->playback_format = SB_DSP_LO_OUTPUT_AUTO; | ||
123 | break; | ||
112 | case SB_HW_PRO: | 124 | case SB_HW_PRO: |
113 | if (runtime->channels > 1) { | 125 | if (runtime->channels > 1) { |
114 | if (snd_BUG_ON(rate != SB8_RATE(11025) && | 126 | if (snd_BUG_ON(rate != SB8_RATE(11025) && |
@@ -133,11 +145,21 @@ static int snd_sb8_playback_prepare(struct snd_pcm_substream *substream) | |||
133 | default: | 145 | default: |
134 | return -EINVAL; | 146 | return -EINVAL; |
135 | } | 147 | } |
148 | if (chip->mode & SB_MODE_PLAYBACK_16) { | ||
149 | format = stereo ? SB_DSP_STEREO_16BIT : SB_DSP_MONO_16BIT; | ||
150 | dma = chip->dma16; | ||
151 | } else { | ||
152 | format = stereo ? SB_DSP_STEREO_8BIT : SB_DSP_MONO_8BIT; | ||
153 | chip->mode |= SB_MODE_PLAYBACK_8; | ||
154 | dma = chip->dma8; | ||
155 | } | ||
136 | size = chip->p_dma_size = snd_pcm_lib_buffer_bytes(substream); | 156 | size = chip->p_dma_size = snd_pcm_lib_buffer_bytes(substream); |
137 | count = chip->p_period_size = snd_pcm_lib_period_bytes(substream); | 157 | count = chip->p_period_size = snd_pcm_lib_period_bytes(substream); |
138 | spin_lock_irqsave(&chip->reg_lock, flags); | 158 | spin_lock_irqsave(&chip->reg_lock, flags); |
139 | snd_sbdsp_command(chip, SB_DSP_SPEAKER_ON); | 159 | snd_sbdsp_command(chip, SB_DSP_SPEAKER_ON); |
140 | if (runtime->channels > 1) { | 160 | if (chip->hardware == SB_HW_JAZZ16) |
161 | snd_sbdsp_command(chip, format); | ||
162 | else if (stereo) { | ||
141 | /* set playback stereo mode */ | 163 | /* set playback stereo mode */ |
142 | spin_lock(&chip->mixer_lock); | 164 | spin_lock(&chip->mixer_lock); |
143 | mixreg = snd_sbmixer_read(chip, SB_DSP_STEREO_SW); | 165 | mixreg = snd_sbmixer_read(chip, SB_DSP_STEREO_SW); |
@@ -147,15 +169,14 @@ static int snd_sb8_playback_prepare(struct snd_pcm_substream *substream) | |||
147 | /* Soundblaster hardware programming reference guide, 3-23 */ | 169 | /* Soundblaster hardware programming reference guide, 3-23 */ |
148 | snd_sbdsp_command(chip, SB_DSP_DMA8_EXIT); | 170 | snd_sbdsp_command(chip, SB_DSP_DMA8_EXIT); |
149 | runtime->dma_area[0] = 0x80; | 171 | runtime->dma_area[0] = 0x80; |
150 | snd_dma_program(chip->dma8, runtime->dma_addr, 1, DMA_MODE_WRITE); | 172 | snd_dma_program(dma, runtime->dma_addr, 1, DMA_MODE_WRITE); |
151 | /* force interrupt */ | 173 | /* force interrupt */ |
152 | chip->mode = SB_MODE_HALT; | ||
153 | snd_sbdsp_command(chip, SB_DSP_OUTPUT); | 174 | snd_sbdsp_command(chip, SB_DSP_OUTPUT); |
154 | snd_sbdsp_command(chip, 0); | 175 | snd_sbdsp_command(chip, 0); |
155 | snd_sbdsp_command(chip, 0); | 176 | snd_sbdsp_command(chip, 0); |
156 | } | 177 | } |
157 | snd_sbdsp_command(chip, SB_DSP_SAMPLE_RATE); | 178 | snd_sbdsp_command(chip, SB_DSP_SAMPLE_RATE); |
158 | if (runtime->channels > 1) { | 179 | if (stereo) { |
159 | snd_sbdsp_command(chip, 256 - runtime->rate_den / 2); | 180 | snd_sbdsp_command(chip, 256 - runtime->rate_den / 2); |
160 | spin_lock(&chip->mixer_lock); | 181 | spin_lock(&chip->mixer_lock); |
161 | /* save output filter status and turn it off */ | 182 | /* save output filter status and turn it off */ |
@@ -168,13 +189,15 @@ static int snd_sb8_playback_prepare(struct snd_pcm_substream *substream) | |||
168 | snd_sbdsp_command(chip, 256 - runtime->rate_den); | 189 | snd_sbdsp_command(chip, 256 - runtime->rate_den); |
169 | } | 190 | } |
170 | if (chip->playback_format != SB_DSP_OUTPUT) { | 191 | if (chip->playback_format != SB_DSP_OUTPUT) { |
192 | if (chip->mode & SB_MODE_PLAYBACK_16) | ||
193 | count /= 2; | ||
171 | count--; | 194 | count--; |
172 | snd_sbdsp_command(chip, SB_DSP_BLOCK_SIZE); | 195 | snd_sbdsp_command(chip, SB_DSP_BLOCK_SIZE); |
173 | snd_sbdsp_command(chip, count & 0xff); | 196 | snd_sbdsp_command(chip, count & 0xff); |
174 | snd_sbdsp_command(chip, count >> 8); | 197 | snd_sbdsp_command(chip, count >> 8); |
175 | } | 198 | } |
176 | spin_unlock_irqrestore(&chip->reg_lock, flags); | 199 | spin_unlock_irqrestore(&chip->reg_lock, flags); |
177 | snd_dma_program(chip->dma8, runtime->dma_addr, | 200 | snd_dma_program(dma, runtime->dma_addr, |
178 | size, DMA_MODE_WRITE | DMA_AUTOINIT); | 201 | size, DMA_MODE_WRITE | DMA_AUTOINIT); |
179 | return 0; | 202 | return 0; |
180 | } | 203 | } |
@@ -212,7 +235,6 @@ static int snd_sb8_playback_trigger(struct snd_pcm_substream *substream, | |||
212 | snd_sbdsp_command(chip, SB_DSP_SPEAKER_OFF); | 235 | snd_sbdsp_command(chip, SB_DSP_SPEAKER_OFF); |
213 | } | 236 | } |
214 | spin_unlock_irqrestore(&chip->reg_lock, flags); | 237 | spin_unlock_irqrestore(&chip->reg_lock, flags); |
215 | chip->mode = (cmd == SNDRV_PCM_TRIGGER_START) ? SB_MODE_PLAYBACK_8 : SB_MODE_HALT; | ||
216 | return 0; | 238 | return 0; |
217 | } | 239 | } |
218 | 240 | ||
@@ -234,9 +256,21 @@ static int snd_sb8_capture_prepare(struct snd_pcm_substream *substream) | |||
234 | struct snd_sb *chip = snd_pcm_substream_chip(substream); | 256 | struct snd_sb *chip = snd_pcm_substream_chip(substream); |
235 | struct snd_pcm_runtime *runtime = substream->runtime; | 257 | struct snd_pcm_runtime *runtime = substream->runtime; |
236 | unsigned int mixreg, rate, size, count; | 258 | unsigned int mixreg, rate, size, count; |
259 | unsigned char format; | ||
260 | unsigned char stereo = runtime->channels > 1; | ||
261 | int dma; | ||
237 | 262 | ||
238 | rate = runtime->rate; | 263 | rate = runtime->rate; |
239 | switch (chip->hardware) { | 264 | switch (chip->hardware) { |
265 | case SB_HW_JAZZ16: | ||
266 | if (runtime->format == SNDRV_PCM_FORMAT_S16_LE) { | ||
267 | if (chip->mode & SB_MODE_PLAYBACK_16) | ||
268 | return -EBUSY; | ||
269 | else | ||
270 | chip->mode |= SB_MODE_CAPTURE_16; | ||
271 | } | ||
272 | chip->capture_format = SB_DSP_LO_INPUT_AUTO; | ||
273 | break; | ||
240 | case SB_HW_PRO: | 274 | case SB_HW_PRO: |
241 | if (runtime->channels > 1) { | 275 | if (runtime->channels > 1) { |
242 | if (snd_BUG_ON(rate != SB8_RATE(11025) && | 276 | if (snd_BUG_ON(rate != SB8_RATE(11025) && |
@@ -262,14 +296,24 @@ static int snd_sb8_capture_prepare(struct snd_pcm_substream *substream) | |||
262 | default: | 296 | default: |
263 | return -EINVAL; | 297 | return -EINVAL; |
264 | } | 298 | } |
299 | if (chip->mode & SB_MODE_CAPTURE_16) { | ||
300 | format = stereo ? SB_DSP_STEREO_16BIT : SB_DSP_MONO_16BIT; | ||
301 | dma = chip->dma16; | ||
302 | } else { | ||
303 | format = stereo ? SB_DSP_STEREO_8BIT : SB_DSP_MONO_8BIT; | ||
304 | chip->mode |= SB_MODE_CAPTURE_8; | ||
305 | dma = chip->dma8; | ||
306 | } | ||
265 | size = chip->c_dma_size = snd_pcm_lib_buffer_bytes(substream); | 307 | size = chip->c_dma_size = snd_pcm_lib_buffer_bytes(substream); |
266 | count = chip->c_period_size = snd_pcm_lib_period_bytes(substream); | 308 | count = chip->c_period_size = snd_pcm_lib_period_bytes(substream); |
267 | spin_lock_irqsave(&chip->reg_lock, flags); | 309 | spin_lock_irqsave(&chip->reg_lock, flags); |
268 | snd_sbdsp_command(chip, SB_DSP_SPEAKER_OFF); | 310 | snd_sbdsp_command(chip, SB_DSP_SPEAKER_OFF); |
269 | if (runtime->channels > 1) | 311 | if (chip->hardware == SB_HW_JAZZ16) |
312 | snd_sbdsp_command(chip, format); | ||
313 | else if (stereo) | ||
270 | snd_sbdsp_command(chip, SB_DSP_STEREO_8BIT); | 314 | snd_sbdsp_command(chip, SB_DSP_STEREO_8BIT); |
271 | snd_sbdsp_command(chip, SB_DSP_SAMPLE_RATE); | 315 | snd_sbdsp_command(chip, SB_DSP_SAMPLE_RATE); |
272 | if (runtime->channels > 1) { | 316 | if (stereo) { |
273 | snd_sbdsp_command(chip, 256 - runtime->rate_den / 2); | 317 | snd_sbdsp_command(chip, 256 - runtime->rate_den / 2); |
274 | spin_lock(&chip->mixer_lock); | 318 | spin_lock(&chip->mixer_lock); |
275 | /* save input filter status and turn it off */ | 319 | /* save input filter status and turn it off */ |
@@ -282,13 +326,15 @@ static int snd_sb8_capture_prepare(struct snd_pcm_substream *substream) | |||
282 | snd_sbdsp_command(chip, 256 - runtime->rate_den); | 326 | snd_sbdsp_command(chip, 256 - runtime->rate_den); |
283 | } | 327 | } |
284 | if (chip->capture_format != SB_DSP_INPUT) { | 328 | if (chip->capture_format != SB_DSP_INPUT) { |
329 | if (chip->mode & SB_MODE_PLAYBACK_16) | ||
330 | count /= 2; | ||
285 | count--; | 331 | count--; |
286 | snd_sbdsp_command(chip, SB_DSP_BLOCK_SIZE); | 332 | snd_sbdsp_command(chip, SB_DSP_BLOCK_SIZE); |
287 | snd_sbdsp_command(chip, count & 0xff); | 333 | snd_sbdsp_command(chip, count & 0xff); |
288 | snd_sbdsp_command(chip, count >> 8); | 334 | snd_sbdsp_command(chip, count >> 8); |
289 | } | 335 | } |
290 | spin_unlock_irqrestore(&chip->reg_lock, flags); | 336 | spin_unlock_irqrestore(&chip->reg_lock, flags); |
291 | snd_dma_program(chip->dma8, runtime->dma_addr, | 337 | snd_dma_program(dma, runtime->dma_addr, |
292 | size, DMA_MODE_READ | DMA_AUTOINIT); | 338 | size, DMA_MODE_READ | DMA_AUTOINIT); |
293 | return 0; | 339 | return 0; |
294 | } | 340 | } |
@@ -328,7 +374,6 @@ static int snd_sb8_capture_trigger(struct snd_pcm_substream *substream, | |||
328 | snd_sbdsp_command(chip, SB_DSP_SPEAKER_OFF); | 374 | snd_sbdsp_command(chip, SB_DSP_SPEAKER_OFF); |
329 | } | 375 | } |
330 | spin_unlock_irqrestore(&chip->reg_lock, flags); | 376 | spin_unlock_irqrestore(&chip->reg_lock, flags); |
331 | chip->mode = (cmd == SNDRV_PCM_TRIGGER_START) ? SB_MODE_CAPTURE_8 : SB_MODE_HALT; | ||
332 | return 0; | 377 | return 0; |
333 | } | 378 | } |
334 | 379 | ||
@@ -339,13 +384,21 @@ irqreturn_t snd_sb8dsp_interrupt(struct snd_sb *chip) | |||
339 | 384 | ||
340 | snd_sb_ack_8bit(chip); | 385 | snd_sb_ack_8bit(chip); |
341 | switch (chip->mode) { | 386 | switch (chip->mode) { |
342 | case SB_MODE_PLAYBACK_8: /* ok.. playback is active */ | 387 | case SB_MODE_PLAYBACK_16: /* ok.. playback is active */ |
388 | if (chip->hardware != SB_HW_JAZZ16) | ||
389 | break; | ||
390 | /* fallthru */ | ||
391 | case SB_MODE_PLAYBACK_8: | ||
343 | substream = chip->playback_substream; | 392 | substream = chip->playback_substream; |
344 | runtime = substream->runtime; | 393 | runtime = substream->runtime; |
345 | if (chip->playback_format == SB_DSP_OUTPUT) | 394 | if (chip->playback_format == SB_DSP_OUTPUT) |
346 | snd_sb8_playback_trigger(substream, SNDRV_PCM_TRIGGER_START); | 395 | snd_sb8_playback_trigger(substream, SNDRV_PCM_TRIGGER_START); |
347 | snd_pcm_period_elapsed(substream); | 396 | snd_pcm_period_elapsed(substream); |
348 | break; | 397 | break; |
398 | case SB_MODE_CAPTURE_16: | ||
399 | if (chip->hardware != SB_HW_JAZZ16) | ||
400 | break; | ||
401 | /* fallthru */ | ||
349 | case SB_MODE_CAPTURE_8: | 402 | case SB_MODE_CAPTURE_8: |
350 | substream = chip->capture_substream; | 403 | substream = chip->capture_substream; |
351 | runtime = substream->runtime; | 404 | runtime = substream->runtime; |
@@ -361,10 +414,15 @@ static snd_pcm_uframes_t snd_sb8_playback_pointer(struct snd_pcm_substream *subs | |||
361 | { | 414 | { |
362 | struct snd_sb *chip = snd_pcm_substream_chip(substream); | 415 | struct snd_sb *chip = snd_pcm_substream_chip(substream); |
363 | size_t ptr; | 416 | size_t ptr; |
417 | int dma; | ||
364 | 418 | ||
365 | if (chip->mode != SB_MODE_PLAYBACK_8) | 419 | if (chip->mode & SB_MODE_PLAYBACK_8) |
420 | dma = chip->dma8; | ||
421 | else if (chip->mode & SB_MODE_PLAYBACK_16) | ||
422 | dma = chip->dma16; | ||
423 | else | ||
366 | return 0; | 424 | return 0; |
367 | ptr = snd_dma_pointer(chip->dma8, chip->p_dma_size); | 425 | ptr = snd_dma_pointer(dma, chip->p_dma_size); |
368 | return bytes_to_frames(substream->runtime, ptr); | 426 | return bytes_to_frames(substream->runtime, ptr); |
369 | } | 427 | } |
370 | 428 | ||
@@ -372,10 +430,15 @@ static snd_pcm_uframes_t snd_sb8_capture_pointer(struct snd_pcm_substream *subst | |||
372 | { | 430 | { |
373 | struct snd_sb *chip = snd_pcm_substream_chip(substream); | 431 | struct snd_sb *chip = snd_pcm_substream_chip(substream); |
374 | size_t ptr; | 432 | size_t ptr; |
433 | int dma; | ||
375 | 434 | ||
376 | if (chip->mode != SB_MODE_CAPTURE_8) | 435 | if (chip->mode & SB_MODE_CAPTURE_8) |
436 | dma = chip->dma8; | ||
437 | else if (chip->mode & SB_MODE_CAPTURE_16) | ||
438 | dma = chip->dma16; | ||
439 | else | ||
377 | return 0; | 440 | return 0; |
378 | ptr = snd_dma_pointer(chip->dma8, chip->c_dma_size); | 441 | ptr = snd_dma_pointer(dma, chip->c_dma_size); |
379 | return bytes_to_frames(substream->runtime, ptr); | 442 | return bytes_to_frames(substream->runtime, ptr); |
380 | } | 443 | } |
381 | 444 | ||
@@ -446,6 +509,13 @@ static int snd_sb8_open(struct snd_pcm_substream *substream) | |||
446 | runtime->hw = snd_sb8_capture; | 509 | runtime->hw = snd_sb8_capture; |
447 | } | 510 | } |
448 | switch (chip->hardware) { | 511 | switch (chip->hardware) { |
512 | case SB_HW_JAZZ16: | ||
513 | runtime->hw.formats |= SNDRV_PCM_FMTBIT_S16_LE; | ||
514 | runtime->hw.rates |= SNDRV_PCM_RATE_8000_48000; | ||
515 | runtime->hw.rate_min = 4000; | ||
516 | runtime->hw.rate_max = 50000; | ||
517 | runtime->hw.channels_max = 2; | ||
518 | break; | ||
449 | case SB_HW_PRO: | 519 | case SB_HW_PRO: |
450 | runtime->hw.rate_max = 44100; | 520 | runtime->hw.rate_max = 44100; |
451 | runtime->hw.channels_max = 2; | 521 | runtime->hw.channels_max = 2; |
@@ -468,6 +538,14 @@ static int snd_sb8_open(struct snd_pcm_substream *substream) | |||
468 | } | 538 | } |
469 | snd_pcm_hw_constraint_ratnums(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, | 539 | snd_pcm_hw_constraint_ratnums(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, |
470 | &hw_constraints_clock); | 540 | &hw_constraints_clock); |
541 | if (chip->dma8 > 3 || chip->dma16 >= 0) { | ||
542 | snd_pcm_hw_constraint_step(runtime, 0, | ||
543 | SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 2); | ||
544 | snd_pcm_hw_constraint_step(runtime, 0, | ||
545 | SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 2); | ||
546 | runtime->hw.buffer_bytes_max = 128 * 1024 * 1024; | ||
547 | runtime->hw.period_bytes_max = 128 * 1024 * 1024; | ||
548 | } | ||
471 | return 0; | 549 | return 0; |
472 | } | 550 | } |
473 | 551 | ||
@@ -480,6 +558,10 @@ static int snd_sb8_close(struct snd_pcm_substream *substream) | |||
480 | chip->capture_substream = NULL; | 558 | chip->capture_substream = NULL; |
481 | spin_lock_irqsave(&chip->open_lock, flags); | 559 | spin_lock_irqsave(&chip->open_lock, flags); |
482 | chip->open &= ~SB_OPEN_PCM; | 560 | chip->open &= ~SB_OPEN_PCM; |
561 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | ||
562 | chip->mode &= ~SB_MODE_PLAYBACK; | ||
563 | else | ||
564 | chip->mode &= ~SB_MODE_CAPTURE; | ||
483 | spin_unlock_irqrestore(&chip->open_lock, flags); | 565 | spin_unlock_irqrestore(&chip->open_lock, flags); |
484 | return 0; | 566 | return 0; |
485 | } | 567 | } |
@@ -515,6 +597,7 @@ int snd_sb8dsp_pcm(struct snd_sb *chip, int device, struct snd_pcm ** rpcm) | |||
515 | struct snd_card *card = chip->card; | 597 | struct snd_card *card = chip->card; |
516 | struct snd_pcm *pcm; | 598 | struct snd_pcm *pcm; |
517 | int err; | 599 | int err; |
600 | size_t max_prealloc = 64 * 1024; | ||
518 | 601 | ||
519 | if (rpcm) | 602 | if (rpcm) |
520 | *rpcm = NULL; | 603 | *rpcm = NULL; |
@@ -527,9 +610,11 @@ int snd_sb8dsp_pcm(struct snd_sb *chip, int device, struct snd_pcm ** rpcm) | |||
527 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_sb8_playback_ops); | 610 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_sb8_playback_ops); |
528 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_sb8_capture_ops); | 611 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_sb8_capture_ops); |
529 | 612 | ||
613 | if (chip->dma8 > 3 || chip->dma16 >= 0) | ||
614 | max_prealloc = 128 * 1024; | ||
530 | snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, | 615 | snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, |
531 | snd_dma_isa_data(), | 616 | snd_dma_isa_data(), |
532 | 64*1024, 64*1024); | 617 | 64*1024, max_prealloc); |
533 | 618 | ||
534 | if (rpcm) | 619 | if (rpcm) |
535 | *rpcm = pcm; | 620 | *rpcm = pcm; |