Changeset 18
- Timestamp:
- 11/22/04 13:06:38 (18 years ago)
- Files:
-
- trunk/freebob/src/avdescriptor.cpp (added)
- trunk/freebob/src/avdescriptor.h (added)
- trunk/freebob/src/avdevice.cpp (modified) (1 diff)
- trunk/freebob/src/avdevice.h (modified) (1 diff)
- trunk/freebob/src/debugmodule.cpp (added)
- trunk/freebob/src/debugmodule.h (modified) (1 diff)
- trunk/freebob/src/ieee1394service.cpp (modified) (2 diffs)
- trunk/freebob/src/Makefile.am (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/freebob/src/avdevice.cpp
r16 r18 18 18 * MA 02111-1307 USA. 19 19 */ 20 20 #include <errno.h> 21 #include <libavc1394/avc1394.h> 22 #include <libavc1394/avc1394_vcr.h> 23 #include "debugmodule.h" 21 24 #include "avdevice.h" 22 25 23 AvDevice::AvDevice( )26 AvDevice::AvDevice(int port, int node) 24 27 { 28 iNodeId=node; 29 m_iPort=port; 30 31 // check to see if a device is really present? 32 } 33 34 FBReturnCodes 35 AvDevice::Initialize() { 36 if (!m_bInitialised) { 37 38 m_handle = raw1394_new_handle(); 39 if ( !m_handle ) { 40 if ( !errno ) { 41 fprintf( stderr, "libraw1394 not compatible.\n" ); 42 } else { 43 perror ("Could not get 1394 handle"); 44 fprintf (stderr, "Is ieee1394 and raw1394 driver loaded?\n"); 45 } 46 return eFBRC_Creating1394HandleFailed; 47 } 48 49 raw1394_set_userdata( m_handle, this ); 50 51 if ( raw1394_set_port( m_handle, m_iPort ) < 0 ) { 52 perror( "Could not set port" ); 53 return eFBRC_Setting1394PortFailed; 54 } 55 } 56 57 m_bInitialised = true; 58 return eFBRC_Success; 59 60 } 61 62 bool AvDevice::isInitialised() { 63 return m_bInitialised; 25 64 } 26 65 27 66 AvDevice::~AvDevice() 28 67 { 68 if ( m_handle ) { 69 raw1394_destroy_handle( m_handle ); 70 m_handle = 0; 71 } 29 72 } 73 74 /* Function to execute an AVC transaction, i.e. send command/status and get response 75 * main purpose is wrapping the avc1394 function call to output some debugging comments. 76 */ 77 quadlet_t * AvDevice::avcExecuteTransaction(quadlet_t *request, unsigned int request_len, unsigned int response_len) { 78 quadlet_t *response; 79 unsigned char *request_pos; 80 unsigned int i; 81 response = avc1394_transaction_block(m_handle, iNodeId, request, request_len, 2); 82 if (request != NULL) { 83 fprintf(stderr," REQUEST: "); 84 /* request is in machine byte order. this function is for intel architecure */ 85 for (i=0;i<request_len;i++) { 86 request_pos=(unsigned char *)(request+i); 87 fprintf(stderr, "0x%02X%02X%02X%02X ", *(request_pos),*(request_pos+1),*(request_pos+2),*(request_pos+3)); 88 } 89 fprintf(stderr,"\n"); 90 fprintf(stderr," => "); 91 fprintf(stderr," "); 92 request_pos=(unsigned char *)(request); 93 fprintf(stderr, "subunit_type=%02X subunit_id=%02X opcode=%02X",((*(request_pos+1))>>3)&0x1F,(*(request_pos+1))&0x07,(*(request_pos+2))&0xFF); 94 fprintf(stderr,"\n"); 95 } 96 if (response != NULL) { 97 /* response is in order of receiving, i.e. msb first */ 98 fprintf(stderr," -> RESPONSE: "); 99 for (i=0;i<response_len;i++) { 100 fprintf(stderr, "0x%08X ", response[i]); 101 } 102 fprintf(stderr,"\n"); 103 fprintf(stderr," => "); 104 switch (response[0]&0xFF000000) { 105 case AVC1394_RESPONSE_NOT_IMPLEMENTED: 106 fprintf(stderr,"Not Implemented "); 107 break; 108 case AVC1394_RESPONSE_ACCEPTED: 109 fprintf(stderr,"Accepted "); 110 break; 111 case AVC1394_RESPONSE_REJECTED: 112 fprintf(stderr,"Rejected "); 113 break; 114 case AVC1394_RESPONSE_IN_TRANSITION: 115 fprintf(stderr,"In Transition "); 116 break; 117 case AVC1394_RESPONSE_IMPLEMENTED: 118 fprintf(stderr,"Implemented / Stable "); 119 break; 120 case AVC1394_RESPONSE_CHANGED: 121 fprintf(stderr,"Changed "); 122 break; 123 case AVC1394_RESPONSE_INTERIM: 124 fprintf(stderr,"Interim "); 125 break; 126 default: 127 fprintf(stderr,"Unknown response "); 128 break; 129 } 130 fprintf(stderr, "subunit_type=%02X subunit_id=%02X opcode=%02X",(response[0]>>19)&0x1F,(response[0]>>16)&0x07,(response[0]>>8)&0xFF); 131 fprintf(stderr,"\n"); 132 } 133 return response; 134 135 } trunk/freebob/src/avdevice.h
r16 r18 22 22 #define AVDEVICE_H 23 23 24 #include "ieee1394service.h" 25 24 26 class AvDevice { 25 27 public: 26 AvDevice( );28 AvDevice(int node,int port); 27 29 virtual ~AvDevice(); 30 31 quadlet_t * avcExecuteTransaction(quadlet_t *request, unsigned int request_len, unsigned int response_len); 32 33 FBReturnCodes AvDevice::Initialize(); 34 35 bool AvDevice::isInitialised(); 36 37 private: 38 int iNodeId; 39 raw1394handle_t m_handle; 40 int m_iPort; 41 bool m_bInitialised; 28 42 }; 29 43 trunk/freebob/src/debugmodule.h
r14 r18 23 23 24 24 #include <stdio.h> 25 #include "ieee1394service.h" 25 26 26 27 #define DEBUG_LEVEL_INFO 5 trunk/freebob/src/ieee1394service.cpp
r17 r18 25 25 #include "debugmodule.h" 26 26 27 #include "avdevice.h" 28 #include "avdescriptor.h" 29 27 30 Ieee1394Service* Ieee1394Service::m_pInstance = 0; 28 31 … … 138 141 // XXX 139 142 // create avcDevice which discovers itself :) 143 144 // PP: just a static try, don't want to mess with the device manager yet... 145 // Remark: the AvDevice and AvDescriptor aren't debugged thouroughly yet! 146 // the following code is the only debug I had time for... to be continued! (later this week) 147 148 debugPrint (DEBUG_LEVEL_INFO, " Trying to create an AvDevice...\n",""); 149 AvDevice *test=new AvDevice(m_iPort, iNodeId); 150 debugPrint (DEBUG_LEVEL_INFO, " Created...\n",""); 151 test->Initialize(); 152 if (test->isInitialised()) { 153 debugPrint (DEBUG_LEVEL_INFO, " Init successfull...\n",""); 154 debugPrint (DEBUG_LEVEL_INFO, " Trying to create an AvDescriptor...\n",""); 155 AvDescriptor *testdesc=new AvDescriptor(test,AVC1394_SUBUNIT_TYPE_MUSIC | AVC1394_SUBUNIT_ID_0,0x00); 156 debugPrint (DEBUG_LEVEL_INFO, " Created...\n",""); 157 debugPrint (DEBUG_LEVEL_INFO, " Opening...\n",""); 158 testdesc->OpenReadOnly(); 159 160 161 debugPrint (DEBUG_LEVEL_INFO, " Closing...\n",""); 162 testdesc->Close(); 163 164 debugPrint (DEBUG_LEVEL_INFO, " Deleting AvDescriptor...\n",""); 165 delete testdesc; 166 167 } 168 debugPrint (DEBUG_LEVEL_INFO, " Deleting AvDevice...\n",""); 169 delete test; 170 140 171 } 141 172 break; trunk/freebob/src/Makefile.am
r16 r18 34 34 avdevicepool.h \ 35 35 avdevicepool.cpp \ 36 avdescriptor.h \ 37 avdescriptor.cpp \ 38 debugmodule.cpp \ 36 39 main.cpp 37 40