Lines Matching +full:lookup +full:- +full:table
1 // SPDX-License-Identifier: GPL-2.0-or-later
47 ((temp_chip->internal->i2c_adap != i2c_adap) || in find_inode()
48 (temp_chip->internal->i2c_addr != i2c_addr))) in find_inode()
50 temp_chip = temp_chip->next_inode; in find_inode()
61 struct stv0900_inode *del_node = find_inode(internal->i2c_adap, in remove_inode()
62 internal->i2c_addr); in remove_inode()
66 stv0900_first_inode = del_node->next_inode; in remove_inode()
68 while (prev_node->next_inode != del_node) in remove_inode()
69 prev_node = prev_node->next_inode; in remove_inode()
71 if (del_node->next_inode == NULL) in remove_inode()
72 prev_node->next_inode = NULL; in remove_inode()
74 prev_node->next_inode = in remove_inode()
75 prev_node->next_inode->next_inode; in remove_inode()
91 while (new_node->next_inode != NULL) in append_internal()
92 new_node = new_node->next_inode; in append_internal()
94 new_node->next_inode = kmalloc(sizeof(struct stv0900_inode), in append_internal()
96 if (new_node->next_inode != NULL) in append_internal()
97 new_node = new_node->next_inode; in append_internal()
103 new_node->internal = internal; in append_internal()
104 new_node->next_inode = NULL; in append_internal()
115 return (a >= (1 << (width - 1))) ? (a - (1 << width)) : a; in ge2comp()
124 .addr = intp->i2c_addr, in stv0900_write_reg()
134 ret = i2c_transfer(intp->i2c_adap, &i2cmsg, 1); in stv0900_write_reg()
146 .addr = intp->i2c_addr, in stv0900_read_reg()
151 .addr = intp->i2c_addr, in stv0900_read_reg()
158 ret = i2c_transfer(intp->i2c_adap, msg, 2); in stv0900_read_reg()
177 (*pos) = (i - 1); in extract_mask_pos()
214 intp->chip_id = stv0900_read_reg(intp, R0900_MID); in stv0900_initialize()
216 if (intp->errs != STV0900_NO_ERROR) in stv0900_initialize()
217 return intp->errs; in stv0900_initialize()
231 switch (intp->clkmode) { in stv0900_initialize()
235 | intp->clkmode); in stv0900_initialize()
292 if (intp->errs) in stv0900_set_mclk()
296 intp->quartz); in stv0900_set_mclk()
299 m_div = ((clk_sel * mclk) / intp->quartz) - 1; in stv0900_set_mclk()
301 intp->mclk = stv0900_get_mclk_freq(intp, in stv0900_set_mclk()
302 intp->quartz); in stv0900_set_mclk()
310 m_div = intp->mclk / 704000; in stv0900_set_mclk()
317 if ((intp->errs)) in stv0900_set_mclk()
349 struct stv0900_state *state = fe->demodulator_priv; in stv0900_i2c_gate_ctrl()
350 struct stv0900_internal *intp = state->internal; in stv0900_i2c_gate_ctrl()
351 enum fe_stv0900_demod_num demod = state->demod; in stv0900_i2c_gate_ctrl()
365 if (intp->chip_id >= 0x20) { in stv0900_set_ts_parallel_serial()
513 frontend_ops = &fe->ops; in stv0900_set_tuner()
514 tuner_ops = &frontend_ops->tuner_ops; in stv0900_set_tuner()
516 if (tuner_ops->set_frequency) { in stv0900_set_tuner()
517 if ((tuner_ops->set_frequency(fe, frequency)) < 0) in stv0900_set_tuner()
524 if (tuner_ops->set_bandwidth) { in stv0900_set_tuner()
525 if ((tuner_ops->set_bandwidth(fe, bandwidth)) < 0) in stv0900_set_tuner()
538 frontend_ops = &fe->ops; in stv0900_set_bandwidth()
539 tuner_ops = &frontend_ops->tuner_ops; in stv0900_set_bandwidth()
541 if (tuner_ops->set_bandwidth) { in stv0900_set_bandwidth()
542 if ((tuner_ops->set_bandwidth(fe, bandwidth)) < 0) in stv0900_set_bandwidth()
556 real_Tuner_Frequency = Tuner_Frequency(MHz) - Tuner_granularity(MHz) in stv0900_get_freq_auto()
591 const struct stv0900_table *lookup, in stv0900_get_rf_level() argument
602 if ((lookup == NULL) || (lookup->size <= 0)) in stv0900_get_rf_level()
609 imax = lookup->size - 1; in stv0900_get_rf_level()
610 if (INRANGE(lookup->table[imin].regval, agc_gain, in stv0900_get_rf_level()
611 lookup->table[imax].regval)) { in stv0900_get_rf_level()
612 while ((imax - imin) > 1) { in stv0900_get_rf_level()
615 if (INRANGE(lookup->table[imin].regval, in stv0900_get_rf_level()
617 lookup->table[i].regval)) in stv0900_get_rf_level()
623 rf_lvl = (s32)agc_gain - lookup->table[imin].regval; in stv0900_get_rf_level()
624 rf_lvl *= (lookup->table[imax].realval - in stv0900_get_rf_level()
625 lookup->table[imin].realval); in stv0900_get_rf_level()
626 rf_lvl /= (lookup->table[imax].regval - in stv0900_get_rf_level()
627 lookup->table[imin].regval); in stv0900_get_rf_level()
628 rf_lvl += lookup->table[imin].realval; in stv0900_get_rf_level()
629 } else if (agc_gain > lookup->table[0].regval) in stv0900_get_rf_level()
631 else if (agc_gain < lookup->table[lookup->size-1].regval) in stv0900_get_rf_level()
632 rf_lvl = -100; in stv0900_get_rf_level()
641 struct stv0900_state *state = fe->demodulator_priv; in stv0900_read_signal_strength()
642 struct stv0900_internal *internal = state->internal; in stv0900_read_signal_strength()
644 state->demod); in stv0900_read_signal_strength()
659 const struct stv0900_table *lookup) in stv0900_carr_get_quality() argument
661 struct stv0900_state *state = fe->demodulator_priv; in stv0900_carr_get_quality()
662 struct stv0900_internal *intp = state->internal; in stv0900_carr_get_quality()
663 enum fe_stv0900_demod_num demod = state->demod; in stv0900_carr_get_quality()
665 s32 c_n = -100, in stv0900_carr_get_quality()
684 if ((lookup != NULL) && lookup->size) { in stv0900_carr_get_quality()
697 imax = lookup->size - 1; in stv0900_carr_get_quality()
698 if (INRANGE(lookup->table[imin].regval, in stv0900_carr_get_quality()
700 lookup->table[imax].regval)) { in stv0900_carr_get_quality()
701 while ((imax - imin) > 1) { in stv0900_carr_get_quality()
703 if (INRANGE(lookup->table[imin].regval, in stv0900_carr_get_quality()
705 lookup->table[i].regval)) in stv0900_carr_get_quality()
711 c_n = ((regval - lookup->table[imin].regval) in stv0900_carr_get_quality()
712 * (lookup->table[imax].realval in stv0900_carr_get_quality()
713 - lookup->table[imin].realval) in stv0900_carr_get_quality()
714 / (lookup->table[imax].regval in stv0900_carr_get_quality()
715 - lookup->table[imin].regval)) in stv0900_carr_get_quality()
716 + lookup->table[imin].realval; in stv0900_carr_get_quality()
717 } else if (regval < lookup->table[imin].regval) in stv0900_carr_get_quality()
727 struct stv0900_state *state = fe->demodulator_priv; in stv0900_read_ucblocks()
728 struct stv0900_internal *intp = state->internal; in stv0900_read_ucblocks()
729 enum fe_stv0900_demod_num demod = state->demod; in stv0900_read_ucblocks()
735 /* DVB-S2 delineator errors count */ in stv0900_read_ucblocks()
817 struct stv0900_state *state = fe->demodulator_priv; in stv0900_read_ber()
818 struct stv0900_internal *internal = state->internal; in stv0900_read_ber()
820 *ber = stv0900_get_ber(internal, state->demod); in stv0900_read_ber()
887 if (intp->chip_id <= 0x11) { in stv0900_activate_s2_modcod()
894 reg_index = MODCODLSTF - mod_code / 2; in stv0900_activate_s2_modcod()
923 } else if (intp->chip_id >= 0x12) { in stv0900_activate_s2_modcod()
963 if (intp->chip_id == 0x10) in stv0900_start_search()
966 if (intp->chip_id < 0x20) in stv0900_start_search()
969 if (intp->chip_id <= 0x20) { in stv0900_start_search()
970 if (intp->symbol_rate[0] <= 5000000) { in stv0900_start_search()
983 if (intp->symbol_rate[demod] <= 5000000) in stv0900_start_search()
989 if (intp->srch_algo[demod] == STV0900_WARM_START) { in stv0900_start_search()
991 freq /= (intp->mclk / 1000); in stv0900_start_search()
994 freq = (intp->srch_range[demod] / 2000); in stv0900_start_search()
995 if (intp->symbol_rate[demod] <= 5000000) in stv0900_start_search()
1001 freq /= (intp->mclk / 1000); in stv0900_start_search()
1007 freq_s16 *= (-1); in stv0900_start_search()
1015 if (intp->chip_id >= 0x20) { in stv0900_start_search()
1019 if ((intp->srch_standard[demod] == STV0900_SEARCH_DVBS1) || in stv0900_start_search()
1020 (intp->srch_standard[demod] == STV0900_SEARCH_DSS) || in stv0900_start_search()
1021 (intp->srch_standard[demod] == STV0900_AUTO_SEARCH)) { in stv0900_start_search()
1035 if (intp->chip_id >= 0x20) { in stv0900_start_search()
1036 if (intp->symbol_rate[demod] < 2000000) { in stv0900_start_search()
1037 if (intp->chip_id <= 0x20) in stv0900_start_search()
1043 } else if (intp->symbol_rate[demod] < 10000000) { in stv0900_start_search()
1052 if (intp->symbol_rate[demod] < 10000000) in stv0900_start_search()
1058 switch (intp->srch_algo[demod]) { in stv0900_start_search()
1269 if ((intp->demod_mode != STV0900_DUAL) in stv0900_st_dvbs2_single()
1273 intp->demod_mode = STV0900_DUAL; in stv0900_st_dvbs2_single()
1317 intp->demod_mode = STV0900_SINGLE; in stv0900_st_dvbs2_single()
1334 struct stv0900_state *state = fe->demodulator_priv; in stv0900_init_internal()
1340 struct stv0900_inode *temp_int = find_inode(state->i2c_adap, in stv0900_init_internal()
1341 state->config->demod_address); in stv0900_init_internal()
1345 if ((temp_int != NULL) && (p_init->demod_mode == STV0900_DUAL)) { in stv0900_init_internal()
1346 state->internal = temp_int->internal; in stv0900_init_internal()
1347 (state->internal->dmds_used)++; in stv0900_init_internal()
1351 state->internal = kmalloc(sizeof(struct stv0900_internal), in stv0900_init_internal()
1353 if (state->internal == NULL) in stv0900_init_internal()
1355 temp_int = append_internal(state->internal); in stv0900_init_internal()
1357 kfree(state->internal); in stv0900_init_internal()
1358 state->internal = NULL; in stv0900_init_internal()
1361 state->internal->dmds_used = 1; in stv0900_init_internal()
1362 state->internal->i2c_adap = state->i2c_adap; in stv0900_init_internal()
1363 state->internal->i2c_addr = state->config->demod_address; in stv0900_init_internal()
1364 state->internal->clkmode = state->config->clkmode; in stv0900_init_internal()
1365 state->internal->errs = STV0900_NO_ERROR; in stv0900_init_internal()
1369 if (state->internal == NULL) { in stv0900_init_internal()
1374 demodError = stv0900_initialize(state->internal); in stv0900_init_internal()
1386 intp = state->internal; in stv0900_init_internal()
1388 intp->demod_mode = p_init->demod_mode; in stv0900_init_internal()
1389 stv0900_st_dvbs2_single(intp, intp->demod_mode, STV0900_DEMOD_1); in stv0900_init_internal()
1390 intp->chip_id = stv0900_read_reg(intp, R0900_MID); in stv0900_init_internal()
1391 intp->rolloff = p_init->rolloff; in stv0900_init_internal()
1392 intp->quartz = p_init->dmd_ref_clk; in stv0900_init_internal()
1394 stv0900_write_bits(intp, F0900_P1_ROLLOFF_CONTROL, p_init->rolloff); in stv0900_init_internal()
1395 stv0900_write_bits(intp, F0900_P2_ROLLOFF_CONTROL, p_init->rolloff); in stv0900_init_internal()
1397 intp->ts_config = p_init->ts_config; in stv0900_init_internal()
1398 if (intp->ts_config == NULL) in stv0900_init_internal()
1400 p_init->path1_ts_clock, in stv0900_init_internal()
1401 p_init->path2_ts_clock); in stv0900_init_internal()
1403 for (i = 0; intp->ts_config[i].addr != 0xffff; i++) in stv0900_init_internal()
1405 intp->ts_config[i].addr, in stv0900_init_internal()
1406 intp->ts_config[i].val); in stv0900_init_internal()
1414 intp->tuner_type[0] = p_init->tuner1_type; in stv0900_init_internal()
1415 intp->tuner_type[1] = p_init->tuner2_type; in stv0900_init_internal()
1417 switch (p_init->tuner1_type) { in stv0900_init_internal()
1435 stv0900_write_bits(intp, F0900_P1_TUN_MADDRESS, p_init->tun1_maddress); in stv0900_init_internal()
1436 switch (p_init->tuner1_adc) { in stv0900_init_internal()
1447 switch (p_init->tuner2_type) { in stv0900_init_internal()
1465 stv0900_write_bits(intp, F0900_P2_TUN_MADDRESS, p_init->tun2_maddress); in stv0900_init_internal()
1466 switch (p_init->tuner2_adc) { in stv0900_init_internal()
1476 stv0900_write_bits(intp, F0900_P1_TUN_IQSWAP, p_init->tun1_iq_inv); in stv0900_init_internal()
1477 stv0900_write_bits(intp, F0900_P2_TUN_IQSWAP, p_init->tun2_iq_inv); in stv0900_init_internal()
1481 switch (intp->clkmode) { in stv0900_init_internal()
1484 stv0900_write_reg(intp, R0900_SYNTCTRL, 0x20 | intp->clkmode); in stv0900_init_internal()
1493 intp->mclk = stv0900_get_mclk_freq(intp, intp->quartz); in stv0900_init_internal()
1494 if (intp->errs) in stv0900_init_internal()
1534 bitrate = (stv0900_get_mclk_freq(intp, intp->quartz)/1000000) in stv0900_status()
1552 dprintk("Enable MIS filtering - %d\n", mis); in stv0900_set_mis()
1564 struct stv0900_state *state = fe->demodulator_priv; in stv0900_search()
1565 struct stv0900_internal *intp = state->internal; in stv0900_search()
1566 enum fe_stv0900_demod_num demod = state->demod; in stv0900_search()
1567 struct dtv_frontend_properties *c = &fe->dtv_property_cache; in stv0900_search()
1570 struct stv0900_signal_info p_result = intp->result[demod]; in stv0900_search()
1576 if (!(INRANGE(100000, c->symbol_rate, 70000000))) in stv0900_search()
1579 if (state->config->set_ts_params) in stv0900_search()
1580 state->config->set_ts_params(fe, 0); in stv0900_search()
1582 stv0900_set_mis(intp, demod, c->stream_id); in stv0900_search()
1586 p_search.frequency = c->frequency; in stv0900_search()
1587 p_search.symbol_rate = c->symbol_rate; in stv0900_search()
1593 /* Speeds up DVB-S searching */ in stv0900_search()
1594 if (c->delivery_system == SYS_DVBS) in stv0900_search()
1597 intp->srch_standard[demod] = p_search.standard; in stv0900_search()
1598 intp->symbol_rate[demod] = p_search.symbol_rate; in stv0900_search()
1599 intp->srch_range[demod] = p_search.search_range; in stv0900_search()
1600 intp->freq[demod] = p_search.frequency; in stv0900_search()
1601 intp->srch_algo[demod] = p_search.search_algo; in stv0900_search()
1602 intp->srch_iq_inv[demod] = p_search.iq_inversion; in stv0900_search()
1603 intp->fec[demod] = p_search.fec; in stv0900_search()
1605 (intp->errs == STV0900_NO_ERROR)) { in stv0900_search()
1606 p_result.locked = intp->result[demod].locked; in stv0900_search()
1607 p_result.standard = intp->result[demod].standard; in stv0900_search()
1608 p_result.frequency = intp->result[demod].frequency; in stv0900_search()
1609 p_result.symbol_rate = intp->result[demod].symbol_rate; in stv0900_search()
1610 p_result.fec = intp->result[demod].fec; in stv0900_search()
1611 p_result.modcode = intp->result[demod].modcode; in stv0900_search()
1612 p_result.pilot = intp->result[demod].pilot; in stv0900_search()
1613 p_result.frame_len = intp->result[demod].frame_len; in stv0900_search()
1614 p_result.spectrum = intp->result[demod].spectrum; in stv0900_search()
1615 p_result.rolloff = intp->result[demod].rolloff; in stv0900_search()
1616 p_result.modulation = intp->result[demod].modulation; in stv0900_search()
1619 switch (intp->err[demod]) { in stv0900_search()
1642 struct stv0900_state *state = fe->demodulator_priv; in stv0900_read_status()
1646 if ((stv0900_status(state->internal, state->demod)) == TRUE) { in stv0900_read_status()
1652 if (state->config->set_lock_led) in stv0900_read_status()
1653 state->config->set_lock_led(fe, 1); in stv0900_read_status()
1656 if (state->config->set_lock_led) in stv0900_read_status()
1657 state->config->set_lock_led(fe, 0); in stv0900_read_status()
1667 struct stv0900_state *state = fe->demodulator_priv; in stv0900_stop_ts()
1668 struct stv0900_internal *intp = state->internal; in stv0900_stop_ts()
1669 enum fe_stv0900_demod_num demod = state->demod; in stv0900_stop_ts()
1681 struct stv0900_state *state = fe->demodulator_priv; in stv0900_diseqc_init()
1682 struct stv0900_internal *intp = state->internal; in stv0900_diseqc_init()
1683 enum fe_stv0900_demod_num demod = state->demod; in stv0900_diseqc_init()
1685 stv0900_write_bits(intp, DISTX_MODE, state->config->diseqc_mode); in stv0900_diseqc_init()
1728 struct stv0900_state *state = fe->demodulator_priv; in stv0900_send_master_cmd()
1730 return stv0900_diseqc_send(state->internal, in stv0900_send_master_cmd()
1731 cmd->msg, in stv0900_send_master_cmd()
1732 cmd->msg_len, in stv0900_send_master_cmd()
1733 state->demod); in stv0900_send_master_cmd()
1739 struct stv0900_state *state = fe->demodulator_priv; in stv0900_send_burst()
1740 struct stv0900_internal *intp = state->internal; in stv0900_send_burst()
1741 enum fe_stv0900_demod_num demod = state->demod; in stv0900_send_burst()
1749 stv0900_diseqc_send(intp, &data, 1, state->demod); in stv0900_send_burst()
1754 stv0900_diseqc_send(intp, &data, 1, state->demod); in stv0900_send_burst()
1764 struct stv0900_state *state = fe->demodulator_priv; in stv0900_recv_slave_reply()
1765 struct stv0900_internal *intp = state->internal; in stv0900_recv_slave_reply()
1766 enum fe_stv0900_demod_num demod = state->demod; in stv0900_recv_slave_reply()
1769 reply->msg_len = 0; in stv0900_recv_slave_reply()
1777 reply->msg_len = stv0900_get_bits(intp, FIFO_BYTENBR); in stv0900_recv_slave_reply()
1779 for (i = 0; i < reply->msg_len; i++) in stv0900_recv_slave_reply()
1780 reply->msg[i] = stv0900_read_reg(intp, DISRXDATA); in stv0900_recv_slave_reply()
1789 struct stv0900_state *state = fe->demodulator_priv; in stv0900_set_tone()
1790 struct stv0900_internal *intp = state->internal; in stv0900_set_tone()
1791 enum fe_stv0900_demod_num demod = state->demod; in stv0900_set_tone()
1804 /*return diseqc mode to config->diseqc_mode. in stv0900_set_tone()
1807 state->config->diseqc_mode); in stv0900_set_tone()
1813 return -EINVAL; in stv0900_set_tone()
1821 struct stv0900_state *state = fe->demodulator_priv; in stv0900_release()
1825 if (state->config->set_lock_led) in stv0900_release()
1826 state->config->set_lock_led(fe, 0); in stv0900_release()
1828 if ((--(state->internal->dmds_used)) <= 0) { in stv0900_release()
1832 remove_inode(state->internal); in stv0900_release()
1833 kfree(state->internal); in stv0900_release()
1841 struct stv0900_state *state = fe->demodulator_priv; in stv0900_sleep()
1845 if (state->config->set_lock_led) in stv0900_sleep()
1846 state->config->set_lock_led(fe, 0); in stv0900_sleep()
1854 struct stv0900_state *state = fe->demodulator_priv; in stv0900_get_frontend()
1855 struct stv0900_internal *intp = state->internal; in stv0900_get_frontend()
1856 enum fe_stv0900_demod_num demod = state->demod; in stv0900_get_frontend()
1857 struct stv0900_signal_info p_result = intp->result[demod]; in stv0900_get_frontend()
1859 p->frequency = p_result.locked ? p_result.frequency : 0; in stv0900_get_frontend()
1860 p->symbol_rate = p_result.locked ? p_result.symbol_rate : 0; in stv0900_get_frontend()
1910 state->demod = demod; in stv0900_attach()
1911 state->config = config; in stv0900_attach()
1912 state->i2c_adap = i2c; in stv0900_attach()
1914 memcpy(&state->frontend.ops, &stv0900_ops, in stv0900_attach()
1916 state->frontend.demodulator_priv = state; in stv0900_attach()
1921 init_params.dmd_ref_clk = config->xtal; in stv0900_attach()
1922 init_params.demod_mode = config->demod_mode; in stv0900_attach()
1924 init_params.path1_ts_clock = config->path1_mode; in stv0900_attach()
1925 init_params.tun1_maddress = config->tun1_maddress; in stv0900_attach()
1927 init_params.tuner1_adc = config->tun1_adc; in stv0900_attach()
1928 init_params.tuner1_type = config->tun1_type; in stv0900_attach()
1929 init_params.path2_ts_clock = config->path2_mode; in stv0900_attach()
1930 init_params.ts_config = config->ts_config_regs; in stv0900_attach()
1931 init_params.tun2_maddress = config->tun2_maddress; in stv0900_attach()
1932 init_params.tuner2_adc = config->tun2_adc; in stv0900_attach()
1933 init_params.tuner2_type = config->tun2_type; in stv0900_attach()
1936 err_stv0900 = stv0900_init_internal(&state->frontend, in stv0900_attach()
1942 if (state->internal->chip_id >= 0x30) in stv0900_attach()
1943 state->frontend.ops.info.caps |= FE_CAN_MULTISTREAM; in stv0900_attach()
1952 return &state->frontend; in stv0900_attach()