1 /* SPDX-License-Identifier: GPL-2.0-only */ << 2 /* 1 /* 3 * rt286.h -- RT286 ALSA SoC audio driver 2 * rt286.h -- RT286 ALSA SoC audio driver 4 * 3 * 5 * Copyright 2011 Realtek Microelectronics 4 * Copyright 2011 Realtek Microelectronics 6 * Author: Johnny Hsu <johnnyhsu@realtek.com> 5 * Author: Johnny Hsu <johnnyhsu@realtek.com> >> 6 * >> 7 * This program is free software; you can redistribute it and/or modify >> 8 * it under the terms of the GNU General Public License version 2 as >> 9 * published by the Free Software Foundation. 7 */ 10 */ 8 11 9 #ifndef __RT286_H__ 12 #ifndef __RT286_H__ 10 #define __RT286_H__ 13 #define __RT286_H__ 11 14 12 #define VERB_CMD(V, N, D) ((N << 20) | (V << 8 15 #define VERB_CMD(V, N, D) ((N << 20) | (V << 8) | D) 13 16 14 #define RT286_AUDIO_FUNCTION_GROUP 17 #define RT286_AUDIO_FUNCTION_GROUP 0x01 15 #define RT286_DAC_OUT1 18 #define RT286_DAC_OUT1 0x02 16 #define RT286_DAC_OUT2 19 #define RT286_DAC_OUT2 0x03 17 #define RT286_ADC_IN1 20 #define RT286_ADC_IN1 0x09 18 #define RT286_ADC_IN2 21 #define RT286_ADC_IN2 0x08 19 #define RT286_MIXER_IN 22 #define RT286_MIXER_IN 0x0b 20 #define RT286_MIXER_OUT1 23 #define RT286_MIXER_OUT1 0x0c 21 #define RT286_MIXER_OUT2 24 #define RT286_MIXER_OUT2 0x0d 22 #define RT286_DMIC1 25 #define RT286_DMIC1 0x12 23 #define RT286_DMIC2 26 #define RT286_DMIC2 0x13 24 #define RT286_SPK_OUT 27 #define RT286_SPK_OUT 0x14 25 #define RT286_MIC1 28 #define RT286_MIC1 0x18 26 #define RT286_LINE1 29 #define RT286_LINE1 0x1a 27 #define RT286_BEEP 30 #define RT286_BEEP 0x1d 28 #define RT286_SPDIF 31 #define RT286_SPDIF 0x1e 29 #define RT286_VENDOR_REGISTERS 32 #define RT286_VENDOR_REGISTERS 0x20 30 #define RT286_HP_OUT 33 #define RT286_HP_OUT 0x21 31 #define RT286_MIXER_IN1 34 #define RT286_MIXER_IN1 0x22 32 #define RT286_MIXER_IN2 35 #define RT286_MIXER_IN2 0x23 33 36 34 #define RT286_SET_PIN_SFT 37 #define RT286_SET_PIN_SFT 6 35 #define RT286_SET_PIN_ENABLE 38 #define RT286_SET_PIN_ENABLE 0x40 36 #define RT286_SET_PIN_DISABLE 39 #define RT286_SET_PIN_DISABLE 0 37 #define RT286_SET_EAPD_HIGH 40 #define RT286_SET_EAPD_HIGH 0x2 38 #define RT286_SET_EAPD_LOW 41 #define RT286_SET_EAPD_LOW 0 39 42 40 #define RT286_MUTE_SFT 43 #define RT286_MUTE_SFT 7 41 44 42 /* Verb commands */ 45 /* Verb commands */ 43 #define RT286_GET_PARAM(NID, PARAM) VERB_CMD(A 46 #define RT286_GET_PARAM(NID, PARAM) VERB_CMD(AC_VERB_PARAMETERS, NID, PARAM) 44 #define RT286_SET_POWER(NID) VERB_CMD(AC_VERB_ 47 #define RT286_SET_POWER(NID) VERB_CMD(AC_VERB_SET_POWER_STATE, NID, 0) 45 #define RT286_SET_AUDIO_POWER RT286_SET_POWER( 48 #define RT286_SET_AUDIO_POWER RT286_SET_POWER(RT286_AUDIO_FUNCTION_GROUP) 46 #define RT286_SET_HPO_POWER RT286_SET_POWER(RT 49 #define RT286_SET_HPO_POWER RT286_SET_POWER(RT286_HP_OUT) 47 #define RT286_SET_SPK_POWER RT286_SET_POWER(RT 50 #define RT286_SET_SPK_POWER RT286_SET_POWER(RT286_SPK_OUT) 48 #define RT286_SET_DMIC1_POWER RT286_SET_POWER( 51 #define RT286_SET_DMIC1_POWER RT286_SET_POWER(RT286_DMIC1) 49 #define RT286_SPK_MUX\ 52 #define RT286_SPK_MUX\ 50 VERB_CMD(AC_VERB_SET_CONNECT_SEL, RT28 53 VERB_CMD(AC_VERB_SET_CONNECT_SEL, RT286_SPK_OUT, 0) 51 #define RT286_HPO_MUX\ 54 #define RT286_HPO_MUX\ 52 VERB_CMD(AC_VERB_SET_CONNECT_SEL, RT28 55 VERB_CMD(AC_VERB_SET_CONNECT_SEL, RT286_HP_OUT, 0) 53 #define RT286_ADC0_MUX\ 56 #define RT286_ADC0_MUX\ 54 VERB_CMD(AC_VERB_SET_CONNECT_SEL, RT28 57 VERB_CMD(AC_VERB_SET_CONNECT_SEL, RT286_MIXER_IN1, 0) 55 #define RT286_ADC1_MUX\ 58 #define RT286_ADC1_MUX\ 56 VERB_CMD(AC_VERB_SET_CONNECT_SEL, RT28 59 VERB_CMD(AC_VERB_SET_CONNECT_SEL, RT286_MIXER_IN2, 0) 57 #define RT286_SET_MIC1\ 60 #define RT286_SET_MIC1\ 58 VERB_CMD(AC_VERB_SET_PIN_WIDGET_CONTRO 61 VERB_CMD(AC_VERB_SET_PIN_WIDGET_CONTROL, RT286_MIC1, 0) 59 #define RT286_SET_PIN_HPO\ 62 #define RT286_SET_PIN_HPO\ 60 VERB_CMD(AC_VERB_SET_PIN_WIDGET_CONTRO 63 VERB_CMD(AC_VERB_SET_PIN_WIDGET_CONTROL, RT286_HP_OUT, 0) 61 #define RT286_SET_PIN_SPK\ 64 #define RT286_SET_PIN_SPK\ 62 VERB_CMD(AC_VERB_SET_PIN_WIDGET_CONTRO 65 VERB_CMD(AC_VERB_SET_PIN_WIDGET_CONTROL, RT286_SPK_OUT, 0) 63 #define RT286_SET_PIN_DMIC1\ 66 #define RT286_SET_PIN_DMIC1\ 64 VERB_CMD(AC_VERB_SET_PIN_WIDGET_CONTRO 67 VERB_CMD(AC_VERB_SET_PIN_WIDGET_CONTROL, RT286_DMIC1, 0) 65 #define RT286_SPK_EAPD\ 68 #define RT286_SPK_EAPD\ 66 VERB_CMD(AC_VERB_SET_EAPD_BTLENABLE, R 69 VERB_CMD(AC_VERB_SET_EAPD_BTLENABLE, RT286_SPK_OUT, 0) 67 #define RT286_SET_AMP_GAIN_HPO\ 70 #define RT286_SET_AMP_GAIN_HPO\ 68 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT 71 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT286_HP_OUT, 0) 69 #define RT286_SET_AMP_GAIN_ADC_IN1\ 72 #define RT286_SET_AMP_GAIN_ADC_IN1\ 70 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT 73 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT286_ADC_IN1, 0) 71 #define RT286_SET_AMP_GAIN_ADC_IN2\ 74 #define RT286_SET_AMP_GAIN_ADC_IN2\ 72 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT 75 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT286_ADC_IN2, 0) 73 #define RT286_GET_HP_SENSE\ 76 #define RT286_GET_HP_SENSE\ 74 VERB_CMD(AC_VERB_GET_PIN_SENSE, RT286_ 77 VERB_CMD(AC_VERB_GET_PIN_SENSE, RT286_HP_OUT, 0) 75 #define RT286_GET_MIC1_SENSE\ 78 #define RT286_GET_MIC1_SENSE\ 76 VERB_CMD(AC_VERB_GET_PIN_SENSE, RT286_ 79 VERB_CMD(AC_VERB_GET_PIN_SENSE, RT286_MIC1, 0) 77 #define RT286_SET_DMIC2_DEFAULT\ 80 #define RT286_SET_DMIC2_DEFAULT\ 78 VERB_CMD(AC_VERB_SET_CONFIG_DEFAULT_BY 81 VERB_CMD(AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, RT286_DMIC2, 0) 79 #define RT286_DACL_GAIN\ 82 #define RT286_DACL_GAIN\ 80 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT 83 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT286_DAC_OUT1, 0xa000) 81 #define RT286_DACR_GAIN\ 84 #define RT286_DACR_GAIN\ 82 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT 85 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT286_DAC_OUT1, 0x9000) 83 #define RT286_ADCL_GAIN\ 86 #define RT286_ADCL_GAIN\ 84 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT 87 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT286_ADC_IN1, 0x6000) 85 #define RT286_ADCR_GAIN\ 88 #define RT286_ADCR_GAIN\ 86 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT 89 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT286_ADC_IN1, 0x5000) 87 #define RT286_MIC_GAIN\ 90 #define RT286_MIC_GAIN\ 88 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT 91 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT286_MIC1, 0x7000) 89 #define RT286_SPOL_GAIN\ 92 #define RT286_SPOL_GAIN\ 90 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT 93 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT286_SPK_OUT, 0xa000) 91 #define RT286_SPOR_GAIN\ 94 #define RT286_SPOR_GAIN\ 92 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT 95 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT286_SPK_OUT, 0x9000) 93 #define RT286_HPOL_GAIN\ 96 #define RT286_HPOL_GAIN\ 94 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT 97 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT286_HP_OUT, 0xa000) 95 #define RT286_HPOR_GAIN\ 98 #define RT286_HPOR_GAIN\ 96 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT 99 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT286_HP_OUT, 0x9000) 97 #define RT286_F_DAC_SWITCH\ 100 #define RT286_F_DAC_SWITCH\ 98 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT 101 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT286_MIXER_OUT1, 0x7000) 99 #define RT286_F_RECMIX_SWITCH\ 102 #define RT286_F_RECMIX_SWITCH\ 100 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT 103 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT286_MIXER_OUT1, 0x7100) 101 #define RT286_REC_MIC_SWITCH\ 104 #define RT286_REC_MIC_SWITCH\ 102 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT 105 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT286_MIXER_IN, 0x7000) 103 #define RT286_REC_I2S_SWITCH\ 106 #define RT286_REC_I2S_SWITCH\ 104 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT 107 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT286_MIXER_IN, 0x7100) 105 #define RT286_REC_LINE_SWITCH\ 108 #define RT286_REC_LINE_SWITCH\ 106 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT 109 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT286_MIXER_IN, 0x7200) 107 #define RT286_REC_BEEP_SWITCH\ 110 #define RT286_REC_BEEP_SWITCH\ 108 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT 111 VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT286_MIXER_IN, 0x7300) 109 #define RT286_DAC_FORMAT\ 112 #define RT286_DAC_FORMAT\ 110 VERB_CMD(AC_VERB_SET_STREAM_FORMAT, RT 113 VERB_CMD(AC_VERB_SET_STREAM_FORMAT, RT286_DAC_OUT1, 0) 111 #define RT286_ADC_FORMAT\ 114 #define RT286_ADC_FORMAT\ 112 VERB_CMD(AC_VERB_SET_STREAM_FORMAT, RT 115 VERB_CMD(AC_VERB_SET_STREAM_FORMAT, RT286_ADC_IN1, 0) 113 #define RT286_COEF_INDEX\ 116 #define RT286_COEF_INDEX\ 114 VERB_CMD(AC_VERB_SET_COEF_INDEX, RT286 117 VERB_CMD(AC_VERB_SET_COEF_INDEX, RT286_VENDOR_REGISTERS, 0) 115 #define RT286_PROC_COEF\ 118 #define RT286_PROC_COEF\ 116 VERB_CMD(AC_VERB_SET_PROC_COEF, RT286_ 119 VERB_CMD(AC_VERB_SET_PROC_COEF, RT286_VENDOR_REGISTERS, 0) 117 #define RT286_SET_GPIO_MASK\ 120 #define RT286_SET_GPIO_MASK\ 118 VERB_CMD(AC_VERB_SET_GPIO_MASK, RT286_ 121 VERB_CMD(AC_VERB_SET_GPIO_MASK, RT286_AUDIO_FUNCTION_GROUP, 0) 119 #define RT286_SET_GPIO_DIRECTION\ 122 #define RT286_SET_GPIO_DIRECTION\ 120 VERB_CMD(AC_VERB_SET_GPIO_DIRECTION, R 123 VERB_CMD(AC_VERB_SET_GPIO_DIRECTION, RT286_AUDIO_FUNCTION_GROUP, 0) 121 #define RT286_SET_GPIO_DATA\ 124 #define RT286_SET_GPIO_DATA\ 122 VERB_CMD(AC_VERB_SET_GPIO_DATA, RT286_ 125 VERB_CMD(AC_VERB_SET_GPIO_DATA, RT286_AUDIO_FUNCTION_GROUP, 0) 123 126 124 /* Index registers */ 127 /* Index registers */ 125 #define RT286_A_BIAS_CTRL1 0x01 128 #define RT286_A_BIAS_CTRL1 0x01 126 #define RT286_A_BIAS_CTRL2 0x02 129 #define RT286_A_BIAS_CTRL2 0x02 127 #define RT286_POWER_CTRL1 0x03 130 #define RT286_POWER_CTRL1 0x03 128 #define RT286_A_BIAS_CTRL3 0x04 131 #define RT286_A_BIAS_CTRL3 0x04 129 #define RT286_POWER_CTRL2 0x08 132 #define RT286_POWER_CTRL2 0x08 130 #define RT286_I2S_CTRL1 0x09 133 #define RT286_I2S_CTRL1 0x09 131 #define RT286_I2S_CTRL2 0x0a 134 #define RT286_I2S_CTRL2 0x0a 132 #define RT286_CLK_DIV 0x0b 135 #define RT286_CLK_DIV 0x0b 133 #define RT286_DC_GAIN 0x0d 136 #define RT286_DC_GAIN 0x0d 134 #define RT286_POWER_CTRL3 0x0f 137 #define RT286_POWER_CTRL3 0x0f 135 #define RT286_MIC1_DET_CTRL 0x19 138 #define RT286_MIC1_DET_CTRL 0x19 136 #define RT286_MISC_CTRL1 0x20 139 #define RT286_MISC_CTRL1 0x20 137 #define RT286_GPIO_CTRL 0x29 140 #define RT286_GPIO_CTRL 0x29 138 #define RT286_IRQ_CTRL 0x33 141 #define RT286_IRQ_CTRL 0x33 139 #define RT286_PLL_CTRL1 0x49 142 #define RT286_PLL_CTRL1 0x49 140 #define RT286_CBJ_CTRL1 0x4f 143 #define RT286_CBJ_CTRL1 0x4f 141 #define RT286_CBJ_CTRL2 0x50 144 #define RT286_CBJ_CTRL2 0x50 142 #define RT286_PLL_CTRL 0x63 145 #define RT286_PLL_CTRL 0x63 143 #define RT286_DEPOP_CTRL1 0x66 146 #define RT286_DEPOP_CTRL1 0x66 144 #define RT286_DEPOP_CTRL2 0x67 147 #define RT286_DEPOP_CTRL2 0x67 145 #define RT286_DEPOP_CTRL3 0x68 148 #define RT286_DEPOP_CTRL3 0x68 146 #define RT286_DEPOP_CTRL4 0x69 149 #define RT286_DEPOP_CTRL4 0x69 147 150 148 /* SPDIF (0x06) */ 151 /* SPDIF (0x06) */ 149 #define RT286_SPDIF_SEL_SFT 0 152 #define RT286_SPDIF_SEL_SFT 0 150 #define RT286_SPDIF_SEL_PCM0 0 153 #define RT286_SPDIF_SEL_PCM0 0 151 #define RT286_SPDIF_SEL_PCM1 1 154 #define RT286_SPDIF_SEL_PCM1 1 152 #define RT286_SPDIF_SEL_SPOUT 2 155 #define RT286_SPDIF_SEL_SPOUT 2 153 #define RT286_SPDIF_SEL_PP 3 156 #define RT286_SPDIF_SEL_PP 3 154 157 155 /* RECMIX (0x0b) */ 158 /* RECMIX (0x0b) */ 156 #define RT286_M_REC_BEEP_SFT 0 159 #define RT286_M_REC_BEEP_SFT 0 157 #define RT286_M_REC_LINE1_SFT 1 160 #define RT286_M_REC_LINE1_SFT 1 158 #define RT286_M_REC_MIC1_SFT 2 161 #define RT286_M_REC_MIC1_SFT 2 159 #define RT286_M_REC_I2S_SFT 3 162 #define RT286_M_REC_I2S_SFT 3 160 163 161 /* Front (0x0c) */ 164 /* Front (0x0c) */ 162 #define RT286_M_FRONT_DAC_SFT 0 165 #define RT286_M_FRONT_DAC_SFT 0 163 #define RT286_M_FRONT_REC_SFT 1 166 #define RT286_M_FRONT_REC_SFT 1 164 167 165 /* SPK-OUT (0x14) */ 168 /* SPK-OUT (0x14) */ 166 #define RT286_M_SPK_MUX_SFT 14 169 #define RT286_M_SPK_MUX_SFT 14 167 #define RT286_SPK_SEL_MASK 0x1 170 #define RT286_SPK_SEL_MASK 0x1 168 #define RT286_SPK_SEL_SFT 0 171 #define RT286_SPK_SEL_SFT 0 169 #define RT286_SPK_SEL_F 0 172 #define RT286_SPK_SEL_F 0 170 #define RT286_SPK_SEL_S 1 173 #define RT286_SPK_SEL_S 1 171 174 172 /* HP-OUT (0x21) */ 175 /* HP-OUT (0x21) */ 173 #define RT286_M_HP_MUX_SFT 14 176 #define RT286_M_HP_MUX_SFT 14 174 #define RT286_HP_SEL_MASK 0x1 177 #define RT286_HP_SEL_MASK 0x1 175 #define RT286_HP_SEL_SFT 0 178 #define RT286_HP_SEL_SFT 0 176 #define RT286_HP_SEL_F 0 179 #define RT286_HP_SEL_F 0 177 #define RT286_HP_SEL_S 1 180 #define RT286_HP_SEL_S 1 178 181 179 /* ADC (0x22) (0x23) */ 182 /* ADC (0x22) (0x23) */ 180 #define RT286_ADC_SEL_MASK 0x7 183 #define RT286_ADC_SEL_MASK 0x7 181 #define RT286_ADC_SEL_SFT 0 184 #define RT286_ADC_SEL_SFT 0 182 #define RT286_ADC_SEL_SURR 0 185 #define RT286_ADC_SEL_SURR 0 183 #define RT286_ADC_SEL_FRONT 1 186 #define RT286_ADC_SEL_FRONT 1 184 #define RT286_ADC_SEL_DMIC 2 187 #define RT286_ADC_SEL_DMIC 2 185 #define RT286_ADC_SEL_BEEP 4 188 #define RT286_ADC_SEL_BEEP 4 186 #define RT286_ADC_SEL_LINE1 5 189 #define RT286_ADC_SEL_LINE1 5 187 #define RT286_ADC_SEL_I2S 6 190 #define RT286_ADC_SEL_I2S 6 188 #define RT286_ADC_SEL_MIC1 7 191 #define RT286_ADC_SEL_MIC1 7 189 192 190 #define RT286_SCLK_S_MCLK 0 193 #define RT286_SCLK_S_MCLK 0 191 #define RT286_SCLK_S_PLL 1 194 #define RT286_SCLK_S_PLL 1 192 195 193 enum { 196 enum { 194 RT286_AIF1, 197 RT286_AIF1, 195 RT286_AIF2, 198 RT286_AIF2, 196 RT286_AIFS, 199 RT286_AIFS, 197 }; 200 }; >> 201 >> 202 int rt286_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *jack); 198 203 199 #endif /* __RT286_H__ */ 204 #endif /* __RT286_H__ */ 200 205 201 206
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.