1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17#ifndef __RCAR_VIN__
18#define __RCAR_VIN__
19
20#include <media/v4l2-async.h>
21#include <media/v4l2-ctrls.h>
22#include <media/v4l2-dev.h>
23#include <media/v4l2-device.h>
24#include <media/videobuf2-v4l2.h>
25
26
27#define HW_BUFFER_NUM 3
28
29
30#define HW_BUFFER_MASK 0x7f
31
32enum chip_id {
33 RCAR_H1,
34 RCAR_M1,
35 RCAR_GEN2,
36};
37
38
39
40
41
42
43
44enum rvin_dma_state {
45 STOPPED = 0,
46 RUNNING,
47 STALLED,
48 STOPPING,
49};
50
51
52
53
54
55
56struct rvin_source_fmt {
57 u32 width;
58 u32 height;
59};
60
61
62
63
64
65
66struct rvin_video_format {
67 u32 fourcc;
68 u8 bpp;
69};
70
71
72
73
74
75
76
77
78struct rvin_graph_entity {
79 struct v4l2_async_subdev asd;
80 struct v4l2_subdev *subdev;
81
82 u32 code;
83 struct v4l2_mbus_config mbus_cfg;
84};
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117struct rvin_dev {
118 struct device *dev;
119 void __iomem *base;
120 enum chip_id chip;
121
122 struct video_device vdev;
123 struct v4l2_device v4l2_dev;
124 int src_pad_idx;
125 int sink_pad_idx;
126 struct v4l2_ctrl_handler ctrl_handler;
127 struct v4l2_async_notifier notifier;
128 struct rvin_graph_entity digital;
129
130 struct mutex lock;
131 struct vb2_queue queue;
132
133 spinlock_t qlock;
134 struct vb2_v4l2_buffer *queue_buf[HW_BUFFER_NUM];
135 struct list_head buf_list;
136 bool continuous;
137 unsigned int sequence;
138 enum rvin_dma_state state;
139
140 struct rvin_source_fmt source;
141 struct v4l2_pix_format format;
142
143 struct v4l2_rect crop;
144 struct v4l2_rect compose;
145};
146
147#define vin_to_source(vin) vin->digital.subdev
148
149
150#define vin_dbg(d, fmt, arg...) dev_dbg(d->dev, fmt, ##arg)
151#define vin_info(d, fmt, arg...) dev_info(d->dev, fmt, ##arg)
152#define vin_warn(d, fmt, arg...) dev_warn(d->dev, fmt, ##arg)
153#define vin_err(d, fmt, arg...) dev_err(d->dev, fmt, ##arg)
154
155int rvin_dma_probe(struct rvin_dev *vin, int irq);
156void rvin_dma_remove(struct rvin_dev *vin);
157
158int rvin_v4l2_probe(struct rvin_dev *vin);
159void rvin_v4l2_remove(struct rvin_dev *vin);
160
161const struct rvin_video_format *rvin_format_from_pixel(u32 pixelformat);
162
163
164void rvin_scale_try(struct rvin_dev *vin, struct v4l2_pix_format *pix,
165 u32 width, u32 height);
166void rvin_crop_scale_comp(struct rvin_dev *vin);
167
168#endif
169