mirror of
https://github.com/torvalds/linux.git
synced 2026-06-04 12:35:52 +02:00
drm/panel: visionox-rm69299: Add backlight support
The shift6mq's variant supports controlling the backlight via DSI commands. Use that if a max_brightness is set in the device specific data. Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org> Signed-off-by: Guido Günther <agx@sigxcpu.org> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com> Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org> Link: https://lore.kernel.org/r/20250910-shift6mq-panel-v3-3-a7729911afb9@sigxcpu.org
This commit is contained in:
parent
39144b611e
commit
7911d8cab5
|
|
@ -3,6 +3,7 @@
|
||||||
* Copyright (c) 2019, The Linux Foundation. All rights reserved.
|
* Copyright (c) 2019, The Linux Foundation. All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <linux/backlight.h>
|
||||||
#include <linux/delay.h>
|
#include <linux/delay.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/property.h>
|
#include <linux/property.h>
|
||||||
|
|
@ -20,6 +21,8 @@ struct visionox_rm69299_panel_desc {
|
||||||
const struct drm_display_mode *mode;
|
const struct drm_display_mode *mode;
|
||||||
const u8 *init_seq;
|
const u8 *init_seq;
|
||||||
unsigned int init_seq_len;
|
unsigned int init_seq_len;
|
||||||
|
int max_brightness;
|
||||||
|
int initial_brightness;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct visionox_rm69299 {
|
struct visionox_rm69299 {
|
||||||
|
|
@ -285,6 +288,63 @@ static const struct drm_panel_funcs visionox_rm69299_drm_funcs = {
|
||||||
.get_modes = visionox_rm69299_get_modes,
|
.get_modes = visionox_rm69299_get_modes,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static int visionox_rm69299_bl_get_brightness(struct backlight_device *bl)
|
||||||
|
{
|
||||||
|
struct mipi_dsi_device *dsi = bl_get_data(bl);
|
||||||
|
u16 brightness;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int visionox_rm69299_bl_update_status(struct backlight_device *bl)
|
||||||
|
{
|
||||||
|
struct mipi_dsi_device *dsi = bl_get_data(bl);
|
||||||
|
u16 brightness = backlight_get_brightness(bl);
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
dsi->mode_flags &= ~MIPI_DSI_MODE_LPM;
|
||||||
|
|
||||||
|
ret = mipi_dsi_dcs_set_display_brightness(dsi, brightness);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
dsi->mode_flags |= MIPI_DSI_MODE_LPM;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct backlight_ops visionox_rm69299_bl_ops = {
|
||||||
|
.update_status = visionox_rm69299_bl_update_status,
|
||||||
|
.get_brightness = visionox_rm69299_bl_get_brightness,
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct backlight_device *
|
||||||
|
visionox_rm69299_create_backlight(struct visionox_rm69299 *ctx)
|
||||||
|
{
|
||||||
|
struct device *dev = &ctx->dsi->dev;
|
||||||
|
const struct backlight_properties props = {
|
||||||
|
.type = BACKLIGHT_RAW,
|
||||||
|
.brightness = ctx->desc->initial_brightness,
|
||||||
|
.max_brightness = ctx->desc->max_brightness,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!ctx->desc->max_brightness)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return devm_backlight_device_register(dev, dev_name(dev), dev, ctx->dsi,
|
||||||
|
&visionox_rm69299_bl_ops,
|
||||||
|
&props);
|
||||||
|
}
|
||||||
|
|
||||||
static int visionox_rm69299_probe(struct mipi_dsi_device *dsi)
|
static int visionox_rm69299_probe(struct mipi_dsi_device *dsi)
|
||||||
{
|
{
|
||||||
struct device *dev = &dsi->dev;
|
struct device *dev = &dsi->dev;
|
||||||
|
|
@ -316,6 +376,11 @@ static int visionox_rm69299_probe(struct mipi_dsi_device *dsi)
|
||||||
return PTR_ERR(ctx->reset_gpio);
|
return PTR_ERR(ctx->reset_gpio);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ctx->panel.backlight = visionox_rm69299_create_backlight(ctx);
|
||||||
|
if (IS_ERR(ctx->panel.backlight))
|
||||||
|
return dev_err_probe(dev, PTR_ERR(ctx->panel.backlight),
|
||||||
|
"Failed to create backlight\n");
|
||||||
|
|
||||||
drm_panel_add(&ctx->panel);
|
drm_panel_add(&ctx->panel);
|
||||||
|
|
||||||
dsi->lanes = 4;
|
dsi->lanes = 4;
|
||||||
|
|
@ -353,6 +418,8 @@ const struct visionox_rm69299_panel_desc visionox_rm69299_shift_desc = {
|
||||||
.mode = &visionox_rm69299_1080x2160_60hz,
|
.mode = &visionox_rm69299_1080x2160_60hz,
|
||||||
.init_seq = (const u8 *)visionox_rm69299_1080x2160_60hz_init_seq,
|
.init_seq = (const u8 *)visionox_rm69299_1080x2160_60hz_init_seq,
|
||||||
.init_seq_len = ARRAY_SIZE(visionox_rm69299_1080x2160_60hz_init_seq),
|
.init_seq_len = ARRAY_SIZE(visionox_rm69299_1080x2160_60hz_init_seq),
|
||||||
|
.max_brightness = 255,
|
||||||
|
.initial_brightness = 50,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct of_device_id visionox_rm69299_of_match[] = {
|
static const struct of_device_id visionox_rm69299_of_match[] = {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user