aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2008-09-06 14:26:44 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2008-10-12 07:37:00 -0400
commit6bd6dff6318397b1127dd256b65dde007306b8ea (patch)
treeab42df43b2e22a527fb12bc1bf0e18771ecb29ce
parent2796073a3d9cc4f610f1e68b3f62c197d86577ab (diff)
V4L/DVB (8940): saa7115: fix saa7111(a) support
The saa7111 support in saa7115.c was missing some features and did not properly take some of the differences into account. With this patch saa7115 can be used in the mxb driver instead of saa7111.c. Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/video/saa7115.c34
-rw-r--r--include/media/saa7115.h19
-rw-r--r--include/media/v4l2-common.h12
3 files changed, 50 insertions, 15 deletions
diff --git a/drivers/media/video/saa7115.c b/drivers/media/video/saa7115.c
index ad733caec720..4ed7d65dd634 100644
--- a/drivers/media/video/saa7115.c
+++ b/drivers/media/video/saa7115.c
@@ -1309,10 +1309,13 @@ static int saa7115_command(struct i2c_client *client, unsigned int cmd, void *ar
1309 case VIDIOC_INT_S_VIDEO_ROUTING: 1309 case VIDIOC_INT_S_VIDEO_ROUTING:
1310 { 1310 {
1311 struct v4l2_routing *route = arg; 1311 struct v4l2_routing *route = arg;
1312 u32 input = route->input;
1313 u8 mask = (state->ident == V4L2_IDENT_SAA7111) ? 0xf8 : 0xf0;
1312 1314
1313 v4l_dbg(1, debug, client, "decoder set input %d output %d\n", route->input, route->output); 1315 v4l_dbg(1, debug, client, "decoder set input %d output %d\n", route->input, route->output);
1314 /* saa7113 does not have these inputs */ 1316 /* saa7111/3 does not have these inputs */
1315 if (state->ident == V4L2_IDENT_SAA7113 && 1317 if ((state->ident == V4L2_IDENT_SAA7113 ||
1318 state->ident == V4L2_IDENT_SAA7111) &&
1316 (route->input == SAA7115_COMPOSITE4 || 1319 (route->input == SAA7115_COMPOSITE4 ||
1317 route->input == SAA7115_COMPOSITE5)) { 1320 route->input == SAA7115_COMPOSITE5)) {
1318 return -EINVAL; 1321 return -EINVAL;
@@ -1327,10 +1330,23 @@ static int saa7115_command(struct i2c_client *client, unsigned int cmd, void *ar
1327 (route->input >= SAA7115_SVIDEO0) ? "S-Video" : "Composite", (route->output == SAA7115_IPORT_ON) ? "iport on" : "iport off"); 1330 (route->input >= SAA7115_SVIDEO0) ? "S-Video" : "Composite", (route->output == SAA7115_IPORT_ON) ? "iport on" : "iport off");
1328 state->input = route->input; 1331 state->input = route->input;
1329 1332
1333 /* saa7111 has slightly different input numbering */
1334 if (state->ident == V4L2_IDENT_SAA7111) {
1335 if (input >= SAA7115_COMPOSITE4)
1336 input -= 2;
1337 /* saa7111 specific */
1338 saa711x_write(client, R_10_CHROMA_CNTL_2,
1339 (saa711x_read(client, R_10_CHROMA_CNTL_2) & 0x3f) |
1340 ((route->output & 0xc0) ^ 0x40));
1341 saa711x_write(client, R_13_RT_X_PORT_OUT_CNTL,
1342 (saa711x_read(client, R_13_RT_X_PORT_OUT_CNTL) & 0xf0) |
1343 ((route->output & 2) ? 0x0a : 0));
1344 }
1345
1330 /* select mode */ 1346 /* select mode */
1331 saa711x_write(client, R_02_INPUT_CNTL_1, 1347 saa711x_write(client, R_02_INPUT_CNTL_1,
1332 (saa711x_read(client, R_02_INPUT_CNTL_1) & 0xf0) | 1348 (saa711x_read(client, R_02_INPUT_CNTL_1) & mask) |
1333 state->input); 1349 input);
1334 1350
1335 /* bypass chrominance trap for S-Video modes */ 1351 /* bypass chrominance trap for S-Video modes */
1336 saa711x_write(client, R_09_LUMA_CNTL, 1352 saa711x_write(client, R_09_LUMA_CNTL,
@@ -1384,6 +1400,13 @@ static int saa7115_command(struct i2c_client *client, unsigned int cmd, void *ar
1384 saa711x_writeregs(client, saa7115_cfg_reset_scaler); 1400 saa711x_writeregs(client, saa7115_cfg_reset_scaler);
1385 break; 1401 break;
1386 1402
1403 case VIDIOC_INT_S_GPIO:
1404 if (state->ident != V4L2_IDENT_SAA7111)
1405 return -EINVAL;
1406 saa711x_write(client, 0x11, (saa711x_read(client, 0x11) & 0x7f) |
1407 (*(u32 *)arg ? 0x80 : 0));
1408 break;
1409
1387 case VIDIOC_INT_G_VBI_DATA: 1410 case VIDIOC_INT_G_VBI_DATA:
1388 { 1411 {
1389 struct v4l2_sliced_vbi_data *data = arg; 1412 struct v4l2_sliced_vbi_data *data = arg;
@@ -1539,7 +1562,8 @@ static int saa7115_probe(struct i2c_client *client,
1539 state->crystal_freq = SAA7115_FREQ_32_11_MHZ; 1562 state->crystal_freq = SAA7115_FREQ_32_11_MHZ;
1540 saa711x_writeregs(client, saa7115_init_auto_input); 1563 saa711x_writeregs(client, saa7115_init_auto_input);
1541 } 1564 }
1542 saa711x_writeregs(client, saa7115_init_misc); 1565 if (state->ident != V4L2_IDENT_SAA7111)
1566 saa711x_writeregs(client, saa7115_init_misc);
1543 saa711x_set_v4lstd(client, V4L2_STD_NTSC); 1567 saa711x_set_v4lstd(client, V4L2_STD_NTSC);
1544 1568
1545 v4l_dbg(1, debug, client, "status: (1E) 0x%02x, (1F) 0x%02x\n", 1569 v4l_dbg(1, debug, client, "status: (1E) 0x%02x, (1F) 0x%02x\n",
diff --git a/include/media/saa7115.h b/include/media/saa7115.h
index f677dfb9d373..bab212719591 100644
--- a/include/media/saa7115.h
+++ b/include/media/saa7115.h
@@ -1,5 +1,5 @@
1/* 1/*
2 saa7115.h - definition for saa7113/4/5 inputs and frequency flags 2 saa7115.h - definition for saa7111/3/4/5 inputs and frequency flags
3 3
4 Copyright (C) 2006 Hans Verkuil (hverkuil@xs4all.nl) 4 Copyright (C) 2006 Hans Verkuil (hverkuil@xs4all.nl)
5 5
@@ -21,13 +21,13 @@
21#ifndef _SAA7115_H_ 21#ifndef _SAA7115_H_
22#define _SAA7115_H_ 22#define _SAA7115_H_
23 23
24/* SAA7113/4/5 HW inputs */ 24/* SAA7111/3/4/5 HW inputs */
25#define SAA7115_COMPOSITE0 0 25#define SAA7115_COMPOSITE0 0
26#define SAA7115_COMPOSITE1 1 26#define SAA7115_COMPOSITE1 1
27#define SAA7115_COMPOSITE2 2 27#define SAA7115_COMPOSITE2 2
28#define SAA7115_COMPOSITE3 3 28#define SAA7115_COMPOSITE3 3
29#define SAA7115_COMPOSITE4 4 /* not available for the saa7113 */ 29#define SAA7115_COMPOSITE4 4 /* not available for the saa7111/3 */
30#define SAA7115_COMPOSITE5 5 /* not available for the saa7113 */ 30#define SAA7115_COMPOSITE5 5 /* not available for the saa7111/3 */
31#define SAA7115_SVIDEO0 6 31#define SAA7115_SVIDEO0 6
32#define SAA7115_SVIDEO1 7 32#define SAA7115_SVIDEO1 7
33#define SAA7115_SVIDEO2 8 33#define SAA7115_SVIDEO2 8
@@ -42,8 +42,15 @@
42#define SAA7115_FREQ_FL_CGCDIV (1 << 1) /* SA 3A[6], CGCDIV, SAA7115 only */ 42#define SAA7115_FREQ_FL_CGCDIV (1 << 1) /* SA 3A[6], CGCDIV, SAA7115 only */
43#define SAA7115_FREQ_FL_APLL (1 << 2) /* SA 3A[3], APLL, SAA7114/5 only */ 43#define SAA7115_FREQ_FL_APLL (1 << 2) /* SA 3A[3], APLL, SAA7114/5 only */
44 44
45#define SAA7115_IPORT_ON 1 45#define SAA7115_IPORT_ON 1
46#define SAA7115_IPORT_OFF 0 46#define SAA7115_IPORT_OFF 0
47
48/* SAA7111 specific output flags */
49#define SAA7111_VBI_BYPASS 2
50#define SAA7111_FMT_YUV422 0x00
51#define SAA7111_FMT_RGB 0x40
52#define SAA7111_FMT_CCIR 0x80
53#define SAA7111_FMT_YUV411 0xc0
47 54
48#endif 55#endif
49 56
diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h
index 0c195ccd45d2..2f8719abf5cb 100644
--- a/include/media/v4l2-common.h
+++ b/include/media/v4l2-common.h
@@ -225,18 +225,22 @@ struct v4l2_crystal_freq {
225 An extra flags field allows device specific configuration regarding 225 An extra flags field allows device specific configuration regarding
226 clock frequency dividers, etc. If not used, then set flags to 0. 226 clock frequency dividers, etc. If not used, then set flags to 0.
227 If the frequency is not supported, then -EINVAL is returned. */ 227 If the frequency is not supported, then -EINVAL is returned. */
228#define VIDIOC_INT_S_CRYSTAL_FREQ _IOW ('d', 113, struct v4l2_crystal_freq) 228#define VIDIOC_INT_S_CRYSTAL_FREQ _IOW('d', 113, struct v4l2_crystal_freq)
229 229
230/* Initialize the sensor registors to some sort of reasonable 230/* Initialize the sensor registors to some sort of reasonable
231 default values. */ 231 default values. */
232#define VIDIOC_INT_INIT _IOW ('d', 114, u32) 232#define VIDIOC_INT_INIT _IOW('d', 114, u32)
233 233
234/* Set v4l2_std_id for video OUTPUT devices. This is ignored by 234/* Set v4l2_std_id for video OUTPUT devices. This is ignored by
235 video input devices. */ 235 video input devices. */
236#define VIDIOC_INT_S_STD_OUTPUT _IOW ('d', 115, v4l2_std_id) 236#define VIDIOC_INT_S_STD_OUTPUT _IOW('d', 115, v4l2_std_id)
237 237
238/* Get v4l2_std_id for video OUTPUT devices. This is ignored by 238/* Get v4l2_std_id for video OUTPUT devices. This is ignored by
239 video input devices. */ 239 video input devices. */
240#define VIDIOC_INT_G_STD_OUTPUT _IOW ('d', 116, v4l2_std_id) 240#define VIDIOC_INT_G_STD_OUTPUT _IOW('d', 116, v4l2_std_id)
241
242/* Set GPIO pins. Very simple right now, might need to be extended with
243 a v4l2_gpio struct if a direction is also needed. */
244#define VIDIOC_INT_S_GPIO _IOW('d', 117, u32)
241 245
242#endif /* V4L2_COMMON_H_ */ 246#endif /* V4L2_COMMON_H_ */