Hi, v6 of the subdev active state series. v5 can be found from: https://lore.kernel.org/all/20220301105548.305191-1-tomi.valkeinen@xxxxxxxxxxxxxxxx/ Changes since v5: - Fix code-block in docs - State management wrappers (DEFINE_STATE_WRAPPER). These wrappers will handle the cases where the caller does not pass the active state properly. - Added v4l2_subdev_get_fmt(). This can be used by state-enabled subdev drivers for v4l2_subdev_pad_ops.get_fmt. - Drop the legacy .h file and have v4l2_subdev_call_state_active() in v4l2-subdev.h. The macro is now part of the "add subdev state locking" patch as it is used there. - Added v4l2_subdev_get_pad_* helpers. These are temporary helpers to get rid of the "try" word. The v4l2_subdev_get_try_* functions should later be renamed and these temporary macros dropped. - Rename v4l2_subdev_get_active_state() to v4l2_subdev_get_unlocked_active_state() - Fix v4l2_subdev_lock_and_get_active_state() when there is no active state I have pushed my work/test branch to: git://git.kernel.org/pub/scm/linux/kernel/git/tomba/linux.git streams/state-work It contains this series, ov5640 series from Jacopo, and a some hacks/fixes I needed. The important part there is the topmost commit: "ov5640: convert to active state", which shows how a sensor driver can be changed to support active state. A few notes about that patch: - It could perhaps be cleaner if the state was passed around in certain functions instead of calling v4l2_subdev_get_locked_active_state() in multiple places. - The driver has a private mutex, which was shared with the control handler. The same mutex is now also used for the states. There are not many places where the private mutex is used as it were, and those could be converted to just lock the active state. - Only the format is handled via the state. The driver also has some crop/selection code, but I wasn't sure how that works. - ov5640_get_fmt() goes away as we can just use the v4l2_subdev_get_fmt() - The driver uses the new helper macro to get the format, instead of the "try" version, e.g. "fmt = v4l2_subdev_get_pad_format(&sensor->sd, state, 0);" to get the format for pad 0 in the given state. Tomi Tomi Valkeinen (8): media: subdev: rename subdev-state alloc & free media: subdev: add active state to struct v4l2_subdev media: subdev: add v4l2_subdev_get_pad_* helpers media: subdev: pass also the active state to subdevs from ioctls media: subdev: add subdev state locking media: subdev: add locking wrappers to subdev op wrappers media: subdev: add v4l2_subdev_get_fmt() helper function media: Documentation: add documentation about subdev state .../driver-api/media/v4l2-subdev.rst | 75 ++++++ .../platform/renesas/rcar-vin/rcar-v4l2.c | 9 +- .../media/platform/renesas/vsp1/vsp1_entity.c | 10 +- drivers/media/v4l2-core/v4l2-subdev.c | 194 ++++++++++++--- drivers/staging/media/tegra-video/vi.c | 10 +- include/media/v4l2-subdev.h | 220 +++++++++++++++++- 6 files changed, 480 insertions(+), 38 deletions(-) -- 2.25.1