• Home
  • Raw
  • Download

Lines Matching refs:cm

501 static inline void snd_cmipci_write(struct cmipci *cm, unsigned int cmd, unsigned int data)  in snd_cmipci_write()  argument
503 outl(data, cm->iobase + cmd); in snd_cmipci_write()
506 static inline unsigned int snd_cmipci_read(struct cmipci *cm, unsigned int cmd) in snd_cmipci_read() argument
508 return inl(cm->iobase + cmd); in snd_cmipci_read()
512 static inline void snd_cmipci_write_w(struct cmipci *cm, unsigned int cmd, unsigned short data) in snd_cmipci_write_w() argument
514 outw(data, cm->iobase + cmd); in snd_cmipci_write_w()
517 static inline unsigned short snd_cmipci_read_w(struct cmipci *cm, unsigned int cmd) in snd_cmipci_read_w() argument
519 return inw(cm->iobase + cmd); in snd_cmipci_read_w()
523 static inline void snd_cmipci_write_b(struct cmipci *cm, unsigned int cmd, unsigned char data) in snd_cmipci_write_b() argument
525 outb(data, cm->iobase + cmd); in snd_cmipci_write_b()
528 static inline unsigned char snd_cmipci_read_b(struct cmipci *cm, unsigned int cmd) in snd_cmipci_read_b() argument
530 return inb(cm->iobase + cmd); in snd_cmipci_read_b()
534 static int snd_cmipci_set_bit(struct cmipci *cm, unsigned int cmd, unsigned int flag) in snd_cmipci_set_bit() argument
537 val = oval = inl(cm->iobase + cmd); in snd_cmipci_set_bit()
541 outl(val, cm->iobase + cmd); in snd_cmipci_set_bit()
545 static int snd_cmipci_clear_bit(struct cmipci *cm, unsigned int cmd, unsigned int flag) in snd_cmipci_clear_bit() argument
548 val = oval = inl(cm->iobase + cmd); in snd_cmipci_clear_bit()
552 outl(val, cm->iobase + cmd); in snd_cmipci_clear_bit()
557 static int snd_cmipci_set_bit_b(struct cmipci *cm, unsigned int cmd, unsigned char flag) in snd_cmipci_set_bit_b() argument
560 val = oval = inb(cm->iobase + cmd); in snd_cmipci_set_bit_b()
564 outb(val, cm->iobase + cmd); in snd_cmipci_set_bit_b()
568 static int snd_cmipci_clear_bit_b(struct cmipci *cm, unsigned int cmd, unsigned char flag) in snd_cmipci_clear_bit_b() argument
571 val = oval = inb(cm->iobase + cmd); in snd_cmipci_clear_bit_b()
575 outb(val, cm->iobase + cmd); in snd_cmipci_clear_bit_b()
650 static void snd_cmipci_set_pll(struct cmipci *cm, unsigned int rate, unsigned int slot) in snd_cmipci_set_pll() argument
661 snd_cmipci_write_b(cm, reg, rate>>8); in snd_cmipci_set_pll()
662 snd_cmipci_write_b(cm, reg, rate&0xff); in snd_cmipci_set_pll()
677 struct cmipci *cm = snd_pcm_substream_chip(substream); in snd_cmipci_playback2_hw_params() local
679 mutex_lock(&cm->open_mutex); in snd_cmipci_playback2_hw_params()
680 if (cm->opened[CM_CH_PLAY]) { in snd_cmipci_playback2_hw_params()
681 mutex_unlock(&cm->open_mutex); in snd_cmipci_playback2_hw_params()
685 cm->opened[CM_CH_PLAY] = CM_OPEN_PLAYBACK_MULTI; in snd_cmipci_playback2_hw_params()
686 mutex_unlock(&cm->open_mutex); in snd_cmipci_playback2_hw_params()
691 static void snd_cmipci_ch_reset(struct cmipci *cm, int ch) in snd_cmipci_ch_reset() argument
693 int reset = CM_RST_CH0 << (cm->channel[ch].ch); in snd_cmipci_ch_reset()
694 snd_cmipci_write(cm, CM_REG_FUNCTRL0, cm->ctrl | reset); in snd_cmipci_ch_reset()
695 snd_cmipci_write(cm, CM_REG_FUNCTRL0, cm->ctrl & ~reset); in snd_cmipci_ch_reset()
725 static int set_dac_channels(struct cmipci *cm, struct cmipci_pcm *rec, int channels) in set_dac_channels() argument
728 if (!cm->can_multi_ch || !rec->ch) in set_dac_channels()
734 if (cm->can_multi_ch) { in set_dac_channels()
735 spin_lock_irq(&cm->reg_lock); in set_dac_channels()
737 snd_cmipci_set_bit(cm, CM_REG_LEGACY_CTRL, CM_NXCHG); in set_dac_channels()
738 snd_cmipci_set_bit(cm, CM_REG_MISC_CTRL, CM_XCHGDAC); in set_dac_channels()
740 snd_cmipci_clear_bit(cm, CM_REG_LEGACY_CTRL, CM_NXCHG); in set_dac_channels()
741 snd_cmipci_clear_bit(cm, CM_REG_MISC_CTRL, CM_XCHGDAC); in set_dac_channels()
744 snd_cmipci_set_bit(cm, CM_REG_EXT_MISC, CM_CHB3D8C); in set_dac_channels()
746 snd_cmipci_clear_bit(cm, CM_REG_EXT_MISC, CM_CHB3D8C); in set_dac_channels()
748 snd_cmipci_set_bit(cm, CM_REG_CHFORMAT, CM_CHB3D5C); in set_dac_channels()
749 snd_cmipci_set_bit(cm, CM_REG_LEGACY_CTRL, CM_CHB3D6C); in set_dac_channels()
751 snd_cmipci_clear_bit(cm, CM_REG_CHFORMAT, CM_CHB3D5C); in set_dac_channels()
752 snd_cmipci_clear_bit(cm, CM_REG_LEGACY_CTRL, CM_CHB3D6C); in set_dac_channels()
755 snd_cmipci_set_bit(cm, CM_REG_CHFORMAT, CM_CHB3D); in set_dac_channels()
757 snd_cmipci_clear_bit(cm, CM_REG_CHFORMAT, CM_CHB3D); in set_dac_channels()
758 spin_unlock_irq(&cm->reg_lock); in set_dac_channels()
768 static int snd_cmipci_pcm_prepare(struct cmipci *cm, struct cmipci_pcm *rec, in snd_cmipci_pcm_prepare() argument
784 if (rec->is_dac && set_dac_channels(cm, rec, runtime->channels) < 0) { in snd_cmipci_pcm_prepare()
785 dev_dbg(cm->card->dev, "cannot set dac channels\n"); in snd_cmipci_pcm_prepare()
799 spin_lock_irq(&cm->reg_lock); in snd_cmipci_pcm_prepare()
803 snd_cmipci_write(cm, reg, rec->offset); in snd_cmipci_pcm_prepare()
806 snd_cmipci_write_w(cm, reg, rec->dma_size - 1); in snd_cmipci_pcm_prepare()
807 snd_cmipci_write_w(cm, reg + 2, period_size - 1); in snd_cmipci_pcm_prepare()
812 cm->ctrl &= ~val; in snd_cmipci_pcm_prepare()
814 cm->ctrl |= val; in snd_cmipci_pcm_prepare()
815 snd_cmipci_write(cm, CM_REG_FUNCTRL0, cm->ctrl); in snd_cmipci_pcm_prepare()
830 val = snd_cmipci_read(cm, CM_REG_FUNCTRL1); in snd_cmipci_pcm_prepare()
838 snd_cmipci_write(cm, CM_REG_FUNCTRL1, val); in snd_cmipci_pcm_prepare()
839 dev_dbg(cm->card->dev, "functrl1 = %08x\n", val); in snd_cmipci_pcm_prepare()
842 val = snd_cmipci_read(cm, CM_REG_CHFORMAT); in snd_cmipci_pcm_prepare()
850 if (cm->can_96k) { in snd_cmipci_pcm_prepare()
854 snd_cmipci_write(cm, CM_REG_CHFORMAT, val); in snd_cmipci_pcm_prepare()
855 dev_dbg(cm->card->dev, "chformat = %08x\n", val); in snd_cmipci_pcm_prepare()
857 if (!rec->is_dac && cm->chip_version) { in snd_cmipci_pcm_prepare()
859 snd_cmipci_set_bit(cm, CM_REG_EXT_MISC, CM_ADC48K44K); in snd_cmipci_pcm_prepare()
861 snd_cmipci_clear_bit(cm, CM_REG_EXT_MISC, CM_ADC48K44K); in snd_cmipci_pcm_prepare()
865 spin_unlock_irq(&cm->reg_lock); in snd_cmipci_pcm_prepare()
873 static int snd_cmipci_pcm_trigger(struct cmipci *cm, struct cmipci_pcm *rec, in snd_cmipci_pcm_trigger() argument
884 spin_lock(&cm->reg_lock); in snd_cmipci_pcm_trigger()
889 snd_cmipci_set_bit(cm, CM_REG_INT_HLDCLR, inthld); in snd_cmipci_pcm_trigger()
890 cm->ctrl |= chen; in snd_cmipci_pcm_trigger()
892 snd_cmipci_write(cm, CM_REG_FUNCTRL0, cm->ctrl); in snd_cmipci_pcm_trigger()
893 dev_dbg(cm->card->dev, "functrl0 = %08x\n", cm->ctrl); in snd_cmipci_pcm_trigger()
898 snd_cmipci_clear_bit(cm, CM_REG_INT_HLDCLR, inthld); in snd_cmipci_pcm_trigger()
900 cm->ctrl &= ~chen; in snd_cmipci_pcm_trigger()
901 snd_cmipci_write(cm, CM_REG_FUNCTRL0, cm->ctrl | reset); in snd_cmipci_pcm_trigger()
902 snd_cmipci_write(cm, CM_REG_FUNCTRL0, cm->ctrl & ~reset); in snd_cmipci_pcm_trigger()
907 cm->ctrl |= pause; in snd_cmipci_pcm_trigger()
908 snd_cmipci_write(cm, CM_REG_FUNCTRL0, cm->ctrl); in snd_cmipci_pcm_trigger()
912 cm->ctrl &= ~pause; in snd_cmipci_pcm_trigger()
913 snd_cmipci_write(cm, CM_REG_FUNCTRL0, cm->ctrl); in snd_cmipci_pcm_trigger()
919 spin_unlock(&cm->reg_lock); in snd_cmipci_pcm_trigger()
926 static snd_pcm_uframes_t snd_cmipci_pcm_pointer(struct cmipci *cm, struct cmipci_pcm *rec, in snd_cmipci_pcm_pointer() argument
937 rem = snd_cmipci_read_w(cm, reg); in snd_cmipci_pcm_pointer()
941 dev_err(cm->card->dev, "invalid PCM pointer: %#x\n", rem); in snd_cmipci_pcm_pointer()
947 ptr = snd_cmipci_read(cm, reg) - rec->offset; in snd_cmipci_pcm_pointer()
962 struct cmipci *cm = snd_pcm_substream_chip(substream); in snd_cmipci_playback_trigger() local
963 return snd_cmipci_pcm_trigger(cm, &cm->channel[CM_CH_PLAY], cmd); in snd_cmipci_playback_trigger()
968 struct cmipci *cm = snd_pcm_substream_chip(substream); in snd_cmipci_playback_pointer() local
969 return snd_cmipci_pcm_pointer(cm, &cm->channel[CM_CH_PLAY], substream); in snd_cmipci_playback_pointer()
981 struct cmipci *cm = snd_pcm_substream_chip(substream); in snd_cmipci_capture_trigger() local
982 return snd_cmipci_pcm_trigger(cm, &cm->channel[CM_CH_CAPT], cmd); in snd_cmipci_capture_trigger()
987 struct cmipci *cm = snd_pcm_substream_chip(substream); in snd_cmipci_capture_pointer() local
988 return snd_cmipci_pcm_pointer(cm, &cm->channel[CM_CH_CAPT], substream); in snd_cmipci_capture_pointer()
1122 static int save_mixer_state(struct cmipci *cm) in save_mixer_state() argument
1124 if (! cm->mixer_insensitive) { in save_mixer_state()
1132 struct snd_kcontrol *ctl = cm->mixer_res_ctl[i]; in save_mixer_state()
1137 cm->mixer_res_status[i] = val->value.integer.value[0]; in save_mixer_state()
1140 if (cm->mixer_res_status[i] != val->value.integer.value[0]) { in save_mixer_state()
1145 snd_ctl_notify(cm->card, event, &ctl->id); in save_mixer_state()
1149 cm->mixer_insensitive = 1; in save_mixer_state()
1156 static void restore_mixer_state(struct cmipci *cm) in restore_mixer_state() argument
1158 if (cm->mixer_insensitive) { in restore_mixer_state()
1165 cm->mixer_insensitive = 0; /* at first clear this; in restore_mixer_state()
1168 struct snd_kcontrol *ctl = cm->mixer_res_ctl[i]; in restore_mixer_state()
1176 if (val->value.integer.value[0] != cm->mixer_res_status[i]) { in restore_mixer_state()
1177 val->value.integer.value[0] = cm->mixer_res_status[i]; in restore_mixer_state()
1181 snd_ctl_notify(cm->card, event, &ctl->id); in restore_mixer_state()
1189 static void setup_ac3(struct cmipci *cm, struct snd_pcm_substream *subs, int do_ac3, int rate) in setup_ac3() argument
1193 snd_cmipci_set_bit(cm, CM_REG_CHFORMAT, CM_AC3EN1); in setup_ac3()
1195 snd_cmipci_set_bit(cm, CM_REG_MISC_CTRL, CM_AC3EN2); in setup_ac3()
1197 if (cm->can_ac3_hw) { in setup_ac3()
1200 snd_cmipci_set_bit(cm, CM_REG_CHFORMAT, CM_SPD24SEL); in setup_ac3()
1201 snd_cmipci_clear_bit(cm, CM_REG_MISC_CTRL, CM_SPD32SEL); in setup_ac3()
1204 snd_cmipci_set_bit(cm, CM_REG_MISC_CTRL, CM_SPD32SEL); in setup_ac3()
1206 if (cm->chip_version == 33) { in setup_ac3()
1208 snd_cmipci_set_bit(cm, CM_REG_CHFORMAT, CM_PLAYBACK_SRATE_176K); in setup_ac3()
1210 snd_cmipci_clear_bit(cm, CM_REG_CHFORMAT, CM_PLAYBACK_SRATE_176K); in setup_ac3()
1216 snd_cmipci_clear_bit(cm, CM_REG_CHFORMAT, CM_AC3EN1); in setup_ac3()
1217 snd_cmipci_clear_bit(cm, CM_REG_MISC_CTRL, CM_AC3EN2); in setup_ac3()
1219 if (cm->can_ac3_hw) { in setup_ac3()
1222 snd_cmipci_set_bit(cm, CM_REG_MISC_CTRL, CM_SPD32SEL); in setup_ac3()
1223 snd_cmipci_set_bit(cm, CM_REG_CHFORMAT, CM_SPD24SEL); in setup_ac3()
1225 snd_cmipci_clear_bit(cm, CM_REG_MISC_CTRL, CM_SPD32SEL); in setup_ac3()
1226 snd_cmipci_clear_bit(cm, CM_REG_CHFORMAT, CM_SPD24SEL); in setup_ac3()
1229 snd_cmipci_clear_bit(cm, CM_REG_MISC_CTRL, CM_SPD32SEL); in setup_ac3()
1230 snd_cmipci_clear_bit(cm, CM_REG_CHFORMAT, CM_SPD24SEL); in setup_ac3()
1231 snd_cmipci_clear_bit(cm, CM_REG_CHFORMAT, CM_PLAYBACK_SRATE_176K); in setup_ac3()
1236 static int setup_spdif_playback(struct cmipci *cm, struct snd_pcm_substream *subs, int up, int do_a… in setup_spdif_playback() argument
1243 if ((err = save_mixer_state(cm)) < 0) in setup_spdif_playback()
1246 spin_lock_irq(&cm->reg_lock); in setup_spdif_playback()
1247 cm->spdif_playback_avail = up; in setup_spdif_playback()
1252 if (cm->spdif_playback_enabled) in setup_spdif_playback()
1253 snd_cmipci_set_bit(cm, CM_REG_FUNCTRL1, CM_PLAYBACK_SPDF); in setup_spdif_playback()
1254 setup_ac3(cm, subs, do_ac3, rate); in setup_spdif_playback()
1257 snd_cmipci_set_bit(cm, CM_REG_MISC_CTRL, CM_SPDIF48K | CM_SPDF_AC97); in setup_spdif_playback()
1259 snd_cmipci_clear_bit(cm, CM_REG_MISC_CTRL, CM_SPDIF48K | CM_SPDF_AC97); in setup_spdif_playback()
1261 snd_cmipci_set_bit(cm, CM_REG_CHFORMAT, CM_DBLSPDS); in setup_spdif_playback()
1263 snd_cmipci_clear_bit(cm, CM_REG_CHFORMAT, CM_DBLSPDS); in setup_spdif_playback()
1268 snd_cmipci_clear_bit(cm, CM_REG_CHFORMAT, CM_DBLSPDS); in setup_spdif_playback()
1269 snd_cmipci_clear_bit(cm, CM_REG_FUNCTRL1, CM_PLAYBACK_SPDF); in setup_spdif_playback()
1270 setup_ac3(cm, subs, 0, 0); in setup_spdif_playback()
1272 spin_unlock_irq(&cm->reg_lock); in setup_spdif_playback()
1284 struct cmipci *cm = snd_pcm_substream_chip(substream); in snd_cmipci_playback_prepare() local
1291 if (do_spdif && cm->can_ac3_hw) in snd_cmipci_playback_prepare()
1292 do_ac3 = cm->dig_pcm_status & IEC958_AES0_NONAUDIO; in snd_cmipci_playback_prepare()
1293 if ((err = setup_spdif_playback(cm, substream, do_spdif, do_ac3)) < 0) in snd_cmipci_playback_prepare()
1295 return snd_cmipci_pcm_prepare(cm, &cm->channel[CM_CH_PLAY], substream); in snd_cmipci_playback_prepare()
1301 struct cmipci *cm = snd_pcm_substream_chip(substream); in snd_cmipci_playback_spdif_prepare() local
1304 if (cm->can_ac3_hw) in snd_cmipci_playback_spdif_prepare()
1305 do_ac3 = cm->dig_pcm_status & IEC958_AES0_NONAUDIO; in snd_cmipci_playback_spdif_prepare()
1308 if ((err = setup_spdif_playback(cm, substream, 1, do_ac3)) < 0) in snd_cmipci_playback_spdif_prepare()
1310 return snd_cmipci_pcm_prepare(cm, &cm->channel[CM_CH_PLAY], substream); in snd_cmipci_playback_spdif_prepare()
1321 static void snd_cmipci_silence_hack(struct cmipci *cm, struct cmipci_pcm *rec) in snd_cmipci_silence_hack() argument
1331 snd_cmipci_write(cm, reg, val); in snd_cmipci_silence_hack()
1335 set_dac_channels(cm, rec, 2); in snd_cmipci_silence_hack()
1336 spin_lock_irq(&cm->reg_lock); in snd_cmipci_silence_hack()
1337 val = snd_cmipci_read(cm, CM_REG_FUNCTRL1); in snd_cmipci_silence_hack()
1340 snd_cmipci_write(cm, CM_REG_FUNCTRL1, val); in snd_cmipci_silence_hack()
1341 val = snd_cmipci_read(cm, CM_REG_CHFORMAT); in snd_cmipci_silence_hack()
1344 if (cm->can_96k) in snd_cmipci_silence_hack()
1346 snd_cmipci_write(cm, CM_REG_CHFORMAT, val); in snd_cmipci_silence_hack()
1349 cm->ctrl |= CM_CHEN0 << rec->ch; in snd_cmipci_silence_hack()
1350 snd_cmipci_write(cm, CM_REG_FUNCTRL0, cm->ctrl); in snd_cmipci_silence_hack()
1351 spin_unlock_irq(&cm->reg_lock); in snd_cmipci_silence_hack()
1356 spin_lock_irq(&cm->reg_lock); in snd_cmipci_silence_hack()
1357 cm->ctrl &= ~(CM_CHEN0 << rec->ch); in snd_cmipci_silence_hack()
1359 snd_cmipci_write(cm, CM_REG_FUNCTRL0, cm->ctrl | val); in snd_cmipci_silence_hack()
1360 snd_cmipci_write(cm, CM_REG_FUNCTRL0, cm->ctrl & ~val); in snd_cmipci_silence_hack()
1361 spin_unlock_irq(&cm->reg_lock); in snd_cmipci_silence_hack()
1369 struct cmipci *cm = snd_pcm_substream_chip(substream); in snd_cmipci_playback_hw_free() local
1370 setup_spdif_playback(cm, substream, 0, 0); in snd_cmipci_playback_hw_free()
1371 restore_mixer_state(cm); in snd_cmipci_playback_hw_free()
1372 snd_cmipci_silence_hack(cm, &cm->channel[0]); in snd_cmipci_playback_hw_free()
1378 struct cmipci *cm = snd_pcm_substream_chip(substream); in snd_cmipci_playback2_hw_free() local
1379 snd_cmipci_silence_hack(cm, &cm->channel[1]); in snd_cmipci_playback2_hw_free()
1386 struct cmipci *cm = snd_pcm_substream_chip(substream); in snd_cmipci_capture_prepare() local
1387 return snd_cmipci_pcm_prepare(cm, &cm->channel[CM_CH_CAPT], substream); in snd_cmipci_capture_prepare()
1393 struct cmipci *cm = snd_pcm_substream_chip(substream); in snd_cmipci_capture_spdif_prepare() local
1395 spin_lock_irq(&cm->reg_lock); in snd_cmipci_capture_spdif_prepare()
1396 snd_cmipci_set_bit(cm, CM_REG_FUNCTRL1, CM_CAPTURE_SPDF); in snd_cmipci_capture_spdif_prepare()
1397 if (cm->can_96k) { in snd_cmipci_capture_spdif_prepare()
1399 snd_cmipci_set_bit(cm, CM_REG_CHFORMAT, CM_DBLSPDS); in snd_cmipci_capture_spdif_prepare()
1401 snd_cmipci_clear_bit(cm, CM_REG_CHFORMAT, CM_DBLSPDS); in snd_cmipci_capture_spdif_prepare()
1404 snd_cmipci_set_bit(cm, CM_REG_MISC_CTRL, CM_SPD32SEL); in snd_cmipci_capture_spdif_prepare()
1406 snd_cmipci_clear_bit(cm, CM_REG_MISC_CTRL, CM_SPD32SEL); in snd_cmipci_capture_spdif_prepare()
1408 spin_unlock_irq(&cm->reg_lock); in snd_cmipci_capture_spdif_prepare()
1410 return snd_cmipci_pcm_prepare(cm, &cm->channel[CM_CH_CAPT], substream); in snd_cmipci_capture_spdif_prepare()
1415 struct cmipci *cm = snd_pcm_substream_chip(subs); in snd_cmipci_capture_spdif_hw_free() local
1417 spin_lock_irq(&cm->reg_lock); in snd_cmipci_capture_spdif_hw_free()
1418 snd_cmipci_clear_bit(cm, CM_REG_FUNCTRL1, CM_CAPTURE_SPDF); in snd_cmipci_capture_spdif_hw_free()
1419 snd_cmipci_clear_bit(cm, CM_REG_MISC_CTRL, CM_SPD32SEL); in snd_cmipci_capture_spdif_hw_free()
1420 spin_unlock_irq(&cm->reg_lock); in snd_cmipci_capture_spdif_hw_free()
1431 struct cmipci *cm = dev_id; in snd_cmipci_interrupt() local
1435 status = snd_cmipci_read(cm, CM_REG_INT_STATUS); in snd_cmipci_interrupt()
1440 spin_lock(&cm->reg_lock); in snd_cmipci_interrupt()
1445 snd_cmipci_clear_bit(cm, CM_REG_INT_HLDCLR, mask); in snd_cmipci_interrupt()
1446 snd_cmipci_set_bit(cm, CM_REG_INT_HLDCLR, mask); in snd_cmipci_interrupt()
1447 spin_unlock(&cm->reg_lock); in snd_cmipci_interrupt()
1449 if (cm->rmidi && (status & CM_UARTINT)) in snd_cmipci_interrupt()
1450 snd_mpu401_uart_interrupt(irq, cm->rmidi->private_data); in snd_cmipci_interrupt()
1452 if (cm->pcm) { in snd_cmipci_interrupt()
1453 if ((status & CM_CHINT0) && cm->channel[0].running) in snd_cmipci_interrupt()
1454 snd_pcm_period_elapsed(cm->channel[0].substream); in snd_cmipci_interrupt()
1455 if ((status & CM_CHINT1) && cm->channel[1].running) in snd_cmipci_interrupt()
1456 snd_pcm_period_elapsed(cm->channel[1].substream); in snd_cmipci_interrupt()
1597 static int open_device_check(struct cmipci *cm, int mode, struct snd_pcm_substream *subs) in open_device_check() argument
1606 mutex_lock(&cm->open_mutex); in open_device_check()
1607 if (cm->opened[ch]) { in open_device_check()
1608 mutex_unlock(&cm->open_mutex); in open_device_check()
1611 cm->opened[ch] = mode; in open_device_check()
1612 cm->channel[ch].substream = subs; in open_device_check()
1615 cm->channel[ch].is_dac = 0; in open_device_check()
1616 spin_lock_irq(&cm->reg_lock); in open_device_check()
1617 snd_cmipci_clear_bit(cm, CM_REG_MISC_CTRL, CM_ENDBDAC); in open_device_check()
1618 spin_unlock_irq(&cm->reg_lock); in open_device_check()
1620 mutex_unlock(&cm->open_mutex); in open_device_check()
1624 static void close_device_check(struct cmipci *cm, int mode) in close_device_check() argument
1628 mutex_lock(&cm->open_mutex); in close_device_check()
1629 if (cm->opened[ch] == mode) { in close_device_check()
1630 if (cm->channel[ch].substream) { in close_device_check()
1631 snd_cmipci_ch_reset(cm, ch); in close_device_check()
1632 cm->channel[ch].running = 0; in close_device_check()
1633 cm->channel[ch].substream = NULL; in close_device_check()
1635 cm->opened[ch] = 0; in close_device_check()
1636 if (! cm->channel[ch].is_dac) { in close_device_check()
1638 cm->channel[ch].is_dac = 1; in close_device_check()
1639 spin_lock_irq(&cm->reg_lock); in close_device_check()
1640 snd_cmipci_set_bit(cm, CM_REG_MISC_CTRL, CM_ENDBDAC); in close_device_check()
1641 spin_unlock_irq(&cm->reg_lock); in close_device_check()
1644 mutex_unlock(&cm->open_mutex); in close_device_check()
1652 struct cmipci *cm = snd_pcm_substream_chip(substream); in snd_cmipci_playback_open() local
1656 if ((err = open_device_check(cm, CM_OPEN_PLAYBACK, substream)) < 0) in snd_cmipci_playback_open()
1659 if (cm->chip_version == 68) { in snd_cmipci_playback_open()
1663 } else if (cm->chip_version == 55) { in snd_cmipci_playback_open()
1672 cm->dig_pcm_status = cm->dig_status; in snd_cmipci_playback_open()
1678 struct cmipci *cm = snd_pcm_substream_chip(substream); in snd_cmipci_capture_open() local
1682 if ((err = open_device_check(cm, CM_OPEN_CAPTURE, substream)) < 0) in snd_cmipci_capture_open()
1685 if (cm->chip_version == 68) { // 8768 only supports 44k/48k recording in snd_cmipci_capture_open()
1688 } else if (cm->chip_version == 55) { in snd_cmipci_capture_open()
1702 struct cmipci *cm = snd_pcm_substream_chip(substream); in snd_cmipci_playback2_open() local
1706 if ((err = open_device_check(cm, CM_OPEN_PLAYBACK2, substream)) < 0) /* use channel B */ in snd_cmipci_playback2_open()
1709 mutex_lock(&cm->open_mutex); in snd_cmipci_playback2_open()
1710 if (! cm->opened[CM_CH_PLAY]) { in snd_cmipci_playback2_open()
1711 if (cm->can_multi_ch) { in snd_cmipci_playback2_open()
1712 runtime->hw.channels_max = cm->max_channels; in snd_cmipci_playback2_open()
1713 if (cm->max_channels == 4) in snd_cmipci_playback2_open()
1715 else if (cm->max_channels == 6) in snd_cmipci_playback2_open()
1717 else if (cm->max_channels == 8) in snd_cmipci_playback2_open()
1721 mutex_unlock(&cm->open_mutex); in snd_cmipci_playback2_open()
1722 if (cm->chip_version == 68) { in snd_cmipci_playback2_open()
1726 } else if (cm->chip_version == 55) { in snd_cmipci_playback2_open()
1740 struct cmipci *cm = snd_pcm_substream_chip(substream); in snd_cmipci_playback_spdif_open() local
1744 if ((err = open_device_check(cm, CM_OPEN_SPDIF_PLAYBACK, substream)) < 0) /* use channel A */ in snd_cmipci_playback_spdif_open()
1746 if (cm->can_ac3_hw) { in snd_cmipci_playback_spdif_open()
1748 if (cm->chip_version >= 37) { in snd_cmipci_playback_spdif_open()
1752 if (cm->can_96k) { in snd_cmipci_playback_spdif_open()
1761 cm->dig_pcm_status = cm->dig_status; in snd_cmipci_playback_spdif_open()
1767 struct cmipci *cm = snd_pcm_substream_chip(substream); in snd_cmipci_capture_spdif_open() local
1771 if ((err = open_device_check(cm, CM_OPEN_SPDIF_CAPTURE, substream)) < 0) /* use channel B */ in snd_cmipci_capture_spdif_open()
1774 if (cm->can_96k && !(cm->chip_version == 68)) { in snd_cmipci_capture_spdif_open()
1789 struct cmipci *cm = snd_pcm_substream_chip(substream); in snd_cmipci_playback_close() local
1790 close_device_check(cm, CM_OPEN_PLAYBACK); in snd_cmipci_playback_close()
1796 struct cmipci *cm = snd_pcm_substream_chip(substream); in snd_cmipci_capture_close() local
1797 close_device_check(cm, CM_OPEN_CAPTURE); in snd_cmipci_capture_close()
1803 struct cmipci *cm = snd_pcm_substream_chip(substream); in snd_cmipci_playback2_close() local
1804 close_device_check(cm, CM_OPEN_PLAYBACK2); in snd_cmipci_playback2_close()
1805 close_device_check(cm, CM_OPEN_PLAYBACK_MULTI); in snd_cmipci_playback2_close()
1811 struct cmipci *cm = snd_pcm_substream_chip(substream); in snd_cmipci_playback_spdif_close() local
1812 close_device_check(cm, CM_OPEN_SPDIF_PLAYBACK); in snd_cmipci_playback_spdif_close()
1818 struct cmipci *cm = snd_pcm_substream_chip(substream); in snd_cmipci_capture_spdif_close() local
1819 close_device_check(cm, CM_OPEN_SPDIF_CAPTURE); in snd_cmipci_capture_spdif_close()
1886 static int snd_cmipci_pcm_new(struct cmipci *cm, int device) in snd_cmipci_pcm_new() argument
1891 err = snd_pcm_new(cm->card, cm->card->driver, device, 1, 1, &pcm); in snd_cmipci_pcm_new()
1898 pcm->private_data = cm; in snd_cmipci_pcm_new()
1901 cm->pcm = pcm; in snd_cmipci_pcm_new()
1904 snd_dma_pci_data(cm->pci), 64*1024, 128*1024); in snd_cmipci_pcm_new()
1909 static int snd_cmipci_pcm2_new(struct cmipci *cm, int device) in snd_cmipci_pcm2_new() argument
1914 err = snd_pcm_new(cm->card, cm->card->driver, device, 1, 0, &pcm); in snd_cmipci_pcm2_new()
1920 pcm->private_data = cm; in snd_cmipci_pcm2_new()
1923 cm->pcm2 = pcm; in snd_cmipci_pcm2_new()
1926 snd_dma_pci_data(cm->pci), 64*1024, 128*1024); in snd_cmipci_pcm2_new()
1931 static int snd_cmipci_pcm_spdif_new(struct cmipci *cm, int device) in snd_cmipci_pcm_spdif_new() argument
1936 err = snd_pcm_new(cm->card, cm->card->driver, device, 1, 1, &pcm); in snd_cmipci_pcm_spdif_new()
1943 pcm->private_data = cm; in snd_cmipci_pcm_spdif_new()
1946 cm->pcm_spdif = pcm; in snd_cmipci_pcm_spdif_new()
1949 snd_dma_pci_data(cm->pci), 64*1024, 128*1024); in snd_cmipci_pcm_spdif_new()
1952 snd_pcm_alt_chmaps, cm->max_channels, 0, in snd_cmipci_pcm_spdif_new()
2037 struct cmipci *cm = snd_kcontrol_chip(kcontrol); in snd_cmipci_get_volume() local
2042 spin_lock_irq(&cm->reg_lock); in snd_cmipci_get_volume()
2043 val = (snd_cmipci_mixer_read(cm, reg.left_reg) >> reg.left_shift) & reg.mask; in snd_cmipci_get_volume()
2048 val = (snd_cmipci_mixer_read(cm, reg.right_reg) >> reg.right_shift) & reg.mask; in snd_cmipci_get_volume()
2053 spin_unlock_irq(&cm->reg_lock); in snd_cmipci_get_volume()
2060 struct cmipci *cm = snd_kcontrol_chip(kcontrol); in snd_cmipci_put_volume() local
2077 spin_lock_irq(&cm->reg_lock); in snd_cmipci_put_volume()
2078 oleft = snd_cmipci_mixer_read(cm, reg.left_reg); in snd_cmipci_put_volume()
2083 snd_cmipci_mixer_write(cm, reg.left_reg, left); in snd_cmipci_put_volume()
2084 oright = snd_cmipci_mixer_read(cm, reg.right_reg); in snd_cmipci_put_volume()
2089 snd_cmipci_mixer_write(cm, reg.right_reg, right); in snd_cmipci_put_volume()
2091 snd_cmipci_mixer_write(cm, reg.left_reg, left); in snd_cmipci_put_volume()
2092 spin_unlock_irq(&cm->reg_lock); in snd_cmipci_put_volume()
2119 struct cmipci *cm = snd_kcontrol_chip(kcontrol); in snd_cmipci_get_input_sw() local
2124 spin_lock_irq(&cm->reg_lock); in snd_cmipci_get_input_sw()
2125 val1 = snd_cmipci_mixer_read(cm, reg.left_reg); in snd_cmipci_get_input_sw()
2126 val2 = snd_cmipci_mixer_read(cm, reg.right_reg); in snd_cmipci_get_input_sw()
2127 spin_unlock_irq(&cm->reg_lock); in snd_cmipci_get_input_sw()
2138 struct cmipci *cm = snd_kcontrol_chip(kcontrol); in snd_cmipci_put_input_sw() local
2144 spin_lock_irq(&cm->reg_lock); in snd_cmipci_put_input_sw()
2145 oval1 = snd_cmipci_mixer_read(cm, reg.left_reg); in snd_cmipci_put_input_sw()
2146 oval2 = snd_cmipci_mixer_read(cm, reg.right_reg); in snd_cmipci_put_input_sw()
2154 snd_cmipci_mixer_write(cm, reg.left_reg, val1); in snd_cmipci_put_input_sw()
2155 snd_cmipci_mixer_write(cm, reg.right_reg, val2); in snd_cmipci_put_input_sw()
2156 spin_unlock_irq(&cm->reg_lock); in snd_cmipci_put_input_sw()
2209 struct cmipci *cm = snd_kcontrol_chip(kcontrol); in snd_cmipci_get_native_mixer() local
2214 spin_lock_irq(&cm->reg_lock); in snd_cmipci_get_native_mixer()
2215 oreg = inb(cm->iobase + reg.left_reg); in snd_cmipci_get_native_mixer()
2226 spin_unlock_irq(&cm->reg_lock); in snd_cmipci_get_native_mixer()
2233 struct cmipci *cm = snd_kcontrol_chip(kcontrol); in snd_cmipci_put_native_mixer() local
2238 spin_lock_irq(&cm->reg_lock); in snd_cmipci_put_native_mixer()
2239 oreg = inb(cm->iobase + reg.left_reg); in snd_cmipci_put_native_mixer()
2252 outb(nreg, cm->iobase + reg.left_reg); in snd_cmipci_put_native_mixer()
2253 spin_unlock_irq(&cm->reg_lock); in snd_cmipci_put_native_mixer()
2270 struct cmipci *cm = snd_kcontrol_chip(kcontrol); in snd_cmipci_put_native_mixer_sensitive() local
2271 if (cm->mixer_insensitive) { in snd_cmipci_put_native_mixer_sensitive()
2338 struct cmipci *cm = snd_kcontrol_chip(kcontrol); in _snd_cmipci_uswitch_get() local
2340 spin_lock_irq(&cm->reg_lock); in _snd_cmipci_uswitch_get()
2341 if (args->ac3_sensitive && cm->mixer_insensitive) { in _snd_cmipci_uswitch_get()
2343 spin_unlock_irq(&cm->reg_lock); in _snd_cmipci_uswitch_get()
2347 val = inb(cm->iobase + args->reg); in _snd_cmipci_uswitch_get()
2349 val = snd_cmipci_read(cm, args->reg); in _snd_cmipci_uswitch_get()
2351 spin_unlock_irq(&cm->reg_lock); in _snd_cmipci_uswitch_get()
2371 struct cmipci *cm = snd_kcontrol_chip(kcontrol); in _snd_cmipci_uswitch_put() local
2373 spin_lock_irq(&cm->reg_lock); in _snd_cmipci_uswitch_put()
2374 if (args->ac3_sensitive && cm->mixer_insensitive) { in _snd_cmipci_uswitch_put()
2376 spin_unlock_irq(&cm->reg_lock); in _snd_cmipci_uswitch_put()
2380 val = inb(cm->iobase + args->reg); in _snd_cmipci_uswitch_put()
2382 val = snd_cmipci_read(cm, args->reg); in _snd_cmipci_uswitch_put()
2392 outb((unsigned char)val, cm->iobase + args->reg); in _snd_cmipci_uswitch_put()
2394 snd_cmipci_write(cm, args->reg, val); in _snd_cmipci_uswitch_put()
2396 spin_unlock_irq(&cm->reg_lock); in _snd_cmipci_uswitch_put()
2501 struct cmipci *cm = snd_kcontrol_chip(kcontrol); in snd_cmipci_line_in_mode_info() local
2507 cm->chip_version >= 39 ? 3 : 2, texts); in snd_cmipci_line_in_mode_info()
2510 static inline unsigned int get_line_in_mode(struct cmipci *cm) in get_line_in_mode() argument
2513 if (cm->chip_version >= 39) { in get_line_in_mode()
2514 val = snd_cmipci_read(cm, CM_REG_LEGACY_CTRL); in get_line_in_mode()
2518 val = snd_cmipci_read_b(cm, CM_REG_MIXER1); in get_line_in_mode()
2527 struct cmipci *cm = snd_kcontrol_chip(kcontrol); in snd_cmipci_line_in_mode_get() local
2529 spin_lock_irq(&cm->reg_lock); in snd_cmipci_line_in_mode_get()
2530 ucontrol->value.enumerated.item[0] = get_line_in_mode(cm); in snd_cmipci_line_in_mode_get()
2531 spin_unlock_irq(&cm->reg_lock); in snd_cmipci_line_in_mode_get()
2538 struct cmipci *cm = snd_kcontrol_chip(kcontrol); in snd_cmipci_line_in_mode_put() local
2541 spin_lock_irq(&cm->reg_lock); in snd_cmipci_line_in_mode_put()
2543 change = snd_cmipci_set_bit(cm, CM_REG_LEGACY_CTRL, CM_CENTR2LIN | CM_BASE2LIN); in snd_cmipci_line_in_mode_put()
2545 change = snd_cmipci_clear_bit(cm, CM_REG_LEGACY_CTRL, CM_CENTR2LIN | CM_BASE2LIN); in snd_cmipci_line_in_mode_put()
2547 change |= snd_cmipci_set_bit_b(cm, CM_REG_MIXER1, CM_REAR2LIN); in snd_cmipci_line_in_mode_put()
2549 change |= snd_cmipci_clear_bit_b(cm, CM_REG_MIXER1, CM_REAR2LIN); in snd_cmipci_line_in_mode_put()
2550 spin_unlock_irq(&cm->reg_lock); in snd_cmipci_line_in_mode_put()
2565 struct cmipci *cm = snd_kcontrol_chip(kcontrol); in snd_cmipci_mic_in_mode_get() local
2567 spin_lock_irq(&cm->reg_lock); in snd_cmipci_mic_in_mode_get()
2569 (snd_cmipci_read_b(cm, CM_REG_MISC) & CM_SPDIF_INVERSE) ? 1 : 0; in snd_cmipci_mic_in_mode_get()
2570 spin_unlock_irq(&cm->reg_lock); in snd_cmipci_mic_in_mode_get()
2577 struct cmipci *cm = snd_kcontrol_chip(kcontrol); in snd_cmipci_mic_in_mode_put() local
2580 spin_lock_irq(&cm->reg_lock); in snd_cmipci_mic_in_mode_put()
2582 change = snd_cmipci_set_bit_b(cm, CM_REG_MISC, CM_SPDIF_INVERSE); in snd_cmipci_mic_in_mode_put()
2584 change = snd_cmipci_clear_bit_b(cm, CM_REG_MISC, CM_SPDIF_INVERSE); in snd_cmipci_mic_in_mode_put()
2585 spin_unlock_irq(&cm->reg_lock); in snd_cmipci_mic_in_mode_put()
2652 static int snd_cmipci_mixer_new(struct cmipci *cm, int pcm_spdif_device) in snd_cmipci_mixer_new() argument
2660 if (snd_BUG_ON(!cm || !cm->card)) in snd_cmipci_mixer_new()
2663 card = cm->card; in snd_cmipci_mixer_new()
2667 spin_lock_irq(&cm->reg_lock); in snd_cmipci_mixer_new()
2668 snd_cmipci_mixer_write(cm, 0x00, 0x00); /* mixer reset */ in snd_cmipci_mixer_new()
2669 spin_unlock_irq(&cm->reg_lock); in snd_cmipci_mixer_new()
2672 if (cm->chip_version == 68) { // 8768 has no PCM volume in snd_cmipci_mixer_new()
2677 if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_cmipci_mixers[idx], cm))) < 0) in snd_cmipci_mixer_new()
2684 err = snd_ctl_add(cm->card, snd_ctl_new1(sw, cm)); in snd_cmipci_mixer_new()
2688 if (! cm->can_multi_ch) { in snd_cmipci_mixer_new()
2689 err = snd_ctl_add(cm->card, snd_ctl_new1(&snd_cmipci_nomulti_switch, cm)); in snd_cmipci_mixer_new()
2693 if (cm->device == PCI_DEVICE_ID_CMEDIA_CM8738 || in snd_cmipci_mixer_new()
2694 cm->device == PCI_DEVICE_ID_CMEDIA_CM8738B) { in snd_cmipci_mixer_new()
2697 err = snd_ctl_add(cm->card, snd_ctl_new1(sw, cm)); in snd_cmipci_mixer_new()
2701 if (cm->can_ac3_hw) { in snd_cmipci_mixer_new()
2702 if ((err = snd_ctl_add(card, kctl = snd_ctl_new1(&snd_cmipci_spdif_default, cm))) < 0) in snd_cmipci_mixer_new()
2705 if ((err = snd_ctl_add(card, kctl = snd_ctl_new1(&snd_cmipci_spdif_mask, cm))) < 0) in snd_cmipci_mixer_new()
2708 if ((err = snd_ctl_add(card, kctl = snd_ctl_new1(&snd_cmipci_spdif_stream, cm))) < 0) in snd_cmipci_mixer_new()
2712 if (cm->chip_version <= 37) { in snd_cmipci_mixer_new()
2715 err = snd_ctl_add(cm->card, snd_ctl_new1(sw, cm)); in snd_cmipci_mixer_new()
2721 if (cm->chip_version >= 39) { in snd_cmipci_mixer_new()
2724 err = snd_ctl_add(cm->card, snd_ctl_new1(sw, cm)); in snd_cmipci_mixer_new()
2735 if (cm->chip_version < 39) { in snd_cmipci_mixer_new()
2736 err = snd_ctl_add(cm->card, in snd_cmipci_mixer_new()
2737 snd_ctl_new1(&snd_cmipci_modem_switch, cm)); in snd_cmipci_mixer_new()
2748 ctl = snd_ctl_find_id(cm->card, &elem_id); in snd_cmipci_mixer_new()
2750 cm->mixer_res_ctl[idx] = ctl; in snd_cmipci_mixer_new()
2764 struct cmipci *cm = entry->private_data; in snd_cmipci_proc_read() local
2767 snd_iprintf(buffer, "%s\n", cm->card->longname); in snd_cmipci_proc_read()
2771 v = inb(cm->iobase + i); in snd_cmipci_proc_read()
2779 static void snd_cmipci_proc_init(struct cmipci *cm) in snd_cmipci_proc_init() argument
2781 snd_card_ro_proc_new(cm->card, "cmipci", cm, snd_cmipci_proc_read); in snd_cmipci_proc_init()
2798 static void query_chip(struct cmipci *cm) in query_chip() argument
2803 detect = snd_cmipci_read(cm, CM_REG_INT_HLDCLR) & CM_CHIP_MASK2; in query_chip()
2806 detect = snd_cmipci_read(cm, CM_REG_CHFORMAT) & CM_CHIP_MASK1; in query_chip()
2809 cm->chip_version = 33; in query_chip()
2810 if (cm->do_soft_ac3) in query_chip()
2811 cm->can_ac3_sw = 1; in query_chip()
2813 cm->can_ac3_hw = 1; in query_chip()
2816 cm->chip_version = 37; in query_chip()
2817 cm->can_ac3_hw = 1; in query_chip()
2820 cm->chip_version = 39; in query_chip()
2821 cm->can_ac3_hw = 1; in query_chip()
2824 cm->max_channels = 2; in query_chip()
2827 cm->chip_version = 39; in query_chip()
2829 cm->max_channels = 6; in query_chip()
2831 cm->max_channels = 4; in query_chip()
2833 cm->chip_version = 68; in query_chip()
2834 cm->max_channels = 8; in query_chip()
2835 cm->can_96k = 1; in query_chip()
2837 cm->chip_version = 55; in query_chip()
2838 cm->max_channels = 6; in query_chip()
2839 cm->can_96k = 1; in query_chip()
2841 cm->can_ac3_hw = 1; in query_chip()
2842 cm->can_multi_ch = 1; in query_chip()
2847 static int snd_cmipci_create_gameport(struct cmipci *cm, int dev) in snd_cmipci_create_gameport() argument
2870 dev_warn(cm->card->dev, "cannot reserve joystick ports\n"); in snd_cmipci_create_gameport()
2874 cm->gameport = gp = gameport_allocate_port(); in snd_cmipci_create_gameport()
2876 dev_err(cm->card->dev, "cannot allocate memory for gameport\n"); in snd_cmipci_create_gameport()
2881 gameport_set_phys(gp, "pci%s/gameport0", pci_name(cm->pci)); in snd_cmipci_create_gameport()
2882 gameport_set_dev_parent(gp, &cm->pci->dev); in snd_cmipci_create_gameport()
2886 snd_cmipci_set_bit(cm, CM_REG_FUNCTRL1, CM_JYSTK_EN); in snd_cmipci_create_gameport()
2888 gameport_register_port(cm->gameport); in snd_cmipci_create_gameport()
2893 static void snd_cmipci_free_gameport(struct cmipci *cm) in snd_cmipci_free_gameport() argument
2895 if (cm->gameport) { in snd_cmipci_free_gameport()
2896 struct resource *r = gameport_get_port_data(cm->gameport); in snd_cmipci_free_gameport()
2898 gameport_unregister_port(cm->gameport); in snd_cmipci_free_gameport()
2899 cm->gameport = NULL; in snd_cmipci_free_gameport()
2901 snd_cmipci_clear_bit(cm, CM_REG_FUNCTRL1, CM_JYSTK_EN); in snd_cmipci_free_gameport()
2906 static inline int snd_cmipci_create_gameport(struct cmipci *cm, int dev) { return -ENOSYS; } in snd_cmipci_create_gameport() argument
2907 static inline void snd_cmipci_free_gameport(struct cmipci *cm) { } in snd_cmipci_free_gameport() argument
2910 static int snd_cmipci_free(struct cmipci *cm) in snd_cmipci_free() argument
2912 if (cm->irq >= 0) { in snd_cmipci_free()
2913 snd_cmipci_clear_bit(cm, CM_REG_MISC_CTRL, CM_FM_EN); in snd_cmipci_free()
2914 snd_cmipci_clear_bit(cm, CM_REG_LEGACY_CTRL, CM_ENSPDOUT); in snd_cmipci_free()
2915 snd_cmipci_write(cm, CM_REG_INT_HLDCLR, 0); /* disable ints */ in snd_cmipci_free()
2916 snd_cmipci_ch_reset(cm, CM_CH_PLAY); in snd_cmipci_free()
2917 snd_cmipci_ch_reset(cm, CM_CH_CAPT); in snd_cmipci_free()
2918 snd_cmipci_write(cm, CM_REG_FUNCTRL0, 0); /* disable channels */ in snd_cmipci_free()
2919 snd_cmipci_write(cm, CM_REG_FUNCTRL1, 0); in snd_cmipci_free()
2922 snd_cmipci_mixer_write(cm, 0, 0); in snd_cmipci_free()
2924 free_irq(cm->irq, cm); in snd_cmipci_free()
2927 snd_cmipci_free_gameport(cm); in snd_cmipci_free()
2928 pci_release_regions(cm->pci); in snd_cmipci_free()
2929 pci_disable_device(cm->pci); in snd_cmipci_free()
2930 kfree(cm); in snd_cmipci_free()
2936 struct cmipci *cm = device->device_data; in snd_cmipci_dev_free() local
2937 return snd_cmipci_free(cm); in snd_cmipci_dev_free()
2940 static int snd_cmipci_create_fm(struct cmipci *cm, long fm_port) in snd_cmipci_create_fm() argument
2950 if (cm->chip_version >= 39) { in snd_cmipci_create_fm()
2952 iosynth = cm->iobase + CM_REG_FM_PCI; in snd_cmipci_create_fm()
2953 err = snd_opl3_create(cm->card, iosynth, iosynth + 2, in snd_cmipci_create_fm()
2960 val = snd_cmipci_read(cm, CM_REG_LEGACY_CTRL) & ~CM_FMSEL_MASK; in snd_cmipci_create_fm()
2970 snd_cmipci_write(cm, CM_REG_LEGACY_CTRL, val); in snd_cmipci_create_fm()
2972 snd_cmipci_set_bit(cm, CM_REG_MISC_CTRL, CM_FM_EN); in snd_cmipci_create_fm()
2974 if (snd_opl3_create(cm->card, iosynth, iosynth + 2, in snd_cmipci_create_fm()
2976 dev_err(cm->card->dev, in snd_cmipci_create_fm()
2983 dev_err(cm->card->dev, "cannot create OPL3 hwdep\n"); in snd_cmipci_create_fm()
2989 snd_cmipci_clear_bit(cm, CM_REG_LEGACY_CTRL, CM_FMSEL_MASK); in snd_cmipci_create_fm()
2990 snd_cmipci_clear_bit(cm, CM_REG_MISC_CTRL, CM_FM_EN); in snd_cmipci_create_fm()
2997 struct cmipci *cm; in snd_cmipci_create() local
3017 cm = kzalloc(sizeof(*cm), GFP_KERNEL); in snd_cmipci_create()
3018 if (cm == NULL) { in snd_cmipci_create()
3023 spin_lock_init(&cm->reg_lock); in snd_cmipci_create()
3024 mutex_init(&cm->open_mutex); in snd_cmipci_create()
3025 cm->device = pci->device; in snd_cmipci_create()
3026 cm->card = card; in snd_cmipci_create()
3027 cm->pci = pci; in snd_cmipci_create()
3028 cm->irq = -1; in snd_cmipci_create()
3029 cm->channel[0].ch = 0; in snd_cmipci_create()
3030 cm->channel[1].ch = 1; in snd_cmipci_create()
3031 cm->channel[0].is_dac = cm->channel[1].is_dac = 1; /* dual DAC mode */ in snd_cmipci_create()
3034 kfree(cm); in snd_cmipci_create()
3038 cm->iobase = pci_resource_start(pci, 0); in snd_cmipci_create()
3041 IRQF_SHARED, KBUILD_MODNAME, cm)) { in snd_cmipci_create()
3043 snd_cmipci_free(cm); in snd_cmipci_create()
3046 cm->irq = pci->irq; in snd_cmipci_create()
3048 pci_set_master(cm->pci); in snd_cmipci_create()
3054 cm->chip_version = 0; in snd_cmipci_create()
3055 cm->max_channels = 2; in snd_cmipci_create()
3056 cm->do_soft_ac3 = soft_ac3[dev]; in snd_cmipci_create()
3060 query_chip(cm); in snd_cmipci_create()
3062 if (cm->can_multi_ch) in snd_cmipci_create()
3063 sprintf(cm->card->driver + strlen(cm->card->driver), in snd_cmipci_create()
3064 "-MC%d", cm->max_channels); in snd_cmipci_create()
3065 else if (cm->can_ac3_sw) in snd_cmipci_create()
3066 strcpy(cm->card->driver + strlen(cm->card->driver), "-SWIEC"); in snd_cmipci_create()
3068 cm->dig_status = SNDRV_PCM_DEFAULT_CON_SPDIF; in snd_cmipci_create()
3069 cm->dig_pcm_status = SNDRV_PCM_DEFAULT_CON_SPDIF; in snd_cmipci_create()
3072 cm->ctrl = CM_CHADC0; /* default FUNCNTRL0 */ in snd_cmipci_create()
3074 cm->ctrl = CM_CHADC1; /* default FUNCNTRL0 */ in snd_cmipci_create()
3078 snd_cmipci_set_bit(cm, CM_REG_MISC_CTRL, CM_RESET); in snd_cmipci_create()
3079 snd_cmipci_clear_bit(cm, CM_REG_MISC_CTRL, CM_RESET); in snd_cmipci_create()
3080 snd_cmipci_write(cm, CM_REG_INT_HLDCLR, 0); /* disable ints */ in snd_cmipci_create()
3081 snd_cmipci_ch_reset(cm, CM_CH_PLAY); in snd_cmipci_create()
3082 snd_cmipci_ch_reset(cm, CM_CH_CAPT); in snd_cmipci_create()
3083 snd_cmipci_write(cm, CM_REG_FUNCTRL0, 0); /* disable channels */ in snd_cmipci_create()
3084 snd_cmipci_write(cm, CM_REG_FUNCTRL1, 0); in snd_cmipci_create()
3086 snd_cmipci_write(cm, CM_REG_CHFORMAT, 0); in snd_cmipci_create()
3087 snd_cmipci_set_bit(cm, CM_REG_MISC_CTRL, CM_ENDBDAC|CM_N4SPK3D); in snd_cmipci_create()
3089 snd_cmipci_set_bit(cm, CM_REG_MISC_CTRL, CM_XCHGDAC); in snd_cmipci_create()
3091 snd_cmipci_clear_bit(cm, CM_REG_MISC_CTRL, CM_XCHGDAC); in snd_cmipci_create()
3093 if (cm->chip_version) { in snd_cmipci_create()
3094 snd_cmipci_write_b(cm, CM_REG_EXT_MISC, 0x20); /* magic */ in snd_cmipci_create()
3095 snd_cmipci_write_b(cm, CM_REG_EXT_MISC + 1, 0x09); /* more magic */ in snd_cmipci_create()
3098 snd_cmipci_set_bit(cm, CM_REG_FUNCTRL1, CM_BREQ); in snd_cmipci_create()
3105 snd_cmipci_set_bit(cm, CM_REG_MISC_CTRL, CM_TXVX); in snd_cmipci_create()
3111 if (cm->chip_version < 68) { in snd_cmipci_create()
3114 switch (snd_cmipci_read_b(cm, CM_REG_INT_HLDCLR + 3) & 0x03) { in snd_cmipci_create()
3139 if (cm->chip_version < 68) in snd_cmipci_create()
3140 sprintf(modelstr, " (model %d)", cm->chip_version); in snd_cmipci_create()
3144 card->shortname, modelstr, cm->iobase, cm->irq); in snd_cmipci_create()
3146 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, cm, &ops)) < 0) { in snd_cmipci_create()
3147 snd_cmipci_free(cm); in snd_cmipci_create()
3151 if (cm->chip_version >= 39) { in snd_cmipci_create()
3152 val = snd_cmipci_read_b(cm, CM_REG_MPU_PCI + 1); in snd_cmipci_create()
3154 iomidi = cm->iobase + CM_REG_MPU_PCI; in snd_cmipci_create()
3170 snd_cmipci_write(cm, CM_REG_LEGACY_CTRL, val); in snd_cmipci_create()
3172 snd_cmipci_set_bit(cm, CM_REG_FUNCTRL1, CM_UART_EN); in snd_cmipci_create()
3174 dev_err(cm->card->dev, in snd_cmipci_create()
3177 snd_cmipci_clear_bit(cm, CM_REG_FUNCTRL1, in snd_cmipci_create()
3184 if (cm->chip_version < 68) { in snd_cmipci_create()
3185 err = snd_cmipci_create_fm(cm, fm_port[dev]); in snd_cmipci_create()
3191 snd_cmipci_mixer_write(cm, 0, 0); in snd_cmipci_create()
3193 snd_cmipci_proc_init(cm); in snd_cmipci_create()
3197 if ((err = snd_cmipci_pcm_new(cm, pcm_index)) < 0) in snd_cmipci_create()
3200 if ((err = snd_cmipci_pcm2_new(cm, pcm_index)) < 0) in snd_cmipci_create()
3203 if (cm->can_ac3_hw || cm->can_ac3_sw) { in snd_cmipci_create()
3205 if ((err = snd_cmipci_pcm_spdif_new(cm, pcm_index)) < 0) in snd_cmipci_create()
3210 if ((err = snd_cmipci_mixer_new(cm, pcm_spdif_index)) < 0) in snd_cmipci_create()
3219 -1, &cm->rmidi)) < 0) { in snd_cmipci_create()
3220 dev_err(cm->card->dev, in snd_cmipci_create()
3227 snd_cmipci_set_pll(cm, rates[val], val); in snd_cmipci_create()
3232 snd_cmipci_set_bit(cm, CM_REG_MISC_CTRL, CM_SPDIF48K|CM_SPDF_AC97); in snd_cmipci_create()
3235 if (snd_cmipci_create_gameport(cm, dev) < 0) in snd_cmipci_create()
3236 snd_cmipci_clear_bit(cm, CM_REG_FUNCTRL1, CM_JYSTK_EN); in snd_cmipci_create()
3238 *rcmipci = cm; in snd_cmipci_create()
3252 struct cmipci *cm; in snd_cmipci_probe() local
3281 err = snd_cmipci_create(card, pci, dev, &cm); in snd_cmipci_probe()
3285 card->private_data = cm; in snd_cmipci_probe()
3332 struct cmipci *cm = card->private_data; in snd_cmipci_suspend() local
3339 cm->saved_regs[i] = snd_cmipci_read(cm, saved_regs[i]); in snd_cmipci_suspend()
3341 cm->saved_mixers[i] = snd_cmipci_mixer_read(cm, saved_mixers[i]); in snd_cmipci_suspend()
3344 snd_cmipci_write(cm, CM_REG_INT_HLDCLR, 0); in snd_cmipci_suspend()
3351 struct cmipci *cm = card->private_data; in snd_cmipci_resume() local
3355 snd_cmipci_write(cm, CM_REG_INT_HLDCLR, 0); in snd_cmipci_resume()
3356 snd_cmipci_ch_reset(cm, CM_CH_PLAY); in snd_cmipci_resume()
3357 snd_cmipci_ch_reset(cm, CM_CH_CAPT); in snd_cmipci_resume()
3358 snd_cmipci_mixer_write(cm, 0, 0); in snd_cmipci_resume()
3362 snd_cmipci_write(cm, saved_regs[i], cm->saved_regs[i]); in snd_cmipci_resume()
3364 snd_cmipci_mixer_write(cm, saved_mixers[i], cm->saved_mixers[i]); in snd_cmipci_resume()