- Timestamp:
- 01/17/10 17:33:19 (14 years ago)
- Location:
- trunk/csctapi
- Files:
-
- 2 deleted
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/csctapi/Makefile
r1220 r1266 13 13 $(LIBFILE1)(ctapi.o) \ 14 14 $(LIBFILE1)(icc_async.o) \ 15 $(LIBFILE1)(ifd_towitoko.o) \16 15 $(LIBFILE1)(ifd_cool.o) \ 17 16 $(LIBFILE1)(ifd_sci.o) \ -
trunk/csctapi/ct_slot.c
r1253 r1266 25 25 #include "defines.h" 26 26 #include "ct_slot.h" 27 #include "ifd_towitoko.h"28 27 #include "icc_async.h" 29 28 #include "protocol_t0.h" … … 38 37 #endif 39 38 39 /* Card status *///FIXME simplify this + duplicate in icc_async.h 40 #define IFD_TOWITOKO_CARD(status) (((status) & 0x40) == 0x40) 41 #define IFD_TOWITOKO_CHANGE(status) (((status) & 0x80) == 0x80) 42 40 43 /* Try first asynchronous init and if it fails try synchronous */ 41 44 //#undef ICC_PROBE_ASYNC_FIRST … … 66 69 char CT_Slot_Init (CT_Slot * slot, int sn) 67 70 { 68 slot->ifd = IFD_Towitoko_New(); 69 70 if (slot->ifd == NULL) 71 return ERR_MEMORY; 72 73 if (IFD_Towitoko_Init (slot->ifd, sn) != IFD_TOWITOKO_OK) 74 { 75 IFD_Towitoko_Delete (slot->ifd); 76 slot->ifd = NULL; 71 if (!Phoenix_Init()) 77 72 return ERR_TRANS; 78 }79 73 80 74 return OK; … … 133 127 return ERR_MEMORY; 134 128 135 if (ICC_Async_Init (slot->icc , slot->ifd) != ICC_ASYNC_OK)129 if (ICC_Async_Init (slot->icc) != ICC_ASYNC_OK) 136 130 { 137 131 ICC_Async_Delete (slot->icc); … … 303 297 bool CT_Slot_IsLast (CT_Slot * slot) 304 298 { 305 return (IFD_Towitoko_GetSlot(slot->ifd) >= IFD_Towitoko_GetNumSlots()-1); 299 //return (IFD_Towitoko_GetSlot(slot->ifd) >= IFD_Towitoko_GetNumSlots()-1); 300 return 1; //GetSlot always returns 0, and GetNumSlots returns always 1 306 301 } 307 302 308 303 void CT_Slot_GetType (CT_Slot * slot, BYTE * buffer, int len) 309 304 { 310 IFD_Towitoko_GetDescription (slot->ifd, buffer, len); 305 //IFD_Towitoko_GetDescription (slot->ifd, buffer, len) 306 buffer="dummy"; 307 len=5; 311 308 } 312 309 … … 347 344 } 348 345 349 if (slot->ifd != NULL) 350 { 351 if (IFD_Towitoko_Close (slot->ifd) != IFD_TOWITOKO_OK) 352 ret = ERR_TRANS; 353 354 IFD_Towitoko_Delete (slot->ifd); 355 } 346 if (!Phoenix_Close ()) 347 ret = ERR_TRANS; 356 348 357 349 CT_Slot_Clear (slot); … … 371 363 static void CT_Slot_Clear (CT_Slot * slot) 372 364 { 373 slot->ifd = NULL;374 365 slot->icc = NULL; 375 366 slot->protocol = NULL; -
trunk/csctapi/ct_slot.h
r1253 r1266 31 31 #include "ctapi.h" 32 32 #include "ctbcs.h" 33 #include "ifd_towitoko.h"34 33 35 34 … … 53 52 typedef struct 54 53 { 55 IFD * ifd; /* Interface device */56 54 void * icc; /* Integrated circuit card */ 57 55 void * protocol; /* Protocol handler */ -
trunk/csctapi/ctapi.c
r1253 r1266 115 115 116 116 #ifdef DEBUG_CTAPI 117 printf ("CTAPI: CT_init(ctn=%u , pn=%u)=%d\n", ctn, pn, ret);117 printf ("CTAPI: CT_init(ctn=%u)=%d\n", ctn, ret); 118 118 #endif 119 119 -
trunk/csctapi/icc_async.c
r1262 r1266 30 30 #include <string.h> 31 31 #include "ifd.h" 32 #include "mc_global.h" 32 33 33 34 /* … … 120 121 { 121 122 if(!Sci_GetStatus(reader[ridx].handle, &in)) 122 return I FD_TOWITOKO_IO_ERROR;123 return ICC_ASYNC_IFD_ERROR; 123 124 } 124 125 else … … 127 128 { 128 129 if (!Cool_GetStatus(&in)) 129 return I FD_TOWITOKO_IO_ERROR;130 return ICC_ASYNC_IFD_ERROR; 130 131 } 131 132 else … … 147 148 else 148 149 #endif 149 #ifdef USE_GPIO150 if (gpio_detect)151 in=get_gpio();152 else153 #endif154 150 if (!Phoenix_GetStatus(&in)) 155 return I FD_TOWITOKO_IO_ERROR;151 return ICC_ASYNC_IFD_ERROR; 156 152 157 153 if (in) … … 161 157 status[0] = IFD_TOWITOKO_CARD_CHANGE; 162 158 reader[ridx].status = 1; 163 #ifdef USE_GPIO164 if (gpio_detect) set_gpio1(0);165 #endif166 159 } 167 160 else if(reader[ridx].status == 1) … … 173 166 status[0] = IFD_TOWITOKO_CARD_CHANGE; 174 167 reader[ridx].status = 1; 175 #ifdef USE_GPIO176 if (gpio_detect) set_gpio1(0);177 #endif178 168 } 179 169 } … … 184 174 status[0] = IFD_TOWITOKO_NOCARD_CHANGE; 185 175 reader[ridx].status = 2; 186 #ifdef USE_GPIO187 if (gpio_detect) set_gpio1(1);188 #endif189 176 } 190 177 else if(reader[ridx].status == 1) … … 192 179 status[0] = IFD_TOWITOKO_NOCARD_CHANGE; 193 180 reader[ridx].status = 2; 194 #ifdef USE_GPIO195 if (gpio_detect) set_gpio1(1);196 #endif197 181 } 198 182 else … … 209 193 #endif 210 194 211 return I FD_TOWITOKO_OK;212 } 213 214 int ICC_Async_Init (ICC_Async * icc , IFD * ifd)195 return ICC_ASYNC_OK; 196 } 197 198 int ICC_Async_Init (ICC_Async * icc) 215 199 { 216 200 #ifndef ICC_TYPE_SYNC … … 221 205 return ICC_ASYNC_IFD_ERROR; 222 206 207 #ifdef SCI_DEV 223 208 /* Activate ICC */ 224 if ( IFD_Towitoko_ActivateICC (ifd) != IFD_TOWITOKO_OK)209 if (!Sci_Activate()) 225 210 return ICC_ASYNC_IFD_ERROR; 226 211 /* Reset ICC */ 227 #ifdef SCI_DEV228 212 if (reader[ridx].typ == R_INTERNAL) { 229 213 if (!Sci_Reset(&(icc->atr))) … … 278 262 /* Initialize member variables */ 279 263 icc->baudrate = ICC_ASYNC_BAUDRATE; 280 icc->ifd = ifd;281 264 282 265 if (icc->convention == ATR_CONVENTION_INVERSE) … … 435 418 } 436 419 437 IFD * ICC_Async_GetIFD (ICC_Async * icc)438 {439 return icc->ifd;440 }441 442 420 int ICC_Async_Close (ICC_Async * icc) 443 421 { 422 #ifdef SCI_DEV 444 423 /* Dectivate ICC */ 445 if (IFD_Towitoko_DeactivateICC (icc->ifd) != IFD_TOWITOKO_OK) 446 return ICC_ASYNC_IFD_ERROR; 424 if (!Sci_Deactivate()) 425 return ICC_ASYNC_IFD_ERROR; 426 #endif 447 427 448 428 /* Delete atr */ … … 486 466 static void ICC_Async_Clear (ICC_Async * icc) 487 467 { 488 icc->ifd = NULL;489 468 icc->atr = NULL; 490 469 icc->baudrate = 0L; -
trunk/csctapi/icc_async.h
r1224 r1266 27 27 28 28 #include "defines.h" 29 #include "ifd_towitoko.h" //FIXME30 29 #include "atr.h" 31 30 … … 38 37 #define ICC_ASYNC_IFD_ERROR 1 39 38 #define ICC_ASYNC_ATR_ERROR 2 39 40 /* Card status */ 41 #define IFD_TOWITOKO_NOCARD_NOCHANGE 0x00 42 #define IFD_TOWITOKO_CARD_NOCHANGE 0x40 43 #define IFD_TOWITOKO_NOCARD_CHANGE 0x80 44 #define IFD_TOWITOKO_CARD_CHANGE 0xC0 45 #define IFD_TOWITOKO_CARD(status) (((status) & 0x40) == 0x40) 46 #define IFD_TOWITOKO_CHANGE(status) (((status) & 0x80) == 0x80) 40 47 41 48 /* … … 54 61 typedef struct 55 62 { 56 IFD *ifd; /* Interface device */57 63 ATR *atr; /* Answer to reset of this ICC */ 58 64 int convention; /* Convention of this ICC */ … … 72 78 73 79 /* Initialization and Deactivation */ 74 extern int ICC_Async_Init (ICC_Async * icc , IFD * ifd);80 extern int ICC_Async_Init (ICC_Async * icc); 75 81 extern int ICC_Async_Close (ICC_Async * icc); 76 82 … … 81 87 extern int ICC_Async_GetBaudrate (ICC_Async * icc, unsigned long * baudrate); 82 88 extern ATR *ICC_Async_GetAtr (ICC_Async * icc); 83 extern IFD *ICC_Async_GetIFD (ICC_Async * icc);84 89 extern unsigned long ICC_Async_GetClockRate (); 85 90 -
trunk/csctapi/ifd.h
r1207 r1266 5 5 6 6 #include "ifd_cool.h" 7 8 typedef struct 9 { 10 unsigned block_delay; /* Delay (ms) after starting to transmit */ 11 unsigned char_delay; /* Delay (ms) after transmiting sucesive chars */ 12 unsigned block_timeout; /* Max timeout (ms) to receive firtst char */ 13 unsigned char_timeout; /* Max timeout (ms) to receive sucesive characters */ 14 } 15 IFD_Timings; //FIXME kill this -
trunk/csctapi/ifd_phoenix.c
r1263 r1266 10 10 #include "../globals.h" 11 11 #include "atr.h" 12 #include "ifd_towitoko.h" //FIXME13 12 #include <termios.h> 13 #include "ifd.h" //FIXME kill this after IFD timings 14 14 15 15 #define OK 1 … … 18 18 #define IFD_TOWITOKO_MAX_TRANSMIT 255 19 19 #define IFD_TOWITOKO_ATR_TIMEOUT 800 20 #define IFD_TOWITOKO_BAUDRATE 9600 21 22 #ifdef USE_GPIO //felix: definition of gpio functions 23 int gpio_outen,gpio_out,gpio_in; 24 unsigned int pin,gpio; 25 int gpio_detect=0; 26 27 static void set_gpio(int level) 28 { 29 read(gpio_outen, &gpio, sizeof(gpio)); 30 gpio |= pin; 31 write(gpio_outen, &gpio, sizeof(gpio)); 32 33 read(gpio_out, &gpio, sizeof(gpio)); 34 if (level>0) 35 gpio|=pin; 36 else 37 gpio&=~pin; 38 write(gpio_out, &gpio, sizeof(gpio)); 39 } 40 41 static void set_gpio_input(void) 42 { 43 read(gpio_outen, &gpio, sizeof(gpio)); 44 gpio &= ~pin; 45 write(gpio_outen, &gpio, sizeof(gpio)); 46 } 47 48 static int get_gpio(void) 49 { 50 set_gpio_input(); 51 read(gpio_in, &gpio, sizeof(gpio)); 52 return ((int)((gpio&pin)?1:0)); 53 } 54 #endif 55 20 56 21 57 int Phoenix_Init () 22 58 { 59 #ifdef USE_GPIO //felix: define gpio number used for card detect and reset. ref to globals.h 60 extern int oscam_card_detect; 61 if (oscam_card_detect>4) 62 { 63 gpio_detect=oscam_card_detect-4; 64 pin = 1<<gpio_detect; 65 gpio_outen=open("/dev/gpio/outen",O_RDWR); 66 gpio_out=open("/dev/gpio/out",O_RDWR); 67 gpio_in=open("/dev/gpio/in",O_RDWR); 68 set_gpio_input(); 69 } 70 #endif 71 72 #ifdef DEBUG_IFD 73 printf ("IFD: Initializing slot number %d, com=%d\n", slot, reader[ridx].typ); 74 #endif 75 76 if(reader[ridx].typ == R_INTERNAL) //not sure whether this should be moved in front of GPIO part 77 return OK; 78 79 /* Default serial port settings */ 80 if (!IO_Serial_SetParams (IFD_TOWITOKO_BAUDRATE, 8, PARITY_EVEN, 2, IO_SERIAL_HIGH, IO_SERIAL_LOW)) 81 { 82 reader[ridx].status = 0;//added this one because it seemed logical 83 return ERROR; 84 } 85 86 if (!Phoenix_SetBaudrate(IFD_TOWITOKO_BAUDRATE)) 87 { 88 reader[ridx].status = 0; 89 return ERROR; 90 } 91 92 if (!IO_Serial_SetParity (PARITY_EVEN)) 93 { 94 reader[ridx].status = 0; 95 return ERROR; 96 } 97 98 IO_Serial_Flush(); 23 99 return OK; 24 100 } … … 75 151 IO_Serial_Ioctl_Lock(1); 76 152 #ifdef USE_GPIO 77 if (gpio_detect) {153 if (gpio_detect) 78 154 set_gpio(0); 79 set_gpio1(0);80 }81 155 else 82 156 #endif … … 105 179 ATR_Delete (*atr); 106 180 (*atr) = NULL; 107 #ifdef USE_GPIO108 if (gpio_detect) set_gpio1(0);109 #endif110 181 } 111 182 } … … 145 216 block_delay = IFD_TOWITOKO_DELAY + timings->block_delay; 146 217 147 #ifdef USE_GPIO148 if (gpio_detect) set_gpio1(0);149 #endif150 218 for (sent = 0; sent < size; sent = sent + to_send) 151 219 { … … 168 236 } 169 237 } 170 #ifdef USE_GPIO171 if (gpio_detect) set_gpio1(1);172 #endif173 238 return OK; 174 239 } … … 186 251 char_timeout = IFD_TOWITOKO_TIMEOUT + timings->char_timeout; 187 252 block_timeout = IFD_TOWITOKO_TIMEOUT + timings->block_timeout; 188 #ifdef USE_GPIO189 if (gpio_detect) set_gpio1(0);190 #endif191 253 if (block_timeout != char_timeout) 192 254 { … … 208 270 return ERROR; 209 271 } 210 #ifdef USE_GPIO211 if (gpio_detect) set_gpio1(1);212 #endif213 272 214 273 #ifdef DEBUG_IFD … … 249 308 return OK; 250 309 } 310 311 int Phoenix_Close () 312 { 313 #ifdef USE_GPIO //felix: close dev if card detected 314 if(gpio_detect) 315 { 316 close(gpio_outen); 317 close(gpio_out); 318 close(gpio_in); 319 } 320 #endif 321 322 #ifdef DEBUG_IFD 323 printf ("IFD: Closing slot\n"); 324 #endif 325 326 reader[ridx].status = 0; 327 return OK; 328 } -
trunk/csctapi/ifd_sci.c
r1234 r1266 20 20 #include "../globals.h" 21 21 22 #include "ifd_towitoko.h"23 22 #define IFD_TOWITOKO_ATR_TIMEOUT 800 24 23 … … 142 141 } 143 142 144 #endif 143 int Sci_Activate () 144 { 145 #ifdef DEBUG_IFD 146 printf ("IFD: Activating card\n"); 147 #endif 148 #ifdef SCI_DEV 149 if(reader[ridx].typ == R_INTERNAL) 150 { 151 int in; 152 153 #if defined(TUXBOX) && (defined(MIPSEL) || defined(PPC) || defined(SH4)) 154 if(ioctl(reader[ridx].handle, IOCTL_GET_IS_CARD_PRESENT, &in)<0) 155 #else 156 if(ioctl(reader[ridx].handle, IOCTL_GET_IS_CARD_ACTIVATED, &in)<0) 157 #endif 158 return ERROR; 159 160 if(in) 161 { 162 struct timespec req_ts; 163 req_ts.tv_sec = 0; 164 req_ts.tv_nsec = 50000000; 165 nanosleep (&req_ts, NULL); 166 return OK; 167 } 168 else 169 return ERROR; 170 } 171 else 172 #endif 173 { 174 return OK; 175 } 176 } 177 178 int Sci_Deactivate () 179 { 180 #ifdef DEBUG_IFD 181 printf ("IFD: Deactivating card\n"); 182 #endif 183 184 #ifdef SCI_DEV 185 if(reader[ridx].typ == R_INTERNAL) 186 { 187 int in; 188 189 #if defined(TUXBOX) && (defined(MIPSEL) || defined(PPC) || defined(SH4)) 190 if(ioctl(reader[ridx].handle, IOCTL_GET_IS_CARD_PRESENT, &in)<0) 191 #else 192 if(ioctl(reader[ridx].handle, IOCTL_GET_IS_CARD_ACTIVATED, &in)<0) 193 #endif 194 return ERROR; 195 196 if(in) 197 { 198 if(ioctl(reader[ridx].handle, IOCTL_SET_DEACTIVATE)<0) 199 return ERROR; 200 } 201 202 203 } 204 #endif 205 206 return OK; 207 } 208 209 #endif
Note:
See TracChangeset
for help on using the changeset viewer.