[BlueZ PATCH v2 4/4] input: Set uniq attribute

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Set the uniq attribute of /dev/uinput with the peer device address.

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 (AVRCP)"
    ATTR{phys}=="00:00:00:6e:d0:74"
    ATTR{properties}=="0"
    ATTR{uniq}=="00:00:00:1a:33:21"

---

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


Changes in v2:
- Split setting uniq to its own commit

 profiles/audio/avctp.c | 4 +++-
 src/uinput.h           | 2 ++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/profiles/audio/avctp.c b/profiles/audio/avctp.c
index 5116a5cde..544bc640c 100644
--- a/profiles/audio/avctp.c
+++ b/profiles/audio/avctp.c
@@ -1166,7 +1166,7 @@ static int uinput_create(struct btd_device *device, const char *name,
 {
 	struct uinput_dev dev;
 	int fd, err, i;
-	char src[18];
+	char dest[18], src[18];
 
 	fd = open("/dev/uinput", O_RDWR);
 	if (fd < 0) {
@@ -1222,7 +1222,9 @@ static int uinput_create(struct btd_device *device, const char *name,
 	ioctl(fd, UI_SET_EVBIT, EV_SYN);
 
 	ba2strlc(btd_adapter_get_address(device_get_adapter(device)), src);
+	ba2strlc(device_get_address(device), dest);
 	ioctl(fd, UI_SET_PHYS, src);
+	ioctl(fd, UI_SET_UNIQ, dest);
 
 	for (i = 0; key_map[i].name != NULL; i++)
 		ioctl(fd, UI_SET_KEYBIT, key_map[i].uinput);
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.393.g34dc348eaf-goog




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux