00001 /*************************************************************************** 00002 l1394card.h - description 00003 ------------------- 00004 begin : Wed Jul 5 2000 00005 copyright : (C) 2000-2004 by Michael Repplinger 00006 email : repplix@studcs.uni-sb.de 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * * 00011 * This program is free software; you can redistribute it and/or modify * 00012 * it under the terms of the GNU General Public License as published by * 00013 * the Free Software Foundation; either version 2 of the License, or * 00014 * (at your option) any later version. * 00015 * * 00016 ***************************************************************************/ 00017 00018 #ifndef L1394CARD_H 00019 #define L1394CARD_H 00020 00021 #include "l1394_node.h" 00022 #include "l1394_nodecontainer.h" 00023 #include "l1394_nodefactory.h" 00024 #include "l1394_csrdirectory.h" 00025 #include "l1394_bustopology.h" 00026 #include "l1394_message.h" 00027 #include "l1394_transaction.h" 00028 #include "Thread.hpp" 00029 00030 #include <list> 00031 00032 00033 namespace L1394{ 00034 /*! \class Card 00035 * \ingroup L1394_Node 00036 * \brief This class represents a FireWire card. 00037 * 00038 * A Card manages up to 64 (pointer of) Nodes in an array. 00039 * The Nodes are stored in a global internal::NodeContainer except Nodes with a physical layer only, 00040 * so called PhyNodes(because there is no way to identify them). PhyNodes are 00041 * deleted after every bus reset (and recreate if they are always 00042 * connected to the FireWire bus.) 00043 * 00044 * To guarantee that every node connected to the bus is represented by one 00045 * L1394 node the Card searches the global internal::NodeContainer for an 00046 * existing object. So its possible to connect one device to multiple cards and work always with the same object. 00047 * 00048 * Every card object provides a Transaction object (wrapper class for libraw1394) 00049 * that can be used to send asynchone transactions. 00050 * 00051 * This class provides also functions to find and get Nodes, but they search on 00052 * the current card only. The Card returns objects from type L1394::Node, so you need to cast 00053 * the L1394 nodes to the correct type if you need. <BR> 00054 * To find and get nodes you should use the functions from class Session. 00055 * 00056 * @author Michael Repplinger 00057 */ 00058 00059 00060 class Card : public Node 00061 { 00062 public: 00063 /*! \name Camera constructor 00064 * These functions creates the Card objects. 00065 */ 00066 //@{ 00067 /*! \fn Card(const u_int32_t card_number, const u_int32_t node_number, raw1394handle_t default_handle) 00068 * \brief constructor 00069 * \param card_number : specify the card number. 00070 * \param node_number : specify the node_number by creating this object 00071 * \param default_handle: pointer to the default handle for this node 00072 */ 00073 Card(const u_int32_t card_id, const u_int32_t node_id, raw1394handle_t default_handle); 00074 00075 00076 /*! \fn ~Card() 00077 * \brief destroy an 1394 Card object 00078 */ 00079 virtual ~Card(); 00080 //@} 00081 00082 00083 /** \name Access the connected nodes 00084 * These functions access the connected nodes on a FireWire card. All functions 00085 * search only on this card. 00086 */ 00087 //@{ 00088 /*! \fn getNode(const u_int64_t guid) const 00089 * \brief This method searches a Node with a certain guid. 00090 * 00091 * This method searches only on this card. 00092 * \param guid : the guid of the node 00093 * \return Node* : pointer to the node, NULL if the node doesn't exist on this card. 00094 */ 00095 Node *getNode(const u_int64_t guid) const; 00096 00097 00098 /*! \fn getAllNodes(const int node_type) const 00099 * \brief This method searches all nodes with a certain type and 00100 * returns a STL-list. 00101 * 00102 * This method searches only on this card. 00103 * \param node_type : integer for type of the nodes. 00104 * \return list<Node*> : stl_list with Nodes from type node_type 00105 */ 00106 list<Node*> getAllNodes(const int node_type) const; 00107 00108 00109 /*! \fn findNode(const int node_type) const 00110 * \brief This method searches the first node with a certain node type. 00111 * 00112 * This method searches only on this card. 00113 * \param node_type : integer value with the node type (defined in class Node) 00114 * \return Node* : pointer to the first node with this node_type, NULL if no node 00115 * exist on this card. 00116 */ 00117 Node *findNode(const int node_type) const; 00118 00119 00120 /*! \fn getNodeArray() const 00121 * \brief This method returns the array of all nodes on the card. 00122 * 00123 * The node_array stores all Nodes connected to this card. 00124 * The array has length 64 and is filled up with NULL-pointer, if it contains 00125 * less than 64 nodes. The content of this array can change after bus reset. 00126 * \return Node** : pointer to the Node array with size 64. 00127 */ 00128 Node **getNodeArray() const {return node_array;} 00129 00130 00131 /*! \fn getExplicitNode(const int i) const 00132 * \brief This method returns the i'th node on the card. 00133 * \param i : for the i'th node. 00134 * \return Node* : pointer to the Node, NULL if no node with this id exist. 00135 */ 00136 Node* getExplicitNode(const int i) const {return node_array[i];} 00137 00138 00139 /*! \fn nodeExist(const u_int64_t guid) const 00140 * \brief This method tests if a node with a certain guid is connected to this card. 00141 * 00142 * This method searches only on this card. 00143 * \param guid : the guid of the node 00144 * \return bool : value true for node exist, else false. 00145 */ 00146 bool nodeExist(const u_int64_t guid) const; 00147 00148 00149 /*! \fn getBusMaster() const 00150 * \brief This method returns the actual Bus-Master node. The busmaster 00151 * can change after bus reset. 00152 * \return Node* : pointer to the actual busmaster. 00153 */ 00154 Node* getBusMaster() const {if (node_count >=1 ) return node_array[node_count-1]; return NULL;} 00155 //@} 00156 00157 00158 /** \name Card specific information 00159 * These functions return some card specific information. 00160 */ 00161 //@{ 00162 /*! \fn getNodeCount() const 00163 * \brief This method returns the number of connected nodes. 00164 * \return int : value with node count (between 1..64) 00165 */ 00166 u_int32_t getNodeCount() const {return node_count;} 00167 00168 00169 /*! \fn getCardID() const 00170 * \brief This method returns the card-id 00171 */ 00172 u_int32_t getCardID() const {return card_id;} 00173 00174 00175 /*! \fn getDefaultHandle() const 00176 * \brief This method returns the current default-handler (obsolete) 00177 */ 00178 raw1394handle_t getDefaultHandle() const {return default_handle;} 00179 00180 00181 /*! \fn getBusTopology() const 00182 * \brief This method returns the actual BusTopology. 00183 * 00184 * An object of this class stores the actual Topo Map as QArray and as tree. 00185 * The bustopology changes after every bus reset. 00186 * \return internal::BusTopology* : pointer to the actual BusTopology 00187 */ 00188 internal::BusTopology* getBusTopology() const { return bustopology;} 00189 00190 00191 /*! \fn printNodeList() const 00192 * \brief prints the device list of a card to standard output 00193 */ 00194 void printNodeList() const; 00195 00196 00197 /*! \fn getTopoMap() const 00198 * \brief This method returns the actual topology map 00199 * \return QArray* : pointer to the topology map 00200 */ 00201 QArray* getTopoMap() const {return topo_map;} 00202 00203 /** resets the bus 00204 */ 00205 int reset() const; 00206 //@} 00207 00208 00209 /** \name Transaction object 00210 * These methods access the Transaction object of a card. 00211 */ 00212 //@{ 00213 /*! \fn requestTransaction() const 00214 * \brief This method returns the Transaction object of a Card. 00215 * 00216 * This method is for internal use. You should use the Node memberfunctions 00217 * read, write and lock. 00218 * Remark: The Transaction object must be released before any Node can 00219 * request it again. So if you must use this method you MUST call 00220 * the method releaseTransaction() to release the Transaction object. 00221 */ 00222 const internal::Transaction* requestTransaction() const ; 00223 00224 00225 /*! \fn releaseTransaction() const 00226 * \brief This method releases the Transaction object 00227 */ 00228 void releaseTransaction() const; 00229 //@} 00230 00231 /*! \fn makeNodeList(raw1394handle_t) 00232 * \brief This method creates the internal node list. 00233 */ 00234 virtual void makeNodeList(raw1394handle_t); 00235 00236 /* 00237 returns -1, if no channel available 00238 */ 00239 int requestIsoChannel() const; 00240 int requestIsoChannel(const u_int32_t) const; 00241 void releaseIsoChannel(const u_int32_t) const; 00242 protected: 00243 00244 /*! \fn readAGuid(const int node); 00245 * \brief This method reads the GUID of a node connected to this card direct from CSR. 00246 * \return u_int64_t : Return the GUID. 00247 */ 00248 u_int64_t readAGuid(const int node); 00249 00250 00251 /*! \fn readTopoMap() 00252 * \brief This method reads the Topologie map 00253 */ 00254 void readTopoMap(); 00255 00256 private: 00257 /* Disables Copy constructor */ 00258 Card(const Card&); 00259 00260 // releases all; 00261 //void makeClean(); 00262 00263 // pointer to the NodeContainer object 00264 internal::NodeContainer* node_container; 00265 00266 // pointer to the csr-object (defined in l1394csr.h) 00267 internal::CsrRom* rom_info; 00268 00269 // pointer to the bustopology 00270 internal::BusTopology* bustopology; 00271 00272 // The transaction object 00273 internal::Transaction* transaction; 00274 00275 // pointer to actual topology map 00276 QArray* topo_map; 00277 00278 // counter for nodes and bus reset 00279 u_int32_t node_count, reset_count, card_id; 00280 00281 // the node array 00282 Node **node_array; 00283 00284 // mutex 00285 ThreadMutex mutex; 00286 00287 // The default_handle 00288 raw1394handle_t default_handle; 00289 00290 00291 mutable Quadlet low_iso_channel; 00292 mutable Quadlet high_iso_channel; 00293 }; 00294 } //namespace L1394 00295 #endif