disp: msm: dsi: snapshot of dsi from 4.14 to 4.19
This change is a snapshot of dsi files taken of 4.14 as of commit 764f7c2 (Merge remote-tracking branch 'quic/dev/msm-4.14-display' into msm-4.14) Change-Id: I8361a844c35a4450f7800964a8da2741676fd6c7 Signed-off-by: Satya Rama Aditya Pinapala <psraditya30@codeaurora.org>
This commit is contained in:

committed by
Gerrit - the friendly Code Review server

parent
91f4bcda9d
commit
edef6ae040
@@ -8,6 +8,7 @@
|
||||
#include <linux/slab.h>
|
||||
#include <linux/gpio.h>
|
||||
#include <linux/of_gpio.h>
|
||||
#include <linux/pwm.h>
|
||||
#include <video/mipi_display.h>
|
||||
|
||||
#include "dsi_panel.h"
|
||||
@@ -587,17 +588,16 @@ error:
|
||||
static int dsi_panel_wled_register(struct dsi_panel *panel,
|
||||
struct dsi_backlight_config *bl)
|
||||
{
|
||||
int rc = 0;
|
||||
struct backlight_device *bd;
|
||||
|
||||
bd = backlight_device_get_by_type(BACKLIGHT_RAW);
|
||||
if (!bd) {
|
||||
pr_err("[%s] fail raw backlight register\n", panel->name);
|
||||
rc = -EINVAL;
|
||||
return -EPROBE_DEFER;
|
||||
}
|
||||
|
||||
bl->raw_bd = bd;
|
||||
return rc;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dsi_panel_update_backlight(struct dsi_panel *panel,
|
||||
@@ -620,6 +620,57 @@ static int dsi_panel_update_backlight(struct dsi_panel *panel,
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int dsi_panel_update_pwm_backlight(struct dsi_panel *panel,
|
||||
u32 bl_lvl)
|
||||
{
|
||||
int rc = 0;
|
||||
u32 duty = 0;
|
||||
u32 period_ns = 0;
|
||||
struct dsi_backlight_config *bl;
|
||||
|
||||
if (!panel) {
|
||||
pr_err("Invalid Params\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
bl = &panel->bl_config;
|
||||
if (!bl->pwm_bl) {
|
||||
pr_err("pwm device not found\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
period_ns = bl->pwm_period_usecs * NSEC_PER_USEC;
|
||||
duty = bl_lvl * period_ns;
|
||||
duty /= bl->bl_max_level;
|
||||
|
||||
rc = pwm_config(bl->pwm_bl, duty, period_ns);
|
||||
if (rc) {
|
||||
pr_err("[%s] failed to change pwm config, rc=\n", panel->name,
|
||||
rc);
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (bl_lvl == 0 && bl->pwm_enabled) {
|
||||
pwm_disable(bl->pwm_bl);
|
||||
bl->pwm_enabled = false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!bl->pwm_enabled) {
|
||||
rc = pwm_enable(bl->pwm_bl);
|
||||
if (rc) {
|
||||
pr_err("[%s] failed to enable pwm, rc=\n", panel->name,
|
||||
rc);
|
||||
goto error;
|
||||
}
|
||||
|
||||
bl->pwm_enabled = true;
|
||||
}
|
||||
|
||||
error:
|
||||
return rc;
|
||||
}
|
||||
|
||||
int dsi_panel_set_backlight(struct dsi_panel *panel, u32 bl_lvl)
|
||||
{
|
||||
int rc = 0;
|
||||
@@ -638,6 +689,9 @@ int dsi_panel_set_backlight(struct dsi_panel *panel, u32 bl_lvl)
|
||||
break;
|
||||
case DSI_BACKLIGHT_EXTERNAL:
|
||||
break;
|
||||
case DSI_BACKLIGHT_PWM:
|
||||
rc = dsi_panel_update_pwm_backlight(panel, bl_lvl);
|
||||
break;
|
||||
default:
|
||||
pr_err("Backlight type(%d) not supported\n", bl->type);
|
||||
rc = -ENOTSUPP;
|
||||
@@ -662,6 +716,7 @@ static u32 dsi_panel_get_brightness(struct dsi_backlight_config *bl)
|
||||
break;
|
||||
case DSI_BACKLIGHT_DCS:
|
||||
case DSI_BACKLIGHT_EXTERNAL:
|
||||
case DSI_BACKLIGHT_PWM:
|
||||
default:
|
||||
/*
|
||||
* Ideally, we should read the backlight level from the
|
||||
@@ -681,6 +736,22 @@ void dsi_panel_bl_handoff(struct dsi_panel *panel)
|
||||
bl->bl_level = dsi_panel_get_brightness(bl);
|
||||
}
|
||||
|
||||
static int dsi_panel_pwm_register(struct dsi_panel *panel)
|
||||
{
|
||||
int rc = 0;
|
||||
struct dsi_backlight_config *bl = &panel->bl_config;
|
||||
|
||||
bl->pwm_bl = devm_of_pwm_get(panel->parent, panel->panel_of_node, NULL);
|
||||
if (IS_ERR_OR_NULL(bl->pwm_bl)) {
|
||||
rc = PTR_ERR(bl->pwm_bl);
|
||||
pr_err("[%s] failed to request pwm, rc=%d\n", panel->name,
|
||||
rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dsi_panel_bl_register(struct dsi_panel *panel)
|
||||
{
|
||||
int rc = 0;
|
||||
@@ -697,6 +768,9 @@ static int dsi_panel_bl_register(struct dsi_panel *panel)
|
||||
break;
|
||||
case DSI_BACKLIGHT_EXTERNAL:
|
||||
break;
|
||||
case DSI_BACKLIGHT_PWM:
|
||||
rc = dsi_panel_pwm_register(panel);
|
||||
break;
|
||||
default:
|
||||
pr_err("Backlight type(%d) not supported\n", bl->type);
|
||||
rc = -ENOTSUPP;
|
||||
@@ -707,6 +781,13 @@ error:
|
||||
return rc;
|
||||
}
|
||||
|
||||
static void dsi_panel_pwm_unregister(struct dsi_panel *panel)
|
||||
{
|
||||
struct dsi_backlight_config *bl = &panel->bl_config;
|
||||
|
||||
devm_pwm_put(panel->parent, bl->pwm_bl);
|
||||
}
|
||||
|
||||
static int dsi_panel_bl_unregister(struct dsi_panel *panel)
|
||||
{
|
||||
int rc = 0;
|
||||
@@ -722,6 +803,9 @@ static int dsi_panel_bl_unregister(struct dsi_panel *panel)
|
||||
break;
|
||||
case DSI_BACKLIGHT_EXTERNAL:
|
||||
break;
|
||||
case DSI_BACKLIGHT_PWM:
|
||||
dsi_panel_pwm_unregister(panel);
|
||||
break;
|
||||
default:
|
||||
pr_err("Backlight type(%d) not supported\n", bl->type);
|
||||
rc = -ENOTSUPP;
|
||||
@@ -1085,6 +1169,44 @@ static int dsi_panel_parse_misc_host_config(struct dsi_host_common_cfg *host,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void dsi_panel_parse_split_link_config(struct dsi_host_common_cfg *host,
|
||||
struct dsi_parser_utils *utils,
|
||||
const char *name)
|
||||
{
|
||||
int rc = 0;
|
||||
u32 val = 0;
|
||||
bool supported = false;
|
||||
struct dsi_split_link_config *split_link = &host->split_link;
|
||||
|
||||
supported = utils->read_bool(utils->data, "qcom,split-link-enabled");
|
||||
|
||||
if (!supported) {
|
||||
pr_debug("[%s] Split link is not supported\n", name);
|
||||
split_link->split_link_enabled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
rc = utils->read_u32(utils->data, "qcom,sublinks-count", &val);
|
||||
if (rc || val < 1) {
|
||||
pr_debug("[%s] Using default sublinks count\n", name);
|
||||
split_link->num_sublinks = 2;
|
||||
} else {
|
||||
split_link->num_sublinks = val;
|
||||
}
|
||||
|
||||
rc = utils->read_u32(utils->data, "qcom,lanes-per-sublink", &val);
|
||||
if (rc || val < 1) {
|
||||
pr_debug("[%s] Using default lanes per sublink\n", name);
|
||||
split_link->lanes_per_sublink = 2;
|
||||
} else {
|
||||
split_link->lanes_per_sublink = val;
|
||||
}
|
||||
|
||||
pr_debug("[%s] Split link is supported %d-%d\n", name,
|
||||
split_link->num_sublinks, split_link->lanes_per_sublink);
|
||||
split_link->split_link_enabled = true;
|
||||
}
|
||||
|
||||
static int dsi_panel_parse_host_config(struct dsi_panel *panel)
|
||||
{
|
||||
int rc = 0;
|
||||
@@ -1130,6 +1252,9 @@ static int dsi_panel_parse_host_config(struct dsi_panel *panel)
|
||||
goto error;
|
||||
}
|
||||
|
||||
dsi_panel_parse_split_link_config(&panel->host_config, utils,
|
||||
panel->name);
|
||||
|
||||
error:
|
||||
return rc;
|
||||
}
|
||||
@@ -2021,34 +2146,14 @@ static int dsi_panel_parse_bl_pwm_config(struct dsi_panel *panel)
|
||||
struct dsi_backlight_config *config = &panel->bl_config;
|
||||
struct dsi_parser_utils *utils = &panel->utils;
|
||||
|
||||
rc = utils->read_u32(utils->data, "qcom,dsi-bl-pmic-bank-select",
|
||||
rc = utils->read_u32(utils->data, "qcom,bl-pmic-pwm-period-usecs",
|
||||
&val);
|
||||
if (rc) {
|
||||
pr_err("bl-pmic-bank-select is not defined, rc=%d\n", rc);
|
||||
goto error;
|
||||
}
|
||||
config->pwm_pmic_bank = val;
|
||||
|
||||
rc = utils->read_u32(utils->data, "qcom,dsi-bl-pmic-pwm-frequency",
|
||||
&val);
|
||||
if (rc) {
|
||||
pr_err("bl-pmic-bank-select is not defined, rc=%d\n", rc);
|
||||
pr_err("bl-pmic-pwm-period-usecs is not defined, rc=%d\n", rc);
|
||||
goto error;
|
||||
}
|
||||
config->pwm_period_usecs = val;
|
||||
|
||||
config->pwm_pmi_control = utils->read_bool(utils->data,
|
||||
"qcom,mdss-dsi-bl-pwm-pmi");
|
||||
|
||||
config->pwm_gpio = utils->get_named_gpio(utils->data,
|
||||
"qcom,mdss-dsi-pwm-gpio",
|
||||
0);
|
||||
if (!gpio_is_valid(config->pwm_gpio)) {
|
||||
pr_err("pwm gpio is invalid\n");
|
||||
rc = -EINVAL;
|
||||
goto error;
|
||||
}
|
||||
|
||||
error:
|
||||
return rc;
|
||||
}
|
||||
@@ -2139,9 +2244,17 @@ static int dsi_panel_parse_bl_config(struct dsi_panel *panel)
|
||||
"qcom,platform-bklight-en-gpio",
|
||||
0);
|
||||
if (!gpio_is_valid(panel->bl_config.en_gpio)) {
|
||||
pr_debug("[%s] failed get bklt gpio, rc=%d\n", panel->name, rc);
|
||||
rc = 0;
|
||||
goto error;
|
||||
if (panel->bl_config.en_gpio == -EPROBE_DEFER) {
|
||||
pr_debug("[%s] failed to get bklt gpio, rc=%d\n",
|
||||
panel->name, rc);
|
||||
rc = -EPROBE_DEFER;
|
||||
goto error;
|
||||
} else {
|
||||
pr_debug("[%s] failed to get bklt gpio, rc=%d\n",
|
||||
panel->name, rc);
|
||||
rc = 0;
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
error:
|
||||
@@ -2341,12 +2454,16 @@ int dsi_dsc_populate_static_param(struct msm_display_dsc_info *dsc)
|
||||
|
||||
|
||||
static int dsi_panel_parse_phy_timing(struct dsi_display_mode *mode,
|
||||
struct dsi_parser_utils *utils)
|
||||
struct dsi_parser_utils *utils)
|
||||
{
|
||||
const char *data;
|
||||
u32 len, i;
|
||||
int rc = 0;
|
||||
struct dsi_display_mode_priv_info *priv_info;
|
||||
struct dsi_mode_info *timing = NULL;
|
||||
|
||||
if (!mode || !mode->priv_info)
|
||||
return -EINVAL;
|
||||
|
||||
priv_info = mode->priv_info;
|
||||
|
||||
@@ -2366,9 +2483,11 @@ static int dsi_panel_parse_phy_timing(struct dsi_display_mode *mode,
|
||||
priv_info->phy_timing_len = len;
|
||||
}
|
||||
|
||||
mode->pixel_clk_khz = (DSI_H_TOTAL_DSC(&mode->timing) *
|
||||
DSI_V_TOTAL(&mode->timing) *
|
||||
mode->timing.refresh_rate) / 1000;
|
||||
timing = &mode->timing;
|
||||
|
||||
mode->pixel_clk_khz = (DSI_H_TOTAL(&mode->timing) *
|
||||
DSI_V_TOTAL(&mode->timing) *
|
||||
mode->timing.refresh_rate) / 1000;
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -3111,9 +3230,11 @@ struct dsi_panel *dsi_panel_get(struct device *parent,
|
||||
pr_err("failed to parse power config, rc=%d\n", rc);
|
||||
|
||||
rc = dsi_panel_parse_bl_config(panel);
|
||||
if (rc)
|
||||
if (rc) {
|
||||
pr_err("failed to parse backlight config, rc=%d\n", rc);
|
||||
|
||||
if (rc == -EPROBE_DEFER)
|
||||
goto error;
|
||||
}
|
||||
|
||||
rc = dsi_panel_parse_misc_features(panel);
|
||||
if (rc)
|
||||
@@ -3637,10 +3758,14 @@ int dsi_panel_set_lp1(struct dsi_panel *panel)
|
||||
}
|
||||
|
||||
mutex_lock(&panel->panel_lock);
|
||||
if (!panel->panel_initialized)
|
||||
goto exit;
|
||||
|
||||
rc = dsi_panel_tx_cmd_set(panel, DSI_CMD_SET_LP1);
|
||||
if (rc)
|
||||
pr_err("[%s] failed to send DSI_CMD_SET_LP1 cmd, rc=%d\n",
|
||||
panel->name, rc);
|
||||
exit:
|
||||
mutex_unlock(&panel->panel_lock);
|
||||
return rc;
|
||||
}
|
||||
@@ -3655,10 +3780,14 @@ int dsi_panel_set_lp2(struct dsi_panel *panel)
|
||||
}
|
||||
|
||||
mutex_lock(&panel->panel_lock);
|
||||
if (!panel->panel_initialized)
|
||||
goto exit;
|
||||
|
||||
rc = dsi_panel_tx_cmd_set(panel, DSI_CMD_SET_LP2);
|
||||
if (rc)
|
||||
pr_err("[%s] failed to send DSI_CMD_SET_LP2 cmd, rc=%d\n",
|
||||
panel->name, rc);
|
||||
exit:
|
||||
mutex_unlock(&panel->panel_lock);
|
||||
return rc;
|
||||
}
|
||||
@@ -3673,10 +3802,14 @@ int dsi_panel_set_nolp(struct dsi_panel *panel)
|
||||
}
|
||||
|
||||
mutex_lock(&panel->panel_lock);
|
||||
if (!panel->panel_initialized)
|
||||
goto exit;
|
||||
|
||||
rc = dsi_panel_tx_cmd_set(panel, DSI_CMD_SET_NOLP);
|
||||
if (rc)
|
||||
pr_err("[%s] failed to send DSI_CMD_SET_NOLP cmd, rc=%d\n",
|
||||
panel->name, rc);
|
||||
exit:
|
||||
mutex_unlock(&panel->panel_lock);
|
||||
return rc;
|
||||
}
|
||||
@@ -3868,6 +4001,7 @@ int dsi_panel_send_roi_dcs(struct dsi_panel *panel, int ctrl_idx,
|
||||
mutex_unlock(&panel->panel_lock);
|
||||
|
||||
dsi_panel_destroy_cmd_packets(set);
|
||||
dsi_panel_dealloc_cmd_packets(set);
|
||||
|
||||
return rc;
|
||||
}
|
||||
@@ -4004,11 +4138,11 @@ int dsi_panel_enable(struct dsi_panel *panel)
|
||||
mutex_lock(&panel->panel_lock);
|
||||
|
||||
rc = dsi_panel_tx_cmd_set(panel, DSI_CMD_SET_ON);
|
||||
if (rc) {
|
||||
if (rc)
|
||||
pr_err("[%s] failed to send DSI_CMD_SET_ON cmds, rc=%d\n",
|
||||
panel->name, rc);
|
||||
}
|
||||
panel->panel_initialized = true;
|
||||
else
|
||||
panel->panel_initialized = true;
|
||||
mutex_unlock(&panel->panel_lock);
|
||||
return rc;
|
||||
}
|
||||
|
Reference in New Issue
Block a user