Lines Matching +full:short +full:- +full:press +full:- +full:ms

1 // SPDX-License-Identifier: GPL-2.0-or-later
12 * - Fixed deadlock on capture
13 * - Added Canyon3D-2 support by Rob Riggs <rob@pangalactic.org>
16 #define CARD_NAME "ESS Maestro3/Allegro/Canyon3D-2"
24 #include <linux/dma-mapping.h>
45 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
48 static bool external_amp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
49 static int amp_gpio[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = -1};
60 MODULE_PARM_DESC(amp_gpio, "GPIO pin number for external amp. (default = -1)");
365 #define REV_A_CODE_MEMORY_LENGTH (REV_A_CODE_MEMORY_END - REV_A_CODE_MEMORY_BEGIN + 1)
370 #define REV_B_CODE_MEMORY_LENGTH (REV_B_CODE_MEMORY_END - REV_B_CODE_MEMORY_BEGIN + 1)
375 #define REV_A_DATA_MEMORY_LENGTH (REV_A_DATA_MEMORY_END - REV_A_DATA_MEMORY_BEGIN + 1)
380 #define REV_B_DATA_MEMORY_LENGTH (REV_B_DATA_MEMORY_END - REV_B_DATA_MEMORY_BEGIN + 1)
594 #define MAX_INSTANCE_MINISRC (KDATA_INSTANCE_MINISRC_ENDMARK - KDATA_INSTANCE0_MINISRC)
595 #define MAX_VIRTUAL_DMA_CHANNELS (KDATA_DMA_XFER_ENDMARK - KDATA_DMA_XFER0)
596 #define MAX_VIRTUAL_MIXER_CHANNELS (KDATA_MIXER_XFER_ENDMARK - KDATA_MIXER_XFER0)
597 #define MAX_VIRTUAL_ADC1_CHANNELS (KDATA_ADC1_XFER_ENDMARK - KDATA_ADC1_XFER0)
698 unsigned short code, data;
746 int amp_gpio; /* gpio pin # for external amp, -1 = default */
747 unsigned int hv_config; /* hardware-volume config bits */
805 SND_PCI_QUIRK(0x10f7, 0x833e, "Panasonic CF-28", 0x0d),
806 SND_PCI_QUIRK(0x10f7, 0x833d, "Panasonic CF-72", 0x0d),
910 outw(value, chip->iobase + reg); in snd_m3_outw()
915 return inw(chip->iobase + reg); in snd_m3_inw()
920 outb(value, chip->iobase + reg); in snd_m3_outb()
925 return inb(chip->iobase + reg); in snd_m3_inb()
948 chip->reset_state = snd_m3_inb(chip, DSP_PORT_CONTROL_REG_B) & ~REGB_STOP_CLOCK; in snd_m3_assp_halt()
950 snd_m3_outb(chip, chip->reset_state & ~REGB_ENABLE_RESET, DSP_PORT_CONTROL_REG_B); in snd_m3_assp_halt()
955 snd_m3_outb(chip, chip->reset_state | REGB_ENABLE_RESET, DSP_PORT_CONTROL_REG_B); in snd_m3_assp_continue()
970 list->mem_addr + list->curlen, in snd_m3_add_list()
972 return list->curlen++; in snd_m3_add_list()
978 int lastindex = list->curlen - 1; in snd_m3_remove_list()
982 list->mem_addr + lastindex); in snd_m3_remove_list()
984 list->mem_addr + index, in snd_m3_remove_list()
989 list->mem_addr + lastindex, in snd_m3_remove_list()
992 list->curlen--; in snd_m3_remove_list()
997 chip->timer_users++; in snd_m3_inc_timer_users()
998 if (chip->timer_users != 1) in snd_m3_inc_timer_users()
1016 chip->timer_users--; in snd_m3_dec_timer_users()
1017 if (chip->timer_users > 0) in snd_m3_dec_timer_users()
1042 return -EINVAL; in snd_m3_pcm_start()
1045 switch (subs->stream) { in snd_m3_pcm_start()
1047 chip->dacs_active++; in snd_m3_pcm_start()
1049 s->inst.data + CDATA_INSTANCE_READY, 1); in snd_m3_pcm_start()
1052 chip->dacs_active); in snd_m3_pcm_start()
1058 s->inst.data + CDATA_INSTANCE_READY, 1); in snd_m3_pcm_start()
1069 return -EINVAL; in snd_m3_pcm_stop()
1072 s->inst.data + CDATA_INSTANCE_READY, 0); in snd_m3_pcm_stop()
1074 switch (subs->stream) { in snd_m3_pcm_stop()
1076 chip->dacs_active--; in snd_m3_pcm_stop()
1079 chip->dacs_active); in snd_m3_pcm_stop()
1093 struct m3_dma *s = subs->runtime->private_data; in snd_m3_pcm_trigger()
1094 int err = -EINVAL; in snd_m3_pcm_trigger()
1097 return -ENXIO; in snd_m3_pcm_trigger()
1099 spin_lock(&chip->reg_lock); in snd_m3_pcm_trigger()
1103 if (s->running) in snd_m3_pcm_trigger()
1104 err = -EBUSY; in snd_m3_pcm_trigger()
1106 s->running = 1; in snd_m3_pcm_trigger()
1112 if (! s->running) in snd_m3_pcm_trigger()
1115 s->running = 0; in snd_m3_pcm_trigger()
1120 spin_unlock(&chip->reg_lock); in snd_m3_pcm_trigger()
1131 struct snd_pcm_runtime *runtime = subs->runtime; in snd_m3_pcm_setup1()
1133 if (subs->stream == SNDRV_PCM_STREAM_PLAYBACK) { in snd_m3_pcm_setup1()
1134 dsp_in_size = MINISRC_IN_BUFFER_SIZE - (0x20 * 2); in snd_m3_pcm_setup1()
1135 dsp_out_size = MINISRC_OUT_BUFFER_SIZE - (0x20 * 2); in snd_m3_pcm_setup1()
1137 dsp_in_size = MINISRC_IN_BUFFER_SIZE - (0x10 * 2); in snd_m3_pcm_setup1()
1138 dsp_out_size = MINISRC_OUT_BUFFER_SIZE - (0x10 * 2); in snd_m3_pcm_setup1()
1140 dsp_in_buffer = s->inst.data + (MINISRC_TMP_BUFFER_SIZE / 2); in snd_m3_pcm_setup1()
1143 s->dma_size = frames_to_bytes(runtime, runtime->buffer_size); in snd_m3_pcm_setup1()
1144 s->period_size = frames_to_bytes(runtime, runtime->period_size); in snd_m3_pcm_setup1()
1145 s->hwptr = 0; in snd_m3_pcm_setup1()
1146 s->count = 0; in snd_m3_pcm_setup1()
1153 s->inst.data + CDATA_HOST_SRC_ADDRL, in snd_m3_pcm_setup1()
1154 LO(s->buffer_addr)); in snd_m3_pcm_setup1()
1157 s->inst.data + CDATA_HOST_SRC_ADDRH, in snd_m3_pcm_setup1()
1158 HI(s->buffer_addr)); in snd_m3_pcm_setup1()
1161 s->inst.data + CDATA_HOST_SRC_END_PLUS_1L, in snd_m3_pcm_setup1()
1162 LO(s->buffer_addr + s->dma_size)); in snd_m3_pcm_setup1()
1165 s->inst.data + CDATA_HOST_SRC_END_PLUS_1H, in snd_m3_pcm_setup1()
1166 HI(s->buffer_addr + s->dma_size)); in snd_m3_pcm_setup1()
1169 s->inst.data + CDATA_HOST_SRC_CURRENTL, in snd_m3_pcm_setup1()
1170 LO(s->buffer_addr)); in snd_m3_pcm_setup1()
1173 s->inst.data + CDATA_HOST_SRC_CURRENTH, in snd_m3_pcm_setup1()
1174 HI(s->buffer_addr)); in snd_m3_pcm_setup1()
1181 s->inst.data + CDATA_IN_BUF_BEGIN, in snd_m3_pcm_setup1()
1185 s->inst.data + CDATA_IN_BUF_END_PLUS_1, in snd_m3_pcm_setup1()
1189 s->inst.data + CDATA_IN_BUF_HEAD, in snd_m3_pcm_setup1()
1193 s->inst.data + CDATA_IN_BUF_TAIL, in snd_m3_pcm_setup1()
1197 s->inst.data + CDATA_OUT_BUF_BEGIN, in snd_m3_pcm_setup1()
1201 s->inst.data + CDATA_OUT_BUF_END_PLUS_1, in snd_m3_pcm_setup1()
1205 s->inst.data + CDATA_OUT_BUF_HEAD, in snd_m3_pcm_setup1()
1209 s->inst.data + CDATA_OUT_BUF_TAIL, in snd_m3_pcm_setup1()
1221 if (! s->in_lists) { in snd_m3_pcm_setup2()
1222 s->index[0] = snd_m3_add_list(chip, s->index_list[0], in snd_m3_pcm_setup2()
1223 s->inst.data >> DP_SHIFT_COUNT); in snd_m3_pcm_setup2()
1224 s->index[1] = snd_m3_add_list(chip, s->index_list[1], in snd_m3_pcm_setup2()
1225 s->inst.data >> DP_SHIFT_COUNT); in snd_m3_pcm_setup2()
1226 s->index[2] = snd_m3_add_list(chip, s->index_list[2], in snd_m3_pcm_setup2()
1227 s->inst.data >> DP_SHIFT_COUNT); in snd_m3_pcm_setup2()
1228 s->in_lists = 1; in snd_m3_pcm_setup2()
1233 s->inst.data + SRC3_DIRECTION_OFFSET + 1, in snd_m3_pcm_setup2()
1234 runtime->channels == 2 ? 0 : 1); in snd_m3_pcm_setup2()
1237 s->inst.data + SRC3_DIRECTION_OFFSET + 2, in snd_m3_pcm_setup2()
1238 snd_pcm_format_width(runtime->format) == 16 ? 0 : 1); in snd_m3_pcm_setup2()
1241 freq = DIV_ROUND_CLOSEST(runtime->rate << 15, 48000); in snd_m3_pcm_setup2()
1243 freq--; in snd_m3_pcm_setup2()
1246 s->inst.data + CDATA_FREQUENCY, in snd_m3_pcm_setup2()
1272 {SRC3_DIRECTION_OFFSET + 18, MINISRC_BIQUAD_STAGE - 1}, /* numstage */
1290 s->inst.data + SRC3_DIRECTION_OFFSET + 12, in snd_m3_playback_setup()
1291 s->inst.data + 40 + 8); in snd_m3_playback_setup()
1294 s->inst.data + SRC3_DIRECTION_OFFSET + 19, in snd_m3_playback_setup()
1295 s->inst.code + MINISRC_COEF_LOC); in snd_m3_playback_setup()
1299 s->inst.data + SRC3_DIRECTION_OFFSET + 22, in snd_m3_playback_setup()
1300 subs->runtime->rate > 45000 ? 0xff : 0); in snd_m3_playback_setup()
1304 s->inst.data + CDATA_DMA_CONTROL, in snd_m3_playback_setup()
1312 s->inst.data + pv[i].addr, pv[i].val); in snd_m3_playback_setup()
1356 s->inst.data + SRC3_DIRECTION_OFFSET + 12, in snd_m3_capture_setup()
1357 s->inst.data + 40 + 8); in snd_m3_capture_setup()
1361 s->inst.data + CDATA_DMA_CONTROL, in snd_m3_capture_setup()
1370 s->inst.data + rv[i].addr, rv[i].val); in snd_m3_capture_setup()
1376 struct m3_dma *s = substream->runtime->private_data; in snd_m3_pcm_hw_params()
1379 s->buffer_addr = substream->runtime->dma_addr; in snd_m3_pcm_hw_params()
1380 if (s->buffer_addr & 0x3) { in snd_m3_pcm_hw_params()
1381 dev_err(substream->pcm->card->dev, "oh my, not aligned\n"); in snd_m3_pcm_hw_params()
1382 s->buffer_addr = s->buffer_addr & ~0x3; in snd_m3_pcm_hw_params()
1391 if (substream->runtime->private_data == NULL) in snd_m3_pcm_hw_free()
1393 s = substream->runtime->private_data; in snd_m3_pcm_hw_free()
1394 s->buffer_addr = 0; in snd_m3_pcm_hw_free()
1402 struct snd_pcm_runtime *runtime = subs->runtime; in snd_m3_pcm_prepare()
1403 struct m3_dma *s = runtime->private_data; in snd_m3_pcm_prepare()
1406 return -ENXIO; in snd_m3_pcm_prepare()
1408 if (runtime->format != SNDRV_PCM_FORMAT_U8 && in snd_m3_pcm_prepare()
1409 runtime->format != SNDRV_PCM_FORMAT_S16_LE) in snd_m3_pcm_prepare()
1410 return -EINVAL; in snd_m3_pcm_prepare()
1411 if (runtime->rate > 48000 || in snd_m3_pcm_prepare()
1412 runtime->rate < 8000) in snd_m3_pcm_prepare()
1413 return -EINVAL; in snd_m3_pcm_prepare()
1415 spin_lock_irq(&chip->reg_lock); in snd_m3_pcm_prepare()
1419 if (subs->stream == SNDRV_PCM_STREAM_PLAYBACK) in snd_m3_pcm_prepare()
1426 spin_unlock_irq(&chip->reg_lock); in snd_m3_pcm_prepare()
1444 while (retry--) { in snd_m3_get_pointer()
1446 s->inst.data + CDATA_HOST_SRC_CURRENTH); in snd_m3_get_pointer()
1449 s->inst.data + CDATA_HOST_SRC_CURRENTL); in snd_m3_get_pointer()
1452 s->inst.data + CDATA_HOST_SRC_CURRENTH)) in snd_m3_get_pointer()
1456 return (unsigned int)(addr - s->buffer_addr); in snd_m3_get_pointer()
1464 struct m3_dma *s = subs->runtime->private_data; in snd_m3_pcm_pointer()
1469 spin_lock(&chip->reg_lock); in snd_m3_pcm_pointer()
1471 spin_unlock(&chip->reg_lock); in snd_m3_pcm_pointer()
1472 return bytes_to_frames(subs->runtime, ptr); in snd_m3_pcm_pointer()
1480 struct snd_pcm_substream *subs = s->substream; in snd_m3_update_ptr()
1484 if (! s->running) in snd_m3_update_ptr()
1490 if (hwptr >= s->dma_size) in snd_m3_update_ptr()
1491 hwptr %= s->dma_size; in snd_m3_update_ptr()
1493 diff = s->dma_size + hwptr - s->hwptr; in snd_m3_update_ptr()
1494 if (diff >= s->dma_size) in snd_m3_update_ptr()
1495 diff %= s->dma_size; in snd_m3_update_ptr()
1497 s->hwptr = hwptr; in snd_m3_update_ptr()
1498 s->count += diff; in snd_m3_update_ptr()
1500 if (s->count >= (signed)s->period_size) { in snd_m3_update_ptr()
1502 if (s->count < 2 * (signed)s->period_size) in snd_m3_update_ptr()
1503 s->count -= (signed)s->period_size; in snd_m3_update_ptr()
1505 s->count %= s->period_size; in snd_m3_update_ptr()
1507 spin_unlock(&chip->reg_lock); in snd_m3_update_ptr()
1509 spin_lock(&chip->reg_lock); in snd_m3_update_ptr()
1515 generating an interrupt. The pair of counters is stored in bits 1-3 and 5-7
1525 x = inb(chip->iobase + SHADOW_MIX_REG_VOICE) & 0xee; in snd_m3_update_hw_volume()
1536 outb(0x88, chip->iobase + SHADOW_MIX_REG_VOICE); in snd_m3_update_hw_volume()
1537 outb(0x88, chip->iobase + HW_VOL_COUNTER_VOICE); in snd_m3_update_hw_volume()
1538 outb(0x88, chip->iobase + SHADOW_MIX_REG_MASTER); in snd_m3_update_hw_volume()
1539 outb(0x88, chip->iobase + HW_VOL_COUNTER_MASTER); in snd_m3_update_hw_volume()
1542 mistaking them for a mute button press. */ in snd_m3_update_hw_volume()
1543 if (chip->in_suspend) in snd_m3_update_hw_volume()
1547 if (!chip->master_switch || !chip->master_volume) in snd_m3_update_hw_volume()
1550 val = snd_ac97_read(chip->ac97, AC97_MASTER); in snd_m3_update_hw_volume()
1559 /* counters increased by 1 -> volume up */ in snd_m3_update_hw_volume()
1561 val--; in snd_m3_update_hw_volume()
1563 val -= 0x0100; in snd_m3_update_hw_volume()
1566 /* counters decreased by 1 -> volume down */ in snd_m3_update_hw_volume()
1573 if (snd_ac97_update(chip->ac97, AC97_MASTER, val)) in snd_m3_update_hw_volume()
1574 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, in snd_m3_update_hw_volume()
1575 &chip->master_switch->id); in snd_m3_update_hw_volume()
1577 if (!chip->input_dev) in snd_m3_update_hw_volume()
1589 /* counters increased by 1 -> volume up */ in snd_m3_update_hw_volume()
1593 /* counters decreased by 1 -> volume down */ in snd_m3_update_hw_volume()
1599 input_report_key(chip->input_dev, val, 1); in snd_m3_update_hw_volume()
1600 input_sync(chip->input_dev); in snd_m3_update_hw_volume()
1601 input_report_key(chip->input_dev, val, 0); in snd_m3_update_hw_volume()
1602 input_sync(chip->input_dev); in snd_m3_update_hw_volume()
1613 status = inb(chip->iobase + HOST_INT_STATUS); in snd_m3_interrupt()
1619 schedule_work(&chip->hwvol_work); in snd_m3_interrupt()
1626 u8 ctl = inb(chip->iobase + ASSP_CONTROL_B); in snd_m3_interrupt()
1628 ctl = inb(chip->iobase + ASSP_HOST_INT_STATUS); in snd_m3_interrupt()
1630 outb(DSP2HOST_REQ_TIMER, chip->iobase + ASSP_HOST_INT_STATUS); in snd_m3_interrupt()
1632 spin_lock(&chip->reg_lock); in snd_m3_interrupt()
1633 for (i = 0; i < chip->num_substreams; i++) { in snd_m3_interrupt()
1634 struct m3_dma *s = &chip->substreams[i]; in snd_m3_interrupt()
1635 if (s->running) in snd_m3_interrupt()
1638 spin_unlock(&chip->reg_lock); in snd_m3_interrupt()
1644 if ((status & MPU401_INT_PENDING) && chip->rmidi) in snd_m3_interrupt()
1645 snd_mpu401_uart_interrupt(irq, chip->rmidi->private_data, regs); in snd_m3_interrupt()
1649 outb(status, chip->iobase + HOST_INT_STATUS); in snd_m3_interrupt()
1710 spin_lock_irq(&chip->reg_lock); in snd_m3_substream_open()
1711 for (i = 0; i < chip->num_substreams; i++) { in snd_m3_substream_open()
1712 s = &chip->substreams[i]; in snd_m3_substream_open()
1713 if (! s->opened) in snd_m3_substream_open()
1716 spin_unlock_irq(&chip->reg_lock); in snd_m3_substream_open()
1717 return -ENOMEM; in snd_m3_substream_open()
1719 s->opened = 1; in snd_m3_substream_open()
1720 s->running = 0; in snd_m3_substream_open()
1721 spin_unlock_irq(&chip->reg_lock); in snd_m3_substream_open()
1723 subs->runtime->private_data = s; in snd_m3_substream_open()
1724 s->substream = subs; in snd_m3_substream_open()
1727 if (subs->stream == SNDRV_PCM_STREAM_PLAYBACK) { in snd_m3_substream_open()
1728 s->index_list[0] = &chip->mixer_list; in snd_m3_substream_open()
1730 s->index_list[0] = &chip->adc1_list; in snd_m3_substream_open()
1731 s->index_list[1] = &chip->msrc_list; in snd_m3_substream_open()
1732 s->index_list[2] = &chip->dma_list; in snd_m3_substream_open()
1740 struct m3_dma *s = subs->runtime->private_data; in snd_m3_substream_close()
1745 spin_lock_irq(&chip->reg_lock); in snd_m3_substream_close()
1746 if (s->substream && s->running) in snd_m3_substream_close()
1747 snd_m3_pcm_stop(chip, s, s->substream); /* does this happen? */ in snd_m3_substream_close()
1748 if (s->in_lists) { in snd_m3_substream_close()
1749 snd_m3_remove_list(chip, s->index_list[0], s->index[0]); in snd_m3_substream_close()
1750 snd_m3_remove_list(chip, s->index_list[1], s->index[1]); in snd_m3_substream_close()
1751 snd_m3_remove_list(chip, s->index_list[2], s->index[2]); in snd_m3_substream_close()
1752 s->in_lists = 0; in snd_m3_substream_close()
1754 s->running = 0; in snd_m3_substream_close()
1755 s->opened = 0; in snd_m3_substream_close()
1756 spin_unlock_irq(&chip->reg_lock); in snd_m3_substream_close()
1763 struct snd_pcm_runtime *runtime = subs->runtime; in snd_m3_playback_open()
1770 runtime->hw = snd_m3_playback; in snd_m3_playback_open()
1788 struct snd_pcm_runtime *runtime = subs->runtime; in snd_m3_capture_open()
1795 runtime->hw = snd_m3_capture; in snd_m3_capture_open()
1839 err = snd_pcm_new(chip->card, chip->card->driver, device, in snd_m3_pcm()
1847 pcm->private_data = chip; in snd_m3_pcm()
1848 pcm->info_flags = 0; in snd_m3_pcm()
1849 strcpy(pcm->name, chip->card->driver); in snd_m3_pcm()
1850 chip->pcm = pcm; in snd_m3_pcm()
1853 &chip->pci->dev, 64*1024, 64*1024); in snd_m3_pcm()
1875 } while (i-- > 0); in snd_m3_ac97_wait()
1877 dev_err(chip->card->dev, "ac97 serial bus busy\n"); in snd_m3_ac97_wait()
1881 static unsigned short
1882 snd_m3_ac97_read(struct snd_ac97 *ac97, unsigned short reg) in snd_m3_ac97_read()
1884 struct snd_m3 *chip = ac97->private_data; in snd_m3_ac97_read()
1885 unsigned short data = 0xffff; in snd_m3_ac97_read()
1898 snd_m3_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short val) in snd_m3_ac97_write()
1900 struct snd_m3 *chip = ac97->private_data; in snd_m3_ac97_write()
1911 if (ac97->id == 0x45838308 && reg == AC97_MASTER) { in snd_m3_ac97_write()
1921 int io = chip->iobase; in snd_m3_remote_codec_config()
1928 if (chip->pci->subsystem_vendor == 0x1028 && in snd_m3_remote_codec_config()
1929 chip->pci->subsystem_device == 0x00e5) in snd_m3_remote_codec_config()
1962 int io = chip->iobase; in snd_m3_ac97_reset()
1964 if (chip->allegro_flag) { in snd_m3_ac97_reset()
1980 if (!chip->irda_workaround) in snd_m3_ac97_reset()
1997 /* ok, bring back the ac-link */ in snd_m3_ac97_reset()
2009 dev_dbg(chip->card->dev, in snd_m3_ac97_reset()
2010 "retrying codec reset with delays of %d and %d ms\n", in snd_m3_ac97_reset()
2015 /* more gung-ho reset that doesn't in snd_m3_ac97_reset()
2036 err = snd_ac97_bus(chip->card, 0, &ops, NULL, &pbus); in snd_m3_mixer()
2042 err = snd_ac97_mixer(pbus, &ac97, &chip->ac97); in snd_m3_mixer()
2047 snd_ac97_write(chip->ac97, AC97_PCM, 0x8000 | (15 << 8) | 15); in snd_m3_mixer()
2049 snd_ac97_write(chip->ac97, AC97_PCM, 0); in snd_m3_mixer()
2052 chip->master_switch = snd_ctl_find_id_mixer(chip->card, in snd_m3_mixer()
2054 chip->master_volume = snd_ctl_find_id_mixer(chip->card, in snd_m3_mixer()
2093 data = (const __le16 *)chip->assp_kernel_image->data; in snd_m3_assp_init()
2094 for (i = 0 ; i * 2 < chip->assp_kernel_image->size; i++) { in snd_m3_assp_init()
2106 data = (const __le16 *)chip->assp_minisrc_image->data; in snd_m3_assp_init()
2107 for (i = 0; i * 2 < chip->assp_minisrc_image->size; i++) { in snd_m3_assp_init()
2148 chip->mixer_list.curlen = 0; in snd_m3_assp_init()
2149 chip->mixer_list.mem_addr = KDATA_MIXER_XFER0; in snd_m3_assp_init()
2150 chip->mixer_list.max = MAX_VIRTUAL_MIXER_CHANNELS; in snd_m3_assp_init()
2151 chip->adc1_list.curlen = 0; in snd_m3_assp_init()
2152 chip->adc1_list.mem_addr = KDATA_ADC1_XFER0; in snd_m3_assp_init()
2153 chip->adc1_list.max = MAX_VIRTUAL_ADC1_CHANNELS; in snd_m3_assp_init()
2154 chip->dma_list.curlen = 0; in snd_m3_assp_init()
2155 chip->dma_list.mem_addr = KDATA_DMA_XFER0; in snd_m3_assp_init()
2156 chip->dma_list.max = MAX_VIRTUAL_DMA_CHANNELS; in snd_m3_assp_init()
2157 chip->msrc_list.curlen = 0; in snd_m3_assp_init()
2158 chip->msrc_list.mem_addr = KDATA_INSTANCE0_MINISRC; in snd_m3_assp_init()
2159 chip->msrc_list.max = MAX_INSTANCE_MINISRC; in snd_m3_assp_init()
2184 dev_err(chip->card->dev, in snd_m3_assp_client_init()
2187 return -ENOMEM; in snd_m3_assp_client_init()
2190 s->number = index; in snd_m3_assp_client_init()
2191 s->inst.code = 0x400; in snd_m3_assp_client_init()
2192 s->inst.data = address; in snd_m3_assp_client_init()
2194 for (i = data_bytes / 2; i > 0; address++, i--) { in snd_m3_assp_client_init()
2212 int io = chip->iobase; in snd_m3_amp_enable()
2215 if (! chip->external_amp) in snd_m3_amp_enable()
2219 polarity = polarity << chip->amp_gpio; in snd_m3_amp_enable()
2220 gpo = 1 << chip->amp_gpio; in snd_m3_amp_enable()
2236 unsigned long io = chip->iobase; in snd_m3_hv_init()
2239 if (!chip->is_omnibook) in snd_m3_hv_init()
2259 struct pci_dev *pcidev = chip->pci; in snd_m3_chip_init()
2260 unsigned long io = chip->iobase; in snd_m3_chip_init()
2273 n |= chip->hv_config; in snd_m3_chip_init()
2279 outb(RESET_ASSP, chip->iobase + ASSP_CONTROL_B); in snd_m3_chip_init()
2282 if (!chip->allegro_flag) { in snd_m3_chip_init()
2289 if (chip->allegro_flag) { in snd_m3_chip_init()
2295 t = inb(chip->iobase + ASSP_CONTROL_A); in snd_m3_chip_init()
2299 outb(t, chip->iobase + ASSP_CONTROL_A); in snd_m3_chip_init()
2302 outb(RUN_ASSP, chip->iobase + ASSP_CONTROL_B); in snd_m3_chip_init()
2316 unsigned long io = chip->iobase; in snd_m3_enable_ints()
2317 unsigned short val; in snd_m3_enable_ints()
2321 if (chip->hv_config & HV_CTRL_ENABLE) in snd_m3_enable_ints()
2323 outb(val, chip->iobase + HOST_INT_STATUS); in snd_m3_enable_ints()
2335 struct snd_m3 *chip = card->private_data; in snd_m3_free()
2339 cancel_work_sync(&chip->hwvol_work); in snd_m3_free()
2341 if (chip->substreams) { in snd_m3_free()
2342 spin_lock_irq(&chip->reg_lock); in snd_m3_free()
2343 for (i = 0; i < chip->num_substreams; i++) { in snd_m3_free()
2344 s = &chip->substreams[i]; in snd_m3_free()
2346 if (s->substream && s->running) in snd_m3_free()
2347 snd_m3_pcm_stop(chip, s, s->substream); in snd_m3_free()
2349 spin_unlock_irq(&chip->reg_lock); in snd_m3_free()
2351 if (chip->iobase) { in snd_m3_free()
2352 outw(0, chip->iobase + HOST_INT_CTRL); /* disable ints */ in snd_m3_free()
2355 vfree(chip->suspend_mem); in snd_m3_free()
2356 release_firmware(chip->assp_kernel_image); in snd_m3_free()
2357 release_firmware(chip->assp_minisrc_image); in snd_m3_free()
2367 struct snd_m3 *chip = card->private_data; in m3_suspend()
2370 if (chip->suspend_mem == NULL) in m3_suspend()
2373 chip->in_suspend = 1; in m3_suspend()
2374 cancel_work_sync(&chip->hwvol_work); in m3_suspend()
2376 snd_ac97_suspend(chip->ac97); in m3_suspend()
2385 chip->suspend_mem[dsp_index++] = in m3_suspend()
2388 chip->suspend_mem[dsp_index++] = in m3_suspend()
2396 struct snd_m3 *chip = card->private_data; in m3_resume()
2399 if (chip->suspend_mem == NULL) in m3_resume()
2414 chip->suspend_mem[dsp_index++]); in m3_resume()
2417 chip->suspend_mem[dsp_index++]); in m3_resume()
2424 snd_ac97_resume(chip->ac97); in m3_resume()
2433 chip->in_suspend = 0; in m3_resume()
2445 input_dev = devm_input_allocate_device(&chip->pci->dev); in snd_m3_input_register()
2447 return -ENOMEM; in snd_m3_input_register()
2449 snprintf(chip->phys, sizeof(chip->phys), "pci-%s/input0", in snd_m3_input_register()
2450 pci_name(chip->pci)); in snd_m3_input_register()
2452 input_dev->name = chip->card->driver; in snd_m3_input_register()
2453 input_dev->phys = chip->phys; in snd_m3_input_register()
2454 input_dev->id.bustype = BUS_PCI; in snd_m3_input_register()
2455 input_dev->id.vendor = chip->pci->vendor; in snd_m3_input_register()
2456 input_dev->id.product = chip->pci->device; in snd_m3_input_register()
2457 input_dev->dev.parent = &chip->pci->dev; in snd_m3_input_register()
2459 __set_bit(EV_KEY, input_dev->evbit); in snd_m3_input_register()
2460 __set_bit(KEY_MUTE, input_dev->keybit); in snd_m3_input_register()
2461 __set_bit(KEY_VOLUMEDOWN, input_dev->keybit); in snd_m3_input_register()
2462 __set_bit(KEY_VOLUMEUP, input_dev->keybit); in snd_m3_input_register()
2468 chip->input_dev = input_dev; in snd_m3_input_register()
2481 struct snd_m3 *chip = card->private_data; in snd_m3_create()
2486 return -EIO; in snd_m3_create()
2489 if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(28))) { in snd_m3_create()
2490 dev_err(card->dev, in snd_m3_create()
2492 return -ENXIO; in snd_m3_create()
2495 spin_lock_init(&chip->reg_lock); in snd_m3_create()
2497 switch (pci->device) { in snd_m3_create()
2502 chip->allegro_flag = 1; in snd_m3_create()
2506 chip->card = card; in snd_m3_create()
2507 chip->pci = pci; in snd_m3_create()
2508 chip->irq = -1; in snd_m3_create()
2509 INIT_WORK(&chip->hwvol_work, snd_m3_update_hw_volume); in snd_m3_create()
2510 card->private_free = snd_m3_free; in snd_m3_create()
2512 chip->external_amp = enable_amp; in snd_m3_create()
2514 chip->amp_gpio = amp_gpio; in snd_m3_create()
2518 dev_info(card->dev, "set amp-gpio for '%s'\n", in snd_m3_create()
2520 chip->amp_gpio = quirk->value; in snd_m3_create()
2521 } else if (chip->allegro_flag) in snd_m3_create()
2522 chip->amp_gpio = GPO_EXT_AMP_ALLEGRO; in snd_m3_create()
2524 chip->amp_gpio = GPO_EXT_AMP_M3; in snd_m3_create()
2529 dev_info(card->dev, "enabled irda workaround for '%s'\n", in snd_m3_create()
2531 chip->irda_workaround = 1; in snd_m3_create()
2535 chip->hv_config = quirk->value; in snd_m3_create()
2537 chip->is_omnibook = 1; in snd_m3_create()
2539 chip->num_substreams = NR_DSPS; in snd_m3_create()
2540 chip->substreams = devm_kcalloc(&pci->dev, chip->num_substreams, in snd_m3_create()
2542 if (!chip->substreams) in snd_m3_create()
2543 return -ENOMEM; in snd_m3_create()
2545 err = request_firmware(&chip->assp_kernel_image, in snd_m3_create()
2546 "ess/maestro3_assp_kernel.fw", &pci->dev); in snd_m3_create()
2550 err = request_firmware(&chip->assp_minisrc_image, in snd_m3_create()
2551 "ess/maestro3_assp_minisrc.fw", &pci->dev); in snd_m3_create()
2555 err = pci_request_regions(pci, card->driver); in snd_m3_create()
2559 chip->iobase = pci_resource_start(pci, 0); in snd_m3_create()
2573 if (devm_request_irq(&pci->dev, pci->irq, snd_m3_interrupt, IRQF_SHARED, in snd_m3_create()
2575 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq); in snd_m3_create()
2576 return -ENOMEM; in snd_m3_create()
2578 chip->irq = pci->irq; in snd_m3_create()
2579 card->sync_irq = chip->irq; in snd_m3_create()
2582 chip->suspend_mem = in snd_m3_create()
2586 if (!chip->suspend_mem) in snd_m3_create()
2587 dev_warn(card->dev, "can't allocate apm buffer\n"); in snd_m3_create()
2594 for (i = 0; i < chip->num_substreams; i++) { in snd_m3_create()
2595 struct m3_dma *s = &chip->substreams[i]; in snd_m3_create()
2606 if (chip->hv_config & HV_CTRL_ENABLE) { in snd_m3_create()
2609 dev_warn(card->dev, in snd_m3_create()
2632 if (((pci->class >> 8) & 0xffff) != PCI_CLASS_MULTIMEDIA_AUDIO) in __snd_m3_probe()
2633 return -ENODEV; in __snd_m3_probe()
2636 return -ENODEV; in __snd_m3_probe()
2639 return -ENOENT; in __snd_m3_probe()
2642 err = snd_devm_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, in __snd_m3_probe()
2646 chip = card->private_data; in __snd_m3_probe()
2648 switch (pci->device) { in __snd_m3_probe()
2651 strcpy(card->driver, "Allegro"); in __snd_m3_probe()
2655 strcpy(card->driver, "Canyon3D-2"); in __snd_m3_probe()
2658 strcpy(card->driver, "Maestro3"); in __snd_m3_probe()
2666 sprintf(card->shortname, "ESS %s PCI", card->driver); in __snd_m3_probe()
2667 sprintf(card->longname, "%s at 0x%lx, irq %d", in __snd_m3_probe()
2668 card->shortname, chip->iobase, chip->irq); in __snd_m3_probe()
2676 err = snd_mpu401_uart_new(chip->card, 0, MPU401_HW_MPU401, in __snd_m3_probe()
2677 chip->iobase + MPU401_DATA_PORT, in __snd_m3_probe()
2679 -1, &chip->rmidi); in __snd_m3_probe()
2681 dev_warn(card->dev, "no MIDI support.\n"); in __snd_m3_probe()
2692 return snd_card_free_on_error(&pci->dev, __snd_m3_probe(pci, pci_id)); in snd_m3_probe()