• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * libbacklight - userspace interface to Linux backlight control
3  *
4  * Copyright © 2012 Intel Corporation
5  * Copyright 2010 Red Hat <mjg@redhat.com>
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining a
8  * copy of this software and associated documentation files (the "Software"),
9  * to deal in the Software without restriction, including without limitation
10  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11  * and/or sell copies of the Software, and to permit persons to whom the
12  * Software is furnished to do so, subject to the following conditions:
13  *
14  * The above copyright notice and this permission notice (including the next
15  * paragraph) shall be included in all copies or substantial portions of the
16  * Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21  * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25  * DEALINGS IN THE SOFTWARE.
26  *
27  * Authors:
28  *    Matthew Garrett <mjg@redhat.com>
29  *    Tiago Vignatti <vignatti@freedesktop.org>
30  */
31 #ifndef LIBBACKLIGHT_H
32 #define LIBBACKLIGHT_H
33 #include <libudev.h>
34 #include <stdint.h>
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 enum backlight_type {
41 	BACKLIGHT_RAW,
42 	BACKLIGHT_PLATFORM,
43 	BACKLIGHT_FIRMWARE
44 };
45 
46 struct backlight {
47 	char *path;
48 	int max_brightness;
49 	int brightness;
50 	enum backlight_type type;
51 };
52 
53 /*
54  * Find and set up a backlight for a valid udev connector device, i.e. one
55  * matching drm subsystem and with status of connected.
56  */
57 struct backlight *backlight_init(struct udev_device *drm_device,
58 				 uint32_t connector_type);
59 
60 /* Free backlight resources */
61 void backlight_destroy(struct backlight *backlight);
62 
63 /* Provide the maximum backlight value */
64 long backlight_get_max_brightness(struct backlight *backlight);
65 
66 /* Provide the cached backlight value */
67 long backlight_get_brightness(struct backlight *backlight);
68 
69 /* Provide the hardware backlight value */
70 long backlight_get_actual_brightness(struct backlight *backlight);
71 
72 /* Set the backlight to a value between 0 and max */
73 long backlight_set_brightness(struct backlight *backlight, long brightness);
74 
75 #ifdef __cplusplus
76 }
77 #endif
78 
79 #endif /* LIBBACKLIGHT_H */
80