aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2012-04-20 04:47:49 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-05-08 13:15:50 -0400
commit684c8e26e755c0af49c1de554f863602c1803141 (patch)
treeba38793027b7918680a37809442c7dc2a1e3b5c2 /drivers
parenta64909b806b156fd4579c948bbbdb15095f55058 (diff)
[media] omap3isp: preview: Replace the crop API by the selection API
Support for the legacy crop API is emulated in the subdev core. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Sakari Ailus <sakari.ailus@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/video/omap3isp/isppreview.c74
1 files changed, 54 insertions, 20 deletions
diff --git a/drivers/media/video/omap3isp/isppreview.c b/drivers/media/video/omap3isp/isppreview.c
index 420b131282d8..cbc887010b28 100644
--- a/drivers/media/video/omap3isp/isppreview.c
+++ b/drivers/media/video/omap3isp/isppreview.c
@@ -1929,55 +1929,89 @@ static int preview_enum_frame_size(struct v4l2_subdev *sd,
1929} 1929}
1930 1930
1931/* 1931/*
1932 * preview_get_crop - Retrieve the crop rectangle on a pad 1932 * preview_get_selection - Retrieve a selection rectangle on a pad
1933 * @sd: ISP preview V4L2 subdevice 1933 * @sd: ISP preview V4L2 subdevice
1934 * @fh: V4L2 subdev file handle 1934 * @fh: V4L2 subdev file handle
1935 * @crop: crop rectangle 1935 * @sel: Selection rectangle
1936 *
1937 * The only supported rectangles are the crop rectangles on the sink pad.
1936 * 1938 *
1937 * Return 0 on success or a negative error code otherwise. 1939 * Return 0 on success or a negative error code otherwise.
1938 */ 1940 */
1939static int preview_get_crop(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 1941static int preview_get_selection(struct v4l2_subdev *sd,
1940 struct v4l2_subdev_crop *crop) 1942 struct v4l2_subdev_fh *fh,
1943 struct v4l2_subdev_selection *sel)
1941{ 1944{
1942 struct isp_prev_device *prev = v4l2_get_subdevdata(sd); 1945 struct isp_prev_device *prev = v4l2_get_subdevdata(sd);
1946 struct v4l2_mbus_framefmt *format;
1947
1948 if (sel->pad != PREV_PAD_SINK)
1949 return -EINVAL;
1950
1951 switch (sel->target) {
1952 case V4L2_SUBDEV_SEL_TGT_CROP_BOUNDS:
1953 sel->r.left = 0;
1954 sel->r.top = 0;
1955 sel->r.width = INT_MAX;
1956 sel->r.height = INT_MAX;
1957
1958 format = __preview_get_format(prev, fh, PREV_PAD_SINK,
1959 sel->which);
1960 preview_try_crop(prev, format, &sel->r);
1961 break;
1962
1963 case V4L2_SUBDEV_SEL_TGT_CROP_ACTUAL:
1964 sel->r = *__preview_get_crop(prev, fh, sel->which);
1965 break;
1943 1966
1944 /* Cropping is only supported on the sink pad. */ 1967 default:
1945 if (crop->pad != PREV_PAD_SINK)
1946 return -EINVAL; 1968 return -EINVAL;
1969 }
1947 1970
1948 crop->rect = *__preview_get_crop(prev, fh, crop->which);
1949 return 0; 1971 return 0;
1950} 1972}
1951 1973
1952/* 1974/*
1953 * preview_set_crop - Retrieve the crop rectangle on a pad 1975 * preview_set_selection - Set a selection rectangle on a pad
1954 * @sd: ISP preview V4L2 subdevice 1976 * @sd: ISP preview V4L2 subdevice
1955 * @fh: V4L2 subdev file handle 1977 * @fh: V4L2 subdev file handle
1956 * @crop: crop rectangle 1978 * @sel: Selection rectangle
1979 *
1980 * The only supported rectangle is the actual crop rectangle on the sink pad.
1957 * 1981 *
1958 * Return 0 on success or a negative error code otherwise. 1982 * Return 0 on success or a negative error code otherwise.
1959 */ 1983 */
1960static int preview_set_crop(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh, 1984static int preview_set_selection(struct v4l2_subdev *sd,
1961 struct v4l2_subdev_crop *crop) 1985 struct v4l2_subdev_fh *fh,
1986 struct v4l2_subdev_selection *sel)
1962{ 1987{
1963 struct isp_prev_device *prev = v4l2_get_subdevdata(sd); 1988 struct isp_prev_device *prev = v4l2_get_subdevdata(sd);
1964 struct v4l2_mbus_framefmt *format; 1989 struct v4l2_mbus_framefmt *format;
1965 1990
1966 /* Cropping is only supported on the sink pad. */ 1991 if (sel->target != V4L2_SUBDEV_SEL_TGT_CROP_ACTUAL ||
1967 if (crop->pad != PREV_PAD_SINK) 1992 sel->pad != PREV_PAD_SINK)
1968 return -EINVAL; 1993 return -EINVAL;
1969 1994
1970 /* The crop rectangle can't be changed while streaming. */ 1995 /* The crop rectangle can't be changed while streaming. */
1971 if (prev->state != ISP_PIPELINE_STREAM_STOPPED) 1996 if (prev->state != ISP_PIPELINE_STREAM_STOPPED)
1972 return -EBUSY; 1997 return -EBUSY;
1973 1998
1974 format = __preview_get_format(prev, fh, PREV_PAD_SINK, crop->which); 1999 /* Modifying the crop rectangle always changes the format on the source
1975 preview_try_crop(prev, format, &crop->rect); 2000 * pad. If the KEEP_CONFIG flag is set, just return the current crop
1976 *__preview_get_crop(prev, fh, crop->which) = crop->rect; 2001 * rectangle.
2002 */
2003 if (sel->flags & V4L2_SUBDEV_SEL_FLAG_KEEP_CONFIG) {
2004 sel->r = *__preview_get_crop(prev, fh, sel->which);
2005 return 0;
2006 }
2007
2008 format = __preview_get_format(prev, fh, PREV_PAD_SINK, sel->which);
2009 preview_try_crop(prev, format, &sel->r);
2010 *__preview_get_crop(prev, fh, sel->which) = sel->r;
1977 2011
1978 /* Update the source format. */ 2012 /* Update the source format. */
1979 format = __preview_get_format(prev, fh, PREV_PAD_SOURCE, crop->which); 2013 format = __preview_get_format(prev, fh, PREV_PAD_SOURCE, sel->which);
1980 preview_try_format(prev, fh, PREV_PAD_SOURCE, format, crop->which); 2014 preview_try_format(prev, fh, PREV_PAD_SOURCE, format, sel->which);
1981 2015
1982 return 0; 2016 return 0;
1983} 2017}
@@ -2086,8 +2120,8 @@ static const struct v4l2_subdev_pad_ops preview_v4l2_pad_ops = {
2086 .enum_frame_size = preview_enum_frame_size, 2120 .enum_frame_size = preview_enum_frame_size,
2087 .get_fmt = preview_get_format, 2121 .get_fmt = preview_get_format,
2088 .set_fmt = preview_set_format, 2122 .set_fmt = preview_set_format,
2089 .get_crop = preview_get_crop, 2123 .get_selection = preview_get_selection,
2090 .set_crop = preview_set_crop, 2124 .set_selection = preview_set_selection,
2091}; 2125};
2092 2126
2093/* subdev operations */ 2127/* subdev operations */