Lines Matching refs:state
58 static int i2c_writebytes (struct nxt200x_state* state, u8 addr, u8 *buf, u8 len) in i2c_writebytes() argument
63 if ((err = i2c_transfer (state->i2c, &msg, 1)) != 1) { in i2c_writebytes()
71 static int i2c_readbytes(struct nxt200x_state *state, u8 addr, u8 *buf, u8 len) in i2c_readbytes() argument
76 if ((err = i2c_transfer (state->i2c, &msg, 1)) != 1) { in i2c_readbytes()
84 static int nxt200x_writebytes (struct nxt200x_state* state, u8 reg, in nxt200x_writebytes() argument
89 …struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf2, .len = len +… 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()
108 static int nxt200x_readbytes(struct nxt200x_state *state, u8 reg, u8 *buf, u8 len) in nxt200x_readbytes() argument
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()
141 static int nxt200x_writereg_multibyte (struct nxt200x_state* state, u8 reg, u8* data, u8 len) in nxt200x_writereg_multibyte() argument
147 nxt200x_writebytes(state, 0x35, ®, 1); in nxt200x_writereg_multibyte()
150 nxt200x_writebytes(state, 0x36, data, len); in nxt200x_writereg_multibyte()
152 switch (state->demod_chip) { in nxt200x_writereg_multibyte()
175 nxt200x_writebytes(state, 0x34, &len2, 1); in nxt200x_writereg_multibyte()
178 nxt200x_writebytes(state, 0x21, &buf, 1); in nxt200x_writereg_multibyte()
180 nxt200x_readbytes(state, 0x21, &buf, 1); in nxt200x_writereg_multibyte()
182 switch (state->demod_chip) { in nxt200x_writereg_multibyte()
201 static int nxt200x_readreg_multibyte (struct nxt200x_state* state, u8 reg, u8* data, u8 len) in nxt200x_readreg_multibyte() argument
208 nxt200x_writebytes(state, 0x35, ®, 1); in nxt200x_readreg_multibyte()
210 switch (state->demod_chip) { in nxt200x_readreg_multibyte()
214 nxt200x_writebytes(state, 0x34, &len2, 1); in nxt200x_readreg_multibyte()
217 nxt200x_readbytes(state, reg, data, len); in nxt200x_readreg_multibyte()
231 nxt200x_writebytes(state, 0x34, &len2, 1); in nxt200x_readreg_multibyte()
235 nxt200x_writebytes(state, 0x21, &buf, 1); in nxt200x_readreg_multibyte()
239 nxt200x_readbytes(state, 0x36 + i, &data[i], 1); in nxt200x_readreg_multibyte()
249 static void nxt200x_microcontroller_stop (struct nxt200x_state* state) in nxt200x_microcontroller_stop() argument
255 switch (state->demod_chip) { in nxt200x_microcontroller_stop()
268 nxt200x_writebytes(state, 0x22, &buf, 1); in nxt200x_microcontroller_stop()
271 nxt200x_readbytes(state, 0x31, &buf, 1); in nxt200x_microcontroller_stop()
282 static void nxt200x_microcontroller_start (struct nxt200x_state* state) in nxt200x_microcontroller_start() argument
288 nxt200x_writebytes(state, 0x22, &buf, 1); in nxt200x_microcontroller_start()
291 static void nxt2004_microcontroller_init (struct nxt200x_state* state) in nxt2004_microcontroller_init() argument
298 nxt200x_writebytes(state, 0x2b, buf, 1); in nxt2004_microcontroller_init()
300 nxt200x_writebytes(state, 0x34, buf, 1); in nxt2004_microcontroller_init()
302 nxt200x_writebytes(state, 0x35, buf, 1); in nxt2004_microcontroller_init()
305 nxt200x_writebytes(state, 0x36, buf, 9); in nxt2004_microcontroller_init()
307 nxt200x_writebytes(state, 0x21, buf, 1); in nxt2004_microcontroller_init()
310 nxt200x_readbytes(state, 0x21, buf, 1); in nxt2004_microcontroller_init()
322 static int nxt200x_writetuner (struct nxt200x_state* state, u8* data) in nxt200x_writetuner() argument
332 switch (state->demod_chip) { in nxt200x_writetuner()
334 if (i2c_writebytes(state, data[0], data+1, 4)) in nxt200x_writetuner()
338 i2c_readbytes(state, data[0], &buf, 1); in nxt200x_writetuner()
349 nxt200x_writebytes(state, 0x20, &buf, 1); in nxt200x_writetuner()
353 nxt200x_writebytes(state, 0x34, &buf, 1); in nxt200x_writetuner()
356 nxt200x_writebytes(state, 0x36, data+1, 4); in nxt200x_writetuner()
360 nxt200x_writebytes(state, 0x35, &buf, 1); in nxt200x_writetuner()
364 nxt200x_writebytes(state, 0x21, &buf, 1); in nxt200x_writetuner()
367 nxt200x_readbytes(state, 0x21, &buf, 1); in nxt200x_writetuner()
382 static void nxt200x_agc_reset(struct nxt200x_state* state) in nxt200x_agc_reset() argument
387 switch (state->demod_chip) { in nxt200x_agc_reset()
390 nxt200x_writebytes(state, 0x08, &buf, 1); in nxt200x_agc_reset()
392 nxt200x_writebytes(state, 0x08, &buf, 1); in nxt200x_agc_reset()
395 nxt200x_readreg_multibyte(state, 0x08, &buf, 1); in nxt200x_agc_reset()
397 nxt200x_writereg_multibyte(state, 0x08, &buf, 1); in nxt200x_agc_reset()
399 nxt200x_writereg_multibyte(state, 0x08, &buf, 1); in nxt200x_agc_reset()
410 struct nxt200x_state* state = fe->demodulator_priv; in nxt2002_load_firmware() local
418 nxt200x_readbytes(state, 0x10, buf, 1); in nxt2002_load_firmware()
429 nxt200x_writebytes(state, 0x2B, buf, 1); in nxt2002_load_firmware()
439 nxt200x_writebytes(state, 0x29, buf, 3); in nxt2002_load_firmware()
445 nxt200x_writebytes(state, chunkpos, &fw->data[position-3], 4); in nxt2002_load_firmware()
451 nxt200x_writebytes(state, chunkpos+4-(written %4), in nxt2002_load_firmware()
458 nxt200x_writebytes(state, 0x2C, buf, 2); in nxt2002_load_firmware()
461 nxt200x_readbytes(state, 0x2A, buf, 1); in nxt2002_load_firmware()
465 nxt200x_writebytes(state, 0x2B, buf, 1); in nxt2002_load_firmware()
477 struct nxt200x_state* state = fe->demodulator_priv; in nxt2004_load_firmware() local
489 nxt200x_writebytes(state, 0x2B, buf,1); in nxt2004_load_firmware()
500 nxt200x_writebytes(state,0x29,buf,3); in nxt2004_load_firmware()
503 nxt200x_writebytes(state, 0x2C, &fw->data[position], in nxt2004_load_firmware()
513 nxt200x_writebytes(state, 0x2C, buf,2); in nxt2004_load_firmware()
516 nxt200x_readbytes(state, 0x2C, buf, 1); in nxt2004_load_firmware()
520 nxt200x_writebytes(state, 0x2B, buf,1); in nxt2004_load_firmware()
528 struct nxt200x_state* state = fe->demodulator_priv; in nxt200x_setup_frontend_parameters() local
532 nxt200x_microcontroller_stop(state); in nxt200x_setup_frontend_parameters()
534 if (state->demod_chip == NXT2004) { in nxt200x_setup_frontend_parameters()
537 nxt200x_writebytes(state, 0x14, buf, 1); in nxt200x_setup_frontend_parameters()
539 nxt200x_writebytes(state, 0x17, buf, 1); in nxt200x_setup_frontend_parameters()
548 if (state->config->set_ts_params) in nxt200x_setup_frontend_parameters()
549 state->config->set_ts_params(fe, 1); in nxt200x_setup_frontend_parameters()
553 if (state->config->set_ts_params) in nxt200x_setup_frontend_parameters()
554 state->config->set_ts_params(fe, 0); in nxt200x_setup_frontend_parameters()
566 nxt200x_writetuner(state, buf); in nxt200x_setup_frontend_parameters()
570 nxt200x_agc_reset(state); in nxt200x_setup_frontend_parameters()
585 nxt200x_writebytes(state, 0x42, buf, 1); in nxt200x_setup_frontend_parameters()
588 switch (state->demod_chip) { in nxt200x_setup_frontend_parameters()
599 nxt200x_writebytes(state, 0x57, buf, 1); in nxt200x_setup_frontend_parameters()
604 switch (state->demod_chip) { in nxt200x_setup_frontend_parameters()
606 nxt200x_writereg_multibyte(state, 0x58, buf, 2); in nxt200x_setup_frontend_parameters()
609 nxt200x_writebytes(state, 0x58, buf, 2); in nxt200x_setup_frontend_parameters()
632 switch (state->demod_chip) { in nxt200x_setup_frontend_parameters()
634 nxt200x_writereg_multibyte(state, 0x5C, buf, 2); in nxt200x_setup_frontend_parameters()
637 nxt200x_writebytes(state, 0x5C, buf, 2); in nxt200x_setup_frontend_parameters()
646 nxt200x_writebytes(state, 0x43, buf, 1); in nxt200x_setup_frontend_parameters()
648 if (state->demod_chip == NXT2004) { in nxt200x_setup_frontend_parameters()
652 nxt200x_writebytes(state, 0x46, buf, 2); in nxt200x_setup_frontend_parameters()
658 switch (state->demod_chip) { in nxt200x_setup_frontend_parameters()
660 nxt200x_writereg_multibyte(state, 0x4B, buf, 2); in nxt200x_setup_frontend_parameters()
663 nxt200x_writebytes(state, 0x4B, buf, 2); in nxt200x_setup_frontend_parameters()
672 nxt200x_writebytes(state, 0x4D, buf, 1); in nxt200x_setup_frontend_parameters()
676 nxt200x_writebytes(state, 0x55, buf, 1); in nxt200x_setup_frontend_parameters()
680 nxt200x_writebytes(state, 0x41, buf, 1); in nxt200x_setup_frontend_parameters()
682 if (state->demod_chip == NXT2004) { in nxt200x_setup_frontend_parameters()
683 nxt200x_readreg_multibyte(state, 0x80, buf, 1); in nxt200x_setup_frontend_parameters()
685 nxt200x_writereg_multibyte(state, 0x80, buf, 1); in nxt200x_setup_frontend_parameters()
688 nxt200x_readreg_multibyte(state, 0x08, buf, 1); in nxt200x_setup_frontend_parameters()
690 nxt200x_writereg_multibyte(state, 0x08, buf, 1); in nxt200x_setup_frontend_parameters()
691 nxt200x_readreg_multibyte(state, 0x08, buf, 1); in nxt200x_setup_frontend_parameters()
693 nxt200x_writereg_multibyte(state, 0x08, buf, 1); in nxt200x_setup_frontend_parameters()
695 nxt200x_readreg_multibyte(state, 0x80, buf, 1); in nxt200x_setup_frontend_parameters()
697 nxt200x_writereg_multibyte(state, 0x80, buf, 1); in nxt200x_setup_frontend_parameters()
699 nxt200x_writereg_multibyte(state, 0x81, buf, 1); in nxt200x_setup_frontend_parameters()
701 nxt200x_writereg_multibyte(state, 0x82, buf, 3); in nxt200x_setup_frontend_parameters()
702 nxt200x_readreg_multibyte(state, 0x88, buf, 1); in nxt200x_setup_frontend_parameters()
704 nxt200x_writereg_multibyte(state, 0x88, buf, 1); in nxt200x_setup_frontend_parameters()
705 nxt200x_readreg_multibyte(state, 0x80, buf, 1); in nxt200x_setup_frontend_parameters()
707 nxt200x_writereg_multibyte(state, 0x80, buf, 1); in nxt200x_setup_frontend_parameters()
725 nxt200x_writebytes(state, 0x30, buf, 1); in nxt200x_setup_frontend_parameters()
729 nxt200x_writebytes(state, 0x41, buf, 1); in nxt200x_setup_frontend_parameters()
734 switch (state->demod_chip) { in nxt200x_setup_frontend_parameters()
736 nxt200x_writereg_multibyte(state, 0x49, buf, 2); in nxt200x_setup_frontend_parameters()
737 nxt200x_writereg_multibyte(state, 0x4B, buf, 2); in nxt200x_setup_frontend_parameters()
740 nxt200x_writebytes(state, 0x49, buf, 2); in nxt200x_setup_frontend_parameters()
741 nxt200x_writebytes(state, 0x4B, buf, 2); in nxt200x_setup_frontend_parameters()
750 nxt200x_writebytes(state, 0x41, buf, 1); in nxt200x_setup_frontend_parameters()
752 nxt200x_microcontroller_start(state); in nxt200x_setup_frontend_parameters()
754 if (state->demod_chip == NXT2004) { in nxt200x_setup_frontend_parameters()
755 nxt2004_microcontroller_init(state); in nxt200x_setup_frontend_parameters()
760 nxt200x_writebytes(state, 0x5C, buf, 2); in nxt200x_setup_frontend_parameters()
771 struct nxt200x_state* state = fe->demodulator_priv; in nxt200x_read_status() local
773 nxt200x_readbytes(state, 0x31, &lock, 1); in nxt200x_read_status()
788 struct nxt200x_state* state = fe->demodulator_priv; in nxt200x_read_ber() local
791 nxt200x_readreg_multibyte(state, 0xE6, b, 3); in nxt200x_read_ber()
800 struct nxt200x_state* state = fe->demodulator_priv; in nxt200x_read_signal_strength() local
806 nxt200x_writebytes(state, 0xA1, b, 1); in nxt200x_read_signal_strength()
809 nxt200x_readreg_multibyte(state, 0xA6, b, 2); in nxt200x_read_signal_strength()
820 struct nxt200x_state* state = fe->demodulator_priv; in nxt200x_read_snr() local
827 nxt200x_writebytes(state, 0xA1, b, 1); in nxt200x_read_snr()
830 nxt200x_readreg_multibyte(state, 0xA6, b, 2); in nxt200x_read_snr()
853 struct nxt200x_state* state = fe->demodulator_priv; in nxt200x_read_ucblocks() local
856 nxt200x_readreg_multibyte(state, 0xE6, b, 3); in nxt200x_read_ucblocks()
869 struct nxt200x_state* state = fe->demodulator_priv; in nxt2002_init() local
878 state->i2c->dev.parent); in nxt2002_init()
895 nxt200x_microcontroller_stop(state); in nxt2002_init()
899 nxt200x_writebytes(state, 0x2B, buf, 1); in nxt2002_init()
902 nxt200x_microcontroller_stop(state); in nxt2002_init()
906 nxt200x_writebytes(state, 0x08, buf, 1); in nxt2002_init()
908 nxt200x_writebytes(state, 0x08, buf, 1); in nxt2002_init()
912 nxt200x_writebytes(state, 0x57, buf, 1); in nxt2002_init()
916 nxt200x_writebytes(state, 0x09, buf, 1); in nxt2002_init()
921 nxt200x_writebytes(state, 0xE9, buf, 2); in nxt2002_init()
925 nxt200x_writebytes(state, 0xCC, buf, 1); in nxt2002_init()
932 struct nxt200x_state* state = fe->demodulator_priv; in nxt2004_init() local
939 nxt200x_writebytes(state, 0x1E, buf, 1); in nxt2004_init()
945 state->i2c->dev.parent); in nxt2004_init()
963 nxt200x_writebytes(state, 0x19, buf, 1); in nxt2004_init()
965 nxt2004_microcontroller_init(state); in nxt2004_init()
966 nxt200x_microcontroller_stop(state); in nxt2004_init()
967 nxt200x_microcontroller_stop(state); in nxt2004_init()
968 nxt2004_microcontroller_init(state); in nxt2004_init()
969 nxt200x_microcontroller_stop(state); in nxt2004_init()
973 nxt200x_writereg_multibyte(state, 0x08, buf, 1); in nxt2004_init()
975 nxt200x_writereg_multibyte(state, 0x08, buf, 1); in nxt2004_init()
979 nxt200x_writebytes(state, 0x57, buf, 1); in nxt2004_init()
984 nxt200x_writebytes(state, 0x35, buf, 2); in nxt2004_init()
986 nxt200x_writebytes(state, 0x34, buf, 1); in nxt2004_init()
988 nxt200x_writebytes(state, 0x21, buf, 1); in nxt2004_init()
992 nxt200x_writebytes(state, 0x0A, buf, 1); in nxt2004_init()
996 nxt200x_writereg_multibyte(state, 0x80, buf, 1); in nxt2004_init()
1001 nxt200x_writebytes(state, 0xE9, buf, 2); in nxt2004_init()
1005 nxt200x_writebytes(state, 0xCC, buf, 1); in nxt2004_init()
1008 nxt200x_readreg_multibyte(state, 0x80, buf, 1); in nxt2004_init()
1010 nxt200x_writereg_multibyte(state, 0x80, buf, 1); in nxt2004_init()
1013 nxt200x_readreg_multibyte(state, 0x08, buf, 1); in nxt2004_init()
1015 nxt200x_writereg_multibyte(state, 0x08, buf, 1); in nxt2004_init()
1016 nxt200x_readreg_multibyte(state, 0x08, buf, 1); in nxt2004_init()
1018 nxt200x_writereg_multibyte(state, 0x08, buf, 1); in nxt2004_init()
1021 nxt200x_readreg_multibyte(state, 0x80, buf, 1); in nxt2004_init()
1023 nxt200x_writereg_multibyte(state, 0x80, buf, 1); in nxt2004_init()
1025 nxt200x_writereg_multibyte(state, 0x81, buf, 1); in nxt2004_init()
1027 nxt200x_writereg_multibyte(state, 0x82, buf, 3); in nxt2004_init()
1029 nxt200x_readreg_multibyte(state, 0x88, buf, 1); in nxt2004_init()
1031 nxt200x_writereg_multibyte(state, 0x88, buf, 1); in nxt2004_init()
1032 nxt200x_readreg_multibyte(state, 0x80, buf, 1); in nxt2004_init()
1034 nxt200x_writereg_multibyte(state, 0x80, buf, 1); in nxt2004_init()
1036 nxt200x_readbytes(state, 0x10, buf, 1); in nxt2004_init()
1038 nxt200x_writebytes(state, 0x10, buf, 1); in nxt2004_init()
1039 nxt200x_readbytes(state, 0x0A, buf, 1); in nxt2004_init()
1041 nxt200x_writebytes(state, 0x0A, buf, 1); in nxt2004_init()
1043 nxt2004_microcontroller_init(state); in nxt2004_init()
1046 nxt200x_writebytes(state, 0x0A, buf, 1); in nxt2004_init()
1048 nxt200x_writebytes(state, 0xE9, buf, 1); in nxt2004_init()
1050 nxt200x_writebytes(state, 0xEA, buf, 1); in nxt2004_init()
1052 nxt200x_readreg_multibyte(state, 0x80, buf, 1); in nxt2004_init()
1054 nxt200x_writereg_multibyte(state, 0x80, buf, 1); in nxt2004_init()
1055 nxt200x_readreg_multibyte(state, 0x80, buf, 1); in nxt2004_init()
1057 nxt200x_writereg_multibyte(state, 0x80, buf, 1); in nxt2004_init()
1060 nxt200x_readreg_multibyte(state, 0x08, buf, 1); in nxt2004_init()
1062 nxt200x_writereg_multibyte(state, 0x08, buf, 1); in nxt2004_init()
1063 nxt200x_readreg_multibyte(state, 0x08, buf, 1); in nxt2004_init()
1065 nxt200x_writereg_multibyte(state, 0x08, buf, 1); in nxt2004_init()
1067 nxt200x_readreg_multibyte(state, 0x80, buf, 1); in nxt2004_init()
1069 nxt200x_writereg_multibyte(state, 0x80, buf, 1); in nxt2004_init()
1071 nxt200x_writereg_multibyte(state, 0x81, buf, 1); in nxt2004_init()
1073 nxt200x_writereg_multibyte(state, 0x82, buf, 3); in nxt2004_init()
1075 nxt200x_readreg_multibyte(state, 0x88, buf, 1); in nxt2004_init()
1077 nxt200x_writereg_multibyte(state, 0x88, buf, 1); in nxt2004_init()
1079 nxt200x_readreg_multibyte(state, 0x80, buf, 1); in nxt2004_init()
1081 nxt200x_writereg_multibyte(state, 0x80, buf, 1); in nxt2004_init()
1084 nxt200x_readbytes(state, 0x10, buf, 1); in nxt2004_init()
1086 nxt200x_writebytes(state, 0x10, buf, 1); in nxt2004_init()
1088 nxt200x_writebytes(state, 0x13, buf, 1); in nxt2004_init()
1090 nxt200x_writebytes(state, 0x16, buf, 1); in nxt2004_init()
1092 nxt200x_writebytes(state, 0x14, buf, 1); in nxt2004_init()
1094 nxt200x_writebytes(state, 0x14, buf, 1); in nxt2004_init()
1095 nxt200x_writebytes(state, 0x17, buf, 1); in nxt2004_init()
1096 nxt200x_writebytes(state, 0x14, buf, 1); in nxt2004_init()
1097 nxt200x_writebytes(state, 0x17, buf, 1); in nxt2004_init()
1104 struct nxt200x_state* state = fe->demodulator_priv; in nxt200x_init() local
1107 if (!state->initialised) { in nxt200x_init()
1108 switch (state->demod_chip) { in nxt200x_init()
1119 state->initialised = 1; in nxt200x_init()
1134 struct nxt200x_state* state = fe->demodulator_priv; in nxt200x_release() local
1135 kfree(state); in nxt200x_release()
1143 struct nxt200x_state* state = NULL; in nxt200x_attach() local
1147 state = kzalloc(sizeof(struct nxt200x_state), GFP_KERNEL); in nxt200x_attach()
1148 if (state == NULL) in nxt200x_attach()
1152 state->config = config; in nxt200x_attach()
1153 state->i2c = i2c; in nxt200x_attach()
1154 state->initialised = 0; in nxt200x_attach()
1157 nxt200x_readbytes(state, 0x00, buf, 5); in nxt200x_attach()
1163 state->demod_chip = NXT2002; in nxt200x_attach()
1167 state->demod_chip = NXT2004; in nxt200x_attach()
1175 switch (state->demod_chip) { in nxt200x_attach()
1191 memcpy(&state->frontend.ops, &nxt200x_ops, sizeof(struct dvb_frontend_ops)); in nxt200x_attach()
1192 state->frontend.demodulator_priv = state; in nxt200x_attach()
1193 return &state->frontend; in nxt200x_attach()
1196 kfree(state); in nxt200x_attach()