Changeset 562
- Timestamp:
- 11/29/09 14:41:17 (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/csctapi/io_serial.c
r557 r562 338 338 339 339 extern int mhz; 340 extern int reader_irdeto_mode; 340 extern int reader_has_irdeto_card; 341 341 342 342 343 if(io->reader_type==RTYP_SMART) … … 354 355 } 355 356 356 if (mhz == 600)357 {358 359 /* for 6MHz */360 if (reader_irdeto_mode)361 {362 cfsetospeed(&newtio, IO_Serial_Bitrate_to_Speed(props->output_bitrate));363 cfsetispeed(&newtio, IO_Serial_Bitrate_to_Speed(props->input_bitrate));364 }365 else366 {367 357 #ifdef OS_LINUX 368 /* these structures are only available on linux as fas as we know so limit this code to OS_LINUX */ 369 struct serial_struct nuts; 370 ioctl(io->fd, TIOCGSERIAL, &nuts); 371 nuts.custom_divisor = nuts.baud_base / 9600 * 3.57 / 6; 372 nuts.flags &= ~ASYNC_SPD_MASK; 373 nuts.flags |= ASYNC_SPD_CUST; 374 ioctl(io->fd, TIOCSSERIAL, &nuts); 375 cfsetospeed(&newtio, IO_Serial_Bitrate_to_Speed(38400)); 376 cfsetispeed(&newtio, IO_Serial_Bitrate_to_Speed(38400)); 377 #else 378 cfsetospeed(&newtio, IO_Serial_Bitrate_to_Speed(props->output_bitrate)); 379 cfsetispeed(&newtio, IO_Serial_Bitrate_to_Speed(props->input_bitrate)); 380 #endif 381 } 358 int standard_card_clock; //contains non-overclocked, standard clockrate of the card in 10kHz steps 359 if (reader_has_irdeto_card) 360 standard_card_clock = 600; 361 else 362 standard_card_clock = 357; 363 if (mhz == standard_card_clock) 364 #endif 365 { //no overclocking 366 cfsetospeed(&newtio, IO_Serial_Bitrate_to_Speed(props->output_bitrate)); 367 cfsetispeed(&newtio, IO_Serial_Bitrate_to_Speed(props->input_bitrate)); 382 368 } 383 else if (mhz == 357 || mhz == 358)384 {385 /* for 3.57 MHz */386 if (reader_irdeto_mode)387 {388 369 #ifdef OS_LINUX 389 /* these structures are only available on linux as fas as we know so limit this code to OS_LINUX */ 390 struct serial_struct nuts; 391 ioctl(io->fd, TIOCGSERIAL, &nuts); 392 nuts.custom_divisor = nuts.baud_base / 5713; 393 nuts.flags &= ~ASYNC_SPD_MASK; 394 nuts.flags |= ASYNC_SPD_CUST; 395 ioctl(io->fd, TIOCSSERIAL, &nuts); 396 cfsetospeed(&newtio, IO_Serial_Bitrate_to_Speed(38400)); 397 cfsetispeed(&newtio, IO_Serial_Bitrate_to_Speed(38400)); 398 #else 399 cfsetospeed(&newtio, IO_Serial_Bitrate_to_Speed(props->output_bitrate)); 400 cfsetispeed(&newtio, IO_Serial_Bitrate_to_Speed(props->input_bitrate)); 401 #endif 402 } 403 else 404 { 405 cfsetospeed(&newtio, IO_Serial_Bitrate_to_Speed(props->output_bitrate)); 406 cfsetispeed(&newtio, IO_Serial_Bitrate_to_Speed(props->input_bitrate)); 407 } 408 } 409 else if (mhz == 800) 410 { 411 412 /* for 8MHz */ 413 if (reader_irdeto_mode) 414 { 415 cfsetospeed(&newtio, IO_Serial_Bitrate_to_Speed(props->output_bitrate)); 416 cfsetispeed(&newtio, IO_Serial_Bitrate_to_Speed(props->input_bitrate)); 417 } 418 else 419 { 420 #ifdef OS_LINUX 421 /* these structures are only available on linux as fas as we know so limit this code to OS_LINUX */ 422 struct serial_struct nuts; 423 ioctl(io->fd, TIOCGSERIAL, &nuts); 424 nuts.custom_divisor = nuts.baud_base / 9600 * 6 / 8; 425 nuts.flags &= ~ASYNC_SPD_MASK; 426 nuts.flags |= ASYNC_SPD_CUST; 427 ioctl(io->fd, TIOCSSERIAL, &nuts); 428 cfsetospeed(&newtio, IO_Serial_Bitrate_to_Speed(38400)); 429 cfsetispeed(&newtio, IO_Serial_Bitrate_to_Speed(38400)); 430 #else 431 cfsetospeed(&newtio, IO_Serial_Bitrate_to_Speed(props->output_bitrate)); 432 cfsetispeed(&newtio, IO_Serial_Bitrate_to_Speed(props->input_bitrate)); 433 #endif 434 } 435 } 436 else if (mhz == 1000) 437 { 438 439 /* for 10MHz */ 440 if (reader_irdeto_mode) 441 { 442 cfsetospeed(&newtio, IO_Serial_Bitrate_to_Speed(props->output_bitrate)); 443 cfsetispeed(&newtio, IO_Serial_Bitrate_to_Speed(props->input_bitrate)); 444 } 445 else 446 { 447 #ifdef OS_LINUX 448 /* these structures are only available on linux as fas as we know so limit this code to OS_LINUX */ 449 struct serial_struct nuts; 450 ioctl(io->fd, TIOCGSERIAL, &nuts); 451 nuts.custom_divisor = nuts.baud_base / 9600 * 6 / 10; 452 nuts.flags &= ~ASYNC_SPD_MASK; 453 nuts.flags |= ASYNC_SPD_CUST; 454 ioctl(io->fd, TIOCSSERIAL, &nuts); 455 cfsetospeed(&newtio, IO_Serial_Bitrate_to_Speed(38400)); 456 cfsetispeed(&newtio, IO_Serial_Bitrate_to_Speed(38400)); 457 #else 458 cfsetospeed(&newtio, IO_Serial_Bitrate_to_Speed(props->output_bitrate)); 459 cfsetispeed(&newtio, IO_Serial_Bitrate_to_Speed(props->input_bitrate)); 460 #endif 461 } 462 } 463 else 464 { 465 /* invalid */ 466 return FALSE; 370 else { //over or underclocking 371 /* these structures are only available on linux as fas as we know so limit this code to OS_LINUX */ 372 struct serial_struct nuts; 373 ioctl(io->fd, TIOCGSERIAL, &nuts); 374 int custom_baud = 9600 * mhz / standard_card_clock; 375 nuts.custom_divisor = (nuts.baud_base + (custom_baud/2))/ custom_baud; 376 cs_debug("customspeed: standardclock=%d mhz=%d custom_baud=%d baud_base=%d divisor=%d -> effective baudrate %d", 377 standard_card_clock, mhz, custom_baud, nuts.baud_base, nuts.custom_divisor, nuts.baud_base/nuts.custom_divisor); 378 nuts.flags &= ~ASYNC_SPD_MASK; 379 nuts.flags |= ASYNC_SPD_CUST; 380 ioctl(io->fd, TIOCSSERIAL, &nuts); 381 cfsetospeed(&newtio, IO_Serial_Bitrate_to_Speed(38400)); 382 cfsetispeed(&newtio, IO_Serial_Bitrate_to_Speed(38400)); 383 #endif 467 384 } 468 385 … … 1115 1032 return FALSE; 1116 1033 1117 while ((i < IO_SERIAL_PNPID_SIZE) && IO_Serial_Read (io, 200, 1, &(io->PnP_id[i]))) 1034 while ((i < IO_SERIAL_PNPID_SIZE) && IO_Serial_Read (io, 1000, 1, &(io->PnP_id[i]))) 1035 //while ((i < IO_SERIAL_PNPID_SIZE) && IO_Serial_Read (io, 200, 1, &(io->PnP_id[i]))) 1118 1036 i++; 1119 1037 -
trunk/reader-common.c
r552 r562 5 5 int oscam_card_detect; 6 6 int mhz; 7 int reader_ irdeto_mode;7 int reader_has_irdeto_card; 8 8 9 9 uchar cta_cmd[272], cta_res[260], atr[64]; … … 154 154 for (i=0; i<5; i++) 155 155 { 156 reader_irdeto_mode = i%2 == 1;156 //reader_irdeto_mode = i%2 == 1; //only works when not overclocking 157 157 cta_cmd[0] = CTBCS_CLA; 158 158 cta_cmd[1] = CTBCS_INS_REQUEST; … … 180 180 #endif 181 181 cs_ri_log("ATR: %s", cs_hexdump(1, atr, atr_size)); 182 if (!memcmp(atr+4, "IRDETO", 6)) 183 reader_has_irdeto_card = 1; 184 else 185 reader_has_irdeto_card = 0; 182 186 sleep(1); 183 187 return(1);
Note:
See TracChangeset
for help on using the changeset viewer.