1 // SPDX-License-Identifier: GPL-2.0-only
3 * GMA500 Backlight Interface
5 * Copyright (c) 2009-2011, Intel Corporation.
11 #include "psb_intel_reg.h"
12 #include "psb_intel_drv.h"
13 #include "intel_bios.h"
16 #ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
17 static void do_gma_backlight_set(struct drm_device
*dev
)
19 struct drm_psb_private
*dev_priv
= dev
->dev_private
;
20 backlight_update_status(dev_priv
->backlight_device
);
24 void gma_backlight_enable(struct drm_device
*dev
)
26 #ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
27 struct drm_psb_private
*dev_priv
= dev
->dev_private
;
28 dev_priv
->backlight_enabled
= true;
29 if (dev_priv
->backlight_device
) {
30 dev_priv
->backlight_device
->props
.brightness
= dev_priv
->backlight_level
;
31 do_gma_backlight_set(dev
);
36 void gma_backlight_disable(struct drm_device
*dev
)
38 #ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
39 struct drm_psb_private
*dev_priv
= dev
->dev_private
;
40 dev_priv
->backlight_enabled
= false;
41 if (dev_priv
->backlight_device
) {
42 dev_priv
->backlight_device
->props
.brightness
= 0;
43 do_gma_backlight_set(dev
);
48 void gma_backlight_set(struct drm_device
*dev
, int v
)
50 #ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
51 struct drm_psb_private
*dev_priv
= dev
->dev_private
;
52 dev_priv
->backlight_level
= v
;
53 if (dev_priv
->backlight_device
&& dev_priv
->backlight_enabled
) {
54 dev_priv
->backlight_device
->props
.brightness
= v
;
55 do_gma_backlight_set(dev
);
60 int gma_backlight_init(struct drm_device
*dev
)
62 #ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
63 struct drm_psb_private
*dev_priv
= dev
->dev_private
;
64 dev_priv
->backlight_enabled
= true;
65 return dev_priv
->ops
->backlight_init(dev
);
71 void gma_backlight_exit(struct drm_device
*dev
)
73 #ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
74 struct drm_psb_private
*dev_priv
= dev
->dev_private
;
75 if (dev_priv
->backlight_device
) {
76 dev_priv
->backlight_device
->props
.brightness
= 0;
77 backlight_update_status(dev_priv
->backlight_device
);
78 backlight_device_unregister(dev_priv
->backlight_device
);