Lines Matching +full:multi +full:- +full:attr

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Support for NXT2002 and NXT2004 - VSB/QAM
6 * Copyright (C) 2006-2014 Michael Krufky <mkrufky@linuxtv.org>
8 * and nxt2004 by Jean-Francois Thibert <jeanfrancois@sagetv.com>
15 * B2C2/BBTI Technisat Air2PC - ATSC (NXT2002)
31 #define NXT2002_DEFAULT_FIRMWARE "dvb-fe-nxt2002.fw"
32 #define NXT2004_DEFAULT_FIRMWARE "dvb-fe-nxt2004.fw"
63 if ((err = i2c_transfer (state->i2c, &msg, 1)) != 1) { in i2c_writebytes()
66 return -EREMOTEIO; in i2c_writebytes()
76 if ((err = i2c_transfer (state->i2c, &msg, 1)) != 1) { in i2c_readbytes()
79 return -EREMOTEIO; in i2c_readbytes()
89 …struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf2, .len = len +… in nxt200x_writebytes()
94 return -EINVAL; in nxt200x_writebytes()
100 if ((err = i2c_transfer (state->i2c, &msg, 1)) != 1) { in nxt200x_writebytes()
102 __func__, state->config->demod_address, err); in nxt200x_writebytes()
103 return -EREMOTEIO; in nxt200x_writebytes()
112 …struct i2c_msg msg [] = { { .addr = state->config->demod_address, .flags = 0, .buf = reg2, .len = … in nxt200x_readbytes()
113 { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = buf, .len = len } }; in nxt200x_readbytes()
117 if ((err = i2c_transfer (state->i2c, msg, 2)) != 2) { in nxt200x_readbytes()
119 __func__, state->config->demod_address, err); in nxt200x_readbytes()
120 return -EREMOTEIO; in nxt200x_readbytes()
143 u8 attr, len2, buf; in nxt200x_writereg_multibyte() local
146 /* set multi register register */ in nxt200x_writereg_multibyte()
152 switch (state->demod_chip) { in nxt200x_writereg_multibyte()
159 attr = 0x02; in nxt200x_writereg_multibyte()
161 attr = attr << 1; in nxt200x_writereg_multibyte()
163 attr = attr >> 1; in nxt200x_writereg_multibyte()
166 len2 = ((attr << 4) | 0x10) | len; in nxt200x_writereg_multibyte()
170 return -EINVAL; in nxt200x_writereg_multibyte()
173 /* set multi register length */ in nxt200x_writereg_multibyte()
181 switch (state->demod_chip) { in nxt200x_writereg_multibyte()
191 return -EINVAL; in nxt200x_writereg_multibyte()
202 u8 buf, len2, attr; in nxt200x_readreg_multibyte() local
205 /* set multi register register */ in nxt200x_readreg_multibyte()
208 switch (state->demod_chip) { in nxt200x_readreg_multibyte()
210 /* set multi register length */ in nxt200x_readreg_multibyte()
219 attr = 0x02; in nxt200x_readreg_multibyte()
221 attr = attr << 1; in nxt200x_readreg_multibyte()
223 attr = attr >> 1; in nxt200x_readreg_multibyte()
226 /* set multi register length */ in nxt200x_readreg_multibyte()
227 len2 = (attr << 4) | len; in nxt200x_readreg_multibyte()
240 return -EINVAL; in nxt200x_readreg_multibyte()
250 switch (state->demod_chip) { in nxt200x_microcontroller_stop()
327 switch (state->demod_chip) { in nxt200x_writetuner()
371 return -EINVAL; in nxt200x_writetuner()
381 switch (state->demod_chip) { in nxt200x_agc_reset()
404 struct nxt200x_state* state = fe->demodulator_priv; in nxt2002_load_firmware()
409 dprintk("Firmware is %zu bytes\n", fw->size); in nxt2002_load_firmware()
425 for (position = 0; position < fw->size; position++) { in nxt2002_load_firmware()
439 nxt200x_writebytes(state, chunkpos, &fw->data[position-3], 4); in nxt2002_load_firmware()
441 crc = nxt200x_crc(crc, fw->data[position]); in nxt2002_load_firmware()
443 if ((written == 255) || (position+1 == fw->size)) { in nxt2002_load_firmware()
445 nxt200x_writebytes(state, chunkpos+4-(written %4), in nxt2002_load_firmware()
446 &fw->data[position-(written %4) + 1], in nxt2002_load_firmware()
471 struct nxt200x_state* state = fe->demodulator_priv; in nxt2004_load_firmware()
476 dprintk("Firmware is %zu bytes\n", fw->size); in nxt2004_load_firmware()
486 for (position = 0; position < fw->size; position++) { in nxt2004_load_firmware()
487 crc = nxt200x_crc(crc, fw->data[position]); in nxt2004_load_firmware()
496 for (position = 0; position < fw->size;) { in nxt2004_load_firmware()
497 nxt200x_writebytes(state, 0x2C, &fw->data[position], in nxt2004_load_firmware()
498 fw->size-position > 255 ? 255 : fw->size-position); in nxt2004_load_firmware()
499 position += (fw->size-position > 255 ? 255 : fw->size-position); in nxt2004_load_firmware()
521 struct dtv_frontend_properties *p = &fe->dtv_property_cache; in nxt200x_setup_frontend_parameters()
522 struct nxt200x_state* state = fe->demodulator_priv; in nxt200x_setup_frontend_parameters()
528 if (state->demod_chip == NXT2004) { in nxt200x_setup_frontend_parameters()
537 switch (p->modulation) { in nxt200x_setup_frontend_parameters()
542 if (state->config->set_ts_params) in nxt200x_setup_frontend_parameters()
543 state->config->set_ts_params(fe, 1); in nxt200x_setup_frontend_parameters()
546 /* Set non-punctured clock for VSB */ in nxt200x_setup_frontend_parameters()
547 if (state->config->set_ts_params) in nxt200x_setup_frontend_parameters()
548 state->config->set_ts_params(fe, 0); in nxt200x_setup_frontend_parameters()
551 return -EINVAL; in nxt200x_setup_frontend_parameters()
554 if (fe->ops.tuner_ops.calc_regs) { in nxt200x_setup_frontend_parameters()
556 fe->ops.tuner_ops.calc_regs(fe, buf, 5); in nxt200x_setup_frontend_parameters()
566 switch (p->modulation) { in nxt200x_setup_frontend_parameters()
575 return -EINVAL; in nxt200x_setup_frontend_parameters()
580 switch (state->demod_chip) { in nxt200x_setup_frontend_parameters()
588 return -EINVAL; in nxt200x_setup_frontend_parameters()
595 switch (state->demod_chip) { in nxt200x_setup_frontend_parameters()
603 return -EINVAL; in nxt200x_setup_frontend_parameters()
607 switch (p->modulation) { in nxt200x_setup_frontend_parameters()
618 return -EINVAL; in nxt200x_setup_frontend_parameters()
621 switch (state->demod_chip) { in nxt200x_setup_frontend_parameters()
629 return -EINVAL; in nxt200x_setup_frontend_parameters()
636 if (state->demod_chip == NXT2004) { in nxt200x_setup_frontend_parameters()
646 switch (state->demod_chip) { in nxt200x_setup_frontend_parameters()
654 return -EINVAL; in nxt200x_setup_frontend_parameters()
669 if (state->demod_chip == NXT2004) { in nxt200x_setup_frontend_parameters()
698 switch (p->modulation) { in nxt200x_setup_frontend_parameters()
709 return -EINVAL; in nxt200x_setup_frontend_parameters()
720 switch (state->demod_chip) { in nxt200x_setup_frontend_parameters()
730 return -EINVAL; in nxt200x_setup_frontend_parameters()
739 if (state->demod_chip == NXT2004) { in nxt200x_setup_frontend_parameters()
756 struct nxt200x_state* state = fe->demodulator_priv; in nxt200x_read_status()
773 struct nxt200x_state* state = fe->demodulator_priv; in nxt200x_read_ber()
785 struct nxt200x_state* state = fe->demodulator_priv; in nxt200x_read_signal_strength()
797 *strength = ((0x7FFF - temp) & 0x0FFF) * 16; in nxt200x_read_signal_strength()
805 struct nxt200x_state* state = fe->demodulator_priv; in nxt200x_read_snr()
818 temp2 = 0x7FFF - temp; in nxt200x_read_snr()
822 snrdb = 1000*24 + ( 1000*(30-24) * ( temp2 - 0x7F00 ) / ( 0x7FFF - 0x7F00 ) ); in nxt200x_read_snr()
824 snrdb = 1000*18 + ( 1000*(24-18) * ( temp2 - 0x7EC0 ) / ( 0x7F00 - 0x7EC0 ) ); in nxt200x_read_snr()
826 snrdb = 1000*12 + ( 1000*(18-12) * ( temp2 - 0x7C00 ) / ( 0x7EC0 - 0x7C00 ) ); in nxt200x_read_snr()
828 snrdb = 1000*0 + ( 1000*(12-0) * ( temp2 - 0 ) / ( 0x7C00 - 0 ) ); in nxt200x_read_snr()
838 struct nxt200x_state* state = fe->demodulator_priv; in nxt200x_read_ucblocks()
854 struct nxt200x_state* state = fe->demodulator_priv; in nxt2002_init()
863 state->i2c->dev.parent); in nxt2002_init()
917 struct nxt200x_state* state = fe->demodulator_priv; in nxt2004_init()
930 state->i2c->dev.parent); in nxt2004_init()
1089 struct nxt200x_state* state = fe->demodulator_priv; in nxt200x_init()
1092 if (!state->initialised) { in nxt200x_init()
1093 switch (state->demod_chip) { in nxt200x_init()
1101 return -EINVAL; in nxt200x_init()
1103 state->initialised = 1; in nxt200x_init()
1110 fesettings->min_delay_ms = 500; in nxt200x_get_tune_settings()
1111 fesettings->step_size = 0; in nxt200x_get_tune_settings()
1112 fesettings->max_drift = 0; in nxt200x_get_tune_settings()
1118 struct nxt200x_state* state = fe->demodulator_priv; in nxt200x_release()
1136 state->config = config; in nxt200x_attach()
1137 state->i2c = i2c; in nxt200x_attach()
1138 state->initialised = 0; in nxt200x_attach()
1147 state->demod_chip = NXT2002; in nxt200x_attach()
1151 state->demod_chip = NXT2004; in nxt200x_attach()
1159 switch (state->demod_chip) { in nxt200x_attach()
1175 memcpy(&state->frontend.ops, &nxt200x_ops, sizeof(struct dvb_frontend_ops)); in nxt200x_attach()
1176 state->frontend.demodulator_priv = state; in nxt200x_attach()
1177 return &state->frontend; in nxt200x_attach()
1215 MODULE_DESCRIPTION("NXT200X (ATSC 8VSB & ITU-T J.83 AnnexB 64/256 QAM) Demodulator Driver");
1216 MODULE_AUTHOR("Kirk Lapray, Michael Krufky, Jean-Francois Thibert, and Taylor Jacob");