~vcs-imports/qemu/maemo

« back to all changes in this revision

Viewing changes to hw/tsc2005.c

  • Committer: Riku Voipio
  • Date: 2009-06-08 15:31:58 UTC
  • mfrom: (6281.2.366)
  • mto: This revision was merged to the branch mainline in revision 6452.
  • Revision ID: git-v1:759b334a9739814df2883aa4c41b1c0f5670e90a
Merge commit 'gnu/master' into test

Epic merge

Conflicts:
        Makefile
        block.c
        block.h
        configure
        hw/boards.h
        hw/flash.h
        hw/integratorcp.c
        hw/nand.c
        hw/omap2.c
        hw/omap_i2c.c
        hw/sd.c
        hw/smc91c111.c
        hw/tsc2005.c
        hw/tusb6010.c
        hw/usb-musb.c
        linux-user/syscall.c
        target-arm/machine.c
        target-arm/translate.c

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
276
276
    qemu_mod_timer(s->timer, expires);
277
277
}
278
278
 
279
 
static void tsc2005_reset(struct tsc2005_state_s *s)
 
279
static void tsc2005_reset(TSC2005State *s)
280
280
{
281
281
    s->state = 0;
282
282
    s->pin_func = 0;
302
302
 
303
303
static uint8_t tsc2005_txrx_word(void *opaque, uint8_t value)
304
304
{
305
 
    struct tsc2005_state_s *s = opaque;
 
305
    TSC2005State *s = opaque;
306
306
    uint32_t ret = 0;
307
307
 
308
308
    switch (s->state ++) {
380
380
 
381
381
static void tsc2005_timer_tick(void *opaque)
382
382
{
383
 
    struct tsc2005_state_s *s = opaque;
 
383
    TSC2005State *s = opaque;
384
384
        int pin_state;
385
385
 
386
386
    /* Timer ticked -- a set of conversions has been finished.  */
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;
548
548
    qemu_add_mouse_event_handler(tsc2005_touchscreen_event, s, 1,
549
549
                    "QEMU TSC2005-driven Touchscreen");
550
550
 
551
 
    qemu_register_reset((void *) tsc2005_reset, s);
 
551
    qemu_register_reset((void *) tsc2005_reset, 0, s);
552
552
    register_savevm("tsc2005", -1, 0, tsc2005_save, tsc2005_load, s);
553
553
 
554
554
    return s;
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.  */