mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 10:58:48 +09:00
drm/panel: simple: Add support for dcs backlight
Signed-off-by: Guochun Huang <hero.huang@rock-chips.com> Change-Id: Id9380a16c1db606f30032259a3bbba0884731c97
This commit is contained in:
@@ -728,6 +728,52 @@ static void panel_simple_parse_panel_timing_node(struct device *dev,
|
||||
dev_err(dev, "Reject override mode: No display_timing found\n");
|
||||
}
|
||||
|
||||
static int dcs_bl_update_status(struct backlight_device *bl)
|
||||
{
|
||||
struct panel_simple *p = bl_get_data(bl);
|
||||
struct mipi_dsi_device *dsi = p->dsi;
|
||||
int ret;
|
||||
|
||||
if (!p->prepared)
|
||||
return 0;
|
||||
|
||||
dsi->mode_flags &= ~MIPI_DSI_MODE_LPM;
|
||||
|
||||
ret = mipi_dsi_dcs_set_display_brightness(dsi, bl->props.brightness);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
dsi->mode_flags |= MIPI_DSI_MODE_LPM;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dcs_bl_get_brightness(struct backlight_device *bl)
|
||||
{
|
||||
struct panel_simple *p = bl_get_data(bl);
|
||||
struct mipi_dsi_device *dsi = p->dsi;
|
||||
u16 brightness = bl->props.brightness;
|
||||
int ret;
|
||||
|
||||
if (!p->prepared)
|
||||
return 0;
|
||||
|
||||
dsi->mode_flags &= ~MIPI_DSI_MODE_LPM;
|
||||
|
||||
ret = mipi_dsi_dcs_get_display_brightness(dsi, &brightness);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
dsi->mode_flags |= MIPI_DSI_MODE_LPM;
|
||||
|
||||
return brightness & 0xff;
|
||||
}
|
||||
|
||||
static const struct backlight_ops dcs_bl_ops = {
|
||||
.update_status = dcs_bl_update_status,
|
||||
.get_brightness = dcs_bl_get_brightness,
|
||||
};
|
||||
|
||||
static int panel_simple_probe(struct device *dev, const struct panel_desc *desc)
|
||||
{
|
||||
struct panel_simple *panel;
|
||||
@@ -4994,6 +5040,26 @@ static int panel_simple_dsi_probe(struct mipi_dsi_device *dsi)
|
||||
panel = dev_get_drvdata(dev);
|
||||
panel->dsi = dsi;
|
||||
|
||||
if (!panel->base.backlight) {
|
||||
struct backlight_properties props;
|
||||
|
||||
memset(&props, 0, sizeof(props));
|
||||
props.type = BACKLIGHT_RAW;
|
||||
props.brightness = 255;
|
||||
props.max_brightness = 255;
|
||||
|
||||
panel->base.backlight =
|
||||
devm_backlight_device_register(dev, "dcs-backlight",
|
||||
dev, panel, &dcs_bl_ops,
|
||||
&props);
|
||||
if (IS_ERR(panel->base.backlight)) {
|
||||
err = PTR_ERR(panel->base.backlight);
|
||||
dev_err(dev, "failed to register dcs backlight: %d\n",
|
||||
err);
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
dsi->mode_flags = desc->flags;
|
||||
dsi->format = desc->format;
|
||||
dsi->lanes = desc->lanes;
|
||||
|
||||
Reference in New Issue
Block a user