Lines Matching +full:invert +full:- +full:enable

1 // SPDX-License-Identifier: GPL-2.0-or-later
28 for (i = 10000; i; i--) in snd_es1688_dsp_command()
43 for (i = 1000; i; i--) in snd_es1688_dsp_get_byte()
47 return -ENODEV; in snd_es1688_dsp_get_byte()
62 return -1; in snd_es1688_read()
64 return -1; in snd_es1688_read()
92 outb(3, ES1688P(chip, RESET)); /* valid only for ESS chips, SB -> 1 */ in snd_es1688_reset()
98 snd_printd("ess_reset at 0x%lx: failed!!!\n", chip->port); in snd_es1688_reset()
99 return -ENODEV; in snd_es1688_reset()
101 snd_es1688_dsp_command(chip, 0xc6); /* enable extended mode */ in snd_es1688_reset()
116 spin_lock_irqsave(&chip->reg_lock, flags); /* Some ESS1688 cards need this */ in snd_es1688_probe()
130 snd_printdd("ESS: [0x%lx] reset failed... 0x%x\n", chip->port, inb(ES1688P(chip, READ))); in snd_es1688_probe()
131 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_es1688_probe()
132 return -ENODEV; in snd_es1688_probe()
136 for (i = 1000, major = minor = 0; i; i--) { in snd_es1688_probe()
146 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_es1688_probe()
148 snd_printdd("ESS: [0x%lx] found.. major = 0x%x, minor = 0x%x\n", chip->port, major, minor); in snd_es1688_probe()
150 chip->version = (major << 8) | minor; in snd_es1688_probe()
151 if (!chip->version) in snd_es1688_probe()
152 return -ENODEV; /* probably SB */ in snd_es1688_probe()
154 switch (chip->version & 0xfff0) { in snd_es1688_probe()
157 "but driver is in another place\n", chip->port); in snd_es1688_probe()
158 return -ENODEV; in snd_es1688_probe()
164 chip->port, chip->version); in snd_es1688_probe()
165 return -ENODEV; in snd_es1688_probe()
168 spin_lock_irqsave(&chip->reg_lock, flags); in snd_es1688_probe()
171 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_es1688_probe()
173 /* enable joystick, but disable OPL3 */ in snd_es1688_probe()
174 spin_lock_irqsave(&chip->mixer_lock, flags); in snd_es1688_probe()
176 spin_unlock_irqrestore(&chip->mixer_lock, flags); in snd_es1688_probe()
181 static int snd_es1688_init(struct snd_es1688 * chip, int enable) in snd_es1688_init() argument
183 static const int irqs[16] = {-1, -1, 0, -1, -1, 1, -1, 2, -1, 0, 3, -1, -1, -1, -1, -1}; in snd_es1688_init()
187 /* ok.. setup MPU-401 port and joystick and OPL3 */ in snd_es1688_init()
188 cfg = 0x01; /* enable joystick, but disable OPL3 */ in snd_es1688_init()
189 if (enable && chip->mpu_port >= 0x300 && chip->mpu_irq > 0 && chip->hardware != ES1688_HW_688) { in snd_es1688_init()
190 tmp = (chip->mpu_port & 0x0f0) >> 4; in snd_es1688_init()
192 switch (chip->mpu_irq) { in snd_es1688_init()
216 spin_lock_irqsave(&chip->reg_lock, flags); in snd_es1688_init()
218 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_es1688_init()
219 /* --- */ in snd_es1688_init()
220 spin_lock_irqsave(&chip->reg_lock, flags); in snd_es1688_init()
223 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_es1688_init()
224 if (enable) { in snd_es1688_init()
225 cfg = 0xf0; /* enable only DMA counter interrupt */ in snd_es1688_init()
226 irq_bits = irqs[chip->irq & 0x0f]; in snd_es1688_init()
230 chip->port, chip->irq); in snd_es1688_init()
235 return -EINVAL; in snd_es1688_init()
237 spin_lock_irqsave(&chip->reg_lock, flags); in snd_es1688_init()
239 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_es1688_init()
240 cfg = 0xf0; /* extended mode DMA enable */ in snd_es1688_init()
241 dma = chip->dma8; in snd_es1688_init()
244 "for ES1688 chip!!\n", chip->port, dma); in snd_es1688_init()
249 return -EINVAL; in snd_es1688_init()
255 spin_lock_irqsave(&chip->reg_lock, flags); in snd_es1688_init()
257 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_es1688_init()
259 spin_lock_irqsave(&chip->reg_lock, flags); in snd_es1688_init()
262 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_es1688_init()
264 spin_lock_irqsave(&chip->reg_lock, flags); in snd_es1688_init()
268 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_es1688_init()
298 struct snd_pcm_runtime *runtime = substream->runtime; in snd_es1688_set_rate()
301 if (runtime->rate_num == clocks[0].num) in snd_es1688_set_rate()
302 bits = 256 - runtime->rate_den; in snd_es1688_set_rate()
304 bits = 128 - runtime->rate_den; in snd_es1688_set_rate()
306 divider = 256 - 7160000*20/(8*82*runtime->rate); in snd_es1688_set_rate()
319 return -EINVAL; in snd_es1688_trigger()
321 spin_lock(&chip->reg_lock); in snd_es1688_trigger()
322 chip->trigger_value = value; in snd_es1688_trigger()
325 spin_unlock(&chip->reg_lock); in snd_es1688_trigger()
326 return -EINVAL; /* something is wrong */ in snd_es1688_trigger()
331 snd_dma_pointer(chip->dma8, chip->dma_size)); in snd_es1688_trigger()
334 spin_unlock(&chip->reg_lock); in snd_es1688_trigger()
342 struct snd_pcm_runtime *runtime = substream->runtime; in snd_es1688_playback_prepare()
346 chip->dma_size = size; in snd_es1688_playback_prepare()
347 spin_lock_irqsave(&chip->reg_lock, flags); in snd_es1688_playback_prepare()
351 snd_es1688_write(chip, 0xa8, (snd_es1688_read(chip, 0xa8) & ~0x03) | (3 - runtime->channels)); in snd_es1688_playback_prepare()
353 if (runtime->channels == 1) { in snd_es1688_playback_prepare()
354 if (snd_pcm_format_width(runtime->format) == 8) { in snd_es1688_playback_prepare()
366 if (snd_pcm_format_width(runtime->format) == 8) { in snd_es1688_playback_prepare()
381 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_es1688_playback_prepare()
382 /* --- */ in snd_es1688_playback_prepare()
383 count = -count; in snd_es1688_playback_prepare()
384 snd_dma_program(chip->dma8, runtime->dma_addr, size, DMA_MODE_WRITE | DMA_AUTOINIT); in snd_es1688_playback_prepare()
385 spin_lock_irqsave(&chip->reg_lock, flags); in snd_es1688_playback_prepare()
388 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_es1688_playback_prepare()
403 struct snd_pcm_runtime *runtime = substream->runtime; in snd_es1688_capture_prepare()
407 chip->dma_size = size; in snd_es1688_capture_prepare()
408 spin_lock_irqsave(&chip->reg_lock, flags); in snd_es1688_capture_prepare()
413 snd_es1688_write(chip, 0xa8, (snd_es1688_read(chip, 0xa8) & ~0x03) | (3 - runtime->channels)); in snd_es1688_capture_prepare()
415 if (runtime->channels == 1) { in snd_es1688_capture_prepare()
416 if (snd_pcm_format_width(runtime->format) == 8) { in snd_es1688_capture_prepare()
426 if (snd_pcm_format_width(runtime->format) == 8) { in snd_es1688_capture_prepare()
438 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_es1688_capture_prepare()
439 /* --- */ in snd_es1688_capture_prepare()
440 count = -count; in snd_es1688_capture_prepare()
441 snd_dma_program(chip->dma8, runtime->dma_addr, size, DMA_MODE_READ | DMA_AUTOINIT); in snd_es1688_capture_prepare()
442 spin_lock_irqsave(&chip->reg_lock, flags); in snd_es1688_capture_prepare()
445 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_es1688_capture_prepare()
460 if (chip->trigger_value == 0x05) /* ok.. playback is active */ in snd_es1688_interrupt()
461 snd_pcm_period_elapsed(chip->playback_substream); in snd_es1688_interrupt()
462 if (chip->trigger_value == 0x0f) /* ok.. capture is active */ in snd_es1688_interrupt()
463 snd_pcm_period_elapsed(chip->capture_substream); in snd_es1688_interrupt()
474 if (chip->trigger_value != 0x05) in snd_es1688_playback_pointer()
476 ptr = snd_dma_pointer(chip->dma8, chip->dma_size); in snd_es1688_playback_pointer()
477 return bytes_to_frames(substream->runtime, ptr); in snd_es1688_playback_pointer()
485 if (chip->trigger_value != 0x0f) in snd_es1688_capture_pointer()
487 ptr = snd_dma_pointer(chip->dma8, chip->dma_size); in snd_es1688_capture_pointer()
488 return bytes_to_frames(substream->runtime, ptr); in snd_es1688_capture_pointer()
538 struct snd_pcm_runtime *runtime = substream->runtime; in snd_es1688_playback_open()
540 if (chip->capture_substream != NULL) in snd_es1688_playback_open()
541 return -EAGAIN; in snd_es1688_playback_open()
542 chip->playback_substream = substream; in snd_es1688_playback_open()
543 runtime->hw = snd_es1688_playback; in snd_es1688_playback_open()
552 struct snd_pcm_runtime *runtime = substream->runtime; in snd_es1688_capture_open()
554 if (chip->playback_substream != NULL) in snd_es1688_capture_open()
555 return -EAGAIN; in snd_es1688_capture_open()
556 chip->capture_substream = substream; in snd_es1688_capture_open()
557 runtime->hw = snd_es1688_capture; in snd_es1688_capture_open()
567 chip->playback_substream = NULL; in snd_es1688_playback_close()
575 chip->capture_substream = NULL; in snd_es1688_capture_close()
581 if (chip->hardware != ES1688_HW_UNDEF) in snd_es1688_free()
583 release_and_free_resource(chip->res_port); in snd_es1688_free()
584 if (chip->irq >= 0) in snd_es1688_free()
585 free_irq(chip->irq, (void *) chip); in snd_es1688_free()
586 if (chip->dma8 >= 0) { in snd_es1688_free()
587 disable_dma(chip->dma8); in snd_es1688_free()
588 free_dma(chip->dma8); in snd_es1688_free()
595 struct snd_es1688 *chip = device->device_data; in snd_es1688_dev_free()
602 sprintf(tmp, "ES%s688 rev %i", chip->hardware == ES1688_HW_688 ? "" : "1", chip->version & 0x0f); in snd_es1688_chip_id()
622 return -ENOMEM; in snd_es1688_create()
623 chip->irq = -1; in snd_es1688_create()
624 chip->dma8 = -1; in snd_es1688_create()
625 chip->hardware = ES1688_HW_UNDEF; in snd_es1688_create()
627 chip->res_port = request_region(port + 4, 12, "ES1688"); in snd_es1688_create()
628 if (chip->res_port == NULL) { in snd_es1688_create()
630 err = -EBUSY; in snd_es1688_create()
640 chip->irq = irq; in snd_es1688_create()
641 card->sync_irq = chip->irq; in snd_es1688_create()
648 chip->dma8 = dma8; in snd_es1688_create()
650 spin_lock_init(&chip->reg_lock); in snd_es1688_create()
651 spin_lock_init(&chip->mixer_lock); in snd_es1688_create()
652 chip->port = port; in snd_es1688_create()
656 chip->mpu_port = mpu_port; in snd_es1688_create()
657 chip->mpu_irq = mpu_irq; in snd_es1688_create()
658 chip->hardware = hardware; in snd_es1688_create()
704 pcm->private_data = chip; in snd_es1688_pcm()
705 pcm->info_flags = SNDRV_PCM_INFO_HALF_DUPLEX; in snd_es1688_pcm()
706 strcpy(pcm->name, snd_es1688_chip_id(chip)); in snd_es1688_pcm()
707 chip->pcm = pcm; in snd_es1688_pcm()
709 snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, card->dev, in snd_es1688_pcm()
731 ucontrol->value.enumerated.item[0] = snd_es1688_mixer_read(chip, ES1688_REC_DEV) & 7; in snd_es1688_get_mux()
742 if (ucontrol->value.enumerated.item[0] > 8) in snd_es1688_put_mux()
743 return -EINVAL; in snd_es1688_put_mux()
744 spin_lock_irqsave(&chip->reg_lock, flags); in snd_es1688_put_mux()
746 nval = (ucontrol->value.enumerated.item[0] & 7) | (oval & ~15); in snd_es1688_put_mux()
750 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_es1688_put_mux()
754 #define ES1688_SINGLE(xname, xindex, reg, shift, mask, invert) \ argument
758 .private_value = reg | (shift << 8) | (mask << 16) | (invert << 24) }
762 int mask = (kcontrol->private_value >> 16) & 0xff; in snd_es1688_info_single()
764 uinfo->type = mask == 1 ? SNDRV_CTL_ELEM_TYPE_BOOLEAN : SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_es1688_info_single()
765 uinfo->count = 1; in snd_es1688_info_single()
766 uinfo->value.integer.min = 0; in snd_es1688_info_single()
767 uinfo->value.integer.max = mask; in snd_es1688_info_single()
775 int reg = kcontrol->private_value & 0xff; in snd_es1688_get_single()
776 int shift = (kcontrol->private_value >> 8) & 0xff; in snd_es1688_get_single()
777 int mask = (kcontrol->private_value >> 16) & 0xff; in snd_es1688_get_single()
778 int invert = (kcontrol->private_value >> 24) & 0xff; in snd_es1688_get_single() local
780 spin_lock_irqsave(&chip->reg_lock, flags); in snd_es1688_get_single()
781 ucontrol->value.integer.value[0] = (snd_es1688_mixer_read(chip, reg) >> shift) & mask; in snd_es1688_get_single()
782 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_es1688_get_single()
783 if (invert) in snd_es1688_get_single()
784 ucontrol->value.integer.value[0] = mask - ucontrol->value.integer.value[0]; in snd_es1688_get_single()
792 int reg = kcontrol->private_value & 0xff; in snd_es1688_put_single()
793 int shift = (kcontrol->private_value >> 8) & 0xff; in snd_es1688_put_single()
794 int mask = (kcontrol->private_value >> 16) & 0xff; in snd_es1688_put_single()
795 int invert = (kcontrol->private_value >> 24) & 0xff; in snd_es1688_put_single() local
799 nval = (ucontrol->value.integer.value[0] & mask); in snd_es1688_put_single()
800 if (invert) in snd_es1688_put_single()
801 nval = mask - nval; in snd_es1688_put_single()
803 spin_lock_irqsave(&chip->reg_lock, flags); in snd_es1688_put_single()
809 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_es1688_put_single()
813 #define ES1688_DOUBLE(xname, xindex, left_reg, right_reg, shift_left, shift_right, mask, invert) \ argument
817 …reg | (right_reg << 8) | (shift_left << 16) | (shift_right << 19) | (mask << 24) | (invert << 22) }
821 int mask = (kcontrol->private_value >> 24) & 0xff; in snd_es1688_info_double()
823 uinfo->type = mask == 1 ? SNDRV_CTL_ELEM_TYPE_BOOLEAN : SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_es1688_info_double()
824 uinfo->count = 2; in snd_es1688_info_double()
825 uinfo->value.integer.min = 0; in snd_es1688_info_double()
826 uinfo->value.integer.max = mask; in snd_es1688_info_double()
834 int left_reg = kcontrol->private_value & 0xff; in snd_es1688_get_double()
835 int right_reg = (kcontrol->private_value >> 8) & 0xff; in snd_es1688_get_double()
836 int shift_left = (kcontrol->private_value >> 16) & 0x07; in snd_es1688_get_double()
837 int shift_right = (kcontrol->private_value >> 19) & 0x07; in snd_es1688_get_double()
838 int mask = (kcontrol->private_value >> 24) & 0xff; in snd_es1688_get_double()
839 int invert = (kcontrol->private_value >> 22) & 1; in snd_es1688_get_double() local
842 spin_lock_irqsave(&chip->reg_lock, flags); in snd_es1688_get_double()
854 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_es1688_get_double()
855 ucontrol->value.integer.value[0] = (left >> shift_left) & mask; in snd_es1688_get_double()
856 ucontrol->value.integer.value[1] = (right >> shift_right) & mask; in snd_es1688_get_double()
857 if (invert) { in snd_es1688_get_double()
858 ucontrol->value.integer.value[0] = mask - ucontrol->value.integer.value[0]; in snd_es1688_get_double()
859 ucontrol->value.integer.value[1] = mask - ucontrol->value.integer.value[1]; in snd_es1688_get_double()
868 int left_reg = kcontrol->private_value & 0xff; in snd_es1688_put_double()
869 int right_reg = (kcontrol->private_value >> 8) & 0xff; in snd_es1688_put_double()
870 int shift_left = (kcontrol->private_value >> 16) & 0x07; in snd_es1688_put_double()
871 int shift_right = (kcontrol->private_value >> 19) & 0x07; in snd_es1688_put_double()
872 int mask = (kcontrol->private_value >> 24) & 0xff; in snd_es1688_put_double()
873 int invert = (kcontrol->private_value >> 22) & 1; in snd_es1688_put_double() local
877 val1 = ucontrol->value.integer.value[0] & mask; in snd_es1688_put_double()
878 val2 = ucontrol->value.integer.value[1] & mask; in snd_es1688_put_double()
879 if (invert) { in snd_es1688_put_double()
880 val1 = mask - val1; in snd_es1688_put_double()
881 val2 = mask - val2; in snd_es1688_put_double()
885 spin_lock_irqsave(&chip->reg_lock, flags); in snd_es1688_put_double()
923 spin_unlock_irqrestore(&chip->reg_lock, flags); in snd_es1688_put_double()
969 return -EINVAL; in snd_es1688_mixer()
971 strcpy(card->mixername, snd_es1688_chip_id(chip)); in snd_es1688_mixer()