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

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