|
@@ -346,6 +346,7 @@ EXPORT_SYMBOL_GPL(v4l2_print_dv_timings);
|
|
|
* @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
|
|
@@ -357,7 +358,7 @@ EXPORT_SYMBOL_GPL(v4l2_print_dv_timings);
|
|
|
* detection function.
|
|
|
*/
|
|
|
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)
|
|
|
{
|
|
|
int v_fp, v_bp, h_fp, h_bp, hsync;
|
|
|
int frame_width, image_height, image_width;
|
|
@@ -392,7 +393,11 @@ bool v4l2_detect_cvt(unsigned frame_height, unsigned hfreq, unsigned vsync,
|
|
|
if (v_bp < CVT_MIN_V_BPORCH)
|
|
|
v_bp = CVT_MIN_V_BPORCH;
|
|
|
}
|
|
|
- image_height = (frame_height - v_fp - vsync - v_bp + 1) & ~0x1;
|
|
|
+
|
|
|
+ if (interlaced)
|
|
|
+ image_height = (frame_height - 2 * v_fp - 2 * vsync - 2 * v_bp) & ~0x1;
|
|
|
+ else
|
|
|
+ image_height = (frame_height - v_fp - vsync - v_bp + 1) & ~0x1;
|
|
|
|
|
|
if (image_height < 0)
|
|
|
return false;
|
|
@@ -465,11 +470,27 @@ bool v4l2_detect_cvt(unsigned frame_height, unsigned hfreq, unsigned vsync,
|
|
|
fmt->bt.hsync = hsync;
|
|
|
fmt->bt.vsync = vsync;
|
|
|
fmt->bt.hbackporch = frame_width - image_width - h_fp - hsync;
|
|
|
- fmt->bt.vbackporch = frame_height - image_height - v_fp - vsync;
|
|
|
+
|
|
|
+ if (!interlaced) {
|
|
|
+ fmt->bt.vbackporch = frame_height - image_height - v_fp - vsync;
|
|
|
+ fmt->bt.interlaced = V4L2_DV_PROGRESSIVE;
|
|
|
+ } else {
|
|
|
+ fmt->bt.vbackporch = (frame_height - image_height - 2 * v_fp -
|
|
|
+ 2 * vsync) / 2;
|
|
|
+ fmt->bt.il_vbackporch = frame_height - image_height - 2 * v_fp -
|
|
|
+ 2 * vsync - fmt->bt.vbackporch;
|
|
|
+ fmt->bt.il_vfrontporch = v_fp;
|
|
|
+ fmt->bt.il_vsync = vsync;
|
|
|
+ fmt->bt.flags |= V4L2_DV_FL_HALF_LINE;
|
|
|
+ fmt->bt.interlaced = V4L2_DV_INTERLACED;
|
|
|
+ }
|
|
|
+
|
|
|
fmt->bt.pixelclock = pix_clk;
|
|
|
fmt->bt.standards = V4L2_DV_BT_STD_CVT;
|
|
|
+
|
|
|
if (reduced_blanking)
|
|
|
fmt->bt.flags |= V4L2_DV_FL_REDUCED_BLANKING;
|
|
|
+
|
|
|
return true;
|
|
|
}
|
|
|
EXPORT_SYMBOL_GPL(v4l2_detect_cvt);
|
|
@@ -508,6 +529,7 @@ EXPORT_SYMBOL_GPL(v4l2_detect_cvt);
|
|
|
* @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
|
|
@@ -523,6 +545,7 @@ bool v4l2_detect_gtf(unsigned frame_height,
|
|
|
unsigned hfreq,
|
|
|
unsigned vsync,
|
|
|
u32 polarities,
|
|
|
+ bool interlaced,
|
|
|
struct v4l2_fract aspect,
|
|
|
struct v4l2_dv_timings *fmt)
|
|
|
{
|
|
@@ -547,9 +570,11 @@ bool v4l2_detect_gtf(unsigned frame_height,
|
|
|
|
|
|
/* Vertical */
|
|
|
v_fp = GTF_V_FP;
|
|
|
-
|
|
|
v_bp = (GTF_MIN_VSYNC_BP * hfreq + 500000) / 1000000 - vsync;
|
|
|
- image_height = (frame_height - v_fp - vsync - v_bp + 1) & ~0x1;
|
|
|
+ if (interlaced)
|
|
|
+ image_height = (frame_height - 2 * v_fp - 2 * vsync - 2 * v_bp) & ~0x1;
|
|
|
+ else
|
|
|
+ image_height = (frame_height - v_fp - vsync - v_bp + 1) & ~0x1;
|
|
|
|
|
|
if (image_height < 0)
|
|
|
return false;
|
|
@@ -603,11 +628,27 @@ bool v4l2_detect_gtf(unsigned frame_height,
|
|
|
fmt->bt.hsync = hsync;
|
|
|
fmt->bt.vsync = vsync;
|
|
|
fmt->bt.hbackporch = frame_width - image_width - h_fp - hsync;
|
|
|
- fmt->bt.vbackporch = frame_height - image_height - v_fp - vsync;
|
|
|
+
|
|
|
+ if (!interlaced) {
|
|
|
+ fmt->bt.vbackporch = frame_height - image_height - v_fp - vsync;
|
|
|
+ fmt->bt.interlaced = V4L2_DV_PROGRESSIVE;
|
|
|
+ } else {
|
|
|
+ fmt->bt.vbackporch = (frame_height - image_height - 2 * v_fp -
|
|
|
+ 2 * vsync) / 2;
|
|
|
+ fmt->bt.il_vbackporch = frame_height - image_height - 2 * v_fp -
|
|
|
+ 2 * vsync - fmt->bt.vbackporch;
|
|
|
+ fmt->bt.il_vfrontporch = v_fp;
|
|
|
+ fmt->bt.il_vsync = vsync;
|
|
|
+ fmt->bt.flags |= V4L2_DV_FL_HALF_LINE;
|
|
|
+ fmt->bt.interlaced = V4L2_DV_INTERLACED;
|
|
|
+ }
|
|
|
+
|
|
|
fmt->bt.pixelclock = pix_clk;
|
|
|
fmt->bt.standards = V4L2_DV_BT_STD_GTF;
|
|
|
+
|
|
|
if (!default_gtf)
|
|
|
fmt->bt.flags |= V4L2_DV_FL_REDUCED_BLANKING;
|
|
|
+
|
|
|
return true;
|
|
|
}
|
|
|
EXPORT_SYMBOL_GPL(v4l2_detect_gtf);
|