add_audio_ubus_dsp_set
Change-Id: I57b470d8033911e97995c94022838673bae92b9f
diff --git a/mbtk/libmbtk_audio/src/mbtk_audio_ubus.c b/mbtk/libmbtk_audio/src/mbtk_audio_ubus.c
index f676f02..8ccc14e 100755
--- a/mbtk/libmbtk_audio/src/mbtk_audio_ubus.c
+++ b/mbtk/libmbtk_audio/src/mbtk_audio_ubus.c
@@ -205,3 +205,54 @@
}
}
+/**
+ * @brief mbtk_audio_dsp_gain_set
+ *
+ * @details dsp gain set
+ *
+ * @param param
+ * type: 0:tx
+ * 0: tx
+ * 1: rx
+ * gain: -36~12 db
+
+ * @return return
+ */
+int mbtk_audio_dsp_gain_set(int type, int gain)
+{
+ int rc = 0;
+ struct ubus_request *req = NULL;
+
+ if(audio_ctx == NULL || ubus_id_audio_if == 0) {
+ LOGE("MBTK audio ubus not inited.");
+ return -1;
+ }
+
+ req = (struct ubus_request *)malloc(sizeof(struct ubus_request));
+ if (req == NULL)
+ {
+ LOGE("leave %s: lack of memory", __FUNCTION__);
+ return -1;
+ }
+ static struct blob_buf b;
+ memset(req, 0, sizeof(struct ubus_request));
+ blob_buf_init(&b, 0);
+ blobmsg_add_u32(&b, "type", type);
+ blobmsg_add_u32(&b, "gain", gain);
+ if ((rc = ubus_invoke_async(audio_ctx,
+ ubus_id_audio_if,
+ AUDIO_UBUS_DSP_SET,
+ b.head, req)) != UBUS_STATUS_OK) {
+ free(req);
+ LOGE("ubus_invoke_async %s failed %s", AUDIO_UBUS_DSP_SET, ubus_strerror(rc));
+ return -1;
+ }
+ else
+ {
+ LOGD("ubus_invoke_async %s success", AUDIO_UBUS_DSP_SET);
+ req->complete_cb = ubus_complete_cb;
+ ubus_complete_request_async(audio_ctx, req);
+ return 0;
+ }
+}
+