carl9170 toolchain: update to gcc 6.2.0 and binutils 2.27
[carl9170fw.git] / include / pattern.h
1 /*
2  * carl9170 firmware - used by the ar9170 wireless device
3  *
4  * Pattern pulse definitions
5  *
6  * Copyright 2012 Christian Lamparter <chunkeey@googlemail.com>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program 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
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with this program; if not, write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21  */
22
23 #ifndef __CARL9170FW_PATTERN_H
24 #define __CARL9170FW_PATTERN_H
25
26 #include "types.h"
27 #include "compiler.h"
28 #include "fwdesc.h"
29
30 enum PATTERN_TYPE {
31         NO_PATTERN = 0,
32         ONE_KHZ,
33         TEN_KHZ,
34
35         ONE_TWO_KHZ,
36
37         FCC1,
38         FCC4,
39
40         ETSIFIXED,
41
42         /* keep last */
43         __CARL9170FW_NUM_PATTERNS
44 };
45
46 struct pattern_pulse_info {
47         unsigned int pulse_width;
48         unsigned int pulse_interval;
49         uint32_t     pulse_pattern;
50         uint32_t     pulse_mode;
51 };
52
53 struct pattern_info {
54         unsigned int pulses;
55         const struct pattern_pulse_info *pattern;
56 };
57
58 static const struct pattern_pulse_info pattern_NO_PATTERN[0] = {  };
59 static const struct pattern_pulse_info pattern_ONE_KHZ[] = {
60         {
61                 .pulse_width = 1,
62                 .pulse_interval = 1000,
63                 .pulse_pattern = 0xaa55,
64                 .pulse_mode    = 0x17f01,
65         },
66 };
67
68 static const struct pattern_pulse_info pattern_TEN_KHZ[] = {
69         {
70                 .pulse_width = 1,
71                 .pulse_interval = 100,
72                 .pulse_pattern = 0xaa55,
73                 .pulse_mode    = 0x17f01,
74         },
75 };
76
77 static const struct pattern_pulse_info pattern_ONE_TWO_KHZ[] = {
78         {
79                 .pulse_width = 1,
80                 .pulse_interval = 1000,
81                 .pulse_pattern = 0xaa55,
82                 .pulse_mode    = 0x17f01,
83         },
84
85         {
86                 .pulse_width = 10,
87                 .pulse_interval = 500,
88                 .pulse_pattern = 0xaa55,
89                 .pulse_mode    = 0x17f01,
90         },
91 };
92
93 /*
94  * Data taken from:
95  * <http://linuxwireless.org/en/developers/DFS>
96  */
97
98 /* FCC Test Signal 1 - 1us pulse, 1428 us interval */
99 static const struct pattern_pulse_info pattern_FCC1[] = {
100         {
101                 .pulse_width = 1,
102                 .pulse_interval = 1428,
103                 .pulse_pattern = 0xaa55,
104                 .pulse_mode    = 0x17f01,
105         },
106 };
107
108 /* FCC Test Signal 4 - 11-20us pulse, 200-500 us interval */
109 static const struct pattern_pulse_info pattern_FCC4[] = {
110         {
111                 .pulse_width = 11,
112                 .pulse_interval = 200,
113                 .pulse_pattern = 0xaa55,
114                 .pulse_mode    = 0x7f01,
115         },
116 };
117
118 /* ETSI Test Signal 1 (Fixed) - 1us Pulse, 750 us interval */
119 static const struct pattern_pulse_info pattern_ETSIFIXED[] = {
120         {
121                 .pulse_width = 1,
122                 .pulse_interval = 750,
123                 .pulse_pattern = 0xaa55,
124                 .pulse_mode    = 0x7f01,
125         },
126 };
127
128
129 #define ADD_RADAR(name) [name] = { .pulses = ARRAY_SIZE(pattern_## name), .pattern = pattern_## name }
130
131 static const struct pattern_info patterns[__CARL9170FW_NUM_PATTERNS] = {
132         ADD_RADAR(NO_PATTERN),
133         ADD_RADAR(ONE_KHZ),
134         ADD_RADAR(TEN_KHZ),
135         ADD_RADAR(ONE_TWO_KHZ),
136         ADD_RADAR(FCC1),
137         ADD_RADAR(FCC4),
138         ADD_RADAR(ETSIFIXED),
139 };
140
141 #define MAP_ENTRY(idx) [idx] = { .index = idx, .name = # idx , }
142 #define NAMED_MAP_ENTRY(idx, named) [idx] = {.index = idx, .name = named, }
143
144 static const struct carl9170fw_pattern_map_entry pattern_names[__CARL9170FW_NUM_PATTERNS] = {
145         MAP_ENTRY(NO_PATTERN),
146         MAP_ENTRY(ONE_KHZ),
147         MAP_ENTRY(TEN_KHZ),
148         MAP_ENTRY(ONE_TWO_KHZ),
149
150         MAP_ENTRY(FCC1),
151         MAP_ENTRY(FCC4),
152
153         MAP_ENTRY(ETSIFIXED),
154 };
155
156 #endif /* __CARL9170FW_PATTERN_H */