}
static int
-isp_video_set_format(struct file *file, void *fh, struct v4l2_format *format)
+isp_video_try_format(struct file *file, void *fh, struct v4l2_format *format)
{
- struct isp_video_fh *vfh = file_to_isp_video_fh(file);
struct isp_video *video = video_drvdata(file);
- struct v4l2_mbus_framefmt fmt;
+ struct v4l2_subdev_format fmt = {
+ .which = V4L2_SUBDEV_FORMAT_ACTIVE,
+ };
+ struct v4l2_subdev *subdev;
+ u32 pad;
+ int ret;
if (format->type != video->type)
return -EINVAL;
break;
}
- /* Fill the bytesperline and sizeimage fields by converting to media bus
- * format and back to pixel format.
- */
- isp_video_pix_to_mbus(&format->fmt.pix, &fmt);
- isp_video_mbus_to_pix(video, &fmt, &format->fmt.pix);
-
- mutex_lock(&video->mutex);
- vfh->format = *format;
- mutex_unlock(&video->mutex);
-
- return 0;
-}
-
-static int
-isp_video_try_format(struct file *file, void *fh, struct v4l2_format *format)
-{
- struct isp_video *video = video_drvdata(file);
- struct v4l2_subdev_format fmt = {
- .which = V4L2_SUBDEV_FORMAT_ACTIVE,
- };
- struct v4l2_subdev *subdev;
- u32 pad;
- int ret;
-
- if (format->type != video->type)
- return -EINVAL;
+ if (video->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) {
+ isp_video_pix_to_mbus(&format->fmt.pix, &fmt.format);
+ isp_video_mbus_to_pix(video, &fmt.format, &format->fmt.pix);
+ return 0;
+ }
subdev = isp_video_remote_subdev(video, &pad);
if (subdev == NULL)
return 0;
}
+static int
+isp_video_set_format(struct file *file, void *fh, struct v4l2_format *format)
+{
+ struct isp_video_fh *vfh = file_to_isp_video_fh(file);
+ struct isp_video *video = video_drvdata(file);
+ int ret;
+
+ ret = isp_video_try_format(file, fh, format);
+ if (ret)
+ return ret;
+
+ mutex_lock(&video->mutex);
+ vfh->format = *format;
+ mutex_unlock(&video->mutex);
+
+ return 0;
+}
+
static int
isp_video_get_selection(struct file *file, void *fh, struct v4l2_selection *sel)
{