root/branches/libffado-2.0/src/bebob/bebob_dl_mgr.h

Revision 1558, 3.9 kB (checked in by ppalmers, 15 years ago)

add firmware check for Terratec Phase88 (click/pop issue)

Line 
1 /*
2  * Copyright (C) 2005-2008 by Daniel Wagner
3  *
4  * This file is part of FFADO
5  * FFADO = Free Firewire (pro-)audio drivers for linux
6  *
7  * FFADO is based upon FreeBoB
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 2 of the License, or
12  * (at your option) version 3 of the License.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21  *
22  */
23
24 #ifndef BEBOB_DL_MGR_H
25 #define BEBOB_DL_MGR_H
26
27 #include "bebob_dl_codes.h"
28
29 #include "fbtypes.h"
30 #include "libutil/Functors.h"
31
32 #include "debugmodule/debugmodule.h"
33
34 #include <iostream>
35
36 class Ieee1394Service;
37 class ConfigRom;
38
39 using namespace Util;
40
41 namespace BeBoB {
42     class BCD;
43
44     class BootloaderManager {
45     public:
46         BootloaderManager( Ieee1394Service& ieee1349service,
47                            fb_nodeid_t nodeId );
48         ~BootloaderManager();
49
50         const ConfigRom* const getConfigRom() const
51             { return m_configRom; }
52
53         void printInfoRegisters();
54
55         bool downloadFirmware( std::string filename );
56         bool downloadCnE( std::string filename );
57         bool programGUID( octlet_t guid );
58
59         void busresetHandler();
60
61         Ieee1394Service* get1394Serivce() const
62                 { return m_ieee1394service; }
63
64         bool setForceOperations( bool enabled )
65                 { m_forceEnabled = enabled; return true; }
66
67         bool setStartBootloader( bool bStartBootloader )
68             { m_bStartBootloader = bStartBootloader; return true; }
69
70         int getSoftwareVersion() {return m_cachedInfoRegs.m_softwareVersion;};
71         std::string getSoftwareDate();
72         std::string getSoftwareTime();
73
74         protected:
75         enum EObjectType {
76             eOT_Application,
77             eOT_CnE
78         };
79
80         void waitForBusReset();
81         bool writeRequest( CommandCodes& cmd );
82         bool readResponse( CommandCodes& writeRequestCmd );
83         bool downloadObject( BCD& bcd, EObjectType eObject );
84
85         bool programGUIDCmd( octlet_t guid );
86         bool startBootloaderCmd();
87         bool startApplicationCmd();
88         bool initializePersParamCmd();
89         bool initializeConfigToFactorySettingCmd();
90         bool checkDeviceCompatibility( BCD& bcd );
91
92     private:
93         bool cacheInfoRegisters();
94         bool cacheInfoRegisters( int retries );
95
96         struct info_register_t {
97             fb_octlet_t  m_manId;
98             fb_quadlet_t m_protocolVersion;
99             fb_quadlet_t m_bootloaderVersion;
100             fb_octlet_t  m_guid;
101             fb_quadlet_t m_hardwareModelId;
102             fb_quadlet_t m_hardwareRevision;
103             fb_octlet_t  m_softwareDate;
104             fb_octlet_t  m_softwareTime;
105             fb_quadlet_t m_softwareId;
106             fb_quadlet_t m_softwareVersion;
107             fb_quadlet_t m_baseAddress;
108             fb_quadlet_t m_maxImageLen;
109             fb_octlet_t  m_bootloaderDate;
110             fb_octlet_t  m_bootloaderTime;
111             fb_octlet_t  m_debuggerDate;
112             fb_octlet_t  m_debuggerTime;
113             fb_quadlet_t m_debuggerId;
114             fb_quadlet_t m_debuggerVersion;
115         };
116
117         Ieee1394Service*   m_ieee1394service;
118         ConfigRom*         m_configRom;
119
120         EBootloaderProtocolVersion m_protocolVersion;
121         bool               m_isAppRunning;
122         info_register_t    m_cachedInfoRegs;
123
124         pthread_mutex_t m_mutex;
125         pthread_cond_t  m_cond;
126
127         Functor*        m_functor;
128
129             bool            m_forceEnabled;
130         bool            m_bStartBootloader;
131
132         DECLARE_DEBUG_MODULE;
133     };
134 }
135
136 #endif
Note: See TracBrowser for help on using the browser.