hal: add support for dolby license validation

Add dolby audio_extn API's to set dolby license.
License needs to be set with dsp everytime it is loaded.

Change-Id: I21d58a21d65c823469d066f4ba5edc5b2660ea1e
diff --git a/hal/audio_extn/dolby.c b/hal/audio_extn/dolby.c
index 99fa2b7..cb74715 100644
--- a/hal/audio_extn/dolby.c
+++ b/hal/audio_extn/dolby.c
@@ -287,6 +287,15 @@
     int ddp_dev, dev_ch_cap;
     int val, ret;
     char value[32]={0};
+
+    ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_SND_CARD_STATUS, value,
+                            sizeof(value));
+    if (ret >= 0) {
+        char *snd_card_status = value + 2;
+        if (strncmp(snd_card_status, "ONLINE", sizeof("ONLINE")) == 0)
+            audio_extn_dolby_set_license(adev);
+    }
+
     ret = str_parms_get_str(parms, AUDIO_PARAMETER_DDP_DEV, value,
                             sizeof(value));
     if (ret >= 0) {
@@ -470,4 +479,29 @@
 
     return;
 }
+
+void audio_extn_dolby_set_license(struct audio_device *adev)
+{
+    int ret, key=0;
+    char value[128] = {0};
+    struct mixer_ctl *ctl;
+    const char *mixer_ctl_name = "DS1 License";
+
+    ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
+    if (!ctl) {
+        ALOGE("%s: Could not get ctl for mixer cmd - %s",
+              __func__, mixer_ctl_name);
+        return;
+    }
+
+    property_get("audio.ds1.metainfo.key",value,"0");
+    key = atoi(value);
+
+    ALOGV("%s Setting DS1 License, key:0x%x",__func__, key);
+    ret = mixer_ctl_set_value(ctl, 0, key);
+    if (ret)
+        ALOGE("%s: cannot set license, error:%d",__func__, ret);
+
+    return;
+}
 #endif /* DS1_DOLBY_DDP_ENABLED || DS1_DOLBY_DAP_ENABLED */