From 14ddd592a6fcba2ceb751c0d4b0a3b5d46f2a59f Mon Sep 17 00:00:00 2001 From: Todor Tomov Date: Tue, 25 Jan 2011 17:46:48 +0200 Subject: Add v4l2_subdev_get_frame_interval() Add function to get frame interval. Signed-off-by: Todor Tomov --- subdev.c | 20 ++++++++++++++++++++ subdev.h | 17 +++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/subdev.c b/subdev.c index 3a8e82a..3960d05 100644 --- a/subdev.c +++ b/subdev.c @@ -145,6 +145,26 @@ int v4l2_subdev_set_crop(struct media_entity *entity, struct v4l2_rect *rect, return 0; } +int v4l2_subdev_get_frame_interval(struct media_entity *entity, + struct v4l2_fract *interval) +{ + struct v4l2_subdev_frame_interval ival; + int ret; + + ret = v4l2_subdev_open(entity); + if (ret < 0) + return ret; + + memset(&ival, 0, sizeof(ival)); + + ret = ioctl(entity->fd, VIDIOC_SUBDEV_G_FRAME_INTERVAL, &ival); + if (ret < 0) + return -errno; + + *interval = ival.interval; + return 0; +} + int v4l2_subdev_set_frame_interval(struct media_entity *entity, struct v4l2_fract *interval) { diff --git a/subdev.h b/subdev.h index 9451b12..b5772e0 100644 --- a/subdev.h +++ b/subdev.h @@ -124,6 +124,23 @@ int v4l2_subdev_get_crop(struct media_entity *entity, struct v4l2_rect *rect, int v4l2_subdev_set_crop(struct media_entity *entity, struct v4l2_rect *rect, unsigned int pad, enum v4l2_subdev_format_whence which); +/** + * @brief Retrieve the frame interval on a sub-device. + * @param entity - subdev-device media entity. + * @param interval - frame interval to be filled. + * + * Retrieve the current frame interval on subdev @a entity and store it in the + * @a interval structure. + * + * Frame interval retrieving is usually supported only on devices at the + * beginning of video pipelines, such as sensors. + * + * @return 0 on success, or a negative error code on failure. + */ + +int v4l2_subdev_get_frame_interval(struct media_entity *entity, + struct v4l2_fract *interval); + /** * @brief Set the frame interval on a sub-device. * @param entity - subdev-device media entity. -- cgit v1.2.3