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

Revision 436, 5.9 kB (checked in by pieterpalmers, 15 years ago)

- fixed verbose level setting
- debugged DICE code, works with EVM

Line 
1 /* dice_avdevice.h
2  * Copyright (C) 2007 by Pieter Palmers
3  *
4  * This file is part of FreeBob.
5  *
6  * FreeBob is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  * FreeBob is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with FreeBob; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
18  * MA 02111-1307 USA.
19  */
20 #ifndef DICEDEVICE_H
21 #define DICEDEVICE_H
22
23 #include "iavdevice.h"
24
25 #include "debugmodule/debugmodule.h"
26 #include "libavc/avc_definitions.h"
27
28 #include "libstreaming/AmdtpStreamProcessor.h"
29 #include "libstreaming/AmdtpPort.h"
30 #include "libieee1394/ARMHandler.h"
31
32 #include <string>
33 #include <vector>
34
35 class ConfigRom;
36 class Ieee1394Service;
37
38 namespace Dice {
39
40 class DiceNotifier;
41
42 // struct to define the supported devices
43 struct VendorModelEntry {
44     unsigned int vendor_id;
45     unsigned int model_id;
46     char *vendor_name;
47     char *model_name;
48 };
49
50 class DiceAvDevice : public IAvDevice {
51 private:
52     class DiceNotifier;
53 public:
54     DiceAvDevice( std::auto_ptr<ConfigRom>( configRom ),
55                   Ieee1394Service& ieee1394Service,
56                   int nodeId);
57     ~DiceAvDevice();
58
59     static bool probe( ConfigRom& configRom );
60     bool discover();
61
62     void showDevice();
63
64     bool setSamplingFrequency( ESamplingFrequency samplingFrequency );
65     int getSamplingFrequency( );
66
67     int getStreamCount();
68     Streaming::StreamProcessor *getStreamProcessorByIndex(int i);
69
70     bool prepare();
71    
72     bool lock();
73     bool unlock();
74    
75     bool startStreamByIndex(int i);
76     bool stopStreamByIndex(int i);
77    
78     bool enableStreaming();
79     bool disableStreaming();
80    
81 protected:
82     struct VendorModelEntry *m_model;
83    
84     // streaming stuff
85     typedef std::vector< Streaming::StreamProcessor * > StreamProcessorVector;
86     StreamProcessorVector m_receiveProcessors;
87     StreamProcessorVector m_transmitProcessors;
88    
89 private: // streaming & port helpers
90     enum EPortTypes {
91         ePT_Analog,
92         ePT_MIDI,
93     };
94    
95     typedef struct {
96         std::string name;
97         enum EPortTypes portType;
98         unsigned int streamPosition;
99         unsigned int streamLocation;
100     } diceChannelInfo;
101    
102     bool addChannelToProcessor( diceChannelInfo *,
103                               Streaming::StreamProcessor *,
104                               Streaming::Port::E_Direction direction);
105    
106     int allocateIsoChannel(unsigned int packet_size);
107     bool deallocateIsoChannel(int channel);
108    
109 private: // helper functions
110     bool enableIsoStreaming();
111     bool disableIsoStreaming();
112     bool isIsoStreamingEnabled();
113    
114     bool maskedCheckZeroGlobalReg(fb_nodeaddr_t offset, fb_quadlet_t mask);
115     bool maskedCheckNotZeroGlobalReg(fb_nodeaddr_t offset, fb_quadlet_t mask);
116    
117     typedef std::vector< std::string > diceNameVector;
118     typedef std::vector< std::string >::iterator diceNameVectorIterator;
119     diceNameVector splitNameString(std::string in);
120     diceNameVector getTxNameString(unsigned int i);
121     diceNameVector getRxNameString(unsigned int i);
122     diceNameVector getClockSourceNameString();
123     std::string getDeviceNickName();
124    
125 private: // register I/O routines
126     bool initIoFunctions();
127     // quadlet read/write routines
128     bool readReg(fb_nodeaddr_t, fb_quadlet_t *);
129     bool writeReg(fb_nodeaddr_t, fb_quadlet_t);
130     bool readRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t);
131     bool writeRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t);
132    
133     bool readGlobalReg(fb_nodeaddr_t, fb_quadlet_t *);
134     bool writeGlobalReg(fb_nodeaddr_t, fb_quadlet_t);
135     bool readGlobalRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t);
136     bool writeGlobalRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t);
137     fb_nodeaddr_t globalOffsetGen(fb_nodeaddr_t, size_t);
138    
139     bool readTxReg(unsigned int i, fb_nodeaddr_t, fb_quadlet_t *);
140     bool writeTxReg(unsigned int i, fb_nodeaddr_t, fb_quadlet_t);
141     bool readTxRegBlock(unsigned int i, fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length);
142     bool writeTxRegBlock(unsigned int i, fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length);
143     fb_nodeaddr_t txOffsetGen(unsigned int, fb_nodeaddr_t, size_t);
144    
145     bool readRxReg(unsigned int i, fb_nodeaddr_t, fb_quadlet_t *);
146     bool writeRxReg(unsigned int i, fb_nodeaddr_t, fb_quadlet_t);
147     bool readRxRegBlock(unsigned int i, fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length);
148     bool writeRxRegBlock(unsigned int i, fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length);
149     fb_nodeaddr_t rxOffsetGen(unsigned int, fb_nodeaddr_t, size_t);
150    
151     fb_quadlet_t m_global_reg_offset;
152     fb_quadlet_t m_global_reg_size;
153     fb_quadlet_t m_tx_reg_offset;
154     fb_quadlet_t m_tx_reg_size;
155     fb_quadlet_t m_rx_reg_offset;
156     fb_quadlet_t m_rx_reg_size;
157     fb_quadlet_t m_unused1_reg_offset;
158     fb_quadlet_t m_unused1_reg_size;
159     fb_quadlet_t m_unused2_reg_offset;
160     fb_quadlet_t m_unused2_reg_size;
161    
162     fb_quadlet_t m_nb_tx;
163     fb_quadlet_t m_tx_size;
164     fb_quadlet_t m_nb_rx;
165     fb_quadlet_t m_rx_size;
166    
167 private:
168     // notification
169     DiceNotifier *m_notifier;
170    
171     /**
172      * this class reacts on the DICE device writing to the
173      * hosts notify address
174      */
175     #define DICE_NOTIFIER_BASE_ADDRESS 0x0000FFFFE0000000ULL
176     #define DICE_NOTIFIER_BLOCK_LENGTH 4
177     class DiceNotifier : public ARMHandler
178     {
179     public:
180         DiceNotifier(DiceAvDevice *, nodeaddr_t start);
181         virtual ~DiceNotifier();
182        
183     private:
184         DiceAvDevice *m_dicedevice;
185     };
186
187 };
188
189 }
190 #endif
Note: See TracBrowser for help on using the browser.