Lines Matching +full:sense +full:- +full:freq

1 // SPDX-License-Identifier: GPL-2.0
4 * Sony CXD2880 DVB-T2/T tuner + demodulator driver
52 return -EINVAL; in cxd2880_pre_bit_err_t()
54 if (tnrdmd->diver_mode == CXD2880_TNRDMD_DIVERMODE_SUB) in cxd2880_pre_bit_err_t()
55 return -EINVAL; in cxd2880_pre_bit_err_t()
57 if (tnrdmd->state != CXD2880_TNRDMD_STATE_ACTIVE) in cxd2880_pre_bit_err_t()
58 return -EINVAL; in cxd2880_pre_bit_err_t()
60 if (tnrdmd->sys != CXD2880_DTV_SYS_DVBT) in cxd2880_pre_bit_err_t()
61 return -EINVAL; in cxd2880_pre_bit_err_t()
67 ret = tnrdmd->io->write_reg(tnrdmd->io, in cxd2880_pre_bit_err_t()
75 ret = tnrdmd->io->read_regs(tnrdmd->io, in cxd2880_pre_bit_err_t()
85 return -EAGAIN; in cxd2880_pre_bit_err_t()
88 ret = tnrdmd->io->read_regs(tnrdmd->io, in cxd2880_pre_bit_err_t()
98 ret = tnrdmd->io->read_regs(tnrdmd->io, in cxd2880_pre_bit_err_t()
124 return -EINVAL; in cxd2880_pre_bit_err_t2()
126 if (tnrdmd->diver_mode == CXD2880_TNRDMD_DIVERMODE_SUB) in cxd2880_pre_bit_err_t2()
127 return -EINVAL; in cxd2880_pre_bit_err_t2()
129 if (tnrdmd->state != CXD2880_TNRDMD_STATE_ACTIVE) in cxd2880_pre_bit_err_t2()
130 return -EINVAL; in cxd2880_pre_bit_err_t2()
132 if (tnrdmd->sys != CXD2880_DTV_SYS_DVBT2) in cxd2880_pre_bit_err_t2()
133 return -EINVAL; in cxd2880_pre_bit_err_t2()
139 ret = tnrdmd->io->write_reg(tnrdmd->io, in cxd2880_pre_bit_err_t2()
147 ret = tnrdmd->io->read_regs(tnrdmd->io, in cxd2880_pre_bit_err_t2()
157 return -EAGAIN; in cxd2880_pre_bit_err_t2()
162 ret = tnrdmd->io->read_regs(tnrdmd->io, in cxd2880_pre_bit_err_t2()
177 ret = tnrdmd->io->write_reg(tnrdmd->io, in cxd2880_pre_bit_err_t2()
183 ret = tnrdmd->io->read_regs(tnrdmd->io, in cxd2880_pre_bit_err_t2()
206 return -EINVAL; in cxd2880_post_bit_err_t()
208 if (tnrdmd->diver_mode == CXD2880_TNRDMD_DIVERMODE_SUB) in cxd2880_post_bit_err_t()
209 return -EINVAL; in cxd2880_post_bit_err_t()
211 if (tnrdmd->state != CXD2880_TNRDMD_STATE_ACTIVE) in cxd2880_post_bit_err_t()
212 return -EINVAL; in cxd2880_post_bit_err_t()
214 if (tnrdmd->sys != CXD2880_DTV_SYS_DVBT) in cxd2880_post_bit_err_t()
215 return -EINVAL; in cxd2880_post_bit_err_t()
217 ret = tnrdmd->io->write_reg(tnrdmd->io, in cxd2880_post_bit_err_t()
223 ret = tnrdmd->io->read_regs(tnrdmd->io, in cxd2880_post_bit_err_t()
230 return -EAGAIN; in cxd2880_post_bit_err_t()
234 ret = tnrdmd->io->write_reg(tnrdmd->io, in cxd2880_post_bit_err_t()
240 ret = tnrdmd->io->read_regs(tnrdmd->io, in cxd2880_post_bit_err_t()
249 return -EAGAIN; in cxd2880_post_bit_err_t()
274 return -EINVAL; in cxd2880_post_bit_err_t2()
276 if (tnrdmd->diver_mode == CXD2880_TNRDMD_DIVERMODE_SUB) in cxd2880_post_bit_err_t2()
277 return -EINVAL; in cxd2880_post_bit_err_t2()
279 if (tnrdmd->state != CXD2880_TNRDMD_STATE_ACTIVE) in cxd2880_post_bit_err_t2()
280 return -EINVAL; in cxd2880_post_bit_err_t2()
282 if (tnrdmd->sys != CXD2880_DTV_SYS_DVBT2) in cxd2880_post_bit_err_t2()
283 return -EINVAL; in cxd2880_post_bit_err_t2()
289 ret = tnrdmd->io->write_reg(tnrdmd->io, in cxd2880_post_bit_err_t2()
297 ret = tnrdmd->io->read_regs(tnrdmd->io, in cxd2880_post_bit_err_t2()
307 return -EAGAIN; in cxd2880_post_bit_err_t2()
313 ret = tnrdmd->io->read_regs(tnrdmd->io, in cxd2880_post_bit_err_t2()
324 ret = tnrdmd->io->read_regs(tnrdmd->io, in cxd2880_post_bit_err_t2()
336 ret = tnrdmd->io->write_reg(tnrdmd->io, in cxd2880_post_bit_err_t2()
342 ret = tnrdmd->io->read_regs(tnrdmd->io, in cxd2880_post_bit_err_t2()
352 return -EAGAIN; in cxd2880_post_bit_err_t2()
357 return -EAGAIN; in cxd2880_post_bit_err_t2()
372 return -EINVAL; in cxd2880_read_block_err_t()
374 if (tnrdmd->diver_mode == CXD2880_TNRDMD_DIVERMODE_SUB) in cxd2880_read_block_err_t()
375 return -EINVAL; in cxd2880_read_block_err_t()
377 if (tnrdmd->state != CXD2880_TNRDMD_STATE_ACTIVE) in cxd2880_read_block_err_t()
378 return -EINVAL; in cxd2880_read_block_err_t()
380 if (tnrdmd->sys != CXD2880_DTV_SYS_DVBT) in cxd2880_read_block_err_t()
381 return -EINVAL; in cxd2880_read_block_err_t()
383 ret = tnrdmd->io->write_reg(tnrdmd->io, in cxd2880_read_block_err_t()
389 ret = tnrdmd->io->read_regs(tnrdmd->io, in cxd2880_read_block_err_t()
396 return -EAGAIN; in cxd2880_read_block_err_t()
400 ret = tnrdmd->io->write_reg(tnrdmd->io, in cxd2880_read_block_err_t()
406 ret = tnrdmd->io->read_regs(tnrdmd->io, in cxd2880_read_block_err_t()
415 return -EAGAIN; in cxd2880_read_block_err_t()
428 return -EINVAL; in cxd2880_read_block_err_t2()
430 if (tnrdmd->diver_mode == CXD2880_TNRDMD_DIVERMODE_SUB) in cxd2880_read_block_err_t2()
431 return -EINVAL; in cxd2880_read_block_err_t2()
433 if (tnrdmd->state != CXD2880_TNRDMD_STATE_ACTIVE) in cxd2880_read_block_err_t2()
434 return -EINVAL; in cxd2880_read_block_err_t2()
435 if (tnrdmd->sys != CXD2880_DTV_SYS_DVBT2) in cxd2880_read_block_err_t2()
436 return -EINVAL; in cxd2880_read_block_err_t2()
438 ret = tnrdmd->io->write_reg(tnrdmd->io, in cxd2880_read_block_err_t2()
444 ret = tnrdmd->io->read_regs(tnrdmd->io, in cxd2880_read_block_err_t2()
451 return -EAGAIN; in cxd2880_read_block_err_t2()
455 ret = tnrdmd->io->write_reg(tnrdmd->io, in cxd2880_read_block_err_t2()
461 ret = tnrdmd->io->read_regs(tnrdmd->io, in cxd2880_read_block_err_t2()
470 return -EAGAIN; in cxd2880_read_block_err_t2()
483 priv = fe->demodulator_priv; in cxd2880_release()
495 return -EINVAL; in cxd2880_init()
498 priv = fe->demodulator_priv; in cxd2880_init()
507 mutex_lock(priv->spi_mutex); in cxd2880_init()
508 if (priv->tnrdmd.io != &priv->regio) { in cxd2880_init()
509 ret = cxd2880_tnrdmd_create(&priv->tnrdmd, in cxd2880_init()
510 &priv->regio, &create_param); in cxd2880_init()
512 mutex_unlock(priv->spi_mutex); in cxd2880_init()
517 ret = cxd2880_integ_init(&priv->tnrdmd); in cxd2880_init()
519 mutex_unlock(priv->spi_mutex); in cxd2880_init()
524 ret = cxd2880_tnrdmd_set_cfg(&priv->tnrdmd, in cxd2880_init()
528 mutex_unlock(priv->spi_mutex); in cxd2880_init()
532 mutex_unlock(priv->spi_mutex); in cxd2880_init()
546 return -EINVAL; in cxd2880_sleep()
549 priv = fe->demodulator_priv; in cxd2880_sleep()
551 mutex_lock(priv->spi_mutex); in cxd2880_sleep()
552 ret = cxd2880_tnrdmd_sleep(&priv->tnrdmd); in cxd2880_sleep()
553 mutex_unlock(priv->spi_mutex); in cxd2880_sleep()
570 return -EINVAL; in cxd2880_read_signal_strength()
573 priv = fe->demodulator_priv; in cxd2880_read_signal_strength()
574 c = &fe->dtv_property_cache; in cxd2880_read_signal_strength()
576 mutex_lock(priv->spi_mutex); in cxd2880_read_signal_strength()
577 if (c->delivery_system == SYS_DVBT || in cxd2880_read_signal_strength()
578 c->delivery_system == SYS_DVBT2) { in cxd2880_read_signal_strength()
579 ret = cxd2880_tnrdmd_mon_rf_lvl(&priv->tnrdmd, &level); in cxd2880_read_signal_strength()
582 mutex_unlock(priv->spi_mutex); in cxd2880_read_signal_strength()
583 return -EINVAL; in cxd2880_read_signal_strength()
585 mutex_unlock(priv->spi_mutex); in cxd2880_read_signal_strength()
589 * level should be between -105dBm and -30dBm. in cxd2880_read_signal_strength()
591 * -105000/125 = -840 and -30000/125 = -240 in cxd2880_read_signal_strength()
593 level = clamp(level, -840, -240); in cxd2880_read_signal_strength()
594 /* scale value to 0x0000-0xffff */ in cxd2880_read_signal_strength()
595 *strength = ((level + 840) * 0xffff) / (-240 + 840); in cxd2880_read_signal_strength()
612 return -EINVAL; in cxd2880_read_snr()
615 priv = fe->demodulator_priv; in cxd2880_read_snr()
616 c = &fe->dtv_property_cache; in cxd2880_read_snr()
618 mutex_lock(priv->spi_mutex); in cxd2880_read_snr()
619 if (c->delivery_system == SYS_DVBT) { in cxd2880_read_snr()
620 ret = cxd2880_tnrdmd_dvbt_mon_snr(&priv->tnrdmd, in cxd2880_read_snr()
622 } else if (c->delivery_system == SYS_DVBT2) { in cxd2880_read_snr()
623 ret = cxd2880_tnrdmd_dvbt2_mon_snr(&priv->tnrdmd, in cxd2880_read_snr()
627 mutex_unlock(priv->spi_mutex); in cxd2880_read_snr()
628 return -EINVAL; in cxd2880_read_snr()
630 mutex_unlock(priv->spi_mutex); in cxd2880_read_snr()
650 return -EINVAL; in cxd2880_read_ucblocks()
653 priv = fe->demodulator_priv; in cxd2880_read_ucblocks()
654 c = &fe->dtv_property_cache; in cxd2880_read_ucblocks()
656 mutex_lock(priv->spi_mutex); in cxd2880_read_ucblocks()
657 if (c->delivery_system == SYS_DVBT) { in cxd2880_read_ucblocks()
658 ret = cxd2880_tnrdmd_dvbt_mon_packet_error_number(&priv->tnrdmd, in cxd2880_read_ucblocks()
660 } else if (c->delivery_system == SYS_DVBT2) { in cxd2880_read_ucblocks()
661 ret = cxd2880_tnrdmd_dvbt2_mon_packet_error_number(&priv->tnrdmd, in cxd2880_read_ucblocks()
665 mutex_unlock(priv->spi_mutex); in cxd2880_read_ucblocks()
666 return -EINVAL; in cxd2880_read_ucblocks()
668 mutex_unlock(priv->spi_mutex); in cxd2880_read_ucblocks()
698 return -EINVAL; in cxd2880_set_ber_per_period_t()
701 priv = fe->demodulator_priv; in cxd2880_set_ber_per_period_t()
702 bw = priv->dvbt_tune_param.bandwidth; in cxd2880_set_ber_per_period_t()
704 ret = cxd2880_tnrdmd_dvbt_mon_tps_info(&priv->tnrdmd, in cxd2880_set_ber_per_period_t()
728 struct cxd2880_tnrdmd *tnrdmd = &priv->tnrdmd; in cxd2880_set_ber_per_period_t()
730 ret = tnrdmd->io->write_reg(tnrdmd->io, in cxd2880_set_ber_per_period_t()
734 ret = tnrdmd->io->read_regs(tnrdmd->io, in cxd2880_set_ber_per_period_t()
768 priv->pre_ber_interval = in cxd2880_set_ber_per_period_t()
771 cxd2880_tnrdmd_set_cfg(&priv->tnrdmd, in cxd2880_set_ber_per_period_t()
773 mes_exp == 8 ? 0 : mes_exp - 12); in cxd2880_set_ber_per_period_t()
776 priv->post_ber_interval = in cxd2880_set_ber_per_period_t()
779 cxd2880_tnrdmd_set_cfg(&priv->tnrdmd, in cxd2880_set_ber_per_period_t()
784 priv->ucblock_interval = in cxd2880_set_ber_per_period_t()
787 cxd2880_tnrdmd_set_cfg(&priv->tnrdmd, in cxd2880_set_ber_per_period_t()
820 return -EINVAL; in cxd2880_set_ber_per_period_t2()
823 priv = fe->demodulator_priv; in cxd2880_set_ber_per_period_t2()
824 bw = priv->dvbt2_tune_param.bandwidth; in cxd2880_set_ber_per_period_t2()
826 ret = cxd2880_tnrdmd_dvbt2_mon_l1_pre(&priv->tnrdmd, &l1pre); in cxd2880_set_ber_per_period_t2()
832 ret = cxd2880_tnrdmd_dvbt2_mon_active_plp(&priv->tnrdmd, in cxd2880_set_ber_per_period_t2()
839 ret = cxd2880_tnrdmd_dvbt2_mon_l1_post(&priv->tnrdmd, &l1post); in cxd2880_set_ber_per_period_t2()
890 priv->pre_ber_interval = in cxd2880_set_ber_per_period_t2()
893 cxd2880_tnrdmd_set_cfg(&priv->tnrdmd, in cxd2880_set_ber_per_period_t2()
898 priv->post_ber_interval = in cxd2880_set_ber_per_period_t2()
901 cxd2880_tnrdmd_set_cfg(&priv->tnrdmd, in cxd2880_set_ber_per_period_t2()
905 ret = cxd2880_tnrdmd_dvbt2_mon_bbheader(&priv->tnrdmd, in cxd2880_set_ber_per_period_t2()
933 priv->ucblock_interval = in cxd2880_set_ber_per_period_t2()
936 cxd2880_tnrdmd_set_cfg(&priv->tnrdmd, in cxd2880_set_ber_per_period_t2()
943 priv->pre_ber_interval = 1000; in cxd2880_set_ber_per_period_t2()
944 cxd2880_tnrdmd_set_cfg(&priv->tnrdmd, in cxd2880_set_ber_per_period_t2()
947 priv->post_ber_interval = 1000; in cxd2880_set_ber_per_period_t2()
948 cxd2880_tnrdmd_set_cfg(&priv->tnrdmd, in cxd2880_set_ber_per_period_t2()
952 priv->ucblock_interval = 1000; in cxd2880_set_ber_per_period_t2()
953 cxd2880_tnrdmd_set_cfg(&priv->tnrdmd, in cxd2880_set_ber_per_period_t2()
966 return -EINVAL; in cxd2880_dvbt_tune()
968 if (tnr_dmd->diver_mode == CXD2880_TNRDMD_DIVERMODE_SUB) in cxd2880_dvbt_tune()
969 return -EINVAL; in cxd2880_dvbt_tune()
971 if (tnr_dmd->state != CXD2880_TNRDMD_STATE_SLEEP && in cxd2880_dvbt_tune()
972 tnr_dmd->state != CXD2880_TNRDMD_STATE_ACTIVE) in cxd2880_dvbt_tune()
973 return -EINVAL; in cxd2880_dvbt_tune()
975 atomic_set(&tnr_dmd->cancel, 0); in cxd2880_dvbt_tune()
977 if (tune_param->bandwidth != CXD2880_DTV_BW_5_MHZ && in cxd2880_dvbt_tune()
978 tune_param->bandwidth != CXD2880_DTV_BW_6_MHZ && in cxd2880_dvbt_tune()
979 tune_param->bandwidth != CXD2880_DTV_BW_7_MHZ && in cxd2880_dvbt_tune()
980 tune_param->bandwidth != CXD2880_DTV_BW_8_MHZ) { in cxd2880_dvbt_tune()
981 return -ENOTTY; in cxd2880_dvbt_tune()
1001 return -EINVAL; in cxd2880_dvbt2_tune()
1003 if (tnr_dmd->diver_mode == CXD2880_TNRDMD_DIVERMODE_SUB) in cxd2880_dvbt2_tune()
1004 return -EINVAL; in cxd2880_dvbt2_tune()
1006 if (tnr_dmd->state != CXD2880_TNRDMD_STATE_SLEEP && in cxd2880_dvbt2_tune()
1007 tnr_dmd->state != CXD2880_TNRDMD_STATE_ACTIVE) in cxd2880_dvbt2_tune()
1008 return -EINVAL; in cxd2880_dvbt2_tune()
1010 atomic_set(&tnr_dmd->cancel, 0); in cxd2880_dvbt2_tune()
1012 if (tune_param->bandwidth != CXD2880_DTV_BW_1_7_MHZ && in cxd2880_dvbt2_tune()
1013 tune_param->bandwidth != CXD2880_DTV_BW_5_MHZ && in cxd2880_dvbt2_tune()
1014 tune_param->bandwidth != CXD2880_DTV_BW_6_MHZ && in cxd2880_dvbt2_tune()
1015 tune_param->bandwidth != CXD2880_DTV_BW_7_MHZ && in cxd2880_dvbt2_tune()
1016 tune_param->bandwidth != CXD2880_DTV_BW_8_MHZ) { in cxd2880_dvbt2_tune()
1017 return -ENOTTY; in cxd2880_dvbt2_tune()
1020 if (tune_param->profile != CXD2880_DVBT2_PROFILE_BASE && in cxd2880_dvbt2_tune()
1021 tune_param->profile != CXD2880_DVBT2_PROFILE_LITE) in cxd2880_dvbt2_tune()
1022 return -EINVAL; in cxd2880_dvbt2_tune()
1043 return -EINVAL; in cxd2880_set_frontend()
1046 priv = fe->demodulator_priv; in cxd2880_set_frontend()
1047 c = &fe->dtv_property_cache; in cxd2880_set_frontend()
1049 c->pre_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in cxd2880_set_frontend()
1050 c->pre_bit_error.stat[0].uvalue = 0; in cxd2880_set_frontend()
1051 c->pre_bit_error.len = 1; in cxd2880_set_frontend()
1052 c->pre_bit_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in cxd2880_set_frontend()
1053 c->pre_bit_count.stat[0].uvalue = 0; in cxd2880_set_frontend()
1054 c->pre_bit_count.len = 1; in cxd2880_set_frontend()
1055 c->post_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in cxd2880_set_frontend()
1056 c->post_bit_error.stat[0].uvalue = 0; in cxd2880_set_frontend()
1057 c->post_bit_error.len = 1; in cxd2880_set_frontend()
1058 c->post_bit_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in cxd2880_set_frontend()
1059 c->post_bit_count.stat[0].uvalue = 0; in cxd2880_set_frontend()
1060 c->post_bit_count.len = 1; in cxd2880_set_frontend()
1061 c->block_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in cxd2880_set_frontend()
1062 c->block_error.stat[0].uvalue = 0; in cxd2880_set_frontend()
1063 c->block_error.len = 1; in cxd2880_set_frontend()
1064 c->block_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in cxd2880_set_frontend()
1065 c->block_count.stat[0].uvalue = 0; in cxd2880_set_frontend()
1066 c->block_count.len = 1; in cxd2880_set_frontend()
1068 switch (c->bandwidth_hz) { in cxd2880_set_frontend()
1085 return -EINVAL; in cxd2880_set_frontend()
1088 priv->s = 0; in cxd2880_set_frontend()
1090 pr_info("sys:%d freq:%d bw:%d\n", in cxd2880_set_frontend()
1091 c->delivery_system, c->frequency, bw); in cxd2880_set_frontend()
1092 mutex_lock(priv->spi_mutex); in cxd2880_set_frontend()
1093 if (c->delivery_system == SYS_DVBT) { in cxd2880_set_frontend()
1094 priv->tnrdmd.sys = CXD2880_DTV_SYS_DVBT; in cxd2880_set_frontend()
1095 priv->dvbt_tune_param.center_freq_khz = c->frequency / 1000; in cxd2880_set_frontend()
1096 priv->dvbt_tune_param.bandwidth = bw; in cxd2880_set_frontend()
1097 priv->dvbt_tune_param.profile = CXD2880_DVBT_PROFILE_HP; in cxd2880_set_frontend()
1098 ret = cxd2880_dvbt_tune(&priv->tnrdmd, in cxd2880_set_frontend()
1099 &priv->dvbt_tune_param); in cxd2880_set_frontend()
1100 } else if (c->delivery_system == SYS_DVBT2) { in cxd2880_set_frontend()
1101 priv->tnrdmd.sys = CXD2880_DTV_SYS_DVBT2; in cxd2880_set_frontend()
1102 priv->dvbt2_tune_param.center_freq_khz = c->frequency / 1000; in cxd2880_set_frontend()
1103 priv->dvbt2_tune_param.bandwidth = bw; in cxd2880_set_frontend()
1104 priv->dvbt2_tune_param.data_plp_id = (u16)c->stream_id; in cxd2880_set_frontend()
1105 priv->dvbt2_tune_param.profile = CXD2880_DVBT2_PROFILE_BASE; in cxd2880_set_frontend()
1106 ret = cxd2880_dvbt2_tune(&priv->tnrdmd, in cxd2880_set_frontend()
1107 &priv->dvbt2_tune_param); in cxd2880_set_frontend()
1110 mutex_unlock(priv->spi_mutex); in cxd2880_set_frontend()
1111 return -EINVAL; in cxd2880_set_frontend()
1113 mutex_unlock(priv->spi_mutex); in cxd2880_set_frontend()
1132 return -EINVAL; in cxd2880_get_stats()
1135 priv = fe->demodulator_priv; in cxd2880_get_stats()
1136 c = &fe->dtv_property_cache; in cxd2880_get_stats()
1139 c->pre_bit_error.len = 1; in cxd2880_get_stats()
1140 c->pre_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in cxd2880_get_stats()
1141 c->pre_bit_count.len = 1; in cxd2880_get_stats()
1142 c->pre_bit_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in cxd2880_get_stats()
1143 c->post_bit_error.len = 1; in cxd2880_get_stats()
1144 c->post_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in cxd2880_get_stats()
1145 c->post_bit_count.len = 1; in cxd2880_get_stats()
1146 c->post_bit_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in cxd2880_get_stats()
1147 c->block_error.len = 1; in cxd2880_get_stats()
1148 c->block_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in cxd2880_get_stats()
1149 c->block_count.len = 1; in cxd2880_get_stats()
1150 c->block_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in cxd2880_get_stats()
1155 if (time_after(jiffies, priv->pre_ber_update)) { in cxd2880_get_stats()
1156 priv->pre_ber_update = in cxd2880_get_stats()
1157 jiffies + msecs_to_jiffies(priv->pre_ber_interval); in cxd2880_get_stats()
1158 if (c->delivery_system == SYS_DVBT) { in cxd2880_get_stats()
1159 mutex_lock(priv->spi_mutex); in cxd2880_get_stats()
1160 ret = cxd2880_pre_bit_err_t(&priv->tnrdmd, in cxd2880_get_stats()
1163 mutex_unlock(priv->spi_mutex); in cxd2880_get_stats()
1164 } else if (c->delivery_system == SYS_DVBT2) { in cxd2880_get_stats()
1165 mutex_lock(priv->spi_mutex); in cxd2880_get_stats()
1166 ret = cxd2880_pre_bit_err_t2(&priv->tnrdmd, in cxd2880_get_stats()
1169 mutex_unlock(priv->spi_mutex); in cxd2880_get_stats()
1171 return -EINVAL; in cxd2880_get_stats()
1175 c->pre_bit_error.len = 1; in cxd2880_get_stats()
1176 c->pre_bit_error.stat[0].scale = FE_SCALE_COUNTER; in cxd2880_get_stats()
1177 c->pre_bit_error.stat[0].uvalue += pre_bit_err; in cxd2880_get_stats()
1178 c->pre_bit_count.len = 1; in cxd2880_get_stats()
1179 c->pre_bit_count.stat[0].scale = FE_SCALE_COUNTER; in cxd2880_get_stats()
1180 c->pre_bit_count.stat[0].uvalue += pre_bit_count; in cxd2880_get_stats()
1182 c->pre_bit_error.len = 1; in cxd2880_get_stats()
1183 c->pre_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in cxd2880_get_stats()
1184 c->pre_bit_count.len = 1; in cxd2880_get_stats()
1185 c->pre_bit_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in cxd2880_get_stats()
1190 if (time_after(jiffies, priv->post_ber_update)) { in cxd2880_get_stats()
1191 priv->post_ber_update = in cxd2880_get_stats()
1192 jiffies + msecs_to_jiffies(priv->post_ber_interval); in cxd2880_get_stats()
1193 if (c->delivery_system == SYS_DVBT) { in cxd2880_get_stats()
1194 mutex_lock(priv->spi_mutex); in cxd2880_get_stats()
1195 ret = cxd2880_post_bit_err_t(&priv->tnrdmd, in cxd2880_get_stats()
1198 mutex_unlock(priv->spi_mutex); in cxd2880_get_stats()
1199 } else if (c->delivery_system == SYS_DVBT2) { in cxd2880_get_stats()
1200 mutex_lock(priv->spi_mutex); in cxd2880_get_stats()
1201 ret = cxd2880_post_bit_err_t2(&priv->tnrdmd, in cxd2880_get_stats()
1204 mutex_unlock(priv->spi_mutex); in cxd2880_get_stats()
1206 return -EINVAL; in cxd2880_get_stats()
1210 c->post_bit_error.len = 1; in cxd2880_get_stats()
1211 c->post_bit_error.stat[0].scale = FE_SCALE_COUNTER; in cxd2880_get_stats()
1212 c->post_bit_error.stat[0].uvalue += post_bit_err; in cxd2880_get_stats()
1213 c->post_bit_count.len = 1; in cxd2880_get_stats()
1214 c->post_bit_count.stat[0].scale = FE_SCALE_COUNTER; in cxd2880_get_stats()
1215 c->post_bit_count.stat[0].uvalue += post_bit_count; in cxd2880_get_stats()
1217 c->post_bit_error.len = 1; in cxd2880_get_stats()
1218 c->post_bit_error.stat[0].scale = in cxd2880_get_stats()
1220 c->post_bit_count.len = 1; in cxd2880_get_stats()
1221 c->post_bit_count.stat[0].scale = in cxd2880_get_stats()
1227 if (time_after(jiffies, priv->ucblock_update)) { in cxd2880_get_stats()
1228 priv->ucblock_update = in cxd2880_get_stats()
1229 jiffies + msecs_to_jiffies(priv->ucblock_interval); in cxd2880_get_stats()
1230 if (c->delivery_system == SYS_DVBT) { in cxd2880_get_stats()
1231 mutex_lock(priv->spi_mutex); in cxd2880_get_stats()
1232 ret = cxd2880_read_block_err_t(&priv->tnrdmd, in cxd2880_get_stats()
1235 mutex_unlock(priv->spi_mutex); in cxd2880_get_stats()
1236 } else if (c->delivery_system == SYS_DVBT2) { in cxd2880_get_stats()
1237 mutex_lock(priv->spi_mutex); in cxd2880_get_stats()
1238 ret = cxd2880_read_block_err_t2(&priv->tnrdmd, in cxd2880_get_stats()
1241 mutex_unlock(priv->spi_mutex); in cxd2880_get_stats()
1243 return -EINVAL; in cxd2880_get_stats()
1246 c->block_error.len = 1; in cxd2880_get_stats()
1247 c->block_error.stat[0].scale = FE_SCALE_COUNTER; in cxd2880_get_stats()
1248 c->block_error.stat[0].uvalue += block_err; in cxd2880_get_stats()
1249 c->block_count.len = 1; in cxd2880_get_stats()
1250 c->block_count.stat[0].scale = FE_SCALE_COUNTER; in cxd2880_get_stats()
1251 c->block_count.stat[0].uvalue += block_count; in cxd2880_get_stats()
1253 c->block_error.len = 1; in cxd2880_get_stats()
1254 c->block_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in cxd2880_get_stats()
1255 c->block_count.len = 1; in cxd2880_get_stats()
1256 c->block_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in cxd2880_get_stats()
1273 return -EINVAL; in cxd2880_check_l1post_plp()
1276 priv = fe->demodulator_priv; in cxd2880_check_l1post_plp()
1278 ret = cxd2880_tnrdmd_dvbt2_check_l1post_valid(&priv->tnrdmd, in cxd2880_check_l1post_plp()
1284 return -EAGAIN; in cxd2880_check_l1post_plp()
1286 ret = cxd2880_tnrdmd_dvbt2_mon_data_plp_error(&priv->tnrdmd, in cxd2880_check_l1post_plp()
1292 priv->dvbt2_tune_param.tune_info = in cxd2880_check_l1post_plp()
1295 priv->dvbt2_tune_param.tune_info = in cxd2880_check_l1post_plp()
1314 return -EINVAL; in cxd2880_read_status()
1317 priv = fe->demodulator_priv; in cxd2880_read_status()
1318 c = &fe->dtv_property_cache; in cxd2880_read_status()
1321 if (priv->tnrdmd.state == CXD2880_TNRDMD_STATE_ACTIVE) { in cxd2880_read_status()
1322 mutex_lock(priv->spi_mutex); in cxd2880_read_status()
1323 if (c->delivery_system == SYS_DVBT) { in cxd2880_read_status()
1324 ret = cxd2880_tnrdmd_dvbt_mon_sync_stat(&priv->tnrdmd, in cxd2880_read_status()
1328 } else if (c->delivery_system == SYS_DVBT2) { in cxd2880_read_status()
1329 ret = cxd2880_tnrdmd_dvbt2_mon_sync_stat(&priv->tnrdmd, in cxd2880_read_status()
1335 mutex_unlock(priv->spi_mutex); in cxd2880_read_status()
1336 return -EINVAL; in cxd2880_read_status()
1339 mutex_unlock(priv->spi_mutex); in cxd2880_read_status()
1341 pr_err("failed. sys = %d\n", priv->tnrdmd.sys); in cxd2880_read_status()
1357 if (priv->s == 0 && (*status & FE_HAS_LOCK) && in cxd2880_read_status()
1359 mutex_lock(priv->spi_mutex); in cxd2880_read_status()
1360 if (c->delivery_system == SYS_DVBT) { in cxd2880_read_status()
1362 priv->s = *status; in cxd2880_read_status()
1363 } else if (c->delivery_system == SYS_DVBT2) { in cxd2880_read_status()
1367 priv->s = *status; in cxd2880_read_status()
1371 mutex_unlock(priv->spi_mutex); in cxd2880_read_status()
1372 return -EINVAL; in cxd2880_read_status()
1374 mutex_unlock(priv->spi_mutex); in cxd2880_read_status()
1391 return -EINVAL; in cxd2880_tune()
1415 enum cxd2880_tnrdmd_spectrum_sense sense; in cxd2880_get_frontend_t() local
1421 return -EINVAL; in cxd2880_get_frontend_t()
1424 priv = fe->demodulator_priv; in cxd2880_get_frontend_t()
1426 mutex_lock(priv->spi_mutex); in cxd2880_get_frontend_t()
1427 ret = cxd2880_tnrdmd_dvbt_mon_mode_guard(&priv->tnrdmd, in cxd2880_get_frontend_t()
1429 mutex_unlock(priv->spi_mutex); in cxd2880_get_frontend_t()
1433 c->transmission_mode = TRANSMISSION_MODE_2K; in cxd2880_get_frontend_t()
1436 c->transmission_mode = TRANSMISSION_MODE_8K; in cxd2880_get_frontend_t()
1439 c->transmission_mode = TRANSMISSION_MODE_2K; in cxd2880_get_frontend_t()
1445 c->guard_interval = GUARD_INTERVAL_1_32; in cxd2880_get_frontend_t()
1448 c->guard_interval = GUARD_INTERVAL_1_16; in cxd2880_get_frontend_t()
1451 c->guard_interval = GUARD_INTERVAL_1_8; in cxd2880_get_frontend_t()
1454 c->guard_interval = GUARD_INTERVAL_1_4; in cxd2880_get_frontend_t()
1457 c->guard_interval = GUARD_INTERVAL_1_32; in cxd2880_get_frontend_t()
1463 c->transmission_mode = TRANSMISSION_MODE_2K; in cxd2880_get_frontend_t()
1464 c->guard_interval = GUARD_INTERVAL_1_32; in cxd2880_get_frontend_t()
1468 mutex_lock(priv->spi_mutex); in cxd2880_get_frontend_t()
1469 ret = cxd2880_tnrdmd_dvbt_mon_tps_info(&priv->tnrdmd, &tps); in cxd2880_get_frontend_t()
1470 mutex_unlock(priv->spi_mutex); in cxd2880_get_frontend_t()
1474 c->hierarchy = HIERARCHY_NONE; in cxd2880_get_frontend_t()
1477 c->hierarchy = HIERARCHY_1; in cxd2880_get_frontend_t()
1480 c->hierarchy = HIERARCHY_2; in cxd2880_get_frontend_t()
1483 c->hierarchy = HIERARCHY_4; in cxd2880_get_frontend_t()
1486 c->hierarchy = HIERARCHY_NONE; in cxd2880_get_frontend_t()
1494 c->code_rate_HP = FEC_1_2; in cxd2880_get_frontend_t()
1497 c->code_rate_HP = FEC_2_3; in cxd2880_get_frontend_t()
1500 c->code_rate_HP = FEC_3_4; in cxd2880_get_frontend_t()
1503 c->code_rate_HP = FEC_5_6; in cxd2880_get_frontend_t()
1506 c->code_rate_HP = FEC_7_8; in cxd2880_get_frontend_t()
1509 c->code_rate_HP = FEC_NONE; in cxd2880_get_frontend_t()
1516 c->code_rate_LP = FEC_1_2; in cxd2880_get_frontend_t()
1519 c->code_rate_LP = FEC_2_3; in cxd2880_get_frontend_t()
1522 c->code_rate_LP = FEC_3_4; in cxd2880_get_frontend_t()
1525 c->code_rate_LP = FEC_5_6; in cxd2880_get_frontend_t()
1528 c->code_rate_LP = FEC_7_8; in cxd2880_get_frontend_t()
1531 c->code_rate_LP = FEC_NONE; in cxd2880_get_frontend_t()
1538 c->modulation = QPSK; in cxd2880_get_frontend_t()
1541 c->modulation = QAM_16; in cxd2880_get_frontend_t()
1544 c->modulation = QAM_64; in cxd2880_get_frontend_t()
1547 c->modulation = QPSK; in cxd2880_get_frontend_t()
1553 c->hierarchy = HIERARCHY_NONE; in cxd2880_get_frontend_t()
1554 c->code_rate_HP = FEC_NONE; in cxd2880_get_frontend_t()
1555 c->code_rate_LP = FEC_NONE; in cxd2880_get_frontend_t()
1556 c->modulation = QPSK; in cxd2880_get_frontend_t()
1560 mutex_lock(priv->spi_mutex); in cxd2880_get_frontend_t()
1561 ret = cxd2880_tnrdmd_dvbt_mon_spectrum_sense(&priv->tnrdmd, &sense); in cxd2880_get_frontend_t()
1562 mutex_unlock(priv->spi_mutex); in cxd2880_get_frontend_t()
1564 switch (sense) { in cxd2880_get_frontend_t()
1566 c->inversion = INVERSION_OFF; in cxd2880_get_frontend_t()
1569 c->inversion = INVERSION_ON; in cxd2880_get_frontend_t()
1572 c->inversion = INVERSION_OFF; in cxd2880_get_frontend_t()
1573 pr_debug("spectrum sense is invalid %d\n", sense); in cxd2880_get_frontend_t()
1577 c->inversion = INVERSION_OFF; in cxd2880_get_frontend_t()
1581 mutex_lock(priv->spi_mutex); in cxd2880_get_frontend_t()
1582 ret = cxd2880_tnrdmd_mon_rf_lvl(&priv->tnrdmd, &strength); in cxd2880_get_frontend_t()
1583 mutex_unlock(priv->spi_mutex); in cxd2880_get_frontend_t()
1585 c->strength.len = 1; in cxd2880_get_frontend_t()
1586 c->strength.stat[0].scale = FE_SCALE_DECIBEL; in cxd2880_get_frontend_t()
1587 c->strength.stat[0].svalue = strength; in cxd2880_get_frontend_t()
1589 c->strength.len = 1; in cxd2880_get_frontend_t()
1590 c->strength.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in cxd2880_get_frontend_t()
1596 c->cnr.len = 1; in cxd2880_get_frontend_t()
1597 c->cnr.stat[0].scale = FE_SCALE_DECIBEL; in cxd2880_get_frontend_t()
1598 c->cnr.stat[0].svalue = snr; in cxd2880_get_frontend_t()
1600 c->cnr.len = 1; in cxd2880_get_frontend_t()
1601 c->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in cxd2880_get_frontend_t()
1616 enum cxd2880_tnrdmd_spectrum_sense sense; in cxd2880_get_frontend_t2() local
1622 return -EINVAL; in cxd2880_get_frontend_t2()
1625 priv = fe->demodulator_priv; in cxd2880_get_frontend_t2()
1627 mutex_lock(priv->spi_mutex); in cxd2880_get_frontend_t2()
1628 ret = cxd2880_tnrdmd_dvbt2_mon_l1_pre(&priv->tnrdmd, &l1pre); in cxd2880_get_frontend_t2()
1629 mutex_unlock(priv->spi_mutex); in cxd2880_get_frontend_t2()
1633 c->transmission_mode = TRANSMISSION_MODE_2K; in cxd2880_get_frontend_t2()
1636 c->transmission_mode = TRANSMISSION_MODE_8K; in cxd2880_get_frontend_t2()
1639 c->transmission_mode = TRANSMISSION_MODE_4K; in cxd2880_get_frontend_t2()
1642 c->transmission_mode = TRANSMISSION_MODE_1K; in cxd2880_get_frontend_t2()
1645 c->transmission_mode = TRANSMISSION_MODE_16K; in cxd2880_get_frontend_t2()
1648 c->transmission_mode = TRANSMISSION_MODE_32K; in cxd2880_get_frontend_t2()
1651 c->transmission_mode = TRANSMISSION_MODE_2K; in cxd2880_get_frontend_t2()
1658 c->guard_interval = GUARD_INTERVAL_1_32; in cxd2880_get_frontend_t2()
1661 c->guard_interval = GUARD_INTERVAL_1_16; in cxd2880_get_frontend_t2()
1664 c->guard_interval = GUARD_INTERVAL_1_8; in cxd2880_get_frontend_t2()
1667 c->guard_interval = GUARD_INTERVAL_1_4; in cxd2880_get_frontend_t2()
1670 c->guard_interval = GUARD_INTERVAL_1_128; in cxd2880_get_frontend_t2()
1673 c->guard_interval = GUARD_INTERVAL_19_128; in cxd2880_get_frontend_t2()
1676 c->guard_interval = GUARD_INTERVAL_19_256; in cxd2880_get_frontend_t2()
1679 c->guard_interval = GUARD_INTERVAL_1_32; in cxd2880_get_frontend_t2()
1685 c->transmission_mode = TRANSMISSION_MODE_2K; in cxd2880_get_frontend_t2()
1686 c->guard_interval = GUARD_INTERVAL_1_32; in cxd2880_get_frontend_t2()
1690 mutex_lock(priv->spi_mutex); in cxd2880_get_frontend_t2()
1691 ret = cxd2880_tnrdmd_dvbt2_mon_code_rate(&priv->tnrdmd, in cxd2880_get_frontend_t2()
1694 mutex_unlock(priv->spi_mutex); in cxd2880_get_frontend_t2()
1698 c->fec_inner = FEC_1_2; in cxd2880_get_frontend_t2()
1701 c->fec_inner = FEC_3_5; in cxd2880_get_frontend_t2()
1704 c->fec_inner = FEC_2_3; in cxd2880_get_frontend_t2()
1707 c->fec_inner = FEC_3_4; in cxd2880_get_frontend_t2()
1710 c->fec_inner = FEC_4_5; in cxd2880_get_frontend_t2()
1713 c->fec_inner = FEC_5_6; in cxd2880_get_frontend_t2()
1716 c->fec_inner = FEC_NONE; in cxd2880_get_frontend_t2()
1721 c->fec_inner = FEC_NONE; in cxd2880_get_frontend_t2()
1725 mutex_lock(priv->spi_mutex); in cxd2880_get_frontend_t2()
1726 ret = cxd2880_tnrdmd_dvbt2_mon_qam(&priv->tnrdmd, in cxd2880_get_frontend_t2()
1729 mutex_unlock(priv->spi_mutex); in cxd2880_get_frontend_t2()
1733 c->modulation = QPSK; in cxd2880_get_frontend_t2()
1736 c->modulation = QAM_16; in cxd2880_get_frontend_t2()
1739 c->modulation = QAM_64; in cxd2880_get_frontend_t2()
1742 c->modulation = QAM_256; in cxd2880_get_frontend_t2()
1745 c->modulation = QPSK; in cxd2880_get_frontend_t2()
1750 c->modulation = QPSK; in cxd2880_get_frontend_t2()
1754 mutex_lock(priv->spi_mutex); in cxd2880_get_frontend_t2()
1755 ret = cxd2880_tnrdmd_dvbt2_mon_spectrum_sense(&priv->tnrdmd, &sense); in cxd2880_get_frontend_t2()
1756 mutex_unlock(priv->spi_mutex); in cxd2880_get_frontend_t2()
1758 switch (sense) { in cxd2880_get_frontend_t2()
1760 c->inversion = INVERSION_OFF; in cxd2880_get_frontend_t2()
1763 c->inversion = INVERSION_ON; in cxd2880_get_frontend_t2()
1766 c->inversion = INVERSION_OFF; in cxd2880_get_frontend_t2()
1767 pr_debug("spectrum sense is invalid %d\n", sense); in cxd2880_get_frontend_t2()
1771 c->inversion = INVERSION_OFF; in cxd2880_get_frontend_t2()
1775 mutex_lock(priv->spi_mutex); in cxd2880_get_frontend_t2()
1776 ret = cxd2880_tnrdmd_mon_rf_lvl(&priv->tnrdmd, &strength); in cxd2880_get_frontend_t2()
1777 mutex_unlock(priv->spi_mutex); in cxd2880_get_frontend_t2()
1779 c->strength.len = 1; in cxd2880_get_frontend_t2()
1780 c->strength.stat[0].scale = FE_SCALE_DECIBEL; in cxd2880_get_frontend_t2()
1781 c->strength.stat[0].svalue = strength; in cxd2880_get_frontend_t2()
1783 c->strength.len = 1; in cxd2880_get_frontend_t2()
1784 c->strength.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in cxd2880_get_frontend_t2()
1790 c->cnr.len = 1; in cxd2880_get_frontend_t2()
1791 c->cnr.stat[0].scale = FE_SCALE_DECIBEL; in cxd2880_get_frontend_t2()
1792 c->cnr.stat[0].svalue = snr; in cxd2880_get_frontend_t2()
1794 c->cnr.len = 1; in cxd2880_get_frontend_t2()
1795 c->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in cxd2880_get_frontend_t2()
1809 return -EINVAL; in cxd2880_get_frontend()
1812 pr_debug("system=%d\n", fe->dtv_property_cache.delivery_system); in cxd2880_get_frontend()
1813 switch (fe->dtv_property_cache.delivery_system) { in cxd2880_get_frontend()
1821 ret = -EINVAL; in cxd2880_get_frontend()
1894 priv->spi = cfg->spi; in cxd2880_attach()
1895 priv->spi_mutex = cfg->spi_mutex; in cxd2880_attach()
1896 priv->spi_device.spi = cfg->spi; in cxd2880_attach()
1898 memcpy(&fe->ops, &cxd2880_dvbt_t2_ops, in cxd2880_attach()
1901 ret = cxd2880_spi_device_initialize(&priv->spi_device, in cxd2880_attach()
1910 ret = cxd2880_spi_device_create_spi(&priv->cxd2880_spi, in cxd2880_attach()
1911 &priv->spi_device); in cxd2880_attach()
1918 ret = cxd2880_io_spi_create(&priv->regio, &priv->cxd2880_spi, 0); in cxd2880_attach()
1924 ret = priv->regio.write_reg(&priv->regio, in cxd2880_attach()
1931 ret = priv->regio.read_regs(&priv->regio, in cxd2880_attach()
1947 fe->demodulator_priv = priv; in cxd2880_attach()
1955 MODULE_DESCRIPTION("Sony CXD2880 DVB-T2/T tuner + demod driver");