fdhwlib  2.0.25
/home/kopmann/git-mirror/fdhwlib/fdhwlib/Pbus/pbus1394.h
Go to the documentation of this file.
00001 /***************************************************************************
00002     pbus1394.h  -  description
00003 
00004     begin                : Mon Oct 27 2003
00005     copyright            : (C) 2003 by A Kopmann
00006     email                : kopmann@ipe.fzk.de
00007     status               :
00008     test                 :
00009     history              :
00010  ***************************************************************************/
00011 
00012 #ifndef PBUS1394_H
00013 #define PBUS1394_H
00014 
00015 #include "pbusimp.h"
00016 
00017 
00018 #ifdef PBUS_1394
00019 
00020 
00021 #ifdef __linux__
00022 #define USE_LIBRAW1394
00023 #endif
00024 
00025 #ifdef __APPLE__
00026 #define USE_IOFIREWIRELIB
00027 #endif
00028 
00029 
00030 #ifdef USE_LIBRAW1394
00031 #include <libraw1394/raw1394.h>
00032 #include <libraw1394/csr.h>
00033 #endif
00034 
00035 #ifdef USE_IOFIREWIRELIB
00036 #include <IOKit/firewire/IOFirewireLib.h>
00037 #endif
00038 
00039 #define PBUS1394_MAXPORTS 16
00040 
00041 
00042 class semaphore;
00043 
00089 class Pbus1394 : public PbusImp
00090 {
00091 
00092 public:
00093   Pbus1394();
00094 
00095   ~Pbus1394();
00096 
00097   const char *getMode();
00098 
00099   int getModeId();
00100 
00101   const char *getLibName();
00102 
00103   int get(std::string item, std::string *value);
00104 
00105   int init(char *inifile, int host=0);
00106 
00107   int free(int host=0);
00108 
00109   void reset();
00110 
00111   unsigned long getState();
00112 
00113   unsigned long getState(unsigned long addr);
00114 
00115   int waitForIR(int timeout);
00116 
00117   int checkIR();
00118 
00119   unsigned long getIRvector();
00120 
00121   unsigned long rawRead(unsigned long addr);
00122 
00123   void rawWrite(unsigned long addr, unsigned long data);
00124 
00125   void readBlock(unsigned long addr, unsigned long * data,
00126                unsigned long n, unsigned long incr=1);
00127 
00131   void readRegisterBlock(unsigned long addr, unsigned long *data,
00132                       unsigned long nPix, unsigned long incrPix,
00133                       unsigned long nSlots=1, unsigned long incrSlots=0);
00134 
00135 private:
00136 
00137 #ifdef USE_LIBRAW1394
00138 
00144   static int bus1394ResetHandler(raw1394handle_t handle, unsigned int generation);
00145 
00147   static int tag1394Handler(raw1394handle_t handle, unsigned long tag,
00148                    raw1394_errcode_t errcode);
00149 #endif
00150 
00154   void handleError(const char *cmd, unsigned long addr,
00155                    int nLoop, int errNo);
00156 
00164   static int get1394NodeId();
00165 
00166 #ifdef USE_IOFIREWIRELIB
00167   typedef unsigned long quadlet_t;
00168 
00170   int raw1394_read(int handle, unsigned long id, long long addr, unsigned long len, unsigned long *data);
00171 
00173   int raw1394_write(int handle, unsigned long id, long long addr, unsigned long len, unsigned long *data);
00174 
00175   void BusResetHandler(IOFireWireLibDeviceRef self, void *);
00176 
00177 #endif
00178 
00179 private: // Members
00180 
00181 #ifdef USE_LIBRAW1394
00182 
00185   static raw1394handle_t handle1394;
00186 
00188   static struct raw1394_portinfo *p1394info;
00189 #endif
00190 
00195   static int id1394;
00196 
00198   static int idCard;
00199 
00200 
00201 #ifdef USE_IOFIREWIRELIB
00202 
00203   unsigned int handle1394;
00204 
00206   static io_object_t service;
00207 
00209   static IOCFPlugInInterface** interface;
00210 
00212   static IOFireWireLibNubRef unit;  
00213 #endif
00214 
00215 
00217   static bool resetDetected;
00218 
00219 
00221   static int sibMajorVersion;
00222 
00223   static int sibMinorVersion;
00224 
00225 
00227   static unsigned long sibStatus;
00228 
00230   static unsigned long logNo;
00231   
00232 };
00233 
00234 #endif  // of PBUS_1394
00235 
00236 #endif
00237 
00238