]>
Commit | Line | Data |
---|---|---|
bbbb262d AC |
1 | /* |
2 | * GMA500 Backlight Interface | |
3 | * | |
4 | * Copyright (c) 2009-2011, Intel Corporation. | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or modify it | |
7 | * under the terms and conditions of the GNU General Public License, | |
8 | * version 2, as published by the Free Software Foundation. | |
9 | * | |
10 | * This program is distributed in the hope it will be useful, but WITHOUT | |
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
13 | * more details. | |
14 | * | |
15 | * You should have received a copy of the GNU General Public License along with | |
16 | * this program; if not, write to the Free Software Foundation, Inc., | |
17 | * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. | |
18 | * | |
19 | * Authors: Eric Knopp | |
20 | * | |
21 | */ | |
22 | ||
23 | #include "psb_drv.h" | |
24 | #include "psb_intel_reg.h" | |
25 | #include "psb_intel_drv.h" | |
26 | #include "intel_bios.h" | |
27 | #include "power.h" | |
28 | ||
d112a816 ZY |
29 | static void do_gma_backlight_set(struct drm_device *dev) |
30 | { | |
31 | #ifdef CONFIG_BACKLIGHT_CLASS_DEVICE | |
32 | struct drm_psb_private *dev_priv = dev->dev_private; | |
33 | backlight_update_status(dev_priv->backlight_device); | |
34 | #endif | |
35 | } | |
36 | ||
37 | void gma_backlight_enable(struct drm_device *dev) | |
38 | { | |
39 | #ifdef CONFIG_BACKLIGHT_CLASS_DEVICE | |
40 | struct drm_psb_private *dev_priv = dev->dev_private; | |
41 | dev_priv->backlight_enabled = true; | |
42 | if (dev_priv->backlight_device) { | |
43 | dev_priv->backlight_device->props.brightness = dev_priv->backlight_level; | |
44 | do_gma_backlight_set(dev); | |
45 | } | |
46 | #endif | |
47 | } | |
48 | ||
49 | void gma_backlight_disable(struct drm_device *dev) | |
50 | { | |
51 | #ifdef CONFIG_BACKLIGHT_CLASS_DEVICE | |
52 | struct drm_psb_private *dev_priv = dev->dev_private; | |
53 | dev_priv->backlight_enabled = false; | |
54 | if (dev_priv->backlight_device) { | |
55 | dev_priv->backlight_device->props.brightness = 0; | |
56 | do_gma_backlight_set(dev); | |
57 | } | |
58 | #endif | |
59 | } | |
60 | ||
61 | void gma_backlight_set(struct drm_device *dev, int v) | |
62 | { | |
63 | #ifdef CONFIG_BACKLIGHT_CLASS_DEVICE | |
64 | struct drm_psb_private *dev_priv = dev->dev_private; | |
65 | dev_priv->backlight_level = v; | |
66 | if (dev_priv->backlight_device && dev_priv->backlight_enabled) { | |
67 | dev_priv->backlight_device->props.brightness = v; | |
68 | do_gma_backlight_set(dev); | |
69 | } | |
70 | #endif | |
71 | } | |
72 | ||
bbbb262d AC |
73 | int gma_backlight_init(struct drm_device *dev) |
74 | { | |
75 | #ifdef CONFIG_BACKLIGHT_CLASS_DEVICE | |
76 | struct drm_psb_private *dev_priv = dev->dev_private; | |
d112a816 | 77 | dev_priv->backlight_enabled = true; |
bbbb262d AC |
78 | return dev_priv->ops->backlight_init(dev); |
79 | #else | |
80 | return 0; | |
81 | #endif | |
82 | } | |
83 | ||
84 | void gma_backlight_exit(struct drm_device *dev) | |
85 | { | |
86 | #ifdef CONFIG_BACKLIGHT_CLASS_DEVICE | |
87 | struct drm_psb_private *dev_priv = dev->dev_private; | |
88 | if (dev_priv->backlight_device) { | |
89 | dev_priv->backlight_device->props.brightness = 0; | |
90 | backlight_update_status(dev_priv->backlight_device); | |
91 | backlight_device_unregister(dev_priv->backlight_device); | |
92 | } | |
93 | #endif | |
94 | } |