am 3c935eda: resolved conflicts for merge of 33fddf0c to gingerbread-plus-aosp

* commit '3c935eda2dcd96eda70da6367d705b3b081f6524':
  emulator: Add <hardware/qemu_pipe.h> header
diff --git a/include/hardware/gralloc.h b/include/hardware/gralloc.h
index 73cc9e0..5eefe79 100644
--- a/include/hardware/gralloc.h
+++ b/include/hardware/gralloc.h
@@ -28,6 +28,8 @@
 
 __BEGIN_DECLS
 
+#define GRALLOC_API_VERSION 1
+
 /**
  * The id of this module
  */
@@ -70,6 +72,19 @@
     /* mask for the software usage bit-mask */
     GRALLOC_USAGE_HW_MASK         = 0x00001F00,
 
+    /* buffer should be displayed full-screen on an external display when
+     * possible
+     */
+    GRALLOC_USAGE_EXTERNAL_DISP   = 0x00002000,
+
+    /* Must have a hardware-protected path to external display sink for
+     * this buffer.  If a hardware-protected path is not available, then
+     * either don't composite only this buffer (preferred) to the
+     * external sink, or (less desirable) do not route the entire
+     * composition to the external sink.
+     */
+    GRALLOC_USAGE_PROTECTED       = 0x00004000,
+
     /* implementation-specific private usage flags */
     GRALLOC_USAGE_PRIVATE_0       = 0x10000000,
     GRALLOC_USAGE_PRIVATE_1       = 0x20000000,
@@ -222,6 +237,13 @@
     int (*free)(struct alloc_device_t* dev,
             buffer_handle_t handle);
 
+    /* This hook is OPTIONAL.
+     *
+     * If non NULL it will be caused by SurfaceFlinger on dumpsys
+     */
+    void (*dump)(struct alloc_device_t *dev, char *buff, int buff_len);
+
+    void* reserved_proc[7];
 } alloc_device_t;
 
 
@@ -316,8 +338,14 @@
 
     int (*compositionComplete)(struct framebuffer_device_t* dev);
 
+    /*
+     * This hook is OPTIONAL.
+     *
+     * If non NULL it will be caused by SurfaceFlinger on dumpsys
+     */
+    void (*dump)(struct framebuffer_device_t* dev, char *buff, int buff_len);
 
-    void* reserved_proc[8];
+    void* reserved_proc[7];
 
 } framebuffer_device_t;
 
diff --git a/include/hardware/hwcomposer.h b/include/hardware/hwcomposer.h
new file mode 100644
index 0000000..321dfc1
--- /dev/null
+++ b/include/hardware/hwcomposer.h
@@ -0,0 +1,310 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_H
+#define ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_H
+
+#include <stdint.h>
+#include <sys/cdefs.h>
+
+#include <hardware/gralloc.h>
+#include <hardware/hardware.h>
+#include <cutils/native_handle.h>
+
+__BEGIN_DECLS
+
+/*****************************************************************************/
+
+#define HWC_API_VERSION 1
+
+/**
+ * The id of this module
+ */
+#define HWC_HARDWARE_MODULE_ID "hwcomposer"
+
+/**
+ * Name of the sensors device to open
+ */
+#define HWC_HARDWARE_COMPOSER   "composer"
+
+
+enum {
+    /* hwc_composer_device_t::set failed in EGL */
+    HWC_EGL_ERROR = -1
+};
+
+/*
+ * hwc_layer_t::hints values
+ * Hints are set by the HAL and read by SurfaceFlinger
+ */
+enum {
+    /*
+     * HWC can set the HWC_HINT_TRIPLE_BUFFER hint to indicate to SurfaceFlinger
+     * that it should triple buffer this layer. Typically HWC does this when
+     * the layer will be unavailable for use for an extended period of time,
+     * e.g. if the display will be fetching data directly from the layer and
+     * the layer can not be modified until after the next set().
+     */
+    HWC_HINT_TRIPLE_BUFFER  = 0x00000001,
+
+    /*
+     * HWC sets HWC_HINT_CLEAR_FB to tell SurfaceFlinger that it should clear the
+     * framebuffer with transparent pixels where this layer would be.
+     * SurfaceFlinger will only honor this flag when the layer has no blending
+     *
+     */
+    HWC_HINT_CLEAR_FB       = 0x00000002
+};
+
+/*
+ * hwc_layer_t::flags values
+ * Flags are set by SurfaceFlinger and read by the HAL
+ */
+enum {
+    /*
+     * HWC_SKIP_LAYER is set by SurfaceFlnger to indicate that the HAL
+     * shall not consider this layer for composition as it will be handled
+     * by SurfaceFlinger (just as if compositionType was set to HWC_OVERLAY).
+     */
+    HWC_SKIP_LAYER = 0x00000001,
+};
+
+/*
+ * hwc_layer_t::compositionType values
+ */
+enum {
+    /* this layer is to be drawn into the framebuffer by SurfaceFlinger */
+    HWC_FRAMEBUFFER = 0,
+
+    /* this layer will be handled in the HWC */
+    HWC_OVERLAY = 1,
+};
+
+/*
+ * hwc_layer_t::blending values
+ */
+enum {
+    /* no blending */
+    HWC_BLENDING_NONE     = 0x0100,
+
+    /* ONE / ONE_MINUS_SRC_ALPHA */
+    HWC_BLENDING_PREMULT  = 0x0105,
+
+    /* SRC_ALPHA / ONE_MINUS_SRC_ALPHA */
+    HWC_BLENDING_COVERAGE = 0x0405
+};
+
+/*
+ * hwc_layer_t::transform values
+ */
+enum {
+    /* flip source image horizontally */
+    HWC_TRANSFORM_FLIP_H = HAL_TRANSFORM_FLIP_H,
+    /* flip source image vertically */
+    HWC_TRANSFORM_FLIP_V = HAL_TRANSFORM_FLIP_V,
+    /* rotate source image 90 degrees clock-wise */
+    HWC_TRANSFORM_ROT_90 = HAL_TRANSFORM_ROT_90,
+    /* rotate source image 180 degrees */
+    HWC_TRANSFORM_ROT_180 = HAL_TRANSFORM_ROT_180,
+    /* rotate source image 270 degrees clock-wise */
+    HWC_TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_270,
+};
+
+typedef struct hwc_rect {
+    int left;
+    int top;
+    int right;
+    int bottom;
+} hwc_rect_t;
+
+typedef struct hwc_region {
+    size_t numRects;
+    hwc_rect_t const* rects;
+} hwc_region_t;
+
+typedef struct hwc_layer {
+    /*
+     * initially set to HWC_FRAMEBUFFER, indicates the layer will
+     * be drawn into the framebuffer using OpenGL ES.
+     * The HWC can toggle this value to HWC_OVERLAY, to indicate
+     * it will handle the layer.
+     */
+    int32_t compositionType;
+
+    /* see hwc_layer_t::hints above */
+    uint32_t hints;
+
+    /* see hwc_layer_t::flags above */
+    uint32_t flags;
+
+    /* handle of buffer to compose. this handle is guaranteed to have been
+     * allocated with gralloc */
+    buffer_handle_t handle;
+
+    /* transformation to apply to the buffer during composition */
+    uint32_t transform;
+
+    /* blending to apply during composition */
+    int32_t blending;
+
+    /* area of the source to consider, the origin is the top-left corner of
+     * the buffer */
+    hwc_rect_t sourceCrop;
+
+    /* where to composite the sourceCrop onto the display. The sourceCrop
+     * is scaled using linear filtering to the displayFrame. The origin is the
+     * top-left corner of the screen.
+     */
+    hwc_rect_t displayFrame;
+
+    /* visible region in screen space. The origin is the
+     * top-left corner of the screen.
+     * The visible region INCLUDES areas overlapped by a translucent layer.
+     */
+    hwc_region_t visibleRegionScreen;
+} hwc_layer_t;
+
+
+/*
+ * hwc_layer_list_t::flags values
+ */
+enum {
+    /*
+     * HWC_GEOMETRY_CHANGED is set by SurfaceFlinger to indicate that the list
+     * passed to (*prepare)() has changed by more than just the buffer handles.
+     */
+    HWC_GEOMETRY_CHANGED = 0x00000001,
+};
+
+/*
+ * List of layers.
+ * The handle members of hwLayers elements must be unique.
+ */
+typedef struct hwc_layer_list {
+    uint32_t flags;
+    size_t numHwLayers;
+    hwc_layer_t hwLayers[0];
+} hwc_layer_list_t;
+
+/* This represents a display, typically an EGLDisplay object */
+typedef void* hwc_display_t;
+
+/* This represents a surface, typically an EGLSurface object  */
+typedef void* hwc_surface_t;
+
+/*****************************************************************************/
+
+
+typedef struct hwc_module {
+    struct hw_module_t common;
+} hwc_module_t;
+
+
+typedef struct hwc_composer_device {
+    struct hw_device_t common;
+
+    /*
+     * (*prepare)() is called for each frame before composition and is used by
+     * SurfaceFlinger to determine what composition steps the HWC can handle.
+     *
+     * (*prepare)() can be called more than once, the last call prevails.
+     *
+     * The HWC responds by setting the compositionType field to either
+     * HWC_FRAMEBUFFER or HWC_OVERLAY. In the former case, the composition for
+     * this layer is handled by SurfaceFlinger with OpenGL ES, in the later
+     * case, the HWC will have to handle this layer's composition.
+     *
+     * (*prepare)() is called with HWC_GEOMETRY_CHANGED to indicate that the
+     * list's geometry has changed, that is, when more than just the buffer's
+     * handles have been updated. Typically this happens (but is not limited to)
+     * when a window is added, removed, resized or moved.
+     *
+     * a NULL list parameter or a numHwLayers of zero indicates that the
+     * entire composition will be handled by SurfaceFlinger with OpenGL ES.
+     *
+     * returns: 0 on success. An negative error code on error. If an error is
+     * returned, SurfaceFlinger will assume that none of the layer will be
+     * handled by the HWC.
+     */
+    int (*prepare)(struct hwc_composer_device *dev, hwc_layer_list_t* list);
+
+
+    /*
+     * (*set)() is used in place of eglSwapBuffers(), and assumes the same
+     * functionality, except it also commits the work list atomically with
+     * the actual eglSwapBuffers().
+     *
+     * The list parameter is guaranteed to be the same as the one returned
+     * from the last call to (*prepare)().
+     *
+     * When this call returns the caller assumes that:
+     *
+     * - the display will be updated in the near future with the content
+     *   of the work list, without artifacts during the transition from the
+     *   previous frame.
+     *
+     * - all objects are available for immediate access or destruction, in
+     *   particular, hwc_region_t::rects data and hwc_layer_t::layer's buffer.
+     *   Note that this means that immediately accessing (potentially from a
+     *   different process) a buffer used in this call will not result in
+     *   screen corruption, the driver must apply proper synchronization or
+     *   scheduling (eg: block the caller, such as gralloc_module_t::lock(),
+     *   OpenGL ES, Camera, Codecs, etc..., or schedule the caller's work
+     *   after the buffer is freed from the actual composition).
+     *
+     * a NULL list parameter or a numHwLayers of zero indicates that the
+     * entire composition has been handled by SurfaceFlinger with OpenGL ES.
+     * In this case, (*set)() behaves just like eglSwapBuffers().
+     *
+     * returns: 0 on success. An negative error code on error:
+     *    HWC_EGL_ERROR: eglGetError() will provide the proper error code
+     *    Another code for non EGL errors.
+     *
+     */
+    int (*set)(struct hwc_composer_device *dev,
+                hwc_display_t dpy,
+                hwc_surface_t sur,
+                hwc_layer_list_t* list);
+    /*
+     * This hook is OPTIONAL.
+     *
+     * If non NULL it will be caused by SurfaceFlinger on dumpsys
+     */
+    void (*dump)(struct hwc_composer_device* dev, char *buff, int buff_len);
+
+    void* reserved_proc[7];
+
+} hwc_composer_device_t;
+
+
+/** convenience API for opening and closing a device */
+
+static inline int hwc_open(const struct hw_module_t* module,
+        hwc_composer_device_t** device) {
+    return module->methods->open(module,
+            HWC_HARDWARE_COMPOSER, (struct hw_device_t**)device);
+}
+
+static inline int hwc_close(hwc_composer_device_t* device) {
+    return device->common.close(&device->common);
+}
+
+
+/*****************************************************************************/
+
+__END_DECLS
+
+#endif /* ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_H */
diff --git a/include/hardware/sensors.h b/include/hardware/sensors.h
index 297d31a..1dcd5fa 100644
--- a/include/hardware/sensors.h
+++ b/include/hardware/sensors.h
@@ -229,6 +229,13 @@
  *
  * Pressure sensors report events at a constant rate defined by setDelay().
  *
+ * Gyro
+ * --------
+ *
+ * The gyroscope sensor values are returned in degrees per second (dps)
+ *
+ * Gyroscope sensor report events at a constant rate defined by setDelay().
+ *
  * Gravity
  * -------
  * A gravity output indicates the direction of and magnitude of gravity in the devices's
diff --git a/include/hardware/sensors_deprecated.h b/include/hardware/sensors_deprecated.h
index 7974788..ee667d6 100644
--- a/include/hardware/sensors_deprecated.h
+++ b/include/hardware/sensors_deprecated.h
@@ -29,6 +29,7 @@
         float           temperature;
         float           distance;
         float           light;
+        float           pressure;
     };
     int64_t         time;
     uint32_t        reserved;
diff --git a/modules/hwcomposer/Android.mk b/modules/hwcomposer/Android.mk
new file mode 100644
index 0000000..233059b
--- /dev/null
+++ b/modules/hwcomposer/Android.mk
@@ -0,0 +1,27 @@
+# Copyright (C) 2008 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+LOCAL_PATH := $(call my-dir)
+
+# HAL module implemenation, not prelinked and stored in
+# hw/<OVERLAY_HARDWARE_MODULE_ID>.<ro.product.board>.so
+include $(CLEAR_VARS)
+LOCAL_PRELINK_MODULE := false
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
+LOCAL_SHARED_LIBRARIES := liblog libEGL
+LOCAL_SRC_FILES := hwcomposer.cpp
+LOCAL_MODULE := hwcomposer.default
+LOCAL_CFLAGS:= -DLOG_TAG=\"hwcomposer\"
+include $(BUILD_SHARED_LIBRARY)
diff --git a/modules/hwcomposer/README.android b/modules/hwcomposer/README.android
new file mode 100644
index 0000000..4aa7203
--- /dev/null
+++ b/modules/hwcomposer/README.android
@@ -0,0 +1,3 @@
+
+Skeleton for the "hwcomposer" HAL module.
+
diff --git a/modules/hwcomposer/hwcomposer.cpp b/modules/hwcomposer/hwcomposer.cpp
new file mode 100644
index 0000000..939210b
--- /dev/null
+++ b/modules/hwcomposer/hwcomposer.cpp
@@ -0,0 +1,132 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <hardware/hardware.h>
+#include <hardware/overlay.h>
+
+#include <fcntl.h>
+#include <errno.h>
+
+#include <cutils/log.h>
+#include <cutils/atomic.h>
+
+#include <hardware/hwcomposer.h>
+
+#include <EGL/egl.h>
+
+/*****************************************************************************/
+
+struct hwc_context_t {
+    hwc_composer_device_t device;
+    /* our private state goes below here */
+};
+
+static int hwc_device_open(const struct hw_module_t* module, const char* name,
+        struct hw_device_t** device);
+
+static struct hw_module_methods_t hwc_module_methods = {
+    open: hwc_device_open
+};
+
+hwc_module_t HAL_MODULE_INFO_SYM = {
+    common: {
+        tag: HARDWARE_MODULE_TAG,
+        version_major: 1,
+        version_minor: 0,
+        id: HWC_HARDWARE_MODULE_ID,
+        name: "Sample hwcomposer module",
+        author: "The Android Open Source Project",
+        methods: &hwc_module_methods,
+    }
+};
+
+/*****************************************************************************/
+
+static void dump_layer(hwc_layer_t const* l) {
+    LOGD("\ttype=%d, flags=%08x, handle=%p, tr=%02x, blend=%04x, {%d,%d,%d,%d}, {%d,%d,%d,%d}",
+            l->compositionType, l->flags, l->handle, l->transform, l->blending,
+            l->sourceCrop.left,
+            l->sourceCrop.top,
+            l->sourceCrop.right,
+            l->sourceCrop.bottom,
+            l->displayFrame.left,
+            l->displayFrame.top,
+            l->displayFrame.right,
+            l->displayFrame.bottom);
+}
+
+static int hwc_prepare(hwc_composer_device_t *dev, hwc_layer_list_t* list) {
+    if (list && (list->flags & HWC_GEOMETRY_CHANGED)) {
+        for (size_t i=0 ; i<list->numHwLayers ; i++) {
+            //dump_layer(&list->hwLayers[i]);
+            list->hwLayers[i].compositionType = HWC_FRAMEBUFFER;
+        }
+    }
+    return 0;
+}
+
+static int hwc_set(hwc_composer_device_t *dev,
+        hwc_display_t dpy,
+        hwc_surface_t sur,
+        hwc_layer_list_t* list)
+{
+    //for (size_t i=0 ; i<list->numHwLayers ; i++) {
+    //    dump_layer(&list->hwLayers[i]);
+    //}
+
+    EGLBoolean sucess = eglSwapBuffers((EGLDisplay)dpy, (EGLSurface)sur);
+    if (!sucess) {
+        return HWC_EGL_ERROR;
+    }
+    return 0;
+}
+
+static int hwc_device_close(struct hw_device_t *dev)
+{
+    struct hwc_context_t* ctx = (struct hwc_context_t*)dev;
+    if (ctx) {
+        free(ctx);
+    }
+    return 0;
+}
+
+/*****************************************************************************/
+
+static int hwc_device_open(const struct hw_module_t* module, const char* name,
+        struct hw_device_t** device)
+{
+    int status = -EINVAL;
+    if (!strcmp(name, HWC_HARDWARE_COMPOSER)) {
+        struct hwc_context_t *dev;
+        dev = (hwc_context_t*)malloc(sizeof(*dev));
+
+        /* initialize our state here */
+        memset(dev, 0, sizeof(*dev));
+
+        /* initialize the procs */
+        dev->device.common.tag = HARDWARE_DEVICE_TAG;
+        dev->device.common.version = 0;
+        dev->device.common.module = const_cast<hw_module_t*>(module);
+        dev->device.common.close = hwc_device_close;
+
+        dev->device.prepare = hwc_prepare;
+        dev->device.set = hwc_set;
+
+        *device = &dev->device.common;
+        status = 0;
+    }
+    return status;
+}