root/trunk/libffado/src/fireworks/efc/efc_cmd.h

Revision 629, 3.4 kB (checked in by ppalmers, 16 years ago)

- Base infrastructure for the Echo EFC commands
- Some first command implementations

Line 
1 /*
2  * Copyright (C) 2007 by Pieter Palmers
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 library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License version 2.1, as published by the Free Software Foundation;
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21  * MA 02110-1301 USA
22  */
23
24 #ifndef FIREWORKS_EFC_CMD_H
25 #define FIREWORKS_EFC_CMD_H
26
27 #include "debugmodule/debugmodule.h"
28
29 #include "libutil/cmd_serialize.h"
30
31 #define EFC_CAT_INVALID                 0xFFFFFFFF
32 #define EFC_CMD_INVALID                 0xFFFFFFFF
33
34 // Categories
35 #define EFC_CAT_HARDWARE_INFO           0
36 #define EFC_CAT_FLASH                   1
37 #define EFC_CAT_TRANSPORT               2
38 #define EFC_CAT_HARDWARE_CONTROL        3
39 #define EFC_CAT_PHYSICAL_OUTPUT_MIX     4
40 #define EFC_CAT_PHYSICAL_INPUT_MIX      5
41 #define EFC_CAT_PLAYBACK_MIX            6
42 #define EFC_CAT_RECORD_MIX              7
43 #define EFC_CAT_MONITOR_MIX             8
44 #define EFC_CAT_IO_CONFIG               9
45 #define EFC_CAT_COUNT                   10
46
47 // size of the header
48 #define EFC_HEADER_LENGTH_QUADLETS      ((sizeof(uint32_t) + sizeof(struct EfcCmd::efc_header))/4)
49
50 // util macro to do deserialization and byteswap
51 #define EFC_DESERIALIZE_AND_SWAP(__de__, __value__, __result__) \
52     { __result__ &= __de__.read(__value__); \
53       *(__value__)=ntohl(*(__value__)); } \
54
55
56 namespace FireWorks {
57
58 class EfcCmd
59 {
60 public:
61     enum EfcReturnValue {
62         eERV_Ok             = 0,
63         eERV_Bad            = 1,
64         eERV_BadCommand     = 2,
65         eERV_CommErr        = 3,
66         eERV_BadQuadCount   = 4,
67         eERV_Unsupported    = 5,
68         eERV_1394Timeout    = 6,
69         eERV_DspTimeout     = 7,
70         eERV_BadRate        = 8,
71         eERV_BadClock       = 9,
72         eERV_BadChannel     = 10,
73         eERV_BadPan         = 11,
74         eERV_FlashBusy      = 12,
75         eERV_BadMirror      = 13,
76         eERV_BadLed         = 14,
77         eERV_BadParameter   = 15,
78         eERV_Incomplete     = 0x80000000L,
79         eERV_Unspecified    = 0xFFFFFFFFL,
80     };
81
82     typedef struct efc_header
83     {
84         uint32_t    version;
85         uint32_t    seqnum;
86         uint32_t    category;
87         uint32_t    command;
88         uint32_t    retval;
89     };
90
91 protected: // this HAS to be overloaded
92     EfcCmd(uint32_t cat, uint32_t cmd);
93
94 public:
95     virtual ~EfcCmd();
96    
97     virtual bool serialize( Util::IOSSerialize& se );
98     virtual bool deserialize( Util::IISDeserialize& de );
99
100     virtual const char* getCmdName() const = 0;
101
102     virtual void showEfcCmd();
103
104     uint32_t            m_length; // in quadlets, including length field and header.
105     struct efc_header   m_header;
106
107 private:
108     uint32_t            m_category_id;
109     uint32_t            m_command_id;
110
111 public:
112     static uint32_t     m_seqnum;
113 protected:
114     DECLARE_DEBUG_MODULE;
115 };
116
117 } // namespace FireWorks
118
119 #endif // FIREWORKS_EFC_CMD_H
Note: See TracBrowser for help on using the browser.