1*4882a593Smuzhiyun=============================================== 2*4882a593SmuzhiyunDriver documentation for yealink usb-p1k phones 3*4882a593Smuzhiyun=============================================== 4*4882a593Smuzhiyun 5*4882a593SmuzhiyunStatus 6*4882a593Smuzhiyun====== 7*4882a593Smuzhiyun 8*4882a593SmuzhiyunThe p1k is a relatively cheap usb 1.1 phone with: 9*4882a593Smuzhiyun 10*4882a593Smuzhiyun - keyboard full support, yealink.ko / input event API 11*4882a593Smuzhiyun - LCD full support, yealink.ko / sysfs API 12*4882a593Smuzhiyun - LED full support, yealink.ko / sysfs API 13*4882a593Smuzhiyun - dialtone full support, yealink.ko / sysfs API 14*4882a593Smuzhiyun - ringtone full support, yealink.ko / sysfs API 15*4882a593Smuzhiyun - audio playback full support, snd_usb_audio.ko / alsa API 16*4882a593Smuzhiyun - audio record full support, snd_usb_audio.ko / alsa API 17*4882a593Smuzhiyun 18*4882a593SmuzhiyunFor vendor documentation see http://www.yealink.com 19*4882a593Smuzhiyun 20*4882a593Smuzhiyun 21*4882a593Smuzhiyunkeyboard features 22*4882a593Smuzhiyun================= 23*4882a593Smuzhiyun 24*4882a593SmuzhiyunThe current mapping in the kernel is provided by the map_p1k_to_key 25*4882a593Smuzhiyunfunction:: 26*4882a593Smuzhiyun 27*4882a593Smuzhiyun Physical USB-P1K button layout input events 28*4882a593Smuzhiyun 29*4882a593Smuzhiyun 30*4882a593Smuzhiyun up up 31*4882a593Smuzhiyun IN OUT left, right 32*4882a593Smuzhiyun down down 33*4882a593Smuzhiyun 34*4882a593Smuzhiyun pickup C hangup enter, backspace, escape 35*4882a593Smuzhiyun 1 2 3 1, 2, 3 36*4882a593Smuzhiyun 4 5 6 4, 5, 6, 37*4882a593Smuzhiyun 7 8 9 7, 8, 9, 38*4882a593Smuzhiyun * 0 # *, 0, #, 39*4882a593Smuzhiyun 40*4882a593SmuzhiyunThe "up" and "down" keys, are symbolised by arrows on the button. 41*4882a593SmuzhiyunThe "pickup" and "hangup" keys are symbolised by a green and red phone 42*4882a593Smuzhiyunon the button. 43*4882a593Smuzhiyun 44*4882a593Smuzhiyun 45*4882a593SmuzhiyunLCD features 46*4882a593Smuzhiyun============ 47*4882a593Smuzhiyun 48*4882a593SmuzhiyunThe LCD is divided and organised as a 3 line display:: 49*4882a593Smuzhiyun 50*4882a593Smuzhiyun |[] [][] [][] [][] in |[][] 51*4882a593Smuzhiyun |[] M [][] D [][] : [][] out |[][] 52*4882a593Smuzhiyun store 53*4882a593Smuzhiyun 54*4882a593Smuzhiyun NEW REP SU MO TU WE TH FR SA 55*4882a593Smuzhiyun 56*4882a593Smuzhiyun [] [] [] [] [] [] [] [] [] [] [] [] 57*4882a593Smuzhiyun [] [] [] [] [] [] [] [] [] [] [] [] 58*4882a593Smuzhiyun 59*4882a593Smuzhiyun 60*4882a593Smuzhiyun Line 1 Format (see below) : 18.e8.M8.88...188 61*4882a593Smuzhiyun Icon names : M D : IN OUT STORE 62*4882a593Smuzhiyun Line 2 Format : ......... 63*4882a593Smuzhiyun Icon name : NEW REP SU MO TU WE TH FR SA 64*4882a593Smuzhiyun Line 3 Format : 888888888888 65*4882a593Smuzhiyun 66*4882a593Smuzhiyun 67*4882a593SmuzhiyunFormat description: 68*4882a593Smuzhiyun From a userspace perspective the world is separated into "digits" and "icons". 69*4882a593Smuzhiyun A digit can have a character set, an icon can only be ON or OFF. 70*4882a593Smuzhiyun 71*4882a593Smuzhiyun Format specifier:: 72*4882a593Smuzhiyun 73*4882a593Smuzhiyun '8' : Generic 7 segment digit with individual addressable segments 74*4882a593Smuzhiyun 75*4882a593Smuzhiyun Reduced capability 7 segment digit, when segments are hard wired together. 76*4882a593Smuzhiyun '1' : 2 segments digit only able to produce a 1. 77*4882a593Smuzhiyun 'e' : Most significant day of the month digit, 78*4882a593Smuzhiyun able to produce at least 1 2 3. 79*4882a593Smuzhiyun 'M' : Most significant minute digit, 80*4882a593Smuzhiyun able to produce at least 0 1 2 3 4 5. 81*4882a593Smuzhiyun 82*4882a593Smuzhiyun Icons or pictograms: 83*4882a593Smuzhiyun '.' : For example like AM, PM, SU, a 'dot' .. or other single segment 84*4882a593Smuzhiyun elements. 85*4882a593Smuzhiyun 86*4882a593Smuzhiyun 87*4882a593SmuzhiyunDriver usage 88*4882a593Smuzhiyun============ 89*4882a593Smuzhiyun 90*4882a593SmuzhiyunFor userland the following interfaces are available using the sysfs interface:: 91*4882a593Smuzhiyun 92*4882a593Smuzhiyun /sys/.../ 93*4882a593Smuzhiyun line1 Read/Write, lcd line1 94*4882a593Smuzhiyun line2 Read/Write, lcd line2 95*4882a593Smuzhiyun line3 Read/Write, lcd line3 96*4882a593Smuzhiyun 97*4882a593Smuzhiyun get_icons Read, returns a set of available icons. 98*4882a593Smuzhiyun hide_icon Write, hide the element by writing the icon name. 99*4882a593Smuzhiyun show_icon Write, display the element by writing the icon name. 100*4882a593Smuzhiyun 101*4882a593Smuzhiyun map_seg7 Read/Write, the 7 segments char set, common for all 102*4882a593Smuzhiyun yealink phones. (see map_to_7segment.h) 103*4882a593Smuzhiyun 104*4882a593Smuzhiyun ringtone Write, upload binary representation of a ringtone, 105*4882a593Smuzhiyun see yealink.c. status EXPERIMENTAL due to potential 106*4882a593Smuzhiyun races between async. and sync usb calls. 107*4882a593Smuzhiyun 108*4882a593Smuzhiyun 109*4882a593SmuzhiyunlineX 110*4882a593Smuzhiyun~~~~~ 111*4882a593Smuzhiyun 112*4882a593SmuzhiyunReading /sys/../lineX will return the format string with its current value. 113*4882a593Smuzhiyun 114*4882a593Smuzhiyun Example:: 115*4882a593Smuzhiyun 116*4882a593Smuzhiyun cat ./line3 117*4882a593Smuzhiyun 888888888888 118*4882a593Smuzhiyun Linux Rocks! 119*4882a593Smuzhiyun 120*4882a593SmuzhiyunWriting to /sys/../lineX will set the corresponding LCD line. 121*4882a593Smuzhiyun 122*4882a593Smuzhiyun - Excess characters are ignored. 123*4882a593Smuzhiyun - If less characters are written than allowed, the remaining digits are 124*4882a593Smuzhiyun unchanged. 125*4882a593Smuzhiyun - The tab '\t'and '\n' char does not overwrite the original content. 126*4882a593Smuzhiyun - Writing a space to an icon will always hide its content. 127*4882a593Smuzhiyun 128*4882a593Smuzhiyun Example:: 129*4882a593Smuzhiyun 130*4882a593Smuzhiyun date +"%m.%e.%k:%M" | sed 's/^0/ /' > ./line1 131*4882a593Smuzhiyun 132*4882a593Smuzhiyun Will update the LCD with the current date & time. 133*4882a593Smuzhiyun 134*4882a593Smuzhiyun 135*4882a593Smuzhiyunget_icons 136*4882a593Smuzhiyun~~~~~~~~~ 137*4882a593Smuzhiyun 138*4882a593SmuzhiyunReading will return all available icon names and its current settings:: 139*4882a593Smuzhiyun 140*4882a593Smuzhiyun cat ./get_icons 141*4882a593Smuzhiyun on M 142*4882a593Smuzhiyun on D 143*4882a593Smuzhiyun on : 144*4882a593Smuzhiyun IN 145*4882a593Smuzhiyun OUT 146*4882a593Smuzhiyun STORE 147*4882a593Smuzhiyun NEW 148*4882a593Smuzhiyun REP 149*4882a593Smuzhiyun SU 150*4882a593Smuzhiyun MO 151*4882a593Smuzhiyun TU 152*4882a593Smuzhiyun WE 153*4882a593Smuzhiyun TH 154*4882a593Smuzhiyun FR 155*4882a593Smuzhiyun SA 156*4882a593Smuzhiyun LED 157*4882a593Smuzhiyun DIALTONE 158*4882a593Smuzhiyun RINGTONE 159*4882a593Smuzhiyun 160*4882a593Smuzhiyun 161*4882a593Smuzhiyunshow/hide icons 162*4882a593Smuzhiyun~~~~~~~~~~~~~~~ 163*4882a593Smuzhiyun 164*4882a593SmuzhiyunWriting to these files will update the state of the icon. 165*4882a593SmuzhiyunOnly one icon at a time can be updated. 166*4882a593Smuzhiyun 167*4882a593SmuzhiyunIf an icon is also on a ./lineX the corresponding value is 168*4882a593Smuzhiyunupdated with the first letter of the icon. 169*4882a593Smuzhiyun 170*4882a593Smuzhiyun Example - light up the store icon:: 171*4882a593Smuzhiyun 172*4882a593Smuzhiyun echo -n "STORE" > ./show_icon 173*4882a593Smuzhiyun 174*4882a593Smuzhiyun cat ./line1 175*4882a593Smuzhiyun 18.e8.M8.88...188 176*4882a593Smuzhiyun S 177*4882a593Smuzhiyun 178*4882a593Smuzhiyun Example - sound the ringtone for 10 seconds:: 179*4882a593Smuzhiyun 180*4882a593Smuzhiyun echo -n RINGTONE > /sys/..../show_icon 181*4882a593Smuzhiyun sleep 10 182*4882a593Smuzhiyun echo -n RINGTONE > /sys/..../hide_icon 183*4882a593Smuzhiyun 184*4882a593Smuzhiyun 185*4882a593SmuzhiyunSound features 186*4882a593Smuzhiyun============== 187*4882a593Smuzhiyun 188*4882a593SmuzhiyunSound is supported by the ALSA driver: snd_usb_audio 189*4882a593Smuzhiyun 190*4882a593SmuzhiyunOne 16-bit channel with sample and playback rates of 8000 Hz is the practical 191*4882a593Smuzhiyunlimit of the device. 192*4882a593Smuzhiyun 193*4882a593Smuzhiyun Example - recording test:: 194*4882a593Smuzhiyun 195*4882a593Smuzhiyun arecord -v -d 10 -r 8000 -f S16_LE -t wav foobar.wav 196*4882a593Smuzhiyun 197*4882a593Smuzhiyun Example - playback test:: 198*4882a593Smuzhiyun 199*4882a593Smuzhiyun aplay foobar.wav 200*4882a593Smuzhiyun 201*4882a593Smuzhiyun 202*4882a593SmuzhiyunTroubleshooting 203*4882a593Smuzhiyun=============== 204*4882a593Smuzhiyun 205*4882a593Smuzhiyun:Q: Module yealink compiled and installed without any problem but phone 206*4882a593Smuzhiyun is not initialized and does not react to any actions. 207*4882a593Smuzhiyun:A: If you see something like: 208*4882a593Smuzhiyun hiddev0: USB HID v1.00 Device [Yealink Network Technology Ltd. VOIP USB Phone 209*4882a593Smuzhiyun in dmesg, it means that the hid driver has grabbed the device first. Try to 210*4882a593Smuzhiyun load module yealink before any other usb hid driver. Please see the 211*4882a593Smuzhiyun instructions provided by your distribution on module configuration. 212*4882a593Smuzhiyun 213*4882a593Smuzhiyun:Q: Phone is working now (displays version and accepts keypad input) but I can't 214*4882a593Smuzhiyun find the sysfs files. 215*4882a593Smuzhiyun:A: The sysfs files are located on the particular usb endpoint. On most 216*4882a593Smuzhiyun distributions you can do: "find /sys/ -name get_icons" for a hint. 217*4882a593Smuzhiyun 218*4882a593Smuzhiyun 219*4882a593SmuzhiyunCredits & Acknowledgments 220*4882a593Smuzhiyun========================= 221*4882a593Smuzhiyun 222*4882a593Smuzhiyun - Olivier Vandorpe, for starting the usbb2k-api project doing much of 223*4882a593Smuzhiyun the reverse engineering. 224*4882a593Smuzhiyun - Martin Diehl, for pointing out how to handle USB memory allocation. 225*4882a593Smuzhiyun - Dmitry Torokhov, for the numerous code reviews and suggestions. 226