diff mbox series

[v2,2/4] media: v4l: subdev: Add a helper to tell if a sub-device state is active

Message ID 20231009220906.221303-3-sakari.ailus@linux.intel.com
State New
Headers show
Series V4L2 sub-device active state helper, CCS fixes | expand

Commit Message

Sakari Ailus Oct. 9, 2023, 10:09 p.m. UTC
Add a helper called v4l2_subdev_state_whence() to return enum
v4l2_subdev_format_whence to tell whether a state the driver is dealing with
it active or not.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
 include/media/v4l2-subdev.h | 8 ++++++++
 1 file changed, 8 insertions(+)
diff mbox series

Patch

diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index ea05b70389b3..ff211b0f07ff 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -1645,6 +1645,14 @@  v4l2_subdev_state_get_opposite_stream_format(struct v4l2_subdev_state *state,
 u64 v4l2_subdev_state_xlate_streams(const struct v4l2_subdev_state *state,
 				    u32 pad0, u32 pad1, u64 *streams);
 
+static inline enum v4l2_subdev_format_whence
+v4l2_subdev_state_whence(struct v4l2_subdev *sd,
+			 struct v4l2_subdev_state *state)
+{
+	return sd->active_state == state ?
+		V4L2_SUBDEV_FORMAT_ACTIVE : V4L2_SUBDEV_FORMAT_TRY;
+}
+
 /**
  * enum v4l2_subdev_routing_restriction - Subdevice internal routing restrictions
  *