[RFC,0/2] Add v4l2_ctrl_request_create()

Message ID 20200728094851.121933-1-hverkuil-cisco@xs4all.nl (mailing list archive)
Headers
Series Add v4l2_ctrl_request_create() |

Message

Hans Verkuil July 28, 2020, 9:48 a.m. UTC
  The Request API is missing a feature: if userspace did not set any controls,
then the request object will not contain a control object (that's created
only if the user sets a control in the request).

This is fine for e.g. stateless codecs since they require that each request
contains controls, so this is always done. And this is also the reason that
this hasn't been a problem before, since the Request API is almost exclusively
used by stateless codecs.

But for e.g. vivid this means that the completed request does not contain
any controls in the request containing the control values at the time that
the frame was captured (or output).

In addition, if a driver needs to set a status control, then that control
won't be part of the request either.

This RFC series adds a v4l2_ctrl_request_create() function that can be
called in the req_validate() callback of the request. If the request
doesn't contain a control object, then it will add a new one.

This is an RFC for now. Hopefully this will help Yunfei Dong with the
development of Read-Only Requests, since that should be a lot simpler with
this new function.

Also, I am not entirely happy with the name of the function and I also
think that we might need a helper in v4l2-common.c that combines with
function with vb2_request_validate(), thus avoiding that drivers need
to remember to call both v4l2_ctrl_request_create() and vb2_request_validate().

Regards,

	Hans

Hans Verkuil (2):
  v4l2-ctrls.c: add v4l2_ctrl_request_create
  vivid: call v4l2_ctrl_request_create()

 drivers/media/mc/mc-request.c                 |  3 +-
 drivers/media/test-drivers/vivid/vivid-core.c |  4 +++
 drivers/media/v4l2-core/v4l2-ctrls.c          | 35 +++++++++++++++++++
 include/media/v4l2-ctrls.h                    | 16 +++++++++
 4 files changed, 57 insertions(+), 1 deletion(-)