25 #include <linux/module.h>
27 #include <linux/kernel.h>
28 #include <linux/string.h>
31 #include <linux/errno.h>
32 #include <linux/slab.h>
33 #include <linux/videodev2.h>
34 #include <linux/i2c.h>
40 #ifndef VIDEO_AUDIO_BALANCE
41 # define VIDEO_AUDIO_BALANCE 32
54 MODULE_PARM_DESC(loudness,
"Turn loudness on(1) else off(0). Default is off(0).");
56 MODULE_PARM_DESC(maxvol,
"Set maximium volume to +20dB(0) else +0dB(1). Default is +20dB(0).");
92 #define TDA7432_IN 0x00
93 #define TDA7432_VL 0x01
94 #define TDA7432_TN 0x02
95 #define TDA7432_LF 0x03
96 #define TDA7432_LR 0x04
97 #define TDA7432_RF 0x05
98 #define TDA7432_RR 0x06
99 #define TDA7432_LD 0x07
121 #define TDA7432_STEREO_IN 0
122 #define TDA7432_MONO_IN 2
123 #define TDA7432_BASS_SYM 1 << 3
124 #define TDA7432_BASS_NORM 1 << 4
139 #define TDA7432_VOL_0DB 0x20
140 #define TDA7432_LD_ON 1 << 7
164 #define TDA7432_TREBLE_0DB 0xf
165 #define TDA7432_TREBLE 7
166 #define TDA7432_TREBLE_GAIN 1 << 3
167 #define TDA7432_BASS_0DB 0xf
168 #define TDA7432_BASS 7 << 4
169 #define TDA7432_BASS_GAIN 1 << 7
188 #define TDA7432_ATTEN_0DB 0x00
189 #define TDA7432_MUTE 0x1 << 5
220 v4l2_err(sd,
"I/O error, trying (write %d 0x%x)\n",
231 unsigned char buf[16];
234 "tda7432: 7432_set(0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x)\n",
248 v4l2_err(sd,
"I/O error, trying tda7432_set\n");
255 static void do_tda7432_init(
struct v4l2_subdev *sd)
257 struct tda7432 *t = to_state(sd);
281 struct tda7432 *t = to_state(sd);
296 if ( (t->
lf) < (t->
rf) )
298 ctrl->
value = (32768 - 1057*(t->
rf));
301 ctrl->
value = (32768 + 1057*(t->
lf));
309 bass = ~(bass - 0x8) & 0xf;
310 ctrl->
value = (bass << 12)+(bass << 8)+(bass << 4)+(bass);
317 treble = ~(treble - 0x8) & 0xf;
318 ctrl->
value = (treble << 12)+(treble << 8)+(treble << 4)+(treble);
327 struct tda7432 *t = to_state(sd);
345 if (ctrl->
value < 32768) {
347 t->
rr = (32768 - ctrl->
value)/1057;
351 }
else if(ctrl->
value > 32769) {
353 t->
lf = (ctrl->
value - 32768)/1057;
418 .queryctrl = tda7432_queryctrl,
419 .g_ctrl = tda7432_g_ctrl,
420 .s_ctrl = tda7432_s_ctrl,
424 .core = &tda7432_core_ops,
433 static int tda7432_probe(
struct i2c_client *client,
439 v4l_info(client,
"chip found @ 0x%02x (%s)\n",
447 if (loudness < 0 || loudness > 15) {
448 v4l2_warn(sd,
"loudness parameter must be between 0 and 15\n");
459 static int tda7432_remove(
struct i2c_client *client)
461 struct v4l2_subdev *sd = i2c_get_clientdata(client);
480 .probe = tda7432_probe,
481 .remove = tda7432_remove,
482 .id_table = tda7432_id,