diff mbox series

[v4,15/28] media: iris: implement query_cap, query_ctrl and query_menu ioctls

Message ID 20241014-qcom-video-iris-v4-v4-15-c5eaa4e9ab9e@quicinc.com (mailing list archive)
State New
Headers show
Series Qualcomm iris video decoder driver | expand

Commit Message

Dikshita Agarwal Oct. 14, 2024, 9:07 a.m. UTC
From: Vedang Nagar <quic_vnagar@quicinc.com>

Implement query_cap, query_ctrl and query_menu ioctls
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 | 52 ++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)

Comments

Hans Verkuil Oct. 23, 2024, 11:05 a.m. UTC | #1
On 14/10/2024 11:07, Dikshita Agarwal wrote:
> From: Vedang Nagar <quic_vnagar@quicinc.com>
> 
> Implement query_cap, query_ctrl and query_menu ioctls
> 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 | 52 ++++++++++++++++++++++++++++
>  1 file changed, 52 insertions(+)
> 
> diff --git a/drivers/media/platform/qcom/iris/iris_vidc.c b/drivers/media/platform/qcom/iris/iris_vidc.c
> index 93d2be118a81..60ee05b67f86 100644
> --- a/drivers/media/platform/qcom/iris/iris_vidc.c
> +++ b/drivers/media/platform/qcom/iris/iris_vidc.c
> @@ -300,6 +300,55 @@ static int iris_enum_framesizes(struct file *filp, void *fh,
>  	return 0;
>  }
>  
> +static int iris_querycap(struct file *filp, void *fh, struct v4l2_capability *cap)
> +{
> +	strscpy(cap->driver, IRIS_DRV_NAME, sizeof(cap->driver));
> +	strscpy(cap->bus_info, IRIS_BUS_NAME, sizeof(cap->bus_info));

Filled in automatically, just drop this.

> +	memset(cap->reserved, 0, sizeof(cap->reserved));

The core zeroes this already, just drop this.

> +	strscpy(cap->card, "iris_decoder", sizeof(cap->card));
> +
> +	return 0;
> +}
> +
> +static int iris_queryctrl(struct file *filp, void *fh, struct v4l2_queryctrl *q_ctrl)
> +{
> +	struct v4l2_ctrl *ctrl;
> +	struct iris_inst *inst = iris_get_inst(filp, NULL);
> +
> +	ctrl = v4l2_ctrl_find(&inst->ctrl_handler, q_ctrl->id);
> +	if (!ctrl)
> +		return -EINVAL;
> +
> +	q_ctrl->minimum = ctrl->minimum;
> +	q_ctrl->maximum = ctrl->maximum;
> +	q_ctrl->default_value = ctrl->default_value;
> +	q_ctrl->flags = 0;
> +	q_ctrl->step = ctrl->step;
> +
> +	return 0;
> +}

Huh???

> +
> +static int iris_querymenu(struct file *filp, void *fh, struct v4l2_querymenu *qmenu)
> +{
> +	struct iris_inst *inst = iris_get_inst(filp, NULL);
> +	struct v4l2_ctrl *ctrl;
> +
> +	ctrl = v4l2_ctrl_find(&inst->ctrl_handler, qmenu->id);
> +	if (!ctrl)
> +		return -EINVAL;
> +
> +	if (ctrl->type != V4L2_CTRL_TYPE_MENU)
> +		return -EINVAL;
> +
> +	if (qmenu->index < ctrl->minimum || qmenu->index > ctrl->maximum)
> +		return -EINVAL;
> +
> +	if (ctrl->menu_skip_mask & (1 << qmenu->index))
> +		return -EINVAL;
> +
> +	return 0;
> +}

Huh??

> +
>  static int iris_g_selection(struct file *filp, void *fh, struct v4l2_selection *s)
>  {
>  	struct iris_inst *inst = iris_get_inst(filp, NULL);
> @@ -366,6 +415,9 @@ static const struct v4l2_ioctl_ops iris_v4l2_ioctl_ops = {
>  	.vidioc_g_fmt_vid_out_mplane    = iris_g_fmt_vid_mplane,
>  	.vidioc_enum_framesizes         = iris_enum_framesizes,
>  	.vidioc_reqbufs                 = v4l2_m2m_ioctl_reqbufs,
> +	.vidioc_querycap                = iris_querycap,
> +	.vidioc_queryctrl               = iris_queryctrl,
> +	.vidioc_querymenu               = iris_querymenu,

queryctrl/menu are handled by the core if you set ctrl_handler in the v4l2_fh struct.

If you use the control handler, then this should never be used.

>  	.vidioc_g_selection             = iris_g_selection,
>  	.vidioc_subscribe_event         = iris_subscribe_event,
>  	.vidioc_unsubscribe_event       = iris_unsubscribe_event,
> 

Regards,

	Hans
Dikshita Agarwal Oct. 24, 2024, 5:50 a.m. UTC | #2
On 10/23/2024 4:35 PM, Hans Verkuil wrote:
> On 14/10/2024 11:07, Dikshita Agarwal wrote:
>> From: Vedang Nagar <quic_vnagar@quicinc.com>
>>
>> Implement query_cap, query_ctrl and query_menu ioctls
>> 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 | 52 ++++++++++++++++++++++++++++
>>  1 file changed, 52 insertions(+)
>>
>> diff --git a/drivers/media/platform/qcom/iris/iris_vidc.c b/drivers/media/platform/qcom/iris/iris_vidc.c
>> index 93d2be118a81..60ee05b67f86 100644
>> --- a/drivers/media/platform/qcom/iris/iris_vidc.c
>> +++ b/drivers/media/platform/qcom/iris/iris_vidc.c
>> @@ -300,6 +300,55 @@ static int iris_enum_framesizes(struct file *filp, void *fh,
>>  	return 0;
>>  }
>>  
>> +static int iris_querycap(struct file *filp, void *fh, struct v4l2_capability *cap)
>> +{
>> +	strscpy(cap->driver, IRIS_DRV_NAME, sizeof(cap->driver));
>> +	strscpy(cap->bus_info, IRIS_BUS_NAME, sizeof(cap->bus_info));
> 
> Filled in automatically, just drop this.
Sure, will do.
> 
>> +	memset(cap->reserved, 0, sizeof(cap->reserved));
> 
> The core zeroes this already, just drop this.
> 
Sure, will do.
>> +	strscpy(cap->card, "iris_decoder", sizeof(cap->card));
>> +
>> +	return 0;
>> +}
>> +
>> +static int iris_queryctrl(struct file *filp, void *fh, struct v4l2_queryctrl *q_ctrl)
>> +{
>> +	struct v4l2_ctrl *ctrl;
>> +	struct iris_inst *inst = iris_get_inst(filp, NULL);
>> +
>> +	ctrl = v4l2_ctrl_find(&inst->ctrl_handler, q_ctrl->id);
>> +	if (!ctrl)
>> +		return -EINVAL;
>> +
>> +	q_ctrl->minimum = ctrl->minimum;
>> +	q_ctrl->maximum = ctrl->maximum;
>> +	q_ctrl->default_value = ctrl->default_value;
>> +	q_ctrl->flags = 0;
>> +	q_ctrl->step = ctrl->step;
>> +
>> +	return 0;
>> +}
> 
> Huh???
> 
>> +
>> +static int iris_querymenu(struct file *filp, void *fh, struct v4l2_querymenu *qmenu)
>> +{
>> +	struct iris_inst *inst = iris_get_inst(filp, NULL);
>> +	struct v4l2_ctrl *ctrl;
>> +
>> +	ctrl = v4l2_ctrl_find(&inst->ctrl_handler, qmenu->id);
>> +	if (!ctrl)
>> +		return -EINVAL;
>> +
>> +	if (ctrl->type != V4L2_CTRL_TYPE_MENU)
>> +		return -EINVAL;
>> +
>> +	if (qmenu->index < ctrl->minimum || qmenu->index > ctrl->maximum)
>> +		return -EINVAL;
>> +
>> +	if (ctrl->menu_skip_mask & (1 << qmenu->index))
>> +		return -EINVAL;
>> +
>> +	return 0;
>> +}
> 
> Huh??
> 
>> +
>>  static int iris_g_selection(struct file *filp, void *fh, struct v4l2_selection *s)
>>  {
>>  	struct iris_inst *inst = iris_get_inst(filp, NULL);
>> @@ -366,6 +415,9 @@ static const struct v4l2_ioctl_ops iris_v4l2_ioctl_ops = {
>>  	.vidioc_g_fmt_vid_out_mplane    = iris_g_fmt_vid_mplane,
>>  	.vidioc_enum_framesizes         = iris_enum_framesizes,
>>  	.vidioc_reqbufs                 = v4l2_m2m_ioctl_reqbufs,
>> +	.vidioc_querycap                = iris_querycap,
>> +	.vidioc_queryctrl               = iris_queryctrl,
>> +	.vidioc_querymenu               = iris_querymenu,
> 
> queryctrl/menu are handled by the core if you set ctrl_handler in the v4l2_fh struct.
> 
> If you use the control handler, then this should never be used.Right, make sense, will remove these.

Thanks,
Dikshita
> 
>>  	.vidioc_g_selection             = iris_g_selection,
>>  	.vidioc_subscribe_event         = iris_subscribe_event,
>>  	.vidioc_unsubscribe_event       = iris_unsubscribe_event,
>>
> 
> Regards,
> 
> 	Hans
diff mbox series

Patch

diff --git a/drivers/media/platform/qcom/iris/iris_vidc.c b/drivers/media/platform/qcom/iris/iris_vidc.c
index 93d2be118a81..60ee05b67f86 100644
--- a/drivers/media/platform/qcom/iris/iris_vidc.c
+++ b/drivers/media/platform/qcom/iris/iris_vidc.c
@@ -300,6 +300,55 @@  static int iris_enum_framesizes(struct file *filp, void *fh,
 	return 0;
 }
 
+static int iris_querycap(struct file *filp, void *fh, struct v4l2_capability *cap)
+{
+	strscpy(cap->driver, IRIS_DRV_NAME, sizeof(cap->driver));
+	strscpy(cap->bus_info, IRIS_BUS_NAME, sizeof(cap->bus_info));
+	memset(cap->reserved, 0, sizeof(cap->reserved));
+	strscpy(cap->card, "iris_decoder", sizeof(cap->card));
+
+	return 0;
+}
+
+static int iris_queryctrl(struct file *filp, void *fh, struct v4l2_queryctrl *q_ctrl)
+{
+	struct v4l2_ctrl *ctrl;
+	struct iris_inst *inst = iris_get_inst(filp, NULL);
+
+	ctrl = v4l2_ctrl_find(&inst->ctrl_handler, q_ctrl->id);
+	if (!ctrl)
+		return -EINVAL;
+
+	q_ctrl->minimum = ctrl->minimum;
+	q_ctrl->maximum = ctrl->maximum;
+	q_ctrl->default_value = ctrl->default_value;
+	q_ctrl->flags = 0;
+	q_ctrl->step = ctrl->step;
+
+	return 0;
+}
+
+static int iris_querymenu(struct file *filp, void *fh, struct v4l2_querymenu *qmenu)
+{
+	struct iris_inst *inst = iris_get_inst(filp, NULL);
+	struct v4l2_ctrl *ctrl;
+
+	ctrl = v4l2_ctrl_find(&inst->ctrl_handler, qmenu->id);
+	if (!ctrl)
+		return -EINVAL;
+
+	if (ctrl->type != V4L2_CTRL_TYPE_MENU)
+		return -EINVAL;
+
+	if (qmenu->index < ctrl->minimum || qmenu->index > ctrl->maximum)
+		return -EINVAL;
+
+	if (ctrl->menu_skip_mask & (1 << qmenu->index))
+		return -EINVAL;
+
+	return 0;
+}
+
 static int iris_g_selection(struct file *filp, void *fh, struct v4l2_selection *s)
 {
 	struct iris_inst *inst = iris_get_inst(filp, NULL);
@@ -366,6 +415,9 @@  static const struct v4l2_ioctl_ops iris_v4l2_ioctl_ops = {
 	.vidioc_g_fmt_vid_out_mplane    = iris_g_fmt_vid_mplane,
 	.vidioc_enum_framesizes         = iris_enum_framesizes,
 	.vidioc_reqbufs                 = v4l2_m2m_ioctl_reqbufs,
+	.vidioc_querycap                = iris_querycap,
+	.vidioc_queryctrl               = iris_queryctrl,
+	.vidioc_querymenu               = iris_querymenu,
 	.vidioc_g_selection             = iris_g_selection,
 	.vidioc_subscribe_event         = iris_subscribe_event,
 	.vidioc_unsubscribe_event       = iris_unsubscribe_event,