Lines Matching refs:chip
430 struct via82xx *chip = snd_pcm_substream_chip(substream); in build_via_table() local
436 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), in build_via_table()
512 static inline unsigned int snd_via82xx_codec_xread(struct via82xx *chip) in snd_via82xx_codec_xread() argument
514 return inl(VIAREG(chip, AC97)); in snd_via82xx_codec_xread()
517 static inline void snd_via82xx_codec_xwrite(struct via82xx *chip, unsigned int val) in snd_via82xx_codec_xwrite() argument
519 outl(val, VIAREG(chip, AC97)); in snd_via82xx_codec_xwrite()
522 static int snd_via82xx_codec_ready(struct via82xx *chip, int secondary) in snd_via82xx_codec_ready() argument
529 if (!((val = snd_via82xx_codec_xread(chip)) & VIA_REG_AC97_BUSY)) in snd_via82xx_codec_ready()
532 dev_err(chip->card->dev, "codec_ready: codec %i is not ready [0x%x]\n", in snd_via82xx_codec_ready()
533 secondary, snd_via82xx_codec_xread(chip)); in snd_via82xx_codec_ready()
537 static int snd_via82xx_codec_valid(struct via82xx *chip, int secondary) in snd_via82xx_codec_valid() argument
545 val = snd_via82xx_codec_xread(chip); in snd_via82xx_codec_valid()
556 struct via82xx *chip = ac97->private_data; in snd_via82xx_codec_wait() local
558 err = snd_via82xx_codec_ready(chip, ac97->num); in snd_via82xx_codec_wait()
568 struct via82xx *chip = ac97->private_data; in snd_via82xx_codec_write() local
575 snd_via82xx_codec_xwrite(chip, xval); in snd_via82xx_codec_write()
576 snd_via82xx_codec_ready(chip, ac97->num); in snd_via82xx_codec_write()
581 struct via82xx *chip = ac97->private_data; in snd_via82xx_codec_read() local
591 dev_err(chip->card->dev, in snd_via82xx_codec_read()
593 ac97->num, snd_via82xx_codec_xread(chip)); in snd_via82xx_codec_read()
596 snd_via82xx_codec_xwrite(chip, xval); in snd_via82xx_codec_read()
598 if (snd_via82xx_codec_valid(chip, ac97->num) >= 0) { in snd_via82xx_codec_read()
600 val = snd_via82xx_codec_xread(chip); in snd_via82xx_codec_read()
607 static void snd_via82xx_channel_reset(struct via82xx *chip, struct viadev *viadev) in snd_via82xx_channel_reset() argument
630 struct via82xx *chip = dev_id; in snd_via686_interrupt() local
634 status = inl(VIAREG(chip, SGD_SHADOW)); in snd_via686_interrupt()
635 if (! (status & chip->intr_mask)) { in snd_via686_interrupt()
636 if (chip->rmidi) in snd_via686_interrupt()
638 return snd_mpu401_uart_interrupt(irq, chip->rmidi->private_data); in snd_via686_interrupt()
643 spin_lock(&chip->reg_lock); in snd_via686_interrupt()
644 for (i = 0; i < chip->num_devs; i++) { in snd_via686_interrupt()
645 struct viadev *viadev = &chip->devs[i]; in snd_via686_interrupt()
660 spin_unlock(&chip->reg_lock); in snd_via686_interrupt()
662 spin_lock(&chip->reg_lock); in snd_via686_interrupt()
667 spin_unlock(&chip->reg_lock); in snd_via686_interrupt()
676 struct via82xx *chip = dev_id; in snd_via8233_interrupt() local
682 spin_lock(&chip->reg_lock); in snd_via8233_interrupt()
683 status = inl(VIAREG(chip, SGD_SHADOW)); in snd_via8233_interrupt()
685 for (i = 0; i < chip->num_devs; i++) { in snd_via8233_interrupt()
686 struct viadev *viadev = &chip->devs[i]; in snd_via8233_interrupt()
711 spin_unlock(&chip->reg_lock); in snd_via8233_interrupt()
715 spin_lock(&chip->reg_lock); in snd_via8233_interrupt()
721 spin_unlock(&chip->reg_lock); in snd_via8233_interrupt()
734 struct via82xx *chip = snd_pcm_substream_chip(substream); in snd_via82xx_pcm_trigger() local
738 if (chip->chip_type != TYPE_VIA686) in snd_via82xx_pcm_trigger()
765 snd_via82xx_channel_reset(chip, viadev); in snd_via82xx_pcm_trigger()
782 static inline unsigned int calc_linear_pos(struct via82xx *chip, in calc_linear_pos() argument
797 dev_dbg(chip->card->dev, in calc_linear_pos()
815 dev_dbg(chip->card->dev, in calc_linear_pos()
825 dev_dbg(chip->card->dev, in calc_linear_pos()
839 struct via82xx *chip = snd_pcm_substream_chip(substream); in snd_via686_pcm_pointer() local
848 spin_lock(&chip->reg_lock); in snd_via686_pcm_pointer()
858 res = calc_linear_pos(chip, viadev, idx, count); in snd_via686_pcm_pointer()
860 spin_unlock(&chip->reg_lock); in snd_via686_pcm_pointer()
870 struct via82xx *chip = snd_pcm_substream_chip(substream); in snd_via8233_pcm_pointer() local
878 spin_lock(&chip->reg_lock); in snd_via8233_pcm_pointer()
886 if (chip->revision == VIA_REV_8251 && (status & VIA_REG_STAT_EOL)) in snd_via8233_pcm_pointer()
897 dev_dbg(chip->card->dev, in snd_via8233_pcm_pointer()
904 res = calc_linear_pos(chip, viadev, idx, count); in snd_via8233_pcm_pointer()
919 spin_unlock(&chip->reg_lock); in snd_via8233_pcm_pointer()
932 struct via82xx *chip = snd_pcm_substream_chip(substream); in snd_via82xx_hw_params() local
939 err = build_via_table(viadev, substream, chip->pci, in snd_via82xx_hw_params()
954 struct via82xx *chip = snd_pcm_substream_chip(substream); in snd_via82xx_hw_free() local
957 clean_via_table(viadev, substream, chip->pci); in snd_via82xx_hw_free()
966 static void snd_via82xx_set_table_ptr(struct via82xx *chip, struct viadev *viadev) in snd_via82xx_set_table_ptr() argument
968 snd_via82xx_codec_ready(chip, 0); in snd_via82xx_set_table_ptr()
971 snd_via82xx_codec_ready(chip, 0); in snd_via82xx_set_table_ptr()
977 static void via686_setup_format(struct via82xx *chip, struct viadev *viadev, in via686_setup_format() argument
980 snd_via82xx_channel_reset(chip, viadev); in via686_setup_format()
982 snd_via82xx_set_table_ptr(chip, viadev); in via686_setup_format()
993 struct via82xx *chip = snd_pcm_substream_chip(substream); in snd_via686_playback_prepare() local
997 snd_ac97_set_rate(chip->ac97, AC97_PCM_FRONT_DAC_RATE, runtime->rate); in snd_via686_playback_prepare()
998 snd_ac97_set_rate(chip->ac97, AC97_SPDIF, runtime->rate); in snd_via686_playback_prepare()
999 via686_setup_format(chip, viadev, runtime); in snd_via686_playback_prepare()
1005 struct via82xx *chip = snd_pcm_substream_chip(substream); in snd_via686_capture_prepare() local
1009 snd_ac97_set_rate(chip->ac97, AC97_PCM_LR_ADC_RATE, runtime->rate); in snd_via686_capture_prepare()
1010 via686_setup_format(chip, viadev, runtime); in snd_via686_capture_prepare()
1039 struct via82xx *chip = snd_pcm_substream_chip(substream); in snd_via8233_playback_prepare() local
1042 int ac97_rate = chip->dxs_src ? 48000 : runtime->rate; in snd_via8233_playback_prepare()
1046 if ((rate_changed = via_lock_rate(&chip->rates[0], ac97_rate)) < 0) in snd_via8233_playback_prepare()
1049 snd_ac97_set_rate(chip->ac97, AC97_PCM_FRONT_DAC_RATE, in snd_via8233_playback_prepare()
1050 chip->no_vra ? 48000 : runtime->rate); in snd_via8233_playback_prepare()
1051 if (chip->spdif_on && viadev->reg_offset == 0x30) in snd_via8233_playback_prepare()
1052 snd_ac97_set_rate(chip->ac97, AC97_SPDIF, runtime->rate); in snd_via8233_playback_prepare()
1060 snd_via82xx_channel_reset(chip, viadev); in snd_via8233_playback_prepare()
1061 snd_via82xx_set_table_ptr(chip, viadev); in snd_via8233_playback_prepare()
1062 outb(chip->playback_volume[viadev->reg_offset / 0x10][0], in snd_via8233_playback_prepare()
1064 outb(chip->playback_volume[viadev->reg_offset / 0x10][1], in snd_via8233_playback_prepare()
1072 snd_via82xx_codec_ready(chip, 0); in snd_via8233_playback_prepare()
1081 struct via82xx *chip = snd_pcm_substream_chip(substream); in snd_via8233_multi_prepare() local
1087 if (via_lock_rate(&chip->rates[0], runtime->rate) < 0) in snd_via8233_multi_prepare()
1089 snd_ac97_set_rate(chip->ac97, AC97_PCM_FRONT_DAC_RATE, runtime->rate); in snd_via8233_multi_prepare()
1090 snd_ac97_set_rate(chip->ac97, AC97_PCM_SURR_DAC_RATE, runtime->rate); in snd_via8233_multi_prepare()
1091 snd_ac97_set_rate(chip->ac97, AC97_PCM_LFE_DAC_RATE, runtime->rate); in snd_via8233_multi_prepare()
1092 snd_ac97_set_rate(chip->ac97, AC97_SPDIF, runtime->rate); in snd_via8233_multi_prepare()
1093 snd_via82xx_channel_reset(chip, viadev); in snd_via8233_multi_prepare()
1094 snd_via82xx_set_table_ptr(chip, viadev); in snd_via8233_multi_prepare()
1101 if (chip->revision == VIA_REV_8233A) in snd_via8233_multi_prepare()
1121 snd_via82xx_codec_ready(chip, 0); in snd_via8233_multi_prepare()
1130 struct via82xx *chip = snd_pcm_substream_chip(substream); in snd_via8233_capture_prepare() local
1134 if (via_lock_rate(&chip->rates[1], runtime->rate) < 0) in snd_via8233_capture_prepare()
1136 snd_ac97_set_rate(chip->ac97, AC97_PCM_LR_ADC_RATE, runtime->rate); in snd_via8233_capture_prepare()
1137 snd_via82xx_channel_reset(chip, viadev); in snd_via8233_capture_prepare()
1138 snd_via82xx_set_table_ptr(chip, viadev); in snd_via8233_capture_prepare()
1145 snd_via82xx_codec_ready(chip, 0); in snd_via8233_capture_prepare()
1178 static int snd_via82xx_pcm_open(struct via82xx *chip, struct viadev *viadev, in snd_via82xx_pcm_open() argument
1189 ratep = &chip->rates[viadev->direction]; in snd_via82xx_pcm_open()
1192 if (chip->spdif_on && viadev->reg_offset == 0x30) { in snd_via82xx_pcm_open()
1194 runtime->hw.rates = chip->ac97->rates[AC97_RATES_SPDIF]; in snd_via82xx_pcm_open()
1196 } else if (chip->dxs_fixed && viadev->reg_offset < 0x40) { in snd_via82xx_pcm_open()
1200 } else if (chip->dxs_src && viadev->reg_offset < 0x40) { in snd_via82xx_pcm_open()
1209 runtime->hw.rates = chip->ac97->rates[idx]; in snd_via82xx_pcm_open()
1241 struct via82xx *chip = snd_pcm_substream_chip(substream); in snd_via686_playback_open() local
1242 struct viadev *viadev = &chip->devs[chip->playback_devno + substream->number]; in snd_via686_playback_open()
1245 if ((err = snd_via82xx_pcm_open(chip, viadev, substream)) < 0) in snd_via686_playback_open()
1255 struct via82xx *chip = snd_pcm_substream_chip(substream); in snd_via8233_playback_open() local
1260 viadev = &chip->devs[chip->playback_devno + substream->number]; in snd_via8233_playback_open()
1261 if ((err = snd_via82xx_pcm_open(chip, viadev, substream)) < 0) in snd_via8233_playback_open()
1264 if (chip->dxs_controls[stream]) { in snd_via8233_playback_open()
1265 chip->playback_volume[stream][0] = in snd_via8233_playback_open()
1267 chip->playback_volume[stream][1] = in snd_via8233_playback_open()
1269 chip->dxs_controls[stream]->vd[0].access &= in snd_via8233_playback_open()
1271 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE | in snd_via8233_playback_open()
1273 &chip->dxs_controls[stream]->id); in snd_via8233_playback_open()
1283 struct via82xx *chip = snd_pcm_substream_chip(substream); in snd_via8233_multi_open() local
1284 struct viadev *viadev = &chip->devs[chip->multi_devno]; in snd_via8233_multi_open()
1298 if ((err = snd_via82xx_pcm_open(chip, viadev, substream)) < 0) in snd_via8233_multi_open()
1301 if (chip->revision == VIA_REV_8233A) in snd_via8233_multi_open()
1313 struct via82xx *chip = snd_pcm_substream_chip(substream); in snd_via82xx_capture_open() local
1314 struct viadev *viadev = &chip->devs[chip->capture_devno + substream->pcm->device]; in snd_via82xx_capture_open()
1316 return snd_via82xx_pcm_open(chip, viadev, substream); in snd_via82xx_capture_open()
1324 struct via82xx *chip = snd_pcm_substream_chip(substream); in snd_via82xx_pcm_close() local
1329 ratep = &chip->rates[viadev->direction]; in snd_via82xx_pcm_close()
1337 snd_ac97_update_power(chip->ac97, in snd_via82xx_pcm_close()
1339 snd_ac97_update_power(chip->ac97, in snd_via82xx_pcm_close()
1341 snd_ac97_update_power(chip->ac97, in snd_via82xx_pcm_close()
1344 snd_ac97_update_power(chip->ac97, in snd_via82xx_pcm_close()
1353 struct via82xx *chip = snd_pcm_substream_chip(substream); in snd_via8233_playback_close() local
1358 if (chip->dxs_controls[stream]) { in snd_via8233_playback_close()
1359 chip->dxs_controls[stream]->vd[0].access |= in snd_via8233_playback_close()
1361 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_INFO, in snd_via8233_playback_close()
1362 &chip->dxs_controls[stream]->id); in snd_via8233_playback_close()
1434 static void init_viadev(struct via82xx *chip, int idx, unsigned int reg_offset, in init_viadev() argument
1437 chip->devs[idx].reg_offset = reg_offset; in init_viadev()
1438 chip->devs[idx].shadow_shift = shadow_pos * 4; in init_viadev()
1439 chip->devs[idx].direction = direction; in init_viadev()
1440 chip->devs[idx].port = chip->port + reg_offset; in init_viadev()
1446 static int snd_via8233_pcm_new(struct via82xx *chip) in snd_via8233_pcm_new() argument
1452 chip->playback_devno = 0; /* x 4 */ in snd_via8233_pcm_new()
1453 chip->multi_devno = 4; /* x 1 */ in snd_via8233_pcm_new()
1454 chip->capture_devno = 5; /* x 2 */ in snd_via8233_pcm_new()
1455 chip->num_devs = 7; in snd_via8233_pcm_new()
1456 chip->intr_mask = 0x33033333; /* FLAG|EOL for rec0-1, mc, sdx0-3 */ in snd_via8233_pcm_new()
1459 err = snd_pcm_new(chip->card, chip->card->shortname, 0, 4, 1, &pcm); in snd_via8233_pcm_new()
1464 pcm->private_data = chip; in snd_via8233_pcm_new()
1465 strcpy(pcm->name, chip->card->shortname); in snd_via8233_pcm_new()
1466 chip->pcms[0] = pcm; in snd_via8233_pcm_new()
1469 init_viadev(chip, i, 0x10 * i, i, 0); in snd_via8233_pcm_new()
1471 init_viadev(chip, chip->capture_devno, VIA_REG_CAPTURE_8233_STATUS, 6, 1); in snd_via8233_pcm_new()
1474 snd_dma_pci_data(chip->pci), in snd_via8233_pcm_new()
1484 err = snd_pcm_new(chip->card, chip->card->shortname, 1, 1, 1, &pcm); in snd_via8233_pcm_new()
1489 pcm->private_data = chip; in snd_via8233_pcm_new()
1490 strcpy(pcm->name, chip->card->shortname); in snd_via8233_pcm_new()
1491 chip->pcms[1] = pcm; in snd_via8233_pcm_new()
1493 init_viadev(chip, chip->multi_devno, VIA_REG_MULTPLAY_STATUS, 4, 0); in snd_via8233_pcm_new()
1495 init_viadev(chip, chip->capture_devno + 1, VIA_REG_CAPTURE_8233_STATUS + 0x10, 7, 1); in snd_via8233_pcm_new()
1498 snd_dma_pci_data(chip->pci), in snd_via8233_pcm_new()
1506 chip->ac97->chmaps[SNDRV_PCM_STREAM_PLAYBACK] = chmap; in snd_via8233_pcm_new()
1514 static int snd_via8233a_pcm_new(struct via82xx *chip) in snd_via8233a_pcm_new() argument
1520 chip->multi_devno = 0; in snd_via8233a_pcm_new()
1521 chip->playback_devno = 1; in snd_via8233a_pcm_new()
1522 chip->capture_devno = 2; in snd_via8233a_pcm_new()
1523 chip->num_devs = 3; in snd_via8233a_pcm_new()
1524 chip->intr_mask = 0x03033000; /* FLAG|EOL for rec0, mc, sdx3 */ in snd_via8233a_pcm_new()
1527 err = snd_pcm_new(chip->card, chip->card->shortname, 0, 1, 1, &pcm); in snd_via8233a_pcm_new()
1532 pcm->private_data = chip; in snd_via8233a_pcm_new()
1533 strcpy(pcm->name, chip->card->shortname); in snd_via8233a_pcm_new()
1534 chip->pcms[0] = pcm; in snd_via8233a_pcm_new()
1536 init_viadev(chip, chip->multi_devno, VIA_REG_MULTPLAY_STATUS, 4, 0); in snd_via8233a_pcm_new()
1538 init_viadev(chip, chip->capture_devno, VIA_REG_CAPTURE_8233_STATUS, 6, 1); in snd_via8233a_pcm_new()
1541 snd_dma_pci_data(chip->pci), in snd_via8233a_pcm_new()
1549 chip->ac97->chmaps[SNDRV_PCM_STREAM_PLAYBACK] = chmap; in snd_via8233a_pcm_new()
1552 if (! ac97_can_spdif(chip->ac97)) in snd_via8233a_pcm_new()
1556 err = snd_pcm_new(chip->card, chip->card->shortname, 1, 1, 0, &pcm); in snd_via8233a_pcm_new()
1560 pcm->private_data = chip; in snd_via8233a_pcm_new()
1561 strcpy(pcm->name, chip->card->shortname); in snd_via8233a_pcm_new()
1562 chip->pcms[1] = pcm; in snd_via8233a_pcm_new()
1564 init_viadev(chip, chip->playback_devno, 0x30, 3, 0); in snd_via8233a_pcm_new()
1567 snd_dma_pci_data(chip->pci), in snd_via8233a_pcm_new()
1575 static int snd_via686_pcm_new(struct via82xx *chip) in snd_via686_pcm_new() argument
1580 chip->playback_devno = 0; in snd_via686_pcm_new()
1581 chip->capture_devno = 1; in snd_via686_pcm_new()
1582 chip->num_devs = 2; in snd_via686_pcm_new()
1583 chip->intr_mask = 0x77; /* FLAG | EOL for PB, CP, FM */ in snd_via686_pcm_new()
1585 err = snd_pcm_new(chip->card, chip->card->shortname, 0, 1, 1, &pcm); in snd_via686_pcm_new()
1590 pcm->private_data = chip; in snd_via686_pcm_new()
1591 strcpy(pcm->name, chip->card->shortname); in snd_via686_pcm_new()
1592 chip->pcms[0] = pcm; in snd_via686_pcm_new()
1593 init_viadev(chip, 0, VIA_REG_PLAYBACK_STATUS, 0, 0); in snd_via686_pcm_new()
1594 init_viadev(chip, 1, VIA_REG_CAPTURE_STATUS, 0, 1); in snd_via686_pcm_new()
1597 snd_dma_pci_data(chip->pci), in snd_via686_pcm_new()
1622 struct via82xx *chip = snd_kcontrol_chip(kcontrol); in snd_via8233_capture_source_get() local
1623 …unsigned long port = chip->port + (kcontrol->id.index ? (VIA_REG_CAPTURE_CHANNEL + 0x10) : VIA_REG… in snd_via8233_capture_source_get()
1631 struct via82xx *chip = snd_kcontrol_chip(kcontrol); in snd_via8233_capture_source_put() local
1632 …unsigned long port = chip->port + (kcontrol->id.index ? (VIA_REG_CAPTURE_CHANNEL + 0x10) : VIA_REG… in snd_via8233_capture_source_put()
1635 spin_lock_irq(&chip->reg_lock); in snd_via8233_capture_source_put()
1642 spin_unlock_irq(&chip->reg_lock); in snd_via8233_capture_source_put()
1659 struct via82xx *chip = snd_kcontrol_chip(kcontrol); in snd_via8233_dxs3_spdif_get() local
1662 pci_read_config_byte(chip->pci, VIA8233_SPDIF_CTRL, &val); in snd_via8233_dxs3_spdif_get()
1670 struct via82xx *chip = snd_kcontrol_chip(kcontrol); in snd_via8233_dxs3_spdif_put() local
1673 pci_read_config_byte(chip->pci, VIA8233_SPDIF_CTRL, &oval); in snd_via8233_dxs3_spdif_put()
1678 chip->spdif_on = ucontrol->value.integer.value[0] ? 1 : 0; in snd_via8233_dxs3_spdif_put()
1680 pci_write_config_byte(chip->pci, VIA8233_SPDIF_CTRL, val); in snd_via8233_dxs3_spdif_put()
1707 struct via82xx *chip = snd_kcontrol_chip(kcontrol); in snd_via8233_dxs_volume_get() local
1710 ucontrol->value.integer.value[0] = VIA_DXS_MAX_VOLUME - chip->playback_volume[idx][0]; in snd_via8233_dxs_volume_get()
1711 ucontrol->value.integer.value[1] = VIA_DXS_MAX_VOLUME - chip->playback_volume[idx][1]; in snd_via8233_dxs_volume_get()
1718 struct via82xx *chip = snd_kcontrol_chip(kcontrol); in snd_via8233_pcmdxs_volume_get() local
1719 ucontrol->value.integer.value[0] = VIA_DXS_MAX_VOLUME - chip->playback_volume_c[0]; in snd_via8233_pcmdxs_volume_get()
1720 ucontrol->value.integer.value[1] = VIA_DXS_MAX_VOLUME - chip->playback_volume_c[1]; in snd_via8233_pcmdxs_volume_get()
1727 struct via82xx *chip = snd_kcontrol_chip(kcontrol); in snd_via8233_dxs_volume_put() local
1729 unsigned long port = chip->port + 0x10 * idx; in snd_via8233_dxs_volume_put()
1738 change |= val != chip->playback_volume[idx][i]; in snd_via8233_dxs_volume_put()
1740 chip->playback_volume[idx][i] = val; in snd_via8233_dxs_volume_put()
1750 struct via82xx *chip = snd_kcontrol_chip(kcontrol); in snd_via8233_pcmdxs_volume_put() local
1760 if (val != chip->playback_volume_c[i]) { in snd_via8233_pcmdxs_volume_put()
1762 chip->playback_volume_c[i] = val; in snd_via8233_pcmdxs_volume_put()
1764 unsigned long port = chip->port + 0x10 * idx; in snd_via8233_pcmdxs_volume_put()
1765 chip->playback_volume[idx][i] = val; in snd_via8233_pcmdxs_volume_put()
1805 struct via82xx *chip = bus->private_data; in snd_via82xx_mixer_free_ac97_bus() local
1806 chip->ac97_bus = NULL; in snd_via82xx_mixer_free_ac97_bus()
1811 struct via82xx *chip = ac97->private_data; in snd_via82xx_mixer_free_ac97() local
1812 chip->ac97 = NULL; in snd_via82xx_mixer_free_ac97()
1898 static int snd_via82xx_mixer_new(struct via82xx *chip, const char *quirk_override) in snd_via82xx_mixer_new() argument
1908 if ((err = snd_ac97_bus(chip->card, 0, &ops, chip, &chip->ac97_bus)) < 0) in snd_via82xx_mixer_new()
1910 chip->ac97_bus->private_free = snd_via82xx_mixer_free_ac97_bus; in snd_via82xx_mixer_new()
1911 chip->ac97_bus->clock = chip->ac97_clock; in snd_via82xx_mixer_new()
1914 ac97.private_data = chip; in snd_via82xx_mixer_new()
1916 ac97.pci = chip->pci; in snd_via82xx_mixer_new()
1918 if ((err = snd_ac97_mixer(chip->ac97_bus, &ac97, &chip->ac97)) < 0) in snd_via82xx_mixer_new()
1921 snd_ac97_tune_hardware(chip->ac97, ac97_quirks, quirk_override); in snd_via82xx_mixer_new()
1923 if (chip->chip_type != TYPE_VIA686) { in snd_via82xx_mixer_new()
1925 snd_ac97_update_bits(chip->ac97, AC97_EXTENDED_STATUS, 0x03 << 4, 0x03 << 4); in snd_via82xx_mixer_new()
1933 static int snd_via686_create_gameport(struct via82xx *chip, unsigned char *legacy) in snd_via686_create_gameport() argument
1943 dev_warn(chip->card->dev, "cannot reserve joystick port %#x\n", in snd_via686_create_gameport()
1948 chip->gameport = gp = gameport_allocate_port(); in snd_via686_create_gameport()
1950 dev_err(chip->card->dev, in snd_via686_create_gameport()
1957 gameport_set_phys(gp, "pci%s/gameport0", pci_name(chip->pci)); in snd_via686_create_gameport()
1958 gameport_set_dev_parent(gp, &chip->pci->dev); in snd_via686_create_gameport()
1964 pci_write_config_byte(chip->pci, VIA_FUNC_ENABLE, *legacy); in snd_via686_create_gameport()
1966 gameport_register_port(chip->gameport); in snd_via686_create_gameport()
1971 static void snd_via686_free_gameport(struct via82xx *chip) in snd_via686_free_gameport() argument
1973 if (chip->gameport) { in snd_via686_free_gameport()
1974 struct resource *r = gameport_get_port_data(chip->gameport); in snd_via686_free_gameport()
1976 gameport_unregister_port(chip->gameport); in snd_via686_free_gameport()
1977 chip->gameport = NULL; in snd_via686_free_gameport()
1982 static inline int snd_via686_create_gameport(struct via82xx *chip, unsigned char *legacy) in snd_via686_create_gameport() argument
1986 static inline void snd_via686_free_gameport(struct via82xx *chip) { } in snd_via686_free_gameport() argument
1994 static int snd_via8233_init_misc(struct via82xx *chip) in snd_via8233_init_misc() argument
1999 caps = chip->chip_type == TYPE_VIA8233A ? 1 : 2; in snd_via8233_init_misc()
2002 err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_via8233_capture_source, chip)); in snd_via8233_init_misc()
2006 if (ac97_can_spdif(chip->ac97)) { in snd_via8233_init_misc()
2007 err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_via8233_dxs3_spdif_control, chip)); in snd_via8233_init_misc()
2011 if (chip->chip_type != TYPE_VIA8233A) { in snd_via8233_init_misc()
2019 if (! snd_ctl_find_id(chip->card, &sid)) { in snd_via8233_init_misc()
2020 dev_info(chip->card->dev, in snd_via8233_init_misc()
2022 err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_via8233_pcmdxs_volume_control, chip)); in snd_via8233_init_misc()
2032 &snd_via8233_dxs_volume_control, chip); in snd_via8233_init_misc()
2036 err = snd_ctl_add(chip->card, kctl); in snd_via8233_init_misc()
2039 chip->dxs_controls[i] = kctl; in snd_via8233_init_misc()
2044 pci_read_config_byte(chip->pci, VIA8233_SPDIF_CTRL, &val); in snd_via8233_init_misc()
2047 pci_write_config_byte(chip->pci, VIA8233_SPDIF_CTRL, val); in snd_via8233_init_misc()
2052 static int snd_via686_init_misc(struct via82xx *chip) in snd_via686_init_misc() argument
2057 legacy = chip->old_legacy; in snd_via686_init_misc()
2058 legacy_cfg = chip->old_legacy_cfg; in snd_via686_init_misc()
2061 if (chip->revision >= VIA_REV_686_H) { in snd_via686_init_misc()
2065 pci_write_config_dword(chip->pci, 0x18, mpu_port | 0x01); in snd_via686_init_misc()
2067 chip->mpu_port_saved = mpu_port; in snd_via686_init_misc()
2070 mpu_port = pci_resource_start(chip->pci, 2); in snd_via686_init_misc()
2088 (chip->mpu_res = request_region(mpu_port, 2, "VIA82xx MPU401")) in snd_via686_init_misc()
2100 pci_write_config_byte(chip->pci, VIA_FUNC_ENABLE, legacy); in snd_via686_init_misc()
2101 pci_write_config_byte(chip->pci, VIA_PNP_CONTROL, legacy_cfg); in snd_via686_init_misc()
2102 if (chip->mpu_res) { in snd_via686_init_misc()
2103 if (snd_mpu401_uart_new(chip->card, 0, MPU401_HW_VIA686A, in snd_via686_init_misc()
2106 &chip->rmidi) < 0) { in snd_via686_init_misc()
2107 dev_warn(chip->card->dev, in snd_via686_init_misc()
2114 pci_write_config_byte(chip->pci, VIA_FUNC_ENABLE, legacy); in snd_via686_init_misc()
2117 snd_via686_create_gameport(chip, &legacy); in snd_via686_init_misc()
2120 chip->legacy_saved = legacy; in snd_via686_init_misc()
2121 chip->legacy_cfg_saved = legacy_cfg; in snd_via686_init_misc()
2134 struct via82xx *chip = entry->private_data; in snd_via82xx_proc_read() local
2137 snd_iprintf(buffer, "%s\n\n", chip->card->longname); in snd_via82xx_proc_read()
2139 snd_iprintf(buffer, "%02x: %08x\n", i, inl(chip->port + i)); in snd_via82xx_proc_read()
2143 static void snd_via82xx_proc_init(struct via82xx *chip) in snd_via82xx_proc_init() argument
2147 if (! snd_card_proc_new(chip->card, "via82xx", &entry)) in snd_via82xx_proc_init()
2148 snd_info_set_text_ops(entry, chip, snd_via82xx_proc_read); in snd_via82xx_proc_init()
2155 static int snd_via82xx_chip_init(struct via82xx *chip) in snd_via82xx_chip_init() argument
2162 if (chip->chip_type == TYPE_VIA686) in snd_via82xx_chip_init()
2164 pci_write_config_byte(chip->pci, VIA_FUNC_ENABLE, 0); in snd_via82xx_chip_init()
2166 pci_read_config_byte(chip->pci, VIA_ACLINK_STAT, &pval); in snd_via82xx_chip_init()
2169 pci_write_config_byte(chip->pci, VIA_ACLINK_CTRL, in snd_via82xx_chip_init()
2175 pci_write_config_byte(chip->pci, VIA_ACLINK_CTRL, 0x00); in snd_via82xx_chip_init()
2179 pci_write_config_byte(chip->pci, VIA_ACLINK_CTRL, in snd_via82xx_chip_init()
2185 pci_write_config_byte(chip->pci, VIA_ACLINK_CTRL, VIA_ACLINK_CTRL_INIT); in snd_via82xx_chip_init()
2191 pci_read_config_byte(chip->pci, VIA_ACLINK_CTRL, &pval); in snd_via82xx_chip_init()
2195 pci_write_config_byte(chip->pci, VIA_ACLINK_CTRL, VIA_ACLINK_CTRL_INIT); in snd_via82xx_chip_init()
2202 pci_read_config_byte(chip->pci, VIA_ACLINK_STAT, &pval); in snd_via82xx_chip_init()
2208 if ((val = snd_via82xx_codec_xread(chip)) & VIA_REG_AC97_BUSY) in snd_via82xx_chip_init()
2209 dev_err(chip->card->dev, in snd_via82xx_chip_init()
2213 snd_via82xx_codec_xwrite(chip, VIA_REG_AC97_READ | in snd_via82xx_chip_init()
2217 snd_via82xx_codec_xwrite(chip, VIA_REG_AC97_READ | in snd_via82xx_chip_init()
2221 if ((val = snd_via82xx_codec_xread(chip)) & VIA_REG_AC97_SECONDARY_VALID) { in snd_via82xx_chip_init()
2222 chip->ac97_secondary = 1; in snd_via82xx_chip_init()
2232 if (chip->chip_type == TYPE_VIA686) { in snd_via82xx_chip_init()
2234 pci_write_config_byte(chip->pci, VIA_FM_NMI_CTRL, 0); in snd_via82xx_chip_init()
2236 outl(0, VIAREG(chip, GPI_INTR)); in snd_via82xx_chip_init()
2239 if (chip->chip_type != TYPE_VIA686) { in snd_via82xx_chip_init()
2253 if (chip->chip_type != TYPE_VIA8233A) { in snd_via82xx_chip_init()
2256 unsigned long port = chip->port + 0x10 * idx; in snd_via82xx_chip_init()
2258 chip->playback_volume[idx][i]=chip->playback_volume_c[i]; in snd_via82xx_chip_init()
2259 outb(chip->playback_volume_c[i], in snd_via82xx_chip_init()
2275 struct via82xx *chip = card->private_data; in snd_via82xx_suspend() local
2280 snd_pcm_suspend_all(chip->pcms[i]); in snd_via82xx_suspend()
2281 for (i = 0; i < chip->num_devs; i++) in snd_via82xx_suspend()
2282 snd_via82xx_channel_reset(chip, &chip->devs[i]); in snd_via82xx_suspend()
2283 synchronize_irq(chip->irq); in snd_via82xx_suspend()
2284 snd_ac97_suspend(chip->ac97); in snd_via82xx_suspend()
2287 if (chip->chip_type != TYPE_VIA686) { in snd_via82xx_suspend()
2288 pci_read_config_byte(chip->pci, VIA8233_SPDIF_CTRL, &chip->spdif_ctrl_saved); in snd_via82xx_suspend()
2289 chip->capture_src_saved[0] = inb(chip->port + VIA_REG_CAPTURE_CHANNEL); in snd_via82xx_suspend()
2290 chip->capture_src_saved[1] = inb(chip->port + VIA_REG_CAPTURE_CHANNEL + 0x10); in snd_via82xx_suspend()
2299 struct via82xx *chip = card->private_data; in snd_via82xx_resume() local
2302 snd_via82xx_chip_init(chip); in snd_via82xx_resume()
2304 if (chip->chip_type == TYPE_VIA686) { in snd_via82xx_resume()
2305 if (chip->mpu_port_saved) in snd_via82xx_resume()
2306 pci_write_config_dword(chip->pci, 0x18, chip->mpu_port_saved | 0x01); in snd_via82xx_resume()
2307 pci_write_config_byte(chip->pci, VIA_FUNC_ENABLE, chip->legacy_saved); in snd_via82xx_resume()
2308 pci_write_config_byte(chip->pci, VIA_PNP_CONTROL, chip->legacy_cfg_saved); in snd_via82xx_resume()
2310 pci_write_config_byte(chip->pci, VIA8233_SPDIF_CTRL, chip->spdif_ctrl_saved); in snd_via82xx_resume()
2311 outb(chip->capture_src_saved[0], chip->port + VIA_REG_CAPTURE_CHANNEL); in snd_via82xx_resume()
2312 outb(chip->capture_src_saved[1], chip->port + VIA_REG_CAPTURE_CHANNEL + 0x10); in snd_via82xx_resume()
2315 snd_ac97_resume(chip->ac97); in snd_via82xx_resume()
2317 for (i = 0; i < chip->num_devs; i++) in snd_via82xx_resume()
2318 snd_via82xx_channel_reset(chip, &chip->devs[i]); in snd_via82xx_resume()
2330 static int snd_via82xx_free(struct via82xx *chip) in snd_via82xx_free() argument
2334 if (chip->irq < 0) in snd_via82xx_free()
2337 for (i = 0; i < chip->num_devs; i++) in snd_via82xx_free()
2338 snd_via82xx_channel_reset(chip, &chip->devs[i]); in snd_via82xx_free()
2340 if (chip->irq >= 0) in snd_via82xx_free()
2341 free_irq(chip->irq, chip); in snd_via82xx_free()
2343 release_and_free_resource(chip->mpu_res); in snd_via82xx_free()
2344 pci_release_regions(chip->pci); in snd_via82xx_free()
2346 if (chip->chip_type == TYPE_VIA686) { in snd_via82xx_free()
2347 snd_via686_free_gameport(chip); in snd_via82xx_free()
2348 pci_write_config_byte(chip->pci, VIA_FUNC_ENABLE, chip->old_legacy); in snd_via82xx_free()
2349 pci_write_config_byte(chip->pci, VIA_PNP_CONTROL, chip->old_legacy_cfg); in snd_via82xx_free()
2351 pci_disable_device(chip->pci); in snd_via82xx_free()
2352 kfree(chip); in snd_via82xx_free()
2358 struct via82xx *chip = device->device_data; in snd_via82xx_dev_free() local
2359 return snd_via82xx_free(chip); in snd_via82xx_dev_free()
2369 struct via82xx *chip; in snd_via82xx_create() local
2378 if ((chip = kzalloc(sizeof(*chip), GFP_KERNEL)) == NULL) { in snd_via82xx_create()
2383 chip->chip_type = chip_type; in snd_via82xx_create()
2384 chip->revision = revision; in snd_via82xx_create()
2386 spin_lock_init(&chip->reg_lock); in snd_via82xx_create()
2387 spin_lock_init(&chip->rates[0].lock); in snd_via82xx_create()
2388 spin_lock_init(&chip->rates[1].lock); in snd_via82xx_create()
2389 chip->card = card; in snd_via82xx_create()
2390 chip->pci = pci; in snd_via82xx_create()
2391 chip->irq = -1; in snd_via82xx_create()
2393 pci_read_config_byte(pci, VIA_FUNC_ENABLE, &chip->old_legacy); in snd_via82xx_create()
2394 pci_read_config_byte(pci, VIA_PNP_CONTROL, &chip->old_legacy_cfg); in snd_via82xx_create()
2395 pci_write_config_byte(chip->pci, VIA_FUNC_ENABLE, in snd_via82xx_create()
2396 chip->old_legacy & ~(VIA_FUNC_ENABLE_SB|VIA_FUNC_ENABLE_FM)); in snd_via82xx_create()
2399 kfree(chip); in snd_via82xx_create()
2403 chip->port = pci_resource_start(pci, 0); in snd_via82xx_create()
2408 KBUILD_MODNAME, chip)) { in snd_via82xx_create()
2410 snd_via82xx_free(chip); in snd_via82xx_create()
2413 chip->irq = pci->irq; in snd_via82xx_create()
2415 chip->ac97_clock = ac97_clock; in snd_via82xx_create()
2416 synchronize_irq(chip->irq); in snd_via82xx_create()
2418 if ((err = snd_via82xx_chip_init(chip)) < 0) { in snd_via82xx_create()
2419 snd_via82xx_free(chip); in snd_via82xx_create()
2423 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { in snd_via82xx_create()
2424 snd_via82xx_free(chip); in snd_via82xx_create()
2433 *r_via = chip; in snd_via82xx_create()
2529 struct via82xx *chip; in snd_via82xx_probe() local
2580 ac97_clock, &chip)) < 0) in snd_via82xx_probe()
2582 card->private_data = chip; in snd_via82xx_probe()
2583 if ((err = snd_via82xx_mixer_new(chip, ac97_quirk)) < 0) in snd_via82xx_probe()
2587 if ((err = snd_via686_pcm_new(chip)) < 0 || in snd_via82xx_probe()
2588 (err = snd_via686_init_misc(chip)) < 0) in snd_via82xx_probe()
2592 if ((err = snd_via8233a_pcm_new(chip)) < 0) in snd_via82xx_probe()
2596 if ((err = snd_via8233_pcm_new(chip)) < 0) in snd_via82xx_probe()
2599 chip->dxs_fixed = 1; in snd_via82xx_probe()
2601 chip->no_vra = 1; in snd_via82xx_probe()
2603 chip->no_vra = 1; in snd_via82xx_probe()
2604 chip->dxs_src = 1; in snd_via82xx_probe()
2607 if ((err = snd_via8233_init_misc(chip)) < 0) in snd_via82xx_probe()
2612 for (i = 0; i < chip->num_devs; i++) in snd_via82xx_probe()
2613 snd_via82xx_channel_reset(chip, &chip->devs[i]); in snd_via82xx_probe()
2617 snd_ac97_get_short_name(chip->ac97), chip->port, chip->irq); in snd_via82xx_probe()
2619 snd_via82xx_proc_init(chip); in snd_via82xx_probe()