Re: [PATCH v4 27/29] media: v4l2-subdev: Add v4l2_subdev_call_ci_active_state

Laurent Pinchart
2026-04-16T17:38:26Z

On Wed, Apr 08, 2026 at 06:39:36PM +0300, Sakari Ailus wrote:
> Add v4l2_subdev_call_ci_active_state(), to call sub-device pad ops that
> take struct v4l2_subdev_client_info pointer as an argument.

If we drop the client info parameter from .get_fmt(), the only driver
calling this new macro will be
drivers/media/platform/ti/cal/cal-video.c. I would just pass NULL
explicitly there and drop this patch.

> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> ---
> include/media/v4l2-subdev.h | 49 ++++++++++++++++++++++++++++---------
> 1 file changed, 38 insertions(+), 11 deletions(-)
>
> diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
> index 1ce1c18f84a9..9b0e091c30c1 100644
> --- a/include/media/v4l2-subdev.h
> +++ b/include/media/v4l2-subdev.h
> @@ -1968,6 +1968,22 @@ extern const struct v4l2_subdev_ops v4l2_subdev_call_wrappers;
> __result; \
> })
>
> +#define v4l2_subdev_call_drop_fourth(first, second, third, fourth, rest...) \
> + v4l2_subdev_call(first, second, third, ##rest)
> +
> +#define __v4l2_subdev_call_state_active(call, sd, o, f, args...) \
> + ({ \
> + int __result; \
> + struct v4l2_subdev_state *state; \
> + state = v4l2_subdev_get_unlocked_active_state(sd); \
> + if (state) \
> + v4l2_subdev_lock_state(state); \
> + __result = call(sd, o, f, NULL, state, ##args); \
> + if (state) \
> + v4l2_subdev_unlock_state(state); \
> + __result; \
> + })
> +
> /**
> * v4l2_subdev_call_state_active - call an operation of a v4l2_subdev which
> * takes state as a parameter, passing the
> @@ -1986,17 +2002,28 @@ extern const struct v4l2_subdev_ops v4l2_subdev_call_wrappers;
> * active state, lock it before calling the op and unlock it after the call.
> */
> #define v4l2_subdev_call_state_active(sd, o, f, args...) \
> - ({ \
> - int __result; \
> - struct v4l2_subdev_state *state; \
> - state = v4l2_subdev_get_unlocked_active_state(sd); \
> - if (state) \
> - v4l2_subdev_lock_state(state); \
> - __result = v4l2_subdev_call(sd, o, f, state, ##args); \
> - if (state) \
> - v4l2_subdev_unlock_state(state); \
> - __result; \
> - })
> + __v4l2_subdev_call_state_active(v4l2_subdev_call_drop_fourth, \
> + sd, o, f, ##args)
> +
> +/**
> + * v4l2_subdev_call_ci_state_active - call an operation of a v4l2_subdev which
> + * takes state as a parameter, passing the
> + * subdev its active state.
> + *
> + * @sd: pointer to the &struct v4l2_subdev
> + * @o: name of the element at &struct v4l2_subdev_ops that contains @f.
> + * Each element there groups a set of callbacks functions.
> + * @f: callback function to be called.
> + * The callback functions are defined in groups, according to
> + * each element at &struct v4l2_subdev_ops.
> + * @args: arguments for @f.
> + *
> + * This macro is just as v4l2_subdev_call_state_active(), with the exception
> + * that it passes NULL as the client info to sub-device ops that need it
> + * (currently pad ops get_fmt, set_fmt, get_selection and set_selection).
> + */
> +#define v4l2_subdev_call_ci_state_active(sd, o, f, args...) \
> + __v4l2_subdev_call_state_active(v4l2_subdev_call, sd, o, f, ##args)
>
> /**
> * v4l2_subdev_call_state_try - call an operation of a v4l2_subdev which
> --
> 2.47.3
>

--
Regards,

Laurent Pinchart