Fix incorrect orientation at boot.
The goldfish kernel's event driver is very picky about the
state of the virtual device it talks to. Essentially, it can
only listen to h/w events if the corresponding IRQ is raised
_after_ it has completed some initial setup.
If the IRQ is raised before, the driver will refuse to listen
to events, and any interaction becomes impossible.
We changed the way our UI windows are built and managed
previously, and this had the unfortunate effect of sending
one h/w event too soon, which, in the old code, would raise
the IRQ prematurely. This resulted in an input freeze.
To work around this the UI code was modified to not send
the initial h/w event, but this resulted in bad orientation
of the home screen at the end of the boot sequence.
This change allows the virtual device to wait for the kernel
driver before raising the IRQ, in the case any h/w event has
been buffered. It also removes the hack in the UI code,
allowing the send of the initial h/w event at startup.
BONUS MINOR CHANGES:
EsounD probe: fix error message.
console: fix compiler warnings
libpng: proper handling of MMX support.
android-configure.sh: fix --ignore-audio handling
The option didn't do anything if the audio development packages
are properly installed on the system.
Change-Id: Ib134158873d5cb72290c9676d92d20233226c889
diff --git a/android-configure.sh b/android-configure.sh
index f31831c..fbc7f0d 100755
--- a/android-configure.sh
+++ b/android-configure.sh
@@ -275,6 +275,12 @@
ORG_CFLAGS=$CFLAGS
ORG_LDFLAGS=$LDFLAGS
+if [ "$OPTION_IGNORE_AUDIO" = "yes" ] ; then
+PROBE_ESD_ESD=no
+PROBE_ALSA=no
+PROBE_PULSEAUDIO=no
+fi
+
# Probe a system library
#
# $1: Variable name (e.g. PROBE_ESD)
@@ -290,17 +296,17 @@
cp -f android/config/check-esd.c $TMPC
compile && link && $TMPE
if [ $? = 0 ] ; then
- log "AudioProbe : $1 seems to be usable on this system"
+ log "AudioProbe : $2 seems to be usable on this system"
else
if [ "$OPTION_IGNORE_AUDIO" = no ] ; then
- echo "the $1 development files do not seem to be installed on this system"
- echo "Are you missing the $3 package ?"
+ echo "The $2 development files do not seem to be installed on this system"
+ echo "Are you missing the $4 package ?"
echo "Correct the errors below and try again:"
cat $TMPL
clean_exit
fi
eval $1=no
- log "AudioProbe : $1 seems to be UNUSABLE on this system !!"
+ log "AudioProbe : $2 seems to be UNUSABLE on this system !!"
fi
fi
}
diff --git a/android/config/check-esd.c b/android/config/check-esd.c
index a8eb11b..684afe2 100644
--- a/android/config/check-esd.c
+++ b/android/config/check-esd.c
@@ -47,7 +47,7 @@
esd_lib = dlopen( "libesd.so.0", RTLD_NOW );
if (esd_lib == NULL) {
- D("could not find libesd on this system");
+ D("could not find libesd on this system\n");
return 1;
}
diff --git a/android/console.c b/android/console.c
index c47768e..3db9b30 100644
--- a/android/console.c
+++ b/android/console.c
@@ -545,7 +545,7 @@
ControlClient client;
Socket fd;
- D(( "control_global_accept: just in (fd=%p)\n", (void*)global->listen_fd ));
+ D(( "control_global_accept: just in (fd=%d)\n", global->listen_fd ));
for(;;) {
fd = socket_accept( global->listen_fd, NULL );
@@ -1047,6 +1047,7 @@
if (endptr != args) {
amodem_set_cdma_prl_version( android_modem, version );
}
+ return 0;
}
/********************************************************************************************/
/********************************************************************************************/
@@ -1398,6 +1399,9 @@
{ "ssource", "Set the current CDMA subscription source",
NULL, describe_subscription_source,
do_cdma_ssource, NULL },
+ { "prl_version", "Dump the current PRL version",
+ NULL, NULL,
+ do_cdma_prl_version, NULL },
};
static const CommandDefRec gsm_commands[] =
diff --git a/android/skin/window.c b/android/skin/window.c
index b1d98af..edc9028 100644
--- a/android/skin/window.c
+++ b/android/skin/window.c
@@ -1220,6 +1220,15 @@
skin_window_redraw( window, NULL );
+ if (slayout->event_type != 0) {
+ user_event_generic( slayout->event_type, slayout->event_code, slayout->event_value );
+ /* XXX: hack, replace by better code here */
+ if (slayout->event_value != 0)
+ android_core_sensors_set_coarse_orientation( ANDROID_COARSE_PORTRAIT );
+ else
+ android_core_sensors_set_coarse_orientation( ANDROID_COARSE_LANDSCAPE );
+ }
+
return 0;
}
@@ -1232,14 +1241,6 @@
if (skin_window_reset_internal( window, slayout ) < 0)
return -1;
- if (slayout->event_type != 0) {
- user_event_generic( slayout->event_type, slayout->event_code, slayout->event_value );
- /* XXX: hack, replace by better code here */
- if (slayout->event_value != 0)
- android_core_sensors_set_coarse_orientation( ANDROID_COARSE_PORTRAIT );
- else
- android_core_sensors_set_coarse_orientation( ANDROID_COARSE_LANDSCAPE );
- }
return 0;
}
diff --git a/android/ui-core-protocol.c b/android/ui-core-protocol.c
index 4da625c..8877c0b 100644
--- a/android/ui-core-protocol.c
+++ b/android/ui-core-protocol.c
@@ -28,10 +28,11 @@
#include "trace.h"
#include "audio/audio.h"
/* Implemented in vl-android.c */
-extern void qemu_system_shutdown_request(void);
extern char* qemu_find_file(int type, const char* filename);
#endif // CONFIG_STANDALONE_UI
+extern void qemu_system_shutdown_request(void);
+
int
android_core_get_hw_lcd_density(void)
{
diff --git a/distrib/libpng-1.2.19/sources.make b/distrib/libpng-1.2.19/sources.make
index a9b37ba..f512f7b 100644
--- a/distrib/libpng-1.2.19/sources.make
+++ b/distrib/libpng-1.2.19/sources.make
@@ -4,14 +4,19 @@
pngrio.c pngrtran.c pngrutil.c pngset.c pngtrans.c pngvcrd.c pngwio.c \
pngwrite.c pngwtran.c pngwutil.c
+# Enable MMX code path for x86, except on Darwin where it fails
+PNG_MMX := no
+ifeq ($(HOST_ARCH),x86)
+ PNG_MMX := yes
+endif
ifeq ($(HOST_OS),darwin)
- LIBPNG_CFLAGS += -DPNG_NO_MMX_CODE
+ PNG_MMX := no
+endif
+
+ifeq ($(PNG_MMX),yes)
+ LIBPNG_SOURCES += pnggccrd.c
else
- ifeq ($(HOST_ARCH),ppc)
- LIBPNG_CFLAGS += -DPNG_NO_MMX_CODE
- else
- LIBPNG_SOURCES += pnggccrd.c
- endif
+ LIBPNG_CFLAGS += -DPNG_NO_MMX_CODE
endif
LIBPNG_SOURCES := $(LIBPNG_SOURCES:%=$(LIBPNG_DIR)/%)
diff --git a/hw/goldfish_events_device.c b/hw/goldfish_events_device.c
index 1f932f3..b0f95ec 100644
--- a/hw/goldfish_events_device.c
+++ b/hw/goldfish_events_device.c
@@ -30,6 +30,17 @@
PAGE_ABSDATA = 0x20000 | EV_ABS,
};
+/* These corresponds to the state of the driver.
+ * Unfortunately, we have to buffer events coming
+ * from the UI, since the kernel driver is not
+ * capable of receiving them until XXXXXX
+ */
+enum {
+ STATE_INIT = 0, /* The device is initialized */
+ STATE_BUFFERED, /* Events have been buffered, but no IRQ raised yet */
+ STATE_LIVE /* Events can be sent directly to the kernel */
+};
+
/* NOTE: The ev_bits arrays are used to indicate to the kernel
* which events can be sent by the emulated hardware.
*/
@@ -44,6 +55,7 @@
unsigned events[MAX_EVENTS];
unsigned first;
unsigned last;
+ unsigned state;
const char *name;
@@ -59,7 +71,7 @@
/* modify this each time you change the events_device structure. you
* will also need to upadte events_state_load and events_state_save
*/
-#define EVENTS_STATE_SAVE_VERSION 1
+#define EVENTS_STATE_SAVE_VERSION 2
#undef QFIELD_STRUCT
#define QFIELD_STRUCT events_state
@@ -70,6 +82,7 @@
QFIELD_BUFFER(events),
QFIELD_INT32(first),
QFIELD_INT32(last),
+ QFIELD_INT32(state),
QFIELD_END
static void events_state_save(QEMUFile* f, void* opaque)
@@ -98,13 +111,17 @@
if (enqueued < 0)
enqueued += MAX_EVENTS;
- if (enqueued + 3 >= MAX_EVENTS-1) {
+ if (enqueued + 3 > MAX_EVENTS) {
fprintf(stderr, "##KBD: Full queue, lose event\n");
return;
}
if(s->first == s->last) {
- qemu_irq_raise(s->irq);
+ if (s->state == STATE_LIVE)
+ qemu_irq_raise(s->irq);
+ else {
+ s->state = STATE_BUFFERED;
+ }
}
//fprintf(stderr, "##KBD: type=%d code=%d value=%d\n", type, code, value);
@@ -158,8 +175,9 @@
return s->name[offset];
if (page >= PAGE_EVBITS && page <= PAGE_EVBITS + EV_MAX)
return s->ev_bits[page - PAGE_EVBITS].bits[offset];
- if (page == PAGE_ABSDATA)
+ if (page == PAGE_ABSDATA) {
return s->abs_info[offset / sizeof(s->abs_info[0])];
+ }
return 0;
}
@@ -167,6 +185,19 @@
{
events_state *s = (events_state *) x;
int offset = off; // - s->base;
+
+ /* This gross hack below is used to ensure that we
+ * only raise the IRQ when the kernel driver is
+ * properly ready! If done before this, the driver
+ * becomes confused and ignores all input events
+ * as soon as one was buffered!
+ */
+ if (offset == REG_LEN && s->page == PAGE_ABSDATA) {
+ if (s->state == STATE_BUFFERED)
+ qemu_irq_raise(s->irq);
+ s->state = STATE_LIVE;
+ }
+
if (offset == REG_READ)
return dequeue_event(s);
else if (offset == REG_LEN)
@@ -388,15 +419,19 @@
qemu_add_kbd_event_handler(events_put_keycode, s);
qemu_add_mouse_event_handler(events_put_mouse, s, 1, "goldfish-events");
- user_event_register_generic(s, events_put_generic);
s->base = base;
s->irq = irq;
s->first = 0;
s->last = 0;
+ s->state = STATE_INIT;
+
+ /* This function migh fire buffered events to the device, so
+ * ensure that it is called after initialization is complete
+ */
+ user_event_register_generic(s, events_put_generic);
register_savevm( "events_state", 0, EVENTS_STATE_SAVE_VERSION,
events_state_save, events_state_load, s );
}
-