blob: 9412fcd1bddb65f57293b56ffbb80fba3d1cf3dc [file] [log] [blame]
Pierrick Hascoet41b44e02011-10-31 12:24:39 -03001/*
2 * Abilis Systems Single DVB-T Receiver
3 * Copyright (C) 2008 Pierrick Hascoet <pierrick.hascoet@abilis.com>
Devin Heitmueller87ad567e2011-10-31 12:24:44 -03004 * Copyright (C) 2010 Devin Heitmueller <dheitmueller@kernellabs.com>
Pierrick Hascoet41b44e02011-10-31 12:24:39 -03005 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
Pierrick Hascoet41b44e02011-10-31 12:24:39 -030015 */
Mauro Carvalho Chehab47f79122014-08-12 18:50:22 -030016
17#include <dvb_frontend.h>
18
19#include "as102_fe.h"
Pierrick Hascoet41b44e02011-10-31 12:24:39 -030020
Mauro Carvalho Chehabb601d9a2014-08-12 18:50:19 -030021struct as102_state {
22 struct dvb_frontend frontend;
23 struct as10x_demod_stats demod_stats;
Pierrick Hascoet41b44e02011-10-31 12:24:39 -030024
Mauro Carvalho Chehab47f79122014-08-12 18:50:22 -030025 const struct as102_fe_ops *ops;
26 void *priv;
Mauro Carvalho Chehabb601d9a2014-08-12 18:50:19 -030027 uint8_t elna_cfg;
Pierrick Hascoet41b44e02011-10-31 12:24:39 -030028
Mauro Carvalho Chehabb601d9a2014-08-12 18:50:19 -030029 /* signal strength */
30 uint16_t signal_strength;
31 /* bit error rate */
32 uint32_t ber;
Pierrick Hascoet41b44e02011-10-31 12:24:39 -030033};
34
Mauro Carvalho Chehab0df289a2015-06-07 14:53:52 -030035static uint8_t as102_fe_get_code_rate(enum fe_code_rate arg)
Devin Heitmueller87ad567e2011-10-31 12:24:44 -030036{
Pierrick Hascoet41b44e02011-10-31 12:24:39 -030037 uint8_t c;
38
Devin Heitmueller87ad567e2011-10-31 12:24:44 -030039 switch (arg) {
40 case FEC_1_2:
41 c = CODE_RATE_1_2;
42 break;
43 case FEC_2_3:
44 c = CODE_RATE_2_3;
45 break;
46 case FEC_3_4:
47 c = CODE_RATE_3_4;
48 break;
49 case FEC_5_6:
50 c = CODE_RATE_5_6;
51 break;
52 case FEC_7_8:
53 c = CODE_RATE_7_8;
54 break;
55 default:
56 c = CODE_RATE_UNKNOWN;
57 break;
Pierrick Hascoet41b44e02011-10-31 12:24:39 -030058 }
59
60 return c;
61}
62
Mauro Carvalho Chehab1d6207f2014-08-12 18:50:20 -030063static int as102_fe_set_frontend(struct dvb_frontend *fe)
Devin Heitmueller87ad567e2011-10-31 12:24:44 -030064{
Mauro Carvalho Chehab1d6207f2014-08-12 18:50:20 -030065 struct as102_state *state = fe->demodulator_priv;
66 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
Mauro Carvalho Chehab1d6207f2014-08-12 18:50:20 -030067 struct as10x_tune_args tune_args = { 0 };
Pierrick Hascoet41b44e02011-10-31 12:24:39 -030068
69 /* set frequency */
Mauro Carvalho Chehab1d6207f2014-08-12 18:50:20 -030070 tune_args.freq = c->frequency / 1000;
Pierrick Hascoet41b44e02011-10-31 12:24:39 -030071
72 /* fix interleaving_mode */
Mauro Carvalho Chehab1d6207f2014-08-12 18:50:20 -030073 tune_args.interleaving_mode = INTLV_NATIVE;
Pierrick Hascoet41b44e02011-10-31 12:24:39 -030074
Mauro Carvalho Chehab1d6207f2014-08-12 18:50:20 -030075 switch (c->bandwidth_hz) {
Mauro Carvalho Chehabdfc64382011-12-26 15:20:03 -030076 case 8000000:
Mauro Carvalho Chehab1d6207f2014-08-12 18:50:20 -030077 tune_args.bandwidth = BW_8_MHZ;
Devin Heitmueller87ad567e2011-10-31 12:24:44 -030078 break;
Mauro Carvalho Chehabdfc64382011-12-26 15:20:03 -030079 case 7000000:
Mauro Carvalho Chehab1d6207f2014-08-12 18:50:20 -030080 tune_args.bandwidth = BW_7_MHZ;
Devin Heitmueller87ad567e2011-10-31 12:24:44 -030081 break;
Mauro Carvalho Chehabdfc64382011-12-26 15:20:03 -030082 case 6000000:
Mauro Carvalho Chehab1d6207f2014-08-12 18:50:20 -030083 tune_args.bandwidth = BW_6_MHZ;
Devin Heitmueller87ad567e2011-10-31 12:24:44 -030084 break;
85 default:
Mauro Carvalho Chehab1d6207f2014-08-12 18:50:20 -030086 tune_args.bandwidth = BW_8_MHZ;
Pierrick Hascoet41b44e02011-10-31 12:24:39 -030087 }
88
Mauro Carvalho Chehab1d6207f2014-08-12 18:50:20 -030089 switch (c->guard_interval) {
Devin Heitmueller87ad567e2011-10-31 12:24:44 -030090 case GUARD_INTERVAL_1_32:
Mauro Carvalho Chehab1d6207f2014-08-12 18:50:20 -030091 tune_args.guard_interval = GUARD_INT_1_32;
Devin Heitmueller87ad567e2011-10-31 12:24:44 -030092 break;
93 case GUARD_INTERVAL_1_16:
Mauro Carvalho Chehab1d6207f2014-08-12 18:50:20 -030094 tune_args.guard_interval = GUARD_INT_1_16;
Devin Heitmueller87ad567e2011-10-31 12:24:44 -030095 break;
96 case GUARD_INTERVAL_1_8:
Mauro Carvalho Chehab1d6207f2014-08-12 18:50:20 -030097 tune_args.guard_interval = GUARD_INT_1_8;
Devin Heitmueller87ad567e2011-10-31 12:24:44 -030098 break;
99 case GUARD_INTERVAL_1_4:
Mauro Carvalho Chehab1d6207f2014-08-12 18:50:20 -0300100 tune_args.guard_interval = GUARD_INT_1_4;
Devin Heitmueller87ad567e2011-10-31 12:24:44 -0300101 break;
102 case GUARD_INTERVAL_AUTO:
103 default:
Mauro Carvalho Chehab1d6207f2014-08-12 18:50:20 -0300104 tune_args.guard_interval = GUARD_UNKNOWN;
Devin Heitmueller87ad567e2011-10-31 12:24:44 -0300105 break;
Pierrick Hascoet41b44e02011-10-31 12:24:39 -0300106 }
107
Mauro Carvalho Chehab1d6207f2014-08-12 18:50:20 -0300108 switch (c->modulation) {
Devin Heitmueller87ad567e2011-10-31 12:24:44 -0300109 case QPSK:
Mauro Carvalho Chehab1d6207f2014-08-12 18:50:20 -0300110 tune_args.modulation = CONST_QPSK;
Devin Heitmueller87ad567e2011-10-31 12:24:44 -0300111 break;
112 case QAM_16:
Mauro Carvalho Chehab1d6207f2014-08-12 18:50:20 -0300113 tune_args.modulation = CONST_QAM16;
Devin Heitmueller87ad567e2011-10-31 12:24:44 -0300114 break;
115 case QAM_64:
Mauro Carvalho Chehab1d6207f2014-08-12 18:50:20 -0300116 tune_args.modulation = CONST_QAM64;
Devin Heitmueller87ad567e2011-10-31 12:24:44 -0300117 break;
118 default:
Mauro Carvalho Chehab1d6207f2014-08-12 18:50:20 -0300119 tune_args.modulation = CONST_UNKNOWN;
Devin Heitmueller87ad567e2011-10-31 12:24:44 -0300120 break;
Pierrick Hascoet41b44e02011-10-31 12:24:39 -0300121 }
122
Mauro Carvalho Chehab1d6207f2014-08-12 18:50:20 -0300123 switch (c->transmission_mode) {
Devin Heitmueller87ad567e2011-10-31 12:24:44 -0300124 case TRANSMISSION_MODE_2K:
Mauro Carvalho Chehab1d6207f2014-08-12 18:50:20 -0300125 tune_args.transmission_mode = TRANS_MODE_2K;
Devin Heitmueller87ad567e2011-10-31 12:24:44 -0300126 break;
127 case TRANSMISSION_MODE_8K:
Mauro Carvalho Chehab1d6207f2014-08-12 18:50:20 -0300128 tune_args.transmission_mode = TRANS_MODE_8K;
Devin Heitmueller87ad567e2011-10-31 12:24:44 -0300129 break;
130 default:
Mauro Carvalho Chehab1d6207f2014-08-12 18:50:20 -0300131 tune_args.transmission_mode = TRANS_MODE_UNKNOWN;
Pierrick Hascoet41b44e02011-10-31 12:24:39 -0300132 }
133
Mauro Carvalho Chehab1d6207f2014-08-12 18:50:20 -0300134 switch (c->hierarchy) {
Devin Heitmueller87ad567e2011-10-31 12:24:44 -0300135 case HIERARCHY_NONE:
Mauro Carvalho Chehab1d6207f2014-08-12 18:50:20 -0300136 tune_args.hierarchy = HIER_NONE;
Devin Heitmueller87ad567e2011-10-31 12:24:44 -0300137 break;
138 case HIERARCHY_1:
Mauro Carvalho Chehab1d6207f2014-08-12 18:50:20 -0300139 tune_args.hierarchy = HIER_ALPHA_1;
Devin Heitmueller87ad567e2011-10-31 12:24:44 -0300140 break;
141 case HIERARCHY_2:
Mauro Carvalho Chehab1d6207f2014-08-12 18:50:20 -0300142 tune_args.hierarchy = HIER_ALPHA_2;
Devin Heitmueller87ad567e2011-10-31 12:24:44 -0300143 break;
144 case HIERARCHY_4:
Mauro Carvalho Chehab1d6207f2014-08-12 18:50:20 -0300145 tune_args.hierarchy = HIER_ALPHA_4;
Devin Heitmueller87ad567e2011-10-31 12:24:44 -0300146 break;
147 case HIERARCHY_AUTO:
Mauro Carvalho Chehab1d6207f2014-08-12 18:50:20 -0300148 tune_args.hierarchy = HIER_UNKNOWN;
Devin Heitmueller87ad567e2011-10-31 12:24:44 -0300149 break;
Pierrick Hascoet41b44e02011-10-31 12:24:39 -0300150 }
151
Martin Kepplinger2179de62014-08-04 08:13:16 -0300152 pr_debug("as102: tuner parameters: freq: %d bw: 0x%02x gi: 0x%02x\n",
Mauro Carvalho Chehab1d6207f2014-08-12 18:50:20 -0300153 c->frequency,
154 tune_args.bandwidth,
155 tune_args.guard_interval);
Pierrick Hascoet41b44e02011-10-31 12:24:39 -0300156
157 /*
158 * Detect a hierarchy selection
159 * if HP/LP are both set to FEC_NONE, HP will be selected.
160 */
Mauro Carvalho Chehab1d6207f2014-08-12 18:50:20 -0300161 if ((tune_args.hierarchy != HIER_NONE) &&
162 ((c->code_rate_LP == FEC_NONE) ||
163 (c->code_rate_HP == FEC_NONE))) {
Pierrick Hascoet41b44e02011-10-31 12:24:39 -0300164
Mauro Carvalho Chehab1d6207f2014-08-12 18:50:20 -0300165 if (c->code_rate_LP == FEC_NONE) {
166 tune_args.hier_select = HIER_HIGH_PRIORITY;
167 tune_args.code_rate =
168 as102_fe_get_code_rate(c->code_rate_HP);
Pierrick Hascoet41b44e02011-10-31 12:24:39 -0300169 }
170
Mauro Carvalho Chehab1d6207f2014-08-12 18:50:20 -0300171 if (c->code_rate_HP == FEC_NONE) {
172 tune_args.hier_select = HIER_LOW_PRIORITY;
173 tune_args.code_rate =
174 as102_fe_get_code_rate(c->code_rate_LP);
Pierrick Hascoet41b44e02011-10-31 12:24:39 -0300175 }
176
Martin Kepplinger2179de62014-08-04 08:13:16 -0300177 pr_debug("as102: \thierarchy: 0x%02x selected: %s code_rate_%s: 0x%02x\n",
Mauro Carvalho Chehab1d6207f2014-08-12 18:50:20 -0300178 tune_args.hierarchy,
179 tune_args.hier_select == HIER_HIGH_PRIORITY ?
Devin Heitmueller87ad567e2011-10-31 12:24:44 -0300180 "HP" : "LP",
Mauro Carvalho Chehab1d6207f2014-08-12 18:50:20 -0300181 tune_args.hier_select == HIER_HIGH_PRIORITY ?
Devin Heitmueller87ad567e2011-10-31 12:24:44 -0300182 "HP" : "LP",
Mauro Carvalho Chehab1d6207f2014-08-12 18:50:20 -0300183 tune_args.code_rate);
Pierrick Hascoet41b44e02011-10-31 12:24:39 -0300184 } else {
Mauro Carvalho Chehab1d6207f2014-08-12 18:50:20 -0300185 tune_args.code_rate =
186 as102_fe_get_code_rate(c->code_rate_HP);
Pierrick Hascoet41b44e02011-10-31 12:24:39 -0300187 }
Mauro Carvalho Chehabb601d9a2014-08-12 18:50:19 -0300188
Mauro Carvalho Chehab1d6207f2014-08-12 18:50:20 -0300189 /* Set frontend arguments */
Mauro Carvalho Chehab47f79122014-08-12 18:50:22 -0300190 return state->ops->set_tune(state->priv, &tune_args);
Mauro Carvalho Chehabb601d9a2014-08-12 18:50:19 -0300191}
192
Mauro Carvalho Chehab7e3e68b2016-02-04 12:58:30 -0200193static int as102_fe_get_frontend(struct dvb_frontend *fe,
194 struct dtv_frontend_properties *c)
Mauro Carvalho Chehabb601d9a2014-08-12 18:50:19 -0300195{
196 struct as102_state *state = fe->demodulator_priv;
Mauro Carvalho Chehabb601d9a2014-08-12 18:50:19 -0300197 int ret = 0;
198 struct as10x_tps tps = { 0 };
199
Mauro Carvalho Chehabb601d9a2014-08-12 18:50:19 -0300200 /* send abilis command: GET_TPS */
Mauro Carvalho Chehab47f79122014-08-12 18:50:22 -0300201 ret = state->ops->get_tps(state->priv, &tps);
Mauro Carvalho Chehabc098c2192014-08-12 18:50:21 -0300202 if (ret < 0)
203 return ret;
204
205 /* extract constellation */
206 switch (tps.modulation) {
207 case CONST_QPSK:
208 c->modulation = QPSK;
209 break;
210 case CONST_QAM16:
211 c->modulation = QAM_16;
212 break;
213 case CONST_QAM64:
214 c->modulation = QAM_64;
215 break;
216 }
217
218 /* extract hierarchy */
219 switch (tps.hierarchy) {
220 case HIER_NONE:
221 c->hierarchy = HIERARCHY_NONE;
222 break;
223 case HIER_ALPHA_1:
224 c->hierarchy = HIERARCHY_1;
225 break;
226 case HIER_ALPHA_2:
227 c->hierarchy = HIERARCHY_2;
228 break;
229 case HIER_ALPHA_4:
230 c->hierarchy = HIERARCHY_4;
231 break;
232 }
233
234 /* extract code rate HP */
235 switch (tps.code_rate_HP) {
236 case CODE_RATE_1_2:
237 c->code_rate_HP = FEC_1_2;
238 break;
239 case CODE_RATE_2_3:
240 c->code_rate_HP = FEC_2_3;
241 break;
242 case CODE_RATE_3_4:
243 c->code_rate_HP = FEC_3_4;
244 break;
245 case CODE_RATE_5_6:
246 c->code_rate_HP = FEC_5_6;
247 break;
248 case CODE_RATE_7_8:
249 c->code_rate_HP = FEC_7_8;
250 break;
251 }
252
253 /* extract code rate LP */
254 switch (tps.code_rate_LP) {
255 case CODE_RATE_1_2:
256 c->code_rate_LP = FEC_1_2;
257 break;
258 case CODE_RATE_2_3:
259 c->code_rate_LP = FEC_2_3;
260 break;
261 case CODE_RATE_3_4:
262 c->code_rate_LP = FEC_3_4;
263 break;
264 case CODE_RATE_5_6:
265 c->code_rate_LP = FEC_5_6;
266 break;
267 case CODE_RATE_7_8:
268 c->code_rate_LP = FEC_7_8;
269 break;
270 }
271
272 /* extract guard interval */
273 switch (tps.guard_interval) {
274 case GUARD_INT_1_32:
275 c->guard_interval = GUARD_INTERVAL_1_32;
276 break;
277 case GUARD_INT_1_16:
278 c->guard_interval = GUARD_INTERVAL_1_16;
279 break;
280 case GUARD_INT_1_8:
281 c->guard_interval = GUARD_INTERVAL_1_8;
282 break;
283 case GUARD_INT_1_4:
284 c->guard_interval = GUARD_INTERVAL_1_4;
285 break;
286 }
287
288 /* extract transmission mode */
289 switch (tps.transmission_mode) {
290 case TRANS_MODE_2K:
291 c->transmission_mode = TRANSMISSION_MODE_2K;
292 break;
293 case TRANS_MODE_8K:
294 c->transmission_mode = TRANSMISSION_MODE_8K;
295 break;
296 }
297
298 return 0;
Mauro Carvalho Chehabb601d9a2014-08-12 18:50:19 -0300299}
300
301static int as102_fe_get_tune_settings(struct dvb_frontend *fe,
302 struct dvb_frontend_tune_settings *settings) {
303
304 settings->min_delay_ms = 1000;
305
306 return 0;
307}
308
Mauro Carvalho Chehab0df289a2015-06-07 14:53:52 -0300309static int as102_fe_read_status(struct dvb_frontend *fe, enum fe_status *status)
Mauro Carvalho Chehabb601d9a2014-08-12 18:50:19 -0300310{
311 int ret = 0;
312 struct as102_state *state = fe->demodulator_priv;
313 struct as10x_tune_status tstate = { 0 };
314
Mauro Carvalho Chehabb601d9a2014-08-12 18:50:19 -0300315 /* send abilis command: GET_TUNE_STATUS */
Mauro Carvalho Chehab47f79122014-08-12 18:50:22 -0300316 ret = state->ops->get_status(state->priv, &tstate);
317 if (ret < 0)
318 return ret;
Mauro Carvalho Chehabb601d9a2014-08-12 18:50:19 -0300319
320 state->signal_strength = tstate.signal_strength;
321 state->ber = tstate.BER;
322
323 switch (tstate.tune_state) {
324 case TUNE_STATUS_SIGNAL_DVB_OK:
325 *status = FE_HAS_SIGNAL | FE_HAS_CARRIER;
326 break;
327 case TUNE_STATUS_STREAM_DETECTED:
Mauro Carvalho Chehab4628f992014-08-12 18:50:24 -0300328 *status = FE_HAS_SIGNAL | FE_HAS_CARRIER | FE_HAS_SYNC |
329 FE_HAS_VITERBI;
Mauro Carvalho Chehabb601d9a2014-08-12 18:50:19 -0300330 break;
331 case TUNE_STATUS_STREAM_TUNED:
332 *status = FE_HAS_SIGNAL | FE_HAS_CARRIER | FE_HAS_SYNC |
Mauro Carvalho Chehab4628f992014-08-12 18:50:24 -0300333 FE_HAS_LOCK | FE_HAS_VITERBI;
Mauro Carvalho Chehabb601d9a2014-08-12 18:50:19 -0300334 break;
335 default:
336 *status = TUNE_STATUS_NOT_TUNED;
337 }
338
Mauro Carvalho Chehab47f79122014-08-12 18:50:22 -0300339 pr_debug("as102: tuner status: 0x%02x, strength %d, per: %d, ber: %d\n",
340 tstate.tune_state, tstate.signal_strength,
341 tstate.PER, tstate.BER);
Mauro Carvalho Chehabb601d9a2014-08-12 18:50:19 -0300342
Mauro Carvalho Chehab47f79122014-08-12 18:50:22 -0300343 if (!(*status & FE_HAS_LOCK)) {
Mauro Carvalho Chehabb601d9a2014-08-12 18:50:19 -0300344 memset(&state->demod_stats, 0, sizeof(state->demod_stats));
Mauro Carvalho Chehab47f79122014-08-12 18:50:22 -0300345 return 0;
Mauro Carvalho Chehabb601d9a2014-08-12 18:50:19 -0300346 }
347
Mauro Carvalho Chehab47f79122014-08-12 18:50:22 -0300348 ret = state->ops->get_stats(state->priv, &state->demod_stats);
349 if (ret < 0)
350 memset(&state->demod_stats, 0, sizeof(state->demod_stats));
351
Mauro Carvalho Chehabb601d9a2014-08-12 18:50:19 -0300352 return ret;
353}
354
355/*
356 * Note:
357 * - in AS102 SNR=MER
358 * - the SNR will be returned in linear terms, i.e. not in dB
359 * - the accuracy equals ±2dB for a SNR range from 4dB to 30dB
360 * - the accuracy is >2dB for SNR values outside this range
361 */
362static int as102_fe_read_snr(struct dvb_frontend *fe, u16 *snr)
363{
364 struct as102_state *state = fe->demodulator_priv;
365
366 *snr = state->demod_stats.mer;
367
368 return 0;
369}
370
371static int as102_fe_read_ber(struct dvb_frontend *fe, u32 *ber)
372{
373 struct as102_state *state = fe->demodulator_priv;
374
375 *ber = state->ber;
376
377 return 0;
378}
379
380static int as102_fe_read_signal_strength(struct dvb_frontend *fe,
381 u16 *strength)
382{
383 struct as102_state *state = fe->demodulator_priv;
384
385 *strength = (((0xffff * 400) * state->signal_strength + 41000) * 2);
386
387 return 0;
388}
389
390static int as102_fe_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks)
391{
392 struct as102_state *state = fe->demodulator_priv;
393
394 if (state->demod_stats.has_started)
395 *ucblocks = state->demod_stats.bad_frame_count;
396 else
397 *ucblocks = 0;
398
399 return 0;
400}
401
402static int as102_fe_ts_bus_ctrl(struct dvb_frontend *fe, int acquire)
403{
404 struct as102_state *state = fe->demodulator_priv;
Mauro Carvalho Chehabb601d9a2014-08-12 18:50:19 -0300405
Mauro Carvalho Chehab47f79122014-08-12 18:50:22 -0300406 return state->ops->stream_ctrl(state->priv, acquire,
407 state->elna_cfg);
Mauro Carvalho Chehabb601d9a2014-08-12 18:50:19 -0300408}
409
Mauro Carvalho Chehab5b6aa192014-08-12 21:35:44 -0300410static void as102_fe_release(struct dvb_frontend *fe)
411{
412 struct as102_state *state = fe->demodulator_priv;
413
414 kfree(state);
415}
416
417
Mauro Carvalho Chehabb601d9a2014-08-12 18:50:19 -0300418static struct dvb_frontend_ops as102_fe_ops = {
419 .delsys = { SYS_DVBT },
420 .info = {
421 .name = "Abilis AS102 DVB-T",
422 .frequency_min = 174000000,
423 .frequency_max = 862000000,
424 .frequency_stepsize = 166667,
425 .caps = FE_CAN_INVERSION_AUTO
426 | FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4
427 | FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO
428 | FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QPSK
429 | FE_CAN_QAM_AUTO
430 | FE_CAN_TRANSMISSION_MODE_AUTO
431 | FE_CAN_GUARD_INTERVAL_AUTO
432 | FE_CAN_HIERARCHY_AUTO
433 | FE_CAN_RECOVER
434 | FE_CAN_MUTE_TS
435 },
436
437 .set_frontend = as102_fe_set_frontend,
438 .get_frontend = as102_fe_get_frontend,
439 .get_tune_settings = as102_fe_get_tune_settings,
440
441 .read_status = as102_fe_read_status,
442 .read_snr = as102_fe_read_snr,
443 .read_ber = as102_fe_read_ber,
444 .read_signal_strength = as102_fe_read_signal_strength,
445 .read_ucblocks = as102_fe_read_ucblocks,
446 .ts_bus_ctrl = as102_fe_ts_bus_ctrl,
Mauro Carvalho Chehab5b6aa192014-08-12 21:35:44 -0300447 .release = as102_fe_release,
Mauro Carvalho Chehabb601d9a2014-08-12 18:50:19 -0300448};
449
450struct dvb_frontend *as102_attach(const char *name,
Mauro Carvalho Chehab47f79122014-08-12 18:50:22 -0300451 const struct as102_fe_ops *ops,
452 void *priv,
Mauro Carvalho Chehabb601d9a2014-08-12 18:50:19 -0300453 uint8_t elna_cfg)
454{
455 struct as102_state *state;
456 struct dvb_frontend *fe;
457
458 state = kzalloc(sizeof(struct as102_state), GFP_KERNEL);
459 if (state == NULL) {
Mauro Carvalho Chehab47f79122014-08-12 18:50:22 -0300460 pr_err("%s: unable to allocate memory for state\n", __func__);
Mauro Carvalho Chehabb601d9a2014-08-12 18:50:19 -0300461 return NULL;
462 }
463 fe = &state->frontend;
464 fe->demodulator_priv = state;
Mauro Carvalho Chehab47f79122014-08-12 18:50:22 -0300465 state->ops = ops;
466 state->priv = priv;
Mauro Carvalho Chehabb601d9a2014-08-12 18:50:19 -0300467 state->elna_cfg = elna_cfg;
468
469 /* init frontend callback ops */
470 memcpy(&fe->ops, &as102_fe_ops, sizeof(struct dvb_frontend_ops));
471 strncpy(fe->ops.info.name, name, sizeof(fe->ops.info.name));
472
473 return fe;
474
475}
476EXPORT_SYMBOL_GPL(as102_attach);
Mauro Carvalho Chehabdcae7782014-08-12 18:50:23 -0300477
478MODULE_DESCRIPTION("as102-fe");
479MODULE_LICENSE("GPL");
480MODULE_AUTHOR("Pierrick Hascoet <pierrick.hascoet@abilis.com>");