mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-09 16:07:17 -04:00
media: rkisp1: Implement s_fmt/try_fmt
Implement in the rkisp1 driver support for the s_fmt and try_fmt operation to allow userspace to select between the extensible and the fixed parameters formats. Implement enum_mbus_code to enumerate the fixed and the extensible formats and disallow changing the data format while the queue is busy. Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
committed by
Laurent Pinchart
parent
6c53a7b68c
commit
f848c0312e
@@ -75,6 +75,17 @@ static const struct v4l2_meta_format rkisp1_params_formats[] = {
|
||||
},
|
||||
};
|
||||
|
||||
static const struct v4l2_meta_format *
|
||||
rkisp1_params_get_format_info(u32 dataformat)
|
||||
{
|
||||
for (unsigned int i = 0; i < ARRAY_SIZE(rkisp1_params_formats); i++) {
|
||||
if (rkisp1_params_formats[i].dataformat == dataformat)
|
||||
return &rkisp1_params_formats[i];
|
||||
}
|
||||
|
||||
return &rkisp1_params_formats[RKISP1_PARAMS_FIXED];
|
||||
}
|
||||
|
||||
static inline void
|
||||
rkisp1_param_set_bits(struct rkisp1_params *params, u32 reg, u32 bit_mask)
|
||||
{
|
||||
@@ -2244,12 +2255,12 @@ static int rkisp1_params_enum_fmt_meta_out(struct file *file, void *priv,
|
||||
struct v4l2_fmtdesc *f)
|
||||
{
|
||||
struct video_device *video = video_devdata(file);
|
||||
struct rkisp1_params *params = video_get_drvdata(video);
|
||||
|
||||
if (f->index > 0 || f->type != video->queue->type)
|
||||
if (f->index >= ARRAY_SIZE(rkisp1_params_formats) ||
|
||||
f->type != video->queue->type)
|
||||
return -EINVAL;
|
||||
|
||||
f->pixelformat = params->metafmt->dataformat;
|
||||
f->pixelformat = rkisp1_params_formats[f->index].dataformat;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -2264,9 +2275,40 @@ static int rkisp1_params_g_fmt_meta_out(struct file *file, void *fh,
|
||||
if (f->type != video->queue->type)
|
||||
return -EINVAL;
|
||||
|
||||
memset(meta, 0, sizeof(*meta));
|
||||
meta->dataformat = params->metafmt->dataformat;
|
||||
meta->buffersize = params->metafmt->buffersize;
|
||||
*meta = *params->metafmt;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rkisp1_params_try_fmt_meta_out(struct file *file, void *fh,
|
||||
struct v4l2_format *f)
|
||||
{
|
||||
struct video_device *video = video_devdata(file);
|
||||
struct v4l2_meta_format *meta = &f->fmt.meta;
|
||||
|
||||
if (f->type != video->queue->type)
|
||||
return -EINVAL;
|
||||
|
||||
*meta = *rkisp1_params_get_format_info(meta->dataformat);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rkisp1_params_s_fmt_meta_out(struct file *file, void *fh,
|
||||
struct v4l2_format *f)
|
||||
{
|
||||
struct video_device *video = video_devdata(file);
|
||||
struct rkisp1_params *params = video_get_drvdata(video);
|
||||
struct v4l2_meta_format *meta = &f->fmt.meta;
|
||||
|
||||
if (f->type != video->queue->type)
|
||||
return -EINVAL;
|
||||
|
||||
if (vb2_is_busy(video->queue))
|
||||
return -EBUSY;
|
||||
|
||||
params->metafmt = rkisp1_params_get_format_info(meta->dataformat);
|
||||
*meta = *params->metafmt;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -2296,8 +2338,8 @@ static const struct v4l2_ioctl_ops rkisp1_params_ioctl = {
|
||||
.vidioc_streamoff = vb2_ioctl_streamoff,
|
||||
.vidioc_enum_fmt_meta_out = rkisp1_params_enum_fmt_meta_out,
|
||||
.vidioc_g_fmt_meta_out = rkisp1_params_g_fmt_meta_out,
|
||||
.vidioc_s_fmt_meta_out = rkisp1_params_g_fmt_meta_out,
|
||||
.vidioc_try_fmt_meta_out = rkisp1_params_g_fmt_meta_out,
|
||||
.vidioc_s_fmt_meta_out = rkisp1_params_s_fmt_meta_out,
|
||||
.vidioc_try_fmt_meta_out = rkisp1_params_try_fmt_meta_out,
|
||||
.vidioc_querycap = rkisp1_params_querycap,
|
||||
.vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
|
||||
.vidioc_unsubscribe_event = v4l2_event_unsubscribe,
|
||||
|
||||
Reference in New Issue
Block a user