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 dma_addr_t dma_addr; 42 }; 43 44 #define IPU6_ISYS_BUFFER_LIST_FL_INCOMING BIT(0) 45 #define IPU6_ISYS_BUFFER_LIST_FL_ACTIVE BIT(1) 46 #define IPU6_ISYS_BUFFER_LIST_FL_SET_STATE BIT(2) 47 48 struct ipu6_isys_buffer_list { 49 struct list_head head; 50 unsigned int nbufs; 51 }; 52 53 #define vb2_queue_to_isys_queue(__vb2) \ 54 container_of(__vb2, struct ipu6_isys_queue, vbq) 55 56 #define ipu6_isys_to_isys_video_buffer(__ib) \ 57 container_of(__ib, struct ipu6_isys_video_buffer, ib) 58 59 #define vb2_buffer_to_ipu6_isys_video_buffer(__vvb) \ 60 container_of(__vvb, struct ipu6_isys_video_buffer, vb_v4l2) 61 62 #define ipu6_isys_buffer_to_vb2_buffer(__ib) \ 63 (&ipu6_isys_to_isys_video_buffer(__ib)->vb_v4l2.vb2_buf) 64 65 void ipu6_isys_buffer_list_queue(struct ipu6_isys_buffer_list *bl, 66 unsigned long op_flags, 67 enum vb2_buffer_state state); 68 void 69 ipu6_isys_buf_to_fw_frame_buf(struct ipu6_fw_isys_frame_buff_set_abi *set, 70 struct ipu6_isys_stream *stream, 71 struct ipu6_isys_buffer_list *bl); 72 void 73 ipu6_isys_buf_calc_sequence_time(struct ipu6_isys_buffer *ib, 74 struct ipu6_fw_isys_resp_info_abi *info); 75 void ipu6_isys_queue_buf_done(struct ipu6_isys_buffer *ib); 76 void ipu6_isys_queue_buf_ready(struct ipu6_isys_stream *stream, 77 struct ipu6_fw_isys_resp_info_abi *info); 78 int ipu6_isys_queue_init(struct ipu6_isys_queue *aq); 79 #endif /* IPU6_ISYS_QUEUE_H */ 80