Lines Matching full:chip
8 * Yamaha OPL3-SA3 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()
190 dev_dbg(chip->card->dev, in snd_wss_out()
194 wss_outb(chip, CS4231P(REGSEL), chip->mce_bit | reg); in snd_wss_out()
195 wss_outb(chip, CS4231P(REG), value); 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()
203 unsigned char snd_wss_in(struct snd_wss *chip, unsigned char reg) in snd_wss_in() argument
205 snd_wss_wait(chip); in snd_wss_in()
207 if (wss_inb(chip, CS4231P(REGSEL)) & CS4231_INIT) in snd_wss_in()
208 dev_dbg(chip->card->dev, in snd_wss_in()
211 wss_outb(chip, CS4231P(REGSEL), chip->mce_bit | reg); in snd_wss_in()
213 return wss_inb(chip, CS4231P(REG)); in snd_wss_in()
217 void snd_cs4236_ext_out(struct snd_wss *chip, unsigned char reg, in snd_cs4236_ext_out() argument
220 wss_outb(chip, CS4231P(REGSEL), chip->mce_bit | 0x17); in snd_cs4236_ext_out()
221 wss_outb(chip, CS4231P(REG), in snd_cs4236_ext_out()
222 reg | (chip->image[CS4236_EXT_REG] & 0x01)); in snd_cs4236_ext_out()
223 wss_outb(chip, CS4231P(REG), val); 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()
231 unsigned char snd_cs4236_ext_in(struct snd_wss *chip, unsigned char reg) in snd_cs4236_ext_in() argument
233 wss_outb(chip, CS4231P(REGSEL), chip->mce_bit | 0x17); in snd_cs4236_ext_in()
234 wss_outb(chip, CS4231P(REG), in snd_cs4236_ext_in()
235 reg | (chip->image[CS4236_EXT_REG] & 0x01)); in snd_cs4236_ext_in()
237 return wss_inb(chip, CS4231P(REG)); in snd_cs4236_ext_in()
241 res = wss_inb(chip, CS4231P(REG)); 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()
252 static void snd_wss_debug(struct snd_wss *chip)
254 dev_dbg(chip->card->dev,
257 wss_inb(chip, CS4231P(REGSEL)),
258 wss_inb(chip, CS4231P(STATUS)));
259 dev_dbg(chip->card->dev,
262 snd_wss_in(chip, 0x00),
263 snd_wss_in(chip, 0x10));
264 dev_dbg(chip->card->dev,
267 snd_wss_in(chip, 0x01),
268 snd_wss_in(chip, 0x11));
269 dev_dbg(chip->card->dev,
272 snd_wss_in(chip, 0x02),
273 snd_wss_in(chip, 0x12));
274 dev_dbg(chip->card->dev,
277 snd_wss_in(chip, 0x03),
278 snd_wss_in(chip, 0x13));
279 dev_dbg(chip->card->dev,
282 snd_wss_in(chip, 0x04),
283 snd_wss_in(chip, 0x14));
284 dev_dbg(chip->card->dev,
287 snd_wss_in(chip, 0x05),
288 snd_wss_in(chip, 0x15));
289 dev_dbg(chip->card->dev,
292 snd_wss_in(chip, 0x06),
293 snd_wss_in(chip, 0x16));
294 dev_dbg(chip->card->dev,
297 snd_wss_in(chip, 0x07),
298 snd_wss_in(chip, 0x17));
299 dev_dbg(chip->card->dev,
302 snd_wss_in(chip, 0x08),
303 snd_wss_in(chip, 0x18));
304 dev_dbg(chip->card->dev,
307 snd_wss_in(chip, 0x09),
308 snd_wss_in(chip, 0x19));
309 dev_dbg(chip->card->dev,
312 snd_wss_in(chip, 0x0a),
313 snd_wss_in(chip, 0x1a));
314 dev_dbg(chip->card->dev,
317 snd_wss_in(chip, 0x0b),
318 snd_wss_in(chip, 0x1b));
319 dev_dbg(chip->card->dev,
322 snd_wss_in(chip, 0x0c),
323 snd_wss_in(chip, 0x1c));
324 dev_dbg(chip->card->dev,
327 snd_wss_in(chip, 0x0d),
328 snd_wss_in(chip, 0x1d));
329 dev_dbg(chip->card->dev,
332 snd_wss_in(chip, 0x0e),
333 snd_wss_in(chip, 0x1e));
334 dev_dbg(chip->card->dev,
337 snd_wss_in(chip, 0x0f),
338 snd_wss_in(chip, 0x1f));
347 static void snd_wss_busy_wait(struct snd_wss *chip) in snd_wss_busy_wait() argument
351 /* huh.. looks like this sequence is proper for CS4231A chip (GUS MAX) */ in snd_wss_busy_wait()
353 wss_inb(chip, CS4231P(REGSEL)); in snd_wss_busy_wait()
356 timeout > 0 && (wss_inb(chip, CS4231P(REGSEL)) & CS4231_INIT); in snd_wss_busy_wait()
361 void snd_wss_mce_up(struct snd_wss *chip) in snd_wss_mce_up() argument
366 snd_wss_wait(chip); in snd_wss_mce_up()
368 if (wss_inb(chip, CS4231P(REGSEL)) & CS4231_INIT) in snd_wss_mce_up()
369 dev_dbg(chip->card->dev, 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()
374 timeout = wss_inb(chip, CS4231P(REGSEL)); in snd_wss_mce_up()
376 dev_dbg(chip->card->dev, in snd_wss_mce_up()
378 chip->port); in snd_wss_mce_up()
380 wss_outb(chip, CS4231P(REGSEL), 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()
386 void snd_wss_mce_down(struct snd_wss *chip) in snd_wss_mce_down() argument
393 snd_wss_busy_wait(chip); in snd_wss_mce_down()
396 if (wss_inb(chip, CS4231P(REGSEL)) & CS4231_INIT) in snd_wss_mce_down()
397 dev_dbg(chip->card->dev, 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()
403 timeout = wss_inb(chip, CS4231P(REGSEL)); 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()
409 chip->port); in snd_wss_mce_down()
410 if ((timeout & CS4231_MCE) == 0 || !(chip->hardware & hw_mask)) in snd_wss_mce_down()
420 dev_dbg(chip->card->dev, "(1) jiffies = %lu\n", jiffies); in snd_wss_mce_down()
424 while (snd_wss_in(chip, CS4231_TEST_INIT) & in snd_wss_mce_down()
428 dev_err(chip->card->dev, in snd_wss_mce_down()
435 dev_dbg(chip->card->dev, "(2) jiffies = %lu\n", jiffies); in snd_wss_mce_down()
439 while (wss_inb(chip, CS4231P(REGSEL)) & CS4231_INIT) { in snd_wss_mce_down()
441 dev_err(chip->card->dev, 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()
450 wss_inb(chip, CS4231P(REGSEL))); in snd_wss_mce_down()
472 struct snd_wss *chip = snd_pcm_substream_chip(substream); in snd_wss_trigger() local
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()
512 snd_wss_debug(chip); in snd_wss_trigger()
532 static unsigned char snd_wss_get_format(struct snd_wss *chip, in snd_wss_get_format() argument
549 dev_dbg(chip->card->dev, "get_format: 0x%x (mode=0x%x)\n", format, mode); in snd_wss_get_format()
554 static void snd_wss_calibrate_mute(struct snd_wss *chip, int mute) in snd_wss_calibrate_mute() argument
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()
565 snd_wss_dout(chip, CS4231_LEFT_INPUT, in snd_wss_calibrate_mute()
566 chip->image[CS4231_LEFT_INPUT]); in snd_wss_calibrate_mute()
567 snd_wss_dout(chip, CS4231_RIGHT_INPUT, in snd_wss_calibrate_mute()
568 chip->image[CS4231_RIGHT_INPUT]); in snd_wss_calibrate_mute()
569 snd_wss_dout(chip, CS4231_LOOPBACK, in snd_wss_calibrate_mute()
570 chip->image[CS4231_LOOPBACK]); in snd_wss_calibrate_mute()
572 snd_wss_dout(chip, CS4231_LEFT_INPUT, in snd_wss_calibrate_mute()
574 snd_wss_dout(chip, CS4231_RIGHT_INPUT, in snd_wss_calibrate_mute()
576 snd_wss_dout(chip, CS4231_LOOPBACK, in snd_wss_calibrate_mute()
580 snd_wss_dout(chip, CS4231_AUX1_LEFT_INPUT, in snd_wss_calibrate_mute()
581 mute | chip->image[CS4231_AUX1_LEFT_INPUT]); in snd_wss_calibrate_mute()
582 snd_wss_dout(chip, CS4231_AUX1_RIGHT_INPUT, in snd_wss_calibrate_mute()
583 mute | chip->image[CS4231_AUX1_RIGHT_INPUT]); in snd_wss_calibrate_mute()
584 snd_wss_dout(chip, CS4231_AUX2_LEFT_INPUT, in snd_wss_calibrate_mute()
585 mute | chip->image[CS4231_AUX2_LEFT_INPUT]); in snd_wss_calibrate_mute()
586 snd_wss_dout(chip, CS4231_AUX2_RIGHT_INPUT, in snd_wss_calibrate_mute()
587 mute | chip->image[CS4231_AUX2_RIGHT_INPUT]); in snd_wss_calibrate_mute()
588 snd_wss_dout(chip, CS4231_LEFT_OUTPUT, in snd_wss_calibrate_mute()
589 mute | chip->image[CS4231_LEFT_OUTPUT]); in snd_wss_calibrate_mute()
590 snd_wss_dout(chip, CS4231_RIGHT_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()
593 snd_wss_dout(chip, CS4231_LEFT_LINE_IN, in snd_wss_calibrate_mute()
594 mute | chip->image[CS4231_LEFT_LINE_IN]); in snd_wss_calibrate_mute()
595 snd_wss_dout(chip, CS4231_RIGHT_LINE_IN, in snd_wss_calibrate_mute()
596 mute | chip->image[CS4231_RIGHT_LINE_IN]); in snd_wss_calibrate_mute()
597 snd_wss_dout(chip, CS4231_MONO_CTRL, 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()
601 snd_wss_dout(chip, CS4231_LEFT_MIC_INPUT, in snd_wss_calibrate_mute()
602 mute | chip->image[CS4231_LEFT_MIC_INPUT]); in snd_wss_calibrate_mute()
603 snd_wss_dout(chip, CS4231_RIGHT_MIC_INPUT, in snd_wss_calibrate_mute()
604 mute | chip->image[CS4231_RIGHT_MIC_INPUT]); in snd_wss_calibrate_mute()
605 snd_wss_dout(chip, CS4231_LINE_LEFT_OUTPUT, in snd_wss_calibrate_mute()
606 mute | chip->image[CS4231_LINE_LEFT_OUTPUT]); in snd_wss_calibrate_mute()
607 snd_wss_dout(chip, CS4231_LINE_RIGHT_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()
614 static void snd_wss_playback_format(struct snd_wss *chip, in snd_wss_playback_format() argument
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()
626 snd_wss_out(chip, CS4231_ALT_FEATURE_1, 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()
629 snd_wss_out(chip, CS4231_PLAYBK_FORMAT, in snd_wss_playback_format()
630 chip->image[CS4231_PLAYBK_FORMAT]); in snd_wss_playback_format()
631 snd_wss_out(chip, CS4231_ALT_FEATURE_1, 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()
650 snd_wss_out(chip, CS4231_PLAYBK_FORMAT, (pdfr & 0xf0)); in snd_wss_playback_format()
651 snd_wss_out(chip, AD1845_UPR_FREQ_SEL, (rate >> 8) & 0xff); in snd_wss_playback_format()
652 snd_wss_out(chip, AD1845_LWR_FREQ_SEL, rate & 0xff); in snd_wss_playback_format()
654 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_playback_format()
657 snd_wss_mce_up(chip); 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()
666 snd_wss_out(chip, 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()
670 snd_wss_mce_down(chip); in snd_wss_playback_format()
672 mutex_unlock(&chip->mce_mutex); in snd_wss_playback_format()
675 static void snd_wss_capture_format(struct snd_wss *chip, in snd_wss_capture_format() argument
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()
688 snd_wss_out(chip, CS4231_ALT_FEATURE_1, in snd_wss_capture_format()
689 chip->image[CS4231_ALT_FEATURE_1] | 0x20); in snd_wss_capture_format()
690 snd_wss_out(chip, CS4231_REC_FORMAT, in snd_wss_capture_format()
691 chip->image[CS4231_REC_FORMAT] = cdfr); in snd_wss_capture_format()
692 snd_wss_out(chip, CS4231_ALT_FEATURE_1, 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()
710 snd_wss_out(chip, CS4231_REC_FORMAT, (cdfr & 0xf0)); in snd_wss_capture_format()
711 snd_wss_out(chip, AD1845_UPR_FREQ_SEL, (rate >> 8) & 0xff); in snd_wss_capture_format()
712 snd_wss_out(chip, AD1845_LWR_FREQ_SEL, rate & 0xff); in snd_wss_capture_format()
714 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_capture_format()
717 snd_wss_mce_up(chip); 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()
722 snd_wss_out(chip, CS4231_PLAYBK_FORMAT, cdfr); in snd_wss_capture_format()
724 snd_wss_out(chip, CS4231_PLAYBK_FORMAT, 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()
728 snd_wss_mce_down(chip); in snd_wss_capture_format()
729 snd_wss_mce_up(chip); 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()
733 snd_wss_out(chip, CS4231_PLAYBK_FORMAT, cdfr); in snd_wss_capture_format()
735 snd_wss_out(chip, CS4231_REC_FORMAT, cdfr); in snd_wss_capture_format()
736 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_capture_format()
737 snd_wss_mce_down(chip); in snd_wss_capture_format()
739 mutex_unlock(&chip->mce_mutex); in snd_wss_capture_format()
748 struct snd_wss *chip = snd_timer_chip(timer); in snd_wss_timer_resolution() local
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()
759 struct snd_wss *chip = snd_timer_chip(timer); in snd_wss_timer_start() local
760 spin_lock_irqsave(&chip->reg_lock, flags); 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()
766 snd_wss_out(chip, CS4231_TIMER_HIGH, 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()
769 snd_wss_out(chip, CS4231_TIMER_LOW, in snd_wss_timer_start()
770 chip->image[CS4231_TIMER_LOW]); in snd_wss_timer_start()
771 snd_wss_out(chip, CS4231_ALT_FEATURE_1, 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()
782 struct snd_wss *chip = snd_timer_chip(timer); in snd_wss_timer_stop() local
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()
785 snd_wss_out(chip, CS4231_ALT_FEATURE_1, 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()
791 static void snd_wss_init(struct snd_wss *chip) in snd_wss_init() argument
795 snd_wss_calibrate_mute(chip, 1); in snd_wss_init()
796 snd_wss_mce_down(chip); in snd_wss_init()
799 dev_dbg(chip->card->dev, "init: (1)\n"); in snd_wss_init()
801 snd_wss_mce_up(chip); 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()
811 snd_wss_mce_down(chip); in snd_wss_init()
814 dev_dbg(chip->card->dev, "init: (2)\n"); in snd_wss_init()
817 snd_wss_mce_up(chip); 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()
821 snd_wss_out(chip, 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()
824 snd_wss_mce_down(chip); 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()
832 snd_wss_out(chip, CS4231_ALT_FEATURE_2, 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()
836 snd_wss_mce_up(chip); in snd_wss_init()
837 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_init()
838 snd_wss_out(chip, CS4231_PLAYBK_FORMAT, 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()
841 snd_wss_mce_down(chip); in snd_wss_init()
844 dev_dbg(chip->card->dev, "init: (4)\n"); in snd_wss_init()
847 snd_wss_mce_up(chip); 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()
850 snd_wss_out(chip, CS4231_REC_FORMAT, 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()
853 snd_wss_mce_down(chip); in snd_wss_init()
854 snd_wss_calibrate_mute(chip, 0); in snd_wss_init()
857 dev_dbg(chip->card->dev, "init: (5)\n"); in snd_wss_init()
861 static int snd_wss_open(struct snd_wss *chip, unsigned int mode) in snd_wss_open() argument
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()
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()
879 snd_wss_out(chip, CS4231_IRQ_STATUS, in snd_wss_open()
883 snd_wss_out(chip, CS4231_IRQ_STATUS, 0); in snd_wss_open()
885 wss_outb(chip, CS4231P(STATUS), 0); /* clear IRQ */ in snd_wss_open()
886 wss_outb(chip, CS4231P(STATUS), 0); /* clear IRQ */ 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()
890 snd_wss_out(chip, CS4231_IRQ_STATUS, in snd_wss_open()
894 snd_wss_out(chip, CS4231_IRQ_STATUS, 0); 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()
903 static void snd_wss_close(struct snd_wss *chip, unsigned int mode) in snd_wss_close() argument
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()
916 snd_wss_out(chip, CS4231_IRQ_STATUS, 0); in snd_wss_close()
917 wss_outb(chip, CS4231P(STATUS), 0); /* clear IRQ */ in snd_wss_close()
918 wss_outb(chip, CS4231P(STATUS), 0); /* clear IRQ */ 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()
927 snd_wss_mce_up(chip); 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()
931 snd_wss_out(chip, CS4231_IFACE_CTRL, 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()
934 snd_wss_mce_down(chip); 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()
940 snd_wss_out(chip, CS4231_IRQ_STATUS, 0); in snd_wss_close()
941 wss_outb(chip, CS4231P(STATUS), 0); /* clear IRQ */ in snd_wss_close()
942 wss_outb(chip, CS4231P(STATUS), 0); /* clear IRQ */ 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()
955 struct snd_wss *chip = snd_timer_chip(timer); in snd_wss_timer_open() local
956 snd_wss_open(chip, WSS_MODE_TIMER); in snd_wss_timer_open()
962 struct snd_wss *chip = snd_timer_chip(timer); in snd_wss_timer_close() local
963 snd_wss_close(chip, WSS_MODE_TIMER); in snd_wss_timer_close()
986 struct snd_wss *chip = snd_pcm_substream_chip(substream); in snd_wss_playback_hw_params() local
989 new_pdfr = snd_wss_get_format(chip, params_format(hw_params), in snd_wss_playback_hw_params()
992 chip->set_playback_format(chip, hw_params, new_pdfr); in snd_wss_playback_hw_params()
998 struct snd_wss *chip = snd_pcm_substream_chip(substream); in snd_wss_playback_prepare() local
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()
1009 snd_wss_out(chip, CS4231_PLY_LWR_CNT, (unsigned char) count); in snd_wss_playback_prepare()
1010 snd_wss_out(chip, CS4231_PLY_UPR_CNT, (unsigned char) (count >> 8)); in snd_wss_playback_prepare()
1011 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_playback_prepare()
1013 snd_wss_debug(chip); in snd_wss_playback_prepare()
1021 struct snd_wss *chip = snd_pcm_substream_chip(substream); in snd_wss_capture_hw_params() local
1024 new_cdfr = snd_wss_get_format(chip, params_format(hw_params), in snd_wss_capture_hw_params()
1027 chip->set_capture_format(chip, hw_params, new_cdfr); in snd_wss_capture_hw_params()
1033 struct snd_wss *chip = snd_pcm_substream_chip(substream); in snd_wss_capture_prepare() local
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()
1050 if (chip->single_dma && chip->hardware != WSS_HW_INTERWAVE) { in snd_wss_capture_prepare()
1051 snd_wss_out(chip, CS4231_PLY_LWR_CNT, (unsigned char) count); in snd_wss_capture_prepare()
1052 snd_wss_out(chip, CS4231_PLY_UPR_CNT, in snd_wss_capture_prepare()
1055 snd_wss_out(chip, CS4231_REC_LWR_CNT, (unsigned char) count); in snd_wss_capture_prepare()
1056 snd_wss_out(chip, CS4231_REC_UPR_CNT, in snd_wss_capture_prepare()
1059 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_capture_prepare()
1063 void snd_wss_overrange(struct snd_wss *chip) in snd_wss_overrange() argument
1068 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_overrange()
1069 res = snd_wss_in(chip, CS4231_TEST_INIT); 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()
1078 struct snd_wss *chip = dev_id; in snd_wss_interrupt() local
1081 if (chip->hardware & WSS_HW_AD1848_MASK) in snd_wss_interrupt()
1085 status = snd_wss_in(chip, CS4231_IRQ_STATUS); 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()
1098 snd_wss_overrange(chip); 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()
1110 snd_wss_overrange(chip); 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()
1119 wss_outb(chip, CS4231P(STATUS), 0); in snd_wss_interrupt()
1121 snd_wss_out(chip, CS4231_IRQ_STATUS, status); in snd_wss_interrupt()
1122 spin_unlock(&chip->reg_lock); in snd_wss_interrupt()
1129 struct snd_wss *chip = snd_pcm_substream_chip(substream); in snd_wss_playback_pointer() local
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()
1140 struct snd_wss *chip = snd_pcm_substream_chip(substream); in snd_wss_capture_pointer() local
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()
1153 static int snd_ad1848_probe(struct snd_wss *chip) in snd_ad1848_probe() argument
1162 while (wss_inb(chip, CS4231P(REGSEL)) & CS4231_INIT) { in snd_ad1848_probe()
1167 spin_lock_irqsave(&chip->reg_lock, flags); in snd_ad1848_probe()
1170 snd_wss_dout(chip, CS4231_MISC_INFO, 0); in snd_ad1848_probe()
1172 snd_wss_dout(chip, CS4231_RIGHT_INPUT, 0x45); /* 0x55 & ~0x10 */ in snd_ad1848_probe()
1173 r = snd_wss_in(chip, CS4231_RIGHT_INPUT); in snd_ad1848_probe()
1182 snd_wss_dout(chip, CS4231_LEFT_INPUT, 0xaa); in snd_ad1848_probe()
1183 r = snd_wss_in(chip, CS4231_LEFT_INPUT); in snd_ad1848_probe()
1192 wss_inb(chip, CS4231P(STATUS)); in snd_ad1848_probe()
1193 wss_outb(chip, CS4231P(STATUS), 0); 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()
1204 r = snd_wss_in(chip, CS4231_MISC_INFO); in snd_ad1848_probe()
1207 snd_wss_dout(chip, CS4231_MISC_INFO, CS4231_MODE2); in snd_ad1848_probe()
1209 if (snd_wss_in(chip, i) != snd_wss_in(chip, 16 + i)) { in snd_ad1848_probe()
1217 snd_wss_dout(chip, CS4231_VERSION, 0); in snd_ad1848_probe()
1218 r = snd_wss_in(chip, CS4231_VERSION) & 0xe7; 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()
1229 snd_wss_dout(chip, CS4231_MISC_INFO, 0); in snd_ad1848_probe()
1231 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_ad1848_probe()
1235 static int snd_wss_probe(struct snd_wss *chip) in snd_wss_probe() argument
1242 id = snd_ad1848_probe(chip); in snd_wss_probe()
1246 hw = chip->hardware; in snd_wss_probe()
1250 if (wss_inb(chip, CS4231P(REGSEL)) & CS4231_INIT) in snd_wss_probe()
1253 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_probe()
1254 snd_wss_out(chip, CS4231_MISC_INFO, in snd_wss_probe()
1256 id = snd_wss_in(chip, CS4231_MISC_INFO) & 0x0f; 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()
1267 rev = snd_wss_in(chip, CS4231_VERSION) & 0xe7; in snd_wss_probe()
1268 dev_dbg(chip->card->dev, "CS4231: VERSION (I25) = 0x%x\n", rev); in snd_wss_probe()
1270 unsigned char tmp = snd_wss_in(chip, 23); in snd_wss_probe()
1271 snd_wss_out(chip, 23, ~tmp); in snd_wss_probe()
1272 if (snd_wss_in(chip, 23) != tmp) 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()
1288 "unknown CS chip with version 0x%x\n", rev); 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()
1293 wss_inb(chip, CS4231P(STATUS)); /* clear any pendings IRQ */ in snd_wss_probe()
1294 wss_outb(chip, CS4231P(STATUS), 0); 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()
1330 snd_wss_mce_down(chip); in snd_wss_probe()
1331 spin_lock_irqsave(&chip->reg_lock, flags); in snd_wss_probe()
1333 snd_wss_out(chip, i, *ptr++); in snd_wss_probe()
1334 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_probe()
1335 snd_wss_mce_up(chip); in snd_wss_probe()
1336 snd_wss_mce_down(chip); in snd_wss_probe()
1342 if (chip->hardware == WSS_HW_CS4236B) { in snd_wss_probe()
1343 rev = snd_cs4236_ext_in(chip, CS4236_VERSION); in snd_wss_probe()
1344 snd_cs4236_ext_out(chip, CS4236_VERSION, 0xff); in snd_wss_probe()
1345 id = snd_cs4236_ext_in(chip, CS4236_VERSION); in snd_wss_probe()
1346 snd_cs4236_ext_out(chip, CS4236_VERSION, rev); in snd_wss_probe()
1347 dev_dbg(chip->card->dev, in snd_wss_probe()
1351 chip->hardware = WSS_HW_CS4235; in snd_wss_probe()
1358 dev_warn(chip->card->dev, in snd_wss_probe()
1359 "unknown CS4235 chip (enhanced version = 0x%x)\n", in snd_wss_probe()
1368 chip->hardware = WSS_HW_CS4236B; in snd_wss_probe()
1371 dev_warn(chip->card->dev, in snd_wss_probe()
1372 "unknown CS4236 chip (enhanced version = 0x%x)\n", in snd_wss_probe()
1376 chip->hardware = WSS_HW_CS4237B; in snd_wss_probe()
1384 dev_warn(chip->card->dev, in snd_wss_probe()
1385 "unknown CS4237B chip (enhanced version = 0x%x)\n", in snd_wss_probe()
1389 chip->hardware = WSS_HW_CS4238B; in snd_wss_probe()
1396 dev_warn(chip->card->dev, in snd_wss_probe()
1397 "unknown CS4238B chip (enhanced version = 0x%x)\n", in snd_wss_probe()
1401 chip->hardware = WSS_HW_CS4239; in snd_wss_probe()
1408 dev_warn(chip->card->dev, in snd_wss_probe()
1409 "unknown CS4239 chip (enhanced version = 0x%x)\n", in snd_wss_probe()
1413 dev_warn(chip->card->dev, in snd_wss_probe()
1414 "unknown CS4236/CS423xB chip (enhanced version = 0x%x)\n", in snd_wss_probe()
1473 struct snd_wss *chip = snd_pcm_substream_chip(substream); in snd_wss_playback_open() local
1480 if (chip->hardware & WSS_HW_AD1848_MASK) in snd_wss_playback_open()
1485 if (chip->hardware == WSS_HW_INTERWAVE && chip->dma1 > 3) 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()
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()
1502 err = snd_wss_open(chip, WSS_MODE_PLAY); 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()
1516 struct snd_wss *chip = snd_pcm_substream_chip(substream); in snd_wss_capture_open() local
1523 if (chip->hardware & WSS_HW_AD1848_MASK) 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()
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()
1543 err = snd_wss_open(chip, WSS_MODE_RECORD); 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()
1557 struct snd_wss *chip = snd_pcm_substream_chip(substream); in snd_wss_playback_close() local
1559 chip->playback_substream = NULL; in snd_wss_playback_close()
1560 snd_wss_close(chip, WSS_MODE_PLAY); in snd_wss_playback_close()
1566 struct snd_wss *chip = snd_pcm_substream_chip(substream); in snd_wss_capture_close() local
1568 chip->capture_substream = NULL; in snd_wss_capture_close()
1569 snd_wss_close(chip, WSS_MODE_RECORD); in snd_wss_capture_close()
1573 static void snd_wss_thinkpad_twiddle(struct snd_wss *chip, int on) in snd_wss_thinkpad_twiddle() argument
1577 if (!chip->thinkpad_flag) in snd_wss_thinkpad_twiddle()
1596 static void snd_wss_suspend(struct snd_wss *chip) in snd_wss_suspend() argument
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()
1606 snd_wss_thinkpad_twiddle(chip, 0); in snd_wss_suspend()
1610 static void snd_wss_resume(struct snd_wss *chip) in snd_wss_resume() argument
1616 if (chip->thinkpad_flag) in snd_wss_resume()
1617 snd_wss_thinkpad_twiddle(chip, 1); in snd_wss_resume()
1618 snd_wss_mce_up(chip); 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()
1631 snd_wss_out(chip, CS4231_PLAYBK_FORMAT, 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()
1635 snd_wss_mce_down(chip); in snd_wss_resume()
1641 snd_wss_busy_wait(chip); 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()
1644 timeout = wss_inb(chip, CS4231P(REGSEL)); 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()
1650 chip->port); in snd_wss_resume()
1652 !(chip->hardware & (WSS_HW_CS4231_MASK | WSS_HW_CS4232_MASK))) { in snd_wss_resume()
1655 snd_wss_busy_wait(chip); in snd_wss_resume()
1660 const char *snd_wss_chip_id(struct snd_wss *chip) in snd_wss_chip_id() argument
1662 switch (chip->hardware) { in snd_wss_chip_id()
1686 return chip->card->shortname; in snd_wss_chip_id()
1710 struct snd_wss *chip; in snd_wss_new() local
1713 chip = devm_kzalloc(card->dev, sizeof(*chip), GFP_KERNEL); in snd_wss_new()
1714 if (chip == NULL) 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()
1737 *rchip = chip; in snd_wss_new()
1749 struct snd_wss *chip; in snd_wss_create() local
1752 err = snd_wss_new(card, hardware, hwshare, &chip); in snd_wss_create()
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()
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()
1775 chip->cport = cport; in snd_wss_create()
1778 "WSS", (void *) chip)) { in snd_wss_create()
1779 dev_err(chip->card->dev, "wss: can't grab IRQ %d\n", irq); in snd_wss_create()
1782 chip->irq = irq; in snd_wss_create()
1783 card->sync_irq = chip->irq; in snd_wss_create()
1786 dev_err(chip->card->dev, "wss: can't grab DMA1 %d\n", dma1); in snd_wss_create()
1789 chip->dma1 = dma1; in snd_wss_create()
1792 dev_err(chip->card->dev, "wss: can't grab DMA2 %d\n", dma2); 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()
1804 snd_wss_thinkpad_twiddle(chip, 1); in snd_wss_create()
1808 if (snd_wss_probe(chip) < 0) in snd_wss_create()
1810 snd_wss_init(chip); 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()
1826 *rchip = chip; in snd_wss_create()
1849 int snd_wss_pcm(struct snd_wss *chip, int device) in snd_wss_pcm() argument
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()
1864 if (chip->single_dma) in snd_wss_pcm()
1866 if (chip->hardware != WSS_HW_INTERWAVE) 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() local
1881 chip->timer = NULL; in snd_wss_timer_free()
1884 int snd_wss_timer(struct snd_wss *chip, int device) in snd_wss_timer() argument
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()
1903 chip->timer = timer; in snd_wss_timer()
1925 struct snd_wss *chip = snd_kcontrol_chip(kcontrol); in snd_wss_info_mux() local
1927 if (snd_BUG_ON(!chip->card)) 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()
1946 struct snd_wss *chip = snd_kcontrol_chip(kcontrol); in snd_wss_get_mux() local
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()
1959 struct snd_wss *chip = snd_kcontrol_chip(kcontrol); in snd_wss_put_mux() local
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()
1974 snd_wss_out(chip, CS4231_LEFT_INPUT, left); in snd_wss_put_mux()
1975 snd_wss_out(chip, CS4231_RIGHT_INPUT, right); in snd_wss_put_mux()
1976 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_put_mux()
1996 struct snd_wss *chip = snd_kcontrol_chip(kcontrol); 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()
2015 struct snd_wss *chip = snd_kcontrol_chip(kcontrol); in snd_wss_put_single() local
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()
2031 snd_wss_out(chip, reg, val); in snd_wss_put_single()
2032 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_put_single()
2053 struct snd_wss *chip = snd_kcontrol_chip(kcontrol); 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()
2077 struct snd_wss *chip = snd_kcontrol_chip(kcontrol); in snd_wss_put_double() local
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()
2102 snd_wss_out(chip, left_reg, val1); in snd_wss_put_double()
2103 snd_wss_out(chip, right_reg, val2); 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()
2108 snd_wss_out(chip, left_reg, val1); in snd_wss_put_double()
2110 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_wss_put_double()
2167 int snd_wss_mixer(struct snd_wss *chip) in snd_wss_mixer() argument
2174 if (snd_BUG_ON(!chip || !chip->pcm)) 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()
2191 chip)); in snd_wss_mixer()