add mix command for set channel
authora0220410 <peter-li@ti.com>
Tue, 20 Dec 2016 00:24:51 +0000 (08:24 +0800)
committera0220410 <peter-li@ti.com>
Tue, 20 Dec 2016 00:24:51 +0000 (08:24 +0800)
tas2557-codec.c
tas2557-core.c
tas2557-core.h

index 1f365d8212de768931f5979f72d5b6134647066e..885d2f687177e8d1b04aa12210db33ef3f83fdeb 100755 (executable)
@@ -529,6 +529,45 @@ static int tas2557_calibration_put(struct snd_kcontrol *pKcontrol,
  */
 static DECLARE_TLV_DB_SCALE(dac_tlv, 0, 100, 0);
 
+static const char *channel_text[] = {"Left Channel","Right Channel"};
+
+static const struct soc_enum channel_enum[] = {
+       SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(channel_text),channel_text),
+};
+
+static int tas2557_get_channel(struct snd_kcontrol *pKcontrol,
+                       struct snd_ctl_elem_value *pUcontrol)
+{
+#ifdef KCONTROL_CODEC
+       struct snd_soc_codec *pCodec = snd_soc_kcontrol_codec(pKcontrol);
+#else
+       struct snd_soc_codec *pCodec = snd_kcontrol_chip(pKcontrol);
+#endif
+       struct tas2557_priv *pTAS2557 = snd_soc_codec_get_drvdata(pCodec);
+
+       pUcontrol->value.integer.value[0] = pTAS2557->mnDevChl;
+       
+       return 0;
+}
+
+static int tas2557_set_channel(struct snd_kcontrol *pKcontrol,
+                       struct snd_ctl_elem_value *pUcontrol)
+{
+#ifdef KCONTROL_CODEC
+       struct snd_soc_codec *pCodec = snd_soc_kcontrol_codec(pKcontrol);
+#else
+       struct snd_soc_codec *pCodec = snd_kcontrol_chip(pKcontrol);
+#endif 
+       struct tas2557_priv *pTAS2557 = snd_soc_codec_get_drvdata(pCodec);
+
+       pTAS2557->mnDevChl = pUcontrol->value.integer.value[0];
+       dev_dbg(pTAS2557->dev,"%s:channel = 0x%x\n",__func__,
+                       pTAS2557->mnDevChl);
+
+       tas2557_setChannel(pTAS2557, pTAS2557->mnDevChl);
+       return 0;
+}
+
 static const struct snd_kcontrol_new tas2557_snd_controls[] = {
        SOC_SINGLE_TLV("DAC Playback Volume", TAS2557_SPK_CTRL_REG, 3, 0x0f, 0,
                dac_tlv),
@@ -546,6 +585,8 @@ static const struct snd_kcontrol_new tas2557_snd_controls[] = {
                tas2557_fs_get, tas2557_fs_put),
        SOC_SINGLE_EXT("Calibration", SND_SOC_NOPM, 0, 0x00FF, 0,
                tas2557_calibration_get, tas2557_calibration_put),
+       SOC_ENUM_EXT("TAS2557 Channel",channel_enum[0],
+                     tas2557_get_channel,tas2557_set_channel),         
 };
 
 static struct snd_soc_codec_driver soc_codec_driver_tas2557 = {
index 3e4d0ab972d327086510ea306efe632e3bfa181d..f0721ba7b03e29ab2422e32576715bb6db767205 100755 (executable)
@@ -88,13 +88,11 @@ static unsigned int p_tas2557_SA_chl_right_data[] =
        0xFFFFFFFF, 0xFFFFFFFF
 };
 
-/*
 static unsigned int p_tas2557_SA_swap_data[] =
 {
        TAS2557_SA_COEFF_SWAP_REG, 0x04, 0x00, 0x00, 0x00, 0x01, // when DSP powered on, swap needed to update coefficient memory
        0xFFFFFFFF, 0xFFFFFFFF
 };
-*/
 
 static unsigned int p_tas2557_dboost_data[] = {
        TAS2557_DBOOST_CTL_REG, 0x08,   //enable, 0x0c=disable
@@ -290,16 +288,31 @@ err:
        return ret;
 }
 
+int tas2557_setChannel(struct tas2557_priv *pTAS2557, int channel)
+{
+       int ret = -1;
+       
+       if(channel == LEFT_CHANNEL){
+               ret = pTAS2557->update_bits(pTAS2557, TAS2557_ASI_CTRL_REG, 0x06, 0x00);        //ROM mode
+               ret = tas2557_dev_load_blk_data(pTAS2557, p_tas2557_SA_chl_left_data);
+       }else if(channel == RIGHT_CHANNEL){
+               ret = pTAS2557->update_bits(pTAS2557, TAS2557_ASI_CTRL_REG, 0x06, 0x02);        //ROM mode
+               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);
+       }
+       
+       return ret;
+}
+
 int tas2557_load_platdata(struct tas2557_priv *pTAS2557)
 {
        int ret = 0;
        
        ret = tas2557_setLoad(pTAS2557, pTAS2557->mnLoad);
-       if(pTAS2557->mnDevChl == LEFT_CHANNEL){
-               pTAS2557->update_bits(pTAS2557, TAS2557_ASI_CTRL_REG, 0x06, 0x00);      //ROM mode
-       }else if(pTAS2557->mnDevChl == LEFT_CHANNEL){
-               pTAS2557->update_bits(pTAS2557, TAS2557_ASI_CTRL_REG, 0x06, 0x02);      //ROM mode
-       }
+       ret = tas2557_setChannel(pTAS2557, pTAS2557->mnDevChl);
                
        return ret;
 }
index ea2425843d46d19d845b1d544df16917285dd213..b9e126cc7b61e18f8f7bf2e84131bfcc51afa548 100755 (executable)
@@ -42,5 +42,6 @@ extern int tas2557_set_program(struct tas2557_priv *pTAS2557,
 extern int tas2557_set_calibration(struct tas2557_priv *pTAS2557,
        int nCalibration);
 extern int tas2557_load_default(struct tas2557_priv *pTAS2557);
+int tas2557_setChannel(struct tas2557_priv *pTAS2557, int channel);
        
 #endif /* _TAS2557_CORE_H */