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

Revision 734, 6.3 kB (checked in by ppalmers, 15 years ago)

merge ppalmers-streaming branch

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