update for calibration load
authorPeter Li <peter-li@ti.com>
Mon, 16 Jan 2017 14:45:18 +0000 (22:45 +0800)
committerPeter Li <peter-li@ti.com>
Mon, 16 Jan 2017 14:45:18 +0000 (22:45 +0800)
tas2557-core.c
tas2557-core.h
tas2557-misc.c
tas2557-regmap.c
tas2557.h
tiload.c

index 2e4730dc7173ec2e9abf542bac540c5390438ac5..2f025b84ee40df9004027577d15658ca5ace9429 100755 (executable)
@@ -51,9 +51,9 @@
 
 static void tas2557_load_calibration(struct tas2557_priv *pTAS2557,
        char *pFileName);
-static void tas2557_load_data(struct tas2557_priv *pTAS2557, TData * pData,
+static void tas2557_load_data(struct tas2557_priv *pTAS2557, struct TData * pData,
        unsigned int nType);
-static void tas2557_load_block(struct tas2557_priv *pTAS2557, TBlock * pBlock);
+static void tas2557_load_block(struct tas2557_priv *pTAS2557, struct TBlock * pBlock);
 static void tas2557_load_configuration(struct tas2557_priv *pTAS2557,
        unsigned int nConfiguration, bool bLoadSame);
        
@@ -220,9 +220,7 @@ int tas2557_setChannel(struct tas2557_priv *pTAS2557, int channel)
                ret = tas2557_dev_load_blk_data(pTAS2557, p_tas2557_SA_chl_right_data);
        }
                
-       if(pTAS2557->mbPowerUp && (ret >= 0)){
-               ret = tas2557_dev_load_blk_data(pTAS2557, p_tas2557_SA_swap_data);
-       }
+       ret = tas2557_dev_load_blk_data(pTAS2557, p_tas2557_SA_swap_data);
        
        return ret;
 }
@@ -268,7 +266,7 @@ void tas2557_enable(struct tas2557_priv *pTAS2557, bool bEnable)
 
 int tas2557_set_sampling_rate(struct tas2557_priv *pTAS2557, unsigned int nSamplingRate)
 {
-       TConfiguration *pConfiguration;
+       struct TConfiguration *pConfiguration;
        unsigned int nConfiguration;
 
        dev_dbg(pTAS2557->dev, "tas2557_setup_clocks: nSamplingRate = %d [Hz]\n",
@@ -308,7 +306,7 @@ int tas2557_set_sampling_rate(struct tas2557_priv *pTAS2557, unsigned int nSampl
        return -EINVAL;
 }
 
-static void fw_print_header(struct tas2557_priv *pTAS2557, TFirmware * pFirmware)
+static void fw_print_header(struct tas2557_priv *pTAS2557, struct TFirmware * pFirmware)
 {
        dev_info(pTAS2557->dev, "FW Size        = %d", pFirmware->mnFWSize);
        dev_info(pTAS2557->dev, "Checksum       = 0x%04X", pFirmware->mnChecksum);
@@ -326,7 +324,7 @@ inline unsigned int fw_convert_number(unsigned char *pData)
 }
 
 static int fw_parse_header(struct tas2557_priv *pTAS2557, 
-       TFirmware * pFirmware, unsigned char *pData,
+       struct TFirmware * pFirmware, unsigned char *pData,
        unsigned int nSize)
 {
        unsigned char *pDataStart = pData;
@@ -397,7 +395,7 @@ static int fw_parse_header(struct tas2557_priv *pTAS2557,
        return pData - pDataStart;
 }
 
-static int fw_parse_block_data(TBlock * pBlock, unsigned char *pData)
+static int fw_parse_block_data(struct TBlock * pBlock, unsigned char *pData)
 {
        unsigned char *pDataStart = pData;
        unsigned int n;
@@ -415,7 +413,7 @@ static int fw_parse_block_data(TBlock * pBlock, unsigned char *pData)
        return pData - pDataStart;
 }
 
-static int fw_parse_data(TData * pImageData, unsigned char *pData)
+static int fw_parse_data(struct TData * pImageData, unsigned char *pData)
 {
        unsigned char *pDataStart = pData;
        unsigned int nBlock;
@@ -432,7 +430,7 @@ static int fw_parse_data(TData * pImageData, unsigned char *pData)
        pData += 2;
 
        pImageData->mpBlocks =
-               kmalloc(sizeof(TBlock) * pImageData->mnBlocks, GFP_KERNEL);
+               kmalloc(sizeof(struct TBlock) * pImageData->mnBlocks, GFP_KERNEL);
 
        for (nBlock = 0; nBlock < pImageData->mnBlocks; nBlock++) {
                n = fw_parse_block_data(&(pImageData->mpBlocks[nBlock]), pData);
@@ -442,17 +440,17 @@ static int fw_parse_data(TData * pImageData, unsigned char *pData)
        return pData - pDataStart;
 }
 
-static int fw_parse_pll_data(TFirmware * pFirmware, unsigned char *pData)
+static int fw_parse_pll_data(struct TFirmware * pFirmware, unsigned char *pData)
 {
        unsigned char *pDataStart = pData;
        unsigned int n;
        unsigned int nPLL;
-       TPLL *pPLL;
+       struct TPLL *pPLL;
 
        pFirmware->mnPLLs = (pData[0] << 8) + pData[1];
        pData += 2;
 
-       pFirmware->mpPLLs = kmalloc(sizeof(TPLL) * pFirmware->mnPLLs, GFP_KERNEL);
+       pFirmware->mpPLLs = kmalloc(sizeof(struct TPLL) * pFirmware->mnPLLs, GFP_KERNEL);
        for (nPLL = 0; nPLL < pFirmware->mnPLLs; nPLL++) {
                pPLL = &(pFirmware->mpPLLs[nPLL]);
 
@@ -470,18 +468,18 @@ static int fw_parse_pll_data(TFirmware * pFirmware, unsigned char *pData)
        return pData - pDataStart;
 }
 
-static int fw_parse_program_data(TFirmware * pFirmware, unsigned char *pData)
+static int fw_parse_program_data(struct TFirmware * pFirmware, unsigned char *pData)
 {
        unsigned char *pDataStart = pData;
        unsigned int n;
        unsigned int nProgram;
-       TProgram *pProgram;
+       struct TProgram *pProgram;
 
        pFirmware->mnPrograms = (pData[0] << 8) + pData[1];
        pData += 2;
 
        pFirmware->mpPrograms =
-               kmalloc(sizeof(TProgram) * pFirmware->mnPrograms, GFP_KERNEL);
+               kmalloc(sizeof(struct TProgram) * pFirmware->mnPrograms, GFP_KERNEL);
        for (nProgram = 0; nProgram < pFirmware->mnPrograms; nProgram++) {
                pProgram = &(pFirmware->mpPrograms[nProgram]);
                memcpy(pProgram->mpName, pData, 64);
@@ -504,19 +502,19 @@ static int fw_parse_program_data(TFirmware * pFirmware, unsigned char *pData)
        return pData - pDataStart;
 }
 
-static int fw_parse_configuration_data(TFirmware * pFirmware,
+static int fw_parse_configuration_data(struct TFirmware * pFirmware,
        unsigned char *pData)
 {
        unsigned char *pDataStart = pData;
        unsigned int n;
        unsigned int nConfiguration;
-       TConfiguration *pConfiguration;
+       struct TConfiguration *pConfiguration;
 
        pFirmware->mnConfigurations = (pData[0] << 8) + pData[1];
        pData += 2;
 
        pFirmware->mpConfigurations =
-               kmalloc(sizeof(TConfiguration) * pFirmware->mnConfigurations,
+               kmalloc(sizeof(struct TConfiguration) * pFirmware->mnConfigurations,
                GFP_KERNEL);
        for (nConfiguration = 0; nConfiguration < pFirmware->mnConfigurations;
                nConfiguration++) {
@@ -544,18 +542,18 @@ static int fw_parse_configuration_data(TFirmware * pFirmware,
        return pData - pDataStart;
 }
 
-int fw_parse_calibration_data(TFirmware * pFirmware, unsigned char *pData)
+int fw_parse_calibration_data(struct TFirmware * pFirmware, unsigned char *pData)
 {
        unsigned char *pDataStart = pData;
        unsigned int n;
        unsigned int nCalibration;
-       TCalibration *pCalibration;
+       struct TCalibration *pCalibration;
 
        pFirmware->mnCalibrations = (pData[0] << 8) + pData[1];
        pData += 2;
 
        pFirmware->mpCalibrations =
-               kmalloc(sizeof(TCalibration) * pFirmware->mnCalibrations, GFP_KERNEL);
+               kmalloc(sizeof(struct TCalibration) * pFirmware->mnCalibrations, GFP_KERNEL);
        for (nCalibration = 0;
                nCalibration < pFirmware->mnCalibrations;
                nCalibration++) {
@@ -573,7 +571,7 @@ int fw_parse_calibration_data(TFirmware * pFirmware, unsigned char *pData)
                pCalibration->mnConfiguration = pData[0];
                pData++;
 
-               n = fw_parse_block_data(&(pCalibration->mBlock), pData);
+               n = fw_parse_data(&(pCalibration->mData), pData);
                pData += n;
        }
 
@@ -581,7 +579,7 @@ int fw_parse_calibration_data(TFirmware * pFirmware, unsigned char *pData)
 }
 
 static int fw_parse(struct tas2557_priv *pTAS2557,
-       TFirmware * pFirmware,
+       struct TFirmware * pFirmware,
        unsigned char *pData,
        unsigned int nSize)
 {
@@ -626,7 +624,7 @@ static int fw_parse(struct tas2557_priv *pTAS2557,
        return 0;
 }
 
-static void tas2557_load_block(struct tas2557_priv *pTAS2557, TBlock * pBlock)
+static void tas2557_load_block(struct tas2557_priv *pTAS2557, struct TBlock * pBlock)
 {
        unsigned int nCommand = 0;
        unsigned char nBook;
@@ -674,11 +672,11 @@ static void tas2557_load_block(struct tas2557_priv *pTAS2557, TBlock * pBlock)
        }
 }
 
-static void tas2557_load_data(struct tas2557_priv *pTAS2557, TData * pData,
+static void tas2557_load_data(struct tas2557_priv *pTAS2557, struct TData * pData,
        unsigned int nType)
 {
        unsigned int nBlock;
-       TBlock *pBlock;
+       struct TBlock *pBlock;
 
        dev_dbg(pTAS2557->dev,
                "TAS2557 load data: %s, Blocks = %d, Block Type = %d\n", pData->mpName,
@@ -694,9 +692,9 @@ static void tas2557_load_data(struct tas2557_priv *pTAS2557, TData * pData,
 static void tas2557_load_configuration(struct tas2557_priv *pTAS2557,
        unsigned int nConfiguration, bool bLoadSame)
 {
-       TConfiguration *pCurrentConfiguration;
-       TConfiguration *pNewConfiguration;
-       TPLL *pNewPLL;
+       struct TConfiguration *pCurrentConfiguration;
+       struct TConfiguration *pNewConfiguration;
+       struct TPLL *pNewPLL;
 
        dev_dbg(pTAS2557->dev, "tas2557_load_configuration: %d\n", nConfiguration);
 
@@ -759,6 +757,12 @@ static void tas2557_load_configuration(struct tas2557_priv *pTAS2557,
                                pNewConfiguration->mpName);
                        tas2557_load_data(pTAS2557, &(pNewConfiguration->mData),
                                TAS2557_BLOCK_CFG_COEFF_DEV_A);
+                       if(pTAS2557->mpCalFirmware->mnCalibrations){
+                               struct TCalibration *pCalibration = &(pTAS2557->mpCalFirmware->mpCalibrations[pTAS2557->mnCurrentCalibration]);
+                               tas2557_load_data(pTAS2557, &(pCalibration->mData),
+                                       TAS2557_BLOCK_CFG_COEFF_DEV_A);
+                       }
+
                        if(pTAS2557->mnDevChl == LEFT_CHANNEL){
                                tas2557_dev_load_blk_data(pTAS2557, p_tas2557_SA_chl_left_data);
                        }else if(pTAS2557->mnDevChl == RIGHT_CHANNEL){
@@ -773,7 +777,13 @@ static void tas2557_load_configuration(struct tas2557_priv *pTAS2557,
                                "TAS2557 is powered up, no change in PLL: load new configuration: %s, coeff block data\n",
                                pNewConfiguration->mpName);
                        tas2557_load_data(pTAS2557, &(pNewConfiguration->mData),
-                               TAS2557_BLOCK_CFG_COEFF_DEV_A); 
+                               TAS2557_BLOCK_CFG_COEFF_DEV_A);
+                       if (pTAS2557->mpCalFirmware->mnCalibrations) {
+                               struct TCalibration *pCalibration = &(pTAS2557->mpCalFirmware->mpCalibrations[pTAS2557->mnCurrentCalibration]);
+                               tas2557_load_data(pTAS2557, &(pCalibration->mData),
+                                       TAS2557_BLOCK_CFG_COEFF_DEV_A);
+                       }
+
                        if(pTAS2557->mnDevChl == LEFT_CHANNEL){
                                tas2557_dev_load_blk_data(pTAS2557, p_tas2557_SA_chl_left_data);
                        }else if(pTAS2557->mnDevChl == RIGHT_CHANNEL){
@@ -796,19 +806,22 @@ static void tas2557_load_configuration(struct tas2557_priv *pTAS2557,
                        tas2557_load_data(pTAS2557, &(pNewConfiguration->mData),
                                TAS2557_BLOCK_CFG_PRE_DEV_A);
                }
-               
+
                dev_dbg(pTAS2557->dev,
                                "TAS2557: load new configuration: %s, coeff block data\n",
                                pNewConfiguration->mpName);
                tas2557_load_data(pTAS2557, &(pNewConfiguration->mData),
-                               TAS2557_BLOCK_CFG_COEFF_DEV_A); 
-                               
-               if(pTAS2557->mnDevChl == LEFT_CHANNEL){
+                               TAS2557_BLOCK_CFG_COEFF_DEV_A);
+               if (pTAS2557->mpFirmware->mnCalibrations) {
+                       struct TCalibration *pCalibration = &(pTAS2557->mpCalFirmware->mpCalibrations[pTAS2557->mnCurrentCalibration]);
+                       tas2557_load_data(pTAS2557, &(pCalibration->mData),
+                               TAS2557_BLOCK_CFG_COEFF_DEV_A);
+               }
+               if (pTAS2557->mnDevChl == LEFT_CHANNEL)
                        tas2557_dev_load_blk_data(pTAS2557, p_tas2557_SA_chl_left_data);
-               }else if(pTAS2557->mnDevChl == RIGHT_CHANNEL){
+               else if(pTAS2557->mnDevChl == RIGHT_CHANNEL)
                        tas2557_dev_load_blk_data(pTAS2557, p_tas2557_SA_chl_right_data);
-               }               
-               
+
                pTAS2557->mbLoadConfigurationPostPowerUp = true;
        }
 
@@ -817,8 +830,8 @@ static void tas2557_load_configuration(struct tas2557_priv *pTAS2557,
 
 int tas2557_set_config(struct tas2557_priv *pTAS2557, int config)
 {
-       TConfiguration *pConfiguration;
-       TProgram *pProgram;
+       struct TConfiguration *pConfiguration;
+       struct TProgram *pProgram;
        unsigned int nProgram = pTAS2557->mnCurrentProgram;
        unsigned int nConfiguration = config;
 
@@ -850,47 +863,53 @@ int tas2557_set_config(struct tas2557_priv *pTAS2557, int config)
        return 0;
 }
 
-void tas2557_clear_firmware(TFirmware *pFirmware)
+void tas2557_clear_firmware(struct TFirmware *pFirmware)
 {
        unsigned int n, nn;
        if (!pFirmware) return;
        if (pFirmware->mpDescription) kfree(pFirmware->mpDescription);  
 
-       for (n = 0; n < pFirmware->mnPLLs; n++)
-       {
-               kfree(pFirmware->mpPLLs[n].mpDescription);
-               kfree(pFirmware->mpPLLs[n].mBlock.mpData);
+       if (pFirmware->mpPLLs) {
+               for (n = 0; n < pFirmware->mnPLLs; n++) {
+                       kfree(pFirmware->mpPLLs[n].mpDescription);
+                       kfree(pFirmware->mpPLLs[n].mBlock.mpData);
+               }
+               kfree(pFirmware->mpPLLs);
        }
-       kfree(pFirmware->mpPLLs);
 
-       for (n = 0; n < pFirmware->mnPrograms; n++)
-       {
-               kfree(pFirmware->mpPrograms[n].mpDescription);
-               kfree(pFirmware->mpPrograms[n].mData.mpDescription);
-               for (nn = 0; nn < pFirmware->mpPrograms[n].mData.mnBlocks; nn++)
-                       kfree(pFirmware->mpPrograms[n].mData.mpBlocks[nn].mpData);
-               kfree(pFirmware->mpPrograms[n].mData.mpBlocks);
+       if (pFirmware->mpPrograms) {
+               for (n = 0; n < pFirmware->mnPrograms; n++) {
+                       kfree(pFirmware->mpPrograms[n].mpDescription);
+                       kfree(pFirmware->mpPrograms[n].mData.mpDescription);
+                       for (nn = 0; nn < pFirmware->mpPrograms[n].mData.mnBlocks; nn++)
+                               kfree(pFirmware->mpPrograms[n].mData.mpBlocks[nn].mpData);
+                       kfree(pFirmware->mpPrograms[n].mData.mpBlocks);
+               }
+               kfree(pFirmware->mpPrograms);
        }
-       kfree(pFirmware->mpPrograms);
 
-       for (n = 0; n < pFirmware->mnConfigurations; n++)
-       {
-               kfree(pFirmware->mpConfigurations[n].mpDescription);
-               kfree(pFirmware->mpConfigurations[n].mData.mpDescription);
-               for (nn = 0; nn < pFirmware->mpConfigurations[n].mData.mnBlocks; nn++)
-                       kfree(pFirmware->mpConfigurations[n].mData.mpBlocks[nn].mpData);
-               kfree(pFirmware->mpConfigurations[n].mData.mpBlocks);
+       if (pFirmware->mpConfigurations) {
+               for (n = 0; n < pFirmware->mnConfigurations; n++) {
+                       kfree(pFirmware->mpConfigurations[n].mpDescription);
+                       kfree(pFirmware->mpConfigurations[n].mData.mpDescription);
+                       for (nn = 0; nn < pFirmware->mpConfigurations[n].mData.mnBlocks; nn++)
+                               kfree(pFirmware->mpConfigurations[n].mData.mpBlocks[nn].mpData);
+                       kfree(pFirmware->mpConfigurations[n].mData.mpBlocks);
+               }
+               kfree(pFirmware->mpConfigurations);
        }
-       kfree(pFirmware->mpConfigurations);
 
-       for (n = 0; n < pFirmware->mnCalibrations; n++)
-       {
-               kfree(pFirmware->mpCalibrations[n].mpDescription);
-               kfree(pFirmware->mpCalibrations[n].mBlock.mpData);
+       if (pFirmware->mpCalibrations) {
+               for (n = 0; n < pFirmware->mnCalibrations; n++) {
+                       kfree(pFirmware->mpCalibrations[n].mpDescription);
+                       for (nn = 0; nn < pFirmware->mpCalibrations[n].mData.mnBlocks; nn++)
+                               kfree(pFirmware->mpCalibrations[n].mData.mpBlocks[nn].mpData);
+                       kfree(pFirmware->mpCalibrations[n].mData.mpBlocks);
+               }
+               kfree(pFirmware->mpCalibrations);
        }
-       kfree(pFirmware->mpCalibrations);
 
-       memset(pFirmware, 0x00, sizeof(TFirmware));
+       memset(pFirmware, 0x00, sizeof(struct TFirmware));
 }
 
 static void tas2557_load_calibration(struct tas2557_priv *pTAS2557,
@@ -997,8 +1016,8 @@ void tas2557_fw_ready(const struct firmware *pFW, void *pContext)
 int tas2557_set_program(struct tas2557_priv *pTAS2557,
        unsigned int nProgram)
 {
-       TPLL *pPLL;
-       TConfiguration *pConfiguration;
+       struct TPLL *pPLL;
+       struct TConfiguration *pConfiguration;
        unsigned int nConfiguration = 0;
        unsigned int nSampleRate = 0;
        unsigned int Value = 0;
@@ -1102,9 +1121,10 @@ int tas2557_set_program(struct tas2557_priv *pTAS2557,
        return 0;
 }
 
-int tas2557_set_calibration(struct tas2557_priv *pTAS2557,
-       int nCalibration)
+int tas2557_set_calibration(struct tas2557_priv *pTAS2557, int nCalibration)
 {
+       struct TCalibration *pCalibration;
+
        if ((!pTAS2557->mpFirmware->mpPrograms) || (!pTAS2557->mpFirmware->mpConfigurations)) 
        {
                dev_err(pTAS2557->dev, "Firmware not loaded\n\r");
@@ -1118,20 +1138,15 @@ int tas2557_set_calibration(struct tas2557_priv *pTAS2557,
                nCalibration = 0;
        }
 
-       if (nCalibration >= pTAS2557->mpFirmware->mnCalibrations) {
+       if (nCalibration >= pTAS2557->mpCalFirmware->mnCalibrations) {
                dev_err(pTAS2557->dev,
                        "Calibration %d doesn't exist\n", nCalibration);
                return -1;
        }
 
        pTAS2557->mnCurrentCalibration = nCalibration;
-       if(pTAS2557->mbPowerUp){
-               tas2557_load_block(pTAS2557, 
-                       &(pTAS2557->mpCalFirmware->mpCalibrations[pTAS2557->mnCurrentCalibration].mBlock));
-               pTAS2557->mbLoadCalibrationPostPowerUp = false; 
-       }else{
-               pTAS2557->mbLoadCalibrationPostPowerUp = true; 
-       }
+       pCalibration = &(pTAS2557->mpCalFirmware->mpCalibrations[pTAS2557->mnCurrentCalibration]);
+       tas2557_load_data(pTAS2557, &(pCalibration->mData), TAS2557_BLOCK_CFG_COEFF_DEV_A);
 
        return 0;
 }
index b9e126cc7b61e18f8f7bf2e84131bfcc51afa548..7aa9eaca1683d2c4e3ae0dc70ee45afc3875df3e 100755 (executable)
 
 #include "tas2557.h"
 
-extern int tas2557_parse_dt(struct device *dev,
+int tas2557_parse_dt(struct device *dev,
                        struct tas2557_priv *pTAS2557);
-extern void tas2557_enable(struct tas2557_priv *pTAS2557, bool bEnable);
-extern int tas2557_set_sampling_rate(struct tas2557_priv *pTAS2557, 
+void tas2557_enable(struct tas2557_priv *pTAS2557, bool bEnable);
+int tas2557_set_sampling_rate(struct tas2557_priv *pTAS2557, 
        unsigned int nSamplingRate);
-extern int tas2557_set_config(struct tas2557_priv *pTAS2557, int config);
-extern void tas2557_load_fs_firmware(struct tas2557_priv *pTAS2557,
+int tas2557_set_config(struct tas2557_priv *pTAS2557, int config);
+void tas2557_load_fs_firmware(struct tas2557_priv *pTAS2557,
        char *pFileName);
-extern void tas2557_fw_ready(const struct firmware *pFW, void *pContext);
-extern int tas2557_set_program(struct tas2557_priv *pTAS2557,
+void tas2557_fw_ready(const struct firmware *pFW, void *pContext);
+int tas2557_set_program(struct tas2557_priv *pTAS2557,
        unsigned int nProgram);
-extern int tas2557_set_calibration(struct tas2557_priv *pTAS2557,
+int tas2557_set_calibration(struct tas2557_priv *pTAS2557,
        int nCalibration);
-extern int tas2557_load_default(struct tas2557_priv *pTAS2557);
+int tas2557_load_default(struct tas2557_priv *pTAS2557);
 int tas2557_setChannel(struct tas2557_priv *pTAS2557, int channel);
        
 #endif /* _TAS2557_CORE_H */
index 024ebae48c281414320613cfbef490380bb2550a..26cb388e16bbdbc832061519a0be3649f3297af9 100755 (executable)
@@ -165,14 +165,14 @@ static ssize_t tas2557_file_read(struct file *file, char *buf, size_t count, lof
                
                case TIAUDIO_CMD_PROGRAM:
                {
-                       if(g_logEnable) dev_info(pTAS2557->dev,
+                       if (g_logEnable) dev_info(pTAS2557->dev,
                                                "TIAUDIO_CMD_PROGRAM: count = %d\n", 
                                                (int)count);
 
-                       if(count == PROGRAM_BUF_SIZE){
+                       if (count == PROGRAM_BUF_SIZE) {
                                p_kBuf = (unsigned char *)kzalloc(count, GFP_KERNEL);
-                               if(p_kBuf != NULL){
-                                       TProgram * pProgram = 
+                               if (p_kBuf != NULL) {
+                                       struct TProgram * pProgram = 
                                                &(pTAS2557->mpFirmware->mpPrograms[pTAS2557->mnCurrentProgram]);
                                        
                                        p_kBuf[0] = pTAS2557->mpFirmware->mnPrograms;                                                   
@@ -188,27 +188,24 @@ static ssize_t tas2557_file_read(struct file *file, char *buf, size_t count, lof
                                                /* Failed to copy all the data, exit */
                                                dev_err(pTAS2557->dev, "copy to user fail %d\n", ret);
                                        }
-                                       
                                        kfree(p_kBuf);
-                               }else{
+                               } else
                                        dev_err(pTAS2557->dev, "read no mem\n");
-                               }                               
-                       }else{
+                       }else
                                dev_err(pTAS2557->dev, "read buffer not sufficient\n");
-                       }
                }
                break;
                
                case TIAUDIO_CMD_CONFIGURATION:
                {
-                       if(g_logEnable) dev_info(pTAS2557->dev,
+                       if (g_logEnable) dev_info(pTAS2557->dev,
                                                "TIAUDIO_CMD_CONFIGURATION: count = %d\n", 
                                                (int)count);
 
                        if(count == CONFIGURATION_BUF_SIZE){
                                p_kBuf = (unsigned char *)kzalloc(count, GFP_KERNEL);
                                if(p_kBuf != NULL){
-                                       TConfiguration * pConfiguration = 
+                                       struct TConfiguration * pConfiguration = 
                                                &(pTAS2557->mpFirmware->mpConfigurations[pTAS2557->mnCurrentConfiguration]);
 
                                        p_kBuf[0] = pTAS2557->mpFirmware->mnConfigurations;                                                                                     
@@ -291,7 +288,7 @@ static ssize_t tas2557_file_read(struct file *file, char *buf, size_t count, lof
                        if(count == 4){
                                p_kBuf = (unsigned char *)kzalloc(count, GFP_KERNEL);
                                if(p_kBuf != NULL){                             
-                                       TConfiguration *pConfiguration = 
+                                       struct TConfiguration *pConfiguration = 
                                                &(pTAS2557->mpFirmware->mpConfigurations[pTAS2557->mnCurrentConfiguration]);
 
                                        p_kBuf[0] = (pConfiguration->mnSamplingRate&0x000000ff);
index fdb203ff0acf6a1298070278b3af2d70cebd97db..ed72cb879ee18ef7f1a02e02235a1fa2edbe7cc4 100755 (executable)
@@ -294,13 +294,13 @@ static int tas2557_i2c_probe(struct i2c_client *pClient,
        udelay(1000);
 
        pTAS2557->mpFirmware =
-               devm_kzalloc(&pClient->dev, sizeof(TFirmware),
+               devm_kzalloc(&pClient->dev, sizeof(struct TFirmware),
                GFP_KERNEL);
        if (!pTAS2557->mpFirmware)
                return -ENOMEM;
 
        pTAS2557->mpCalFirmware =
-               devm_kzalloc(&pClient->dev, sizeof(TFirmware),
+               devm_kzalloc(&pClient->dev, sizeof(struct TFirmware),
                GFP_KERNEL);
        if (!pTAS2557->mpCalFirmware)
                return -ENOMEM;
index d184ef4467b075c81f48f93b3031948570dd6389..609f62822947305f3cfd0bc62df2e7d7b2e70be5 100755 (executable)
--- a/tas2557.h
+++ b/tas2557.h
@@ -47,9 +47,9 @@
 #define TAS2557_SW_RESET_REG                   TAS2557_REG(0, 0, 1)
 
 #define TAS2557_REV_PGID_REG                   TAS2557_REG(0, 0, 3)
-#define TAS2557_PG_VERSION_1P0                 0x00
-#define TAS2557_PG_VERSION_2P0                 0x10
-#define TAS2557_PG_VERSION_2P1                 0x20
+#define TAS2557_PG_VERSION_1P0                 0x80
+#define TAS2557_PG_VERSION_2P0                 0x90
+#define TAS2557_PG_VERSION_2P1                 0xa0
 
 #define TAS2557_POWER_CTRL1_REG                        TAS2557_REG(0, 0, 4)
 #define TAS2557_POWER_CTRL2_REG                        TAS2557_REG(0, 0, 5)
 #define LEFT_CHANNEL   0
 #define RIGHT_CHANNEL  1
 
-typedef struct {
+struct TBlock {
        unsigned int mnType;
        unsigned int mnCommands;
        unsigned char *mpData;
-} TBlock;
+};
 
-typedef struct {
+struct TData {
        char mpName[64];
        char *mpDescription;
        unsigned int mnBlocks;
-       TBlock *mpBlocks;
-} TData;
+       struct TBlock *mpBlocks;
+};
 
-typedef struct {
+struct TProgram {
        char mpName[64];
        char *mpDescription;
        unsigned char mnAppMode;
        unsigned short mnBoost;
-       TData mData;
-} TProgram;
+       struct TData mData;
+};
 
-typedef struct {
+struct TPLL {
        char mpName[64];
        char *mpDescription;
-       TBlock mBlock;
-} TPLL;
+       struct TBlock mBlock;
+};
 
-typedef struct {
+struct TConfiguration {
        char mpName[64];
        char *mpDescription;
        unsigned int mnProgram;
        unsigned int mnPLL;
        unsigned int mnSamplingRate;
-       TData mData;
-} TConfiguration;
+       struct TData mData;
+};
 
-typedef struct
-{
+struct TCalibration {
        char mpName[64];
        char *mpDescription;
        unsigned int mnProgram;
        unsigned int mnConfiguration;
-       TBlock mBlock;
-} TCalibration;
+       struct TData mData;
+};
 
-typedef struct {
+struct TFirmware {
        unsigned int mnFWSize;
        unsigned int mnChecksum;
        unsigned int mnPPCVersion;
@@ -340,14 +339,14 @@ typedef struct {
        unsigned int mnDeviceFamily;
        unsigned int mnDevice;
        unsigned int mnPLLs;
-       TPLL *mpPLLs;
+       struct TPLL *mpPLLs;
        unsigned int mnPrograms;
-       TProgram *mpPrograms;
+       struct TProgram *mpPrograms;
        unsigned int mnConfigurations;
-       TConfiguration *mpConfigurations;
+       struct TConfiguration *mpConfigurations;
        unsigned int mnCalibrations;
-       TCalibration *mpCalibrations;
-} TFirmware;
+       struct TCalibration *mpCalibrations;
+};
 
 struct tas2557_register {
        int book;
@@ -360,10 +359,10 @@ struct tas2557_priv {
        struct regmap *mpRegmap;
        int mnLoad;
        int mnPGID;
-       int mnResetGPIO;        
-       struct mutex dev_lock;  
-       TFirmware *mpFirmware;
-       TFirmware *mpCalFirmware;
+       int mnResetGPIO;
+       struct mutex dev_lock;
+       struct TFirmware *mpFirmware;
+       struct TFirmware *mpCalFirmware;
        unsigned int mnCurrentProgram;
        unsigned int mnCurrentSampleRate;
        unsigned int mnCurrentConfiguration;
@@ -377,26 +376,26 @@ struct tas2557_priv {
        bool mbLoadCalibrationPostPowerUp;
        unsigned int mnPowerCtrl;
        bool mbCalibrationLoaded;
-       int (*read) (struct tas2557_priv * pTAS2557, unsigned int reg,
+       int (*read)(struct tas2557_priv * pTAS2557, unsigned int reg,
                unsigned int *pValue);
-       int (*write) (struct tas2557_priv * pTAS2557, unsigned int reg,
+       int (*write)(struct tas2557_priv * pTAS2557, unsigned int reg,
                unsigned int Value);
-       int (*bulk_read) (struct tas2557_priv * pTAS2557, unsigned int reg,
+       int (*bulk_read)(struct tas2557_priv * pTAS2557, unsigned int reg,
                unsigned char *pData, unsigned int len);
-       int (*bulk_write) (struct tas2557_priv * pTAS2557, unsigned int reg,
+       int (*bulk_write)(struct tas2557_priv * pTAS2557, unsigned int reg,
                unsigned char *pData, unsigned int len);
-       int (*update_bits) (struct tas2557_priv * pTAS2557, unsigned int reg,
+       int (*update_bits)(struct tas2557_priv * pTAS2557, unsigned int reg,
                unsigned int mask, unsigned int value);
-       int (*set_config) (struct tas2557_priv *pTAS2557, int config);
-       int (*set_calibration) (struct tas2557_priv *pTAS2557, int calibration);        
-#ifdef CONFIG_TAS2557_CODEC    
+       int (*set_config)(struct tas2557_priv *pTAS2557, int config);
+       int (*set_calibration)(struct tas2557_priv *pTAS2557, int calibration);
+#ifdef CONFIG_TAS2557_CODEC
        struct mutex codec_lock;
-#endif 
-#ifdef CONFIG_TAS2557_MISC     
+#endif
+#ifdef CONFIG_TAS2557_MISC
        int mnDBGCmd;
-       int mnCurrentReg;       
+       int mnCurrentReg;
        struct mutex file_lock;
-#endif 
+#endif
 };
 
 #endif /* _TAS2557_H */
index e7757dd113f7901369faff6edecb3b128cd5cb39..5afe6f7facb50b5f9fcd6453e8595c94f4bb89d7 100755 (executable)
--- a/tiload.c
+++ b/tiload.c
@@ -284,7 +284,7 @@ static long tiload_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
                        bpr.nPage, bpr.nRegister);
                break;
        case TILOAD_IOCTL_SET_CHL:
-               break;          
+               break;
        case TILOAD_IOCTL_SET_CONFIG:
                num = copy_from_user(&val, argp, sizeof(val));
                pTAS2557->set_config(pTAS2557, val);
@@ -292,7 +292,7 @@ static long tiload_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
        case TILOAD_IOCTL_SET_CALIBRATION:
                num = copy_from_user(&val, argp, sizeof(val));
                pTAS2557->set_calibration(pTAS2557, val);
-               break;                          
+               break;
        default:
                break;
        }