Changeset 42
- Timestamp:
- 12/05/04 14:36:17 (19 years ago)
- Files:
-
- trunk/freebob/src/avdevice.cpp (modified) (12 diffs)
- trunk/freebob/src/avdevice.h (modified) (4 diffs)
- trunk/freebob/src/avdevicepool.cpp (modified) (3 diffs)
- trunk/freebob/src/avdevicepool.h (modified) (2 diffs)
- trunk/freebob/src/ieee1394service.cpp (modified) (6 diffs)
- trunk/freebob/src/ieee1394service.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/freebob/src/avdevice.cpp
r40 r42 27 27 #include "avdevicemusicsubunit.h" 28 28 29 AvDevice::AvDevice( int port, int node)29 AvDevice::AvDevice(octlet_t oGuid) 30 30 { 31 iNodeId=node; 32 m_iPort=port; 33 34 // check to see if a device is really present? 35 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. 31 m_oGuid = oGuid; 41 32 } 42 33 43 34 FBReturnCodes 44 AvDevice::Initialize() { 45 46 if (!m_bInitialised) { 47 48 m_handle = raw1394_new_handle(); 35 AvDevice::initialize() { 36 if (!m_bInitialised) { 37 m_handle = raw1394_new_handle(); 49 38 if ( !m_handle ) { 50 39 if ( !errno ) { … … 161 150 tmpAvDeviceSubunit->unReserve(); 162 151 //setDebugLevel(DEBUG_LEVEL_MODERATE); 163 152 164 153 165 154 } else { … … 208 197 unsigned char *request_pos; 209 198 unsigned int i; 210 response = avc1394_transaction_block(m_handle, iNodeId, request, request_len, 2);199 response = avc1394_transaction_block(m_handle, m_iNodeId, request, request_len, 2); 211 200 if (request != NULL) { 212 201 debugPrint (DEBUG_LEVEL_TRANSFERS, "------- TRANSACTION START -------\n"); … … 275 264 response = avcExecuteTransaction(request, 2, 2); 276 265 if (response != NULL) { 277 278 } 279 266 267 } 268 return eFBRC_Success; 280 269 } 281 270 … … 292 281 *fdf=response[1]& 0x00FFFFFF; 293 282 } 294 295 } 283 return eFBRC_Success; 284 } 285 296 286 FBReturnCodes AvDevice::setOutputPlugSignalFormat(unsigned char plug, unsigned char fmt, quadlet_t fdf) { 297 287 quadlet_t request[6]; … … 303 293 response = avcExecuteTransaction(request, 2, 2); 304 294 if (response != NULL) { 305 306 } 307 295 296 } 297 return eFBRC_Success; 308 298 } 309 299 … … 320 310 *fdf=response[1]& 0x00FFFFFF; 321 311 } 322 312 return eFBRC_Success; 323 313 } 324 314 … … 340 330 quadlet_t *response; 341 331 //setDebugLevel(DEBUG_LEVEL_ALL); 342 343 debugPrint (DEBUG_LEVEL_DEVICE,"AvDevice: ISO source connections:\n"); 332 333 debugPrint (DEBUG_LEVEL_DEVICE,"AvDevice: ISO source connections:\n"); 344 334 345 335 for (unsigned int i=0;i<getNbIsoSourcePlugs();i++) { … … 347 337 | AVC1394_COMMAND_SIGNAL_SOURCE | 0xFF; 348 338 request[1]=0xFFFEFF00 | ((i & 0xFF)); 349 339 350 340 response = avcExecuteTransaction(request, 2, 2); 351 341 352 342 if (response != NULL) { 353 343 unsigned char output_status=(response[0]&0xE0) >> 5; 354 344 unsigned char conv=(response[0]&0x10) >> 4; 355 345 unsigned char signal_status=(response[0]&0x0F); 356 346 357 347 unsigned int signal_source=((response[1]>>16)&0xFFFF); 358 348 359 349 unsigned char source_subunit_type=(signal_source>>11)&0x1F; 360 350 unsigned char source_subunit_id=(signal_source>>8)&0x07; 361 351 unsigned char source_plug=signal_source&0xFF; 362 352 363 353 debugPrint (DEBUG_LEVEL_DEVICE,"AvDevice: OPCR 0x%02X <- subunit: 0x%02X/0x%02X, plug: 0x%02X (0x%02X / %d / 0x%02X)\n",i, source_subunit_type,source_subunit_id,source_plug,output_status,conv,signal_status); 364 // find the subunit this plug is connected to 354 // find the subunit this plug is connected to 365 355 AvDeviceSubunit *tmpSubunit=getSubunit(source_subunit_type,source_subunit_id); 366 356 if(tmpSubunit) { 367 357 tmpSubunit->printSourcePlugConnections(source_plug); 368 358 } 369 370 } 371 } 372 373 debugPrint (DEBUG_LEVEL_DEVICE,"AvDevice: External source connections:\n"); 359 360 } 361 } 362 363 debugPrint (DEBUG_LEVEL_DEVICE,"AvDevice: External source connections:\n"); 374 364 375 365 for (unsigned int i=0;i<getNbExtSourcePlugs();i++) { … … 377 367 | AVC1394_COMMAND_SIGNAL_SOURCE | 0xFF; 378 368 request[1]=0xFFFEFF00 | ((i & 0xFF)|0x80); 379 369 380 370 response = avcExecuteTransaction(request, 2, 2); 381 371 382 372 if (response != NULL) { 383 373 unsigned char output_status=(response[0]&0xE0) >> 5; 384 374 unsigned char conv=(response[0]&0x10) >> 4; 385 375 unsigned char signal_status=(response[0]&0x0F); 386 376 387 377 unsigned int signal_source=((response[1]>>16)&0xFFFF); 388 378 389 379 unsigned char source_subunit_type=(signal_source>>11)&0x1F; 390 380 unsigned char source_subunit_id=(signal_source>>8)&0x07; 391 381 unsigned char source_plug=signal_source&0xFF; 392 393 debugPrint (DEBUG_LEVEL_DEVICE,"AvDevice: EXTOUT 0x%02X <- subunit: 0x%02X/0x%02X, plug: 0x%02X (0x%02X / %d / 0x%02X)\n",i, source_subunit_type,source_subunit_id,source_plug,output_status,conv,signal_status); 394 395 // find the subunit this plug is connected to 382 383 debugPrint (DEBUG_LEVEL_DEVICE,"AvDevice: EXTOUT 0x%02X <- subunit: 0x%02X/0x%02X, plug: 0x%02X (0x%02X / %d / 0x%02X)\n",i, source_subunit_type,source_subunit_id,source_plug,output_status,conv,signal_status); 384 385 // find the subunit this plug is connected to 396 386 AvDeviceSubunit *tmpSubunit=getSubunit(source_subunit_type,source_subunit_id); 397 387 if(tmpSubunit) { 398 388 tmpSubunit->printSourcePlugConnections(source_plug); 399 } 400 } 401 } 402 403 debugPrint (DEBUG_LEVEL_DEVICE,"AvDevice: ISO sink connections:\n"); 389 } 390 } 391 } 392 393 debugPrint (DEBUG_LEVEL_DEVICE,"AvDevice: ISO sink connections:\n"); 404 394 405 395 for (unsigned int i=0;i<getNbIsoDestinationPlugs();i++) { … … 407 397 | AVC1394_COMMAND_SIGNAL_SOURCE | 0xFF; 408 398 request[1]=0xFFFEFF00 | ((i & 0xFF)); 409 399 410 400 response = avcExecuteTransaction(request, 2, 2); 411 401 412 402 if (response != NULL) { 413 403 unsigned char output_status=(response[0]&0xE0) >> 5; 414 404 unsigned char conv=(response[0]&0x10) >> 4; 415 405 unsigned char signal_status=(response[0]&0x0F); 416 406 417 407 unsigned int signal_source=((response[1]>>16)&0xFFFF); 418 408 419 409 unsigned char source_subunit_type=(signal_source>>11)&0x1F; 420 410 unsigned char source_subunit_id=(signal_source>>8)&0x07; 421 411 unsigned char source_plug=signal_source&0xFF; 422 412 423 413 debugPrint (DEBUG_LEVEL_DEVICE,"AvDevice: OPCR 0x%02X <- subunit: 0x%02X/0x%02X, plug: 0x%02X (0x%02X / %d / 0x%02X)\n",i, source_subunit_type,source_subunit_id,source_plug,output_status,conv,signal_status); 424 // find the subunit this plug is connected to 414 // find the subunit this plug is connected to 425 415 AvDeviceSubunit *tmpSubunit=getSubunit(source_subunit_type,source_subunit_id); 426 416 if(tmpSubunit) { 427 417 //tmpSubunit->printDestinationPlugConnections(source_plug); 428 418 } 429 430 } 431 } 432 433 debugPrint (DEBUG_LEVEL_DEVICE,"AvDevice: External sink connections:\n"); 419 420 } 421 } 422 423 debugPrint (DEBUG_LEVEL_DEVICE,"AvDevice: External sink connections:\n"); 434 424 435 425 for (unsigned int i=0;i<getNbExtDestinationPlugs();i++) { … … 437 427 | AVC1394_COMMAND_SIGNAL_SOURCE | 0xFF; 438 428 request[1]=0xFFFEFF00 | ((i & 0xFF)|0x80); 439 429 440 430 response = avcExecuteTransaction(request, 2, 2); 441 431 442 432 if (response != NULL) { 443 433 unsigned char output_status=(response[0]&0xE0) >> 5; 444 434 unsigned char conv=(response[0]&0x10) >> 4; 445 435 unsigned char signal_status=(response[0]&0x0F); 446 436 447 437 unsigned int signal_source=((response[1]>>16)&0xFFFF); 448 438 449 439 unsigned char source_subunit_type=(signal_source>>11)&0x1F; 450 440 unsigned char source_subunit_id=(signal_source>>8)&0x07; 451 441 unsigned char source_plug=signal_source&0xFF; 452 453 debugPrint (DEBUG_LEVEL_DEVICE,"AvDevice: EXTOUT 0x%02X <- subunit: 0x%02X/0x%02X, plug: 0x%02X (0x%02X / %d / 0x%02X)\n",i, source_subunit_type,source_subunit_id,source_plug,output_status,conv,signal_status); 454 455 // find the subunit this plug is connected to 442 443 debugPrint (DEBUG_LEVEL_DEVICE,"AvDevice: EXTOUT 0x%02X <- subunit: 0x%02X/0x%02X, plug: 0x%02X (0x%02X / %d / 0x%02X)\n",i, source_subunit_type,source_subunit_id,source_plug,output_status,conv,signal_status); 444 445 // find the subunit this plug is connected to 456 446 AvDeviceSubunit *tmpSubunit=getSubunit(source_subunit_type,source_subunit_id); 457 447 if(tmpSubunit) { 458 448 //tmpSubunit->printDestinationPlugConnections(source_plug); 459 } 460 } 461 } 462 463 } 449 } 450 } 451 } 452 453 } trunk/freebob/src/avdevice.h
r40 r42 19 19 * MA 02111-1307 USA. 20 20 */ 21 #ifndef AVDEVICE_H 22 #define AVDEVICE_H 21 23 22 24 #include "ieee1394service.h" … … 25 27 using std::vector; 26 28 27 28 #ifndef AVDEVICE_H29 #define AVDEVICE_H30 31 29 class AvDeviceSubunit; 32 30 33 31 class AvDevice { 34 32 public: 35 AvDevice( int node,int port);33 AvDevice( octlet_t oGuid ); 36 34 virtual ~AvDevice(); 37 35 38 quadlet_t * avcExecuteTransaction(quadlet_t *request, unsigned int request_len, unsigned int response_len); 36 void setNodeId( int iNodeId ) 37 { m_iNodeId = iNodeId; } 38 int getNodeId() 39 { return m_iNodeId; } 40 void setPort( int iPort ) 41 { m_iPort = iPort; } 42 void setGeneration( unsigned int iGeneration ) 43 { m_iGeneration = iGeneration; } 44 unsigned int getGeneration() 45 { return m_iGeneration; } 46 octlet_t getGuid() 47 { return m_oGuid; } 39 48 40 FBReturnCodes Initialize(); 41 49 quadlet_t * avcExecuteTransaction( quadlet_t *request, 50 unsigned int request_len, 51 unsigned int response_len ); 52 53 FBReturnCodes initialize(); 42 54 bool isInitialised(); 43 55 … … 56 68 unsigned char getNbExtSourcePlugs() { return iNbExtSourcePlugs; } ; 57 69 unsigned char getNbExtDestinationPlugs() { return iNbExtDestinationPlugs; } ; 58 59 int getNodeId() { return iNodeId; } ;60 70 61 71 protected: … … 63 73 64 74 private: 65 int iNodeId; 66 raw1394handle_t m_handle; 67 int m_iPort; 68 bool m_bInitialised; 69 vector<AvDeviceSubunit *> cSubUnits; 70 71 unsigned char iNbAsyncDestinationPlugs; 72 unsigned char iNbAsyncSourcePlugs; 73 unsigned char iNbIsoDestinationPlugs; 74 unsigned char iNbIsoSourcePlugs; 75 unsigned char iNbExtDestinationPlugs; 76 unsigned char iNbExtSourcePlugs; 77 75 int m_iNodeId; 76 raw1394handle_t m_handle; 77 int m_iPort; 78 bool m_bInitialised; 79 octlet_t m_oGuid; 80 unsigned int m_iGeneration; //Which generation this device belongs to 81 vector< AvDeviceSubunit * > cSubUnits; 82 83 unsigned char iNbAsyncDestinationPlugs; 84 unsigned char iNbAsyncSourcePlugs; 85 unsigned char iNbIsoDestinationPlugs; 86 unsigned char iNbIsoSourcePlugs; 87 unsigned char iNbExtDestinationPlugs; 88 unsigned char iNbExtSourcePlugs; 78 89 }; 79 90 trunk/freebob/src/avdevicepool.cpp
r16 r42 19 19 */ 20 20 21 #include <queue> 22 23 #include "avdevice.h" 21 24 #include "avdevicepool.h" 25 26 AvDevicePool* AvDevicePool::m_pInstance = 0; 22 27 23 28 AvDevicePool::AvDevicePool() … … 27 32 AvDevicePool::~AvDevicePool() 28 33 { 34 } 35 36 AvDevicePool* 37 AvDevicePool::instance() 38 { 39 if ( !m_pInstance ) { 40 m_pInstance = new AvDevicePool; 41 } 42 return m_pInstance; 29 43 } 30 44 … … 58 72 } 59 73 74 AvDevice* 75 AvDevicePool::getAvDevice(octlet_t oGuid) 76 { 77 AvDevice* pAvDevice = 0; 78 for ( AvDeviceVector::iterator iter = m_avDevices.begin(); 79 iter != m_avDevices.end(); 80 ++iter ) 81 { 82 if ( ( *iter )->getGuid() == oGuid ) { 83 pAvDevice = *iter; 84 break; 85 } 86 } 87 return pAvDevice; 88 } 89 90 FBReturnCodes 91 AvDevicePool::removeObsoleteDevices( unsigned int iGeneration ) 92 { 93 // XXX dw: removing elements can be done more elegant. 94 std::queue< AvDevice* > deleteQueue; 95 96 for ( AvDeviceVector::iterator iter = m_avDevices.begin(); 97 iter != m_avDevices.end(); 98 ++iter ) 99 { 100 if ( ( *iter )->getGeneration() < iGeneration ) { 101 deleteQueue.push( *iter ); 102 } 103 } 104 105 while ( !deleteQueue.empty() ) { 106 AvDevice* pAvDevice = deleteQueue.front(); 107 deleteQueue.pop(); 108 delete pAvDevice; 109 } 110 111 return eFBRC_Success; 112 } trunk/freebob/src/avdevicepool.h
r16 r42 23 23 #include "freebob.h" 24 24 #include <vector> 25 #include <libraw1394/raw1394.h> // octlet_t 25 26 26 27 class AvDevice; … … 28 29 class AvDevicePool { 29 30 public: 31 static AvDevicePool* instance(); 32 33 FBReturnCodes registerAvDevice( AvDevice* pAvDevice ); 34 FBReturnCodes unregisterAvDevice( AvDevice* pAvDevice ); 35 36 AvDevice* getAvDevice( octlet_t oGuid ); 37 38 /** 39 * Remove devices in pool which where (physically) removed 40 * from the bus. 41 * 42 * All devices which have a lower generation count smaller 43 * than iGeneration are removed from the pool 44 * 45 * @param iGeneration Current generation count. 46 * @return see FBReturnCodes. 47 */ 48 FBReturnCodes removeObsoleteDevices( unsigned int iGeneration ); 49 private: 30 50 AvDevicePool(); 31 51 ~AvDevicePool(); 32 52 33 FBReturnCodes registerAvDevice(AvDevice* pAvDevice); 34 FBReturnCodes unregisterAvDevice(AvDevice* pAvDevice); 35 private: 36 typedef std::vector<AvDevice*> AvDeviceVector; 53 static AvDevicePool* m_pInstance; 54 55 typedef std::vector< AvDevice* > AvDeviceVector; 37 56 AvDeviceVector m_avDevices; 38 57 }; trunk/freebob/src/ieee1394service.cpp
r40 r42 24 24 #include <libiec61883/iec61883.h> 25 25 26 27 26 #include "ieee1394service.h" 27 #include "threads.h" 28 28 #include "debugmodule.h" 29 #include "avdevicepool.h" 29 30 30 31 #include "avdevice.h" … … 104 105 startRHThread(); 105 106 106 discoveryDevices();107 107 m_bInitialised = true; 108 109 asyncCall( this, &Ieee1394Service::discoveryDevices, 110 m_iGenerationCount); 108 111 } 109 112 return eFBRC_Success; … … 126 129 127 130 FBReturnCodes 128 Ieee1394Service::discoveryDevices( )131 Ieee1394Service::discoveryDevices( unsigned int iGeneration ) 129 132 { 130 133 //scan bus … … 152 155 AVC1394_SUBUNIT_TYPE_AUDIO ) ) { 153 156 154 // XXX 155 // create avcDevice which discovers itself :) 156 157 // PP: just a static try, don't want to mess with the device manager yet... 158 // Remark: the AvDevice and AvDescriptor aren't debugged thouroughly yet! 159 // the following code is the only debug I had time for... to be continued! (later this week) 160 debugPrint (DEBUG_LEVEL_INFO, " Trying to create an AvDevice...\n"); 161 162 AvDevice *test=new AvDevice(m_iPort, iNodeId); 163 debugPrint (DEBUG_LEVEL_INFO, " Created...\n"); 164 test->Initialize(); 165 if (test->isInitialised()) { 166 unsigned char fmt; 167 quadlet_t fdf; 168 test->getInputPlugSignalFormat(0,&fmt,&fdf); 169 debugPrint (DEBUG_LEVEL_INFO, " fmt=%02X fdf=%08X\n",fmt,fdf); 170 test->getInputPlugSignalFormat(1,&fmt,&fdf); 171 debugPrint (DEBUG_LEVEL_INFO, " fmt=%02X fdf=%08X\n",fmt,fdf); 172 test->getOutputPlugSignalFormat(0,&fmt,&fdf); 173 debugPrint (DEBUG_LEVEL_INFO, " fmt=%02X fdf=%08X\n",fmt,fdf); 174 test->getOutputPlugSignalFormat(1,&fmt,&fdf); 175 debugPrint (DEBUG_LEVEL_INFO, " fmt=%02X fdf=%08X\n",fmt,fdf); 176 test->printConnections(); 177 } 178 179 debugPrint (DEBUG_LEVEL_INFO, " Deleting AvDevice...\n"); 180 delete test; 181 157 octlet_t oGuid = rom1394_get_guid( m_handle, iNodeId ); 158 AvDevice* pAvDevice 159 = AvDevicePool::instance()->getAvDevice( oGuid ); 160 if ( !pAvDevice ) { 161 pAvDevice = new AvDevice( oGuid ); 162 } 163 pAvDevice->setNodeId( iNodeId ); 164 pAvDevice->setPort( m_iPort ); 165 166 if ( !pAvDevice->isInitialised() ) { 167 FBReturnCodes eStatus = pAvDevice->initialize(); 168 if ( eStatus != eFBRC_Success ) { 169 debugError( "AvDevice with GUID 0x%08x%08x could " 170 "not be initialized\n", 171 (quadlet_t) (oGuid>>32), 172 (quadlet_t) (oGuid & 0xffffffff) ); 173 174 delete pAvDevice; 175 return eStatus; 176 } 177 } 178 179 // XXX Pieter's test code. 180 avDeviceTests( oGuid, m_iPort, iNodeId ); 182 181 } 183 182 break; … … 195 194 } 196 195 } 196 197 AvDevicePool::instance()->removeObsoleteDevices( iGeneration ); 197 198 return eFBRC_Success; 198 199 } 200 201 202 void 203 Ieee1394Service::avDeviceTests(octlet_t oGuid, int iPort, int iNodeId) 204 { 205 // PP: just a static try, don't want to mess with the device manager yet... 206 // Remark: the AvDevice and AvDescriptor aren't debugged thouroughly yet! 207 // the following code is the only debug I had time for... to be continued! (later this week) 208 debugPrint (DEBUG_LEVEL_INFO, " Trying to create an AvDevice...\n"); 209 210 AvDevice *test=new AvDevice(oGuid); 211 test->setNodeId( iNodeId ); 212 test->setPort( iPort ); 213 debugPrint (DEBUG_LEVEL_INFO, " Created...\n"); 214 test->initialize(); 215 if (test->isInitialised()) { 216 unsigned char fmt; 217 quadlet_t fdf; 218 test->getInputPlugSignalFormat(0,&fmt,&fdf); 219 debugPrint (DEBUG_LEVEL_INFO, " fmt=%02X fdf=%08X\n",fmt,fdf); 220 test->getInputPlugSignalFormat(1,&fmt,&fdf); 221 debugPrint (DEBUG_LEVEL_INFO, " fmt=%02X fdf=%08X\n",fmt,fdf); 222 test->getOutputPlugSignalFormat(0,&fmt,&fdf); 223 debugPrint (DEBUG_LEVEL_INFO, " fmt=%02X fdf=%08X\n",fmt,fdf); 224 test->getOutputPlugSignalFormat(1,&fmt,&fdf); 225 debugPrint (DEBUG_LEVEL_INFO, " fmt=%02X fdf=%08X\n",fmt,fdf); 226 test->printConnections(); 227 } 228 229 debugPrint (DEBUG_LEVEL_INFO, " Deleting AvDevice...\n"); 230 delete test; 231 } 232 199 233 200 234 void … … 309 343 = (Ieee1394Service*) raw1394_get_userdata (handle); 310 344 pInstance->setGenerationCount( iGeneration ); 345 346 // dw: let's rescan the bus. this might not the correct order 347 // of commands. 348 asyncCall( pInstance, &Ieee1394Service::discoveryDevices, iGeneration ); 311 349 return 0; 312 350 } trunk/freebob/src/ieee1394service.h
r31 r42 57 57 58 58 static Ieee1394Service* instance(); 59 FBReturnCodes discoveryDevices( );59 FBReturnCodes discoveryDevices( unsigned int iGenerationCount ); 60 60 61 61 unsigned int getGenerationCount(); … … 72 72 void printAvcUnitInfo( int iNodeId ); 73 73 void printRomDirectory( int iNodeId, rom1394_directory* pRomDir ); 74 75 void avDeviceTests( octlet_t oGuid, int iPort, int iNodeId ); 74 76 private: 75 77 Ieee1394Service(); … … 79 81 raw1394handle_t m_handle; 80 82 raw1394handle_t m_rhHandle; 81 int m_iPort; 83 int m_iPort; // XXX dw: port in 1394 service makes no sense 82 84 bool m_bInitialised; 83 85 pthread_t m_thread;