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

Revision 583, 3.9 kB (checked in by ppalmers, 15 years ago)

- Clean up the FFADODevice constructor to remove the nodeid that

can be retrieved from the configrom.

- Implement new method of creating devices: a device is supposed

to implement the createDevice static method that should return
an instance of itself or a subclass of itself. This should ease
support for manufacturer specific customizations since we don't
have to put them into the device manager class.

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( Ieee1394Service& ieee1394Service,
53                         std::auto_ptr<ConfigRom>( configRom ))
54     : FFADODevice( ieee1394Service, configRom )
55     , m_model( NULL )
56
57 {
58     debugOutput( DEBUG_LEVEL_VERBOSE, "Created MetricHalo::MHAvDevice (NodeID %d)\n",
59                  configRom->getNodeId() );
60 }
61
62 MHAvDevice::~MHAvDevice()
63 {
64
65 }
66
67 bool
68 MHAvDevice::probe( ConfigRom& configRom )
69 {
70     unsigned int vendorId = configRom.getNodeVendorId();
71     unsigned int modelId = configRom.getModelId();
72
73     for ( unsigned int i = 0;
74           i < ( sizeof( supportedDeviceList )/sizeof( VendorModelEntry ) );
75           ++i )
76     {
77         if ( ( supportedDeviceList[i].vendor_id == vendorId )
78              && ( supportedDeviceList[i].model_id == modelId )
79            )
80         {
81             return true;
82         }
83     }
84
85     return false;
86 }
87
88 FFADODevice *
89 MHAvDevice::createDevice( Ieee1394Service& ieee1394Service,
90                           std::auto_ptr<ConfigRom>( configRom ))
91 {
92     return new MHAvDevice(ieee1394Service, configRom );
93 }
94
95 bool
96 MHAvDevice::discover()
97 {
98     unsigned int vendorId = m_pConfigRom->getNodeVendorId();
99     unsigned int modelId = m_pConfigRom->getModelId();
100
101     for ( unsigned int i = 0;
102           i < ( sizeof( supportedDeviceList )/sizeof( VendorModelEntry ) );
103           ++i )
104     {
105         if ( ( supportedDeviceList[i].vendor_id == vendorId )
106              && ( supportedDeviceList[i].model_id == modelId )
107            )
108         {
109             m_model = &(supportedDeviceList[i]);
110         }
111     }
112
113     if (m_model != NULL) {
114         debugOutput( DEBUG_LEVEL_VERBOSE, "found %s %s\n",
115                 m_model->vendor_name, m_model->model_name);
116         return true;
117     }
118
119     return false;
120 }
121
122 int
123 MHAvDevice::getSamplingFrequency( ) {
124     return 0;
125 }
126
127 int
128 MHAvDevice::getConfigurationId( ) {
129     return 0;
130 }
131
132 bool
133 MHAvDevice::setSamplingFrequency( int samplingFrequency )
134 {
135
136     return false;
137 }
138
139 bool
140 MHAvDevice::lock() {
141
142     return true;
143 }
144
145
146 bool
147 MHAvDevice::unlock() {
148
149     return true;
150 }
151
152 void
153 MHAvDevice::showDevice()
154 {
155     debugOutput(DEBUG_LEVEL_VERBOSE,
156         "%s %s at node %d\n", m_model->vendor_name, m_model->model_name,
157         getNodeId());
158 }
159
160 bool
161 MHAvDevice::prepare() {
162
163     return true;
164 }
165
166 int
167 MHAvDevice::getStreamCount() {
168     return 0;
169 }
170
171 Streaming::StreamProcessor *
172 MHAvDevice::getStreamProcessorByIndex(int i) {
173
174     return NULL;
175 }
176
177 bool
178 MHAvDevice::startStreamByIndex(int i) {
179     return false;
180 }
181
182 bool
183 MHAvDevice::stopStreamByIndex(int i) {
184     return false;
185 }
186
187 }
Note: See TracBrowser for help on using the browser.