1
2
3
4
5
6
7
8 #ifndef PT3_H
9 #define PT3_H
10
11 #include <linux/atomic.h>
12 #include <linux/types.h>
13
14 #include <media/dvb_demux.h>
15 #include <media/dvb_frontend.h>
16 #include <media/dmxdev.h>
17
18 #include "tc90522.h"
19 #include "mxl301rf.h"
20 #include "qm1d1c0042.h"
21
22 #define DRV_NAME KBUILD_MODNAME
23
24 #define PT3_NUM_FE 4
25
26
27
28
29 #define REG_VERSION 0x00
30 #define REG_BUS 0x04
31 #define REG_SYSTEM_W 0x08
32 #define REG_SYSTEM_R 0x0c
33 #define REG_I2C_W 0x10
34 #define REG_I2C_R 0x14
35 #define REG_RAM_W 0x18
36 #define REG_RAM_R 0x1c
37 #define REG_DMA_BASE 0x40
38 #define OFST_DMA_DESC_L 0x00
39 #define OFST_DMA_DESC_H 0x04
40 #define OFST_DMA_CTL 0x08
41 #define OFST_TS_CTL 0x0c
42 #define OFST_STATUS 0x10
43 #define OFST_TS_ERR 0x14
44
45
46
47
48 #define PT3_I2C_MAX 4091
49 struct pt3_i2cbuf {
50 u8 data[PT3_I2C_MAX];
51 u8 tmp;
52 u32 num_cmds;
53 };
54
55
56
57
58 #define TS_PACKET_SZ 188
59
60 #define DATA_XFER_SZ 4096
61 #define DATA_BUF_XFERS 47
62
63 #define DATA_BUF_SZ (DATA_BUF_XFERS * DATA_XFER_SZ)
64 #define MAX_DATA_BUFS 16
65 #define MIN_DATA_BUFS 2
66
67 #define DESCS_IN_PAGE (PAGE_SIZE / sizeof(struct xfer_desc))
68 #define MAX_NUM_XFERS (MAX_DATA_BUFS * DATA_BUF_XFERS)
69 #define MAX_DESC_BUFS DIV_ROUND_UP(MAX_NUM_XFERS, DESCS_IN_PAGE)
70
71
72
73
74
75 struct xfer_desc {
76 u32 addr_l;
77 u32 addr_h;
78 u32 size;
79 u32 next_l;
80 u32 next_h;
81 };
82
83
84 struct xfer_desc_buffer {
85 dma_addr_t b_addr;
86 struct xfer_desc *descs;
87 };
88
89
90 struct dma_data_buffer {
91 dma_addr_t b_addr;
92 u8 *data;
93 };
94
95
96
97
98 struct pt3_adap_config {
99 struct i2c_board_info demod_info;
100 struct tc90522_config demod_cfg;
101
102 struct i2c_board_info tuner_info;
103 union tuner_config {
104 struct qm1d1c0042_config qm1d1c0042;
105 struct mxl301rf_config mxl301rf;
106 } tuner_cfg;
107 u32 init_freq;
108 };
109
110 struct pt3_adapter {
111 struct dvb_adapter dvb_adap;
112 int adap_idx;
113
114 struct dvb_demux demux;
115 struct dmxdev dmxdev;
116 struct dvb_frontend *fe;
117 struct i2c_client *i2c_demod;
118 struct i2c_client *i2c_tuner;
119
120
121 struct task_struct *thread;
122 int num_feeds;
123
124 bool cur_lna;
125 bool cur_lnb;
126
127
128 struct dma_data_buffer buffer[MAX_DATA_BUFS];
129 int buf_idx;
130 int buf_ofs;
131 int num_bufs;
132 int num_discard;
133
134 struct xfer_desc_buffer desc_buf[MAX_DESC_BUFS];
135 int num_desc_bufs;
136 };
137
138
139 struct pt3_board {
140 struct pci_dev *pdev;
141 void __iomem *regs[2];
142
143
144 struct mutex lock;
145
146
147 int lnb_on_cnt;
148
149
150 int lna_on_cnt;
151
152 int num_bufs;
153
154 struct i2c_adapter i2c_adap;
155 struct pt3_i2cbuf *i2c_buf;
156
157 struct pt3_adapter *adaps[PT3_NUM_FE];
158 };
159
160
161
162
163
164 extern int pt3_alloc_dmabuf(struct pt3_adapter *adap);
165 extern void pt3_init_dmabuf(struct pt3_adapter *adap);
166 extern void pt3_free_dmabuf(struct pt3_adapter *adap);
167 extern int pt3_start_dma(struct pt3_adapter *adap);
168 extern int pt3_stop_dma(struct pt3_adapter *adap);
169 extern int pt3_proc_dma(struct pt3_adapter *adap);
170
171 extern int pt3_i2c_master_xfer(struct i2c_adapter *adap,
172 struct i2c_msg *msgs, int num);
173 extern u32 pt3_i2c_functionality(struct i2c_adapter *adap);
174 extern void pt3_i2c_reset(struct pt3_board *pt3);
175 extern int pt3_init_all_demods(struct pt3_board *pt3);
176 extern int pt3_init_all_mxl301rf(struct pt3_board *pt3);
177 #endif