Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

V4L/DVB (13818): Add Prof 7500 DVB-S2 USB card

The card based on stv0903 demod, stb6100 tuner.

Signed-off-by: Igor M. Liplianin <liplianin@me.by>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

authored by

Igor M. Liplianin and committed by
Mauro Carvalho Chehab
cd79d33e d41592a2

+226 -18
+84 -10
drivers/media/dvb/dvb-usb/dw2102.c
··· 1 1 /* DVB USB framework compliant Linux driver for the 2 2 * DVBWorld DVB-S 2101, 2102, DVB-S2 2104, DVB-C 3101, 3 - * TeVii S600, S630, S650 Cards 3 + * TeVii S600, S630, S650, 4 + * Prof 1100, 7500 Cards 4 5 * Copyright (C) 2008,2009 Igor M. Liplianin (liplianin@me.by) 5 6 * 6 7 * This program is free software; you can redistribute it and/or modify it ··· 470 469 int num) 471 470 { 472 471 struct dvb_usb_device *d = i2c_get_adapdata(adap); 472 + struct usb_device *udev = d->udev; 473 473 int ret = 0; 474 474 int len, i, j; 475 475 ··· 490 488 } 491 489 case (DW2102_VOLTAGE_CTRL): { 492 490 u8 obuf[2]; 491 + 492 + obuf[0] = 1; 493 + obuf[1] = msg[j].buf[1];/* off-on */ 494 + ret = dw210x_op_rw(d->udev, 0x8a, 0, 0, 495 + obuf, 2, DW210X_WRITE_MSG); 493 496 obuf[0] = 3; 494 - obuf[1] = msg[j].buf[0]; 497 + obuf[1] = msg[j].buf[0];/* 13v-18v */ 495 498 ret = dw210x_op_rw(d->udev, 0x8a, 0, 0, 496 499 obuf, 2, DW210X_WRITE_MSG); 497 500 break; ··· 534 527 i += 16; 535 528 len -= 16; 536 529 } while (len > 0); 530 + } else if ((udev->descriptor.idProduct == 0x7500) 531 + && (j < (num - 1))) { 532 + /* write register addr before read */ 533 + u8 obuf[msg[j].len + 2]; 534 + obuf[0] = msg[j + 1].len; 535 + obuf[1] = (msg[j].addr << 1); 536 + memcpy(obuf + 2, msg[j].buf, msg[j].len); 537 + ret = dw210x_op_rw(d->udev, 0x92, 0, 0, 538 + obuf, msg[j].len + 2, 539 + DW210X_WRITE_MSG); 540 + break; 537 541 } else { 538 542 /* write registers */ 539 543 u8 obuf[msg[j].len + 2]; ··· 669 651 670 652 static int dw210x_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage) 671 653 { 672 - static u8 command_13v[1] = {0x00}; 673 - static u8 command_18v[1] = {0x01}; 674 - struct i2c_msg msg[] = { 675 - {.addr = DW2102_VOLTAGE_CTRL, .flags = 0, 676 - .buf = command_13v, .len = 1}, 654 + static u8 command_13v[] = {0x00, 0x01}; 655 + static u8 command_18v[] = {0x01, 0x01}; 656 + static u8 command_off[] = {0x00, 0x00}; 657 + struct i2c_msg msg = { 658 + .addr = DW2102_VOLTAGE_CTRL, 659 + .flags = 0, 660 + .buf = command_off, 661 + .len = 2, 677 662 }; 678 663 679 664 struct dvb_usb_adapter *udev_adap = 680 665 (struct dvb_usb_adapter *)(fe->dvb->priv); 681 666 if (voltage == SEC_VOLTAGE_18) 682 - msg[0].buf = command_18v; 683 - i2c_transfer(&udev_adap->dev->i2c_adap, msg, 1); 667 + msg.buf = command_18v; 668 + else if (voltage == SEC_VOLTAGE_13) 669 + msg.buf = command_13v; 670 + 671 + i2c_transfer(&udev_adap->dev->i2c_adap, &msg, 1); 672 + 684 673 return 0; 685 674 } 686 675 ··· 758 733 .i2c_address = 0x60, 759 734 .mclk = 16000000, 760 735 .clk_div = 1, 736 + }; 737 + 738 + static struct stv0900_config prof_7500_stv0900_config = { 739 + .demod_address = 0x6a, 740 + .demod_mode = 0, 741 + .xtal = 27000000, 742 + .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */ 743 + .diseqc_mode = 2,/* 2/3 PWM */ 744 + .tun1_maddress = 0,/* 0x60 */ 745 + .tun1_adc = 0,/* 2 Vpp */ 746 + .path1_mode = 3, 747 + .tun1_type = 3, 761 748 }; 762 749 763 750 static int dw2104_frontend_attach(struct dvb_usb_adapter *d) ··· 917 880 } 918 881 919 882 return -EIO; 883 + } 884 + 885 + static int prof_7500_frontend_attach(struct dvb_usb_adapter *d) 886 + { 887 + d->fe = dvb_attach(stv0900_attach, &prof_7500_stv0900_config, 888 + &d->dev->i2c_adap, 0); 889 + if (d->fe == NULL) 890 + return -EIO; 891 + d->fe->ops.set_voltage = dw210x_set_voltage; 892 + 893 + info("Attached STV0900+STB6100A!\n"); 894 + 895 + return 0; 920 896 } 921 897 922 898 static int dw2102_tuner_attach(struct dvb_usb_adapter *adap) ··· 1123 1073 {USB_DEVICE(0x9022, USB_PID_TEVII_S630)}, 1124 1074 {USB_DEVICE(0x3011, USB_PID_PROF_1100)}, 1125 1075 {USB_DEVICE(0x9022, USB_PID_TEVII_S660)}, 1076 + {USB_DEVICE(0x3034, 0x7500)}, 1126 1077 { } 1127 1078 }; 1128 1079 ··· 1438 1387 } 1439 1388 }; 1440 1389 1390 + struct dvb_usb_device_properties *p7500; 1391 + static struct dvb_usb_device_description d7500 = { 1392 + "Prof 7500 USB DVB-S2", 1393 + {&dw2102_table[9], NULL}, 1394 + {NULL}, 1395 + }; 1396 + 1441 1397 static int dw2102_probe(struct usb_interface *intf, 1442 1398 const struct usb_device_id *id) 1443 1399 { 1400 + 1401 + p7500 = kzalloc(sizeof(struct dvb_usb_device_properties), GFP_KERNEL); 1402 + if (!p7500) 1403 + return -ENOMEM; 1404 + /* copy default structure */ 1405 + memcpy(p7500, &s6x0_properties, 1406 + sizeof(struct dvb_usb_device_properties)); 1407 + /* fill only different fields */ 1408 + p7500->firmware = "dvb-usb-p7500.fw"; 1409 + p7500->devices[0] = d7500; 1410 + p7500->rc_key_map = tbs_rc_keys; 1411 + p7500->rc_key_map_size = ARRAY_SIZE(tbs_rc_keys); 1412 + p7500->adapter->frontend_attach = prof_7500_frontend_attach; 1413 + 1444 1414 if (0 == dvb_usb_device_init(intf, &dw2102_properties, 1445 1415 THIS_MODULE, NULL, adapter_nr) || 1446 1416 0 == dvb_usb_device_init(intf, &dw2104_properties, ··· 1469 1397 0 == dvb_usb_device_init(intf, &dw3101_properties, 1470 1398 THIS_MODULE, NULL, adapter_nr) || 1471 1399 0 == dvb_usb_device_init(intf, &s6x0_properties, 1400 + THIS_MODULE, NULL, adapter_nr) || 1401 + 0 == dvb_usb_device_init(intf, p7500, 1472 1402 THIS_MODULE, NULL, adapter_nr)) 1473 1403 return 0; 1474 1404 ··· 1505 1431 MODULE_DESCRIPTION("Driver for DVBWorld DVB-S 2101, 2102, DVB-S2 2104," 1506 1432 " DVB-C 3101 USB2.0," 1507 1433 " TeVii S600, S630, S650, S660 USB2.0," 1508 - " Prof 1100 USB2.0 devices"); 1434 + " Prof 1100, 7500 USB2.0 devices"); 1509 1435 MODULE_VERSION("0.1"); 1510 1436 MODULE_LICENSE("GPL");
+2
drivers/media/dvb/frontends/stv0900.h
··· 49 49 u8 tun2_maddress; 50 50 u8 tun1_adc;/* 1 for stv6110, 2 for stb6100 */ 51 51 u8 tun2_adc; 52 + u8 tun1_type;/* for now 3 for stb6100 auto, else - software */ 53 + u8 tun2_type; 52 54 /* Set device param to start dma */ 53 55 int (*set_ts_params)(struct dvb_frontend *fe, int is_punctured); 54 56 };
+86 -1
drivers/media/dvb/frontends/stv0900_core.c
··· 567 567 } 568 568 } 569 569 570 + u32 stv0900_get_freq_auto(struct stv0900_internal *intp, int demod) 571 + { 572 + u32 freq, round; 573 + /* Formulat : 574 + Tuner_Frequency(MHz) = Regs / 64 575 + Tuner_granularity(MHz) = Regs / 2048 576 + real_Tuner_Frequency = Tuner_Frequency(MHz) - Tuner_granularity(MHz) 577 + */ 578 + freq = (stv0900_get_bits(intp, TUN_RFFREQ2) << 10) + 579 + (stv0900_get_bits(intp, TUN_RFFREQ1) << 2) + 580 + stv0900_get_bits(intp, TUN_RFFREQ0); 581 + 582 + freq = (freq * 1000) / 64; 583 + 584 + round = (stv0900_get_bits(intp, TUN_RFRESTE1) >> 2) + 585 + stv0900_get_bits(intp, TUN_RFRESTE0); 586 + 587 + round = (round * 1000) / 2048; 588 + 589 + return freq + round; 590 + } 591 + 592 + void stv0900_set_tuner_auto(struct stv0900_internal *intp, u32 Frequency, 593 + u32 Bandwidth, int demod) 594 + { 595 + u32 tunerFrequency; 596 + /* Formulat: 597 + Tuner_frequency_reg= Frequency(MHz)*64 598 + */ 599 + tunerFrequency = (Frequency * 64) / 1000; 600 + 601 + stv0900_write_bits(intp, TUN_RFFREQ2, (tunerFrequency >> 10)); 602 + stv0900_write_bits(intp, TUN_RFFREQ1, (tunerFrequency >> 2) & 0xff); 603 + stv0900_write_bits(intp, TUN_RFFREQ0, (tunerFrequency & 0x03)); 604 + /* Low Pass Filter = BW /2 (MHz)*/ 605 + stv0900_write_bits(intp, TUN_BW, Bandwidth / 2000000); 606 + /* Tuner Write trig */ 607 + stv0900_write_reg(intp, TNRLD, 1); 608 + } 609 + 570 610 static s32 stv0900_get_rf_level(struct stv0900_internal *intp, 571 611 const struct stv0900_table *lookup, 572 612 enum fe_stv0900_demod_num demod) ··· 1369 1329 enum fe_stv0900_error error = STV0900_NO_ERROR; 1370 1330 enum fe_stv0900_error demodError = STV0900_NO_ERROR; 1371 1331 struct stv0900_internal *intp = NULL; 1372 - 1373 1332 int selosci, i; 1374 1333 1375 1334 struct stv0900_inode *temp_int = find_inode(state->i2c_adap, ··· 1443 1404 stv0900_write_bits(intp, F0900_P1_RST_HWARE, 0); 1444 1405 } 1445 1406 1407 + intp->tuner_type[0] = p_init->tuner1_type; 1408 + intp->tuner_type[1] = p_init->tuner2_type; 1409 + /* tuner init */ 1410 + switch (p_init->tuner1_type) { 1411 + case 3: /*FE_AUTO_STB6100:*/ 1412 + stv0900_write_reg(intp, R0900_P1_TNRCFG, 0x3c); 1413 + stv0900_write_reg(intp, R0900_P1_TNRCFG2, 0x86); 1414 + stv0900_write_reg(intp, R0900_P1_TNRCFG3, 0x18); 1415 + stv0900_write_reg(intp, R0900_P1_TNRXTAL, 27); /* 27MHz */ 1416 + stv0900_write_reg(intp, R0900_P1_TNRSTEPS, 0x05); 1417 + stv0900_write_reg(intp, R0900_P1_TNRGAIN, 0x17); 1418 + stv0900_write_reg(intp, R0900_P1_TNRADJ, 0x1f); 1419 + stv0900_write_reg(intp, R0900_P1_TNRCTL2, 0x0); 1420 + stv0900_write_bits(intp, F0900_P1_TUN_TYPE, 3); 1421 + break; 1422 + /* case FE_SW_TUNER: */ 1423 + default: 1424 + stv0900_write_bits(intp, F0900_P1_TUN_TYPE, 6); 1425 + break; 1426 + } 1427 + 1446 1428 stv0900_write_bits(intp, F0900_P1_TUN_MADDRESS, p_init->tun1_maddress); 1447 1429 switch (p_init->tuner1_adc) { 1448 1430 case 1: 1449 1431 stv0900_write_reg(intp, R0900_TSTTNR1, 0x26); 1450 1432 break; 1451 1433 default: 1434 + break; 1435 + } 1436 + 1437 + stv0900_write_reg(intp, R0900_P1_TNRLD, 1); /* hw tuner */ 1438 + 1439 + /* tuner init */ 1440 + switch (p_init->tuner2_type) { 1441 + case 3: /*FE_AUTO_STB6100:*/ 1442 + stv0900_write_reg(intp, R0900_P2_TNRCFG, 0x3c); 1443 + stv0900_write_reg(intp, R0900_P2_TNRCFG2, 0x86); 1444 + stv0900_write_reg(intp, R0900_P2_TNRCFG3, 0x18); 1445 + stv0900_write_reg(intp, R0900_P2_TNRXTAL, 27); /* 27MHz */ 1446 + stv0900_write_reg(intp, R0900_P2_TNRSTEPS, 0x05); 1447 + stv0900_write_reg(intp, R0900_P2_TNRGAIN, 0x17); 1448 + stv0900_write_reg(intp, R0900_P2_TNRADJ, 0x1f); 1449 + stv0900_write_reg(intp, R0900_P2_TNRCTL2, 0x0); 1450 + stv0900_write_bits(intp, F0900_P2_TUN_TYPE, 3); 1451 + break; 1452 + /* case FE_SW_TUNER: */ 1453 + default: 1454 + stv0900_write_bits(intp, F0900_P2_TUN_TYPE, 6); 1452 1455 break; 1453 1456 } 1454 1457 ··· 1502 1421 default: 1503 1422 break; 1504 1423 } 1424 + 1425 + stv0900_write_reg(intp, R0900_P2_TNRLD, 1); /* hw tuner */ 1505 1426 1506 1427 stv0900_write_bits(intp, F0900_P1_TUN_IQSWAP, p_init->tun1_iq_inv); 1507 1428 stv0900_write_bits(intp, F0900_P2_TUN_IQSWAP, p_init->tun2_iq_inv); ··· 1907 1824 init_params.tun1_maddress = config->tun1_maddress; 1908 1825 init_params.tun1_iq_inv = STV0900_IQ_NORMAL; 1909 1826 init_params.tuner1_adc = config->tun1_adc; 1827 + init_params.tuner1_type = config->tun1_type; 1910 1828 init_params.path2_ts_clock = config->path2_mode; 1911 1829 init_params.ts_config = config->ts_config_regs; 1912 1830 init_params.tun2_maddress = config->tun2_maddress; 1913 1831 init_params.tuner2_adc = config->tun2_adc; 1832 + init_params.tuner2_type = config->tun2_type; 1914 1833 init_params.tun2_iq_inv = STV0900_IQ_SWAPPED; 1915 1834 1916 1835 err_stv0900 = stv0900_init_internal(&state->frontend,
+11
drivers/media/dvb/frontends/stv0900_priv.h
··· 247 247 248 248 u8 tun1_maddress; 249 249 int tuner1_adc; 250 + int tuner1_type; 250 251 251 252 /* IQ from the tuner1 to the demod */ 252 253 enum stv0900_iq_inversion tun1_iq_inv; ··· 255 254 256 255 u8 tun2_maddress; 257 256 int tuner2_adc; 257 + int tuner2_type; 258 258 259 259 /* IQ from the tuner2 to the demod */ 260 260 enum stv0900_iq_inversion tun2_iq_inv; ··· 311 309 s32 bw[2]; 312 310 s32 symbol_rate[2]; 313 311 s32 srch_range[2]; 312 + /* for software/auto tuner */ 313 + int tuner_type[2]; 314 314 315 315 /* algorithm for search Blind, Cold or Warm*/ 316 316 enum fe_stv0900_search_algo srch_algo[2]; ··· 397 393 extern enum 398 394 fe_stv0900_tracking_standard stv0900_get_standard(struct dvb_frontend *fe, 399 395 enum fe_stv0900_demod_num demod); 396 + 397 + extern u32 398 + stv0900_get_freq_auto(struct stv0900_internal *intp, int demod); 399 + 400 + extern void 401 + stv0900_set_tuner_auto(struct stv0900_internal *intp, u32 Frequency, 402 + u32 Bandwidth, int demod); 400 403 401 404 #endif
+6
drivers/media/dvb/frontends/stv0900_reg.h
··· 3174 3174 #define R0900_P1_TNRRF1 0xf4e9 3175 3175 #define TNRRF1 REGx(R0900_P1_TNRRF1) 3176 3176 #define F0900_P1_TUN_RFFREQ2 0xf4e900ff 3177 + #define TUN_RFFREQ2 FLDx(F0900_P1_TUN_RFFREQ2) 3177 3178 3178 3179 /*P1_TNRRF0*/ 3179 3180 #define R0900_P1_TNRRF0 0xf4ea 3180 3181 #define TNRRF0 REGx(R0900_P1_TNRRF0) 3181 3182 #define F0900_P1_TUN_RFFREQ1 0xf4ea00ff 3183 + #define TUN_RFFREQ1 FLDx(F0900_P1_TUN_RFFREQ1) 3182 3184 3183 3185 /*P1_TNRBW*/ 3184 3186 #define R0900_P1_TNRBW 0xf4eb 3185 3187 #define TNRBW REGx(R0900_P1_TNRBW) 3186 3188 #define F0900_P1_TUN_RFFREQ0 0xf4eb00c0 3189 + #define TUN_RFFREQ0 FLDx(F0900_P1_TUN_RFFREQ0) 3187 3190 #define F0900_P1_TUN_BW 0xf4eb003f 3191 + #define TUN_BW FLDx(F0900_P1_TUN_BW) 3188 3192 3189 3193 /*P1_TNRADJ*/ 3190 3194 #define R0900_P1_TNRADJ 0xf4ec ··· 3238 3234 #define F0900_P1_TUN_I2CLOCKED 0xf4f60010 3239 3235 #define F0900_P1_TUN_PROGDONE 0xf4f6000c 3240 3236 #define F0900_P1_TUN_RFRESTE1 0xf4f60003 3237 + #define TUN_RFRESTE1 FLDx(F0900_P1_TUN_RFRESTE1) 3241 3238 3242 3239 /*P1_TNRRESTE*/ 3243 3240 #define R0900_P1_TNRRESTE 0xf4f7 3244 3241 #define TNRRESTE REGx(R0900_P1_TNRRESTE) 3245 3242 #define F0900_P1_TUN_RFRESTE0 0xf4f700ff 3243 + #define TUN_RFRESTE0 FLDx(F0900_P1_TUN_RFRESTE0) 3246 3244 3247 3245 /*P1_SMAPCOEF7*/ 3248 3246 #define R0900_P1_SMAPCOEF7 0xf500
+37 -7
drivers/media/dvb/frontends/stv0900_sw.c
··· 606 606 tuner_freq -= (current_step * currier_step); 607 607 608 608 if (intp->chip_id <= 0x20) { 609 - stv0900_set_tuner(fe, tuner_freq, intp->bw[d]); 609 + if (intp->tuner_type[d] == 3) 610 + stv0900_set_tuner_auto(intp, tuner_freq, 611 + intp->bw[d], demod); 612 + else 613 + stv0900_set_tuner(fe, tuner_freq, intp->bw[d]); 614 + 610 615 stv0900_write_reg(intp, DMDISTATE, 0x1c); 611 616 stv0900_write_reg(intp, CFRINIT1, 0); 612 617 stv0900_write_reg(intp, CFRINIT0, 0); ··· 981 976 intp->rolloff) + 10000000; 982 977 983 978 if ((intp->chip_id >= 0x20) || (blind_tun_sw == 1)) { 984 - if (intp->srch_algo[demod] != STV0900_WARM_START) 985 - stv0900_set_bandwidth(fe, intp->bw[demod]); 979 + if (intp->srch_algo[demod] != STV0900_WARM_START) { 980 + if (intp->tuner_type[demod] == 3) 981 + stv0900_set_tuner_auto(intp, 982 + intp->freq[demod], 983 + intp->bw[demod], 984 + demod); 985 + else 986 + stv0900_set_bandwidth(fe, 987 + intp->bw[demod]); 988 + } 986 989 } 987 990 988 991 if ((intp->srch_algo[demod] == STV0900_BLIND_SEARCH) || ··· 1215 1202 } 1216 1203 1217 1204 result->standard = stv0900_get_standard(fe, d); 1218 - result->frequency = stv0900_get_tuner_freq(fe); 1205 + if (intp->tuner_type[demod] == 3) 1206 + result->frequency = stv0900_get_freq_auto(intp, d); 1207 + else 1208 + result->frequency = stv0900_get_tuner_freq(fe); 1209 + 1219 1210 offsetFreq = stv0900_get_carr_freq(intp, intp->mclk, d) / 1000; 1220 1211 result->frequency += offsetFreq; 1221 1212 result->symbol_rate = stv0900_get_symbol_rate(intp, intp->mclk, d); ··· 1256 1239 if ((intp->srch_algo[d] == STV0900_BLIND_SEARCH) || 1257 1240 (intp->symbol_rate[d] < 10000000)) { 1258 1241 offsetFreq = result->frequency - intp->freq[d]; 1259 - intp->freq[d] = stv0900_get_tuner_freq(fe); 1242 + if (intp->tuner_type[demod] == 3) 1243 + intp->freq[d] = stv0900_get_freq_auto(intp, d); 1244 + else 1245 + intp->freq[d] = stv0900_get_tuner_freq(fe); 1246 + 1260 1247 if (ABS(offsetFreq) <= ((intp->srch_range[d] / 2000) + 500)) 1261 1248 range = STV0900_RANGEOK; 1262 1249 else if (ABS(offsetFreq) <= ··· 1502 1481 else 1503 1482 tuner_freq -= (current_step * currier_step); 1504 1483 1505 - stv0900_set_tuner(fe, tuner_freq, intp->bw[demod]); 1484 + if (intp->tuner_type[demod] == 3) 1485 + stv0900_set_tuner_auto(intp, tuner_freq, 1486 + intp->bw[demod], demod); 1487 + else 1488 + stv0900_set_tuner(fe, tuner_freq, 1489 + intp->bw[demod]); 1506 1490 } 1507 1491 } 1508 1492 ··· 1901 1875 1902 1876 } 1903 1877 1904 - stv0900_set_tuner(fe, intp->freq[demod], intp->bw[demod]); 1878 + if (intp->tuner_type[demod] == 3) 1879 + stv0900_set_tuner_auto(intp, intp->freq[demod], 1880 + intp->bw[demod], demod); 1881 + else 1882 + stv0900_set_tuner(fe, intp->freq[demod], intp->bw[demod]); 1905 1883 1906 1884 agc1_power = MAKEWORD(stv0900_get_bits(intp, AGCIQ_VALUE1), 1907 1885 stv0900_get_bits(intp, AGCIQ_VALUE0));