~jderose/ubuntu/raring/qemu/vde-again

« back to all changes in this revision

Viewing changes to hw/ads7846.c

  • Committer: Bazaar Package Importer
  • Author(s): Riku Voipio, Josh Triplett, Riku Voipio
  • Date: 2009-07-29 13:28:05 UTC
  • mfrom: (1.4.1 upstream)
  • mto: (12.1.1 sid) (10.1.13 sid)
  • mto: This revision was merged to the branch mainline in revision 13.
  • Revision ID: james.westby@ubuntu.com-20090729132805-cau7rfexh7dawyb8
Tags: 0.10.50+git20090729-1
[ Josh Triplett ]
* Remove myself from Uploaders.

[ Riku Voipio ]
* new upstream RC version
* nuke all linux-user patches (applied upstream)
  06_exit_segfault
  12_signal_powerpc_support
  21_net_soopts
  30_syscall_ipc
  32_syscall_sysctl
  35_syscall_sockaddr
  48_signal_terminate
  55_unmux_socketcall
* nuke all other applied-upstream patches
  01_nostrip (better version upstream)
  07_i386_exec_name (can be reintroduced in debian/rules)
  50_linuxbios_isa_bios_ram (shouldn't be needed anymore)
  51_linuxbios_piix_ram_size (applied)
  56_dhcp (crap)
  60_ppc_ld (reintroduce if needed)
  64_ppc_asm_constraints (ditto)
  66_tls_ld.patch (ditto)
  81_compile_dtb.patch (applied upstream)
  82_qemu-img_decimal (ditto)
* move to git
* simplify build rules
* Correct my email address

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
 * This code is licensed under the GNU GPL v2.
8
8
 */
9
9
 
10
 
#include "hw.h"
11
 
#include "devices.h"
 
10
#include "ssi.h"
12
11
#include "console.h"
13
12
 
14
 
struct ads7846_state_s {
 
13
typedef struct {
 
14
    SSISlave ssidev;
15
15
    qemu_irq interrupt;
16
16
 
17
17
    int input[8];
20
20
 
21
21
    int cycle;
22
22
    int output;
23
 
};
 
23
} ADS7846State;
24
24
 
25
25
/* Control-byte bitfields */
26
26
#define CB_PD0          (1 << 0)
46
46
#define ADS_Z1POS(x, y) 600
47
47
#define ADS_Z2POS(x, y) (600 + 6000 / ADS_XPOS(x, y))
48
48
 
49
 
static void ads7846_int_update(struct ads7846_state_s *s)
 
49
static void ads7846_int_update(ADS7846State *s)
50
50
{
51
51
    if (s->interrupt)
52
52
        qemu_set_irq(s->interrupt, s->pressure == 0);
53
53
}
54
54
 
55
 
uint32_t ads7846_read(void *opaque)
56
 
{
57
 
    struct ads7846_state_s *s = (struct ads7846_state_s *) opaque;
58
 
 
59
 
    return s->output;
60
 
}
61
 
 
62
 
void ads7846_write(void *opaque, uint32_t value)
63
 
{
64
 
    struct ads7846_state_s *s = (struct ads7846_state_s *) opaque;
 
55
static uint32_t ads7846_transfer(SSISlave *dev, uint32_t value)
 
56
{
 
57
    ADS7846State *s = FROM_SSI_SLAVE(ADS7846State, dev);
65
58
 
66
59
    switch (s->cycle ++) {
67
60
    case 0:
89
82
        s->cycle = 0;
90
83
        break;
91
84
    }
 
85
    return s->output;
92
86
}
93
87
 
94
88
static void ads7846_ts_event(void *opaque,
95
89
                int x, int y, int z, int buttons_state)
96
90
{
97
 
    struct ads7846_state_s *s = opaque;
 
91
    ADS7846State *s = opaque;
98
92
 
99
93
    if (buttons_state) {
100
94
        x = 0x7fff - x;
113
107
 
114
108
static void ads7846_save(QEMUFile *f, void *opaque)
115
109
{
116
 
    struct ads7846_state_s *s = (struct ads7846_state_s *) opaque;
 
110
    ADS7846State *s = (ADS7846State *) opaque;
117
111
    int i;
118
112
 
119
113
    for (i = 0; i < 8; i ++)
125
119
 
126
120
static int ads7846_load(QEMUFile *f, void *opaque, int version_id)
127
121
{
128
 
    struct ads7846_state_s *s = (struct ads7846_state_s *) opaque;
 
122
    ADS7846State *s = (ADS7846State *) opaque;
129
123
    int i;
130
124
 
131
125
    for (i = 0; i < 8; i ++)
140
134
    return 0;
141
135
}
142
136
 
143
 
struct ads7846_state_s *ads7846_init(qemu_irq penirq)
 
137
static void ads7846_init(SSISlave *dev)
144
138
{
145
 
    struct ads7846_state_s *s;
146
 
    s = (struct ads7846_state_s *)
147
 
            qemu_mallocz(sizeof(struct ads7846_state_s));
148
 
    memset(s, 0, sizeof(struct ads7846_state_s));
 
139
    ADS7846State *s = FROM_SSI_SLAVE(ADS7846State, dev);
149
140
 
150
 
    s->interrupt = penirq;
 
141
    qdev_init_gpio_out(&dev->qdev, &s->interrupt, 1);
151
142
 
152
143
    s->input[0] = ADS_TEMP0;    /* TEMP0 */
153
144
    s->input[2] = ADS_VBAT;     /* VBAT */
161
152
    ads7846_int_update(s);
162
153
 
163
154
    register_savevm("ads7846", -1, 0, ads7846_save, ads7846_load, s);
164
 
 
165
 
    return s;
166
 
}
 
155
}
 
156
 
 
157
static SSISlaveInfo ads7846_info = {
 
158
    .qdev.name ="ads7846",
 
159
    .qdev.size = sizeof(ADS7846State),
 
160
    .init = ads7846_init,
 
161
    .transfer = ads7846_transfer
 
162
};
 
163
 
 
164
static void ads7846_register_devices(void)
 
165
{
 
166
    ssi_register_slave(&ads7846_info);
 
167
}
 
168
 
 
169
device_init(ads7846_register_devices)