summaryrefslogtreecommitdiffstats
path: root/drivers/media/pci/intel/ipu6/ipu6-isys-queue.h
blob: 95cfd4869d935635512ae534d139db5a1529ad36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/* SPDX-License-Identifier: GPL-2.0-only */
/* Copyright (C) 2013--2024 Intel Corporation */

#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;
	struct device *dev;
	/*
	 * @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;
};

#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)

void ipu6_isys_buffer_list_queue(struct ipu6_isys_buffer_list *bl,
				 unsigned long op_flags,
				 enum vb2_buffer_state state);
void
ipu6_isys_buf_to_fw_frame_buf(struct ipu6_fw_isys_frame_buff_set_abi *set,
			      struct ipu6_isys_stream *stream,
			      struct ipu6_isys_buffer_list *bl);
void
ipu6_isys_buf_calc_sequence_time(struct ipu6_isys_buffer *ib,
				 struct ipu6_fw_isys_resp_info_abi *info);
void ipu6_isys_queue_buf_done(struct ipu6_isys_buffer *ib);
void ipu6_isys_queue_buf_ready(struct ipu6_isys_stream *stream,
			       struct ipu6_fw_isys_resp_info_abi *info);
int ipu6_isys_queue_init(struct ipu6_isys_queue *aq);
#endif /* IPU6_ISYS_QUEUE_H */