media: v4l: subdev: Store the sub-device in the sub-device state
authorSakari Ailus <sakari.ailus@linux.intel.com>
Fri, 13 Oct 2023 07:15:48 +0000 (09:15 +0200)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Thu, 23 Nov 2023 17:30:41 +0000 (18:30 +0100)
Store the sub-device in the sub-device state. This will be needed in e.g.
validating pad number when retrieving information for non-stream-aware
users. There are expected to be more needs for this in the future.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
drivers/media/v4l2-core/v4l2-subdev.c
include/media/v4l2-subdev.h

index be86b906c985cc33166e2e803f6c1e47be6ed156..cd3ff5b19d0c42fefbc71042d3c55a8740f39b71 100644 (file)
@@ -1448,6 +1448,8 @@ __v4l2_subdev_state_alloc(struct v4l2_subdev *sd, const char *lock_name,
        else
                state->lock = &state->_lock;
 
+       state->sd = sd;
+
        /* Drivers that support streams do not need the legacy pad config */
        if (!(sd->flags & V4L2_SUBDEV_FL_STREAMS) && sd->entity.num_pads) {
                state->pads = kvcalloc(sd->entity.num_pads,
index 8a345b5fa39df217fd33e65754f68f567a6f5c79..46296852cb5bace33b10fc4893856e8ad2cfe6f3 100644 (file)
@@ -749,6 +749,7 @@ struct v4l2_subdev_krouting {
  *
  * @_lock: default for 'lock'
  * @lock: mutex for the state. May be replaced by the user.
+ * @sd: the sub-device which the state is related to
  * @pads: &struct v4l2_subdev_pad_config array
  * @routing: routing table for the subdev
  * @stream_configs: stream configurations (only for V4L2_SUBDEV_FL_STREAMS)
@@ -761,6 +762,7 @@ struct v4l2_subdev_state {
        /* lock for the struct v4l2_subdev_state fields */
        struct mutex _lock;
        struct mutex *lock;
+       struct v4l2_subdev *sd;
        struct v4l2_subdev_pad_config *pads;
        struct v4l2_subdev_krouting routing;
        struct v4l2_subdev_stream_configs stream_configs;