Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: da7219: Fix pole orientation detection on OMTP headsets when playing music

The OMTP pin define headsets can be mis-detected as line out
instead of OMTP, causing obvious issues with audio quality.
This patch is to put increased resistances within
the device at a suitable point.

To solve this issue better, the new mechanism setup
ground switches with conditional delay control
and these allow for more stabile detection process
to operate as intended. This conditional delay control
will not impact the hardware process
but use extra system resource.

This commit improves control of ground switches in the AAD logic.

Signed-off-by: David Rau <david.rau.zg@renesas.com>
Link: https://lore.kernel.org/r/20221121050744.2278-1-david.rau.zg@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

David Rau and committed by
Mark Brown
969357ec c1dd6bf6

+37 -6
+36 -6
sound/soc/codecs/da7219-aad.c
··· 351 351 struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); 352 352 struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); 353 353 u8 events[DA7219_AAD_IRQ_REG_MAX]; 354 - u8 statusa; 354 + u8 statusa, srm_st; 355 355 int i, report = 0, mask = 0; 356 + 357 + srm_st = snd_soc_component_read(component, DA7219_PLL_SRM_STS) & DA7219_PLL_SRM_STS_MCLK; 358 + msleep(da7219_aad->gnd_switch_delay * ((srm_st == 0x0) ? 2 : 1) - 4); 359 + /* Enable ground switch */ 360 + snd_soc_component_update_bits(component, 0xFB, 0x01, 0x01); 356 361 357 362 /* Read current IRQ events */ 358 363 regmap_bulk_read(da7219->regmap, DA7219_ACCDET_IRQ_EVENT_A, ··· 458 453 snd_soc_dapm_disable_pin(dapm, "Mic Bias"); 459 454 snd_soc_dapm_sync(dapm); 460 455 461 - /* Enable ground switch */ 462 - snd_soc_component_update_bits(component, 0xFB, 0x01, 0x01); 456 + /* Disable ground switch */ 457 + snd_soc_component_update_bits(component, 0xFB, 0x01, 0x00); 463 458 } 464 459 } 465 460 ··· 835 830 } 836 831 } 837 832 833 + static void da7219_aad_handle_gnd_switch_time(struct snd_soc_component *component) 834 + { 835 + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); 836 + struct da7219_aad_priv *da7219_aad = da7219->aad; 837 + u8 jack_det; 838 + 839 + jack_det = snd_soc_component_read(component, DA7219_ACCDET_CONFIG_2) 840 + & DA7219_JACK_DETECT_RATE_MASK; 841 + switch (jack_det) { 842 + case 0x00: 843 + da7219_aad->gnd_switch_delay = 32; 844 + break; 845 + case 0x10: 846 + da7219_aad->gnd_switch_delay = 64; 847 + break; 848 + case 0x20: 849 + da7219_aad->gnd_switch_delay = 128; 850 + break; 851 + case 0x30: 852 + da7219_aad->gnd_switch_delay = 256; 853 + break; 854 + default: 855 + da7219_aad->gnd_switch_delay = 32; 856 + break; 857 + } 858 + } 838 859 839 860 /* 840 861 * Suspend/Resume ··· 938 907 snd_soc_component_update_bits(component, DA7219_ACCDET_CONFIG_1, 939 908 DA7219_BUTTON_CONFIG_MASK, 0); 940 909 941 - /* Enable ground switch */ 942 - snd_soc_component_update_bits(component, 0xFB, 0x01, 0x01); 943 - 944 910 INIT_WORK(&da7219_aad->btn_det_work, da7219_aad_btn_det_work); 945 911 INIT_WORK(&da7219_aad->hptest_work, da7219_aad_hptest_work); 946 912 ··· 954 926 memset(mask, 0, DA7219_AAD_IRQ_REG_MAX); 955 927 regmap_bulk_write(da7219->regmap, DA7219_ACCDET_IRQ_MASK_A, 956 928 &mask, DA7219_AAD_IRQ_REG_MAX); 929 + 930 + da7219_aad_handle_gnd_switch_time(component); 957 931 958 932 return 0; 959 933 }
+1
sound/soc/codecs/da7219-aad.h
··· 187 187 struct da7219_aad_priv { 188 188 struct snd_soc_component *component; 189 189 int irq; 190 + int gnd_switch_delay; 190 191 191 192 u8 micbias_pulse_lvl; 192 193 u32 micbias_pulse_time;