Support for interlaced in cvt/gtf timings
v2 cover Support for interlaced in cvt/gtf timings
Please find version 2 of patches adding interlaced support in cvt/gtf timing.
Changes compared to v1:
Incorporated the comments from review of first RFC. It was about the error calculation of vertical back porch due to rounding. (Thanks to Hans for spoting this error).
Prashant Laddha (4):
v4l2-dv-timings: add interlace support in detect cvt/gtf
vivid: Use interlaced info for cvt/gtf timing detection
adv7604: Use interlaced info for cvt/gtf timing detection
adv7842: Use interlaced info for cvt/gtf timing detection
drivers/media/i2c/adv7604.c | 4 +-- drivers/media/i2c/adv7842.c | 4 +-- drivers/media/platform/vivid/vivid-vid-cap.c | 5 +-- drivers/media/v4l2-core/v4l2-dv-timings.c | 53 ++++++++++++++++++++++++---- include/media/v4l2-dv-timings.h | 6 ++-- 5 files changed, 58 insertions(+), 14 deletions(-)
Signature · 1 line
1.9.1
RFC PATCH v2 1/4 v4l2-dv-timings: add interlace support in detect cvt/gtf
Extended detect_cvt/gtf API to indicate the format type (interlaced or progressive). In case of interlaced, the vertical front and back porch and vsync values for both (odd,even) fields are considered to derive image height. Populated vsync, verical front, back porch values in bt timing structure for even and odd fields and updated the flags appropriately.
Also modified the functions calling the detect_cvt/gtf(). As of now these functions are calling detect_cvt/gtf() with interlaced flag set to false.
--- drivers/media/i2c/adv7604.c | 4 +-- drivers/media/i2c/adv7842.c | 4 +-- drivers/media/platform/vivid/vivid-vid-cap.c | 5 +-- drivers/media/v4l2-core/v4l2-dv-timings.c | 53 ++++++++++++++++++++++++---- include/media/v4l2-dv-timings.h | 6 ++-- 5 files changed, 58 insertions(+), 14 deletions(-)
drivers/media/i2c/adv7604.c +2 -2
@@ -1323,12 +1323,12 @@ static int stdi2dv_timings(struct v4l2_subdev *sd,if (v4l2_detect_cvt (stdi->lcf +1 , hfreq, stdi->lcvs, (stdi->hs_pol =='+' ?V4L2_DV_HSYNC_POS_POL :0 ) | (stdi->vs_pol =='+' ?V4L2_DV_VSYNC_POS_POL :0 ), - timings)) + false, timings))return 0 ;if (v4l2_detect_gtf (stdi->lcf +1 , hfreq, stdi->lcvs, (stdi->hs_pol =='+' ?V4L2_DV_HSYNC_POS_POL :0 ) | (stdi->vs_pol =='+' ?V4L2_DV_VSYNC_POS_POL :0 ), - state->aspect_ratio, timings)) + false, state->aspect_ratio, timings))return 0 ; v4l2_dbg(2, debug, sd,
drivers/media/i2c/adv7842.c +2 -2
@@ -1445,12 +1445,12 @@ static int stdi2dv_timings(struct v4l2_subdev *sd,if (v4l2_detect_cvt (stdi->lcf +1 , hfreq, stdi->lcvs, (stdi->hs_pol =='+' ?V4L2_DV_HSYNC_POS_POL :0 ) | (stdi->vs_pol =='+' ?V4L2_DV_VSYNC_POS_POL :0 ), - timings)) + false, timings))return 0 ;if (v4l2_detect_gtf (stdi->lcf +1 , hfreq, stdi->lcvs, (stdi->hs_pol =='+' ?V4L2_DV_HSYNC_POS_POL :0 ) | (stdi->vs_pol =='+' ?V4L2_DV_VSYNC_POS_POL :0 ), - state->aspect_ratio, timings)) + false, state->aspect_ratio, timings))return 0 ; v4l2_dbg(2, debug, sd,
drivers/media/platform/vivid/vivid-vid-cap.c +3 -2
@@ -1619,7 +1619,7 @@ static bool valid_cvt_gtf_timings(struct v4l2_dv_timings *timings)if (bt->standards ==0 || (bt->standards &V4L2_DV_BT_STD_CVT )) {if (v4l2_detect_cvt (total_v_lines, h_freq, bt->vsync, - bt->polarities, timings)) + bt->polarities, false, timings))return true; }
@@ -1630,7 +1630,8 @@ static bool valid_cvt_gtf_timings(struct v4l2_dv_timings *timings) &aspect_ratio.numerator, &aspect_ratio.denominator);if (v4l2_detect_gtf (total_v_lines, h_freq, bt->vsync, - bt->polarities, aspect_ratio, timings)) + bt->polarities, false, + aspect_ratio, timings))return true; }return false;
drivers/media/v4l2-core/v4l2-dv-timings.c +47 -6
110 lines not on this page · raw message
include/media/v4l2-dv-timings.h +4 -2
@@ -117,6 +117,7 @@ void v4l2_print_dv_timings(const char *dev_prefix, const char *prefix,* @vsync - the height of the vertical sync in lines. * @polarities - the horizontal and vertical polarities (same as struct * v4l2_bt_timings polarities). +* @interlaced - if this flag is true, it indicates interlaced format * @fmt - the resulting timings. * * This function will attempt to detect if the given values correspond to a
@@ -124,7 +125,7 @@ void v4l2_print_dv_timings(const char *dev_prefix, const char *prefix,* in with the found CVT timings. */ bool v4l2_detect_cvt (unsigned frame_height,unsigned hfreq,unsigned vsync, -u32 polarities,struct v4l2_dv_timings *fmt); +u32 polarities,bool interlaced,struct v4l2_dv_timings *fmt);/** v4l2_detect_gtf - detect if the given timings follow the GTF standard * @frame_height - the total height of the frame (including blanking) in lines.
@@ -132,6 +133,7 @@ bool v4l2_detect_cvt(unsigned frame_height, unsigned hfreq, unsigned vsync,* @vsync - the height of the vertical sync in lines. * @polarities - the horizontal and vertical polarities (same as struct * v4l2_bt_timings polarities). +* @interlaced - if this flag is true, it indicates interlaced format * @aspect - preferred aspect ratio. GTF has no method of determining the * aspect ratio in order to derive the image width from the * image height, so it has to be passed explicitly. Usually
@@ -144,7 +146,7 @@ bool v4l2_detect_cvt(unsigned frame_height, unsigned hfreq, unsigned vsync,* in with the found GTF timings. */ bool v4l2_detect_gtf (unsigned frame_height,unsigned hfreq,unsigned vsync, -u32 polarities,struct v4l2_fract aspect, +u32 polarities,bool interlaced,struct v4l2_fract aspect,struct v4l2_dv_timings *fmt);/** v4l2_calc_aspect_ratio - calculate the aspect ratio based on bytes
Signature · 1 line
1.9.1
RFC PATCH v2 2/4 vivid: Use interlaced info for cvt/gtf timing detection
In reply to Prashant LaddhaThe detect_cvt/gtf() now supports timing calculations for interlaced format.
--- drivers/media/platform/vivid/vivid-vid-cap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/platform/vivid/vivid-vid-cap.c +2 -2
@@ -1619,7 +1619,7 @@ static bool valid_cvt_gtf_timings(struct v4l2_dv_timings *timings)if (bt->standards ==0 || (bt->standards &V4L2_DV_BT_STD_CVT )) {if (v4l2_detect_cvt (total_v_lines, h_freq, bt->vsync, - bt->polarities, false, timings)) + bt->polarities, bt->interlaced, timings))return true; }
@@ -1630,7 +1630,7 @@ static bool valid_cvt_gtf_timings(struct v4l2_dv_timings *timings) &aspect_ratio.numerator, &aspect_ratio.denominator);if (v4l2_detect_gtf (total_v_lines, h_freq, bt->vsync, - bt->polarities, false, + bt->polarities, bt->interlaced, aspect_ratio, timings))return true; }
Signature · 1 line
1.9.1
RFC PATCH v2 3/4 adv7604: Use interlaced info for cvt/gtf timing detection
In reply to Prashant LaddhaThe interlaced information from stdi is passed to detect_cvt/gtf(). These functions now supports timing calculations for interlaced format.
--- drivers/media/i2c/adv7604.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/i2c/adv7604.c +2 -2
@@ -1323,12 +1323,12 @@ static int stdi2dv_timings(struct v4l2_subdev *sd,if (v4l2_detect_cvt (stdi->lcf +1 , hfreq, stdi->lcvs, (stdi->hs_pol =='+' ?V4L2_DV_HSYNC_POS_POL :0 ) | (stdi->vs_pol =='+' ?V4L2_DV_VSYNC_POS_POL :0 ), - false, timings)) + stdi->interlaced, timings))return 0 ;if (v4l2_detect_gtf (stdi->lcf +1 , hfreq, stdi->lcvs, (stdi->hs_pol =='+' ?V4L2_DV_HSYNC_POS_POL :0 ) | (stdi->vs_pol =='+' ?V4L2_DV_VSYNC_POS_POL :0 ), - false, state->aspect_ratio, timings)) + stdi->interlaced, state->aspect_ratio, timings))return 0 ; v4l2_dbg(2, debug, sd,
Signature · 1 line
1.9.1
RFC PATCH v2 4/4 adv7842: Use interlaced info for cvt/gtf timing detection
In reply to Prashant LaddhaThe interlaced information from stdi is passed to detect_cvt/gtf().
--- drivers/media/i2c/adv7842.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/i2c/adv7842.c +2 -2
@@ -1445,12 +1445,12 @@ static int stdi2dv_timings(struct v4l2_subdev *sd,if (v4l2_detect_cvt (stdi->lcf +1 , hfreq, stdi->lcvs, (stdi->hs_pol =='+' ?V4L2_DV_HSYNC_POS_POL :0 ) | (stdi->vs_pol =='+' ?V4L2_DV_VSYNC_POS_POL :0 ), - false, timings)) + stdi->interlaced, timings))return 0 ;if (v4l2_detect_gtf (stdi->lcf +1 , hfreq, stdi->lcvs, (stdi->hs_pol =='+' ?V4L2_DV_HSYNC_POS_POL :0 ) | (stdi->vs_pol =='+' ?V4L2_DV_VSYNC_POS_POL :0 ), - false, state->aspect_ratio, timings)) + stdi->interlaced, state->aspect_ratio, timings))return 0 ; v4l2_dbg(2, debug, sd,
Signature · 1 line
1.9.1
Hans Verkuil
AppliedHi Prashant,
I've merged patches 1 and 2, but I'm postponing 3 and 4: I'd like to be able to test this before merging, ideally with the cobalt driver, but that will take time.
They are in my todo list, so they won't be forgotten. In the meantime it is useful to have support for this in v4l2-dv-timings should someone want to use it.
Regards,
Hans
Quoted 21 lines · Prashant Laddha
Please find version 2 of patches adding interlaced support in cvt/gtf timing.
Changes compared to v1:
Incorporated the comments from review of first RFC. It was about the error calculation of vertical back porch due to rounding. (Thanks to Hans for spoting this error).Prashant Laddha (4):
v4l2-dv-timings: add interlace support in detect cvt/gtf
vivid: Use interlaced info for cvt/gtf timing detection
adv7604: Use interlaced info for cvt/gtf timing detection
adv7842: Use interlaced info for cvt/gtf timing detectiondrivers/media/i2c/adv7604.c | 4 +-- drivers/media/i2c/adv7842.c | 4 +-- drivers/media/platform/vivid/vivid-vid-cap.c | 5 +-- drivers/media/v4l2-core/v4l2-dv-timings.c | 53 ++++++++++++++++++++++++---- include/media/v4l2-dv-timings.h | 6 ++-- 5 files changed, 58 insertions(+), 14 deletions(-)