Lines Matching +full:fine +full:- +full:tune

1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * Copyright (C) 1999-2001 Ralph Metzler
53 …e_delay, "0: normal (default), >0 => delay in milliseconds to wait for lock after a tune attempt");
57 MODULE_PARM_DESC(dvb_mfe_wait_time, "Wait up to <mfe_wait_time> seconds on open() for multi-fronten…
78 * FESTATE_RETUNE. Parameters have been supplied, but we have not yet performed the first tune.
136 struct dvb_frontend_private *fepriv = fe->frontend_priv; in __dvb_frontend_free()
139 dvb_device_put(fepriv->dvbdev); in __dvb_frontend_free()
141 dvb_frontend_invoke_release(fe, fe->ops.release); in __dvb_frontend_free()
157 if (fe->ops.detach) in dvb_frontend_put()
158 fe->ops.detach(fe); in dvb_frontend_put()
163 if (fe->frontend_priv) in dvb_frontend_put()
164 kref_put(&fe->refcount, dvb_frontend_free); in dvb_frontend_put()
171 kref_get(&fe->refcount); in dvb_frontend_get()
185 return fe->ops.get_frontend; in has_get_frontend()
240 struct dvb_frontend_private *fepriv = fe->frontend_priv; in dvb_frontend_add_event()
241 struct dtv_frontend_properties *c = &fe->dtv_property_cache; in dvb_frontend_add_event()
242 struct dvb_fe_events *events = &fepriv->events; in dvb_frontend_add_event()
246 dev_dbg(fe->dvb->device, "%s:\n", __func__); in dvb_frontend_add_event()
249 dtv_get_frontend(fe, c, &fepriv->parameters_out); in dvb_frontend_add_event()
251 mutex_lock(&events->mtx); in dvb_frontend_add_event()
253 wp = (events->eventw + 1) % MAX_EVENT; in dvb_frontend_add_event()
254 if (wp == events->eventr) { in dvb_frontend_add_event()
255 events->overflow = 1; in dvb_frontend_add_event()
256 events->eventr = (events->eventr + 1) % MAX_EVENT; in dvb_frontend_add_event()
259 e = &events->events[events->eventw]; in dvb_frontend_add_event()
260 e->status = status; in dvb_frontend_add_event()
261 e->parameters = fepriv->parameters_out; in dvb_frontend_add_event()
263 events->eventw = wp; in dvb_frontend_add_event()
265 mutex_unlock(&events->mtx); in dvb_frontend_add_event()
267 wake_up_interruptible(&events->wait_queue); in dvb_frontend_add_event()
275 up(&fepriv->sem); in dvb_frontend_test_event()
276 ret = events->eventw != events->eventr; in dvb_frontend_test_event()
277 down(&fepriv->sem); in dvb_frontend_test_event()
285 struct dvb_frontend_private *fepriv = fe->frontend_priv; in dvb_frontend_get_event()
286 struct dvb_fe_events *events = &fepriv->events; in dvb_frontend_get_event()
288 dev_dbg(fe->dvb->device, "%s:\n", __func__); in dvb_frontend_get_event()
290 if (events->overflow) { in dvb_frontend_get_event()
291 events->overflow = 0; in dvb_frontend_get_event()
292 return -EOVERFLOW; in dvb_frontend_get_event()
295 if (events->eventw == events->eventr) { in dvb_frontend_get_event()
300 return -EWOULDBLOCK; in dvb_frontend_get_event()
303 add_wait_queue(&events->wait_queue, &wait); in dvb_frontend_get_event()
307 ret = -ERESTARTSYS; in dvb_frontend_get_event()
311 remove_wait_queue(&events->wait_queue, &wait); in dvb_frontend_get_event()
316 mutex_lock(&events->mtx); in dvb_frontend_get_event()
317 *event = events->events[events->eventr]; in dvb_frontend_get_event()
318 events->eventr = (events->eventr + 1) % MAX_EVENT; in dvb_frontend_get_event()
319 mutex_unlock(&events->mtx); in dvb_frontend_get_event()
326 struct dvb_frontend_private *fepriv = fe->frontend_priv; in dvb_frontend_clear_events()
327 struct dvb_fe_events *events = &fepriv->events; in dvb_frontend_clear_events()
329 mutex_lock(&events->mtx); in dvb_frontend_clear_events()
330 events->eventr = events->eventw; in dvb_frontend_clear_events()
331 mutex_unlock(&events->mtx); in dvb_frontend_clear_events()
336 dev_dbg(fe->dvb->device, in dvb_frontend_init()
338 __func__, fe->dvb->num, fe->id, fe->ops.info.name); in dvb_frontend_init()
340 if (fe->ops.init) in dvb_frontend_init()
341 fe->ops.init(fe); in dvb_frontend_init()
342 if (fe->ops.tuner_ops.init) { in dvb_frontend_init()
343 if (fe->ops.i2c_gate_ctrl) in dvb_frontend_init()
344 fe->ops.i2c_gate_ctrl(fe, 1); in dvb_frontend_init()
345 fe->ops.tuner_ops.init(fe); in dvb_frontend_init()
346 if (fe->ops.i2c_gate_ctrl) in dvb_frontend_init()
347 fe->ops.i2c_gate_ctrl(fe, 0); in dvb_frontend_init()
353 struct dvb_frontend_private *fepriv = fe->frontend_priv; in dvb_frontend_reinitialise()
355 fepriv->reinitialise = 1; in dvb_frontend_reinitialise()
363 struct dvb_frontend *fe = fepriv->dvbdev->priv; in dvb_frontend_swzigzag_update_delay()
365 dev_dbg(fe->dvb->device, "%s:\n", __func__); in dvb_frontend_swzigzag_update_delay()
368 (fepriv->quality) = (fepriv->quality * 220 + 36 * 256) / 256; in dvb_frontend_swzigzag_update_delay()
370 (fepriv->quality) = (fepriv->quality * 220 + 0) / 256; in dvb_frontend_swzigzag_update_delay()
372 q2 = fepriv->quality - 128; in dvb_frontend_swzigzag_update_delay()
375 fepriv->delay = fepriv->min_delay + q2 * HZ / (128 * 128); in dvb_frontend_swzigzag_update_delay()
379 * dvb_frontend_swzigzag_autotune - Performs automatic twiddling of frontend
393 struct dvb_frontend_private *fepriv = fe->frontend_priv; in dvb_frontend_swzigzag_autotune()
394 struct dtv_frontend_properties *c = &fe->dtv_property_cache, tmp; in dvb_frontend_swzigzag_autotune()
395 int original_inversion = c->inversion; in dvb_frontend_swzigzag_autotune()
396 u32 original_frequency = c->frequency; in dvb_frontend_swzigzag_autotune()
399 autoinversion = ((!(fe->ops.info.caps & FE_CAN_INVERSION_AUTO)) && in dvb_frontend_swzigzag_autotune()
400 (c->inversion == INVERSION_AUTO)); in dvb_frontend_swzigzag_autotune()
405 fepriv->lnb_drift = fepriv->auto_step * fepriv->step_size; in dvb_frontend_swzigzag_autotune()
408 if (fepriv->lnb_drift > fepriv->max_drift) { in dvb_frontend_swzigzag_autotune()
409 fepriv->auto_step = 0; in dvb_frontend_swzigzag_autotune()
410 fepriv->auto_sub_step = 0; in dvb_frontend_swzigzag_autotune()
411 fepriv->lnb_drift = 0; in dvb_frontend_swzigzag_autotune()
414 /* perform inversion and +/- zigzag */ in dvb_frontend_swzigzag_autotune()
415 switch (fepriv->auto_sub_step) { in dvb_frontend_swzigzag_autotune()
424 fepriv->inversion = (fepriv->inversion == INVERSION_OFF) ? INVERSION_ON : INVERSION_OFF; in dvb_frontend_swzigzag_autotune()
429 if (fepriv->lnb_drift == 0) break; in dvb_frontend_swzigzag_autotune()
431 fepriv->lnb_drift = -fepriv->lnb_drift; in dvb_frontend_swzigzag_autotune()
436 if (fepriv->lnb_drift == 0) break; in dvb_frontend_swzigzag_autotune()
439 fepriv->inversion = (fepriv->inversion == INVERSION_OFF) ? INVERSION_ON : INVERSION_OFF; in dvb_frontend_swzigzag_autotune()
440 fepriv->lnb_drift = -fepriv->lnb_drift; in dvb_frontend_swzigzag_autotune()
445 fepriv->auto_step++; in dvb_frontend_swzigzag_autotune()
446 fepriv->auto_sub_step = 0; in dvb_frontend_swzigzag_autotune()
450 if (!ready) fepriv->auto_sub_step++; in dvb_frontend_swzigzag_autotune()
455 if ((fepriv->auto_step == fepriv->started_auto_step) && in dvb_frontend_swzigzag_autotune()
456 (fepriv->auto_sub_step == 0) && check_wrapped) { in dvb_frontend_swzigzag_autotune()
460 dev_dbg(fe->dvb->device, in dvb_frontend_swzigzag_autotune()
462 __func__, fepriv->lnb_drift, fepriv->inversion, in dvb_frontend_swzigzag_autotune()
463 fepriv->auto_step, fepriv->auto_sub_step, in dvb_frontend_swzigzag_autotune()
464 fepriv->started_auto_step); in dvb_frontend_swzigzag_autotune()
467 c->frequency += fepriv->lnb_drift; in dvb_frontend_swzigzag_autotune()
469 c->inversion = fepriv->inversion; in dvb_frontend_swzigzag_autotune()
471 if (fe->ops.set_frontend) in dvb_frontend_swzigzag_autotune()
472 fe_set_err = fe->ops.set_frontend(fe); in dvb_frontend_swzigzag_autotune()
475 fepriv->state = FESTATE_ERROR; in dvb_frontend_swzigzag_autotune()
479 c->frequency = original_frequency; in dvb_frontend_swzigzag_autotune()
480 c->inversion = original_inversion; in dvb_frontend_swzigzag_autotune()
482 fepriv->auto_sub_step++; in dvb_frontend_swzigzag_autotune()
490 struct dvb_frontend_private *fepriv = fe->frontend_priv; in dvb_frontend_swzigzag()
491 struct dtv_frontend_properties *c = &fe->dtv_property_cache, tmp; in dvb_frontend_swzigzag()
493 if (fepriv->max_drift) in dvb_frontend_swzigzag()
494 dev_warn_once(fe->dvb->device, in dvb_frontend_swzigzag()
498 if (fepriv->state & FESTATE_IDLE) { in dvb_frontend_swzigzag()
499 fepriv->delay = 3 * HZ; in dvb_frontend_swzigzag()
500 fepriv->quality = 0; in dvb_frontend_swzigzag()
505 if (fepriv->tune_mode_flags & FE_TUNE_MODE_ONESHOT) { in dvb_frontend_swzigzag()
506 if (fepriv->state & FESTATE_RETUNE) { in dvb_frontend_swzigzag()
508 if (fe->ops.set_frontend) in dvb_frontend_swzigzag()
509 retval = fe->ops.set_frontend(fe); in dvb_frontend_swzigzag()
512 fepriv->state = FESTATE_ERROR; in dvb_frontend_swzigzag()
514 fepriv->state = FESTATE_TUNED; in dvb_frontend_swzigzag()
516 fepriv->delay = 3 * HZ; in dvb_frontend_swzigzag()
517 fepriv->quality = 0; in dvb_frontend_swzigzag()
522 if (fepriv->state & FESTATE_RETUNE) { in dvb_frontend_swzigzag()
525 if (fe->ops.read_status) in dvb_frontend_swzigzag()
526 fe->ops.read_status(fe, &s); in dvb_frontend_swzigzag()
527 if (s != fepriv->status) { in dvb_frontend_swzigzag()
529 fepriv->status = s; in dvb_frontend_swzigzag()
534 if ((fepriv->state & FESTATE_WAITFORLOCK) && (s & FE_HAS_LOCK)) { in dvb_frontend_swzigzag()
536 fepriv->state = FESTATE_TUNED; in dvb_frontend_swzigzag()
539 if ((!(fe->ops.info.caps & FE_CAN_INVERSION_AUTO)) && in dvb_frontend_swzigzag()
540 (c->inversion == INVERSION_AUTO)) { in dvb_frontend_swzigzag()
541 c->inversion = fepriv->inversion; in dvb_frontend_swzigzag()
547 if (fepriv->state & FESTATE_TUNED) { in dvb_frontend_swzigzag()
554 fepriv->state = FESTATE_ZIGZAG_FAST; in dvb_frontend_swzigzag()
555 fepriv->started_auto_step = fepriv->auto_step; in dvb_frontend_swzigzag()
556 fepriv->check_wrapped = 0; in dvb_frontend_swzigzag()
562 if ((fepriv->state & FESTATE_LOSTLOCK) && in dvb_frontend_swzigzag()
563 (fe->ops.info.caps & FE_CAN_RECOVER) && (fepriv->max_drift == 0)) { in dvb_frontend_swzigzag()
570 * If its actually a re-tune, there will be a SET_FRONTEND soon enough. */ in dvb_frontend_swzigzag()
571 if (fepriv->state & FESTATE_DISEQC) { in dvb_frontend_swzigzag()
578 * tune is _very_ likely to require the same */ in dvb_frontend_swzigzag()
579 if (fepriv->state & FESTATE_RETUNE) { in dvb_frontend_swzigzag()
580 fepriv->lnb_drift = 0; in dvb_frontend_swzigzag()
581 fepriv->auto_step = 0; in dvb_frontend_swzigzag()
582 fepriv->auto_sub_step = 0; in dvb_frontend_swzigzag()
583 fepriv->started_auto_step = 0; in dvb_frontend_swzigzag()
584 fepriv->check_wrapped = 0; in dvb_frontend_swzigzag()
588 if ((fepriv->state & FESTATE_SEARCHING_FAST) || (fepriv->state & FESTATE_RETUNE)) { in dvb_frontend_swzigzag()
589 fepriv->delay = fepriv->min_delay; in dvb_frontend_swzigzag()
591 /* perform a tune */ in dvb_frontend_swzigzag()
593 fepriv->check_wrapped); in dvb_frontend_swzigzag()
599 fepriv->state = FESTATE_SEARCHING_SLOW; in dvb_frontend_swzigzag()
600 fepriv->started_auto_step = fepriv->auto_step; in dvb_frontend_swzigzag()
603 fepriv->check_wrapped = 1; in dvb_frontend_swzigzag()
605 /* if we've just re-tuned, enter the ZIGZAG_FAST state. in dvb_frontend_swzigzag()
607 * FE_SET_FRONTEND ioctl before the first frontend tune in dvb_frontend_swzigzag()
609 if (fepriv->state & FESTATE_RETUNE) { in dvb_frontend_swzigzag()
610 fepriv->state = FESTATE_TUNING_FAST; in dvb_frontend_swzigzag()
615 if (fepriv->state & FESTATE_SEARCHING_SLOW) { in dvb_frontend_swzigzag()
626 struct dvb_frontend_private *fepriv = fe->frontend_priv; in dvb_frontend_is_exiting()
628 if (fe->exit != DVB_FE_NO_EXIT) in dvb_frontend_is_exiting()
631 if (fepriv->dvbdev->writers == 1) in dvb_frontend_is_exiting()
632 if (time_after_eq(jiffies, fepriv->release_jiffies + in dvb_frontend_is_exiting()
641 struct dvb_frontend_private *fepriv = fe->frontend_priv; in dvb_frontend_should_wakeup()
643 if (fepriv->wakeup) { in dvb_frontend_should_wakeup()
644 fepriv->wakeup = 0; in dvb_frontend_should_wakeup()
652 struct dvb_frontend_private *fepriv = fe->frontend_priv; in dvb_frontend_wakeup()
654 fepriv->wakeup = 1; in dvb_frontend_wakeup()
655 wake_up_interruptible(&fepriv->wait_queue); in dvb_frontend_wakeup()
661 struct dtv_frontend_properties *c = &fe->dtv_property_cache; in dvb_frontend_thread()
662 struct dvb_frontend_private *fepriv = fe->frontend_priv; in dvb_frontend_thread()
668 dev_dbg(fe->dvb->device, "%s:\n", __func__); in dvb_frontend_thread()
670 fepriv->check_wrapped = 0; in dvb_frontend_thread()
671 fepriv->quality = 0; in dvb_frontend_thread()
672 fepriv->delay = 3 * HZ; in dvb_frontend_thread()
673 fepriv->status = 0; in dvb_frontend_thread()
674 fepriv->wakeup = 0; in dvb_frontend_thread()
675 fepriv->reinitialise = 0; in dvb_frontend_thread()
681 up(&fepriv->sem); /* is locked when we enter the thread... */ in dvb_frontend_thread()
682 wait_event_freezable_timeout(fepriv->wait_queue, in dvb_frontend_thread()
685 fepriv->delay); in dvb_frontend_thread()
689 if (!down_interruptible(&fepriv->sem)) in dvb_frontend_thread()
691 fe->exit = DVB_FE_NORMAL_EXIT; in dvb_frontend_thread()
695 if (down_interruptible(&fepriv->sem)) in dvb_frontend_thread()
698 if (fepriv->reinitialise) { in dvb_frontend_thread()
700 if (fe->ops.set_tone && fepriv->tone != -1) in dvb_frontend_thread()
701 fe->ops.set_tone(fe, fepriv->tone); in dvb_frontend_thread()
702 if (fe->ops.set_voltage && fepriv->voltage != -1) in dvb_frontend_thread()
703 fe->ops.set_voltage(fe, fepriv->voltage); in dvb_frontend_thread()
704 fepriv->reinitialise = 0; in dvb_frontend_thread()
708 if (fe->ops.get_frontend_algo) { in dvb_frontend_thread()
709 algo = fe->ops.get_frontend_algo(fe); in dvb_frontend_thread()
712 dev_dbg(fe->dvb->device, "%s: Frontend ALGO = DVBFE_ALGO_HW\n", __func__); in dvb_frontend_thread()
714 if (fepriv->state & FESTATE_RETUNE) { in dvb_frontend_thread()
715 dev_dbg(fe->dvb->device, "%s: Retune requested, FESTATE_RETUNE\n", __func__); in dvb_frontend_thread()
717 fepriv->state = FESTATE_TUNED; in dvb_frontend_thread()
722 if (fe->ops.tune) in dvb_frontend_thread()
723 fe->ops.tune(fe, re_tune, fepriv->tune_mode_flags, &fepriv->delay, &s); in dvb_frontend_thread()
725 if (s != fepriv->status && !(fepriv->tune_mode_flags & FE_TUNE_MODE_ONESHOT)) { in dvb_frontend_thread()
726 dev_dbg(fe->dvb->device, "%s: state changed, adding current state\n", __func__); in dvb_frontend_thread()
728 fepriv->status = s; in dvb_frontend_thread()
732 dev_dbg(fe->dvb->device, "%s: Frontend ALGO = DVBFE_ALGO_SW\n", __func__); in dvb_frontend_thread()
736 …dev_dbg(fe->dvb->device, "%s: Frontend ALGO = DVBFE_ALGO_CUSTOM, state=%d\n", __func__, fepriv->st… in dvb_frontend_thread()
737 if (fepriv->state & FESTATE_RETUNE) { in dvb_frontend_thread()
738 dev_dbg(fe->dvb->device, "%s: Retune requested, FESTAT_RETUNE\n", __func__); in dvb_frontend_thread()
739 fepriv->state = FESTATE_TUNED; in dvb_frontend_thread()
745 if (fepriv->algo_status & DVBFE_ALGO_SEARCH_AGAIN) { in dvb_frontend_thread()
746 if (fe->ops.search) { in dvb_frontend_thread()
747 fepriv->algo_status = fe->ops.search(fe); in dvb_frontend_thread()
752 fepriv->algo_status &= ~DVBFE_ALGO_SEARCH_AGAIN; in dvb_frontend_thread()
756 if (fepriv->algo_status != DVBFE_ALGO_SEARCH_SUCCESS) { in dvb_frontend_thread()
757 fepriv->algo_status |= DVBFE_ALGO_SEARCH_AGAIN; in dvb_frontend_thread()
758 fepriv->delay = HZ / 2; in dvb_frontend_thread()
760 dtv_property_legacy_params_sync(fe, c, &fepriv->parameters_out); in dvb_frontend_thread()
761 fe->ops.read_status(fe, &s); in dvb_frontend_thread()
762 if (s != fepriv->status) { in dvb_frontend_thread()
764 fepriv->status = s; in dvb_frontend_thread()
766 fepriv->delay = HZ / 10; in dvb_frontend_thread()
767 fepriv->algo_status |= DVBFE_ALGO_SEARCH_AGAIN; in dvb_frontend_thread()
769 fepriv->delay = 60 * HZ; in dvb_frontend_thread()
774 dev_dbg(fe->dvb->device, "%s: UNDEFINED ALGO !\n", __func__); in dvb_frontend_thread()
783 if (fe->ops.set_voltage) in dvb_frontend_thread()
784 fe->ops.set_voltage(fe, SEC_VOLTAGE_OFF); in dvb_frontend_thread()
785 if (fe->ops.tuner_ops.sleep) { in dvb_frontend_thread()
786 if (fe->ops.i2c_gate_ctrl) in dvb_frontend_thread()
787 fe->ops.i2c_gate_ctrl(fe, 1); in dvb_frontend_thread()
788 fe->ops.tuner_ops.sleep(fe); in dvb_frontend_thread()
789 if (fe->ops.i2c_gate_ctrl) in dvb_frontend_thread()
790 fe->ops.i2c_gate_ctrl(fe, 0); in dvb_frontend_thread()
792 if (fe->ops.sleep) in dvb_frontend_thread()
793 fe->ops.sleep(fe); in dvb_frontend_thread()
796 fepriv->thread = NULL; in dvb_frontend_thread()
798 fe->exit = DVB_FE_DEVICE_REMOVED; in dvb_frontend_thread()
800 fe->exit = DVB_FE_NO_EXIT; in dvb_frontend_thread()
804 up(&fepriv->sem); in dvb_frontend_thread()
811 struct dvb_frontend_private *fepriv = fe->frontend_priv; in dvb_frontend_stop()
813 dev_dbg(fe->dvb->device, "%s:\n", __func__); in dvb_frontend_stop()
815 if (fe->exit != DVB_FE_DEVICE_REMOVED) in dvb_frontend_stop()
816 fe->exit = DVB_FE_NORMAL_EXIT; in dvb_frontend_stop()
819 if (!fepriv->thread) in dvb_frontend_stop()
822 kthread_stop(fepriv->thread); in dvb_frontend_stop()
824 sema_init(&fepriv->sem, 1); in dvb_frontend_stop()
825 fepriv->state = FESTATE_IDLE; in dvb_frontend_stop()
828 if (fepriv->thread) in dvb_frontend_stop()
829 dev_warn(fe->dvb->device, in dvb_frontend_stop()
831 fepriv->thread); in dvb_frontend_stop()
848 msleep((delta - 1500) / 1000); in dvb_frontend_sleep_until()
859 struct dvb_frontend_private *fepriv = fe->frontend_priv; in dvb_frontend_start()
862 dev_dbg(fe->dvb->device, "%s:\n", __func__); in dvb_frontend_start()
864 if (fepriv->thread) { in dvb_frontend_start()
865 if (fe->exit == DVB_FE_NO_EXIT) in dvb_frontend_start()
872 return -EINTR; in dvb_frontend_start()
873 if (down_interruptible(&fepriv->sem)) in dvb_frontend_start()
874 return -EINTR; in dvb_frontend_start()
876 fepriv->state = FESTATE_IDLE; in dvb_frontend_start()
877 fe->exit = DVB_FE_NO_EXIT; in dvb_frontend_start()
878 fepriv->thread = NULL; in dvb_frontend_start()
882 "kdvb-ad-%i-fe-%i", fe->dvb->num, fe->id); in dvb_frontend_start()
885 dev_warn(fe->dvb->device, in dvb_frontend_start()
888 up(&fepriv->sem); in dvb_frontend_start()
891 fepriv->thread = fe_thread; in dvb_frontend_start()
899 struct dtv_frontend_properties *c = &fe->dtv_property_cache; in dvb_frontend_get_frequency_limits()
900 u32 tuner_min = fe->ops.tuner_ops.info.frequency_min_hz; in dvb_frontend_get_frequency_limits()
901 u32 tuner_max = fe->ops.tuner_ops.info.frequency_max_hz; in dvb_frontend_get_frequency_limits()
902 u32 frontend_min = fe->ops.info.frequency_min_hz; in dvb_frontend_get_frequency_limits()
903 u32 frontend_max = fe->ops.info.frequency_max_hz; in dvb_frontend_get_frequency_limits()
915 dev_warn(fe->dvb->device, in dvb_frontend_get_frequency_limits()
916 "DVB: adapter %i frontend %u frequency limits undefined - fix the driver\n", in dvb_frontend_get_frequency_limits()
917 fe->dvb->num, fe->id); in dvb_frontend_get_frequency_limits()
919 dev_dbg(fe->dvb->device, "frequency interval: tuner: %u...%u, frontend: %u...%u", in dvb_frontend_get_frequency_limits()
923 switch (c->delivery_system) { in dvb_frontend_get_frequency_limits()
932 *tolerance = fe->ops.info.frequency_tolerance_hz / kHz; in dvb_frontend_get_frequency_limits()
937 *tolerance = fe->ops.info.frequency_tolerance_hz; in dvb_frontend_get_frequency_limits()
944 struct dtv_frontend_properties *c = &fe->dtv_property_cache; in dvb_frontend_get_stepsize()
945 u32 fe_step = fe->ops.info.frequency_stepsize_hz; in dvb_frontend_get_stepsize()
946 u32 tuner_step = fe->ops.tuner_ops.info.frequency_step_hz; in dvb_frontend_get_stepsize()
949 switch (c->delivery_system) { in dvb_frontend_get_stepsize()
966 struct dtv_frontend_properties *c = &fe->dtv_property_cache; in dvb_frontend_check_parameters()
972 if ((freq_min && c->frequency < freq_min) || in dvb_frontend_check_parameters()
973 (freq_max && c->frequency > freq_max)) { in dvb_frontend_check_parameters()
974 dev_warn(fe->dvb->device, "DVB: adapter %i frontend %i frequency %u out of range (%u..%u)\n", in dvb_frontend_check_parameters()
975 fe->dvb->num, fe->id, c->frequency, in dvb_frontend_check_parameters()
977 return -EINVAL; in dvb_frontend_check_parameters()
981 switch (c->delivery_system) { in dvb_frontend_check_parameters()
988 if ((fe->ops.info.symbol_rate_min && in dvb_frontend_check_parameters()
989 c->symbol_rate < fe->ops.info.symbol_rate_min) || in dvb_frontend_check_parameters()
990 (fe->ops.info.symbol_rate_max && in dvb_frontend_check_parameters()
991 c->symbol_rate > fe->ops.info.symbol_rate_max)) { in dvb_frontend_check_parameters()
992 dev_warn(fe->dvb->device, "DVB: adapter %i frontend %i symbol rate %u out of range (%u..%u)\n", in dvb_frontend_check_parameters()
993 fe->dvb->num, fe->id, c->symbol_rate, in dvb_frontend_check_parameters()
994 fe->ops.info.symbol_rate_min, in dvb_frontend_check_parameters()
995 fe->ops.info.symbol_rate_max); in dvb_frontend_check_parameters()
996 return -EINVAL; in dvb_frontend_check_parameters()
1008 struct dtv_frontend_properties *c = &fe->dtv_property_cache; in dvb_frontend_clear_cache()
1012 delsys = c->delivery_system; in dvb_frontend_clear_cache()
1014 c->delivery_system = delsys; in dvb_frontend_clear_cache()
1016 dev_dbg(fe->dvb->device, "%s: Clearing cache for delivery system %d\n", in dvb_frontend_clear_cache()
1017 __func__, c->delivery_system); in dvb_frontend_clear_cache()
1019 c->transmission_mode = TRANSMISSION_MODE_AUTO; in dvb_frontend_clear_cache()
1020 c->bandwidth_hz = 0; /* AUTO */ in dvb_frontend_clear_cache()
1021 c->guard_interval = GUARD_INTERVAL_AUTO; in dvb_frontend_clear_cache()
1022 c->hierarchy = HIERARCHY_AUTO; in dvb_frontend_clear_cache()
1023 c->symbol_rate = 0; in dvb_frontend_clear_cache()
1024 c->code_rate_HP = FEC_AUTO; in dvb_frontend_clear_cache()
1025 c->code_rate_LP = FEC_AUTO; in dvb_frontend_clear_cache()
1026 c->fec_inner = FEC_AUTO; in dvb_frontend_clear_cache()
1027 c->rolloff = ROLLOFF_AUTO; in dvb_frontend_clear_cache()
1028 c->voltage = SEC_VOLTAGE_OFF; in dvb_frontend_clear_cache()
1029 c->sectone = SEC_TONE_OFF; in dvb_frontend_clear_cache()
1030 c->pilot = PILOT_AUTO; in dvb_frontend_clear_cache()
1032 c->isdbt_partial_reception = 0; in dvb_frontend_clear_cache()
1033 c->isdbt_sb_mode = 0; in dvb_frontend_clear_cache()
1034 c->isdbt_sb_subchannel = 0; in dvb_frontend_clear_cache()
1035 c->isdbt_sb_segment_idx = 0; in dvb_frontend_clear_cache()
1036 c->isdbt_sb_segment_count = 0; in dvb_frontend_clear_cache()
1037 c->isdbt_layer_enabled = 7; /* All layers (A,B,C) */ in dvb_frontend_clear_cache()
1039 c->layer[i].fec = FEC_AUTO; in dvb_frontend_clear_cache()
1040 c->layer[i].modulation = QAM_AUTO; in dvb_frontend_clear_cache()
1041 c->layer[i].interleaving = 0; in dvb_frontend_clear_cache()
1042 c->layer[i].segment_count = 0; in dvb_frontend_clear_cache()
1045 c->stream_id = NO_STREAM_ID_FILTER; in dvb_frontend_clear_cache()
1046 c->scrambling_sequence_index = 0;/* default sequence */ in dvb_frontend_clear_cache()
1048 switch (c->delivery_system) { in dvb_frontend_clear_cache()
1050 c->modulation = QPSK; in dvb_frontend_clear_cache()
1051 c->rolloff = ROLLOFF_20; in dvb_frontend_clear_cache()
1056 c->modulation = QPSK; /* implied for DVB-S in legacy API */ in dvb_frontend_clear_cache()
1057 c->rolloff = ROLLOFF_35;/* implied for DVB-S */ in dvb_frontend_clear_cache()
1060 c->modulation = VSB_8; in dvb_frontend_clear_cache()
1063 c->symbol_rate = 28860000; in dvb_frontend_clear_cache()
1064 c->rolloff = ROLLOFF_35; in dvb_frontend_clear_cache()
1065 c->bandwidth_hz = c->symbol_rate / 100 * 135; in dvb_frontend_clear_cache()
1068 c->modulation = QAM_AUTO; in dvb_frontend_clear_cache()
1072 c->lna = LNA_AUTO; in dvb_frontend_clear_cache()
1176 c->frequency = p->frequency; in dtv_property_cache_sync()
1177 c->inversion = p->inversion; in dtv_property_cache_sync()
1179 switch (dvbv3_type(c->delivery_system)) { in dtv_property_cache_sync()
1181 dev_dbg(fe->dvb->device, "%s: Preparing QPSK req\n", __func__); in dtv_property_cache_sync()
1182 c->symbol_rate = p->u.qpsk.symbol_rate; in dtv_property_cache_sync()
1183 c->fec_inner = p->u.qpsk.fec_inner; in dtv_property_cache_sync()
1186 dev_dbg(fe->dvb->device, "%s: Preparing QAM req\n", __func__); in dtv_property_cache_sync()
1187 c->symbol_rate = p->u.qam.symbol_rate; in dtv_property_cache_sync()
1188 c->fec_inner = p->u.qam.fec_inner; in dtv_property_cache_sync()
1189 c->modulation = p->u.qam.modulation; in dtv_property_cache_sync()
1192 dev_dbg(fe->dvb->device, "%s: Preparing OFDM req\n", __func__); in dtv_property_cache_sync()
1194 switch (p->u.ofdm.bandwidth) { in dtv_property_cache_sync()
1196 c->bandwidth_hz = 10000000; in dtv_property_cache_sync()
1199 c->bandwidth_hz = 8000000; in dtv_property_cache_sync()
1202 c->bandwidth_hz = 7000000; in dtv_property_cache_sync()
1205 c->bandwidth_hz = 6000000; in dtv_property_cache_sync()
1208 c->bandwidth_hz = 5000000; in dtv_property_cache_sync()
1211 c->bandwidth_hz = 1712000; in dtv_property_cache_sync()
1214 c->bandwidth_hz = 0; in dtv_property_cache_sync()
1217 c->code_rate_HP = p->u.ofdm.code_rate_HP; in dtv_property_cache_sync()
1218 c->code_rate_LP = p->u.ofdm.code_rate_LP; in dtv_property_cache_sync()
1219 c->modulation = p->u.ofdm.constellation; in dtv_property_cache_sync()
1220 c->transmission_mode = p->u.ofdm.transmission_mode; in dtv_property_cache_sync()
1221 c->guard_interval = p->u.ofdm.guard_interval; in dtv_property_cache_sync()
1222 c->hierarchy = p->u.ofdm.hierarchy_information; in dtv_property_cache_sync()
1225 dev_dbg(fe->dvb->device, "%s: Preparing ATSC req\n", __func__); in dtv_property_cache_sync()
1226 c->modulation = p->u.vsb.modulation; in dtv_property_cache_sync()
1227 if (c->delivery_system == SYS_ATSCMH) in dtv_property_cache_sync()
1229 if ((c->modulation == VSB_8) || (c->modulation == VSB_16)) in dtv_property_cache_sync()
1230 c->delivery_system = SYS_ATSC; in dtv_property_cache_sync()
1232 c->delivery_system = SYS_DVBC_ANNEX_B; in dtv_property_cache_sync()
1235 dev_err(fe->dvb->device, in dtv_property_cache_sync()
1237 __func__, c->delivery_system); in dtv_property_cache_sync()
1238 return -EINVAL; in dtv_property_cache_sync()
1252 p->frequency = c->frequency; in dtv_property_legacy_params_sync()
1253 p->inversion = c->inversion; in dtv_property_legacy_params_sync()
1255 switch (dvbv3_type(c->delivery_system)) { in dtv_property_legacy_params_sync()
1257 dev_err(fe->dvb->device, in dtv_property_legacy_params_sync()
1259 __func__, c->delivery_system); in dtv_property_legacy_params_sync()
1260 return -EINVAL; in dtv_property_legacy_params_sync()
1262 dev_dbg(fe->dvb->device, "%s: Preparing QPSK req\n", __func__); in dtv_property_legacy_params_sync()
1263 p->u.qpsk.symbol_rate = c->symbol_rate; in dtv_property_legacy_params_sync()
1264 p->u.qpsk.fec_inner = c->fec_inner; in dtv_property_legacy_params_sync()
1267 dev_dbg(fe->dvb->device, "%s: Preparing QAM req\n", __func__); in dtv_property_legacy_params_sync()
1268 p->u.qam.symbol_rate = c->symbol_rate; in dtv_property_legacy_params_sync()
1269 p->u.qam.fec_inner = c->fec_inner; in dtv_property_legacy_params_sync()
1270 p->u.qam.modulation = c->modulation; in dtv_property_legacy_params_sync()
1273 dev_dbg(fe->dvb->device, "%s: Preparing OFDM req\n", __func__); in dtv_property_legacy_params_sync()
1274 switch (c->bandwidth_hz) { in dtv_property_legacy_params_sync()
1276 p->u.ofdm.bandwidth = BANDWIDTH_10_MHZ; in dtv_property_legacy_params_sync()
1279 p->u.ofdm.bandwidth = BANDWIDTH_8_MHZ; in dtv_property_legacy_params_sync()
1282 p->u.ofdm.bandwidth = BANDWIDTH_7_MHZ; in dtv_property_legacy_params_sync()
1285 p->u.ofdm.bandwidth = BANDWIDTH_6_MHZ; in dtv_property_legacy_params_sync()
1288 p->u.ofdm.bandwidth = BANDWIDTH_5_MHZ; in dtv_property_legacy_params_sync()
1291 p->u.ofdm.bandwidth = BANDWIDTH_1_712_MHZ; in dtv_property_legacy_params_sync()
1295 p->u.ofdm.bandwidth = BANDWIDTH_AUTO; in dtv_property_legacy_params_sync()
1297 p->u.ofdm.code_rate_HP = c->code_rate_HP; in dtv_property_legacy_params_sync()
1298 p->u.ofdm.code_rate_LP = c->code_rate_LP; in dtv_property_legacy_params_sync()
1299 p->u.ofdm.constellation = c->modulation; in dtv_property_legacy_params_sync()
1300 p->u.ofdm.transmission_mode = c->transmission_mode; in dtv_property_legacy_params_sync()
1301 p->u.ofdm.guard_interval = c->guard_interval; in dtv_property_legacy_params_sync()
1302 p->u.ofdm.hierarchy_information = c->hierarchy; in dtv_property_legacy_params_sync()
1305 dev_dbg(fe->dvb->device, "%s: Preparing VSB req\n", __func__); in dtv_property_legacy_params_sync()
1306 p->u.vsb.modulation = c->modulation; in dtv_property_legacy_params_sync()
1313 * dtv_get_frontend - calls a callback for retrieving DTV parameters
1328 if (fe->ops.get_frontend) { in dtv_get_frontend()
1329 r = fe->ops.get_frontend(fe, c); in dtv_get_frontend()
1352 switch (tvp->cmd) { in dtv_property_process_get()
1355 while (ncaps < MAX_DELSYS && fe->ops.delsys[ncaps]) { in dtv_property_process_get()
1356 tvp->u.buffer.data[ncaps] = fe->ops.delsys[ncaps]; in dtv_property_process_get()
1359 tvp->u.buffer.len = ncaps; in dtv_property_process_get()
1363 tvp->u.data = c->frequency; in dtv_property_process_get()
1366 tvp->u.data = c->modulation; in dtv_property_process_get()
1369 tvp->u.data = c->bandwidth_hz; in dtv_property_process_get()
1372 tvp->u.data = c->inversion; in dtv_property_process_get()
1375 tvp->u.data = c->symbol_rate; in dtv_property_process_get()
1378 tvp->u.data = c->fec_inner; in dtv_property_process_get()
1381 tvp->u.data = c->pilot; in dtv_property_process_get()
1384 tvp->u.data = c->rolloff; in dtv_property_process_get()
1387 tvp->u.data = c->delivery_system; in dtv_property_process_get()
1390 tvp->u.data = c->voltage; in dtv_property_process_get()
1393 tvp->u.data = c->sectone; in dtv_property_process_get()
1396 tvp->u.data = (DVB_API_VERSION << 8) | DVB_API_VERSION_MINOR; in dtv_property_process_get()
1399 tvp->u.data = c->code_rate_HP; in dtv_property_process_get()
1402 tvp->u.data = c->code_rate_LP; in dtv_property_process_get()
1405 tvp->u.data = c->guard_interval; in dtv_property_process_get()
1408 tvp->u.data = c->transmission_mode; in dtv_property_process_get()
1411 tvp->u.data = c->hierarchy; in dtv_property_process_get()
1414 tvp->u.data = c->interleaving; in dtv_property_process_get()
1417 /* ISDB-T Support here */ in dtv_property_process_get()
1419 tvp->u.data = c->isdbt_partial_reception; in dtv_property_process_get()
1422 tvp->u.data = c->isdbt_sb_mode; in dtv_property_process_get()
1425 tvp->u.data = c->isdbt_sb_subchannel; in dtv_property_process_get()
1428 tvp->u.data = c->isdbt_sb_segment_idx; in dtv_property_process_get()
1431 tvp->u.data = c->isdbt_sb_segment_count; in dtv_property_process_get()
1434 tvp->u.data = c->isdbt_layer_enabled; in dtv_property_process_get()
1437 tvp->u.data = c->layer[0].fec; in dtv_property_process_get()
1440 tvp->u.data = c->layer[0].modulation; in dtv_property_process_get()
1443 tvp->u.data = c->layer[0].segment_count; in dtv_property_process_get()
1446 tvp->u.data = c->layer[0].interleaving; in dtv_property_process_get()
1449 tvp->u.data = c->layer[1].fec; in dtv_property_process_get()
1452 tvp->u.data = c->layer[1].modulation; in dtv_property_process_get()
1455 tvp->u.data = c->layer[1].segment_count; in dtv_property_process_get()
1458 tvp->u.data = c->layer[1].interleaving; in dtv_property_process_get()
1461 tvp->u.data = c->layer[2].fec; in dtv_property_process_get()
1464 tvp->u.data = c->layer[2].modulation; in dtv_property_process_get()
1467 tvp->u.data = c->layer[2].segment_count; in dtv_property_process_get()
1470 tvp->u.data = c->layer[2].interleaving; in dtv_property_process_get()
1476 tvp->u.data = c->stream_id; in dtv_property_process_get()
1481 tvp->u.data = c->scrambling_sequence_index; in dtv_property_process_get()
1484 /* ATSC-MH */ in dtv_property_process_get()
1486 tvp->u.data = fe->dtv_property_cache.atscmh_fic_ver; in dtv_property_process_get()
1489 tvp->u.data = fe->dtv_property_cache.atscmh_parade_id; in dtv_property_process_get()
1492 tvp->u.data = fe->dtv_property_cache.atscmh_nog; in dtv_property_process_get()
1495 tvp->u.data = fe->dtv_property_cache.atscmh_tnog; in dtv_property_process_get()
1498 tvp->u.data = fe->dtv_property_cache.atscmh_sgn; in dtv_property_process_get()
1501 tvp->u.data = fe->dtv_property_cache.atscmh_prc; in dtv_property_process_get()
1504 tvp->u.data = fe->dtv_property_cache.atscmh_rs_frame_mode; in dtv_property_process_get()
1507 tvp->u.data = fe->dtv_property_cache.atscmh_rs_frame_ensemble; in dtv_property_process_get()
1510 tvp->u.data = fe->dtv_property_cache.atscmh_rs_code_mode_pri; in dtv_property_process_get()
1513 tvp->u.data = fe->dtv_property_cache.atscmh_rs_code_mode_sec; in dtv_property_process_get()
1516 tvp->u.data = fe->dtv_property_cache.atscmh_sccc_block_mode; in dtv_property_process_get()
1519 tvp->u.data = fe->dtv_property_cache.atscmh_sccc_code_mode_a; in dtv_property_process_get()
1522 tvp->u.data = fe->dtv_property_cache.atscmh_sccc_code_mode_b; in dtv_property_process_get()
1525 tvp->u.data = fe->dtv_property_cache.atscmh_sccc_code_mode_c; in dtv_property_process_get()
1528 tvp->u.data = fe->dtv_property_cache.atscmh_sccc_code_mode_d; in dtv_property_process_get()
1532 tvp->u.data = c->lna; in dtv_property_process_get()
1537 tvp->u.st = c->strength; in dtv_property_process_get()
1538 if (tvp->u.buffer.len > MAX_DTV_STATS * sizeof(u32)) in dtv_property_process_get()
1539 tvp->u.buffer.len = MAX_DTV_STATS * sizeof(u32); in dtv_property_process_get()
1540 len = tvp->u.buffer.len; in dtv_property_process_get()
1543 tvp->u.st = c->cnr; in dtv_property_process_get()
1544 if (tvp->u.buffer.len > MAX_DTV_STATS * sizeof(u32)) in dtv_property_process_get()
1545 tvp->u.buffer.len = MAX_DTV_STATS * sizeof(u32); in dtv_property_process_get()
1546 len = tvp->u.buffer.len; in dtv_property_process_get()
1549 tvp->u.st = c->pre_bit_error; in dtv_property_process_get()
1550 if (tvp->u.buffer.len > MAX_DTV_STATS * sizeof(u32)) in dtv_property_process_get()
1551 tvp->u.buffer.len = MAX_DTV_STATS * sizeof(u32); in dtv_property_process_get()
1552 len = tvp->u.buffer.len; in dtv_property_process_get()
1555 tvp->u.st = c->pre_bit_count; in dtv_property_process_get()
1556 if (tvp->u.buffer.len > MAX_DTV_STATS * sizeof(u32)) in dtv_property_process_get()
1557 tvp->u.buffer.len = MAX_DTV_STATS * sizeof(u32); in dtv_property_process_get()
1558 len = tvp->u.buffer.len; in dtv_property_process_get()
1561 tvp->u.st = c->post_bit_error; in dtv_property_process_get()
1562 if (tvp->u.buffer.len > MAX_DTV_STATS * sizeof(u32)) in dtv_property_process_get()
1563 tvp->u.buffer.len = MAX_DTV_STATS * sizeof(u32); in dtv_property_process_get()
1564 len = tvp->u.buffer.len; in dtv_property_process_get()
1567 tvp->u.st = c->post_bit_count; in dtv_property_process_get()
1568 if (tvp->u.buffer.len > MAX_DTV_STATS * sizeof(u32)) in dtv_property_process_get()
1569 tvp->u.buffer.len = MAX_DTV_STATS * sizeof(u32); in dtv_property_process_get()
1570 len = tvp->u.buffer.len; in dtv_property_process_get()
1573 tvp->u.st = c->block_error; in dtv_property_process_get()
1574 if (tvp->u.buffer.len > MAX_DTV_STATS * sizeof(u32)) in dtv_property_process_get()
1575 tvp->u.buffer.len = MAX_DTV_STATS * sizeof(u32); in dtv_property_process_get()
1576 len = tvp->u.buffer.len; in dtv_property_process_get()
1579 tvp->u.st = c->block_count; in dtv_property_process_get()
1580 if (tvp->u.buffer.len > MAX_DTV_STATS * sizeof(u32)) in dtv_property_process_get()
1581 tvp->u.buffer.len = MAX_DTV_STATS * sizeof(u32); in dtv_property_process_get()
1582 len = tvp->u.buffer.len; in dtv_property_process_get()
1585 dev_dbg(fe->dvb->device, in dtv_property_process_get()
1587 __func__, tvp->cmd); in dtv_property_process_get()
1588 return -EINVAL; in dtv_property_process_get()
1594 dev_dbg(fe->dvb->device, in dtv_property_process_get()
1596 __func__, tvp->cmd, dtv_cmd_name(tvp->cmd), in dtv_property_process_get()
1597 tvp->u.buffer.len, tvp->u.buffer.len, tvp->u.buffer.data); in dtv_property_process_get()
1611 * emulate_delivery_system - emulate a DVBv5 delivery system with a DVBv3 type
1616 * DVBv3 call. Among its usages, it provices support for ISDB-T, and allows
1617 * using a DVB-S2 only frontend just like it were a DVB-S, if the frontend
1618 * parameters are compatible with DVB-S spec.
1623 struct dtv_frontend_properties *c = &fe->dtv_property_cache; in emulate_delivery_system()
1625 c->delivery_system = delsys; in emulate_delivery_system()
1628 * If the call is for ISDB-T, put it into full-seg, auto mode, TV in emulate_delivery_system()
1630 if (c->delivery_system == SYS_ISDBT) { in emulate_delivery_system()
1631 dev_dbg(fe->dvb->device, in emulate_delivery_system()
1635 if (!c->bandwidth_hz) in emulate_delivery_system()
1636 c->bandwidth_hz = 6000000; in emulate_delivery_system()
1638 c->isdbt_partial_reception = 0; in emulate_delivery_system()
1639 c->isdbt_sb_mode = 0; in emulate_delivery_system()
1640 c->isdbt_sb_subchannel = 0; in emulate_delivery_system()
1641 c->isdbt_sb_segment_idx = 0; in emulate_delivery_system()
1642 c->isdbt_sb_segment_count = 0; in emulate_delivery_system()
1643 c->isdbt_layer_enabled = 7; in emulate_delivery_system()
1645 c->layer[i].fec = FEC_AUTO; in emulate_delivery_system()
1646 c->layer[i].modulation = QAM_AUTO; in emulate_delivery_system()
1647 c->layer[i].interleaving = 0; in emulate_delivery_system()
1648 c->layer[i].segment_count = 0; in emulate_delivery_system()
1651 dev_dbg(fe->dvb->device, "%s: change delivery system on cache to %d\n", in emulate_delivery_system()
1652 __func__, c->delivery_system); in emulate_delivery_system()
1658 * dvbv5_set_delivery_system - Sets the delivery system for a DVBv5 API call
1672 * ISDB-T provided backward compat with DVB-T.
1679 struct dtv_frontend_properties *c = &fe->dtv_property_cache; in dvbv5_set_delivery_system()
1689 desired_system = fe->ops.delsys[0]; in dvbv5_set_delivery_system()
1697 while (ncaps < MAX_DELSYS && fe->ops.delsys[ncaps]) { in dvbv5_set_delivery_system()
1698 if (fe->ops.delsys[ncaps] == desired_system) { in dvbv5_set_delivery_system()
1699 c->delivery_system = desired_system; in dvbv5_set_delivery_system()
1700 dev_dbg(fe->dvb->device, in dvbv5_set_delivery_system()
1716 dev_dbg(fe->dvb->device, in dvbv5_set_delivery_system()
1719 return -EINVAL; in dvbv5_set_delivery_system()
1725 * Get the last non-DVBv3 delivery system that has the same type in dvbv5_set_delivery_system()
1729 while (ncaps < MAX_DELSYS && fe->ops.delsys[ncaps]) { in dvbv5_set_delivery_system()
1730 if (dvbv3_type(fe->ops.delsys[ncaps]) == type) in dvbv5_set_delivery_system()
1731 delsys = fe->ops.delsys[ncaps]; in dvbv5_set_delivery_system()
1737 dev_dbg(fe->dvb->device, in dvbv5_set_delivery_system()
1740 return -EINVAL; in dvbv5_set_delivery_system()
1743 dev_dbg(fe->dvb->device, in dvbv5_set_delivery_system()
1751 * dvbv3_set_delivery_system - Sets the delivery system for a DVBv3 API call
1762 * This routine should work fine for frontends that support just one delivery
1773 * uses a DVBv5 call for DVB-S2 and a DVBv3 call to go back to
1774 * DVB-S, drivers that support both DVB-S and DVB-S2 should have the
1776 * to DVB-S.
1782 struct dtv_frontend_properties *c = &fe->dtv_property_cache; in dvbv3_set_delivery_system()
1785 if (c->delivery_system == SYS_UNDEFINED) in dvbv3_set_delivery_system()
1786 c->delivery_system = fe->ops.delsys[0]; in dvbv3_set_delivery_system()
1792 if (is_dvbv3_delsys(c->delivery_system)) { in dvbv3_set_delivery_system()
1793 dev_dbg(fe->dvb->device, in dvbv3_set_delivery_system()
1795 __func__, c->delivery_system); in dvbv3_set_delivery_system()
1804 while (ncaps < MAX_DELSYS && fe->ops.delsys[ncaps]) { in dvbv3_set_delivery_system()
1805 if (dvbv3_type(fe->ops.delsys[ncaps]) != DVBV3_UNKNOWN) { in dvbv3_set_delivery_system()
1806 delsys = fe->ops.delsys[ncaps]; in dvbv3_set_delivery_system()
1812 dev_dbg(fe->dvb->device, in dvbv3_set_delivery_system()
1815 return -EINVAL; in dvbv3_set_delivery_system()
1822 struct dtv_frontend_properties *c = &fe->dtv_property_cache; in prepare_tuning_algo_parameters()
1823 struct dvb_frontend_private *fepriv = fe->frontend_priv; in prepare_tuning_algo_parameters()
1826 /* get frontend-specific tuning settings */ in prepare_tuning_algo_parameters()
1827 if (fe->ops.get_tune_settings && (fe->ops.get_tune_settings(fe, &fetunesettings) == 0)) { in prepare_tuning_algo_parameters()
1828 fepriv->min_delay = (fetunesettings.min_delay_ms * HZ) / 1000; in prepare_tuning_algo_parameters()
1829 fepriv->max_drift = fetunesettings.max_drift; in prepare_tuning_algo_parameters()
1830 fepriv->step_size = fetunesettings.step_size; in prepare_tuning_algo_parameters()
1833 switch (c->delivery_system) { in prepare_tuning_algo_parameters()
1841 fepriv->min_delay = HZ / 20; in prepare_tuning_algo_parameters()
1842 fepriv->step_size = c->symbol_rate / 16000; in prepare_tuning_algo_parameters()
1843 fepriv->max_drift = c->symbol_rate / 2000; in prepare_tuning_algo_parameters()
1849 fepriv->min_delay = HZ / 20; in prepare_tuning_algo_parameters()
1850 fepriv->step_size = dvb_frontend_get_stepsize(fe) * 2; in prepare_tuning_algo_parameters()
1851 fepriv->max_drift = fepriv->step_size + 1; in prepare_tuning_algo_parameters()
1858 fepriv->min_delay = HZ / 20; in prepare_tuning_algo_parameters()
1859 fepriv->step_size = 0; /* no zigzag */ in prepare_tuning_algo_parameters()
1860 fepriv->max_drift = 0; in prepare_tuning_algo_parameters()
1865 fepriv->min_delay = (dvb_override_tune_delay * HZ) / 1000; in prepare_tuning_algo_parameters()
1869 * dtv_property_process_set - Sets a single DTV property
1873 * @data: An unsigned 32-bits number
1887 struct dtv_frontend_properties *c = &fe->dtv_property_cache; in dtv_property_process_set()
1891 dev_warn(fe->dvb->device, "%s: SET cmd 0x%08x undefined\n", in dtv_property_process_set()
1894 dev_dbg(fe->dvb->device, in dtv_property_process_set()
1907 * Use the cached Digital TV properties to tune the in dtv_property_process_set()
1910 dev_dbg(fe->dvb->device, in dtv_property_process_set()
1917 c->frequency = data; in dtv_property_process_set()
1920 c->modulation = data; in dtv_property_process_set()
1923 c->bandwidth_hz = data; in dtv_property_process_set()
1926 c->inversion = data; in dtv_property_process_set()
1929 c->symbol_rate = data; in dtv_property_process_set()
1932 c->fec_inner = data; in dtv_property_process_set()
1935 c->pilot = data; in dtv_property_process_set()
1938 c->rolloff = data; in dtv_property_process_set()
1944 c->voltage = data; in dtv_property_process_set()
1946 (void *)c->voltage); in dtv_property_process_set()
1949 c->sectone = data; in dtv_property_process_set()
1951 (void *)c->sectone); in dtv_property_process_set()
1954 c->code_rate_HP = data; in dtv_property_process_set()
1957 c->code_rate_LP = data; in dtv_property_process_set()
1960 c->guard_interval = data; in dtv_property_process_set()
1963 c->transmission_mode = data; in dtv_property_process_set()
1966 c->hierarchy = data; in dtv_property_process_set()
1969 c->interleaving = data; in dtv_property_process_set()
1972 /* ISDB-T Support here */ in dtv_property_process_set()
1974 c->isdbt_partial_reception = data; in dtv_property_process_set()
1977 c->isdbt_sb_mode = data; in dtv_property_process_set()
1980 c->isdbt_sb_subchannel = data; in dtv_property_process_set()
1983 c->isdbt_sb_segment_idx = data; in dtv_property_process_set()
1986 c->isdbt_sb_segment_count = data; in dtv_property_process_set()
1989 c->isdbt_layer_enabled = data; in dtv_property_process_set()
1992 c->layer[0].fec = data; in dtv_property_process_set()
1995 c->layer[0].modulation = data; in dtv_property_process_set()
1998 c->layer[0].segment_count = data; in dtv_property_process_set()
2001 c->layer[0].interleaving = data; in dtv_property_process_set()
2004 c->layer[1].fec = data; in dtv_property_process_set()
2007 c->layer[1].modulation = data; in dtv_property_process_set()
2010 c->layer[1].segment_count = data; in dtv_property_process_set()
2013 c->layer[1].interleaving = data; in dtv_property_process_set()
2016 c->layer[2].fec = data; in dtv_property_process_set()
2019 c->layer[2].modulation = data; in dtv_property_process_set()
2022 c->layer[2].segment_count = data; in dtv_property_process_set()
2025 c->layer[2].interleaving = data; in dtv_property_process_set()
2031 c->stream_id = data; in dtv_property_process_set()
2036 c->scrambling_sequence_index = data; in dtv_property_process_set()
2039 /* ATSC-MH */ in dtv_property_process_set()
2041 fe->dtv_property_cache.atscmh_parade_id = data; in dtv_property_process_set()
2044 fe->dtv_property_cache.atscmh_rs_frame_ensemble = data; in dtv_property_process_set()
2048 c->lna = data; in dtv_property_process_set()
2049 if (fe->ops.set_lna) in dtv_property_process_set()
2050 r = fe->ops.set_lna(fe); in dtv_property_process_set()
2052 c->lna = LNA_AUTO; in dtv_property_process_set()
2056 return -EINVAL; in dtv_property_process_set()
2065 struct dvb_device *dvbdev = file->private_data; in dvb_frontend_do_ioctl()
2066 struct dvb_frontend *fe = dvbdev->priv; in dvb_frontend_do_ioctl()
2067 struct dvb_frontend_private *fepriv = fe->frontend_priv; in dvb_frontend_do_ioctl()
2070 dev_dbg(fe->dvb->device, "%s: (%d)\n", __func__, _IOC_NR(cmd)); in dvb_frontend_do_ioctl()
2071 if (down_interruptible(&fepriv->sem)) in dvb_frontend_do_ioctl()
2072 return -ERESTARTSYS; in dvb_frontend_do_ioctl()
2074 if (fe->exit != DVB_FE_NO_EXIT) { in dvb_frontend_do_ioctl()
2075 up(&fepriv->sem); in dvb_frontend_do_ioctl()
2076 return -ENODEV; in dvb_frontend_do_ioctl()
2080 * If the frontend is opened in read-only mode, only the ioctls in dvb_frontend_do_ioctl()
2081 * that don't interfere with the tune logic should be accepted. in dvb_frontend_do_ioctl()
2086 * - FE_GET_EVENT is part of the tuning logic on a DVB application; in dvb_frontend_do_ioctl()
2087 * - FE_DISEQC_RECV_SLAVE_REPLY is part of DiSEqC 2.0 in dvb_frontend_do_ioctl()
2089 * So, those two ioctls should also return -EPERM, as otherwise in dvb_frontend_do_ioctl()
2090 * reading from them would interfere with a DVB tune application in dvb_frontend_do_ioctl()
2092 if ((file->f_flags & O_ACCMODE) == O_RDONLY in dvb_frontend_do_ioctl()
2096 up(&fepriv->sem); in dvb_frontend_do_ioctl()
2097 return -EPERM; in dvb_frontend_do_ioctl()
2102 up(&fepriv->sem); in dvb_frontend_do_ioctl()
2109 struct dvb_device *dvbdev = file->private_data; in dvb_frontend_ioctl()
2112 return -ENODEV; in dvb_frontend_ioctl()
2145 struct dvb_device *dvbdev = file->private_data; in dvb_frontend_handle_compat_ioctl()
2146 struct dvb_frontend *fe = dvbdev->priv; in dvb_frontend_handle_compat_ioctl()
2147 struct dvb_frontend_private *fepriv = fe->frontend_priv; in dvb_frontend_handle_compat_ioctl()
2155 return -EFAULT; in dvb_frontend_handle_compat_ioctl()
2163 if (!tvps->num || (tvps->num > DTV_IOCTL_MAX_MSGS)) in dvb_frontend_handle_compat_ioctl()
2164 return -EINVAL; in dvb_frontend_handle_compat_ioctl()
2166 tvp = memdup_array_user(compat_ptr(tvps->props), in dvb_frontend_handle_compat_ioctl()
2167 tvps->num, sizeof(*tvp)); in dvb_frontend_handle_compat_ioctl()
2171 for (i = 0; i < tvps->num; i++) { in dvb_frontend_handle_compat_ioctl()
2173 (tvp + i)->cmd, in dvb_frontend_handle_compat_ioctl()
2174 (tvp + i)->u.data); in dvb_frontend_handle_compat_ioctl()
2184 struct dtv_frontend_properties getp = fe->dtv_property_cache; in dvb_frontend_handle_compat_ioctl()
2187 return -EFAULT; in dvb_frontend_handle_compat_ioctl()
2195 if (!tvps->num || (tvps->num > DTV_IOCTL_MAX_MSGS)) in dvb_frontend_handle_compat_ioctl()
2196 return -EINVAL; in dvb_frontend_handle_compat_ioctl()
2198 tvp = memdup_array_user(compat_ptr(tvps->props), in dvb_frontend_handle_compat_ioctl()
2199 tvps->num, sizeof(*tvp)); in dvb_frontend_handle_compat_ioctl()
2209 if (fepriv->state != FESTATE_IDLE) { in dvb_frontend_handle_compat_ioctl()
2216 for (i = 0; i < tvps->num; i++) { in dvb_frontend_handle_compat_ioctl()
2225 if (copy_to_user((void __user *)compat_ptr(tvps->props), tvp, in dvb_frontend_handle_compat_ioctl()
2226 tvps->num * sizeof(struct compat_dtv_property))) { in dvb_frontend_handle_compat_ioctl()
2228 return -EFAULT; in dvb_frontend_handle_compat_ioctl()
2239 struct dvb_device *dvbdev = file->private_data; in dvb_frontend_compat_ioctl()
2240 struct dvb_frontend *fe = dvbdev->priv; in dvb_frontend_compat_ioctl()
2241 struct dvb_frontend_private *fepriv = fe->frontend_priv; in dvb_frontend_compat_ioctl()
2245 if (down_interruptible(&fepriv->sem)) in dvb_frontend_compat_ioctl()
2246 return -ERESTARTSYS; in dvb_frontend_compat_ioctl()
2250 up(&fepriv->sem); in dvb_frontend_compat_ioctl()
2260 struct dvb_frontend_private *fepriv = fe->frontend_priv; in dtv_set_frontend()
2261 struct dtv_frontend_properties *c = &fe->dtv_property_cache; in dtv_set_frontend()
2265 return -EINVAL; in dtv_set_frontend()
2272 dtv_property_legacy_params_sync(fe, c, &fepriv->parameters_out); in dtv_set_frontend()
2276 * non-satellite systems, as tuners need to know what in dtv_set_frontend()
2278 * order to avoid inter-channel noise. in dtv_set_frontend()
2280 * ISDB-T and DVB-T/T2 already sets bandwidth. in dtv_set_frontend()
2281 * ATSC and DVB-C don't set, so, the core should fill it. in dtv_set_frontend()
2283 * On DVB-C Annex A and C, the bandwidth is a function of in dtv_set_frontend()
2284 * the roll-off and symbol rate. Annex B defines different in dtv_set_frontend()
2285 * roll-off factors depending on the modulation. Fortunately, in dtv_set_frontend()
2293 switch (c->delivery_system) { in dtv_set_frontend()
2296 c->bandwidth_hz = 6000000; in dtv_set_frontend()
2313 switch (c->rolloff) { in dtv_set_frontend()
2329 c->bandwidth_hz = mult_frac(c->symbol_rate, rolloff, 100); in dtv_set_frontend()
2333 c->inversion = INVERSION_AUTO; in dtv_set_frontend()
2339 if (c->hierarchy == HIERARCHY_NONE && c->code_rate_LP == FEC_NONE) in dtv_set_frontend()
2340 c->code_rate_LP = FEC_AUTO; in dtv_set_frontend()
2344 fepriv->state = FESTATE_RETUNE; in dtv_set_frontend()
2347 fepriv->algo_status |= DVBFE_ALGO_SEARCH_AGAIN; in dtv_set_frontend()
2352 fepriv->status = 0; in dtv_set_frontend()
2360 struct dvb_frontend_private *fepriv = fe->frontend_priv; in dvb_get_property()
2365 memcpy(&getp, &fe->dtv_property_cache, sizeof(getp)); in dvb_get_property()
2367 dev_dbg(fe->dvb->device, "%s: properties.num = %d\n", in dvb_get_property()
2368 __func__, tvps->num); in dvb_get_property()
2369 dev_dbg(fe->dvb->device, "%s: properties.props = %p\n", in dvb_get_property()
2370 __func__, tvps->props); in dvb_get_property()
2376 if (!tvps->num || tvps->num > DTV_IOCTL_MAX_MSGS) in dvb_get_property()
2377 return -EINVAL; in dvb_get_property()
2379 tvp = memdup_array_user((void __user *)tvps->props, in dvb_get_property()
2380 tvps->num, sizeof(*tvp)); in dvb_get_property()
2390 if (fepriv->state != FESTATE_IDLE) { in dvb_get_property()
2395 for (i = 0; i < tvps->num; i++) { in dvb_get_property()
2402 if (copy_to_user((void __user *)tvps->props, tvp, in dvb_get_property()
2403 tvps->num * sizeof(struct dtv_property))) { in dvb_get_property()
2404 err = -EFAULT; in dvb_get_property()
2425 memcpy(&getp, &fe->dtv_property_cache, sizeof(getp)); in dvb_get_frontend()
2433 struct dvb_device *dvbdev = file->private_data; in dvb_frontend_handle_ioctl()
2434 struct dvb_frontend *fe = dvbdev->priv; in dvb_frontend_handle_ioctl()
2435 struct dvb_frontend_private *fepriv = fe->frontend_priv; in dvb_frontend_handle_ioctl()
2436 struct dtv_frontend_properties *c = &fe->dtv_property_cache; in dvb_frontend_handle_ioctl()
2437 int i, err = -ENOTSUPP; in dvb_frontend_handle_ioctl()
2439 dev_dbg(fe->dvb->device, "%s:\n", __func__); in dvb_frontend_handle_ioctl()
2446 dev_dbg(fe->dvb->device, "%s: properties.num = %d\n", in dvb_frontend_handle_ioctl()
2447 __func__, tvps->num); in dvb_frontend_handle_ioctl()
2448 dev_dbg(fe->dvb->device, "%s: properties.props = %p\n", in dvb_frontend_handle_ioctl()
2449 __func__, tvps->props); in dvb_frontend_handle_ioctl()
2455 if (!tvps->num || (tvps->num > DTV_IOCTL_MAX_MSGS)) in dvb_frontend_handle_ioctl()
2456 return -EINVAL; in dvb_frontend_handle_ioctl()
2458 tvp = memdup_array_user((void __user *)tvps->props, in dvb_frontend_handle_ioctl()
2459 tvps->num, sizeof(*tvp)); in dvb_frontend_handle_ioctl()
2463 for (i = 0; i < tvps->num; i++) { in dvb_frontend_handle_ioctl()
2465 (tvp + i)->cmd, in dvb_frontend_handle_ioctl()
2466 (tvp + i)->u.data); in dvb_frontend_handle_ioctl()
2484 strscpy(info->name, fe->ops.info.name, sizeof(info->name)); in dvb_frontend_handle_ioctl()
2485 info->symbol_rate_min = fe->ops.info.symbol_rate_min; in dvb_frontend_handle_ioctl()
2486 info->symbol_rate_max = fe->ops.info.symbol_rate_max; in dvb_frontend_handle_ioctl()
2487 info->symbol_rate_tolerance = fe->ops.info.symbol_rate_tolerance; in dvb_frontend_handle_ioctl()
2488 info->caps = fe->ops.info.caps; in dvb_frontend_handle_ioctl()
2489 info->frequency_stepsize = dvb_frontend_get_stepsize(fe); in dvb_frontend_handle_ioctl()
2490 dvb_frontend_get_frequency_limits(fe, &info->frequency_min, in dvb_frontend_handle_ioctl()
2491 &info->frequency_max, in dvb_frontend_handle_ioctl()
2492 &info->frequency_tolerance); in dvb_frontend_handle_ioctl()
2499 * It should be noticed that, on multi-frontend devices with in dvb_frontend_handle_ioctl()
2505 switch (dvbv3_type(c->delivery_system)) { in dvb_frontend_handle_ioctl()
2507 info->type = FE_QPSK; in dvb_frontend_handle_ioctl()
2510 info->type = FE_ATSC; in dvb_frontend_handle_ioctl()
2513 info->type = FE_QAM; in dvb_frontend_handle_ioctl()
2516 info->type = FE_OFDM; in dvb_frontend_handle_ioctl()
2519 dev_err(fe->dvb->device, in dvb_frontend_handle_ioctl()
2521 __func__, c->delivery_system); in dvb_frontend_handle_ioctl()
2522 info->type = FE_OFDM; in dvb_frontend_handle_ioctl()
2524 dev_dbg(fe->dvb->device, "%s: current delivery system on cache: %d, V3 type: %d\n", in dvb_frontend_handle_ioctl()
2525 __func__, c->delivery_system, info->type); in dvb_frontend_handle_ioctl()
2528 if (!(fepriv->tune_mode_flags & FE_TUNE_MODE_ONESHOT)) in dvb_frontend_handle_ioctl()
2529 info->caps |= FE_CAN_INVERSION_AUTO; in dvb_frontend_handle_ioctl()
2539 if (fepriv->state == FESTATE_RETUNE || in dvb_frontend_handle_ioctl()
2540 fepriv->state == FESTATE_ERROR) { in dvb_frontend_handle_ioctl()
2546 if (fe->ops.read_status) in dvb_frontend_handle_ioctl()
2547 err = fe->ops.read_status(fe, status); in dvb_frontend_handle_ioctl()
2552 if (fe->ops.diseqc_reset_overload) { in dvb_frontend_handle_ioctl()
2553 err = fe->ops.diseqc_reset_overload(fe); in dvb_frontend_handle_ioctl()
2554 fepriv->state = FESTATE_DISEQC; in dvb_frontend_handle_ioctl()
2555 fepriv->status = 0; in dvb_frontend_handle_ioctl()
2560 if (fe->ops.diseqc_send_master_cmd) { in dvb_frontend_handle_ioctl()
2563 if (cmd->msg_len > sizeof(cmd->msg)) { in dvb_frontend_handle_ioctl()
2564 err = -EINVAL; in dvb_frontend_handle_ioctl()
2567 err = fe->ops.diseqc_send_master_cmd(fe, cmd); in dvb_frontend_handle_ioctl()
2568 fepriv->state = FESTATE_DISEQC; in dvb_frontend_handle_ioctl()
2569 fepriv->status = 0; in dvb_frontend_handle_ioctl()
2574 if (fe->ops.diseqc_send_burst) { in dvb_frontend_handle_ioctl()
2575 err = fe->ops.diseqc_send_burst(fe, (long)parg); in dvb_frontend_handle_ioctl()
2576 fepriv->state = FESTATE_DISEQC; in dvb_frontend_handle_ioctl()
2577 fepriv->status = 0; in dvb_frontend_handle_ioctl()
2582 if (fe->ops.set_tone) { in dvb_frontend_handle_ioctl()
2583 fepriv->tone = (long)parg; in dvb_frontend_handle_ioctl()
2584 err = fe->ops.set_tone(fe, fepriv->tone); in dvb_frontend_handle_ioctl()
2585 fepriv->state = FESTATE_DISEQC; in dvb_frontend_handle_ioctl()
2586 fepriv->status = 0; in dvb_frontend_handle_ioctl()
2591 if (fe->ops.set_voltage) { in dvb_frontend_handle_ioctl()
2592 fepriv->voltage = (long)parg; in dvb_frontend_handle_ioctl()
2593 err = fe->ops.set_voltage(fe, fepriv->voltage); in dvb_frontend_handle_ioctl()
2594 fepriv->state = FESTATE_DISEQC; in dvb_frontend_handle_ioctl()
2595 fepriv->status = 0; in dvb_frontend_handle_ioctl()
2600 if (fe->ops.diseqc_recv_slave_reply) in dvb_frontend_handle_ioctl()
2601 err = fe->ops.diseqc_recv_slave_reply(fe, parg); in dvb_frontend_handle_ioctl()
2605 if (fe->ops.enable_high_lnb_voltage) in dvb_frontend_handle_ioctl()
2606 err = fe->ops.enable_high_lnb_voltage(fe, (long)parg); in dvb_frontend_handle_ioctl()
2610 fepriv->tune_mode_flags = (unsigned long)parg; in dvb_frontend_handle_ioctl()
2616 if (fe->ops.dishnetwork_send_legacy_command) { in dvb_frontend_handle_ioctl()
2617 err = fe->ops.dishnetwork_send_legacy_command(fe, in dvb_frontend_handle_ioctl()
2619 fepriv->state = FESTATE_DISEQC; in dvb_frontend_handle_ioctl()
2620 fepriv->status = 0; in dvb_frontend_handle_ioctl()
2621 } else if (fe->ops.set_voltage) { in dvb_frontend_handle_ioctl()
2629 * are controlled by sending 9-bit command words in dvb_frontend_handle_ioctl()
2653 fe->ops.set_voltage(fe, SEC_VOLTAGE_18); in dvb_frontend_handle_ioctl()
2661 fe->ops.set_voltage(fe, (last) ? SEC_VOLTAGE_13 : SEC_VOLTAGE_18); in dvb_frontend_handle_ioctl()
2670 fe->dvb->num); in dvb_frontend_handle_ioctl()
2673 (int)ktime_us_delta(tv[i], tv[i - 1])); in dvb_frontend_handle_ioctl()
2676 fepriv->state = FESTATE_DISEQC; in dvb_frontend_handle_ioctl()
2677 fepriv->status = 0; in dvb_frontend_handle_ioctl()
2684 if (fe->ops.read_ber) { in dvb_frontend_handle_ioctl()
2685 if (fepriv->thread) in dvb_frontend_handle_ioctl()
2686 err = fe->ops.read_ber(fe, parg); in dvb_frontend_handle_ioctl()
2688 err = -EAGAIN; in dvb_frontend_handle_ioctl()
2693 if (fe->ops.read_signal_strength) { in dvb_frontend_handle_ioctl()
2694 if (fepriv->thread) in dvb_frontend_handle_ioctl()
2695 err = fe->ops.read_signal_strength(fe, parg); in dvb_frontend_handle_ioctl()
2697 err = -EAGAIN; in dvb_frontend_handle_ioctl()
2702 if (fe->ops.read_snr) { in dvb_frontend_handle_ioctl()
2703 if (fepriv->thread) in dvb_frontend_handle_ioctl()
2704 err = fe->ops.read_snr(fe, parg); in dvb_frontend_handle_ioctl()
2706 err = -EAGAIN; in dvb_frontend_handle_ioctl()
2711 if (fe->ops.read_ucblocks) { in dvb_frontend_handle_ioctl()
2712 if (fepriv->thread) in dvb_frontend_handle_ioctl()
2713 err = fe->ops.read_ucblocks(fe, parg); in dvb_frontend_handle_ioctl()
2715 err = -EAGAIN; in dvb_frontend_handle_ioctl()
2733 err = dvb_frontend_get_event(fe, parg, file->f_flags); in dvb_frontend_handle_ioctl()
2741 return -ENOTSUPP; in dvb_frontend_handle_ioctl()
2749 struct dvb_device *dvbdev = file->private_data; in dvb_frontend_poll()
2750 struct dvb_frontend *fe = dvbdev->priv; in dvb_frontend_poll()
2751 struct dvb_frontend_private *fepriv = fe->frontend_priv; in dvb_frontend_poll()
2753 dev_dbg_ratelimited(fe->dvb->device, "%s:\n", __func__); in dvb_frontend_poll()
2755 poll_wait(file, &fepriv->events.wait_queue, wait); in dvb_frontend_poll()
2757 if (fepriv->events.eventw != fepriv->events.eventr) in dvb_frontend_poll()
2765 struct dvb_device *dvbdev = file->private_data; in dvb_frontend_open()
2766 struct dvb_frontend *fe = dvbdev->priv; in dvb_frontend_open()
2767 struct dvb_frontend_private *fepriv = fe->frontend_priv; in dvb_frontend_open()
2768 struct dvb_adapter *adapter = fe->dvb; in dvb_frontend_open()
2771 dev_dbg(fe->dvb->device, "%s:\n", __func__); in dvb_frontend_open()
2772 if (fe->exit == DVB_FE_DEVICE_REMOVED) in dvb_frontend_open()
2773 return -ENODEV; in dvb_frontend_open()
2775 if (adapter->mfe_shared == 2) { in dvb_frontend_open()
2776 mutex_lock(&adapter->mfe_lock); in dvb_frontend_open()
2777 if ((file->f_flags & O_ACCMODE) != O_RDONLY) { in dvb_frontend_open()
2778 if (adapter->mfe_dvbdev && in dvb_frontend_open()
2779 !adapter->mfe_dvbdev->writers) { in dvb_frontend_open()
2780 mutex_unlock(&adapter->mfe_lock); in dvb_frontend_open()
2781 return -EBUSY; in dvb_frontend_open()
2783 adapter->mfe_dvbdev = dvbdev; in dvb_frontend_open()
2785 } else if (adapter->mfe_shared) { in dvb_frontend_open()
2786 mutex_lock(&adapter->mfe_lock); in dvb_frontend_open()
2788 if (!adapter->mfe_dvbdev) in dvb_frontend_open()
2789 adapter->mfe_dvbdev = dvbdev; in dvb_frontend_open()
2791 else if (adapter->mfe_dvbdev != dvbdev) { in dvb_frontend_open()
2793 *mfedev = adapter->mfe_dvbdev; in dvb_frontend_open()
2795 *mfe = mfedev->priv; in dvb_frontend_open()
2797 *mfepriv = mfe->frontend_priv; in dvb_frontend_open()
2800 mutex_unlock(&adapter->mfe_lock); in dvb_frontend_open()
2801 while (mferetry-- && (mfedev->users != -1 || in dvb_frontend_open()
2802 mfepriv->thread)) { in dvb_frontend_open()
2805 return -EINTR; in dvb_frontend_open()
2809 mutex_lock(&adapter->mfe_lock); in dvb_frontend_open()
2810 if (adapter->mfe_dvbdev != dvbdev) { in dvb_frontend_open()
2811 mfedev = adapter->mfe_dvbdev; in dvb_frontend_open()
2812 mfe = mfedev->priv; in dvb_frontend_open()
2813 mfepriv = mfe->frontend_priv; in dvb_frontend_open()
2814 if (mfedev->users != -1 || in dvb_frontend_open()
2815 mfepriv->thread) { in dvb_frontend_open()
2816 mutex_unlock(&adapter->mfe_lock); in dvb_frontend_open()
2817 return -EBUSY; in dvb_frontend_open()
2819 adapter->mfe_dvbdev = dvbdev; in dvb_frontend_open()
2824 if (dvbdev->users == -1 && fe->ops.ts_bus_ctrl) { in dvb_frontend_open()
2825 if ((ret = fe->ops.ts_bus_ctrl(fe, 1)) < 0) in dvb_frontend_open()
2834 fepriv->reinitialise = 1; in dvb_frontend_open()
2840 if ((file->f_flags & O_ACCMODE) != O_RDONLY) { in dvb_frontend_open()
2841 /* normal tune mode when opened R/W */ in dvb_frontend_open()
2842 fepriv->tune_mode_flags &= ~FE_TUNE_MODE_ONESHOT; in dvb_frontend_open()
2843 fepriv->tone = -1; in dvb_frontend_open()
2844 fepriv->voltage = -1; in dvb_frontend_open()
2847 mutex_lock(&fe->dvb->mdev_lock); in dvb_frontend_open()
2848 if (fe->dvb->mdev) { in dvb_frontend_open()
2849 mutex_lock(&fe->dvb->mdev->graph_mutex); in dvb_frontend_open()
2850 if (fe->dvb->mdev->enable_source) in dvb_frontend_open()
2851 ret = fe->dvb->mdev->enable_source( in dvb_frontend_open()
2852 dvbdev->entity, in dvb_frontend_open()
2853 &fepriv->pipe); in dvb_frontend_open()
2854 mutex_unlock(&fe->dvb->mdev->graph_mutex); in dvb_frontend_open()
2856 mutex_unlock(&fe->dvb->mdev_lock); in dvb_frontend_open()
2857 dev_err(fe->dvb->device, in dvb_frontend_open()
2862 mutex_unlock(&fe->dvb->mdev_lock); in dvb_frontend_open()
2869 fepriv->events.eventr = fepriv->events.eventw = 0; in dvb_frontend_open()
2874 if (adapter->mfe_shared) in dvb_frontend_open()
2875 mutex_unlock(&adapter->mfe_lock); in dvb_frontend_open()
2880 mutex_lock(&fe->dvb->mdev_lock); in dvb_frontend_open()
2881 if (fe->dvb->mdev) { in dvb_frontend_open()
2882 mutex_lock(&fe->dvb->mdev->graph_mutex); in dvb_frontend_open()
2883 if (fe->dvb->mdev->disable_source) in dvb_frontend_open()
2884 fe->dvb->mdev->disable_source(dvbdev->entity); in dvb_frontend_open()
2885 mutex_unlock(&fe->dvb->mdev->graph_mutex); in dvb_frontend_open()
2887 mutex_unlock(&fe->dvb->mdev_lock); in dvb_frontend_open()
2892 if (dvbdev->users == -1 && fe->ops.ts_bus_ctrl) in dvb_frontend_open()
2893 fe->ops.ts_bus_ctrl(fe, 0); in dvb_frontend_open()
2895 if (adapter->mfe_shared) in dvb_frontend_open()
2896 mutex_unlock(&adapter->mfe_lock); in dvb_frontend_open()
2902 struct dvb_device *dvbdev = file->private_data; in dvb_frontend_release()
2903 struct dvb_frontend *fe = dvbdev->priv; in dvb_frontend_release()
2904 struct dvb_frontend_private *fepriv = fe->frontend_priv; in dvb_frontend_release()
2907 dev_dbg(fe->dvb->device, "%s:\n", __func__); in dvb_frontend_release()
2909 if ((file->f_flags & O_ACCMODE) != O_RDONLY) { in dvb_frontend_release()
2910 fepriv->release_jiffies = jiffies; in dvb_frontend_release()
2916 if (dvbdev->users == -1) { in dvb_frontend_release()
2917 wake_up(&fepriv->wait_queue); in dvb_frontend_release()
2919 mutex_lock(&fe->dvb->mdev_lock); in dvb_frontend_release()
2920 if (fe->dvb->mdev) { in dvb_frontend_release()
2921 mutex_lock(&fe->dvb->mdev->graph_mutex); in dvb_frontend_release()
2922 if (fe->dvb->mdev->disable_source) in dvb_frontend_release()
2923 fe->dvb->mdev->disable_source(dvbdev->entity); in dvb_frontend_release()
2924 mutex_unlock(&fe->dvb->mdev->graph_mutex); in dvb_frontend_release()
2926 mutex_unlock(&fe->dvb->mdev_lock); in dvb_frontend_release()
2928 if (fe->exit != DVB_FE_NO_EXIT) in dvb_frontend_release()
2929 wake_up(&dvbdev->wait_queue); in dvb_frontend_release()
2930 if (fe->ops.ts_bus_ctrl) in dvb_frontend_release()
2931 fe->ops.ts_bus_ctrl(fe, 0); in dvb_frontend_release()
2955 dev_dbg(fe->dvb->device, "%s: adap=%d fe=%d\n", __func__, fe->dvb->num, in dvb_frontend_suspend()
2956 fe->id); in dvb_frontend_suspend()
2958 if (fe->ops.tuner_ops.suspend) in dvb_frontend_suspend()
2959 ret = fe->ops.tuner_ops.suspend(fe); in dvb_frontend_suspend()
2960 else if (fe->ops.tuner_ops.sleep) in dvb_frontend_suspend()
2961 ret = fe->ops.tuner_ops.sleep(fe); in dvb_frontend_suspend()
2963 if (fe->ops.suspend) in dvb_frontend_suspend()
2964 ret = fe->ops.suspend(fe); in dvb_frontend_suspend()
2965 else if (fe->ops.sleep) in dvb_frontend_suspend()
2966 ret = fe->ops.sleep(fe); in dvb_frontend_suspend()
2974 struct dvb_frontend_private *fepriv = fe->frontend_priv; in dvb_frontend_resume()
2977 dev_dbg(fe->dvb->device, "%s: adap=%d fe=%d\n", __func__, fe->dvb->num, in dvb_frontend_resume()
2978 fe->id); in dvb_frontend_resume()
2980 fe->exit = DVB_FE_DEVICE_RESUME; in dvb_frontend_resume()
2981 if (fe->ops.resume) in dvb_frontend_resume()
2982 ret = fe->ops.resume(fe); in dvb_frontend_resume()
2983 else if (fe->ops.init) in dvb_frontend_resume()
2984 ret = fe->ops.init(fe); in dvb_frontend_resume()
2986 if (fe->ops.tuner_ops.resume) in dvb_frontend_resume()
2987 ret = fe->ops.tuner_ops.resume(fe); in dvb_frontend_resume()
2988 else if (fe->ops.tuner_ops.init) in dvb_frontend_resume()
2989 ret = fe->ops.tuner_ops.init(fe); in dvb_frontend_resume()
2991 if (fe->ops.set_tone && fepriv->tone != -1) in dvb_frontend_resume()
2992 fe->ops.set_tone(fe, fepriv->tone); in dvb_frontend_resume()
2993 if (fe->ops.set_voltage && fepriv->voltage != -1) in dvb_frontend_resume()
2994 fe->ops.set_voltage(fe, fepriv->voltage); in dvb_frontend_resume()
2996 fe->exit = DVB_FE_NO_EXIT; in dvb_frontend_resume()
2997 fepriv->state = FESTATE_RETUNE; in dvb_frontend_resume()
3011 .readers = (~0) - 1, in dvb_register_frontend()
3014 .name = fe->ops.info.name, in dvb_register_frontend()
3019 dev_dbg(dvb->device, "%s:\n", __func__); in dvb_register_frontend()
3022 return -ERESTARTSYS; in dvb_register_frontend()
3024 fe->frontend_priv = kzalloc(sizeof(struct dvb_frontend_private), GFP_KERNEL); in dvb_register_frontend()
3025 if (!fe->frontend_priv) { in dvb_register_frontend()
3027 return -ENOMEM; in dvb_register_frontend()
3029 fepriv = fe->frontend_priv; in dvb_register_frontend()
3031 kref_init(&fe->refcount); in dvb_register_frontend()
3040 sema_init(&fepriv->sem, 1); in dvb_register_frontend()
3041 init_waitqueue_head(&fepriv->wait_queue); in dvb_register_frontend()
3042 init_waitqueue_head(&fepriv->events.wait_queue); in dvb_register_frontend()
3043 mutex_init(&fepriv->events.mtx); in dvb_register_frontend()
3044 fe->dvb = dvb; in dvb_register_frontend()
3045 fepriv->inversion = INVERSION_OFF; in dvb_register_frontend()
3047 dev_info(fe->dvb->device, in dvb_register_frontend()
3049 fe->dvb->num, fe->id, fe->ops.info.name); in dvb_register_frontend()
3051 ret = dvb_register_device(fe->dvb, &fepriv->dvbdev, &dvbdev_template, in dvb_register_frontend()
3061 * first supported delivery system (ops->delsys[0]) in dvb_register_frontend()
3064 fe->dtv_property_cache.delivery_system = fe->ops.delsys[0]; in dvb_register_frontend()
3074 struct dvb_frontend_private *fepriv = fe->frontend_priv; in dvb_unregister_frontend()
3076 dev_dbg(fe->dvb->device, "%s:\n", __func__); in dvb_unregister_frontend()
3080 dvb_remove_device(fepriv->dvbdev); in dvb_unregister_frontend()
3102 dvb_frontend_invoke_release(fe, fe->ops.release_sec); in dvb_frontend_detach()
3103 dvb_frontend_invoke_release(fe, fe->ops.tuner_ops.release); in dvb_frontend_detach()
3104 dvb_frontend_invoke_release(fe, fe->ops.analog_ops.release); in dvb_frontend_detach()