Lines Matching refs:chip
128 #define CS4231U(chip, x) ((chip)->port + ((c_d_c_CS4231##x) << 2)) argument
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()
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()
331 __cs4231_writeb(chip, chip->mce_bit | reg, CS4231U(chip, REGSEL)); in snd_cs4231_in()
333 return __cs4231_readb(chip, CS4231U(chip, REG)); in snd_cs4231_in()
340 static void snd_cs4231_busy_wait(struct snd_cs4231 *chip) in snd_cs4231_busy_wait() argument
346 __cs4231_readb(chip, CS4231U(chip, REGSEL)); in snd_cs4231_busy_wait()
350 int val = __cs4231_readb(chip, CS4231U(chip, REGSEL)); in snd_cs4231_busy_wait()
357 static void snd_cs4231_mce_up(struct snd_cs4231 *chip) in snd_cs4231_mce_up() argument
362 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_mce_up()
363 snd_cs4231_ready(chip); in snd_cs4231_mce_up()
365 if (__cs4231_readb(chip, CS4231U(chip, REGSEL)) & CS4231_INIT) in snd_cs4231_mce_up()
368 chip->mce_bit |= CS4231_MCE; in snd_cs4231_mce_up()
369 timeout = __cs4231_readb(chip, CS4231U(chip, REGSEL)); in snd_cs4231_mce_up()
373 chip->port); in snd_cs4231_mce_up()
375 __cs4231_writeb(chip, chip->mce_bit | (timeout & 0x1f), in snd_cs4231_mce_up()
376 CS4231U(chip, REGSEL)); in snd_cs4231_mce_up()
377 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_mce_up()
380 static void snd_cs4231_mce_down(struct snd_cs4231 *chip) in snd_cs4231_mce_down() argument
385 snd_cs4231_busy_wait(chip); in snd_cs4231_mce_down()
386 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_mce_down()
388 if (__cs4231_readb(chip, CS4231U(chip, REGSEL)) & CS4231_INIT) in snd_cs4231_mce_down()
390 CS4231U(chip, REGSEL)); in snd_cs4231_mce_down()
392 chip->mce_bit &= ~CS4231_MCE; in snd_cs4231_mce_down()
393 reg = __cs4231_readb(chip, CS4231U(chip, REGSEL)); in snd_cs4231_mce_down()
394 __cs4231_writeb(chip, chip->mce_bit | (reg & 0x1f), in snd_cs4231_mce_down()
395 CS4231U(chip, REGSEL)); in snd_cs4231_mce_down()
398 "- codec still busy\n", chip->port); in snd_cs4231_mce_down()
400 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_mce_down()
409 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_mce_down()
411 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_mce_down()
412 reg = snd_cs4231_in(chip, CS4231_TEST_INIT); in snd_cs4231_mce_down()
415 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_mce_down()
445 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); in cs4231_dma_trigger() local
449 dma_cont = &chip->p_dma; in cs4231_dma_trigger()
454 chip->playback_substream, in cs4231_dma_trigger()
455 &chip->p_periods_sent); in cs4231_dma_trigger()
461 dma_cont = &chip->c_dma; in cs4231_dma_trigger()
466 chip->capture_substream, in cs4231_dma_trigger()
467 &chip->c_periods_sent); in cs4231_dma_trigger()
476 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); in snd_cs4231_trigger() local
488 if (s == chip->playback_substream) { in snd_cs4231_trigger()
491 } else if (s == chip->capture_substream) { in snd_cs4231_trigger()
497 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_trigger()
500 chip->image[CS4231_IFACE_CTRL] |= what; in snd_cs4231_trigger()
503 chip->image[CS4231_IFACE_CTRL] &= ~what; in snd_cs4231_trigger()
505 snd_cs4231_out(chip, CS4231_IFACE_CTRL, in snd_cs4231_trigger()
506 chip->image[CS4231_IFACE_CTRL]); in snd_cs4231_trigger()
507 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_trigger()
533 static unsigned char snd_cs4231_get_format(struct snd_cs4231 *chip, int format, in snd_cs4231_get_format() argument
561 static void snd_cs4231_calibrate_mute(struct snd_cs4231 *chip, int mute) in snd_cs4231_calibrate_mute() argument
566 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_calibrate_mute()
567 if (chip->calibrate_mute == mute) { in snd_cs4231_calibrate_mute()
568 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_calibrate_mute()
572 snd_cs4231_dout(chip, CS4231_LEFT_INPUT, in snd_cs4231_calibrate_mute()
573 chip->image[CS4231_LEFT_INPUT]); in snd_cs4231_calibrate_mute()
574 snd_cs4231_dout(chip, CS4231_RIGHT_INPUT, in snd_cs4231_calibrate_mute()
575 chip->image[CS4231_RIGHT_INPUT]); in snd_cs4231_calibrate_mute()
576 snd_cs4231_dout(chip, CS4231_LOOPBACK, in snd_cs4231_calibrate_mute()
577 chip->image[CS4231_LOOPBACK]); in snd_cs4231_calibrate_mute()
579 snd_cs4231_dout(chip, CS4231_AUX1_LEFT_INPUT, in snd_cs4231_calibrate_mute()
580 mute ? 0x80 : chip->image[CS4231_AUX1_LEFT_INPUT]); in snd_cs4231_calibrate_mute()
581 snd_cs4231_dout(chip, CS4231_AUX1_RIGHT_INPUT, in snd_cs4231_calibrate_mute()
582 mute ? 0x80 : chip->image[CS4231_AUX1_RIGHT_INPUT]); in snd_cs4231_calibrate_mute()
583 snd_cs4231_dout(chip, CS4231_AUX2_LEFT_INPUT, in snd_cs4231_calibrate_mute()
584 mute ? 0x80 : chip->image[CS4231_AUX2_LEFT_INPUT]); in snd_cs4231_calibrate_mute()
585 snd_cs4231_dout(chip, CS4231_AUX2_RIGHT_INPUT, in snd_cs4231_calibrate_mute()
586 mute ? 0x80 : chip->image[CS4231_AUX2_RIGHT_INPUT]); in snd_cs4231_calibrate_mute()
587 snd_cs4231_dout(chip, CS4231_LEFT_OUTPUT, in snd_cs4231_calibrate_mute()
588 mute ? 0x80 : chip->image[CS4231_LEFT_OUTPUT]); in snd_cs4231_calibrate_mute()
589 snd_cs4231_dout(chip, CS4231_RIGHT_OUTPUT, in snd_cs4231_calibrate_mute()
590 mute ? 0x80 : chip->image[CS4231_RIGHT_OUTPUT]); in snd_cs4231_calibrate_mute()
591 snd_cs4231_dout(chip, CS4231_LEFT_LINE_IN, in snd_cs4231_calibrate_mute()
592 mute ? 0x80 : chip->image[CS4231_LEFT_LINE_IN]); in snd_cs4231_calibrate_mute()
593 snd_cs4231_dout(chip, CS4231_RIGHT_LINE_IN, in snd_cs4231_calibrate_mute()
594 mute ? 0x80 : chip->image[CS4231_RIGHT_LINE_IN]); in snd_cs4231_calibrate_mute()
595 snd_cs4231_dout(chip, CS4231_MONO_CTRL, in snd_cs4231_calibrate_mute()
596 mute ? 0xc0 : chip->image[CS4231_MONO_CTRL]); in snd_cs4231_calibrate_mute()
597 chip->calibrate_mute = mute; in snd_cs4231_calibrate_mute()
598 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_calibrate_mute()
601 static void snd_cs4231_playback_format(struct snd_cs4231 *chip, in snd_cs4231_playback_format() argument
607 mutex_lock(&chip->mce_mutex); in snd_cs4231_playback_format()
608 snd_cs4231_calibrate_mute(chip, 1); in snd_cs4231_playback_format()
610 snd_cs4231_mce_up(chip); in snd_cs4231_playback_format()
612 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_playback_format()
613 snd_cs4231_out(chip, CS4231_PLAYBK_FORMAT, in snd_cs4231_playback_format()
614 (chip->image[CS4231_IFACE_CTRL] & CS4231_RECORD_ENABLE) ? in snd_cs4231_playback_format()
615 (pdfr & 0xf0) | (chip->image[CS4231_REC_FORMAT] & 0x0f) : in snd_cs4231_playback_format()
617 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_playback_format()
619 snd_cs4231_mce_down(chip); in snd_cs4231_playback_format()
621 snd_cs4231_calibrate_mute(chip, 0); in snd_cs4231_playback_format()
622 mutex_unlock(&chip->mce_mutex); in snd_cs4231_playback_format()
625 static void snd_cs4231_capture_format(struct snd_cs4231 *chip, in snd_cs4231_capture_format() argument
631 mutex_lock(&chip->mce_mutex); in snd_cs4231_capture_format()
632 snd_cs4231_calibrate_mute(chip, 1); in snd_cs4231_capture_format()
634 snd_cs4231_mce_up(chip); in snd_cs4231_capture_format()
636 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_capture_format()
637 if (!(chip->image[CS4231_IFACE_CTRL] & CS4231_PLAYBACK_ENABLE)) { in snd_cs4231_capture_format()
638 snd_cs4231_out(chip, CS4231_PLAYBK_FORMAT, in snd_cs4231_capture_format()
639 ((chip->image[CS4231_PLAYBK_FORMAT]) & 0xf0) | in snd_cs4231_capture_format()
641 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_capture_format()
642 snd_cs4231_mce_down(chip); in snd_cs4231_capture_format()
643 snd_cs4231_mce_up(chip); in snd_cs4231_capture_format()
644 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_capture_format()
646 snd_cs4231_out(chip, CS4231_REC_FORMAT, cdfr); in snd_cs4231_capture_format()
647 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_capture_format()
649 snd_cs4231_mce_down(chip); in snd_cs4231_capture_format()
651 snd_cs4231_calibrate_mute(chip, 0); in snd_cs4231_capture_format()
652 mutex_unlock(&chip->mce_mutex); in snd_cs4231_capture_format()
661 struct snd_cs4231 *chip = snd_timer_chip(timer); in snd_cs4231_timer_resolution() local
663 return chip->image[CS4231_PLAYBK_FORMAT] & 1 ? 9969 : 9920; in snd_cs4231_timer_resolution()
670 struct snd_cs4231 *chip = snd_timer_chip(timer); in snd_cs4231_timer_start() local
672 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_timer_start()
674 if ((chip->image[CS4231_ALT_FEATURE_1] & CS4231_TIMER_ENABLE) == 0 || in snd_cs4231_timer_start()
675 (unsigned char)(ticks >> 8) != chip->image[CS4231_TIMER_HIGH] || in snd_cs4231_timer_start()
676 (unsigned char)ticks != chip->image[CS4231_TIMER_LOW]) { in snd_cs4231_timer_start()
677 snd_cs4231_out(chip, CS4231_TIMER_HIGH, in snd_cs4231_timer_start()
678 chip->image[CS4231_TIMER_HIGH] = in snd_cs4231_timer_start()
680 snd_cs4231_out(chip, CS4231_TIMER_LOW, in snd_cs4231_timer_start()
681 chip->image[CS4231_TIMER_LOW] = in snd_cs4231_timer_start()
683 snd_cs4231_out(chip, CS4231_ALT_FEATURE_1, in snd_cs4231_timer_start()
684 chip->image[CS4231_ALT_FEATURE_1] | in snd_cs4231_timer_start()
687 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_timer_start()
695 struct snd_cs4231 *chip = snd_timer_chip(timer); in snd_cs4231_timer_stop() local
697 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_timer_stop()
698 chip->image[CS4231_ALT_FEATURE_1] &= ~CS4231_TIMER_ENABLE; in snd_cs4231_timer_stop()
699 snd_cs4231_out(chip, CS4231_ALT_FEATURE_1, in snd_cs4231_timer_stop()
700 chip->image[CS4231_ALT_FEATURE_1]); in snd_cs4231_timer_stop()
701 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_timer_stop()
706 static void snd_cs4231_init(struct snd_cs4231 *chip) in snd_cs4231_init() argument
710 snd_cs4231_mce_down(chip); in snd_cs4231_init()
715 snd_cs4231_mce_up(chip); in snd_cs4231_init()
716 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_init()
717 chip->image[CS4231_IFACE_CTRL] &= ~(CS4231_PLAYBACK_ENABLE | in snd_cs4231_init()
722 chip->image[CS4231_IFACE_CTRL] |= CS4231_AUTOCALIB; in snd_cs4231_init()
723 snd_cs4231_out(chip, CS4231_IFACE_CTRL, chip->image[CS4231_IFACE_CTRL]); in snd_cs4231_init()
724 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_init()
725 snd_cs4231_mce_down(chip); in snd_cs4231_init()
731 snd_cs4231_mce_up(chip); in snd_cs4231_init()
732 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_init()
733 snd_cs4231_out(chip, CS4231_ALT_FEATURE_1, in snd_cs4231_init()
734 chip->image[CS4231_ALT_FEATURE_1]); in snd_cs4231_init()
735 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_init()
736 snd_cs4231_mce_down(chip); in snd_cs4231_init()
740 chip->image[CS4231_ALT_FEATURE_1]); in snd_cs4231_init()
743 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_init()
744 snd_cs4231_out(chip, CS4231_ALT_FEATURE_2, in snd_cs4231_init()
745 chip->image[CS4231_ALT_FEATURE_2]); in snd_cs4231_init()
746 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_init()
748 snd_cs4231_mce_up(chip); in snd_cs4231_init()
749 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_init()
750 snd_cs4231_out(chip, CS4231_PLAYBK_FORMAT, in snd_cs4231_init()
751 chip->image[CS4231_PLAYBK_FORMAT]); in snd_cs4231_init()
752 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_init()
753 snd_cs4231_mce_down(chip); in snd_cs4231_init()
759 snd_cs4231_mce_up(chip); in snd_cs4231_init()
760 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_init()
761 snd_cs4231_out(chip, CS4231_REC_FORMAT, chip->image[CS4231_REC_FORMAT]); in snd_cs4231_init()
762 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_init()
763 snd_cs4231_mce_down(chip); in snd_cs4231_init()
770 static int snd_cs4231_open(struct snd_cs4231 *chip, unsigned int mode) in snd_cs4231_open() argument
774 mutex_lock(&chip->open_mutex); in snd_cs4231_open()
775 if ((chip->mode & mode)) { in snd_cs4231_open()
776 mutex_unlock(&chip->open_mutex); in snd_cs4231_open()
779 if (chip->mode & CS4231_MODE_OPEN) { in snd_cs4231_open()
780 chip->mode |= mode; in snd_cs4231_open()
781 mutex_unlock(&chip->open_mutex); in snd_cs4231_open()
785 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_open()
786 snd_cs4231_out(chip, CS4231_IRQ_STATUS, CS4231_PLAYBACK_IRQ | in snd_cs4231_open()
789 snd_cs4231_out(chip, CS4231_IRQ_STATUS, 0); in snd_cs4231_open()
790 __cs4231_writeb(chip, 0, CS4231U(chip, STATUS)); /* clear IRQ */ in snd_cs4231_open()
791 __cs4231_writeb(chip, 0, CS4231U(chip, STATUS)); /* clear IRQ */ in snd_cs4231_open()
793 snd_cs4231_out(chip, CS4231_IRQ_STATUS, CS4231_PLAYBACK_IRQ | in snd_cs4231_open()
796 snd_cs4231_out(chip, CS4231_IRQ_STATUS, 0); in snd_cs4231_open()
798 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_open()
800 chip->mode = mode; in snd_cs4231_open()
801 mutex_unlock(&chip->open_mutex); in snd_cs4231_open()
805 static void snd_cs4231_close(struct snd_cs4231 *chip, unsigned int mode) in snd_cs4231_close() argument
809 mutex_lock(&chip->open_mutex); in snd_cs4231_close()
810 chip->mode &= ~mode; in snd_cs4231_close()
811 if (chip->mode & CS4231_MODE_OPEN) { in snd_cs4231_close()
812 mutex_unlock(&chip->open_mutex); in snd_cs4231_close()
815 snd_cs4231_calibrate_mute(chip, 1); in snd_cs4231_close()
818 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_close()
819 snd_cs4231_out(chip, CS4231_IRQ_STATUS, 0); in snd_cs4231_close()
820 __cs4231_writeb(chip, 0, CS4231U(chip, STATUS)); /* clear IRQ */ in snd_cs4231_close()
821 __cs4231_writeb(chip, 0, CS4231U(chip, STATUS)); /* clear IRQ */ in snd_cs4231_close()
825 if (chip->image[CS4231_IFACE_CTRL] & in snd_cs4231_close()
828 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_close()
829 snd_cs4231_mce_up(chip); in snd_cs4231_close()
830 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_close()
831 chip->image[CS4231_IFACE_CTRL] &= in snd_cs4231_close()
834 snd_cs4231_out(chip, CS4231_IFACE_CTRL, in snd_cs4231_close()
835 chip->image[CS4231_IFACE_CTRL]); in snd_cs4231_close()
836 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_close()
837 snd_cs4231_mce_down(chip); in snd_cs4231_close()
838 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_close()
842 snd_cs4231_out(chip, CS4231_IRQ_STATUS, 0); in snd_cs4231_close()
843 __cs4231_writeb(chip, 0, CS4231U(chip, STATUS)); /* clear IRQ */ in snd_cs4231_close()
844 __cs4231_writeb(chip, 0, CS4231U(chip, STATUS)); /* clear IRQ */ in snd_cs4231_close()
845 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_close()
847 snd_cs4231_calibrate_mute(chip, 0); in snd_cs4231_close()
849 chip->mode = 0; in snd_cs4231_close()
850 mutex_unlock(&chip->open_mutex); in snd_cs4231_close()
859 struct snd_cs4231 *chip = snd_timer_chip(timer); in snd_cs4231_timer_open() local
860 snd_cs4231_open(chip, CS4231_MODE_TIMER); in snd_cs4231_timer_open()
866 struct snd_cs4231 *chip = snd_timer_chip(timer); in snd_cs4231_timer_close() local
867 snd_cs4231_close(chip, CS4231_MODE_TIMER); in snd_cs4231_timer_close()
889 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); in snd_cs4231_playback_hw_params() local
892 new_pdfr = snd_cs4231_get_format(chip, params_format(hw_params), in snd_cs4231_playback_hw_params()
895 snd_cs4231_playback_format(chip, hw_params, new_pdfr); in snd_cs4231_playback_hw_params()
902 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); in snd_cs4231_playback_prepare() local
907 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_playback_prepare()
909 chip->image[CS4231_IFACE_CTRL] &= ~(CS4231_PLAYBACK_ENABLE | in snd_cs4231_playback_prepare()
917 chip->p_periods_sent = 0; in snd_cs4231_playback_prepare()
920 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_playback_prepare()
928 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); in snd_cs4231_capture_hw_params() local
931 new_cdfr = snd_cs4231_get_format(chip, params_format(hw_params), in snd_cs4231_capture_hw_params()
934 snd_cs4231_capture_format(chip, hw_params, new_cdfr); in snd_cs4231_capture_hw_params()
941 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); in snd_cs4231_capture_prepare() local
944 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_capture_prepare()
945 chip->image[CS4231_IFACE_CTRL] &= ~(CS4231_RECORD_ENABLE | in snd_cs4231_capture_prepare()
949 chip->c_periods_sent = 0; in snd_cs4231_capture_prepare()
950 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_capture_prepare()
955 static void snd_cs4231_overrange(struct snd_cs4231 *chip) in snd_cs4231_overrange() argument
960 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_overrange()
961 res = snd_cs4231_in(chip, CS4231_TEST_INIT); in snd_cs4231_overrange()
962 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_overrange()
966 chip->capture_substream->runtime->overrange++; in snd_cs4231_overrange()
969 static void snd_cs4231_play_callback(struct snd_cs4231 *chip) in snd_cs4231_play_callback() argument
971 if (chip->image[CS4231_IFACE_CTRL] & CS4231_PLAYBACK_ENABLE) { in snd_cs4231_play_callback()
972 snd_pcm_period_elapsed(chip->playback_substream); in snd_cs4231_play_callback()
973 snd_cs4231_advance_dma(&chip->p_dma, chip->playback_substream, in snd_cs4231_play_callback()
974 &chip->p_periods_sent); in snd_cs4231_play_callback()
978 static void snd_cs4231_capture_callback(struct snd_cs4231 *chip) in snd_cs4231_capture_callback() argument
980 if (chip->image[CS4231_IFACE_CTRL] & CS4231_RECORD_ENABLE) { in snd_cs4231_capture_callback()
981 snd_pcm_period_elapsed(chip->capture_substream); in snd_cs4231_capture_callback()
982 snd_cs4231_advance_dma(&chip->c_dma, chip->capture_substream, in snd_cs4231_capture_callback()
983 &chip->c_periods_sent); in snd_cs4231_capture_callback()
990 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); in snd_cs4231_playback_pointer() local
991 struct cs4231_dma_control *dma_cont = &chip->p_dma; in snd_cs4231_playback_pointer()
994 if (!(chip->image[CS4231_IFACE_CTRL] & CS4231_PLAYBACK_ENABLE)) in snd_cs4231_playback_pointer()
1006 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); in snd_cs4231_capture_pointer() local
1007 struct cs4231_dma_control *dma_cont = &chip->c_dma; in snd_cs4231_capture_pointer()
1010 if (!(chip->image[CS4231_IFACE_CTRL] & CS4231_RECORD_ENABLE)) in snd_cs4231_capture_pointer()
1019 static int snd_cs4231_probe(struct snd_cs4231 *chip) in snd_cs4231_probe() argument
1029 if (__cs4231_readb(chip, CS4231U(chip, REGSEL)) & CS4231_INIT) in snd_cs4231_probe()
1032 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_probe()
1033 snd_cs4231_out(chip, CS4231_MISC_INFO, CS4231_MODE2); in snd_cs4231_probe()
1034 id = snd_cs4231_in(chip, CS4231_MISC_INFO) & 0x0f; in snd_cs4231_probe()
1035 vers = snd_cs4231_in(chip, CS4231_VERSION); in snd_cs4231_probe()
1036 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_probe()
1041 snd_printdd("cs4231: port = %p, id = 0x%x\n", chip->port, id); in snd_cs4231_probe()
1045 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_probe()
1048 __cs4231_readb(chip, CS4231U(chip, STATUS)); in snd_cs4231_probe()
1049 __cs4231_writeb(chip, 0, CS4231U(chip, STATUS)); in snd_cs4231_probe()
1052 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_probe()
1054 chip->image[CS4231_MISC_INFO] = CS4231_MODE2; in snd_cs4231_probe()
1055 chip->image[CS4231_IFACE_CTRL] = in snd_cs4231_probe()
1056 chip->image[CS4231_IFACE_CTRL] & ~CS4231_SINGLE_DMA; in snd_cs4231_probe()
1057 chip->image[CS4231_ALT_FEATURE_1] = 0x80; in snd_cs4231_probe()
1058 chip->image[CS4231_ALT_FEATURE_2] = 0x01; in snd_cs4231_probe()
1060 chip->image[CS4231_ALT_FEATURE_2] |= 0x02; in snd_cs4231_probe()
1062 ptr = (unsigned char *) &chip->image; in snd_cs4231_probe()
1064 snd_cs4231_mce_down(chip); in snd_cs4231_probe()
1066 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_probe()
1069 snd_cs4231_out(chip, i, *ptr++); in snd_cs4231_probe()
1071 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_probe()
1073 snd_cs4231_mce_up(chip); in snd_cs4231_probe()
1075 snd_cs4231_mce_down(chip); in snd_cs4231_probe()
1132 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); in snd_cs4231_playback_open() local
1138 err = snd_cs4231_open(chip, CS4231_MODE_PLAY); in snd_cs4231_playback_open()
1141 chip->playback_substream = substream; in snd_cs4231_playback_open()
1142 chip->p_periods_sent = 0; in snd_cs4231_playback_open()
1151 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); in snd_cs4231_capture_open() local
1157 err = snd_cs4231_open(chip, CS4231_MODE_RECORD); in snd_cs4231_capture_open()
1160 chip->capture_substream = substream; in snd_cs4231_capture_open()
1161 chip->c_periods_sent = 0; in snd_cs4231_capture_open()
1170 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); in snd_cs4231_playback_close() local
1172 snd_cs4231_close(chip, CS4231_MODE_PLAY); in snd_cs4231_playback_close()
1173 chip->playback_substream = NULL; in snd_cs4231_playback_close()
1180 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); in snd_cs4231_capture_close() local
1182 snd_cs4231_close(chip, CS4231_MODE_RECORD); in snd_cs4231_capture_close()
1183 chip->capture_substream = NULL; in snd_cs4231_capture_close()
1212 struct snd_cs4231 *chip = card->private_data; in snd_cs4231_pcm() local
1226 pcm->private_data = chip; in snd_cs4231_pcm()
1231 &chip->op->dev, 64 * 1024, 128 * 1024); in snd_cs4231_pcm()
1233 chip->pcm = pcm; in snd_cs4231_pcm()
1240 struct snd_cs4231 *chip = card->private_data; in snd_cs4231_timer() local
1255 timer->private_data = chip; in snd_cs4231_timer()
1257 chip->timer = timer; in snd_cs4231_timer()
1279 struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); in snd_cs4231_get_mux() local
1282 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_get_mux()
1284 (chip->image[CS4231_LEFT_INPUT] & CS4231_MIXS_ALL) >> 6; in snd_cs4231_get_mux()
1286 (chip->image[CS4231_RIGHT_INPUT] & CS4231_MIXS_ALL) >> 6; in snd_cs4231_get_mux()
1287 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_get_mux()
1295 struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); in snd_cs4231_put_mux() local
1306 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_put_mux()
1308 left = (chip->image[CS4231_LEFT_INPUT] & ~CS4231_MIXS_ALL) | left; in snd_cs4231_put_mux()
1309 right = (chip->image[CS4231_RIGHT_INPUT] & ~CS4231_MIXS_ALL) | right; in snd_cs4231_put_mux()
1310 change = left != chip->image[CS4231_LEFT_INPUT] || in snd_cs4231_put_mux()
1311 right != chip->image[CS4231_RIGHT_INPUT]; in snd_cs4231_put_mux()
1312 snd_cs4231_out(chip, CS4231_LEFT_INPUT, left); in snd_cs4231_put_mux()
1313 snd_cs4231_out(chip, CS4231_RIGHT_INPUT, right); in snd_cs4231_put_mux()
1315 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_put_mux()
1337 struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); in snd_cs4231_get_single() local
1344 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_get_single()
1346 ucontrol->value.integer.value[0] = (chip->image[reg] >> shift) & mask; in snd_cs4231_get_single()
1348 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_get_single()
1360 struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); in snd_cs4231_put_single() local
1374 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_put_single()
1376 val = (chip->image[reg] & ~(mask << shift)) | val; in snd_cs4231_put_single()
1377 change = val != chip->image[reg]; in snd_cs4231_put_single()
1378 snd_cs4231_out(chip, reg, val); in snd_cs4231_put_single()
1380 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_put_single()
1402 struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); in snd_cs4231_get_double() local
1411 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_get_double()
1414 (chip->image[left_reg] >> shift_left) & mask; in snd_cs4231_get_double()
1416 (chip->image[right_reg] >> shift_right) & mask; in snd_cs4231_get_double()
1418 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_get_double()
1433 struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); in snd_cs4231_put_double() local
1453 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_put_double()
1455 val1 = (chip->image[left_reg] & ~(mask << shift_left)) | val1; in snd_cs4231_put_double()
1456 val2 = (chip->image[right_reg] & ~(mask << shift_right)) | val2; in snd_cs4231_put_double()
1457 change = val1 != chip->image[left_reg]; in snd_cs4231_put_double()
1458 change |= val2 != chip->image[right_reg]; in snd_cs4231_put_double()
1459 snd_cs4231_out(chip, left_reg, val1); in snd_cs4231_put_double()
1460 snd_cs4231_out(chip, right_reg, val2); in snd_cs4231_put_double()
1462 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_put_double()
1522 struct snd_cs4231 *chip = card->private_data; in snd_cs4231_mixer() local
1525 if (snd_BUG_ON(!chip || !chip->pcm)) in snd_cs4231_mixer()
1528 strcpy(card->mixername, chip->pcm->name); in snd_cs4231_mixer()
1532 snd_ctl_new1(&snd_cs4231_controls[idx], chip)); in snd_cs4231_mixer()
1545 struct snd_cs4231 *chip; in cs4231_attach_begin() local
1566 chip = card->private_data; in cs4231_attach_begin()
1567 chip->card = card; in cs4231_attach_begin()
1575 struct snd_cs4231 *chip = card->private_data; in cs4231_attach_finish() local
1594 dev_set_drvdata(&chip->op->dev, chip); in cs4231_attach_finish()
1611 struct snd_cs4231 *chip = dev_id; in snd_cs4231_sbus_interrupt() local
1614 if (!(__cs4231_readb(chip, CS4231U(chip, STATUS)) & CS4231_GLOBALIRQ)) in snd_cs4231_sbus_interrupt()
1618 csr = sbus_readl(chip->port + APCCSR); in snd_cs4231_sbus_interrupt()
1620 sbus_writel(csr, chip->port + APCCSR); in snd_cs4231_sbus_interrupt()
1626 snd_cs4231_play_callback(chip); in snd_cs4231_sbus_interrupt()
1632 snd_cs4231_capture_callback(chip); in snd_cs4231_sbus_interrupt()
1634 status = snd_cs4231_in(chip, CS4231_IRQ_STATUS); in snd_cs4231_sbus_interrupt()
1637 if (chip->timer) in snd_cs4231_sbus_interrupt()
1638 snd_timer_interrupt(chip->timer, chip->timer->sticks); in snd_cs4231_sbus_interrupt()
1642 snd_cs4231_overrange(chip); in snd_cs4231_sbus_interrupt()
1645 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_sbus_interrupt()
1646 snd_cs4231_outm(chip, CS4231_IRQ_STATUS, ~CS4231_ALL_IRQS | ~status, 0); in snd_cs4231_sbus_interrupt()
1647 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_sbus_interrupt()
1753 static int snd_cs4231_sbus_free(struct snd_cs4231 *chip) in snd_cs4231_sbus_free() argument
1755 struct platform_device *op = chip->op; in snd_cs4231_sbus_free()
1757 if (chip->irq[0]) in snd_cs4231_sbus_free()
1758 free_irq(chip->irq[0], chip); in snd_cs4231_sbus_free()
1760 if (chip->port) in snd_cs4231_sbus_free()
1761 of_iounmap(&op->resource[0], chip->port, chip->regs_size); in snd_cs4231_sbus_free()
1781 struct snd_cs4231 *chip = card->private_data; in snd_cs4231_sbus_create() local
1784 spin_lock_init(&chip->lock); in snd_cs4231_sbus_create()
1785 spin_lock_init(&chip->c_dma.sbus_info.lock); in snd_cs4231_sbus_create()
1786 spin_lock_init(&chip->p_dma.sbus_info.lock); in snd_cs4231_sbus_create()
1787 mutex_init(&chip->mce_mutex); in snd_cs4231_sbus_create()
1788 mutex_init(&chip->open_mutex); in snd_cs4231_sbus_create()
1789 chip->op = op; in snd_cs4231_sbus_create()
1790 chip->regs_size = resource_size(&op->resource[0]); in snd_cs4231_sbus_create()
1791 memcpy(&chip->image, &snd_cs4231_original_image, in snd_cs4231_sbus_create()
1794 chip->port = of_ioremap(&op->resource[0], 0, in snd_cs4231_sbus_create()
1795 chip->regs_size, "cs4231"); in snd_cs4231_sbus_create()
1796 if (!chip->port) { in snd_cs4231_sbus_create()
1801 chip->c_dma.sbus_info.regs = chip->port; in snd_cs4231_sbus_create()
1802 chip->p_dma.sbus_info.regs = chip->port; in snd_cs4231_sbus_create()
1803 chip->c_dma.sbus_info.dir = APC_RECORD; in snd_cs4231_sbus_create()
1804 chip->p_dma.sbus_info.dir = APC_PLAY; in snd_cs4231_sbus_create()
1806 chip->p_dma.prepare = sbus_dma_prepare; in snd_cs4231_sbus_create()
1807 chip->p_dma.enable = sbus_dma_enable; in snd_cs4231_sbus_create()
1808 chip->p_dma.request = sbus_dma_request; in snd_cs4231_sbus_create()
1809 chip->p_dma.address = sbus_dma_addr; in snd_cs4231_sbus_create()
1811 chip->c_dma.prepare = sbus_dma_prepare; in snd_cs4231_sbus_create()
1812 chip->c_dma.enable = sbus_dma_enable; in snd_cs4231_sbus_create()
1813 chip->c_dma.request = sbus_dma_request; in snd_cs4231_sbus_create()
1814 chip->c_dma.address = sbus_dma_addr; in snd_cs4231_sbus_create()
1817 IRQF_SHARED, "cs4231", chip)) { in snd_cs4231_sbus_create()
1820 snd_cs4231_sbus_free(chip); in snd_cs4231_sbus_create()
1823 chip->irq[0] = op->archdata.irqs[0]; in snd_cs4231_sbus_create()
1825 if (snd_cs4231_probe(chip) < 0) { in snd_cs4231_sbus_create()
1826 snd_cs4231_sbus_free(chip); in snd_cs4231_sbus_create()
1829 snd_cs4231_init(chip); in snd_cs4231_sbus_create()
1832 chip, &snd_cs4231_sbus_dev_ops); in snd_cs4231_sbus_create()
1834 snd_cs4231_sbus_free(chip); in snd_cs4231_sbus_create()
1872 struct snd_cs4231 *chip = cookie; in snd_cs4231_ebus_play_callback() local
1874 snd_cs4231_play_callback(chip); in snd_cs4231_ebus_play_callback()
1880 struct snd_cs4231 *chip = cookie; in snd_cs4231_ebus_capture_callback() local
1882 snd_cs4231_capture_callback(chip); in snd_cs4231_ebus_capture_callback()
1914 static int snd_cs4231_ebus_free(struct snd_cs4231 *chip) in snd_cs4231_ebus_free() argument
1916 struct platform_device *op = chip->op; in snd_cs4231_ebus_free()
1918 if (chip->c_dma.ebus_info.regs) { in snd_cs4231_ebus_free()
1919 ebus_dma_unregister(&chip->c_dma.ebus_info); in snd_cs4231_ebus_free()
1920 of_iounmap(&op->resource[2], chip->c_dma.ebus_info.regs, 0x10); in snd_cs4231_ebus_free()
1922 if (chip->p_dma.ebus_info.regs) { in snd_cs4231_ebus_free()
1923 ebus_dma_unregister(&chip->p_dma.ebus_info); in snd_cs4231_ebus_free()
1924 of_iounmap(&op->resource[1], chip->p_dma.ebus_info.regs, 0x10); in snd_cs4231_ebus_free()
1927 if (chip->port) in snd_cs4231_ebus_free()
1928 of_iounmap(&op->resource[0], chip->port, 0x10); in snd_cs4231_ebus_free()
1948 struct snd_cs4231 *chip = card->private_data; in snd_cs4231_ebus_create() local
1951 spin_lock_init(&chip->lock); in snd_cs4231_ebus_create()
1952 spin_lock_init(&chip->c_dma.ebus_info.lock); in snd_cs4231_ebus_create()
1953 spin_lock_init(&chip->p_dma.ebus_info.lock); in snd_cs4231_ebus_create()
1954 mutex_init(&chip->mce_mutex); in snd_cs4231_ebus_create()
1955 mutex_init(&chip->open_mutex); in snd_cs4231_ebus_create()
1956 chip->flags |= CS4231_FLAG_EBUS; in snd_cs4231_ebus_create()
1957 chip->op = op; in snd_cs4231_ebus_create()
1958 memcpy(&chip->image, &snd_cs4231_original_image, in snd_cs4231_ebus_create()
1960 strcpy(chip->c_dma.ebus_info.name, "cs4231(capture)"); in snd_cs4231_ebus_create()
1961 chip->c_dma.ebus_info.flags = EBUS_DMA_FLAG_USE_EBDMA_HANDLER; in snd_cs4231_ebus_create()
1962 chip->c_dma.ebus_info.callback = snd_cs4231_ebus_capture_callback; in snd_cs4231_ebus_create()
1963 chip->c_dma.ebus_info.client_cookie = chip; in snd_cs4231_ebus_create()
1964 chip->c_dma.ebus_info.irq = op->archdata.irqs[0]; in snd_cs4231_ebus_create()
1965 strcpy(chip->p_dma.ebus_info.name, "cs4231(play)"); in snd_cs4231_ebus_create()
1966 chip->p_dma.ebus_info.flags = EBUS_DMA_FLAG_USE_EBDMA_HANDLER; in snd_cs4231_ebus_create()
1967 chip->p_dma.ebus_info.callback = snd_cs4231_ebus_play_callback; in snd_cs4231_ebus_create()
1968 chip->p_dma.ebus_info.client_cookie = chip; in snd_cs4231_ebus_create()
1969 chip->p_dma.ebus_info.irq = op->archdata.irqs[1]; in snd_cs4231_ebus_create()
1971 chip->p_dma.prepare = _ebus_dma_prepare; in snd_cs4231_ebus_create()
1972 chip->p_dma.enable = _ebus_dma_enable; in snd_cs4231_ebus_create()
1973 chip->p_dma.request = _ebus_dma_request; in snd_cs4231_ebus_create()
1974 chip->p_dma.address = _ebus_dma_addr; in snd_cs4231_ebus_create()
1976 chip->c_dma.prepare = _ebus_dma_prepare; in snd_cs4231_ebus_create()
1977 chip->c_dma.enable = _ebus_dma_enable; in snd_cs4231_ebus_create()
1978 chip->c_dma.request = _ebus_dma_request; in snd_cs4231_ebus_create()
1979 chip->c_dma.address = _ebus_dma_addr; in snd_cs4231_ebus_create()
1981 chip->port = of_ioremap(&op->resource[0], 0, 0x10, "cs4231"); in snd_cs4231_ebus_create()
1982 chip->p_dma.ebus_info.regs = in snd_cs4231_ebus_create()
1984 chip->c_dma.ebus_info.regs = in snd_cs4231_ebus_create()
1986 if (!chip->port || !chip->p_dma.ebus_info.regs || in snd_cs4231_ebus_create()
1987 !chip->c_dma.ebus_info.regs) { in snd_cs4231_ebus_create()
1988 snd_cs4231_ebus_free(chip); in snd_cs4231_ebus_create()
1993 if (ebus_dma_register(&chip->c_dma.ebus_info)) { in snd_cs4231_ebus_create()
1994 snd_cs4231_ebus_free(chip); in snd_cs4231_ebus_create()
1999 if (ebus_dma_irq_enable(&chip->c_dma.ebus_info, 1)) { in snd_cs4231_ebus_create()
2000 snd_cs4231_ebus_free(chip); in snd_cs4231_ebus_create()
2006 if (ebus_dma_register(&chip->p_dma.ebus_info)) { in snd_cs4231_ebus_create()
2007 snd_cs4231_ebus_free(chip); in snd_cs4231_ebus_create()
2012 if (ebus_dma_irq_enable(&chip->p_dma.ebus_info, 1)) { in snd_cs4231_ebus_create()
2013 snd_cs4231_ebus_free(chip); in snd_cs4231_ebus_create()
2018 if (snd_cs4231_probe(chip) < 0) { in snd_cs4231_ebus_create()
2019 snd_cs4231_ebus_free(chip); in snd_cs4231_ebus_create()
2022 snd_cs4231_init(chip); in snd_cs4231_ebus_create()
2025 chip, &snd_cs4231_ebus_dev_ops); in snd_cs4231_ebus_create()
2027 snd_cs4231_ebus_free(chip); in snd_cs4231_ebus_create()
2074 struct snd_cs4231 *chip = dev_get_drvdata(&op->dev); in cs4231_remove() local
2076 snd_card_free(chip->card); in cs4231_remove()