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

Revision 445, 3.7 kB (checked in by pieterpalmers, 15 years ago)

* name change from FreeBoB to FFADO
* replaced tabs by 4 spaces
* got rid of end-of-line spaces
* made all license and copyrights conform

library becomes LGPL, apps become GPL
explicitly state LGPL v2.1 and GPL v2 (don't like v3 draft)

copyrights are 2005-2007 Daniel & Pieter
except for the MotU stuff (C) Jonathan, Pieter

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/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 "iavdevice.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 IAvDevice {
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     bool discover();
78
79     bool setSamplingFrequency( ESamplingFrequency samplingFrequency );
80     int getSamplingFrequency( );
81
82     bool prepare();
83     bool lock();
84     bool unlock();
85
86     int getStreamCount();
87
88     Streaming::StreamProcessor *getStreamProcessorByIndex(int i);
89
90     bool startStreamByIndex(int i);
91     bool stopStreamByIndex(int i);
92
93     void showDevice();
94
95 protected:
96     unsigned int m_samplerate;
97     struct VendorModelEntry* m_model;
98
99     // streaming stuff
100     typedef std::vector< Streaming::StreamProcessor * > StreamProcessorVector;
101     StreamProcessorVector m_receiveProcessors;
102     StreamProcessorVector m_transmitProcessors;
103
104     bool addPortsToProcessor(
105        Streaming::StreamProcessor *processor,
106        Streaming::Port::E_Direction direction);
107
108 private: // generic helpers
109     int allocateIsoChannel(unsigned int packet_size);
110     bool deallocateIsoChannel(int channel);
111
112 protected: // I/O helpers
113     // quadlet read/write routines
114     bool readReg(fb_nodeaddr_t, fb_quadlet_t *);
115     bool writeReg(fb_nodeaddr_t, fb_quadlet_t);
116     bool readRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t);
117     bool writeRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t);
118
119 private:
120     BounceNotifier *m_Notifier;
121     /**
122      * this class reacts on the other side writing to the
123      * hosts address space
124      */
125     #define BOUNCE_NOTIFIER_BASE_ADDRESS 0x0000FFFFE0000000ULL
126     #define BOUNCE_NOTIFIER_BLOCK_LENGTH 4
127     class BounceNotifier : public ARMHandler
128     {
129     public:
130         BounceNotifier(BounceDevice *, nodeaddr_t start);
131         virtual ~BounceNotifier();
132
133     private:
134         BounceDevice *m_bouncedevice;
135     };
136 };
137
138 }
139
140 #endif
Note: See TracBrowser for help on using the browser.