libgscaler: don't reconfigure m2m gscaler every frame
authorGreg Hackmann <ghackmann@google.com>
Wed, 3 Oct 2012 23:24:35 +0000 (16:24 -0700)
committerGreg Hackmann <ghackmann@google.com>
Wed, 3 Oct 2012 23:34:23 +0000 (16:34 -0700)
Reconfiguration happens iff config_exclusive() is called since the last
call to run_exclusive().  Streaming can now stay on until the Gscaler is
reconfigured or explicitly stopped.

Bug: 7202379
Change-Id: I7594e39e01454785098a7abc0b6480df6553f8d0
Signed-off-by: Greg Hackmann <ghackmann@google.com>
libgscaler/exynos_gsc_utils.h
libgscaler/exynos_gscaler.c

index fab170a65b2e453cbd1ccaf6b3e380f73b765ee5..dfe7925a5580871482ed1f6c4ef0773dd27c27ee 100644 (file)
@@ -100,6 +100,7 @@ struct gsc_info {
     int                rotation;
     int                flip_horizontal;
     int                flip_vertical;
+    bool               dirty;
 
     void              *addr[NUM_OF_GSC_PLANES];
     bool               stream_on;
index 80faaae869f93567aba23c81da7a6dbef6a82e97..b731054f5c974f79d7e06720d12a87455264120c 100644 (file)
@@ -615,6 +615,19 @@ static bool m_exynos_gsc_set_format(
             return false;
         }
         info->stream_on = false;
+
+        req_buf.count  = 0;
+        req_buf.type   = info->buf_type;
+        req_buf.memory = V4L2_MEMORY_DMABUF;
+        if (exynos_v4l2_reqbufs(fd, &req_buf) < 0) {
+            ALOGE("%s::exynos_v4l2_reqbufs() fail", __func__);
+            return false;
+        }
+
+        if (exynos_v4l2_s_ctrl(fd, V4L2_CID_CONTENT_PROTECTION, 0) < 0) {
+            ALOGE("%s::exynos_v4l2_s_ctrl(V4L2_CID_CONTENT_PROTECTION) fail", __func__);
+            return false;
+        }
     }
 
     if (exynos_v4l2_s_ctrl(fd, V4L2_CID_ROTATE, info->rotation) < 0) {
@@ -1065,6 +1078,7 @@ int exynos_gsc_set_src_format(
     gsc_handle->src.v4l2_colorformat = v4l2_colorformat;
     gsc_handle->src.cacheable        = cacheable;
     gsc_handle->src.mode_drm         = mode_drm;
+    gsc_handle->src.dirty            = true;
 
 
     exynos_mutex_unlock(gsc_handle->op_mutex);
@@ -1107,6 +1121,7 @@ int exynos_gsc_set_dst_format(
     gsc_handle->dst.v4l2_colorformat = v4l2_colorformat;
     gsc_handle->dst.cacheable        = cacheable;
     gsc_handle->dst.mode_drm         = mode_drm;
+    gsc_handle->dst.dirty            = true;
 
     exynos_mutex_unlock(gsc_handle->op_mutex);
 
@@ -1753,14 +1768,20 @@ static int exynos_gsc_m2m_run_core(void *handle)
         goto done;
     }
 
-    if (m_exynos_gsc_set_format(gsc_handle->gsc_fd, &gsc_handle->src) == false) {
-        ALOGE("%s::m_exynos_gsc_set_format(src) fail", __func__);
-        goto done;
+    if (gsc_handle->src.dirty) {
+        if (m_exynos_gsc_set_format(gsc_handle->gsc_fd, &gsc_handle->src) == false) {
+            ALOGE("%s::m_exynos_gsc_set_format(src) fail", __func__);
+            goto done;
+        }
+        gsc_handle->src.dirty = false;
     }
 
-    if (m_exynos_gsc_set_format(gsc_handle->gsc_fd, &gsc_handle->dst) == false) {
-        ALOGE("%s::m_exynos_gsc_set_format(dst) fail", __func__);
-        goto done;
+    if (gsc_handle->dst.dirty) {
+        if (m_exynos_gsc_set_format(gsc_handle->gsc_fd, &gsc_handle->dst) == false) {
+            ALOGE("%s::m_exynos_gsc_set_format(dst) fail", __func__);
+            goto done;
+        }
+        gsc_handle->dst.dirty = false;
     }
 
     if (m_exynos_gsc_set_addr(gsc_handle->gsc_fd, &gsc_handle->src) == false) {