r1906 - in trunk/linux-2.6.x/drivers
dslinux_amadeus at dslinux.in-berlin.de
dslinux_amadeus at dslinux.in-berlin.de
Tue Sep 18 21:34:28 CEST 2007
Author: amadeus
Date: 2007-09-18 21:34:23 +0200 (Tue, 18 Sep 2007)
New Revision: 1906
Log:
Touchscreen driver will switch to mouse mode if /dev/fb1 is opened.
Modified: trunk/linux-2.6.x/drivers/input/touchscreen/nds_ts.c
===================================================================
--- trunk/linux-2.6.x/drivers/input/touchscreen/nds_ts.c 2007-09-17 20:58:11 UTC (rev 1905)
+++ trunk/linux-2.6.x/drivers/input/touchscreen/nds_ts.c 2007-09-18 19:34:23 UTC (rev 1906)
@@ -16,7 +16,6 @@
#include <linux/interrupt.h>
#include <linux/version.h>
#include <linux/kbd_kern.h>
-//#include <linux/config.h>
#include <asm/arch/fifo.h>
#include <asm/irq.h>
@@ -119,8 +118,8 @@
#define DISABLED_MODE 0
#define KEYBOARD_MODE 1
#define MOUSE_MODE 2
+#define XMOUSE_MODE 3 /* absolute mouse mode with nano-X on /dev/fb1 */
-
static void ndstouch_input_event(u8 touched, u8 x, u8 y);
static int ndstouch_output_event(struct input_dev *dev, unsigned int type, unsigned int code, int value);
@@ -267,6 +266,31 @@
update_keyboard(0);
}
+static void
+switch_to_xmouse_mode(void)
+{
+ mode = XMOUSE_MODE;
+
+ memset( bgmap, 0, 32 * 24 * 2 );
+ memset( fgmap, 0, 32 * 24 * 2 );
+
+ input_report_abs(&ndstouch_dev, ABS_PRESSURE, 1);
+ input_report_abs(&ndstouch_dev, ABS_TOOL_WIDTH, 5);
+
+}
+
+/* These 2 functions are called by the frame buffer driver
+ if /dev/fb1 is opened or closed. */
+void ndstouch_open_fb1(void)
+{
+ switch_to_xmouse_mode();
+}
+
+void ndstouch_close_fb1(void)
+{
+ switch_to_keyboard_mode();
+}
+
int ndstouch_output_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
{
if (type == EV_LED && code == LED_CAPSL ) {
@@ -320,12 +344,14 @@
break;
case MOUSE_MODE:
+ case XMOUSE_MODE:
if (touched) {
u8 kx = x / 8;
u8 ky = y / 8;
if (!wasTouched) {
wasTouched = TRUE;
- if (qwertyKeyMap[ky * 32 + kx] == BTN_TOUCH) {
+ if ((mode == MOUSE_MODE)
+ &&(qwertyKeyMap[ky * 32 + kx] == BTN_TOUCH)) {
switch_to_keyboard_mode();
break ;
}
@@ -359,6 +385,7 @@
draw_keyboard(0);
break;
case MOUSE_MODE:
+ case XMOUSE_MODE:
case DISABLED_MODE:
break;
}
Modified: trunk/linux-2.6.x/drivers/video/ndsfb.c
===================================================================
--- trunk/linux-2.6.x/drivers/video/ndsfb.c 2007-09-17 20:58:11 UTC (rev 1905)
+++ trunk/linux-2.6.x/drivers/video/ndsfb.c 2007-09-18 19:34:23 UTC (rev 1906)
@@ -222,7 +222,9 @@
struct fb_info *info);
static int ndsfb_mmap(struct fb_info *info, struct file *file,
struct vm_area_struct *vma);
-static int ndsfb_blank(int blank_mode, const struct fb_info *info);
+static int ndsfb_blank(int blank_mode, struct fb_info *info);
+static int ndsfb_open(struct fb_info *info, int user);
+static int ndsfb_release(struct fb_info *info, int user);
static struct fb_ops ndsfb_ops = {
.fb_check_var = ndsfb_check_var,
@@ -234,9 +236,14 @@
.fb_imageblit = cfb_imageblit,
.fb_cursor = soft_cursor,
.fb_mmap = ndsfb_mmap,
- .fb_blank = ndsfb_blank
+ .fb_blank = ndsfb_blank,
+ .fb_open = ndsfb_open,
+ .fb_release = ndsfb_release
};
+extern void ndstouch_open_fb1(void);
+extern void ndstouch_close_fb1(void);
+
#if 0
static irqreturn_t ndsfb_interrupt(int irq, void *dev_id, struct pt_regs *regs)
{
@@ -357,7 +364,7 @@
info->fix.line_length =
info->var.xres_virtual * (info->var.bits_per_pixel / 8);
- info->fix.smem_start = info->screen_base;
+ info->fix.smem_start = (unsigned)info->screen_base;
info->fix.smem_len = info->var.xres_virtual * info->var.yres_virtual *
(info->var.bits_per_pixel / 8);
@@ -433,7 +440,7 @@
return 0;
}
-static int ndsfb_blank(int blank_mode, const struct fb_info *info)
+static int ndsfb_blank(int blank_mode, struct fb_info *info)
{
if (blank_mode) {
//POWER_CR &= ~ ( POWER_2D | POWER_2D_SUB | POWER_LCD_TOP | POWER_LCD_TOP ) ;
@@ -557,6 +564,25 @@
return 1;
}
+
+static int ndsfb_open(struct fb_info *info, int user)
+{
+ struct platform_device *dev = to_platform_device(info->device);
+ if (dev->id == 1) {
+ ndstouch_open_fb1();
+ }
+ return 0;
+}
+
+static int ndsfb_release(struct fb_info *info, int user)
+{
+ struct platform_device *dev = to_platform_device(info->device);
+ if (dev->id == 1) {
+ ndstouch_close_fb1();
+ }
+ return 0;
+}
+
/*
* Initialisation
*/
More information about the dslinux-commit
mailing list