Subversion Repositories Kolibri OS

Rev

Rev 6088 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

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