Changeset 548
- Timestamp:
- 11/26/09 12:46:14 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/csctapi/ifd_towitoko.c
r546 r548 55 55 #define IFD_TOWITOKO_DELAY 0 56 56 #define IFD_TOWITOKO_BAUDRATE 9600 57 #define IFD_TOWITOKO_PS 1557 //#define IFD_TOWITOKO_PS 15 58 58 #define IFD_TOWITOKO_MAX_TRANSMIT 255 59 59 //#define IFD_TOWITOKO_ATR_TIMEOUT 200 … … 473 473 int in; 474 474 475 #if defined(TUXBOX) && defined(MIPSEL)475 #if defined(TUXBOX) && (defined(MIPSEL) || defined(PPC) || defined(SH4)) 476 476 if(ioctl(ifd->io->fd, IOCTL_GET_IS_CARD_PRESENT, &in)<0) 477 477 #else … … 511 511 int in; 512 512 513 #if defined(TUXBOX) && defined(MIPSEL)513 #if defined(TUXBOX) && (defined(MIPSEL) || defined(PPC) || defined(SH4)) 514 514 if(ioctl(ifd->io->fd, IOCTL_GET_IS_CARD_PRESENT, &in)<0) 515 515 #else … … 547 547 SCI_PARAMETERS params; 548 548 static char irdeto[] = "IRDETO"; 549 #ifdef SH4 550 struct timeval tv, tv_spent; 551 int atr_size = 2, TDi_exists = 0; 552 #endif 549 553 550 554 (*atr) = NULL; 555 556 #ifdef SH4 557 memset(¶ms,0,sizeof(SCI_PARAMETERS)); 558 559 params.ETU = 372; 560 params.EGT = 3; 561 params.f = 9; 562 params.T = 0; 563 564 if(ioctl(ifd->io->fd, IOCTL_SET_PARAMETERS, ¶ms)!=0) 565 return IFD_TOWITOKO_IO_ERROR; 566 #endif 551 567 552 568 if(ioctl(ifd->io->fd, IOCTL_SET_RESET)<0) … … 555 571 if(ioctl(ifd->io->fd, IOCTL_SET_ATR_READY)<0) 556 572 return IFD_TOWITOKO_IO_ERROR; 573 574 #ifdef SH4 575 gettimeofday(&tv,0); 576 memcpy(&tv_spent,&tv,sizeof(struct timeval)); 577 578 while(n<atr_size && (tv_spent.tv_sec-tv.tv_sec)<10) 579 { 580 if(IO_Serial_Read(ifd->io, IFD_TOWITOKO_ATR_TIMEOUT, 1, buf+n)) 581 n++; 582 gettimeofday(&tv_spent,0); 583 if(n==2) // format character 584 { 585 // high nibble = TA1 , TB1 , TC1 , TD1 586 if(buf[n-1] & 0x10) 587 atr_size++; 588 if(buf[n-1] & 0x20) 589 atr_size++; 590 if(buf[n-1] & 0x40) 591 atr_size++; 592 if(buf[n-1] & 0x80) 593 { 594 atr_size++; 595 TDi_exists=atr_size; 596 } 597 atr_size+=(buf[n-1] & 0x0F); // historical bytes 598 } 599 if( (TDi_exists>0) && (n==TDi_exists) ) 600 { 601 TDi_exists=0; 602 // high nibble = TA1 , TB1 , TC1 , TD1 603 if(buf[n-1] & 0x10) 604 atr_size++; 605 if(buf[n-1] & 0x20) 606 atr_size++; 607 if(buf[n-1] & 0x40) 608 atr_size++; 609 if(buf[n-1] & 0x80) 610 { 611 atr_size++; 612 TDi_exists=atr_size; 613 } 614 } 615 } 616 #else 557 617 while(n<SCI_MAX_ATR_SIZE && IO_Serial_Read(ifd->io, IFD_TOWITOKO_ATR_TIMEOUT, 1, buf+n)) 558 618 { 559 619 n++; 560 620 } 621 #endif 561 622 562 623 if(n==0) … … 565 626 if(ioctl(ifd->io->fd, IOCTL_GET_PARAMETERS, ¶ms)<0) 566 627 return IFD_TOWITOKO_IO_ERROR; 567 /* 568 printf("T=%d\n", (int)params.T); 569 printf("f=%d\n", (int)params.f); 570 printf("ETU=%d\n", (int)params.ETU); 571 printf("WWT=%d\n", (int)params.WWT); 572 printf("CWT=%d\n", (int)params.CWT); 573 printf("BWT=%d\n", (int)params.BWT); 574 printf("EGT=%d\n", (int)params.EGT); 575 printf("clock=%d\n", (int)params.clock_stop_polarity); 576 printf("check=%d\n", (int)params.check); 577 printf("P=%d\n", (int)params.P); 578 printf("I=%d\n", (int)params.I); 579 printf("U=%d\n", (int)params.U); 580 */ 581 582 // print_hex_data(buf, n); 628 629 // cs_dump(buf, n, "BUF:"); 583 630 if(n>9 && !memcmp(buf+4, irdeto, 6)) 584 631 { … … 603 650 double a; 604 651 652 double atrparam_d = 0; 653 654 ATR_GetParameter(*atr,ATR_PARAMETER_D,&atrparam_d); 655 params.ETU = (unsigned char)atrparam_d; 656 657 // printf("atr D=%f\n", a); 658 ATR_GetParameter(*atr, ATR_PARAMETER_N, &a); 659 params.EGT = (unsigned char)a; 605 660 ATR_GetParameter(*atr, ATR_PARAMETER_P, &a); 606 661 // printf("atr P=%f\n", a); … … 610 665 params.I = (unsigned char)a; 611 666 667 double atrparam_f = 0; 668 669 if (ATR_GetParameter(*atr,ATR_PARAMETER_F,&atrparam_f)!=ATR_OK) 670 { 671 cs_log ("Error getting ATR parameter (F)"); 672 ATR_Delete (*atr); 673 (*atr) = NULL; 674 return IFD_TOWITOKO_IO_ERROR; 675 } 676 if (ATR_GetParameter(*atr,ATR_PARAMETER_D,&atrparam_d)!=ATR_OK) 677 { 678 cs_log ("Error getting ATR parameter (D)"); 679 ATR_Delete (*atr); 680 (*atr) = NULL; 681 return IFD_TOWITOKO_IO_ERROR; 682 } 683 684 if (params.ETU != 0) 685 params.ETU=atrparam_f/atrparam_d; 686 else 687 params.ETU=372; 612 688 613 689 if(ioctl(ifd->io->fd, IOCTL_SET_PARAMETERS, ¶ms)!=0) … … 618 694 } 619 695 620 621 /*622 696 ioctl(ifd->io->fd, IOCTL_GET_PARAMETERS, ¶ms); 623 697 624 printf("T=%d\n", (int)params.T); 625 printf("f=%d\n", (int)params.f); 626 printf("ETU=%d\n", (int)params.ETU); 627 printf("WWT=%d\n", (int)params.WWT); 628 printf("CWT=%d\n", (int)params.CWT); 629 printf("BWT=%d\n", (int)params.BWT); 630 printf("EGT=%d\n", (int)params.EGT); 631 printf("clock=%d\n", (int)params.clock_stop_polarity); 632 printf("check=%d\n", (int)params.check); 633 printf("P=%d\n", (int)params.P); 634 printf("I=%d\n", (int)params.I); 635 printf("U=%d\n", (int)params.U);*/ 636 637 698 cs_debug("T=%d f=%d ETU=%d WWT=%d CWT=%d BWT=%d EGT=%d clock=%d check=%d P=%d I=%d U=%d", (int)params.T, (int)params.f, (int)params.ETU, (int)params.WWT, (int)params.CWT, (int)params.BWT, (int)params.EGT, (int)params.clock_stop_polarity, (int)params.check, (int)params.P, (int)params.I, (int)params.U); 638 699 639 700 req_ts.tv_sec = 0; … … 881 942 IFD_Towitoko_GetClockRate (IFD * ifd) 882 943 { 883 return IFD_TOWITOKO_CLOCK_RATE; 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; 884 948 } 885 949
Note:
See TracChangeset
for help on using the changeset viewer.