4 * Copyright (C) 2012-2013, Samsung Electronics, Co., Ltd.
5 * Andrzej Hajda <a.hajda@samsung.com>
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:
15 * The above copyright notice and this permission notice (including the
16 * next paragraph) shall be included in all copies or substantial portions
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.
29 #include <drm/drm_mipi_dsi.h>
31 #include <linux/device.h>
32 #include <linux/module.h>
33 #include <linux/slab.h>
35 #include <video/mipi_display.h>
40 * These functions contain some common logic and helpers to deal with MIPI DSI
43 * Helpers are provided for a number of standard MIPI DSI command as well as a
44 * subset of the MIPI DCS command set.
48 static int mipi_dsi_device_match(struct device
*dev
, struct device_driver
*drv
)
50 return of_driver_match_device(dev
, drv
);
53 static const struct dev_pm_ops mipi_dsi_device_pm_ops
= {
54 .runtime_suspend
= pm_generic_runtime_suspend
,
55 .runtime_resume
= pm_generic_runtime_resume
,
56 .suspend
= pm_generic_suspend
,
57 .resume
= pm_generic_resume
,
58 .freeze
= pm_generic_freeze
,
59 .thaw
= pm_generic_thaw
,
60 .poweroff
= pm_generic_poweroff
,
61 .restore
= pm_generic_restore
,
64 static struct bus_type mipi_dsi_bus_type
= {
66 .match
= mipi_dsi_device_match
,
67 .pm
= &mipi_dsi_device_pm_ops
,
70 static int of_device_match(struct device
*dev
, void *data
)
72 return dev
->of_node
== data
;
76 * of_find_mipi_dsi_device_by_node() - find the MIPI DSI device matching a
78 * @np: device tree node
80 * Return: A pointer to the MIPI DSI device corresponding to @np or NULL if no
81 * such device exists (or has not been registered yet).
83 struct mipi_dsi_device
*of_find_mipi_dsi_device_by_node(struct device_node
*np
)
87 dev
= bus_find_device(&mipi_dsi_bus_type
, NULL
, np
, of_device_match
);
89 return dev
? to_mipi_dsi_device(dev
) : NULL
;
91 EXPORT_SYMBOL(of_find_mipi_dsi_device_by_node
);
93 static void mipi_dsi_dev_release(struct device
*dev
)
95 struct mipi_dsi_device
*dsi
= to_mipi_dsi_device(dev
);
97 of_node_put(dev
->of_node
);
101 static const struct device_type mipi_dsi_device_type
= {
102 .release
= mipi_dsi_dev_release
,
105 static struct mipi_dsi_device
*mipi_dsi_device_alloc(struct mipi_dsi_host
*host
)
107 struct mipi_dsi_device
*dsi
;
109 dsi
= kzalloc(sizeof(*dsi
), GFP_KERNEL
);
111 return ERR_PTR(-ENOMEM
);
114 dsi
->dev
.bus
= &mipi_dsi_bus_type
;
115 dsi
->dev
.parent
= host
->dev
;
116 dsi
->dev
.type
= &mipi_dsi_device_type
;
118 device_initialize(&dsi
->dev
);
123 static int mipi_dsi_device_add(struct mipi_dsi_device
*dsi
)
125 struct mipi_dsi_host
*host
= dsi
->host
;
127 dev_set_name(&dsi
->dev
, "%s.%d", dev_name(host
->dev
), dsi
->channel
);
129 return device_add(&dsi
->dev
);
132 static struct mipi_dsi_device
*
133 of_mipi_dsi_device_add(struct mipi_dsi_host
*host
, struct device_node
*node
)
135 struct mipi_dsi_device
*dsi
;
136 struct device
*dev
= host
->dev
;
140 ret
= of_property_read_u32(node
, "reg", ®
);
142 dev_err(dev
, "device node %s has no valid reg property: %d\n",
143 node
->full_name
, ret
);
144 return ERR_PTR(-EINVAL
);
148 dev_err(dev
, "device node %s has invalid reg property: %u\n",
149 node
->full_name
, reg
);
150 return ERR_PTR(-EINVAL
);
153 dsi
= mipi_dsi_device_alloc(host
);
155 dev_err(dev
, "failed to allocate DSI device %s: %ld\n",
156 node
->full_name
, PTR_ERR(dsi
));
160 dsi
->dev
.of_node
= of_node_get(node
);
163 ret
= mipi_dsi_device_add(dsi
);
165 dev_err(dev
, "failed to add DSI device %s: %d\n",
166 node
->full_name
, ret
);
174 int mipi_dsi_host_register(struct mipi_dsi_host
*host
)
176 struct device_node
*node
;
178 for_each_available_child_of_node(host
->dev
->of_node
, node
) {
179 /* skip nodes without reg property */
180 if (!of_find_property(node
, "reg", NULL
))
182 of_mipi_dsi_device_add(host
, node
);
187 EXPORT_SYMBOL(mipi_dsi_host_register
);
189 static int mipi_dsi_remove_device_fn(struct device
*dev
, void *priv
)
191 struct mipi_dsi_device
*dsi
= to_mipi_dsi_device(dev
);
193 device_unregister(&dsi
->dev
);
198 void mipi_dsi_host_unregister(struct mipi_dsi_host
*host
)
200 device_for_each_child(host
->dev
, NULL
, mipi_dsi_remove_device_fn
);
202 EXPORT_SYMBOL(mipi_dsi_host_unregister
);
206 * mipi_dsi_attach - attach a DSI device to its DSI host
207 * @dsi: DSI peripheral
209 int mipi_dsi_attach(struct mipi_dsi_device
*dsi
)
211 const struct mipi_dsi_host_ops
*ops
= dsi
->host
->ops
;
213 if (!ops
|| !ops
->attach
)
216 return ops
->attach(dsi
->host
, dsi
);
218 EXPORT_SYMBOL(mipi_dsi_attach
);
221 * mipi_dsi_detach - detach a DSI device from its DSI host
222 * @dsi: DSI peripheral
224 int mipi_dsi_detach(struct mipi_dsi_device
*dsi
)
226 const struct mipi_dsi_host_ops
*ops
= dsi
->host
->ops
;
228 if (!ops
|| !ops
->detach
)
231 return ops
->detach(dsi
->host
, dsi
);
233 EXPORT_SYMBOL(mipi_dsi_detach
);
235 static ssize_t
mipi_dsi_device_transfer(struct mipi_dsi_device
*dsi
,
236 struct mipi_dsi_msg
*msg
)
238 const struct mipi_dsi_host_ops
*ops
= dsi
->host
->ops
;
240 if (!ops
|| !ops
->transfer
)
243 if (dsi
->mode_flags
& MIPI_DSI_MODE_LPM
)
244 msg
->flags
|= MIPI_DSI_MSG_USE_LPM
;
246 return ops
->transfer(dsi
->host
, msg
);
250 * mipi_dsi_packet_format_is_short - check if a packet is of the short format
251 * @type: MIPI DSI data type of the packet
253 * Return: true if the packet for the given data type is a short packet, false
256 bool mipi_dsi_packet_format_is_short(u8 type
)
259 case MIPI_DSI_V_SYNC_START
:
260 case MIPI_DSI_V_SYNC_END
:
261 case MIPI_DSI_H_SYNC_START
:
262 case MIPI_DSI_H_SYNC_END
:
263 case MIPI_DSI_END_OF_TRANSMISSION
:
264 case MIPI_DSI_COLOR_MODE_OFF
:
265 case MIPI_DSI_COLOR_MODE_ON
:
266 case MIPI_DSI_SHUTDOWN_PERIPHERAL
:
267 case MIPI_DSI_TURN_ON_PERIPHERAL
:
268 case MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM
:
269 case MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM
:
270 case MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM
:
271 case MIPI_DSI_GENERIC_READ_REQUEST_0_PARAM
:
272 case MIPI_DSI_GENERIC_READ_REQUEST_1_PARAM
:
273 case MIPI_DSI_GENERIC_READ_REQUEST_2_PARAM
:
274 case MIPI_DSI_DCS_SHORT_WRITE
:
275 case MIPI_DSI_DCS_SHORT_WRITE_PARAM
:
276 case MIPI_DSI_DCS_READ
:
277 case MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE
:
283 EXPORT_SYMBOL(mipi_dsi_packet_format_is_short
);
286 * mipi_dsi_packet_format_is_long - check if a packet is of the long format
287 * @type: MIPI DSI data type of the packet
289 * Return: true if the packet for the given data type is a long packet, false
292 bool mipi_dsi_packet_format_is_long(u8 type
)
295 case MIPI_DSI_NULL_PACKET
:
296 case MIPI_DSI_BLANKING_PACKET
:
297 case MIPI_DSI_GENERIC_LONG_WRITE
:
298 case MIPI_DSI_DCS_LONG_WRITE
:
299 case MIPI_DSI_LOOSELY_PACKED_PIXEL_STREAM_YCBCR20
:
300 case MIPI_DSI_PACKED_PIXEL_STREAM_YCBCR24
:
301 case MIPI_DSI_PACKED_PIXEL_STREAM_YCBCR16
:
302 case MIPI_DSI_PACKED_PIXEL_STREAM_30
:
303 case MIPI_DSI_PACKED_PIXEL_STREAM_36
:
304 case MIPI_DSI_PACKED_PIXEL_STREAM_YCBCR12
:
305 case MIPI_DSI_PACKED_PIXEL_STREAM_16
:
306 case MIPI_DSI_PACKED_PIXEL_STREAM_18
:
307 case MIPI_DSI_PIXEL_STREAM_3BYTE_18
:
308 case MIPI_DSI_PACKED_PIXEL_STREAM_24
:
314 EXPORT_SYMBOL(mipi_dsi_packet_format_is_long
);
317 * mipi_dsi_create_packet - create a packet from a message according to the
319 * @packet: pointer to a DSI packet structure
320 * @msg: message to translate into a packet
322 * Return: 0 on success or a negative error code on failure.
324 int mipi_dsi_create_packet(struct mipi_dsi_packet
*packet
,
325 const struct mipi_dsi_msg
*msg
)
330 /* do some minimum sanity checking */
331 if (!mipi_dsi_packet_format_is_short(msg
->type
) &&
332 !mipi_dsi_packet_format_is_long(msg
->type
))
335 if (msg
->channel
> 3)
338 memset(packet
, 0, sizeof(*packet
));
339 packet
->header
[0] = ((msg
->channel
& 0x3) << 6) | (msg
->type
& 0x3f);
341 /* TODO: compute ECC if hardware support is not available */
344 * Long write packets contain the word count in header bytes 1 and 2.
345 * The payload follows the header and is word count bytes long.
347 * Short write packets encode up to two parameters in header bytes 1
350 if (mipi_dsi_packet_format_is_long(msg
->type
)) {
351 packet
->header
[1] = (msg
->tx_len
>> 0) & 0xff;
352 packet
->header
[2] = (msg
->tx_len
>> 8) & 0xff;
354 packet
->payload_length
= msg
->tx_len
;
355 packet
->payload
= msg
->tx_buf
;
357 const u8
*tx
= msg
->tx_buf
;
359 packet
->header
[1] = (msg
->tx_len
> 0) ? tx
[0] : 0;
360 packet
->header
[2] = (msg
->tx_len
> 1) ? tx
[1] : 0;
363 packet
->size
= sizeof(packet
->header
) + packet
->payload_length
;
367 EXPORT_SYMBOL(mipi_dsi_create_packet
);
371 * mipi_dsi_set_maximum_return_packet_size() - specify the maximum size of the
372 * the payload in a long packet transmitted from the peripheral back to the
374 * @dsi: DSI peripheral device
375 * @value: the maximum size of the payload
377 * Return: 0 on success or a negative error code on failure.
379 int mipi_dsi_set_maximum_return_packet_size(struct mipi_dsi_device
*dsi
,
382 u8 tx
[2] = { value
& 0xff, value
>> 8 };
383 struct mipi_dsi_msg msg
= {
384 .channel
= dsi
->channel
,
385 .type
= MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE
,
386 .tx_len
= sizeof(tx
),
390 return mipi_dsi_device_transfer(dsi
, &msg
);
392 EXPORT_SYMBOL(mipi_dsi_set_maximum_return_packet_size
);
396 * mipi_dsi_generic_write() - transmit data using a generic write packet
397 * @dsi: DSI peripheral device
398 * @payload: buffer containing the payload
399 * @size: size of payload buffer
401 * This function will automatically choose the right data type depending on
402 * the payload length.
404 * Return: The number of bytes transmitted on success or a negative error code
407 ssize_t
mipi_dsi_generic_write(struct mipi_dsi_device
*dsi
, const void *payload
,
410 struct mipi_dsi_msg msg
= {
411 .channel
= dsi
->channel
,
418 msg
.type
= MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM
;
422 msg
.type
= MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM
;
426 msg
.type
= MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM
;
430 msg
.type
= MIPI_DSI_GENERIC_LONG_WRITE
;
434 return mipi_dsi_device_transfer(dsi
, &msg
);
436 EXPORT_SYMBOL(mipi_dsi_generic_write
);
439 * mipi_dsi_generic_read() - receive data using a generic read packet
440 * @dsi: DSI peripheral device
441 * @params: buffer containing the request parameters
442 * @num_params: number of request parameters
443 * @data: buffer in which to return the received data
444 * @size: size of receive buffer
446 * This function will automatically choose the right data type depending on
447 * the number of parameters passed in.
449 * Return: The number of bytes successfully read or a negative error code on
452 ssize_t
mipi_dsi_generic_read(struct mipi_dsi_device
*dsi
, const void *params
,
453 size_t num_params
, void *data
, size_t size
)
455 struct mipi_dsi_msg msg
= {
456 .channel
= dsi
->channel
,
457 .tx_len
= num_params
,
463 switch (num_params
) {
465 msg
.type
= MIPI_DSI_GENERIC_READ_REQUEST_0_PARAM
;
469 msg
.type
= MIPI_DSI_GENERIC_READ_REQUEST_1_PARAM
;
473 msg
.type
= MIPI_DSI_GENERIC_READ_REQUEST_2_PARAM
;
480 return mipi_dsi_device_transfer(dsi
, &msg
);
482 EXPORT_SYMBOL(mipi_dsi_generic_read
);
485 * mipi_dsi_dcs_write_buffer() - transmit a DCS command with payload
486 * @dsi: DSI peripheral device
487 * @data: buffer containing data to be transmitted
488 * @len: size of transmission buffer
490 * This function will automatically choose the right data type depending on
491 * the command payload length.
493 * Return: The number of bytes successfully transmitted or a negative error
496 ssize_t
mipi_dsi_dcs_write_buffer(struct mipi_dsi_device
*dsi
,
497 const void *data
, size_t len
)
499 struct mipi_dsi_msg msg
= {
500 .channel
= dsi
->channel
,
510 msg
.type
= MIPI_DSI_DCS_SHORT_WRITE
;
514 msg
.type
= MIPI_DSI_DCS_SHORT_WRITE_PARAM
;
518 msg
.type
= MIPI_DSI_DCS_LONG_WRITE
;
522 return mipi_dsi_device_transfer(dsi
, &msg
);
524 EXPORT_SYMBOL(mipi_dsi_dcs_write_buffer
);
528 * mipi_dsi_dcs_write() - send DCS write command
529 * @dsi: DSI peripheral device
531 * @data: buffer containing the command payload
532 * @len: command payload length
534 * This function will automatically choose the right data type depending on
535 * the command payload length.
537 * Return: The number of bytes successfully transmitted or a negative error
540 ssize_t
mipi_dsi_dcs_write(struct mipi_dsi_device
*dsi
, u8 cmd
,
541 const void *data
, size_t len
)
550 tx
= kmalloc(size
, GFP_KERNEL
);
554 /* concatenate the DCS command byte and the payload */
556 memcpy(&tx
[1], data
, len
);
562 err
= mipi_dsi_dcs_write_buffer(dsi
, tx
, size
);
569 EXPORT_SYMBOL(mipi_dsi_dcs_write
);
573 * mipi_dsi_dcs_read() - send DCS read request command
574 * @dsi: DSI peripheral device
576 * @data: buffer in which to receive data
577 * @len: size of receive buffer
579 * Return: The number of bytes read or a negative error code on failure.
581 ssize_t
mipi_dsi_dcs_read(struct mipi_dsi_device
*dsi
, u8 cmd
, void *data
,
584 struct mipi_dsi_msg msg
= {
585 .channel
= dsi
->channel
,
586 .type
= MIPI_DSI_DCS_READ
,
593 return mipi_dsi_device_transfer(dsi
, &msg
);
595 EXPORT_SYMBOL(mipi_dsi_dcs_read
);
599 * mipi_dsi_dcs_nop() - send DCS nop packet
600 * @dsi: DSI peripheral device
602 * Return: 0 on success or a negative error code on failure.
604 int mipi_dsi_dcs_nop(struct mipi_dsi_device
*dsi
)
608 err
= mipi_dsi_dcs_write(dsi
, MIPI_DCS_NOP
, NULL
, 0);
614 EXPORT_SYMBOL(mipi_dsi_dcs_nop
);
617 * mipi_dsi_dcs_soft_reset() - perform a software reset of the display module
618 * @dsi: DSI peripheral device
620 * Return: 0 on success or a negative error code on failure.
622 int mipi_dsi_dcs_soft_reset(struct mipi_dsi_device
*dsi
)
626 err
= mipi_dsi_dcs_write(dsi
, MIPI_DCS_SOFT_RESET
, NULL
, 0);
632 EXPORT_SYMBOL(mipi_dsi_dcs_soft_reset
);
635 * mipi_dsi_dcs_get_power_mode() - query the display module's current power
637 * @dsi: DSI peripheral device
638 * @mode: return location for the current power mode
640 * Return: 0 on success or a negative error code on failure.
642 int mipi_dsi_dcs_get_power_mode(struct mipi_dsi_device
*dsi
, u8
*mode
)
646 err
= mipi_dsi_dcs_read(dsi
, MIPI_DCS_GET_POWER_MODE
, mode
,
657 EXPORT_SYMBOL(mipi_dsi_dcs_get_power_mode
);
660 * mipi_dsi_dcs_get_pixel_format() - gets the pixel format for the RGB image
661 * data used by the interface
662 * @dsi: DSI peripheral device
663 * @format: return location for the pixel format
665 * Return: 0 on success or a negative error code on failure.
667 int mipi_dsi_dcs_get_pixel_format(struct mipi_dsi_device
*dsi
, u8
*format
)
671 err
= mipi_dsi_dcs_read(dsi
, MIPI_DCS_GET_PIXEL_FORMAT
, format
,
682 EXPORT_SYMBOL(mipi_dsi_dcs_get_pixel_format
);
685 * mipi_dsi_dcs_enter_sleep_mode() - disable all unnecessary blocks inside the
686 * display module except interface communication
687 * @dsi: DSI peripheral device
689 * Return: 0 on success or a negative error code on failure.
691 int mipi_dsi_dcs_enter_sleep_mode(struct mipi_dsi_device
*dsi
)
695 err
= mipi_dsi_dcs_write(dsi
, MIPI_DCS_ENTER_SLEEP_MODE
, NULL
, 0);
701 EXPORT_SYMBOL(mipi_dsi_dcs_enter_sleep_mode
);
704 * mipi_dsi_dcs_exit_sleep_mode() - enable all blocks inside the display
706 * @dsi: DSI peripheral device
708 * Return: 0 on success or a negative error code on failure.
710 int mipi_dsi_dcs_exit_sleep_mode(struct mipi_dsi_device
*dsi
)
714 err
= mipi_dsi_dcs_write(dsi
, MIPI_DCS_EXIT_SLEEP_MODE
, NULL
, 0);
720 EXPORT_SYMBOL(mipi_dsi_dcs_exit_sleep_mode
);
723 * mipi_dsi_dcs_set_display_off() - stop displaying the image data on the
725 * @dsi: DSI peripheral device
727 * Return: 0 on success or a negative error code on failure.
729 int mipi_dsi_dcs_set_display_off(struct mipi_dsi_device
*dsi
)
733 err
= mipi_dsi_dcs_write(dsi
, MIPI_DCS_SET_DISPLAY_OFF
, NULL
, 0);
739 EXPORT_SYMBOL(mipi_dsi_dcs_set_display_off
);
742 * mipi_dsi_dcs_set_display_on() - start displaying the image data on the
744 * @dsi: DSI peripheral device
746 * Return: 0 on success or a negative error code on failure
748 int mipi_dsi_dcs_set_display_on(struct mipi_dsi_device
*dsi
)
752 err
= mipi_dsi_dcs_write(dsi
, MIPI_DCS_SET_DISPLAY_ON
, NULL
, 0);
758 EXPORT_SYMBOL(mipi_dsi_dcs_set_display_on
);
761 * mipi_dsi_dcs_set_column_address() - define the column extent of the frame
762 * memory accessed by the host processor
763 * @dsi: DSI peripheral device
764 * @start: first column of frame memory
765 * @end: last column of frame memory
767 * Return: 0 on success or a negative error code on failure.
769 int mipi_dsi_dcs_set_column_address(struct mipi_dsi_device
*dsi
, u16 start
,
772 u8 payload
[4] = { start
>> 8, start
& 0xff, end
>> 8, end
& 0xff };
775 err
= mipi_dsi_dcs_write(dsi
, MIPI_DCS_SET_COLUMN_ADDRESS
, payload
,
782 EXPORT_SYMBOL(mipi_dsi_dcs_set_column_address
);
785 * mipi_dsi_dcs_set_page_address() - define the page extent of the frame
786 * memory accessed by the host processor
787 * @dsi: DSI peripheral device
788 * @start: first page of frame memory
789 * @end: last page of frame memory
791 * Return: 0 on success or a negative error code on failure.
793 int mipi_dsi_dcs_set_page_address(struct mipi_dsi_device
*dsi
, u16 start
,
796 u8 payload
[4] = { start
>> 8, start
& 0xff, end
>> 8, end
& 0xff };
799 err
= mipi_dsi_dcs_write(dsi
, MIPI_DCS_SET_PAGE_ADDRESS
, payload
,
806 EXPORT_SYMBOL(mipi_dsi_dcs_set_page_address
);
809 * mipi_dsi_dcs_set_tear_off() - turn off the display module's Tearing Effect
810 * output signal on the TE signal line
811 * @dsi: DSI peripheral device
813 * Return: 0 on success or a negative error code on failure
815 int mipi_dsi_dcs_set_tear_off(struct mipi_dsi_device
*dsi
)
819 err
= mipi_dsi_dcs_write(dsi
, MIPI_DCS_SET_TEAR_OFF
, NULL
, 0);
825 EXPORT_SYMBOL(mipi_dsi_dcs_set_tear_off
);
828 * mipi_dsi_dcs_set_tear_on() - turn on the display module's Tearing Effect
829 * output signal on the TE signal line.
830 * @dsi: DSI peripheral device
831 * @mode: the Tearing Effect Output Line mode
833 * Return: 0 on success or a negative error code on failure
835 int mipi_dsi_dcs_set_tear_on(struct mipi_dsi_device
*dsi
,
836 enum mipi_dsi_dcs_tear_mode mode
)
841 err
= mipi_dsi_dcs_write(dsi
, MIPI_DCS_SET_TEAR_ON
, &value
,
848 EXPORT_SYMBOL(mipi_dsi_dcs_set_tear_on
);
851 * mipi_dsi_dcs_set_pixel_format() - sets the pixel format for the RGB image
852 * data used by the interface
853 * @dsi: DSI peripheral device
854 * @format: pixel format
856 * Return: 0 on success or a negative error code on failure.
858 int mipi_dsi_dcs_set_pixel_format(struct mipi_dsi_device
*dsi
, u8 format
)
862 err
= mipi_dsi_dcs_write(dsi
, MIPI_DCS_SET_PIXEL_FORMAT
, &format
,
869 EXPORT_SYMBOL(mipi_dsi_dcs_set_pixel_format
);
871 static int mipi_dsi_drv_probe(struct device
*dev
)
873 struct mipi_dsi_driver
*drv
= to_mipi_dsi_driver(dev
->driver
);
874 struct mipi_dsi_device
*dsi
= to_mipi_dsi_device(dev
);
876 return drv
->probe(dsi
);
879 static int mipi_dsi_drv_remove(struct device
*dev
)
881 struct mipi_dsi_driver
*drv
= to_mipi_dsi_driver(dev
->driver
);
882 struct mipi_dsi_device
*dsi
= to_mipi_dsi_device(dev
);
884 return drv
->remove(dsi
);
887 static void mipi_dsi_drv_shutdown(struct device
*dev
)
889 struct mipi_dsi_driver
*drv
= to_mipi_dsi_driver(dev
->driver
);
890 struct mipi_dsi_device
*dsi
= to_mipi_dsi_device(dev
);
896 * mipi_dsi_driver_register_full() - register a driver for DSI devices
897 * @drv: DSI driver structure
898 * @owner: owner module
900 * Return: 0 on success or a negative error code on failure.
902 int mipi_dsi_driver_register_full(struct mipi_dsi_driver
*drv
,
903 struct module
*owner
)
905 drv
->driver
.bus
= &mipi_dsi_bus_type
;
906 drv
->driver
.owner
= owner
;
909 drv
->driver
.probe
= mipi_dsi_drv_probe
;
911 drv
->driver
.remove
= mipi_dsi_drv_remove
;
913 drv
->driver
.shutdown
= mipi_dsi_drv_shutdown
;
915 return driver_register(&drv
->driver
);
917 EXPORT_SYMBOL(mipi_dsi_driver_register_full
);
920 * mipi_dsi_driver_unregister() - unregister a driver for DSI devices
921 * @drv: DSI driver structure
923 * Return: 0 on success or a negative error code on failure.
925 void mipi_dsi_driver_unregister(struct mipi_dsi_driver
*drv
)
927 driver_unregister(&drv
->driver
);
929 EXPORT_SYMBOL(mipi_dsi_driver_unregister
);
931 static int __init
mipi_dsi_bus_init(void)
933 return bus_register(&mipi_dsi_bus_type
);
935 postcore_initcall(mipi_dsi_bus_init
);
938 MODULE_AUTHOR("Andrzej Hajda <a.hajda@samsung.com>");
939 MODULE_DESCRIPTION("MIPI DSI Bus");