Fixed ioctl code and added coeff setting example code
[aic34-eq] / kernel-2.6.28 / sound / soc / codecs / tlv320aic3x.c
index 944daaf..ec84be5 100644 (file)
@@ -478,7 +478,6 @@ static int aic3x_dacfilter_write_coeffs
     (struct snd_soc_codec *codec, struct aic3x_iir_coeffs *coeffs)
 {
        printk("MNZ: dacfilter_write_coeffs\n");
     (struct snd_soc_codec *codec, struct aic3x_iir_coeffs *coeffs)
 {
        printk("MNZ: dacfilter_write_coeffs\n");
-       snd_soc_update_bits(codec, AIC3X_CODEC_DFILT_CTRL, EFFECTS_ON, 0);
        aic3x_write_coeff(codec, EFFECTS_LEFT_N0, coeffs->N0);
        aic3x_write_coeff(codec, EFFECTS_LEFT_N1, coeffs->N1);
        aic3x_write_coeff(codec, EFFECTS_LEFT_N2, coeffs->N2);
        aic3x_write_coeff(codec, EFFECTS_LEFT_N0, coeffs->N0);
        aic3x_write_coeff(codec, EFFECTS_LEFT_N1, coeffs->N1);
        aic3x_write_coeff(codec, EFFECTS_LEFT_N2, coeffs->N2);
@@ -501,7 +500,7 @@ static int aic3x_dacfilter_write_coeffs
        aic3x_write_coeff(codec, EFFECTS_RIGHT_D4, coeffs->D4);
        aic3x_write_coeff(codec, EFFECTS_RIGHT_D5, coeffs->D5);
        
        aic3x_write_coeff(codec, EFFECTS_RIGHT_D4, coeffs->D4);
        aic3x_write_coeff(codec, EFFECTS_RIGHT_D5, coeffs->D5);
        
-       return 0;
+       return 1;
 }
 
 int aic3x_dacfilter_set_coeffs
 }
 
 int aic3x_dacfilter_set_coeffs
@@ -510,31 +509,39 @@ int aic3x_dacfilter_set_coeffs
        struct aic3x_priv *aic3x = codec->private_data;
        memcpy((void*)&aic3x->dacfilter.coeffs, (void*)coeffs,
                        sizeof(struct aic3x_iir_coeffs));
        struct aic3x_priv *aic3x = codec->private_data;
        memcpy((void*)&aic3x->dacfilter.coeffs, (void*)coeffs,
                        sizeof(struct aic3x_iir_coeffs));
+       if(aic3x->dacfilter.state == 2)
+               aic3x_dacfilter_set_state(codec, 0);
        return 0;
 }
 EXPORT_SYMBOL_GPL(aic3x_dacfilter_set_coeffs);
 
 int aic3x_dacfilter_set_state(struct snd_soc_codec *codec, int state)
 {
        return 0;
 }
 EXPORT_SYMBOL_GPL(aic3x_dacfilter_set_coeffs);
 
 int aic3x_dacfilter_set_state(struct snd_soc_codec *codec, int state)
 {
+       printk("MNZ: dacfilter_set_state to %i\n", state);
        struct aic3x_priv *aic3x = codec->private_data;
        struct aic3x_priv *aic3x = codec->private_data;
-
+       int ret = 0;
        if(aic3x->dacfilter.state == state) return 0;
        if(aic3x->dacfilter.state == state) return 0;
-       
-       aic3x->dacfilter.state = state;
 
 
-       if(state == 0)
-               snd_soc_update_bits(codec, AIC3X_CODEC_DFILT_CTRL,
+       snd_soc_update_bits(codec, AIC3X_CODEC_DFILT_CTRL,
                        EFFECTS_ON, 0);
                        EFFECTS_ON, 0);
-       else if(state == 1) {}
+
+       if(state == 0)
+               ret = 1;
+       else if(state == 1)
+               ret = 1;
                /* FIXME MNZ. Set preset from current chosen preset */
        else if (state == 2){
                /* FIXME MNZ. Set preset from current chosen preset */
        else if (state == 2){
-               aic3x_dacfilter_write_coeffs(codec,     &aic3x->dacfilter.coeffs);
-               snd_soc_update_bits(codec, AIC3X_CODEC_DFILT_CTRL,
+               ret = aic3x_dacfilter_write_coeffs(codec,
+                                       &aic3x->dacfilter.coeffs);
+               if(ret) snd_soc_update_bits(codec, AIC3X_CODEC_DFILT_CTRL,
                        EFFECTS_ON, EFFECTS_ON);
        }
                        EFFECTS_ON, EFFECTS_ON);
        }
+       else ret = 0;
 
 
-       return 0;
+       if(ret) aic3x->dacfilter.state = state;
+       return ret;
 }
 }
+
 EXPORT_SYMBOL_GPL(aic3x_dacfilter_set_state);
 
 /* DAC Filter hwdep device callbacks */
 EXPORT_SYMBOL_GPL(aic3x_dacfilter_set_state);
 
 /* DAC Filter hwdep device callbacks */
@@ -554,8 +561,8 @@ static int snd_hwdep_dacfilter_ioctl_aic3x(struct snd_hwdep *hw,
         */
        struct snd_soc_codec *codec = hw->private_data;
        if (cmd != 1) return -EINVAL;
         */
        struct snd_soc_codec *codec = hw->private_data;
        if (cmd != 1) return -EINVAL;
+       printk("MNZ: IOCTL: cmd = %i, arg = %i\n", cmd, *((int*)arg));
        return aic3x_dacfilter_set_state(codec, *((int*)arg));
        return aic3x_dacfilter_set_state(codec, *((int*)arg));
-       return 0;
 }
 
 static long snd_hwdep_dacfilter_read_aic3x(struct snd_hwdep *hw,
 }
 
 static long snd_hwdep_dacfilter_read_aic3x(struct snd_hwdep *hw,