Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * rt700.h -- RT700 ALSA SoC audio driver header
0004  *
0005  * Copyright(c) 2019 Realtek Semiconductor Corp.
0006  */
0007 
0008 #ifndef __RT700_H__
0009 #define __RT700_H__
0010 
0011 extern const struct dev_pm_ops rt700_runtime_pm;
0012 
0013 struct  rt700_priv {
0014     struct snd_soc_component *component;
0015     struct regmap *regmap;
0016     struct regmap *sdw_regmap;
0017     struct sdw_slave *slave;
0018     enum sdw_slave_status status;
0019     struct sdw_bus_params params;
0020     bool hw_init;
0021     bool first_hw_init;
0022     struct snd_soc_jack *hs_jack;
0023     struct delayed_work jack_detect_work;
0024     struct delayed_work jack_btn_check_work;
0025     int jack_type;
0026     struct mutex disable_irq_lock; /* imp-def irq lock protection */
0027     bool disable_irq;
0028 };
0029 
0030 struct sdw_stream_data {
0031     struct sdw_stream_runtime *sdw_stream;
0032 };
0033 
0034 /* NID */
0035 #define RT700_AUDIO_FUNCTION_GROUP          0x01
0036 #define RT700_DAC_OUT1                  0x02
0037 #define RT700_DAC_OUT2                  0x03
0038 #define RT700_ADC_IN1                   0x09
0039 #define RT700_ADC_IN2                   0x08
0040 #define RT700_DMIC1                 0x12
0041 #define RT700_DMIC2                 0x13
0042 #define RT700_SPK_OUT                   0x14
0043 #define RT700_MIC2                  0x19
0044 #define RT700_LINE1                 0x1a
0045 #define RT700_LINE2                 0x1b
0046 #define RT700_BEEP                  0x1d
0047 #define RT700_SPDIF                 0x1e
0048 #define RT700_VENDOR_REGISTERS              0x20
0049 #define RT700_HP_OUT                    0x21
0050 #define RT700_MIXER_IN1                 0x22
0051 #define RT700_MIXER_IN2                 0x23
0052 #define RT700_INLINE_CMD                0x55
0053 
0054 /* Index (NID:20h) */
0055 #define RT700_DAC_DC_CALI_CTL1              0x00
0056 #define RT700_PARA_VERB_CTL             0x1a
0057 #define RT700_COMBO_JACK_AUTO_CTL1              0x45
0058 #define RT700_COMBO_JACK_AUTO_CTL2              0x46
0059 #define RT700_INLINE_CMD_CTL                0x48
0060 #define RT700_DIGITAL_MISC_CTRL4            0x4a
0061 #define RT700_VREFOUT_CTL               0x6b
0062 #define RT700_FSM_CTL               0x6f
0063 #define RT700_IRQ_FLAG_TABLE1               0x80
0064 #define RT700_IRQ_FLAG_TABLE2               0x81
0065 #define RT700_IRQ_FLAG_TABLE3               0x82
0066 
0067 /* Verb */
0068 #define RT700_VERB_SET_CONNECT_SEL          0x3100
0069 #define RT700_VERB_SET_EAPD_BTLENABLE           0x3c00
0070 #define RT700_VERB_GET_CONNECT_SEL          0xb100
0071 #define RT700_VERB_SET_POWER_STATE          0x3500
0072 #define RT700_VERB_SET_CHANNEL_STREAMID         0x3600
0073 #define RT700_VERB_SET_PIN_WIDGET_CONTROL       0x3700
0074 #define RT700_VERB_SET_UNSOLICITED_ENABLE       0x3800
0075 #define RT700_SET_AMP_GAIN_MUTE_H           0x7300
0076 #define RT700_SET_AMP_GAIN_MUTE_L           0x8380
0077 #define RT700_VERB_GET_PIN_SENSE            0xb900
0078 
0079 #define RT700_READ_HDA_3                0x2012
0080 #define RT700_READ_HDA_2                0x2013
0081 #define RT700_READ_HDA_1                0x2014
0082 #define RT700_READ_HDA_0                0x2015
0083 #define RT700_PRIV_INDEX_W_H                0x7520
0084 #define RT700_PRIV_INDEX_W_L                0x85a0
0085 #define RT700_PRIV_DATA_W_H             0x7420
0086 #define RT700_PRIV_DATA_W_L             0x84a0
0087 #define RT700_PRIV_INDEX_R_H                0x9d20
0088 #define RT700_PRIV_INDEX_R_L                0xada0
0089 #define RT700_PRIV_DATA_R_H             0x9c20
0090 #define RT700_PRIV_DATA_R_L             0xaca0
0091 #define RT700_DAC_FORMAT_H              0x7203
0092 #define RT700_DAC_FORMAT_L              0x8283
0093 #define RT700_ADC_FORMAT_H              0x7209
0094 #define RT700_ADC_FORMAT_L              0x8289
0095 #define RT700_SET_AUDIO_POWER_STATE\
0096     (RT700_VERB_SET_POWER_STATE | RT700_AUDIO_FUNCTION_GROUP)
0097 #define RT700_SET_PIN_DMIC1\
0098     (RT700_VERB_SET_PIN_WIDGET_CONTROL | RT700_DMIC1)
0099 #define RT700_SET_PIN_DMIC2\
0100     (RT700_VERB_SET_PIN_WIDGET_CONTROL | RT700_DMIC2)
0101 #define RT700_SET_PIN_SPK\
0102     (RT700_VERB_SET_PIN_WIDGET_CONTROL | RT700_SPK_OUT)
0103 #define RT700_SET_PIN_HP\
0104     (RT700_VERB_SET_PIN_WIDGET_CONTROL | RT700_HP_OUT)
0105 #define RT700_SET_PIN_MIC2\
0106     (RT700_VERB_SET_PIN_WIDGET_CONTROL | RT700_MIC2)
0107 #define RT700_SET_PIN_LINE1\
0108     (RT700_VERB_SET_PIN_WIDGET_CONTROL | RT700_LINE1)
0109 #define RT700_SET_PIN_LINE2\
0110     (RT700_VERB_SET_PIN_WIDGET_CONTROL | RT700_LINE2)
0111 #define RT700_SET_MIC2_UNSOLICITED_ENABLE\
0112     (RT700_VERB_SET_UNSOLICITED_ENABLE | RT700_MIC2)
0113 #define RT700_SET_HP_UNSOLICITED_ENABLE\
0114     (RT700_VERB_SET_UNSOLICITED_ENABLE | RT700_HP_OUT)
0115 #define RT700_SET_INLINE_UNSOLICITED_ENABLE\
0116     (RT700_VERB_SET_UNSOLICITED_ENABLE | RT700_INLINE_CMD)
0117 #define RT700_SET_STREAMID_DAC1\
0118     (RT700_VERB_SET_CHANNEL_STREAMID | RT700_DAC_OUT1)
0119 #define RT700_SET_STREAMID_DAC2\
0120     (RT700_VERB_SET_CHANNEL_STREAMID | RT700_DAC_OUT2)
0121 #define RT700_SET_STREAMID_ADC1\
0122     (RT700_VERB_SET_CHANNEL_STREAMID | RT700_ADC_IN1)
0123 #define RT700_SET_STREAMID_ADC2\
0124     (RT700_VERB_SET_CHANNEL_STREAMID | RT700_ADC_IN2)
0125 #define RT700_SET_GAIN_DAC1_L\
0126     (RT700_SET_AMP_GAIN_MUTE_L | RT700_DAC_OUT1)
0127 #define RT700_SET_GAIN_DAC1_H\
0128     (RT700_SET_AMP_GAIN_MUTE_H | RT700_DAC_OUT1)
0129 #define RT700_SET_GAIN_ADC1_L\
0130     (RT700_SET_AMP_GAIN_MUTE_L | RT700_ADC_IN1)
0131 #define RT700_SET_GAIN_ADC1_H\
0132     (RT700_SET_AMP_GAIN_MUTE_H | RT700_ADC_IN1)
0133 #define RT700_SET_GAIN_ADC2_L\
0134     (RT700_SET_AMP_GAIN_MUTE_L | RT700_ADC_IN2)
0135 #define RT700_SET_GAIN_ADC2_H\
0136     (RT700_SET_AMP_GAIN_MUTE_H | RT700_ADC_IN2)
0137 #define RT700_SET_GAIN_AMIC_L\
0138     (RT700_SET_AMP_GAIN_MUTE_L | RT700_MIC2)
0139 #define RT700_SET_GAIN_AMIC_H\
0140     (RT700_SET_AMP_GAIN_MUTE_H | RT700_MIC2)
0141 #define RT700_SET_GAIN_HP_L\
0142     (RT700_SET_AMP_GAIN_MUTE_L | RT700_HP_OUT)
0143 #define RT700_SET_GAIN_HP_H\
0144     (RT700_SET_AMP_GAIN_MUTE_H | RT700_HP_OUT)
0145 #define RT700_SET_GAIN_SPK_L\
0146     (RT700_SET_AMP_GAIN_MUTE_L | RT700_SPK_OUT)
0147 #define RT700_SET_GAIN_SPK_H\
0148     (RT700_SET_AMP_GAIN_MUTE_H | RT700_SPK_OUT)
0149 #define RT700_SET_EAPD_SPK\
0150     (RT700_VERB_SET_EAPD_BTLENABLE | RT700_SPK_OUT)
0151 
0152 /* combo jack auto switch control 2 (0x46)(NID:20h) */
0153 #define RT700_COMBOJACK_AUTO_DET_STATUS         (0x1 << 11)
0154 #define RT700_COMBOJACK_AUTO_DET_TRS            (0x1 << 10)
0155 #define RT700_COMBOJACK_AUTO_DET_CTIA           (0x1 << 9)
0156 #define RT700_COMBOJACK_AUTO_DET_OMTP           (0x1 << 8)
0157 
0158 #define RT700_EAPD_HIGH                 0x2
0159 #define RT700_EAPD_LOW                  0x0
0160 #define RT700_MUTE_SFT                  7
0161 #define RT700_DIR_IN_SFT                6
0162 #define RT700_DIR_OUT_SFT               7
0163 
0164 enum {
0165     RT700_AIF1,
0166     RT700_AIF2,
0167     RT700_AIFS,
0168 };
0169 
0170 int rt700_io_init(struct device *dev, struct sdw_slave *slave);
0171 int rt700_init(struct device *dev, struct regmap *sdw_regmap,
0172            struct regmap *regmap, struct sdw_slave *slave);
0173 
0174 int rt700_jack_detect(struct rt700_priv *rt700, bool *hp, bool *mic);
0175 int rt700_clock_config(struct device *dev);
0176 #endif /* __RT700_H__ */