Alan Nisota | 9bbe076 | 2006-05-14 13:23:56 -0300 | [diff] [blame] | 1 | /* DVB USB compliant Linux driver for the |
Alan Nisota | 458b634 | 2007-08-18 17:52:35 -0300 | [diff] [blame] | 2 | * - GENPIX 8pks/qpsk/DCII USB2.0 DVB-S module |
Alan Nisota | 9bbe076 | 2006-05-14 13:23:56 -0300 | [diff] [blame] | 3 | * |
Alan Nisota | 458b634 | 2007-08-18 17:52:35 -0300 | [diff] [blame] | 4 | * Copyright (C) 2006,2007 Alan Nisota (alannisota@gmail.com) |
| 5 | * Copyright (C) 2006,2007 Genpix Electronics (genpix@genpix-electronics.com) |
Alan Nisota | 9bbe076 | 2006-05-14 13:23:56 -0300 | [diff] [blame] | 6 | * |
| 7 | * Thanks to GENPIX for the sample code used to implement this module. |
| 8 | * |
| 9 | * This module is based off the vp7045 and vp702x modules |
| 10 | * |
| 11 | * This program is free software; you can redistribute it and/or modify it |
| 12 | * under the terms of the GNU General Public License as published by the Free |
| 13 | * Software Foundation, version 2. |
| 14 | * |
| 15 | * see Documentation/dvb/README.dvb-usb for more information |
| 16 | */ |
Mauro Carvalho Chehab | 7a0786c | 2016-11-12 12:46:28 -0200 | [diff] [blame^] | 17 | |
| 18 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 19 | |
| 20 | #include "gp8psk-fe.h" |
| 21 | #include "dvb_frontend.h" |
| 22 | |
| 23 | static int debug; |
| 24 | module_param(debug, int, 0644); |
| 25 | MODULE_PARM_DESC(debug, "Turn on/off debugging (default:off)."); |
| 26 | |
| 27 | #define dprintk(fmt, arg...) do { \ |
| 28 | if (debug) \ |
| 29 | printk(KERN_DEBUG pr_fmt("%s: " fmt), \ |
| 30 | __func__, ##arg); \ |
| 31 | } while (0) |
Alan Nisota | 9bbe076 | 2006-05-14 13:23:56 -0300 | [diff] [blame] | 32 | |
| 33 | struct gp8psk_fe_state { |
| 34 | struct dvb_frontend fe; |
Mauro Carvalho Chehab | 7a0786c | 2016-11-12 12:46:28 -0200 | [diff] [blame^] | 35 | void *priv; |
| 36 | const struct gp8psk_fe_ops *ops; |
| 37 | bool is_rev1; |
Alan Nisota | 458b634 | 2007-08-18 17:52:35 -0300 | [diff] [blame] | 38 | u8 lock; |
Alan Nisota | 9bbe076 | 2006-05-14 13:23:56 -0300 | [diff] [blame] | 39 | u16 snr; |
Alan Nisota | 458b634 | 2007-08-18 17:52:35 -0300 | [diff] [blame] | 40 | unsigned long next_status_check; |
| 41 | unsigned long status_check_interval; |
Alan Nisota | 9bbe076 | 2006-05-14 13:23:56 -0300 | [diff] [blame] | 42 | }; |
| 43 | |
Alan Nisota | 02ebf23 | 2008-12-20 12:03:06 -0300 | [diff] [blame] | 44 | static int gp8psk_tuned_to_DCII(struct dvb_frontend *fe) |
| 45 | { |
| 46 | struct gp8psk_fe_state *st = fe->demodulator_priv; |
| 47 | u8 status; |
Mauro Carvalho Chehab | 7a0786c | 2016-11-12 12:46:28 -0200 | [diff] [blame^] | 48 | |
| 49 | st->ops->in(st->priv, GET_8PSK_CONFIG, 0, 0, &status, 1); |
Alan Nisota | 02ebf23 | 2008-12-20 12:03:06 -0300 | [diff] [blame] | 50 | return status & bmDCtuned; |
| 51 | } |
| 52 | |
| 53 | static int gp8psk_set_tuner_mode(struct dvb_frontend *fe, int mode) |
| 54 | { |
Mauro Carvalho Chehab | 7a0786c | 2016-11-12 12:46:28 -0200 | [diff] [blame^] | 55 | struct gp8psk_fe_state *st = fe->demodulator_priv; |
| 56 | |
| 57 | return st->ops->out(st->priv, SET_8PSK_CONFIG, mode, 0, NULL, 0); |
Alan Nisota | 02ebf23 | 2008-12-20 12:03:06 -0300 | [diff] [blame] | 58 | } |
| 59 | |
Alan Nisota | 458b634 | 2007-08-18 17:52:35 -0300 | [diff] [blame] | 60 | static int gp8psk_fe_update_status(struct gp8psk_fe_state *st) |
| 61 | { |
| 62 | u8 buf[6]; |
| 63 | if (time_after(jiffies,st->next_status_check)) { |
Mauro Carvalho Chehab | 7a0786c | 2016-11-12 12:46:28 -0200 | [diff] [blame^] | 64 | st->ops->in(st->priv, GET_SIGNAL_LOCK, 0, 0, &st->lock, 1); |
| 65 | st->ops->in(st->priv, GET_SIGNAL_STRENGTH, 0, 0, buf, 6); |
Alan Nisota | 458b634 | 2007-08-18 17:52:35 -0300 | [diff] [blame] | 66 | st->snr = (buf[1]) << 8 | buf[0]; |
| 67 | st->next_status_check = jiffies + (st->status_check_interval*HZ)/1000; |
| 68 | } |
| 69 | return 0; |
| 70 | } |
| 71 | |
Mauro Carvalho Chehab | 0df289a | 2015-06-07 14:53:52 -0300 | [diff] [blame] | 72 | static int gp8psk_fe_read_status(struct dvb_frontend *fe, |
| 73 | enum fe_status *status) |
Alan Nisota | 9bbe076 | 2006-05-14 13:23:56 -0300 | [diff] [blame] | 74 | { |
| 75 | struct gp8psk_fe_state *st = fe->demodulator_priv; |
Alan Nisota | 458b634 | 2007-08-18 17:52:35 -0300 | [diff] [blame] | 76 | gp8psk_fe_update_status(st); |
Alan Nisota | 9bbe076 | 2006-05-14 13:23:56 -0300 | [diff] [blame] | 77 | |
Alan Nisota | 458b634 | 2007-08-18 17:52:35 -0300 | [diff] [blame] | 78 | if (st->lock) |
Alan Nisota | 9bbe076 | 2006-05-14 13:23:56 -0300 | [diff] [blame] | 79 | *status = FE_HAS_LOCK | FE_HAS_SYNC | FE_HAS_VITERBI | FE_HAS_SIGNAL | FE_HAS_CARRIER; |
| 80 | else |
| 81 | *status = 0; |
| 82 | |
Alan Nisota | 458b634 | 2007-08-18 17:52:35 -0300 | [diff] [blame] | 83 | if (*status & FE_HAS_LOCK) |
| 84 | st->status_check_interval = 1000; |
| 85 | else |
| 86 | st->status_check_interval = 100; |
Alan Nisota | 9bbe076 | 2006-05-14 13:23:56 -0300 | [diff] [blame] | 87 | return 0; |
| 88 | } |
| 89 | |
| 90 | /* not supported by this Frontend */ |
| 91 | static int gp8psk_fe_read_ber(struct dvb_frontend* fe, u32 *ber) |
| 92 | { |
| 93 | (void) fe; |
| 94 | *ber = 0; |
| 95 | return 0; |
| 96 | } |
| 97 | |
| 98 | /* not supported by this Frontend */ |
| 99 | static int gp8psk_fe_read_unc_blocks(struct dvb_frontend* fe, u32 *unc) |
| 100 | { |
| 101 | (void) fe; |
| 102 | *unc = 0; |
| 103 | return 0; |
| 104 | } |
| 105 | |
| 106 | static int gp8psk_fe_read_snr(struct dvb_frontend* fe, u16 *snr) |
| 107 | { |
| 108 | struct gp8psk_fe_state *st = fe->demodulator_priv; |
Alan Nisota | 458b634 | 2007-08-18 17:52:35 -0300 | [diff] [blame] | 109 | gp8psk_fe_update_status(st); |
| 110 | /* snr is reported in dBu*256 */ |
| 111 | *snr = st->snr; |
Alan Nisota | 9bbe076 | 2006-05-14 13:23:56 -0300 | [diff] [blame] | 112 | return 0; |
| 113 | } |
| 114 | |
| 115 | static int gp8psk_fe_read_signal_strength(struct dvb_frontend* fe, u16 *strength) |
| 116 | { |
Alan Nisota | 458b634 | 2007-08-18 17:52:35 -0300 | [diff] [blame] | 117 | struct gp8psk_fe_state *st = fe->demodulator_priv; |
| 118 | gp8psk_fe_update_status(st); |
| 119 | /* snr is reported in dBu*256 */ |
| 120 | /* snr / 38.4 ~= 100% strength */ |
| 121 | /* snr * 17 returns 100% strength as 65535 */ |
| 122 | if (st->snr > 0xf00) |
| 123 | *strength = 0xffff; |
| 124 | else |
| 125 | *strength = (st->snr << 4) + st->snr; /* snr*17 */ |
| 126 | return 0; |
Alan Nisota | 9bbe076 | 2006-05-14 13:23:56 -0300 | [diff] [blame] | 127 | } |
| 128 | |
| 129 | static int gp8psk_fe_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings *tune) |
| 130 | { |
Derek Kelly | fb249ca | 2010-10-16 16:07:47 -0300 | [diff] [blame] | 131 | tune->min_delay_ms = 800; |
Alan Nisota | 9bbe076 | 2006-05-14 13:23:56 -0300 | [diff] [blame] | 132 | return 0; |
| 133 | } |
| 134 | |
Mauro Carvalho Chehab | 6e07d5c | 2011-12-26 15:49:16 -0300 | [diff] [blame] | 135 | static int gp8psk_fe_set_frontend(struct dvb_frontend *fe) |
Alan Nisota | 9bbe076 | 2006-05-14 13:23:56 -0300 | [diff] [blame] | 136 | { |
Mauro Carvalho Chehab | 7a0786c | 2016-11-12 12:46:28 -0200 | [diff] [blame^] | 137 | struct gp8psk_fe_state *st = fe->demodulator_priv; |
Alan Nisota | 02ebf23 | 2008-12-20 12:03:06 -0300 | [diff] [blame] | 138 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; |
Alan Nisota | 9bbe076 | 2006-05-14 13:23:56 -0300 | [diff] [blame] | 139 | u8 cmd[10]; |
Mauro Carvalho Chehab | 6e07d5c | 2011-12-26 15:49:16 -0300 | [diff] [blame] | 140 | u32 freq = c->frequency * 1000; |
Alan Nisota | 02ebf23 | 2008-12-20 12:03:06 -0300 | [diff] [blame] | 141 | |
Mauro Carvalho Chehab | 7a0786c | 2016-11-12 12:46:28 -0200 | [diff] [blame^] | 142 | dprintk("%s()\n", __func__); |
Alan Nisota | 9bbe076 | 2006-05-14 13:23:56 -0300 | [diff] [blame] | 143 | |
| 144 | cmd[4] = freq & 0xff; |
| 145 | cmd[5] = (freq >> 8) & 0xff; |
| 146 | cmd[6] = (freq >> 16) & 0xff; |
| 147 | cmd[7] = (freq >> 24) & 0xff; |
| 148 | |
Andreas Oberritter | 8fc74fd | 2011-08-08 11:54:37 -0300 | [diff] [blame] | 149 | /* backwards compatibility: DVB-S + 8-PSK were used for Turbo-FEC */ |
| 150 | if (c->delivery_system == SYS_DVBS && c->modulation == PSK_8) |
| 151 | c->delivery_system = SYS_TURBO; |
| 152 | |
Alan Nisota | 02ebf23 | 2008-12-20 12:03:06 -0300 | [diff] [blame] | 153 | switch (c->delivery_system) { |
| 154 | case SYS_DVBS: |
Andreas Oberritter | 8fc74fd | 2011-08-08 11:54:37 -0300 | [diff] [blame] | 155 | if (c->modulation != QPSK) { |
Mauro Carvalho Chehab | 7a0786c | 2016-11-12 12:46:28 -0200 | [diff] [blame^] | 156 | dprintk("%s: unsupported modulation selected (%d)\n", |
Alan Nisota | 02ebf23 | 2008-12-20 12:03:06 -0300 | [diff] [blame] | 157 | __func__, c->modulation); |
| 158 | return -EOPNOTSUPP; |
| 159 | } |
| 160 | c->fec_inner = FEC_AUTO; |
Alan Nisota | 9bbe076 | 2006-05-14 13:23:56 -0300 | [diff] [blame] | 161 | break; |
Andreas Oberritter | 8fc74fd | 2011-08-08 11:54:37 -0300 | [diff] [blame] | 162 | case SYS_DVBS2: /* kept for backwards compatibility */ |
Mauro Carvalho Chehab | 7a0786c | 2016-11-12 12:46:28 -0200 | [diff] [blame^] | 163 | dprintk("%s: DVB-S2 delivery system selected\n", __func__); |
Alan Nisota | 02ebf23 | 2008-12-20 12:03:06 -0300 | [diff] [blame] | 164 | break; |
Andreas Oberritter | 8fc74fd | 2011-08-08 11:54:37 -0300 | [diff] [blame] | 165 | case SYS_TURBO: |
Mauro Carvalho Chehab | 7a0786c | 2016-11-12 12:46:28 -0200 | [diff] [blame^] | 166 | dprintk("%s: Turbo-FEC delivery system selected\n", __func__); |
Andreas Oberritter | 8fc74fd | 2011-08-08 11:54:37 -0300 | [diff] [blame] | 167 | break; |
Alan Nisota | 02ebf23 | 2008-12-20 12:03:06 -0300 | [diff] [blame] | 168 | |
Alan Nisota | 9bbe076 | 2006-05-14 13:23:56 -0300 | [diff] [blame] | 169 | default: |
Mauro Carvalho Chehab | 7a0786c | 2016-11-12 12:46:28 -0200 | [diff] [blame^] | 170 | dprintk("%s: unsupported delivery system selected (%d)\n", |
Alan Nisota | 02ebf23 | 2008-12-20 12:03:06 -0300 | [diff] [blame] | 171 | __func__, c->delivery_system); |
| 172 | return -EOPNOTSUPP; |
Alan Nisota | 9bbe076 | 2006-05-14 13:23:56 -0300 | [diff] [blame] | 173 | } |
| 174 | |
Alan Nisota | 02ebf23 | 2008-12-20 12:03:06 -0300 | [diff] [blame] | 175 | cmd[0] = c->symbol_rate & 0xff; |
| 176 | cmd[1] = (c->symbol_rate >> 8) & 0xff; |
| 177 | cmd[2] = (c->symbol_rate >> 16) & 0xff; |
| 178 | cmd[3] = (c->symbol_rate >> 24) & 0xff; |
| 179 | switch (c->modulation) { |
| 180 | case QPSK: |
Mauro Carvalho Chehab | 7a0786c | 2016-11-12 12:46:28 -0200 | [diff] [blame^] | 181 | if (st->is_rev1) |
Alan Nisota | 02ebf23 | 2008-12-20 12:03:06 -0300 | [diff] [blame] | 182 | if (gp8psk_tuned_to_DCII(fe)) |
Mauro Carvalho Chehab | 7a0786c | 2016-11-12 12:46:28 -0200 | [diff] [blame^] | 183 | st->ops->reload(st->priv); |
Alan Nisota | 02ebf23 | 2008-12-20 12:03:06 -0300 | [diff] [blame] | 184 | switch (c->fec_inner) { |
| 185 | case FEC_1_2: |
| 186 | cmd[9] = 0; break; |
| 187 | case FEC_2_3: |
| 188 | cmd[9] = 1; break; |
| 189 | case FEC_3_4: |
| 190 | cmd[9] = 2; break; |
| 191 | case FEC_5_6: |
| 192 | cmd[9] = 3; break; |
| 193 | case FEC_7_8: |
| 194 | cmd[9] = 4; break; |
| 195 | case FEC_AUTO: |
| 196 | cmd[9] = 5; break; |
| 197 | default: |
| 198 | cmd[9] = 5; break; |
| 199 | } |
Andreas Oberritter | 8fc74fd | 2011-08-08 11:54:37 -0300 | [diff] [blame] | 200 | if (c->delivery_system == SYS_TURBO) |
| 201 | cmd[8] = ADV_MOD_TURBO_QPSK; |
| 202 | else |
| 203 | cmd[8] = ADV_MOD_DVB_QPSK; |
Alan Nisota | 02ebf23 | 2008-12-20 12:03:06 -0300 | [diff] [blame] | 204 | break; |
| 205 | case PSK_8: /* PSK_8 is for compatibility with DN */ |
| 206 | cmd[8] = ADV_MOD_TURBO_8PSK; |
| 207 | switch (c->fec_inner) { |
| 208 | case FEC_2_3: |
| 209 | cmd[9] = 0; break; |
| 210 | case FEC_3_4: |
| 211 | cmd[9] = 1; break; |
| 212 | case FEC_3_5: |
| 213 | cmd[9] = 2; break; |
| 214 | case FEC_5_6: |
| 215 | cmd[9] = 3; break; |
| 216 | case FEC_8_9: |
| 217 | cmd[9] = 4; break; |
| 218 | default: |
| 219 | cmd[9] = 0; break; |
| 220 | } |
| 221 | break; |
| 222 | case QAM_16: /* QAM_16 is for compatibility with DN */ |
| 223 | cmd[8] = ADV_MOD_TURBO_16QAM; |
| 224 | cmd[9] = 0; |
| 225 | break; |
| 226 | default: /* Unknown modulation */ |
Mauro Carvalho Chehab | 7a0786c | 2016-11-12 12:46:28 -0200 | [diff] [blame^] | 227 | dprintk("%s: unsupported modulation selected (%d)\n", |
Alan Nisota | 02ebf23 | 2008-12-20 12:03:06 -0300 | [diff] [blame] | 228 | __func__, c->modulation); |
| 229 | return -EOPNOTSUPP; |
| 230 | } |
| 231 | |
Mauro Carvalho Chehab | 7a0786c | 2016-11-12 12:46:28 -0200 | [diff] [blame^] | 232 | if (st->is_rev1) |
Alan Nisota | 02ebf23 | 2008-12-20 12:03:06 -0300 | [diff] [blame] | 233 | gp8psk_set_tuner_mode(fe, 0); |
Mauro Carvalho Chehab | 7a0786c | 2016-11-12 12:46:28 -0200 | [diff] [blame^] | 234 | st->ops->out(st->priv, TUNE_8PSK, 0, 0, cmd, 10); |
Alan Nisota | 9bbe076 | 2006-05-14 13:23:56 -0300 | [diff] [blame] | 235 | |
Mauro Carvalho Chehab | 7a0786c | 2016-11-12 12:46:28 -0200 | [diff] [blame^] | 236 | st->lock = 0; |
| 237 | st->next_status_check = jiffies; |
| 238 | st->status_check_interval = 200; |
Alan Nisota | 9bbe076 | 2006-05-14 13:23:56 -0300 | [diff] [blame] | 239 | |
| 240 | return 0; |
| 241 | } |
| 242 | |
Alan Nisota | 9bbe076 | 2006-05-14 13:23:56 -0300 | [diff] [blame] | 243 | static int gp8psk_fe_send_diseqc_msg (struct dvb_frontend* fe, |
| 244 | struct dvb_diseqc_master_cmd *m) |
| 245 | { |
| 246 | struct gp8psk_fe_state *st = fe->demodulator_priv; |
| 247 | |
Mauro Carvalho Chehab | 7a0786c | 2016-11-12 12:46:28 -0200 | [diff] [blame^] | 248 | dprintk("%s\n", __func__); |
Alan Nisota | 9bbe076 | 2006-05-14 13:23:56 -0300 | [diff] [blame] | 249 | |
Mauro Carvalho Chehab | 7a0786c | 2016-11-12 12:46:28 -0200 | [diff] [blame^] | 250 | if (st->ops->out(st->priv, SEND_DISEQC_COMMAND, m->msg[0], 0, |
Alan Nisota | 9bbe076 | 2006-05-14 13:23:56 -0300 | [diff] [blame] | 251 | m->msg, m->msg_len)) { |
| 252 | return -EINVAL; |
| 253 | } |
| 254 | return 0; |
| 255 | } |
| 256 | |
Mauro Carvalho Chehab | 0df289a | 2015-06-07 14:53:52 -0300 | [diff] [blame] | 257 | static int gp8psk_fe_send_diseqc_burst(struct dvb_frontend *fe, |
| 258 | enum fe_sec_mini_cmd burst) |
Alan Nisota | 9bbe076 | 2006-05-14 13:23:56 -0300 | [diff] [blame] | 259 | { |
| 260 | struct gp8psk_fe_state *st = fe->demodulator_priv; |
| 261 | u8 cmd; |
| 262 | |
Mauro Carvalho Chehab | 7a0786c | 2016-11-12 12:46:28 -0200 | [diff] [blame^] | 263 | dprintk("%s\n", __func__); |
Alan Nisota | 9bbe076 | 2006-05-14 13:23:56 -0300 | [diff] [blame] | 264 | |
| 265 | /* These commands are certainly wrong */ |
| 266 | cmd = (burst == SEC_MINI_A) ? 0x00 : 0x01; |
| 267 | |
Mauro Carvalho Chehab | 7a0786c | 2016-11-12 12:46:28 -0200 | [diff] [blame^] | 268 | if (st->ops->out(st->priv, SEND_DISEQC_COMMAND, cmd, 0, |
Alan Nisota | 9bbe076 | 2006-05-14 13:23:56 -0300 | [diff] [blame] | 269 | &cmd, 0)) { |
| 270 | return -EINVAL; |
| 271 | } |
| 272 | return 0; |
| 273 | } |
| 274 | |
Mauro Carvalho Chehab | 0df289a | 2015-06-07 14:53:52 -0300 | [diff] [blame] | 275 | static int gp8psk_fe_set_tone(struct dvb_frontend *fe, |
| 276 | enum fe_sec_tone_mode tone) |
Alan Nisota | 9bbe076 | 2006-05-14 13:23:56 -0300 | [diff] [blame] | 277 | { |
Mauro Carvalho Chehab | 7a0786c | 2016-11-12 12:46:28 -0200 | [diff] [blame^] | 278 | struct gp8psk_fe_state *st = fe->demodulator_priv; |
Alan Nisota | 9bbe076 | 2006-05-14 13:23:56 -0300 | [diff] [blame] | 279 | |
Mauro Carvalho Chehab | 7a0786c | 2016-11-12 12:46:28 -0200 | [diff] [blame^] | 280 | if (st->ops->out(st->priv, SET_22KHZ_TONE, |
| 281 | (tone == SEC_TONE_ON), 0, NULL, 0)) { |
Alan Nisota | 9bbe076 | 2006-05-14 13:23:56 -0300 | [diff] [blame] | 282 | return -EINVAL; |
| 283 | } |
| 284 | return 0; |
| 285 | } |
| 286 | |
Mauro Carvalho Chehab | 0df289a | 2015-06-07 14:53:52 -0300 | [diff] [blame] | 287 | static int gp8psk_fe_set_voltage(struct dvb_frontend *fe, |
| 288 | enum fe_sec_voltage voltage) |
Alan Nisota | 9bbe076 | 2006-05-14 13:23:56 -0300 | [diff] [blame] | 289 | { |
Mauro Carvalho Chehab | 7a0786c | 2016-11-12 12:46:28 -0200 | [diff] [blame^] | 290 | struct gp8psk_fe_state *st = fe->demodulator_priv; |
Alan Nisota | 9bbe076 | 2006-05-14 13:23:56 -0300 | [diff] [blame] | 291 | |
Mauro Carvalho Chehab | 7a0786c | 2016-11-12 12:46:28 -0200 | [diff] [blame^] | 292 | if (st->ops->out(st->priv, SET_LNB_VOLTAGE, |
Alan Nisota | 9bbe076 | 2006-05-14 13:23:56 -0300 | [diff] [blame] | 293 | voltage == SEC_VOLTAGE_18, 0, NULL, 0)) { |
| 294 | return -EINVAL; |
| 295 | } |
| 296 | return 0; |
| 297 | } |
| 298 | |
Alan Nisota | 458b634 | 2007-08-18 17:52:35 -0300 | [diff] [blame] | 299 | static int gp8psk_fe_enable_high_lnb_voltage(struct dvb_frontend* fe, long onoff) |
| 300 | { |
Mauro Carvalho Chehab | 7a0786c | 2016-11-12 12:46:28 -0200 | [diff] [blame^] | 301 | struct gp8psk_fe_state *st = fe->demodulator_priv; |
| 302 | |
| 303 | return st->ops->out(st->priv, USE_EXTRA_VOLT, onoff, 0, NULL, 0); |
Alan Nisota | 458b634 | 2007-08-18 17:52:35 -0300 | [diff] [blame] | 304 | } |
| 305 | |
Alan Nisota | 9bbe076 | 2006-05-14 13:23:56 -0300 | [diff] [blame] | 306 | static int gp8psk_fe_send_legacy_dish_cmd (struct dvb_frontend* fe, unsigned long sw_cmd) |
| 307 | { |
Mauro Carvalho Chehab | 7a0786c | 2016-11-12 12:46:28 -0200 | [diff] [blame^] | 308 | struct gp8psk_fe_state *st = fe->demodulator_priv; |
Alan Nisota | 9bbe076 | 2006-05-14 13:23:56 -0300 | [diff] [blame] | 309 | u8 cmd = sw_cmd & 0x7f; |
| 310 | |
Mauro Carvalho Chehab | 7a0786c | 2016-11-12 12:46:28 -0200 | [diff] [blame^] | 311 | if (st->ops->out(st->priv, SET_DN_SWITCH, cmd, 0, NULL, 0)) |
Alan Nisota | 9bbe076 | 2006-05-14 13:23:56 -0300 | [diff] [blame] | 312 | return -EINVAL; |
Mauro Carvalho Chehab | 7a0786c | 2016-11-12 12:46:28 -0200 | [diff] [blame^] | 313 | |
| 314 | if (st->ops->out(st->priv, SET_LNB_VOLTAGE, !!(sw_cmd & 0x80), |
| 315 | 0, NULL, 0)) |
Alan Nisota | 9bbe076 | 2006-05-14 13:23:56 -0300 | [diff] [blame] | 316 | return -EINVAL; |
Alan Nisota | 9bbe076 | 2006-05-14 13:23:56 -0300 | [diff] [blame] | 317 | |
| 318 | return 0; |
| 319 | } |
| 320 | |
| 321 | static void gp8psk_fe_release(struct dvb_frontend* fe) |
| 322 | { |
Mauro Carvalho Chehab | 7a0786c | 2016-11-12 12:46:28 -0200 | [diff] [blame^] | 323 | struct gp8psk_fe_state *st = fe->demodulator_priv; |
| 324 | |
| 325 | kfree(st); |
Alan Nisota | 9bbe076 | 2006-05-14 13:23:56 -0300 | [diff] [blame] | 326 | } |
| 327 | |
| 328 | static struct dvb_frontend_ops gp8psk_fe_ops; |
| 329 | |
Mauro Carvalho Chehab | 7a0786c | 2016-11-12 12:46:28 -0200 | [diff] [blame^] | 330 | struct dvb_frontend *gp8psk_fe_attach(const struct gp8psk_fe_ops *ops, |
| 331 | void *priv, bool is_rev1) |
Alan Nisota | 9bbe076 | 2006-05-14 13:23:56 -0300 | [diff] [blame] | 332 | { |
Mauro Carvalho Chehab | 7a0786c | 2016-11-12 12:46:28 -0200 | [diff] [blame^] | 333 | struct gp8psk_fe_state *st; |
Alan Nisota | 9bbe076 | 2006-05-14 13:23:56 -0300 | [diff] [blame] | 334 | |
Mauro Carvalho Chehab | 7a0786c | 2016-11-12 12:46:28 -0200 | [diff] [blame^] | 335 | if (!ops || !ops->in || !ops->out || !ops->reload) { |
| 336 | pr_err("Error! gp8psk-fe ops not defined.\n"); |
| 337 | return NULL; |
| 338 | } |
Alan Nisota | 9bbe076 | 2006-05-14 13:23:56 -0300 | [diff] [blame] | 339 | |
Mauro Carvalho Chehab | 7a0786c | 2016-11-12 12:46:28 -0200 | [diff] [blame^] | 340 | st = kzalloc(sizeof(struct gp8psk_fe_state), GFP_KERNEL); |
| 341 | if (!st) |
| 342 | return NULL; |
| 343 | |
| 344 | memcpy(&st->fe.ops, &gp8psk_fe_ops, sizeof(struct dvb_frontend_ops)); |
| 345 | st->fe.demodulator_priv = st; |
| 346 | st->ops = ops; |
| 347 | st->priv = priv; |
| 348 | st->is_rev1 = is_rev1; |
| 349 | |
| 350 | pr_info("Frontend %sattached\n", is_rev1 ? "revision 1 " : ""); |
| 351 | |
| 352 | return &st->fe; |
Alan Nisota | 9bbe076 | 2006-05-14 13:23:56 -0300 | [diff] [blame] | 353 | } |
Mauro Carvalho Chehab | 7a0786c | 2016-11-12 12:46:28 -0200 | [diff] [blame^] | 354 | EXPORT_SYMBOL_GPL(gp8psk_fe_attach); |
Alan Nisota | 9bbe076 | 2006-05-14 13:23:56 -0300 | [diff] [blame] | 355 | |
| 356 | static struct dvb_frontend_ops gp8psk_fe_ops = { |
Mauro Carvalho Chehab | 6e07d5c | 2011-12-26 15:49:16 -0300 | [diff] [blame] | 357 | .delsys = { SYS_DVBS }, |
Alan Nisota | 9bbe076 | 2006-05-14 13:23:56 -0300 | [diff] [blame] | 358 | .info = { |
Derek Kelly | d12da8e | 2010-10-16 16:18:15 -0300 | [diff] [blame] | 359 | .name = "Genpix DVB-S", |
Alan Nisota | 458b634 | 2007-08-18 17:52:35 -0300 | [diff] [blame] | 360 | .frequency_min = 800000, |
| 361 | .frequency_max = 2250000, |
Alan Nisota | 9bbe076 | 2006-05-14 13:23:56 -0300 | [diff] [blame] | 362 | .frequency_stepsize = 100, |
| 363 | .symbol_rate_min = 1000000, |
| 364 | .symbol_rate_max = 45000000, |
| 365 | .symbol_rate_tolerance = 500, /* ppm */ |
| 366 | .caps = FE_CAN_INVERSION_AUTO | |
Alan Nisota | 02ebf23 | 2008-12-20 12:03:06 -0300 | [diff] [blame] | 367 | FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 | |
| 368 | FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO | |
| 369 | /* |
| 370 | * FE_CAN_QAM_16 is for compatibility |
| 371 | * (Myth incorrectly detects Turbo-QPSK as plain QAM-16) |
| 372 | */ |
Klaus Schmidinger | f6a20eb | 2010-07-01 01:37:34 -0300 | [diff] [blame] | 373 | FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_TURBO_FEC |
Alan Nisota | 9bbe076 | 2006-05-14 13:23:56 -0300 | [diff] [blame] | 374 | }, |
| 375 | |
| 376 | .release = gp8psk_fe_release, |
| 377 | |
| 378 | .init = NULL, |
| 379 | .sleep = NULL, |
| 380 | |
Mauro Carvalho Chehab | 6e07d5c | 2011-12-26 15:49:16 -0300 | [diff] [blame] | 381 | .set_frontend = gp8psk_fe_set_frontend, |
Alan Nisota | 02ebf23 | 2008-12-20 12:03:06 -0300 | [diff] [blame] | 382 | |
Alan Nisota | 9bbe076 | 2006-05-14 13:23:56 -0300 | [diff] [blame] | 383 | .get_tune_settings = gp8psk_fe_get_tune_settings, |
| 384 | |
| 385 | .read_status = gp8psk_fe_read_status, |
| 386 | .read_ber = gp8psk_fe_read_ber, |
| 387 | .read_signal_strength = gp8psk_fe_read_signal_strength, |
| 388 | .read_snr = gp8psk_fe_read_snr, |
| 389 | .read_ucblocks = gp8psk_fe_read_unc_blocks, |
| 390 | |
| 391 | .diseqc_send_master_cmd = gp8psk_fe_send_diseqc_msg, |
| 392 | .diseqc_send_burst = gp8psk_fe_send_diseqc_burst, |
| 393 | .set_tone = gp8psk_fe_set_tone, |
| 394 | .set_voltage = gp8psk_fe_set_voltage, |
| 395 | .dishnetwork_send_legacy_command = gp8psk_fe_send_legacy_dish_cmd, |
Alan Nisota | 458b634 | 2007-08-18 17:52:35 -0300 | [diff] [blame] | 396 | .enable_high_lnb_voltage = gp8psk_fe_enable_high_lnb_voltage |
Alan Nisota | 9bbe076 | 2006-05-14 13:23:56 -0300 | [diff] [blame] | 397 | }; |