hwc: Ignore content for HDMI when it is not enabled

Bug: 7231798
Change-Id: I82d4baa3c1b84c2f16e6b633f4e1457730333124
diff --git a/libhwc/hwc.cpp b/libhwc/hwc.cpp
index 6e4fc2a..1dea15a 100644
--- a/libhwc/hwc.cpp
+++ b/libhwc/hwc.cpp
@@ -949,10 +949,6 @@
     }
 
     if (hdmi_contents) {
-        if (!pdev->hdmi_enabled) {
-            ALOGE("HDMI disabled; can't prepare contents of external display");
-            return -EINVAL;
-        }
         int err = exynos5_prepare_hdmi(pdev, hdmi_contents);
         if (err)
             return err;
@@ -1320,6 +1316,13 @@
                           i, strerror(errno));
             close(layer.acquireFenceFd);
         }
+    }
+
+    if (!pdev->hdmi_enabled)
+        return 0;
+
+    for (size_t i = 0; i < contents->numHwLayers; i++) {
+        hwc_layer_1_t &layer = contents->hwLayers[i];
 
         if (layer.compositionType == HWC_FRAMEBUFFER_TARGET) {
             if (!layer.handle)
@@ -1353,10 +1356,6 @@
     }
 
     if (hdmi_contents) {
-        if (!pdev->hdmi_enabled) {
-            ALOGE("HDMI disabled; can't set contents of external display");
-            return -EINVAL;
-        }
         int err = exynos5_set_hdmi(pdev, hdmi_contents);
         if (err)
             return err;