From subversion@balloonboard.org Fri May 25 16:32:55 2012
Received: from nick by stoneboat.aleph1.co.uk with local (Exim 4.72)
	(envelope-from <subversion@balloonboard.org>) id 1SXwVb-0004ec-Rz
	for balloon-svn@balloonboard.org; Fri, 25 May 2012 16:32:55 +0100
Message-Id: <E1SXwVb-0004ec-Rz@stoneboat.aleph1.co.uk>
Date: Fri, 25 May 2012 16:32:55 +0100
To: balloon-svn@balloonboard.org
From: subversion@balloonboard.org
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-SA-Exim-Connect-IP: <locally generated>
X-SA-Exim-Mail-From: subversion@balloonboard.org
X-SA-Exim-Scanned: No (on stoneboat.aleph1.co.uk);
	SAEximRunCond expanded to false
Subject: [Balloon-svn] r1880 -
	balloon/branches/menuconfig2/package/kernel/patches/2.6.39.4
X-BeenThere: balloon-svn@balloonboard.org
X-Mailman-Version: 2.1.13
Precedence: list
List-Id: <balloon-svn.balloonboard.org>
List-Unsubscribe: <http://balloonboard.org/cgi-bin/mailman/options/balloon-svn>, 
	<mailto:balloon-svn-request@balloonboard.org?subject=unsubscribe>
List-Archive: <http://balloonboard.org/lurker/list/balloon-svn.html>
List-Post: <mailto:balloon-svn@balloonboard.org>
List-Help: <mailto:balloon-svn-request@balloonboard.org?subject=help>
List-Subscribe: <http://balloonboard.org/cgi-bin/mailman/listinfo/balloon-svn>, 
	<mailto:balloon-svn-request@balloonboard.org?subject=subscribe>
X-List-Received-Date: Fri, 25 May 2012 15:32:55 -0000

Author: nick
Date: 2012-05-25 16:32:55 +0100 (Fri, 25 May 2012)
New Revision: 1880

Modified:
   balloon/branches/menuconfig2/package/kernel/patches/2.6.39.4/keyboard-tt.patch
Log:
fixup dev references and add suspend/resume behaviour as per tt spec

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-25 15:32:08 UTC (rev 1879)
+++ balloon/branches/menuconfig2/package/kernel/patches/2.6.39.4/keyboard-tt.patch	2012-05-25 15:32:55 UTC (rev 1880)
@@ -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-24 17:46:47.000000000 +0100
-@@ -0,0 +1,820 @@
++++ linux-2.6.39.4/drivers/input/keyboard/tt-keyboard.c	2012-05-25 15:20:19.000000000 +0100
+@@ -0,0 +1,830 @@
 +/*
 + * Balloon3 Bubble TT Keyboard Controller Driver
 + * Based on OpenCores keyboard controller
@@ -118,30 +118,33 @@
 +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", 
++	struct tt_kbd *kbd = dev_get_drvdata(dev);
++
++	return sprintf(buf, "dev %p, kbd %p, kbd->spi %p, 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",
++		dev, kbd, kbd->spi,
 +		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 void maskKey(struct spi_device *dev, int row, int col);
++static void unmaskKey(struct spi_device *dev, int row, int col);
 +
 +static ssize_t
 +set_keymask(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
 +{
++	struct tt_kbd *kbd = dev_get_drvdata(dev);
 +	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++) {
++		for (row = 0; row < 8; row++) {
 +			int col;
 +			for (col = 0; col < 8; col++) {
-+				if (keyboard_keymask[row] & (1 << col)) {
-+					maskKey(dev, row, col);
-+				}
++				if (keyboard_keymask[row] & (1 << col))
++					maskKey(kbd->spi, row, col);
 +				else
-+					unmaskKey(dev, row,col);
++					unmaskKey(kbd->spi, row,col);
 +			}
 +		}
 +	}
@@ -228,20 +231,14 @@
 +	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));
++static void maskKey(struct spi_device *dev, int row, int col) {
++	spiWriteRegData(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));
++static void unmaskKey(struct spi_device *dev, int row, int col) {
++	spiWriteRegData(dev, 0x12, ((row & 0xf) << 4) | (col & 0xf));
 +	msleep(1);
 +}
 +
@@ -371,6 +368,24 @@
 +{KEY_ESC, KEY_COMPOSE, KEY_LEFTMETA, KEY_INSERT, KEY_ENTER, 0, 0, 0},
 +{KEY_UP, KEY_RIGHT, KEY_DOWN, KEY_LEFT, 0, 0, 0, KEY_KPENTER},		// joystick
 +};
++
++static void suspendKeys(struct device *dev) {
++	int row, col;
++	for (row = 6; row < 8; row++) {
++		for (col = 0; col < 8; col++)
++			if (spi_keycodes[row][col] != KEY_LEFTMETA)
++				maskKey(dev, row, col);
++	}
++}
++
++static void resumeKeys(struct device *dev) {
++	int row, col;
++	for (row = 6; row < 8; row++) {
++		for (col = 0; col < 8; col++)
++			unmaskKey(dev, row, col);
++	}
++}
++
 +#endif
 +
 +static void kbd_work(struct work_struct *work) {
@@ -681,8 +696,7 @@
 +	if (error)
 +		dev_err(&dev->dev, "failed to create sysfs entries\n");
 +
-+	// FIXME remove!!
-+	horrible = tt_kbd->spi;
++	resumeKeys(dev);
 +	return 0;
 +
 + err_free_irq:
@@ -771,18 +785,14 @@
 +#ifdef CONFIG_PM_SLEEP
 +static int tt_kbd_suspend(struct device *dev)
 +{
-+//	struct samosa_device *sdev = to_samosa_device(dev);
-+//	struct tt_kbd *kbd = samosa_get_drvdata(sdev);
-+//	remove reset in case interfering with suspend/resume
-+//	ttkeypad_reset();
++	suspendKeys(to_spi_device(dev));
 +	return 0;
 +}
 +
 +static int tt_kbd_resume(struct device *dev)
 +{
-+//	struct samosa_device *sdev = to_samosa_device(dev);
-+//	struct tt_kbd *kbd = samosa_get_drvdata(sdev);
 +	ttkeypad_reset();
++	resumeKeys(to_spi_device(dev));
 +	return 0;
 +}
 +#endif


