[media] media: tw686x: Support frame sizes and frame intervals enumeration
authorEzequiel Garcia <ezequiel@vanguardiasur.com.ar>
Mon, 22 Aug 2016 16:12:24 +0000 (13:12 -0300)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Tue, 6 Sep 2016 19:42:07 +0000 (16:42 -0300)
This commit adds support for VIDIOC_ENUM_FRAMESIZES
and VIDIOC_ENUM_FRAMEINTERVALS enumeration ioctls.

Signed-off-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
drivers/media/pci/tw686x/tw686x-video.c

index 24a813256c99e680fd8ba4a8ed4909ff6930f3b7..9621588be12c77fb6e06ffbed5b65cadf46f9881 100644 (file)
@@ -906,6 +906,42 @@ static int tw686x_g_std(struct file *file, void *priv, v4l2_std_id *id)
        return 0;
 }
 
+static int tw686x_enum_framesizes(struct file *file, void *priv,
+                                 struct v4l2_frmsizeenum *fsize)
+{
+       struct tw686x_video_channel *vc = video_drvdata(file);
+
+       if (fsize->index)
+               return -EINVAL;
+       fsize->type = V4L2_FRMSIZE_TYPE_STEPWISE;
+       fsize->stepwise.max_width = TW686X_VIDEO_WIDTH;
+       fsize->stepwise.min_width = fsize->stepwise.max_width / 2;
+       fsize->stepwise.step_width = fsize->stepwise.min_width;
+       fsize->stepwise.max_height = TW686X_VIDEO_HEIGHT(vc->video_standard);
+       fsize->stepwise.min_height = fsize->stepwise.max_height / 2;
+       fsize->stepwise.step_height = fsize->stepwise.min_height;
+       return 0;
+}
+
+static int tw686x_enum_frameintervals(struct file *file, void *priv,
+                                     struct v4l2_frmivalenum *ival)
+{
+       struct tw686x_video_channel *vc = video_drvdata(file);
+       int max_fps = TW686X_MAX_FPS(vc->video_standard);
+       int max_rates = DIV_ROUND_UP(max_fps, 2);
+
+       if (ival->index >= max_rates)
+               return -EINVAL;
+
+       ival->type = V4L2_FRMIVAL_TYPE_DISCRETE;
+       ival->discrete.numerator = 1;
+       if (ival->index < (max_rates - 1))
+               ival->discrete.denominator = (ival->index + 1) * 2;
+       else
+               ival->discrete.denominator = max_fps;
+       return 0;
+}
+
 static int tw686x_g_parm(struct file *file, void *priv,
                         struct v4l2_streamparm *sp)
 {
@@ -1034,6 +1070,8 @@ static const struct v4l2_ioctl_ops tw686x_video_ioctl_ops = {
 
        .vidioc_g_parm                  = tw686x_g_parm,
        .vidioc_s_parm                  = tw686x_s_parm,
+       .vidioc_enum_framesizes         = tw686x_enum_framesizes,
+       .vidioc_enum_frameintervals     = tw686x_enum_frameintervals,
 
        .vidioc_enum_input              = tw686x_enum_input,
        .vidioc_g_input                 = tw686x_g_input,