ai_datasaving.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /*****************************************************************************
  2. ** ai_datasaving.h: AL Layer Storage Internal Interface
  3. **
  4. ** Description: This file is only used by AL modules and the application
  5. ** can't access it directly
  6. **
  7. ** Copyright(c) 2011 Sunmedia Technologies - All Rights Reserved
  8. **
  9. ** Author : anlzhao
  10. **
  11. ** $Id: ai_datasaving.h 1901 2011-01-22 05:47:03Z liang.wu_c1 $
  12. *****************************************************************************/
  13. #ifndef AI_DATASAVING_H_INCLUDED
  14. #define AI_DATASAVING_H_INCLUDED
  15. #include "al_basictypes.h"
  16. /* NVM Message Queue Size , NVMSTORE_URGENT_Q_SIZE should be set 0 coz this Data saving task
  17. * is not supposed to deal with urgent msg by the current timing-oriented mechanism.
  18. */
  19. #define NVMSTORE_NORMAL_Q_SIZE (8)
  20. #define NVMSTORE_URGENT_Q_SIZE (0)
  21. #define SLEEP_FOR_PE_FINISH_TIME 200
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /* Storage command type */
  26. typedef enum NvmStore_Msg_e
  27. {
  28. #ifdef CONFIG_DTV_SUPPORT
  29. AI_NVMSTORE_CMD_DTV_STORE_ALL = 1, /* Store DTV Database */
  30. AI_NVMSTORE_CMD_DTV_RST_ALL, /* Reset DTV Database */
  31. AI_NVMSTORE_CMD_DTV_EMPTY_ALL, /* Empty DTV Database */
  32. AI_NVMSTORE_CMD_DTV_STORE_SINGLE, /* Store DTV -T/C/S Database */
  33. AI_NVMSTORE_CMD_DTV_RST_SINGLE, /* Reset DTV -T/C/S Database */
  34. AI_NVMSTORE_CMD_DTV_EMPTY_SINGLE, /* Empty DTV -T/C/S Database */
  35. #endif
  36. #ifdef CONFIG_ATV_SUPPORT
  37. AI_NVMSTORE_CMD_ATV_STORE, /* Store ATV Database */
  38. AI_NVMSTORE_CMD_ATV_RST, /* Reset ATV Database */
  39. AI_NVMSTORE_CMD_ATV_EMPTY, /* Empty ATV Database */
  40. #endif
  41. #if defined(CONFIG_DTV_SUPPORT) || defined(CONFIG_ATV_SUPPORT)
  42. AI_NVMSTORE_CMD_ATV_DTV_RST, /* Reset DTV & ATV */
  43. #endif
  44. AI_NVMSTORE_CMD_TERM,
  45. AI_NVMSTORE_BUSY_WAIT = 0x4000,
  46. } AI_NvmStore_CMD_e;
  47. /*Data saving message type*/
  48. typedef enum
  49. {
  50. #if defined(CONFIG_DTV_SUPPORT) || defined(CONFIG_ATV_SUPPORT)
  51. AI_DATASAVING_MSG_ATVDB_STORE_START,
  52. AI_DATASAVING_MSG_ATVDB_STORE_END,
  53. AI_DATASAVING_MSG_DVBDB_STORE_START,
  54. AI_DATASAVING_MSG_DVBDB_STORE_END,
  55. #endif
  56. AI_DATASAVING_MSG_USERSETING_STORE_START,
  57. AI_DATASAVING_MSG_USERSETING_STORE_END,
  58. } AI_DataSaving_Msg_Type_t;
  59. /* message structure and command sending to nvm storing thread */
  60. typedef struct _APP_NvmStoreCMD_t
  61. {
  62. al_uint32 dEventType; /* AI_NvmStore_CMD_e */
  63. al_uint32 eventData; /* For system setting, it is refer to ID */
  64. al_uint32 req_tick; /* ticks when requiring */
  65. } AI_NvmStore_CMD_t;
  66. typedef al_int32 (*ALDataSavingCallback)(AI_DataSaving_Msg_Type_t MessageType, al_void* pParam);
  67. /*****************************************************************************
  68. ** FUNCTION : AI_SETTING_Request
  69. **
  70. ** DESCRIPTION :
  71. ** This method sends a request for storage.
  72. **
  73. ** PARAMETERS :
  74. ** storetype - Storage type
  75. ** data - message data
  76. ** req_id - the id of request
  77. **
  78. ** RETURN VALUES:
  79. ** AL_SUCCESS
  80. *****************************************************************************/
  81. AL_Return_t AI_DataSaving_Request(al_uint32 storetype, al_uint32 data, al_uint32 *req_id);
  82. /***************************************************************************
  83. ** FUNCTION : AI_SETTING_Init
  84. **
  85. ** DESCRIPTION :
  86. ** initialize the data saving thread.
  87. ** PARAMETERS :
  88. ** func
  89. ** RETURN VALUES :
  90. ** AL_SUCCESS
  91. ** AL_FAILURE
  92. ***************************************************************************/
  93. AL_Return_t AI_DataSaving_Init(ALDataSavingCallback fpFunc);
  94. /*****************************************************************************
  95. ** FUNCTION : AI_DataSaving_AnyStoreInProgress
  96. **
  97. ** DESCRIPTION :
  98. ** This function is used to check if any nvm store request
  99. ** or process in progress.
  100. ** Notice: This function is not thread safe and it may be
  101. ** modified later.
  102. **
  103. ** PARAMETERS :
  104. ** None
  105. **
  106. ** RETURN VALUES:
  107. ** al_true is storing is in process
  108. ** al_false if storing is not in process
  109. *****************************************************************************/
  110. al_bool AI_DataSaving_AnyStoreInProgress(al_void);
  111. /*****************************************************************************
  112. ** FUNCTION : AI_DataSaving_IsFinished
  113. **
  114. ** DESCRIPTION :
  115. ** This function is to check whether saving request is handled by Datasaving
  116. ** module.
  117. **
  118. ** PARAMETERS :
  119. ** req_id - the id of the request
  120. **
  121. ** RETURN VALUES:
  122. ** al_true is storing is in process
  123. ** al_false if storing is not in process
  124. *****************************************************************************/
  125. al_bool AI_DataSaving_IsFinished(al_uint32 req_id);
  126. /*****************************************************************************
  127. ** FUNCTION : AI_DataSaving_Term
  128. **
  129. ** DESCRIPTION :
  130. ** This function is used to terminate datasaving task.
  131. ** Notice: This function will not return until task is terminated.
  132. **
  133. ** PARAMETERS :
  134. ** None
  135. **
  136. ** RETURN VALUES:
  137. ** al_true is storing is in process
  138. ** al_false if storing is not in process
  139. *****************************************************************************/
  140. AL_Return_t AI_DataSaving_Term(al_bool IsSync);
  141. #ifdef __cplusplus
  142. }
  143. #endif
  144. #endif /* AI_DATASAVING_H_INCLUDED */
  145. /*****************************************************************************
  146. ** $Rev: 1901 $
  147. **
  148. *****************************************************************************/