···11+AU Optronics Corporation 11.6" HD (1366x768) color TFT-LCD panel22+33+Required properties:44+- compatible: should be "auo,b116xw03"55+66+This binding is compatible with the simple-panel binding, which is specified77+in simple-panel.txt in this directory.
···11+HannStar Display Corp. HSD070PWW1 7.0" WXGA TFT LCD panel22+33+Required properties:44+- compatible: should be "hannstar,hsd070pww1"55+66+This binding is compatible with the simple-panel binding, which is specified77+in simple-panel.txt in this directory.
···11+Hitachi Ltd. Corporation 9" WVGA (800x480) TFT LCD panel22+33+Required properties:44+- compatible: should be "hit,tx23d38vm0caa"55+66+This binding is compatible with the simple-panel binding, which is specified77+in simple-panel.txt in this directory.
···11+Innolux Corporation 12.1" WXGA (1280x800) TFT LCD panel22+33+Required properties:44+- compatible: should be "innolux,g121i1-l01"55+66+This binding is compatible with the simple-panel binding, which is specified77+in simple-panel.txt in this directory.
···198198}199199EXPORT_SYMBOL(mipi_dsi_detach);200200201201-/**202202- * mipi_dsi_dcs_write - send DCS write command203203- * @dsi: DSI device204204- * @data: pointer to the command followed by parameters205205- * @len: length of @data206206- */207207-ssize_t mipi_dsi_dcs_write(struct mipi_dsi_device *dsi, const void *data,208208- size_t len)201201+static ssize_t mipi_dsi_device_transfer(struct mipi_dsi_device *dsi,202202+ struct mipi_dsi_msg *msg)209203{210204 const struct mipi_dsi_host_ops *ops = dsi->host->ops;205205+206206+ if (!ops || !ops->transfer)207207+ return -ENOSYS;208208+209209+ if (dsi->mode_flags & MIPI_DSI_MODE_LPM)210210+ msg->flags |= MIPI_DSI_MSG_USE_LPM;211211+212212+ return ops->transfer(dsi->host, msg);213213+}214214+215215+/**216216+ * mipi_dsi_packet_format_is_short - check if a packet is of the short format217217+ * @type: MIPI DSI data type of the packet218218+ *219219+ * Return: true if the packet for the given data type is a short packet, false220220+ * otherwise.221221+ */222222+bool mipi_dsi_packet_format_is_short(u8 type)223223+{224224+ switch (type) {225225+ case MIPI_DSI_V_SYNC_START:226226+ case MIPI_DSI_V_SYNC_END:227227+ case MIPI_DSI_H_SYNC_START:228228+ case MIPI_DSI_H_SYNC_END:229229+ case MIPI_DSI_END_OF_TRANSMISSION:230230+ case MIPI_DSI_COLOR_MODE_OFF:231231+ case MIPI_DSI_COLOR_MODE_ON:232232+ case MIPI_DSI_SHUTDOWN_PERIPHERAL:233233+ case MIPI_DSI_TURN_ON_PERIPHERAL:234234+ case MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM:235235+ case MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM:236236+ case MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM:237237+ case MIPI_DSI_GENERIC_READ_REQUEST_0_PARAM:238238+ case MIPI_DSI_GENERIC_READ_REQUEST_1_PARAM:239239+ case MIPI_DSI_GENERIC_READ_REQUEST_2_PARAM:240240+ case MIPI_DSI_DCS_SHORT_WRITE:241241+ case MIPI_DSI_DCS_SHORT_WRITE_PARAM:242242+ case MIPI_DSI_DCS_READ:243243+ case MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE:244244+ return true;245245+ }246246+247247+ return false;248248+}249249+EXPORT_SYMBOL(mipi_dsi_packet_format_is_short);250250+251251+/**252252+ * mipi_dsi_packet_format_is_long - check if a packet is of the long format253253+ * @type: MIPI DSI data type of the packet254254+ *255255+ * Return: true if the packet for the given data type is a long packet, false256256+ * otherwise.257257+ */258258+bool mipi_dsi_packet_format_is_long(u8 type)259259+{260260+ switch (type) {261261+ case MIPI_DSI_NULL_PACKET:262262+ case MIPI_DSI_BLANKING_PACKET:263263+ case MIPI_DSI_GENERIC_LONG_WRITE:264264+ case MIPI_DSI_DCS_LONG_WRITE:265265+ case MIPI_DSI_LOOSELY_PACKED_PIXEL_STREAM_YCBCR20:266266+ case MIPI_DSI_PACKED_PIXEL_STREAM_YCBCR24:267267+ case MIPI_DSI_PACKED_PIXEL_STREAM_YCBCR16:268268+ case MIPI_DSI_PACKED_PIXEL_STREAM_30:269269+ case MIPI_DSI_PACKED_PIXEL_STREAM_36:270270+ case MIPI_DSI_PACKED_PIXEL_STREAM_YCBCR12:271271+ case MIPI_DSI_PACKED_PIXEL_STREAM_16:272272+ case MIPI_DSI_PACKED_PIXEL_STREAM_18:273273+ case MIPI_DSI_PIXEL_STREAM_3BYTE_18:274274+ case MIPI_DSI_PACKED_PIXEL_STREAM_24:275275+ return true;276276+ }277277+278278+ return false;279279+}280280+EXPORT_SYMBOL(mipi_dsi_packet_format_is_long);281281+282282+/**283283+ * mipi_dsi_create_packet - create a packet from a message according to the284284+ * DSI protocol285285+ * @packet: pointer to a DSI packet structure286286+ * @msg: message to translate into a packet287287+ *288288+ * Return: 0 on success or a negative error code on failure.289289+ */290290+int mipi_dsi_create_packet(struct mipi_dsi_packet *packet,291291+ const struct mipi_dsi_msg *msg)292292+{293293+ const u8 *tx = msg->tx_buf;294294+295295+ if (!packet || !msg)296296+ return -EINVAL;297297+298298+ /* do some minimum sanity checking */299299+ if (!mipi_dsi_packet_format_is_short(msg->type) &&300300+ !mipi_dsi_packet_format_is_long(msg->type))301301+ return -EINVAL;302302+303303+ if (msg->channel > 3)304304+ return -EINVAL;305305+306306+ memset(packet, 0, sizeof(*packet));307307+ packet->header[0] = ((msg->channel & 0x3) << 6) | (msg->type & 0x3f);308308+309309+ /* TODO: compute ECC if hardware support is not available */310310+311311+ /*312312+ * Long write packets contain the word count in header bytes 1 and 2.313313+ * The payload follows the header and is word count bytes long.314314+ *315315+ * Short write packets encode up to two parameters in header bytes 1316316+ * and 2.317317+ */318318+ if (mipi_dsi_packet_format_is_long(msg->type)) {319319+ packet->header[1] = (msg->tx_len >> 0) & 0xff;320320+ packet->header[2] = (msg->tx_len >> 8) & 0xff;321321+322322+ packet->payload_length = msg->tx_len;323323+ packet->payload = tx;324324+ } else {325325+ packet->header[1] = (msg->tx_len > 0) ? tx[0] : 0;326326+ packet->header[2] = (msg->tx_len > 1) ? tx[1] : 0;327327+ }328328+329329+ packet->size = sizeof(packet->header) + packet->payload_length;330330+331331+ return 0;332332+}333333+EXPORT_SYMBOL(mipi_dsi_create_packet);334334+335335+/**336336+ * mipi_dsi_dcs_write_buffer() - transmit a DCS command with payload337337+ * @dsi: DSI peripheral device338338+ * @data: buffer containing data to be transmitted339339+ * @len: size of transmission buffer340340+ *341341+ * This function will automatically choose the right data type depending on342342+ * the command payload length.343343+ *344344+ * Return: The number of bytes successfully transmitted or a negative error345345+ * code on failure.346346+ */347347+ssize_t mipi_dsi_dcs_write_buffer(struct mipi_dsi_device *dsi,348348+ const void *data, size_t len)349349+{211350 struct mipi_dsi_msg msg = {212351 .channel = dsi->channel,213352 .tx_buf = data,214353 .tx_len = len215354 };216355217217- if (!ops || !ops->transfer)218218- return -ENOSYS;219219-220356 switch (len) {221357 case 0:222358 return -EINVAL;359359+223360 case 1:224361 msg.type = MIPI_DSI_DCS_SHORT_WRITE;225362 break;363363+226364 case 2:227365 msg.type = MIPI_DSI_DCS_SHORT_WRITE_PARAM;228366 break;367367+229368 default:230369 msg.type = MIPI_DSI_DCS_LONG_WRITE;231370 break;232371 }233372234234- if (dsi->mode_flags & MIPI_DSI_MODE_LPM)235235- msg.flags = MIPI_DSI_MSG_USE_LPM;373373+ return mipi_dsi_device_transfer(dsi, &msg);374374+}375375+EXPORT_SYMBOL(mipi_dsi_dcs_write_buffer);236376237237- return ops->transfer(dsi->host, &msg);377377+/**378378+ * mipi_dsi_dcs_write() - send DCS write command379379+ * @dsi: DSI peripheral device380380+ * @cmd: DCS command381381+ * @data: buffer containing the command payload382382+ * @len: command payload length383383+ *384384+ * This function will automatically choose the right data type depending on385385+ * the command payload length.386386+ *387387+ * Return: The number of bytes successfully transmitted or a negative error388388+ * code on failure.389389+ */390390+ssize_t mipi_dsi_dcs_write(struct mipi_dsi_device *dsi, u8 cmd,391391+ const void *data, size_t len)392392+{393393+ ssize_t err;394394+ size_t size;395395+ u8 *tx;396396+397397+ if (len > 0) {398398+ size = 1 + len;399399+400400+ tx = kmalloc(size, GFP_KERNEL);401401+ if (!tx)402402+ return -ENOMEM;403403+404404+ /* concatenate the DCS command byte and the payload */405405+ tx[0] = cmd;406406+ memcpy(&tx[1], data, len);407407+ } else {408408+ tx = &cmd;409409+ size = 1;410410+ }411411+412412+ err = mipi_dsi_dcs_write_buffer(dsi, tx, size);413413+414414+ if (len > 0)415415+ kfree(tx);416416+417417+ return err;238418}239419EXPORT_SYMBOL(mipi_dsi_dcs_write);240420241421/**242242- * mipi_dsi_dcs_read - send DCS read request command243243- * @dsi: DSI device244244- * @cmd: DCS read command245245- * @data: pointer to read buffer246246- * @len: length of @data422422+ * mipi_dsi_dcs_read() - send DCS read request command423423+ * @dsi: DSI peripheral device424424+ * @cmd: DCS command425425+ * @data: buffer in which to receive data426426+ * @len: size of receive buffer247427 *248248- * Function returns number of read bytes or error code.428428+ * Return: The number of bytes read or a negative error code on failure.249429 */250430ssize_t mipi_dsi_dcs_read(struct mipi_dsi_device *dsi, u8 cmd, void *data,251431 size_t len)252432{253253- const struct mipi_dsi_host_ops *ops = dsi->host->ops;254433 struct mipi_dsi_msg msg = {255434 .channel = dsi->channel,256435 .type = MIPI_DSI_DCS_READ,···439260 .rx_len = len440261 };441262442442- if (!ops || !ops->transfer)443443- return -ENOSYS;444444-445445- if (dsi->mode_flags & MIPI_DSI_MODE_LPM)446446- msg.flags = MIPI_DSI_MSG_USE_LPM;447447-448448- return ops->transfer(dsi->host, &msg);263263+ return mipi_dsi_device_transfer(dsi, &msg);449264}450265EXPORT_SYMBOL(mipi_dsi_dcs_read);451266