root/trunk/libffado/src/metrichalo/mh_avdevice.cpp

Revision 554, 3.7 kB (checked in by ppalmers, 16 years ago)

Merge echoaudio branch into trunk.

This adds support for the Echo Audiofire devices to FFADO. Possibly also other devices working with the Apple Class Driver will work with this code. It is not fully complete yet, but the main rework is
done.

First of all the IAvDevice class/interface is renamed to FFADODevice, in order to separate the AV/C code from the FFADO API code. A device supported by FFADO implements a FFADODevice.

The BeBoB device has been split up into three groups:
- libavc/* : all code and commands that are specified by AV/C specs. Note that a lot of the code that used to be in BeBoB::AvDevice? now resides in AVC::Unit
- genericavc/* : a FFADODevice that uses AV/C descriptors & commands for discovery and config
- bebob/* : the bebob FFADODevice that inherits from GenericAVC::AvDevice? but that uses BridgeCo? commands for discovery

Everything has been moved as high as possible in the class hierarchy. If necessary, a subclass that uses device specific commands is introduced (e.g. BeBoB::Plug inherits from AVC::Plug and uses the
BridgeCo? extended plug info command to discover it's properties).

There are some other fixes along the way that have been done too.

Line 
1 /*
2  * Copyright (C) 2005-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 #warning Metric Halo support is currently useless
25
26 #include "metrichalo/mh_avdevice.h"
27
28 #include "libieee1394/configrom.h"
29 #include "libieee1394/ieee1394service.h"
30
31 #include "libavc/avc_definitions.h"
32
33 #include "debugmodule/debugmodule.h"
34
35 #include <string>
36 #include <stdint.h>
37 #include <assert.h>
38 #include <netinet/in.h>
39 #include <iostream>
40 #include <sstream>
41
42 #include <libraw1394/csr.h>
43
44 namespace MetricHalo {
45
46 // to define the supported devices
47 static VendorModelEntry supportedDeviceList[] =
48 {
49     {0x00000000, 0x0000, "Metric Halo", "XXX"},
50 };
51
52 MHAvDevice::MHAvDevice( std::auto_ptr< ConfigRom >( configRom ),
53                     Ieee1394Service& ieee1394service,
54                     int nodeId )
55     :  FFADODevice( configRom, ieee1394service, nodeId )
56     , m_model( NULL )
57
58 {
59     debugOutput( DEBUG_LEVEL_VERBOSE, "Created MetricHalo::MHAvDevice (NodeID %d)\n",
60                  nodeId );
61 }
62
63 MHAvDevice::~MHAvDevice()
64 {
65
66 }
67
68 bool
69 MHAvDevice::probe( ConfigRom& configRom )
70 {
71     unsigned int vendorId = configRom.getNodeVendorId();
72     unsigned int modelId = configRom.getModelId();
73
74     for ( unsigned int i = 0;
75           i < ( sizeof( supportedDeviceList )/sizeof( VendorModelEntry ) );
76           ++i )
77     {
78         if ( ( supportedDeviceList[i].vendor_id == vendorId )
79              && ( supportedDeviceList[i].model_id == modelId )
80            )
81         {
82             return true;
83         }
84     }
85
86     return false;
87 }
88
89 bool
90 MHAvDevice::discover()
91 {
92     unsigned int vendorId = m_pConfigRom->getNodeVendorId();
93     unsigned int modelId = m_pConfigRom->getModelId();
94
95     for ( unsigned int i = 0;
96           i < ( sizeof( supportedDeviceList )/sizeof( VendorModelEntry ) );
97           ++i )
98     {
99         if ( ( supportedDeviceList[i].vendor_id == vendorId )
100              && ( supportedDeviceList[i].model_id == modelId )
101            )
102         {
103             m_model = &(supportedDeviceList[i]);
104         }
105     }
106
107     if (m_model != NULL) {
108         debugOutput( DEBUG_LEVEL_VERBOSE, "found %s %s\n",
109                 m_model->vendor_name, m_model->model_name);
110         return true;
111     }
112
113     return false;
114 }
115
116 int
117 MHAvDevice::getSamplingFrequency( ) {
118     return 0;
119 }
120
121 int
122 MHAvDevice::getConfigurationId( ) {
123     return 0;
124 }
125
126 bool
127 MHAvDevice::setSamplingFrequency( int samplingFrequency )
128 {
129
130     return false;
131 }
132
133 bool
134 MHAvDevice::lock() {
135
136     return true;
137 }
138
139
140 bool
141 MHAvDevice::unlock() {
142
143     return true;
144 }
145
146 void
147 MHAvDevice::showDevice()
148 {
149     debugOutput(DEBUG_LEVEL_VERBOSE,
150         "%s %s at node %d\n", m_model->vendor_name, m_model->model_name,
151         m_nodeId);
152 }
153
154 bool
155 MHAvDevice::prepare() {
156
157     return true;
158 }
159
160 int
161 MHAvDevice::getStreamCount() {
162     return 0;
163 }
164
165 Streaming::StreamProcessor *
166 MHAvDevice::getStreamProcessorByIndex(int i) {
167
168     return NULL;
169 }
170
171 bool
172 MHAvDevice::startStreamByIndex(int i) {
173     return false;
174 }
175
176 bool
177 MHAvDevice::stopStreamByIndex(int i) {
178     return false;
179 }
180
181 }
Note: See TracBrowser for help on using the browser.