Skip to content

Commit 35dfee5

Browse files
flar2DhineshCool
authored andcommitted
msm: dsi: add direct HBM
Go directly to HBM mode and add old sysfs path for compatibility with existing apps. This preserves the stock HBM implementation, which doesn't ramp up right away.
1 parent 1b52768 commit 35dfee5

1 file changed

Lines changed: 64 additions & 0 deletions

File tree

drivers/gpu/drm/msm/dsi-staging/dsi_backlight.c

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,63 @@
3333
#define BL_STATE_STANDBY BL_CORE_FBBLANK
3434
#define BL_STATE_LP BL_CORE_DRIVER1
3535
#define BL_STATE_LP2 BL_CORE_DRIVER2
36+
#define BL_HBM 1023
37+
38+
static int hbm_enable = 0;
39+
static struct dsi_backlight_config *bl_g;
40+
static struct device *fb0_device;
41+
42+
static void enable_hbm(int enable)
43+
{
44+
struct dsi_panel *panel = container_of(bl_g, struct dsi_panel, bl_config);
45+
struct hbm_data *hbm = bl_g->hbm;
46+
struct hbm_range *range = NULL;
47+
u32 target_range = enable ? bl_g->hbm->num_ranges - 1 : 0;
48+
range = hbm->ranges + target_range;
49+
50+
if(dsi_panel_cmd_set_transfer(panel, &range->dsi_cmd))
51+
pr_err("Failed to send command for range %d\n", enable);
52+
}
53+
54+
static ssize_t hbm_show(struct device *device, struct device_attribute *attr,
55+
char *buf)
56+
{
57+
return snprintf(buf, PAGE_SIZE, "%d\n", hbm_enable);
58+
}
59+
60+
static ssize_t hbm_store(struct device *device, struct device_attribute *attr,
61+
const char *buf, size_t count)
62+
{
63+
int ret, val;
64+
65+
ret = kstrtoint(buf, 0, &val);
66+
if (ret < 0)
67+
return ret;
68+
69+
if (val < 0 || val > 1)
70+
val = 0;
71+
72+
hbm_enable = val;
73+
enable_hbm(hbm_enable);
74+
backlight_update_status(bl_g->bl_device);
75+
76+
return count;
77+
}
78+
79+
static DEVICE_ATTR_RW(hbm);
80+
81+
static void fb0_init_device(struct dsi_backlight_config *bl)
82+
{
83+
bl_g = bl;
84+
fb0_device = device_create(fb_class, NULL, MKDEV(0, 0), NULL, "fb0");
85+
if (IS_ERR(fb0_device)) {
86+
fb0_device = NULL;
87+
return;
88+
}
89+
90+
if (device_create_file(fb0_device, &dev_attr_hbm))
91+
pr_warn("unable to create hbm node\n");
92+
}
3693

3794
struct dsi_backlight_pwm_config {
3895
bool pwm_pmi_control;
@@ -385,6 +442,10 @@ static u32 dsi_backlight_calculate(struct dsi_backlight_config *bl,
385442
bl_temp = mult_frac(bl_temp, bl->bl_scale_ad,
386443
MAX_AD_BL_SCALE_LEVEL);
387444

445+
if (hbm_enable) {
446+
return BL_HBM;
447+
}
448+
388449
if (panel->hbm_mode)
389450
bl_lvl = dsi_backlight_calculate_hbm(bl, bl_temp);
390451
else
@@ -711,6 +772,9 @@ static int dsi_backlight_register(struct dsi_backlight_config *bl)
711772
if (sysfs_create_groups(&bl->bl_device->dev.kobj, bl_device_groups))
712773
pr_warn("unable to create device groups\n");
713774

775+
//make dummy fb0 device so we have the old standard hbm sysfs path
776+
fb0_init_device(bl);
777+
714778
reg = regulator_get(panel->parent, "lab");
715779
if (!PTR_ERR_OR_ZERO(reg)) {
716780
pr_info("LAB regulator found\n");

0 commit comments

Comments
 (0)