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

Revision 583, 4.0 kB (checked in by ppalmers, 17 years ago)

- Clean up the FFADODevice constructor to remove the nodeid that

can be retrieved from the configrom.

- Implement new method of creating devices: a device is supposed

to implement the createDevice static method that should return
an instance of itself or a subclass of itself. This should ease
support for manufacturer specific customizations since we don't
have to put them into the device manager class.

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