diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2013-08-15 07:05:59 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <m.chehab@samsung.com> | 2013-08-24 03:26:27 -0400 |
commit | 11d034c8b60c3eebc2a12f5e99a200f55a786230 (patch) | |
tree | 145305d5d3f61259f6fd373185b55ed3a6fd7ad2 | |
parent | 0216dc2fe666b5cedba54df4c0be6ddc8eb352e1 (diff) |
[media] ad9389b/adv7604/ths8200: use new v4l2_print_dv_timings helper
These three drivers all have code to log the dv_timings contents. Replace
that code with the new helper function.
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/ad9389b.c | 17 | ||||
-rw-r--r-- | drivers/media/i2c/adv7604.c | 61 | ||||
-rw-r--r-- | drivers/media/i2c/ths8200.c | 38 |
3 files changed, 14 insertions, 102 deletions
diff --git a/drivers/media/i2c/ad9389b.c b/drivers/media/i2c/ad9389b.c index 92cdb25c73f7..1c6d352acfa0 100644 --- a/drivers/media/i2c/ad9389b.c +++ b/drivers/media/i2c/ad9389b.c | |||
@@ -443,20 +443,11 @@ static int ad9389b_log_status(struct v4l2_subdev *sd) | |||
443 | vic_detect, vic_sent); | 443 | vic_detect, vic_sent); |
444 | } | 444 | } |
445 | } | 445 | } |
446 | if (state->dv_timings.type == V4L2_DV_BT_656_1120) { | 446 | if (state->dv_timings.type == V4L2_DV_BT_656_1120) |
447 | struct v4l2_bt_timings *bt = bt = &state->dv_timings.bt; | 447 | v4l2_print_dv_timings(sd->name, "timings: ", |
448 | u32 frame_width = V4L2_DV_BT_FRAME_WIDTH(bt); | 448 | &state->dv_timings, false); |
449 | u32 frame_height = V4L2_DV_BT_FRAME_HEIGHT(bt); | 449 | else |
450 | u32 frame_size = frame_width * frame_height; | ||
451 | |||
452 | v4l2_info(sd, "timings: %ux%u%s%u (%ux%u). Pix freq. = %u Hz. Polarities = 0x%x\n", | ||
453 | bt->width, bt->height, bt->interlaced ? "i" : "p", | ||
454 | frame_size > 0 ? (unsigned)bt->pixelclock / frame_size : 0, | ||
455 | frame_width, frame_height, | ||
456 | (unsigned)bt->pixelclock, bt->polarities); | ||
457 | } else { | ||
458 | v4l2_info(sd, "no timings set\n"); | 450 | v4l2_info(sd, "no timings set\n"); |
459 | } | ||
460 | return 0; | 451 | return 0; |
461 | } | 452 | } |
462 | 453 | ||
diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c index e732c9bcf0e0..ba8602c06d6b 100644 --- a/drivers/media/i2c/adv7604.c +++ b/drivers/media/i2c/adv7604.c | |||
@@ -1051,53 +1051,6 @@ static int adv7604_g_input_status(struct v4l2_subdev *sd, u32 *status) | |||
1051 | 1051 | ||
1052 | /* ----------------------------------------------------------------------- */ | 1052 | /* ----------------------------------------------------------------------- */ |
1053 | 1053 | ||
1054 | static void adv7604_print_timings(struct v4l2_subdev *sd, | ||
1055 | struct v4l2_dv_timings *timings, | ||
1056 | const char *txt, bool detailed) | ||
1057 | { | ||
1058 | struct v4l2_bt_timings *bt = &timings->bt; | ||
1059 | u32 htot, vtot; | ||
1060 | |||
1061 | if (timings->type != V4L2_DV_BT_656_1120) | ||
1062 | return; | ||
1063 | |||
1064 | htot = htotal(bt); | ||
1065 | vtot = vtotal(bt); | ||
1066 | |||
1067 | v4l2_info(sd, "%s %dx%d%s%d (%dx%d)", | ||
1068 | txt, bt->width, bt->height, bt->interlaced ? "i" : "p", | ||
1069 | (htot * vtot) > 0 ? ((u32)bt->pixelclock / | ||
1070 | (htot * vtot)) : 0, | ||
1071 | htot, vtot); | ||
1072 | |||
1073 | if (!detailed) | ||
1074 | return; | ||
1075 | |||
1076 | v4l2_info(sd, " horizontal: fp = %d, %ssync = %d, bp = %d\n", | ||
1077 | bt->hfrontporch, | ||
1078 | (bt->polarities & V4L2_DV_HSYNC_POS_POL) ? "+" : "-", | ||
1079 | bt->hsync, bt->hbackporch); | ||
1080 | v4l2_info(sd, " vertical: fp = %d, %ssync = %d, bp = %d\n", | ||
1081 | bt->vfrontporch, | ||
1082 | (bt->polarities & V4L2_DV_VSYNC_POS_POL) ? "+" : "-", | ||
1083 | bt->vsync, bt->vbackporch); | ||
1084 | v4l2_info(sd, " pixelclock: %lld\n", bt->pixelclock); | ||
1085 | v4l2_info(sd, " flags (0x%x):%s%s%s%s\n", bt->flags, | ||
1086 | (bt->flags & V4L2_DV_FL_REDUCED_BLANKING) ? | ||
1087 | " Reduced blanking," : "", | ||
1088 | (bt->flags & V4L2_DV_FL_CAN_REDUCE_FPS) ? | ||
1089 | " Can reduce FPS," : "", | ||
1090 | (bt->flags & V4L2_DV_FL_REDUCED_FPS) ? | ||
1091 | " Reduced FPS," : "", | ||
1092 | (bt->flags & V4L2_DV_FL_HALF_LINE) ? | ||
1093 | " Half line," : ""); | ||
1094 | v4l2_info(sd, " standards (0x%x):%s%s%s%s\n", bt->standards, | ||
1095 | (bt->standards & V4L2_DV_BT_STD_CEA861) ? " CEA," : "", | ||
1096 | (bt->standards & V4L2_DV_BT_STD_DMT) ? " DMT," : "", | ||
1097 | (bt->standards & V4L2_DV_BT_STD_CVT) ? " CVT" : "", | ||
1098 | (bt->standards & V4L2_DV_BT_STD_GTF) ? " GTF" : ""); | ||
1099 | } | ||
1100 | |||
1101 | struct stdi_readback { | 1054 | struct stdi_readback { |
1102 | u16 bl, lcf, lcvs; | 1055 | u16 bl, lcf, lcvs; |
1103 | u8 hs_pol, vs_pol; | 1056 | u8 hs_pol, vs_pol; |
@@ -1360,8 +1313,8 @@ found: | |||
1360 | } | 1313 | } |
1361 | 1314 | ||
1362 | if (debug > 1) | 1315 | if (debug > 1) |
1363 | adv7604_print_timings(sd, timings, | 1316 | v4l2_print_dv_timings(sd->name, "adv7604_query_dv_timings: ", |
1364 | "adv7604_query_dv_timings:", true); | 1317 | timings, true); |
1365 | 1318 | ||
1366 | return 0; | 1319 | return 0; |
1367 | } | 1320 | } |
@@ -1403,8 +1356,8 @@ static int adv7604_s_dv_timings(struct v4l2_subdev *sd, | |||
1403 | 1356 | ||
1404 | 1357 | ||
1405 | if (debug > 1) | 1358 | if (debug > 1) |
1406 | adv7604_print_timings(sd, timings, | 1359 | v4l2_print_dv_timings(sd->name, "adv7604_s_dv_timings: ", |
1407 | "adv7604_s_dv_timings:", true); | 1360 | timings, true); |
1408 | return 0; | 1361 | return 0; |
1409 | } | 1362 | } |
1410 | 1363 | ||
@@ -1770,8 +1723,10 @@ static int adv7604_log_status(struct v4l2_subdev *sd) | |||
1770 | if (adv7604_query_dv_timings(sd, &timings)) | 1723 | if (adv7604_query_dv_timings(sd, &timings)) |
1771 | v4l2_info(sd, "No video detected\n"); | 1724 | v4l2_info(sd, "No video detected\n"); |
1772 | else | 1725 | else |
1773 | adv7604_print_timings(sd, &timings, "Detected format:", true); | 1726 | v4l2_print_dv_timings(sd->name, "Detected format: ", |
1774 | adv7604_print_timings(sd, &state->timings, "Configured format:", true); | 1727 | &timings, true); |
1728 | v4l2_print_dv_timings(sd->name, "Configured format: ", | ||
1729 | &state->timings, true); | ||
1775 | 1730 | ||
1776 | if (no_signal(sd)) | 1731 | if (no_signal(sd)) |
1777 | return 0; | 1732 | return 0; |
diff --git a/drivers/media/i2c/ths8200.c b/drivers/media/i2c/ths8200.c index 7a60a8fda5df..49041e577e13 100644 --- a/drivers/media/i2c/ths8200.c +++ b/drivers/media/i2c/ths8200.c | |||
@@ -133,39 +133,6 @@ static int ths8200_s_register(struct v4l2_subdev *sd, | |||
133 | } | 133 | } |
134 | #endif | 134 | #endif |
135 | 135 | ||
136 | static void ths8200_print_timings(struct v4l2_subdev *sd, | ||
137 | struct v4l2_dv_timings *timings, | ||
138 | const char *txt, bool detailed) | ||
139 | { | ||
140 | struct v4l2_bt_timings *bt = &timings->bt; | ||
141 | u32 htot, vtot; | ||
142 | |||
143 | if (timings->type != V4L2_DV_BT_656_1120) | ||
144 | return; | ||
145 | |||
146 | htot = htotal(bt); | ||
147 | vtot = vtotal(bt); | ||
148 | |||
149 | v4l2_info(sd, "%s %dx%d%s%d (%dx%d)", | ||
150 | txt, bt->width, bt->height, bt->interlaced ? "i" : "p", | ||
151 | (htot * vtot) > 0 ? ((u32)bt->pixelclock / (htot * vtot)) : 0, | ||
152 | htot, vtot); | ||
153 | |||
154 | if (detailed) { | ||
155 | v4l2_info(sd, " horizontal: fp = %d, %ssync = %d, bp = %d\n", | ||
156 | bt->hfrontporch, | ||
157 | (bt->polarities & V4L2_DV_HSYNC_POS_POL) ? "+" : "-", | ||
158 | bt->hsync, bt->hbackporch); | ||
159 | v4l2_info(sd, " vertical: fp = %d, %ssync = %d, bp = %d\n", | ||
160 | bt->vfrontporch, | ||
161 | (bt->polarities & V4L2_DV_VSYNC_POS_POL) ? "+" : "-", | ||
162 | bt->vsync, bt->vbackporch); | ||
163 | v4l2_info(sd, | ||
164 | " pixelclock: %lld, flags: 0x%x, standards: 0x%x\n", | ||
165 | bt->pixelclock, bt->flags, bt->standards); | ||
166 | } | ||
167 | } | ||
168 | |||
169 | static int ths8200_log_status(struct v4l2_subdev *sd) | 136 | static int ths8200_log_status(struct v4l2_subdev *sd) |
170 | { | 137 | { |
171 | struct ths8200_state *state = to_state(sd); | 138 | struct ths8200_state *state = to_state(sd); |
@@ -182,9 +149,8 @@ static int ths8200_log_status(struct v4l2_subdev *sd) | |||
182 | ths8200_read(sd, THS8200_DTG2_PIXEL_CNT_LSB), | 149 | ths8200_read(sd, THS8200_DTG2_PIXEL_CNT_LSB), |
183 | (ths8200_read(sd, THS8200_DTG2_LINE_CNT_MSB) & 0x07) * 256 + | 150 | (ths8200_read(sd, THS8200_DTG2_LINE_CNT_MSB) & 0x07) * 256 + |
184 | ths8200_read(sd, THS8200_DTG2_LINE_CNT_LSB)); | 151 | ths8200_read(sd, THS8200_DTG2_LINE_CNT_LSB)); |
185 | ths8200_print_timings(sd, &state->dv_timings, | 152 | v4l2_print_dv_timings(sd->name, "Configured format:", |
186 | "Configured format:", true); | 153 | &state->dv_timings, true); |
187 | |||
188 | return 0; | 154 | return 0; |
189 | } | 155 | } |
190 | 156 | ||