aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video')
-rw-r--r--drivers/media/video/bt832.c65
-rw-r--r--drivers/media/video/tda7432.c36
2 files changed, 49 insertions, 52 deletions
diff --git a/drivers/media/video/bt832.c b/drivers/media/video/bt832.c
index d2cb5ccff56b..dda4aa6bef27 100644
--- a/drivers/media/video/bt832.c
+++ b/drivers/media/video/bt832.c
@@ -30,8 +30,9 @@
30#include <linux/init.h> 30#include <linux/init.h>
31#include <linux/errno.h> 31#include <linux/errno.h>
32#include <linux/slab.h> 32#include <linux/slab.h>
33
34#include <media/audiochip.h> 33#include <media/audiochip.h>
34#include <media/v4l2-common.h>
35
35#include "bttv.h" 36#include "bttv.h"
36#include "bt832.h" 37#include "bt832.h"
37 38
@@ -42,9 +43,10 @@ static unsigned short normal_i2c[] = { I2C_BT832_ALT1>>1, I2C_BT832_ALT2>>1,
42 I2C_CLIENT_END }; 43 I2C_CLIENT_END };
43I2C_CLIENT_INSMOD; 44I2C_CLIENT_INSMOD;
44 45
45/* ---------------------------------------------------------------------- */ 46int debug = 0; /* debug output */
47module_param(debug, int, 0644);
46 48
47#define dprintk if (debug) printk 49/* ---------------------------------------------------------------------- */
48 50
49static int bt832_detach(struct i2c_client *client); 51static int bt832_detach(struct i2c_client *client);
50 52
@@ -61,23 +63,26 @@ int bt832_hexdump(struct i2c_client *i2c_client_s, unsigned char *buf)
61 int i,rc; 63 int i,rc;
62 buf[0]=0x80; // start at register 0 with auto-increment 64 buf[0]=0x80; // start at register 0 with auto-increment
63 if (1 != (rc = i2c_master_send(i2c_client_s,buf,1))) 65 if (1 != (rc = i2c_master_send(i2c_client_s,buf,1)))
64 printk("bt832: i2c i/o error: rc == %d (should be 1)\n",rc); 66 v4l_err(i2c_client_s,"i2c i/o error: rc == %d (should be 1)\n",rc);
65 67
66 for(i=0;i<65;i++) 68 for(i=0;i<65;i++)
67 buf[i]=0; 69 buf[i]=0;
68 if (65 != (rc=i2c_master_recv(i2c_client_s,buf,65))) 70 if (65 != (rc=i2c_master_recv(i2c_client_s,buf,65)))
69 printk("bt832: i2c i/o error: rc == %d (should be 65)\n",rc); 71 v4l_err(i2c_client_s,"i2c i/o error: rc == %d (should be 65)\n",rc);
70 72
71 // Note: On READ the first byte is the current index 73 // Note: On READ the first byte is the current index
72 // (e.g. 0x80, what we just wrote) 74 // (e.g. 0x80, what we just wrote)
73 75
74 if(1) { 76 if(debug>1) {
75 int i; 77 int i;
76 printk("BT832 hexdump:\n"); 78 v4l_dbg(2,i2c_client_s,"hexdump:");
77 for(i=1;i<65;i++) { 79 for(i=1;i<65;i++) {
78 if(i!=1) { 80 if(i!=1) {
79 if(((i-1)%8)==0) printk(" "); 81 if(((i-1)%8)==0) printk(" ");
80 if(((i-1)%16)==0) printk("\n"); 82 if(((i-1)%16)==0) {
83 printk("\n");
84 v4l_dbg(2,i2c_client_s,"hexdump:");
85 }
81 } 86 }
82 printk(" %02x",buf[i]); 87 printk(" %02x",buf[i]);
83 } 88 }
@@ -96,56 +101,56 @@ int bt832_init(struct i2c_client *i2c_client_s)
96 bt832_hexdump(i2c_client_s,buf); 101 bt832_hexdump(i2c_client_s,buf);
97 102
98 if(buf[0x40] != 0x31) { 103 if(buf[0x40] != 0x31) {
99 printk("bt832: this i2c chip is no bt832 (id=%02x). Detaching.\n",buf[0x40]); 104 v4l_err(i2c_client_s,"This i2c chip is no bt832 (id=%02x). Detaching.\n",buf[0x40]);
100 kfree(buf); 105 kfree(buf);
101 return 0; 106 return 0;
102 } 107 }
103 108
104 printk("Write 0 tp VPSTATUS\n"); 109 v4l_err(i2c_client_s,"Write 0 tp VPSTATUS\n");
105 buf[0]=BT832_VP_STATUS; // Reg.52 110 buf[0]=BT832_VP_STATUS; // Reg.52
106 buf[1]= 0x00; 111 buf[1]= 0x00;
107 if (2 != (rc = i2c_master_send(i2c_client_s,buf,2))) 112 if (2 != (rc = i2c_master_send(i2c_client_s,buf,2)))
108 printk("bt832: i2c i/o error VPS: rc == %d (should be 2)\n",rc); 113 v4l_err(i2c_client_s,"i2c i/o error VPS: rc == %d (should be 2)\n",rc);
109 114
110 bt832_hexdump(i2c_client_s,buf); 115 bt832_hexdump(i2c_client_s,buf);
111 116
112 117
113 // Leave low power mode: 118 // Leave low power mode:
114 printk("Bt832: leave low power mode.\n"); 119 v4l_err(i2c_client_s,"leave low power mode.\n");
115 buf[0]=BT832_CAM_SETUP0; //0x39 57 120 buf[0]=BT832_CAM_SETUP0; //0x39 57
116 buf[1]=0x08; 121 buf[1]=0x08;
117 if (2 != (rc = i2c_master_send(i2c_client_s,buf,2))) 122 if (2 != (rc = i2c_master_send(i2c_client_s,buf,2)))
118 printk("bt832: i2c i/o error LLPM: rc == %d (should be 2)\n",rc); 123 v4l_err(i2c_client_s,"i2c i/o error LLPM: rc == %d (should be 2)\n",rc);
119 124
120 bt832_hexdump(i2c_client_s,buf); 125 bt832_hexdump(i2c_client_s,buf);
121 126
122 printk("Write 0 tp VPSTATUS\n"); 127 v4l_info(i2c_client_s,"Write 0 tp VPSTATUS\n");
123 buf[0]=BT832_VP_STATUS; // Reg.52 128 buf[0]=BT832_VP_STATUS; // Reg.52
124 buf[1]= 0x00; 129 buf[1]= 0x00;
125 if (2 != (rc = i2c_master_send(i2c_client_s,buf,2))) 130 if (2 != (rc = i2c_master_send(i2c_client_s,buf,2)))
126 printk("bt832: i2c i/o error VPS: rc == %d (should be 2)\n",rc); 131 v4l_err(i2c_client_s,"i2c i/o error VPS: rc == %d (should be 2)\n",rc);
127 132
128 bt832_hexdump(i2c_client_s,buf); 133 bt832_hexdump(i2c_client_s,buf);
129 134
130 135
131 // Enable Output 136 // Enable Output
132 printk("Enable Output\n"); 137 v4l_info(i2c_client_s,"Enable Output\n");
133 buf[0]=BT832_VP_CONTROL1; // Reg.40 138 buf[0]=BT832_VP_CONTROL1; // Reg.40
134 buf[1]= 0x27 & (~0x01); // Default | !skip 139 buf[1]= 0x27 & (~0x01); // Default | !skip
135 if (2 != (rc = i2c_master_send(i2c_client_s,buf,2))) 140 if (2 != (rc = i2c_master_send(i2c_client_s,buf,2)))
136 printk("bt832: i2c i/o error EO: rc == %d (should be 2)\n",rc); 141 v4l_err(i2c_client_s,"i2c i/o error EO: rc == %d (should be 2)\n",rc);
137 142
138 bt832_hexdump(i2c_client_s,buf); 143 bt832_hexdump(i2c_client_s,buf);
139 144
140 145
141 // for testing (even works when no camera attached) 146 // for testing (even works when no camera attached)
142 printk("bt832: *** Generate NTSC M Bars *****\n"); 147 v4l_info(i2c_client_s,"*** Generate NTSC M Bars *****\n");
143 buf[0]=BT832_VP_TESTCONTROL0; // Reg. 42 148 buf[0]=BT832_VP_TESTCONTROL0; // Reg. 42
144 buf[1]=3; // Generate NTSC System M bars, Generate Frame timing internally 149 buf[1]=3; // Generate NTSC System M bars, Generate Frame timing internally
145 if (2 != (rc = i2c_master_send(i2c_client_s,buf,2))) 150 if (2 != (rc = i2c_master_send(i2c_client_s,buf,2)))
146 printk("bt832: i2c i/o error MBAR: rc == %d (should be 2)\n",rc); 151 v4l_info(i2c_client_s,"i2c i/o error MBAR: rc == %d (should be 2)\n",rc);
147 152
148 printk("Bt832: Camera Present: %s\n", 153 v4l_info(i2c_client_s,"Camera Present: %s\n",
149 (buf[1+BT832_CAM_STATUS] & BT832_56_CAMERA_PRESENT) ? "yes":"no"); 154 (buf[1+BT832_CAM_STATUS] & BT832_56_CAMERA_PRESENT) ? "yes":"no");
150 155
151 bt832_hexdump(i2c_client_s,buf); 156 bt832_hexdump(i2c_client_s,buf);
@@ -159,13 +164,9 @@ static int bt832_attach(struct i2c_adapter *adap, int addr, int kind)
159{ 164{
160 struct bt832 *t; 165 struct bt832 *t;
161 166
162 printk("bt832_attach\n");
163
164 client_template.adapter = adap; 167 client_template.adapter = adap;
165 client_template.addr = addr; 168 client_template.addr = addr;
166 169
167 printk("bt832: chip found @ 0x%x\n", addr<<1);
168
169 if (NULL == (t = kmalloc(sizeof(*t), GFP_KERNEL))) 170 if (NULL == (t = kmalloc(sizeof(*t), GFP_KERNEL)))
170 return -ENOMEM; 171 return -ENOMEM;
171 memset(t,0,sizeof(*t)); 172 memset(t,0,sizeof(*t));
@@ -173,6 +174,9 @@ static int bt832_attach(struct i2c_adapter *adap, int addr, int kind)
173 i2c_set_clientdata(&t->client, t); 174 i2c_set_clientdata(&t->client, t);
174 i2c_attach_client(&t->client); 175 i2c_attach_client(&t->client);
175 176
177 v4l_info(&t->client,"chip found @ 0x%x\n", addr<<1);
178
179
176 if(! bt832_init(&t->client)) { 180 if(! bt832_init(&t->client)) {
177 bt832_detach(&t->client); 181 bt832_detach(&t->client);
178 return -1; 182 return -1;
@@ -192,7 +196,7 @@ static int bt832_detach(struct i2c_client *client)
192{ 196{
193 struct bt832 *t = i2c_get_clientdata(client); 197 struct bt832 *t = i2c_get_clientdata(client);
194 198
195 printk("bt832: detach.\n"); 199 v4l_info(&t->client,"dettach\n");
196 i2c_detach_client(client); 200 i2c_detach_client(client);
197 kfree(t); 201 kfree(t);
198 return 0; 202 return 0;
@@ -203,7 +207,8 @@ bt832_command(struct i2c_client *client, unsigned int cmd, void *arg)
203{ 207{
204 struct bt832 *t = i2c_get_clientdata(client); 208 struct bt832 *t = i2c_get_clientdata(client);
205 209
206 printk("bt832: command %x\n",cmd); 210 if (debug>1)
211 v4l_i2c_print_ioctl(&t->client,cmd);
207 212
208 switch (cmd) { 213 switch (cmd) {
209 case BT832_HEXDUMP: { 214 case BT832_HEXDUMP: {
@@ -214,7 +219,7 @@ bt832_command(struct i2c_client *client, unsigned int cmd, void *arg)
214 } 219 }
215 break; 220 break;
216 case BT832_REATTACH: 221 case BT832_REATTACH:
217 printk("bt832: re-attach\n"); 222 v4l_info(&t->client,"re-attach\n");
218 i2c_del_driver(&driver); 223 i2c_del_driver(&driver);
219 i2c_add_driver(&driver); 224 i2c_add_driver(&driver);
220 break; 225 break;
@@ -226,9 +231,9 @@ bt832_command(struct i2c_client *client, unsigned int cmd, void *arg)
226 231
227static struct i2c_driver driver = { 232static struct i2c_driver driver = {
228 .driver = { 233 .driver = {
229 .name = "i2c bt832 driver", 234 .name = "bt832",
230 }, 235 },
231 .id = -1, /* FIXME */ 236 .id = 0, /* FIXME */
232 .attach_adapter = bt832_probe, 237 .attach_adapter = bt832_probe,
233 .detach_client = bt832_detach, 238 .detach_client = bt832_detach,
234 .command = bt832_command, 239 .command = bt832_command,
diff --git a/drivers/media/video/tda7432.c b/drivers/media/video/tda7432.c
index 3bd7dfb8cc7c..c6efc9826ba5 100644
--- a/drivers/media/video/tda7432.c
+++ b/drivers/media/video/tda7432.c
@@ -50,6 +50,7 @@
50 50
51#include "bttv.h" 51#include "bttv.h"
52#include <media/audiochip.h> 52#include <media/audiochip.h>
53#include <media/v4l2-common.h>
53 54
54#ifndef VIDEO_AUDIO_BALANCE 55#ifndef VIDEO_AUDIO_BALANCE
55# define VIDEO_AUDIO_BALANCE 32 56# define VIDEO_AUDIO_BALANCE 32
@@ -90,9 +91,6 @@ struct tda7432 {
90static struct i2c_driver driver; 91static struct i2c_driver driver;
91static struct i2c_client client_template; 92static struct i2c_client client_template;
92 93
93#define dprintk if (debug) printk
94#define d2printk if (debug > 1) printk
95
96/* The TDA7432 is made by STS-Thompson 94/* The TDA7432 is made by STS-Thompson
97 * http://www.st.com 95 * http://www.st.com
98 * http://us.st.com/stonline/books/pdf/docs/4056.pdf 96 * http://us.st.com/stonline/books/pdf/docs/4056.pdf
@@ -229,12 +227,12 @@ static struct i2c_client client_template;
229static int tda7432_write(struct i2c_client *client, int subaddr, int val) 227static int tda7432_write(struct i2c_client *client, int subaddr, int val)
230{ 228{
231 unsigned char buffer[2]; 229 unsigned char buffer[2];
232 d2printk("tda7432: In tda7432_write\n"); 230 v4l_dbg(2,client,"In tda7432_write\n");
233 dprintk("tda7432: Writing %d 0x%x\n", subaddr, val); 231 v4l_dbg(1,client,"Writing %d 0x%x\n", subaddr, val);
234 buffer[0] = subaddr; 232 buffer[0] = subaddr;
235 buffer[1] = val; 233 buffer[1] = val;
236 if (2 != i2c_master_send(client,buffer,2)) { 234 if (2 != i2c_master_send(client,buffer,2)) {
237 printk(KERN_WARNING "tda7432: I/O error, trying (write %d 0x%x)\n", 235 v4l_err(client,"I/O error, trying (write %d 0x%x)\n",
238 subaddr, val); 236 subaddr, val);
239 return -1; 237 return -1;
240 } 238 }
@@ -247,9 +245,9 @@ static int tda7432_set(struct i2c_client *client)
247{ 245{
248 struct tda7432 *t = i2c_get_clientdata(client); 246 struct tda7432 *t = i2c_get_clientdata(client);
249 unsigned char buf[16]; 247 unsigned char buf[16];
250 d2printk("tda7432: In tda7432_set\n"); 248 v4l_dbg(2,client,"In tda7432_set\n");
251 249
252 dprintk(KERN_INFO 250 v4l_dbg(1,client,
253 "tda7432: 7432_set(0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x)\n", 251 "tda7432: 7432_set(0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x)\n",
254 t->input,t->volume,t->bass,t->treble,t->lf,t->lr,t->rf,t->rr,t->loud); 252 t->input,t->volume,t->bass,t->treble,t->lf,t->lr,t->rf,t->rr,t->loud);
255 buf[0] = TDA7432_IN; 253 buf[0] = TDA7432_IN;
@@ -263,7 +261,7 @@ static int tda7432_set(struct i2c_client *client)
263 buf[8] = t->rr; 261 buf[8] = t->rr;
264 buf[9] = t->loud; 262 buf[9] = t->loud;
265 if (10 != i2c_master_send(client,buf,10)) { 263 if (10 != i2c_master_send(client,buf,10)) {
266 printk(KERN_WARNING "tda7432: I/O error, trying tda7432_set\n"); 264 v4l_err(client,"I/O error, trying tda7432_set\n");
267 return -1; 265 return -1;
268 } 266 }
269 267
@@ -273,7 +271,7 @@ static int tda7432_set(struct i2c_client *client)
273static void do_tda7432_init(struct i2c_client *client) 271static void do_tda7432_init(struct i2c_client *client)
274{ 272{
275 struct tda7432 *t = i2c_get_clientdata(client); 273 struct tda7432 *t = i2c_get_clientdata(client);
276 d2printk("tda7432: In tda7432_init\n"); 274 v4l_dbg(2,client,"In tda7432_init\n");
277 275
278 t->input = TDA7432_STEREO_IN | /* Main (stereo) input */ 276 t->input = TDA7432_STEREO_IN | /* Main (stereo) input */
279 TDA7432_BASS_SYM | /* Symmetric bass cut */ 277 TDA7432_BASS_SYM | /* Symmetric bass cut */
@@ -301,7 +299,6 @@ static int tda7432_attach(struct i2c_adapter *adap, int addr, int kind)
301{ 299{
302 struct tda7432 *t; 300 struct tda7432 *t;
303 struct i2c_client *client; 301 struct i2c_client *client;
304 d2printk("tda7432: In tda7432_attach\n");
305 302
306 t = kmalloc(sizeof *t,GFP_KERNEL); 303 t = kmalloc(sizeof *t,GFP_KERNEL);
307 if (!t) 304 if (!t)
@@ -315,9 +312,9 @@ static int tda7432_attach(struct i2c_adapter *adap, int addr, int kind)
315 i2c_set_clientdata(client, t); 312 i2c_set_clientdata(client, t);
316 313
317 do_tda7432_init(client); 314 do_tda7432_init(client);
318 printk(KERN_INFO "tda7432: init\n");
319
320 i2c_attach_client(client); 315 i2c_attach_client(client);
316
317 v4l_info(client, "chip found @ 0x%x (%s)\n", addr << 1, adap->name);
321 return 0; 318 return 0;
322} 319}
323 320
@@ -343,7 +340,9 @@ static int tda7432_command(struct i2c_client *client,
343 unsigned int cmd, void *arg) 340 unsigned int cmd, void *arg)
344{ 341{
345 struct tda7432 *t = i2c_get_clientdata(client); 342 struct tda7432 *t = i2c_get_clientdata(client);
346 d2printk("tda7432: In tda7432_command\n"); 343 v4l_dbg(2,client,"In tda7432_command\n");
344 if (debug>1)
345 v4l_i2c_print_ioctl(client,cmd);
347 346
348 switch (cmd) { 347 switch (cmd) {
349 /* --- v4l ioctls --- */ 348 /* --- v4l ioctls --- */
@@ -354,7 +353,6 @@ static int tda7432_command(struct i2c_client *client,
354 case VIDIOCGAUDIO: 353 case VIDIOCGAUDIO:
355 { 354 {
356 struct video_audio *va = arg; 355 struct video_audio *va = arg;
357 dprintk("tda7432: VIDIOCGAUDIO\n");
358 356
359 va->flags |= VIDEO_AUDIO_VOLUME | 357 va->flags |= VIDEO_AUDIO_VOLUME |
360 VIDEO_AUDIO_BASS | 358 VIDEO_AUDIO_BASS |
@@ -409,7 +407,6 @@ static int tda7432_command(struct i2c_client *client,
409 case VIDIOCSAUDIO: 407 case VIDIOCSAUDIO:
410 { 408 {
411 struct video_audio *va = arg; 409 struct video_audio *va = arg;
412 dprintk("tda7432: VIDEOCSAUDIO\n");
413 410
414 if(va->flags & VIDEO_AUDIO_VOLUME){ 411 if(va->flags & VIDEO_AUDIO_VOLUME){
415 if(!maxvol){ /* max +20db */ 412 if(!maxvol){ /* max +20db */
@@ -485,11 +482,6 @@ static int tda7432_command(struct i2c_client *client,
485 482
486 } /* end of VIDEOCSAUDIO case */ 483 } /* end of VIDEOCSAUDIO case */
487 484
488 default: /* Not VIDEOCGAUDIO or VIDEOCSAUDIO */
489
490 /* nothing */
491 d2printk("tda7432: Default\n");
492
493 } /* end of (cmd) switch */ 485 } /* end of (cmd) switch */
494 486
495 return 0; 487 return 0;
@@ -514,7 +506,7 @@ static struct i2c_client client_template =
514static int __init tda7432_init(void) 506static int __init tda7432_init(void)
515{ 507{
516 if ( (loudness < 0) || (loudness > 15) ) { 508 if ( (loudness < 0) || (loudness > 15) ) {
517 printk(KERN_ERR "tda7432: loudness parameter must be between 0 and 15\n"); 509 printk(KERN_ERR "loudness parameter must be between 0 and 15\n");
518 return -EINVAL; 510 return -EINVAL;
519 } 511 }
520 512