Lines Matching defs:chip
14 * Note: Some chip revisions have hardware bug. Changing capture
16 * 16bit DMA transfers from DSP chip (capture) until 8bit transfer
17 * to DSP chip (playback) starts. This bug can be avoided with
41 static void snd_sb16_csp_playback_prepare(struct snd_sb *chip, struct snd_pcm_runtime *runtime)
43 if (chip->hardware == SB_HW_16CSP) {
44 struct snd_sb_csp *csp = chip->csp;
74 if (csp->ops.csp_start(csp, (chip->mode & SB_MODE_PLAYBACK_16) ?
82 chip->open = SNDRV_SB_CSP_MODE_DSP_WRITE;
89 static void snd_sb16_csp_capture_prepare(struct snd_sb *chip, struct snd_pcm_runtime *runtime)
91 if (chip->hardware == SB_HW_16CSP) {
92 struct snd_sb_csp *csp = chip->csp;
112 if (csp->ops.csp_start(csp, (chip->mode & SB_MODE_CAPTURE_16) ?
120 chip->open = SNDRV_SB_CSP_MODE_DSP_READ;
127 static void snd_sb16_csp_update(struct snd_sb *chip)
129 if (chip->hardware == SB_HW_16CSP) {
130 struct snd_sb_csp *csp = chip->csp;
133 spin_lock(&chip->reg_lock);
135 spin_unlock(&chip->reg_lock);
140 static void snd_sb16_csp_playback_open(struct snd_sb *chip, struct snd_pcm_runtime *runtime)
143 if (chip->hardware == SB_HW_16CSP) {
144 struct snd_sb_csp *csp = chip->csp;
159 static void snd_sb16_csp_playback_close(struct snd_sb *chip)
161 if ((chip->hardware == SB_HW_16CSP) && (chip->open == SNDRV_SB_CSP_MODE_DSP_WRITE)) {
162 struct snd_sb_csp *csp = chip->csp;
166 chip->open = 0;
171 static void snd_sb16_csp_capture_open(struct snd_sb *chip, struct snd_pcm_runtime *runtime)
174 if (chip->hardware == SB_HW_16CSP) {
175 struct snd_sb_csp *csp = chip->csp;
190 static void snd_sb16_csp_capture_close(struct snd_sb *chip)
192 if ((chip->hardware == SB_HW_16CSP) && (chip->open == SNDRV_SB_CSP_MODE_DSP_READ)) {
193 struct snd_sb_csp *csp = chip->csp;
197 chip->open = 0;
202 #define snd_sb16_csp_playback_prepare(chip, runtime) /*nop*/
203 #define snd_sb16_csp_capture_prepare(chip, runtime) /*nop*/
204 #define snd_sb16_csp_update(chip) /*nop*/
205 #define snd_sb16_csp_playback_open(chip, runtime) /*nop*/
206 #define snd_sb16_csp_playback_close(chip) /*nop*/
207 #define snd_sb16_csp_capture_open(chip, runtime) /*nop*/
208 #define snd_sb16_csp_capture_close(chip) /*nop*/
212 static void snd_sb16_setup_rate(struct snd_sb *chip,
218 spin_lock_irqsave(&chip->reg_lock, flags);
219 if (chip->mode & (channel == SNDRV_PCM_STREAM_PLAYBACK ? SB_MODE_PLAYBACK_16 : SB_MODE_CAPTURE_16))
220 snd_sb_ack_16bit(chip);
222 snd_sb_ack_8bit(chip);
223 if (!(chip->mode & SB_RATE_LOCK)) {
224 chip->locked_rate = rate;
225 snd_sbdsp_command(chip, SB_DSP_SAMPLE_RATE_IN);
226 snd_sbdsp_command(chip, rate >> 8);
227 snd_sbdsp_command(chip, rate & 0xff);
228 snd_sbdsp_command(chip, SB_DSP_SAMPLE_RATE_OUT);
229 snd_sbdsp_command(chip, rate >> 8);
230 snd_sbdsp_command(chip, rate & 0xff);
232 spin_unlock_irqrestore(&chip->reg_lock, flags);
238 struct snd_sb *chip = snd_pcm_substream_chip(substream);
243 snd_sb16_csp_playback_prepare(chip, runtime);
250 snd_sb16_setup_rate(chip, runtime->rate, SNDRV_PCM_STREAM_PLAYBACK);
251 size = chip->p_dma_size = snd_pcm_lib_buffer_bytes(substream);
252 dma = (chip->mode & SB_MODE_PLAYBACK_8) ? chip->dma8 : chip->dma16;
256 spin_lock_irqsave(&chip->reg_lock, flags);
257 if (chip->mode & SB_MODE_PLAYBACK_16) {
260 snd_sbdsp_command(chip, SB_DSP4_OUT16_AI);
261 snd_sbdsp_command(chip, format);
262 snd_sbdsp_command(chip, count & 0xff);
263 snd_sbdsp_command(chip, count >> 8);
264 snd_sbdsp_command(chip, SB_DSP_DMA16_OFF);
267 snd_sbdsp_command(chip, SB_DSP4_OUT8_AI);
268 snd_sbdsp_command(chip, format);
269 snd_sbdsp_command(chip, count & 0xff);
270 snd_sbdsp_command(chip, count >> 8);
271 snd_sbdsp_command(chip, SB_DSP_DMA8_OFF);
273 spin_unlock_irqrestore(&chip->reg_lock, flags);
280 struct snd_sb *chip = snd_pcm_substream_chip(substream);
283 spin_lock(&chip->reg_lock);
287 chip->mode |= SB_RATE_LOCK_PLAYBACK;
288 snd_sbdsp_command(chip, chip->mode & SB_MODE_PLAYBACK_16 ? SB_DSP_DMA16_ON : SB_DSP_DMA8_ON);
292 snd_sbdsp_command(chip, chip->mode & SB_MODE_PLAYBACK_16 ? SB_DSP_DMA16_OFF : SB_DSP_DMA8_OFF);
294 if (chip->mode & SB_RATE_LOCK_CAPTURE)
295 snd_sbdsp_command(chip, chip->mode & SB_MODE_CAPTURE_16 ? SB_DSP_DMA16_ON : SB_DSP_DMA8_ON);
296 chip->mode &= ~SB_RATE_LOCK_PLAYBACK;
301 spin_unlock(&chip->reg_lock);
308 struct snd_sb *chip = snd_pcm_substream_chip(substream);
313 snd_sb16_csp_capture_prepare(chip, runtime);
319 snd_sb16_setup_rate(chip, runtime->rate, SNDRV_PCM_STREAM_CAPTURE);
320 size = chip->c_dma_size = snd_pcm_lib_buffer_bytes(substream);
321 dma = (chip->mode & SB_MODE_CAPTURE_8) ? chip->dma8 : chip->dma16;
325 spin_lock_irqsave(&chip->reg_lock, flags);
326 if (chip->mode & SB_MODE_CAPTURE_16) {
329 snd_sbdsp_command(chip, SB_DSP4_IN16_AI);
330 snd_sbdsp_command(chip, format);
331 snd_sbdsp_command(chip, count & 0xff);
332 snd_sbdsp_command(chip, count >> 8);
333 snd_sbdsp_command(chip, SB_DSP_DMA16_OFF);
336 snd_sbdsp_command(chip, SB_DSP4_IN8_AI);
337 snd_sbdsp_command(chip, format);
338 snd_sbdsp_command(chip, count & 0xff);
339 snd_sbdsp_command(chip, count >> 8);
340 snd_sbdsp_command(chip, SB_DSP_DMA8_OFF);
342 spin_unlock_irqrestore(&chip->reg_lock, flags);
349 struct snd_sb *chip = snd_pcm_substream_chip(substream);
352 spin_lock(&chip->reg_lock);
356 chip->mode |= SB_RATE_LOCK_CAPTURE;
357 snd_sbdsp_command(chip, chip->mode & SB_MODE_CAPTURE_16 ? SB_DSP_DMA16_ON : SB_DSP_DMA8_ON);
361 snd_sbdsp_command(chip, chip->mode & SB_MODE_CAPTURE_16 ? SB_DSP_DMA16_OFF : SB_DSP_DMA8_OFF);
363 if (chip->mode & SB_RATE_LOCK_PLAYBACK)
364 snd_sbdsp_command(chip, chip->mode & SB_MODE_PLAYBACK_16 ? SB_DSP_DMA16_ON : SB_DSP_DMA8_ON);
365 chip->mode &= ~SB_RATE_LOCK_CAPTURE;
370 spin_unlock(&chip->reg_lock);
376 struct snd_sb *chip = dev_id;
380 spin_lock(&chip->mixer_lock);
381 status = snd_sbmixer_read(chip, SB_DSP4_IRQSTATUS);
382 spin_unlock(&chip->mixer_lock);
383 if ((status & SB_IRQTYPE_MPUIN) && chip->rmidi_callback)
384 chip->rmidi_callback(irq, chip->rmidi->private_data);
387 if (chip->mode & SB_MODE_PLAYBACK_8) {
388 snd_pcm_period_elapsed(chip->playback_substream);
389 snd_sb16_csp_update(chip);
392 if (chip->mode & SB_MODE_CAPTURE_8) {
393 snd_pcm_period_elapsed(chip->capture_substream);
396 spin_lock(&chip->reg_lock);
398 snd_sbdsp_command(chip, SB_DSP_DMA8_OFF);
399 snd_sb_ack_8bit(chip);
400 spin_unlock(&chip->reg_lock);
404 if (chip->mode & SB_MODE_PLAYBACK_16) {
405 snd_pcm_period_elapsed(chip->playback_substream);
406 snd_sb16_csp_update(chip);
409 if (chip->mode & SB_MODE_CAPTURE_16) {
410 snd_pcm_period_elapsed(chip->capture_substream);
413 spin_lock(&chip->reg_lock);
415 snd_sbdsp_command(chip, SB_DSP_DMA16_OFF);
416 snd_sb_ack_16bit(chip);
417 spin_unlock(&chip->reg_lock);
428 struct snd_sb *chip = snd_pcm_substream_chip(substream);
432 dma = (chip->mode & SB_MODE_PLAYBACK_8) ? chip->dma8 : chip->dma16;
433 ptr = snd_dma_pointer(dma, chip->p_dma_size);
439 struct snd_sb *chip = snd_pcm_substream_chip(substream);
443 dma = (chip->mode & SB_MODE_CAPTURE_8) ? chip->dma8 : chip->dma16;
444 ptr = snd_dma_pointer(dma, chip->c_dma_size);
495 struct snd_sb *chip = snd_pcm_substream_chip(substream);
498 spin_lock_irqsave(&chip->open_lock, flags);
499 if (chip->mode & SB_MODE_PLAYBACK) {
500 spin_unlock_irqrestore(&chip->open_lock, flags);
506 if (chip->force_mode16 & SB_MODE_CAPTURE_16)
509 if (chip->dma16 >= 0 && !(chip->mode & SB_MODE_CAPTURE_16)) {
510 chip->mode |= SB_MODE_PLAYBACK_16;
513 if (chip->dma16 <= 3) {
517 snd_sb16_csp_playback_open(chip, runtime);
523 if (chip->dma8 >= 0 && !(chip->mode & SB_MODE_CAPTURE_8)) {
524 chip->mode |= SB_MODE_PLAYBACK_8;
526 if (chip->dma16 < 0) {
528 chip->mode |= SB_MODE_PLAYBACK_16;
536 spin_unlock_irqrestore(&chip->open_lock, flags);
540 if (chip->hardware == SB_HW_ALS100)
542 if (chip->hardware == SB_HW_CS5530) {
547 if (chip->mode & SB_RATE_LOCK)
548 runtime->hw.rate_min = runtime->hw.rate_max = chip->locked_rate;
549 chip->playback_substream = substream;
550 spin_unlock_irqrestore(&chip->open_lock, flags);
557 struct snd_sb *chip = snd_pcm_substream_chip(substream);
559 snd_sb16_csp_playback_close(chip);
560 spin_lock_irqsave(&chip->open_lock, flags);
561 chip->playback_substream = NULL;
562 chip->mode &= ~SB_MODE_PLAYBACK;
563 spin_unlock_irqrestore(&chip->open_lock, flags);
570 struct snd_sb *chip = snd_pcm_substream_chip(substream);
573 spin_lock_irqsave(&chip->open_lock, flags);
574 if (chip->mode & SB_MODE_CAPTURE) {
575 spin_unlock_irqrestore(&chip->open_lock, flags);
581 if (chip->force_mode16 & SB_MODE_PLAYBACK_16)
584 if (chip->dma16 >= 0 && !(chip->mode & SB_MODE_PLAYBACK_16)) {
585 chip->mode |= SB_MODE_CAPTURE_16;
588 if (chip->dma16 <= 3) {
592 snd_sb16_csp_capture_open(chip, runtime);
598 if (chip->dma8 >= 0 && !(chip->mode & SB_MODE_PLAYBACK_8)) {
599 chip->mode |= SB_MODE_CAPTURE_8;
601 if (chip->dma16 < 0) {
603 chip->mode |= SB_MODE_CAPTURE_16;
611 spin_unlock_irqrestore(&chip->open_lock, flags);
615 if (chip->hardware == SB_HW_ALS100)
617 if (chip->hardware == SB_HW_CS5530) {
622 if (chip->mode & SB_RATE_LOCK)
623 runtime->hw.rate_min = runtime->hw.rate_max = chip->locked_rate;
624 chip->capture_substream = substream;
625 spin_unlock_irqrestore(&chip->open_lock, flags);
632 struct snd_sb *chip = snd_pcm_substream_chip(substream);
634 snd_sb16_csp_capture_close(chip);
635 spin_lock_irqsave(&chip->open_lock, flags);
636 chip->capture_substream = NULL;
637 chip->mode &= ~SB_MODE_CAPTURE;
638 spin_unlock_irqrestore(&chip->open_lock, flags);
646 static int snd_sb16_set_dma_mode(struct snd_sb *chip, int what)
648 if (chip->dma8 < 0 || chip->dma16 < 0) {
654 chip->force_mode16 = 0;
656 chip->force_mode16 = SB_MODE_PLAYBACK_16;
658 chip->force_mode16 = SB_MODE_CAPTURE_16;
665 static int snd_sb16_get_dma_mode(struct snd_sb *chip)
667 if (chip->dma8 < 0 || chip->dma16 < 0)
669 switch (chip->force_mode16) {
690 struct snd_sb *chip = snd_kcontrol_chip(kcontrol);
693 spin_lock_irqsave(&chip->reg_lock, flags);
694 ucontrol->value.enumerated.item[0] = snd_sb16_get_dma_mode(chip);
695 spin_unlock_irqrestore(&chip->reg_lock, flags);
701 struct snd_sb *chip = snd_kcontrol_chip(kcontrol);
706 if (chip->mode & (SB_MODE_PLAYBACK | SB_MODE_CAPTURE))
712 spin_lock_irqsave(&chip->reg_lock, flags);
713 oval = snd_sb16_get_dma_mode(chip);
715 snd_sb16_set_dma_mode(chip, nval);
716 spin_unlock_irqrestore(&chip->reg_lock, flags);
718 snd_dma_disable(chip->dma8);
719 snd_dma_disable(chip->dma16);
736 int snd_sb16dsp_configure(struct snd_sb * chip)
743 spin_lock_irqsave(&chip->mixer_lock, flags);
744 mpureg = snd_sbmixer_read(chip, SB_DSP4_MPUSETUP) & ~0x06;
745 spin_unlock_irqrestore(&chip->mixer_lock, flags);
746 switch (chip->irq) {
763 if (chip->dma8 >= 0) {
764 switch (chip->dma8) {
778 if (chip->dma16 >= 0 && chip->dma16 != chip->dma8) {
779 switch (chip->dma16) {
793 switch (chip->mpu_port) {
803 spin_lock_irqsave(&chip->mixer_lock, flags);
805 snd_sbmixer_write(chip, SB_DSP4_IRQSETUP, irqreg);
806 realirq = snd_sbmixer_read(chip, SB_DSP4_IRQSETUP);
808 snd_sbmixer_write(chip, SB_DSP4_DMASETUP, dmareg);
809 realdma = snd_sbmixer_read(chip, SB_DSP4_DMASETUP);
811 snd_sbmixer_write(chip, SB_DSP4_MPUSETUP, mpureg);
812 realmpureg = snd_sbmixer_read(chip, SB_DSP4_MPUSETUP);
814 spin_unlock_irqrestore(&chip->mixer_lock, flags);
816 dev_err(chip->card->dev,
818 chip->port);
819 dev_err(chip->card->dev,
821 chip->port, realirq, realdma, realmpureg);
822 dev_err(chip->card->dev,
824 chip->port, irqreg, dmareg, mpureg);
846 int snd_sb16dsp_pcm(struct snd_sb *chip, int device)
848 struct snd_card *card = chip->card;
855 sprintf(pcm->name, "DSP v%i.%i", chip->version >> 8, chip->version & 0xff);
857 pcm->private_data = chip;
858 chip->pcm = pcm;
863 if (chip->dma16 >= 0 && chip->dma8 != chip->dma16)
864 snd_ctl_add(card, snd_ctl_new1(&snd_sb16_dma_control, chip));