diff options
author | Wolfram Sang <w.sang@pengutronix.de> | 2011-07-04 22:22:00 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2011-07-04 22:31:38 -0400 |
commit | c8f205258bc8942e79cd37ebc1c8ec4652a1a501 (patch) | |
tree | f8851068e51f6b9575ef9778c7f24f4ba1a9aba3 /drivers/input | |
parent | 2456689b3b11ddecc091cd5f00b9adea6a9854cf (diff) |
Input: wm97xx - refactor channel selection in poll_sample()
The current implementation of poll_sample() has the problem that one of
its arguments, the channel to be selected, differs from wm9713 to other
variants. This parameter gets passed to the (currently unused)
mach-specific functions pre_sample() and post_sample() which thus have
to deal with codec-specific differences. Refactor the routine so that
the argument to poll_sample() is generic for all codecs and do necessary
conversions only in the codec-specific driver. The outcome even uses
less code and removes the non-standard use of the PEN_DOWN bit to mark
the AUX-channels.
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input')
-rw-r--r-- | drivers/input/touchscreen/wm9705.c | 14 | ||||
-rw-r--r-- | drivers/input/touchscreen/wm9712.c | 14 | ||||
-rw-r--r-- | drivers/input/touchscreen/wm9713.c | 18 |
3 files changed, 21 insertions, 25 deletions
diff --git a/drivers/input/touchscreen/wm9705.c b/drivers/input/touchscreen/wm9705.c index 98e61175d3f5..363d61dbe83c 100644 --- a/drivers/input/touchscreen/wm9705.c +++ b/drivers/input/touchscreen/wm9705.c | |||
@@ -224,13 +224,10 @@ static int wm9705_poll_sample(struct wm97xx *wm, int adcsel, int *sample) | |||
224 | } | 224 | } |
225 | 225 | ||
226 | /* set up digitiser */ | 226 | /* set up digitiser */ |
227 | if (adcsel & 0x8000) | ||
228 | adcsel = ((adcsel & 0x7fff) + 3) << 12; | ||
229 | |||
230 | if (wm->mach_ops && wm->mach_ops->pre_sample) | 227 | if (wm->mach_ops && wm->mach_ops->pre_sample) |
231 | wm->mach_ops->pre_sample(adcsel); | 228 | wm->mach_ops->pre_sample(adcsel); |
232 | wm97xx_reg_write(wm, AC97_WM97XX_DIGITISER1, | 229 | wm97xx_reg_write(wm, AC97_WM97XX_DIGITISER1, (adcsel & WM97XX_ADCSEL_MASK) |
233 | adcsel | WM97XX_POLL | WM97XX_DELAY(delay)); | 230 | | WM97XX_POLL | WM97XX_DELAY(delay)); |
234 | 231 | ||
235 | /* wait 3 AC97 time slots + delay for conversion */ | 232 | /* wait 3 AC97 time slots + delay for conversion */ |
236 | poll_delay(delay); | 233 | poll_delay(delay); |
@@ -256,9 +253,10 @@ static int wm9705_poll_sample(struct wm97xx *wm, int adcsel, int *sample) | |||
256 | wm->mach_ops->post_sample(adcsel); | 253 | wm->mach_ops->post_sample(adcsel); |
257 | 254 | ||
258 | /* check we have correct sample */ | 255 | /* check we have correct sample */ |
259 | if ((*sample & WM97XX_ADCSEL_MASK) != adcsel) { | 256 | if ((*sample ^ adcsel) & WM97XX_ADCSEL_MASK) { |
260 | dev_dbg(wm->dev, "adc wrong sample, read %x got %x", adcsel, | 257 | dev_dbg(wm->dev, "adc wrong sample, wanted %x got %x", |
261 | *sample & WM97XX_ADCSEL_MASK); | 258 | adcsel & WM97XX_ADCSEL_MASK, |
259 | *sample & WM97XX_ADCSEL_MASK); | ||
262 | return RC_PENUP; | 260 | return RC_PENUP; |
263 | } | 261 | } |
264 | 262 | ||
diff --git a/drivers/input/touchscreen/wm9712.c b/drivers/input/touchscreen/wm9712.c index 2bc2fb801009..d26093f479d1 100644 --- a/drivers/input/touchscreen/wm9712.c +++ b/drivers/input/touchscreen/wm9712.c | |||
@@ -264,13 +264,10 @@ static int wm9712_poll_sample(struct wm97xx *wm, int adcsel, int *sample) | |||
264 | } | 264 | } |
265 | 265 | ||
266 | /* set up digitiser */ | 266 | /* set up digitiser */ |
267 | if (adcsel & 0x8000) | ||
268 | adcsel = ((adcsel & 0x7fff) + 3) << 12; | ||
269 | |||
270 | if (wm->mach_ops && wm->mach_ops->pre_sample) | 267 | if (wm->mach_ops && wm->mach_ops->pre_sample) |
271 | wm->mach_ops->pre_sample(adcsel); | 268 | wm->mach_ops->pre_sample(adcsel); |
272 | wm97xx_reg_write(wm, AC97_WM97XX_DIGITISER1, | 269 | wm97xx_reg_write(wm, AC97_WM97XX_DIGITISER1, (adcsel & WM97XX_ADCSEL_MASK) |
273 | adcsel | WM97XX_POLL | WM97XX_DELAY(delay)); | 270 | | WM97XX_POLL | WM97XX_DELAY(delay)); |
274 | 271 | ||
275 | /* wait 3 AC97 time slots + delay for conversion */ | 272 | /* wait 3 AC97 time slots + delay for conversion */ |
276 | poll_delay(delay); | 273 | poll_delay(delay); |
@@ -296,9 +293,10 @@ static int wm9712_poll_sample(struct wm97xx *wm, int adcsel, int *sample) | |||
296 | wm->mach_ops->post_sample(adcsel); | 293 | wm->mach_ops->post_sample(adcsel); |
297 | 294 | ||
298 | /* check we have correct sample */ | 295 | /* check we have correct sample */ |
299 | if ((*sample & WM97XX_ADCSEL_MASK) != adcsel) { | 296 | if ((*sample ^ adcsel) & WM97XX_ADCSEL_MASK) { |
300 | dev_dbg(wm->dev, "adc wrong sample, read %x got %x", adcsel, | 297 | dev_dbg(wm->dev, "adc wrong sample, wanted %x got %x", |
301 | *sample & WM97XX_ADCSEL_MASK); | 298 | adcsel & WM97XX_ADCSEL_MASK, |
299 | *sample & WM97XX_ADCSEL_MASK); | ||
302 | return RC_PENUP; | 300 | return RC_PENUP; |
303 | } | 301 | } |
304 | 302 | ||
diff --git a/drivers/input/touchscreen/wm9713.c b/drivers/input/touchscreen/wm9713.c index 13cd9d1fa07a..a7558015429b 100644 --- a/drivers/input/touchscreen/wm9713.c +++ b/drivers/input/touchscreen/wm9713.c | |||
@@ -270,15 +270,14 @@ static int wm9713_poll_sample(struct wm97xx *wm, int adcsel, int *sample) | |||
270 | } | 270 | } |
271 | 271 | ||
272 | /* set up digitiser */ | 272 | /* set up digitiser */ |
273 | if (adcsel & 0x8000) | ||
274 | adcsel = 1 << ((adcsel & 0x7fff) + 3); | ||
275 | |||
276 | dig1 = wm97xx_reg_read(wm, AC97_WM9713_DIG1); | 273 | dig1 = wm97xx_reg_read(wm, AC97_WM9713_DIG1); |
277 | dig1 &= ~WM9713_ADCSEL_MASK; | 274 | dig1 &= ~WM9713_ADCSEL_MASK; |
275 | /* WM97XX_ADCSEL_* channels need to be converted to WM9713 format */ | ||
276 | dig1 |= 1 << ((adcsel & WM97XX_ADCSEL_MASK) >> 12); | ||
278 | 277 | ||
279 | if (wm->mach_ops && wm->mach_ops->pre_sample) | 278 | if (wm->mach_ops && wm->mach_ops->pre_sample) |
280 | wm->mach_ops->pre_sample(adcsel); | 279 | wm->mach_ops->pre_sample(adcsel); |
281 | wm97xx_reg_write(wm, AC97_WM9713_DIG1, dig1 | adcsel | WM9713_POLL); | 280 | wm97xx_reg_write(wm, AC97_WM9713_DIG1, dig1 | WM9713_POLL); |
282 | 281 | ||
283 | /* wait 3 AC97 time slots + delay for conversion */ | 282 | /* wait 3 AC97 time slots + delay for conversion */ |
284 | poll_delay(delay); | 283 | poll_delay(delay); |
@@ -304,8 +303,9 @@ static int wm9713_poll_sample(struct wm97xx *wm, int adcsel, int *sample) | |||
304 | wm->mach_ops->post_sample(adcsel); | 303 | wm->mach_ops->post_sample(adcsel); |
305 | 304 | ||
306 | /* check we have correct sample */ | 305 | /* check we have correct sample */ |
307 | if ((*sample & WM97XX_ADCSEL_MASK) != ffs(adcsel >> 1) << 12) { | 306 | if ((*sample ^ adcsel) & WM97XX_ADCSEL_MASK) { |
308 | dev_dbg(wm->dev, "adc wrong sample, read %x got %x", adcsel, | 307 | dev_dbg(wm->dev, "adc wrong sample, wanted %x got %x", |
308 | adcsel & WM97XX_ADCSEL_MASK, | ||
309 | *sample & WM97XX_ADCSEL_MASK); | 309 | *sample & WM97XX_ADCSEL_MASK); |
310 | return RC_PENUP; | 310 | return RC_PENUP; |
311 | } | 311 | } |
@@ -400,14 +400,14 @@ static int wm9713_poll_touch(struct wm97xx *wm, struct wm97xx_data *data) | |||
400 | if (rc != RC_VALID) | 400 | if (rc != RC_VALID) |
401 | return rc; | 401 | return rc; |
402 | } else { | 402 | } else { |
403 | rc = wm9713_poll_sample(wm, WM9713_ADCSEL_X, &data->x); | 403 | rc = wm9713_poll_sample(wm, WM97XX_ADCSEL_X, &data->x); |
404 | if (rc != RC_VALID) | 404 | if (rc != RC_VALID) |
405 | return rc; | 405 | return rc; |
406 | rc = wm9713_poll_sample(wm, WM9713_ADCSEL_Y, &data->y); | 406 | rc = wm9713_poll_sample(wm, WM97XX_ADCSEL_Y, &data->y); |
407 | if (rc != RC_VALID) | 407 | if (rc != RC_VALID) |
408 | return rc; | 408 | return rc; |
409 | if (pil) { | 409 | if (pil) { |
410 | rc = wm9713_poll_sample(wm, WM9713_ADCSEL_PRES, | 410 | rc = wm9713_poll_sample(wm, WM97XX_ADCSEL_PRES, |
411 | &data->p); | 411 | &data->p); |
412 | if (rc != RC_VALID) | 412 | if (rc != RC_VALID) |
413 | return rc; | 413 | return rc; |