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

Revision 426, 3.7 kB (checked in by pieterpalmers, 15 years ago)

- changed the IAvDevice from an interface to a base class,

since there is some code duplication starting to
appear.

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 "libavc/avc_definitions.h"
26 #include "libavc/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     uint32_t vendor_id;
54     uint32_t model_id;
55     uint32_t 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     virtual ~BounceDevice();
68
69     static bool probe( ConfigRom& configRom );
70     bool discover();
71    
72     bool setSamplingFrequency( ESamplingFrequency samplingFrequency );
73     int getSamplingFrequency( );
74    
75     bool prepare();
76     bool lock();
77     bool unlock();
78
79     int getStreamCount();
80
81     Streaming::StreamProcessor *getStreamProcessorByIndex(int i);
82
83     bool startStreamByIndex(int i);
84     bool stopStreamByIndex(int i);
85    
86     void showDevice() const;
87
88 protected:
89     unsigned int m_samplerate;
90     struct VendorModelEntry* m_model;
91
92     // streaming stuff
93     typedef std::vector< Streaming::StreamProcessor * > StreamProcessorVector;
94     StreamProcessorVector m_receiveProcessors;
95     StreamProcessorVector m_transmitProcessors;
96
97     bool addPortsToProcessor(
98        Streaming::StreamProcessor *processor,
99        Streaming::Port::E_Direction direction);
100    
101 private: // generic helpers
102     int allocateIsoChannel(unsigned int packet_size);
103     bool deallocateIsoChannel(int channel);
104
105 protected: // I/O helpers
106     // quadlet read/write routines
107     bool readReg(fb_nodeaddr_t, fb_quadlet_t *);
108     bool writeReg(fb_nodeaddr_t, fb_quadlet_t);
109     bool readRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t);
110     bool writeRegBlock(fb_nodeaddr_t, fb_quadlet_t *, size_t);
111    
112 private:
113     BounceNotifier *m_Notifier;
114     /**
115      * this class reacts on the other side writing to the
116      * hosts address space
117      */
118     #define BOUNCE_NOTIFIER_BASE_ADDRESS 0x0000FFFFE0000000ULL
119     #define BOUNCE_NOTIFIER_BLOCK_LENGTH 4
120     class BounceNotifier : public ARMHandler
121     {
122     public:
123         BounceNotifier(BounceDevice *, nodeaddr_t start);
124         virtual ~BounceNotifier();
125        
126     private:
127         BounceDevice *m_bouncedevice;
128     };
129 };
130
131 }
132
133 #endif
Note: See TracBrowser for help on using the browser.