db845c: Add rb5 support in db845c-userdebug build target

* Enabled multiple appended DTBs support to allow db845c
boot.img/vendor_boot.img to boot on rb5 as well.

* Introduced a vendor.hw property which will be used to run
device specific services.

* Folded Caleb's HDMI audio routing fix.

Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
Change-Id: I779d01946ae359d5c405d959419e29460083e5df
diff --git a/sepolicy/file.te b/sepolicy/file.te
index 54de779..e5a0bd1 100644
--- a/sepolicy/file.te
+++ b/sepolicy/file.te
@@ -3,6 +3,7 @@
 type sysfs_rmtfs, fs_type, sysfs_type;
 type sysfs_remoteproc, fs_type, sysfs_type;
 type sysfs_udc, fs_type, sysfs_type;
+type sysfs_dt_compatible, fs_type, sysfs_type;
 type dri_device, dev_type;
 type rmtfs_device, dev_type;
 type modem_block_device, dev_type;
diff --git a/sepolicy/file_contexts b/sepolicy/file_contexts
index e8738ac..d7419dc 100644
--- a/sepolicy/file_contexts
+++ b/sepolicy/file_contexts
@@ -42,6 +42,8 @@
 
 /sys/class/udc										u:object_r:sysfs_udc:s0
 
+/sys/firmware/devicetree/base/compatible						u:object_r:sysfs_dt_compatible:s0
+
 /data/vendor/tmp(/.*)?									u:object_r:tqftpserv_vendor_data_file:s0
 /data/vendor/readwrite(/.*)?								u:object_r:tqftpserv_vendor_data_file:s0
 /data/vendor/readonly(/.*)?								u:object_r:tqftpserv_vendor_data_file:s0
@@ -58,6 +60,7 @@
 /vendor/bin/rmtfs									u:object_r:rmtfs_exec:s0
 /vendor/bin/tqftpserv									u:object_r:tqftpserv_exec:s0
 /vendor/bin/suspend_blocker								u:object_r:suspend_blocker_exec:s0
+/vendor/bin/set_hw\.sh									u:object_r:set_hw_exec:s0
 /vendor/bin/set_udc\.sh									u:object_r:set_udc_exec:s0
 
 /vendor/lib(64)?/dri/.*									u:object_r:same_process_hal_file:s0
diff --git a/sepolicy/genfs_contexts b/sepolicy/genfs_contexts
index 95ce0cc..e8ddb12 100644
--- a/sepolicy/genfs_contexts
+++ b/sepolicy/genfs_contexts
@@ -6,6 +6,7 @@
 genfscon sysfs   /devices/platform/soc@0/17300000.remoteproc					u:object_r:sysfs_remoteproc:s0
 genfscon sysfs   /devices/platform/soc@0/ae00000.mdss						u:object_r:sysfs_gpu:s0
 genfscon sysfs   /class/udc									u:object_r:sysfs_udc:s0
+genfscon sysfs   /firmware/devicetree/base/compatible						u:object_r:sysfs_dt_compatible:s0
 
 #wakeups on db845c
 genfscon sysfs   /devices/platform/soc@0/1c00000.pci/pci0000:00/0000:00:00.0/0000:01:00.0/wakeup/wakeup1					u:object_r:sysfs_wakeup:s0
diff --git a/sepolicy/hal_audio_default.te b/sepolicy/hal_audio_default.te
new file mode 100644
index 0000000..cede442
--- /dev/null
+++ b/sepolicy/hal_audio_default.te
@@ -0,0 +1,2 @@
+# audit2allow
+allow hal_audio_default vendor_hw_prop:file { getattr map open read };
diff --git a/sepolicy/property_contexts b/sepolicy/property_contexts
index 0d68bd3..9c495ab 100644
--- a/sepolicy/property_contexts
+++ b/sepolicy/property_contexts
@@ -1 +1,2 @@
 vendor.usb.controller  u:object_r:vendor_usb_prop:s0
+vendor.hw  u:object_r:vendor_hw_prop:s0
diff --git a/sepolicy/set_hw.te b/sepolicy/set_hw.te
new file mode 100644
index 0000000..996e574
--- /dev/null
+++ b/sepolicy/set_hw.te
@@ -0,0 +1,11 @@
+type set_hw, domain;
+type set_hw_exec, exec_type, vendor_file_type, file_type;
+init_daemon_domain(set_hw);
+
+vendor_public_prop(vendor_hw_prop)
+set_prop(set_hw, vendor_hw_prop)
+get_prop(vendor_init, vendor_hw_prop)
+
+allow set_hw vendor_shell_exec:file rx_file_perms;
+allow set_hw vendor_toolbox_exec:file rx_file_perms;
+allow set_hw sysfs_dt_compatible:file { open read };