ASoC: rt711-sdca: check pin sense when system resumes
Subsystems (3)
PATCH 2/2 ASoC: rt711-sdca: check pin sense when system resumes
From: Shuming Fan <[email protected]>
If the jack is unplugged when the system was suspended,
the system will believe the jack exists for a while after the system resumes.
The codec needs some time, then alerts the host to detect whether the jack exists or not. This patch wants to use the pin sense to detect whether the jack exists or not when the system resumes. It could report the status immediately if the jack was unplugged.
It will improve the user experience.
Signed-off-by Shuming Fan <[email protected]>
--- sound/soc/codecs/rt711-sdca-sdw.c | 18 ++++++++++++++++++ sound/soc/codecs/rt711-sdca.c | 2 +- sound/soc/codecs/rt711-sdca.h | 2 ++ 3 files changed, 21 insertions(+), 1 deletion(-)
sound/soc/codecs/rt711-sdca-sdw.c +18 -0
@@ -12,6 +12,7 @@#include <linux/soundwire/sdw_registers.h> #include <linux/module.h> #include <linux/pm_runtime.h> +#include <sound/jack.h> #include "rt711-sdca.h" #include "rt711-sdca-sdw.h"
@@ -435,6 +436,8 @@ static int __maybe_unused rt711_sdca_dev_resume(struct device *dev)struct sdw_slave *slave =dev_to_sdw_dev (dev);struct rt711_sdca_priv *rt711 =dev_get_drvdata (dev);unsigned long time; +unsigned int pin_sense; +int ret;if (!rt711->first_hw_init)return 0 ;
@@ -457,6 +460,21 @@ static int __maybe_unused rt711_sdca_dev_resume(struct device *dev)regcache_sync (rt711->regmap);regcache_cache_only (rt711->mbq_regmap, false);regcache_sync (rt711->mbq_regmap); + +/* +* detect whether jack exists or not +* if the jack is unplugged, we will report it immediately +* if the jack exists, it will take some time to detect, then alert the host +*/ + ret =rt711_sdca_index_read (rt711,RT711_VENDOR_REG ,RT711_IRQ_FLAG_TABLE2 , &pin_sense); + pin_sense = ((pin_sense &0x100 ) >>8 ); +if (ret <0 ) { +dev_err (&slave->dev,"Pin Sense read failed:%d\n" , ret); +return ret; + } +if (rt711->hs_jack && !pin_sense) +snd_soc_jack_report (rt711->hs_jack,0 ,SND_JACK_HEADSET ); +return 0 ; }
sound/soc/codecs/rt711-sdca.c +1 -1
@@ -42,7 +42,7 @@ static int rt711_sdca_index_write(struct rt711_sdca_priv *rt711,return ret; } -static int rt711_sdca_index_read (struct rt711_sdca_priv *rt711, +int rt711_sdca_index_read (struct rt711_sdca_priv *rt711,unsigned int nid,unsigned int reg,unsigned int *value) {int ret;
sound/soc/codecs/rt711-sdca.h +2 -0
@@ -240,4 +240,6 @@ int rt711_sdca_init(struct device *dev, struct regmap *regmap, struct regmap *mbq_regmap, struct sdw_slave *slave);int rt711_sdca_jack_detect (struct rt711_sdca_priv *rt711,bool *hp,bool *mic); +int rt711_sdca_index_read (struct rt711_sdca_priv *rt711, +unsigned int nid,unsigned int reg,unsigned int *value);#endif /* __RT711_SDCA_H__ */
Signature · 1 line
2.34.1