root/trunk/libffado/src/libavc/avc_definitions.cpp

Revision 554, 5.1 kB (checked in by ppalmers, 13 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.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 /*
2  * Copyright (C) 2005-2007 by Daniel Wagner
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 "avc_definitions.h"
25 #include <libiec61883/iec61883.h>
26
27 namespace AVC {
28
29 int
30 convertESamplingFrequency(ESamplingFrequency freq)
31 {
32     int value = 0;
33
34     switch ( freq ) {
35     case eSF_22050Hz:
36         value = 22050;
37         break;
38     case eSF_24000Hz:
39         value = 24000;
40         break;
41     case eSF_32000Hz:
42         value = 32000;
43         break;
44     case eSF_44100Hz:
45         value = 44100;
46         break;
47     case eSF_48000Hz:
48         value = 48000;
49         break;
50     case eSF_88200Hz:
51         value = 88200;
52         break;
53     case eSF_96000Hz:
54         value = 96000;
55         break;
56     case eSF_176400Hz:
57         value = 176400;
58         break;
59     case eSF_192000Hz:
60         value = 192000;
61         break;
62     case eSF_AnyLow:
63         value = 48000;
64         break;
65     case eSF_AnyMid:
66         value = 96000;
67         break;
68     case eSF_AnyHigh:
69         value = 192000;
70         break;
71     default:
72         value = 0;
73     }
74
75
76     return value;
77 }
78
79 ESamplingFrequency
80 parseSampleRate( int sampleRate )
81 {
82     ESamplingFrequency efreq;
83     switch ( sampleRate ) {
84     case 22050:
85         efreq = eSF_22050Hz;
86         break;
87     case 24000:
88         efreq = eSF_24000Hz;
89         break;
90     case 32000:
91         efreq = eSF_32000Hz;
92         break;
93     case 44100:
94         efreq = eSF_44100Hz;
95         break;
96     case 48000:
97         efreq = eSF_48000Hz;
98         break;
99     case 88200:
100         efreq = eSF_88200Hz;
101         break;
102     case 96000:
103         efreq = eSF_96000Hz;
104         break;
105     case 176400:
106         efreq = eSF_176400Hz;
107         break;
108     case 192000:
109         efreq = eSF_192000Hz;
110         break;
111     default:
112         efreq = eSF_DontCare;
113     }
114
115     return efreq;
116 }
117
118 std::ostream& operator<<( std::ostream& stream, ESamplingFrequency samplingFrequency )
119 {
120     char* str;
121     switch ( samplingFrequency ) {
122     case eSF_22050Hz:
123         str = "22050";
124         break;
125     case eSF_24000Hz:
126         str = "24000";
127         break;
128     case eSF_32000Hz:
129         str = "32000";
130         break;
131     case eSF_44100Hz:
132         str = "44100";
133         break;
134     case eSF_48000Hz:
135         str = "48000";
136         break;
137     case eSF_88200Hz:
138         str = "88200";
139         break;
140     case eSF_96000Hz:
141         str = "96000";
142         break;
143     case eSF_176400Hz:
144         str = "176400";
145         break;
146     case eSF_192000Hz:
147         str = "192000";
148         break;
149     case eSF_DontCare:
150     default:
151         str = "unknown";
152     }
153     return stream << str;
154 };
155
156 enum ESubunitType byteToSubunitType(byte_t s) {
157     switch (s) {
158     case eST_Monitor:
159         return eST_Monitor;
160     case eST_Audio:
161         return eST_Audio;
162     case eST_Printer:
163         return eST_Printer;
164     case eST_Disc:
165         return eST_Disc;
166     case eST_VCR:
167         return eST_VCR;
168     case eST_Tuner:
169         return eST_Tuner;
170     case eST_CA:
171         return eST_CA;
172     case eST_Camera:
173         return eST_Camera;
174     case eST_Panel:
175         return eST_Panel;
176     case eST_BulltinBoard:
177         return eST_BulltinBoard;
178     case eST_CameraStorage:
179         return eST_CameraStorage;
180     case eST_Music:
181         return eST_Music;
182     case eST_VendorUnique:
183         return eST_VendorUnique;
184     case eST_Reserved:
185         return eST_Reserved;
186     case eST_Extended:
187         return eST_Extended;
188     default:
189     case eST_Unit:
190         return eST_Unit;
191     }
192 }
193
194 unsigned int fdfSfcToSampleRate(byte_t fdf) {
195     switch(fdf & 0x07) {
196         default:                       return 0;
197         case IEC61883_FDF_SFC_32KHZ:   return 32000;
198         case IEC61883_FDF_SFC_44K1HZ:  return 44100;
199         case IEC61883_FDF_SFC_48KHZ:   return 48000;
200         case IEC61883_FDF_SFC_88K2HZ:  return 88200;
201         case IEC61883_FDF_SFC_96KHZ:   return 96000;
202         case IEC61883_FDF_SFC_176K4HZ: return 176400;
203         case IEC61883_FDF_SFC_192KHZ:  return 192000;
204     }
205 }
206
207 byte_t sampleRateToFdfSfc(unsigned int rate) {
208     switch(rate) {
209         default:      return 0x07;
210         case 32000:   return IEC61883_FDF_SFC_32KHZ;
211         case 44100:   return IEC61883_FDF_SFC_44K1HZ;
212         case 48000:   return IEC61883_FDF_SFC_48KHZ;
213         case 88200:   return IEC61883_FDF_SFC_88K2HZ;
214         case 96000:   return IEC61883_FDF_SFC_96KHZ;
215         case 176400:  return IEC61883_FDF_SFC_176K4HZ;
216         case 192000:  return IEC61883_FDF_SFC_192KHZ;
217     }
218 }
219
220 }
Note: See TracBrowser for help on using the browser.