1
From 2c7c6abd1c972d177e73853eaf750ed3216c18f5 Mon Sep 17 00:00:00 2001
2
From: =?UTF-8?q?Juha=20Riihim=C3=A4ki?= <juha.riihimaki@nokia.com>
3
Date: Mon, 18 Feb 2013 16:58:28 +0000
4
Subject: [PATCH 27/70] tsc2005: rearrange pin_update/timer_tick
6
Rearrange the division of work between pin_update and
9
TODO: this has the look of a bug fix but I have not identified what.
11
hw/input/tsc2005.c | 74 +++++++++++++++++++++++++++++++-----------------------
12
1 file changed, 43 insertions(+), 31 deletions(-)
14
diff --git a/hw/input/tsc2005.c b/hw/input/tsc2005.c
15
index 50f8163..7554fb6 100644
16
--- a/hw/input/tsc2005.c
17
+++ b/hw/input/tsc2005.c
19
* TI TSC2005 emulator.
21
* Copyright (c) 2006 Andrzej Zaborowski <balrog@zabor.org>
22
- * Copyright (C) 2008 Nokia Corporation
23
+ * Copyright (c) 2009-2010 Nokia Corporation
25
* This program is free software; you can redistribute it and/or
26
* modify it under the terms of the GNU General Public License as
27
@@ -274,29 +274,16 @@ static void tsc2005_write(TSC2005State *s, int reg, uint16_t data)
28
static void tsc2005_pin_update(TSC2005State *s)
33
- switch (s->pin_func) {
35
- pin_state = !s->pressure && !!s->dav;
40
- pin_state = !s->dav;
43
- pin_state = !s->pressure;
46
- if (pin_state != s->irq) {
48
- qemu_set_irq(s->pint, s->irq);
51
+ TRACE("nextf=%d, press=%d, ena=%d, busy=%d, dav=0x%04x, irq=%d",
52
+ s->nextfunction, s->pressure, s->enabled, s->busy, s->dav, s->irq);
53
switch (s->nextfunction) {
54
case TSC_MODE_XYZ_SCAN:
55
case TSC_MODE_XY_SCAN:
56
+ if (!s->pin_func && !s->dav) {
57
+ TRACE("all values read, lowering irq");
59
+ qemu_set_irq(s->pint, s->irq);
61
if (!s->host_mode && s->dav)
64
@@ -329,15 +316,15 @@ static void tsc2005_pin_update(TSC2005State *s)
68
- if (!s->enabled || s->busy)
72
- s->precision = s->nextprecision;
73
- s->function = s->nextfunction;
74
- s->pdst = !s->pnd0; /* Synchronised on internal clock */
75
- expires = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + (get_ticks_per_sec() >> 7);
76
- timer_mod(s->timer, expires);
77
+ if (s->enabled && !s->busy) {
79
+ s->precision = s->nextprecision;
80
+ s->function = s->nextfunction;
81
+ s->pdst = !s->pnd0; /* Synchronised on internal clock */
82
+ expires = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL)
83
+ + (get_ticks_per_sec() >> 7);
84
+ timer_mod(s->timer, expires);
88
static void tsc2005_reset(TSC2005State *s)
89
@@ -444,6 +431,7 @@ uint32_t tsc2005_txrx(void *opaque, uint32_t value, int len)
91
static void tsc2005_timer_tick(void *opaque)
94
TSC2005State *s = opaque;
96
/* Timer ticked -- a set of conversions has been finished. */
97
@@ -453,10 +441,34 @@ static void tsc2005_timer_tick(void *opaque)
101
+ switch (s->pin_func) {
103
+ pin_state = s->pressure || !s->dav;
108
+ pin_state = !s->dav;
111
+ pin_state = s->pressure;
114
- s->dav |= mode_regs[s->function];
116
+ TRACE("report new conversions ready");
117
+ s->dav |= mode_regs[s->function];
119
+ TRACE("pin_func=%d, pin_state=%d, pressure=%d, irq=%d, dav=0x%04x",
120
+ s->pin_func, pin_state, s->pressure, s->irq, s->dav);
122
tsc2005_pin_update(s);
124
+ if (pin_state != s->irq) {
125
+ TRACE("changing IRQ state to %d", pin_state);
126
+ s->irq = pin_state;
127
+ qemu_set_irq(s->pint, s->irq);
132
static void tsc2005_touchscreen_event(void *opaque,