drv_tuner_internal.h 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. /******************************************************************************
  2. ** File Name: drv_tuner_internal.h
  3. **
  4. ** File Description: This file implements frontend modules apis.
  5. **
  6. ** Copyright(c) 2011 S2 Technologies - All Rights Reserved.
  7. **
  8. ** History Information Description
  9. ** Date Author Modification
  10. ** -------------------------------------------------------------
  11. ** 2011/01/24 TonyChung Create
  12. ******************************************************************************/
  13. #ifndef _DRV_TUNER_INTERNAL_H_
  14. #define _DRV_TUNER_INTERNAL_H_
  15. /******************************************************************************
  16. * Header include
  17. *****************************************************************************/
  18. #include "drv_types.h"
  19. #include <drv_tuner_external.h> // Weird include
  20. #ifdef __KERNEL__
  21. #include <linux/version.h>
  22. #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)
  23. #include <asm/swab.h>
  24. #include <linux/slab.h> //for new_kernal
  25. #endif
  26. #include <linux/kref.h> // kref_init()/kref_put()
  27. #include <linux/module.h>
  28. #include <linux/compiler.h>
  29. #include <linux/init.h>
  30. #include <linux/ioctl.h> /* needed for the _IOW etc stuff used later */
  31. #endif
  32. /******************************************************************************
  33. * Constant
  34. *****************************************************************************/
  35. /******************************************************************************
  36. * Enumeration
  37. ******************************************************************************/
  38. typedef enum {
  39. ATV_UNKNOW = -1,
  40. ATV_NTSC,
  41. ATV_PAL_M,
  42. ATV_PAL_N,
  43. ATV_PAL_DK,
  44. ATV_PAL_BG,
  45. ATV_PAL_I,
  46. ATV_SECAM_L,
  47. ATV_SECAM_L1,
  48. ATV_SECAM_DK,
  49. ATV_SECAM_BG,
  50. ATV_NTSC443,
  51. ATV_NTSC443_DK,
  52. ATV_NTSC443_BG,
  53. ATV_NTSC443_I,
  54. ATV_NTSC_DK,
  55. ATV_NTSC_BG,
  56. ATV_NTSC_I,
  57. ATV_PAL_UNKNOWN,
  58. ATV_SECAM_UNKNOWN,
  59. ATV_END
  60. }ATVModulationMode;
  61. /*!
  62. \enum DRV_Frontend_GPIO_Pin_Def_t
  63. \brief external tuner/demod gpio pin def
  64. */
  65. typedef enum
  66. {
  67. DRV_FRONTEND_SI2157_GPIO1, //SI2157 pin 1 , GPIO1
  68. DRV_FRONTEND_SI2157_GPIO2, //SI2157 pin 1 , GPIO1
  69. DRV_FRONTEND_SI2158_GPIO1, //SI2158 pin 1 , GPIO1
  70. DRV_FRONTEND_SI2158_GPIO2, //SI2158 pin 2 , GPIO2
  71. DRV_FRONTEND_PANASONIC_MN88472_GPIO0, //PANASONIC_MN88472 pin 16 , GPIO0
  72. } DRV_Frontend_GPIO_Pin_Def_t;
  73. typedef enum
  74. {
  75. DRV_FRONTEND_GPO_LOW = 0, //GPO output low level
  76. DRV_FRONTEND_GPO_HIGH, //GPO output high level
  77. } DRV_Frontend_GPO_OutputValue_t;
  78. typedef struct
  79. {
  80. DRV_Frontend_GPIO_Pin_Def_t eGPIO_Pin_Def;
  81. DRV_Frontend_GPO_OutputValue_t eOutPutValue;
  82. }sFrontEnd_GPO_Pin_Def_OutputValue;
  83. /*!
  84. * @brief Digital TS mode
  85. */
  86. typedef enum
  87. {
  88. FRONTEND_TS_MODE_Serial = 0,
  89. FRONTEND_TS_MODE_Parallel,
  90. FRONTEND_TS_MODE_MAX,
  91. } DRV_Frontend_TS_Mode_t;
  92. /*!
  93. * @brief LNB Power Switch.
  94. */
  95. typedef enum
  96. {
  97. FRONTEND_LNB_Disable = 0, /**< Disable LNB power */
  98. FRONTEND_LNB_Enable, /**< Enable LNB power */
  99. FRONTEND_LNB_MAX,
  100. }DRV_Frontend_LNB_PowerType_e;
  101. /*!
  102. * @brief LNB 22k Tone Switch.
  103. */
  104. typedef enum
  105. {
  106. FRONTEND_LNB_22kTone_ON = 0, /**< Enable 22k tone */
  107. FRONTEND_LNB_22kTone_OFF, /**< Disable 22k tone */
  108. FRONTEND_LNB_22kTone_MAX,
  109. }DRV_Frontend_LNB_22kTone_e;
  110. /*!
  111. * @brief LNB Voltage Type.
  112. */
  113. typedef enum
  114. {
  115. FRONTEND_LNB_Voltage_13V = 0, /**< LNB polarization voltage: 13V */
  116. FRONTEND_LNB_Voltage_18V, /**< LNB polarization voltage: 18V */
  117. FRONTEND_LNB_Voltage_MAX,
  118. }DRV_Frontend_LNB_VoltageType_e;
  119. /*!
  120. * @brief LNB 22k Tone Switch.
  121. */
  122. typedef enum
  123. {
  124. FRONTEND_LNB_ToneBurst_A = 0, /**< Enable ToneBurst A */
  125. FRONTEND_LNB_ToneBurst_B, /**< Enable ToneBurst B */
  126. FRONTEND_LNB_ToneBurst_OFF, /**< Disable ToneBurst */
  127. FRONTEND_LNB_Tone_MAX,
  128. }DRV_Frontend_LNB_ToneBurst_e;
  129. typedef struct _TunerFreqRequest_t
  130. {
  131. unsigned int Freq;
  132. unsigned int ulSymbolRate;
  133. unsigned char ModulationMode;
  134. unsigned int BandWidth;
  135. unsigned int Cmd[20];
  136. #if defined(CONFIG_ISDB_SYSTEM) //kenny added for ISDB-T need three Dword to store Layer A, B & C parameters 2012/05/25
  137. unsigned long UccpLockInfo[3];
  138. #else
  139. unsigned long UccpLockInfo;
  140. #endif
  141. unsigned char ExtDemodFlag; // for external DTV demod
  142. int PlpId;
  143. unsigned int CmdLength; // for ATV demod
  144. int bLock;
  145. int FreqOffset;
  146. DRV_RfFrontend_Std_t Std;
  147. unsigned int RegAddr; // for tunerap
  148. unsigned int RegAddrStartBit;// for tunerap
  149. unsigned int RegLength; // for tunerap
  150. unsigned int RegValue; // for tunerap
  151. DRV_Frontend_Spectral_Inversion_t invert_spectrum;
  152. } TunerFreqRequest_t, * PTunerFreqRequest_t;
  153. //SIF request type
  154. typedef enum {
  155. DEMODATV_SifReqNormalSleep,
  156. DEMODATV_SifReqNormalWakeUp,
  157. DEMODATV_SifReqForceSleep,
  158. DEMODATV_SifReqForceWakeUp,
  159. DEMODATV_SifReqMax
  160. } demodatv_TypeSifReq, *demodatv_pTypeSifReq;
  161. typedef enum {
  162. DEMODATV_SifReqStsOK,
  163. DEMODATV_SifReqStsFail,
  164. DEMODATV_SifReqStsMax
  165. } demodatv_TypeSifReqSts, *demodatv_pTypeSifReqSts;
  166. typedef struct {
  167. demodatv_TypeSifReq req;
  168. demodatv_TypeSifReqSts status;
  169. } demodatv_TypeSif, *demodatv_pTypeSif;
  170. //---//
  171. //Request type
  172. typedef enum {
  173. DEMODATV_ReqSetVIFTop,
  174. DEMODATV_ReqSetAudioSys,
  175. DEMODATV_ReqSetAFTOn,
  176. DEMODATV_ReqSetFilter,
  177. DEMODATV_ReqMax
  178. } demodatv_TypeReq, *demodatv_pTypeReq;
  179. typedef enum {
  180. DEMODATV_ReqStsOK,
  181. DEMODATV_ReqStsFail,
  182. DEMODATV_ReqStsMax
  183. } demodatv_TypeReqSts, *demodatv_pTypeReqSts;
  184. typedef enum {
  185. DEMODATV_SetNtscFilter,
  186. DEMODATV_SetPalFilter,
  187. DEMODATV_SetSecamFilter,
  188. DEMODATV_SetMaxFilter
  189. } demodatv_TypeFilter, *demodatv_pTypeFilter;
  190. typedef struct {
  191. demodatv_TypeReq req;
  192. unsigned char value;
  193. demodatv_TypeFilter filter;
  194. PTunerFreqRequest_t pFreqRequest;
  195. demodatv_TypeReqSts status;
  196. } tuner_TypeReq, *tuner_pTypeReq;
  197. typedef enum {
  198. Ademod_Type_CVBSInverseSts,
  199. Ademod_Type_GetAudioCarrier,
  200. Ademod_Type_SetNarrowLPF49MFIR,
  201. Ademod_Type_SetScanLPF49MFIR,
  202. Ademod_Type_GetAdemodStatus,
  203. Ademod_Type_SetStopPolling,
  204. Ademod_Type_SetInverseNyquist,
  205. Ademod_Type_ResetPLL,
  206. Ademod_Type_CheckSpur,
  207. Ademod_Type_EnClkForCheckSpur,
  208. Ademod_Type_SetCVBSInverse,
  209. Ademod_Type_GetORSTStatus,
  210. Ademod_Type_Max
  211. } Ademod_Type, *Ademod_pType;
  212. typedef enum {
  213. Ademod_CVBS_NonInverse,
  214. Ademod_CVBS_Inverse
  215. } Ademod_InverseSts, *Ademod_pInverseSts;
  216. typedef enum {
  217. Ademod_NonStdSts_FALSE,
  218. Ademod_NonStdSts_TRUE
  219. } Ademod_mode_NonStdSts, *Ademod_pmode_NonStdSts;
  220. typedef enum {
  221. Ademod_mode_PLLSts_FALSE,
  222. Ademod_mode_PLLSts_TRUE
  223. } Ademod_mode_PLLSts, *Ademod_pmode_PLLSts;
  224. typedef enum {
  225. Ademod_ReqStsFail,
  226. Ademod_ReqStsOK
  227. } Ademod_ReqSts, *Ademod_pReqSts;
  228. typedef struct {
  229. Ademod_Type type;
  230. Ademod_InverseSts inverseSts;
  231. Ademod_mode_NonStdSts modeNonStdSts;
  232. Ademod_mode_PLLSts modePLLSts;
  233. Ademod_ReqSts status;
  234. unsigned int value;
  235. } Ademod_Request_Type, *Ademod_pRequest_Type;
  236. typedef enum {
  237. DEMOD_ReqSetTsoClkInvertMode,//Rising-Edge
  238. DEMOD_ReqSetTsoClkNormalMode,//Falling-Edge
  239. DEMOD_ReqMax
  240. } demod_TypeReqCmd, *demod_pTypeReqCmd;
  241. typedef struct {
  242. demod_TypeReqCmd req;
  243. } demod_TypeReq, *demod_pTypeReq;
  244. //---//
  245. /*--------------------------------------
  246. * indicate the request to tuner power on/off
  247. */
  248. typedef enum{
  249. TUNER_PowerOn,
  250. TUNER_PowerOff,
  251. TUNER_PowerDefault = TUNER_PowerOff
  252. } tuner_TypePower, *tuner_pTypePower;
  253. /*--------------------------------------
  254. * indicate the status of tuner power on/off
  255. */
  256. typedef enum{
  257. TUNER_PowerStsOn,
  258. TUNER_PowerStsOff,
  259. TUNER_PowerStsDefault = TUNER_PowerStsOff
  260. } tuner_TyPowerSts, *tuner_pTyPowerSts;
  261. /*--------------------------------------
  262. * indicate the request for ATV or DTV
  263. */
  264. typedef enum{
  265. TUNER_TvTypeAtv,
  266. TUNER_TvTypeDtv,
  267. TUNER_TvTypeMax
  268. } tuner_TypeTvType, *tuner_pTypeTvType;
  269. /*--------------------------------------
  270. * indicate the current input source
  271. */
  272. typedef enum{
  273. TUNER_InputSourceAtv,
  274. TUNER_InputSourceDtv,
  275. TUNER_InputSourceAv,
  276. TUNER_InputSourceAv2,
  277. TUNER_InputSourceSv,
  278. TUNER_InputSourceSv2,
  279. TUNER_InputSourceComponent,
  280. TUNER_InputSourceScart1Av,
  281. TUNER_InputSourceScart1Sv,
  282. TUNER_InputSourceScart1Auto,
  283. TUNER_InputSourceScart2Av,
  284. TUNER_InputSourceScart2Sv,
  285. TUNER_InputSourceScart2Auto,
  286. TUNER_InputSourceMax
  287. } tuner_TypeInputSource, *tuner_pTypeInputSource;
  288. //extern unsigned int kmf_GetProjectTunerID(void);
  289. extern int DRV_FrontendCtrl(DRV_Frontend_Cmd dCmd, void *pdPara);
  290. extern int _DRV_Ademod_Request(Ademod_pRequest_Type pRequest);
  291. extern int DRV_ADEMOD_SetInverseCVBS(UINT8 vaule);
  292. #endif // _DRV_TUNER_INTERNAL_H_