hal: send DTS HPX license to ADSP after ssr

Send DTS HPX license to ADSP after SSR.

Change-Id: I60ac2a2ab3f575e671bcd0af133755b2089526dc
diff --git a/hal/audio_extn/audio_extn.h b/hal/audio_extn/audio_extn.h
index 98b2672..1f1058e 100644
--- a/hal/audio_extn/audio_extn.h
+++ b/hal/audio_extn/audio_extn.h
@@ -292,6 +292,7 @@
 #define audio_extn_dts_eagle_set_parameters(adev, parms)     (0)
 #define audio_extn_dts_eagle_get_parameters(adev, query, reply) (0)
 #define audio_extn_dts_eagle_fade(adev, fade_in, out) (0)
+#define audio_extn_dts_eagle_send_lic()               (0)
 #define audio_extn_dts_create_state_notifier_node(stream_out) (0)
 #define audio_extn_dts_notify_playback_state(stream_out, has_video, sample_rate, \
                                     channels, is_playing) (0)
@@ -303,6 +304,7 @@
 int audio_extn_dts_eagle_get_parameters(const struct audio_device *adev,
                   struct str_parms *query, struct str_parms *reply);
 int audio_extn_dts_eagle_fade(const struct audio_device *adev, bool fade_in, const struct stream_out *out);
+void audio_extn_dts_eagle_send_lic();
 void audio_extn_dts_create_state_notifier_node(int stream_out);
 void audio_extn_dts_notify_playback_state(int stream_out, int has_video, int sample_rate,
                                   int channels, int is_playing);
diff --git a/hal/audio_extn/dts_eagle.c b/hal/audio_extn/dts_eagle.c
index 52d7abb..71bfea6 100644
--- a/hal/audio_extn/dts_eagle.c
+++ b/hal/audio_extn/dts_eagle.c
@@ -190,6 +190,28 @@
     return 0;
 }
 
+void audio_extn_dts_eagle_send_lic() {
+    char prop[PROPERTY_VALUE_MAX] = {0};
+    bool enabled;
+    property_get("use.dts_eagle", prop, "0");
+    enabled = !strncmp("true", prop, sizeof("true")) || atoi(prop);
+    if (!enabled)
+        return;
+    int fd = open(DEVICE_NODE, O_RDWR);
+    int index = 1;
+    if (fd >= 0) {
+        if (ioctl(fd, DTS_EAGLE_IOCTL_SEND_LICENSE, &index) < 0) {
+            ALOGE("DTS_EAGLE_HAL: error sending license after adsp ssr");
+        } else {
+            ALOGD("DTS_EAGLE_HAL: sent license after adsp ssr");
+        }
+        close(fd);
+    } else {
+        ALOGE("DTS_EAGLE_HAL: error opening eagle");
+    }
+    return;
+}
+
 void audio_extn_dts_eagle_set_parameters(struct audio_device *adev, struct str_parms *parms) {
     int ret, val;
     char value[32] = { 0 }, prop[PROPERTY_VALUE_MAX];
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 3d157da..c500f9e 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -3132,6 +3132,8 @@
         } else if (strstr(snd_card_status, "ONLINE")) {
             ALOGD("Received sound card ONLINE status");
             set_snd_card_state(adev,SND_CARD_STATE_ONLINE);
+            //send dts hpx license if enabled
+            audio_extn_dts_eagle_send_lic();
         }
     }