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

Revision 516, 3.9 kB (checked in by wagi, 16 years ago)

- some de/serialing bugs found and fixed
- caching enabled for bebob devices

(finally online again! big thanks to my free wireless internet provider. s/he is finally back from
her/his holiday :)

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     static int getConfigurationId( );
78     virtual bool discover();
79
80     virtual bool setSamplingFrequency( ESamplingFrequency 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.