1 |
/* bounce_avdevice.h |
---|
2 |
* Copyright (C) 2006 by Pieter Palmers |
---|
3 |
* Copyright (C) 2006 by Daniel Wagner |
---|
4 |
* |
---|
5 |
* This file is part of FreeBoB. |
---|
6 |
* |
---|
7 |
* FreeBoB is free software; you can redistribute it and/or modify |
---|
8 |
* it under the terms of the GNU General Public License as published by |
---|
9 |
* the Free Software Foundation; either version 2 of the License, or |
---|
10 |
* (at your option) any later version. |
---|
11 |
* FreeBoB is distributed in the hope that it will be useful, |
---|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
14 |
* GNU General Public License for more details. |
---|
15 |
* |
---|
16 |
* You should have received a copy of the GNU General Public License |
---|
17 |
* along with FreeBoB; if not, write to the Free Software |
---|
18 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
---|
19 |
* MA 02111-1307 USA. |
---|
20 |
*/ |
---|
21 |
#ifndef BOUNCEDEVICE_H |
---|
22 |
#define BOUNCEDEVICE_H |
---|
23 |
|
---|
24 |
#include "debugmodule/debugmodule.h" |
---|
25 |
#include "libavc/avc_definitions.h" |
---|
26 |
#include "libavc/avc_extended_cmd_generic.h" |
---|
27 |
|
---|
28 |
#include "libstreaming/AmdtpStreamProcessor.h" |
---|
29 |
#include "libstreaming/AmdtpPort.h" |
---|
30 |
#include "libstreaming/AmdtpPortInfo.h" |
---|
31 |
|
---|
32 |
#include "libieee1394/ARMHandler.h" |
---|
33 |
|
---|
34 |
#include "iavdevice.h" |
---|
35 |
|
---|
36 |
#include <vector> |
---|
37 |
|
---|
38 |
#define BOUNCE_REGISTER_BASE 0x0000FFFFE0000000ULL |
---|
39 |
#define BOUNCE_REGISTER_LENGTH (4*256) |
---|
40 |
#define BOUNCE_REGISTER_TX_ISOCHANNEL 0x10 |
---|
41 |
#define BOUNCE_REGISTER_RX_ISOCHANNEL 0x14 |
---|
42 |
#define BOUNCE_INVALID_OFFSET 0xFFFFF00000000000ULL |
---|
43 |
|
---|
44 |
#define BOUNCE_NB_AUDIO_CHANNELS 4 |
---|
45 |
|
---|
46 |
// don't define more than 8 midi channels! |
---|
47 |
#define BOUNCE_NB_MIDI_CHANNELS 2 |
---|
48 |
|
---|
49 |
class ConfigRom; |
---|
50 |
class Ieee1394Service; |
---|
51 |
|
---|
52 |
namespace Bounce { |
---|
53 |
|
---|
54 |
// struct to define the supported devices |
---|
55 |
struct VendorModelEntry { |
---|
56 |
uint32_t vendor_id; |
---|
57 |
uint32_t model_id; |
---|
58 |
uint32_t unit_specifier_id; |
---|
59 |
char *vendor_name; |
---|
60 |
char *model_name; |
---|
61 |
}; |
---|
62 |
|
---|
63 |
class BounceDevice : public IAvDevice { |
---|
64 |
private: |
---|
65 |
class BounceNotifier; |
---|
66 |
public: |
---|
67 |
BounceDevice( std::auto_ptr<ConfigRom>( configRom ), |
---|
68 |
Ieee1394Service& ieee1394Service, |
---|
69 |
int nodeId ); |
---|
70 |
virtual ~BounceDevice(); |
---|
71 |
|
---|
72 |
static bool probe( ConfigRom& configRom ); |
---|
73 |
bool discover(); |
---|
74 |
|
---|
75 |
bool setSamplingFrequency( ESamplingFrequency samplingFrequency ); |
---|
76 |
int getSamplingFrequency( ); |
---|
77 |
|
---|
78 |
bool prepare(); |
---|
79 |
bool lock(); |
---|
80 |
bool unlock(); |
---|
81 |
|
---|
82 |
int getStreamCount(); |
---|
83 |
|
---|
84 |
Streaming::StreamProcessor *getStreamProcessorByIndex(int i); |
---|
85 |
|
---|
86 |
bool startStreamByIndex(int i); |
---|
87 |
bool stopStreamByIndex(int i); |
---|
88 |
|
---|
89 |
void showDevice(); |
---|
90 |
|
---|
91 |
protected: |
---|
92 |
unsigned int m_samplerate; |
---|
93 |
struct VendorModelEntry* m_model; |
---|
94 |
|
---|
95 |
// streaming stuff |
---|
96 |
typedef std::vector< Streaming::StreamProcessor * > StreamProcessorVector; |
---|
97 |
StreamProcessorVector m_receiveProcessors; |
---|
98 |
StreamProcessorVector m_transmitProcessors; |
---|
99 |
|
---|
100 |
bool addPortsToProcessor( |
---|
101 |
Streaming::StreamProcessor *processor, |
---|
102 |
Streaming::Port::E_Direction direction); |
---|
103 |
|
---|
104 |
private: // generic helpers |
---|
105 |
int allocateIsoChannel(unsigned int packet_size); |
---|
106 |
bool deallocateIsoChannel(int channel); |
---|
107 |
|
---|
108 |
protected: // I/O helpers |
---|
109 |
// quadlet read/write routines |
---|
110 |
bool readReg(fb_nodeaddr_t, fb_quadlet_t *); |
---|
111 |
bool writeReg(fb_nodeaddr_t, fb_quadlet_t); |
---|
112 |
bool readRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t); |
---|
113 |
bool writeRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t); |
---|
114 |
|
---|
115 |
private: |
---|
116 |
BounceNotifier *m_Notifier; |
---|
117 |
/** |
---|
118 |
* this class reacts on the other side writing to the |
---|
119 |
* hosts address space |
---|
120 |
*/ |
---|
121 |
#define BOUNCE_NOTIFIER_BASE_ADDRESS 0x0000FFFFE0000000ULL |
---|
122 |
#define BOUNCE_NOTIFIER_BLOCK_LENGTH 4 |
---|
123 |
class BounceNotifier : public ARMHandler |
---|
124 |
{ |
---|
125 |
public: |
---|
126 |
BounceNotifier(BounceDevice *, nodeaddr_t start); |
---|
127 |
virtual ~BounceNotifier(); |
---|
128 |
|
---|
129 |
private: |
---|
130 |
BounceDevice *m_bouncedevice; |
---|
131 |
}; |
---|
132 |
}; |
---|
133 |
|
---|
134 |
} |
---|
135 |
|
---|
136 |
#endif |
---|