Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Hans Verkuil and committed by
Mauro Carvalho Chehab
6bd6dff6 2796073a

+50 -15
+29 -5
drivers/media/video/saa7115.c
··· 1309 1309 case VIDIOC_INT_S_VIDEO_ROUTING: 1310 1310 { 1311 1311 struct v4l2_routing *route = arg; 1312 + u32 input = route->input; 1313 + u8 mask = (state->ident == V4L2_IDENT_SAA7111) ? 0xf8 : 0xf0; 1312 1314 1313 1315 v4l_dbg(1, debug, client, "decoder set input %d output %d\n", route->input, route->output); 1314 - /* saa7113 does not have these inputs */ 1315 - if (state->ident == V4L2_IDENT_SAA7113 && 1316 + /* saa7111/3 does not have these inputs */ 1317 + if ((state->ident == V4L2_IDENT_SAA7113 || 1318 + state->ident == V4L2_IDENT_SAA7111) && 1316 1319 (route->input == SAA7115_COMPOSITE4 || 1317 1320 route->input == SAA7115_COMPOSITE5)) { 1318 1321 return -EINVAL; ··· 1330 1327 (route->input >= SAA7115_SVIDEO0) ? "S-Video" : "Composite", (route->output == SAA7115_IPORT_ON) ? "iport on" : "iport off"); 1331 1328 state->input = route->input; 1332 1329 1330 + /* saa7111 has slightly different input numbering */ 1331 + if (state->ident == V4L2_IDENT_SAA7111) { 1332 + if (input >= SAA7115_COMPOSITE4) 1333 + input -= 2; 1334 + /* saa7111 specific */ 1335 + saa711x_write(client, R_10_CHROMA_CNTL_2, 1336 + (saa711x_read(client, R_10_CHROMA_CNTL_2) & 0x3f) | 1337 + ((route->output & 0xc0) ^ 0x40)); 1338 + saa711x_write(client, R_13_RT_X_PORT_OUT_CNTL, 1339 + (saa711x_read(client, R_13_RT_X_PORT_OUT_CNTL) & 0xf0) | 1340 + ((route->output & 2) ? 0x0a : 0)); 1341 + } 1342 + 1333 1343 /* select mode */ 1334 1344 saa711x_write(client, R_02_INPUT_CNTL_1, 1335 - (saa711x_read(client, R_02_INPUT_CNTL_1) & 0xf0) | 1336 - state->input); 1345 + (saa711x_read(client, R_02_INPUT_CNTL_1) & mask) | 1346 + input); 1337 1347 1338 1348 /* bypass chrominance trap for S-Video modes */ 1339 1349 saa711x_write(client, R_09_LUMA_CNTL, ··· 1398 1382 case VIDIOC_INT_RESET: 1399 1383 v4l_dbg(1, debug, client, "decoder RESET\n"); 1400 1384 saa711x_writeregs(client, saa7115_cfg_reset_scaler); 1385 + break; 1386 + 1387 + case VIDIOC_INT_S_GPIO: 1388 + if (state->ident != V4L2_IDENT_SAA7111) 1389 + return -EINVAL; 1390 + saa711x_write(client, 0x11, (saa711x_read(client, 0x11) & 0x7f) | 1391 + (*(u32 *)arg ? 0x80 : 0)); 1401 1392 break; 1402 1393 1403 1394 case VIDIOC_INT_G_VBI_DATA: ··· 1562 1539 state->crystal_freq = SAA7115_FREQ_32_11_MHZ; 1563 1540 saa711x_writeregs(client, saa7115_init_auto_input); 1564 1541 } 1565 - saa711x_writeregs(client, saa7115_init_misc); 1542 + if (state->ident != V4L2_IDENT_SAA7111) 1543 + saa711x_writeregs(client, saa7115_init_misc); 1566 1544 saa711x_set_v4lstd(client, V4L2_STD_NTSC); 1567 1545 1568 1546 v4l_dbg(1, debug, client, "status: (1E) 0x%02x, (1F) 0x%02x\n",
+13 -6
include/media/saa7115.h
··· 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 4 Copyright (C) 2006 Hans Verkuil (hverkuil@xs4all.nl) 5 5 ··· 21 21 #ifndef _SAA7115_H_ 22 22 #define _SAA7115_H_ 23 23 24 - /* SAA7113/4/5 HW inputs */ 24 + /* SAA7111/3/4/5 HW inputs */ 25 25 #define SAA7115_COMPOSITE0 0 26 26 #define SAA7115_COMPOSITE1 1 27 27 #define SAA7115_COMPOSITE2 2 28 28 #define SAA7115_COMPOSITE3 3 29 - #define SAA7115_COMPOSITE4 4 /* not available for the saa7113 */ 30 - #define SAA7115_COMPOSITE5 5 /* 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 saa7111/3 */ 31 31 #define SAA7115_SVIDEO0 6 32 32 #define SAA7115_SVIDEO1 7 33 33 #define SAA7115_SVIDEO2 8 ··· 42 42 #define SAA7115_FREQ_FL_CGCDIV (1 << 1) /* SA 3A[6], CGCDIV, SAA7115 only */ 43 43 #define SAA7115_FREQ_FL_APLL (1 << 2) /* SA 3A[3], APLL, SAA7114/5 only */ 44 44 45 - #define SAA7115_IPORT_ON 1 46 - #define SAA7115_IPORT_OFF 0 45 + #define SAA7115_IPORT_ON 1 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 55 #endif 49 56
+8 -4
include/media/v4l2-common.h
··· 225 225 An extra flags field allows device specific configuration regarding 226 226 clock frequency dividers, etc. If not used, then set flags to 0. 227 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 230 /* Initialize the sensor registors to some sort of reasonable 231 231 default values. */ 232 - #define VIDIOC_INT_INIT _IOW ('d', 114, u32) 232 + #define VIDIOC_INT_INIT _IOW('d', 114, u32) 233 233 234 234 /* Set v4l2_std_id for video OUTPUT devices. This is ignored by 235 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 238 /* Get v4l2_std_id for video OUTPUT devices. This is ignored by 239 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 246 #endif /* V4L2_COMMON_H_ */