root/trunk/libffado/src/dice/dice_avdevice.h

Revision 554, 6.0 kB (checked in by ppalmers, 15 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 #ifndef DICEDEVICE_H
25 #define DICEDEVICE_H
26
27 #include "ffadodevice.h"
28
29 #include "debugmodule/debugmodule.h"
30 #include "libavc/avc_definitions.h"
31
32 #include "libstreaming/AmdtpStreamProcessor.h"
33 #include "libstreaming/AmdtpPort.h"
34 #include "libieee1394/ARMHandler.h"
35
36 #include <string>
37 #include <vector>
38
39 class ConfigRom;
40 class Ieee1394Service;
41
42 namespace Dice {
43
44 class DiceNotifier;
45
46 // struct to define the supported devices
47 struct VendorModelEntry {
48     unsigned int vendor_id;
49     unsigned int model_id;
50     char *vendor_name;
51     char *model_name;
52 };
53
54 class DiceAvDevice : public FFADODevice {
55 private:
56     class DiceNotifier;
57 public:
58     DiceAvDevice( std::auto_ptr<ConfigRom>( configRom ),
59                   Ieee1394Service& ieee1394Service,
60                   int nodeId);
61     ~DiceAvDevice();
62
63     static bool probe( ConfigRom& configRom );
64     static int getConfigurationId( );
65     virtual bool discover();
66
67     virtual void showDevice();
68
69     virtual bool setSamplingFrequency( int samplingFrequency );
70     virtual int getSamplingFrequency( );
71
72     virtual int getStreamCount();
73     virtual Streaming::StreamProcessor *getStreamProcessorByIndex(int i);
74
75     virtual bool prepare();
76
77     virtual bool lock();
78     virtual bool unlock();
79
80     virtual bool startStreamByIndex(int i);
81     virtual bool stopStreamByIndex(int i);
82
83     virtual bool enableStreaming();
84     virtual bool disableStreaming();
85
86 protected:
87     struct VendorModelEntry *m_model;
88
89     // streaming stuff
90     typedef std::vector< Streaming::StreamProcessor * > StreamProcessorVector;
91     StreamProcessorVector m_receiveProcessors;
92     StreamProcessorVector m_transmitProcessors;
93
94 private: // streaming & port helpers
95     enum EPortTypes {
96         ePT_Analog,
97         ePT_MIDI,
98     };
99
100     typedef struct {
101         std::string name;
102         enum EPortTypes portType;
103         unsigned int streamPosition;
104         unsigned int streamLocation;
105     } diceChannelInfo;
106
107     bool addChannelToProcessor( diceChannelInfo *,
108                               Streaming::StreamProcessor *,
109                               Streaming::Port::E_Direction direction);
110
111     int allocateIsoChannel(unsigned int packet_size);
112     bool deallocateIsoChannel(int channel);
113
114 private: // helper functions
115     bool enableIsoStreaming();
116     bool disableIsoStreaming();
117     bool isIsoStreamingEnabled();
118
119     bool maskedCheckZeroGlobalReg(fb_nodeaddr_t offset, fb_quadlet_t mask);
120     bool maskedCheckNotZeroGlobalReg(fb_nodeaddr_t offset, fb_quadlet_t mask);
121
122     typedef std::vector< std::string > diceNameVector;
123     typedef std::vector< std::string >::iterator diceNameVectorIterator;
124     diceNameVector splitNameString(std::string in);
125     diceNameVector getTxNameString(unsigned int i);
126     diceNameVector getRxNameString(unsigned int i);
127     diceNameVector getClockSourceNameString();
128     std::string getDeviceNickName();
129
130 private: // register I/O routines
131     bool initIoFunctions();
132     // quadlet read/write routines
133     bool readReg(fb_nodeaddr_t, fb_quadlet_t *);
134     bool writeReg(fb_nodeaddr_t, fb_quadlet_t);
135     bool readRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t);
136     bool writeRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t);
137
138     bool readGlobalReg(fb_nodeaddr_t, fb_quadlet_t *);
139     bool writeGlobalReg(fb_nodeaddr_t, fb_quadlet_t);
140     bool readGlobalRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t);
141     bool writeGlobalRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t);
142     fb_nodeaddr_t globalOffsetGen(fb_nodeaddr_t, size_t);
143
144     bool readTxReg(unsigned int i, fb_nodeaddr_t, fb_quadlet_t *);
145     bool writeTxReg(unsigned int i, fb_nodeaddr_t, fb_quadlet_t);
146     bool readTxRegBlock(unsigned int i, fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length);
147     bool writeTxRegBlock(unsigned int i, fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length);
148     fb_nodeaddr_t txOffsetGen(unsigned int, fb_nodeaddr_t, size_t);
149
150     bool readRxReg(unsigned int i, fb_nodeaddr_t, fb_quadlet_t *);
151     bool writeRxReg(unsigned int i, fb_nodeaddr_t, fb_quadlet_t);
152     bool readRxRegBlock(unsigned int i, fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length);
153     bool writeRxRegBlock(unsigned int i, fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length);
154     fb_nodeaddr_t rxOffsetGen(unsigned int, fb_nodeaddr_t, size_t);
155
156     fb_quadlet_t m_global_reg_offset;
157     fb_quadlet_t m_global_reg_size;
158     fb_quadlet_t m_tx_reg_offset;
159     fb_quadlet_t m_tx_reg_size;
160     fb_quadlet_t m_rx_reg_offset;
161     fb_quadlet_t m_rx_reg_size;
162     fb_quadlet_t m_unused1_reg_offset;
163     fb_quadlet_t m_unused1_reg_size;
164     fb_quadlet_t m_unused2_reg_offset;
165     fb_quadlet_t m_unused2_reg_size;
166
167     fb_quadlet_t m_nb_tx;
168     fb_quadlet_t m_tx_size;
169     fb_quadlet_t m_nb_rx;
170     fb_quadlet_t m_rx_size;
171
172 private:
173     // notification
174     DiceNotifier *m_notifier;
175
176     /**
177      * this class reacts on the DICE device writing to the
178      * hosts notify address
179      */
180     #define DICE_NOTIFIER_BASE_ADDRESS 0x0000FFFFE0000000ULL
181     #define DICE_NOTIFIER_BLOCK_LENGTH 4
182     class DiceNotifier : public ARMHandler
183     {
184     public:
185         DiceNotifier(DiceAvDevice *, nodeaddr_t start);
186         virtual ~DiceNotifier();
187
188     private:
189         DiceAvDevice *m_dicedevice;
190     };
191 };
192
193 }
194 #endif
Note: See TracBrowser for help on using the browser.