1
2
3
4
5
6
7
8
9
10#ifndef QC_MSM_CAMSS_CSID_H
11#define QC_MSM_CAMSS_CSID_H
12
13#include <linux/clk.h>
14#include <linux/interrupt.h>
15#include <media/media-entity.h>
16#include <media/v4l2-ctrls.h>
17#include <media/v4l2-device.h>
18#include <media/v4l2-mediabus.h>
19#include <media/v4l2-subdev.h>
20
21#define MSM_CSID_PAD_SINK 0
22#define MSM_CSID_PAD_SRC 1
23#define MSM_CSID_PADS_NUM 2
24
25#define DATA_TYPE_EMBEDDED_DATA_8BIT 0x12
26#define DATA_TYPE_YUV420_8BIT 0x18
27#define DATA_TYPE_YUV420_10BIT 0x19
28#define DATA_TYPE_YUV420_8BIT_LEGACY 0x1a
29#define DATA_TYPE_YUV420_8BIT_SHIFTED 0x1c
30#define DATA_TYPE_YUV420_10BIT_SHIFTED 0x1d
31#define DATA_TYPE_YUV422_8BIT 0x1e
32#define DATA_TYPE_YUV422_10BIT 0x1f
33#define DATA_TYPE_RGB444 0x20
34#define DATA_TYPE_RGB555 0x21
35#define DATA_TYPE_RGB565 0x22
36#define DATA_TYPE_RGB666 0x23
37#define DATA_TYPE_RGB888 0x24
38#define DATA_TYPE_RAW_24BIT 0x27
39#define DATA_TYPE_RAW_6BIT 0x28
40#define DATA_TYPE_RAW_7BIT 0x29
41#define DATA_TYPE_RAW_8BIT 0x2a
42#define DATA_TYPE_RAW_10BIT 0x2b
43#define DATA_TYPE_RAW_12BIT 0x2c
44#define DATA_TYPE_RAW_14BIT 0x2d
45#define DATA_TYPE_RAW_16BIT 0x2e
46#define DATA_TYPE_RAW_20BIT 0x2f
47
48#define CSID_RESET_TIMEOUT_MS 500
49
50enum csid_testgen_mode {
51 CSID_PAYLOAD_MODE_DISABLED = 0,
52 CSID_PAYLOAD_MODE_INCREMENTING = 1,
53 CSID_PAYLOAD_MODE_ALTERNATING_55_AA = 2,
54 CSID_PAYLOAD_MODE_ALL_ZEROES = 3,
55 CSID_PAYLOAD_MODE_ALL_ONES = 4,
56 CSID_PAYLOAD_MODE_RANDOM = 5,
57 CSID_PAYLOAD_MODE_USER_SPECIFIED = 6,
58 CSID_PAYLOAD_MODE_NUM_SUPPORTED_GEN1 = 6,
59 CSID_PAYLOAD_MODE_COMPLEX_PATTERN = 7,
60 CSID_PAYLOAD_MODE_COLOR_BOX = 8,
61 CSID_PAYLOAD_MODE_COLOR_BARS = 9,
62 CSID_PAYLOAD_MODE_NUM_SUPPORTED_GEN2 = 9,
63};
64
65struct csid_format {
66 u32 code;
67 u8 data_type;
68 u8 decode_format;
69 u8 bpp;
70 u8 spp;
71};
72
73struct csid_testgen_config {
74 enum csid_testgen_mode mode;
75 const char * const*modes;
76 u8 nmodes;
77 u8 enabled;
78};
79
80struct csid_phy_config {
81 u8 csiphy_id;
82 u8 lane_cnt;
83 u32 lane_assign;
84};
85
86struct csid_device;
87
88struct csid_hw_ops {
89
90
91
92
93 void (*configure_stream)(struct csid_device *csid, u8 enable);
94
95
96
97
98
99
100 int (*configure_testgen_pattern)(struct csid_device *csid, s32 val);
101
102
103
104
105
106 u32 (*hw_version)(struct csid_device *csid);
107
108
109
110
111
112
113
114
115 irqreturn_t (*isr)(int irq, void *dev);
116
117
118
119
120
121
122
123 int (*reset)(struct csid_device *csid);
124
125
126
127
128
129
130
131
132
133
134
135 u32 (*src_pad_code)(struct csid_device *csid, u32 sink_code,
136 unsigned int match_format_idx, u32 match_code);
137
138
139
140
141
142 void (*subdev_init)(struct csid_device *csid);
143};
144
145struct csid_device {
146 struct camss *camss;
147 u8 id;
148 struct v4l2_subdev subdev;
149 struct media_pad pads[MSM_CSID_PADS_NUM];
150 void __iomem *base;
151 u32 irq;
152 char irq_name[30];
153 struct camss_clock *clock;
154 int nclocks;
155 struct regulator *vdda;
156 struct completion reset_complete;
157 struct csid_testgen_config testgen;
158 struct csid_phy_config phy;
159 struct v4l2_mbus_framefmt fmt[MSM_CSID_PADS_NUM];
160 struct v4l2_ctrl_handler ctrls;
161 struct v4l2_ctrl *testgen_mode;
162 const struct csid_format *formats;
163 unsigned int nformats;
164 const struct csid_hw_ops *ops;
165};
166
167struct resources;
168
169
170
171
172
173
174
175
176
177
178
179u32 csid_find_code(u32 *codes, unsigned int ncode,
180 unsigned int match_format_idx, u32 match_code);
181
182
183
184
185
186
187
188
189
190const struct csid_format *csid_get_fmt_entry(const struct csid_format *formats,
191 unsigned int nformats,
192 u32 code);
193
194int msm_csid_subdev_init(struct camss *camss, struct csid_device *csid,
195 const struct resources *res, u8 id);
196
197int msm_csid_register_entity(struct csid_device *csid,
198 struct v4l2_device *v4l2_dev);
199
200void msm_csid_unregister_entity(struct csid_device *csid);
201
202void msm_csid_get_csid_id(struct media_entity *entity, u8 *id);
203
204extern const char * const csid_testgen_modes[];
205
206extern const struct csid_hw_ops csid_ops_4_1;
207extern const struct csid_hw_ops csid_ops_4_7;
208extern const struct csid_hw_ops csid_ops_170;
209
210
211#endif
212