diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2015-03-04 04:48:00 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2015-03-23 15:01:15 -0400 |
commit | 17bef885249db5db921ac8cf6e23938a91a6cd7b (patch) | |
tree | 23f58ecb46904cc3fbe4f5f4fbbe53a6dc4c9735 /drivers/media/i2c/ov7670.c | |
parent | d3e4bd8e10cd70d35a59854dcdcd7280c5ed240c (diff) |
[media] v4l2-subdev: add support for the new enum_frame_interval 'which' field
Support the new 'which' field in the enum_frame_interval ops. Most drivers do not
need to be changed since they always returns the same enumeration regardless
of the 'which' field.
Tested for ov7670 and marvell-ccic on a OLPC XO-1 laptop.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Jonathan Corbet <corbet@lwn.net>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media/i2c/ov7670.c')
-rw-r--r-- | drivers/media/i2c/ov7670.c | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/drivers/media/i2c/ov7670.c b/drivers/media/i2c/ov7670.c index 957927f7a353..b9847527eb5a 100644 --- a/drivers/media/i2c/ov7670.c +++ b/drivers/media/i2c/ov7670.c | |||
@@ -1069,29 +1069,35 @@ static int ov7670_s_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *parms) | |||
1069 | 1069 | ||
1070 | static int ov7670_frame_rates[] = { 30, 15, 10, 5, 1 }; | 1070 | static int ov7670_frame_rates[] = { 30, 15, 10, 5, 1 }; |
1071 | 1071 | ||
1072 | static int ov7670_enum_frameintervals(struct v4l2_subdev *sd, | 1072 | static int ov7670_enum_frame_interval(struct v4l2_subdev *sd, |
1073 | struct v4l2_frmivalenum *interval) | 1073 | struct v4l2_subdev_pad_config *cfg, |
1074 | struct v4l2_subdev_frame_interval_enum *fie) | ||
1074 | { | 1075 | { |
1075 | if (interval->index >= ARRAY_SIZE(ov7670_frame_rates)) | 1076 | if (fie->pad) |
1076 | return -EINVAL; | 1077 | return -EINVAL; |
1077 | interval->type = V4L2_FRMIVAL_TYPE_DISCRETE; | 1078 | if (fie->index >= ARRAY_SIZE(ov7670_frame_rates)) |
1078 | interval->discrete.numerator = 1; | 1079 | return -EINVAL; |
1079 | interval->discrete.denominator = ov7670_frame_rates[interval->index]; | 1080 | fie->interval.numerator = 1; |
1081 | fie->interval.denominator = ov7670_frame_rates[fie->index]; | ||
1080 | return 0; | 1082 | return 0; |
1081 | } | 1083 | } |
1082 | 1084 | ||
1083 | /* | 1085 | /* |
1084 | * Frame size enumeration | 1086 | * Frame size enumeration |
1085 | */ | 1087 | */ |
1086 | static int ov7670_enum_framesizes(struct v4l2_subdev *sd, | 1088 | static int ov7670_enum_frame_size(struct v4l2_subdev *sd, |
1087 | struct v4l2_frmsizeenum *fsize) | 1089 | struct v4l2_subdev_pad_config *cfg, |
1090 | struct v4l2_subdev_frame_size_enum *fse) | ||
1088 | { | 1091 | { |
1089 | struct ov7670_info *info = to_state(sd); | 1092 | struct ov7670_info *info = to_state(sd); |
1090 | int i; | 1093 | int i; |
1091 | int num_valid = -1; | 1094 | int num_valid = -1; |
1092 | __u32 index = fsize->index; | 1095 | __u32 index = fse->index; |
1093 | unsigned int n_win_sizes = info->devtype->n_win_sizes; | 1096 | unsigned int n_win_sizes = info->devtype->n_win_sizes; |
1094 | 1097 | ||
1098 | if (fse->pad) | ||
1099 | return -EINVAL; | ||
1100 | |||
1095 | /* | 1101 | /* |
1096 | * If a minimum width/height was requested, filter out the capture | 1102 | * If a minimum width/height was requested, filter out the capture |
1097 | * windows that fall outside that. | 1103 | * windows that fall outside that. |
@@ -1103,9 +1109,8 @@ static int ov7670_enum_framesizes(struct v4l2_subdev *sd, | |||
1103 | if (info->min_height && win->height < info->min_height) | 1109 | if (info->min_height && win->height < info->min_height) |
1104 | continue; | 1110 | continue; |
1105 | if (index == ++num_valid) { | 1111 | if (index == ++num_valid) { |
1106 | fsize->type = V4L2_FRMSIZE_TYPE_DISCRETE; | 1112 | fse->min_width = fse->max_width = win->width; |
1107 | fsize->discrete.width = win->width; | 1113 | fse->min_height = fse->max_height = win->height; |
1108 | fsize->discrete.height = win->height; | ||
1109 | return 0; | 1114 | return 0; |
1110 | } | 1115 | } |
1111 | } | 1116 | } |
@@ -1485,13 +1490,17 @@ static const struct v4l2_subdev_video_ops ov7670_video_ops = { | |||
1485 | .s_mbus_fmt = ov7670_s_mbus_fmt, | 1490 | .s_mbus_fmt = ov7670_s_mbus_fmt, |
1486 | .s_parm = ov7670_s_parm, | 1491 | .s_parm = ov7670_s_parm, |
1487 | .g_parm = ov7670_g_parm, | 1492 | .g_parm = ov7670_g_parm, |
1488 | .enum_frameintervals = ov7670_enum_frameintervals, | 1493 | }; |
1489 | .enum_framesizes = ov7670_enum_framesizes, | 1494 | |
1495 | static const struct v4l2_subdev_pad_ops ov7670_pad_ops = { | ||
1496 | .enum_frame_interval = ov7670_enum_frame_interval, | ||
1497 | .enum_frame_size = ov7670_enum_frame_size, | ||
1490 | }; | 1498 | }; |
1491 | 1499 | ||
1492 | static const struct v4l2_subdev_ops ov7670_ops = { | 1500 | static const struct v4l2_subdev_ops ov7670_ops = { |
1493 | .core = &ov7670_core_ops, | 1501 | .core = &ov7670_core_ops, |
1494 | .video = &ov7670_video_ops, | 1502 | .video = &ov7670_video_ops, |
1503 | .pad = &ov7670_pad_ops, | ||
1495 | }; | 1504 | }; |
1496 | 1505 | ||
1497 | /* ----------------------------------------------------------------------- */ | 1506 | /* ----------------------------------------------------------------------- */ |