summaryrefslogtreecommitdiff
path: root/drivers/video/simple_panel.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2018-10-01 12:22:41 -0600
committerSimon Glass <sjg@chromium.org>2018-10-09 04:40:27 -0600
commita4f737a9c39abb45a5bde47f313df48e645331f7 (patch)
treeb491944bdc102e4bd9f7009ccead12ed5256d214 /drivers/video/simple_panel.c
parent5d9a88f44a93daf623906fee7ca20fa396460ae2 (diff)
panel: Expand the backlight support
At present the panel can be turned on but not off, and the brightness cannot be controlled at run-time. Add a new API function to both the panel and backlight uclasses to handle this. Enhance the PWM backlight driver to deal with custom levels properly and allow the backlight to be turned on and off. Update the test to cover thes new features. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/video/simple_panel.c')
-rw-r--r--drivers/video/simple_panel.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/drivers/video/simple_panel.c b/drivers/video/simple_panel.c
index 6c604f9bed..7a968e740c 100644
--- a/drivers/video/simple_panel.c
+++ b/drivers/video/simple_panel.c
@@ -32,6 +32,21 @@ static int simple_panel_enable_backlight(struct udevice *dev)
return 0;
}
+static int simple_panel_set_backlight(struct udevice *dev, int percent)
+{
+ struct simple_panel_priv *priv = dev_get_priv(dev);
+ int ret;
+
+ debug("%s: start, backlight = '%s'\n", __func__, priv->backlight->name);
+ dm_gpio_set_value(&priv->enable, 1);
+ ret = backlight_set_brightness(priv->backlight, percent);
+ debug("%s: done, ret = %d\n", __func__, ret);
+ if (ret)
+ return ret;
+
+ return 0;
+}
+
static int simple_panel_ofdata_to_platdata(struct udevice *dev)
{
struct simple_panel_priv *priv = dev_get_priv(dev);
@@ -51,7 +66,7 @@ static int simple_panel_ofdata_to_platdata(struct udevice *dev)
"backlight", &priv->backlight);
if (ret) {
debug("%s: Cannot get backlight: ret=%d\n", __func__, ret);
- return ret;
+ return log_ret(ret);
}
ret = gpio_request_by_name(dev, "enable-gpios", 0, &priv->enable,
GPIOD_IS_OUT);
@@ -59,7 +74,7 @@ static int simple_panel_ofdata_to_platdata(struct udevice *dev)
debug("%s: Warning: cannot get enable GPIO: ret=%d\n",
__func__, ret);
if (ret != -ENOENT)
- return ret;
+ return log_ret(ret);
}
return 0;
@@ -82,6 +97,7 @@ static int simple_panel_probe(struct udevice *dev)
static const struct panel_ops simple_panel_ops = {
.enable_backlight = simple_panel_enable_backlight,
+ .set_backlight = simple_panel_set_backlight,
};
static const struct udevice_id simple_panel_ids[] = {