Merge "[Feature][T8TSK-183][VERSION]Update software version LYNQ_SW_VERSION:T800MLD_DB2_v02.MP1_MR3.01b21.06.02 to T800MLD_DB2_v02.MP1_MR3.01b21.07.00" into MR3.0-Merge-v2.0-ZK
diff --git a/LYNQ_PUBLIC/IC_src/mtk/lib/liblynq-codec/include/lynq_codec.h b/LYNQ_PUBLIC/IC_src/mtk/lib/liblynq-codec/include/lynq_codec.h
index 2e3cf37..8316c93 100755
--- a/LYNQ_PUBLIC/IC_src/mtk/lib/liblynq-codec/include/lynq_codec.h
+++ b/LYNQ_PUBLIC/IC_src/mtk/lib/liblynq-codec/include/lynq_codec.h
@@ -21,6 +21,8 @@
 int get_customer_tone_sample_rate();
 int customer_set_pa_volume(const int volume);
 int customer_get_pa_volume(int* volume);
+int set_codec_mic_volume(const int volume);
+int get_codec_mic_volume(int* volume);
 
 #ifdef __cplusplus
 }
diff --git a/LYNQ_PUBLIC/IC_src/mtk/lib/liblynq-codec/liblynq-codec/lynq_codec.c b/LYNQ_PUBLIC/IC_src/mtk/lib/liblynq-codec/liblynq-codec/lynq_codec.c
index e474b27..af7ffa5 100755
--- a/LYNQ_PUBLIC/IC_src/mtk/lib/liblynq-codec/liblynq-codec/lynq_codec.c
+++ b/LYNQ_PUBLIC/IC_src/mtk/lib/liblynq-codec/liblynq-codec/lynq_codec.c
@@ -111,6 +111,16 @@
     fclose(fp);

 }

 

+#ifdef ZK_CODEC_CFG

+static int s_codec_mic_volume=1;

+

+static char s_codec_cmd_buf[16];

+

+void get_set_codec_cmd(int reg_num, int value)

+{   

+    snprintf(s_codec_cmd_buf, sizeof(s_codec_cmd_buf), "0x%02x 0x%02x", reg_num, value);  

+}

+

 void set_zk_3104_codec(int open)

 {

     RLOGD("set_codec %d",open);

@@ -154,8 +164,10 @@
         write_codec_reg("0x0b 0x32");

         write_codec_reg("0x0c 0x00");

         write_codec_reg("0x0d 0x00");

-        write_codec_reg("0x0f 0x10");

-        write_codec_reg("0x10 0x20");

+        get_set_codec_cmd(15,s_codec_mic_volume);

+        write_codec_reg(s_codec_cmd_buf);        

+        get_set_codec_cmd(16,s_codec_mic_volume);

+        write_codec_reg(s_codec_cmd_buf);        

         write_codec_reg("0x11 0xf8");

         write_codec_reg("0x12 0xff");

         /*dongyu@2023.7.12 ZK ADC/DAC 0x13 power supply default off state, turn on during call, turn off after hang up*/

@@ -254,6 +266,7 @@
         write_codec_reg("0x6d 0x00");

     }

 }

+#endif

 

 /*hqing add for Geely demand on 11/07/2022, after playing audio, codec should sleep*/

 static void set_gsw_3104_codec(codec_op open)

@@ -515,6 +528,19 @@
 

 }

 

+int set_codec_mic_volume(const int volume)

+{

+    s_codec_mic_volume = volume;

+    return 0;

+}

+

+int get_codec_mic_volume(int* volume)

+{

+    (*volume)=s_codec_mic_volume;

+    return 0;

+}

+

+

 #elif defined(GSW_CODEC_CFG)

 

 void set_codec(media_src_t src, codec_op open_close)

@@ -545,6 +571,19 @@
     return -1;

 }

 

+int set_codec_mic_volume(const int volume)

+{

+    RLOGE("not implement\n");

+    return 1;

+}

+

+int get_codec_mic_volume(int* volume)

+{

+    RLOGE("not implement\n");

+    return 1;

+}

+

+

 #else

 const char * get_customer_tone_path()

 {

@@ -573,4 +612,16 @@
     RLOGE("not implement\n");

 }

 

+int set_codec_mic_volume(const int volume)

+{

+    RLOGE("not implement\n");

+    return 1;

+}

+

+int get_codec_mic_volume(int* volume)

+{

+    RLOGE("not implement\n");

+    return 1;

+}

+

 #endif

diff --git a/LYNQ_PUBLIC/common_src/lib/liblynq-media/liblynq-media/media_control.c b/LYNQ_PUBLIC/common_src/lib/liblynq-media/liblynq-media/media_control.c
index 92a8db3..45c4fc1 100755
--- a/LYNQ_PUBLIC/common_src/lib/liblynq-media/liblynq-media/media_control.c
+++ b/LYNQ_PUBLIC/common_src/lib/liblynq-media/liblynq-media/media_control.c
@@ -150,8 +150,14 @@
     } 

     return real_volume;

 }

- int lynq_set_mic_volume(const int volume) {

-    int real_volume;

+

+int lynq_set_mic_volume(const int volume) {

+    if(set_codec_mic_volume(volume)==0)

+    {

+        return 0;

+    }

+ 

+    int real_volume;    

     if((volume>MIC_VOLUME_LEVEL7)||(volume<MIC_VOLUME_LEVEL1))

     return 1;

     lynq_set_mic_volume_to_nvram(volume);

@@ -165,6 +171,11 @@
     {

         return 1;

     }

+

+    if(get_codec_mic_volume(volume)==0)

+    {

+        return 0;

+    }

    

     (*volume) = lynq_get_mic_current_volume();

     return 0;

diff --git a/meta-sdk/meta/meta-lynqSDK-T800/recipes-customer/data-demo/files/data-demo.cpp b/meta-sdk/meta/meta-lynqSDK-T800/recipes-customer/data-demo/files/data-demo.cpp
index e080e31..d32e1ab 100755
--- a/meta-sdk/meta/meta-lynqSDK-T800/recipes-customer/data-demo/files/data-demo.cpp
+++ b/meta-sdk/meta/meta-lynqSDK-T800/recipes-customer/data-demo/files/data-demo.cpp
@@ -65,6 +65,7 @@
 int (*lynq_setup_data_call_sp)(int *,char *apn,char *apnType,char *user,char *password,char *authType,char *normalProtocol,char *roamingProtocol);

 int (*lynq_get_data_call_list)(int *,lynq_data_call_response_v11_t *dataCallList);

 int (*lynq_wait_data_call_state_change)(int *);

+int (*lynq_modify_apn_db)(const int cmd,char *id,char *mcc,char *mnc,char *apn,char *apntype,char *user,char *password,char *normalprotocol,char *roamingprotocol,char *carrier,char *out);

 

 

 void *triggerUrcEvent(void *parg)

@@ -113,6 +114,88 @@
     return NULL;

 }

 

+/**

+ * @brief 修改 APN 记录

+ *

+ * 根据给定的参数,在数据库中修改 APN 记录。

+ *

+ * @param id 记录 ID

+ * @param mcc 移动国家码

+ * @param mnc 移动网络码

+ * @param apn 接入点名称

+ * @param apntype APN 类型

+ * @param user 用户名

+ * @param password 密码

+ * @param normalprotocol 本地协议

+ * @param roamingprotocol 漫游协议

+ * @param carrier 运营商

+ *

+ * @return 修改结果,0 表示成功,非 0 表示失败

+ */

+int modify_apn(char *id,char *mcc,char *mnc,char *apn,char *apntype,char *user,char *password,char *normalprotocol,char *roamingprotocol,char *carrier)

+{

+    char out[512] = {0};

+    int ret = 0;

+

+    //check record

+    ret = lynq_modify_apn_db(2,id,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,out);

+    if(ret == 0)

+    {

+        printf("out = %s\n",out);

+        if(strstr(out,"No record found!") == NULL)

+        {

+            printf("check whether record correct\n");

+            ret = lynq_modify_apn_db(2,id,mcc,mnc,apn,apntype,user,password,normalprotocol,roamingprotocol,carrier,out);

+            if(ret == 0)

+            {

+                printf("out = %s\n",out);

+                if(strstr(out,"No record found!") != NULL)

+                {

+                    printf("has record but not correct,need to modify record\n");

+                    ret = lynq_modify_apn_db(3,id,mcc,mnc,apn,apntype,user,password,normalprotocol,roamingprotocol,carrier,out);

+                    if(ret == 0)

+                    {

+                        printf("update success,out = %s\n",out);

+                        return 0;

+                    }

+                    else

+                    {

+                        printf("lynq_modify_apn_db modify failed,ret = %d\n",ret);

+                        return ret;

+                    }

+                }

+                else

+                {

+                    printf("correct record,don't need insert or update, just return\n");

+                    return 0;

+                }

+             }

+            

+        }

+        else

+        {

+            printf("no any record,insert record\n");

+            ret = lynq_modify_apn_db(0,id,mcc,mnc,apn,apntype,user,password,normalprotocol,roamingprotocol,carrier,out);

+            if(ret == 0)

+            {

+                printf("insert success,out = %s\n",out);

+                return 0;

+            }

+            else

+            {

+                printf("lynq_modify_apn_db insert failed,ret = %d\n",ret);

+                return ret;

+            }

+        }

+    }

+    else

+    {

+        printf("lynq_modify_apn_db query failed,ret = %d\n",ret);

+        return ret;

+    }

+

+}

+

 //此demo 示例建立两路APN,以中国移动SIM卡为例。默认每一个API 执行都成功,依次往下执行。

 int main(int argc, char *argv[])

 {

@@ -159,6 +242,13 @@
         printf("lynq_init_data not defined or exported in %s\r\n", lynq_libpath_data);

         exit(EXIT_FAILURE);

     }

+

+    lynq_modify_apn_db = (int(*)(const int cmd, char *id, char *mcc, char *mnc, char *apn, char *apntype, char *user, char *password, char *normalprotocol, char *roamingprotocol, char *carrier, char *out))dlsym(dlHandle_data,"lynq_modify_apn_db");

+    if (lynq_modify_apn_db == NULL)

+    {

+        printf("lynq_modify_apn_db not defined or exported in %s\r\n", lynq_libpath_data);

+        exit(EXIT_FAILURE);

+    }

     

     ret = lynq_init_data(2022);//初始化数据业务。

 

@@ -172,6 +262,20 @@
         printf("init data call fail!!!\n");

         return -1;

     }

+

+    //插入预设的apn记录

+    ret = modify_apn("-1","460","00","cmwap","wap",NULL,NULL,"IPV4V6","IPV4V6","China Mobile");

+    if(ret == 0)

+    {

+        printf("modify apn success");

+    }else{

+        printf("modify apn fail,ret = %d\n",ret);

+        //do something 

+        //进行插入失败的处理,如重试等。

+    }

+    sleep(1);//等待插入完成。

+

+

     ret = pthread_create(&tid,&attr,triggerUrcEvent,NULL);//创建一个线程用来处理data call改变事件。

 

     sleep(1);//等待线程tid 开始执行。