Merge tag 'io_uring-5.11-2021-01-16' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / drivers / gpu / drm / gma500 / backlight.c
blob35600d070cb53e36a96e7ac21a12de3fa6310b11
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * GMA500 Backlight Interface
5 * Copyright (c) 2009-2011, Intel Corporation.
7 * Authors: Eric Knopp
8 */
10 #include "psb_drv.h"
11 #include "psb_intel_reg.h"
12 #include "psb_intel_drv.h"
13 #include "intel_bios.h"
14 #include "power.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);
22 #endif
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);
33 #endif
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);
45 #endif
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);
57 #endif
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);
66 #else
67 return 0;
68 #endif
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);
80 #endif