• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * GMA500 Backlight Interface
4  *
5  * Copyright (c) 2009-2011, Intel Corporation.
6  *
7  * Authors: Eric Knopp
8  */
9 
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"
15 
16 #ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
do_gma_backlight_set(struct drm_device * dev)17 static void do_gma_backlight_set(struct drm_device *dev)
18 {
19 	struct drm_psb_private *dev_priv = dev->dev_private;
20 	backlight_update_status(dev_priv->backlight_device);
21 }
22 #endif
23 
gma_backlight_enable(struct drm_device * dev)24 void gma_backlight_enable(struct drm_device *dev)
25 {
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);
32 	}
33 #endif
34 }
35 
gma_backlight_disable(struct drm_device * dev)36 void gma_backlight_disable(struct drm_device *dev)
37 {
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);
44 	}
45 #endif
46 }
47 
gma_backlight_set(struct drm_device * dev,int v)48 void gma_backlight_set(struct drm_device *dev, int v)
49 {
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);
56 	}
57 #endif
58 }
59 
gma_backlight_init(struct drm_device * dev)60 int gma_backlight_init(struct drm_device *dev)
61 {
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
69 }
70 
gma_backlight_exit(struct drm_device * dev)71 void gma_backlight_exit(struct drm_device *dev)
72 {
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);
79 	}
80 #endif
81 }
82