Lines Matching full:chip
129 #define CS4231U(chip, x) ((chip)->port + ((c_d_c_CS4231##x) << 2)) argument
175 #define APC_CHIP_RESET 0x01 /* Reset the chip */
278 static void snd_cs4231_ready(struct snd_cs4231 *chip) in snd_cs4231_ready() argument
283 int val = __cs4231_readb(chip, CS4231U(chip, REGSEL)); in snd_cs4231_ready()
290 static void snd_cs4231_dout(struct snd_cs4231 *chip, unsigned char reg, in snd_cs4231_dout() argument
293 snd_cs4231_ready(chip); in snd_cs4231_dout()
295 if (__cs4231_readb(chip, CS4231U(chip, REGSEL)) & CS4231_INIT) in snd_cs4231_dout()
300 __cs4231_writeb(chip, chip->mce_bit | reg, CS4231U(chip, REGSEL)); in snd_cs4231_dout()
302 __cs4231_writeb(chip, value, CS4231U(chip, REG)); in snd_cs4231_dout()
306 static inline void snd_cs4231_outm(struct snd_cs4231 *chip, unsigned char reg, in snd_cs4231_outm() argument
309 unsigned char tmp = (chip->image[reg] & mask) | value; in snd_cs4231_outm()
311 chip->image[reg] = tmp; in snd_cs4231_outm()
312 if (!chip->calibrate_mute) in snd_cs4231_outm()
313 snd_cs4231_dout(chip, reg, tmp); in snd_cs4231_outm()
316 static void snd_cs4231_out(struct snd_cs4231 *chip, unsigned char reg, in snd_cs4231_out() argument
319 snd_cs4231_dout(chip, reg, value); in snd_cs4231_out()
320 chip->image[reg] = value; in snd_cs4231_out()
324 static unsigned char snd_cs4231_in(struct snd_cs4231 *chip, unsigned char reg) in snd_cs4231_in() argument
326 snd_cs4231_ready(chip); in snd_cs4231_in()
328 if (__cs4231_readb(chip, CS4231U(chip, REGSEL)) & CS4231_INIT) 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()
369 chip->mce_bit |= CS4231_MCE; in snd_cs4231_mce_up()
370 timeout = __cs4231_readb(chip, CS4231U(chip, REGSEL)); in snd_cs4231_mce_up()
374 chip->port); in snd_cs4231_mce_up()
376 __cs4231_writeb(chip, chip->mce_bit | (timeout & 0x1f), in snd_cs4231_mce_up()
377 CS4231U(chip, REGSEL)); in snd_cs4231_mce_up()
378 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_mce_up()
381 static void snd_cs4231_mce_down(struct snd_cs4231 *chip) in snd_cs4231_mce_down() argument
386 snd_cs4231_busy_wait(chip); in snd_cs4231_mce_down()
387 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_mce_down()
389 if (__cs4231_readb(chip, CS4231U(chip, REGSEL)) & CS4231_INIT) in snd_cs4231_mce_down()
391 CS4231U(chip, REGSEL)); in snd_cs4231_mce_down()
393 chip->mce_bit &= ~CS4231_MCE; in snd_cs4231_mce_down()
394 reg = __cs4231_readb(chip, CS4231U(chip, REGSEL)); in snd_cs4231_mce_down()
395 __cs4231_writeb(chip, chip->mce_bit | (reg & 0x1f), in snd_cs4231_mce_down()
396 CS4231U(chip, REGSEL)); in snd_cs4231_mce_down()
399 "- codec still busy\n", chip->port); in snd_cs4231_mce_down()
401 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_mce_down()
410 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_mce_down()
412 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_mce_down()
413 reg = snd_cs4231_in(chip, CS4231_TEST_INIT); in snd_cs4231_mce_down()
416 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_mce_down()
446 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); in cs4231_dma_trigger() local
450 dma_cont = &chip->p_dma; in cs4231_dma_trigger()
455 chip->playback_substream, in cs4231_dma_trigger()
456 &chip->p_periods_sent); in cs4231_dma_trigger()
462 dma_cont = &chip->c_dma; in cs4231_dma_trigger()
467 chip->capture_substream, in cs4231_dma_trigger()
468 &chip->c_periods_sent); in cs4231_dma_trigger()
477 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); in snd_cs4231_trigger() local
489 if (s == chip->playback_substream) { in snd_cs4231_trigger()
492 } else if (s == chip->capture_substream) { in snd_cs4231_trigger()
498 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_trigger()
501 chip->image[CS4231_IFACE_CTRL] |= what; in snd_cs4231_trigger()
504 chip->image[CS4231_IFACE_CTRL] &= ~what; in snd_cs4231_trigger()
506 snd_cs4231_out(chip, CS4231_IFACE_CTRL, in snd_cs4231_trigger()
507 chip->image[CS4231_IFACE_CTRL]); in snd_cs4231_trigger()
508 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_trigger()
534 static unsigned char snd_cs4231_get_format(struct snd_cs4231 *chip, int format, in snd_cs4231_get_format() argument
562 static void snd_cs4231_calibrate_mute(struct snd_cs4231 *chip, int mute) in snd_cs4231_calibrate_mute() argument
567 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_calibrate_mute()
568 if (chip->calibrate_mute == mute) { in snd_cs4231_calibrate_mute()
569 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_calibrate_mute()
573 snd_cs4231_dout(chip, CS4231_LEFT_INPUT, in snd_cs4231_calibrate_mute()
574 chip->image[CS4231_LEFT_INPUT]); in snd_cs4231_calibrate_mute()
575 snd_cs4231_dout(chip, CS4231_RIGHT_INPUT, in snd_cs4231_calibrate_mute()
576 chip->image[CS4231_RIGHT_INPUT]); in snd_cs4231_calibrate_mute()
577 snd_cs4231_dout(chip, CS4231_LOOPBACK, in snd_cs4231_calibrate_mute()
578 chip->image[CS4231_LOOPBACK]); in snd_cs4231_calibrate_mute()
580 snd_cs4231_dout(chip, CS4231_AUX1_LEFT_INPUT, in snd_cs4231_calibrate_mute()
581 mute ? 0x80 : chip->image[CS4231_AUX1_LEFT_INPUT]); in snd_cs4231_calibrate_mute()
582 snd_cs4231_dout(chip, CS4231_AUX1_RIGHT_INPUT, in snd_cs4231_calibrate_mute()
583 mute ? 0x80 : chip->image[CS4231_AUX1_RIGHT_INPUT]); in snd_cs4231_calibrate_mute()
584 snd_cs4231_dout(chip, CS4231_AUX2_LEFT_INPUT, in snd_cs4231_calibrate_mute()
585 mute ? 0x80 : chip->image[CS4231_AUX2_LEFT_INPUT]); in snd_cs4231_calibrate_mute()
586 snd_cs4231_dout(chip, CS4231_AUX2_RIGHT_INPUT, in snd_cs4231_calibrate_mute()
587 mute ? 0x80 : chip->image[CS4231_AUX2_RIGHT_INPUT]); in snd_cs4231_calibrate_mute()
588 snd_cs4231_dout(chip, CS4231_LEFT_OUTPUT, in snd_cs4231_calibrate_mute()
589 mute ? 0x80 : chip->image[CS4231_LEFT_OUTPUT]); in snd_cs4231_calibrate_mute()
590 snd_cs4231_dout(chip, CS4231_RIGHT_OUTPUT, in snd_cs4231_calibrate_mute()
591 mute ? 0x80 : chip->image[CS4231_RIGHT_OUTPUT]); in snd_cs4231_calibrate_mute()
592 snd_cs4231_dout(chip, CS4231_LEFT_LINE_IN, in snd_cs4231_calibrate_mute()
593 mute ? 0x80 : chip->image[CS4231_LEFT_LINE_IN]); in snd_cs4231_calibrate_mute()
594 snd_cs4231_dout(chip, CS4231_RIGHT_LINE_IN, in snd_cs4231_calibrate_mute()
595 mute ? 0x80 : chip->image[CS4231_RIGHT_LINE_IN]); in snd_cs4231_calibrate_mute()
596 snd_cs4231_dout(chip, CS4231_MONO_CTRL, in snd_cs4231_calibrate_mute()
597 mute ? 0xc0 : chip->image[CS4231_MONO_CTRL]); in snd_cs4231_calibrate_mute()
598 chip->calibrate_mute = mute; in snd_cs4231_calibrate_mute()
599 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_calibrate_mute()
602 static void snd_cs4231_playback_format(struct snd_cs4231 *chip, in snd_cs4231_playback_format() argument
608 mutex_lock(&chip->mce_mutex); in snd_cs4231_playback_format()
609 snd_cs4231_calibrate_mute(chip, 1); in snd_cs4231_playback_format()
611 snd_cs4231_mce_up(chip); in snd_cs4231_playback_format()
613 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_playback_format()
614 snd_cs4231_out(chip, CS4231_PLAYBK_FORMAT, in snd_cs4231_playback_format()
615 (chip->image[CS4231_IFACE_CTRL] & CS4231_RECORD_ENABLE) ? in snd_cs4231_playback_format()
616 (pdfr & 0xf0) | (chip->image[CS4231_REC_FORMAT] & 0x0f) : in snd_cs4231_playback_format()
618 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_playback_format()
620 snd_cs4231_mce_down(chip); in snd_cs4231_playback_format()
622 snd_cs4231_calibrate_mute(chip, 0); in snd_cs4231_playback_format()
623 mutex_unlock(&chip->mce_mutex); in snd_cs4231_playback_format()
626 static void snd_cs4231_capture_format(struct snd_cs4231 *chip, in snd_cs4231_capture_format() argument
632 mutex_lock(&chip->mce_mutex); in snd_cs4231_capture_format()
633 snd_cs4231_calibrate_mute(chip, 1); in snd_cs4231_capture_format()
635 snd_cs4231_mce_up(chip); in snd_cs4231_capture_format()
637 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_capture_format()
638 if (!(chip->image[CS4231_IFACE_CTRL] & CS4231_PLAYBACK_ENABLE)) { in snd_cs4231_capture_format()
639 snd_cs4231_out(chip, CS4231_PLAYBK_FORMAT, in snd_cs4231_capture_format()
640 ((chip->image[CS4231_PLAYBK_FORMAT]) & 0xf0) | in snd_cs4231_capture_format()
642 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_capture_format()
643 snd_cs4231_mce_down(chip); in snd_cs4231_capture_format()
644 snd_cs4231_mce_up(chip); in snd_cs4231_capture_format()
645 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_capture_format()
647 snd_cs4231_out(chip, CS4231_REC_FORMAT, cdfr); in snd_cs4231_capture_format()
648 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_capture_format()
650 snd_cs4231_mce_down(chip); in snd_cs4231_capture_format()
652 snd_cs4231_calibrate_mute(chip, 0); in snd_cs4231_capture_format()
653 mutex_unlock(&chip->mce_mutex); in snd_cs4231_capture_format()
662 struct snd_cs4231 *chip = snd_timer_chip(timer); in snd_cs4231_timer_resolution() local
664 return chip->image[CS4231_PLAYBK_FORMAT] & 1 ? 9969 : 9920; in snd_cs4231_timer_resolution()
671 struct snd_cs4231 *chip = snd_timer_chip(timer); in snd_cs4231_timer_start() local
673 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_timer_start()
675 if ((chip->image[CS4231_ALT_FEATURE_1] & CS4231_TIMER_ENABLE) == 0 || in snd_cs4231_timer_start()
676 (unsigned char)(ticks >> 8) != chip->image[CS4231_TIMER_HIGH] || in snd_cs4231_timer_start()
677 (unsigned char)ticks != chip->image[CS4231_TIMER_LOW]) { in snd_cs4231_timer_start()
678 snd_cs4231_out(chip, CS4231_TIMER_HIGH, in snd_cs4231_timer_start()
679 chip->image[CS4231_TIMER_HIGH] = in snd_cs4231_timer_start()
681 snd_cs4231_out(chip, CS4231_TIMER_LOW, in snd_cs4231_timer_start()
682 chip->image[CS4231_TIMER_LOW] = in snd_cs4231_timer_start()
684 snd_cs4231_out(chip, CS4231_ALT_FEATURE_1, in snd_cs4231_timer_start()
685 chip->image[CS4231_ALT_FEATURE_1] | in snd_cs4231_timer_start()
688 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_timer_start()
696 struct snd_cs4231 *chip = snd_timer_chip(timer); in snd_cs4231_timer_stop() local
698 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_timer_stop()
699 chip->image[CS4231_ALT_FEATURE_1] &= ~CS4231_TIMER_ENABLE; in snd_cs4231_timer_stop()
700 snd_cs4231_out(chip, CS4231_ALT_FEATURE_1, in snd_cs4231_timer_stop()
701 chip->image[CS4231_ALT_FEATURE_1]); in snd_cs4231_timer_stop()
702 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_timer_stop()
707 static void snd_cs4231_init(struct snd_cs4231 *chip) in snd_cs4231_init() argument
711 snd_cs4231_mce_down(chip); in snd_cs4231_init()
716 snd_cs4231_mce_up(chip); in snd_cs4231_init()
717 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_init()
718 chip->image[CS4231_IFACE_CTRL] &= ~(CS4231_PLAYBACK_ENABLE | in snd_cs4231_init()
723 chip->image[CS4231_IFACE_CTRL] |= CS4231_AUTOCALIB; in snd_cs4231_init()
724 snd_cs4231_out(chip, CS4231_IFACE_CTRL, chip->image[CS4231_IFACE_CTRL]); in snd_cs4231_init()
725 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_init()
726 snd_cs4231_mce_down(chip); in snd_cs4231_init()
732 snd_cs4231_mce_up(chip); in snd_cs4231_init()
733 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_init()
734 snd_cs4231_out(chip, CS4231_ALT_FEATURE_1, in snd_cs4231_init()
735 chip->image[CS4231_ALT_FEATURE_1]); in snd_cs4231_init()
736 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_init()
737 snd_cs4231_mce_down(chip); in snd_cs4231_init()
741 chip->image[CS4231_ALT_FEATURE_1]); in snd_cs4231_init()
744 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_init()
745 snd_cs4231_out(chip, CS4231_ALT_FEATURE_2, in snd_cs4231_init()
746 chip->image[CS4231_ALT_FEATURE_2]); in snd_cs4231_init()
747 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_init()
749 snd_cs4231_mce_up(chip); in snd_cs4231_init()
750 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_init()
751 snd_cs4231_out(chip, CS4231_PLAYBK_FORMAT, in snd_cs4231_init()
752 chip->image[CS4231_PLAYBK_FORMAT]); in snd_cs4231_init()
753 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_init()
754 snd_cs4231_mce_down(chip); in snd_cs4231_init()
760 snd_cs4231_mce_up(chip); in snd_cs4231_init()
761 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_init()
762 snd_cs4231_out(chip, CS4231_REC_FORMAT, chip->image[CS4231_REC_FORMAT]); in snd_cs4231_init()
763 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_init()
764 snd_cs4231_mce_down(chip); in snd_cs4231_init()
771 static int snd_cs4231_open(struct snd_cs4231 *chip, unsigned int mode) in snd_cs4231_open() argument
775 mutex_lock(&chip->open_mutex); in snd_cs4231_open()
776 if ((chip->mode & mode)) { in snd_cs4231_open()
777 mutex_unlock(&chip->open_mutex); in snd_cs4231_open()
780 if (chip->mode & CS4231_MODE_OPEN) { in snd_cs4231_open()
781 chip->mode |= mode; in snd_cs4231_open()
782 mutex_unlock(&chip->open_mutex); in snd_cs4231_open()
786 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_open()
787 snd_cs4231_out(chip, CS4231_IRQ_STATUS, CS4231_PLAYBACK_IRQ | in snd_cs4231_open()
790 snd_cs4231_out(chip, CS4231_IRQ_STATUS, 0); in snd_cs4231_open()
791 __cs4231_writeb(chip, 0, CS4231U(chip, STATUS)); /* clear IRQ */ in snd_cs4231_open()
792 __cs4231_writeb(chip, 0, CS4231U(chip, STATUS)); /* clear IRQ */ in snd_cs4231_open()
794 snd_cs4231_out(chip, CS4231_IRQ_STATUS, CS4231_PLAYBACK_IRQ | in snd_cs4231_open()
797 snd_cs4231_out(chip, CS4231_IRQ_STATUS, 0); in snd_cs4231_open()
799 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_open()
801 chip->mode = mode; in snd_cs4231_open()
802 mutex_unlock(&chip->open_mutex); in snd_cs4231_open()
806 static void snd_cs4231_close(struct snd_cs4231 *chip, unsigned int mode) in snd_cs4231_close() argument
810 mutex_lock(&chip->open_mutex); in snd_cs4231_close()
811 chip->mode &= ~mode; in snd_cs4231_close()
812 if (chip->mode & CS4231_MODE_OPEN) { in snd_cs4231_close()
813 mutex_unlock(&chip->open_mutex); in snd_cs4231_close()
816 snd_cs4231_calibrate_mute(chip, 1); in snd_cs4231_close()
819 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_close()
820 snd_cs4231_out(chip, CS4231_IRQ_STATUS, 0); in snd_cs4231_close()
821 __cs4231_writeb(chip, 0, CS4231U(chip, STATUS)); /* clear IRQ */ in snd_cs4231_close()
822 __cs4231_writeb(chip, 0, CS4231U(chip, STATUS)); /* clear IRQ */ in snd_cs4231_close()
826 if (chip->image[CS4231_IFACE_CTRL] & in snd_cs4231_close()
829 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_close()
830 snd_cs4231_mce_up(chip); in snd_cs4231_close()
831 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_close()
832 chip->image[CS4231_IFACE_CTRL] &= in snd_cs4231_close()
835 snd_cs4231_out(chip, CS4231_IFACE_CTRL, in snd_cs4231_close()
836 chip->image[CS4231_IFACE_CTRL]); in snd_cs4231_close()
837 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_close()
838 snd_cs4231_mce_down(chip); in snd_cs4231_close()
839 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_close()
843 snd_cs4231_out(chip, CS4231_IRQ_STATUS, 0); in snd_cs4231_close()
844 __cs4231_writeb(chip, 0, CS4231U(chip, STATUS)); /* clear IRQ */ in snd_cs4231_close()
845 __cs4231_writeb(chip, 0, CS4231U(chip, STATUS)); /* clear IRQ */ in snd_cs4231_close()
846 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_close()
848 snd_cs4231_calibrate_mute(chip, 0); in snd_cs4231_close()
850 chip->mode = 0; in snd_cs4231_close()
851 mutex_unlock(&chip->open_mutex); in snd_cs4231_close()
860 struct snd_cs4231 *chip = snd_timer_chip(timer); in snd_cs4231_timer_open() local
861 snd_cs4231_open(chip, CS4231_MODE_TIMER); in snd_cs4231_timer_open()
867 struct snd_cs4231 *chip = snd_timer_chip(timer); in snd_cs4231_timer_close() local
868 snd_cs4231_close(chip, CS4231_MODE_TIMER); in snd_cs4231_timer_close()
890 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); in snd_cs4231_playback_hw_params() local
898 new_pdfr = snd_cs4231_get_format(chip, params_format(hw_params), in snd_cs4231_playback_hw_params()
901 snd_cs4231_playback_format(chip, hw_params, new_pdfr); in snd_cs4231_playback_hw_params()
908 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); in snd_cs4231_playback_prepare() local
913 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_playback_prepare()
915 chip->image[CS4231_IFACE_CTRL] &= ~(CS4231_PLAYBACK_ENABLE | in snd_cs4231_playback_prepare()
923 chip->p_periods_sent = 0; in snd_cs4231_playback_prepare()
926 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_playback_prepare()
934 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); in snd_cs4231_capture_hw_params() local
942 new_cdfr = snd_cs4231_get_format(chip, params_format(hw_params), in snd_cs4231_capture_hw_params()
945 snd_cs4231_capture_format(chip, hw_params, new_cdfr); in snd_cs4231_capture_hw_params()
952 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); in snd_cs4231_capture_prepare() local
955 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_capture_prepare()
956 chip->image[CS4231_IFACE_CTRL] &= ~(CS4231_RECORD_ENABLE | in snd_cs4231_capture_prepare()
960 chip->c_periods_sent = 0; in snd_cs4231_capture_prepare()
961 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_capture_prepare()
966 static void snd_cs4231_overrange(struct snd_cs4231 *chip) in snd_cs4231_overrange() argument
971 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_overrange()
972 res = snd_cs4231_in(chip, CS4231_TEST_INIT); in snd_cs4231_overrange()
973 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_overrange()
977 chip->capture_substream->runtime->overrange++; in snd_cs4231_overrange()
980 static void snd_cs4231_play_callback(struct snd_cs4231 *chip) in snd_cs4231_play_callback() argument
982 if (chip->image[CS4231_IFACE_CTRL] & CS4231_PLAYBACK_ENABLE) { in snd_cs4231_play_callback()
983 snd_pcm_period_elapsed(chip->playback_substream); in snd_cs4231_play_callback()
984 snd_cs4231_advance_dma(&chip->p_dma, chip->playback_substream, in snd_cs4231_play_callback()
985 &chip->p_periods_sent); in snd_cs4231_play_callback()
989 static void snd_cs4231_capture_callback(struct snd_cs4231 *chip) in snd_cs4231_capture_callback() argument
991 if (chip->image[CS4231_IFACE_CTRL] & CS4231_RECORD_ENABLE) { in snd_cs4231_capture_callback()
992 snd_pcm_period_elapsed(chip->capture_substream); in snd_cs4231_capture_callback()
993 snd_cs4231_advance_dma(&chip->c_dma, chip->capture_substream, in snd_cs4231_capture_callback()
994 &chip->c_periods_sent); in snd_cs4231_capture_callback()
1001 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); in snd_cs4231_playback_pointer() local
1002 struct cs4231_dma_control *dma_cont = &chip->p_dma; in snd_cs4231_playback_pointer()
1005 if (!(chip->image[CS4231_IFACE_CTRL] & CS4231_PLAYBACK_ENABLE)) in snd_cs4231_playback_pointer()
1017 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); in snd_cs4231_capture_pointer() local
1018 struct cs4231_dma_control *dma_cont = &chip->c_dma; in snd_cs4231_capture_pointer()
1021 if (!(chip->image[CS4231_IFACE_CTRL] & CS4231_RECORD_ENABLE)) in snd_cs4231_capture_pointer()
1030 static int snd_cs4231_probe(struct snd_cs4231 *chip) in snd_cs4231_probe() argument
1040 if (__cs4231_readb(chip, CS4231U(chip, REGSEL)) & CS4231_INIT) in snd_cs4231_probe()
1043 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_probe()
1044 snd_cs4231_out(chip, CS4231_MISC_INFO, CS4231_MODE2); in snd_cs4231_probe()
1045 id = snd_cs4231_in(chip, CS4231_MISC_INFO) & 0x0f; in snd_cs4231_probe()
1046 vers = snd_cs4231_in(chip, CS4231_VERSION); in snd_cs4231_probe()
1047 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_probe()
1052 snd_printdd("cs4231: port = %p, id = 0x%x\n", chip->port, id); in snd_cs4231_probe()
1056 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_probe()
1059 __cs4231_readb(chip, CS4231U(chip, STATUS)); in snd_cs4231_probe()
1060 __cs4231_writeb(chip, 0, CS4231U(chip, STATUS)); in snd_cs4231_probe()
1063 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_probe()
1065 chip->image[CS4231_MISC_INFO] = CS4231_MODE2; in snd_cs4231_probe()
1066 chip->image[CS4231_IFACE_CTRL] = in snd_cs4231_probe()
1067 chip->image[CS4231_IFACE_CTRL] & ~CS4231_SINGLE_DMA; in snd_cs4231_probe()
1068 chip->image[CS4231_ALT_FEATURE_1] = 0x80; in snd_cs4231_probe()
1069 chip->image[CS4231_ALT_FEATURE_2] = 0x01; in snd_cs4231_probe()
1071 chip->image[CS4231_ALT_FEATURE_2] |= 0x02; in snd_cs4231_probe()
1073 ptr = (unsigned char *) &chip->image; in snd_cs4231_probe()
1075 snd_cs4231_mce_down(chip); in snd_cs4231_probe()
1077 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_probe()
1080 snd_cs4231_out(chip, i, *ptr++); in snd_cs4231_probe()
1082 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_probe()
1084 snd_cs4231_mce_up(chip); in snd_cs4231_probe()
1086 snd_cs4231_mce_down(chip); in snd_cs4231_probe()
1143 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); in snd_cs4231_playback_open() local
1149 err = snd_cs4231_open(chip, CS4231_MODE_PLAY); in snd_cs4231_playback_open()
1152 chip->playback_substream = substream; in snd_cs4231_playback_open()
1153 chip->p_periods_sent = 0; in snd_cs4231_playback_open()
1162 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); in snd_cs4231_capture_open() local
1168 err = snd_cs4231_open(chip, CS4231_MODE_RECORD); in snd_cs4231_capture_open()
1171 chip->capture_substream = substream; in snd_cs4231_capture_open()
1172 chip->c_periods_sent = 0; in snd_cs4231_capture_open()
1181 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); in snd_cs4231_playback_close() local
1183 snd_cs4231_close(chip, CS4231_MODE_PLAY); in snd_cs4231_playback_close()
1184 chip->playback_substream = NULL; in snd_cs4231_playback_close()
1191 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); in snd_cs4231_capture_close() local
1193 snd_cs4231_close(chip, CS4231_MODE_RECORD); in snd_cs4231_capture_close()
1194 chip->capture_substream = NULL; in snd_cs4231_capture_close()
1227 struct snd_cs4231 *chip = card->private_data; in snd_cs4231_pcm() local
1241 pcm->private_data = chip; in snd_cs4231_pcm()
1246 &chip->op->dev, in snd_cs4231_pcm()
1249 chip->pcm = pcm; in snd_cs4231_pcm()
1256 struct snd_cs4231 *chip = card->private_data; in snd_cs4231_timer() local
1271 timer->private_data = chip; in snd_cs4231_timer()
1273 chip->timer = timer; in snd_cs4231_timer()
1295 struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); in snd_cs4231_get_mux() local
1298 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_get_mux()
1300 (chip->image[CS4231_LEFT_INPUT] & CS4231_MIXS_ALL) >> 6; in snd_cs4231_get_mux()
1302 (chip->image[CS4231_RIGHT_INPUT] & CS4231_MIXS_ALL) >> 6; in snd_cs4231_get_mux()
1303 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_get_mux()
1311 struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); in snd_cs4231_put_mux() local
1322 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_put_mux()
1324 left = (chip->image[CS4231_LEFT_INPUT] & ~CS4231_MIXS_ALL) | left; in snd_cs4231_put_mux()
1325 right = (chip->image[CS4231_RIGHT_INPUT] & ~CS4231_MIXS_ALL) | right; in snd_cs4231_put_mux()
1326 change = left != chip->image[CS4231_LEFT_INPUT] || in snd_cs4231_put_mux()
1327 right != chip->image[CS4231_RIGHT_INPUT]; in snd_cs4231_put_mux()
1328 snd_cs4231_out(chip, CS4231_LEFT_INPUT, left); in snd_cs4231_put_mux()
1329 snd_cs4231_out(chip, CS4231_RIGHT_INPUT, right); in snd_cs4231_put_mux()
1331 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_put_mux()
1353 struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); in snd_cs4231_get_single() local
1360 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_get_single()
1362 ucontrol->value.integer.value[0] = (chip->image[reg] >> shift) & mask; in snd_cs4231_get_single()
1364 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_get_single()
1376 struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); in snd_cs4231_put_single() local
1390 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_put_single()
1392 val = (chip->image[reg] & ~(mask << shift)) | val; in snd_cs4231_put_single()
1393 change = val != chip->image[reg]; in snd_cs4231_put_single()
1394 snd_cs4231_out(chip, reg, val); in snd_cs4231_put_single()
1396 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_put_single()
1418 struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); in snd_cs4231_get_double() local
1427 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_get_double()
1430 (chip->image[left_reg] >> shift_left) & mask; in snd_cs4231_get_double()
1432 (chip->image[right_reg] >> shift_right) & mask; in snd_cs4231_get_double()
1434 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_get_double()
1449 struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); in snd_cs4231_put_double() local
1469 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_put_double()
1471 val1 = (chip->image[left_reg] & ~(mask << shift_left)) | val1; in snd_cs4231_put_double()
1472 val2 = (chip->image[right_reg] & ~(mask << shift_right)) | val2; in snd_cs4231_put_double()
1473 change = val1 != chip->image[left_reg]; in snd_cs4231_put_double()
1474 change |= val2 != chip->image[right_reg]; in snd_cs4231_put_double()
1475 snd_cs4231_out(chip, left_reg, val1); in snd_cs4231_put_double()
1476 snd_cs4231_out(chip, right_reg, val2); in snd_cs4231_put_double()
1478 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_put_double()
1538 struct snd_cs4231 *chip = card->private_data; in snd_cs4231_mixer() local
1541 if (snd_BUG_ON(!chip || !chip->pcm)) in snd_cs4231_mixer()
1544 strcpy(card->mixername, chip->pcm->name); in snd_cs4231_mixer()
1548 snd_ctl_new1(&snd_cs4231_controls[idx], chip)); in snd_cs4231_mixer()
1561 struct snd_cs4231 *chip; in cs4231_attach_begin() local
1582 chip = card->private_data; in cs4231_attach_begin()
1583 chip->card = card; in cs4231_attach_begin()
1591 struct snd_cs4231 *chip = card->private_data; in cs4231_attach_finish() local
1610 dev_set_drvdata(&chip->op->dev, chip); in cs4231_attach_finish()
1627 struct snd_cs4231 *chip = dev_id; in snd_cs4231_sbus_interrupt() local
1630 if (!(__cs4231_readb(chip, CS4231U(chip, STATUS)) & CS4231_GLOBALIRQ)) in snd_cs4231_sbus_interrupt()
1634 csr = sbus_readl(chip->port + APCCSR); in snd_cs4231_sbus_interrupt()
1636 sbus_writel(csr, chip->port + APCCSR); in snd_cs4231_sbus_interrupt()
1642 snd_cs4231_play_callback(chip); in snd_cs4231_sbus_interrupt()
1648 snd_cs4231_capture_callback(chip); in snd_cs4231_sbus_interrupt()
1650 status = snd_cs4231_in(chip, CS4231_IRQ_STATUS); in snd_cs4231_sbus_interrupt()
1653 if (chip->timer) in snd_cs4231_sbus_interrupt()
1654 snd_timer_interrupt(chip->timer, chip->timer->sticks); in snd_cs4231_sbus_interrupt()
1658 snd_cs4231_overrange(chip); in snd_cs4231_sbus_interrupt()
1661 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_sbus_interrupt()
1662 snd_cs4231_outm(chip, CS4231_IRQ_STATUS, ~CS4231_ALL_IRQS | ~status, 0); in snd_cs4231_sbus_interrupt()
1663 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_sbus_interrupt()
1769 static int snd_cs4231_sbus_free(struct snd_cs4231 *chip) in snd_cs4231_sbus_free() argument
1771 struct platform_device *op = chip->op; in snd_cs4231_sbus_free()
1773 if (chip->irq[0]) in snd_cs4231_sbus_free()
1774 free_irq(chip->irq[0], chip); in snd_cs4231_sbus_free()
1776 if (chip->port) in snd_cs4231_sbus_free()
1777 of_iounmap(&op->resource[0], chip->port, chip->regs_size); in snd_cs4231_sbus_free()
1797 struct snd_cs4231 *chip = card->private_data; in snd_cs4231_sbus_create() local
1800 spin_lock_init(&chip->lock); in snd_cs4231_sbus_create()
1801 spin_lock_init(&chip->c_dma.sbus_info.lock); in snd_cs4231_sbus_create()
1802 spin_lock_init(&chip->p_dma.sbus_info.lock); in snd_cs4231_sbus_create()
1803 mutex_init(&chip->mce_mutex); in snd_cs4231_sbus_create()
1804 mutex_init(&chip->open_mutex); in snd_cs4231_sbus_create()
1805 chip->op = op; in snd_cs4231_sbus_create()
1806 chip->regs_size = resource_size(&op->resource[0]); in snd_cs4231_sbus_create()
1807 memcpy(&chip->image, &snd_cs4231_original_image, in snd_cs4231_sbus_create()
1810 chip->port = of_ioremap(&op->resource[0], 0, in snd_cs4231_sbus_create()
1811 chip->regs_size, "cs4231"); in snd_cs4231_sbus_create()
1812 if (!chip->port) { in snd_cs4231_sbus_create()
1813 snd_printdd("cs4231-%d: Unable to map chip registers.\n", dev); in snd_cs4231_sbus_create()
1817 chip->c_dma.sbus_info.regs = chip->port; in snd_cs4231_sbus_create()
1818 chip->p_dma.sbus_info.regs = chip->port; in snd_cs4231_sbus_create()
1819 chip->c_dma.sbus_info.dir = APC_RECORD; in snd_cs4231_sbus_create()
1820 chip->p_dma.sbus_info.dir = APC_PLAY; in snd_cs4231_sbus_create()
1822 chip->p_dma.prepare = sbus_dma_prepare; in snd_cs4231_sbus_create()
1823 chip->p_dma.enable = sbus_dma_enable; in snd_cs4231_sbus_create()
1824 chip->p_dma.request = sbus_dma_request; in snd_cs4231_sbus_create()
1825 chip->p_dma.address = sbus_dma_addr; in snd_cs4231_sbus_create()
1827 chip->c_dma.prepare = sbus_dma_prepare; in snd_cs4231_sbus_create()
1828 chip->c_dma.enable = sbus_dma_enable; in snd_cs4231_sbus_create()
1829 chip->c_dma.request = sbus_dma_request; in snd_cs4231_sbus_create()
1830 chip->c_dma.address = sbus_dma_addr; in snd_cs4231_sbus_create()
1833 IRQF_SHARED, "cs4231", chip)) { in snd_cs4231_sbus_create()
1836 snd_cs4231_sbus_free(chip); in snd_cs4231_sbus_create()
1839 chip->irq[0] = op->archdata.irqs[0]; in snd_cs4231_sbus_create()
1841 if (snd_cs4231_probe(chip) < 0) { in snd_cs4231_sbus_create()
1842 snd_cs4231_sbus_free(chip); in snd_cs4231_sbus_create()
1845 snd_cs4231_init(chip); in snd_cs4231_sbus_create()
1848 chip, &snd_cs4231_sbus_dev_ops)) < 0) { in snd_cs4231_sbus_create()
1849 snd_cs4231_sbus_free(chip); in snd_cs4231_sbus_create()
1887 struct snd_cs4231 *chip = cookie; in snd_cs4231_ebus_play_callback() local
1889 snd_cs4231_play_callback(chip); in snd_cs4231_ebus_play_callback()
1895 struct snd_cs4231 *chip = cookie; in snd_cs4231_ebus_capture_callback() local
1897 snd_cs4231_capture_callback(chip); in snd_cs4231_ebus_capture_callback()
1929 static int snd_cs4231_ebus_free(struct snd_cs4231 *chip) in snd_cs4231_ebus_free() argument
1931 struct platform_device *op = chip->op; in snd_cs4231_ebus_free()
1933 if (chip->c_dma.ebus_info.regs) { in snd_cs4231_ebus_free()
1934 ebus_dma_unregister(&chip->c_dma.ebus_info); in snd_cs4231_ebus_free()
1935 of_iounmap(&op->resource[2], chip->c_dma.ebus_info.regs, 0x10); in snd_cs4231_ebus_free()
1937 if (chip->p_dma.ebus_info.regs) { in snd_cs4231_ebus_free()
1938 ebus_dma_unregister(&chip->p_dma.ebus_info); in snd_cs4231_ebus_free()
1939 of_iounmap(&op->resource[1], chip->p_dma.ebus_info.regs, 0x10); in snd_cs4231_ebus_free()
1942 if (chip->port) in snd_cs4231_ebus_free()
1943 of_iounmap(&op->resource[0], chip->port, 0x10); in snd_cs4231_ebus_free()
1963 struct snd_cs4231 *chip = card->private_data; in snd_cs4231_ebus_create() local
1966 spin_lock_init(&chip->lock); in snd_cs4231_ebus_create()
1967 spin_lock_init(&chip->c_dma.ebus_info.lock); in snd_cs4231_ebus_create()
1968 spin_lock_init(&chip->p_dma.ebus_info.lock); in snd_cs4231_ebus_create()
1969 mutex_init(&chip->mce_mutex); in snd_cs4231_ebus_create()
1970 mutex_init(&chip->open_mutex); in snd_cs4231_ebus_create()
1971 chip->flags |= CS4231_FLAG_EBUS; in snd_cs4231_ebus_create()
1972 chip->op = op; in snd_cs4231_ebus_create()
1973 memcpy(&chip->image, &snd_cs4231_original_image, in snd_cs4231_ebus_create()
1975 strcpy(chip->c_dma.ebus_info.name, "cs4231(capture)"); in snd_cs4231_ebus_create()
1976 chip->c_dma.ebus_info.flags = EBUS_DMA_FLAG_USE_EBDMA_HANDLER; in snd_cs4231_ebus_create()
1977 chip->c_dma.ebus_info.callback = snd_cs4231_ebus_capture_callback; in snd_cs4231_ebus_create()
1978 chip->c_dma.ebus_info.client_cookie = chip; in snd_cs4231_ebus_create()
1979 chip->c_dma.ebus_info.irq = op->archdata.irqs[0]; in snd_cs4231_ebus_create()
1980 strcpy(chip->p_dma.ebus_info.name, "cs4231(play)"); in snd_cs4231_ebus_create()
1981 chip->p_dma.ebus_info.flags = EBUS_DMA_FLAG_USE_EBDMA_HANDLER; in snd_cs4231_ebus_create()
1982 chip->p_dma.ebus_info.callback = snd_cs4231_ebus_play_callback; in snd_cs4231_ebus_create()
1983 chip->p_dma.ebus_info.client_cookie = chip; in snd_cs4231_ebus_create()
1984 chip->p_dma.ebus_info.irq = op->archdata.irqs[1]; in snd_cs4231_ebus_create()
1986 chip->p_dma.prepare = _ebus_dma_prepare; in snd_cs4231_ebus_create()
1987 chip->p_dma.enable = _ebus_dma_enable; in snd_cs4231_ebus_create()
1988 chip->p_dma.request = _ebus_dma_request; in snd_cs4231_ebus_create()
1989 chip->p_dma.address = _ebus_dma_addr; in snd_cs4231_ebus_create()
1991 chip->c_dma.prepare = _ebus_dma_prepare; in snd_cs4231_ebus_create()
1992 chip->c_dma.enable = _ebus_dma_enable; in snd_cs4231_ebus_create()
1993 chip->c_dma.request = _ebus_dma_request; in snd_cs4231_ebus_create()
1994 chip->c_dma.address = _ebus_dma_addr; in snd_cs4231_ebus_create()
1996 chip->port = of_ioremap(&op->resource[0], 0, 0x10, "cs4231"); in snd_cs4231_ebus_create()
1997 chip->p_dma.ebus_info.regs = in snd_cs4231_ebus_create()
1999 chip->c_dma.ebus_info.regs = in snd_cs4231_ebus_create()
2001 if (!chip->port || !chip->p_dma.ebus_info.regs || in snd_cs4231_ebus_create()
2002 !chip->c_dma.ebus_info.regs) { in snd_cs4231_ebus_create()
2003 snd_cs4231_ebus_free(chip); in snd_cs4231_ebus_create()
2004 snd_printdd("cs4231-%d: Unable to map chip registers.\n", dev); in snd_cs4231_ebus_create()
2008 if (ebus_dma_register(&chip->c_dma.ebus_info)) { in snd_cs4231_ebus_create()
2009 snd_cs4231_ebus_free(chip); in snd_cs4231_ebus_create()
2014 if (ebus_dma_irq_enable(&chip->c_dma.ebus_info, 1)) { in snd_cs4231_ebus_create()
2015 snd_cs4231_ebus_free(chip); in snd_cs4231_ebus_create()
2021 if (ebus_dma_register(&chip->p_dma.ebus_info)) { in snd_cs4231_ebus_create()
2022 snd_cs4231_ebus_free(chip); in snd_cs4231_ebus_create()
2027 if (ebus_dma_irq_enable(&chip->p_dma.ebus_info, 1)) { in snd_cs4231_ebus_create()
2028 snd_cs4231_ebus_free(chip); in snd_cs4231_ebus_create()
2033 if (snd_cs4231_probe(chip) < 0) { in snd_cs4231_ebus_create()
2034 snd_cs4231_ebus_free(chip); in snd_cs4231_ebus_create()
2037 snd_cs4231_init(chip); in snd_cs4231_ebus_create()
2040 chip, &snd_cs4231_ebus_dev_ops)) < 0) { in snd_cs4231_ebus_create()
2041 snd_cs4231_ebus_free(chip); in snd_cs4231_ebus_create()
2088 struct snd_cs4231 *chip = dev_get_drvdata(&op->dev); in cs4231_remove() local
2090 snd_card_free(chip->card); in cs4231_remove()