-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathaml_dvb.h
330 lines (281 loc) · 8.6 KB
/
aml_dvb.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
#ifndef _AML_DVB_H_
#define _AML_DVB_H_
#include <linux/interrupt.h>
#include <linux/socket.h>
#include <linux/netdevice.h>
#include <linux/i2c.h>
#include <linux/dvb/video.h>
#include <linux/dvb/audio.h>
#include <linux/dvb/dmx.h>
#include <linux/dvb/ca.h>
#include <linux/dvb/osd.h>
#include <linux/dvb/net.h>
#include <linux/dvb/frontend.h>
#include <linux/mutex.h>
#include <linux/spinlock.h>
#include <linux/interrupt.h>
#ifdef CONFIG_HAS_EARLYSUSPEND
#include <linux/earlysuspend.h>
#endif
#include "dvbdev.h"
#include "demux.h"
#include "dvb_demux.h"
#include "dmxdev.h"
#include "dvb_filter.h"
#include "dvb_net.h"
#include "dvb_ringbuffer.h"
#include "dvb_frontend.h"
#include <linux/of.h>
#include <linux/pinctrl/consumer.h>
#define TS_IN_COUNT 3
#define S2P_COUNT 2
#define DMX_DEV_COUNT 3
#define FE_DEV_COUNT 2
#define CHANNEL_COUNT 31
#define FILTER_COUNT 31
#define FILTER_LEN 15
#define DSC_DEV_COUNT 1
#define DSC_COUNT 8
#define SEC_BUF_GRP_COUNT 4
#define SEC_BUF_BUSY_SIZE 4
#define SEC_BUF_COUNT (SEC_BUF_GRP_COUNT*8)
#define ASYNCFIFO_COUNT 2
enum aml_dmx_id_t {
AM_DMX_0 = 0,
AM_DMX_1,
AM_DMX_2,
AM_DMX_MAX,
};
enum aml_ts_source_t {
AM_TS_SRC_TS0,
AM_TS_SRC_TS1,
AM_TS_SRC_TS2,
AM_TS_SRC_S_TS0,
AM_TS_SRC_S_TS1,
AM_TS_SRC_S_TS2,
AM_TS_SRC_HIU,
AM_TS_SRC_DMX0,
AM_TS_SRC_DMX1,
AM_TS_SRC_DMX2
};
struct aml_sec_buf {
unsigned long addr;
int len;
};
struct aml_channel {
int type;
enum dmx_ts_pes pes_type;
int pid;
int used;
int filter_count;
struct dvb_demux_feed *feed;
struct dvb_demux_feed *dvr_feed;
};
struct aml_filter {
int chan_id;
int used;
struct dmx_section_filter *filter;
u8 value[FILTER_LEN];
u8 maskandmode[FILTER_LEN];
u8 maskandnotmode[FILTER_LEN];
u8 neq;
};
struct aml_dsc {
int pid;
u8 even[8];
u8 odd[8];
int used;
int set;
int id;
struct aml_dvb *dvb;
};
struct aml_smallsec {
struct aml_dmx *dmx;
int enable;
int bufsize;
#define SS_BUFSIZE_DEF (16*4*256) /*16KB*/
long buf;
long buf_map;
};
struct aml_dmxtimeout {
struct aml_dmx *dmx;
int enable;
int timeout;
#define DTO_TIMEOUT_DEF (9000) /*0.5s*/
u32 ch_disable;
#define DTO_CHDIS_VAS (0xfffffff8) /*v/a/s only*/
int match;
int trigger;
};
struct aml_dmx {
struct dvb_demux demux;
struct dmxdev dmxdev;
int id;
int feed_count;
int chan_count;
enum aml_ts_source_t source;
int init;
int record;
struct dmx_frontend hw_fe[DMX_DEV_COUNT];
struct dmx_frontend mem_fe;
struct dvb_net dvb_net;
int dmx_irq;
int dvr_irq;
struct tasklet_struct dmx_tasklet;
struct tasklet_struct dvr_tasklet;
unsigned long sec_pages;
unsigned long sec_pages_map;
int sec_total_len;
struct aml_sec_buf sec_buf[SEC_BUF_COUNT];
unsigned long pes_pages;
unsigned long pes_pages_map;
int pes_buf_len;
unsigned long sub_pages;
unsigned long sub_pages_map;
int sub_buf_len;
struct aml_channel channel[CHANNEL_COUNT];
struct aml_filter filter[FILTER_COUNT];
irq_handler_t irq_handler;
void *irq_data;
int aud_chan;
int vid_chan;
int sub_chan;
int pcr_chan;
u32 section_busy[SEC_BUF_BUSY_SIZE];
struct dvb_frontend *fe;
int int_check_count;
u32 int_check_time;
int in_tune;
int error_check;
int dump_ts_select;
int sec_buf_watchdog_count[SEC_BUF_COUNT];
struct aml_smallsec smallsec;
struct aml_dmxtimeout timeout;
int demux_filter_user;
};
struct aml_asyncfifo {
int id;
int init;
int asyncfifo_irq;
enum aml_dmx_id_t source;
unsigned long pages;
unsigned long pages_map;
int buf_len;
int buf_toggle;
int buf_read;
int flush_size;
struct tasklet_struct asyncfifo_tasklet;
struct aml_dvb *dvb;
};
enum{
AM_TS_DISABLE,
AM_TS_PARALLEL,
AM_TS_SERIAL
};
struct aml_ts_input {
int mode;
struct pinctrl *pinctrl;
int control;
int s2p_id;
};
struct aml_s2p {
int invert;
};
struct aml_swfilter {
int user;
struct aml_dmx *dmx;
struct aml_asyncfifo *afifo;
struct dvb_ringbuffer rbuf;
#define SF_BUFFER_SIZE (10*188*1024)
u8 wrapbuf[188];
int track_dmx;
};
struct aml_dvb {
struct dvb_device dvb_dev;
struct aml_ts_input ts[TS_IN_COUNT];
struct aml_s2p s2p[S2P_COUNT];
struct aml_dmx dmx[DMX_DEV_COUNT];
struct aml_dsc dsc[DSC_COUNT];
struct aml_asyncfifo asyncfifo[ASYNCFIFO_COUNT];
struct dvb_device *dsc_dev;
struct dvb_adapter dvb_adapter;
struct device *dev;
struct platform_device *pdev;
enum aml_ts_source_t stb_source;
enum aml_ts_source_t dsc_source;
enum aml_ts_source_t tso_source;
int dmx_init;
int reset_flag;
spinlock_t slock;
struct timer_list watchdog_timer;
int dmx_watchdog_disable[DMX_DEV_COUNT];
struct aml_swfilter swfilter;
};
/*AMLogic demux interface*/
extern int aml_dmx_hw_init(struct aml_dmx *dmx);
extern int aml_dmx_hw_deinit(struct aml_dmx *dmx);
extern int aml_dmx_hw_start_feed(struct dvb_demux_feed *dvbdmxfeed);
extern int aml_dmx_hw_stop_feed(struct dvb_demux_feed *dvbdmxfeed);
extern int aml_dmx_hw_set_source(struct dmx_demux *demux, dmx_source_t src);
extern int aml_stb_hw_set_source(struct aml_dvb *dvb, dmx_source_t src);
extern int aml_dsc_hw_set_source(struct aml_dvb *dvb, dmx_source_t src);
extern int aml_tso_hw_set_source(struct aml_dvb *dvb, dmx_source_t src);
extern int aml_dmx_set_skipbyte(struct aml_dvb *dvb, int skipbyte);
extern int aml_dmx_set_demux(struct aml_dvb *dvb, int id);
extern int aml_dmx_hw_set_dump_ts_select
(struct dmx_demux *demux, int dump_ts_select);
extern int dmx_alloc_chan(struct aml_dmx *dmx, int type,
int pes_type, int pid);
extern void dmx_free_chan(struct aml_dmx *dmx, int cid);
extern int dmx_get_ts_serial(enum aml_ts_source_t src);
/*AMLogic dsc interface*/
extern int dsc_set_pid(struct aml_dsc *dsc, int pid);
extern int dsc_set_key(struct aml_dsc *dsc, int type, u8 *key);
extern int dsc_release(struct aml_dsc *dsc);
/*AMLogic ASYNC FIFO interface*/
extern int aml_asyncfifo_hw_init(struct aml_asyncfifo *afifo);
extern int aml_asyncfifo_hw_deinit(struct aml_asyncfifo *afifo);
extern int aml_asyncfifo_hw_set_source(struct aml_asyncfifo *afifo,
enum aml_dmx_id_t src);
extern int aml_asyncfifo_hw_reset(struct aml_asyncfifo *afifo);
/*Get the Audio & Video PTS*/
extern u32 aml_dmx_get_video_pts(struct aml_dvb *dvb);
extern u32 aml_dmx_get_audio_pts(struct aml_dvb *dvb);
extern u32 aml_dmx_get_first_video_pts(struct aml_dvb *dvb);
extern u32 aml_dmx_get_first_audio_pts(struct aml_dvb *dvb);
/*Get the DVB device*/
extern struct aml_dvb *aml_get_dvb_device(void);
/*Demod interface*/
extern void aml_dmx_register_frontend(enum aml_ts_source_t src,
struct dvb_frontend *fe);
extern void aml_dmx_before_retune(enum aml_ts_source_t src,
struct dvb_frontend *fe);
extern void aml_dmx_after_retune(enum aml_ts_source_t src,
struct dvb_frontend *fe);
extern void aml_dmx_start_error_check(enum aml_ts_source_t src,
struct dvb_frontend *fe);
extern int aml_dmx_stop_error_check(enum aml_ts_source_t src,
struct dvb_frontend *fe);
extern int aml_regist_dmx_class(void);
extern int aml_unregist_dmx_class(void);
extern void dvb_frontend_retune(struct dvb_frontend *fe);
struct devio_aml_platform_data {
int (*io_setup)(void *);
int (*io_cleanup)(void *);
int (*io_power)(void *, int enable);
int (*io_reset)(void *, int enable);
};
/*Reset the demux device*/
void dmx_reset_hw(struct aml_dvb *dvb);
void dmx_reset_hw_ex(struct aml_dvb *dvb, int reset_irq);
/*Reset the individual demux*/
void dmx_reset_dmx_hw(struct aml_dvb *dvb, int id);
void dmx_reset_dmx_id_hw_ex(struct aml_dvb *dvb, int id, int reset_irq);
void dmx_reset_dmx_id_hw_ex_unlock(struct aml_dvb *dvb, int id, int reset_irq);
void dmx_reset_dmx_hw_ex(struct aml_dvb *dvb,
struct aml_dmx *dmx,
int reset_irq);
void dmx_reset_dmx_hw_ex_unlock(struct aml_dvb *dvb,
struct aml_dmx *dmx,
int reset_irq);
#endif