[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b49e2a94-695e-42ec-99de-aed42e62572d@linaro.org>
Date: Tue, 2 Sep 2025 09:34:09 +0200
From: Neil Armstrong <neil.armstrong@...aro.org>
To: Guido Günther <agx@...xcpu.org>,
Jessica Zhang <jessica.zhang@....qualcomm.com>,
Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Maxime Ripard <mripard@...nel.org>, Thomas Zimmermann <tzimmermann@...e.de>,
David Airlie <airlied@...il.com>, Simona Vetter <simona@...ll.ch>
Cc: dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org,
phone-devel@...r.kernel.org
Subject: Re: [PATCH 3/3] drm/panel: visionox-rm69299: Add backlight support
On 01/09/2025 16:22, Guido Günther wrote:
> The shift6mq's variant supports controlling the backlight via DSI
> commands. Use that if a max_brightness is set in the device specific
> data.
>
> Signed-off-by: Guido Günther <agx@...xcpu.org>
> ---
> drivers/gpu/drm/panel/panel-visionox-rm69299.c | 67 ++++++++++++++++++++++++++
> 1 file changed, 67 insertions(+)
>
> diff --git a/drivers/gpu/drm/panel/panel-visionox-rm69299.c b/drivers/gpu/drm/panel/panel-visionox-rm69299.c
> index 2216d38366ea37368d15480f9d8a8ccbfe77ba3b..5e5ff6056c80e67a5bf8fe4911cdbc588db5d03b 100644
> --- a/drivers/gpu/drm/panel/panel-visionox-rm69299.c
> +++ b/drivers/gpu/drm/panel/panel-visionox-rm69299.c
> @@ -3,6 +3,7 @@
> * Copyright (c) 2019, The Linux Foundation. All rights reserved.
> */
>
> +#include <linux/backlight.h>
> #include <linux/delay.h>
> #include <linux/module.h>
> #include <linux/property.h>
> @@ -20,6 +21,8 @@ struct visionox_rm69299_panel_desc {
> const struct drm_display_mode *mode;
> const u8 *init_seq;
> unsigned int init_seq_len;
> + int max_brightness;
> + int initial_brightness;
> };
>
> struct visionox_rm69299 {
> @@ -285,6 +288,63 @@ static const struct drm_panel_funcs visionox_rm69299_drm_funcs = {
> .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)
> {
> 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);
> }
>
> + 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);
>
> dsi->lanes = 4;
> @@ -353,6 +418,8 @@ const struct visionox_rm69299_panel_desc visionox_rm69299_shift_desc = {
> .mode = &visionox_rm69299_1080x2160_60hz,
> .init_seq = (const u8 *)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[] = {
>
Reviewed-by: Neil Armstrong <neil.armstrong@...aro.org>
Powered by blists - more mailing lists