1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
2 | /* |
3 | * drivers/usb/input/yealink.h |
4 | * |
5 | * Copyright (c) 2005 Henk Vergonet <Henk.Vergonet@gmail.com> |
6 | */ |
7 | #ifndef INPUT_YEALINK_H |
8 | #define INPUT_YEALINK_H |
9 | |
10 | /* Using the control channel on interface 3 various aspects of the phone |
11 | * can be controlled like LCD, LED, dialtone and the ringtone. |
12 | */ |
13 | |
14 | struct yld_ctl_packet { |
15 | u8 cmd; /* command code, see below */ |
16 | u8 size; /* 1-11, size of used data bytes. */ |
17 | __be16 offset; /* internal packet offset */ |
18 | u8 data[11]; |
19 | s8 sum; /* negative sum of 15 preceding bytes */ |
20 | } __attribute__ ((packed)); |
21 | |
22 | #define USB_PKT_LEN sizeof(struct yld_ctl_packet) |
23 | |
24 | /* The following yld_ctl_packet's are available: */ |
25 | |
26 | /* Init registers |
27 | * |
28 | * cmd 0x8e |
29 | * size 10 |
30 | * offset 0 |
31 | * data 0,0,0,0.... |
32 | */ |
33 | #define CMD_INIT 0x8e |
34 | |
35 | /* Request key scan |
36 | * |
37 | * cmd 0x80 |
38 | * size 1 |
39 | * offset 0 |
40 | * data[0] on return returns the key number, if it changes there's a new |
41 | * key pressed. |
42 | */ |
43 | #define CMD_KEYPRESS 0x80 |
44 | |
45 | /* Request scancode |
46 | * |
47 | * cmd 0x81 |
48 | * size 1 |
49 | * offset key number [0-1f] |
50 | * data[0] on return returns the scancode |
51 | */ |
52 | #define CMD_SCANCODE 0x81 |
53 | |
54 | /* Set LCD |
55 | * |
56 | * cmd 0x04 |
57 | * size 1-11 |
58 | * offset 0-23 |
59 | * data segment bits |
60 | */ |
61 | #define CMD_LCD 0x04 |
62 | |
63 | /* Set led |
64 | * |
65 | * cmd 0x05 |
66 | * size 1 |
67 | * offset 0 |
68 | * data[0] 0 OFF / 1 ON |
69 | */ |
70 | #define CMD_LED 0x05 |
71 | |
72 | /* Set ringtone volume |
73 | * |
74 | * cmd 0x11 |
75 | * size 1 |
76 | * offset 0 |
77 | * data[0] 0-0xff volume |
78 | */ |
79 | #define CMD_RING_VOLUME 0x11 |
80 | |
81 | /* Set ringtone notes |
82 | * |
83 | * cmd 0x02 |
84 | * size 1-11 |
85 | * offset 0-> |
86 | * data binary representation LE16(-freq), LE16(duration) .... |
87 | */ |
88 | #define CMD_RING_NOTE 0x02 |
89 | |
90 | /* Sound ringtone via the speaker on the back |
91 | * |
92 | * cmd 0x03 |
93 | * size 1 |
94 | * offset 0 |
95 | * data[0] 0 OFF / 0x24 ON |
96 | */ |
97 | #define CMD_RINGTONE 0x03 |
98 | |
99 | /* Sound dial tone via the ear speaker |
100 | * |
101 | * cmd 0x09 |
102 | * size 1 |
103 | * offset 0 |
104 | * data[0] 0 OFF / 1 ON |
105 | */ |
106 | #define CMD_DIALTONE 0x09 |
107 | |
108 | #endif /* INPUT_YEALINK_H */ |
109 | |
110 | |
111 | #if defined(_SEG) && defined(_PIC) |
112 | /* This table maps the LCD segments onto individual bit positions in the |
113 | * yld_status struct. |
114 | */ |
115 | |
116 | /* LCD, each segment must be driven separately. |
117 | * |
118 | * Layout: |
119 | * |
120 | * |[] [][] [][] [][] in |[][] |
121 | * |[] M [][] D [][] : [][] out |[][] |
122 | * store |
123 | * |
124 | * NEW REP SU MO TU WE TH FR SA |
125 | * |
126 | * [] [] [] [] [] [] [] [] [] [] [] [] |
127 | * [] [] [] [] [] [] [] [] [] [] [] [] |
128 | */ |
129 | |
130 | /* Line 1 |
131 | * Format : 18.e8.M8.88...188 |
132 | * Icon names : M D : IN OUT STORE |
133 | */ |
134 | #define LCD_LINE1_OFFSET 0 |
135 | #define LCD_LINE1_SIZE 17 |
136 | |
137 | /* Note: first g then f => ! ! */ |
138 | /* _SEG( type a b c d e g f ) */ |
139 | _SEG('1', 0,0 , 22,2 , 22,2 , 0,0 , 0,0 , 0,0 , 0,0 ), |
140 | _SEG('8', 20,1 , 20,2 , 20,4 , 20,8 , 21,4 , 21,2 , 21,1 ), |
141 | _PIC('.', 22,1 , "M" ), |
142 | _SEG('e', 18,1 , 18,2 , 18,4 , 18,1 , 19,2 , 18,1 , 19,1 ), |
143 | _SEG('8', 16,1 , 16,2 , 16,4 , 16,8 , 17,4 , 17,2 , 17,1 ), |
144 | _PIC('.', 15,8 , "D" ), |
145 | _SEG('M', 14,1 , 14,2 , 14,4 , 14,1 , 15,4 , 15,2 , 15,1 ), |
146 | _SEG('8', 12,1 , 12,2 , 12,4 , 12,8 , 13,4 , 13,2 , 13,1 ), |
147 | _PIC('.', 11,8 , ":" ), |
148 | _SEG('8', 10,1 , 10,2 , 10,4 , 10,8 , 11,4 , 11,2 , 11,1 ), |
149 | _SEG('8', 8,1 , 8,2 , 8,4 , 8,8 , 9,4 , 9,2 , 9,1 ), |
150 | _PIC('.', 7,1 , "IN" ), |
151 | _PIC('.', 7,2 , "OUT" ), |
152 | _PIC('.', 7,4 , "STORE" ), |
153 | _SEG('1', 0,0 , 5,1 , 5,1 , 0,0 , 0,0 , 0,0 , 0,0 ), |
154 | _SEG('8', 4,1 , 4,2 , 4,4 , 4,8 , 5,8 , 5,4 , 5,2 ), |
155 | _SEG('8', 2,1 , 2,2 , 2,4 , 2,8 , 3,4 , 3,2 , 3,1 ), |
156 | |
157 | /* Line 2 |
158 | * Format : ......... |
159 | * Pict. name : NEW REP SU MO TU WE TH FR SA |
160 | */ |
161 | #define LCD_LINE2_OFFSET LCD_LINE1_OFFSET + LCD_LINE1_SIZE |
162 | #define LCD_LINE2_SIZE 9 |
163 | |
164 | _PIC('.', 23,2 , "NEW" ), |
165 | _PIC('.', 23,4 , "REP" ), |
166 | _PIC('.', 1,8 , "SU" ), |
167 | _PIC('.', 1,4 , "MO" ), |
168 | _PIC('.', 1,2 , "TU" ), |
169 | _PIC('.', 1,1 , "WE" ), |
170 | _PIC('.', 0,1 , "TH" ), |
171 | _PIC('.', 0,2 , "FR" ), |
172 | _PIC('.', 0,4 , "SA" ), |
173 | |
174 | /* Line 3 |
175 | * Format : 888888888888 |
176 | */ |
177 | #define LCD_LINE3_OFFSET LCD_LINE2_OFFSET + LCD_LINE2_SIZE |
178 | #define LCD_LINE3_SIZE 12 |
179 | |
180 | _SEG('8', 22,16, 22,32, 22,64, 22,128, 23,128, 23,64, 23,32 ), |
181 | _SEG('8', 20,16, 20,32, 20,64, 20,128, 21,128, 21,64, 21,32 ), |
182 | _SEG('8', 18,16, 18,32, 18,64, 18,128, 19,128, 19,64, 19,32 ), |
183 | _SEG('8', 16,16, 16,32, 16,64, 16,128, 17,128, 17,64, 17,32 ), |
184 | _SEG('8', 14,16, 14,32, 14,64, 14,128, 15,128, 15,64, 15,32 ), |
185 | _SEG('8', 12,16, 12,32, 12,64, 12,128, 13,128, 13,64, 13,32 ), |
186 | _SEG('8', 10,16, 10,32, 10,64, 10,128, 11,128, 11,64, 11,32 ), |
187 | _SEG('8', 8,16, 8,32, 8,64, 8,128, 9,128, 9,64, 9,32 ), |
188 | _SEG('8', 6,16, 6,32, 6,64, 6,128, 7,128, 7,64, 7,32 ), |
189 | _SEG('8', 4,16, 4,32, 4,64, 4,128, 5,128, 5,64, 5,32 ), |
190 | _SEG('8', 2,16, 2,32, 2,64, 2,128, 3,128, 3,64, 3,32 ), |
191 | _SEG('8', 0,16, 0,32, 0,64, 0,128, 1,128, 1,64, 1,32 ), |
192 | |
193 | /* Line 4 |
194 | * |
195 | * The LED, DIALTONE and RINGTONE are implemented as icons and use the same |
196 | * sysfs interface. |
197 | */ |
198 | #define LCD_LINE4_OFFSET LCD_LINE3_OFFSET + LCD_LINE3_SIZE |
199 | |
200 | _PIC('.', offsetof(struct yld_status, led) , 0x01, "LED" ), |
201 | _PIC('.', offsetof(struct yld_status, dialtone) , 0x01, "DIALTONE" ), |
202 | _PIC('.', offsetof(struct yld_status, ringtone) , 0x24, "RINGTONE" ), |
203 | |
204 | #undef _SEG |
205 | #undef _PIC |
206 | #endif /* _SEG && _PIC */ |
207 | |