Rev 6088 | Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
6084 | serge | 1 | /* |
2 | * MIPI DSI Bus |
||
3 | * |
||
4 | * Copyright (C) 2012-2013, Samsung Electronics, Co., Ltd. |
||
5 | * Andrzej Hajda |
||
6 | * |
||
7 | * Permission is hereby granted, free of charge, to any person obtaining a |
||
8 | * copy of this software and associated documentation files (the |
||
9 | * "Software"), to deal in the Software without restriction, including |
||
10 | * without limitation the rights to use, copy, modify, merge, publish, |
||
11 | * distribute, sub license, and/or sell copies of the Software, and to |
||
12 | * permit persons to whom the Software is furnished to do so, subject to |
||
13 | * the following conditions: |
||
14 | * |
||
15 | * The above copyright notice and this permission notice (including the |
||
16 | * next paragraph) shall be included in all copies or substantial portions |
||
17 | * of the Software. |
||
18 | * |
||
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL |
||
22 | * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, |
||
23 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
||
24 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE |
||
25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. |
||
26 | */ |
||
27 | |||
28 | #include |
||
29 | #include |
||
30 | |||
31 | #include |
||
32 | #include |
||
33 | //#include |
||
34 | #include |
||
35 | //#include |
||
36 | |||
37 | #include |
||
38 | |||
39 | |||
40 | /** |
||
41 | * mipi_dsi_attach - attach a DSI device to its DSI host |
||
42 | * @dsi: DSI peripheral |
||
43 | */ |
||
44 | int mipi_dsi_attach(struct mipi_dsi_device *dsi) |
||
45 | { |
||
46 | const struct mipi_dsi_host_ops *ops = dsi->host->ops; |
||
47 | |||
48 | if (!ops || !ops->attach) |
||
49 | return -ENOSYS; |
||
50 | |||
51 | return ops->attach(dsi->host, dsi); |
||
52 | } |
||
53 | EXPORT_SYMBOL(mipi_dsi_attach); |
||
54 | |||
55 | static ssize_t mipi_dsi_device_transfer(struct mipi_dsi_device *dsi, |
||
56 | struct mipi_dsi_msg *msg) |
||
57 | { |
||
58 | const struct mipi_dsi_host_ops *ops = dsi->host->ops; |
||
59 | |||
60 | if (!ops || !ops->transfer) |
||
61 | return -ENOSYS; |
||
62 | |||
63 | if (dsi->mode_flags & MIPI_DSI_MODE_LPM) |
||
64 | msg->flags |= MIPI_DSI_MSG_USE_LPM; |
||
65 | |||
66 | return ops->transfer(dsi->host, msg); |
||
67 | } |
||
68 | |||
69 | /** |
||
70 | * mipi_dsi_packet_format_is_short - check if a packet is of the short format |
||
71 | * @type: MIPI DSI data type of the packet |
||
72 | * |
||
73 | * Return: true if the packet for the given data type is a short packet, false |
||
74 | * otherwise. |
||
75 | */ |
||
76 | bool mipi_dsi_packet_format_is_short(u8 type) |
||
77 | { |
||
78 | switch (type) { |
||
79 | case MIPI_DSI_V_SYNC_START: |
||
80 | case MIPI_DSI_V_SYNC_END: |
||
81 | case MIPI_DSI_H_SYNC_START: |
||
82 | case MIPI_DSI_H_SYNC_END: |
||
83 | case MIPI_DSI_END_OF_TRANSMISSION: |
||
84 | case MIPI_DSI_COLOR_MODE_OFF: |
||
85 | case MIPI_DSI_COLOR_MODE_ON: |
||
86 | case MIPI_DSI_SHUTDOWN_PERIPHERAL: |
||
87 | case MIPI_DSI_TURN_ON_PERIPHERAL: |
||
88 | case MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM: |
||
89 | case MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM: |
||
90 | case MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM: |
||
91 | case MIPI_DSI_GENERIC_READ_REQUEST_0_PARAM: |
||
92 | case MIPI_DSI_GENERIC_READ_REQUEST_1_PARAM: |
||
93 | case MIPI_DSI_GENERIC_READ_REQUEST_2_PARAM: |
||
94 | case MIPI_DSI_DCS_SHORT_WRITE: |
||
95 | case MIPI_DSI_DCS_SHORT_WRITE_PARAM: |
||
96 | case MIPI_DSI_DCS_READ: |
||
97 | case MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE: |
||
98 | return true; |
||
99 | } |
||
100 | |||
101 | return false; |
||
102 | } |
||
103 | EXPORT_SYMBOL(mipi_dsi_packet_format_is_short); |
||
104 | |||
105 | /** |
||
106 | * mipi_dsi_packet_format_is_long - check if a packet is of the long format |
||
107 | * @type: MIPI DSI data type of the packet |
||
108 | * |
||
109 | * Return: true if the packet for the given data type is a long packet, false |
||
110 | * otherwise. |
||
111 | */ |
||
112 | bool mipi_dsi_packet_format_is_long(u8 type) |
||
113 | { |
||
114 | switch (type) { |
||
115 | case MIPI_DSI_NULL_PACKET: |
||
116 | case MIPI_DSI_BLANKING_PACKET: |
||
117 | case MIPI_DSI_GENERIC_LONG_WRITE: |
||
118 | case MIPI_DSI_DCS_LONG_WRITE: |
||
119 | case MIPI_DSI_LOOSELY_PACKED_PIXEL_STREAM_YCBCR20: |
||
120 | case MIPI_DSI_PACKED_PIXEL_STREAM_YCBCR24: |
||
121 | case MIPI_DSI_PACKED_PIXEL_STREAM_YCBCR16: |
||
122 | case MIPI_DSI_PACKED_PIXEL_STREAM_30: |
||
123 | case MIPI_DSI_PACKED_PIXEL_STREAM_36: |
||
124 | case MIPI_DSI_PACKED_PIXEL_STREAM_YCBCR12: |
||
125 | case MIPI_DSI_PACKED_PIXEL_STREAM_16: |
||
126 | case MIPI_DSI_PACKED_PIXEL_STREAM_18: |
||
127 | case MIPI_DSI_PIXEL_STREAM_3BYTE_18: |
||
128 | case MIPI_DSI_PACKED_PIXEL_STREAM_24: |
||
129 | return true; |
||
130 | } |
||
131 | |||
132 | return false; |
||
133 | } |
||
134 | EXPORT_SYMBOL(mipi_dsi_packet_format_is_long); |
||
135 | |||
136 | /** |
||
137 | * mipi_dsi_create_packet - create a packet from a message according to the |
||
138 | * DSI protocol |
||
139 | * @packet: pointer to a DSI packet structure |
||
140 | * @msg: message to translate into a packet |
||
141 | * |
||
142 | * Return: 0 on success or a negative error code on failure. |
||
143 | */ |
||
144 | int mipi_dsi_create_packet(struct mipi_dsi_packet *packet, |
||
145 | const struct mipi_dsi_msg *msg) |
||
146 | { |
||
147 | if (!packet || !msg) |
||
148 | return -EINVAL; |
||
149 | |||
150 | /* do some minimum sanity checking */ |
||
151 | if (!mipi_dsi_packet_format_is_short(msg->type) && |
||
152 | !mipi_dsi_packet_format_is_long(msg->type)) |
||
153 | return -EINVAL; |
||
154 | |||
155 | if (msg->channel > 3) |
||
156 | return -EINVAL; |
||
157 | |||
158 | memset(packet, 0, sizeof(*packet)); |
||
159 | packet->header[0] = ((msg->channel & 0x3) << 6) | (msg->type & 0x3f); |
||
160 | |||
161 | /* TODO: compute ECC if hardware support is not available */ |
||
162 | |||
163 | /* |
||
164 | * Long write packets contain the word count in header bytes 1 and 2. |
||
165 | * The payload follows the header and is word count bytes long. |
||
166 | * |
||
167 | * Short write packets encode up to two parameters in header bytes 1 |
||
168 | * and 2. |
||
169 | */ |
||
170 | if (mipi_dsi_packet_format_is_long(msg->type)) { |
||
171 | packet->header[1] = (msg->tx_len >> 0) & 0xff; |
||
172 | packet->header[2] = (msg->tx_len >> 8) & 0xff; |
||
173 | |||
174 | packet->payload_length = msg->tx_len; |
||
175 | packet->payload = msg->tx_buf; |
||
176 | } else { |
||
177 | const u8 *tx = msg->tx_buf; |
||
178 | |||
179 | packet->header[1] = (msg->tx_len > 0) ? tx[0] : 0; |
||
180 | packet->header[2] = (msg->tx_len > 1) ? tx[1] : 0; |
||
181 | } |
||
182 | |||
183 | packet->size = sizeof(packet->header) + packet->payload_length; |
||
184 | |||
185 | return 0; |
||
186 | } |
||
187 | EXPORT_SYMBOL(mipi_dsi_create_packet); |
||
188 | |||
189 | /* |
||
190 | * mipi_dsi_set_maximum_return_packet_size() - specify the maximum size of the |
||
191 | * the payload in a long packet transmitted from the peripheral back to the |
||
192 | * host processor |
||
193 | * @dsi: DSI peripheral device |
||
194 | * @value: the maximum size of the payload |
||
195 | * |
||
196 | * Return: 0 on success or a negative error code on failure. |
||
197 | */ |
||
198 | int mipi_dsi_set_maximum_return_packet_size(struct mipi_dsi_device *dsi, |
||
199 | u16 value) |
||
200 | { |
||
201 | u8 tx[2] = { value & 0xff, value >> 8 }; |
||
202 | struct mipi_dsi_msg msg = { |
||
203 | .channel = dsi->channel, |
||
204 | .type = MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE, |
||
205 | .tx_len = sizeof(tx), |
||
206 | .tx_buf = tx, |
||
207 | }; |
||
208 | |||
209 | return mipi_dsi_device_transfer(dsi, &msg); |
||
210 | } |
||
211 | EXPORT_SYMBOL(mipi_dsi_set_maximum_return_packet_size); |
||
212 | |||
213 | /** |
||
214 | * mipi_dsi_generic_write() - transmit data using a generic write packet |
||
215 | * @dsi: DSI peripheral device |
||
216 | * @payload: buffer containing the payload |
||
217 | * @size: size of payload buffer |
||
218 | * |
||
219 | * This function will automatically choose the right data type depending on |
||
220 | * the payload length. |
||
221 | * |
||
222 | * Return: The number of bytes transmitted on success or a negative error code |
||
223 | * on failure. |
||
224 | */ |
||
225 | ssize_t mipi_dsi_generic_write(struct mipi_dsi_device *dsi, const void *payload, |
||
226 | size_t size) |
||
227 | { |
||
228 | struct mipi_dsi_msg msg = { |
||
229 | .channel = dsi->channel, |
||
230 | .tx_buf = payload, |
||
231 | .tx_len = size |
||
232 | }; |
||
233 | |||
234 | switch (size) { |
||
235 | case 0: |
||
236 | msg.type = MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM; |
||
237 | break; |
||
238 | |||
239 | case 1: |
||
240 | msg.type = MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM; |
||
241 | break; |
||
242 | |||
243 | case 2: |
||
244 | msg.type = MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM; |
||
245 | break; |
||
246 | |||
247 | default: |
||
248 | msg.type = MIPI_DSI_GENERIC_LONG_WRITE; |
||
249 | break; |
||
250 | } |
||
251 | |||
252 | return mipi_dsi_device_transfer(dsi, &msg); |
||
253 | } |
||
254 | EXPORT_SYMBOL(mipi_dsi_generic_write); |
||
255 | |||
256 | /** |
||
257 | * mipi_dsi_generic_read() - receive data using a generic read packet |
||
258 | * @dsi: DSI peripheral device |
||
259 | * @params: buffer containing the request parameters |
||
260 | * @num_params: number of request parameters |
||
261 | * @data: buffer in which to return the received data |
||
262 | * @size: size of receive buffer |
||
263 | * |
||
264 | * This function will automatically choose the right data type depending on |
||
265 | * the number of parameters passed in. |
||
266 | * |
||
267 | * Return: The number of bytes successfully read or a negative error code on |
||
268 | * failure. |
||
269 | */ |
||
270 | ssize_t mipi_dsi_generic_read(struct mipi_dsi_device *dsi, const void *params, |
||
271 | size_t num_params, void *data, size_t size) |
||
272 | { |
||
273 | struct mipi_dsi_msg msg = { |
||
274 | .channel = dsi->channel, |
||
275 | .tx_len = num_params, |
||
276 | .tx_buf = params, |
||
277 | .rx_len = size, |
||
278 | .rx_buf = data |
||
279 | }; |
||
280 | |||
281 | switch (num_params) { |
||
282 | case 0: |
||
283 | msg.type = MIPI_DSI_GENERIC_READ_REQUEST_0_PARAM; |
||
284 | break; |
||
285 | |||
286 | case 1: |
||
287 | msg.type = MIPI_DSI_GENERIC_READ_REQUEST_1_PARAM; |
||
288 | break; |
||
289 | |||
290 | case 2: |
||
291 | msg.type = MIPI_DSI_GENERIC_READ_REQUEST_2_PARAM; |
||
292 | break; |
||
293 | |||
294 | default: |
||
295 | return -EINVAL; |
||
296 | } |
||
297 | |||
298 | return mipi_dsi_device_transfer(dsi, &msg); |
||
299 | } |
||
300 | EXPORT_SYMBOL(mipi_dsi_generic_read); |
||
301 | |||
302 | /** |
||
303 | * mipi_dsi_dcs_write_buffer() - transmit a DCS command with payload |
||
304 | * @dsi: DSI peripheral device |
||
305 | * @data: buffer containing data to be transmitted |
||
306 | * @len: size of transmission buffer |
||
307 | * |
||
308 | * This function will automatically choose the right data type depending on |
||
309 | * the command payload length. |
||
310 | * |
||
311 | * Return: The number of bytes successfully transmitted or a negative error |
||
312 | * code on failure. |
||
313 | */ |
||
314 | ssize_t mipi_dsi_dcs_write_buffer(struct mipi_dsi_device *dsi, |
||
315 | const void *data, size_t len) |
||
316 | { |
||
317 | struct mipi_dsi_msg msg = { |
||
318 | .channel = dsi->channel, |
||
319 | .tx_buf = data, |
||
320 | .tx_len = len |
||
321 | }; |
||
322 | |||
323 | switch (len) { |
||
324 | case 0: |
||
325 | return -EINVAL; |
||
326 | |||
327 | case 1: |
||
328 | msg.type = MIPI_DSI_DCS_SHORT_WRITE; |
||
329 | break; |
||
330 | |||
331 | case 2: |
||
332 | msg.type = MIPI_DSI_DCS_SHORT_WRITE_PARAM; |
||
333 | break; |
||
334 | |||
335 | default: |
||
336 | msg.type = MIPI_DSI_DCS_LONG_WRITE; |
||
337 | break; |
||
338 | } |
||
339 | |||
340 | return mipi_dsi_device_transfer(dsi, &msg); |
||
341 | } |
||
342 | EXPORT_SYMBOL(mipi_dsi_dcs_write_buffer); |
||
343 | |||
344 | /** |
||
345 | * mipi_dsi_dcs_write() - send DCS write command |
||
346 | * @dsi: DSI peripheral device |
||
347 | * @cmd: DCS command |
||
348 | * @data: buffer containing the command payload |
||
349 | * @len: command payload length |
||
350 | * |
||
351 | * This function will automatically choose the right data type depending on |
||
352 | * the command payload length. |
||
353 | * |
||
354 | * Return: The number of bytes successfully transmitted or a negative error |
||
355 | * code on failure. |
||
356 | */ |
||
357 | ssize_t mipi_dsi_dcs_write(struct mipi_dsi_device *dsi, u8 cmd, |
||
358 | const void *data, size_t len) |
||
359 | { |
||
360 | ssize_t err; |
||
361 | size_t size; |
||
362 | u8 *tx; |
||
363 | |||
364 | if (len > 0) { |
||
365 | size = 1 + len; |
||
366 | |||
367 | tx = kmalloc(size, GFP_KERNEL); |
||
368 | if (!tx) |
||
369 | return -ENOMEM; |
||
370 | |||
371 | /* concatenate the DCS command byte and the payload */ |
||
372 | tx[0] = cmd; |
||
373 | memcpy(&tx[1], data, len); |
||
374 | } else { |
||
375 | tx = &cmd; |
||
376 | size = 1; |
||
377 | } |
||
378 | |||
379 | err = mipi_dsi_dcs_write_buffer(dsi, tx, size); |
||
380 | |||
381 | if (len > 0) |
||
382 | kfree(tx); |
||
383 | |||
384 | return err; |
||
385 | } |
||
386 | EXPORT_SYMBOL(mipi_dsi_dcs_write); |
||
387 | |||
388 | /** |
||
389 | * mipi_dsi_dcs_read() - send DCS read request command |
||
390 | * @dsi: DSI peripheral device |
||
391 | * @cmd: DCS command |
||
392 | * @data: buffer in which to receive data |
||
393 | * @len: size of receive buffer |
||
394 | * |
||
395 | * Return: The number of bytes read or a negative error code on failure. |
||
396 | */ |
||
397 | ssize_t mipi_dsi_dcs_read(struct mipi_dsi_device *dsi, u8 cmd, void *data, |
||
398 | size_t len) |
||
399 | { |
||
400 | struct mipi_dsi_msg msg = { |
||
401 | .channel = dsi->channel, |
||
402 | .type = MIPI_DSI_DCS_READ, |
||
403 | .tx_buf = &cmd, |
||
404 | .tx_len = 1, |
||
405 | .rx_buf = data, |
||
406 | .rx_len = len |
||
407 | }; |
||
408 | |||
409 | return mipi_dsi_device_transfer(dsi, &msg); |
||
410 | } |
||
411 | EXPORT_SYMBOL(mipi_dsi_dcs_read); |
||
412 | |||
413 | /** |
||
414 | * mipi_dsi_dcs_nop() - send DCS nop packet |
||
415 | * @dsi: DSI peripheral device |
||
416 | * |
||
417 | * Return: 0 on success or a negative error code on failure. |
||
418 | */ |
||
419 | int mipi_dsi_dcs_nop(struct mipi_dsi_device *dsi) |
||
420 | { |
||
421 | ssize_t err; |
||
422 | |||
423 | err = mipi_dsi_dcs_write(dsi, MIPI_DCS_NOP, NULL, 0); |
||
424 | if (err < 0) |
||
425 | return err; |
||
426 | |||
427 | return 0; |
||
428 | } |
||
429 | EXPORT_SYMBOL(mipi_dsi_dcs_nop); |
||
430 | |||
431 | /** |
||
432 | * mipi_dsi_dcs_soft_reset() - perform a software reset of the display module |
||
433 | * @dsi: DSI peripheral device |
||
434 | * |
||
435 | * Return: 0 on success or a negative error code on failure. |
||
436 | */ |
||
437 | int mipi_dsi_dcs_soft_reset(struct mipi_dsi_device *dsi) |
||
438 | { |
||
439 | ssize_t err; |
||
440 | |||
441 | err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SOFT_RESET, NULL, 0); |
||
442 | if (err < 0) |
||
443 | return err; |
||
444 | |||
445 | return 0; |
||
446 | } |
||
447 | EXPORT_SYMBOL(mipi_dsi_dcs_soft_reset); |
||
448 | |||
449 | /** |
||
450 | * mipi_dsi_dcs_get_power_mode() - query the display module's current power |
||
451 | * mode |
||
452 | * @dsi: DSI peripheral device |
||
453 | * @mode: return location for the current power mode |
||
454 | * |
||
455 | * Return: 0 on success or a negative error code on failure. |
||
456 | */ |
||
457 | int mipi_dsi_dcs_get_power_mode(struct mipi_dsi_device *dsi, u8 *mode) |
||
458 | { |
||
459 | ssize_t err; |
||
460 | |||
461 | err = mipi_dsi_dcs_read(dsi, MIPI_DCS_GET_POWER_MODE, mode, |
||
462 | sizeof(*mode)); |
||
463 | if (err <= 0) { |
||
464 | if (err == 0) |
||
465 | err = -ENODATA; |
||
466 | |||
467 | return err; |
||
468 | } |
||
469 | |||
470 | return 0; |
||
471 | } |
||
472 | EXPORT_SYMBOL(mipi_dsi_dcs_get_power_mode); |
||
473 | |||
474 | /** |
||
475 | * mipi_dsi_dcs_get_pixel_format() - gets the pixel format for the RGB image |
||
476 | * data used by the interface |
||
477 | * @dsi: DSI peripheral device |
||
478 | * @format: return location for the pixel format |
||
479 | * |
||
480 | * Return: 0 on success or a negative error code on failure. |
||
481 | */ |
||
482 | int mipi_dsi_dcs_get_pixel_format(struct mipi_dsi_device *dsi, u8 *format) |
||
483 | { |
||
484 | ssize_t err; |
||
485 | |||
486 | err = mipi_dsi_dcs_read(dsi, MIPI_DCS_GET_PIXEL_FORMAT, format, |
||
487 | sizeof(*format)); |
||
488 | if (err <= 0) { |
||
489 | if (err == 0) |
||
490 | err = -ENODATA; |
||
491 | |||
492 | return err; |
||
493 | } |
||
494 | |||
495 | return 0; |
||
496 | } |
||
497 | EXPORT_SYMBOL(mipi_dsi_dcs_get_pixel_format); |
||
498 | |||
499 | /** |
||
500 | * mipi_dsi_dcs_enter_sleep_mode() - disable all unnecessary blocks inside the |
||
501 | * display module except interface communication |
||
502 | * @dsi: DSI peripheral device |
||
503 | * |
||
504 | * Return: 0 on success or a negative error code on failure. |
||
505 | */ |
||
506 | int mipi_dsi_dcs_enter_sleep_mode(struct mipi_dsi_device *dsi) |
||
507 | { |
||
508 | ssize_t err; |
||
509 | |||
510 | err = mipi_dsi_dcs_write(dsi, MIPI_DCS_ENTER_SLEEP_MODE, NULL, 0); |
||
511 | if (err < 0) |
||
512 | return err; |
||
513 | |||
514 | return 0; |
||
515 | } |
||
516 | EXPORT_SYMBOL(mipi_dsi_dcs_enter_sleep_mode); |
||
517 | |||
518 | /** |
||
519 | * mipi_dsi_dcs_exit_sleep_mode() - enable all blocks inside the display |
||
520 | * module |
||
521 | * @dsi: DSI peripheral device |
||
522 | * |
||
523 | * Return: 0 on success or a negative error code on failure. |
||
524 | */ |
||
525 | int mipi_dsi_dcs_exit_sleep_mode(struct mipi_dsi_device *dsi) |
||
526 | { |
||
527 | ssize_t err; |
||
528 | |||
529 | err = mipi_dsi_dcs_write(dsi, MIPI_DCS_EXIT_SLEEP_MODE, NULL, 0); |
||
530 | if (err < 0) |
||
531 | return err; |
||
532 | |||
533 | return 0; |
||
534 | } |
||
535 | EXPORT_SYMBOL(mipi_dsi_dcs_exit_sleep_mode); |
||
536 | |||
537 | /** |
||
538 | * mipi_dsi_dcs_set_display_off() - stop displaying the image data on the |
||
539 | * display device |
||
540 | * @dsi: DSI peripheral device |
||
541 | * |
||
542 | * Return: 0 on success or a negative error code on failure. |
||
543 | */ |
||
544 | int mipi_dsi_dcs_set_display_off(struct mipi_dsi_device *dsi) |
||
545 | { |
||
546 | ssize_t err; |
||
547 | |||
548 | err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_DISPLAY_OFF, NULL, 0); |
||
549 | if (err < 0) |
||
550 | return err; |
||
551 | |||
552 | return 0; |
||
553 | } |
||
554 | EXPORT_SYMBOL(mipi_dsi_dcs_set_display_off); |
||
555 | |||
556 | /** |
||
557 | * mipi_dsi_dcs_set_display_on() - start displaying the image data on the |
||
558 | * display device |
||
559 | * @dsi: DSI peripheral device |
||
560 | * |
||
561 | * Return: 0 on success or a negative error code on failure |
||
562 | */ |
||
563 | int mipi_dsi_dcs_set_display_on(struct mipi_dsi_device *dsi) |
||
564 | { |
||
565 | ssize_t err; |
||
566 | |||
567 | err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_DISPLAY_ON, NULL, 0); |
||
568 | if (err < 0) |
||
569 | return err; |
||
570 | |||
571 | return 0; |
||
572 | } |
||
573 | EXPORT_SYMBOL(mipi_dsi_dcs_set_display_on); |
||
574 | |||
575 | /** |
||
576 | * mipi_dsi_dcs_set_column_address() - define the column extent of the frame |
||
577 | * memory accessed by the host processor |
||
578 | * @dsi: DSI peripheral device |
||
579 | * @start: first column of frame memory |
||
580 | * @end: last column of frame memory |
||
581 | * |
||
582 | * Return: 0 on success or a negative error code on failure. |
||
583 | */ |
||
584 | int mipi_dsi_dcs_set_column_address(struct mipi_dsi_device *dsi, u16 start, |
||
585 | u16 end) |
||
586 | { |
||
587 | u8 payload[4] = { start >> 8, start & 0xff, end >> 8, end & 0xff }; |
||
588 | ssize_t err; |
||
589 | |||
590 | err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_COLUMN_ADDRESS, payload, |
||
591 | sizeof(payload)); |
||
592 | if (err < 0) |
||
593 | return err; |
||
594 | |||
595 | return 0; |
||
596 | } |
||
597 | EXPORT_SYMBOL(mipi_dsi_dcs_set_column_address); |
||
598 | |||
599 | /** |
||
600 | * mipi_dsi_dcs_set_page_address() - define the page extent of the frame |
||
601 | * memory accessed by the host processor |
||
602 | * @dsi: DSI peripheral device |
||
603 | * @start: first page of frame memory |
||
604 | * @end: last page of frame memory |
||
605 | * |
||
606 | * Return: 0 on success or a negative error code on failure. |
||
607 | */ |
||
608 | int mipi_dsi_dcs_set_page_address(struct mipi_dsi_device *dsi, u16 start, |
||
609 | u16 end) |
||
610 | { |
||
611 | u8 payload[4] = { start >> 8, start & 0xff, end >> 8, end & 0xff }; |
||
612 | ssize_t err; |
||
613 | |||
614 | err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_PAGE_ADDRESS, payload, |
||
615 | sizeof(payload)); |
||
616 | if (err < 0) |
||
617 | return err; |
||
618 | |||
619 | return 0; |
||
620 | } |
||
621 | EXPORT_SYMBOL(mipi_dsi_dcs_set_page_address); |
||
622 | |||
623 | /** |
||
624 | * mipi_dsi_dcs_set_tear_off() - turn off the display module's Tearing Effect |
||
625 | * output signal on the TE signal line |
||
626 | * @dsi: DSI peripheral device |
||
627 | * |
||
628 | * Return: 0 on success or a negative error code on failure |
||
629 | */ |
||
630 | int mipi_dsi_dcs_set_tear_off(struct mipi_dsi_device *dsi) |
||
631 | { |
||
632 | ssize_t err; |
||
633 | |||
634 | err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_TEAR_OFF, NULL, 0); |
||
635 | if (err < 0) |
||
636 | return err; |
||
637 | |||
638 | return 0; |
||
639 | } |
||
640 | EXPORT_SYMBOL(mipi_dsi_dcs_set_tear_off); |
||
641 | |||
642 | /** |
||
643 | * mipi_dsi_dcs_set_tear_on() - turn on the display module's Tearing Effect |
||
644 | * output signal on the TE signal line. |
||
645 | * @dsi: DSI peripheral device |
||
646 | * @mode: the Tearing Effect Output Line mode |
||
647 | * |
||
648 | * Return: 0 on success or a negative error code on failure |
||
649 | */ |
||
650 | int mipi_dsi_dcs_set_tear_on(struct mipi_dsi_device *dsi, |
||
651 | enum mipi_dsi_dcs_tear_mode mode) |
||
652 | { |
||
653 | u8 value = mode; |
||
654 | ssize_t err; |
||
655 | |||
656 | err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_TEAR_ON, &value, |
||
657 | sizeof(value)); |
||
658 | if (err < 0) |
||
659 | return err; |
||
660 | |||
661 | return 0; |
||
662 | } |
||
663 | EXPORT_SYMBOL(mipi_dsi_dcs_set_tear_on); |
||
664 | |||
665 | /** |
||
666 | * mipi_dsi_dcs_set_pixel_format() - sets the pixel format for the RGB image |
||
667 | * data used by the interface |
||
668 | * @dsi: DSI peripheral device |
||
669 | * @format: pixel format |
||
670 | * |
||
671 | * Return: 0 on success or a negative error code on failure. |
||
672 | */ |
||
673 | int mipi_dsi_dcs_set_pixel_format(struct mipi_dsi_device *dsi, u8 format) |
||
674 | { |
||
675 | ssize_t err; |
||
676 | |||
677 | err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_PIXEL_FORMAT, &format, |
||
678 | sizeof(format)); |
||
679 | if (err < 0) |
||
680 | return err; |
||
681 | |||
682 | return 0; |
||
683 | } |
||
684 | EXPORT_SYMBOL(mipi_dsi_dcs_set_pixel_format); |
||
685 | |||
686 | MODULE_AUTHOR("Andrzej Hajda |
||
687 | MODULE_DESCRIPTION("MIPI DSI Bus"); |
||
688 | MODULE_LICENSE("GPL and additional rights");>>>>>>>>>=>=>>>><> |