cec: added vendor id detection for LG. changed vendorid display to hex
[deb_libcec.git] / src / lib / platform / baudrate.h
... / ...
CommitLineData
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 "os-dependent.h"
25
26#ifndef __WINDOWS__
27#include <termios.h>
28#endif
29
30namespace CEC
31{
32 static struct sbaudrate
33 {
34 int32_t rate;
35 int32_t symbol;
36 }
37 baudrates[] =
38 {
39 #ifdef B50
40 { 50, B50 },
41 #endif
42 #ifdef B75
43 { 75, B75 },
44 #endif
45 #ifdef B110
46 { 110, B110 },
47 #endif
48 #ifdef B134
49 { 134, B134 },
50 #endif
51 #ifdef B150
52 { 150, B150 },
53 #endif
54 #ifdef B200
55 { 200, B200 },
56 #endif
57 #ifdef B300
58 { 300, B300 },
59 #endif
60 #ifdef B600
61 { 600, B600 },
62 #endif
63 #ifdef B1200
64 { 1200, B1200 },
65 #endif
66 #ifdef B1800
67 { 1800, B1800 },
68 #endif
69 #ifdef B2400
70 { 2400, B2400 },
71 #endif
72 #ifdef B4800
73 { 4800, B4800 },
74 #endif
75 #ifdef B9600
76 { 9600, B9600 },
77 #endif
78 #ifdef B14400
79 { 14400, B14400 },
80 #endif
81 #ifdef B19200
82 { 19200, B19200 },
83 #endif
84 #ifdef B28800
85 { 28800, B28800 },
86 #endif
87 #ifdef B38400
88 { 38400, B38400 },
89 #endif
90 #ifdef B57600
91 { 57600, B57600 },
92 #endif
93 #ifdef B76800
94 { 76800, B76800 },
95 #endif
96 #ifdef B115200
97 { 115200, B115200 },
98 #endif
99 #ifdef B230400
100 { 230400, B230400 },
101 #endif
102 #ifdef B250000
103 { 250000, B250000 },
104 #endif
105 #ifdef B460800
106 { 460800, B460800 },
107 #endif
108 #ifdef B500000
109 { 500000, B500000 },
110 #endif
111 #ifdef B576000
112 { 576000, B576000 },
113 #endif
114 #ifdef B921600
115 { 921600, B921600 },
116 #endif
117 #ifdef B1000000
118 { 1000000, B1000000 },
119 #endif
120 #ifdef B1152000
121 { 1152000, B1152000 },
122 #endif
123 #ifdef B1500000
124 { 1500000, B1500000 },
125 #endif
126 #ifdef B2000000
127 { 2000000, B2000000 },
128 #endif
129 #ifdef B2500000
130 { 2500000, B2500000 },
131 #endif
132 #ifdef B3000000
133 { 3000000, B3000000 },
134 #endif
135 #ifdef B3500000
136 { 3500000, B3500000 },
137 #endif
138 #ifdef B4000000
139 { 4000000, B4000000 },
140 #endif
141 #ifdef CBR_110
142 { 110, CBR_110 },
143 #endif
144 #ifdef CBR_300
145 { 300, CBR_300 },
146 #endif
147 #ifdef CBR_600
148 { 600, CBR_600 },
149 #endif
150 #ifdef CBR_1200
151 { 1200, CBR_1200 },
152 #endif
153 #ifdef CBR_2400
154 { 2400, CBR_2400 },
155 #endif
156 #ifdef CBR_4800
157 { 4800, CBR_4800 },
158 #endif
159 #ifdef CBR_9600
160 { 9600, CBR_9600 },
161 #endif
162 #ifdef CBR_11400
163 { 11400, CBR_14400 },
164 #endif
165 #ifdef CBR_19200
166 { 19200, CBR_19200 },
167 #endif
168 #ifdef CBR_38400
169 { 38400, CBR_38400 },
170 #endif
171 #ifdef CBR_56000
172 { 56000, CBR_56000 },
173 #endif
174 #ifdef CBR_57600
175 { 57600, CBR_57600 },
176 #endif
177 #ifdef CBR_115200
178 { 115200, CBR_115200 },
179 #endif
180 #ifdef CBR_128000
181 { 128000, CBR_128000 },
182 #endif
183 #ifdef CBR_256000
184 { 256000, CBR_256000 },
185 #endif
186 { -1, -1}
187 };
188
189 static int32_t IntToBaudrate(uint32_t baudrate)
190 {
191 for (unsigned int i = 0; i < sizeof(baudrates) / sizeof(CEC::sbaudrate) - 1; i++)
192 {
193 if (baudrates[i].rate == (int32_t) baudrate)
194 return baudrates[i].symbol;
195 }
196
197 return -1;
198 };
199};