linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC v2 0/4] vivid: reduced fps support
@ 2015-09-22 14:27 Prashant Laddha
  2015-09-22 14:27 ` [RFC v2 1/4] v4l2-dv-timings: add condition checks for reduced fps Prashant Laddha
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Prashant Laddha @ 2015-09-22 14:27 UTC (permalink / raw)
  To: linux-media

Hi,

Please find RFC v2 for adding reduced fps support in vivid video
transmit and receive.

Changes since v1:
1. Added helper function to check if all necessary conditions for
reduced fps are met.
2. This function can now common for  vivid-vid-out and vivid-vid-cap
3. Same helper function can also be used by v4l2-dv-timings before
setting the flag for reduced fps.
4. Incorporated other review comments. Also split patches into
smaller and well separated changes.

Please review and share your comments.

Regards,
Prashant

Prashant Laddha (4):
  v4l2-dv-timings: add condition checks for reduced fps
  vivid: add support for reduced fps in video out
  vivid-capture: add control for reduced frame rate
  vivid: add support for reduced frame rate in video capture

 drivers/media/platform/vivid/vivid-core.h    |  1 +
 drivers/media/platform/vivid/vivid-ctrls.c   | 15 +++++++++++++++
 drivers/media/platform/vivid/vivid-vid-cap.c | 10 +++++++++-
 drivers/media/platform/vivid/vivid-vid-out.c |  9 ++++++++-
 drivers/media/v4l2-core/v4l2-dv-timings.c    |  5 +++++
 include/media/v4l2-dv-timings.h              | 21 +++++++++++++++++++++
 6 files changed, 59 insertions(+), 2 deletions(-)

-- 
1.9.1


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

* [RFC v2 1/4] v4l2-dv-timings: add condition checks for reduced fps
  2015-09-22 14:27 [RFC v2 0/4] vivid: reduced fps support Prashant Laddha
@ 2015-09-22 14:27 ` Prashant Laddha
  2015-09-22 14:27 ` [RFC v2 2/4] vivid: add support for reduced fps in video out Prashant Laddha
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Prashant Laddha @ 2015-09-22 14:27 UTC (permalink / raw)
  To: linux-media; +Cc: Hans Verkuil, Prashant Laddha

Added a helper function to check necessary conditions required for
reduced fps. The reduced fps is supported for CVT and CEA861 timings.
CVT supports reduced fps only if reduced blanking v2 (indicated by
vsync = 8) is true. Whereas CEA861 supports reduced fps if
V4L2_DV_FL_CAN_REDUCE_FPS flag is true.

Cc: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Prashant Laddha <prladdha@cisco.com>
---
 drivers/media/v4l2-core/v4l2-dv-timings.c |  5 +++++
 include/media/v4l2-dv-timings.h           | 21 +++++++++++++++++++++
 2 files changed, 26 insertions(+)

diff --git a/drivers/media/v4l2-core/v4l2-dv-timings.c b/drivers/media/v4l2-core/v4l2-dv-timings.c
index 6a83d61..d8e62f6 100644
--- a/drivers/media/v4l2-core/v4l2-dv-timings.c
+++ b/drivers/media/v4l2-core/v4l2-dv-timings.c
@@ -210,7 +210,12 @@ bool v4l2_find_dv_timings_cap(struct v4l2_dv_timings *t,
 					  fnc, fnc_handle) &&
 		    v4l2_match_dv_timings(t, v4l2_dv_timings_presets + i,
 					  pclock_delta)) {
+			u32 flags = t->bt.flags & V4L2_DV_FL_REDUCED_FPS;
+
 			*t = v4l2_dv_timings_presets[i];
+			if (can_reduce_fps(&t->bt))
+				t->bt.flags |= flags;
+
 			return true;
 		}
 	}
diff --git a/include/media/v4l2-dv-timings.h b/include/media/v4l2-dv-timings.h
index b6130b5..49c2328 100644
--- a/include/media/v4l2-dv-timings.h
+++ b/include/media/v4l2-dv-timings.h
@@ -183,4 +183,25 @@ bool v4l2_detect_gtf(unsigned frame_height, unsigned hfreq, unsigned vsync,
  */
 struct v4l2_fract v4l2_calc_aspect_ratio(u8 hor_landscape, u8 vert_portrait);
 
+/*
+ * reduce_fps - check if conditions for reduced fps are true.
+ * bt - v4l2 timing structure
+ * For different timings reduced fps is allowed if following conditions
+ * are met -
+ * For CVT timings: if reduced blanking v2 (vsync == 8) is true.
+ * For CEA861 timings: if V4L2_DV_FL_CAN_REDUCE_FPS flag is true.
+ */
+static inline  bool can_reduce_fps(struct v4l2_bt_timings *bt)
+{
+	if ((bt->standards & V4L2_DV_BT_STD_CVT) && (bt->vsync == 8))
+		return true;
+
+	if ((bt->standards & V4L2_DV_BT_STD_CEA861) &&
+	    (bt->flags & V4L2_DV_FL_CAN_REDUCE_FPS))
+		return true;
+
+	return false;
+}
+
+
 #endif
-- 
1.9.1


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

* [RFC v2 2/4] vivid: add support for reduced fps in video out
  2015-09-22 14:27 [RFC v2 0/4] vivid: reduced fps support Prashant Laddha
  2015-09-22 14:27 ` [RFC v2 1/4] v4l2-dv-timings: add condition checks for reduced fps Prashant Laddha
@ 2015-09-22 14:27 ` Prashant Laddha
  2015-09-22 14:27 ` [RFC v2 3/4] vivid-capture: add control for reduced frame rate Prashant Laddha
  2015-09-22 14:27 ` [RFC v2 4/4] vivid: add support for reduced frame rate in video capture Prashant Laddha
  3 siblings, 0 replies; 5+ messages in thread
From: Prashant Laddha @ 2015-09-22 14:27 UTC (permalink / raw)
  To: linux-media; +Cc: Hans Verkuil, Prashant Laddha

If reduced fps flag is set then check if other necessary conditions
are true for the given bt timing. If yes, then reduce the frame rate.
For vivid transmitter, timeperframe_vid_out controls the frame rate.
Adjusting the timeperframe_vid_out by scaling down pixel clock by
factor of 1000 / 1001.

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

diff --git a/drivers/media/platform/vivid/vivid-vid-out.c b/drivers/media/platform/vivid/vivid-vid-out.c
index c404e27..e860347 100644
--- a/drivers/media/platform/vivid/vivid-vid-out.c
+++ b/drivers/media/platform/vivid/vivid-vid-out.c
@@ -220,6 +220,7 @@ void vivid_update_format_out(struct vivid_dev *dev)
 {
 	struct v4l2_bt_timings *bt = &dev->dv_timings_out.bt;
 	unsigned size, p;
+	u64 pixelclock;
 
 	switch (dev->output_type[dev->output]) {
 	case SVID:
@@ -241,8 +242,14 @@ void vivid_update_format_out(struct vivid_dev *dev)
 		dev->sink_rect.width = bt->width;
 		dev->sink_rect.height = bt->height;
 		size = V4L2_DV_BT_FRAME_WIDTH(bt) * V4L2_DV_BT_FRAME_HEIGHT(bt);
+
+		if (can_reduce_fps(bt) && (bt->flags & V4L2_DV_FL_REDUCED_FPS))
+			pixelclock = div_u64(bt->pixelclock * 1000, 1001);
+		else
+			pixelclock = bt->pixelclock;
+
 		dev->timeperframe_vid_out = (struct v4l2_fract) {
-			size / 100, (u32)bt->pixelclock / 100
+			size / 100, (u32)pixelclock / 100
 		};
 		if (bt->interlaced)
 			dev->field_out = V4L2_FIELD_ALTERNATE;
-- 
1.9.1


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

* [RFC v2 3/4] vivid-capture: add control for reduced frame rate
  2015-09-22 14:27 [RFC v2 0/4] vivid: reduced fps support Prashant Laddha
  2015-09-22 14:27 ` [RFC v2 1/4] v4l2-dv-timings: add condition checks for reduced fps Prashant Laddha
  2015-09-22 14:27 ` [RFC v2 2/4] vivid: add support for reduced fps in video out Prashant Laddha
@ 2015-09-22 14:27 ` Prashant Laddha
  2015-09-22 14:27 ` [RFC v2 4/4] vivid: add support for reduced frame rate in video capture Prashant Laddha
  3 siblings, 0 replies; 5+ messages in thread
From: Prashant Laddha @ 2015-09-22 14:27 UTC (permalink / raw)
  To: linux-media; +Cc: Hans Verkuil, Prashant Laddha

A boolean control Reduced Framerate is added to vivid controls for
controlling the reduced fps option for vivid capture from gui.

Cc: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Prashant Laddha <prladdha@cisco.com>
---
 drivers/media/platform/vivid/vivid-core.h  |  1 +
 drivers/media/platform/vivid/vivid-ctrls.c | 15 +++++++++++++++
 2 files changed, 16 insertions(+)

diff --git a/drivers/media/platform/vivid/vivid-core.h b/drivers/media/platform/vivid/vivid-core.h
index c72349c..4a2c8b7 100644
--- a/drivers/media/platform/vivid/vivid-core.h
+++ b/drivers/media/platform/vivid/vivid-core.h
@@ -263,6 +263,7 @@ struct vivid_dev {
 	bool				vflip;
 	bool				vbi_cap_interlaced;
 	bool				loop_video;
+	bool				reduced_fps;
 
 	/* Framebuffer */
 	unsigned long			video_pbase;
diff --git a/drivers/media/platform/vivid/vivid-ctrls.c b/drivers/media/platform/vivid/vivid-ctrls.c
index 339c8b7..30d472a 100644
--- a/drivers/media/platform/vivid/vivid-ctrls.c
+++ b/drivers/media/platform/vivid/vivid-ctrls.c
@@ -78,6 +78,7 @@
 #define VIVID_CID_TIME_WRAP		(VIVID_CID_VIVID_BASE + 39)
 #define VIVID_CID_MAX_EDID_BLOCKS	(VIVID_CID_VIVID_BASE + 40)
 #define VIVID_CID_PERCENTAGE_FILL	(VIVID_CID_VIVID_BASE + 41)
+#define VIVID_CID_REDUCED_FPS		(VIVID_CID_VIVID_BASE + 42)
 
 #define VIVID_CID_STD_SIGNAL_MODE	(VIVID_CID_VIVID_BASE + 60)
 #define VIVID_CID_STANDARD		(VIVID_CID_VIVID_BASE + 61)
@@ -422,6 +423,10 @@ static int vivid_vid_cap_s_ctrl(struct v4l2_ctrl *ctrl)
 		dev->sensor_vflip = ctrl->val;
 		tpg_s_vflip(&dev->tpg, dev->sensor_vflip ^ dev->vflip);
 		break;
+	case VIVID_CID_REDUCED_FPS:
+		dev->reduced_fps = ctrl->val;
+		vivid_update_format_cap(dev, true);
+		break;
 	case VIVID_CID_HAS_CROP_CAP:
 		dev->has_crop_cap = ctrl->val;
 		vivid_update_format_cap(dev, true);
@@ -599,6 +604,15 @@ static const struct v4l2_ctrl_config vivid_ctrl_vflip = {
 	.step = 1,
 };
 
+static const struct v4l2_ctrl_config vivid_ctrl_reduced_fps = {
+	.ops = &vivid_vid_cap_ctrl_ops,
+	.id = VIVID_CID_REDUCED_FPS,
+	.name = "Reduced Framerate",
+	.type = V4L2_CTRL_TYPE_BOOLEAN,
+	.max = 1,
+	.step = 1,
+};
+
 static const struct v4l2_ctrl_config vivid_ctrl_has_crop_cap = {
 	.ops = &vivid_vid_cap_ctrl_ops,
 	.id = VIVID_CID_HAS_CROP_CAP,
@@ -1379,6 +1393,7 @@ int vivid_create_controls(struct vivid_dev *dev, bool show_ccs_cap,
 		v4l2_ctrl_new_custom(hdl_vid_cap, &vivid_ctrl_vflip, NULL);
 		v4l2_ctrl_new_custom(hdl_vid_cap, &vivid_ctrl_insert_sav, NULL);
 		v4l2_ctrl_new_custom(hdl_vid_cap, &vivid_ctrl_insert_eav, NULL);
+		v4l2_ctrl_new_custom(hdl_vid_cap, &vivid_ctrl_reduced_fps, NULL);
 		if (show_ccs_cap) {
 			dev->ctrl_has_crop_cap = v4l2_ctrl_new_custom(hdl_vid_cap,
 				&vivid_ctrl_has_crop_cap, NULL);
-- 
1.9.1


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

* [RFC v2 4/4] vivid: add support for reduced frame rate in video capture
  2015-09-22 14:27 [RFC v2 0/4] vivid: reduced fps support Prashant Laddha
                   ` (2 preceding siblings ...)
  2015-09-22 14:27 ` [RFC v2 3/4] vivid-capture: add control for reduced frame rate Prashant Laddha
@ 2015-09-22 14:27 ` Prashant Laddha
  3 siblings, 0 replies; 5+ messages in thread
From: Prashant Laddha @ 2015-09-22 14:27 UTC (permalink / raw)
  To: linux-media; +Cc: Hans Verkuil, Prashant Laddha

With this patch, vivid capture thread can now generate a video with
frame rate reduced by a factor of 1000 / 1001. This option can be
selected using a control Reduced Framerate from gui.

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

diff --git a/drivers/media/platform/vivid/vivid-vid-cap.c b/drivers/media/platform/vivid/vivid-vid-cap.c
index ed0b878..74ba98f 100644
--- a/drivers/media/platform/vivid/vivid-vid-cap.c
+++ b/drivers/media/platform/vivid/vivid-vid-cap.c
@@ -401,6 +401,7 @@ void vivid_update_format_cap(struct vivid_dev *dev, bool keep_controls)
 {
 	struct v4l2_bt_timings *bt = &dev->dv_timings_cap.bt;
 	unsigned size;
+	u64 pixelclock;
 
 	switch (dev->input_type[dev->input]) {
 	case WEBCAM:
@@ -430,8 +431,15 @@ void vivid_update_format_cap(struct vivid_dev *dev, bool keep_controls)
 		dev->src_rect.width = bt->width;
 		dev->src_rect.height = bt->height;
 		size = V4L2_DV_BT_FRAME_WIDTH(bt) * V4L2_DV_BT_FRAME_HEIGHT(bt);
+		if (dev->reduced_fps && can_reduce_fps(bt)) {
+			pixelclock = div_u64(bt->pixelclock * 1000, 1001);
+			bt->flags |= V4L2_DV_FL_REDUCED_FPS;
+		} else {
+			pixelclock = bt->pixelclock;
+			bt->flags &= ~V4L2_DV_FL_REDUCED_FPS;
+		}
 		dev->timeperframe_vid_cap = (struct v4l2_fract) {
-			size / 100, (u32)bt->pixelclock / 100
+			size / 100, (u32)pixelclock / 100
 		};
 		if (bt->interlaced)
 			dev->field_cap = V4L2_FIELD_ALTERNATE;
-- 
1.9.1


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

end of thread, other threads:[~2015-09-22 14:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-22 14:27 [RFC v2 0/4] vivid: reduced fps support Prashant Laddha
2015-09-22 14:27 ` [RFC v2 1/4] v4l2-dv-timings: add condition checks for reduced fps Prashant Laddha
2015-09-22 14:27 ` [RFC v2 2/4] vivid: add support for reduced fps in video out Prashant Laddha
2015-09-22 14:27 ` [RFC v2 3/4] vivid-capture: add control for reduced frame rate Prashant Laddha
2015-09-22 14:27 ` [RFC v2 4/4] vivid: add support for reduced frame rate in video capture Prashant Laddha

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).