]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - tas2557sw-android/tas2557-stereo-driver.git/commitdiff
update for "mono case" support
authorPeter Li <a0220410@ti.com>
Fri, 24 Mar 2017 17:44:26 +0000 (01:44 +0800)
committerPeter Li <a0220410@ti.com>
Fri, 24 Mar 2017 17:44:26 +0000 (01:44 +0800)
tas2557-codec.c
tas2557-core.c
tas2557-core.h
tas2557-misc.c
tas2557-regmap.c
tas2557.h

index 1e26ac8932e4338be068feaefc106781440a1ca0..d924ccb0eebda3b6dcb6b4a469498b5cb5f687f4 100755 (executable)
@@ -326,17 +326,10 @@ static int tas2557_program_put(struct snd_kcontrol *pKcontrol,
 #endif
        struct tas2557_priv *pTAS2557 = snd_soc_codec_get_drvdata(codec);
        unsigned int nProgram = pValue->value.integer.value[0];
-       struct TConfiguration *pConfiguration;
        int ret = 0;
 
        mutex_lock(&pTAS2557->codec_lock);
-       if ((pTAS2557->mpFirmware->mnPrograms > 0)
-               && (pTAS2557->mpFirmware->mnConfigurations > 0)) {
-               pConfiguration = &(pTAS2557->mpFirmware->mpConfigurations[pTAS2557->mnCurrentConfiguration]);
-               ret = tas2557_set_program(pTAS2557, pConfiguration->mnDevices, nProgram, -1);
-       } else
-               dev_err(pTAS2557->dev, "%s, firmware not loaded\n", __func__);
-
+       ret = tas2557_set_program(pTAS2557, nProgram, -1);
        mutex_unlock(&pTAS2557->codec_lock);
        return ret;
 }
index 48da03e4ceeae9c3ee2f711e8db624e34ef73e42..c2b4a2e982eb326fb6b70bfd714f165fb22c649a 100755 (executable)
@@ -134,13 +134,6 @@ static unsigned int p_tas2557_shutdown_data[] = {
        0xFFFFFFFF, 0xFFFFFFFF
 };
 
-static unsigned int p_tas2557_mute_DSP_down_data[] = {
-       TAS2557_MUTE_REG, 0x03,          /* mute */
-       TAS2557_POWER_CTRL1_REG, 0x60,   /* DSP power down */
-       TAS2557_UDELAY, 0xFF,            /* delay */
-       0xFFFFFFFF, 0xFFFFFFFF
-};
-
 static int tas2557_dev_load_data(struct tas2557_priv *pTAS2557,
        enum channel chl, unsigned int *pData)
 {
@@ -443,25 +436,13 @@ end:
 
 static void failsafe(struct tas2557_priv *pTAS2557)
 {
-       struct TConfiguration *pConfiguration;
-       enum channel chl;
-
        dev_err(pTAS2557->dev, "%s\n", __func__);
        pTAS2557->mnErrCode |= ERROR_FAILSAFE;
-       if (pTAS2557->mpFirmware->mnConfigurations) {
-               if (pTAS2557->mnCurrentConfiguration >= pTAS2557->mpFirmware->mnConfigurations)
-                       chl = channel_both;
-               else {
-                       pConfiguration = &(pTAS2557->mpFirmware->mpConfigurations[pTAS2557->mnCurrentConfiguration]);
-                       chl = pConfiguration->mnDevices;
-               }
-       } else
-               chl = channel_both;
 
        if (hrtimer_active(&pTAS2557->mtimer))
                hrtimer_cancel(&pTAS2557->mtimer);
        pTAS2557->enableIRQ(pTAS2557, channel_both, false);
-       tas2557_dev_load_data(pTAS2557, chl, p_tas2557_shutdown_data);
+       tas2557_dev_load_data(pTAS2557, channel_both, p_tas2557_shutdown_data);
        pTAS2557->mbPowerUp = false;
        pTAS2557->hw_reset(pTAS2557);
        pTAS2557->write(pTAS2557, channel_both, TAS2557_SW_RESET_REG, 0x01);
@@ -471,6 +452,16 @@ static void failsafe(struct tas2557_priv *pTAS2557)
                tas2557_clear_firmware(pTAS2557->mpFirmware);
 }
 
+int tas2557_checkPLL(struct tas2557_priv *pTAS2557)
+{
+       int nResult = 0;
+/*
+* TO DO
+*/
+
+       return nResult;
+}
+
 /*
 * tas2557_load_coefficient
 */
@@ -517,14 +508,14 @@ static int tas2557_load_coefficient(struct tas2557_priv *pTAS2557,
 
        pProgram = &(pTAS2557->mpFirmware->mpPrograms[pTAS2557->mnCurrentProgram]);
        if (bPowerOn) {
-               dev_dbg(pTAS2557->dev, "%s, power down to load new PLL\n", __func__);
+               dev_dbg(pTAS2557->dev, "%s, power down to load new snapshot\n", __func__);
                if (hrtimer_active(&pTAS2557->mtimer))
                        hrtimer_cancel(&pTAS2557->mtimer);
 
                if (pProgram->mnAppMode == TAS2557_APP_TUNINGMODE)
                        pTAS2557->enableIRQ(pTAS2557, channel_both, false);
-
-               nResult = tas2557_dev_load_data(pTAS2557, chl, p_tas2557_mute_DSP_down_data);
+               dev_dbg(pTAS2557->dev, "%s, shutdown %d\n", __func__, chl);
+               nResult = tas2557_dev_load_data(pTAS2557, chl, p_tas2557_shutdown_data);
                if (nResult < 0)
                        goto end;
                bRestorePower = true;
@@ -591,10 +582,17 @@ prog_coefficient:
 
        if (bRestorePower) {
                pTAS2557->clearIRQ(pTAS2557);
-               dev_dbg(pTAS2557->dev, "device powered up, load startup\n");
+               dev_dbg(pTAS2557->dev, "%s, %s, load startup %d\n",
+                       __func__, pNewConfiguration->mpName, pNewConfiguration->mnDevices);
                nResult = tas2557_dev_load_data(pTAS2557, pNewConfiguration->mnDevices, p_tas2557_startup_data);
                if (nResult < 0)
                        goto end;
+               nResult = tas2557_checkPLL(pTAS2557);
+               if (nResult < 0) {
+                       nResult = tas2557_dev_load_data(pTAS2557, pNewConfiguration->mnDevices, p_tas2557_shutdown_data);
+                       pTAS2557->mbPowerUp = false;
+                       goto end;
+               }
                dev_dbg(pTAS2557->dev,
                        "device powered up, load unmute\n");
                nResult = tas2557_dev_load_data(pTAS2557, pNewConfiguration->mnDevices, p_tas2557_unmute_data);
@@ -616,16 +614,6 @@ end:
        return nResult;
 }
 
-int tas2557_checkPLL(struct tas2557_priv *pTAS2557)
-{
-       int nResult = 0;
-/*
-* TO DO
-*/
-
-       return nResult;
-}
-
 int tas2557_enable(struct tas2557_priv *pTAS2557, bool bEnable)
 {
        int nResult = 0;
@@ -673,7 +661,8 @@ int tas2557_enable(struct tas2557_priv *pTAS2557, bool bEnable)
                        pTAS2557->clearIRQ(pTAS2557);
                        pConfiguration = &(pTAS2557->mpFirmware->mpConfigurations[pTAS2557->mnCurrentConfiguration]);
                        /* power on device */
-                       dev_dbg(pTAS2557->dev, "Enable: load startup sequence\n");
+                       dev_dbg(pTAS2557->dev, "%s: %s, %d, load startup sequence\n",
+                               __func__, pConfiguration->mpName, pConfiguration->mnDevices);
                        nResult = tas2557_dev_load_data(pTAS2557, pConfiguration->mnDevices, p_tas2557_startup_data);
                        if (nResult < 0)
                                goto end;
@@ -711,6 +700,7 @@ int tas2557_enable(struct tas2557_priv *pTAS2557, bool bEnable)
                                /* turn off IRQ */
                                pTAS2557->enableIRQ(pTAS2557, channel_both, false);
                        }
+                       dev_dbg(pTAS2557->dev, "%s, %s, shutdown %d\n", __func__, pConfiguration->mpName, pConfiguration->mnDevices);
                        nResult = tas2557_dev_load_data(pTAS2557, pConfiguration->mnDevices, p_tas2557_shutdown_data);
                        if (nResult < 0)
                                goto end;
@@ -1699,7 +1689,7 @@ static int tas2557_load_configuration(struct tas2557_priv *pTAS2557,
        struct TConfiguration *pCurrentConfiguration = NULL;
        struct TConfiguration *pNewConfiguration = NULL;
 
-       dev_dbg(pTAS2557->dev, "tas2557_load_configuration: %d\n", nConfiguration);
+       dev_dbg(pTAS2557->dev, "%s: %d\n", __func__, nConfiguration);
 
        if ((!pTAS2557->mpFirmware->mpPrograms) ||
                (!pTAS2557->mpFirmware->mpConfigurations)) {
@@ -1909,7 +1899,6 @@ void tas2557_fw_ready(const struct firmware *pFW, void *pContext)
        struct TConfiguration *pConfiguration;
        int nResult;
        unsigned int nProgram = 0;
-       unsigned int nDevices = 0;
        unsigned int nSampleRate = 0;
 
 #ifdef CONFIG_TAS2557_CODEC_STEREO
@@ -1932,7 +1921,6 @@ void tas2557_fw_ready(const struct firmware *pFW, void *pContext)
                nProgram = pTAS2557->mnCurrentProgram;
                nSampleRate = pTAS2557->mnCurrentSampleRate;
                pConfiguration = &(pTAS2557->mpFirmware->mpConfigurations[pTAS2557->mnCurrentConfiguration]);
-               nDevices = pConfiguration->mnDevices;
                dev_dbg(pTAS2557->dev, "clear current firmware\n");
                tas2557_clear_firmware(pTAS2557->mpFirmware);
        }
@@ -1963,7 +1951,7 @@ void tas2557_fw_ready(const struct firmware *pFW, void *pContext)
        }
 
        pTAS2557->mnCurrentSampleRate = nSampleRate;
-       nResult = tas2557_set_program(pTAS2557, nDevices, nProgram, -1);
+       nResult = tas2557_set_program(pTAS2557, nProgram, -1);
 
 end:
 
@@ -1976,7 +1964,7 @@ end:
 #endif
 }
 
-int tas2557_set_program(struct tas2557_priv *pTAS2557, int nPrevDevices,
+int tas2557_set_program(struct tas2557_priv *pTAS2557,
        unsigned int nProgram, int nConfig)
 {
        struct TProgram *pProgram;
@@ -2046,7 +2034,7 @@ int tas2557_set_program(struct tas2557_priv *pTAS2557, int nPrevDevices,
                if (pProgram->mnAppMode == TAS2557_APP_TUNINGMODE)
                        pTAS2557->enableIRQ(pTAS2557, channel_both, false);
 
-               nResult = tas2557_dev_load_data(pTAS2557, nPrevDevices, p_tas2557_mute_DSP_down_data);
+               nResult = tas2557_dev_load_data(pTAS2557, channel_both, p_tas2557_shutdown_data);
                if (nResult < 0)
                        goto end;
        }
@@ -2085,7 +2073,8 @@ int tas2557_set_program(struct tas2557_priv *pTAS2557, int nPrevDevices,
        if (pTAS2557->mbPowerUp) {
                pTAS2557->clearIRQ(pTAS2557);
                pConfiguration = &(pTAS2557->mpFirmware->mpConfigurations[pTAS2557->mnCurrentConfiguration]);
-               dev_dbg(pTAS2557->dev, "device powered up, load startup\n");
+               dev_dbg(pTAS2557->dev, "%s, %s, load startup %d\n",
+                       __func__, pConfiguration->mpName, pConfiguration->mnDevices);
                nResult = tas2557_dev_load_data(pTAS2557, pConfiguration->mnDevices, p_tas2557_startup_data);
                if (nResult < 0)
                        goto end;
@@ -2168,8 +2157,7 @@ int tas2557_set_calibration(struct tas2557_priv *pTAS2557, int nCalibration)
 end:
        if (nResult < 0) {
                tas2557_clear_firmware(pTAS2557->mpCalFirmware);
-               nResult = tas2557_set_program(pTAS2557, pConfiguration->mnDevices,
-                       pTAS2557->mnCurrentProgram, pTAS2557->mnCurrentConfiguration);
+               nResult = tas2557_set_program(pTAS2557, pTAS2557->mnCurrentProgram, pTAS2557->mnCurrentConfiguration);
        }
 
        return nResult;
index 8164054850c6a063998bf58613001903aa44bdc8..63eb6509fbaf7d75b8b0f7ac1e6d4d0496acf113 100755 (executable)
@@ -67,7 +67,7 @@ int tas2557_set_bit_rate(struct tas2557_priv *pTAS2557, enum channel chn, unsign
 int tas2557_get_bit_rate(struct tas2557_priv *pTAS2557, enum channel chn, unsigned char *pBitRate);
 int tas2557_set_config(struct tas2557_priv *pTAS2557, int config);
 void tas2557_fw_ready(const struct firmware *pFW, void *pContext);
-int tas2557_set_program(struct tas2557_priv *pTAS2557, int nPrevDevices, unsigned int nProgram, int nConfig);
+int tas2557_set_program(struct tas2557_priv *pTAS2557, unsigned int nProgram, int nConfig);
 int tas2557_set_calibration(struct tas2557_priv *pTAS2557, int nCalibration);
 int tas2557_load_default(struct tas2557_priv *pTAS2557);
 int tas2557_parse_dt(struct device *dev, struct tas2557_priv *pTAS2557);
index 3a0937930f205b8a25bf41b00c87d3c847c6fcd2..a7f869f2fb966fff82bd7325741f89175f41d4e3 100755 (executable)
@@ -316,7 +316,6 @@ static ssize_t tas2557_file_write(struct file *file, const char *buf, size_t cou
 {
        struct tas2557_priv *pTAS2557 = (struct tas2557_priv *)file->private_data;
        int ret = 0;
-       struct TConfiguration *pConfiguration;
        unsigned char *p_kBuf = NULL;
        unsigned int reg = 0;
        enum channel chl;
@@ -396,8 +395,7 @@ static ssize_t tas2557_file_write(struct file *file, const char *buf, size_t cou
                                && (pTAS2557->mpFirmware->mnPrograms > 0)) {
                                if (g_logEnable)
                                        dev_info(pTAS2557->dev, "TIAUDIO_CMD_PROGRAM, set to %d\n", p_kBuf[1]);
-                               pConfiguration = &(pTAS2557->mpFirmware->mpConfigurations[pTAS2557->mnCurrentConfiguration]);
-                               tas2557_set_program(pTAS2557, pConfiguration->mnDevices, p_kBuf[1], -1);
+                               tas2557_set_program(pTAS2557, p_kBuf[1], -1);
                                pTAS2557->mnDBGCmd = 0;
                        } else
                                dev_err(pTAS2557->dev, "%s, firmware not loaded\n", __func__);
@@ -523,7 +521,6 @@ err:
 static long tas2557_file_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 {
        struct tas2557_priv *pTAS2557 = file->private_data;
-       struct TConfiguration *pConfiguration;
        int ret = 0;
 
        mutex_lock(&pTAS2557->file_lock);
@@ -549,10 +546,8 @@ static long tas2557_file_unlocked_ioctl(struct file *file, unsigned int cmd, uns
        case SMARTPA_SPK_SWITCH_PROGRAM:
        {
                if ((pTAS2557->mpFirmware->mnConfigurations > 0)
-                       && (pTAS2557->mpFirmware->mnPrograms > 0)) {
-                       pConfiguration = &(pTAS2557->mpFirmware->mpConfigurations[pTAS2557->mnCurrentConfiguration]);
-                       tas2557_set_program(pTAS2557, pConfiguration->mnDevices, arg, -1);
-               }
+                       && (pTAS2557->mpFirmware->mnPrograms > 0))
+                       tas2557_set_program(pTAS2557, arg, -1);
        }
        break;
 
index 32dc7838e480b62a6357b68068ff8e5d5284e2a0..935b84eecbaf746f2d7d399cc2df219aabd5bfba 100755 (executable)
@@ -837,8 +837,7 @@ static void irq_work_routine(struct work_struct *work)
 
 program:
        /* hardware reset and reload */
-       tas2557_set_program(pTAS2557, pConfiguration->mnDevices,
-               pTAS2557->mnCurrentProgram, pTAS2557->mnCurrentConfiguration);
+       tas2557_set_program(pTAS2557, pTAS2557->mnCurrentProgram, pTAS2557->mnCurrentConfiguration);
 
 end:
 
index 09c5d920fa8246d43f957a4528f803573a40512b..54621e8755224cfffbe2c1059518ab7a3bac6806 100755 (executable)
--- a/tas2557.h
+++ b/tas2557.h
 #define TAS2557_ASI1_WDIV_CLK_RATIO_REG                TAS2557_REG(0, 1, 15)
 #define TAS2557_ASI1_DAC_CLKOUT_REG            TAS2557_REG(0, 1, 16)
 #define TAS2557_ASI1_ADC_CLKOUT_REG            TAS2557_REG(0, 1, 17)
-
 #define TAS2557_ASI2_DAC_FORMAT_REG            TAS2557_REG(0, 1, 21)
 #define TAS2557_ASI2_ADC_FORMAT_REG            TAS2557_REG(0, 1, 22)
 #define TAS2557_ASI2_OFFSET1_REG               TAS2557_REG(0, 1, 23)
 #define TAS2557_ASI2_WDIV_CLK_RATIO_REG                TAS2557_REG(0, 1, 35)
 #define TAS2557_ASI2_DAC_CLKOUT_REG            TAS2557_REG(0, 1, 36)
 #define TAS2557_ASI2_ADC_CLKOUT_REG            TAS2557_REG(0, 1, 37)
-
 #define TAS2557_GPIO1_PIN_REG                  TAS2557_REG(0, 1, 61)   /*B0_P1_R0x3d */
 #define TAS2557_GPIO2_PIN_REG                  TAS2557_REG(0, 1, 62)   /*B0_P1_R0x3e */
 #define TAS2557_GPIO3_PIN_REG                  TAS2557_REG(0, 1, 63)   /*B0_P1_R0x3f */
 #define TAS2557_GPIO8_PIN_REG                  TAS2557_REG(0, 1, 68)
 #define TAS2557_GPIO9_PIN_REG                  TAS2557_REG(0, 1, 69)
 #define TAS2557_GPIO10_PIN_REG                 TAS2557_REG(0, 1, 70)
-
 #define TAS2557_GPI_PIN_REG                            TAS2557_REG(0, 1, 77)   /*B0_P1_R0x4d */
 #define TAS2557_GPIO_HIZ_CTRL1_REG             TAS2557_REG(0, 1, 79)
 #define TAS2557_GPIO_HIZ_CTRL2_REG             TAS2557_REG(0, 1, 80)
 #define TAS2557_GPIO_HIZ_CTRL3_REG             TAS2557_REG(0, 1, 81)
 #define TAS2557_GPIO_HIZ_CTRL4_REG             TAS2557_REG(0, 1, 82)
 #define TAS2557_GPIO_HIZ_CTRL5_REG             TAS2557_REG(0, 1, 83)
-
 #define TAS2557_BIT_BANG_CTRL_REG              TAS2557_REG(0, 1, 87)
 #define TAS2557_BIT_BANG_OUT1_REG              TAS2557_REG(0, 1, 88)
 #define TAS2557_BIT_BANG_OUT2_REG              TAS2557_REG(0, 1, 89)
 #define TAS2557_BIT_BANG_IN1_REG               TAS2557_REG(0, 1, 90)
 #define TAS2557_BIT_BANG_IN2_REG               TAS2557_REG(0, 1, 91)
 #define TAS2557_BIT_BANG_IN3_REG               TAS2557_REG(0, 1, 92)
-
 #define TAS2557_PDM_IN_CLK_REG                 TAS2557_REG(0, 1, 94)
 #define TAS2557_PDM_IN_PIN_REG                 TAS2557_REG(0, 1, 95)
-
 #define TAS2557_ASIM_IFACE1_REG                        TAS2557_REG(0, 1, 98)
 #define TAS2557_ASIM_FORMAT_REG                        TAS2557_REG(0, 1, 99)
 #define TAS2557_ASIM_IFACE3_REG                        TAS2557_REG(0, 1, 100)
 #define TAS2557_INT_GEN3_REG                   TAS2557_REG(0, 1, 110)  /* B0_P1_R0x6e */
 #define TAS2557_INT_GEN4_REG                   TAS2557_REG(0, 1, 111)  /* B0_P1_R0x6f */
 #define TAS2557_INT_MODE_REG                   TAS2557_REG(0, 1, 114)  /* B0_P1_R0x72 */
-
 #define TAS2557_MAIN_CLKIN_REG                 TAS2557_REG(0, 1, 115)
 #define TAS2557_PLL_CLKIN_REG                  TAS2557_REG(0, 1, 116)
 #define TAS2557_CLKOUT_MUX_REG                 TAS2557_REG(0, 1, 117)
 #define TAS2557_CLKOUT_CDIV_REG                        TAS2557_REG(0, 1, 118)
-
 #define TAS2557_HACK_GP01_REG                  TAS2557_REG(0, 1, 122)
 
 #define TAS2557_HACK01_REG                     TAS2557_REG(0, 2, 10)
 
 #define TAS2557_SA_PG1P0_CHL_CTRL_REG  TAS2557_REG(0, 58, 120) /* B0_P0x3a_R0x78 */
 
-
 #define TAS2557_TEST_MODE_REG                  TAS2557_REG(0, 253, 13)
 #define TAS2557_BROADCAST_REG                  TAS2557_REG(0, 253, 54)
 #define TAS2557_CRYPTIC_REG                    TAS2557_REG(0, 253, 71)
 
+#define TAS2557_XMEM_687_REG                           TAS2557_REG(78, 23, 116)        /* B0x78_P0x23_R0x40 */
+
 #define TAS2557_DAC_INTERPOL_REG               TAS2557_REG(100, 0, 1)
 #define TAS2557_SOFT_MUTE_REG                  TAS2557_REG(100, 0, 7)
 #define TAS2557_PLL_P_VAL_REG                  TAS2557_REG(100, 0, 27)
 #define TAS2557_RAMP_CLK_DIV_MSB_REG           TAS2557_REG(100, 0, 43)
 #define TAS2557_RAMP_CLK_DIV_LSB_REG           TAS2557_REG(100, 0, 44)
 
-#define TAS2557_XMEM_44_REG                            TAS2557_REG(130, 2, 64) /* B0x82_P0x02_R0x40 */
 #define TAS2557_DIE_TEMP_REG                   TAS2557_REG(130, 2, 124)        /* B0x82_P0x02_R0x7C */
 
 /* Bits */
 
 #define TAS2557_BROADCAST_ADDR 0x4c
 
-#define TAS2557_APP_ROM1MODE   0
-#define TAS2557_APP_ROM2MODE   1
-#define TAS2557_APP_TUNINGMODE 2
+#define        TAS2557_APP_ROM1MODE    0
+#define        TAS2557_APP_ROM2MODE    1
+#define        TAS2557_APP_TUNINGMODE  2
+#define        TAS2557_APP_ROM1_96KHZ  3
+#define        TAS2557_APP_ROM2_96KHZ  4
+#define        TAS2557_APP_RAMMODE             5
+
+#define        TAS2557_BOOST_OFF               0
+#define        TAS2557_BOOST_DEVA              1
+#define        TAS2557_BOOST_DEVB              2
+#define        TAS2557_BOOST_BOTH              3
 
 #define        ERROR_NONE                      0x00000000
 #define        ERROR_PLL_ABSENT        0x00000001