* [PATCH] drm/panel: rpi-touchscreen: Add backlight support
@ 2018-12-14 17:27 Nicolas Saenz Julienne
2018-12-18 22:49 ` kbuild test robot
0 siblings, 1 reply; 2+ messages in thread
From: Nicolas Saenz Julienne @ 2018-12-14 17:27 UTC (permalink / raw)
To: Thierry Reding
Cc: linux-rpi-kernel, stefan.wahren, eric, Nicolas Saenz Julienne,
David Airlie, dri-devel, linux-kernel
This patch exposes backlight control into userspace by creating a
backlight device instead of directly accessing the PWM registers.
The backlight driver can't go on a separate file as it shares the I2C
bus & address with the panel.
Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
---
.../drm/panel/panel-raspberrypi-touchscreen.c | 33 +++++++++++++++++--
1 file changed, 31 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c b/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c
index 2c9c9722734f..838b5c8767bc 100644
--- a/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c
+++ b/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c
@@ -52,6 +52,7 @@
#include <linux/of_device.h>
#include <linux/of_graph.h>
#include <linux/pm.h>
+#include <linux/backlight.h>
#include <drm/drm_panel.h>
#include <drm/drmP.h>
@@ -196,6 +197,7 @@ struct rpi_touchscreen {
struct drm_panel base;
struct mipi_dsi_device *dsi;
struct i2c_client *i2c;
+ struct backlight_device *backlight;
};
static const struct drm_display_mode rpi_touchscreen_modes[] = {
@@ -256,7 +258,8 @@ static int rpi_touchscreen_disable(struct drm_panel *panel)
{
struct rpi_touchscreen *ts = panel_to_ts(panel);
- rpi_touchscreen_i2c_write(ts, REG_PWM, 0);
+ ts->backlight->props.brightness = 0;
+ backlight_update_status(ts->backlight);
rpi_touchscreen_i2c_write(ts, REG_POWERON, 0);
udelay(1);
@@ -300,7 +303,8 @@ static int rpi_touchscreen_enable(struct drm_panel *panel)
msleep(100);
/* Turn on the backlight. */
- rpi_touchscreen_i2c_write(ts, REG_PWM, 255);
+ ts->backlight->props.brightness = 255;
+ backlight_update_status(ts->backlight);
/* Default to the same orientation as the closed source
* firmware used for the panel. Runtime rotation
@@ -358,12 +362,26 @@ static const struct drm_panel_funcs rpi_touchscreen_funcs = {
.get_modes = rpi_touchscreen_get_modes,
};
+static int raspberrypi_bl_update_status(struct backlight_device *bl)
+{
+ struct rpi_touchscreen *ts = bl_get_data(bl);
+
+ rpi_touchscreen_i2c_write(ts, REG_PWM, bl->props.brightness);
+
+ return 0;
+}
+
+static const struct backlight_ops raspberrypi_bl_ops = {
+ .update_status = raspberrypi_bl_update_status,
+};
+
static int rpi_touchscreen_probe(struct i2c_client *i2c,
const struct i2c_device_id *id)
{
struct device *dev = &i2c->dev;
struct rpi_touchscreen *ts;
struct device_node *endpoint, *dsi_host_node;
+ struct backlight_properties props;
struct mipi_dsi_host *host;
int ret, ver;
struct mipi_dsi_device_info info = {
@@ -398,6 +416,17 @@ static int rpi_touchscreen_probe(struct i2c_client *i2c,
/* Turn off at boot, so we can cleanly sequence powering on. */
rpi_touchscreen_i2c_write(ts, REG_POWERON, 0);
+ memset(&props, 0, sizeof(props));
+ props.type = BACKLIGHT_RAW;
+ props.max_brightness = 255;
+ ts->backlight = devm_backlight_device_register(dev, dev_name(dev), dev,
+ ts, &raspberrypi_bl_ops,
+ &props);
+ if (IS_ERR(ts->backlight)) {
+ dev_err(dev, "Failed to create backlight device\n");
+ return PTR_ERR(ts->backlight);
+ }
+
/* Look up the DSI host. It needs to probe before we do. */
endpoint = of_graph_get_next_endpoint(dev->of_node, NULL);
dsi_host_node = of_graph_get_remote_port_parent(endpoint);
--
2.19.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] drm/panel: rpi-touchscreen: Add backlight support
2018-12-14 17:27 [PATCH] drm/panel: rpi-touchscreen: Add backlight support Nicolas Saenz Julienne
@ 2018-12-18 22:49 ` kbuild test robot
0 siblings, 0 replies; 2+ messages in thread
From: kbuild test robot @ 2018-12-18 22:49 UTC (permalink / raw)
To: Nicolas Saenz Julienne
Cc: kbuild-all, Thierry Reding, linux-rpi-kernel, stefan.wahren,
eric, Nicolas Saenz Julienne, David Airlie, dri-devel,
linux-kernel
[-- Attachment #1: Type: text/plain, Size: 896 bytes --]
Hi Nicolas,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on linus/master]
[also build test ERROR on v4.20-rc7 next-20181218]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Nicolas-Saenz-Julienne/drm-panel-rpi-touchscreen-Add-backlight-support/20181215-164117
config: x86_64-randconfig-s3-12190437 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64
All errors (new ones prefixed by >>):
>> ERROR: "devm_backlight_device_register" [drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.ko] undefined!
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 35572 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-12-18 22:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-14 17:27 [PATCH] drm/panel: rpi-touchscreen: Add backlight support Nicolas Saenz Julienne
2018-12-18 22:49 ` kbuild test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).