162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * rt298.h -- RT298 ALSA SoC audio driver 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * Copyright 2011 Realtek Microelectronics 662306a36Sopenharmony_ci * Author: Johnny Hsu <johnnyhsu@realtek.com> 762306a36Sopenharmony_ci */ 862306a36Sopenharmony_ci 962306a36Sopenharmony_ci#ifndef __RT298_H__ 1062306a36Sopenharmony_ci#define __RT298_H__ 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ci#define VERB_CMD(V, N, D) ((N << 20) | (V << 8) | D) 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_ci#define RT298_AUDIO_FUNCTION_GROUP 0x01 1562306a36Sopenharmony_ci#define RT298_DAC_OUT1 0x02 1662306a36Sopenharmony_ci#define RT298_DAC_OUT2 0x03 1762306a36Sopenharmony_ci#define RT298_DIG_CVT 0x06 1862306a36Sopenharmony_ci#define RT298_ADC_IN1 0x09 1962306a36Sopenharmony_ci#define RT298_ADC_IN2 0x08 2062306a36Sopenharmony_ci#define RT298_MIXER_IN 0x0b 2162306a36Sopenharmony_ci#define RT298_MIXER_OUT1 0x0c 2262306a36Sopenharmony_ci#define RT298_MIXER_OUT2 0x0d 2362306a36Sopenharmony_ci#define RT298_DMIC1 0x12 2462306a36Sopenharmony_ci#define RT298_DMIC2 0x13 2562306a36Sopenharmony_ci#define RT298_SPK_OUT 0x14 2662306a36Sopenharmony_ci#define RT298_MIC1 0x18 2762306a36Sopenharmony_ci#define RT298_LINE1 0x1a 2862306a36Sopenharmony_ci#define RT298_BEEP 0x1d 2962306a36Sopenharmony_ci#define RT298_SPDIF 0x1e 3062306a36Sopenharmony_ci#define RT298_VENDOR_REGISTERS 0x20 3162306a36Sopenharmony_ci#define RT298_HP_OUT 0x21 3262306a36Sopenharmony_ci#define RT298_MIXER_IN1 0x22 3362306a36Sopenharmony_ci#define RT298_MIXER_IN2 0x23 3462306a36Sopenharmony_ci#define RT298_INLINE_CMD 0x55 3562306a36Sopenharmony_ci 3662306a36Sopenharmony_ci#define RT298_SET_PIN_SFT 6 3762306a36Sopenharmony_ci#define RT298_SET_PIN_ENABLE 0x40 3862306a36Sopenharmony_ci#define RT298_SET_PIN_DISABLE 0 3962306a36Sopenharmony_ci#define RT298_SET_EAPD_HIGH 0x2 4062306a36Sopenharmony_ci#define RT298_SET_EAPD_LOW 0 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_ci#define RT298_MUTE_SFT 7 4362306a36Sopenharmony_ci 4462306a36Sopenharmony_ci/* Verb commands */ 4562306a36Sopenharmony_ci#define RT298_GET_PARAM(NID, PARAM) VERB_CMD(AC_VERB_PARAMETERS, NID, PARAM) 4662306a36Sopenharmony_ci#define RT298_SET_POWER(NID) VERB_CMD(AC_VERB_SET_POWER_STATE, NID, 0) 4762306a36Sopenharmony_ci#define RT298_SET_AUDIO_POWER RT298_SET_POWER(RT298_AUDIO_FUNCTION_GROUP) 4862306a36Sopenharmony_ci#define RT298_SET_HPO_POWER RT298_SET_POWER(RT298_HP_OUT) 4962306a36Sopenharmony_ci#define RT298_SET_SPK_POWER RT298_SET_POWER(RT298_SPK_OUT) 5062306a36Sopenharmony_ci#define RT298_SET_DMIC1_POWER RT298_SET_POWER(RT298_DMIC1) 5162306a36Sopenharmony_ci#define RT298_SPK_MUX\ 5262306a36Sopenharmony_ci VERB_CMD(AC_VERB_SET_CONNECT_SEL, RT298_SPK_OUT, 0) 5362306a36Sopenharmony_ci#define RT298_HPO_MUX\ 5462306a36Sopenharmony_ci VERB_CMD(AC_VERB_SET_CONNECT_SEL, RT298_HP_OUT, 0) 5562306a36Sopenharmony_ci#define RT298_ADC0_MUX\ 5662306a36Sopenharmony_ci VERB_CMD(AC_VERB_SET_CONNECT_SEL, RT298_MIXER_IN1, 0) 5762306a36Sopenharmony_ci#define RT298_ADC1_MUX\ 5862306a36Sopenharmony_ci VERB_CMD(AC_VERB_SET_CONNECT_SEL, RT298_MIXER_IN2, 0) 5962306a36Sopenharmony_ci#define RT298_SET_MIC1\ 6062306a36Sopenharmony_ci VERB_CMD(AC_VERB_SET_PIN_WIDGET_CONTROL, RT298_MIC1, 0) 6162306a36Sopenharmony_ci#define RT298_SET_PIN_HPO\ 6262306a36Sopenharmony_ci VERB_CMD(AC_VERB_SET_PIN_WIDGET_CONTROL, RT298_HP_OUT, 0) 6362306a36Sopenharmony_ci#define RT298_SET_PIN_SPK\ 6462306a36Sopenharmony_ci VERB_CMD(AC_VERB_SET_PIN_WIDGET_CONTROL, RT298_SPK_OUT, 0) 6562306a36Sopenharmony_ci#define RT298_SET_PIN_DMIC1\ 6662306a36Sopenharmony_ci VERB_CMD(AC_VERB_SET_PIN_WIDGET_CONTROL, RT298_DMIC1, 0) 6762306a36Sopenharmony_ci#define RT298_SET_PIN_SPDIF\ 6862306a36Sopenharmony_ci VERB_CMD(AC_VERB_SET_PIN_WIDGET_CONTROL, RT298_SPDIF, 0) 6962306a36Sopenharmony_ci#define RT298_SET_PIN_DIG_CVT\ 7062306a36Sopenharmony_ci VERB_CMD(AC_VERB_SET_DIGI_CONVERT_1, RT298_DIG_CVT, 0) 7162306a36Sopenharmony_ci#define RT298_SPK_EAPD\ 7262306a36Sopenharmony_ci VERB_CMD(AC_VERB_SET_EAPD_BTLENABLE, RT298_SPK_OUT, 0) 7362306a36Sopenharmony_ci#define RT298_SET_AMP_GAIN_HPO\ 7462306a36Sopenharmony_ci VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT298_HP_OUT, 0) 7562306a36Sopenharmony_ci#define RT298_SET_AMP_GAIN_ADC_IN1\ 7662306a36Sopenharmony_ci VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT298_ADC_IN1, 0) 7762306a36Sopenharmony_ci#define RT298_SET_AMP_GAIN_ADC_IN2\ 7862306a36Sopenharmony_ci VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT298_ADC_IN2, 0) 7962306a36Sopenharmony_ci#define RT298_GET_HP_SENSE\ 8062306a36Sopenharmony_ci VERB_CMD(AC_VERB_GET_PIN_SENSE, RT298_HP_OUT, 0) 8162306a36Sopenharmony_ci#define RT298_GET_MIC1_SENSE\ 8262306a36Sopenharmony_ci VERB_CMD(AC_VERB_GET_PIN_SENSE, RT298_MIC1, 0) 8362306a36Sopenharmony_ci#define RT298_SET_DMIC2_DEFAULT\ 8462306a36Sopenharmony_ci VERB_CMD(AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, RT298_DMIC2, 0) 8562306a36Sopenharmony_ci#define RT298_SET_SPDIF_DEFAULT\ 8662306a36Sopenharmony_ci VERB_CMD(AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, RT298_SPDIF, 0) 8762306a36Sopenharmony_ci#define RT298_DACL_GAIN\ 8862306a36Sopenharmony_ci VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT298_DAC_OUT1, 0xa000) 8962306a36Sopenharmony_ci#define RT298_DACR_GAIN\ 9062306a36Sopenharmony_ci VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT298_DAC_OUT1, 0x9000) 9162306a36Sopenharmony_ci#define RT298_ADCL_GAIN\ 9262306a36Sopenharmony_ci VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT298_ADC_IN1, 0x6000) 9362306a36Sopenharmony_ci#define RT298_ADCR_GAIN\ 9462306a36Sopenharmony_ci VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT298_ADC_IN1, 0x5000) 9562306a36Sopenharmony_ci#define RT298_MIC_GAIN\ 9662306a36Sopenharmony_ci VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT298_MIC1, 0x7000) 9762306a36Sopenharmony_ci#define RT298_SPOL_GAIN\ 9862306a36Sopenharmony_ci VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT298_SPK_OUT, 0xa000) 9962306a36Sopenharmony_ci#define RT298_SPOR_GAIN\ 10062306a36Sopenharmony_ci VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT298_SPK_OUT, 0x9000) 10162306a36Sopenharmony_ci#define RT298_HPOL_GAIN\ 10262306a36Sopenharmony_ci VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT298_HP_OUT, 0xa000) 10362306a36Sopenharmony_ci#define RT298_HPOR_GAIN\ 10462306a36Sopenharmony_ci VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT298_HP_OUT, 0x9000) 10562306a36Sopenharmony_ci#define RT298_F_DAC_SWITCH\ 10662306a36Sopenharmony_ci VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT298_MIXER_OUT1, 0x7000) 10762306a36Sopenharmony_ci#define RT298_F_RECMIX_SWITCH\ 10862306a36Sopenharmony_ci VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT298_MIXER_OUT1, 0x7100) 10962306a36Sopenharmony_ci#define RT298_REC_MIC_SWITCH\ 11062306a36Sopenharmony_ci VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT298_MIXER_IN, 0x7000) 11162306a36Sopenharmony_ci#define RT298_REC_I2S_SWITCH\ 11262306a36Sopenharmony_ci VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT298_MIXER_IN, 0x7100) 11362306a36Sopenharmony_ci#define RT298_REC_LINE_SWITCH\ 11462306a36Sopenharmony_ci VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT298_MIXER_IN, 0x7200) 11562306a36Sopenharmony_ci#define RT298_REC_BEEP_SWITCH\ 11662306a36Sopenharmony_ci VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT298_MIXER_IN, 0x7300) 11762306a36Sopenharmony_ci#define RT298_DAC_FORMAT\ 11862306a36Sopenharmony_ci VERB_CMD(AC_VERB_SET_STREAM_FORMAT, RT298_DAC_OUT1, 0) 11962306a36Sopenharmony_ci#define RT298_ADC_FORMAT\ 12062306a36Sopenharmony_ci VERB_CMD(AC_VERB_SET_STREAM_FORMAT, RT298_ADC_IN1, 0) 12162306a36Sopenharmony_ci#define RT298_COEF_INDEX\ 12262306a36Sopenharmony_ci VERB_CMD(AC_VERB_SET_COEF_INDEX, RT298_VENDOR_REGISTERS, 0) 12362306a36Sopenharmony_ci#define RT298_PROC_COEF\ 12462306a36Sopenharmony_ci VERB_CMD(AC_VERB_SET_PROC_COEF, RT298_VENDOR_REGISTERS, 0) 12562306a36Sopenharmony_ci#define RT298_UNSOLICITED_INLINE_CMD\ 12662306a36Sopenharmony_ci VERB_CMD(AC_VERB_SET_UNSOLICITED_ENABLE, RT298_INLINE_CMD, 0) 12762306a36Sopenharmony_ci#define RT298_UNSOLICITED_HP_OUT\ 12862306a36Sopenharmony_ci VERB_CMD(AC_VERB_SET_UNSOLICITED_ENABLE, RT298_HP_OUT, 0) 12962306a36Sopenharmony_ci#define RT298_UNSOLICITED_MIC1\ 13062306a36Sopenharmony_ci VERB_CMD(AC_VERB_SET_UNSOLICITED_ENABLE, RT298_MIC1, 0) 13162306a36Sopenharmony_ci 13262306a36Sopenharmony_ci/* Index registers */ 13362306a36Sopenharmony_ci#define RT298_A_BIAS_CTRL1 0x01 13462306a36Sopenharmony_ci#define RT298_A_BIAS_CTRL2 0x02 13562306a36Sopenharmony_ci#define RT298_POWER_CTRL1 0x03 13662306a36Sopenharmony_ci#define RT298_A_BIAS_CTRL3 0x04 13762306a36Sopenharmony_ci#define RT298_D_FILTER_CTRL 0x05 13862306a36Sopenharmony_ci#define RT298_POWER_CTRL2 0x08 13962306a36Sopenharmony_ci#define RT298_I2S_CTRL1 0x09 14062306a36Sopenharmony_ci#define RT298_I2S_CTRL2 0x0a 14162306a36Sopenharmony_ci#define RT298_CLK_DIV 0x0b 14262306a36Sopenharmony_ci#define RT298_DC_GAIN 0x0d 14362306a36Sopenharmony_ci#define RT298_POWER_CTRL3 0x0f 14462306a36Sopenharmony_ci#define RT298_MIC1_DET_CTRL 0x19 14562306a36Sopenharmony_ci#define RT298_MISC_CTRL1 0x20 14662306a36Sopenharmony_ci#define RT298_IRQ_CTRL 0x33 14762306a36Sopenharmony_ci#define RT298_WIND_FILTER_CTRL 0x46 14862306a36Sopenharmony_ci#define RT298_PLL_CTRL1 0x49 14962306a36Sopenharmony_ci#define RT298_VAD_CTRL 0x4e 15062306a36Sopenharmony_ci#define RT298_CBJ_CTRL1 0x4f 15162306a36Sopenharmony_ci#define RT298_CBJ_CTRL2 0x50 15262306a36Sopenharmony_ci#define RT298_PLL_CTRL 0x63 15362306a36Sopenharmony_ci#define RT298_DEPOP_CTRL1 0x66 15462306a36Sopenharmony_ci#define RT298_DEPOP_CTRL2 0x67 15562306a36Sopenharmony_ci#define RT298_DEPOP_CTRL3 0x68 15662306a36Sopenharmony_ci#define RT298_DEPOP_CTRL4 0x69 15762306a36Sopenharmony_ci#define RT298_IRQ_FLAG_CTRL 0x7c 15862306a36Sopenharmony_ci 15962306a36Sopenharmony_ci/* SPDIF (0x06) */ 16062306a36Sopenharmony_ci#define RT298_SPDIF_SEL_SFT 0 16162306a36Sopenharmony_ci#define RT298_SPDIF_SEL_PCM0 0 16262306a36Sopenharmony_ci#define RT298_SPDIF_SEL_PCM1 1 16362306a36Sopenharmony_ci#define RT298_SPDIF_SEL_SPOUT 2 16462306a36Sopenharmony_ci#define RT298_SPDIF_SEL_PP 3 16562306a36Sopenharmony_ci 16662306a36Sopenharmony_ci/* RECMIX (0x0b) */ 16762306a36Sopenharmony_ci#define RT298_M_REC_BEEP_SFT 0 16862306a36Sopenharmony_ci#define RT298_M_REC_LINE1_SFT 1 16962306a36Sopenharmony_ci#define RT298_M_REC_MIC1_SFT 2 17062306a36Sopenharmony_ci#define RT298_M_REC_I2S_SFT 3 17162306a36Sopenharmony_ci 17262306a36Sopenharmony_ci/* Front (0x0c) */ 17362306a36Sopenharmony_ci#define RT298_M_FRONT_DAC_SFT 0 17462306a36Sopenharmony_ci#define RT298_M_FRONT_REC_SFT 1 17562306a36Sopenharmony_ci 17662306a36Sopenharmony_ci/* SPK-OUT (0x14) */ 17762306a36Sopenharmony_ci#define RT298_M_SPK_MUX_SFT 14 17862306a36Sopenharmony_ci#define RT298_SPK_SEL_MASK 0x1 17962306a36Sopenharmony_ci#define RT298_SPK_SEL_SFT 0 18062306a36Sopenharmony_ci#define RT298_SPK_SEL_F 0 18162306a36Sopenharmony_ci#define RT298_SPK_SEL_S 1 18262306a36Sopenharmony_ci 18362306a36Sopenharmony_ci/* HP-OUT (0x21) */ 18462306a36Sopenharmony_ci#define RT298_M_HP_MUX_SFT 14 18562306a36Sopenharmony_ci#define RT298_HP_SEL_MASK 0x1 18662306a36Sopenharmony_ci#define RT298_HP_SEL_SFT 0 18762306a36Sopenharmony_ci#define RT298_HP_SEL_F 0 18862306a36Sopenharmony_ci#define RT298_HP_SEL_S 1 18962306a36Sopenharmony_ci 19062306a36Sopenharmony_ci/* ADC (0x22) (0x23) */ 19162306a36Sopenharmony_ci#define RT298_ADC_SEL_MASK 0x7 19262306a36Sopenharmony_ci#define RT298_ADC_SEL_SFT 0 19362306a36Sopenharmony_ci#define RT298_ADC_SEL_SURR 0 19462306a36Sopenharmony_ci#define RT298_ADC_SEL_FRONT 1 19562306a36Sopenharmony_ci#define RT298_ADC_SEL_DMIC 2 19662306a36Sopenharmony_ci#define RT298_ADC_SEL_BEEP 4 19762306a36Sopenharmony_ci#define RT298_ADC_SEL_LINE1 5 19862306a36Sopenharmony_ci#define RT298_ADC_SEL_I2S 6 19962306a36Sopenharmony_ci#define RT298_ADC_SEL_MIC1 7 20062306a36Sopenharmony_ci 20162306a36Sopenharmony_ci#define RT298_SCLK_S_MCLK 0 20262306a36Sopenharmony_ci#define RT298_SCLK_S_PLL 1 20362306a36Sopenharmony_ci 20462306a36Sopenharmony_cienum { 20562306a36Sopenharmony_ci RT298_AIF1, 20662306a36Sopenharmony_ci RT298_AIF2, 20762306a36Sopenharmony_ci RT298_AIFS, 20862306a36Sopenharmony_ci}; 20962306a36Sopenharmony_ci 21062306a36Sopenharmony_ci#endif /* __RT298_H__ */ 21162306a36Sopenharmony_ci 212