aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Bugge <marbugge@cisco.com>2013-12-05 09:52:39 -0500
committerMauro Carvalho Chehab <m.chehab@samsung.com>2014-01-07 03:30:41 -0500
commit3c4da74fe55e52e2635b08af99471a5679a7a92e (patch)
treecb1ffb628b9ff75b67ab554733759c1c7bdf064b
parentb38a1c4cf27ca8303b7c15f8df8247c081ba2723 (diff)
[media] adv7842: 625/525 line standard jitter fix
Both the PAL and NTSC standards are interlaced where a frame consist of two fields. Total number of lines in a frame in both systems are an odd number so the two fields will have different length. In the 625 line standard ("PAL") the odd field of the frame is transmitted first, while in the 525 standard ("NTSC") the even field is transmitted first. This adds the possibility to change output config between the fields and standards. This setting will reduce the "format-jitter" on the signal sent by the pixelport moving the difference between the fields to vertical front/back-porch only. Signed-off-by: Martin Bugge <marbugge@cisco.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
-rw-r--r--drivers/media/i2c/adv7842.c56
-rw-r--r--include/media/adv7842.h3
2 files changed, 42 insertions, 17 deletions
diff --git a/drivers/media/i2c/adv7842.c b/drivers/media/i2c/adv7842.c
index 8d0edd47b65d..dcafc8e7a86a 100644
--- a/drivers/media/i2c/adv7842.c
+++ b/drivers/media/i2c/adv7842.c
@@ -2345,15 +2345,55 @@ static int adv7842_querystd(struct v4l2_subdev *sd, v4l2_std_id *std)
2345 return 0; 2345 return 0;
2346} 2346}
2347 2347
2348static void adv7842_s_sdp_io(struct v4l2_subdev *sd, struct adv7842_sdp_io_sync_adjustment *s)
2349{
2350 if (s && s->adjust) {
2351 sdp_io_write(sd, 0x94, (s->hs_beg >> 8) & 0xf);
2352 sdp_io_write(sd, 0x95, s->hs_beg & 0xff);
2353 sdp_io_write(sd, 0x96, (s->hs_width >> 8) & 0xf);
2354 sdp_io_write(sd, 0x97, s->hs_width & 0xff);
2355 sdp_io_write(sd, 0x98, (s->de_beg >> 8) & 0xf);
2356 sdp_io_write(sd, 0x99, s->de_beg & 0xff);
2357 sdp_io_write(sd, 0x9a, (s->de_end >> 8) & 0xf);
2358 sdp_io_write(sd, 0x9b, s->de_end & 0xff);
2359 sdp_io_write(sd, 0xac, s->de_v_beg_o);
2360 sdp_io_write(sd, 0xad, s->de_v_beg_e);
2361 sdp_io_write(sd, 0xae, s->de_v_end_o);
2362 sdp_io_write(sd, 0xaf, s->de_v_end_e);
2363 } else {
2364 /* set to default */
2365 sdp_io_write(sd, 0x94, 0x00);
2366 sdp_io_write(sd, 0x95, 0x00);
2367 sdp_io_write(sd, 0x96, 0x00);
2368 sdp_io_write(sd, 0x97, 0x20);
2369 sdp_io_write(sd, 0x98, 0x00);
2370 sdp_io_write(sd, 0x99, 0x00);
2371 sdp_io_write(sd, 0x9a, 0x00);
2372 sdp_io_write(sd, 0x9b, 0x00);
2373 sdp_io_write(sd, 0xac, 0x04);
2374 sdp_io_write(sd, 0xad, 0x04);
2375 sdp_io_write(sd, 0xae, 0x04);
2376 sdp_io_write(sd, 0xaf, 0x04);
2377 }
2378}
2379
2348static int adv7842_s_std(struct v4l2_subdev *sd, v4l2_std_id norm) 2380static int adv7842_s_std(struct v4l2_subdev *sd, v4l2_std_id norm)
2349{ 2381{
2350 struct adv7842_state *state = to_state(sd); 2382 struct adv7842_state *state = to_state(sd);
2383 struct adv7842_platform_data *pdata = &state->pdata;
2351 2384
2352 v4l2_dbg(1, debug, sd, "%s:\n", __func__); 2385 v4l2_dbg(1, debug, sd, "%s:\n", __func__);
2353 2386
2354 if (state->mode != ADV7842_MODE_SDP) 2387 if (state->mode != ADV7842_MODE_SDP)
2355 return -ENODATA; 2388 return -ENODATA;
2356 2389
2390 if (norm & V4L2_STD_625_50)
2391 adv7842_s_sdp_io(sd, &pdata->sdp_io_sync_625);
2392 else if (norm & V4L2_STD_525_60)
2393 adv7842_s_sdp_io(sd, &pdata->sdp_io_sync_525);
2394 else
2395 adv7842_s_sdp_io(sd, NULL);
2396
2357 if (norm & V4L2_STD_ALL) { 2397 if (norm & V4L2_STD_ALL) {
2358 state->norm = norm; 2398 state->norm = norm;
2359 return 0; 2399 return 0;
@@ -2423,22 +2463,6 @@ static int adv7842_core_init(struct v4l2_subdev *sd)
2423 2463
2424 sdp_csc_coeff(sd, &pdata->sdp_csc_coeff); 2464 sdp_csc_coeff(sd, &pdata->sdp_csc_coeff);
2425 2465
2426 if (pdata->sdp_io_sync.adjust) {
2427 const struct adv7842_sdp_io_sync_adjustment *s = &pdata->sdp_io_sync;
2428 sdp_io_write(sd, 0x94, (s->hs_beg>>8) & 0xf);
2429 sdp_io_write(sd, 0x95, s->hs_beg & 0xff);
2430 sdp_io_write(sd, 0x96, (s->hs_width>>8) & 0xf);
2431 sdp_io_write(sd, 0x97, s->hs_width & 0xff);
2432 sdp_io_write(sd, 0x98, (s->de_beg>>8) & 0xf);
2433 sdp_io_write(sd, 0x99, s->de_beg & 0xff);
2434 sdp_io_write(sd, 0x9a, (s->de_end>>8) & 0xf);
2435 sdp_io_write(sd, 0x9b, s->de_end & 0xff);
2436 sdp_io_write(sd, 0xac, s->de_v_beg_o);
2437 sdp_io_write(sd, 0xad, s->de_v_beg_e);
2438 sdp_io_write(sd, 0xae, s->de_v_end_o);
2439 sdp_io_write(sd, 0xaf, s->de_v_end_e);
2440 }
2441
2442 /* todo, improve settings for sdram */ 2466 /* todo, improve settings for sdram */
2443 if (pdata->sd_ram_size >= 128) { 2467 if (pdata->sd_ram_size >= 128) {
2444 sdp_write(sd, 0x12, 0x0d); /* Frame TBC,3D comb enabled */ 2468 sdp_write(sd, 0x12, 0x0d); /* Frame TBC,3D comb enabled */
diff --git a/include/media/adv7842.h b/include/media/adv7842.h
index f4e9d0d68c13..5327ba36d846 100644
--- a/include/media/adv7842.h
+++ b/include/media/adv7842.h
@@ -197,7 +197,8 @@ struct adv7842_platform_data {
197 197
198 struct adv7842_sdp_csc_coeff sdp_csc_coeff; 198 struct adv7842_sdp_csc_coeff sdp_csc_coeff;
199 199
200 struct adv7842_sdp_io_sync_adjustment sdp_io_sync; 200 struct adv7842_sdp_io_sync_adjustment sdp_io_sync_625;
201 struct adv7842_sdp_io_sync_adjustment sdp_io_sync_525;
201 202
202 /* i2c addresses */ 203 /* i2c addresses */
203 u8 i2c_sdp_io; 204 u8 i2c_sdp_io;