Merge "target: Update target backlight control API"
diff --git a/target/apq8084/target_display.c b/target/apq8084/target_display.c
index 54589dc..53e74b6 100644
--- a/target/apq8084/target_display.c
+++ b/target/apq8084/target_display.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2014, 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
@@ -86,7 +86,7 @@
return rc;
}
-int target_backlight_ctrl(uint8_t enable)
+int target_backlight_ctrl(struct backlight *bl, uint8_t enable)
{
struct pm8x41_gpio pwmgpio_param = {
.direction = PM_GPIO_DIR_OUT,
@@ -96,18 +96,19 @@
.output_buffer = PM_GPIO_OUT_CMOS,
.out_strength = 0x03,
};
+
if (enable) {
- pm8x41_gpio_config(7, &pwmgpio_param);
+ pm8x41_gpio_config(bl->bl_pwm_gpio_num, &pwmgpio_param);
/* lpg channel 2 */
- pm8x41_lpg_write(3, 0x41, 0x33); /* LPG_PWM_SIZE_CLK, */
- pm8x41_lpg_write(3, 0x42, 0x01); /* LPG_PWM_FREQ_PREDIV */
- pm8x41_lpg_write(3, 0x43, 0x20); /* LPG_PWM_TYPE_CONFIG */
- pm8x41_lpg_write(3, 0x44, 0xcc); /* LPG_VALUE_LSB */
- pm8x41_lpg_write(3, 0x45, 0x00); /* LPG_VALUE_MSB */
- pm8x41_lpg_write(3, 0x46, 0xe4); /* LPG_ENABLE_CONTROL */
+ pm8x41_lpg_write(bl->bl_lpg_chan_id, 0x41, 0x33); /* LPG_PWM_SIZE_CLK, */
+ pm8x41_lpg_write(bl->bl_lpg_chan_id, 0x42, 0x01); /* LPG_PWM_FREQ_PREDIV */
+ pm8x41_lpg_write(bl->bl_lpg_chan_id, 0x43, 0x20); /* LPG_PWM_TYPE_CONFIG */
+ pm8x41_lpg_write(bl->bl_lpg_chan_id, 0x44, 0xcc); /* LPG_VALUE_LSB */
+ pm8x41_lpg_write(bl->bl_lpg_chan_id, 0x45, 0x00); /* LPG_VALUE_MSB */
+ pm8x41_lpg_write(bl->bl_lpg_chan_id, 0x46, 0xe4); /* LPG_ENABLE_CONTROL */
} else {
- pm8x41_lpg_write(3, 0x46, 0x0); /* LPG_ENABLE_CONTROL */
+ pm8x41_lpg_write(bl->bl_lpg_chan_id, 0x46, 0x0); /* LPG_ENABLE_CONTROL */
}
return NO_ERROR;
diff --git a/target/msm8226/target_display.c b/target/msm8226/target_display.c
index 8ddfa89..c89c1ac 100755
--- a/target/msm8226/target_display.c
+++ b/target/msm8226/target_display.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2014, 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
@@ -198,10 +198,21 @@
return pll_locked;
}
-int target_backlight_ctrl(uint8_t enable)
+int target_backlight_ctrl(struct backlight *bl, uint8_t enable)
{
dprintf(SPEW, "target_backlight_ctrl\n");
+ if (!bl) {
+ dprintf(CRITICAL, "backlight structure is not available\n");
+ return ERR_INVALID_ARGS;
+ }
+
+ if (bl->bl_interface_type != BL_WLED) {
+ dprintf(CRITICAL, "backlight type:%d not supported\n",
+ bl->bl_interface_type);
+ return ERR_NOT_SUPPORTED;
+ }
+
if (enable) {
pm8x41_wled_config(&wled_ctrl);
pm8x41_wled_sink_control(enable);
diff --git a/target/msm8610/target_display.c b/target/msm8610/target_display.c
index e352c46..fde805a 100644
--- a/target/msm8610/target_display.c
+++ b/target/msm8610/target_display.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2014, 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
@@ -53,7 +53,7 @@
#define PWM_DUTY_US 13
#define PWM_PERIOD_US 27
-int target_backlight_ctrl(uint8_t enable)
+int target_backlight_ctrl(struct backlight *bl, uint8_t enable)
{
struct pm8x41_mpp mpp;
int rc;
diff --git a/target/msm8974/target_display.c b/target/msm8974/target_display.c
index ddee155..ffe3202 100644
--- a/target/msm8974/target_display.c
+++ b/target/msm8974/target_display.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2014, 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
@@ -94,7 +94,7 @@
return rc;
}
-int target_backlight_ctrl(uint8_t enable)
+static int msm8974_wled_backlight_ctrl(uint8_t enable)
{
uint32_t platform_id = board_platform_id();
uint32_t hardware_id = board_hardware_id();
@@ -117,6 +117,62 @@
return NO_ERROR;
}
+static int msm8974_pwm_backlight_ctrl(int gpio_num, int lpg_chan, int enable)
+{
+ struct pm8x41_gpio gpio_param = {
+ .direction = PM_GPIO_DIR_OUT,
+ .function = PM_GPIO_FUNC_2,
+ .vin_sel = 2, /* VIN_2 */
+ .pull = PM_GPIO_PULL_UP_1_5 | PM_GPIO_PULLDOWN_10,
+ .output_buffer = PM_GPIO_OUT_CMOS,
+ .out_strength = PM_GPIO_OUT_DRIVE_HIGH,
+ };
+
+ dprintf(SPEW, "%s: gpio=%d lpg=%d enable=%d\n", __func__,
+ gpio_num, lpg_chan, enable);
+
+ if (enable) {
+ pm8x41_gpio_config(gpio_num, &gpio_param);
+ pm8x41_lpg_write(lpg_chan, 0x41, 0x33); /* LPG_PWM_SIZE_CLK, */
+ pm8x41_lpg_write(lpg_chan, 0x42, 0x01); /* LPG_PWM_FREQ_PREDIV */
+ pm8x41_lpg_write(lpg_chan, 0x43, 0x20); /* LPG_PWM_TYPE_CONFIG */
+ pm8x41_lpg_write(lpg_chan, 0x44, 0xb2); /* LPG_VALUE_LSB */
+ pm8x41_lpg_write(lpg_chan, 0x45, 0x01); /* LPG_VALUE_MSB */
+ pm8x41_lpg_write(lpg_chan, 0x46, 0xe4); /* LPG_ENABLE_CONTROL */
+ } else {
+ pm8x41_lpg_write(lpg_chan, 0x46, 0x00);
+ }
+
+ return NO_ERROR;
+}
+
+int target_backlight_ctrl(struct backlight *bl, uint8_t enable)
+{
+ uint32_t ret = NO_ERROR;
+
+ if (!bl) {
+ dprintf(CRITICAL, "backlight structure is not available\n");
+ return ERR_INVALID_ARGS;
+ }
+
+ switch (bl->bl_interface_type) {
+ case BL_WLED:
+ ret = msm8974_wled_backlight_ctrl(enable);
+ break;
+ case BL_PWM:
+ ret = msm8974_pwm_backlight_ctrl(bl->bl_pwm_gpio_num,
+ bl->bl_lpg_chan_id,
+ enable);
+ break;
+ default:
+ dprintf(CRITICAL, "backlight type:%d not supported\n",
+ bl->bl_interface_type);
+ return ERR_NOT_SUPPORTED;
+ }
+
+ return ret;
+}
+
int target_panel_clock(uint8_t enable, struct msm_panel_info *pinfo)
{
struct mdss_dsi_pll_config *pll_data;
@@ -234,22 +290,6 @@
return 0;
}
-static void msm8974_lpg_backlight_enable(void)
-{
- /* lpg channel 8 */
- pm8x41_lpg_write(8, 0x41, 0x33); /* LPG_PWM_SIZE_CLK, */
- pm8x41_lpg_write(8, 0x42, 0x01); /* LPG_PWM_FREQ_PREDIV */
- pm8x41_lpg_write(8, 0x43, 0x20); /* LPG_PWM_TYPE_CONFIG */
- pm8x41_lpg_write(8, 0x44, 0xb2); /* LPG_VALUE_LSB */
- pm8x41_lpg_write(8, 0x45, 0x01); /* LPG_VALUE_MSB */
- pm8x41_lpg_write(8, 0x46, 0xe4); /* LPG_ENABLE_CONTROL */
-}
-
-static void msm8974_lpg_backlight_disable(void)
-{
- pm8x41_lpg_write(8, 0x46, 0x00); /* LPG_ENABLE_CONTROL */
-}
-
static int msm8974_edp_panel_power(int enable)
{
struct pm8x41_gpio gpio36_param = {
@@ -266,8 +306,7 @@
if (enable) {
/* Enable backlight */
dprintf(SPEW, "Enable Backlight\n");
- pm8x41_gpio_config(36, &gpio36_param);
- msm8974_lpg_backlight_enable();
+ msm8974_pwm_backlight_ctrl(36, 8, 1);
dprintf(SPEW, "Enable Backlight Done\n");
/* Turn on LDO12 for edp vdda */
@@ -285,7 +324,7 @@
} else {
/* Keep LDO12 on, otherwise kernel will not boot */
gpio_set(58, 0);
- msm8974_lpg_backlight_disable();
+ msm8974_pwm_backlight_ctrl(36, 8, 0);
}
return 0;