Merge "target: msm8226: Restore MDP security configs before accessing MDP HW"
diff --git a/dev/gcdb/display/include/panel_hx8389b_qhd_video.h b/dev/gcdb/display/include/panel_hx8389b_qhd_video.h
new file mode 100644
index 0000000..b172fdb
--- /dev/null
+++ b/dev/gcdb/display/include/panel_hx8389b_qhd_video.h
@@ -0,0 +1,283 @@
+/* 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_HX8389B_QHD_VIDEO_H_
+
+#define _PANEL_HX8389B_QHD_VIDEO_H_
+/*---------------------------------------------------------------------------*/
+/* HEADER files                                                              */
+/*---------------------------------------------------------------------------*/
+#include "panel.h"
+
+/*---------------------------------------------------------------------------*/
+/* Panel configuration                                                       */
+/*---------------------------------------------------------------------------*/
+
+static struct panel_config hx8389b_qhd_video_panel_data = {
+  "qcom,mdss_dsi_hx8389b_qhd_video", "dsi:0:", "qcom,mdss-dsi-panel",
+  10, 0, "DISPLAY_1", 0, 0, 60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+/*---------------------------------------------------------------------------*/
+/* Panel resolution                                                          */
+/*---------------------------------------------------------------------------*/
+static struct panel_resolution hx8389b_qhd_video_panel_res = {
+  540, 960, 48, 96, 96, 0, 9, 13, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+/*---------------------------------------------------------------------------*/
+/* Panel Color Information                                                   */
+/*---------------------------------------------------------------------------*/
+static struct color_info hx8389b_qhd_video_color = {
+  24, 0, 0xff, 0, 0, 0
+};
+
+/*---------------------------------------------------------------------------*/
+/* Panel Command information                                                 */
+/*---------------------------------------------------------------------------*/
+static char hx8389b_qhd_video_on_cmd0[] = {
+0x04, 0x00, 0x39, 0xC0,
+0xB9, 0xFF, 0x83, 0x89,
+ };
+
+
+static char hx8389b_qhd_video_on_cmd1[] = {
+0x08, 0x00, 0x39, 0xC0,
+0xBA, 0x41, 0x93, 0x00,
+0x16, 0xA4, 0x10, 0x18,
+ };
+
+
+static char hx8389b_qhd_video_on_cmd2[] = {
+0xC6, 0x08, 0x23, 0x80 };
+
+
+static char hx8389b_qhd_video_on_cmd3[] = {
+0x03, 0x00, 0x39, 0xC0,
+0xBC, 0x02, 0x00, 0xFF,  };
+
+
+static char hx8389b_qhd_video_on_cmd4[] = {
+0xCC, 0x02, 0x23, 0x80 };
+
+
+static char hx8389b_qhd_video_on_cmd5[] = {
+0x14, 0x00, 0x39, 0xC0,
+0xB1, 0x00, 0x00, 0x07,
+0xE8, 0x50, 0x10, 0x11,
+0x98, 0xf8, 0x21, 0x29,
+0x27, 0x27, 0x43, 0x01,
+0x58, 0xF0, 0x00, 0xE6,
+ };
+
+
+static char hx8389b_qhd_video_on_cmd6[] = {
+0x08, 0x00, 0x39, 0xC0,
+0xB2, 0x00, 0x00, 0x78,
+0x0C, 0x07, 0x3F, 0x80,
+ };
+
+
+static char hx8389b_qhd_video_on_cmd7[] = {
+0x18, 0x00, 0x39, 0xC0,
+0xb4, 0x82, 0x08, 0x00,
+0x32, 0x10, 0x04, 0x32,
+0x10, 0x00, 0x32, 0x10,
+0x00, 0x37, 0x0a, 0x40,
+0x08, 0x37, 0x0a, 0x40,
+0x14, 0x46, 0x50, 0x0a,
+ };
+
+
+static char hx8389b_qhd_video_on_cmd8[] = {
+0x39, 0x00, 0x39, 0xC0,
+0xd5, 0x00, 0x00, 0x00,
+0x00, 0x01, 0x00, 0x00,
+0x00, 0x60, 0x00, 0x99,
+0x88, 0xAA, 0xBB, 0x88,
+0x23, 0x88, 0x01, 0x88,
+0x67, 0x88, 0x45, 0x01,
+0x23, 0x88, 0x88, 0x88,
+0x88, 0x88, 0x88, 0x99,
+0xBB, 0xAA, 0x88, 0x54,
+0x88, 0x76, 0x88, 0x10,
+0x88, 0x32, 0x32, 0x10,
+0x88, 0x88, 0x88, 0x88,
+0x88, 0x00, 0x04, 0x00,
+0x00, 0x00, 0x00, 0x00,
+0x00, 0xFF, 0xFF, 0xFF,
+ };
+
+
+static char hx8389b_qhd_video_on_cmd9[] = {
+0x03, 0x00, 0x39, 0xC0,
+0xCB, 0x07, 0x07, 0xFF,
+};
+
+
+static char hx8389b_qhd_video_on_cmd10[] = {
+0x05, 0x00, 0x39, 0xC0,
+0xBB, 0x00, 0x00, 0xFF,
+0x80, 0xFF, 0xFF, 0xFF,
+};
+
+
+static char hx8389b_qhd_video_on_cmd11[] = {
+0x04, 0x00, 0x39, 0xC0,
+0xDE, 0x05, 0x58, 0x10,
+ };
+
+
+static char hx8389b_qhd_video_on_cmd12[] = {
+0x05, 0x00, 0x39, 0xC0,
+0xB6, 0x00, 0x8A, 0x00,
+0x8A, 0xFF, 0xFF, 0xFF,
+};
+
+
+static char hx8389b_qhd_video_on_cmd13[] = {
+0x23, 0x00, 0x39, 0xC0,
+0xE0, 0x01, 0x08, 0x0C,
+0x1F, 0x25, 0x36, 0x12,
+0x35, 0x05, 0x09, 0x0D,
+0x10, 0x11, 0x0F, 0x0F,
+0x1C, 0x1D, 0x01, 0x08,
+0x0C, 0x1F, 0x25, 0x36,
+0x12, 0x35, 0x05, 0x09,
+0x0D, 0x10, 0x11, 0x0F,
+0x0F, 0x1C, 0x1D, 0xFF,  };
+
+
+static char hx8389b_qhd_video_on_cmd14[] = {
+0x11, 0x00, 0x05, 0x80 };
+
+
+static char hx8389b_qhd_video_on_cmd15[] = {
+0x29, 0x00, 0x05, 0x80 };
+
+
+
+
+static struct mipi_dsi_cmd hx8389b_qhd_video_on_command[] = {
+{ 0x8 , hx8389b_qhd_video_on_cmd0},
+{ 0xc , hx8389b_qhd_video_on_cmd1},
+{ 0x4 , hx8389b_qhd_video_on_cmd2},
+{ 0x8 , hx8389b_qhd_video_on_cmd3},
+{ 0x4 , hx8389b_qhd_video_on_cmd4},
+{ 0x18 , hx8389b_qhd_video_on_cmd5},
+{ 0xc , hx8389b_qhd_video_on_cmd6},
+{ 0x1c , hx8389b_qhd_video_on_cmd7},
+{ 0x3c , hx8389b_qhd_video_on_cmd8},
+{ 0x8 , hx8389b_qhd_video_on_cmd9},
+{ 0xc , hx8389b_qhd_video_on_cmd10},
+{ 0x8 , hx8389b_qhd_video_on_cmd11},
+{ 0xc , hx8389b_qhd_video_on_cmd12},
+{ 0x28 , hx8389b_qhd_video_on_cmd13},
+{ 0x4 , hx8389b_qhd_video_on_cmd14},
+{ 0x4 , hx8389b_qhd_video_on_cmd15}
+};
+#define HX8389B_QHD_VIDEO_ON_COMMAND 16
+
+
+static char hx8389b_qhd_videooff_cmd0[] = {
+0x28, 0x00, 0x05, 0x80 };
+
+
+static char hx8389b_qhd_videooff_cmd1[] = {
+0x10, 0x00, 0x05, 0x80 };
+
+
+
+
+static struct mipi_dsi_cmd hx8389b_qhd_video_off_command[] = {
+{ 0x4 , hx8389b_qhd_videooff_cmd0},
+{ 0x4 , hx8389b_qhd_videooff_cmd1}
+};
+#define HX8389B_QHD_VIDEO_OFF_COMMAND 2
+
+
+static struct command_state hx8389b_qhd_video_state = {
+  0, 0
+};
+
+/*---------------------------------------------------------------------------*/
+/* Command mode panel information                                            */
+/*---------------------------------------------------------------------------*/
+
+static struct commandpanel_info hx8389b_qhd_video_command_panel = {
+  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+/*---------------------------------------------------------------------------*/
+/* Video mode panel information                                              */
+/*---------------------------------------------------------------------------*/
+
+static struct videopanel_info hx8389b_qhd_video_video_panel = {
+  1, 0, 0, 0, 1, 1, 2, 0, 0x9
+};
+
+/*---------------------------------------------------------------------------*/
+/* Lane Configuration                                                        */
+/*---------------------------------------------------------------------------*/
+
+static struct lane_configuration hx8389b_qhd_video_lane_config = {
+  2, 1, 1, 1, 0, 0
+};
+
+
+/*---------------------------------------------------------------------------*/
+/* Panel Timing                                                              */
+/*---------------------------------------------------------------------------*/
+static const uint32_t hx8389b_qhd_video_timings[] = {
+  0x97,0x23,0x17,0x00,0x4B,0x53,0x1C,0x27,0x27,0x03,0x04,0x00
+};
+
+static struct panel_timing hx8389b_qhd_video_timing_info = {
+  0, 4, 0x04, 0x1b
+};
+static struct panel_reset_sequence hx8389b_qhd_video_reset_seq = {
+  { 2, 0, 2, }, { 20, 2, 20, }, 2
+};
+
+/*---------------------------------------------------------------------------*/
+/* Backlight Settings                                                        */
+/*---------------------------------------------------------------------------*/
+
+static struct backlight hx8389b_qhd_video_backlight = {
+  0, 1, 255, 0, 1, 0
+};
+
+
+#endif /*_PANEL_HX8389B_QHD_VIDEO_H_*/
diff --git a/target/msm8610/oem_panel.c b/target/msm8610/oem_panel.c
old mode 100755
new mode 100644
index e532b56..8ea0a5e
--- a/target/msm8610/oem_panel.c
+++ b/target/msm8610/oem_panel.c
@@ -43,6 +43,7 @@
 #include "include/panel_truly_wvga_cmd.h"
 #include "include/panel_truly_wvga_video.h"
 #include "include/panel_hx8379a_wvga_video.h"
+#include "include/panel_hx8389b_qhd_video.h"
 #include "include/panel_otm8018b_fwvga_video.h"
 #include "include/panel_nt35590_720p_video.h"
 
@@ -55,6 +56,13 @@
 HX8379A_WVGA_VIDEO_PANEL,
 OTM8018B_FWVGA_VIDEO_PANEL,
 NT35590_720P_VIDEO_PANEL,
+HX8389B_QHD_VIDEO_PANEL,
+};
+
+enum {
+QRD_DEF,
+QRD_SKUAA,
+QRD_SKUAB = 3,
 };
 
 static uint32_t panel_id;
@@ -186,6 +194,26 @@
 		memcpy(phy_db->timing,
 				nt35590_720p_video_timings, TIMING_SIZE);
 		break;
+	case HX8389B_QHD_VIDEO_PANEL:
+		panelstruct->paneldata    = &hx8389b_qhd_video_panel_data;
+		panelstruct->panelres     = &hx8389b_qhd_video_panel_res;
+		panelstruct->color        = &hx8389b_qhd_video_color;
+		panelstruct->videopanel   = &hx8389b_qhd_video_video_panel;
+		panelstruct->commandpanel = &hx8389b_qhd_video_command_panel;
+		panelstruct->state        = &hx8389b_qhd_video_state;
+		panelstruct->laneconfig   = &hx8389b_qhd_video_lane_config;
+		panelstruct->paneltiminginfo
+					 = &hx8389b_qhd_video_timing_info;
+		panelstruct->panelresetseq
+					 = &hx8389b_qhd_video_reset_seq;
+		panelstruct->backlightinfo = &hx8389b_qhd_video_backlight;
+		pinfo->mipi.panel_cmds
+					= hx8389b_qhd_video_on_command;
+		pinfo->mipi.num_of_panel_cmds
+					= HX8389B_QHD_VIDEO_ON_COMMAND;
+		memcpy(phy_db->timing,
+				hx8389b_qhd_video_timings, TIMING_SIZE);
+		break;
 	default:
 		dprintf(CRITICAL, "Panel ID not detected %d\n", panel_id);
 		return false;
@@ -199,13 +227,31 @@
 {
 	uint32_t hw_id = board_hardware_id();
 	uint32_t platform_subtype = board_hardware_subtype();
+	uint32_t target_id = board_target_id();
+
+	target_id = (target_id >> 16) & 0xFF;
 
 	switch (hw_id) {
 	case HW_PLATFORM_QRD:
-		if ((0 == platform_subtype) || (1 == platform_subtype))
-			panel_id = HX8379A_WVGA_VIDEO_PANEL;
-		else if (3 == platform_subtype)
-			panel_id = OTM8018B_FWVGA_VIDEO_PANEL;
+		switch (platform_subtype) {
+			case QRD_DEF:
+			case QRD_SKUAA:
+				panel_id = HX8379A_WVGA_VIDEO_PANEL;
+				break;
+			case QRD_SKUAB:
+				if (target_id == 0x1)	// 1st HW version
+					panel_id = OTM8018B_FWVGA_VIDEO_PANEL;
+				else if (target_id == 0x2)	//2nd HW version
+					panel_id = HX8389B_QHD_VIDEO_PANEL;
+				else
+					dprintf(CRITICAL, "SKUAB Display not enabled for %d type\n",
+							target_id);
+				break;
+			default:
+				dprintf(CRITICAL, "QRD Display not enabled for %d type\n",
+							platform_subtype);
+				return false;
+		}
 		break;
 	case HW_PLATFORM_MTP:
 		if (0 == platform_subtype)