ranchu: trigger goldfish_fb rotation on command

It seems QEMU is turning the display around in a counter-clockwise
maner, but Android understands degrees of rotations as clockwise
rotations.  Tweaking the input values and the actual rotation of the
framebuffer accordingly makes things work as expected.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
[CD: rotation mapping fix]
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
ranchu: set global graphic_rotation variable to map input events

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
add goldfish_sensors: basic support for pipe based accelerometer

This imports a small chunk of the old hw-sensors code to handle the
acceleration code. The old code "supported" a bunch of different sensors
however I've dropped all the boilerplate for that. Any potential
upstream solution will probably want to enumerate things differently.

Apart from only supporting the accelerometer this also interfaces
directly with the AndroidPipe code instead of going through the qemud
layer. It also requires the updated guest code.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
[CD: fix time report to ms, initialize state]
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
ranchu: trigger rotation in goldfish_sensors on command

The original hw-sensors code miscalculated radians from degrees, which
probably happened to work on the legacy emulator, but was giving some
pretty strange values on the Android side.  When fixing this, Android
calculates almost clean 9/90/180/270 orientation value based on the
below (slightly adjusted for time drift and low-pass filtering on the
Android side).

Also add support for all 4 rotation modes, which will be useful when
emulating tablets in addition to phone UI models, where full rotation
including 180 degress is supported.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
[CD: radians fix, 4 rotation modes]
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
android-console: Fix OK message output

Adjusted "OK" message to be shared by all cases to avoid duplicates and
need for all help output to print.  Alse added missing "OK" after the top
most help output.

Signed-off-by: Greg Bellows <greg.bellows@linaro.org>
android-console: Remove extra redir help message

Removed an extraneous message in the redir command help.  The message is not
part of the standard Android emulator output.

Signed-off-by: Greg Bellows <greg.bellows@linaro.org>
android-console: Consolidate redir help text

Consolidated the Android emulator console help text for the redir command to
make the hndler functions more readable.  This establishes the pattern to be
used for each command added in the future.

Signed-off-by: Greg Bellows <greg.bellows@linaro.org>
android-console: Add console base power command

Added the base Android emulator console power command and infrastructure for
adding sub-commands.

Signed-off-by: Greg Bellows <greg.bellows@linaro.org>
[AJB: fixed up sub-table]
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
android-console: Add missing hw_has_battery prop

Added the missing hw_has_battery property to the Goldfish batter state.  This
property indicates whether the device has a battery and controls whether some
power commands are available.

In the Android emulator this property is acquired from the AVD for the device.
For now, this is wired as always enabled.

Signed-off-by: Greg Bellows <greg.bellows@linaro.org>
android-console: Init the battery ID state field

Adds initialization of the battery ID field so that it is discoverable by name
(ID) when needed by power commands.

Signed-off-by: Greg Bellows <greg.bellows@linaro.org>
android-console: Add header for battery externs

Added goldfish_battery.h to share power and battery constants and externs
between the Goldfish battery code and the Android console code.

Signed-off-by: Greg Bellows <greg.bellows@linaro.org>
android-console: Add GF battery prop print func

Add a function for printing out the Goldfish battery properties to the android
console.

Signed-off-by: Greg Bellows <greg.bellows@linaro.org>
android-console: Add GF battery property getter

Add a function for acquiring each of the goldfish battery properties.

Signed-off-by: Greg Bellows <greg.bellows@linaro.org>
android-console: Add power display command

Add the Android emulator console "power display" along with the associated help
messages.  The "display" command allows the current device power and battery state
to be displayed.

Signed-off-by: Greg Bellows <greg.bellows@linaro.org>
android-console: Add power ac command

Add the Android emulator console "power ac" along with the associated help
messages.  The "ac" command allows the power supply state of the device to be
manipulated.

Signed-off-by: Greg Bellows <greg.bellows@linaro.org>

---

v2 -> v3
- Add missing "OK" messages
android-console: Add power status command

Add the Android emulator console "power status" command and associated help
messages.  The "status" command allows the battery status of the device to be
manipulated.

Signed-off-by: Greg Bellows <greg.bellows@linaro.org>

---

v2 -> v3
- Add missing "OK" messages
android-console: Add power present command

Add the Android emulator console "power present" command and associated help
messages.  The "present" command allows the battery presence in the device to be
manipulated.

Signed-off-by: Greg Bellows <greg.bellows@linaro.org>

---

v2 -> v3
- Add missing "OK" messages
android-console: Add power health command

Add the Android emulator console "power health" command and associated help
messages.  The "health" command allows the battery health of the device to be
manipulated.

Signed-off-by: Greg Bellows <greg.bellows@linaro.org>

---

v2 -> v3
- Add missing "OK" messages
android-console: Add power capacity command

Add the Android emulator console "power capacity" command along associated help
messages.  The "capacity" command allows the battery capacity of the device to
be manipulated.

Signed-off-by: Greg Bellows <greg.bellows@linaro.org>

---

v2 -> v3
- Add missing "OK" messages
android-console: Add console base event command

Add the base Android emulator console "event" command and infrastructure for
adding sub-commands.

Signed-off-by: Greg Bellows <greg.bellows@linaro.org>
[AJB: minor fix for sub-table]
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>