am 5b485127: am 49520247: am 0904c365: Don\'t advertise metadata mode for VP8 decoder.

* commit '5b485127089c591c2744076ac73c10e2fca3da81':
diff --git a/exynos_omx/openmax/exynos_omx/osal/Exynos_OSAL_Android.cpp b/exynos_omx/openmax/exynos_omx/osal/Exynos_OSAL_Android.cpp
index 8cfd0f9..9eda9b7 100644
--- a/exynos_omx/openmax/exynos_omx/osal/Exynos_OSAL_Android.cpp
+++ b/exynos_omx/openmax/exynos_omx/osal/Exynos_OSAL_Android.cpp
@@ -801,7 +801,6 @@
         }
 
         // WORKAROUND: do not advertise metadata mode support for VP8 decoder until it can handle dynamic resolution change
-        // TRICKY: check VP8 decode feature on input port, but matching feature in on output port
         bool isVP8Decoder = pExynosComponent->pExynosPort[INPUT_PORT_INDEX].portDefinition.format.video.eCompressionFormat == OMX_VIDEO_CodingVPX;
         if (isVP8Decoder && portIndex == OUTPUT_PORT_INDEX) {
             ret = OMX_ErrorNotImplemented;
diff --git a/gralloc/framebuffer.cpp b/gralloc/framebuffer.cpp
index ce409ce..82a36bc 100644
--- a/gralloc/framebuffer.cpp
+++ b/gralloc/framebuffer.cpp
@@ -40,7 +40,6 @@
 #endif
 
 #include "gralloc_priv.h"
-#include "gr.h"
 
 /*****************************************************************************/
 
diff --git a/gralloc/gr.h b/gralloc/gr.h
deleted file mode 100644
index ad7047c..0000000
--- a/gralloc/gr.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.
- */
-
-#ifndef GR_H_
-#define GR_H_
-
-#include <stdint.h>
-#include <limits.h>
-#include <sys/cdefs.h>
-#include <hardware/gralloc.h>
-#include <pthread.h>
-#include <errno.h>
-
-#include <cutils/native_handle.h>
-
-/*****************************************************************************/
-
-struct private_module_t;
-struct private_handle_t;
-
-int grallocMap(gralloc_module_t const* module, private_handle_t *hnd);
-int grallocUnmap(gralloc_module_t const* module, private_handle_t *hnd);
-
-#endif /* GR_H_ */
diff --git a/gralloc/gralloc.cpp b/gralloc/gralloc.cpp
index 9e768ae..3c56a1e 100644
--- a/gralloc/gralloc.cpp
+++ b/gralloc/gralloc.cpp
@@ -37,7 +37,6 @@
 
 #include "gralloc_priv.h"
 #include "exynos_format.h"
-#include "gr.h"
 
 #define ION_HEAP_EXYNOS_CONTIG_MASK (1 << 4)
 #define ION_EXYNOS_FIMD_VIDEO_MASK  (1 << 28)
@@ -108,6 +107,7 @@
 numBuffers: 0,
 bufferMask: 0,
 lock: PTHREAD_MUTEX_INITIALIZER,
+refcount: 0,
 currentBuffer: 0,
 ionfd: -1,
 };
@@ -353,9 +353,10 @@
         err = gralloc_alloc_yuv(m->ionfd, w, h, format, usage, ion_flags,
                                 &hnd, &stride);
     if (err)
-        return err;
+        goto err;
 
-    if (err != 0)
+    err = gralloc_register_buffer(module, hnd);
+    if (err)
         goto err;
 
     *pHandle = hnd;
@@ -381,8 +382,8 @@
     private_handle_t const* hnd = reinterpret_cast<private_handle_t const*>(handle);
     gralloc_module_t* module = reinterpret_cast<gralloc_module_t*>(
                                                                    dev->common.module);
-    if (hnd->base)
-        grallocUnmap(module, const_cast<private_handle_t*>(hnd));
+
+    gralloc_unregister_buffer(module, hnd);
 
     close(hnd->fd);
     if (hnd->fd1 >= 0)
@@ -400,6 +401,14 @@
 {
     gralloc_context_t* ctx = reinterpret_cast<gralloc_context_t*>(dev);
     if (ctx) {
+        private_module_t *p = reinterpret_cast<private_module_t*>(ctx->device.common.module);
+        pthread_mutex_lock(&p->lock);
+        LOG_ALWAYS_FATAL_IF(!p->refcount);
+        p->refcount--;
+        if (!p->refcount)
+            close(p->ionfd);
+        pthread_mutex_unlock(&p->lock);
+
         /* TODO: keep a list of all buffer_handle_t created, and free them
          * all here.
          */
@@ -429,7 +438,11 @@
         dev->device.free = gralloc_free;
 
         private_module_t *p = reinterpret_cast<private_module_t*>(dev->device.common.module);
-        p->ionfd = ion_open();
+        pthread_mutex_lock(&p->lock);
+        if (!p->refcount)
+            p->ionfd = ion_open();
+        p->refcount++;
+        pthread_mutex_unlock(&p->lock);
 
         *device = &dev->device.common;
         status = 0;
diff --git a/gralloc/mapper.cpp b/gralloc/mapper.cpp
index e63f749..1a70973 100644
--- a/gralloc/mapper.cpp
+++ b/gralloc/mapper.cpp
@@ -72,16 +72,6 @@
 
 /*****************************************************************************/
 
-int grallocMap(gralloc_module_t const* module, private_handle_t *hnd)
-{
-    return gralloc_map(module, hnd);
-}
-
-int grallocUnmap(gralloc_module_t const* module, private_handle_t *hnd)	
-{
-    return gralloc_unmap(module, hnd);
-}
-
 int getIonFd(gralloc_module_t const *module)
 {
     private_module_t* m = const_cast<private_module_t*>(reinterpret_cast<const private_module_t*>(module));
@@ -97,12 +87,9 @@
 int gralloc_register_buffer(gralloc_module_t const* module,
                             buffer_handle_t handle)
 {
-    int err;
     if (private_handle_t::validate(handle) < 0)
         return -EINVAL;
 
-    err = gralloc_map(module, handle);
-
     private_handle_t* hnd = (private_handle_t*)handle;
     ALOGV("%s: base %p %d %d %d %d\n", __func__, hnd->base, hnd->size,
           hnd->width, hnd->height, hnd->stride);
@@ -122,7 +109,7 @@
             ALOGE("error importing handle2 %d %x\n", hnd->fd2, hnd->format);
     }
 
-    return err;
+    return ret;
 }
 
 int gralloc_unregister_buffer(gralloc_module_t const* module,
diff --git a/include/gralloc_priv.h b/include/gralloc_priv.h
index bce84e4..416101c 100644
--- a/include/gralloc_priv.h
+++ b/include/gralloc_priv.h
@@ -43,6 +43,7 @@
     uint32_t numBuffers;
     uint32_t bufferMask;
     pthread_mutex_t lock;
+    unsigned int refcount;
     buffer_handle_t currentBuffer;
     int ionfd;
 
diff --git a/libcamera2/ExynosCamera2.cpp b/libcamera2/ExynosCamera2.cpp
index b57c477..c7cdd48 100644
--- a/libcamera2/ExynosCamera2.cpp
+++ b/libcamera2/ExynosCamera2.cpp
@@ -588,9 +588,9 @@
     ADD_OR_SIZE(ANDROID_CONTROL_AVAILABLE_EFFECTS,
             availableEffects, sizeof(availableEffects));
 
-    int32_t max3aRegions = 1;
+    static const int32_t max3aRegions[] = {/*AE*/ 1,/*AWB*/ 1,/*AF*/ 1};
     ADD_OR_SIZE(ANDROID_CONTROL_MAX_REGIONS,
-            &max3aRegions, 1);
+            max3aRegions, sizeof(max3aRegions)/sizeof(max3aRegions[0]));
 
     ADD_OR_SIZE(ANDROID_CONTROL_AE_AVAILABLE_MODES,
             m_curCameraInfo->availableAeModes, m_curCameraInfo->numAvailableAeModes);
@@ -749,7 +749,6 @@
     uint8_t demosaicMode = 0;
     uint8_t noiseMode = 0;
     uint8_t shadingMode = 0;
-    uint8_t geometricMode = 0;
     uint8_t colorMode = 0;
     uint8_t tonemapMode = 0;
     uint8_t edgeMode = 0;
@@ -766,7 +765,6 @@
         demosaicMode = ANDROID_DEMOSAIC_MODE_HIGH_QUALITY;
         noiseMode = ANDROID_NOISE_REDUCTION_MODE_HIGH_QUALITY;
         shadingMode = ANDROID_SHADING_MODE_HIGH_QUALITY;
-        geometricMode = ANDROID_GEOMETRIC_MODE_HIGH_QUALITY;
         colorMode = ANDROID_COLOR_CORRECTION_MODE_HIGH_QUALITY;
         tonemapMode = ANDROID_TONEMAP_MODE_HIGH_QUALITY;
         edgeMode = ANDROID_EDGE_MODE_HIGH_QUALITY;
@@ -781,7 +779,6 @@
         demosaicMode = ANDROID_DEMOSAIC_MODE_FAST;
         noiseMode = ANDROID_NOISE_REDUCTION_MODE_FAST;
         shadingMode = ANDROID_SHADING_MODE_FAST;
-        geometricMode = ANDROID_GEOMETRIC_MODE_FAST;
         colorMode = ANDROID_COLOR_CORRECTION_MODE_FAST;
         tonemapMode = ANDROID_TONEMAP_MODE_FAST;
         edgeMode = ANDROID_EDGE_MODE_FAST;
@@ -791,7 +788,6 @@
     ADD_OR_SIZE(ANDROID_DEMOSAIC_MODE, &demosaicMode, 1);
     ADD_OR_SIZE(ANDROID_NOISE_REDUCTION_MODE, &noiseMode, 1);
     ADD_OR_SIZE(ANDROID_SHADING_MODE, &shadingMode, 1);
-    ADD_OR_SIZE(ANDROID_GEOMETRIC_MODE, &geometricMode, 1);
     ADD_OR_SIZE(ANDROID_COLOR_CORRECTION_MODE, &colorMode, 1);
     ADD_OR_SIZE(ANDROID_TONEMAP_MODE, &tonemapMode, 1);
     ADD_OR_SIZE(ANDROID_EDGE_MODE, &edgeMode, 1);
@@ -897,7 +893,7 @@
     static const uint8_t effectMode = ANDROID_CONTROL_EFFECT_MODE_OFF;
     ADD_OR_SIZE(ANDROID_CONTROL_EFFECT_MODE, &effectMode, 1);
 
-    static const uint8_t sceneMode = ANDROID_CONTROL_SCENE_MODE_UNSUPPORTED;
+    static const uint8_t sceneMode = ANDROID_CONTROL_SCENE_MODE_DISABLED;
     ADD_OR_SIZE(ANDROID_CONTROL_SCENE_MODE, &sceneMode, 1);
 
     static const uint8_t aeMode = ANDROID_CONTROL_AE_MODE_ON;