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 */
807 SND_PCI_QUIRK(0x10f7, 0x833e, "Panasonic CF-28", 0x0d),
808 SND_PCI_QUIRK(0x10f7, 0x833d, "Panasonic CF-72", 0x0d),
912 outw(value, chip->iobase + reg); in snd_m3_outw()
917 return inw(chip->iobase + reg); in snd_m3_inw()
922 outb(value, chip->iobase + reg); in snd_m3_outb()
927 return inb(chip->iobase + reg); in snd_m3_inb()
950 chip->reset_state = snd_m3_inb(chip, DSP_PORT_CONTROL_REG_B) & ~REGB_STOP_CLOCK; in snd_m3_assp_halt()
952 snd_m3_outb(chip, chip->reset_state & ~REGB_ENABLE_RESET, DSP_PORT_CONTROL_REG_B); in snd_m3_assp_halt()
957 snd_m3_outb(chip, chip->reset_state | REGB_ENABLE_RESET, DSP_PORT_CONTROL_REG_B); in snd_m3_assp_continue()
972 list->mem_addr + list->curlen, in snd_m3_add_list()
974 return list->curlen++; in snd_m3_add_list()
980 int lastindex = list->curlen - 1; in snd_m3_remove_list()
984 list->mem_addr + lastindex); in snd_m3_remove_list()
986 list->mem_addr + index, in snd_m3_remove_list()
991 list->mem_addr + lastindex, in snd_m3_remove_list()
994 list->curlen--; in snd_m3_remove_list()
999 chip->timer_users++; in snd_m3_inc_timer_users()
1000 if (chip->timer_users != 1) in snd_m3_inc_timer_users()
1018 chip->timer_users--; in snd_m3_dec_timer_users()
1019 if (chip->timer_users > 0) in snd_m3_dec_timer_users()
1044 return -EINVAL; in snd_m3_pcm_start()
1047 switch (subs->stream) { in snd_m3_pcm_start()
1049 chip->dacs_active++; in snd_m3_pcm_start()
1051 s->inst.data + CDATA_INSTANCE_READY, 1); in snd_m3_pcm_start()
1054 chip->dacs_active); in snd_m3_pcm_start()
1060 s->inst.data + CDATA_INSTANCE_READY, 1); in snd_m3_pcm_start()
1071 return -EINVAL; in snd_m3_pcm_stop()
1074 s->inst.data + CDATA_INSTANCE_READY, 0); in snd_m3_pcm_stop()
1076 switch (subs->stream) { in snd_m3_pcm_stop()
1078 chip->dacs_active--; in snd_m3_pcm_stop()
1081 chip->dacs_active); in snd_m3_pcm_stop()
1095 struct m3_dma *s = subs->runtime->private_data; in snd_m3_pcm_trigger()
1096 int err = -EINVAL; in snd_m3_pcm_trigger()
1099 return -ENXIO; in snd_m3_pcm_trigger()
1101 spin_lock(&chip->reg_lock); in snd_m3_pcm_trigger()
1105 if (s->running) in snd_m3_pcm_trigger()
1106 err = -EBUSY; in snd_m3_pcm_trigger()
1108 s->running = 1; in snd_m3_pcm_trigger()
1114 if (! s->running) in snd_m3_pcm_trigger()
1117 s->running = 0; in snd_m3_pcm_trigger()
1122 spin_unlock(&chip->reg_lock); in snd_m3_pcm_trigger()
1133 struct snd_pcm_runtime *runtime = subs->runtime; in snd_m3_pcm_setup1()
1135 if (subs->stream == SNDRV_PCM_STREAM_PLAYBACK) { in snd_m3_pcm_setup1()
1136 dsp_in_size = MINISRC_IN_BUFFER_SIZE - (0x20 * 2); in snd_m3_pcm_setup1()
1137 dsp_out_size = MINISRC_OUT_BUFFER_SIZE - (0x20 * 2); in snd_m3_pcm_setup1()
1139 dsp_in_size = MINISRC_IN_BUFFER_SIZE - (0x10 * 2); in snd_m3_pcm_setup1()
1140 dsp_out_size = MINISRC_OUT_BUFFER_SIZE - (0x10 * 2); in snd_m3_pcm_setup1()
1142 dsp_in_buffer = s->inst.data + (MINISRC_TMP_BUFFER_SIZE / 2); in snd_m3_pcm_setup1()
1145 s->dma_size = frames_to_bytes(runtime, runtime->buffer_size); in snd_m3_pcm_setup1()
1146 s->period_size = frames_to_bytes(runtime, runtime->period_size); in snd_m3_pcm_setup1()
1147 s->hwptr = 0; in snd_m3_pcm_setup1()
1148 s->count = 0; in snd_m3_pcm_setup1()
1155 s->inst.data + CDATA_HOST_SRC_ADDRL, in snd_m3_pcm_setup1()
1156 LO(s->buffer_addr)); in snd_m3_pcm_setup1()
1159 s->inst.data + CDATA_HOST_SRC_ADDRH, in snd_m3_pcm_setup1()
1160 HI(s->buffer_addr)); in snd_m3_pcm_setup1()
1163 s->inst.data + CDATA_HOST_SRC_END_PLUS_1L, in snd_m3_pcm_setup1()
1164 LO(s->buffer_addr + s->dma_size)); in snd_m3_pcm_setup1()
1167 s->inst.data + CDATA_HOST_SRC_END_PLUS_1H, in snd_m3_pcm_setup1()
1168 HI(s->buffer_addr + s->dma_size)); in snd_m3_pcm_setup1()
1171 s->inst.data + CDATA_HOST_SRC_CURRENTL, in snd_m3_pcm_setup1()
1172 LO(s->buffer_addr)); in snd_m3_pcm_setup1()
1175 s->inst.data + CDATA_HOST_SRC_CURRENTH, in snd_m3_pcm_setup1()
1176 HI(s->buffer_addr)); in snd_m3_pcm_setup1()
1183 s->inst.data + CDATA_IN_BUF_BEGIN, in snd_m3_pcm_setup1()
1187 s->inst.data + CDATA_IN_BUF_END_PLUS_1, in snd_m3_pcm_setup1()
1191 s->inst.data + CDATA_IN_BUF_HEAD, in snd_m3_pcm_setup1()
1195 s->inst.data + CDATA_IN_BUF_TAIL, in snd_m3_pcm_setup1()
1199 s->inst.data + CDATA_OUT_BUF_BEGIN, in snd_m3_pcm_setup1()
1203 s->inst.data + CDATA_OUT_BUF_END_PLUS_1, in snd_m3_pcm_setup1()
1207 s->inst.data + CDATA_OUT_BUF_HEAD, in snd_m3_pcm_setup1()
1211 s->inst.data + CDATA_OUT_BUF_TAIL, in snd_m3_pcm_setup1()
1223 if (! s->in_lists) { in snd_m3_pcm_setup2()
1224 s->index[0] = snd_m3_add_list(chip, s->index_list[0], in snd_m3_pcm_setup2()
1225 s->inst.data >> DP_SHIFT_COUNT); in snd_m3_pcm_setup2()
1226 s->index[1] = snd_m3_add_list(chip, s->index_list[1], in snd_m3_pcm_setup2()
1227 s->inst.data >> DP_SHIFT_COUNT); in snd_m3_pcm_setup2()
1228 s->index[2] = snd_m3_add_list(chip, s->index_list[2], in snd_m3_pcm_setup2()
1229 s->inst.data >> DP_SHIFT_COUNT); in snd_m3_pcm_setup2()
1230 s->in_lists = 1; in snd_m3_pcm_setup2()
1235 s->inst.data + SRC3_DIRECTION_OFFSET + 1, in snd_m3_pcm_setup2()
1236 runtime->channels == 2 ? 0 : 1); in snd_m3_pcm_setup2()
1239 s->inst.data + SRC3_DIRECTION_OFFSET + 2, in snd_m3_pcm_setup2()
1240 snd_pcm_format_width(runtime->format) == 16 ? 0 : 1); in snd_m3_pcm_setup2()
1243 freq = DIV_ROUND_CLOSEST(runtime->rate << 15, 48000); in snd_m3_pcm_setup2()
1245 freq--; in snd_m3_pcm_setup2()
1248 s->inst.data + CDATA_FREQUENCY, in snd_m3_pcm_setup2()
1274 {SRC3_DIRECTION_OFFSET + 18, MINISRC_BIQUAD_STAGE - 1}, /* numstage */
1292 s->inst.data + SRC3_DIRECTION_OFFSET + 12, in snd_m3_playback_setup()
1293 s->inst.data + 40 + 8); in snd_m3_playback_setup()
1296 s->inst.data + SRC3_DIRECTION_OFFSET + 19, in snd_m3_playback_setup()
1297 s->inst.code + MINISRC_COEF_LOC); in snd_m3_playback_setup()
1301 s->inst.data + SRC3_DIRECTION_OFFSET + 22, in snd_m3_playback_setup()
1302 subs->runtime->rate > 45000 ? 0xff : 0); in snd_m3_playback_setup()
1306 s->inst.data + CDATA_DMA_CONTROL, in snd_m3_playback_setup()
1314 s->inst.data + pv[i].addr, pv[i].val); in snd_m3_playback_setup()
1358 s->inst.data + SRC3_DIRECTION_OFFSET + 12, in snd_m3_capture_setup()
1359 s->inst.data + 40 + 8); in snd_m3_capture_setup()
1363 s->inst.data + CDATA_DMA_CONTROL, in snd_m3_capture_setup()
1372 s->inst.data + rv[i].addr, rv[i].val); in snd_m3_capture_setup()
1378 struct m3_dma *s = substream->runtime->private_data; in snd_m3_pcm_hw_params()
1381 s->buffer_addr = substream->runtime->dma_addr; in snd_m3_pcm_hw_params()
1382 if (s->buffer_addr & 0x3) { in snd_m3_pcm_hw_params()
1383 dev_err(substream->pcm->card->dev, "oh my, not aligned\n"); in snd_m3_pcm_hw_params()
1384 s->buffer_addr = s->buffer_addr & ~0x3; in snd_m3_pcm_hw_params()
1393 if (substream->runtime->private_data == NULL) in snd_m3_pcm_hw_free()
1395 s = substream->runtime->private_data; in snd_m3_pcm_hw_free()
1396 s->buffer_addr = 0; in snd_m3_pcm_hw_free()
1404 struct snd_pcm_runtime *runtime = subs->runtime; in snd_m3_pcm_prepare()
1405 struct m3_dma *s = runtime->private_data; in snd_m3_pcm_prepare()
1408 return -ENXIO; in snd_m3_pcm_prepare()
1410 if (runtime->format != SNDRV_PCM_FORMAT_U8 && in snd_m3_pcm_prepare()
1411 runtime->format != SNDRV_PCM_FORMAT_S16_LE) in snd_m3_pcm_prepare()
1412 return -EINVAL; in snd_m3_pcm_prepare()
1413 if (runtime->rate > 48000 || in snd_m3_pcm_prepare()
1414 runtime->rate < 8000) in snd_m3_pcm_prepare()
1415 return -EINVAL; in snd_m3_pcm_prepare()
1417 spin_lock_irq(&chip->reg_lock); in snd_m3_pcm_prepare()
1421 if (subs->stream == SNDRV_PCM_STREAM_PLAYBACK) in snd_m3_pcm_prepare()
1428 spin_unlock_irq(&chip->reg_lock); in snd_m3_pcm_prepare()
1446 while (retry--) { in snd_m3_get_pointer()
1448 s->inst.data + CDATA_HOST_SRC_CURRENTH); in snd_m3_get_pointer()
1451 s->inst.data + CDATA_HOST_SRC_CURRENTL); in snd_m3_get_pointer()
1454 s->inst.data + CDATA_HOST_SRC_CURRENTH)) in snd_m3_get_pointer()
1458 return (unsigned int)(addr - s->buffer_addr); in snd_m3_get_pointer()
1466 struct m3_dma *s = subs->runtime->private_data; in snd_m3_pcm_pointer()
1471 spin_lock(&chip->reg_lock); in snd_m3_pcm_pointer()
1473 spin_unlock(&chip->reg_lock); in snd_m3_pcm_pointer()
1474 return bytes_to_frames(subs->runtime, ptr); in snd_m3_pcm_pointer()
1482 struct snd_pcm_substream *subs = s->substream; in snd_m3_update_ptr()
1486 if (! s->running) in snd_m3_update_ptr()
1492 if (hwptr >= s->dma_size) in snd_m3_update_ptr()
1493 hwptr %= s->dma_size; in snd_m3_update_ptr()
1495 diff = s->dma_size + hwptr - s->hwptr; in snd_m3_update_ptr()
1496 if (diff >= s->dma_size) in snd_m3_update_ptr()
1497 diff %= s->dma_size; in snd_m3_update_ptr()
1499 s->hwptr = hwptr; in snd_m3_update_ptr()
1500 s->count += diff; in snd_m3_update_ptr()
1502 if (s->count >= (signed)s->period_size) { in snd_m3_update_ptr()
1504 if (s->count < 2 * (signed)s->period_size) in snd_m3_update_ptr()
1505 s->count -= (signed)s->period_size; in snd_m3_update_ptr()
1507 s->count %= s->period_size; in snd_m3_update_ptr()
1509 spin_unlock(&chip->reg_lock); in snd_m3_update_ptr()
1511 spin_lock(&chip->reg_lock); in snd_m3_update_ptr()
1517 generating an interrupt. The pair of counters is stored in bits 1-3 and 5-7
1527 x = inb(chip->iobase + SHADOW_MIX_REG_VOICE) & 0xee; in snd_m3_update_hw_volume()
1538 outb(0x88, chip->iobase + SHADOW_MIX_REG_VOICE); in snd_m3_update_hw_volume()
1539 outb(0x88, chip->iobase + HW_VOL_COUNTER_VOICE); in snd_m3_update_hw_volume()
1540 outb(0x88, chip->iobase + SHADOW_MIX_REG_MASTER); in snd_m3_update_hw_volume()
1541 outb(0x88, chip->iobase + HW_VOL_COUNTER_MASTER); in snd_m3_update_hw_volume()
1544 mistaking them for a mute button press. */ in snd_m3_update_hw_volume()
1545 if (chip->in_suspend) in snd_m3_update_hw_volume()
1549 if (!chip->master_switch || !chip->master_volume) in snd_m3_update_hw_volume()
1552 val = snd_ac97_read(chip->ac97, AC97_MASTER); in snd_m3_update_hw_volume()
1561 /* counters increased by 1 -> volume up */ in snd_m3_update_hw_volume()
1563 val--; in snd_m3_update_hw_volume()
1565 val -= 0x0100; in snd_m3_update_hw_volume()
1568 /* counters decreased by 1 -> volume down */ in snd_m3_update_hw_volume()
1575 if (snd_ac97_update(chip->ac97, AC97_MASTER, val)) in snd_m3_update_hw_volume()
1576 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, in snd_m3_update_hw_volume()
1577 &chip->master_switch->id); in snd_m3_update_hw_volume()
1579 if (!chip->input_dev) in snd_m3_update_hw_volume()
1591 /* counters increased by 1 -> volume up */ in snd_m3_update_hw_volume()
1595 /* counters decreased by 1 -> volume down */ in snd_m3_update_hw_volume()
1601 input_report_key(chip->input_dev, val, 1); in snd_m3_update_hw_volume()
1602 input_sync(chip->input_dev); in snd_m3_update_hw_volume()
1603 input_report_key(chip->input_dev, val, 0); in snd_m3_update_hw_volume()
1604 input_sync(chip->input_dev); in snd_m3_update_hw_volume()
1615 status = inb(chip->iobase + HOST_INT_STATUS); in snd_m3_interrupt()
1621 schedule_work(&chip->hwvol_work); in snd_m3_interrupt()
1628 u8 ctl = inb(chip->iobase + ASSP_CONTROL_B); in snd_m3_interrupt()
1630 ctl = inb(chip->iobase + ASSP_HOST_INT_STATUS); in snd_m3_interrupt()
1632 outb(DSP2HOST_REQ_TIMER, chip->iobase + ASSP_HOST_INT_STATUS); in snd_m3_interrupt()
1634 spin_lock(&chip->reg_lock); in snd_m3_interrupt()
1635 for (i = 0; i < chip->num_substreams; i++) { in snd_m3_interrupt()
1636 struct m3_dma *s = &chip->substreams[i]; in snd_m3_interrupt()
1637 if (s->running) in snd_m3_interrupt()
1640 spin_unlock(&chip->reg_lock); in snd_m3_interrupt()
1646 if ((status & MPU401_INT_PENDING) && chip->rmidi) in snd_m3_interrupt()
1647 snd_mpu401_uart_interrupt(irq, chip->rmidi->private_data, regs); in snd_m3_interrupt()
1651 outb(status, chip->iobase + HOST_INT_STATUS); in snd_m3_interrupt()
1712 spin_lock_irq(&chip->reg_lock); in snd_m3_substream_open()
1713 for (i = 0; i < chip->num_substreams; i++) { in snd_m3_substream_open()
1714 s = &chip->substreams[i]; in snd_m3_substream_open()
1715 if (! s->opened) in snd_m3_substream_open()
1718 spin_unlock_irq(&chip->reg_lock); in snd_m3_substream_open()
1719 return -ENOMEM; in snd_m3_substream_open()
1721 s->opened = 1; in snd_m3_substream_open()
1722 s->running = 0; in snd_m3_substream_open()
1723 spin_unlock_irq(&chip->reg_lock); in snd_m3_substream_open()
1725 subs->runtime->private_data = s; in snd_m3_substream_open()
1726 s->substream = subs; in snd_m3_substream_open()
1729 if (subs->stream == SNDRV_PCM_STREAM_PLAYBACK) { in snd_m3_substream_open()
1730 s->index_list[0] = &chip->mixer_list; in snd_m3_substream_open()
1732 s->index_list[0] = &chip->adc1_list; in snd_m3_substream_open()
1733 s->index_list[1] = &chip->msrc_list; in snd_m3_substream_open()
1734 s->index_list[2] = &chip->dma_list; in snd_m3_substream_open()
1742 struct m3_dma *s = subs->runtime->private_data; in snd_m3_substream_close()
1747 spin_lock_irq(&chip->reg_lock); in snd_m3_substream_close()
1748 if (s->substream && s->running) in snd_m3_substream_close()
1749 snd_m3_pcm_stop(chip, s, s->substream); /* does this happen? */ in snd_m3_substream_close()
1750 if (s->in_lists) { in snd_m3_substream_close()
1751 snd_m3_remove_list(chip, s->index_list[0], s->index[0]); in snd_m3_substream_close()
1752 snd_m3_remove_list(chip, s->index_list[1], s->index[1]); in snd_m3_substream_close()
1753 snd_m3_remove_list(chip, s->index_list[2], s->index[2]); in snd_m3_substream_close()
1754 s->in_lists = 0; in snd_m3_substream_close()
1756 s->running = 0; in snd_m3_substream_close()
1757 s->opened = 0; in snd_m3_substream_close()
1758 spin_unlock_irq(&chip->reg_lock); in snd_m3_substream_close()
1765 struct snd_pcm_runtime *runtime = subs->runtime; in snd_m3_playback_open()
1772 runtime->hw = snd_m3_playback; in snd_m3_playback_open()
1790 struct snd_pcm_runtime *runtime = subs->runtime; in snd_m3_capture_open()
1797 runtime->hw = snd_m3_capture; in snd_m3_capture_open()
1841 err = snd_pcm_new(chip->card, chip->card->driver, device, in snd_m3_pcm()
1849 pcm->private_data = chip; in snd_m3_pcm()
1850 pcm->info_flags = 0; in snd_m3_pcm()
1851 strcpy(pcm->name, chip->card->driver); in snd_m3_pcm()
1852 chip->pcm = pcm; in snd_m3_pcm()
1855 &chip->pci->dev, 64*1024, 64*1024); in snd_m3_pcm()
1877 } while (i-- > 0); in snd_m3_ac97_wait()
1879 dev_err(chip->card->dev, "ac97 serial bus busy\n"); in snd_m3_ac97_wait()
1883 static unsigned short
1884 snd_m3_ac97_read(struct snd_ac97 *ac97, unsigned short reg) in snd_m3_ac97_read()
1886 struct snd_m3 *chip = ac97->private_data; in snd_m3_ac97_read()
1887 unsigned short data = 0xffff; in snd_m3_ac97_read()
1900 snd_m3_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short val) in snd_m3_ac97_write()
1902 struct snd_m3 *chip = ac97->private_data; in snd_m3_ac97_write()
1913 if (ac97->id == 0x45838308 && reg == AC97_MASTER) { in snd_m3_ac97_write()
1923 int io = chip->iobase; in snd_m3_remote_codec_config()
1930 if (chip->pci->subsystem_vendor == 0x1028 && in snd_m3_remote_codec_config()
1931 chip->pci->subsystem_device == 0x00e5) in snd_m3_remote_codec_config()
1964 int io = chip->iobase; in snd_m3_ac97_reset()
1966 if (chip->allegro_flag) { in snd_m3_ac97_reset()
1982 if (!chip->irda_workaround) in snd_m3_ac97_reset()
1999 /* ok, bring back the ac-link */ in snd_m3_ac97_reset()
2011 dev_dbg(chip->card->dev, in snd_m3_ac97_reset()
2012 "retrying codec reset with delays of %d and %d ms\n", in snd_m3_ac97_reset()
2017 /* more gung-ho reset that doesn't in snd_m3_ac97_reset()
2041 err = snd_ac97_bus(chip->card, 0, &ops, NULL, &pbus); in snd_m3_mixer()
2047 err = snd_ac97_mixer(pbus, &ac97, &chip->ac97); in snd_m3_mixer()
2052 snd_ac97_write(chip->ac97, AC97_PCM, 0x8000 | (15 << 8) | 15); in snd_m3_mixer()
2054 snd_ac97_write(chip->ac97, AC97_PCM, 0); in snd_m3_mixer()
2060 chip->master_switch = snd_ctl_find_id(chip->card, &elem_id); in snd_m3_mixer()
2064 chip->master_volume = snd_ctl_find_id(chip->card, &elem_id); in snd_m3_mixer()
2102 data = (const __le16 *)chip->assp_kernel_image->data; in snd_m3_assp_init()
2103 for (i = 0 ; i * 2 < chip->assp_kernel_image->size; i++) { in snd_m3_assp_init()
2115 data = (const __le16 *)chip->assp_minisrc_image->data; in snd_m3_assp_init()
2116 for (i = 0; i * 2 < chip->assp_minisrc_image->size; i++) { in snd_m3_assp_init()
2157 chip->mixer_list.curlen = 0; in snd_m3_assp_init()
2158 chip->mixer_list.mem_addr = KDATA_MIXER_XFER0; in snd_m3_assp_init()
2159 chip->mixer_list.max = MAX_VIRTUAL_MIXER_CHANNELS; in snd_m3_assp_init()
2160 chip->adc1_list.curlen = 0; in snd_m3_assp_init()
2161 chip->adc1_list.mem_addr = KDATA_ADC1_XFER0; in snd_m3_assp_init()
2162 chip->adc1_list.max = MAX_VIRTUAL_ADC1_CHANNELS; in snd_m3_assp_init()
2163 chip->dma_list.curlen = 0; in snd_m3_assp_init()
2164 chip->dma_list.mem_addr = KDATA_DMA_XFER0; in snd_m3_assp_init()
2165 chip->dma_list.max = MAX_VIRTUAL_DMA_CHANNELS; in snd_m3_assp_init()
2166 chip->msrc_list.curlen = 0; in snd_m3_assp_init()
2167 chip->msrc_list.mem_addr = KDATA_INSTANCE0_MINISRC; in snd_m3_assp_init()
2168 chip->msrc_list.max = MAX_INSTANCE_MINISRC; in snd_m3_assp_init()
2193 dev_err(chip->card->dev, in snd_m3_assp_client_init()
2196 return -ENOMEM; in snd_m3_assp_client_init()
2199 s->number = index; in snd_m3_assp_client_init()
2200 s->inst.code = 0x400; in snd_m3_assp_client_init()
2201 s->inst.data = address; in snd_m3_assp_client_init()
2203 for (i = data_bytes / 2; i > 0; address++, i--) { in snd_m3_assp_client_init()
2221 int io = chip->iobase; in snd_m3_amp_enable()
2224 if (! chip->external_amp) in snd_m3_amp_enable()
2228 polarity = polarity << chip->amp_gpio; in snd_m3_amp_enable()
2229 gpo = 1 << chip->amp_gpio; in snd_m3_amp_enable()
2245 unsigned long io = chip->iobase; in snd_m3_hv_init()
2248 if (!chip->is_omnibook) in snd_m3_hv_init()
2268 struct pci_dev *pcidev = chip->pci; in snd_m3_chip_init()
2269 unsigned long io = chip->iobase; in snd_m3_chip_init()
2282 n |= chip->hv_config; in snd_m3_chip_init()
2288 outb(RESET_ASSP, chip->iobase + ASSP_CONTROL_B); in snd_m3_chip_init()
2291 if (!chip->allegro_flag) { in snd_m3_chip_init()
2298 if (chip->allegro_flag) { in snd_m3_chip_init()
2304 t = inb(chip->iobase + ASSP_CONTROL_A); in snd_m3_chip_init()
2308 outb(t, chip->iobase + ASSP_CONTROL_A); in snd_m3_chip_init()
2311 outb(RUN_ASSP, chip->iobase + ASSP_CONTROL_B); in snd_m3_chip_init()
2325 unsigned long io = chip->iobase; in snd_m3_enable_ints()
2326 unsigned short val; in snd_m3_enable_ints()
2330 if (chip->hv_config & HV_CTRL_ENABLE) in snd_m3_enable_ints()
2332 outb(val, chip->iobase + HOST_INT_STATUS); in snd_m3_enable_ints()
2344 struct snd_m3 *chip = card->private_data; in snd_m3_free()
2348 cancel_work_sync(&chip->hwvol_work); in snd_m3_free()
2350 if (chip->substreams) { in snd_m3_free()
2351 spin_lock_irq(&chip->reg_lock); in snd_m3_free()
2352 for (i = 0; i < chip->num_substreams; i++) { in snd_m3_free()
2353 s = &chip->substreams[i]; in snd_m3_free()
2355 if (s->substream && s->running) in snd_m3_free()
2356 snd_m3_pcm_stop(chip, s, s->substream); in snd_m3_free()
2358 spin_unlock_irq(&chip->reg_lock); in snd_m3_free()
2360 if (chip->iobase) { in snd_m3_free()
2361 outw(0, chip->iobase + HOST_INT_CTRL); /* disable ints */ in snd_m3_free()
2365 vfree(chip->suspend_mem); in snd_m3_free()
2367 release_firmware(chip->assp_kernel_image); in snd_m3_free()
2368 release_firmware(chip->assp_minisrc_image); in snd_m3_free()
2379 struct snd_m3 *chip = card->private_data; in m3_suspend()
2382 if (chip->suspend_mem == NULL) in m3_suspend()
2385 chip->in_suspend = 1; in m3_suspend()
2386 cancel_work_sync(&chip->hwvol_work); in m3_suspend()
2388 snd_ac97_suspend(chip->ac97); in m3_suspend()
2397 chip->suspend_mem[dsp_index++] = in m3_suspend()
2400 chip->suspend_mem[dsp_index++] = in m3_suspend()
2408 struct snd_m3 *chip = card->private_data; in m3_resume()
2411 if (chip->suspend_mem == NULL) in m3_resume()
2426 chip->suspend_mem[dsp_index++]); in m3_resume()
2429 chip->suspend_mem[dsp_index++]); in m3_resume()
2436 snd_ac97_resume(chip->ac97); in m3_resume()
2445 chip->in_suspend = 0; in m3_resume()
2461 input_dev = devm_input_allocate_device(&chip->pci->dev); in snd_m3_input_register()
2463 return -ENOMEM; in snd_m3_input_register()
2465 snprintf(chip->phys, sizeof(chip->phys), "pci-%s/input0", in snd_m3_input_register()
2466 pci_name(chip->pci)); in snd_m3_input_register()
2468 input_dev->name = chip->card->driver; in snd_m3_input_register()
2469 input_dev->phys = chip->phys; in snd_m3_input_register()
2470 input_dev->id.bustype = BUS_PCI; in snd_m3_input_register()
2471 input_dev->id.vendor = chip->pci->vendor; in snd_m3_input_register()
2472 input_dev->id.product = chip->pci->device; in snd_m3_input_register()
2473 input_dev->dev.parent = &chip->pci->dev; in snd_m3_input_register()
2475 __set_bit(EV_KEY, input_dev->evbit); in snd_m3_input_register()
2476 __set_bit(KEY_MUTE, input_dev->keybit); in snd_m3_input_register()
2477 __set_bit(KEY_VOLUMEDOWN, input_dev->keybit); in snd_m3_input_register()
2478 __set_bit(KEY_VOLUMEUP, input_dev->keybit); in snd_m3_input_register()
2484 chip->input_dev = input_dev; in snd_m3_input_register()
2497 struct snd_m3 *chip = card->private_data; in snd_m3_create()
2502 return -EIO; in snd_m3_create()
2505 if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(28))) { in snd_m3_create()
2506 dev_err(card->dev, in snd_m3_create()
2508 return -ENXIO; in snd_m3_create()
2511 spin_lock_init(&chip->reg_lock); in snd_m3_create()
2513 switch (pci->device) { in snd_m3_create()
2518 chip->allegro_flag = 1; in snd_m3_create()
2522 chip->card = card; in snd_m3_create()
2523 chip->pci = pci; in snd_m3_create()
2524 chip->irq = -1; in snd_m3_create()
2525 INIT_WORK(&chip->hwvol_work, snd_m3_update_hw_volume); in snd_m3_create()
2526 card->private_free = snd_m3_free; in snd_m3_create()
2528 chip->external_amp = enable_amp; in snd_m3_create()
2530 chip->amp_gpio = amp_gpio; in snd_m3_create()
2534 dev_info(card->dev, "set amp-gpio for '%s'\n", in snd_m3_create()
2536 chip->amp_gpio = quirk->value; in snd_m3_create()
2537 } else if (chip->allegro_flag) in snd_m3_create()
2538 chip->amp_gpio = GPO_EXT_AMP_ALLEGRO; in snd_m3_create()
2540 chip->amp_gpio = GPO_EXT_AMP_M3; in snd_m3_create()
2545 dev_info(card->dev, "enabled irda workaround for '%s'\n", in snd_m3_create()
2547 chip->irda_workaround = 1; in snd_m3_create()
2551 chip->hv_config = quirk->value; in snd_m3_create()
2553 chip->is_omnibook = 1; in snd_m3_create()
2555 chip->num_substreams = NR_DSPS; in snd_m3_create()
2556 chip->substreams = devm_kcalloc(&pci->dev, chip->num_substreams, in snd_m3_create()
2558 if (!chip->substreams) in snd_m3_create()
2559 return -ENOMEM; in snd_m3_create()
2561 err = request_firmware(&chip->assp_kernel_image, in snd_m3_create()
2562 "ess/maestro3_assp_kernel.fw", &pci->dev); in snd_m3_create()
2566 err = request_firmware(&chip->assp_minisrc_image, in snd_m3_create()
2567 "ess/maestro3_assp_minisrc.fw", &pci->dev); in snd_m3_create()
2571 err = pci_request_regions(pci, card->driver); in snd_m3_create()
2575 chip->iobase = pci_resource_start(pci, 0); in snd_m3_create()
2589 if (devm_request_irq(&pci->dev, pci->irq, snd_m3_interrupt, IRQF_SHARED, in snd_m3_create()
2591 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq); in snd_m3_create()
2592 return -ENOMEM; in snd_m3_create()
2594 chip->irq = pci->irq; in snd_m3_create()
2595 card->sync_irq = chip->irq; in snd_m3_create()
2598 chip->suspend_mem = in snd_m3_create()
2602 if (chip->suspend_mem == NULL) in snd_m3_create()
2603 dev_warn(card->dev, "can't allocate apm buffer\n"); in snd_m3_create()
2610 for (i = 0; i < chip->num_substreams; i++) { in snd_m3_create()
2611 struct m3_dma *s = &chip->substreams[i]; in snd_m3_create()
2622 if (chip->hv_config & HV_CTRL_ENABLE) { in snd_m3_create()
2625 dev_warn(card->dev, in snd_m3_create()
2648 if (((pci->class >> 8) & 0xffff) != PCI_CLASS_MULTIMEDIA_AUDIO) in __snd_m3_probe()
2649 return -ENODEV; in __snd_m3_probe()
2652 return -ENODEV; in __snd_m3_probe()
2655 return -ENOENT; in __snd_m3_probe()
2658 err = snd_devm_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, in __snd_m3_probe()
2662 chip = card->private_data; in __snd_m3_probe()
2664 switch (pci->device) { in __snd_m3_probe()
2667 strcpy(card->driver, "Allegro"); in __snd_m3_probe()
2671 strcpy(card->driver, "Canyon3D-2"); in __snd_m3_probe()
2674 strcpy(card->driver, "Maestro3"); in __snd_m3_probe()
2682 sprintf(card->shortname, "ESS %s PCI", card->driver); in __snd_m3_probe()
2683 sprintf(card->longname, "%s at 0x%lx, irq %d", in __snd_m3_probe()
2684 card->shortname, chip->iobase, chip->irq); in __snd_m3_probe()
2692 err = snd_mpu401_uart_new(chip->card, 0, MPU401_HW_MPU401, in __snd_m3_probe()
2693 chip->iobase + MPU401_DATA_PORT, in __snd_m3_probe()
2695 -1, &chip->rmidi); in __snd_m3_probe()
2697 dev_warn(card->dev, "no MIDI support.\n"); in __snd_m3_probe()
2708 return snd_card_free_on_error(&pci->dev, __snd_m3_probe(pci, pci_id)); in snd_m3_probe()