hikey/hikey960: Enable drm_hwcomposer for 4.14+ kernels

Modifications needed to enable the drm_hwcomposer in
the hikey build.

This enables drm_hwcomposer for 4.14+ on HiKey and HiKey960

This requires updated drm_hwc source and changes to the kernel
source and 4.14 kernel prebuilt to be updated (and merged
together with this change).

So DO NOT MERGE until pre-built kernel which incldues
the following commits is submitted:
https://android-review.googlesource.com/c/kernel/hikey-linaro/+/743923

As well as the following update to drm_hwcomposer:
https://android-review.googlesource.com/c/platform/external/drm_hwcomposer/+/743902

Bug: 62066689
Change-Id: Ifbe76eed77672d06ceb3bce16de4b4d8cac56f17
Signed-off-by: John Stultz <john.stultz@linaro.org>
diff --git a/device-common.mk b/device-common.mk
index e092764..12312bd 100644
--- a/device-common.mk
+++ b/device-common.mk
@@ -62,6 +62,11 @@
     android.hardware.graphics.composer@2.1-service \
     android.hardware.graphics.mapper@2.0-impl
 
+ifeq ($(HIKEY_USE_DRM_HWCOMPOSER), true)
+  BOARD_USES_DRM_HWCOMPOSER := true
+  PRODUCT_PACKAGES += hwcomposer.drm
+endif
+
 # Memtrack
 PRODUCT_PACKAGES += memtrack.default \
     android.hardware.memtrack@1.0-service \
diff --git a/hikey-common.mk b/hikey-common.mk
index 1927fcf..5dca9d5 100644
--- a/hikey-common.mk
+++ b/hikey-common.mk
@@ -7,6 +7,8 @@
 TARGET_COMPRESSED_KERNEL=true
 endif
 
+HIKEY_USE_DRM_HWCOMPOSER := false
+
 ifeq ($(TARGET_COMPRESSED_KERNEL), false)
 TARGET_PREBUILT_KERNEL := device/linaro/hikey-kernel/Image-dtb-$(TARGET_KERNEL_USE)
 else
@@ -25,6 +27,11 @@
     HIKEY_USE_LEGACY_TI_BLUETOOTH := true
   else
     HIKEY_USE_LEGACY_TI_BLUETOOTH := false
+    ifeq ($(TARGET_KERNEL_USE), 4.9)
+      HIKEY_USE_DRM_HWCOMPOSER := false
+    else
+      HIKEY_USE_DRM_HWCOMPOSER := true
+    endif
   endif
   TARGET_FSTAB := fstab.hikey
 endif
diff --git a/hikey960.mk b/hikey960.mk
index 3666ec3..57ef5a4 100644
--- a/hikey960.mk
+++ b/hikey960.mk
@@ -5,8 +5,14 @@
 TARGET_PREBUILT_DTB := device/linaro/hikey-kernel/hi3660-hikey960.dtb-$(TARGET_KERNEL_USE)
 
 ifeq ($(TARGET_KERNEL_USE), 4.4)
+  HIKEY_USE_DRM_HWCOMPOSER := false
   HIKEY_USE_LEGACY_TI_BLUETOOTH := true
 else
+  ifeq ($(TARGET_KERNEL_USE), 4.9)
+    HIKEY_USE_DRM_HWCOMPOSER := false
+  else
+    HIKEY_USE_DRM_HWCOMPOSER := true
+  endif
   HIKEY_USE_LEGACY_TI_BLUETOOTH := false
 endif
 
diff --git a/init.common.rc b/init.common.rc
index c15b29d..cb8abb7 100644
--- a/init.common.rc
+++ b/init.common.rc
@@ -54,6 +54,7 @@
 
 # Set supported opengles version
     setprop ro.opengles.version 196608
+    setprop ro.hardware.hwcomposer drm
 
 # If an app forces screen rotation, revert it once the apps closes
     setprop persist.demo.rotationlock 1
diff --git a/sepolicy/hal_graphics_composer_default.te b/sepolicy/hal_graphics_composer_default.te
index d7715de..9c310f6 100644
--- a/sepolicy/hal_graphics_composer_default.te
+++ b/sepolicy/hal_graphics_composer_default.te
@@ -1,2 +1,3 @@
 vndbinder_use(hal_graphics_composer_default)
 
+allow hal_graphics_composer_default self:netlink_kobject_uevent_socket { bind create read };