summaryrefslogtreecommitdiff
path: root/tvapi/libtv/tv/CFrontEnd.h (plain)
blob: 81b8caf3b2293c3e0dc5d2ad47b0eae1283e7afd
1#ifndef ANDROID_FRONTEND_H
2#define ANDROID_FRONTEND_H
3#include <stdio.h>
4#include <stdlib.h>
5#include <unistd.h>
6#include <string.h>
7#include "CTvLog.h"
8#include "CTvEv.h"
9extern "C" {
10#include "am_fend.h"
11#include "am_vout.h"
12#include "linux/dvb/frontend.h"
13}
14//for app
15typedef enum atv_audo_std_s {
16 CC_ATV_AUDIO_STD_START = 0,
17 CC_ATV_AUDIO_STD_DK = 0,
18 CC_ATV_AUDIO_STD_I,
19 CC_ATV_AUDIO_STD_BG,
20 CC_ATV_AUDIO_STD_M,
21 CC_ATV_AUDIO_STD_L,
22 CC_ATV_AUDIO_STD_AUTO,
23 CC_ATV_AUDIO_STD_END = CC_ATV_AUDIO_STD_AUTO,
24 CC_ATV_AUDIO_STD_MUTE,
25} atv_audio_std_t;
26//for app
27typedef enum atv_video_std_s {
28 CC_ATV_VIDEO_STD_START = 0,
29 CC_ATV_VIDEO_STD_AUTO = 0,
30 CC_ATV_VIDEO_STD_PAL,
31 CC_ATV_VIDEO_STD_NTSC,
32 CC_ATV_VIDEO_STD_SECAM,
33 CC_ATV_VIDEO_STD_END = CC_ATV_VIDEO_STD_SECAM,
34} atv_video_std_t;
35
36
37//from kernel
38/*COLOR MODULATION TYPE*/
39static const v4l2_std_id V4L2_COLOR_STD_PAL = ((v4l2_std_id)0x04000000);
40static const v4l2_std_id V4L2_COLOR_STD_NTSC = ((v4l2_std_id)0x08000000);
41static const v4l2_std_id V4L2_COLOR_STD_SECAM = ((v4l2_std_id)0x10000000);
42//virtual
43static const v4l2_std_id V4L2_COLOR_STD_AUTO = ((v4l2_std_id)0x02000000);
44
45typedef struct frontend_para_set_s {
46 fe_type_t mode;
47 int freq;
48 atv_video_std_t videoStd;
49 atv_audio_std_t audioStd;
50 int para1;
51 int para2;
52} frontend_para_set_t;
53
54typedef struct atv_channel_info_s {
55 int finefreq;
56 atv_video_std_t videoStd;
57 atv_audio_std_t audioStd;
58 int isAutoStd;
59} atv_channel_info_t;
60
61typedef struct dtv_channel_info_s {
62 int strength;
63 int quality;
64 int ber;
65} dtv_channel_info_t;
66
67typedef struct channel_info_s {
68 int freq;
69 union {
70 atv_channel_info_t atvChanInfo;
71 dtv_channel_info_t dtvChanInfo;
72 } uInfo;
73} channel_info_t;
74
75class CFrontEnd {
76public:
77
78 static const int FE_DEV_ID = 0;
79 static const int AFC_RANGE = 1000000;
80
81 CFrontEnd();
82 ~CFrontEnd();
83
84 int Open(int mode);
85 int Close();
86 int setMode(int mode);
87 int fineTune(int freq);
88 static int formatATVFreq(int freq);
89 int GetTSSource(AM_DMX_Source_t *src);
90 int setPara(int mode, int freq, int para1, int para2);
91 int ClearAnalogFrontEnd();
92 int autoLoadFE();
93 int SetAnalogFrontEndTimerSwitch(int onOff);
94 int SetAnalogFrontEndSearhSlowMode(int onOff);
95
96 static int stdAndColorToAudioEnum(int std);
97 static int stdAndColorToVideoEnum(int std);
98 static bool stdIsColorAuto(int std);
99 static int addColorAutoFlag(int std);
100 static int printVideoStdStr(int videoStd, char strBuffer[], int buff_size);
101 static int printAudioStdStr(int audioStd, char strBuffer[], int buff_size);
102 static v4l2_std_id enumToStdAndColor(int videoStd, int audioStd);
103 static int stdEnumToCvbsFmt (int videoStd, int audioStd);
104 class FEEvent: public CTvEv {
105 public:
106 //static const int EVENT_FE_HAS_SIG = 0X01; /* found something above the noise level */
107 //static const int EVENT_FE_HAS_CARRIER = 0x02; /* found a DVB signal */
108 //static const int EVENT_FE_HAS_VITERBI = 0X04; /* FEC is stable */
109 //static const int EVENT_FE_HAS_SYNC = 0X08; /* found sync bytes */
110 // static const int EVENT_FE_HAS_LOCK = 0X10; /* everything's working... */
111 //static const int EVENT_FE_HAS_TIMEOUT = 0X20; /* no lock within the last ~2 seconds */
112 //static const int EVENT_FE_REINIT = 0X40; /* frontend was reinitialized, */
113 static const int EVENT_FE_HAS_SIG = 0x01;
114 static const int EVENT_FE_NO_SIG = 0x02;
115 static const int EVENT_FE_INIT = 0x03;
116
117 FEEvent(): CTvEv(CTvEv::TV_EVENT_SIGLE_DETECT)
118 {
119 }
120 ~FEEvent()
121 {
122 }
123 int mCurSigStaus;
124 int mCurFreq;
125 };
126
127 class IObserver {
128 public:
129 IObserver() {};
130 virtual ~IObserver() {};
131 virtual void onEvent(const FEEvent &ev) = 0;
132 };
133
134 int setObserver(IObserver *ob)
135 {
136 mpObserver = ob;
137 return 0;
138 }
139
140 int getSNR();
141 int getBER();
142 int getInfo();
143 int getStatus();
144 int checkStatusOnce();
145 int getStrength();
146 int setCvbsAmpOut(int amp);
147 int setThreadDelay(int delay) ;
148 int getPara(int *mode, int *freq, int *para1, int *para2);
149 int lock(int frequency, int symbol_rate, int modulation, int bandwidth);
150 int setTunerAfc(int afc);
151private:
152 int mFrontDevID;
153 int mDemuxDevID;
154 int mTvPlayDevID;
155 int mCurFineFreq;
156 IObserver *mpObserver;
157 FEEvent mCurSigEv;
158 int mCurMode;
159 int mCurFreq;
160 int mCurPara1;
161 int mCurPara2;
162 bool mbFEOpened;
163 static void dmd_fend_callback(long dev_no, int event_type, void *param, void *user_data);
164};
165#endif // ANDROID_FRONTEND_H
166
167