linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] [INPUT] keypad driver: Added support for OpenCores Keyboard Controller
@ 2008-01-30  9:50 Bryan Wu
  2008-01-30 11:53 ` Will Newton
  0 siblings, 1 reply; 9+ messages in thread
From: Bryan Wu @ 2008-01-30  9:50 UTC (permalink / raw)
  To: dmitry.torokhov, linux-input; +Cc: linux-kernel, Javier Herrero, Bryan Wu

From: Javier Herrero <jherrero@hvsistemas.es>

Signed-off-by: Javier Herrero <jherrero@hvsistemas.es>
Signed-off-by: Bryan Wu <bryan.wu@analog.com>
---
 drivers/input/keyboard/Kconfig         |    9 ++
 drivers/input/keyboard/Makefile        |    2 +
 drivers/input/keyboard/opencores-kbd.c |  195 ++++++++++++++++++++++++++++++++
 3 files changed, 206 insertions(+), 0 deletions(-)
 create mode 100644 drivers/input/keyboard/opencores-kbd.c

diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index 086d58c..a0a016b 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -293,4 +293,13 @@ config KEYBOARD_BFIN
 	  To compile this driver as a module, choose M here: the
 	  module will be called bf54x-keys.
 
+config KEYBOARD_OPENCORES
+       tristate "OpenCores Keyboard Controller"
+       help
+         Say Y here if you want to use the OpenCores Keyboard Controller
+         http://www.opencores.org/projects.cgi/web/keyboardcontroller/overview
+ 
+         To comile this driver as a module, choose M here. the
+         module will be called opencores-kbd.
+
 endif
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile
index e97455f..77b47fb 100644
--- a/drivers/input/keyboard/Makefile
+++ b/drivers/input/keyboard/Makefile
@@ -25,3 +25,5 @@ obj-$(CONFIG_KEYBOARD_HP6XX)		+= jornada680_kbd.o
 obj-$(CONFIG_KEYBOARD_HP7XX)		+= jornada720_kbd.o
 obj-$(CONFIG_KEYBOARD_MAPLE)		+= maple_keyb.o
 obj-$(CONFIG_KEYBOARD_BFIN)		+= bf54x-keys.o
+obj-$(CONFIG_KEYBOARD_OPENCORES)	+= opencores-kbd.o
+
diff --git a/drivers/input/keyboard/opencores-kbd.c b/drivers/input/keyboard/opencores-kbd.c
new file mode 100644
index 0000000..dfe68c6
--- /dev/null
+++ b/drivers/input/keyboard/opencores-kbd.c
@@ -0,0 +1,195 @@
+/*
+ * File:         drivers/input/keyboard/opencores-kbd.c
+ * Based on:	 bf54x-keys.c
+ * Author:       Javier Herrero <jherrero@hvsistemas.es>
+ *
+ * Created:
+ * Description:  OpenCores Keyboard Controller Driver
+ *		 http://www.opencores.org/projects.cgi/web/keyboardcontroller/overview
+ *
+ * Modified:
+ *               Copyright 2007 HV Sistemas S.L.
+ *
+ * Bugs:         Enter bugs at http://blackfin.uclinux.org/
+ *
+ * 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see the file COPYING, or write
+ * to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+
+#include <linux/module.h>
+#include <linux/version.h>
+
+#include <linux/init.h>
+#include <linux/fs.h>
+#include <linux/interrupt.h>
+#include <linux/irq.h>
+#include <linux/sched.h>
+#include <linux/pm.h>
+#include <linux/sysctl.h>
+#include <linux/proc_fs.h>
+#include <linux/delay.h>
+#include <linux/platform_device.h>
+#include <linux/input.h>
+#include <linux/irq.h>
+
+#define DRV_NAME "opencores-kbd"
+#define NUM_KEYS 128
+
+struct opencores_kbd {
+	struct input_dev *input;
+	struct resource	*addr_res;
+	struct resource *irq_res;
+	unsigned short *keycode;
+};
+
+static irqreturn_t opencores_kbd_isr(int irq, void *dev_id)
+{
+	unsigned char c;
+	struct platform_device *pdev = dev_id;
+	struct opencores_kbd *opencores_kbd = platform_get_drvdata(pdev);
+	struct input_dev *input = opencores_kbd->input;
+
+	c = readb(opencores_kbd->addr_res->start);
+	input_report_key(input, c & 0x7f, c & 0x80 ? 0 : 1);
+	input_sync(input);
+
+	return IRQ_HANDLED;
+}
+
+static int __devinit opencores_kbd_probe(struct platform_device *pdev)
+{
+	struct input_dev *input;
+	struct opencores_kbd *opencores_kbd;
+	int i, error;
+
+	opencores_kbd = kzalloc(sizeof(*opencores_kbd), GFP_KERNEL);
+	if (!opencores_kbd)
+		return -ENOMEM;
+
+	opencores_kbd->keycode = kmalloc(NUM_KEYS * sizeof(unsigned short), GFP_KERNEL);
+	if (!opencores_kbd->keycode) {
+		error = -ENOMEM;
+		goto out;
+	}
+
+	platform_set_drvdata(pdev, opencores_kbd);
+
+	opencores_kbd->addr_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	opencores_kbd->irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+
+	if (opencores_kbd->addr_res == NULL || opencores_kbd->irq_res == NULL) {
+		printk(KERN_ERR "insufficient resources\n");
+		error = -ENOENT;
+		goto out1;
+	}
+
+	error = request_irq(opencores_kbd->irq_res->start, &opencores_kbd_isr, IRQF_TRIGGER_RISING, pdev->name, pdev);
+	if (error) {
+		printk(KERN_ERR DRV_NAME ": Unable to claim irq %d; error %d\n", opencores_kbd->irq_res->start, error);
+		goto out2;
+	}
+
+	input = input_allocate_device();
+	if (!input) {
+		error = -ENOMEM;
+		goto out3;
+	}
+
+	opencores_kbd->input = input;
+
+	input->name = pdev->name;
+	input->phys = "opencores-kbd/input0";
+	input->dev.parent = &pdev->dev;
+
+	input_set_drvdata(input, opencores_kbd);
+
+	input->id.bustype = BUS_HOST;
+	input->id.vendor = 0x0001;
+	input->id.product = 0x0001;
+	input->id.version = 0x0100;
+
+	input->keycodesize = sizeof(*opencores_kbd->keycode);
+	input->keycodemax = NUM_KEYS;
+	input->keycode = opencores_kbd->keycode;
+
+	__set_bit(EV_KEY, input->evbit);
+
+	for (i = 0; i < input->keycodemax; i++) {
+		opencores_kbd->keycode[i] = i;
+		__set_bit(opencores_kbd->keycode[i] & KEY_MAX, input->keybit);
+	}
+	__clear_bit(KEY_RESERVED, input->keybit);
+
+	error = input_register_device(opencores_kbd->input);
+	if (error) {
+		printk(KERN_ERR DRV_NAME ": Unable to register input device (%d)\n", error);
+		goto out2;
+	}
+
+	return 0;
+
+out3:
+	input_free_device(input);
+out2:
+	free_irq(opencores_kbd->irq_res->start, pdev);
+out1:
+	kfree(opencores_kbd->keycode);
+out:
+	kfree(opencores_kbd);
+	platform_set_drvdata(pdev, NULL);
+
+	return error;
+}
+
+static int __devexit opencores_kbd_remove(struct platform_device *pdev)
+{
+	struct opencores_kbd *opencores_kbd = platform_get_drvdata(pdev);
+
+	free_irq(opencores_kbd->irq_res->start, pdev);
+
+	input_unregister_device(opencores_kbd->input);
+
+	kfree(opencores_kbd->keycode);
+	kfree(opencores_kbd);
+	platform_set_drvdata(pdev, NULL);
+
+	return 0;
+}
+
+struct platform_driver opencores_kbd_device_driver = {
+	.probe		= opencores_kbd_probe,
+	.remove		= __devexit_p(opencores_kbd_remove),
+	.driver		= {
+		.name	= DRV_NAME,
+	}
+};
+
+static int __init opencores_kbd_init(void)
+{
+	return platform_driver_register(&opencores_kbd_device_driver);
+}
+
+static void __exit opencores_kbd_exit(void)
+{
+	platform_driver_unregister(&opencores_kbd_device_driver);
+}
+
+module_init(opencores_kbd_init);
+module_exit(opencores_kbd_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Javier Herrero <jherrero@hvsistemas.es");
+MODULE_DESCRIPTION("Keyboard driver for OpenCores Keyboard Controller");
-- 
1.5.3.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/1] [INPUT] keypad driver: Added support for OpenCores Keyboard Controller
  2008-01-30  9:50 [PATCH 1/1] [INPUT] keypad driver: Added support for OpenCores Keyboard Controller Bryan Wu
@ 2008-01-30 11:53 ` Will Newton
  2008-01-30 17:07   ` Bryan Wu
  2008-01-30 17:18   ` [PATCH 1/1 try#2] " Bryan Wu
  0 siblings, 2 replies; 9+ messages in thread
From: Will Newton @ 2008-01-30 11:53 UTC (permalink / raw)
  To: Bryan Wu; +Cc: dmitry.torokhov, linux-input, linux-kernel, Javier Herrero

On Jan 30, 2008 9:50 AM, Bryan Wu <bryan.wu@analog.com> wrote:

> +config KEYBOARD_OPENCORES
> +       tristate "OpenCores Keyboard Controller"
> +       help
> +         Say Y here if you want to use the OpenCores Keyboard Controller
> +         http://www.opencores.org/projects.cgi/web/keyboardcontroller/overview
> +
> +         To comile this driver as a module, choose M here. the
> +         module will be called opencores-kbd.
> +

Typo, "comile" should be "compile" here.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/1] [INPUT] keypad driver: Added support for OpenCores Keyboard Controller
  2008-01-30 11:53 ` Will Newton
@ 2008-01-30 17:07   ` Bryan Wu
  2008-01-30 17:18   ` [PATCH 1/1 try#2] " Bryan Wu
  1 sibling, 0 replies; 9+ messages in thread
From: Bryan Wu @ 2008-01-30 17:07 UTC (permalink / raw)
  To: Will Newton
  Cc: Bryan Wu, dmitry.torokhov, linux-input, linux-kernel, Javier Herrero

On Jan 30, 2008 7:53 PM, Will Newton <will.newton@gmail.com> wrote:
> On Jan 30, 2008 9:50 AM, Bryan Wu <bryan.wu@analog.com> wrote:
>
> > +config KEYBOARD_OPENCORES
> > +       tristate "OpenCores Keyboard Controller"
> > +       help
> > +         Say Y here if you want to use the OpenCores Keyboard Controller
> > +         http://www.opencores.org/projects.cgi/web/keyboardcontroller/overview
> > +
> > +         To comile this driver as a module, choose M here. the
> > +         module will be called opencores-kbd.
> > +
>
> Typo, "comile" should be "compile" here.
>

Thanks, fix it now. I will update this patch soon.

-Bryan

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/1 try#2] [INPUT] keypad driver: Added support for OpenCores Keyboard Controller
  2008-01-30 11:53 ` Will Newton
  2008-01-30 17:07   ` Bryan Wu
@ 2008-01-30 17:18   ` Bryan Wu
  2008-02-05 10:42     ` Vojtech Pavlik
  1 sibling, 1 reply; 9+ messages in thread
From: Bryan Wu @ 2008-01-30 17:18 UTC (permalink / raw)
  To: Will Newton
  Cc: Bryan Wu, dmitry.torokhov, linux-input, linux-kernel, Javier Herrero

>From 2d1896f15eca96d887db9fff7988b7977e0b201d Mon Sep 17 00:00:00 2001
From: Javier Herrero <jherrero@hvsistemas.es>
Date: Thu, 31 Jan 2008 01:16:07 +0800
Subject: [PATCH] [INPUT] keypad driver: Added support for OpenCores Keyboard Controller

Signed-off-by: Javier Herrero <jherrero@hvsistemas.es>
Signed-off-by: Bryan Wu <bryan.wu@analog.com>
---
 drivers/input/keyboard/Kconfig         |    9 ++
 drivers/input/keyboard/Makefile        |    2 +
 drivers/input/keyboard/opencores-kbd.c |  195 ++++++++++++++++++++++++++++++++
 3 files changed, 206 insertions(+), 0 deletions(-)
 create mode 100644 drivers/input/keyboard/opencores-kbd.c

diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index 086d58c..c404cd4 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -293,4 +293,13 @@ config KEYBOARD_BFIN
 	  To compile this driver as a module, choose M here: the
 	  module will be called bf54x-keys.
 
+config KEYBOARD_OPENCORES
+	tristate "OpenCores Keyboard Controller"
+	help
+	 Say Y here if you want to use the OpenCores Keyboard Controller
+	 http://www.opencores.org/projects.cgi/web/keyboardcontroller/overview
+
+	 To compile this driver as a module, choose M here. the
+	 module will be called opencores-kbd.
+
 endif
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile
index e97455f..77b47fb 100644
--- a/drivers/input/keyboard/Makefile
+++ b/drivers/input/keyboard/Makefile
@@ -25,3 +25,5 @@ obj-$(CONFIG_KEYBOARD_HP6XX)		+= jornada680_kbd.o
 obj-$(CONFIG_KEYBOARD_HP7XX)		+= jornada720_kbd.o
 obj-$(CONFIG_KEYBOARD_MAPLE)		+= maple_keyb.o
 obj-$(CONFIG_KEYBOARD_BFIN)		+= bf54x-keys.o
+obj-$(CONFIG_KEYBOARD_OPENCORES)	+= opencores-kbd.o
+
diff --git a/drivers/input/keyboard/opencores-kbd.c b/drivers/input/keyboard/opencores-kbd.c
new file mode 100644
index 0000000..dfe68c6
--- /dev/null
+++ b/drivers/input/keyboard/opencores-kbd.c
@@ -0,0 +1,195 @@
+/*
+ * File:         drivers/input/keyboard/opencores-kbd.c
+ * Based on:	 bf54x-keys.c
+ * Author:       Javier Herrero <jherrero@hvsistemas.es>
+ *
+ * Created:
+ * Description:  OpenCores Keyboard Controller Driver
+ *		 http://www.opencores.org/projects.cgi/web/keyboardcontroller/overview
+ *
+ * Modified:
+ *               Copyright 2007 HV Sistemas S.L.
+ *
+ * Bugs:         Enter bugs at http://blackfin.uclinux.org/
+ *
+ * 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see the file COPYING, or write
+ * to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+
+#include <linux/module.h>
+#include <linux/version.h>
+
+#include <linux/init.h>
+#include <linux/fs.h>
+#include <linux/interrupt.h>
+#include <linux/irq.h>
+#include <linux/sched.h>
+#include <linux/pm.h>
+#include <linux/sysctl.h>
+#include <linux/proc_fs.h>
+#include <linux/delay.h>
+#include <linux/platform_device.h>
+#include <linux/input.h>
+#include <linux/irq.h>
+
+#define DRV_NAME "opencores-kbd"
+#define NUM_KEYS 128
+
+struct opencores_kbd {
+	struct input_dev *input;
+	struct resource	*addr_res;
+	struct resource *irq_res;
+	unsigned short *keycode;
+};
+
+static irqreturn_t opencores_kbd_isr(int irq, void *dev_id)
+{
+	unsigned char c;
+	struct platform_device *pdev = dev_id;
+	struct opencores_kbd *opencores_kbd = platform_get_drvdata(pdev);
+	struct input_dev *input = opencores_kbd->input;
+
+	c = readb(opencores_kbd->addr_res->start);
+	input_report_key(input, c & 0x7f, c & 0x80 ? 0 : 1);
+	input_sync(input);
+
+	return IRQ_HANDLED;
+}
+
+static int __devinit opencores_kbd_probe(struct platform_device *pdev)
+{
+	struct input_dev *input;
+	struct opencores_kbd *opencores_kbd;
+	int i, error;
+
+	opencores_kbd = kzalloc(sizeof(*opencores_kbd), GFP_KERNEL);
+	if (!opencores_kbd)
+		return -ENOMEM;
+
+	opencores_kbd->keycode = kmalloc(NUM_KEYS * sizeof(unsigned short), GFP_KERNEL);
+	if (!opencores_kbd->keycode) {
+		error = -ENOMEM;
+		goto out;
+	}
+
+	platform_set_drvdata(pdev, opencores_kbd);
+
+	opencores_kbd->addr_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	opencores_kbd->irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+
+	if (opencores_kbd->addr_res == NULL || opencores_kbd->irq_res == NULL) {
+		printk(KERN_ERR "insufficient resources\n");
+		error = -ENOENT;
+		goto out1;
+	}
+
+	error = request_irq(opencores_kbd->irq_res->start, &opencores_kbd_isr, IRQF_TRIGGER_RISING, pdev->name, pdev);
+	if (error) {
+		printk(KERN_ERR DRV_NAME ": Unable to claim irq %d; error %d\n", opencores_kbd->irq_res->start, error);
+		goto out2;
+	}
+
+	input = input_allocate_device();
+	if (!input) {
+		error = -ENOMEM;
+		goto out3;
+	}
+
+	opencores_kbd->input = input;
+
+	input->name = pdev->name;
+	input->phys = "opencores-kbd/input0";
+	input->dev.parent = &pdev->dev;
+
+	input_set_drvdata(input, opencores_kbd);
+
+	input->id.bustype = BUS_HOST;
+	input->id.vendor = 0x0001;
+	input->id.product = 0x0001;
+	input->id.version = 0x0100;
+
+	input->keycodesize = sizeof(*opencores_kbd->keycode);
+	input->keycodemax = NUM_KEYS;
+	input->keycode = opencores_kbd->keycode;
+
+	__set_bit(EV_KEY, input->evbit);
+
+	for (i = 0; i < input->keycodemax; i++) {
+		opencores_kbd->keycode[i] = i;
+		__set_bit(opencores_kbd->keycode[i] & KEY_MAX, input->keybit);
+	}
+	__clear_bit(KEY_RESERVED, input->keybit);
+
+	error = input_register_device(opencores_kbd->input);
+	if (error) {
+		printk(KERN_ERR DRV_NAME ": Unable to register input device (%d)\n", error);
+		goto out2;
+	}
+
+	return 0;
+
+out3:
+	input_free_device(input);
+out2:
+	free_irq(opencores_kbd->irq_res->start, pdev);
+out1:
+	kfree(opencores_kbd->keycode);
+out:
+	kfree(opencores_kbd);
+	platform_set_drvdata(pdev, NULL);
+
+	return error;
+}
+
+static int __devexit opencores_kbd_remove(struct platform_device *pdev)
+{
+	struct opencores_kbd *opencores_kbd = platform_get_drvdata(pdev);
+
+	free_irq(opencores_kbd->irq_res->start, pdev);
+
+	input_unregister_device(opencores_kbd->input);
+
+	kfree(opencores_kbd->keycode);
+	kfree(opencores_kbd);
+	platform_set_drvdata(pdev, NULL);
+
+	return 0;
+}
+
+struct platform_driver opencores_kbd_device_driver = {
+	.probe		= opencores_kbd_probe,
+	.remove		= __devexit_p(opencores_kbd_remove),
+	.driver		= {
+		.name	= DRV_NAME,
+	}
+};
+
+static int __init opencores_kbd_init(void)
+{
+	return platform_driver_register(&opencores_kbd_device_driver);
+}
+
+static void __exit opencores_kbd_exit(void)
+{
+	platform_driver_unregister(&opencores_kbd_device_driver);
+}
+
+module_init(opencores_kbd_init);
+module_exit(opencores_kbd_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Javier Herrero <jherrero@hvsistemas.es");
+MODULE_DESCRIPTION("Keyboard driver for OpenCores Keyboard Controller");
-- 
1.5.3.4


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/1 try#2] [INPUT] keypad driver: Added support for OpenCores Keyboard Controller
  2008-01-30 17:18   ` [PATCH 1/1 try#2] " Bryan Wu
@ 2008-02-05 10:42     ` Vojtech Pavlik
  2008-02-05 11:18       ` Javier Herrero
  0 siblings, 1 reply; 9+ messages in thread
From: Vojtech Pavlik @ 2008-02-05 10:42 UTC (permalink / raw)
  To: Bryan Wu
  Cc: Will Newton, dmitry.torokhov, linux-input, linux-kernel, Javier Herrero

On Thu, Jan 31, 2008 at 01:18:22AM +0800, Bryan Wu wrote:

> +static irqreturn_t opencores_kbd_isr(int irq, void *dev_id)
> +{
> +	unsigned char c;
> +	struct platform_device *pdev = dev_id;
> +	struct opencores_kbd *opencores_kbd = platform_get_drvdata(pdev);
> +	struct input_dev *input = opencores_kbd->input;
> +
> +	c = readb(opencores_kbd->addr_res->start);
> +	input_report_key(input, c & 0x7f, c & 0x80 ? 0 : 1);
> +	input_sync(input);
> +
> +	return IRQ_HANDLED;
> +}
 
This looks utterly wrong: It assumes 1:1 mapping between Linux keycodes
and what the keyboard sends, which I can't believe is the case.

-- 
Vojtech Pavlik
Director SuSE Labs

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/1 try#2] [INPUT] keypad driver: Added support for OpenCores Keyboard Controller
  2008-02-05 10:42     ` Vojtech Pavlik
@ 2008-02-05 11:18       ` Javier Herrero
  2008-02-05 11:22         ` Vojtech Pavlik
  0 siblings, 1 reply; 9+ messages in thread
From: Javier Herrero @ 2008-02-05 11:18 UTC (permalink / raw)
  To: Vojtech Pavlik
  Cc: Bryan Wu, Will Newton, dmitry.torokhov, linux-input, linux-kernel

Dear Vojtech,

I think that a 1:1 mapping between linux keycodes and what keyboard 
sends is right, because the scan code to key code conversion is already 
programmed and done inside the FPGA code.

Best regards,

Javier

Vojtech Pavlik escribió:
> On Thu, Jan 31, 2008 at 01:18:22AM +0800, Bryan Wu wrote:
>
>> +static irqreturn_t opencores_kbd_isr(int irq, void *dev_id)
>> +{
>> +	unsigned char c;
>> +	struct platform_device *pdev = dev_id;
>> +	struct opencores_kbd *opencores_kbd = platform_get_drvdata(pdev);
>> +	struct input_dev *input = opencores_kbd->input;
>> +
>> +	c = readb(opencores_kbd->addr_res->start);
>> +	input_report_key(input, c & 0x7f, c & 0x80 ? 0 : 1);
>> +	input_sync(input);
>> +
>> +	return IRQ_HANDLED;
>> +}
>  
> This looks utterly wrong: It assumes 1:1 mapping between Linux keycodes
> and what the keyboard sends, which I can't believe is the case.
>

-- 
------------------------------------------------------------------------
Javier Herrero                            EMAIL: jherrero@hvsistemas.com
HV Sistemas S.L.                          PHONE:         +34 949 336 806
Los Charcones, 17A                        FAX:           +34 949 336 792
19170 El Casar - Guadalajara - Spain      WEB: http://www.hvsistemas.com 


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/1 try#2] [INPUT] keypad driver: Added support for OpenCores Keyboard Controller
  2008-02-05 11:18       ` Javier Herrero
@ 2008-02-05 11:22         ` Vojtech Pavlik
  2008-02-05 11:33           ` Javier Herrero
  0 siblings, 1 reply; 9+ messages in thread
From: Vojtech Pavlik @ 2008-02-05 11:22 UTC (permalink / raw)
  To: Javier Herrero
  Cc: Bryan Wu, Will Newton, dmitry.torokhov, linux-input, linux-kernel

On Tue, Feb 05, 2008 at 12:18:15PM +0100, Javier Herrero wrote:
> Dear Vojtech,
>
> I think that a 1:1 mapping between linux keycodes and what keyboard sends 
> is right, because the scan code to key code conversion is already 
> programmed and done inside the FPGA code.

And the FPGA code changes with different keyboards attached?

> Best regards,
>
> Javier
>
> Vojtech Pavlik escribió:
>> On Thu, Jan 31, 2008 at 01:18:22AM +0800, Bryan Wu wrote:
>>
>>> +static irqreturn_t opencores_kbd_isr(int irq, void *dev_id)
>>> +{
>>> +	unsigned char c;
>>> +	struct platform_device *pdev = dev_id;
>>> +	struct opencores_kbd *opencores_kbd = platform_get_drvdata(pdev);
>>> +	struct input_dev *input = opencores_kbd->input;
>>> +
>>> +	c = readb(opencores_kbd->addr_res->start);
>>> +	input_report_key(input, c & 0x7f, c & 0x80 ? 0 : 1);
>>> +	input_sync(input);
>>> +
>>> +	return IRQ_HANDLED;
>>> +}
>>  This looks utterly wrong: It assumes 1:1 mapping between Linux keycodes
>> and what the keyboard sends, which I can't believe is the case.
>>
>
> -- 
> ------------------------------------------------------------------------
> Javier Herrero                            EMAIL: jherrero@hvsistemas.com
> HV Sistemas S.L.                          PHONE:         +34 949 336 806
> Los Charcones, 17A                        FAX:           +34 949 336 792
> 19170 El Casar - Guadalajara - Spain      WEB: http://www.hvsistemas.com 

-- 
Vojtech Pavlik
Director SuSE Labs

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/1 try#2] [INPUT] keypad driver: Added support for OpenCores Keyboard Controller
  2008-02-05 11:22         ` Vojtech Pavlik
@ 2008-02-05 11:33           ` Javier Herrero
  2008-05-12  5:50             ` Bryan Wu
  0 siblings, 1 reply; 9+ messages in thread
From: Javier Herrero @ 2008-02-05 11:33 UTC (permalink / raw)
  To: Vojtech Pavlik
  Cc: Bryan Wu, Will Newton, dmitry.torokhov, linux-input, linux-kernel

Vojtech Pavlik escribió:
> On Tue, Feb 05, 2008 at 12:18:15PM +0100, Javier Herrero wrote:
>> Dear Vojtech,
>>
>> I think that a 1:1 mapping between linux keycodes and what keyboard sends 
>> is right, because the scan code to key code conversion is already 
>> programmed and done inside the FPGA code.
>
> And the FPGA code changes with different keyboards attached?
>
The original OpenCores keyboard controller is a 6 rows x 12 cols 
keyboard controller that can be customized for other row/col sizes 
modifiying Constants.vhd VHDL file, in which also the translation table 
is defined, and for different key disposition schemes both the number of 
rows and cols can be changed. We are currently using this controller 
with a 4x4 key matrix, and with a different key mapping values, so I 
thought that it would be preferable to have the driver mapping fixed to 
1:1 and do the mapping in the VHDL, since in most cases the keyboard 
using this controller would be different to the default keyboard defined 
in the original Contants.vhd VHDL file.

Regards,

Javier

>> Best regards,
>>
>> Javier
>>
>> Vojtech Pavlik escribió:
>>> On Thu, Jan 31, 2008 at 01:18:22AM +0800, Bryan Wu wrote:
>>>
>>>> +static irqreturn_t opencores_kbd_isr(int irq, void *dev_id)
>>>> +{
>>>> +	unsigned char c;
>>>> +	struct platform_device *pdev = dev_id;
>>>> +	struct opencores_kbd *opencores_kbd = platform_get_drvdata(pdev);
>>>> +	struct input_dev *input = opencores_kbd->input;
>>>> +
>>>> +	c = readb(opencores_kbd->addr_res->start);
>>>> +	input_report_key(input, c & 0x7f, c & 0x80 ? 0 : 1);
>>>> +	input_sync(input);
>>>> +
>>>> +	return IRQ_HANDLED;
>>>> +}
>>>  This looks utterly wrong: It assumes 1:1 mapping between Linux keycodes
>>> and what the keyboard sends, which I can't believe is the case.
>>>
>> -- 
>> ------------------------------------------------------------------------
>> Javier Herrero                            EMAIL: jherrero@hvsistemas.com
>> HV Sistemas S.L.                          PHONE:         +34 949 336 806
>> Los Charcones, 17A                        FAX:           +34 949 336 792
>> 19170 El Casar - Guadalajara - Spain      WEB: http://www.hvsistemas.com 
>

-- 
------------------------------------------------------------------------
Javier Herrero                            EMAIL: jherrero@hvsistemas.com
HV Sistemas S.L.                          PHONE:         +34 949 336 806
Los Charcones, 17A                        FAX:           +34 949 336 792
19170 El Casar - Guadalajara - Spain      WEB: http://www.hvsistemas.com 


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/1 try#2] [INPUT] keypad driver: Added support for OpenCores Keyboard Controller
  2008-02-05 11:33           ` Javier Herrero
@ 2008-05-12  5:50             ` Bryan Wu
  0 siblings, 0 replies; 9+ messages in thread
From: Bryan Wu @ 2008-05-12  5:50 UTC (permalink / raw)
  To: Javier Herrero
  Cc: Vojtech Pavlik, Bryan Wu, Will Newton, dmitry.torokhov,
	linux-input, linux-kernel

On Tue, Feb 5, 2008 at 7:33 PM, Javier Herrero <jherrero@hvsistemas.es> wrote:
> Vojtech Pavlik escribió:
>>
>> On Tue, Feb 05, 2008 at 12:18:15PM +0100, Javier Herrero wrote:
>>>
>>> Dear Vojtech,
>>>
>>> I think that a 1:1 mapping between linux keycodes and what keyboard sends
>>> is right, because the scan code to key code conversion is already programmed
>>> and done inside the FPGA code.
>>
>> And the FPGA code changes with different keyboards attached?
>>
> The original OpenCores keyboard controller is a 6 rows x 12 cols keyboard
> controller that can be customized for other row/col sizes modifiying
> Constants.vhd VHDL file, in which also the translation table is defined, and
> for different key disposition schemes both the number of rows and cols can
> be changed. We are currently using this controller with a 4x4 key matrix,
> and with a different key mapping values, so I thought that it would be
> preferable to have the driver mapping fixed to 1:1 and do the mapping in the
> VHDL, since in most cases the keyboard using this controller would be
> different to the default keyboard defined in the original Contants.vhd VHDL
> file.
>
> Regards,
>
> Javier
>

Hi Vojtech, Will and Dmitry,

How do you think of this driver from Javier?
It works fine on Blackfin arch, but it can also be shared by other platform.
So this driver is useful of the other developers.
Could you please consider merging this driver?

If you need me to resend this patch, please ping me.

Thanks
-Bryan

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2008-05-12  5:50 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-30  9:50 [PATCH 1/1] [INPUT] keypad driver: Added support for OpenCores Keyboard Controller Bryan Wu
2008-01-30 11:53 ` Will Newton
2008-01-30 17:07   ` Bryan Wu
2008-01-30 17:18   ` [PATCH 1/1 try#2] " Bryan Wu
2008-02-05 10:42     ` Vojtech Pavlik
2008-02-05 11:18       ` Javier Herrero
2008-02-05 11:22         ` Vojtech Pavlik
2008-02-05 11:33           ` Javier Herrero
2008-05-12  5:50             ` Bryan Wu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).