root/branches/streaming-rework/src/bounce/bounce_avdevice.h

Revision 419, 4.1 kB (checked in by pieterpalmers, 17 years ago)

namespace simplification

Line 
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 "libfreebobavc/avc_definitions.h"
26 #include "libfreebobavc/avc_extended_cmd_generic.h"
27 #include "libfreebob/xmlparser.h"
28
29 #include "libstreaming/AmdtpStreamProcessor.h"
30 #include "libstreaming/AmdtpPort.h"
31 #include "libstreaming/AmdtpPortInfo.h"
32
33 #include "libieee1394/ARMHandler.h"
34
35 #include "iavdevice.h"
36 #include "libfreebob/freebob_bounce.h"
37
38 #include <vector>
39
40 #define BOUNCE_REGISTER_BASE 0x0000FFFFE0000000ULL
41 #define BOUNCE_REGISTER_LENGTH (4*256)
42 #define BOUNCE_REGISTER_TX_ISOCHANNEL 0x10
43 #define BOUNCE_REGISTER_RX_ISOCHANNEL 0x14
44 #define BOUNCE_INVALID_OFFSET 0xFFFFF00000000000ULL
45
46 class ConfigRom;
47 class Ieee1394Service;
48
49 namespace Bounce {
50
51 // struct to define the supported devices
52 struct VendorModelEntry {
53     unsigned int vendor_id;
54     unsigned int model_id;
55     unsigned int unit_specifier_id;
56     char *vendor_name;
57     char *model_name;
58 };
59
60 class BounceDevice : public IAvDevice {
61 private:
62     class BounceNotifier;
63 public:
64     BounceDevice( std::auto_ptr<ConfigRom>( configRom ),
65                   Ieee1394Service& ieee1394Service,
66                   int nodeId,
67                   int verboseLevel );
68     virtual ~BounceDevice();
69
70     static bool probe( ConfigRom& configRom );
71     virtual bool discover();
72     virtual ConfigRom& getConfigRom() const;
73    
74     virtual bool addXmlDescription( xmlNodePtr deviceNode );
75    
76     virtual bool setSamplingFrequency( ESamplingFrequency samplingFrequency );
77         virtual int getSamplingFrequency( );
78    
79         virtual bool prepare();
80     bool lock();
81     bool unlock();
82        
83         virtual int getStreamCount();
84        
85         virtual Streaming::StreamProcessor *getStreamProcessorByIndex(int i);
86        
87     bool startStreamByIndex(int i);
88     bool stopStreamByIndex(int i);
89    
90     virtual void showDevice() const;
91     virtual bool setId(unsigned int id);
92
93 protected:
94     std::auto_ptr<ConfigRom>( m_configRom );
95     Ieee1394Service* m_p1394Service;
96     int              m_nodeId;
97     int              m_verboseLevel;
98
99 private:
100         std::string xmlDescription;
101
102     unsigned int m_samplerate;
103     struct VendorModelEntry* m_model;
104
105     // streaming stuff
106     typedef std::vector< Streaming::StreamProcessor * > StreamProcessorVector;
107     StreamProcessorVector m_receiveProcessors;
108     StreamProcessorVector m_transmitProcessors;
109
110     bool addPortsToProcessor(
111        Streaming::StreamProcessor *processor,
112        Streaming::Port::E_Direction direction);
113
114     DECLARE_DEBUG_MODULE;
115    
116 private: // generic helpers
117     int allocateIsoChannel(unsigned int packet_size);
118     bool deallocateIsoChannel(int channel);
119    
120 private: // I/O helpers
121     // quadlet read/write routines
122     bool readReg(fb_nodeaddr_t, fb_quadlet_t *);
123     bool writeReg(fb_nodeaddr_t, fb_quadlet_t);
124     bool readRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t);
125     bool writeRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t);
126    
127 private:
128     BounceNotifier *m_Notifier;
129     /**
130      * this class reacts on the ohter side writing to the
131      * hosts address space
132      */
133     #define BOUNCE_NOTIFIER_BASE_ADDRESS 0x0000FFFFE0000000ULL
134     #define BOUNCE_NOTIFIER_BLOCK_LENGTH 4
135     class BounceNotifier : public ARMHandler
136     {
137     public:
138         BounceNotifier(BounceDevice *, nodeaddr_t start);
139         virtual ~BounceNotifier();
140        
141     private:
142         BounceDevice *m_bouncedevice;
143     };
144 };
145
146 }
147
148 #endif
Note: See TracBrowser for help on using the browser.