aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/saa5249.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/saa5249.c')
-rw-r--r--drivers/media/video/saa5249.c112
1 files changed, 56 insertions, 56 deletions
diff --git a/drivers/media/video/saa5249.c b/drivers/media/video/saa5249.c
index a9f3cf0b1e3c..531e9461cb66 100644
--- a/drivers/media/video/saa5249.c
+++ b/drivers/media/video/saa5249.c
@@ -71,7 +71,7 @@
71#define NUM_BUFS 8 71#define NUM_BUFS 8
72#define IF_NAME "SAA5249" 72#define IF_NAME "SAA5249"
73 73
74static const int disp_modes[8][3] = 74static const int disp_modes[8][3] =
75{ 75{
76 { 0x46, 0x03, 0x03 }, /* DISPOFF */ 76 { 0x46, 0x03, 0x03 }, /* DISPOFF */
77 { 0x46, 0xcc, 0xcc }, /* DISPNORM */ 77 { 0x46, 0xcc, 0xcc }, /* DISPNORM */
@@ -150,8 +150,8 @@ static int saa5249_attach(struct i2c_adapter *adap, int addr, int kind)
150 client=kmalloc(sizeof(*client), GFP_KERNEL); 150 client=kmalloc(sizeof(*client), GFP_KERNEL);
151 if(client==NULL) 151 if(client==NULL)
152 return -ENOMEM; 152 return -ENOMEM;
153 client_template.adapter = adap; 153 client_template.adapter = adap;
154 client_template.addr = addr; 154 client_template.addr = addr;
155 memcpy(client, &client_template, sizeof(*client)); 155 memcpy(client, &client_template, sizeof(*client));
156 t = kzalloc(sizeof(*t), GFP_KERNEL); 156 t = kzalloc(sizeof(*t), GFP_KERNEL);
157 if(t==NULL) 157 if(t==NULL)
@@ -161,11 +161,11 @@ static int saa5249_attach(struct i2c_adapter *adap, int addr, int kind)
161 } 161 }
162 strlcpy(client->name, IF_NAME, I2C_NAME_SIZE); 162 strlcpy(client->name, IF_NAME, I2C_NAME_SIZE);
163 mutex_init(&t->lock); 163 mutex_init(&t->lock);
164 164
165 /* 165 /*
166 * Now create a video4linux device 166 * Now create a video4linux device
167 */ 167 */
168 168
169 vd = kmalloc(sizeof(struct video_device), GFP_KERNEL); 169 vd = kmalloc(sizeof(struct video_device), GFP_KERNEL);
170 if(vd==NULL) 170 if(vd==NULL)
171 { 171 {
@@ -175,8 +175,8 @@ static int saa5249_attach(struct i2c_adapter *adap, int addr, int kind)
175 } 175 }
176 i2c_set_clientdata(client, vd); 176 i2c_set_clientdata(client, vd);
177 memcpy(vd, &saa_template, sizeof(*vd)); 177 memcpy(vd, &saa_template, sizeof(*vd));
178 178
179 for (pgbuf = 0; pgbuf < NUM_DAUS; pgbuf++) 179 for (pgbuf = 0; pgbuf < NUM_DAUS; pgbuf++)
180 { 180 {
181 memset(t->vdau[pgbuf].pgbuf, ' ', sizeof(t->vdau[0].pgbuf)); 181 memset(t->vdau[pgbuf].pgbuf, ' ', sizeof(t->vdau[0].pgbuf));
182 memset(t->vdau[pgbuf].sregs, 0, sizeof(t->vdau[0].sregs)); 182 memset(t->vdau[pgbuf].sregs, 0, sizeof(t->vdau[0].sregs));
@@ -186,9 +186,9 @@ static int saa5249_attach(struct i2c_adapter *adap, int addr, int kind)
186 t->vdau[pgbuf].stopped = TRUE; 186 t->vdau[pgbuf].stopped = TRUE;
187 t->is_searching[pgbuf] = FALSE; 187 t->is_searching[pgbuf] = FALSE;
188 } 188 }
189 vd->priv=t; 189 vd->priv=t;
190 190
191 191
192 /* 192 /*
193 * Register it 193 * Register it
194 */ 194 */
@@ -208,7 +208,7 @@ static int saa5249_attach(struct i2c_adapter *adap, int addr, int kind)
208/* 208/*
209 * We do most of the hard work when we become a device on the i2c. 209 * We do most of the hard work when we become a device on the i2c.
210 */ 210 */
211 211
212static int saa5249_probe(struct i2c_adapter *adap) 212static int saa5249_probe(struct i2c_adapter *adap)
213{ 213{
214 if (adap->class & I2C_CLASS_TV_ANALOG) 214 if (adap->class & I2C_CLASS_TV_ANALOG)
@@ -229,7 +229,7 @@ static int saa5249_detach(struct i2c_client *client)
229 229
230/* new I2C driver support */ 230/* new I2C driver support */
231 231
232static struct i2c_driver i2c_driver_videotext = 232static struct i2c_driver i2c_driver_videotext =
233{ 233{
234 .driver = { 234 .driver = {
235 .name = IF_NAME, /* name */ 235 .name = IF_NAME, /* name */
@@ -249,7 +249,7 @@ static struct i2c_client client_template = {
249 * delay may be longer. 249 * delay may be longer.
250 */ 250 */
251 251
252static void jdelay(unsigned long delay) 252static void jdelay(unsigned long delay)
253{ 253{
254 sigset_t oldblocked = current->blocked; 254 sigset_t oldblocked = current->blocked;
255 255
@@ -269,14 +269,14 @@ static void jdelay(unsigned long delay)
269/* 269/*
270 * I2C interfaces 270 * I2C interfaces
271 */ 271 */
272 272
273static int i2c_sendbuf(struct saa5249_device *t, int reg, int count, u8 *data) 273static int i2c_sendbuf(struct saa5249_device *t, int reg, int count, u8 *data)
274{ 274{
275 char buf[64]; 275 char buf[64];
276 276
277 buf[0] = reg; 277 buf[0] = reg;
278 memcpy(buf+1, data, count); 278 memcpy(buf+1, data, count);
279 279
280 if(i2c_master_send(t->client, buf, count+1)==count+1) 280 if(i2c_master_send(t->client, buf, count+1)==count+1)
281 return 0; 281 return 0;
282 return -1; 282 return -1;
@@ -289,7 +289,7 @@ static int i2c_senddata(struct saa5249_device *t, ...)
289 int ct=0; 289 int ct=0;
290 va_list argp; 290 va_list argp;
291 va_start(argp,t); 291 va_start(argp,t);
292 292
293 while((v=va_arg(argp,int))!=-1) 293 while((v=va_arg(argp,int))!=-1)
294 buf[ct++]=v; 294 buf[ct++]=v;
295 return i2c_sendbuf(t, buf[0], ct-1, buf+1); 295 return i2c_sendbuf(t, buf[0], ct-1, buf+1);
@@ -301,7 +301,7 @@ static int i2c_senddata(struct saa5249_device *t, ...)
301 * Returns -1 if I²C-device didn't send acknowledge, 0 otherwise 301 * Returns -1 if I²C-device didn't send acknowledge, 0 otherwise
302 */ 302 */
303 303
304static int i2c_getdata(struct saa5249_device *t, int count, u8 *buf) 304static int i2c_getdata(struct saa5249_device *t, int count, u8 *buf)
305{ 305{
306 if(i2c_master_recv(t->client, buf, count)!=count) 306 if(i2c_master_recv(t->client, buf, count)!=count)
307 return -1; 307 return -1;
@@ -320,9 +320,9 @@ static int do_saa5249_ioctl(struct inode *inode, struct file *file,
320 struct video_device *vd = video_devdata(file); 320 struct video_device *vd = video_devdata(file);
321 struct saa5249_device *t=vd->priv; 321 struct saa5249_device *t=vd->priv;
322 322
323 switch(cmd) 323 switch(cmd)
324 { 324 {
325 case VTXIOCGETINFO: 325 case VTXIOCGETINFO:
326 { 326 {
327 vtx_info_t *info = arg; 327 vtx_info_t *info = arg;
328 info->version_major = VTX_VER_MAJ; 328 info->version_major = VTX_VER_MAJ;
@@ -332,10 +332,10 @@ static int do_saa5249_ioctl(struct inode *inode, struct file *file,
332 return 0; 332 return 0;
333 } 333 }
334 334
335 case VTXIOCCLRPAGE: 335 case VTXIOCCLRPAGE:
336 { 336 {
337 vtx_pagereq_t *req = arg; 337 vtx_pagereq_t *req = arg;
338 338
339 if (req->pgbuf < 0 || req->pgbuf >= NUM_DAUS) 339 if (req->pgbuf < 0 || req->pgbuf >= NUM_DAUS)
340 return -EINVAL; 340 return -EINVAL;
341 memset(t->vdau[req->pgbuf].pgbuf, ' ', sizeof(t->vdau[0].pgbuf)); 341 memset(t->vdau[req->pgbuf].pgbuf, ' ', sizeof(t->vdau[0].pgbuf));
@@ -343,17 +343,17 @@ static int do_saa5249_ioctl(struct inode *inode, struct file *file,
343 return 0; 343 return 0;
344 } 344 }
345 345
346 case VTXIOCCLRFOUND: 346 case VTXIOCCLRFOUND:
347 { 347 {
348 vtx_pagereq_t *req = arg; 348 vtx_pagereq_t *req = arg;
349 349
350 if (req->pgbuf < 0 || req->pgbuf >= NUM_DAUS) 350 if (req->pgbuf < 0 || req->pgbuf >= NUM_DAUS)
351 return -EINVAL; 351 return -EINVAL;
352 t->vdau[req->pgbuf].clrfound = TRUE; 352 t->vdau[req->pgbuf].clrfound = TRUE;
353 return 0; 353 return 0;
354 } 354 }
355 355
356 case VTXIOCPAGEREQ: 356 case VTXIOCPAGEREQ:
357 { 357 {
358 vtx_pagereq_t *req = arg; 358 vtx_pagereq_t *req = arg;
359 if (!(req->pagemask & PGMASK_PAGE)) 359 if (!(req->pagemask & PGMASK_PAGE))
@@ -381,7 +381,7 @@ static int do_saa5249_ioctl(struct inode *inode, struct file *file,
381 return 0; 381 return 0;
382 } 382 }
383 383
384 case VTXIOCGETSTAT: 384 case VTXIOCGETSTAT:
385 { 385 {
386 vtx_pagereq_t *req = arg; 386 vtx_pagereq_t *req = arg;
387 u8 infobits[10]; 387 u8 infobits[10];
@@ -390,7 +390,7 @@ static int do_saa5249_ioctl(struct inode *inode, struct file *file,
390 390
391 if (req->pgbuf < 0 || req->pgbuf >= NUM_DAUS) 391 if (req->pgbuf < 0 || req->pgbuf >= NUM_DAUS)
392 return -EINVAL; 392 return -EINVAL;
393 if (!t->vdau[req->pgbuf].stopped) 393 if (!t->vdau[req->pgbuf].stopped)
394 { 394 {
395 if (i2c_senddata(t, 2, 0, -1) || 395 if (i2c_senddata(t, 2, 0, -1) ||
396 i2c_sendbuf(t, 3, sizeof(t->vdau[0].sregs), t->vdau[req->pgbuf].sregs) || 396 i2c_sendbuf(t, 3, sizeof(t->vdau[0].sregs), t->vdau[req->pgbuf].sregs) ||
@@ -403,7 +403,7 @@ static int do_saa5249_ioctl(struct inode *inode, struct file *file,
403 return -EIO; 403 return -EIO;
404 404
405 if (!(infobits[8] & 0x10) && !(infobits[7] & 0xf0) && /* check FOUND-bit */ 405 if (!(infobits[8] & 0x10) && !(infobits[7] & 0xf0) && /* check FOUND-bit */
406 (memcmp(infobits, t->vdau[req->pgbuf].laststat, sizeof(infobits)) || 406 (memcmp(infobits, t->vdau[req->pgbuf].laststat, sizeof(infobits)) ||
407 time_after_eq(jiffies, t->vdau[req->pgbuf].expire))) 407 time_after_eq(jiffies, t->vdau[req->pgbuf].expire)))
408 { /* check if new page arrived */ 408 { /* check if new page arrived */
409 if (i2c_senddata(t, 8, 0, 0, 0, -1) || 409 if (i2c_senddata(t, 8, 0, 0, 0, -1) ||
@@ -411,7 +411,7 @@ static int do_saa5249_ioctl(struct inode *inode, struct file *file,
411 return -EIO; 411 return -EIO;
412 t->vdau[req->pgbuf].expire = jiffies + PGBUF_EXPIRE; 412 t->vdau[req->pgbuf].expire = jiffies + PGBUF_EXPIRE;
413 memset(t->vdau[req->pgbuf].pgbuf + VTX_PAGESIZE, ' ', VTX_VIRTUALSIZE - VTX_PAGESIZE); 413 memset(t->vdau[req->pgbuf].pgbuf + VTX_PAGESIZE, ' ', VTX_VIRTUALSIZE - VTX_PAGESIZE);
414 if (t->virtual_mode) 414 if (t->virtual_mode)
415 { 415 {
416 /* Packet X/24 */ 416 /* Packet X/24 */
417 if (i2c_senddata(t, 8, 0, 0x20, 0, -1) || 417 if (i2c_senddata(t, 8, 0, 0x20, 0, -1) ||
@@ -459,9 +459,9 @@ static int do_saa5249_ioctl(struct inode *inode, struct file *file,
459 info.notfound = !!(infobits[8] & 0x10); 459 info.notfound = !!(infobits[8] & 0x10);
460 info.pblf = !!(infobits[9] & 0x20); 460 info.pblf = !!(infobits[9] & 0x20);
461 info.hamming = 0; 461 info.hamming = 0;
462 for (a = 0; a <= 7; a++) 462 for (a = 0; a <= 7; a++)
463 { 463 {
464 if (infobits[a] & 0xf0) 464 if (infobits[a] & 0xf0)
465 { 465 {
466 info.hamming = 1; 466 info.hamming = 1;
467 break; 467 break;
@@ -471,14 +471,14 @@ static int do_saa5249_ioctl(struct inode *inode, struct file *file,
471 info.notfound = 1; 471 info.notfound = 1;
472 if(copy_to_user(req->buffer, &info, sizeof(vtx_pageinfo_t))) 472 if(copy_to_user(req->buffer, &info, sizeof(vtx_pageinfo_t)))
473 return -EFAULT; 473 return -EFAULT;
474 if (!info.hamming && !info.notfound) 474 if (!info.hamming && !info.notfound)
475 { 475 {
476 t->is_searching[req->pgbuf] = FALSE; 476 t->is_searching[req->pgbuf] = FALSE;
477 } 477 }
478 return 0; 478 return 0;
479 } 479 }
480 480
481 case VTXIOCGETPAGE: 481 case VTXIOCGETPAGE:
482 { 482 {
483 vtx_pagereq_t *req = arg; 483 vtx_pagereq_t *req = arg;
484 int start, end; 484 int start, end;
@@ -488,15 +488,15 @@ static int do_saa5249_ioctl(struct inode *inode, struct file *file,
488 return -EINVAL; 488 return -EINVAL;
489 if(copy_to_user(req->buffer, &t->vdau[req->pgbuf].pgbuf[req->start], req->end - req->start + 1)) 489 if(copy_to_user(req->buffer, &t->vdau[req->pgbuf].pgbuf[req->start], req->end - req->start + 1))
490 return -EFAULT; 490 return -EFAULT;
491 491
492 /* 492 /*
493 * Always read the time directly from SAA5249 493 * Always read the time directly from SAA5249
494 */ 494 */
495 495
496 if (req->start <= 39 && req->end >= 32) 496 if (req->start <= 39 && req->end >= 32)
497 { 497 {
498 int len; 498 int len;
499 char buf[16]; 499 char buf[16];
500 start = max(req->start, 32); 500 start = max(req->start, 32);
501 end = min(req->end, 39); 501 end = min(req->end, 39);
502 len=end-start+1; 502 len=end-start+1;
@@ -507,7 +507,7 @@ static int do_saa5249_ioctl(struct inode *inode, struct file *file,
507 return -EFAULT; 507 return -EFAULT;
508 } 508 }
509 /* Insert the current header if DAU is still searching for a page */ 509 /* Insert the current header if DAU is still searching for a page */
510 if (req->start <= 31 && req->end >= 7 && t->is_searching[req->pgbuf]) 510 if (req->start <= 31 && req->end >= 7 && t->is_searching[req->pgbuf])
511 { 511 {
512 char buf[32]; 512 char buf[32];
513 int len; 513 int len;
@@ -523,7 +523,7 @@ static int do_saa5249_ioctl(struct inode *inode, struct file *file,
523 return 0; 523 return 0;
524 } 524 }
525 525
526 case VTXIOCSTOPDAU: 526 case VTXIOCSTOPDAU:
527 { 527 {
528 vtx_pagereq_t *req = arg; 528 vtx_pagereq_t *req = arg;
529 529
@@ -534,12 +534,12 @@ static int do_saa5249_ioctl(struct inode *inode, struct file *file,
534 return 0; 534 return 0;
535 } 535 }
536 536
537 case VTXIOCPUTPAGE: 537 case VTXIOCPUTPAGE:
538 case VTXIOCSETDISP: 538 case VTXIOCSETDISP:
539 case VTXIOCPUTSTAT: 539 case VTXIOCPUTSTAT:
540 return 0; 540 return 0;
541 541
542 case VTXIOCCLRCACHE: 542 case VTXIOCCLRCACHE:
543 { 543 {
544 if (i2c_senddata(t, 0, NUM_DAUS, 0, 8, -1) || i2c_senddata(t, 11, 544 if (i2c_senddata(t, 0, NUM_DAUS, 0, 8, -1) || i2c_senddata(t, 11,
545 ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ', 545 ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',
@@ -551,7 +551,7 @@ static int do_saa5249_ioctl(struct inode *inode, struct file *file,
551 return 0; 551 return 0;
552 } 552 }
553 553
554 case VTXIOCSETVIRT: 554 case VTXIOCSETVIRT:
555 { 555 {
556 /* The SAA5249 has virtual-row reception turned on always */ 556 /* The SAA5249 has virtual-row reception turned on always */
557 t->virtual_mode = (int)(long)arg; 557 t->virtual_mode = (int)(long)arg;
@@ -612,14 +612,14 @@ static inline unsigned int vtx_fix_command(unsigned int cmd)
612/* 612/*
613 * Handle the locking 613 * Handle the locking
614 */ 614 */
615 615
616static int saa5249_ioctl(struct inode *inode, struct file *file, 616static int saa5249_ioctl(struct inode *inode, struct file *file,
617 unsigned int cmd, unsigned long arg) 617 unsigned int cmd, unsigned long arg)
618{ 618{
619 struct video_device *vd = video_devdata(file); 619 struct video_device *vd = video_devdata(file);
620 struct saa5249_device *t=vd->priv; 620 struct saa5249_device *t=vd->priv;
621 int err; 621 int err;
622 622
623 cmd = vtx_fix_command(cmd); 623 cmd = vtx_fix_command(cmd);
624 mutex_lock(&t->lock); 624 mutex_lock(&t->lock);
625 err = video_usercopy(inode,file,cmd,arg,do_saa5249_ioctl); 625 err = video_usercopy(inode,file,cmd,arg,do_saa5249_ioctl);
@@ -627,7 +627,7 @@ static int saa5249_ioctl(struct inode *inode, struct file *file,
627 return err; 627 return err;
628} 628}
629 629
630static int saa5249_open(struct inode *inode, struct file *file) 630static int saa5249_open(struct inode *inode, struct file *file)
631{ 631{
632 struct video_device *vd = video_devdata(file); 632 struct video_device *vd = video_devdata(file);
633 struct saa5249_device *t=vd->priv; 633 struct saa5249_device *t=vd->priv;
@@ -636,7 +636,7 @@ static int saa5249_open(struct inode *inode, struct file *file)
636 err = video_exclusive_open(inode,file); 636 err = video_exclusive_open(inode,file);
637 if (err < 0) 637 if (err < 0)
638 return err; 638 return err;
639 639
640 if (t->client==NULL) { 640 if (t->client==NULL) {
641 err = -ENODEV; 641 err = -ENODEV;
642 goto fail; 642 goto fail;
@@ -647,13 +647,13 @@ static int saa5249_open(struct inode *inode, struct file *file)
647 i2c_senddata(t, 1, disp_modes[t->disp_mode][0], 0, -1) || 647 i2c_senddata(t, 1, disp_modes[t->disp_mode][0], 0, -1) ||
648 /* Display TV-picture, no virtual rows */ 648 /* Display TV-picture, no virtual rows */
649 i2c_senddata(t, 4, NUM_DAUS, disp_modes[t->disp_mode][1], disp_modes[t->disp_mode][2], 7, -1)) /* Set display to page 4 */ 649 i2c_senddata(t, 4, NUM_DAUS, disp_modes[t->disp_mode][1], disp_modes[t->disp_mode][2], 7, -1)) /* Set display to page 4 */
650 650
651 { 651 {
652 err = -EIO; 652 err = -EIO;
653 goto fail; 653 goto fail;
654 } 654 }
655 655
656 for (pgbuf = 0; pgbuf < NUM_DAUS; pgbuf++) 656 for (pgbuf = 0; pgbuf < NUM_DAUS; pgbuf++)
657 { 657 {
658 memset(t->vdau[pgbuf].pgbuf, ' ', sizeof(t->vdau[0].pgbuf)); 658 memset(t->vdau[pgbuf].pgbuf, ' ', sizeof(t->vdau[0].pgbuf));
659 memset(t->vdau[pgbuf].sregs, 0, sizeof(t->vdau[0].sregs)); 659 memset(t->vdau[pgbuf].sregs, 0, sizeof(t->vdau[0].sregs));
@@ -673,7 +673,7 @@ static int saa5249_open(struct inode *inode, struct file *file)
673 673
674 674
675 675
676static int saa5249_release(struct inode *inode, struct file *file) 676static int saa5249_release(struct inode *inode, struct file *file)
677{ 677{
678 struct video_device *vd = video_devdata(file); 678 struct video_device *vd = video_devdata(file);
679 struct saa5249_device *t=vd->priv; 679 struct saa5249_device *t=vd->priv;
@@ -690,7 +690,7 @@ static int __init init_saa_5249 (void)
690 return i2c_add_driver(&i2c_driver_videotext); 690 return i2c_add_driver(&i2c_driver_videotext);
691} 691}
692 692
693static void __exit cleanup_saa_5249 (void) 693static void __exit cleanup_saa_5249 (void)
694{ 694{
695 i2c_del_driver(&i2c_driver_videotext); 695 i2c_del_driver(&i2c_driver_videotext);
696} 696}