root/trunk/libffado/src/bounce/bounce_avdevice.h

Revision 554, 3.9 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  * Copyright (C) 2005-2007 by Daniel Wagner
4  *
5  * This file is part of FFADO
6  * FFADO = Free Firewire (pro-)audio drivers for linux
7  *
8  * FFADO is based upon FreeBoB
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License version 2.1, as published by the Free Software Foundation;
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
22  * MA 02110-1301 USA
23  */
24
25 #ifndef BOUNCEDEVICE_H
26 #define BOUNCEDEVICE_H
27
28 #include "debugmodule/debugmodule.h"
29 #include "libavc/avc_definitions.h"
30 #include "libavc/general/avc_extended_cmd_generic.h"
31
32 #include "libstreaming/AmdtpStreamProcessor.h"
33 #include "libstreaming/AmdtpPort.h"
34 #include "libstreaming/AmdtpPortInfo.h"
35
36 #include "libieee1394/ARMHandler.h"
37
38 #include "ffadodevice.h"
39
40 #include <vector>
41
42 #define BOUNCE_REGISTER_BASE 0x0000FFFFE0000000ULL
43 #define BOUNCE_REGISTER_LENGTH (4*256)
44 #define BOUNCE_REGISTER_TX_ISOCHANNEL 0x10
45 #define BOUNCE_REGISTER_RX_ISOCHANNEL 0x14
46 #define BOUNCE_INVALID_OFFSET 0xFFFFF00000000000ULL
47
48 #define BOUNCE_NB_AUDIO_CHANNELS 4
49
50 // don't define more than 8 midi channels!
51 #define BOUNCE_NB_MIDI_CHANNELS  2
52
53 class ConfigRom;
54 class Ieee1394Service;
55
56 namespace Bounce {
57
58 // struct to define the supported devices
59 struct VendorModelEntry {
60     uint32_t vendor_id;
61     uint32_t model_id;
62     uint32_t unit_specifier_id;
63     char *vendor_name;
64     char *model_name;
65 };
66
67 class BounceDevice : public FFADODevice {
68 private:
69     class BounceNotifier;
70 public:
71     BounceDevice( std::auto_ptr<ConfigRom>( configRom ),
72           Ieee1394Service& ieee1394Service,
73           int nodeId );
74     virtual ~BounceDevice();
75
76     static bool probe( ConfigRom& configRom );
77     static int getConfigurationId( );
78     virtual bool discover();
79
80     virtual bool setSamplingFrequency( int samplingFrequency );
81     virtual int getSamplingFrequency( );
82
83     virtual bool prepare();
84     virtual bool lock();
85     virtual bool unlock();
86
87     virtual int getStreamCount();
88
89     virtual Streaming::StreamProcessor *getStreamProcessorByIndex(int i);
90
91     virtual bool startStreamByIndex(int i);
92     virtual bool stopStreamByIndex(int i);
93
94     virtual void showDevice();
95
96 protected:
97     unsigned int m_samplerate;
98     struct VendorModelEntry* m_model;
99
100     // streaming stuff
101     typedef std::vector< Streaming::StreamProcessor * > StreamProcessorVector;
102     StreamProcessorVector m_receiveProcessors;
103     StreamProcessorVector m_transmitProcessors;
104
105     bool addPortsToProcessor(
106        Streaming::StreamProcessor *processor,
107        Streaming::Port::E_Direction direction);
108
109 private: // generic helpers
110     int allocateIsoChannel(unsigned int packet_size);
111     bool deallocateIsoChannel(int channel);
112
113 protected: // I/O helpers
114     // quadlet read/write routines
115     bool readReg(fb_nodeaddr_t, fb_quadlet_t *);
116     bool writeReg(fb_nodeaddr_t, fb_quadlet_t);
117     bool readRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t);
118     bool writeRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t);
119
120 private:
121     BounceNotifier *m_Notifier;
122     /**
123      * this class reacts on the other side writing to the
124      * hosts address space
125      */
126     #define BOUNCE_NOTIFIER_BASE_ADDRESS 0x0000FFFFE0000000ULL
127     #define BOUNCE_NOTIFIER_BLOCK_LENGTH 4
128     class BounceNotifier : public ARMHandler
129     {
130     public:
131         BounceNotifier(BounceDevice *, nodeaddr_t start);
132         virtual ~BounceNotifier();
133
134     private:
135         BounceDevice *m_bouncedevice;
136     };
137 };
138
139 }
140
141 #endif
Note: See TracBrowser for help on using the browser.