Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/panel: himax-hx83102: Add support for DSI DCS backlight control

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>
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
Link: https://patch.msgid.link/20260217070121.190108-5-val@packett.cool

authored by

Val Packett and committed by
Neil Armstrong
987170d0 cc72a473

+65
+65
drivers/gpu/drm/panel/panel-himax-hx83102.c
··· 7 7 * Based on drivers/gpu/drm/panel/panel-himax-hx8394.c 8 8 */ 9 9 10 + #include <linux/backlight.h> 10 11 #include <linux/delay.h> 11 12 #include <linux/gpio/consumer.h> 12 13 #include <linux/module.h> ··· 76 75 unsigned int width_mm; 77 76 unsigned int height_mm; 78 77 } size; 78 + 79 + bool has_backlight; 79 80 80 81 int (*init)(struct hx83102 *ctx); 81 82 }; ··· 916 913 .width_mm = 68, 917 914 .height_mm = 151, 918 915 }, 916 + .has_backlight = true, 919 917 .init = holitech_htf065h045_init, 920 918 }; 921 919 ··· 1053 1049 .get_orientation = hx83102_get_orientation, 1054 1050 }; 1055 1051 1052 + static int hx83102_bl_update_status(struct backlight_device *bl) 1053 + { 1054 + struct mipi_dsi_device *dsi = bl_get_data(bl); 1055 + u16 brightness = backlight_get_brightness(bl); 1056 + int ret; 1057 + 1058 + dsi->mode_flags &= ~MIPI_DSI_MODE_LPM; 1059 + 1060 + ret = mipi_dsi_dcs_set_display_brightness_large(dsi, brightness); 1061 + if (ret < 0) 1062 + return ret; 1063 + 1064 + dsi->mode_flags |= MIPI_DSI_MODE_LPM; 1065 + 1066 + return 0; 1067 + } 1068 + 1069 + static int hx83102_bl_get_brightness(struct backlight_device *bl) 1070 + { 1071 + struct mipi_dsi_device *dsi = bl_get_data(bl); 1072 + u16 brightness; 1073 + int ret; 1074 + 1075 + dsi->mode_flags &= ~MIPI_DSI_MODE_LPM; 1076 + 1077 + ret = mipi_dsi_dcs_get_display_brightness_large(dsi, &brightness); 1078 + if (ret < 0) 1079 + return ret; 1080 + 1081 + dsi->mode_flags |= MIPI_DSI_MODE_LPM; 1082 + 1083 + return brightness; 1084 + } 1085 + 1086 + static const struct backlight_ops hx83102_bl_ops = { 1087 + .update_status = hx83102_bl_update_status, 1088 + .get_brightness = hx83102_bl_get_brightness, 1089 + }; 1090 + 1091 + static struct backlight_device * 1092 + hx83102_create_dcs_backlight(struct mipi_dsi_device *dsi) 1093 + { 1094 + struct device *dev = &dsi->dev; 1095 + const struct backlight_properties props = { 1096 + .type = BACKLIGHT_RAW, 1097 + .brightness = 4095, 1098 + .max_brightness = 4095, 1099 + }; 1100 + 1101 + return devm_backlight_device_register(dev, dev_name(dev), dev, dsi, 1102 + &hx83102_bl_ops, &props); 1103 + } 1104 + 1056 1105 static int hx83102_panel_add(struct hx83102 *ctx) 1057 1106 { 1058 1107 struct device *dev = &ctx->dsi->dev; ··· 1136 1079 err = drm_panel_of_backlight(&ctx->base); 1137 1080 if (err) 1138 1081 return err; 1082 + 1083 + /* Use DSI-based backlight as fallback if available */ 1084 + if (ctx->desc->has_backlight && !ctx->base.backlight) { 1085 + ctx->base.backlight = hx83102_create_dcs_backlight(ctx->dsi); 1086 + if (IS_ERR(ctx->base.backlight)) 1087 + return dev_err_probe(dev, PTR_ERR(ctx->base.backlight), 1088 + "Failed to create backlight\n"); 1089 + } 1139 1090 1140 1091 ctx->base.funcs = &hx83102_drm_funcs; 1141 1092 ctx->base.dev = &ctx->dsi->dev;