rkvdec: Do not require all controls to be present in every request
Subsystems (2)
PATCH 1/1 rkvdec: Do not require all controls to be present in every request
From: Daniel Almeida <[email protected]>
According to the v4l2 api, it is allowed to skip
setting a control if its contents haven't changed for performance
reasons: userspace should only update the controls that changed from last frame rather then updating them all. Still some ancient code that checks for mandatory controls has been left in this driver.
Remove it.
--- drivers/staging/media/rkvdec/rkvdec.c | 48 +-------------------------- drivers/staging/media/rkvdec/rkvdec.h | 1 - 2 files changed, 1 insertion(+), 48 deletions(-)
drivers/staging/media/rkvdec/rkvdec.c +1 -47
@@ -55,16 +55,13 @@ static const struct v4l2_ctrl_ops rkvdec_ctrl_ops = {static const struct rkvdec_ctrl_desc rkvdec_h264_ctrl_descs[] = { { - .mandatory = true, .cfg.id =V4L2_CID_STATELESS_H264_DECODE_PARAMS , }, { - .mandatory = true, .cfg.id =V4L2_CID_STATELESS_H264_SPS , .cfg.ops = &rkvdec_ctrl_ops, }, { - .mandatory = true, .cfg.id =V4L2_CID_STATELESS_H264_PPS , }, {
@@ -585,25 +582,7 @@ static const struct vb2_ops rkvdec_queue_ops = {static int rkvdec_request_validate (struct media_request *req) { -struct media_request_object *obj; -const struct rkvdec_ctrls *ctrls; -struct v4l2_ctrl_handler *hdl; -struct rkvdec_ctx *ctx =NULL ; -unsigned int count, i; -int ret; - -list_for_each_entry (obj, &req->objects, list) { -if (vb2_request_object_is_buffer (obj)) { -struct vb2_buffer *vb; - - vb = container_of(obj, struct vb2_buffer, req_obj); - ctx =vb2_get_drv_priv (vb->vb2_queue); -break ; - } - } - -if (!ctx) -return -EINVAL ; +unsigned int count; count =vb2_request_buffer_cnt (req);if (!count)
@@ -611,31 +590,6 @@ static int rkvdec_request_validate(struct media_request *req)else if (count >1 )return -EINVAL ; - hdl =v4l2_ctrl_request_hdl_find (req, &ctx->ctrl_hdl); -if (!hdl) -return -ENOENT ; - - ret =0 ; - ctrls = ctx->coded_fmt_desc->ctrls; -for (i =0 ; ctrls && i < ctrls->num_ctrls; i++) { -u32 id = ctrls->ctrls[i].cfg.id; -struct v4l2_ctrl *ctrl; - -if (!ctrls->ctrls[i].mandatory) -continue ; - - ctrl =v4l2_ctrl_request_hdl_ctrl_find (hdl, id); -if (!ctrl) { - ret = -ENOENT ; -break ; - } - } - -v4l2_ctrl_request_hdl_put (hdl); - -if (ret) -return ret; -return vb2_request_validate (req); }
drivers/staging/media/rkvdec/rkvdec.h +0 -1
@@ -25,7 +25,6 @@struct rkvdec_ctx ;struct rkvdec_ctrl_desc { -u32 mandatory :1 ;struct v4l2_ctrl_config cfg; };
Signature · 1 line
2.31.0
Quoted 8 lines · On Tue, 2021-03-23 at 15:57 -0300, [email protected] wrote:
From: Daniel Almeida <[email protected]>
According to the v4l2 api, it is allowed to skip
setting a control if its contents haven't changed for performance
reasons: userspace should only update the controls that changed from last frame rather then updating them all. Still some ancient code that checks for mandatory controls has been left in this driver.
Quoted 4 lines
Remove it.
Fixes cd33c830448b ("media: rkvdec: Add the rkvdec driver")Signed-off-by Daniel Almeida <[email protected]>
Thanks,
Ezequiel
Quoted 97 lines
---
drivers/staging/media/rkvdec/rkvdec.c | 48 +--------------------------drivers/staging/media/rkvdec/rkvdec.h| 1 -2 files changed, 1 insertion(+), 48 deletions(-)drivers/staging/media/rkvdec/rkvdec.c +0
-0@@ -55,16 +55,13 @@ static const struct v4l2_ctrl_ops rkvdec_ctrl_ops = {
static const structrkvdec_ctrl_descrkvdec_h264_ctrl_descs[] = { {
- .mandatory = true,
.cfg.id =V4L2_CID_STATELESS_H264_DECODE_PARAMS, },
{
- .mandatory = true,
.cfg.id =V4L2_CID_STATELESS_H264_SPS, .cfg.ops =&rkvdec_ctrl_ops,
},
{
- .mandatory = true,
.cfg.id =V4L2_CID_STATELESS_H264_PPS, },
{drivers/staging/media/rkvdec/rkvdec.c +0
-0@@ -585,25 +582,7 @@ static const struct vb2_ops rkvdec_queue_ops = {
static intrkvdec_request_validate(struct media_request *req){
- structmedia_request_object*obj;
- const structrkvdec_ctrls*ctrls;
- structv4l2_ctrl_handler*hdl;
- structrkvdec_ctx*ctx = NULL;
- unsigned int count, i;
- int ret;drivers/staging/media/rkvdec/rkvdec.c +1
-13- - list_for_each_entry(obj, &req->objects, list) { - if (vb2_request_object_is_buffer(obj)) { - struct vb2_buffer *vb; - - vb = container_of(obj, struct vb2_buffer, req_obj); - ctx = vb2_get_drv_priv(vb->vb2_queue); - break; - } - } - - if (!ctx) - return -EINVAL; + unsigned int count;
count =vb2_request_buffer_cnt(req);
if (!count)drivers/staging/media/rkvdec/rkvdec.c +0
-0@@ -611,31 +590,6 @@ static int rkvdec_request_validate(struct media_request *req) else if (count > 1) return -EINVAL;
- hdl =v4l2_ctrl_request_hdl_find(req, &ctx->ctrl_hdl); - if (!hdl)
- return-ENOENT;drivers/staging/media/rkvdec/rkvdec.c +0
-22- - ret = 0; - ctrls = ctx->coded_fmt_desc->ctrls; - for (i = 0; ctrls && i < ctrls->num_ctrls; i++) { - u32 id = ctrls->ctrls[i].cfg.id; - struct v4l2_ctrl *ctrl; - - if (!ctrls->ctrls[i].mandatory) - continue; - - ctrl = v4l2_ctrl_request_hdl_ctrl_find(hdl, id); - if (!ctrl) { - ret = -ENOENT; - break; - } - } - - v4l2_ctrl_request_hdl_put(hdl); - - if (ret) - return ret; -return
vb2_request_validate(req);
}drivers/staging/media/rkvdec/rkvdec.h +0
-0@@ -25,7 +25,6 @@ struct rkvdec_ctx;
structrkvdec_ctrl_desc{
- u32 mandatory : 1;
structv4l2_ctrl_configcfg;
};