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)
227 { PCI_VDEVICE(ESS, 0x1969), 0, }, /* Solo-1 */
237 /* -----------------------------------------------------------------
239 * -----------------------------------------------------------------*/
243 spin_lock_irqsave(&chip->mixer_lock, flags); in snd_es1938_mixer_write()
246 spin_unlock_irqrestore(&chip->mixer_lock, flags); in snd_es1938_mixer_write()
247 dev_dbg(chip->card->dev, "Mixer reg %02x set to %02x\n", reg, val); in snd_es1938_mixer_write()
250 /* -----------------------------------------------------------------
252 * -----------------------------------------------------------------*/
257 spin_lock_irqsave(&chip->mixer_lock, flags); in snd_es1938_mixer_read()
260 spin_unlock_irqrestore(&chip->mixer_lock, flags); in snd_es1938_mixer_read()
261 dev_dbg(chip->card->dev, "Mixer reg %02x now is %02x\n", reg, data); in snd_es1938_mixer_read()
265 /* -----------------------------------------------------------------
267 * -----------------------------------------------------------------*/
273 spin_lock_irqsave(&chip->mixer_lock, flags); in snd_es1938_mixer_bits()
280 dev_dbg(chip->card->dev, in snd_es1938_mixer_bits()
284 spin_unlock_irqrestore(&chip->mixer_lock, flags); in snd_es1938_mixer_bits()
288 /* -----------------------------------------------------------------
290 * -----------------------------------------------------------------*/
302 dev_err(chip->card->dev, in snd_es1938_write_cmd()
306 /* -----------------------------------------------------------------
308 * -----------------------------------------------------------------*/
313 for (i = GET_LOOP_TIMEOUT; i; i--) { in snd_es1938_get_byte()
318 dev_err(chip->card->dev, "get_byte timeout: status 0x02%x\n", v); in snd_es1938_get_byte()
319 return -ENODEV; in snd_es1938_get_byte()
322 /* -----------------------------------------------------------------
324 * -----------------------------------------------------------------*/
328 spin_lock_irqsave(&chip->reg_lock, flags); in snd_es1938_write()
331 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_es1938_write()
332 dev_dbg(chip->card->dev, "Reg %02x set to %02x\n", reg, val); in snd_es1938_write()
335 /* -----------------------------------------------------------------
337 * -----------------------------------------------------------------*/
342 spin_lock_irqsave(&chip->reg_lock, flags); in snd_es1938_read()
346 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_es1938_read()
347 dev_dbg(chip->card->dev, "Reg %02x now is %02x\n", reg, val); in snd_es1938_read()
351 /* -----------------------------------------------------------------
353 * -----------------------------------------------------------------*/
359 spin_lock_irqsave(&chip->reg_lock, flags); in snd_es1938_bits()
368 dev_dbg(chip->card->dev, "Reg %02x was %02x, set to %02x\n", in snd_es1938_bits()
371 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_es1938_bits()
375 /* --------------------------------------------------------------------
377 * --------------------------------------------------------------------*/
391 dev_err(chip->card->dev, "ESS Solo-1 reset failed\n"); in snd_es1938_reset()
414 /* --------------------------------------------------------------------
416 * --------------------------------------------------------------------*/
449 struct snd_pcm_runtime *runtime = substream->runtime; in snd_es1938_rate_set()
450 if (runtime->rate_num == clocks[0].num) in snd_es1938_rate_set()
451 bits = 128 - runtime->rate_den; in snd_es1938_rate_set()
453 bits = 256 - runtime->rate_den; in snd_es1938_rate_set()
456 div0 = 256 - 7160000*20/(8*82*runtime->rate); in snd_es1938_rate_set()
467 /* --------------------------------------------------------------------
469 * --------------------------------------------------------------------*/
474 outl(chip->dma2_start, SLIO_REG(chip, AUDIO2DMAADDR)); in snd_es1938_playback1_setdma()
476 outw(chip->dma2_size, SLIO_REG(chip, AUDIO2DMACOUNT)); in snd_es1938_playback1_setdma()
488 outl(chip->dma1_start, SLDM_REG(chip, DMAADDR)); in snd_es1938_playback2_setdma()
489 outw(chip->dma1_size - 1, SLDM_REG(chip, DMACOUNT)); in snd_es1938_playback2_setdma()
503 outl(chip->dma1_start, SLDM_REG(chip, DMAADDR)); in snd_es1938_capture_setdma()
504 chip->last_capture_dmaaddr = chip->dma1_start; in snd_es1938_capture_setdma()
505 outw(chip->dma1_size - 1, SLDM_REG(chip, DMACOUNT)); in snd_es1938_capture_setdma()
510 /* ----------------------------------------------------------------------
524 chip->active |= ADC1; in snd_es1938_capture_trigger()
529 chip->active &= ~ADC1; in snd_es1938_capture_trigger()
532 return -EINVAL; in snd_es1938_capture_trigger()
550 /* This two stage init gives the FIFO -> DAC connection time to in snd_es1938_playback1_trigger()
552 * no swapping of stereo channels. Report a bug if otherwise :-) */ in snd_es1938_playback1_trigger()
554 chip->active |= DAC2; in snd_es1938_playback1_trigger()
560 chip->active &= ~DAC2; in snd_es1938_playback1_trigger()
563 return -EINVAL; in snd_es1938_playback1_trigger()
577 chip->active |= DAC1; in snd_es1938_playback2_trigger()
582 chip->active &= ~DAC1; in snd_es1938_playback2_trigger()
585 return -EINVAL; in snd_es1938_playback2_trigger()
594 switch (substream->number) { in snd_es1938_playback_trigger()
601 return -EINVAL; in snd_es1938_playback_trigger()
604 /* --------------------------------------------------------------------
606 * --------------------------------------------------------------------*/
610 struct snd_pcm_runtime *runtime = substream->runtime; in snd_es1938_capture_prepare()
615 chip->dma1_size = size; in snd_es1938_capture_prepare()
616 chip->dma1_start = runtime->dma_addr; in snd_es1938_capture_prepare()
618 mono = (runtime->channels > 1) ? 0 : 1; in snd_es1938_capture_prepare()
619 is8 = snd_pcm_format_width(runtime->format) == 16 ? 0 : 1; in snd_es1938_capture_prepare()
620 u = snd_pcm_format_unsigned(runtime->format); in snd_es1938_capture_prepare()
622 chip->dma1_shift = 2 - mono - is8; in snd_es1938_capture_prepare()
632 count = 0x10000 - count; in snd_es1938_capture_prepare()
652 /* ------------------------------------------------------------------------------
654 * ------------------------------------------------------------------------------*/
658 struct snd_pcm_runtime *runtime = substream->runtime; in snd_es1938_playback1_prepare()
663 chip->dma2_size = size; in snd_es1938_playback1_prepare()
664 chip->dma2_start = runtime->dma_addr; in snd_es1938_playback1_prepare()
666 mono = (runtime->channels > 1) ? 0 : 1; in snd_es1938_playback1_prepare()
667 is8 = snd_pcm_format_width(runtime->format) == 16 ? 0 : 1; in snd_es1938_playback1_prepare()
668 u = snd_pcm_format_unsigned(runtime->format); in snd_es1938_playback1_prepare()
670 chip->dma2_shift = 2 - mono - is8; in snd_es1938_playback1_prepare()
678 count = 0x10000 - count; in snd_es1938_playback1_prepare()
695 struct snd_pcm_runtime *runtime = substream->runtime; in snd_es1938_playback2_prepare()
700 chip->dma1_size = size; in snd_es1938_playback2_prepare()
701 chip->dma1_start = runtime->dma_addr; in snd_es1938_playback2_prepare()
703 mono = (runtime->channels > 1) ? 0 : 1; in snd_es1938_playback2_prepare()
704 is8 = snd_pcm_format_width(runtime->format) == 16 ? 0 : 1; in snd_es1938_playback2_prepare()
705 u = snd_pcm_format_unsigned(runtime->format); in snd_es1938_playback2_prepare()
707 chip->dma1_shift = 2 - mono - is8; in snd_es1938_playback2_prepare()
709 count = 0x10000 - count; in snd_es1938_playback2_prepare()
736 switch (substream->number) { in snd_es1938_playback_prepare()
743 return -EINVAL; in snd_es1938_playback_prepare()
749 - is the current DMA address in the valid DMA range ?
750 - is the sum of DMA address and DMA counter pointing to the last DMA byte ?
760 /* This stuff is *needed*, don't ask why - AB */ in snd_es1938_capture_pointer()
764 ptr = chip->dma1_size - 1 - new; in snd_es1938_capture_pointer()
771 diff = chip->dma1_start + chip->dma1_size - ptr - count; in snd_es1938_capture_pointer()
773 if (diff > 3 || ptr < chip->dma1_start in snd_es1938_capture_pointer()
774 || ptr >= chip->dma1_start+chip->dma1_size) in snd_es1938_capture_pointer()
775 ptr = chip->last_capture_dmaaddr; /* bad, use last saved */ in snd_es1938_capture_pointer()
777 chip->last_capture_dmaaddr = ptr; /* good, remember it */ in snd_es1938_capture_pointer()
779 ptr -= chip->dma1_start; in snd_es1938_capture_pointer()
781 return ptr >> chip->dma1_shift; in snd_es1938_capture_pointer()
789 ptr = chip->dma2_size - inw(SLIO_REG(chip, AUDIO2DMACOUNT)); in snd_es1938_playback1_pointer()
791 ptr = inl(SLIO_REG(chip, AUDIO2DMAADDR)) - chip->dma2_start; in snd_es1938_playback1_pointer()
793 return ptr >> chip->dma2_shift; in snd_es1938_playback1_pointer()
802 /* This stuff is *needed*, don't ask why - AB */ in snd_es1938_playback2_pointer()
806 ptr = chip->dma1_size - 1 - new; in snd_es1938_playback2_pointer()
808 ptr = inl(SLDM_REG(chip, DMAADDR)) - chip->dma1_start; in snd_es1938_playback2_pointer()
810 return ptr >> chip->dma1_shift; in snd_es1938_playback2_pointer()
815 switch (substream->number) { in snd_es1938_playback_pointer()
822 return -EINVAL; in snd_es1938_playback_pointer()
826 int channel, unsigned long pos, in snd_es1938_capture_copy() argument
829 struct snd_pcm_runtime *runtime = substream->runtime; in snd_es1938_capture_copy()
832 if (snd_BUG_ON(pos + count > chip->dma1_size)) in snd_es1938_capture_copy()
833 return -EINVAL; in snd_es1938_capture_copy()
834 if (pos + count < chip->dma1_size) { in snd_es1938_capture_copy()
835 if (copy_to_user(dst, runtime->dma_area + pos + 1, count)) in snd_es1938_capture_copy()
836 return -EFAULT; in snd_es1938_capture_copy()
838 if (copy_to_user(dst, runtime->dma_area + pos + 1, count - 1)) in snd_es1938_capture_copy()
839 return -EFAULT; in snd_es1938_capture_copy()
840 if (put_user(runtime->dma_area[0], in snd_es1938_capture_copy()
841 ((unsigned char __user *)dst) + count - 1)) in snd_es1938_capture_copy()
842 return -EFAULT; in snd_es1938_capture_copy()
848 int channel, unsigned long pos, in snd_es1938_capture_copy_kernel() argument
851 struct snd_pcm_runtime *runtime = substream->runtime; in snd_es1938_capture_copy_kernel()
854 if (snd_BUG_ON(pos + count > chip->dma1_size)) in snd_es1938_capture_copy_kernel()
855 return -EINVAL; in snd_es1938_capture_copy_kernel()
856 if (pos + count < chip->dma1_size) { in snd_es1938_capture_copy_kernel()
857 memcpy(dst, runtime->dma_area + pos + 1, count); in snd_es1938_capture_copy_kernel()
859 memcpy(dst, runtime->dma_area + pos + 1, count - 1); in snd_es1938_capture_copy_kernel()
860 runtime->dma_area[0] = *((unsigned char *)dst + count - 1); in snd_es1938_capture_copy_kernel()
865 /* ----------------------------------------------------------------------
867 * ----------------------------------------------------------------------*/
887 /* -----------------------------------------------------------------------
889 * -----------------------------------------------------------------------*/
913 struct snd_pcm_runtime *runtime = substream->runtime; in snd_es1938_capture_open()
915 if (chip->playback2_substream) in snd_es1938_capture_open()
916 return -EAGAIN; in snd_es1938_capture_open()
917 chip->capture_substream = substream; in snd_es1938_capture_open()
918 runtime->hw = snd_es1938_capture; in snd_es1938_capture_open()
928 struct snd_pcm_runtime *runtime = substream->runtime; in snd_es1938_playback_open()
930 switch (substream->number) { in snd_es1938_playback_open()
932 chip->playback1_substream = substream; in snd_es1938_playback_open()
935 if (chip->capture_substream) in snd_es1938_playback_open()
936 return -EAGAIN; in snd_es1938_playback_open()
937 chip->playback2_substream = substream; in snd_es1938_playback_open()
941 return -EINVAL; in snd_es1938_playback_open()
943 runtime->hw = snd_es1938_playback; in snd_es1938_playback_open()
954 chip->capture_substream = NULL; in snd_es1938_capture_close()
962 switch (substream->number) { in snd_es1938_playback_close()
964 chip->playback1_substream = NULL; in snd_es1938_playback_close()
967 chip->playback2_substream = NULL; in snd_es1938_playback_close()
971 return -EINVAL; in snd_es1938_playback_close()
999 err = snd_pcm_new(chip->card, "es-1938-1946", device, 2, 1, &pcm); in snd_es1938_new_pcm()
1005 pcm->private_data = chip; in snd_es1938_new_pcm()
1006 pcm->info_flags = 0; in snd_es1938_new_pcm()
1007 strcpy(pcm->name, "ESS Solo-1"); in snd_es1938_new_pcm()
1010 &chip->pci->dev, 64*1024, 64*1024); in snd_es1938_new_pcm()
1012 chip->pcm = pcm; in snd_es1938_new_pcm()
1016 /* -------------------------------------------------------------------
1025 "Mic", "Mic Master", "CD", "AOUT", in snd_es1938_info_mux()
1036 ucontrol->value.enumerated.item[0] = snd_es1938_mixer_read(chip, 0x1c) & 0x07; in snd_es1938_get_mux()
1044 unsigned char val = ucontrol->value.enumerated.item[0]; in snd_es1938_put_mux()
1047 return -EINVAL; in snd_es1938_put_mux()
1058 ucontrol->value.integer.value[0] = !!(val & 8); in snd_es1938_get_spatializer_enable()
1068 nval = ucontrol->value.integer.value[0] ? 0x0c : 0x04; in snd_es1938_put_spatializer_enable()
1081 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_es1938_info_hw_volume()
1082 uinfo->count = 2; in snd_es1938_info_hw_volume()
1083 uinfo->value.integer.min = 0; in snd_es1938_info_hw_volume()
1084 uinfo->value.integer.max = 63; in snd_es1938_info_hw_volume()
1092 ucontrol->value.integer.value[0] = snd_es1938_mixer_read(chip, 0x61) & 0x3f; in snd_es1938_get_hw_volume()
1093 ucontrol->value.integer.value[1] = snd_es1938_mixer_read(chip, 0x63) & 0x3f; in snd_es1938_get_hw_volume()
1103 ucontrol->value.integer.value[0] = !(snd_es1938_mixer_read(chip, 0x61) & 0x40); in snd_es1938_get_hw_switch()
1104 ucontrol->value.integer.value[1] = !(snd_es1938_mixer_read(chip, 0x63) & 0x40); in snd_es1938_get_hw_switch()
1111 chip->master_volume = NULL; in snd_es1938_hwv_free()
1112 chip->master_switch = NULL; in snd_es1938_hwv_free()
1113 chip->hw_volume = NULL; in snd_es1938_hwv_free()
1114 chip->hw_switch = NULL; in snd_es1938_hwv_free()
1151 int mask = (kcontrol->private_value >> 16) & 0xff; in snd_es1938_info_single()
1153 uinfo->type = mask == 1 ? SNDRV_CTL_ELEM_TYPE_BOOLEAN : SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_es1938_info_single()
1154 uinfo->count = 1; in snd_es1938_info_single()
1155 uinfo->value.integer.min = 0; in snd_es1938_info_single()
1156 uinfo->value.integer.max = mask; in snd_es1938_info_single()
1164 int reg = kcontrol->private_value & 0xff; in snd_es1938_get_single()
1165 int shift = (kcontrol->private_value >> 8) & 0xff; in snd_es1938_get_single()
1166 int mask = (kcontrol->private_value >> 16) & 0xff; in snd_es1938_get_single()
1167 int invert = (kcontrol->private_value >> 24) & 0xff; in snd_es1938_get_single()
1171 ucontrol->value.integer.value[0] = (val >> shift) & mask; in snd_es1938_get_single()
1173 ucontrol->value.integer.value[0] = mask - ucontrol->value.integer.value[0]; in snd_es1938_get_single()
1181 int reg = kcontrol->private_value & 0xff; in snd_es1938_put_single()
1182 int shift = (kcontrol->private_value >> 8) & 0xff; in snd_es1938_put_single()
1183 int mask = (kcontrol->private_value >> 16) & 0xff; in snd_es1938_put_single()
1184 int invert = (kcontrol->private_value >> 24) & 0xff; in snd_es1938_put_single()
1187 val = (ucontrol->value.integer.value[0] & mask); in snd_es1938_put_single()
1189 val = mask - val; in snd_es1938_put_single()
1212 int mask = (kcontrol->private_value >> 24) & 0xff; in snd_es1938_info_double()
1214 uinfo->type = mask == 1 ? SNDRV_CTL_ELEM_TYPE_BOOLEAN : SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_es1938_info_double()
1215 uinfo->count = 2; in snd_es1938_info_double()
1216 uinfo->value.integer.min = 0; in snd_es1938_info_double()
1217 uinfo->value.integer.max = mask; in snd_es1938_info_double()
1225 int left_reg = kcontrol->private_value & 0xff; in snd_es1938_get_double()
1226 int right_reg = (kcontrol->private_value >> 8) & 0xff; in snd_es1938_get_double()
1227 int shift_left = (kcontrol->private_value >> 16) & 0x07; in snd_es1938_get_double()
1228 int shift_right = (kcontrol->private_value >> 19) & 0x07; in snd_es1938_get_double()
1229 int mask = (kcontrol->private_value >> 24) & 0xff; in snd_es1938_get_double()
1230 int invert = (kcontrol->private_value >> 22) & 1; in snd_es1938_get_double()
1238 ucontrol->value.integer.value[0] = (left >> shift_left) & mask; in snd_es1938_get_double()
1239 ucontrol->value.integer.value[1] = (right >> shift_right) & mask; in snd_es1938_get_double()
1241 ucontrol->value.integer.value[0] = mask - ucontrol->value.integer.value[0]; in snd_es1938_get_double()
1242 ucontrol->value.integer.value[1] = mask - ucontrol->value.integer.value[1]; in snd_es1938_get_double()
1251 int left_reg = kcontrol->private_value & 0xff; in snd_es1938_put_double()
1252 int right_reg = (kcontrol->private_value >> 8) & 0xff; in snd_es1938_put_double()
1253 int shift_left = (kcontrol->private_value >> 16) & 0x07; in snd_es1938_put_double()
1254 int shift_right = (kcontrol->private_value >> 19) & 0x07; in snd_es1938_put_double()
1255 int mask = (kcontrol->private_value >> 24) & 0xff; in snd_es1938_put_double()
1256 int invert = (kcontrol->private_value >> 22) & 1; in snd_es1938_put_double()
1260 val1 = ucontrol->value.integer.value[0] & mask; in snd_es1938_put_double()
1261 val2 = ucontrol->value.integer.value[1] & mask; in snd_es1938_put_double()
1263 val1 = mask - val1; in snd_es1938_put_double()
1264 val2 = mask - val2; in snd_es1938_put_double()
1284 0, 54, TLV_DB_SCALE_ITEM(-3600, 50, 1),
1285 54, 63, TLV_DB_SCALE_ITEM(-900, 100, 0),
1289 0, 8, TLV_DB_SCALE_ITEM(-3300, 300, 1),
1290 8, 15, TLV_DB_SCALE_ITEM(-900, 150, 0),
1294 0, 8, TLV_DB_SCALE_ITEM(-3450, 300, 1),
1295 8, 15, TLV_DB_SCALE_ITEM(-1050, 150, 0),
1299 0, 8, TLV_DB_SCALE_ITEM(-2400, 300, 1),
1304 0, 8, TLV_DB_SCALE_ITEM(-3150, 300, 1),
1305 8, 15, TLV_DB_SCALE_ITEM(-750, 150, 0),
1338 ES1938_DOUBLE_TLV("Mic Playback Volume", 0, 0x1a, 0x1a, 4, 0, 15, 0,
1358 ES1938_DOUBLE_TLV("Mic Capture Volume", 0, 0x68, 0x68, 4, 0, 15, 0,
1374 ES1938_SINGLE("3D Control - Level", 0, 0x52, 0, 63, 0),
1377 .name = "3D Control - Switch",
1382 ES1938_SINGLE("Mic Boost (+26dB)", 0, 0x7d, 3, 1, 0)
1386 /* ---------------------------------------------------------------------------- */
1387 /* ---------------------------------------------------------------------------- */
1390 * initialize the chip - used by resume callback, too
1400 pci_set_master(chip->pci); in snd_es1938_chip_init()
1403 pci_write_config_word(chip->pci, SL_PCI_LEGACYCONTROL, 0x805f); in snd_es1938_chip_init()
1406 pci_write_config_word(chip->pci, SL_PCI_DDMACONTROL, chip->ddma_port | 1); in snd_es1938_chip_init()
1409 pci_write_config_dword(chip->pci, SL_PCI_CONFIG, 0); in snd_es1938_chip_init()
1434 struct es1938 *chip = card->private_data; in es1938_suspend()
1440 /* save mixer-related registers */ in es1938_suspend()
1441 for (s = saved_regs, d = chip->saved_regs; *s; s++, d++) in es1938_suspend()
1445 if (chip->irq >= 0) { in es1938_suspend()
1446 free_irq(chip->irq, chip); in es1938_suspend()
1447 chip->irq = -1; in es1938_suspend()
1448 card->sync_irq = -1; in es1938_suspend()
1457 struct es1938 *chip = card->private_data; in es1938_resume()
1461 if (request_irq(pci->irq, snd_es1938_interrupt, in es1938_resume()
1464 pci->irq); in es1938_resume()
1466 return -EIO; in es1938_resume()
1468 chip->irq = pci->irq; in es1938_resume()
1469 card->sync_irq = chip->irq; in es1938_resume()
1472 /* restore mixer-related registers */ in es1938_resume()
1473 for (s = saved_regs, d = chip->saved_regs; *s; s++, d++) { in es1938_resume()
1495 chip->gameport = gp = gameport_allocate_port(); in snd_es1938_create_gameport()
1497 dev_err(chip->card->dev, in snd_es1938_create_gameport()
1499 return -ENOMEM; in snd_es1938_create_gameport()
1503 gameport_set_phys(gp, "pci%s/gameport0", pci_name(chip->pci)); in snd_es1938_create_gameport()
1504 gameport_set_dev_parent(gp, &chip->pci->dev); in snd_es1938_create_gameport()
1505 gp->io = chip->game_port; in snd_es1938_create_gameport()
1514 if (chip->gameport) { in snd_es1938_free_gameport()
1515 gameport_unregister_port(chip->gameport); in snd_es1938_free_gameport()
1516 chip->gameport = NULL; in snd_es1938_free_gameport()
1520 static inline int snd_es1938_create_gameport(struct es1938 *chip) { return -ENOSYS; } in snd_es1938_create_gameport()
1526 struct es1938 *chip = card->private_data; in snd_es1938_free()
1530 if (chip->rmidi) in snd_es1938_free()
1535 if (chip->irq >= 0) in snd_es1938_free()
1536 free_irq(chip->irq, chip); in snd_es1938_free()
1542 struct es1938 *chip = card->private_data; in snd_es1938_create()
1550 if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(24))) { in snd_es1938_create()
1551 dev_err(card->dev, in snd_es1938_create()
1553 return -ENXIO; in snd_es1938_create()
1556 spin_lock_init(&chip->reg_lock); in snd_es1938_create()
1557 spin_lock_init(&chip->mixer_lock); in snd_es1938_create()
1558 chip->card = card; in snd_es1938_create()
1559 chip->pci = pci; in snd_es1938_create()
1560 chip->irq = -1; in snd_es1938_create()
1561 err = pci_request_regions(pci, "ESS Solo-1"); in snd_es1938_create()
1564 chip->io_port = pci_resource_start(pci, 0); in snd_es1938_create()
1565 chip->sb_port = pci_resource_start(pci, 1); in snd_es1938_create()
1566 chip->vc_port = pci_resource_start(pci, 2); in snd_es1938_create()
1567 chip->mpu_port = pci_resource_start(pci, 3); in snd_es1938_create()
1568 chip->game_port = pci_resource_start(pci, 4); in snd_es1938_create()
1569 /* still use non-managed irq handler as it's re-acquired at PM resume */ in snd_es1938_create()
1570 if (request_irq(pci->irq, snd_es1938_interrupt, IRQF_SHARED, in snd_es1938_create()
1572 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq); in snd_es1938_create()
1573 return -EBUSY; in snd_es1938_create()
1575 chip->irq = pci->irq; in snd_es1938_create()
1576 card->sync_irq = chip->irq; in snd_es1938_create()
1577 card->private_free = snd_es1938_free; in snd_es1938_create()
1578 dev_dbg(card->dev, in snd_es1938_create()
1580 chip->io_port, chip->sb_port, chip->vc_port, chip->mpu_port, chip->game_port); in snd_es1938_create()
1582 chip->ddma_port = chip->vc_port + 0x00; /* fix from Thomas Sailer */ in snd_es1938_create()
1588 /* --------------------------------------------------------------------
1590 * -------------------------------------------------------------------- */
1600 dev_dbg(chip->card->dev, in snd_es1938_interrupt()
1601 "Es1938debug - interrupt status: =0x%x\n", status); in snd_es1938_interrupt()
1607 dev_dbg(chip->card->dev, in snd_es1938_interrupt()
1608 "Es1938debug - AUDIO channel 1 interrupt\n"); in snd_es1938_interrupt()
1609 dev_dbg(chip->card->dev, in snd_es1938_interrupt()
1610 "Es1938debug - AUDIO channel 1 DMAC DMA count: %u\n", in snd_es1938_interrupt()
1612 dev_dbg(chip->card->dev, in snd_es1938_interrupt()
1613 "Es1938debug - AUDIO channel 1 DMAC DMA base: %u\n", in snd_es1938_interrupt()
1615 dev_dbg(chip->card->dev, in snd_es1938_interrupt()
1616 "Es1938debug - AUDIO channel 1 DMAC DMA status: 0x%x\n", in snd_es1938_interrupt()
1622 if (chip->active & ADC1) in snd_es1938_interrupt()
1623 snd_pcm_period_elapsed(chip->capture_substream); in snd_es1938_interrupt()
1624 else if (chip->active & DAC1) in snd_es1938_interrupt()
1625 snd_pcm_period_elapsed(chip->playback2_substream); in snd_es1938_interrupt()
1631 dev_dbg(chip->card->dev, in snd_es1938_interrupt()
1632 "Es1938debug - AUDIO channel 2 interrupt\n"); in snd_es1938_interrupt()
1633 dev_dbg(chip->card->dev, in snd_es1938_interrupt()
1634 "Es1938debug - AUDIO channel 2 DMAC DMA count: %u\n", in snd_es1938_interrupt()
1636 dev_dbg(chip->card->dev, in snd_es1938_interrupt()
1637 "Es1938debug - AUDIO channel 2 DMAC DMA base: %u\n", in snd_es1938_interrupt()
1644 if (chip->active & DAC2) in snd_es1938_interrupt()
1645 snd_pcm_period_elapsed(chip->playback1_substream); in snd_es1938_interrupt()
1652 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, &chip->hw_switch->id); in snd_es1938_interrupt()
1653 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, &chip->hw_volume->id); in snd_es1938_interrupt()
1655 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, in snd_es1938_interrupt()
1656 &chip->master_switch->id); in snd_es1938_interrupt()
1657 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, in snd_es1938_interrupt()
1658 &chip->master_volume->id); in snd_es1938_interrupt()
1667 // replacing the last 0 by 0x40 works for ESS-Solo1, but just doing nothing works as well! in snd_es1938_interrupt()
1668 // andreas@flying-snail.de in snd_es1938_interrupt()
1670 if (chip->rmidi) { in snd_es1938_interrupt()
1672 snd_mpu401_uart_interrupt(irq, chip->rmidi->private_data); in snd_es1938_interrupt()
1686 card = chip->card; in snd_es1938_mixer()
1688 strcpy(card->mixername, "ESS Solo-1"); in snd_es1938_mixer()
1695 chip->master_volume = kctl; in snd_es1938_mixer()
1696 kctl->private_free = snd_es1938_hwv_free; in snd_es1938_mixer()
1699 chip->master_switch = kctl; in snd_es1938_mixer()
1700 kctl->private_free = snd_es1938_hwv_free; in snd_es1938_mixer()
1703 chip->hw_volume = kctl; in snd_es1938_mixer()
1704 kctl->private_free = snd_es1938_hwv_free; in snd_es1938_mixer()
1707 chip->hw_switch = kctl; in snd_es1938_mixer()
1708 kctl->private_free = snd_es1938_hwv_free; in snd_es1938_mixer()
1729 return -ENODEV; in __snd_es1938_probe()
1732 return -ENOENT; in __snd_es1938_probe()
1735 err = snd_devm_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, in __snd_es1938_probe()
1739 chip = card->private_data; in __snd_es1938_probe()
1744 return -ENODEV; in __snd_es1938_probe()
1750 strcpy(card->driver, "ES1938"); in __snd_es1938_probe()
1751 strcpy(card->shortname, "ESS ES1938 (Solo-1)"); in __snd_es1938_probe()
1752 sprintf(card->longname, "%s rev %i, irq %i", in __snd_es1938_probe()
1753 card->shortname, in __snd_es1938_probe()
1754 chip->revision, in __snd_es1938_probe()
1755 chip->irq); in __snd_es1938_probe()
1767 dev_err(card->dev, "OPL3 not detected at 0x%lx\n", in __snd_es1938_probe()
1778 chip->mpu_port, in __snd_es1938_probe()
1780 -1, &chip->rmidi) < 0) { in __snd_es1938_probe()
1781 dev_err(card->dev, "unable to initialize MPU-401\n"); in __snd_es1938_probe()
1783 // this line is vital for MIDI interrupt handling on ess-solo1 in __snd_es1938_probe()
1784 // andreas@flying-snail.de in __snd_es1938_probe()
1802 return snd_card_free_on_error(&pci->dev, __snd_es1938_probe(pci, pci_id)); in snd_es1938_probe()