summaryrefslogtreecommitdiff
path: root/tvapi/libtv/tv/CFrontEnd.h (plain)
blob: d562cfc5a595a57399ffc4b6492bd60ee3cc1d98
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
76{
77public:
78
79 static const int FE_DEV_ID = 0;
80 static const int AFC_RANGE = 1000000;
81
82 CFrontEnd();
83 ~CFrontEnd();
84
85 int Open(int mode);
86 int Close();
87 int setMode(int mode);
88 int fineTune(int freq);
89 int formatATVFreq(int freq);
90 int GetTSSource(AM_DMX_Source_t *src);
91 int setPara(int frequency, int symbol_rate, int modulation, int bandwidth);
92 int ClearAnalogFrontEnd();
93 int autoLoadFE();
94
95 static int stdAndColorToAudioEnum(int std);
96 static int stdAndColorToVideoEnum(int std);
97 static int printVideoStdStr(int videoStd, char strBuffer[], int buff_size);
98 static int printAudioStdStr(int audioStd, char strBuffer[], int buff_size);
99 static v4l2_std_id enumToStdAndColor(int videoStd, int audioStd);
100 static int stdEnumToCvbsFmt (int videoStd, int audioStd);
101 class FEEvent: public CTvEv
102 {
103 public:
104 //static const int EVENT_FE_HAS_SIG = 0X01; /* found something above the noise level */
105 //static const int EVENT_FE_HAS_CARRIER = 0x02; /* found a DVB signal */
106 //static const int EVENT_FE_HAS_VITERBI = 0X04; /* FEC is stable */
107 //static const int EVENT_FE_HAS_SYNC = 0X08; /* found sync bytes */
108 // static const int EVENT_FE_HAS_LOCK = 0X10; /* everything's working... */
109 //static const int EVENT_FE_HAS_TIMEOUT = 0X20; /* no lock within the last ~2 seconds */
110 //static const int EVENT_FE_REINIT = 0X40; /* frontend was reinitialized, */
111 static const int EVENT_FE_HAS_SIG = 0x01;
112 static const int EVENT_FE_NO_SIG = 0x02;
113 static const int EVENT_FE_INIT = 0x03;
114
115 FEEvent(): CTvEv(CTvEv::TV_EVENT_SIGLE_DETECT)
116 {
117 }
118 ~FEEvent()
119 {
120 }
121 int mCurSigStaus;
122 int mCurFreq;
123 };
124
125 class IObserver
126 {
127 public:
128 IObserver() {};
129 virtual ~IObserver() {};
130 virtual void onEvent(const FEEvent &ev) = 0;
131 };
132
133 int setObserver(IObserver *ob)
134 {
135 mpObserver = ob;
136 return 0;
137 }
138
139 int getSNR();
140 int getBER();
141 int getInfo();
142 int getStatus();
143 int checkStatusOnce();
144 int getStrength();
145 int setCvbsAmpOut(int amp);
146 int setThreadDelay(int delay) ;
147 int getPara(frontend_para_set_t *fpara);
148 int lock(int frequency, int symbol_rate, int modulation, int bandwidth);
149private:
150 int mFrontDevID;
151 int mDemuxDevID;
152 int mTvPlayDevID;
153 int mCurFineFreq;
154 IObserver *mpObserver;
155 FEEvent mCurSigEv;
156 int mCurMode;
157 static void dmd_fend_callback(int dev_no, int event_type, void *param, void *user_data);
158};
159#endif // ANDROID_FRONTEND_H
160
161