]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - tas2557sw-android/tas2557-stereo-driver.git/commitdiff
update for low_temp gain set and channel swap for PG2.1
authorPeter Li <peter-li@ti.com>
Thu, 2 Mar 2017 18:20:25 +0000 (02:20 +0800)
committerPeter Li <peter-li@ti.com>
Thu, 2 Mar 2017 18:20:25 +0000 (02:20 +0800)
tas2557-core.c
tas2557-regmap.c
tas2557.h

index 10e06b148b38e08c8ab8dbf1571df3e36431cfcf..7e2cce7ef2ed9929dc29c5417533d820157c75c4 100755 (executable)
@@ -233,11 +233,9 @@ int tas2557_configIRQ(struct tas2557_priv *pTAS2557)
 
 int tas2557_SA_SwapChannel(struct tas2557_priv *pTAS2557, bool swap)
 {
-       int ret = 0;
+       int nResult = 0;
        struct TProgram *pProgram;
-       unsigned char buf_a[8], buf_b[8];
-       unsigned char push[4] = {0, 0, 0, 1};
-       int nReg;
+       unsigned char buf_a[16], buf_b[16];
 
        if ((pTAS2557->mpFirmware->mnPrograms == 0)
                || (pTAS2557->mpFirmware->mnConfigurations == 0)) {
@@ -251,39 +249,49 @@ int tas2557_SA_SwapChannel(struct tas2557_priv *pTAS2557, bool swap)
                goto end;
        }
 
-       if (pTAS2557->mnLPGID == TAS2557_PG_VERSION_2P1)
-               nReg = TAS2557_SA_PG2P1_CHL_CTRL_REG;
-       else
-               nReg = TAS2557_SA_PG1P0_CHL_CTRL_REG;
+/*
+* for PG2.1
+* for left channel, data[16] =
+* {0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+*  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+*
+* for right channel, data[16] =
+* {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+*  0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+*
+* for (left+right)/2 , data[16] =
+* {0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+*  0x20, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00};
+*/
+
+       if (pTAS2557->mnLPGID != TAS2557_PG_VERSION_2P1) {
+               dev_err(pTAS2557->dev, "%s, currently we only support PG2.1\n", __func__);
+               goto end;
+       }
 
-       /* for left channel, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 */
-       /* for right channel, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00 */
-       /* for (left+right)/2 , 0x20, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00 */
        if (swap != pTAS2557->mnChannelSwap) {
                /* get current configuration */
-               ret = pTAS2557->bulk_read(pTAS2557, channel_left, nReg, buf_a, 8);
-               if (ret < 0) {
+               nResult = pTAS2557->bulk_read(pTAS2557, channel_left, TAS2557_SA_PG2P1_CHL_CTRL_REG, buf_a, 16);
+               if (nResult < 0) {
                        dev_err(pTAS2557->dev, "%s, left I2C error\n", __func__);
                        goto end;
                }
 
-               pTAS2557->bulk_read(pTAS2557, channel_right, nReg, buf_b, 8);
-               if (ret < 0) {
+               nResult = pTAS2557->bulk_read(pTAS2557, channel_right, TAS2557_SA_PG2P1_CHL_CTRL_REG, buf_b, 16);
+               if (nResult < 0) {
                        dev_err(pTAS2557->dev, "%s, right I2C error\n", __func__);
                        goto end;
                }
 
                /* do channel swap */
-               pTAS2557->bulk_write(pTAS2557, channel_left, nReg, buf_b, 8);
-               pTAS2557->bulk_write(pTAS2557, channel_right, nReg, buf_a, 8);
-               /* push to DSP */
-               pTAS2557->bulk_write(pTAS2557, channel_both, TAS2557_SA_COEFF_SWAP_REG, push, 4);
+               pTAS2557->bulk_write(pTAS2557, channel_left, TAS2557_SA_PG2P1_CHL_CTRL_REG, buf_b, 16);
+               pTAS2557->bulk_write(pTAS2557, channel_right, TAS2557_SA_PG2P1_CHL_CTRL_REG, buf_a, 16);
                pTAS2557->mnChannelSwap = swap;
        }
 
 end:
 
-       return ret;
+       return nResult;
 }
 
 int tas2557_SA_ctl_echoRef(struct tas2557_priv *pTAS2557)
@@ -471,6 +479,7 @@ int tas2557_get_die_temperature(struct tas2557_priv *pTAS2557, int *pTemperature
 int tas2557_load_platdata(struct tas2557_priv *pTAS2557)
 {
        int nResult = 0;
+       unsigned char nGain;
 
        if (gpio_is_valid(pTAS2557->mnLeftChlGpioINT)
                || gpio_is_valid(pTAS2557->mnRightChlGpioINT)) {
@@ -485,6 +494,12 @@ int tas2557_load_platdata(struct tas2557_priv *pTAS2557)
                goto end;
 
        nResult = tas2557_SA_ctl_echoRef(pTAS2557);
+       if (nResult < 0)
+               goto end;
+
+       nResult = tas2557_get_DAC_gain(pTAS2557, channel_left, &nGain);
+       if (nResult >= 0)
+               pTAS2557->mnDevGain = nGain;
 
 end:
 
index bf0b257cd7e93704d11ce585c2c7e8da72478f8d..840f9d120bf7fff8c8bebdb3cafe690c5dbded90 100755 (executable)
@@ -54,6 +54,7 @@
 #include "tiload.h"
 #endif
 
+#define LOW_TEMPERATURE_GAIN 6
 /*
 * tas2557_i2c_write_device : write single byte to device
 * platform dependent, need platform specific support
@@ -686,6 +687,22 @@ static void timer_work_routine(struct work_struct *work)
        if (nResult >= 0) {
                dev_dbg(pTAS2557->dev, "Die=0x%x\n", nTemp);
 
+               if ((nTemp & 0x80000000) != 0) {
+                       /* if Die temperature is below ZERO */
+                       if (pTAS2557->mnDevCurrentGain != LOW_TEMPERATURE_GAIN) {
+                               tas2557_set_DAC_gain(pTAS2557, channel_both, LOW_TEMPERATURE_GAIN);
+                               pTAS2557->mnDevCurrentGain = LOW_TEMPERATURE_GAIN;
+                               dev_info(pTAS2557->dev, "LOW Temp: set gain to %d\n", LOW_TEMPERATURE_GAIN);
+                       }
+               } else {
+                       /* if Die temperature is above ZERO */
+                       if (pTAS2557->mnDevCurrentGain != pTAS2557->mnDevGain) {
+                               tas2557_set_DAC_gain(pTAS2557, channel_both, pTAS2557->mnDevGain);
+                               pTAS2557->mnDevCurrentGain = pTAS2557->mnDevGain;
+                               dev_info(pTAS2557->dev, "LOW Temp: set gain to original\n");
+                       }
+               }
+
                if (pTAS2557->mbPowerUp)
                        hrtimer_start(&pTAS2557->mtimer,
                                ns_to_ktime((u64)LOW_TEMPERATURE_CHECK_PERIOD * NSEC_PER_MSEC), HRTIMER_MODE_REL);
index c856d9fa97e45704b163186989948c4c5860464d..2d60fb752f365400ae26e9aa652275f15c4adc49 100755 (executable)
--- a/tas2557.h
+++ b/tas2557.h
@@ -460,6 +460,8 @@ struct tas2557_priv {
        unsigned int mnROMChlCtrl;
 
        /* for low temperature check */
+       unsigned int mnDevGain;
+       unsigned int mnDevCurrentGain;
        struct hrtimer mtimer;
        struct work_struct mtimerwork;
 #ifdef CONFIG_TAS2557_MISC_STEREO