/* * Set internal pull up for pen detect. * * Pull up is in the range 1.02k (least sensitive) to 64k (most sensitive) * i.e. pull up resistance = 64k Ohms / rpu. * * Adjust this value if you are having problems with pen detect not * detecting any down event.
*/ staticint rpu = 8;
module_param(rpu, int, 0);
MODULE_PARM_DESC(rpu, "Set internal pull up resistor for pen detect.");
/* * Set current used for pressure measurement. * * Set pil = 2 to use 400uA * pil = 1 to use 200uA and * pil = 0 to disable pressure measurement. * * This is used to increase the range of values returned by the adc * when measureing touchpanel pressure.
*/ staticint pil;
module_param(pil, int, 0);
MODULE_PARM_DESC(pil, "Set current used for pressure measurement.");
/* * Set threshold for pressure measurement. * * Pen down pressure below threshold is ignored.
*/ staticint pressure = DEFAULT_PRESSURE & 0xfff;
module_param(pressure, int, 0);
MODULE_PARM_DESC(pressure, "Set threshold for pressure measurement.");
/* * Set adc sample delay. * * For accurate touchpanel measurements, some settling time may be * required between the switch matrix applying a voltage across the * touchpanel plate and the ADC sampling the signal. * * This delay can be set by setting delay = n, where n is the array * position of the delay in the array delay_table below. * Long delays > 1ms are supported for completeness, but are not * recommended.
*/ staticint delay = 3;
module_param(delay, int, 0);
MODULE_PARM_DESC(delay, "Set adc sample delay.");
/* * Set five_wire = 1 to use a 5 wire touchscreen. * * NOTE: Five wire mode does not allow for readback of pressure.
*/ staticint five_wire;
module_param(five_wire, int, 0);
MODULE_PARM_DESC(five_wire, "Set to '1' to use 5-wire touchscreen.");
/* * Set adc mask function. * * Sources of glitch noise, such as signals driving an LCD display, may feed * through to the touch screen plates and affect measurement accuracy. In * order to minimise this, a signal may be applied to the MASK pin to delay or * synchronise the sampling. * * 0 = No delay or sync * 1 = High on pin stops conversions * 2 = Edge triggered, edge on pin delays conversion by delay param (above) * 3 = Edge triggered, edge on pin starts conversion after delay param
*/ staticint mask;
module_param(mask, int, 0);
MODULE_PARM_DESC(mask, "Set adc mask function.");
/* * Coordinate Polling Enable. * * Set to 1 to enable coordinate polling. e.g. x,y[,p] is sampled together * for every poll.
*/ staticint coord;
module_param(coord, int, 0);
MODULE_PARM_DESC(coord, "Polling coordinate mode");
/* * Read a sample from the WM9712 adc in polling mode.
*/ staticint wm9712_poll_sample(struct wm97xx *wm, int adcsel, int *sample)
{ int timeout = 5 * delay; bool wants_pen = adcsel & WM97XX_PEN_DOWN;
if (wants_pen && !wm->pen_probably_down) {
u16 data = wm97xx_reg_read(wm, AC97_WM97XX_DIGITISER_RD); if (!(data & WM97XX_PEN_DOWN)) return RC_PENUP;
wm->pen_probably_down = 1;
}
/* set up digitiser */ if (wm->mach_ops && wm->mach_ops->pre_sample)
wm->mach_ops->pre_sample(adcsel);
wm97xx_reg_write(wm, AC97_WM97XX_DIGITISER1, (adcsel & WM97XX_ADCSEL_MASK)
| WM97XX_POLL | WM97XX_DELAY(delay));
/* wait 3 AC97 time slots + delay for conversion */
poll_delay(delay);
/* wait for POLL to go low */ while ((wm97xx_reg_read(wm, AC97_WM97XX_DIGITISER1) & WM97XX_POLL)
&& timeout) {
udelay(AC97_LINK_FRAME);
timeout--;
}
if (timeout <= 0) { /* If PDEN is set, we can get a timeout when pen goes up */ if (is_pden(wm))
wm->pen_probably_down = 0; else
dev_dbg(wm->dev, "adc sample timeout\n"); return RC_PENUP;
}
*sample = wm97xx_reg_read(wm, AC97_WM97XX_DIGITISER_RD); if (wm->mach_ops && wm->mach_ops->post_sample)
wm->mach_ops->post_sample(adcsel);
if (wants_pen && !(*sample & WM97XX_PEN_DOWN)) { /* Sometimes it reads a wrong value the first time. */
*sample = wm97xx_reg_read(wm, AC97_WM97XX_DIGITISER_RD); if (!(*sample & WM97XX_PEN_DOWN)) {
wm->pen_probably_down = 0; return RC_PENUP;
}
}
return RC_VALID;
}
/* * Read a coord from the WM9712 adc in polling mode.
*/ staticint wm9712_poll_coord(struct wm97xx *wm, struct wm97xx_data *data)
{ int timeout = 5 * delay;
if (!wm->pen_probably_down) {
u16 data_rd = wm97xx_reg_read(wm, AC97_WM97XX_DIGITISER_RD); if (!(data_rd & WM97XX_PEN_DOWN)) return RC_PENUP;
wm->pen_probably_down = 1;
}
/* set up digitiser */ if (wm->mach_ops && wm->mach_ops->pre_sample)
wm->mach_ops->pre_sample(WM97XX_ADCSEL_X | WM97XX_ADCSEL_Y);
/* wait 3 AC97 time slots + delay for conversion and read x */
poll_delay(delay);
data->x = wm97xx_reg_read(wm, AC97_WM97XX_DIGITISER_RD); /* wait for POLL to go low */ while ((wm97xx_reg_read(wm, AC97_WM97XX_DIGITISER1) & WM97XX_POLL)
&& timeout) {
udelay(AC97_LINK_FRAME);
timeout--;
}
if (timeout <= 0) { /* If PDEN is set, we can get a timeout when pen goes up */ if (is_pden(wm))
wm->pen_probably_down = 0; else
dev_dbg(wm->dev, "adc sample timeout\n"); return RC_PENUP;
}
/* read back y data */
data->y = wm97xx_reg_read(wm, AC97_WM97XX_DIGITISER_RD); if (pil)
data->p = wm97xx_reg_read(wm, AC97_WM97XX_DIGITISER_RD); else
data->p = DEFAULT_PRESSURE;
if (wm->mach_ops && wm->mach_ops->post_sample)
wm->mach_ops->post_sample(WM97XX_ADCSEL_X | WM97XX_ADCSEL_Y);
/* check we have correct sample */ if (!(data->x & WM97XX_ADCSEL_X) || !(data->y & WM97XX_ADCSEL_Y)) goto err; if (pil && !(data->p & WM97XX_ADCSEL_PRES)) goto err;
/* * Enable WM9712 continuous mode, i.e. touch data is streamed across * an AC97 slot
*/ staticint wm9712_acc_enable(struct wm97xx *wm, int enable)
{
u16 dig1, dig2; int ret = 0;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.