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() const; |
---|
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 |
protected: |
---|
79 |
std::auto_ptr<ConfigRom>( m_configRom ); |
---|
80 |
Ieee1394Service* m_p1394Service; |
---|
81 |
|
---|
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 |
diceNameVector splitNameString(std::string in); |
---|
119 |
diceNameVector getTxNameString(unsigned int i); |
---|
120 |
diceNameVector getRxNameString(unsigned int i); |
---|
121 |
diceNameVector getClockSourceNameString(); |
---|
122 |
std::string getDeviceNickName(); |
---|
123 |
|
---|
124 |
private: // register I/O routines |
---|
125 |
bool initIoFunctions(); |
---|
126 |
// quadlet read/write routines |
---|
127 |
bool readReg(fb_nodeaddr_t, fb_quadlet_t *); |
---|
128 |
bool writeReg(fb_nodeaddr_t, fb_quadlet_t); |
---|
129 |
bool readRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t); |
---|
130 |
bool writeRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t); |
---|
131 |
|
---|
132 |
bool readGlobalReg(fb_nodeaddr_t, fb_quadlet_t *); |
---|
133 |
bool writeGlobalReg(fb_nodeaddr_t, fb_quadlet_t); |
---|
134 |
bool readGlobalRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t); |
---|
135 |
bool writeGlobalRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t); |
---|
136 |
fb_nodeaddr_t globalOffsetGen(fb_nodeaddr_t, size_t); |
---|
137 |
|
---|
138 |
bool readTxReg(unsigned int i, fb_nodeaddr_t, fb_quadlet_t *); |
---|
139 |
bool writeTxReg(unsigned int i, fb_nodeaddr_t, fb_quadlet_t); |
---|
140 |
bool readTxRegBlock(unsigned int i, fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length); |
---|
141 |
bool writeTxRegBlock(unsigned int i, fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length); |
---|
142 |
fb_nodeaddr_t txOffsetGen(unsigned int, fb_nodeaddr_t, size_t); |
---|
143 |
|
---|
144 |
bool readRxReg(unsigned int i, fb_nodeaddr_t, fb_quadlet_t *); |
---|
145 |
bool writeRxReg(unsigned int i, fb_nodeaddr_t, fb_quadlet_t); |
---|
146 |
bool readRxRegBlock(unsigned int i, fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length); |
---|
147 |
bool writeRxRegBlock(unsigned int i, fb_nodeaddr_t offset, fb_quadlet_t *data, size_t length); |
---|
148 |
fb_nodeaddr_t rxOffsetGen(unsigned int, fb_nodeaddr_t, size_t); |
---|
149 |
|
---|
150 |
fb_quadlet_t m_global_reg_offset; |
---|
151 |
fb_quadlet_t m_global_reg_size; |
---|
152 |
fb_quadlet_t m_tx_reg_offset; |
---|
153 |
fb_quadlet_t m_tx_reg_size; |
---|
154 |
fb_quadlet_t m_rx_reg_offset; |
---|
155 |
fb_quadlet_t m_rx_reg_size; |
---|
156 |
fb_quadlet_t m_unused1_reg_offset; |
---|
157 |
fb_quadlet_t m_unused1_reg_size; |
---|
158 |
fb_quadlet_t m_unused2_reg_offset; |
---|
159 |
fb_quadlet_t m_unused2_reg_size; |
---|
160 |
|
---|
161 |
fb_quadlet_t m_nb_tx; |
---|
162 |
fb_quadlet_t m_tx_size; |
---|
163 |
fb_quadlet_t m_nb_rx; |
---|
164 |
fb_quadlet_t m_rx_size; |
---|
165 |
|
---|
166 |
private: |
---|
167 |
// notification |
---|
168 |
DiceNotifier *m_notifier; |
---|
169 |
|
---|
170 |
/** |
---|
171 |
* this class reacts on the DICE device writing to the |
---|
172 |
* hosts notify address |
---|
173 |
*/ |
---|
174 |
#define DICE_NOTIFIER_BASE_ADDRESS 0x0000FFFFE0000000ULL |
---|
175 |
#define DICE_NOTIFIER_BLOCK_LENGTH 4 |
---|
176 |
class DiceNotifier : public ARMHandler |
---|
177 |
{ |
---|
178 |
public: |
---|
179 |
DiceNotifier(DiceAvDevice *, nodeaddr_t start); |
---|
180 |
virtual ~DiceNotifier(); |
---|
181 |
|
---|
182 |
private: |
---|
183 |
DiceAvDevice *m_dicedevice; |
---|
184 |
}; |
---|
185 |
|
---|
186 |
}; |
---|
187 |
|
---|
188 |
} |
---|
189 |
#endif |
---|