Skip to contentSkip to conversation

ASoC: rt5645: add fallback case for jack detection support

PATCH In review Pierre-Louis Bossart 2 participants 2 messages Jan 11, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ASoC: rt5645: add fallback case for jack detection support

Commit 78f5605c0329 ("ASoC: rt5645: cleanup DMI matching code") did a lot of useful cleanups. This patch adds a default case to enable jack detection if there is no pdata, device property or quirk.

The chosen jd-mode3 is the most common and should limit the addition of new DMI-based quirks. Existing DMI quirks which only set this mode are left as is and not removed.

---
v2: no functional change, only rewrite of the commit message for clarity

 sound/soc/codecs/rt5645.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
sound/soc/codecs/rt5645.c +14 -1
index 789346cb30b9..8f140c8b93ac 100644
@@ -3739,6 +3739,17 @@ static const struct dmi_system_id dmi_platform_data[] = {
 	{ }
 };
 
+static bool rt5645_check_dp(struct device *dev)
+{
+	if (device_property_present(dev, "realtek,in2-differential") ||
+	    device_property_present(dev, "realtek,dmic1-data-pin") ||
+	    device_property_present(dev, "realtek,dmic2-data-pin") ||
+	    device_property_present(dev, "realtek,jd-mode"))
+		return true;
+
+	return false;
+}
+
 static int rt5645_parse_dt(struct rt5645_priv *rt5645, struct device *dev)
 {
 	rt5645->pdata.in2_diff = device_property_read_bool(dev,
@@ -3779,8 +3790,10 @@ static int rt5645_i2c_probe(struct i2c_client *i2c,
 
 	if (pdata)
 		rt5645->pdata = *pdata;
-	else
+	else if (rt5645_check_dp(&i2c->dev))
 		rt5645_parse_dt(rt5645, &i2c->dev);
+	else
+		rt5645->pdata = jd_mode3_platform_data;
 
 	if (quirk != -1) {
 		rt5645->pdata.in2_diff = QUIRK_IN2_DIFF(quirk);
Signature · 1 line
2.14.1
Reviewed-by on v2 1/1
#1 lore raw

Hi,

Quoted 11 lines · Pierre-Louis Bossart

Commit 78f5605c0329 ("ASoC: rt5645: cleanup DMI matching code") did a lot of useful cleanups. This patch adds a default case to enable jack detection if there is no pdata, device property or quirk.

The chosen jd-mode3 is the most common and should limit the addition of new DMI-based quirks. Existing DMI quirks which only set this mode are left as is and not removed.

Looks good to me:

Regards,

Hans

Quoted 41 lines

---
v2: no functional change, only rewrite of the commit message for clarity

  sound/soc/codecs/rt5645.c | 15 ++++++++++++++-
  1 file changed, 14 insertions(+), 1 deletion(-)
sound/soc/codecs/rt5645.c +14 -1
index 789346cb30b9..8f140c8b93ac 100644
@@ -3739,6 +3739,17 @@ static const struct dmi_system_id dmi_platform_data[] = {
  	{ }
  };
 
+static bool rt5645_check_dp(struct device *dev)
+{
+	if (device_property_present(dev, "realtek,in2-differential") ||
+	    device_property_present(dev, "realtek,dmic1-data-pin") ||
+	    device_property_present(dev, "realtek,dmic2-data-pin") ||
+	    device_property_present(dev, "realtek,jd-mode"))
+		return true;
+
+	return false;
+}
+
  static int rt5645_parse_dt(struct rt5645_priv *rt5645, struct device *dev)
  {
  	rt5645->pdata.in2_diff = device_property_read_bool(dev,
@@ -3779,8 +3790,10 @@ static int rt5645_i2c_probe(struct i2c_client *i2c,
 
  	if (pdata)
  		rt5645->pdata = *pdata;
-	else
+	else if (rt5645_check_dp(&i2c->dev))
  		rt5645_parse_dt(rt5645, &i2c->dev);
+	else
+		rt5645->pdata = jd_mode3_platform_data;
 
  	if (quirk != -1) {
  		rt5645->pdata.in2_diff = QUIRK_IN2_DIFF(quirk);