Lines Matching +full:invert +full:- +full:ext
1 // SPDX-License-Identifier: GPL-2.0-or-later
7 * - sometimes record brokes playback with WSS portion of
8 * Yamaha OPL3-SA3 chip
9 * - CS4231 (GUS MAX) - still trouble with occasional noises
10 * - broken initialization?
77 0x00, /* 00/00 - lic */
78 0x00, /* 01/01 - ric */
79 0x9f, /* 02/02 - la1ic */
80 0x9f, /* 03/03 - ra1ic */
81 0x9f, /* 04/04 - la2ic */
82 0x9f, /* 05/05 - ra2ic */
83 0xbf, /* 06/06 - loc */
84 0xbf, /* 07/07 - roc */
85 0x20, /* 08/08 - pdfr */
86 CS4231_AUTOCALIB, /* 09/09 - ic */
87 0x00, /* 0a/10 - pc */
88 0x00, /* 0b/11 - ti */
89 CS4231_MODE2, /* 0c/12 - mi */
90 0xfc, /* 0d/13 - lbc */
91 0x00, /* 0e/14 - pbru */
92 0x00, /* 0f/15 - pbrl */
93 0x80, /* 10/16 - afei */
94 0x01, /* 11/17 - afeii */
95 0x9f, /* 12/18 - llic */
96 0x9f, /* 13/19 - rlic */
97 0x00, /* 14/20 - tlb */
98 0x00, /* 15/21 - thb */
99 0x00, /* 16/22 - la3mic/reserved */
100 0x00, /* 17/23 - ra3mic/reserved */
101 0x00, /* 18/24 - afs */
102 0x00, /* 19/25 - lamoc/version */
103 0xcf, /* 1a/26 - mioc */
104 0x00, /* 1b/27 - ramoc/reserved */
105 0x20, /* 1c/28 - cdfr */
106 0x00, /* 1d/29 - res4 */
107 0x00, /* 1e/30 - cbru */
108 0x00, /* 1f/31 - cbrl */
113 0x00, /* 00/00 - l_mixout_outctrl */
114 0x00, /* 01/01 - r_mixout_outctrl */
115 0x88, /* 02/02 - l_cd_inctrl */
116 0x88, /* 03/03 - r_cd_inctrl */
117 0x88, /* 04/04 - l_a1/fm_inctrl */
118 0x88, /* 05/05 - r_a1/fm_inctrl */
119 0x80, /* 06/06 - l_dac_inctrl */
120 0x80, /* 07/07 - r_dac_inctrl */
121 0x00, /* 08/08 - ply_dataform_reg */
122 0x00, /* 09/09 - if_conf */
123 0x00, /* 0a/10 - pin_ctrl */
124 0x00, /* 0b/11 - err_init_reg */
125 0x0a, /* 0c/12 - id_reg */
126 0x00, /* 0d/13 - reserved */
127 0x00, /* 0e/14 - ply_upcount_reg */
128 0x00, /* 0f/15 - ply_lowcount_reg */
129 0x88, /* 10/16 - reserved/l_a1_inctrl */
130 0x88, /* 11/17 - reserved/r_a1_inctrl */
131 0x88, /* 12/18 - l_line_inctrl */
132 0x88, /* 13/19 - r_line_inctrl */
133 0x88, /* 14/20 - l_mic_inctrl */
134 0x88, /* 15/21 - r_mic_inctrl */
135 0x80, /* 16/22 - l_out_outctrl */
136 0x80, /* 17/23 - r_out_outctrl */
137 0x00, /* 18/24 - reserved */
138 0x00, /* 19/25 - reserved */
139 0x00, /* 1a/26 - reserved */
140 0x00, /* 1b/27 - reserved */
141 0x00, /* 1c/28 - cap_dataform_reg */
142 0x00, /* 1d/29 - reserved */
143 0x00, /* 1e/30 - cap_upcount_reg */
144 0x00 /* 1f/31 - cap_lowcount_reg */
153 outb(val, chip->port + offset); in wss_outb()
158 return inb(chip->port + offset); in wss_inb()
167 timeout--) in snd_wss_wait()
178 timeout--) in snd_wss_dout()
180 wss_outb(chip, CS4231P(REGSEL), chip->mce_bit | reg); in snd_wss_dout()
190 dev_dbg(chip->card->dev, in snd_wss_out()
191 "out: auto calibration time out - reg = 0x%x, value = 0x%x\n", in snd_wss_out()
194 wss_outb(chip, CS4231P(REGSEL), chip->mce_bit | reg); in snd_wss_out()
196 chip->image[reg] = value; in snd_wss_out()
198 dev_dbg(chip->card->dev, "codec out - reg 0x%x = 0x%x\n", in snd_wss_out()
199 chip->mce_bit | reg, value); in snd_wss_out()
208 dev_dbg(chip->card->dev, in snd_wss_in()
209 "in: auto calibration time out - reg = 0x%x\n", reg); in snd_wss_in()
211 wss_outb(chip, CS4231P(REGSEL), chip->mce_bit | reg); in snd_wss_in()
220 wss_outb(chip, CS4231P(REGSEL), chip->mce_bit | 0x17); in snd_cs4236_ext_out()
222 reg | (chip->image[CS4236_EXT_REG] & 0x01)); in snd_cs4236_ext_out()
224 chip->eimage[CS4236_REG(reg)] = val; in snd_cs4236_ext_out()
226 dev_dbg(chip->card->dev, "ext out : reg = 0x%x, val = 0x%x\n", reg, val); in snd_cs4236_ext_out()
233 wss_outb(chip, CS4231P(REGSEL), chip->mce_bit | 0x17); in snd_cs4236_ext_in()
235 reg | (chip->image[CS4236_EXT_REG] & 0x01)); in snd_cs4236_ext_in()
242 dev_dbg(chip->card->dev, "ext in : reg = 0x%x, val = 0x%x\n", in snd_cs4236_ext_in()
254 dev_dbg(chip->card->dev,
259 dev_dbg(chip->card->dev,
264 dev_dbg(chip->card->dev,
269 dev_dbg(chip->card->dev,
274 dev_dbg(chip->card->dev,
279 dev_dbg(chip->card->dev,
284 dev_dbg(chip->card->dev,
289 dev_dbg(chip->card->dev,
294 dev_dbg(chip->card->dev,
299 dev_dbg(chip->card->dev,
304 dev_dbg(chip->card->dev,
309 dev_dbg(chip->card->dev,
314 dev_dbg(chip->card->dev,
319 dev_dbg(chip->card->dev,
324 dev_dbg(chip->card->dev,
329 dev_dbg(chip->card->dev,
334 dev_dbg(chip->card->dev,
352 for (timeout = 5; timeout > 0; timeout--) in snd_wss_busy_wait()
357 timeout--) in snd_wss_busy_wait()
369 dev_dbg(chip->card->dev, in snd_wss_mce_up()
370 "mce_up - auto calibration time out (0)\n"); in snd_wss_mce_up()
372 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_mce_up()
373 chip->mce_bit |= CS4231_MCE; in snd_wss_mce_up()
376 dev_dbg(chip->card->dev, in snd_wss_mce_up()
377 "mce_up [0x%lx]: serious init problem - codec still busy\n", in snd_wss_mce_up()
378 chip->port); in snd_wss_mce_up()
381 chip->mce_bit | (timeout & 0x1f)); in snd_wss_mce_up()
382 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_mce_up()
397 dev_dbg(chip->card->dev, in snd_wss_mce_down()
398 "mce_down [0x%lx] - auto calibration time out (0)\n", in snd_wss_mce_down()
401 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_mce_down()
402 chip->mce_bit &= ~CS4231_MCE; in snd_wss_mce_down()
404 wss_outb(chip, CS4231P(REGSEL), chip->mce_bit | (timeout & 0x1f)); in snd_wss_mce_down()
405 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_mce_down()
407 dev_dbg(chip->card->dev, in snd_wss_mce_down()
408 "mce_down [0x%lx]: serious init problem - codec still busy\n", in snd_wss_mce_down()
409 chip->port); in snd_wss_mce_down()
410 if ((timeout & CS4231_MCE) == 0 || !(chip->hardware & hw_mask)) in snd_wss_mce_down()
414 * Wait for (possible -- during init auto-calibration may not be set) in snd_wss_mce_down()
420 dev_dbg(chip->card->dev, "(1) jiffies = %lu\n", jiffies); in snd_wss_mce_down()
428 dev_err(chip->card->dev, in snd_wss_mce_down()
429 "mce_down - auto calibration time out (2)\n"); in snd_wss_mce_down()
435 dev_dbg(chip->card->dev, "(2) jiffies = %lu\n", jiffies); in snd_wss_mce_down()
441 dev_err(chip->card->dev, in snd_wss_mce_down()
442 "mce_down - auto calibration time out (3)\n"); in snd_wss_mce_down()
448 dev_dbg(chip->card->dev, "(3) jiffies = %lu\n", jiffies); in snd_wss_mce_down()
449 dev_dbg(chip->card->dev, "mce_down - exit = 0x%x\n", in snd_wss_mce_down()
486 return -EINVAL; in snd_wss_trigger()
491 if (s == chip->playback_substream) { in snd_wss_trigger()
494 } else if (s == chip->capture_substream) { in snd_wss_trigger()
499 spin_lock(&chip->reg_lock); in snd_wss_trigger()
501 chip->image[CS4231_IFACE_CTRL] |= what; in snd_wss_trigger()
502 if (chip->trigger) in snd_wss_trigger()
503 chip->trigger(chip, what, 1); in snd_wss_trigger()
505 chip->image[CS4231_IFACE_CTRL] &= ~what; in snd_wss_trigger()
506 if (chip->trigger) in snd_wss_trigger()
507 chip->trigger(chip, what, 0); in snd_wss_trigger()
509 snd_wss_out(chip, CS4231_IFACE_CTRL, chip->image[CS4231_IFACE_CTRL]); in snd_wss_trigger()
510 spin_unlock(&chip->reg_lock); in snd_wss_trigger()
529 return freq_bits[ARRAY_SIZE(rates) - 1]; in snd_wss_get_rate()
549 dev_dbg(chip->card->dev, "get_format: 0x%x (mode=0x%x)\n", format, mode); in snd_wss_get_format()
559 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_calibrate_mute()
560 if (chip->calibrate_mute == mute) { in snd_wss_calibrate_mute()
561 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_calibrate_mute()
566 chip->image[CS4231_LEFT_INPUT]); in snd_wss_calibrate_mute()
568 chip->image[CS4231_RIGHT_INPUT]); in snd_wss_calibrate_mute()
570 chip->image[CS4231_LOOPBACK]); in snd_wss_calibrate_mute()
581 mute | chip->image[CS4231_AUX1_LEFT_INPUT]); in snd_wss_calibrate_mute()
583 mute | chip->image[CS4231_AUX1_RIGHT_INPUT]); in snd_wss_calibrate_mute()
585 mute | chip->image[CS4231_AUX2_LEFT_INPUT]); in snd_wss_calibrate_mute()
587 mute | chip->image[CS4231_AUX2_RIGHT_INPUT]); in snd_wss_calibrate_mute()
589 mute | chip->image[CS4231_LEFT_OUTPUT]); in snd_wss_calibrate_mute()
591 mute | chip->image[CS4231_RIGHT_OUTPUT]); in snd_wss_calibrate_mute()
592 if (!(chip->hardware & WSS_HW_AD1848_MASK)) { in snd_wss_calibrate_mute()
594 mute | chip->image[CS4231_LEFT_LINE_IN]); in snd_wss_calibrate_mute()
596 mute | chip->image[CS4231_RIGHT_LINE_IN]); in snd_wss_calibrate_mute()
598 mute ? 0xc0 : chip->image[CS4231_MONO_CTRL]); in snd_wss_calibrate_mute()
600 if (chip->hardware == WSS_HW_INTERWAVE) { in snd_wss_calibrate_mute()
602 mute | chip->image[CS4231_LEFT_MIC_INPUT]); in snd_wss_calibrate_mute()
604 mute | chip->image[CS4231_RIGHT_MIC_INPUT]); in snd_wss_calibrate_mute()
606 mute | chip->image[CS4231_LINE_LEFT_OUTPUT]); in snd_wss_calibrate_mute()
608 mute | chip->image[CS4231_LINE_RIGHT_OUTPUT]); in snd_wss_calibrate_mute()
610 chip->calibrate_mute = mute; in snd_wss_calibrate_mute()
611 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_calibrate_mute()
621 mutex_lock(&chip->mce_mutex); in snd_wss_playback_format()
622 if (chip->hardware == WSS_HW_CS4231A || in snd_wss_playback_format()
623 (chip->hardware & WSS_HW_CS4232_MASK)) { in snd_wss_playback_format()
624 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_playback_format()
625 if ((chip->image[CS4231_PLAYBK_FORMAT] & 0x0f) == (pdfr & 0x0f)) { /* rate is same? */ in snd_wss_playback_format()
627 chip->image[CS4231_ALT_FEATURE_1] | 0x10); in snd_wss_playback_format()
628 chip->image[CS4231_PLAYBK_FORMAT] = pdfr; in snd_wss_playback_format()
630 chip->image[CS4231_PLAYBK_FORMAT]); in snd_wss_playback_format()
632 chip->image[CS4231_ALT_FEATURE_1] &= ~0x10); in snd_wss_playback_format()
636 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_playback_format()
637 } else if (chip->hardware == WSS_HW_AD1845) { in snd_wss_playback_format()
649 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_playback_format()
654 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_playback_format()
658 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_playback_format()
659 if (chip->hardware != WSS_HW_INTERWAVE && !chip->single_dma) { in snd_wss_playback_format()
660 if (chip->image[CS4231_IFACE_CTRL] & CS4231_RECORD_ENABLE) in snd_wss_playback_format()
662 (chip->image[CS4231_REC_FORMAT] & 0x0f); in snd_wss_playback_format()
664 chip->image[CS4231_PLAYBK_FORMAT] = pdfr; in snd_wss_playback_format()
667 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_playback_format()
668 if (chip->hardware == WSS_HW_OPL3SA2) in snd_wss_playback_format()
672 mutex_unlock(&chip->mce_mutex); in snd_wss_playback_format()
682 mutex_lock(&chip->mce_mutex); in snd_wss_capture_format()
683 if (chip->hardware == WSS_HW_CS4231A || in snd_wss_capture_format()
684 (chip->hardware & WSS_HW_CS4232_MASK)) { in snd_wss_capture_format()
685 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_capture_format()
686 if ((chip->image[CS4231_PLAYBK_FORMAT] & 0x0f) == (cdfr & 0x0f) || /* rate is same? */ in snd_wss_capture_format()
687 (chip->image[CS4231_IFACE_CTRL] & CS4231_PLAYBACK_ENABLE)) { in snd_wss_capture_format()
689 chip->image[CS4231_ALT_FEATURE_1] | 0x20); in snd_wss_capture_format()
691 chip->image[CS4231_REC_FORMAT] = cdfr); in snd_wss_capture_format()
693 chip->image[CS4231_ALT_FEATURE_1] &= ~0x20); in snd_wss_capture_format()
696 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_capture_format()
697 } else if (chip->hardware == WSS_HW_AD1845) { in snd_wss_capture_format()
709 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_capture_format()
714 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_capture_format()
718 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_capture_format()
719 if (chip->hardware != WSS_HW_INTERWAVE && in snd_wss_capture_format()
720 !(chip->image[CS4231_IFACE_CTRL] & CS4231_PLAYBACK_ENABLE)) { in snd_wss_capture_format()
721 if (chip->single_dma) in snd_wss_capture_format()
725 (chip->image[CS4231_PLAYBK_FORMAT] & 0xf0) | in snd_wss_capture_format()
727 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_capture_format()
730 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_capture_format()
732 if (chip->hardware & WSS_HW_AD1848_MASK) in snd_wss_capture_format()
736 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_capture_format()
739 mutex_unlock(&chip->mce_mutex); in snd_wss_capture_format()
749 if (chip->hardware & WSS_HW_CS4236B_MASK) in snd_wss_timer_resolution()
752 return chip->image[CS4231_PLAYBK_FORMAT] & 1 ? 9969 : 9920; in snd_wss_timer_resolution()
760 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_timer_start()
761 ticks = timer->sticks; in snd_wss_timer_start()
762 if ((chip->image[CS4231_ALT_FEATURE_1] & CS4231_TIMER_ENABLE) == 0 || in snd_wss_timer_start()
763 (unsigned char)(ticks >> 8) != chip->image[CS4231_TIMER_HIGH] || in snd_wss_timer_start()
764 (unsigned char)ticks != chip->image[CS4231_TIMER_LOW]) { in snd_wss_timer_start()
765 chip->image[CS4231_TIMER_HIGH] = (unsigned char) (ticks >> 8); in snd_wss_timer_start()
767 chip->image[CS4231_TIMER_HIGH]); in snd_wss_timer_start()
768 chip->image[CS4231_TIMER_LOW] = (unsigned char) ticks; in snd_wss_timer_start()
770 chip->image[CS4231_TIMER_LOW]); in snd_wss_timer_start()
772 chip->image[CS4231_ALT_FEATURE_1] | in snd_wss_timer_start()
775 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_timer_start()
783 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_timer_stop()
784 chip->image[CS4231_ALT_FEATURE_1] &= ~CS4231_TIMER_ENABLE; in snd_wss_timer_stop()
786 chip->image[CS4231_ALT_FEATURE_1]); in snd_wss_timer_stop()
787 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_timer_stop()
799 dev_dbg(chip->card->dev, "init: (1)\n"); in snd_wss_init()
802 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_init()
803 chip->image[CS4231_IFACE_CTRL] &= ~(CS4231_PLAYBACK_ENABLE | in snd_wss_init()
808 chip->image[CS4231_IFACE_CTRL] |= CS4231_AUTOCALIB; in snd_wss_init()
809 snd_wss_out(chip, CS4231_IFACE_CTRL, chip->image[CS4231_IFACE_CTRL]); in snd_wss_init()
810 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_init()
814 dev_dbg(chip->card->dev, "init: (2)\n"); in snd_wss_init()
818 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_init()
819 chip->image[CS4231_IFACE_CTRL] &= ~CS4231_AUTOCALIB; in snd_wss_init()
820 snd_wss_out(chip, CS4231_IFACE_CTRL, chip->image[CS4231_IFACE_CTRL]); in snd_wss_init()
822 CS4231_ALT_FEATURE_1, chip->image[CS4231_ALT_FEATURE_1]); in snd_wss_init()
823 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_init()
827 dev_dbg(chip->card->dev, "init: (3) - afei = 0x%x\n", in snd_wss_init()
828 chip->image[CS4231_ALT_FEATURE_1]); in snd_wss_init()
831 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_init()
833 chip->image[CS4231_ALT_FEATURE_2]); in snd_wss_init()
834 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_init()
837 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_init()
839 chip->image[CS4231_PLAYBK_FORMAT]); in snd_wss_init()
840 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_init()
844 dev_dbg(chip->card->dev, "init: (4)\n"); in snd_wss_init()
848 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_init()
849 if (!(chip->hardware & WSS_HW_AD1848_MASK)) in snd_wss_init()
851 chip->image[CS4231_REC_FORMAT]); in snd_wss_init()
852 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_init()
857 dev_dbg(chip->card->dev, "init: (5)\n"); in snd_wss_init()
865 mutex_lock(&chip->open_mutex); in snd_wss_open()
866 if ((chip->mode & mode) || in snd_wss_open()
867 ((chip->mode & WSS_MODE_OPEN) && chip->single_dma)) { in snd_wss_open()
868 mutex_unlock(&chip->open_mutex); in snd_wss_open()
869 return -EAGAIN; in snd_wss_open()
871 if (chip->mode & WSS_MODE_OPEN) { in snd_wss_open()
872 chip->mode |= mode; in snd_wss_open()
873 mutex_unlock(&chip->open_mutex); in snd_wss_open()
877 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_open()
878 if (!(chip->hardware & WSS_HW_AD1848_MASK)) { in snd_wss_open()
887 chip->image[CS4231_PIN_CTRL] |= CS4231_IRQ_ENABLE; in snd_wss_open()
888 snd_wss_out(chip, CS4231_PIN_CTRL, chip->image[CS4231_PIN_CTRL]); in snd_wss_open()
889 if (!(chip->hardware & WSS_HW_AD1848_MASK)) { in snd_wss_open()
896 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_open()
898 chip->mode = mode; in snd_wss_open()
899 mutex_unlock(&chip->open_mutex); in snd_wss_open()
907 mutex_lock(&chip->open_mutex); in snd_wss_close()
908 chip->mode &= ~mode; in snd_wss_close()
909 if (chip->mode & WSS_MODE_OPEN) { in snd_wss_close()
910 mutex_unlock(&chip->open_mutex); in snd_wss_close()
914 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_close()
915 if (!(chip->hardware & WSS_HW_AD1848_MASK)) in snd_wss_close()
919 chip->image[CS4231_PIN_CTRL] &= ~CS4231_IRQ_ENABLE; in snd_wss_close()
920 snd_wss_out(chip, CS4231_PIN_CTRL, chip->image[CS4231_PIN_CTRL]); in snd_wss_close()
924 if (chip->image[CS4231_IFACE_CTRL] & (CS4231_PLAYBACK_ENABLE | CS4231_PLAYBACK_PIO | in snd_wss_close()
926 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_close()
928 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_close()
929 chip->image[CS4231_IFACE_CTRL] &= ~(CS4231_PLAYBACK_ENABLE | CS4231_PLAYBACK_PIO | in snd_wss_close()
932 chip->image[CS4231_IFACE_CTRL]); in snd_wss_close()
933 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_close()
935 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_close()
939 if (!(chip->hardware & WSS_HW_AD1848_MASK)) in snd_wss_close()
943 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_close()
945 chip->mode = 0; in snd_wss_close()
946 mutex_unlock(&chip->open_mutex); in snd_wss_close()
992 chip->set_playback_format(chip, hw_params, new_pdfr); in snd_wss_playback_hw_params()
999 struct snd_pcm_runtime *runtime = substream->runtime; in snd_wss_playback_prepare()
1004 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_playback_prepare()
1005 chip->p_dma_size = size; in snd_wss_playback_prepare()
1006 chip->image[CS4231_IFACE_CTRL] &= ~(CS4231_PLAYBACK_ENABLE | CS4231_PLAYBACK_PIO); in snd_wss_playback_prepare()
1007 snd_dma_program(chip->dma1, runtime->dma_addr, size, DMA_MODE_WRITE | DMA_AUTOINIT); in snd_wss_playback_prepare()
1008 count = snd_wss_get_count(chip->image[CS4231_PLAYBK_FORMAT], count) - 1; in snd_wss_playback_prepare()
1011 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_playback_prepare()
1027 chip->set_capture_format(chip, hw_params, new_cdfr); in snd_wss_capture_hw_params()
1034 struct snd_pcm_runtime *runtime = substream->runtime; in snd_wss_capture_prepare()
1039 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_capture_prepare()
1040 chip->c_dma_size = size; in snd_wss_capture_prepare()
1041 chip->image[CS4231_IFACE_CTRL] &= ~(CS4231_RECORD_ENABLE | CS4231_RECORD_PIO); in snd_wss_capture_prepare()
1042 snd_dma_program(chip->dma2, runtime->dma_addr, size, DMA_MODE_READ | DMA_AUTOINIT); in snd_wss_capture_prepare()
1043 if (chip->hardware & WSS_HW_AD1848_MASK) in snd_wss_capture_prepare()
1044 count = snd_wss_get_count(chip->image[CS4231_PLAYBK_FORMAT], in snd_wss_capture_prepare()
1047 count = snd_wss_get_count(chip->image[CS4231_REC_FORMAT], in snd_wss_capture_prepare()
1049 count--; in snd_wss_capture_prepare()
1050 if (chip->single_dma && chip->hardware != WSS_HW_INTERWAVE) { in snd_wss_capture_prepare()
1059 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_capture_prepare()
1068 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_overrange()
1070 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_overrange()
1072 chip->capture_substream->runtime->overrange++; in snd_wss_overrange()
1081 if (chip->hardware & WSS_HW_AD1848_MASK) in snd_wss_interrupt()
1087 if (chip->timer) in snd_wss_interrupt()
1088 snd_timer_interrupt(chip->timer, chip->timer->sticks); in snd_wss_interrupt()
1090 if (chip->single_dma && chip->hardware != WSS_HW_INTERWAVE) { in snd_wss_interrupt()
1092 if (chip->mode & WSS_MODE_PLAY) { in snd_wss_interrupt()
1093 if (chip->playback_substream) in snd_wss_interrupt()
1094 snd_pcm_period_elapsed(chip->playback_substream); in snd_wss_interrupt()
1096 if (chip->mode & WSS_MODE_RECORD) { in snd_wss_interrupt()
1097 if (chip->capture_substream) { in snd_wss_interrupt()
1099 snd_pcm_period_elapsed(chip->capture_substream); in snd_wss_interrupt()
1105 if (chip->playback_substream) in snd_wss_interrupt()
1106 snd_pcm_period_elapsed(chip->playback_substream); in snd_wss_interrupt()
1109 if (chip->capture_substream) { in snd_wss_interrupt()
1111 snd_pcm_period_elapsed(chip->capture_substream); in snd_wss_interrupt()
1116 spin_lock(&chip->reg_lock); in snd_wss_interrupt()
1118 if (chip->hardware & WSS_HW_AD1848_MASK) in snd_wss_interrupt()
1122 spin_unlock(&chip->reg_lock); in snd_wss_interrupt()
1132 if (!(chip->image[CS4231_IFACE_CTRL] & CS4231_PLAYBACK_ENABLE)) in snd_wss_playback_pointer()
1134 ptr = snd_dma_pointer(chip->dma1, chip->p_dma_size); in snd_wss_playback_pointer()
1135 return bytes_to_frames(substream->runtime, ptr); in snd_wss_playback_pointer()
1143 if (!(chip->image[CS4231_IFACE_CTRL] & CS4231_RECORD_ENABLE)) in snd_wss_capture_pointer()
1145 ptr = snd_dma_pointer(chip->dma2, chip->c_dma_size); in snd_wss_capture_pointer()
1146 return bytes_to_frames(substream->runtime, ptr); in snd_wss_capture_pointer()
1164 return -ENODEV; in snd_ad1848_probe()
1167 spin_lock_irqsave(&chip->reg_lock, flags); in snd_ad1848_probe()
1177 err = -ENODEV; in snd_ad1848_probe()
1186 err = -ENODEV; in snd_ad1848_probe()
1196 if ((chip->hardware & WSS_HW_TYPE_MASK) != WSS_HW_DETECT) in snd_ad1848_probe()
1200 chip->hardware = hardware; in snd_ad1848_probe()
1220 chip->hardware = WSS_HW_CMI8330; in snd_ad1848_probe()
1225 chip->hardware = WSS_HW_CS4248; in snd_ad1848_probe()
1227 chip->hardware = WSS_HW_AD1848; in snd_ad1848_probe()
1231 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_ad1848_probe()
1246 hw = chip->hardware; in snd_wss_probe()
1253 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_probe()
1257 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_probe()
1262 dev_dbg(chip->card->dev, "wss: port = 0x%lx, id = 0x%x\n", in snd_wss_probe()
1263 chip->port, id); in snd_wss_probe()
1265 return -ENODEV; /* no valid device found */ in snd_wss_probe()
1268 dev_dbg(chip->card->dev, "CS4231: VERSION (I25) = 0x%x\n", rev); in snd_wss_probe()
1273 chip->hardware = WSS_HW_AD1845; in snd_wss_probe()
1275 chip->hardware = WSS_HW_CS4231; in snd_wss_probe()
1277 chip->hardware = WSS_HW_CS4231A; in snd_wss_probe()
1279 chip->hardware = WSS_HW_CS4232; in snd_wss_probe()
1281 chip->hardware = WSS_HW_CS4232A; in snd_wss_probe()
1283 chip->hardware = WSS_HW_CS4236; in snd_wss_probe()
1285 chip->hardware = WSS_HW_CS4236B; in snd_wss_probe()
1287 dev_err(chip->card->dev, in snd_wss_probe()
1289 return -ENODEV; /* unknown CS4231 chip? */ in snd_wss_probe()
1292 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_probe()
1296 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_probe()
1298 if (!(chip->hardware & WSS_HW_AD1848_MASK)) in snd_wss_probe()
1299 chip->image[CS4231_MISC_INFO] = CS4231_MODE2; in snd_wss_probe()
1300 switch (chip->hardware) { in snd_wss_probe()
1302 chip->image[CS4231_MISC_INFO] = CS4231_IW_MODE3; in snd_wss_probe()
1310 chip->image[CS4231_MISC_INFO] = CS4231_4236_MODE3; in snd_wss_probe()
1312 chip->hardware = WSS_HW_CS4236; in snd_wss_probe()
1316 chip->image[CS4231_IFACE_CTRL] = in snd_wss_probe()
1317 (chip->image[CS4231_IFACE_CTRL] & ~CS4231_SINGLE_DMA) | in snd_wss_probe()
1318 (chip->single_dma ? CS4231_SINGLE_DMA : 0); in snd_wss_probe()
1319 if (chip->hardware != WSS_HW_OPTI93X) { in snd_wss_probe()
1320 chip->image[CS4231_ALT_FEATURE_1] = 0x80; in snd_wss_probe()
1321 chip->image[CS4231_ALT_FEATURE_2] = in snd_wss_probe()
1322 chip->hardware == WSS_HW_INTERWAVE ? 0xc2 : 0x01; in snd_wss_probe()
1325 if (chip->hardware == WSS_HW_AD1845) in snd_wss_probe()
1326 chip->image[AD1845_PWR_DOWN] = 8; in snd_wss_probe()
1328 ptr = (unsigned char *) &chip->image; in snd_wss_probe()
1329 regnum = (chip->hardware & WSS_HW_AD1848_MASK) ? 16 : 32; in snd_wss_probe()
1331 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_probe()
1334 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_probe()
1342 if (chip->hardware == WSS_HW_CS4236B) { in snd_wss_probe()
1347 dev_dbg(chip->card->dev, in snd_wss_probe()
1348 "CS4231: ext version; rev = 0x%x, id = 0x%x\n", in snd_wss_probe()
1351 chip->hardware = WSS_HW_CS4235; in snd_wss_probe()
1358 dev_warn(chip->card->dev, in snd_wss_probe()
1368 chip->hardware = WSS_HW_CS4236B; in snd_wss_probe()
1371 dev_warn(chip->card->dev, in snd_wss_probe()
1376 chip->hardware = WSS_HW_CS4237B; in snd_wss_probe()
1384 dev_warn(chip->card->dev, in snd_wss_probe()
1389 chip->hardware = WSS_HW_CS4238B; in snd_wss_probe()
1396 dev_warn(chip->card->dev, in snd_wss_probe()
1401 chip->hardware = WSS_HW_CS4239; in snd_wss_probe()
1408 dev_warn(chip->card->dev, in snd_wss_probe()
1413 dev_warn(chip->card->dev, in snd_wss_probe()
1474 struct snd_pcm_runtime *runtime = substream->runtime; in snd_wss_playback_open()
1477 runtime->hw = snd_wss_playback; in snd_wss_playback_open()
1480 if (chip->hardware & WSS_HW_AD1848_MASK) in snd_wss_playback_open()
1481 runtime->hw.formats &= ~(SNDRV_PCM_FMTBIT_IMA_ADPCM | in snd_wss_playback_open()
1485 if (chip->hardware == WSS_HW_INTERWAVE && chip->dma1 > 3) in snd_wss_playback_open()
1486 runtime->hw.formats &= ~SNDRV_PCM_FMTBIT_MU_LAW; in snd_wss_playback_open()
1489 if (chip->hardware == WSS_HW_CS4235 || in snd_wss_playback_open()
1490 chip->hardware == WSS_HW_CS4239) in snd_wss_playback_open()
1491 runtime->hw.formats = SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE; in snd_wss_playback_open()
1493 snd_pcm_limit_isa_dma_size(chip->dma1, &runtime->hw.buffer_bytes_max); in snd_wss_playback_open()
1494 snd_pcm_limit_isa_dma_size(chip->dma1, &runtime->hw.period_bytes_max); in snd_wss_playback_open()
1496 if (chip->claim_dma) { in snd_wss_playback_open()
1497 err = chip->claim_dma(chip, chip->dma_private_data, chip->dma1); in snd_wss_playback_open()
1504 if (chip->release_dma) in snd_wss_playback_open()
1505 chip->release_dma(chip, chip->dma_private_data, chip->dma1); in snd_wss_playback_open()
1508 chip->playback_substream = substream; in snd_wss_playback_open()
1510 chip->rate_constraint(runtime); in snd_wss_playback_open()
1517 struct snd_pcm_runtime *runtime = substream->runtime; in snd_wss_capture_open()
1520 runtime->hw = snd_wss_capture; in snd_wss_capture_open()
1523 if (chip->hardware & WSS_HW_AD1848_MASK) in snd_wss_capture_open()
1524 runtime->hw.formats &= ~(SNDRV_PCM_FMTBIT_IMA_ADPCM | in snd_wss_capture_open()
1528 if (chip->hardware == WSS_HW_CS4235 || in snd_wss_capture_open()
1529 chip->hardware == WSS_HW_CS4239 || in snd_wss_capture_open()
1530 chip->hardware == WSS_HW_OPTI93X) in snd_wss_capture_open()
1531 runtime->hw.formats = SNDRV_PCM_FMTBIT_U8 | in snd_wss_capture_open()
1534 snd_pcm_limit_isa_dma_size(chip->dma2, &runtime->hw.buffer_bytes_max); in snd_wss_capture_open()
1535 snd_pcm_limit_isa_dma_size(chip->dma2, &runtime->hw.period_bytes_max); in snd_wss_capture_open()
1537 if (chip->claim_dma) { in snd_wss_capture_open()
1538 err = chip->claim_dma(chip, chip->dma_private_data, chip->dma2); in snd_wss_capture_open()
1545 if (chip->release_dma) in snd_wss_capture_open()
1546 chip->release_dma(chip, chip->dma_private_data, chip->dma2); in snd_wss_capture_open()
1549 chip->capture_substream = substream; in snd_wss_capture_open()
1551 chip->rate_constraint(runtime); in snd_wss_capture_open()
1559 chip->playback_substream = NULL; in snd_wss_playback_close()
1568 chip->capture_substream = NULL; in snd_wss_capture_close()
1577 if (!chip->thinkpad_flag) in snd_wss_thinkpad_twiddle()
1601 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_suspend()
1603 chip->image[reg] = snd_wss_in(chip, reg); in snd_wss_suspend()
1604 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_suspend()
1605 if (chip->thinkpad_flag) in snd_wss_suspend()
1616 if (chip->thinkpad_flag) in snd_wss_resume()
1619 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_resume()
1625 snd_wss_out(chip, reg, chip->image[reg]); in snd_wss_resume()
1630 if (chip->hardware == WSS_HW_OPL3SA2) in snd_wss_resume()
1632 chip->image[CS4231_PLAYBK_FORMAT]); in snd_wss_resume()
1633 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_resume()
1639 include rescheduling. -- iwai in snd_wss_resume()
1642 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_resume()
1643 chip->mce_bit &= ~CS4231_MCE; in snd_wss_resume()
1645 wss_outb(chip, CS4231P(REGSEL), chip->mce_bit | (timeout & 0x1f)); in snd_wss_resume()
1646 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_resume()
1648 dev_err(chip->card->dev in snd_wss_resume()
1649 "down [0x%lx]: serious init problem - codec still busy\n", in snd_wss_resume()
1650 chip->port); in snd_wss_resume()
1652 !(chip->hardware & (WSS_HW_CS4231_MASK | WSS_HW_CS4232_MASK))) { in snd_wss_resume()
1662 switch (chip->hardware) { in snd_wss_chip_id()
1686 return chip->card->shortname; in snd_wss_chip_id()
1713 chip = devm_kzalloc(card->dev, sizeof(*chip), GFP_KERNEL); in snd_wss_new()
1715 return -ENOMEM; in snd_wss_new()
1716 chip->hardware = hardware; in snd_wss_new()
1717 chip->hwshare = hwshare; in snd_wss_new()
1719 spin_lock_init(&chip->reg_lock); in snd_wss_new()
1720 mutex_init(&chip->mce_mutex); in snd_wss_new()
1721 mutex_init(&chip->open_mutex); in snd_wss_new()
1722 chip->card = card; in snd_wss_new()
1723 chip->rate_constraint = snd_wss_xrate; in snd_wss_new()
1724 chip->set_playback_format = snd_wss_playback_format; in snd_wss_new()
1725 chip->set_capture_format = snd_wss_capture_format; in snd_wss_new()
1726 if (chip->hardware == WSS_HW_OPTI93X) in snd_wss_new()
1727 memcpy(&chip->image, &snd_opti93x_original_image, in snd_wss_new()
1730 memcpy(&chip->image, &snd_wss_original_image, in snd_wss_new()
1732 if (chip->hardware & WSS_HW_AD1848_MASK) { in snd_wss_new()
1733 chip->image[CS4231_PIN_CTRL] = 0; in snd_wss_new()
1734 chip->image[CS4231_TEST_INIT] = 0; in snd_wss_new()
1756 chip->irq = -1; in snd_wss_create()
1757 chip->dma1 = -1; in snd_wss_create()
1758 chip->dma2 = -1; in snd_wss_create()
1760 chip->res_port = devm_request_region(card->dev, port, 4, "WSS"); in snd_wss_create()
1761 if (!chip->res_port) { in snd_wss_create()
1762 dev_err(chip->card->dev, "wss: can't grab port 0x%lx\n", port); in snd_wss_create()
1763 return -EBUSY; in snd_wss_create()
1765 chip->port = port; in snd_wss_create()
1767 chip->res_cport = devm_request_region(card->dev, cport, 8, in snd_wss_create()
1769 if (!chip->res_cport) { in snd_wss_create()
1770 dev_err(chip->card->dev, in snd_wss_create()
1772 return -ENODEV; in snd_wss_create()
1775 chip->cport = cport; in snd_wss_create()
1777 if (devm_request_irq(card->dev, irq, snd_wss_interrupt, 0, in snd_wss_create()
1779 dev_err(chip->card->dev, "wss: can't grab IRQ %d\n", irq); in snd_wss_create()
1780 return -EBUSY; in snd_wss_create()
1782 chip->irq = irq; in snd_wss_create()
1783 card->sync_irq = chip->irq; in snd_wss_create()
1785 snd_devm_request_dma(card->dev, dma1, "WSS - 1")) { in snd_wss_create()
1786 dev_err(chip->card->dev, "wss: can't grab DMA1 %d\n", dma1); in snd_wss_create()
1787 return -EBUSY; in snd_wss_create()
1789 chip->dma1 = dma1; in snd_wss_create()
1791 snd_devm_request_dma(card->dev, dma2, "WSS - 2")) { in snd_wss_create()
1792 dev_err(chip->card->dev, "wss: can't grab DMA2 %d\n", dma2); in snd_wss_create()
1793 return -EBUSY; in snd_wss_create()
1796 chip->single_dma = 1; in snd_wss_create()
1797 chip->dma2 = chip->dma1; in snd_wss_create()
1799 chip->dma2 = dma2; in snd_wss_create()
1802 chip->thinkpad_flag = 1; in snd_wss_create()
1803 chip->hardware = WSS_HW_DETECT; /* reset */ in snd_wss_create()
1809 return -ENODEV; in snd_wss_create()
1813 if (chip->hardware & WSS_HW_CS4232_MASK) { in snd_wss_create()
1814 if (chip->res_cport == NULL) in snd_wss_create()
1815 dev_err(chip->card->dev, in snd_wss_create()
1822 chip->suspend = snd_wss_suspend; in snd_wss_create()
1823 chip->resume = snd_wss_resume; in snd_wss_create()
1854 err = snd_pcm_new(chip->card, "WSS", device, 1, 1, &pcm); in snd_wss_pcm()
1862 pcm->private_data = chip; in snd_wss_pcm()
1863 pcm->info_flags = 0; in snd_wss_pcm()
1864 if (chip->single_dma) in snd_wss_pcm()
1865 pcm->info_flags |= SNDRV_PCM_INFO_HALF_DUPLEX; in snd_wss_pcm()
1866 if (chip->hardware != WSS_HW_INTERWAVE) in snd_wss_pcm()
1867 pcm->info_flags |= SNDRV_PCM_INFO_JOINT_DUPLEX; in snd_wss_pcm()
1868 strcpy(pcm->name, snd_wss_chip_id(chip)); in snd_wss_pcm()
1870 snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, chip->card->dev, in snd_wss_pcm()
1871 64*1024, chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024); in snd_wss_pcm()
1873 chip->pcm = pcm; in snd_wss_pcm()
1880 struct snd_wss *chip = timer->private_data; in snd_wss_timer_free()
1881 chip->timer = NULL; in snd_wss_timer_free()
1893 tid.card = chip->card->number; in snd_wss_timer()
1896 err = snd_timer_new(chip->card, "CS4231", &tid, &timer); in snd_wss_timer()
1899 strcpy(timer->name, snd_wss_chip_id(chip)); in snd_wss_timer()
1900 timer->private_data = chip; in snd_wss_timer()
1901 timer->private_free = snd_wss_timer_free; in snd_wss_timer()
1902 timer->hw = snd_wss_timer_table; in snd_wss_timer()
1903 chip->timer = timer; in snd_wss_timer()
1927 if (snd_BUG_ON(!chip->card)) in snd_wss_info_mux()
1928 return -EINVAL; in snd_wss_info_mux()
1929 if (!strcmp(chip->card->driver, "GUS MAX")) in snd_wss_info_mux()
1931 switch (chip->hardware) { in snd_wss_info_mux()
1949 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_get_mux()
1950 ucontrol->value.enumerated.item[0] = (chip->image[CS4231_LEFT_INPUT] & CS4231_MIXS_ALL) >> 6; in snd_wss_get_mux()
1951 ucontrol->value.enumerated.item[1] = (chip->image[CS4231_RIGHT_INPUT] & CS4231_MIXS_ALL) >> 6; in snd_wss_get_mux()
1952 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_get_mux()
1964 if (ucontrol->value.enumerated.item[0] > 3 || in snd_wss_put_mux()
1965 ucontrol->value.enumerated.item[1] > 3) in snd_wss_put_mux()
1966 return -EINVAL; in snd_wss_put_mux()
1967 left = ucontrol->value.enumerated.item[0] << 6; in snd_wss_put_mux()
1968 right = ucontrol->value.enumerated.item[1] << 6; in snd_wss_put_mux()
1969 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_put_mux()
1970 left = (chip->image[CS4231_LEFT_INPUT] & ~CS4231_MIXS_ALL) | left; in snd_wss_put_mux()
1971 right = (chip->image[CS4231_RIGHT_INPUT] & ~CS4231_MIXS_ALL) | right; in snd_wss_put_mux()
1972 change = left != chip->image[CS4231_LEFT_INPUT] || in snd_wss_put_mux()
1973 right != chip->image[CS4231_RIGHT_INPUT]; in snd_wss_put_mux()
1976 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_put_mux()
1983 int mask = (kcontrol->private_value >> 16) & 0xff; in snd_wss_info_single()
1985 uinfo->type = mask == 1 ? SNDRV_CTL_ELEM_TYPE_BOOLEAN : SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_wss_info_single()
1986 uinfo->count = 1; in snd_wss_info_single()
1987 uinfo->value.integer.min = 0; in snd_wss_info_single()
1988 uinfo->value.integer.max = mask; in snd_wss_info_single()
1998 int reg = kcontrol->private_value & 0xff; in snd_wss_get_single()
1999 int shift = (kcontrol->private_value >> 8) & 0xff; in snd_wss_get_single()
2000 int mask = (kcontrol->private_value >> 16) & 0xff; in snd_wss_get_single()
2001 int invert = (kcontrol->private_value >> 24) & 0xff; in snd_wss_get_single() local
2003 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_get_single()
2004 ucontrol->value.integer.value[0] = (chip->image[reg] >> shift) & mask; in snd_wss_get_single()
2005 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_get_single()
2006 if (invert) in snd_wss_get_single()
2007 ucontrol->value.integer.value[0] = mask - ucontrol->value.integer.value[0]; in snd_wss_get_single()
2017 int reg = kcontrol->private_value & 0xff; in snd_wss_put_single()
2018 int shift = (kcontrol->private_value >> 8) & 0xff; in snd_wss_put_single()
2019 int mask = (kcontrol->private_value >> 16) & 0xff; in snd_wss_put_single()
2020 int invert = (kcontrol->private_value >> 24) & 0xff; in snd_wss_put_single() local
2024 val = (ucontrol->value.integer.value[0] & mask); in snd_wss_put_single()
2025 if (invert) in snd_wss_put_single()
2026 val = mask - val; in snd_wss_put_single()
2028 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_put_single()
2029 val = (chip->image[reg] & ~(mask << shift)) | val; in snd_wss_put_single()
2030 change = val != chip->image[reg]; in snd_wss_put_single()
2032 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_put_single()
2040 int mask = (kcontrol->private_value >> 24) & 0xff; in snd_wss_info_double()
2042 uinfo->type = mask == 1 ? SNDRV_CTL_ELEM_TYPE_BOOLEAN : SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_wss_info_double()
2043 uinfo->count = 2; in snd_wss_info_double()
2044 uinfo->value.integer.min = 0; in snd_wss_info_double()
2045 uinfo->value.integer.max = mask; in snd_wss_info_double()
2055 int left_reg = kcontrol->private_value & 0xff; in snd_wss_get_double()
2056 int right_reg = (kcontrol->private_value >> 8) & 0xff; in snd_wss_get_double()
2057 int shift_left = (kcontrol->private_value >> 16) & 0x07; in snd_wss_get_double()
2058 int shift_right = (kcontrol->private_value >> 19) & 0x07; in snd_wss_get_double()
2059 int mask = (kcontrol->private_value >> 24) & 0xff; in snd_wss_get_double()
2060 int invert = (kcontrol->private_value >> 22) & 1; in snd_wss_get_double() local
2062 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_get_double()
2063 ucontrol->value.integer.value[0] = (chip->image[left_reg] >> shift_left) & mask; in snd_wss_get_double()
2064 ucontrol->value.integer.value[1] = (chip->image[right_reg] >> shift_right) & mask; in snd_wss_get_double()
2065 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_get_double()
2066 if (invert) { in snd_wss_get_double()
2067 ucontrol->value.integer.value[0] = mask - ucontrol->value.integer.value[0]; in snd_wss_get_double()
2068 ucontrol->value.integer.value[1] = mask - ucontrol->value.integer.value[1]; in snd_wss_get_double()
2079 int left_reg = kcontrol->private_value & 0xff; in snd_wss_put_double()
2080 int right_reg = (kcontrol->private_value >> 8) & 0xff; in snd_wss_put_double()
2081 int shift_left = (kcontrol->private_value >> 16) & 0x07; in snd_wss_put_double()
2082 int shift_right = (kcontrol->private_value >> 19) & 0x07; in snd_wss_put_double()
2083 int mask = (kcontrol->private_value >> 24) & 0xff; in snd_wss_put_double()
2084 int invert = (kcontrol->private_value >> 22) & 1; in snd_wss_put_double() local
2088 val1 = ucontrol->value.integer.value[0] & mask; in snd_wss_put_double()
2089 val2 = ucontrol->value.integer.value[1] & mask; in snd_wss_put_double()
2090 if (invert) { in snd_wss_put_double()
2091 val1 = mask - val1; in snd_wss_put_double()
2092 val2 = mask - val2; in snd_wss_put_double()
2096 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_put_double()
2098 val1 = (chip->image[left_reg] & ~(mask << shift_left)) | val1; in snd_wss_put_double()
2099 val2 = (chip->image[right_reg] & ~(mask << shift_right)) | val2; in snd_wss_put_double()
2100 change = val1 != chip->image[left_reg] || in snd_wss_put_double()
2101 val2 != chip->image[right_reg]; in snd_wss_put_double()
2106 val1 = (chip->image[left_reg] & ~mask) | val1 | val2; in snd_wss_put_double()
2107 change = val1 != chip->image[left_reg]; in snd_wss_put_double()
2110 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_put_double()
2115 static const DECLARE_TLV_DB_SCALE(db_scale_6bit, -9450, 150, 0);
2116 static const DECLARE_TLV_DB_SCALE(db_scale_5bit_12db_max, -3450, 150, 0);
2118 static const DECLARE_TLV_DB_SCALE(db_scale_4bit, -4500, 300, 0);
2174 if (snd_BUG_ON(!chip || !chip->pcm)) in snd_wss_mixer()
2175 return -EINVAL; in snd_wss_mixer()
2177 card = chip->card; in snd_wss_mixer()
2179 strcpy(card->mixername, chip->pcm->name); in snd_wss_mixer()
2182 if (chip->hardware & WSS_HW_AD1848_MASK) in snd_wss_mixer()
2185 else if (chip->hardware == WSS_HW_OPTI93X) in snd_wss_mixer()