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