xref: /linux/drivers/media/pci/intel/ipu6/ipu6-isys-queue.h (revision d53b8e36925256097a08d7cb749198d85cbf9b2b)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /* Copyright (C) 2013--2024 Intel Corporation */
3 
4 #ifndef IPU6_ISYS_QUEUE_H
5 #define IPU6_ISYS_QUEUE_H
6 
7 #include <linux/container_of.h>
8 #include <linux/atomic.h>
9 #include <linux/device.h>
10 #include <linux/list.h>
11 #include <linux/spinlock_types.h>
12 
13 #include <media/videobuf2-v4l2.h>
14 
15 #include "ipu6-fw-isys.h"
16 #include "ipu6-isys-video.h"
17 
18 struct ipu6_isys_stream;
19 
20 struct ipu6_isys_queue {
21 	struct vb2_queue vbq;
22 	struct list_head node;
23 	struct device *dev;
24 	/*
25 	 * @lock: serialise access to queued and pre_streamon_queued
26 	 */
27 	spinlock_t lock;
28 	struct list_head active;
29 	struct list_head incoming;
30 	unsigned int fw_output;
31 };
32 
33 struct ipu6_isys_buffer {
34 	struct list_head head;
35 	atomic_t str2mmio_flag;
36 };
37 
38 struct ipu6_isys_video_buffer {
39 	struct vb2_v4l2_buffer vb_v4l2;
40 	struct ipu6_isys_buffer ib;
41 };
42 
43 #define IPU6_ISYS_BUFFER_LIST_FL_INCOMING	BIT(0)
44 #define IPU6_ISYS_BUFFER_LIST_FL_ACTIVE	BIT(1)
45 #define IPU6_ISYS_BUFFER_LIST_FL_SET_STATE	BIT(2)
46 
47 struct ipu6_isys_buffer_list {
48 	struct list_head head;
49 	unsigned int nbufs;
50 };
51 
52 #define vb2_queue_to_isys_queue(__vb2) \
53 	container_of(__vb2, struct ipu6_isys_queue, vbq)
54 
55 #define ipu6_isys_to_isys_video_buffer(__ib) \
56 	container_of(__ib, struct ipu6_isys_video_buffer, ib)
57 
58 #define vb2_buffer_to_ipu6_isys_video_buffer(__vvb) \
59 	container_of(__vvb, struct ipu6_isys_video_buffer, vb_v4l2)
60 
61 #define ipu6_isys_buffer_to_vb2_buffer(__ib) \
62 	(&ipu6_isys_to_isys_video_buffer(__ib)->vb_v4l2.vb2_buf)
63 
64 void ipu6_isys_buffer_list_queue(struct ipu6_isys_buffer_list *bl,
65 				 unsigned long op_flags,
66 				 enum vb2_buffer_state state);
67 void
68 ipu6_isys_buf_to_fw_frame_buf(struct ipu6_fw_isys_frame_buff_set_abi *set,
69 			      struct ipu6_isys_stream *stream,
70 			      struct ipu6_isys_buffer_list *bl);
71 void
72 ipu6_isys_buf_calc_sequence_time(struct ipu6_isys_buffer *ib,
73 				 struct ipu6_fw_isys_resp_info_abi *info);
74 void ipu6_isys_queue_buf_done(struct ipu6_isys_buffer *ib);
75 void ipu6_isys_queue_buf_ready(struct ipu6_isys_stream *stream,
76 			       struct ipu6_fw_isys_resp_info_abi *info);
77 int ipu6_isys_queue_init(struct ipu6_isys_queue *aq);
78 #endif /* IPU6_ISYS_QUEUE_H */
79