root/trunk/libffado/src/fireworks/fireworks_device.cpp

Revision 589, 3.4 kB (checked in by ppalmers, 16 years ago)

small discovery fix

Line 
1 /*
2  * Copyright (C) 2007 by Pieter Palmers
3  *
4  * This file is part of FFADO
5  * FFADO = Free Firewire (pro-)audio drivers for linux
6  *
7  * FFADO is based upon FreeBoB.
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License version 2.1, as published by the Free Software Foundation;
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21  * MA 02110-1301 USA
22  */
23
24 #include "fireworks_device.h"
25
26 #include "audiofire/audiofire_device.h"
27
28 #include "libieee1394/configrom.h"
29 #include "libieee1394/ieee1394service.h"
30
31 // FireWorks is the platform used and developed by ECHO AUDIO
32 namespace FireWorks {
33
34 // to define the supported devices
35 static GenericAVC::VendorModelEntry supportedDeviceList[] =
36 {
37     {FW_VENDORID_ECHO, 0x00000af2, "Echo", "AudioFire2"},
38 };
39
40 Device::Device( Ieee1394Service& ieee1394Service,
41                             std::auto_ptr<ConfigRom>( configRom ))
42     : GenericAVC::AvDevice( ieee1394Service, configRom)
43 {
44     debugOutput( DEBUG_LEVEL_VERBOSE, "Created FireWorks::Device (NodeID %d)\n",
45                  getConfigRom().getNodeId() );
46 }
47
48 Device::~Device()
49 {
50 }
51
52 void
53 Device::showDevice()
54 {
55     debugOutput(DEBUG_LEVEL_VERBOSE, "This is a FireWorks::Device\n");
56     GenericAVC::AvDevice::showDevice();
57 }
58
59
60 bool
61 Device::probe( ConfigRom& configRom )
62 {
63     unsigned int vendorId = configRom.getNodeVendorId();
64     unsigned int modelId = configRom.getModelId();
65
66     for ( unsigned int i = 0;
67           i < ( sizeof( supportedDeviceList )/sizeof( GenericAVC::VendorModelEntry ) );
68           ++i )
69     {
70         if ( ( supportedDeviceList[i].vendor_id == vendorId )
71              && ( supportedDeviceList[i].model_id == modelId )
72            )
73         {
74             return true;
75         }
76     }
77
78     return false;
79 }
80
81 bool
82 Device::discover()
83 {
84     unsigned int vendorId = m_pConfigRom->getNodeVendorId();
85     unsigned int modelId = m_pConfigRom->getModelId();
86
87     for ( unsigned int i = 0;
88           i < ( sizeof( supportedDeviceList )/sizeof( GenericAVC::VendorModelEntry ) );
89           ++i )
90     {
91         if ( ( supportedDeviceList[i].vendor_id == vendorId )
92              && ( supportedDeviceList[i].model_id == modelId )
93            )
94         {
95             m_model = &(supportedDeviceList[i]);
96         }
97     }
98
99     if (m_model == NULL) {
100         return false;
101     }
102     debugOutput( DEBUG_LEVEL_VERBOSE, "found %s %s\n",
103             m_model->vendor_name, m_model->model_name);
104
105     if ( !GenericAVC::AvDevice::discover() ) {
106         debugError( "Could not discover GenericAVC::AvDevice\n" );
107         return false;
108     }
109
110     return true;
111 }
112
113 FFADODevice *
114 Device::createDevice( Ieee1394Service& ieee1394Service,
115                       std::auto_ptr<ConfigRom>( configRom ))
116 {
117     unsigned int vendorId = configRom->getNodeVendorId();
118     unsigned int modelId = configRom->getModelId();
119    
120     switch(vendorId) {
121         case FW_VENDORID_ECHO: return new ECHO::AudioFire(ieee1394Service, configRom );
122         default: return new Device(ieee1394Service, configRom );
123     }
124 }
125
126
127 } // FireWorks
Note: See TracBrowser for help on using the browser.