Lines Matching full:chip
128 #define CS4231U(chip, x) ((chip)->port + ((c_d_c_CS4231##x) << 2)) argument
174 #define APC_CHIP_RESET 0x01 /* Reset the chip */
277 static void snd_cs4231_ready(struct snd_cs4231 *chip) in snd_cs4231_ready() argument
282 int val = __cs4231_readb(chip, CS4231U(chip, REGSEL)); in snd_cs4231_ready()
289 static void snd_cs4231_dout(struct snd_cs4231 *chip, unsigned char reg, in snd_cs4231_dout() argument
292 snd_cs4231_ready(chip); in snd_cs4231_dout()
294 if (__cs4231_readb(chip, CS4231U(chip, REGSEL)) & CS4231_INIT) in snd_cs4231_dout()
295 dev_dbg(chip->card->dev, in snd_cs4231_dout()
299 __cs4231_writeb(chip, chip->mce_bit | reg, CS4231U(chip, REGSEL)); in snd_cs4231_dout()
301 __cs4231_writeb(chip, value, CS4231U(chip, REG)); in snd_cs4231_dout()
305 static inline void snd_cs4231_outm(struct snd_cs4231 *chip, unsigned char reg, in snd_cs4231_outm() argument
308 unsigned char tmp = (chip->image[reg] & mask) | value; in snd_cs4231_outm()
310 chip->image[reg] = tmp; in snd_cs4231_outm()
311 if (!chip->calibrate_mute) in snd_cs4231_outm()
312 snd_cs4231_dout(chip, reg, tmp); in snd_cs4231_outm()
315 static void snd_cs4231_out(struct snd_cs4231 *chip, unsigned char reg, in snd_cs4231_out() argument
318 snd_cs4231_dout(chip, reg, value); in snd_cs4231_out()
319 chip->image[reg] = value; in snd_cs4231_out()
323 static unsigned char snd_cs4231_in(struct snd_cs4231 *chip, unsigned char reg) in snd_cs4231_in() argument
325 snd_cs4231_ready(chip); in snd_cs4231_in()
327 if (__cs4231_readb(chip, CS4231U(chip, REGSEL)) & CS4231_INIT) in snd_cs4231_in()
328 dev_dbg(chip->card->dev, in snd_cs4231_in()
332 __cs4231_writeb(chip, chip->mce_bit | reg, CS4231U(chip, REGSEL)); in snd_cs4231_in()
334 return __cs4231_readb(chip, CS4231U(chip, REG)); in snd_cs4231_in()
341 static void snd_cs4231_busy_wait(struct snd_cs4231 *chip) in snd_cs4231_busy_wait() argument
345 /* looks like this sequence is proper for CS4231A chip (GUS MAX) */ in snd_cs4231_busy_wait()
347 __cs4231_readb(chip, CS4231U(chip, REGSEL)); in snd_cs4231_busy_wait()
351 int val = __cs4231_readb(chip, CS4231U(chip, REGSEL)); in snd_cs4231_busy_wait()
358 static void snd_cs4231_mce_up(struct snd_cs4231 *chip) in snd_cs4231_mce_up() argument
363 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_mce_up()
364 snd_cs4231_ready(chip); in snd_cs4231_mce_up()
366 if (__cs4231_readb(chip, CS4231U(chip, REGSEL)) & CS4231_INIT) in snd_cs4231_mce_up()
367 dev_dbg(chip->card->dev, in snd_cs4231_mce_up()
370 chip->mce_bit |= CS4231_MCE; in snd_cs4231_mce_up()
371 timeout = __cs4231_readb(chip, CS4231U(chip, REGSEL)); in snd_cs4231_mce_up()
373 dev_dbg(chip->card->dev, in snd_cs4231_mce_up()
375 chip->port); in snd_cs4231_mce_up()
377 __cs4231_writeb(chip, chip->mce_bit | (timeout & 0x1f), in snd_cs4231_mce_up()
378 CS4231U(chip, REGSEL)); in snd_cs4231_mce_up()
379 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_mce_up()
382 static void snd_cs4231_mce_down(struct snd_cs4231 *chip) in snd_cs4231_mce_down() argument
387 snd_cs4231_busy_wait(chip); in snd_cs4231_mce_down()
388 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_mce_down()
390 if (__cs4231_readb(chip, CS4231U(chip, REGSEL)) & CS4231_INIT) in snd_cs4231_mce_down()
391 dev_dbg(chip->card->dev, in snd_cs4231_mce_down()
393 CS4231U(chip, REGSEL)); in snd_cs4231_mce_down()
395 chip->mce_bit &= ~CS4231_MCE; in snd_cs4231_mce_down()
396 reg = __cs4231_readb(chip, CS4231U(chip, REGSEL)); in snd_cs4231_mce_down()
397 __cs4231_writeb(chip, chip->mce_bit | (reg & 0x1f), in snd_cs4231_mce_down()
398 CS4231U(chip, REGSEL)); in snd_cs4231_mce_down()
400 dev_dbg(chip->card->dev, in snd_cs4231_mce_down()
402 chip->port); in snd_cs4231_mce_down()
404 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_mce_down()
413 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_mce_down()
415 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_mce_down()
416 reg = snd_cs4231_in(chip, CS4231_TEST_INIT); in snd_cs4231_mce_down()
419 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_mce_down()
422 dev_err(chip->card->dev, in snd_cs4231_mce_down()
449 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); in cs4231_dma_trigger() local
453 dma_cont = &chip->p_dma; in cs4231_dma_trigger()
458 chip->playback_substream, in cs4231_dma_trigger()
459 &chip->p_periods_sent); in cs4231_dma_trigger()
465 dma_cont = &chip->c_dma; in cs4231_dma_trigger()
470 chip->capture_substream, in cs4231_dma_trigger()
471 &chip->c_periods_sent); in cs4231_dma_trigger()
480 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); in snd_cs4231_trigger() local
492 if (s == chip->playback_substream) { in snd_cs4231_trigger()
495 } else if (s == chip->capture_substream) { in snd_cs4231_trigger()
501 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_trigger()
504 chip->image[CS4231_IFACE_CTRL] |= what; in snd_cs4231_trigger()
507 chip->image[CS4231_IFACE_CTRL] &= ~what; in snd_cs4231_trigger()
509 snd_cs4231_out(chip, CS4231_IFACE_CTRL, in snd_cs4231_trigger()
510 chip->image[CS4231_IFACE_CTRL]); in snd_cs4231_trigger()
511 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_trigger()
537 static unsigned char snd_cs4231_get_format(struct snd_cs4231 *chip, int format, in snd_cs4231_get_format() argument
565 static void snd_cs4231_calibrate_mute(struct snd_cs4231 *chip, int mute) in snd_cs4231_calibrate_mute() argument
570 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_calibrate_mute()
571 if (chip->calibrate_mute == mute) { in snd_cs4231_calibrate_mute()
572 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_calibrate_mute()
576 snd_cs4231_dout(chip, CS4231_LEFT_INPUT, in snd_cs4231_calibrate_mute()
577 chip->image[CS4231_LEFT_INPUT]); in snd_cs4231_calibrate_mute()
578 snd_cs4231_dout(chip, CS4231_RIGHT_INPUT, in snd_cs4231_calibrate_mute()
579 chip->image[CS4231_RIGHT_INPUT]); in snd_cs4231_calibrate_mute()
580 snd_cs4231_dout(chip, CS4231_LOOPBACK, in snd_cs4231_calibrate_mute()
581 chip->image[CS4231_LOOPBACK]); in snd_cs4231_calibrate_mute()
583 snd_cs4231_dout(chip, CS4231_AUX1_LEFT_INPUT, in snd_cs4231_calibrate_mute()
584 mute ? 0x80 : chip->image[CS4231_AUX1_LEFT_INPUT]); in snd_cs4231_calibrate_mute()
585 snd_cs4231_dout(chip, CS4231_AUX1_RIGHT_INPUT, in snd_cs4231_calibrate_mute()
586 mute ? 0x80 : chip->image[CS4231_AUX1_RIGHT_INPUT]); in snd_cs4231_calibrate_mute()
587 snd_cs4231_dout(chip, CS4231_AUX2_LEFT_INPUT, in snd_cs4231_calibrate_mute()
588 mute ? 0x80 : chip->image[CS4231_AUX2_LEFT_INPUT]); in snd_cs4231_calibrate_mute()
589 snd_cs4231_dout(chip, CS4231_AUX2_RIGHT_INPUT, in snd_cs4231_calibrate_mute()
590 mute ? 0x80 : chip->image[CS4231_AUX2_RIGHT_INPUT]); in snd_cs4231_calibrate_mute()
591 snd_cs4231_dout(chip, CS4231_LEFT_OUTPUT, in snd_cs4231_calibrate_mute()
592 mute ? 0x80 : chip->image[CS4231_LEFT_OUTPUT]); in snd_cs4231_calibrate_mute()
593 snd_cs4231_dout(chip, CS4231_RIGHT_OUTPUT, in snd_cs4231_calibrate_mute()
594 mute ? 0x80 : chip->image[CS4231_RIGHT_OUTPUT]); in snd_cs4231_calibrate_mute()
595 snd_cs4231_dout(chip, CS4231_LEFT_LINE_IN, in snd_cs4231_calibrate_mute()
596 mute ? 0x80 : chip->image[CS4231_LEFT_LINE_IN]); in snd_cs4231_calibrate_mute()
597 snd_cs4231_dout(chip, CS4231_RIGHT_LINE_IN, in snd_cs4231_calibrate_mute()
598 mute ? 0x80 : chip->image[CS4231_RIGHT_LINE_IN]); in snd_cs4231_calibrate_mute()
599 snd_cs4231_dout(chip, CS4231_MONO_CTRL, in snd_cs4231_calibrate_mute()
600 mute ? 0xc0 : chip->image[CS4231_MONO_CTRL]); in snd_cs4231_calibrate_mute()
601 chip->calibrate_mute = mute; in snd_cs4231_calibrate_mute()
602 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_calibrate_mute()
605 static void snd_cs4231_playback_format(struct snd_cs4231 *chip, in snd_cs4231_playback_format() argument
611 mutex_lock(&chip->mce_mutex); in snd_cs4231_playback_format()
612 snd_cs4231_calibrate_mute(chip, 1); in snd_cs4231_playback_format()
614 snd_cs4231_mce_up(chip); in snd_cs4231_playback_format()
616 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_playback_format()
617 snd_cs4231_out(chip, CS4231_PLAYBK_FORMAT, in snd_cs4231_playback_format()
618 (chip->image[CS4231_IFACE_CTRL] & CS4231_RECORD_ENABLE) ? in snd_cs4231_playback_format()
619 (pdfr & 0xf0) | (chip->image[CS4231_REC_FORMAT] & 0x0f) : in snd_cs4231_playback_format()
621 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_playback_format()
623 snd_cs4231_mce_down(chip); in snd_cs4231_playback_format()
625 snd_cs4231_calibrate_mute(chip, 0); in snd_cs4231_playback_format()
626 mutex_unlock(&chip->mce_mutex); in snd_cs4231_playback_format()
629 static void snd_cs4231_capture_format(struct snd_cs4231 *chip, in snd_cs4231_capture_format() argument
635 mutex_lock(&chip->mce_mutex); in snd_cs4231_capture_format()
636 snd_cs4231_calibrate_mute(chip, 1); in snd_cs4231_capture_format()
638 snd_cs4231_mce_up(chip); in snd_cs4231_capture_format()
640 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_capture_format()
641 if (!(chip->image[CS4231_IFACE_CTRL] & CS4231_PLAYBACK_ENABLE)) { in snd_cs4231_capture_format()
642 snd_cs4231_out(chip, CS4231_PLAYBK_FORMAT, in snd_cs4231_capture_format()
643 ((chip->image[CS4231_PLAYBK_FORMAT]) & 0xf0) | in snd_cs4231_capture_format()
645 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_capture_format()
646 snd_cs4231_mce_down(chip); in snd_cs4231_capture_format()
647 snd_cs4231_mce_up(chip); in snd_cs4231_capture_format()
648 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_capture_format()
650 snd_cs4231_out(chip, CS4231_REC_FORMAT, cdfr); in snd_cs4231_capture_format()
651 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_capture_format()
653 snd_cs4231_mce_down(chip); in snd_cs4231_capture_format()
655 snd_cs4231_calibrate_mute(chip, 0); in snd_cs4231_capture_format()
656 mutex_unlock(&chip->mce_mutex); in snd_cs4231_capture_format()
665 struct snd_cs4231 *chip = snd_timer_chip(timer); in snd_cs4231_timer_resolution() local
667 return chip->image[CS4231_PLAYBK_FORMAT] & 1 ? 9969 : 9920; in snd_cs4231_timer_resolution()
674 struct snd_cs4231 *chip = snd_timer_chip(timer); in snd_cs4231_timer_start() local
676 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_timer_start()
678 if ((chip->image[CS4231_ALT_FEATURE_1] & CS4231_TIMER_ENABLE) == 0 || in snd_cs4231_timer_start()
679 (unsigned char)(ticks >> 8) != chip->image[CS4231_TIMER_HIGH] || in snd_cs4231_timer_start()
680 (unsigned char)ticks != chip->image[CS4231_TIMER_LOW]) { in snd_cs4231_timer_start()
681 snd_cs4231_out(chip, CS4231_TIMER_HIGH, in snd_cs4231_timer_start()
682 chip->image[CS4231_TIMER_HIGH] = in snd_cs4231_timer_start()
684 snd_cs4231_out(chip, CS4231_TIMER_LOW, in snd_cs4231_timer_start()
685 chip->image[CS4231_TIMER_LOW] = in snd_cs4231_timer_start()
687 snd_cs4231_out(chip, CS4231_ALT_FEATURE_1, in snd_cs4231_timer_start()
688 chip->image[CS4231_ALT_FEATURE_1] | in snd_cs4231_timer_start()
691 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_timer_start()
699 struct snd_cs4231 *chip = snd_timer_chip(timer); in snd_cs4231_timer_stop() local
701 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_timer_stop()
702 chip->image[CS4231_ALT_FEATURE_1] &= ~CS4231_TIMER_ENABLE; in snd_cs4231_timer_stop()
703 snd_cs4231_out(chip, CS4231_ALT_FEATURE_1, in snd_cs4231_timer_stop()
704 chip->image[CS4231_ALT_FEATURE_1]); in snd_cs4231_timer_stop()
705 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_timer_stop()
710 static void snd_cs4231_init(struct snd_cs4231 *chip) in snd_cs4231_init() argument
714 snd_cs4231_mce_down(chip); in snd_cs4231_init()
719 snd_cs4231_mce_up(chip); in snd_cs4231_init()
720 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_init()
721 chip->image[CS4231_IFACE_CTRL] &= ~(CS4231_PLAYBACK_ENABLE | in snd_cs4231_init()
726 chip->image[CS4231_IFACE_CTRL] |= CS4231_AUTOCALIB; in snd_cs4231_init()
727 snd_cs4231_out(chip, CS4231_IFACE_CTRL, chip->image[CS4231_IFACE_CTRL]); in snd_cs4231_init()
728 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_init()
729 snd_cs4231_mce_down(chip); in snd_cs4231_init()
735 snd_cs4231_mce_up(chip); in snd_cs4231_init()
736 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_init()
737 snd_cs4231_out(chip, CS4231_ALT_FEATURE_1, in snd_cs4231_init()
738 chip->image[CS4231_ALT_FEATURE_1]); in snd_cs4231_init()
739 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_init()
740 snd_cs4231_mce_down(chip); in snd_cs4231_init()
744 chip->image[CS4231_ALT_FEATURE_1]); in snd_cs4231_init()
747 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_init()
748 snd_cs4231_out(chip, CS4231_ALT_FEATURE_2, in snd_cs4231_init()
749 chip->image[CS4231_ALT_FEATURE_2]); in snd_cs4231_init()
750 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_init()
752 snd_cs4231_mce_up(chip); in snd_cs4231_init()
753 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_init()
754 snd_cs4231_out(chip, CS4231_PLAYBK_FORMAT, in snd_cs4231_init()
755 chip->image[CS4231_PLAYBK_FORMAT]); in snd_cs4231_init()
756 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_init()
757 snd_cs4231_mce_down(chip); in snd_cs4231_init()
763 snd_cs4231_mce_up(chip); in snd_cs4231_init()
764 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_init()
765 snd_cs4231_out(chip, CS4231_REC_FORMAT, chip->image[CS4231_REC_FORMAT]); in snd_cs4231_init()
766 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_init()
767 snd_cs4231_mce_down(chip); in snd_cs4231_init()
774 static int snd_cs4231_open(struct snd_cs4231 *chip, unsigned int mode) in snd_cs4231_open() argument
778 mutex_lock(&chip->open_mutex); in snd_cs4231_open()
779 if ((chip->mode & mode)) { in snd_cs4231_open()
780 mutex_unlock(&chip->open_mutex); in snd_cs4231_open()
783 if (chip->mode & CS4231_MODE_OPEN) { in snd_cs4231_open()
784 chip->mode |= mode; in snd_cs4231_open()
785 mutex_unlock(&chip->open_mutex); in snd_cs4231_open()
789 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_open()
790 snd_cs4231_out(chip, CS4231_IRQ_STATUS, CS4231_PLAYBACK_IRQ | in snd_cs4231_open()
793 snd_cs4231_out(chip, CS4231_IRQ_STATUS, 0); in snd_cs4231_open()
794 __cs4231_writeb(chip, 0, CS4231U(chip, STATUS)); /* clear IRQ */ in snd_cs4231_open()
795 __cs4231_writeb(chip, 0, CS4231U(chip, STATUS)); /* clear IRQ */ in snd_cs4231_open()
797 snd_cs4231_out(chip, CS4231_IRQ_STATUS, CS4231_PLAYBACK_IRQ | in snd_cs4231_open()
800 snd_cs4231_out(chip, CS4231_IRQ_STATUS, 0); in snd_cs4231_open()
802 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_open()
804 chip->mode = mode; in snd_cs4231_open()
805 mutex_unlock(&chip->open_mutex); in snd_cs4231_open()
809 static void snd_cs4231_close(struct snd_cs4231 *chip, unsigned int mode) in snd_cs4231_close() argument
813 mutex_lock(&chip->open_mutex); in snd_cs4231_close()
814 chip->mode &= ~mode; in snd_cs4231_close()
815 if (chip->mode & CS4231_MODE_OPEN) { in snd_cs4231_close()
816 mutex_unlock(&chip->open_mutex); in snd_cs4231_close()
819 snd_cs4231_calibrate_mute(chip, 1); in snd_cs4231_close()
822 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_close()
823 snd_cs4231_out(chip, CS4231_IRQ_STATUS, 0); in snd_cs4231_close()
824 __cs4231_writeb(chip, 0, CS4231U(chip, STATUS)); /* clear IRQ */ in snd_cs4231_close()
825 __cs4231_writeb(chip, 0, CS4231U(chip, STATUS)); /* clear IRQ */ in snd_cs4231_close()
829 if (chip->image[CS4231_IFACE_CTRL] & in snd_cs4231_close()
832 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_close()
833 snd_cs4231_mce_up(chip); in snd_cs4231_close()
834 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_close()
835 chip->image[CS4231_IFACE_CTRL] &= in snd_cs4231_close()
838 snd_cs4231_out(chip, CS4231_IFACE_CTRL, in snd_cs4231_close()
839 chip->image[CS4231_IFACE_CTRL]); in snd_cs4231_close()
840 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_close()
841 snd_cs4231_mce_down(chip); in snd_cs4231_close()
842 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_close()
846 snd_cs4231_out(chip, CS4231_IRQ_STATUS, 0); in snd_cs4231_close()
847 __cs4231_writeb(chip, 0, CS4231U(chip, STATUS)); /* clear IRQ */ in snd_cs4231_close()
848 __cs4231_writeb(chip, 0, CS4231U(chip, STATUS)); /* clear IRQ */ in snd_cs4231_close()
849 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_close()
851 snd_cs4231_calibrate_mute(chip, 0); in snd_cs4231_close()
853 chip->mode = 0; in snd_cs4231_close()
854 mutex_unlock(&chip->open_mutex); in snd_cs4231_close()
863 struct snd_cs4231 *chip = snd_timer_chip(timer); in snd_cs4231_timer_open() local
864 snd_cs4231_open(chip, CS4231_MODE_TIMER); in snd_cs4231_timer_open()
870 struct snd_cs4231 *chip = snd_timer_chip(timer); in snd_cs4231_timer_close() local
871 snd_cs4231_close(chip, CS4231_MODE_TIMER); in snd_cs4231_timer_close()
893 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); in snd_cs4231_playback_hw_params() local
896 new_pdfr = snd_cs4231_get_format(chip, params_format(hw_params), in snd_cs4231_playback_hw_params()
899 snd_cs4231_playback_format(chip, hw_params, new_pdfr); in snd_cs4231_playback_hw_params()
906 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); in snd_cs4231_playback_prepare() local
911 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_playback_prepare()
913 chip->image[CS4231_IFACE_CTRL] &= ~(CS4231_PLAYBACK_ENABLE | in snd_cs4231_playback_prepare()
921 chip->p_periods_sent = 0; in snd_cs4231_playback_prepare()
924 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_playback_prepare()
932 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); in snd_cs4231_capture_hw_params() local
935 new_cdfr = snd_cs4231_get_format(chip, params_format(hw_params), in snd_cs4231_capture_hw_params()
938 snd_cs4231_capture_format(chip, hw_params, new_cdfr); in snd_cs4231_capture_hw_params()
945 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); in snd_cs4231_capture_prepare() local
948 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_capture_prepare()
949 chip->image[CS4231_IFACE_CTRL] &= ~(CS4231_RECORD_ENABLE | in snd_cs4231_capture_prepare()
953 chip->c_periods_sent = 0; in snd_cs4231_capture_prepare()
954 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_capture_prepare()
959 static void snd_cs4231_overrange(struct snd_cs4231 *chip) in snd_cs4231_overrange() argument
964 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_overrange()
965 res = snd_cs4231_in(chip, CS4231_TEST_INIT); in snd_cs4231_overrange()
966 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_overrange()
970 chip->capture_substream->runtime->overrange++; in snd_cs4231_overrange()
973 static void snd_cs4231_play_callback(struct snd_cs4231 *chip) in snd_cs4231_play_callback() argument
975 if (chip->image[CS4231_IFACE_CTRL] & CS4231_PLAYBACK_ENABLE) { in snd_cs4231_play_callback()
976 snd_pcm_period_elapsed(chip->playback_substream); in snd_cs4231_play_callback()
977 snd_cs4231_advance_dma(&chip->p_dma, chip->playback_substream, in snd_cs4231_play_callback()
978 &chip->p_periods_sent); in snd_cs4231_play_callback()
982 static void snd_cs4231_capture_callback(struct snd_cs4231 *chip) in snd_cs4231_capture_callback() argument
984 if (chip->image[CS4231_IFACE_CTRL] & CS4231_RECORD_ENABLE) { in snd_cs4231_capture_callback()
985 snd_pcm_period_elapsed(chip->capture_substream); in snd_cs4231_capture_callback()
986 snd_cs4231_advance_dma(&chip->c_dma, chip->capture_substream, in snd_cs4231_capture_callback()
987 &chip->c_periods_sent); in snd_cs4231_capture_callback()
994 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); in snd_cs4231_playback_pointer() local
995 struct cs4231_dma_control *dma_cont = &chip->p_dma; in snd_cs4231_playback_pointer()
998 if (!(chip->image[CS4231_IFACE_CTRL] & CS4231_PLAYBACK_ENABLE)) in snd_cs4231_playback_pointer()
1010 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); in snd_cs4231_capture_pointer() local
1011 struct cs4231_dma_control *dma_cont = &chip->c_dma; in snd_cs4231_capture_pointer()
1014 if (!(chip->image[CS4231_IFACE_CTRL] & CS4231_RECORD_ENABLE)) in snd_cs4231_capture_pointer()
1023 static int snd_cs4231_probe(struct snd_cs4231 *chip) in snd_cs4231_probe() argument
1033 if (__cs4231_readb(chip, CS4231U(chip, REGSEL)) & CS4231_INIT) in snd_cs4231_probe()
1036 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_probe()
1037 snd_cs4231_out(chip, CS4231_MISC_INFO, CS4231_MODE2); in snd_cs4231_probe()
1038 id = snd_cs4231_in(chip, CS4231_MISC_INFO) & 0x0f; in snd_cs4231_probe()
1039 vers = snd_cs4231_in(chip, CS4231_VERSION); in snd_cs4231_probe()
1040 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_probe()
1045 dev_dbg(chip->card->dev, in snd_cs4231_probe()
1046 "cs4231: port = %p, id = 0x%x\n", chip->port, id); in snd_cs4231_probe()
1050 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_probe()
1053 __cs4231_readb(chip, CS4231U(chip, STATUS)); in snd_cs4231_probe()
1054 __cs4231_writeb(chip, 0, CS4231U(chip, STATUS)); in snd_cs4231_probe()
1057 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_probe()
1059 chip->image[CS4231_MISC_INFO] = CS4231_MODE2; in snd_cs4231_probe()
1060 chip->image[CS4231_IFACE_CTRL] = in snd_cs4231_probe()
1061 chip->image[CS4231_IFACE_CTRL] & ~CS4231_SINGLE_DMA; in snd_cs4231_probe()
1062 chip->image[CS4231_ALT_FEATURE_1] = 0x80; in snd_cs4231_probe()
1063 chip->image[CS4231_ALT_FEATURE_2] = 0x01; in snd_cs4231_probe()
1065 chip->image[CS4231_ALT_FEATURE_2] |= 0x02; in snd_cs4231_probe()
1067 ptr = (unsigned char *) &chip->image; in snd_cs4231_probe()
1069 snd_cs4231_mce_down(chip); in snd_cs4231_probe()
1071 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_probe()
1074 snd_cs4231_out(chip, i, *ptr++); in snd_cs4231_probe()
1076 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_probe()
1078 snd_cs4231_mce_up(chip); in snd_cs4231_probe()
1080 snd_cs4231_mce_down(chip); in snd_cs4231_probe()
1137 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); in snd_cs4231_playback_open() local
1143 err = snd_cs4231_open(chip, CS4231_MODE_PLAY); in snd_cs4231_playback_open()
1146 chip->playback_substream = substream; in snd_cs4231_playback_open()
1147 chip->p_periods_sent = 0; in snd_cs4231_playback_open()
1156 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); in snd_cs4231_capture_open() local
1162 err = snd_cs4231_open(chip, CS4231_MODE_RECORD); in snd_cs4231_capture_open()
1165 chip->capture_substream = substream; in snd_cs4231_capture_open()
1166 chip->c_periods_sent = 0; in snd_cs4231_capture_open()
1175 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); in snd_cs4231_playback_close() local
1177 snd_cs4231_close(chip, CS4231_MODE_PLAY); in snd_cs4231_playback_close()
1178 chip->playback_substream = NULL; in snd_cs4231_playback_close()
1185 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); in snd_cs4231_capture_close() local
1187 snd_cs4231_close(chip, CS4231_MODE_RECORD); in snd_cs4231_capture_close()
1188 chip->capture_substream = NULL; in snd_cs4231_capture_close()
1217 struct snd_cs4231 *chip = card->private_data; in snd_cs4231_pcm() local
1231 pcm->private_data = chip; in snd_cs4231_pcm()
1236 &chip->op->dev, 64 * 1024, 128 * 1024); in snd_cs4231_pcm()
1238 chip->pcm = pcm; in snd_cs4231_pcm()
1245 struct snd_cs4231 *chip = card->private_data; in snd_cs4231_timer() local
1260 timer->private_data = chip; in snd_cs4231_timer()
1262 chip->timer = timer; in snd_cs4231_timer()
1284 struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); in snd_cs4231_get_mux() local
1287 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_get_mux()
1289 (chip->image[CS4231_LEFT_INPUT] & CS4231_MIXS_ALL) >> 6; in snd_cs4231_get_mux()
1291 (chip->image[CS4231_RIGHT_INPUT] & CS4231_MIXS_ALL) >> 6; in snd_cs4231_get_mux()
1292 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_get_mux()
1300 struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); in snd_cs4231_put_mux() local
1311 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_put_mux()
1313 left = (chip->image[CS4231_LEFT_INPUT] & ~CS4231_MIXS_ALL) | left; in snd_cs4231_put_mux()
1314 right = (chip->image[CS4231_RIGHT_INPUT] & ~CS4231_MIXS_ALL) | right; in snd_cs4231_put_mux()
1315 change = left != chip->image[CS4231_LEFT_INPUT] || in snd_cs4231_put_mux()
1316 right != chip->image[CS4231_RIGHT_INPUT]; in snd_cs4231_put_mux()
1317 snd_cs4231_out(chip, CS4231_LEFT_INPUT, left); in snd_cs4231_put_mux()
1318 snd_cs4231_out(chip, CS4231_RIGHT_INPUT, right); in snd_cs4231_put_mux()
1320 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_put_mux()
1342 struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); in snd_cs4231_get_single() local
1349 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_get_single()
1351 ucontrol->value.integer.value[0] = (chip->image[reg] >> shift) & mask; in snd_cs4231_get_single()
1353 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_get_single()
1365 struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); in snd_cs4231_put_single() local
1379 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_put_single()
1381 val = (chip->image[reg] & ~(mask << shift)) | val; in snd_cs4231_put_single()
1382 change = val != chip->image[reg]; in snd_cs4231_put_single()
1383 snd_cs4231_out(chip, reg, val); in snd_cs4231_put_single()
1385 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_put_single()
1407 struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); in snd_cs4231_get_double() local
1416 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_get_double()
1419 (chip->image[left_reg] >> shift_left) & mask; in snd_cs4231_get_double()
1421 (chip->image[right_reg] >> shift_right) & mask; in snd_cs4231_get_double()
1423 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_get_double()
1438 struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); in snd_cs4231_put_double() local
1458 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_put_double()
1460 val1 = (chip->image[left_reg] & ~(mask << shift_left)) | val1; in snd_cs4231_put_double()
1461 val2 = (chip->image[right_reg] & ~(mask << shift_right)) | val2; in snd_cs4231_put_double()
1462 change = val1 != chip->image[left_reg]; in snd_cs4231_put_double()
1463 change |= val2 != chip->image[right_reg]; in snd_cs4231_put_double()
1464 snd_cs4231_out(chip, left_reg, val1); in snd_cs4231_put_double()
1465 snd_cs4231_out(chip, right_reg, val2); in snd_cs4231_put_double()
1467 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_put_double()
1527 struct snd_cs4231 *chip = card->private_data; in snd_cs4231_mixer() local
1530 if (snd_BUG_ON(!chip || !chip->pcm)) in snd_cs4231_mixer()
1533 strcpy(card->mixername, chip->pcm->name); in snd_cs4231_mixer()
1537 snd_ctl_new1(&snd_cs4231_controls[idx], chip)); in snd_cs4231_mixer()
1550 struct snd_cs4231 *chip; in cs4231_attach_begin() local
1571 chip = card->private_data; in cs4231_attach_begin()
1572 chip->card = card; in cs4231_attach_begin()
1580 struct snd_cs4231 *chip = card->private_data; in cs4231_attach_finish() local
1599 dev_set_drvdata(&chip->op->dev, chip); in cs4231_attach_finish()
1616 struct snd_cs4231 *chip = dev_id; in snd_cs4231_sbus_interrupt() local
1619 if (!(__cs4231_readb(chip, CS4231U(chip, STATUS)) & CS4231_GLOBALIRQ)) in snd_cs4231_sbus_interrupt()
1623 csr = sbus_readl(chip->port + APCCSR); in snd_cs4231_sbus_interrupt()
1625 sbus_writel(csr, chip->port + APCCSR); in snd_cs4231_sbus_interrupt()
1631 snd_cs4231_play_callback(chip); in snd_cs4231_sbus_interrupt()
1637 snd_cs4231_capture_callback(chip); in snd_cs4231_sbus_interrupt()
1639 status = snd_cs4231_in(chip, CS4231_IRQ_STATUS); in snd_cs4231_sbus_interrupt()
1642 if (chip->timer) in snd_cs4231_sbus_interrupt()
1643 snd_timer_interrupt(chip->timer, chip->timer->sticks); in snd_cs4231_sbus_interrupt()
1647 snd_cs4231_overrange(chip); in snd_cs4231_sbus_interrupt()
1650 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_sbus_interrupt()
1651 snd_cs4231_outm(chip, CS4231_IRQ_STATUS, ~CS4231_ALL_IRQS | ~status, 0); in snd_cs4231_sbus_interrupt()
1652 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_sbus_interrupt()
1758 static int snd_cs4231_sbus_free(struct snd_cs4231 *chip) in snd_cs4231_sbus_free() argument
1760 struct platform_device *op = chip->op; in snd_cs4231_sbus_free()
1762 if (chip->irq[0]) in snd_cs4231_sbus_free()
1763 free_irq(chip->irq[0], chip); in snd_cs4231_sbus_free()
1765 if (chip->port) in snd_cs4231_sbus_free()
1766 of_iounmap(&op->resource[0], chip->port, chip->regs_size); in snd_cs4231_sbus_free()
1786 struct snd_cs4231 *chip = card->private_data; in snd_cs4231_sbus_create() local
1789 spin_lock_init(&chip->lock); in snd_cs4231_sbus_create()
1790 spin_lock_init(&chip->c_dma.sbus_info.lock); in snd_cs4231_sbus_create()
1791 spin_lock_init(&chip->p_dma.sbus_info.lock); in snd_cs4231_sbus_create()
1792 mutex_init(&chip->mce_mutex); in snd_cs4231_sbus_create()
1793 mutex_init(&chip->open_mutex); in snd_cs4231_sbus_create()
1794 chip->op = op; in snd_cs4231_sbus_create()
1795 chip->regs_size = resource_size(&op->resource[0]); in snd_cs4231_sbus_create()
1796 memcpy(&chip->image, &snd_cs4231_original_image, in snd_cs4231_sbus_create()
1799 chip->port = of_ioremap(&op->resource[0], 0, in snd_cs4231_sbus_create()
1800 chip->regs_size, "cs4231"); in snd_cs4231_sbus_create()
1801 if (!chip->port) { in snd_cs4231_sbus_create()
1802 dev_dbg(chip->card->dev, in snd_cs4231_sbus_create()
1803 "cs4231-%d: Unable to map chip registers.\n", dev); in snd_cs4231_sbus_create()
1807 chip->c_dma.sbus_info.regs = chip->port; in snd_cs4231_sbus_create()
1808 chip->p_dma.sbus_info.regs = chip->port; in snd_cs4231_sbus_create()
1809 chip->c_dma.sbus_info.dir = APC_RECORD; in snd_cs4231_sbus_create()
1810 chip->p_dma.sbus_info.dir = APC_PLAY; in snd_cs4231_sbus_create()
1812 chip->p_dma.prepare = sbus_dma_prepare; in snd_cs4231_sbus_create()
1813 chip->p_dma.enable = sbus_dma_enable; in snd_cs4231_sbus_create()
1814 chip->p_dma.request = sbus_dma_request; in snd_cs4231_sbus_create()
1815 chip->p_dma.address = sbus_dma_addr; in snd_cs4231_sbus_create()
1817 chip->c_dma.prepare = sbus_dma_prepare; in snd_cs4231_sbus_create()
1818 chip->c_dma.enable = sbus_dma_enable; in snd_cs4231_sbus_create()
1819 chip->c_dma.request = sbus_dma_request; in snd_cs4231_sbus_create()
1820 chip->c_dma.address = sbus_dma_addr; in snd_cs4231_sbus_create()
1823 IRQF_SHARED, "cs4231", chip)) { in snd_cs4231_sbus_create()
1824 dev_dbg(chip->card->dev, in snd_cs4231_sbus_create()
1827 snd_cs4231_sbus_free(chip); in snd_cs4231_sbus_create()
1830 chip->irq[0] = op->archdata.irqs[0]; in snd_cs4231_sbus_create()
1832 if (snd_cs4231_probe(chip) < 0) { in snd_cs4231_sbus_create()
1833 snd_cs4231_sbus_free(chip); in snd_cs4231_sbus_create()
1836 snd_cs4231_init(chip); in snd_cs4231_sbus_create()
1839 chip, &snd_cs4231_sbus_dev_ops); in snd_cs4231_sbus_create()
1841 snd_cs4231_sbus_free(chip); in snd_cs4231_sbus_create()
1879 struct snd_cs4231 *chip = cookie; in snd_cs4231_ebus_play_callback() local
1881 snd_cs4231_play_callback(chip); in snd_cs4231_ebus_play_callback()
1887 struct snd_cs4231 *chip = cookie; in snd_cs4231_ebus_capture_callback() local
1889 snd_cs4231_capture_callback(chip); in snd_cs4231_ebus_capture_callback()
1921 static int snd_cs4231_ebus_free(struct snd_cs4231 *chip) in snd_cs4231_ebus_free() argument
1923 struct platform_device *op = chip->op; in snd_cs4231_ebus_free()
1925 if (chip->c_dma.ebus_info.regs) { in snd_cs4231_ebus_free()
1926 ebus_dma_unregister(&chip->c_dma.ebus_info); in snd_cs4231_ebus_free()
1927 of_iounmap(&op->resource[2], chip->c_dma.ebus_info.regs, 0x10); in snd_cs4231_ebus_free()
1929 if (chip->p_dma.ebus_info.regs) { in snd_cs4231_ebus_free()
1930 ebus_dma_unregister(&chip->p_dma.ebus_info); in snd_cs4231_ebus_free()
1931 of_iounmap(&op->resource[1], chip->p_dma.ebus_info.regs, 0x10); in snd_cs4231_ebus_free()
1934 if (chip->port) in snd_cs4231_ebus_free()
1935 of_iounmap(&op->resource[0], chip->port, 0x10); in snd_cs4231_ebus_free()
1955 struct snd_cs4231 *chip = card->private_data; in snd_cs4231_ebus_create() local
1958 spin_lock_init(&chip->lock); in snd_cs4231_ebus_create()
1959 spin_lock_init(&chip->c_dma.ebus_info.lock); in snd_cs4231_ebus_create()
1960 spin_lock_init(&chip->p_dma.ebus_info.lock); in snd_cs4231_ebus_create()
1961 mutex_init(&chip->mce_mutex); in snd_cs4231_ebus_create()
1962 mutex_init(&chip->open_mutex); in snd_cs4231_ebus_create()
1963 chip->flags |= CS4231_FLAG_EBUS; in snd_cs4231_ebus_create()
1964 chip->op = op; in snd_cs4231_ebus_create()
1965 memcpy(&chip->image, &snd_cs4231_original_image, in snd_cs4231_ebus_create()
1967 strcpy(chip->c_dma.ebus_info.name, "cs4231(capture)"); in snd_cs4231_ebus_create()
1968 chip->c_dma.ebus_info.flags = EBUS_DMA_FLAG_USE_EBDMA_HANDLER; in snd_cs4231_ebus_create()
1969 chip->c_dma.ebus_info.callback = snd_cs4231_ebus_capture_callback; in snd_cs4231_ebus_create()
1970 chip->c_dma.ebus_info.client_cookie = chip; in snd_cs4231_ebus_create()
1971 chip->c_dma.ebus_info.irq = op->archdata.irqs[0]; in snd_cs4231_ebus_create()
1972 strcpy(chip->p_dma.ebus_info.name, "cs4231(play)"); in snd_cs4231_ebus_create()
1973 chip->p_dma.ebus_info.flags = EBUS_DMA_FLAG_USE_EBDMA_HANDLER; in snd_cs4231_ebus_create()
1974 chip->p_dma.ebus_info.callback = snd_cs4231_ebus_play_callback; in snd_cs4231_ebus_create()
1975 chip->p_dma.ebus_info.client_cookie = chip; in snd_cs4231_ebus_create()
1976 chip->p_dma.ebus_info.irq = op->archdata.irqs[1]; in snd_cs4231_ebus_create()
1978 chip->p_dma.prepare = _ebus_dma_prepare; in snd_cs4231_ebus_create()
1979 chip->p_dma.enable = _ebus_dma_enable; in snd_cs4231_ebus_create()
1980 chip->p_dma.request = _ebus_dma_request; in snd_cs4231_ebus_create()
1981 chip->p_dma.address = _ebus_dma_addr; in snd_cs4231_ebus_create()
1983 chip->c_dma.prepare = _ebus_dma_prepare; in snd_cs4231_ebus_create()
1984 chip->c_dma.enable = _ebus_dma_enable; in snd_cs4231_ebus_create()
1985 chip->c_dma.request = _ebus_dma_request; in snd_cs4231_ebus_create()
1986 chip->c_dma.address = _ebus_dma_addr; in snd_cs4231_ebus_create()
1988 chip->port = of_ioremap(&op->resource[0], 0, 0x10, "cs4231"); in snd_cs4231_ebus_create()
1989 chip->p_dma.ebus_info.regs = in snd_cs4231_ebus_create()
1991 chip->c_dma.ebus_info.regs = in snd_cs4231_ebus_create()
1993 if (!chip->port || !chip->p_dma.ebus_info.regs || in snd_cs4231_ebus_create()
1994 !chip->c_dma.ebus_info.regs) { in snd_cs4231_ebus_create()
1995 snd_cs4231_ebus_free(chip); in snd_cs4231_ebus_create()
1996 dev_dbg(chip->card->dev, in snd_cs4231_ebus_create()
1997 "cs4231-%d: Unable to map chip registers.\n", dev); in snd_cs4231_ebus_create()
2001 if (ebus_dma_register(&chip->c_dma.ebus_info)) { in snd_cs4231_ebus_create()
2002 snd_cs4231_ebus_free(chip); in snd_cs4231_ebus_create()
2003 dev_dbg(chip->card->dev, in snd_cs4231_ebus_create()
2008 if (ebus_dma_irq_enable(&chip->c_dma.ebus_info, 1)) { in snd_cs4231_ebus_create()
2009 snd_cs4231_ebus_free(chip); in snd_cs4231_ebus_create()
2010 dev_dbg(chip->card->dev, in snd_cs4231_ebus_create()
2016 if (ebus_dma_register(&chip->p_dma.ebus_info)) { in snd_cs4231_ebus_create()
2017 snd_cs4231_ebus_free(chip); in snd_cs4231_ebus_create()
2018 dev_dbg(chip->card->dev, in snd_cs4231_ebus_create()
2023 if (ebus_dma_irq_enable(&chip->p_dma.ebus_info, 1)) { in snd_cs4231_ebus_create()
2024 snd_cs4231_ebus_free(chip); in snd_cs4231_ebus_create()
2025 dev_dbg(chip->card->dev, in snd_cs4231_ebus_create()
2030 if (snd_cs4231_probe(chip) < 0) { in snd_cs4231_ebus_create()
2031 snd_cs4231_ebus_free(chip); in snd_cs4231_ebus_create()
2034 snd_cs4231_init(chip); in snd_cs4231_ebus_create()
2037 chip, &snd_cs4231_ebus_dev_ops); in snd_cs4231_ebus_create()
2039 snd_cs4231_ebus_free(chip); in snd_cs4231_ebus_create()
2086 struct snd_cs4231 *chip = dev_get_drvdata(&op->dev); in cs4231_remove() local
2088 snd_card_free(chip->card); in cs4231_remove()