Add kbled control
This commit is contained in:
parent
884c9916e4
commit
2b8b1a3d20
@ -1,7 +1,7 @@
|
|||||||
#include <board/acpi.h>
|
#include <board/acpi.h>
|
||||||
#include <board/battery.h>
|
#include <board/battery.h>
|
||||||
#include <board/dac.h>
|
|
||||||
#include <board/gpio.h>
|
#include <board/gpio.h>
|
||||||
|
#include <board/kbled.h>
|
||||||
#include <board/peci.h>
|
#include <board/peci.h>
|
||||||
#include <common/debug.h>
|
#include <common/debug.h>
|
||||||
|
|
||||||
@ -9,9 +9,9 @@ extern bool lid_wake;
|
|||||||
|
|
||||||
extern uint8_t sci_extra;
|
extern uint8_t sci_extra;
|
||||||
|
|
||||||
uint8_t fcmd = 0;
|
static uint8_t fcmd = 0;
|
||||||
uint8_t fdat = 0;
|
static uint8_t fdat = 0;
|
||||||
uint8_t fbuf[4] = { 0, 0, 0, 0 };
|
static uint8_t fbuf[4] = { 0, 0, 0, 0 };
|
||||||
|
|
||||||
void fcommand(void) {
|
void fcommand(void) {
|
||||||
switch (fcmd) {
|
switch (fcmd) {
|
||||||
@ -20,11 +20,11 @@ void fcommand(void) {
|
|||||||
switch (fdat) {
|
switch (fdat) {
|
||||||
// Set white LED brightness
|
// Set white LED brightness
|
||||||
case 0x00:
|
case 0x00:
|
||||||
DACDAT2 = fbuf[0];
|
kbled_set(fbuf[0]);
|
||||||
break;
|
break;
|
||||||
// Get white LED brightness
|
// Get white LED brightness
|
||||||
case 0x01:
|
case 0x01:
|
||||||
fbuf[0] = DACDAT2;
|
fbuf[0] = kbled_get();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
9
src/board/system76/lemp9/include/board/kbled.h
Normal file
9
src/board/system76/lemp9/include/board/kbled.h
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#ifndef _BOARD_KBLED_H
|
||||||
|
#define _BOARD_KBLED_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
uint8_t kbled_get(void);
|
||||||
|
void kbled_set(uint8_t level);
|
||||||
|
|
||||||
|
#endif // _BOARD_KBLED_H
|
31
src/board/system76/lemp9/kbled.c
Normal file
31
src/board/system76/lemp9/kbled.c
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
#include <board/dac.h>
|
||||||
|
#include <board/kbled.h>
|
||||||
|
#include <common/macro.h>
|
||||||
|
|
||||||
|
static uint8_t __code levels[] = {
|
||||||
|
0,
|
||||||
|
48,
|
||||||
|
72,
|
||||||
|
96,
|
||||||
|
192,
|
||||||
|
255
|
||||||
|
};
|
||||||
|
|
||||||
|
uint8_t kbled_get(void) {
|
||||||
|
uint8_t level;
|
||||||
|
uint8_t raw = DACDAT2;
|
||||||
|
for (level = 0; level < ARRAY_SIZE(levels); level++) {
|
||||||
|
if (raw <= levels[level]) {
|
||||||
|
return level;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void kbled_set(uint8_t level) {
|
||||||
|
if (level < ARRAY_SIZE(levels)) {
|
||||||
|
DACDAT2 = levels[level];
|
||||||
|
} else {
|
||||||
|
DACDAT2 = 0;
|
||||||
|
}
|
||||||
|
}
|
@ -3,6 +3,7 @@
|
|||||||
#include <arch/delay.h>
|
#include <arch/delay.h>
|
||||||
#include <board/gpio.h>
|
#include <board/gpio.h>
|
||||||
#include <board/kbc.h>
|
#include <board/kbc.h>
|
||||||
|
#include <board/kbled.h>
|
||||||
#include <board/kbscan.h>
|
#include <board/kbscan.h>
|
||||||
#include <board/keymap.h>
|
#include <board/keymap.h>
|
||||||
#include <board/pmc.h>
|
#include <board/pmc.h>
|
||||||
@ -104,6 +105,14 @@ void kbscan_event(void) {
|
|||||||
if (new_b) {
|
if (new_b) {
|
||||||
uint8_t sci = SCI_EXTRA;
|
uint8_t sci = SCI_EXTRA;
|
||||||
sci_extra = (uint8_t)(key & 0xFF);
|
sci_extra = (uint8_t)(key & 0xFF);
|
||||||
|
|
||||||
|
// HACK FOR HARDWARE HOTKEYS
|
||||||
|
switch (sci_extra) {
|
||||||
|
case SCI_EXTRA_KBD_BKL:
|
||||||
|
kbled_set(kbled_get() + 1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (!pmc_sci(&PMC_1, sci)) {
|
if (!pmc_sci(&PMC_1, sci)) {
|
||||||
// In the case of ignored SCI, reset bit
|
// In the case of ignored SCI, reset bit
|
||||||
new &= ~(1 << j);
|
new &= ~(1 << j);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user