Merge "target: apq8084: Fix DSI clock disable API call"
diff --git a/dev/gcdb/display/gcdb_display.c b/dev/gcdb/display/gcdb_display.c
index 1c08d96..c184b11 100755
--- a/dev/gcdb/display/gcdb_display.c
+++ b/dev/gcdb/display/gcdb_display.c
@@ -148,19 +148,44 @@
 
 bool target_display_panel_node(char *pbuf, uint16_t buf_size)
 {
-	char *dsi_id = NULL, *panel_node = NULL;
-	bool ret = false;
+	char *dsi_id = NULL;
+	char *panel_node = NULL;
+	uint16_t dsi_id_len = 0;
+	bool ret = true;
+	char *default_str;
 
-	if(!panelstruct.paneldata) {
-		return ret;
+	if(panelstruct.paneldata)
+	{
+		dsi_id = panelstruct.paneldata->panel_controller;
+		panel_node = panelstruct.paneldata->panel_node_id;
+	}
+	else
+	{
+		if (target_is_edp())
+		{
+			default_str = "0:edp:";
+		}
+		else
+		{
+			default_str = "0:dsi:0:";
+		}
+		strlcpy(pbuf, default_str, buf_size);
+		return true;
 	}
 
-	dsi_id = panelstruct.paneldata->panel_controller;
-	panel_node = panelstruct.paneldata->panel_node_id;
+	if (dsi_id == NULL || panel_node == NULL)
+		return false;
 
-	if (buf_size >= (strlen(panel_node) + MAX_DSI_STREAM_LEN +
-			MAX_PANEL_FORMAT_STRING + 1) &&
-		strlen(panel_node) && strlen(dsi_id))
+	dsi_id_len = strlen(dsi_id);
+
+	if (buf_size < (strlen(panel_node) + dsi_id_len +
+			MAX_PANEL_FORMAT_STRING + 1) ||
+		strlen(panel_node) ||
+		strlen(dsi_id))
+	{
+		ret = false;
+	}
+	else
 	{
 		pbuf[0] = '1'; // 1 indicates that LK is overriding the panel
 		pbuf[1] = ':'; // seperator
@@ -168,8 +193,8 @@
 		buf_size -= MAX_PANEL_FORMAT_STRING;
 
 		strlcpy(pbuf, dsi_id, buf_size);
-		pbuf += MAX_DSI_STREAM_LEN;
-		buf_size -= MAX_DSI_STREAM_LEN;
+		pbuf += dsi_id_len;
+		buf_size -= dsi_id_len;
 
 		strlcpy(pbuf, panel_node, buf_size);
 		ret = true;
diff --git a/dev/gcdb/display/gcdb_display.h b/dev/gcdb/display/gcdb_display.h
index 1de05fb..4811015 100755
--- a/dev/gcdb/display/gcdb_display.h
+++ b/dev/gcdb/display/gcdb_display.h
@@ -43,8 +43,6 @@
 #define BIST_SIZE 6
 #define LANE_SIZE 45
 
-#define MAX_DSI_STREAM_LEN 6
-
 #define MAX_PANEL_FORMAT_STRING 2
 
 /*---------------------------------------------------------------------------*/
diff --git a/dev/gcdb/display/include/panel_generic_720p_cmd.h b/dev/gcdb/display/include/panel_generic_720p_cmd.h
new file mode 100644
index 0000000..8320407
--- /dev/null
+++ b/dev/gcdb/display/include/panel_generic_720p_cmd.h
@@ -0,0 +1,184 @@
+/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *  * Neither the name of The Linux Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*---------------------------------------------------------------------------
+ * This file is autogenerated file using gcdb parser. Please do not edit it.
+ * Update input XML file to add a new entry or update variable in this file
+ * VERSION = "1.0"
+ *---------------------------------------------------------------------------*/
+
+#ifndef _PANEL_GENERIC_720P_CMD_H_
+
+#define _PANEL_GENERIC_720P_CMD_H_
+/*---------------------------------------------------------------------------*/
+/* HEADER files                                                              */
+/*---------------------------------------------------------------------------*/
+#include "panel.h"
+
+/*---------------------------------------------------------------------------*/
+/* Panel configuration                                                       */
+/*---------------------------------------------------------------------------*/
+
+static struct panel_config generic_720p_cmd_panel_data = {
+  "qcom,mdss_dsi_generic_720p_cmd", "dsi:0:", "qcom,mdss-dsi-panel",
+  10, 1, "DISPLAY_1", 0, 0, 60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+/*---------------------------------------------------------------------------*/
+/* Panel resolution                                                          */
+/*---------------------------------------------------------------------------*/
+static struct panel_resolution generic_720p_cmd_panel_res = {
+  768, 1280, 26, 26, 26, 0, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+/*---------------------------------------------------------------------------*/
+/* Panel Color Information                                                   */
+/*---------------------------------------------------------------------------*/
+static struct color_info generic_720p_cmd_color = {
+  24, 0, 0xff, 0, 0, 0
+};
+
+/*---------------------------------------------------------------------------*/
+/* Panel Command information                                                 */
+/*---------------------------------------------------------------------------*/
+static char generic_720p_cmd_on_cmd0[] = {
+0x11, 0x00, 0x05, 0x80 };
+
+
+static char generic_720p_cmd_on_cmd1[] = {
+0x36, 0x00, 0x15, 0x80 };
+
+
+static char generic_720p_cmd_on_cmd2[] = {
+0x29, 0x00, 0x05, 0x80 };
+
+
+static char generic_720p_cmd_on_cmd3[] = {
+0x53, 0x24, 0x15, 0x80 };
+
+
+static char generic_720p_cmd_on_cmd4[] = {
+0x35, 0x00, 0x15, 0x80 };
+
+
+
+
+static struct mipi_dsi_cmd generic_720p_cmd_on_command[] = {
+{ 0x4 , generic_720p_cmd_on_cmd0},
+{ 0x4 , generic_720p_cmd_on_cmd1},
+{ 0x4 , generic_720p_cmd_on_cmd2},
+{ 0x4 , generic_720p_cmd_on_cmd3},
+{ 0x4 , generic_720p_cmd_on_cmd4}
+};
+#define GENERIC_720P_CMD_ON_COMMAND 5
+
+
+static char generic_720p_cmdoff_cmd0[] = {
+0x34, 0x00, 0x05, 0x80 };
+
+
+static char generic_720p_cmdoff_cmd1[] = {
+0x10, 0x00, 0x05, 0x80 };
+
+
+static char generic_720p_cmdoff_cmd2[] = {
+0x28, 0x00, 0x05, 0x80 };
+
+
+static char generic_720p_cmdoff_cmd3[] = {
+0x53, 0x00, 0x15, 0x80 };
+
+
+
+
+static struct mipi_dsi_cmd generic_720p_cmd_off_command[] = {
+{ 0x4 , generic_720p_cmdoff_cmd0},
+{ 0x4 , generic_720p_cmdoff_cmd1},
+{ 0x4 , generic_720p_cmdoff_cmd2},
+{ 0x4 , generic_720p_cmdoff_cmd3}
+};
+#define GENERIC_720P_CMD_OFF_COMMAND 4
+
+
+static struct command_state generic_720p_cmd_state = {
+  0, 1
+};
+
+/*---------------------------------------------------------------------------*/
+/* Command mode panel information                                            */
+/*---------------------------------------------------------------------------*/
+
+static struct commandpanel_info generic_720p_cmd_command_panel = {
+  1, 1, 1, 0, 0, 0x2c, 0, 0, 0, 1, 0, 0
+};
+
+/*---------------------------------------------------------------------------*/
+/* Video mode panel information                                              */
+/*---------------------------------------------------------------------------*/
+
+static struct videopanel_info generic_720p_cmd_video_panel = {
+  0, 0, 0, 0, 1, 1, 1, 0, 0x9
+};
+
+/*---------------------------------------------------------------------------*/
+/* Lane Configuration                                                        */
+/*---------------------------------------------------------------------------*/
+
+static struct lane_configuration generic_720p_cmd_lane_config = {
+  4, 0, 1, 1, 1, 1
+};
+
+
+/*---------------------------------------------------------------------------*/
+/* Panel Timing                                                              */
+/*---------------------------------------------------------------------------*/
+static const uint32_t generic_720p_cmd_timings[] = {
+  0x6e, 0x26, 0x1b, 0x00, 0x35, 0x34, 0x20, 0x28, 0x17, 0x03, 0x04, 0x00
+};
+
+static struct panel_timing generic_720p_cmd_timing_info = {
+  0, 4, 0x20, 0x2a
+};
+
+static struct panel_reset_sequence generic_720p_cmd_reset_seq = {
+ { 1, 0, 1, }, { 20, 2, 20, }, 2
+};
+
+
+/*---------------------------------------------------------------------------*/
+/* Backlight Settings                                                        */
+/*---------------------------------------------------------------------------*/
+
+static struct backlight generic_720p_cmd_backlight = {
+  1, 1, 4095, 100, 1, "PMIC_8941"
+};
+
+#define GENERIC_720P_CMD_SIGNATURE 0x210000
+
+#endif /*_PANEL_GENERIC_720P_CMD_H_*/
diff --git a/target/init.c b/target/init.c
index 5eca9c6..92bcf04 100644
--- a/target/init.c
+++ b/target/init.c
@@ -155,3 +155,8 @@
 {
 	return 0;
 }
+
+__WEAK uint8_t target_is_edp()
+{
+	return 0;
+}
diff --git a/target/msm8974/init.c b/target/msm8974/init.c
index 97ca6b1..1ee89bf 100644
--- a/target/msm8974/init.c
+++ b/target/msm8974/init.c
@@ -619,6 +619,20 @@
 	return 0;
 }
 
+uint8_t target_is_edp()
+{
+	switch(board_hardware_id())
+	{
+		case HW_PLATFORM_LIQUID:
+			return 1;
+			break;
+		default:
+			return 0;
+			break;
+	}
+	return 0;
+}
+
 static uint8_t splash_override;
 /* Returns 1 if target supports continuous splash screen. */
 int target_cont_splash_screen()
diff --git a/target/msm8974/oem_panel.c b/target/msm8974/oem_panel.c
index 1f876d7..c9b87c2 100755
--- a/target/msm8974/oem_panel.c
+++ b/target/msm8974/oem_panel.c
@@ -43,8 +43,9 @@
 #include "include/panel_toshiba_720p_video.h"
 #include "include/panel_sharp_qhd_video.h"
 #include "include/panel_jdi_1080p_video.h"
+#include "include/panel_generic_720p_cmd.h"
 
-#define DISPLAY_MAX_PANEL_DETECTION 2
+#define DISPLAY_MAX_PANEL_DETECTION 3
 
 /*---------------------------------------------------------------------------*/
 /* static panel selection variable                                           */
@@ -53,6 +54,7 @@
 JDI_1080P_VIDEO_PANEL,
 TOSHIBA_720P_VIDEO_PANEL,
 SHARP_QHD_VIDEO_PANEL,
+GENERIC_720P_CMD_PANEL,
 UNKNOWN_PANEL
 };
 
@@ -147,6 +149,27 @@
 			jdi_1080p_video_timings, TIMING_SIZE);
 		pinfo->mipi.signature = JDI_1080P_VIDEO_SIGNATURE;
 		break;
+	case GENERIC_720P_CMD_PANEL:
+		panelstruct->paneldata    = &generic_720p_cmd_panel_data;
+		panelstruct->panelres     = &generic_720p_cmd_panel_res;
+		panelstruct->color        = &generic_720p_cmd_color;
+		panelstruct->videopanel   = &generic_720p_cmd_video_panel;
+		panelstruct->commandpanel = &generic_720p_cmd_command_panel;
+		panelstruct->state        = &generic_720p_cmd_state;
+		panelstruct->laneconfig   = &generic_720p_cmd_lane_config;
+		panelstruct->paneltiminginfo
+			= &generic_720p_cmd_timing_info;
+		panelstruct->panelresetseq
+					 = &generic_720p_cmd_reset_seq;
+		panelstruct->backlightinfo = &generic_720p_cmd_backlight;
+		pinfo->mipi.panel_cmds
+			= generic_720p_cmd_on_command;
+		pinfo->mipi.num_of_panel_cmds
+			= GENERIC_720P_CMD_ON_COMMAND;
+		memcpy(phy_db->timing,
+			generic_720p_cmd_timings, TIMING_SIZE);
+		pinfo->mipi.signature = GENERIC_720P_CMD_SIGNATURE;
+		break;
 	case UNKNOWN_PANEL:
 		memset(panelstruct, 0, sizeof(struct panel_struct));
 		memset(pinfo->mipi.panel_cmds, 0, sizeof(struct mipi_dsi_cmd));
@@ -184,6 +207,9 @@
 		case 1:
 			panel_id = TOSHIBA_720P_VIDEO_PANEL;
 			break;
+		case 2:
+			panel_id = GENERIC_720P_CMD_PANEL;
+			break;
 		default:
 			panel_id = UNKNOWN_PANEL;
 			ret = false;