Revision bc24a225 hw/tsc2005.c
b/hw/tsc2005.c | ||
---|---|---|
26 | 26 |
|
27 | 27 |
#define TSC_CUT_RESOLUTION(value, p) ((value) >> (16 - (p ? 12 : 10))) |
28 | 28 |
|
29 |
struct tsc2005_state_s {
|
|
29 |
typedef struct {
|
|
30 | 30 |
qemu_irq pint; /* Combination of the nPENIRQ and DAV signals */ |
31 | 31 |
QEMUTimer *timer; |
32 | 32 |
uint16_t model; |
... | ... | |
55 | 55 |
uint16_t aux_thr[2]; |
56 | 56 |
|
57 | 57 |
int tr[8]; |
58 |
}; |
|
58 |
} TSC2005State;
|
|
59 | 59 |
|
60 | 60 |
enum { |
61 | 61 |
TSC_MODE_XYZ_SCAN = 0x0, |
... | ... | |
108 | 108 |
#define TEMP1_VAL (1264 << 4) /* +/- 5 at 12-bit */ |
109 | 109 |
#define TEMP2_VAL (1531 << 4) /* +/- 5 at 12-bit */ |
110 | 110 |
|
111 |
static uint16_t tsc2005_read(struct tsc2005_state_s *s, int reg)
|
|
111 |
static uint16_t tsc2005_read(TSC2005State *s, int reg)
|
|
112 | 112 |
{ |
113 | 113 |
uint16_t ret; |
114 | 114 |
|
... | ... | |
178 | 178 |
return 0xffff; |
179 | 179 |
} |
180 | 180 |
|
181 |
static void tsc2005_write(struct tsc2005_state_s *s, int reg, uint16_t data)
|
|
181 |
static void tsc2005_write(TSC2005State *s, int reg, uint16_t data)
|
|
182 | 182 |
{ |
183 | 183 |
switch (reg) { |
184 | 184 |
case 0x8: /* AUX high treshold */ |
... | ... | |
226 | 226 |
} |
227 | 227 |
|
228 | 228 |
/* This handles most of the chip's logic. */ |
229 |
static void tsc2005_pin_update(struct tsc2005_state_s *s)
|
|
229 |
static void tsc2005_pin_update(TSC2005State *s)
|
|
230 | 230 |
{ |
231 | 231 |
int64_t expires; |
232 | 232 |
int pin_state; |
... | ... | |
295 | 295 |
qemu_mod_timer(s->timer, expires); |
296 | 296 |
} |
297 | 297 |
|
298 |
static void tsc2005_reset(struct tsc2005_state_s *s)
|
|
298 |
static void tsc2005_reset(TSC2005State *s)
|
|
299 | 299 |
{ |
300 | 300 |
s->state = 0; |
301 | 301 |
s->pin_func = 0; |
... | ... | |
321 | 321 |
|
322 | 322 |
static uint8_t tsc2005_txrx_word(void *opaque, uint8_t value) |
323 | 323 |
{ |
324 |
struct tsc2005_state_s *s = opaque;
|
|
324 |
TSC2005State *s = opaque;
|
|
325 | 325 |
uint32_t ret = 0; |
326 | 326 |
|
327 | 327 |
switch (s->state ++) { |
... | ... | |
399 | 399 |
|
400 | 400 |
static void tsc2005_timer_tick(void *opaque) |
401 | 401 |
{ |
402 |
struct tsc2005_state_s *s = opaque;
|
|
402 |
TSC2005State *s = opaque;
|
|
403 | 403 |
|
404 | 404 |
/* Timer ticked -- a set of conversions has been finished. */ |
405 | 405 |
|
... | ... | |
415 | 415 |
static void tsc2005_touchscreen_event(void *opaque, |
416 | 416 |
int x, int y, int z, int buttons_state) |
417 | 417 |
{ |
418 |
struct tsc2005_state_s *s = opaque;
|
|
418 |
TSC2005State *s = opaque;
|
|
419 | 419 |
int p = s->pressure; |
420 | 420 |
|
421 | 421 |
if (buttons_state) { |
... | ... | |
435 | 435 |
|
436 | 436 |
static void tsc2005_save(QEMUFile *f, void *opaque) |
437 | 437 |
{ |
438 |
struct tsc2005_state_s *s = (struct tsc2005_state_s *) opaque;
|
|
438 |
TSC2005State *s = (TSC2005State *) opaque;
|
|
439 | 439 |
int i; |
440 | 440 |
|
441 | 441 |
qemu_put_be16(f, s->x); |
... | ... | |
476 | 476 |
|
477 | 477 |
static int tsc2005_load(QEMUFile *f, void *opaque, int version_id) |
478 | 478 |
{ |
479 |
struct tsc2005_state_s *s = (struct tsc2005_state_s *) opaque;
|
|
479 |
TSC2005State *s = (TSC2005State *) opaque;
|
|
480 | 480 |
int i; |
481 | 481 |
|
482 | 482 |
s->x = qemu_get_be16(f); |
... | ... | |
522 | 522 |
|
523 | 523 |
void *tsc2005_init(qemu_irq pintdav) |
524 | 524 |
{ |
525 |
struct tsc2005_state_s *s;
|
|
525 |
TSC2005State *s;
|
|
526 | 526 |
|
527 |
s = (struct tsc2005_state_s *)
|
|
528 |
qemu_mallocz(sizeof(struct tsc2005_state_s));
|
|
527 |
s = (TSC2005State *)
|
|
528 |
qemu_mallocz(sizeof(TSC2005State));
|
|
529 | 529 |
s->x = 400; |
530 | 530 |
s->y = 240; |
531 | 531 |
s->pressure = 0; |
... | ... | |
559 | 559 |
* from the touchscreen. Assuming 12-bit precision was used during |
560 | 560 |
* tslib calibration. |
561 | 561 |
*/ |
562 |
void tsc2005_set_transform(void *opaque, struct mouse_transform_info_s *info)
|
|
562 |
void tsc2005_set_transform(void *opaque, MouseTransformInfo *info)
|
|
563 | 563 |
{ |
564 |
struct tsc2005_state_s *s = (struct tsc2005_state_s *) opaque;
|
|
564 |
TSC2005State *s = (TSC2005State *) opaque;
|
|
565 | 565 |
|
566 | 566 |
/* This version assumes touchscreen X & Y axis are parallel or |
567 | 567 |
* perpendicular to LCD's X & Y axis in some way. */ |
Also available in: Unified diff