From: <cri...@us...> - 2006-08-13 17:46:07
|
Revision: 544 Author: cristianop Date: 2006-08-13 10:45:49 -0700 (Sun, 13 Aug 2006) ViewCVS: http://svn.sourceforge.net/hackndev/?rev=544&view=rev Log Message: ----------- linux4palm: some changes to prevent read errors ... Modified Paths: -------------- linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmld_ac97.c Modified: linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmld_ac97.c =================================================================== --- linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmld_ac97.c 2006-08-13 16:07:50 UTC (rev 543) +++ linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmld_ac97.c 2006-08-13 17:45:49 UTC (rev 544) @@ -47,6 +47,7 @@ #define WM9712_PIL 0x00100 #define WM97XX_POLL 0x8000 /* initiate a polling measurement */ #define AC97_LINK_FRAME 21 /* time in uS for AC97 link frame */ +#define WM97XX_DELAY(i) ((i << 4) & 0x00f0) /* sample delay times */ #define DEFAULT_PRESSURE_TRESHOLD 45160 /* default pressure treshold for pen up/down */ @@ -76,6 +77,7 @@ static unsigned long last_update = 0; static int battery_voltage; static int previous_voltage; +static u16 d2base; #if defined(CONFIG_APM) || defined(CONFIG_APM_MODULE) /* original APM hook */ @@ -133,19 +135,13 @@ ac97->bus->ops->write(ac97, 0x52, GWn); } -static int wm97xx_set_digitiser_power(struct device *dev, int value) +static void wm97xx_set_digitiser_power(struct device *dev, int value) { ac97_t *ac97 = dev->platform_data; - u16 d2; + u16 d2 = d2base; - d2 = ac97->bus->ops->read(ac97, AC97_WM97XX_DIGITISER2); - if (d2 == (unsigned short) -1){ - printk("wm9712: will not set digitizer to %d due to read error on 0x78\n", value); - return -1; - } d2 |= value; ac97->bus->ops->write(ac97, AC97_WM97XX_DIGITISER2, d2); - return 1; } /* @@ -159,24 +155,19 @@ static int palmld_ac97_take_reading(struct device *dev, int adcsel) { ac97_t *ac97 = dev->platform_data; - int timeout = 10; - u16 r76, r7a; + int timeout = 15; + u16 r76 = 0; + u16 r7a; - r76 = ac97->bus->ops->read(ac97, 0x76); - if (r76 == (unsigned short) -1){ - printk("wm9712: will not continue take reading due to read error on 0x76\n"); - return 0; - } - - r76 &= ~WM97XX_ADCSEL_MASK; /* clear ADCSEL */ r76 |= adcsel; /* set ADCSEL */ + r76 |= WM97XX_DELAY(3); /* set DELAY */ r76 &= ~(1<<11); /* COO = 0 (single measurement) */ r76 &= ~(1<<10); /* CTC = 0 (polling mode) */ - r76 |= (1<<15); /* start reading */ + r76 |= (1<<15); /* start reading */ ac97->bus->ops->write(ac97, 0x76, r76); // some code from the the wolfson' driver - udelay (3 * AC97_LINK_FRAME + 167); + udelay ((3 * AC97_LINK_FRAME) + 167); /* wait for POLL to go low */ @@ -215,23 +206,16 @@ return; down(&digitiser_sem); - //wm97xx_set_digitiser_power(palmld_ac97_dev, WM97XX_PRP_DET_DIG); - if (wm97xx_set_digitiser_power(palmld_ac97_dev, WM97XX_PRP_DET_DIG)){ - // todo: check if reading is valid - reading = palmld_ac97_take_reading(palmld_ac97_dev, WM97XX_ADCSEL_BMON); - wm97xx_set_digitiser_power(palmld_ac97_dev, WM97XX_PRP_DET); - up(&digitiser_sem); - previous_voltage = battery_voltage; - battery_voltage = reading & 0xfff; - //printk("wm9712: battery -> %d\n", battery_voltage); - last_update = jiffies; - } - else { - up(&digitiser_sem); - printk ("wm9712: couldn't power digitiser on ... skipping battery read\n"); - - } + wm97xx_set_digitiser_power(palmld_ac97_dev, WM97XX_PRP_DET_DIG); + // todo: check if reading is valid + reading = palmld_ac97_take_reading(palmld_ac97_dev, WM97XX_ADCSEL_BMON); + wm97xx_set_digitiser_power(palmld_ac97_dev, WM97XX_PRP_DET); + up(&digitiser_sem); + previous_voltage = battery_voltage; + battery_voltage = reading & 0xfff; + //printk("wm9712: battery -> %d\n", battery_voltage); + last_update = jiffies; up(&battery_update_mutex); } @@ -358,11 +342,8 @@ //wm97xx_set_digitiser_power(dev, WM97XX_PRP_DET_DIG); /* take readings */ - //printk("wm9712: reading x\n"); xread = palmld_ac97_take_reading(dev, WM97XX_ADCSEL_X); - //printk("wm9712: reading y\n"); yread = palmld_ac97_take_reading(dev, WM97XX_ADCSEL_Y); - //printk("wm9712: reading pressure\n"); pressure = palmld_ac97_take_reading(dev, WM97XX_ADCSEL_PRES); /* power down digitiser to conserve power */ @@ -404,55 +385,30 @@ u16 levels; u16 polarity; - - //printk ("wm97xx: disabling pen detect interrupt\n"); - // disable pen detect interrupt - //wm97xx_gpio_mode(ac97, WM97XX_GPIO_13, WM97XX_GPIO_IN, - // WM97XX_GPIO_POL_HIGH, WM97XX_GPIO_NOTSTICKY, WM97XX_GPIO_NOWAKE); - //printk ("wm97xx: pen detect interrupt disabled\n"); - - levels = ac97->bus->ops->read(ac97, 0x54); polarity = ac97->bus->ops->read(ac97, 0x4e); if(polarity & levels & WM97XX_GPIO_13) { - //printk("wm9712: starting read\n"); - down(&digitiser_sem); // power up digitiser: - // test if doing it for all read cycle has benefits to ac97 usage - - - if (wm97xx_set_digitiser_power(dev, WM97XX_PRP_DET_DIG)){ - palmld_ac97_pendown(dev); - /* power down digitiser to conserve power */ - wm97xx_set_digitiser_power(dev, WM97XX_PRP_DET); - } - else{ - printk("wm9712: cannot power digitizer on ... skipping pendown reading\n"); - } - ac97->bus->ops->write(ac97, 0x4e, polarity & ~WM97XX_GPIO_13); + // test if doing it for all read cycle helps + down(&digitiser_sem); + wm97xx_set_digitiser_power(dev, WM97XX_PRP_DET_DIG); + palmld_ac97_pendown(dev); + /* power down digitiser to conserve power */ + wm97xx_set_digitiser_power(dev, WM97XX_PRP_DET); + ac97->bus->ops->write(ac97, 0x4e, polarity & ~WM97XX_GPIO_13); up(&digitiser_sem); } else { ac97->bus->ops->write(ac97, 0x4e, polarity | WM97XX_GPIO_13); } - ac97->bus->ops->write(ac97, 0x54, levels & ~WM97XX_GPIO_13); - - - //printk ("wm97xx: re-enabling pen detect interrupt\n"); - /* re-enable pen detect interrupt */ - - //wm97xx_gpio_mode(ac97, WM97XX_GPIO_13, WM97XX_GPIO_IN, - // WM97XX_GPIO_POL_HIGH, WM97XX_GPIO_STICKY, WM97XX_GPIO_WAKE); - //printk ("wm97xx: re-enabled pen detect interrupt\n"); - udelay(50); + udelay(1); up(&queue_sem); enable_irq(IRQ_GPIO_PALMTX_WM9712_IRQ); - } static irqreturn_t palmld_ac97_irq_handler(int irq, void *dev_id, struct pt_regs *regs) @@ -461,20 +417,10 @@ * we can't use ac97 from within the interrupt handler, so schedule a task * to do the actual handling. */ - //printk("wm9712: IRQ request received\n"); - // probably this lock is useless as irq seems to be disabled so quickly that - // I haven't seen up until now requests not queued if (down_trylock(&queue_sem) == 0){ disable_irq(IRQ_GPIO_PALMTX_WM9712_IRQ); queue_work(palmld_ac97_workqueue, &palmld_ac97_irq_task); - //printk("wm9712: IRQ request queued\n"); } - //else{ - // printk("wm9712: IRQ request not queued\n"); - //} - - - return IRQ_HANDLED; } @@ -509,6 +455,7 @@ /* disable digitiser to save power, enable pen-down detect */ d2 = ac97->bus->ops->read(ac97, AC97_WM97XX_DIGITISER2); d2 |= WM97XX_PRP_DET; + d2base = d2; ac97->bus->ops->write(ac97, AC97_WM97XX_DIGITISER2, d2); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cri...@us...> - 2006-08-21 17:15:31
|
Revision: 554 Author: cristianop Date: 2006-08-21 10:15:17 -0700 (Mon, 21 Aug 2006) ViewCVS: http://svn.sourceforge.net/hackndev/?rev=554&view=rev Log Message: ----------- palmtx: simple handling of 'on hold' jitter Modified Paths: -------------- linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmld_ac97.c Modified: linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmld_ac97.c =================================================================== --- linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmld_ac97.c 2006-08-20 17:17:41 UTC (rev 553) +++ linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmld_ac97.c 2006-08-21 17:15:17 UTC (rev 554) @@ -44,12 +44,14 @@ #define PRESSURE_MIN 0 #define PRESSURE_MAX 150 //300 +#define DIG2_INIT 0x0001 /* initial value for digitiser2 register */ #define WM9712_PIL 0x00100 #define WM97XX_POLL 0x8000 /* initiate a polling measurement */ #define AC97_LINK_FRAME 21 /* time in uS for AC97 link frame */ -#define WM97XX_DELAY(i) ((i << 4) & 0x00f0) /* sample delay times */ #define DEFAULT_PRESSURE_TRESHOLD 45160 /* default pressure treshold for pen up/down */ +#define DEFAULT_X_JITTER_TRESHOLD 5; +#define DEFAULT_Y_JITTER_TRESHOLD 35; #define palmld_ac97_WORK_QUEUE_NAME "palmld_ac97.c" @@ -62,7 +64,14 @@ module_param(dbglvl, int, 0); MODULE_PARM_DESC(dbglvl, "debug level (0 is disabled)"); +static int xdjtrsh = DEFAULT_X_JITTER_TRESHOLD; +module_param(xdjtrsh, int, 0); +MODULE_PARM_DESC(ptrsh, "treshold for x coordinates jitter"); +static int ydjtrsh = DEFAULT_Y_JITTER_TRESHOLD; +module_param(ydjtrsh, int, 0); +MODULE_PARM_DESC(ptrsh, "treshold for y coordinates jitter"); + static DECLARE_MUTEX_LOCKED(queue_sem); static DECLARE_MUTEX(digitiser_sem); static DECLARE_MUTEX(battery_update_mutex); @@ -79,6 +88,9 @@ static int previous_voltage; static u16 d2base; +static int lastx = 0; +static int lasty = 0; + #if defined(CONFIG_APM) || defined(CONFIG_APM_MODULE) /* original APM hook */ static void (*apm_get_power_status_orig)(struct apm_power_info *info); @@ -329,37 +341,33 @@ static void palmld_ac97_pendown(struct device *dev) { - //ac97_t *ac97 = dev->platform_data; int xread, yread, pressure; + int xval, yval; int valid_coords=0, btn_pressed = 0; /* take readings until the pen goes up */ do { - //printk("wm9712: starting read\n"); - //down(&digitiser_sem); - - /* power up digitiser */ - //wm97xx_set_digitiser_power(dev, WM97XX_PRP_DET_DIG); - /* take readings */ xread = palmld_ac97_take_reading(dev, WM97XX_ADCSEL_X); yread = palmld_ac97_take_reading(dev, WM97XX_ADCSEL_Y); pressure = palmld_ac97_take_reading(dev, WM97XX_ADCSEL_PRES); - /* power down digitiser to conserve power */ - //wm97xx_set_digitiser_power(dev, WM97XX_PRP_DET); - //up(&digitiser_sem); - - valid_coords = (xread & 0xfff) && (yread & 0xfff) && (pressure & 0xfff); - - if(valid_coords && (pressure < ptrsh)) { + //valid_coords = (xread & 0xfff) && (yread & 0xfff) && (pressure & 0xfff); + xval = xread & 0xfff; + yval = yread & 0xfff; + valid_coords = (xval) && (yval) && (pressure & 0xfff); + + if(valid_coords && (pressure < ptrsh)) { + if(abs(xval - lastx) <= xdjtrsh){ xval = lastx; } + if(abs(yval - lasty) <= ydjtrsh){ yval = lasty; } btn_pressed = 1; input_report_key(palmld_ac97_input, BTN_TOUCH, 1); - input_report_abs(palmld_ac97_input, ABS_X, xread & 0xfff); - input_report_abs(palmld_ac97_input, ABS_Y, yread & 0xfff); + input_report_abs(palmld_ac97_input, ABS_X, xval); + input_report_abs(palmld_ac97_input, ABS_Y, yval); input_report_abs(palmld_ac97_input, ABS_PRESSURE, pressure & 0xfff); - //printk("x: %d, y=%d, p=%d\n", xread, yread, pressure); input_sync(palmld_ac97_input); + lastx = xval; + lasty = yval; set_current_state(TASK_INTERRUPTIBLE); schedule_timeout(HZ/100); @@ -374,6 +382,8 @@ input_report_abs(palmld_ac97_input, ABS_Y, 0); input_report_abs(palmld_ac97_input, ABS_PRESSURE, 0); input_sync(palmld_ac97_input); + lastx = 0; + lasty = 0; } } @@ -390,9 +400,9 @@ if(polarity & levels & WM97XX_GPIO_13) { // power up digitiser: - // test if doing it for all read cycle helps down(&digitiser_sem); wm97xx_set_digitiser_power(dev, WM97XX_PRP_DET_DIG); + palmld_ac97_pendown(dev); /* power down digitiser to conserve power */ @@ -435,9 +445,7 @@ if(!machine_is_xscale_palmtx()) return -ENODEV; - //printk("palmld_ac97_probe: start\n"); - - /* for use by bettery level monitor */ + /* for use by battery level monitor */ palmld_ac97_dev = dev; set_irq_type(IRQ_GPIO_PALMTX_WM9712_IRQ, IRQT_RISING); @@ -453,7 +461,7 @@ ac97->bus->ops->write(ac97, 0x54, 0); /* disable digitiser to save power, enable pen-down detect */ - d2 = ac97->bus->ops->read(ac97, AC97_WM97XX_DIGITISER2); + d2 = DIG2_INIT; d2 |= WM97XX_PRP_DET; d2base = d2; ac97->bus->ops->write(ac97, AC97_WM97XX_DIGITISER2, d2); @@ -468,40 +476,24 @@ wm97xx_gpio_mode(ac97, WM97XX_GPIO_13, WM97XX_GPIO_IN, WM97XX_GPIO_POL_HIGH, WM97XX_GPIO_STICKY, WM97XX_GPIO_WAKE); - /* enable ada detect interrupt */ - /* - wm97xx_gpio_mode(ac97, WM97XX_GPIO_12, WM97XX_GPIO_IN, - WM97XX_GPIO_POL_HIGH, WM97XX_GPIO_NOTSTICKY, WM97XX_GPIO_NOWAKE); - */ - /* turn off irq gpio inverting */ ac97->bus->ops->write(ac97, 0x58, ac97->bus->ops->read(ac97, 0x58)&~1); - /* turn on the digitiser and pen down detector */ d2 = ac97->bus->ops->read(ac97, AC97_WM97XX_DIGITISER2); d2 |= WM97XX_PRP_DETW; ac97->bus->ops->write(ac97, AC97_WM97XX_DIGITISER2, d2); - // init the digitiser - //d2 = WM97XX_RPR | (1&0x3f); - //d2 |= WM9712_PIL; - - //d2 |= WM97XX_PRP_DETW; - //ac97->bus->ops->write(ac97, AC97_WM97XX_DIGITISER2, d2); - - /* setup the input device */ palmld_ac97_input = input_allocate_device(); palmld_ac97_input->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); - //palmld_ac97_input->evbit[0] = BIT(EV_ABS); palmld_ac97_input->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); input_set_abs_params(palmld_ac97_input, ABS_X, X_AXIS_MIN, X_AXIS_MAX, 0, 0); input_set_abs_params(palmld_ac97_input, ABS_Y, Y_AXIS_MIN, Y_AXIS_MAX, 0, 0); input_set_abs_params(palmld_ac97_input, ABS_PRESSURE, PRESSURE_MIN, PRESSURE_MAX, 0, 0); - palmld_ac97_input->name = "Palm TX touchscreen (Wolfson WM9712G)"; + palmld_ac97_input->name = "Palm TX touchscreen (Wolfson WM9712)"; palmld_ac97_input->dev = dev; palmld_ac97_input->id.bustype = BUS_HOST; input_register_device(palmld_ac97_input); @@ -514,8 +506,6 @@ palmld_ac97_workqueue = create_workqueue(palmld_ac97_WORK_QUEUE_NAME); INIT_WORK(&palmld_ac97_irq_task, palmld_ac97_irq_work, dev); - - /* register battery */ if(battery_class_register(&palmld_battery)) { @@ -527,7 +517,6 @@ } - //printk("palmld_ac97_probe: end\n"); up(&queue_sem); return 0; } @@ -542,7 +531,7 @@ } static struct device_driver palmld_ac97_driver = { - .name = "WM9712G", + .name = "WM9712", .bus = &ac97_bus_type, .probe = palmld_ac97_probe, .remove = palmld_ac97_remove, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cri...@us...> - 2006-08-25 18:52:27
|
Revision: 555 Author: cristianop Date: 2006-08-25 11:52:15 -0700 (Fri, 25 Aug 2006) ViewCVS: http://svn.sourceforge.net/hackndev/?rev=555&view=rev Log Message: ----------- palmtx: fixed parameters' names Modified Paths: -------------- linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmld_ac97.c Modified: linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmld_ac97.c =================================================================== --- linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmld_ac97.c 2006-08-21 17:15:17 UTC (rev 554) +++ linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmld_ac97.c 2006-08-25 18:52:15 UTC (rev 555) @@ -66,11 +66,11 @@ static int xdjtrsh = DEFAULT_X_JITTER_TRESHOLD; module_param(xdjtrsh, int, 0); -MODULE_PARM_DESC(ptrsh, "treshold for x coordinates jitter"); +MODULE_PARM_DESC(xdjtrsh, "treshold for x coordinates jitter"); static int ydjtrsh = DEFAULT_Y_JITTER_TRESHOLD; module_param(ydjtrsh, int, 0); -MODULE_PARM_DESC(ptrsh, "treshold for y coordinates jitter"); +MODULE_PARM_DESC(ydjtrsh, "treshold for y coordinates jitter"); static DECLARE_MUTEX_LOCKED(queue_sem); static DECLARE_MUTEX(digitiser_sem); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cri...@us...> - 2006-08-26 15:51:20
|
Revision: 558 Author: cristianop Date: 2006-08-26 08:51:13 -0700 (Sat, 26 Aug 2006) ViewCVS: http://svn.sourceforge.net/hackndev/?rev=558&view=rev Log Message: ----------- palmtx: handling jitter with input's absfuzz Modified Paths: -------------- linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmld_ac97.c Modified: linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmld_ac97.c =================================================================== --- linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmld_ac97.c 2006-08-26 13:58:50 UTC (rev 557) +++ linux4palm/linux/trunk/arch/arm/mach-pxa/palmtx/palmld_ac97.c 2006-08-26 15:51:13 UTC (rev 558) @@ -36,23 +36,22 @@ #include <sound/initval.h> #include <sound/ac97_codec.h> - -#define X_AXIS_MAX 3630 //3900 //3630 -#define X_AXIS_MIN 200 //350 //200 -#define Y_AXIS_MAX 3880 //3750 //3880 -#define Y_AXIS_MIN 160 //320 //160 +#define X_AXIS_MAX 3900 //3630 +#define X_AXIS_MIN 350 //200 +#define Y_AXIS_MAX 3750 //3880 +#define Y_AXIS_MIN 320 //160 #define PRESSURE_MIN 0 #define PRESSURE_MAX 150 //300 #define DIG2_INIT 0x0001 /* initial value for digitiser2 register */ -#define WM9712_PIL 0x00100 -#define WM97XX_POLL 0x8000 /* initiate a polling measurement */ -#define AC97_LINK_FRAME 21 /* time in uS for AC97 link frame */ -#define DEFAULT_PRESSURE_TRESHOLD 45160 /* default pressure treshold for pen up/down */ -#define DEFAULT_X_JITTER_TRESHOLD 5; -#define DEFAULT_Y_JITTER_TRESHOLD 35; +#define AC97_LINK_FRAME 21 /* time in uS for AC97 link frame */ +#define DEFAULT_PRESSURE_TRESHOLD 45160 /* default pressure treshold for pen up/down */ +#define DEFAULT_X_AXIS_FUZZ 5 /* default x axis noise treshold */ +#define DEFAULT_Y_AXIS_FUZZ 35 /* default y axis noise treshold */ +#define PRESSURE_FUZZ 5 /* default pressure noise treshold */ + #define palmld_ac97_WORK_QUEUE_NAME "palmld_ac97.c" @@ -64,19 +63,18 @@ module_param(dbglvl, int, 0); MODULE_PARM_DESC(dbglvl, "debug level (0 is disabled)"); -static int xdjtrsh = DEFAULT_X_JITTER_TRESHOLD; +static int xdjtrsh = DEFAULT_X_AXIS_FUZZ; module_param(xdjtrsh, int, 0); -MODULE_PARM_DESC(xdjtrsh, "treshold for x coordinates jitter"); +MODULE_PARM_DESC(xdjtrsh, "treshold for x axis jitter"); -static int ydjtrsh = DEFAULT_Y_JITTER_TRESHOLD; +static int ydjtrsh = DEFAULT_Y_AXIS_FUZZ; module_param(ydjtrsh, int, 0); -MODULE_PARM_DESC(ydjtrsh, "treshold for y coordinates jitter"); +MODULE_PARM_DESC(ydjtrsh, "treshold for y axis jitter"); static DECLARE_MUTEX_LOCKED(queue_sem); static DECLARE_MUTEX(digitiser_sem); static DECLARE_MUTEX(battery_update_mutex); - static struct workqueue_struct *palmld_ac97_workqueue; static struct work_struct palmld_ac97_irq_task; @@ -88,8 +86,6 @@ static int previous_voltage; static u16 d2base; -static int lastx = 0; -static int lasty = 0; #if defined(CONFIG_APM) || defined(CONFIG_APM_MODULE) /* original APM hook */ @@ -111,7 +107,8 @@ GEn &= ~gpio; ac97->bus->ops->write(ac97, 0x56, GEn); } - + + void wm97xx_gpio_mode(ac97_t *ac97, int gpio, int config, int polarity, int sticky, int wakeup) { @@ -147,15 +144,15 @@ ac97->bus->ops->write(ac97, 0x52, GWn); } + static void wm97xx_set_digitiser_power(struct device *dev, int value) { ac97_t *ac97 = dev->platform_data; - u16 d2 = d2base; - - d2 |= value; - ac97->bus->ops->write(ac97, AC97_WM97XX_DIGITISER2, d2); + + ac97->bus->ops->write(ac97, AC97_WM97XX_DIGITISER2, d2base | value); } + /* * note: for the TX there's some code that gets enabled in linux/sound/pxa2xx-ac97.c * (ifdef CONFIG_MACH_PALMTX) that tries to implement some recommended procedure for @@ -163,7 +160,6 @@ * (PXA27x Specification Update: 28007109.pdf sec.: E54) */ - static int palmld_ac97_take_reading(struct device *dev, int adcsel) { ac97_t *ac97 = dev->platform_data; @@ -171,33 +167,34 @@ u16 r76 = 0; u16 r7a; - r76 |= adcsel; /* set ADCSEL */ - r76 |= WM97XX_DELAY(3); /* set DELAY */ - r76 &= ~(1<<11); /* COO = 0 (single measurement) */ - r76 &= ~(1<<10); /* CTC = 0 (polling mode) */ - r76 |= (1<<15); /* start reading */ + r76 |= adcsel; /* set ADCSEL (ADC source) */ + r76 |= WM97XX_DELAY(3); /* set settling time delay DELAY */ + r76 &= ~(1<<11); /* COO = 0 (single measurement) */ + r76 &= ~(1<<10); /* CTC = 0 (polling mode) */ + r76 |= (1<<15); /* initiate measurement (POLL) */ ac97->bus->ops->write(ac97, 0x76, r76); - // some code from the the wolfson' driver + // wait settling time udelay ((3 * AC97_LINK_FRAME) + 167); /* wait for POLL to go low */ - while((ac97->bus->ops->read(ac97, 0x76) & 0x8000) && timeout){ udelay(AC97_LINK_FRAME); timeout--; } if (timeout == 0){ - printk("wm9712: discarding reading due to poll wait timout on 0x76\n"); + printk("wm9712: discarding reading due to POLL wait timout on 0x76\n"); return 0; } r7a = ac97->bus->ops->read(ac97, 0x7a); - // todo: print an error here - if ((r7a & WM97XX_ADCSEL_MASK) != adcsel) + + if ((r7a & WM97XX_ADCSEL_MASK) != adcsel){ + printk("wm9712: discarding reading -> wrong ADC source\n"); return 0; - + } + return (int) r7a; } @@ -255,14 +252,17 @@ { return PALMTX_BAT_MIN_VOLTAGE; } + int get_min_charge(struct battery *b) { return PALMTX_BAT_MIN_CHARGE; } + int get_max_voltage(struct battery *b) { return PALMTX_BAT_MAX_VOLTAGE; /* mV */ } + int get_max_charge(struct battery *b) { return PALMTX_BAT_MAX_CHARGE; @@ -280,6 +280,7 @@ { return 0; } + int get_status(struct battery *b) { int ac_connected = 0; @@ -342,7 +343,6 @@ static void palmld_ac97_pendown(struct device *dev) { int xread, yread, pressure; - int xval, yval; int valid_coords=0, btn_pressed = 0; /* take readings until the pen goes up */ @@ -352,22 +352,15 @@ yread = palmld_ac97_take_reading(dev, WM97XX_ADCSEL_Y); pressure = palmld_ac97_take_reading(dev, WM97XX_ADCSEL_PRES); - //valid_coords = (xread & 0xfff) && (yread & 0xfff) && (pressure & 0xfff); - xval = xread & 0xfff; - yval = yread & 0xfff; - valid_coords = (xval) && (yval) && (pressure & 0xfff); + valid_coords = (xread & 0xfff) && (yread & 0xfff) && (pressure & 0xfff); if(valid_coords && (pressure < ptrsh)) { - if(abs(xval - lastx) <= xdjtrsh){ xval = lastx; } - if(abs(yval - lasty) <= ydjtrsh){ yval = lasty; } btn_pressed = 1; input_report_key(palmld_ac97_input, BTN_TOUCH, 1); - input_report_abs(palmld_ac97_input, ABS_X, xval); - input_report_abs(palmld_ac97_input, ABS_Y, yval); + input_report_abs(palmld_ac97_input, ABS_X, xread & 0xfff); + input_report_abs(palmld_ac97_input, ABS_Y, yread & 0xfff); input_report_abs(palmld_ac97_input, ABS_PRESSURE, pressure & 0xfff); input_sync(palmld_ac97_input); - lastx = xval; - lasty = yval; set_current_state(TASK_INTERRUPTIBLE); schedule_timeout(HZ/100); @@ -382,12 +375,11 @@ input_report_abs(palmld_ac97_input, ABS_Y, 0); input_report_abs(palmld_ac97_input, ABS_PRESSURE, 0); input_sync(palmld_ac97_input); - lastx = 0; - lasty = 0; } } + static void palmld_ac97_irq_work(void *data) { struct device *dev = data; @@ -421,12 +413,9 @@ enable_irq(IRQ_GPIO_PALMTX_WM9712_IRQ); } + static irqreturn_t palmld_ac97_irq_handler(int irq, void *dev_id, struct pt_regs *regs) { - /* - * we can't use ac97 from within the interrupt handler, so schedule a task - * to do the actual handling. - */ if (down_trylock(&queue_sem) == 0){ disable_irq(IRQ_GPIO_PALMTX_WM9712_IRQ); queue_work(palmld_ac97_workqueue, &palmld_ac97_irq_task); @@ -440,7 +429,7 @@ { int err; ac97_t *ac97 = dev->platform_data; - u16 d2; // init d1 too? + u16 d2 = DIG2_INIT; // init d1 too? if(!machine_is_xscale_palmtx()) return -ENODEV; @@ -461,12 +450,10 @@ ac97->bus->ops->write(ac97, 0x54, 0); /* disable digitiser to save power, enable pen-down detect */ - d2 = DIG2_INIT; d2 |= WM97XX_PRP_DET; d2base = d2; - ac97->bus->ops->write(ac97, AC97_WM97XX_DIGITISER2, d2); + ac97->bus->ops->write(ac97, AC97_WM97XX_DIGITISER2, d2base); - /* enable interrupts on codec's gpio 2 (connected to cpu gpio 27) */ wm97xx_gpio_mode(ac97, WM97XX_GPIO_2, WM97XX_GPIO_IN, WM97XX_GPIO_POL_HIGH, WM97XX_GPIO_NOTSTICKY, WM97XX_GPIO_NOWAKE); @@ -475,23 +462,22 @@ /* enable pen detect interrupt */ wm97xx_gpio_mode(ac97, WM97XX_GPIO_13, WM97XX_GPIO_IN, WM97XX_GPIO_POL_HIGH, WM97XX_GPIO_STICKY, WM97XX_GPIO_WAKE); + /* turn off irq gpio inverting */ ac97->bus->ops->write(ac97, 0x58, ac97->bus->ops->read(ac97, 0x58)&~1); /* turn on the digitiser and pen down detector */ - d2 = ac97->bus->ops->read(ac97, AC97_WM97XX_DIGITISER2); - d2 |= WM97XX_PRP_DETW; - ac97->bus->ops->write(ac97, AC97_WM97XX_DIGITISER2, d2); + ac97->bus->ops->write(ac97, AC97_WM97XX_DIGITISER2, d2base | WM97XX_PRP_DETW); /* setup the input device */ palmld_ac97_input = input_allocate_device(); palmld_ac97_input->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); palmld_ac97_input->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); - input_set_abs_params(palmld_ac97_input, ABS_X, X_AXIS_MIN, X_AXIS_MAX, 0, 0); - input_set_abs_params(palmld_ac97_input, ABS_Y, Y_AXIS_MIN, Y_AXIS_MAX, 0, 0); - input_set_abs_params(palmld_ac97_input, ABS_PRESSURE, PRESSURE_MIN, PRESSURE_MAX, 0, 0); + input_set_abs_params(palmld_ac97_input, ABS_X, X_AXIS_MIN, X_AXIS_MAX, xdjtrsh, 0); + input_set_abs_params(palmld_ac97_input, ABS_Y, Y_AXIS_MIN, Y_AXIS_MAX, ydjtrsh, 0); + input_set_abs_params(palmld_ac97_input, ABS_PRESSURE, PRESSURE_MIN, PRESSURE_MAX, PRESSURE_FUZZ, 0); palmld_ac97_input->name = "Palm TX touchscreen (Wolfson WM9712)"; palmld_ac97_input->dev = dev; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |