[PATCH 3/7] media: intel/ipu6: Move common structures definitions to isys.h

Stanislaw Gruszka
2025-04-07T13:40:58Z

Move some structures that will be reused in ipu7 to isys.h file.
Use one header file instead of multiple, since we frequently include
most of ipu6-*.h headers in c files anyways.

Signed-off-by: Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>
---
.../media/pci/intel/ipu6/ipu6-isys-queue.c | 1 +
.../media/pci/intel/ipu6/ipu6-isys-queue.h | 56 +---------
.../media/pci/intel/ipu6/ipu6-isys-video.h | 59 +---------
drivers/media/pci/intel/ipu6/isys.h | 102 ++++++++++++++++++
4 files changed, 105 insertions(+), 113 deletions(-)

diff --git a/drivers/media/pci/intel/ipu6/ipu6-isys-queue.c b/drivers/media/pci/intel/ipu6/ipu6-isys-queue.c
index 5fc52a3b89e6..252097c61d0a 100644
--- a/drivers/media/pci/intel/ipu6/ipu6-isys-queue.c
+++ b/drivers/media/pci/intel/ipu6/ipu6-isys-queue.c
@@ -20,6 +20,7 @@
#include "ipu6-dma.h"
#include "ipu6-fw-isys.h"
#include "ipu6-isys.h"
+#include "ipu6-isys-queue.h"
#include "ipu6-isys-video.h"

static int ipu6_isys_buf_init(struct vb2_buffer *vb)
diff --git a/drivers/media/pci/intel/ipu6/ipu6-isys-queue.h b/drivers/media/pci/intel/ipu6/ipu6-isys-queue.h
index 00666098bbdc..6a95858bfd59 100644
--- a/drivers/media/pci/intel/ipu6/ipu6-isys-queue.h
+++ b/drivers/media/pci/intel/ipu6/ipu6-isys-queue.h
@@ -4,62 +4,8 @@
#ifndef IPU6_ISYS_QUEUE_H
#define IPU6_ISYS_QUEUE_H

-#include <linux/container_of.h>
-#include <linux/atomic.h>
-#include <linux/device.h>
-#include <linux/list.h>
-#include <linux/spinlock_types.h>
-
-#include <media/videobuf2-v4l2.h>
-
#include "ipu6-fw-isys.h"
-#include "ipu6-isys-video.h"
-
-struct ipu6_isys_stream;
-
-struct ipu6_isys_queue {
- struct vb2_queue vbq;
- struct list_head node;
- /*
- * @lock: serialise access to queued and pre_streamon_queued
- */
- spinlock_t lock;
- struct list_head active;
- struct list_head incoming;
- unsigned int fw_output;
-};
-
-struct ipu6_isys_buffer {
- struct list_head head;
- atomic_t str2mmio_flag;
-};
-
-struct ipu6_isys_video_buffer {
- struct vb2_v4l2_buffer vb_v4l2;
- struct ipu6_isys_buffer ib;
- dma_addr_t dma_addr;
-};
-
-#define IPU6_ISYS_BUFFER_LIST_FL_INCOMING BIT(0)
-#define IPU6_ISYS_BUFFER_LIST_FL_ACTIVE BIT(1)
-#define IPU6_ISYS_BUFFER_LIST_FL_SET_STATE BIT(2)
-
-struct ipu6_isys_buffer_list {
- struct list_head head;
- unsigned int nbufs;
-};
-
-#define vb2_queue_to_isys_queue(__vb2) \
- container_of(__vb2, struct ipu6_isys_queue, vbq)
-
-#define ipu6_isys_to_isys_video_buffer(__ib) \
- container_of(__ib, struct ipu6_isys_video_buffer, ib)
-
-#define vb2_buffer_to_ipu6_isys_video_buffer(__vvb) \
- container_of(__vvb, struct ipu6_isys_video_buffer, vb_v4l2)
-
-#define ipu6_isys_buffer_to_vb2_buffer(__ib) \
- (&ipu6_isys_to_isys_video_buffer(__ib)->vb_v4l2.vb2_buf)
+#include "isys.h"

void ipu6_isys_buffer_list_queue(struct ipu6_isys_buffer_list *bl,
unsigned long op_flags,
diff --git a/drivers/media/pci/intel/ipu6/ipu6-isys-video.h b/drivers/media/pci/intel/ipu6/ipu6-isys-video.h
index f4dee6120635..bca8e65dd5ec 100644
--- a/drivers/media/pci/intel/ipu6/ipu6-isys-video.h
+++ b/drivers/media/pci/intel/ipu6/ipu6-isys-video.h
@@ -13,64 +13,7 @@
#include <media/media-entity.h>
#include <media/v4l2-dev.h>

-#include "ipu6-isys-queue.h"
-
-#define IPU6_ISYS_OUTPUT_PINS 11
-#define IPU6_ISYS_MAX_PARALLEL_SOF 2
-
-struct file;
-struct ipu6_isys;
-struct ipu6_isys_csi2;
-struct isys_subdev;
-
-struct ipu6_isys_pixelformat {
- u32 pixelformat;
- u32 bpp;
- u32 bpp_packed;
- u32 code;
- u32 css_pixelformat;
- bool is_meta;
-};
-
-struct sequence_info {
- unsigned int sequence;
- u64 timestamp;
-};
-
-struct output_pin_data {
- void (*pin_ready)(struct ipu6_isys_stream *stream, void *_info);
- struct ipu6_isys_queue *aq;
-};
-
-/*
- * Align with firmware stream. Each stream represents a CSI virtual channel.
- * May map to multiple video devices
- */
-struct ipu6_isys_stream {
- struct mutex mutex;
- struct media_entity *source_entity;
- atomic_t sequence;
- unsigned int seq_index;
- struct sequence_info seq[IPU6_ISYS_MAX_PARALLEL_SOF];
- int stream_source;
- int stream_handle;
- unsigned int nr_output_pins;
- struct isys_subdev *asd;
-
- int nr_queues; /* Number of capture queues */
- int nr_streaming;
- int streaming; /* Has streaming been really started? */
- struct list_head queues;
- struct completion stream_open_completion;
- struct completion stream_close_completion;
- struct completion stream_start_completion;
- struct completion stream_stop_completion;
- struct ipu6_isys *isys;
-
- struct output_pin_data output_pins[IPU6_ISYS_OUTPUT_PINS];
- int error;
- u8 vc;
-};
+#include "isys.h"

struct video_stream_watermark {
u32 width;
diff --git a/drivers/media/pci/intel/ipu6/isys.h b/drivers/media/pci/intel/ipu6/isys.h
index b6ddadfc374b..f2a49694a050 100644
--- a/drivers/media/pci/intel/ipu6/isys.h
+++ b/drivers/media/pci/intel/ipu6/isys.h
@@ -4,10 +4,14 @@
#ifndef ISYS_H
#define ISYS_H

+#include <linux/atomic.h>
#include <linux/container_of.h>
+#include <linux/list.h>
+#include <linux/mutex.h>

#include <media/v4l2-ctrls.h>
#include <media/v4l2-subdev.h>
+#include <media/videobuf2-v4l2.h>

struct isys_subdev {
struct v4l2_subdev sd;
@@ -20,6 +24,104 @@ struct isys_subdev {

#define to_isys_subdev(__sd) container_of(__sd, struct isys_subdev, sd)

+struct ipu6_isys_queue {
+ struct vb2_queue vbq;
+ struct list_head node;
+ /*
+ * @lock: serialise access to queued and pre_streamon_queued
+ */
+ spinlock_t lock;
+ struct list_head active;
+ struct list_head incoming;
+ unsigned int fw_output;
+};
+
+struct ipu6_isys_buffer {
+ struct list_head head;
+ atomic_t str2mmio_flag;
+};
+
+struct ipu6_isys_video_buffer {
+ struct vb2_v4l2_buffer vb_v4l2;
+ struct ipu6_isys_buffer ib;
+ dma_addr_t dma_addr;
+};
+
+struct ipu6_isys_buffer_list {
+ struct list_head head;
+ unsigned int nbufs;
+};
+
+#define vb2_queue_to_isys_queue(__vb2) \
+ container_of(__vb2, struct ipu6_isys_queue, vbq)
+
+#define vb2_buffer_to_ipu6_isys_video_buffer(__vvb) \
+ container_of(__vvb, struct ipu6_isys_video_buffer, vb_v4l2)
+
+#define ipu6_isys_to_isys_video_buffer(__ib) \
+ container_of(__ib, struct ipu6_isys_video_buffer, ib)
+
+#define ipu6_isys_buffer_to_vb2_buffer(__ib) \
+ (&ipu6_isys_to_isys_video_buffer(__ib)->vb_v4l2.vb2_buf)
+
+#define IPU6_ISYS_BUFFER_LIST_FL_INCOMING BIT(0)
+#define IPU6_ISYS_BUFFER_LIST_FL_ACTIVE BIT(1)
+#define IPU6_ISYS_BUFFER_LIST_FL_SET_STATE BIT(2)
+
+#define IPU6_ISYS_OUTPUT_PINS 11
+#define IPU6_ISYS_MAX_PARALLEL_SOF 2
+
+struct ipu6_isys_pixelformat {
+ u32 pixelformat;
+ u32 bpp;
+ u32 bpp_packed;
+ u32 code;
+ u32 css_pixelformat;
+ bool is_meta;
+};
+
+struct isys_sequence_info {
+ unsigned int sequence;
+ u64 timestamp;
+};
+
+struct ipu6_isys_stream;
+
+struct isys_output_pin_data {
+ void (*pin_ready)(struct ipu6_isys_stream *stream, void *_info);
+ struct ipu6_isys_queue *aq;
+};
+
+/*
+ * Align with firmware stream. Each stream represents a CSI virtual channel.
+ * May map to multiple video devices
+ */
+struct ipu6_isys_stream {
+ struct mutex mutex;
+ struct media_entity *source_entity;
+ atomic_t sequence;
+ unsigned int seq_index;
+ struct isys_sequence_info seq[IPU6_ISYS_MAX_PARALLEL_SOF];
+ int stream_source;
+ int stream_handle;
+ unsigned int nr_output_pins;
+ struct isys_subdev *asd;
+
+ int nr_queues; /* Number of capture queues */
+ int nr_streaming;
+ int streaming; /* Has streaming been really started? */
+ struct list_head queues;
+ struct completion stream_open_completion;
+ struct completion stream_close_completion;
+ struct completion stream_start_completion;
+ struct completion stream_stop_completion;
+ struct ipu6_isys *isys;
+
+ struct isys_output_pin_data output_pins[IPU6_ISYS_OUTPUT_PINS];
+ int error;
+ u8 vc;
+};
+
int isys_get_stream_pad_fmt(struct v4l2_subdev *sd, u32 pad, u32 stream,
struct v4l2_mbus_framefmt *format);
int isys_get_stream_pad_crop(struct v4l2_subdev *sd, u32 pad, u32 stream,
--
2.34.1