aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/saa7115.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/saa7115.c')
-rw-r--r--drivers/media/video/saa7115.c107
1 files changed, 90 insertions, 17 deletions
diff --git a/drivers/media/video/saa7115.c b/drivers/media/video/saa7115.c
index ffd87ce55556..b184fd00b4e7 100644
--- a/drivers/media/video/saa7115.c
+++ b/drivers/media/video/saa7115.c
@@ -1,4 +1,4 @@
1/* saa7115 - Philips SAA7114/SAA7115 video decoder driver 1/* saa7115 - Philips SAA7113/SAA7114/SAA7115 video decoder driver
2 * 2 *
3 * Based on saa7114 driver by Maxim Yevtyushkin, which is based on 3 * Based on saa7114 driver by Maxim Yevtyushkin, which is based on
4 * the saa7111 driver by Dave Perks. 4 * the saa7111 driver by Dave Perks.
@@ -16,6 +16,7 @@
16 * (2/17/2003) 16 * (2/17/2003)
17 * 17 *
18 * VBI support (2004) and cleanups (2005) by Hans Verkuil <hverkuil@xs4all.nl> 18 * VBI support (2004) and cleanups (2005) by Hans Verkuil <hverkuil@xs4all.nl>
19 * SAA7113 support by Mauro Carvalho Chehab <mchehab@infradead.org>
19 * 20 *
20 * This program is free software; you can redistribute it and/or 21 * This program is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU General Public License 22 * modify it under the terms of the GNU General Public License
@@ -42,8 +43,9 @@
42#include <media/audiochip.h> 43#include <media/audiochip.h>
43#include <asm/div64.h> 44#include <asm/div64.h>
44 45
45MODULE_DESCRIPTION("Philips SAA7114/SAA7115 video decoder driver"); 46MODULE_DESCRIPTION("Philips SAA7113/SAA7114/SAA7115 video decoder driver");
46MODULE_AUTHOR("Maxim Yevtyushkin, Kevin Thayer, Chris Kennedy, Hans Verkuil"); 47MODULE_AUTHOR( "Maxim Yevtyushkin, Kevin Thayer, Chris Kennedy, "
48 "Hans Verkuil, Mauro Carvalho Chehab");
47MODULE_LICENSE("GPL"); 49MODULE_LICENSE("GPL");
48 50
49static int debug = 0; 51static int debug = 0;
@@ -51,7 +53,10 @@ module_param(debug, bool, 0644);
51 53
52MODULE_PARM_DESC(debug, "Debug level (0-1)"); 54MODULE_PARM_DESC(debug, "Debug level (0-1)");
53 55
54static unsigned short normal_i2c[] = { 0x42 >> 1, 0x40 >> 1, I2C_CLIENT_END }; 56static unsigned short normal_i2c[] = {
57 0x4a >>1, 0x48 >>1, /* SAA7113 */
58 0x42 >> 1, 0x40 >> 1, /* SAA7114 and SAA7115 */
59 I2C_CLIENT_END };
55 60
56 61
57I2C_CLIENT_INSMOD; 62I2C_CLIENT_INSMOD;
@@ -101,10 +106,12 @@ static inline int saa7115_read(struct i2c_client *client, u8 reg)
101 Hauppauge driver sets. */ 106 Hauppauge driver sets. */
102 107
103static const unsigned char saa7115_init_auto_input[] = { 108static const unsigned char saa7115_init_auto_input[] = {
109 /* Front-End Part */
104 0x01, 0x48, /* white peak control disabled */ 110 0x01, 0x48, /* white peak control disabled */
105 0x03, 0x20, /* was 0x30. 0x20: long vertical blanking */ 111 0x03, 0x20, /* was 0x30. 0x20: long vertical blanking */
106 0x04, 0x90, /* analog gain set to 0 */ 112 0x04, 0x90, /* analog gain set to 0 */
107 0x05, 0x90, /* analog gain set to 0 */ 113 0x05, 0x90, /* analog gain set to 0 */
114 /* Decoder Part */
108 0x06, 0xeb, /* horiz sync begin = -21 */ 115 0x06, 0xeb, /* horiz sync begin = -21 */
109 0x07, 0xe0, /* horiz sync stop = -17 */ 116 0x07, 0xe0, /* horiz sync stop = -17 */
110 0x0a, 0x80, /* was 0x88. decoder brightness, 0x80 is itu standard */ 117 0x0a, 0x80, /* was 0x88. decoder brightness, 0x80 is itu standard */
@@ -123,6 +130,8 @@ static const unsigned char saa7115_init_auto_input[] = {
123 0x1b, 0x42, /* misc chroma control 0x42 = recommended */ 130 0x1b, 0x42, /* misc chroma control 0x42 = recommended */
124 0x1c, 0xa9, /* combfilter control 0xA9 = recommended */ 131 0x1c, 0xa9, /* combfilter control 0xA9 = recommended */
125 0x1d, 0x01, /* combfilter control 0x01 = recommended */ 132 0x1d, 0x01, /* combfilter control 0x01 = recommended */
133
134 /* Power Device Control */
126 0x88, 0xd0, /* reset device */ 135 0x88, 0xd0, /* reset device */
127 0x88, 0xf0, /* set device programmed, all in operational mode */ 136 0x88, 0xf0, /* set device programmed, all in operational mode */
128 0x00, 0x00 137 0x00, 0x00
@@ -338,6 +347,33 @@ static const unsigned char saa7115_cfg_vbi_off[] = {
338 0x00, 0x00 347 0x00, 0x00
339}; 348};
340 349
350static const unsigned char saa7113_init_auto_input[] = {
351 0x01, 0x08, /* PH7113_INCREMENT_DELAY - (1) (1) (1) (1) IDEL3 IDEL2 IDELL1 IDEL0 */
352 0x02, 0xc2, /* PH7113_ANALOG_INPUT_CONTR_1 - FUSE1 FUSE0 GUDL1 GUDL0 MODE3 MODE2 MODE1 MODE0 */
353 0x03, 0x30, /* PH7113_ANALOG_INPUT_CONTR_2 - (1) HLNRS VBSL WPOFF HOLDG GAFIX GAI28 GAI18 */
354 0x04, 0x00, /* PH7113_ANALOG_INPUT_CONTR_3 - GAI17 GAI16 GAI15 GAI14 GAI13 GAI12 GAI11 GAI10 */
355 0x05, 0x00, /* PH7113_ANALOG_INPUT_CONTR_4 - GAI27 GAI26 GAI25 GAI24 GAI23 GAI22 GAI21 GAI20 */
356 0x06, 0x89, /* PH7113_HORIZONTAL_SYNC_START - HSB7 HSB6 HSB5 HSB4 HSB3 HSB2 HSB1 HSB0 */
357 0x07, 0x0d, /* PH7113_HORIZONTAL_SYNC_STOP - HSS7 HSS6 HSS5 HSS4 HSS3 HSS2 HSS1 HSS0 */
358 0x08, 0x88, /* PH7113_SYNC_CONTROL - AUFD FSEL FOET HTC1 HTC0 HPLL VNOI1 VNOI0 */
359 0x09, 0x01, /* PH7113_LUMINANCE_CONTROL - BYPS PREF BPSS1 BPSS0 VBLB UPTCV APER1 APER0 */
360 0x0a, 0x80, /* PH7113_LUMINANCE_BRIGHTNESS - BRIG7 BRIG6 BRIG5 BRIG4 BRIG3 BRIG2 BRIG1 BRIG0 */
361 0x0b, 0x47, /* PH7113_LUMINANCE_CONTRAST - CONT7 CONT6 CONT5 CONT4 CONT3 CONT2 CONT1 CONT0 */
362 0x0c, 0x40, /* PH7113_CHROMA_SATURATION - SATN7 SATN6 SATN5 SATN4 SATN3 SATN2 SATN1 SATN0 */
363 0x0d, 0x00, /* PH7113_CHROMA_HUE_CONTROL - HUEC7 HUEC6 HUEC5 HUEC4 HUEC3 HUEC2 HUEC1 HUEC0 */
364 0x0e, 0x01, /* PH7113_CHROMA_CONTROL - CDTO CSTD2 CSTD1 CSTD0 DCCF FCTC CHBW1 CHBW0 */
365 0x0f, 0x2a, /* PH7113_CHROMA_GAIN_CONTROL - ACGC CGAIN6 CGAIN5 CGAIN4 CGAIN3 CGAIN2 CGAIN1 CGAIN0 */
366 0x10, 0x08, /* PH7113_FORMAT_DELAY_CONTROL - OFTS1 OFTS0 HDEL1 HDEL0 VRLN YDEL2 YDEL1 YDEL0 */
367 0x11, 0x0c, /* PH7113_OUTPUT_CONTROL_1 - GPSW1 CM99 GPSW0 HLSEL OEYC OERT VIPB COLO */
368 0x12, 0x07, /* PH7113_OUTPUT_CONTROL_2 - RTSE13 RTSE12 RTSE11 RTSE10 RTSE03 RTSE02 RTSE01 RTSE00 */
369 0x13, 0x00, /* PH7113_OUTPUT_CONTROL_3 - ADLSB (1) (1) OLDSB FIDP (1) AOSL1 AOSL0 */
370 0x14, 0x00, /* RESERVED 14 - (1) (1) (1) (1) (1) (1) (1) (1) */
371 0x15, 0x00, /* PH7113_V_GATE1_START - VSTA7 VSTA6 VSTA5 VSTA4 VSTA3 VSTA2 VSTA1 VSTA0 */
372 0x16, 0x00, /* PH7113_V_GATE1_STOP - VSTO7 VSTO6 VSTO5 VSTO4 VSTO3 VSTO2 VSTO1 VSTO0 */
373 0x17, 0x00, /* PH7113_V_GATE1_MSB - (1) (1) (1) (1) (1) (1) VSTO8 VSTA8 */
374 0x00, 0x00
375};
376
341static const unsigned char saa7115_init_misc[] = { 377static const unsigned char saa7115_init_misc[] = {
342 0x38, 0x03, /* audio stuff */ 378 0x38, 0x03, /* audio stuff */
343 0x39, 0x10, 379 0x39, 0x10,
@@ -677,10 +713,35 @@ static void saa7115_set_v4lstd(struct i2c_client *client, v4l2_std_id std)
677 saa7115_writeregs(client, saa7115_cfg_50hz_video); 713 saa7115_writeregs(client, saa7115_cfg_50hz_video);
678 } 714 }
679 715
716 /* Register 0E - Bits D6-D4 on NO-AUTO mode
717 (SAA7113 doesn't have auto mode)
718 50 Hz / 625 lines 60 Hz / 525 lines
719 000 PAL BGDHI (4.43Mhz) NTSC M (3.58MHz)
720 001 NTSC 4.43 (50 Hz) PAL 4.43 (60 Hz)
721 010 Combination-PAL N (3.58MHz) NTSC 4.43 (60 Hz)
722 011 NTSC N (3.58MHz) PAL M (3.58MHz)
723 100 reserved NTSC-Japan (3.58MHz)
724 */
725 if (state->ident == V4L2_IDENT_SAA7113) {
726 u8 reg = saa7115_read(client, 0x0e) & 0x8f;
727
728 if (std == V4L2_STD_PAL_M) {
729 reg|=0x30;
730 } else if (std == V4L2_STD_PAL_N) {
731 reg|=0x20;
732 } else if (std == V4L2_STD_PAL_60) {
733 reg|=0x10;
734 } else if (std == V4L2_STD_NTSC_M_JP) {
735 reg|=0x40;
736 }
737 saa7115_write(client, 0x0e, reg);
738 }
739
740
680 state->std = std; 741 state->std = std;
681 742
682 /* restart task B if needed */ 743 /* restart task B if needed */
683 if (taskb && state->ident == V4L2_IDENT_SAA7114) { 744 if (taskb && state->ident != V4L2_IDENT_SAA7115) {
684 saa7115_writeregs(client, saa7115_cfg_vbi_on); 745 saa7115_writeregs(client, saa7115_cfg_vbi_on);
685 } 746 }
686 747
@@ -703,7 +764,7 @@ static void saa7115_log_status(struct i2c_client *client)
703 int vcr; 764 int vcr;
704 765
705 v4l_info(client, "Audio frequency: %d Hz\n", state->audclk_freq); 766 v4l_info(client, "Audio frequency: %d Hz\n", state->audclk_freq);
706 if (client->name[6] == '4') { 767 if (state->ident != V4L2_IDENT_SAA7115) {
707 /* status for the saa7114 */ 768 /* status for the saa7114 */
708 reg1f = saa7115_read(client, 0x1f); 769 reg1f = saa7115_read(client, 0x1f);
709 signalOk = (reg1f & 0xc1) == 0x81; 770 signalOk = (reg1f & 0xc1) == 0x81;
@@ -751,8 +812,8 @@ static void saa7115_set_lcr(struct i2c_client *client, struct v4l2_sliced_vbi_fo
751 u8 lcr[24]; 812 u8 lcr[24];
752 int i, x; 813 int i, x;
753 814
754 /* saa7114 doesn't yet support VBI */ 815 /* saa7113/71144 doesn't yet support VBI */
755 if (state->ident == V4L2_IDENT_SAA7114) 816 if (state->ident != V4L2_IDENT_SAA7115)
756 return; 817 return;
757 818
758 for (i = 0; i <= 23; i++) 819 for (i = 0; i <= 23; i++)
@@ -791,7 +852,7 @@ static void saa7115_set_lcr(struct i2c_client *client, struct v4l2_sliced_vbi_fo
791 case 0: 852 case 0:
792 lcr[i] |= 0xf << (4 * x); 853 lcr[i] |= 0xf << (4 * x);
793 break; 854 break;
794 case V4L2_SLICED_TELETEXT_B: 855 case V4L2_SLICED_TELETEXT_PAL_B:
795 lcr[i] |= 1 << (4 * x); 856 lcr[i] |= 1 << (4 * x);
796 break; 857 break;
797 case V4L2_SLICED_CAPTION_525: 858 case V4L2_SLICED_CAPTION_525:
@@ -820,7 +881,7 @@ static void saa7115_set_lcr(struct i2c_client *client, struct v4l2_sliced_vbi_fo
820static int saa7115_get_v4lfmt(struct i2c_client *client, struct v4l2_format *fmt) 881static int saa7115_get_v4lfmt(struct i2c_client *client, struct v4l2_format *fmt)
821{ 882{
822 static u16 lcr2vbi[] = { 883 static u16 lcr2vbi[] = {
823 0, V4L2_SLICED_TELETEXT_B, 0, /* 1 */ 884 0, V4L2_SLICED_TELETEXT_PAL_B, 0, /* 1 */
824 0, V4L2_SLICED_CAPTION_525, /* 4 */ 885 0, V4L2_SLICED_CAPTION_525, /* 4 */
825 V4L2_SLICED_WSS_625, 0, /* 5 */ 886 V4L2_SLICED_WSS_625, 0, /* 5 */
826 V4L2_SLICED_VPS, 0, 0, 0, 0, /* 7 */ 887 V4L2_SLICED_VPS, 0, 0, 0, 0, /* 7 */
@@ -985,7 +1046,7 @@ static void saa7115_decode_vbi_line(struct i2c_client *client,
985 /* decode payloads */ 1046 /* decode payloads */
986 switch (id2) { 1047 switch (id2) {
987 case 1: 1048 case 1:
988 vbi->type = V4L2_SLICED_TELETEXT_B; 1049 vbi->type = V4L2_SLICED_TELETEXT_PAL_B;
989 break; 1050 break;
990 case 4: 1051 case 4:
991 if (!saa7115_odd_parity(p[0]) || !saa7115_odd_parity(p[1])) 1052 if (!saa7115_odd_parity(p[0]) || !saa7115_odd_parity(p[1]))
@@ -1261,14 +1322,12 @@ static int saa7115_attach(struct i2c_adapter *adapter, int address, int kind)
1261 1322
1262 saa7115_write(client, 0, 5); 1323 saa7115_write(client, 0, 5);
1263 chip_id = saa7115_read(client, 0) & 0x0f; 1324 chip_id = saa7115_read(client, 0) & 0x0f;
1264 if (chip_id != 4 && chip_id != 5) { 1325 if (chip_id <3 && chip_id > 5) {
1265 v4l_dbg(1, debug, client, "saa7115 not found\n"); 1326 v4l_dbg(1, debug, client, "saa7115 not found\n");
1266 kfree(client); 1327 kfree(client);
1267 return 0; 1328 return 0;
1268 } 1329 }
1269 if (chip_id == 4) { 1330 snprintf(client->name, sizeof(client->name) - 1, "saa711%d",chip_id);
1270 snprintf(client->name, sizeof(client->name) - 1, "saa7114");
1271 }
1272 v4l_info(client, "saa711%d found @ 0x%x (%s)\n", chip_id, address << 1, adapter->name); 1331 v4l_info(client, "saa711%d found @ 0x%x (%s)\n", chip_id, address << 1, adapter->name);
1273 1332
1274 state = kzalloc(sizeof(struct saa7115_state), GFP_KERNEL); 1333 state = kzalloc(sizeof(struct saa7115_state), GFP_KERNEL);
@@ -1285,13 +1344,27 @@ static int saa7115_attach(struct i2c_adapter *adapter, int address, int kind)
1285 state->contrast = 64; 1344 state->contrast = 64;
1286 state->hue = 0; 1345 state->hue = 0;
1287 state->sat = 64; 1346 state->sat = 64;
1288 state->ident = (chip_id == 4) ? V4L2_IDENT_SAA7114 : V4L2_IDENT_SAA7115; 1347 switch (chip_id) {
1348 case 3:
1349 state->ident = V4L2_IDENT_SAA7113;
1350 break;
1351 case 4:
1352 state->ident = V4L2_IDENT_SAA7114;
1353 break;
1354 default:
1355 state->ident = V4L2_IDENT_SAA7115;
1356 break;
1357 }
1358
1289 state->audclk_freq = 48000; 1359 state->audclk_freq = 48000;
1290 1360
1291 v4l_dbg(1, debug, client, "writing init values\n"); 1361 v4l_dbg(1, debug, client, "writing init values\n");
1292 1362
1293 /* init to 60hz/48khz */ 1363 /* init to 60hz/48khz */
1294 saa7115_writeregs(client, saa7115_init_auto_input); 1364 if (state->ident==V4L2_IDENT_SAA7113)
1365 saa7115_writeregs(client, saa7113_init_auto_input);
1366 else
1367 saa7115_writeregs(client, saa7115_init_auto_input);
1295 saa7115_writeregs(client, saa7115_init_misc); 1368 saa7115_writeregs(client, saa7115_init_misc);
1296 saa7115_writeregs(client, saa7115_cfg_60hz_fullres_x); 1369 saa7115_writeregs(client, saa7115_cfg_60hz_fullres_x);
1297 saa7115_writeregs(client, saa7115_cfg_60hz_fullres_y); 1370 saa7115_writeregs(client, saa7115_cfg_60hz_fullres_y);