input: Set uniq attribute
authorAbhishek Pandit-Subedi <abhishekpandit@chromium.org>
Tue, 3 Dec 2019 01:04:00 +0000 (17:04 -0800)
committerAyush Garg <ayush.garg@samsung.com>
Mon, 12 Apr 2021 09:00:47 +0000 (14:30 +0530)
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"

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
profiles/audio/avctp.c
src/uinput.h

index 66a4d93..a8a1172 100644 (file)
@@ -1224,7 +1224,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) {
@@ -1282,7 +1282,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);
 
 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
        ioctl(fd, UI_SET_EVBIT, EV_ABS);
index 20e0941..589c225 100755 (executable)
@@ -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)