From 7a7c00965c7f1d0641ce22ce9f443b1788604986 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Radek=20Pup=C3=A1k?= Date: Fri, 4 Jul 2008 00:29:02 +0200 Subject: [PATCH] uprava unregistrace driveru - je mozne nahravat bez restartu, zatim obejit problem touch down a up irq, nutno jeste vyresit --- mx1_ts-driver.c | 89 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 66 insertions(+), 23 deletions(-) diff --git a/mx1_ts-driver.c b/mx1_ts-driver.c index e46b498..923d462 100644 --- a/mx1_ts-driver.c +++ b/mx1_ts-driver.c @@ -1,19 +1,23 @@ /* - * MX1 touchscreen driver + * MX1 touchscreen driver * - * Author: Nicolas Pitre - * Created: September 25, 2006 - * Copyright: MontaVista Software, Inc. + * Copyright (C) 2008 + * Radek Pupak (pupakr1@fel.cvut.cz) + * Czech Technical University, FEE, DCE * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * - * This code is heavily based on ucb1x00-*.c copyrighted by Russell King - * covering the UCB1100, UCB1200 and UCB1300.. Support for the UCB1400 has - * been made separate from ucb1x00-core/ucb1x00-ts on Russell's request. + * This code is heavily based on ucb*.c copyrighted by Russell King + * and Nicolas Pitre covering the UCB1100, UCB1200, UCB1300 and UCB1400. + * + * Hardware specific properties are based on mx1ts.h and mx1ts.c copyrated + * by Blue Mug, Inc. for Motorola, Inc. + * */ + #include #include #include @@ -278,10 +282,20 @@ static void mx1ts_enable_pen_touch_interrupt(struct mx1ts *mts) { unsigned int value; + /*while (1) { + value = mx1ts_reg_read(mts, ASP_ACNTLCR); + value = 0X00000000; + value |= ASP_SW3 | ASP_SW6 | ASP_SW5 | ASP_BGE | ASP_PADE ; + mx1ts_reg_write(mts, ASP_ACNTLCR, value); + + pen_x = mx1ts_reg_read(mts, ASP_PADFIFO); + mx1ts_evt_add(mts->ts_idev, 20 , pen_x, 00);*/ + /* Enable pen touch interrupt. */ value = mx1ts_reg_read(mts, ASP_ICNTLR); - value |= /*ASP_EDGE |*/ ASP_PIRQE; + value |= /*ASP_EDGE | ASP_POL |*/ ASP_PIRQE; mx1ts_reg_write(mts, ASP_ICNTLR, value); + printk(KERN_ERR "mx1_touchscreen pen_touch: aktivuji pen down interrupt \n"); } @@ -292,6 +306,7 @@ static void mx1ts_disable_pen_touch_interrupt(struct mx1ts *mts) /* Enable pen touch interrupt. */ value = mx1ts_reg_read(mts, ASP_ICNTLR); value &= ~ASP_PIRQE; + value = 0; /* TODO tohle se musi smazat*/ mx1ts_reg_write(mts, ASP_ICNTLR, value); printk(KERN_ERR "mx1_touchscreen pen_touch: deaktivuji pen down interrupt \n"); } @@ -322,6 +337,8 @@ static void mx1ts_disable_pen_up_interrupt(struct mx1ts *mts) static void mx1ts_start_auto_calibration(struct mx1ts *mts) { unsigned int value; + printk(KERN_ERR "mx1_touchscreen start_auto_calibration \n"); + mts->auto_calibration = 1; @@ -385,23 +402,43 @@ static void mx1ts_reset_asp(struct mx1ts *mts) mx1ts_reg_write(mts, ASP_CMPCNTL, 0); } -static void mx1ts_evt_add(struct input_dev *idev, u8 p , u16 x, u16 y) +static void mx1ts_evt_add_touch(struct input_dev *idev, u8 p , u16 x, u16 y) { input_report_key(idev, BTN_TOUCH, 1); input_report_abs(idev, ABS_X, x); input_report_abs(idev, ABS_Y, y); /*input_report_abs(idev, ABS_PRESSURE, p);*/ - /*printk(KERN_ERR "P %i X %i Y %i.\n", p, x, y);*/ /*devprint dev_dbg(zarizeni, co se vypisuje)*/ + input_report_abs(idev, ABS_PRESSURE, 1); + input_sync(idev); +} + +static void mx1ts_evt_add_up(struct input_dev *idev, u16 x, u16 y) +{ + input_report_abs(idev, ABS_X, x); + input_report_abs(idev, ABS_Y, y); + input_report_abs(idev, ABS_PRESSURE, 0); + /*input_report_key(idev, BTN_TOUCH, 0);*/ input_sync(idev); } +static void mx1ts_evt_add(struct input_dev *idev, u8 p , u16 x, u16 y) +{ + if((x < 7900 || x > 8900) && (y < 7751 || y > 10900)) { + mx1ts_evt_add_touch(idev,p, x, y); /* TODO opravit pen_up pen_down zrejme chyba HW ??? TODO */ + mx1ts_evt_add_up(idev, x, y); + } + + +} + /* * Handle the pen data ready interrupt, generated when pen data is * in the FIFO. */ -/*static irqreturn_t mx1ts_pendata_irq(int irq, void *dev_id)*/ + static irqreturn_t mx1ts_pendata_irq(int irq, void *dev_id) { + struct mx1ts *mts = (struct mx1ts *)dev_id; u16 mx1_cal_range_x; u16 mx1_cal_range_y; @@ -409,7 +446,8 @@ static irqreturn_t mx1ts_pendata_irq(int irq, void *dev_id) mx1_cal_range_x = 1; mx1_cal_range_y = 1; - + + /*printk(KERN_ERR "mx1_touchscreen mx1ts_pendata_irq \n");*/ /* printk(KERN_ERR "mx1_touchscreen: mx1_pendata_irq interrupt recived from struct %p\n", mts);*/ if (mx1ts_reg_read(mts, ASP_ISTATR) & ASP_PUIS) { /*pen up interupt pending*/ @@ -420,7 +458,7 @@ static irqreturn_t mx1ts_pendata_irq(int irq, void *dev_id) mx1ts_enable_pen_touch_interrupt(mts); if(mts->is_open) /*report last known touch*/ - mx1ts_evt_add(mts->ts_idev, 1, 0, 0); + mx1ts_evt_add_up(mts->ts_idev, 100, 100); printk(KERN_ERR "Pen up interrupt.\n"); mx1ts_flush_fifo(mts); @@ -428,7 +466,7 @@ static irqreturn_t mx1ts_pendata_irq(int irq, void *dev_id) } if (mts->auto_calibration) { - unsigned int value; +/* unsigned int value;*/ mts->cal_auto_zero = mx1ts_reg_read(mts, ASP_PADFIFO) & 0xFFFF; mts->cal_range_x = mx1ts_reg_read(mts, ASP_PADFIFO) & 0xFFFF; @@ -452,11 +490,11 @@ static irqreturn_t mx1ts_pendata_irq(int irq, void *dev_id) mts->cal_range_y -= mts->cal_auto_zero; - - value = mx1ts_reg_read(mts, ASP_ACNTLCR); /*switching S0..S7 by internal logic*/ + /* + value = mx1ts_reg_read(mts, ASP_ACNTLCR); podle me duplicita value &= ~0x04000000; mx1ts_reg_write(mts, ASP_ACNTLCR, value); - + */ mts->auto_calibration = 0; mx1ts_enable_auto_sample(mts); @@ -484,7 +522,7 @@ static irqreturn_t mx1ts_pendata_irq(int irq, void *dev_id) mts->cal_range_y); if(mts->is_open) - mx1ts_evt_add(mts->ts_idev, 1 , pen_x, pen_y); + mx1ts_evt_add(mts->ts_idev, 200 , pen_x, pen_y); } return IRQ_HANDLED; } @@ -504,6 +542,7 @@ static irqreturn_t mx1ts_touch_irq(int irq, void *dev_id) mx1ts_reg_set_mask(mts, ASP_ISTATR, ASP_PEN); mx1ts_disable_pen_touch_interrupt(mts); + mx1ts_flush_fifo(mts); mx1ts_start_auto_calibration(mts); mx1ts_enable_pen_up_interrupt(mts); @@ -571,6 +610,7 @@ static void mx1ts_close(struct input_dev *idev) { struct mx1ts *mts = dev_get_drvdata(idev->dev.parent); mts->is_open = 0; + mx1ts_flush_fifo(mts); mx1ts_reset_asp(mts); printk(KERN_ERR "mx1ts: reset\tOK\n"); mx1ts_disable_pen_touch_interrupt(mts); @@ -582,7 +622,7 @@ static int mx1ts_open(struct input_dev *idev) { struct mx1ts *mts = dev_get_drvdata(idev->dev.parent); mts->is_open = 1; - + mx1ts_flush_fifo(mts); /*if there are some older data*/ mx1ts_enable_pen_touch_interrupt(mts); printk(KERN_ERR "mx1ts: zapnuti touch interrupt\n"); return 0; @@ -647,13 +687,13 @@ static int mx1ts_probe(struct platform_device *dev) printk(KERN_ERR "mx1ts: setting idev struct \tOK\n"); - x_res = 35000; - y_res = 35000; + x_res = 60000; + y_res = 60000; printk(KERN_DEBUG "mx1ts: x/y = %d/%d\n", x_res, y_res); input_set_abs_params(idev, ABS_X, 0, x_res, 0, 0); input_set_abs_params(idev, ABS_Y, 0, y_res, 0, 0); - input_set_abs_params(idev, ABS_PRESSURE, 0, 0, 0, 0); + input_set_abs_params(idev, ABS_PRESSURE, 0, 20000, 0, 0); error = input_register_device(idev); if (error) { @@ -684,8 +724,11 @@ static int mx1ts_remove(struct platform_device *dev) free_irq(ASP_PENDATA_IRQ, mts); free_irq(ASP_TOUCH_IRQ, mts); - input_free_device(mts->ts_idev); + /*input_free_device(mts->ts_idev); + printk(KERN_ERR "Free device \tOK\n");*/ + input_unregister_device(mts->ts_idev); + printk(KERN_ERR "Unregister device \tOK\n"); iounmap(mts->mx1ts_mem); release_mem_region(ASP_BASE_ADDR, 0x38); -- 2.39.2