Discard HID input from CM108 device

During experimenting with USB soundcard devices based on cm108 chips I discovered that a squelch signal on the GPIO inputs of the sound chip does trigger a keyboard event as if one pressed the “volume down” key. Depending on the system configuration that can lead to your default sound card being muted. In my case I was running UniPager as DAPNET client to the pager network in combination with a self made USB sound device with GPIO-controlled PTT.

If you just want to exlude the emulated volume down key press event you can remap this button press event from the emulated keyboard using an udev hwdb config directive. To achieve this you have to know the keyscan code of the button being emulated. This value can then be remapped or ignored.

To identify the scan code you can execute evtest (after installation):

$ sudo evtest
No device specified, trying to scan all of /dev/input/event*
Available devices:
/dev/input/event16:     C-Media Electronics Inc.       USB PnP Sound Device
Select the device event number [0-16]: 16
Input driver version is 1.0.1
Input device ID: bus 0x3 vendor 0xd8c product 0x13c version 0x100
Input device name: "C-Media Electronics Inc.       USB PnP Sound Device"
Supported events:
  Event type 0 (EV_SYN)
  Event type 1 (EV_KEY)
    Event code 113 (KEY_MUTE)
    Event code 114 (KEY_VOLUMEDOWN)
    Event code 115 (KEY_VOLUMEUP)
  Event type 4 (EV_MSC)
    Event code 4 (MSC_SCAN)
Properties:
Testing ... (interrupt to exit)
Event: time 1543530910.142311, type 4 (EV_MSC), code 4 (MSC_SCAN), value c00ea
Event: time 1543530910.142311, type 1 (EV_KEY), code 114 (KEY_VOLUMEDOWN), value 0
Event: time 1543530910.142311, -------------- SYN_REPORT ------------
Event: time 1543530912.926319, type 4 (EV_MSC), code 4 (MSC_SCAN), value c00ea
Event: time 1543530912.926319, type 1 (EV_KEY), code 114 (KEY_VOLUMEDOWN), value 1
Event: time 1543530912.926319, -------------- SYN_REPORT ------------
^C

During the test I transmitted a test transmission in order to trigger the squelch which triggers a GPIO pin on the radio which itself is connected to one of the GPIOs of the CM108 chip. It shows that a scan code of c00ea is triggered.

Now let’s remap this emualted key press event. Edit a custom udev hwdb rule (e.g. /etc/udev/hwdb.d/50-cm108.hwdb) with the following content:

# Ignore hid input events from cm108 GPIOs
evdev:input:b*v0D8Cp013C*
   KEYBOARD_KEY_c00ea=reserved

Afterward you just have to rebuild the hwdb using the command “udevadm hwdb –update” and then kick it “udevadm trigger” or restart udev. Now the emulated keypress events should be ignored.