This source file includes following definitions.
- to_mipi_dsi_device
- mipi_dsi_pixel_format_to_bpp
- to_mipi_dsi_driver
- mipi_dsi_get_drvdata
- mipi_dsi_set_drvdata
1
2
3
4
5
6
7
8
9 #ifndef __DRM_MIPI_DSI_H__
10 #define __DRM_MIPI_DSI_H__
11
12 #include <linux/device.h>
13
14 struct mipi_dsi_host;
15 struct mipi_dsi_device;
16
17
18 #define MIPI_DSI_MSG_REQ_ACK BIT(0)
19
20 #define MIPI_DSI_MSG_USE_LPM BIT(1)
21
22
23
24
25
26
27
28
29
30
31
32 struct mipi_dsi_msg {
33 u8 channel;
34 u8 type;
35 u16 flags;
36
37 size_t tx_len;
38 const void *tx_buf;
39
40 size_t rx_len;
41 void *rx_buf;
42 };
43
44 bool mipi_dsi_packet_format_is_short(u8 type);
45 bool mipi_dsi_packet_format_is_long(u8 type);
46
47
48
49
50
51
52
53
54
55 struct mipi_dsi_packet {
56 size_t size;
57 u8 header[4];
58 size_t payload_length;
59 const u8 *payload;
60 };
61
62 int mipi_dsi_create_packet(struct mipi_dsi_packet *packet,
63 const struct mipi_dsi_msg *msg);
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83 struct mipi_dsi_host_ops {
84 int (*attach)(struct mipi_dsi_host *host,
85 struct mipi_dsi_device *dsi);
86 int (*detach)(struct mipi_dsi_host *host,
87 struct mipi_dsi_device *dsi);
88 ssize_t (*transfer)(struct mipi_dsi_host *host,
89 const struct mipi_dsi_msg *msg);
90 };
91
92
93
94
95
96
97
98 struct mipi_dsi_host {
99 struct device *dev;
100 const struct mipi_dsi_host_ops *ops;
101 struct list_head list;
102 };
103
104 int mipi_dsi_host_register(struct mipi_dsi_host *host);
105 void mipi_dsi_host_unregister(struct mipi_dsi_host *host);
106 struct mipi_dsi_host *of_find_mipi_dsi_host_by_node(struct device_node *node);
107
108
109
110
111 #define MIPI_DSI_MODE_VIDEO BIT(0)
112
113 #define MIPI_DSI_MODE_VIDEO_BURST BIT(1)
114
115 #define MIPI_DSI_MODE_VIDEO_SYNC_PULSE BIT(2)
116
117 #define MIPI_DSI_MODE_VIDEO_AUTO_VERT BIT(3)
118
119 #define MIPI_DSI_MODE_VIDEO_HSE BIT(4)
120
121 #define MIPI_DSI_MODE_VIDEO_HFP BIT(5)
122
123 #define MIPI_DSI_MODE_VIDEO_HBP BIT(6)
124
125 #define MIPI_DSI_MODE_VIDEO_HSA BIT(7)
126
127 #define MIPI_DSI_MODE_VSYNC_FLUSH BIT(8)
128
129 #define MIPI_DSI_MODE_EOT_PACKET BIT(9)
130
131 #define MIPI_DSI_CLOCK_NON_CONTINUOUS BIT(10)
132
133 #define MIPI_DSI_MODE_LPM BIT(11)
134
135 enum mipi_dsi_pixel_format {
136 MIPI_DSI_FMT_RGB888,
137 MIPI_DSI_FMT_RGB666,
138 MIPI_DSI_FMT_RGB666_PACKED,
139 MIPI_DSI_FMT_RGB565,
140 };
141
142 #define DSI_DEV_NAME_SIZE 20
143
144
145
146
147
148
149
150
151
152
153 struct mipi_dsi_device_info {
154 char type[DSI_DEV_NAME_SIZE];
155 u32 channel;
156 struct device_node *node;
157 };
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175 struct mipi_dsi_device {
176 struct mipi_dsi_host *host;
177 struct device dev;
178
179 char name[DSI_DEV_NAME_SIZE];
180 unsigned int channel;
181 unsigned int lanes;
182 enum mipi_dsi_pixel_format format;
183 unsigned long mode_flags;
184 unsigned long hs_rate;
185 unsigned long lp_rate;
186 };
187
188 #define MIPI_DSI_MODULE_PREFIX "mipi-dsi:"
189
190 static inline struct mipi_dsi_device *to_mipi_dsi_device(struct device *dev)
191 {
192 return container_of(dev, struct mipi_dsi_device, dev);
193 }
194
195
196
197
198
199
200
201
202
203 static inline int mipi_dsi_pixel_format_to_bpp(enum mipi_dsi_pixel_format fmt)
204 {
205 switch (fmt) {
206 case MIPI_DSI_FMT_RGB888:
207 case MIPI_DSI_FMT_RGB666:
208 return 24;
209
210 case MIPI_DSI_FMT_RGB666_PACKED:
211 return 18;
212
213 case MIPI_DSI_FMT_RGB565:
214 return 16;
215 }
216
217 return -EINVAL;
218 }
219
220 struct mipi_dsi_device *
221 mipi_dsi_device_register_full(struct mipi_dsi_host *host,
222 const struct mipi_dsi_device_info *info);
223 void mipi_dsi_device_unregister(struct mipi_dsi_device *dsi);
224 struct mipi_dsi_device *of_find_mipi_dsi_device_by_node(struct device_node *np);
225 int mipi_dsi_attach(struct mipi_dsi_device *dsi);
226 int mipi_dsi_detach(struct mipi_dsi_device *dsi);
227 int mipi_dsi_shutdown_peripheral(struct mipi_dsi_device *dsi);
228 int mipi_dsi_turn_on_peripheral(struct mipi_dsi_device *dsi);
229 int mipi_dsi_set_maximum_return_packet_size(struct mipi_dsi_device *dsi,
230 u16 value);
231
232 ssize_t mipi_dsi_generic_write(struct mipi_dsi_device *dsi, const void *payload,
233 size_t size);
234 ssize_t mipi_dsi_generic_read(struct mipi_dsi_device *dsi, const void *params,
235 size_t num_params, void *data, size_t size);
236
237
238
239
240
241
242
243
244 enum mipi_dsi_dcs_tear_mode {
245 MIPI_DSI_DCS_TEAR_MODE_VBLANK,
246 MIPI_DSI_DCS_TEAR_MODE_VHBLANK,
247 };
248
249 #define MIPI_DSI_DCS_POWER_MODE_DISPLAY (1 << 2)
250 #define MIPI_DSI_DCS_POWER_MODE_NORMAL (1 << 3)
251 #define MIPI_DSI_DCS_POWER_MODE_SLEEP (1 << 4)
252 #define MIPI_DSI_DCS_POWER_MODE_PARTIAL (1 << 5)
253 #define MIPI_DSI_DCS_POWER_MODE_IDLE (1 << 6)
254
255 ssize_t mipi_dsi_dcs_write_buffer(struct mipi_dsi_device *dsi,
256 const void *data, size_t len);
257 ssize_t mipi_dsi_dcs_write(struct mipi_dsi_device *dsi, u8 cmd,
258 const void *data, size_t len);
259 ssize_t mipi_dsi_dcs_read(struct mipi_dsi_device *dsi, u8 cmd, void *data,
260 size_t len);
261 int mipi_dsi_dcs_nop(struct mipi_dsi_device *dsi);
262 int mipi_dsi_dcs_soft_reset(struct mipi_dsi_device *dsi);
263 int mipi_dsi_dcs_get_power_mode(struct mipi_dsi_device *dsi, u8 *mode);
264 int mipi_dsi_dcs_get_pixel_format(struct mipi_dsi_device *dsi, u8 *format);
265 int mipi_dsi_dcs_enter_sleep_mode(struct mipi_dsi_device *dsi);
266 int mipi_dsi_dcs_exit_sleep_mode(struct mipi_dsi_device *dsi);
267 int mipi_dsi_dcs_set_display_off(struct mipi_dsi_device *dsi);
268 int mipi_dsi_dcs_set_display_on(struct mipi_dsi_device *dsi);
269 int mipi_dsi_dcs_set_column_address(struct mipi_dsi_device *dsi, u16 start,
270 u16 end);
271 int mipi_dsi_dcs_set_page_address(struct mipi_dsi_device *dsi, u16 start,
272 u16 end);
273 int mipi_dsi_dcs_set_tear_off(struct mipi_dsi_device *dsi);
274 int mipi_dsi_dcs_set_tear_on(struct mipi_dsi_device *dsi,
275 enum mipi_dsi_dcs_tear_mode mode);
276 int mipi_dsi_dcs_set_pixel_format(struct mipi_dsi_device *dsi, u8 format);
277 int mipi_dsi_dcs_set_tear_scanline(struct mipi_dsi_device *dsi, u16 scanline);
278 int mipi_dsi_dcs_set_display_brightness(struct mipi_dsi_device *dsi,
279 u16 brightness);
280 int mipi_dsi_dcs_get_display_brightness(struct mipi_dsi_device *dsi,
281 u16 *brightness);
282
283
284
285
286
287
288
289
290 struct mipi_dsi_driver {
291 struct device_driver driver;
292 int(*probe)(struct mipi_dsi_device *dsi);
293 int(*remove)(struct mipi_dsi_device *dsi);
294 void (*shutdown)(struct mipi_dsi_device *dsi);
295 };
296
297 static inline struct mipi_dsi_driver *
298 to_mipi_dsi_driver(struct device_driver *driver)
299 {
300 return container_of(driver, struct mipi_dsi_driver, driver);
301 }
302
303 static inline void *mipi_dsi_get_drvdata(const struct mipi_dsi_device *dsi)
304 {
305 return dev_get_drvdata(&dsi->dev);
306 }
307
308 static inline void mipi_dsi_set_drvdata(struct mipi_dsi_device *dsi, void *data)
309 {
310 dev_set_drvdata(&dsi->dev, data);
311 }
312
313 int mipi_dsi_driver_register_full(struct mipi_dsi_driver *driver,
314 struct module *owner);
315 void mipi_dsi_driver_unregister(struct mipi_dsi_driver *driver);
316
317 #define mipi_dsi_driver_register(driver) \
318 mipi_dsi_driver_register_full(driver, THIS_MODULE)
319
320 #define module_mipi_dsi_driver(__mipi_dsi_driver) \
321 module_driver(__mipi_dsi_driver, mipi_dsi_driver_register, \
322 mipi_dsi_driver_unregister)
323
324 #endif