summaryrefslogtreecommitdiff
path: root/common/pwm_kblight.c
blob: bd7e07644d4a128d8f682dc2827c186edb7c901f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/* Copyright 2013 The ChromiumOS Authors
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

/* PWM control module for keyboard backlight. */

#include "common.h"
#include "keyboard_backlight.h"
#include "pwm.h"
#include "system.h"
#include "util.h"

const enum pwm_channel kblight_pwm_ch = PWM_CH_KBLIGHT;

static int kblight_pwm_set(int percent)
{
	pwm_set_duty(kblight_pwm_ch, percent);
	return EC_SUCCESS;
}

static int kblight_pwm_init(void)
{
	/* dnojiri: Why do we need save/restore setting over sysjump? */
	kblight_pwm_set(0);
	pwm_enable(kblight_pwm_ch, 0);
	return EC_SUCCESS;
}

static int kblight_pwm_enable(int enable)
{
	pwm_enable(kblight_pwm_ch, enable);
	return EC_SUCCESS;
}

static int kblight_pwm_get_enabled(void)
{
	return pwm_get_enabled(kblight_pwm_ch);
}

const struct kblight_drv kblight_pwm = {
	.init = kblight_pwm_init,
	.set = kblight_pwm_set,
	.enable = kblight_pwm_enable,
	.get_enabled = kblight_pwm_get_enabled,
};