hikey960: Update HiFi3 firmware am: b7b7ecdb84 am: 0045a00b8d am: 57ae5a690d
am: 585b633020

Change-Id: Ib485a97eca18f6137f4e8dbc6ad0ab2a6348d0b4
diff --git a/audio/Android.mk b/audio/Android.mk
index fe091a8..c1ba564 100644
--- a/audio/Android.mk
+++ b/audio/Android.mk
@@ -33,5 +33,16 @@
         system/media/audio_utils/include \
         system/media/audio_effects/include
 
+ifeq ($(TARGET_ENABLE_DSP_DEVICE), true)
+LOCAL_CFLAGS += -DENABLE_XAF_DSP_DEVICE
+LOCAL_C_INCLUDES += \
+        $(LOCAL_PATH)/../hifi/xaf/host-apf/include \
+        $(LOCAL_PATH)/../hifi/xaf/host-apf/include/os/android \
+        $(LOCAL_PATH)/../hifi/xaf/host-apf/include/sys/fio\
+        $(LOCAL_PATH)/../hifi/xaf/host-apf/include/audio \
+        $(LOCAL_PATH)/../hifi/xaf/host-apf/utest/include
+
+LOCAL_STATIC_LIBRARIES := libxtensa_proxy
+endif
 include $(BUILD_SHARED_LIBRARY)
 
diff --git a/audio/audio_hw.c b/audio/audio_hw.c
index 7b66a1a..ceeea8c 100644
--- a/audio/audio_hw.c
+++ b/audio/audio_hw.c
@@ -59,6 +59,33 @@
 #define CHANNEL_STEREO 2
 #define MIN_WRITE_SLEEP_US      5000
 
+#ifdef ENABLE_XAF_DSP_DEVICE
+#include "xaf-utils-test.h"
+#include "audio/xa_vorbis_dec_api.h"
+#include "audio/xa-audio-decoder-api.h"
+#define NUM_COMP_IN_GRAPH   1
+
+struct alsa_audio_device;
+
+struct xaf_dsp_device {
+    void *p_adev;
+    void *p_decoder;
+    xaf_info_t comp_info;
+    /* ...playback format */
+    xaf_format_t pb_format;
+    xaf_comp_status dec_status;
+    int dec_info[4];
+    void *dec_inbuf[2];
+    int read_length;
+    xf_id_t dec_id;
+    int xaf_started;
+    mem_obj_t* mem_handle;
+    int num_comp;
+    int (*dec_setup)(void *p_comp, struct alsa_audio_device *audio_device);
+    int xafinitdone;
+};
+#endif
+
 struct stub_stream_in {
     struct audio_stream_in stream;
 };
@@ -71,6 +98,10 @@
     struct alsa_stream_in *active_input;
     struct alsa_stream_out *active_output;
     bool mic_mute;
+#ifdef ENABLE_XAF_DSP_DEVICE
+    struct xaf_dsp_device dsp_device;
+    int hifi_dsp_fd;
+#endif
 };
 
 struct alsa_stream_out {
@@ -86,6 +117,134 @@
     unsigned int written;
 };
 
+#ifdef ENABLE_XAF_DSP_DEVICE
+static int pcm_setup(void *p_pcm, struct alsa_audio_device *audio_device)
+{
+    int param[6];
+
+    param[0] = XA_CODEC_CONFIG_PARAM_SAMPLE_RATE;
+    param[1] = audio_device->dsp_device.pb_format.sample_rate;
+    param[2] = XA_CODEC_CONFIG_PARAM_CHANNELS;
+    param[3] = audio_device->dsp_device.pb_format.channels;
+    param[4] = XA_CODEC_CONFIG_PARAM_PCM_WIDTH;
+    param[5] = audio_device->dsp_device.pb_format.pcm_width;
+
+    XF_CHK_API(xaf_comp_set_config(p_pcm, 3, &param[0]));
+
+    return 0;
+}
+
+void xa_thread_exit_handler(int sig)
+{
+    /* ...unused arg */
+    (void) sig;
+
+    pthread_exit(0);
+}
+
+/*xtensa audio device init*/
+static int xa_device_init(struct alsa_audio_device *audio_device)
+{
+    /* ...initialize playback format */
+    audio_device->dsp_device.p_adev = NULL;
+    audio_device->dsp_device.pb_format.sample_rate = 48000;
+    audio_device->dsp_device.pb_format.channels    = 2;
+    audio_device->dsp_device.pb_format.pcm_width   = 16;
+    audio_device->dsp_device.xafinitdone = 0;
+    audio_frmwk_buf_size = 0; //unused
+    audio_comp_buf_size  = 0; //unused
+    audio_device->dsp_device.num_comp = NUM_COMP_IN_GRAPH;
+    struct sigaction actions;
+    memset(&actions, 0, sizeof(actions));
+    sigemptyset(&actions.sa_mask);
+    actions.sa_flags = 0;
+    actions.sa_handler = xa_thread_exit_handler;
+    sigaction(SIGUSR1,&actions,NULL);
+    /* ...initialize tracing facility */
+    audio_device->dsp_device.xaf_started =1;
+    audio_device->dsp_device.dec_id    = "audio-decoder/pcm";
+    audio_device->dsp_device.dec_setup = pcm_setup;
+    audio_device->dsp_device.mem_handle = mem_init(); //initialize memory handler
+    XF_CHK_API(xaf_adev_open(&audio_device->dsp_device.p_adev, audio_frmwk_buf_size, audio_comp_buf_size, mem_malloc, mem_free));
+    /* ...create decoder component */
+    XF_CHK_API(xaf_comp_create(audio_device->dsp_device.p_adev, &audio_device->dsp_device.p_decoder, audio_device->dsp_device.dec_id, 1, 1, &audio_device->dsp_device.dec_inbuf[0], XAF_DECODER));
+    XF_CHK_API(audio_device->dsp_device.dec_setup(audio_device->dsp_device.p_decoder,audio_device));
+
+    /* ...start decoder component */
+    XF_CHK_API(xaf_comp_process(audio_device->dsp_device.p_adev, audio_device->dsp_device.p_decoder, NULL, 0, XAF_START_FLAG));
+    return 0;
+}
+
+static int xa_device_run(struct audio_stream_out *stream, const void *buffer, size_t frame_size, size_t out_frames, size_t bytes)
+{
+    struct alsa_stream_out *out = (struct alsa_stream_out *)stream;
+    struct alsa_audio_device *adev = out->dev;
+    int ret=0;
+    void *p_comp=adev->dsp_device.p_decoder;
+    xaf_comp_status comp_status;
+    memcpy(adev->dsp_device.dec_inbuf[0],buffer,bytes);
+    adev->dsp_device.read_length=bytes;
+
+    if (adev->dsp_device.xafinitdone == 0) {
+        XF_CHK_API(xaf_comp_process(adev->dsp_device.p_adev, adev->dsp_device.p_decoder, adev->dsp_device.dec_inbuf[0], adev->dsp_device.read_length, XAF_INPUT_READY_FLAG));
+        XF_CHK_API(xaf_comp_get_status(adev->dsp_device.p_adev, adev->dsp_device.p_decoder, &adev->dsp_device.dec_status, &adev->dsp_device.comp_info));
+        ALOGE("PROXY:%s xaf_comp_get_status %d\n",__func__,adev->dsp_device.dec_status);
+        if (adev->dsp_device.dec_status == XAF_INIT_DONE) {
+            adev->dsp_device.xafinitdone = 1;
+            out->written += out_frames;
+            XF_CHK_API(xaf_comp_process(NULL, p_comp, NULL, 0, XAF_EXEC_FLAG));
+        }
+    } else {
+        XF_CHK_API(xaf_comp_process(NULL, adev->dsp_device.p_decoder, adev->dsp_device.dec_inbuf[0], adev->dsp_device.read_length, XAF_INPUT_READY_FLAG));
+        while (1) {
+            XF_CHK_API(xaf_comp_get_status(NULL, p_comp, &comp_status, &adev->dsp_device.comp_info));
+            if (comp_status == XAF_EXEC_DONE) break;
+            if (comp_status == XAF_NEED_INPUT) {
+                 ALOGV("PROXY:%s loop:XAF_NEED_INPUT\n",__func__);
+                 break;
+            }
+            if (comp_status == XAF_OUTPUT_READY) {
+                void *p_buf = (void *)adev->dsp_device.comp_info.buf;
+                int size    = adev->dsp_device.comp_info.length;
+                ret = pcm_mmap_write(out->pcm, p_buf, size);
+                if (ret == 0) {
+                    out->written += out_frames;
+                }
+                XF_CHK_API(xaf_comp_process(NULL, adev->dsp_device.p_decoder, (void *)adev->dsp_device.comp_info.buf, adev->dsp_device.comp_info.length, XAF_NEED_OUTPUT_FLAG));
+            }
+        }
+    }
+    return ret;
+}
+
+static int xa_device_close(struct alsa_audio_device *audio_device)
+{
+    if (audio_device->dsp_device.xaf_started) {
+        xaf_comp_status comp_status;
+        audio_device->dsp_device.xaf_started=0;
+        while (1) {
+            XF_CHK_API(xaf_comp_get_status(NULL, audio_device->dsp_device.p_decoder, &comp_status, &audio_device->dsp_device.comp_info));
+            ALOGV("PROXY:comp_status:%d,audio_device->dsp_device.comp_info.length:%d\n",(int)comp_status,audio_device->dsp_device.comp_info.length);
+            if (comp_status == XAF_EXEC_DONE)
+                break;
+            if (comp_status == XAF_NEED_INPUT) {
+                XF_CHK_API(xaf_comp_process(NULL, audio_device->dsp_device.p_decoder, NULL, 0, XAF_INPUT_OVER_FLAG));
+            }
+
+            if (comp_status == XAF_OUTPUT_READY) {
+                XF_CHK_API(xaf_comp_process(NULL, audio_device->dsp_device.p_decoder, (void *)audio_device->dsp_device.comp_info.buf, audio_device->dsp_device.comp_info.length, XAF_NEED_OUTPUT_FLAG));
+            }
+        }
+
+        /* ...exec done, clean-up */
+        XF_CHK_API(xaf_comp_delete(audio_device->dsp_device.p_decoder));
+        XF_CHK_API(xaf_adev_close(audio_device->dsp_device.p_adev, 0 /*unused*/));
+        mem_exit();
+        XF_CHK_API(print_mem_mcps_info(audio_device->dsp_device.mem_handle, audio_device->dsp_device.num_comp));
+    }
+    return 0;
+}
+#endif
 
 /* must be called with hw device and output stream mutexes locked */
 static int start_output_stream(struct alsa_stream_out *out)
@@ -180,6 +339,9 @@
 
     pthread_mutex_lock(&out->dev->lock);
     pthread_mutex_lock(&out->lock);
+#ifdef ENABLE_XAF_DSP_DEVICE
+    xa_device_close(out->dev);
+#endif
     status = do_output_standby(out);
     pthread_mutex_unlock(&out->lock);
     pthread_mutex_unlock(&out->dev->lock);
@@ -256,6 +418,11 @@
     pthread_mutex_lock(&adev->lock);
     pthread_mutex_lock(&out->lock);
     if (out->standby) {
+#ifdef ENABLE_XAF_DSP_DEVICE
+        if (adev->hifi_dsp_fd >= 0) {
+            xa_device_init(adev);
+        }
+#endif
         ret = start_output_stream(out);
         if (ret != 0) {
             pthread_mutex_unlock(&adev->lock);
@@ -266,11 +433,19 @@
 
     pthread_mutex_unlock(&adev->lock);
 
-
-    ret = pcm_mmap_write(out->pcm, buffer, out_frames * frame_size);
-    if (ret == 0) {
-        out->written += out_frames;
+#ifdef ENABLE_XAF_DSP_DEVICE
+    /*fallback to original audio processing*/
+    if (adev->dsp_device.p_adev != NULL) {
+        ret = xa_device_run(stream, buffer,frame_size, out_frames, bytes);
+    } else {
+#endif
+        ret = pcm_mmap_write(out->pcm, buffer, out_frames * frame_size);
+        if (ret == 0) {
+            out->written += out_frames;
+        }
+#ifdef ENABLE_XAF_DSP_DEVICE
     }
+#endif
 exit:
     pthread_mutex_unlock(&out->lock);
 
@@ -628,7 +803,14 @@
 
 static int adev_close(hw_device_t *device)
 {
+#ifdef ENABLE_XAF_DSP_DEVICE
+    struct alsa_audio_device *adev = (struct alsa_audio_device *)device;
+#endif
     ALOGV("adev_close");
+#ifdef ENABLE_XAF_DSP_DEVICE
+    if (adev->hifi_dsp_fd >= 0)
+        close(adev->hifi_dsp_fd);
+#endif
     free(device);
     return 0;
 }
@@ -672,7 +854,14 @@
     adev->devices = AUDIO_DEVICE_NONE;
 
     *device = &adev->hw_device.common;
-
+#ifdef ENABLE_XAF_DSP_DEVICE
+    adev->hifi_dsp_fd = open(HIFI_DSP_MISC_DRIVER, O_WRONLY, 0);
+    if (adev->hifi_dsp_fd < 0) {
+        ALOGW("hifi_dsp: Error opening device %d", errno);
+    } else {
+        ALOGI("hifi_dsp: Open device");
+    }
+#endif
     return 0;
 }
 
diff --git a/device-common.mk b/device-common.mk
index 1b362bf..d7c3ff5 100644
--- a/device-common.mk
+++ b/device-common.mk
@@ -137,8 +137,8 @@
 
 endif
 
-# Use Launcher3
-PRODUCT_PACKAGES += Launcher3
+# Use Launcher3QuickStep
+PRODUCT_PACKAGES += Launcher3QuickStep
 
 # Copy hardware config file(s)
 PRODUCT_COPY_FILES +=  \
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/hifi/firmware/hifi-hikey960.img b/hifi/firmware/hifi-hikey960.img
index 0a731bf..b8c2516 100644
--- a/hifi/firmware/hifi-hikey960.img
+++ b/hifi/firmware/hifi-hikey960.img
Binary files differ
diff --git a/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/dsp_driver_mailbox.h b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/dsp_driver_mailbox.h
index 8730df2..5fdcca9 100644
--- a/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/dsp_driver_mailbox.h
+++ b/hifi/xaf/hifi-dpf/include/sys/xt-shmem/board-hikey/dsp_driver_mailbox.h
@@ -132,8 +132,9 @@
 	/* ...length of attached buffer */
 	uint32_t                 length;
 
-	/* ...shared logical address of message buffer */
+	/* ...physical address of message buffer */
 	uint64_t                 address;
+	uint64_t                 v_address;
 
 }	__attribute__((__packed__)) xf_proxy_msg_t;
 
diff --git a/hifi/xaf/hifi-dpf/include/xf-proxy.h b/hifi/xaf/hifi-dpf/include/xf-proxy.h
index 298b782..0260749 100644
--- a/hifi/xaf/hifi-dpf/include/xf-proxy.h
+++ b/hifi/xaf/hifi-dpf/include/xf-proxy.h
@@ -39,16 +39,17 @@
 typedef struct xf_proxy_message
 {
     /* ...session ID */
-    u32                 session_id;
+    uint32_t                 session_id;
 
     /* ...proxy API command/reponse code */
-    u32                 opcode;
+    uint32_t                 opcode;
 
     /* ...length of attached buffer */
-    u32                 length;
+    uint32_t                 length;
 
     /* ...physical address of message buffer */
-    u32                 address;
+    uint64_t                 address;
+    uint64_t                 v_address;
 
 }   __attribute__((__packed__)) xf_proxy_message_t;
 #else
@@ -68,7 +69,7 @@
     uint64_t                 address;
     uint64_t                 v_address;
 
-}/*   __attribute__((__packed__)) */xf_proxy_message_t;
+}   __attribute__((__packed__)) xf_proxy_message_t;
 #endif
 /*******************************************************************************
  * Ring buffer support
diff --git a/hifi/xaf/host-apf/Android.mk b/hifi/xaf/host-apf/Android.mk
index aa859d0..28e7101 100644
--- a/hifi/xaf/host-apf/Android.mk
+++ b/hifi/xaf/host-apf/Android.mk
@@ -23,7 +23,7 @@
 	utest/xaf-utils-test.c	\
 	utest/xaf-mem-test.c
 
-C_FLAGS := -DXF_TRACE=1 -Wall -Werror #-Wno-everything
+C_FLAGS := -DXF_TRACE=0 -Wall -Werror -Wno-everything
 
 LOCAL_C_INCLUDES := $(common_C_INCLUDES)
 LOCAL_CFLAGS := $(C_FLAGS)
diff --git a/hifi/xaf/host-apf/include/xf-proxy.h b/hifi/xaf/host-apf/include/xf-proxy.h
index ab8bd23..90d7079 100644
--- a/hifi/xaf/host-apf/include/xf-proxy.h
+++ b/hifi/xaf/host-apf/include/xf-proxy.h
@@ -48,19 +48,19 @@
 struct xf_proxy_msg
 {
     /* ...session-id field */
-    u32             id;
+    uint32_t             id;
     
     /* ...message opcode */
-    u32             opcode;
+    uint32_t             opcode;
     
     /* ...buffer length */
-    u32             length;
+    uint32_t             length;
     
     /* ...buffer pointer */
-    u32             address;
-uint64_t         v_address;
+    uint64_t             address;
+    uint64_t         v_address;
 
-}/*   __attribute__((__packed__))*/;
+}   __attribute__((__packed__));
 
 typedef struct xf_proxy_msg_driv
 {
@@ -77,7 +77,7 @@
     uint64_t                 address;
     uint64_t                 v_address;
 
-}xf_proxy_message_driv_t;
+}__attribute__((__packed__)) xf_proxy_message_driv_t;
 /*******************************************************************************
  * Buffer pools
  ******************************************************************************/
diff --git a/hikey.mk b/hikey.mk
index 0b32845..14a2e92 100644
--- a/hikey.mk
+++ b/hikey.mk
@@ -1,6 +1,13 @@
 $(call inherit-product, $(SRC_TARGET_DIR)/product/core_64_bit.mk)
 $(call inherit-product, device/linaro/hikey/hikey-common.mk)
 
+#setup dm-verity configs
+PRODUCT_SYSTEM_VERITY_PARTITION := /dev/block/platform/soc/f723d000.dwmmc0/by-name/system
+PRODUCT_VENDOR_VERITY_PARTITION := /dev/block/platform/soc/f723d000.dwmmc0/by-name/vendor
+$(call inherit-product, build/target/product/verity.mk)
+PRODUCT_SUPPORTS_BOOT_SIGNER := false
+PRODUCT_SUPPORTS_VERITY_FEC := false
+
 PRODUCT_NAME := hikey
 PRODUCT_DEVICE := hikey
 PRODUCT_BRAND := Android
diff --git a/hikey/fstab.hikey b/hikey/fstab.hikey
index 35eee26..e70b2c6 100644
--- a/hikey/fstab.hikey
+++ b/hikey/fstab.hikey
@@ -3,9 +3,8 @@
 # The filesystem that contains the filesystem checker binary (typically /system) cannot
 # specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK
 
-/dev/block/platform/soc/f723d000.dwmmc0/by-name/system      /system             ext4      ro                                                           wait
-/dev/block/platform/soc/f723d000.dwmmc0/by-name/system      /system             squashfs  ro                                                           wait
-/dev/block/platform/soc/f723d000.dwmmc0/by-name/vendor      /vendor             ext4      ro                                                           wait
+/dev/block/platform/soc/f723d000.dwmmc0/by-name/system      /system             ext4      ro                                                           wait,verify
+/dev/block/platform/soc/f723d000.dwmmc0/by-name/vendor      /vendor             ext4      ro                                                           wait,verify
 /dev/block/platform/soc/f723d000.dwmmc0/by-name/cache       /cache              ext4      discard,noatime,noauto_da_alloc,data=ordered,user_xattr,barrier=1    wait
 /dev/block/platform/soc/f723d000.dwmmc0/by-name/userdata    /data               f2fs      discard,noatime,nosuid,nodev                                 wait,check,fileencryption=software,quota
 /dev/block/platform/soc/f723d000.dwmmc0/by-name/userdata    /data               ext4      discard,noatime,noauto_da_alloc,data=ordered,user_xattr,barrier=1    wait,formattable
diff --git a/hikey960/device-hikey960.mk b/hikey960/device-hikey960.mk
index 47b6bbe..ad2f9d7 100644
--- a/hikey960/device-hikey960.mk
+++ b/hikey960/device-hikey960.mk
@@ -53,3 +53,5 @@
 PRODUCT_PACKAGES += power.hikey960
 
 PRODUCT_PACKAGES += sensors.hikey960
+
+$(call inherit-product-if-exists, vendor/linaro/hikey960/device-vendor.mk)
diff --git a/hikey960/fstab.hikey960 b/hikey960/fstab.hikey960
index a811839..4657187 100644
--- a/hikey960/fstab.hikey960
+++ b/hikey960/fstab.hikey960
@@ -13,3 +13,4 @@
 /dev/block/sdd13    /data      ext4    discard,noatime,noauto_da_alloc,data=ordered,user_xattr,barrier=1    wait,formattable
 /devices/platform/soc/ff37f000.dwmmc1/mmc_host/mmc*      auto       auto    defaults    voldmanaged=sdcard1:auto,encryptable=userdata
 /devices/platform/soc/ff200000.hisi_usb/ff100000.dwc3/xhci-hcd.*.auto/usb*               auto               auto      defaults  voldmanaged=usbdisk:auto,encryptable=userdata
+/devices/platform/soc/f4000000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/nvme/nvme*      auto       auto    defaults    voldmanaged=nvmedisk:auto,encryptable=userdata
diff --git a/init.common.rc b/init.common.rc
index 0085215..e5bfb43 100644
--- a/init.common.rc
+++ b/init.common.rc
@@ -120,3 +120,9 @@
     class core
     oneshot
     seclabel u:r:watchdogd:s0
+
+service bugreport /system/bin/dumpstate -d -p -B -z \
+    -o /data/user_de/0/com.android.shell/files/bugreports/bugreport
+    class main
+    disabled
+    oneshot
diff --git a/installer/hikey/flash-all.sh b/installer/hikey/flash-all.sh
index a4170dd..be909fe 100755
--- a/installer/hikey/flash-all.sh
+++ b/installer/hikey/flash-all.sh
@@ -71,6 +71,7 @@
         fastboot oem serialno
     fi
 fi
+fastboot getvar partition-size:ptable
 fastboot flash ptable "${INSTALLER_DIR}"/"${PTABLE}"
 fastboot flash fastboot "${FIRMWARE_DIR}"/fip.bin
 fastboot flash nvme "${INSTALLER_DIR}"/nvme.img
diff --git a/self-extractors_hikey960/arm/COPYRIGHT b/self-extractors_hikey960/arm/COPYRIGHT
deleted file mode 100644
index c627c1a..0000000
--- a/self-extractors_hikey960/arm/COPYRIGHT
+++ /dev/null
@@ -1 +0,0 @@
-# (C) ARM Limited.
diff --git a/self-extractors_hikey960/arm/LICENSE b/self-extractors_hikey960/arm/LICENSE
deleted file mode 100644
index 4a8cdd5..0000000
--- a/self-extractors_hikey960/arm/LICENSE
+++ /dev/null
@@ -1,177 +0,0 @@
-THIS END USER LICENCE AGREEMENT ("LICENCE") IS A LEGAL AGREEMENT
-BETWEEN YOU (EITHER A SINGLE INDIVIDUAL, OR SINGLE LEGAL ENTITY) AND
-ARM LIMITED ("ARM") FOR THE USE OF THE SOFTWARE ACCOMPANYING THIS
-LICENCE. ARM IS ONLY WILLING TO LICENSE THE SOFTWARE TO YOU ON
-CONDITION THAT YOU ACCEPT ALL OF THE TERMS IN THIS LICENCE. BY
-CLICKING "I AGREE" OR BY INSTALLING OR OTHERWISE USING OR COPYING THE
-SOFTWARE YOU INDICATE THAT YOU AGREE TO BE BOUND BY ALL OF THE TERMS
-OF THIS LICENCE. IF YOU DO NOT AGREE TO THE TERMS OF THIS LICENCE, ARM
-IS UNWILLING TO LICENSE THE SOFTWARE TO YOU AND YOU MAY NOT INSTALL,
-USE OR COPY THE SOFTWARE, AND YOU SHOULD PROMPTLY RETURN THE SOFTWARE
-TO YOUR SUPPLIER.
-
-"Software" means any software, firmware and data accompanying this
-Licence, any printed, electronic or online documentation supplied with
-it under the terms of this Licence for the MALI GPU Driver.
-
-  1. LICENCE GRANTS TO YOU.
-
-  1.1 ARM hereby grants to you, subject to the terms and conditions of
-  this Licence, a non-exclusive, non-transferable, revocable, worldwide
-  licence to: (i) use the Software or certain components or optional
-  functionality in the Software, as applicable, solely for the purposes
-  of designing or developing applications for use in conjunction with
-  MALI GPU based products manufactured under licence from ARM; and (ii)
-  modify the Software or certain components or optional functionality in
-  the Software for the purposes of porting the Software to your target;
-
-  2. RESTRICTIONS ON USE OF THE SOFTWARE.
-
-  COPYING: You shall not use or copy the Software except as expressly
-  authorised in this Licence. You may make one additional copy of the
-  delivered Software for backup or archival purposes.
-
-  BENCHMARKING: This Licence does not prevent you from using the
-  Software for internal benchmarking purposes. However, you shall treat
-  any and all benchmarking data relating to the Software, and any other
-  results of your use or testing of the Software which are indicative of
-  its performance, efficacy, reliability or quality, as confidential
-  information and you shall not disclose such information to any third
-  party without the express written permission of ARM.
-
-  COPYRIGHT AND RESERVATION OF RIGHTS: The Software is owned by ARM or
-  its licensors and is protected by copyright and other intellectual
-  property laws and international treaties. The Software is licensed not
-  sold. You acquire no rights to the Software other than as expressly
-  provided by this Licence. You shall not remove from the Software any
-  copyright notice or other notice and shall ensure that any such notice
-  is reproduced in any copies of the whole or any part of the Software
-  made by you or other permitted users.
-
-  REVERSE ENGINEERING: Except to the extent that such activity is
-  permitted by applicable law you shall not reverse engineer, decompile
-  or disassemble any of the Software. If the Software was provided to
-  you in Europe you shall not reverse engineer, decompile or disassemble
-  any of the Software for the purposes of error correction.
-
-  3. SUPPORT.
-
-  ARM is not under an obligation to provide support, but it may do so at
-  its own discretion, and if it does, it will only be in respect of the
-  Software as delivered and not any modifications thereto.
-
-  4. NO WARRANTIES.
-
-  YOU AGREE THAT THE SOFTWARE IS LICENSED "AS IS", AND THAT ARM
-  EXPRESSLY DISCLAIMS ALL REPRESENTATIONS, WARRANTIES, CONDITIONS OR
-  OTHER TERMS, EXPRESS OR IMPLIED OR STATUTORY, INCLUDING WITHOUT
-  LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, SATISFACTORY
-  QUALITY, AND FITNESS FOR A PARTICULAR PURPOSE.
-
-  YOU EXPRESSLY ASSUME ALL LIABILITIES AND RISKS, FOR USE OR OPERATION
-  OF SOFTWARE APPLICATIONS, INCLUDING WITHOUT LIMITATION, SOFTWARE
-  APPLICATIONS DESIGNED OR INTENDED FOR MISSION CRITICAL APPLICATIONS,
-  SUCH AS PACEMAKERS, WEAPONRY, AIRCRAFT NAVIGATION, FACTORY CONTROL
-  SYSTEMS, ETC. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE
-  ENTIRE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
-  5. LIMITATION OF LIABILITY.
-
-  TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL
-  ARM BE LIABLE FOR ANY INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL
-  DAMAGES (INCLUDING LOSS OF PROFITS) ARISING OUT OF THE USE OR
-  INABILITY TO USE THE SOFTWARE WHETHER BASED ON A CLAIM UNDER CONTRACT,
-  TORT OR OTHER LEGAL THEORY, EVEN IF ARM WAS ADVISED OF THE POSSIBILITY
-  OF SUCH DAMAGES.
-
-  ARM does not seek to limit or exclude liability for death or personal
-  injury arising from ARM's negligence or ARM's fraud and because some
-  jurisdictions do not permit the exclusion or limitation of liability
-  for consequential or incidental damages the above limitation relating
-  to liability for consequential damages may not apply to you.
-
-  NOTWITHSTANDING ANYTHING TO THE CONTRARY CONTAINED IN THIS LICENCE,
-  THE MAXIMUM LIABILITY OF ARM TO YOU IN AGGREGATE FOR ALL CLAIMS MADE
-  AGAINST ARM IN CONTRACT TORT OR OTHERWISE UNDER OR IN CONNECTION WITH
-  THE SUBJECT MATTER OF THIS LICENCE SHALL NOT EXCEED THE GREATER OF:
-  (I) THE TOTAL OF SUMS PAID BY YOU TO ARM (IF ANY) FOR THIS LICENCE;
-  AND (II) $10.00 USD. THE EXISTENCE OF MORE THAN ONE CLAIM WILL NOT
-  ENLARGE OR EXTEND THE LIMIT.
-
-  6. CONFIDENTIALITY.
-
-  You acknowledge that the Software and any benchmarking data and
-  related information mentioned in Clause 2 may contain trade secrets
-  and confidential material and you agree to maintain all such
-  information in confidence and apply security measures no less
-  stringent than the measures which you apply to protect your own like
-  information, but not less than a reasonable degree of care, to prevent
-  their unauthorised disclosure and use. Subject to any restrictions
-  imposed by applicable law, the period of confidentiality shall be
-  indefinite. You agree not to use any such information other than in
-  normal use of the Software under the licences granted in this Licence.
-
-  7. U.S. GOVERNMENT END USERS.
-
-  US Government Restrictions: Use, duplication, reproduction, release,
-  modification, disclosure or transfer of the Software is restricted in
-  accordance with the terms of this Licence.
-
-  8. TERM AND TERMINATION.
-
-  This Licence shall remain in force until terminated by you or by
-  ARM. Without prejudice to any of its other rights if you are in breach
-  of any of the terms and conditions of this Licence then ARM may
-  terminate this Licence immediately upon giving written notice to you
-  or on thirty (30) days written notice without cause. You may terminate
-  this Licence at any time. Upon termination of this Licence by you or
-  by ARM , you shall stop using the Software and confidential
-  information and destroy all copies of the Software and confidential
-  information in your possession, together with all documentation and
-  related materials. The provisions of clauses 4, 5, 6, 7, 8 and 9 shall
-  survive termination of this Licence.
-
-  9. GENERAL.
-
-  This Licence is governed by English Law. Except where ARM agrees
-  otherwise in: (i) a written contract signed by you and ARM; or (ii) a
-  written contract provided by ARM and accepted by you, this is the only
-  agreement between you and ARM relating to the Software and it may only
-  be modified by written agreement between you and ARM. Except as
-  expressly agreed in writing, this Licence may not be modified by
-  purchase orders, advertising or other representation by any person. If
-  any clause or sentence in this Licence is held by a court of law to be
-  illegal or unenforceable the remaining provisions of this Licence
-  shall not be affected thereby. The failure by ARM to enforce any of
-  the provisions of this Licence, unless waived in writing, shall not
-  constitute a waiver of ARM's rights to enforce such provision or any
-  other provision of this Licence in the future.
-
-  At ARM's request, you agree to check your computers for installations
-  of the Software and any other information requested by ARM relating to
-  Software installation and to provide this information to ARM. You
-  agree that auditors nominated by ARM may also perform such checking
-  and reporting on behalf of ARM by prior appointment during your normal
-  business hours on seven (7) days' notice. ARM shall bear the auditors'
-  costs for that audit unless it reveals unlicensed usage in which case
-  you shall promptly reimburse ARM for all reasonable costs and
-  expenses, including professional fees, relating to such audit. Any
-  information which is disclosed to ARM or such auditors during checking
-  or audit shall be treated as your confidential information and shall
-  only be used by ARM for licence management, compliance and enforcement
-  purposes.
-
-  The Software provided under this Licence is subject to U.S. export
-  control laws, including the U.S. Export Administration Act and its
-  associated regulations, and may be subject to export or import
-  regulations in other countries. You agree to comply fully with all
-  laws and regulations of the United States and other countries ("Export
-  Laws") to assure that the Software, is not (1) exported, directly or
-  indirectly, in violation of Export Laws, either to any countries that
-  are subject to U.S.A. export restrictions or to any end user who has
-  been prohibited from participating in the U.S.A. export transactions
-  by any federal agency of the U.S.A. government; or (2) intended to be
-  used for any purpose prohibited by Export Laws, including, without
-  limitation, nuclear, chemical, or biological weapons proliferation.
-
-Mali GPU Userspace LES-PRE-20376
diff --git a/self-extractors_hikey960/arm/staging/device-partial.mk b/self-extractors_hikey960/arm/staging/device-partial.mk
deleted file mode 100644
index 8af8e9c..0000000
--- a/self-extractors_hikey960/arm/staging/device-partial.mk
+++ /dev/null
@@ -1,20 +0,0 @@
-# Copyright 2016 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# Linaro blob(s) necessary for Hikey hardware
-PRODUCT_COPY_FILES := \
-    vendor/linaro/hikey960/arm/proprietary/lib64/libGLES_mali.so:system/lib64/egl/libGLES_mali.so:linaro \
-    vendor/linaro/hikey960/arm/proprietary/libGLES_mali.so:system/lib/egl/libGLES_mali.so:linaro \
-    vendor/linaro/hikey960/arm/proprietary/lib64/libGLES_mali.so:system/vendor/lib64/hw/vulkan.hikey960.so:linaro \
-    vendor/linaro/hikey960/arm/proprietary/libGLES_mali.so:system/vendor/lib/hw/vulkan.hikey960.so:linaro
diff --git a/self-extractors_hikey960/extract-lists.txt b/self-extractors_hikey960/extract-lists.txt
index ad4df6b..932ca9b 100644
--- a/self-extractors_hikey960/extract-lists.txt
+++ b/self-extractors_hikey960/extract-lists.txt
@@ -1,6 +1,18 @@
-  arm)
+  hisilicon)
     TO_EXTRACT="\
-            SYSTEM/lib/egl/libGLES_mali.so \
-            SYSTEM/lib64/egl/libGLES_mali.so \
+            SYSTEM/lib/libc_secshared.so \
+            SYSTEM/lib/libhiion.so \
+            SYSTEM/lib/libhilog.so \
+            SYSTEM/lib/libOMX.hisi.vdec.core.so \
+            SYSTEM/lib/libOMX.hisi.video.decoder.so \
+            SYSTEM/lib/libOMX_Core.so \
+            SYSTEM/lib/libstagefrighthw.so \
+            SYSTEM/lib64/libc_secshared.so \
+            SYSTEM/lib64/libhiion.so \
+            SYSTEM/lib64/libhilog.so \
+            SYSTEM/lib64/libOMX.hisi.vdec.core.so \
+            SYSTEM/lib64/libOMX.hisi.video.decoder.so \
+            SYSTEM/lib64/libOMX_Core.so \
+            SYSTEM/lib64/libstagefrighthw.so \
             "
             ;;
diff --git a/self-extractors_hikey960/hisilicon/COPYRIGHT b/self-extractors_hikey960/hisilicon/COPYRIGHT
new file mode 100644
index 0000000..8e57b9d
--- /dev/null
+++ b/self-extractors_hikey960/hisilicon/COPYRIGHT
@@ -0,0 +1 @@
+# (C) HiSilicon Limited.
diff --git a/self-extractors_hikey960/hisilicon/LICENSE b/self-extractors_hikey960/hisilicon/LICENSE
new file mode 100644
index 0000000..4746d43
--- /dev/null
+++ b/self-extractors_hikey960/hisilicon/LICENSE
@@ -0,0 +1,126 @@
+End User License Agreement for Software related to Hisilicon HiKey960 Board
+
+THIS END USER LICENSE AGREEMENT (“AGREEMENT”) IS A LEGAL AGREEMENT BETWEEN
+YOU (EITHER A SINGLE INDIVIDUAL, OR SINGLE LEGAL ENTITY) AND HISILICON
+TECHNOLOGIES CO., LTD. (&quot;HISILICON&quot;) FOR THE USE OF THE SOFTWARE ACCOMPANYING
+THIS AGREEMENT. HISILICON IS ONLY WILLING TO LICENSE THE SOFTWARE TO YOU ON
+CONDITION THAT YOU ACCEPT ALL OF THE TERMS IN THIS AGREEMENT. BY CLICKING “I
+AGREE” OR BY INSTALLING OR OTHERWISE USING OR COPYING THE SOFTWARE YOU
+INDICATE THAT YOU AGREE TO BE BOUND BY ALL OF THE TERMS OF THIS AGREEMENT. IF
+YOU DO NOT AGREE TO THE TERMS OF THIS AGREEMENT, HISILICON IS UNWILLING
+TO LICENSE THE SOFTWARE TO YOU AND YOU MAY NOT INSTALL, USE OR COPY THE
+SOFTWARE, AND YOU SHALL PROMPTLY DESTROY, DELETE, OR RETURN THE SOFTWARE TO
+YOUR SUPPLIER.
+
+“SOFTWARE” means the software in object code provided under the terms of this Agreement related
+to Hisilicon HiKey960 Board.
+
+1. GRANT OF LICENSE
+In consideration of your agreement to abide by the following terms, and subject to the terms and conditions of
+this Agreement, HISILICON hereby grants YOU, a non-transferable, non-exclusive, royalty-free, revocable,
+worldwide copyright license (without the right to sublicense) to use and copy the SOFTWARE solely for the
+purpose of designing or developing applications for use in conjunction with Hisilicon HiKey960 Board.
+All rights to the SOFTWARE and all intellectual property rights contained therein shall remain the sole and
+exclusive property of HISILICON. The SOFTWARE is licensed not sold. Except as expressly licensed in
+Clause 1, in no event shall the license granted in this Clause 1 be construed as granting YOU expressly or by
+implication, estoppels or otherwise, licenses to any intellectual property rights, including but not limited to
+patent rights, copyrights, trademark or trade secret in the SOFTWARE.
+No right is granted to YOU under this Agreement to manufacture, have manufactured, or sell, supply or
+distribute any products which have taken into use or which embody any of the SOFTWARE or any of the
+intellectual property rights embodied therein.
+
+2. RESTRICTIONS
+This Agreement does not prevent YOU from using the SOFTWARE for internal benchmarking purposes.
+However, YOU shall treat any and all benchmarking data relating to the SOFTWARE, and any other results of
+your use or testing of the SOFTWARE which are indicative of its performance, efficacy, reliability or quality,
+as confidential information and YOU shall not disclose such information to any third party without the express
+written permission of HISILICON.
+
+YOU shall reproduce and not remove or obscure any notice incorporated by HISILICON in the SOFTWARE to
+protect HISILICON’s intellectual property rights embodied therein.
+YOU shall not decompile, disassemble, or reverse engineer the SOFTWARE.
+
+3. FEEDBACK
+YOU may choose to provide suggestions, comments, feedback, ideas, modifications or know-how (whether in
+oral or written form) relating to the use of the SOFTWARE (&quot;Feedback&quot;) to HISILICON under the terms of this
+Agreement. YOU hereby grants to HISILICON and its affiliates, under all of your and your affiliates’ (as applicable)
+intellectual property rights, a perpetual, irrevocable, royalty free, non-exclusive, worldwide license
+to (i) use, copy and modify the Feedback; (ii) sell, supply, or otherwise distribute the Feedback; (iii) design,
+have designed, manufacture, have manufactured, use, import, sell, and otherwise distribute and dispose of
+products that incorporate the Feedback; and (iv) sublicense (together with the rights to further sublicense) the
+rights granted in this paragraph to any third party.
+
+4. NO WARRANTY
+YOU AGREE THAT THE SOFTWARE IS PROVIDED BY HISILICON ON AN &quot;AS IS&quot; BASIS.
+HISILICON MAKES NO WARRANTY, EXPRESSED OR IMPLIED OR STATUTORY, WITH RESPECT
+TO ANY OF THE SOFTWARE, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES
+OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE OR
+NON-INFRINGEMENT.
+YOU EXPRESSLY ASSUME ALL LIABILITIES AND RISKS, FOR USE OR OPERATION OF THE
+SOFTWARE, INCLUDING WITHOUT LIMITATION, SOFTWARE APPLICATIONS DESIGNED OR
+INTENDED FOR MISSION CRITICAL APPLICATIONS, SUCH AS PACEMAKERS, WEAPONRY,
+AIRCRAFT NAVIGATION, FACTORY CONTROL SYSTEMS, ETC. SHOULD THE SOFTWARE
+PROVE DEFECTIVE, YOU ASSUME THE ENTIRE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+5. NO LIABILITY
+PLEASE READ THE INSTRUCTIONS COMPLETELY, AND PLEASE NOTE THAT YOU SHOULD USE
+THE SOFTWARE AT YOUR OWN RISK.
+IN NO EVENT SHALL HISILICON BE LIABLE FOR ANY DIRECT OR INDIRECT, SPECIAL,
+INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION,
+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE OF OR INABILITY TO USE
+THE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT
+(INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHER LEGAL THEORY, EVEN IF HISILICON
+HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. EVEN IF THE SOFTWARE HAS
+ANY MATERIAL, VERIFIABLE, AND REPRODUCIBLE PROGRAM ERRORS, HISILICON SHALL
+HAVE NO LIABILITY TO MODIFY SUCH ERRORS.
+NOTWITHSTANDING ANYTHING TO THE CONTRARY CONTAINED IN THIS AGREEMENT, THE
+MAXIMUM LIABILITY OF HISILICON TO YOU IN AGGREGATE FOR ALL CLAIMS MADE AGAINST
+HISILICON IN CONTRACT TORT OR OTHERWISE UNDER OR IN CONNECTION WITH THE
+SUBJECT MATTER OF THIS AGREEMENT SHALL NOT EXCEED THE TOTAL OF SUMS
+RECEIVED BY HISILICON FROM YOU FOR THIS AGREEMENT. THE EXISTENCE OF MORE
+THAN ONE CLAIM WILL NOT ENLARGE OR EXTEND THE LIMIT.
+
+6. CONFIDENTIALITY
+YOU acknowledge and agree that the SOFTWARE and any benchmarking data and related information
+provided under this Agreement contain trade secrets and confidential material of HISILICON and YOU agree
+to maintain all such information in confidence and apply security measures no less stringent than the measures
+which YOU apply to protect your own like information, but not less than a reasonable degree of care, to prevent
+their unauthorized disclosure and use. The period of confidentiality shall be indefinite. YOU agree not to use
+any such information other than in normal use of the SOFTWARE under the license granted in this Agreement.
+
+7. TERM AND TERMINATION
+This Agreement shall remain in force until terminated. HISILICON may terminate this Agreement at any time
+with or without any cause. Upon termination of this Agreement, YOU shall immediately stop using the
+SOFTWARE and confidential information and destroy all copies of the SOFTWARE and confidential
+information in your possession, together with all documentation and related materials. The provisions
+of clauses 3, 4, 5, 6, 7 and 8 shall survive termination of this Agreement.
+
+8. GENERAL
+Any provision of this Agreement which is prohibited or unenforceable in any jurisdiction shall be ineffective to
+the extent of such prohibition or unenforceability without affecting, impairing or invalidating the remaining
+provisions hereof.
+The failure by HISILICON to enforce any of the provisions of this Agreement, unless waived in writing,
+shall not constitute a waiver of HISILICON&#39;s rights to enforce such provision or any other provision of
+this Agreement in the future.
+At HISILICON’s request, YOU agree to check your computers for installations of the SOFTWARE and any
+other information requested by HISILICON relating to SOFTWARE installation and to provide this
+information to HISILICON. YOU agree that employees or auditors nominated by HISILICON may also
+perform such checking and reporting on behalf of HISILICON by prior appointment during your normal
+business hours on seven (7) days’ notice. HISILICON shall bear the auditors’ costs for that audit unless it
+reveals unlicensed usage in which case YOU shall promptly reimburse HISILICON for all reasonable costs and
+expenses, including professional fees, relating to such audit.
+The SOFTWARE provided under this Agreement is subject to U.S. export control laws, including the
+U.S. Export Administration Act and its associated regulations, and may be subject to export or import
+regulations in other countries. YOU agree to comply fully with all laws and regulations of the United
+States and other countries (&quot;Export Laws&quot;) to assure that the SOFTWARE, is not (1) exported, directly
+or indirectly, in violation of Export Laws, either to any countries that are subject to U.S.A. export
+restrictions or to any end user who has been prohibited from participating in the U.S.A. export
+transactions by any federal agency of the U.S.A. government; or (2) intended to be used for any
+purpose prohibited by Export Laws, including, without limitation, nuclear, chemical, or biological
+weapons proliferation.
+This Agreement shall be governed by and construed in accordance with the laws of People’s Republic of China,
+without reference to the principles of conflicts of laws. Any dispute arising out of or relating to this Agreement
+shall be submitted to Shenzhen Longgang District People’s court and parties waive all objections to that
+jurisdiction and venue.
diff --git a/self-extractors_hikey960/arm/staging/BoardConfigPartial.mk b/self-extractors_hikey960/hisilicon/staging/BoardConfigPartial.mk
similarity index 100%
rename from self-extractors_hikey960/arm/staging/BoardConfigPartial.mk
rename to self-extractors_hikey960/hisilicon/staging/BoardConfigPartial.mk
diff --git a/self-extractors_hikey960/hisilicon/staging/device-partial.mk b/self-extractors_hikey960/hisilicon/staging/device-partial.mk
new file mode 100644
index 0000000..c76663a
--- /dev/null
+++ b/self-extractors_hikey960/hisilicon/staging/device-partial.mk
@@ -0,0 +1,32 @@
+# Copyright 2016 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Blobs needed for HiKey960 video decoding hardware
+TARGET_HISI_CODEC_VERSION := 1
+
+PRODUCT_COPY_FILES  += vendor/linaro/hikey960/hisilicon/proprietary/libOMX.hisi.video.decoder.so:$(TARGET_COPY_OUT_VENDOR)/lib/libOMX.hisi.video.decoder.so \
+    vendor/linaro/hikey960/hisilicon/proprietary/lib64/libOMX.hisi.video.decoder.so:$(TARGET_COPY_OUT_VENDOR)/lib64/libOMX.hisi.video.decoder.so \
+    vendor/linaro/hikey960/hisilicon/proprietary/libOMX.hisi.vdec.core.so:$(TARGET_COPY_OUT_VENDOR)/lib/libOMX.hisi.vdec.core.so \
+    vendor/linaro/hikey960/hisilicon/proprietary/lib64/libOMX.hisi.vdec.core.so:$(TARGET_COPY_OUT_VENDOR)/lib64/libOMX.hisi.vdec.core.so \
+    vendor/linaro/hikey960/hisilicon/proprietary/libOMX_Core.so:$(TARGET_COPY_OUT_VENDOR)/lib/libOMX_Core.so \
+    vendor/linaro/hikey960/hisilicon/proprietary/lib64/libOMX_Core.so:$(TARGET_COPY_OUT_VENDOR)/lib64/libOMX_Core.so \
+    vendor/linaro/hikey960/hisilicon/proprietary/libstagefrighthw.so:$(TARGET_COPY_OUT_VENDOR)/lib/libstagefrighthw.so \
+    vendor/linaro/hikey960/hisilicon/proprietary/lib64/libstagefrighthw.so:$(TARGET_COPY_OUT_VENDOR)/lib64/libstagefrighthw.so \
+    vendor/linaro/hikey960/hisilicon/proprietary/libc_secshared.so:$(TARGET_COPY_OUT_VENDOR)/lib/libc_secshared.so \
+    vendor/linaro/hikey960/hisilicon/proprietary/lib64/libc_secshared.so:$(TARGET_COPY_OUT_VENDOR)/lib64/libc_secshared.so \
+    vendor/linaro/hikey960/hisilicon/proprietary/lib64/libhilog.so:$(TARGET_COPY_OUT_VENDOR)/lib64/libhilog.so \
+    vendor/linaro/hikey960/hisilicon/proprietary/libhilog.so:$(TARGET_COPY_OUT_VENDOR)/lib/libhilog.so \
+    vendor/linaro/hikey960/hisilicon/proprietary/lib64/libhiion.so:$(TARGET_COPY_OUT_VENDOR)/lib64/libhiion.so \
+    vendor/linaro/hikey960/hisilicon/proprietary/libhiion.so:$(TARGET_COPY_OUT_VENDOR)/lib/libhiion.so
+
diff --git a/self-extractors_hikey960/root/device-vendor.mk b/self-extractors_hikey960/root/device-vendor.mk
index 0dd7123..31f5c3a 100644
--- a/self-extractors_hikey960/root/device-vendor.mk
+++ b/self-extractors_hikey960/root/device-vendor.mk
@@ -16,4 +16,4 @@
 
 LOCAL_STEM := device-partial.mk
 
-$(call inherit-product-if-exists, vendor/linaro/hikey960/arm/$(LOCAL_STEM))
+$(call inherit-product-if-exists, vendor/linaro/hikey960/hisilicon/$(LOCAL_STEM))
diff --git a/sepolicy/file_contexts b/sepolicy/file_contexts
index 85c43d2..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
@@ -21,4 +24,7 @@
 /data/vendor/sensor(/.*)?        u:object_r:sensor_vendor_data_file:s0
 
 /sys/devices/platform/ddr_devfreq/devfreq/ddr_devfreq/min_freq		u:object_r:sysfs_power:s0
-/sys/devices/platform/e82c0000.mali/devfreq/e82c0000.mali/min_freq	u:object_r:sysfs_power:s0
+/sys/devices/platform/e82c0000\.mali/devfreq/e82c0000\.mali/min_freq	u:object_r:sysfs_power:s0
+
+/dev/block/platform/soc/f723d000\.dwmmc0/by-name/cache u:object_r:cache_block_device:s0
+/dev/block/platform/soc/f723d000\.dwmmc0/by-name/userdata u:object_r:userdata_block_device:s0
diff --git a/sepolicy/healthd.te b/sepolicy/healthd.te
new file mode 100644
index 0000000..d4f839d
--- /dev/null
+++ b/sepolicy/healthd.te
@@ -0,0 +1 @@
+allow healthd self:capability2 wake_alarm;
diff --git a/sepolicy/netd.te b/sepolicy/netd.te
index 86fe108..54290ce 100644
--- a/sepolicy/netd.te
+++ b/sepolicy/netd.te
@@ -1,2 +1,3 @@
 # Triggers a sys_module denial, but kernel has CONFIG_MODULES=n.
 dontaudit netd self:capability sys_module;
+dontaudit netd kernel:system module_request;
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