All of lore.kernel.org
 help / color / mirror / Atom feed
* Support for CVT and GTF timings in vivid
@ 2015-03-20  6:41 Prashant Laddha
  2015-03-20  6:41 ` [PATCH 1/2] vivid: add CVT,GTF standards to vivid dv timings caps Prashant Laddha
  2015-03-20  6:41 ` [PATCH 2/2] vivid: add support to set CVT, GTF timings Prashant Laddha
  0 siblings, 2 replies; 5+ messages in thread
From: Prashant Laddha @ 2015-03-20  6:41 UTC (permalink / raw)
  To: Linux Media Mailing List

These patches add support for setting CVT and GTF timings in vivid.

Currently vivid supports V4L2_DV_BT_STD_DMT and V4L2_DV_BT_STD_CEA861
digital video standards which are all discrete monitor timings. So,
there is no support for standards outside of that set. Hans has been
thinking about extending vivid capability to support wider set of 
timings. I have been working with Hans on adding support for CVT/GTF
timings in vivid. Please find the patches for the same.

[PATCH 1/2] vivid: add CVT,GTF standards to vivid dv timings caps
[PATCH 2/2] vivid: add support to set CVT, GTF timings

Please review and share your comments, suggestions.

Regards,
Prashant

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] vivid: add CVT,GTF standards to vivid dv timings caps
  2015-03-20  6:41 Support for CVT and GTF timings in vivid Prashant Laddha
@ 2015-03-20  6:41 ` Prashant Laddha
  2015-03-20  6:41 ` [PATCH 2/2] vivid: add support to set CVT, GTF timings Prashant Laddha
  1 sibling, 0 replies; 5+ messages in thread
From: Prashant Laddha @ 2015-03-20  6:41 UTC (permalink / raw)
  To: Linux Media Mailing List; +Cc: Hans Verkuil, Prashant Laddha

Currently vivid supports V4L2_DV_BT_STD_DMT and V4L2_DV_BT_STD_CEA861
discrete video standards. Extending the capability set to allow for
setting CVT and GTF standards. This change, along with adding the
support for calculating CVT, GTF timings in v4l2-ctl would extend
the number of resolutions supported by vivid to almost any custom
resolution.

Also extending the limits on min and max pixel clock to accomodate
pixel clock range provided by cvt/gtf for resolutions ranging from
640x360p50 to 4kx2Kp60.

Cc: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Prashant Laddha <prladdha@cisco.com>
---
 drivers/media/platform/vivid/vivid-vid-common.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/vivid/vivid-vid-common.c b/drivers/media/platform/vivid/vivid-vid-common.c
index 6bef1e6..cba095f 100644
--- a/drivers/media/platform/vivid/vivid-vid-common.c
+++ b/drivers/media/platform/vivid/vivid-vid-common.c
@@ -33,8 +33,9 @@ const struct v4l2_dv_timings_cap vivid_dv_timings_cap = {
 	.type = V4L2_DV_BT_656_1120,
 	/* keep this initialization for compatibility with GCC < 4.4.6 */
 	.reserved = { 0 },
-	V4L2_INIT_BT_TIMINGS(0, MAX_WIDTH, 0, MAX_HEIGHT, 25000000, 600000000,
-		V4L2_DV_BT_STD_CEA861 | V4L2_DV_BT_STD_DMT,
+	V4L2_INIT_BT_TIMINGS(0, MAX_WIDTH, 0, MAX_HEIGHT, 14000000, 775000000,
+		V4L2_DV_BT_STD_CEA861 | V4L2_DV_BT_STD_DMT |
+		V4L2_DV_BT_STD_CVT | V4L2_DV_BT_STD_GTF,
 		V4L2_DV_BT_CAP_PROGRESSIVE | V4L2_DV_BT_CAP_INTERLACED)
 };
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] vivid: add support to set CVT, GTF timings
  2015-03-20  6:41 Support for CVT and GTF timings in vivid Prashant Laddha
  2015-03-20  6:41 ` [PATCH 1/2] vivid: add CVT,GTF standards to vivid dv timings caps Prashant Laddha
@ 2015-03-20  6:41 ` Prashant Laddha
  2015-03-20 11:20   ` Hans Verkuil
  1 sibling, 1 reply; 5+ messages in thread
From: Prashant Laddha @ 2015-03-20  6:41 UTC (permalink / raw)
  To: Linux Media Mailing List; +Cc: Hans Verkuil, Prashant Laddha

In addition to v4l2_find_dv_timings_cap(), where timings are serached
against the list of preset timings, the incoming timing from v4l2-ctl
is checked against CVT and GTF standards. If it confirms to be CVT or
GTF, it is treated as valid timing and vivid format is updated with
new timings.

Cc: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Prashant Laddha <prladdha@cisco.com>
---
 drivers/media/platform/vivid/vivid-vid-cap.c | 62 +++++++++++++++++++++++++++-
 1 file changed, 61 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/vivid/vivid-vid-cap.c b/drivers/media/platform/vivid/vivid-vid-cap.c
index 867a29a..d769113 100644
--- a/drivers/media/platform/vivid/vivid-vid-cap.c
+++ b/drivers/media/platform/vivid/vivid-vid-cap.c
@@ -1552,6 +1552,64 @@ int vivid_vid_cap_s_std(struct file *file, void *priv, v4l2_std_id id)
 	return 0;
 }
 
+static void find_aspect_ratio(u32 width, u32 height,
+			       u32 *num, u32 *denom)
+{
+	if (!(height % 3) && ((height * 4 / 3) == width)) {
+		*num = 4;
+		*denom = 3;
+	} else if (!(height % 9) && ((height * 16 / 9) == width)) {
+		*num = 16;
+		*denom = 9;
+	} else if (!(height % 10) && ((height * 16 / 10) == width)) {
+		*num = 16;
+		*denom = 10;
+	} else if (!(height % 4) && ((height * 5 / 4) == width)) {
+		*num = 5;
+		*denom = 4;
+	} else if (!(height % 9) && ((height * 15 / 9) == width)) {
+		*num = 15;
+		*denom = 9;
+	} else { /* default to 16:9 */
+		*num = 16;
+		*denom = 9;
+	}
+}
+
+static bool valid_cvt_gtf_timings(struct v4l2_dv_timings *timings)
+{
+	struct v4l2_dv_timings fmt;
+	struct v4l2_bt_timings *bt = &timings->bt;
+	u32 total_h_pixel;
+	u32 total_v_lines;
+	u32 h_freq;
+
+	if (!v4l2_valid_dv_timings(timings, &vivid_dv_timings_cap,
+				NULL, NULL))
+		return false;
+
+	total_h_pixel = V4L2_DV_BT_FRAME_WIDTH(bt);
+	total_v_lines = V4L2_DV_BT_FRAME_HEIGHT(bt);
+
+	h_freq = (u32)bt->pixelclock / total_h_pixel;
+
+	if (bt->standards == V4L2_DV_BT_STD_CVT)
+		return v4l2_detect_cvt(total_v_lines, h_freq, bt->vsync,
+				       bt->polarities, &fmt);
+
+	if (bt->standards == V4L2_DV_BT_STD_GTF) {
+		struct v4l2_fract aspect_ratio;
+
+		find_aspect_ratio(bt->width, bt->height,
+				  &aspect_ratio.numerator,
+				  &aspect_ratio.denominator);
+		return v4l2_detect_gtf(total_v_lines, h_freq, bt->vsync,
+				       bt->polarities, aspect_ratio, &fmt);
+	}
+
+	return false;
+}
+
 int vivid_vid_cap_s_dv_timings(struct file *file, void *_fh,
 				    struct v4l2_dv_timings *timings)
 {
@@ -1561,8 +1619,10 @@ int vivid_vid_cap_s_dv_timings(struct file *file, void *_fh,
 		return -ENODATA;
 	if (vb2_is_busy(&dev->vb_vid_cap_q))
 		return -EBUSY;
+
 	if (!v4l2_find_dv_timings_cap(timings, &vivid_dv_timings_cap,
-				0, NULL, NULL))
+				      0, NULL, NULL)
+	    && !valid_cvt_gtf_timings(timings))
 		return -EINVAL;
 	if (v4l2_match_dv_timings(timings, &dev->dv_timings_cap, 0))
 		return 0;
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] vivid: add support to set CVT, GTF timings
  2015-03-20  6:41 ` [PATCH 2/2] vivid: add support to set CVT, GTF timings Prashant Laddha
@ 2015-03-20 11:20   ` Hans Verkuil
  0 siblings, 0 replies; 5+ messages in thread
From: Hans Verkuil @ 2015-03-20 11:20 UTC (permalink / raw)
  To: Prashant Laddha, Linux Media Mailing List; +Cc: Hans Verkuil

Hi Prashant,

Thank you for the patch, but I have some comments below:

On 03/20/2015 07:41 AM, Prashant Laddha wrote:
> In addition to v4l2_find_dv_timings_cap(), where timings are serached
> against the list of preset timings, the incoming timing from v4l2-ctl
> is checked against CVT and GTF standards. If it confirms to be CVT or
> GTF, it is treated as valid timing and vivid format is updated with
> new timings.
> 
> Cc: Hans Verkuil <hans.verkuil@cisco.com>
> Signed-off-by: Prashant Laddha <prladdha@cisco.com>
> ---
>  drivers/media/platform/vivid/vivid-vid-cap.c | 62 +++++++++++++++++++++++++++-
>  1 file changed, 61 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/vivid/vivid-vid-cap.c b/drivers/media/platform/vivid/vivid-vid-cap.c
> index 867a29a..d769113 100644
> --- a/drivers/media/platform/vivid/vivid-vid-cap.c
> +++ b/drivers/media/platform/vivid/vivid-vid-cap.c
> @@ -1552,6 +1552,64 @@ int vivid_vid_cap_s_std(struct file *file, void *priv, v4l2_std_id id)
>  	return 0;
>  }
>  
> +static void find_aspect_ratio(u32 width, u32 height,
> +			       u32 *num, u32 *denom)
> +{
> +	if (!(height % 3) && ((height * 4 / 3) == width)) {
> +		*num = 4;
> +		*denom = 3;
> +	} else if (!(height % 9) && ((height * 16 / 9) == width)) {
> +		*num = 16;
> +		*denom = 9;
> +	} else if (!(height % 10) && ((height * 16 / 10) == width)) {
> +		*num = 16;
> +		*denom = 10;
> +	} else if (!(height % 4) && ((height * 5 / 4) == width)) {
> +		*num = 5;
> +		*denom = 4;
> +	} else if (!(height % 9) && ((height * 15 / 9) == width)) {
> +		*num = 15;
> +		*denom = 9;
> +	} else { /* default to 16:9 */
> +		*num = 16;
> +		*denom = 9;
> +	}
> +}
> +
> +static bool valid_cvt_gtf_timings(struct v4l2_dv_timings *timings)
> +{
> +	struct v4l2_dv_timings fmt;

This can be dropped, see below.

> +	struct v4l2_bt_timings *bt = &timings->bt;
> +	u32 total_h_pixel;
> +	u32 total_v_lines;
> +	u32 h_freq;
> +
> +	if (!v4l2_valid_dv_timings(timings, &vivid_dv_timings_cap,
> +				NULL, NULL))
> +		return false;
> +
> +	total_h_pixel = V4L2_DV_BT_FRAME_WIDTH(bt);
> +	total_v_lines = V4L2_DV_BT_FRAME_HEIGHT(bt);
> +
> +	h_freq = (u32)bt->pixelclock / total_h_pixel;
> +
> +	if (bt->standards == V4L2_DV_BT_STD_CVT)
> +		return v4l2_detect_cvt(total_v_lines, h_freq, bt->vsync,
> +				       bt->polarities, &fmt);

Pass in 'timings' instead of &fmt. You want to return the fully filled in
timings, so there is no point in storing it in a copy.

> +
> +	if (bt->standards == V4L2_DV_BT_STD_GTF) {
> +		struct v4l2_fract aspect_ratio;
> +
> +		find_aspect_ratio(bt->width, bt->height,
> +				  &aspect_ratio.numerator,
> +				  &aspect_ratio.denominator);
> +		return v4l2_detect_gtf(total_v_lines, h_freq, bt->vsync,
> +				       bt->polarities, aspect_ratio, &fmt);

Ditto.

> +	}
> +
> +	return false;
> +}
> +
>  int vivid_vid_cap_s_dv_timings(struct file *file, void *_fh,
>  				    struct v4l2_dv_timings *timings)
>  {
> @@ -1561,8 +1619,10 @@ int vivid_vid_cap_s_dv_timings(struct file *file, void *_fh,
>  		return -ENODATA;
>  	if (vb2_is_busy(&dev->vb_vid_cap_q))
>  		return -EBUSY;
> +
>  	if (!v4l2_find_dv_timings_cap(timings, &vivid_dv_timings_cap,
> -				0, NULL, NULL))
> +				      0, NULL, NULL)
> +	    && !valid_cvt_gtf_timings(timings))
>  		return -EINVAL;
>  	if (v4l2_match_dv_timings(timings, &dev->dv_timings_cap, 0))
>  		return 0;
> 

This looks good otherwise.

Regards,

	Hans

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 2/2] vivid: add support to set CVT, GTF timings
  2015-03-20 14:31 ` Prashant Laddha
@ 2015-03-20 14:31   ` Prashant Laddha
  0 siblings, 0 replies; 5+ messages in thread
From: Prashant Laddha @ 2015-03-20 14:31 UTC (permalink / raw)
  To: Linux Media Mailing List; +Cc: Hans Verkuil, Prashant Laddha

In addition to v4l2_find_dv_timings_cap(), where timings are serached
against the list of preset timings, the incoming timing from v4l2-ctl
is checked against CVT and GTF standards. If it confirms to be CVT or
GTF, it is treated as valid timing and vivid format is updated with
new timings.

Cc: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Prashant Laddha <prladdha@cisco.com>
---
 drivers/media/platform/vivid/vivid-vid-cap.c | 61 +++++++++++++++++++++++++++-
 1 file changed, 60 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/vivid/vivid-vid-cap.c b/drivers/media/platform/vivid/vivid-vid-cap.c
index 867a29a..b4ec9b0 100644
--- a/drivers/media/platform/vivid/vivid-vid-cap.c
+++ b/drivers/media/platform/vivid/vivid-vid-cap.c
@@ -1552,6 +1552,63 @@ int vivid_vid_cap_s_std(struct file *file, void *priv, v4l2_std_id id)
 	return 0;
 }
 
+static void find_aspect_ratio(u32 width, u32 height,
+			       u32 *num, u32 *denom)
+{
+	if (!(height % 3) && ((height * 4 / 3) == width)) {
+		*num = 4;
+		*denom = 3;
+	} else if (!(height % 9) && ((height * 16 / 9) == width)) {
+		*num = 16;
+		*denom = 9;
+	} else if (!(height % 10) && ((height * 16 / 10) == width)) {
+		*num = 16;
+		*denom = 10;
+	} else if (!(height % 4) && ((height * 5 / 4) == width)) {
+		*num = 5;
+		*denom = 4;
+	} else if (!(height % 9) && ((height * 15 / 9) == width)) {
+		*num = 15;
+		*denom = 9;
+	} else { /* default to 16:9 */
+		*num = 16;
+		*denom = 9;
+	}
+}
+
+static bool valid_cvt_gtf_timings(struct v4l2_dv_timings *timings)
+{
+	struct v4l2_bt_timings *bt = &timings->bt;
+	u32 total_h_pixel;
+	u32 total_v_lines;
+	u32 h_freq;
+
+	if (!v4l2_valid_dv_timings(timings, &vivid_dv_timings_cap,
+				NULL, NULL))
+		return false;
+
+	total_h_pixel = V4L2_DV_BT_FRAME_WIDTH(bt);
+	total_v_lines = V4L2_DV_BT_FRAME_HEIGHT(bt);
+
+	h_freq = (u32)bt->pixelclock / total_h_pixel;
+
+	if (bt->standards == V4L2_DV_BT_STD_CVT)
+		return v4l2_detect_cvt(total_v_lines, h_freq, bt->vsync,
+				       bt->polarities, timings);
+
+	if (bt->standards == V4L2_DV_BT_STD_GTF) {
+		struct v4l2_fract aspect_ratio;
+
+		find_aspect_ratio(bt->width, bt->height,
+				  &aspect_ratio.numerator,
+				  &aspect_ratio.denominator);
+		return v4l2_detect_gtf(total_v_lines, h_freq, bt->vsync,
+				       bt->polarities, aspect_ratio, timings);
+	}
+
+	return false;
+}
+
 int vivid_vid_cap_s_dv_timings(struct file *file, void *_fh,
 				    struct v4l2_dv_timings *timings)
 {
@@ -1561,8 +1618,10 @@ int vivid_vid_cap_s_dv_timings(struct file *file, void *_fh,
 		return -ENODATA;
 	if (vb2_is_busy(&dev->vb_vid_cap_q))
 		return -EBUSY;
+
 	if (!v4l2_find_dv_timings_cap(timings, &vivid_dv_timings_cap,
-				0, NULL, NULL))
+				      0, NULL, NULL)
+	    && !valid_cvt_gtf_timings(timings))
 		return -EINVAL;
 	if (v4l2_match_dv_timings(timings, &dev->dv_timings_cap, 0))
 		return 0;
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-03-20 14:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-20  6:41 Support for CVT and GTF timings in vivid Prashant Laddha
2015-03-20  6:41 ` [PATCH 1/2] vivid: add CVT,GTF standards to vivid dv timings caps Prashant Laddha
2015-03-20  6:41 ` [PATCH 2/2] vivid: add support to set CVT, GTF timings Prashant Laddha
2015-03-20 11:20   ` Hans Verkuil
     [not found] <Re: [PATCH 2/2] vivid: add support to set CVT, GTF timings>
2015-03-20 14:31 ` Prashant Laddha
2015-03-20 14:31   ` [PATCH 2/2] vivid: add support to set CVT, GTF timings Prashant Laddha

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.