root/trunk/libffado/src/fireworks/fireworks_device.h

Revision 1133, 3.5 kB (checked in by ppalmers, 16 years ago)

convert fireworks poll lock to stack based locking

Line 
1 /*
2  * Copyright (C) 2005-2008 by Daniel Wagner
3  * Copyright (C) 2005-2008 by Pieter Palmers
4  *
5  * This file is part of FFADO
6  * FFADO = Free Firewire (pro-)audio drivers for linux
7  *
8  * FFADO is based upon FreeBoB.
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 2 of the License, or
13  * (at your option) version 3 of the License.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
22  *
23  */
24
25 #ifndef FIREWORKS_DEVICE_H
26 #define FIREWORKS_DEVICE_H
27
28 #include "debugmodule/debugmodule.h"
29
30 #include "genericavc/avc_avdevice.h"
31
32 #include "efc/efc_cmd.h"
33 #include "efc/efc_cmds_hardware.h"
34
35 #include <pthread.h>
36 #include "libutil/Mutex.h"
37
38 class ConfigRom;
39 class Ieee1394Service;
40
41 namespace FireWorks {
42
43 class Device : public GenericAVC::AvDevice {
44 public:
45     Device( DeviceManager& d, std::auto_ptr<ConfigRom>( configRom ) );
46     virtual ~Device();
47    
48     static bool probe( ConfigRom& configRom );
49     static FFADODevice * createDevice( DeviceManager& d, std::auto_ptr<ConfigRom>( configRom ));
50     virtual bool discover();
51
52     virtual void showDevice();
53    
54     virtual bool buildMixer();
55     virtual bool destroyMixer();
56
57     virtual ClockSourceVector getSupportedClockSources();
58     virtual bool setActiveClockSource(ClockSource);
59     virtual ClockSource getActiveClockSource();
60
61     const EfcHardwareInfoCmd getHwInfo()
62         {return m_HwInfo;};
63
64 // protected: //?
65     bool doEfcOverAVC(EfcCmd& c);
66    
67     /**
68      * @brief Read flash
69      * @param start start address
70      * @param len length in quadlets (4 bytes)
71      * @param buffer target buffer (should be 'len*4' bytes long)
72      * @return true if successful
73      */
74     bool readFlash(uint32_t start, uint32_t len, uint32_t* buffer);
75
76     /**
77      * @brief Write flash
78      * @param start start address
79      * @param len length in quadlets (4 bytes)
80      * @param buffer target buffer (should be 'len*4' bytes long)
81      * @return true if successful
82      */
83     bool writeFlash(uint32_t start, uint32_t len, uint32_t* buffer);
84
85     /**
86      * @brief (un)lock the flash
87      * @param lock true=locked, false=unlocked
88      * @return true if successful
89      */
90     bool lockFlash(bool lock);
91     /**
92      * @brief erase flash block
93      * @param addr address of block to erase
94      * @return true if successful
95      */
96     bool eraseFlash(uint32_t addr);
97
98     /**
99      * @brief wait until the device indicates the flash memory is ready
100      * @param msecs time to wait before timeout
101      * @return true if the flash is ready, false if timeout
102      */
103     bool waitForFlash(unsigned int msecs);
104
105 // Echo specific stuff
106 private:
107    
108     bool discoverUsingEFC();
109
110     FFADODevice::ClockSource clockIdToClockSource(uint32_t clockflag);
111     bool isClockValid(uint32_t id);
112     uint32_t getClock();
113     bool setClock(uint32_t);
114
115     uint32_t            m_efc_version;
116
117     EfcHardwareInfoCmd  m_HwInfo;
118
119     bool updatePolledValues();
120     Util::Mutex*        m_poll_lock;
121     EfcPolledValuesCmd  m_Polled;
122
123     bool                m_efc_discovery_done;
124
125 private:
126     Control::Container *m_MixerContainer;
127
128 };
129
130 } // namespace FireWorks
131
132 #endif
Note: See TracBrowser for help on using the browser.