This source file includes following definitions.
- map_to_seg7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 #ifndef MAP_TO_7SEGMENT_H
21 #define MAP_TO_7SEGMENT_H
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63 #include <linux/errno.h>
64
65
66 #define BIT_SEG7_A 0
67 #define BIT_SEG7_B 1
68 #define BIT_SEG7_C 2
69 #define BIT_SEG7_D 3
70 #define BIT_SEG7_E 4
71 #define BIT_SEG7_F 5
72 #define BIT_SEG7_G 6
73 #define BIT_SEG7_RESERVED 7
74
75 struct seg7_conversion_map {
76 unsigned char table[128];
77 };
78
79 static __inline__ int map_to_seg7(struct seg7_conversion_map *map, int c)
80 {
81 return c >= 0 && c < sizeof(map->table) ? map->table[c] : -EINVAL;
82 }
83
84 #define SEG7_CONVERSION_MAP(_name, _map) \
85 struct seg7_conversion_map _name = { .table = { _map } }
86
87
88
89
90
91
92 #define MAP_TO_SEG7_SYSFS_FILE "map_seg7"
93
94
95
96
97
98 #define _SEG7(l,a,b,c,d,e,f,g) \
99 ( a<<BIT_SEG7_A | b<<BIT_SEG7_B | c<<BIT_SEG7_C | d<<BIT_SEG7_D | \
100 e<<BIT_SEG7_E | f<<BIT_SEG7_F | g<<BIT_SEG7_G )
101
102 #define _MAP_0_32_ASCII_SEG7_NON_PRINTABLE \
103 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
104
105 #define _MAP_33_47_ASCII_SEG7_SYMBOL \
106 _SEG7('!',0,0,0,0,1,1,0), _SEG7('"',0,1,0,0,0,1,0), _SEG7('#',0,1,1,0,1,1,0),\
107 _SEG7('$',1,0,1,1,0,1,1), _SEG7('%',0,0,1,0,0,1,0), _SEG7('&',1,0,1,1,1,1,1),\
108 _SEG7('\'',0,0,0,0,0,1,0),_SEG7('(',1,0,0,1,1,1,0), _SEG7(')',1,1,1,1,0,0,0),\
109 _SEG7('*',0,1,1,0,1,1,1), _SEG7('+',0,1,1,0,0,0,1), _SEG7(',',0,0,0,0,1,0,0),\
110 _SEG7('-',0,0,0,0,0,0,1), _SEG7('.',0,0,0,0,1,0,0), _SEG7('/',0,1,0,0,1,0,1),
111
112 #define _MAP_48_57_ASCII_SEG7_NUMERIC \
113 _SEG7('0',1,1,1,1,1,1,0), _SEG7('1',0,1,1,0,0,0,0), _SEG7('2',1,1,0,1,1,0,1),\
114 _SEG7('3',1,1,1,1,0,0,1), _SEG7('4',0,1,1,0,0,1,1), _SEG7('5',1,0,1,1,0,1,1),\
115 _SEG7('6',1,0,1,1,1,1,1), _SEG7('7',1,1,1,0,0,0,0), _SEG7('8',1,1,1,1,1,1,1),\
116 _SEG7('9',1,1,1,1,0,1,1),
117
118 #define _MAP_58_64_ASCII_SEG7_SYMBOL \
119 _SEG7(':',0,0,0,1,0,0,1), _SEG7(';',0,0,0,1,0,0,1), _SEG7('<',1,0,0,0,0,1,1),\
120 _SEG7('=',0,0,0,1,0,0,1), _SEG7('>',1,1,0,0,0,0,1), _SEG7('?',1,1,1,0,0,1,0),\
121 _SEG7('@',1,1,0,1,1,1,1),
122
123 #define _MAP_65_90_ASCII_SEG7_ALPHA_UPPR \
124 _SEG7('A',1,1,1,0,1,1,1), _SEG7('B',1,1,1,1,1,1,1), _SEG7('C',1,0,0,1,1,1,0),\
125 _SEG7('D',1,1,1,1,1,1,0), _SEG7('E',1,0,0,1,1,1,1), _SEG7('F',1,0,0,0,1,1,1),\
126 _SEG7('G',1,1,1,1,0,1,1), _SEG7('H',0,1,1,0,1,1,1), _SEG7('I',0,1,1,0,0,0,0),\
127 _SEG7('J',0,1,1,1,0,0,0), _SEG7('K',0,1,1,0,1,1,1), _SEG7('L',0,0,0,1,1,1,0),\
128 _SEG7('M',1,1,1,0,1,1,0), _SEG7('N',1,1,1,0,1,1,0), _SEG7('O',1,1,1,1,1,1,0),\
129 _SEG7('P',1,1,0,0,1,1,1), _SEG7('Q',1,1,1,1,1,1,0), _SEG7('R',1,1,1,0,1,1,1),\
130 _SEG7('S',1,0,1,1,0,1,1), _SEG7('T',0,0,0,1,1,1,1), _SEG7('U',0,1,1,1,1,1,0),\
131 _SEG7('V',0,1,1,1,1,1,0), _SEG7('W',0,1,1,1,1,1,1), _SEG7('X',0,1,1,0,1,1,1),\
132 _SEG7('Y',0,1,1,0,0,1,1), _SEG7('Z',1,1,0,1,1,0,1),
133
134 #define _MAP_91_96_ASCII_SEG7_SYMBOL \
135 _SEG7('[',1,0,0,1,1,1,0), _SEG7('\\',0,0,1,0,0,1,1),_SEG7(']',1,1,1,1,0,0,0),\
136 _SEG7('^',1,1,0,0,0,1,0), _SEG7('_',0,0,0,1,0,0,0), _SEG7('`',0,1,0,0,0,0,0),
137
138 #define _MAP_97_122_ASCII_SEG7_ALPHA_LOWER \
139 _SEG7('A',1,1,1,0,1,1,1), _SEG7('b',0,0,1,1,1,1,1), _SEG7('c',0,0,0,1,1,0,1),\
140 _SEG7('d',0,1,1,1,1,0,1), _SEG7('E',1,0,0,1,1,1,1), _SEG7('F',1,0,0,0,1,1,1),\
141 _SEG7('G',1,1,1,1,0,1,1), _SEG7('h',0,0,1,0,1,1,1), _SEG7('i',0,0,1,0,0,0,0),\
142 _SEG7('j',0,0,1,1,0,0,0), _SEG7('k',0,0,1,0,1,1,1), _SEG7('L',0,0,0,1,1,1,0),\
143 _SEG7('M',1,1,1,0,1,1,0), _SEG7('n',0,0,1,0,1,0,1), _SEG7('o',0,0,1,1,1,0,1),\
144 _SEG7('P',1,1,0,0,1,1,1), _SEG7('q',1,1,1,0,0,1,1), _SEG7('r',0,0,0,0,1,0,1),\
145 _SEG7('S',1,0,1,1,0,1,1), _SEG7('T',0,0,0,1,1,1,1), _SEG7('u',0,0,1,1,1,0,0),\
146 _SEG7('v',0,0,1,1,1,0,0), _SEG7('W',0,1,1,1,1,1,1), _SEG7('X',0,1,1,0,1,1,1),\
147 _SEG7('y',0,1,1,1,0,1,1), _SEG7('Z',1,1,0,1,1,0,1),
148
149 #define _MAP_123_126_ASCII_SEG7_SYMBOL \
150 _SEG7('{',1,0,0,1,1,1,0), _SEG7('|',0,0,0,0,1,1,0), _SEG7('}',1,1,1,1,0,0,0),\
151 _SEG7('~',1,0,0,0,0,0,0),
152
153
154
155
156
157
158
159 #define MAP_ASCII7SEG_ALPHANUM \
160 _MAP_0_32_ASCII_SEG7_NON_PRINTABLE \
161 _MAP_33_47_ASCII_SEG7_SYMBOL \
162 _MAP_48_57_ASCII_SEG7_NUMERIC \
163 _MAP_58_64_ASCII_SEG7_SYMBOL \
164 _MAP_65_90_ASCII_SEG7_ALPHA_UPPR \
165 _MAP_91_96_ASCII_SEG7_SYMBOL \
166 _MAP_97_122_ASCII_SEG7_ALPHA_LOWER \
167 _MAP_123_126_ASCII_SEG7_SYMBOL
168
169
170
171
172
173
174 #define MAP_ASCII7SEG_ALPHANUM_LC \
175 _MAP_0_32_ASCII_SEG7_NON_PRINTABLE \
176 _MAP_33_47_ASCII_SEG7_SYMBOL \
177 _MAP_48_57_ASCII_SEG7_NUMERIC \
178 _MAP_58_64_ASCII_SEG7_SYMBOL \
179 _MAP_97_122_ASCII_SEG7_ALPHA_LOWER \
180 _MAP_91_96_ASCII_SEG7_SYMBOL \
181 _MAP_97_122_ASCII_SEG7_ALPHA_LOWER \
182 _MAP_123_126_ASCII_SEG7_SYMBOL
183
184 #define SEG7_DEFAULT_MAP(_name) \
185 SEG7_CONVERSION_MAP(_name,MAP_ASCII7SEG_ALPHANUM)
186
187 #endif
188