Integrate HiSi video decoder support

This adds support for HiSi's video decoder support.

This commit does not contain the library blobs, as those
will be provided in a separate vendor package.

However this seems to gracefully fall back to software
decoding if the libraries aren't present or the kernel
doesn't support the vdec driver (like w/ 4.14+).

Change-Id: I5656e8616b18302a89fb2f708801bd5eb988aa7e
Signed-off-by: John Stultz <john.stultz@linaro.org>
diff --git a/etc/media_codecs.xml b/etc/media_codecs.xml
index 424914d..43bb0d8 100644
--- a/etc/media_codecs.xml
+++ b/etc/media_codecs.xml
@@ -78,6 +78,69 @@
 <MediaCodecs>
     <Include href="media_codecs_google_audio.xml" />
     <Decoders>
+        <MediaCodec name="OMX.hisi.video.decoder.avc" type="video/avc" >
+            <Quirk name="needs-flush-on-all-ports" />
+            <Limit name="size" min="128x128" max="4096x2304" />
+            <Limit name="alignment" value="2x2" />
+            <Limit name="block-size" value="16x16" />
+            <Limit name="blocks-per-second" min="1" max="972000" />
+            <Limit name="bitrate" range="1-100000000" />
+            <Feature name="adaptive-playback" />
+            <Quirk name="requires-allocate-on-input-ports" />
+            <Quirk name="requires-allocate-on-output-ports" />
+            <Limit name="concurrent-instances" max="16" />
+        </MediaCodec>
+        <MediaCodec name="OMX.hisi.video.decoder.hevc" type="video/hevc" >
+            <Quirk name="needs-flush-on-all-ports" />
+            <Limit name="size" min="128x128" max="4096x2304" />
+            <Limit name="alignment" value="2x2" />
+            <Limit name="block-size" value="16x16" />
+            <Limit name="block-count" range="64-36896" />
+            <Limit name="blocks-per-second" range="99-1106880" />
+            <Limit name="bitrate" range="1-52428800" />
+            <Feature name="adaptive-playback" />
+            <Quirk name="requires-allocate-on-input-ports" />
+            <Quirk name="requires-allocate-on-output-ports" />
+            <Limit name="concurrent-instances" max="16" />
+        </MediaCodec>
+        <MediaCodec name="OMX.hisi.video.decoder.mpeg4" type="video/mp4v-es" >
+             <Quirk name="needs-flush-on-all-ports" />
+            <Limit name="size" min="128x128" max="1920x1088" />
+            <Limit name="alignment" value="2x2" />
+            <Limit name="block-size" value="16x16" />
+            <Limit name="blocks-per-second" range="99-244800" />
+            <Limit name="bitrate" range="1-60000000" />
+            <Feature name="adaptive-playback" />
+            <Quirk name="requires-allocate-on-input-ports" />
+            <Quirk name="requires-allocate-on-output-ports" />
+            <Limit name="concurrent-instances" max="16" />
+        </MediaCodec>
+        <MediaCodec name="OMX.hisi.video.decoder.mpeg2" >
+            <Quirk name="needs-flush-on-all-ports" />
+            <Limit name="size" min="128x128" max="1920x1088" />
+            <Limit name="alignment" value="2x2" />
+            <Limit name="block-size" value="16x16" />
+            <Limit name="blocks-per-second" range="99-244800" />
+            <Limit name="bitrate" range="1-60000000" />
+            <Feature name="adaptive-playback" />
+            <Quirk name="requires-allocate-on-input-ports" />
+            <Quirk name="requires-allocate-on-output-ports" />
+            <Limit name="concurrent-instances" max="16" />
+            <Type name="video/mpeg2">
+            <Limit name="concurrent-instances" max="16" />
+            </Type>
+            <Type name="video/mpeg">
+            <Limit name="concurrent-instances" max="16" />
+            </Type>
+        </MediaCodec>
+        <MediaCodec name="OMX.hisi.video.decoder.vp8" type="video/x-vnd.on2.vp8" >
+            <Limit name="size" min="128x128" max="1920x1088" />
+            <Quirk name="needs-flush-on-all-ports" />
+            <Quirk name="requires-allocate-on-input-ports" />
+            <Quirk name="requires-allocate-on-output-ports" />
+            <Feature name="adaptive-playback" />
+            <Limit name="concurrent-instances" max="16" />
+        </MediaCodec>
         <MediaCodec name="OMX.google.mpeg4.decoder" type="video/mp4v-es" />
         <MediaCodec name="OMX.google.h263.decoder" type="video/3gpp" />
         <MediaCodec name="OMX.google.h264.decoder" type="video/avc" />
diff --git a/sepolicy/file_contexts b/sepolicy/file_contexts
index 9d70393..d9658d3 100644
--- a/sepolicy/file_contexts
+++ b/sepolicy/file_contexts
@@ -11,6 +11,9 @@
 /dev/ttyAMA1           u:object_r:hci_attach_dev:s0
 /dev/ttyAMA4           u:object_r:hci_attach_dev:s0
 /dev/hifi_misc         u:object_r:audio_device:s0
+/dev/hi_vdec	       u:object_r:video_device:s0
+/dev/hi_venc	       u:object_r:video_device:s0
+
 
 # files in /vendor
 /(vendor|system/vendor)/bin/uim  u:object_r:hci_attach_exec:s0
diff --git a/ueventd.common.rc b/ueventd.common.rc
index df20cba..b76dd4c 100644
--- a/ueventd.common.rc
+++ b/ueventd.common.rc
@@ -9,6 +9,8 @@
 /dev/nanohub              0660   system     system
 /dev/nanohub_comms        0660   system     system
 /dev/hifi_misc   0666 system audio
+/dev/hi_vdec     0660 system camera
+/dev/hi_venc     0660 system camera
 
 /sys/devices/platform/ddr_devfreq/devfreq/ddr_devfreq		min_freq	0644	system	system
 /sys/devices/platform/e82c0000.mali/devfreq/e82c0000.mali	min_freq	0644	system	system