summaryrefslogtreecommitdiff
path: root/firmware/target/hosted/fiio/buttonlight-fiio.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/hosted/fiio/buttonlight-fiio.c')
-rw-r--r--firmware/target/hosted/fiio/buttonlight-fiio.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/firmware/target/hosted/fiio/buttonlight-fiio.c b/firmware/target/hosted/fiio/buttonlight-fiio.c
new file mode 100644
index 0000000000..37961f7b63
--- /dev/null
+++ b/firmware/target/hosted/fiio/buttonlight-fiio.c
@@ -0,0 +1,57 @@
1/***************************************************************************
2 * __________ __ ___
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * Copyright (C) 2017 Marcin Bukat
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
15 *
16 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
17 * KIND, either express or implied.
18 *
19 ****************************************************************************/
20#include <sys/types.h>
21#include <sys/stat.h>
22#include <fcntl.h>
23#include <stdbool.h>
24#include <unistd.h>
25#include <string.h>
26#include <stdio.h>
27#include "config.h"
28#include "backlight-target.h"
29#include "sysfs.h"
30#include "panic.h"
31#include "lcd.h"
32
33static const char * const sysfs_kb_brightness =
34 "/sys/class/jz_pwm_dev/jz_pwm_dev4/duty_ratio";
35
36static const char * const sysfs_kb_power =
37 "/sys/class/jz_pwm_dev/jz_pwm_dev4/enable";
38
39void buttonlight_hw_on(void)
40{
41 sysfs_set_int(sysfs_kb_power, 1);
42}
43
44void buttonlight_hw_off(void)
45{
46 sysfs_set_int(sysfs_kb_power, 0);
47}
48
49void buttonlight_hw_brightness(int brightness)
50{
51 if (brightness > MAX_BRIGHTNESS_SETTING)
52 brightness = MAX_BRIGHTNESS_SETTING;
53 if (brightness < MIN_BRIGHTNESS_SETTING)
54 brightness = MIN_BRIGHTNESS_SETTING;
55
56 sysfs_set_int(sysfs_kb_brightness, brightness);
57}