Changeset 31
- Timestamp:
- 11/28/04 14:11:36 (18 years ago)
- Files:
-
- trunk/freebob/src/avaudioinfoblock.h (modified) (2 diffs)
- trunk/freebob/src/avaudiosyncinfoblock.h (modified) (2 diffs)
- trunk/freebob/src/avdescriptor.h (modified) (2 diffs)
- trunk/freebob/src/avdevice.cpp (modified) (12 diffs)
- trunk/freebob/src/avdevice.h (modified) (2 diffs)
- trunk/freebob/src/avdeviceaudiosubunit.h (modified) (1 diff)
- trunk/freebob/src/avdevicemusicsubunit.h (modified) (2 diffs)
- trunk/freebob/src/avdevicesubunit.cpp (modified) (5 diffs)
- trunk/freebob/src/avmusicidentifierdescriptor.h (modified) (2 diffs)
- trunk/freebob/src/ieee1394service.h (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/freebob/src/avaudioinfoblock.h
r22 r31 18 18 * MA 02111-1307 USA. 19 19 */ 20 20 21 21 #include <string.h> 22 22 #include <errno.h> … … 42 42 protected: 43 43 AvNameInfoBlock *cNameInfoBlock; 44 private: 45 44 private: 45 46 46 }; 47 47 trunk/freebob/src/avaudiosyncinfoblock.h
r22 r31 18 18 * MA 02111-1307 USA. 19 19 */ 20 20 21 21 22 22 #include <string.h> … … 41 41 protected: 42 42 43 private: 44 43 private: 44 45 45 }; 46 46 trunk/freebob/src/avdescriptor.h
r25 r31 28 28 AvDescriptor(AvDevice *parent, quadlet_t target, unsigned int type); 29 29 virtual ~AvDescriptor(); 30 30 31 31 void Load(); 32 32 bool isLoaded(); … … 42 42 bool canWrite(); 43 43 bool isValid(); 44 44 45 45 protected: 46 46 AvDevice *cParent; trunk/freebob/src/avdevice.cpp
r27 r31 1 1 /* avdevice.cpp 2 2 * Copyright (C) 2004 by Daniel Wagner, Pieter Palmers 3 *4 3 * 5 4 * This file is part of FreeBob. … … 34 33 35 34 // check to see if a device is really present? 36 35 37 36 // probably initialisation would be better done here 37 38 // Port and node id are not distinct. The node id 39 // can change after a bus reset, therefore the 40 // device id has to be taken for identifiction. 38 41 } 39 42 … … 43 46 44 47 m_handle = raw1394_new_handle(); 45 46 47 48 49 50 51 52 53 54 48 if ( !m_handle ) { 49 if ( !errno ) { 50 debugPrint(DEBUG_LEVEL_DEVICE, "libraw1394 not compatible.\n" ); 51 } else { 52 perror ("Could not get 1394 handle"); 53 debugPrint(DEBUG_LEVEL_DEVICE, "Is ieee1394 and raw1394 driver loaded?\n"); 54 } 55 return eFBRC_Creating1394HandleFailed; 56 } 57 55 58 raw1394_set_userdata( m_handle, this ); 56 59 57 60 if ( raw1394_set_port( m_handle, m_iPort ) < 0 ) { 58 59 60 61 perror( "Could not set port" ); 62 return eFBRC_Setting1394PortFailed; 63 } 61 64 } 62 65 63 66 // enumerate the subunits present in this device, create an AvDeviceSubunit for them, and add this object to the cSubUnits vector 64 67 unsigned char table_entry; 65 68 unsigned char subunit_maxid; 66 69 unsigned char subunit_type; 67 quadlet_t table_entries; // buffer these table entries, because the memory content pointed to by 70 quadlet_t table_entries; // buffer these table entries, because the memory content pointed to by 68 71 // the response pointer can change due to other libraw operations on this handle 69 72 70 73 quadlet_t request[6]; 71 74 quadlet_t *response; 72 75 AvDeviceSubunit *tmpAvDeviceSubunit=NULL; 73 76 74 77 // check the number of I/O plugs 75 78 76 79 request[0] = AVC1394_CTYPE_STATUS | AVC1394_SUBUNIT_TYPE_UNIT | AVC1394_SUBUNIT_ID_IGNORE 77 80 | AVC1394_COMMAND_PLUG_INFO | 0x00; … … 92 95 iNbAsyncSourcePlugs= (unsigned char) ((response[1]>>16) & 0xff); 93 96 } 94 97 95 98 debugPrint (DEBUG_LEVEL_DEVICE,"AvDevice: %d Isochronous source plugs, %d Isochronous destination plugs\n",iNbIsoSourcePlugs,iNbIsoDestinationPlugs); 96 99 debugPrint (DEBUG_LEVEL_DEVICE,"AvDevice: %d External source plugs, %d External destination plugs\n",iNbExtSourcePlugs,iNbExtDestinationPlugs); 97 100 debugPrint (DEBUG_LEVEL_DEVICE,"AvDevice: %d Asynchronous source plugs, %d Asynchronous destination plugs\n",iNbAsyncSourcePlugs,iNbAsyncDestinationPlugs); 98 101 99 102 // create the subunits 100 103 for (unsigned int i=0;i<8;i++) { // cycle through the 8 pages (max 32 subunits; 4 subunits/page) … … 103 106 request[1] = 0xFFFFFFFF; 104 107 response = avcExecuteTransaction(request, 6, 2); 105 108 106 109 table_entries=response[1]; 107 110 108 111 if (response != NULL) { 109 112 // this way of processing the table entries assumes that the subunit type is not "extended" 110 113 111 114 // stop processing when a "not implemented" is received (according to spec) 112 115 if((response[0]&0xFF000000) == AVC1394_RESPONSE_NOT_IMPLEMENTED) break; 113 116 114 117 // warning: don't do unsigned int j! comparison >= 0 is always true for uint 115 118 for (int j=3;j>=0;j--) { // cycle through the 8 pages (max 32 subunits; 4 subunits/page) … … 118 121 subunit_type=(table_entry >> 3) & 0x1F; 119 122 //debugPrint (DEBUG_LEVEL_DEVICE,"AvDevice: Page %d, item %d: Table entry=0x%02X, subunit_maxid=0x%02X, subunit_type=0x%02X\n",i,j,table_entry,subunit_maxid,subunit_type); 120 123 121 124 // according to spec we could stop processing 122 125 // at the first 0xFF entry, but doing it this way … … 124 127 if (table_entry != 0xFF) { 125 128 for (unsigned char subunit_id=0;subunit_id<subunit_maxid+1;subunit_id++) { 126 129 127 130 // only two types of specific subunits are supported: audio and music 128 131 switch (subunit_type) { … … 139 142 } 140 143 break; 141 144 142 145 default: // generic 143 146 tmpAvDeviceSubunit=new AvDeviceSubunit(this,subunit_type,subunit_id); 144 147 break; 145 } 146 148 } 149 147 150 if(tmpAvDeviceSubunit && tmpAvDeviceSubunit->isValid()) { 148 151 cSubUnits.push_back(tmpAvDeviceSubunit); 149 150 152 153 151 154 } else { 152 155 if (tmpAvDeviceSubunit) { 153 debugPrint (DEBUG_LEVEL_DEVICE,"AvDevice: Unsupported AvDeviceSubunit encountered. Page %d, item %d: Table entry=0x%02X, subunit_maxid=0x%02X, subunit_type=0x%02X, subunit_id=%0x02X\n",i,j,table_entry,subunit_maxid,subunit_ id);154 156 debugPrint (DEBUG_LEVEL_DEVICE,"AvDevice: Unsupported AvDeviceSubunit encountered. Page %d, item %d: Table entry=0x%02X, subunit_maxid=0x%02X, subunit_type=0x%02X, subunit_id=%0x02X\n",i,j,table_entry,subunit_maxid,subunit_type,subunit_id); 157 155 158 delete tmpAvDeviceSubunit; 156 159 } else { … … 163 166 } 164 167 } 165 168 166 169 m_bInitialised = true; 167 170 return eFBRC_Success; 168 171 169 172 } 170 173 … … 182 185 183 186 if ( m_handle ) { 184 185 187 raw1394_destroy_handle( m_handle ); 188 m_handle = 0; 186 189 } 187 190 } … … 209 212 debugPrint (DEBUG_LEVEL_TRANSFERS, "subunit_type=%02X subunit_id=%02X opcode=%02X",((*(request_pos+1))>>3)&0x1F,(*(request_pos+1))&0x07,(*(request_pos+2))&0xFF); 210 213 debugPrint (DEBUG_LEVEL_TRANSFERS,"\n"); 211 } 214 } 212 215 if (response != NULL) { 213 216 /* response is in order of receiving, i.e. msb first */ … … 237 240 debugPrint (DEBUG_LEVEL_TRANSFERS,"Changed "); 238 241 break; 239 case AVC1394_RESPONSE_INTERIM: 242 case AVC1394_RESPONSE_INTERIM: 240 243 debugPrint (DEBUG_LEVEL_TRANSFERS,"Interim "); 241 244 break; trunk/freebob/src/avdevice.h
r26 r31 1 1 /* avdevice.h 2 2 * Copyright (C) 2004 by Daniel Wagner, Pieter Palmers 3 * 3 * 4 4 * 5 5 * This file is part of FreeBob. … … 35 35 AvDevice(int node,int port); 36 36 virtual ~AvDevice(); 37 37 38 38 quadlet_t * avcExecuteTransaction(quadlet_t *request, unsigned int request_len, unsigned int response_len); 39 39 40 40 FBReturnCodes AvDevice::Initialize(); 41 41 42 42 bool AvDevice::isInitialised(); 43 43 44 44 private: 45 45 int iNodeId; 46 46 raw1394handle_t m_handle; 47 47 int m_iPort; 48 48 bool m_bInitialised; 49 49 vector<AvDeviceSubunit *> cSubUnits; 50 51 52 53 54 55 56 57 50 51 unsigned char iNbAsyncDestinationPlugs; 52 unsigned char iNbAsyncSourcePlugs; 53 unsigned char iNbIsoDestinationPlugs; 54 unsigned char iNbIsoSourcePlugs; 55 unsigned char iNbExtDestinationPlugs; 56 unsigned char iNbExtSourcePlugs; 57 58 58 }; 59 59 trunk/freebob/src/avdeviceaudiosubunit.h
r26 r31 31 31 virtual ~AvDeviceAudioSubunit(); 32 32 33 33 34 34 private: 35 35 trunk/freebob/src/avdevicemusicsubunit.h
r27 r31 35 35 36 36 void test(); 37 37 38 // functions to demonstrate the usage of the commands defined by the specs 38 39 // we'll see later what to do with them exactly … … 42 43 private: 43 44 AvMusicStatusDescriptor *cStatusDescriptor; 44 AvMusicIdentifierDescriptor 45 AvMusicIdentifierDescriptor *cIdentifierDescriptor; 45 46 }; 46 47 trunk/freebob/src/avdevicesubunit.cpp
r26 r31 36 36 quadlet_t request[6]; 37 37 quadlet_t *response; 38 38 39 39 cParent=parent; 40 40 iTarget=target; … … 42 42 iNbDestinationPlugs=0; 43 43 iNbSourcePlugs=0; 44 44 45 45 debugPrint (DEBUG_LEVEL_SUBUNIT,"AvDeviceSubunit target=%02X id=%02X created\n",target,id); 46 46 47 47 if (!cParent) { 48 48 debugPrint (DEBUG_LEVEL_SUBUNIT,"AvDeviceSubunit: parent == NULL!\n"); … … 50 50 return; 51 51 } 52 52 53 53 bValid=true; 54 54 55 55 // check the number of I/O plugs 56 56 57 57 request[0] = AVC1394_CTYPE_STATUS | ((iTarget & 0x1F) << 19) | ((iId & 0x07) << 16) 58 58 | AVC1394_COMMAND_PLUG_INFO | 0x00; … … 64 64 } 65 65 debugPrint (DEBUG_LEVEL_SUBUNIT,"AvDeviceSubunit: %d source plugs, %d destination plugs\n",iNbSourcePlugs,iNbDestinationPlugs); 66 67 66 67 68 68 } 69 69 … … 85 85 return iNbSourcePlugs; 86 86 } 87 trunk/freebob/src/avmusicidentifierdescriptor.h
r26 r31 18 18 * MA 02111-1307 USA. 19 19 */ 20 20 21 21 #include "avdevice.h" 22 22 #include "avdescriptor.h" … … 35 35 AvMusicIdentifierDescriptor(AvDevice *parent, unsigned char id); 36 36 ~AvMusicIdentifierDescriptor(); 37 37 38 38 void printCapabilities(); 39 39 40 40 protected: 41 41 42 42 private: 43 43 trunk/freebob/src/ieee1394service.h
r21 r31 28 28 29 29 /* XXX: add those to avc1394.h */ 30 #define AVC1394_SUBUNIT_TYPE_AUDIO (1 <<19) 31 #define AVC1394_SUBUNIT_TYPE_PRINTER (2 <<19) 32 #define AVC1394_SUBUNIT_TYPE_CA (6 <<19) 33 #define AVC1394_SUBUNIT_TYPE_PANEL (9 <<19) 34 #define AVC1394_SUBUNIT_TYPE_BULLETIN_BOARD (0xA <<19) 35 #define AVC1394_SUBUNIT_TYPE_CAMERA_STORAGE (0xB <<19) 36 #define AVC1394_SUBUNIT_TYPE_MUSIC (0xC <<19) 30 #define AVC1394_SUBUNIT_TYPE_AUDIO (1 <<19) 31 #define AVC1394_SUBUNIT_TYPE_PRINTER (2 <<19) 32 #define AVC1394_SUBUNIT_TYPE_CA (6 <<19) 33 #define AVC1394_SUBUNIT_TYPE_PANEL (9 <<19) 34 #define AVC1394_SUBUNIT_TYPE_BULLETIN_BOARD (0xA <<19) 35 #define AVC1394_SUBUNIT_TYPE_CAMERA_STORAGE (0xB <<19) 36 #define AVC1394_SUBUNIT_TYPE_MUSIC (0xC <<19) 37 37 38 38 #define AVC1394_SUBUNIT_MUSIC_CAPABILITY_GENERAL (1<<0) … … 53 53 class Ieee1394Service { 54 54 public: 55 Ieee1394Service();56 ~Ieee1394Service();57 58 55 FBReturnCodes initialize(); 59 void shutdown(); 56 void shutdown(); 60 57 61 58 static Ieee1394Service* instance(); … … 65 62 66 63 protected: 67 static int resetHandler( raw1394handle_t handle, 64 static int resetHandler( raw1394handle_t handle, 68 65 unsigned int iGeneration ); 69 66 void setGenerationCount( unsigned int iGeneration ); … … 76 73 void printRomDirectory( int iNodeId, rom1394_directory* pRomDir ); 77 74 private: 75 Ieee1394Service(); 76 ~Ieee1394Service(); 77 78 78 static Ieee1394Service* m_pInstance; 79 79 raw1394handle_t m_handle;