Message ID | 20241014-qcom-video-iris-v4-v4-11-c5eaa4e9ab9e@quicinc.com |
---|---|
State | New |
Headers | show |
Series | [v4,01/28] dt-bindings: media: Add video support for QCOM SM8550 SoC | expand |
On 10/23/2024 4:15 PM, Hans Verkuil wrote: > On 14/10/2024 11:07, Dikshita Agarwal wrote: >> From: Vedang Nagar <quic_vnagar@quicinc.com> >> >> Implement g_selection ioctl in the driver with necessary hooks. >> >> Signed-off-by: Vedang Nagar <quic_vnagar@quicinc.com> >> Signed-off-by: Dikshita Agarwal <quic_dikshita@quicinc.com> >> --- >> drivers/media/platform/qcom/iris/iris_vidc.c | 29 ++++++++++++++++++++++++++++ >> 1 file changed, 29 insertions(+) >> >> diff --git a/drivers/media/platform/qcom/iris/iris_vidc.c b/drivers/media/platform/qcom/iris/iris_vidc.c >> index 05146970189b..481fa0a7b7f3 100644 >> --- a/drivers/media/platform/qcom/iris/iris_vidc.c >> +++ b/drivers/media/platform/qcom/iris/iris_vidc.c >> @@ -256,6 +256,34 @@ static int iris_g_fmt_vid_mplane(struct file *filp, void *fh, struct v4l2_format >> return ret; >> } >> >> +static int iris_g_selection(struct file *filp, void *fh, struct v4l2_selection *s) >> +{ >> + struct iris_inst *inst = iris_get_inst(filp, NULL); >> + >> + if (s->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE && > > For g/s_selection the MPLANE type will always be mapped to the non-mplane type, > so you'll never see V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE here. > > See v4l_g/s_selection in v4l2-core/v4l2-ioctl.c. > > It's a bit of an historical artifact. > I see, Will remove the check for MPLANE then and keep only for V4L2_BUF_TYPE_VIDEO_CAPTURE. Thanks, Dikshita >> + s->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) >> + return -EINVAL; >> + >> + switch (s->target) { >> + case V4L2_SEL_TGT_CROP_BOUNDS: >> + case V4L2_SEL_TGT_CROP_DEFAULT: >> + case V4L2_SEL_TGT_CROP: >> + case V4L2_SEL_TGT_COMPOSE_BOUNDS: >> + case V4L2_SEL_TGT_COMPOSE_PADDED: >> + case V4L2_SEL_TGT_COMPOSE_DEFAULT: >> + case V4L2_SEL_TGT_COMPOSE: >> + s->r.left = inst->crop.left; >> + s->r.top = inst->crop.top; >> + s->r.width = inst->crop.width; >> + s->r.height = inst->crop.height; >> + break; >> + default: >> + return -EINVAL; >> + } >> + >> + return 0; >> +} >> + >> static struct v4l2_file_operations iris_v4l2_file_ops = { >> .owner = THIS_MODULE, >> .open = iris_open, >> @@ -277,6 +305,7 @@ static const struct v4l2_ioctl_ops iris_v4l2_ioctl_ops = { >> .vidioc_g_fmt_vid_cap_mplane = iris_g_fmt_vid_mplane, >> .vidioc_g_fmt_vid_out_mplane = iris_g_fmt_vid_mplane, >> .vidioc_reqbufs = v4l2_m2m_ioctl_reqbufs, >> + .vidioc_g_selection = iris_g_selection, >> }; >> >> void iris_init_ops(struct iris_core *core) >> > > Regards, > > Hans
diff --git a/drivers/media/platform/qcom/iris/iris_vidc.c b/drivers/media/platform/qcom/iris/iris_vidc.c index 05146970189b..481fa0a7b7f3 100644 --- a/drivers/media/platform/qcom/iris/iris_vidc.c +++ b/drivers/media/platform/qcom/iris/iris_vidc.c @@ -256,6 +256,34 @@ static int iris_g_fmt_vid_mplane(struct file *filp, void *fh, struct v4l2_format return ret; } +static int iris_g_selection(struct file *filp, void *fh, struct v4l2_selection *s) +{ + struct iris_inst *inst = iris_get_inst(filp, NULL); + + if (s->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE && + s->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) + return -EINVAL; + + switch (s->target) { + case V4L2_SEL_TGT_CROP_BOUNDS: + case V4L2_SEL_TGT_CROP_DEFAULT: + case V4L2_SEL_TGT_CROP: + case V4L2_SEL_TGT_COMPOSE_BOUNDS: + case V4L2_SEL_TGT_COMPOSE_PADDED: + case V4L2_SEL_TGT_COMPOSE_DEFAULT: + case V4L2_SEL_TGT_COMPOSE: + s->r.left = inst->crop.left; + s->r.top = inst->crop.top; + s->r.width = inst->crop.width; + s->r.height = inst->crop.height; + break; + default: + return -EINVAL; + } + + return 0; +} + static struct v4l2_file_operations iris_v4l2_file_ops = { .owner = THIS_MODULE, .open = iris_open, @@ -277,6 +305,7 @@ static const struct v4l2_ioctl_ops iris_v4l2_ioctl_ops = { .vidioc_g_fmt_vid_cap_mplane = iris_g_fmt_vid_mplane, .vidioc_g_fmt_vid_out_mplane = iris_g_fmt_vid_mplane, .vidioc_reqbufs = v4l2_m2m_ioctl_reqbufs, + .vidioc_g_selection = iris_g_selection, }; void iris_init_ops(struct iris_core *core)