mirror of
https://github.com/wessel-novacustom/clevo-keyboard.git
synced 2024-11-15 03:34:01 +01:00
Add color scaling to cl kbd bl driver
Modify scaling for one-zone rgb Implements #79
This commit is contained in:
parent
e2e69ea79d
commit
5c9ca122cc
|
@ -64,6 +64,17 @@ void clevo_leds_set_color_extern(u32 color);
|
||||||
static enum clevo_kb_backlight_types clevo_kb_backlight_type = CLEVO_KB_BACKLIGHT_TYPE_NONE;
|
static enum clevo_kb_backlight_types clevo_kb_backlight_type = CLEVO_KB_BACKLIGHT_TYPE_NONE;
|
||||||
static bool leds_initialized = false;
|
static bool leds_initialized = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Color scaling quirk list
|
||||||
|
*/
|
||||||
|
static void color_scaling(enum clevo_kb_backlight_types *type, u8 *red, u8 *green, u8 *blue)
|
||||||
|
{
|
||||||
|
if (*type == CLEVO_KB_BACKLIGHT_TYPE_1_ZONE_RGB) {
|
||||||
|
*red = (180 * *red) / 255;
|
||||||
|
*blue = (200 * *blue) / 255;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int clevo_evaluate_set_white_brightness(u8 brightness)
|
static int clevo_evaluate_set_white_brightness(u8 brightness)
|
||||||
{
|
{
|
||||||
pr_debug("Set white brightness on %d\n", brightness);
|
pr_debug("Set white brightness on %d\n", brightness);
|
||||||
|
@ -134,6 +145,7 @@ static struct led_classdev_mc clevo_mcled_cdevs[3]; // forward declaration
|
||||||
static void clevo_leds_set_brightness_mc(struct led_classdev *led_cdev, enum led_brightness brightness) {
|
static void clevo_leds_set_brightness_mc(struct led_classdev *led_cdev, enum led_brightness brightness) {
|
||||||
int ret;
|
int ret;
|
||||||
u32 zone, color;
|
u32 zone, color;
|
||||||
|
u8 red, green, blue;
|
||||||
struct led_classdev_mc *mcled_cdev = lcdev_to_mccdev(led_cdev);
|
struct led_classdev_mc *mcled_cdev = lcdev_to_mccdev(led_cdev);
|
||||||
|
|
||||||
ret = clevo_evaluate_set_rgb_brightness(brightness);
|
ret = clevo_evaluate_set_rgb_brightness(brightness);
|
||||||
|
@ -147,9 +159,15 @@ static void clevo_leds_set_brightness_mc(struct led_classdev *led_cdev, enum led
|
||||||
|
|
||||||
zone = mcled_cdev->subled_info[0].channel;
|
zone = mcled_cdev->subled_info[0].channel;
|
||||||
|
|
||||||
color = (mcled_cdev->subled_info[0].intensity << 16) +
|
red = mcled_cdev->subled_info[0].intensity;
|
||||||
(mcled_cdev->subled_info[1].intensity << 8) +
|
green = mcled_cdev->subled_info[1].intensity;
|
||||||
mcled_cdev->subled_info[2].intensity;
|
blue = mcled_cdev->subled_info[2].intensity;
|
||||||
|
|
||||||
|
color_scaling(&clevo_kb_backlight_type, &red, &green, &blue);
|
||||||
|
|
||||||
|
color = (red << 16) +
|
||||||
|
(green << 8) +
|
||||||
|
blue;
|
||||||
|
|
||||||
ret = clevo_evaluate_set_rgb_color(zone, color);
|
ret = clevo_evaluate_set_rgb_color(zone, color);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
|
|
Loading…
Reference in a new issue