Added de-emphasis filter functions and speaker protection.
[aic34-eq] / kernel-2.6.28 / sound / soc / codecs / tlv320aic3x.h
index c71cafc..1e71f08 100644 (file)
 #define _AIC3X_H
 
 /* AIC3X register space */
-#define AIC3X_CACHEREGNUM              103
+#define AIC3X_CACHEREGNUM              205
+#define AIC3X_PAGE0REGNUM              103
+#define AIC3X_PAGE1REGNUM              77
+
 #define AIC3X_COEFF_CACHE_SIZE 52
 #define COEFF_OFFSET(msbreg)   ((msbreg+1)/2)
 
 
 /* Page 1 registers for setting coefficients for filters */
 /* DAC Audio Effects for Left Channel */
-#define EFFECTS_LEFT_N0 1
-#define EFFECTS_LEFT_N1 3
-#define EFFECTS_LEFT_N2 5
-#define EFFECTS_LEFT_N3 7
-#define EFFECTS_LEFT_N4 9
-#define EFFECTS_LEFT_N5 11
-
-#define EFFECTS_LEFT_D1 13
-#define EFFECTS_LEFT_D2 15
-#define EFFECTS_LEFT_D4 17
-#define EFFECTS_LEFT_D5 19
+#define EFFECTS_LEFT_N0 129
+#define EFFECTS_LEFT_N1 131
+#define EFFECTS_LEFT_N2 133
+#define EFFECTS_LEFT_N3 135
+#define EFFECTS_LEFT_N4 137
+#define EFFECTS_LEFT_N5 139
+
+#define EFFECTS_LEFT_D1 141
+#define EFFECTS_LEFT_D2 143
+#define EFFECTS_LEFT_D4 145
+#define EFFECTS_LEFT_D5 147
 
 /* DAC De-Emphasis for Left Channel */
 
-#define DEEMPH_LEFT_N0 21
-#define DEEMPH_LEFT_N1 23
-#define DEEMPH_LEFT_D1 25
+#define DEEMPH_LEFT_N0 149
+#define DEEMPH_LEFT_N1 151
+#define DEEMPH_LEFT_D1 153
 
 /* DAC Audio Effects for Right Channel */
 
-#define EFFECTS_RIGHT_N0 27
-#define EFFECTS_RIGHT_N1 29
-#define EFFECTS_RIGHT_N2 31
-#define EFFECTS_RIGHT_N3 33
-#define EFFECTS_RIGHT_N4 35
-#define EFFECTS_RIGHT_N5 37
+#define EFFECTS_RIGHT_N0 155
+#define EFFECTS_RIGHT_N1 157
+#define EFFECTS_RIGHT_N2 159
+#define EFFECTS_RIGHT_N3 161
+#define EFFECTS_RIGHT_N4 163
+#define EFFECTS_RIGHT_N5 165
 
-#define EFFECTS_RIGHT_D1 39
-#define EFFECTS_RIGHT_D2 41
-#define EFFECTS_RIGHT_D4 43
-#define EFFECTS_RIGHT_D5 45
+#define EFFECTS_RIGHT_D1 167
+#define EFFECTS_RIGHT_D2 169
+#define EFFECTS_RIGHT_D4 171
+#define EFFECTS_RIGHT_D5 173
 
 /* DAC De-Emphasis for Right Channel */
 
-#define DEEMPH_RIGHT_N0 47
-#define DEEMPH_RIGHT_N1 49
-#define DEEMPH_RIGHT_D1 51
+#define DEEMPH_RIGHT_N0 175
+#define DEEMPH_RIGHT_N1 177
+#define DEEMPH_RIGHT_D1 179
 
 /* DAC 3D Attenuation */
 
-#define EFFECTS_3DATTEN 53
+#define EFFECTS_3DATTEN 181
 
 /* ADC High-Pass Filter for Left Channel */
 
-#define HIGHPASS_LEFT_NO 65
-#define HIGHPASS_LEFT_N1 67
-#define HIGHPASS_LEFT_D1 69
+#define HIGHPASS_LEFT_NO 193
+#define HIGHPASS_LEFT_N1 195
+#define HIGHPASS_LEFT_D1 197
 
 /* ADC High-Pass Filter for Right Channel */
 
-#define HIGHPASS_RIGHT_NO 71
-#define HIGHPASS_RIGHT_N1 73
-#define HIGHPASS_RIGHT_D1 75
+#define HIGHPASS_RIGHT_NO 199
+#define HIGHPASS_RIGHT_N1 201
+#define HIGHPASS_RIGHT_D1 203
 
 /* Page select register bits */
 #define PAGE0_SELECT           0
 /* Default input volume */
 #define DEFAULT_GAIN    0x20
 
+/* Filter bits */
+#define EFFECTS_3D_ON  0x04
+#define EFFECTS_ON             0x0a
+#define DEEMPH_ON              0x05
+
 /* GPIO API */
 enum {
        AIC3X_GPIO1_FUNC_DISABLED               = 0,
@@ -280,6 +288,19 @@ enum {
        AIC3X_GPIO2_FUNC_BUTTON_PRESS_IRQ       = 15
 };
 
+/* Data for reading/writing to the IIR Filter hwdep */
+struct aic3x_iir_coeffs {
+       short N0, N1, N2, D1, D2;
+       short N3, N4, N5, D4, D5;
+};
+
+int aic3x_deemph_set_coeffs(struct snd_soc_codec *codec, 
+       int N0, int N1, int D1);
+int aic3x_deemph_set_state(struct snd_soc_codec *codec, int state);
+int aic3x_dacfilter_set_coeffs
+       (struct snd_soc_codec *codec, struct aic3x_iir_coeffs *coeffs);
+int aic3x_dacfilter_set_state(struct snd_soc_codec *codec, int state);
+
 void aic3x_set_gpio(struct snd_soc_codec *codec, int gpio, int state);
 int aic3x_get_gpio(struct snd_soc_codec *codec, int gpio);
 int aic3x_headset_detected(struct snd_soc_codec *codec);