diff --git a/Android.mk b/Android.mk
index 877187d..d970428 100644
--- a/Android.mk
+++ b/Android.mk
@@ -71,6 +71,12 @@
 LOCAL_SRC_FILES += power-710.c
 endif
 
+ifeq ($(call is-board-platform-in-list,trinket), true)
+LOCAL_SHARED_LIBRARIES := liblog libcutils libdl libxml2
+LOCAL_SRC_FILES := power.c metadata-parser.c utils.c list.c hint-data.c powerhintparser.c
+LOCAL_SRC_FILES += power-6125.c
+endif
+
 ifeq ($(call is-board-platform-in-list,msmnile), true)
 LOCAL_SRC_FILES += power-msmnile.c
 endif
@@ -79,11 +85,22 @@
     LOCAL_CFLAGS += -DINTERACTION_BOOST
 endif
 
+ifeq ($(call is-board-platform-in-list,trinket), true)
+LOCAL_MODULE := power.qcom
+LOCAL_MODULE_TAGS := optional
+LOCAL_CFLAGS += -Wno-unused-parameter -Wno-unused-variable
+LOCAL_VENDOR_MODULE := true
+include $(BUILD_SHARED_LIBRARY)
+endif
+
+ifeq ($(call is-board-platform-in-list,trinket), false)
 LOCAL_MODULE := android.hardware.power@1.2-service
 LOCAL_INIT_RC := android.hardware.power@1.2-service.rc
 LOCAL_MODULE_TAGS := optional
 LOCAL_CFLAGS += -Wno-unused-parameter -Wno-unused-variable
 LOCAL_VENDOR_MODULE := true
 include $(BUILD_EXECUTABLE)
+endif
+
 
 endif
diff --git a/power-6125.c b/power-6125.c
new file mode 100644
index 0000000..6f627cb
--- /dev/null
+++ b/power-6125.c
@@ -0,0 +1,267 @@
+/*
+ * Copyright (c) 2019, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * *    * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ *       copyright notice, this list of conditions and the following
+ *       disclaimer in the documentation and/or other materials provided
+ *       with the distribution.
+ *     * Neither the name of The Linux Foundation nor the names of its
+ *       contributors may be used to endorse or promote products derived
+ *       from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#define LOG_NIDEBUG 0
+
+#include <errno.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <dlfcn.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include <unistd.h>
+
+#define LOG_TAG "QTI PowerHAL"
+#include <utils/Log.h>
+#include <hardware/hardware.h>
+#include <hardware/power.h>
+
+#include "utils.h"
+#include "metadata-defs.h"
+#include "hint-data.h"
+#include "performance.h"
+#include "power-common.h"
+
+#define MIN_VAL(X,Y) ((X>Y)?(Y):(X))
+
+static int video_encode_hint_sent;
+
+pthread_mutex_t camera_hint_mutex = PTHREAD_MUTEX_INITIALIZER;
+static int camera_hint_ref_count;
+static void process_video_encode_hint(void *metadata);
+static void process_video_encode_hfr_hint(void *metadata);
+
+int  power_hint_override(struct power_module *module, power_hint_t hint,
+        void *data)
+{
+    switch(hint) {
+        case POWER_HINT_VSYNC:
+        {
+            break;
+        }
+        case POWER_HINT_VIDEO_ENCODE:
+        {
+            process_video_encode_hint(data);
+            return HINT_HANDLED;
+        }
+        /* Using VIDEO_DECODE hint for HR use cases */
+        case POWER_HINT_VIDEO_DECODE:
+        {
+            process_video_encode_hfr_hint(data);
+            return HINT_HANDLED;
+        }
+    }
+    return HINT_NONE;
+}
+
+int  set_interactive_override(struct power_module *module, int on)
+{
+    return HINT_HANDLED; /* to set hints for display on and off. Not in use now */
+}
+
+/* Video Encode Hint */
+static void process_video_encode_hint(void *metadata)
+{
+    char governor[80] = {0};
+    int resource_values[32] = {0};
+    int num_resources = 0;
+    struct video_encode_metadata_t video_encode_metadata;
+
+    ALOGI("Got process_video_encode_hint");
+
+    if (get_scaling_governor_check_cores(governor,
+        sizeof(governor),CPU0) == -1) {
+            if (get_scaling_governor_check_cores(governor,
+                sizeof(governor),CPU1) == -1) {
+                    if (get_scaling_governor_check_cores(governor,
+                        sizeof(governor),CPU2) == -1) {
+                            if (get_scaling_governor_check_cores(governor,
+                                sizeof(governor),CPU3) == -1) {
+                                    ALOGE("Can't obtain scaling governor.");
+                                    // return HINT_HANDLED;
+                            }
+                    }
+            }
+    }
+
+    /* Initialize encode metadata struct fields. */
+    memset(&video_encode_metadata, 0, sizeof(struct video_encode_metadata_t));
+    video_encode_metadata.state = -1;
+    video_encode_metadata.hint_id = DEFAULT_VIDEO_ENCODE_HINT_ID;
+
+    if (metadata) {
+        if (parse_video_encode_metadata((char *)metadata,
+            &video_encode_metadata) == -1) {
+            ALOGE("Error occurred while parsing metadata.");
+            return;
+        }
+    } else {
+        return;
+    }
+
+    if (video_encode_metadata.state == 1) {
+        if((strncmp(governor, SCHEDUTIL_GOVERNOR,
+            strlen(SCHEDUTIL_GOVERNOR)) == 0) &&
+            (strlen(governor) == strlen(SCHEDUTIL_GOVERNOR))) {
+                /* sample_ms = 20mS
+                * hispeed load for both clusters = 95
+                * sched_load_boost on all cores = -15
+                * silver max freq = 1612 */
+                int res[] = {
+                             0x41820000, 0x14,
+                             0x41440100, 0x5f,
+                             0x41440000, 0x5f,
+                             0x40C68100, 0xFFFFFFF1,
+                             0x40C68110, 0xFFFFFFF1,
+                             0x40C68120, 0xFFFFFFF1,
+                             0x40C68130, 0xFFFFFFF1,
+                             0x40C68000, 0xFFFFFFF1,
+                             0x40C68010, 0xFFFFFFF1,
+                             0x40C68020, 0xFFFFFFF1,
+                             0x40C68030, 0xFFFFFFF1,
+                             0x40804100, 0x64C,
+                            };
+                memcpy(resource_values, res, MIN_VAL(sizeof(resource_values), sizeof(res)));
+                num_resources = sizeof(res)/sizeof(res[0]);
+                pthread_mutex_lock(&camera_hint_mutex);
+                camera_hint_ref_count++;
+                if (camera_hint_ref_count == 1) {
+                    if (!video_encode_hint_sent) {
+                        perform_hint_action(video_encode_metadata.hint_id,
+                        resource_values, num_resources);
+                        video_encode_hint_sent = 1;
+                    }
+                }
+                pthread_mutex_unlock(&camera_hint_mutex);
+        }
+    } if (video_encode_metadata.state == 0) {
+        if (((strncmp(governor, INTERACTIVE_GOVERNOR,
+            strlen(INTERACTIVE_GOVERNOR)) == 0) &&
+            (strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) ||
+            ((strncmp(governor, SCHEDUTIL_GOVERNOR,
+            strlen(SCHEDUTIL_GOVERNOR)) == 0) &&
+            (strlen(governor) == strlen(SCHEDUTIL_GOVERNOR)))) {
+            pthread_mutex_lock(&camera_hint_mutex);
+            camera_hint_ref_count--;
+            if (!camera_hint_ref_count) {
+                undo_hint_action(video_encode_metadata.hint_id);
+                video_encode_hint_sent = 0;
+            }
+            pthread_mutex_unlock(&camera_hint_mutex);
+            return ;
+        }
+    }
+    return;
+}
+
+/* Video Encode Hint for HFR use cases */
+static void process_video_encode_hfr_hint(void *metadata)
+{
+    char governor[80] = {0};
+    int resource_values[32] = {0};
+    int num_resources = 0;
+    struct video_encode_metadata_t video_encode_metadata;
+
+    ALOGI("Got process_video_encode_hint for HFR");
+
+    if (get_scaling_governor_check_cores(governor,
+        sizeof(governor),CPU0) == -1) {
+            if (get_scaling_governor_check_cores(governor,
+                sizeof(governor),CPU1) == -1) {
+                    if (get_scaling_governor_check_cores(governor,
+                        sizeof(governor),CPU2) == -1) {
+                            if (get_scaling_governor_check_cores(governor,
+                                sizeof(governor),CPU3) == -1) {
+                                    ALOGE("Can't obtain scaling governor.");
+                                    // return HINT_HANDLED;
+                            }
+                    }
+            }
+    }
+
+    /* Initialize encode metadata struct fields. */
+    memset(&video_encode_metadata, 0, sizeof(struct video_encode_metadata_t));
+    video_encode_metadata.state = -1;
+    video_encode_metadata.hint_id = DEFAULT_VIDEO_ENCODE_HINT_ID;
+
+    if (metadata) {
+        if (parse_video_encode_metadata((char *)metadata,
+            &video_encode_metadata) == -1) {
+            ALOGE("Error occurred while parsing metadata.");
+            return;
+        }
+    } else {
+        return;
+    }
+
+    if (video_encode_metadata.state == 1) {
+        if((strncmp(governor, SCHEDUTIL_GOVERNOR,
+            strlen(SCHEDUTIL_GOVERNOR)) == 0) &&
+            (strlen(governor) == strlen(SCHEDUTIL_GOVERNOR))) {
+                /* sample_ms = 20mS
+                * hispeed load = 95
+                * hispeed freq = 1017 */
+                int res[] = {0x41820000, 0x14,
+                             0x41440100, 0x5f,
+                             0x4143c100, 0x3f9,
+                            };
+                memcpy(resource_values, res, MIN_VAL(sizeof(resource_values), sizeof(res)));
+                num_resources = sizeof(res)/sizeof(res[0]);
+                pthread_mutex_lock(&camera_hint_mutex);
+                camera_hint_ref_count++;
+                if (camera_hint_ref_count == 1) {
+                    if (!video_encode_hint_sent) {
+                        perform_hint_action(video_encode_metadata.hint_id,
+                        resource_values, num_resources);
+                        video_encode_hint_sent = 1;
+                    }
+                }
+                pthread_mutex_unlock(&camera_hint_mutex);
+        }
+    } if (video_encode_metadata.state == 0) {
+        if (((strncmp(governor, INTERACTIVE_GOVERNOR,
+            strlen(INTERACTIVE_GOVERNOR)) == 0) &&
+            (strlen(governor) == strlen(INTERACTIVE_GOVERNOR))) ||
+            ((strncmp(governor, SCHEDUTIL_GOVERNOR,
+            strlen(SCHEDUTIL_GOVERNOR)) == 0) &&
+            (strlen(governor) == strlen(SCHEDUTIL_GOVERNOR)))) {
+            pthread_mutex_lock(&camera_hint_mutex);
+            camera_hint_ref_count--;
+            if (!camera_hint_ref_count) {
+                undo_hint_action(video_encode_metadata.hint_id);
+                video_encode_hint_sent = 0;
+            }
+            pthread_mutex_unlock(&camera_hint_mutex);
+            return ;
+        }
+    }
+    return;
+}
\ No newline at end of file
diff --git a/power-common-old.h b/power-common-old.h
new file mode 100644
index 0000000..e374e46
--- /dev/null
+++ b/power-common-old.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2013, 2018 The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * *    * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ *       copyright notice, this list of conditions and the following
+ *       disclaimer in the documentation and/or other materials provided
+ *       with the distribution.
+ *     * Neither the name of The Linux Foundation nor the names of its
+ *       contributors may be used to endorse or promote products derived
+ *       from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#define NODE_MAX (64)
+
+#define SCALING_GOVERNOR_PATH "/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor"
+#define DCVS_CPU0_SLACK_MAX_NODE "/sys/module/msm_dcvs/cores/cpu0/slack_time_max_us"
+#define DCVS_CPU0_SLACK_MIN_NODE "/sys/module/msm_dcvs/cores/cpu0/slack_time_min_us"
+#define MPDECISION_SLACK_MAX_NODE "/sys/module/msm_mpdecision/slack_time_max_us"
+#define MPDECISION_SLACK_MIN_NODE "/sys/module/msm_mpdecision/slack_time_min_us"
+#define SCALING_MIN_FREQ "/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq"
+#define ONDEMAND_GOVERNOR "ondemand"
+#define INTERACTIVE_GOVERNOR "interactive"
+#define MSMDCVS_GOVERNOR "msm-dcvs"
+#define SCHEDUTIL_GOVERNOR "schedutil"
+
+#define HINT_HANDLED (0)
+#define HINT_NONE (-1)
+
+enum CPU_GOV_CHECK {
+    CPU0 = 0,
+    CPU1 = 1,
+    CPU2 = 2,
+    CPU3 = 3
+};
diff --git a/power.c b/power.c
new file mode 100644
index 0000000..7a09d8b
--- /dev/null
+++ b/power.c
@@ -0,0 +1,197 @@
+/*
+ * Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * *    * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ *       copyright notice, this list of conditions and the following
+ *       disclaimer in the documentation and/or other materials provided
+ *       with the distribution.
+ *     * Neither the name of The Linux Foundation nor the names of its
+ *       contributors may be used to endorse or promote products derived
+ *       from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#define LOG_NIDEBUG 0
+
+#include <errno.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <dlfcn.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#define LOG_TAG "QTI PowerHAL"
+#include <utils/Log.h>
+#include <hardware/hardware.h>
+#include <hardware/power.h>
+
+#include "utils.h"
+#include "hint-data.h"
+#include "performance.h"
+#include "power-common-old.h"
+
+static struct hint_handles handles[NUM_HINTS];
+
+static int power_device_open(const hw_module_t* module, const char* name,
+        hw_device_t** device);
+
+static struct hw_module_methods_t power_module_methods = {
+    .open = power_device_open,
+};
+
+static void power_init(struct power_module *module)
+{
+    ALOGI("Initing");
+
+    for (int i=0; i<NUM_HINTS; i++) {
+        handles[i].handle       = 0;
+        handles[i].ref_count    = 0;
+    }
+}
+
+int __attribute__ ((weak)) power_hint_override(struct power_module *module, power_hint_t hint,
+        void *data)
+{
+    return HINT_NONE;
+}
+
+/* Declare function before use */
+void interaction(int duration, int num_args, int opt_list[]);
+
+static void power_hint(struct power_module *module, power_hint_t hint,
+        void *data)
+{
+    /* Check if this hint has been overridden. */
+    if (power_hint_override(module, hint, data) == HINT_HANDLED) {
+        /* The power_hint has been handled. We can skip the rest. */
+        return;
+    }
+    switch(hint) {
+        case POWER_HINT_VSYNC:
+        break;
+        case POWER_HINT_VR_MODE:
+            ALOGI("VR mode power hint not handled in power_hint_override");
+            break;
+        case POWER_HINT_INTERACTION:
+        {
+            int resources[] = {0x702, 0x20F, 0x30F};
+            int duration = 3000;
+
+            interaction(duration, sizeof(resources)/sizeof(resources[0]), resources);
+        }
+        break;
+        //fall through below, hints will fail if not defined in powerhint.xml
+        case POWER_HINT_SUSTAINED_PERFORMANCE:
+        case POWER_HINT_VIDEO_ENCODE:
+            if (data) {
+                if (handles[hint].ref_count == 0)
+                    handles[hint].handle = perf_hint_enable((AOSP_DELTA + hint), 0);
+
+                if (handles[hint].handle > 0)
+                    handles[hint].ref_count++;
+            }
+            else
+                if (handles[hint].handle > 0)
+                    if (--handles[hint].ref_count == 0) {
+                        release_request(handles[hint].handle);
+                        handles[hint].handle = 0;
+                    }
+                else
+                    ALOGE("Lock for hint: %X was not acquired, cannot be released", hint);
+        break;
+    }
+}
+
+int __attribute__ ((weak)) set_interactive_override(struct power_module *module, int on)
+{
+    return HINT_NONE;
+}
+
+void set_interactive(struct power_module *module, int on)
+{
+    if (!on) {
+        /* Send Display OFF hint to perf HAL */
+        perf_hint_enable(VENDOR_HINT_DISPLAY_OFF, 0);
+    } else {
+        /* Send Display ON hint to perf HAL */
+        perf_hint_enable(VENDOR_HINT_DISPLAY_ON, 0);
+    }
+
+    if (set_interactive_override(module, on) == HINT_HANDLED) {
+        return;
+    }
+
+    ALOGI("Got set_interactive hint");
+}
+
+static int power_device_open(const hw_module_t* module, const char* name,
+        hw_device_t** device)
+{
+    int status = -EINVAL;
+    if (module && name && device) {
+        if (!strcmp(name, POWER_HARDWARE_MODULE_ID)) {
+            power_module_t *dev = (power_module_t *)malloc(sizeof(*dev));
+
+            if(dev) {
+                memset(dev, 0, sizeof(*dev));
+
+                if(dev) {
+                    /* initialize the fields */
+                    dev->common.module_api_version = POWER_MODULE_API_VERSION_0_2;
+                    dev->common.tag = HARDWARE_DEVICE_TAG;
+                    dev->init = power_init;
+                    dev->powerHint = power_hint;
+                    dev->setInteractive = set_interactive;
+                    /* At the moment we support 0.2 APIs */
+                    dev->setFeature = NULL,
+                        dev->get_number_of_platform_modes = NULL,
+                        dev->get_platform_low_power_stats = NULL,
+                        dev->get_voter_list = NULL,
+                        *device = (hw_device_t*)dev;
+                    status = 0;
+                } else {
+                    status = -ENOMEM;
+                }
+            }
+            else {
+                status = -ENOMEM;
+            }
+        }
+    }
+
+    return status;
+}
+
+struct power_module HAL_MODULE_INFO_SYM = {
+    .common = {
+        .tag = HARDWARE_MODULE_TAG,
+        .module_api_version = POWER_MODULE_API_VERSION_0_2,
+        .hal_api_version = HARDWARE_HAL_API_VERSION,
+        .id = POWER_HARDWARE_MODULE_ID,
+        .name = "QTI Power HAL",
+        .author = "QTI",
+        .methods = &power_module_methods,
+    },
+
+    .init = power_init,
+    .powerHint = power_hint,
+    .setInteractive = set_interactive,
+};
