Author: nick
Date: 2012-05-24 17:58:53 +0100 (Thu, 24 May 2012)
New Revision: 1878
Modified:
balloon/branches/menuconfig2/package/kernel/patches/2.6.39.4/keyboard-tt.patch
Log:
add ability to mask keypresses on keyboard controller
Modified: balloon/branches/menuconfig2/package/kernel/patches/2.6.39.4/keyboard-tt.patch
===================================================================
--- balloon/branches/menuconfig2/package/kernel/patches/2.6.39.4/keyboard-tt.patch 2012-05-15 13:39:31 UTC (rev 1877)
+++ balloon/branches/menuconfig2/package/kernel/patches/2.6.39.4/keyboard-tt.patch 2012-05-24 16:58:53 UTC (rev 1878)
@@ -1,7 +1,7 @@
Index: linux-2.6.39.4/drivers/input/keyboard/Kconfig
===================================================================
---- linux-2.6.39.4.orig/drivers/input/keyboard/Kconfig 2012-05-14 14:02:38.000000000 +0100
-+++ linux-2.6.39.4/drivers/input/keyboard/Kconfig 2012-05-14 14:02:44.000000000 +0100
+--- linux-2.6.39.4.orig/drivers/input/keyboard/Kconfig 2012-05-15 14:38:12.000000000 +0100
++++ linux-2.6.39.4/drivers/input/keyboard/Kconfig 2012-05-15 14:38:23.000000000 +0100
@@ -530,4 +530,13 @@
To compile this driver as a module, choose M here: the
module will be called w90p910_keypad.
@@ -18,8 +18,8 @@
endif
Index: linux-2.6.39.4/drivers/input/keyboard/Makefile
===================================================================
---- linux-2.6.39.4.orig/drivers/input/keyboard/Makefile 2012-05-14 14:02:38.000000000 +0100
-+++ linux-2.6.39.4/drivers/input/keyboard/Makefile 2012-05-14 14:02:44.000000000 +0100
+--- linux-2.6.39.4.orig/drivers/input/keyboard/Makefile 2012-05-15 14:38:12.000000000 +0100
++++ linux-2.6.39.4/drivers/input/keyboard/Makefile 2012-05-15 14:38:23.000000000 +0100
@@ -48,3 +48,4 @@
obj-$(CONFIG_KEYBOARD_TWL4030) += twl4030_keypad.o
obj-$(CONFIG_KEYBOARD_XTKBD) += xtkbd.o
@@ -28,8 +28,8 @@
Index: linux-2.6.39.4/drivers/input/keyboard/tt-keyboard.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ linux-2.6.39.4/drivers/input/keyboard/tt-keyboard.c 2012-05-14 15:34:30.000000000 +0100
-@@ -0,0 +1,735 @@
++++ linux-2.6.39.4/drivers/input/keyboard/tt-keyboard.c 2012-05-24 17:46:47.000000000 +0100
+@@ -0,0 +1,820 @@
+/*
+ * Balloon3 Bubble TT Keyboard Controller Driver
+ * Based on OpenCores keyboard controller
@@ -113,8 +113,46 @@
+#define SAMOSA_KEYBOARD_INT_STATUS 0x0F
+
+static u8 keyboard_id;
++static unsigned int keyboard_keymask[8];
+
+static ssize_t
++show_keymask(struct device *dev, struct device_attribute *attr, char *buf)
++{
++ return sprintf(buf, "0x%2.2x 0x%2.2x 0x%2.2x 0x%2.2x 0x%2.2x 0x%2.2x 0x%2.2x 0x%2.2x\n",
++ keyboard_keymask[0], keyboard_keymask[1], keyboard_keymask[2], keyboard_keymask[3],
++ keyboard_keymask[4], keyboard_keymask[5], keyboard_keymask[6], keyboard_keymask[7]);
++}
++
++static void maskKey(struct device *dev, int row, int col);
++static void unmaskKey(struct device *dev, int row, int col);
++
++static ssize_t
++set_keymask(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
++{
++ int args = sscanf(buf,"%u %u %u %u %u %u %u %u",
++ &keyboard_keymask[0], &keyboard_keymask[1], &keyboard_keymask[2], &keyboard_keymask[3],
++ &keyboard_keymask[4], &keyboard_keymask[5], &keyboard_keymask[6], &keyboard_keymask[7]);
++ if (args == 8) {
++ int row;
++ for (row = 6; row < 8; row++) {
++ int col;
++ for (col = 0; col < 8; col++) {
++ if (keyboard_keymask[row] & (1 << col)) {
++ maskKey(dev, row, col);
++ }
++ else
++ unmaskKey(dev, row,col);
++ }
++ }
++ }
++ else
++ pr_info("%s: invalid input\n", __func__);
++ return count;
++}
++
++static DEVICE_ATTR(keymask, S_IRUGO | S_IWUSR, show_keymask, set_keymask);
++
++static ssize_t
+show_id(struct device *dev, struct device_attribute *attr, char *buf)
+{
+ return sprintf(buf, "0x%x\n", keyboard_id);
@@ -163,6 +201,50 @@
+
+ return result;
+}
++
++static int spiWriteRegData(struct spi_device *spi, unsigned char reg, unsigned char data)
++{
++ int res = 0;
++ char dummy;
++ unsigned char txbuffer[2]= { reg, data };
++ struct spi_transfer rg = {
++ .tx_buf = &txbuffer[0],
++ .len = 2,
++ };
++ struct spi_transfer rd = {
++ .rx_buf = &dummy,
++ .len = 0,
++ };
++ struct spi_message m;
++
++// reg |= 0x80; // set read bit
++ spi_message_init(&m);
++ spi_message_add_tail(&rg, &m);
++// spi_message_add_tail(&rd, &m);
++ res = spi_sync(spi, &m);
++ if (res != 0)
++ pr_info("%s: spi_sync returned %d\n", __func__, res);
++
++ return res;
++}
++
++// FIXME remove!!
++static struct spi_dev *horrible;
++
++static void maskKey(struct device *dev, int row, int col) {
++// struct spi_device * spi_dev = container_of(dev, struct spi_device, dev);
++ struct spi_device * spi_dev = horrible;
++ spiWriteRegData(spi_dev, 0x11, ((row & 0xf) << 4) | (col & 0xf));
++ msleep(1);
++}
++
++static void unmaskKey(struct device *dev, int row, int col) {
++// struct spi_device * spi_dev = container_of(dev, struct spi_device, dev);
++ struct spi_device * spi_dev = horrible;
++ spiWriteRegData(spi_dev, 0x12, ((row & 0xf) << 4) | (col & 0xf));
++ msleep(1);
++}
++
+#endif
+
+static void ttkeypad_reset(void)
@@ -593,11 +675,14 @@
+// this doesn't seem to work either - returns 255
+// schedule_work(&tt_kbd->kbd_wq);
+
-+// error = sysfs_create_group(&dev->dev.kobj, &tt_kbd_attr_group);
+ error = sysfs_create_file(&input->dev.kobj, &dev_attr_kbd_id.attr);
++ if (!error)
++ error = sysfs_create_file(&input->dev.kobj, &dev_attr_keymask.attr);
+ if (error)
+ dev_err(&dev->dev, "failed to create sysfs entries\n");
+
++ // FIXME remove!!
++ horrible = tt_kbd->spi;
+ return 0;
+
+ err_free_irq: