root/trunk/libffado/src/libieee1394/configrom.cpp

Revision 1336, 21.7 kB (checked in by ppalmers, 16 years ago)

Bring trunk up to date with branches/libffado-2.0:

"""
svn merge -r 1254:1299 svn+ssh://ffadosvn@ffado.org/ffado/branches/libffado-2.0
svn merge -r 1301:1320 svn+ssh://ffadosvn@ffado.org/ffado/branches/libffado-2.0
svn merge -r 1322:1323 svn+ssh://ffadosvn@ffado.org/ffado/branches/libffado-2.0
svn merge -r 1329:HEAD svn+ssh://ffadosvn@ffado.org/ffado/branches/libffado-2.0
"""

Add getSupportedSamplingFrequencies() to DICE, RME and Metric Halo AvDevices?

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 /*
2  * Copyright (C) 2005-2008 by Daniel Wagner
3  * Copyright (C) 2005-2008 by Jonathan Woithe
4  * Copyright (C) 2005-2008 by Pieter Palmers
5  *
6  * This file is part of FFADO
7  * FFADO = Free Firewire (pro-)audio drivers for linux
8  *
9  * FFADO is based upon FreeBoB
10  *
11  * This program is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation, either version 2 of the License, or
14  * (at your option) version 3 of the License.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
23  *
24  */
25
26 #include "config.h"
27
28 #include "configrom.h"
29 #include "ieee1394service.h"
30
31 #include "vendor_model_ids.h"
32
33 #include "libutil/SystemTimeSource.h"
34
35 #include <stdio.h>
36 #include <string.h>
37
38 #include <iostream>
39 #include <iomanip>
40
41 using namespace std;
42
43 IMPL_DEBUG_MODULE( ConfigRom, ConfigRom, DEBUG_LEVEL_NORMAL );
44
45 static int busRead( struct csr1212_csr* csr,
46                     u_int64_t addr,
47                     u_int16_t length,
48                     void* buffer,
49                     void* private_data );
50
51 static int getMaxRom( u_int32_t* bus_info_data,
52                       void* private_data );
53
54 static struct csr1212_bus_ops configrom_csr1212_ops = {
55     busRead,
56     0,
57     0,
58     getMaxRom
59 };
60
61 struct config_csr_info {
62     Ieee1394Service* service;
63     fb_nodeid_t      nodeId;
64 };
65
66 //-------------------------------------------------------------
67
68 ConfigRom::ConfigRom( Ieee1394Service& ieee1394service, fb_nodeid_t nodeId )
69     : Control::Element(NULL, "ConfigRom")
70     , m_1394Service( ieee1394service )
71     , m_nodeId( nodeId )
72     , m_avcDevice( false ) // FIXME: this does not seem veryu
73     , m_guid( 0 )
74     , m_vendorName( "" )
75     , m_modelName( "" )
76     , m_vendorId( 0 )
77     , m_modelId( 0 )
78     , m_unit_specifier_id( 0 )
79     , m_unit_version( 0 )
80     , m_isIsoResourceManager( false )
81     , m_isCycleMasterCapable( false )
82     , m_isSupportIsoOperations( false )
83     , m_isBusManagerCapable( false )
84     , m_cycleClkAcc( 0 )
85     , m_maxRec( 0 )
86     , m_nodeVendorId( 0 )
87     , m_chipIdHi( 0 )
88     , m_chipIdLow( 0 )
89     , m_vendorNameKv( 0 )
90     , m_modelNameKv( 0 )
91     , m_csr( 0 )
92 {
93 }
94
95 ConfigRom::ConfigRom()
96     : Control::Element(NULL, "ConfigRom")
97     , m_1394Service( *(new Ieee1394Service()) )
98     , m_nodeId( -1 )
99     , m_avcDevice( false ) // FIXME: this does not seem veryu
100     , m_guid( 0 )
101     , m_vendorName( "" )
102     , m_modelName( "" )
103     , m_vendorId( 0 )
104     , m_modelId( 0 )
105     , m_unit_specifier_id( 0 )
106     , m_unit_version( 0 )
107     , m_isIsoResourceManager( false )
108     , m_isCycleMasterCapable( false )
109     , m_isSupportIsoOperations( false )
110     , m_isBusManagerCapable( false )
111     , m_cycleClkAcc( 0 )
112     , m_maxRec( 0 )
113     , m_nodeVendorId( 0 )
114     , m_chipIdHi( 0 )
115     , m_chipIdLow( 0 )
116     , m_vendorNameKv( 0 )
117     , m_modelNameKv( 0 )
118     , m_csr( 0 )
119 {
120 }
121
122 Ieee1394Service&
123 ConfigRom::get1394Service()
124 {
125     return m_1394Service;
126 }
127
128 bool
129 ConfigRom::operator == ( const ConfigRom& rhs )
130 {
131     return m_guid == rhs.m_guid;
132 }
133
134 bool
135 ConfigRom::compareGUID( const ConfigRom& a, const ConfigRom& b ) {
136     return a.getGuid() > b.getGuid();
137 }
138
139 bool
140 ConfigRom::initialize()
141 {
142      struct config_csr_info csr_info;
143      csr_info.service = &m_1394Service;
144      csr_info.nodeId = 0xffc0 | m_nodeId;
145
146      m_csr = csr1212_create_csr( &configrom_csr1212_ops,
147                                  5 * sizeof(fb_quadlet_t),   // XXX Why 5 ?!?
148                                  &csr_info );
149     if (!m_csr || csr1212_parse_csr( m_csr ) != CSR1212_SUCCESS) {
150         debugError( "Could not parse config rom of node %d on port %d\n", m_nodeId, m_1394Service.getPort() );
151         if (m_csr) {
152             csr1212_destroy_csr(m_csr);
153             m_csr = 0;
154         }
155         return false;
156     }
157
158     // Process Bus_Info_Block
159     m_isIsoResourceManager = CSR1212_BE32_TO_CPU(m_csr->bus_info_data[2] ) >> 31;
160     m_isCycleMasterCapable = ( CSR1212_BE32_TO_CPU(m_csr->bus_info_data[2] ) >> 30 ) & 0x1;
161     m_isSupportIsoOperations = ( CSR1212_BE32_TO_CPU(m_csr->bus_info_data[2] ) >> 29 ) & 0x1;
162     m_isBusManagerCapable = ( CSR1212_BE32_TO_CPU(m_csr->bus_info_data[2] ) >> 28 ) & 0x1;
163     m_cycleClkAcc = ( CSR1212_BE32_TO_CPU(m_csr->bus_info_data[2] ) >> 16 ) & 0xff;
164     m_maxRec = ( CSR1212_BE32_TO_CPU( m_csr->bus_info_data[2] ) >> 12 ) & 0xf;
165     m_nodeVendorId = ( CSR1212_BE32_TO_CPU( m_csr->bus_info_data[3] ) >> 8 );
166     m_chipIdHi = ( CSR1212_BE32_TO_CPU( m_csr->bus_info_data[3] ) ) & 0xff;
167     m_chipIdLow = CSR1212_BE32_TO_CPU( m_csr->bus_info_data[4] );
168
169     // Process Root Directory
170     processRootDirectory(m_csr);
171
172     if ( m_vendorNameKv ) {
173         int len = ( m_vendorNameKv->value.leaf.len - 2) * sizeof( quadlet_t );
174         char* buf = new char[len+2];
175         memcpy( buf,
176                 ( void* )CSR1212_TEXTUAL_DESCRIPTOR_LEAF_DATA( m_vendorNameKv ),
177                 len );
178
179     while ((buf + len - 1) == '\0') {
180             len--;
181         }
182         // \todo XXX seems a bit strage to do this but the nodemgr.c code does
183         // it. try to figure out why this is needed (or not)
184     buf[len++] = ' ';
185     buf[len] = '\0';
186
187
188         debugOutput( DEBUG_LEVEL_VERBOSE, "Vendor name: '%s'\n", buf );
189         m_vendorName = buf;
190         delete[] buf;
191     }
192     if ( m_modelNameKv ) {
193         int len = ( m_modelNameKv->value.leaf.len - 2) * sizeof( quadlet_t );
194         char* buf = new char[len+2];
195         memcpy( buf,
196                 ( void* )CSR1212_TEXTUAL_DESCRIPTOR_LEAF_DATA( m_modelNameKv ),
197                 len );
198     while ((buf + len - 1) == '\0') {
199             len--;
200         }
201         // \todo XXX for edirol fa-66 it seems somehow broken. see above
202         // todo as well.
203     buf[len++] = ' ';
204     buf[len] = '\0';
205
206         debugOutput( DEBUG_LEVEL_VERBOSE, "Model name: '%s'\n", buf);
207         m_modelName = buf;
208         delete[] buf;
209     }
210
211     m_guid = ((u_int64_t)CSR1212_BE32_TO_CPU(m_csr->bus_info_data[3]) << 32)
212              | CSR1212_BE32_TO_CPU(m_csr->bus_info_data[4]);
213
214     if ( m_vendorNameKv ) {
215         csr1212_release_keyval( m_vendorNameKv );
216         m_vendorNameKv = 0;
217     }
218     if ( m_modelNameKv ) {
219         csr1212_release_keyval( m_modelNameKv );
220         m_modelNameKv = 0;
221     }
222     if ( m_csr ) {
223         csr1212_destroy_csr(m_csr);
224         m_csr = 0;
225     }
226     return true;
227 }
228
229 static int
230 busRead( struct csr1212_csr* csr,
231          u_int64_t addr,
232          u_int16_t length,
233          void* buffer,
234          void* private_data )
235 {
236     struct config_csr_info* csr_info = (struct config_csr_info*) private_data;
237
238     int nb_retries = 5;
239
240     while ( nb_retries--
241             && !csr_info->service->read( csr_info->nodeId,
242                                          addr,
243                                          (size_t)length/4,
244                                          ( quadlet_t* )buffer)  )
245     {// failed, retry
246         Util::SystemTimeSource::SleepUsecRelative(IEEE1394SERVICE_CONFIGROM_READ_WAIT_USECS);
247     }
248     Util::SystemTimeSource::SleepUsecRelative(IEEE1394SERVICE_CONFIGROM_READ_WAIT_USECS);
249
250     if (nb_retries > -1) return 0; // success
251     else return -1; // failure
252 }
253
254 static int
255 getMaxRom( u_int32_t* bus_info_data,
256            void* /*private_data*/)
257 {
258     return (CSR1212_BE32_TO_CPU( bus_info_data[2] ) >> 8) & 0x3;
259 }
260
261
262 void
263 ConfigRom::processUnitDirectory( struct csr1212_csr* csr,
264                                  struct csr1212_keyval* ud_kv,
265                                  unsigned int *id )
266 {
267     struct csr1212_dentry *dentry;
268     struct csr1212_keyval *kv;
269     unsigned int last_key_id = 0;
270
271     debugOutput( DEBUG_LEVEL_VERBOSE, "process unit directory:\n" );
272     csr1212_for_each_dir_entry(csr, kv, ud_kv, dentry) {
273     switch (kv->key.id) {
274         case CSR1212_KV_ID_VENDOR:
275         if (kv->key.type == CSR1212_KV_TYPE_IMMEDIATE) {
276                     debugOutput( DEBUG_LEVEL_VERBOSE,
277                                  "\tvendor_id = 0x%08x\n",
278                                  kv->value.immediate);
279                     m_vendorId = kv->value.immediate;
280         }
281         break;
282
283         case CSR1212_KV_ID_MODEL:
284                 debugOutput( DEBUG_LEVEL_VERBOSE,
285                              "\tmodel_id = 0x%08x\n",
286                              kv->value.immediate);
287                 m_modelId = kv->value.immediate;
288         break;
289
290         case CSR1212_KV_ID_SPECIFIER_ID:
291                 debugOutput( DEBUG_LEVEL_VERBOSE,
292                              "\tspecifier_id = 0x%08x\n",
293                              kv->value.immediate);
294                 m_unit_specifier_id = kv->value.immediate;
295         break;
296
297         case CSR1212_KV_ID_VERSION:
298                 debugOutput( DEBUG_LEVEL_VERBOSE,
299                              "\tversion = 0x%08x\n",
300                              kv->value.immediate);
301                 m_unit_version = kv->value.immediate;
302                 if ( m_unit_specifier_id == 0x0000a02d ) // XXX
303                 {
304                     m_avcDevice = true; // FIXME: disable this check for the moment
305                     if ( kv->value.immediate == 0x14001 ) {
306                         m_avcDevice = true;
307                     }
308                 }
309         break;
310
311         case CSR1212_KV_ID_DESCRIPTOR:
312         if (kv->key.type == CSR1212_KV_TYPE_LEAF &&
313             CSR1212_DESCRIPTOR_LEAF_TYPE(kv) == 0 &&
314             CSR1212_DESCRIPTOR_LEAF_SPECIFIER_ID(kv) == 0 &&
315             CSR1212_TEXTUAL_DESCRIPTOR_LEAF_WIDTH(kv) == 0 &&
316             CSR1212_TEXTUAL_DESCRIPTOR_LEAF_CHAR_SET(kv) == 0 &&
317             CSR1212_TEXTUAL_DESCRIPTOR_LEAF_LANGUAGE(kv) == 0)
318         {
319             switch (last_key_id) {
320             case CSR1212_KV_ID_VENDOR:
321                 csr1212_keep_keyval(kv);
322                             m_vendorNameKv = kv;
323                 break;
324
325             case CSR1212_KV_ID_MODEL:
326                             m_modelNameKv = kv;
327                 csr1212_keep_keyval(kv);
328                 break;
329
330             }
331         } /* else if (kv->key.type == CSR1212_KV_TYPE_DIRECTORY) ... */
332         break;
333
334         case CSR1212_KV_ID_DEPENDENT_INFO:
335         if (kv->key.type == CSR1212_KV_TYPE_DIRECTORY) {
336             /* This should really be done in SBP2 as this is
337              * doing SBP2 specific parsing. */
338             processUnitDirectory(csr, kv, id);
339         }
340
341         break;
342
343         default:
344         break;
345     }
346     last_key_id = kv->key.id;
347     }
348 }
349
350 void
351 ConfigRom::processRootDirectory(struct csr1212_csr* csr)
352 {
353     unsigned int ud_id = 0;
354     struct csr1212_dentry *dentry;
355     struct csr1212_keyval *kv;
356     unsigned int last_key_id = 0;
357
358     csr1212_for_each_dir_entry(csr, kv, csr->root_kv, dentry) {
359     switch (kv->key.id) {
360         case CSR1212_KV_ID_VENDOR:
361                 debugOutput( DEBUG_LEVEL_VERBOSE,
362                              "vendor id = 0x%08x\n", kv->value.immediate);
363         break;
364
365         case CSR1212_KV_ID_NODE_CAPABILITIES:
366                 debugOutput( DEBUG_LEVEL_VERBOSE,
367                              "capabilities = 0x%08x\n", kv->value.immediate);
368         break;
369
370         case CSR1212_KV_ID_UNIT:
371         processUnitDirectory(csr, kv, &ud_id);
372         break;
373
374         case CSR1212_KV_ID_DESCRIPTOR:
375         if (last_key_id == CSR1212_KV_ID_VENDOR) {
376             if (kv->key.type == CSR1212_KV_TYPE_LEAF &&
377             CSR1212_DESCRIPTOR_LEAF_TYPE(kv) == 0 &&
378             CSR1212_DESCRIPTOR_LEAF_SPECIFIER_ID(kv) == 0 &&
379             CSR1212_TEXTUAL_DESCRIPTOR_LEAF_WIDTH(kv) == 0 &&
380             CSR1212_TEXTUAL_DESCRIPTOR_LEAF_CHAR_SET(kv) == 0 &&
381             CSR1212_TEXTUAL_DESCRIPTOR_LEAF_LANGUAGE(kv) == 0)
382                     {
383                         m_vendorNameKv = kv;
384             csr1212_keep_keyval(kv);
385             }
386         }
387         break;
388     }
389     last_key_id = kv->key.id;
390     }
391
392 }
393
394 const fb_nodeid_t
395 ConfigRom::getNodeId() const
396 {
397     return m_nodeId;
398 }
399
400 const fb_octlet_t
401 ConfigRom::getGuid() const
402 {
403     return m_guid;
404 }
405
406 const std::string
407 ConfigRom::getGuidString() const
408 {
409     char* buf;
410     asprintf( &buf, "%08x%08x",
411               ( unsigned int ) ( getGuid() >> 32 ),
412               ( unsigned int ) ( getGuid() & 0xffffffff ) );
413     std::string result = buf;
414     free( buf );
415     return result;
416 }
417  
418 const std::string
419 ConfigRom::getModelName() const
420 {
421     // HACK:
422     // workarounds for devices that don't fill a correct model name
423     switch(m_vendorId) {
424         case FW_VENDORID_MOTU:
425             switch(m_unit_specifier_id) {
426                 case 0x00000003:
427                     return "828MkII";
428                 case 0x00000009:
429                     return "Traveler";
430                 case 0x0000000d:
431                     return "UltraLite";
432                 case 0x0000000f:
433                     return "8pre";
434                 case 0x00000001:
435                     return "828MkI";
436                 case 0x00000005:
437                     return "896HD";
438                 default:
439                     return "unknown";
440             }
441             break;
442         default:
443             return m_modelName;
444     }
445 }
446
447 const std::string
448 ConfigRom::getVendorName() const
449 {
450     // HACK:
451     // workarounds for devices that don't fill a correct vendor name
452     switch(m_vendorId) {
453         case FW_VENDORID_MOTU:
454             return "MOTU";
455         default:
456             return m_vendorName;
457     }
458 }
459
460 const unsigned int
461 ConfigRom::getModelId() const
462 {
463     return m_modelId;
464 }
465
466 const unsigned int
467 ConfigRom::getVendorId() const
468 {
469     return m_vendorId;
470 }
471
472 const unsigned int
473 ConfigRom::getUnitSpecifierId() const
474 {
475     return m_unit_specifier_id;
476 }
477
478 const unsigned int
479 ConfigRom::getUnitVersion() const
480 {
481     return m_unit_version;
482 }
483
484 bool
485 ConfigRom::updatedNodeId()
486 {
487     debugOutput( DEBUG_LEVEL_VERBOSE,
488                  "Checking for updated node id for device with GUID 0x%016llX...\n",
489                  getGuid());
490
491     struct csr1212_csr* csr = NULL;
492     for ( fb_nodeid_t nodeId = 0;
493           nodeId < m_1394Service.getNodeCount();
494           ++nodeId )
495     {
496         struct config_csr_info csr_info;
497         csr_info.service = &m_1394Service;
498         csr_info.nodeId = 0xffc0 | nodeId;
499         debugOutput( DEBUG_LEVEL_VERBOSE, "Looking at node %d...\n", nodeId);
500
501         csr = csr1212_create_csr( &configrom_csr1212_ops,
502                                   5 * sizeof(fb_quadlet_t),   // XXX Why 5 ?!?
503                                   &csr_info );
504
505         if (!csr || csr1212_parse_csr( csr ) != CSR1212_SUCCESS) {
506             debugWarning( "Failed to get/parse CSR\n");
507             if (csr) {
508                 csr1212_destroy_csr(csr);
509                 csr = NULL;
510             }
511             continue;
512         }
513
514         octlet_t guid =
515             ((u_int64_t)CSR1212_BE32_TO_CPU(csr->bus_info_data[3]) << 32)
516             | CSR1212_BE32_TO_CPU(csr->bus_info_data[4]);
517
518         debugOutput( DEBUG_LEVEL_VERBOSE,
519                         " Node has GUID 0x%016llX\n",
520                         guid);
521
522         if ( guid == getGuid() ) {
523             debugOutput( DEBUG_LEVEL_VERBOSE, "GUID matches ours\n");
524             if ( nodeId != getNodeId() ) {
525                 debugOutput( DEBUG_LEVEL_VERBOSE,
526                              "Device with GUID 0x%016llX changed node id "
527                              "from %d to %d\n",
528                              getGuid(),
529                              getNodeId(),
530                              nodeId );
531                 m_nodeId = nodeId;
532             } else {
533                 debugOutput( DEBUG_LEVEL_VERBOSE,
534                              "Device with GUID 0x%016llX kept node id %d\n",
535                              getGuid(),
536                              getNodeId());
537             }
538             if (csr) {
539                 csr1212_destroy_csr(csr);
540                 csr = NULL;
541             }
542             return true;
543         }
544     }
545
546     if (csr) {
547         csr1212_destroy_csr(csr);
548     }
549
550     debugOutput( DEBUG_LEVEL_VERBOSE,
551                  "Device with GUID 0x%016llX could not be found on "
552                  "the bus anymore (removed?)\n",
553                  getGuid() );
554     m_nodeId = INVALID_NODE_ID;
555     return false;
556 }
557
558 void
559 ConfigRom::printConfigRomDebug() const
560 {
561     using namespace std;
562     debugOutput(DEBUG_LEVEL_NORMAL, "Config ROM\n" );
563     debugOutput(DEBUG_LEVEL_NORMAL, "\tCurrent Node Id:\t%d\n",       getNodeId() );
564     debugOutput(DEBUG_LEVEL_NORMAL, "\tGUID:\t\t\t0x%016llX\n",       getGuid());
565     debugOutput(DEBUG_LEVEL_NORMAL, "\tVendor Name:\t\t%s\n",         getVendorName().c_str() );
566     debugOutput(DEBUG_LEVEL_NORMAL, "\tModel Name:\t\t%s\n",          getModelName().c_str() );
567     debugOutput(DEBUG_LEVEL_NORMAL, "\tNode Vendor ID:\t\t0x%06x\n",  getNodeVendorId() );
568     debugOutput(DEBUG_LEVEL_NORMAL, "\tModel Id:\t\t0x%08x\n",        getModelId() );
569     debugOutput(DEBUG_LEVEL_NORMAL, "\tUnit Specifier ID:\t0x%06x\n", getUnitSpecifierId() );
570     debugOutput(DEBUG_LEVEL_NORMAL, "\tUnit version:\t\t0x%08x\n",    getUnitVersion() );
571     debugOutput(DEBUG_LEVEL_NORMAL, "\tISO resource manager:\t%d\n",  isIsoResourseManager() );
572     debugOutput(DEBUG_LEVEL_NORMAL, "\tCycle master capable:\t%d\n",  isSupportsIsoOperations() );
573     debugOutput(DEBUG_LEVEL_NORMAL, "\tBus manager capable:\t%d\n",   isBusManagerCapable() );
574     debugOutput(DEBUG_LEVEL_NORMAL, "\tCycle clock accuracy:\t%d\n",  getCycleClockAccurancy() );
575     debugOutput(DEBUG_LEVEL_NORMAL, "\tMax rec:\t\t%d (max asy payload: %d bytes)\n",
576             getMaxRec(), getAsyMaxPayload() );
577 }
578
579 void
580 ConfigRom::printConfigRom() const
581 {
582     using namespace std;
583     printMessage("Config ROM\n" );
584     printMessage("\tCurrent Node Id:\t%d\n",       getNodeId() );
585     printMessage("\tGUID:\t\t\t0x%016llX\n",       getGuid());
586     printMessage("\tVendor Name:\t\t%s\n",         getVendorName().c_str() );
587     printMessage("\tModel Name:\t\t%s\n",          getModelName().c_str() );
588     printMessage("\tNode Vendor ID:\t\t0x%06x\n",  getNodeVendorId() );
589     printMessage("\tModel Id:\t\t0x%08x\n",        getModelId() );
590     printMessage("\tUnit Specifier ID:\t0x%06x\n", getUnitSpecifierId() );
591     printMessage("\tUnit version:\t\t0x%08x\n",    getUnitVersion() );
592     printMessage("\tISO resource manager:\t%d\n",  isIsoResourseManager() );
593     printMessage("\tCycle master capable:\t%d\n",  isSupportsIsoOperations() );
594     printMessage("\tBus manager capable:\t%d\n",   isBusManagerCapable() );
595     printMessage("\tCycle clock accuracy:\t%d\n",  getCycleClockAccurancy() );
596     printMessage("\tMax rec:\t\t%d (max asy payload: %d bytes)\n", getMaxRec(), getAsyMaxPayload() );
597 }
598
599 unsigned short
600 ConfigRom::getAsyMaxPayload() const
601 {
602     // XXX use pow instead?
603     return 1 << ( m_maxRec + 1 );
604 }
605
606 bool
607 ConfigRom::serialize( std::string path, Util::IOSerialize& ser )
608 {
609     bool result;
610     result  = ser.write( path + "m_nodeId", m_nodeId );
611     result &= ser.write( path + "m_avcDevice",  m_avcDevice );
612     result &= ser.write( path + "m_guid", m_guid );
613     result &= ser.write( path + "m_vendorName", std::string( m_vendorName ) );
614     result &= ser.write( path + "m_modelName", std::string( m_modelName ) );
615     result &= ser.write( path + "m_vendorId", m_vendorId );
616     result &= ser.write( path + "m_modelId", m_modelId );
617     result &= ser.write( path + "m_unit_specifier_id", m_unit_specifier_id );
618     result &= ser.write( path + "m_unit_version",  m_unit_version );
619     result &= ser.write( path + "m_isIsoResourceManager", m_isIsoResourceManager );
620     result &= ser.write( path + "m_isCycleMasterCapable", m_isCycleMasterCapable );
621     result &= ser.write( path + "m_isSupportIsoOperations", m_isSupportIsoOperations );
622     result &= ser.write( path + "m_isBusManagerCapable", m_isBusManagerCapable );
623     result &= ser.write( path + "m_cycleClkAcc", m_cycleClkAcc );
624     result &= ser.write( path + "m_maxRec", m_maxRec );
625     result &= ser.write( path + "m_nodeVendorId", m_nodeVendorId );
626     result &= ser.write( path + "m_chipIdHi", m_chipIdHi );
627     result &= ser.write( path + "m_chipIdLow", m_chipIdLow );
628     return result;
629 }
630
631 ConfigRom*
632 ConfigRom::deserialize( std::string path, Util::IODeserialize& deser, Ieee1394Service& ieee1394Service )
633 {
634     ConfigRom* pConfigRom = new ConfigRom;
635     if ( !pConfigRom ) {
636         return 0;
637     }
638
639     pConfigRom->m_1394Service = ieee1394Service;
640
641     bool result;
642     result  = deser.read( path + "m_nodeId", pConfigRom->m_nodeId );
643     result &= deser.read( path + "m_avcDevice", pConfigRom->m_avcDevice );
644     result &= deser.read( path + "m_guid", pConfigRom->m_guid );
645     result &= deser.read( path + "m_vendorName", pConfigRom->m_vendorName );
646     result &= deser.read( path + "m_modelName", pConfigRom->m_modelName );
647     result &= deser.read( path + "m_vendorId", pConfigRom->m_vendorId );
648     result &= deser.read( path + "m_modelId", pConfigRom->m_modelId );
649     result &= deser.read( path + "m_unit_specifier_id", pConfigRom->m_unit_specifier_id );
650     result &= deser.read( path + "m_unit_version", pConfigRom->m_unit_version );
651     result &= deser.read( path + "m_isIsoResourceManager", pConfigRom->m_isIsoResourceManager );
652     result &= deser.read( path + "m_isCycleMasterCapable", pConfigRom->m_isCycleMasterCapable );
653     result &= deser.read( path + "m_isSupportIsoOperations", pConfigRom->m_isSupportIsoOperations );
654     result &= deser.read( path + "m_isBusManagerCapable", pConfigRom->m_isBusManagerCapable );
655     result &= deser.read( path + "m_cycleClkAcc", pConfigRom->m_cycleClkAcc );
656     result &= deser.read( path + "m_maxRec", pConfigRom->m_maxRec );
657     result &= deser.read( path + "m_nodeVendorId", pConfigRom->m_nodeVendorId );
658     result &= deser.read( path + "m_chipIdHi", pConfigRom->m_chipIdHi );
659     result &= deser.read( path + "m_chipIdLow", pConfigRom->m_chipIdLow );
660
661     if ( !result ) {
662         delete pConfigRom;
663         return 0;
664     }
665
666     return pConfigRom;
667 }
668
669 bool
670 ConfigRom::setNodeId( fb_nodeid_t nodeId )
671 {
672     m_nodeId = nodeId;
673     return true;
674 }
Note: See TracBrowser for help on using the browser.