yealink.txt 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. Driver documentation for yealink usb-p1k phones
  2. 0. Status
  3. ~~~~~~~~~
  4. The p1k is a relatively cheap usb 1.1 phone with:
  5. - keyboard full support, yealink.ko / input event API
  6. - LCD full support, yealink.ko / sysfs API
  7. - LED full support, yealink.ko / sysfs API
  8. - dialtone full support, yealink.ko / sysfs API
  9. - ringtone full support, yealink.ko / sysfs API
  10. - audio playback full support, snd_usb_audio.ko / alsa API
  11. - audio record full support, snd_usb_audio.ko / alsa API
  12. For vendor documentation see http://www.yealink.com
  13. 1. Compilation (stand alone version)
  14. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  15. Currently only kernel 2.6.x.y versions are supported.
  16. In order to build the yealink.ko module do:
  17. make
  18. If you encounter problems please check if in the MAKE_OPTS variable in
  19. the Makefile is pointing to the location where your kernel sources
  20. are located, default /usr/src/linux.
  21. 2. keyboard features
  22. ~~~~~~~~~~~~~~~~~~~~
  23. The current mapping in the kernel is provided by the map_p1k_to_key
  24. function:
  25. Physical USB-P1K button layout input events
  26. up up
  27. IN OUT left, right
  28. down down
  29. pickup C hangup enter, backspace, escape
  30. 1 2 3 1, 2, 3
  31. 4 5 6 4, 5, 6,
  32. 7 8 9 7, 8, 9,
  33. * 0 # *, 0, #,
  34. The "up" and "down" keys, are symbolised by arrows on the button.
  35. The "pickup" and "hangup" keys are symbolised by a green and red phone
  36. on the button.
  37. 3. LCD features
  38. ~~~~~~~~~~~~~~~
  39. The LCD is divided and organised as a 3 line display:
  40. |[] [][] [][] [][] in |[][]
  41. |[] M [][] D [][] : [][] out |[][]
  42. store
  43. NEW REP SU MO TU WE TH FR SA
  44. [] [] [] [] [] [] [] [] [] [] [] []
  45. [] [] [] [] [] [] [] [] [] [] [] []
  46. Line 1 Format (see below) : 18.e8.M8.88...188
  47. Icon names : M D : IN OUT STORE
  48. Line 2 Format : .........
  49. Icon name : NEW REP SU MO TU WE TH FR SA
  50. Line 3 Format : 888888888888
  51. Format description:
  52. From a user space perspective the world is seperated in "digits" and "icons".
  53. A digit can have a character set, an icon can only be ON or OFF.
  54. Format specifier
  55. '8' : Generic 7 segment digit with individual addressable segments
  56. Reduced capabillity 7 segm digit, when segments are hard wired together.
  57. '1' : 2 segments digit only able to produce a 1.
  58. 'e' : Most significant day of the month digit,
  59. able to produce at least 1 2 3.
  60. 'M' : Most significant minute digit,
  61. able to produce at least 0 1 2 3 4 5.
  62. Icons or pictograms:
  63. '.' : For example like AM, PM, SU, a 'dot' .. or other single segment
  64. elements.
  65. 4. Driver usage
  66. ~~~~~~~~~~~~~~~
  67. For userland the following interfaces are available using the sysfs interface:
  68. /sys/.../
  69. line1 Read/Write, lcd line1
  70. line2 Read/Write, lcd line2
  71. line3 Read/Write, lcd line3
  72. get_icons Read, returns a set of available icons.
  73. hide_icon Write, hide the element by writing the icon name.
  74. show_icon Write, display the element by writing the icon name.
  75. map_seg7 Read/Write, the 7 segments char set, common for all
  76. yealink phones. (see map_to_7segment.h)
  77. ringtone Write, upload binary representation of a ringtone,
  78. see yealink.c. status EXPERIMENTAL due to potential
  79. races between async. and sync usb calls.
  80. 4.1 lineX
  81. ~~~~~~~~~
  82. Reading /sys/../lineX will return the format string with its current value:
  83. Example:
  84. cat ./line3
  85. 888888888888
  86. Linux Rocks!
  87. Writing to /sys/../lineX will set the coresponding LCD line.
  88. - Excess characters are ignored.
  89. - If less characters are written than allowed, the remaining digits are
  90. unchanged.
  91. - The tab '\t'and '\n' char does not overwrite the original content.
  92. - Writing a space to an icon will always hide its content.
  93. Example:
  94. date +"%m.%e.%k:%M" | sed 's/^0/ /' > ./line1
  95. Will update the LCD with the current date & time.
  96. 4.2 get_icons
  97. ~~~~~~~~~~~~~
  98. Reading will return all available icon names and its current settings:
  99. cat ./get_icons
  100. on M
  101. on D
  102. on :
  103. IN
  104. OUT
  105. STORE
  106. NEW
  107. REP
  108. SU
  109. MO
  110. TU
  111. WE
  112. TH
  113. FR
  114. SA
  115. LED
  116. DIALTONE
  117. RINGTONE
  118. 4.3 show/hide icons
  119. ~~~~~~~~~~~~~~~~~~~
  120. Writing to these files will update the state of the icon.
  121. Only one icon at a time can be updated.
  122. If an icon is also on a ./lineX the corresponding value is
  123. updated with the first letter of the icon.
  124. Example - light up the store icon:
  125. echo -n "STORE" > ./show_icon
  126. cat ./line1
  127. 18.e8.M8.88...188
  128. S
  129. Example - sound the ringtone for 10 seconds:
  130. echo -n RINGTONE > /sys/..../show_icon
  131. sleep 10
  132. echo -n RINGTONE > /sys/..../hide_icon
  133. 5. Sound features
  134. ~~~~~~~~~~~~~~~~~
  135. Sound is supported by the ALSA driver: snd_usb_audio
  136. One 16-bit channel with sample and playback rates of 8000 Hz is the practical
  137. limit of the device.
  138. Example - recording test:
  139. arecord -v -d 10 -r 8000 -f S16_LE -t wav foobar.wav
  140. Example - playback test:
  141. aplay foobar.wav
  142. 6. Credits & Acknowledgments
  143. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  144. - Olivier Vandorpe, for starting the usbb2k-api project doing much of
  145. the reverse engineering.
  146. - Martin Diehl, for pointing out how to handle USB memory allocation.
  147. - Dmitry Torokhov, for the numerous code reviews and suggestions.