From: Paul A. T. <phe...@gm...> - 2014-03-28 16:38:10
|
From: "Paul A. Tessier" <phe...@gm...> adds sysfs attribute wacom_led/crop_marks_luminance adds support for crop marks in led control message adds script to exercise LEDs Signed-off-by: Paul A. Tessier <phe...@gm...> --- 3.7/wacom.h | 1 + 3.7/wacom_sys.c | 5 +++- test/cycle-leds | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+), 1 deletion(-) create mode 100755 test/cycle-leds diff --git a/3.7/wacom.h b/3.7/wacom.h index b79d451..19ab360 100644 --- a/3.7/wacom.h +++ b/3.7/wacom.h @@ -121,6 +121,7 @@ struct wacom { u8 llv; /* status led brightness no button (1..127) */ u8 hlv; /* status led brightness button pressed (1..127) */ u8 img_lum; /* OLED matrix display brightness */ + u8 crop_lum; /* crop marks led brightness (1..127) */ } led; struct power_supply battery; }; diff --git a/3.7/wacom_sys.c b/3.7/wacom_sys.c index 255a398..e0311a5 100644 --- a/3.7/wacom_sys.c +++ b/3.7/wacom_sys.c @@ -732,7 +732,7 @@ static int wacom_led_control(struct wacom *wacom) */ int ring_led = wacom->led.select[0] & 0x03; int ring_lum = (((wacom->led.llv & 0x60) >> 5) - 1) & 0x03; - int crop_lum = 0; + int crop_lum = (((wacom->led.crop_lum & 0x60) >> 5) - 1) & 0x03; buf[0] = WAC_CMD_LED_CONTROL; buf[1] = (crop_lum << 4) | (ring_lum << 2) | (ring_led); @@ -880,6 +880,7 @@ static DEVICE_ATTR(name##_luminance, DEV_ATTR_RW_PERM, \ DEVICE_LUMINANCE_ATTR(status0, llv); DEVICE_LUMINANCE_ATTR(status1, hlv); +DEVICE_LUMINANCE_ATTR(crop_marks, crop_lum); DEVICE_LUMINANCE_ATTR(buttons, img_lum); static ssize_t wacom_button_image_store(struct device *dev, int button_id, @@ -952,6 +953,7 @@ static struct attribute_group intuos4_led_attr_group = { static struct attribute *intuos5_led_attrs[] = { &dev_attr_status0_luminance.attr, + &dev_attr_crop_marks_luminance.attr, &dev_attr_status_led0_select.attr, NULL }; @@ -1002,6 +1004,7 @@ static int wacom_initialize_leds(struct wacom *wacom) wacom->led.select[1] = 0; wacom->led.llv = 32; wacom->led.hlv = 0; + wacom->led.crop_lum = 32; wacom->led.img_lum = 0; error = sysfs_create_group(&wacom->intf->dev.kobj, diff --git a/test/cycle-leds b/test/cycle-leds new file mode 100755 index 0000000..89b46cd --- /dev/null +++ b/test/cycle-leds @@ -0,0 +1,71 @@ +#!/bin/bash +err() +{ + echo "$@" >&2 + exit 1 +} + +set_led() +{ + echo $1 > "$led_sel" +} +set_rng() +{ +# echo $(expr $1 \* 32 ) > "$rng_lum" + echo $1 > "$rng_lum" +} +set_crp() +{ +# echo $(expr $1 \* 32 ) > "$crp_lum" + echo $1 > "$crp_lum" +} + +if [ -z "$1" ]; then + loc="$(find /sys/ -name wacom_led)" + [ ! -d "$loc" ] && err "no wacom_led found in /sys/" +else + loc="$1" + [ ! -d "$loc" ] && err "not a folder: $1" +fi + +led_sel="$loc/status_led0_select" +rng_lum="$loc/status0_luminance" +crp_lum="$loc/crop_marks_luminance" + +[ ! -f "$led_sel" ] && err "no led selector found: $led_sel" +[ ! -f "$rng_lum" ] && err "no ring leds found: $rng_lum" +[ ! -f "$crp_lum" ] && err "no crop leds found: $crp_lum" + +old_led=$(cat "$led_sel") +old_rng=$(cat "$rng_lum") +old_crp=$(cat "$crp_lum") + +set_led 0 +set_crp 0 +set_rng 0 + +for j in {0..1}; do + for i in {1..127}; do + set_crp $i + done + for i in {126..0}; do + set_crp $i + done +done + +for k in {0..3}; do + set_led $k + for j in {0..1}; do + for i in {1..127}; do + set_rng $i + done + for i in {126..0}; do + set_rng $i + done + done +done + +set_led $old_led +set_crp $old_crp +set_rng $old_rng + -- 1.8.3.2 |