Lines Matching +full:i2s +full:- +full:receiver +full:- +full:1

1 // SPDX-License-Identifier: GPL-2.0-or-later
11 * Audio controller: VIA Envy24HT-S (slightly trimmed down Envy24HT, 4in/4out)
13 * Digital receiver: CS8414-CS (supported in this release)
18 * - CS directly from GPIO 10
19 * - CCLK via 74HCT125's gate #4 from GPIO 4
20 * - CDTI via 74HCT125's gate #2 from GPIO 5
21 * CDTI may be completely blocked by 74HCT125's gate #1
28 * Digital receiver: CS8414-CS (supported in this release)
51 #define WM_DAC_ATTEN 0x00 /* DAC1-8 analog attenuation */
53 #define WM_DAC_DIG_ATTEN 0x09 /* DAC1-8 digital attenuation */
58 #define WM_DAC_CTRL2 0x15 /* de-emphasis and zefo-flag */
61 #define WM_POWERDOWN 0x18 /* power-down controls */
62 #define WM_ADC_GAIN 0x19 /* ADC gain L(19)/R(1a) */
84 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
85 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
88 #define WM_VOL_MAX (sizeof(wm_vol) - 1)
99 .cif = 1,
100 .data_mask = 1 << 4,
101 .clk_mask = 1 << 5,
102 .cs_mask = 1 << 10,
103 .cs_addr = 1 << 10,
105 .add_flags = 1 << 3,
115 switch (ice->eeprom.subvendor) {
118 ice->num_total_dacs = 2;
119 ice->num_total_adcs = 2;
120 ice->vt1720 = 1; /* Envy24HT-S have 16 bit wide GPIO */
124 return -EINVAL;
128 ice->akm = kzalloc(sizeof(struct snd_akm4xxx), GFP_KERNEL);
129 ak = ice->akm;
131 return -ENOMEM;
132 ice->akm_codecs = 1;
133 switch (ice->eeprom.subvendor) {
150 switch (ice->eeprom.subvendor) {
162 spdif-in/1xADC, 1xDACs */
163 [ICE_EEP2_ACLINK] = 0x80, /* I2S */
165 [ICE_EEP2_SPDIF] = 0xc3, /* out-en, out-int, spdif-in */
179 spdif-in/1xADC, 4xDACs */
180 [ICE_EEP2_ACLINK] = 0x80, /* I2S */
182 [ICE_EEP2_SPDIF] = 0xc3, /* out-en, out-int, spdif-in */
210 udelay(1);
212 for (i = bits - 1; i >= 0; i--) {
215 udelay(1);
216 if (data & (1 << i))
221 udelay(1);
224 udelay(1);
230 udelay(1);
233 udelay(1);
241 reg <<= 1;
242 return ((unsigned short)ice->akm[0].images[reg] << 8) |
243 ice->akm[0].images[reg + 1];
260 reg <<= 1;
261 ice->akm[0].images[reg] = val >> 8;
262 ice->akm[0].images[reg + 1] = val;
273 nvol = 127 - wm_vol[(((vol & ~WM_VOL_MUTE) *
290 guard(mutex)(&ice->gpio_mutex);
291 ucontrol->value.integer.value[0] = (wm_get(ice, WM_MUTE) & 0x10) ?
292 0 : 1;
305 nval = (oval & ~0x10) | (ucontrol->value.integer.value[0] ? 0 : 0x10);
320 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
321 uinfo->count = 2;
322 uinfo->value.integer.min = 0;
323 uinfo->value.integer.max = WM_VOL_MAX;
331 struct phase28_spec *spec = ice->spec;
334 ucontrol->value.integer.value[i] = spec->master[i] &
343 struct phase28_spec *spec = ice->spec;
348 unsigned int vol = ucontrol->value.integer.value[ch];
351 vol |= spec->master[ch] & WM_VOL_MUTE;
352 if (vol != spec->master[ch]) {
354 spec->master[ch] = vol;
355 for (dac = 0; dac < ice->num_total_dacs; dac += 2)
357 spec->vol[dac + ch],
358 spec->master[ch]);
359 change = 1;
374 0x18, 0x000, /* All power-up */
376 0x16, 0x122, /* I2S, normal polarity, 24bit */
400 0x19, 0x000, /* -12dB ADC/L */
401 0x1a, 0x000, /* -12dB ADC/R */
402 (unsigned short)-1
411 ice->num_total_dacs = 8;
412 ice->num_total_adcs = 2;
416 return -ENOMEM;
417 ice->spec = spec;
420 ice->akm = kzalloc(sizeof(struct snd_akm4xxx), GFP_KERNEL);
421 ak = ice->akm;
423 return -ENOMEM;
424 ice->akm_codecs = 1;
436 udelay(1);
439 udelay(1);
442 udelay(1);
445 for (; *p != (unsigned short)-1; p += 2)
446 wm_put(ice, p[0], p[1]);
450 spec->master[0] = WM_VOL_MUTE;
451 spec->master[1] = WM_VOL_MUTE;
452 for (i = 0; i < ice->num_total_dacs; i++) {
453 spec->vol[i] = WM_VOL_MUTE;
454 wm_set_vol(ice, i, spec->vol[i], spec->master[i % 2]);
466 int voices = kcontrol->private_value >> 8;
467 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
468 uinfo->count = voices;
469 uinfo->value.integer.min = 0; /* mute (-101dB) */
470 uinfo->value.integer.max = 0x7F; /* 0dB */
478 struct phase28_spec *spec = ice->spec;
481 voices = kcontrol->private_value >> 8;
482 ofs = kcontrol->private_value & 0xff;
484 ucontrol->value.integer.value[i] =
485 spec->vol[ofs+i] & ~WM_VOL_MUTE;
493 struct phase28_spec *spec = ice->spec;
497 voices = kcontrol->private_value >> 8;
498 ofs = kcontrol->private_value & 0xff;
502 vol = ucontrol->value.integer.value[i];
505 vol |= spec->vol[ofs+i] & WM_VOL_MUTE;
506 if (vol != spec->vol[ofs+i]) {
507 spec->vol[ofs+i] = vol;
509 wm_set_vol(ice, idx, spec->vol[ofs+i],
510 spec->master[i]);
511 change = 1;
523 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
524 uinfo->count = kcontrol->private_value >> 8;
525 uinfo->value.integer.min = 0;
526 uinfo->value.integer.max = 1;
534 struct phase28_spec *spec = ice->spec;
537 voices = kcontrol->private_value >> 8;
538 ofs = kcontrol->private_value & 0xFF;
541 ucontrol->value.integer.value[i] =
542 (spec->vol[ofs+i] & WM_VOL_MUTE) ? 0 : 1;
550 struct phase28_spec *spec = ice->spec;
553 voices = kcontrol->private_value >> 8;
554 ofs = kcontrol->private_value & 0xFF;
558 int val = (spec->vol[ofs + i] & WM_VOL_MUTE) ? 0 : 1;
559 if (ucontrol->value.integer.value[i] != val) {
560 spec->vol[ofs + i] &= ~WM_VOL_MUTE;
561 spec->vol[ofs + i] |=
562 ucontrol->value.integer.value[i] ? 0 :
564 wm_set_vol(ice, ofs + i, spec->vol[ofs + i],
565 spec->master[i]);
566 change = 1;
583 struct phase28_spec *spec = ice->spec;
585 ucontrol->value.integer.value[0] =
586 (spec->master[0] & WM_VOL_MUTE) ? 0 : 1;
587 ucontrol->value.integer.value[1] =
588 (spec->master[1] & WM_VOL_MUTE) ? 0 : 1;
596 struct phase28_spec *spec = ice->spec;
601 int val = (spec->master[i] & WM_VOL_MUTE) ? 0 : 1;
602 if (ucontrol->value.integer.value[i] != val) {
604 spec->master[i] &= ~WM_VOL_MUTE;
605 spec->master[i] |=
606 ucontrol->value.integer.value[i] ? 0 :
608 for (dac = 0; dac < ice->num_total_dacs; dac += 2)
610 spec->vol[dac + i],
611 spec->master[i]);
612 change = 1;
622 #define PCM_RES 128 /* -64dB */
623 #define PCM_MIN (PCM_0dB - PCM_RES)
627 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
628 uinfo->count = 1;
629 uinfo->value.integer.min = 0; /* mute (-64dB) */
630 uinfo->value.integer.max = PCM_RES; /* 0dB */
640 guard(mutex)(&ice->gpio_mutex);
642 val = val > PCM_MIN ? (val - PCM_MIN) : 0;
643 ucontrol->value.integer.value[0] = val;
654 nvol = ucontrol->value.integer.value[0];
656 return -EINVAL;
664 change = 1;
679 ucontrol->value.integer.value[0] = (wm_get(ice, WM_DAC_CTRL2) & 0xf) ==
691 if (ucontrol->value.integer.value[0])
697 return 1;
710 return snd_ctl_enum_info(uinfo, 1, 2, texts);
717 ucontrol->value.enumerated.item[0] = (wm_get(ice, WM_MASTER) & 0x8) ==
731 if (ucontrol->value.enumerated.item[0])
738 return 1;
743 static const DECLARE_TLV_DB_SCALE(db_scale_wm_dac, -12700, 100, 1);
744 static const DECLARE_TLV_DB_SCALE(db_scale_wm_pcm, -6400, 50, 1);
808 .private_value = (1 << 8) | 4
818 .private_value = (1 << 8) | 4,
827 .private_value = (1 << 8) | 5
837 .private_value = (1 << 8) | 5,
902 err = snd_ctl_add(ice->card,
910 err = snd_ctl_add(ice->card,