public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [Bluez-users] DiNovo at last
@ 2007-10-18 13:11 Fabrice Ménard
  0 siblings, 0 replies; only message in thread
From: Fabrice Ménard @ 2007-10-18 13:11 UTC (permalink / raw)
  To: bluez-users


[-- Attachment #1.1.1: Type: text/plain, Size: 4610 bytes --]

Hi,

I managed to make work my DiNovo set quit well but I want to share my story 
with you in order to know if there's better way to do things. I apologize for 
this lengthy message.

I wanted to use the device with the input service instead of hidd as it is,
as far as I know, the correct way now to proceed.  Moreover, I wanted to use
the new xorg input hotplug system.

Here are the versions used:
        - bluez-libs-3.19
        - bluez-utils-3.19
        - kernel 2.6.22.6
        - xorg-xserver-1.4
        - udev 115

After loading the necessary modules and switching to
hci mode, I get the famous bug message in dmesg:
       "BUG: at drivers/hid/hid-core.c:785 implement()"

I found that hid2hci send wrong values in its report. 
(the conversion beetwen 'char' and 'unsigned int' left shifts the highest bit 
so the uref.value in 'send_report (hid2hci.c)' exceeds the mask in the 
function 'implement (hid-core.c in the kernel)' and triggers the warning. 
Therefore, I applied a mask on the uref.value ; see hid2hci.patch)

Now it's time to connect the devices:
        hcitool scan
        hcitool inq

I don't want to enter a PIN everyday for the keyboard, the mediapad and the 
mouse:
        dbus-send --system --type=method_call --print-reply \
        --dest=org.bluez /org/bluez/hci0 org.bluez.Adapter.SetTrusted \
        string:"XX:XX:XX:XX:XX:XX"

Setting the input service:
        dbus-send --system --type=method_call --print-reply \
        --dest=org.bluez /org/bluez org.bluez.Manager.ActivateService 
string:input
        dbus-send --system --type=method_call --print-reply \
        --dest=":X.X" /org/bluez/input org.bluez.input.Manager.CreateDevice \
        string:"XX:XX:XX:XX:XX:XX"
        dbus-send --system --type=method_call --print-reply \
        --dest=":X.X" /org/bluez/input/keyboard0 
org.bluez.input.Device.Connect
(the last two commands for the three devices)

linkkeys creation:
       
(terminal1)# /usr/src/bluez/src/bluez-utils-build/daemon/passkey-agent\ 
xxxx   XX:XX:XX:XX:XX:XX
(terminal 2)# dbus-send --system --type=method_call \
--print-reply --dest=org.bluez /org/bluez/hci0 \
org.bluez.Adapter.CreateBonding string:"XX:XX:XX:XX:XX:XX"
(again, for all the devices except the mouse)

So far so good.

After a while, I discovered that when you don't use the keyboard for approx. 
15 mn., you can't wake it up until a long time later. Here is the picture:

  ---------------- |XXXXXXXXXXXXXXXXXXXX  |----------> time
                        |                                                       |
                kernel event                                    bluetooth 
                + udev remove                           disconnect
        
(during the gray zone the devices are unresponsive)

To solve this problem I added this udev rule:
        SUBSYSTEM=="input", ACTION=="remove", ENV{UNIQ}=="?*", \
        RUN{ignore_error}+="/bin/sh -c '/usr/bin/dbus-send --system \
        --type=method_call --dest=org.bluez /org/bluez/hci0 \
        org.bluez.Adapter.DisconnectRemoteDevice string:$env{UNIQ}'"
(ie I disconnect the bluetooth device when the kernel sends an input remove 
event ;  the bluetooth device will reconnect automatically with the next 
keystroke)

Now the X part:

For input hotplug the X server uses hal to discover the devices.  
Unfortunatly, the x11-input.fdi file provided by xorg doesn't detect
the good ones in our case (see the attached x11-input.fdi file).

Finally, there'is a bug in Xorg xserver that crash the server when you
remove a device.  You can test it with the following command:
        dbus-send --system --type=method_call --print-reply \
        --dest=org.x.config.display0 /org/x/config/0 
org.x.config.input.listDevices
        dbus-send --system --type=method_call --print-reply \
        --dest=org.x.config.display0 /org/x/config/0 org.x.config.input.remove 
\
        uint32:X
(where X is the device number you want to remove)

The problem is that a part of de xorg input driver is double freed (see 
xserver.patch).  I will send this one to the xorg mailing list because I'm 
not sure I don't break something. 

That's the end for now.  Eveything works well albeit my .xsession-errors fills 
with X error (I think they are related to x_setPointerMapping) but I don't 
know how to debug these ones yet.
Please, tell me if I made really stupid things and, once again, excuse me for 
this lengthy message and for my poor english.

Regards,

-- 
Fabrice Ménard
menard.fabrice@orange.fr

[-- Attachment #1.1.2: hid2hci.patch --]
[-- Type: text/x-diff, Size: 441 bytes --]

--- bluez-utils-3.19/tools/hid2hci.c	2007-09-16 09:57:40.000000000 +0200
+++ bluez-utils-3.19/tools/hid2hci.c.new	2007-10-18 11:25:40.000000000 +0200
@@ -138,7 +138,7 @@ static int send_report(int fd, const cha
 		uref.field_index = 0;
 		uref.usage_index = i;
 		uref.usage_code  = 0xff000001;
-		uref.value       = buf[i];
+		uref.value       = buf[i] & 0x000000ff;
 		err = ioctl(fd, HIDIOCSUSAGE, &uref);
 		if (err < 0)
 			return err;

[-- Attachment #1.1.3: x11-input.fdi --]
[-- Type: text/plain, Size: 735 bytes --]

<?xml version="1.0" encoding="UTF-8"?>
<deviceinfo version="0.2">
  <device>
    <!-- Pour DiNovo -->
    <match key="info.product" contains="Logitech MX900 Mouse">
      <merge key="input.x11_driver" type="string">evdev</merge>
    </match>
    <match key="info.product" contains="Logitech diNovo Keyboard">
      <merge key="input.x11_driver" type="string">evdev</merge>
      <merge key="input.xkb.rules" type="string">base</merge>
      <merge key="input.xkb.model" type="string">evdev</merge>
      <merge key="input.xkb.layout" type="string">fr</merge>
    </match>
    <match key="info.product" contains="Logitech Mediapad">
      <merge key="input.x11_driver" type="string">evdev</merge>
    </match>
  </device>
</deviceinfo>

[-- Attachment #1.1.4: xserver.patch --]
[-- Type: text/x-diff, Size: 419 bytes --]

--- xorg-server-1.4/hw/xfree86/common/xf86Helper.c	2007-08-23 21:04:53.000000000 +0200
+++ xorg-server-1.4/hw/xfree86/common/xf86Helper.c.new	2007-10-12 22:42:00.000000000 +0200
@@ -388,7 +388,7 @@ xf86DeleteInput(InputInfoPtr pInp, int f
 	    p->next = pInp->next;
 	/* Else the entry wasn't in the xf86InputDevs list (ignore this). */
     }
-    xfree(pInp);
+/*     xfree(pInp); */
 }
 
 _X_EXPORT Bool

[-- Attachment #1.2: Type: application/pgp-signature, Size: 189 bytes --]

[-- Attachment #2: Type: text/plain, Size: 314 bytes --]

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/

[-- Attachment #3: Type: text/plain, Size: 164 bytes --]

_______________________________________________
Bluez-users mailing list
Bluez-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-users

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-10-18 13:11 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-18 13:11 [Bluez-users] DiNovo at last Fabrice Ménard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox