18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * rt5670.c -- RT5670 ALSA SoC audio codec driver 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright 2014 Realtek Semiconductor Corp. 68c2ecf20Sopenharmony_ci * Author: Bard Liao <bardliao@realtek.com> 78c2ecf20Sopenharmony_ci */ 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#include <linux/module.h> 108c2ecf20Sopenharmony_ci#include <linux/moduleparam.h> 118c2ecf20Sopenharmony_ci#include <linux/init.h> 128c2ecf20Sopenharmony_ci#include <linux/delay.h> 138c2ecf20Sopenharmony_ci#include <linux/pm.h> 148c2ecf20Sopenharmony_ci#include <linux/pm_runtime.h> 158c2ecf20Sopenharmony_ci#include <linux/i2c.h> 168c2ecf20Sopenharmony_ci#include <linux/platform_device.h> 178c2ecf20Sopenharmony_ci#include <linux/acpi.h> 188c2ecf20Sopenharmony_ci#include <linux/spi/spi.h> 198c2ecf20Sopenharmony_ci#include <linux/dmi.h> 208c2ecf20Sopenharmony_ci#include <sound/core.h> 218c2ecf20Sopenharmony_ci#include <sound/pcm.h> 228c2ecf20Sopenharmony_ci#include <sound/pcm_params.h> 238c2ecf20Sopenharmony_ci#include <sound/jack.h> 248c2ecf20Sopenharmony_ci#include <sound/soc.h> 258c2ecf20Sopenharmony_ci#include <sound/soc-dapm.h> 268c2ecf20Sopenharmony_ci#include <sound/initval.h> 278c2ecf20Sopenharmony_ci#include <sound/tlv.h> 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci#include "rl6231.h" 308c2ecf20Sopenharmony_ci#include "rt5670.h" 318c2ecf20Sopenharmony_ci#include "rt5670-dsp.h" 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci#define RT5670_GPIO1_IS_IRQ BIT(0) 348c2ecf20Sopenharmony_ci#define RT5670_IN2_DIFF BIT(1) 358c2ecf20Sopenharmony_ci#define RT5670_DMIC_EN BIT(2) 368c2ecf20Sopenharmony_ci#define RT5670_DMIC1_IN2P BIT(3) 378c2ecf20Sopenharmony_ci#define RT5670_DMIC1_GPIO6 BIT(4) 388c2ecf20Sopenharmony_ci#define RT5670_DMIC1_GPIO7 BIT(5) 398c2ecf20Sopenharmony_ci#define RT5670_DMIC2_INR BIT(6) 408c2ecf20Sopenharmony_ci#define RT5670_DMIC2_GPIO8 BIT(7) 418c2ecf20Sopenharmony_ci#define RT5670_DMIC3_GPIO5 BIT(8) 428c2ecf20Sopenharmony_ci#define RT5670_JD_MODE1 BIT(9) 438c2ecf20Sopenharmony_ci#define RT5670_JD_MODE2 BIT(10) 448c2ecf20Sopenharmony_ci#define RT5670_JD_MODE3 BIT(11) 458c2ecf20Sopenharmony_ci#define RT5670_GPIO1_IS_EXT_SPK_EN BIT(12) 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_cistatic unsigned long rt5670_quirk; 488c2ecf20Sopenharmony_cistatic unsigned int quirk_override; 498c2ecf20Sopenharmony_cimodule_param_named(quirk, quirk_override, uint, 0444); 508c2ecf20Sopenharmony_ciMODULE_PARM_DESC(quirk, "Board-specific quirk override"); 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci#define RT5670_DEVICE_ID 0x6271 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ci#define RT5670_PR_RANGE_BASE (0xff + 1) 558c2ecf20Sopenharmony_ci#define RT5670_PR_SPACING 0x100 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ci#define RT5670_PR_BASE (RT5670_PR_RANGE_BASE + (0 * RT5670_PR_SPACING)) 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_cistatic const struct regmap_range_cfg rt5670_ranges[] = { 608c2ecf20Sopenharmony_ci { .name = "PR", .range_min = RT5670_PR_BASE, 618c2ecf20Sopenharmony_ci .range_max = RT5670_PR_BASE + 0xf8, 628c2ecf20Sopenharmony_ci .selector_reg = RT5670_PRIV_INDEX, 638c2ecf20Sopenharmony_ci .selector_mask = 0xff, 648c2ecf20Sopenharmony_ci .selector_shift = 0x0, 658c2ecf20Sopenharmony_ci .window_start = RT5670_PRIV_DATA, 668c2ecf20Sopenharmony_ci .window_len = 0x1, }, 678c2ecf20Sopenharmony_ci}; 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_cistatic const struct reg_sequence init_list[] = { 708c2ecf20Sopenharmony_ci { RT5670_PR_BASE + 0x14, 0x9a8a }, 718c2ecf20Sopenharmony_ci { RT5670_PR_BASE + 0x38, 0x1fe1 }, 728c2ecf20Sopenharmony_ci { RT5670_PR_BASE + 0x3d, 0x3640 }, 738c2ecf20Sopenharmony_ci { 0x8a, 0x0123 }, 748c2ecf20Sopenharmony_ci}; 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_cistatic const struct reg_default rt5670_reg[] = { 778c2ecf20Sopenharmony_ci { 0x00, 0x0000 }, 788c2ecf20Sopenharmony_ci { 0x02, 0x8888 }, 798c2ecf20Sopenharmony_ci { 0x03, 0x8888 }, 808c2ecf20Sopenharmony_ci { 0x0a, 0x0001 }, 818c2ecf20Sopenharmony_ci { 0x0b, 0x0827 }, 828c2ecf20Sopenharmony_ci { 0x0c, 0x0000 }, 838c2ecf20Sopenharmony_ci { 0x0d, 0x0008 }, 848c2ecf20Sopenharmony_ci { 0x0e, 0x0000 }, 858c2ecf20Sopenharmony_ci { 0x0f, 0x0808 }, 868c2ecf20Sopenharmony_ci { 0x19, 0xafaf }, 878c2ecf20Sopenharmony_ci { 0x1a, 0xafaf }, 888c2ecf20Sopenharmony_ci { 0x1b, 0x0011 }, 898c2ecf20Sopenharmony_ci { 0x1c, 0x2f2f }, 908c2ecf20Sopenharmony_ci { 0x1d, 0x2f2f }, 918c2ecf20Sopenharmony_ci { 0x1e, 0x0000 }, 928c2ecf20Sopenharmony_ci { 0x1f, 0x2f2f }, 938c2ecf20Sopenharmony_ci { 0x20, 0x0000 }, 948c2ecf20Sopenharmony_ci { 0x26, 0x7860 }, 958c2ecf20Sopenharmony_ci { 0x27, 0x7860 }, 968c2ecf20Sopenharmony_ci { 0x28, 0x7871 }, 978c2ecf20Sopenharmony_ci { 0x29, 0x8080 }, 988c2ecf20Sopenharmony_ci { 0x2a, 0x5656 }, 998c2ecf20Sopenharmony_ci { 0x2b, 0x5454 }, 1008c2ecf20Sopenharmony_ci { 0x2c, 0xaaa0 }, 1018c2ecf20Sopenharmony_ci { 0x2d, 0x0000 }, 1028c2ecf20Sopenharmony_ci { 0x2e, 0x2f2f }, 1038c2ecf20Sopenharmony_ci { 0x2f, 0x1002 }, 1048c2ecf20Sopenharmony_ci { 0x30, 0x0000 }, 1058c2ecf20Sopenharmony_ci { 0x31, 0x5f00 }, 1068c2ecf20Sopenharmony_ci { 0x32, 0x0000 }, 1078c2ecf20Sopenharmony_ci { 0x33, 0x0000 }, 1088c2ecf20Sopenharmony_ci { 0x34, 0x0000 }, 1098c2ecf20Sopenharmony_ci { 0x35, 0x0000 }, 1108c2ecf20Sopenharmony_ci { 0x36, 0x0000 }, 1118c2ecf20Sopenharmony_ci { 0x37, 0x0000 }, 1128c2ecf20Sopenharmony_ci { 0x38, 0x0000 }, 1138c2ecf20Sopenharmony_ci { 0x3b, 0x0000 }, 1148c2ecf20Sopenharmony_ci { 0x3c, 0x007f }, 1158c2ecf20Sopenharmony_ci { 0x3d, 0x0000 }, 1168c2ecf20Sopenharmony_ci { 0x3e, 0x007f }, 1178c2ecf20Sopenharmony_ci { 0x45, 0xe00f }, 1188c2ecf20Sopenharmony_ci { 0x4c, 0x5380 }, 1198c2ecf20Sopenharmony_ci { 0x4f, 0x0073 }, 1208c2ecf20Sopenharmony_ci { 0x52, 0x00d3 }, 1218c2ecf20Sopenharmony_ci { 0x53, 0xf000 }, 1228c2ecf20Sopenharmony_ci { 0x61, 0x0000 }, 1238c2ecf20Sopenharmony_ci { 0x62, 0x0001 }, 1248c2ecf20Sopenharmony_ci { 0x63, 0x00c3 }, 1258c2ecf20Sopenharmony_ci { 0x64, 0x0000 }, 1268c2ecf20Sopenharmony_ci { 0x65, 0x0001 }, 1278c2ecf20Sopenharmony_ci { 0x66, 0x0000 }, 1288c2ecf20Sopenharmony_ci { 0x6f, 0x8000 }, 1298c2ecf20Sopenharmony_ci { 0x70, 0x8000 }, 1308c2ecf20Sopenharmony_ci { 0x71, 0x8000 }, 1318c2ecf20Sopenharmony_ci { 0x72, 0x8000 }, 1328c2ecf20Sopenharmony_ci { 0x73, 0x7770 }, 1338c2ecf20Sopenharmony_ci { 0x74, 0x0e00 }, 1348c2ecf20Sopenharmony_ci { 0x75, 0x1505 }, 1358c2ecf20Sopenharmony_ci { 0x76, 0x0015 }, 1368c2ecf20Sopenharmony_ci { 0x77, 0x0c00 }, 1378c2ecf20Sopenharmony_ci { 0x78, 0x4000 }, 1388c2ecf20Sopenharmony_ci { 0x79, 0x0123 }, 1398c2ecf20Sopenharmony_ci { 0x7f, 0x1100 }, 1408c2ecf20Sopenharmony_ci { 0x80, 0x0000 }, 1418c2ecf20Sopenharmony_ci { 0x81, 0x0000 }, 1428c2ecf20Sopenharmony_ci { 0x82, 0x0000 }, 1438c2ecf20Sopenharmony_ci { 0x83, 0x0000 }, 1448c2ecf20Sopenharmony_ci { 0x84, 0x0000 }, 1458c2ecf20Sopenharmony_ci { 0x85, 0x0000 }, 1468c2ecf20Sopenharmony_ci { 0x86, 0x0004 }, 1478c2ecf20Sopenharmony_ci { 0x87, 0x0000 }, 1488c2ecf20Sopenharmony_ci { 0x88, 0x0000 }, 1498c2ecf20Sopenharmony_ci { 0x89, 0x0000 }, 1508c2ecf20Sopenharmony_ci { 0x8a, 0x0123 }, 1518c2ecf20Sopenharmony_ci { 0x8b, 0x0000 }, 1528c2ecf20Sopenharmony_ci { 0x8c, 0x0003 }, 1538c2ecf20Sopenharmony_ci { 0x8d, 0x0000 }, 1548c2ecf20Sopenharmony_ci { 0x8e, 0x0004 }, 1558c2ecf20Sopenharmony_ci { 0x8f, 0x1100 }, 1568c2ecf20Sopenharmony_ci { 0x90, 0x0646 }, 1578c2ecf20Sopenharmony_ci { 0x91, 0x0c06 }, 1588c2ecf20Sopenharmony_ci { 0x93, 0x0000 }, 1598c2ecf20Sopenharmony_ci { 0x94, 0x1270 }, 1608c2ecf20Sopenharmony_ci { 0x95, 0x1000 }, 1618c2ecf20Sopenharmony_ci { 0x97, 0x0000 }, 1628c2ecf20Sopenharmony_ci { 0x98, 0x0000 }, 1638c2ecf20Sopenharmony_ci { 0x99, 0x0000 }, 1648c2ecf20Sopenharmony_ci { 0x9a, 0x2184 }, 1658c2ecf20Sopenharmony_ci { 0x9b, 0x010a }, 1668c2ecf20Sopenharmony_ci { 0x9c, 0x0aea }, 1678c2ecf20Sopenharmony_ci { 0x9d, 0x000c }, 1688c2ecf20Sopenharmony_ci { 0x9e, 0x0400 }, 1698c2ecf20Sopenharmony_ci { 0xae, 0x7000 }, 1708c2ecf20Sopenharmony_ci { 0xaf, 0x0000 }, 1718c2ecf20Sopenharmony_ci { 0xb0, 0x7000 }, 1728c2ecf20Sopenharmony_ci { 0xb1, 0x0000 }, 1738c2ecf20Sopenharmony_ci { 0xb2, 0x0000 }, 1748c2ecf20Sopenharmony_ci { 0xb3, 0x001f }, 1758c2ecf20Sopenharmony_ci { 0xb4, 0x220c }, 1768c2ecf20Sopenharmony_ci { 0xb5, 0x1f00 }, 1778c2ecf20Sopenharmony_ci { 0xb6, 0x0000 }, 1788c2ecf20Sopenharmony_ci { 0xb7, 0x0000 }, 1798c2ecf20Sopenharmony_ci { 0xbb, 0x0000 }, 1808c2ecf20Sopenharmony_ci { 0xbc, 0x0000 }, 1818c2ecf20Sopenharmony_ci { 0xbd, 0x0000 }, 1828c2ecf20Sopenharmony_ci { 0xbe, 0x0000 }, 1838c2ecf20Sopenharmony_ci { 0xbf, 0x0000 }, 1848c2ecf20Sopenharmony_ci { 0xc0, 0x0000 }, 1858c2ecf20Sopenharmony_ci { 0xc1, 0x0000 }, 1868c2ecf20Sopenharmony_ci { 0xc2, 0x0000 }, 1878c2ecf20Sopenharmony_ci { 0xcd, 0x0000 }, 1888c2ecf20Sopenharmony_ci { 0xce, 0x0000 }, 1898c2ecf20Sopenharmony_ci { 0xcf, 0x1813 }, 1908c2ecf20Sopenharmony_ci { 0xd0, 0x0690 }, 1918c2ecf20Sopenharmony_ci { 0xd1, 0x1c17 }, 1928c2ecf20Sopenharmony_ci { 0xd3, 0xa220 }, 1938c2ecf20Sopenharmony_ci { 0xd4, 0x0000 }, 1948c2ecf20Sopenharmony_ci { 0xd6, 0x0400 }, 1958c2ecf20Sopenharmony_ci { 0xd9, 0x0809 }, 1968c2ecf20Sopenharmony_ci { 0xda, 0x0000 }, 1978c2ecf20Sopenharmony_ci { 0xdb, 0x0001 }, 1988c2ecf20Sopenharmony_ci { 0xdc, 0x0049 }, 1998c2ecf20Sopenharmony_ci { 0xdd, 0x0024 }, 2008c2ecf20Sopenharmony_ci { 0xe6, 0x8000 }, 2018c2ecf20Sopenharmony_ci { 0xe7, 0x0000 }, 2028c2ecf20Sopenharmony_ci { 0xec, 0xa200 }, 2038c2ecf20Sopenharmony_ci { 0xed, 0x0000 }, 2048c2ecf20Sopenharmony_ci { 0xee, 0xa200 }, 2058c2ecf20Sopenharmony_ci { 0xef, 0x0000 }, 2068c2ecf20Sopenharmony_ci { 0xf8, 0x0000 }, 2078c2ecf20Sopenharmony_ci { 0xf9, 0x0000 }, 2088c2ecf20Sopenharmony_ci { 0xfa, 0x8010 }, 2098c2ecf20Sopenharmony_ci { 0xfb, 0x0033 }, 2108c2ecf20Sopenharmony_ci { 0xfc, 0x0100 }, 2118c2ecf20Sopenharmony_ci}; 2128c2ecf20Sopenharmony_ci 2138c2ecf20Sopenharmony_cistatic bool rt5670_volatile_register(struct device *dev, unsigned int reg) 2148c2ecf20Sopenharmony_ci{ 2158c2ecf20Sopenharmony_ci int i; 2168c2ecf20Sopenharmony_ci 2178c2ecf20Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(rt5670_ranges); i++) { 2188c2ecf20Sopenharmony_ci if ((reg >= rt5670_ranges[i].window_start && 2198c2ecf20Sopenharmony_ci reg <= rt5670_ranges[i].window_start + 2208c2ecf20Sopenharmony_ci rt5670_ranges[i].window_len) || 2218c2ecf20Sopenharmony_ci (reg >= rt5670_ranges[i].range_min && 2228c2ecf20Sopenharmony_ci reg <= rt5670_ranges[i].range_max)) { 2238c2ecf20Sopenharmony_ci return true; 2248c2ecf20Sopenharmony_ci } 2258c2ecf20Sopenharmony_ci } 2268c2ecf20Sopenharmony_ci 2278c2ecf20Sopenharmony_ci switch (reg) { 2288c2ecf20Sopenharmony_ci case RT5670_RESET: 2298c2ecf20Sopenharmony_ci case RT5670_PDM_DATA_CTRL1: 2308c2ecf20Sopenharmony_ci case RT5670_PDM1_DATA_CTRL4: 2318c2ecf20Sopenharmony_ci case RT5670_PDM2_DATA_CTRL4: 2328c2ecf20Sopenharmony_ci case RT5670_PRIV_DATA: 2338c2ecf20Sopenharmony_ci case RT5670_ASRC_5: 2348c2ecf20Sopenharmony_ci case RT5670_CJ_CTRL1: 2358c2ecf20Sopenharmony_ci case RT5670_CJ_CTRL2: 2368c2ecf20Sopenharmony_ci case RT5670_CJ_CTRL3: 2378c2ecf20Sopenharmony_ci case RT5670_A_JD_CTRL1: 2388c2ecf20Sopenharmony_ci case RT5670_A_JD_CTRL2: 2398c2ecf20Sopenharmony_ci case RT5670_VAD_CTRL5: 2408c2ecf20Sopenharmony_ci case RT5670_ADC_EQ_CTRL1: 2418c2ecf20Sopenharmony_ci case RT5670_EQ_CTRL1: 2428c2ecf20Sopenharmony_ci case RT5670_ALC_CTRL_1: 2438c2ecf20Sopenharmony_ci case RT5670_IRQ_CTRL2: 2448c2ecf20Sopenharmony_ci case RT5670_INT_IRQ_ST: 2458c2ecf20Sopenharmony_ci case RT5670_IL_CMD: 2468c2ecf20Sopenharmony_ci case RT5670_DSP_CTRL1: 2478c2ecf20Sopenharmony_ci case RT5670_DSP_CTRL2: 2488c2ecf20Sopenharmony_ci case RT5670_DSP_CTRL3: 2498c2ecf20Sopenharmony_ci case RT5670_DSP_CTRL4: 2508c2ecf20Sopenharmony_ci case RT5670_DSP_CTRL5: 2518c2ecf20Sopenharmony_ci case RT5670_VENDOR_ID: 2528c2ecf20Sopenharmony_ci case RT5670_VENDOR_ID1: 2538c2ecf20Sopenharmony_ci case RT5670_VENDOR_ID2: 2548c2ecf20Sopenharmony_ci return true; 2558c2ecf20Sopenharmony_ci default: 2568c2ecf20Sopenharmony_ci return false; 2578c2ecf20Sopenharmony_ci } 2588c2ecf20Sopenharmony_ci} 2598c2ecf20Sopenharmony_ci 2608c2ecf20Sopenharmony_cistatic bool rt5670_readable_register(struct device *dev, unsigned int reg) 2618c2ecf20Sopenharmony_ci{ 2628c2ecf20Sopenharmony_ci int i; 2638c2ecf20Sopenharmony_ci 2648c2ecf20Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(rt5670_ranges); i++) { 2658c2ecf20Sopenharmony_ci if ((reg >= rt5670_ranges[i].window_start && 2668c2ecf20Sopenharmony_ci reg <= rt5670_ranges[i].window_start + 2678c2ecf20Sopenharmony_ci rt5670_ranges[i].window_len) || 2688c2ecf20Sopenharmony_ci (reg >= rt5670_ranges[i].range_min && 2698c2ecf20Sopenharmony_ci reg <= rt5670_ranges[i].range_max)) { 2708c2ecf20Sopenharmony_ci return true; 2718c2ecf20Sopenharmony_ci } 2728c2ecf20Sopenharmony_ci } 2738c2ecf20Sopenharmony_ci 2748c2ecf20Sopenharmony_ci switch (reg) { 2758c2ecf20Sopenharmony_ci case RT5670_RESET: 2768c2ecf20Sopenharmony_ci case RT5670_HP_VOL: 2778c2ecf20Sopenharmony_ci case RT5670_LOUT1: 2788c2ecf20Sopenharmony_ci case RT5670_CJ_CTRL1: 2798c2ecf20Sopenharmony_ci case RT5670_CJ_CTRL2: 2808c2ecf20Sopenharmony_ci case RT5670_CJ_CTRL3: 2818c2ecf20Sopenharmony_ci case RT5670_IN2: 2828c2ecf20Sopenharmony_ci case RT5670_INL1_INR1_VOL: 2838c2ecf20Sopenharmony_ci case RT5670_DAC1_DIG_VOL: 2848c2ecf20Sopenharmony_ci case RT5670_DAC2_DIG_VOL: 2858c2ecf20Sopenharmony_ci case RT5670_DAC_CTRL: 2868c2ecf20Sopenharmony_ci case RT5670_STO1_ADC_DIG_VOL: 2878c2ecf20Sopenharmony_ci case RT5670_MONO_ADC_DIG_VOL: 2888c2ecf20Sopenharmony_ci case RT5670_STO2_ADC_DIG_VOL: 2898c2ecf20Sopenharmony_ci case RT5670_ADC_BST_VOL1: 2908c2ecf20Sopenharmony_ci case RT5670_ADC_BST_VOL2: 2918c2ecf20Sopenharmony_ci case RT5670_STO2_ADC_MIXER: 2928c2ecf20Sopenharmony_ci case RT5670_STO1_ADC_MIXER: 2938c2ecf20Sopenharmony_ci case RT5670_MONO_ADC_MIXER: 2948c2ecf20Sopenharmony_ci case RT5670_AD_DA_MIXER: 2958c2ecf20Sopenharmony_ci case RT5670_STO_DAC_MIXER: 2968c2ecf20Sopenharmony_ci case RT5670_DD_MIXER: 2978c2ecf20Sopenharmony_ci case RT5670_DIG_MIXER: 2988c2ecf20Sopenharmony_ci case RT5670_DSP_PATH1: 2998c2ecf20Sopenharmony_ci case RT5670_DSP_PATH2: 3008c2ecf20Sopenharmony_ci case RT5670_DIG_INF1_DATA: 3018c2ecf20Sopenharmony_ci case RT5670_DIG_INF2_DATA: 3028c2ecf20Sopenharmony_ci case RT5670_PDM_OUT_CTRL: 3038c2ecf20Sopenharmony_ci case RT5670_PDM_DATA_CTRL1: 3048c2ecf20Sopenharmony_ci case RT5670_PDM1_DATA_CTRL2: 3058c2ecf20Sopenharmony_ci case RT5670_PDM1_DATA_CTRL3: 3068c2ecf20Sopenharmony_ci case RT5670_PDM1_DATA_CTRL4: 3078c2ecf20Sopenharmony_ci case RT5670_PDM2_DATA_CTRL2: 3088c2ecf20Sopenharmony_ci case RT5670_PDM2_DATA_CTRL3: 3098c2ecf20Sopenharmony_ci case RT5670_PDM2_DATA_CTRL4: 3108c2ecf20Sopenharmony_ci case RT5670_REC_L1_MIXER: 3118c2ecf20Sopenharmony_ci case RT5670_REC_L2_MIXER: 3128c2ecf20Sopenharmony_ci case RT5670_REC_R1_MIXER: 3138c2ecf20Sopenharmony_ci case RT5670_REC_R2_MIXER: 3148c2ecf20Sopenharmony_ci case RT5670_HPO_MIXER: 3158c2ecf20Sopenharmony_ci case RT5670_MONO_MIXER: 3168c2ecf20Sopenharmony_ci case RT5670_OUT_L1_MIXER: 3178c2ecf20Sopenharmony_ci case RT5670_OUT_R1_MIXER: 3188c2ecf20Sopenharmony_ci case RT5670_LOUT_MIXER: 3198c2ecf20Sopenharmony_ci case RT5670_PWR_DIG1: 3208c2ecf20Sopenharmony_ci case RT5670_PWR_DIG2: 3218c2ecf20Sopenharmony_ci case RT5670_PWR_ANLG1: 3228c2ecf20Sopenharmony_ci case RT5670_PWR_ANLG2: 3238c2ecf20Sopenharmony_ci case RT5670_PWR_MIXER: 3248c2ecf20Sopenharmony_ci case RT5670_PWR_VOL: 3258c2ecf20Sopenharmony_ci case RT5670_PRIV_INDEX: 3268c2ecf20Sopenharmony_ci case RT5670_PRIV_DATA: 3278c2ecf20Sopenharmony_ci case RT5670_I2S4_SDP: 3288c2ecf20Sopenharmony_ci case RT5670_I2S1_SDP: 3298c2ecf20Sopenharmony_ci case RT5670_I2S2_SDP: 3308c2ecf20Sopenharmony_ci case RT5670_I2S3_SDP: 3318c2ecf20Sopenharmony_ci case RT5670_ADDA_CLK1: 3328c2ecf20Sopenharmony_ci case RT5670_ADDA_CLK2: 3338c2ecf20Sopenharmony_ci case RT5670_DMIC_CTRL1: 3348c2ecf20Sopenharmony_ci case RT5670_DMIC_CTRL2: 3358c2ecf20Sopenharmony_ci case RT5670_TDM_CTRL_1: 3368c2ecf20Sopenharmony_ci case RT5670_TDM_CTRL_2: 3378c2ecf20Sopenharmony_ci case RT5670_TDM_CTRL_3: 3388c2ecf20Sopenharmony_ci case RT5670_DSP_CLK: 3398c2ecf20Sopenharmony_ci case RT5670_GLB_CLK: 3408c2ecf20Sopenharmony_ci case RT5670_PLL_CTRL1: 3418c2ecf20Sopenharmony_ci case RT5670_PLL_CTRL2: 3428c2ecf20Sopenharmony_ci case RT5670_ASRC_1: 3438c2ecf20Sopenharmony_ci case RT5670_ASRC_2: 3448c2ecf20Sopenharmony_ci case RT5670_ASRC_3: 3458c2ecf20Sopenharmony_ci case RT5670_ASRC_4: 3468c2ecf20Sopenharmony_ci case RT5670_ASRC_5: 3478c2ecf20Sopenharmony_ci case RT5670_ASRC_7: 3488c2ecf20Sopenharmony_ci case RT5670_ASRC_8: 3498c2ecf20Sopenharmony_ci case RT5670_ASRC_9: 3508c2ecf20Sopenharmony_ci case RT5670_ASRC_10: 3518c2ecf20Sopenharmony_ci case RT5670_ASRC_11: 3528c2ecf20Sopenharmony_ci case RT5670_ASRC_12: 3538c2ecf20Sopenharmony_ci case RT5670_ASRC_13: 3548c2ecf20Sopenharmony_ci case RT5670_ASRC_14: 3558c2ecf20Sopenharmony_ci case RT5670_DEPOP_M1: 3568c2ecf20Sopenharmony_ci case RT5670_DEPOP_M2: 3578c2ecf20Sopenharmony_ci case RT5670_DEPOP_M3: 3588c2ecf20Sopenharmony_ci case RT5670_CHARGE_PUMP: 3598c2ecf20Sopenharmony_ci case RT5670_MICBIAS: 3608c2ecf20Sopenharmony_ci case RT5670_A_JD_CTRL1: 3618c2ecf20Sopenharmony_ci case RT5670_A_JD_CTRL2: 3628c2ecf20Sopenharmony_ci case RT5670_VAD_CTRL1: 3638c2ecf20Sopenharmony_ci case RT5670_VAD_CTRL2: 3648c2ecf20Sopenharmony_ci case RT5670_VAD_CTRL3: 3658c2ecf20Sopenharmony_ci case RT5670_VAD_CTRL4: 3668c2ecf20Sopenharmony_ci case RT5670_VAD_CTRL5: 3678c2ecf20Sopenharmony_ci case RT5670_ADC_EQ_CTRL1: 3688c2ecf20Sopenharmony_ci case RT5670_ADC_EQ_CTRL2: 3698c2ecf20Sopenharmony_ci case RT5670_EQ_CTRL1: 3708c2ecf20Sopenharmony_ci case RT5670_EQ_CTRL2: 3718c2ecf20Sopenharmony_ci case RT5670_ALC_DRC_CTRL1: 3728c2ecf20Sopenharmony_ci case RT5670_ALC_DRC_CTRL2: 3738c2ecf20Sopenharmony_ci case RT5670_ALC_CTRL_1: 3748c2ecf20Sopenharmony_ci case RT5670_ALC_CTRL_2: 3758c2ecf20Sopenharmony_ci case RT5670_ALC_CTRL_3: 3768c2ecf20Sopenharmony_ci case RT5670_JD_CTRL: 3778c2ecf20Sopenharmony_ci case RT5670_IRQ_CTRL1: 3788c2ecf20Sopenharmony_ci case RT5670_IRQ_CTRL2: 3798c2ecf20Sopenharmony_ci case RT5670_INT_IRQ_ST: 3808c2ecf20Sopenharmony_ci case RT5670_GPIO_CTRL1: 3818c2ecf20Sopenharmony_ci case RT5670_GPIO_CTRL2: 3828c2ecf20Sopenharmony_ci case RT5670_GPIO_CTRL3: 3838c2ecf20Sopenharmony_ci case RT5670_SCRABBLE_FUN: 3848c2ecf20Sopenharmony_ci case RT5670_SCRABBLE_CTRL: 3858c2ecf20Sopenharmony_ci case RT5670_BASE_BACK: 3868c2ecf20Sopenharmony_ci case RT5670_MP3_PLUS1: 3878c2ecf20Sopenharmony_ci case RT5670_MP3_PLUS2: 3888c2ecf20Sopenharmony_ci case RT5670_ADJ_HPF1: 3898c2ecf20Sopenharmony_ci case RT5670_ADJ_HPF2: 3908c2ecf20Sopenharmony_ci case RT5670_HP_CALIB_AMP_DET: 3918c2ecf20Sopenharmony_ci case RT5670_SV_ZCD1: 3928c2ecf20Sopenharmony_ci case RT5670_SV_ZCD2: 3938c2ecf20Sopenharmony_ci case RT5670_IL_CMD: 3948c2ecf20Sopenharmony_ci case RT5670_IL_CMD2: 3958c2ecf20Sopenharmony_ci case RT5670_IL_CMD3: 3968c2ecf20Sopenharmony_ci case RT5670_DRC_HL_CTRL1: 3978c2ecf20Sopenharmony_ci case RT5670_DRC_HL_CTRL2: 3988c2ecf20Sopenharmony_ci case RT5670_ADC_MONO_HP_CTRL1: 3998c2ecf20Sopenharmony_ci case RT5670_ADC_MONO_HP_CTRL2: 4008c2ecf20Sopenharmony_ci case RT5670_ADC_STO2_HP_CTRL1: 4018c2ecf20Sopenharmony_ci case RT5670_ADC_STO2_HP_CTRL2: 4028c2ecf20Sopenharmony_ci case RT5670_JD_CTRL3: 4038c2ecf20Sopenharmony_ci case RT5670_JD_CTRL4: 4048c2ecf20Sopenharmony_ci case RT5670_DIG_MISC: 4058c2ecf20Sopenharmony_ci case RT5670_DSP_CTRL1: 4068c2ecf20Sopenharmony_ci case RT5670_DSP_CTRL2: 4078c2ecf20Sopenharmony_ci case RT5670_DSP_CTRL3: 4088c2ecf20Sopenharmony_ci case RT5670_DSP_CTRL4: 4098c2ecf20Sopenharmony_ci case RT5670_DSP_CTRL5: 4108c2ecf20Sopenharmony_ci case RT5670_GEN_CTRL2: 4118c2ecf20Sopenharmony_ci case RT5670_GEN_CTRL3: 4128c2ecf20Sopenharmony_ci case RT5670_VENDOR_ID: 4138c2ecf20Sopenharmony_ci case RT5670_VENDOR_ID1: 4148c2ecf20Sopenharmony_ci case RT5670_VENDOR_ID2: 4158c2ecf20Sopenharmony_ci return true; 4168c2ecf20Sopenharmony_ci default: 4178c2ecf20Sopenharmony_ci return false; 4188c2ecf20Sopenharmony_ci } 4198c2ecf20Sopenharmony_ci} 4208c2ecf20Sopenharmony_ci 4218c2ecf20Sopenharmony_ci/** 4228c2ecf20Sopenharmony_ci * rt5670_headset_detect - Detect headset. 4238c2ecf20Sopenharmony_ci * @component: SoC audio component device. 4248c2ecf20Sopenharmony_ci * @jack_insert: Jack insert or not. 4258c2ecf20Sopenharmony_ci * 4268c2ecf20Sopenharmony_ci * Detect whether is headset or not when jack inserted. 4278c2ecf20Sopenharmony_ci * 4288c2ecf20Sopenharmony_ci * Returns detect status. 4298c2ecf20Sopenharmony_ci */ 4308c2ecf20Sopenharmony_ci 4318c2ecf20Sopenharmony_cistatic int rt5670_headset_detect(struct snd_soc_component *component, int jack_insert) 4328c2ecf20Sopenharmony_ci{ 4338c2ecf20Sopenharmony_ci int val; 4348c2ecf20Sopenharmony_ci struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); 4358c2ecf20Sopenharmony_ci struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); 4368c2ecf20Sopenharmony_ci 4378c2ecf20Sopenharmony_ci if (jack_insert) { 4388c2ecf20Sopenharmony_ci snd_soc_dapm_force_enable_pin(dapm, "Mic Det Power"); 4398c2ecf20Sopenharmony_ci snd_soc_dapm_sync(dapm); 4408c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, RT5670_GEN_CTRL3, 0x4, 0x0); 4418c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, RT5670_CJ_CTRL2, 4428c2ecf20Sopenharmony_ci RT5670_CBJ_DET_MODE | RT5670_CBJ_MN_JD, 4438c2ecf20Sopenharmony_ci RT5670_CBJ_MN_JD); 4448c2ecf20Sopenharmony_ci snd_soc_component_write(component, RT5670_GPIO_CTRL2, 0x0004); 4458c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, RT5670_GPIO_CTRL1, 4468c2ecf20Sopenharmony_ci RT5670_GP1_PIN_MASK, RT5670_GP1_PIN_IRQ); 4478c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, RT5670_CJ_CTRL1, 4488c2ecf20Sopenharmony_ci RT5670_CBJ_BST1_EN, RT5670_CBJ_BST1_EN); 4498c2ecf20Sopenharmony_ci snd_soc_component_write(component, RT5670_JD_CTRL3, 0x00f0); 4508c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, RT5670_CJ_CTRL2, 4518c2ecf20Sopenharmony_ci RT5670_CBJ_MN_JD, RT5670_CBJ_MN_JD); 4528c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, RT5670_CJ_CTRL2, 4538c2ecf20Sopenharmony_ci RT5670_CBJ_MN_JD, 0); 4548c2ecf20Sopenharmony_ci msleep(300); 4558c2ecf20Sopenharmony_ci val = snd_soc_component_read(component, RT5670_CJ_CTRL3) & 0x7; 4568c2ecf20Sopenharmony_ci if (val == 0x1 || val == 0x2) { 4578c2ecf20Sopenharmony_ci rt5670->jack_type = SND_JACK_HEADSET; 4588c2ecf20Sopenharmony_ci /* for push button */ 4598c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, RT5670_INT_IRQ_ST, 0x8, 0x8); 4608c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, RT5670_IL_CMD, 0x40, 0x40); 4618c2ecf20Sopenharmony_ci snd_soc_component_read(component, RT5670_IL_CMD); 4628c2ecf20Sopenharmony_ci } else { 4638c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, RT5670_GEN_CTRL3, 0x4, 0x4); 4648c2ecf20Sopenharmony_ci rt5670->jack_type = SND_JACK_HEADPHONE; 4658c2ecf20Sopenharmony_ci snd_soc_dapm_disable_pin(dapm, "Mic Det Power"); 4668c2ecf20Sopenharmony_ci snd_soc_dapm_sync(dapm); 4678c2ecf20Sopenharmony_ci } 4688c2ecf20Sopenharmony_ci } else { 4698c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, RT5670_INT_IRQ_ST, 0x8, 0x0); 4708c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, RT5670_GEN_CTRL3, 0x4, 0x4); 4718c2ecf20Sopenharmony_ci rt5670->jack_type = 0; 4728c2ecf20Sopenharmony_ci snd_soc_dapm_disable_pin(dapm, "Mic Det Power"); 4738c2ecf20Sopenharmony_ci snd_soc_dapm_sync(dapm); 4748c2ecf20Sopenharmony_ci } 4758c2ecf20Sopenharmony_ci 4768c2ecf20Sopenharmony_ci return rt5670->jack_type; 4778c2ecf20Sopenharmony_ci} 4788c2ecf20Sopenharmony_ci 4798c2ecf20Sopenharmony_civoid rt5670_jack_suspend(struct snd_soc_component *component) 4808c2ecf20Sopenharmony_ci{ 4818c2ecf20Sopenharmony_ci struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); 4828c2ecf20Sopenharmony_ci 4838c2ecf20Sopenharmony_ci rt5670->jack_type_saved = rt5670->jack_type; 4848c2ecf20Sopenharmony_ci rt5670_headset_detect(component, 0); 4858c2ecf20Sopenharmony_ci} 4868c2ecf20Sopenharmony_ciEXPORT_SYMBOL_GPL(rt5670_jack_suspend); 4878c2ecf20Sopenharmony_ci 4888c2ecf20Sopenharmony_civoid rt5670_jack_resume(struct snd_soc_component *component) 4898c2ecf20Sopenharmony_ci{ 4908c2ecf20Sopenharmony_ci struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); 4918c2ecf20Sopenharmony_ci 4928c2ecf20Sopenharmony_ci if (rt5670->jack_type_saved) 4938c2ecf20Sopenharmony_ci rt5670_headset_detect(component, 1); 4948c2ecf20Sopenharmony_ci} 4958c2ecf20Sopenharmony_ciEXPORT_SYMBOL_GPL(rt5670_jack_resume); 4968c2ecf20Sopenharmony_ci 4978c2ecf20Sopenharmony_cistatic int rt5670_button_detect(struct snd_soc_component *component) 4988c2ecf20Sopenharmony_ci{ 4998c2ecf20Sopenharmony_ci int btn_type, val; 5008c2ecf20Sopenharmony_ci 5018c2ecf20Sopenharmony_ci val = snd_soc_component_read(component, RT5670_IL_CMD); 5028c2ecf20Sopenharmony_ci btn_type = val & 0xff80; 5038c2ecf20Sopenharmony_ci snd_soc_component_write(component, RT5670_IL_CMD, val); 5048c2ecf20Sopenharmony_ci if (btn_type != 0) { 5058c2ecf20Sopenharmony_ci msleep(20); 5068c2ecf20Sopenharmony_ci val = snd_soc_component_read(component, RT5670_IL_CMD); 5078c2ecf20Sopenharmony_ci snd_soc_component_write(component, RT5670_IL_CMD, val); 5088c2ecf20Sopenharmony_ci } 5098c2ecf20Sopenharmony_ci 5108c2ecf20Sopenharmony_ci return btn_type; 5118c2ecf20Sopenharmony_ci} 5128c2ecf20Sopenharmony_ci 5138c2ecf20Sopenharmony_cistatic int rt5670_irq_detection(void *data) 5148c2ecf20Sopenharmony_ci{ 5158c2ecf20Sopenharmony_ci struct rt5670_priv *rt5670 = (struct rt5670_priv *)data; 5168c2ecf20Sopenharmony_ci struct snd_soc_jack_gpio *gpio = &rt5670->hp_gpio; 5178c2ecf20Sopenharmony_ci struct snd_soc_jack *jack = rt5670->jack; 5188c2ecf20Sopenharmony_ci int val, btn_type, report = jack->status; 5198c2ecf20Sopenharmony_ci 5208c2ecf20Sopenharmony_ci if (rt5670->jd_mode == 1) /* 2 port */ 5218c2ecf20Sopenharmony_ci val = snd_soc_component_read(rt5670->component, RT5670_A_JD_CTRL1) & 0x0070; 5228c2ecf20Sopenharmony_ci else 5238c2ecf20Sopenharmony_ci val = snd_soc_component_read(rt5670->component, RT5670_A_JD_CTRL1) & 0x0020; 5248c2ecf20Sopenharmony_ci 5258c2ecf20Sopenharmony_ci switch (val) { 5268c2ecf20Sopenharmony_ci /* jack in */ 5278c2ecf20Sopenharmony_ci case 0x30: /* 2 port */ 5288c2ecf20Sopenharmony_ci case 0x0: /* 1 port or 2 port */ 5298c2ecf20Sopenharmony_ci if (rt5670->jack_type == 0) { 5308c2ecf20Sopenharmony_ci report = rt5670_headset_detect(rt5670->component, 1); 5318c2ecf20Sopenharmony_ci /* for push button and jack out */ 5328c2ecf20Sopenharmony_ci gpio->debounce_time = 25; 5338c2ecf20Sopenharmony_ci break; 5348c2ecf20Sopenharmony_ci } 5358c2ecf20Sopenharmony_ci btn_type = 0; 5368c2ecf20Sopenharmony_ci if (snd_soc_component_read(rt5670->component, RT5670_INT_IRQ_ST) & 0x4) { 5378c2ecf20Sopenharmony_ci /* button pressed */ 5388c2ecf20Sopenharmony_ci report = SND_JACK_HEADSET; 5398c2ecf20Sopenharmony_ci btn_type = rt5670_button_detect(rt5670->component); 5408c2ecf20Sopenharmony_ci switch (btn_type) { 5418c2ecf20Sopenharmony_ci case 0x2000: /* up */ 5428c2ecf20Sopenharmony_ci report |= SND_JACK_BTN_1; 5438c2ecf20Sopenharmony_ci break; 5448c2ecf20Sopenharmony_ci case 0x0400: /* center */ 5458c2ecf20Sopenharmony_ci report |= SND_JACK_BTN_0; 5468c2ecf20Sopenharmony_ci break; 5478c2ecf20Sopenharmony_ci case 0x0080: /* down */ 5488c2ecf20Sopenharmony_ci report |= SND_JACK_BTN_2; 5498c2ecf20Sopenharmony_ci break; 5508c2ecf20Sopenharmony_ci default: 5518c2ecf20Sopenharmony_ci dev_err(rt5670->component->dev, 5528c2ecf20Sopenharmony_ci "Unexpected button code 0x%04x\n", 5538c2ecf20Sopenharmony_ci btn_type); 5548c2ecf20Sopenharmony_ci break; 5558c2ecf20Sopenharmony_ci } 5568c2ecf20Sopenharmony_ci } 5578c2ecf20Sopenharmony_ci if (btn_type == 0)/* button release */ 5588c2ecf20Sopenharmony_ci report = rt5670->jack_type; 5598c2ecf20Sopenharmony_ci 5608c2ecf20Sopenharmony_ci break; 5618c2ecf20Sopenharmony_ci /* jack out */ 5628c2ecf20Sopenharmony_ci case 0x70: /* 2 port */ 5638c2ecf20Sopenharmony_ci case 0x10: /* 2 port */ 5648c2ecf20Sopenharmony_ci case 0x20: /* 1 port */ 5658c2ecf20Sopenharmony_ci report = 0; 5668c2ecf20Sopenharmony_ci snd_soc_component_update_bits(rt5670->component, RT5670_INT_IRQ_ST, 0x1, 0x0); 5678c2ecf20Sopenharmony_ci rt5670_headset_detect(rt5670->component, 0); 5688c2ecf20Sopenharmony_ci gpio->debounce_time = 150; /* for jack in */ 5698c2ecf20Sopenharmony_ci break; 5708c2ecf20Sopenharmony_ci default: 5718c2ecf20Sopenharmony_ci break; 5728c2ecf20Sopenharmony_ci } 5738c2ecf20Sopenharmony_ci 5748c2ecf20Sopenharmony_ci return report; 5758c2ecf20Sopenharmony_ci} 5768c2ecf20Sopenharmony_ci 5778c2ecf20Sopenharmony_ciint rt5670_set_jack_detect(struct snd_soc_component *component, 5788c2ecf20Sopenharmony_ci struct snd_soc_jack *jack) 5798c2ecf20Sopenharmony_ci{ 5808c2ecf20Sopenharmony_ci struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); 5818c2ecf20Sopenharmony_ci int ret; 5828c2ecf20Sopenharmony_ci 5838c2ecf20Sopenharmony_ci rt5670->jack = jack; 5848c2ecf20Sopenharmony_ci rt5670->hp_gpio.gpiod_dev = component->dev; 5858c2ecf20Sopenharmony_ci rt5670->hp_gpio.name = "headset"; 5868c2ecf20Sopenharmony_ci rt5670->hp_gpio.report = SND_JACK_HEADSET | 5878c2ecf20Sopenharmony_ci SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_BTN_2; 5888c2ecf20Sopenharmony_ci rt5670->hp_gpio.debounce_time = 150; 5898c2ecf20Sopenharmony_ci rt5670->hp_gpio.wake = true; 5908c2ecf20Sopenharmony_ci rt5670->hp_gpio.data = (struct rt5670_priv *)rt5670; 5918c2ecf20Sopenharmony_ci rt5670->hp_gpio.jack_status_check = rt5670_irq_detection; 5928c2ecf20Sopenharmony_ci 5938c2ecf20Sopenharmony_ci ret = snd_soc_jack_add_gpios(rt5670->jack, 1, 5948c2ecf20Sopenharmony_ci &rt5670->hp_gpio); 5958c2ecf20Sopenharmony_ci if (ret) { 5968c2ecf20Sopenharmony_ci dev_err(component->dev, "Adding jack GPIO failed\n"); 5978c2ecf20Sopenharmony_ci return ret; 5988c2ecf20Sopenharmony_ci } 5998c2ecf20Sopenharmony_ci 6008c2ecf20Sopenharmony_ci return 0; 6018c2ecf20Sopenharmony_ci} 6028c2ecf20Sopenharmony_ciEXPORT_SYMBOL_GPL(rt5670_set_jack_detect); 6038c2ecf20Sopenharmony_ci 6048c2ecf20Sopenharmony_cistatic const DECLARE_TLV_DB_SCALE(out_vol_tlv, -4650, 150, 0); 6058c2ecf20Sopenharmony_cistatic const DECLARE_TLV_DB_MINMAX(dac_vol_tlv, -6562, 0); 6068c2ecf20Sopenharmony_cistatic const DECLARE_TLV_DB_SCALE(in_vol_tlv, -3450, 150, 0); 6078c2ecf20Sopenharmony_cistatic const DECLARE_TLV_DB_MINMAX(adc_vol_tlv, -1762, 3000); 6088c2ecf20Sopenharmony_cistatic const DECLARE_TLV_DB_SCALE(adc_bst_tlv, 0, 1200, 0); 6098c2ecf20Sopenharmony_ci 6108c2ecf20Sopenharmony_ci/* {0, +20, +24, +30, +35, +40, +44, +50, +52} dB */ 6118c2ecf20Sopenharmony_cistatic const DECLARE_TLV_DB_RANGE(bst_tlv, 6128c2ecf20Sopenharmony_ci 0, 0, TLV_DB_SCALE_ITEM(0, 0, 0), 6138c2ecf20Sopenharmony_ci 1, 1, TLV_DB_SCALE_ITEM(2000, 0, 0), 6148c2ecf20Sopenharmony_ci 2, 2, TLV_DB_SCALE_ITEM(2400, 0, 0), 6158c2ecf20Sopenharmony_ci 3, 5, TLV_DB_SCALE_ITEM(3000, 500, 0), 6168c2ecf20Sopenharmony_ci 6, 6, TLV_DB_SCALE_ITEM(4400, 0, 0), 6178c2ecf20Sopenharmony_ci 7, 7, TLV_DB_SCALE_ITEM(5000, 0, 0), 6188c2ecf20Sopenharmony_ci 8, 8, TLV_DB_SCALE_ITEM(5200, 0, 0) 6198c2ecf20Sopenharmony_ci); 6208c2ecf20Sopenharmony_ci 6218c2ecf20Sopenharmony_ci/* Interface data select */ 6228c2ecf20Sopenharmony_cistatic const char * const rt5670_data_select[] = { 6238c2ecf20Sopenharmony_ci "Normal", "Swap", "left copy to right", "right copy to left" 6248c2ecf20Sopenharmony_ci}; 6258c2ecf20Sopenharmony_ci 6268c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(rt5670_if2_dac_enum, RT5670_DIG_INF1_DATA, 6278c2ecf20Sopenharmony_ci RT5670_IF2_DAC_SEL_SFT, rt5670_data_select); 6288c2ecf20Sopenharmony_ci 6298c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(rt5670_if2_adc_enum, RT5670_DIG_INF1_DATA, 6308c2ecf20Sopenharmony_ci RT5670_IF2_ADC_SEL_SFT, rt5670_data_select); 6318c2ecf20Sopenharmony_ci 6328c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5670_snd_controls[] = { 6338c2ecf20Sopenharmony_ci /* Headphone Output Volume */ 6348c2ecf20Sopenharmony_ci SOC_DOUBLE("HP Playback Switch", RT5670_HP_VOL, 6358c2ecf20Sopenharmony_ci RT5670_L_MUTE_SFT, RT5670_R_MUTE_SFT, 1, 1), 6368c2ecf20Sopenharmony_ci SOC_DOUBLE_TLV("HP Playback Volume", RT5670_HP_VOL, 6378c2ecf20Sopenharmony_ci RT5670_L_VOL_SFT, RT5670_R_VOL_SFT, 6388c2ecf20Sopenharmony_ci 39, 1, out_vol_tlv), 6398c2ecf20Sopenharmony_ci /* OUTPUT Control */ 6408c2ecf20Sopenharmony_ci SOC_DOUBLE("OUT Channel Switch", RT5670_LOUT1, 6418c2ecf20Sopenharmony_ci RT5670_VOL_L_SFT, RT5670_VOL_R_SFT, 1, 1), 6428c2ecf20Sopenharmony_ci SOC_DOUBLE_TLV("OUT Playback Volume", RT5670_LOUT1, 6438c2ecf20Sopenharmony_ci RT5670_L_VOL_SFT, RT5670_R_VOL_SFT, 39, 1, out_vol_tlv), 6448c2ecf20Sopenharmony_ci /* DAC Digital Volume */ 6458c2ecf20Sopenharmony_ci SOC_DOUBLE("DAC2 Playback Switch", RT5670_DAC_CTRL, 6468c2ecf20Sopenharmony_ci RT5670_M_DAC_L2_VOL_SFT, RT5670_M_DAC_R2_VOL_SFT, 1, 1), 6478c2ecf20Sopenharmony_ci SOC_DOUBLE_TLV("DAC1 Playback Volume", RT5670_DAC1_DIG_VOL, 6488c2ecf20Sopenharmony_ci RT5670_L_VOL_SFT, RT5670_R_VOL_SFT, 6498c2ecf20Sopenharmony_ci 175, 0, dac_vol_tlv), 6508c2ecf20Sopenharmony_ci SOC_DOUBLE_TLV("Mono DAC Playback Volume", RT5670_DAC2_DIG_VOL, 6518c2ecf20Sopenharmony_ci RT5670_L_VOL_SFT, RT5670_R_VOL_SFT, 6528c2ecf20Sopenharmony_ci 175, 0, dac_vol_tlv), 6538c2ecf20Sopenharmony_ci /* IN1/IN2 Control */ 6548c2ecf20Sopenharmony_ci SOC_SINGLE_TLV("IN1 Boost Volume", RT5670_CJ_CTRL1, 6558c2ecf20Sopenharmony_ci RT5670_BST_SFT1, 8, 0, bst_tlv), 6568c2ecf20Sopenharmony_ci SOC_SINGLE_TLV("IN2 Boost Volume", RT5670_IN2, 6578c2ecf20Sopenharmony_ci RT5670_BST_SFT1, 8, 0, bst_tlv), 6588c2ecf20Sopenharmony_ci /* INL/INR Volume Control */ 6598c2ecf20Sopenharmony_ci SOC_DOUBLE_TLV("IN Capture Volume", RT5670_INL1_INR1_VOL, 6608c2ecf20Sopenharmony_ci RT5670_INL_VOL_SFT, RT5670_INR_VOL_SFT, 6618c2ecf20Sopenharmony_ci 31, 1, in_vol_tlv), 6628c2ecf20Sopenharmony_ci /* ADC Digital Volume Control */ 6638c2ecf20Sopenharmony_ci SOC_DOUBLE("ADC Capture Switch", RT5670_STO1_ADC_DIG_VOL, 6648c2ecf20Sopenharmony_ci RT5670_L_MUTE_SFT, RT5670_R_MUTE_SFT, 1, 1), 6658c2ecf20Sopenharmony_ci SOC_DOUBLE_TLV("ADC Capture Volume", RT5670_STO1_ADC_DIG_VOL, 6668c2ecf20Sopenharmony_ci RT5670_L_VOL_SFT, RT5670_R_VOL_SFT, 6678c2ecf20Sopenharmony_ci 127, 0, adc_vol_tlv), 6688c2ecf20Sopenharmony_ci 6698c2ecf20Sopenharmony_ci SOC_DOUBLE_TLV("Mono ADC Capture Volume", RT5670_MONO_ADC_DIG_VOL, 6708c2ecf20Sopenharmony_ci RT5670_L_VOL_SFT, RT5670_R_VOL_SFT, 6718c2ecf20Sopenharmony_ci 127, 0, adc_vol_tlv), 6728c2ecf20Sopenharmony_ci 6738c2ecf20Sopenharmony_ci /* ADC Boost Volume Control */ 6748c2ecf20Sopenharmony_ci SOC_DOUBLE_TLV("STO1 ADC Boost Gain Volume", RT5670_ADC_BST_VOL1, 6758c2ecf20Sopenharmony_ci RT5670_STO1_ADC_L_BST_SFT, RT5670_STO1_ADC_R_BST_SFT, 6768c2ecf20Sopenharmony_ci 3, 0, adc_bst_tlv), 6778c2ecf20Sopenharmony_ci 6788c2ecf20Sopenharmony_ci SOC_DOUBLE_TLV("STO2 ADC Boost Gain Volume", RT5670_ADC_BST_VOL1, 6798c2ecf20Sopenharmony_ci RT5670_STO2_ADC_L_BST_SFT, RT5670_STO2_ADC_R_BST_SFT, 6808c2ecf20Sopenharmony_ci 3, 0, adc_bst_tlv), 6818c2ecf20Sopenharmony_ci 6828c2ecf20Sopenharmony_ci SOC_ENUM("ADC IF2 Data Switch", rt5670_if2_adc_enum), 6838c2ecf20Sopenharmony_ci SOC_ENUM("DAC IF2 Data Switch", rt5670_if2_dac_enum), 6848c2ecf20Sopenharmony_ci}; 6858c2ecf20Sopenharmony_ci 6868c2ecf20Sopenharmony_ci/** 6878c2ecf20Sopenharmony_ci * set_dmic_clk - Set parameter of dmic. 6888c2ecf20Sopenharmony_ci * 6898c2ecf20Sopenharmony_ci * @w: DAPM widget. 6908c2ecf20Sopenharmony_ci * @kcontrol: The kcontrol of this widget. 6918c2ecf20Sopenharmony_ci * @event: Event id. 6928c2ecf20Sopenharmony_ci * 6938c2ecf20Sopenharmony_ci * Choose dmic clock between 1MHz and 3MHz. 6948c2ecf20Sopenharmony_ci * It is better for clock to approximate 3MHz. 6958c2ecf20Sopenharmony_ci */ 6968c2ecf20Sopenharmony_cistatic int set_dmic_clk(struct snd_soc_dapm_widget *w, 6978c2ecf20Sopenharmony_ci struct snd_kcontrol *kcontrol, int event) 6988c2ecf20Sopenharmony_ci{ 6998c2ecf20Sopenharmony_ci struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); 7008c2ecf20Sopenharmony_ci struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); 7018c2ecf20Sopenharmony_ci int idx, rate; 7028c2ecf20Sopenharmony_ci 7038c2ecf20Sopenharmony_ci rate = rt5670->sysclk / rl6231_get_pre_div(rt5670->regmap, 7048c2ecf20Sopenharmony_ci RT5670_ADDA_CLK1, RT5670_I2S_PD1_SFT); 7058c2ecf20Sopenharmony_ci idx = rl6231_calc_dmic_clk(rate); 7068c2ecf20Sopenharmony_ci if (idx < 0) 7078c2ecf20Sopenharmony_ci dev_err(component->dev, "Failed to set DMIC clock\n"); 7088c2ecf20Sopenharmony_ci else 7098c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, RT5670_DMIC_CTRL1, 7108c2ecf20Sopenharmony_ci RT5670_DMIC_CLK_MASK, idx << RT5670_DMIC_CLK_SFT); 7118c2ecf20Sopenharmony_ci return idx; 7128c2ecf20Sopenharmony_ci} 7138c2ecf20Sopenharmony_ci 7148c2ecf20Sopenharmony_cistatic int is_sys_clk_from_pll(struct snd_soc_dapm_widget *source, 7158c2ecf20Sopenharmony_ci struct snd_soc_dapm_widget *sink) 7168c2ecf20Sopenharmony_ci{ 7178c2ecf20Sopenharmony_ci struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); 7188c2ecf20Sopenharmony_ci struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); 7198c2ecf20Sopenharmony_ci 7208c2ecf20Sopenharmony_ci if (rt5670->sysclk_src == RT5670_SCLK_S_PLL1) 7218c2ecf20Sopenharmony_ci return 1; 7228c2ecf20Sopenharmony_ci else 7238c2ecf20Sopenharmony_ci return 0; 7248c2ecf20Sopenharmony_ci} 7258c2ecf20Sopenharmony_ci 7268c2ecf20Sopenharmony_cistatic int is_using_asrc(struct snd_soc_dapm_widget *source, 7278c2ecf20Sopenharmony_ci struct snd_soc_dapm_widget *sink) 7288c2ecf20Sopenharmony_ci{ 7298c2ecf20Sopenharmony_ci struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); 7308c2ecf20Sopenharmony_ci unsigned int reg, shift, val; 7318c2ecf20Sopenharmony_ci 7328c2ecf20Sopenharmony_ci switch (source->shift) { 7338c2ecf20Sopenharmony_ci case 0: 7348c2ecf20Sopenharmony_ci reg = RT5670_ASRC_3; 7358c2ecf20Sopenharmony_ci shift = 0; 7368c2ecf20Sopenharmony_ci break; 7378c2ecf20Sopenharmony_ci case 1: 7388c2ecf20Sopenharmony_ci reg = RT5670_ASRC_3; 7398c2ecf20Sopenharmony_ci shift = 4; 7408c2ecf20Sopenharmony_ci break; 7418c2ecf20Sopenharmony_ci case 2: 7428c2ecf20Sopenharmony_ci reg = RT5670_ASRC_5; 7438c2ecf20Sopenharmony_ci shift = 12; 7448c2ecf20Sopenharmony_ci break; 7458c2ecf20Sopenharmony_ci case 3: 7468c2ecf20Sopenharmony_ci reg = RT5670_ASRC_2; 7478c2ecf20Sopenharmony_ci shift = 0; 7488c2ecf20Sopenharmony_ci break; 7498c2ecf20Sopenharmony_ci case 8: 7508c2ecf20Sopenharmony_ci reg = RT5670_ASRC_2; 7518c2ecf20Sopenharmony_ci shift = 4; 7528c2ecf20Sopenharmony_ci break; 7538c2ecf20Sopenharmony_ci case 9: 7548c2ecf20Sopenharmony_ci reg = RT5670_ASRC_2; 7558c2ecf20Sopenharmony_ci shift = 8; 7568c2ecf20Sopenharmony_ci break; 7578c2ecf20Sopenharmony_ci case 10: 7588c2ecf20Sopenharmony_ci reg = RT5670_ASRC_2; 7598c2ecf20Sopenharmony_ci shift = 12; 7608c2ecf20Sopenharmony_ci break; 7618c2ecf20Sopenharmony_ci default: 7628c2ecf20Sopenharmony_ci return 0; 7638c2ecf20Sopenharmony_ci } 7648c2ecf20Sopenharmony_ci 7658c2ecf20Sopenharmony_ci val = (snd_soc_component_read(component, reg) >> shift) & 0xf; 7668c2ecf20Sopenharmony_ci switch (val) { 7678c2ecf20Sopenharmony_ci case 1: 7688c2ecf20Sopenharmony_ci case 2: 7698c2ecf20Sopenharmony_ci case 3: 7708c2ecf20Sopenharmony_ci case 4: 7718c2ecf20Sopenharmony_ci return 1; 7728c2ecf20Sopenharmony_ci default: 7738c2ecf20Sopenharmony_ci return 0; 7748c2ecf20Sopenharmony_ci } 7758c2ecf20Sopenharmony_ci 7768c2ecf20Sopenharmony_ci} 7778c2ecf20Sopenharmony_ci 7788c2ecf20Sopenharmony_cistatic int can_use_asrc(struct snd_soc_dapm_widget *source, 7798c2ecf20Sopenharmony_ci struct snd_soc_dapm_widget *sink) 7808c2ecf20Sopenharmony_ci{ 7818c2ecf20Sopenharmony_ci struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); 7828c2ecf20Sopenharmony_ci struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); 7838c2ecf20Sopenharmony_ci 7848c2ecf20Sopenharmony_ci if (rt5670->sysclk > rt5670->lrck[RT5670_AIF1] * 384) 7858c2ecf20Sopenharmony_ci return 1; 7868c2ecf20Sopenharmony_ci 7878c2ecf20Sopenharmony_ci return 0; 7888c2ecf20Sopenharmony_ci} 7898c2ecf20Sopenharmony_ci 7908c2ecf20Sopenharmony_ci 7918c2ecf20Sopenharmony_ci/** 7928c2ecf20Sopenharmony_ci * rt5670_sel_asrc_clk_src - select ASRC clock source for a set of filters 7938c2ecf20Sopenharmony_ci * @component: SoC audio component device. 7948c2ecf20Sopenharmony_ci * @filter_mask: mask of filters. 7958c2ecf20Sopenharmony_ci * @clk_src: clock source 7968c2ecf20Sopenharmony_ci * 7978c2ecf20Sopenharmony_ci * The ASRC function is for asynchronous MCLK and LRCK. Also, since RT5670 can 7988c2ecf20Sopenharmony_ci * only support standard 32fs or 64fs i2s format, ASRC should be enabled to 7998c2ecf20Sopenharmony_ci * support special i2s clock format such as Intel's 100fs(100 * sampling rate). 8008c2ecf20Sopenharmony_ci * ASRC function will track i2s clock and generate a corresponding system clock 8018c2ecf20Sopenharmony_ci * for codec. This function provides an API to select the clock source for a 8028c2ecf20Sopenharmony_ci * set of filters specified by the mask. And the codec driver will turn on ASRC 8038c2ecf20Sopenharmony_ci * for these filters if ASRC is selected as their clock source. 8048c2ecf20Sopenharmony_ci */ 8058c2ecf20Sopenharmony_ciint rt5670_sel_asrc_clk_src(struct snd_soc_component *component, 8068c2ecf20Sopenharmony_ci unsigned int filter_mask, unsigned int clk_src) 8078c2ecf20Sopenharmony_ci{ 8088c2ecf20Sopenharmony_ci unsigned int asrc2_mask = 0, asrc2_value = 0; 8098c2ecf20Sopenharmony_ci unsigned int asrc3_mask = 0, asrc3_value = 0; 8108c2ecf20Sopenharmony_ci 8118c2ecf20Sopenharmony_ci if (clk_src > RT5670_CLK_SEL_SYS3) 8128c2ecf20Sopenharmony_ci return -EINVAL; 8138c2ecf20Sopenharmony_ci 8148c2ecf20Sopenharmony_ci if (filter_mask & RT5670_DA_STEREO_FILTER) { 8158c2ecf20Sopenharmony_ci asrc2_mask |= RT5670_DA_STO_CLK_SEL_MASK; 8168c2ecf20Sopenharmony_ci asrc2_value = (asrc2_value & ~RT5670_DA_STO_CLK_SEL_MASK) 8178c2ecf20Sopenharmony_ci | (clk_src << RT5670_DA_STO_CLK_SEL_SFT); 8188c2ecf20Sopenharmony_ci } 8198c2ecf20Sopenharmony_ci 8208c2ecf20Sopenharmony_ci if (filter_mask & RT5670_DA_MONO_L_FILTER) { 8218c2ecf20Sopenharmony_ci asrc2_mask |= RT5670_DA_MONOL_CLK_SEL_MASK; 8228c2ecf20Sopenharmony_ci asrc2_value = (asrc2_value & ~RT5670_DA_MONOL_CLK_SEL_MASK) 8238c2ecf20Sopenharmony_ci | (clk_src << RT5670_DA_MONOL_CLK_SEL_SFT); 8248c2ecf20Sopenharmony_ci } 8258c2ecf20Sopenharmony_ci 8268c2ecf20Sopenharmony_ci if (filter_mask & RT5670_DA_MONO_R_FILTER) { 8278c2ecf20Sopenharmony_ci asrc2_mask |= RT5670_DA_MONOR_CLK_SEL_MASK; 8288c2ecf20Sopenharmony_ci asrc2_value = (asrc2_value & ~RT5670_DA_MONOR_CLK_SEL_MASK) 8298c2ecf20Sopenharmony_ci | (clk_src << RT5670_DA_MONOR_CLK_SEL_SFT); 8308c2ecf20Sopenharmony_ci } 8318c2ecf20Sopenharmony_ci 8328c2ecf20Sopenharmony_ci if (filter_mask & RT5670_AD_STEREO_FILTER) { 8338c2ecf20Sopenharmony_ci asrc2_mask |= RT5670_AD_STO1_CLK_SEL_MASK; 8348c2ecf20Sopenharmony_ci asrc2_value = (asrc2_value & ~RT5670_AD_STO1_CLK_SEL_MASK) 8358c2ecf20Sopenharmony_ci | (clk_src << RT5670_AD_STO1_CLK_SEL_SFT); 8368c2ecf20Sopenharmony_ci } 8378c2ecf20Sopenharmony_ci 8388c2ecf20Sopenharmony_ci if (filter_mask & RT5670_AD_MONO_L_FILTER) { 8398c2ecf20Sopenharmony_ci asrc3_mask |= RT5670_AD_MONOL_CLK_SEL_MASK; 8408c2ecf20Sopenharmony_ci asrc3_value = (asrc3_value & ~RT5670_AD_MONOL_CLK_SEL_MASK) 8418c2ecf20Sopenharmony_ci | (clk_src << RT5670_AD_MONOL_CLK_SEL_SFT); 8428c2ecf20Sopenharmony_ci } 8438c2ecf20Sopenharmony_ci 8448c2ecf20Sopenharmony_ci if (filter_mask & RT5670_AD_MONO_R_FILTER) { 8458c2ecf20Sopenharmony_ci asrc3_mask |= RT5670_AD_MONOR_CLK_SEL_MASK; 8468c2ecf20Sopenharmony_ci asrc3_value = (asrc3_value & ~RT5670_AD_MONOR_CLK_SEL_MASK) 8478c2ecf20Sopenharmony_ci | (clk_src << RT5670_AD_MONOR_CLK_SEL_SFT); 8488c2ecf20Sopenharmony_ci } 8498c2ecf20Sopenharmony_ci 8508c2ecf20Sopenharmony_ci if (filter_mask & RT5670_UP_RATE_FILTER) { 8518c2ecf20Sopenharmony_ci asrc3_mask |= RT5670_UP_CLK_SEL_MASK; 8528c2ecf20Sopenharmony_ci asrc3_value = (asrc3_value & ~RT5670_UP_CLK_SEL_MASK) 8538c2ecf20Sopenharmony_ci | (clk_src << RT5670_UP_CLK_SEL_SFT); 8548c2ecf20Sopenharmony_ci } 8558c2ecf20Sopenharmony_ci 8568c2ecf20Sopenharmony_ci if (filter_mask & RT5670_DOWN_RATE_FILTER) { 8578c2ecf20Sopenharmony_ci asrc3_mask |= RT5670_DOWN_CLK_SEL_MASK; 8588c2ecf20Sopenharmony_ci asrc3_value = (asrc3_value & ~RT5670_DOWN_CLK_SEL_MASK) 8598c2ecf20Sopenharmony_ci | (clk_src << RT5670_DOWN_CLK_SEL_SFT); 8608c2ecf20Sopenharmony_ci } 8618c2ecf20Sopenharmony_ci 8628c2ecf20Sopenharmony_ci if (asrc2_mask) 8638c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, RT5670_ASRC_2, 8648c2ecf20Sopenharmony_ci asrc2_mask, asrc2_value); 8658c2ecf20Sopenharmony_ci 8668c2ecf20Sopenharmony_ci if (asrc3_mask) 8678c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, RT5670_ASRC_3, 8688c2ecf20Sopenharmony_ci asrc3_mask, asrc3_value); 8698c2ecf20Sopenharmony_ci return 0; 8708c2ecf20Sopenharmony_ci} 8718c2ecf20Sopenharmony_ciEXPORT_SYMBOL_GPL(rt5670_sel_asrc_clk_src); 8728c2ecf20Sopenharmony_ci 8738c2ecf20Sopenharmony_ci/* Digital Mixer */ 8748c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5670_sto1_adc_l_mix[] = { 8758c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("ADC1 Switch", RT5670_STO1_ADC_MIXER, 8768c2ecf20Sopenharmony_ci RT5670_M_ADC_L1_SFT, 1, 1), 8778c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("ADC2 Switch", RT5670_STO1_ADC_MIXER, 8788c2ecf20Sopenharmony_ci RT5670_M_ADC_L2_SFT, 1, 1), 8798c2ecf20Sopenharmony_ci}; 8808c2ecf20Sopenharmony_ci 8818c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5670_sto1_adc_r_mix[] = { 8828c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("ADC1 Switch", RT5670_STO1_ADC_MIXER, 8838c2ecf20Sopenharmony_ci RT5670_M_ADC_R1_SFT, 1, 1), 8848c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("ADC2 Switch", RT5670_STO1_ADC_MIXER, 8858c2ecf20Sopenharmony_ci RT5670_M_ADC_R2_SFT, 1, 1), 8868c2ecf20Sopenharmony_ci}; 8878c2ecf20Sopenharmony_ci 8888c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5670_sto2_adc_l_mix[] = { 8898c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("ADC1 Switch", RT5670_STO2_ADC_MIXER, 8908c2ecf20Sopenharmony_ci RT5670_M_ADC_L1_SFT, 1, 1), 8918c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("ADC2 Switch", RT5670_STO2_ADC_MIXER, 8928c2ecf20Sopenharmony_ci RT5670_M_ADC_L2_SFT, 1, 1), 8938c2ecf20Sopenharmony_ci}; 8948c2ecf20Sopenharmony_ci 8958c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5670_sto2_adc_r_mix[] = { 8968c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("ADC1 Switch", RT5670_STO2_ADC_MIXER, 8978c2ecf20Sopenharmony_ci RT5670_M_ADC_R1_SFT, 1, 1), 8988c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("ADC2 Switch", RT5670_STO2_ADC_MIXER, 8998c2ecf20Sopenharmony_ci RT5670_M_ADC_R2_SFT, 1, 1), 9008c2ecf20Sopenharmony_ci}; 9018c2ecf20Sopenharmony_ci 9028c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5670_mono_adc_l_mix[] = { 9038c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("ADC1 Switch", RT5670_MONO_ADC_MIXER, 9048c2ecf20Sopenharmony_ci RT5670_M_MONO_ADC_L1_SFT, 1, 1), 9058c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("ADC2 Switch", RT5670_MONO_ADC_MIXER, 9068c2ecf20Sopenharmony_ci RT5670_M_MONO_ADC_L2_SFT, 1, 1), 9078c2ecf20Sopenharmony_ci}; 9088c2ecf20Sopenharmony_ci 9098c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5670_mono_adc_r_mix[] = { 9108c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("ADC1 Switch", RT5670_MONO_ADC_MIXER, 9118c2ecf20Sopenharmony_ci RT5670_M_MONO_ADC_R1_SFT, 1, 1), 9128c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("ADC2 Switch", RT5670_MONO_ADC_MIXER, 9138c2ecf20Sopenharmony_ci RT5670_M_MONO_ADC_R2_SFT, 1, 1), 9148c2ecf20Sopenharmony_ci}; 9158c2ecf20Sopenharmony_ci 9168c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5670_dac_l_mix[] = { 9178c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("Stereo ADC Switch", RT5670_AD_DA_MIXER, 9188c2ecf20Sopenharmony_ci RT5670_M_ADCMIX_L_SFT, 1, 1), 9198c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("DAC1 Switch", RT5670_AD_DA_MIXER, 9208c2ecf20Sopenharmony_ci RT5670_M_DAC1_L_SFT, 1, 1), 9218c2ecf20Sopenharmony_ci}; 9228c2ecf20Sopenharmony_ci 9238c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5670_dac_r_mix[] = { 9248c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("Stereo ADC Switch", RT5670_AD_DA_MIXER, 9258c2ecf20Sopenharmony_ci RT5670_M_ADCMIX_R_SFT, 1, 1), 9268c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("DAC1 Switch", RT5670_AD_DA_MIXER, 9278c2ecf20Sopenharmony_ci RT5670_M_DAC1_R_SFT, 1, 1), 9288c2ecf20Sopenharmony_ci}; 9298c2ecf20Sopenharmony_ci 9308c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5670_sto_dac_l_mix[] = { 9318c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("DAC L1 Switch", RT5670_STO_DAC_MIXER, 9328c2ecf20Sopenharmony_ci RT5670_M_DAC_L1_SFT, 1, 1), 9338c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("DAC L2 Switch", RT5670_STO_DAC_MIXER, 9348c2ecf20Sopenharmony_ci RT5670_M_DAC_L2_SFT, 1, 1), 9358c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("DAC R1 Switch", RT5670_STO_DAC_MIXER, 9368c2ecf20Sopenharmony_ci RT5670_M_DAC_R1_STO_L_SFT, 1, 1), 9378c2ecf20Sopenharmony_ci}; 9388c2ecf20Sopenharmony_ci 9398c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5670_sto_dac_r_mix[] = { 9408c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("DAC R1 Switch", RT5670_STO_DAC_MIXER, 9418c2ecf20Sopenharmony_ci RT5670_M_DAC_R1_SFT, 1, 1), 9428c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("DAC R2 Switch", RT5670_STO_DAC_MIXER, 9438c2ecf20Sopenharmony_ci RT5670_M_DAC_R2_SFT, 1, 1), 9448c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("DAC L1 Switch", RT5670_STO_DAC_MIXER, 9458c2ecf20Sopenharmony_ci RT5670_M_DAC_L1_STO_R_SFT, 1, 1), 9468c2ecf20Sopenharmony_ci}; 9478c2ecf20Sopenharmony_ci 9488c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5670_mono_dac_l_mix[] = { 9498c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("DAC L1 Switch", RT5670_DD_MIXER, 9508c2ecf20Sopenharmony_ci RT5670_M_DAC_L1_MONO_L_SFT, 1, 1), 9518c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("DAC L2 Switch", RT5670_DD_MIXER, 9528c2ecf20Sopenharmony_ci RT5670_M_DAC_L2_MONO_L_SFT, 1, 1), 9538c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("DAC R2 Switch", RT5670_DD_MIXER, 9548c2ecf20Sopenharmony_ci RT5670_M_DAC_R2_MONO_L_SFT, 1, 1), 9558c2ecf20Sopenharmony_ci}; 9568c2ecf20Sopenharmony_ci 9578c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5670_mono_dac_r_mix[] = { 9588c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("DAC R1 Switch", RT5670_DD_MIXER, 9598c2ecf20Sopenharmony_ci RT5670_M_DAC_R1_MONO_R_SFT, 1, 1), 9608c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("DAC R2 Switch", RT5670_DD_MIXER, 9618c2ecf20Sopenharmony_ci RT5670_M_DAC_R2_MONO_R_SFT, 1, 1), 9628c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("DAC L2 Switch", RT5670_DD_MIXER, 9638c2ecf20Sopenharmony_ci RT5670_M_DAC_L2_MONO_R_SFT, 1, 1), 9648c2ecf20Sopenharmony_ci}; 9658c2ecf20Sopenharmony_ci 9668c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5670_dig_l_mix[] = { 9678c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("Sto DAC Mix L Switch", RT5670_DIG_MIXER, 9688c2ecf20Sopenharmony_ci RT5670_M_STO_L_DAC_L_SFT, 1, 1), 9698c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("DAC L2 Switch", RT5670_DIG_MIXER, 9708c2ecf20Sopenharmony_ci RT5670_M_DAC_L2_DAC_L_SFT, 1, 1), 9718c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("DAC R2 Switch", RT5670_DIG_MIXER, 9728c2ecf20Sopenharmony_ci RT5670_M_DAC_R2_DAC_L_SFT, 1, 1), 9738c2ecf20Sopenharmony_ci}; 9748c2ecf20Sopenharmony_ci 9758c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5670_dig_r_mix[] = { 9768c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("Sto DAC Mix R Switch", RT5670_DIG_MIXER, 9778c2ecf20Sopenharmony_ci RT5670_M_STO_R_DAC_R_SFT, 1, 1), 9788c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("DAC R2 Switch", RT5670_DIG_MIXER, 9798c2ecf20Sopenharmony_ci RT5670_M_DAC_R2_DAC_R_SFT, 1, 1), 9808c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("DAC L2 Switch", RT5670_DIG_MIXER, 9818c2ecf20Sopenharmony_ci RT5670_M_DAC_L2_DAC_R_SFT, 1, 1), 9828c2ecf20Sopenharmony_ci}; 9838c2ecf20Sopenharmony_ci 9848c2ecf20Sopenharmony_ci/* Analog Input Mixer */ 9858c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5670_rec_l_mix[] = { 9868c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("INL Switch", RT5670_REC_L2_MIXER, 9878c2ecf20Sopenharmony_ci RT5670_M_IN_L_RM_L_SFT, 1, 1), 9888c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("BST2 Switch", RT5670_REC_L2_MIXER, 9898c2ecf20Sopenharmony_ci RT5670_M_BST2_RM_L_SFT, 1, 1), 9908c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("BST1 Switch", RT5670_REC_L2_MIXER, 9918c2ecf20Sopenharmony_ci RT5670_M_BST1_RM_L_SFT, 1, 1), 9928c2ecf20Sopenharmony_ci}; 9938c2ecf20Sopenharmony_ci 9948c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5670_rec_r_mix[] = { 9958c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("INR Switch", RT5670_REC_R2_MIXER, 9968c2ecf20Sopenharmony_ci RT5670_M_IN_R_RM_R_SFT, 1, 1), 9978c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("BST2 Switch", RT5670_REC_R2_MIXER, 9988c2ecf20Sopenharmony_ci RT5670_M_BST2_RM_R_SFT, 1, 1), 9998c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("BST1 Switch", RT5670_REC_R2_MIXER, 10008c2ecf20Sopenharmony_ci RT5670_M_BST1_RM_R_SFT, 1, 1), 10018c2ecf20Sopenharmony_ci}; 10028c2ecf20Sopenharmony_ci 10038c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5670_out_l_mix[] = { 10048c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("BST1 Switch", RT5670_OUT_L1_MIXER, 10058c2ecf20Sopenharmony_ci RT5670_M_BST1_OM_L_SFT, 1, 1), 10068c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("INL Switch", RT5670_OUT_L1_MIXER, 10078c2ecf20Sopenharmony_ci RT5670_M_IN_L_OM_L_SFT, 1, 1), 10088c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("DAC L2 Switch", RT5670_OUT_L1_MIXER, 10098c2ecf20Sopenharmony_ci RT5670_M_DAC_L2_OM_L_SFT, 1, 1), 10108c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("DAC L1 Switch", RT5670_OUT_L1_MIXER, 10118c2ecf20Sopenharmony_ci RT5670_M_DAC_L1_OM_L_SFT, 1, 1), 10128c2ecf20Sopenharmony_ci}; 10138c2ecf20Sopenharmony_ci 10148c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5670_out_r_mix[] = { 10158c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("BST2 Switch", RT5670_OUT_R1_MIXER, 10168c2ecf20Sopenharmony_ci RT5670_M_BST2_OM_R_SFT, 1, 1), 10178c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("INR Switch", RT5670_OUT_R1_MIXER, 10188c2ecf20Sopenharmony_ci RT5670_M_IN_R_OM_R_SFT, 1, 1), 10198c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("DAC R2 Switch", RT5670_OUT_R1_MIXER, 10208c2ecf20Sopenharmony_ci RT5670_M_DAC_R2_OM_R_SFT, 1, 1), 10218c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("DAC R1 Switch", RT5670_OUT_R1_MIXER, 10228c2ecf20Sopenharmony_ci RT5670_M_DAC_R1_OM_R_SFT, 1, 1), 10238c2ecf20Sopenharmony_ci}; 10248c2ecf20Sopenharmony_ci 10258c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5670_hpo_mix[] = { 10268c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("DAC1 Switch", RT5670_HPO_MIXER, 10278c2ecf20Sopenharmony_ci RT5670_M_DAC1_HM_SFT, 1, 1), 10288c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("HPVOL Switch", RT5670_HPO_MIXER, 10298c2ecf20Sopenharmony_ci RT5670_M_HPVOL_HM_SFT, 1, 1), 10308c2ecf20Sopenharmony_ci}; 10318c2ecf20Sopenharmony_ci 10328c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5670_hpvoll_mix[] = { 10338c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("DAC1 Switch", RT5670_HPO_MIXER, 10348c2ecf20Sopenharmony_ci RT5670_M_DACL1_HML_SFT, 1, 1), 10358c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("INL Switch", RT5670_HPO_MIXER, 10368c2ecf20Sopenharmony_ci RT5670_M_INL1_HML_SFT, 1, 1), 10378c2ecf20Sopenharmony_ci}; 10388c2ecf20Sopenharmony_ci 10398c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5670_hpvolr_mix[] = { 10408c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("DAC1 Switch", RT5670_HPO_MIXER, 10418c2ecf20Sopenharmony_ci RT5670_M_DACR1_HMR_SFT, 1, 1), 10428c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("INR Switch", RT5670_HPO_MIXER, 10438c2ecf20Sopenharmony_ci RT5670_M_INR1_HMR_SFT, 1, 1), 10448c2ecf20Sopenharmony_ci}; 10458c2ecf20Sopenharmony_ci 10468c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5670_lout_mix[] = { 10478c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("DAC L1 Switch", RT5670_LOUT_MIXER, 10488c2ecf20Sopenharmony_ci RT5670_M_DAC_L1_LM_SFT, 1, 1), 10498c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("DAC R1 Switch", RT5670_LOUT_MIXER, 10508c2ecf20Sopenharmony_ci RT5670_M_DAC_R1_LM_SFT, 1, 1), 10518c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("OUTMIX L Switch", RT5670_LOUT_MIXER, 10528c2ecf20Sopenharmony_ci RT5670_M_OV_L_LM_SFT, 1, 1), 10538c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE("OUTMIX R Switch", RT5670_LOUT_MIXER, 10548c2ecf20Sopenharmony_ci RT5670_M_OV_R_LM_SFT, 1, 1), 10558c2ecf20Sopenharmony_ci}; 10568c2ecf20Sopenharmony_ci 10578c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new lout_l_enable_control = 10588c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("Switch", RT5670_LOUT1, 10598c2ecf20Sopenharmony_ci RT5670_L_MUTE_SFT, 1, 1); 10608c2ecf20Sopenharmony_ci 10618c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new lout_r_enable_control = 10628c2ecf20Sopenharmony_ci SOC_DAPM_SINGLE_AUTODISABLE("Switch", RT5670_LOUT1, 10638c2ecf20Sopenharmony_ci RT5670_R_MUTE_SFT, 1, 1); 10648c2ecf20Sopenharmony_ci 10658c2ecf20Sopenharmony_ci/* DAC1 L/R source */ /* MX-29 [9:8] [11:10] */ 10668c2ecf20Sopenharmony_cistatic const char * const rt5670_dac1_src[] = { 10678c2ecf20Sopenharmony_ci "IF1 DAC", "IF2 DAC" 10688c2ecf20Sopenharmony_ci}; 10698c2ecf20Sopenharmony_ci 10708c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(rt5670_dac1l_enum, RT5670_AD_DA_MIXER, 10718c2ecf20Sopenharmony_ci RT5670_DAC1_L_SEL_SFT, rt5670_dac1_src); 10728c2ecf20Sopenharmony_ci 10738c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5670_dac1l_mux = 10748c2ecf20Sopenharmony_ci SOC_DAPM_ENUM("DAC1 L source", rt5670_dac1l_enum); 10758c2ecf20Sopenharmony_ci 10768c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(rt5670_dac1r_enum, RT5670_AD_DA_MIXER, 10778c2ecf20Sopenharmony_ci RT5670_DAC1_R_SEL_SFT, rt5670_dac1_src); 10788c2ecf20Sopenharmony_ci 10798c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5670_dac1r_mux = 10808c2ecf20Sopenharmony_ci SOC_DAPM_ENUM("DAC1 R source", rt5670_dac1r_enum); 10818c2ecf20Sopenharmony_ci 10828c2ecf20Sopenharmony_ci/*DAC2 L/R source*/ /* MX-1B [6:4] [2:0] */ 10838c2ecf20Sopenharmony_ci/* TODO Use SOC_VALUE_ENUM_SINGLE_DECL */ 10848c2ecf20Sopenharmony_cistatic const char * const rt5670_dac12_src[] = { 10858c2ecf20Sopenharmony_ci "IF1 DAC", "IF2 DAC", "IF3 DAC", "TxDC DAC", 10868c2ecf20Sopenharmony_ci "Bass", "VAD_ADC", "IF4 DAC" 10878c2ecf20Sopenharmony_ci}; 10888c2ecf20Sopenharmony_ci 10898c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(rt5670_dac2l_enum, RT5670_DAC_CTRL, 10908c2ecf20Sopenharmony_ci RT5670_DAC2_L_SEL_SFT, rt5670_dac12_src); 10918c2ecf20Sopenharmony_ci 10928c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5670_dac_l2_mux = 10938c2ecf20Sopenharmony_ci SOC_DAPM_ENUM("DAC2 L source", rt5670_dac2l_enum); 10948c2ecf20Sopenharmony_ci 10958c2ecf20Sopenharmony_cistatic const char * const rt5670_dacr2_src[] = { 10968c2ecf20Sopenharmony_ci "IF1 DAC", "IF2 DAC", "IF3 DAC", "TxDC DAC", "TxDP ADC", "IF4 DAC" 10978c2ecf20Sopenharmony_ci}; 10988c2ecf20Sopenharmony_ci 10998c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(rt5670_dac2r_enum, RT5670_DAC_CTRL, 11008c2ecf20Sopenharmony_ci RT5670_DAC2_R_SEL_SFT, rt5670_dacr2_src); 11018c2ecf20Sopenharmony_ci 11028c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5670_dac_r2_mux = 11038c2ecf20Sopenharmony_ci SOC_DAPM_ENUM("DAC2 R source", rt5670_dac2r_enum); 11048c2ecf20Sopenharmony_ci 11058c2ecf20Sopenharmony_ci/*RxDP source*/ /* MX-2D [15:13] */ 11068c2ecf20Sopenharmony_cistatic const char * const rt5670_rxdp_src[] = { 11078c2ecf20Sopenharmony_ci "IF2 DAC", "IF1 DAC", "STO1 ADC Mixer", "STO2 ADC Mixer", 11088c2ecf20Sopenharmony_ci "Mono ADC Mixer L", "Mono ADC Mixer R", "DAC1" 11098c2ecf20Sopenharmony_ci}; 11108c2ecf20Sopenharmony_ci 11118c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(rt5670_rxdp_enum, RT5670_DSP_PATH1, 11128c2ecf20Sopenharmony_ci RT5670_RXDP_SEL_SFT, rt5670_rxdp_src); 11138c2ecf20Sopenharmony_ci 11148c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5670_rxdp_mux = 11158c2ecf20Sopenharmony_ci SOC_DAPM_ENUM("DAC2 L source", rt5670_rxdp_enum); 11168c2ecf20Sopenharmony_ci 11178c2ecf20Sopenharmony_ci/* MX-2D [1] [0] */ 11188c2ecf20Sopenharmony_cistatic const char * const rt5670_dsp_bypass_src[] = { 11198c2ecf20Sopenharmony_ci "DSP", "Bypass" 11208c2ecf20Sopenharmony_ci}; 11218c2ecf20Sopenharmony_ci 11228c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(rt5670_dsp_ul_enum, RT5670_DSP_PATH1, 11238c2ecf20Sopenharmony_ci RT5670_DSP_UL_SFT, rt5670_dsp_bypass_src); 11248c2ecf20Sopenharmony_ci 11258c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5670_dsp_ul_mux = 11268c2ecf20Sopenharmony_ci SOC_DAPM_ENUM("DSP UL source", rt5670_dsp_ul_enum); 11278c2ecf20Sopenharmony_ci 11288c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(rt5670_dsp_dl_enum, RT5670_DSP_PATH1, 11298c2ecf20Sopenharmony_ci RT5670_DSP_DL_SFT, rt5670_dsp_bypass_src); 11308c2ecf20Sopenharmony_ci 11318c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5670_dsp_dl_mux = 11328c2ecf20Sopenharmony_ci SOC_DAPM_ENUM("DSP DL source", rt5670_dsp_dl_enum); 11338c2ecf20Sopenharmony_ci 11348c2ecf20Sopenharmony_ci/* Stereo2 ADC source */ 11358c2ecf20Sopenharmony_ci/* MX-26 [15] */ 11368c2ecf20Sopenharmony_cistatic const char * const rt5670_stereo2_adc_lr_src[] = { 11378c2ecf20Sopenharmony_ci "L", "LR" 11388c2ecf20Sopenharmony_ci}; 11398c2ecf20Sopenharmony_ci 11408c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(rt5670_stereo2_adc_lr_enum, RT5670_STO2_ADC_MIXER, 11418c2ecf20Sopenharmony_ci RT5670_STO2_ADC_SRC_SFT, rt5670_stereo2_adc_lr_src); 11428c2ecf20Sopenharmony_ci 11438c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5670_sto2_adc_lr_mux = 11448c2ecf20Sopenharmony_ci SOC_DAPM_ENUM("Stereo2 ADC LR source", rt5670_stereo2_adc_lr_enum); 11458c2ecf20Sopenharmony_ci 11468c2ecf20Sopenharmony_ci/* Stereo1 ADC source */ 11478c2ecf20Sopenharmony_ci/* MX-27 MX-26 [12] */ 11488c2ecf20Sopenharmony_cistatic const char * const rt5670_stereo_adc1_src[] = { 11498c2ecf20Sopenharmony_ci "DAC MIX", "ADC" 11508c2ecf20Sopenharmony_ci}; 11518c2ecf20Sopenharmony_ci 11528c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(rt5670_stereo1_adc1_enum, RT5670_STO1_ADC_MIXER, 11538c2ecf20Sopenharmony_ci RT5670_ADC_1_SRC_SFT, rt5670_stereo_adc1_src); 11548c2ecf20Sopenharmony_ci 11558c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5670_sto_adc_1_mux = 11568c2ecf20Sopenharmony_ci SOC_DAPM_ENUM("Stereo1 ADC 1 Mux", rt5670_stereo1_adc1_enum); 11578c2ecf20Sopenharmony_ci 11588c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(rt5670_stereo2_adc1_enum, RT5670_STO2_ADC_MIXER, 11598c2ecf20Sopenharmony_ci RT5670_ADC_1_SRC_SFT, rt5670_stereo_adc1_src); 11608c2ecf20Sopenharmony_ci 11618c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5670_sto2_adc_1_mux = 11628c2ecf20Sopenharmony_ci SOC_DAPM_ENUM("Stereo2 ADC 1 Mux", rt5670_stereo2_adc1_enum); 11638c2ecf20Sopenharmony_ci 11648c2ecf20Sopenharmony_ci 11658c2ecf20Sopenharmony_ci/* MX-27 MX-26 [11] */ 11668c2ecf20Sopenharmony_cistatic const char * const rt5670_stereo_adc2_src[] = { 11678c2ecf20Sopenharmony_ci "DAC MIX", "DMIC" 11688c2ecf20Sopenharmony_ci}; 11698c2ecf20Sopenharmony_ci 11708c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(rt5670_stereo1_adc2_enum, RT5670_STO1_ADC_MIXER, 11718c2ecf20Sopenharmony_ci RT5670_ADC_2_SRC_SFT, rt5670_stereo_adc2_src); 11728c2ecf20Sopenharmony_ci 11738c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5670_sto_adc_2_mux = 11748c2ecf20Sopenharmony_ci SOC_DAPM_ENUM("Stereo1 ADC 2 Mux", rt5670_stereo1_adc2_enum); 11758c2ecf20Sopenharmony_ci 11768c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(rt5670_stereo2_adc2_enum, RT5670_STO2_ADC_MIXER, 11778c2ecf20Sopenharmony_ci RT5670_ADC_2_SRC_SFT, rt5670_stereo_adc2_src); 11788c2ecf20Sopenharmony_ci 11798c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5670_sto2_adc_2_mux = 11808c2ecf20Sopenharmony_ci SOC_DAPM_ENUM("Stereo2 ADC 2 Mux", rt5670_stereo2_adc2_enum); 11818c2ecf20Sopenharmony_ci 11828c2ecf20Sopenharmony_ci/* MX-27 MX-26 [9:8] */ 11838c2ecf20Sopenharmony_cistatic const char * const rt5670_stereo_dmic_src[] = { 11848c2ecf20Sopenharmony_ci "DMIC1", "DMIC2", "DMIC3" 11858c2ecf20Sopenharmony_ci}; 11868c2ecf20Sopenharmony_ci 11878c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(rt5670_stereo1_dmic_enum, RT5670_STO1_ADC_MIXER, 11888c2ecf20Sopenharmony_ci RT5670_DMIC_SRC_SFT, rt5670_stereo_dmic_src); 11898c2ecf20Sopenharmony_ci 11908c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5670_sto1_dmic_mux = 11918c2ecf20Sopenharmony_ci SOC_DAPM_ENUM("Stereo1 DMIC source", rt5670_stereo1_dmic_enum); 11928c2ecf20Sopenharmony_ci 11938c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(rt5670_stereo2_dmic_enum, RT5670_STO2_ADC_MIXER, 11948c2ecf20Sopenharmony_ci RT5670_DMIC_SRC_SFT, rt5670_stereo_dmic_src); 11958c2ecf20Sopenharmony_ci 11968c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5670_sto2_dmic_mux = 11978c2ecf20Sopenharmony_ci SOC_DAPM_ENUM("Stereo2 DMIC source", rt5670_stereo2_dmic_enum); 11988c2ecf20Sopenharmony_ci 11998c2ecf20Sopenharmony_ci/* Mono ADC source */ 12008c2ecf20Sopenharmony_ci/* MX-28 [12] */ 12018c2ecf20Sopenharmony_cistatic const char * const rt5670_mono_adc_l1_src[] = { 12028c2ecf20Sopenharmony_ci "Mono DAC MIXL", "ADC1" 12038c2ecf20Sopenharmony_ci}; 12048c2ecf20Sopenharmony_ci 12058c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(rt5670_mono_adc_l1_enum, RT5670_MONO_ADC_MIXER, 12068c2ecf20Sopenharmony_ci RT5670_MONO_ADC_L1_SRC_SFT, rt5670_mono_adc_l1_src); 12078c2ecf20Sopenharmony_ci 12088c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5670_mono_adc_l1_mux = 12098c2ecf20Sopenharmony_ci SOC_DAPM_ENUM("Mono ADC1 left source", rt5670_mono_adc_l1_enum); 12108c2ecf20Sopenharmony_ci/* MX-28 [11] */ 12118c2ecf20Sopenharmony_cistatic const char * const rt5670_mono_adc_l2_src[] = { 12128c2ecf20Sopenharmony_ci "Mono DAC MIXL", "DMIC" 12138c2ecf20Sopenharmony_ci}; 12148c2ecf20Sopenharmony_ci 12158c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(rt5670_mono_adc_l2_enum, RT5670_MONO_ADC_MIXER, 12168c2ecf20Sopenharmony_ci RT5670_MONO_ADC_L2_SRC_SFT, rt5670_mono_adc_l2_src); 12178c2ecf20Sopenharmony_ci 12188c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5670_mono_adc_l2_mux = 12198c2ecf20Sopenharmony_ci SOC_DAPM_ENUM("Mono ADC2 left source", rt5670_mono_adc_l2_enum); 12208c2ecf20Sopenharmony_ci 12218c2ecf20Sopenharmony_ci/* MX-28 [9:8] */ 12228c2ecf20Sopenharmony_cistatic const char * const rt5670_mono_dmic_src[] = { 12238c2ecf20Sopenharmony_ci "DMIC1", "DMIC2", "DMIC3" 12248c2ecf20Sopenharmony_ci}; 12258c2ecf20Sopenharmony_ci 12268c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(rt5670_mono_dmic_l_enum, RT5670_MONO_ADC_MIXER, 12278c2ecf20Sopenharmony_ci RT5670_MONO_DMIC_L_SRC_SFT, rt5670_mono_dmic_src); 12288c2ecf20Sopenharmony_ci 12298c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5670_mono_dmic_l_mux = 12308c2ecf20Sopenharmony_ci SOC_DAPM_ENUM("Mono DMIC left source", rt5670_mono_dmic_l_enum); 12318c2ecf20Sopenharmony_ci/* MX-28 [1:0] */ 12328c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(rt5670_mono_dmic_r_enum, RT5670_MONO_ADC_MIXER, 12338c2ecf20Sopenharmony_ci RT5670_MONO_DMIC_R_SRC_SFT, rt5670_mono_dmic_src); 12348c2ecf20Sopenharmony_ci 12358c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5670_mono_dmic_r_mux = 12368c2ecf20Sopenharmony_ci SOC_DAPM_ENUM("Mono DMIC Right source", rt5670_mono_dmic_r_enum); 12378c2ecf20Sopenharmony_ci/* MX-28 [4] */ 12388c2ecf20Sopenharmony_cistatic const char * const rt5670_mono_adc_r1_src[] = { 12398c2ecf20Sopenharmony_ci "Mono DAC MIXR", "ADC2" 12408c2ecf20Sopenharmony_ci}; 12418c2ecf20Sopenharmony_ci 12428c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(rt5670_mono_adc_r1_enum, RT5670_MONO_ADC_MIXER, 12438c2ecf20Sopenharmony_ci RT5670_MONO_ADC_R1_SRC_SFT, rt5670_mono_adc_r1_src); 12448c2ecf20Sopenharmony_ci 12458c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5670_mono_adc_r1_mux = 12468c2ecf20Sopenharmony_ci SOC_DAPM_ENUM("Mono ADC1 right source", rt5670_mono_adc_r1_enum); 12478c2ecf20Sopenharmony_ci/* MX-28 [3] */ 12488c2ecf20Sopenharmony_cistatic const char * const rt5670_mono_adc_r2_src[] = { 12498c2ecf20Sopenharmony_ci "Mono DAC MIXR", "DMIC" 12508c2ecf20Sopenharmony_ci}; 12518c2ecf20Sopenharmony_ci 12528c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(rt5670_mono_adc_r2_enum, RT5670_MONO_ADC_MIXER, 12538c2ecf20Sopenharmony_ci RT5670_MONO_ADC_R2_SRC_SFT, rt5670_mono_adc_r2_src); 12548c2ecf20Sopenharmony_ci 12558c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5670_mono_adc_r2_mux = 12568c2ecf20Sopenharmony_ci SOC_DAPM_ENUM("Mono ADC2 right source", rt5670_mono_adc_r2_enum); 12578c2ecf20Sopenharmony_ci 12588c2ecf20Sopenharmony_ci/* MX-2D [3:2] */ 12598c2ecf20Sopenharmony_cistatic const char * const rt5670_txdp_slot_src[] = { 12608c2ecf20Sopenharmony_ci "Slot 0-1", "Slot 2-3", "Slot 4-5", "Slot 6-7" 12618c2ecf20Sopenharmony_ci}; 12628c2ecf20Sopenharmony_ci 12638c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(rt5670_txdp_slot_enum, RT5670_DSP_PATH1, 12648c2ecf20Sopenharmony_ci RT5670_TXDP_SLOT_SEL_SFT, rt5670_txdp_slot_src); 12658c2ecf20Sopenharmony_ci 12668c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5670_txdp_slot_mux = 12678c2ecf20Sopenharmony_ci SOC_DAPM_ENUM("TxDP Slot source", rt5670_txdp_slot_enum); 12688c2ecf20Sopenharmony_ci 12698c2ecf20Sopenharmony_ci/* MX-2F [15] */ 12708c2ecf20Sopenharmony_cistatic const char * const rt5670_if1_adc2_in_src[] = { 12718c2ecf20Sopenharmony_ci "IF_ADC2", "VAD_ADC" 12728c2ecf20Sopenharmony_ci}; 12738c2ecf20Sopenharmony_ci 12748c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(rt5670_if1_adc2_in_enum, RT5670_DIG_INF1_DATA, 12758c2ecf20Sopenharmony_ci RT5670_IF1_ADC2_IN_SFT, rt5670_if1_adc2_in_src); 12768c2ecf20Sopenharmony_ci 12778c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5670_if1_adc2_in_mux = 12788c2ecf20Sopenharmony_ci SOC_DAPM_ENUM("IF1 ADC2 IN source", rt5670_if1_adc2_in_enum); 12798c2ecf20Sopenharmony_ci 12808c2ecf20Sopenharmony_ci/* MX-2F [14:12] */ 12818c2ecf20Sopenharmony_cistatic const char * const rt5670_if2_adc_in_src[] = { 12828c2ecf20Sopenharmony_ci "IF_ADC1", "IF_ADC2", "IF_ADC3", "TxDC_DAC", "TxDP_ADC", "VAD_ADC" 12838c2ecf20Sopenharmony_ci}; 12848c2ecf20Sopenharmony_ci 12858c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(rt5670_if2_adc_in_enum, RT5670_DIG_INF1_DATA, 12868c2ecf20Sopenharmony_ci RT5670_IF2_ADC_IN_SFT, rt5670_if2_adc_in_src); 12878c2ecf20Sopenharmony_ci 12888c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5670_if2_adc_in_mux = 12898c2ecf20Sopenharmony_ci SOC_DAPM_ENUM("IF2 ADC IN source", rt5670_if2_adc_in_enum); 12908c2ecf20Sopenharmony_ci 12918c2ecf20Sopenharmony_ci/* MX-31 [15] [13] [11] [9] */ 12928c2ecf20Sopenharmony_cistatic const char * const rt5670_pdm_src[] = { 12938c2ecf20Sopenharmony_ci "Mono DAC", "Stereo DAC" 12948c2ecf20Sopenharmony_ci}; 12958c2ecf20Sopenharmony_ci 12968c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(rt5670_pdm1_l_enum, RT5670_PDM_OUT_CTRL, 12978c2ecf20Sopenharmony_ci RT5670_PDM1_L_SFT, rt5670_pdm_src); 12988c2ecf20Sopenharmony_ci 12998c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5670_pdm1_l_mux = 13008c2ecf20Sopenharmony_ci SOC_DAPM_ENUM("PDM1 L source", rt5670_pdm1_l_enum); 13018c2ecf20Sopenharmony_ci 13028c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(rt5670_pdm1_r_enum, RT5670_PDM_OUT_CTRL, 13038c2ecf20Sopenharmony_ci RT5670_PDM1_R_SFT, rt5670_pdm_src); 13048c2ecf20Sopenharmony_ci 13058c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5670_pdm1_r_mux = 13068c2ecf20Sopenharmony_ci SOC_DAPM_ENUM("PDM1 R source", rt5670_pdm1_r_enum); 13078c2ecf20Sopenharmony_ci 13088c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(rt5670_pdm2_l_enum, RT5670_PDM_OUT_CTRL, 13098c2ecf20Sopenharmony_ci RT5670_PDM2_L_SFT, rt5670_pdm_src); 13108c2ecf20Sopenharmony_ci 13118c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5670_pdm2_l_mux = 13128c2ecf20Sopenharmony_ci SOC_DAPM_ENUM("PDM2 L source", rt5670_pdm2_l_enum); 13138c2ecf20Sopenharmony_ci 13148c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(rt5670_pdm2_r_enum, RT5670_PDM_OUT_CTRL, 13158c2ecf20Sopenharmony_ci RT5670_PDM2_R_SFT, rt5670_pdm_src); 13168c2ecf20Sopenharmony_ci 13178c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5670_pdm2_r_mux = 13188c2ecf20Sopenharmony_ci SOC_DAPM_ENUM("PDM2 R source", rt5670_pdm2_r_enum); 13198c2ecf20Sopenharmony_ci 13208c2ecf20Sopenharmony_ci/* MX-FA [12] */ 13218c2ecf20Sopenharmony_cistatic const char * const rt5670_if1_adc1_in1_src[] = { 13228c2ecf20Sopenharmony_ci "IF_ADC1", "IF1_ADC3" 13238c2ecf20Sopenharmony_ci}; 13248c2ecf20Sopenharmony_ci 13258c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(rt5670_if1_adc1_in1_enum, RT5670_DIG_MISC, 13268c2ecf20Sopenharmony_ci RT5670_IF1_ADC1_IN1_SFT, rt5670_if1_adc1_in1_src); 13278c2ecf20Sopenharmony_ci 13288c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5670_if1_adc1_in1_mux = 13298c2ecf20Sopenharmony_ci SOC_DAPM_ENUM("IF1 ADC1 IN1 source", rt5670_if1_adc1_in1_enum); 13308c2ecf20Sopenharmony_ci 13318c2ecf20Sopenharmony_ci/* MX-FA [11] */ 13328c2ecf20Sopenharmony_cistatic const char * const rt5670_if1_adc1_in2_src[] = { 13338c2ecf20Sopenharmony_ci "IF1_ADC1_IN1", "IF1_ADC4" 13348c2ecf20Sopenharmony_ci}; 13358c2ecf20Sopenharmony_ci 13368c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(rt5670_if1_adc1_in2_enum, RT5670_DIG_MISC, 13378c2ecf20Sopenharmony_ci RT5670_IF1_ADC1_IN2_SFT, rt5670_if1_adc1_in2_src); 13388c2ecf20Sopenharmony_ci 13398c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5670_if1_adc1_in2_mux = 13408c2ecf20Sopenharmony_ci SOC_DAPM_ENUM("IF1 ADC1 IN2 source", rt5670_if1_adc1_in2_enum); 13418c2ecf20Sopenharmony_ci 13428c2ecf20Sopenharmony_ci/* MX-FA [10] */ 13438c2ecf20Sopenharmony_cistatic const char * const rt5670_if1_adc2_in1_src[] = { 13448c2ecf20Sopenharmony_ci "IF1_ADC2_IN", "IF1_ADC4" 13458c2ecf20Sopenharmony_ci}; 13468c2ecf20Sopenharmony_ci 13478c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(rt5670_if1_adc2_in1_enum, RT5670_DIG_MISC, 13488c2ecf20Sopenharmony_ci RT5670_IF1_ADC2_IN1_SFT, rt5670_if1_adc2_in1_src); 13498c2ecf20Sopenharmony_ci 13508c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5670_if1_adc2_in1_mux = 13518c2ecf20Sopenharmony_ci SOC_DAPM_ENUM("IF1 ADC2 IN1 source", rt5670_if1_adc2_in1_enum); 13528c2ecf20Sopenharmony_ci 13538c2ecf20Sopenharmony_ci/* MX-9D [9:8] */ 13548c2ecf20Sopenharmony_cistatic const char * const rt5670_vad_adc_src[] = { 13558c2ecf20Sopenharmony_ci "Sto1 ADC L", "Mono ADC L", "Mono ADC R", "Sto2 ADC L" 13568c2ecf20Sopenharmony_ci}; 13578c2ecf20Sopenharmony_ci 13588c2ecf20Sopenharmony_cistatic SOC_ENUM_SINGLE_DECL(rt5670_vad_adc_enum, RT5670_VAD_CTRL4, 13598c2ecf20Sopenharmony_ci RT5670_VAD_SEL_SFT, rt5670_vad_adc_src); 13608c2ecf20Sopenharmony_ci 13618c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new rt5670_vad_adc_mux = 13628c2ecf20Sopenharmony_ci SOC_DAPM_ENUM("VAD ADC source", rt5670_vad_adc_enum); 13638c2ecf20Sopenharmony_ci 13648c2ecf20Sopenharmony_cistatic int rt5670_hp_power_event(struct snd_soc_dapm_widget *w, 13658c2ecf20Sopenharmony_ci struct snd_kcontrol *kcontrol, int event) 13668c2ecf20Sopenharmony_ci{ 13678c2ecf20Sopenharmony_ci struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); 13688c2ecf20Sopenharmony_ci struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); 13698c2ecf20Sopenharmony_ci 13708c2ecf20Sopenharmony_ci switch (event) { 13718c2ecf20Sopenharmony_ci case SND_SOC_DAPM_POST_PMU: 13728c2ecf20Sopenharmony_ci regmap_update_bits(rt5670->regmap, RT5670_CHARGE_PUMP, 13738c2ecf20Sopenharmony_ci RT5670_PM_HP_MASK, RT5670_PM_HP_HV); 13748c2ecf20Sopenharmony_ci regmap_update_bits(rt5670->regmap, RT5670_GEN_CTRL2, 13758c2ecf20Sopenharmony_ci 0x0400, 0x0400); 13768c2ecf20Sopenharmony_ci /* headphone amp power on */ 13778c2ecf20Sopenharmony_ci regmap_update_bits(rt5670->regmap, RT5670_PWR_ANLG1, 13788c2ecf20Sopenharmony_ci RT5670_PWR_HA | RT5670_PWR_FV1 | 13798c2ecf20Sopenharmony_ci RT5670_PWR_FV2, RT5670_PWR_HA | 13808c2ecf20Sopenharmony_ci RT5670_PWR_FV1 | RT5670_PWR_FV2); 13818c2ecf20Sopenharmony_ci /* depop parameters */ 13828c2ecf20Sopenharmony_ci regmap_write(rt5670->regmap, RT5670_DEPOP_M2, 0x3100); 13838c2ecf20Sopenharmony_ci regmap_write(rt5670->regmap, RT5670_DEPOP_M1, 0x8009); 13848c2ecf20Sopenharmony_ci regmap_write(rt5670->regmap, RT5670_PR_BASE + 13858c2ecf20Sopenharmony_ci RT5670_HP_DCC_INT1, 0x9f00); 13868c2ecf20Sopenharmony_ci mdelay(20); 13878c2ecf20Sopenharmony_ci regmap_write(rt5670->regmap, RT5670_DEPOP_M1, 0x8019); 13888c2ecf20Sopenharmony_ci break; 13898c2ecf20Sopenharmony_ci case SND_SOC_DAPM_PRE_PMD: 13908c2ecf20Sopenharmony_ci regmap_write(rt5670->regmap, RT5670_DEPOP_M1, 0x0004); 13918c2ecf20Sopenharmony_ci msleep(30); 13928c2ecf20Sopenharmony_ci break; 13938c2ecf20Sopenharmony_ci default: 13948c2ecf20Sopenharmony_ci return 0; 13958c2ecf20Sopenharmony_ci } 13968c2ecf20Sopenharmony_ci 13978c2ecf20Sopenharmony_ci return 0; 13988c2ecf20Sopenharmony_ci} 13998c2ecf20Sopenharmony_ci 14008c2ecf20Sopenharmony_cistatic int rt5670_hp_event(struct snd_soc_dapm_widget *w, 14018c2ecf20Sopenharmony_ci struct snd_kcontrol *kcontrol, int event) 14028c2ecf20Sopenharmony_ci{ 14038c2ecf20Sopenharmony_ci struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); 14048c2ecf20Sopenharmony_ci struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); 14058c2ecf20Sopenharmony_ci 14068c2ecf20Sopenharmony_ci switch (event) { 14078c2ecf20Sopenharmony_ci case SND_SOC_DAPM_POST_PMU: 14088c2ecf20Sopenharmony_ci /* headphone unmute sequence */ 14098c2ecf20Sopenharmony_ci regmap_write(rt5670->regmap, RT5670_PR_BASE + 14108c2ecf20Sopenharmony_ci RT5670_MAMP_INT_REG2, 0xb400); 14118c2ecf20Sopenharmony_ci regmap_write(rt5670->regmap, RT5670_DEPOP_M3, 0x0772); 14128c2ecf20Sopenharmony_ci regmap_write(rt5670->regmap, RT5670_DEPOP_M1, 0x805d); 14138c2ecf20Sopenharmony_ci regmap_write(rt5670->regmap, RT5670_DEPOP_M1, 0x831d); 14148c2ecf20Sopenharmony_ci regmap_update_bits(rt5670->regmap, RT5670_GEN_CTRL2, 14158c2ecf20Sopenharmony_ci 0x0300, 0x0300); 14168c2ecf20Sopenharmony_ci regmap_update_bits(rt5670->regmap, RT5670_HP_VOL, 14178c2ecf20Sopenharmony_ci RT5670_L_MUTE | RT5670_R_MUTE, 0); 14188c2ecf20Sopenharmony_ci msleep(80); 14198c2ecf20Sopenharmony_ci regmap_write(rt5670->regmap, RT5670_DEPOP_M1, 0x8019); 14208c2ecf20Sopenharmony_ci break; 14218c2ecf20Sopenharmony_ci 14228c2ecf20Sopenharmony_ci case SND_SOC_DAPM_PRE_PMD: 14238c2ecf20Sopenharmony_ci /* headphone mute sequence */ 14248c2ecf20Sopenharmony_ci regmap_write(rt5670->regmap, RT5670_PR_BASE + 14258c2ecf20Sopenharmony_ci RT5670_MAMP_INT_REG2, 0xb400); 14268c2ecf20Sopenharmony_ci regmap_write(rt5670->regmap, RT5670_DEPOP_M3, 0x0772); 14278c2ecf20Sopenharmony_ci regmap_write(rt5670->regmap, RT5670_DEPOP_M1, 0x803d); 14288c2ecf20Sopenharmony_ci mdelay(10); 14298c2ecf20Sopenharmony_ci regmap_write(rt5670->regmap, RT5670_DEPOP_M1, 0x831d); 14308c2ecf20Sopenharmony_ci mdelay(10); 14318c2ecf20Sopenharmony_ci regmap_update_bits(rt5670->regmap, RT5670_HP_VOL, 14328c2ecf20Sopenharmony_ci RT5670_L_MUTE | RT5670_R_MUTE, 14338c2ecf20Sopenharmony_ci RT5670_L_MUTE | RT5670_R_MUTE); 14348c2ecf20Sopenharmony_ci msleep(20); 14358c2ecf20Sopenharmony_ci regmap_update_bits(rt5670->regmap, 14368c2ecf20Sopenharmony_ci RT5670_GEN_CTRL2, 0x0300, 0x0); 14378c2ecf20Sopenharmony_ci regmap_write(rt5670->regmap, RT5670_DEPOP_M1, 0x8019); 14388c2ecf20Sopenharmony_ci regmap_write(rt5670->regmap, RT5670_DEPOP_M3, 0x0707); 14398c2ecf20Sopenharmony_ci regmap_write(rt5670->regmap, RT5670_PR_BASE + 14408c2ecf20Sopenharmony_ci RT5670_MAMP_INT_REG2, 0xfc00); 14418c2ecf20Sopenharmony_ci break; 14428c2ecf20Sopenharmony_ci 14438c2ecf20Sopenharmony_ci default: 14448c2ecf20Sopenharmony_ci return 0; 14458c2ecf20Sopenharmony_ci } 14468c2ecf20Sopenharmony_ci 14478c2ecf20Sopenharmony_ci return 0; 14488c2ecf20Sopenharmony_ci} 14498c2ecf20Sopenharmony_ci 14508c2ecf20Sopenharmony_cistatic int rt5670_spk_event(struct snd_soc_dapm_widget *w, 14518c2ecf20Sopenharmony_ci struct snd_kcontrol *kcontrol, int event) 14528c2ecf20Sopenharmony_ci{ 14538c2ecf20Sopenharmony_ci struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); 14548c2ecf20Sopenharmony_ci struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); 14558c2ecf20Sopenharmony_ci 14568c2ecf20Sopenharmony_ci if (!rt5670->gpio1_is_ext_spk_en) 14578c2ecf20Sopenharmony_ci return 0; 14588c2ecf20Sopenharmony_ci 14598c2ecf20Sopenharmony_ci switch (event) { 14608c2ecf20Sopenharmony_ci case SND_SOC_DAPM_POST_PMU: 14618c2ecf20Sopenharmony_ci regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL2, 14628c2ecf20Sopenharmony_ci RT5670_GP1_OUT_MASK, RT5670_GP1_OUT_HI); 14638c2ecf20Sopenharmony_ci break; 14648c2ecf20Sopenharmony_ci 14658c2ecf20Sopenharmony_ci case SND_SOC_DAPM_PRE_PMD: 14668c2ecf20Sopenharmony_ci regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL2, 14678c2ecf20Sopenharmony_ci RT5670_GP1_OUT_MASK, RT5670_GP1_OUT_LO); 14688c2ecf20Sopenharmony_ci break; 14698c2ecf20Sopenharmony_ci 14708c2ecf20Sopenharmony_ci default: 14718c2ecf20Sopenharmony_ci return 0; 14728c2ecf20Sopenharmony_ci } 14738c2ecf20Sopenharmony_ci 14748c2ecf20Sopenharmony_ci return 0; 14758c2ecf20Sopenharmony_ci} 14768c2ecf20Sopenharmony_ci 14778c2ecf20Sopenharmony_cistatic int rt5670_bst1_event(struct snd_soc_dapm_widget *w, 14788c2ecf20Sopenharmony_ci struct snd_kcontrol *kcontrol, int event) 14798c2ecf20Sopenharmony_ci{ 14808c2ecf20Sopenharmony_ci struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); 14818c2ecf20Sopenharmony_ci 14828c2ecf20Sopenharmony_ci switch (event) { 14838c2ecf20Sopenharmony_ci case SND_SOC_DAPM_POST_PMU: 14848c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, RT5670_PWR_ANLG2, 14858c2ecf20Sopenharmony_ci RT5670_PWR_BST1_P, RT5670_PWR_BST1_P); 14868c2ecf20Sopenharmony_ci break; 14878c2ecf20Sopenharmony_ci 14888c2ecf20Sopenharmony_ci case SND_SOC_DAPM_PRE_PMD: 14898c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, RT5670_PWR_ANLG2, 14908c2ecf20Sopenharmony_ci RT5670_PWR_BST1_P, 0); 14918c2ecf20Sopenharmony_ci break; 14928c2ecf20Sopenharmony_ci 14938c2ecf20Sopenharmony_ci default: 14948c2ecf20Sopenharmony_ci return 0; 14958c2ecf20Sopenharmony_ci } 14968c2ecf20Sopenharmony_ci 14978c2ecf20Sopenharmony_ci return 0; 14988c2ecf20Sopenharmony_ci} 14998c2ecf20Sopenharmony_ci 15008c2ecf20Sopenharmony_cistatic int rt5670_bst2_event(struct snd_soc_dapm_widget *w, 15018c2ecf20Sopenharmony_ci struct snd_kcontrol *kcontrol, int event) 15028c2ecf20Sopenharmony_ci{ 15038c2ecf20Sopenharmony_ci struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); 15048c2ecf20Sopenharmony_ci 15058c2ecf20Sopenharmony_ci switch (event) { 15068c2ecf20Sopenharmony_ci case SND_SOC_DAPM_POST_PMU: 15078c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, RT5670_PWR_ANLG2, 15088c2ecf20Sopenharmony_ci RT5670_PWR_BST2_P, RT5670_PWR_BST2_P); 15098c2ecf20Sopenharmony_ci break; 15108c2ecf20Sopenharmony_ci 15118c2ecf20Sopenharmony_ci case SND_SOC_DAPM_PRE_PMD: 15128c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, RT5670_PWR_ANLG2, 15138c2ecf20Sopenharmony_ci RT5670_PWR_BST2_P, 0); 15148c2ecf20Sopenharmony_ci break; 15158c2ecf20Sopenharmony_ci 15168c2ecf20Sopenharmony_ci default: 15178c2ecf20Sopenharmony_ci return 0; 15188c2ecf20Sopenharmony_ci } 15198c2ecf20Sopenharmony_ci 15208c2ecf20Sopenharmony_ci return 0; 15218c2ecf20Sopenharmony_ci} 15228c2ecf20Sopenharmony_ci 15238c2ecf20Sopenharmony_cistatic const struct snd_soc_dapm_widget rt5670_dapm_widgets[] = { 15248c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY("PLL1", RT5670_PWR_ANLG2, 15258c2ecf20Sopenharmony_ci RT5670_PWR_PLL_BIT, 0, NULL, 0), 15268c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY("I2S DSP", RT5670_PWR_DIG2, 15278c2ecf20Sopenharmony_ci RT5670_PWR_I2S_DSP_BIT, 0, NULL, 0), 15288c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY("Mic Det Power", RT5670_PWR_VOL, 15298c2ecf20Sopenharmony_ci RT5670_PWR_MIC_DET_BIT, 0, NULL, 0), 15308c2ecf20Sopenharmony_ci 15318c2ecf20Sopenharmony_ci /* ASRC */ 15328c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY_S("I2S1 ASRC", 1, RT5670_ASRC_1, 15338c2ecf20Sopenharmony_ci 11, 0, NULL, 0), 15348c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY_S("I2S2 ASRC", 1, RT5670_ASRC_1, 15358c2ecf20Sopenharmony_ci 12, 0, NULL, 0), 15368c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY_S("DAC STO ASRC", 1, RT5670_ASRC_1, 15378c2ecf20Sopenharmony_ci 10, 0, NULL, 0), 15388c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY_S("DAC MONO L ASRC", 1, RT5670_ASRC_1, 15398c2ecf20Sopenharmony_ci 9, 0, NULL, 0), 15408c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY_S("DAC MONO R ASRC", 1, RT5670_ASRC_1, 15418c2ecf20Sopenharmony_ci 8, 0, NULL, 0), 15428c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY_S("DMIC STO1 ASRC", 1, RT5670_ASRC_1, 15438c2ecf20Sopenharmony_ci 7, 0, NULL, 0), 15448c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY_S("DMIC STO2 ASRC", 1, RT5670_ASRC_1, 15458c2ecf20Sopenharmony_ci 6, 0, NULL, 0), 15468c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY_S("DMIC MONO L ASRC", 1, RT5670_ASRC_1, 15478c2ecf20Sopenharmony_ci 5, 0, NULL, 0), 15488c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY_S("DMIC MONO R ASRC", 1, RT5670_ASRC_1, 15498c2ecf20Sopenharmony_ci 4, 0, NULL, 0), 15508c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY_S("ADC STO1 ASRC", 1, RT5670_ASRC_1, 15518c2ecf20Sopenharmony_ci 3, 0, NULL, 0), 15528c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY_S("ADC STO2 ASRC", 1, RT5670_ASRC_1, 15538c2ecf20Sopenharmony_ci 2, 0, NULL, 0), 15548c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY_S("ADC MONO L ASRC", 1, RT5670_ASRC_1, 15558c2ecf20Sopenharmony_ci 1, 0, NULL, 0), 15568c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY_S("ADC MONO R ASRC", 1, RT5670_ASRC_1, 15578c2ecf20Sopenharmony_ci 0, 0, NULL, 0), 15588c2ecf20Sopenharmony_ci 15598c2ecf20Sopenharmony_ci /* Input Side */ 15608c2ecf20Sopenharmony_ci /* micbias */ 15618c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY("MICBIAS1", RT5670_PWR_ANLG2, 15628c2ecf20Sopenharmony_ci RT5670_PWR_MB1_BIT, 0, NULL, 0), 15638c2ecf20Sopenharmony_ci 15648c2ecf20Sopenharmony_ci /* Input Lines */ 15658c2ecf20Sopenharmony_ci SND_SOC_DAPM_INPUT("DMIC L1"), 15668c2ecf20Sopenharmony_ci SND_SOC_DAPM_INPUT("DMIC R1"), 15678c2ecf20Sopenharmony_ci SND_SOC_DAPM_INPUT("DMIC L2"), 15688c2ecf20Sopenharmony_ci SND_SOC_DAPM_INPUT("DMIC R2"), 15698c2ecf20Sopenharmony_ci SND_SOC_DAPM_INPUT("DMIC L3"), 15708c2ecf20Sopenharmony_ci SND_SOC_DAPM_INPUT("DMIC R3"), 15718c2ecf20Sopenharmony_ci 15728c2ecf20Sopenharmony_ci SND_SOC_DAPM_INPUT("IN1P"), 15738c2ecf20Sopenharmony_ci SND_SOC_DAPM_INPUT("IN1N"), 15748c2ecf20Sopenharmony_ci SND_SOC_DAPM_INPUT("IN2P"), 15758c2ecf20Sopenharmony_ci SND_SOC_DAPM_INPUT("IN2N"), 15768c2ecf20Sopenharmony_ci 15778c2ecf20Sopenharmony_ci SND_SOC_DAPM_PGA("DMIC1", SND_SOC_NOPM, 0, 0, NULL, 0), 15788c2ecf20Sopenharmony_ci SND_SOC_DAPM_PGA("DMIC2", SND_SOC_NOPM, 0, 0, NULL, 0), 15798c2ecf20Sopenharmony_ci SND_SOC_DAPM_PGA("DMIC3", SND_SOC_NOPM, 0, 0, NULL, 0), 15808c2ecf20Sopenharmony_ci 15818c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY("DMIC CLK", SND_SOC_NOPM, 0, 0, 15828c2ecf20Sopenharmony_ci set_dmic_clk, SND_SOC_DAPM_PRE_PMU), 15838c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY("DMIC1 Power", RT5670_DMIC_CTRL1, 15848c2ecf20Sopenharmony_ci RT5670_DMIC_1_EN_SFT, 0, NULL, 0), 15858c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY("DMIC2 Power", RT5670_DMIC_CTRL1, 15868c2ecf20Sopenharmony_ci RT5670_DMIC_2_EN_SFT, 0, NULL, 0), 15878c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY("DMIC3 Power", RT5670_DMIC_CTRL1, 15888c2ecf20Sopenharmony_ci RT5670_DMIC_3_EN_SFT, 0, NULL, 0), 15898c2ecf20Sopenharmony_ci /* Boost */ 15908c2ecf20Sopenharmony_ci SND_SOC_DAPM_PGA_E("BST1", RT5670_PWR_ANLG2, RT5670_PWR_BST1_BIT, 15918c2ecf20Sopenharmony_ci 0, NULL, 0, rt5670_bst1_event, 15928c2ecf20Sopenharmony_ci SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), 15938c2ecf20Sopenharmony_ci SND_SOC_DAPM_PGA_E("BST2", RT5670_PWR_ANLG2, RT5670_PWR_BST2_BIT, 15948c2ecf20Sopenharmony_ci 0, NULL, 0, rt5670_bst2_event, 15958c2ecf20Sopenharmony_ci SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), 15968c2ecf20Sopenharmony_ci /* Input Volume */ 15978c2ecf20Sopenharmony_ci SND_SOC_DAPM_PGA("INL VOL", RT5670_PWR_VOL, 15988c2ecf20Sopenharmony_ci RT5670_PWR_IN_L_BIT, 0, NULL, 0), 15998c2ecf20Sopenharmony_ci SND_SOC_DAPM_PGA("INR VOL", RT5670_PWR_VOL, 16008c2ecf20Sopenharmony_ci RT5670_PWR_IN_R_BIT, 0, NULL, 0), 16018c2ecf20Sopenharmony_ci 16028c2ecf20Sopenharmony_ci /* REC Mixer */ 16038c2ecf20Sopenharmony_ci SND_SOC_DAPM_MIXER("RECMIXL", RT5670_PWR_MIXER, RT5670_PWR_RM_L_BIT, 0, 16048c2ecf20Sopenharmony_ci rt5670_rec_l_mix, ARRAY_SIZE(rt5670_rec_l_mix)), 16058c2ecf20Sopenharmony_ci SND_SOC_DAPM_MIXER("RECMIXR", RT5670_PWR_MIXER, RT5670_PWR_RM_R_BIT, 0, 16068c2ecf20Sopenharmony_ci rt5670_rec_r_mix, ARRAY_SIZE(rt5670_rec_r_mix)), 16078c2ecf20Sopenharmony_ci /* ADCs */ 16088c2ecf20Sopenharmony_ci SND_SOC_DAPM_ADC("ADC 1", NULL, SND_SOC_NOPM, 0, 0), 16098c2ecf20Sopenharmony_ci SND_SOC_DAPM_ADC("ADC 2", NULL, SND_SOC_NOPM, 0, 0), 16108c2ecf20Sopenharmony_ci 16118c2ecf20Sopenharmony_ci SND_SOC_DAPM_PGA("ADC 1_2", SND_SOC_NOPM, 0, 0, NULL, 0), 16128c2ecf20Sopenharmony_ci 16138c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY("ADC 1 power", RT5670_PWR_DIG1, 16148c2ecf20Sopenharmony_ci RT5670_PWR_ADC_L_BIT, 0, NULL, 0), 16158c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY("ADC 2 power", RT5670_PWR_DIG1, 16168c2ecf20Sopenharmony_ci RT5670_PWR_ADC_R_BIT, 0, NULL, 0), 16178c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY("ADC clock", RT5670_PR_BASE + 16188c2ecf20Sopenharmony_ci RT5670_CHOP_DAC_ADC, 12, 0, NULL, 0), 16198c2ecf20Sopenharmony_ci /* ADC Mux */ 16208c2ecf20Sopenharmony_ci SND_SOC_DAPM_MUX("Stereo1 DMIC Mux", SND_SOC_NOPM, 0, 0, 16218c2ecf20Sopenharmony_ci &rt5670_sto1_dmic_mux), 16228c2ecf20Sopenharmony_ci SND_SOC_DAPM_MUX("Stereo1 ADC L2 Mux", SND_SOC_NOPM, 0, 0, 16238c2ecf20Sopenharmony_ci &rt5670_sto_adc_2_mux), 16248c2ecf20Sopenharmony_ci SND_SOC_DAPM_MUX("Stereo1 ADC R2 Mux", SND_SOC_NOPM, 0, 0, 16258c2ecf20Sopenharmony_ci &rt5670_sto_adc_2_mux), 16268c2ecf20Sopenharmony_ci SND_SOC_DAPM_MUX("Stereo1 ADC L1 Mux", SND_SOC_NOPM, 0, 0, 16278c2ecf20Sopenharmony_ci &rt5670_sto_adc_1_mux), 16288c2ecf20Sopenharmony_ci SND_SOC_DAPM_MUX("Stereo1 ADC R1 Mux", SND_SOC_NOPM, 0, 0, 16298c2ecf20Sopenharmony_ci &rt5670_sto_adc_1_mux), 16308c2ecf20Sopenharmony_ci SND_SOC_DAPM_MUX("Stereo2 DMIC Mux", SND_SOC_NOPM, 0, 0, 16318c2ecf20Sopenharmony_ci &rt5670_sto2_dmic_mux), 16328c2ecf20Sopenharmony_ci SND_SOC_DAPM_MUX("Stereo2 ADC L2 Mux", SND_SOC_NOPM, 0, 0, 16338c2ecf20Sopenharmony_ci &rt5670_sto2_adc_2_mux), 16348c2ecf20Sopenharmony_ci SND_SOC_DAPM_MUX("Stereo2 ADC R2 Mux", SND_SOC_NOPM, 0, 0, 16358c2ecf20Sopenharmony_ci &rt5670_sto2_adc_2_mux), 16368c2ecf20Sopenharmony_ci SND_SOC_DAPM_MUX("Stereo2 ADC L1 Mux", SND_SOC_NOPM, 0, 0, 16378c2ecf20Sopenharmony_ci &rt5670_sto2_adc_1_mux), 16388c2ecf20Sopenharmony_ci SND_SOC_DAPM_MUX("Stereo2 ADC R1 Mux", SND_SOC_NOPM, 0, 0, 16398c2ecf20Sopenharmony_ci &rt5670_sto2_adc_1_mux), 16408c2ecf20Sopenharmony_ci SND_SOC_DAPM_MUX("Stereo2 ADC LR Mux", SND_SOC_NOPM, 0, 0, 16418c2ecf20Sopenharmony_ci &rt5670_sto2_adc_lr_mux), 16428c2ecf20Sopenharmony_ci SND_SOC_DAPM_MUX("Mono DMIC L Mux", SND_SOC_NOPM, 0, 0, 16438c2ecf20Sopenharmony_ci &rt5670_mono_dmic_l_mux), 16448c2ecf20Sopenharmony_ci SND_SOC_DAPM_MUX("Mono DMIC R Mux", SND_SOC_NOPM, 0, 0, 16458c2ecf20Sopenharmony_ci &rt5670_mono_dmic_r_mux), 16468c2ecf20Sopenharmony_ci SND_SOC_DAPM_MUX("Mono ADC L2 Mux", SND_SOC_NOPM, 0, 0, 16478c2ecf20Sopenharmony_ci &rt5670_mono_adc_l2_mux), 16488c2ecf20Sopenharmony_ci SND_SOC_DAPM_MUX("Mono ADC L1 Mux", SND_SOC_NOPM, 0, 0, 16498c2ecf20Sopenharmony_ci &rt5670_mono_adc_l1_mux), 16508c2ecf20Sopenharmony_ci SND_SOC_DAPM_MUX("Mono ADC R1 Mux", SND_SOC_NOPM, 0, 0, 16518c2ecf20Sopenharmony_ci &rt5670_mono_adc_r1_mux), 16528c2ecf20Sopenharmony_ci SND_SOC_DAPM_MUX("Mono ADC R2 Mux", SND_SOC_NOPM, 0, 0, 16538c2ecf20Sopenharmony_ci &rt5670_mono_adc_r2_mux), 16548c2ecf20Sopenharmony_ci /* ADC Mixer */ 16558c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY("ADC Stereo1 Filter", RT5670_PWR_DIG2, 16568c2ecf20Sopenharmony_ci RT5670_PWR_ADC_S1F_BIT, 0, NULL, 0), 16578c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY("ADC Stereo2 Filter", RT5670_PWR_DIG2, 16588c2ecf20Sopenharmony_ci RT5670_PWR_ADC_S2F_BIT, 0, NULL, 0), 16598c2ecf20Sopenharmony_ci SND_SOC_DAPM_MIXER("Sto1 ADC MIXL", RT5670_STO1_ADC_DIG_VOL, 16608c2ecf20Sopenharmony_ci RT5670_L_MUTE_SFT, 1, rt5670_sto1_adc_l_mix, 16618c2ecf20Sopenharmony_ci ARRAY_SIZE(rt5670_sto1_adc_l_mix)), 16628c2ecf20Sopenharmony_ci SND_SOC_DAPM_MIXER("Sto1 ADC MIXR", RT5670_STO1_ADC_DIG_VOL, 16638c2ecf20Sopenharmony_ci RT5670_R_MUTE_SFT, 1, rt5670_sto1_adc_r_mix, 16648c2ecf20Sopenharmony_ci ARRAY_SIZE(rt5670_sto1_adc_r_mix)), 16658c2ecf20Sopenharmony_ci SND_SOC_DAPM_MIXER("Sto2 ADC MIXL", SND_SOC_NOPM, 0, 0, 16668c2ecf20Sopenharmony_ci rt5670_sto2_adc_l_mix, 16678c2ecf20Sopenharmony_ci ARRAY_SIZE(rt5670_sto2_adc_l_mix)), 16688c2ecf20Sopenharmony_ci SND_SOC_DAPM_MIXER("Sto2 ADC MIXR", SND_SOC_NOPM, 0, 0, 16698c2ecf20Sopenharmony_ci rt5670_sto2_adc_r_mix, 16708c2ecf20Sopenharmony_ci ARRAY_SIZE(rt5670_sto2_adc_r_mix)), 16718c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY("ADC Mono Left Filter", RT5670_PWR_DIG2, 16728c2ecf20Sopenharmony_ci RT5670_PWR_ADC_MF_L_BIT, 0, NULL, 0), 16738c2ecf20Sopenharmony_ci SND_SOC_DAPM_MIXER("Mono ADC MIXL", RT5670_MONO_ADC_DIG_VOL, 16748c2ecf20Sopenharmony_ci RT5670_L_MUTE_SFT, 1, rt5670_mono_adc_l_mix, 16758c2ecf20Sopenharmony_ci ARRAY_SIZE(rt5670_mono_adc_l_mix)), 16768c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY("ADC Mono Right Filter", RT5670_PWR_DIG2, 16778c2ecf20Sopenharmony_ci RT5670_PWR_ADC_MF_R_BIT, 0, NULL, 0), 16788c2ecf20Sopenharmony_ci SND_SOC_DAPM_MIXER("Mono ADC MIXR", RT5670_MONO_ADC_DIG_VOL, 16798c2ecf20Sopenharmony_ci RT5670_R_MUTE_SFT, 1, rt5670_mono_adc_r_mix, 16808c2ecf20Sopenharmony_ci ARRAY_SIZE(rt5670_mono_adc_r_mix)), 16818c2ecf20Sopenharmony_ci 16828c2ecf20Sopenharmony_ci /* ADC PGA */ 16838c2ecf20Sopenharmony_ci SND_SOC_DAPM_PGA("Stereo1 ADC MIXL", SND_SOC_NOPM, 0, 0, NULL, 0), 16848c2ecf20Sopenharmony_ci SND_SOC_DAPM_PGA("Stereo1 ADC MIXR", SND_SOC_NOPM, 0, 0, NULL, 0), 16858c2ecf20Sopenharmony_ci SND_SOC_DAPM_PGA("Stereo2 ADC MIXL", SND_SOC_NOPM, 0, 0, NULL, 0), 16868c2ecf20Sopenharmony_ci SND_SOC_DAPM_PGA("Stereo2 ADC MIXR", SND_SOC_NOPM, 0, 0, NULL, 0), 16878c2ecf20Sopenharmony_ci SND_SOC_DAPM_PGA("Sto2 ADC LR MIX", SND_SOC_NOPM, 0, 0, NULL, 0), 16888c2ecf20Sopenharmony_ci SND_SOC_DAPM_PGA("Stereo1 ADC MIX", SND_SOC_NOPM, 0, 0, NULL, 0), 16898c2ecf20Sopenharmony_ci SND_SOC_DAPM_PGA("Stereo2 ADC MIX", SND_SOC_NOPM, 0, 0, NULL, 0), 16908c2ecf20Sopenharmony_ci SND_SOC_DAPM_PGA("Mono ADC MIX", SND_SOC_NOPM, 0, 0, NULL, 0), 16918c2ecf20Sopenharmony_ci SND_SOC_DAPM_PGA("VAD_ADC", SND_SOC_NOPM, 0, 0, NULL, 0), 16928c2ecf20Sopenharmony_ci SND_SOC_DAPM_PGA("IF_ADC1", SND_SOC_NOPM, 0, 0, NULL, 0), 16938c2ecf20Sopenharmony_ci SND_SOC_DAPM_PGA("IF_ADC2", SND_SOC_NOPM, 0, 0, NULL, 0), 16948c2ecf20Sopenharmony_ci SND_SOC_DAPM_PGA("IF_ADC3", SND_SOC_NOPM, 0, 0, NULL, 0), 16958c2ecf20Sopenharmony_ci SND_SOC_DAPM_PGA("IF1_ADC1", SND_SOC_NOPM, 0, 0, NULL, 0), 16968c2ecf20Sopenharmony_ci SND_SOC_DAPM_PGA("IF1_ADC2", SND_SOC_NOPM, 0, 0, NULL, 0), 16978c2ecf20Sopenharmony_ci SND_SOC_DAPM_PGA("IF1_ADC3", SND_SOC_NOPM, 0, 0, NULL, 0), 16988c2ecf20Sopenharmony_ci 16998c2ecf20Sopenharmony_ci /* DSP */ 17008c2ecf20Sopenharmony_ci SND_SOC_DAPM_PGA("TxDP_ADC", SND_SOC_NOPM, 0, 0, NULL, 0), 17018c2ecf20Sopenharmony_ci SND_SOC_DAPM_PGA("TxDP_ADC_L", SND_SOC_NOPM, 0, 0, NULL, 0), 17028c2ecf20Sopenharmony_ci SND_SOC_DAPM_PGA("TxDP_ADC_R", SND_SOC_NOPM, 0, 0, NULL, 0), 17038c2ecf20Sopenharmony_ci SND_SOC_DAPM_PGA("TxDC_DAC", SND_SOC_NOPM, 0, 0, NULL, 0), 17048c2ecf20Sopenharmony_ci 17058c2ecf20Sopenharmony_ci SND_SOC_DAPM_MUX("TDM Data Mux", SND_SOC_NOPM, 0, 0, 17068c2ecf20Sopenharmony_ci &rt5670_txdp_slot_mux), 17078c2ecf20Sopenharmony_ci 17088c2ecf20Sopenharmony_ci SND_SOC_DAPM_MUX("DSP UL Mux", SND_SOC_NOPM, 0, 0, 17098c2ecf20Sopenharmony_ci &rt5670_dsp_ul_mux), 17108c2ecf20Sopenharmony_ci SND_SOC_DAPM_MUX("DSP DL Mux", SND_SOC_NOPM, 0, 0, 17118c2ecf20Sopenharmony_ci &rt5670_dsp_dl_mux), 17128c2ecf20Sopenharmony_ci 17138c2ecf20Sopenharmony_ci SND_SOC_DAPM_MUX("RxDP Mux", SND_SOC_NOPM, 0, 0, 17148c2ecf20Sopenharmony_ci &rt5670_rxdp_mux), 17158c2ecf20Sopenharmony_ci 17168c2ecf20Sopenharmony_ci /* IF2 Mux */ 17178c2ecf20Sopenharmony_ci SND_SOC_DAPM_MUX("IF2 ADC Mux", SND_SOC_NOPM, 0, 0, 17188c2ecf20Sopenharmony_ci &rt5670_if2_adc_in_mux), 17198c2ecf20Sopenharmony_ci 17208c2ecf20Sopenharmony_ci /* Digital Interface */ 17218c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY("I2S1", RT5670_PWR_DIG1, 17228c2ecf20Sopenharmony_ci RT5670_PWR_I2S1_BIT, 0, NULL, 0), 17238c2ecf20Sopenharmony_ci SND_SOC_DAPM_PGA("IF1 DAC1", SND_SOC_NOPM, 0, 0, NULL, 0), 17248c2ecf20Sopenharmony_ci SND_SOC_DAPM_PGA("IF1 DAC2", SND_SOC_NOPM, 0, 0, NULL, 0), 17258c2ecf20Sopenharmony_ci SND_SOC_DAPM_PGA("IF1 DAC1 L", SND_SOC_NOPM, 0, 0, NULL, 0), 17268c2ecf20Sopenharmony_ci SND_SOC_DAPM_PGA("IF1 DAC1 R", SND_SOC_NOPM, 0, 0, NULL, 0), 17278c2ecf20Sopenharmony_ci SND_SOC_DAPM_PGA("IF1 DAC2 L", SND_SOC_NOPM, 0, 0, NULL, 0), 17288c2ecf20Sopenharmony_ci SND_SOC_DAPM_PGA("IF1 DAC2 R", SND_SOC_NOPM, 0, 0, NULL, 0), 17298c2ecf20Sopenharmony_ci SND_SOC_DAPM_PGA("IF1 ADC", SND_SOC_NOPM, 0, 0, NULL, 0), 17308c2ecf20Sopenharmony_ci SND_SOC_DAPM_PGA("IF1 ADC L", SND_SOC_NOPM, 0, 0, NULL, 0), 17318c2ecf20Sopenharmony_ci SND_SOC_DAPM_PGA("IF1 ADC R", SND_SOC_NOPM, 0, 0, NULL, 0), 17328c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY("I2S2", RT5670_PWR_DIG1, 17338c2ecf20Sopenharmony_ci RT5670_PWR_I2S2_BIT, 0, NULL, 0), 17348c2ecf20Sopenharmony_ci SND_SOC_DAPM_PGA("IF2 DAC", SND_SOC_NOPM, 0, 0, NULL, 0), 17358c2ecf20Sopenharmony_ci SND_SOC_DAPM_PGA("IF2 DAC L", SND_SOC_NOPM, 0, 0, NULL, 0), 17368c2ecf20Sopenharmony_ci SND_SOC_DAPM_PGA("IF2 DAC R", SND_SOC_NOPM, 0, 0, NULL, 0), 17378c2ecf20Sopenharmony_ci SND_SOC_DAPM_PGA("IF2 ADC", SND_SOC_NOPM, 0, 0, NULL, 0), 17388c2ecf20Sopenharmony_ci SND_SOC_DAPM_PGA("IF2 ADC L", SND_SOC_NOPM, 0, 0, NULL, 0), 17398c2ecf20Sopenharmony_ci SND_SOC_DAPM_PGA("IF2 ADC R", SND_SOC_NOPM, 0, 0, NULL, 0), 17408c2ecf20Sopenharmony_ci 17418c2ecf20Sopenharmony_ci /* Digital Interface Select */ 17428c2ecf20Sopenharmony_ci SND_SOC_DAPM_MUX("IF1 ADC1 IN1 Mux", SND_SOC_NOPM, 0, 0, 17438c2ecf20Sopenharmony_ci &rt5670_if1_adc1_in1_mux), 17448c2ecf20Sopenharmony_ci SND_SOC_DAPM_MUX("IF1 ADC1 IN2 Mux", SND_SOC_NOPM, 0, 0, 17458c2ecf20Sopenharmony_ci &rt5670_if1_adc1_in2_mux), 17468c2ecf20Sopenharmony_ci SND_SOC_DAPM_MUX("IF1 ADC2 IN Mux", SND_SOC_NOPM, 0, 0, 17478c2ecf20Sopenharmony_ci &rt5670_if1_adc2_in_mux), 17488c2ecf20Sopenharmony_ci SND_SOC_DAPM_MUX("IF1 ADC2 IN1 Mux", SND_SOC_NOPM, 0, 0, 17498c2ecf20Sopenharmony_ci &rt5670_if1_adc2_in1_mux), 17508c2ecf20Sopenharmony_ci SND_SOC_DAPM_MUX("VAD ADC Mux", SND_SOC_NOPM, 0, 0, 17518c2ecf20Sopenharmony_ci &rt5670_vad_adc_mux), 17528c2ecf20Sopenharmony_ci 17538c2ecf20Sopenharmony_ci /* Audio Interface */ 17548c2ecf20Sopenharmony_ci SND_SOC_DAPM_AIF_IN("AIF1RX", "AIF1 Playback", 0, SND_SOC_NOPM, 0, 0), 17558c2ecf20Sopenharmony_ci SND_SOC_DAPM_AIF_OUT("AIF1TX", "AIF1 Capture", 0, SND_SOC_NOPM, 0, 0), 17568c2ecf20Sopenharmony_ci SND_SOC_DAPM_AIF_IN("AIF2RX", "AIF2 Playback", 0, SND_SOC_NOPM, 0, 0), 17578c2ecf20Sopenharmony_ci SND_SOC_DAPM_AIF_OUT("AIF2TX", "AIF2 Capture", 0, 17588c2ecf20Sopenharmony_ci RT5670_GPIO_CTRL1, RT5670_I2S2_PIN_SFT, 1), 17598c2ecf20Sopenharmony_ci 17608c2ecf20Sopenharmony_ci /* Audio DSP */ 17618c2ecf20Sopenharmony_ci SND_SOC_DAPM_PGA("Audio DSP", SND_SOC_NOPM, 0, 0, NULL, 0), 17628c2ecf20Sopenharmony_ci 17638c2ecf20Sopenharmony_ci /* Output Side */ 17648c2ecf20Sopenharmony_ci /* DAC mixer before sound effect */ 17658c2ecf20Sopenharmony_ci SND_SOC_DAPM_MIXER("DAC1 MIXL", SND_SOC_NOPM, 0, 0, 17668c2ecf20Sopenharmony_ci rt5670_dac_l_mix, ARRAY_SIZE(rt5670_dac_l_mix)), 17678c2ecf20Sopenharmony_ci SND_SOC_DAPM_MIXER("DAC1 MIXR", SND_SOC_NOPM, 0, 0, 17688c2ecf20Sopenharmony_ci rt5670_dac_r_mix, ARRAY_SIZE(rt5670_dac_r_mix)), 17698c2ecf20Sopenharmony_ci SND_SOC_DAPM_PGA("DAC MIX", SND_SOC_NOPM, 0, 0, NULL, 0), 17708c2ecf20Sopenharmony_ci 17718c2ecf20Sopenharmony_ci /* DAC2 channel Mux */ 17728c2ecf20Sopenharmony_ci SND_SOC_DAPM_MUX("DAC L2 Mux", SND_SOC_NOPM, 0, 0, 17738c2ecf20Sopenharmony_ci &rt5670_dac_l2_mux), 17748c2ecf20Sopenharmony_ci SND_SOC_DAPM_MUX("DAC R2 Mux", SND_SOC_NOPM, 0, 0, 17758c2ecf20Sopenharmony_ci &rt5670_dac_r2_mux), 17768c2ecf20Sopenharmony_ci SND_SOC_DAPM_PGA("DAC L2 Volume", RT5670_PWR_DIG1, 17778c2ecf20Sopenharmony_ci RT5670_PWR_DAC_L2_BIT, 0, NULL, 0), 17788c2ecf20Sopenharmony_ci SND_SOC_DAPM_PGA("DAC R2 Volume", RT5670_PWR_DIG1, 17798c2ecf20Sopenharmony_ci RT5670_PWR_DAC_R2_BIT, 0, NULL, 0), 17808c2ecf20Sopenharmony_ci 17818c2ecf20Sopenharmony_ci SND_SOC_DAPM_MUX("DAC1 L Mux", SND_SOC_NOPM, 0, 0, &rt5670_dac1l_mux), 17828c2ecf20Sopenharmony_ci SND_SOC_DAPM_MUX("DAC1 R Mux", SND_SOC_NOPM, 0, 0, &rt5670_dac1r_mux), 17838c2ecf20Sopenharmony_ci 17848c2ecf20Sopenharmony_ci /* DAC Mixer */ 17858c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY("DAC Stereo1 Filter", RT5670_PWR_DIG2, 17868c2ecf20Sopenharmony_ci RT5670_PWR_DAC_S1F_BIT, 0, NULL, 0), 17878c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY("DAC Mono Left Filter", RT5670_PWR_DIG2, 17888c2ecf20Sopenharmony_ci RT5670_PWR_DAC_MF_L_BIT, 0, NULL, 0), 17898c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY("DAC Mono Right Filter", RT5670_PWR_DIG2, 17908c2ecf20Sopenharmony_ci RT5670_PWR_DAC_MF_R_BIT, 0, NULL, 0), 17918c2ecf20Sopenharmony_ci SND_SOC_DAPM_MIXER("Stereo DAC MIXL", SND_SOC_NOPM, 0, 0, 17928c2ecf20Sopenharmony_ci rt5670_sto_dac_l_mix, 17938c2ecf20Sopenharmony_ci ARRAY_SIZE(rt5670_sto_dac_l_mix)), 17948c2ecf20Sopenharmony_ci SND_SOC_DAPM_MIXER("Stereo DAC MIXR", SND_SOC_NOPM, 0, 0, 17958c2ecf20Sopenharmony_ci rt5670_sto_dac_r_mix, 17968c2ecf20Sopenharmony_ci ARRAY_SIZE(rt5670_sto_dac_r_mix)), 17978c2ecf20Sopenharmony_ci SND_SOC_DAPM_MIXER("Mono DAC MIXL", SND_SOC_NOPM, 0, 0, 17988c2ecf20Sopenharmony_ci rt5670_mono_dac_l_mix, 17998c2ecf20Sopenharmony_ci ARRAY_SIZE(rt5670_mono_dac_l_mix)), 18008c2ecf20Sopenharmony_ci SND_SOC_DAPM_MIXER("Mono DAC MIXR", SND_SOC_NOPM, 0, 0, 18018c2ecf20Sopenharmony_ci rt5670_mono_dac_r_mix, 18028c2ecf20Sopenharmony_ci ARRAY_SIZE(rt5670_mono_dac_r_mix)), 18038c2ecf20Sopenharmony_ci SND_SOC_DAPM_MIXER("DAC MIXL", SND_SOC_NOPM, 0, 0, 18048c2ecf20Sopenharmony_ci rt5670_dig_l_mix, 18058c2ecf20Sopenharmony_ci ARRAY_SIZE(rt5670_dig_l_mix)), 18068c2ecf20Sopenharmony_ci SND_SOC_DAPM_MIXER("DAC MIXR", SND_SOC_NOPM, 0, 0, 18078c2ecf20Sopenharmony_ci rt5670_dig_r_mix, 18088c2ecf20Sopenharmony_ci ARRAY_SIZE(rt5670_dig_r_mix)), 18098c2ecf20Sopenharmony_ci 18108c2ecf20Sopenharmony_ci /* DACs */ 18118c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY("DAC L1 Power", RT5670_PWR_DIG1, 18128c2ecf20Sopenharmony_ci RT5670_PWR_DAC_L1_BIT, 0, NULL, 0), 18138c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY("DAC R1 Power", RT5670_PWR_DIG1, 18148c2ecf20Sopenharmony_ci RT5670_PWR_DAC_R1_BIT, 0, NULL, 0), 18158c2ecf20Sopenharmony_ci SND_SOC_DAPM_DAC("DAC L1", NULL, SND_SOC_NOPM, 0, 0), 18168c2ecf20Sopenharmony_ci SND_SOC_DAPM_DAC("DAC R1", NULL, SND_SOC_NOPM, 0, 0), 18178c2ecf20Sopenharmony_ci SND_SOC_DAPM_DAC("DAC L2", NULL, RT5670_PWR_DIG1, 18188c2ecf20Sopenharmony_ci RT5670_PWR_DAC_L2_BIT, 0), 18198c2ecf20Sopenharmony_ci 18208c2ecf20Sopenharmony_ci SND_SOC_DAPM_DAC("DAC R2", NULL, RT5670_PWR_DIG1, 18218c2ecf20Sopenharmony_ci RT5670_PWR_DAC_R2_BIT, 0), 18228c2ecf20Sopenharmony_ci /* OUT Mixer */ 18238c2ecf20Sopenharmony_ci 18248c2ecf20Sopenharmony_ci SND_SOC_DAPM_MIXER("OUT MIXL", RT5670_PWR_MIXER, RT5670_PWR_OM_L_BIT, 18258c2ecf20Sopenharmony_ci 0, rt5670_out_l_mix, ARRAY_SIZE(rt5670_out_l_mix)), 18268c2ecf20Sopenharmony_ci SND_SOC_DAPM_MIXER("OUT MIXR", RT5670_PWR_MIXER, RT5670_PWR_OM_R_BIT, 18278c2ecf20Sopenharmony_ci 0, rt5670_out_r_mix, ARRAY_SIZE(rt5670_out_r_mix)), 18288c2ecf20Sopenharmony_ci /* Ouput Volume */ 18298c2ecf20Sopenharmony_ci SND_SOC_DAPM_MIXER("HPOVOL MIXL", RT5670_PWR_VOL, 18308c2ecf20Sopenharmony_ci RT5670_PWR_HV_L_BIT, 0, 18318c2ecf20Sopenharmony_ci rt5670_hpvoll_mix, ARRAY_SIZE(rt5670_hpvoll_mix)), 18328c2ecf20Sopenharmony_ci SND_SOC_DAPM_MIXER("HPOVOL MIXR", RT5670_PWR_VOL, 18338c2ecf20Sopenharmony_ci RT5670_PWR_HV_R_BIT, 0, 18348c2ecf20Sopenharmony_ci rt5670_hpvolr_mix, ARRAY_SIZE(rt5670_hpvolr_mix)), 18358c2ecf20Sopenharmony_ci SND_SOC_DAPM_PGA("DAC 1", SND_SOC_NOPM, 0, 0, NULL, 0), 18368c2ecf20Sopenharmony_ci SND_SOC_DAPM_PGA("DAC 2", SND_SOC_NOPM, 0, 0, NULL, 0), 18378c2ecf20Sopenharmony_ci SND_SOC_DAPM_PGA("HPOVOL", SND_SOC_NOPM, 0, 0, NULL, 0), 18388c2ecf20Sopenharmony_ci 18398c2ecf20Sopenharmony_ci /* HPO/LOUT/Mono Mixer */ 18408c2ecf20Sopenharmony_ci SND_SOC_DAPM_MIXER("HPO MIX", SND_SOC_NOPM, 0, 0, 18418c2ecf20Sopenharmony_ci rt5670_hpo_mix, ARRAY_SIZE(rt5670_hpo_mix)), 18428c2ecf20Sopenharmony_ci SND_SOC_DAPM_MIXER("LOUT MIX", RT5670_PWR_ANLG1, RT5670_PWR_LM_BIT, 18438c2ecf20Sopenharmony_ci 0, rt5670_lout_mix, ARRAY_SIZE(rt5670_lout_mix)), 18448c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY_S("Improve HP Amp Drv", 1, SND_SOC_NOPM, 0, 0, 18458c2ecf20Sopenharmony_ci rt5670_hp_power_event, SND_SOC_DAPM_POST_PMU | 18468c2ecf20Sopenharmony_ci SND_SOC_DAPM_PRE_PMD), 18478c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY("HP L Amp", RT5670_PWR_ANLG1, 18488c2ecf20Sopenharmony_ci RT5670_PWR_HP_L_BIT, 0, NULL, 0), 18498c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY("HP R Amp", RT5670_PWR_ANLG1, 18508c2ecf20Sopenharmony_ci RT5670_PWR_HP_R_BIT, 0, NULL, 0), 18518c2ecf20Sopenharmony_ci SND_SOC_DAPM_PGA_S("HP Amp", 1, SND_SOC_NOPM, 0, 0, 18528c2ecf20Sopenharmony_ci rt5670_hp_event, SND_SOC_DAPM_PRE_PMD | 18538c2ecf20Sopenharmony_ci SND_SOC_DAPM_POST_PMU), 18548c2ecf20Sopenharmony_ci SND_SOC_DAPM_SWITCH("LOUT L Playback", SND_SOC_NOPM, 0, 0, 18558c2ecf20Sopenharmony_ci &lout_l_enable_control), 18568c2ecf20Sopenharmony_ci SND_SOC_DAPM_SWITCH("LOUT R Playback", SND_SOC_NOPM, 0, 0, 18578c2ecf20Sopenharmony_ci &lout_r_enable_control), 18588c2ecf20Sopenharmony_ci SND_SOC_DAPM_PGA("LOUT Amp", SND_SOC_NOPM, 0, 0, NULL, 0), 18598c2ecf20Sopenharmony_ci 18608c2ecf20Sopenharmony_ci /* PDM */ 18618c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY("PDM1 Power", RT5670_PWR_DIG2, 18628c2ecf20Sopenharmony_ci RT5670_PWR_PDM1_BIT, 0, NULL, 0), 18638c2ecf20Sopenharmony_ci 18648c2ecf20Sopenharmony_ci SND_SOC_DAPM_MUX("PDM1 L Mux", RT5670_PDM_OUT_CTRL, 18658c2ecf20Sopenharmony_ci RT5670_M_PDM1_L_SFT, 1, &rt5670_pdm1_l_mux), 18668c2ecf20Sopenharmony_ci SND_SOC_DAPM_MUX("PDM1 R Mux", RT5670_PDM_OUT_CTRL, 18678c2ecf20Sopenharmony_ci RT5670_M_PDM1_R_SFT, 1, &rt5670_pdm1_r_mux), 18688c2ecf20Sopenharmony_ci 18698c2ecf20Sopenharmony_ci /* Output Lines */ 18708c2ecf20Sopenharmony_ci SND_SOC_DAPM_OUTPUT("HPOL"), 18718c2ecf20Sopenharmony_ci SND_SOC_DAPM_OUTPUT("HPOR"), 18728c2ecf20Sopenharmony_ci SND_SOC_DAPM_OUTPUT("LOUTL"), 18738c2ecf20Sopenharmony_ci SND_SOC_DAPM_OUTPUT("LOUTR"), 18748c2ecf20Sopenharmony_ci}; 18758c2ecf20Sopenharmony_ci 18768c2ecf20Sopenharmony_cistatic const struct snd_soc_dapm_widget rt5670_specific_dapm_widgets[] = { 18778c2ecf20Sopenharmony_ci SND_SOC_DAPM_SUPPLY("PDM2 Power", RT5670_PWR_DIG2, 18788c2ecf20Sopenharmony_ci RT5670_PWR_PDM2_BIT, 0, NULL, 0), 18798c2ecf20Sopenharmony_ci SND_SOC_DAPM_MUX("PDM2 L Mux", RT5670_PDM_OUT_CTRL, 18808c2ecf20Sopenharmony_ci RT5670_M_PDM2_L_SFT, 1, &rt5670_pdm2_l_mux), 18818c2ecf20Sopenharmony_ci SND_SOC_DAPM_MUX("PDM2 R Mux", RT5670_PDM_OUT_CTRL, 18828c2ecf20Sopenharmony_ci RT5670_M_PDM2_R_SFT, 1, &rt5670_pdm2_r_mux), 18838c2ecf20Sopenharmony_ci SND_SOC_DAPM_OUTPUT("PDM1L"), 18848c2ecf20Sopenharmony_ci SND_SOC_DAPM_OUTPUT("PDM1R"), 18858c2ecf20Sopenharmony_ci SND_SOC_DAPM_OUTPUT("PDM2L"), 18868c2ecf20Sopenharmony_ci SND_SOC_DAPM_OUTPUT("PDM2R"), 18878c2ecf20Sopenharmony_ci}; 18888c2ecf20Sopenharmony_ci 18898c2ecf20Sopenharmony_cistatic const struct snd_soc_dapm_widget rt5672_specific_dapm_widgets[] = { 18908c2ecf20Sopenharmony_ci SND_SOC_DAPM_PGA_E("SPO Amp", SND_SOC_NOPM, 0, 0, NULL, 0, 18918c2ecf20Sopenharmony_ci rt5670_spk_event, SND_SOC_DAPM_PRE_PMD | 18928c2ecf20Sopenharmony_ci SND_SOC_DAPM_POST_PMU), 18938c2ecf20Sopenharmony_ci SND_SOC_DAPM_OUTPUT("SPOLP"), 18948c2ecf20Sopenharmony_ci SND_SOC_DAPM_OUTPUT("SPOLN"), 18958c2ecf20Sopenharmony_ci SND_SOC_DAPM_OUTPUT("SPORP"), 18968c2ecf20Sopenharmony_ci SND_SOC_DAPM_OUTPUT("SPORN"), 18978c2ecf20Sopenharmony_ci}; 18988c2ecf20Sopenharmony_ci 18998c2ecf20Sopenharmony_cistatic const struct snd_soc_dapm_route rt5670_dapm_routes[] = { 19008c2ecf20Sopenharmony_ci { "ADC Stereo1 Filter", NULL, "ADC STO1 ASRC", is_using_asrc }, 19018c2ecf20Sopenharmony_ci { "ADC Stereo2 Filter", NULL, "ADC STO2 ASRC", is_using_asrc }, 19028c2ecf20Sopenharmony_ci { "ADC Mono Left Filter", NULL, "ADC MONO L ASRC", is_using_asrc }, 19038c2ecf20Sopenharmony_ci { "ADC Mono Right Filter", NULL, "ADC MONO R ASRC", is_using_asrc }, 19048c2ecf20Sopenharmony_ci { "DAC Mono Left Filter", NULL, "DAC MONO L ASRC", is_using_asrc }, 19058c2ecf20Sopenharmony_ci { "DAC Mono Right Filter", NULL, "DAC MONO R ASRC", is_using_asrc }, 19068c2ecf20Sopenharmony_ci { "DAC Stereo1 Filter", NULL, "DAC STO ASRC", is_using_asrc }, 19078c2ecf20Sopenharmony_ci { "Stereo1 DMIC Mux", NULL, "DMIC STO1 ASRC", can_use_asrc }, 19088c2ecf20Sopenharmony_ci { "Stereo2 DMIC Mux", NULL, "DMIC STO2 ASRC", can_use_asrc }, 19098c2ecf20Sopenharmony_ci { "Mono DMIC L Mux", NULL, "DMIC MONO L ASRC", can_use_asrc }, 19108c2ecf20Sopenharmony_ci { "Mono DMIC R Mux", NULL, "DMIC MONO R ASRC", can_use_asrc }, 19118c2ecf20Sopenharmony_ci 19128c2ecf20Sopenharmony_ci { "I2S1", NULL, "I2S1 ASRC", can_use_asrc}, 19138c2ecf20Sopenharmony_ci { "I2S2", NULL, "I2S2 ASRC", can_use_asrc}, 19148c2ecf20Sopenharmony_ci 19158c2ecf20Sopenharmony_ci { "DMIC1", NULL, "DMIC L1" }, 19168c2ecf20Sopenharmony_ci { "DMIC1", NULL, "DMIC R1" }, 19178c2ecf20Sopenharmony_ci { "DMIC2", NULL, "DMIC L2" }, 19188c2ecf20Sopenharmony_ci { "DMIC2", NULL, "DMIC R2" }, 19198c2ecf20Sopenharmony_ci { "DMIC3", NULL, "DMIC L3" }, 19208c2ecf20Sopenharmony_ci { "DMIC3", NULL, "DMIC R3" }, 19218c2ecf20Sopenharmony_ci 19228c2ecf20Sopenharmony_ci { "BST1", NULL, "IN1P" }, 19238c2ecf20Sopenharmony_ci { "BST1", NULL, "IN1N" }, 19248c2ecf20Sopenharmony_ci { "BST1", NULL, "Mic Det Power" }, 19258c2ecf20Sopenharmony_ci { "BST2", NULL, "IN2P" }, 19268c2ecf20Sopenharmony_ci { "BST2", NULL, "IN2N" }, 19278c2ecf20Sopenharmony_ci 19288c2ecf20Sopenharmony_ci { "INL VOL", NULL, "IN2P" }, 19298c2ecf20Sopenharmony_ci { "INR VOL", NULL, "IN2N" }, 19308c2ecf20Sopenharmony_ci 19318c2ecf20Sopenharmony_ci { "RECMIXL", "INL Switch", "INL VOL" }, 19328c2ecf20Sopenharmony_ci { "RECMIXL", "BST2 Switch", "BST2" }, 19338c2ecf20Sopenharmony_ci { "RECMIXL", "BST1 Switch", "BST1" }, 19348c2ecf20Sopenharmony_ci 19358c2ecf20Sopenharmony_ci { "RECMIXR", "INR Switch", "INR VOL" }, 19368c2ecf20Sopenharmony_ci { "RECMIXR", "BST2 Switch", "BST2" }, 19378c2ecf20Sopenharmony_ci { "RECMIXR", "BST1 Switch", "BST1" }, 19388c2ecf20Sopenharmony_ci 19398c2ecf20Sopenharmony_ci { "ADC 1", NULL, "RECMIXL" }, 19408c2ecf20Sopenharmony_ci { "ADC 1", NULL, "ADC 1 power" }, 19418c2ecf20Sopenharmony_ci { "ADC 1", NULL, "ADC clock" }, 19428c2ecf20Sopenharmony_ci { "ADC 2", NULL, "RECMIXR" }, 19438c2ecf20Sopenharmony_ci { "ADC 2", NULL, "ADC 2 power" }, 19448c2ecf20Sopenharmony_ci { "ADC 2", NULL, "ADC clock" }, 19458c2ecf20Sopenharmony_ci 19468c2ecf20Sopenharmony_ci { "DMIC L1", NULL, "DMIC CLK" }, 19478c2ecf20Sopenharmony_ci { "DMIC L1", NULL, "DMIC1 Power" }, 19488c2ecf20Sopenharmony_ci { "DMIC R1", NULL, "DMIC CLK" }, 19498c2ecf20Sopenharmony_ci { "DMIC R1", NULL, "DMIC1 Power" }, 19508c2ecf20Sopenharmony_ci { "DMIC L2", NULL, "DMIC CLK" }, 19518c2ecf20Sopenharmony_ci { "DMIC L2", NULL, "DMIC2 Power" }, 19528c2ecf20Sopenharmony_ci { "DMIC R2", NULL, "DMIC CLK" }, 19538c2ecf20Sopenharmony_ci { "DMIC R2", NULL, "DMIC2 Power" }, 19548c2ecf20Sopenharmony_ci { "DMIC L3", NULL, "DMIC CLK" }, 19558c2ecf20Sopenharmony_ci { "DMIC L3", NULL, "DMIC3 Power" }, 19568c2ecf20Sopenharmony_ci { "DMIC R3", NULL, "DMIC CLK" }, 19578c2ecf20Sopenharmony_ci { "DMIC R3", NULL, "DMIC3 Power" }, 19588c2ecf20Sopenharmony_ci 19598c2ecf20Sopenharmony_ci { "Stereo1 DMIC Mux", "DMIC1", "DMIC1" }, 19608c2ecf20Sopenharmony_ci { "Stereo1 DMIC Mux", "DMIC2", "DMIC2" }, 19618c2ecf20Sopenharmony_ci { "Stereo1 DMIC Mux", "DMIC3", "DMIC3" }, 19628c2ecf20Sopenharmony_ci 19638c2ecf20Sopenharmony_ci { "Stereo2 DMIC Mux", "DMIC1", "DMIC1" }, 19648c2ecf20Sopenharmony_ci { "Stereo2 DMIC Mux", "DMIC2", "DMIC2" }, 19658c2ecf20Sopenharmony_ci { "Stereo2 DMIC Mux", "DMIC3", "DMIC3" }, 19668c2ecf20Sopenharmony_ci 19678c2ecf20Sopenharmony_ci { "Mono DMIC L Mux", "DMIC1", "DMIC L1" }, 19688c2ecf20Sopenharmony_ci { "Mono DMIC L Mux", "DMIC2", "DMIC L2" }, 19698c2ecf20Sopenharmony_ci { "Mono DMIC L Mux", "DMIC3", "DMIC L3" }, 19708c2ecf20Sopenharmony_ci 19718c2ecf20Sopenharmony_ci { "Mono DMIC R Mux", "DMIC1", "DMIC R1" }, 19728c2ecf20Sopenharmony_ci { "Mono DMIC R Mux", "DMIC2", "DMIC R2" }, 19738c2ecf20Sopenharmony_ci { "Mono DMIC R Mux", "DMIC3", "DMIC R3" }, 19748c2ecf20Sopenharmony_ci 19758c2ecf20Sopenharmony_ci { "ADC 1_2", NULL, "ADC 1" }, 19768c2ecf20Sopenharmony_ci { "ADC 1_2", NULL, "ADC 2" }, 19778c2ecf20Sopenharmony_ci 19788c2ecf20Sopenharmony_ci { "Stereo1 ADC L2 Mux", "DMIC", "Stereo1 DMIC Mux" }, 19798c2ecf20Sopenharmony_ci { "Stereo1 ADC L2 Mux", "DAC MIX", "DAC MIXL" }, 19808c2ecf20Sopenharmony_ci { "Stereo1 ADC L1 Mux", "ADC", "ADC 1_2" }, 19818c2ecf20Sopenharmony_ci { "Stereo1 ADC L1 Mux", "DAC MIX", "DAC MIXL" }, 19828c2ecf20Sopenharmony_ci 19838c2ecf20Sopenharmony_ci { "Stereo1 ADC R1 Mux", "ADC", "ADC 1_2" }, 19848c2ecf20Sopenharmony_ci { "Stereo1 ADC R1 Mux", "DAC MIX", "DAC MIXR" }, 19858c2ecf20Sopenharmony_ci { "Stereo1 ADC R2 Mux", "DMIC", "Stereo1 DMIC Mux" }, 19868c2ecf20Sopenharmony_ci { "Stereo1 ADC R2 Mux", "DAC MIX", "DAC MIXR" }, 19878c2ecf20Sopenharmony_ci 19888c2ecf20Sopenharmony_ci { "Mono ADC L2 Mux", "DMIC", "Mono DMIC L Mux" }, 19898c2ecf20Sopenharmony_ci { "Mono ADC L2 Mux", "Mono DAC MIXL", "Mono DAC MIXL" }, 19908c2ecf20Sopenharmony_ci { "Mono ADC L1 Mux", "Mono DAC MIXL", "Mono DAC MIXL" }, 19918c2ecf20Sopenharmony_ci { "Mono ADC L1 Mux", "ADC1", "ADC 1" }, 19928c2ecf20Sopenharmony_ci 19938c2ecf20Sopenharmony_ci { "Mono ADC R1 Mux", "Mono DAC MIXR", "Mono DAC MIXR" }, 19948c2ecf20Sopenharmony_ci { "Mono ADC R1 Mux", "ADC2", "ADC 2" }, 19958c2ecf20Sopenharmony_ci { "Mono ADC R2 Mux", "DMIC", "Mono DMIC R Mux" }, 19968c2ecf20Sopenharmony_ci { "Mono ADC R2 Mux", "Mono DAC MIXR", "Mono DAC MIXR" }, 19978c2ecf20Sopenharmony_ci 19988c2ecf20Sopenharmony_ci { "Sto1 ADC MIXL", "ADC1 Switch", "Stereo1 ADC L1 Mux" }, 19998c2ecf20Sopenharmony_ci { "Sto1 ADC MIXL", "ADC2 Switch", "Stereo1 ADC L2 Mux" }, 20008c2ecf20Sopenharmony_ci { "Sto1 ADC MIXR", "ADC1 Switch", "Stereo1 ADC R1 Mux" }, 20018c2ecf20Sopenharmony_ci { "Sto1 ADC MIXR", "ADC2 Switch", "Stereo1 ADC R2 Mux" }, 20028c2ecf20Sopenharmony_ci 20038c2ecf20Sopenharmony_ci { "Stereo1 ADC MIXL", NULL, "Sto1 ADC MIXL" }, 20048c2ecf20Sopenharmony_ci { "Stereo1 ADC MIXL", NULL, "ADC Stereo1 Filter" }, 20058c2ecf20Sopenharmony_ci 20068c2ecf20Sopenharmony_ci { "Stereo1 ADC MIXR", NULL, "Sto1 ADC MIXR" }, 20078c2ecf20Sopenharmony_ci { "Stereo1 ADC MIXR", NULL, "ADC Stereo1 Filter" }, 20088c2ecf20Sopenharmony_ci { "ADC Stereo1 Filter", NULL, "PLL1", is_sys_clk_from_pll }, 20098c2ecf20Sopenharmony_ci 20108c2ecf20Sopenharmony_ci { "Mono ADC MIXL", "ADC1 Switch", "Mono ADC L1 Mux" }, 20118c2ecf20Sopenharmony_ci { "Mono ADC MIXL", "ADC2 Switch", "Mono ADC L2 Mux" }, 20128c2ecf20Sopenharmony_ci { "Mono ADC MIXL", NULL, "ADC Mono Left Filter" }, 20138c2ecf20Sopenharmony_ci { "ADC Mono Left Filter", NULL, "PLL1", is_sys_clk_from_pll }, 20148c2ecf20Sopenharmony_ci 20158c2ecf20Sopenharmony_ci { "Mono ADC MIXR", "ADC1 Switch", "Mono ADC R1 Mux" }, 20168c2ecf20Sopenharmony_ci { "Mono ADC MIXR", "ADC2 Switch", "Mono ADC R2 Mux" }, 20178c2ecf20Sopenharmony_ci { "Mono ADC MIXR", NULL, "ADC Mono Right Filter" }, 20188c2ecf20Sopenharmony_ci { "ADC Mono Right Filter", NULL, "PLL1", is_sys_clk_from_pll }, 20198c2ecf20Sopenharmony_ci 20208c2ecf20Sopenharmony_ci { "Stereo2 ADC L2 Mux", "DMIC", "Stereo2 DMIC Mux" }, 20218c2ecf20Sopenharmony_ci { "Stereo2 ADC L2 Mux", "DAC MIX", "DAC MIXL" }, 20228c2ecf20Sopenharmony_ci { "Stereo2 ADC L1 Mux", "ADC", "ADC 1_2" }, 20238c2ecf20Sopenharmony_ci { "Stereo2 ADC L1 Mux", "DAC MIX", "DAC MIXL" }, 20248c2ecf20Sopenharmony_ci 20258c2ecf20Sopenharmony_ci { "Stereo2 ADC R1 Mux", "ADC", "ADC 1_2" }, 20268c2ecf20Sopenharmony_ci { "Stereo2 ADC R1 Mux", "DAC MIX", "DAC MIXR" }, 20278c2ecf20Sopenharmony_ci { "Stereo2 ADC R2 Mux", "DMIC", "Stereo2 DMIC Mux" }, 20288c2ecf20Sopenharmony_ci { "Stereo2 ADC R2 Mux", "DAC MIX", "DAC MIXR" }, 20298c2ecf20Sopenharmony_ci 20308c2ecf20Sopenharmony_ci { "Sto2 ADC MIXL", "ADC1 Switch", "Stereo2 ADC L1 Mux" }, 20318c2ecf20Sopenharmony_ci { "Sto2 ADC MIXL", "ADC2 Switch", "Stereo2 ADC L2 Mux" }, 20328c2ecf20Sopenharmony_ci { "Sto2 ADC MIXR", "ADC1 Switch", "Stereo2 ADC R1 Mux" }, 20338c2ecf20Sopenharmony_ci { "Sto2 ADC MIXR", "ADC2 Switch", "Stereo2 ADC R2 Mux" }, 20348c2ecf20Sopenharmony_ci 20358c2ecf20Sopenharmony_ci { "Sto2 ADC LR MIX", NULL, "Sto2 ADC MIXL" }, 20368c2ecf20Sopenharmony_ci { "Sto2 ADC LR MIX", NULL, "Sto2 ADC MIXR" }, 20378c2ecf20Sopenharmony_ci 20388c2ecf20Sopenharmony_ci { "Stereo2 ADC LR Mux", "L", "Sto2 ADC MIXL" }, 20398c2ecf20Sopenharmony_ci { "Stereo2 ADC LR Mux", "LR", "Sto2 ADC LR MIX" }, 20408c2ecf20Sopenharmony_ci 20418c2ecf20Sopenharmony_ci { "Stereo2 ADC MIXL", NULL, "Stereo2 ADC LR Mux" }, 20428c2ecf20Sopenharmony_ci { "Stereo2 ADC MIXL", NULL, "ADC Stereo2 Filter" }, 20438c2ecf20Sopenharmony_ci 20448c2ecf20Sopenharmony_ci { "Stereo2 ADC MIXR", NULL, "Sto2 ADC MIXR" }, 20458c2ecf20Sopenharmony_ci { "Stereo2 ADC MIXR", NULL, "ADC Stereo2 Filter" }, 20468c2ecf20Sopenharmony_ci { "ADC Stereo2 Filter", NULL, "PLL1", is_sys_clk_from_pll }, 20478c2ecf20Sopenharmony_ci 20488c2ecf20Sopenharmony_ci { "VAD ADC Mux", "Sto1 ADC L", "Stereo1 ADC MIXL" }, 20498c2ecf20Sopenharmony_ci { "VAD ADC Mux", "Mono ADC L", "Mono ADC MIXL" }, 20508c2ecf20Sopenharmony_ci { "VAD ADC Mux", "Mono ADC R", "Mono ADC MIXR" }, 20518c2ecf20Sopenharmony_ci { "VAD ADC Mux", "Sto2 ADC L", "Sto2 ADC MIXL" }, 20528c2ecf20Sopenharmony_ci 20538c2ecf20Sopenharmony_ci { "VAD_ADC", NULL, "VAD ADC Mux" }, 20548c2ecf20Sopenharmony_ci 20558c2ecf20Sopenharmony_ci { "IF_ADC1", NULL, "Stereo1 ADC MIXL" }, 20568c2ecf20Sopenharmony_ci { "IF_ADC1", NULL, "Stereo1 ADC MIXR" }, 20578c2ecf20Sopenharmony_ci { "IF_ADC2", NULL, "Mono ADC MIXL" }, 20588c2ecf20Sopenharmony_ci { "IF_ADC2", NULL, "Mono ADC MIXR" }, 20598c2ecf20Sopenharmony_ci { "IF_ADC3", NULL, "Stereo2 ADC MIXL" }, 20608c2ecf20Sopenharmony_ci { "IF_ADC3", NULL, "Stereo2 ADC MIXR" }, 20618c2ecf20Sopenharmony_ci 20628c2ecf20Sopenharmony_ci { "IF1 ADC1 IN1 Mux", "IF_ADC1", "IF_ADC1" }, 20638c2ecf20Sopenharmony_ci { "IF1 ADC1 IN1 Mux", "IF1_ADC3", "IF1_ADC3" }, 20648c2ecf20Sopenharmony_ci 20658c2ecf20Sopenharmony_ci { "IF1 ADC1 IN2 Mux", "IF1_ADC1_IN1", "IF1 ADC1 IN1 Mux" }, 20668c2ecf20Sopenharmony_ci { "IF1 ADC1 IN2 Mux", "IF1_ADC4", "TxDP_ADC" }, 20678c2ecf20Sopenharmony_ci 20688c2ecf20Sopenharmony_ci { "IF1 ADC2 IN Mux", "IF_ADC2", "IF_ADC2" }, 20698c2ecf20Sopenharmony_ci { "IF1 ADC2 IN Mux", "VAD_ADC", "VAD_ADC" }, 20708c2ecf20Sopenharmony_ci 20718c2ecf20Sopenharmony_ci { "IF1 ADC2 IN1 Mux", "IF1_ADC2_IN", "IF1 ADC2 IN Mux" }, 20728c2ecf20Sopenharmony_ci { "IF1 ADC2 IN1 Mux", "IF1_ADC4", "TxDP_ADC" }, 20738c2ecf20Sopenharmony_ci 20748c2ecf20Sopenharmony_ci { "IF1_ADC1" , NULL, "IF1 ADC1 IN2 Mux" }, 20758c2ecf20Sopenharmony_ci { "IF1_ADC2" , NULL, "IF1 ADC2 IN1 Mux" }, 20768c2ecf20Sopenharmony_ci 20778c2ecf20Sopenharmony_ci { "Stereo1 ADC MIX", NULL, "Stereo1 ADC MIXL" }, 20788c2ecf20Sopenharmony_ci { "Stereo1 ADC MIX", NULL, "Stereo1 ADC MIXR" }, 20798c2ecf20Sopenharmony_ci { "Stereo2 ADC MIX", NULL, "Sto2 ADC MIXL" }, 20808c2ecf20Sopenharmony_ci { "Stereo2 ADC MIX", NULL, "Sto2 ADC MIXR" }, 20818c2ecf20Sopenharmony_ci { "Mono ADC MIX", NULL, "Mono ADC MIXL" }, 20828c2ecf20Sopenharmony_ci { "Mono ADC MIX", NULL, "Mono ADC MIXR" }, 20838c2ecf20Sopenharmony_ci 20848c2ecf20Sopenharmony_ci { "RxDP Mux", "IF2 DAC", "IF2 DAC" }, 20858c2ecf20Sopenharmony_ci { "RxDP Mux", "IF1 DAC", "IF1 DAC2" }, 20868c2ecf20Sopenharmony_ci { "RxDP Mux", "STO1 ADC Mixer", "Stereo1 ADC MIX" }, 20878c2ecf20Sopenharmony_ci { "RxDP Mux", "STO2 ADC Mixer", "Stereo2 ADC MIX" }, 20888c2ecf20Sopenharmony_ci { "RxDP Mux", "Mono ADC Mixer L", "Mono ADC MIXL" }, 20898c2ecf20Sopenharmony_ci { "RxDP Mux", "Mono ADC Mixer R", "Mono ADC MIXR" }, 20908c2ecf20Sopenharmony_ci { "RxDP Mux", "DAC1", "DAC MIX" }, 20918c2ecf20Sopenharmony_ci 20928c2ecf20Sopenharmony_ci { "TDM Data Mux", "Slot 0-1", "Stereo1 ADC MIX" }, 20938c2ecf20Sopenharmony_ci { "TDM Data Mux", "Slot 2-3", "Mono ADC MIX" }, 20948c2ecf20Sopenharmony_ci { "TDM Data Mux", "Slot 4-5", "Stereo2 ADC MIX" }, 20958c2ecf20Sopenharmony_ci { "TDM Data Mux", "Slot 6-7", "IF2 DAC" }, 20968c2ecf20Sopenharmony_ci 20978c2ecf20Sopenharmony_ci { "DSP UL Mux", "Bypass", "TDM Data Mux" }, 20988c2ecf20Sopenharmony_ci { "DSP UL Mux", NULL, "I2S DSP" }, 20998c2ecf20Sopenharmony_ci { "DSP DL Mux", "Bypass", "RxDP Mux" }, 21008c2ecf20Sopenharmony_ci { "DSP DL Mux", NULL, "I2S DSP" }, 21018c2ecf20Sopenharmony_ci 21028c2ecf20Sopenharmony_ci { "TxDP_ADC_L", NULL, "DSP UL Mux" }, 21038c2ecf20Sopenharmony_ci { "TxDP_ADC_R", NULL, "DSP UL Mux" }, 21048c2ecf20Sopenharmony_ci { "TxDC_DAC", NULL, "DSP DL Mux" }, 21058c2ecf20Sopenharmony_ci 21068c2ecf20Sopenharmony_ci { "TxDP_ADC", NULL, "TxDP_ADC_L" }, 21078c2ecf20Sopenharmony_ci { "TxDP_ADC", NULL, "TxDP_ADC_R" }, 21088c2ecf20Sopenharmony_ci 21098c2ecf20Sopenharmony_ci { "IF1 ADC", NULL, "I2S1" }, 21108c2ecf20Sopenharmony_ci { "IF1 ADC", NULL, "IF1_ADC1" }, 21118c2ecf20Sopenharmony_ci { "IF1 ADC", NULL, "IF1_ADC2" }, 21128c2ecf20Sopenharmony_ci { "IF1 ADC", NULL, "IF_ADC3" }, 21138c2ecf20Sopenharmony_ci { "IF1 ADC", NULL, "TxDP_ADC" }, 21148c2ecf20Sopenharmony_ci 21158c2ecf20Sopenharmony_ci { "IF2 ADC Mux", "IF_ADC1", "IF_ADC1" }, 21168c2ecf20Sopenharmony_ci { "IF2 ADC Mux", "IF_ADC2", "IF_ADC2" }, 21178c2ecf20Sopenharmony_ci { "IF2 ADC Mux", "IF_ADC3", "IF_ADC3" }, 21188c2ecf20Sopenharmony_ci { "IF2 ADC Mux", "TxDC_DAC", "TxDC_DAC" }, 21198c2ecf20Sopenharmony_ci { "IF2 ADC Mux", "TxDP_ADC", "TxDP_ADC" }, 21208c2ecf20Sopenharmony_ci { "IF2 ADC Mux", "VAD_ADC", "VAD_ADC" }, 21218c2ecf20Sopenharmony_ci 21228c2ecf20Sopenharmony_ci { "IF2 ADC L", NULL, "IF2 ADC Mux" }, 21238c2ecf20Sopenharmony_ci { "IF2 ADC R", NULL, "IF2 ADC Mux" }, 21248c2ecf20Sopenharmony_ci 21258c2ecf20Sopenharmony_ci { "IF2 ADC", NULL, "I2S2" }, 21268c2ecf20Sopenharmony_ci { "IF2 ADC", NULL, "IF2 ADC L" }, 21278c2ecf20Sopenharmony_ci { "IF2 ADC", NULL, "IF2 ADC R" }, 21288c2ecf20Sopenharmony_ci 21298c2ecf20Sopenharmony_ci { "AIF1TX", NULL, "IF1 ADC" }, 21308c2ecf20Sopenharmony_ci { "AIF2TX", NULL, "IF2 ADC" }, 21318c2ecf20Sopenharmony_ci 21328c2ecf20Sopenharmony_ci { "IF1 DAC1", NULL, "AIF1RX" }, 21338c2ecf20Sopenharmony_ci { "IF1 DAC2", NULL, "AIF1RX" }, 21348c2ecf20Sopenharmony_ci { "IF2 DAC", NULL, "AIF2RX" }, 21358c2ecf20Sopenharmony_ci 21368c2ecf20Sopenharmony_ci { "IF1 DAC1", NULL, "I2S1" }, 21378c2ecf20Sopenharmony_ci { "IF1 DAC2", NULL, "I2S1" }, 21388c2ecf20Sopenharmony_ci { "IF2 DAC", NULL, "I2S2" }, 21398c2ecf20Sopenharmony_ci 21408c2ecf20Sopenharmony_ci { "IF1 DAC2 L", NULL, "IF1 DAC2" }, 21418c2ecf20Sopenharmony_ci { "IF1 DAC2 R", NULL, "IF1 DAC2" }, 21428c2ecf20Sopenharmony_ci { "IF1 DAC1 L", NULL, "IF1 DAC1" }, 21438c2ecf20Sopenharmony_ci { "IF1 DAC1 R", NULL, "IF1 DAC1" }, 21448c2ecf20Sopenharmony_ci { "IF2 DAC L", NULL, "IF2 DAC" }, 21458c2ecf20Sopenharmony_ci { "IF2 DAC R", NULL, "IF2 DAC" }, 21468c2ecf20Sopenharmony_ci 21478c2ecf20Sopenharmony_ci { "DAC1 L Mux", "IF1 DAC", "IF1 DAC1 L" }, 21488c2ecf20Sopenharmony_ci { "DAC1 L Mux", "IF2 DAC", "IF2 DAC L" }, 21498c2ecf20Sopenharmony_ci 21508c2ecf20Sopenharmony_ci { "DAC1 R Mux", "IF1 DAC", "IF1 DAC1 R" }, 21518c2ecf20Sopenharmony_ci { "DAC1 R Mux", "IF2 DAC", "IF2 DAC R" }, 21528c2ecf20Sopenharmony_ci 21538c2ecf20Sopenharmony_ci { "DAC1 MIXL", "Stereo ADC Switch", "Stereo1 ADC MIXL" }, 21548c2ecf20Sopenharmony_ci { "DAC1 MIXL", "DAC1 Switch", "DAC1 L Mux" }, 21558c2ecf20Sopenharmony_ci { "DAC1 MIXL", NULL, "DAC Stereo1 Filter" }, 21568c2ecf20Sopenharmony_ci { "DAC1 MIXR", "Stereo ADC Switch", "Stereo1 ADC MIXR" }, 21578c2ecf20Sopenharmony_ci { "DAC1 MIXR", "DAC1 Switch", "DAC1 R Mux" }, 21588c2ecf20Sopenharmony_ci { "DAC1 MIXR", NULL, "DAC Stereo1 Filter" }, 21598c2ecf20Sopenharmony_ci 21608c2ecf20Sopenharmony_ci { "DAC Stereo1 Filter", NULL, "PLL1", is_sys_clk_from_pll }, 21618c2ecf20Sopenharmony_ci { "DAC Mono Left Filter", NULL, "PLL1", is_sys_clk_from_pll }, 21628c2ecf20Sopenharmony_ci { "DAC Mono Right Filter", NULL, "PLL1", is_sys_clk_from_pll }, 21638c2ecf20Sopenharmony_ci 21648c2ecf20Sopenharmony_ci { "DAC MIX", NULL, "DAC1 MIXL" }, 21658c2ecf20Sopenharmony_ci { "DAC MIX", NULL, "DAC1 MIXR" }, 21668c2ecf20Sopenharmony_ci 21678c2ecf20Sopenharmony_ci { "Audio DSP", NULL, "DAC1 MIXL" }, 21688c2ecf20Sopenharmony_ci { "Audio DSP", NULL, "DAC1 MIXR" }, 21698c2ecf20Sopenharmony_ci 21708c2ecf20Sopenharmony_ci { "DAC L2 Mux", "IF1 DAC", "IF1 DAC2 L" }, 21718c2ecf20Sopenharmony_ci { "DAC L2 Mux", "IF2 DAC", "IF2 DAC L" }, 21728c2ecf20Sopenharmony_ci { "DAC L2 Mux", "TxDC DAC", "TxDC_DAC" }, 21738c2ecf20Sopenharmony_ci { "DAC L2 Mux", "VAD_ADC", "VAD_ADC" }, 21748c2ecf20Sopenharmony_ci { "DAC L2 Volume", NULL, "DAC L2 Mux" }, 21758c2ecf20Sopenharmony_ci { "DAC L2 Volume", NULL, "DAC Mono Left Filter" }, 21768c2ecf20Sopenharmony_ci 21778c2ecf20Sopenharmony_ci { "DAC R2 Mux", "IF1 DAC", "IF1 DAC2 R" }, 21788c2ecf20Sopenharmony_ci { "DAC R2 Mux", "IF2 DAC", "IF2 DAC R" }, 21798c2ecf20Sopenharmony_ci { "DAC R2 Mux", "TxDC DAC", "TxDC_DAC" }, 21808c2ecf20Sopenharmony_ci { "DAC R2 Mux", "TxDP ADC", "TxDP_ADC" }, 21818c2ecf20Sopenharmony_ci { "DAC R2 Volume", NULL, "DAC R2 Mux" }, 21828c2ecf20Sopenharmony_ci { "DAC R2 Volume", NULL, "DAC Mono Right Filter" }, 21838c2ecf20Sopenharmony_ci 21848c2ecf20Sopenharmony_ci { "Stereo DAC MIXL", "DAC L1 Switch", "DAC1 MIXL" }, 21858c2ecf20Sopenharmony_ci { "Stereo DAC MIXL", "DAC R1 Switch", "DAC1 MIXR" }, 21868c2ecf20Sopenharmony_ci { "Stereo DAC MIXL", "DAC L2 Switch", "DAC L2 Volume" }, 21878c2ecf20Sopenharmony_ci { "Stereo DAC MIXL", NULL, "DAC Stereo1 Filter" }, 21888c2ecf20Sopenharmony_ci { "Stereo DAC MIXL", NULL, "DAC L1 Power" }, 21898c2ecf20Sopenharmony_ci { "Stereo DAC MIXR", "DAC R1 Switch", "DAC1 MIXR" }, 21908c2ecf20Sopenharmony_ci { "Stereo DAC MIXR", "DAC L1 Switch", "DAC1 MIXL" }, 21918c2ecf20Sopenharmony_ci { "Stereo DAC MIXR", "DAC R2 Switch", "DAC R2 Volume" }, 21928c2ecf20Sopenharmony_ci { "Stereo DAC MIXR", NULL, "DAC Stereo1 Filter" }, 21938c2ecf20Sopenharmony_ci { "Stereo DAC MIXR", NULL, "DAC R1 Power" }, 21948c2ecf20Sopenharmony_ci 21958c2ecf20Sopenharmony_ci { "Mono DAC MIXL", "DAC L1 Switch", "DAC1 MIXL" }, 21968c2ecf20Sopenharmony_ci { "Mono DAC MIXL", "DAC L2 Switch", "DAC L2 Volume" }, 21978c2ecf20Sopenharmony_ci { "Mono DAC MIXL", "DAC R2 Switch", "DAC R2 Volume" }, 21988c2ecf20Sopenharmony_ci { "Mono DAC MIXL", NULL, "DAC Mono Left Filter" }, 21998c2ecf20Sopenharmony_ci { "Mono DAC MIXR", "DAC R1 Switch", "DAC1 MIXR" }, 22008c2ecf20Sopenharmony_ci { "Mono DAC MIXR", "DAC R2 Switch", "DAC R2 Volume" }, 22018c2ecf20Sopenharmony_ci { "Mono DAC MIXR", "DAC L2 Switch", "DAC L2 Volume" }, 22028c2ecf20Sopenharmony_ci { "Mono DAC MIXR", NULL, "DAC Mono Right Filter" }, 22038c2ecf20Sopenharmony_ci 22048c2ecf20Sopenharmony_ci { "DAC MIXL", "Sto DAC Mix L Switch", "Stereo DAC MIXL" }, 22058c2ecf20Sopenharmony_ci { "DAC MIXL", "DAC L2 Switch", "DAC L2 Volume" }, 22068c2ecf20Sopenharmony_ci { "DAC MIXL", "DAC R2 Switch", "DAC R2 Volume" }, 22078c2ecf20Sopenharmony_ci { "DAC MIXR", "Sto DAC Mix R Switch", "Stereo DAC MIXR" }, 22088c2ecf20Sopenharmony_ci { "DAC MIXR", "DAC R2 Switch", "DAC R2 Volume" }, 22098c2ecf20Sopenharmony_ci { "DAC MIXR", "DAC L2 Switch", "DAC L2 Volume" }, 22108c2ecf20Sopenharmony_ci 22118c2ecf20Sopenharmony_ci { "DAC L1", NULL, "DAC L1 Power" }, 22128c2ecf20Sopenharmony_ci { "DAC L1", NULL, "Stereo DAC MIXL" }, 22138c2ecf20Sopenharmony_ci { "DAC R1", NULL, "DAC R1 Power" }, 22148c2ecf20Sopenharmony_ci { "DAC R1", NULL, "Stereo DAC MIXR" }, 22158c2ecf20Sopenharmony_ci { "DAC L2", NULL, "Mono DAC MIXL" }, 22168c2ecf20Sopenharmony_ci { "DAC R2", NULL, "Mono DAC MIXR" }, 22178c2ecf20Sopenharmony_ci 22188c2ecf20Sopenharmony_ci { "OUT MIXL", "BST1 Switch", "BST1" }, 22198c2ecf20Sopenharmony_ci { "OUT MIXL", "INL Switch", "INL VOL" }, 22208c2ecf20Sopenharmony_ci { "OUT MIXL", "DAC L2 Switch", "DAC L2" }, 22218c2ecf20Sopenharmony_ci { "OUT MIXL", "DAC L1 Switch", "DAC L1" }, 22228c2ecf20Sopenharmony_ci 22238c2ecf20Sopenharmony_ci { "OUT MIXR", "BST2 Switch", "BST2" }, 22248c2ecf20Sopenharmony_ci { "OUT MIXR", "INR Switch", "INR VOL" }, 22258c2ecf20Sopenharmony_ci { "OUT MIXR", "DAC R2 Switch", "DAC R2" }, 22268c2ecf20Sopenharmony_ci { "OUT MIXR", "DAC R1 Switch", "DAC R1" }, 22278c2ecf20Sopenharmony_ci 22288c2ecf20Sopenharmony_ci { "HPOVOL MIXL", "DAC1 Switch", "DAC L1" }, 22298c2ecf20Sopenharmony_ci { "HPOVOL MIXL", "INL Switch", "INL VOL" }, 22308c2ecf20Sopenharmony_ci { "HPOVOL MIXR", "DAC1 Switch", "DAC R1" }, 22318c2ecf20Sopenharmony_ci { "HPOVOL MIXR", "INR Switch", "INR VOL" }, 22328c2ecf20Sopenharmony_ci 22338c2ecf20Sopenharmony_ci { "DAC 2", NULL, "DAC L2" }, 22348c2ecf20Sopenharmony_ci { "DAC 2", NULL, "DAC R2" }, 22358c2ecf20Sopenharmony_ci { "DAC 1", NULL, "DAC L1" }, 22368c2ecf20Sopenharmony_ci { "DAC 1", NULL, "DAC R1" }, 22378c2ecf20Sopenharmony_ci { "HPOVOL", NULL, "HPOVOL MIXL" }, 22388c2ecf20Sopenharmony_ci { "HPOVOL", NULL, "HPOVOL MIXR" }, 22398c2ecf20Sopenharmony_ci { "HPO MIX", "DAC1 Switch", "DAC 1" }, 22408c2ecf20Sopenharmony_ci { "HPO MIX", "HPVOL Switch", "HPOVOL" }, 22418c2ecf20Sopenharmony_ci 22428c2ecf20Sopenharmony_ci { "LOUT MIX", "DAC L1 Switch", "DAC L1" }, 22438c2ecf20Sopenharmony_ci { "LOUT MIX", "DAC R1 Switch", "DAC R1" }, 22448c2ecf20Sopenharmony_ci { "LOUT MIX", "OUTMIX L Switch", "OUT MIXL" }, 22458c2ecf20Sopenharmony_ci { "LOUT MIX", "OUTMIX R Switch", "OUT MIXR" }, 22468c2ecf20Sopenharmony_ci 22478c2ecf20Sopenharmony_ci { "PDM1 L Mux", "Stereo DAC", "Stereo DAC MIXL" }, 22488c2ecf20Sopenharmony_ci { "PDM1 L Mux", "Mono DAC", "Mono DAC MIXL" }, 22498c2ecf20Sopenharmony_ci { "PDM1 L Mux", NULL, "PDM1 Power" }, 22508c2ecf20Sopenharmony_ci { "PDM1 R Mux", "Stereo DAC", "Stereo DAC MIXR" }, 22518c2ecf20Sopenharmony_ci { "PDM1 R Mux", "Mono DAC", "Mono DAC MIXR" }, 22528c2ecf20Sopenharmony_ci { "PDM1 R Mux", NULL, "PDM1 Power" }, 22538c2ecf20Sopenharmony_ci 22548c2ecf20Sopenharmony_ci { "HP Amp", NULL, "HPO MIX" }, 22558c2ecf20Sopenharmony_ci { "HP Amp", NULL, "Mic Det Power" }, 22568c2ecf20Sopenharmony_ci { "HPOL", NULL, "HP Amp" }, 22578c2ecf20Sopenharmony_ci { "HPOL", NULL, "HP L Amp" }, 22588c2ecf20Sopenharmony_ci { "HPOL", NULL, "Improve HP Amp Drv" }, 22598c2ecf20Sopenharmony_ci { "HPOR", NULL, "HP Amp" }, 22608c2ecf20Sopenharmony_ci { "HPOR", NULL, "HP R Amp" }, 22618c2ecf20Sopenharmony_ci { "HPOR", NULL, "Improve HP Amp Drv" }, 22628c2ecf20Sopenharmony_ci 22638c2ecf20Sopenharmony_ci { "LOUT Amp", NULL, "LOUT MIX" }, 22648c2ecf20Sopenharmony_ci { "LOUT L Playback", "Switch", "LOUT Amp" }, 22658c2ecf20Sopenharmony_ci { "LOUT R Playback", "Switch", "LOUT Amp" }, 22668c2ecf20Sopenharmony_ci { "LOUTL", NULL, "LOUT L Playback" }, 22678c2ecf20Sopenharmony_ci { "LOUTR", NULL, "LOUT R Playback" }, 22688c2ecf20Sopenharmony_ci { "LOUTL", NULL, "Improve HP Amp Drv" }, 22698c2ecf20Sopenharmony_ci { "LOUTR", NULL, "Improve HP Amp Drv" }, 22708c2ecf20Sopenharmony_ci}; 22718c2ecf20Sopenharmony_ci 22728c2ecf20Sopenharmony_cistatic const struct snd_soc_dapm_route rt5670_specific_dapm_routes[] = { 22738c2ecf20Sopenharmony_ci { "PDM2 L Mux", "Stereo DAC", "Stereo DAC MIXL" }, 22748c2ecf20Sopenharmony_ci { "PDM2 L Mux", "Mono DAC", "Mono DAC MIXL" }, 22758c2ecf20Sopenharmony_ci { "PDM2 L Mux", NULL, "PDM2 Power" }, 22768c2ecf20Sopenharmony_ci { "PDM2 R Mux", "Stereo DAC", "Stereo DAC MIXR" }, 22778c2ecf20Sopenharmony_ci { "PDM2 R Mux", "Mono DAC", "Mono DAC MIXR" }, 22788c2ecf20Sopenharmony_ci { "PDM2 R Mux", NULL, "PDM2 Power" }, 22798c2ecf20Sopenharmony_ci { "PDM1L", NULL, "PDM1 L Mux" }, 22808c2ecf20Sopenharmony_ci { "PDM1R", NULL, "PDM1 R Mux" }, 22818c2ecf20Sopenharmony_ci { "PDM2L", NULL, "PDM2 L Mux" }, 22828c2ecf20Sopenharmony_ci { "PDM2R", NULL, "PDM2 R Mux" }, 22838c2ecf20Sopenharmony_ci}; 22848c2ecf20Sopenharmony_ci 22858c2ecf20Sopenharmony_cistatic const struct snd_soc_dapm_route rt5672_specific_dapm_routes[] = { 22868c2ecf20Sopenharmony_ci { "SPO Amp", NULL, "PDM1 L Mux" }, 22878c2ecf20Sopenharmony_ci { "SPO Amp", NULL, "PDM1 R Mux" }, 22888c2ecf20Sopenharmony_ci { "SPOLP", NULL, "SPO Amp" }, 22898c2ecf20Sopenharmony_ci { "SPOLN", NULL, "SPO Amp" }, 22908c2ecf20Sopenharmony_ci { "SPORP", NULL, "SPO Amp" }, 22918c2ecf20Sopenharmony_ci { "SPORN", NULL, "SPO Amp" }, 22928c2ecf20Sopenharmony_ci}; 22938c2ecf20Sopenharmony_ci 22948c2ecf20Sopenharmony_cistatic int rt5670_hw_params(struct snd_pcm_substream *substream, 22958c2ecf20Sopenharmony_ci struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) 22968c2ecf20Sopenharmony_ci{ 22978c2ecf20Sopenharmony_ci struct snd_soc_component *component = dai->component; 22988c2ecf20Sopenharmony_ci struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); 22998c2ecf20Sopenharmony_ci unsigned int val_len = 0, val_clk, mask_clk; 23008c2ecf20Sopenharmony_ci int pre_div, bclk_ms, frame_size; 23018c2ecf20Sopenharmony_ci 23028c2ecf20Sopenharmony_ci rt5670->lrck[dai->id] = params_rate(params); 23038c2ecf20Sopenharmony_ci pre_div = rl6231_get_clk_info(rt5670->sysclk, rt5670->lrck[dai->id]); 23048c2ecf20Sopenharmony_ci if (pre_div < 0) { 23058c2ecf20Sopenharmony_ci dev_err(component->dev, "Unsupported clock setting %d for DAI %d\n", 23068c2ecf20Sopenharmony_ci rt5670->lrck[dai->id], dai->id); 23078c2ecf20Sopenharmony_ci return -EINVAL; 23088c2ecf20Sopenharmony_ci } 23098c2ecf20Sopenharmony_ci frame_size = snd_soc_params_to_frame_size(params); 23108c2ecf20Sopenharmony_ci if (frame_size < 0) { 23118c2ecf20Sopenharmony_ci dev_err(component->dev, "Unsupported frame size: %d\n", frame_size); 23128c2ecf20Sopenharmony_ci return -EINVAL; 23138c2ecf20Sopenharmony_ci } 23148c2ecf20Sopenharmony_ci bclk_ms = frame_size > 32; 23158c2ecf20Sopenharmony_ci rt5670->bclk[dai->id] = rt5670->lrck[dai->id] * (32 << bclk_ms); 23168c2ecf20Sopenharmony_ci 23178c2ecf20Sopenharmony_ci dev_dbg(dai->dev, "bclk is %dHz and lrck is %dHz\n", 23188c2ecf20Sopenharmony_ci rt5670->bclk[dai->id], rt5670->lrck[dai->id]); 23198c2ecf20Sopenharmony_ci dev_dbg(dai->dev, "bclk_ms is %d and pre_div is %d for iis %d\n", 23208c2ecf20Sopenharmony_ci bclk_ms, pre_div, dai->id); 23218c2ecf20Sopenharmony_ci 23228c2ecf20Sopenharmony_ci switch (params_width(params)) { 23238c2ecf20Sopenharmony_ci case 16: 23248c2ecf20Sopenharmony_ci break; 23258c2ecf20Sopenharmony_ci case 20: 23268c2ecf20Sopenharmony_ci val_len |= RT5670_I2S_DL_20; 23278c2ecf20Sopenharmony_ci break; 23288c2ecf20Sopenharmony_ci case 24: 23298c2ecf20Sopenharmony_ci val_len |= RT5670_I2S_DL_24; 23308c2ecf20Sopenharmony_ci break; 23318c2ecf20Sopenharmony_ci case 8: 23328c2ecf20Sopenharmony_ci val_len |= RT5670_I2S_DL_8; 23338c2ecf20Sopenharmony_ci break; 23348c2ecf20Sopenharmony_ci default: 23358c2ecf20Sopenharmony_ci return -EINVAL; 23368c2ecf20Sopenharmony_ci } 23378c2ecf20Sopenharmony_ci 23388c2ecf20Sopenharmony_ci switch (dai->id) { 23398c2ecf20Sopenharmony_ci case RT5670_AIF1: 23408c2ecf20Sopenharmony_ci mask_clk = RT5670_I2S_BCLK_MS1_MASK | RT5670_I2S_PD1_MASK; 23418c2ecf20Sopenharmony_ci val_clk = bclk_ms << RT5670_I2S_BCLK_MS1_SFT | 23428c2ecf20Sopenharmony_ci pre_div << RT5670_I2S_PD1_SFT; 23438c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, RT5670_I2S1_SDP, 23448c2ecf20Sopenharmony_ci RT5670_I2S_DL_MASK, val_len); 23458c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, RT5670_ADDA_CLK1, mask_clk, val_clk); 23468c2ecf20Sopenharmony_ci break; 23478c2ecf20Sopenharmony_ci case RT5670_AIF2: 23488c2ecf20Sopenharmony_ci mask_clk = RT5670_I2S_BCLK_MS2_MASK | RT5670_I2S_PD2_MASK; 23498c2ecf20Sopenharmony_ci val_clk = bclk_ms << RT5670_I2S_BCLK_MS2_SFT | 23508c2ecf20Sopenharmony_ci pre_div << RT5670_I2S_PD2_SFT; 23518c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, RT5670_I2S2_SDP, 23528c2ecf20Sopenharmony_ci RT5670_I2S_DL_MASK, val_len); 23538c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, RT5670_ADDA_CLK1, mask_clk, val_clk); 23548c2ecf20Sopenharmony_ci break; 23558c2ecf20Sopenharmony_ci default: 23568c2ecf20Sopenharmony_ci dev_err(component->dev, "Invalid dai->id: %d\n", dai->id); 23578c2ecf20Sopenharmony_ci return -EINVAL; 23588c2ecf20Sopenharmony_ci } 23598c2ecf20Sopenharmony_ci 23608c2ecf20Sopenharmony_ci return 0; 23618c2ecf20Sopenharmony_ci} 23628c2ecf20Sopenharmony_ci 23638c2ecf20Sopenharmony_cistatic int rt5670_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) 23648c2ecf20Sopenharmony_ci{ 23658c2ecf20Sopenharmony_ci struct snd_soc_component *component = dai->component; 23668c2ecf20Sopenharmony_ci struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); 23678c2ecf20Sopenharmony_ci unsigned int reg_val = 0; 23688c2ecf20Sopenharmony_ci 23698c2ecf20Sopenharmony_ci switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { 23708c2ecf20Sopenharmony_ci case SND_SOC_DAIFMT_CBM_CFM: 23718c2ecf20Sopenharmony_ci rt5670->master[dai->id] = 1; 23728c2ecf20Sopenharmony_ci break; 23738c2ecf20Sopenharmony_ci case SND_SOC_DAIFMT_CBS_CFS: 23748c2ecf20Sopenharmony_ci reg_val |= RT5670_I2S_MS_S; 23758c2ecf20Sopenharmony_ci rt5670->master[dai->id] = 0; 23768c2ecf20Sopenharmony_ci break; 23778c2ecf20Sopenharmony_ci default: 23788c2ecf20Sopenharmony_ci return -EINVAL; 23798c2ecf20Sopenharmony_ci } 23808c2ecf20Sopenharmony_ci 23818c2ecf20Sopenharmony_ci switch (fmt & SND_SOC_DAIFMT_INV_MASK) { 23828c2ecf20Sopenharmony_ci case SND_SOC_DAIFMT_NB_NF: 23838c2ecf20Sopenharmony_ci break; 23848c2ecf20Sopenharmony_ci case SND_SOC_DAIFMT_IB_NF: 23858c2ecf20Sopenharmony_ci reg_val |= RT5670_I2S_BP_INV; 23868c2ecf20Sopenharmony_ci break; 23878c2ecf20Sopenharmony_ci default: 23888c2ecf20Sopenharmony_ci return -EINVAL; 23898c2ecf20Sopenharmony_ci } 23908c2ecf20Sopenharmony_ci 23918c2ecf20Sopenharmony_ci switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { 23928c2ecf20Sopenharmony_ci case SND_SOC_DAIFMT_I2S: 23938c2ecf20Sopenharmony_ci break; 23948c2ecf20Sopenharmony_ci case SND_SOC_DAIFMT_LEFT_J: 23958c2ecf20Sopenharmony_ci reg_val |= RT5670_I2S_DF_LEFT; 23968c2ecf20Sopenharmony_ci break; 23978c2ecf20Sopenharmony_ci case SND_SOC_DAIFMT_DSP_A: 23988c2ecf20Sopenharmony_ci reg_val |= RT5670_I2S_DF_PCM_A; 23998c2ecf20Sopenharmony_ci break; 24008c2ecf20Sopenharmony_ci case SND_SOC_DAIFMT_DSP_B: 24018c2ecf20Sopenharmony_ci reg_val |= RT5670_I2S_DF_PCM_B; 24028c2ecf20Sopenharmony_ci break; 24038c2ecf20Sopenharmony_ci default: 24048c2ecf20Sopenharmony_ci return -EINVAL; 24058c2ecf20Sopenharmony_ci } 24068c2ecf20Sopenharmony_ci 24078c2ecf20Sopenharmony_ci switch (dai->id) { 24088c2ecf20Sopenharmony_ci case RT5670_AIF1: 24098c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, RT5670_I2S1_SDP, 24108c2ecf20Sopenharmony_ci RT5670_I2S_MS_MASK | RT5670_I2S_BP_MASK | 24118c2ecf20Sopenharmony_ci RT5670_I2S_DF_MASK, reg_val); 24128c2ecf20Sopenharmony_ci break; 24138c2ecf20Sopenharmony_ci case RT5670_AIF2: 24148c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, RT5670_I2S2_SDP, 24158c2ecf20Sopenharmony_ci RT5670_I2S_MS_MASK | RT5670_I2S_BP_MASK | 24168c2ecf20Sopenharmony_ci RT5670_I2S_DF_MASK, reg_val); 24178c2ecf20Sopenharmony_ci break; 24188c2ecf20Sopenharmony_ci default: 24198c2ecf20Sopenharmony_ci dev_err(component->dev, "Invalid dai->id: %d\n", dai->id); 24208c2ecf20Sopenharmony_ci return -EINVAL; 24218c2ecf20Sopenharmony_ci } 24228c2ecf20Sopenharmony_ci return 0; 24238c2ecf20Sopenharmony_ci} 24248c2ecf20Sopenharmony_ci 24258c2ecf20Sopenharmony_cistatic int rt5670_set_codec_sysclk(struct snd_soc_component *component, int clk_id, 24268c2ecf20Sopenharmony_ci int source, unsigned int freq, int dir) 24278c2ecf20Sopenharmony_ci{ 24288c2ecf20Sopenharmony_ci struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); 24298c2ecf20Sopenharmony_ci unsigned int reg_val = 0; 24308c2ecf20Sopenharmony_ci 24318c2ecf20Sopenharmony_ci switch (clk_id) { 24328c2ecf20Sopenharmony_ci case RT5670_SCLK_S_MCLK: 24338c2ecf20Sopenharmony_ci reg_val |= RT5670_SCLK_SRC_MCLK; 24348c2ecf20Sopenharmony_ci break; 24358c2ecf20Sopenharmony_ci case RT5670_SCLK_S_PLL1: 24368c2ecf20Sopenharmony_ci reg_val |= RT5670_SCLK_SRC_PLL1; 24378c2ecf20Sopenharmony_ci break; 24388c2ecf20Sopenharmony_ci case RT5670_SCLK_S_RCCLK: 24398c2ecf20Sopenharmony_ci reg_val |= RT5670_SCLK_SRC_RCCLK; 24408c2ecf20Sopenharmony_ci break; 24418c2ecf20Sopenharmony_ci default: 24428c2ecf20Sopenharmony_ci dev_err(component->dev, "Invalid clock id (%d)\n", clk_id); 24438c2ecf20Sopenharmony_ci return -EINVAL; 24448c2ecf20Sopenharmony_ci } 24458c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, RT5670_GLB_CLK, 24468c2ecf20Sopenharmony_ci RT5670_SCLK_SRC_MASK, reg_val); 24478c2ecf20Sopenharmony_ci rt5670->sysclk = freq; 24488c2ecf20Sopenharmony_ci if (clk_id != RT5670_SCLK_S_RCCLK) 24498c2ecf20Sopenharmony_ci rt5670->sysclk_src = clk_id; 24508c2ecf20Sopenharmony_ci 24518c2ecf20Sopenharmony_ci dev_dbg(component->dev, "Sysclk : %dHz clock id : %d\n", freq, clk_id); 24528c2ecf20Sopenharmony_ci 24538c2ecf20Sopenharmony_ci return 0; 24548c2ecf20Sopenharmony_ci} 24558c2ecf20Sopenharmony_ci 24568c2ecf20Sopenharmony_cistatic int rt5670_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, 24578c2ecf20Sopenharmony_ci unsigned int freq_in, unsigned int freq_out) 24588c2ecf20Sopenharmony_ci{ 24598c2ecf20Sopenharmony_ci struct snd_soc_component *component = dai->component; 24608c2ecf20Sopenharmony_ci struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); 24618c2ecf20Sopenharmony_ci struct rl6231_pll_code pll_code; 24628c2ecf20Sopenharmony_ci int ret; 24638c2ecf20Sopenharmony_ci 24648c2ecf20Sopenharmony_ci if (source == rt5670->pll_src && freq_in == rt5670->pll_in && 24658c2ecf20Sopenharmony_ci freq_out == rt5670->pll_out) 24668c2ecf20Sopenharmony_ci return 0; 24678c2ecf20Sopenharmony_ci 24688c2ecf20Sopenharmony_ci if (!freq_in || !freq_out) { 24698c2ecf20Sopenharmony_ci dev_dbg(component->dev, "PLL disabled\n"); 24708c2ecf20Sopenharmony_ci 24718c2ecf20Sopenharmony_ci rt5670->pll_in = 0; 24728c2ecf20Sopenharmony_ci rt5670->pll_out = 0; 24738c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, RT5670_GLB_CLK, 24748c2ecf20Sopenharmony_ci RT5670_SCLK_SRC_MASK, RT5670_SCLK_SRC_MCLK); 24758c2ecf20Sopenharmony_ci return 0; 24768c2ecf20Sopenharmony_ci } 24778c2ecf20Sopenharmony_ci 24788c2ecf20Sopenharmony_ci switch (source) { 24798c2ecf20Sopenharmony_ci case RT5670_PLL1_S_MCLK: 24808c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, RT5670_GLB_CLK, 24818c2ecf20Sopenharmony_ci RT5670_PLL1_SRC_MASK, RT5670_PLL1_SRC_MCLK); 24828c2ecf20Sopenharmony_ci break; 24838c2ecf20Sopenharmony_ci case RT5670_PLL1_S_BCLK1: 24848c2ecf20Sopenharmony_ci case RT5670_PLL1_S_BCLK2: 24858c2ecf20Sopenharmony_ci case RT5670_PLL1_S_BCLK3: 24868c2ecf20Sopenharmony_ci case RT5670_PLL1_S_BCLK4: 24878c2ecf20Sopenharmony_ci switch (dai->id) { 24888c2ecf20Sopenharmony_ci case RT5670_AIF1: 24898c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, RT5670_GLB_CLK, 24908c2ecf20Sopenharmony_ci RT5670_PLL1_SRC_MASK, RT5670_PLL1_SRC_BCLK1); 24918c2ecf20Sopenharmony_ci break; 24928c2ecf20Sopenharmony_ci case RT5670_AIF2: 24938c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, RT5670_GLB_CLK, 24948c2ecf20Sopenharmony_ci RT5670_PLL1_SRC_MASK, RT5670_PLL1_SRC_BCLK2); 24958c2ecf20Sopenharmony_ci break; 24968c2ecf20Sopenharmony_ci default: 24978c2ecf20Sopenharmony_ci dev_err(component->dev, "Invalid dai->id: %d\n", dai->id); 24988c2ecf20Sopenharmony_ci return -EINVAL; 24998c2ecf20Sopenharmony_ci } 25008c2ecf20Sopenharmony_ci break; 25018c2ecf20Sopenharmony_ci default: 25028c2ecf20Sopenharmony_ci dev_err(component->dev, "Unknown PLL source %d\n", source); 25038c2ecf20Sopenharmony_ci return -EINVAL; 25048c2ecf20Sopenharmony_ci } 25058c2ecf20Sopenharmony_ci 25068c2ecf20Sopenharmony_ci ret = rl6231_pll_calc(freq_in, freq_out, &pll_code); 25078c2ecf20Sopenharmony_ci if (ret < 0) { 25088c2ecf20Sopenharmony_ci dev_err(component->dev, "Unsupport input clock %d\n", freq_in); 25098c2ecf20Sopenharmony_ci return ret; 25108c2ecf20Sopenharmony_ci } 25118c2ecf20Sopenharmony_ci 25128c2ecf20Sopenharmony_ci dev_dbg(component->dev, "bypass=%d m=%d n=%d k=%d\n", 25138c2ecf20Sopenharmony_ci pll_code.m_bp, (pll_code.m_bp ? 0 : pll_code.m_code), 25148c2ecf20Sopenharmony_ci pll_code.n_code, pll_code.k_code); 25158c2ecf20Sopenharmony_ci 25168c2ecf20Sopenharmony_ci snd_soc_component_write(component, RT5670_PLL_CTRL1, 25178c2ecf20Sopenharmony_ci pll_code.n_code << RT5670_PLL_N_SFT | pll_code.k_code); 25188c2ecf20Sopenharmony_ci snd_soc_component_write(component, RT5670_PLL_CTRL2, 25198c2ecf20Sopenharmony_ci (pll_code.m_bp ? 0 : pll_code.m_code) << RT5670_PLL_M_SFT | 25208c2ecf20Sopenharmony_ci pll_code.m_bp << RT5670_PLL_M_BP_SFT); 25218c2ecf20Sopenharmony_ci 25228c2ecf20Sopenharmony_ci rt5670->pll_in = freq_in; 25238c2ecf20Sopenharmony_ci rt5670->pll_out = freq_out; 25248c2ecf20Sopenharmony_ci rt5670->pll_src = source; 25258c2ecf20Sopenharmony_ci 25268c2ecf20Sopenharmony_ci return 0; 25278c2ecf20Sopenharmony_ci} 25288c2ecf20Sopenharmony_ci 25298c2ecf20Sopenharmony_cistatic int rt5670_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, 25308c2ecf20Sopenharmony_ci unsigned int rx_mask, int slots, int slot_width) 25318c2ecf20Sopenharmony_ci{ 25328c2ecf20Sopenharmony_ci struct snd_soc_component *component = dai->component; 25338c2ecf20Sopenharmony_ci unsigned int val = 0; 25348c2ecf20Sopenharmony_ci 25358c2ecf20Sopenharmony_ci if (rx_mask || tx_mask) 25368c2ecf20Sopenharmony_ci val |= (1 << 14); 25378c2ecf20Sopenharmony_ci 25388c2ecf20Sopenharmony_ci switch (slots) { 25398c2ecf20Sopenharmony_ci case 4: 25408c2ecf20Sopenharmony_ci val |= (1 << 12); 25418c2ecf20Sopenharmony_ci break; 25428c2ecf20Sopenharmony_ci case 6: 25438c2ecf20Sopenharmony_ci val |= (2 << 12); 25448c2ecf20Sopenharmony_ci break; 25458c2ecf20Sopenharmony_ci case 8: 25468c2ecf20Sopenharmony_ci val |= (3 << 12); 25478c2ecf20Sopenharmony_ci break; 25488c2ecf20Sopenharmony_ci case 2: 25498c2ecf20Sopenharmony_ci break; 25508c2ecf20Sopenharmony_ci default: 25518c2ecf20Sopenharmony_ci return -EINVAL; 25528c2ecf20Sopenharmony_ci } 25538c2ecf20Sopenharmony_ci 25548c2ecf20Sopenharmony_ci switch (slot_width) { 25558c2ecf20Sopenharmony_ci case 20: 25568c2ecf20Sopenharmony_ci val |= (1 << 10); 25578c2ecf20Sopenharmony_ci break; 25588c2ecf20Sopenharmony_ci case 24: 25598c2ecf20Sopenharmony_ci val |= (2 << 10); 25608c2ecf20Sopenharmony_ci break; 25618c2ecf20Sopenharmony_ci case 32: 25628c2ecf20Sopenharmony_ci val |= (3 << 10); 25638c2ecf20Sopenharmony_ci break; 25648c2ecf20Sopenharmony_ci case 16: 25658c2ecf20Sopenharmony_ci break; 25668c2ecf20Sopenharmony_ci default: 25678c2ecf20Sopenharmony_ci return -EINVAL; 25688c2ecf20Sopenharmony_ci } 25698c2ecf20Sopenharmony_ci 25708c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, RT5670_TDM_CTRL_1, 0x7c00, val); 25718c2ecf20Sopenharmony_ci 25728c2ecf20Sopenharmony_ci return 0; 25738c2ecf20Sopenharmony_ci} 25748c2ecf20Sopenharmony_ci 25758c2ecf20Sopenharmony_cistatic int rt5670_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio) 25768c2ecf20Sopenharmony_ci{ 25778c2ecf20Sopenharmony_ci struct snd_soc_component *component = dai->component; 25788c2ecf20Sopenharmony_ci 25798c2ecf20Sopenharmony_ci dev_dbg(component->dev, "%s ratio=%d\n", __func__, ratio); 25808c2ecf20Sopenharmony_ci if (dai->id != RT5670_AIF1) 25818c2ecf20Sopenharmony_ci return 0; 25828c2ecf20Sopenharmony_ci 25838c2ecf20Sopenharmony_ci if ((ratio % 50) == 0) 25848c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, RT5670_GEN_CTRL3, 25858c2ecf20Sopenharmony_ci RT5670_TDM_DATA_MODE_SEL, RT5670_TDM_DATA_MODE_50FS); 25868c2ecf20Sopenharmony_ci else 25878c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, RT5670_GEN_CTRL3, 25888c2ecf20Sopenharmony_ci RT5670_TDM_DATA_MODE_SEL, RT5670_TDM_DATA_MODE_NOR); 25898c2ecf20Sopenharmony_ci 25908c2ecf20Sopenharmony_ci return 0; 25918c2ecf20Sopenharmony_ci} 25928c2ecf20Sopenharmony_ci 25938c2ecf20Sopenharmony_cistatic int rt5670_set_bias_level(struct snd_soc_component *component, 25948c2ecf20Sopenharmony_ci enum snd_soc_bias_level level) 25958c2ecf20Sopenharmony_ci{ 25968c2ecf20Sopenharmony_ci struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); 25978c2ecf20Sopenharmony_ci 25988c2ecf20Sopenharmony_ci switch (level) { 25998c2ecf20Sopenharmony_ci case SND_SOC_BIAS_PREPARE: 26008c2ecf20Sopenharmony_ci if (SND_SOC_BIAS_STANDBY == snd_soc_component_get_bias_level(component)) { 26018c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, RT5670_PWR_ANLG1, 26028c2ecf20Sopenharmony_ci RT5670_PWR_VREF1 | RT5670_PWR_MB | 26038c2ecf20Sopenharmony_ci RT5670_PWR_BG | RT5670_PWR_VREF2, 26048c2ecf20Sopenharmony_ci RT5670_PWR_VREF1 | RT5670_PWR_MB | 26058c2ecf20Sopenharmony_ci RT5670_PWR_BG | RT5670_PWR_VREF2); 26068c2ecf20Sopenharmony_ci mdelay(10); 26078c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, RT5670_PWR_ANLG1, 26088c2ecf20Sopenharmony_ci RT5670_PWR_FV1 | RT5670_PWR_FV2, 26098c2ecf20Sopenharmony_ci RT5670_PWR_FV1 | RT5670_PWR_FV2); 26108c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, RT5670_CHARGE_PUMP, 26118c2ecf20Sopenharmony_ci RT5670_OSW_L_MASK | RT5670_OSW_R_MASK, 26128c2ecf20Sopenharmony_ci RT5670_OSW_L_DIS | RT5670_OSW_R_DIS); 26138c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, RT5670_DIG_MISC, 0x1, 0x1); 26148c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, RT5670_PWR_ANLG1, 26158c2ecf20Sopenharmony_ci RT5670_LDO_SEL_MASK, 0x5); 26168c2ecf20Sopenharmony_ci } 26178c2ecf20Sopenharmony_ci break; 26188c2ecf20Sopenharmony_ci case SND_SOC_BIAS_STANDBY: 26198c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, RT5670_PWR_ANLG1, 26208c2ecf20Sopenharmony_ci RT5670_PWR_VREF1 | RT5670_PWR_VREF2 | 26218c2ecf20Sopenharmony_ci RT5670_PWR_FV1 | RT5670_PWR_FV2, 0); 26228c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, RT5670_PWR_ANLG1, 26238c2ecf20Sopenharmony_ci RT5670_LDO_SEL_MASK, 0x3); 26248c2ecf20Sopenharmony_ci break; 26258c2ecf20Sopenharmony_ci case SND_SOC_BIAS_OFF: 26268c2ecf20Sopenharmony_ci if (rt5670->jd_mode) 26278c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, RT5670_PWR_ANLG1, 26288c2ecf20Sopenharmony_ci RT5670_PWR_VREF1 | RT5670_PWR_MB | 26298c2ecf20Sopenharmony_ci RT5670_PWR_BG | RT5670_PWR_VREF2 | 26308c2ecf20Sopenharmony_ci RT5670_PWR_FV1 | RT5670_PWR_FV2, 26318c2ecf20Sopenharmony_ci RT5670_PWR_MB | RT5670_PWR_BG); 26328c2ecf20Sopenharmony_ci else 26338c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, RT5670_PWR_ANLG1, 26348c2ecf20Sopenharmony_ci RT5670_PWR_VREF1 | RT5670_PWR_MB | 26358c2ecf20Sopenharmony_ci RT5670_PWR_BG | RT5670_PWR_VREF2 | 26368c2ecf20Sopenharmony_ci RT5670_PWR_FV1 | RT5670_PWR_FV2, 0); 26378c2ecf20Sopenharmony_ci 26388c2ecf20Sopenharmony_ci snd_soc_component_update_bits(component, RT5670_DIG_MISC, 0x1, 0x0); 26398c2ecf20Sopenharmony_ci break; 26408c2ecf20Sopenharmony_ci 26418c2ecf20Sopenharmony_ci default: 26428c2ecf20Sopenharmony_ci break; 26438c2ecf20Sopenharmony_ci } 26448c2ecf20Sopenharmony_ci 26458c2ecf20Sopenharmony_ci return 0; 26468c2ecf20Sopenharmony_ci} 26478c2ecf20Sopenharmony_ci 26488c2ecf20Sopenharmony_cistatic int rt5670_probe(struct snd_soc_component *component) 26498c2ecf20Sopenharmony_ci{ 26508c2ecf20Sopenharmony_ci struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); 26518c2ecf20Sopenharmony_ci struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); 26528c2ecf20Sopenharmony_ci 26538c2ecf20Sopenharmony_ci switch (snd_soc_component_read(component, RT5670_RESET) & RT5670_ID_MASK) { 26548c2ecf20Sopenharmony_ci case RT5670_ID_5670: 26558c2ecf20Sopenharmony_ci case RT5670_ID_5671: 26568c2ecf20Sopenharmony_ci snd_soc_dapm_new_controls(dapm, 26578c2ecf20Sopenharmony_ci rt5670_specific_dapm_widgets, 26588c2ecf20Sopenharmony_ci ARRAY_SIZE(rt5670_specific_dapm_widgets)); 26598c2ecf20Sopenharmony_ci snd_soc_dapm_add_routes(dapm, 26608c2ecf20Sopenharmony_ci rt5670_specific_dapm_routes, 26618c2ecf20Sopenharmony_ci ARRAY_SIZE(rt5670_specific_dapm_routes)); 26628c2ecf20Sopenharmony_ci break; 26638c2ecf20Sopenharmony_ci case RT5670_ID_5672: 26648c2ecf20Sopenharmony_ci snd_soc_dapm_new_controls(dapm, 26658c2ecf20Sopenharmony_ci rt5672_specific_dapm_widgets, 26668c2ecf20Sopenharmony_ci ARRAY_SIZE(rt5672_specific_dapm_widgets)); 26678c2ecf20Sopenharmony_ci snd_soc_dapm_add_routes(dapm, 26688c2ecf20Sopenharmony_ci rt5672_specific_dapm_routes, 26698c2ecf20Sopenharmony_ci ARRAY_SIZE(rt5672_specific_dapm_routes)); 26708c2ecf20Sopenharmony_ci break; 26718c2ecf20Sopenharmony_ci default: 26728c2ecf20Sopenharmony_ci dev_err(component->dev, 26738c2ecf20Sopenharmony_ci "The driver is for RT5670 RT5671 or RT5672 only\n"); 26748c2ecf20Sopenharmony_ci return -ENODEV; 26758c2ecf20Sopenharmony_ci } 26768c2ecf20Sopenharmony_ci rt5670->component = component; 26778c2ecf20Sopenharmony_ci 26788c2ecf20Sopenharmony_ci return 0; 26798c2ecf20Sopenharmony_ci} 26808c2ecf20Sopenharmony_ci 26818c2ecf20Sopenharmony_cistatic void rt5670_remove(struct snd_soc_component *component) 26828c2ecf20Sopenharmony_ci{ 26838c2ecf20Sopenharmony_ci struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); 26848c2ecf20Sopenharmony_ci 26858c2ecf20Sopenharmony_ci regmap_write(rt5670->regmap, RT5670_RESET, 0); 26868c2ecf20Sopenharmony_ci snd_soc_jack_free_gpios(rt5670->jack, 1, &rt5670->hp_gpio); 26878c2ecf20Sopenharmony_ci} 26888c2ecf20Sopenharmony_ci 26898c2ecf20Sopenharmony_ci#ifdef CONFIG_PM 26908c2ecf20Sopenharmony_cistatic int rt5670_suspend(struct snd_soc_component *component) 26918c2ecf20Sopenharmony_ci{ 26928c2ecf20Sopenharmony_ci struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); 26938c2ecf20Sopenharmony_ci 26948c2ecf20Sopenharmony_ci regcache_cache_only(rt5670->regmap, true); 26958c2ecf20Sopenharmony_ci regcache_mark_dirty(rt5670->regmap); 26968c2ecf20Sopenharmony_ci return 0; 26978c2ecf20Sopenharmony_ci} 26988c2ecf20Sopenharmony_ci 26998c2ecf20Sopenharmony_cistatic int rt5670_resume(struct snd_soc_component *component) 27008c2ecf20Sopenharmony_ci{ 27018c2ecf20Sopenharmony_ci struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); 27028c2ecf20Sopenharmony_ci 27038c2ecf20Sopenharmony_ci regcache_cache_only(rt5670->regmap, false); 27048c2ecf20Sopenharmony_ci regcache_sync(rt5670->regmap); 27058c2ecf20Sopenharmony_ci 27068c2ecf20Sopenharmony_ci return 0; 27078c2ecf20Sopenharmony_ci} 27088c2ecf20Sopenharmony_ci#else 27098c2ecf20Sopenharmony_ci#define rt5670_suspend NULL 27108c2ecf20Sopenharmony_ci#define rt5670_resume NULL 27118c2ecf20Sopenharmony_ci#endif 27128c2ecf20Sopenharmony_ci 27138c2ecf20Sopenharmony_ci#define RT5670_STEREO_RATES SNDRV_PCM_RATE_8000_96000 27148c2ecf20Sopenharmony_ci#define RT5670_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \ 27158c2ecf20Sopenharmony_ci SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S8) 27168c2ecf20Sopenharmony_ci 27178c2ecf20Sopenharmony_cistatic const struct snd_soc_dai_ops rt5670_aif_dai_ops = { 27188c2ecf20Sopenharmony_ci .hw_params = rt5670_hw_params, 27198c2ecf20Sopenharmony_ci .set_fmt = rt5670_set_dai_fmt, 27208c2ecf20Sopenharmony_ci .set_tdm_slot = rt5670_set_tdm_slot, 27218c2ecf20Sopenharmony_ci .set_pll = rt5670_set_dai_pll, 27228c2ecf20Sopenharmony_ci .set_bclk_ratio = rt5670_set_bclk_ratio, 27238c2ecf20Sopenharmony_ci}; 27248c2ecf20Sopenharmony_ci 27258c2ecf20Sopenharmony_cistatic struct snd_soc_dai_driver rt5670_dai[] = { 27268c2ecf20Sopenharmony_ci { 27278c2ecf20Sopenharmony_ci .name = "rt5670-aif1", 27288c2ecf20Sopenharmony_ci .id = RT5670_AIF1, 27298c2ecf20Sopenharmony_ci .playback = { 27308c2ecf20Sopenharmony_ci .stream_name = "AIF1 Playback", 27318c2ecf20Sopenharmony_ci .channels_min = 1, 27328c2ecf20Sopenharmony_ci .channels_max = 2, 27338c2ecf20Sopenharmony_ci .rates = RT5670_STEREO_RATES, 27348c2ecf20Sopenharmony_ci .formats = RT5670_FORMATS, 27358c2ecf20Sopenharmony_ci }, 27368c2ecf20Sopenharmony_ci .capture = { 27378c2ecf20Sopenharmony_ci .stream_name = "AIF1 Capture", 27388c2ecf20Sopenharmony_ci .channels_min = 1, 27398c2ecf20Sopenharmony_ci .channels_max = 2, 27408c2ecf20Sopenharmony_ci .rates = RT5670_STEREO_RATES, 27418c2ecf20Sopenharmony_ci .formats = RT5670_FORMATS, 27428c2ecf20Sopenharmony_ci }, 27438c2ecf20Sopenharmony_ci .ops = &rt5670_aif_dai_ops, 27448c2ecf20Sopenharmony_ci .symmetric_rates = 1, 27458c2ecf20Sopenharmony_ci }, 27468c2ecf20Sopenharmony_ci { 27478c2ecf20Sopenharmony_ci .name = "rt5670-aif2", 27488c2ecf20Sopenharmony_ci .id = RT5670_AIF2, 27498c2ecf20Sopenharmony_ci .playback = { 27508c2ecf20Sopenharmony_ci .stream_name = "AIF2 Playback", 27518c2ecf20Sopenharmony_ci .channels_min = 1, 27528c2ecf20Sopenharmony_ci .channels_max = 2, 27538c2ecf20Sopenharmony_ci .rates = RT5670_STEREO_RATES, 27548c2ecf20Sopenharmony_ci .formats = RT5670_FORMATS, 27558c2ecf20Sopenharmony_ci }, 27568c2ecf20Sopenharmony_ci .capture = { 27578c2ecf20Sopenharmony_ci .stream_name = "AIF2 Capture", 27588c2ecf20Sopenharmony_ci .channels_min = 1, 27598c2ecf20Sopenharmony_ci .channels_max = 2, 27608c2ecf20Sopenharmony_ci .rates = RT5670_STEREO_RATES, 27618c2ecf20Sopenharmony_ci .formats = RT5670_FORMATS, 27628c2ecf20Sopenharmony_ci }, 27638c2ecf20Sopenharmony_ci .ops = &rt5670_aif_dai_ops, 27648c2ecf20Sopenharmony_ci .symmetric_rates = 1, 27658c2ecf20Sopenharmony_ci }, 27668c2ecf20Sopenharmony_ci}; 27678c2ecf20Sopenharmony_ci 27688c2ecf20Sopenharmony_cistatic const struct snd_soc_component_driver soc_component_dev_rt5670 = { 27698c2ecf20Sopenharmony_ci .probe = rt5670_probe, 27708c2ecf20Sopenharmony_ci .remove = rt5670_remove, 27718c2ecf20Sopenharmony_ci .suspend = rt5670_suspend, 27728c2ecf20Sopenharmony_ci .resume = rt5670_resume, 27738c2ecf20Sopenharmony_ci .set_bias_level = rt5670_set_bias_level, 27748c2ecf20Sopenharmony_ci .set_sysclk = rt5670_set_codec_sysclk, 27758c2ecf20Sopenharmony_ci .controls = rt5670_snd_controls, 27768c2ecf20Sopenharmony_ci .num_controls = ARRAY_SIZE(rt5670_snd_controls), 27778c2ecf20Sopenharmony_ci .dapm_widgets = rt5670_dapm_widgets, 27788c2ecf20Sopenharmony_ci .num_dapm_widgets = ARRAY_SIZE(rt5670_dapm_widgets), 27798c2ecf20Sopenharmony_ci .dapm_routes = rt5670_dapm_routes, 27808c2ecf20Sopenharmony_ci .num_dapm_routes = ARRAY_SIZE(rt5670_dapm_routes), 27818c2ecf20Sopenharmony_ci .use_pmdown_time = 1, 27828c2ecf20Sopenharmony_ci .endianness = 1, 27838c2ecf20Sopenharmony_ci .non_legacy_dai_naming = 1, 27848c2ecf20Sopenharmony_ci}; 27858c2ecf20Sopenharmony_ci 27868c2ecf20Sopenharmony_cistatic const struct regmap_config rt5670_regmap = { 27878c2ecf20Sopenharmony_ci .reg_bits = 8, 27888c2ecf20Sopenharmony_ci .val_bits = 16, 27898c2ecf20Sopenharmony_ci .use_single_read = true, 27908c2ecf20Sopenharmony_ci .use_single_write = true, 27918c2ecf20Sopenharmony_ci .max_register = RT5670_VENDOR_ID2 + 1 + (ARRAY_SIZE(rt5670_ranges) * 27928c2ecf20Sopenharmony_ci RT5670_PR_SPACING), 27938c2ecf20Sopenharmony_ci .volatile_reg = rt5670_volatile_register, 27948c2ecf20Sopenharmony_ci .readable_reg = rt5670_readable_register, 27958c2ecf20Sopenharmony_ci .cache_type = REGCACHE_RBTREE, 27968c2ecf20Sopenharmony_ci .reg_defaults = rt5670_reg, 27978c2ecf20Sopenharmony_ci .num_reg_defaults = ARRAY_SIZE(rt5670_reg), 27988c2ecf20Sopenharmony_ci .ranges = rt5670_ranges, 27998c2ecf20Sopenharmony_ci .num_ranges = ARRAY_SIZE(rt5670_ranges), 28008c2ecf20Sopenharmony_ci}; 28018c2ecf20Sopenharmony_ci 28028c2ecf20Sopenharmony_cistatic const struct i2c_device_id rt5670_i2c_id[] = { 28038c2ecf20Sopenharmony_ci { "rt5670", 0 }, 28048c2ecf20Sopenharmony_ci { "rt5671", 0 }, 28058c2ecf20Sopenharmony_ci { "rt5672", 0 }, 28068c2ecf20Sopenharmony_ci { } 28078c2ecf20Sopenharmony_ci}; 28088c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(i2c, rt5670_i2c_id); 28098c2ecf20Sopenharmony_ci 28108c2ecf20Sopenharmony_ci#ifdef CONFIG_ACPI 28118c2ecf20Sopenharmony_cistatic const struct acpi_device_id rt5670_acpi_match[] = { 28128c2ecf20Sopenharmony_ci { "10EC5670", 0}, 28138c2ecf20Sopenharmony_ci { "10EC5672", 0}, 28148c2ecf20Sopenharmony_ci { "10EC5640", 0}, /* quirk */ 28158c2ecf20Sopenharmony_ci { }, 28168c2ecf20Sopenharmony_ci}; 28178c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(acpi, rt5670_acpi_match); 28188c2ecf20Sopenharmony_ci#endif 28198c2ecf20Sopenharmony_ci 28208c2ecf20Sopenharmony_cistatic int rt5670_quirk_cb(const struct dmi_system_id *id) 28218c2ecf20Sopenharmony_ci{ 28228c2ecf20Sopenharmony_ci rt5670_quirk = (unsigned long)id->driver_data; 28238c2ecf20Sopenharmony_ci return 1; 28248c2ecf20Sopenharmony_ci} 28258c2ecf20Sopenharmony_ci 28268c2ecf20Sopenharmony_cistatic const struct dmi_system_id dmi_platform_intel_quirks[] = { 28278c2ecf20Sopenharmony_ci { 28288c2ecf20Sopenharmony_ci .callback = rt5670_quirk_cb, 28298c2ecf20Sopenharmony_ci .ident = "Intel Braswell", 28308c2ecf20Sopenharmony_ci .matches = { 28318c2ecf20Sopenharmony_ci DMI_MATCH(DMI_SYS_VENDOR, "Intel Corporation"), 28328c2ecf20Sopenharmony_ci DMI_MATCH(DMI_BOARD_NAME, "Braswell CRB"), 28338c2ecf20Sopenharmony_ci }, 28348c2ecf20Sopenharmony_ci .driver_data = (unsigned long *)(RT5670_DMIC_EN | 28358c2ecf20Sopenharmony_ci RT5670_DMIC1_IN2P | 28368c2ecf20Sopenharmony_ci RT5670_GPIO1_IS_IRQ | 28378c2ecf20Sopenharmony_ci RT5670_JD_MODE1), 28388c2ecf20Sopenharmony_ci }, 28398c2ecf20Sopenharmony_ci { 28408c2ecf20Sopenharmony_ci .callback = rt5670_quirk_cb, 28418c2ecf20Sopenharmony_ci .ident = "Dell Wyse 3040", 28428c2ecf20Sopenharmony_ci .matches = { 28438c2ecf20Sopenharmony_ci DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), 28448c2ecf20Sopenharmony_ci DMI_MATCH(DMI_PRODUCT_NAME, "Wyse 3040"), 28458c2ecf20Sopenharmony_ci }, 28468c2ecf20Sopenharmony_ci .driver_data = (unsigned long *)(RT5670_DMIC_EN | 28478c2ecf20Sopenharmony_ci RT5670_DMIC1_IN2P | 28488c2ecf20Sopenharmony_ci RT5670_GPIO1_IS_IRQ | 28498c2ecf20Sopenharmony_ci RT5670_JD_MODE1), 28508c2ecf20Sopenharmony_ci }, 28518c2ecf20Sopenharmony_ci { 28528c2ecf20Sopenharmony_ci .callback = rt5670_quirk_cb, 28538c2ecf20Sopenharmony_ci .ident = "Lenovo Thinkpad Tablet 8", 28548c2ecf20Sopenharmony_ci .matches = { 28558c2ecf20Sopenharmony_ci DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), 28568c2ecf20Sopenharmony_ci DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad 8"), 28578c2ecf20Sopenharmony_ci }, 28588c2ecf20Sopenharmony_ci .driver_data = (unsigned long *)(RT5670_DMIC_EN | 28598c2ecf20Sopenharmony_ci RT5670_DMIC2_INR | 28608c2ecf20Sopenharmony_ci RT5670_GPIO1_IS_IRQ | 28618c2ecf20Sopenharmony_ci RT5670_JD_MODE1), 28628c2ecf20Sopenharmony_ci }, 28638c2ecf20Sopenharmony_ci { 28648c2ecf20Sopenharmony_ci .callback = rt5670_quirk_cb, 28658c2ecf20Sopenharmony_ci .ident = "Lenovo Thinkpad Tablet 10", 28668c2ecf20Sopenharmony_ci .matches = { 28678c2ecf20Sopenharmony_ci DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), 28688c2ecf20Sopenharmony_ci DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad 10"), 28698c2ecf20Sopenharmony_ci }, 28708c2ecf20Sopenharmony_ci .driver_data = (unsigned long *)(RT5670_DMIC_EN | 28718c2ecf20Sopenharmony_ci RT5670_DMIC1_IN2P | 28728c2ecf20Sopenharmony_ci RT5670_GPIO1_IS_IRQ | 28738c2ecf20Sopenharmony_ci RT5670_JD_MODE1), 28748c2ecf20Sopenharmony_ci }, 28758c2ecf20Sopenharmony_ci { 28768c2ecf20Sopenharmony_ci .callback = rt5670_quirk_cb, 28778c2ecf20Sopenharmony_ci .ident = "Lenovo Thinkpad Tablet 10", 28788c2ecf20Sopenharmony_ci .matches = { 28798c2ecf20Sopenharmony_ci DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), 28808c2ecf20Sopenharmony_ci DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad Tablet B"), 28818c2ecf20Sopenharmony_ci }, 28828c2ecf20Sopenharmony_ci .driver_data = (unsigned long *)(RT5670_DMIC_EN | 28838c2ecf20Sopenharmony_ci RT5670_DMIC1_IN2P | 28848c2ecf20Sopenharmony_ci RT5670_GPIO1_IS_IRQ | 28858c2ecf20Sopenharmony_ci RT5670_JD_MODE1), 28868c2ecf20Sopenharmony_ci }, 28878c2ecf20Sopenharmony_ci { 28888c2ecf20Sopenharmony_ci .callback = rt5670_quirk_cb, 28898c2ecf20Sopenharmony_ci .ident = "Lenovo Miix 2 10", 28908c2ecf20Sopenharmony_ci .matches = { 28918c2ecf20Sopenharmony_ci DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), 28928c2ecf20Sopenharmony_ci DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo Miix 2 10"), 28938c2ecf20Sopenharmony_ci }, 28948c2ecf20Sopenharmony_ci .driver_data = (unsigned long *)(RT5670_DMIC_EN | 28958c2ecf20Sopenharmony_ci RT5670_DMIC1_IN2P | 28968c2ecf20Sopenharmony_ci RT5670_GPIO1_IS_EXT_SPK_EN | 28978c2ecf20Sopenharmony_ci RT5670_JD_MODE2), 28988c2ecf20Sopenharmony_ci }, 28998c2ecf20Sopenharmony_ci { 29008c2ecf20Sopenharmony_ci .callback = rt5670_quirk_cb, 29018c2ecf20Sopenharmony_ci .ident = "Dell Venue 8 Pro 5855", 29028c2ecf20Sopenharmony_ci .matches = { 29038c2ecf20Sopenharmony_ci DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), 29048c2ecf20Sopenharmony_ci DMI_MATCH(DMI_PRODUCT_NAME, "Venue 8 Pro 5855"), 29058c2ecf20Sopenharmony_ci }, 29068c2ecf20Sopenharmony_ci .driver_data = (unsigned long *)(RT5670_DMIC_EN | 29078c2ecf20Sopenharmony_ci RT5670_DMIC2_INR | 29088c2ecf20Sopenharmony_ci RT5670_GPIO1_IS_IRQ | 29098c2ecf20Sopenharmony_ci RT5670_JD_MODE3), 29108c2ecf20Sopenharmony_ci }, 29118c2ecf20Sopenharmony_ci { 29128c2ecf20Sopenharmony_ci .callback = rt5670_quirk_cb, 29138c2ecf20Sopenharmony_ci .ident = "Dell Venue 10 Pro 5055", 29148c2ecf20Sopenharmony_ci .matches = { 29158c2ecf20Sopenharmony_ci DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), 29168c2ecf20Sopenharmony_ci DMI_MATCH(DMI_PRODUCT_NAME, "Venue 10 Pro 5055"), 29178c2ecf20Sopenharmony_ci }, 29188c2ecf20Sopenharmony_ci .driver_data = (unsigned long *)(RT5670_DMIC_EN | 29198c2ecf20Sopenharmony_ci RT5670_DMIC2_INR | 29208c2ecf20Sopenharmony_ci RT5670_GPIO1_IS_IRQ | 29218c2ecf20Sopenharmony_ci RT5670_JD_MODE1), 29228c2ecf20Sopenharmony_ci }, 29238c2ecf20Sopenharmony_ci { 29248c2ecf20Sopenharmony_ci .callback = rt5670_quirk_cb, 29258c2ecf20Sopenharmony_ci .ident = "Aegex 10 tablet (RU2)", 29268c2ecf20Sopenharmony_ci .matches = { 29278c2ecf20Sopenharmony_ci DMI_MATCH(DMI_SYS_VENDOR, "AEGEX"), 29288c2ecf20Sopenharmony_ci DMI_MATCH(DMI_PRODUCT_VERSION, "RU2"), 29298c2ecf20Sopenharmony_ci }, 29308c2ecf20Sopenharmony_ci .driver_data = (unsigned long *)(RT5670_DMIC_EN | 29318c2ecf20Sopenharmony_ci RT5670_DMIC2_INR | 29328c2ecf20Sopenharmony_ci RT5670_GPIO1_IS_IRQ | 29338c2ecf20Sopenharmony_ci RT5670_JD_MODE3), 29348c2ecf20Sopenharmony_ci }, 29358c2ecf20Sopenharmony_ci {} 29368c2ecf20Sopenharmony_ci}; 29378c2ecf20Sopenharmony_ci 29388c2ecf20Sopenharmony_cistatic int rt5670_i2c_probe(struct i2c_client *i2c, 29398c2ecf20Sopenharmony_ci const struct i2c_device_id *id) 29408c2ecf20Sopenharmony_ci{ 29418c2ecf20Sopenharmony_ci struct rt5670_priv *rt5670; 29428c2ecf20Sopenharmony_ci int ret; 29438c2ecf20Sopenharmony_ci unsigned int val; 29448c2ecf20Sopenharmony_ci 29458c2ecf20Sopenharmony_ci rt5670 = devm_kzalloc(&i2c->dev, 29468c2ecf20Sopenharmony_ci sizeof(struct rt5670_priv), 29478c2ecf20Sopenharmony_ci GFP_KERNEL); 29488c2ecf20Sopenharmony_ci if (NULL == rt5670) 29498c2ecf20Sopenharmony_ci return -ENOMEM; 29508c2ecf20Sopenharmony_ci 29518c2ecf20Sopenharmony_ci i2c_set_clientdata(i2c, rt5670); 29528c2ecf20Sopenharmony_ci 29538c2ecf20Sopenharmony_ci dmi_check_system(dmi_platform_intel_quirks); 29548c2ecf20Sopenharmony_ci if (quirk_override) { 29558c2ecf20Sopenharmony_ci dev_info(&i2c->dev, "Overriding quirk 0x%x => 0x%x\n", 29568c2ecf20Sopenharmony_ci (unsigned int)rt5670_quirk, quirk_override); 29578c2ecf20Sopenharmony_ci rt5670_quirk = quirk_override; 29588c2ecf20Sopenharmony_ci } 29598c2ecf20Sopenharmony_ci 29608c2ecf20Sopenharmony_ci if (rt5670_quirk & RT5670_GPIO1_IS_IRQ) { 29618c2ecf20Sopenharmony_ci rt5670->gpio1_is_irq = true; 29628c2ecf20Sopenharmony_ci dev_info(&i2c->dev, "quirk GPIO1 is IRQ\n"); 29638c2ecf20Sopenharmony_ci } 29648c2ecf20Sopenharmony_ci if (rt5670_quirk & RT5670_GPIO1_IS_EXT_SPK_EN) { 29658c2ecf20Sopenharmony_ci rt5670->gpio1_is_ext_spk_en = true; 29668c2ecf20Sopenharmony_ci dev_info(&i2c->dev, "quirk GPIO1 is external speaker enable\n"); 29678c2ecf20Sopenharmony_ci } 29688c2ecf20Sopenharmony_ci if (rt5670_quirk & RT5670_IN2_DIFF) { 29698c2ecf20Sopenharmony_ci rt5670->in2_diff = true; 29708c2ecf20Sopenharmony_ci dev_info(&i2c->dev, "quirk IN2_DIFF\n"); 29718c2ecf20Sopenharmony_ci } 29728c2ecf20Sopenharmony_ci if (rt5670_quirk & RT5670_DMIC_EN) { 29738c2ecf20Sopenharmony_ci rt5670->dmic_en = true; 29748c2ecf20Sopenharmony_ci dev_info(&i2c->dev, "quirk DMIC enabled\n"); 29758c2ecf20Sopenharmony_ci } 29768c2ecf20Sopenharmony_ci if (rt5670_quirk & RT5670_DMIC1_IN2P) { 29778c2ecf20Sopenharmony_ci rt5670->dmic1_data_pin = RT5670_DMIC_DATA_IN2P; 29788c2ecf20Sopenharmony_ci dev_info(&i2c->dev, "quirk DMIC1 on IN2P pin\n"); 29798c2ecf20Sopenharmony_ci } 29808c2ecf20Sopenharmony_ci if (rt5670_quirk & RT5670_DMIC1_GPIO6) { 29818c2ecf20Sopenharmony_ci rt5670->dmic1_data_pin = RT5670_DMIC_DATA_GPIO6; 29828c2ecf20Sopenharmony_ci dev_info(&i2c->dev, "quirk DMIC1 on GPIO6 pin\n"); 29838c2ecf20Sopenharmony_ci } 29848c2ecf20Sopenharmony_ci if (rt5670_quirk & RT5670_DMIC1_GPIO7) { 29858c2ecf20Sopenharmony_ci rt5670->dmic1_data_pin = RT5670_DMIC_DATA_GPIO7; 29868c2ecf20Sopenharmony_ci dev_info(&i2c->dev, "quirk DMIC1 on GPIO7 pin\n"); 29878c2ecf20Sopenharmony_ci } 29888c2ecf20Sopenharmony_ci if (rt5670_quirk & RT5670_DMIC2_INR) { 29898c2ecf20Sopenharmony_ci rt5670->dmic2_data_pin = RT5670_DMIC_DATA_IN3N; 29908c2ecf20Sopenharmony_ci dev_info(&i2c->dev, "quirk DMIC2 on INR pin\n"); 29918c2ecf20Sopenharmony_ci } 29928c2ecf20Sopenharmony_ci if (rt5670_quirk & RT5670_DMIC2_GPIO8) { 29938c2ecf20Sopenharmony_ci rt5670->dmic2_data_pin = RT5670_DMIC_DATA_GPIO8; 29948c2ecf20Sopenharmony_ci dev_info(&i2c->dev, "quirk DMIC2 on GPIO8 pin\n"); 29958c2ecf20Sopenharmony_ci } 29968c2ecf20Sopenharmony_ci if (rt5670_quirk & RT5670_DMIC3_GPIO5) { 29978c2ecf20Sopenharmony_ci rt5670->dmic3_data_pin = RT5670_DMIC_DATA_GPIO5; 29988c2ecf20Sopenharmony_ci dev_info(&i2c->dev, "quirk DMIC3 on GPIO5 pin\n"); 29998c2ecf20Sopenharmony_ci } 30008c2ecf20Sopenharmony_ci 30018c2ecf20Sopenharmony_ci if (rt5670_quirk & RT5670_JD_MODE1) { 30028c2ecf20Sopenharmony_ci rt5670->jd_mode = 1; 30038c2ecf20Sopenharmony_ci dev_info(&i2c->dev, "quirk JD mode 1\n"); 30048c2ecf20Sopenharmony_ci } 30058c2ecf20Sopenharmony_ci if (rt5670_quirk & RT5670_JD_MODE2) { 30068c2ecf20Sopenharmony_ci rt5670->jd_mode = 2; 30078c2ecf20Sopenharmony_ci dev_info(&i2c->dev, "quirk JD mode 2\n"); 30088c2ecf20Sopenharmony_ci } 30098c2ecf20Sopenharmony_ci if (rt5670_quirk & RT5670_JD_MODE3) { 30108c2ecf20Sopenharmony_ci rt5670->jd_mode = 3; 30118c2ecf20Sopenharmony_ci dev_info(&i2c->dev, "quirk JD mode 3\n"); 30128c2ecf20Sopenharmony_ci } 30138c2ecf20Sopenharmony_ci 30148c2ecf20Sopenharmony_ci rt5670->regmap = devm_regmap_init_i2c(i2c, &rt5670_regmap); 30158c2ecf20Sopenharmony_ci if (IS_ERR(rt5670->regmap)) { 30168c2ecf20Sopenharmony_ci ret = PTR_ERR(rt5670->regmap); 30178c2ecf20Sopenharmony_ci dev_err(&i2c->dev, "Failed to allocate register map: %d\n", 30188c2ecf20Sopenharmony_ci ret); 30198c2ecf20Sopenharmony_ci return ret; 30208c2ecf20Sopenharmony_ci } 30218c2ecf20Sopenharmony_ci 30228c2ecf20Sopenharmony_ci regmap_read(rt5670->regmap, RT5670_VENDOR_ID2, &val); 30238c2ecf20Sopenharmony_ci if (val != RT5670_DEVICE_ID) { 30248c2ecf20Sopenharmony_ci dev_err(&i2c->dev, 30258c2ecf20Sopenharmony_ci "Device with ID register %#x is not rt5670/72\n", val); 30268c2ecf20Sopenharmony_ci return -ENODEV; 30278c2ecf20Sopenharmony_ci } 30288c2ecf20Sopenharmony_ci 30298c2ecf20Sopenharmony_ci regmap_write(rt5670->regmap, RT5670_RESET, 0); 30308c2ecf20Sopenharmony_ci regmap_update_bits(rt5670->regmap, RT5670_PWR_ANLG1, 30318c2ecf20Sopenharmony_ci RT5670_PWR_HP_L | RT5670_PWR_HP_R | 30328c2ecf20Sopenharmony_ci RT5670_PWR_VREF2, RT5670_PWR_VREF2); 30338c2ecf20Sopenharmony_ci msleep(100); 30348c2ecf20Sopenharmony_ci 30358c2ecf20Sopenharmony_ci regmap_write(rt5670->regmap, RT5670_RESET, 0); 30368c2ecf20Sopenharmony_ci 30378c2ecf20Sopenharmony_ci regmap_read(rt5670->regmap, RT5670_VENDOR_ID, &val); 30388c2ecf20Sopenharmony_ci if (val >= 4) 30398c2ecf20Sopenharmony_ci regmap_write(rt5670->regmap, RT5670_GPIO_CTRL3, 0x0980); 30408c2ecf20Sopenharmony_ci else 30418c2ecf20Sopenharmony_ci regmap_write(rt5670->regmap, RT5670_GPIO_CTRL3, 0x0d00); 30428c2ecf20Sopenharmony_ci 30438c2ecf20Sopenharmony_ci ret = regmap_register_patch(rt5670->regmap, init_list, 30448c2ecf20Sopenharmony_ci ARRAY_SIZE(init_list)); 30458c2ecf20Sopenharmony_ci if (ret != 0) 30468c2ecf20Sopenharmony_ci dev_warn(&i2c->dev, "Failed to apply regmap patch: %d\n", ret); 30478c2ecf20Sopenharmony_ci 30488c2ecf20Sopenharmony_ci regmap_update_bits(rt5670->regmap, RT5670_DIG_MISC, 30498c2ecf20Sopenharmony_ci RT5670_MCLK_DET, RT5670_MCLK_DET); 30508c2ecf20Sopenharmony_ci 30518c2ecf20Sopenharmony_ci if (rt5670->in2_diff) 30528c2ecf20Sopenharmony_ci regmap_update_bits(rt5670->regmap, RT5670_IN2, 30538c2ecf20Sopenharmony_ci RT5670_IN_DF2, RT5670_IN_DF2); 30548c2ecf20Sopenharmony_ci 30558c2ecf20Sopenharmony_ci if (rt5670->gpio1_is_irq) { 30568c2ecf20Sopenharmony_ci /* for push button */ 30578c2ecf20Sopenharmony_ci regmap_write(rt5670->regmap, RT5670_IL_CMD, 0x0000); 30588c2ecf20Sopenharmony_ci regmap_write(rt5670->regmap, RT5670_IL_CMD2, 0x0010); 30598c2ecf20Sopenharmony_ci regmap_write(rt5670->regmap, RT5670_IL_CMD3, 0x0014); 30608c2ecf20Sopenharmony_ci /* for irq */ 30618c2ecf20Sopenharmony_ci regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL1, 30628c2ecf20Sopenharmony_ci RT5670_GP1_PIN_MASK, RT5670_GP1_PIN_IRQ); 30638c2ecf20Sopenharmony_ci regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL2, 30648c2ecf20Sopenharmony_ci RT5670_GP1_PF_MASK, RT5670_GP1_PF_OUT); 30658c2ecf20Sopenharmony_ci } 30668c2ecf20Sopenharmony_ci 30678c2ecf20Sopenharmony_ci if (rt5670->gpio1_is_ext_spk_en) { 30688c2ecf20Sopenharmony_ci regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL1, 30698c2ecf20Sopenharmony_ci RT5670_GP1_PIN_MASK, RT5670_GP1_PIN_GPIO1); 30708c2ecf20Sopenharmony_ci regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL2, 30718c2ecf20Sopenharmony_ci RT5670_GP1_PF_MASK, RT5670_GP1_PF_OUT); 30728c2ecf20Sopenharmony_ci } 30738c2ecf20Sopenharmony_ci 30748c2ecf20Sopenharmony_ci if (rt5670->jd_mode) { 30758c2ecf20Sopenharmony_ci regmap_update_bits(rt5670->regmap, RT5670_GLB_CLK, 30768c2ecf20Sopenharmony_ci RT5670_SCLK_SRC_MASK, RT5670_SCLK_SRC_RCCLK); 30778c2ecf20Sopenharmony_ci rt5670->sysclk = 0; 30788c2ecf20Sopenharmony_ci rt5670->sysclk_src = RT5670_SCLK_S_RCCLK; 30798c2ecf20Sopenharmony_ci regmap_update_bits(rt5670->regmap, RT5670_PWR_ANLG1, 30808c2ecf20Sopenharmony_ci RT5670_PWR_MB, RT5670_PWR_MB); 30818c2ecf20Sopenharmony_ci regmap_update_bits(rt5670->regmap, RT5670_PWR_ANLG2, 30828c2ecf20Sopenharmony_ci RT5670_PWR_JD1, RT5670_PWR_JD1); 30838c2ecf20Sopenharmony_ci regmap_update_bits(rt5670->regmap, RT5670_IRQ_CTRL1, 30848c2ecf20Sopenharmony_ci RT5670_JD1_1_EN_MASK, RT5670_JD1_1_EN); 30858c2ecf20Sopenharmony_ci regmap_update_bits(rt5670->regmap, RT5670_JD_CTRL3, 30868c2ecf20Sopenharmony_ci RT5670_JD_TRI_CBJ_SEL_MASK | 30878c2ecf20Sopenharmony_ci RT5670_JD_TRI_HPO_SEL_MASK, 30888c2ecf20Sopenharmony_ci RT5670_JD_CBJ_JD1_1 | RT5670_JD_HPO_JD1_1); 30898c2ecf20Sopenharmony_ci switch (rt5670->jd_mode) { 30908c2ecf20Sopenharmony_ci case 1: 30918c2ecf20Sopenharmony_ci regmap_update_bits(rt5670->regmap, RT5670_A_JD_CTRL1, 30928c2ecf20Sopenharmony_ci RT5670_JD1_MODE_MASK, 30938c2ecf20Sopenharmony_ci RT5670_JD1_MODE_0); 30948c2ecf20Sopenharmony_ci break; 30958c2ecf20Sopenharmony_ci case 2: 30968c2ecf20Sopenharmony_ci regmap_update_bits(rt5670->regmap, RT5670_A_JD_CTRL1, 30978c2ecf20Sopenharmony_ci RT5670_JD1_MODE_MASK, 30988c2ecf20Sopenharmony_ci RT5670_JD1_MODE_1); 30998c2ecf20Sopenharmony_ci break; 31008c2ecf20Sopenharmony_ci case 3: 31018c2ecf20Sopenharmony_ci regmap_update_bits(rt5670->regmap, RT5670_A_JD_CTRL1, 31028c2ecf20Sopenharmony_ci RT5670_JD1_MODE_MASK, 31038c2ecf20Sopenharmony_ci RT5670_JD1_MODE_2); 31048c2ecf20Sopenharmony_ci break; 31058c2ecf20Sopenharmony_ci default: 31068c2ecf20Sopenharmony_ci break; 31078c2ecf20Sopenharmony_ci } 31088c2ecf20Sopenharmony_ci } 31098c2ecf20Sopenharmony_ci 31108c2ecf20Sopenharmony_ci if (rt5670->dmic_en) { 31118c2ecf20Sopenharmony_ci regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL1, 31128c2ecf20Sopenharmony_ci RT5670_GP2_PIN_MASK, 31138c2ecf20Sopenharmony_ci RT5670_GP2_PIN_DMIC1_SCL); 31148c2ecf20Sopenharmony_ci 31158c2ecf20Sopenharmony_ci switch (rt5670->dmic1_data_pin) { 31168c2ecf20Sopenharmony_ci case RT5670_DMIC_DATA_IN2P: 31178c2ecf20Sopenharmony_ci regmap_update_bits(rt5670->regmap, RT5670_DMIC_CTRL1, 31188c2ecf20Sopenharmony_ci RT5670_DMIC_1_DP_MASK, 31198c2ecf20Sopenharmony_ci RT5670_DMIC_1_DP_IN2P); 31208c2ecf20Sopenharmony_ci break; 31218c2ecf20Sopenharmony_ci 31228c2ecf20Sopenharmony_ci case RT5670_DMIC_DATA_GPIO6: 31238c2ecf20Sopenharmony_ci regmap_update_bits(rt5670->regmap, RT5670_DMIC_CTRL1, 31248c2ecf20Sopenharmony_ci RT5670_DMIC_1_DP_MASK, 31258c2ecf20Sopenharmony_ci RT5670_DMIC_1_DP_GPIO6); 31268c2ecf20Sopenharmony_ci regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL1, 31278c2ecf20Sopenharmony_ci RT5670_GP6_PIN_MASK, 31288c2ecf20Sopenharmony_ci RT5670_GP6_PIN_DMIC1_SDA); 31298c2ecf20Sopenharmony_ci break; 31308c2ecf20Sopenharmony_ci 31318c2ecf20Sopenharmony_ci case RT5670_DMIC_DATA_GPIO7: 31328c2ecf20Sopenharmony_ci regmap_update_bits(rt5670->regmap, RT5670_DMIC_CTRL1, 31338c2ecf20Sopenharmony_ci RT5670_DMIC_1_DP_MASK, 31348c2ecf20Sopenharmony_ci RT5670_DMIC_1_DP_GPIO7); 31358c2ecf20Sopenharmony_ci regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL1, 31368c2ecf20Sopenharmony_ci RT5670_GP7_PIN_MASK, 31378c2ecf20Sopenharmony_ci RT5670_GP7_PIN_DMIC1_SDA); 31388c2ecf20Sopenharmony_ci break; 31398c2ecf20Sopenharmony_ci 31408c2ecf20Sopenharmony_ci default: 31418c2ecf20Sopenharmony_ci break; 31428c2ecf20Sopenharmony_ci } 31438c2ecf20Sopenharmony_ci 31448c2ecf20Sopenharmony_ci switch (rt5670->dmic2_data_pin) { 31458c2ecf20Sopenharmony_ci case RT5670_DMIC_DATA_IN3N: 31468c2ecf20Sopenharmony_ci regmap_update_bits(rt5670->regmap, RT5670_DMIC_CTRL1, 31478c2ecf20Sopenharmony_ci RT5670_DMIC_2_DP_MASK, 31488c2ecf20Sopenharmony_ci RT5670_DMIC_2_DP_IN3N); 31498c2ecf20Sopenharmony_ci break; 31508c2ecf20Sopenharmony_ci 31518c2ecf20Sopenharmony_ci case RT5670_DMIC_DATA_GPIO8: 31528c2ecf20Sopenharmony_ci regmap_update_bits(rt5670->regmap, RT5670_DMIC_CTRL1, 31538c2ecf20Sopenharmony_ci RT5670_DMIC_2_DP_MASK, 31548c2ecf20Sopenharmony_ci RT5670_DMIC_2_DP_GPIO8); 31558c2ecf20Sopenharmony_ci regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL1, 31568c2ecf20Sopenharmony_ci RT5670_GP8_PIN_MASK, 31578c2ecf20Sopenharmony_ci RT5670_GP8_PIN_DMIC2_SDA); 31588c2ecf20Sopenharmony_ci break; 31598c2ecf20Sopenharmony_ci 31608c2ecf20Sopenharmony_ci default: 31618c2ecf20Sopenharmony_ci break; 31628c2ecf20Sopenharmony_ci } 31638c2ecf20Sopenharmony_ci 31648c2ecf20Sopenharmony_ci switch (rt5670->dmic3_data_pin) { 31658c2ecf20Sopenharmony_ci case RT5670_DMIC_DATA_GPIO5: 31668c2ecf20Sopenharmony_ci regmap_update_bits(rt5670->regmap, RT5670_DMIC_CTRL2, 31678c2ecf20Sopenharmony_ci RT5670_DMIC_3_DP_MASK, 31688c2ecf20Sopenharmony_ci RT5670_DMIC_3_DP_GPIO5); 31698c2ecf20Sopenharmony_ci regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL1, 31708c2ecf20Sopenharmony_ci RT5670_GP5_PIN_MASK, 31718c2ecf20Sopenharmony_ci RT5670_GP5_PIN_DMIC3_SDA); 31728c2ecf20Sopenharmony_ci break; 31738c2ecf20Sopenharmony_ci 31748c2ecf20Sopenharmony_ci case RT5670_DMIC_DATA_GPIO9: 31758c2ecf20Sopenharmony_ci case RT5670_DMIC_DATA_GPIO10: 31768c2ecf20Sopenharmony_ci dev_err(&i2c->dev, 31778c2ecf20Sopenharmony_ci "Always use GPIO5 as DMIC3 data pin\n"); 31788c2ecf20Sopenharmony_ci break; 31798c2ecf20Sopenharmony_ci 31808c2ecf20Sopenharmony_ci default: 31818c2ecf20Sopenharmony_ci break; 31828c2ecf20Sopenharmony_ci } 31838c2ecf20Sopenharmony_ci 31848c2ecf20Sopenharmony_ci } 31858c2ecf20Sopenharmony_ci 31868c2ecf20Sopenharmony_ci pm_runtime_enable(&i2c->dev); 31878c2ecf20Sopenharmony_ci pm_request_idle(&i2c->dev); 31888c2ecf20Sopenharmony_ci 31898c2ecf20Sopenharmony_ci ret = devm_snd_soc_register_component(&i2c->dev, 31908c2ecf20Sopenharmony_ci &soc_component_dev_rt5670, 31918c2ecf20Sopenharmony_ci rt5670_dai, ARRAY_SIZE(rt5670_dai)); 31928c2ecf20Sopenharmony_ci if (ret < 0) 31938c2ecf20Sopenharmony_ci goto err; 31948c2ecf20Sopenharmony_ci 31958c2ecf20Sopenharmony_ci return 0; 31968c2ecf20Sopenharmony_cierr: 31978c2ecf20Sopenharmony_ci pm_runtime_disable(&i2c->dev); 31988c2ecf20Sopenharmony_ci 31998c2ecf20Sopenharmony_ci return ret; 32008c2ecf20Sopenharmony_ci} 32018c2ecf20Sopenharmony_ci 32028c2ecf20Sopenharmony_cistatic int rt5670_i2c_remove(struct i2c_client *i2c) 32038c2ecf20Sopenharmony_ci{ 32048c2ecf20Sopenharmony_ci pm_runtime_disable(&i2c->dev); 32058c2ecf20Sopenharmony_ci 32068c2ecf20Sopenharmony_ci return 0; 32078c2ecf20Sopenharmony_ci} 32088c2ecf20Sopenharmony_ci 32098c2ecf20Sopenharmony_cistatic struct i2c_driver rt5670_i2c_driver = { 32108c2ecf20Sopenharmony_ci .driver = { 32118c2ecf20Sopenharmony_ci .name = "rt5670", 32128c2ecf20Sopenharmony_ci .acpi_match_table = ACPI_PTR(rt5670_acpi_match), 32138c2ecf20Sopenharmony_ci }, 32148c2ecf20Sopenharmony_ci .probe = rt5670_i2c_probe, 32158c2ecf20Sopenharmony_ci .remove = rt5670_i2c_remove, 32168c2ecf20Sopenharmony_ci .id_table = rt5670_i2c_id, 32178c2ecf20Sopenharmony_ci}; 32188c2ecf20Sopenharmony_ci 32198c2ecf20Sopenharmony_cimodule_i2c_driver(rt5670_i2c_driver); 32208c2ecf20Sopenharmony_ci 32218c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("ASoC RT5670 driver"); 32228c2ecf20Sopenharmony_ciMODULE_AUTHOR("Bard Liao <bardliao@realtek.com>"); 32238c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL v2"); 3224