Commit 5fd14f28 authored by Sam Ravnborg's avatar Sam Ravnborg

drm/panel: kingdisplay-kd097d04: use drm_panel backlight support

Use the backlight support in drm_panel to simplify the driver
Signed-off-by: default avatarSam Ravnborg <sam@ravnborg.org>
Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20191207140353.23967-12-sam@ravnborg.org
parent 16793e00
......@@ -3,7 +3,6 @@
* Copyright (c) 2017, Fuzhou Rockchip Electronics Co., Ltd
*/
#include <linux/backlight.h>
#include <linux/delay.h>
#include <linux/gpio/consumer.h>
#include <linux/module.h>
......@@ -23,7 +22,6 @@ struct kingdisplay_panel {
struct drm_panel base;
struct mipi_dsi_device *link;
struct backlight_device *backlight;
struct regulator *supply;
struct gpio_desc *enable_gpio;
......@@ -191,8 +189,6 @@ static int kingdisplay_panel_disable(struct drm_panel *panel)
if (!kingdisplay->enabled)
return 0;
backlight_disable(kingdisplay->backlight);
err = mipi_dsi_dcs_set_display_off(kingdisplay->link);
if (err < 0)
DRM_DEV_ERROR(panel->dev, "failed to set display off: %d\n",
......@@ -303,18 +299,10 @@ static int kingdisplay_panel_prepare(struct drm_panel *panel)
static int kingdisplay_panel_enable(struct drm_panel *panel)
{
struct kingdisplay_panel *kingdisplay = to_kingdisplay_panel(panel);
int ret;
if (kingdisplay->enabled)
return 0;
ret = backlight_enable(kingdisplay->backlight);
if (ret) {
DRM_DEV_ERROR(panel->dev,
"Failed to enable backlight %d\n", ret);
return ret;
}
kingdisplay->enabled = true;
return 0;
......@@ -388,13 +376,13 @@ static int kingdisplay_panel_add(struct kingdisplay_panel *kingdisplay)
kingdisplay->enable_gpio = NULL;
}
kingdisplay->backlight = devm_of_find_backlight(dev);
if (IS_ERR(kingdisplay->backlight))
return PTR_ERR(kingdisplay->backlight);
drm_panel_init(&kingdisplay->base, &kingdisplay->link->dev,
&kingdisplay_panel_funcs, DRM_MODE_CONNECTOR_DSI);
err = drm_panel_of_backlight(&kingdisplay->base);
if (err)
return err;
return drm_panel_add(&kingdisplay->base);
}
......@@ -432,12 +420,12 @@ static int kingdisplay_panel_remove(struct mipi_dsi_device *dsi)
struct kingdisplay_panel *kingdisplay = mipi_dsi_get_drvdata(dsi);
int err;
err = kingdisplay_panel_unprepare(&kingdisplay->base);
err = drm_panel_unprepare(&kingdisplay->base);
if (err < 0)
DRM_DEV_ERROR(&dsi->dev, "failed to unprepare panel: %d\n",
err);
err = kingdisplay_panel_disable(&kingdisplay->base);
err = drm_panel_disable(&kingdisplay->base);
if (err < 0)
DRM_DEV_ERROR(&dsi->dev, "failed to disable panel: %d\n", err);
......@@ -455,8 +443,8 @@ static void kingdisplay_panel_shutdown(struct mipi_dsi_device *dsi)
{
struct kingdisplay_panel *kingdisplay = mipi_dsi_get_drvdata(dsi);
kingdisplay_panel_unprepare(&kingdisplay->base);
kingdisplay_panel_disable(&kingdisplay->base);
drm_panel_unprepare(&kingdisplay->base);
drm_panel_disable(&kingdisplay->base);
}
static struct mipi_dsi_driver kingdisplay_panel_driver = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment