Add libdrmdecrypt and sgx

These are copied from vendor/ti/proprietary/omap4 at SHA
73ff514f524f75b68d44e5a81ac29db3064c95f0.  Modify
mk files so that these are only built if
TARGET_BOARD_PLATFORM_VARIANT is ahh.  This is a
step toward moving phantasm over to hardware/ti/omap4-aah.

Change-Id: Ie3eb1702b01c45656caea48abf29d44829ea57b9
Signed-off-by: Mike J. Chen <mjchen@google.com>
diff --git a/Android.mk b/Android.mk
index 2729bab..6147175 100644
--- a/Android.mk
+++ b/Android.mk
@@ -1,4 +1,5 @@
 ifeq ($(TARGET_BOARD_PLATFORM),omap4)
+ifeq ($(TARGET_BOARD_PLATFORM_VARIANT),aah)
 
 LOCAL_PATH:= $(call my-dir)
 HARDWARE_TI_OMAP4_BASE:= $(LOCAL_PATH)
@@ -32,3 +33,4 @@
 
 include $(call first-makefiles-under,$(LOCAL_PATH))
 endif
+endif
diff --git a/libdrmdecrypt/Android.mk b/libdrmdecrypt/Android.mk
new file mode 100644
index 0000000..02138c7
--- /dev/null
+++ b/libdrmdecrypt/Android.mk
@@ -0,0 +1,33 @@
+ifeq ($(TARGET_BOARD_PLATFORM),omap4)
+ifeq ($(TARGET_BOARD_PLATFORM_VARIANT),aah)
+ifeq ($(BOARD_USES_SECURE_SERVICES),true)
+
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+-include $(TOP)/vendor/widevine/proprietary/cryptoPlugin/decrypt-core.mk
+
+LOCAL_C_INCLUDES:= \
+        $(TOP)/frameworks/native/include/media/hardware \
+        $(TOP)/vendor/widevine/proprietary/cryptoPlugin \
+
+LOCAL_STATIC_LIBRARIES += \
+        libtee_client_api_driver        \
+
+LOCAL_SHARED_LIBRARIES := \
+        libstagefright_foundation       \
+        liblog                          \
+        libcutils                       \
+        libcrypto
+
+LOCAL_MODULE_OWNER := ti
+
+LOCAL_MODULE := libdrmdecrypt
+
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_SHARED_LIBRARY)
+
+endif # ifeq ($(BOARD_USES_SECURE_SERVICES),true)
+endif # ifeq ($(strip $(TARGET_BOARD_PLATFORM_VARIANT)),)
+endif # ifeq ($(TARGET_BOARD_PLATFORM),omap4)
diff --git a/omap4.mk b/omap4.mk
index 8bef517..ec31e36 100644
--- a/omap4.mk
+++ b/omap4.mk
@@ -34,6 +34,8 @@
 	hwcomposer.omap4 \
 	smc_pa_ctrl \
 	tf_daemon \
-	libtf_crypto_sst
+	libtf_crypto_sst \
+	ti_omap4_sgx_libs \
+	libdrmdecrypt
 
 PRODUCT_VENDOR_KERNEL_HEADERS := hardware/ti/omap4xxx/kernel-headers
diff --git a/sgx/Android.mk b/sgx/Android.mk
new file mode 100644
index 0000000..8bde0ff
--- /dev/null
+++ b/sgx/Android.mk
@@ -0,0 +1,78 @@
+ifeq ($(TARGET_BOARD_PLATFORM),omap4)
+ifeq ($(TARGET_BOARD_PLATFORM_VARIANT),aah)
+
+LOCAL_PATH := $(call my-dir)
+
+define _add-sgx-vendor-lib
+include $$(CLEAR_VARS)
+$(if $(word 2,$1),$(error Invalid SGX module name $1))
+LOCAL_MODULE := $(basename $(notdir $1))
+LOCAL_MODULE_OWNER := imgtec
+LOCAL_SRC_FILES := $1
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_SUFFIX := $(suffix $1)
+LOCAL_MODULE_CLASS := SHARED_LIBRARIES
+LOCAL_MODULE_PATH := $$(TARGET_OUT)$(abspath /vendor/$(dir $1))
+LOCAL_STRIP_MODULE := true
+OVERRIDE_BUILT_MODULE_PATH := $$(TARGET_OUT_INTERMEDIATE_LIBRARIES)
+include $$(BUILD_PREBUILT)
+endef
+
+define _add-sgx-vendor-bin
+include $$(CLEAR_VARS)
+$(if $(word 2,$1),$(error Invalid SGX module name $1))
+LOCAL_MODULE := $(basename $(notdir $1))
+LOCAL_MODULE_OWNER := imgtec
+LOCAL_SRC_FILES := $1
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_SUFFIX := $(suffix $1)
+LOCAL_MODULE_CLASS := EXECUTABLES
+LOCAL_MODULE_PATH := $$(TARGET_OUT)$(abspath /vendor/$(dir $1))
+LOCAL_STRIP_MODULE := true
+OVERRIDE_BUILT_MODULE_PATH := $$(TARGET_OUT_INTERMEDIATE_EXECUTABLES)
+include $$(BUILD_PREBUILT)
+endef
+
+
+prebuilt_sgx_vendor_libs := \
+	lib/libIMGegl.so \
+	lib/libglslcompiler.so \
+	lib/libusc.so \
+	lib/libPVRScopeServices.so \
+	lib/libsrv_um.so \
+	lib/hw/gralloc.omap4.so \
+	lib/libpvrANDROID_WSEGL.so \
+	lib/libpvr2d.so \
+	lib/libsrv_init.so \
+	lib/egl/libGLESv1_CM_POWERVR_SGX540_120.so \
+	lib/egl/libGLESv2_POWERVR_SGX540_120.so \
+	lib/egl/libEGL_POWERVR_SGX540_120.so
+
+prebuilt_sgx_vendor_bins := \
+	bin/pvrsrvctl
+
+prebuilt_sgx_modules := \
+  $(foreach _file,$(prebuilt_sgx_vendor_libs) $(prebuilt_sgx_vendor_bins),\
+    $(notdir $(basename $(_file))))
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := ti_omap4_sgx_libs
+LOCAL_MODULE_OWNER := ti
+LOCAL_MODULE_TAGS := optional
+LOCAL_REQUIRED_MODULES := $(prebuilt_sgx_modules)
+include $(BUILD_PHONY_PACKAGE)
+
+$(foreach _file,$(prebuilt_sgx_vendor_libs),\
+  $(eval $(call _add-sgx-vendor-lib,$(_file))))
+
+$(foreach _file,$(prebuilt_sgx_vendor_bins),\
+  $(eval $(call _add-sgx-vendor-bin,$(_file))))
+
+prebuilt_sgx_modules :=
+prebuilt_sgx_vendor_libs :=
+prebuilt_sgx_vendor_bins :=
+_add-sgx-vendor-lib :=
+_add-sgx-vendor-bin :=
+
+endif # ifeq ($(TARGET_BOARD_PLATFORM),omap4)
+endif # ifeq ($(TARGET_BOARD_PLATFORM_VARIANT),aah)
diff --git a/sgx/bin/pvrsrvctl b/sgx/bin/pvrsrvctl
new file mode 100755
index 0000000..02afdc5
--- /dev/null
+++ b/sgx/bin/pvrsrvctl
Binary files differ
diff --git a/sgx/lib/egl/libEGL_POWERVR_SGX540_120.so b/sgx/lib/egl/libEGL_POWERVR_SGX540_120.so
new file mode 100644
index 0000000..b499093
--- /dev/null
+++ b/sgx/lib/egl/libEGL_POWERVR_SGX540_120.so
Binary files differ
diff --git a/sgx/lib/egl/libGLESv1_CM_POWERVR_SGX540_120.so b/sgx/lib/egl/libGLESv1_CM_POWERVR_SGX540_120.so
new file mode 100644
index 0000000..9121aff
--- /dev/null
+++ b/sgx/lib/egl/libGLESv1_CM_POWERVR_SGX540_120.so
Binary files differ
diff --git a/sgx/lib/egl/libGLESv2_POWERVR_SGX540_120.so b/sgx/lib/egl/libGLESv2_POWERVR_SGX540_120.so
new file mode 100644
index 0000000..c3d4ce0
--- /dev/null
+++ b/sgx/lib/egl/libGLESv2_POWERVR_SGX540_120.so
Binary files differ
diff --git a/sgx/lib/hw/gralloc.omap4.so b/sgx/lib/hw/gralloc.omap4.so
new file mode 100644
index 0000000..3ba1391
--- /dev/null
+++ b/sgx/lib/hw/gralloc.omap4.so
Binary files differ
diff --git a/sgx/lib/libIMGegl.so b/sgx/lib/libIMGegl.so
new file mode 100644
index 0000000..f803a6e
--- /dev/null
+++ b/sgx/lib/libIMGegl.so
Binary files differ
diff --git a/sgx/lib/libPVRScopeServices.so b/sgx/lib/libPVRScopeServices.so
new file mode 100644
index 0000000..3a2ce36
--- /dev/null
+++ b/sgx/lib/libPVRScopeServices.so
Binary files differ
diff --git a/sgx/lib/libglslcompiler.so b/sgx/lib/libglslcompiler.so
new file mode 100644
index 0000000..5402024
--- /dev/null
+++ b/sgx/lib/libglslcompiler.so
Binary files differ
diff --git a/sgx/lib/libpvr2d.so b/sgx/lib/libpvr2d.so
new file mode 100644
index 0000000..1c76f11
--- /dev/null
+++ b/sgx/lib/libpvr2d.so
Binary files differ
diff --git a/sgx/lib/libpvrANDROID_WSEGL.so b/sgx/lib/libpvrANDROID_WSEGL.so
new file mode 100644
index 0000000..9108dde
--- /dev/null
+++ b/sgx/lib/libpvrANDROID_WSEGL.so
Binary files differ
diff --git a/sgx/lib/libsrv_init.so b/sgx/lib/libsrv_init.so
new file mode 100644
index 0000000..9e2997e
--- /dev/null
+++ b/sgx/lib/libsrv_init.so
Binary files differ
diff --git a/sgx/lib/libsrv_um.so b/sgx/lib/libsrv_um.so
new file mode 100644
index 0000000..4135473
--- /dev/null
+++ b/sgx/lib/libsrv_um.so
Binary files differ
diff --git a/sgx/lib/libusc.so b/sgx/lib/libusc.so
new file mode 100644
index 0000000..d6e3233
--- /dev/null
+++ b/sgx/lib/libusc.so
Binary files differ
diff --git a/sgx/updatelibs.sh b/sgx/updatelibs.sh
new file mode 100755
index 0000000..7a4b927
--- /dev/null
+++ b/sgx/updatelibs.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+for a in `find bin lib -type f`; do
+cp ${ANDROID_PRODUCT_OUT}/target/`basename $a` $a 
+done