Lines Matching +full:full +full:- +full:hd

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (c) by James Courtier-Dutton <James@superbug.demon.co.uk>
17 * Corrected speaker output, so Front -> Front etc.
36 * Merging with snd-emu10k1 driver.
42 * Integrated with snd-emu10k1 driver.
49 * e.g. When HD Capture source is set to SPDIF,
50 * setting HD Capture channel to 0 captures from CDROM digital input.
51 * setting HD Capture channel to 1 captures from SPDIF in.
56 * Some stability problems when unloading the snd-p16v kernel module.
57 * --
64 * --
67 * P16V Chip: CA0151-DBS
68 * Audigy 2 Chip: CA0102-IAT
71 * DAC: CS4382-K (8-channel, 24bit, 192Khz)
103 * Class 0401: 1102:0004 (rev 04) Subsystem: 1102:2002 -> Audigy2 ZS 7.1 Model:SB0350
104 * Class 0401: 1102:0004 (rev 04) Subsystem: 1102:1007 -> Audigy2 6.1 Model:SB0240
105 * Class 0401: 1102:0004 (rev 04) Subsystem: 1102:1002 -> Audigy2 Platinum Model:SB msb0240230009266
106 * Class 0401: 1102:0004 (rev 04) Subsystem: 1102:2007 -> Audigy4 Pro Model:SB0380 M1SB0380472001901E
118 .formats = SNDRV_PCM_FMTBIT_S32_LE, /* Only supports 24-bit samples padded to 32 bits. */
124 .buffer_bytes_max = ((65536 - 64) * 8),
126 .period_bytes_max = (65536 - 64),
144 .buffer_bytes_max = (65536 - 64),
146 .period_bytes_max = (65536 - 128) >> 1, /* size has to be N*64 bytes */
155 struct snd_pcm_runtime *runtime = substream->runtime;
159 dev_dbg(emu->card->dev, "epcm device=%d, channel_id=%d\n",
160 substream->pcm->device, channel_id);
163 runtime->hw = snd_p16v_playback_hw;
166 dev_dbg(emu->card->dev,
168 channel_id, channel, channel->use);
169 dev_dbg(emu->card->dev, "open:channel_id=%d, chip=%p, channel=%p\n",
172 /* channel->interrupt = snd_p16v_pcm_channel_interrupt; */
183 struct snd_pcm_runtime *runtime = substream->runtime;
187 dev_dbg(emu->card->dev, "epcm device=%d, channel_id=%d\n",
188 substream->pcm->device, channel_id);
191 runtime->hw = snd_p16v_capture_hw;
239 struct snd_pcm_runtime *runtime = substream->runtime;
240 int channel = substream->pcm->device - emu->p16v_device_offset;
241 u32 *table_base = (u32 *)(emu->p16v_buffer->area+(8*16*channel));
242 u32 period_size_bytes = frames_to_bytes(runtime, runtime->period_size);
247 dev_dbg(emu->card->dev,
251 channel, runtime->rate, runtime->format, runtime->channels,
252 runtime->buffer_size, runtime->period_size,
253 runtime->periods, frames_to_bytes(runtime, 1));
254 dev_dbg(emu->card->dev,
256 runtime->dma_addr, runtime->dma_area, table_base);
257 dev_dbg(emu->card->dev,
259 emu->p16v_buffer->addr, emu->p16v_buffer->area,
260 emu->p16v_buffer->bytes);
264 switch (runtime->rate) {
283 /* FIXME: Check emu->buffer.size before actually writing to it. */
284 for(i = 0; i < runtime->periods; i++) {
285 table_base[i*2]=runtime->dma_addr+(i*period_size_bytes);
289 snd_emu10k1_ptr20_write(emu, PLAYBACK_LIST_ADDR, channel, emu->p16v_buffer->addr+(8*16*channel));
290 snd_emu10k1_ptr20_write(emu, PLAYBACK_LIST_SIZE, channel, (runtime->periods - 1) << 19);
292 snd_emu10k1_ptr20_write(emu, PLAYBACK_DMA_ADDR, channel, runtime->dma_addr);
293 //snd_emu10k1_ptr20_write(emu, PLAYBACK_PERIOD_SIZE, channel, frames_to_bytes(runtime, runtime->period_size)<<16); // buffer size in bytes
306 struct snd_pcm_runtime *runtime = substream->runtime;
307 int channel = substream->pcm->device - emu->p16v_device_offset;
310 dev_dbg(emu->card->dev, "prepare capture:channel_number=%d, rate=%d, "
313 channel, runtime->rate, runtime->format, runtime->channels,
314 runtime->buffer_size, runtime->period_size,
317 switch (runtime->rate) {
332 /* FIXME: Check emu->buffer.size before actually writing to it. */
334 snd_emu10k1_ptr20_write(emu, CAPTURE_DMA_ADDR, channel, runtime->dma_addr);
335 snd_emu10k1_ptr20_write(emu, CAPTURE_BUFFER_SIZE, channel, frames_to_bytes(runtime, runtime->buffer_size) << 16); // buffer size in bytes
347 guard(spinlock_irqsave)(&emu->emu_lock);
348 enable = inl(emu->port + INTE2) | intrenb;
349 outl(enable, emu->port + INTE2);
356 guard(spinlock_irqsave)(&emu->emu_lock);
357 disable = inl(emu->port + INTE2) & (~intrenb);
358 outl(disable, emu->port + INTE2);
365 while ((status = inl(emu->port + IPR2)) != 0) {
366 u32 mask = INTE2_PLAYBACK_CH_0_LOOP; /* Full Loop */
368 /* dev_dbg(emu->card->dev, "p16v status=0x%x\n", status); */
371 emu->pcm_p16v->streams[SNDRV_PCM_STREAM_PLAYBACK].substream;
372 struct snd_pcm_runtime *runtime = substream->runtime;
374 if (runtime && runtime->private_data) {
377 dev_err(emu->card->dev,
384 emu->pcm_p16v->streams[SNDRV_PCM_STREAM_CAPTURE].substream;
385 struct snd_pcm_runtime *runtime = substream->runtime;
387 /* dev_info(emu->card->dev, "capture int found\n"); */
388 if (runtime && runtime->private_data) {
389 /* dev_info(emu->card->dev, "capture period_elapsed\n"); */
393 outl(status, emu->port + IPR2); /* ack all */
421 s->stream != SNDRV_PCM_STREAM_PLAYBACK)
423 runtime = s->runtime;
424 channel = substream->pcm->device-emu->p16v_device_offset;
425 /* dev_dbg(emu->card->dev, "p16v channel=%d\n", channel); */
426 runtime->private_data = (void *)(ptrdiff_t)running;
431 /* dev_dbg(emu->card->dev, "basic=0x%x, inte=0x%x\n", basic, inte); */
443 result = -EINVAL;
454 struct snd_pcm_runtime *runtime = substream->runtime;
463 runtime->private_data = (void *)1;
469 runtime->private_data = NULL;
472 result = -EINVAL;
483 struct snd_pcm_runtime *runtime = substream->runtime;
485 int channel = substream->pcm->device - emu->p16v_device_offset;
487 if (!runtime->private_data)
495 ptr2+= (ptr4 >> 3) * runtime->period_size;
497 if (ptr >= runtime->buffer_size)
498 ptr -= runtime->buffer_size;
508 struct snd_pcm_runtime *runtime = substream->runtime;
512 if (!runtime->private_data)
518 if (ptr >= runtime->buffer_size) {
519 ptr -= runtime->buffer_size;
520 dev_warn(emu->card->dev, "buffer capture limited!\n");
523 dev_dbg(emu->card->dev, "ptr1 = 0x%lx, ptr2=0x%lx, ptr=0x%lx, "
525 ptr1, ptr2, ptr, (int)runtime->buffer_size,
526 (int)runtime->period_size, (int)runtime->frame_bits,
527 (int)runtime->rate);
557 /* dev_dbg(emu->card->dev, "snd_p16v_pcm called. device=%d\n", device); */
558 emu->p16v_device_offset = device;
560 err = snd_pcm_new(emu->card, "p16v", device, 1, capture, &pcm);
564 pcm->private_data = emu;
570 pcm->info_flags = 0;
571 pcm->dev_subclass = SNDRV_PCM_SUBCLASS_GENERIC_MIX;
572 strscpy(pcm->name, "p16v");
573 emu->pcm_p16v = pcm;
574 emu->p16v_interrupt = snd_p16v_interrupt;
576 for(substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream;
578 substream = substream->next) {
580 &emu->pci->dev,
581 (65536 - 64) * 8,
582 (65536 - 64) * 8);
584 dev_dbg(emu->card->dev,
589 for (substream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream;
591 substream = substream->next) {
593 &emu->pci->dev,
594 65536 - 64, 65536 - 64);
596 dev_dbg(emu->card->dev,
607 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
608 uinfo->count = 2;
609 uinfo->value.integer.min = 0;
610 uinfo->value.integer.max = 255;
618 int high_low = (kcontrol->private_value >> 8) & 0xff;
619 int reg = kcontrol->private_value & 0xff;
624 ucontrol->value.integer.value[0] = 0xff - ((value >> 24) & 0xff); /* Left */
625 ucontrol->value.integer.value[1] = 0xff - ((value >> 16) & 0xff); /* Right */
627 ucontrol->value.integer.value[0] = 0xff - ((value >> 8) & 0xff); /* Left */
628 ucontrol->value.integer.value[1] = 0xff - ((value >> 0) & 0xff); /* Right */
637 int high_low = (kcontrol->private_value >> 8) & 0xff;
638 int reg = kcontrol->private_value & 0xff;
644 value |= ((0xff - ucontrol->value.integer.value[0]) << 24) |
645 ((0xff - ucontrol->value.integer.value[1]) << 16);
648 value |= ((0xff - ucontrol->value.integer.value[0]) << 8) |
649 ((0xff - ucontrol->value.integer.value[1]) );
674 ucontrol->value.enumerated.item[0] = emu->p16v_capture_source;
687 val = ucontrol->value.enumerated.item[0] ;
689 return -EINVAL;
690 change = (emu->p16v_capture_source != val);
692 emu->p16v_capture_source = val;
713 ucontrol->value.enumerated.item[0] = emu->p16v_capture_channel;
725 val = ucontrol->value.enumerated.item[0] ;
727 return -EINVAL;
728 change = (emu->p16v_capture_channel != val);
730 emu->p16v_capture_channel = val;
736 static const DECLARE_TLV_DB_SCALE(snd_p16v_db_scale1, -5175, 25, 1);
750 P16V_VOL("HD Analog Front Playback Volume", PLAYBACK_VOLUME_MIXER9, 0),
751 P16V_VOL("HD Analog Rear Playback Volume", PLAYBACK_VOLUME_MIXER10, 1),
752 P16V_VOL("HD Analog Center/LFE Playback Volume", PLAYBACK_VOLUME_MIXER9, 1),
753 P16V_VOL("HD Analog Side Playback Volume", PLAYBACK_VOLUME_MIXER10, 0),
754 P16V_VOL("HD SPDIF Front Playback Volume", PLAYBACK_VOLUME_MIXER7, 0),
755 P16V_VOL("HD SPDIF Rear Playback Volume", PLAYBACK_VOLUME_MIXER8, 1),
756 P16V_VOL("HD SPDIF Center/LFE Playback Volume", PLAYBACK_VOLUME_MIXER7, 1),
757 P16V_VOL("HD SPDIF Side Playback Volume", PLAYBACK_VOLUME_MIXER8, 0),
760 .name = "HD source Capture",
767 .name = "HD channel Capture",
778 struct snd_card *card = emu->card;
794 emu->p16v_saved = vmalloc(array_size(NUM_CHS * 4, 0x80));
795 if (! emu->p16v_saved)
796 return -ENOMEM;
802 vfree(emu->p16v_saved);
810 val = emu->p16v_saved;
821 val = emu->p16v_saved;