r2920 - in trunk/src/host/qemu-neo1973: gnokiigsm hw
andrew at sita.openmoko.org
andrew at sita.openmoko.org
Wed Sep 5 17:33:39 CEST 2007
Author: andrew
Date: 2007-09-05 17:33:37 +0200 (Wed, 05 Sep 2007)
New Revision: 2920
Modified:
trunk/src/host/qemu-neo1973/gnokiigsm/at-emulator.h
trunk/src/host/qemu-neo1973/hw/neo1973.c
trunk/src/host/qemu-neo1973/hw/s3c.h
trunk/src/host/qemu-neo1973/hw/s3c2410.c
Log:
Scale the S3C ADC readings to natural values from a GTA01, fixes bug #736.
Take AT error constants from the specs.
Modified: trunk/src/host/qemu-neo1973/gnokiigsm/at-emulator.h
===================================================================
--- trunk/src/host/qemu-neo1973/gnokiigsm/at-emulator.h 2007-09-05 14:34:37 UTC (rev 2919)
+++ trunk/src/host/qemu-neo1973/gnokiigsm/at-emulator.h 2007-09-05 15:33:37 UTC (rev 2920)
@@ -84,15 +84,14 @@
/* Definition of modem result codes - these are returned to "terminal"
numerically or as a string depending on the setting of S12 */
- /* FIX ME - Numeric values for everything except OK and ERROR
- are guesses as I've not got an AT reference handy. HAB */
-
#define MR_OK (0)
+#define MR_CONNECT (1)
#define MR_RING (2)
#define MR_NOCARRIER (3)
#define MR_ERROR (4)
-#define MR_CARRIER (5) /* guess */
-#define MR_CONNECT (6) /* guess */
+#define MR_CARRIER (5)
+#define MR_NODIALTONE (6)
#define MR_BUSY (7)
+#define MR_NOANSWER (8)
#endif /* _gnokii_data_at_emulator_h */
Modified: trunk/src/host/qemu-neo1973/hw/neo1973.c
===================================================================
--- trunk/src/host/qemu-neo1973/hw/neo1973.c 2007-09-05 14:34:37 UTC (rev 2919)
+++ trunk/src/host/qemu-neo1973/hw/neo1973.c 2007-09-05 15:33:37 UTC (rev 2920)
@@ -404,6 +404,12 @@
pcf_exton_set(s->pmu, 1);
}
+/* Typical touchscreen calibration values */
+static const int gta01_ts_scale[6] = {
+ 0, (90 - 960) * 256 / 1021, -90 * 256 * 32,
+ (940 - 75) * 256 / 1021, 0, 75 * 256 * 32,
+};
+
/* Board init. */
static void neo_init(int ram_size, int vga_ram_size, int boot_device,
DisplayState *ds, const char **fd_filename, int snapshot,
@@ -443,6 +449,8 @@
if (usb_enabled)
usb_device_attach(usb_bt_init(local_piconet));
+ s3c_adc_setscale(s->cpu->adc, gta01_ts_scale);
+
/* Setup initial (reset) machine state */
qemu_register_reset(neo_reset, s);
#if 0
Modified: trunk/src/host/qemu-neo1973/hw/s3c.h
===================================================================
--- trunk/src/host/qemu-neo1973/hw/s3c.h 2007-09-05 14:34:37 UTC (rev 2919)
+++ trunk/src/host/qemu-neo1973/hw/s3c.h 2007-09-05 15:33:37 UTC (rev 2920)
@@ -124,6 +124,7 @@
struct s3c_adc_state_s;
struct s3c_adc_state_s *s3c_adc_init(target_phys_addr_t base, qemu_irq irq,
qemu_irq tcirq);
+void s3c_adc_setscale(struct s3c_adc_state_s *adc, const int m[]);
struct s3c_i2c_state_s;
struct s3c_i2c_state_s *s3c_i2c_init(target_phys_addr_t base, qemu_irq irq);
Modified: trunk/src/host/qemu-neo1973/hw/s3c2410.c
===================================================================
--- trunk/src/host/qemu-neo1973/hw/s3c2410.c 2007-09-05 14:34:37 UTC (rev 2919)
+++ trunk/src/host/qemu-neo1973/hw/s3c2410.c 2007-09-05 15:33:37 UTC (rev 2920)
@@ -1643,6 +1643,7 @@
int input[8];
int in_idx;
int noise;
+ int scale[6];
uint16_t control;
uint16_t ts;
@@ -1680,12 +1681,16 @@
static void s3c_adc_tick(void *opaque)
{
struct s3c_adc_state_s *s = (struct s3c_adc_state_s *) opaque;
+ int sx, sy;
+
if (s->down) {
if ((s->ts & 3) == 3 && s->enable)
qemu_irq_raise(s->tcirq);
else if (s->enable && ((s->ts & (1 << 2)) || (s->ts & 3))) {
- s->xdata = (s->x >> 5) | (1 << 14) | ((s->ts & 3) << 12);
- s->ydata = (s->y >> 5) | (1 << 14) | ((s->ts & 3) << 12);
+ sx = s->x * s->scale[0] + s->y * s->scale[1] + s->scale[2];
+ sy = s->x * s->scale[3] + s->y * s->scale[4] + s->scale[5];
+ s->xdata = ((sx >> 13) & 0xfff) | (1 << 14) | ((s->ts & 3) << 12);
+ s->ydata = ((sy >> 13) & 0xfff) | (1 << 14) | ((s->ts & 3) << 12);
s->xdata ^= s->noise >> 1;
s->ydata ^= s->noise >> 2;
qemu_irq_raise(s->irq);
@@ -1846,6 +1851,11 @@
return s;
}
+void s3c_adc_setscale(struct s3c_adc_state_s *adc, const int m[])
+{
+ memcpy(adc->scale, m, 6 * sizeof(int));
+}
+
/* IIC-bus serial interface */
struct s3c_i2c_state_s {
i2c_slave slave;
More information about the commitlog
mailing list