temp: add T108 temp api

Change-Id: Icef782cc595f090c4dd2a732c4fa34b1acac6cbc
diff --git a/mbtk/lynq_lib/src/lynq_thermal.c b/mbtk/lynq_lib/src/lynq_thermal.c
new file mode 100644
index 0000000..ed88a8b
--- /dev/null
+++ b/mbtk/lynq_lib/src/lynq_thermal.c
@@ -0,0 +1,114 @@
+#if 1
+#include "mbtk_type.h"
+#include "mbtk_log.h"
+#include "lynq_qser_thermal.h"
+#include "mbtk_info_api.h"
+
+/****************************DEFINE***************************************/
+#define QSER_RESULT_FAIL    -1
+#define QSER_RESULT_SUCCESS 0
+/****************************DEFINE***************************************/
+
+/****************************VARIABLE***************************************/
+extern mbtk_info_handle_t* qser_info_handle;
+extern int qser_info_handle_num;
+/****************************VARIABLE***************************************/
+
+
+/******************************FUNC*****************************************/
+static int qser_thermal_client_init(void)
+{
+    if(qser_info_handle == NULL)
+    {
+        qser_info_handle = mbtk_info_handle_get();
+        if(qser_info_handle)
+        {
+            qser_info_handle_num++;
+        } 
+        else
+        {
+            LOGE("[qser_thermal] mbtk_info_handle_get() fail.");
+            return QSER_RESULT_FAIL;
+        }
+    }
+    else
+    {
+        qser_info_handle_num++;
+    }
+
+    LOGE("[qser_thermal] mbtk_info_handle_get() success.");
+    return QSER_RESULT_SUCCESS;
+}
+
+static int qser_thermal_client_deinit(void)
+{
+    if(qser_info_handle)
+    {
+        LOGE("[qser_thermal] qser_info_handle_num = %d", qser_info_handle_num);
+        if(qser_info_handle_num == 1)
+        { // 最后一个引用,可释放。
+            int ret = mbtk_info_handle_free(&qser_info_handle);
+            if(ret)
+            {
+                LOGE("[qser_thermal] mbtk_info_handle_free() fail.");
+                return QSER_RESULT_FAIL;
+            }
+            else
+            {
+                qser_info_handle_num = 0;
+                qser_info_handle = NULL;
+            }
+        } 
+        else
+        {
+            qser_info_handle_num--;
+        }
+    }
+    else
+    {
+        LOGE("[qser_thermal] handle not inited.");
+        return QSER_RESULT_FAIL;
+    }
+
+    return QSER_RESULT_SUCCESS;
+}
+
+/******************************FUNC*****************************************/
+
+/****************************API***************************************/
+int get_thermal_zone(int *numbers, int size)
+{
+    if(numbers == NULL || size < 1)
+    {
+        LOGE("[qser_thermal]: numbers is NULL!");
+        return -1;
+    }
+    
+    int ret = 0;
+    int thermal = -1;
+    int thermal_num = 0;
+
+    ret = qser_thermal_client_init();
+    if(ret != QSER_RESULT_SUCCESS)
+    {
+        LOGE("[qser_thermal]qser_led_client_init fail.");
+        return QSER_RESULT_FAIL;
+    }
+    
+    ret = mbtk_temp_get(qser_info_handle, 1, &thermal);
+    if(ret != QSER_RESULT_SUCCESS)
+    {
+        LOGE("[qser_thermal]mbtk_temp_get fail.");
+        qser_thermal_client_deinit();
+        return QSER_RESULT_FAIL;
+    }
+
+    qser_thermal_client_deinit();
+    thermal_num = 1;
+    numbers[0] = thermal;
+
+    return thermal_num;
+}
+/****************************API***************************************/
+
+#endif