The Linux Kernel
  • Linux kernel licensing rules
    • License identifier syntax
    • License identifiers
  • The Linux kernel user’s and administrator’s guide
    • Linux kernel release 4.x <http://kernel.org/>
    • The kernel’s command-line parameters
    • Linux allocated devices (4.x+ version)
    • Hardware vulnerabilities
    • Reporting bugs
    • Security bugs
    • Bug hunting
    • Bisecting a bug
    • Tainted kernels
    • Ramoops oops/panic logger
    • Dynamic debug
    • Explaining the dreaded “No init found.” boot hang message
    • Rules on how to access information in sysfs
    • Using the initial RAM disk (initrd)
    • Control Group v2
    • Linux Serial Console
    • Linux Braille Console
    • Parport
    • RAID arrays
    • Kernel module signing facility
    • Linux Magic System Request Key Hacks
    • Unicode support
    • Software cursor for VGA
    • Kernel Support for miscellaneous (your favourite) Binary Formats v1.1
    • Mono(tm) Binary Kernel Support for Linux
    • Java(tm) Binary Kernel Support for Linux v1.03
    • Reliability, Availability and Serviceability
    • A block layer cache (bcache)
    • Power Management
    • Thunderbolt
    • Linux Security Module Usage
    • Memory Management
  • The Linux kernel user-space API guide
    • No New Privileges Flag
    • Seccomp BPF (SECure COMPuting with filters)
    • unshare system call
    • Speculation Control
  • Working with the kernel development community
    • HOWTO do Linux kernel development
    • Contributor Covenant Code of Conduct
    • Linux Kernel Contributor Covenant Code of Conduct Interpretation
    • A guide to the Kernel Development Process
    • Submitting patches: the essential guide to getting your code into the kernel
    • Linux kernel coding style
    • Kernel Maintainer PGP guide
    • Email clients info for Linux
    • Linux Kernel Enforcement Statement
    • Kernel Driver Statement
    • Minimal requirements to compile the Kernel
    • Submitting Drivers For The Linux Kernel
    • The Linux Kernel Driver Interface
    • Linux kernel management style
    • Everything you ever wanted to know about Linux -stable releases
    • Linux Kernel patch submission checklist
    • Index of Documentation for People Interested in Writing and/or Understanding the Linux Kernel
    • Applying Patches To The Linux Kernel
    • Adding a New System Call
    • Linux magic numbers
    • Why the “volatile” type class should not be used
    • clang-format
  • Development tools for the kernel
    • Coccinelle
    • Sparse
    • kcov: code coverage for fuzzing
    • Using gcov with the Linux kernel
    • The Kernel Address Sanitizer (KASAN)
    • The Undefined Behavior Sanitizer - UBSAN
    • Kernel Memory Leak Detector
    • Debugging kernel and modules via gdb
    • Using kgdb, kdb and the kernel debugger internals
    • Linux Kernel Selftests
  • How to write kernel documentation
    • Introduction
    • Sphinx Install
    • Sphinx Build
    • Writing Documentation
    • Figures & Images
    • Writing kernel-doc comments
    • Including kernel-doc comments
    • Including uAPI header files
  • Kernel Hacking Guides
    • Unreliable Guide To Hacking The Linux Kernel
    • Unreliable Guide To Locking
  • Linux Tracing Technologies
    • Function Tracer Design
    • Notes on Analysing Behaviour Using Events and Tracepoints
    • ftrace - Function Tracer
    • Using ftrace to hook to functions
    • Kprobe-based Event Tracing
    • Uprobe-tracer: Uprobe-based Event Tracing
    • Using the Linux Kernel Tracepoints
    • Event Tracing
    • Subsystem Trace Points: kmem
    • Subsystem Trace Points: power
    • NMI Trace Events
    • MSR Trace Events
    • In-kernel memory-mapped I/O tracing
    • Event Histograms
    • Hardware Latency Detector
    • Intel(R) Trace Hub (TH)
    • System Trace Module
  • Kernel Maintainer Handbook
    • Configure Git
    • Creating Pull Requests
  • The Linux driver implementer’s API guide
    • Driver Basics
    • Device drivers infrastructure
    • Device Power Management
    • The Common Clk Framework
    • Bus-Independent Device Accesses
    • Device connections
    • Buffer Sharing and Synchronization
    • Device links
    • Message-based devices
    • Sound Devices
    • Frame Buffer Library
    • Voltage and current regulator API
    • Industrial I/O
    • Input Subsystem
    • Linux USB API
    • PCI Support Library
    • PCI Hotplug Support Library
    • Serial Peripheral Interface (SPI)
    • I2C and SMBus Subsystem
    • High Speed Synchronous Serial Interface (HSI)
    • Error Detection And Correction (EDAC) Devices
    • SCSI Interfaces Guide
    • libATA Developer’s Guide
    • target and iSCSI Interfaces Guide
    • MTD NAND Driver Programming Interface
    • Parallel Port Devices
    • 16x50 UART Driver
    • Pulse-Width Modulation (PWM)
    • W1: Dallas’ 1-wire bus
    • RapidIO Subsystem Guide
    • Writing s390 channel device drivers
    • VME Device Drivers
    • Linux 802.11 Driver Developer’s Guide
    • The Userspace I/O HOWTO
    • Linux Firmware API
    • PINCTRL (PIN CONTROL) subsystem
    • General Purpose Input/Output (GPIO)
    • Miscellaneous Devices
    • DMAEngine documentation
    • Linux kernel SLIMbus support
    • SoundWire Documentation
    • FPGA Subsystem
  • Core API Documentation
    • Core utilities
    • Interfaces for kernel debugging
  • Linux Media Subsystem Documentation
    • Linux Media Infrastructure userspace API
    • Media subsystem kernel internal API
    • Linux Digital TV driver-specific documentation
    • Video4Linux (V4L) driver-specific documentation
    • CEC driver-specific documentation
  • Linux Networking Documentation
    • netdev FAQ
    • AF_XDP
    • batman-adv
    • SocketCAN - Controller Area Network
    • The UCAN Protocol
    • DPAA2 Documentation
    • Linux* Base Driver for the Intel(R) PRO/100 Family of Adapters
    • Linux* Base Driver for Intel(R) Ethernet Network Connection
    • Linux Networking and Network Devices APIs
    • Z8530 Programming Guide
    • MSG_ZEROCOPY
    • FAILOVER
    • NET_FAILOVER
    • IP-Aliasing
    • Ethernet Bridging
  • The Linux Input Documentation
    • Linux Input Subsystem userspace API
    • Linux Input Subsystem kernel API
    • Driver-specific documentation
  • Linux GPU Driver Developer’s Guide
    • Introduction
    • DRM Internals
    • DRM Memory Management
    • Kernel Mode Setting (KMS)
    • Mode Setting Helper Functions
    • Userland interfaces
    • Kernel clients
    • GPU Driver Documentation
    • VGA Switcheroo
    • VGA Arbiter
    • TODO list
  • Security Documentation
    • Credentials in Linux
    • IMA Template Management Mechanism
    • Kernel Keys
    • Linux Security Module Development
    • SCTP LSM Support
    • Security Hooks used for Association Establishment
    • SCTP SELinux Support
    • Security Hooks
    • Policy Statements
    • SCTP Peer Labeling
    • Kernel Self-Protection
    • Trusted Platform Module documentation
  • Linux Sound Subsystem Documentation
    • ALSA Kernel API Documentation
    • Designs and Implementations
    • ALSA SoC Layer
    • Advanced Linux Sound Architecture - Driver Configuration guide
    • HD-Audio
    • Card-Specific Information
  • Linux Kernel Crypto API
    • Kernel Crypto API Interface Specification
    • Kernel Crypto API Architecture
    • Developing Cipher Algorithms
    • User Space Interface
    • CRYPTO ENGINE
    • Programming Interface
    • Code Examples
  • Linux Filesystems API
    • The Linux VFS
    • The proc filesystem
    • Events based on file descriptors
    • The Filesystem for Exporting Kernel Objects
    • The debugfs filesystem
    • The Linux Journalling API
    • splice API
    • pipes API
    • Encryption API
  • Linux Memory Management Documentation
    • User guides for MM features
    • Kernel developers MM documentation
  • BPF Documentation
    • Frequently asked questions (FAQ)
  • SuperH Interfaces Guide
    • Memory Management
    • Machine Specific Interfaces
    • Busses
  • x86 architecture specifics
    • Microarchitectural Data Sampling (MDS) mitigation
  • ext4 Filesystem
    • 1. General Information
    • 2. Data Structures and Algorithms
  • Translations
    • Chinese translations
    • Traduzione italiana
    • Korean translations
    • Japanese translations
 
The Linux Kernel
  • Docs »
  • The Linux Input Documentation »
  • Driver-specific documentation »
  • 18. Driver documentation for yealink usb-p1k phones
  • View page source

18. Driver documentation for yealink usb-p1k phones¶

18.1. Status¶

The p1k is a relatively cheap usb 1.1 phone with:

  • keyboard full support, yealink.ko / input event API
  • LCD full support, yealink.ko / sysfs API
  • LED full support, yealink.ko / sysfs API
  • dialtone full support, yealink.ko / sysfs API
  • ringtone full support, yealink.ko / sysfs API
  • audio playback full support, snd_usb_audio.ko / alsa API
  • audio record full support, snd_usb_audio.ko / alsa API

For vendor documentation see http://www.yealink.com

18.2. keyboard features¶

The current mapping in the kernel is provided by the map_p1k_to_key function:

Physical USB-P1K button layout       input events


           up                             up
     IN           OUT                left,   right
          down                           down

   pickup   C    hangup              enter, backspace, escape
     1      2      3                 1, 2, 3
     4      5      6                 4, 5, 6,
     7      8      9                 7, 8, 9,
     *      0      #                 *, 0, #,

The “up” and “down” keys, are symbolised by arrows on the button. The “pickup” and “hangup” keys are symbolised by a green and red phone on the button.

18.3. LCD features¶

The LCD is divided and organised as a 3 line display:

  |[]   [][]   [][]   [][]   in   |[][]
  |[] M [][] D [][] : [][]   out  |[][]
                            store

  NEW REP         SU MO TU WE TH FR SA

  [] [] [] [] [] [] [] [] [] [] [] []
  [] [] [] [] [] [] [] [] [] [] [] []


Line 1  Format (see below)    : 18.e8.M8.88...188
        Icon names            :   M  D  :  IN OUT STORE
Line 2  Format                : .........
        Icon name             : NEW REP SU MO TU WE TH FR SA
Line 3  Format                : 888888888888
Format description:

From a userspace perspective the world is separated into “digits” and “icons”. A digit can have a character set, an icon can only be ON or OFF.

Format specifier:

'8' :  Generic 7 segment digit with individual addressable segments

Reduced capability 7 segment digit, when segments are hard wired together.
'1' : 2 segments digit only able to produce a 1.
'e' : Most significant day of the month digit,
      able to produce at least 1 2 3.
'M' : Most significant minute digit,
      able to produce at least 0 1 2 3 4 5.

Icons or pictograms:
'.' : For example like AM, PM, SU, a 'dot' .. or other single segment
      elements.

18.4. Driver usage¶

For userland the following interfaces are available using the sysfs interface:

/sys/.../
         line1        Read/Write, lcd line1
         line2        Read/Write, lcd line2
         line3        Read/Write, lcd line3

         get_icons    Read, returns a set of available icons.
         hide_icon    Write, hide the element by writing the icon name.
         show_icon    Write, display the element by writing the icon name.

         map_seg7     Read/Write, the 7 segments char set, common for all
                      yealink phones. (see map_to_7segment.h)

         ringtone     Write, upload binary representation of a ringtone,
                      see yealink.c. status EXPERIMENTAL due to potential
                      races between async. and sync usb calls.

18.4.1. lineX¶

Reading /sys/../lineX will return the format string with its current value.

Example:

cat ./line3
888888888888
Linux Rocks!

Writing to /sys/../lineX will set the corresponding LCD line.

  • Excess characters are ignored.
  • If less characters are written than allowed, the remaining digits are unchanged.
  • The tab ‘t’and ‘n’ char does not overwrite the original content.
  • Writing a space to an icon will always hide its content.

Example:

date +"%m.%e.%k:%M"  | sed 's/^0/ /' > ./line1

Will update the LCD with the current date & time.

18.4.2. get_icons¶

Reading will return all available icon names and its current settings:

cat ./get_icons
on M
on D
on :
   IN
   OUT
   STORE
   NEW
   REP
   SU
   MO
   TU
   WE
   TH
   FR
   SA
   LED
   DIALTONE
   RINGTONE

18.4.3. show/hide icons¶

Writing to these files will update the state of the icon. Only one icon at a time can be updated.

If an icon is also on a ./lineX the corresponding value is updated with the first letter of the icon.

Example - light up the store icon:

echo -n "STORE" > ./show_icon

cat ./line1
18.e8.M8.88...188
              S

Example - sound the ringtone for 10 seconds:

echo -n RINGTONE > /sys/..../show_icon
sleep 10
echo -n RINGTONE > /sys/..../hide_icon

18.5. Sound features¶

Sound is supported by the ALSA driver: snd_usb_audio

One 16-bit channel with sample and playback rates of 8000 Hz is the practical limit of the device.

Example - recording test:

arecord -v -d 10 -r 8000 -f S16_LE -t wav  foobar.wav

Example - playback test:

aplay foobar.wav

18.6. Troubleshooting¶

Q:Module yealink compiled and installed without any problem but phone is not initialized and does not react to any actions.
A:If you see something like: hiddev0: USB HID v1.00 Device [Yealink Network Technology Ltd. VOIP USB Phone in dmesg, it means that the hid driver has grabbed the device first. Try to load module yealink before any other usb hid driver. Please see the instructions provided by your distribution on module configuration.
Q:Phone is working now (displays version and accepts keypad input) but I can’t find the sysfs files.
A:The sysfs files are located on the particular usb endpoint. On most distributions you can do: “find /sys/ -name get_icons” for a hint.

18.7. Credits & Acknowledgments¶

  • Olivier Vandorpe, for starting the usbb2k-api project doing much of the reverse engineering.
  • Martin Diehl, for pointing out how to handle USB memory allocation.
  • Dmitry Torokhov, for the numerous code reviews and suggestions.
Next Previous

© Copyright The kernel development community.

Sphinx theme provided by Read the Docs