From 2a83bef85838361f873771711dc1aa74e3d95eab Mon Sep 17 00:00:00 2001 From: Roy Spliet Date: Sun, 1 Sep 2013 16:25:44 +0200 Subject: [PATCH] drm/nv50: Fix backlight not working when PWM_DIV is uninitialised Signed-off-by: Roy Spliet --- drivers/gpu/drm/nouveau/nouveau_backlight.c | 19 ++++++++++++++++--- drivers/gpu/drm/nouveau/nouveau_display.c | 4 ++++ drivers/gpu/drm/nouveau/nouveau_display.h | 7 +++++++ 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_backlight.c b/drivers/gpu/drm/nouveau/nouveau_backlight.c index 2ffad21..4fd96e8 100644 --- a/drivers/gpu/drm/nouveau/nouveau_backlight.c +++ b/drivers/gpu/drm/nouveau/nouveau_backlight.c @@ -174,6 +174,22 @@ static const struct backlight_ops nva3_bl_ops = { .update_status = nva3_set_intensity, }; +int +nouveau_backlight_config(struct nouveau_drm *drm) +{ + struct backlight_device *bd = drm->backlight; + struct nouveau_encoder *nv_encoder = bl_get_data(bd); + struct nouveau_device *device = nv_device(drm->device); + int or = nv_encoder->or; + + if (device->chipset <= 0xa0 || + device->chipset == 0xaa || + device->chipset == 0xac) + nv_wr32(device, NV50_PDISP_SOR_PWM_DIV(or), 0x5e); + + return 0; +} + static int nv50_backlight_init(struct drm_connector *connector) { @@ -191,9 +207,6 @@ nv50_backlight_init(struct drm_connector *connector) return -ENODEV; } - if (!nv_rd32(device, NV50_PDISP_SOR_PWM_CTL(nv_encoder->or))) - return 0; - if (device->chipset <= 0xa0 || device->chipset == 0xaa || device->chipset == 0xac) diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c index e616124..08d5ff4 100644 --- a/drivers/gpu/drm/nouveau/nouveau_display.c +++ b/drivers/gpu/drm/nouveau/nouveau_display.c @@ -249,6 +249,10 @@ nouveau_display_init(struct drm_device *dev) } } + /* configure backlight params */ + if(drm->backlight) + nouveau_backlight_config(drm); + return ret; } diff --git a/drivers/gpu/drm/nouveau/nouveau_display.h b/drivers/gpu/drm/nouveau/nouveau_display.h index 1ea3e47..d4113be 100644 --- a/drivers/gpu/drm/nouveau/nouveau_display.h +++ b/drivers/gpu/drm/nouveau/nouveau_display.h @@ -75,6 +75,7 @@ void nouveau_hdmi_mode_set(struct drm_encoder *, struct drm_display_mode *); #ifdef CONFIG_DRM_NOUVEAU_BACKLIGHT extern int nouveau_backlight_init(struct drm_device *); +extern int nouveau_backlight_config(struct nouveau_drm *); extern void nouveau_backlight_exit(struct drm_device *); #else static inline int @@ -83,6 +84,12 @@ nouveau_backlight_init(struct drm_device *dev) return 0; } +static inline int +nouveau_backlight_config(struct nouveau_drm *drm) +{ + return 0; +} + static inline void nouveau_backlight_exit(struct drm_device *dev) { } -- 1.8.3.1