Lines Matching +full:jack +full:- +full:det +full:- +full:rate
1 // SPDX-License-Identifier: GPL-2.0-only
3 * 88pm860x-codec.c -- 88PM860x ALSA SoC Audio Driver
23 #include <sound/jack.h>
26 #include "88pm860x-codec.h"
117 * This widget should be just after DAC & PGA in DAPM power-on sequence and
118 * before DAC & PGA in DAPM power-off sequence.
143 struct pm860x_det det; member
149 /* -9450dB to 0dB in 150dB steps ( mute instead of -9450dB) */
150 static const DECLARE_TLV_DB_SCALE(dpga_tlv, -9450, 150, 1);
152 /* -9dB to 0db in 3dB steps */
153 static const DECLARE_TLV_DB_SCALE(adc_tlv, -900, 300, 0);
155 /* {-23, -17, -13.5, -11, -9, -6, -3, 0}dB */
157 0, 0, TLV_DB_SCALE_ITEM(-2300, 0, 0),
158 1, 1, TLV_DB_SCALE_ITEM(-1700, 0, 0),
159 2, 2, TLV_DB_SCALE_ITEM(-1350, 0, 0),
160 3, 3, TLV_DB_SCALE_ITEM(-1100, 0, 0),
161 4, 7, TLV_DB_SCALE_ITEM(-900, 300, 0)
164 /* {0, 0, 0, -6, 0, 6, 12, 18}dB */
167 3, 7, TLV_DB_SCALE_ITEM(-600, 600, 0)
170 /* {-16, -13, -10, -7, -5.2, -3,3, -2.2, 0}dB, mute instead of -16dB */
172 0, 3, TLV_DB_SCALE_ITEM(-1600, 300, 1),
173 4, 4, TLV_DB_SCALE_ITEM(-520, 0, 0),
174 5, 5, TLV_DB_SCALE_ITEM(-330, 0, 0),
175 6, 7, TLV_DB_SCALE_ITEM(-220, 220, 0)
179 0, 1, TLV_DB_SCALE_ITEM(-12041, 602, 0),
180 2, 3, TLV_DB_SCALE_ITEM(-11087, 250, 0),
181 4, 5, TLV_DB_SCALE_ITEM(-10643, 158, 0),
182 6, 7, TLV_DB_SCALE_ITEM(-10351, 116, 0),
183 8, 9, TLV_DB_SCALE_ITEM(-10133, 92, 0),
184 10, 13, TLV_DB_SCALE_ITEM(-9958, 70, 0),
185 14, 17, TLV_DB_SCALE_ITEM(-9689, 53, 0),
186 18, 271, TLV_DB_SCALE_ITEM(-9484, 37, 0)
189 /* Sidetone Gain = M * 2^(-5-N) */
197 {-12041, 1, 15}, {-11439, 1, 14}, {-11087, 3, 15}, {-10837, 1, 13},
198 {-10643, 5, 15}, {-10485, 3, 14}, {-10351, 7, 15}, {-10235, 1, 12},
199 {-10133, 9, 15}, {-10041, 5, 14}, { -9958, 11, 15}, { -9883, 3, 13},
200 { -9813, 13, 15}, { -9749, 7, 14}, { -9689, 15, 15}, { -9633, 1, 11},
201 { -9580, 17, 15}, { -9531, 9, 14}, { -9484, 19, 15}, { -9439, 5, 13},
202 { -9397, 21, 15}, { -9356, 11, 14}, { -9318, 23, 15}, { -9281, 3, 12},
203 { -9245, 25, 15}, { -9211, 13, 14}, { -9178, 27, 15}, { -9147, 7, 13},
204 { -9116, 29, 15}, { -9087, 15, 14}, { -9058, 31, 15}, { -9031, 1, 10},
205 { -8978, 17, 14}, { -8929, 9, 13}, { -8882, 19, 14}, { -8837, 5, 12},
206 { -8795, 21, 14}, { -8754, 11, 13}, { -8716, 23, 14}, { -8679, 3, 11},
207 { -8643, 25, 14}, { -8609, 13, 13}, { -8576, 27, 14}, { -8545, 7, 12},
208 { -8514, 29, 14}, { -8485, 15, 13}, { -8456, 31, 14}, { -8429, 1, 9},
209 { -8376, 17, 13}, { -8327, 9, 12}, { -8280, 19, 13}, { -8235, 5, 11},
210 { -8193, 21, 13}, { -8152, 11, 12}, { -8114, 23, 13}, { -8077, 3, 10},
211 { -8041, 25, 13}, { -8007, 13, 12}, { -7974, 27, 13}, { -7943, 7, 11},
212 { -7912, 29, 13}, { -7883, 15, 12}, { -7854, 31, 13}, { -7827, 1, 8},
213 { -7774, 17, 12}, { -7724, 9, 11}, { -7678, 19, 12}, { -7633, 5, 10},
214 { -7591, 21, 12}, { -7550, 11, 11}, { -7512, 23, 12}, { -7475, 3, 9},
215 { -7439, 25, 12}, { -7405, 13, 11}, { -7372, 27, 12}, { -7341, 7, 10},
216 { -7310, 29, 12}, { -7281, 15, 11}, { -7252, 31, 12}, { -7225, 1, 7},
217 { -7172, 17, 11}, { -7122, 9, 10}, { -7075, 19, 11}, { -7031, 5, 9},
218 { -6989, 21, 11}, { -6948, 11, 10}, { -6910, 23, 11}, { -6873, 3, 8},
219 { -6837, 25, 11}, { -6803, 13, 10}, { -6770, 27, 11}, { -6739, 7, 9},
220 { -6708, 29, 11}, { -6679, 15, 10}, { -6650, 31, 11}, { -6623, 1, 6},
221 { -6570, 17, 10}, { -6520, 9, 9}, { -6473, 19, 10}, { -6429, 5, 8},
222 { -6386, 21, 10}, { -6346, 11, 9}, { -6307, 23, 10}, { -6270, 3, 7},
223 { -6235, 25, 10}, { -6201, 13, 9}, { -6168, 27, 10}, { -6137, 7, 8},
224 { -6106, 29, 10}, { -6077, 15, 9}, { -6048, 31, 10}, { -6021, 1, 5},
225 { -5968, 17, 9}, { -5918, 9, 8}, { -5871, 19, 9}, { -5827, 5, 7},
226 { -5784, 21, 9}, { -5744, 11, 8}, { -5705, 23, 9}, { -5668, 3, 6},
227 { -5633, 25, 9}, { -5599, 13, 8}, { -5566, 27, 9}, { -5535, 7, 7},
228 { -5504, 29, 9}, { -5475, 15, 8}, { -5446, 31, 9}, { -5419, 1, 4},
229 { -5366, 17, 8}, { -5316, 9, 7}, { -5269, 19, 8}, { -5225, 5, 6},
230 { -5182, 21, 8}, { -5142, 11, 7}, { -5103, 23, 8}, { -5066, 3, 5},
231 { -5031, 25, 8}, { -4997, 13, 7}, { -4964, 27, 8}, { -4932, 7, 6},
232 { -4902, 29, 8}, { -4873, 15, 7}, { -4844, 31, 8}, { -4816, 1, 3},
233 { -4764, 17, 7}, { -4714, 9, 6}, { -4667, 19, 7}, { -4623, 5, 5},
234 { -4580, 21, 7}, { -4540, 11, 6}, { -4501, 23, 7}, { -4464, 3, 4},
235 { -4429, 25, 7}, { -4395, 13, 6}, { -4362, 27, 7}, { -4330, 7, 5},
236 { -4300, 29, 7}, { -4270, 15, 6}, { -4242, 31, 7}, { -4214, 1, 2},
237 { -4162, 17, 6}, { -4112, 9, 5}, { -4065, 19, 6}, { -4021, 5, 4},
238 { -3978, 21, 6}, { -3938, 11, 5}, { -3899, 23, 6}, { -3862, 3, 3},
239 { -3827, 25, 6}, { -3793, 13, 5}, { -3760, 27, 6}, { -3728, 7, 4},
240 { -3698, 29, 6}, { -3668, 15, 5}, { -3640, 31, 6}, { -3612, 1, 1},
241 { -3560, 17, 5}, { -3510, 9, 4}, { -3463, 19, 5}, { -3419, 5, 3},
242 { -3376, 21, 5}, { -3336, 11, 4}, { -3297, 23, 5}, { -3260, 3, 2},
243 { -3225, 25, 5}, { -3191, 13, 4}, { -3158, 27, 5}, { -3126, 7, 3},
244 { -3096, 29, 5}, { -3066, 15, 4}, { -3038, 31, 5}, { -3010, 1, 0},
245 { -2958, 17, 4}, { -2908, 9, 3}, { -2861, 19, 4}, { -2816, 5, 2},
246 { -2774, 21, 4}, { -2734, 11, 3}, { -2695, 23, 4}, { -2658, 3, 1},
247 { -2623, 25, 4}, { -2589, 13, 3}, { -2556, 27, 4}, { -2524, 7, 2},
248 { -2494, 29, 4}, { -2464, 15, 3}, { -2436, 31, 4}, { -2408, 2, 0},
249 { -2356, 17, 3}, { -2306, 9, 2}, { -2259, 19, 3}, { -2214, 5, 1},
250 { -2172, 21, 3}, { -2132, 11, 2}, { -2093, 23, 3}, { -2056, 3, 0},
251 { -2021, 25, 3}, { -1987, 13, 2}, { -1954, 27, 3}, { -1922, 7, 1},
252 { -1892, 29, 3}, { -1862, 15, 2}, { -1834, 31, 3}, { -1806, 4, 0},
253 { -1754, 17, 2}, { -1704, 9, 1}, { -1657, 19, 2}, { -1612, 5, 0},
254 { -1570, 21, 2}, { -1530, 11, 1}, { -1491, 23, 2}, { -1454, 6, 0},
255 { -1419, 25, 2}, { -1384, 13, 1}, { -1352, 27, 2}, { -1320, 7, 0},
256 { -1290, 29, 2}, { -1260, 15, 1}, { -1232, 31, 2}, { -1204, 8, 0},
257 { -1151, 17, 1}, { -1102, 9, 0}, { -1055, 19, 1}, { -1010, 10, 0},
258 { -968, 21, 1}, { -928, 11, 0}, { -889, 23, 1}, { -852, 12, 0},
259 { -816, 25, 1}, { -782, 13, 0}, { -750, 27, 1}, { -718, 14, 0},
260 { -688, 29, 1}, { -658, 15, 0}, { -630, 31, 1}, { -602, 16, 0},
261 { -549, 17, 0}, { -500, 18, 0}, { -453, 19, 0}, { -408, 20, 0},
262 { -366, 21, 0}, { -325, 22, 0}, { -287, 23, 0}, { -250, 24, 0},
263 { -214, 25, 0}, { -180, 26, 0}, { -148, 27, 0}, { -116, 28, 0},
264 { -86, 29, 0}, { -56, 30, 0}, { -28, 31, 0}, { 0, 0, 0},
271 (struct soc_mixer_control *)kcontrol->private_value; in snd_soc_get_volsw_2r_st()
273 unsigned int reg = mc->reg; in snd_soc_get_volsw_2r_st()
274 unsigned int reg2 = mc->rreg; in snd_soc_get_volsw_2r_st()
284 ucontrol->value.integer.value[0] = i; in snd_soc_get_volsw_2r_st()
286 ucontrol->value.integer.value[1] = i; in snd_soc_get_volsw_2r_st()
295 (struct soc_mixer_control *)kcontrol->private_value; in snd_soc_put_volsw_2r_st()
297 unsigned int reg = mc->reg; in snd_soc_put_volsw_2r_st()
298 unsigned int reg2 = mc->rreg; in snd_soc_put_volsw_2r_st()
302 val = ucontrol->value.integer.value[0]; in snd_soc_put_volsw_2r_st()
303 val2 = ucontrol->value.integer.value[1]; in snd_soc_put_volsw_2r_st()
306 return -EINVAL; in snd_soc_put_volsw_2r_st()
328 (struct soc_mixer_control *)kcontrol->private_value; in snd_soc_get_volsw_2r_out()
330 unsigned int reg = mc->reg; in snd_soc_get_volsw_2r_out()
331 unsigned int reg2 = mc->rreg; in snd_soc_get_volsw_2r_out()
332 unsigned int shift = mc->shift; in snd_soc_get_volsw_2r_out()
333 int max = mc->max, val, val2; in snd_soc_get_volsw_2r_out()
334 unsigned int mask = (1 << fls(max)) - 1; in snd_soc_get_volsw_2r_out()
338 ucontrol->value.integer.value[0] = (max - val) & mask; in snd_soc_get_volsw_2r_out()
339 ucontrol->value.integer.value[1] = (max - val2) & mask; in snd_soc_get_volsw_2r_out()
348 (struct soc_mixer_control *)kcontrol->private_value; in snd_soc_put_volsw_2r_out()
350 unsigned int reg = mc->reg; in snd_soc_put_volsw_2r_out()
351 unsigned int reg2 = mc->rreg; in snd_soc_put_volsw_2r_out()
352 unsigned int shift = mc->shift; in snd_soc_put_volsw_2r_out()
353 int max = mc->max; in snd_soc_put_volsw_2r_out()
354 unsigned int mask = (1 << fls(max)) - 1; in snd_soc_put_volsw_2r_out()
359 val = ((max - ucontrol->value.integer.value[0]) & mask); in snd_soc_put_volsw_2r_out()
360 val2 = ((max - ucontrol->value.integer.value[1]) & mask); in snd_soc_put_volsw_2r_out()
382 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in pm860x_rsync_event()
385 * In order to avoid current on the load, mute power-on and power-off in pm860x_rsync_event()
399 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in pm860x_dac_event()
410 /* Auto mute in power-on sequence. */ in pm860x_dac_event()
423 /* Auto mute in power-off sequence. */ in pm860x_dac_event()
440 static const char *pm860x_opamp_texts[] = {"-50%", "-25%", "0%", "75%"};
442 static const char *pm860x_pa_texts[] = {"-33%", "0%", "33%", "66%"};
487 PM860X_SIDETONE_R_GAIN, 0, ARRAY_SIZE(st_table)-1,
907 struct snd_soc_component *component = codec_dai->component; in pm860x_mute_stream()
922 struct snd_soc_component *component = dai->component; in pm860x_pcm_hw_params()
934 return -EINVAL; in pm860x_pcm_hw_params()
939 /* sample rate */ in pm860x_pcm_hw_params()
954 return -EINVAL; in pm860x_pcm_hw_params()
964 struct snd_soc_component *component = codec_dai->component; in pm860x_pcm_set_dai_fmt()
967 int ret = -EINVAL; in pm860x_pcm_set_dai_fmt()
975 if (pm860x->dir == PM860X_CLK_DIR_OUT) { in pm860x_pcm_set_dai_fmt()
981 if (pm860x->dir == PM860X_CLK_DIR_IN) { in pm860x_pcm_set_dai_fmt()
1004 struct snd_soc_component *component = codec_dai->component; in pm860x_set_dai_sysclk()
1008 pm860x->dir = PM860X_CLK_DIR_OUT; in pm860x_set_dai_sysclk()
1010 return -EINVAL; in pm860x_set_dai_sysclk()
1019 struct snd_soc_component *component = dai->component; in pm860x_i2s_hw_params()
1031 return -EINVAL; in pm860x_i2s_hw_params()
1035 /* sample rate */ in pm860x_i2s_hw_params()
1059 return -EINVAL; in pm860x_i2s_hw_params()
1069 struct snd_soc_component *component = codec_dai->component; in pm860x_i2s_set_dai_fmt()
1078 if (pm860x->dir == PM860X_CLK_DIR_OUT) in pm860x_i2s_set_dai_fmt()
1081 return -EINVAL; in pm860x_i2s_set_dai_fmt()
1084 if (pm860x->dir == PM860X_CLK_DIR_IN) in pm860x_i2s_set_dai_fmt()
1087 return -EINVAL; in pm860x_i2s_set_dai_fmt()
1090 return -EINVAL; in pm860x_i2s_set_dai_fmt()
1098 return -EINVAL; in pm860x_i2s_set_dai_fmt()
1122 pm860x_reg_write(pm860x->i2c, REG_MISC2, data); in pm860x_set_bias_level()
1126 pm860x_reg_write(pm860x->i2c, REG_MISC2, data); in pm860x_set_bias_level()
1132 pm860x_set_bits(pm860x->i2c, REG_MISC2, data, 0); in pm860x_set_bias_level()
1160 .name = "88pm860x-pcm",
1181 .name = "88pm860x-i2s",
1209 status = pm860x_reg_read(pm860x->i2c, REG_STATUS_1); in pm860x_component_handler()
1210 shrt = pm860x_reg_read(pm860x->i2c, REG_SHORTS); in pm860x_component_handler()
1211 mask = pm860x->det.hs_shrt | pm860x->det.hook_det | pm860x->det.lo_shrt in pm860x_component_handler()
1212 | pm860x->det.hp_det; in pm860x_component_handler()
1217 trace_snd_soc_jack_irq(dev_name(pm860x->component->dev)); in pm860x_component_handler()
1220 if ((pm860x->det.hp_det & SND_JACK_HEADPHONE) in pm860x_component_handler()
1224 if ((pm860x->det.mic_det & SND_JACK_MICROPHONE) in pm860x_component_handler()
1228 if (pm860x->det.hs_shrt && (shrt & (SHORT_HS1 | SHORT_HS2))) in pm860x_component_handler()
1229 report |= pm860x->det.hs_shrt; in pm860x_component_handler()
1231 if (pm860x->det.hook_det && (status & HOOK_STATUS)) in pm860x_component_handler()
1232 report |= pm860x->det.hook_det; in pm860x_component_handler()
1234 if (pm860x->det.lo_shrt && (shrt & (SHORT_LO1 | SHORT_LO2))) in pm860x_component_handler()
1235 report |= pm860x->det.lo_shrt; in pm860x_component_handler()
1238 snd_soc_jack_report(pm860x->det.hp_jack, report, mask); in pm860x_component_handler()
1240 snd_soc_jack_report(pm860x->det.mic_jack, SND_JACK_MICROPHONE, in pm860x_component_handler()
1243 dev_dbg(pm860x->component->dev, "headphone report:0x%x, mask:%x\n", in pm860x_component_handler()
1245 dev_dbg(pm860x->component->dev, "microphone report:0x%x\n", mic_report); in pm860x_component_handler()
1250 struct snd_soc_jack *jack, in pm860x_hs_jack_detect() argument
1251 int det, int hook, int hs_shrt, int lo_shrt) in pm860x_hs_jack_detect() argument
1256 pm860x->det.hp_jack = jack; in pm860x_hs_jack_detect()
1257 pm860x->det.hp_det = det; in pm860x_hs_jack_detect()
1258 pm860x->det.hook_det = hook; in pm860x_hs_jack_detect()
1259 pm860x->det.hs_shrt = hs_shrt; in pm860x_hs_jack_detect()
1260 pm860x->det.lo_shrt = lo_shrt; in pm860x_hs_jack_detect()
1262 if (det & SND_JACK_HEADPHONE) in pm860x_hs_jack_detect()
1263 pm860x_set_bits(pm860x->i2c, REG_HS_DET, in pm860x_hs_jack_detect()
1268 pm860x_set_bits(pm860x->i2c, REG_SHORTS, data, data); in pm860x_hs_jack_detect()
1273 pm860x_set_bits(pm860x->i2c, REG_SHORTS, data, data); in pm860x_hs_jack_detect()
1283 struct snd_soc_jack *jack, int det) in pm860x_mic_jack_detect() argument
1287 pm860x->det.mic_jack = jack; in pm860x_mic_jack_detect()
1288 pm860x->det.mic_det = det; in pm860x_mic_jack_detect()
1290 if (det & SND_JACK_MICROPHONE) in pm860x_mic_jack_detect()
1291 pm860x_set_bits(pm860x->i2c, REG_MIC_DET, in pm860x_mic_jack_detect()
1305 pm860x->component = component; in pm860x_probe()
1306 snd_soc_component_init_regmap(component, pm860x->regmap); in pm860x_probe()
1309 ret = request_threaded_irq(pm860x->irq[i], NULL, in pm860x_probe()
1311 pm860x->name[i], pm860x); in pm860x_probe()
1313 dev_err(component->dev, "Failed to request IRQ!\n"); in pm860x_probe()
1321 while (--i >= 0) in pm860x_probe()
1322 free_irq(pm860x->irq[i], pm860x); in pm860x_probe()
1331 for (i = 3; i >= 0; i--) in pm860x_remove()
1332 free_irq(pm860x->irq[i], pm860x); in pm860x_remove()
1352 struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent); in pm860x_codec_probe()
1357 pm860x = devm_kzalloc(&pdev->dev, sizeof(struct pm860x_priv), in pm860x_codec_probe()
1360 return -ENOMEM; in pm860x_codec_probe()
1362 pm860x->chip = chip; in pm860x_codec_probe()
1363 pm860x->i2c = (chip->id == CHIP_PM8607) ? chip->client in pm860x_codec_probe()
1364 : chip->companion; in pm860x_codec_probe()
1365 pm860x->regmap = (chip->id == CHIP_PM8607) ? chip->regmap in pm860x_codec_probe()
1366 : chip->regmap_companion; in pm860x_codec_probe()
1372 dev_err(&pdev->dev, "Failed to get IRQ resources\n"); in pm860x_codec_probe()
1373 return -EINVAL; in pm860x_codec_probe()
1375 pm860x->irq[i] = res->start + chip->irq_base; in pm860x_codec_probe()
1376 strscpy(pm860x->name[i], res->name, MAX_NAME_LEN); in pm860x_codec_probe()
1379 ret = devm_snd_soc_register_component(&pdev->dev, in pm860x_codec_probe()
1383 dev_err(&pdev->dev, "Failed to register component\n"); in pm860x_codec_probe()
1384 return -EINVAL; in pm860x_codec_probe()
1391 .name = "88pm860x-codec",
1401 MODULE_ALIAS("platform:88pm860x-codec");