root/trunk/freebob/src/avdevice.cpp

Revision 56, 19.6 kB (checked in by wagi, 19 years ago)

Undo last checkin mistake: Do a complete device scan.

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