Lines Matching full:state
57 static int dst_command(struct dst_state *state, u8 *data, u8 len);
59 static void dst_packsize(struct dst_state *state, int psize) in dst_packsize() argument
64 bt878_device_control(state->bt, DST_IG_TS, &bits); in dst_packsize()
67 static int dst_gpio_outb(struct dst_state *state, u32 mask, u32 enbb, in dst_gpio_outb() argument
79 if ((err = bt878_device_control(state->bt, DST_IG_ENABLE, &enb)) < 0) { in dst_gpio_outb()
92 if ((err = bt878_device_control(state->bt, DST_IG_WRITE, &bits)) < 0) { in dst_gpio_outb()
101 static int dst_gpio_inb(struct dst_state *state, u8 *result) in dst_gpio_inb() argument
107 if ((err = bt878_device_control(state->bt, DST_IG_READ, &rd_packet)) < 0) { in dst_gpio_inb()
116 int rdc_reset_state(struct dst_state *state) in rdc_reset_state() argument
118 dprintk(2, "Resetting state machine\n"); in rdc_reset_state()
119 if (dst_gpio_outb(state, RDC_8820_INT, RDC_8820_INT, 0, NO_DELAY) < 0) { in rdc_reset_state()
124 if (dst_gpio_outb(state, RDC_8820_INT, RDC_8820_INT, RDC_8820_INT, NO_DELAY) < 0) { in rdc_reset_state()
134 static int rdc_8820_reset(struct dst_state *state) in rdc_8820_reset() argument
137 if (dst_gpio_outb(state, RDC_8820_RESET, RDC_8820_RESET, 0, NO_DELAY) < 0) { in rdc_8820_reset()
142 if (dst_gpio_outb(state, RDC_8820_RESET, RDC_8820_RESET, RDC_8820_RESET, DELAY) < 0) { in rdc_8820_reset()
150 static int dst_pio_enable(struct dst_state *state) in dst_pio_enable() argument
152 if (dst_gpio_outb(state, ~0, RDC_8820_PIO_0_ENABLE, 0, NO_DELAY) < 0) { in dst_pio_enable()
161 int dst_pio_disable(struct dst_state *state) in dst_pio_disable() argument
163 if (dst_gpio_outb(state, ~0, RDC_8820_PIO_0_DISABLE, RDC_8820_PIO_0_DISABLE, NO_DELAY) < 0) { in dst_pio_disable()
167 if (state->type_flags & DST_TYPE_HAS_FW_1) in dst_pio_disable()
174 int dst_wait_dst_ready(struct dst_state *state, u8 delay_mode) in dst_wait_dst_ready() argument
180 if (dst_gpio_inb(state, &reply) < 0) { in dst_wait_dst_ready()
196 int dst_error_recovery(struct dst_state *state) in dst_error_recovery() argument
199 dst_pio_disable(state); in dst_error_recovery()
201 dst_pio_enable(state); in dst_error_recovery()
208 int dst_error_bailout(struct dst_state *state) in dst_error_bailout() argument
211 rdc_8820_reset(state); in dst_error_bailout()
212 dst_pio_disable(state); in dst_error_bailout()
219 int dst_comm_init(struct dst_state *state) in dst_comm_init() argument
222 if ((dst_pio_enable(state)) < 0) { in dst_comm_init()
226 if ((rdc_reset_state(state)) < 0) { in dst_comm_init()
227 pr_err("RDC 8820 State RESET Failed.\n"); in dst_comm_init()
230 if (state->type_flags & DST_TYPE_HAS_FW_1) in dst_comm_init()
239 int write_dst(struct dst_state *state, u8 *data, u8 len) in write_dst() argument
242 .addr = state->config->demod_address, in write_dst()
254 if ((err = i2c_transfer(state->i2c, &msg, 1)) < 0) { in write_dst()
257 dst_error_recovery(state); in write_dst()
264 dst_error_bailout(state); in write_dst()
273 int read_dst(struct dst_state *state, u8 *ret, u8 len) in read_dst() argument
276 .addr = state->config->demod_address, in read_dst()
286 if ((err = i2c_transfer(state->i2c, &msg, 1)) < 0) { in read_dst()
289 dst_error_recovery(state); in read_dst()
296 dst_error_bailout(state); in read_dst()
306 static int dst_set_polarization(struct dst_state *state) in dst_set_polarization() argument
308 switch (state->voltage) { in dst_set_polarization()
311 state->tx_tuna[8] &= ~0x40; in dst_set_polarization()
315 state->tx_tuna[8] |= 0x40; in dst_set_polarization()
324 static int dst_set_freq(struct dst_state *state, u32 freq) in dst_set_freq() argument
326 state->frequency = freq; in dst_set_freq()
329 if (state->dst_type == DST_TYPE_IS_SAT) { in dst_set_freq()
333 state->tx_tuna[2] = (freq >> 8); in dst_set_freq()
334 state->tx_tuna[3] = (u8) freq; in dst_set_freq()
335 state->tx_tuna[4] = 0x01; in dst_set_freq()
336 state->tx_tuna[8] &= ~0x04; in dst_set_freq()
337 if (state->type_flags & DST_TYPE_HAS_OBS_REGS) { in dst_set_freq()
339 state->tx_tuna[8] |= 0x04; in dst_set_freq()
341 } else if (state->dst_type == DST_TYPE_IS_TERR) { in dst_set_freq()
345 state->tx_tuna[2] = (freq >> 16) & 0xff; in dst_set_freq()
346 state->tx_tuna[3] = (freq >> 8) & 0xff; in dst_set_freq()
347 state->tx_tuna[4] = (u8) freq; in dst_set_freq()
348 } else if (state->dst_type == DST_TYPE_IS_CABLE) { in dst_set_freq()
350 state->tx_tuna[2] = (freq >> 16) & 0xff; in dst_set_freq()
351 state->tx_tuna[3] = (freq >> 8) & 0xff; in dst_set_freq()
352 state->tx_tuna[4] = (u8) freq; in dst_set_freq()
353 } else if (state->dst_type == DST_TYPE_IS_ATSC) { in dst_set_freq()
357 state->tx_tuna[2] = (freq >> 16) & 0xff; in dst_set_freq()
358 state->tx_tuna[3] = (freq >> 8) & 0xff; in dst_set_freq()
359 state->tx_tuna[4] = (u8) freq; in dst_set_freq()
360 state->tx_tuna[5] = 0x00; /* ATSC */ in dst_set_freq()
361 state->tx_tuna[6] = 0x00; in dst_set_freq()
362 if (state->dst_hw_cap & DST_TYPE_HAS_ANALOG) in dst_set_freq()
363 state->tx_tuna[7] = 0x00; /* Digital */ in dst_set_freq()
370 static int dst_set_bandwidth(struct dst_state *state, u32 bandwidth) in dst_set_bandwidth() argument
372 state->bandwidth = bandwidth; in dst_set_bandwidth()
374 if (state->dst_type != DST_TYPE_IS_TERR) in dst_set_bandwidth()
379 if (state->dst_hw_cap & DST_TYPE_HAS_CA) in dst_set_bandwidth()
380 state->tx_tuna[7] = 0x06; in dst_set_bandwidth()
382 state->tx_tuna[6] = 0x06; in dst_set_bandwidth()
383 state->tx_tuna[7] = 0x00; in dst_set_bandwidth()
387 if (state->dst_hw_cap & DST_TYPE_HAS_CA) in dst_set_bandwidth()
388 state->tx_tuna[7] = 0x07; in dst_set_bandwidth()
390 state->tx_tuna[6] = 0x07; in dst_set_bandwidth()
391 state->tx_tuna[7] = 0x00; in dst_set_bandwidth()
395 if (state->dst_hw_cap & DST_TYPE_HAS_CA) in dst_set_bandwidth()
396 state->tx_tuna[7] = 0x08; in dst_set_bandwidth()
398 state->tx_tuna[6] = 0x08; in dst_set_bandwidth()
399 state->tx_tuna[7] = 0x00; in dst_set_bandwidth()
409 static int dst_set_inversion(struct dst_state *state, in dst_set_inversion() argument
412 state->inversion = inversion; in dst_set_inversion()
415 state->tx_tuna[8] &= ~0x80; in dst_set_inversion()
418 state->tx_tuna[8] |= 0x80; in dst_set_inversion()
427 static int dst_set_fec(struct dst_state *state, enum fe_code_rate fec) in dst_set_fec() argument
429 state->fec = fec; in dst_set_fec()
433 static enum fe_code_rate dst_get_fec(struct dst_state *state) in dst_get_fec() argument
435 return state->fec; in dst_get_fec()
438 static int dst_set_symbolrate(struct dst_state *state, u32 srate) in dst_set_symbolrate() argument
443 state->symbol_rate = srate; in dst_set_symbolrate()
444 if (state->dst_type == DST_TYPE_IS_TERR) { in dst_set_symbolrate()
449 if (state->dst_type == DST_TYPE_IS_SAT) { in dst_set_symbolrate()
450 if (state->type_flags & DST_TYPE_HAS_SYMDIV) { in dst_set_symbolrate()
456 state->tx_tuna[5] = (u8) (symcalc >> 12); in dst_set_symbolrate()
457 state->tx_tuna[6] = (u8) (symcalc >> 4); in dst_set_symbolrate()
458 state->tx_tuna[7] = (u8) (symcalc << 4); in dst_set_symbolrate()
460 state->tx_tuna[5] = (u8) (srate >> 16) & 0x7f; in dst_set_symbolrate()
461 state->tx_tuna[6] = (u8) (srate >> 8); in dst_set_symbolrate()
462 state->tx_tuna[7] = (u8) srate; in dst_set_symbolrate()
464 state->tx_tuna[8] &= ~0x20; in dst_set_symbolrate()
465 if (state->type_flags & DST_TYPE_HAS_OBS_REGS) { in dst_set_symbolrate()
467 state->tx_tuna[8] |= 0x20; in dst_set_symbolrate()
469 } else if (state->dst_type == DST_TYPE_IS_CABLE) { in dst_set_symbolrate()
470 dprintk(3, "%s\n", state->fw_name); in dst_set_symbolrate()
471 if (!strncmp(state->fw_name, "DCTNEW", 6)) { in dst_set_symbolrate()
472 state->tx_tuna[5] = (u8) (srate >> 8); in dst_set_symbolrate()
473 state->tx_tuna[6] = (u8) srate; in dst_set_symbolrate()
474 state->tx_tuna[7] = 0x00; in dst_set_symbolrate()
475 } else if (!strncmp(state->fw_name, "DCT-CI", 6)) { in dst_set_symbolrate()
476 state->tx_tuna[5] = 0x00; in dst_set_symbolrate()
477 state->tx_tuna[6] = (u8) (srate >> 8); in dst_set_symbolrate()
478 state->tx_tuna[7] = (u8) srate; in dst_set_symbolrate()
484 static int dst_set_modulation(struct dst_state *state, in dst_set_modulation() argument
487 if (state->dst_type != DST_TYPE_IS_CABLE) in dst_set_modulation()
490 state->modulation = modulation; in dst_set_modulation()
493 state->tx_tuna[8] = 0x10; in dst_set_modulation()
496 state->tx_tuna[8] = 0x20; in dst_set_modulation()
499 state->tx_tuna[8] = 0x40; in dst_set_modulation()
502 state->tx_tuna[8] = 0x80; in dst_set_modulation()
505 if (!strncmp(state->fw_name, "DCTNEW", 6)) in dst_set_modulation()
506 state->tx_tuna[8] = 0xff; in dst_set_modulation()
507 else if (!strncmp(state->fw_name, "DCT-CI", 6)) in dst_set_modulation()
508 state->tx_tuna[8] = 0x00; in dst_set_modulation()
522 static enum fe_modulation dst_get_modulation(struct dst_state *state) in dst_get_modulation() argument
524 return state->modulation; in dst_get_modulation()
541 static void dst_type_flags_print(struct dst_state *state) in dst_type_flags_print() argument
543 u32 type_flags = state->type_flags; in dst_type_flags_print()
566 static int dst_type_print(struct dst_state *state, u8 type) in dst_type_print() argument
893 static int dst_get_mac(struct dst_state *state) in dst_get_mac() argument
897 if (dst_command(state, get_mac, 8) < 0) { in dst_get_mac()
901 memset(&state->mac_address, '\0', 8); in dst_get_mac()
902 memcpy(&state->mac_address, &state->rxbuffer, 6); in dst_get_mac()
903 pr_err("MAC Address=[%pM]\n", state->mac_address); in dst_get_mac()
908 static int dst_fw_ver(struct dst_state *state) in dst_fw_ver() argument
912 if (dst_command(state, get_ver, 8) < 0) { in dst_fw_ver()
916 memcpy(&state->fw_version, &state->rxbuffer, 8); in dst_fw_ver()
918 state->fw_version[0] >> 4, state->fw_version[0] & 0x0f, in dst_fw_ver()
919 state->fw_version[1], in dst_fw_ver()
920 state->fw_version[5], state->fw_version[6], in dst_fw_ver()
921 state->fw_version[4], state->fw_version[3], state->fw_version[2]); in dst_fw_ver()
926 static int dst_card_type(struct dst_state *state) in dst_card_type() argument
933 if (dst_command(state, get_type, 8) < 0) { in dst_card_type()
937 memset(&state->card_info, '\0', 8); in dst_card_type()
938 memcpy(&state->card_info, &state->rxbuffer, 7); in dst_card_type()
939 pr_err("Device Model=[%s]\n", &state->card_info[0]); in dst_card_type()
942 if (!strcmp(&state->card_info[0], p_tuner_list->board_name)) { in dst_card_type()
943 state->tuner_type = p_tuner_list->tuner_type; in dst_card_type()
952 static int dst_get_vendor(struct dst_state *state) in dst_get_vendor() argument
956 if (dst_command(state, get_vendor, 8) < 0) { in dst_get_vendor()
960 memset(&state->vendor, '\0', 8); in dst_get_vendor()
961 memcpy(&state->vendor, &state->rxbuffer, 7); in dst_get_vendor()
962 pr_err("Vendor=[%s]\n", &state->vendor[0]); in dst_get_vendor()
967 static void debug_dst_buffer(struct dst_state *state) in debug_dst_buffer() argument
969 dprintk(3, "%s: [ %*ph ]\n", __func__, 8, state->rxbuffer); in debug_dst_buffer()
972 static int dst_check_stv0299(struct dst_state *state) in dst_check_stv0299() argument
977 if (dst_command(state, check_stv0299, 8) < 0) { in dst_check_stv0299()
981 debug_dst_buffer(state); in dst_check_stv0299()
983 if (memcmp(&check_stv0299, &state->rxbuffer, 8)) { in dst_check_stv0299()
985 state->tuner_type = TUNER_TYPE_STV0299; in dst_check_stv0299()
992 static int dst_check_mb86a15(struct dst_state *state) in dst_check_mb86a15() argument
997 if (dst_command(state, check_mb86a15, 8) < 0) { in dst_check_mb86a15()
1001 debug_dst_buffer(state); in dst_check_mb86a15()
1003 if (memcmp(&check_mb86a15, &state->rxbuffer, 8) < 0) { in dst_check_mb86a15()
1005 state->tuner_type = TUNER_TYPE_MB86A15; in dst_check_mb86a15()
1012 static int dst_get_tuner_info(struct dst_state *state) in dst_get_tuner_info() argument
1020 if (state->type_flags & DST_TYPE_HAS_MULTI_FE) { in dst_get_tuner_info()
1021 if (dst_command(state, get_tuner_1, 8) < 0) { in dst_get_tuner_info()
1026 if (dst_command(state, get_tuner_2, 8) < 0) { in dst_get_tuner_info()
1031 memcpy(&state->board_info, &state->rxbuffer, 8); in dst_get_tuner_info()
1032 if (state->type_flags & DST_TYPE_HAS_MULTI_FE) { in dst_get_tuner_info()
1035 if (state->board_info[0] == 0xbc) { in dst_get_tuner_info()
1036 if (state->dst_type != DST_TYPE_IS_ATSC) in dst_get_tuner_info()
1037 state->type_flags |= DST_TYPE_HAS_TS188; in dst_get_tuner_info()
1039 state->type_flags |= DST_TYPE_HAS_NEWTUNE_2; in dst_get_tuner_info()
1041 if (state->board_info[1] == 0x01) { in dst_get_tuner_info()
1042 state->dst_hw_cap |= DST_TYPE_HAS_DBOARD; in dst_get_tuner_info()
1049 if (!strncmp(state->fw_name, "DCT-CI", 6)) { in dst_get_tuner_info()
1050 state->type_flags |= DST_TYPE_HAS_TS204; in dst_get_tuner_info()
1051 pr_err("Forcing [%s] to TS188\n", state->fw_name); in dst_get_tuner_info()
1057 static int dst_get_device_id(struct dst_state *state) in dst_get_device_id() argument
1070 state->tuner_type = 0; in dst_get_device_id()
1073 if (write_dst(state, device_type, FIXED_COMM)) in dst_get_device_id()
1075 if ((dst_pio_disable(state)) < 0) in dst_get_device_id()
1077 if (read_dst(state, &reply, GET_ACK)) in dst_get_device_id()
1083 if (!dst_wait_dst_ready(state, DEVICE_INIT)) in dst_get_device_id()
1085 if (read_dst(state, state->rxbuffer, FIXED_COMM)) in dst_get_device_id()
1088 dst_pio_disable(state); in dst_get_device_id()
1089 if (state->rxbuffer[7] != dst_check_sum(state->rxbuffer, 7)) { in dst_get_device_id()
1093 state->rxbuffer[7] = '\0'; in dst_get_device_id()
1096 …if (!strncmp (&state->rxbuffer[p_dst_type->offset], p_dst_type->device_id, strlen (p_dst_type->dev… in dst_get_device_id()
1101 state->dst_hw_cap = p_dst_type->dst_feature; in dst_get_device_id()
1103 strncpy(&state->fw_name[0], p_dst_type->device_id, 6); in dst_get_device_id()
1109 if (dst_check_stv0299(state) < 0) { in dst_get_device_id()
1111 state->tuner_type = TUNER_TYPE_MB86A15; in dst_get_device_id()
1117 if (dst_check_mb86a15(state) < 0) in dst_get_device_id()
1121 state->tuner_type = p_dst_type->tuner_type; in dst_get_device_id()
1125 p_tuner_list->tuner_type == state->tuner_type) { in dst_get_device_id()
1135 pr_err("Unable to recognize %s or %s\n", &state->rxbuffer[0], &state->rxbuffer[1]); in dst_get_device_id()
1140 dst_type_print(state, use_dst_type); in dst_get_device_id()
1141 state->type_flags = use_type_flags; in dst_get_device_id()
1142 state->dst_type = use_dst_type; in dst_get_device_id()
1143 dst_type_flags_print(state); in dst_get_device_id()
1148 static int dst_probe(struct dst_state *state) in dst_probe() argument
1150 mutex_init(&state->dst_mutex); in dst_probe()
1152 if ((rdc_8820_reset(state)) < 0) { in dst_probe()
1160 if ((dst_comm_init(state)) < 0) { in dst_probe()
1165 if (dst_get_device_id(state) < 0) { in dst_probe()
1169 if (dst_get_mac(state) < 0) { in dst_probe()
1172 if ((state->type_flags & DST_TYPE_HAS_MULTI_FE) || (state->type_flags & DST_TYPE_HAS_FW_BUILD)) { in dst_probe()
1173 if (dst_get_tuner_info(state) < 0) in dst_probe()
1176 if (state->type_flags & DST_TYPE_HAS_TS204) { in dst_probe()
1177 dst_packsize(state, 204); in dst_probe()
1179 if (state->type_flags & DST_TYPE_HAS_FW_BUILD) { in dst_probe()
1180 if (dst_fw_ver(state) < 0) { in dst_probe()
1184 if (dst_card_type(state) < 0) { in dst_probe()
1188 if (dst_get_vendor(state) < 0) { in dst_probe()
1197 static int dst_command(struct dst_state *state, u8 *data, u8 len) in dst_command() argument
1201 mutex_lock(&state->dst_mutex); in dst_command()
1202 if ((dst_comm_init(state)) < 0) { in dst_command()
1206 if (write_dst(state, data, len)) { in dst_command()
1208 if ((dst_error_recovery(state)) < 0) { in dst_command()
1214 if ((dst_pio_disable(state)) < 0) { in dst_command()
1218 if (state->type_flags & DST_TYPE_HAS_FW_1) in dst_command()
1220 if (read_dst(state, &reply, GET_ACK)) { in dst_command()
1222 if ((dst_error_recovery(state)) < 0) { in dst_command()
1234 if (state->type_flags & DST_TYPE_HAS_FW_1) in dst_command()
1238 if (!dst_wait_dst_ready(state, NO_DELAY)) in dst_command()
1240 if (read_dst(state, state->rxbuffer, FIXED_COMM)) { in dst_command()
1242 if ((dst_error_recovery(state)) < 0) { in dst_command()
1248 if (state->rxbuffer[7] != dst_check_sum(state->rxbuffer, 7)) { in dst_command()
1252 mutex_unlock(&state->dst_mutex); in dst_command()
1256 mutex_unlock(&state->dst_mutex); in dst_command()
1261 static int dst_get_signal(struct dst_state *state) in dst_get_signal() argument
1266 if ((state->diseq_flags & ATTEMPT_TUNE) == 0) { in dst_get_signal()
1267 state->decode_lock = state->decode_strength = state->decode_snr = 0; in dst_get_signal()
1270 if (0 == (state->diseq_flags & HAS_LOCK)) { in dst_get_signal()
1271 state->decode_lock = state->decode_strength = state->decode_snr = 0; in dst_get_signal()
1274 if (time_after_eq(jiffies, state->cur_jiff + (HZ / 5))) { in dst_get_signal()
1275 retval = dst_command(state, get_signal, 8); in dst_get_signal()
1278 if (state->dst_type == DST_TYPE_IS_SAT) { in dst_get_signal()
1279 state->decode_lock = ((state->rxbuffer[6] & 0x10) == 0) ? 1 : 0; in dst_get_signal()
1280 state->decode_strength = state->rxbuffer[5] << 8; in dst_get_signal()
1281 state->decode_snr = state->rxbuffer[2] << 8 | state->rxbuffer[3]; in dst_get_signal()
1282 } else if ((state->dst_type == DST_TYPE_IS_TERR) || (state->dst_type == DST_TYPE_IS_CABLE)) { in dst_get_signal()
1283 state->decode_lock = (state->rxbuffer[1]) ? 1 : 0; in dst_get_signal()
1284 state->decode_strength = state->rxbuffer[4] << 8; in dst_get_signal()
1285 state->decode_snr = state->rxbuffer[3] << 8; in dst_get_signal()
1286 } else if (state->dst_type == DST_TYPE_IS_ATSC) { in dst_get_signal()
1287 state->decode_lock = (state->rxbuffer[6] == 0x00) ? 1 : 0; in dst_get_signal()
1288 state->decode_strength = state->rxbuffer[4] << 8; in dst_get_signal()
1289 state->decode_snr = state->rxbuffer[2] << 8 | state->rxbuffer[3]; in dst_get_signal()
1291 state->cur_jiff = jiffies; in dst_get_signal()
1296 static int dst_tone_power_cmd(struct dst_state *state) in dst_tone_power_cmd() argument
1300 if (state->dst_type != DST_TYPE_IS_SAT) in dst_tone_power_cmd()
1302 paket[4] = state->tx_tuna[4]; in dst_tone_power_cmd()
1303 paket[2] = state->tx_tuna[2]; in dst_tone_power_cmd()
1304 paket[3] = state->tx_tuna[3]; in dst_tone_power_cmd()
1306 return dst_command(state, paket, 8); in dst_tone_power_cmd()
1309 static int dst_get_tuna(struct dst_state *state) in dst_get_tuna() argument
1313 if ((state->diseq_flags & ATTEMPT_TUNE) == 0) in dst_get_tuna()
1315 state->diseq_flags &= ~(HAS_LOCK); in dst_get_tuna()
1316 if (!dst_wait_dst_ready(state, NO_DELAY)) in dst_get_tuna()
1318 if ((state->type_flags & DST_TYPE_HAS_VLF) && in dst_get_tuna()
1319 !(state->dst_type == DST_TYPE_IS_ATSC)) in dst_get_tuna()
1321 retval = read_dst(state, state->rx_tuna, 10); in dst_get_tuna()
1323 retval = read_dst(state, &state->rx_tuna[2], FIXED_COMM); in dst_get_tuna()
1328 if ((state->type_flags & DST_TYPE_HAS_VLF) && in dst_get_tuna()
1329 !(state->dst_type == DST_TYPE_IS_ATSC)) { in dst_get_tuna()
1331 if (state->rx_tuna[9] != dst_check_sum(&state->rx_tuna[0], 9)) { in dst_get_tuna()
1336 if (state->rx_tuna[9] != dst_check_sum(&state->rx_tuna[2], 7)) { in dst_get_tuna()
1341 if (state->rx_tuna[2] == 0 && state->rx_tuna[3] == 0) in dst_get_tuna()
1343 if (state->dst_type == DST_TYPE_IS_SAT) { in dst_get_tuna()
1344 state->decode_freq = ((state->rx_tuna[2] & 0x7f) << 8) + state->rx_tuna[3]; in dst_get_tuna()
1346 …state->decode_freq = ((state->rx_tuna[2] & 0x7f) << 16) + (state->rx_tuna[3] << 8) + state->rx_tun… in dst_get_tuna()
1348 state->decode_freq = state->decode_freq * 1000; in dst_get_tuna()
1349 state->decode_lock = 1; in dst_get_tuna()
1350 state->diseq_flags |= HAS_LOCK; in dst_get_tuna()
1360 struct dst_state *state = fe->demodulator_priv; in dst_write_tuna() local
1364 dprintk(2, "type_flags 0x%x\n", state->type_flags); in dst_write_tuna()
1365 state->decode_freq = 0; in dst_write_tuna()
1366 state->decode_lock = state->decode_strength = state->decode_snr = 0; in dst_write_tuna()
1367 if (state->dst_type == DST_TYPE_IS_SAT) { in dst_write_tuna()
1368 if (!(state->diseq_flags & HAS_POWER)) in dst_write_tuna()
1371 state->diseq_flags &= ~(HAS_LOCK | ATTEMPT_TUNE); in dst_write_tuna()
1372 mutex_lock(&state->dst_mutex); in dst_write_tuna()
1373 if ((dst_comm_init(state)) < 0) { in dst_write_tuna()
1377 // if (state->type_flags & DST_TYPE_HAS_NEWTUNE) { in dst_write_tuna()
1378 if ((state->type_flags & DST_TYPE_HAS_VLF) && in dst_write_tuna()
1379 (!(state->dst_type == DST_TYPE_IS_ATSC))) { in dst_write_tuna()
1381 state->tx_tuna[9] = dst_check_sum(&state->tx_tuna[0], 9); in dst_write_tuna()
1382 retval = write_dst(state, &state->tx_tuna[0], 10); in dst_write_tuna()
1384 state->tx_tuna[9] = dst_check_sum(&state->tx_tuna[2], 7); in dst_write_tuna()
1385 retval = write_dst(state, &state->tx_tuna[2], FIXED_COMM); in dst_write_tuna()
1388 dst_pio_disable(state); in dst_write_tuna()
1392 if ((dst_pio_disable(state)) < 0) { in dst_write_tuna()
1396 if ((read_dst(state, &reply, GET_ACK) < 0)) { in dst_write_tuna()
1404 state->diseq_flags |= ATTEMPT_TUNE; in dst_write_tuna()
1405 retval = dst_get_tuna(state); in dst_write_tuna()
1407 mutex_unlock(&state->dst_mutex); in dst_write_tuna()
1411 mutex_unlock(&state->dst_mutex); in dst_write_tuna()
1431 struct dst_state *state = fe->demodulator_priv; in dst_set_diseqc() local
1434 if (state->dst_type != DST_TYPE_IS_SAT) in dst_set_diseqc()
1438 else if (cmd->msg_len == 5 && state->dst_hw_cap & DST_TYPE_HAS_DISEQC5) in dst_set_diseqc()
1443 return dst_command(state, paket, 8); in dst_set_diseqc()
1449 struct dst_state *state = fe->demodulator_priv; in dst_set_voltage() local
1451 state->voltage = voltage; in dst_set_voltage()
1452 if (state->dst_type != DST_TYPE_IS_SAT) in dst_set_voltage()
1460 if ((state->diseq_flags & HAS_POWER) == 0) in dst_set_voltage()
1462 state->diseq_flags |= HAS_POWER; in dst_set_voltage()
1463 state->tx_tuna[4] = 0x01; in dst_set_voltage()
1467 state->diseq_flags &= ~(HAS_POWER | HAS_LOCK | ATTEMPT_TUNE); in dst_set_voltage()
1468 state->tx_tuna[4] = 0x00; in dst_set_voltage()
1475 retval = dst_tone_power_cmd(state); in dst_set_voltage()
1482 struct dst_state *state = fe->demodulator_priv; in dst_set_tone() local
1484 state->tone = tone; in dst_set_tone()
1485 if (state->dst_type != DST_TYPE_IS_SAT) in dst_set_tone()
1490 if (state->type_flags & DST_TYPE_HAS_OBS_REGS) in dst_set_tone()
1491 state->tx_tuna[2] = 0x00; in dst_set_tone()
1493 state->tx_tuna[2] = 0xff; in dst_set_tone()
1497 state->tx_tuna[2] = 0x02; in dst_set_tone()
1502 return dst_tone_power_cmd(state); in dst_set_tone()
1507 struct dst_state *state = fe->demodulator_priv; in dst_send_burst() local
1509 if (state->dst_type != DST_TYPE_IS_SAT) in dst_send_burst()
1511 state->minicmd = minicmd; in dst_send_burst()
1514 state->tx_tuna[3] = 0x02; in dst_send_burst()
1517 state->tx_tuna[3] = 0xff; in dst_send_burst()
1520 return dst_tone_power_cmd(state); in dst_send_burst()
1526 struct dst_state *state = fe->demodulator_priv; in bt8xx_dst_init() local
1536 state->inversion = INVERSION_OFF; in bt8xx_dst_init()
1537 state->voltage = SEC_VOLTAGE_13; in bt8xx_dst_init()
1538 state->tone = SEC_TONE_OFF; in bt8xx_dst_init()
1539 state->diseq_flags = 0; in bt8xx_dst_init()
1540 state->k22 = 0x02; in bt8xx_dst_init()
1541 state->bandwidth = 7000000; in bt8xx_dst_init()
1542 state->cur_jiff = jiffies; in bt8xx_dst_init()
1543 if (state->dst_type == DST_TYPE_IS_SAT) in bt8xx_dst_init()
1544 …memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_VLF) ? sat_tuna_188 : sat_tuna_204), siz… in bt8xx_dst_init()
1545 else if (state->dst_type == DST_TYPE_IS_TERR) in bt8xx_dst_init()
1546 …memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_VLF) ? ter_tuna_188 : ter_tuna_204), siz… in bt8xx_dst_init()
1547 else if (state->dst_type == DST_TYPE_IS_CABLE) in bt8xx_dst_init()
1548 …memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_VLF) ? cab_tuna_188 : cab_tuna_204), siz… in bt8xx_dst_init()
1549 else if (state->dst_type == DST_TYPE_IS_ATSC) in bt8xx_dst_init()
1550 memcpy(state->tx_tuna, atsc_tuner, sizeof (atsc_tuner)); in bt8xx_dst_init()
1557 struct dst_state *state = fe->demodulator_priv; in dst_read_status() local
1560 if (state->diseq_flags & HAS_LOCK) { in dst_read_status()
1561 // dst_get_signal(state); // don't require(?) to ask MCU in dst_read_status()
1562 if (state->decode_lock) in dst_read_status()
1571 struct dst_state *state = fe->demodulator_priv; in dst_read_signal_strength() local
1573 int retval = dst_get_signal(state); in dst_read_signal_strength()
1574 *strength = state->decode_strength; in dst_read_signal_strength()
1581 struct dst_state *state = fe->demodulator_priv; in dst_read_snr() local
1583 int retval = dst_get_signal(state); in dst_read_snr()
1584 *snr = state->decode_snr; in dst_read_snr()
1593 struct dst_state *state = fe->demodulator_priv; in dst_set_frontend() local
1596 retval = dst_set_freq(state, p->frequency); in dst_set_frontend()
1601 if (state->dst_type == DST_TYPE_IS_SAT) { in dst_set_frontend()
1602 if (state->type_flags & DST_TYPE_HAS_OBS_REGS) in dst_set_frontend()
1603 dst_set_inversion(state, p->inversion); in dst_set_frontend()
1604 dst_set_fec(state, p->fec_inner); in dst_set_frontend()
1605 dst_set_symbolrate(state, p->symbol_rate); in dst_set_frontend()
1606 dst_set_polarization(state); in dst_set_frontend()
1609 } else if (state->dst_type == DST_TYPE_IS_TERR) in dst_set_frontend()
1610 dst_set_bandwidth(state, p->bandwidth_hz); in dst_set_frontend()
1611 else if (state->dst_type == DST_TYPE_IS_CABLE) { in dst_set_frontend()
1612 dst_set_fec(state, p->fec_inner); in dst_set_frontend()
1613 dst_set_symbolrate(state, p->symbol_rate); in dst_set_frontend()
1614 dst_set_modulation(state, p->modulation); in dst_set_frontend()
1628 struct dst_state *state = fe->demodulator_priv; in dst_tune_frontend() local
1632 dst_set_freq(state, p->frequency); in dst_tune_frontend()
1635 if (state->dst_type == DST_TYPE_IS_SAT) { in dst_tune_frontend()
1636 if (state->type_flags & DST_TYPE_HAS_OBS_REGS) in dst_tune_frontend()
1637 dst_set_inversion(state, p->inversion); in dst_tune_frontend()
1638 dst_set_fec(state, p->fec_inner); in dst_tune_frontend()
1639 dst_set_symbolrate(state, p->symbol_rate); in dst_tune_frontend()
1640 dst_set_polarization(state); in dst_tune_frontend()
1643 } else if (state->dst_type == DST_TYPE_IS_TERR) in dst_tune_frontend()
1644 dst_set_bandwidth(state, p->bandwidth_hz); in dst_tune_frontend()
1645 else if (state->dst_type == DST_TYPE_IS_CABLE) { in dst_tune_frontend()
1646 dst_set_fec(state, p->fec_inner); in dst_tune_frontend()
1647 dst_set_symbolrate(state, p->symbol_rate); in dst_tune_frontend()
1648 dst_set_modulation(state, p->modulation); in dst_tune_frontend()
1668 struct dst_state *state = fe->demodulator_priv; in dst_get_frontend() local
1670 p->frequency = state->decode_freq; in dst_get_frontend()
1671 if (state->dst_type == DST_TYPE_IS_SAT) { in dst_get_frontend()
1672 if (state->type_flags & DST_TYPE_HAS_OBS_REGS) in dst_get_frontend()
1673 p->inversion = state->inversion; in dst_get_frontend()
1674 p->symbol_rate = state->symbol_rate; in dst_get_frontend()
1675 p->fec_inner = dst_get_fec(state); in dst_get_frontend()
1676 } else if (state->dst_type == DST_TYPE_IS_TERR) { in dst_get_frontend()
1677 p->bandwidth_hz = state->bandwidth; in dst_get_frontend()
1678 } else if (state->dst_type == DST_TYPE_IS_CABLE) { in dst_get_frontend()
1679 p->symbol_rate = state->symbol_rate; in dst_get_frontend()
1680 p->fec_inner = dst_get_fec(state); in dst_get_frontend()
1681 p->modulation = dst_get_modulation(state); in dst_get_frontend()
1689 struct dst_state *state = fe->demodulator_priv; in bt8xx_dst_release() local
1690 if (state->dst_ca) { in bt8xx_dst_release()
1691 dvb_unregister_device(state->dst_ca); in bt8xx_dst_release()
1696 kfree(state); in bt8xx_dst_release()
1704 struct dst_state *dst_attach(struct dst_state *state, struct dvb_adapter *dvb_adapter) in dst_attach() argument
1707 if (dst_probe(state) < 0) { in dst_attach()
1708 kfree(state); in dst_attach()
1713 switch (state->dst_type) { in dst_attach()
1715 memcpy(&state->frontend.ops, &dst_dvbt_ops, sizeof(struct dvb_frontend_ops)); in dst_attach()
1718 memcpy(&state->frontend.ops, &dst_dvbc_ops, sizeof(struct dvb_frontend_ops)); in dst_attach()
1721 memcpy(&state->frontend.ops, &dst_dvbs_ops, sizeof(struct dvb_frontend_ops)); in dst_attach()
1724 memcpy(&state->frontend.ops, &dst_atsc_ops, sizeof(struct dvb_frontend_ops)); in dst_attach()
1728 kfree(state); in dst_attach()
1731 state->frontend.demodulator_priv = state; in dst_attach()
1733 return state; /* Manu (DST is a card not a frontend) */ in dst_attach()