diff options
Diffstat (limited to 'drivers/media/platform/davinci')
-rw-r--r-- | drivers/media/platform/davinci/vpbe_display.c | 65 | ||||
-rw-r--r-- | drivers/media/platform/davinci/vpfe_capture.c | 52 |
2 files changed, 71 insertions, 46 deletions
diff --git a/drivers/media/platform/davinci/vpbe_display.c b/drivers/media/platform/davinci/vpbe_display.c index 0b1709e96673..a9bc0175e4d3 100644 --- a/drivers/media/platform/davinci/vpbe_display.c +++ b/drivers/media/platform/davinci/vpbe_display.c @@ -440,7 +440,7 @@ vpbe_disp_calculate_scale_factor(struct vpbe_display *disp_dev, /* * Application initially set the image format. Current display * size is obtained from the vpbe display controller. expected_xsize - * and expected_ysize are set through S_CROP ioctl. Based on this, + * and expected_ysize are set through S_SELECTION ioctl. Based on this, * driver will calculate the scale factors for vertical and * horizontal direction so that the image is displayed scaled * and expanded. Application uses expansion to display the image @@ -649,24 +649,23 @@ static int vpbe_display_querycap(struct file *file, void *priv, return 0; } -static int vpbe_display_s_crop(struct file *file, void *priv, - const struct v4l2_crop *crop) +static int vpbe_display_s_selection(struct file *file, void *priv, + struct v4l2_selection *sel) { struct vpbe_layer *layer = video_drvdata(file); struct vpbe_display *disp_dev = layer->disp_dev; struct vpbe_device *vpbe_dev = disp_dev->vpbe_dev; struct osd_layer_config *cfg = &layer->layer_info.config; struct osd_state *osd_device = disp_dev->osd_device; - struct v4l2_rect rect = crop->c; + struct v4l2_rect rect = sel->r; int ret; v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, - "VIDIOC_S_CROP, layer id = %d\n", layer->device_id); + "VIDIOC_S_SELECTION, layer id = %d\n", layer->device_id); - if (crop->type != V4L2_BUF_TYPE_VIDEO_OUTPUT) { - v4l2_err(&vpbe_dev->v4l2_dev, "Invalid buf type\n"); + if (sel->type != V4L2_BUF_TYPE_VIDEO_OUTPUT || + sel->target != V4L2_SEL_TGT_CROP) return -EINVAL; - } if (rect.top < 0) rect.top = 0; @@ -714,32 +713,45 @@ static int vpbe_display_s_crop(struct file *file, void *priv, else osd_device->ops.set_interpolation_filter(osd_device, 0); + sel->r = rect; return 0; } -static int vpbe_display_g_crop(struct file *file, void *priv, - struct v4l2_crop *crop) +static int vpbe_display_g_selection(struct file *file, void *priv, + struct v4l2_selection *sel) { struct vpbe_layer *layer = video_drvdata(file); struct osd_layer_config *cfg = &layer->layer_info.config; struct vpbe_device *vpbe_dev = layer->disp_dev->vpbe_dev; struct osd_state *osd_device = layer->disp_dev->osd_device; - struct v4l2_rect *rect = &crop->c; + struct v4l2_rect *rect = &sel->r; v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, - "VIDIOC_G_CROP, layer id = %d\n", + "VIDIOC_G_SELECTION, layer id = %d\n", layer->device_id); - if (crop->type != V4L2_BUF_TYPE_VIDEO_OUTPUT) { - v4l2_err(&vpbe_dev->v4l2_dev, "Invalid buf type\n"); + if (sel->type != V4L2_BUF_TYPE_VIDEO_OUTPUT) + return -EINVAL; + + switch (sel->target) { + case V4L2_SEL_TGT_CROP: + osd_device->ops.get_layer_config(osd_device, + layer->layer_info.id, cfg); + rect->top = cfg->ypos; + rect->left = cfg->xpos; + rect->width = cfg->xsize; + rect->height = cfg->ysize; + break; + case V4L2_SEL_TGT_CROP_DEFAULT: + case V4L2_SEL_TGT_CROP_BOUNDS: + rect->left = 0; + rect->top = 0; + rect->width = vpbe_dev->current_timings.xres; + rect->height = vpbe_dev->current_timings.yres; + break; + default: return -EINVAL; } - osd_device->ops.get_layer_config(osd_device, - layer->layer_info.id, cfg); - rect->top = cfg->ypos; - rect->left = cfg->xpos; - rect->width = cfg->xsize; - rect->height = cfg->ysize; return 0; } @@ -752,13 +764,10 @@ static int vpbe_display_cropcap(struct file *file, void *priv, v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "VIDIOC_CROPCAP ioctl\n"); - cropcap->type = V4L2_BUF_TYPE_VIDEO_OUTPUT; - cropcap->bounds.left = 0; - cropcap->bounds.top = 0; - cropcap->bounds.width = vpbe_dev->current_timings.xres; - cropcap->bounds.height = vpbe_dev->current_timings.yres; + if (cropcap->type != V4L2_BUF_TYPE_VIDEO_OUTPUT) + return -EINVAL; + cropcap->pixelaspect = vpbe_dev->current_timings.aspect; - cropcap->defrect = cropcap->bounds; return 0; } @@ -1251,8 +1260,8 @@ static const struct v4l2_ioctl_ops vpbe_ioctl_ops = { .vidioc_expbuf = vb2_ioctl_expbuf, .vidioc_cropcap = vpbe_display_cropcap, - .vidioc_g_crop = vpbe_display_g_crop, - .vidioc_s_crop = vpbe_display_s_crop, + .vidioc_g_selection = vpbe_display_g_selection, + .vidioc_s_selection = vpbe_display_s_selection, .vidioc_s_std = vpbe_display_s_std, .vidioc_g_std = vpbe_display_g_std, diff --git a/drivers/media/platform/davinci/vpfe_capture.c b/drivers/media/platform/davinci/vpfe_capture.c index 7767e072d623..6efb2f1631c4 100644 --- a/drivers/media/platform/davinci/vpfe_capture.c +++ b/drivers/media/platform/davinci/vpfe_capture.c @@ -1610,38 +1610,53 @@ static int vpfe_cropcap(struct file *file, void *priv, v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_cropcap\n"); - if (vpfe_dev->std_index >= ARRAY_SIZE(vpfe_standards)) + if (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) return -EINVAL; + /* If std_index is invalid, then just return (== 1:1 aspect) */ + if (vpfe_dev->std_index >= ARRAY_SIZE(vpfe_standards)) + return 0; - memset(crop, 0, sizeof(struct v4l2_cropcap)); - crop->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - crop->bounds.width = crop->defrect.width = - vpfe_standards[vpfe_dev->std_index].width; - crop->bounds.height = crop->defrect.height = - vpfe_standards[vpfe_dev->std_index].height; crop->pixelaspect = vpfe_standards[vpfe_dev->std_index].pixelaspect; return 0; } -static int vpfe_g_crop(struct file *file, void *priv, - struct v4l2_crop *crop) +static int vpfe_g_selection(struct file *file, void *priv, + struct v4l2_selection *sel) { struct vpfe_device *vpfe_dev = video_drvdata(file); - v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_g_crop\n"); + v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_g_selection\n"); - crop->c = vpfe_dev->crop; + if (sel->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) + return -EINVAL; + + switch (sel->target) { + case V4L2_SEL_TGT_CROP: + sel->r = vpfe_dev->crop; + break; + case V4L2_SEL_TGT_CROP_DEFAULT: + case V4L2_SEL_TGT_CROP_BOUNDS: + sel->r.width = vpfe_standards[vpfe_dev->std_index].width; + sel->r.height = vpfe_standards[vpfe_dev->std_index].height; + break; + default: + return -EINVAL; + } return 0; } -static int vpfe_s_crop(struct file *file, void *priv, - const struct v4l2_crop *crop) +static int vpfe_s_selection(struct file *file, void *priv, + struct v4l2_selection *sel) { struct vpfe_device *vpfe_dev = video_drvdata(file); - struct v4l2_rect rect = crop->c; + struct v4l2_rect rect = sel->r; int ret = 0; - v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_s_crop\n"); + v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_s_selection\n"); + + if (sel->type != V4L2_BUF_TYPE_VIDEO_CAPTURE || + sel->target != V4L2_SEL_TGT_CROP) + return -EINVAL; if (vpfe_dev->started) { /* make sure streaming is not started */ @@ -1669,7 +1684,7 @@ static int vpfe_s_crop(struct file *file, void *priv, vpfe_dev->std_info.active_pixels) || (rect.top + rect.height > vpfe_dev->std_info.active_lines)) { - v4l2_err(&vpfe_dev->v4l2_dev, "Error in S_CROP params\n"); + v4l2_err(&vpfe_dev->v4l2_dev, "Error in S_SELECTION params\n"); ret = -EINVAL; goto unlock_out; } @@ -1682,6 +1697,7 @@ static int vpfe_s_crop(struct file *file, void *priv, vpfe_dev->fmt.fmt.pix.bytesperline * vpfe_dev->fmt.fmt.pix.height; vpfe_dev->crop = rect; + sel->r = rect; unlock_out: mutex_unlock(&vpfe_dev->lock); return ret; @@ -1760,8 +1776,8 @@ static const struct v4l2_ioctl_ops vpfe_ioctl_ops = { .vidioc_streamon = vpfe_streamon, .vidioc_streamoff = vpfe_streamoff, .vidioc_cropcap = vpfe_cropcap, - .vidioc_g_crop = vpfe_g_crop, - .vidioc_s_crop = vpfe_s_crop, + .vidioc_g_selection = vpfe_g_selection, + .vidioc_s_selection = vpfe_s_selection, .vidioc_default = vpfe_param_handler, }; |