Merge "[Bugfix][T106BUG-487]fix led state about calling"
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-qser-autosuspend-demo/files/lynq-qser-autosuspend-demo.cpp b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-qser-autosuspend-demo/files/lynq-qser-autosuspend-demo.cpp
index fbaa297..b0c2330 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-qser-autosuspend-demo/files/lynq-qser-autosuspend-demo.cpp
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-qser-autosuspend-demo/files/lynq-qser-autosuspend-demo.cpp
@@ -65,7 +65,7 @@
     {
         if(strlen(lock_status.lock_name[i]) != 0)
         {
-            printf("fd: %d lock_name:%s strlen:%d\n", i, lock_status.lock_name[i], strlen(lock_status.lock_name[i]));
+            printf("fd: %d lock_name:%s strlen:%d, pid=%d\n", i, lock_status.lock_name[i], strlen(lock_status.lock_name[i]), lock_status.lock_pid[i]);
         }
     }
 
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-qser-network-demo/files/lynq-qser-network-demo.cpp b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-qser-network-demo/files/lynq-qser-network-demo.cpp
index 3982cbc..ad38820 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-qser-network-demo/files/lynq-qser-network-demo.cpp
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-qser-network-demo/files/lynq-qser-network-demo.cpp
@@ -25,6 +25,10 @@
 int (*qser_nw_get_oos_config_p)(nw_client_handle_type   h_nw, QSER_NW_OOS_CONFIG_INFO_T *pt_info);

 int (*qser_nw_set_rf_mode_p) (nw_client_handle_type   h_nw,E_QSER_NW_RF_MODE_TYPE_T rf_mode);

 int (*qser_nw_get_rf_mode_p) (nw_client_handle_type   h_nw,E_QSER_NW_RF_MODE_TYPE_T* rf_mode);

+int (*qser_nw_set_ims_enable_p) (nw_client_handle_type h_nw,E_QSER_NW_IMS_MODE_TYPE_T ims_mode);

+int (*qser_nw_get_ims_reg_status_p) (nw_client_handle_type h_nw, QSER_NW_IMS_REG_STATUS_INFO_T *pt_info);

+

+

 

 int getFunc()

 {

@@ -48,10 +52,13 @@
     qser_nw_set_oos_config_p = (int (*)(nw_client_handle_type   h_nw, QSER_NW_OOS_CONFIG_INFO_T *pt_info))dlsym(handle_network,"qser_nw_set_oos_config");

     qser_nw_set_rf_mode_p = (int (*)(nw_client_handle_type   h_nw, E_QSER_NW_RF_MODE_TYPE_T rf_mode))dlsym(handle_network,"qser_nw_set_rf_mode");

     qser_nw_get_rf_mode_p = (int (*)(nw_client_handle_type   h_nw, E_QSER_NW_RF_MODE_TYPE_T* rf_mode))dlsym(handle_network,"qser_nw_get_rf_mode");

+    qser_nw_set_ims_enable_p = (int (*)(nw_client_handle_type  h_nw, E_QSER_NW_IMS_MODE_TYPE_T ims_mode))dlsym(handle_network,"qser_nw_set_ims_enable");

+    qser_nw_get_ims_reg_status_p = (int (*)(nw_client_handle_type  h_nw, QSER_NW_IMS_REG_STATUS_INFO_T  *pt_info))dlsym(handle_network,"qser_nw_get_ims_reg_status");

         

     if(qser_nw_client_deinit_p==NULL || qser_nw_client_init_p==NULL || qser_nw_set_config_p ==NULL ||

        qser_nw_get_operator_name_p == NULL || qser_nw_get_reg_status_p ==NULL || qser_nw_add_rx_msg_handler_p==NULL ||

-       qser_nw_set_rf_mode_p == NULL || qser_nw_get_rf_mode_p == NULL || qser_nw_get_oos_config_p == NULL || qser_nw_set_oos_config_p == NULL)

+       qser_nw_set_rf_mode_p == NULL || qser_nw_get_rf_mode_p == NULL || qser_nw_get_oos_config_p == NULL || qser_nw_set_oos_config_p == NULL || 

+       qser_nw_set_ims_enable_p == NULL || qser_nw_get_ims_reg_status_p == NULL)

     {

         printf("get func pointer null");

         exit(EXIT_FAILURE);

@@ -91,9 +98,9 @@
     {7,     "qser_nw_get_oos_config"},

     {8,     "qser_nw_set_rf_mode"},

     {9,     "qser_nw_get_rf_mode"},

-    {10,     "qser_nw_client_deinit"},  

- 

-    

+    {10,     "qser_nw_set_ims_enable"},

+    {11,     "qser_nw_get_ims_reg_status"},

+    {12,     "qser_nw_client_deinit"},      

     {-1,    "quit"}

 };

 

@@ -298,7 +305,13 @@
                             ind->hdr_sig_info.io);

                 }

                 break;

-            }        

+            }

+        case NW_IND_IMS_REG_EVENT_IND_FLAG:

+            {

+                printf("Recv event indication : IMS REG EVENT\n");               

+                

+                break;

+            }

         default:

             break;

     }

@@ -439,7 +452,7 @@
                              

                  break;

              }                 

-             case 10://"qser_nw_client_deinit"

+             case 12://"qser_nw_client_deinit"

              {

                  ret = qser_nw_client_deinit_p(h_nw);

                  printf("qser_nw_client_deinit ret = %d\n", ret);

@@ -576,6 +589,28 @@
                  printf("qser_nw_set_rf_mode %d ret = %dn",rf_mode, ret);

                  break;

              }       

+             case 10://"qser_nw_set_ims_enable"

+             {

+                 E_QSER_NW_IMS_MODE_TYPE_T  ims_mode;

+                 printf("please input you want set ims mode (0: off;  1: volte enable \n");

+                 scanf("%d", &ims_mode);

+                 ret = qser_nw_set_ims_enable_p(h_nw, ims_mode);

+                 printf("qser_nw_set_ims_enable %d ret = %dn",ims_mode, ret);

+                 break;

+             }       

+             case 11://"qser_nw_get_ims_reg_status"

+             {

+                 QSER_NW_IMS_REG_STATUS_INFO_T         t_info;

+                 memset(&t_info, 0, sizeof(QSER_NW_IMS_REG_STATUS_INFO_T));

+                 ret = qser_nw_get_ims_reg_status_p(h_nw, &t_info);

+                 printf("qser_nw_get_ims_reg_status ret = %d, detail info:\n", ret);

+                 if(ret == 0)

+                 {

+                     printf("ims_registration: registration_state=%d\n",                          

+                         t_info.registration_state);

+                 }                

+                 break;

+             }                 

              default:

              {

                  show_group_help(&t_nw_test);

diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-qser-network-demo/files/lynq_qser_network.h b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-qser-network-demo/files/lynq_qser_network.h
index bf7781a..56e2ce0 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-qser-network-demo/files/lynq_qser_network.h
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-qser-network-demo/files/lynq_qser_network.h
@@ -35,6 +35,12 @@
     E_QSER_NW_ROAM_STATE_TYPE_T   roaming_pref;       /**<   Roaming preference.*/
 }QSER_NW_CONFIG_INFO_T;
 
+typedef enum 
+{
+    E_QSER_NW_IMS_MODE_OFF    = 0,     /**<  close ims. */
+    E_QSER_NW_IMS_MODE_VOLTE_ENABLE    = 1,  /**<  support volte. */
+}E_QSER_NW_IMS_MODE_TYPE_T;
+
 /** Configures the OOS (out of service)  settings that define the MCM network interface. */
 #define QSER_NW_OOS_CFG_TYPE_FAST_SCAN          0x00    /**<  fast net scan */
 #define QSER_NW_OOS_CFG_TYPE_FULL_BAND_SCAN     0x01    /**<  full band scan */
@@ -65,12 +71,13 @@
   } u;
 }QSER_NW_OOS_CONFIG_INFO_T;
 
-
-
 //defined for QSER_NW_EventRegister
 #define     NW_IND_VOICE_REG_EVENT_IND_FLAG               (1 << 0)    /**< msg format : QSER_NW_VOICE_REG_EVENT_IND_T */
 #define     NW_IND_DATA_REG_EVENT_IND_FLAG                (1 << 1)    /**< msg format : QSER_NW_DATA_REG_EVENT_IND_T */ 
 #define     NW_IND_SIGNAL_STRENGTH_EVENT_IND_FLAG         (1 << 2)    /**< msg format : QSER_NW_SINGNAL_EVENT_IND_T */ 
+//#define     NW_IND_CELL_ACCESS_STATE_CHG_EVENT_IND_FLAG   (1 << 3)    /**< msg format : QL_MCM_NW_CELL_ACCESS_STATE_EVENT_IND_T */ 
+//#define     NW_IND_NITZ_TIME_UPDATE_EVENT_IND_FLAG        (1 << 4)    /**< msg format : QL_MCM_NW_NITZ_TIME_EVENT_IND_T */ 
+#define     NW_IND_IMS_REG_EVENT_IND_FLAG                 (1 << 5)    /**< msg format : NULL */ 
 
 typedef struct 
 {
@@ -209,6 +216,16 @@
     QSER_NW_3GPP2_REG_INFO_T      data_registration_details_3gpp2;        /**<   Data registration details for 3GPP2. */
 }QSER_NW_REG_STATUS_INFO_T;
 
+typedef enum 
+{
+    E_QSER_NW_IMS_SERVICE_NONE     = 0x0000,  /**<  Not registered */
+    E_QSER_NW_IMS_SERVICE_REGISTERED     = 0x0001,  /**<  Registered*/
+}E_QSER_NW_IMS_SERVICE_TYPE_T;
+
+typedef struct 
+{   
+    E_QSER_NW_IMS_SERVICE_TYPE_T      registration_state; /**<   Registration state.*/
+}QSER_NW_IMS_REG_STATUS_INFO_T;
 
 typedef struct 
 {
@@ -305,6 +322,7 @@
  *  NW_IND_SIGNAL_STRENGTH_EVENT_IND_FLAG : QSER_NW_SINGNAL_EVENT_IND_T
  *  NW_IND_CELL_ACCESS_STATE_CHG_EVENT_IND_FLAG : QSER_NW_CELL_ACCESS_STATE_EVENT_IND_T
  *  NW_IND_NITZ_TIME_UPDATE_EVENT_IND_FLAG : QSER_NW_NITZ_TIME_EVENT_IND_T 
+ *  NW_IND_IMS_REG_EVENT_IND_FLAG : NULL 
  * */
 typedef void (*QSER_NW_RxMsgHandlerFunc_t)(
     nw_client_handle_type h_nw, 
@@ -383,6 +401,12 @@
     QSER_NW_CONFIG_INFO_T     *pt_info 
 );
 
+int qser_nw_set_ims_enable
+(
+    nw_client_handle_type h_nw,
+    E_QSER_NW_IMS_MODE_TYPE_T ims_mode
+);
+
 int qser_nw_set_oos_config
 (
     nw_client_handle_type       h_nw,
@@ -413,6 +437,12 @@
     QSER_NW_REG_STATUS_INFO_T         *pt_info 
 );
 
+int qser_nw_get_ims_reg_status
+(
+    nw_client_handle_type h_nw,
+    QSER_NW_IMS_REG_STATUS_INFO_T *pt_info
+);
+
 int qser_nw_get_signal_strength
 (
     nw_client_handle_type               h_nw,
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-autosuspend/include/lynq-qser-autosuspend.h b/cap/zx297520v3/src/lynq/lib/liblynq-qser-autosuspend/include/lynq-qser-autosuspend.h
index 5d3966a..5d4b91d 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-autosuspend/include/lynq-qser-autosuspend.h
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-autosuspend/include/lynq-qser-autosuspend.h
@@ -53,6 +53,7 @@
 typedef struct
 {
     char lock_name[MAX_LOCK_NUM][64];
+    int lock_pid[MAX_LOCK_NUM];
 } LOCK_TABLE;
 
 int read_lock_table(void);
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-autosuspend/lynq-qser-autosuspend.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-qser-autosuspend/lynq-qser-autosuspend.cpp
index 01ccd5d..bb659ef 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-autosuspend/lynq-qser-autosuspend.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-autosuspend/lynq-qser-autosuspend.cpp
@@ -7,7 +7,6 @@
 #include <errno.h>
 #include <pthread.h>
 #include <unistd.h>
-#include <cutils/uevent.h>
 
 #include <lynq_autosuspend.h>
 #include "lynq-qser-autosuspend.h"
@@ -31,16 +30,7 @@
 
 #define UEVENT_MSG_LEN 128
 
-int device_fd;
 int g_init_flag = 0;
-struct dtr_uevent {
-    const char *action;
-    const char *path;
-    const char *subsystem;
-    const char *usbevent;
-};
-
-static void parse_event(const char *msg, struct dtr_uevent *dtr_uevent);
 
 
 qser_lpm_Handler_t g_lpm_handler = NULL;
@@ -154,11 +144,20 @@
     return 0;
 }
 
+int check_pid(int pid)
+{
+    char cmd1[64];
+    int ret = -1;
+    sprintf(cmd1, "ps -ef |awk '{print $1}'|grep \"^%d$\"", pid);
+    ret = system(cmd1);
+    return ret;
+}
 
 int check_lock(char *name)
 {
     int j;
     int num;
+    int ret=-1;
     for(j=0;j<MAX_LOCK_NUM;j++)
     {
         if(strcmp(lock_status.lock_name[j], name) == 0)
@@ -170,7 +169,18 @@
 
     if(j < MAX_LOCK_NUM)
     {
-        return num;
+        ret = check_pid(lock_status.lock_pid[j]);
+        if(!ret)
+        {
+            LYINFLOG("the pid is exist\n");
+            num = MAX_LOCK_NUM+1;
+            return num;
+        }
+        else
+        {
+            LYINFLOG("the pid is not exist\n");
+            return num;
+        }
     }
 
     return -1;
@@ -183,15 +193,15 @@
     int i = 0;
     int num;
     int check_flag;
-    
-    LYINFLOG("name:%s\n", name);
+    int pid;
+
     ret = read_lock_table();
     LYINFLOG("read_lock_table ret = %d\n", ret);
     if(ret <0)
     {
         return ret;
     }
-
+    pid = getpid();
     check_flag = check_lock(name);
 
     if(check_flag < 0)
@@ -201,7 +211,8 @@
             if(strlen(lock_status.lock_name[i]) == 0)
             {
                 strcpy(lock_status.lock_name[i], name);
-                LYINFLOG("lock_name[%d] %s\n", i, lock_status.lock_name[i]);
+                lock_status.lock_pid[i] = pid;
+                LYINFLOG("lock_name[%d] %s, lock_pid = %d\n", i, lock_status.lock_name[i], pid);
                 break;
             }
         }
@@ -214,10 +225,15 @@
             num = i;
         }
     }
-    else
+    else if(check_flag > MAX_LOCK_NUM)
     {
         return E_LOCK_EXIST;
     }
+    else
+    {
+        num = check_flag;
+        lock_status.lock_pid[num] = pid;
+    }
 
     LYINFLOG("num = %d\n", num);
     ret = save_lock_table();
@@ -234,79 +250,40 @@
     int i;
     ret = read_lock_table();
     memset(lock_status.lock_name[fd], 0, sizeof(lock_status.lock_name[fd]));
+    lock_status.lock_pid[fd] = -1;
     ret = save_lock_table();
     return ret;
 }
 
-static void parse_event(const char *msg, struct dtr_uevent *dtr_uevent)
-{
-    dtr_uevent->action = "";
-    dtr_uevent->path = "";
-    dtr_uevent->subsystem = "";
-    dtr_uevent->usbevent = "";
-
-    while (*msg) {
-        if (!strncmp(msg, "ACTION=", 7))
-        {
-            msg += 7;
-            dtr_uevent->action = msg;
-        }
-        else if (!strncmp(msg, "DEVPATH=", 8))
-        {
-            msg += 8;
-            dtr_uevent->path = msg;
-        }
-        else if (!strncmp(msg, "SUBSYSTEM=", 10))
-        {
-            msg += 10;
-            dtr_uevent->subsystem = msg;
-        }
-        else if (!strncmp(msg, "USBEVENT=", 9)) {
-            msg += 9;
-            dtr_uevent->usbevent = msg;
-        }
-
-        while(*msg++);
-    }
-
-    LYINFLOG("event { '%s', '%s', '%s', '%s'}\n",
-                    dtr_uevent->action, dtr_uevent->path, dtr_uevent->subsystem,dtr_uevent->usbevent);
-}
-
-
 
 void *check_dtr(void * arg)
 {
     qser_lpm_edge_t lpm_edge;
-    char msg[UEVENT_MSG_LEN+2];
-    struct dtr_uevent dtr_uevent;
-    int n;
-    int i;
- 
-    device_fd = uevent_open_socket(4*UEVENT_MSG_LEN, true);
-    if(device_fd < 0)
-    {
-        LYERRLOG("uevent_open_socket fail\n");
-        return -1;
-    }
+    char msg[16];
+    int fd=0;
+    int ret=0;
+
     while(1) 
     {
-        n = uevent_kernel_multicast_recv(device_fd, msg, UEVENT_MSG_LEN);
-        msg[n] = '\0';
-        msg[n+1] = '\0';
-        parse_event(msg, &dtr_uevent);
-        if((!strcmp(dtr_uevent.subsystem, "xp2xp")))
+        fd = open("/sys/xp2xp/xp2xp_notify/xp2xp_state", O_RDONLY);
+        ret=read(fd, &msg,15);
+        LYERRLOG("xp2xp_state ret = %d\n", ret);
+        close(fd);
+
+        if(ret == 5)
         {
-            if(!strcmp(dtr_uevent.action, "online"))
-            {
-                lpm_edge =E_QL_LPM_FALLING;
-            }
-            else
-            {
-                lpm_edge =E_QL_LPM_RISING;
-            }
-            g_lpm_handler(lpm_edge);
+            lpm_edge =E_QL_LPM_FALLING;
         }
+        else if(ret == 6)
+        {
+            lpm_edge =E_QL_LPM_RISING;
+        }
+        else
+        {
+            continue;
+        }
+        g_lpm_handler(lpm_edge);
+
     }
  
     return 0;
@@ -343,7 +320,6 @@
     }
     g_init_flag = 0;
     ret = pthread_cancel(thid);
-    close(device_fd);
     if(!ret)
     {
         LYERRLOG("pthread cancel success, lpm deinit success\n");
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-network/include/lynq_qser_network.h b/cap/zx297520v3/src/lynq/lib/liblynq-qser-network/include/lynq_qser_network.h
index 81aa0c2..dcfb9b7 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-network/include/lynq_qser_network.h
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-network/include/lynq_qser_network.h
@@ -35,6 +35,12 @@
     E_QSER_NW_ROAM_STATE_TYPE_T   roaming_pref;       /**<   Roaming preference.*/
 }QSER_NW_CONFIG_INFO_T;
 
+typedef enum 
+{
+    E_QSER_NW_IMS_MODE_OFF    = 0,     /**<  close ims. */
+    E_QSER_NW_IMS_MODE_VOLTE_ENABLE    = 1,  /**<  support volte. */
+}E_QSER_NW_IMS_MODE_TYPE_T;
+
 /** Configures the OOS (out of service)  settings that define the MCM network interface. */
 #define QSER_NW_OOS_CFG_TYPE_FAST_SCAN          0x00    /**<  fast net scan */
 #define QSER_NW_OOS_CFG_TYPE_FULL_BAND_SCAN     0x01    /**<  full band scan */
@@ -69,6 +75,9 @@
 #define     NW_IND_VOICE_REG_EVENT_IND_FLAG               (1 << 0)    /**< msg format : QSER_NW_VOICE_REG_EVENT_IND_T */
 #define     NW_IND_DATA_REG_EVENT_IND_FLAG                (1 << 1)    /**< msg format : QSER_NW_DATA_REG_EVENT_IND_T */ 
 #define     NW_IND_SIGNAL_STRENGTH_EVENT_IND_FLAG         (1 << 2)    /**< msg format : QSER_NW_SINGNAL_EVENT_IND_T */ 
+//#define     NW_IND_CELL_ACCESS_STATE_CHG_EVENT_IND_FLAG   (1 << 3)    /**< msg format : QL_MCM_NW_CELL_ACCESS_STATE_EVENT_IND_T */ 
+//#define     NW_IND_NITZ_TIME_UPDATE_EVENT_IND_FLAG        (1 << 4)    /**< msg format : QL_MCM_NW_NITZ_TIME_EVENT_IND_T */ 
+#define     NW_IND_IMS_REG_EVENT_IND_FLAG                 (1 << 5)    /**< msg format : NULL */ 
 
 typedef struct 
 {
@@ -207,6 +216,16 @@
     QSER_NW_3GPP2_REG_INFO_T      data_registration_details_3gpp2;        /**<   Data registration details for 3GPP2. */
 }QSER_NW_REG_STATUS_INFO_T;
 
+typedef enum 
+{
+    E_QSER_NW_IMS_SERVICE_NONE     = 0x0000,  /**<  Not registered */
+    E_QSER_NW_IMS_SERVICE_REGISTERED     = 0x0001,  /**<  Registered*/
+}E_QSER_NW_IMS_SERVICE_TYPE_T;
+
+typedef struct 
+{   
+    E_QSER_NW_IMS_SERVICE_TYPE_T      registration_state; /**<   Registration state.*/
+}QSER_NW_IMS_REG_STATUS_INFO_T;
 
 typedef struct 
 {
@@ -303,6 +322,7 @@
  *  NW_IND_SIGNAL_STRENGTH_EVENT_IND_FLAG : QSER_NW_SINGNAL_EVENT_IND_T
  *  NW_IND_CELL_ACCESS_STATE_CHG_EVENT_IND_FLAG : QSER_NW_CELL_ACCESS_STATE_EVENT_IND_T
  *  NW_IND_NITZ_TIME_UPDATE_EVENT_IND_FLAG : QSER_NW_NITZ_TIME_EVENT_IND_T 
+ *  NW_IND_IMS_REG_EVENT_IND_FLAG : NULL 
  * */
 typedef void (*QSER_NW_RxMsgHandlerFunc_t)(
     nw_client_handle_type h_nw, 
@@ -371,7 +391,6 @@
     E_QSER_NW_RF_MODE_FLIGHT = 4,    /**<  Flight Mode, CFUN 4. */
 }E_QSER_NW_RF_MODE_TYPE_T;
 
-
 int qser_nw_client_init(nw_client_handle_type  *ph_nw);
 
 int qser_nw_client_deinit(nw_client_handle_type  h_nw);
@@ -382,6 +401,12 @@
     QSER_NW_CONFIG_INFO_T     *pt_info 
 );
 
+int qser_nw_set_ims_enable
+(
+    nw_client_handle_type h_nw,
+    E_QSER_NW_IMS_MODE_TYPE_T ims_mode
+);
+
 int qser_nw_set_oos_config
 (
     nw_client_handle_type       h_nw,
@@ -412,6 +437,12 @@
     QSER_NW_REG_STATUS_INFO_T         *pt_info 
 );
 
+int qser_nw_get_ims_reg_status
+(
+    nw_client_handle_type h_nw,
+    QSER_NW_IMS_REG_STATUS_INFO_T *pt_info
+);
+
 int qser_nw_get_signal_strength
 (
     nw_client_handle_type               h_nw,
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-network/lynq_qser_network.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-qser-network/lynq_qser_network.cpp
index d75c23b..86f3ed6 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-network/lynq_qser_network.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-network/lynq_qser_network.cpp
@@ -116,6 +116,13 @@
     }  
 }
 
+void urc_msg_process_ims_reg()
+{
+    if(s_handlerPtr!=NULL)
+    {
+        s_handlerPtr(g_ph_hw,NW_IND_IMS_REG_EVENT_IND_FLAG,NULL,0,s_contextPtr);
+    }
+}
 
 void urc_msg_process_signal_strength()
 {
@@ -182,6 +189,11 @@
                 urc_msg_process_signal_strength();
                 break;
             }
+            case 1037://RIL_UNSOL_RESPONSE_IMS_NETWORK_STATE_CHANGED:
+            {   
+                urc_msg_process_ims_reg();
+                break;
+            }
         }        
     }
     return NULL;
@@ -226,6 +238,9 @@
         LYINFLOG("pthread join waiting urc thread ret = %d",ret);
         s_new_network_tid =-1;
     }
+	
+    s_handlerPtr=NULL;
+    s_contextPtr=NULL;
 
     ret=lynq_network_deinit();
     
@@ -271,6 +286,24 @@
     return RESULT_OK;
 }
 
+int qser_nw_set_ims_enable(nw_client_handle_type h_nw,E_QSER_NW_IMS_MODE_TYPE_T ims_mode)
+{ 
+    if(h_nw != g_ph_hw || h_nw == INVALID_CLIENT_HANDLE)
+    {
+        LYERRLOG("h_nw not right %d %d",h_nw,g_ph_hw);
+        return RESULT_ERROR;
+    }          
+    
+    int ret = lynq_set_ims(ims_mode);
+    if (ret != RESULT_OK)
+    {
+        LYERRLOG("lynq_set_ims failed ret is %d",ret);
+        return RESULT_ERROR;
+    }
+    return RESULT_OK;
+}
+
+
 int qser_nw_set_oos_config(    nw_client_handle_type       h_nw,QSER_NW_OOS_CONFIG_INFO_T     *pt_info
 )
 {
@@ -632,6 +665,43 @@
     return RESULT_OK;
 }
 
+int qser_nw_get_ims_reg_status(nw_client_handle_type h_nw, QSER_NW_IMS_REG_STATUS_INFO_T *pt_info)
+{
+    if(NULL == pt_info)
+    {
+        LYERRLOG("invalid client parameters incoming");
+        return RESULT_ERROR;
+    }
+
+    if(h_nw != g_ph_hw || h_nw == INVALID_CLIENT_HANDLE)
+    {
+        LYERRLOG("h_nw not right %d %d",h_nw,g_ph_hw);
+        return RESULT_ERROR;
+    }    
+    
+    int ret = 0;   
+    int regState = 0;
+    int imsRegState = 0;
+    char CID[128]={0};
+    char LAC[128]={0};
+    int netType = 0;
+    int radioTechFam = 0;
+    int netreject = 0;
+        
+
+    ret = lynq_query_registration_state("IMS",&regState,&imsRegState,LAC,CID,&netType,&radioTechFam,&netreject);
+    if(ret!=0)
+    {
+        LYERRLOG("get ims regstate fail ret is %d", ret);         
+    }
+    else {    
+        pt_info->registration_state = imsRegState;        
+    }    
+       
+    return ret;
+}
+
+
 int qser_nw_setlowpowermode(nw_client_handle_type h_nw,uint32_t low_power_mode_on)
 {
     if(h_nw == 0)
@@ -708,6 +778,7 @@
             LYDBGLOG("%s pthread_create error!!!",__func__);
             s_handlerPtr=NULL;
             s_contextPtr=NULL;
+            s_new_network_tid=-1;
             return RESULT_ERROR;
         }
     }
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/soc/sc/power_4line/hal_xp2xp.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/soc/sc/power_4line/hal_xp2xp.c
index 7d75efc..7d19f5c 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/soc/sc/power_4line/hal_xp2xp.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/soc/sc/power_4line/hal_xp2xp.c
@@ -50,14 +50,14 @@
 /****************************************************************************

 *											   Local Macros

 ****************************************************************************/

-#define AP2CP_WAKE_GPIO     50			/*AP»½ÐÑCPÖжÏÏß¶ÔÓ¦µÄGPIO*/

-#define AP2CP_SLEEP_GPIO    53			/*AP¸øCPµÄ˯Ãß»½ÐÑ״̬¶ÔÓ¦µÄGPIO*/

-#define CP2AP_WAKE_GPIO     131			/*CP»½ÐÑAPÖжÏÏß¶ÔÓ¦µÄGPIO*/

-#define CP2AP_SLEEP_GPIO    130			/*CP¸øAPµÄ˯Ãß»½ÐÑ״̬¶ÔÓ¦µÄGPIO*/

+#define AP2CP_WAKE_GPIO     50

+#define AP2CP_SLEEP_GPIO    53

+#define CP2AP_WAKE_GPIO     131

+#define CP2AP_SLEEP_GPIO    130

 

 

-#define AP_SLEEP_STATUS     0	/*AP˯Ãßʱ¸ÃÒý½ÅΪ0*/

-#define AP_WAKE_STATUS      1	/*AP»½ÐÑʱ¸ÃÒý½ÅΪ1*/

+#define AP_SLEEP_STATUS     0

+#define AP_WAKE_STATUS      1

 

 #define CP_SLEEP_STATUS     1	//jb.q add for dtr on 20231204

 #define CP_WAKE_STATUS      0	//jb.q add for dtr on 20231204

@@ -141,7 +141,8 @@
 /****************************************************************************

 *											  Global Variables

 ****************************************************************************/

-

+static wait_queue_head_t  wakeup_dtr_wqhead;//jb.qi add for dtr on 20240202

+static int wakeup_irq_occurs = 0;//jb.qi add for dtr on 20240202

 struct wakeup_source *xp2xp_wake_lock;

 static int xp2xp_init_flag = 0;

 static int irq_num = 0;

@@ -175,17 +176,17 @@
 

 ssize_t xp2xp_obj_show(struct kobject *kobject,struct attribute *attr,char *buf)

 {

-	

-	  if(!strcmp(attr->name, XP2XP_STATE)){

-	  		sprintf(buf, "curr_gpio_v:%d, currState:%s, sleep_cnt:%d, wake_cnt:%d, \n",g_xp2xp.curr_gpio_value,  (g_xp2xp.wake_state == 1 ? "work" : "sleep"),

-				g_xp2xp.sleep_cnt, g_xp2xp.wake_cnt

-				);

-			

-	  }	

+    /*jb.qi add for dtr on 20240202 start*/

+    wakeup_irq_occurs = 0;

+    wait_event_interruptible(wakeup_dtr_wqhead,wakeup_irq_occurs);

+    if(!strcmp(attr->name, XP2XP_STATE))

+    {

+      sprintf(buf, "%s\n",(g_xp2xp.wake_state == 1 ? "work" : "sleep"));

+    }

+    /*jb.qi add for dtr on 20240202 end*/

       return strlen(buf);

 }

 

-

 ssize_t xp2xp_obj_store(struct kobject *kobject,struct attribute *attr, const char *buf,size_t size)

 {

 	unsigned int value = 0;

@@ -402,8 +403,7 @@
 	unsigned int irq_type;

 	struct hal_xp2xp_dev *xp2xp_dev = (struct hal_xp2xp_dev *)priv;

 

-	disable_irq_nosync(irq);

-	xp2xp_dev->xp2xp_irq_state = 0;

+    disable_irq_nosync(irq);/*jb.qi add for dtr on 20240202*/

 	gpio_value = 0 ;

 

 	if(xp2xp_dev->xp2xp_ws){

@@ -431,12 +431,15 @@
         xp2xp_dev->wake_state = 1;

         pm_stay_awake(g_xp2xp.dev);

 	}

-

 	if (pinctrl_select_state(xp2xp_dev->pctrl_wk_int, xp2xp_dev->st_int) < 0) {

 		printk( "setting card detect irq failed\n");

 	}

 	irq_set_irq_type(irq,irq_type);

-	up(&xp2xp_dev->wk_sem);

+    /*jb.qi add for dtr on 20240202 start*/

+	wakeup_irq_occurs = 1;

+	wake_up_interruptible(&wakeup_dtr_wqhead);

+    enable_irq(xp2xp_dev->eint_irq);

+    /*jb.qi add for dtr on 20240202 end*/

 	return IRQ_HANDLED;

 }

 /*jb.qi add for dtr uevent on 20231218 end*/

@@ -628,8 +631,7 @@
   int ret = 0;

 

    printk("kset test init!\n");

-   

-   /* ´´½¨²¢×¢²á kset_p */

+

    kset_xp2xp = kset_create_and_add("xp2xp", &xp2xp_uevent_ops, NULL);    

    

    xp2xpkobj = kzalloc(sizeof(*xp2xpkobj),GFP_KERNEL);

@@ -718,7 +720,7 @@
 	spin_lock_init(&g_xp2xp.wk_lock);

 

 	device_init_wakeup(&pdev->dev, true);//jb.q add for dtr on 20231204

-

+	init_waitqueue_head(&wakeup_dtr_wqhead);/*jb.qi add for dtr on 20240202*/

 	g_xp2xp.xp2xp_ws = wakeup_source_register(NULL, "xp2xp");

 	if(g_xp2xp.xp2xp_ws  == NULL){

 		printk("adb_setup wakeup_source_create fail\n");

@@ -796,14 +798,14 @@
 		panic("hal_xp2xp_probe request_irq fail, %d", ret);

 	}

 

-

+	/*jb.qi add for dtr on 20240202 start

 	g_xp2xp.wake_int_thread = kthread_run(xp2xp_wkcp_thread, (void *)&g_xp2xp, "xp2xp_wake_thread");

 	

 	if (IS_ERR(g_xp2xp.wake_int_thread)) {

 		printk("Can't start up our thread");

 		return PTR_ERR(g_xp2xp.wake_int_thread);

 	}	

-

+	*/

 	enable_irq_wake(g_xp2xp.eint_irq);

 /*jb.q add for dtr on 20231204 start*/

 	/* gpio request */