On Fri, Nov 16, 2012 at 02:38:09PM +0100, Hans Verkuil wrote:
On Wed November 7 2012 12:30:01 Kirill Smelkov wrote:
[...]
diff --git a/drivers/media/platform/vivi.c b/drivers/media/platform/vivi.c
index 37d0af8..5d1b374 100644
--- a/drivers/media/platform/vivi.c
+++ b/drivers/media/platform/vivi.c
@@ -65,8 +65,11 @@ MODULE_PARM_DESC(vid_limit, capture memory limit in
megabytes);
/* Global font descriptor */
static const u8 *font8x16;
-/* default to NTSC timeperframe */
-static const struct v4l2_fract TPF_DEFAULT = {.numerator = 1001,
.denominator = 3};
+/* timeperframe: min/max and default */
+static const struct v4l2_fract
+ tpf_min = {.numerator = 1, .denominator = UINT_MAX}, /*
1/infty */
+ tpf_max = {.numerator = UINT_MAX, .denominator = 1}, /*
infty */
I understand your reasoning here, but I wouldn't go with UINT_MAX here.
Something like
1/1000 tpf (or 1 ms) up to 86400/1 tpf (or once a day). With UINT_MAX I am
afraid we
might hit application errors when they manipulate these values. The shortest
time
between frames is 1 ms anyway.
It's the only comment I have, it looks good otherwise.
Thanks, Let's then merge it with 1/1000 - 1000/1 limit. Ok?
Thanks again,
Kirill
8
From: Kirill Smelkov k...@mns.spb.ru
Date: Tue, 23 Oct 2012 16:56:59 +0400
Subject: [PATCH v5] [media] vivi: Teach it to tune FPS
I was testing my video-over-ethernet subsystem recently, and vivi
seemed to be perfect video source for testing when one don't have lots
of capture boards and cameras. Only its framerate was hardcoded to
NTSC's 30fps, while in my country we usually use PAL (25 fps) and I
needed that to precisely simulate bandwidth.
That's why here is this patch with -enum_frameintervals() and
-{g,s}_parm() implemented as suggested by Hans Verkuil which passes
v4l2-compliance and manual testing through v4l2-ctl -P / -p fps.
Regarding newly introduced __get_format(u32 pixelformat) I decided not
to convert original get_format() to operate on fourcc codes, since = 3
places in driver need to deal with v4l2_format and otherwise it won't be
handy.
Thanks.
Signed-off-by: Kirill Smelkov k...@mns.spb.ru
---
drivers/media/platform/vivi.c | 92 ++-
1 file changed, 83 insertions(+), 9 deletions(-)
V5:
- changed 1/infty - infty/1 limits to 1/1000 - 1000/1, to avoid
hitting aplication errors when they try to manipulato those
values, as suggested by Hans Verkuil.
V4:
- corrected fival-stepwise setting and added its check to s_parm();
also cosmetics - all as per Hans Verkuil review.
V3:
- corrected issues with V4L2 spec compliance as pointed by Hans
Verkuil.
V2:
- reworked FPS setting from module param to via -{g,s}_parm() as suggested
by Hans Verkuil.
diff --git a/drivers/media/platform/vivi.c b/drivers/media/platform/vivi.c
index 6e6dd25..793d7ee 100644
--- a/drivers/media/platform/vivi.c
+++ b/drivers/media/platform/vivi.c
@@ -36,10 +36,6 @@
#define VIVI_MODULE_NAME vivi
-/* Wake up at about 30 fps */
-#define WAKE_NUMERATOR 30
-#define WAKE_DENOMINATOR 1001
-
#define MAX_WIDTH 1920
#define MAX_HEIGHT 1200
@@ -69,6 +65,12 @@ MODULE_PARM_DESC(vid_limit, capture memory limit in
megabytes);
/* Global font descriptor */
static const u8 *font8x16;
+/* timeperframe: min/max and default */
+static const struct v4l2_fract
+ tpf_min = {.numerator = 1, .denominator = 1000}, /*
~1/infty */
+ tpf_max = {.numerator = 1000, .denominator = 1}, /*
~infty */
+ tpf_default = {.numerator = 1001, .denominator = 3}; /* NTSC
*/
+
#define dprintk(dev, level, fmt, arg...) \
v4l2_dbg(level, debug, dev-v4l2_dev, fmt, ## arg)
@@ -150,14 +152,14 @@ static struct vivi_fmt formats[] = {
},
};
-static struct vivi_fmt *get_format(struct v4l2_format *f)
+static struct vivi_fmt *__get_format(u32 pixelformat)
{
struct vivi_fmt *fmt;
unsigned int k;
for (k = 0; k ARRAY_SIZE(formats); k++) {
fmt = formats[k];
- if (fmt-fourcc == f-fmt.pix.pixelformat)
+ if (fmt-fourcc == pixelformat)
break;
}
@@ -167,6 +169,11 @@ static struct vivi_fmt *get_format(struct v4l2_format *f)
return formats[k];
}
+static struct vivi_fmt *get_format(struct v4l2_format *f)
+{
+ return __get_format(f-fmt.pix.pixelformat);
+}
+
/* buffer for one video frame */
struct vivi_buffer {
/* common v4l buffer stuff -- must be first */
@@ -232,6 +239,7 @@ struct vivi_dev {
/* video capture */
struct vivi_fmt*fmt;
+ struct v4l2_fract timeperframe;
unsigned int width, height;
struct vb2_queue vb_vidq;
unsigned int field_count;
@@ -691,8 +699,8 @@ static void vivi_thread_tick