~sqrammi/bluez/bluez-bdremote

« back to all changes in this revision

Viewing changes to debian/patches/12-bdremote-timeout.patch

  • Committer: Jeff Hansen (Lisa)
  • Date: 2013-04-17 04:16:35 UTC
  • Revision ID: x@jeffhansen.com-20130417041635-3p0u5ydonr0azb0y
debian/patches/12-bdremote-timeout.patch: Make ps3remote use the system-wide
input IdleTimeout, which dramatically increases battery life on PS3 remote.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
--- ./input/device.h.orig       2010-09-08 09:27:53.000000000 -0600
 
2
+++ ./input/device.h    2013-02-19 22:03:40.310100075 -0700
 
3
@@ -40,6 +40,8 @@
 
4
        int             (*disconnect) (struct input_conn *iconn);
 
5
        void            *priv;
 
6
        const struct input_device *idev;
 
7
+       guint           idle_timeout;
 
8
+       uint32_t        timeout;
 
9
 };
 
10
 
 
11
 int fake_input_register(DBusConnection *conn, struct btd_device *device,
 
12
@@ -54,3 +56,5 @@
 
13
 int input_device_set_channel(const bdaddr_t *src, const bdaddr_t *dst, int psm,
 
14
                                                        GIOChannel *io);
 
15
 int input_device_close_channels(const bdaddr_t *src, const bdaddr_t *dst);
 
16
+
 
17
+void input_device_request_disconnect(const struct input_device *idev);
 
18
--- ./input/fakehid.c.orig      2013-02-19 22:01:58.524706809 -0700
 
19
+++ ./input/fakehid.c   2013-02-19 22:03:40.310100075 -0700
 
20
@@ -208,6 +208,13 @@
 
21
        return -1;
 
22
 }
 
23
 
 
24
+static gboolean ps3remote_idle(gpointer data)
 
25
+{
 
26
+       struct fake_input *fake = data;
 
27
+       input_device_request_disconnect(fake->idev);
 
28
+       return FALSE;
 
29
+}
 
30
+
 
31
 static gboolean ps3remote_event(GIOChannel *chan, GIOCondition cond,
 
32
                                gpointer data)
 
33
 {
 
34
@@ -218,6 +225,13 @@
 
35
        char buff[50];
 
36
        int fd;
 
37
 
 
38
+       if (fake->idle_timeout) {
 
39
+               g_source_remove(fake->idle_timeout);
 
40
+               fake->idle_timeout = 0;
 
41
+       }
 
42
+       if (fake->timeout)
 
43
+               fake->idle_timeout = g_timeout_add(fake->timeout, ps3remote_idle, fake);
 
44
+
 
45
        if (cond & G_IO_NVAL)
 
46
                return FALSE;
 
47
 
 
48
@@ -337,6 +351,10 @@
 
49
 
 
50
 static int fake_hid_common_disconnect(struct fake_input *fake)
 
51
 {
 
52
+       if (fake->idle_timeout) {
 
53
+               g_source_remove(fake->idle_timeout);
 
54
+               fake->idle_timeout = 0;
 
55
+       }
 
56
        return 0;
 
57
 }
 
58
 
 
59
--- ./input/device.c.orig       2011-12-21 15:53:54.000000000 -0700
 
60
+++ ./input/device.c    2013-02-19 22:03:40.306100021 -0700
 
61
@@ -608,6 +608,7 @@
 
62
                fake->disconnect = fake_hid_disconnect;
 
63
                fake->priv = fake_hid;
 
64
                fake->idev = idev;
 
65
+               fake->timeout = iconn->timeout * 1000;
 
66
                fake = fake_hid_connadd(fake, iconn->intr_io, fake_hid);
 
67
                if (fake == NULL)
 
68
                        err = -ENOMEM;
 
69
@@ -1256,3 +1257,8 @@
 
70
 
 
71
        return 0;
 
72
 }
 
73
+
 
74
+void input_device_request_disconnect(const struct input_device *idev)
 
75
+{
 
76
+       device_request_disconnect(idev->device, NULL);
 
77
+}