Lines Matching +full:analog +full:- +full:out
1 // SPDX-License-Identifier: GPL-2.0-or-later
11 * Audio controller: VIA Envy24HT-S (slightly trimmed down Envy24HT, 4in/4out)
12 * Analog chip: AK4524 (partially via Philip's 74HCT125)
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
26 * Audio controller: VIA Envy24HT (full untrimmed version, 4in/8out)
27 * Analog chip: WM8770 (8 channel 192k DAC, 2 channel 96k ADC)
28 * Digital receiver: CS8414-CS (supported in this release)
51 #define WM_DAC_ATTEN 0x00 /* DAC1-8 analog attenuation */
52 #define WM_DAC_MASTER_ATTEN 0x08 /* DAC master 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 */
88 #define WM_VOL_MAX (sizeof(wm_vol) - 1)
115 switch (ice->eeprom.subvendor) { in phase22_init()
118 ice->num_total_dacs = 2; in phase22_init()
119 ice->num_total_adcs = 2; in phase22_init()
120 ice->vt1720 = 1; /* Envy24HT-S have 16 bit wide GPIO */ in phase22_init()
124 return -EINVAL; in phase22_init()
127 /* Initialize analog chips */ in phase22_init()
128 ice->akm = kzalloc(sizeof(struct snd_akm4xxx), GFP_KERNEL); in phase22_init()
129 ak = ice->akm; in phase22_init()
131 return -ENOMEM; in phase22_init()
132 ice->akm_codecs = 1; in phase22_init()
133 switch (ice->eeprom.subvendor) { in phase22_init()
150 switch (ice->eeprom.subvendor) { in phase22_add_controls()
162 spdif-in/1xADC, 1xDACs */
165 [ICE_EEP2_SPDIF] = 0xc3, /* out-en, out-int, spdif-in */
179 spdif-in/1xADC, 4xDACs */
182 [ICE_EEP2_SPDIF] = 0xc3, /* out-en, out-int, spdif-in */
212 for (i = bits - 1; i >= 0; i--) { in phase28_spi_write()
242 return ((unsigned short)ice->akm[0].images[reg] << 8) | in wm_get()
243 ice->akm[0].images[reg + 1]; in wm_get()
261 ice->akm[0].images[reg] = val >> 8; in wm_put()
262 ice->akm[0].images[reg + 1] = val; in wm_put()
273 nvol = 127 - wm_vol[(((vol & ~WM_VOL_MUTE) * in wm_set_vol()
290 mutex_lock(&ice->gpio_mutex); in wm_pcm_mute_get()
291 ucontrol->value.integer.value[0] = (wm_get(ice, WM_MUTE) & 0x10) ? in wm_pcm_mute_get()
293 mutex_unlock(&ice->gpio_mutex); in wm_pcm_mute_get()
306 nval = (oval & ~0x10) | (ucontrol->value.integer.value[0] ? 0 : 0x10); in wm_pcm_mute_put()
321 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in wm_master_vol_info()
322 uinfo->count = 2; in wm_master_vol_info()
323 uinfo->value.integer.min = 0; in wm_master_vol_info()
324 uinfo->value.integer.max = WM_VOL_MAX; in wm_master_vol_info()
332 struct phase28_spec *spec = ice->spec; in wm_master_vol_get()
335 ucontrol->value.integer.value[i] = spec->master[i] & in wm_master_vol_get()
344 struct phase28_spec *spec = ice->spec; in wm_master_vol_put()
349 unsigned int vol = ucontrol->value.integer.value[ch]; in wm_master_vol_put()
352 vol |= spec->master[ch] & WM_VOL_MUTE; in wm_master_vol_put()
353 if (vol != spec->master[ch]) { in wm_master_vol_put()
355 spec->master[ch] = vol; in wm_master_vol_put()
356 for (dac = 0; dac < ice->num_total_dacs; dac += 2) in wm_master_vol_put()
358 spec->vol[dac + ch], in wm_master_vol_put()
359 spec->master[ch]); in wm_master_vol_put()
372 0x1c, 0x00B, /* Out Mux1 (VOUT1 = DAC+AUX, VOUT2 = DAC) */ in phase28_init()
373 0x1d, 0x009, /* Out Mux2 (VOUT2 = DAC, VOUT3 = DAC) */ in phase28_init()
375 0x18, 0x000, /* All power-up */ in phase28_init()
379 0x00, 0, /* DAC1 analog mute */ in phase28_init()
380 0x01, 0, /* DAC2 analog mute */ in phase28_init()
381 0x02, 0, /* DAC3 analog mute */ in phase28_init()
382 0x03, 0, /* DAC4 analog mute */ in phase28_init()
383 0x04, 0, /* DAC5 analog mute */ in phase28_init()
384 0x05, 0, /* DAC6 analog mute */ in phase28_init()
385 0x06, 0, /* DAC7 analog mute */ in phase28_init()
386 0x07, 0, /* DAC8 analog mute */ in phase28_init()
387 0x08, 0x100, /* master analog mute */ in phase28_init()
401 0x19, 0x000, /* -12dB ADC/L */ in phase28_init()
402 0x1a, 0x000, /* -12dB ADC/R */ in phase28_init()
403 (unsigned short)-1 in phase28_init()
412 ice->num_total_dacs = 8; in phase28_init()
413 ice->num_total_adcs = 2; in phase28_init()
417 return -ENOMEM; in phase28_init()
418 ice->spec = spec; in phase28_init()
420 /* Initialize analog chips */ in phase28_init()
421 ice->akm = kzalloc(sizeof(struct snd_akm4xxx), GFP_KERNEL); in phase28_init()
422 ak = ice->akm; in phase28_init()
424 return -ENOMEM; in phase28_init()
425 ice->akm_codecs = 1; in phase28_init()
446 for (; *p != (unsigned short)-1; p += 2) in phase28_init()
451 spec->master[0] = WM_VOL_MUTE; in phase28_init()
452 spec->master[1] = WM_VOL_MUTE; in phase28_init()
453 for (i = 0; i < ice->num_total_dacs; i++) { in phase28_init()
454 spec->vol[i] = WM_VOL_MUTE; in phase28_init()
455 wm_set_vol(ice, i, spec->vol[i], spec->master[i % 2]); in phase28_init()
467 int voices = kcontrol->private_value >> 8; in wm_vol_info()
468 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in wm_vol_info()
469 uinfo->count = voices; in wm_vol_info()
470 uinfo->value.integer.min = 0; /* mute (-101dB) */ in wm_vol_info()
471 uinfo->value.integer.max = 0x7F; /* 0dB */ in wm_vol_info()
479 struct phase28_spec *spec = ice->spec; in wm_vol_get()
482 voices = kcontrol->private_value >> 8; in wm_vol_get()
483 ofs = kcontrol->private_value & 0xff; in wm_vol_get()
485 ucontrol->value.integer.value[i] = in wm_vol_get()
486 spec->vol[ofs+i] & ~WM_VOL_MUTE; in wm_vol_get()
494 struct phase28_spec *spec = ice->spec; in wm_vol_put()
498 voices = kcontrol->private_value >> 8; in wm_vol_put()
499 ofs = kcontrol->private_value & 0xff; in wm_vol_put()
503 vol = ucontrol->value.integer.value[i]; in wm_vol_put()
506 vol |= spec->vol[ofs+i] & WM_VOL_MUTE; in wm_vol_put()
507 if (vol != spec->vol[ofs+i]) { in wm_vol_put()
508 spec->vol[ofs+i] = vol; in wm_vol_put()
510 wm_set_vol(ice, idx, spec->vol[ofs+i], in wm_vol_put()
511 spec->master[i]); in wm_vol_put()
524 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; in wm_mute_info()
525 uinfo->count = kcontrol->private_value >> 8; in wm_mute_info()
526 uinfo->value.integer.min = 0; in wm_mute_info()
527 uinfo->value.integer.max = 1; in wm_mute_info()
535 struct phase28_spec *spec = ice->spec; in wm_mute_get()
538 voices = kcontrol->private_value >> 8; in wm_mute_get()
539 ofs = kcontrol->private_value & 0xFF; in wm_mute_get()
542 ucontrol->value.integer.value[i] = in wm_mute_get()
543 (spec->vol[ofs+i] & WM_VOL_MUTE) ? 0 : 1; in wm_mute_get()
551 struct phase28_spec *spec = ice->spec; in wm_mute_put()
554 voices = kcontrol->private_value >> 8; in wm_mute_put()
555 ofs = kcontrol->private_value & 0xFF; in wm_mute_put()
559 int val = (spec->vol[ofs + i] & WM_VOL_MUTE) ? 0 : 1; in wm_mute_put()
560 if (ucontrol->value.integer.value[i] != val) { in wm_mute_put()
561 spec->vol[ofs + i] &= ~WM_VOL_MUTE; in wm_mute_put()
562 spec->vol[ofs + i] |= in wm_mute_put()
563 ucontrol->value.integer.value[i] ? 0 : in wm_mute_put()
565 wm_set_vol(ice, ofs + i, spec->vol[ofs + i], in wm_mute_put()
566 spec->master[i]); in wm_mute_put()
584 struct phase28_spec *spec = ice->spec; in wm_master_mute_get()
586 ucontrol->value.integer.value[0] = in wm_master_mute_get()
587 (spec->master[0] & WM_VOL_MUTE) ? 0 : 1; in wm_master_mute_get()
588 ucontrol->value.integer.value[1] = in wm_master_mute_get()
589 (spec->master[1] & WM_VOL_MUTE) ? 0 : 1; in wm_master_mute_get()
597 struct phase28_spec *spec = ice->spec; in wm_master_mute_put()
602 int val = (spec->master[i] & WM_VOL_MUTE) ? 0 : 1; in wm_master_mute_put()
603 if (ucontrol->value.integer.value[i] != val) { in wm_master_mute_put()
605 spec->master[i] &= ~WM_VOL_MUTE; in wm_master_mute_put()
606 spec->master[i] |= in wm_master_mute_put()
607 ucontrol->value.integer.value[i] ? 0 : in wm_master_mute_put()
609 for (dac = 0; dac < ice->num_total_dacs; dac += 2) in wm_master_mute_put()
611 spec->vol[dac + i], in wm_master_mute_put()
612 spec->master[i]); in wm_master_mute_put()
623 #define PCM_RES 128 /* -64dB */
624 #define PCM_MIN (PCM_0dB - PCM_RES)
628 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in wm_pcm_vol_info()
629 uinfo->count = 1; in wm_pcm_vol_info()
630 uinfo->value.integer.min = 0; /* mute (-64dB) */ in wm_pcm_vol_info()
631 uinfo->value.integer.max = PCM_RES; /* 0dB */ in wm_pcm_vol_info()
641 mutex_lock(&ice->gpio_mutex); in wm_pcm_vol_get()
643 val = val > PCM_MIN ? (val - PCM_MIN) : 0; in wm_pcm_vol_get()
644 ucontrol->value.integer.value[0] = val; in wm_pcm_vol_get()
645 mutex_unlock(&ice->gpio_mutex); in wm_pcm_vol_get()
656 nvol = ucontrol->value.integer.value[0]; in wm_pcm_vol_put()
658 return -EINVAL; in wm_pcm_vol_put()
681 ucontrol->value.integer.value[0] = (wm_get(ice, WM_DAC_CTRL2) & 0xf) == in phase28_deemp_get()
693 if (ucontrol->value.integer.value[0]) in phase28_deemp_put()
719 ucontrol->value.enumerated.item[0] = (wm_get(ice, WM_MASTER) & 0x8) == in phase28_oversampling_get()
733 if (ucontrol->value.enumerated.item[0]) in phase28_oversampling_put()
745 static const DECLARE_TLV_DB_SCALE(db_scale_wm_dac, -12700, 100, 1);
746 static const DECLARE_TLV_DB_SCALE(db_scale_wm_pcm, -6400, 50, 1);
904 err = snd_ctl_add(ice->card, in phase28_add_controls()
912 err = snd_ctl_add(ice->card, in phase28_add_controls()