Merge "target: msm8953: enable display for SDM632 EVT2"
diff --git a/dev/gcdb/display/include/panel_auo_390p_cmd.h b/dev/gcdb/display/include/panel_auo_390p_cmd.h
index d886cb2..5c8a860 100644
--- a/dev/gcdb/display/include/panel_auo_390p_cmd.h
+++ b/dev/gcdb/display/include/panel_auo_390p_cmd.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2017-2018, 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
@@ -140,6 +140,21 @@
 	0x52, 0x08, 0x01, 0xff,
 };
 
+static char auo_390p_cmd_on_cmd14[] = {
+	0xfe, 0x01, 0x15, 0x80,
+};
+
+static char auo_390p_cmd_on_cmd15[] = {
+	0x04, 0x00, 0x15, 0x80,
+};
+
+static char auo_390p_cmd_on_cmd16[] = {
+	0xfe, 0x00, 0x15, 0x80,
+};
+
+static char auo_390p_cmd_on_cmd17[] = {
+	0x3a, 0x77, 0x15, 0x80,
+};
 
 static struct mipi_dsi_cmd auo_390p_cmd_on_command[] = {
 	{ 0x4 , auo_390p_cmd_on_cmd0, 0x00},
@@ -156,9 +171,13 @@
 	{ 0x4 , auo_390p_cmd_on_cmd11, 0x00},
 	{ 0xc , auo_390p_cmd_on_cmd12, 0x00},
 	{ 0xc , auo_390p_cmd_on_cmd13, 0x00},
+	{ 0x4 , auo_390p_cmd_on_cmd14, 0x00},
+	{ 0x4 , auo_390p_cmd_on_cmd15, 0x00},
+	{ 0x4 , auo_390p_cmd_on_cmd16, 0x00},
+	{ 0x4 , auo_390p_cmd_on_cmd17, 0x00},
 };
 
-#define AUO_390P_CMD_ON_COMMAND 14
+#define AUO_390P_CMD_ON_COMMAND 18
 
 
 static char auo_390p_cmd_off_cmd0[] = {
diff --git a/platform/msm_shared/avb/VerifiedBoot.c b/platform/msm_shared/avb/VerifiedBoot.c
index a23e15d..df10f35 100644
--- a/platform/msm_shared/avb/VerifiedBoot.c
+++ b/platform/msm_shared/avb/VerifiedBoot.c
@@ -115,7 +115,7 @@
 	if (!partition_multislot_is_supported())
 		return ERR_INVALID_ARGS;
 
-	strncpy(CurrentSlot->Suffix,
+	strlcpy(CurrentSlot->Suffix,
 			SUFFIX_SLOT(partition_find_active_slot()),
 			MAX_SLOT_SUFFIX_SZ);
 	return 0;
@@ -137,7 +137,7 @@
 	int idx = partition_find_active_slot();
 	if (idx != INVALID)
 	{
-		strncpy(ActiveSlot->Suffix,
+		strlcpy(ActiveSlot->Suffix,
 			SUFFIX_SLOT(partition_find_active_slot()),
 			MAX_SLOT_SUFFIX_SZ);
 		return 0;
@@ -205,8 +205,8 @@
 		return 0;
 	}
 
-	strncpy(PartitionName, "system", strlen("system") + 1);
-	strncat(PartitionName, CurSlot.Suffix, MAX_GPT_NAME_SIZE - 1);
+	strlcpy(PartitionName, "system", strlen("system") + 1);
+	strlcat(PartitionName, CurSlot.Suffix, MAX_GPT_NAME_SIZE - 1);
 
 	Index = partition_get_index(PartitionName);
 	if (Index == INVALID_PTN || Index >= NUM_PARTITIONS) {
@@ -304,7 +304,7 @@
 	}
 	Info->num_loaded_images = 1;
 	Info->images[0].name = malloc(strlen(Info->pname) + 1);
-	strncpy(Info->images[0].name, Info->pname, strlen(Info->pname)); //FIXME
+	strlcpy(Info->images[0].name, Info->pname, strlen(Info->pname)); //FIXME
 	return Status;
 }
 
@@ -325,13 +325,13 @@
 	DevInfo_vb.is_unlocked = !is_device_locked();
 	DevInfo_vb.is_unlock_critical = !is_device_locked_critical();
 
-	strncpy(StrPname, "/", strlen("/"));
-	strncpy(Pname, Info->pname, strlen(Info->pname));
+	strlcpy(StrPname, "/", strlen("/"));
+	strlcpy(Pname, Info->pname, strlen(Info->pname));
 	if (Info->multi_slot_boot) {
-		strncat(StrPname, Pname,
+		strlcat(StrPname, Pname,
 	              strlen(Pname) - (MAX_SLOT_SUFFIX_SZ - 1));
 	} else {
-		strncat(StrPname, Pname, strlen(Pname));
+		strlcat(StrPname, Pname, strlen(Pname));
 	}
 
 	Status = boot_verify_image((UINT8 *)Info->images[0].image_buffer,
@@ -433,7 +433,7 @@
 		goto out;
 	}
 	if(Info->multi_slot_boot) {
-	strncpy(Pname, Info->pname, strlen(Info->pname));
+	strlcpy(Pname, Info->pname, strlen(Info->pname));
 	if ((MAX_SLOT_SUFFIX_SZ + 1) > strlen(Pname)) {
 		dprintf(CRITICAL, "ERROR: Can not determine slot suffix\n");
 		Status = EFI_INVALID_PARAMETER;
@@ -681,10 +681,10 @@
 	if (!Info->multi_slot_boot) {
 		if (Info->bootinto_recovery) {
 			dprintf(INFO, "Booting Into Recovery Mode\n");
-			strncpy(Info->pname, "recovery", strlen("recovery"));
+			strlcpy(Info->pname, "recovery", strlen("recovery"));
 		} else {
 			dprintf(INFO, "Booting Into Mission Mode\n");
-			strncpy(Info->pname, "boot", strlen("boot"));
+			strlcpy(Info->pname, "boot", strlen("boot"));
 		}
 	} else {
 		Slot CurrentSlot = {{0}};
@@ -694,8 +694,8 @@
 			dprintf(CRITICAL, "No bootable slot\n");
 			return EFI_LOAD_ERROR;
 		}
-		strncpy(Info->pname, "boot", strlen("boot"));
-		strncat(Info->pname, CurrentSlot.Suffix, strlen(CurrentSlot.Suffix));
+		strlcpy(Info->pname, "boot", strlen("boot"));
+		strlcat(Info->pname, CurrentSlot.Suffix, strlen(CurrentSlot.Suffix));
 	}
 
 	dprintf(DEBUG, "MultiSlot %s, partition name %s\n",
diff --git a/project/msm8952.mk b/project/msm8952.mk
index d40dfa1..7bfc1b5 100644
--- a/project/msm8952.mk
+++ b/project/msm8952.mk
@@ -34,7 +34,7 @@
 
 
 ENABLE_SMD_SUPPORT := 1
-#ENABLE_PWM_SUPPORT := true
+ENABLE_PWM_SUPPORT := true
 
 #DEFINES += WITH_DEBUG_DCC=1
 DEFINES += WITH_DEBUG_LOG_BUF=1
diff --git a/target/msm8952/target_display.c b/target/msm8952/target_display.c
index 65d8222..68baa70 100644
--- a/target/msm8952/target_display.c
+++ b/target/msm8952/target_display.c
@@ -53,6 +53,9 @@
 #include "include/display_resource.h"
 #include "gcdb_display.h"
 
+#define PWM_DUTY_US 13
+#define PWM_PERIOD_US 27
+
 #define TRULY_720P_VID_PANEL "truly_720p_video"
 #define TRULY_720P_CMD_PANEL "truly_720p_cmd"
 
@@ -276,6 +279,19 @@
 	return NO_ERROR;
 }
 
+static int pwm_backlight_ctrl(uint8_t enable)
+{
+	if (enable) {
+		pm_pwm_enable(false);
+		pm_pwm_config(PWM_DUTY_US, PWM_PERIOD_US);
+		pm_pwm_enable(true);
+	} else {
+		pm_pwm_enable(false);
+	}
+
+	return NO_ERROR;
+}
+
 int target_backlight_ctrl(struct backlight *bl, uint8_t enable)
 {
 	uint32_t ret = NO_ERROR;
@@ -283,8 +299,12 @@
 	if (bl->bl_interface_type == BL_DCS)
 		return ret;
 
-	ret = msm8952_wled_backlight_ctrl(enable);
-
+	if ((target_get_pmic() == PMIC_IS_PMI632) &&
+		(bl->bl_interface_type == BL_PWM)) {
+		ret = pwm_backlight_ctrl(enable);
+	} else {
+		ret = msm8952_wled_backlight_ctrl(enable);
+	}
 	return ret;
 }