diff mbox series

[v1,2/5] ASoC: codecs: ES8326: Change Hp_detect and volatile reg function

Message ID 20230714032453.3334-2-zhuning0077@gmail.com (mailing list archive)
State New, archived
Headers show
Series [v1,1/5] ASoC: codecs: ES8326: Add es8326_mute function | expand

Commit Message

Zhu Ning July 14, 2023, 3:24 a.m. UTC
The old register naming method is confusing. The reg 0x57 decides
the default headset hardware connection type, and the reg 0xfb is
the headset detection status register, which changes during headset
insertion. Change the name to ES8326_HPDET_TYPE and ES8326_HPDET_STA.

Signed-off-by: Zhu Ning <zhuning0077@gmail.com>
---
 sound/soc/codecs/es8326.c | 29 +++++++++++++++++------------
 sound/soc/codecs/es8326.h | 12 ++++++++----
 2 files changed, 25 insertions(+), 16 deletions(-)

Comments

Mark Brown July 14, 2023, 1:19 p.m. UTC | #1
On Fri, Jul 14, 2023 at 11:24:50AM +0800, Zhu Ning wrote:

> -static const struct regmap_range es8326_volatile_ranges[] = {
> -	regmap_reg_range(ES8326_HP_DETECT, ES8326_HP_DETECT),
> -};
> -
> -static const struct regmap_access_table es8326_volatile_table = {
> -	.yes_ranges = es8326_volatile_ranges,
> -	.n_yes_ranges = ARRAY_SIZE(es8326_volatile_ranges),
> -};
> +static bool es8326_volatile_register(struct device *dev, unsigned int reg)
> +{
> +	switch (reg) {
> +	case ES8326_HPL_OFFSET_INI:
> +	case ES8326_HPR_OFFSET_INI:
> +	case ES8326_HPDET_STA:
> +	case ES8326_CTIA_OMTP_STA:
> +	case ES8326_CSM_MUTE_STA:
> +		return true;

That's clearly not just a name chnage, it's extending the set of
volatile registers which should really be a separate patch - if you need
to resend for some other reason please split it out, but if there's no
other issues in the series don't worry here and just consider it next
time.
Mark Brown July 14, 2023, 4:06 p.m. UTC | #2
On Fri, Jul 14, 2023 at 11:24:50AM +0800, Zhu Ning wrote:
> The old register naming method is confusing. The reg 0x57 decides
> the default headset hardware connection type, and the reg 0xfb is
> the headset detection status register, which changes during headset
> insertion. Change the name to ES8326_HPDET_TYPE and ES8326_HPDET_STA.

This breaks an x86 allmodconfig build:

/build/stage/linux/sound/soc/codecs/es8326.c: In function ‘es8326_resume’:
/build/stage/linux/sound/soc/codecs/es8326.c:659:38: error: ‘ES8326_HP_DET’ undeclared (first use in this function); did you mean ‘ES8326_HP_OFF’?
  659 |         regmap_write(es8326->regmap, ES8326_HP_DET,
      |                                      ^~~~~~~~~~~~~
      |                                      ES8326_HP_OFF
diff mbox series

Patch

diff --git a/sound/soc/codecs/es8326.c b/sound/soc/codecs/es8326.c
index 191579d9552c..8c78f0bf514b 100644
--- a/sound/soc/codecs/es8326.c
+++ b/sound/soc/codecs/es8326.c
@@ -158,20 +158,25 @@  static const struct snd_soc_dapm_route es8326_dapm_routes[] = {
 	{"HPOR", NULL, "RHPMIX"},
 };
 
-static const struct regmap_range es8326_volatile_ranges[] = {
-	regmap_reg_range(ES8326_HP_DETECT, ES8326_HP_DETECT),
-};
-
-static const struct regmap_access_table es8326_volatile_table = {
-	.yes_ranges = es8326_volatile_ranges,
-	.n_yes_ranges = ARRAY_SIZE(es8326_volatile_ranges),
-};
+static bool es8326_volatile_register(struct device *dev, unsigned int reg)
+{
+	switch (reg) {
+	case ES8326_HPL_OFFSET_INI:
+	case ES8326_HPR_OFFSET_INI:
+	case ES8326_HPDET_STA:
+	case ES8326_CTIA_OMTP_STA:
+	case ES8326_CSM_MUTE_STA:
+		return true;
+	default:
+		return false;
+	}
+}
 
 static const struct regmap_config es8326_regmap_config = {
 	.reg_bits = 8,
 	.val_bits = 8,
 	.max_register = 0xff,
-	.volatile_table = &es8326_volatile_table,
+	.volatile_reg = es8326_volatile_register,
 	.cache_type = REGCACHE_RBTREE,
 };
 
@@ -519,7 +524,7 @@  static void es8326_jack_button_handler(struct work_struct *work)
 		return;
 
 	mutex_lock(&es8326->lock);
-	iface = snd_soc_component_read(comp, ES8326_HP_DETECT);
+	iface = snd_soc_component_read(comp, ES8326_HPDET_STA);
 	switch (iface) {
 	case 0x93:
 		/* pause button detected */
@@ -578,7 +583,7 @@  static void es8326_jack_detect_handler(struct work_struct *work)
 	unsigned int iface;
 
 	mutex_lock(&es8326->lock);
-	iface = snd_soc_component_read(comp, ES8326_HP_DETECT);
+	iface = snd_soc_component_read(comp, ES8326_HPDET_STA);
 	dev_dbg(comp->dev, "gpio flag %#04x", iface);
 	if ((iface & ES8326_HPINSERT_FLAG) == 0) {
 		/* Jack unplugged or spurious IRQ */
@@ -743,7 +748,7 @@  static void es8326_enable_jack_detect(struct snd_soc_component *component,
 
 	mutex_lock(&es8326->lock);
 	if (es8326->jd_inverted)
-		snd_soc_component_update_bits(component, ES8326_HP_DET,
+		snd_soc_component_update_bits(component, ES8326_HPDET_TYPE,
 					      ES8326_HP_DET_JACK_POL, ~es8326->jack_pol);
 	es8326->jack = jack;
 
diff --git a/sound/soc/codecs/es8326.h b/sound/soc/codecs/es8326.h
index 3f8f7da58062..6cb8e3ed76e3 100644
--- a/sound/soc/codecs/es8326.h
+++ b/sound/soc/codecs/es8326.h
@@ -73,15 +73,19 @@ 
 #define ES8326_DRC_RECOVERY	0x53
 #define ES8326_DRC_WINSIZE	0x54
 #define ES8326_HPJACK_TIMER	0x56
-#define ES8326_HP_DET		0x57
+#define ES8326_HPDET_TYPE	0x57
 #define ES8326_INT_SOURCE	0x58
 #define ES8326_INTOUT_IO	0x59
 #define ES8326_SDINOUT1_IO	0x5A
 #define ES8326_SDINOUT23_IO	0x5B
 #define ES8326_JACK_PULSE	0x5C
 
+#define ES8326_HP_MISC		0xF7
+#define ES8326_CTIA_OMTP_STA	0xF8
 #define ES8326_PULLUP_CTL	0xF9
-#define ES8326_HP_DETECT	0xFB
+#define ES8326_CSM_I2C_STA	0xFA
+#define ES8326_HPDET_STA	0xFB
+#define ES8326_CSM_MUTE_STA	0xFC
 #define ES8326_CHIP_ID1		0xFD
 #define ES8326_CHIP_ID2		0xFE
 #define ES8326_CHIP_VERSION	0xFF
@@ -146,7 +150,7 @@ 
 #define ES8326_ADC3_SHIFT 0
 #define ES8326_ADC4_SHIFT 3
 
-/* ES8326_HP_DET */
+/* ES8326_HPDET_TYPE */
 #define ES8326_HP_DET_SRC_PIN27 (1 << 5)
 #define ES8326_HP_DET_SRC_PIN9 (1 << 4)
 #define ES8326_HP_DET_JACK_POL (1 << 3)
@@ -174,7 +178,7 @@ 
 #define ES8326_SDINOUT2_SHIFT 4
 #define ES8326_SDINOUT3_SHIFT 0
 
-/* ES8326_HP_DETECT */
+/* ES8326_HPDET_STA */
 #define ES8326_HPINSERT_FLAG (1 << 1)
 #define ES8326_HPBUTTON_FLAG (1 << 0)