mirror of
https://github.com/torvalds/linux.git
synced 2024-11-21 19:41:42 +00:00
ASoC: da7219: Add Jack insertion detection polarity
Add support of selecting insertion detection polarity - Default polarity (Low) - Inverted polarity (High) Correct the keywords of parsing `dlg,jack-det-rate` bases on the new DT binding. Signed-off-by: David Rau <David.Rau.opensource@dm.renesas.com> Link: https://lore.kernel.org/r/20230523161821.4260-4-David.Rau.opensource@dm.renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
c28dc3bdfc
commit
dc0ff0fa3a
@ -44,6 +44,11 @@ enum da7219_aad_jack_ins_deb {
|
|||||||
DA7219_AAD_JACK_INS_DEB_1S,
|
DA7219_AAD_JACK_INS_DEB_1S,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum da7219_aad_jack_ins_det_pty {
|
||||||
|
DA7219_AAD_JACK_INS_DET_PTY_LOW = 0,
|
||||||
|
DA7219_AAD_JACK_INS_DET_PTY_HIGH,
|
||||||
|
};
|
||||||
|
|
||||||
enum da7219_aad_jack_det_rate {
|
enum da7219_aad_jack_det_rate {
|
||||||
DA7219_AAD_JACK_DET_RATE_32_64MS = 0,
|
DA7219_AAD_JACK_DET_RATE_32_64MS = 0,
|
||||||
DA7219_AAD_JACK_DET_RATE_64_128MS,
|
DA7219_AAD_JACK_DET_RATE_64_128MS,
|
||||||
@ -80,6 +85,7 @@ struct da7219_aad_pdata {
|
|||||||
enum da7219_aad_btn_cfg btn_cfg;
|
enum da7219_aad_btn_cfg btn_cfg;
|
||||||
enum da7219_aad_mic_det_thr mic_det_thr;
|
enum da7219_aad_mic_det_thr mic_det_thr;
|
||||||
enum da7219_aad_jack_ins_deb jack_ins_deb;
|
enum da7219_aad_jack_ins_deb jack_ins_deb;
|
||||||
|
enum da7219_aad_jack_ins_det_pty jack_ins_det_pty;
|
||||||
enum da7219_aad_jack_det_rate jack_det_rate;
|
enum da7219_aad_jack_det_rate jack_det_rate;
|
||||||
enum da7219_aad_jack_rem_deb jack_rem_deb;
|
enum da7219_aad_jack_rem_deb jack_rem_deb;
|
||||||
|
|
||||||
|
@ -571,16 +571,29 @@ static enum da7219_aad_jack_ins_deb
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static enum da7219_aad_jack_ins_det_pty
|
||||||
|
da7219_aad_fw_jack_ins_det_pty(struct device *dev, const char *str)
|
||||||
|
{
|
||||||
|
if (!strcmp(str, "low")) {
|
||||||
|
return DA7219_AAD_JACK_INS_DET_PTY_LOW;
|
||||||
|
} else if (!strcmp(str, "high")) {
|
||||||
|
return DA7219_AAD_JACK_INS_DET_PTY_HIGH;
|
||||||
|
} else {
|
||||||
|
dev_warn(dev, "Invalid jack insertion detection polarity");
|
||||||
|
return DA7219_AAD_JACK_INS_DET_PTY_LOW;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static enum da7219_aad_jack_det_rate
|
static enum da7219_aad_jack_det_rate
|
||||||
da7219_aad_fw_jack_det_rate(struct device *dev, const char *str)
|
da7219_aad_fw_jack_det_rate(struct device *dev, const char *str)
|
||||||
{
|
{
|
||||||
if (!strcmp(str, "32ms_64ms")) {
|
if (!strcmp(str, "32_64")) {
|
||||||
return DA7219_AAD_JACK_DET_RATE_32_64MS;
|
return DA7219_AAD_JACK_DET_RATE_32_64MS;
|
||||||
} else if (!strcmp(str, "64ms_128ms")) {
|
} else if (!strcmp(str, "64_128")) {
|
||||||
return DA7219_AAD_JACK_DET_RATE_64_128MS;
|
return DA7219_AAD_JACK_DET_RATE_64_128MS;
|
||||||
} else if (!strcmp(str, "128ms_256ms")) {
|
} else if (!strcmp(str, "128_256")) {
|
||||||
return DA7219_AAD_JACK_DET_RATE_128_256MS;
|
return DA7219_AAD_JACK_DET_RATE_128_256MS;
|
||||||
} else if (!strcmp(str, "256ms_512ms")) {
|
} else if (!strcmp(str, "256_512")) {
|
||||||
return DA7219_AAD_JACK_DET_RATE_256_512MS;
|
return DA7219_AAD_JACK_DET_RATE_256_512MS;
|
||||||
} else {
|
} else {
|
||||||
dev_warn(dev, "Invalid jack detect rate");
|
dev_warn(dev, "Invalid jack detect rate");
|
||||||
@ -688,6 +701,12 @@ static struct da7219_aad_pdata *da7219_aad_fw_to_pdata(struct device *dev)
|
|||||||
else
|
else
|
||||||
aad_pdata->jack_ins_deb = DA7219_AAD_JACK_INS_DEB_20MS;
|
aad_pdata->jack_ins_deb = DA7219_AAD_JACK_INS_DEB_20MS;
|
||||||
|
|
||||||
|
if (!fwnode_property_read_string(aad_np, "dlg,jack-ins-det-pty", &fw_str))
|
||||||
|
aad_pdata->jack_ins_det_pty =
|
||||||
|
da7219_aad_fw_jack_ins_det_pty(dev, fw_str);
|
||||||
|
else
|
||||||
|
aad_pdata->jack_ins_det_pty = DA7219_AAD_JACK_INS_DET_PTY_LOW;
|
||||||
|
|
||||||
if (!fwnode_property_read_string(aad_np, "dlg,jack-det-rate", &fw_str))
|
if (!fwnode_property_read_string(aad_np, "dlg,jack-det-rate", &fw_str))
|
||||||
aad_pdata->jack_det_rate =
|
aad_pdata->jack_det_rate =
|
||||||
da7219_aad_fw_jack_det_rate(dev, fw_str);
|
da7219_aad_fw_jack_det_rate(dev, fw_str);
|
||||||
@ -849,6 +868,21 @@ static void da7219_aad_handle_pdata(struct snd_soc_component *component)
|
|||||||
mask |= DA7219_ADC_1_BIT_REPEAT_MASK;
|
mask |= DA7219_ADC_1_BIT_REPEAT_MASK;
|
||||||
}
|
}
|
||||||
snd_soc_component_update_bits(component, DA7219_ACCDET_CONFIG_7, mask, cfg);
|
snd_soc_component_update_bits(component, DA7219_ACCDET_CONFIG_7, mask, cfg);
|
||||||
|
|
||||||
|
switch (aad_pdata->jack_ins_det_pty) {
|
||||||
|
case DA7219_AAD_JACK_INS_DET_PTY_LOW:
|
||||||
|
snd_soc_component_write(component, 0xF0, 0x8B);
|
||||||
|
snd_soc_component_write(component, 0x75, 0x80);
|
||||||
|
snd_soc_component_write(component, 0xF0, 0x00);
|
||||||
|
break;
|
||||||
|
case DA7219_AAD_JACK_INS_DET_PTY_HIGH:
|
||||||
|
snd_soc_component_write(component, 0xF0, 0x8B);
|
||||||
|
snd_soc_component_write(component, 0x75, 0x00);
|
||||||
|
snd_soc_component_write(component, 0xF0, 0x00);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user