Lines Matching refs:chip

151 static inline void wss_outb(struct snd_wss *chip, u8 offset, u8 val)  in wss_outb()  argument
153 outb(val, chip->port + offset); in wss_outb()
156 static inline u8 wss_inb(struct snd_wss *chip, u8 offset) in wss_inb() argument
158 return inb(chip->port + offset); in wss_inb()
161 static void snd_wss_wait(struct snd_wss *chip) in snd_wss_wait() argument
166 timeout > 0 && (wss_inb(chip, CS4231P(REGSEL)) & CS4231_INIT); in snd_wss_wait()
171 static void snd_wss_dout(struct snd_wss *chip, unsigned char reg, in snd_wss_dout() argument
177 timeout > 0 && (wss_inb(chip, CS4231P(REGSEL)) & CS4231_INIT); in snd_wss_dout()
180 wss_outb(chip, CS4231P(REGSEL), chip->mce_bit | reg); in snd_wss_dout()
181 wss_outb(chip, CS4231P(REG), value); in snd_wss_dout()
185 void snd_wss_out(struct snd_wss *chip, unsigned char reg, unsigned char value) in snd_wss_out() argument
187 snd_wss_wait(chip); in snd_wss_out()
189 if (wss_inb(chip, CS4231P(REGSEL)) & CS4231_INIT) in snd_wss_out()
193 wss_outb(chip, CS4231P(REGSEL), chip->mce_bit | reg); in snd_wss_out()
194 wss_outb(chip, CS4231P(REG), value); in snd_wss_out()
195 chip->image[reg] = value; in snd_wss_out()
198 chip->mce_bit | reg, value); in snd_wss_out()
202 unsigned char snd_wss_in(struct snd_wss *chip, unsigned char reg) in snd_wss_in() argument
204 snd_wss_wait(chip); in snd_wss_in()
206 if (wss_inb(chip, CS4231P(REGSEL)) & CS4231_INIT) in snd_wss_in()
210 wss_outb(chip, CS4231P(REGSEL), chip->mce_bit | reg); in snd_wss_in()
212 return wss_inb(chip, CS4231P(REG)); in snd_wss_in()
216 void snd_cs4236_ext_out(struct snd_wss *chip, unsigned char reg, in snd_cs4236_ext_out() argument
219 wss_outb(chip, CS4231P(REGSEL), chip->mce_bit | 0x17); in snd_cs4236_ext_out()
220 wss_outb(chip, CS4231P(REG), in snd_cs4236_ext_out()
221 reg | (chip->image[CS4236_EXT_REG] & 0x01)); in snd_cs4236_ext_out()
222 wss_outb(chip, CS4231P(REG), val); in snd_cs4236_ext_out()
223 chip->eimage[CS4236_REG(reg)] = val; in snd_cs4236_ext_out()
230 unsigned char snd_cs4236_ext_in(struct snd_wss *chip, unsigned char reg) in snd_cs4236_ext_in() argument
232 wss_outb(chip, CS4231P(REGSEL), chip->mce_bit | 0x17); in snd_cs4236_ext_in()
233 wss_outb(chip, CS4231P(REG), in snd_cs4236_ext_in()
234 reg | (chip->image[CS4236_EXT_REG] & 0x01)); in snd_cs4236_ext_in()
236 return wss_inb(chip, CS4231P(REG)); in snd_cs4236_ext_in()
240 res = wss_inb(chip, CS4231P(REG)); in snd_cs4236_ext_in()
251 static void snd_wss_debug(struct snd_wss *chip)
256 wss_inb(chip, CS4231P(REGSEL)),
257 wss_inb(chip, CS4231P(STATUS)));
261 snd_wss_in(chip, 0x00),
262 snd_wss_in(chip, 0x10));
266 snd_wss_in(chip, 0x01),
267 snd_wss_in(chip, 0x11));
271 snd_wss_in(chip, 0x02),
272 snd_wss_in(chip, 0x12));
276 snd_wss_in(chip, 0x03),
277 snd_wss_in(chip, 0x13));
281 snd_wss_in(chip, 0x04),
282 snd_wss_in(chip, 0x14));
286 snd_wss_in(chip, 0x05),
287 snd_wss_in(chip, 0x15));
291 snd_wss_in(chip, 0x06),
292 snd_wss_in(chip, 0x16));
296 snd_wss_in(chip, 0x07),
297 snd_wss_in(chip, 0x17));
301 snd_wss_in(chip, 0x08),
302 snd_wss_in(chip, 0x18));
306 snd_wss_in(chip, 0x09),
307 snd_wss_in(chip, 0x19));
311 snd_wss_in(chip, 0x0a),
312 snd_wss_in(chip, 0x1a));
316 snd_wss_in(chip, 0x0b),
317 snd_wss_in(chip, 0x1b));
321 snd_wss_in(chip, 0x0c),
322 snd_wss_in(chip, 0x1c));
326 snd_wss_in(chip, 0x0d),
327 snd_wss_in(chip, 0x1d));
331 snd_wss_in(chip, 0x0e),
332 snd_wss_in(chip, 0x1e));
336 snd_wss_in(chip, 0x0f),
337 snd_wss_in(chip, 0x1f));
346 static void snd_wss_busy_wait(struct snd_wss *chip) in snd_wss_busy_wait() argument
352 wss_inb(chip, CS4231P(REGSEL)); in snd_wss_busy_wait()
355 timeout > 0 && (wss_inb(chip, CS4231P(REGSEL)) & CS4231_INIT); in snd_wss_busy_wait()
360 void snd_wss_mce_up(struct snd_wss *chip) in snd_wss_mce_up() argument
365 snd_wss_wait(chip); in snd_wss_mce_up()
367 if (wss_inb(chip, CS4231P(REGSEL)) & CS4231_INIT) in snd_wss_mce_up()
371 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_mce_up()
372 chip->mce_bit |= CS4231_MCE; in snd_wss_mce_up()
373 timeout = wss_inb(chip, CS4231P(REGSEL)); in snd_wss_mce_up()
377 chip->port); in snd_wss_mce_up()
379 wss_outb(chip, CS4231P(REGSEL), in snd_wss_mce_up()
380 chip->mce_bit | (timeout & 0x1f)); in snd_wss_mce_up()
381 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_mce_up()
385 void snd_wss_mce_down(struct snd_wss *chip) in snd_wss_mce_down() argument
392 snd_wss_busy_wait(chip); in snd_wss_mce_down()
395 if (wss_inb(chip, CS4231P(REGSEL)) & CS4231_INIT) in snd_wss_mce_down()
400 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_mce_down()
401 chip->mce_bit &= ~CS4231_MCE; in snd_wss_mce_down()
402 timeout = wss_inb(chip, CS4231P(REGSEL)); in snd_wss_mce_down()
403 wss_outb(chip, CS4231P(REGSEL), chip->mce_bit | (timeout & 0x1f)); in snd_wss_mce_down()
404 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_mce_down()
408 chip->port); in snd_wss_mce_down()
409 if ((timeout & CS4231_MCE) == 0 || !(chip->hardware & hw_mask)) in snd_wss_mce_down()
423 while (snd_wss_in(chip, CS4231_TEST_INIT) & in snd_wss_mce_down()
438 while (wss_inb(chip, CS4231P(REGSEL)) & CS4231_INIT) { in snd_wss_mce_down()
447 snd_printd("mce_down - exit = 0x%x\n", wss_inb(chip, CS4231P(REGSEL))); in snd_wss_mce_down()
469 struct snd_wss *chip = snd_pcm_substream_chip(substream); in snd_wss_trigger() local
488 if (s == chip->playback_substream) { in snd_wss_trigger()
491 } else if (s == chip->capture_substream) { in snd_wss_trigger()
496 spin_lock(&chip->reg_lock); in snd_wss_trigger()
498 chip->image[CS4231_IFACE_CTRL] |= what; in snd_wss_trigger()
499 if (chip->trigger) in snd_wss_trigger()
500 chip->trigger(chip, what, 1); in snd_wss_trigger()
502 chip->image[CS4231_IFACE_CTRL] &= ~what; in snd_wss_trigger()
503 if (chip->trigger) in snd_wss_trigger()
504 chip->trigger(chip, what, 0); in snd_wss_trigger()
506 snd_wss_out(chip, CS4231_IFACE_CTRL, chip->image[CS4231_IFACE_CTRL]); in snd_wss_trigger()
507 spin_unlock(&chip->reg_lock); in snd_wss_trigger()
509 snd_wss_debug(chip); in snd_wss_trigger()
529 static unsigned char snd_wss_get_format(struct snd_wss *chip, in snd_wss_get_format() argument
551 static void snd_wss_calibrate_mute(struct snd_wss *chip, int mute) in snd_wss_calibrate_mute() argument
556 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_calibrate_mute()
557 if (chip->calibrate_mute == mute) { in snd_wss_calibrate_mute()
558 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_calibrate_mute()
562 snd_wss_dout(chip, CS4231_LEFT_INPUT, in snd_wss_calibrate_mute()
563 chip->image[CS4231_LEFT_INPUT]); in snd_wss_calibrate_mute()
564 snd_wss_dout(chip, CS4231_RIGHT_INPUT, in snd_wss_calibrate_mute()
565 chip->image[CS4231_RIGHT_INPUT]); in snd_wss_calibrate_mute()
566 snd_wss_dout(chip, CS4231_LOOPBACK, in snd_wss_calibrate_mute()
567 chip->image[CS4231_LOOPBACK]); in snd_wss_calibrate_mute()
569 snd_wss_dout(chip, CS4231_LEFT_INPUT, in snd_wss_calibrate_mute()
571 snd_wss_dout(chip, CS4231_RIGHT_INPUT, in snd_wss_calibrate_mute()
573 snd_wss_dout(chip, CS4231_LOOPBACK, in snd_wss_calibrate_mute()
577 snd_wss_dout(chip, CS4231_AUX1_LEFT_INPUT, in snd_wss_calibrate_mute()
578 mute | chip->image[CS4231_AUX1_LEFT_INPUT]); in snd_wss_calibrate_mute()
579 snd_wss_dout(chip, CS4231_AUX1_RIGHT_INPUT, in snd_wss_calibrate_mute()
580 mute | chip->image[CS4231_AUX1_RIGHT_INPUT]); in snd_wss_calibrate_mute()
581 snd_wss_dout(chip, CS4231_AUX2_LEFT_INPUT, in snd_wss_calibrate_mute()
582 mute | chip->image[CS4231_AUX2_LEFT_INPUT]); in snd_wss_calibrate_mute()
583 snd_wss_dout(chip, CS4231_AUX2_RIGHT_INPUT, in snd_wss_calibrate_mute()
584 mute | chip->image[CS4231_AUX2_RIGHT_INPUT]); in snd_wss_calibrate_mute()
585 snd_wss_dout(chip, CS4231_LEFT_OUTPUT, in snd_wss_calibrate_mute()
586 mute | chip->image[CS4231_LEFT_OUTPUT]); in snd_wss_calibrate_mute()
587 snd_wss_dout(chip, CS4231_RIGHT_OUTPUT, in snd_wss_calibrate_mute()
588 mute | chip->image[CS4231_RIGHT_OUTPUT]); in snd_wss_calibrate_mute()
589 if (!(chip->hardware & WSS_HW_AD1848_MASK)) { in snd_wss_calibrate_mute()
590 snd_wss_dout(chip, CS4231_LEFT_LINE_IN, in snd_wss_calibrate_mute()
591 mute | chip->image[CS4231_LEFT_LINE_IN]); in snd_wss_calibrate_mute()
592 snd_wss_dout(chip, CS4231_RIGHT_LINE_IN, in snd_wss_calibrate_mute()
593 mute | chip->image[CS4231_RIGHT_LINE_IN]); in snd_wss_calibrate_mute()
594 snd_wss_dout(chip, CS4231_MONO_CTRL, in snd_wss_calibrate_mute()
595 mute ? 0xc0 : chip->image[CS4231_MONO_CTRL]); in snd_wss_calibrate_mute()
597 if (chip->hardware == WSS_HW_INTERWAVE) { in snd_wss_calibrate_mute()
598 snd_wss_dout(chip, CS4231_LEFT_MIC_INPUT, in snd_wss_calibrate_mute()
599 mute | chip->image[CS4231_LEFT_MIC_INPUT]); in snd_wss_calibrate_mute()
600 snd_wss_dout(chip, CS4231_RIGHT_MIC_INPUT, in snd_wss_calibrate_mute()
601 mute | chip->image[CS4231_RIGHT_MIC_INPUT]); in snd_wss_calibrate_mute()
602 snd_wss_dout(chip, CS4231_LINE_LEFT_OUTPUT, in snd_wss_calibrate_mute()
603 mute | chip->image[CS4231_LINE_LEFT_OUTPUT]); in snd_wss_calibrate_mute()
604 snd_wss_dout(chip, CS4231_LINE_RIGHT_OUTPUT, in snd_wss_calibrate_mute()
605 mute | chip->image[CS4231_LINE_RIGHT_OUTPUT]); in snd_wss_calibrate_mute()
607 chip->calibrate_mute = mute; in snd_wss_calibrate_mute()
608 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_calibrate_mute()
611 static void snd_wss_playback_format(struct snd_wss *chip, in snd_wss_playback_format() argument
618 mutex_lock(&chip->mce_mutex); in snd_wss_playback_format()
619 if (chip->hardware == WSS_HW_CS4231A || in snd_wss_playback_format()
620 (chip->hardware & WSS_HW_CS4232_MASK)) { in snd_wss_playback_format()
621 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_playback_format()
622 if ((chip->image[CS4231_PLAYBK_FORMAT] & 0x0f) == (pdfr & 0x0f)) { /* rate is same? */ in snd_wss_playback_format()
623 snd_wss_out(chip, CS4231_ALT_FEATURE_1, in snd_wss_playback_format()
624 chip->image[CS4231_ALT_FEATURE_1] | 0x10); in snd_wss_playback_format()
625 chip->image[CS4231_PLAYBK_FORMAT] = pdfr; in snd_wss_playback_format()
626 snd_wss_out(chip, CS4231_PLAYBK_FORMAT, in snd_wss_playback_format()
627 chip->image[CS4231_PLAYBK_FORMAT]); in snd_wss_playback_format()
628 snd_wss_out(chip, CS4231_ALT_FEATURE_1, in snd_wss_playback_format()
629 chip->image[CS4231_ALT_FEATURE_1] &= ~0x10); in snd_wss_playback_format()
633 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_playback_format()
634 } else if (chip->hardware == WSS_HW_AD1845) { in snd_wss_playback_format()
646 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_playback_format()
647 snd_wss_out(chip, CS4231_PLAYBK_FORMAT, (pdfr & 0xf0)); in snd_wss_playback_format()
648 snd_wss_out(chip, AD1845_UPR_FREQ_SEL, (rate >> 8) & 0xff); in snd_wss_playback_format()
649 snd_wss_out(chip, AD1845_LWR_FREQ_SEL, rate & 0xff); in snd_wss_playback_format()
651 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_playback_format()
654 snd_wss_mce_up(chip); in snd_wss_playback_format()
655 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_playback_format()
656 if (chip->hardware != WSS_HW_INTERWAVE && !chip->single_dma) { in snd_wss_playback_format()
657 if (chip->image[CS4231_IFACE_CTRL] & CS4231_RECORD_ENABLE) in snd_wss_playback_format()
659 (chip->image[CS4231_REC_FORMAT] & 0x0f); in snd_wss_playback_format()
661 chip->image[CS4231_PLAYBK_FORMAT] = pdfr; in snd_wss_playback_format()
663 snd_wss_out(chip, CS4231_PLAYBK_FORMAT, pdfr); in snd_wss_playback_format()
664 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_playback_format()
665 if (chip->hardware == WSS_HW_OPL3SA2) in snd_wss_playback_format()
667 snd_wss_mce_down(chip); in snd_wss_playback_format()
669 mutex_unlock(&chip->mce_mutex); in snd_wss_playback_format()
672 static void snd_wss_capture_format(struct snd_wss *chip, in snd_wss_capture_format() argument
679 mutex_lock(&chip->mce_mutex); in snd_wss_capture_format()
680 if (chip->hardware == WSS_HW_CS4231A || in snd_wss_capture_format()
681 (chip->hardware & WSS_HW_CS4232_MASK)) { in snd_wss_capture_format()
682 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_capture_format()
683 if ((chip->image[CS4231_PLAYBK_FORMAT] & 0x0f) == (cdfr & 0x0f) || /* rate is same? */ in snd_wss_capture_format()
684 (chip->image[CS4231_IFACE_CTRL] & CS4231_PLAYBACK_ENABLE)) { in snd_wss_capture_format()
685 snd_wss_out(chip, CS4231_ALT_FEATURE_1, in snd_wss_capture_format()
686 chip->image[CS4231_ALT_FEATURE_1] | 0x20); in snd_wss_capture_format()
687 snd_wss_out(chip, CS4231_REC_FORMAT, in snd_wss_capture_format()
688 chip->image[CS4231_REC_FORMAT] = cdfr); in snd_wss_capture_format()
689 snd_wss_out(chip, CS4231_ALT_FEATURE_1, in snd_wss_capture_format()
690 chip->image[CS4231_ALT_FEATURE_1] &= ~0x20); in snd_wss_capture_format()
693 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_capture_format()
694 } else if (chip->hardware == WSS_HW_AD1845) { in snd_wss_capture_format()
706 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_capture_format()
707 snd_wss_out(chip, CS4231_REC_FORMAT, (cdfr & 0xf0)); in snd_wss_capture_format()
708 snd_wss_out(chip, AD1845_UPR_FREQ_SEL, (rate >> 8) & 0xff); in snd_wss_capture_format()
709 snd_wss_out(chip, AD1845_LWR_FREQ_SEL, rate & 0xff); in snd_wss_capture_format()
711 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_capture_format()
714 snd_wss_mce_up(chip); in snd_wss_capture_format()
715 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_capture_format()
716 if (chip->hardware != WSS_HW_INTERWAVE && in snd_wss_capture_format()
717 !(chip->image[CS4231_IFACE_CTRL] & CS4231_PLAYBACK_ENABLE)) { in snd_wss_capture_format()
718 if (chip->single_dma) in snd_wss_capture_format()
719 snd_wss_out(chip, CS4231_PLAYBK_FORMAT, cdfr); in snd_wss_capture_format()
721 snd_wss_out(chip, CS4231_PLAYBK_FORMAT, in snd_wss_capture_format()
722 (chip->image[CS4231_PLAYBK_FORMAT] & 0xf0) | in snd_wss_capture_format()
724 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_capture_format()
725 snd_wss_mce_down(chip); in snd_wss_capture_format()
726 snd_wss_mce_up(chip); in snd_wss_capture_format()
727 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_capture_format()
729 if (chip->hardware & WSS_HW_AD1848_MASK) in snd_wss_capture_format()
730 snd_wss_out(chip, CS4231_PLAYBK_FORMAT, cdfr); in snd_wss_capture_format()
732 snd_wss_out(chip, CS4231_REC_FORMAT, cdfr); in snd_wss_capture_format()
733 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_capture_format()
734 snd_wss_mce_down(chip); in snd_wss_capture_format()
736 mutex_unlock(&chip->mce_mutex); in snd_wss_capture_format()
745 struct snd_wss *chip = snd_timer_chip(timer); in snd_wss_timer_resolution() local
746 if (chip->hardware & WSS_HW_CS4236B_MASK) in snd_wss_timer_resolution()
749 return chip->image[CS4231_PLAYBK_FORMAT] & 1 ? 9969 : 9920; in snd_wss_timer_resolution()
756 struct snd_wss *chip = snd_timer_chip(timer); in snd_wss_timer_start() local
757 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_timer_start()
759 if ((chip->image[CS4231_ALT_FEATURE_1] & CS4231_TIMER_ENABLE) == 0 || in snd_wss_timer_start()
760 (unsigned char)(ticks >> 8) != chip->image[CS4231_TIMER_HIGH] || in snd_wss_timer_start()
761 (unsigned char)ticks != chip->image[CS4231_TIMER_LOW]) { in snd_wss_timer_start()
762 chip->image[CS4231_TIMER_HIGH] = (unsigned char) (ticks >> 8); in snd_wss_timer_start()
763 snd_wss_out(chip, CS4231_TIMER_HIGH, in snd_wss_timer_start()
764 chip->image[CS4231_TIMER_HIGH]); in snd_wss_timer_start()
765 chip->image[CS4231_TIMER_LOW] = (unsigned char) ticks; in snd_wss_timer_start()
766 snd_wss_out(chip, CS4231_TIMER_LOW, in snd_wss_timer_start()
767 chip->image[CS4231_TIMER_LOW]); in snd_wss_timer_start()
768 snd_wss_out(chip, CS4231_ALT_FEATURE_1, in snd_wss_timer_start()
769 chip->image[CS4231_ALT_FEATURE_1] | in snd_wss_timer_start()
772 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_timer_start()
779 struct snd_wss *chip = snd_timer_chip(timer); in snd_wss_timer_stop() local
780 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_timer_stop()
781 chip->image[CS4231_ALT_FEATURE_1] &= ~CS4231_TIMER_ENABLE; in snd_wss_timer_stop()
782 snd_wss_out(chip, CS4231_ALT_FEATURE_1, in snd_wss_timer_stop()
783 chip->image[CS4231_ALT_FEATURE_1]); in snd_wss_timer_stop()
784 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_timer_stop()
788 static void snd_wss_init(struct snd_wss *chip) in snd_wss_init() argument
792 snd_wss_calibrate_mute(chip, 1); in snd_wss_init()
793 snd_wss_mce_down(chip); in snd_wss_init()
798 snd_wss_mce_up(chip); in snd_wss_init()
799 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_init()
800 chip->image[CS4231_IFACE_CTRL] &= ~(CS4231_PLAYBACK_ENABLE | in snd_wss_init()
805 chip->image[CS4231_IFACE_CTRL] |= CS4231_AUTOCALIB; in snd_wss_init()
806 snd_wss_out(chip, CS4231_IFACE_CTRL, chip->image[CS4231_IFACE_CTRL]); in snd_wss_init()
807 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_init()
808 snd_wss_mce_down(chip); in snd_wss_init()
814 snd_wss_mce_up(chip); in snd_wss_init()
815 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_init()
816 chip->image[CS4231_IFACE_CTRL] &= ~CS4231_AUTOCALIB; in snd_wss_init()
817 snd_wss_out(chip, CS4231_IFACE_CTRL, chip->image[CS4231_IFACE_CTRL]); in snd_wss_init()
818 snd_wss_out(chip, in snd_wss_init()
819 CS4231_ALT_FEATURE_1, chip->image[CS4231_ALT_FEATURE_1]); in snd_wss_init()
820 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_init()
821 snd_wss_mce_down(chip); in snd_wss_init()
825 chip->image[CS4231_ALT_FEATURE_1]); in snd_wss_init()
828 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_init()
829 snd_wss_out(chip, CS4231_ALT_FEATURE_2, in snd_wss_init()
830 chip->image[CS4231_ALT_FEATURE_2]); in snd_wss_init()
831 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_init()
833 snd_wss_mce_up(chip); in snd_wss_init()
834 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_init()
835 snd_wss_out(chip, CS4231_PLAYBK_FORMAT, in snd_wss_init()
836 chip->image[CS4231_PLAYBK_FORMAT]); in snd_wss_init()
837 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_init()
838 snd_wss_mce_down(chip); in snd_wss_init()
844 snd_wss_mce_up(chip); in snd_wss_init()
845 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_init()
846 if (!(chip->hardware & WSS_HW_AD1848_MASK)) in snd_wss_init()
847 snd_wss_out(chip, CS4231_REC_FORMAT, in snd_wss_init()
848 chip->image[CS4231_REC_FORMAT]); in snd_wss_init()
849 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_init()
850 snd_wss_mce_down(chip); in snd_wss_init()
851 snd_wss_calibrate_mute(chip, 0); in snd_wss_init()
858 static int snd_wss_open(struct snd_wss *chip, unsigned int mode) in snd_wss_open() argument
862 mutex_lock(&chip->open_mutex); in snd_wss_open()
863 if ((chip->mode & mode) || in snd_wss_open()
864 ((chip->mode & WSS_MODE_OPEN) && chip->single_dma)) { in snd_wss_open()
865 mutex_unlock(&chip->open_mutex); in snd_wss_open()
868 if (chip->mode & WSS_MODE_OPEN) { in snd_wss_open()
869 chip->mode |= mode; in snd_wss_open()
870 mutex_unlock(&chip->open_mutex); in snd_wss_open()
874 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_open()
875 if (!(chip->hardware & WSS_HW_AD1848_MASK)) { in snd_wss_open()
876 snd_wss_out(chip, CS4231_IRQ_STATUS, in snd_wss_open()
880 snd_wss_out(chip, CS4231_IRQ_STATUS, 0); in snd_wss_open()
882 wss_outb(chip, CS4231P(STATUS), 0); /* clear IRQ */ in snd_wss_open()
883 wss_outb(chip, CS4231P(STATUS), 0); /* clear IRQ */ in snd_wss_open()
884 chip->image[CS4231_PIN_CTRL] |= CS4231_IRQ_ENABLE; in snd_wss_open()
885 snd_wss_out(chip, CS4231_PIN_CTRL, chip->image[CS4231_PIN_CTRL]); in snd_wss_open()
886 if (!(chip->hardware & WSS_HW_AD1848_MASK)) { in snd_wss_open()
887 snd_wss_out(chip, CS4231_IRQ_STATUS, in snd_wss_open()
891 snd_wss_out(chip, CS4231_IRQ_STATUS, 0); in snd_wss_open()
893 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_open()
895 chip->mode = mode; in snd_wss_open()
896 mutex_unlock(&chip->open_mutex); in snd_wss_open()
900 static void snd_wss_close(struct snd_wss *chip, unsigned int mode) in snd_wss_close() argument
904 mutex_lock(&chip->open_mutex); in snd_wss_close()
905 chip->mode &= ~mode; in snd_wss_close()
906 if (chip->mode & WSS_MODE_OPEN) { in snd_wss_close()
907 mutex_unlock(&chip->open_mutex); in snd_wss_close()
911 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_close()
912 if (!(chip->hardware & WSS_HW_AD1848_MASK)) in snd_wss_close()
913 snd_wss_out(chip, CS4231_IRQ_STATUS, 0); in snd_wss_close()
914 wss_outb(chip, CS4231P(STATUS), 0); /* clear IRQ */ in snd_wss_close()
915 wss_outb(chip, CS4231P(STATUS), 0); /* clear IRQ */ in snd_wss_close()
916 chip->image[CS4231_PIN_CTRL] &= ~CS4231_IRQ_ENABLE; in snd_wss_close()
917 snd_wss_out(chip, CS4231_PIN_CTRL, chip->image[CS4231_PIN_CTRL]); in snd_wss_close()
921 if (chip->image[CS4231_IFACE_CTRL] & (CS4231_PLAYBACK_ENABLE | CS4231_PLAYBACK_PIO | in snd_wss_close()
923 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_close()
924 snd_wss_mce_up(chip); in snd_wss_close()
925 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_close()
926 chip->image[CS4231_IFACE_CTRL] &= ~(CS4231_PLAYBACK_ENABLE | CS4231_PLAYBACK_PIO | in snd_wss_close()
928 snd_wss_out(chip, CS4231_IFACE_CTRL, in snd_wss_close()
929 chip->image[CS4231_IFACE_CTRL]); in snd_wss_close()
930 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_close()
931 snd_wss_mce_down(chip); in snd_wss_close()
932 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_close()
936 if (!(chip->hardware & WSS_HW_AD1848_MASK)) in snd_wss_close()
937 snd_wss_out(chip, CS4231_IRQ_STATUS, 0); in snd_wss_close()
938 wss_outb(chip, CS4231P(STATUS), 0); /* clear IRQ */ in snd_wss_close()
939 wss_outb(chip, CS4231P(STATUS), 0); /* clear IRQ */ in snd_wss_close()
940 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_close()
942 chip->mode = 0; in snd_wss_close()
943 mutex_unlock(&chip->open_mutex); in snd_wss_close()
952 struct snd_wss *chip = snd_timer_chip(timer); in snd_wss_timer_open() local
953 snd_wss_open(chip, WSS_MODE_TIMER); in snd_wss_timer_open()
959 struct snd_wss *chip = snd_timer_chip(timer); in snd_wss_timer_close() local
960 snd_wss_close(chip, WSS_MODE_TIMER); in snd_wss_timer_close()
983 struct snd_wss *chip = snd_pcm_substream_chip(substream); in snd_wss_playback_hw_params() local
986 new_pdfr = snd_wss_get_format(chip, params_format(hw_params), in snd_wss_playback_hw_params()
989 chip->set_playback_format(chip, hw_params, new_pdfr); in snd_wss_playback_hw_params()
995 struct snd_wss *chip = snd_pcm_substream_chip(substream); in snd_wss_playback_prepare() local
1001 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_playback_prepare()
1002 chip->p_dma_size = size; in snd_wss_playback_prepare()
1003 chip->image[CS4231_IFACE_CTRL] &= ~(CS4231_PLAYBACK_ENABLE | CS4231_PLAYBACK_PIO); in snd_wss_playback_prepare()
1004 snd_dma_program(chip->dma1, runtime->dma_addr, size, DMA_MODE_WRITE | DMA_AUTOINIT); in snd_wss_playback_prepare()
1005 count = snd_wss_get_count(chip->image[CS4231_PLAYBK_FORMAT], count) - 1; in snd_wss_playback_prepare()
1006 snd_wss_out(chip, CS4231_PLY_LWR_CNT, (unsigned char) count); in snd_wss_playback_prepare()
1007 snd_wss_out(chip, CS4231_PLY_UPR_CNT, (unsigned char) (count >> 8)); in snd_wss_playback_prepare()
1008 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_playback_prepare()
1010 snd_wss_debug(chip); in snd_wss_playback_prepare()
1018 struct snd_wss *chip = snd_pcm_substream_chip(substream); in snd_wss_capture_hw_params() local
1021 new_cdfr = snd_wss_get_format(chip, params_format(hw_params), in snd_wss_capture_hw_params()
1024 chip->set_capture_format(chip, hw_params, new_cdfr); in snd_wss_capture_hw_params()
1030 struct snd_wss *chip = snd_pcm_substream_chip(substream); in snd_wss_capture_prepare() local
1036 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_capture_prepare()
1037 chip->c_dma_size = size; in snd_wss_capture_prepare()
1038 chip->image[CS4231_IFACE_CTRL] &= ~(CS4231_RECORD_ENABLE | CS4231_RECORD_PIO); in snd_wss_capture_prepare()
1039 snd_dma_program(chip->dma2, runtime->dma_addr, size, DMA_MODE_READ | DMA_AUTOINIT); in snd_wss_capture_prepare()
1040 if (chip->hardware & WSS_HW_AD1848_MASK) in snd_wss_capture_prepare()
1041 count = snd_wss_get_count(chip->image[CS4231_PLAYBK_FORMAT], in snd_wss_capture_prepare()
1044 count = snd_wss_get_count(chip->image[CS4231_REC_FORMAT], in snd_wss_capture_prepare()
1047 if (chip->single_dma && chip->hardware != WSS_HW_INTERWAVE) { in snd_wss_capture_prepare()
1048 snd_wss_out(chip, CS4231_PLY_LWR_CNT, (unsigned char) count); in snd_wss_capture_prepare()
1049 snd_wss_out(chip, CS4231_PLY_UPR_CNT, in snd_wss_capture_prepare()
1052 snd_wss_out(chip, CS4231_REC_LWR_CNT, (unsigned char) count); in snd_wss_capture_prepare()
1053 snd_wss_out(chip, CS4231_REC_UPR_CNT, in snd_wss_capture_prepare()
1056 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_capture_prepare()
1060 void snd_wss_overrange(struct snd_wss *chip) in snd_wss_overrange() argument
1065 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_overrange()
1066 res = snd_wss_in(chip, CS4231_TEST_INIT); in snd_wss_overrange()
1067 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_overrange()
1069 chip->capture_substream->runtime->overrange++; in snd_wss_overrange()
1075 struct snd_wss *chip = dev_id; in snd_wss_interrupt() local
1078 if (chip->hardware & WSS_HW_AD1848_MASK) in snd_wss_interrupt()
1082 status = snd_wss_in(chip, CS4231_IRQ_STATUS); in snd_wss_interrupt()
1084 if (chip->timer) in snd_wss_interrupt()
1085 snd_timer_interrupt(chip->timer, chip->timer->sticks); in snd_wss_interrupt()
1087 if (chip->single_dma && chip->hardware != WSS_HW_INTERWAVE) { in snd_wss_interrupt()
1089 if (chip->mode & WSS_MODE_PLAY) { in snd_wss_interrupt()
1090 if (chip->playback_substream) in snd_wss_interrupt()
1091 snd_pcm_period_elapsed(chip->playback_substream); in snd_wss_interrupt()
1093 if (chip->mode & WSS_MODE_RECORD) { in snd_wss_interrupt()
1094 if (chip->capture_substream) { in snd_wss_interrupt()
1095 snd_wss_overrange(chip); in snd_wss_interrupt()
1096 snd_pcm_period_elapsed(chip->capture_substream); in snd_wss_interrupt()
1102 if (chip->playback_substream) in snd_wss_interrupt()
1103 snd_pcm_period_elapsed(chip->playback_substream); in snd_wss_interrupt()
1106 if (chip->capture_substream) { in snd_wss_interrupt()
1107 snd_wss_overrange(chip); in snd_wss_interrupt()
1108 snd_pcm_period_elapsed(chip->capture_substream); in snd_wss_interrupt()
1113 spin_lock(&chip->reg_lock); in snd_wss_interrupt()
1115 if (chip->hardware & WSS_HW_AD1848_MASK) in snd_wss_interrupt()
1116 wss_outb(chip, CS4231P(STATUS), 0); in snd_wss_interrupt()
1118 snd_wss_out(chip, CS4231_IRQ_STATUS, status); in snd_wss_interrupt()
1119 spin_unlock(&chip->reg_lock); in snd_wss_interrupt()
1126 struct snd_wss *chip = snd_pcm_substream_chip(substream); in snd_wss_playback_pointer() local
1129 if (!(chip->image[CS4231_IFACE_CTRL] & CS4231_PLAYBACK_ENABLE)) in snd_wss_playback_pointer()
1131 ptr = snd_dma_pointer(chip->dma1, chip->p_dma_size); in snd_wss_playback_pointer()
1137 struct snd_wss *chip = snd_pcm_substream_chip(substream); in snd_wss_capture_pointer() local
1140 if (!(chip->image[CS4231_IFACE_CTRL] & CS4231_RECORD_ENABLE)) in snd_wss_capture_pointer()
1142 ptr = snd_dma_pointer(chip->dma2, chip->c_dma_size); in snd_wss_capture_pointer()
1150 static int snd_ad1848_probe(struct snd_wss *chip) in snd_ad1848_probe() argument
1159 while (wss_inb(chip, CS4231P(REGSEL)) & CS4231_INIT) { in snd_ad1848_probe()
1164 spin_lock_irqsave(&chip->reg_lock, flags); in snd_ad1848_probe()
1167 snd_wss_dout(chip, CS4231_MISC_INFO, 0); in snd_ad1848_probe()
1169 snd_wss_dout(chip, CS4231_RIGHT_INPUT, 0x45); /* 0x55 & ~0x10 */ in snd_ad1848_probe()
1170 r = snd_wss_in(chip, CS4231_RIGHT_INPUT); in snd_ad1848_probe()
1179 snd_wss_dout(chip, CS4231_LEFT_INPUT, 0xaa); in snd_ad1848_probe()
1180 r = snd_wss_in(chip, CS4231_LEFT_INPUT); in snd_ad1848_probe()
1189 wss_inb(chip, CS4231P(STATUS)); in snd_ad1848_probe()
1190 wss_outb(chip, CS4231P(STATUS), 0); in snd_ad1848_probe()
1193 if ((chip->hardware & WSS_HW_TYPE_MASK) != WSS_HW_DETECT) in snd_ad1848_probe()
1197 chip->hardware = hardware; in snd_ad1848_probe()
1201 r = snd_wss_in(chip, CS4231_MISC_INFO); in snd_ad1848_probe()
1204 snd_wss_dout(chip, CS4231_MISC_INFO, CS4231_MODE2); in snd_ad1848_probe()
1206 if (snd_wss_in(chip, i) != snd_wss_in(chip, 16 + i)) { in snd_ad1848_probe()
1214 snd_wss_dout(chip, CS4231_VERSION, 0); in snd_ad1848_probe()
1215 r = snd_wss_in(chip, CS4231_VERSION) & 0xe7; in snd_ad1848_probe()
1217 chip->hardware = WSS_HW_CMI8330; in snd_ad1848_probe()
1222 chip->hardware = WSS_HW_CS4248; in snd_ad1848_probe()
1224 chip->hardware = WSS_HW_AD1848; in snd_ad1848_probe()
1226 snd_wss_dout(chip, CS4231_MISC_INFO, 0); in snd_ad1848_probe()
1228 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_ad1848_probe()
1232 static int snd_wss_probe(struct snd_wss *chip) in snd_wss_probe() argument
1239 id = snd_ad1848_probe(chip); in snd_wss_probe()
1243 hw = chip->hardware; in snd_wss_probe()
1247 if (wss_inb(chip, CS4231P(REGSEL)) & CS4231_INIT) in snd_wss_probe()
1250 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_probe()
1251 snd_wss_out(chip, CS4231_MISC_INFO, in snd_wss_probe()
1253 id = snd_wss_in(chip, CS4231_MISC_INFO) & 0x0f; in snd_wss_probe()
1254 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_probe()
1259 snd_printdd("wss: port = 0x%lx, id = 0x%x\n", chip->port, id); in snd_wss_probe()
1263 rev = snd_wss_in(chip, CS4231_VERSION) & 0xe7; in snd_wss_probe()
1266 unsigned char tmp = snd_wss_in(chip, 23); in snd_wss_probe()
1267 snd_wss_out(chip, 23, ~tmp); in snd_wss_probe()
1268 if (snd_wss_in(chip, 23) != tmp) in snd_wss_probe()
1269 chip->hardware = WSS_HW_AD1845; in snd_wss_probe()
1271 chip->hardware = WSS_HW_CS4231; in snd_wss_probe()
1273 chip->hardware = WSS_HW_CS4231A; in snd_wss_probe()
1275 chip->hardware = WSS_HW_CS4232; in snd_wss_probe()
1277 chip->hardware = WSS_HW_CS4232A; in snd_wss_probe()
1279 chip->hardware = WSS_HW_CS4236; in snd_wss_probe()
1281 chip->hardware = WSS_HW_CS4236B; in snd_wss_probe()
1288 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_probe()
1289 wss_inb(chip, CS4231P(STATUS)); /* clear any pendings IRQ */ in snd_wss_probe()
1290 wss_outb(chip, CS4231P(STATUS), 0); in snd_wss_probe()
1292 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_probe()
1294 if (!(chip->hardware & WSS_HW_AD1848_MASK)) in snd_wss_probe()
1295 chip->image[CS4231_MISC_INFO] = CS4231_MODE2; in snd_wss_probe()
1296 switch (chip->hardware) { in snd_wss_probe()
1298 chip->image[CS4231_MISC_INFO] = CS4231_IW_MODE3; in snd_wss_probe()
1306 chip->image[CS4231_MISC_INFO] = CS4231_4236_MODE3; in snd_wss_probe()
1308 chip->hardware = WSS_HW_CS4236; in snd_wss_probe()
1312 chip->image[CS4231_IFACE_CTRL] = in snd_wss_probe()
1313 (chip->image[CS4231_IFACE_CTRL] & ~CS4231_SINGLE_DMA) | in snd_wss_probe()
1314 (chip->single_dma ? CS4231_SINGLE_DMA : 0); in snd_wss_probe()
1315 if (chip->hardware != WSS_HW_OPTI93X) { in snd_wss_probe()
1316 chip->image[CS4231_ALT_FEATURE_1] = 0x80; in snd_wss_probe()
1317 chip->image[CS4231_ALT_FEATURE_2] = in snd_wss_probe()
1318 chip->hardware == WSS_HW_INTERWAVE ? 0xc2 : 0x01; in snd_wss_probe()
1321 if (chip->hardware == WSS_HW_AD1845) in snd_wss_probe()
1322 chip->image[AD1845_PWR_DOWN] = 8; in snd_wss_probe()
1324 ptr = (unsigned char *) &chip->image; in snd_wss_probe()
1325 regnum = (chip->hardware & WSS_HW_AD1848_MASK) ? 16 : 32; in snd_wss_probe()
1326 snd_wss_mce_down(chip); in snd_wss_probe()
1327 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_probe()
1329 snd_wss_out(chip, i, *ptr++); in snd_wss_probe()
1330 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_probe()
1331 snd_wss_mce_up(chip); in snd_wss_probe()
1332 snd_wss_mce_down(chip); in snd_wss_probe()
1338 if (chip->hardware == WSS_HW_CS4236B) { in snd_wss_probe()
1339 rev = snd_cs4236_ext_in(chip, CS4236_VERSION); in snd_wss_probe()
1340 snd_cs4236_ext_out(chip, CS4236_VERSION, 0xff); in snd_wss_probe()
1341 id = snd_cs4236_ext_in(chip, CS4236_VERSION); in snd_wss_probe()
1342 snd_cs4236_ext_out(chip, CS4236_VERSION, rev); in snd_wss_probe()
1345 chip->hardware = WSS_HW_CS4235; in snd_wss_probe()
1363 chip->hardware = WSS_HW_CS4236B; in snd_wss_probe()
1372 chip->hardware = WSS_HW_CS4237B; in snd_wss_probe()
1386 chip->hardware = WSS_HW_CS4238B; in snd_wss_probe()
1399 chip->hardware = WSS_HW_CS4239; in snd_wss_probe()
1472 struct snd_wss *chip = snd_pcm_substream_chip(substream); in snd_wss_playback_open() local
1479 if (chip->hardware & WSS_HW_AD1848_MASK) in snd_wss_playback_open()
1484 if (chip->hardware == WSS_HW_INTERWAVE && chip->dma1 > 3) in snd_wss_playback_open()
1488 if (chip->hardware == WSS_HW_CS4235 || in snd_wss_playback_open()
1489 chip->hardware == WSS_HW_CS4239) in snd_wss_playback_open()
1492 snd_pcm_limit_isa_dma_size(chip->dma1, &runtime->hw.buffer_bytes_max); in snd_wss_playback_open()
1493 snd_pcm_limit_isa_dma_size(chip->dma1, &runtime->hw.period_bytes_max); in snd_wss_playback_open()
1495 if (chip->claim_dma) { in snd_wss_playback_open()
1496 err = chip->claim_dma(chip, chip->dma_private_data, chip->dma1); in snd_wss_playback_open()
1501 err = snd_wss_open(chip, WSS_MODE_PLAY); in snd_wss_playback_open()
1503 if (chip->release_dma) in snd_wss_playback_open()
1504 chip->release_dma(chip, chip->dma_private_data, chip->dma1); in snd_wss_playback_open()
1507 chip->playback_substream = substream; in snd_wss_playback_open()
1509 chip->rate_constraint(runtime); in snd_wss_playback_open()
1515 struct snd_wss *chip = snd_pcm_substream_chip(substream); in snd_wss_capture_open() local
1522 if (chip->hardware & WSS_HW_AD1848_MASK) in snd_wss_capture_open()
1527 if (chip->hardware == WSS_HW_CS4235 || in snd_wss_capture_open()
1528 chip->hardware == WSS_HW_CS4239 || in snd_wss_capture_open()
1529 chip->hardware == WSS_HW_OPTI93X) in snd_wss_capture_open()
1533 snd_pcm_limit_isa_dma_size(chip->dma2, &runtime->hw.buffer_bytes_max); in snd_wss_capture_open()
1534 snd_pcm_limit_isa_dma_size(chip->dma2, &runtime->hw.period_bytes_max); in snd_wss_capture_open()
1536 if (chip->claim_dma) { in snd_wss_capture_open()
1537 err = chip->claim_dma(chip, chip->dma_private_data, chip->dma2); in snd_wss_capture_open()
1542 err = snd_wss_open(chip, WSS_MODE_RECORD); in snd_wss_capture_open()
1544 if (chip->release_dma) in snd_wss_capture_open()
1545 chip->release_dma(chip, chip->dma_private_data, chip->dma2); in snd_wss_capture_open()
1548 chip->capture_substream = substream; in snd_wss_capture_open()
1550 chip->rate_constraint(runtime); in snd_wss_capture_open()
1556 struct snd_wss *chip = snd_pcm_substream_chip(substream); in snd_wss_playback_close() local
1558 chip->playback_substream = NULL; in snd_wss_playback_close()
1559 snd_wss_close(chip, WSS_MODE_PLAY); in snd_wss_playback_close()
1565 struct snd_wss *chip = snd_pcm_substream_chip(substream); in snd_wss_capture_close() local
1567 chip->capture_substream = NULL; in snd_wss_capture_close()
1568 snd_wss_close(chip, WSS_MODE_RECORD); in snd_wss_capture_close()
1572 static void snd_wss_thinkpad_twiddle(struct snd_wss *chip, int on) in snd_wss_thinkpad_twiddle() argument
1576 if (!chip->thinkpad_flag) in snd_wss_thinkpad_twiddle()
1595 static void snd_wss_suspend(struct snd_wss *chip) in snd_wss_suspend() argument
1600 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_suspend()
1602 chip->image[reg] = snd_wss_in(chip, reg); in snd_wss_suspend()
1603 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_suspend()
1604 if (chip->thinkpad_flag) in snd_wss_suspend()
1605 snd_wss_thinkpad_twiddle(chip, 0); in snd_wss_suspend()
1609 static void snd_wss_resume(struct snd_wss *chip) in snd_wss_resume() argument
1615 if (chip->thinkpad_flag) in snd_wss_resume()
1616 snd_wss_thinkpad_twiddle(chip, 1); in snd_wss_resume()
1617 snd_wss_mce_up(chip); in snd_wss_resume()
1618 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_resume()
1624 snd_wss_out(chip, reg, chip->image[reg]); in snd_wss_resume()
1629 if (chip->hardware == WSS_HW_OPL3SA2) in snd_wss_resume()
1630 snd_wss_out(chip, CS4231_PLAYBK_FORMAT, in snd_wss_resume()
1631 chip->image[CS4231_PLAYBK_FORMAT]); in snd_wss_resume()
1632 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_resume()
1634 snd_wss_mce_down(chip); in snd_wss_resume()
1640 snd_wss_busy_wait(chip); in snd_wss_resume()
1641 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_resume()
1642 chip->mce_bit &= ~CS4231_MCE; in snd_wss_resume()
1643 timeout = wss_inb(chip, CS4231P(REGSEL)); in snd_wss_resume()
1644 wss_outb(chip, CS4231P(REGSEL), chip->mce_bit | (timeout & 0x1f)); in snd_wss_resume()
1645 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_resume()
1648 "- codec still busy\n", chip->port); in snd_wss_resume()
1650 !(chip->hardware & (WSS_HW_CS4231_MASK | WSS_HW_CS4232_MASK))) { in snd_wss_resume()
1653 snd_wss_busy_wait(chip); in snd_wss_resume()
1658 const char *snd_wss_chip_id(struct snd_wss *chip) in snd_wss_chip_id() argument
1660 switch (chip->hardware) { in snd_wss_chip_id()
1684 return chip->card->shortname; in snd_wss_chip_id()
1708 struct snd_wss *chip; in snd_wss_new() local
1711 chip = devm_kzalloc(card->dev, sizeof(*chip), GFP_KERNEL); in snd_wss_new()
1712 if (chip == NULL) in snd_wss_new()
1714 chip->hardware = hardware; in snd_wss_new()
1715 chip->hwshare = hwshare; in snd_wss_new()
1717 spin_lock_init(&chip->reg_lock); in snd_wss_new()
1718 mutex_init(&chip->mce_mutex); in snd_wss_new()
1719 mutex_init(&chip->open_mutex); in snd_wss_new()
1720 chip->card = card; in snd_wss_new()
1721 chip->rate_constraint = snd_wss_xrate; in snd_wss_new()
1722 chip->set_playback_format = snd_wss_playback_format; in snd_wss_new()
1723 chip->set_capture_format = snd_wss_capture_format; in snd_wss_new()
1724 if (chip->hardware == WSS_HW_OPTI93X) in snd_wss_new()
1725 memcpy(&chip->image, &snd_opti93x_original_image, in snd_wss_new()
1728 memcpy(&chip->image, &snd_wss_original_image, in snd_wss_new()
1730 if (chip->hardware & WSS_HW_AD1848_MASK) { in snd_wss_new()
1731 chip->image[CS4231_PIN_CTRL] = 0; in snd_wss_new()
1732 chip->image[CS4231_TEST_INIT] = 0; in snd_wss_new()
1735 *rchip = chip; in snd_wss_new()
1747 struct snd_wss *chip; in snd_wss_create() local
1750 err = snd_wss_new(card, hardware, hwshare, &chip); in snd_wss_create()
1754 chip->irq = -1; in snd_wss_create()
1755 chip->dma1 = -1; in snd_wss_create()
1756 chip->dma2 = -1; in snd_wss_create()
1758 chip->res_port = devm_request_region(card->dev, port, 4, "WSS"); in snd_wss_create()
1759 if (!chip->res_port) { in snd_wss_create()
1763 chip->port = port; in snd_wss_create()
1765 chip->res_cport = devm_request_region(card->dev, cport, 8, in snd_wss_create()
1767 if (!chip->res_cport) { in snd_wss_create()
1773 chip->cport = cport; in snd_wss_create()
1776 "WSS", (void *) chip)) { in snd_wss_create()
1780 chip->irq = irq; in snd_wss_create()
1781 card->sync_irq = chip->irq; in snd_wss_create()
1787 chip->dma1 = dma1; in snd_wss_create()
1794 chip->single_dma = 1; in snd_wss_create()
1795 chip->dma2 = chip->dma1; in snd_wss_create()
1797 chip->dma2 = dma2; in snd_wss_create()
1800 chip->thinkpad_flag = 1; in snd_wss_create()
1801 chip->hardware = WSS_HW_DETECT; /* reset */ in snd_wss_create()
1802 snd_wss_thinkpad_twiddle(chip, 1); in snd_wss_create()
1806 if (snd_wss_probe(chip) < 0) in snd_wss_create()
1808 snd_wss_init(chip); in snd_wss_create()
1811 if (chip->hardware & WSS_HW_CS4232_MASK) { in snd_wss_create()
1812 if (chip->res_cport == NULL) in snd_wss_create()
1820 chip->suspend = snd_wss_suspend; in snd_wss_create()
1821 chip->resume = snd_wss_resume; in snd_wss_create()
1824 *rchip = chip; in snd_wss_create()
1847 int snd_wss_pcm(struct snd_wss *chip, int device) in snd_wss_pcm() argument
1852 err = snd_pcm_new(chip->card, "WSS", device, 1, 1, &pcm); in snd_wss_pcm()
1860 pcm->private_data = chip; in snd_wss_pcm()
1862 if (chip->single_dma) in snd_wss_pcm()
1864 if (chip->hardware != WSS_HW_INTERWAVE) in snd_wss_pcm()
1866 strcpy(pcm->name, snd_wss_chip_id(chip)); in snd_wss_pcm()
1868 snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, chip->card->dev, in snd_wss_pcm()
1869 64*1024, chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024); in snd_wss_pcm()
1871 chip->pcm = pcm; in snd_wss_pcm()
1878 struct snd_wss *chip = timer->private_data; in snd_wss_timer_free() local
1879 chip->timer = NULL; in snd_wss_timer_free()
1882 int snd_wss_timer(struct snd_wss *chip, int device) in snd_wss_timer() argument
1891 tid.card = chip->card->number; in snd_wss_timer()
1894 err = snd_timer_new(chip->card, "CS4231", &tid, &timer); in snd_wss_timer()
1897 strcpy(timer->name, snd_wss_chip_id(chip)); in snd_wss_timer()
1898 timer->private_data = chip; in snd_wss_timer()
1901 chip->timer = timer; in snd_wss_timer()
1923 struct snd_wss *chip = snd_kcontrol_chip(kcontrol); in snd_wss_info_mux() local
1925 if (snd_BUG_ON(!chip->card)) in snd_wss_info_mux()
1927 if (!strcmp(chip->card->driver, "GUS MAX")) in snd_wss_info_mux()
1929 switch (chip->hardware) { in snd_wss_info_mux()
1944 struct snd_wss *chip = snd_kcontrol_chip(kcontrol); in snd_wss_get_mux() local
1947 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_get_mux()
1948 ucontrol->value.enumerated.item[0] = (chip->image[CS4231_LEFT_INPUT] & CS4231_MIXS_ALL) >> 6; in snd_wss_get_mux()
1949 ucontrol->value.enumerated.item[1] = (chip->image[CS4231_RIGHT_INPUT] & CS4231_MIXS_ALL) >> 6; in snd_wss_get_mux()
1950 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_get_mux()
1957 struct snd_wss *chip = snd_kcontrol_chip(kcontrol); in snd_wss_put_mux() local
1967 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_put_mux()
1968 left = (chip->image[CS4231_LEFT_INPUT] & ~CS4231_MIXS_ALL) | left; in snd_wss_put_mux()
1969 right = (chip->image[CS4231_RIGHT_INPUT] & ~CS4231_MIXS_ALL) | right; in snd_wss_put_mux()
1970 change = left != chip->image[CS4231_LEFT_INPUT] || in snd_wss_put_mux()
1971 right != chip->image[CS4231_RIGHT_INPUT]; in snd_wss_put_mux()
1972 snd_wss_out(chip, CS4231_LEFT_INPUT, left); in snd_wss_put_mux()
1973 snd_wss_out(chip, CS4231_RIGHT_INPUT, right); in snd_wss_put_mux()
1974 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_put_mux()
1994 struct snd_wss *chip = snd_kcontrol_chip(kcontrol); in snd_wss_get_single() local
2001 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_get_single()
2002 ucontrol->value.integer.value[0] = (chip->image[reg] >> shift) & mask; in snd_wss_get_single()
2003 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_get_single()
2013 struct snd_wss *chip = snd_kcontrol_chip(kcontrol); in snd_wss_put_single() local
2026 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_put_single()
2027 val = (chip->image[reg] & ~(mask << shift)) | val; in snd_wss_put_single()
2028 change = val != chip->image[reg]; in snd_wss_put_single()
2029 snd_wss_out(chip, reg, val); in snd_wss_put_single()
2030 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_put_single()
2051 struct snd_wss *chip = snd_kcontrol_chip(kcontrol); in snd_wss_get_double() local
2060 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_get_double()
2061 ucontrol->value.integer.value[0] = (chip->image[left_reg] >> shift_left) & mask; in snd_wss_get_double()
2062 ucontrol->value.integer.value[1] = (chip->image[right_reg] >> shift_right) & mask; in snd_wss_get_double()
2063 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_get_double()
2075 struct snd_wss *chip = snd_kcontrol_chip(kcontrol); in snd_wss_put_double() local
2094 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_put_double()
2096 val1 = (chip->image[left_reg] & ~(mask << shift_left)) | val1; in snd_wss_put_double()
2097 val2 = (chip->image[right_reg] & ~(mask << shift_right)) | val2; in snd_wss_put_double()
2098 change = val1 != chip->image[left_reg] || in snd_wss_put_double()
2099 val2 != chip->image[right_reg]; in snd_wss_put_double()
2100 snd_wss_out(chip, left_reg, val1); in snd_wss_put_double()
2101 snd_wss_out(chip, right_reg, val2); in snd_wss_put_double()
2104 val1 = (chip->image[left_reg] & ~mask) | val1 | val2; in snd_wss_put_double()
2105 change = val1 != chip->image[left_reg]; in snd_wss_put_double()
2106 snd_wss_out(chip, left_reg, val1); in snd_wss_put_double()
2108 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_put_double()
2165 int snd_wss_mixer(struct snd_wss *chip) in snd_wss_mixer() argument
2172 if (snd_BUG_ON(!chip || !chip->pcm)) in snd_wss_mixer()
2175 card = chip->card; in snd_wss_mixer()
2177 strcpy(card->mixername, chip->pcm->name); in snd_wss_mixer()
2180 if (chip->hardware & WSS_HW_AD1848_MASK) in snd_wss_mixer()
2183 else if (chip->hardware == WSS_HW_OPTI93X) in snd_wss_mixer()
2189 chip)); in snd_wss_mixer()