From 37c9c3d8d746c4e2d5d52548789f3759752fce43 Mon Sep 17 00:00:00 2001 From: liaohj Date: Wed, 15 Aug 2018 10:58:26 +0800 Subject: [PATCH] DLKM:audio:tfa987x:modify send_calib_values as mono mode. - sync vendor code. modify send_calib_values as mono mode. Change-Id: Idd94f77967ea4a94a569a6332ffc45242b36b625 Signed-off-by: liaohj Reviewed-on: https://gerrit.mot.com/1226988 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Wanlong Zhou Reviewed-by: Huosheng Liao Submit-Approved: Jira Key --- sound/soc/codecs/tfa98xx.c | 35 ++++++++++------------------------- 1 file changed, 10 insertions(+), 25 deletions(-) diff --git a/sound/soc/codecs/tfa98xx.c b/sound/soc/codecs/tfa98xx.c index 25de92772a50..23b6a7a16bef 100644 --- a/sound/soc/codecs/tfa98xx.c +++ b/sound/soc/codecs/tfa98xx.c @@ -2760,10 +2760,11 @@ static int tfa98xx_hw_params(struct snd_pcm_substream *substream, return 0; } -extern int send_tfa_cal_in_band(void *buf, int cmd_size); - #ifdef TFA9874_NONDSP_STEREO +extern int send_tfa_cal_in_band(void *buf, int cmd_size); static uint8_t bytes[3*3+1] = {0}; +#define MONO_I2C_ADDR (0x34) +#define IMPEDANCE_VALUE (4000) /*or 20000*/ enum Tfa98xx_Error tfa98xx_adsp_send_calib_values(struct tfa98xx *tfa98xx) { @@ -2771,8 +2772,7 @@ enum Tfa98xx_Error tfa98xx_adsp_send_calib_values(struct tfa98xx *tfa98xx) struct tfa_device *tfa = tfa98xx->tfa; int value = 0, nr, dsp_cal_value = 0; - /* If calibration is set to once we load from MTP, else send zero's */ - if (TFA_GET_BF(tfa, MTPEX) == 1 && tfa98xx->i2c->addr == 0x34) + if (TFA_GET_BF(tfa, MTPEX) == 1 && tfa98xx->i2c->addr == MONO_I2C_ADDR) { value = tfa_dev_mtp_get(tfa, TFA_MTP_RE25); dsp_cal_value = (value * 65536) / 1000; @@ -2785,27 +2785,12 @@ enum Tfa98xx_Error tfa98xx_adsp_send_calib_values(struct tfa98xx *tfa98xx) dev_err(&tfa98xx->i2c->dev, "%s: cal value 0x%x\n", __func__, dsp_cal_value); - /* Receiver RDC */ - if (value > 20000) - bytes[0] |= 0x01; - } - - if (TFA_GET_BF(tfa, MTPEX) == 1 && tfa98xx->i2c->addr == 0x35) - { - value = tfa_dev_mtp_get(tfa, TFA_MTP_RE25); - dsp_cal_value = (value * 65536) / 1000; - - nr = 7; - /* We have to copy it for both channels. Even when mono! */ - bytes[nr++] = (uint8_t)((dsp_cal_value >> 16) & 0xff); - bytes[nr++] = (uint8_t)((dsp_cal_value >> 8) & 0xff); - bytes[nr++] = (uint8_t)(dsp_cal_value & 0xff); - - dev_err(&tfa98xx->i2c->dev, "%s: cal value 0x%x\n", __func__, dsp_cal_value); - - /* Speaker RDC */ - if (value > 4000) - bytes[0] |= 0x10; + bytes[nr++] = bytes[4]; + bytes[nr++] = bytes[5]; + bytes[nr++] = bytes[6]; + /* RDC */ + if (value > IMPEDANCE_VALUE) + bytes[0] |= 0x11; } if (bytes[0] == 0x11)