[PATCH 6/7] media: intel/ipu6: Introduce isys and dev accessors macros

Stanislaw Gruszka
2025-04-07T13:41:09Z

Add macro and inline function to get access ipu6_isys and device back
pointer. Using the helpers will allow to transformation to common
structures.

Signed-off-by: Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>
---
Note: this gives checkpatch error about space around ":" , but
the same error is already in include/media/v4l2-common.h and
include/media/v4l2-subdev.h , so ignore it.

drivers/media/pci/intel/ipu6/ipu6-isys.h | 27 ++++++++++++++++++++++++
1 file changed, 27 insertions(+)

diff --git a/drivers/media/pci/intel/ipu6/ipu6-isys.h b/drivers/media/pci/intel/ipu6/ipu6-isys.h
index bf6008bfe539..c753656b04f4 100644
--- a/drivers/media/pci/intel/ipu6/ipu6-isys.h
+++ b/drivers/media/pci/intel/ipu6/ipu6-isys.h
@@ -16,6 +16,7 @@
#include <media/v4l2-device.h>

#include "ipu6.h"
+#include "ipu6-bus.h"
#include "ipu6-fw-isys.h"
#include "ipu6-isys-csi2.h"
#include "ipu6-isys-video.h"
@@ -165,6 +166,32 @@ struct ipu6_isys {
struct isys_iwake_watermark iwake_watermark;
};

+static inline struct ipu6_isys *stream_to_isys6(struct isys_stream *stream)
+{
+ return stream->isys;
+}
+
+static inline struct ipu6_isys *video_to_isys6(struct ipu6_isys_video *video)
+{
+ return video->isys;
+}
+
+static inline struct ipu6_isys *csi2_to_isys6(struct ipu6_isys_csi2 *csi2)
+{
+ return csi2->isys;
+}
+
+#define to_isys(p) \
+ _Generic(p, \
+ struct isys_stream *: stream_to_isys6, \
+ struct ipu6_isys_csi2 *: csi2_to_isys6, \
+ struct ipu6_isys_video *: video_to_isys6)(p)
+
+static inline struct device *isys_to_dev(struct ipu6_isys *isys)
+{
+ return &isys->adev->auxdev.dev;
+}
+
struct isys_fw_msgs {
union {
u64 dummy;
--
2.34.1