Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * dvb_frontend.c: DVB frontend tuning interface/thread |
| 3 | * |
| 4 | * |
| 5 | * Copyright (C) 1999-2001 Ralph Metzler |
| 6 | * Marcus Metzler |
| 7 | * Holger Waechtler |
| 8 | * for convergence integrated media GmbH |
| 9 | * |
| 10 | * Copyright (C) 2004 Andrew de Quincey (tuning thread cleanup) |
| 11 | * |
| 12 | * This program is free software; you can redistribute it and/or |
| 13 | * modify it under the terms of the GNU General Public License |
| 14 | * as published by the Free Software Foundation; either version 2 |
| 15 | * of the License, or (at your option) any later version. |
| 16 | * |
| 17 | * This program is distributed in the hope that it will be useful, |
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 | * GNU General Public License for more details. |
| 21 | * |
| 22 | * You should have received a copy of the GNU General Public License |
| 23 | * along with this program; if not, write to the Free Software |
| 24 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 25 | * Or, point your browser to http://www.gnu.org/copyleft/gpl.html |
| 26 | */ |
| 27 | |
Mauro Carvalho Chehab | 8de8594 | 2011-12-26 20:22:50 -0300 | [diff] [blame] | 28 | /* Enables DVBv3 compatibility bits at the headers */ |
| 29 | #define __DVB_CORE__ |
| 30 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | #include <linux/string.h> |
| 32 | #include <linux/kernel.h> |
| 33 | #include <linux/sched.h> |
| 34 | #include <linux/wait.h> |
| 35 | #include <linux/slab.h> |
| 36 | #include <linux/poll.h> |
Andrew Morton | 4c4cb1b | 2009-12-01 13:17:41 -0800 | [diff] [blame] | 37 | #include <linux/semaphore.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | #include <linux/module.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | #include <linux/list.h> |
Nigel Cunningham | 7dfb710 | 2006-12-06 20:34:23 -0800 | [diff] [blame] | 40 | #include <linux/freezer.h> |
Johannes Stezenbach | cc89c22 | 2005-06-23 22:02:39 -0700 | [diff] [blame] | 41 | #include <linux/jiffies.h> |
Herbert Poetzl | 8eec142 | 2007-02-08 14:32:43 -0300 | [diff] [blame] | 42 | #include <linux/kthread.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | #include <asm/processor.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | |
| 45 | #include "dvb_frontend.h" |
| 46 | #include "dvbdev.h" |
Steven Toth | eacf8d8 | 2008-09-26 00:29:49 -0300 | [diff] [blame] | 47 | #include <linux/dvb/version.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | |
| 49 | static int dvb_frontend_debug; |
Oliver Endriss | 849be2c | 2007-08-25 12:22:16 -0300 | [diff] [blame] | 50 | static int dvb_shutdown_timeout; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | static int dvb_force_auto_inversion; |
| 52 | static int dvb_override_tune_delay; |
| 53 | static int dvb_powerdown_on_sleep = 1; |
Darron Broad | 59b1842 | 2008-10-11 11:44:05 -0300 | [diff] [blame] | 54 | static int dvb_mfe_wait_time = 5; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | |
| 56 | module_param_named(frontend_debug, dvb_frontend_debug, int, 0644); |
Johannes Stezenbach | f4f009a | 2005-05-16 21:54:21 -0700 | [diff] [blame] | 57 | MODULE_PARM_DESC(frontend_debug, "Turn on/off frontend core debugging (default:off)."); |
Manu Abraham | 6baad3f | 2006-02-27 00:09:32 -0300 | [diff] [blame] | 58 | module_param(dvb_shutdown_timeout, int, 0644); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | MODULE_PARM_DESC(dvb_shutdown_timeout, "wait <shutdown_timeout> seconds after close() before suspending hardware"); |
Manu Abraham | 6baad3f | 2006-02-27 00:09:32 -0300 | [diff] [blame] | 60 | module_param(dvb_force_auto_inversion, int, 0644); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | MODULE_PARM_DESC(dvb_force_auto_inversion, "0: normal (default), 1: INVERSION_AUTO forced always"); |
Manu Abraham | 6baad3f | 2006-02-27 00:09:32 -0300 | [diff] [blame] | 62 | module_param(dvb_override_tune_delay, int, 0644); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | MODULE_PARM_DESC(dvb_override_tune_delay, "0: normal (default), >0 => delay in milliseconds to wait for lock after a tune attempt"); |
Manu Abraham | 6baad3f | 2006-02-27 00:09:32 -0300 | [diff] [blame] | 64 | module_param(dvb_powerdown_on_sleep, int, 0644); |
Uwe Bugla | a8558577 | 2006-04-11 10:21:37 -0300 | [diff] [blame] | 65 | MODULE_PARM_DESC(dvb_powerdown_on_sleep, "0: do not power down, 1: turn LNB voltage off on sleep (default)"); |
Darron Broad | 59b1842 | 2008-10-11 11:44:05 -0300 | [diff] [blame] | 66 | module_param(dvb_mfe_wait_time, int, 0644); |
| 67 | MODULE_PARM_DESC(dvb_mfe_wait_time, "Wait up to <mfe_wait_time> seconds on open() for multi-frontend to become available (default:5 seconds)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | |
| 69 | #define dprintk if (dvb_frontend_debug) printk |
| 70 | |
| 71 | #define FESTATE_IDLE 1 |
| 72 | #define FESTATE_RETUNE 2 |
| 73 | #define FESTATE_TUNING_FAST 4 |
| 74 | #define FESTATE_TUNING_SLOW 8 |
| 75 | #define FESTATE_TUNED 16 |
| 76 | #define FESTATE_ZIGZAG_FAST 32 |
| 77 | #define FESTATE_ZIGZAG_SLOW 64 |
| 78 | #define FESTATE_DISEQC 128 |
Janne Grunau | 0188625 | 2009-09-01 19:23:09 -0300 | [diff] [blame] | 79 | #define FESTATE_ERROR 256 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | #define FESTATE_WAITFORLOCK (FESTATE_TUNING_FAST | FESTATE_TUNING_SLOW | FESTATE_ZIGZAG_FAST | FESTATE_ZIGZAG_SLOW | FESTATE_DISEQC) |
| 81 | #define FESTATE_SEARCHING_FAST (FESTATE_TUNING_FAST | FESTATE_ZIGZAG_FAST) |
| 82 | #define FESTATE_SEARCHING_SLOW (FESTATE_TUNING_SLOW | FESTATE_ZIGZAG_SLOW) |
| 83 | #define FESTATE_LOSTLOCK (FESTATE_ZIGZAG_FAST | FESTATE_ZIGZAG_SLOW) |
Manu Abraham | 0249ef1 | 2006-06-21 10:27:31 -0300 | [diff] [blame] | 84 | |
| 85 | #define FE_ALGO_HW 1 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | /* |
| 87 | * FESTATE_IDLE. No tuning parameters have been supplied and the loop is idling. |
| 88 | * FESTATE_RETUNE. Parameters have been supplied, but we have not yet performed the first tune. |
| 89 | * FESTATE_TUNING_FAST. Tuning parameters have been supplied and fast zigzag scan is in progress. |
| 90 | * FESTATE_TUNING_SLOW. Tuning parameters have been supplied. Fast zigzag failed, so we're trying again, but slower. |
| 91 | * FESTATE_TUNED. The frontend has successfully locked on. |
| 92 | * FESTATE_ZIGZAG_FAST. The lock has been lost, and a fast zigzag has been initiated to try and regain it. |
| 93 | * FESTATE_ZIGZAG_SLOW. The lock has been lost. Fast zigzag has been failed, so we're trying again, but slower. |
| 94 | * FESTATE_DISEQC. A DISEQC command has just been issued. |
| 95 | * FESTATE_WAITFORLOCK. When we're waiting for a lock. |
| 96 | * FESTATE_SEARCHING_FAST. When we're searching for a signal using a fast zigzag scan. |
| 97 | * FESTATE_SEARCHING_SLOW. When we're searching for a signal using a slow zigzag scan. |
| 98 | * FESTATE_LOSTLOCK. When the lock has been lost, and we're searching it again. |
| 99 | */ |
| 100 | |
matthieu castet | e36309f | 2010-05-05 15:59:20 -0300 | [diff] [blame] | 101 | #define DVB_FE_NO_EXIT 0 |
| 102 | #define DVB_FE_NORMAL_EXIT 1 |
| 103 | #define DVB_FE_DEVICE_REMOVED 2 |
| 104 | |
Ingo Molnar | 3593cab | 2006-02-07 06:49:14 -0200 | [diff] [blame] | 105 | static DEFINE_MUTEX(frontend_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | |
| 107 | struct dvb_frontend_private { |
| 108 | |
Andrew de Quincey | 36cb557 | 2006-01-09 15:25:07 -0200 | [diff] [blame] | 109 | /* thread/frontend values */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | struct dvb_device *dvbdev; |
Andreas Oberritter | a5959db | 2011-05-08 20:03:40 -0300 | [diff] [blame] | 111 | struct dvb_frontend_parameters parameters_out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | struct dvb_fe_events events; |
| 113 | struct semaphore sem; |
| 114 | struct list_head list_head; |
| 115 | wait_queue_head_t wait_queue; |
Herbert Poetzl | 8eec142 | 2007-02-08 14:32:43 -0300 | [diff] [blame] | 116 | struct task_struct *thread; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | unsigned long release_jiffies; |
Andrew de Quincey | 36cb557 | 2006-01-09 15:25:07 -0200 | [diff] [blame] | 118 | unsigned int exit; |
| 119 | unsigned int wakeup; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | fe_status_t status; |
Peter Beutner | 400b708 | 2006-01-09 15:32:43 -0200 | [diff] [blame] | 121 | unsigned long tune_mode_flags; |
Andrew de Quincey | 36cb557 | 2006-01-09 15:25:07 -0200 | [diff] [blame] | 122 | unsigned int delay; |
Andrew de Quincey | 86f40cc | 2006-03-30 15:53:35 -0300 | [diff] [blame] | 123 | unsigned int reinitialise; |
Andrew de Quincey | 6445401 | 2006-04-06 14:32:23 -0300 | [diff] [blame] | 124 | int tone; |
| 125 | int voltage; |
Andrew de Quincey | 36cb557 | 2006-01-09 15:25:07 -0200 | [diff] [blame] | 126 | |
| 127 | /* swzigzag values */ |
| 128 | unsigned int state; |
| 129 | unsigned int bending; |
| 130 | int lnb_drift; |
| 131 | unsigned int inversion; |
| 132 | unsigned int auto_step; |
| 133 | unsigned int auto_sub_step; |
| 134 | unsigned int started_auto_step; |
| 135 | unsigned int min_delay; |
| 136 | unsigned int max_drift; |
| 137 | unsigned int step_size; |
| 138 | int quality; |
| 139 | unsigned int check_wrapped; |
Manu Abraham | c59e787 | 2008-10-14 16:34:07 -0300 | [diff] [blame] | 140 | enum dvbfe_search algo_status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 141 | }; |
| 142 | |
Andrew de Quincey | 86f40cc | 2006-03-30 15:53:35 -0300 | [diff] [blame] | 143 | static void dvb_frontend_wakeup(struct dvb_frontend *fe); |
Mauro Carvalho Chehab | a689e36 | 2011-12-22 14:47:48 -0300 | [diff] [blame] | 144 | static int dtv_get_frontend(struct dvb_frontend *fe, |
Mauro Carvalho Chehab | a689e36 | 2011-12-22 14:47:48 -0300 | [diff] [blame] | 145 | struct dvb_frontend_parameters *p_out); |
| 146 | |
| 147 | static bool has_get_frontend(struct dvb_frontend *fe) |
| 148 | { |
Mauro Carvalho Chehab | b1e9a6501 | 2011-12-26 16:43:32 -0300 | [diff] [blame] | 149 | return fe->ops.get_frontend; |
Mauro Carvalho Chehab | a689e36 | 2011-12-22 14:47:48 -0300 | [diff] [blame] | 150 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 151 | |
Mauro Carvalho Chehab | 5bfaadd | 2012-01-01 16:11:13 -0300 | [diff] [blame] | 152 | /* |
| 153 | * Due to DVBv3 API calls, a delivery system should be mapped into one of |
| 154 | * the 4 DVBv3 delivery systems (FE_QPSK, FE_QAM, FE_OFDM or FE_ATSC), |
| 155 | * otherwise, a DVBv3 call will fail. |
| 156 | */ |
| 157 | enum dvbv3_emulation_type { |
| 158 | DVBV3_UNKNOWN, |
| 159 | DVBV3_QPSK, |
| 160 | DVBV3_QAM, |
| 161 | DVBV3_OFDM, |
| 162 | DVBV3_ATSC, |
| 163 | }; |
| 164 | |
| 165 | static enum dvbv3_emulation_type dvbv3_type(u32 delivery_system) |
| 166 | { |
| 167 | switch (delivery_system) { |
| 168 | case SYS_DVBC_ANNEX_A: |
| 169 | case SYS_DVBC_ANNEX_C: |
| 170 | return DVBV3_QAM; |
| 171 | case SYS_DVBS: |
| 172 | case SYS_DVBS2: |
| 173 | case SYS_TURBO: |
| 174 | case SYS_ISDBS: |
| 175 | case SYS_DSS: |
| 176 | return DVBV3_QPSK; |
| 177 | case SYS_DVBT: |
| 178 | case SYS_DVBT2: |
| 179 | case SYS_ISDBT: |
| 180 | case SYS_DMBTH: |
| 181 | return DVBV3_OFDM; |
| 182 | case SYS_ATSC: |
| 183 | case SYS_DVBC_ANNEX_B: |
| 184 | return DVBV3_ATSC; |
| 185 | case SYS_UNDEFINED: |
| 186 | case SYS_ISDBC: |
| 187 | case SYS_DVBH: |
| 188 | case SYS_DAB: |
| 189 | case SYS_ATSCMH: |
| 190 | default: |
| 191 | /* |
| 192 | * Doesn't know how to emulate those types and/or |
| 193 | * there's no frontend driver from this type yet |
| 194 | * with some emulation code, so, we're not sure yet how |
| 195 | * to handle them, or they're not compatible with a DVBv3 call. |
| 196 | */ |
| 197 | return DVBV3_UNKNOWN; |
| 198 | } |
| 199 | } |
| 200 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 201 | static void dvb_frontend_add_event(struct dvb_frontend *fe, fe_status_t status) |
| 202 | { |
Johannes Stezenbach | 0c53c70 | 2005-05-16 21:54:24 -0700 | [diff] [blame] | 203 | struct dvb_frontend_private *fepriv = fe->frontend_priv; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 204 | struct dvb_fe_events *events = &fepriv->events; |
| 205 | struct dvb_frontend_event *e; |
| 206 | int wp; |
| 207 | |
Harvey Harrison | 46b4f7c | 2008-04-08 23:20:00 -0300 | [diff] [blame] | 208 | dprintk ("%s\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 | |
Mauro Carvalho Chehab | a689e36 | 2011-12-22 14:47:48 -0300 | [diff] [blame] | 210 | if ((status & FE_HAS_LOCK) && has_get_frontend(fe)) |
Mauro Carvalho Chehab | 7c61d80 | 2011-12-30 11:30:21 -0300 | [diff] [blame] | 211 | dtv_get_frontend(fe, &fepriv->parameters_out); |
Andreas Oberritter | 77b1e2f | 2011-08-04 12:33:15 -0300 | [diff] [blame] | 212 | |
| 213 | mutex_lock(&events->mtx); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 214 | |
| 215 | wp = (events->eventw + 1) % MAX_EVENT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 216 | if (wp == events->eventr) { |
| 217 | events->overflow = 1; |
| 218 | events->eventr = (events->eventr + 1) % MAX_EVENT; |
| 219 | } |
| 220 | |
| 221 | e = &events->events[events->eventw]; |
Andreas Oberritter | 77b1e2f | 2011-08-04 12:33:15 -0300 | [diff] [blame] | 222 | e->status = status; |
Andreas Oberritter | a5959db | 2011-05-08 20:03:40 -0300 | [diff] [blame] | 223 | e->parameters = fepriv->parameters_out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 224 | |
| 225 | events->eventw = wp; |
| 226 | |
Matthias Kaehlcke | 03b7612 | 2007-07-30 14:58:10 -0300 | [diff] [blame] | 227 | mutex_unlock(&events->mtx); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 229 | wake_up_interruptible (&events->wait_queue); |
| 230 | } |
| 231 | |
| 232 | static int dvb_frontend_get_event(struct dvb_frontend *fe, |
| 233 | struct dvb_frontend_event *event, int flags) |
| 234 | { |
Johannes Stezenbach | 0c53c70 | 2005-05-16 21:54:24 -0700 | [diff] [blame] | 235 | struct dvb_frontend_private *fepriv = fe->frontend_priv; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 236 | struct dvb_fe_events *events = &fepriv->events; |
| 237 | |
Harvey Harrison | 46b4f7c | 2008-04-08 23:20:00 -0300 | [diff] [blame] | 238 | dprintk ("%s\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 239 | |
| 240 | if (events->overflow) { |
| 241 | events->overflow = 0; |
| 242 | return -EOVERFLOW; |
| 243 | } |
| 244 | |
| 245 | if (events->eventw == events->eventr) { |
| 246 | int ret; |
| 247 | |
| 248 | if (flags & O_NONBLOCK) |
| 249 | return -EWOULDBLOCK; |
| 250 | |
| 251 | up(&fepriv->sem); |
| 252 | |
| 253 | ret = wait_event_interruptible (events->wait_queue, |
| 254 | events->eventw != events->eventr); |
| 255 | |
| 256 | if (down_interruptible (&fepriv->sem)) |
| 257 | return -ERESTARTSYS; |
| 258 | |
| 259 | if (ret < 0) |
| 260 | return ret; |
| 261 | } |
| 262 | |
Andreas Oberritter | 77b1e2f | 2011-08-04 12:33:15 -0300 | [diff] [blame] | 263 | mutex_lock(&events->mtx); |
| 264 | *event = events->events[events->eventr]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 265 | events->eventr = (events->eventr + 1) % MAX_EVENT; |
Matthias Kaehlcke | 03b7612 | 2007-07-30 14:58:10 -0300 | [diff] [blame] | 266 | mutex_unlock(&events->mtx); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 267 | |
| 268 | return 0; |
| 269 | } |
| 270 | |
Andreas Oberritter | 20640be | 2011-08-04 12:33:14 -0300 | [diff] [blame] | 271 | static void dvb_frontend_clear_events(struct dvb_frontend *fe) |
| 272 | { |
| 273 | struct dvb_frontend_private *fepriv = fe->frontend_priv; |
| 274 | struct dvb_fe_events *events = &fepriv->events; |
| 275 | |
| 276 | mutex_lock(&events->mtx); |
| 277 | events->eventr = events->eventw; |
| 278 | mutex_unlock(&events->mtx); |
| 279 | } |
| 280 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 281 | static void dvb_frontend_init(struct dvb_frontend *fe) |
| 282 | { |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 283 | dprintk ("DVB: initialising adapter %i frontend %i (%s)...\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 284 | fe->dvb->num, |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 285 | fe->id, |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 286 | fe->ops.info.name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 287 | |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 288 | if (fe->ops.init) |
| 289 | fe->ops.init(fe); |
| 290 | if (fe->ops.tuner_ops.init) { |
Manu Abraham | 3b37a15 | 2008-10-20 18:14:14 -0300 | [diff] [blame] | 291 | if (fe->ops.i2c_gate_ctrl) |
| 292 | fe->ops.i2c_gate_ctrl(fe, 1); |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 293 | fe->ops.tuner_ops.init(fe); |
| 294 | if (fe->ops.i2c_gate_ctrl) |
| 295 | fe->ops.i2c_gate_ctrl(fe, 0); |
Andrew de Quincey | 7eef5dd | 2006-04-18 17:47:09 -0300 | [diff] [blame] | 296 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 297 | } |
| 298 | |
Andrew de Quincey | 86f40cc | 2006-03-30 15:53:35 -0300 | [diff] [blame] | 299 | void dvb_frontend_reinitialise(struct dvb_frontend *fe) |
| 300 | { |
| 301 | struct dvb_frontend_private *fepriv = fe->frontend_priv; |
| 302 | |
| 303 | fepriv->reinitialise = 1; |
| 304 | dvb_frontend_wakeup(fe); |
| 305 | } |
| 306 | EXPORT_SYMBOL(dvb_frontend_reinitialise); |
| 307 | |
Andrew de Quincey | 36cb557 | 2006-01-09 15:25:07 -0200 | [diff] [blame] | 308 | static void dvb_frontend_swzigzag_update_delay(struct dvb_frontend_private *fepriv, int locked) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 309 | { |
Andrew de Quincey | 36cb557 | 2006-01-09 15:25:07 -0200 | [diff] [blame] | 310 | int q2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 311 | |
Harvey Harrison | 46b4f7c | 2008-04-08 23:20:00 -0300 | [diff] [blame] | 312 | dprintk ("%s\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 313 | |
Andrew de Quincey | 36cb557 | 2006-01-09 15:25:07 -0200 | [diff] [blame] | 314 | if (locked) |
| 315 | (fepriv->quality) = (fepriv->quality * 220 + 36*256) / 256; |
| 316 | else |
| 317 | (fepriv->quality) = (fepriv->quality * 220 + 0) / 256; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 318 | |
Andrew de Quincey | 36cb557 | 2006-01-09 15:25:07 -0200 | [diff] [blame] | 319 | q2 = fepriv->quality - 128; |
| 320 | q2 *= q2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 321 | |
Andrew de Quincey | 36cb557 | 2006-01-09 15:25:07 -0200 | [diff] [blame] | 322 | fepriv->delay = fepriv->min_delay + q2 * HZ / (128*128); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 323 | } |
| 324 | |
| 325 | /** |
| 326 | * Performs automatic twiddling of frontend parameters. |
| 327 | * |
| 328 | * @param fe The frontend concerned. |
| 329 | * @param check_wrapped Checks if an iteration has completed. DO NOT SET ON THE FIRST ATTEMPT |
| 330 | * @returns Number of complete iterations that have been performed. |
| 331 | */ |
Andrew de Quincey | 36cb557 | 2006-01-09 15:25:07 -0200 | [diff] [blame] | 332 | static int dvb_frontend_swzigzag_autotune(struct dvb_frontend *fe, int check_wrapped) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 333 | { |
| 334 | int autoinversion; |
| 335 | int ready = 0; |
Janne Grunau | 0188625 | 2009-09-01 19:23:09 -0300 | [diff] [blame] | 336 | int fe_set_err = 0; |
Johannes Stezenbach | 0c53c70 | 2005-05-16 21:54:24 -0700 | [diff] [blame] | 337 | struct dvb_frontend_private *fepriv = fe->frontend_priv; |
Mauro Carvalho Chehab | ac3852c | 2011-12-30 09:30:25 -0300 | [diff] [blame] | 338 | struct dtv_frontend_properties *c = &fe->dtv_property_cache, tmp; |
| 339 | int original_inversion = c->inversion; |
| 340 | u32 original_frequency = c->frequency; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 341 | |
| 342 | /* are we using autoinversion? */ |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 343 | autoinversion = ((!(fe->ops.info.caps & FE_CAN_INVERSION_AUTO)) && |
Mauro Carvalho Chehab | ac3852c | 2011-12-30 09:30:25 -0300 | [diff] [blame] | 344 | (c->inversion == INVERSION_AUTO)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 345 | |
| 346 | /* setup parameters correctly */ |
| 347 | while(!ready) { |
| 348 | /* calculate the lnb_drift */ |
| 349 | fepriv->lnb_drift = fepriv->auto_step * fepriv->step_size; |
| 350 | |
| 351 | /* wrap the auto_step if we've exceeded the maximum drift */ |
| 352 | if (fepriv->lnb_drift > fepriv->max_drift) { |
| 353 | fepriv->auto_step = 0; |
| 354 | fepriv->auto_sub_step = 0; |
| 355 | fepriv->lnb_drift = 0; |
| 356 | } |
| 357 | |
| 358 | /* perform inversion and +/- zigzag */ |
| 359 | switch(fepriv->auto_sub_step) { |
| 360 | case 0: |
| 361 | /* try with the current inversion and current drift setting */ |
| 362 | ready = 1; |
| 363 | break; |
| 364 | |
| 365 | case 1: |
| 366 | if (!autoinversion) break; |
| 367 | |
| 368 | fepriv->inversion = (fepriv->inversion == INVERSION_OFF) ? INVERSION_ON : INVERSION_OFF; |
| 369 | ready = 1; |
| 370 | break; |
| 371 | |
| 372 | case 2: |
| 373 | if (fepriv->lnb_drift == 0) break; |
| 374 | |
| 375 | fepriv->lnb_drift = -fepriv->lnb_drift; |
| 376 | ready = 1; |
| 377 | break; |
| 378 | |
| 379 | case 3: |
| 380 | if (fepriv->lnb_drift == 0) break; |
| 381 | if (!autoinversion) break; |
| 382 | |
| 383 | fepriv->inversion = (fepriv->inversion == INVERSION_OFF) ? INVERSION_ON : INVERSION_OFF; |
| 384 | fepriv->lnb_drift = -fepriv->lnb_drift; |
| 385 | ready = 1; |
| 386 | break; |
| 387 | |
| 388 | default: |
| 389 | fepriv->auto_step++; |
| 390 | fepriv->auto_sub_step = -1; /* it'll be incremented to 0 in a moment */ |
| 391 | break; |
| 392 | } |
| 393 | |
| 394 | if (!ready) fepriv->auto_sub_step++; |
| 395 | } |
| 396 | |
| 397 | /* if this attempt would hit where we started, indicate a complete |
| 398 | * iteration has occurred */ |
| 399 | if ((fepriv->auto_step == fepriv->started_auto_step) && |
| 400 | (fepriv->auto_sub_step == 0) && check_wrapped) { |
| 401 | return 1; |
| 402 | } |
| 403 | |
| 404 | dprintk("%s: drift:%i inversion:%i auto_step:%i " |
| 405 | "auto_sub_step:%i started_auto_step:%i\n", |
Harvey Harrison | 46b4f7c | 2008-04-08 23:20:00 -0300 | [diff] [blame] | 406 | __func__, fepriv->lnb_drift, fepriv->inversion, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 407 | fepriv->auto_step, fepriv->auto_sub_step, fepriv->started_auto_step); |
| 408 | |
| 409 | /* set the frontend itself */ |
Mauro Carvalho Chehab | ac3852c | 2011-12-30 09:30:25 -0300 | [diff] [blame] | 410 | c->frequency += fepriv->lnb_drift; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 411 | if (autoinversion) |
Mauro Carvalho Chehab | ac3852c | 2011-12-30 09:30:25 -0300 | [diff] [blame] | 412 | c->inversion = fepriv->inversion; |
| 413 | tmp = *c; |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 414 | if (fe->ops.set_frontend) |
Mauro Carvalho Chehab | bc9cd27 | 2011-12-20 15:31:54 -0300 | [diff] [blame] | 415 | fe_set_err = fe->ops.set_frontend(fe); |
Mauro Carvalho Chehab | ac3852c | 2011-12-30 09:30:25 -0300 | [diff] [blame] | 416 | *c = tmp; |
Janne Grunau | 0188625 | 2009-09-01 19:23:09 -0300 | [diff] [blame] | 417 | if (fe_set_err < 0) { |
| 418 | fepriv->state = FESTATE_ERROR; |
| 419 | return fe_set_err; |
| 420 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 421 | |
Mauro Carvalho Chehab | ac3852c | 2011-12-30 09:30:25 -0300 | [diff] [blame] | 422 | c->frequency = original_frequency; |
| 423 | c->inversion = original_inversion; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 424 | |
| 425 | fepriv->auto_sub_step++; |
| 426 | return 0; |
| 427 | } |
| 428 | |
Andrew de Quincey | 36cb557 | 2006-01-09 15:25:07 -0200 | [diff] [blame] | 429 | static void dvb_frontend_swzigzag(struct dvb_frontend *fe) |
| 430 | { |
Andrew de Quincey | 30d9464 | 2006-11-16 22:12:40 -0300 | [diff] [blame] | 431 | fe_status_t s = 0; |
Janne Grunau | 0188625 | 2009-09-01 19:23:09 -0300 | [diff] [blame] | 432 | int retval = 0; |
Andrew de Quincey | 36cb557 | 2006-01-09 15:25:07 -0200 | [diff] [blame] | 433 | struct dvb_frontend_private *fepriv = fe->frontend_priv; |
Mauro Carvalho Chehab | ac3852c | 2011-12-30 09:30:25 -0300 | [diff] [blame] | 434 | struct dtv_frontend_properties *c = &fe->dtv_property_cache, tmp; |
Andrew de Quincey | 36cb557 | 2006-01-09 15:25:07 -0200 | [diff] [blame] | 435 | |
| 436 | /* if we've got no parameters, just keep idling */ |
| 437 | if (fepriv->state & FESTATE_IDLE) { |
| 438 | fepriv->delay = 3*HZ; |
| 439 | fepriv->quality = 0; |
| 440 | return; |
| 441 | } |
| 442 | |
| 443 | /* in SCAN mode, we just set the frontend when asked and leave it alone */ |
| 444 | if (fepriv->tune_mode_flags & FE_TUNE_MODE_ONESHOT) { |
| 445 | if (fepriv->state & FESTATE_RETUNE) { |
Mauro Carvalho Chehab | ac3852c | 2011-12-30 09:30:25 -0300 | [diff] [blame] | 446 | tmp = *c; |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 447 | if (fe->ops.set_frontend) |
Mauro Carvalho Chehab | bc9cd27 | 2011-12-20 15:31:54 -0300 | [diff] [blame] | 448 | retval = fe->ops.set_frontend(fe); |
Mauro Carvalho Chehab | ac3852c | 2011-12-30 09:30:25 -0300 | [diff] [blame] | 449 | *c = tmp; |
Janne Grunau | 0188625 | 2009-09-01 19:23:09 -0300 | [diff] [blame] | 450 | if (retval < 0) |
| 451 | fepriv->state = FESTATE_ERROR; |
| 452 | else |
| 453 | fepriv->state = FESTATE_TUNED; |
Andrew de Quincey | 36cb557 | 2006-01-09 15:25:07 -0200 | [diff] [blame] | 454 | } |
| 455 | fepriv->delay = 3*HZ; |
| 456 | fepriv->quality = 0; |
| 457 | return; |
| 458 | } |
| 459 | |
| 460 | /* get the frontend status */ |
| 461 | if (fepriv->state & FESTATE_RETUNE) { |
| 462 | s = 0; |
| 463 | } else { |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 464 | if (fe->ops.read_status) |
| 465 | fe->ops.read_status(fe, &s); |
Andrew de Quincey | 36cb557 | 2006-01-09 15:25:07 -0200 | [diff] [blame] | 466 | if (s != fepriv->status) { |
| 467 | dvb_frontend_add_event(fe, s); |
| 468 | fepriv->status = s; |
| 469 | } |
| 470 | } |
| 471 | |
| 472 | /* if we're not tuned, and we have a lock, move to the TUNED state */ |
| 473 | if ((fepriv->state & FESTATE_WAITFORLOCK) && (s & FE_HAS_LOCK)) { |
| 474 | dvb_frontend_swzigzag_update_delay(fepriv, s & FE_HAS_LOCK); |
| 475 | fepriv->state = FESTATE_TUNED; |
| 476 | |
| 477 | /* if we're tuned, then we have determined the correct inversion */ |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 478 | if ((!(fe->ops.info.caps & FE_CAN_INVERSION_AUTO)) && |
Mauro Carvalho Chehab | ac3852c | 2011-12-30 09:30:25 -0300 | [diff] [blame] | 479 | (c->inversion == INVERSION_AUTO)) { |
| 480 | c->inversion = fepriv->inversion; |
Andrew de Quincey | 36cb557 | 2006-01-09 15:25:07 -0200 | [diff] [blame] | 481 | } |
| 482 | return; |
| 483 | } |
| 484 | |
| 485 | /* if we are tuned already, check we're still locked */ |
| 486 | if (fepriv->state & FESTATE_TUNED) { |
| 487 | dvb_frontend_swzigzag_update_delay(fepriv, s & FE_HAS_LOCK); |
| 488 | |
| 489 | /* we're tuned, and the lock is still good... */ |
| 490 | if (s & FE_HAS_LOCK) { |
| 491 | return; |
| 492 | } else { /* if we _WERE_ tuned, but now don't have a lock */ |
| 493 | fepriv->state = FESTATE_ZIGZAG_FAST; |
| 494 | fepriv->started_auto_step = fepriv->auto_step; |
| 495 | fepriv->check_wrapped = 0; |
| 496 | } |
| 497 | } |
| 498 | |
| 499 | /* don't actually do anything if we're in the LOSTLOCK state, |
| 500 | * the frontend is set to FE_CAN_RECOVER, and the max_drift is 0 */ |
| 501 | if ((fepriv->state & FESTATE_LOSTLOCK) && |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 502 | (fe->ops.info.caps & FE_CAN_RECOVER) && (fepriv->max_drift == 0)) { |
Andrew de Quincey | 36cb557 | 2006-01-09 15:25:07 -0200 | [diff] [blame] | 503 | dvb_frontend_swzigzag_update_delay(fepriv, s & FE_HAS_LOCK); |
| 504 | return; |
| 505 | } |
| 506 | |
| 507 | /* don't do anything if we're in the DISEQC state, since this |
| 508 | * might be someone with a motorized dish controlled by DISEQC. |
| 509 | * If its actually a re-tune, there will be a SET_FRONTEND soon enough. */ |
| 510 | if (fepriv->state & FESTATE_DISEQC) { |
| 511 | dvb_frontend_swzigzag_update_delay(fepriv, s & FE_HAS_LOCK); |
| 512 | return; |
| 513 | } |
| 514 | |
| 515 | /* if we're in the RETUNE state, set everything up for a brand |
| 516 | * new scan, keeping the current inversion setting, as the next |
| 517 | * tune is _very_ likely to require the same */ |
| 518 | if (fepriv->state & FESTATE_RETUNE) { |
| 519 | fepriv->lnb_drift = 0; |
| 520 | fepriv->auto_step = 0; |
| 521 | fepriv->auto_sub_step = 0; |
| 522 | fepriv->started_auto_step = 0; |
| 523 | fepriv->check_wrapped = 0; |
| 524 | } |
| 525 | |
| 526 | /* fast zigzag. */ |
| 527 | if ((fepriv->state & FESTATE_SEARCHING_FAST) || (fepriv->state & FESTATE_RETUNE)) { |
| 528 | fepriv->delay = fepriv->min_delay; |
| 529 | |
Guillaume Audirac | 2030c03 | 2010-05-06 09:30:25 -0300 | [diff] [blame] | 530 | /* perform a tune */ |
Janne Grunau | 0188625 | 2009-09-01 19:23:09 -0300 | [diff] [blame] | 531 | retval = dvb_frontend_swzigzag_autotune(fe, |
| 532 | fepriv->check_wrapped); |
| 533 | if (retval < 0) { |
| 534 | return; |
| 535 | } else if (retval) { |
Andrew de Quincey | 36cb557 | 2006-01-09 15:25:07 -0200 | [diff] [blame] | 536 | /* OK, if we've run out of trials at the fast speed. |
| 537 | * Drop back to slow for the _next_ attempt */ |
| 538 | fepriv->state = FESTATE_SEARCHING_SLOW; |
| 539 | fepriv->started_auto_step = fepriv->auto_step; |
| 540 | return; |
| 541 | } |
| 542 | fepriv->check_wrapped = 1; |
| 543 | |
| 544 | /* if we've just retuned, enter the ZIGZAG_FAST state. |
| 545 | * This ensures we cannot return from an |
| 546 | * FE_SET_FRONTEND ioctl before the first frontend tune |
| 547 | * occurs */ |
| 548 | if (fepriv->state & FESTATE_RETUNE) { |
| 549 | fepriv->state = FESTATE_TUNING_FAST; |
| 550 | } |
| 551 | } |
| 552 | |
| 553 | /* slow zigzag */ |
| 554 | if (fepriv->state & FESTATE_SEARCHING_SLOW) { |
| 555 | dvb_frontend_swzigzag_update_delay(fepriv, s & FE_HAS_LOCK); |
| 556 | |
| 557 | /* Note: don't bother checking for wrapping; we stay in this |
| 558 | * state until we get a lock */ |
| 559 | dvb_frontend_swzigzag_autotune(fe, 0); |
| 560 | } |
| 561 | } |
| 562 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 563 | static int dvb_frontend_is_exiting(struct dvb_frontend *fe) |
| 564 | { |
Johannes Stezenbach | 0c53c70 | 2005-05-16 21:54:24 -0700 | [diff] [blame] | 565 | struct dvb_frontend_private *fepriv = fe->frontend_priv; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 566 | |
matthieu castet | e36309f | 2010-05-05 15:59:20 -0300 | [diff] [blame] | 567 | if (fepriv->exit != DVB_FE_NO_EXIT) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 568 | return 1; |
| 569 | |
| 570 | if (fepriv->dvbdev->writers == 1) |
Andreas Oberritter | b9d5efc | 2011-12-09 21:37:00 -0300 | [diff] [blame] | 571 | if (time_after_eq(jiffies, fepriv->release_jiffies + |
Andrew de Quincey | 36cb557 | 2006-01-09 15:25:07 -0200 | [diff] [blame] | 572 | dvb_shutdown_timeout * HZ)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 573 | return 1; |
| 574 | |
| 575 | return 0; |
| 576 | } |
| 577 | |
| 578 | static int dvb_frontend_should_wakeup(struct dvb_frontend *fe) |
| 579 | { |
Johannes Stezenbach | 0c53c70 | 2005-05-16 21:54:24 -0700 | [diff] [blame] | 580 | struct dvb_frontend_private *fepriv = fe->frontend_priv; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 581 | |
| 582 | if (fepriv->wakeup) { |
| 583 | fepriv->wakeup = 0; |
| 584 | return 1; |
| 585 | } |
| 586 | return dvb_frontend_is_exiting(fe); |
| 587 | } |
| 588 | |
| 589 | static void dvb_frontend_wakeup(struct dvb_frontend *fe) |
| 590 | { |
Johannes Stezenbach | 0c53c70 | 2005-05-16 21:54:24 -0700 | [diff] [blame] | 591 | struct dvb_frontend_private *fepriv = fe->frontend_priv; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 592 | |
| 593 | fepriv->wakeup = 1; |
| 594 | wake_up_interruptible(&fepriv->wait_queue); |
| 595 | } |
| 596 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 597 | static int dvb_frontend_thread(void *data) |
| 598 | { |
Johannes Stezenbach | 0c53c70 | 2005-05-16 21:54:24 -0700 | [diff] [blame] | 599 | struct dvb_frontend *fe = data; |
| 600 | struct dvb_frontend_private *fepriv = fe->frontend_priv; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 601 | fe_status_t s; |
Manu Abraham | c59e787 | 2008-10-14 16:34:07 -0300 | [diff] [blame] | 602 | enum dvbfe_algo algo; |
| 603 | |
Mauro Carvalho Chehab | 7e07222 | 2011-12-26 17:48:33 -0300 | [diff] [blame] | 604 | bool re_tune = false; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 605 | |
Harvey Harrison | 46b4f7c | 2008-04-08 23:20:00 -0300 | [diff] [blame] | 606 | dprintk("%s\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 607 | |
Andrew de Quincey | 36cb557 | 2006-01-09 15:25:07 -0200 | [diff] [blame] | 608 | fepriv->check_wrapped = 0; |
| 609 | fepriv->quality = 0; |
| 610 | fepriv->delay = 3*HZ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 611 | fepriv->status = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 612 | fepriv->wakeup = 0; |
Andrew de Quincey | 04c56d0 | 2006-07-10 03:34:14 -0300 | [diff] [blame] | 613 | fepriv->reinitialise = 0; |
| 614 | |
| 615 | dvb_frontend_init(fe); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 616 | |
Rafael J. Wysocki | 8314418 | 2007-07-17 04:03:35 -0700 | [diff] [blame] | 617 | set_freezable(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 618 | while (1) { |
| 619 | up(&fepriv->sem); /* is locked when we enter the thread... */ |
akpm@linux-foundation.org | 6591691 | 2007-02-08 14:36:57 -0300 | [diff] [blame] | 620 | restart: |
Hans Verkuil | 94238e9 | 2011-08-27 11:30:25 -0300 | [diff] [blame] | 621 | wait_event_interruptible_timeout(fepriv->wait_queue, |
Rafael J. Wysocki | e42837b | 2007-10-18 03:04:45 -0700 | [diff] [blame] | 622 | dvb_frontend_should_wakeup(fe) || kthread_should_stop() |
| 623 | || freezing(current), |
Herbert Poetzl | 8eec142 | 2007-02-08 14:32:43 -0300 | [diff] [blame] | 624 | fepriv->delay); |
| 625 | |
| 626 | if (kthread_should_stop() || dvb_frontend_is_exiting(fe)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 627 | /* got signal or quitting */ |
matthieu castet | e36309f | 2010-05-05 15:59:20 -0300 | [diff] [blame] | 628 | fepriv->exit = DVB_FE_NORMAL_EXIT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 629 | break; |
| 630 | } |
| 631 | |
Herbert Poetzl | 8eec142 | 2007-02-08 14:32:43 -0300 | [diff] [blame] | 632 | if (try_to_freeze()) |
akpm@linux-foundation.org | 6591691 | 2007-02-08 14:36:57 -0300 | [diff] [blame] | 633 | goto restart; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 634 | |
| 635 | if (down_interruptible(&fepriv->sem)) |
| 636 | break; |
| 637 | |
Andrew de Quincey | 86f40cc | 2006-03-30 15:53:35 -0300 | [diff] [blame] | 638 | if (fepriv->reinitialise) { |
| 639 | dvb_frontend_init(fe); |
Andreas Oberritter | 42f4e77 | 2011-08-24 14:33:52 -0300 | [diff] [blame] | 640 | if (fe->ops.set_tone && fepriv->tone != -1) |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 641 | fe->ops.set_tone(fe, fepriv->tone); |
Andreas Oberritter | 42f4e77 | 2011-08-24 14:33:52 -0300 | [diff] [blame] | 642 | if (fe->ops.set_voltage && fepriv->voltage != -1) |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 643 | fe->ops.set_voltage(fe, fepriv->voltage); |
Andrew de Quincey | 86f40cc | 2006-03-30 15:53:35 -0300 | [diff] [blame] | 644 | fepriv->reinitialise = 0; |
| 645 | } |
| 646 | |
Andrew de Quincey | 36cb557 | 2006-01-09 15:25:07 -0200 | [diff] [blame] | 647 | /* do an iteration of the tuning loop */ |
Manu Abraham | d772bd0 | 2006-06-24 11:18:58 -0300 | [diff] [blame] | 648 | if (fe->ops.get_frontend_algo) { |
Manu Abraham | c59e787 | 2008-10-14 16:34:07 -0300 | [diff] [blame] | 649 | algo = fe->ops.get_frontend_algo(fe); |
| 650 | switch (algo) { |
| 651 | case DVBFE_ALGO_HW: |
| 652 | dprintk("%s: Frontend ALGO = DVBFE_ALGO_HW\n", __func__); |
Manu Abraham | c59e787 | 2008-10-14 16:34:07 -0300 | [diff] [blame] | 653 | |
Manu Abraham | d772bd0 | 2006-06-24 11:18:58 -0300 | [diff] [blame] | 654 | if (fepriv->state & FESTATE_RETUNE) { |
Manu Abraham | c59e787 | 2008-10-14 16:34:07 -0300 | [diff] [blame] | 655 | dprintk("%s: Retune requested, FESTATE_RETUNE\n", __func__); |
Mauro Carvalho Chehab | 7e07222 | 2011-12-26 17:48:33 -0300 | [diff] [blame] | 656 | re_tune = true; |
Manu Abraham | d772bd0 | 2006-06-24 11:18:58 -0300 | [diff] [blame] | 657 | fepriv->state = FESTATE_TUNED; |
Simon Arlott | 45145b6 | 2012-02-06 17:57:01 -0300 | [diff] [blame] | 658 | } else { |
| 659 | re_tune = false; |
Manu Abraham | d772bd0 | 2006-06-24 11:18:58 -0300 | [diff] [blame] | 660 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 661 | |
Manu Abraham | c59e787 | 2008-10-14 16:34:07 -0300 | [diff] [blame] | 662 | if (fe->ops.tune) |
Mauro Carvalho Chehab | 7e07222 | 2011-12-26 17:48:33 -0300 | [diff] [blame] | 663 | fe->ops.tune(fe, re_tune, fepriv->tune_mode_flags, &fepriv->delay, &s); |
Manu Abraham | c59e787 | 2008-10-14 16:34:07 -0300 | [diff] [blame] | 664 | |
Darron Broad | 2fac9a0 | 2008-12-18 06:27:50 -0300 | [diff] [blame] | 665 | if (s != fepriv->status && !(fepriv->tune_mode_flags & FE_TUNE_MODE_ONESHOT)) { |
Manu Abraham | c59e787 | 2008-10-14 16:34:07 -0300 | [diff] [blame] | 666 | dprintk("%s: state changed, adding current state\n", __func__); |
Manu Abraham | d772bd0 | 2006-06-24 11:18:58 -0300 | [diff] [blame] | 667 | dvb_frontend_add_event(fe, s); |
| 668 | fepriv->status = s; |
| 669 | } |
Manu Abraham | c59e787 | 2008-10-14 16:34:07 -0300 | [diff] [blame] | 670 | break; |
| 671 | case DVBFE_ALGO_SW: |
| 672 | dprintk("%s: Frontend ALGO = DVBFE_ALGO_SW\n", __func__); |
Manu Abraham | 70d9063 | 2006-06-29 22:05:23 -0300 | [diff] [blame] | 673 | dvb_frontend_swzigzag(fe); |
Manu Abraham | c59e787 | 2008-10-14 16:34:07 -0300 | [diff] [blame] | 674 | break; |
| 675 | case DVBFE_ALGO_CUSTOM: |
Manu Abraham | c59e787 | 2008-10-14 16:34:07 -0300 | [diff] [blame] | 676 | dprintk("%s: Frontend ALGO = DVBFE_ALGO_CUSTOM, state=%d\n", __func__, fepriv->state); |
| 677 | if (fepriv->state & FESTATE_RETUNE) { |
| 678 | dprintk("%s: Retune requested, FESTAT_RETUNE\n", __func__); |
| 679 | fepriv->state = FESTATE_TUNED; |
| 680 | } |
| 681 | /* Case where we are going to search for a carrier |
| 682 | * User asked us to retune again for some reason, possibly |
| 683 | * requesting a search with a new set of parameters |
| 684 | */ |
| 685 | if (fepriv->algo_status & DVBFE_ALGO_SEARCH_AGAIN) { |
Arvo Jarve | 7bcbdf3 | 2008-10-20 06:05:21 -0300 | [diff] [blame] | 686 | if (fe->ops.search) { |
Mauro Carvalho Chehab | 41da532 | 2011-12-26 18:03:12 -0300 | [diff] [blame] | 687 | fepriv->algo_status = fe->ops.search(fe); |
Manu Abraham | c59e787 | 2008-10-14 16:34:07 -0300 | [diff] [blame] | 688 | /* We did do a search as was requested, the flags are |
| 689 | * now unset as well and has the flags wrt to search. |
| 690 | */ |
Arvo Jarve | 7bcbdf3 | 2008-10-20 06:05:21 -0300 | [diff] [blame] | 691 | } else { |
| 692 | fepriv->algo_status &= ~DVBFE_ALGO_SEARCH_AGAIN; |
| 693 | } |
Manu Abraham | c59e787 | 2008-10-14 16:34:07 -0300 | [diff] [blame] | 694 | } |
| 695 | /* Track the carrier if the search was successful */ |
Mauro Carvalho Chehab | 1b5d871 | 2011-12-26 18:11:25 -0300 | [diff] [blame] | 696 | if (fepriv->algo_status != DVBFE_ALGO_SEARCH_SUCCESS) { |
Arvo Jarve | 7bcbdf3 | 2008-10-20 06:05:21 -0300 | [diff] [blame] | 697 | fepriv->algo_status |= DVBFE_ALGO_SEARCH_AGAIN; |
| 698 | fepriv->delay = HZ / 2; |
| 699 | } |
| 700 | fe->ops.read_status(fe, &s); |
| 701 | if (s != fepriv->status) { |
| 702 | dvb_frontend_add_event(fe, s); /* update event list */ |
| 703 | fepriv->status = s; |
| 704 | if (!(s & FE_HAS_LOCK)) { |
| 705 | fepriv->delay = HZ / 10; |
| 706 | fepriv->algo_status |= DVBFE_ALGO_SEARCH_AGAIN; |
| 707 | } else { |
| 708 | fepriv->delay = 60 * HZ; |
| 709 | } |
Manu Abraham | c59e787 | 2008-10-14 16:34:07 -0300 | [diff] [blame] | 710 | } |
| 711 | break; |
| 712 | default: |
| 713 | dprintk("%s: UNDEFINED ALGO !\n", __func__); |
| 714 | break; |
| 715 | } |
| 716 | } else { |
Manu Abraham | 4a4edcc | 2006-06-25 05:46:26 -0300 | [diff] [blame] | 717 | dvb_frontend_swzigzag(fe); |
Manu Abraham | c59e787 | 2008-10-14 16:34:07 -0300 | [diff] [blame] | 718 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 719 | } |
| 720 | |
Oliver Endriss | 608f62d | 2007-08-25 13:17:53 -0300 | [diff] [blame] | 721 | if (dvb_powerdown_on_sleep) { |
| 722 | if (fe->ops.set_voltage) |
| 723 | fe->ops.set_voltage(fe, SEC_VOLTAGE_OFF); |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 724 | if (fe->ops.tuner_ops.sleep) { |
Devin Heitmueller | 41286d9 | 2008-11-16 00:44:52 -0300 | [diff] [blame] | 725 | if (fe->ops.i2c_gate_ctrl) |
| 726 | fe->ops.i2c_gate_ctrl(fe, 1); |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 727 | fe->ops.tuner_ops.sleep(fe); |
| 728 | if (fe->ops.i2c_gate_ctrl) |
| 729 | fe->ops.i2c_gate_ctrl(fe, 0); |
Andrew de Quincey | 7eef5dd | 2006-04-18 17:47:09 -0300 | [diff] [blame] | 730 | } |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 731 | if (fe->ops.sleep) |
| 732 | fe->ops.sleep(fe); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 733 | } |
| 734 | |
Herbert Poetzl | 8eec142 | 2007-02-08 14:32:43 -0300 | [diff] [blame] | 735 | fepriv->thread = NULL; |
matthieu castet | e36309f | 2010-05-05 15:59:20 -0300 | [diff] [blame] | 736 | if (kthread_should_stop()) |
| 737 | fepriv->exit = DVB_FE_DEVICE_REMOVED; |
| 738 | else |
| 739 | fepriv->exit = DVB_FE_NO_EXIT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 740 | mb(); |
| 741 | |
| 742 | dvb_frontend_wakeup(fe); |
| 743 | return 0; |
| 744 | } |
| 745 | |
| 746 | static void dvb_frontend_stop(struct dvb_frontend *fe) |
| 747 | { |
Johannes Stezenbach | 0c53c70 | 2005-05-16 21:54:24 -0700 | [diff] [blame] | 748 | struct dvb_frontend_private *fepriv = fe->frontend_priv; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 749 | |
Harvey Harrison | 46b4f7c | 2008-04-08 23:20:00 -0300 | [diff] [blame] | 750 | dprintk ("%s\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 751 | |
matthieu castet | e36309f | 2010-05-05 15:59:20 -0300 | [diff] [blame] | 752 | fepriv->exit = DVB_FE_NORMAL_EXIT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 753 | mb(); |
| 754 | |
Herbert Poetzl | 8eec142 | 2007-02-08 14:32:43 -0300 | [diff] [blame] | 755 | if (!fepriv->thread) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 756 | return; |
| 757 | |
Herbert Poetzl | 8eec142 | 2007-02-08 14:32:43 -0300 | [diff] [blame] | 758 | kthread_stop(fepriv->thread); |
Markus Rechberger | ca5be9c | 2007-04-14 10:18:58 -0300 | [diff] [blame] | 759 | |
Thomas Gleixner | a0a4714 | 2010-09-07 11:33:27 -0300 | [diff] [blame] | 760 | sema_init(&fepriv->sem, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 761 | fepriv->state = FESTATE_IDLE; |
| 762 | |
| 763 | /* paranoia check in case a signal arrived */ |
Herbert Poetzl | 8eec142 | 2007-02-08 14:32:43 -0300 | [diff] [blame] | 764 | if (fepriv->thread) |
| 765 | printk("dvb_frontend_stop: warning: thread %p won't exit\n", |
| 766 | fepriv->thread); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 767 | } |
| 768 | |
NooneImportant | 83b75b0 | 2005-11-08 21:35:27 -0800 | [diff] [blame] | 769 | s32 timeval_usec_diff(struct timeval lasttime, struct timeval curtime) |
| 770 | { |
| 771 | return ((curtime.tv_usec < lasttime.tv_usec) ? |
| 772 | 1000000 - lasttime.tv_usec + curtime.tv_usec : |
| 773 | curtime.tv_usec - lasttime.tv_usec); |
| 774 | } |
| 775 | EXPORT_SYMBOL(timeval_usec_diff); |
| 776 | |
| 777 | static inline void timeval_usec_add(struct timeval *curtime, u32 add_usec) |
| 778 | { |
| 779 | curtime->tv_usec += add_usec; |
| 780 | if (curtime->tv_usec >= 1000000) { |
| 781 | curtime->tv_usec -= 1000000; |
| 782 | curtime->tv_sec++; |
| 783 | } |
| 784 | } |
| 785 | |
| 786 | /* |
| 787 | * Sleep until gettimeofday() > waketime + add_usec |
| 788 | * This needs to be as precise as possible, but as the delay is |
| 789 | * usually between 2ms and 32ms, it is done using a scheduled msleep |
| 790 | * followed by usleep (normally a busy-wait loop) for the remainder |
| 791 | */ |
| 792 | void dvb_frontend_sleep_until(struct timeval *waketime, u32 add_usec) |
| 793 | { |
| 794 | struct timeval lasttime; |
| 795 | s32 delta, newdelta; |
| 796 | |
| 797 | timeval_usec_add(waketime, add_usec); |
| 798 | |
| 799 | do_gettimeofday(&lasttime); |
| 800 | delta = timeval_usec_diff(lasttime, *waketime); |
| 801 | if (delta > 2500) { |
| 802 | msleep((delta - 1500) / 1000); |
| 803 | do_gettimeofday(&lasttime); |
| 804 | newdelta = timeval_usec_diff(lasttime, *waketime); |
| 805 | delta = (newdelta > delta) ? 0 : newdelta; |
| 806 | } |
| 807 | if (delta > 0) |
| 808 | udelay(delta); |
| 809 | } |
| 810 | EXPORT_SYMBOL(dvb_frontend_sleep_until); |
| 811 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 812 | static int dvb_frontend_start(struct dvb_frontend *fe) |
| 813 | { |
| 814 | int ret; |
Johannes Stezenbach | 0c53c70 | 2005-05-16 21:54:24 -0700 | [diff] [blame] | 815 | struct dvb_frontend_private *fepriv = fe->frontend_priv; |
Herbert Poetzl | 8eec142 | 2007-02-08 14:32:43 -0300 | [diff] [blame] | 816 | struct task_struct *fe_thread; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 817 | |
Harvey Harrison | 46b4f7c | 2008-04-08 23:20:00 -0300 | [diff] [blame] | 818 | dprintk ("%s\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 819 | |
Herbert Poetzl | 8eec142 | 2007-02-08 14:32:43 -0300 | [diff] [blame] | 820 | if (fepriv->thread) { |
matthieu castet | e36309f | 2010-05-05 15:59:20 -0300 | [diff] [blame] | 821 | if (fepriv->exit == DVB_FE_NO_EXIT) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 822 | return 0; |
| 823 | else |
| 824 | dvb_frontend_stop (fe); |
| 825 | } |
| 826 | |
| 827 | if (signal_pending(current)) |
| 828 | return -EINTR; |
| 829 | if (down_interruptible (&fepriv->sem)) |
| 830 | return -EINTR; |
| 831 | |
| 832 | fepriv->state = FESTATE_IDLE; |
matthieu castet | e36309f | 2010-05-05 15:59:20 -0300 | [diff] [blame] | 833 | fepriv->exit = DVB_FE_NO_EXIT; |
Herbert Poetzl | 8eec142 | 2007-02-08 14:32:43 -0300 | [diff] [blame] | 834 | fepriv->thread = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 835 | mb(); |
| 836 | |
Herbert Poetzl | 8eec142 | 2007-02-08 14:32:43 -0300 | [diff] [blame] | 837 | fe_thread = kthread_run(dvb_frontend_thread, fe, |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 838 | "kdvb-ad-%i-fe-%i", fe->dvb->num,fe->id); |
Herbert Poetzl | 8eec142 | 2007-02-08 14:32:43 -0300 | [diff] [blame] | 839 | if (IS_ERR(fe_thread)) { |
| 840 | ret = PTR_ERR(fe_thread); |
| 841 | printk("dvb_frontend_start: failed to start kthread (%d)\n", ret); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 842 | up(&fepriv->sem); |
| 843 | return ret; |
| 844 | } |
Herbert Poetzl | 8eec142 | 2007-02-08 14:32:43 -0300 | [diff] [blame] | 845 | fepriv->thread = fe_thread; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 846 | return 0; |
| 847 | } |
| 848 | |
Guillaume Audirac | 2030c03 | 2010-05-06 09:30:25 -0300 | [diff] [blame] | 849 | static void dvb_frontend_get_frequency_limits(struct dvb_frontend *fe, |
Oliver Endriss | c471b33 | 2007-08-09 01:03:42 -0300 | [diff] [blame] | 850 | u32 *freq_min, u32 *freq_max) |
| 851 | { |
| 852 | *freq_min = max(fe->ops.info.frequency_min, fe->ops.tuner_ops.info.frequency_min); |
| 853 | |
| 854 | if (fe->ops.info.frequency_max == 0) |
| 855 | *freq_max = fe->ops.tuner_ops.info.frequency_max; |
| 856 | else if (fe->ops.tuner_ops.info.frequency_max == 0) |
| 857 | *freq_max = fe->ops.info.frequency_max; |
| 858 | else |
| 859 | *freq_max = min(fe->ops.info.frequency_max, fe->ops.tuner_ops.info.frequency_max); |
| 860 | |
| 861 | if (*freq_min == 0 || *freq_max == 0) |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 862 | printk(KERN_WARNING "DVB: adapter %i frontend %u frequency limits undefined - fix the driver\n", |
| 863 | fe->dvb->num,fe->id); |
Oliver Endriss | c471b33 | 2007-08-09 01:03:42 -0300 | [diff] [blame] | 864 | } |
| 865 | |
Mauro Carvalho Chehab | 5bfaadd | 2012-01-01 16:11:13 -0300 | [diff] [blame] | 866 | static int dvb_frontend_check_parameters(struct dvb_frontend *fe) |
Oliver Endriss | 1fab46f | 2007-07-23 21:00:36 -0300 | [diff] [blame] | 867 | { |
Mauro Carvalho Chehab | 5bfaadd | 2012-01-01 16:11:13 -0300 | [diff] [blame] | 868 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; |
Oliver Endriss | c471b33 | 2007-08-09 01:03:42 -0300 | [diff] [blame] | 869 | u32 freq_min; |
| 870 | u32 freq_max; |
| 871 | |
Oliver Endriss | 1fab46f | 2007-07-23 21:00:36 -0300 | [diff] [blame] | 872 | /* range check: frequency */ |
Guillaume Audirac | 2030c03 | 2010-05-06 09:30:25 -0300 | [diff] [blame] | 873 | dvb_frontend_get_frequency_limits(fe, &freq_min, &freq_max); |
Mauro Carvalho Chehab | 5bfaadd | 2012-01-01 16:11:13 -0300 | [diff] [blame] | 874 | if ((freq_min && c->frequency < freq_min) || |
| 875 | (freq_max && c->frequency > freq_max)) { |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 876 | printk(KERN_WARNING "DVB: adapter %i frontend %i frequency %u out of range (%u..%u)\n", |
Mauro Carvalho Chehab | 5bfaadd | 2012-01-01 16:11:13 -0300 | [diff] [blame] | 877 | fe->dvb->num, fe->id, c->frequency, freq_min, freq_max); |
Oliver Endriss | 1fab46f | 2007-07-23 21:00:36 -0300 | [diff] [blame] | 878 | return -EINVAL; |
| 879 | } |
| 880 | |
| 881 | /* range check: symbol rate */ |
Mauro Carvalho Chehab | 5bfaadd | 2012-01-01 16:11:13 -0300 | [diff] [blame] | 882 | switch (c->delivery_system) { |
| 883 | case SYS_DVBS: |
| 884 | case SYS_DVBS2: |
| 885 | case SYS_TURBO: |
| 886 | case SYS_DVBC_ANNEX_A: |
| 887 | case SYS_DVBC_ANNEX_C: |
Oliver Endriss | 1fab46f | 2007-07-23 21:00:36 -0300 | [diff] [blame] | 888 | if ((fe->ops.info.symbol_rate_min && |
Mauro Carvalho Chehab | 5bfaadd | 2012-01-01 16:11:13 -0300 | [diff] [blame] | 889 | c->symbol_rate < fe->ops.info.symbol_rate_min) || |
Oliver Endriss | 1fab46f | 2007-07-23 21:00:36 -0300 | [diff] [blame] | 890 | (fe->ops.info.symbol_rate_max && |
Mauro Carvalho Chehab | 5bfaadd | 2012-01-01 16:11:13 -0300 | [diff] [blame] | 891 | c->symbol_rate > fe->ops.info.symbol_rate_max)) { |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 892 | printk(KERN_WARNING "DVB: adapter %i frontend %i symbol rate %u out of range (%u..%u)\n", |
Mauro Carvalho Chehab | 5bfaadd | 2012-01-01 16:11:13 -0300 | [diff] [blame] | 893 | fe->dvb->num, fe->id, c->symbol_rate, |
| 894 | fe->ops.info.symbol_rate_min, |
| 895 | fe->ops.info.symbol_rate_max); |
Oliver Endriss | 1fab46f | 2007-07-23 21:00:36 -0300 | [diff] [blame] | 896 | return -EINVAL; |
| 897 | } |
Mauro Carvalho Chehab | 5bfaadd | 2012-01-01 16:11:13 -0300 | [diff] [blame] | 898 | default: |
| 899 | break; |
Oliver Endriss | 1fab46f | 2007-07-23 21:00:36 -0300 | [diff] [blame] | 900 | } |
| 901 | |
| 902 | return 0; |
| 903 | } |
| 904 | |
Patrick Boettcher | b6e760f | 2009-08-03 14:39:15 -0300 | [diff] [blame] | 905 | static int dvb_frontend_clear_cache(struct dvb_frontend *fe) |
| 906 | { |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 907 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; |
Patrick Boettcher | b6e760f | 2009-08-03 14:39:15 -0300 | [diff] [blame] | 908 | int i; |
Mauro Carvalho Chehab | 149709f | 2012-01-13 11:46:36 -0200 | [diff] [blame] | 909 | u32 delsys; |
Patrick Boettcher | b6e760f | 2009-08-03 14:39:15 -0300 | [diff] [blame] | 910 | |
Mauro Carvalho Chehab | 149709f | 2012-01-13 11:46:36 -0200 | [diff] [blame] | 911 | delsys = c->delivery_system; |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 912 | memset(c, 0, sizeof(struct dtv_frontend_properties)); |
Mauro Carvalho Chehab | 149709f | 2012-01-13 11:46:36 -0200 | [diff] [blame] | 913 | c->delivery_system = delsys; |
Patrick Boettcher | b6e760f | 2009-08-03 14:39:15 -0300 | [diff] [blame] | 914 | |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 915 | c->state = DTV_CLEAR; |
Mauro Carvalho Chehab | 26c924f | 2012-01-01 16:11:10 -0300 | [diff] [blame] | 916 | |
Mauro Carvalho Chehab | 5bfaadd | 2012-01-01 16:11:13 -0300 | [diff] [blame] | 917 | dprintk("%s() Clearing cache for delivery system %d\n", __func__, |
| 918 | c->delivery_system); |
Mauro Carvalho Chehab | 26c924f | 2012-01-01 16:11:10 -0300 | [diff] [blame] | 919 | |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 920 | c->transmission_mode = TRANSMISSION_MODE_AUTO; |
Mauro Carvalho Chehab | 26c924f | 2012-01-01 16:11:10 -0300 | [diff] [blame] | 921 | c->bandwidth_hz = 0; /* AUTO */ |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 922 | c->guard_interval = GUARD_INTERVAL_AUTO; |
| 923 | c->hierarchy = HIERARCHY_AUTO; |
Mauro Carvalho Chehab | 26c924f | 2012-01-01 16:11:10 -0300 | [diff] [blame] | 924 | c->symbol_rate = 0; |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 925 | c->code_rate_HP = FEC_AUTO; |
| 926 | c->code_rate_LP = FEC_AUTO; |
Mauro Carvalho Chehab | 26c924f | 2012-01-01 16:11:10 -0300 | [diff] [blame] | 927 | c->fec_inner = FEC_AUTO; |
Mauro Carvalho Chehab | 39ce61a | 2011-11-11 12:46:23 -0200 | [diff] [blame] | 928 | c->rolloff = ROLLOFF_AUTO; |
Mauro Carvalho Chehab | 26c924f | 2012-01-01 16:11:10 -0300 | [diff] [blame] | 929 | c->voltage = SEC_VOLTAGE_OFF; |
Mauro Carvalho Chehab | 26c924f | 2012-01-01 16:11:10 -0300 | [diff] [blame] | 930 | c->sectone = SEC_TONE_OFF; |
| 931 | c->pilot = PILOT_AUTO; |
Patrick Boettcher | b6e760f | 2009-08-03 14:39:15 -0300 | [diff] [blame] | 932 | |
Mauro Carvalho Chehab | a520ca9 | 2012-01-01 16:11:15 -0300 | [diff] [blame] | 933 | c->isdbt_partial_reception = 0; |
| 934 | c->isdbt_sb_mode = 0; |
| 935 | c->isdbt_sb_subchannel = 0; |
| 936 | c->isdbt_sb_segment_idx = 0; |
| 937 | c->isdbt_sb_segment_count = 0; |
| 938 | c->isdbt_layer_enabled = 0; |
Patrick Boettcher | b6e760f | 2009-08-03 14:39:15 -0300 | [diff] [blame] | 939 | for (i = 0; i < 3; i++) { |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 940 | c->layer[i].fec = FEC_AUTO; |
| 941 | c->layer[i].modulation = QAM_AUTO; |
Mauro Carvalho Chehab | a520ca9 | 2012-01-01 16:11:15 -0300 | [diff] [blame] | 942 | c->layer[i].interleaving = 0; |
| 943 | c->layer[i].segment_count = 0; |
Patrick Boettcher | b6e760f | 2009-08-03 14:39:15 -0300 | [diff] [blame] | 944 | } |
| 945 | |
Mauro Carvalho Chehab | 26c924f | 2012-01-01 16:11:10 -0300 | [diff] [blame] | 946 | c->isdbs_ts_id = 0; |
| 947 | c->dvbt2_plp_id = 0; |
| 948 | |
Mauro Carvalho Chehab | 5bfaadd | 2012-01-01 16:11:13 -0300 | [diff] [blame] | 949 | switch (c->delivery_system) { |
| 950 | case SYS_DVBS: |
| 951 | case SYS_DVBS2: |
| 952 | case SYS_TURBO: |
| 953 | c->modulation = QPSK; /* implied for DVB-S in legacy API */ |
| 954 | c->rolloff = ROLLOFF_35;/* implied for DVB-S */ |
| 955 | break; |
| 956 | case SYS_ATSC: |
| 957 | c->modulation = VSB_8; |
| 958 | break; |
| 959 | default: |
| 960 | c->modulation = QAM_AUTO; |
| 961 | break; |
| 962 | } |
| 963 | |
Patrick Boettcher | b6e760f | 2009-08-03 14:39:15 -0300 | [diff] [blame] | 964 | return 0; |
| 965 | } |
| 966 | |
| 967 | #define _DTV_CMD(n, s, b) \ |
| 968 | [n] = { \ |
| 969 | .name = #n, \ |
| 970 | .cmd = n, \ |
| 971 | .set = s,\ |
| 972 | .buffer = b \ |
| 973 | } |
| 974 | |
Andreas Oberritter | ec05a64 | 2011-05-26 07:54:14 -0300 | [diff] [blame] | 975 | static struct dtv_cmds_h dtv_cmds[DTV_MAX_COMMAND + 1] = { |
Mauro Carvalho Chehab | 06d3a39 | 2009-10-23 20:09:42 -0300 | [diff] [blame] | 976 | _DTV_CMD(DTV_TUNE, 1, 0), |
| 977 | _DTV_CMD(DTV_CLEAR, 1, 0), |
Steven Toth | 6b73eea | 2008-09-04 01:12:25 -0300 | [diff] [blame] | 978 | |
| 979 | /* Set */ |
Mauro Carvalho Chehab | 06d3a39 | 2009-10-23 20:09:42 -0300 | [diff] [blame] | 980 | _DTV_CMD(DTV_FREQUENCY, 1, 0), |
| 981 | _DTV_CMD(DTV_BANDWIDTH_HZ, 1, 0), |
| 982 | _DTV_CMD(DTV_MODULATION, 1, 0), |
| 983 | _DTV_CMD(DTV_INVERSION, 1, 0), |
| 984 | _DTV_CMD(DTV_DISEQC_MASTER, 1, 1), |
| 985 | _DTV_CMD(DTV_SYMBOL_RATE, 1, 0), |
| 986 | _DTV_CMD(DTV_INNER_FEC, 1, 0), |
| 987 | _DTV_CMD(DTV_VOLTAGE, 1, 0), |
| 988 | _DTV_CMD(DTV_TONE, 1, 0), |
| 989 | _DTV_CMD(DTV_PILOT, 1, 0), |
| 990 | _DTV_CMD(DTV_ROLLOFF, 1, 0), |
| 991 | _DTV_CMD(DTV_DELIVERY_SYSTEM, 1, 0), |
| 992 | _DTV_CMD(DTV_HIERARCHY, 1, 0), |
| 993 | _DTV_CMD(DTV_CODE_RATE_HP, 1, 0), |
| 994 | _DTV_CMD(DTV_CODE_RATE_LP, 1, 0), |
| 995 | _DTV_CMD(DTV_GUARD_INTERVAL, 1, 0), |
| 996 | _DTV_CMD(DTV_TRANSMISSION_MODE, 1, 0), |
Patrick Boettcher | b6e760f | 2009-08-03 14:39:15 -0300 | [diff] [blame] | 997 | |
| 998 | _DTV_CMD(DTV_ISDBT_PARTIAL_RECEPTION, 1, 0), |
| 999 | _DTV_CMD(DTV_ISDBT_SOUND_BROADCASTING, 1, 0), |
| 1000 | _DTV_CMD(DTV_ISDBT_SB_SUBCHANNEL_ID, 1, 0), |
| 1001 | _DTV_CMD(DTV_ISDBT_SB_SEGMENT_IDX, 1, 0), |
| 1002 | _DTV_CMD(DTV_ISDBT_SB_SEGMENT_COUNT, 1, 0), |
Patrick Boettcher | e7b7949 | 2009-08-14 05:24:19 -0300 | [diff] [blame] | 1003 | _DTV_CMD(DTV_ISDBT_LAYER_ENABLED, 1, 0), |
Patrick Boettcher | b6e760f | 2009-08-03 14:39:15 -0300 | [diff] [blame] | 1004 | _DTV_CMD(DTV_ISDBT_LAYERA_FEC, 1, 0), |
| 1005 | _DTV_CMD(DTV_ISDBT_LAYERA_MODULATION, 1, 0), |
| 1006 | _DTV_CMD(DTV_ISDBT_LAYERA_SEGMENT_COUNT, 1, 0), |
| 1007 | _DTV_CMD(DTV_ISDBT_LAYERA_TIME_INTERLEAVING, 1, 0), |
| 1008 | _DTV_CMD(DTV_ISDBT_LAYERB_FEC, 1, 0), |
| 1009 | _DTV_CMD(DTV_ISDBT_LAYERB_MODULATION, 1, 0), |
| 1010 | _DTV_CMD(DTV_ISDBT_LAYERB_SEGMENT_COUNT, 1, 0), |
| 1011 | _DTV_CMD(DTV_ISDBT_LAYERB_TIME_INTERLEAVING, 1, 0), |
| 1012 | _DTV_CMD(DTV_ISDBT_LAYERC_FEC, 1, 0), |
| 1013 | _DTV_CMD(DTV_ISDBT_LAYERC_MODULATION, 1, 0), |
| 1014 | _DTV_CMD(DTV_ISDBT_LAYERC_SEGMENT_COUNT, 1, 0), |
| 1015 | _DTV_CMD(DTV_ISDBT_LAYERC_TIME_INTERLEAVING, 1, 0), |
| 1016 | |
HIRANO Takahito | 98293ef | 2009-09-18 11:17:54 -0300 | [diff] [blame] | 1017 | _DTV_CMD(DTV_ISDBS_TS_ID, 1, 0), |
Andreas Oberritter | ec05a64 | 2011-05-26 07:54:14 -0300 | [diff] [blame] | 1018 | _DTV_CMD(DTV_DVBT2_PLP_ID, 1, 0), |
HIRANO Takahito | 98293ef | 2009-09-18 11:17:54 -0300 | [diff] [blame] | 1019 | |
Steven Toth | 6b73eea | 2008-09-04 01:12:25 -0300 | [diff] [blame] | 1020 | /* Get */ |
Mauro Carvalho Chehab | 06d3a39 | 2009-10-23 20:09:42 -0300 | [diff] [blame] | 1021 | _DTV_CMD(DTV_DISEQC_SLAVE_REPLY, 0, 1), |
| 1022 | _DTV_CMD(DTV_API_VERSION, 0, 0), |
| 1023 | _DTV_CMD(DTV_CODE_RATE_HP, 0, 0), |
| 1024 | _DTV_CMD(DTV_CODE_RATE_LP, 0, 0), |
| 1025 | _DTV_CMD(DTV_GUARD_INTERVAL, 0, 0), |
| 1026 | _DTV_CMD(DTV_TRANSMISSION_MODE, 0, 0), |
| 1027 | _DTV_CMD(DTV_HIERARCHY, 0, 0), |
Manu Abraham | ba2780c | 2011-11-13 18:47:44 -0300 | [diff] [blame] | 1028 | |
| 1029 | _DTV_CMD(DTV_ENUM_DELSYS, 0, 0), |
Steven Toth | 6b73eea | 2008-09-04 01:12:25 -0300 | [diff] [blame] | 1030 | }; |
| 1031 | |
Mauro Carvalho Chehab | 072ce0c | 2009-01-05 01:19:06 -0300 | [diff] [blame] | 1032 | static void dtv_property_dump(struct dtv_property *tvp) |
Steven Toth | 6b73eea | 2008-09-04 01:12:25 -0300 | [diff] [blame] | 1033 | { |
| 1034 | int i; |
| 1035 | |
Mauro Carvalho Chehab | 106ff9e | 2011-07-15 08:49:06 -0300 | [diff] [blame] | 1036 | if (tvp->cmd <= 0 || tvp->cmd > DTV_MAX_COMMAND) { |
Steven Toth | a1bc84c | 2008-10-17 00:20:19 -0300 | [diff] [blame] | 1037 | printk(KERN_WARNING "%s: tvp.cmd = 0x%08x undefined\n", |
Darron Broad | 4aae8ef | 2008-10-03 11:50:00 -0300 | [diff] [blame] | 1038 | __func__, tvp->cmd); |
| 1039 | return; |
| 1040 | } |
| 1041 | |
Steven Toth | a1bc84c | 2008-10-17 00:20:19 -0300 | [diff] [blame] | 1042 | dprintk("%s() tvp.cmd = 0x%08x (%s)\n" |
| 1043 | ,__func__ |
Steven Toth | 6b73eea | 2008-09-04 01:12:25 -0300 | [diff] [blame] | 1044 | ,tvp->cmd |
Steven Toth | 56f0680 | 2008-09-11 10:19:27 -0300 | [diff] [blame] | 1045 | ,dtv_cmds[ tvp->cmd ].name); |
Steven Toth | 6b73eea | 2008-09-04 01:12:25 -0300 | [diff] [blame] | 1046 | |
Steven Toth | 56f0680 | 2008-09-11 10:19:27 -0300 | [diff] [blame] | 1047 | if(dtv_cmds[ tvp->cmd ].buffer) { |
Steven Toth | 6b73eea | 2008-09-04 01:12:25 -0300 | [diff] [blame] | 1048 | |
Steven Toth | a1bc84c | 2008-10-17 00:20:19 -0300 | [diff] [blame] | 1049 | dprintk("%s() tvp.u.buffer.len = 0x%02x\n" |
| 1050 | ,__func__ |
Steven Toth | 6b73eea | 2008-09-04 01:12:25 -0300 | [diff] [blame] | 1051 | ,tvp->u.buffer.len); |
| 1052 | |
| 1053 | for(i = 0; i < tvp->u.buffer.len; i++) |
Steven Toth | a1bc84c | 2008-10-17 00:20:19 -0300 | [diff] [blame] | 1054 | dprintk("%s() tvp.u.buffer.data[0x%02x] = 0x%02x\n" |
| 1055 | ,__func__ |
Steven Toth | 6b73eea | 2008-09-04 01:12:25 -0300 | [diff] [blame] | 1056 | ,i |
| 1057 | ,tvp->u.buffer.data[i]); |
| 1058 | |
| 1059 | } else |
Steven Toth | a1bc84c | 2008-10-17 00:20:19 -0300 | [diff] [blame] | 1060 | dprintk("%s() tvp.u.data = 0x%08x\n", __func__, tvp->u.data); |
Steven Toth | 6b73eea | 2008-09-04 01:12:25 -0300 | [diff] [blame] | 1061 | } |
| 1062 | |
Steven Toth | ee33c52 | 2008-09-11 23:52:32 -0300 | [diff] [blame] | 1063 | /* Synchronise the legacy tuning parameters into the cache, so that demodulator |
| 1064 | * drivers can use a single set_frontend tuning function, regardless of whether |
| 1065 | * it's being used for the legacy or new API, reducing code and complexity. |
| 1066 | */ |
Mauro Carvalho Chehab | 5bfaadd | 2012-01-01 16:11:13 -0300 | [diff] [blame] | 1067 | static int dtv_property_cache_sync(struct dvb_frontend *fe, |
| 1068 | struct dtv_frontend_properties *c, |
| 1069 | const struct dvb_frontend_parameters *p) |
Steven Toth | ee33c52 | 2008-09-11 23:52:32 -0300 | [diff] [blame] | 1070 | { |
Steven Toth | ee33c52 | 2008-09-11 23:52:32 -0300 | [diff] [blame] | 1071 | c->frequency = p->frequency; |
| 1072 | c->inversion = p->inversion; |
| 1073 | |
Mauro Carvalho Chehab | 5bfaadd | 2012-01-01 16:11:13 -0300 | [diff] [blame] | 1074 | switch (dvbv3_type(c->delivery_system)) { |
| 1075 | case DVBV3_QPSK: |
| 1076 | dprintk("%s() Preparing QPSK req\n", __func__); |
Steven Toth | ee33c52 | 2008-09-11 23:52:32 -0300 | [diff] [blame] | 1077 | c->symbol_rate = p->u.qpsk.symbol_rate; |
| 1078 | c->fec_inner = p->u.qpsk.fec_inner; |
| 1079 | break; |
Mauro Carvalho Chehab | 5bfaadd | 2012-01-01 16:11:13 -0300 | [diff] [blame] | 1080 | case DVBV3_QAM: |
| 1081 | dprintk("%s() Preparing QAM req\n", __func__); |
Steven Toth | ee33c52 | 2008-09-11 23:52:32 -0300 | [diff] [blame] | 1082 | c->symbol_rate = p->u.qam.symbol_rate; |
| 1083 | c->fec_inner = p->u.qam.fec_inner; |
| 1084 | c->modulation = p->u.qam.modulation; |
| 1085 | break; |
Mauro Carvalho Chehab | 5bfaadd | 2012-01-01 16:11:13 -0300 | [diff] [blame] | 1086 | case DVBV3_OFDM: |
| 1087 | dprintk("%s() Preparing OFDM req\n", __func__); |
Mauro Carvalho Chehab | 9a27e6a | 2012-01-01 16:11:11 -0300 | [diff] [blame] | 1088 | switch (p->u.ofdm.bandwidth) { |
| 1089 | case BANDWIDTH_10_MHZ: |
| 1090 | c->bandwidth_hz = 10000000; |
| 1091 | break; |
| 1092 | case BANDWIDTH_8_MHZ: |
Steven Toth | 75b7f94 | 2008-09-13 16:56:34 -0300 | [diff] [blame] | 1093 | c->bandwidth_hz = 8000000; |
Mauro Carvalho Chehab | 9a27e6a | 2012-01-01 16:11:11 -0300 | [diff] [blame] | 1094 | break; |
| 1095 | case BANDWIDTH_7_MHZ: |
| 1096 | c->bandwidth_hz = 7000000; |
| 1097 | break; |
| 1098 | case BANDWIDTH_6_MHZ: |
| 1099 | c->bandwidth_hz = 6000000; |
| 1100 | break; |
| 1101 | case BANDWIDTH_5_MHZ: |
| 1102 | c->bandwidth_hz = 5000000; |
| 1103 | break; |
| 1104 | case BANDWIDTH_1_712_MHZ: |
| 1105 | c->bandwidth_hz = 1712000; |
| 1106 | break; |
| 1107 | case BANDWIDTH_AUTO: |
Steven Toth | 75b7f94 | 2008-09-13 16:56:34 -0300 | [diff] [blame] | 1108 | c->bandwidth_hz = 0; |
Mauro Carvalho Chehab | 9a27e6a | 2012-01-01 16:11:11 -0300 | [diff] [blame] | 1109 | } |
| 1110 | |
Steven Toth | ee33c52 | 2008-09-11 23:52:32 -0300 | [diff] [blame] | 1111 | c->code_rate_HP = p->u.ofdm.code_rate_HP; |
| 1112 | c->code_rate_LP = p->u.ofdm.code_rate_LP; |
| 1113 | c->modulation = p->u.ofdm.constellation; |
| 1114 | c->transmission_mode = p->u.ofdm.transmission_mode; |
| 1115 | c->guard_interval = p->u.ofdm.guard_interval; |
| 1116 | c->hierarchy = p->u.ofdm.hierarchy_information; |
| 1117 | break; |
Mauro Carvalho Chehab | 5bfaadd | 2012-01-01 16:11:13 -0300 | [diff] [blame] | 1118 | case DVBV3_ATSC: |
| 1119 | dprintk("%s() Preparing ATSC req\n", __func__); |
Steven Toth | ee33c52 | 2008-09-11 23:52:32 -0300 | [diff] [blame] | 1120 | c->modulation = p->u.vsb.modulation; |
Steven Toth | 80a773c | 2008-09-12 00:53:50 -0300 | [diff] [blame] | 1121 | if ((c->modulation == VSB_8) || (c->modulation == VSB_16)) |
| 1122 | c->delivery_system = SYS_ATSC; |
| 1123 | else |
| 1124 | c->delivery_system = SYS_DVBC_ANNEX_B; |
Steven Toth | ee33c52 | 2008-09-11 23:52:32 -0300 | [diff] [blame] | 1125 | break; |
Mauro Carvalho Chehab | 5bfaadd | 2012-01-01 16:11:13 -0300 | [diff] [blame] | 1126 | case DVBV3_UNKNOWN: |
| 1127 | printk(KERN_ERR |
| 1128 | "%s: doesn't know how to handle a DVBv3 call to delivery system %i\n", |
| 1129 | __func__, c->delivery_system); |
| 1130 | return -EINVAL; |
Steven Toth | ee33c52 | 2008-09-11 23:52:32 -0300 | [diff] [blame] | 1131 | } |
Mauro Carvalho Chehab | 5bfaadd | 2012-01-01 16:11:13 -0300 | [diff] [blame] | 1132 | |
| 1133 | return 0; |
Steven Toth | ee33c52 | 2008-09-11 23:52:32 -0300 | [diff] [blame] | 1134 | } |
| 1135 | |
Steven Toth | d5748f1 | 2008-09-12 00:27:13 -0300 | [diff] [blame] | 1136 | /* Ensure the cached values are set correctly in the frontend |
| 1137 | * legacy tuning structures, for the advanced tuning API. |
| 1138 | */ |
Mauro Carvalho Chehab | 5bfaadd | 2012-01-01 16:11:13 -0300 | [diff] [blame] | 1139 | static int dtv_property_legacy_params_sync(struct dvb_frontend *fe, |
Mauro Carvalho Chehab | a689e36 | 2011-12-22 14:47:48 -0300 | [diff] [blame] | 1140 | struct dvb_frontend_parameters *p) |
Steven Toth | 6b73eea | 2008-09-04 01:12:25 -0300 | [diff] [blame] | 1141 | { |
Andreas Oberritter | 15cc2bb | 2011-05-08 20:03:35 -0300 | [diff] [blame] | 1142 | const struct dtv_frontend_properties *c = &fe->dtv_property_cache; |
Steven Toth | 6b73eea | 2008-09-04 01:12:25 -0300 | [diff] [blame] | 1143 | |
Steven Toth | d5748f1 | 2008-09-12 00:27:13 -0300 | [diff] [blame] | 1144 | p->frequency = c->frequency; |
| 1145 | p->inversion = c->inversion; |
| 1146 | |
Mauro Carvalho Chehab | 5bfaadd | 2012-01-01 16:11:13 -0300 | [diff] [blame] | 1147 | switch (dvbv3_type(c->delivery_system)) { |
| 1148 | case DVBV3_UNKNOWN: |
| 1149 | printk(KERN_ERR |
| 1150 | "%s: doesn't know how to handle a DVBv3 call to delivery system %i\n", |
| 1151 | __func__, c->delivery_system); |
| 1152 | return -EINVAL; |
| 1153 | case DVBV3_QPSK: |
Steven Toth | a1bc84c | 2008-10-17 00:20:19 -0300 | [diff] [blame] | 1154 | dprintk("%s() Preparing QPSK req\n", __func__); |
Steven Toth | d5748f1 | 2008-09-12 00:27:13 -0300 | [diff] [blame] | 1155 | p->u.qpsk.symbol_rate = c->symbol_rate; |
| 1156 | p->u.qpsk.fec_inner = c->fec_inner; |
| 1157 | break; |
Mauro Carvalho Chehab | 5bfaadd | 2012-01-01 16:11:13 -0300 | [diff] [blame] | 1158 | case DVBV3_QAM: |
Steven Toth | a1bc84c | 2008-10-17 00:20:19 -0300 | [diff] [blame] | 1159 | dprintk("%s() Preparing QAM req\n", __func__); |
Steven Toth | d5748f1 | 2008-09-12 00:27:13 -0300 | [diff] [blame] | 1160 | p->u.qam.symbol_rate = c->symbol_rate; |
| 1161 | p->u.qam.fec_inner = c->fec_inner; |
| 1162 | p->u.qam.modulation = c->modulation; |
| 1163 | break; |
Mauro Carvalho Chehab | 5bfaadd | 2012-01-01 16:11:13 -0300 | [diff] [blame] | 1164 | case DVBV3_OFDM: |
Steven Toth | a1bc84c | 2008-10-17 00:20:19 -0300 | [diff] [blame] | 1165 | dprintk("%s() Preparing OFDM req\n", __func__); |
Mauro Carvalho Chehab | 5bfaadd | 2012-01-01 16:11:13 -0300 | [diff] [blame] | 1166 | |
Mauro Carvalho Chehab | 9a27e6a | 2012-01-01 16:11:11 -0300 | [diff] [blame] | 1167 | switch (c->bandwidth_hz) { |
| 1168 | case 10000000: |
| 1169 | p->u.ofdm.bandwidth = BANDWIDTH_10_MHZ; |
| 1170 | break; |
| 1171 | case 8000000: |
Steven Toth | 75b7f94 | 2008-09-13 16:56:34 -0300 | [diff] [blame] | 1172 | p->u.ofdm.bandwidth = BANDWIDTH_8_MHZ; |
Mauro Carvalho Chehab | 9a27e6a | 2012-01-01 16:11:11 -0300 | [diff] [blame] | 1173 | break; |
| 1174 | case 7000000: |
| 1175 | p->u.ofdm.bandwidth = BANDWIDTH_7_MHZ; |
| 1176 | break; |
| 1177 | case 6000000: |
| 1178 | p->u.ofdm.bandwidth = BANDWIDTH_6_MHZ; |
| 1179 | break; |
| 1180 | case 5000000: |
| 1181 | p->u.ofdm.bandwidth = BANDWIDTH_5_MHZ; |
| 1182 | break; |
| 1183 | case 1712000: |
| 1184 | p->u.ofdm.bandwidth = BANDWIDTH_1_712_MHZ; |
| 1185 | break; |
| 1186 | case 0: |
| 1187 | default: |
Steven Toth | 75b7f94 | 2008-09-13 16:56:34 -0300 | [diff] [blame] | 1188 | p->u.ofdm.bandwidth = BANDWIDTH_AUTO; |
Mauro Carvalho Chehab | 9a27e6a | 2012-01-01 16:11:11 -0300 | [diff] [blame] | 1189 | } |
Steven Toth | d5748f1 | 2008-09-12 00:27:13 -0300 | [diff] [blame] | 1190 | p->u.ofdm.code_rate_HP = c->code_rate_HP; |
| 1191 | p->u.ofdm.code_rate_LP = c->code_rate_LP; |
| 1192 | p->u.ofdm.constellation = c->modulation; |
| 1193 | p->u.ofdm.transmission_mode = c->transmission_mode; |
| 1194 | p->u.ofdm.guard_interval = c->guard_interval; |
| 1195 | p->u.ofdm.hierarchy_information = c->hierarchy; |
| 1196 | break; |
Mauro Carvalho Chehab | 5bfaadd | 2012-01-01 16:11:13 -0300 | [diff] [blame] | 1197 | case DVBV3_ATSC: |
Steven Toth | a1bc84c | 2008-10-17 00:20:19 -0300 | [diff] [blame] | 1198 | dprintk("%s() Preparing VSB req\n", __func__); |
Steven Toth | d5748f1 | 2008-09-12 00:27:13 -0300 | [diff] [blame] | 1199 | p->u.vsb.modulation = c->modulation; |
| 1200 | break; |
| 1201 | } |
Mauro Carvalho Chehab | 5bfaadd | 2012-01-01 16:11:13 -0300 | [diff] [blame] | 1202 | return 0; |
Steven Toth | 6b73eea | 2008-09-04 01:12:25 -0300 | [diff] [blame] | 1203 | } |
| 1204 | |
Mauro Carvalho Chehab | a689e36 | 2011-12-22 14:47:48 -0300 | [diff] [blame] | 1205 | /** |
| 1206 | * dtv_get_frontend - calls a callback for retrieving DTV parameters |
| 1207 | * @fe: struct dvb_frontend pointer |
| 1208 | * @c: struct dtv_frontend_properties pointer (DVBv5 cache) |
| 1209 | * @p_out struct dvb_frontend_parameters pointer (DVBv3 FE struct) |
| 1210 | * |
| 1211 | * This routine calls either the DVBv3 or DVBv5 get_frontend call. |
| 1212 | * If c is not null, it will update the DVBv5 cache struct pointed by it. |
| 1213 | * If p_out is not null, it will update the DVBv3 params pointed by it. |
| 1214 | */ |
| 1215 | static int dtv_get_frontend(struct dvb_frontend *fe, |
Mauro Carvalho Chehab | a689e36 | 2011-12-22 14:47:48 -0300 | [diff] [blame] | 1216 | struct dvb_frontend_parameters *p_out) |
| 1217 | { |
Mauro Carvalho Chehab | a689e36 | 2011-12-22 14:47:48 -0300 | [diff] [blame] | 1218 | int r; |
| 1219 | |
Mauro Carvalho Chehab | a689e36 | 2011-12-22 14:47:48 -0300 | [diff] [blame] | 1220 | if (fe->ops.get_frontend) { |
Mauro Carvalho Chehab | 7c61d80 | 2011-12-30 11:30:21 -0300 | [diff] [blame] | 1221 | r = fe->ops.get_frontend(fe); |
Mauro Carvalho Chehab | a689e36 | 2011-12-22 14:47:48 -0300 | [diff] [blame] | 1222 | if (unlikely(r < 0)) |
| 1223 | return r; |
Mauro Carvalho Chehab | 7c61d80 | 2011-12-30 11:30:21 -0300 | [diff] [blame] | 1224 | if (p_out) |
Mauro Carvalho Chehab | a689e36 | 2011-12-22 14:47:48 -0300 | [diff] [blame] | 1225 | dtv_property_legacy_params_sync(fe, p_out); |
| 1226 | return 0; |
| 1227 | } |
| 1228 | |
Mauro Carvalho Chehab | 7c61d80 | 2011-12-30 11:30:21 -0300 | [diff] [blame] | 1229 | /* As everything is in cache, get_frontend fops are always supported */ |
Mauro Carvalho Chehab | b1e9a6501 | 2011-12-26 16:43:32 -0300 | [diff] [blame] | 1230 | return 0; |
Mauro Carvalho Chehab | a689e36 | 2011-12-22 14:47:48 -0300 | [diff] [blame] | 1231 | } |
| 1232 | |
Arnd Bergmann | 16ef8de | 2010-04-27 00:24:00 +0200 | [diff] [blame] | 1233 | static int dvb_frontend_ioctl_legacy(struct file *file, |
Steven Toth | 13c97bf | 2008-09-04 21:19:43 -0300 | [diff] [blame] | 1234 | unsigned int cmd, void *parg); |
Arnd Bergmann | 16ef8de | 2010-04-27 00:24:00 +0200 | [diff] [blame] | 1235 | static int dvb_frontend_ioctl_properties(struct file *file, |
Steven Toth | 13c97bf | 2008-09-04 21:19:43 -0300 | [diff] [blame] | 1236 | unsigned int cmd, void *parg); |
| 1237 | |
Mauro Carvalho Chehab | 072ce0c | 2009-01-05 01:19:06 -0300 | [diff] [blame] | 1238 | static int dtv_property_process_get(struct dvb_frontend *fe, |
Mauro Carvalho Chehab | a689e36 | 2011-12-22 14:47:48 -0300 | [diff] [blame] | 1239 | const struct dtv_frontend_properties *c, |
Mauro Carvalho Chehab | 072ce0c | 2009-01-05 01:19:06 -0300 | [diff] [blame] | 1240 | struct dtv_property *tvp, |
Arnd Bergmann | 16ef8de | 2010-04-27 00:24:00 +0200 | [diff] [blame] | 1241 | struct file *file) |
Steven Toth | 363429a | 2008-09-12 01:34:28 -0300 | [diff] [blame] | 1242 | { |
Mauro Carvalho Chehab | 5bfaadd | 2012-01-01 16:11:13 -0300 | [diff] [blame] | 1243 | int r, ncaps; |
Steven Toth | bfbf2da | 2008-09-12 01:37:37 -0300 | [diff] [blame] | 1244 | |
Steven Toth | 363429a | 2008-09-12 01:34:28 -0300 | [diff] [blame] | 1245 | switch(tvp->cmd) { |
Manu Abraham | ba2780c | 2011-11-13 18:47:44 -0300 | [diff] [blame] | 1246 | case DTV_ENUM_DELSYS: |
Mauro Carvalho Chehab | 5bfaadd | 2012-01-01 16:11:13 -0300 | [diff] [blame] | 1247 | ncaps = 0; |
| 1248 | while (fe->ops.delsys[ncaps] && ncaps < MAX_DELSYS) { |
| 1249 | tvp->u.buffer.data[ncaps] = fe->ops.delsys[ncaps]; |
| 1250 | ncaps++; |
| 1251 | } |
| 1252 | tvp->u.buffer.len = ncaps; |
Manu Abraham | ba2780c | 2011-11-13 18:47:44 -0300 | [diff] [blame] | 1253 | break; |
Steven Toth | 363429a | 2008-09-12 01:34:28 -0300 | [diff] [blame] | 1254 | case DTV_FREQUENCY: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1255 | tvp->u.data = c->frequency; |
Steven Toth | 363429a | 2008-09-12 01:34:28 -0300 | [diff] [blame] | 1256 | break; |
| 1257 | case DTV_MODULATION: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1258 | tvp->u.data = c->modulation; |
Steven Toth | 363429a | 2008-09-12 01:34:28 -0300 | [diff] [blame] | 1259 | break; |
Steven Toth | 75b7f94 | 2008-09-13 16:56:34 -0300 | [diff] [blame] | 1260 | case DTV_BANDWIDTH_HZ: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1261 | tvp->u.data = c->bandwidth_hz; |
Steven Toth | 363429a | 2008-09-12 01:34:28 -0300 | [diff] [blame] | 1262 | break; |
| 1263 | case DTV_INVERSION: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1264 | tvp->u.data = c->inversion; |
Steven Toth | 363429a | 2008-09-12 01:34:28 -0300 | [diff] [blame] | 1265 | break; |
| 1266 | case DTV_SYMBOL_RATE: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1267 | tvp->u.data = c->symbol_rate; |
Steven Toth | 363429a | 2008-09-12 01:34:28 -0300 | [diff] [blame] | 1268 | break; |
| 1269 | case DTV_INNER_FEC: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1270 | tvp->u.data = c->fec_inner; |
Steven Toth | 363429a | 2008-09-12 01:34:28 -0300 | [diff] [blame] | 1271 | break; |
| 1272 | case DTV_PILOT: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1273 | tvp->u.data = c->pilot; |
Steven Toth | 363429a | 2008-09-12 01:34:28 -0300 | [diff] [blame] | 1274 | break; |
| 1275 | case DTV_ROLLOFF: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1276 | tvp->u.data = c->rolloff; |
Steven Toth | 363429a | 2008-09-12 01:34:28 -0300 | [diff] [blame] | 1277 | break; |
| 1278 | case DTV_DELIVERY_SYSTEM: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1279 | tvp->u.data = c->delivery_system; |
Steven Toth | 363429a | 2008-09-12 01:34:28 -0300 | [diff] [blame] | 1280 | break; |
Steven Toth | 363429a | 2008-09-12 01:34:28 -0300 | [diff] [blame] | 1281 | case DTV_VOLTAGE: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1282 | tvp->u.data = c->voltage; |
Steven Toth | 363429a | 2008-09-12 01:34:28 -0300 | [diff] [blame] | 1283 | break; |
| 1284 | case DTV_TONE: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1285 | tvp->u.data = c->sectone; |
Steven Toth | 363429a | 2008-09-12 01:34:28 -0300 | [diff] [blame] | 1286 | break; |
Steven Toth | eacf8d8 | 2008-09-26 00:29:49 -0300 | [diff] [blame] | 1287 | case DTV_API_VERSION: |
| 1288 | tvp->u.data = (DVB_API_VERSION << 8) | DVB_API_VERSION_MINOR; |
| 1289 | break; |
Steven Toth | a4de91b | 2008-10-06 21:55:46 -0300 | [diff] [blame] | 1290 | case DTV_CODE_RATE_HP: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1291 | tvp->u.data = c->code_rate_HP; |
Steven Toth | a4de91b | 2008-10-06 21:55:46 -0300 | [diff] [blame] | 1292 | break; |
| 1293 | case DTV_CODE_RATE_LP: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1294 | tvp->u.data = c->code_rate_LP; |
Steven Toth | a4de91b | 2008-10-06 21:55:46 -0300 | [diff] [blame] | 1295 | break; |
Steven Toth | b87625f | 2008-10-06 21:56:59 -0300 | [diff] [blame] | 1296 | case DTV_GUARD_INTERVAL: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1297 | tvp->u.data = c->guard_interval; |
Steven Toth | b87625f | 2008-10-06 21:56:59 -0300 | [diff] [blame] | 1298 | break; |
| 1299 | case DTV_TRANSMISSION_MODE: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1300 | tvp->u.data = c->transmission_mode; |
Steven Toth | b87625f | 2008-10-06 21:56:59 -0300 | [diff] [blame] | 1301 | break; |
Steven Toth | ef526f4 | 2008-10-06 22:01:47 -0300 | [diff] [blame] | 1302 | case DTV_HIERARCHY: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1303 | tvp->u.data = c->hierarchy; |
Steven Toth | ef526f4 | 2008-10-06 22:01:47 -0300 | [diff] [blame] | 1304 | break; |
Patrick Boettcher | b6e760f | 2009-08-03 14:39:15 -0300 | [diff] [blame] | 1305 | |
| 1306 | /* ISDB-T Support here */ |
| 1307 | case DTV_ISDBT_PARTIAL_RECEPTION: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1308 | tvp->u.data = c->isdbt_partial_reception; |
Patrick Boettcher | b6e760f | 2009-08-03 14:39:15 -0300 | [diff] [blame] | 1309 | break; |
| 1310 | case DTV_ISDBT_SOUND_BROADCASTING: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1311 | tvp->u.data = c->isdbt_sb_mode; |
Patrick Boettcher | b6e760f | 2009-08-03 14:39:15 -0300 | [diff] [blame] | 1312 | break; |
| 1313 | case DTV_ISDBT_SB_SUBCHANNEL_ID: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1314 | tvp->u.data = c->isdbt_sb_subchannel; |
Patrick Boettcher | b6e760f | 2009-08-03 14:39:15 -0300 | [diff] [blame] | 1315 | break; |
| 1316 | case DTV_ISDBT_SB_SEGMENT_IDX: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1317 | tvp->u.data = c->isdbt_sb_segment_idx; |
Patrick Boettcher | b6e760f | 2009-08-03 14:39:15 -0300 | [diff] [blame] | 1318 | break; |
| 1319 | case DTV_ISDBT_SB_SEGMENT_COUNT: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1320 | tvp->u.data = c->isdbt_sb_segment_count; |
Patrick Boettcher | b6e760f | 2009-08-03 14:39:15 -0300 | [diff] [blame] | 1321 | break; |
Patrick Boettcher | e7b7949 | 2009-08-14 05:24:19 -0300 | [diff] [blame] | 1322 | case DTV_ISDBT_LAYER_ENABLED: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1323 | tvp->u.data = c->isdbt_layer_enabled; |
Patrick Boettcher | e7b7949 | 2009-08-14 05:24:19 -0300 | [diff] [blame] | 1324 | break; |
Patrick Boettcher | b6e760f | 2009-08-03 14:39:15 -0300 | [diff] [blame] | 1325 | case DTV_ISDBT_LAYERA_FEC: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1326 | tvp->u.data = c->layer[0].fec; |
Patrick Boettcher | b6e760f | 2009-08-03 14:39:15 -0300 | [diff] [blame] | 1327 | break; |
| 1328 | case DTV_ISDBT_LAYERA_MODULATION: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1329 | tvp->u.data = c->layer[0].modulation; |
Patrick Boettcher | b6e760f | 2009-08-03 14:39:15 -0300 | [diff] [blame] | 1330 | break; |
| 1331 | case DTV_ISDBT_LAYERA_SEGMENT_COUNT: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1332 | tvp->u.data = c->layer[0].segment_count; |
Patrick Boettcher | b6e760f | 2009-08-03 14:39:15 -0300 | [diff] [blame] | 1333 | break; |
| 1334 | case DTV_ISDBT_LAYERA_TIME_INTERLEAVING: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1335 | tvp->u.data = c->layer[0].interleaving; |
Patrick Boettcher | b6e760f | 2009-08-03 14:39:15 -0300 | [diff] [blame] | 1336 | break; |
| 1337 | case DTV_ISDBT_LAYERB_FEC: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1338 | tvp->u.data = c->layer[1].fec; |
Patrick Boettcher | b6e760f | 2009-08-03 14:39:15 -0300 | [diff] [blame] | 1339 | break; |
| 1340 | case DTV_ISDBT_LAYERB_MODULATION: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1341 | tvp->u.data = c->layer[1].modulation; |
Patrick Boettcher | b6e760f | 2009-08-03 14:39:15 -0300 | [diff] [blame] | 1342 | break; |
| 1343 | case DTV_ISDBT_LAYERB_SEGMENT_COUNT: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1344 | tvp->u.data = c->layer[1].segment_count; |
Patrick Boettcher | b6e760f | 2009-08-03 14:39:15 -0300 | [diff] [blame] | 1345 | break; |
| 1346 | case DTV_ISDBT_LAYERB_TIME_INTERLEAVING: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1347 | tvp->u.data = c->layer[1].interleaving; |
Patrick Boettcher | b6e760f | 2009-08-03 14:39:15 -0300 | [diff] [blame] | 1348 | break; |
| 1349 | case DTV_ISDBT_LAYERC_FEC: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1350 | tvp->u.data = c->layer[2].fec; |
Patrick Boettcher | b6e760f | 2009-08-03 14:39:15 -0300 | [diff] [blame] | 1351 | break; |
| 1352 | case DTV_ISDBT_LAYERC_MODULATION: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1353 | tvp->u.data = c->layer[2].modulation; |
Patrick Boettcher | b6e760f | 2009-08-03 14:39:15 -0300 | [diff] [blame] | 1354 | break; |
| 1355 | case DTV_ISDBT_LAYERC_SEGMENT_COUNT: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1356 | tvp->u.data = c->layer[2].segment_count; |
Patrick Boettcher | b6e760f | 2009-08-03 14:39:15 -0300 | [diff] [blame] | 1357 | break; |
| 1358 | case DTV_ISDBT_LAYERC_TIME_INTERLEAVING: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1359 | tvp->u.data = c->layer[2].interleaving; |
Patrick Boettcher | b6e760f | 2009-08-03 14:39:15 -0300 | [diff] [blame] | 1360 | break; |
HIRANO Takahito | 98293ef | 2009-09-18 11:17:54 -0300 | [diff] [blame] | 1361 | case DTV_ISDBS_TS_ID: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1362 | tvp->u.data = c->isdbs_ts_id; |
HIRANO Takahito | 98293ef | 2009-09-18 11:17:54 -0300 | [diff] [blame] | 1363 | break; |
Andreas Oberritter | 94d56ff | 2011-05-12 18:11:06 -0300 | [diff] [blame] | 1364 | case DTV_DVBT2_PLP_ID: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1365 | tvp->u.data = c->dvbt2_plp_id; |
Andreas Oberritter | 94d56ff | 2011-05-12 18:11:06 -0300 | [diff] [blame] | 1366 | break; |
Steven Toth | 363429a | 2008-09-12 01:34:28 -0300 | [diff] [blame] | 1367 | default: |
Andreas Oberritter | aff8ab5 | 2011-05-09 00:03:34 +0100 | [diff] [blame] | 1368 | return -EINVAL; |
Steven Toth | 363429a | 2008-09-12 01:34:28 -0300 | [diff] [blame] | 1369 | } |
| 1370 | |
Andreas Oberritter | e23d9ae | 2011-05-08 20:03:36 -0300 | [diff] [blame] | 1371 | /* Allow the frontend to override outgoing properties */ |
| 1372 | if (fe->ops.get_property) { |
| 1373 | r = fe->ops.get_property(fe, tvp); |
| 1374 | if (r < 0) |
| 1375 | return r; |
| 1376 | } |
| 1377 | |
Mauro Carvalho Chehab | 639544d | 2009-12-31 17:49:32 -0300 | [diff] [blame] | 1378 | dtv_property_dump(tvp); |
| 1379 | |
Andreas Oberritter | aff8ab5 | 2011-05-09 00:03:34 +0100 | [diff] [blame] | 1380 | return 0; |
Steven Toth | 363429a | 2008-09-12 01:34:28 -0300 | [diff] [blame] | 1381 | } |
| 1382 | |
Mauro Carvalho Chehab | 5bfaadd | 2012-01-01 16:11:13 -0300 | [diff] [blame] | 1383 | static int dtv_set_frontend(struct dvb_frontend *fe); |
| 1384 | |
Mauro Carvalho Chehab | 04be0f7 | 2012-01-01 16:11:14 -0300 | [diff] [blame] | 1385 | static bool is_dvbv3_delsys(u32 delsys) |
| 1386 | { |
| 1387 | bool status; |
| 1388 | |
| 1389 | status = (delsys == SYS_DVBT) || (delsys == SYS_DVBC_ANNEX_A) || |
| 1390 | (delsys == SYS_DVBS) || (delsys == SYS_ATSC); |
| 1391 | |
| 1392 | return status; |
| 1393 | } |
| 1394 | |
| 1395 | static int set_delivery_system(struct dvb_frontend *fe, u32 desired_system) |
| 1396 | { |
| 1397 | int ncaps, i; |
| 1398 | u32 delsys = SYS_UNDEFINED; |
| 1399 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; |
| 1400 | enum dvbv3_emulation_type type; |
| 1401 | |
Mauro Carvalho Chehab | f4b1952 | 2012-01-13 11:09:23 -0200 | [diff] [blame] | 1402 | /* |
| 1403 | * It was reported that some old DVBv5 applications were |
| 1404 | * filling delivery_system with SYS_UNDEFINED. If this happens, |
| 1405 | * assume that the application wants to use the first supported |
| 1406 | * delivery system. |
| 1407 | */ |
| 1408 | if (c->delivery_system == SYS_UNDEFINED) |
| 1409 | c->delivery_system = fe->ops.delsys[0]; |
| 1410 | |
Mauro Carvalho Chehab | 04be0f7 | 2012-01-01 16:11:14 -0300 | [diff] [blame] | 1411 | if (desired_system == SYS_UNDEFINED) { |
| 1412 | /* |
| 1413 | * A DVBv3 call doesn't know what's the desired system. |
Mauro Carvalho Chehab | 37fa53c | 2012-01-05 14:39:05 -0200 | [diff] [blame] | 1414 | * Also, DVBv3 applications don't know that ops.info->type |
| 1415 | * could be changed, and they simply dies when it doesn't |
| 1416 | * match. |
| 1417 | * So, don't change the current delivery system, as it |
| 1418 | * may be trying to do the wrong thing, like setting an |
| 1419 | * ISDB-T frontend as DVB-T. Instead, find the closest |
| 1420 | * DVBv3 system that matches the delivery system. |
Mauro Carvalho Chehab | 04be0f7 | 2012-01-01 16:11:14 -0300 | [diff] [blame] | 1421 | */ |
| 1422 | if (is_dvbv3_delsys(c->delivery_system)) { |
| 1423 | dprintk("%s() Using delivery system to %d\n", |
| 1424 | __func__, c->delivery_system); |
| 1425 | return 0; |
| 1426 | } |
| 1427 | type = dvbv3_type(c->delivery_system); |
| 1428 | switch (type) { |
| 1429 | case DVBV3_QPSK: |
Mauro Carvalho Chehab | 37fa53c | 2012-01-05 14:39:05 -0200 | [diff] [blame] | 1430 | desired_system = SYS_DVBS; |
Mauro Carvalho Chehab | 04be0f7 | 2012-01-01 16:11:14 -0300 | [diff] [blame] | 1431 | break; |
| 1432 | case DVBV3_QAM: |
Mauro Carvalho Chehab | 37fa53c | 2012-01-05 14:39:05 -0200 | [diff] [blame] | 1433 | desired_system = SYS_DVBC_ANNEX_A; |
Mauro Carvalho Chehab | 04be0f7 | 2012-01-01 16:11:14 -0300 | [diff] [blame] | 1434 | break; |
| 1435 | case DVBV3_ATSC: |
Mauro Carvalho Chehab | 37fa53c | 2012-01-05 14:39:05 -0200 | [diff] [blame] | 1436 | desired_system = SYS_ATSC; |
Mauro Carvalho Chehab | 04be0f7 | 2012-01-01 16:11:14 -0300 | [diff] [blame] | 1437 | break; |
| 1438 | case DVBV3_OFDM: |
Mauro Carvalho Chehab | 37fa53c | 2012-01-05 14:39:05 -0200 | [diff] [blame] | 1439 | desired_system = SYS_DVBT; |
Mauro Carvalho Chehab | 04be0f7 | 2012-01-01 16:11:14 -0300 | [diff] [blame] | 1440 | break; |
| 1441 | default: |
| 1442 | dprintk("%s(): This frontend doesn't support DVBv3 calls\n", |
| 1443 | __func__); |
| 1444 | return -EINVAL; |
| 1445 | } |
Mauro Carvalho Chehab | 04be0f7 | 2012-01-01 16:11:14 -0300 | [diff] [blame] | 1446 | } else { |
| 1447 | /* |
Mauro Carvalho Chehab | 37fa53c | 2012-01-05 14:39:05 -0200 | [diff] [blame] | 1448 | * This is a DVBv5 call. So, it likely knows the supported |
| 1449 | * delivery systems. |
Mauro Carvalho Chehab | 04be0f7 | 2012-01-01 16:11:14 -0300 | [diff] [blame] | 1450 | */ |
Mauro Carvalho Chehab | 37fa53c | 2012-01-05 14:39:05 -0200 | [diff] [blame] | 1451 | |
| 1452 | /* Check if the desired delivery system is supported */ |
Mauro Carvalho Chehab | 04be0f7 | 2012-01-01 16:11:14 -0300 | [diff] [blame] | 1453 | ncaps = 0; |
| 1454 | while (fe->ops.delsys[ncaps] && ncaps < MAX_DELSYS) { |
| 1455 | if (fe->ops.delsys[ncaps] == desired_system) { |
| 1456 | c->delivery_system = desired_system; |
| 1457 | dprintk("%s() Changing delivery system to %d\n", |
| 1458 | __func__, desired_system); |
| 1459 | return 0; |
| 1460 | } |
Mauro Carvalho Chehab | 6c4b78c | 2012-01-05 11:24:41 -0200 | [diff] [blame] | 1461 | ncaps++; |
Mauro Carvalho Chehab | 04be0f7 | 2012-01-01 16:11:14 -0300 | [diff] [blame] | 1462 | } |
| 1463 | type = dvbv3_type(desired_system); |
| 1464 | |
| 1465 | /* |
| 1466 | * The delivery system is not supported. See if it can be |
| 1467 | * emulated. |
| 1468 | * The emulation only works if the desired system is one of the |
| 1469 | * DVBv3 delivery systems |
| 1470 | */ |
| 1471 | if (!is_dvbv3_delsys(desired_system)) { |
| 1472 | dprintk("%s() can't use a DVBv3 FE_SET_FRONTEND call on this frontend\n", |
| 1473 | __func__); |
| 1474 | return -EINVAL; |
| 1475 | } |
| 1476 | |
| 1477 | /* |
| 1478 | * Get the last non-DVBv3 delivery system that has the same type |
| 1479 | * of the desired system |
| 1480 | */ |
| 1481 | ncaps = 0; |
| 1482 | while (fe->ops.delsys[ncaps] && ncaps < MAX_DELSYS) { |
| 1483 | if ((dvbv3_type(fe->ops.delsys[ncaps]) == type) && |
| 1484 | !is_dvbv3_delsys(fe->ops.delsys[ncaps])) |
| 1485 | delsys = fe->ops.delsys[ncaps]; |
| 1486 | ncaps++; |
| 1487 | } |
| 1488 | /* There's nothing compatible with the desired delivery system */ |
| 1489 | if (delsys == SYS_UNDEFINED) { |
| 1490 | dprintk("%s() Incompatible DVBv3 FE_SET_FRONTEND call for this frontend\n", |
| 1491 | __func__); |
| 1492 | return -EINVAL; |
| 1493 | } |
| 1494 | c->delivery_system = delsys; |
| 1495 | } |
| 1496 | |
| 1497 | /* |
Mauro Carvalho Chehab | 37fa53c | 2012-01-05 14:39:05 -0200 | [diff] [blame] | 1498 | * The DVBv3 or DVBv5 call is requesting a different system. So, |
| 1499 | * emulation is needed. |
| 1500 | * |
Mauro Carvalho Chehab | 04be0f7 | 2012-01-01 16:11:14 -0300 | [diff] [blame] | 1501 | * Emulate newer delivery systems like ISDBT, DVBT and DMBTH |
| 1502 | * for older DVBv5 applications. The emulation will try to use |
| 1503 | * the auto mode for most things, and will assume that the desired |
| 1504 | * delivery system is the last one at the ops.delsys[] array |
| 1505 | */ |
| 1506 | dprintk("%s() Using delivery system %d emulated as if it were a %d\n", |
| 1507 | __func__, delsys, desired_system); |
| 1508 | |
| 1509 | /* |
Mauro Carvalho Chehab | a520ca9 | 2012-01-01 16:11:15 -0300 | [diff] [blame] | 1510 | * For now, handles ISDB-T calls. More code may be needed here for the |
| 1511 | * other emulated stuff |
Mauro Carvalho Chehab | 04be0f7 | 2012-01-01 16:11:14 -0300 | [diff] [blame] | 1512 | */ |
| 1513 | if (type == DVBV3_OFDM) { |
Mauro Carvalho Chehab | a520ca9 | 2012-01-01 16:11:15 -0300 | [diff] [blame] | 1514 | if (c->delivery_system == SYS_ISDBT) { |
| 1515 | dprintk("%s() Using defaults for SYS_ISDBT\n", |
| 1516 | __func__); |
| 1517 | if (!c->bandwidth_hz) |
| 1518 | c->bandwidth_hz = 6000000; |
Mauro Carvalho Chehab | 04be0f7 | 2012-01-01 16:11:14 -0300 | [diff] [blame] | 1519 | |
Mauro Carvalho Chehab | a520ca9 | 2012-01-01 16:11:15 -0300 | [diff] [blame] | 1520 | c->isdbt_partial_reception = 0; |
| 1521 | c->isdbt_sb_mode = 0; |
| 1522 | c->isdbt_sb_subchannel = 0; |
| 1523 | c->isdbt_sb_segment_idx = 0; |
| 1524 | c->isdbt_sb_segment_count = 0; |
| 1525 | c->isdbt_layer_enabled = 0; |
| 1526 | for (i = 0; i < 3; i++) { |
| 1527 | c->layer[i].fec = FEC_AUTO; |
| 1528 | c->layer[i].modulation = QAM_AUTO; |
| 1529 | c->layer[i].interleaving = 0; |
| 1530 | c->layer[i].segment_count = 0; |
| 1531 | } |
Mauro Carvalho Chehab | 04be0f7 | 2012-01-01 16:11:14 -0300 | [diff] [blame] | 1532 | } |
| 1533 | } |
Mauro Carvalho Chehab | 9474c5e | 2012-01-05 12:28:20 -0200 | [diff] [blame] | 1534 | dprintk("change delivery system on cache to %d\n", c->delivery_system); |
| 1535 | |
Mauro Carvalho Chehab | 04be0f7 | 2012-01-01 16:11:14 -0300 | [diff] [blame] | 1536 | return 0; |
| 1537 | } |
| 1538 | |
Mauro Carvalho Chehab | 072ce0c | 2009-01-05 01:19:06 -0300 | [diff] [blame] | 1539 | static int dtv_property_process_set(struct dvb_frontend *fe, |
| 1540 | struct dtv_property *tvp, |
Mauro Carvalho Chehab | 072ce0c | 2009-01-05 01:19:06 -0300 | [diff] [blame] | 1541 | struct file *file) |
Steven Toth | 6b73eea | 2008-09-04 01:12:25 -0300 | [diff] [blame] | 1542 | { |
| 1543 | int r = 0; |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1544 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; |
Steven Toth | 6b73eea | 2008-09-04 01:12:25 -0300 | [diff] [blame] | 1545 | |
Steven Toth | bfbf2da | 2008-09-12 01:37:37 -0300 | [diff] [blame] | 1546 | /* Allow the frontend to validate incoming properties */ |
Andreas Oberritter | aff8ab5 | 2011-05-09 00:03:34 +0100 | [diff] [blame] | 1547 | if (fe->ops.set_property) { |
Steven Toth | bfbf2da | 2008-09-12 01:37:37 -0300 | [diff] [blame] | 1548 | r = fe->ops.set_property(fe, tvp); |
Andreas Oberritter | aff8ab5 | 2011-05-09 00:03:34 +0100 | [diff] [blame] | 1549 | if (r < 0) |
| 1550 | return r; |
| 1551 | } |
Steven Toth | bfbf2da | 2008-09-12 01:37:37 -0300 | [diff] [blame] | 1552 | |
Steven Toth | 6b73eea | 2008-09-04 01:12:25 -0300 | [diff] [blame] | 1553 | switch(tvp->cmd) { |
Steven Toth | e7fee0f3 | 2008-09-11 10:23:01 -0300 | [diff] [blame] | 1554 | case DTV_CLEAR: |
Mauro Carvalho Chehab | 5bfaadd | 2012-01-01 16:11:13 -0300 | [diff] [blame] | 1555 | /* |
| 1556 | * Reset a cache of data specific to the frontend here. This does |
Steven Toth | 6b73eea | 2008-09-04 01:12:25 -0300 | [diff] [blame] | 1557 | * not effect hardware. |
| 1558 | */ |
Patrick Boettcher | b6e760f | 2009-08-03 14:39:15 -0300 | [diff] [blame] | 1559 | dvb_frontend_clear_cache(fe); |
Steven Toth | 6b73eea | 2008-09-04 01:12:25 -0300 | [diff] [blame] | 1560 | break; |
Steven Toth | e7fee0f3 | 2008-09-11 10:23:01 -0300 | [diff] [blame] | 1561 | case DTV_TUNE: |
Steven Toth | 6b73eea | 2008-09-04 01:12:25 -0300 | [diff] [blame] | 1562 | /* interpret the cache of data, build either a traditional frontend |
Steven Toth | d5748f1 | 2008-09-12 00:27:13 -0300 | [diff] [blame] | 1563 | * tunerequest so we can pass validation in the FE_SET_FRONTEND |
| 1564 | * ioctl. |
Steven Toth | 6b73eea | 2008-09-04 01:12:25 -0300 | [diff] [blame] | 1565 | */ |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1566 | c->state = tvp->cmd; |
Steven Toth | a1bc84c | 2008-10-17 00:20:19 -0300 | [diff] [blame] | 1567 | dprintk("%s() Finalised property cache\n", __func__); |
Steven Toth | d5748f1 | 2008-09-12 00:27:13 -0300 | [diff] [blame] | 1568 | |
Mauro Carvalho Chehab | 5bfaadd | 2012-01-01 16:11:13 -0300 | [diff] [blame] | 1569 | r = dtv_set_frontend(fe); |
Steven Toth | 6b73eea | 2008-09-04 01:12:25 -0300 | [diff] [blame] | 1570 | break; |
Steven Toth | 363429a | 2008-09-12 01:34:28 -0300 | [diff] [blame] | 1571 | case DTV_FREQUENCY: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1572 | c->frequency = tvp->u.data; |
Steven Toth | 6b73eea | 2008-09-04 01:12:25 -0300 | [diff] [blame] | 1573 | break; |
Steven Toth | 363429a | 2008-09-12 01:34:28 -0300 | [diff] [blame] | 1574 | case DTV_MODULATION: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1575 | c->modulation = tvp->u.data; |
Steven Toth | 6b73eea | 2008-09-04 01:12:25 -0300 | [diff] [blame] | 1576 | break; |
Steven Toth | 75b7f94 | 2008-09-13 16:56:34 -0300 | [diff] [blame] | 1577 | case DTV_BANDWIDTH_HZ: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1578 | c->bandwidth_hz = tvp->u.data; |
Steven Toth | 6b73eea | 2008-09-04 01:12:25 -0300 | [diff] [blame] | 1579 | break; |
Steven Toth | 363429a | 2008-09-12 01:34:28 -0300 | [diff] [blame] | 1580 | case DTV_INVERSION: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1581 | c->inversion = tvp->u.data; |
Steven Toth | 6b73eea | 2008-09-04 01:12:25 -0300 | [diff] [blame] | 1582 | break; |
Steven Toth | 363429a | 2008-09-12 01:34:28 -0300 | [diff] [blame] | 1583 | case DTV_SYMBOL_RATE: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1584 | c->symbol_rate = tvp->u.data; |
Steven Toth | 6b73eea | 2008-09-04 01:12:25 -0300 | [diff] [blame] | 1585 | break; |
Steven Toth | 363429a | 2008-09-12 01:34:28 -0300 | [diff] [blame] | 1586 | case DTV_INNER_FEC: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1587 | c->fec_inner = tvp->u.data; |
Steven Toth | 6b73eea | 2008-09-04 01:12:25 -0300 | [diff] [blame] | 1588 | break; |
Steven Toth | 363429a | 2008-09-12 01:34:28 -0300 | [diff] [blame] | 1589 | case DTV_PILOT: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1590 | c->pilot = tvp->u.data; |
Steven Toth | 6b73eea | 2008-09-04 01:12:25 -0300 | [diff] [blame] | 1591 | break; |
Steven Toth | 363429a | 2008-09-12 01:34:28 -0300 | [diff] [blame] | 1592 | case DTV_ROLLOFF: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1593 | c->rolloff = tvp->u.data; |
Steven Toth | 6b73eea | 2008-09-04 01:12:25 -0300 | [diff] [blame] | 1594 | break; |
Steven Toth | 363429a | 2008-09-12 01:34:28 -0300 | [diff] [blame] | 1595 | case DTV_DELIVERY_SYSTEM: |
Mauro Carvalho Chehab | 04be0f7 | 2012-01-01 16:11:14 -0300 | [diff] [blame] | 1596 | r = set_delivery_system(fe, tvp->u.data); |
Steven Toth | 6b73eea | 2008-09-04 01:12:25 -0300 | [diff] [blame] | 1597 | break; |
Steven Toth | 363429a | 2008-09-12 01:34:28 -0300 | [diff] [blame] | 1598 | case DTV_VOLTAGE: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1599 | c->voltage = tvp->u.data; |
Arnd Bergmann | 16ef8de | 2010-04-27 00:24:00 +0200 | [diff] [blame] | 1600 | r = dvb_frontend_ioctl_legacy(file, FE_SET_VOLTAGE, |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1601 | (void *)c->voltage); |
Steven Toth | 13c97bf | 2008-09-04 21:19:43 -0300 | [diff] [blame] | 1602 | break; |
Steven Toth | 363429a | 2008-09-12 01:34:28 -0300 | [diff] [blame] | 1603 | case DTV_TONE: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1604 | c->sectone = tvp->u.data; |
Arnd Bergmann | 16ef8de | 2010-04-27 00:24:00 +0200 | [diff] [blame] | 1605 | r = dvb_frontend_ioctl_legacy(file, FE_SET_TONE, |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1606 | (void *)c->sectone); |
Steven Toth | 13c97bf | 2008-09-04 21:19:43 -0300 | [diff] [blame] | 1607 | break; |
Steven Toth | a4de91b | 2008-10-06 21:55:46 -0300 | [diff] [blame] | 1608 | case DTV_CODE_RATE_HP: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1609 | c->code_rate_HP = tvp->u.data; |
Steven Toth | a4de91b | 2008-10-06 21:55:46 -0300 | [diff] [blame] | 1610 | break; |
| 1611 | case DTV_CODE_RATE_LP: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1612 | c->code_rate_LP = tvp->u.data; |
Steven Toth | a4de91b | 2008-10-06 21:55:46 -0300 | [diff] [blame] | 1613 | break; |
Steven Toth | b87625f | 2008-10-06 21:56:59 -0300 | [diff] [blame] | 1614 | case DTV_GUARD_INTERVAL: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1615 | c->guard_interval = tvp->u.data; |
Steven Toth | b87625f | 2008-10-06 21:56:59 -0300 | [diff] [blame] | 1616 | break; |
| 1617 | case DTV_TRANSMISSION_MODE: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1618 | c->transmission_mode = tvp->u.data; |
Steven Toth | b87625f | 2008-10-06 21:56:59 -0300 | [diff] [blame] | 1619 | break; |
Steven Toth | ef526f4 | 2008-10-06 22:01:47 -0300 | [diff] [blame] | 1620 | case DTV_HIERARCHY: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1621 | c->hierarchy = tvp->u.data; |
Steven Toth | ef526f4 | 2008-10-06 22:01:47 -0300 | [diff] [blame] | 1622 | break; |
Patrick Boettcher | b6e760f | 2009-08-03 14:39:15 -0300 | [diff] [blame] | 1623 | |
| 1624 | /* ISDB-T Support here */ |
| 1625 | case DTV_ISDBT_PARTIAL_RECEPTION: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1626 | c->isdbt_partial_reception = tvp->u.data; |
Patrick Boettcher | b6e760f | 2009-08-03 14:39:15 -0300 | [diff] [blame] | 1627 | break; |
| 1628 | case DTV_ISDBT_SOUND_BROADCASTING: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1629 | c->isdbt_sb_mode = tvp->u.data; |
Patrick Boettcher | b6e760f | 2009-08-03 14:39:15 -0300 | [diff] [blame] | 1630 | break; |
| 1631 | case DTV_ISDBT_SB_SUBCHANNEL_ID: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1632 | c->isdbt_sb_subchannel = tvp->u.data; |
Patrick Boettcher | b6e760f | 2009-08-03 14:39:15 -0300 | [diff] [blame] | 1633 | break; |
| 1634 | case DTV_ISDBT_SB_SEGMENT_IDX: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1635 | c->isdbt_sb_segment_idx = tvp->u.data; |
Patrick Boettcher | b6e760f | 2009-08-03 14:39:15 -0300 | [diff] [blame] | 1636 | break; |
| 1637 | case DTV_ISDBT_SB_SEGMENT_COUNT: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1638 | c->isdbt_sb_segment_count = tvp->u.data; |
Patrick Boettcher | b6e760f | 2009-08-03 14:39:15 -0300 | [diff] [blame] | 1639 | break; |
Patrick Boettcher | e7b7949 | 2009-08-14 05:24:19 -0300 | [diff] [blame] | 1640 | case DTV_ISDBT_LAYER_ENABLED: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1641 | c->isdbt_layer_enabled = tvp->u.data; |
Patrick Boettcher | e7b7949 | 2009-08-14 05:24:19 -0300 | [diff] [blame] | 1642 | break; |
Patrick Boettcher | b6e760f | 2009-08-03 14:39:15 -0300 | [diff] [blame] | 1643 | case DTV_ISDBT_LAYERA_FEC: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1644 | c->layer[0].fec = tvp->u.data; |
Patrick Boettcher | b6e760f | 2009-08-03 14:39:15 -0300 | [diff] [blame] | 1645 | break; |
| 1646 | case DTV_ISDBT_LAYERA_MODULATION: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1647 | c->layer[0].modulation = tvp->u.data; |
Patrick Boettcher | b6e760f | 2009-08-03 14:39:15 -0300 | [diff] [blame] | 1648 | break; |
| 1649 | case DTV_ISDBT_LAYERA_SEGMENT_COUNT: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1650 | c->layer[0].segment_count = tvp->u.data; |
Patrick Boettcher | b6e760f | 2009-08-03 14:39:15 -0300 | [diff] [blame] | 1651 | break; |
| 1652 | case DTV_ISDBT_LAYERA_TIME_INTERLEAVING: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1653 | c->layer[0].interleaving = tvp->u.data; |
Patrick Boettcher | b6e760f | 2009-08-03 14:39:15 -0300 | [diff] [blame] | 1654 | break; |
| 1655 | case DTV_ISDBT_LAYERB_FEC: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1656 | c->layer[1].fec = tvp->u.data; |
Patrick Boettcher | b6e760f | 2009-08-03 14:39:15 -0300 | [diff] [blame] | 1657 | break; |
| 1658 | case DTV_ISDBT_LAYERB_MODULATION: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1659 | c->layer[1].modulation = tvp->u.data; |
Patrick Boettcher | b6e760f | 2009-08-03 14:39:15 -0300 | [diff] [blame] | 1660 | break; |
| 1661 | case DTV_ISDBT_LAYERB_SEGMENT_COUNT: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1662 | c->layer[1].segment_count = tvp->u.data; |
Patrick Boettcher | b6e760f | 2009-08-03 14:39:15 -0300 | [diff] [blame] | 1663 | break; |
| 1664 | case DTV_ISDBT_LAYERB_TIME_INTERLEAVING: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1665 | c->layer[1].interleaving = tvp->u.data; |
Patrick Boettcher | b6e760f | 2009-08-03 14:39:15 -0300 | [diff] [blame] | 1666 | break; |
| 1667 | case DTV_ISDBT_LAYERC_FEC: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1668 | c->layer[2].fec = tvp->u.data; |
Patrick Boettcher | b6e760f | 2009-08-03 14:39:15 -0300 | [diff] [blame] | 1669 | break; |
| 1670 | case DTV_ISDBT_LAYERC_MODULATION: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1671 | c->layer[2].modulation = tvp->u.data; |
Patrick Boettcher | b6e760f | 2009-08-03 14:39:15 -0300 | [diff] [blame] | 1672 | break; |
| 1673 | case DTV_ISDBT_LAYERC_SEGMENT_COUNT: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1674 | c->layer[2].segment_count = tvp->u.data; |
Patrick Boettcher | b6e760f | 2009-08-03 14:39:15 -0300 | [diff] [blame] | 1675 | break; |
| 1676 | case DTV_ISDBT_LAYERC_TIME_INTERLEAVING: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1677 | c->layer[2].interleaving = tvp->u.data; |
Patrick Boettcher | b6e760f | 2009-08-03 14:39:15 -0300 | [diff] [blame] | 1678 | break; |
HIRANO Takahito | 98293ef | 2009-09-18 11:17:54 -0300 | [diff] [blame] | 1679 | case DTV_ISDBS_TS_ID: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1680 | c->isdbs_ts_id = tvp->u.data; |
HIRANO Takahito | 98293ef | 2009-09-18 11:17:54 -0300 | [diff] [blame] | 1681 | break; |
Andreas Oberritter | 94d56ff | 2011-05-12 18:11:06 -0300 | [diff] [blame] | 1682 | case DTV_DVBT2_PLP_ID: |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1683 | c->dvbt2_plp_id = tvp->u.data; |
Andreas Oberritter | 94d56ff | 2011-05-12 18:11:06 -0300 | [diff] [blame] | 1684 | break; |
Steven Toth | 363429a | 2008-09-12 01:34:28 -0300 | [diff] [blame] | 1685 | default: |
Andreas Oberritter | aff8ab5 | 2011-05-09 00:03:34 +0100 | [diff] [blame] | 1686 | return -EINVAL; |
Steven Toth | 6b73eea | 2008-09-04 01:12:25 -0300 | [diff] [blame] | 1687 | } |
| 1688 | |
Steven Toth | 13c97bf | 2008-09-04 21:19:43 -0300 | [diff] [blame] | 1689 | return r; |
Steven Toth | 6b73eea | 2008-09-04 01:12:25 -0300 | [diff] [blame] | 1690 | } |
| 1691 | |
Arnd Bergmann | 16ef8de | 2010-04-27 00:24:00 +0200 | [diff] [blame] | 1692 | static int dvb_frontend_ioctl(struct file *file, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1693 | unsigned int cmd, void *parg) |
| 1694 | { |
| 1695 | struct dvb_device *dvbdev = file->private_data; |
| 1696 | struct dvb_frontend *fe = dvbdev->priv; |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1697 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; |
Johannes Stezenbach | 0c53c70 | 2005-05-16 21:54:24 -0700 | [diff] [blame] | 1698 | struct dvb_frontend_private *fepriv = fe->frontend_priv; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1699 | int err = -EOPNOTSUPP; |
| 1700 | |
Mauro Carvalho Chehab | fb8253b | 2009-12-31 18:14:54 -0300 | [diff] [blame] | 1701 | dprintk("%s (%d)\n", __func__, _IOC_NR(cmd)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1702 | |
matthieu castet | e36309f | 2010-05-05 15:59:20 -0300 | [diff] [blame] | 1703 | if (fepriv->exit != DVB_FE_NO_EXIT) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1704 | return -ENODEV; |
| 1705 | |
| 1706 | if ((file->f_flags & O_ACCMODE) == O_RDONLY && |
| 1707 | (_IOC_DIR(cmd) != _IOC_READ || cmd == FE_GET_EVENT || |
| 1708 | cmd == FE_DISEQC_RECV_SLAVE_REPLY)) |
| 1709 | return -EPERM; |
| 1710 | |
| 1711 | if (down_interruptible (&fepriv->sem)) |
| 1712 | return -ERESTARTSYS; |
| 1713 | |
Steven Toth | 13c97bf | 2008-09-04 21:19:43 -0300 | [diff] [blame] | 1714 | if ((cmd == FE_SET_PROPERTY) || (cmd == FE_GET_PROPERTY)) |
Arnd Bergmann | 16ef8de | 2010-04-27 00:24:00 +0200 | [diff] [blame] | 1715 | err = dvb_frontend_ioctl_properties(file, cmd, parg); |
Steven Toth | 4dd88be | 2008-09-13 15:09:07 -0300 | [diff] [blame] | 1716 | else { |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1717 | c->state = DTV_UNDEFINED; |
Arnd Bergmann | 16ef8de | 2010-04-27 00:24:00 +0200 | [diff] [blame] | 1718 | err = dvb_frontend_ioctl_legacy(file, cmd, parg); |
Steven Toth | 4dd88be | 2008-09-13 15:09:07 -0300 | [diff] [blame] | 1719 | } |
Steven Toth | 13c97bf | 2008-09-04 21:19:43 -0300 | [diff] [blame] | 1720 | |
| 1721 | up(&fepriv->sem); |
| 1722 | return err; |
| 1723 | } |
| 1724 | |
Arnd Bergmann | 16ef8de | 2010-04-27 00:24:00 +0200 | [diff] [blame] | 1725 | static int dvb_frontend_ioctl_properties(struct file *file, |
Steven Toth | 13c97bf | 2008-09-04 21:19:43 -0300 | [diff] [blame] | 1726 | unsigned int cmd, void *parg) |
| 1727 | { |
| 1728 | struct dvb_device *dvbdev = file->private_data; |
| 1729 | struct dvb_frontend *fe = dvbdev->priv; |
Mauro Carvalho Chehab | 51dcb19 | 2012-01-17 16:20:37 -0200 | [diff] [blame] | 1730 | struct dvb_frontend_private *fepriv = fe->frontend_priv; |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1731 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; |
Igor M. Liplianin | e6f9ec8 | 2008-09-12 14:49:06 -0300 | [diff] [blame] | 1732 | int err = 0; |
Steven Toth | e7fee0f3 | 2008-09-11 10:23:01 -0300 | [diff] [blame] | 1733 | |
| 1734 | struct dtv_properties *tvps = NULL; |
| 1735 | struct dtv_property *tvp = NULL; |
| 1736 | int i; |
Steven Toth | 13c97bf | 2008-09-04 21:19:43 -0300 | [diff] [blame] | 1737 | |
| 1738 | dprintk("%s\n", __func__); |
| 1739 | |
Steven Toth | 6b73eea | 2008-09-04 01:12:25 -0300 | [diff] [blame] | 1740 | if(cmd == FE_SET_PROPERTY) { |
Steven Toth | e7fee0f3 | 2008-09-11 10:23:01 -0300 | [diff] [blame] | 1741 | tvps = (struct dtv_properties __user *)parg; |
Steven Toth | 6b73eea | 2008-09-04 01:12:25 -0300 | [diff] [blame] | 1742 | |
Steven Toth | a1bc84c | 2008-10-17 00:20:19 -0300 | [diff] [blame] | 1743 | dprintk("%s() properties.num = %d\n", __func__, tvps->num); |
| 1744 | dprintk("%s() properties.props = %p\n", __func__, tvps->props); |
Steven Toth | e7fee0f3 | 2008-09-11 10:23:01 -0300 | [diff] [blame] | 1745 | |
| 1746 | /* Put an arbitrary limit on the number of messages that can |
| 1747 | * be sent at once */ |
Steven Toth | 6068f50 | 2008-10-06 22:46:08 -0300 | [diff] [blame] | 1748 | if ((tvps->num == 0) || (tvps->num > DTV_IOCTL_MAX_MSGS)) |
Steven Toth | e7fee0f3 | 2008-09-11 10:23:01 -0300 | [diff] [blame] | 1749 | return -EINVAL; |
| 1750 | |
Thiago Farina | 6e3924a | 2010-01-16 10:25:38 -0300 | [diff] [blame] | 1751 | tvp = kmalloc(tvps->num * sizeof(struct dtv_property), GFP_KERNEL); |
Steven Toth | e7fee0f3 | 2008-09-11 10:23:01 -0300 | [diff] [blame] | 1752 | if (!tvp) { |
| 1753 | err = -ENOMEM; |
| 1754 | goto out; |
Steven Toth | 6b73eea | 2008-09-04 01:12:25 -0300 | [diff] [blame] | 1755 | } |
| 1756 | |
Steven Toth | e7fee0f3 | 2008-09-11 10:23:01 -0300 | [diff] [blame] | 1757 | if (copy_from_user(tvp, tvps->props, tvps->num * sizeof(struct dtv_property))) { |
| 1758 | err = -EFAULT; |
| 1759 | goto out; |
| 1760 | } |
| 1761 | |
Steven Toth | d48cb40 | 2008-09-26 00:16:25 -0300 | [diff] [blame] | 1762 | for (i = 0; i < tvps->num; i++) { |
Andreas Oberritter | aff8ab5 | 2011-05-09 00:03:34 +0100 | [diff] [blame] | 1763 | err = dtv_property_process_set(fe, tvp + i, file); |
| 1764 | if (err < 0) |
| 1765 | goto out; |
| 1766 | (tvp + i)->result = err; |
Steven Toth | d48cb40 | 2008-09-26 00:16:25 -0300 | [diff] [blame] | 1767 | } |
Steven Toth | e7fee0f3 | 2008-09-11 10:23:01 -0300 | [diff] [blame] | 1768 | |
Andreas Oberritter | 5072771 | 2011-05-08 20:03:39 -0300 | [diff] [blame] | 1769 | if (c->state == DTV_TUNE) |
Steven Toth | a1bc84c | 2008-10-17 00:20:19 -0300 | [diff] [blame] | 1770 | dprintk("%s() Property cache is full, tuning\n", __func__); |
Steven Toth | bfbf2da | 2008-09-12 01:37:37 -0300 | [diff] [blame] | 1771 | |
Steven Toth | 363429a | 2008-09-12 01:34:28 -0300 | [diff] [blame] | 1772 | } else |
| 1773 | if(cmd == FE_GET_PROPERTY) { |
Steven Toth | 363429a | 2008-09-12 01:34:28 -0300 | [diff] [blame] | 1774 | tvps = (struct dtv_properties __user *)parg; |
| 1775 | |
Steven Toth | a1bc84c | 2008-10-17 00:20:19 -0300 | [diff] [blame] | 1776 | dprintk("%s() properties.num = %d\n", __func__, tvps->num); |
| 1777 | dprintk("%s() properties.props = %p\n", __func__, tvps->props); |
Steven Toth | 363429a | 2008-09-12 01:34:28 -0300 | [diff] [blame] | 1778 | |
| 1779 | /* Put an arbitrary limit on the number of messages that can |
| 1780 | * be sent at once */ |
Steven Toth | 6068f50 | 2008-10-06 22:46:08 -0300 | [diff] [blame] | 1781 | if ((tvps->num == 0) || (tvps->num > DTV_IOCTL_MAX_MSGS)) |
Steven Toth | 363429a | 2008-09-12 01:34:28 -0300 | [diff] [blame] | 1782 | return -EINVAL; |
| 1783 | |
Thiago Farina | 6e3924a | 2010-01-16 10:25:38 -0300 | [diff] [blame] | 1784 | tvp = kmalloc(tvps->num * sizeof(struct dtv_property), GFP_KERNEL); |
Steven Toth | 363429a | 2008-09-12 01:34:28 -0300 | [diff] [blame] | 1785 | if (!tvp) { |
| 1786 | err = -ENOMEM; |
| 1787 | goto out; |
| 1788 | } |
| 1789 | |
| 1790 | if (copy_from_user(tvp, tvps->props, tvps->num * sizeof(struct dtv_property))) { |
| 1791 | err = -EFAULT; |
| 1792 | goto out; |
| 1793 | } |
| 1794 | |
Mauro Carvalho Chehab | a689e36 | 2011-12-22 14:47:48 -0300 | [diff] [blame] | 1795 | /* |
| 1796 | * Fills the cache out struct with the cache contents, plus |
Mauro Carvalho Chehab | 51dcb19 | 2012-01-17 16:20:37 -0200 | [diff] [blame] | 1797 | * the data retrieved from get_frontend, if the frontend |
| 1798 | * is not idle. Otherwise, returns the cached content |
Mauro Carvalho Chehab | a689e36 | 2011-12-22 14:47:48 -0300 | [diff] [blame] | 1799 | */ |
Mauro Carvalho Chehab | 51dcb19 | 2012-01-17 16:20:37 -0200 | [diff] [blame] | 1800 | if (fepriv->state != FESTATE_IDLE) { |
| 1801 | err = dtv_get_frontend(fe, NULL); |
| 1802 | if (err < 0) |
| 1803 | goto out; |
| 1804 | } |
Steven Toth | d48cb40 | 2008-09-26 00:16:25 -0300 | [diff] [blame] | 1805 | for (i = 0; i < tvps->num; i++) { |
Mauro Carvalho Chehab | 7c61d80 | 2011-12-30 11:30:21 -0300 | [diff] [blame] | 1806 | err = dtv_property_process_get(fe, c, tvp + i, file); |
Andreas Oberritter | aff8ab5 | 2011-05-09 00:03:34 +0100 | [diff] [blame] | 1807 | if (err < 0) |
| 1808 | goto out; |
| 1809 | (tvp + i)->result = err; |
Steven Toth | d48cb40 | 2008-09-26 00:16:25 -0300 | [diff] [blame] | 1810 | } |
Steven Toth | 363429a | 2008-09-12 01:34:28 -0300 | [diff] [blame] | 1811 | |
| 1812 | if (copy_to_user(tvps->props, tvp, tvps->num * sizeof(struct dtv_property))) { |
| 1813 | err = -EFAULT; |
| 1814 | goto out; |
| 1815 | } |
| 1816 | |
Steven Toth | 363429a | 2008-09-12 01:34:28 -0300 | [diff] [blame] | 1817 | } else |
| 1818 | err = -EOPNOTSUPP; |
| 1819 | |
Steven Toth | e7fee0f3 | 2008-09-11 10:23:01 -0300 | [diff] [blame] | 1820 | out: |
| 1821 | kfree(tvp); |
Steven Toth | 13c97bf | 2008-09-04 21:19:43 -0300 | [diff] [blame] | 1822 | return err; |
| 1823 | } |
| 1824 | |
Mauro Carvalho Chehab | 5bfaadd | 2012-01-01 16:11:13 -0300 | [diff] [blame] | 1825 | static int dtv_set_frontend(struct dvb_frontend *fe) |
Mauro Carvalho Chehab | 9682cea | 2012-01-01 16:11:12 -0300 | [diff] [blame] | 1826 | { |
Mauro Carvalho Chehab | 9682cea | 2012-01-01 16:11:12 -0300 | [diff] [blame] | 1827 | struct dvb_frontend_private *fepriv = fe->frontend_priv; |
| 1828 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; |
| 1829 | struct dvb_frontend_tune_settings fetunesettings; |
Mauro Carvalho Chehab | 5bfaadd | 2012-01-01 16:11:13 -0300 | [diff] [blame] | 1830 | u32 rolloff = 0; |
Mauro Carvalho Chehab | 9682cea | 2012-01-01 16:11:12 -0300 | [diff] [blame] | 1831 | |
Mauro Carvalho Chehab | 5bfaadd | 2012-01-01 16:11:13 -0300 | [diff] [blame] | 1832 | if (dvb_frontend_check_parameters(fe) < 0) |
| 1833 | return -EINVAL; |
Mauro Carvalho Chehab | 9682cea | 2012-01-01 16:11:12 -0300 | [diff] [blame] | 1834 | |
| 1835 | /* |
Mauro Carvalho Chehab | 5bfaadd | 2012-01-01 16:11:13 -0300 | [diff] [blame] | 1836 | * Be sure that the bandwidth will be filled for all |
| 1837 | * non-satellite systems, as tuners need to know what |
| 1838 | * low pass/Nyquist half filter should be applied, in |
| 1839 | * order to avoid inter-channel noise. |
| 1840 | * |
| 1841 | * ISDB-T and DVB-T/T2 already sets bandwidth. |
| 1842 | * ATSC and DVB-C don't set, so, the core should fill it. |
| 1843 | * |
| 1844 | * On DVB-C Annex A and C, the bandwidth is a function of |
| 1845 | * the roll-off and symbol rate. Annex B defines different |
| 1846 | * roll-off factors depending on the modulation. Fortunately, |
| 1847 | * Annex B is only used with 6MHz, so there's no need to |
| 1848 | * calculate it. |
| 1849 | * |
| 1850 | * While not officially supported, a side effect of handling it at |
| 1851 | * the cache level is that a program could retrieve the bandwidth |
| 1852 | * via DTV_BANDWIDTH_HZ, which may be useful for test programs. |
| 1853 | */ |
| 1854 | switch (c->delivery_system) { |
| 1855 | case SYS_ATSC: |
| 1856 | case SYS_DVBC_ANNEX_B: |
| 1857 | c->bandwidth_hz = 6000000; |
| 1858 | break; |
| 1859 | case SYS_DVBC_ANNEX_A: |
| 1860 | rolloff = 115; |
| 1861 | break; |
| 1862 | case SYS_DVBC_ANNEX_C: |
| 1863 | rolloff = 113; |
| 1864 | break; |
| 1865 | default: |
| 1866 | break; |
| 1867 | } |
| 1868 | if (rolloff) |
| 1869 | c->bandwidth_hz = (c->symbol_rate * rolloff) / 100; |
Mauro Carvalho Chehab | 9682cea | 2012-01-01 16:11:12 -0300 | [diff] [blame] | 1870 | |
| 1871 | /* force auto frequency inversion if requested */ |
Mauro Carvalho Chehab | 5bfaadd | 2012-01-01 16:11:13 -0300 | [diff] [blame] | 1872 | if (dvb_force_auto_inversion) |
Mauro Carvalho Chehab | 9682cea | 2012-01-01 16:11:12 -0300 | [diff] [blame] | 1873 | c->inversion = INVERSION_AUTO; |
Mauro Carvalho Chehab | 5bfaadd | 2012-01-01 16:11:13 -0300 | [diff] [blame] | 1874 | |
| 1875 | /* |
| 1876 | * without hierarchical coding code_rate_LP is irrelevant, |
| 1877 | * so we tolerate the otherwise invalid FEC_NONE setting |
| 1878 | */ |
| 1879 | if (c->hierarchy == HIERARCHY_NONE && c->code_rate_LP == FEC_NONE) |
| 1880 | c->code_rate_LP = FEC_AUTO; |
Mauro Carvalho Chehab | 9682cea | 2012-01-01 16:11:12 -0300 | [diff] [blame] | 1881 | |
| 1882 | /* get frontend-specific tuning settings */ |
Mauro Carvalho Chehab | 5bfaadd | 2012-01-01 16:11:13 -0300 | [diff] [blame] | 1883 | memset(&fetunesettings, 0, sizeof(struct dvb_frontend_tune_settings)); |
Mauro Carvalho Chehab | 9682cea | 2012-01-01 16:11:12 -0300 | [diff] [blame] | 1884 | if (fe->ops.get_tune_settings && (fe->ops.get_tune_settings(fe, &fetunesettings) == 0)) { |
| 1885 | fepriv->min_delay = (fetunesettings.min_delay_ms * HZ) / 1000; |
| 1886 | fepriv->max_drift = fetunesettings.max_drift; |
| 1887 | fepriv->step_size = fetunesettings.step_size; |
| 1888 | } else { |
| 1889 | /* default values */ |
Mauro Carvalho Chehab | 5bfaadd | 2012-01-01 16:11:13 -0300 | [diff] [blame] | 1890 | switch (c->delivery_system) { |
| 1891 | case SYS_DVBC_ANNEX_A: |
| 1892 | case SYS_DVBC_ANNEX_C: |
| 1893 | fepriv->min_delay = HZ / 20; |
Mauro Carvalho Chehab | 9682cea | 2012-01-01 16:11:12 -0300 | [diff] [blame] | 1894 | fepriv->step_size = c->symbol_rate / 16000; |
| 1895 | fepriv->max_drift = c->symbol_rate / 2000; |
| 1896 | break; |
Mauro Carvalho Chehab | 5bfaadd | 2012-01-01 16:11:13 -0300 | [diff] [blame] | 1897 | case SYS_DVBT: |
| 1898 | case SYS_DVBT2: |
| 1899 | case SYS_ISDBT: |
| 1900 | case SYS_DMBTH: |
| 1901 | fepriv->min_delay = HZ / 20; |
Mauro Carvalho Chehab | 9682cea | 2012-01-01 16:11:12 -0300 | [diff] [blame] | 1902 | fepriv->step_size = fe->ops.info.frequency_stepsize * 2; |
| 1903 | fepriv->max_drift = (fe->ops.info.frequency_stepsize * 2) + 1; |
| 1904 | break; |
Mauro Carvalho Chehab | 5bfaadd | 2012-01-01 16:11:13 -0300 | [diff] [blame] | 1905 | default: |
| 1906 | /* |
| 1907 | * FIXME: This sounds wrong! if freqency_stepsize is |
| 1908 | * defined by the frontend, why not use it??? |
| 1909 | */ |
| 1910 | fepriv->min_delay = HZ / 20; |
| 1911 | fepriv->step_size = 0; /* no zigzag */ |
Mauro Carvalho Chehab | 9682cea | 2012-01-01 16:11:12 -0300 | [diff] [blame] | 1912 | fepriv->max_drift = 0; |
| 1913 | break; |
| 1914 | } |
| 1915 | } |
| 1916 | if (dvb_override_tune_delay > 0) |
| 1917 | fepriv->min_delay = (dvb_override_tune_delay * HZ) / 1000; |
| 1918 | |
| 1919 | fepriv->state = FESTATE_RETUNE; |
| 1920 | |
| 1921 | /* Request the search algorithm to search */ |
| 1922 | fepriv->algo_status |= DVBFE_ALGO_SEARCH_AGAIN; |
| 1923 | |
| 1924 | dvb_frontend_clear_events(fe); |
| 1925 | dvb_frontend_add_event(fe, 0); |
| 1926 | dvb_frontend_wakeup(fe); |
| 1927 | fepriv->status = 0; |
| 1928 | |
| 1929 | return 0; |
| 1930 | } |
| 1931 | |
| 1932 | |
Arnd Bergmann | 16ef8de | 2010-04-27 00:24:00 +0200 | [diff] [blame] | 1933 | static int dvb_frontend_ioctl_legacy(struct file *file, |
Steven Toth | 13c97bf | 2008-09-04 21:19:43 -0300 | [diff] [blame] | 1934 | unsigned int cmd, void *parg) |
| 1935 | { |
| 1936 | struct dvb_device *dvbdev = file->private_data; |
| 1937 | struct dvb_frontend *fe = dvbdev->priv; |
| 1938 | struct dvb_frontend_private *fepriv = fe->frontend_priv; |
Mauro Carvalho Chehab | 5bfaadd | 2012-01-01 16:11:13 -0300 | [diff] [blame] | 1939 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; |
Michael Krufky | 9133aee | 2009-05-23 18:00:59 -0300 | [diff] [blame] | 1940 | int cb_err, err = -EOPNOTSUPP; |
| 1941 | |
| 1942 | if (fe->dvb->fe_ioctl_override) { |
| 1943 | cb_err = fe->dvb->fe_ioctl_override(fe, cmd, parg, |
| 1944 | DVB_FE_IOCTL_PRE); |
| 1945 | if (cb_err < 0) |
| 1946 | return cb_err; |
| 1947 | if (cb_err > 0) |
| 1948 | return 0; |
| 1949 | /* fe_ioctl_override returning 0 allows |
| 1950 | * dvb-core to continue handling the ioctl */ |
| 1951 | } |
Steven Toth | 13c97bf | 2008-09-04 21:19:43 -0300 | [diff] [blame] | 1952 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1953 | switch (cmd) { |
| 1954 | case FE_GET_INFO: { |
Johannes Stezenbach | 0c53c70 | 2005-05-16 21:54:24 -0700 | [diff] [blame] | 1955 | struct dvb_frontend_info* info = parg; |
Mauro Carvalho Chehab | 9474c5e | 2012-01-05 12:28:20 -0200 | [diff] [blame] | 1956 | |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 1957 | memcpy(info, &fe->ops.info, sizeof(struct dvb_frontend_info)); |
Guillaume Audirac | 2030c03 | 2010-05-06 09:30:25 -0300 | [diff] [blame] | 1958 | dvb_frontend_get_frequency_limits(fe, &info->frequency_min, &info->frequency_max); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1959 | |
Mauro Carvalho Chehab | 5bfaadd | 2012-01-01 16:11:13 -0300 | [diff] [blame] | 1960 | /* |
| 1961 | * Associate the 4 delivery systems supported by DVBv3 |
| 1962 | * API with their DVBv5 counterpart. For the other standards, |
| 1963 | * use the closest type, assuming that it would hopefully |
| 1964 | * work with a DVBv3 application. |
| 1965 | * It should be noticed that, on multi-frontend devices with |
| 1966 | * different types (terrestrial and cable, for example), |
| 1967 | * a pure DVBv3 application won't be able to use all delivery |
| 1968 | * systems. Yet, changing the DVBv5 cache to the other delivery |
| 1969 | * system should be enough for making it work. |
| 1970 | */ |
| 1971 | switch (dvbv3_type(c->delivery_system)) { |
| 1972 | case DVBV3_QPSK: |
Mauro Carvalho Chehab | 9474c5e | 2012-01-05 12:28:20 -0200 | [diff] [blame] | 1973 | info->type = FE_QPSK; |
Mauro Carvalho Chehab | 5bfaadd | 2012-01-01 16:11:13 -0300 | [diff] [blame] | 1974 | break; |
| 1975 | case DVBV3_ATSC: |
Mauro Carvalho Chehab | 9474c5e | 2012-01-05 12:28:20 -0200 | [diff] [blame] | 1976 | info->type = FE_ATSC; |
Mauro Carvalho Chehab | 5bfaadd | 2012-01-01 16:11:13 -0300 | [diff] [blame] | 1977 | break; |
| 1978 | case DVBV3_QAM: |
Mauro Carvalho Chehab | 9474c5e | 2012-01-05 12:28:20 -0200 | [diff] [blame] | 1979 | info->type = FE_QAM; |
Mauro Carvalho Chehab | 5bfaadd | 2012-01-01 16:11:13 -0300 | [diff] [blame] | 1980 | break; |
| 1981 | case DVBV3_OFDM: |
Mauro Carvalho Chehab | 9474c5e | 2012-01-05 12:28:20 -0200 | [diff] [blame] | 1982 | info->type = FE_OFDM; |
Mauro Carvalho Chehab | 5bfaadd | 2012-01-01 16:11:13 -0300 | [diff] [blame] | 1983 | break; |
| 1984 | default: |
| 1985 | printk(KERN_ERR |
| 1986 | "%s: doesn't know how to handle a DVBv3 call to delivery system %i\n", |
| 1987 | __func__, c->delivery_system); |
| 1988 | fe->ops.info.type = FE_OFDM; |
| 1989 | } |
Mauro Carvalho Chehab | 9474c5e | 2012-01-05 12:28:20 -0200 | [diff] [blame] | 1990 | dprintk("current delivery system on cache: %d, V3 type: %d\n", |
| 1991 | c->delivery_system, fe->ops.info.type); |
Mauro Carvalho Chehab | 5bfaadd | 2012-01-01 16:11:13 -0300 | [diff] [blame] | 1992 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1993 | /* Force the CAN_INVERSION_AUTO bit on. If the frontend doesn't |
| 1994 | * do it, it is done for it. */ |
| 1995 | info->caps |= FE_CAN_INVERSION_AUTO; |
| 1996 | err = 0; |
| 1997 | break; |
| 1998 | } |
| 1999 | |
Peter Beutner | 6757ccc | 2005-07-07 17:57:36 -0700 | [diff] [blame] | 2000 | case FE_READ_STATUS: { |
| 2001 | fe_status_t* status = parg; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2002 | |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 2003 | /* if retune was requested but hasn't occurred yet, prevent |
Peter Beutner | 6757ccc | 2005-07-07 17:57:36 -0700 | [diff] [blame] | 2004 | * that user get signal state from previous tuning */ |
Janne Grunau | 0188625 | 2009-09-01 19:23:09 -0300 | [diff] [blame] | 2005 | if (fepriv->state == FESTATE_RETUNE || |
| 2006 | fepriv->state == FESTATE_ERROR) { |
Peter Beutner | 6757ccc | 2005-07-07 17:57:36 -0700 | [diff] [blame] | 2007 | err=0; |
| 2008 | *status = 0; |
| 2009 | break; |
| 2010 | } |
| 2011 | |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 2012 | if (fe->ops.read_status) |
| 2013 | err = fe->ops.read_status(fe, status); |
Peter Beutner | 6757ccc | 2005-07-07 17:57:36 -0700 | [diff] [blame] | 2014 | break; |
| 2015 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2016 | case FE_READ_BER: |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 2017 | if (fe->ops.read_ber) |
| 2018 | err = fe->ops.read_ber(fe, (__u32*) parg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2019 | break; |
| 2020 | |
| 2021 | case FE_READ_SIGNAL_STRENGTH: |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 2022 | if (fe->ops.read_signal_strength) |
| 2023 | err = fe->ops.read_signal_strength(fe, (__u16*) parg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2024 | break; |
| 2025 | |
| 2026 | case FE_READ_SNR: |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 2027 | if (fe->ops.read_snr) |
| 2028 | err = fe->ops.read_snr(fe, (__u16*) parg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2029 | break; |
| 2030 | |
| 2031 | case FE_READ_UNCORRECTED_BLOCKS: |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 2032 | if (fe->ops.read_ucblocks) |
| 2033 | err = fe->ops.read_ucblocks(fe, (__u32*) parg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2034 | break; |
| 2035 | |
| 2036 | |
| 2037 | case FE_DISEQC_RESET_OVERLOAD: |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 2038 | if (fe->ops.diseqc_reset_overload) { |
| 2039 | err = fe->ops.diseqc_reset_overload(fe); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2040 | fepriv->state = FESTATE_DISEQC; |
| 2041 | fepriv->status = 0; |
| 2042 | } |
| 2043 | break; |
| 2044 | |
| 2045 | case FE_DISEQC_SEND_MASTER_CMD: |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 2046 | if (fe->ops.diseqc_send_master_cmd) { |
| 2047 | err = fe->ops.diseqc_send_master_cmd(fe, (struct dvb_diseqc_master_cmd*) parg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2048 | fepriv->state = FESTATE_DISEQC; |
| 2049 | fepriv->status = 0; |
| 2050 | } |
| 2051 | break; |
| 2052 | |
| 2053 | case FE_DISEQC_SEND_BURST: |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 2054 | if (fe->ops.diseqc_send_burst) { |
| 2055 | err = fe->ops.diseqc_send_burst(fe, (fe_sec_mini_cmd_t) parg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2056 | fepriv->state = FESTATE_DISEQC; |
| 2057 | fepriv->status = 0; |
| 2058 | } |
| 2059 | break; |
| 2060 | |
| 2061 | case FE_SET_TONE: |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 2062 | if (fe->ops.set_tone) { |
| 2063 | err = fe->ops.set_tone(fe, (fe_sec_tone_mode_t) parg); |
Andrew de Quincey | 6445401 | 2006-04-06 14:32:23 -0300 | [diff] [blame] | 2064 | fepriv->tone = (fe_sec_tone_mode_t) parg; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2065 | fepriv->state = FESTATE_DISEQC; |
| 2066 | fepriv->status = 0; |
| 2067 | } |
| 2068 | break; |
| 2069 | |
| 2070 | case FE_SET_VOLTAGE: |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 2071 | if (fe->ops.set_voltage) { |
| 2072 | err = fe->ops.set_voltage(fe, (fe_sec_voltage_t) parg); |
Andrew de Quincey | 6445401 | 2006-04-06 14:32:23 -0300 | [diff] [blame] | 2073 | fepriv->voltage = (fe_sec_voltage_t) parg; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2074 | fepriv->state = FESTATE_DISEQC; |
| 2075 | fepriv->status = 0; |
| 2076 | } |
| 2077 | break; |
| 2078 | |
| 2079 | case FE_DISHNETWORK_SEND_LEGACY_CMD: |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 2080 | if (fe->ops.dishnetwork_send_legacy_command) { |
| 2081 | err = fe->ops.dishnetwork_send_legacy_command(fe, (unsigned long) parg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2082 | fepriv->state = FESTATE_DISEQC; |
| 2083 | fepriv->status = 0; |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 2084 | } else if (fe->ops.set_voltage) { |
NooneImportant | 83b75b0 | 2005-11-08 21:35:27 -0800 | [diff] [blame] | 2085 | /* |
| 2086 | * NOTE: This is a fallback condition. Some frontends |
| 2087 | * (stv0299 for instance) take longer than 8msec to |
| 2088 | * respond to a set_voltage command. Those switches |
| 2089 | * need custom routines to switch properly. For all |
Guillaume Audirac | 2030c03 | 2010-05-06 09:30:25 -0300 | [diff] [blame] | 2090 | * other frontends, the following should work ok. |
NooneImportant | 83b75b0 | 2005-11-08 21:35:27 -0800 | [diff] [blame] | 2091 | * Dish network legacy switches (as used by Dish500) |
| 2092 | * are controlled by sending 9-bit command words |
| 2093 | * spaced 8msec apart. |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 2094 | * the actual command word is switch/port dependent |
NooneImportant | 83b75b0 | 2005-11-08 21:35:27 -0800 | [diff] [blame] | 2095 | * so it is up to the userspace application to send |
| 2096 | * the right command. |
| 2097 | * The command must always start with a '0' after |
| 2098 | * initialization, so parg is 8 bits and does not |
| 2099 | * include the initialization or start bit |
| 2100 | */ |
Hans Verkuil | c6eb8ea | 2008-09-03 17:11:54 -0300 | [diff] [blame] | 2101 | unsigned long swcmd = ((unsigned long) parg) << 1; |
NooneImportant | 83b75b0 | 2005-11-08 21:35:27 -0800 | [diff] [blame] | 2102 | struct timeval nexttime; |
| 2103 | struct timeval tv[10]; |
| 2104 | int i; |
| 2105 | u8 last = 1; |
| 2106 | if (dvb_frontend_debug) |
Hans Verkuil | c6eb8ea | 2008-09-03 17:11:54 -0300 | [diff] [blame] | 2107 | printk("%s switch command: 0x%04lx\n", __func__, swcmd); |
NooneImportant | 83b75b0 | 2005-11-08 21:35:27 -0800 | [diff] [blame] | 2108 | do_gettimeofday(&nexttime); |
| 2109 | if (dvb_frontend_debug) |
| 2110 | memcpy(&tv[0], &nexttime, sizeof(struct timeval)); |
| 2111 | /* before sending a command, initialize by sending |
| 2112 | * a 32ms 18V to the switch |
| 2113 | */ |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 2114 | fe->ops.set_voltage(fe, SEC_VOLTAGE_18); |
NooneImportant | 83b75b0 | 2005-11-08 21:35:27 -0800 | [diff] [blame] | 2115 | dvb_frontend_sleep_until(&nexttime, 32000); |
| 2116 | |
| 2117 | for (i = 0; i < 9; i++) { |
| 2118 | if (dvb_frontend_debug) |
| 2119 | do_gettimeofday(&tv[i + 1]); |
Hans Verkuil | c6eb8ea | 2008-09-03 17:11:54 -0300 | [diff] [blame] | 2120 | if ((swcmd & 0x01) != last) { |
NooneImportant | 83b75b0 | 2005-11-08 21:35:27 -0800 | [diff] [blame] | 2121 | /* set voltage to (last ? 13V : 18V) */ |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 2122 | fe->ops.set_voltage(fe, (last) ? SEC_VOLTAGE_13 : SEC_VOLTAGE_18); |
NooneImportant | 83b75b0 | 2005-11-08 21:35:27 -0800 | [diff] [blame] | 2123 | last = (last) ? 0 : 1; |
| 2124 | } |
Hans Verkuil | c6eb8ea | 2008-09-03 17:11:54 -0300 | [diff] [blame] | 2125 | swcmd = swcmd >> 1; |
NooneImportant | 83b75b0 | 2005-11-08 21:35:27 -0800 | [diff] [blame] | 2126 | if (i != 8) |
| 2127 | dvb_frontend_sleep_until(&nexttime, 8000); |
| 2128 | } |
| 2129 | if (dvb_frontend_debug) { |
| 2130 | printk("%s(%d): switch delay (should be 32k followed by all 8k\n", |
Harvey Harrison | 46b4f7c | 2008-04-08 23:20:00 -0300 | [diff] [blame] | 2131 | __func__, fe->dvb->num); |
NooneImportant | 83b75b0 | 2005-11-08 21:35:27 -0800 | [diff] [blame] | 2132 | for (i = 1; i < 10; i++) |
| 2133 | printk("%d: %d\n", i, timeval_usec_diff(tv[i-1] , tv[i])); |
| 2134 | } |
| 2135 | err = 0; |
| 2136 | fepriv->state = FESTATE_DISEQC; |
| 2137 | fepriv->status = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2138 | } |
| 2139 | break; |
| 2140 | |
| 2141 | case FE_DISEQC_RECV_SLAVE_REPLY: |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 2142 | if (fe->ops.diseqc_recv_slave_reply) |
| 2143 | err = fe->ops.diseqc_recv_slave_reply(fe, (struct dvb_diseqc_slave_reply*) parg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2144 | break; |
| 2145 | |
| 2146 | case FE_ENABLE_HIGH_LNB_VOLTAGE: |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 2147 | if (fe->ops.enable_high_lnb_voltage) |
| 2148 | err = fe->ops.enable_high_lnb_voltage(fe, (long) parg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2149 | break; |
| 2150 | |
Mauro Carvalho Chehab | 9682cea | 2012-01-01 16:11:12 -0300 | [diff] [blame] | 2151 | case FE_SET_FRONTEND: |
Mauro Carvalho Chehab | 04be0f7 | 2012-01-01 16:11:14 -0300 | [diff] [blame] | 2152 | err = set_delivery_system(fe, SYS_UNDEFINED); |
| 2153 | if (err) |
| 2154 | break; |
| 2155 | |
Mauro Carvalho Chehab | e399ce7 | 2012-01-01 16:11:16 -0300 | [diff] [blame] | 2156 | err = dtv_property_cache_sync(fe, c, parg); |
Mauro Carvalho Chehab | 5bfaadd | 2012-01-01 16:11:13 -0300 | [diff] [blame] | 2157 | if (err) |
| 2158 | break; |
| 2159 | err = dtv_set_frontend(fe); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2160 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2161 | case FE_GET_EVENT: |
| 2162 | err = dvb_frontend_get_event (fe, parg, file->f_flags); |
| 2163 | break; |
| 2164 | |
| 2165 | case FE_GET_FRONTEND: |
Mauro Carvalho Chehab | e399ce7 | 2012-01-01 16:11:16 -0300 | [diff] [blame] | 2166 | err = dtv_get_frontend(fe, parg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2167 | break; |
Andrew de Quincey | 36cb557 | 2006-01-09 15:25:07 -0200 | [diff] [blame] | 2168 | |
| 2169 | case FE_SET_FRONTEND_TUNE_MODE: |
Hans Verkuil | e18828e | 2006-01-09 15:25:28 -0200 | [diff] [blame] | 2170 | fepriv->tune_mode_flags = (unsigned long) parg; |
Trent Piepho | 1b172e0 | 2006-06-29 13:16:04 -0300 | [diff] [blame] | 2171 | err = 0; |
Andrew de Quincey | 36cb557 | 2006-01-09 15:25:07 -0200 | [diff] [blame] | 2172 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2173 | }; |
| 2174 | |
Michael Krufky | 9133aee | 2009-05-23 18:00:59 -0300 | [diff] [blame] | 2175 | if (fe->dvb->fe_ioctl_override) { |
| 2176 | cb_err = fe->dvb->fe_ioctl_override(fe, cmd, parg, |
| 2177 | DVB_FE_IOCTL_POST); |
| 2178 | if (cb_err < 0) |
| 2179 | return cb_err; |
| 2180 | } |
| 2181 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2182 | return err; |
| 2183 | } |
| 2184 | |
Steven Toth | 6b73eea | 2008-09-04 01:12:25 -0300 | [diff] [blame] | 2185 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2186 | static unsigned int dvb_frontend_poll(struct file *file, struct poll_table_struct *wait) |
| 2187 | { |
| 2188 | struct dvb_device *dvbdev = file->private_data; |
| 2189 | struct dvb_frontend *fe = dvbdev->priv; |
Johannes Stezenbach | 0c53c70 | 2005-05-16 21:54:24 -0700 | [diff] [blame] | 2190 | struct dvb_frontend_private *fepriv = fe->frontend_priv; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2191 | |
Harvey Harrison | 46b4f7c | 2008-04-08 23:20:00 -0300 | [diff] [blame] | 2192 | dprintk ("%s\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2193 | |
| 2194 | poll_wait (file, &fepriv->events.wait_queue, wait); |
| 2195 | |
| 2196 | if (fepriv->events.eventw != fepriv->events.eventr) |
| 2197 | return (POLLIN | POLLRDNORM | POLLPRI); |
| 2198 | |
| 2199 | return 0; |
| 2200 | } |
| 2201 | |
| 2202 | static int dvb_frontend_open(struct inode *inode, struct file *file) |
| 2203 | { |
| 2204 | struct dvb_device *dvbdev = file->private_data; |
| 2205 | struct dvb_frontend *fe = dvbdev->priv; |
Johannes Stezenbach | 0c53c70 | 2005-05-16 21:54:24 -0700 | [diff] [blame] | 2206 | struct dvb_frontend_private *fepriv = fe->frontend_priv; |
Darron Broad | 59b1842 | 2008-10-11 11:44:05 -0300 | [diff] [blame] | 2207 | struct dvb_adapter *adapter = fe->dvb; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2208 | int ret; |
| 2209 | |
Harvey Harrison | 46b4f7c | 2008-04-08 23:20:00 -0300 | [diff] [blame] | 2210 | dprintk ("%s\n", __func__); |
matthieu castet | e36309f | 2010-05-05 15:59:20 -0300 | [diff] [blame] | 2211 | if (fepriv->exit == DVB_FE_DEVICE_REMOVED) |
| 2212 | return -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2213 | |
Darron Broad | 59b1842 | 2008-10-11 11:44:05 -0300 | [diff] [blame] | 2214 | if (adapter->mfe_shared) { |
| 2215 | mutex_lock (&adapter->mfe_lock); |
Darron Broad | 6594690 | 2008-10-15 13:37:59 -0300 | [diff] [blame] | 2216 | |
| 2217 | if (adapter->mfe_dvbdev == NULL) |
| 2218 | adapter->mfe_dvbdev = dvbdev; |
| 2219 | |
| 2220 | else if (adapter->mfe_dvbdev != dvbdev) { |
| 2221 | struct dvb_device |
| 2222 | *mfedev = adapter->mfe_dvbdev; |
| 2223 | struct dvb_frontend |
| 2224 | *mfe = mfedev->priv; |
| 2225 | struct dvb_frontend_private |
| 2226 | *mfepriv = mfe->frontend_priv; |
| 2227 | int mferetry = (dvb_mfe_wait_time << 1); |
| 2228 | |
| 2229 | mutex_unlock (&adapter->mfe_lock); |
| 2230 | while (mferetry-- && (mfedev->users != -1 || |
| 2231 | mfepriv->thread != NULL)) { |
| 2232 | if(msleep_interruptible(500)) { |
| 2233 | if(signal_pending(current)) |
| 2234 | return -EINTR; |
Darron Broad | 59b1842 | 2008-10-11 11:44:05 -0300 | [diff] [blame] | 2235 | } |
| 2236 | } |
Darron Broad | 6594690 | 2008-10-15 13:37:59 -0300 | [diff] [blame] | 2237 | |
| 2238 | mutex_lock (&adapter->mfe_lock); |
| 2239 | if(adapter->mfe_dvbdev != dvbdev) { |
| 2240 | mfedev = adapter->mfe_dvbdev; |
| 2241 | mfe = mfedev->priv; |
| 2242 | mfepriv = mfe->frontend_priv; |
| 2243 | if (mfedev->users != -1 || |
| 2244 | mfepriv->thread != NULL) { |
| 2245 | mutex_unlock (&adapter->mfe_lock); |
| 2246 | return -EBUSY; |
| 2247 | } |
| 2248 | adapter->mfe_dvbdev = dvbdev; |
| 2249 | } |
Darron Broad | 59b1842 | 2008-10-11 11:44:05 -0300 | [diff] [blame] | 2250 | } |
| 2251 | } |
| 2252 | |
Oliver Endriss | 48136e1 | 2007-08-25 12:00:23 -0300 | [diff] [blame] | 2253 | if (dvbdev->users == -1 && fe->ops.ts_bus_ctrl) { |
| 2254 | if ((ret = fe->ops.ts_bus_ctrl(fe, 1)) < 0) |
Darron Broad | 59b1842 | 2008-10-11 11:44:05 -0300 | [diff] [blame] | 2255 | goto err0; |
Devin Heitmueller | 2d19693 | 2011-07-04 21:55:01 -0300 | [diff] [blame] | 2256 | |
| 2257 | /* If we took control of the bus, we need to force |
| 2258 | reinitialization. This is because many ts_bus_ctrl() |
| 2259 | functions strobe the RESET pin on the demod, and if the |
| 2260 | frontend thread already exists then the dvb_init() routine |
| 2261 | won't get called (which is what usually does initial |
| 2262 | register configuration). */ |
| 2263 | fepriv->reinitialise = 1; |
Steven Toth | ba7e6f3 | 2006-09-25 12:41:53 -0300 | [diff] [blame] | 2264 | } |
| 2265 | |
Oliver Endriss | 48136e1 | 2007-08-25 12:00:23 -0300 | [diff] [blame] | 2266 | if ((ret = dvb_generic_open (inode, file)) < 0) |
| 2267 | goto err1; |
Andrew de Quincey | 04c56d0 | 2006-07-10 03:34:14 -0300 | [diff] [blame] | 2268 | |
Oliver Endriss | 48136e1 | 2007-08-25 12:00:23 -0300 | [diff] [blame] | 2269 | if ((file->f_flags & O_ACCMODE) != O_RDONLY) { |
Andrew de Quincey | 04c56d0 | 2006-07-10 03:34:14 -0300 | [diff] [blame] | 2270 | /* normal tune mode when opened R/W */ |
| 2271 | fepriv->tune_mode_flags &= ~FE_TUNE_MODE_ONESHOT; |
| 2272 | fepriv->tone = -1; |
| 2273 | fepriv->voltage = -1; |
| 2274 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2275 | ret = dvb_frontend_start (fe); |
| 2276 | if (ret) |
Oliver Endriss | 48136e1 | 2007-08-25 12:00:23 -0300 | [diff] [blame] | 2277 | goto err2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2278 | |
| 2279 | /* empty event queue */ |
| 2280 | fepriv->events.eventr = fepriv->events.eventw = 0; |
| 2281 | } |
| 2282 | |
Darron Broad | 59b1842 | 2008-10-11 11:44:05 -0300 | [diff] [blame] | 2283 | if (adapter->mfe_shared) |
| 2284 | mutex_unlock (&adapter->mfe_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2285 | return ret; |
Oliver Endriss | 48136e1 | 2007-08-25 12:00:23 -0300 | [diff] [blame] | 2286 | |
| 2287 | err2: |
| 2288 | dvb_generic_release(inode, file); |
| 2289 | err1: |
| 2290 | if (dvbdev->users == -1 && fe->ops.ts_bus_ctrl) |
| 2291 | fe->ops.ts_bus_ctrl(fe, 0); |
Darron Broad | 59b1842 | 2008-10-11 11:44:05 -0300 | [diff] [blame] | 2292 | err0: |
| 2293 | if (adapter->mfe_shared) |
| 2294 | mutex_unlock (&adapter->mfe_lock); |
Oliver Endriss | 48136e1 | 2007-08-25 12:00:23 -0300 | [diff] [blame] | 2295 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2296 | } |
| 2297 | |
| 2298 | static int dvb_frontend_release(struct inode *inode, struct file *file) |
| 2299 | { |
| 2300 | struct dvb_device *dvbdev = file->private_data; |
| 2301 | struct dvb_frontend *fe = dvbdev->priv; |
Johannes Stezenbach | 0c53c70 | 2005-05-16 21:54:24 -0700 | [diff] [blame] | 2302 | struct dvb_frontend_private *fepriv = fe->frontend_priv; |
Markus Rechberger | ca5be9c | 2007-04-14 10:18:58 -0300 | [diff] [blame] | 2303 | int ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2304 | |
Harvey Harrison | 46b4f7c | 2008-04-08 23:20:00 -0300 | [diff] [blame] | 2305 | dprintk ("%s\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2306 | |
Andreas Oberritter | b9d5efc | 2011-12-09 21:37:00 -0300 | [diff] [blame] | 2307 | if ((file->f_flags & O_ACCMODE) != O_RDONLY) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2308 | fepriv->release_jiffies = jiffies; |
Andreas Oberritter | b9d5efc | 2011-12-09 21:37:00 -0300 | [diff] [blame] | 2309 | mb(); |
| 2310 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2311 | |
Markus Rechberger | ca5be9c | 2007-04-14 10:18:58 -0300 | [diff] [blame] | 2312 | ret = dvb_generic_release (inode, file); |
| 2313 | |
Oliver Endriss | 48136e1 | 2007-08-25 12:00:23 -0300 | [diff] [blame] | 2314 | if (dvbdev->users == -1) { |
Andreas Oberritter | b9d5efc | 2011-12-09 21:37:00 -0300 | [diff] [blame] | 2315 | wake_up(&fepriv->wait_queue); |
matthieu castet | e36309f | 2010-05-05 15:59:20 -0300 | [diff] [blame] | 2316 | if (fepriv->exit != DVB_FE_NO_EXIT) { |
Oliver Endriss | 48136e1 | 2007-08-25 12:00:23 -0300 | [diff] [blame] | 2317 | fops_put(file->f_op); |
| 2318 | file->f_op = NULL; |
| 2319 | wake_up(&dvbdev->wait_queue); |
| 2320 | } |
| 2321 | if (fe->ops.ts_bus_ctrl) |
| 2322 | fe->ops.ts_bus_ctrl(fe, 0); |
Markus Rechberger | ca5be9c | 2007-04-14 10:18:58 -0300 | [diff] [blame] | 2323 | } |
Oliver Endriss | 48136e1 | 2007-08-25 12:00:23 -0300 | [diff] [blame] | 2324 | |
Markus Rechberger | ca5be9c | 2007-04-14 10:18:58 -0300 | [diff] [blame] | 2325 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2326 | } |
| 2327 | |
Jan Engelhardt | 784e29d | 2009-01-11 06:12:43 -0300 | [diff] [blame] | 2328 | static const struct file_operations dvb_frontend_fops = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2329 | .owner = THIS_MODULE, |
Arnd Bergmann | 16ef8de | 2010-04-27 00:24:00 +0200 | [diff] [blame] | 2330 | .unlocked_ioctl = dvb_generic_ioctl, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2331 | .poll = dvb_frontend_poll, |
| 2332 | .open = dvb_frontend_open, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 2333 | .release = dvb_frontend_release, |
| 2334 | .llseek = noop_llseek, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2335 | }; |
| 2336 | |
| 2337 | int dvb_register_frontend(struct dvb_adapter* dvb, |
| 2338 | struct dvb_frontend* fe) |
| 2339 | { |
| 2340 | struct dvb_frontend_private *fepriv; |
| 2341 | static const struct dvb_device dvbdev_template = { |
| 2342 | .users = ~0, |
| 2343 | .writers = 1, |
| 2344 | .readers = (~0)-1, |
| 2345 | .fops = &dvb_frontend_fops, |
| 2346 | .kernel_ioctl = dvb_frontend_ioctl |
| 2347 | }; |
| 2348 | |
Harvey Harrison | 46b4f7c | 2008-04-08 23:20:00 -0300 | [diff] [blame] | 2349 | dprintk ("%s\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2350 | |
Ingo Molnar | 3593cab | 2006-02-07 06:49:14 -0200 | [diff] [blame] | 2351 | if (mutex_lock_interruptible(&frontend_mutex)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2352 | return -ERESTARTSYS; |
| 2353 | |
Panagiotis Issaris | 7408187 | 2006-01-11 19:40:56 -0200 | [diff] [blame] | 2354 | fe->frontend_priv = kzalloc(sizeof(struct dvb_frontend_private), GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2355 | if (fe->frontend_priv == NULL) { |
Ingo Molnar | 3593cab | 2006-02-07 06:49:14 -0200 | [diff] [blame] | 2356 | mutex_unlock(&frontend_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2357 | return -ENOMEM; |
| 2358 | } |
Johannes Stezenbach | 0c53c70 | 2005-05-16 21:54:24 -0700 | [diff] [blame] | 2359 | fepriv = fe->frontend_priv; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2360 | |
Thomas Gleixner | a0a4714 | 2010-09-07 11:33:27 -0300 | [diff] [blame] | 2361 | sema_init(&fepriv->sem, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2362 | init_waitqueue_head (&fepriv->wait_queue); |
| 2363 | init_waitqueue_head (&fepriv->events.wait_queue); |
Matthias Kaehlcke | 03b7612 | 2007-07-30 14:58:10 -0300 | [diff] [blame] | 2364 | mutex_init(&fepriv->events.mtx); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2365 | fe->dvb = dvb; |
| 2366 | fepriv->inversion = INVERSION_OFF; |
| 2367 | |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 2368 | printk ("DVB: registering adapter %i frontend %i (%s)...\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2369 | fe->dvb->num, |
Steven Toth | 363c35f | 2008-10-11 11:05:50 -0300 | [diff] [blame] | 2370 | fe->id, |
Patrick Boettcher | dea7486 | 2006-05-14 05:01:31 -0300 | [diff] [blame] | 2371 | fe->ops.info.name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2372 | |
| 2373 | dvb_register_device (fe->dvb, &fepriv->dvbdev, &dvbdev_template, |
| 2374 | fe, DVB_DEVICE_FRONTEND); |
| 2375 | |
Mauro Carvalho Chehab | 5bfaadd | 2012-01-01 16:11:13 -0300 | [diff] [blame] | 2376 | /* |
| 2377 | * Initialize the cache to the proper values according with the |
| 2378 | * first supported delivery system (ops->delsys[0]) |
| 2379 | */ |
Mauro Carvalho Chehab | 240ab50 | 2012-01-10 18:00:50 -0300 | [diff] [blame] | 2380 | |
| 2381 | fe->dtv_property_cache.delivery_system = fe->ops.delsys[0]; |
Mauro Carvalho Chehab | 5bfaadd | 2012-01-01 16:11:13 -0300 | [diff] [blame] | 2382 | dvb_frontend_clear_cache(fe); |
| 2383 | |
Ingo Molnar | 3593cab | 2006-02-07 06:49:14 -0200 | [diff] [blame] | 2384 | mutex_unlock(&frontend_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2385 | return 0; |
| 2386 | } |
| 2387 | EXPORT_SYMBOL(dvb_register_frontend); |
| 2388 | |
| 2389 | int dvb_unregister_frontend(struct dvb_frontend* fe) |
| 2390 | { |
Johannes Stezenbach | 0c53c70 | 2005-05-16 21:54:24 -0700 | [diff] [blame] | 2391 | struct dvb_frontend_private *fepriv = fe->frontend_priv; |
Harvey Harrison | 46b4f7c | 2008-04-08 23:20:00 -0300 | [diff] [blame] | 2392 | dprintk ("%s\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2393 | |
Markus Rechberger | 57861b4 | 2007-04-14 10:19:18 -0300 | [diff] [blame] | 2394 | mutex_lock(&frontend_mutex); |
Markus Rechberger | ca5be9c | 2007-04-14 10:18:58 -0300 | [diff] [blame] | 2395 | dvb_frontend_stop (fe); |
Markus Rechberger | 57861b4 | 2007-04-14 10:19:18 -0300 | [diff] [blame] | 2396 | mutex_unlock(&frontend_mutex); |
| 2397 | |
| 2398 | if (fepriv->dvbdev->users < -1) |
| 2399 | wait_event(fepriv->dvbdev->wait_queue, |
| 2400 | fepriv->dvbdev->users==-1); |
| 2401 | |
Ingo Molnar | 3593cab | 2006-02-07 06:49:14 -0200 | [diff] [blame] | 2402 | mutex_lock(&frontend_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2403 | dvb_unregister_device (fepriv->dvbdev); |
Andrew de Quincey | d995506 | 2006-08-08 09:10:08 -0300 | [diff] [blame] | 2404 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2405 | /* fe is invalid now */ |
| 2406 | kfree(fepriv); |
Ingo Molnar | 3593cab | 2006-02-07 06:49:14 -0200 | [diff] [blame] | 2407 | mutex_unlock(&frontend_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2408 | return 0; |
| 2409 | } |
| 2410 | EXPORT_SYMBOL(dvb_unregister_frontend); |
Andrew de Quincey | f52a838 | 2006-08-08 09:10:09 -0300 | [diff] [blame] | 2411 | |
Mauro Carvalho Chehab | 149ef72 | 2008-04-29 21:38:46 -0300 | [diff] [blame] | 2412 | #ifdef CONFIG_MEDIA_ATTACH |
Andrew de Quincey | f52a838 | 2006-08-08 09:10:09 -0300 | [diff] [blame] | 2413 | void dvb_frontend_detach(struct dvb_frontend* fe) |
| 2414 | { |
| 2415 | void *ptr; |
| 2416 | |
| 2417 | if (fe->ops.release_sec) { |
| 2418 | fe->ops.release_sec(fe); |
| 2419 | symbol_put_addr(fe->ops.release_sec); |
| 2420 | } |
| 2421 | if (fe->ops.tuner_ops.release) { |
| 2422 | fe->ops.tuner_ops.release(fe); |
| 2423 | symbol_put_addr(fe->ops.tuner_ops.release); |
| 2424 | } |
Michael Krufky | 2426a27 | 2007-12-21 11:34:45 -0300 | [diff] [blame] | 2425 | if (fe->ops.analog_ops.release) { |
| 2426 | fe->ops.analog_ops.release(fe); |
| 2427 | symbol_put_addr(fe->ops.analog_ops.release); |
| 2428 | } |
Andrew de Quincey | f52a838 | 2006-08-08 09:10:09 -0300 | [diff] [blame] | 2429 | ptr = (void*)fe->ops.release; |
| 2430 | if (ptr) { |
| 2431 | fe->ops.release(fe); |
| 2432 | symbol_put_addr(ptr); |
| 2433 | } |
| 2434 | } |
| 2435 | #else |
| 2436 | void dvb_frontend_detach(struct dvb_frontend* fe) |
| 2437 | { |
| 2438 | if (fe->ops.release_sec) |
| 2439 | fe->ops.release_sec(fe); |
| 2440 | if (fe->ops.tuner_ops.release) |
| 2441 | fe->ops.tuner_ops.release(fe); |
Michael Krufky | 2426a27 | 2007-12-21 11:34:45 -0300 | [diff] [blame] | 2442 | if (fe->ops.analog_ops.release) |
| 2443 | fe->ops.analog_ops.release(fe); |
Andrew de Quincey | f52a838 | 2006-08-08 09:10:09 -0300 | [diff] [blame] | 2444 | if (fe->ops.release) |
| 2445 | fe->ops.release(fe); |
| 2446 | } |
| 2447 | #endif |
| 2448 | EXPORT_SYMBOL(dvb_frontend_detach); |