audio: Set Analog and HDMI mixer controls

cherry-picked from upstream device/linaro/dragonboard project.

Set Analog and HDMI mixer controls for db845c
on boot completion using tinymix.

Put a 1 second sleep in-between pd-mapper and
tinymix to let sound/codecs initialized properly
before setting mixer controls. Also made sure
that audio out interface is ready before
audioserver service get started.

Change-Id: Ib321559815e5d22d224fc36a1fe6c21f52df3eec
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
diff --git a/qcom/init.qcom.rc b/qcom/init.qcom.rc
index 6325127..5867179 100644
--- a/qcom/init.qcom.rc
+++ b/qcom/init.qcom.rc
@@ -19,6 +19,33 @@
     disabled
     oneshot
 
+on post-fs
+    start pd_mapper
+    exec - root -- /system/bin/sleep 1
+    exec - system audio -- /system/bin/tinymix "QUAT_MI2S_RX Audio Mixer MultiMedia1" 1
+    exec - system audio -- /system/bin/tinymix "SLIM RX0 MUX" AIF1_PB
+    exec - system audio -- /system/bin/tinymix "SLIM RX0 MUX" ZERO
+    exec - system audio -- /system/bin/tinymix "SLIM RX1 MUX" ZERO
+    exec - system audio -- /system/bin/tinymix "SLIM RX2 MUX" ZERO
+    exec - system audio -- /system/bin/tinymix "SLIM RX3 MUX" ZERO
+    exec - system audio -- /system/bin/tinymix "SLIM RX4 MUX" ZERO
+    exec - system audio -- /system/bin/tinymix "SLIM RX5 MUX" ZERO
+    exec - system audio -- /system/bin/tinymix "SLIM RX6 MUX" AIF1_PB
+    exec - system audio -- /system/bin/tinymix "SLIM RX7 MUX" AIF1_PB
+    exec - system audio -- /system/bin/tinymix "RX INT7_1 MIX1 INP0" RX6
+    exec - system audio -- /system/bin/tinymix "RX INT8_1 MIX1 INP0" RX7
+    exec - system audio -- /system/bin/tinymix "COMP7 Switch" 1
+    exec - system audio -- /system/bin/tinymix "COMP8 Switch" 1
+    exec - system audio -- /system/bin/tinymix "SpkrLeft COMP Switch" 1
+    exec - system audio -- /system/bin/tinymix "SpkrLeft BOOST Switch" 1
+    exec - system audio -- /system/bin/tinymix "SpkrLeft VISENSE Switch" 0
+    exec - system audio -- /system/bin/tinymix "SpkrLeft DAC Switch" 1
+    exec - system audio -- /system/bin/tinymix "SpkrRight COMP Switch" 1
+    exec - system audio -- /system/bin/tinymix "SpkrRight BOOST Switch" 1
+    exec - system audio -- /system/bin/tinymix "SpkrRight VISENSE Switch" 0
+    exec - system audio -- /system/bin/tinymix "SpkrRight DAC Switch" 1
+    exec - system audio -- /system/bin/tinymix "SLIMBUS_0_RX Audio Mixer MultiMedia2" 1
+
 on post-fs-data
     mkdir /data/vendor
     mkdir /data/vendor/tmp
@@ -27,6 +54,5 @@
     mkdir /data/vendor/readonly/firmware
     mkdir /data/vendor/readonly/firmware/image
     write /sys/class/firmware/timeout 1
-    start pd_mapper
     start tqftpserv
     start rmtfs
diff --git a/sepolicy/file_contexts b/sepolicy/file_contexts
index d6ce47a..270e621 100644
--- a/sepolicy/file_contexts
+++ b/sepolicy/file_contexts
@@ -23,6 +23,8 @@
 /data/vendor/readwrite(/.*)?								u:object_r:tqftpserv_vendor_data_file:s0
 /data/vendor/readonly(/.*)?								u:object_r:tqftpserv_vendor_data_file:s0
 
+/system/bin/tinymix									u:object_r:tinymix_exec:s0
+
 /vendor/bin/hw/android\.hardware\.gatekeeper@1\.0-service\.software			u:object_r:hal_gatekeeper_default_exec:s0
 /vendor/bin/pd-mapper									u:object_r:pd_mapper_exec:s0
 /vendor/bin/rmtfs									u:object_r:rmtfs_exec:s0
diff --git a/sepolicy/tinymix.te b/sepolicy/tinymix.te
new file mode 100644
index 0000000..75dc071
--- /dev/null
+++ b/sepolicy/tinymix.te
@@ -0,0 +1,7 @@
+type tinymix, domain, coredomain;
+type tinymix_exec, exec_type, system_file_type, file_type;
+
+init_daemon_domain(tinymix)
+
+allow tinymix audio_device:chr_file { ioctl open read write };
+allow tinymix audio_device:dir search;