1
2
3
4 #ifndef __IPU3_H
5 #define __IPU3_H
6
7 #include <linux/iova.h>
8 #include <linux/pci.h>
9
10 #include <media/v4l2-ctrls.h>
11 #include <media/v4l2-device.h>
12 #include <media/videobuf2-dma-sg.h>
13
14 #include "ipu3-css.h"
15
16 #define IMGU_NAME "ipu3-imgu"
17
18
19
20
21
22
23
24 #define IMGU_QUEUE_MASTER IPU3_CSS_QUEUE_IN
25 #define IMGU_QUEUE_FIRST_INPUT IPU3_CSS_QUEUE_OUT
26 #define IMGU_MAX_QUEUE_DEPTH (2 + 2)
27
28 #define IMGU_NODE_IN 0
29 #define IMGU_NODE_PARAMS 1
30 #define IMGU_NODE_OUT 2
31 #define IMGU_NODE_VF 3
32 #define IMGU_NODE_STAT_3A 4
33 #define IMGU_NODE_NUM 5
34
35 #define file_to_intel_imgu_node(__file) \
36 container_of(video_devdata(__file), struct imgu_video_device, vdev)
37
38 #define IPU3_INPUT_MIN_WIDTH 0U
39 #define IPU3_INPUT_MIN_HEIGHT 0U
40 #define IPU3_INPUT_MAX_WIDTH 5120U
41 #define IPU3_INPUT_MAX_HEIGHT 38404U
42 #define IPU3_OUTPUT_MIN_WIDTH 2U
43 #define IPU3_OUTPUT_MIN_HEIGHT 2U
44 #define IPU3_OUTPUT_MAX_WIDTH 4480U
45 #define IPU3_OUTPUT_MAX_HEIGHT 34004U
46
47 struct imgu_vb2_buffer {
48
49 struct vb2_v4l2_buffer vbb;
50
51
52 struct list_head list;
53 };
54
55 struct imgu_buffer {
56 struct imgu_vb2_buffer vid_buf;
57 struct imgu_css_buffer css_buf;
58 struct imgu_css_map map;
59 };
60
61 struct imgu_node_mapping {
62 unsigned int css_queue;
63 const char *name;
64 };
65
66
67
68
69
70
71 struct imgu_video_device {
72 const char *name;
73 bool output;
74 bool enabled;
75 struct v4l2_format vdev_fmt;
76
77
78 struct video_device vdev;
79 struct media_pad vdev_pad;
80 struct v4l2_mbus_framefmt pad_fmt;
81 struct vb2_queue vbq;
82 struct list_head buffers;
83
84 struct mutex lock;
85 atomic_t sequence;
86 unsigned int id;
87 unsigned int pipe;
88 };
89
90 struct imgu_v4l2_subdev {
91 unsigned int pipe;
92 struct v4l2_subdev subdev;
93 struct media_pad subdev_pads[IMGU_NODE_NUM];
94 struct {
95 struct v4l2_rect eff;
96 struct v4l2_rect bds;
97 struct v4l2_rect gdc;
98 } rect;
99 struct v4l2_ctrl_handler ctrl_handler;
100 struct v4l2_ctrl *ctrl;
101 atomic_t running_mode;
102 bool active;
103 };
104
105 struct imgu_media_pipe {
106 unsigned int pipe;
107
108
109 struct {
110 struct imgu_css_map dmap;
111 struct imgu_css_buffer dummybufs[IMGU_MAX_QUEUE_DEPTH];
112 } queues[IPU3_CSS_QUEUES];
113 struct imgu_video_device nodes[IMGU_NODE_NUM];
114 bool queue_enabled[IMGU_NODE_NUM];
115 struct media_pipeline pipeline;
116 struct imgu_v4l2_subdev imgu_sd;
117 };
118
119
120
121
122 struct imgu_device {
123 struct pci_dev *pci_dev;
124 void __iomem *base;
125
126
127 unsigned int buf_struct_size;
128 bool streaming;
129
130 struct imgu_media_pipe imgu_pipe[IMGU_MAX_PIPE_NUM];
131
132
133 struct v4l2_device v4l2_dev;
134 struct media_device media_dev;
135 struct v4l2_file_operations v4l2_file_ops;
136
137
138 struct imgu_mmu_info *mmu;
139 struct iova_domain iova_domain;
140
141
142 struct imgu_css css;
143
144
145
146
147
148 struct mutex lock;
149
150 atomic_t qbuf_barrier;
151
152 bool suspend_in_stream;
153
154 wait_queue_head_t buf_drain_wq;
155 };
156
157 unsigned int imgu_node_to_queue(unsigned int node);
158 unsigned int imgu_map_node(struct imgu_device *imgu, unsigned int css_queue);
159 int imgu_queue_buffers(struct imgu_device *imgu, bool initial,
160 unsigned int pipe);
161
162 int imgu_v4l2_register(struct imgu_device *dev);
163 int imgu_v4l2_unregister(struct imgu_device *dev);
164 void imgu_v4l2_buffer_done(struct vb2_buffer *vb, enum vb2_buffer_state state);
165
166 int imgu_s_stream(struct imgu_device *imgu, int enable);
167
168 #endif