cecd.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. #ifndef __CECD_H_
  2. #define __CECD_H_
  3. #include <pthread.h>
  4. #include <stdbool.h>
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <signal.h>
  8. #include <fcntl.h>
  9. #include <sys/mman.h>
  10. #include <errno.h>
  11. //#include <sis516/sishdmi_interface.h>
  12. #include <drv_cec_external.h>
  13. #include <drv_debug.h>
  14. //#include <sisdebug.h> unused
  15. #include "msgqueue.h"
  16. #include "cecddbg.h"
  17. #include "cecd_interface.h"
  18. BOOL get_bDebugLog();
  19. #define bCECDDBG get_bDebugLog()
  20. extern unsigned int sisdbgconf1;
  21. #ifndef CONFIG_SUPPORT_DEBUG_MESSAGE
  22. //#if 0
  23. #define CECDDBG(fmt,args...)
  24. #else
  25. #define CECDDBG(fmt,args...) do {if (sisdbgconf1 & DBGCFG_CEC) printf(("[CECD] " fmt), ## args);}while(0)
  26. #endif
  27. #define CECTV_DEV_FILE "/dev/cectv"
  28. typedef void (*CB_UMFHANDLER)(CECD_MSG *cecdMsg);
  29. inline static void cecd_msleep(INT32 msec)
  30. {
  31. usleep(msec * 1000);
  32. }
  33. typedef enum
  34. {
  35. YESSIR = 0, // OK, I did it.
  36. NOSIR, // NO, I cant do it (do nothing).
  37. SORRYSIR = -1 // SORRY, I did it but fail.
  38. } cec_result_t;
  39. typedef struct _CECDTV_t
  40. {
  41. UINT8 device_to_power_up;
  42. UINT8 PowerStatus;
  43. UINT8 ActiveSource;
  44. UINT8 MenuLanguageStr[3];
  45. UINT8 DeckStatus;
  46. UINT8 DeviceMenuStatus;
  47. UINT8 TvSource;
  48. UINT8 ViewOnStatus;
  49. pthread_mutex_t list_mutex;
  50. PDEVICEMAP_LIST deviceList;
  51. } CECDTV_t, *PCECDTV_t;
  52. typedef struct _CECDDev_t
  53. {
  54. volatile BOOL bRunning;
  55. BOOL bQuery;
  56. BOOL bDebugLog;
  57. INT32 CECdev;
  58. pCEC_MSG_t pcec_msg;
  59. pFRAME_t prMsg; // Point to the current frame in psiscec_msg.
  60. pthread_mutex_t tx_mutex;
  61. CECDTV_t cecTV;
  62. INT32 CECDmsgId;
  63. INT32 UMFmsgId;
  64. INT32 shmId;
  65. INT32 OSDStringshmId;
  66. BOOL bDeviceListCheck;
  67. pthread_mutex_t dl_mutex;
  68. pthread_cond_t dl_cond;
  69. } CECDDev_t, *PCECDDev_t;
  70. typedef enum
  71. {
  72. Feature_Abort = 0x00,
  73. Image_View_On = 0x04,
  74. Tuner_Step_Increment = 0x05,
  75. Tuner_Step_Decrement = 0x06,
  76. Tuner_Device_Status = 0x07,
  77. Give_Tuner_Device_Status = 0x08,
  78. Record_On = 0x09,
  79. Record_Status = 0x0a,
  80. Text_View_On = 0x0D,
  81. Record_TV_Screen = 0x0f,
  82. Give_Deck_Status = 0x1A,
  83. Deck_Status = 0x1B,
  84. Set_Menu_Language = 0x32,
  85. Standby = 0x36,
  86. Play = 0x41,
  87. Deck_Control = 0x42,
  88. User_Control_Pressed = 0x44,
  89. User_Control_Released = 0x45,
  90. Give_OSD_Name = 0x46,
  91. Set_OSD_Name = 0x47,
  92. Set_OSD_String = 0x64,
  93. System_Audio_Mode_Request = 0x70,
  94. Give_Audio_Status = 0x71,
  95. Set_System_Audio_Mode = 0x72,
  96. Report_Audio_Status = 0x7A,
  97. Give_System_Audio_Mode = 0x7D,
  98. System_Audio_Mode_Status = 0x7E,
  99. Routing_Change = 0x80,
  100. Routing_Information = 0x81,
  101. Active_Source = 0x82,
  102. Give_Physical_Address = 0x83,
  103. Report_Physical_Address = 0x84,
  104. Request_Active_Source = 0x85,
  105. Set_Stream_Path = 0x86,
  106. Device_Vendor_ID = 0x87,
  107. Vendor_Command = 0x89,
  108. Vendor_Remote_Button_Down = 0x8A,
  109. Vendor_Remote_Button_Up = 0x8B,
  110. Give_Device_Vendor_ID = 0x8C,
  111. Menu_Request = 0x8D,
  112. Menu_Statu = 0x8E,
  113. Give_Device_Power_Status = 0x8F,
  114. Report_Power_Status = 0x90,
  115. Get_Menu_Language = 0x91,
  116. Select_Digital_Serveice = 0x93,
  117. Inactive_Source = 0x9D,
  118. CEC_Version = 0x9E,
  119. Get_CEC_Version = 0x9F,
  120. Request_Short_Audio_Descriptor = 0xA4,
  121. Give_Features = 0xA5,
  122. Report_Features = 0xA6,
  123. Report_Current_Latency = 0xA8,
  124. Report_ARC_Initiated = 0xC1,
  125. Report_ARC_Terminated = 0xC2,
  126. Request_ARC_Initiation = 0xC3,
  127. Request_ARC_Termination = 0xC4,
  128. Polling_Message=0xfe,
  129. Abort = 0xff
  130. } cecmsg_t;
  131. //Function Prototype
  132. INT32 none(PCECDDev_t pcdv);
  133. INT32 receive_active_source(PCECDDev_t pcdv);
  134. INT32 receive_inactive_source(PCECDDev_t pcdv);
  135. INT32 receive_image_view_on(PCECDDev_t pcdv);
  136. INT32 receive_text_view_on(PCECDDev_t pcdv);
  137. INT32 receive_request_active_source(PCECDDev_t pcdv);
  138. INT32 receive_routing_change(PCECDDev_t pcdv);
  139. INT32 receive_routing_information(PCECDDev_t pcdv);
  140. INT32 receive_standby(PCECDDev_t pcdv);
  141. INT32 receive_give_physical_address(PCECDDev_t pcdv);
  142. INT32 receive_get_menu_language(PCECDDev_t pcdv);
  143. INT32 receive_report_physical_address(PCECDDev_t pcdv);
  144. INT32 receive_set_menu_language(PCECDDev_t pcdv);
  145. INT32 receive_deck_status(PCECDDev_t pcdv);
  146. INT32 receive_device_vendor_id(PCECDDev_t pcdv);
  147. INT32 receive_give_device_vendor_id(PCECDDev_t pcdv);
  148. INT32 receive_set_osd_string(PCECDDev_t pcdv);
  149. INT32 receive_give_osd_name(PCECDDev_t pcdv);
  150. INT32 receive_set_osd_name(PCECDDev_t pcdv);
  151. INT32 receive_menu_status(PCECDDev_t pcdv);
  152. INT32 receive_give_device_power_status(PCECDDev_t pcdv);
  153. INT32 receive_report_power_status(PCECDDev_t pcdv);
  154. INT32 receive_get_cec_version(PCECDDev_t pcdv);
  155. INT32 receive_cec_version(PCECDDev_t pcdv);
  156. INT32 receive_set_system_audio_mode(PCECDDev_t pcdv);
  157. INT32 receive_report_audio_status(PCECDDev_t pcdv);
  158. INT32 receive_system_audio_mode_status(PCECDDev_t pcdv);
  159. INT32 receive_user_control_pressed(PCECDDev_t pcdv);
  160. INT32 receive_user_control_released(PCECDDev_t pcdv);
  161. INT32 receive_feature_abort(PCECDDev_t pcdv);
  162. INT32 receive_abort(PCECDDev_t pcdv);
  163. INT32 receive_report_short_audio_description(PCECDDev_t pcdv);
  164. INT32 receive_initiate_ARC(PCECDDev_t pcdv);
  165. INT32 receive_terminate_ARC(PCECDDev_t pcdv);
  166. INT32 network_Report_PowerStatus(PCECDDev_t pcdv,UINT8 power_status);
  167. INT32 network_Report_OSD_Name(PCECDDev_t pcdv, PDEVICEMAP pdm);
  168. INT32 network_Report_List(PCECDDev_t pcdv);
  169. INT32 receive_give_features(PCECDDev_t pcdv);
  170. INT32 receive_report_features(PCECDDev_t pcdv);
  171. INT32 request_current_latency(PCECDDev_t pcdv);
  172. typedef INT32 (*opcode_handle_func_t)(PCECDDev_t pcdv);
  173. typedef struct _Opcode_type
  174. {
  175. UINT8 opcode;
  176. UINT8 param_num;
  177. UINT8 bDirect;
  178. UINT8 bBroadcast;
  179. opcode_handle_func_t receive;
  180. } Opcode_type;
  181. extern Opcode_type* CEC_CODES[256];
  182. void cecd_UmfEventHandle(CECD_MSG *CecdMsg);
  183. INT32 cecd_enable(void);
  184. INT32 cecd_disable(void);
  185. void UmfHandler_Register(CB_UMFHANDLER CB_UmfHandler);
  186. #endif