18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * ALSA driver for ICEnsemble ICE1724 (Envy24) 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Lowlevel functions for Terratec PHASE 22 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Copyright (c) 2005 Misha Zhilin <misha@epiphan.com> 88c2ecf20Sopenharmony_ci */ 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci/* PHASE 22 overview: 118c2ecf20Sopenharmony_ci * Audio controller: VIA Envy24HT-S (slightly trimmed down Envy24HT, 4in/4out) 128c2ecf20Sopenharmony_ci * Analog chip: AK4524 (partially via Philip's 74HCT125) 138c2ecf20Sopenharmony_ci * Digital receiver: CS8414-CS (supported in this release) 148c2ecf20Sopenharmony_ci * PHASE 22 revision 2.0 and Terrasoniq/Musonik TS22PCI have CS8416 158c2ecf20Sopenharmony_ci * (support status unknown, please test and report) 168c2ecf20Sopenharmony_ci * 178c2ecf20Sopenharmony_ci * Envy connects to AK4524 188c2ecf20Sopenharmony_ci * - CS directly from GPIO 10 198c2ecf20Sopenharmony_ci * - CCLK via 74HCT125's gate #4 from GPIO 4 208c2ecf20Sopenharmony_ci * - CDTI via 74HCT125's gate #2 from GPIO 5 218c2ecf20Sopenharmony_ci * CDTI may be completely blocked by 74HCT125's gate #1 228c2ecf20Sopenharmony_ci * controlled by GPIO 3 238c2ecf20Sopenharmony_ci */ 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci/* PHASE 28 overview: 268c2ecf20Sopenharmony_ci * Audio controller: VIA Envy24HT (full untrimmed version, 4in/8out) 278c2ecf20Sopenharmony_ci * Analog chip: WM8770 (8 channel 192k DAC, 2 channel 96k ADC) 288c2ecf20Sopenharmony_ci * Digital receiver: CS8414-CS (supported in this release) 298c2ecf20Sopenharmony_ci */ 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci#include <linux/delay.h> 328c2ecf20Sopenharmony_ci#include <linux/interrupt.h> 338c2ecf20Sopenharmony_ci#include <linux/init.h> 348c2ecf20Sopenharmony_ci#include <linux/slab.h> 358c2ecf20Sopenharmony_ci#include <linux/mutex.h> 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci#include <sound/core.h> 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci#include "ice1712.h" 408c2ecf20Sopenharmony_ci#include "envy24ht.h" 418c2ecf20Sopenharmony_ci#include "phase.h" 428c2ecf20Sopenharmony_ci#include <sound/tlv.h> 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci/* AC97 register cache for Phase28 */ 458c2ecf20Sopenharmony_cistruct phase28_spec { 468c2ecf20Sopenharmony_ci unsigned short master[2]; 478c2ecf20Sopenharmony_ci unsigned short vol[8]; 488c2ecf20Sopenharmony_ci}; 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ci/* WM8770 registers */ 518c2ecf20Sopenharmony_ci#define WM_DAC_ATTEN 0x00 /* DAC1-8 analog attenuation */ 528c2ecf20Sopenharmony_ci#define WM_DAC_MASTER_ATTEN 0x08 /* DAC master analog attenuation */ 538c2ecf20Sopenharmony_ci#define WM_DAC_DIG_ATTEN 0x09 /* DAC1-8 digital attenuation */ 548c2ecf20Sopenharmony_ci#define WM_DAC_DIG_MASTER_ATTEN 0x11 /* DAC master digital attenuation */ 558c2ecf20Sopenharmony_ci#define WM_PHASE_SWAP 0x12 /* DAC phase */ 568c2ecf20Sopenharmony_ci#define WM_DAC_CTRL1 0x13 /* DAC control bits */ 578c2ecf20Sopenharmony_ci#define WM_MUTE 0x14 /* mute controls */ 588c2ecf20Sopenharmony_ci#define WM_DAC_CTRL2 0x15 /* de-emphasis and zefo-flag */ 598c2ecf20Sopenharmony_ci#define WM_INT_CTRL 0x16 /* interface control */ 608c2ecf20Sopenharmony_ci#define WM_MASTER 0x17 /* master clock and mode */ 618c2ecf20Sopenharmony_ci#define WM_POWERDOWN 0x18 /* power-down controls */ 628c2ecf20Sopenharmony_ci#define WM_ADC_GAIN 0x19 /* ADC gain L(19)/R(1a) */ 638c2ecf20Sopenharmony_ci#define WM_ADC_MUX 0x1b /* input MUX */ 648c2ecf20Sopenharmony_ci#define WM_OUT_MUX1 0x1c /* output MUX */ 658c2ecf20Sopenharmony_ci#define WM_OUT_MUX2 0x1e /* output MUX */ 668c2ecf20Sopenharmony_ci#define WM_RESET 0x1f /* software reset */ 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci/* 708c2ecf20Sopenharmony_ci * Logarithmic volume values for WM8770 718c2ecf20Sopenharmony_ci * Computed as 20 * Log10(255 / x) 728c2ecf20Sopenharmony_ci */ 738c2ecf20Sopenharmony_cistatic const unsigned char wm_vol[256] = { 748c2ecf20Sopenharmony_ci 127, 48, 42, 39, 36, 34, 33, 31, 30, 29, 28, 27, 27, 26, 25, 25, 24, 758c2ecf20Sopenharmony_ci 24, 23, 23, 22, 22, 21, 21, 21, 20, 20, 20, 19, 19, 19, 18, 18, 18, 18, 768c2ecf20Sopenharmony_ci 17, 17, 17, 17, 16, 16, 16, 16, 15, 15, 15, 15, 15, 15, 14, 14, 14, 14, 778c2ecf20Sopenharmony_ci 14, 13, 13, 13, 13, 13, 13, 13, 12, 12, 12, 12, 12, 12, 12, 11, 11, 11, 788c2ecf20Sopenharmony_ci 11, 11, 11, 11, 11, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 9, 9, 9, 798c2ecf20Sopenharmony_ci 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 808c2ecf20Sopenharmony_ci 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 818c2ecf20Sopenharmony_ci 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 828c2ecf20Sopenharmony_ci 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 838c2ecf20Sopenharmony_ci 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 848c2ecf20Sopenharmony_ci 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 858c2ecf20Sopenharmony_ci 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 868c2ecf20Sopenharmony_ci}; 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ci#define WM_VOL_MAX (sizeof(wm_vol) - 1) 898c2ecf20Sopenharmony_ci#define WM_VOL_MUTE 0x8000 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_cistatic const struct snd_akm4xxx akm_phase22 = { 928c2ecf20Sopenharmony_ci .type = SND_AK4524, 938c2ecf20Sopenharmony_ci .num_dacs = 2, 948c2ecf20Sopenharmony_ci .num_adcs = 2, 958c2ecf20Sopenharmony_ci}; 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_cistatic const struct snd_ak4xxx_private akm_phase22_priv = { 988c2ecf20Sopenharmony_ci .caddr = 2, 998c2ecf20Sopenharmony_ci .cif = 1, 1008c2ecf20Sopenharmony_ci .data_mask = 1 << 4, 1018c2ecf20Sopenharmony_ci .clk_mask = 1 << 5, 1028c2ecf20Sopenharmony_ci .cs_mask = 1 << 10, 1038c2ecf20Sopenharmony_ci .cs_addr = 1 << 10, 1048c2ecf20Sopenharmony_ci .cs_none = 0, 1058c2ecf20Sopenharmony_ci .add_flags = 1 << 3, 1068c2ecf20Sopenharmony_ci .mask_flags = 0, 1078c2ecf20Sopenharmony_ci}; 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_cistatic int phase22_init(struct snd_ice1712 *ice) 1108c2ecf20Sopenharmony_ci{ 1118c2ecf20Sopenharmony_ci struct snd_akm4xxx *ak; 1128c2ecf20Sopenharmony_ci int err; 1138c2ecf20Sopenharmony_ci 1148c2ecf20Sopenharmony_ci /* Configure DAC/ADC description for generic part of ice1724 */ 1158c2ecf20Sopenharmony_ci switch (ice->eeprom.subvendor) { 1168c2ecf20Sopenharmony_ci case VT1724_SUBDEVICE_PHASE22: 1178c2ecf20Sopenharmony_ci case VT1724_SUBDEVICE_TS22: 1188c2ecf20Sopenharmony_ci ice->num_total_dacs = 2; 1198c2ecf20Sopenharmony_ci ice->num_total_adcs = 2; 1208c2ecf20Sopenharmony_ci ice->vt1720 = 1; /* Envy24HT-S have 16 bit wide GPIO */ 1218c2ecf20Sopenharmony_ci break; 1228c2ecf20Sopenharmony_ci default: 1238c2ecf20Sopenharmony_ci snd_BUG(); 1248c2ecf20Sopenharmony_ci return -EINVAL; 1258c2ecf20Sopenharmony_ci } 1268c2ecf20Sopenharmony_ci 1278c2ecf20Sopenharmony_ci /* Initialize analog chips */ 1288c2ecf20Sopenharmony_ci ice->akm = kzalloc(sizeof(struct snd_akm4xxx), GFP_KERNEL); 1298c2ecf20Sopenharmony_ci ak = ice->akm; 1308c2ecf20Sopenharmony_ci if (!ak) 1318c2ecf20Sopenharmony_ci return -ENOMEM; 1328c2ecf20Sopenharmony_ci ice->akm_codecs = 1; 1338c2ecf20Sopenharmony_ci switch (ice->eeprom.subvendor) { 1348c2ecf20Sopenharmony_ci case VT1724_SUBDEVICE_PHASE22: 1358c2ecf20Sopenharmony_ci case VT1724_SUBDEVICE_TS22: 1368c2ecf20Sopenharmony_ci err = snd_ice1712_akm4xxx_init(ak, &akm_phase22, 1378c2ecf20Sopenharmony_ci &akm_phase22_priv, ice); 1388c2ecf20Sopenharmony_ci if (err < 0) 1398c2ecf20Sopenharmony_ci return err; 1408c2ecf20Sopenharmony_ci break; 1418c2ecf20Sopenharmony_ci } 1428c2ecf20Sopenharmony_ci 1438c2ecf20Sopenharmony_ci return 0; 1448c2ecf20Sopenharmony_ci} 1458c2ecf20Sopenharmony_ci 1468c2ecf20Sopenharmony_cistatic int phase22_add_controls(struct snd_ice1712 *ice) 1478c2ecf20Sopenharmony_ci{ 1488c2ecf20Sopenharmony_ci int err = 0; 1498c2ecf20Sopenharmony_ci 1508c2ecf20Sopenharmony_ci switch (ice->eeprom.subvendor) { 1518c2ecf20Sopenharmony_ci case VT1724_SUBDEVICE_PHASE22: 1528c2ecf20Sopenharmony_ci case VT1724_SUBDEVICE_TS22: 1538c2ecf20Sopenharmony_ci err = snd_ice1712_akm4xxx_build_controls(ice); 1548c2ecf20Sopenharmony_ci if (err < 0) 1558c2ecf20Sopenharmony_ci return err; 1568c2ecf20Sopenharmony_ci } 1578c2ecf20Sopenharmony_ci return 0; 1588c2ecf20Sopenharmony_ci} 1598c2ecf20Sopenharmony_ci 1608c2ecf20Sopenharmony_cistatic const unsigned char phase22_eeprom[] = { 1618c2ecf20Sopenharmony_ci [ICE_EEP2_SYSCONF] = 0x28, /* clock 512, mpu 401, 1628c2ecf20Sopenharmony_ci spdif-in/1xADC, 1xDACs */ 1638c2ecf20Sopenharmony_ci [ICE_EEP2_ACLINK] = 0x80, /* I2S */ 1648c2ecf20Sopenharmony_ci [ICE_EEP2_I2S] = 0xf0, /* vol, 96k, 24bit */ 1658c2ecf20Sopenharmony_ci [ICE_EEP2_SPDIF] = 0xc3, /* out-en, out-int, spdif-in */ 1668c2ecf20Sopenharmony_ci [ICE_EEP2_GPIO_DIR] = 0xff, 1678c2ecf20Sopenharmony_ci [ICE_EEP2_GPIO_DIR1] = 0xff, 1688c2ecf20Sopenharmony_ci [ICE_EEP2_GPIO_DIR2] = 0xff, 1698c2ecf20Sopenharmony_ci [ICE_EEP2_GPIO_MASK] = 0x00, 1708c2ecf20Sopenharmony_ci [ICE_EEP2_GPIO_MASK1] = 0x00, 1718c2ecf20Sopenharmony_ci [ICE_EEP2_GPIO_MASK2] = 0x00, 1728c2ecf20Sopenharmony_ci [ICE_EEP2_GPIO_STATE] = 0x00, 1738c2ecf20Sopenharmony_ci [ICE_EEP2_GPIO_STATE1] = 0x00, 1748c2ecf20Sopenharmony_ci [ICE_EEP2_GPIO_STATE2] = 0x00, 1758c2ecf20Sopenharmony_ci}; 1768c2ecf20Sopenharmony_ci 1778c2ecf20Sopenharmony_cistatic const unsigned char phase28_eeprom[] = { 1788c2ecf20Sopenharmony_ci [ICE_EEP2_SYSCONF] = 0x2b, /* clock 512, mpu401, 1798c2ecf20Sopenharmony_ci spdif-in/1xADC, 4xDACs */ 1808c2ecf20Sopenharmony_ci [ICE_EEP2_ACLINK] = 0x80, /* I2S */ 1818c2ecf20Sopenharmony_ci [ICE_EEP2_I2S] = 0xfc, /* vol, 96k, 24bit, 192k */ 1828c2ecf20Sopenharmony_ci [ICE_EEP2_SPDIF] = 0xc3, /* out-en, out-int, spdif-in */ 1838c2ecf20Sopenharmony_ci [ICE_EEP2_GPIO_DIR] = 0xff, 1848c2ecf20Sopenharmony_ci [ICE_EEP2_GPIO_DIR1] = 0xff, 1858c2ecf20Sopenharmony_ci [ICE_EEP2_GPIO_DIR2] = 0x5f, 1868c2ecf20Sopenharmony_ci [ICE_EEP2_GPIO_MASK] = 0x00, 1878c2ecf20Sopenharmony_ci [ICE_EEP2_GPIO_MASK1] = 0x00, 1888c2ecf20Sopenharmony_ci [ICE_EEP2_GPIO_MASK2] = 0x00, 1898c2ecf20Sopenharmony_ci [ICE_EEP2_GPIO_STATE] = 0x00, 1908c2ecf20Sopenharmony_ci [ICE_EEP2_GPIO_STATE1] = 0x00, 1918c2ecf20Sopenharmony_ci [ICE_EEP2_GPIO_STATE2] = 0x00, 1928c2ecf20Sopenharmony_ci}; 1938c2ecf20Sopenharmony_ci 1948c2ecf20Sopenharmony_ci/* 1958c2ecf20Sopenharmony_ci * write data in the SPI mode 1968c2ecf20Sopenharmony_ci */ 1978c2ecf20Sopenharmony_cistatic void phase28_spi_write(struct snd_ice1712 *ice, unsigned int cs, 1988c2ecf20Sopenharmony_ci unsigned int data, int bits) 1998c2ecf20Sopenharmony_ci{ 2008c2ecf20Sopenharmony_ci unsigned int tmp; 2018c2ecf20Sopenharmony_ci int i; 2028c2ecf20Sopenharmony_ci 2038c2ecf20Sopenharmony_ci tmp = snd_ice1712_gpio_read(ice); 2048c2ecf20Sopenharmony_ci 2058c2ecf20Sopenharmony_ci snd_ice1712_gpio_set_mask(ice, ~(PHASE28_WM_RW|PHASE28_SPI_MOSI| 2068c2ecf20Sopenharmony_ci PHASE28_SPI_CLK|PHASE28_WM_CS)); 2078c2ecf20Sopenharmony_ci tmp |= PHASE28_WM_RW; 2088c2ecf20Sopenharmony_ci tmp &= ~cs; 2098c2ecf20Sopenharmony_ci snd_ice1712_gpio_write(ice, tmp); 2108c2ecf20Sopenharmony_ci udelay(1); 2118c2ecf20Sopenharmony_ci 2128c2ecf20Sopenharmony_ci for (i = bits - 1; i >= 0; i--) { 2138c2ecf20Sopenharmony_ci tmp &= ~PHASE28_SPI_CLK; 2148c2ecf20Sopenharmony_ci snd_ice1712_gpio_write(ice, tmp); 2158c2ecf20Sopenharmony_ci udelay(1); 2168c2ecf20Sopenharmony_ci if (data & (1 << i)) 2178c2ecf20Sopenharmony_ci tmp |= PHASE28_SPI_MOSI; 2188c2ecf20Sopenharmony_ci else 2198c2ecf20Sopenharmony_ci tmp &= ~PHASE28_SPI_MOSI; 2208c2ecf20Sopenharmony_ci snd_ice1712_gpio_write(ice, tmp); 2218c2ecf20Sopenharmony_ci udelay(1); 2228c2ecf20Sopenharmony_ci tmp |= PHASE28_SPI_CLK; 2238c2ecf20Sopenharmony_ci snd_ice1712_gpio_write(ice, tmp); 2248c2ecf20Sopenharmony_ci udelay(1); 2258c2ecf20Sopenharmony_ci } 2268c2ecf20Sopenharmony_ci 2278c2ecf20Sopenharmony_ci tmp &= ~PHASE28_SPI_CLK; 2288c2ecf20Sopenharmony_ci tmp |= cs; 2298c2ecf20Sopenharmony_ci snd_ice1712_gpio_write(ice, tmp); 2308c2ecf20Sopenharmony_ci udelay(1); 2318c2ecf20Sopenharmony_ci tmp |= PHASE28_SPI_CLK; 2328c2ecf20Sopenharmony_ci snd_ice1712_gpio_write(ice, tmp); 2338c2ecf20Sopenharmony_ci udelay(1); 2348c2ecf20Sopenharmony_ci} 2358c2ecf20Sopenharmony_ci 2368c2ecf20Sopenharmony_ci/* 2378c2ecf20Sopenharmony_ci * get the current register value of WM codec 2388c2ecf20Sopenharmony_ci */ 2398c2ecf20Sopenharmony_cistatic unsigned short wm_get(struct snd_ice1712 *ice, int reg) 2408c2ecf20Sopenharmony_ci{ 2418c2ecf20Sopenharmony_ci reg <<= 1; 2428c2ecf20Sopenharmony_ci return ((unsigned short)ice->akm[0].images[reg] << 8) | 2438c2ecf20Sopenharmony_ci ice->akm[0].images[reg + 1]; 2448c2ecf20Sopenharmony_ci} 2458c2ecf20Sopenharmony_ci 2468c2ecf20Sopenharmony_ci/* 2478c2ecf20Sopenharmony_ci * set the register value of WM codec 2488c2ecf20Sopenharmony_ci */ 2498c2ecf20Sopenharmony_cistatic void wm_put_nocache(struct snd_ice1712 *ice, int reg, unsigned short val) 2508c2ecf20Sopenharmony_ci{ 2518c2ecf20Sopenharmony_ci phase28_spi_write(ice, PHASE28_WM_CS, (reg << 9) | (val & 0x1ff), 16); 2528c2ecf20Sopenharmony_ci} 2538c2ecf20Sopenharmony_ci 2548c2ecf20Sopenharmony_ci/* 2558c2ecf20Sopenharmony_ci * set the register value of WM codec and remember it 2568c2ecf20Sopenharmony_ci */ 2578c2ecf20Sopenharmony_cistatic void wm_put(struct snd_ice1712 *ice, int reg, unsigned short val) 2588c2ecf20Sopenharmony_ci{ 2598c2ecf20Sopenharmony_ci wm_put_nocache(ice, reg, val); 2608c2ecf20Sopenharmony_ci reg <<= 1; 2618c2ecf20Sopenharmony_ci ice->akm[0].images[reg] = val >> 8; 2628c2ecf20Sopenharmony_ci ice->akm[0].images[reg + 1] = val; 2638c2ecf20Sopenharmony_ci} 2648c2ecf20Sopenharmony_ci 2658c2ecf20Sopenharmony_cistatic void wm_set_vol(struct snd_ice1712 *ice, unsigned int index, 2668c2ecf20Sopenharmony_ci unsigned short vol, unsigned short master) 2678c2ecf20Sopenharmony_ci{ 2688c2ecf20Sopenharmony_ci unsigned char nvol; 2698c2ecf20Sopenharmony_ci 2708c2ecf20Sopenharmony_ci if ((master & WM_VOL_MUTE) || (vol & WM_VOL_MUTE)) 2718c2ecf20Sopenharmony_ci nvol = 0; 2728c2ecf20Sopenharmony_ci else 2738c2ecf20Sopenharmony_ci nvol = 127 - wm_vol[(((vol & ~WM_VOL_MUTE) * 2748c2ecf20Sopenharmony_ci (master & ~WM_VOL_MUTE)) / 127) & WM_VOL_MAX]; 2758c2ecf20Sopenharmony_ci 2768c2ecf20Sopenharmony_ci wm_put(ice, index, nvol); 2778c2ecf20Sopenharmony_ci wm_put_nocache(ice, index, 0x180 | nvol); 2788c2ecf20Sopenharmony_ci} 2798c2ecf20Sopenharmony_ci 2808c2ecf20Sopenharmony_ci/* 2818c2ecf20Sopenharmony_ci * DAC mute control 2828c2ecf20Sopenharmony_ci */ 2838c2ecf20Sopenharmony_ci#define wm_pcm_mute_info snd_ctl_boolean_mono_info 2848c2ecf20Sopenharmony_ci 2858c2ecf20Sopenharmony_cistatic int wm_pcm_mute_get(struct snd_kcontrol *kcontrol, 2868c2ecf20Sopenharmony_ci struct snd_ctl_elem_value *ucontrol) 2878c2ecf20Sopenharmony_ci{ 2888c2ecf20Sopenharmony_ci struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 2898c2ecf20Sopenharmony_ci 2908c2ecf20Sopenharmony_ci mutex_lock(&ice->gpio_mutex); 2918c2ecf20Sopenharmony_ci ucontrol->value.integer.value[0] = (wm_get(ice, WM_MUTE) & 0x10) ? 2928c2ecf20Sopenharmony_ci 0 : 1; 2938c2ecf20Sopenharmony_ci mutex_unlock(&ice->gpio_mutex); 2948c2ecf20Sopenharmony_ci return 0; 2958c2ecf20Sopenharmony_ci} 2968c2ecf20Sopenharmony_ci 2978c2ecf20Sopenharmony_cistatic int wm_pcm_mute_put(struct snd_kcontrol *kcontrol, 2988c2ecf20Sopenharmony_ci struct snd_ctl_elem_value *ucontrol) 2998c2ecf20Sopenharmony_ci{ 3008c2ecf20Sopenharmony_ci struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 3018c2ecf20Sopenharmony_ci unsigned short nval, oval; 3028c2ecf20Sopenharmony_ci int change; 3038c2ecf20Sopenharmony_ci 3048c2ecf20Sopenharmony_ci snd_ice1712_save_gpio_status(ice); 3058c2ecf20Sopenharmony_ci oval = wm_get(ice, WM_MUTE); 3068c2ecf20Sopenharmony_ci nval = (oval & ~0x10) | (ucontrol->value.integer.value[0] ? 0 : 0x10); 3078c2ecf20Sopenharmony_ci change = (nval != oval); 3088c2ecf20Sopenharmony_ci if (change) 3098c2ecf20Sopenharmony_ci wm_put(ice, WM_MUTE, nval); 3108c2ecf20Sopenharmony_ci snd_ice1712_restore_gpio_status(ice); 3118c2ecf20Sopenharmony_ci 3128c2ecf20Sopenharmony_ci return change; 3138c2ecf20Sopenharmony_ci} 3148c2ecf20Sopenharmony_ci 3158c2ecf20Sopenharmony_ci/* 3168c2ecf20Sopenharmony_ci * Master volume attenuation mixer control 3178c2ecf20Sopenharmony_ci */ 3188c2ecf20Sopenharmony_cistatic int wm_master_vol_info(struct snd_kcontrol *kcontrol, 3198c2ecf20Sopenharmony_ci struct snd_ctl_elem_info *uinfo) 3208c2ecf20Sopenharmony_ci{ 3218c2ecf20Sopenharmony_ci uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 3228c2ecf20Sopenharmony_ci uinfo->count = 2; 3238c2ecf20Sopenharmony_ci uinfo->value.integer.min = 0; 3248c2ecf20Sopenharmony_ci uinfo->value.integer.max = WM_VOL_MAX; 3258c2ecf20Sopenharmony_ci return 0; 3268c2ecf20Sopenharmony_ci} 3278c2ecf20Sopenharmony_ci 3288c2ecf20Sopenharmony_cistatic int wm_master_vol_get(struct snd_kcontrol *kcontrol, 3298c2ecf20Sopenharmony_ci struct snd_ctl_elem_value *ucontrol) 3308c2ecf20Sopenharmony_ci{ 3318c2ecf20Sopenharmony_ci struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 3328c2ecf20Sopenharmony_ci struct phase28_spec *spec = ice->spec; 3338c2ecf20Sopenharmony_ci int i; 3348c2ecf20Sopenharmony_ci for (i = 0; i < 2; i++) 3358c2ecf20Sopenharmony_ci ucontrol->value.integer.value[i] = spec->master[i] & 3368c2ecf20Sopenharmony_ci ~WM_VOL_MUTE; 3378c2ecf20Sopenharmony_ci return 0; 3388c2ecf20Sopenharmony_ci} 3398c2ecf20Sopenharmony_ci 3408c2ecf20Sopenharmony_cistatic int wm_master_vol_put(struct snd_kcontrol *kcontrol, 3418c2ecf20Sopenharmony_ci struct snd_ctl_elem_value *ucontrol) 3428c2ecf20Sopenharmony_ci{ 3438c2ecf20Sopenharmony_ci struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 3448c2ecf20Sopenharmony_ci struct phase28_spec *spec = ice->spec; 3458c2ecf20Sopenharmony_ci int ch, change = 0; 3468c2ecf20Sopenharmony_ci 3478c2ecf20Sopenharmony_ci snd_ice1712_save_gpio_status(ice); 3488c2ecf20Sopenharmony_ci for (ch = 0; ch < 2; ch++) { 3498c2ecf20Sopenharmony_ci unsigned int vol = ucontrol->value.integer.value[ch]; 3508c2ecf20Sopenharmony_ci if (vol > WM_VOL_MAX) 3518c2ecf20Sopenharmony_ci continue; 3528c2ecf20Sopenharmony_ci vol |= spec->master[ch] & WM_VOL_MUTE; 3538c2ecf20Sopenharmony_ci if (vol != spec->master[ch]) { 3548c2ecf20Sopenharmony_ci int dac; 3558c2ecf20Sopenharmony_ci spec->master[ch] = vol; 3568c2ecf20Sopenharmony_ci for (dac = 0; dac < ice->num_total_dacs; dac += 2) 3578c2ecf20Sopenharmony_ci wm_set_vol(ice, WM_DAC_ATTEN + dac + ch, 3588c2ecf20Sopenharmony_ci spec->vol[dac + ch], 3598c2ecf20Sopenharmony_ci spec->master[ch]); 3608c2ecf20Sopenharmony_ci change = 1; 3618c2ecf20Sopenharmony_ci } 3628c2ecf20Sopenharmony_ci } 3638c2ecf20Sopenharmony_ci snd_ice1712_restore_gpio_status(ice); 3648c2ecf20Sopenharmony_ci return change; 3658c2ecf20Sopenharmony_ci} 3668c2ecf20Sopenharmony_ci 3678c2ecf20Sopenharmony_cistatic int phase28_init(struct snd_ice1712 *ice) 3688c2ecf20Sopenharmony_ci{ 3698c2ecf20Sopenharmony_ci static const unsigned short wm_inits_phase28[] = { 3708c2ecf20Sopenharmony_ci /* These come first to reduce init pop noise */ 3718c2ecf20Sopenharmony_ci 0x1b, 0x044, /* ADC Mux (AC'97 source) */ 3728c2ecf20Sopenharmony_ci 0x1c, 0x00B, /* Out Mux1 (VOUT1 = DAC+AUX, VOUT2 = DAC) */ 3738c2ecf20Sopenharmony_ci 0x1d, 0x009, /* Out Mux2 (VOUT2 = DAC, VOUT3 = DAC) */ 3748c2ecf20Sopenharmony_ci 3758c2ecf20Sopenharmony_ci 0x18, 0x000, /* All power-up */ 3768c2ecf20Sopenharmony_ci 3778c2ecf20Sopenharmony_ci 0x16, 0x122, /* I2S, normal polarity, 24bit */ 3788c2ecf20Sopenharmony_ci 0x17, 0x022, /* 256fs, slave mode */ 3798c2ecf20Sopenharmony_ci 0x00, 0, /* DAC1 analog mute */ 3808c2ecf20Sopenharmony_ci 0x01, 0, /* DAC2 analog mute */ 3818c2ecf20Sopenharmony_ci 0x02, 0, /* DAC3 analog mute */ 3828c2ecf20Sopenharmony_ci 0x03, 0, /* DAC4 analog mute */ 3838c2ecf20Sopenharmony_ci 0x04, 0, /* DAC5 analog mute */ 3848c2ecf20Sopenharmony_ci 0x05, 0, /* DAC6 analog mute */ 3858c2ecf20Sopenharmony_ci 0x06, 0, /* DAC7 analog mute */ 3868c2ecf20Sopenharmony_ci 0x07, 0, /* DAC8 analog mute */ 3878c2ecf20Sopenharmony_ci 0x08, 0x100, /* master analog mute */ 3888c2ecf20Sopenharmony_ci 0x09, 0xff, /* DAC1 digital full */ 3898c2ecf20Sopenharmony_ci 0x0a, 0xff, /* DAC2 digital full */ 3908c2ecf20Sopenharmony_ci 0x0b, 0xff, /* DAC3 digital full */ 3918c2ecf20Sopenharmony_ci 0x0c, 0xff, /* DAC4 digital full */ 3928c2ecf20Sopenharmony_ci 0x0d, 0xff, /* DAC5 digital full */ 3938c2ecf20Sopenharmony_ci 0x0e, 0xff, /* DAC6 digital full */ 3948c2ecf20Sopenharmony_ci 0x0f, 0xff, /* DAC7 digital full */ 3958c2ecf20Sopenharmony_ci 0x10, 0xff, /* DAC8 digital full */ 3968c2ecf20Sopenharmony_ci 0x11, 0x1ff, /* master digital full */ 3978c2ecf20Sopenharmony_ci 0x12, 0x000, /* phase normal */ 3988c2ecf20Sopenharmony_ci 0x13, 0x090, /* unmute DAC L/R */ 3998c2ecf20Sopenharmony_ci 0x14, 0x000, /* all unmute */ 4008c2ecf20Sopenharmony_ci 0x15, 0x000, /* no deemphasis, no ZFLG */ 4018c2ecf20Sopenharmony_ci 0x19, 0x000, /* -12dB ADC/L */ 4028c2ecf20Sopenharmony_ci 0x1a, 0x000, /* -12dB ADC/R */ 4038c2ecf20Sopenharmony_ci (unsigned short)-1 4048c2ecf20Sopenharmony_ci }; 4058c2ecf20Sopenharmony_ci 4068c2ecf20Sopenharmony_ci unsigned int tmp; 4078c2ecf20Sopenharmony_ci struct snd_akm4xxx *ak; 4088c2ecf20Sopenharmony_ci struct phase28_spec *spec; 4098c2ecf20Sopenharmony_ci const unsigned short *p; 4108c2ecf20Sopenharmony_ci int i; 4118c2ecf20Sopenharmony_ci 4128c2ecf20Sopenharmony_ci ice->num_total_dacs = 8; 4138c2ecf20Sopenharmony_ci ice->num_total_adcs = 2; 4148c2ecf20Sopenharmony_ci 4158c2ecf20Sopenharmony_ci spec = kzalloc(sizeof(*spec), GFP_KERNEL); 4168c2ecf20Sopenharmony_ci if (!spec) 4178c2ecf20Sopenharmony_ci return -ENOMEM; 4188c2ecf20Sopenharmony_ci ice->spec = spec; 4198c2ecf20Sopenharmony_ci 4208c2ecf20Sopenharmony_ci /* Initialize analog chips */ 4218c2ecf20Sopenharmony_ci ice->akm = kzalloc(sizeof(struct snd_akm4xxx), GFP_KERNEL); 4228c2ecf20Sopenharmony_ci ak = ice->akm; 4238c2ecf20Sopenharmony_ci if (!ak) 4248c2ecf20Sopenharmony_ci return -ENOMEM; 4258c2ecf20Sopenharmony_ci ice->akm_codecs = 1; 4268c2ecf20Sopenharmony_ci 4278c2ecf20Sopenharmony_ci snd_ice1712_gpio_set_dir(ice, 0x5fffff); /* fix this for time being */ 4288c2ecf20Sopenharmony_ci 4298c2ecf20Sopenharmony_ci /* reset the wm codec as the SPI mode */ 4308c2ecf20Sopenharmony_ci snd_ice1712_save_gpio_status(ice); 4318c2ecf20Sopenharmony_ci snd_ice1712_gpio_set_mask(ice, ~(PHASE28_WM_RESET|PHASE28_WM_CS| 4328c2ecf20Sopenharmony_ci PHASE28_HP_SEL)); 4338c2ecf20Sopenharmony_ci 4348c2ecf20Sopenharmony_ci tmp = snd_ice1712_gpio_read(ice); 4358c2ecf20Sopenharmony_ci tmp &= ~PHASE28_WM_RESET; 4368c2ecf20Sopenharmony_ci snd_ice1712_gpio_write(ice, tmp); 4378c2ecf20Sopenharmony_ci udelay(1); 4388c2ecf20Sopenharmony_ci tmp |= PHASE28_WM_CS; 4398c2ecf20Sopenharmony_ci snd_ice1712_gpio_write(ice, tmp); 4408c2ecf20Sopenharmony_ci udelay(1); 4418c2ecf20Sopenharmony_ci tmp |= PHASE28_WM_RESET; 4428c2ecf20Sopenharmony_ci snd_ice1712_gpio_write(ice, tmp); 4438c2ecf20Sopenharmony_ci udelay(1); 4448c2ecf20Sopenharmony_ci 4458c2ecf20Sopenharmony_ci p = wm_inits_phase28; 4468c2ecf20Sopenharmony_ci for (; *p != (unsigned short)-1; p += 2) 4478c2ecf20Sopenharmony_ci wm_put(ice, p[0], p[1]); 4488c2ecf20Sopenharmony_ci 4498c2ecf20Sopenharmony_ci snd_ice1712_restore_gpio_status(ice); 4508c2ecf20Sopenharmony_ci 4518c2ecf20Sopenharmony_ci spec->master[0] = WM_VOL_MUTE; 4528c2ecf20Sopenharmony_ci spec->master[1] = WM_VOL_MUTE; 4538c2ecf20Sopenharmony_ci for (i = 0; i < ice->num_total_dacs; i++) { 4548c2ecf20Sopenharmony_ci spec->vol[i] = WM_VOL_MUTE; 4558c2ecf20Sopenharmony_ci wm_set_vol(ice, i, spec->vol[i], spec->master[i % 2]); 4568c2ecf20Sopenharmony_ci } 4578c2ecf20Sopenharmony_ci 4588c2ecf20Sopenharmony_ci return 0; 4598c2ecf20Sopenharmony_ci} 4608c2ecf20Sopenharmony_ci 4618c2ecf20Sopenharmony_ci/* 4628c2ecf20Sopenharmony_ci * DAC volume attenuation mixer control 4638c2ecf20Sopenharmony_ci */ 4648c2ecf20Sopenharmony_cistatic int wm_vol_info(struct snd_kcontrol *kcontrol, 4658c2ecf20Sopenharmony_ci struct snd_ctl_elem_info *uinfo) 4668c2ecf20Sopenharmony_ci{ 4678c2ecf20Sopenharmony_ci int voices = kcontrol->private_value >> 8; 4688c2ecf20Sopenharmony_ci uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 4698c2ecf20Sopenharmony_ci uinfo->count = voices; 4708c2ecf20Sopenharmony_ci uinfo->value.integer.min = 0; /* mute (-101dB) */ 4718c2ecf20Sopenharmony_ci uinfo->value.integer.max = 0x7F; /* 0dB */ 4728c2ecf20Sopenharmony_ci return 0; 4738c2ecf20Sopenharmony_ci} 4748c2ecf20Sopenharmony_ci 4758c2ecf20Sopenharmony_cistatic int wm_vol_get(struct snd_kcontrol *kcontrol, 4768c2ecf20Sopenharmony_ci struct snd_ctl_elem_value *ucontrol) 4778c2ecf20Sopenharmony_ci{ 4788c2ecf20Sopenharmony_ci struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 4798c2ecf20Sopenharmony_ci struct phase28_spec *spec = ice->spec; 4808c2ecf20Sopenharmony_ci int i, ofs, voices; 4818c2ecf20Sopenharmony_ci 4828c2ecf20Sopenharmony_ci voices = kcontrol->private_value >> 8; 4838c2ecf20Sopenharmony_ci ofs = kcontrol->private_value & 0xff; 4848c2ecf20Sopenharmony_ci for (i = 0; i < voices; i++) 4858c2ecf20Sopenharmony_ci ucontrol->value.integer.value[i] = 4868c2ecf20Sopenharmony_ci spec->vol[ofs+i] & ~WM_VOL_MUTE; 4878c2ecf20Sopenharmony_ci return 0; 4888c2ecf20Sopenharmony_ci} 4898c2ecf20Sopenharmony_ci 4908c2ecf20Sopenharmony_cistatic int wm_vol_put(struct snd_kcontrol *kcontrol, 4918c2ecf20Sopenharmony_ci struct snd_ctl_elem_value *ucontrol) 4928c2ecf20Sopenharmony_ci{ 4938c2ecf20Sopenharmony_ci struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 4948c2ecf20Sopenharmony_ci struct phase28_spec *spec = ice->spec; 4958c2ecf20Sopenharmony_ci int i, idx, ofs, voices; 4968c2ecf20Sopenharmony_ci int change = 0; 4978c2ecf20Sopenharmony_ci 4988c2ecf20Sopenharmony_ci voices = kcontrol->private_value >> 8; 4998c2ecf20Sopenharmony_ci ofs = kcontrol->private_value & 0xff; 5008c2ecf20Sopenharmony_ci snd_ice1712_save_gpio_status(ice); 5018c2ecf20Sopenharmony_ci for (i = 0; i < voices; i++) { 5028c2ecf20Sopenharmony_ci unsigned int vol; 5038c2ecf20Sopenharmony_ci vol = ucontrol->value.integer.value[i]; 5048c2ecf20Sopenharmony_ci if (vol > 0x7f) 5058c2ecf20Sopenharmony_ci continue; 5068c2ecf20Sopenharmony_ci vol |= spec->vol[ofs+i] & WM_VOL_MUTE; 5078c2ecf20Sopenharmony_ci if (vol != spec->vol[ofs+i]) { 5088c2ecf20Sopenharmony_ci spec->vol[ofs+i] = vol; 5098c2ecf20Sopenharmony_ci idx = WM_DAC_ATTEN + ofs + i; 5108c2ecf20Sopenharmony_ci wm_set_vol(ice, idx, spec->vol[ofs+i], 5118c2ecf20Sopenharmony_ci spec->master[i]); 5128c2ecf20Sopenharmony_ci change = 1; 5138c2ecf20Sopenharmony_ci } 5148c2ecf20Sopenharmony_ci } 5158c2ecf20Sopenharmony_ci snd_ice1712_restore_gpio_status(ice); 5168c2ecf20Sopenharmony_ci return change; 5178c2ecf20Sopenharmony_ci} 5188c2ecf20Sopenharmony_ci 5198c2ecf20Sopenharmony_ci/* 5208c2ecf20Sopenharmony_ci * WM8770 mute control 5218c2ecf20Sopenharmony_ci */ 5228c2ecf20Sopenharmony_cistatic int wm_mute_info(struct snd_kcontrol *kcontrol, 5238c2ecf20Sopenharmony_ci struct snd_ctl_elem_info *uinfo) { 5248c2ecf20Sopenharmony_ci uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; 5258c2ecf20Sopenharmony_ci uinfo->count = kcontrol->private_value >> 8; 5268c2ecf20Sopenharmony_ci uinfo->value.integer.min = 0; 5278c2ecf20Sopenharmony_ci uinfo->value.integer.max = 1; 5288c2ecf20Sopenharmony_ci return 0; 5298c2ecf20Sopenharmony_ci} 5308c2ecf20Sopenharmony_ci 5318c2ecf20Sopenharmony_cistatic int wm_mute_get(struct snd_kcontrol *kcontrol, 5328c2ecf20Sopenharmony_ci struct snd_ctl_elem_value *ucontrol) 5338c2ecf20Sopenharmony_ci{ 5348c2ecf20Sopenharmony_ci struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 5358c2ecf20Sopenharmony_ci struct phase28_spec *spec = ice->spec; 5368c2ecf20Sopenharmony_ci int voices, ofs, i; 5378c2ecf20Sopenharmony_ci 5388c2ecf20Sopenharmony_ci voices = kcontrol->private_value >> 8; 5398c2ecf20Sopenharmony_ci ofs = kcontrol->private_value & 0xFF; 5408c2ecf20Sopenharmony_ci 5418c2ecf20Sopenharmony_ci for (i = 0; i < voices; i++) 5428c2ecf20Sopenharmony_ci ucontrol->value.integer.value[i] = 5438c2ecf20Sopenharmony_ci (spec->vol[ofs+i] & WM_VOL_MUTE) ? 0 : 1; 5448c2ecf20Sopenharmony_ci return 0; 5458c2ecf20Sopenharmony_ci} 5468c2ecf20Sopenharmony_ci 5478c2ecf20Sopenharmony_cistatic int wm_mute_put(struct snd_kcontrol *kcontrol, 5488c2ecf20Sopenharmony_ci struct snd_ctl_elem_value *ucontrol) 5498c2ecf20Sopenharmony_ci{ 5508c2ecf20Sopenharmony_ci struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 5518c2ecf20Sopenharmony_ci struct phase28_spec *spec = ice->spec; 5528c2ecf20Sopenharmony_ci int change = 0, voices, ofs, i; 5538c2ecf20Sopenharmony_ci 5548c2ecf20Sopenharmony_ci voices = kcontrol->private_value >> 8; 5558c2ecf20Sopenharmony_ci ofs = kcontrol->private_value & 0xFF; 5568c2ecf20Sopenharmony_ci 5578c2ecf20Sopenharmony_ci snd_ice1712_save_gpio_status(ice); 5588c2ecf20Sopenharmony_ci for (i = 0; i < voices; i++) { 5598c2ecf20Sopenharmony_ci int val = (spec->vol[ofs + i] & WM_VOL_MUTE) ? 0 : 1; 5608c2ecf20Sopenharmony_ci if (ucontrol->value.integer.value[i] != val) { 5618c2ecf20Sopenharmony_ci spec->vol[ofs + i] &= ~WM_VOL_MUTE; 5628c2ecf20Sopenharmony_ci spec->vol[ofs + i] |= 5638c2ecf20Sopenharmony_ci ucontrol->value.integer.value[i] ? 0 : 5648c2ecf20Sopenharmony_ci WM_VOL_MUTE; 5658c2ecf20Sopenharmony_ci wm_set_vol(ice, ofs + i, spec->vol[ofs + i], 5668c2ecf20Sopenharmony_ci spec->master[i]); 5678c2ecf20Sopenharmony_ci change = 1; 5688c2ecf20Sopenharmony_ci } 5698c2ecf20Sopenharmony_ci } 5708c2ecf20Sopenharmony_ci snd_ice1712_restore_gpio_status(ice); 5718c2ecf20Sopenharmony_ci 5728c2ecf20Sopenharmony_ci return change; 5738c2ecf20Sopenharmony_ci} 5748c2ecf20Sopenharmony_ci 5758c2ecf20Sopenharmony_ci/* 5768c2ecf20Sopenharmony_ci * WM8770 master mute control 5778c2ecf20Sopenharmony_ci */ 5788c2ecf20Sopenharmony_ci#define wm_master_mute_info snd_ctl_boolean_stereo_info 5798c2ecf20Sopenharmony_ci 5808c2ecf20Sopenharmony_cistatic int wm_master_mute_get(struct snd_kcontrol *kcontrol, 5818c2ecf20Sopenharmony_ci struct snd_ctl_elem_value *ucontrol) 5828c2ecf20Sopenharmony_ci{ 5838c2ecf20Sopenharmony_ci struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 5848c2ecf20Sopenharmony_ci struct phase28_spec *spec = ice->spec; 5858c2ecf20Sopenharmony_ci 5868c2ecf20Sopenharmony_ci ucontrol->value.integer.value[0] = 5878c2ecf20Sopenharmony_ci (spec->master[0] & WM_VOL_MUTE) ? 0 : 1; 5888c2ecf20Sopenharmony_ci ucontrol->value.integer.value[1] = 5898c2ecf20Sopenharmony_ci (spec->master[1] & WM_VOL_MUTE) ? 0 : 1; 5908c2ecf20Sopenharmony_ci return 0; 5918c2ecf20Sopenharmony_ci} 5928c2ecf20Sopenharmony_ci 5938c2ecf20Sopenharmony_cistatic int wm_master_mute_put(struct snd_kcontrol *kcontrol, 5948c2ecf20Sopenharmony_ci struct snd_ctl_elem_value *ucontrol) 5958c2ecf20Sopenharmony_ci{ 5968c2ecf20Sopenharmony_ci struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 5978c2ecf20Sopenharmony_ci struct phase28_spec *spec = ice->spec; 5988c2ecf20Sopenharmony_ci int change = 0, i; 5998c2ecf20Sopenharmony_ci 6008c2ecf20Sopenharmony_ci snd_ice1712_save_gpio_status(ice); 6018c2ecf20Sopenharmony_ci for (i = 0; i < 2; i++) { 6028c2ecf20Sopenharmony_ci int val = (spec->master[i] & WM_VOL_MUTE) ? 0 : 1; 6038c2ecf20Sopenharmony_ci if (ucontrol->value.integer.value[i] != val) { 6048c2ecf20Sopenharmony_ci int dac; 6058c2ecf20Sopenharmony_ci spec->master[i] &= ~WM_VOL_MUTE; 6068c2ecf20Sopenharmony_ci spec->master[i] |= 6078c2ecf20Sopenharmony_ci ucontrol->value.integer.value[i] ? 0 : 6088c2ecf20Sopenharmony_ci WM_VOL_MUTE; 6098c2ecf20Sopenharmony_ci for (dac = 0; dac < ice->num_total_dacs; dac += 2) 6108c2ecf20Sopenharmony_ci wm_set_vol(ice, WM_DAC_ATTEN + dac + i, 6118c2ecf20Sopenharmony_ci spec->vol[dac + i], 6128c2ecf20Sopenharmony_ci spec->master[i]); 6138c2ecf20Sopenharmony_ci change = 1; 6148c2ecf20Sopenharmony_ci } 6158c2ecf20Sopenharmony_ci } 6168c2ecf20Sopenharmony_ci snd_ice1712_restore_gpio_status(ice); 6178c2ecf20Sopenharmony_ci 6188c2ecf20Sopenharmony_ci return change; 6198c2ecf20Sopenharmony_ci} 6208c2ecf20Sopenharmony_ci 6218c2ecf20Sopenharmony_ci/* digital master volume */ 6228c2ecf20Sopenharmony_ci#define PCM_0dB 0xff 6238c2ecf20Sopenharmony_ci#define PCM_RES 128 /* -64dB */ 6248c2ecf20Sopenharmony_ci#define PCM_MIN (PCM_0dB - PCM_RES) 6258c2ecf20Sopenharmony_cistatic int wm_pcm_vol_info(struct snd_kcontrol *kcontrol, 6268c2ecf20Sopenharmony_ci struct snd_ctl_elem_info *uinfo) 6278c2ecf20Sopenharmony_ci{ 6288c2ecf20Sopenharmony_ci uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 6298c2ecf20Sopenharmony_ci uinfo->count = 1; 6308c2ecf20Sopenharmony_ci uinfo->value.integer.min = 0; /* mute (-64dB) */ 6318c2ecf20Sopenharmony_ci uinfo->value.integer.max = PCM_RES; /* 0dB */ 6328c2ecf20Sopenharmony_ci return 0; 6338c2ecf20Sopenharmony_ci} 6348c2ecf20Sopenharmony_ci 6358c2ecf20Sopenharmony_cistatic int wm_pcm_vol_get(struct snd_kcontrol *kcontrol, 6368c2ecf20Sopenharmony_ci struct snd_ctl_elem_value *ucontrol) 6378c2ecf20Sopenharmony_ci{ 6388c2ecf20Sopenharmony_ci struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 6398c2ecf20Sopenharmony_ci unsigned short val; 6408c2ecf20Sopenharmony_ci 6418c2ecf20Sopenharmony_ci mutex_lock(&ice->gpio_mutex); 6428c2ecf20Sopenharmony_ci val = wm_get(ice, WM_DAC_DIG_MASTER_ATTEN) & 0xff; 6438c2ecf20Sopenharmony_ci val = val > PCM_MIN ? (val - PCM_MIN) : 0; 6448c2ecf20Sopenharmony_ci ucontrol->value.integer.value[0] = val; 6458c2ecf20Sopenharmony_ci mutex_unlock(&ice->gpio_mutex); 6468c2ecf20Sopenharmony_ci return 0; 6478c2ecf20Sopenharmony_ci} 6488c2ecf20Sopenharmony_ci 6498c2ecf20Sopenharmony_cistatic int wm_pcm_vol_put(struct snd_kcontrol *kcontrol, 6508c2ecf20Sopenharmony_ci struct snd_ctl_elem_value *ucontrol) 6518c2ecf20Sopenharmony_ci{ 6528c2ecf20Sopenharmony_ci struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 6538c2ecf20Sopenharmony_ci unsigned short ovol, nvol; 6548c2ecf20Sopenharmony_ci int change = 0; 6558c2ecf20Sopenharmony_ci 6568c2ecf20Sopenharmony_ci nvol = ucontrol->value.integer.value[0]; 6578c2ecf20Sopenharmony_ci if (nvol > PCM_RES) 6588c2ecf20Sopenharmony_ci return -EINVAL; 6598c2ecf20Sopenharmony_ci snd_ice1712_save_gpio_status(ice); 6608c2ecf20Sopenharmony_ci nvol = (nvol ? (nvol + PCM_MIN) : 0) & 0xff; 6618c2ecf20Sopenharmony_ci ovol = wm_get(ice, WM_DAC_DIG_MASTER_ATTEN) & 0xff; 6628c2ecf20Sopenharmony_ci if (ovol != nvol) { 6638c2ecf20Sopenharmony_ci wm_put(ice, WM_DAC_DIG_MASTER_ATTEN, nvol); /* prelatch */ 6648c2ecf20Sopenharmony_ci /* update */ 6658c2ecf20Sopenharmony_ci wm_put_nocache(ice, WM_DAC_DIG_MASTER_ATTEN, nvol | 0x100); 6668c2ecf20Sopenharmony_ci change = 1; 6678c2ecf20Sopenharmony_ci } 6688c2ecf20Sopenharmony_ci snd_ice1712_restore_gpio_status(ice); 6698c2ecf20Sopenharmony_ci return change; 6708c2ecf20Sopenharmony_ci} 6718c2ecf20Sopenharmony_ci 6728c2ecf20Sopenharmony_ci/* 6738c2ecf20Sopenharmony_ci * Deemphasis 6748c2ecf20Sopenharmony_ci */ 6758c2ecf20Sopenharmony_ci#define phase28_deemp_info snd_ctl_boolean_mono_info 6768c2ecf20Sopenharmony_ci 6778c2ecf20Sopenharmony_cistatic int phase28_deemp_get(struct snd_kcontrol *kcontrol, 6788c2ecf20Sopenharmony_ci struct snd_ctl_elem_value *ucontrol) 6798c2ecf20Sopenharmony_ci{ 6808c2ecf20Sopenharmony_ci struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 6818c2ecf20Sopenharmony_ci ucontrol->value.integer.value[0] = (wm_get(ice, WM_DAC_CTRL2) & 0xf) == 6828c2ecf20Sopenharmony_ci 0xf; 6838c2ecf20Sopenharmony_ci return 0; 6848c2ecf20Sopenharmony_ci} 6858c2ecf20Sopenharmony_ci 6868c2ecf20Sopenharmony_cistatic int phase28_deemp_put(struct snd_kcontrol *kcontrol, 6878c2ecf20Sopenharmony_ci struct snd_ctl_elem_value *ucontrol) 6888c2ecf20Sopenharmony_ci{ 6898c2ecf20Sopenharmony_ci struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 6908c2ecf20Sopenharmony_ci int temp, temp2; 6918c2ecf20Sopenharmony_ci temp = wm_get(ice, WM_DAC_CTRL2); 6928c2ecf20Sopenharmony_ci temp2 = temp; 6938c2ecf20Sopenharmony_ci if (ucontrol->value.integer.value[0]) 6948c2ecf20Sopenharmony_ci temp |= 0xf; 6958c2ecf20Sopenharmony_ci else 6968c2ecf20Sopenharmony_ci temp &= ~0xf; 6978c2ecf20Sopenharmony_ci if (temp != temp2) { 6988c2ecf20Sopenharmony_ci wm_put(ice, WM_DAC_CTRL2, temp); 6998c2ecf20Sopenharmony_ci return 1; 7008c2ecf20Sopenharmony_ci } 7018c2ecf20Sopenharmony_ci return 0; 7028c2ecf20Sopenharmony_ci} 7038c2ecf20Sopenharmony_ci 7048c2ecf20Sopenharmony_ci/* 7058c2ecf20Sopenharmony_ci * ADC Oversampling 7068c2ecf20Sopenharmony_ci */ 7078c2ecf20Sopenharmony_cistatic int phase28_oversampling_info(struct snd_kcontrol *k, 7088c2ecf20Sopenharmony_ci struct snd_ctl_elem_info *uinfo) 7098c2ecf20Sopenharmony_ci{ 7108c2ecf20Sopenharmony_ci static const char * const texts[2] = { "128x", "64x" }; 7118c2ecf20Sopenharmony_ci 7128c2ecf20Sopenharmony_ci return snd_ctl_enum_info(uinfo, 1, 2, texts); 7138c2ecf20Sopenharmony_ci} 7148c2ecf20Sopenharmony_ci 7158c2ecf20Sopenharmony_cistatic int phase28_oversampling_get(struct snd_kcontrol *kcontrol, 7168c2ecf20Sopenharmony_ci struct snd_ctl_elem_value *ucontrol) 7178c2ecf20Sopenharmony_ci{ 7188c2ecf20Sopenharmony_ci struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 7198c2ecf20Sopenharmony_ci ucontrol->value.enumerated.item[0] = (wm_get(ice, WM_MASTER) & 0x8) == 7208c2ecf20Sopenharmony_ci 0x8; 7218c2ecf20Sopenharmony_ci return 0; 7228c2ecf20Sopenharmony_ci} 7238c2ecf20Sopenharmony_ci 7248c2ecf20Sopenharmony_cistatic int phase28_oversampling_put(struct snd_kcontrol *kcontrol, 7258c2ecf20Sopenharmony_ci struct snd_ctl_elem_value *ucontrol) 7268c2ecf20Sopenharmony_ci{ 7278c2ecf20Sopenharmony_ci int temp, temp2; 7288c2ecf20Sopenharmony_ci struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); 7298c2ecf20Sopenharmony_ci 7308c2ecf20Sopenharmony_ci temp = wm_get(ice, WM_MASTER); 7318c2ecf20Sopenharmony_ci temp2 = temp; 7328c2ecf20Sopenharmony_ci 7338c2ecf20Sopenharmony_ci if (ucontrol->value.enumerated.item[0]) 7348c2ecf20Sopenharmony_ci temp |= 0x8; 7358c2ecf20Sopenharmony_ci else 7368c2ecf20Sopenharmony_ci temp &= ~0x8; 7378c2ecf20Sopenharmony_ci 7388c2ecf20Sopenharmony_ci if (temp != temp2) { 7398c2ecf20Sopenharmony_ci wm_put(ice, WM_MASTER, temp); 7408c2ecf20Sopenharmony_ci return 1; 7418c2ecf20Sopenharmony_ci } 7428c2ecf20Sopenharmony_ci return 0; 7438c2ecf20Sopenharmony_ci} 7448c2ecf20Sopenharmony_ci 7458c2ecf20Sopenharmony_cistatic const DECLARE_TLV_DB_SCALE(db_scale_wm_dac, -12700, 100, 1); 7468c2ecf20Sopenharmony_cistatic const DECLARE_TLV_DB_SCALE(db_scale_wm_pcm, -6400, 50, 1); 7478c2ecf20Sopenharmony_ci 7488c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new phase28_dac_controls[] = { 7498c2ecf20Sopenharmony_ci { 7508c2ecf20Sopenharmony_ci .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 7518c2ecf20Sopenharmony_ci .name = "Master Playback Switch", 7528c2ecf20Sopenharmony_ci .info = wm_master_mute_info, 7538c2ecf20Sopenharmony_ci .get = wm_master_mute_get, 7548c2ecf20Sopenharmony_ci .put = wm_master_mute_put 7558c2ecf20Sopenharmony_ci }, 7568c2ecf20Sopenharmony_ci { 7578c2ecf20Sopenharmony_ci .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 7588c2ecf20Sopenharmony_ci .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | 7598c2ecf20Sopenharmony_ci SNDRV_CTL_ELEM_ACCESS_TLV_READ), 7608c2ecf20Sopenharmony_ci .name = "Master Playback Volume", 7618c2ecf20Sopenharmony_ci .info = wm_master_vol_info, 7628c2ecf20Sopenharmony_ci .get = wm_master_vol_get, 7638c2ecf20Sopenharmony_ci .put = wm_master_vol_put, 7648c2ecf20Sopenharmony_ci .tlv = { .p = db_scale_wm_dac } 7658c2ecf20Sopenharmony_ci }, 7668c2ecf20Sopenharmony_ci { 7678c2ecf20Sopenharmony_ci .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 7688c2ecf20Sopenharmony_ci .name = "Front Playback Switch", 7698c2ecf20Sopenharmony_ci .info = wm_mute_info, 7708c2ecf20Sopenharmony_ci .get = wm_mute_get, 7718c2ecf20Sopenharmony_ci .put = wm_mute_put, 7728c2ecf20Sopenharmony_ci .private_value = (2 << 8) | 0 7738c2ecf20Sopenharmony_ci }, 7748c2ecf20Sopenharmony_ci { 7758c2ecf20Sopenharmony_ci .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 7768c2ecf20Sopenharmony_ci .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | 7778c2ecf20Sopenharmony_ci SNDRV_CTL_ELEM_ACCESS_TLV_READ), 7788c2ecf20Sopenharmony_ci .name = "Front Playback Volume", 7798c2ecf20Sopenharmony_ci .info = wm_vol_info, 7808c2ecf20Sopenharmony_ci .get = wm_vol_get, 7818c2ecf20Sopenharmony_ci .put = wm_vol_put, 7828c2ecf20Sopenharmony_ci .private_value = (2 << 8) | 0, 7838c2ecf20Sopenharmony_ci .tlv = { .p = db_scale_wm_dac } 7848c2ecf20Sopenharmony_ci }, 7858c2ecf20Sopenharmony_ci { 7868c2ecf20Sopenharmony_ci .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 7878c2ecf20Sopenharmony_ci .name = "Rear Playback Switch", 7888c2ecf20Sopenharmony_ci .info = wm_mute_info, 7898c2ecf20Sopenharmony_ci .get = wm_mute_get, 7908c2ecf20Sopenharmony_ci .put = wm_mute_put, 7918c2ecf20Sopenharmony_ci .private_value = (2 << 8) | 2 7928c2ecf20Sopenharmony_ci }, 7938c2ecf20Sopenharmony_ci { 7948c2ecf20Sopenharmony_ci .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 7958c2ecf20Sopenharmony_ci .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | 7968c2ecf20Sopenharmony_ci SNDRV_CTL_ELEM_ACCESS_TLV_READ), 7978c2ecf20Sopenharmony_ci .name = "Rear Playback Volume", 7988c2ecf20Sopenharmony_ci .info = wm_vol_info, 7998c2ecf20Sopenharmony_ci .get = wm_vol_get, 8008c2ecf20Sopenharmony_ci .put = wm_vol_put, 8018c2ecf20Sopenharmony_ci .private_value = (2 << 8) | 2, 8028c2ecf20Sopenharmony_ci .tlv = { .p = db_scale_wm_dac } 8038c2ecf20Sopenharmony_ci }, 8048c2ecf20Sopenharmony_ci { 8058c2ecf20Sopenharmony_ci .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 8068c2ecf20Sopenharmony_ci .name = "Center Playback Switch", 8078c2ecf20Sopenharmony_ci .info = wm_mute_info, 8088c2ecf20Sopenharmony_ci .get = wm_mute_get, 8098c2ecf20Sopenharmony_ci .put = wm_mute_put, 8108c2ecf20Sopenharmony_ci .private_value = (1 << 8) | 4 8118c2ecf20Sopenharmony_ci }, 8128c2ecf20Sopenharmony_ci { 8138c2ecf20Sopenharmony_ci .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 8148c2ecf20Sopenharmony_ci .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | 8158c2ecf20Sopenharmony_ci SNDRV_CTL_ELEM_ACCESS_TLV_READ), 8168c2ecf20Sopenharmony_ci .name = "Center Playback Volume", 8178c2ecf20Sopenharmony_ci .info = wm_vol_info, 8188c2ecf20Sopenharmony_ci .get = wm_vol_get, 8198c2ecf20Sopenharmony_ci .put = wm_vol_put, 8208c2ecf20Sopenharmony_ci .private_value = (1 << 8) | 4, 8218c2ecf20Sopenharmony_ci .tlv = { .p = db_scale_wm_dac } 8228c2ecf20Sopenharmony_ci }, 8238c2ecf20Sopenharmony_ci { 8248c2ecf20Sopenharmony_ci .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 8258c2ecf20Sopenharmony_ci .name = "LFE Playback Switch", 8268c2ecf20Sopenharmony_ci .info = wm_mute_info, 8278c2ecf20Sopenharmony_ci .get = wm_mute_get, 8288c2ecf20Sopenharmony_ci .put = wm_mute_put, 8298c2ecf20Sopenharmony_ci .private_value = (1 << 8) | 5 8308c2ecf20Sopenharmony_ci }, 8318c2ecf20Sopenharmony_ci { 8328c2ecf20Sopenharmony_ci .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 8338c2ecf20Sopenharmony_ci .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | 8348c2ecf20Sopenharmony_ci SNDRV_CTL_ELEM_ACCESS_TLV_READ), 8358c2ecf20Sopenharmony_ci .name = "LFE Playback Volume", 8368c2ecf20Sopenharmony_ci .info = wm_vol_info, 8378c2ecf20Sopenharmony_ci .get = wm_vol_get, 8388c2ecf20Sopenharmony_ci .put = wm_vol_put, 8398c2ecf20Sopenharmony_ci .private_value = (1 << 8) | 5, 8408c2ecf20Sopenharmony_ci .tlv = { .p = db_scale_wm_dac } 8418c2ecf20Sopenharmony_ci }, 8428c2ecf20Sopenharmony_ci { 8438c2ecf20Sopenharmony_ci .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 8448c2ecf20Sopenharmony_ci .name = "Side Playback Switch", 8458c2ecf20Sopenharmony_ci .info = wm_mute_info, 8468c2ecf20Sopenharmony_ci .get = wm_mute_get, 8478c2ecf20Sopenharmony_ci .put = wm_mute_put, 8488c2ecf20Sopenharmony_ci .private_value = (2 << 8) | 6 8498c2ecf20Sopenharmony_ci }, 8508c2ecf20Sopenharmony_ci { 8518c2ecf20Sopenharmony_ci .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 8528c2ecf20Sopenharmony_ci .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | 8538c2ecf20Sopenharmony_ci SNDRV_CTL_ELEM_ACCESS_TLV_READ), 8548c2ecf20Sopenharmony_ci .name = "Side Playback Volume", 8558c2ecf20Sopenharmony_ci .info = wm_vol_info, 8568c2ecf20Sopenharmony_ci .get = wm_vol_get, 8578c2ecf20Sopenharmony_ci .put = wm_vol_put, 8588c2ecf20Sopenharmony_ci .private_value = (2 << 8) | 6, 8598c2ecf20Sopenharmony_ci .tlv = { .p = db_scale_wm_dac } 8608c2ecf20Sopenharmony_ci } 8618c2ecf20Sopenharmony_ci}; 8628c2ecf20Sopenharmony_ci 8638c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new wm_controls[] = { 8648c2ecf20Sopenharmony_ci { 8658c2ecf20Sopenharmony_ci .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 8668c2ecf20Sopenharmony_ci .name = "PCM Playback Switch", 8678c2ecf20Sopenharmony_ci .info = wm_pcm_mute_info, 8688c2ecf20Sopenharmony_ci .get = wm_pcm_mute_get, 8698c2ecf20Sopenharmony_ci .put = wm_pcm_mute_put 8708c2ecf20Sopenharmony_ci }, 8718c2ecf20Sopenharmony_ci { 8728c2ecf20Sopenharmony_ci .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 8738c2ecf20Sopenharmony_ci .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | 8748c2ecf20Sopenharmony_ci SNDRV_CTL_ELEM_ACCESS_TLV_READ), 8758c2ecf20Sopenharmony_ci .name = "PCM Playback Volume", 8768c2ecf20Sopenharmony_ci .info = wm_pcm_vol_info, 8778c2ecf20Sopenharmony_ci .get = wm_pcm_vol_get, 8788c2ecf20Sopenharmony_ci .put = wm_pcm_vol_put, 8798c2ecf20Sopenharmony_ci .tlv = { .p = db_scale_wm_pcm } 8808c2ecf20Sopenharmony_ci }, 8818c2ecf20Sopenharmony_ci { 8828c2ecf20Sopenharmony_ci .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 8838c2ecf20Sopenharmony_ci .name = "DAC Deemphasis Switch", 8848c2ecf20Sopenharmony_ci .info = phase28_deemp_info, 8858c2ecf20Sopenharmony_ci .get = phase28_deemp_get, 8868c2ecf20Sopenharmony_ci .put = phase28_deemp_put 8878c2ecf20Sopenharmony_ci }, 8888c2ecf20Sopenharmony_ci { 8898c2ecf20Sopenharmony_ci .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 8908c2ecf20Sopenharmony_ci .name = "ADC Oversampling", 8918c2ecf20Sopenharmony_ci .info = phase28_oversampling_info, 8928c2ecf20Sopenharmony_ci .get = phase28_oversampling_get, 8938c2ecf20Sopenharmony_ci .put = phase28_oversampling_put 8948c2ecf20Sopenharmony_ci } 8958c2ecf20Sopenharmony_ci}; 8968c2ecf20Sopenharmony_ci 8978c2ecf20Sopenharmony_cistatic int phase28_add_controls(struct snd_ice1712 *ice) 8988c2ecf20Sopenharmony_ci{ 8998c2ecf20Sopenharmony_ci unsigned int i, counts; 9008c2ecf20Sopenharmony_ci int err; 9018c2ecf20Sopenharmony_ci 9028c2ecf20Sopenharmony_ci counts = ARRAY_SIZE(phase28_dac_controls); 9038c2ecf20Sopenharmony_ci for (i = 0; i < counts; i++) { 9048c2ecf20Sopenharmony_ci err = snd_ctl_add(ice->card, 9058c2ecf20Sopenharmony_ci snd_ctl_new1(&phase28_dac_controls[i], 9068c2ecf20Sopenharmony_ci ice)); 9078c2ecf20Sopenharmony_ci if (err < 0) 9088c2ecf20Sopenharmony_ci return err; 9098c2ecf20Sopenharmony_ci } 9108c2ecf20Sopenharmony_ci 9118c2ecf20Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(wm_controls); i++) { 9128c2ecf20Sopenharmony_ci err = snd_ctl_add(ice->card, 9138c2ecf20Sopenharmony_ci snd_ctl_new1(&wm_controls[i], ice)); 9148c2ecf20Sopenharmony_ci if (err < 0) 9158c2ecf20Sopenharmony_ci return err; 9168c2ecf20Sopenharmony_ci } 9178c2ecf20Sopenharmony_ci 9188c2ecf20Sopenharmony_ci return 0; 9198c2ecf20Sopenharmony_ci} 9208c2ecf20Sopenharmony_ci 9218c2ecf20Sopenharmony_cistruct snd_ice1712_card_info snd_vt1724_phase_cards[] = { 9228c2ecf20Sopenharmony_ci { 9238c2ecf20Sopenharmony_ci .subvendor = VT1724_SUBDEVICE_PHASE22, 9248c2ecf20Sopenharmony_ci .name = "Terratec PHASE 22", 9258c2ecf20Sopenharmony_ci .model = "phase22", 9268c2ecf20Sopenharmony_ci .chip_init = phase22_init, 9278c2ecf20Sopenharmony_ci .build_controls = phase22_add_controls, 9288c2ecf20Sopenharmony_ci .eeprom_size = sizeof(phase22_eeprom), 9298c2ecf20Sopenharmony_ci .eeprom_data = phase22_eeprom, 9308c2ecf20Sopenharmony_ci }, 9318c2ecf20Sopenharmony_ci { 9328c2ecf20Sopenharmony_ci .subvendor = VT1724_SUBDEVICE_PHASE28, 9338c2ecf20Sopenharmony_ci .name = "Terratec PHASE 28", 9348c2ecf20Sopenharmony_ci .model = "phase28", 9358c2ecf20Sopenharmony_ci .chip_init = phase28_init, 9368c2ecf20Sopenharmony_ci .build_controls = phase28_add_controls, 9378c2ecf20Sopenharmony_ci .eeprom_size = sizeof(phase28_eeprom), 9388c2ecf20Sopenharmony_ci .eeprom_data = phase28_eeprom, 9398c2ecf20Sopenharmony_ci }, 9408c2ecf20Sopenharmony_ci { 9418c2ecf20Sopenharmony_ci .subvendor = VT1724_SUBDEVICE_TS22, 9428c2ecf20Sopenharmony_ci .name = "Terrasoniq TS22 PCI", 9438c2ecf20Sopenharmony_ci .model = "TS22", 9448c2ecf20Sopenharmony_ci .chip_init = phase22_init, 9458c2ecf20Sopenharmony_ci .build_controls = phase22_add_controls, 9468c2ecf20Sopenharmony_ci .eeprom_size = sizeof(phase22_eeprom), 9478c2ecf20Sopenharmony_ci .eeprom_data = phase22_eeprom, 9488c2ecf20Sopenharmony_ci }, 9498c2ecf20Sopenharmony_ci { } /* terminator */ 9508c2ecf20Sopenharmony_ci}; 951