[RFC,0/5] v4l2-ctrls: refactor and add dynamic array support

Message ID 20210428101841.696059-1-hverkuil-cisco@xs4all.nl (mailing list archive)
Headers
Series v4l2-ctrls: refactor and add dynamic array support |

Message

Hans Verkuil April 28, 2021, 10:18 a.m. UTC
  This patch series adds support for dynamic arrays, something that
is very helpful for stateless codecs.

The first patch fixes a bug in the control framework: if a request
was queued up without any controls, then after completion the request
would still have no controls, so it was impossible to read the state
of the controls at completion time. Note that drivers can also set
control values themselves, so this information would be lost as well.

The v4l2_ctrl_request_complete() was modified to attempt to create
a request control object if it was missing.

This patch will need to be backported to older kernels as well,
but I wait with the details until 5.13-rc1 is released as it is a
bit easier to tell for which kernels this patch applies cleanly.

The second (huge!) patch splits up v4l2-ctrls.c into four source
files. It became unmanageable, and splitting it up made it much
easier to maintain. I hope it reaches the mailinglist, it might
be too big. If it doesn't arrive, then you can find it in my
git repo:

https://git.linuxtv.org/hverkuil/media_tree.git/commit/?h=ctrl-refactor&id=db91a8696a76e62304d73759a3de6b92bacb7085

The third patch adds the new flag + documentation.

The fourth patch adds the actual support for dynamic arrays.

The fifth patch adds a dynamic array test control to vivid which
allowed me to test this feature. I'll post a separate patch that
adds compliance tests for this to v4l2-compliance.

I hope the stateless codec devs can test this to see if it meets
their needs. Regardless of that, I do want to get the first two
patches merged as soon as possible once the rc1 is released and
merged in our master branch.

Especially the refactoring in the second patch was a great help
in understanding the code.

Regards,

	Hans

Hans Verkuil (5):
  v4l2-ctrls: always copy the controls on completion
  v4l2-ctrls: split up into four source files
  videodev2.h: add V4L2_CTRL_FLAG_DYNAMIC_ARRAY
  v4l2-ctrls: add support for dynamically allocated arrays.
  vivid: add dynamic array test control

 .../media/v4l/vidioc-queryctrl.rst            |    8 +
 .../media/videodev2.h.rst.exceptions          |    1 +
 drivers/media/mc/mc-request.c                 |    3 +-
 .../media/test-drivers/vivid/vivid-ctrls.c    |   15 +
 drivers/media/v4l2-core/Makefile              |    5 +-
 drivers/media/v4l2-core/v4l2-ctrls-api.c      | 1278 +++++
 drivers/media/v4l2-core/v4l2-ctrls-core.c     | 2009 +++++++
 drivers/media/v4l2-core/v4l2-ctrls-defs.c     | 1571 +++++
 drivers/media/v4l2-core/v4l2-ctrls-priv.h     |   95 +
 drivers/media/v4l2-core/v4l2-ctrls-request.c  |  501 ++
 drivers/media/v4l2-core/v4l2-ctrls.c          | 5035 -----------------
 include/media/v4l2-ctrls.h                    |   42 +-
 include/uapi/linux/videodev2.h                |    1 +
 13 files changed, 5519 insertions(+), 5045 deletions(-)
 create mode 100644 drivers/media/v4l2-core/v4l2-ctrls-api.c
 create mode 100644 drivers/media/v4l2-core/v4l2-ctrls-core.c
 create mode 100644 drivers/media/v4l2-core/v4l2-ctrls-defs.c
 create mode 100644 drivers/media/v4l2-core/v4l2-ctrls-priv.h
 create mode 100644 drivers/media/v4l2-core/v4l2-ctrls-request.c
 delete mode 100644 drivers/media/v4l2-core/v4l2-ctrls.c