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

Revision 629, 4.2 kB (checked in by ppalmers, 15 years ago)

- Base infrastructure for the Echo EFC commands
- Some first command implementations

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 #include "efc/efc_avc_cmd.h"
26 #include "efc/efc_cmd.h"
27 #include "efc/efc_cmds_hardware.h"
28
29 #include "audiofire/audiofire_device.h"
30
31 #include "libieee1394/configrom.h"
32 #include "libieee1394/ieee1394service.h"
33
34 #include "config.h"
35
36 // FireWorks is the platform used and developed by ECHO AUDIO
37 namespace FireWorks {
38
39 Device::Device( Ieee1394Service& ieee1394Service,
40                             std::auto_ptr<ConfigRom>( configRom ))
41     : GenericAVC::AvDevice( ieee1394Service, configRom)
42 {
43     debugOutput( DEBUG_LEVEL_VERBOSE, "Created FireWorks::Device (NodeID %d)\n",
44                  getConfigRom().getNodeId() );
45 }
46
47 Device::~Device()
48 {
49 }
50
51 void
52 Device::showDevice()
53 {
54     debugOutput(DEBUG_LEVEL_VERBOSE, "This is a FireWorks::Device\n");
55 //     GenericAVC::AvDevice::showDevice();
56
57     EfcOverAVCCmd cmd( get1394Service() );
58     cmd.setCommandType( AVC::AVCCommand::eCT_Control );
59     cmd.setNodeId( getConfigRom().getNodeId() );
60     cmd.setSubunitType( AVC::eST_Unit  );
61     cmd.setSubunitId( 0xff );
62    
63     cmd.setVerbose( getDebugLevel() );
64     cmd.setVerbose( DEBUG_LEVEL_VERY_VERBOSE );
65
66     EfcHardwareInfoCmd *efccmd=new EfcHardwareInfoCmd();
67     if (!efccmd) {
68         debugError("could not allocate efc cmd\n");
69         return;
70     }
71     cmd.m_cmd = efccmd;
72
73     if ( !cmd.fire() ) {
74         debugError( "EfcOverAVCCmd command failed\n" );
75     }
76
77     efccmd->showEfcCmd();
78     delete efccmd;
79    
80     // test the next command
81     cmd.setCommandType( AVC::AVCCommand::eCT_Control );
82    
83     EfcPolledValuesCmd *efccmd2=new EfcPolledValuesCmd();
84     if (!efccmd2) {
85         debugError("could not allocate efc cmd 2\n");
86         return;
87     }
88     cmd.m_cmd = efccmd2;
89
90     if ( !cmd.fire() ) {
91         debugError( "EfcOverAVCCmd command failed\n" );
92     }
93
94     efccmd2->showEfcCmd();
95     delete efccmd2;
96    
97 }
98
99
100 bool
101 Device::probe( ConfigRom& configRom )
102 {
103     unsigned int vendorId = configRom.getNodeVendorId();
104     unsigned int modelId = configRom.getModelId();
105
106     GenericAVC::VendorModel vendorModel( SHAREDIR "/ffado_driver_fireworks.txt" );
107     if ( vendorModel.parse() ) {
108         vendorModel.printTable();
109         return vendorModel.isPresent( vendorId, modelId );
110     }
111
112     return false;
113 }
114
115 bool
116 Device::discover()
117 {
118     unsigned int vendorId = m_pConfigRom->getNodeVendorId();
119     unsigned int modelId = m_pConfigRom->getModelId();
120
121     GenericAVC::VendorModel vendorModel( SHAREDIR "/ffado_driver_fireworks.txt" );
122     if ( vendorModel.parse() ) {
123         m_model = vendorModel.find( vendorId, modelId );
124     }
125
126     if (!GenericAVC::VendorModel::isValid(m_model)) {
127         return false;
128     }
129     debugOutput( DEBUG_LEVEL_VERBOSE, "found %s %s\n",
130             m_model.vendor_name.c_str(), m_model.model_name.c_str());
131
132     if ( !GenericAVC::AvDevice::discover() ) {
133         debugError( "Could not discover GenericAVC::AvDevice\n" );
134         return false;
135     }
136
137     return true;
138 }
139
140 FFADODevice *
141 Device::createDevice( Ieee1394Service& ieee1394Service,
142                       std::auto_ptr<ConfigRom>( configRom ))
143 {
144     unsigned int vendorId = configRom->getNodeVendorId();
145
146 //     return NULL;
147
148     unsigned int modelId = configRom->getModelId();
149
150     switch(vendorId) {
151         case FW_VENDORID_ECHO: return new ECHO::AudioFire(ieee1394Service, configRom );
152         default: return new Device(ieee1394Service, configRom );
153     }
154 }
155
156
157 } // FireWorks
Note: See TracBrowser for help on using the browser.