1 |
/* avdevice.cpp |
---|
2 |
* Copyright (C) 2004 by Daniel Wagner, Pieter Palmers |
---|
3 |
* |
---|
4 |
* This file is part of FreeBob. |
---|
5 |
* |
---|
6 |
* FreeBob is free software; you can redistribute it and/or modify |
---|
7 |
* it under the terms of the GNU General Public License as published by |
---|
8 |
* the Free Software Foundation; either version 2 of the License, or |
---|
9 |
* (at your option) any later version. |
---|
10 |
* FreeBob is distributed in the hope that it will be useful, |
---|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
13 |
* GNU General Public License for more details. |
---|
14 |
* |
---|
15 |
* You should have received a copy of the GNU General Public License |
---|
16 |
* along with FreeBob; if not, write to the Free Software |
---|
17 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
---|
18 |
* MA 02111-1307 USA. |
---|
19 |
*/ |
---|
20 |
#include <errno.h> |
---|
21 |
#include <libavc1394/avc1394.h> |
---|
22 |
#include <libavc1394/avc1394_vcr.h> |
---|
23 |
#include "avdevice.h" |
---|
24 |
#include "avdevicepool.h" |
---|
25 |
#include "avdevicesubunit.h" |
---|
26 |
#include "avdeviceaudiosubunit.h" |
---|
27 |
#include "avdevicemusicsubunit.h" |
---|
28 |
|
---|
29 |
#undef AVC1394_GET_RESPONSE_OPERAN |
---|
30 |
#define AVC1394_GET_RESPONSE_OPERAND(x, n) (((x) & (0xFF000000 >> (((n)%4)*8))) >> (((3-(n))%4)*8)) |
---|
31 |
|
---|
32 |
AvDevice::AvDevice(octlet_t oGuid) |
---|
33 |
: m_iNodeId( -1 ) |
---|
34 |
, m_handle( 0 ) |
---|
35 |
, m_iPort( -1 ) |
---|
36 |
, m_bInitialised( false ) |
---|
37 |
, m_oGuid( oGuid ) |
---|
38 |
, m_iGeneration( 0 ) |
---|
39 |
, cSubUnits( 0 ) |
---|
40 |
, m_iNbAsyncDestinationPlugs( 0 ) |
---|
41 |
, m_iNbAsyncSourcePlugs( 0 ) |
---|
42 |
, m_iNbIsoDestinationPlugs( 0 ) |
---|
43 |
, m_iNbIsoSourcePlugs( 0 ) |
---|
44 |
, m_iNbExtDestinationPlugs( 0 ) |
---|
45 |
, m_iNbExtSourcePlugs( 0 ) |
---|
46 |
{ |
---|
47 |
setDebugLevel( DEBUG_LEVEL_MODERATE ); |
---|
48 |
AvDevicePool::instance()->registerAvDevice( this ); |
---|
49 |
} |
---|
50 |
|
---|
51 |
|
---|
52 |
AvDevice::~AvDevice() |
---|
53 |
{ |
---|
54 |
vector<AvDeviceSubunit *>::iterator it; |
---|
55 |
for( it = cSubUnits.begin(); it != cSubUnits.end(); it++ ) { |
---|
56 |
delete *it; |
---|
57 |
} |
---|
58 |
|
---|
59 |
if ( m_handle ) { |
---|
60 |
raw1394_destroy_handle( m_handle ); |
---|
61 |
m_handle = 0; |
---|
62 |
} |
---|
63 |
AvDevicePool::instance()->unregisterAvDevice( this ); |
---|
64 |
} |
---|
65 |
|
---|
66 |
FBReturnCodes |
---|
67 |
AvDevice::initialize() |
---|
68 |
{ |
---|
69 |
if ( !m_bInitialised ) { |
---|
70 |
FBReturnCodes eStatus = create1394RawHandle(); |
---|
71 |
if ( eStatus != eFBRC_Success ) { |
---|
72 |
debugError( "Could not create 1394 raw handle\n" ); |
---|
73 |
return eStatus; |
---|
74 |
} |
---|
75 |
|
---|
76 |
eStatus = enumerateSubUnits(); |
---|
77 |
if ( eStatus != eFBRC_Success ) { |
---|
78 |
debugError( "Could not enumrate SubUnits\n" ); |
---|
79 |
return eStatus; |
---|
80 |
} |
---|
81 |
|
---|
82 |
m_bInitialised = true; |
---|
83 |
} |
---|
84 |
return eFBRC_Success; |
---|
85 |
} |
---|
86 |
|
---|
87 |
bool AvDevice::isInitialised() |
---|
88 |
{ |
---|
89 |
return m_bInitialised; |
---|
90 |
} |
---|
91 |
|
---|
92 |
FBReturnCodes AvDevice::create1394RawHandle() |
---|
93 |
{ |
---|
94 |
m_handle = raw1394_new_handle(); |
---|
95 |
if ( !m_handle ) { |
---|
96 |
if ( !errno ) { |
---|
97 |
debugPrint( DEBUG_LEVEL_DEVICE, |
---|
98 |
"libraw1394 not compatible.\n" ); |
---|
99 |
} else { |
---|
100 |
perror( "Could not get 1394 handle" ); |
---|
101 |
debugPrint(DEBUG_LEVEL_DEVICE, |
---|
102 |
"Is ieee1394 and raw1394 driver loaded?\n"); |
---|
103 |
} |
---|
104 |
return eFBRC_Creating1394HandleFailed; |
---|
105 |
} |
---|
106 |
|
---|
107 |
raw1394_set_userdata( m_handle, this ); |
---|
108 |
|
---|
109 |
if ( raw1394_set_port( m_handle, m_iPort ) < 0 ) { |
---|
110 |
perror( "Could not set port" ); |
---|
111 |
return eFBRC_Setting1394PortFailed; |
---|
112 |
} |
---|
113 |
return eFBRC_Success; |
---|
114 |
} |
---|
115 |
|
---|
116 |
FBReturnCodes |
---|
117 |
AvDevice::enumerateSubUnits() |
---|
118 |
{ |
---|
119 |
// enumerate the subunits present in this device, create an |
---|
120 |
// AvDeviceSubunit for them, and add this object to the cSubUnits |
---|
121 |
// vector |
---|
122 |
unsigned char table_entry; |
---|
123 |
unsigned char subunit_maxid; |
---|
124 |
unsigned char subunit_type; |
---|
125 |
// buffer these table entries, because the memory content pointed |
---|
126 |
// to by the response pointer can change due to other libraw |
---|
127 |
// operations on this handle |
---|
128 |
quadlet_t table_entries; |
---|
129 |
quadlet_t request[6]; |
---|
130 |
quadlet_t *response; |
---|
131 |
AvDeviceSubunit *tmpAvDeviceSubunit=NULL; |
---|
132 |
|
---|
133 |
// check the number of I/O plugs |
---|
134 |
request[0] = AVC1394_CTYPE_STATUS |
---|
135 |
| AVC1394_SUBUNIT_TYPE_UNIT |
---|
136 |
| AVC1394_SUBUNIT_ID_IGNORE |
---|
137 |
| AVC1394_COMMAND_PLUG_INFO |
---|
138 |
| 0x0000; |
---|
139 |
request[1] = 0xFFFFFFFF; |
---|
140 |
response = avcExecuteTransaction( request, 2, 2 ); |
---|
141 |
request[1] = 0x02020606; |
---|
142 |
response = request; |
---|
143 |
if ( response ) { |
---|
144 |
m_iNbIsoDestinationPlugs |
---|
145 |
= AVC1394_GET_RESPONSE_OPERAND( response[1], 0 ); |
---|
146 |
m_iNbIsoSourcePlugs |
---|
147 |
= AVC1394_GET_RESPONSE_OPERAND( response[1], 1 ); |
---|
148 |
m_iNbExtDestinationPlugs |
---|
149 |
= AVC1394_GET_RESPONSE_OPERAND( response[1], 2 ); |
---|
150 |
m_iNbExtSourcePlugs |
---|
151 |
= AVC1394_GET_RESPONSE_OPERAND( response[1], 3 ); |
---|
152 |
} |
---|
153 |
|
---|
154 |
request[0] = AVC1394_CTYPE_STATUS |
---|
155 |
| AVC1394_SUBUNIT_TYPE_UNIT |
---|
156 |
| AVC1394_SUBUNIT_ID_IGNORE |
---|
157 |
| AVC1394_COMMAND_PLUG_INFO |
---|
158 |
| 0x01; |
---|
159 |
request[1] = 0xFFFFFFFF; |
---|
160 |
response = avcExecuteTransaction( request, 2, 2 ); |
---|
161 |
if ( response != NULL ) { |
---|
162 |
m_iNbAsyncDestinationPlugs |
---|
163 |
= AVC1394_GET_RESPONSE_OPERAND( response[1], 0 ); |
---|
164 |
m_iNbAsyncSourcePlugs |
---|
165 |
= AVC1394_GET_RESPONSE_OPERAND( response[1], 1 ); |
---|
166 |
} |
---|
167 |
|
---|
168 |
debugPrint( DEBUG_LEVEL_DEVICE, |
---|
169 |
"AvDevice: %d Isochronous source plugs, " |
---|
170 |
"%d Isochronous destination plugs\n", |
---|
171 |
m_iNbIsoSourcePlugs, m_iNbIsoDestinationPlugs); |
---|
172 |
debugPrint( DEBUG_LEVEL_DEVICE, |
---|
173 |
"AvDevice: %d External source plugs, " |
---|
174 |
"%d External destination plugs\n", |
---|
175 |
m_iNbExtSourcePlugs, m_iNbExtDestinationPlugs); |
---|
176 |
debugPrint( DEBUG_LEVEL_DEVICE, |
---|
177 |
"AvDevice: %d Asynchronous source plugs, " |
---|
178 |
"%d Asynchronous destination plugs\n", |
---|
179 |
m_iNbAsyncSourcePlugs, m_iNbAsyncDestinationPlugs); |
---|
180 |
|
---|
181 |
// create the subunits |
---|
182 |
for (unsigned int i = 0; i < 8; i++ ) { |
---|
183 |
// cycle through the 8 pages (max 32 subunits; 4 |
---|
184 |
// subunits/page) |
---|
185 |
|
---|
186 |
|
---|
187 |
request[0] = AVC1394_CTYPE_STATUS |
---|
188 |
| AVC1394_SUBUNIT_TYPE_UNIT |
---|
189 |
| AVC1394_SUBUNIT_ID_IGNORE |
---|
190 |
| AVC1394_COMMAND_SUBUNIT_INFO |
---|
191 |
| ((i<<4) & 0xF0) | 0x07; |
---|
192 |
request[1] = 0xFFFFFFFF; |
---|
193 |
response = avcExecuteTransaction( request, 6, 2 ); |
---|
194 |
|
---|
195 |
table_entries=response[1]; /// XXX buggy code! response could be 0! |
---|
196 |
|
---|
197 |
if ( response != NULL ) { |
---|
198 |
// this way of processing the table entries assumes that |
---|
199 |
// the subunit type is not "extended" |
---|
200 |
|
---|
201 |
// stop processing when a "not implemented" is received |
---|
202 |
// (according to spec) |
---|
203 |
if ( (response[0]&0xFF000000) == AVC1394_RESPONSE_NOT_IMPLEMENTED) { |
---|
204 |
break; |
---|
205 |
} |
---|
206 |
|
---|
207 |
// warning: don't do unsigned int j! |
---|
208 |
// comparison >= 0 is always true for uint |
---|
209 |
for ( int j = 3; j >= 0; j-- ) { |
---|
210 |
// cycle through the 8 pages (max 32 |
---|
211 |
// subunits; 4 subunits/page) |
---|
212 |
table_entry = (table_entries >> (j*8)) & 0xFF; |
---|
213 |
subunit_maxid = table_entry & 0x07; |
---|
214 |
subunit_type = (table_entry >> 3) & 0x1F; |
---|
215 |
|
---|
216 |
//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); |
---|
217 |
|
---|
218 |
// according to spec we could stop processing at the |
---|
219 |
// first 0xFF entry, but doing it this way is a little |
---|
220 |
// more robust |
---|
221 |
|
---|
222 |
if ( table_entry != 0xFF ) { |
---|
223 |
for ( unsigned char subunit_id = 0; |
---|
224 |
subunit_id < subunit_maxid+1; |
---|
225 |
subunit_id++ ) |
---|
226 |
{ |
---|
227 |
|
---|
228 |
// only two types of specific subunits are |
---|
229 |
// supported: audio and music |
---|
230 |
switch ( subunit_type ) { |
---|
231 |
case 0x01: // audio subunit |
---|
232 |
tmpAvDeviceSubunit |
---|
233 |
= new AvDeviceAudioSubunit( this, subunit_id); |
---|
234 |
if ( tmpAvDeviceSubunit ) { |
---|
235 |
// test code |
---|
236 |
//tmpAvDeviceSubunit->printOutputPlugConnections(); |
---|
237 |
} |
---|
238 |
break; |
---|
239 |
case 0x0C: // music subunit |
---|
240 |
tmpAvDeviceSubunit=new AvDeviceMusicSubunit(this,subunit_id); |
---|
241 |
/*{ // just a test |
---|
242 |
AvDeviceMusicSubunit tmpAvDeviceSubunit2(this,subunit_id); |
---|
243 |
tmpAvDeviceSubunit2.printMusicPlugInfo(); |
---|
244 |
tmpAvDeviceSubunit2.printMusicPlugConfigurations(); |
---|
245 |
tmpAvDeviceSubunit2.printOutputPlugConnections(); |
---|
246 |
tmpAvDeviceSubunit2.test(); |
---|
247 |
}*/ |
---|
248 |
break; |
---|
249 |
|
---|
250 |
default: // generic |
---|
251 |
tmpAvDeviceSubunit=new AvDeviceSubunit(this,subunit_type,subunit_id); |
---|
252 |
break; |
---|
253 |
} |
---|
254 |
|
---|
255 |
if ( tmpAvDeviceSubunit |
---|
256 |
&& tmpAvDeviceSubunit->isValid() ) |
---|
257 |
{ |
---|
258 |
cSubUnits.push_back(tmpAvDeviceSubunit); |
---|
259 |
//setDebugLevel(DEBUG_LEVEL_ALL); |
---|
260 |
debugPrint( DEBUG_LEVEL_DEVICE, |
---|
261 |
"Trying to reserve the " |
---|
262 |
"subunit...\n" ); |
---|
263 |
tmpAvDeviceSubunit->reserve( 0x01 ); |
---|
264 |
debugPrint( DEBUG_LEVEL_DEVICE, |
---|
265 |
" isReserved?: %d\n", |
---|
266 |
tmpAvDeviceSubunit->isReserved()); |
---|
267 |
tmpAvDeviceSubunit->unReserve(); |
---|
268 |
//setDebugLevel(DEBUG_LEVEL_MODERATE); |
---|
269 |
} else { |
---|
270 |
if ( tmpAvDeviceSubunit ) { |
---|
271 |
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); |
---|
272 |
|
---|
273 |
delete tmpAvDeviceSubunit; |
---|
274 |
} else { |
---|
275 |
debugPrint( DEBUG_LEVEL_DEVICE, |
---|
276 |
"AvDevice: Could not create AvDeviceSubunit object.\n"); |
---|
277 |
} |
---|
278 |
} |
---|
279 |
} |
---|
280 |
} |
---|
281 |
} |
---|
282 |
} |
---|
283 |
} |
---|
284 |
return eFBRC_Success; |
---|
285 |
} |
---|
286 |
|
---|
287 |
/* Function to execute an AVC transaction, i.e. send command/status |
---|
288 |
* and get response main purpose is wrapping the avc1394 function call |
---|
289 |
* to output some debugging comments. |
---|
290 |
*/ |
---|
291 |
quadlet_t* |
---|
292 |
AvDevice::avcExecuteTransaction( quadlet_t* request, |
---|
293 |
unsigned int request_len, |
---|
294 |
unsigned int response_len ) |
---|
295 |
{ |
---|
296 |
quadlet_t* response; |
---|
297 |
unsigned char* request_pos; |
---|
298 |
unsigned int i; |
---|
299 |
|
---|
300 |
response = avc1394_transaction_block( m_handle, |
---|
301 |
m_iNodeId, |
---|
302 |
request, |
---|
303 |
request_len, |
---|
304 |
2 ); |
---|
305 |
if ( request ) { |
---|
306 |
debugPrint( DEBUG_LEVEL_TRANSFERS, |
---|
307 |
"------- TRANSACTION START -------\n" ); |
---|
308 |
debugPrint( DEBUG_LEVEL_TRANSFERS," REQUEST: " ); |
---|
309 |
/* request is in machine byte order. this function is for |
---|
310 |
* intel architecure */ |
---|
311 |
for ( i = 0; i < request_len; i++ ) { |
---|
312 |
request_pos = (unsigned char *)(request+i); |
---|
313 |
debugPrintShort( DEBUG_LEVEL_TRANSFERS, |
---|
314 |
"0x%02X%02X%02X%02X ", |
---|
315 |
*(request_pos), |
---|
316 |
*(request_pos+1), |
---|
317 |
*(request_pos+2), |
---|
318 |
*(request_pos+3)); |
---|
319 |
} |
---|
320 |
debugPrintShort( DEBUG_LEVEL_TRANSFERS, "\n" ); |
---|
321 |
debugPrint( DEBUG_LEVEL_TRANSFERS, " => " ); |
---|
322 |
debugPrintShort( DEBUG_LEVEL_TRANSFERS, " " ); |
---|
323 |
|
---|
324 |
request_pos = (unsigned char *)(request); |
---|
325 |
|
---|
326 |
debugPrintShort( DEBUG_LEVEL_TRANSFERS, |
---|
327 |
"subunit_type=%02X subunit_id=%02X opcode=%02X", |
---|
328 |
((*(request_pos+1))>>3)&0x1F, |
---|
329 |
(*(request_pos+1))&0x07, |
---|
330 |
(*(request_pos+2))&0xFF ); |
---|
331 |
debugPrintShort (DEBUG_LEVEL_TRANSFERS,"\n"); |
---|
332 |
} |
---|
333 |
|
---|
334 |
if ( response ) { |
---|
335 |
/* response is in order of receiving, i.e. msb first */ |
---|
336 |
debugPrint(DEBUG_LEVEL_TRANSFERS, " -> RESPONSE: " ); |
---|
337 |
for ( i = 0; i < response_len; i++ ) { |
---|
338 |
debugPrintShort( DEBUG_LEVEL_TRANSFERS, "0x%08X ", response[i] ); |
---|
339 |
} |
---|
340 |
|
---|
341 |
debugPrintShort( DEBUG_LEVEL_TRANSFERS,"\n" ); |
---|
342 |
debugPrint( DEBUG_LEVEL_TRANSFERS," => " ); |
---|
343 |
switch (response[0]&0xFF000000) { |
---|
344 |
case AVC1394_RESPONSE_NOT_IMPLEMENTED: |
---|
345 |
debugPrintShort( DEBUG_LEVEL_TRANSFERS, "Not Implemented " ); |
---|
346 |
break; |
---|
347 |
case AVC1394_RESPONSE_ACCEPTED: |
---|
348 |
debugPrintShort( DEBUG_LEVEL_TRANSFERS, "Accepted " ); |
---|
349 |
break; |
---|
350 |
case AVC1394_RESPONSE_REJECTED: |
---|
351 |
debugPrintShort( DEBUG_LEVEL_TRANSFERS, "Rejected " ); |
---|
352 |
break; |
---|
353 |
case AVC1394_RESPONSE_IN_TRANSITION: |
---|
354 |
debugPrintShort( DEBUG_LEVEL_TRANSFERS, "In Transition " ); |
---|
355 |
break; |
---|
356 |
case AVC1394_RESPONSE_IMPLEMENTED: |
---|
357 |
debugPrintShort( DEBUG_LEVEL_TRANSFERS, "Implemented / Stable " ); |
---|
358 |
break; |
---|
359 |
case AVC1394_RESPONSE_CHANGED: |
---|
360 |
debugPrintShort( DEBUG_LEVEL_TRANSFERS, "Changed " ); |
---|
361 |
break; |
---|
362 |
case AVC1394_RESPONSE_INTERIM: |
---|
363 |
debugPrintShort( DEBUG_LEVEL_TRANSFERS, "Interim " ); |
---|
364 |
break; |
---|
365 |
default: |
---|
366 |
debugPrintShort( DEBUG_LEVEL_TRANSFERS, "Unknown response " ); |
---|
367 |
break; |
---|
368 |
} |
---|
369 |
debugPrintShort( DEBUG_LEVEL_TRANSFERS, |
---|
370 |
"subunit_type=%02X subunit_id=%02X opcode=%02X", |
---|
371 |
(response[0]>>19)&0x1F, |
---|
372 |
(response[0]>>16)&0x07, |
---|
373 |
(response[0]>>8)&0xFF ); |
---|
374 |
debugPrintShort( DEBUG_LEVEL_TRANSFERS, "\n" ); |
---|
375 |
} |
---|
376 |
debugPrint( DEBUG_LEVEL_TRANSFERS, "------- TRANSACTION END -------\n" ); |
---|
377 |
return response; |
---|
378 |
} |
---|
379 |
|
---|
380 |
FBReturnCodes AvDevice::setInputPlugSignalFormat(unsigned char plug, unsigned char fmt, quadlet_t fdf) { |
---|
381 |
quadlet_t request[6]; |
---|
382 |
quadlet_t *response; |
---|
383 |
|
---|
384 |
request[0] = AVC1394_CTYPE_CONTROL | AVC1394_SUBUNIT_TYPE_UNIT | AVC1394_SUBUNIT_ID_IGNORE |
---|
385 |
| AVC1394_COMMAND_INPUT_PLUG_SIGNAL_FORMAT | plug; |
---|
386 |
request[1] = (0x80000000) | ((fmt & 0x3F)<<24) | (fdf & 0x00FFFFFF); |
---|
387 |
response = avcExecuteTransaction(request, 2, 2); |
---|
388 |
if (response != NULL) { |
---|
389 |
|
---|
390 |
} |
---|
391 |
return eFBRC_Success; |
---|
392 |
} |
---|
393 |
|
---|
394 |
FBReturnCodes AvDevice::getInputPlugSignalFormat(unsigned char plug, unsigned char *fmt, quadlet_t *fdf) { |
---|
395 |
quadlet_t request[6]; |
---|
396 |
quadlet_t *response; |
---|
397 |
|
---|
398 |
request[0] = AVC1394_CTYPE_STATUS | AVC1394_SUBUNIT_TYPE_UNIT | AVC1394_SUBUNIT_ID_IGNORE |
---|
399 |
| AVC1394_COMMAND_INPUT_PLUG_SIGNAL_FORMAT | plug; |
---|
400 |
request[1] = 0xFFFFFFFF; |
---|
401 |
response = avcExecuteTransaction(request, 2, 2); |
---|
402 |
if (response != NULL) { |
---|
403 |
*fmt=((response[1] >> 24) & 0x3F); |
---|
404 |
*fdf=response[1]& 0x00FFFFFF; |
---|
405 |
} |
---|
406 |
return eFBRC_Success; |
---|
407 |
} |
---|
408 |
|
---|
409 |
FBReturnCodes AvDevice::setOutputPlugSignalFormat(unsigned char plug, unsigned char fmt, quadlet_t fdf) { |
---|
410 |
quadlet_t request[6]; |
---|
411 |
quadlet_t *response; |
---|
412 |
|
---|
413 |
request[0] = AVC1394_CTYPE_CONTROL | AVC1394_SUBUNIT_TYPE_UNIT | AVC1394_SUBUNIT_ID_IGNORE |
---|
414 |
| AVC1394_COMMAND_OUTPUT_PLUG_SIGNAL_FORMAT | plug; |
---|
415 |
request[1] = (0x80000000) | ((fmt & 0x3F)<<24) | (fdf & 0x00FFFFFF); |
---|
416 |
response = avcExecuteTransaction(request, 2, 2); |
---|
417 |
if (response != NULL) { |
---|
418 |
|
---|
419 |
} |
---|
420 |
return eFBRC_Success; |
---|
421 |
} |
---|
422 |
|
---|
423 |
FBReturnCodes AvDevice::getOutputPlugSignalFormat(unsigned char plug, unsigned char *fmt, quadlet_t *fdf) { |
---|
424 |
quadlet_t request[6]; |
---|
425 |
quadlet_t *response; |
---|
426 |
|
---|
427 |
request[0] = AVC1394_CTYPE_STATUS | AVC1394_SUBUNIT_TYPE_UNIT | AVC1394_SUBUNIT_ID_IGNORE |
---|
428 |
| AVC1394_COMMAND_OUTPUT_PLUG_SIGNAL_FORMAT | plug; |
---|
429 |
request[1] = 0xFFFFFFFF; |
---|
430 |
response = avcExecuteTransaction(request, 2, 2); |
---|
431 |
if (response != NULL) { |
---|
432 |
*fmt=((response[1] >> 24) & 0x3F); |
---|
433 |
*fdf=response[1]& 0x00FFFFFF; |
---|
434 |
} |
---|
435 |
return eFBRC_Success; |
---|
436 |
} |
---|
437 |
|
---|
438 |
AvDeviceSubunit *AvDevice::getSubunit(unsigned char type, unsigned char id) { |
---|
439 |
vector<AvDeviceSubunit *>::iterator it; |
---|
440 |
for( it = cSubUnits.begin(); it != cSubUnits.end(); it++ ) { |
---|
441 |
if ((*it) && ((*it)->getType()==type) && ((*it)->getId()==id)) { |
---|
442 |
return *it; |
---|
443 |
} |
---|
444 |
} |
---|
445 |
return NULL; |
---|
446 |
} |
---|
447 |
|
---|
448 |
#define AVC1394_COMMAND_SIGNAL_SOURCE 0x00001A00 |
---|
449 |
|
---|
450 |
void AvDevice::printConnections() { |
---|
451 |
quadlet_t request[6]; |
---|
452 |
quadlet_t *response; |
---|
453 |
//setDebugLevel(DEBUG_LEVEL_ALL); |
---|
454 |
|
---|
455 |
debugPrint (DEBUG_LEVEL_DEVICE,"AvDevice: ISO source connections:\n"); |
---|
456 |
|
---|
457 |
for (unsigned int i=0;i<getNbIsoSourcePlugs();i++) { |
---|
458 |
request[0] = AVC1394_CTYPE_STATUS |
---|
459 |
| AVC1394_SUBUNIT_TYPE_UNIT |
---|
460 |
| AVC1394_SUBUNIT_ID_IGNORE |
---|
461 |
| AVC1394_COMMAND_SIGNAL_SOURCE |
---|
462 |
| 0x00FF; |
---|
463 |
request[1]=0xFFFEFF00 | ((i & 0xFF)); |
---|
464 |
|
---|
465 |
response = avcExecuteTransaction(request, 2, 2); |
---|
466 |
|
---|
467 |
if ( response ) { |
---|
468 |
unsigned char output_status=(response[0]&0xE0) >> 5; |
---|
469 |
unsigned char conv=(response[0]&0x10) >> 4; |
---|
470 |
unsigned char signal_status=(response[0]&0x0F); |
---|
471 |
|
---|
472 |
unsigned int signal_source=((response[1]>>16)&0xFFFF); |
---|
473 |
|
---|
474 |
unsigned char source_subunit_type=(signal_source>>11)&0x1F; |
---|
475 |
unsigned char source_subunit_id=(signal_source>>8)&0x07; |
---|
476 |
unsigned char source_plug=signal_source&0xFF; |
---|
477 |
|
---|
478 |
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); |
---|
479 |
// find the subunit this plug is connected to |
---|
480 |
AvDeviceSubunit *tmpSubunit=getSubunit(source_subunit_type,source_subunit_id); |
---|
481 |
if ( tmpSubunit ) { |
---|
482 |
tmpSubunit->printSourcePlugConnections(source_plug); |
---|
483 |
} |
---|
484 |
|
---|
485 |
} |
---|
486 |
} |
---|
487 |
|
---|
488 |
debugPrint (DEBUG_LEVEL_DEVICE,"AvDevice: External source connections:\n"); |
---|
489 |
|
---|
490 |
for (unsigned int i=0;i<getNbExtSourcePlugs();i++) { |
---|
491 |
request[0] = AVC1394_CTYPE_STATUS |
---|
492 |
| AVC1394_SUBUNIT_TYPE_UNIT |
---|
493 |
| AVC1394_SUBUNIT_ID_IGNORE |
---|
494 |
| AVC1394_COMMAND_SIGNAL_SOURCE |
---|
495 |
| 0x00FF; |
---|
496 |
request[1]=0xFFFEFF00 | ((i & 0xFF)|0x80); |
---|
497 |
|
---|
498 |
response = avcExecuteTransaction(request, 2, 2); |
---|
499 |
|
---|
500 |
if ( response ) { |
---|
501 |
unsigned char output_status=(response[0]&0xE0) >> 5; |
---|
502 |
unsigned char conv=(response[0]&0x10) >> 4; |
---|
503 |
unsigned char signal_status=(response[0]&0x0F); |
---|
504 |
|
---|
505 |
unsigned int signal_source=((response[1]>>16)&0xFFFF); |
---|
506 |
|
---|
507 |
unsigned char source_subunit_type=(signal_source>>11)&0x1F; |
---|
508 |
unsigned char source_subunit_id=(signal_source>>8)&0x07; |
---|
509 |
unsigned char source_plug=signal_source&0xFF; |
---|
510 |
|
---|
511 |
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); |
---|
512 |
|
---|
513 |
// find the subunit this plug is connected to |
---|
514 |
AvDeviceSubunit *tmpSubunit=getSubunit(source_subunit_type,source_subunit_id); |
---|
515 |
if ( tmpSubunit ) { |
---|
516 |
tmpSubunit->printSourcePlugConnections(source_plug); |
---|
517 |
} |
---|
518 |
} |
---|
519 |
} |
---|
520 |
|
---|
521 |
debugPrint (DEBUG_LEVEL_DEVICE,"AvDevice: ISO sink connections:\n"); |
---|
522 |
|
---|
523 |
for (unsigned int i=0;i<getNbIsoDestinationPlugs();i++) { |
---|
524 |
request[0] = AVC1394_CTYPE_STATUS |
---|
525 |
| AVC1394_SUBUNIT_TYPE_UNIT |
---|
526 |
| AVC1394_SUBUNIT_ID_IGNORE |
---|
527 |
| AVC1394_COMMAND_SIGNAL_SOURCE |
---|
528 |
| 0x00FF; |
---|
529 |
request[1] = 0xFFFEFF00 | ((i & 0xFF)); |
---|
530 |
|
---|
531 |
response = avcExecuteTransaction(request, 2, 2); |
---|
532 |
|
---|
533 |
if ( response ) { |
---|
534 |
unsigned char output_status=(response[0]&0xE0) >> 5; |
---|
535 |
unsigned char conv=(response[0]&0x10) >> 4; |
---|
536 |
unsigned char signal_status=(response[0]&0x0F); |
---|
537 |
|
---|
538 |
unsigned int signal_source=((response[1]>>16)&0xFFFF); |
---|
539 |
|
---|
540 |
unsigned char source_subunit_type=(signal_source>>11)&0x1F; |
---|
541 |
unsigned char source_subunit_id=(signal_source>>8)&0x07; |
---|
542 |
unsigned char source_plug=signal_source&0xFF; |
---|
543 |
|
---|
544 |
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); |
---|
545 |
// find the subunit this plug is connected to |
---|
546 |
AvDeviceSubunit *tmpSubunit |
---|
547 |
= getSubunit(source_subunit_type,source_subunit_id); |
---|
548 |
if ( tmpSubunit ) { |
---|
549 |
//tmpSubunit->printDestinationPlugConnections(source_plug); |
---|
550 |
} |
---|
551 |
|
---|
552 |
} |
---|
553 |
} |
---|
554 |
|
---|
555 |
debugPrint (DEBUG_LEVEL_DEVICE,"AvDevice: External sink connections:\n"); |
---|
556 |
|
---|
557 |
for (unsigned int i=0;i<getNbExtDestinationPlugs();i++) { |
---|
558 |
request[0] = AVC1394_CTYPE_STATUS |
---|
559 |
| AVC1394_SUBUNIT_TYPE_UNIT |
---|
560 |
| AVC1394_SUBUNIT_ID_IGNORE |
---|
561 |
| AVC1394_COMMAND_SIGNAL_SOURCE |
---|
562 |
| 0x00FF; |
---|
563 |
request[1]=0xFFFEFF00 | ((i & 0xFF)|0x80); |
---|
564 |
|
---|
565 |
response = avcExecuteTransaction(request, 2, 2); |
---|
566 |
|
---|
567 |
if ( response ) { |
---|
568 |
unsigned char output_status=(response[0]&0xE0) >> 5; |
---|
569 |
unsigned char conv=(response[0]&0x10) >> 4; |
---|
570 |
unsigned char signal_status=(response[0]&0x0F); |
---|
571 |
|
---|
572 |
unsigned int signal_source=((response[1]>>16)&0xFFFF); |
---|
573 |
|
---|
574 |
unsigned char source_subunit_type=(signal_source>>11)&0x1F; |
---|
575 |
unsigned char source_subunit_id=(signal_source>>8)&0x07; |
---|
576 |
unsigned char source_plug=signal_source&0xFF; |
---|
577 |
|
---|
578 |
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); |
---|
579 |
|
---|
580 |
// find the subunit this plug is connected to |
---|
581 |
AvDeviceSubunit *tmpSubunit |
---|
582 |
= getSubunit(source_subunit_type,source_subunit_id); |
---|
583 |
if ( tmpSubunit ) { |
---|
584 |
//tmpSubunit->printDestinationPlugConnections(source_plug); |
---|
585 |
} |
---|
586 |
} |
---|
587 |
} |
---|
588 |
} |
---|