Changeset 566
- Timestamp:
- 11/30/09 12:39:07 (14 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/csctapi/cardterminal.c
r565 r566 71 71 } 72 72 73 char CardTerminal_Init (CardTerminal * ct, unsigned short pn, int reader_type )73 char CardTerminal_Init (CardTerminal * ct, unsigned short pn, int reader_type, int mhz) 74 74 { 75 75 char ret; … … 78 78 79 79 /* Create a new IO_Serial */ 80 ct->io = IO_Serial_New (reader_type );80 ct->io = IO_Serial_New (reader_type, mhz); 81 81 82 82 /* Memory error */ -
trunk/csctapi/cardterminal.h
r565 r566 68 68 /* Intialice a CardTerminal in a given port */ 69 69 extern char 70 CardTerminal_Init (CardTerminal * ct, unsigned short pn, int reader_type );70 CardTerminal_Init (CardTerminal * ct, unsigned short pn, int reader_type, int mhz); 71 71 72 72 /* Send a CT-BCS command to a CardTerminal */ -
trunk/csctapi/ctapi.c
r565 r566 50 50 */ 51 51 52 char CT_init (unsigned short ctn, unsigned short pn, int reader_type )52 char CT_init (unsigned short ctn, unsigned short pn, int reader_type, int mhz) 53 53 { 54 54 CardTerminal *ct; … … 69 69 { 70 70 /* Initialize CardTerminal */ 71 ret = CardTerminal_Init (ct, pn, reader_type );71 ret = CardTerminal_Init (ct, pn, reader_type, mhz); 72 72 73 73 /* Add CardTerminal to list */ -
trunk/csctapi/ctapi.h
r565 r566 22 22 unsigned short Ctn, /* Terminal Number */ 23 23 unsigned short pn, /* Port Number */ 24 int reader_type /* reader type (mouse, smartreader) 24 int reader_type, /* reader type (mouse, smartreader) */ 25 int mhz 25 26 ); 26 27 -
trunk/csctapi/ifd_towitoko.c
r565 r566 943 943 { 944 944 //return IFD_TOWITOKO_CLOCK_RATE; 945 extern int mhz; 946 cs_debug("CLOCK RATE IS %i in 10kHz steps",mhz); 947 return mhz * 10000L; 945 cs_debug("CLOCK RATE IS %i in 10kHz steps",ifd->io->mhz); 946 return ifd->io->mhz * 10000L; 948 947 } 949 948 -
trunk/csctapi/io_serial.c
r565 r566 164 164 */ 165 165 166 IO_Serial * IO_Serial_New (int reader_type )166 IO_Serial * IO_Serial_New (int reader_type, int mhz) 167 167 { 168 168 IO_Serial *io; … … 174 174 175 175 io->reader_type=reader_type; 176 io->mhz=mhz; 176 177 177 178 return io; … … 519 520 /* Set the bitrate */ 520 521 521 extern int mhz; 522 523 int mhz = io->mhz; 522 524 extern int reader_irdeto_mode; 523 525 … … 536 538 } 537 539 538 if (mhz == 600) 539 { 540 541 /* for 6MHz */ 542 if (reader_irdeto_mode) 543 { 544 cfsetospeed(&newtio, IO_Serial_Bitrate(props->output_bitrate)); 545 cfsetispeed(&newtio, IO_Serial_Bitrate(props->input_bitrate)); 546 } 547 else 548 { 540 549 541 #ifdef OS_LINUX 550 /* these structures are only available on linux as fas as we know so limit this code to OS_LINUX */ 551 struct serial_struct nuts; 552 ioctl(io->fd, TIOCGSERIAL, &nuts); 553 nuts.custom_divisor = nuts.baud_base / 9600 * 3.57 / 6; 554 nuts.flags &= ~ASYNC_SPD_MASK; 555 nuts.flags |= ASYNC_SPD_CUST; 556 ioctl(io->fd, TIOCSSERIAL, &nuts); 557 cfsetospeed(&newtio, IO_Serial_Bitrate(38400)); 558 cfsetispeed(&newtio, IO_Serial_Bitrate(38400)); 559 #else 560 cfsetospeed(&newtio, IO_Serial_Bitrate(props->output_bitrate)); 561 cfsetispeed(&newtio, IO_Serial_Bitrate(props->input_bitrate)); 562 #endif 563 } 542 int standard_card_clock; //contains non-overclocked, standard clockrate of the card in 10kHz steps 543 if (reader_irdeto_mode) 544 standard_card_clock = 600; 545 else 546 standard_card_clock = 357; 547 if (mhz == standard_card_clock) 548 #endif 549 { //no overclocking 550 cfsetospeed(&newtio, IO_Serial_Bitrate(props->output_bitrate)); 551 cfsetispeed(&newtio, IO_Serial_Bitrate(props->input_bitrate)); 564 552 } 565 else if (mhz == 357 || mhz == 358)566 {567 /* for 3.57 MHz */568 if (reader_irdeto_mode)569 {570 553 #ifdef OS_LINUX 571 /* these structures are only available on linux as fas as we know so limit this code to OS_LINUX */ 572 struct serial_struct nuts; 573 ioctl(io->fd, TIOCGSERIAL, &nuts); 574 nuts.custom_divisor = nuts.baud_base / 5713; 575 nuts.flags &= ~ASYNC_SPD_MASK; 576 nuts.flags |= ASYNC_SPD_CUST; 577 ioctl(io->fd, TIOCSSERIAL, &nuts); 578 cfsetospeed(&newtio, IO_Serial_Bitrate(38400)); 579 cfsetispeed(&newtio, IO_Serial_Bitrate(38400)); 580 #else 581 cfsetospeed(&newtio, IO_Serial_Bitrate(props->output_bitrate)); 582 cfsetispeed(&newtio, IO_Serial_Bitrate(props->input_bitrate)); 583 #endif 584 } 585 else 586 { 587 cfsetospeed(&newtio, IO_Serial_Bitrate(props->output_bitrate)); 588 cfsetispeed(&newtio, IO_Serial_Bitrate(props->input_bitrate)); 589 } 554 else { //over or underclocking 555 /* these structures are only available on linux as fas as we know so limit this code to OS_LINUX */ 556 struct serial_struct nuts; 557 ioctl(io->fd, TIOCGSERIAL, &nuts); 558 int custom_baud = 9600 * mhz / standard_card_clock; 559 nuts.custom_divisor = (nuts.baud_base + (custom_baud/2))/ custom_baud; 560 cs_debug("customspeed: standardclock=%d mhz=%d custom_baud=%d baud_base=%d divisor=%d -> effective baudrate %d", 561 standard_card_clock, mhz, custom_baud, nuts.baud_base, nuts.custom_divisor, nuts.baud_base/nuts.custom_divisor); 562 nuts.flags &= ~ASYNC_SPD_MASK; 563 nuts.flags |= ASYNC_SPD_CUST; 564 ioctl(io->fd, TIOCSSERIAL, &nuts); 565 cfsetospeed(&newtio, IO_Serial_Bitrate(38400)); 566 cfsetispeed(&newtio, IO_Serial_Bitrate(38400)); 590 567 } 591 else if (mhz == 800) 592 { 593 594 /* for 8MHz */ 595 if (reader_irdeto_mode) 596 { 597 cfsetospeed(&newtio, IO_Serial_Bitrate(props->output_bitrate)); 598 cfsetispeed(&newtio, IO_Serial_Bitrate(props->input_bitrate)); 599 } 600 else 601 { 602 #ifdef OS_LINUX 603 /* these structures are only available on linux as fas as we know so limit this code to OS_LINUX */ 604 struct serial_struct nuts; 605 ioctl(io->fd, TIOCGSERIAL, &nuts); 606 nuts.custom_divisor = nuts.baud_base / 9600 * 6 / 8; 607 nuts.flags &= ~ASYNC_SPD_MASK; 608 nuts.flags |= ASYNC_SPD_CUST; 609 ioctl(io->fd, TIOCSSERIAL, &nuts); 610 cfsetospeed(&newtio, IO_Serial_Bitrate(38400)); 611 cfsetispeed(&newtio, IO_Serial_Bitrate(38400)); 612 #else 613 cfsetospeed(&newtio, IO_Serial_Bitrate(props->output_bitrate)); 614 cfsetispeed(&newtio, IO_Serial_Bitrate(props->input_bitrate)); 615 #endif 616 } 617 } 618 else if (mhz == 1000) 619 { 620 621 /* for 10MHz */ 622 if (reader_irdeto_mode) 623 { 624 cfsetospeed(&newtio, IO_Serial_Bitrate(props->output_bitrate)); 625 cfsetispeed(&newtio, IO_Serial_Bitrate(props->input_bitrate)); 626 } 627 else 628 { 629 #ifdef OS_LINUX 630 /* these structures are only available on linux as fas as we know so limit this code to OS_LINUX */ 631 struct serial_struct nuts; 632 ioctl(io->fd, TIOCGSERIAL, &nuts); 633 nuts.custom_divisor = nuts.baud_base / 9600 * 6 / 10; 634 nuts.flags &= ~ASYNC_SPD_MASK; 635 nuts.flags |= ASYNC_SPD_CUST; 636 ioctl(io->fd, TIOCSSERIAL, &nuts); 637 cfsetospeed(&newtio, IO_Serial_Bitrate(38400)); 638 cfsetispeed(&newtio, IO_Serial_Bitrate(38400)); 639 #else 640 cfsetospeed(&newtio, IO_Serial_Bitrate(props->output_bitrate)); 641 cfsetispeed(&newtio, IO_Serial_Bitrate(props->input_bitrate)); 642 #endif 643 } 644 } 645 else 646 { 647 /* invalid */ 648 return FALSE; 649 } 568 #endif 650 569 651 570 /* Set the character size */ -
trunk/csctapi/io_serial.h
r565 r566 76 76 int wr; 77 77 int reader_type; 78 int mhz; /* mhz specified in config = actual reader clock speed */ 78 79 } 79 80 IO_Serial; … … 86 87 //extern void IO_Serial_Reopen (IO_Serial * io); 87 88 extern void IO_Serial_Flush (IO_Serial * io); 88 extern IO_Serial *IO_Serial_New (int reader_type );89 extern IO_Serial *IO_Serial_New (int reader_type, int mhz); 89 90 extern void IO_Serial_Delete (IO_Serial * io); 90 91 -
trunk/globals.h
r505 r566 350 350 char device[128]; 351 351 int detect; 352 int mhz;353 int custom_speed; 352 int mhz; //actual clock rate of reader in 10khz steps 353 int custom_speed; //request immediate baudrate adaption after ATR; no PTS/PPS will be executed 354 354 int r_port; 355 355 char r_usr[64]; -
trunk/reader-common.c
r565 r566 4 4 char oscam_device[128]; 5 5 int oscam_card_detect; 6 int mhz;7 6 int reader_irdeto_mode; 8 7 … … 154 153 for (i=0; i<5; i++) 155 154 { 156 reader_irdeto_mode = i%2 == 1;155 //reader_irdeto_mode = i%2 == 1; //does not work when overclocking 157 156 cta_cmd[0] = CTBCS_CLA; 158 157 cta_cmd[1] = CTBCS_INS_REQUEST; … … 180 179 #endif 181 180 cs_ri_log("ATR: %s", cs_hexdump(1, atr, atr_size)); 181 if (!memcmp(atr+4, "IRDETO", 6)) 182 reader_irdeto_mode = 1; 183 else 184 reader_irdeto_mode = 0; 182 185 sleep(1); 183 186 return(1); … … 289 292 int rc; 290 293 oscam_card_detect=reader[ridx].detect; 291 mhz=reader[ridx].mhz;292 294 cs_ptyp_orig=cs_ptyp; 293 295 cs_ptyp=D_DEVICE; 294 296 snprintf(oscam_device, sizeof(oscam_device), "%s", device); 295 if ((rc=CT_init(1, reader_device_type(device, typ),reader[ridx].typ ))!=OK)297 if ((rc=CT_init(1, reader_device_type(device, typ),reader[ridx].typ,reader[ridx].mhz))!=OK) 296 298 cs_log("Cannot open device: %s", device); 297 299 cs_debug("ct_init on %s: %d", device, rc);
Note:
See TracChangeset
for help on using the changeset viewer.