2 * Copyright (C) 2005-2008 by Daniel Wagner
3 * Copyright (C) 2005-2008 by Pieter Palmers
5 * This file is part of FFADO
6 * FFADO = Free Firewire (pro-)audio drivers for linux
8 * FFADO is based upon FreeBoB.
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.
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.
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/>.
25 #ifndef FIREWORKS_DEVICE_H
26 #define FIREWORKS_DEVICE_H
28 #include "debugmodule/debugmodule.h"
30 #include "genericavc/avc_avdevice.h"
32 #include "efc/efc_cmd.h"
33 #include "efc/efc_cmds_hardware.h"
34 #include "efc/efc_cmds_hardware_ctrl.h"
35 #include "fireworks_session_block.h"
38 #include "libutil/Mutex.h"
41 class Ieee1394Service
;
45 class Device
: public GenericAVC::Device
{
46 friend class MonitorControl
;
47 friend class SimpleControl
;
48 friend class BinaryControl
;
49 friend class IOConfigControl
;
52 Device( DeviceManager
& d
, std::auto_ptr
<ConfigRom
>( configRom
) );
55 static bool probe( Util::Configuration
&, ConfigRom
& configRom
, bool generic
= false );
56 static FFADODevice
* createDevice( DeviceManager
& d
, std::auto_ptr
<ConfigRom
>( configRom
));
57 virtual bool discover();
59 virtual void showDevice();
61 virtual bool buildMixer();
62 virtual bool destroyMixer();
64 virtual std::vector
<int> getSupportedSamplingFrequencies();
66 virtual ClockSourceVector
getSupportedClockSources();
67 virtual bool setActiveClockSource(ClockSource
);
68 virtual ClockSource
getActiveClockSource();
69 virtual int getSamplingFrequency();
70 virtual bool setSamplingFrequency( int );
72 const EfcHardwareInfoCmd
getHwInfo()
76 bool doEfcOverAVC(EfcCmd
& c
);
80 * @param start start address
81 * @param len length in quadlets (4 bytes)
82 * @param buffer target buffer (should be 'len*4' bytes long)
83 * @return true if successful
85 bool readFlash(uint32_t start
, uint32_t len
, uint32_t* buffer
);
89 * @param start start address
90 * @param len length in quadlets (4 bytes)
91 * @param buffer target buffer (should be 'len*4' bytes long)
92 * @return true if successful
94 bool writeFlash(uint32_t start
, uint32_t len
, uint32_t* buffer
);
97 * @brief (un)lock the flash
98 * @param lock true=locked, false=unlocked
99 * @return true if successful
101 bool lockFlash(bool lock
);
103 * @brief erase flash block
104 * @param addr address of block to erase
105 * @return true if successful
107 bool eraseFlash(uint32_t addr
);
108 bool eraseFlashBlocks(uint32_t start_address
, unsigned int nb_quads
);
111 * @brief wait until the device indicates the flash memory is ready
112 * @param msecs time to wait before timeout
113 * @return true if the flash is ready, false if timeout
115 bool waitForFlash(unsigned int msecs
);
118 * @brief get the flash address of the session block
119 * @return session block base address
121 uint32_t getSessionBase();
124 * load the session block from the device
125 * @return true if successful
129 * save the session block to the device
130 * @return true if successful
134 // Echo specific stuff
137 bool discoverUsingEFC();
139 FFADODevice::ClockSource
clockIdToClockSource(uint32_t clockflag
);
140 bool isClockValid(uint32_t id
);
142 bool getClock(EfcGetClockCmd
&gccmd
);
143 uint32_t getClockSrc();
145 bool setClock(EfcSetClockCmd sccmd
);
146 bool setClockSrc(uint32_t clock
);
149 * Audiofire12 often return wrong data for clock source.
150 * This member is used to cache the latest clock source change.
154 EfcHardwareInfoCmd m_HwInfo
;
156 bool updatePolledValues();
157 Util::Mutex
* m_poll_lock
;
158 EfcPolledValuesCmd m_Polled
;
160 bool m_efc_discovery_done
;
165 Control::Container
*m_MixerContainer
;
166 Control::Container
*m_HwInfoContainer
;
171 } // namespace FireWorks