Source
static int dream_cheeky_write(struct led_classdev *cdev, enum led_brightness br)
/*
* Simple USB RGB LED driver
*
* Copyright 2016 Heiner Kallweit <hkallweit1@gmail.com>
* Based on drivers/hid/hid-thingm.c and
* drivers/usb/misc/usbled.c
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, version 2.
*/
enum hidled_report_type {
RAW_REQUEST,
OUTPUT_REPORT
};
enum hidled_type {
RISO_KAGAKU,
DREAM_CHEEKY,
THINGM,
DELCOM,
LUXAFOR,
};
static unsigned const char riso_kagaku_tbl[] = {
/* R+2G+4B -> riso kagaku color index */
[0] = 0, /* black */
[1] = 2, /* red */
[2] = 1, /* green */
[3] = 5, /* yellow */
[4] = 3, /* blue */
[5] = 6, /* magenta */
[6] = 4, /* cyan */
[7] = 7 /* white */
};
union delcom_packet {
__u8 data[8];
struct {
__u8 major_cmd;
__u8 minor_cmd;
__u8 data_lsb;
__u8 data_msb;
} tx;
struct {
__u8 cmd;
} rx;
struct {
__le16 family_code;
__le16 security_code;
__u8 fw_version;
} fw;
};
struct hidled_device;
struct hidled_rgb;
struct hidled_config {
enum hidled_type type;
const char *name;
const char *short_name;
enum led_brightness max_brightness;
int num_leds;
size_t report_size;
enum hidled_report_type report_type;
int (*init)(struct hidled_device *ldev);
int (*write)(struct led_classdev *cdev, enum led_brightness br);
};
struct hidled_led {
struct led_classdev cdev;
struct hidled_rgb *rgb;
char name[32];
};
struct hidled_rgb {
struct hidled_device *ldev;