Lines Matching refs:chip
283 struct via82xx_modem *chip = snd_pcm_substream_chip(substream); in build_via_table() local
289 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), in build_via_table()
366 static inline unsigned int snd_via82xx_codec_xread(struct via82xx_modem *chip) in snd_via82xx_codec_xread() argument
368 return inl(VIAREG(chip, AC97)); in snd_via82xx_codec_xread()
371 static inline void snd_via82xx_codec_xwrite(struct via82xx_modem *chip, unsigned int val) in snd_via82xx_codec_xwrite() argument
373 outl(val, VIAREG(chip, AC97)); in snd_via82xx_codec_xwrite()
376 static int snd_via82xx_codec_ready(struct via82xx_modem *chip, int secondary) in snd_via82xx_codec_ready() argument
383 if (!((val = snd_via82xx_codec_xread(chip)) & VIA_REG_AC97_BUSY)) in snd_via82xx_codec_ready()
386 dev_err(chip->card->dev, "codec_ready: codec %i is not ready [0x%x]\n", in snd_via82xx_codec_ready()
387 secondary, snd_via82xx_codec_xread(chip)); in snd_via82xx_codec_ready()
391 static int snd_via82xx_codec_valid(struct via82xx_modem *chip, int secondary) in snd_via82xx_codec_valid() argument
399 val = snd_via82xx_codec_xread(chip); in snd_via82xx_codec_valid()
410 struct via82xx_modem *chip = ac97->private_data; in snd_via82xx_codec_wait() local
412 err = snd_via82xx_codec_ready(chip, ac97->num); in snd_via82xx_codec_wait()
421 struct via82xx_modem *chip = ac97->private_data; in snd_via82xx_codec_write() local
424 outl(val, VIAREG(chip, GPI_STATUS)); in snd_via82xx_codec_write()
431 snd_via82xx_codec_xwrite(chip, xval); in snd_via82xx_codec_write()
432 snd_via82xx_codec_ready(chip, ac97->num); in snd_via82xx_codec_write()
437 struct via82xx_modem *chip = ac97->private_data; in snd_via82xx_codec_read() local
447 dev_err(chip->card->dev, in snd_via82xx_codec_read()
449 ac97->num, snd_via82xx_codec_xread(chip)); in snd_via82xx_codec_read()
452 snd_via82xx_codec_xwrite(chip, xval); in snd_via82xx_codec_read()
454 if (snd_via82xx_codec_valid(chip, ac97->num) >= 0) { in snd_via82xx_codec_read()
456 val = snd_via82xx_codec_xread(chip); in snd_via82xx_codec_read()
463 static void snd_via82xx_channel_reset(struct via82xx_modem *chip, struct viadev *viadev) in snd_via82xx_channel_reset() argument
485 struct via82xx_modem *chip = dev_id; in snd_via82xx_interrupt() local
489 status = inl(VIAREG(chip, SGD_SHADOW)); in snd_via82xx_interrupt()
490 if (! (status & chip->intr_mask)) { in snd_via82xx_interrupt()
496 spin_lock(&chip->reg_lock); in snd_via82xx_interrupt()
497 for (i = 0; i < chip->num_devs; i++) { in snd_via82xx_interrupt()
498 struct viadev *viadev = &chip->devs[i]; in snd_via82xx_interrupt()
504 spin_unlock(&chip->reg_lock); in snd_via82xx_interrupt()
506 spin_lock(&chip->reg_lock); in snd_via82xx_interrupt()
510 spin_unlock(&chip->reg_lock); in snd_via82xx_interrupt()
523 struct via82xx_modem *chip = snd_pcm_substream_chip(substream); in snd_via82xx_pcm_trigger() local
549 snd_via82xx_channel_reset(chip, viadev); in snd_via82xx_pcm_trigger()
565 static inline unsigned int calc_linear_pos(struct via82xx_modem *chip, in calc_linear_pos() argument
577 dev_err(chip->card->dev, in calc_linear_pos()
583 dev_dbg(chip->card->dev, in calc_linear_pos()
590 dev_dbg(chip->card->dev, in calc_linear_pos()
603 dev_dbg(chip->card->dev, in calc_linear_pos()
620 struct via82xx_modem *chip = snd_pcm_substream_chip(substream); in snd_via686_pcm_pointer() local
629 spin_lock(&chip->reg_lock); in snd_via686_pcm_pointer()
640 res = calc_linear_pos(chip, viadev, idx, count); in snd_via686_pcm_pointer()
641 spin_unlock(&chip->reg_lock); in snd_via686_pcm_pointer()
653 struct via82xx_modem *chip = snd_pcm_substream_chip(substream); in snd_via82xx_hw_params() local
660 err = build_via_table(viadev, substream, chip->pci, in snd_via82xx_hw_params()
666 snd_ac97_write(chip->ac97, AC97_LINE1_RATE, params_rate(hw_params)); in snd_via82xx_hw_params()
667 snd_ac97_write(chip->ac97, AC97_LINE1_LEVEL, 0); in snd_via82xx_hw_params()
678 struct via82xx_modem *chip = snd_pcm_substream_chip(substream); in snd_via82xx_hw_free() local
681 clean_via_table(viadev, substream, chip->pci); in snd_via82xx_hw_free()
690 static void snd_via82xx_set_table_ptr(struct via82xx_modem *chip, struct viadev *viadev) in snd_via82xx_set_table_ptr() argument
692 snd_via82xx_codec_ready(chip, chip->ac97_secondary); in snd_via82xx_set_table_ptr()
695 snd_via82xx_codec_ready(chip, chip->ac97_secondary); in snd_via82xx_set_table_ptr()
703 struct via82xx_modem *chip = snd_pcm_substream_chip(substream); in snd_via82xx_pcm_prepare() local
706 snd_via82xx_channel_reset(chip, viadev); in snd_via82xx_pcm_prepare()
708 snd_via82xx_set_table_ptr(chip, viadev); in snd_via82xx_pcm_prepare()
742 static int snd_via82xx_modem_pcm_open(struct via82xx_modem *chip, struct viadev *viadev, in snd_via82xx_modem_pcm_open() argument
777 struct via82xx_modem *chip = snd_pcm_substream_chip(substream); in snd_via82xx_playback_open() local
778 struct viadev *viadev = &chip->devs[chip->playback_devno + substream->number]; in snd_via82xx_playback_open()
780 return snd_via82xx_modem_pcm_open(chip, viadev, substream); in snd_via82xx_playback_open()
788 struct via82xx_modem *chip = snd_pcm_substream_chip(substream); in snd_via82xx_capture_open() local
789 struct viadev *viadev = &chip->devs[chip->capture_devno + substream->pcm->device]; in snd_via82xx_capture_open()
791 return snd_via82xx_modem_pcm_open(chip, viadev, substream); in snd_via82xx_capture_open()
833 static void init_viadev(struct via82xx_modem *chip, int idx, unsigned int reg_offset, in init_viadev() argument
836 chip->devs[idx].reg_offset = reg_offset; in init_viadev()
837 chip->devs[idx].direction = direction; in init_viadev()
838 chip->devs[idx].port = chip->port + reg_offset; in init_viadev()
844 static int snd_via686_pcm_new(struct via82xx_modem *chip) in snd_via686_pcm_new() argument
849 chip->playback_devno = 0; in snd_via686_pcm_new()
850 chip->capture_devno = 1; in snd_via686_pcm_new()
851 chip->num_devs = 2; in snd_via686_pcm_new()
852 chip->intr_mask = 0x330000; /* FLAGS | EOL for MR, MW */ in snd_via686_pcm_new()
854 err = snd_pcm_new(chip->card, chip->card->shortname, 0, 1, 1, &pcm); in snd_via686_pcm_new()
860 pcm->private_data = chip; in snd_via686_pcm_new()
861 strcpy(pcm->name, chip->card->shortname); in snd_via686_pcm_new()
862 chip->pcms[0] = pcm; in snd_via686_pcm_new()
863 init_viadev(chip, 0, VIA_REG_MO_STATUS, 0); in snd_via686_pcm_new()
864 init_viadev(chip, 1, VIA_REG_MI_STATUS, 1); in snd_via686_pcm_new()
867 snd_dma_pci_data(chip->pci), in snd_via686_pcm_new()
882 struct via82xx_modem *chip = bus->private_data; in snd_via82xx_mixer_free_ac97_bus() local
883 chip->ac97_bus = NULL; in snd_via82xx_mixer_free_ac97_bus()
888 struct via82xx_modem *chip = ac97->private_data; in snd_via82xx_mixer_free_ac97() local
889 chip->ac97 = NULL; in snd_via82xx_mixer_free_ac97()
893 static int snd_via82xx_mixer_new(struct via82xx_modem *chip) in snd_via82xx_mixer_new() argument
903 if ((err = snd_ac97_bus(chip->card, 0, &ops, chip, &chip->ac97_bus)) < 0) in snd_via82xx_mixer_new()
905 chip->ac97_bus->private_free = snd_via82xx_mixer_free_ac97_bus; in snd_via82xx_mixer_new()
906 chip->ac97_bus->clock = chip->ac97_clock; in snd_via82xx_mixer_new()
909 ac97.private_data = chip; in snd_via82xx_mixer_new()
911 ac97.pci = chip->pci; in snd_via82xx_mixer_new()
913 ac97.num = chip->ac97_secondary; in snd_via82xx_mixer_new()
915 if ((err = snd_ac97_mixer(chip->ac97_bus, &ac97, &chip->ac97)) < 0) in snd_via82xx_mixer_new()
927 struct via82xx_modem *chip = entry->private_data; in snd_via82xx_proc_read() local
930 snd_iprintf(buffer, "%s\n\n", chip->card->longname); in snd_via82xx_proc_read()
932 snd_iprintf(buffer, "%02x: %08x\n", i, inl(chip->port + i)); in snd_via82xx_proc_read()
936 static void snd_via82xx_proc_init(struct via82xx_modem *chip) in snd_via82xx_proc_init() argument
940 if (! snd_card_proc_new(chip->card, "via82xx", &entry)) in snd_via82xx_proc_init()
941 snd_info_set_text_ops(entry, chip, snd_via82xx_proc_read); in snd_via82xx_proc_init()
948 static int snd_via82xx_chip_init(struct via82xx_modem *chip) in snd_via82xx_chip_init() argument
954 pci_read_config_byte(chip->pci, VIA_MC97_CTRL, &pval); in snd_via82xx_chip_init()
956 pci_write_config_byte(chip->pci, 0x44, pval|VIA_MC97_CTRL_INIT); in snd_via82xx_chip_init()
960 pci_read_config_byte(chip->pci, VIA_ACLINK_STAT, &pval); in snd_via82xx_chip_init()
963 pci_write_config_byte(chip->pci, VIA_ACLINK_CTRL, in snd_via82xx_chip_init()
969 pci_write_config_byte(chip->pci, VIA_ACLINK_CTRL, 0x00); in snd_via82xx_chip_init()
973 pci_write_config_byte(chip->pci, VIA_ACLINK_CTRL, in snd_via82xx_chip_init()
978 pci_write_config_byte(chip->pci, VIA_ACLINK_CTRL, VIA_ACLINK_CTRL_INIT); in snd_via82xx_chip_init()
982 pci_read_config_byte(chip->pci, VIA_ACLINK_CTRL, &pval); in snd_via82xx_chip_init()
985 pci_write_config_byte(chip->pci, VIA_ACLINK_CTRL, VIA_ACLINK_CTRL_INIT); in snd_via82xx_chip_init()
992 pci_read_config_byte(chip->pci, VIA_ACLINK_STAT, &pval); in snd_via82xx_chip_init()
998 if ((val = snd_via82xx_codec_xread(chip)) & VIA_REG_AC97_BUSY) in snd_via82xx_chip_init()
999 dev_err(chip->card->dev, in snd_via82xx_chip_init()
1002 snd_via82xx_codec_xwrite(chip, VIA_REG_AC97_READ | in snd_via82xx_chip_init()
1006 snd_via82xx_codec_xwrite(chip, VIA_REG_AC97_READ | in snd_via82xx_chip_init()
1010 if ((val = snd_via82xx_codec_xread(chip)) & VIA_REG_AC97_SECONDARY_VALID) { in snd_via82xx_chip_init()
1011 chip->ac97_secondary = 1; in snd_via82xx_chip_init()
1023 outl(0, VIAREG(chip, GPI_INTR)); in snd_via82xx_chip_init()
1035 struct via82xx_modem *chip = card->private_data; in snd_via82xx_suspend() local
1040 snd_pcm_suspend_all(chip->pcms[i]); in snd_via82xx_suspend()
1041 for (i = 0; i < chip->num_devs; i++) in snd_via82xx_suspend()
1042 snd_via82xx_channel_reset(chip, &chip->devs[i]); in snd_via82xx_suspend()
1043 synchronize_irq(chip->irq); in snd_via82xx_suspend()
1044 snd_ac97_suspend(chip->ac97); in snd_via82xx_suspend()
1051 struct via82xx_modem *chip = card->private_data; in snd_via82xx_resume() local
1054 snd_via82xx_chip_init(chip); in snd_via82xx_resume()
1056 snd_ac97_resume(chip->ac97); in snd_via82xx_resume()
1058 for (i = 0; i < chip->num_devs; i++) in snd_via82xx_resume()
1059 snd_via82xx_channel_reset(chip, &chip->devs[i]); in snd_via82xx_resume()
1071 static int snd_via82xx_free(struct via82xx_modem *chip) in snd_via82xx_free() argument
1075 if (chip->irq < 0) in snd_via82xx_free()
1078 for (i = 0; i < chip->num_devs; i++) in snd_via82xx_free()
1079 snd_via82xx_channel_reset(chip, &chip->devs[i]); in snd_via82xx_free()
1082 if (chip->irq >= 0) in snd_via82xx_free()
1083 free_irq(chip->irq, chip); in snd_via82xx_free()
1084 pci_release_regions(chip->pci); in snd_via82xx_free()
1085 pci_disable_device(chip->pci); in snd_via82xx_free()
1086 kfree(chip); in snd_via82xx_free()
1092 struct via82xx_modem *chip = device->device_data; in snd_via82xx_dev_free() local
1093 return snd_via82xx_free(chip); in snd_via82xx_dev_free()
1103 struct via82xx_modem *chip; in snd_via82xx_create() local
1112 if ((chip = kzalloc(sizeof(*chip), GFP_KERNEL)) == NULL) { in snd_via82xx_create()
1117 spin_lock_init(&chip->reg_lock); in snd_via82xx_create()
1118 chip->card = card; in snd_via82xx_create()
1119 chip->pci = pci; in snd_via82xx_create()
1120 chip->irq = -1; in snd_via82xx_create()
1123 kfree(chip); in snd_via82xx_create()
1127 chip->port = pci_resource_start(pci, 0); in snd_via82xx_create()
1129 KBUILD_MODNAME, chip)) { in snd_via82xx_create()
1131 snd_via82xx_free(chip); in snd_via82xx_create()
1134 chip->irq = pci->irq; in snd_via82xx_create()
1136 chip->ac97_clock = ac97_clock; in snd_via82xx_create()
1137 synchronize_irq(chip->irq); in snd_via82xx_create()
1139 if ((err = snd_via82xx_chip_init(chip)) < 0) { in snd_via82xx_create()
1140 snd_via82xx_free(chip); in snd_via82xx_create()
1144 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { in snd_via82xx_create()
1145 snd_via82xx_free(chip); in snd_via82xx_create()
1154 *r_via = chip; in snd_via82xx_create()
1163 struct via82xx_modem *chip; in snd_via82xx_probe() local
1185 ac97_clock, &chip)) < 0) in snd_via82xx_probe()
1187 card->private_data = chip; in snd_via82xx_probe()
1188 if ((err = snd_via82xx_mixer_new(chip)) < 0) in snd_via82xx_probe()
1191 if ((err = snd_via686_pcm_new(chip)) < 0 ) in snd_via82xx_probe()
1195 for (i = 0; i < chip->num_devs; i++) in snd_via82xx_probe()
1196 snd_via82xx_channel_reset(chip, &chip->devs[i]); in snd_via82xx_probe()
1199 card->shortname, chip->port, chip->irq); in snd_via82xx_probe()
1201 snd_via82xx_proc_init(chip); in snd_via82xx_probe()