When creating the uinput device, change the name to the peer device name. Set the peer device address to the uniq attribute instead of the name. The resulting uinput device will look like this: $ udevadm info -a -p /sys/devices/virtual/input/input17 ... looking at device '/devices/virtual/input/input17': KERNEL=="input17" SUBSYSTEM=="input" DRIVER=="" ATTR{inhibited}=="0" ATTR{name}=="BeatsStudio Wireless" ATTR{phys}=="00:00:00:6e:d0:74" ATTR{properties}=="0" ATTR{uniq}=="00:00:00:cc:1c:f3" --- This change requires an accompanying change in the kernel that adds the set uniq ioctl. The change is available here: https://lore.kernel.org/linux-bluetooth/20191127185139.65048-1-abhishekpandit@xxxxxxxxxxxx/T/#u If this change looks ok, I would like to merge it with the previous change before merging since they're related. profiles/audio/avctp.c | 18 +++++++++--------- src/uinput.h | 2 ++ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/profiles/audio/avctp.c b/profiles/audio/avctp.c index 42136f94b..05df57bd2 100644 --- a/profiles/audio/avctp.c +++ b/profiles/audio/avctp.c @@ -1162,7 +1162,7 @@ failed: } static int uinput_create(struct btd_device *device, const char *name, - const char *phys) + const char *src, const char *dst) { struct uinput_dev dev; int fd, err, i; @@ -1203,8 +1203,8 @@ static int uinput_create(struct btd_device *device, const char *name, ioctl(fd, UI_SET_EVBIT, EV_REP); ioctl(fd, UI_SET_EVBIT, EV_SYN); - /* Also set the phys */ - ioctl(fd, UI_SET_PHYS, phys); + ioctl(fd, UI_SET_PHYS, src); + ioctl(fd, UI_SET_UNIQ, dst); for (i = 0; key_map[i].name != NULL; i++) ioctl(fd, UI_SET_KEYBIT, key_map[i].uinput); @@ -1224,7 +1224,7 @@ static int uinput_create(struct btd_device *device, const char *name, static void init_uinput(struct avctp *session) { - char address[18], phys[18], name[248 + 1]; + char dest[18], src[18], name[248 + 1]; device_get_name(session->device, name, sizeof(name)); if (g_str_equal(name, "Nokia CK-20W")) { @@ -1234,15 +1234,15 @@ static void init_uinput(struct avctp *session) session->key_quirks[AVC_PAUSE] |= QUIRK_NO_RELEASE; } - ba2strlc(device_get_address(session->device), address); + ba2strlc(device_get_address(session->device), dest); ba2strlc(btd_adapter_get_address(device_get_adapter(session->device)), - phys); + src); - session->uinput = uinput_create(session->device, address, phys); + session->uinput = uinput_create(session->device, name, src, dest); if (session->uinput < 0) - error("AVRCP: failed to init uinput for %s", address); + error("AVRCP: failed to init uinput for %s", dest); else - DBG("AVRCP: uinput initialized for %s", address); + DBG("AVRCP: uinput initialized for %s", dest); } static struct avctp_queue *avctp_queue_create(struct avctp_channel *chan) diff --git a/src/uinput.h b/src/uinput.h index 20e0941d1..589c22528 100644 --- a/src/uinput.h +++ b/src/uinput.h @@ -686,6 +686,8 @@ extern "C" { #define UI_SET_FFBIT _IOW(UINPUT_IOCTL_BASE, 107, int) #define UI_SET_PHYS _IOW(UINPUT_IOCTL_BASE, 108, char*) #define UI_SET_SWBIT _IOW(UINPUT_IOCTL_BASE, 109, int) +#define UI_SET_PROPBIT _IOW(UINPUT_IOCTL_BASE, 110, int) +#define UI_SET_UNIQ _IOW(UINPUT_IOCTL_BASE, 111, char*) #ifndef NBITS #define NBITS(x) ((((x) - 1) / (sizeof(long) * 8)) + 1) -- 2.24.0.432.g9d3f5f5b63-goog