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

Revision 479, 6.0 kB (checked in by wagi, 15 years ago)

- added all missing 'virtual' to function declared in avdevice implementation
- added getConfigurationId function (used for av/c model caching)

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