Lines Matching +full:mic +full:- +full:pos

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Driver for ESS Solo-1 (ES1938, ES1946, ES1969) soundcard
7 * Abramo Bagnara <abramo@alsa-project.org>,
18 - Capture data is written unaligned starting from dma_base + 1 so I need to
20 - After several cycle of the following:
21 while : ; do arecord -d1 -f cd -t raw | aplay -f cd ; done
25 - Sometimes the interrupt handler is invoked wrongly during playback.
31 hdparm -t -T /dev/hda
42 #include <linux/dma-mapping.h>
53 MODULE_DESCRIPTION("ESS Solo-1");
60 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
65 MODULE_PARM_DESC(index, "Index value for ESS Solo-1 soundcard.");
67 MODULE_PARM_DESC(id, "ID string for ESS Solo-1 soundcard.");
69 MODULE_PARM_DESC(enable, "Enable ESS Solo-1 soundcard.");
71 #define SLIO_REG(chip, x) ((chip)->io_port + ESSIO_REG_##x)
73 #define SLDM_REG(chip, x) ((chip)->ddma_port + ESSDM_REG_##x)
75 #define SLSB_REG(chip, x) ((chip)->sb_port + ESSSB_REG_##x)
225 { PCI_VDEVICE(ESS, 0x1969), 0, }, /* Solo-1 */
235 /* -----------------------------------------------------------------
237 * -----------------------------------------------------------------*/
241 spin_lock_irqsave(&chip->mixer_lock, flags); in snd_es1938_mixer_write()
244 spin_unlock_irqrestore(&chip->mixer_lock, flags); in snd_es1938_mixer_write()
245 dev_dbg(chip->card->dev, "Mixer reg %02x set to %02x\n", reg, val); in snd_es1938_mixer_write()
248 /* -----------------------------------------------------------------
250 * -----------------------------------------------------------------*/
255 spin_lock_irqsave(&chip->mixer_lock, flags); in snd_es1938_mixer_read()
258 spin_unlock_irqrestore(&chip->mixer_lock, flags); in snd_es1938_mixer_read()
259 dev_dbg(chip->card->dev, "Mixer reg %02x now is %02x\n", reg, data); in snd_es1938_mixer_read()
263 /* -----------------------------------------------------------------
265 * -----------------------------------------------------------------*/
271 spin_lock_irqsave(&chip->mixer_lock, flags); in snd_es1938_mixer_bits()
278 dev_dbg(chip->card->dev, in snd_es1938_mixer_bits()
282 spin_unlock_irqrestore(&chip->mixer_lock, flags); in snd_es1938_mixer_bits()
286 /* -----------------------------------------------------------------
288 * -----------------------------------------------------------------*/
300 dev_err(chip->card->dev, in snd_es1938_write_cmd()
304 /* -----------------------------------------------------------------
306 * -----------------------------------------------------------------*/
311 for (i = GET_LOOP_TIMEOUT; i; i--) { in snd_es1938_get_byte()
316 dev_err(chip->card->dev, "get_byte timeout: status 0x02%x\n", v); in snd_es1938_get_byte()
317 return -ENODEV; in snd_es1938_get_byte()
320 /* -----------------------------------------------------------------
322 * -----------------------------------------------------------------*/
326 spin_lock_irqsave(&chip->reg_lock, flags); in snd_es1938_write()
329 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_es1938_write()
330 dev_dbg(chip->card->dev, "Reg %02x set to %02x\n", reg, val); in snd_es1938_write()
333 /* -----------------------------------------------------------------
335 * -----------------------------------------------------------------*/
340 spin_lock_irqsave(&chip->reg_lock, flags); in snd_es1938_read()
344 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_es1938_read()
345 dev_dbg(chip->card->dev, "Reg %02x now is %02x\n", reg, val); in snd_es1938_read()
349 /* -----------------------------------------------------------------
351 * -----------------------------------------------------------------*/
357 spin_lock_irqsave(&chip->reg_lock, flags); in snd_es1938_bits()
366 dev_dbg(chip->card->dev, "Reg %02x was %02x, set to %02x\n", in snd_es1938_bits()
369 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_es1938_bits()
373 /* --------------------------------------------------------------------
375 * --------------------------------------------------------------------*/
389 dev_err(chip->card->dev, "ESS Solo-1 reset failed\n"); in snd_es1938_reset()
412 /* --------------------------------------------------------------------
414 * --------------------------------------------------------------------*/
447 struct snd_pcm_runtime *runtime = substream->runtime; in snd_es1938_rate_set()
448 if (runtime->rate_num == clocks[0].num) in snd_es1938_rate_set()
449 bits = 128 - runtime->rate_den; in snd_es1938_rate_set()
451 bits = 256 - runtime->rate_den; in snd_es1938_rate_set()
454 div0 = 256 - 7160000*20/(8*82*runtime->rate); in snd_es1938_rate_set()
465 /* --------------------------------------------------------------------
467 * --------------------------------------------------------------------*/
472 outl(chip->dma2_start, SLIO_REG(chip, AUDIO2DMAADDR)); in snd_es1938_playback1_setdma()
474 outw(chip->dma2_size, SLIO_REG(chip, AUDIO2DMACOUNT)); in snd_es1938_playback1_setdma()
486 outl(chip->dma1_start, SLDM_REG(chip, DMAADDR)); in snd_es1938_playback2_setdma()
487 outw(chip->dma1_size - 1, SLDM_REG(chip, DMACOUNT)); in snd_es1938_playback2_setdma()
501 outl(chip->dma1_start, SLDM_REG(chip, DMAADDR)); in snd_es1938_capture_setdma()
502 chip->last_capture_dmaaddr = chip->dma1_start; in snd_es1938_capture_setdma()
503 outw(chip->dma1_size - 1, SLDM_REG(chip, DMACOUNT)); in snd_es1938_capture_setdma()
508 /* ----------------------------------------------------------------------
522 chip->active |= ADC1; in snd_es1938_capture_trigger()
527 chip->active &= ~ADC1; in snd_es1938_capture_trigger()
530 return -EINVAL; in snd_es1938_capture_trigger()
548 /* This two stage init gives the FIFO -> DAC connection time to in snd_es1938_playback1_trigger()
550 * no swapping of stereo channels. Report a bug if otherwise :-) */ in snd_es1938_playback1_trigger()
552 chip->active |= DAC2; in snd_es1938_playback1_trigger()
558 chip->active &= ~DAC2; in snd_es1938_playback1_trigger()
561 return -EINVAL; in snd_es1938_playback1_trigger()
575 chip->active |= DAC1; in snd_es1938_playback2_trigger()
580 chip->active &= ~DAC1; in snd_es1938_playback2_trigger()
583 return -EINVAL; in snd_es1938_playback2_trigger()
592 switch (substream->number) { in snd_es1938_playback_trigger()
599 return -EINVAL; in snd_es1938_playback_trigger()
602 /* --------------------------------------------------------------------
604 * --------------------------------------------------------------------*/
608 struct snd_pcm_runtime *runtime = substream->runtime; in snd_es1938_capture_prepare()
613 chip->dma1_size = size; in snd_es1938_capture_prepare()
614 chip->dma1_start = runtime->dma_addr; in snd_es1938_capture_prepare()
616 mono = (runtime->channels > 1) ? 0 : 1; in snd_es1938_capture_prepare()
617 is8 = snd_pcm_format_width(runtime->format) == 16 ? 0 : 1; in snd_es1938_capture_prepare()
618 u = snd_pcm_format_unsigned(runtime->format); in snd_es1938_capture_prepare()
620 chip->dma1_shift = 2 - mono - is8; in snd_es1938_capture_prepare()
630 count = 0x10000 - count; in snd_es1938_capture_prepare()
650 /* ------------------------------------------------------------------------------
652 * ------------------------------------------------------------------------------*/
656 struct snd_pcm_runtime *runtime = substream->runtime; in snd_es1938_playback1_prepare()
661 chip->dma2_size = size; in snd_es1938_playback1_prepare()
662 chip->dma2_start = runtime->dma_addr; in snd_es1938_playback1_prepare()
664 mono = (runtime->channels > 1) ? 0 : 1; in snd_es1938_playback1_prepare()
665 is8 = snd_pcm_format_width(runtime->format) == 16 ? 0 : 1; in snd_es1938_playback1_prepare()
666 u = snd_pcm_format_unsigned(runtime->format); in snd_es1938_playback1_prepare()
668 chip->dma2_shift = 2 - mono - is8; in snd_es1938_playback1_prepare()
676 count = 0x10000 - count; in snd_es1938_playback1_prepare()
693 struct snd_pcm_runtime *runtime = substream->runtime; in snd_es1938_playback2_prepare()
698 chip->dma1_size = size; in snd_es1938_playback2_prepare()
699 chip->dma1_start = runtime->dma_addr; in snd_es1938_playback2_prepare()
701 mono = (runtime->channels > 1) ? 0 : 1; in snd_es1938_playback2_prepare()
702 is8 = snd_pcm_format_width(runtime->format) == 16 ? 0 : 1; in snd_es1938_playback2_prepare()
703 u = snd_pcm_format_unsigned(runtime->format); in snd_es1938_playback2_prepare()
705 chip->dma1_shift = 2 - mono - is8; in snd_es1938_playback2_prepare()
707 count = 0x10000 - count; in snd_es1938_playback2_prepare()
734 switch (substream->number) { in snd_es1938_playback_prepare()
741 return -EINVAL; in snd_es1938_playback_prepare()
747 - is the current DMA address in the valid DMA range ?
748 - is the sum of DMA address and DMA counter pointing to the last DMA byte ?
758 /* This stuff is *needed*, don't ask why - AB */ in snd_es1938_capture_pointer()
762 ptr = chip->dma1_size - 1 - new; in snd_es1938_capture_pointer()
769 diff = chip->dma1_start + chip->dma1_size - ptr - count; in snd_es1938_capture_pointer()
771 if (diff > 3 || ptr < chip->dma1_start in snd_es1938_capture_pointer()
772 || ptr >= chip->dma1_start+chip->dma1_size) in snd_es1938_capture_pointer()
773 ptr = chip->last_capture_dmaaddr; /* bad, use last saved */ in snd_es1938_capture_pointer()
775 chip->last_capture_dmaaddr = ptr; /* good, remember it */ in snd_es1938_capture_pointer()
777 ptr -= chip->dma1_start; in snd_es1938_capture_pointer()
779 return ptr >> chip->dma1_shift; in snd_es1938_capture_pointer()
787 ptr = chip->dma2_size - inw(SLIO_REG(chip, AUDIO2DMACOUNT)); in snd_es1938_playback1_pointer()
789 ptr = inl(SLIO_REG(chip, AUDIO2DMAADDR)) - chip->dma2_start; in snd_es1938_playback1_pointer()
791 return ptr >> chip->dma2_shift; in snd_es1938_playback1_pointer()
800 /* This stuff is *needed*, don't ask why - AB */ in snd_es1938_playback2_pointer()
804 ptr = chip->dma1_size - 1 - new; in snd_es1938_playback2_pointer()
806 ptr = inl(SLDM_REG(chip, DMAADDR)) - chip->dma1_start; in snd_es1938_playback2_pointer()
808 return ptr >> chip->dma1_shift; in snd_es1938_playback2_pointer()
813 switch (substream->number) { in snd_es1938_playback_pointer()
820 return -EINVAL; in snd_es1938_playback_pointer()
824 int channel, unsigned long pos, in snd_es1938_capture_copy() argument
827 struct snd_pcm_runtime *runtime = substream->runtime; in snd_es1938_capture_copy()
830 if (snd_BUG_ON(pos + count > chip->dma1_size)) in snd_es1938_capture_copy()
831 return -EINVAL; in snd_es1938_capture_copy()
832 if (pos + count < chip->dma1_size) { in snd_es1938_capture_copy()
833 if (copy_to_iter(runtime->dma_area + pos + 1, count, dst) != count) in snd_es1938_capture_copy()
834 return -EFAULT; in snd_es1938_capture_copy()
836 if (copy_to_iter(runtime->dma_area + pos + 1, count - 1, dst) != count - 1) in snd_es1938_capture_copy()
837 return -EFAULT; in snd_es1938_capture_copy()
838 if (copy_to_iter(runtime->dma_area, 1, dst) != 1) in snd_es1938_capture_copy()
839 return -EFAULT; in snd_es1938_capture_copy()
844 /* ----------------------------------------------------------------------
846 * ----------------------------------------------------------------------*/
866 /* -----------------------------------------------------------------------
868 * -----------------------------------------------------------------------*/
892 struct snd_pcm_runtime *runtime = substream->runtime; in snd_es1938_capture_open()
894 if (chip->playback2_substream) in snd_es1938_capture_open()
895 return -EAGAIN; in snd_es1938_capture_open()
896 chip->capture_substream = substream; in snd_es1938_capture_open()
897 runtime->hw = snd_es1938_capture; in snd_es1938_capture_open()
907 struct snd_pcm_runtime *runtime = substream->runtime; in snd_es1938_playback_open()
909 switch (substream->number) { in snd_es1938_playback_open()
911 chip->playback1_substream = substream; in snd_es1938_playback_open()
914 if (chip->capture_substream) in snd_es1938_playback_open()
915 return -EAGAIN; in snd_es1938_playback_open()
916 chip->playback2_substream = substream; in snd_es1938_playback_open()
920 return -EINVAL; in snd_es1938_playback_open()
922 runtime->hw = snd_es1938_playback; in snd_es1938_playback_open()
933 chip->capture_substream = NULL; in snd_es1938_capture_close()
941 switch (substream->number) { in snd_es1938_playback_close()
943 chip->playback1_substream = NULL; in snd_es1938_playback_close()
946 chip->playback2_substream = NULL; in snd_es1938_playback_close()
950 return -EINVAL; in snd_es1938_playback_close()
977 err = snd_pcm_new(chip->card, "es-1938-1946", device, 2, 1, &pcm); in snd_es1938_new_pcm()
983 pcm->private_data = chip; in snd_es1938_new_pcm()
984 pcm->info_flags = 0; in snd_es1938_new_pcm()
985 strcpy(pcm->name, "ESS Solo-1"); in snd_es1938_new_pcm()
988 &chip->pci->dev, 64*1024, 64*1024); in snd_es1938_new_pcm()
990 chip->pcm = pcm; in snd_es1938_new_pcm()
994 /* -------------------------------------------------------------------
1003 "Mic", "Mic Master", "CD", "AOUT", in snd_es1938_info_mux()
1014 ucontrol->value.enumerated.item[0] = snd_es1938_mixer_read(chip, 0x1c) & 0x07; in snd_es1938_get_mux()
1022 unsigned char val = ucontrol->value.enumerated.item[0]; in snd_es1938_put_mux()
1025 return -EINVAL; in snd_es1938_put_mux()
1036 ucontrol->value.integer.value[0] = !!(val & 8); in snd_es1938_get_spatializer_enable()
1046 nval = ucontrol->value.integer.value[0] ? 0x0c : 0x04; in snd_es1938_put_spatializer_enable()
1059 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_es1938_info_hw_volume()
1060 uinfo->count = 2; in snd_es1938_info_hw_volume()
1061 uinfo->value.integer.min = 0; in snd_es1938_info_hw_volume()
1062 uinfo->value.integer.max = 63; in snd_es1938_info_hw_volume()
1070 ucontrol->value.integer.value[0] = snd_es1938_mixer_read(chip, 0x61) & 0x3f; in snd_es1938_get_hw_volume()
1071 ucontrol->value.integer.value[1] = snd_es1938_mixer_read(chip, 0x63) & 0x3f; in snd_es1938_get_hw_volume()
1081 ucontrol->value.integer.value[0] = !(snd_es1938_mixer_read(chip, 0x61) & 0x40); in snd_es1938_get_hw_switch()
1082 ucontrol->value.integer.value[1] = !(snd_es1938_mixer_read(chip, 0x63) & 0x40); in snd_es1938_get_hw_switch()
1089 chip->master_volume = NULL; in snd_es1938_hwv_free()
1090 chip->master_switch = NULL; in snd_es1938_hwv_free()
1091 chip->hw_volume = NULL; in snd_es1938_hwv_free()
1092 chip->hw_switch = NULL; in snd_es1938_hwv_free()
1129 int mask = (kcontrol->private_value >> 16) & 0xff; in snd_es1938_info_single()
1131 uinfo->type = mask == 1 ? SNDRV_CTL_ELEM_TYPE_BOOLEAN : SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_es1938_info_single()
1132 uinfo->count = 1; in snd_es1938_info_single()
1133 uinfo->value.integer.min = 0; in snd_es1938_info_single()
1134 uinfo->value.integer.max = mask; in snd_es1938_info_single()
1142 int reg = kcontrol->private_value & 0xff; in snd_es1938_get_single()
1143 int shift = (kcontrol->private_value >> 8) & 0xff; in snd_es1938_get_single()
1144 int mask = (kcontrol->private_value >> 16) & 0xff; in snd_es1938_get_single()
1145 int invert = (kcontrol->private_value >> 24) & 0xff; in snd_es1938_get_single()
1149 ucontrol->value.integer.value[0] = (val >> shift) & mask; in snd_es1938_get_single()
1151 ucontrol->value.integer.value[0] = mask - ucontrol->value.integer.value[0]; in snd_es1938_get_single()
1159 int reg = kcontrol->private_value & 0xff; in snd_es1938_put_single()
1160 int shift = (kcontrol->private_value >> 8) & 0xff; in snd_es1938_put_single()
1161 int mask = (kcontrol->private_value >> 16) & 0xff; in snd_es1938_put_single()
1162 int invert = (kcontrol->private_value >> 24) & 0xff; in snd_es1938_put_single()
1165 val = (ucontrol->value.integer.value[0] & mask); in snd_es1938_put_single()
1167 val = mask - val; in snd_es1938_put_single()
1190 int mask = (kcontrol->private_value >> 24) & 0xff; in snd_es1938_info_double()
1192 uinfo->type = mask == 1 ? SNDRV_CTL_ELEM_TYPE_BOOLEAN : SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_es1938_info_double()
1193 uinfo->count = 2; in snd_es1938_info_double()
1194 uinfo->value.integer.min = 0; in snd_es1938_info_double()
1195 uinfo->value.integer.max = mask; in snd_es1938_info_double()
1203 int left_reg = kcontrol->private_value & 0xff; in snd_es1938_get_double()
1204 int right_reg = (kcontrol->private_value >> 8) & 0xff; in snd_es1938_get_double()
1205 int shift_left = (kcontrol->private_value >> 16) & 0x07; in snd_es1938_get_double()
1206 int shift_right = (kcontrol->private_value >> 19) & 0x07; in snd_es1938_get_double()
1207 int mask = (kcontrol->private_value >> 24) & 0xff; in snd_es1938_get_double()
1208 int invert = (kcontrol->private_value >> 22) & 1; in snd_es1938_get_double()
1216 ucontrol->value.integer.value[0] = (left >> shift_left) & mask; in snd_es1938_get_double()
1217 ucontrol->value.integer.value[1] = (right >> shift_right) & mask; in snd_es1938_get_double()
1219 ucontrol->value.integer.value[0] = mask - ucontrol->value.integer.value[0]; in snd_es1938_get_double()
1220 ucontrol->value.integer.value[1] = mask - ucontrol->value.integer.value[1]; in snd_es1938_get_double()
1229 int left_reg = kcontrol->private_value & 0xff; in snd_es1938_put_double()
1230 int right_reg = (kcontrol->private_value >> 8) & 0xff; in snd_es1938_put_double()
1231 int shift_left = (kcontrol->private_value >> 16) & 0x07; in snd_es1938_put_double()
1232 int shift_right = (kcontrol->private_value >> 19) & 0x07; in snd_es1938_put_double()
1233 int mask = (kcontrol->private_value >> 24) & 0xff; in snd_es1938_put_double()
1234 int invert = (kcontrol->private_value >> 22) & 1; in snd_es1938_put_double()
1238 val1 = ucontrol->value.integer.value[0] & mask; in snd_es1938_put_double()
1239 val2 = ucontrol->value.integer.value[1] & mask; in snd_es1938_put_double()
1241 val1 = mask - val1; in snd_es1938_put_double()
1242 val2 = mask - val2; in snd_es1938_put_double()
1262 0, 54, TLV_DB_SCALE_ITEM(-3600, 50, 1),
1263 54, 63, TLV_DB_SCALE_ITEM(-900, 100, 0),
1267 0, 8, TLV_DB_SCALE_ITEM(-3300, 300, 1),
1268 8, 15, TLV_DB_SCALE_ITEM(-900, 150, 0),
1272 0, 8, TLV_DB_SCALE_ITEM(-3450, 300, 1),
1273 8, 15, TLV_DB_SCALE_ITEM(-1050, 150, 0),
1277 0, 8, TLV_DB_SCALE_ITEM(-2400, 300, 1),
1282 0, 8, TLV_DB_SCALE_ITEM(-3150, 300, 1),
1283 8, 15, TLV_DB_SCALE_ITEM(-750, 150, 0),
1316 ES1938_DOUBLE_TLV("Mic Playback Volume", 0, 0x1a, 0x1a, 4, 0, 15, 0,
1336 ES1938_DOUBLE_TLV("Mic Capture Volume", 0, 0x68, 0x68, 4, 0, 15, 0,
1352 ES1938_SINGLE("3D Control - Level", 0, 0x52, 0, 63, 0),
1355 .name = "3D Control - Switch",
1360 ES1938_SINGLE("Mic Boost (+26dB)", 0, 0x7d, 3, 1, 0)
1364 /* ---------------------------------------------------------------------------- */
1365 /* ---------------------------------------------------------------------------- */
1368 * initialize the chip - used by resume callback, too
1378 pci_set_master(chip->pci); in snd_es1938_chip_init()
1381 pci_write_config_word(chip->pci, SL_PCI_LEGACYCONTROL, 0x805f); in snd_es1938_chip_init()
1384 pci_write_config_word(chip->pci, SL_PCI_DDMACONTROL, chip->ddma_port | 1); in snd_es1938_chip_init()
1387 pci_write_config_dword(chip->pci, SL_PCI_CONFIG, 0); in snd_es1938_chip_init()
1411 struct es1938 *chip = card->private_data; in es1938_suspend()
1417 /* save mixer-related registers */ in es1938_suspend()
1418 for (s = saved_regs, d = chip->saved_regs; *s; s++, d++) in es1938_suspend()
1422 if (chip->irq >= 0) { in es1938_suspend()
1423 free_irq(chip->irq, chip); in es1938_suspend()
1424 chip->irq = -1; in es1938_suspend()
1425 card->sync_irq = -1; in es1938_suspend()
1434 struct es1938 *chip = card->private_data; in es1938_resume()
1438 if (request_irq(pci->irq, snd_es1938_interrupt, in es1938_resume()
1441 pci->irq); in es1938_resume()
1443 return -EIO; in es1938_resume()
1445 chip->irq = pci->irq; in es1938_resume()
1446 card->sync_irq = chip->irq; in es1938_resume()
1449 /* restore mixer-related registers */ in es1938_resume()
1450 for (s = saved_regs, d = chip->saved_regs; *s; s++, d++) { in es1938_resume()
1468 chip->gameport = gp = gameport_allocate_port(); in snd_es1938_create_gameport()
1470 dev_err(chip->card->dev, in snd_es1938_create_gameport()
1472 return -ENOMEM; in snd_es1938_create_gameport()
1476 gameport_set_phys(gp, "pci%s/gameport0", pci_name(chip->pci)); in snd_es1938_create_gameport()
1477 gameport_set_dev_parent(gp, &chip->pci->dev); in snd_es1938_create_gameport()
1478 gp->io = chip->game_port; in snd_es1938_create_gameport()
1487 if (chip->gameport) { in snd_es1938_free_gameport()
1488 gameport_unregister_port(chip->gameport); in snd_es1938_free_gameport()
1489 chip->gameport = NULL; in snd_es1938_free_gameport()
1493 static inline int snd_es1938_create_gameport(struct es1938 *chip) { return -ENOSYS; } in snd_es1938_create_gameport()
1499 struct es1938 *chip = card->private_data; in snd_es1938_free()
1503 if (chip->rmidi) in snd_es1938_free()
1508 if (chip->irq >= 0) in snd_es1938_free()
1509 free_irq(chip->irq, chip); in snd_es1938_free()
1515 struct es1938 *chip = card->private_data; in snd_es1938_create()
1523 if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(24))) { in snd_es1938_create()
1524 dev_err(card->dev, in snd_es1938_create()
1526 return -ENXIO; in snd_es1938_create()
1529 spin_lock_init(&chip->reg_lock); in snd_es1938_create()
1530 spin_lock_init(&chip->mixer_lock); in snd_es1938_create()
1531 chip->card = card; in snd_es1938_create()
1532 chip->pci = pci; in snd_es1938_create()
1533 chip->irq = -1; in snd_es1938_create()
1534 err = pci_request_regions(pci, "ESS Solo-1"); in snd_es1938_create()
1537 chip->io_port = pci_resource_start(pci, 0); in snd_es1938_create()
1538 chip->sb_port = pci_resource_start(pci, 1); in snd_es1938_create()
1539 chip->vc_port = pci_resource_start(pci, 2); in snd_es1938_create()
1540 chip->mpu_port = pci_resource_start(pci, 3); in snd_es1938_create()
1541 chip->game_port = pci_resource_start(pci, 4); in snd_es1938_create()
1542 /* still use non-managed irq handler as it's re-acquired at PM resume */ in snd_es1938_create()
1543 if (request_irq(pci->irq, snd_es1938_interrupt, IRQF_SHARED, in snd_es1938_create()
1545 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq); in snd_es1938_create()
1546 return -EBUSY; in snd_es1938_create()
1548 chip->irq = pci->irq; in snd_es1938_create()
1549 card->sync_irq = chip->irq; in snd_es1938_create()
1550 card->private_free = snd_es1938_free; in snd_es1938_create()
1551 dev_dbg(card->dev, in snd_es1938_create()
1553 chip->io_port, chip->sb_port, chip->vc_port, chip->mpu_port, chip->game_port); in snd_es1938_create()
1555 chip->ddma_port = chip->vc_port + 0x00; /* fix from Thomas Sailer */ in snd_es1938_create()
1561 /* --------------------------------------------------------------------
1563 * -------------------------------------------------------------------- */
1573 dev_dbg(chip->card->dev, in snd_es1938_interrupt()
1574 "Es1938debug - interrupt status: =0x%x\n", status); in snd_es1938_interrupt()
1580 dev_dbg(chip->card->dev, in snd_es1938_interrupt()
1581 "Es1938debug - AUDIO channel 1 interrupt\n"); in snd_es1938_interrupt()
1582 dev_dbg(chip->card->dev, in snd_es1938_interrupt()
1583 "Es1938debug - AUDIO channel 1 DMAC DMA count: %u\n", in snd_es1938_interrupt()
1585 dev_dbg(chip->card->dev, in snd_es1938_interrupt()
1586 "Es1938debug - AUDIO channel 1 DMAC DMA base: %u\n", in snd_es1938_interrupt()
1588 dev_dbg(chip->card->dev, in snd_es1938_interrupt()
1589 "Es1938debug - AUDIO channel 1 DMAC DMA status: 0x%x\n", in snd_es1938_interrupt()
1595 if (chip->active & ADC1) in snd_es1938_interrupt()
1596 snd_pcm_period_elapsed(chip->capture_substream); in snd_es1938_interrupt()
1597 else if (chip->active & DAC1) in snd_es1938_interrupt()
1598 snd_pcm_period_elapsed(chip->playback2_substream); in snd_es1938_interrupt()
1604 dev_dbg(chip->card->dev, in snd_es1938_interrupt()
1605 "Es1938debug - AUDIO channel 2 interrupt\n"); in snd_es1938_interrupt()
1606 dev_dbg(chip->card->dev, in snd_es1938_interrupt()
1607 "Es1938debug - AUDIO channel 2 DMAC DMA count: %u\n", in snd_es1938_interrupt()
1609 dev_dbg(chip->card->dev, in snd_es1938_interrupt()
1610 "Es1938debug - AUDIO channel 2 DMAC DMA base: %u\n", in snd_es1938_interrupt()
1617 if (chip->active & DAC2) in snd_es1938_interrupt()
1618 snd_pcm_period_elapsed(chip->playback1_substream); in snd_es1938_interrupt()
1625 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, &chip->hw_switch->id); in snd_es1938_interrupt()
1626 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, &chip->hw_volume->id); in snd_es1938_interrupt()
1628 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, in snd_es1938_interrupt()
1629 &chip->master_switch->id); in snd_es1938_interrupt()
1630 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, in snd_es1938_interrupt()
1631 &chip->master_volume->id); in snd_es1938_interrupt()
1640 // replacing the last 0 by 0x40 works for ESS-Solo1, but just doing nothing works as well! in snd_es1938_interrupt()
1641 // andreas@flying-snail.de in snd_es1938_interrupt()
1643 if (chip->rmidi) { in snd_es1938_interrupt()
1645 snd_mpu401_uart_interrupt(irq, chip->rmidi->private_data); in snd_es1938_interrupt()
1659 card = chip->card; in snd_es1938_mixer()
1661 strcpy(card->mixername, "ESS Solo-1"); in snd_es1938_mixer()
1668 chip->master_volume = kctl; in snd_es1938_mixer()
1669 kctl->private_free = snd_es1938_hwv_free; in snd_es1938_mixer()
1672 chip->master_switch = kctl; in snd_es1938_mixer()
1673 kctl->private_free = snd_es1938_hwv_free; in snd_es1938_mixer()
1676 chip->hw_volume = kctl; in snd_es1938_mixer()
1677 kctl->private_free = snd_es1938_hwv_free; in snd_es1938_mixer()
1680 chip->hw_switch = kctl; in snd_es1938_mixer()
1681 kctl->private_free = snd_es1938_hwv_free; in snd_es1938_mixer()
1702 return -ENODEV; in __snd_es1938_probe()
1705 return -ENOENT; in __snd_es1938_probe()
1708 err = snd_devm_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, in __snd_es1938_probe()
1712 chip = card->private_data; in __snd_es1938_probe()
1717 return -ENODEV; in __snd_es1938_probe()
1723 strcpy(card->driver, "ES1938"); in __snd_es1938_probe()
1724 strcpy(card->shortname, "ESS ES1938 (Solo-1)"); in __snd_es1938_probe()
1725 sprintf(card->longname, "%s rev %i, irq %i", in __snd_es1938_probe()
1726 card->shortname, in __snd_es1938_probe()
1727 chip->revision, in __snd_es1938_probe()
1728 chip->irq); in __snd_es1938_probe()
1740 dev_err(card->dev, "OPL3 not detected at 0x%lx\n", in __snd_es1938_probe()
1751 chip->mpu_port, in __snd_es1938_probe()
1753 -1, &chip->rmidi) < 0) { in __snd_es1938_probe()
1754 dev_err(card->dev, "unable to initialize MPU-401\n"); in __snd_es1938_probe()
1756 // this line is vital for MIDI interrupt handling on ess-solo1 in __snd_es1938_probe()
1757 // andreas@flying-snail.de in __snd_es1938_probe()
1775 return snd_card_free_on_error(&pci->dev, __snd_es1938_probe(pci, pci_id)); in snd_es1938_probe()