Message ID | 20241209-qcom-video-iris-v7-13-05c6bdead47b@quicinc.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | Qualcomm iris video decoder driver | expand |
On 09/12/2024 13:51, Dikshita Agarwal wrote: > From: Vedang Nagar <quic_vnagar@quicinc.com> > > Implement subscribe_event and unsubscribe_event iocts with necessary > hooks. > > Signed-off-by: Vedang Nagar <quic_vnagar@quicinc.com> > Signed-off-by: Dikshita Agarwal <quic_dikshita@quicinc.com> Reviewed-by: Hans Verkuil <hverkuil@xs4all.nl> Regards, Hans > --- > drivers/media/platform/qcom/iris/iris_vdec.c | 22 ++++++++++++++++++++++ > drivers/media/platform/qcom/iris/iris_vdec.h | 1 + > drivers/media/platform/qcom/iris/iris_vidc.c | 10 ++++++++++ > 3 files changed, 33 insertions(+) > > diff --git a/drivers/media/platform/qcom/iris/iris_vdec.c b/drivers/media/platform/qcom/iris/iris_vdec.c > index 081a9eda5c49..0ba60bcb9fa9 100644 > --- a/drivers/media/platform/qcom/iris/iris_vdec.c > +++ b/drivers/media/platform/qcom/iris/iris_vdec.c > @@ -3,6 +3,7 @@ > * Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved. > */ > > +#include <media/v4l2-event.h> > #include <media/v4l2-mem2mem.h> > > #include "iris_buffer.h" > @@ -193,3 +194,24 @@ int iris_vdec_s_fmt(struct iris_inst *inst, struct v4l2_format *f) > > return 0; > } > + > +int iris_vdec_subscribe_event(struct iris_inst *inst, const struct v4l2_event_subscription *sub) > +{ > + int ret = 0; > + > + switch (sub->type) { > + case V4L2_EVENT_EOS: > + ret = v4l2_event_subscribe(&inst->fh, sub, 0, NULL); > + break; > + case V4L2_EVENT_SOURCE_CHANGE: > + ret = v4l2_src_change_event_subscribe(&inst->fh, sub); > + break; > + case V4L2_EVENT_CTRL: > + ret = v4l2_ctrl_subscribe_event(&inst->fh, sub); > + break; > + default: > + return -EINVAL; > + } > + > + return ret; > +} > diff --git a/drivers/media/platform/qcom/iris/iris_vdec.h b/drivers/media/platform/qcom/iris/iris_vdec.h > index ae456676e578..f64ce3234e6a 100644 > --- a/drivers/media/platform/qcom/iris/iris_vdec.h > +++ b/drivers/media/platform/qcom/iris/iris_vdec.h > @@ -13,5 +13,6 @@ void iris_vdec_inst_deinit(struct iris_inst *inst); > int iris_vdec_enum_fmt(struct iris_inst *inst, struct v4l2_fmtdesc *f); > int iris_vdec_try_fmt(struct iris_inst *inst, struct v4l2_format *f); > int iris_vdec_s_fmt(struct iris_inst *inst, struct v4l2_format *f); > +int iris_vdec_subscribe_event(struct iris_inst *inst, const struct v4l2_event_subscription *sub); > > #endif > diff --git a/drivers/media/platform/qcom/iris/iris_vidc.c b/drivers/media/platform/qcom/iris/iris_vidc.c > index 82bd0be8e5da..511cd13ac471 100644 > --- a/drivers/media/platform/qcom/iris/iris_vidc.c > +++ b/drivers/media/platform/qcom/iris/iris_vidc.c > @@ -4,6 +4,7 @@ > */ > > #include <linux/pm_runtime.h> > +#include <media/v4l2-event.h> > #include <media/v4l2-ioctl.h> > #include <media/v4l2-mem2mem.h> > > @@ -322,6 +323,13 @@ static int iris_g_selection(struct file *filp, void *fh, struct v4l2_selection * > return 0; > } > > +static int iris_subscribe_event(struct v4l2_fh *fh, const struct v4l2_event_subscription *sub) > +{ > + struct iris_inst *inst = container_of(fh, struct iris_inst, fh); > + > + return iris_vdec_subscribe_event(inst, sub); > +} > + > static struct v4l2_file_operations iris_v4l2_file_ops = { > .owner = THIS_MODULE, > .open = iris_open, > @@ -347,6 +355,8 @@ static const struct v4l2_ioctl_ops iris_v4l2_ioctl_ops = { > .vidioc_enum_framesizes = iris_enum_framesizes, > .vidioc_reqbufs = v4l2_m2m_ioctl_reqbufs, > .vidioc_g_selection = iris_g_selection, > + .vidioc_subscribe_event = iris_subscribe_event, > + .vidioc_unsubscribe_event = v4l2_event_unsubscribe, > }; > > void iris_init_ops(struct iris_core *core) >
diff --git a/drivers/media/platform/qcom/iris/iris_vdec.c b/drivers/media/platform/qcom/iris/iris_vdec.c index 081a9eda5c49..0ba60bcb9fa9 100644 --- a/drivers/media/platform/qcom/iris/iris_vdec.c +++ b/drivers/media/platform/qcom/iris/iris_vdec.c @@ -3,6 +3,7 @@ * Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved. */ +#include <media/v4l2-event.h> #include <media/v4l2-mem2mem.h> #include "iris_buffer.h" @@ -193,3 +194,24 @@ int iris_vdec_s_fmt(struct iris_inst *inst, struct v4l2_format *f) return 0; } + +int iris_vdec_subscribe_event(struct iris_inst *inst, const struct v4l2_event_subscription *sub) +{ + int ret = 0; + + switch (sub->type) { + case V4L2_EVENT_EOS: + ret = v4l2_event_subscribe(&inst->fh, sub, 0, NULL); + break; + case V4L2_EVENT_SOURCE_CHANGE: + ret = v4l2_src_change_event_subscribe(&inst->fh, sub); + break; + case V4L2_EVENT_CTRL: + ret = v4l2_ctrl_subscribe_event(&inst->fh, sub); + break; + default: + return -EINVAL; + } + + return ret; +} diff --git a/drivers/media/platform/qcom/iris/iris_vdec.h b/drivers/media/platform/qcom/iris/iris_vdec.h index ae456676e578..f64ce3234e6a 100644 --- a/drivers/media/platform/qcom/iris/iris_vdec.h +++ b/drivers/media/platform/qcom/iris/iris_vdec.h @@ -13,5 +13,6 @@ void iris_vdec_inst_deinit(struct iris_inst *inst); int iris_vdec_enum_fmt(struct iris_inst *inst, struct v4l2_fmtdesc *f); int iris_vdec_try_fmt(struct iris_inst *inst, struct v4l2_format *f); int iris_vdec_s_fmt(struct iris_inst *inst, struct v4l2_format *f); +int iris_vdec_subscribe_event(struct iris_inst *inst, const struct v4l2_event_subscription *sub); #endif diff --git a/drivers/media/platform/qcom/iris/iris_vidc.c b/drivers/media/platform/qcom/iris/iris_vidc.c index 82bd0be8e5da..511cd13ac471 100644 --- a/drivers/media/platform/qcom/iris/iris_vidc.c +++ b/drivers/media/platform/qcom/iris/iris_vidc.c @@ -4,6 +4,7 @@ */ #include <linux/pm_runtime.h> +#include <media/v4l2-event.h> #include <media/v4l2-ioctl.h> #include <media/v4l2-mem2mem.h> @@ -322,6 +323,13 @@ static int iris_g_selection(struct file *filp, void *fh, struct v4l2_selection * return 0; } +static int iris_subscribe_event(struct v4l2_fh *fh, const struct v4l2_event_subscription *sub) +{ + struct iris_inst *inst = container_of(fh, struct iris_inst, fh); + + return iris_vdec_subscribe_event(inst, sub); +} + static struct v4l2_file_operations iris_v4l2_file_ops = { .owner = THIS_MODULE, .open = iris_open, @@ -347,6 +355,8 @@ static const struct v4l2_ioctl_ops iris_v4l2_ioctl_ops = { .vidioc_enum_framesizes = iris_enum_framesizes, .vidioc_reqbufs = v4l2_m2m_ioctl_reqbufs, .vidioc_g_selection = iris_g_selection, + .vidioc_subscribe_event = iris_subscribe_event, + .vidioc_unsubscribe_event = v4l2_event_unsubscribe, }; void iris_init_ops(struct iris_core *core)