blob: 8717ab107d5a46cb10a08379d5a4528dcbe249d4 [file] [log] [blame]
Bryce Harrington2dc06732015-06-12 10:15:36 -07001/*
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 */
Kristian Høgsberg51cba3c2012-02-29 14:23:51 -050031#ifndef LIBBACKLIGHT_H
32#define LIBBACKLIGHT_H
33#include <libudev.h>
34#include <stdint.h>
35
36#ifdef __cplusplus
37extern "C" {
Murray Calavera883ac022015-06-06 13:02:22 +000038#endif
Kristian Høgsberg51cba3c2012-02-29 14:23:51 -050039
40enum backlight_type {
41 BACKLIGHT_RAW,
42 BACKLIGHT_PLATFORM,
Kristian Høgsbergb71302e2012-05-10 12:28:35 -040043 BACKLIGHT_FIRMWARE
Kristian Høgsberg51cba3c2012-02-29 14:23:51 -050044};
45
46struct 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 subsytem and with status of connected.
56 */
57struct backlight *backlight_init(struct udev_device *drm_device,
58 uint32_t connector_type);
59
60/* Free backlight resources */
61void backlight_destroy(struct backlight *backlight);
62
63/* Provide the maximum backlight value */
64long backlight_get_max_brightness(struct backlight *backlight);
65
66/* Provide the cached backlight value */
67long backlight_get_brightness(struct backlight *backlight);
68
69/* Provide the hardware backlight value */
70long backlight_get_actual_brightness(struct backlight *backlight);
71
72/* Set the backlight to a value between 0 and max */
73long backlight_set_brightness(struct backlight *backlight, long brightness);
74
75#ifdef __cplusplus
76}
77#endif
78
79#endif /* LIBBACKLIGHT_H */