Commit | Line | Data |
---|---|---|
b9187cc6 LOK |
1 | #pragma once |
2 | ||
3 | /* | |
4 | * boblight | |
5 | * Copyright (C) Bob 2009 | |
6 | * | |
7 | * boblight is free software: you can redistribute it and/or modify it | |
8 | * under the terms of the GNU General Public License as published by the | |
9 | * Free Software Foundation, either version 3 of the License, or | |
10 | * (at your option) any later version. | |
11 | * | |
12 | * boblight is distributed in the hope that it will be useful, but | |
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
15 | * See the GNU General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public License along | |
18 | * with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 | */ | |
20 | ||
21 | //every baudrate I could find is in here in an #ifdef block | |
22 | //so it should compile on everything | |
23 | ||
24 | #include <termios.h> | |
25 | ||
26 | namespace CEC | |
27 | { | |
28 | static struct sbaudrate | |
29 | { | |
30 | int rate; | |
31 | int symbol; | |
32 | } | |
33 | baudrates[] = | |
34 | { | |
35 | #ifdef B50 | |
36 | { 50, B50 }, | |
37 | #endif | |
38 | #ifdef B75 | |
39 | { 75, B75 }, | |
40 | #endif | |
41 | #ifdef B110 | |
42 | { 110, B110 }, | |
43 | #endif | |
44 | #ifdef B134 | |
45 | { 134, B134 }, | |
46 | #endif | |
47 | #ifdef B150 | |
48 | { 150, B150 }, | |
49 | #endif | |
50 | #ifdef B200 | |
51 | { 200, B200 }, | |
52 | #endif | |
53 | #ifdef B300 | |
54 | { 300, B300 }, | |
55 | #endif | |
56 | #ifdef B600 | |
57 | { 600, B600 }, | |
58 | #endif | |
59 | #ifdef B1200 | |
60 | { 1200, B1200 }, | |
61 | #endif | |
62 | #ifdef B1800 | |
63 | { 1800, B1800 }, | |
64 | #endif | |
65 | #ifdef B2400 | |
66 | { 2400, B2400 }, | |
67 | #endif | |
68 | #ifdef B4800 | |
69 | { 4800, B4800 }, | |
70 | #endif | |
71 | #ifdef B9600 | |
72 | { 9600, B9600 }, | |
73 | #endif | |
74 | #ifdef B14400 | |
75 | { 14400, B14400 }, | |
76 | #endif | |
77 | #ifdef B19200 | |
78 | { 19200, B19200 }, | |
79 | #endif | |
80 | #ifdef B28800 | |
81 | { 28800, B28800 }, | |
82 | #endif | |
83 | #ifdef B38400 | |
84 | { 38400, B38400 }, | |
85 | #endif | |
86 | #ifdef B57600 | |
87 | { 57600, B57600 }, | |
88 | #endif | |
89 | #ifdef B76800 | |
90 | { 76800, B76800 }, | |
91 | #endif | |
92 | #ifdef B115200 | |
93 | { 115200, B115200 }, | |
94 | #endif | |
95 | #ifdef B230400 | |
96 | { 230400, B230400 }, | |
97 | #endif | |
98 | #ifdef B250000 | |
99 | { 250000, B250000 }, | |
100 | #endif | |
101 | #ifdef B460800 | |
102 | { 460800, B460800 }, | |
103 | #endif | |
104 | #ifdef B500000 | |
105 | { 500000, B500000 }, | |
106 | #endif | |
107 | #ifdef B576000 | |
108 | { 576000, B576000 }, | |
109 | #endif | |
110 | #ifdef B921600 | |
111 | { 921600, B921600 }, | |
112 | #endif | |
113 | #ifdef B1000000 | |
114 | { 1000000, B1000000 }, | |
115 | #endif | |
116 | #ifdef B1152000 | |
117 | { 1152000, B1152000 }, | |
118 | #endif | |
119 | #ifdef B1500000 | |
120 | { 1500000, B1500000 }, | |
121 | #endif | |
122 | #ifdef B2000000 | |
123 | { 2000000, B2000000 }, | |
124 | #endif | |
125 | #ifdef B2500000 | |
126 | { 2500000, B2500000 }, | |
127 | #endif | |
128 | #ifdef B3000000 | |
129 | { 3000000, B3000000 }, | |
130 | #endif | |
131 | #ifdef B3500000 | |
132 | { 3500000, B3500000 }, | |
133 | #endif | |
134 | #ifdef B4000000 | |
135 | { 4000000, B4000000 }, | |
136 | #endif | |
137 | #ifdef CBR_110 | |
138 | { 110, CBR_110 }, | |
139 | #endif | |
140 | #ifdef CBR_300 | |
141 | { 300, CBR_300 }, | |
142 | #endif | |
143 | #ifdef CBR_600 | |
144 | { 600, CBR_600 }, | |
145 | #endif | |
146 | #ifdef CBR_1200 | |
147 | { 1200, CBR_1200 }, | |
148 | #endif | |
149 | #ifdef CBR_2400 | |
150 | { 2400, CBR_2400 }, | |
151 | #endif | |
152 | #ifdef CBR_4800 | |
153 | { 4800, CBR_4800 }, | |
154 | #endif | |
155 | #ifdef CBR_9600 | |
156 | { 9600, CBR_9600 }, | |
157 | #endif | |
158 | #ifdef CBR_11400 | |
159 | { 11400, CBR_14400 }, | |
160 | #endif | |
161 | #ifdef CBR_19200 | |
162 | { 19200, CBR_19200 }, | |
163 | #endif | |
164 | #ifdef CBR_38400 | |
165 | { 38400, CBR_38400 }, | |
166 | #endif | |
167 | #ifdef CBR_56000 | |
168 | { 56000, CBR_56000 }, | |
169 | #endif | |
170 | #ifdef CBR_57600 | |
171 | { 57600, CBR_57600 }, | |
172 | #endif | |
173 | #ifdef CBR_115200 | |
174 | { 115200, CBR_115200 }, | |
175 | #endif | |
176 | #ifdef CBR_128000 | |
177 | { 128000, CBR_128000 }, | |
178 | #endif | |
179 | #ifdef CBR_256000 | |
180 | { 256000, CBR_256000 }, | |
181 | #endif | |
182 | { -1, -1} | |
183 | }; | |
184 | ||
185 | static int IntToBaudrate(int baudrate) | |
186 | { | |
187 | for (unsigned int i = 0; i < sizeof(baudrates) / sizeof(CEC::sbaudrate) - 1; i++) | |
188 | { | |
189 | if (baudrates[i].rate == baudrate) | |
190 | return baudrates[i].symbol; | |
191 | } | |
192 | ||
193 | return -1; | |
194 | }; | |
195 | }; |