• Home
  • Raw
  • Download

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
893 new_pdfr = snd_cs4231_get_format(chip, params_format(hw_params), in snd_cs4231_playback_hw_params()
896 snd_cs4231_playback_format(chip, hw_params, new_pdfr); in snd_cs4231_playback_hw_params()
903 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); in snd_cs4231_playback_prepare() local
908 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_playback_prepare()
910 chip->image[CS4231_IFACE_CTRL] &= ~(CS4231_PLAYBACK_ENABLE | in snd_cs4231_playback_prepare()
918 chip->p_periods_sent = 0; in snd_cs4231_playback_prepare()
921 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_playback_prepare()
929 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); in snd_cs4231_capture_hw_params() local
932 new_cdfr = snd_cs4231_get_format(chip, params_format(hw_params), in snd_cs4231_capture_hw_params()
935 snd_cs4231_capture_format(chip, hw_params, new_cdfr); in snd_cs4231_capture_hw_params()
942 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); in snd_cs4231_capture_prepare() local
945 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_capture_prepare()
946 chip->image[CS4231_IFACE_CTRL] &= ~(CS4231_RECORD_ENABLE | in snd_cs4231_capture_prepare()
950 chip->c_periods_sent = 0; in snd_cs4231_capture_prepare()
951 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_capture_prepare()
956 static void snd_cs4231_overrange(struct snd_cs4231 *chip) in snd_cs4231_overrange() argument
961 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_overrange()
962 res = snd_cs4231_in(chip, CS4231_TEST_INIT); in snd_cs4231_overrange()
963 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_overrange()
967 chip->capture_substream->runtime->overrange++; in snd_cs4231_overrange()
970 static void snd_cs4231_play_callback(struct snd_cs4231 *chip) in snd_cs4231_play_callback() argument
972 if (chip->image[CS4231_IFACE_CTRL] & CS4231_PLAYBACK_ENABLE) { in snd_cs4231_play_callback()
973 snd_pcm_period_elapsed(chip->playback_substream); in snd_cs4231_play_callback()
974 snd_cs4231_advance_dma(&chip->p_dma, chip->playback_substream, in snd_cs4231_play_callback()
975 &chip->p_periods_sent); in snd_cs4231_play_callback()
979 static void snd_cs4231_capture_callback(struct snd_cs4231 *chip) in snd_cs4231_capture_callback() argument
981 if (chip->image[CS4231_IFACE_CTRL] & CS4231_RECORD_ENABLE) { in snd_cs4231_capture_callback()
982 snd_pcm_period_elapsed(chip->capture_substream); in snd_cs4231_capture_callback()
983 snd_cs4231_advance_dma(&chip->c_dma, chip->capture_substream, in snd_cs4231_capture_callback()
984 &chip->c_periods_sent); in snd_cs4231_capture_callback()
991 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); in snd_cs4231_playback_pointer() local
992 struct cs4231_dma_control *dma_cont = &chip->p_dma; in snd_cs4231_playback_pointer()
995 if (!(chip->image[CS4231_IFACE_CTRL] & CS4231_PLAYBACK_ENABLE)) in snd_cs4231_playback_pointer()
1007 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); in snd_cs4231_capture_pointer() local
1008 struct cs4231_dma_control *dma_cont = &chip->c_dma; in snd_cs4231_capture_pointer()
1011 if (!(chip->image[CS4231_IFACE_CTRL] & CS4231_RECORD_ENABLE)) in snd_cs4231_capture_pointer()
1020 static int snd_cs4231_probe(struct snd_cs4231 *chip) in snd_cs4231_probe() argument
1030 if (__cs4231_readb(chip, CS4231U(chip, REGSEL)) & CS4231_INIT) in snd_cs4231_probe()
1033 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_probe()
1034 snd_cs4231_out(chip, CS4231_MISC_INFO, CS4231_MODE2); in snd_cs4231_probe()
1035 id = snd_cs4231_in(chip, CS4231_MISC_INFO) & 0x0f; in snd_cs4231_probe()
1036 vers = snd_cs4231_in(chip, CS4231_VERSION); in snd_cs4231_probe()
1037 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_probe()
1042 snd_printdd("cs4231: port = %p, id = 0x%x\n", chip->port, id); in snd_cs4231_probe()
1046 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_probe()
1049 __cs4231_readb(chip, CS4231U(chip, STATUS)); in snd_cs4231_probe()
1050 __cs4231_writeb(chip, 0, CS4231U(chip, STATUS)); in snd_cs4231_probe()
1053 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_probe()
1055 chip->image[CS4231_MISC_INFO] = CS4231_MODE2; in snd_cs4231_probe()
1056 chip->image[CS4231_IFACE_CTRL] = in snd_cs4231_probe()
1057 chip->image[CS4231_IFACE_CTRL] & ~CS4231_SINGLE_DMA; in snd_cs4231_probe()
1058 chip->image[CS4231_ALT_FEATURE_1] = 0x80; in snd_cs4231_probe()
1059 chip->image[CS4231_ALT_FEATURE_2] = 0x01; in snd_cs4231_probe()
1061 chip->image[CS4231_ALT_FEATURE_2] |= 0x02; in snd_cs4231_probe()
1063 ptr = (unsigned char *) &chip->image; in snd_cs4231_probe()
1065 snd_cs4231_mce_down(chip); in snd_cs4231_probe()
1067 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_probe()
1070 snd_cs4231_out(chip, i, *ptr++); in snd_cs4231_probe()
1072 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_probe()
1074 snd_cs4231_mce_up(chip); in snd_cs4231_probe()
1076 snd_cs4231_mce_down(chip); in snd_cs4231_probe()
1133 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); in snd_cs4231_playback_open() local
1139 err = snd_cs4231_open(chip, CS4231_MODE_PLAY); in snd_cs4231_playback_open()
1142 chip->playback_substream = substream; in snd_cs4231_playback_open()
1143 chip->p_periods_sent = 0; in snd_cs4231_playback_open()
1152 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); in snd_cs4231_capture_open() local
1158 err = snd_cs4231_open(chip, CS4231_MODE_RECORD); in snd_cs4231_capture_open()
1161 chip->capture_substream = substream; in snd_cs4231_capture_open()
1162 chip->c_periods_sent = 0; in snd_cs4231_capture_open()
1171 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); in snd_cs4231_playback_close() local
1173 snd_cs4231_close(chip, CS4231_MODE_PLAY); in snd_cs4231_playback_close()
1174 chip->playback_substream = NULL; in snd_cs4231_playback_close()
1181 struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); in snd_cs4231_capture_close() local
1183 snd_cs4231_close(chip, CS4231_MODE_RECORD); in snd_cs4231_capture_close()
1184 chip->capture_substream = NULL; in snd_cs4231_capture_close()
1213 struct snd_cs4231 *chip = card->private_data; in snd_cs4231_pcm() local
1227 pcm->private_data = chip; in snd_cs4231_pcm()
1232 &chip->op->dev, 64 * 1024, 128 * 1024); in snd_cs4231_pcm()
1234 chip->pcm = pcm; in snd_cs4231_pcm()
1241 struct snd_cs4231 *chip = card->private_data; in snd_cs4231_timer() local
1256 timer->private_data = chip; in snd_cs4231_timer()
1258 chip->timer = timer; in snd_cs4231_timer()
1280 struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); in snd_cs4231_get_mux() local
1283 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_get_mux()
1285 (chip->image[CS4231_LEFT_INPUT] & CS4231_MIXS_ALL) >> 6; in snd_cs4231_get_mux()
1287 (chip->image[CS4231_RIGHT_INPUT] & CS4231_MIXS_ALL) >> 6; in snd_cs4231_get_mux()
1288 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_get_mux()
1296 struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); in snd_cs4231_put_mux() local
1307 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_put_mux()
1309 left = (chip->image[CS4231_LEFT_INPUT] & ~CS4231_MIXS_ALL) | left; in snd_cs4231_put_mux()
1310 right = (chip->image[CS4231_RIGHT_INPUT] & ~CS4231_MIXS_ALL) | right; in snd_cs4231_put_mux()
1311 change = left != chip->image[CS4231_LEFT_INPUT] || in snd_cs4231_put_mux()
1312 right != chip->image[CS4231_RIGHT_INPUT]; in snd_cs4231_put_mux()
1313 snd_cs4231_out(chip, CS4231_LEFT_INPUT, left); in snd_cs4231_put_mux()
1314 snd_cs4231_out(chip, CS4231_RIGHT_INPUT, right); in snd_cs4231_put_mux()
1316 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_put_mux()
1338 struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); in snd_cs4231_get_single() local
1345 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_get_single()
1347 ucontrol->value.integer.value[0] = (chip->image[reg] >> shift) & mask; in snd_cs4231_get_single()
1349 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_get_single()
1361 struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); in snd_cs4231_put_single() local
1375 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_put_single()
1377 val = (chip->image[reg] & ~(mask << shift)) | val; in snd_cs4231_put_single()
1378 change = val != chip->image[reg]; in snd_cs4231_put_single()
1379 snd_cs4231_out(chip, reg, val); in snd_cs4231_put_single()
1381 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_put_single()
1403 struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); in snd_cs4231_get_double() local
1412 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_get_double()
1415 (chip->image[left_reg] >> shift_left) & mask; in snd_cs4231_get_double()
1417 (chip->image[right_reg] >> shift_right) & mask; in snd_cs4231_get_double()
1419 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_get_double()
1434 struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); in snd_cs4231_put_double() local
1454 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_put_double()
1456 val1 = (chip->image[left_reg] & ~(mask << shift_left)) | val1; in snd_cs4231_put_double()
1457 val2 = (chip->image[right_reg] & ~(mask << shift_right)) | val2; in snd_cs4231_put_double()
1458 change = val1 != chip->image[left_reg]; in snd_cs4231_put_double()
1459 change |= val2 != chip->image[right_reg]; in snd_cs4231_put_double()
1460 snd_cs4231_out(chip, left_reg, val1); in snd_cs4231_put_double()
1461 snd_cs4231_out(chip, right_reg, val2); in snd_cs4231_put_double()
1463 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_put_double()
1523 struct snd_cs4231 *chip = card->private_data; in snd_cs4231_mixer() local
1526 if (snd_BUG_ON(!chip || !chip->pcm)) in snd_cs4231_mixer()
1529 strcpy(card->mixername, chip->pcm->name); in snd_cs4231_mixer()
1533 snd_ctl_new1(&snd_cs4231_controls[idx], chip)); in snd_cs4231_mixer()
1546 struct snd_cs4231 *chip; in cs4231_attach_begin() local
1567 chip = card->private_data; in cs4231_attach_begin()
1568 chip->card = card; in cs4231_attach_begin()
1576 struct snd_cs4231 *chip = card->private_data; in cs4231_attach_finish() local
1595 dev_set_drvdata(&chip->op->dev, chip); in cs4231_attach_finish()
1612 struct snd_cs4231 *chip = dev_id; in snd_cs4231_sbus_interrupt() local
1615 if (!(__cs4231_readb(chip, CS4231U(chip, STATUS)) & CS4231_GLOBALIRQ)) in snd_cs4231_sbus_interrupt()
1619 csr = sbus_readl(chip->port + APCCSR); in snd_cs4231_sbus_interrupt()
1621 sbus_writel(csr, chip->port + APCCSR); in snd_cs4231_sbus_interrupt()
1627 snd_cs4231_play_callback(chip); in snd_cs4231_sbus_interrupt()
1633 snd_cs4231_capture_callback(chip); in snd_cs4231_sbus_interrupt()
1635 status = snd_cs4231_in(chip, CS4231_IRQ_STATUS); in snd_cs4231_sbus_interrupt()
1638 if (chip->timer) in snd_cs4231_sbus_interrupt()
1639 snd_timer_interrupt(chip->timer, chip->timer->sticks); in snd_cs4231_sbus_interrupt()
1643 snd_cs4231_overrange(chip); in snd_cs4231_sbus_interrupt()
1646 spin_lock_irqsave(&chip->lock, flags); in snd_cs4231_sbus_interrupt()
1647 snd_cs4231_outm(chip, CS4231_IRQ_STATUS, ~CS4231_ALL_IRQS | ~status, 0); in snd_cs4231_sbus_interrupt()
1648 spin_unlock_irqrestore(&chip->lock, flags); in snd_cs4231_sbus_interrupt()
1754 static int snd_cs4231_sbus_free(struct snd_cs4231 *chip) in snd_cs4231_sbus_free() argument
1756 struct platform_device *op = chip->op; in snd_cs4231_sbus_free()
1758 if (chip->irq[0]) in snd_cs4231_sbus_free()
1759 free_irq(chip->irq[0], chip); in snd_cs4231_sbus_free()
1761 if (chip->port) in snd_cs4231_sbus_free()
1762 of_iounmap(&op->resource[0], chip->port, chip->regs_size); in snd_cs4231_sbus_free()
1782 struct snd_cs4231 *chip = card->private_data; in snd_cs4231_sbus_create() local
1785 spin_lock_init(&chip->lock); in snd_cs4231_sbus_create()
1786 spin_lock_init(&chip->c_dma.sbus_info.lock); in snd_cs4231_sbus_create()
1787 spin_lock_init(&chip->p_dma.sbus_info.lock); in snd_cs4231_sbus_create()
1788 mutex_init(&chip->mce_mutex); in snd_cs4231_sbus_create()
1789 mutex_init(&chip->open_mutex); in snd_cs4231_sbus_create()
1790 chip->op = op; in snd_cs4231_sbus_create()
1791 chip->regs_size = resource_size(&op->resource[0]); in snd_cs4231_sbus_create()
1792 memcpy(&chip->image, &snd_cs4231_original_image, in snd_cs4231_sbus_create()
1795 chip->port = of_ioremap(&op->resource[0], 0, in snd_cs4231_sbus_create()
1796 chip->regs_size, "cs4231"); in snd_cs4231_sbus_create()
1797 if (!chip->port) { in snd_cs4231_sbus_create()
1798 snd_printdd("cs4231-%d: Unable to map chip registers.\n", dev); in snd_cs4231_sbus_create()
1802 chip->c_dma.sbus_info.regs = chip->port; in snd_cs4231_sbus_create()
1803 chip->p_dma.sbus_info.regs = chip->port; in snd_cs4231_sbus_create()
1804 chip->c_dma.sbus_info.dir = APC_RECORD; in snd_cs4231_sbus_create()
1805 chip->p_dma.sbus_info.dir = APC_PLAY; in snd_cs4231_sbus_create()
1807 chip->p_dma.prepare = sbus_dma_prepare; in snd_cs4231_sbus_create()
1808 chip->p_dma.enable = sbus_dma_enable; in snd_cs4231_sbus_create()
1809 chip->p_dma.request = sbus_dma_request; in snd_cs4231_sbus_create()
1810 chip->p_dma.address = sbus_dma_addr; in snd_cs4231_sbus_create()
1812 chip->c_dma.prepare = sbus_dma_prepare; in snd_cs4231_sbus_create()
1813 chip->c_dma.enable = sbus_dma_enable; in snd_cs4231_sbus_create()
1814 chip->c_dma.request = sbus_dma_request; in snd_cs4231_sbus_create()
1815 chip->c_dma.address = sbus_dma_addr; in snd_cs4231_sbus_create()
1818 IRQF_SHARED, "cs4231", chip)) { in snd_cs4231_sbus_create()
1821 snd_cs4231_sbus_free(chip); in snd_cs4231_sbus_create()
1824 chip->irq[0] = op->archdata.irqs[0]; in snd_cs4231_sbus_create()
1826 if (snd_cs4231_probe(chip) < 0) { in snd_cs4231_sbus_create()
1827 snd_cs4231_sbus_free(chip); in snd_cs4231_sbus_create()
1830 snd_cs4231_init(chip); in snd_cs4231_sbus_create()
1833 chip, &snd_cs4231_sbus_dev_ops)) < 0) { 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()
1989 snd_printdd("cs4231-%d: Unable to map chip registers.\n", dev); 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)) < 0) { in snd_cs4231_ebus_create()
2026 snd_cs4231_ebus_free(chip); in snd_cs4231_ebus_create()
2073 struct snd_cs4231 *chip = dev_get_drvdata(&op->dev); in cs4231_remove() local
2075 snd_card_free(chip->card); in cs4231_remove()