|
33 | 33 | #define BL_STATE_STANDBY BL_CORE_FBBLANK |
34 | 34 | #define BL_STATE_LP BL_CORE_DRIVER1 |
35 | 35 | #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 | +} |
36 | 93 |
|
37 | 94 | struct dsi_backlight_pwm_config { |
38 | 95 | bool pwm_pmi_control; |
@@ -385,6 +442,10 @@ static u32 dsi_backlight_calculate(struct dsi_backlight_config *bl, |
385 | 442 | bl_temp = mult_frac(bl_temp, bl->bl_scale_ad, |
386 | 443 | MAX_AD_BL_SCALE_LEVEL); |
387 | 444 |
|
| 445 | + if (hbm_enable) { |
| 446 | + return BL_HBM; |
| 447 | + } |
| 448 | + |
388 | 449 | if (panel->hbm_mode) |
389 | 450 | bl_lvl = dsi_backlight_calculate_hbm(bl, bl_temp); |
390 | 451 | else |
@@ -711,6 +772,9 @@ static int dsi_backlight_register(struct dsi_backlight_config *bl) |
711 | 772 | if (sysfs_create_groups(&bl->bl_device->dev.kobj, bl_device_groups)) |
712 | 773 | pr_warn("unable to create device groups\n"); |
713 | 774 |
|
| 775 | + //make dummy fb0 device so we have the old standard hbm sysfs path |
| 776 | + fb0_init_device(bl); |
| 777 | + |
714 | 778 | reg = regulator_get(panel->parent, "lab"); |
715 | 779 | if (!PTR_ERR_OR_ZERO(reg)) { |
716 | 780 | pr_info("LAB regulator found\n"); |
|
0 commit comments