]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - tas2557sw-android/tas2557-stereo-driver.git/commitdiff
update for interrupt handling
authorPeter Li <peter-li@ti.com>
Tue, 17 Jan 2017 15:37:33 +0000 (23:37 +0800)
committerPeter Li <peter-li@ti.com>
Tue, 17 Jan 2017 15:37:33 +0000 (23:37 +0800)
tas2557-codec.c [changed mode: 0644->0755]
tas2557-core.c [changed mode: 0644->0755]
tas2557-core.h [changed mode: 0644->0755]
tas2557-misc.c [changed mode: 0644->0755]
tas2557-regmap.c [changed mode: 0644->0755]
tiload.c [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index 8ecbc14..fb39a39
@@ -297,7 +297,7 @@ static int tas2557_program_put(struct snd_kcontrol *pKcontrol,
        unsigned int nProgram = pValue->value.integer.value[0];
        int ret = 0;
 
-       ret = tas2557_set_program(pTAS2557, nProgram);
+       ret = tas2557_set_program(pTAS2557, nProgram, -1);
        return ret;
 }
 
@@ -543,5 +543,5 @@ int tas2557_deregister_codec(struct tas2557_priv *pTAS2557)
 
 MODULE_AUTHOR("Texas Instruments Inc.");
 MODULE_DESCRIPTION("TAS2557 ALSA SOC Smart Amplifier Stereo driver");
-MODULE_LICENSE("GPLv2");
+MODULE_LICENSE("GPL v2");
 #endif
old mode 100644 (file)
new mode 100755 (executable)
index c6a12a0..1d25be4
@@ -1002,10 +1002,10 @@ void tas2557_fw_ready(const struct firmware *pFW, void *pContext)
        }
        pTAS2557->mnCurrentSampleRate = nSampleRate;
 
-       tas2557_set_program(pTAS2557, nProgram);
+       tas2557_set_program(pTAS2557, nProgram, -1);
 }
 
-int tas2557_set_program(struct tas2557_priv *pTAS2557, unsigned int nProgram)
+int tas2557_set_program(struct tas2557_priv *pTAS2557, unsigned int nProgram, int nConfig)
 {
        struct TPLL *pPLL;
        struct TConfiguration *pConfiguration;
@@ -1022,32 +1022,37 @@ int tas2557_set_program(struct tas2557_priv *pTAS2557, unsigned int nProgram)
        }
        if (nProgram >= pTAS2557->mpFirmware->mnPrograms) {
                dev_err(pTAS2557->dev, "TAS2557: Program %d doesn't exist\n",
-                       nConfiguration);
+                       nProgram);
                return -EINVAL;
        }
-       nConfiguration = 0;
-       nSampleRate = pTAS2557->mnCurrentSampleRate;
-       while (!bFound && (nConfiguration < pTAS2557->mpFirmware->mnConfigurations)) {
-               if (pTAS2557->mpFirmware->mpConfigurations[nConfiguration].mnProgram == nProgram) {
-                       if (nSampleRate == 0) {
-                               bFound = true;
-                               dev_info(pTAS2557->dev, "find default configuration %d\n", nConfiguration);
-                       } else if (nSampleRate == pTAS2557->mpFirmware->mpConfigurations[nConfiguration].mnSamplingRate) {
-                               bFound = true;
-                               dev_info(pTAS2557->dev, "find matching configuration %d\n", nConfiguration);
+
+       if (nConfig < 0) {
+               nConfiguration = 0;
+               nSampleRate = pTAS2557->mnCurrentSampleRate;
+               while (!bFound && (nConfiguration < pTAS2557->mpFirmware->mnConfigurations)) {
+                       if (pTAS2557->mpFirmware->mpConfigurations[nConfiguration].mnProgram == nProgram) {
+                               if (nSampleRate == 0) {
+                                       bFound = true;
+                                       dev_info(pTAS2557->dev, "find default configuration %d\n", nConfiguration);
+                               } else if (nSampleRate == pTAS2557->mpFirmware->mpConfigurations[nConfiguration].mnSamplingRate) {
+                                       bFound = true;
+                                       dev_info(pTAS2557->dev, "find matching configuration %d\n", nConfiguration);
+                               } else {
+                                       nConfiguration++;
+                               }
                        } else {
                                nConfiguration++;
                        }
-               } else {
-                       nConfiguration++;
                }
-       }
-       if (!bFound) {
-               dev_err(pTAS2557->dev,
-                       "Program %d, no valid configuration found for sample rate %d, ignore\n",
-                       nProgram, nSampleRate);
-               return -EINVAL;
-       }
+               if (!bFound) {
+                       dev_err(pTAS2557->dev,
+                               "Program %d, no valid configuration found for sample rate %d, ignore\n",
+                               nProgram, nSampleRate);
+                       return -EINVAL;
+               }
+       } else
+               nConfiguration = nConfig;
+
        pTAS2557->mnCurrentProgram = nProgram;
        if (pTAS2557->mbPowerUp) {
                nResult = tas2557_dev_load_data(pTAS2557, p_tas2557_mute_DSP_down_data);
@@ -1193,4 +1198,4 @@ int tas2557_parse_dt(struct device *dev, struct tas2557_priv *pTAS2557)
 
 MODULE_AUTHOR("Texas Instruments Inc.");
 MODULE_DESCRIPTION("TAS2557 common functions for Android Linux");
-MODULE_LICENSE("GPLv2");
+MODULE_LICENSE("GPL v2");
old mode 100644 (file)
new mode 100755 (executable)
index 462d9a4..125af7b
@@ -30,7 +30,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, unsigned int nProgram);
+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);
old mode 100644 (file)
new mode 100755 (executable)
index aa5f082..bf096d6
@@ -392,7 +392,7 @@ static ssize_t tas2557_file_write(struct file *file, const char *buf, size_t cou
                                dev_info(pTAS2557->dev,
                                "TIAUDIO_CMD_PROGRAM, set to %d\n",
                                p_kBuf[1]);
-                       tas2557_set_program(pTAS2557, p_kBuf[1]);
+                       tas2557_set_program(pTAS2557, p_kBuf[1], -1);
                        pTAS2557->mnDBGCmd = 0;
                }
        }
@@ -537,7 +537,7 @@ static long tas2557_file_unlocked_ioctl(struct file *file, unsigned int cmd, uns
 
        case SMARTPA_SPK_SWITCH_PROGRAM:
        {
-               tas2557_set_program(pTAS2557, arg);
+               tas2557_set_program(pTAS2557, arg, -1);
        }
        break;
 
old mode 100644 (file)
new mode 100755 (executable)
index ee2d344..93ea6ee
@@ -532,31 +532,34 @@ void tas2557_enableIRQ(struct tas2557_priv *pTAS2557, int enable)
 static void irq_work_routine(struct work_struct *work)
 {
        int nResult = 0;
-       unsigned char nDev1IntStatus1, nDev1IntStatus2;
-       unsigned char nDev2IntStatus1, nDev2IntStatus2;
+       unsigned int nDevIntStatus;
        struct tas2557_priv *pTAS2557 =
                container_of(work, struct tas2557_priv, irq_work);
 
-       mutex_lock(&pTAS2557->dev_lock);
+       if (!pTAS2557->mbPowerUp)
+               return;
 
-       nResult = tas2557_change_book_page(pTAS2557,
-                               channel_both,
-                               TAS2557_BOOK_ID(TAS2557_FLAGS_1),
-                               TAS2557_PAGE_ID(TAS2557_FLAGS_1));
-       if (nResult < 0)
+       nResult = tas2557_dev_read(pTAS2557, channel_left, TAS2557_FLAGS_1, &nDevIntStatus);
+       if (nResult < 0) {
+               dev_err(pTAS2557->dev, "left channel I2C doesn't work\n");
                goto program;
+       } else if ((nDevIntStatus && 0xdc) != 0) {
+               /* in case of INT_OC, INT_UV, INT_OT, INT_BO, INT_CL */
+               dev_err(pTAS2557->dev, "left channel critical error 0x%x\n", nDevIntStatus);
+               goto program;
+       }
 
-       tas2557_i2c_read_device(pTAS2557,
-               pTAS2557->mnLAddr, TAS2557_PAGE_REG(TAS2557_FLAGS_1), &nDev1IntStatus1);
-       tas2557_i2c_read_device(pTAS2557,
-               pTAS2557->mnLAddr, TAS2557_PAGE_REG(TAS2557_FLAGS_2), &nDev1IntStatus2);
-       tas2557_i2c_read_device(pTAS2557,
-               pTAS2557->mnRAddr, TAS2557_PAGE_REG(TAS2557_FLAGS_1), &nDev2IntStatus1);
-       tas2557_i2c_read_device(pTAS2557,
-               pTAS2557->mnRAddr, TAS2557_PAGE_REG(TAS2557_FLAGS_2), &nDev2IntStatus2);
+       nResult = tas2557_dev_read(pTAS2557, channel_right, TAS2557_FLAGS_1, &nDevIntStatus);
+       if (nResult < 0) {
+               dev_err(pTAS2557->dev, "right channel I2C doesn't work\n");
+               goto program;
+       } else if ((nDevIntStatus && 0xdc) != 0) {
+               /* in case of INT_OC, INT_UV, INT_OT, INT_BO, INT_CL */
+               dev_err(pTAS2557->dev, "right channel critical error 0x%x\n", nDevIntStatus);
+               goto program;
+       }
 
-       /* check IRQ status and take action accordingly */
-       goto end;
+       return;
 
 program:
        /* hardware reset and reload */
@@ -570,11 +573,7 @@ program:
 #endif
        }
 
-       tas2557_set_program(pTAS2557, pTAS2557->mnCurrentProgram);
-
-end:
-
-       mutex_unlock(&pTAS2557->dev_lock);
+       tas2557_set_program(pTAS2557, pTAS2557->mnCurrentProgram, pTAS2557->mnCurrentConfiguration);
 }
 
 static irqreturn_t tas2557_irq_handler(int irq, void *dev_id)
old mode 100644 (file)
new mode 100755 (executable)