yealink.h 5.1 KB

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