mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Neil Armstrong <neil.armstrong@linaro.org>
To: Val Packett <val@packett.cool>,
	Jessica Zhang <jesszhan0024@gmail.com>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>
Cc: dri-devel@lists.freedesktop.org, phone-devel@vger.kernel.org,
	~postmarketos/upstreaming@lists.sr.ht,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 4/4] drm/panel: himax-hx83102: Add support for DSI DCS backlight control
Date: Wed, 4 Mar 2026 17:27:41 +0100	[thread overview]
Message-ID: <b2ce76f4-bb19-4e4c-a5bb-c3000f8a9827@linaro.org> (raw)
In-Reply-To: <20260217070121.190108-5-val@packett.cool>

On 2/17/26 08:00, Val Packett wrote:
> The HTF065H045 panel based on the HX83102 controller does use DCS
> commands for controlling backlight brightness. Make the driver fall back
> to DCS when no external backlight has been defined in the device tree,
> like many other drivers do.
> 
> Signed-off-by: Val Packett <val@packett.cool>
> ---
>   drivers/gpu/drm/panel/panel-himax-hx83102.c | 65 +++++++++++++++++++++
>   1 file changed, 65 insertions(+)
> 
> diff --git a/drivers/gpu/drm/panel/panel-himax-hx83102.c b/drivers/gpu/drm/panel/panel-himax-hx83102.c
> index 34e0e956db48..8b2a68ee851e 100644
> --- a/drivers/gpu/drm/panel/panel-himax-hx83102.c
> +++ b/drivers/gpu/drm/panel/panel-himax-hx83102.c
> @@ -7,6 +7,7 @@
>    * Based on drivers/gpu/drm/panel/panel-himax-hx8394.c
>    */
>   
> +#include <linux/backlight.h>
>   #include <linux/delay.h>
>   #include <linux/gpio/consumer.h>
>   #include <linux/module.h>
> @@ -76,6 +77,8 @@ struct hx83102_panel_desc {
>   		unsigned int height_mm;
>   	} size;
>   
> +	bool has_backlight;
> +
>   	int (*init)(struct hx83102 *ctx);
>   };
>   
> @@ -913,6 +916,7 @@ static const struct hx83102_panel_desc holitech_htf065h045_desc = {
>   		.width_mm = 68,
>   		.height_mm = 151,
>   	},
> +	.has_backlight = true,
>   	.init = holitech_htf065h045_init,
>   };
>   
> @@ -1049,6 +1053,59 @@ static const struct drm_panel_funcs hx83102_drm_funcs = {
>   	.get_orientation = hx83102_get_orientation,
>   };
>   
> +static int hx83102_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_large(dsi, brightness);
> +	if (ret < 0)
> +		return ret;
> +
> +	dsi->mode_flags |= MIPI_DSI_MODE_LPM;
> +
> +	return 0;
> +}
> +
> +static int hx83102_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_large(dsi, &brightness);
> +	if (ret < 0)
> +		return ret;
> +
> +	dsi->mode_flags |= MIPI_DSI_MODE_LPM;
> +
> +	return brightness;
> +}
> +
> +static const struct backlight_ops hx83102_bl_ops = {
> +	.update_status = hx83102_bl_update_status,
> +	.get_brightness = hx83102_bl_get_brightness,
> +};
> +
> +static struct backlight_device *
> +hx83102_create_dcs_backlight(struct mipi_dsi_device *dsi)
> +{
> +	struct device *dev = &dsi->dev;
> +	const struct backlight_properties props = {
> +		.type = BACKLIGHT_RAW,
> +		.brightness = 4095,
> +		.max_brightness = 4095,

I guess those values could be in the hx83102_panel_desc.

Anyway:

Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>

Thanks,
Neil

> +	};
> +
> +	return devm_backlight_device_register(dev, dev_name(dev), dev, dsi,
> +					      &hx83102_bl_ops, &props);
> +}
> +
>   static int hx83102_panel_add(struct hx83102 *ctx)
>   {
>   	struct device *dev = &ctx->dsi->dev;
> @@ -1080,6 +1137,14 @@ static int hx83102_panel_add(struct hx83102 *ctx)
>   	if (err)
>   		return err;
>   
> +	/* Use DSI-based backlight as fallback if available */
> +	if (ctx->desc->has_backlight && !ctx->base.backlight) {
> +		ctx->base.backlight = hx83102_create_dcs_backlight(ctx->dsi);
> +		if (IS_ERR(ctx->base.backlight))
> +			return dev_err_probe(dev, PTR_ERR(ctx->base.backlight),
> +					     "Failed to create backlight\n");
> +	}
> +
>   	ctx->base.funcs = &hx83102_drm_funcs;
>   	ctx->base.dev = &ctx->dsi->dev;
>   


  reply	other threads:[~2026-03-04 16:27 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-17  7:00 [PATCH 0/4] Add support for hx83102-based Holitech HTF065H045 panel Val Packett
2026-02-17  7:00 ` [PATCH 1/4] dt-bindings: vendor-prefixes: Add Holitech Val Packett
2026-02-17 20:25   ` Krzysztof Kozlowski
2026-02-17  7:00 ` [PATCH 2/4] dt-bindings: display: panel: Add compatible for Holitech HTF065H045 Val Packett
2026-02-17 20:26   ` Krzysztof Kozlowski
2026-02-17  7:00 ` [PATCH 3/4] drm/panel: himax-hx83102: Add support " Val Packett
2026-03-04 16:26   ` Neil Armstrong
2026-03-04 19:00     ` Val Packett
2026-02-17  7:00 ` [PATCH 4/4] drm/panel: himax-hx83102: Add support for DSI DCS backlight control Val Packett
2026-03-04 16:27   ` Neil Armstrong [this message]
2026-03-05  8:58   ` David Heidelberg
2026-03-05  8:52 ` [PATCH 0/4] Add support for hx83102-based Holitech HTF065H045 panel David Heidelberg
2026-03-26  9:02 ` (subset) " Neil Armstrong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b2ce76f4-bb19-4e4c-a5bb-c3000f8a9827@linaro.org \
    --to=neil.armstrong@linaro.org \
    --cc=airlied@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jesszhan0024@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=phone-devel@vger.kernel.org \
    --cc=simona@ffwll.ch \
    --cc=tzimmermann@suse.de \
    --cc=val@packett.cool \
    --cc=~postmarketos/upstreaming@lists.sr.ht \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®