linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] properly report a single frame rate of 60 FPS
@ 2016-05-13 22:19 Florian Echtler
  2016-05-13 22:19 ` [PATCH 2/3] lower poll interval to fix occasional FPS drops to ~56 FPS Florian Echtler
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Florian Echtler @ 2016-05-13 22:19 UTC (permalink / raw)
  To: linux-media; +Cc: hverkuil, Florian Echtler, Martin Kaltenbrunner

The device hardware is always running at 60 FPS, so report this both via
PARM_IOCTL and ENUM_FRAMEINTERVALS.

Signed-off-by: Martin Kaltenbrunner <modin@yuri.at>
Signed-off-by: Florian Echtler <floe@butterbrot.org>
---
 drivers/input/touchscreen/sur40.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/drivers/input/touchscreen/sur40.c b/drivers/input/touchscreen/sur40.c
index 880c40b..fcc5934 100644
--- a/drivers/input/touchscreen/sur40.c
+++ b/drivers/input/touchscreen/sur40.c
@@ -788,6 +788,16 @@ static int sur40_vidioc_fmt(struct file *file, void *priv,
 	return 0;
 }
 
+static int sur40_ioctl_parm(struct file *file, void *priv,
+			    struct v4l2_streamparm *p)
+{
+	if (p->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
+		p->parm.capture.timeperframe.numerator = 1;
+		p->parm.capture.timeperframe.denominator = 60;
+	}
+	return 0;
+}
+
 static int sur40_vidioc_enum_fmt(struct file *file, void *priv,
 				 struct v4l2_fmtdesc *f)
 {
@@ -814,13 +824,13 @@ static int sur40_vidioc_enum_framesizes(struct file *file, void *priv,
 static int sur40_vidioc_enum_frameintervals(struct file *file, void *priv,
 					    struct v4l2_frmivalenum *f)
 {
-	if ((f->index > 1) || (f->pixel_format != V4L2_PIX_FMT_GREY)
+	if ((f->index > 0) || (f->pixel_format != V4L2_PIX_FMT_GREY)
 		|| (f->width  != sur40_video_format.width)
 		|| (f->height != sur40_video_format.height))
 			return -EINVAL;
 
 	f->type = V4L2_FRMIVAL_TYPE_DISCRETE;
-	f->discrete.denominator  = 60/(f->index+1);
+	f->discrete.denominator  = 60;
 	f->discrete.numerator = 1;
 	return 0;
 }
@@ -880,6 +890,9 @@ static const struct v4l2_ioctl_ops sur40_video_ioctl_ops = {
 	.vidioc_enum_framesizes = sur40_vidioc_enum_framesizes,
 	.vidioc_enum_frameintervals = sur40_vidioc_enum_frameintervals,
 
+	.vidioc_g_parm = sur40_ioctl_parm,
+	.vidioc_s_parm = sur40_ioctl_parm,
+
 	.vidioc_enum_input	= sur40_vidioc_enum_input,
 	.vidioc_g_input		= sur40_vidioc_g_input,
 	.vidioc_s_input		= sur40_vidioc_s_input,
-- 
1.9.1


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

* [PATCH 2/3] lower poll interval to fix occasional FPS drops to ~56 FPS
  2016-05-13 22:19 [PATCH 1/3] properly report a single frame rate of 60 FPS Florian Echtler
@ 2016-05-13 22:19 ` Florian Echtler
  2016-05-13 22:19 ` [PATCH 3/3] fix occasional oopses on device close Florian Echtler
  2016-05-23 10:45 ` [PATCH 1/3] properly report a single frame rate of 60 FPS Hans Verkuil
  2 siblings, 0 replies; 5+ messages in thread
From: Florian Echtler @ 2016-05-13 22:19 UTC (permalink / raw)
  To: linux-media; +Cc: hverkuil, Florian Echtler, Martin Kaltenbrunner

The framerate sometimes drops below 60 Hz if the poll interval is too high.
Lowering it to the minimum of 1 ms fixes this.

Signed-off-by: Martin Kaltenbrunner <modin@yuri.at>
Signed-off-by: Florian Echtler <floe@butterbrot.org>
---
 drivers/input/touchscreen/sur40.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/input/touchscreen/sur40.c b/drivers/input/touchscreen/sur40.c
index fcc5934..7b1052a1 100644
--- a/drivers/input/touchscreen/sur40.c
+++ b/drivers/input/touchscreen/sur40.c
@@ -126,7 +126,7 @@ struct sur40_image_header {
 #define VIDEO_PACKET_SIZE  16384
 
 /* polling interval (ms) */
-#define POLL_INTERVAL 4
+#define POLL_INTERVAL 1
 
 /* maximum number of contacts FIXME: this is a guess? */
 #define MAX_CONTACTS 64
-- 
1.9.1


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

* [PATCH 3/3] fix occasional oopses on device close
  2016-05-13 22:19 [PATCH 1/3] properly report a single frame rate of 60 FPS Florian Echtler
  2016-05-13 22:19 ` [PATCH 2/3] lower poll interval to fix occasional FPS drops to ~56 FPS Florian Echtler
@ 2016-05-13 22:19 ` Florian Echtler
  2016-05-23 10:45 ` [PATCH 1/3] properly report a single frame rate of 60 FPS Hans Verkuil
  2 siblings, 0 replies; 5+ messages in thread
From: Florian Echtler @ 2016-05-13 22:19 UTC (permalink / raw)
  To: linux-media; +Cc: hverkuil, Florian Echtler, Martin Kaltenbrunner

Closing the V4L2 device sometimes triggers a kernel oops.
Present patch fixes this.

Signed-off-by: Martin Kaltenbrunner <modin@yuri.at>
Signed-off-by: Florian Echtler <floe@butterbrot.org>
---
 drivers/input/touchscreen/sur40.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/input/touchscreen/sur40.c b/drivers/input/touchscreen/sur40.c
index 7b1052a1..38ebb24 100644
--- a/drivers/input/touchscreen/sur40.c
+++ b/drivers/input/touchscreen/sur40.c
@@ -448,7 +448,7 @@ static void sur40_process_video(struct sur40_state *sur40)
 
 	/* return error if streaming was stopped in the meantime */
 	if (sur40->sequence == -1)
-		goto err_poll;
+		return;
 
 	/* mark as finished */
 	new_buf->vb.vb2_buf.timestamp = ktime_get_ns();
@@ -736,6 +736,7 @@ static int sur40_start_streaming(struct vb2_queue *vq, unsigned int count)
 static void sur40_stop_streaming(struct vb2_queue *vq)
 {
 	struct sur40_state *sur40 = vb2_get_drv_priv(vq);
+	vb2_wait_for_all_buffers(vq);
 	sur40->sequence = -1;
 
 	/* Release all active buffers */
-- 
1.9.1


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

* Re: [PATCH 1/3] properly report a single frame rate of 60 FPS
  2016-05-13 22:19 [PATCH 1/3] properly report a single frame rate of 60 FPS Florian Echtler
  2016-05-13 22:19 ` [PATCH 2/3] lower poll interval to fix occasional FPS drops to ~56 FPS Florian Echtler
  2016-05-13 22:19 ` [PATCH 3/3] fix occasional oopses on device close Florian Echtler
@ 2016-05-23 10:45 ` Hans Verkuil
  2016-05-30  7:54   ` Florian Echtler
  2 siblings, 1 reply; 5+ messages in thread
From: Hans Verkuil @ 2016-05-23 10:45 UTC (permalink / raw)
  To: Florian Echtler, linux-media; +Cc: Martin Kaltenbrunner

On 05/14/2016 12:19 AM, Florian Echtler wrote:
> The device hardware is always running at 60 FPS, so report this both via
> PARM_IOCTL and ENUM_FRAMEINTERVALS.
> 
> Signed-off-by: Martin Kaltenbrunner <modin@yuri.at>
> Signed-off-by: Florian Echtler <floe@butterbrot.org>
> ---
>  drivers/input/touchscreen/sur40.c | 17 +++++++++++++++--
>  1 file changed, 15 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/sur40.c b/drivers/input/touchscreen/sur40.c
> index 880c40b..fcc5934 100644
> --- a/drivers/input/touchscreen/sur40.c
> +++ b/drivers/input/touchscreen/sur40.c
> @@ -788,6 +788,16 @@ static int sur40_vidioc_fmt(struct file *file, void *priv,
>  	return 0;
>  }
>  
> +static int sur40_ioctl_parm(struct file *file, void *priv,
> +			    struct v4l2_streamparm *p)
> +{
> +	if (p->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
> +		p->parm.capture.timeperframe.numerator = 1;
> +		p->parm.capture.timeperframe.denominator = 60;
> +	}

It should return -EINVAL if it is not of type VIDEO_CAPTURE. You should also set the
V4L2_CAP_TIMEPERFRAME capability for this to work. The readbuffers field should also
be set (typically to the minimum required number of buffers).

Please check with v4l2-compliance! It would have warned about these issues.

> +	return 0;
> +}
> +
>  static int sur40_vidioc_enum_fmt(struct file *file, void *priv,
>  				 struct v4l2_fmtdesc *f)
>  {
> @@ -814,13 +824,13 @@ static int sur40_vidioc_enum_framesizes(struct file *file, void *priv,
>  static int sur40_vidioc_enum_frameintervals(struct file *file, void *priv,
>  					    struct v4l2_frmivalenum *f)
>  {
> -	if ((f->index > 1) || (f->pixel_format != V4L2_PIX_FMT_GREY)
> +	if ((f->index > 0) || (f->pixel_format != V4L2_PIX_FMT_GREY)
>  		|| (f->width  != sur40_video_format.width)
>  		|| (f->height != sur40_video_format.height))
>  			return -EINVAL;
>  
>  	f->type = V4L2_FRMIVAL_TYPE_DISCRETE;
> -	f->discrete.denominator  = 60/(f->index+1);
> +	f->discrete.denominator  = 60;
>  	f->discrete.numerator = 1;
>  	return 0;
>  }
> @@ -880,6 +890,9 @@ static const struct v4l2_ioctl_ops sur40_video_ioctl_ops = {
>  	.vidioc_enum_framesizes = sur40_vidioc_enum_framesizes,
>  	.vidioc_enum_frameintervals = sur40_vidioc_enum_frameintervals,
>  
> +	.vidioc_g_parm = sur40_ioctl_parm,
> +	.vidioc_s_parm = sur40_ioctl_parm,
> +
>  	.vidioc_enum_input	= sur40_vidioc_enum_input,
>  	.vidioc_g_input		= sur40_vidioc_g_input,
>  	.vidioc_s_input		= sur40_vidioc_s_input,
> 

Regards,

	Hans

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

* Re: [PATCH 1/3] properly report a single frame rate of 60 FPS
  2016-05-23 10:45 ` [PATCH 1/3] properly report a single frame rate of 60 FPS Hans Verkuil
@ 2016-05-30  7:54   ` Florian Echtler
  0 siblings, 0 replies; 5+ messages in thread
From: Florian Echtler @ 2016-05-30  7:54 UTC (permalink / raw)
  To: Hans Verkuil, linux-media; +Cc: Martin Kaltenbrunner


[-- Attachment #1.1: Type: text/plain, Size: 916 bytes --]

Hello Hans,

On 23.05.2016 12:45, Hans Verkuil wrote:
>> +static int sur40_ioctl_parm(struct file *file, void *priv,
>> +			    struct v4l2_streamparm *p)
>> +{
>> +	if (p->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
>> +		p->parm.capture.timeperframe.numerator = 1;
>> +		p->parm.capture.timeperframe.denominator = 60;
>> +	}
> 
> It should return -EINVAL if it is not of type VIDEO_CAPTURE. You should also set the
> V4L2_CAP_TIMEPERFRAME capability for this to work. The readbuffers field should also
> be set (typically to the minimum required number of buffers).

One question: should this be the same number of buffers as reported in
sur40_queue_setup (i.e. 3)? And is this still relevant with the pending
changes to alloc_ctx?

> Please check with v4l2-compliance! It would have warned about these issues.
Sorry for the noise (again ;-)

Best, Florian
-- 
SENT FROM MY DEC VT50 TERMINAL


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

end of thread, other threads:[~2016-05-30 12:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-13 22:19 [PATCH 1/3] properly report a single frame rate of 60 FPS Florian Echtler
2016-05-13 22:19 ` [PATCH 2/3] lower poll interval to fix occasional FPS drops to ~56 FPS Florian Echtler
2016-05-13 22:19 ` [PATCH 3/3] fix occasional oopses on device close Florian Echtler
2016-05-23 10:45 ` [PATCH 1/3] properly report a single frame rate of 60 FPS Hans Verkuil
2016-05-30  7:54   ` Florian Echtler

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).