Lines Matching +full:mipi +full:- +full:dsi
2 * MIPI DSI Bus
4 * Copyright (C) 2012-2013, Samsung Electronics, Co., Ltd.
21 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
41 * DOC: dsi helpers
43 * These functions contain some common logic and helpers to deal with MIPI DSI
46 * Helpers are provided for a number of standard MIPI DSI command as well as a
47 * subset of the MIPI DCS command set.
52 struct mipi_dsi_device *dsi = to_mipi_dsi_device(dev); in mipi_dsi_device_match() local
58 /* compare DSI device and driver names */ in mipi_dsi_device_match()
59 if (!strcmp(dsi->name, drv->name)) in mipi_dsi_device_match()
67 struct mipi_dsi_device *dsi = to_mipi_dsi_device(dev); in mipi_dsi_uevent() local
71 if (err != -ENODEV) in mipi_dsi_uevent()
75 dsi->name); in mipi_dsi_uevent()
92 .name = "mipi-dsi",
99 * of_find_mipi_dsi_device_by_node() - find the MIPI DSI device matching a
103 * Return: A pointer to the MIPI DSI device corresponding to @np or NULL if no
118 struct mipi_dsi_device *dsi = to_mipi_dsi_device(dev); in mipi_dsi_dev_release() local
120 of_node_put(dev->of_node); in mipi_dsi_dev_release()
121 kfree(dsi); in mipi_dsi_dev_release()
130 struct mipi_dsi_device *dsi; in mipi_dsi_device_alloc() local
132 dsi = kzalloc(sizeof(*dsi), GFP_KERNEL); in mipi_dsi_device_alloc()
133 if (!dsi) in mipi_dsi_device_alloc()
134 return ERR_PTR(-ENOMEM); in mipi_dsi_device_alloc()
136 dsi->host = host; in mipi_dsi_device_alloc()
137 dsi->dev.bus = &mipi_dsi_bus_type; in mipi_dsi_device_alloc()
138 dsi->dev.parent = host->dev; in mipi_dsi_device_alloc()
139 dsi->dev.type = &mipi_dsi_device_type; in mipi_dsi_device_alloc()
141 device_initialize(&dsi->dev); in mipi_dsi_device_alloc()
143 return dsi; in mipi_dsi_device_alloc()
146 static int mipi_dsi_device_add(struct mipi_dsi_device *dsi) in mipi_dsi_device_add() argument
148 struct mipi_dsi_host *host = dsi->host; in mipi_dsi_device_add()
150 dev_set_name(&dsi->dev, "%s.%d", dev_name(host->dev), dsi->channel); in mipi_dsi_device_add()
152 return device_add(&dsi->dev); in mipi_dsi_device_add()
165 return ERR_PTR(-EINVAL); in of_mipi_dsi_device_add()
172 return ERR_PTR(-EINVAL); in of_mipi_dsi_device_add()
184 return ERR_PTR(-ENODEV); in of_mipi_dsi_device_add()
189 * mipi_dsi_device_register_full - create a MIPI DSI device
190 * @host: DSI host to which this device is connected
191 * @info: pointer to template containing DSI device information
193 * Create a MIPI DSI device by using the device information provided by
197 * A pointer to the newly created MIPI DSI device, or, a pointer encoded
204 struct mipi_dsi_device *dsi; in mipi_dsi_device_register_full() local
209 return ERR_PTR(-EINVAL); in mipi_dsi_device_register_full()
212 if (info->channel > 3) { in mipi_dsi_device_register_full()
213 drm_err(host, "invalid virtual channel: %u\n", info->channel); in mipi_dsi_device_register_full()
214 return ERR_PTR(-EINVAL); in mipi_dsi_device_register_full()
217 dsi = mipi_dsi_device_alloc(host); in mipi_dsi_device_register_full()
218 if (IS_ERR(dsi)) { in mipi_dsi_device_register_full()
219 drm_err(host, "failed to allocate DSI device %ld\n", in mipi_dsi_device_register_full()
220 PTR_ERR(dsi)); in mipi_dsi_device_register_full()
221 return dsi; in mipi_dsi_device_register_full()
224 dsi->dev.of_node = info->node; in mipi_dsi_device_register_full()
225 dsi->channel = info->channel; in mipi_dsi_device_register_full()
226 strlcpy(dsi->name, info->type, sizeof(dsi->name)); in mipi_dsi_device_register_full()
228 ret = mipi_dsi_device_add(dsi); in mipi_dsi_device_register_full()
230 drm_err(host, "failed to add DSI device %d\n", ret); in mipi_dsi_device_register_full()
231 kfree(dsi); in mipi_dsi_device_register_full()
235 return dsi; in mipi_dsi_device_register_full()
240 * mipi_dsi_device_unregister - unregister MIPI DSI device
241 * @dsi: DSI peripheral device
243 void mipi_dsi_device_unregister(struct mipi_dsi_device *dsi) in mipi_dsi_device_unregister() argument
245 device_unregister(&dsi->dev); in mipi_dsi_device_unregister()
253 * of_find_mipi_dsi_host_by_node() - find the MIPI DSI host matching a
258 * A pointer to the MIPI DSI host corresponding to @node or NULL if no
268 if (host->dev->of_node == node) { in of_find_mipi_dsi_host_by_node()
284 for_each_available_child_of_node(host->dev->of_node, node) { in mipi_dsi_host_register()
292 list_add_tail(&host->list, &host_list); in mipi_dsi_host_register()
301 struct mipi_dsi_device *dsi = to_mipi_dsi_device(dev); in mipi_dsi_remove_device_fn() local
303 mipi_dsi_device_unregister(dsi); in mipi_dsi_remove_device_fn()
310 device_for_each_child(host->dev, NULL, mipi_dsi_remove_device_fn); in mipi_dsi_host_unregister()
313 list_del_init(&host->list); in mipi_dsi_host_unregister()
319 * mipi_dsi_attach - attach a DSI device to its DSI host
320 * @dsi: DSI peripheral
322 int mipi_dsi_attach(struct mipi_dsi_device *dsi) in mipi_dsi_attach() argument
324 const struct mipi_dsi_host_ops *ops = dsi->host->ops; in mipi_dsi_attach()
326 if (!ops || !ops->attach) in mipi_dsi_attach()
327 return -ENOSYS; in mipi_dsi_attach()
329 return ops->attach(dsi->host, dsi); in mipi_dsi_attach()
334 * mipi_dsi_detach - detach a DSI device from its DSI host
335 * @dsi: DSI peripheral
337 int mipi_dsi_detach(struct mipi_dsi_device *dsi) in mipi_dsi_detach() argument
339 const struct mipi_dsi_host_ops *ops = dsi->host->ops; in mipi_dsi_detach()
341 if (!ops || !ops->detach) in mipi_dsi_detach()
342 return -ENOSYS; in mipi_dsi_detach()
344 return ops->detach(dsi->host, dsi); in mipi_dsi_detach()
348 static ssize_t mipi_dsi_device_transfer(struct mipi_dsi_device *dsi, in mipi_dsi_device_transfer() argument
351 const struct mipi_dsi_host_ops *ops = dsi->host->ops; in mipi_dsi_device_transfer()
353 if (!ops || !ops->transfer) in mipi_dsi_device_transfer()
354 return -ENOSYS; in mipi_dsi_device_transfer()
356 if (dsi->mode_flags & MIPI_DSI_MODE_LPM) in mipi_dsi_device_transfer()
357 msg->flags |= MIPI_DSI_MSG_USE_LPM; in mipi_dsi_device_transfer()
359 return ops->transfer(dsi->host, msg); in mipi_dsi_device_transfer()
363 * mipi_dsi_packet_format_is_short - check if a packet is of the short format
364 * @type: MIPI DSI data type of the packet
401 * mipi_dsi_packet_format_is_long - check if a packet is of the long format
402 * @type: MIPI DSI data type of the packet
434 * mipi_dsi_create_packet - create a packet from a message according to the
435 * DSI protocol
436 * @packet: pointer to a DSI packet structure
445 return -EINVAL; in mipi_dsi_create_packet()
448 if (!mipi_dsi_packet_format_is_short(msg->type) && in mipi_dsi_create_packet()
449 !mipi_dsi_packet_format_is_long(msg->type)) in mipi_dsi_create_packet()
450 return -EINVAL; in mipi_dsi_create_packet()
452 if (msg->channel > 3) in mipi_dsi_create_packet()
453 return -EINVAL; in mipi_dsi_create_packet()
456 packet->header[0] = ((msg->channel & 0x3) << 6) | (msg->type & 0x3f); in mipi_dsi_create_packet()
467 if (mipi_dsi_packet_format_is_long(msg->type)) { in mipi_dsi_create_packet()
468 packet->header[1] = (msg->tx_len >> 0) & 0xff; in mipi_dsi_create_packet()
469 packet->header[2] = (msg->tx_len >> 8) & 0xff; in mipi_dsi_create_packet()
471 packet->payload_length = msg->tx_len; in mipi_dsi_create_packet()
472 packet->payload = msg->tx_buf; in mipi_dsi_create_packet()
474 const u8 *tx = msg->tx_buf; in mipi_dsi_create_packet()
476 packet->header[1] = (msg->tx_len > 0) ? tx[0] : 0; in mipi_dsi_create_packet()
477 packet->header[2] = (msg->tx_len > 1) ? tx[1] : 0; in mipi_dsi_create_packet()
480 packet->size = sizeof(packet->header) + packet->payload_length; in mipi_dsi_create_packet()
487 * mipi_dsi_shutdown_peripheral() - sends a Shutdown Peripheral command
488 * @dsi: DSI peripheral device
492 int mipi_dsi_shutdown_peripheral(struct mipi_dsi_device *dsi) in mipi_dsi_shutdown_peripheral() argument
495 .channel = dsi->channel, in mipi_dsi_shutdown_peripheral()
500 int ret = mipi_dsi_device_transfer(dsi, &msg); in mipi_dsi_shutdown_peripheral()
507 * mipi_dsi_turn_on_peripheral() - sends a Turn On Peripheral command
508 * @dsi: DSI peripheral device
512 int mipi_dsi_turn_on_peripheral(struct mipi_dsi_device *dsi) in mipi_dsi_turn_on_peripheral() argument
515 .channel = dsi->channel, in mipi_dsi_turn_on_peripheral()
520 int ret = mipi_dsi_device_transfer(dsi, &msg); in mipi_dsi_turn_on_peripheral()
527 * mipi_dsi_set_maximum_return_packet_size() - specify the maximum size of the
530 * @dsi: DSI peripheral device
535 int mipi_dsi_set_maximum_return_packet_size(struct mipi_dsi_device *dsi, in mipi_dsi_set_maximum_return_packet_size() argument
540 .channel = dsi->channel, in mipi_dsi_set_maximum_return_packet_size()
545 int ret = mipi_dsi_device_transfer(dsi, &msg); in mipi_dsi_set_maximum_return_packet_size()
552 * mipi_dsi_compression_mode() - enable/disable DSC on the peripheral
553 * @dsi: DSI peripheral device
561 ssize_t mipi_dsi_compression_mode(struct mipi_dsi_device *dsi, bool enable) in mipi_dsi_compression_mode() argument
563 /* Note: Needs updating for non-default PPS or algorithm */ in mipi_dsi_compression_mode()
566 .channel = dsi->channel, in mipi_dsi_compression_mode()
571 int ret = mipi_dsi_device_transfer(dsi, &msg); in mipi_dsi_compression_mode()
578 * mipi_dsi_picture_parameter_set() - transmit the DSC PPS to the peripheral
579 * @dsi: DSI peripheral device
586 ssize_t mipi_dsi_picture_parameter_set(struct mipi_dsi_device *dsi, in mipi_dsi_picture_parameter_set() argument
590 .channel = dsi->channel, in mipi_dsi_picture_parameter_set()
595 int ret = mipi_dsi_device_transfer(dsi, &msg); in mipi_dsi_picture_parameter_set()
602 * mipi_dsi_generic_write() - transmit data using a generic write packet
603 * @dsi: DSI peripheral device
613 ssize_t mipi_dsi_generic_write(struct mipi_dsi_device *dsi, const void *payload, in mipi_dsi_generic_write() argument
617 .channel = dsi->channel, in mipi_dsi_generic_write()
640 return mipi_dsi_device_transfer(dsi, &msg); in mipi_dsi_generic_write()
645 * mipi_dsi_generic_read() - receive data using a generic read packet
646 * @dsi: DSI peripheral device
658 ssize_t mipi_dsi_generic_read(struct mipi_dsi_device *dsi, const void *params, in mipi_dsi_generic_read() argument
662 .channel = dsi->channel, in mipi_dsi_generic_read()
683 return -EINVAL; in mipi_dsi_generic_read()
686 return mipi_dsi_device_transfer(dsi, &msg); in mipi_dsi_generic_read()
691 * mipi_dsi_dcs_write_buffer() - transmit a DCS command with payload
692 * @dsi: DSI peripheral device
702 ssize_t mipi_dsi_dcs_write_buffer(struct mipi_dsi_device *dsi, in mipi_dsi_dcs_write_buffer() argument
706 .channel = dsi->channel, in mipi_dsi_dcs_write_buffer()
713 return -EINVAL; in mipi_dsi_dcs_write_buffer()
728 return mipi_dsi_device_transfer(dsi, &msg); in mipi_dsi_dcs_write_buffer()
733 * mipi_dsi_dcs_write() - send DCS write command
734 * @dsi: DSI peripheral device
745 ssize_t mipi_dsi_dcs_write(struct mipi_dsi_device *dsi, u8 cmd, in mipi_dsi_dcs_write() argument
754 if (len > ARRAY_SIZE(stack_tx) - 1) { in mipi_dsi_dcs_write()
757 return -ENOMEM; in mipi_dsi_dcs_write()
767 err = mipi_dsi_dcs_write_buffer(dsi, tx, size); in mipi_dsi_dcs_write()
777 * mipi_dsi_dcs_read() - send DCS read request command
778 * @dsi: DSI peripheral device
785 ssize_t mipi_dsi_dcs_read(struct mipi_dsi_device *dsi, u8 cmd, void *data, in mipi_dsi_dcs_read() argument
789 .channel = dsi->channel, in mipi_dsi_dcs_read()
797 return mipi_dsi_device_transfer(dsi, &msg); in mipi_dsi_dcs_read()
802 * mipi_dsi_dcs_nop() - send DCS nop packet
803 * @dsi: DSI peripheral device
807 int mipi_dsi_dcs_nop(struct mipi_dsi_device *dsi) in mipi_dsi_dcs_nop() argument
811 err = mipi_dsi_dcs_write(dsi, MIPI_DCS_NOP, NULL, 0); in mipi_dsi_dcs_nop()
820 * mipi_dsi_dcs_soft_reset() - perform a software reset of the display module
821 * @dsi: DSI peripheral device
825 int mipi_dsi_dcs_soft_reset(struct mipi_dsi_device *dsi) in mipi_dsi_dcs_soft_reset() argument
829 err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SOFT_RESET, NULL, 0); in mipi_dsi_dcs_soft_reset()
838 * mipi_dsi_dcs_get_power_mode() - query the display module's current power
840 * @dsi: DSI peripheral device
845 int mipi_dsi_dcs_get_power_mode(struct mipi_dsi_device *dsi, u8 *mode) in mipi_dsi_dcs_get_power_mode() argument
849 err = mipi_dsi_dcs_read(dsi, MIPI_DCS_GET_POWER_MODE, mode, in mipi_dsi_dcs_get_power_mode()
853 err = -ENODATA; in mipi_dsi_dcs_get_power_mode()
863 * mipi_dsi_dcs_get_pixel_format() - gets the pixel format for the RGB image
865 * @dsi: DSI peripheral device
870 int mipi_dsi_dcs_get_pixel_format(struct mipi_dsi_device *dsi, u8 *format) in mipi_dsi_dcs_get_pixel_format() argument
874 err = mipi_dsi_dcs_read(dsi, MIPI_DCS_GET_PIXEL_FORMAT, format, in mipi_dsi_dcs_get_pixel_format()
878 err = -ENODATA; in mipi_dsi_dcs_get_pixel_format()
888 * mipi_dsi_dcs_enter_sleep_mode() - disable all unnecessary blocks inside the
890 * @dsi: DSI peripheral device
894 int mipi_dsi_dcs_enter_sleep_mode(struct mipi_dsi_device *dsi) in mipi_dsi_dcs_enter_sleep_mode() argument
898 err = mipi_dsi_dcs_write(dsi, MIPI_DCS_ENTER_SLEEP_MODE, NULL, 0); in mipi_dsi_dcs_enter_sleep_mode()
907 * mipi_dsi_dcs_exit_sleep_mode() - enable all blocks inside the display
909 * @dsi: DSI peripheral device
913 int mipi_dsi_dcs_exit_sleep_mode(struct mipi_dsi_device *dsi) in mipi_dsi_dcs_exit_sleep_mode() argument
917 err = mipi_dsi_dcs_write(dsi, MIPI_DCS_EXIT_SLEEP_MODE, NULL, 0); in mipi_dsi_dcs_exit_sleep_mode()
926 * mipi_dsi_dcs_set_display_off() - stop displaying the image data on the
928 * @dsi: DSI peripheral device
932 int mipi_dsi_dcs_set_display_off(struct mipi_dsi_device *dsi) in mipi_dsi_dcs_set_display_off() argument
936 err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_DISPLAY_OFF, NULL, 0); in mipi_dsi_dcs_set_display_off()
945 * mipi_dsi_dcs_set_display_on() - start displaying the image data on the
947 * @dsi: DSI peripheral device
951 int mipi_dsi_dcs_set_display_on(struct mipi_dsi_device *dsi) in mipi_dsi_dcs_set_display_on() argument
955 err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_DISPLAY_ON, NULL, 0); in mipi_dsi_dcs_set_display_on()
964 * mipi_dsi_dcs_set_column_address() - define the column extent of the frame
966 * @dsi: DSI peripheral device
972 int mipi_dsi_dcs_set_column_address(struct mipi_dsi_device *dsi, u16 start, in mipi_dsi_dcs_set_column_address() argument
978 err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_COLUMN_ADDRESS, payload, in mipi_dsi_dcs_set_column_address()
988 * mipi_dsi_dcs_set_page_address() - define the page extent of the frame
990 * @dsi: DSI peripheral device
996 int mipi_dsi_dcs_set_page_address(struct mipi_dsi_device *dsi, u16 start, in mipi_dsi_dcs_set_page_address() argument
1002 err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_PAGE_ADDRESS, payload, in mipi_dsi_dcs_set_page_address()
1012 * mipi_dsi_dcs_set_tear_off() - turn off the display module's Tearing Effect
1014 * @dsi: DSI peripheral device
1018 int mipi_dsi_dcs_set_tear_off(struct mipi_dsi_device *dsi) in mipi_dsi_dcs_set_tear_off() argument
1022 err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_TEAR_OFF, NULL, 0); in mipi_dsi_dcs_set_tear_off()
1031 * mipi_dsi_dcs_set_tear_on() - turn on the display module's Tearing Effect
1033 * @dsi: DSI peripheral device
1038 int mipi_dsi_dcs_set_tear_on(struct mipi_dsi_device *dsi, in mipi_dsi_dcs_set_tear_on() argument
1044 err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_TEAR_ON, &value, in mipi_dsi_dcs_set_tear_on()
1054 * mipi_dsi_dcs_set_pixel_format() - sets the pixel format for the RGB image
1056 * @dsi: DSI peripheral device
1061 int mipi_dsi_dcs_set_pixel_format(struct mipi_dsi_device *dsi, u8 format) in mipi_dsi_dcs_set_pixel_format() argument
1065 err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_PIXEL_FORMAT, &format, in mipi_dsi_dcs_set_pixel_format()
1075 * mipi_dsi_dcs_set_tear_scanline() - set the scanline to use as trigger for
1077 * @dsi: DSI peripheral device
1082 int mipi_dsi_dcs_set_tear_scanline(struct mipi_dsi_device *dsi, u16 scanline) in mipi_dsi_dcs_set_tear_scanline() argument
1087 err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_TEAR_SCANLINE, payload, in mipi_dsi_dcs_set_tear_scanline()
1097 * mipi_dsi_dcs_set_display_brightness() - sets the brightness value of the
1099 * @dsi: DSI peripheral device
1104 int mipi_dsi_dcs_set_display_brightness(struct mipi_dsi_device *dsi, in mipi_dsi_dcs_set_display_brightness() argument
1110 err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_DISPLAY_BRIGHTNESS, in mipi_dsi_dcs_set_display_brightness()
1120 * mipi_dsi_dcs_get_display_brightness() - gets the current brightness value
1122 * @dsi: DSI peripheral device
1127 int mipi_dsi_dcs_get_display_brightness(struct mipi_dsi_device *dsi, in mipi_dsi_dcs_get_display_brightness() argument
1132 err = mipi_dsi_dcs_read(dsi, MIPI_DCS_GET_DISPLAY_BRIGHTNESS, in mipi_dsi_dcs_get_display_brightness()
1136 err = -ENODATA; in mipi_dsi_dcs_get_display_brightness()
1147 struct mipi_dsi_driver *drv = to_mipi_dsi_driver(dev->driver); in mipi_dsi_drv_probe()
1148 struct mipi_dsi_device *dsi = to_mipi_dsi_device(dev); in mipi_dsi_drv_probe() local
1150 return drv->probe(dsi); in mipi_dsi_drv_probe()
1155 struct mipi_dsi_driver *drv = to_mipi_dsi_driver(dev->driver); in mipi_dsi_drv_remove()
1156 struct mipi_dsi_device *dsi = to_mipi_dsi_device(dev); in mipi_dsi_drv_remove() local
1158 return drv->remove(dsi); in mipi_dsi_drv_remove()
1163 struct mipi_dsi_driver *drv = to_mipi_dsi_driver(dev->driver); in mipi_dsi_drv_shutdown()
1164 struct mipi_dsi_device *dsi = to_mipi_dsi_device(dev); in mipi_dsi_drv_shutdown() local
1166 drv->shutdown(dsi); in mipi_dsi_drv_shutdown()
1170 * mipi_dsi_driver_register_full() - register a driver for DSI devices
1171 * @drv: DSI driver structure
1179 drv->driver.bus = &mipi_dsi_bus_type; in mipi_dsi_driver_register_full()
1180 drv->driver.owner = owner; in mipi_dsi_driver_register_full()
1182 if (drv->probe) in mipi_dsi_driver_register_full()
1183 drv->driver.probe = mipi_dsi_drv_probe; in mipi_dsi_driver_register_full()
1184 if (drv->remove) in mipi_dsi_driver_register_full()
1185 drv->driver.remove = mipi_dsi_drv_remove; in mipi_dsi_driver_register_full()
1186 if (drv->shutdown) in mipi_dsi_driver_register_full()
1187 drv->driver.shutdown = mipi_dsi_drv_shutdown; in mipi_dsi_driver_register_full()
1189 return driver_register(&drv->driver); in mipi_dsi_driver_register_full()
1194 * mipi_dsi_driver_unregister() - unregister a driver for DSI devices
1195 * @drv: DSI driver structure
1201 driver_unregister(&drv->driver); in mipi_dsi_driver_unregister()
1212 MODULE_DESCRIPTION("MIPI DSI Bus");