[gnome-settings-daemon] wacom: new kernels required the Bluetooth oled data to be scrambled



commit b06555cccdf943fc2729a74ab81bf0f183f662cf
Author: Benjamin Tissoires <benjamin tissoires redhat com>
Date:   Mon Aug 11 16:01:40 2014 -0400

    wacom: new kernels required the Bluetooth oled data to be scrambled
    
    The unified wacom kernel module now uses the same API for OLED
    either on Bluetooth or USB. The choice has been made to not scramble in
    the kernel the incoming data to keep the USB (most used) untouched.
    
    Implement the scrambling for bluetooth in g-s-d.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=734458

 plugins/wacom/gsd-wacom-oled-constants.h |    3 +-
 plugins/wacom/gsd-wacom-oled-helper.c    |   59 +++++++++++++++++++++++++++++-
 2 files changed, 60 insertions(+), 2 deletions(-)
---
diff --git a/plugins/wacom/gsd-wacom-oled-constants.h b/plugins/wacom/gsd-wacom-oled-constants.h
index b779cd2..e93f744 100644
--- a/plugins/wacom/gsd-wacom-oled-constants.h
+++ b/plugins/wacom/gsd-wacom-oled-constants.h
@@ -24,7 +24,8 @@ G_BEGIN_DECLS
 
 typedef enum {
        GSD_WACOM_OLED_TYPE_USB,
-       GSD_WACOM_OLED_TYPE_BLUETOOTH
+       GSD_WACOM_OLED_TYPE_BLUETOOTH,
+       GSD_WACOM_OLED_TYPE_RAW_BLUETOOTH
 } GsdWacomOledType;
 
 /* OLED parameters */
diff --git a/plugins/wacom/gsd-wacom-oled-helper.c b/plugins/wacom/gsd-wacom-oled-helper.c
index e278df6..511a120 100644
--- a/plugins/wacom/gsd-wacom-oled-helper.c
+++ b/plugins/wacom/gsd-wacom-oled-helper.c
@@ -65,6 +65,57 @@ oled_scramble_icon (guchar *image)
 }
 
 static void
+oled_bt_scramble_icon (guchar *input_image)
+{
+       unsigned char image[BT_BUF_LEN];
+       unsigned mask;
+       unsigned s1;
+       unsigned s2;
+       unsigned r1 ;
+       unsigned r2 ;
+       unsigned r;
+       unsigned char buf[256];
+       int i, w, x, y, z;
+
+       for (i = 0; i < BT_BUF_LEN; i++)
+               image[i] = input_image[i];
+
+       for (x = 0; x < 32; x++) {
+               for (y = 0; y < 8; y++)
+                       buf[(8 * x) + (7 - y)] = image[(8 * x) + y];
+       }
+
+       /* Change 76543210 into GECA6420 as required by Intuos4 WL
+        *        HGFEDCBA      HFDB7531
+        */
+       for (x = 0; x < 4; x++) {
+               for (y = 0; y < 4; y++) {
+                       for (z = 0; z < 8; z++) {
+                               mask = 0x0001;
+                               r1 = 0;
+                               r2 = 0;
+                               i = (x << 6) + (y << 4) + z;
+                               s1 = buf[i];
+                               s2 = buf[i+8];
+                               for (w = 0; w < 8; w++) {
+                                       r1 |= (s1 & mask);
+                                       r2 |= (s2 & mask);
+                                       s1 <<= 1;
+                                       s2 <<= 1;
+                                       mask <<= 2;
+                               }
+                               r = r1 | (r2 << 1);
+                               i = (x << 6) + (y << 4) + (z << 1);
+                               image[i] = 0xFF & r;
+                               image[i+1] = (0xFF00 & r) >> 8;
+                       }
+               }
+       }
+       for (i = 0; i < BT_BUF_LEN; i++)
+               input_image[i] = image[i];
+}
+
+static void
 gsd_wacom_oled_convert_1_bit (guchar *image)
 {
        guchar buf[BT_BUF_LEN];
@@ -102,6 +153,12 @@ gsd_wacom_oled_prepare_buf (guchar *image, GsdWacomOledType type)
                gsd_wacom_oled_convert_1_bit (image);
                len = BT_BUF_LEN;
                break;
+       case GSD_WACOM_OLED_TYPE_RAW_BLUETOOTH:
+               /* Image has also to be scrambled for devices connected over BT using the raw API ... */
+               gsd_wacom_oled_convert_1_bit (image);
+               len = BT_BUF_LEN;
+               oled_bt_scramble_icon (image);
+               break;
        default:
                g_assert_not_reached ();
        }
@@ -228,7 +285,7 @@ get_oled_sys_path (GUdevClient      *client,
                filename = get_oled_sysfs_path (parent, button_num);
                g_object_unref (parent);
                if(g_file_test (filename, G_FILE_TEST_EXISTS)) {
-                       *type = GSD_WACOM_OLED_TYPE_USB;
+                       *type = usb ? GSD_WACOM_OLED_TYPE_USB : GSD_WACOM_OLED_TYPE_RAW_BLUETOOTH;
                        return filename;
                }
                g_clear_pointer (&filename, g_free);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]