aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/tvp5150.c
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@infradead.org>2006-01-23 14:11:05 -0500
committerMauro Carvalho Chehab <mchehab@brturbo.com.br>2006-01-23 14:11:05 -0500
commit6ac48b458769059ee6147dd8bf2767e820407292 (patch)
tree1c83bdbbd5b3b8751b922d732d1d8d40c4c47a09 /drivers/media/video/tvp5150.c
parent3ad96835cedec7704b1b5a211b39262bb794adaf (diff)
V4L/DVB (3408): Included new sliced VBI types to videodev2.h and tvp5150
- Added other sliced VBI types to videodev2.h - tvp5150 now uses standard V4L2 API codes from videodev2.h - Implemented VIDIOC_G_SLICED_VBI_CAP for tvp5150. This is dynamically filled based on defined VDP C-RAM values filled by the driver. Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/tvp5150.c')
-rw-r--r--drivers/media/video/tvp5150.c161
1 files changed, 104 insertions, 57 deletions
diff --git a/drivers/media/video/tvp5150.c b/drivers/media/video/tvp5150.c
index f7fa93c64d11..17a8dd726912 100644
--- a/drivers/media/video/tvp5150.c
+++ b/drivers/media/video/tvp5150.c
@@ -1,8 +1,8 @@
1/* 1/*
2 * tvp5150 - Texas Instruments TVP5150A(M) video decoder driver 2 * tvp5150 - Texas Instruments TVP5150A/AM1 video decoder driver
3 * 3 *
4 * Copyright (c) 2005 Mauro Carvalho Chehab (mchehab@brturbo.com.br) 4 * Copyright (c) 2005,2006 Mauro Carvalho Chehab (mchehab@infradead.org)
5 * This code is placed under the terms of the GNU General Public License 5 * This code is placed under the terms of the GNU General Public License v2
6 */ 6 */
7 7
8#include <linux/i2c.h> 8#include <linux/i2c.h>
@@ -13,10 +13,11 @@
13 13
14#include "tvp5150_reg.h" 14#include "tvp5150_reg.h"
15 15
16MODULE_DESCRIPTION("Texas Instruments TVP5150A video decoder driver"); /* standard i2c insmod options */ 16MODULE_DESCRIPTION("Texas Instruments TVP5150A video decoder driver");
17MODULE_AUTHOR("Mauro Carvalho Chehab"); 17MODULE_AUTHOR("Mauro Carvalho Chehab");
18MODULE_LICENSE("GPL"); 18MODULE_LICENSE("GPL");
19 19
20/* standard i2c insmod options */
20static unsigned short normal_i2c[] = { 21static unsigned short normal_i2c[] = {
21 0xb8 >> 1, 22 0xb8 >> 1,
22 0xba >> 1, 23 0xba >> 1,
@@ -477,82 +478,101 @@ static const struct i2c_reg_value tvp5150_init_enable[] = {
477 } 478 }
478}; 479};
479 480
481struct tvp5150_vbi_type {
482 unsigned int vbi_type;
483 unsigned int ini_line;
484 unsigned int end_line;
485 unsigned int by_field :1;
486};
487
480struct i2c_vbi_ram_value { 488struct i2c_vbi_ram_value {
481 u16 reg; 489 u16 reg;
482 unsigned char values[26]; 490 struct tvp5150_vbi_type type;
491 unsigned char values[16];
483}; 492};
484 493
485/* tvp5150_vbi_types should follow the same order as vbi_ram_default 494/* This struct have the values for each supported VBI Standard
495 * by
496 tvp5150_vbi_types should follow the same order as vbi_ram_default
486 * value 0 means rom position 0x10, value 1 means rom position 0x30 497 * value 0 means rom position 0x10, value 1 means rom position 0x30
487 * and so on. There are 16 possible locations from 0 to 15. 498 * and so on. There are 16 possible locations from 0 to 15.
488 */ 499 */
489enum tvp5150_vbi_types { /* Video line number Description */
490 VBI_WST_SECAM, /* 6-23 (field 1,2) Teletext, SECAM */
491 VBI_WST_PAL_B, /* 6-22 (field 1,2) Teletext, PAL, System B */
492 VBI_WST_PAL_C, /* 6-22 (field 1,2) Teletext, PAL, System C */
493 VBI_WST_NTSC_B, /* 10-21 (field 1,2) Teletext, NTSC, System B */
494 VBI_NABTS_NTSC_C, /* 10-21 (field 1,2) Teletext, NTSC, System C */
495 VBI_NABTS_NTSC_D, /* 10-21 (field 1,2) Teletext, NTSC, System D */
496 VBI_CC_PAL_SECAM, /* 22 (field 1,2) Closed Caption PAL/SECAM */
497 VBI_CC_NTSC, /* 21 (field 1,2) Closed Caption NTSC */
498 VBI_WSS_PAL_SECAM, /* 23 (field 1,2) Wide Screen Signal PAL/SECAM */
499 VBI_WSS_NTSC, /* 20 (field 1,2) Wide Screen Signal NTSC */
500 VBI_VITC_PAL_SECAM, /* 6-22 Vertical Interval Timecode PAL/SECAM */
501 VBI_VITC_NTSC, /* 10-20 Vertical Interval Timecode NTSC */
502 VBI_VPS_PAL, /* 16 Video Program System PAL */
503 VBI_EPG_GEMSTAR, /* EPG/Gemstar Electronic program guide */
504 VBI_RESERVED, /* not in use on vbi_ram_default table */
505 VBI_FULL_FIELD /* Active video/Full Field */
506};
507 500
508static struct i2c_vbi_ram_value vbi_ram_default[] = 501static struct i2c_vbi_ram_value vbi_ram_default[] =
509{ 502{
510 {0x010, /* WST SECAM */ 503 {0x010, /* Teletext, SECAM, WST System A */
511 { 0xaa, 0xaa, 0xff, 0xff , 0xe7, 0x2e, 0x20, 0x26, 0xe6, 0xb4, 0x0e, 0x0, 0x0, 0x0, 0x10, 0x0 } 504 {V4L2_SLICED_TELETEXT_SECAM,6,23,1},
505 { 0xaa, 0xaa, 0xff, 0xff, 0xe7, 0x2e, 0x20, 0x26,
506 0xe6, 0xb4, 0x0e, 0x00, 0x00, 0x00, 0x10, 0x00 }
512 }, 507 },
513 {0x030, /* WST PAL B */ 508 {0x030, /* Teletext, PAL, WST System B */
514 { 0xaa, 0xaa, 0xff, 0xff , 0x27, 0x2e, 0x20, 0x2b, 0xa6, 0x72, 0x10, 0x0, 0x0, 0x0, 0x10, 0x0 } 509 {V4L2_SLICED_TELETEXT_PAL_B,6,22,1},
510 { 0xaa, 0xaa, 0xff, 0xff, 0x27, 0x2e, 0x20, 0x2b,
511 0xa6, 0x72, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00 }
515 }, 512 },
516 {0x050, /* WST PAL C */ 513 {0x050, /* Teletext, PAL, WST System C */
517 { 0xaa, 0xaa, 0xff, 0xff , 0xe7, 0x2e, 0x20, 0x22, 0xa6, 0x98, 0x0d, 0x0, 0x0, 0x0, 0x10, 0x0 } 514 {V4L2_SLICED_TELETEXT_PAL_C,6,22,1},
515 { 0xaa, 0xaa, 0xff, 0xff, 0xe7, 0x2e, 0x20, 0x22,
516 0xa6, 0x98, 0x0d, 0x00, 0x00, 0x00, 0x10, 0x00 }
518 }, 517 },
519 {0x070, /* WST NTSC B */ 518 {0x070, /* Teletext, NTSC, WST System B */
520 { 0xaa, 0xaa, 0xff, 0xff , 0x27, 0x2e, 0x20, 0x23, 0x69, 0x93, 0x0d, 0x0, 0x0, 0x0, 0x10, 0x0 } 519 {V4L2_SLICED_TELETEXT_NTSC_B,10,21,1},
520 { 0xaa, 0xaa, 0xff, 0xff, 0x27, 0x2e, 0x20, 0x23,
521 0x69, 0x93, 0x0d, 0x00, 0x00, 0x00, 0x10, 0x00 }
521 }, 522 },
522 {0x090, /* NABTS, NTSC */ 523 {0x090, /* Tetetext, NTSC NABTS System C */
523 { 0xaa, 0xaa, 0xff, 0xff , 0xe7, 0x2e, 0x20, 0x22, 0x69, 0x93, 0x0d, 0x0, 0x0, 0x0, 0x15, 0x0 } 524 {V4L2_SLICED_TELETEXT_NTSC_C,10,21,1},
525 { 0xaa, 0xaa, 0xff, 0xff, 0xe7, 0x2e, 0x20, 0x22,
526 0x69, 0x93, 0x0d, 0x00, 0x00, 0x00, 0x15, 0x00 }
524 }, 527 },
525 {0x0b0, /* NABTS, NTSC-J */ 528 {0x0b0, /* Teletext, NTSC-J, NABTS System D */
526 { 0xaa, 0xaa, 0xff, 0xff , 0xa7, 0x2e, 0x20, 0x23, 0x69, 0x93, 0x0d, 0x0, 0x0, 0x0, 0x10, 0x0 } 529 {V4L2_SLICED_TELETEXT_NTSC_D,10,21,1},
530 { 0xaa, 0xaa, 0xff, 0xff, 0xa7, 0x2e, 0x20, 0x23,
531 0x69, 0x93, 0x0d, 0x00, 0x00, 0x00, 0x10, 0x00 }
527 }, 532 },
528 {0x0d0, /* CC, PAL/SECAM */ 533 {0x0d0, /* Closed Caption, PAL/SECAM */
529 { 0xaa, 0x2a, 0xff, 0x3f , 0x04, 0x51, 0x6e, 0x02, 0xa6, 0x7b, 0x09, 0x0, 0x0, 0x0, 0x27, 0x0 } 534 {V4L2_SLICED_CAPTION_625,22,22,1},
535 { 0xaa, 0x2a, 0xff, 0x3f, 0x04, 0x51, 0x6e, 0x02,
536 0xa6, 0x7b, 0x09, 0x00, 0x00, 0x00, 0x27, 0x00 }
530 }, 537 },
531 {0x0f0, /* CC, NTSC */ 538 {0x0f0, /* Closed Caption, NTSC */
532 { 0xaa, 0x2a, 0xff, 0x3f , 0x04, 0x51, 0x6e, 0x02, 0x69, 0x8c, 0x09, 0x0, 0x0, 0x0, 0x27, 0x0 } 539 {V4L2_SLICED_CAPTION_525,21,21,1},
540 { 0xaa, 0x2a, 0xff, 0x3f, 0x04, 0x51, 0x6e, 0x02,
541 0x69, 0x8c, 0x09, 0x00, 0x00, 0x00, 0x27, 0x00 }
533 }, 542 },
534 {0x110, /* WSS, PAL/SECAM */ 543 {0x110, /* Wide Screen Signal, PAL/SECAM */
535 { 0x5b, 0x55, 0xc5, 0xff , 0x0, 0x71, 0x6e, 0x42, 0xa6, 0xcd, 0x0f, 0x0, 0x0, 0x0, 0x3a, 0x0 } 544 {V4L2_SLICED_WSS_625,20,21,1},
545 { 0x5b, 0x55, 0xc5, 0xff, 0x00, 0x71, 0x6e, 0x42,
546 0xa6, 0xcd, 0x0f, 0x00, 0x00, 0x00, 0x3a, 0x00 }
536 }, 547 },
537 {0x130, /* WSS, NTSC C */ 548 {0x130, /* Wide Screen Signal, NTSC C */
538 { 0x38, 0x00, 0x3f, 0x00 , 0x0, 0x71, 0x6e, 0x43, 0x69, 0x7c, 0x08, 0x0, 0x0, 0x0, 0x39, 0x0 } 549 {V4L2_SLICED_WSS_525,20,20,1},
550 { 0x38, 0x00, 0x3f, 0x00, 0x00, 0x71, 0x6e, 0x43,
551 0x69, 0x7c, 0x08, 0x00, 0x00, 0x00, 0x39, 0x00 }
539 }, 552 },
540 {0x150, /* VITC, PAL/SECAM */ 553 {0x150, /* Vertical Interval Timecode (VITC), PAL/SECAM */
541 { 0x0, 0x0, 0x0, 0x0 , 0x0, 0x8f, 0x6d, 0x49, 0xa6, 0x85, 0x08, 0x0, 0x0, 0x0, 0x4c, 0x0 } 554 {V4l2_SLICED_VITC_625,6,22,0},
555 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x8f, 0x6d, 0x49,
556 0xa6, 0x85, 0x08, 0x00, 0x00, 0x00, 0x4c, 0x00 }
542 }, 557 },
543 {0x170, /* VITC, NTSC */ 558 {0x170, /* Vertical Interval Timecode (VITC), NTSC */
544 { 0x0, 0x0, 0x0, 0x0 , 0x0, 0x8f, 0x6d, 0x49, 0x69, 0x94, 0x08, 0x0, 0x0, 0x0, 0x4c, 0x0 } 559 {V4l2_SLICED_VITC_525,10,20,0},
560 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x8f, 0x6d, 0x49,
561 0x69, 0x94, 0x08, 0x00, 0x00, 0x00, 0x4c, 0x00 }
545 }, 562 },
546 {0x190, /* VPS, PAL */ 563 {0x190, /* Video Program System (VPS), PAL */
547 { 0xaa, 0xaa, 0xff, 0xff, 0xba, 0xce, 0x2b, 0x0d, 0xa6, 0xda, 0x0b, 0x0, 0x0, 0x0, 0x60, 0x0 } 564 {V4L2_SLICED_VPS,16,16,0},
548 }, 565 { 0xaa, 0xaa, 0xff, 0xff, 0xba, 0xce, 0x2b, 0x0d,
549 {0x1b0, /* Gemstar Custom 1 */ 566 0xa6, 0xda, 0x0b, 0x00, 0x00, 0x00, 0x60, 0x00 }
550 { 0xcc, 0xcc, 0xff, 0xff, 0x05, 0x51, 0x6e, 0x05, 0x69, 0x19, 0x13, 0x0, 0x0, 0x0, 0x60, 0x0 }
551 }, 567 },
568 /* 0x1d0 User programmable */
569
570 /* End of struct */
571 { (u16)-1 }
552}; 572};
553 573
554static int tvp5150_write_inittab(struct i2c_client *c, 574static int tvp5150_write_inittab(struct i2c_client *c,
555 const struct i2c_reg_value *regs) 575 const struct i2c_reg_value *regs)
556{ 576{
557 while (regs->reg != 0xff) { 577 while (regs->reg != 0xff) {
558 tvp5150_write(c, regs->reg, regs->value); 578 tvp5150_write(c, regs->reg, regs->value);
@@ -562,7 +582,7 @@ static int tvp5150_write_inittab(struct i2c_client *c,
562} 582}
563 583
564static int tvp5150_vdp_init(struct i2c_client *c, 584static int tvp5150_vdp_init(struct i2c_client *c,
565 const struct i2c_vbi_ram_value *regs) 585 const struct i2c_vbi_ram_value *regs)
566{ 586{
567 unsigned int i; 587 unsigned int i;
568 588
@@ -586,6 +606,24 @@ static int tvp5150_vdp_init(struct i2c_client *c,
586 return 0; 606 return 0;
587} 607}
588 608
609/* Fills VBI capabilities based on i2c_vbi_ram_value struct */
610static void tvp5150_vbi_get_cap(const struct i2c_vbi_ram_value *regs,
611 struct v4l2_sliced_vbi_cap *cap)
612{
613 int line;
614
615 memset(cap, 0, sizeof *cap);
616
617 while (regs->reg != (u16)-1 ) {
618 for (line=regs->type.ini_line;line<=regs->type.end_line;line++) {
619 cap->service_lines[0][line] |= regs->type.vbi_type;
620 }
621 cap->service_set |= regs->type.vbi_type;
622
623 regs++;
624 }
625}
626
589/* Set vbi processing 627/* Set vbi processing
590 * type - one of tvp5150_vbi_types 628 * type - one of tvp5150_vbi_types
591 * line - line to gather data 629 * line - line to gather data
@@ -599,7 +637,7 @@ static int tvp5150_vdp_init(struct i2c_client *c,
599 * LSB = field1 637 * LSB = field1
600 * MSB = field2 638 * MSB = field2
601 */ 639 */
602static int tvp5150_set_vbi(struct i2c_client *c, enum tvp5150_vbi_types type, 640static int tvp5150_set_vbi(struct i2c_client *c, unsigned int type,
603 u8 flags, int line, const int fields) 641 u8 flags, int line, const int fields)
604{ 642{
605 struct tvp5150 *decoder = i2c_get_clientdata(c); 643 struct tvp5150 *decoder = i2c_get_clientdata(c);
@@ -775,6 +813,15 @@ static int tvp5150_command(struct i2c_client *c,
775 *(v4l2_std_id *)arg = decoder->norm; 813 *(v4l2_std_id *)arg = decoder->norm;
776 break; 814 break;
777 815
816 case VIDIOC_G_SLICED_VBI_CAP:
817 {
818 struct v4l2_sliced_vbi_cap *cap = arg;
819 tvp5150_dbg(1, "VIDIOC_G_SLICED_VBI_CAP\n");
820
821 tvp5150_vbi_get_cap(vbi_ram_default, cap);
822 break;
823 }
824
778#ifdef CONFIG_VIDEO_ADV_DEBUG 825#ifdef CONFIG_VIDEO_ADV_DEBUG
779 case VIDIOC_INT_G_REGISTER: 826 case VIDIOC_INT_G_REGISTER:
780 { 827 {
@@ -1021,7 +1068,7 @@ static int tvp5150_detect_client(struct i2c_adapter *adapter,
1021 return rv; 1068 return rv;
1022 } 1069 }
1023 1070
1024 if (debug > 1) 1071// if (debug > 1)
1025 dump_reg(c); 1072 dump_reg(c);
1026 return 0; 1073 return 0;
1027} 1074}