Add ttrace
authorJengHyun Kang <jhyuni.kang@samsung.com>
Thu, 11 Feb 2016 06:44:36 +0000 (15:44 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Tue, 4 Feb 2025 08:13:19 +0000 (17:13 +0900)
Change-Id: I82a316d226c967a396f6ce5671feeafbfb37bd0f

meson.build
packaging/libinput.spec
src/evdev-fallback.c
src/evdev.c
src/libinput-private.h
src/libinput.c

index e2945611bc4f881cb8e09cf4510565dfa809b910..c37f45997dc422c851793a0c6f436c7dc49f7ed6 100644 (file)
@@ -178,6 +178,14 @@ else
        dep_libwacom = declare_dependency()
 endif
 
+############ ttrace configuration ############
+
+dep_ttrace = dependency('ttrace', required : false)
+if dep_ttrace.found()
+       config_h.set10('ENABLE_TTRACE', 1)
+endif
+
+
 ############ udev bits ############
 
 executable('libinput-device-group',
@@ -386,7 +394,8 @@ deps_libinput = [
        dep_rt,
        dep_libwacom,
        dep_libinput_util,
-       dep_libquirks
+       dep_libquirks,
+       dep_ttrace
 ]
 
 libinput_version_h_config = configuration_data()
index af0deada620971e4adf18eacd567a40985268002..d666dee20951b2d58936dbd974eb999bec5e5b8b 100644 (file)
@@ -16,7 +16,7 @@ BuildRequires:  pkgconfig(libevdev)
 BuildRequires:  pkgconfig(libevent)
 BuildRequires:  pkgconfig(libudev)
 BuildRequires:  pkgconfig(mtdev)
-BuildRequires:  pkgconfig(wacom)
+BuildRequires:  pkgconfig(ttrace)
 
 
 %description
index 87fd26f62fb1986166088902cdb616d853020fe0..49be0fc50a371ff525e6e8a234be9125918a15df 100644 (file)
@@ -173,8 +173,12 @@ fallback_flush_relative_motion(struct fallback_dispatch *dispatch,
        struct libinput_device *base = &device->base;
        struct normalized_coords accel;
 
-       if (!(device->seat_caps & EVDEV_DEVICE_POINTER))
+       TRACE_BEGIN(fallback_flush_relative_motion);
+
+       if (!(device->seat_caps & EVDEV_DEVICE_POINTER)) {
+               TRACE_END();
                return;
+       }
 
        struct device_float_coords raw = fallback_rotate_relative(dispatch, device);
 
@@ -182,8 +186,10 @@ fallback_flush_relative_motion(struct fallback_dispatch *dispatch,
        dispatch->rel.y = 0;
 
        /* Use unaccelerated deltas for pointing stick scroll */
-       if (post_button_scroll(device, raw, time))
+       if (post_button_scroll(device, raw, time)) {
+               TRACE_END();
                return;
+       }
 
        if (device->pointer.filter) {
                /* Apply pointer acceleration. */
@@ -197,10 +203,13 @@ fallback_flush_relative_motion(struct fallback_dispatch *dispatch,
                accel.x = accel.y = 0;
        }
 
-       if (normalized_is_zero(accel))
+       if (normalized_is_zero(accel)) {
+               TRACE_END();
                return;
+       }
 
        pointer_notify_motion(base, time, &accel, &raw);
+       TRACE_END();
 }
 
 static void
@@ -480,9 +489,13 @@ fallback_process_key(struct fallback_dispatch *dispatch,
 {
        enum key_type type;
 
+       TRACE_BEGIN(fallbak_process_key);
+
        /* ignore kernel key repeat */
-       if (e->value == 2)
+       if (e->value == 2) {
+               TRACE_END();
                return;
+       }
 
        if (e->code == BTN_TOUCH) {
                if (!device->is_mt)
@@ -490,6 +503,7 @@ fallback_process_key(struct fallback_dispatch *dispatch,
                                                      device,
                                                      time,
                                                      e->value);
+               TRACE_END();
                return;
        }
 
@@ -504,8 +518,10 @@ fallback_process_key(struct fallback_dispatch *dispatch,
        case KEY_TYPE_KEY:
        case KEY_TYPE_BUTTON:
                if ((e->value && hw_is_key_down(dispatch, e->code)) ||
-                   (e->value == 0 && !hw_is_key_down(dispatch, e->code)))
+                   (e->value == 0 && !hw_is_key_down(dispatch, e->code))) {
+                   TRACE_END();
                        return;
+               }
 
                dispatch->pending_event |= EVDEV_KEY;
                break;
@@ -528,6 +544,7 @@ fallback_process_key(struct fallback_dispatch *dispatch,
        case KEY_TYPE_BUTTON:
                break;
        }
+       TRACE_END();
 }
 
 static void
@@ -786,8 +803,12 @@ fallback_process_relative(struct fallback_dispatch *dispatch,
                          struct evdev_device *device,
                          struct input_event *e, uint64_t time)
 {
-       if (fallback_reject_relative(device, e, time))
+       TRACE_BEGIN(fallback_process_relative);
+
+       if (fallback_reject_relative(device, e, time)) {
+               TRACE_END();
                return;
+       }
 
        switch (e->code) {
        case REL_X:
@@ -801,6 +822,7 @@ fallback_process_relative(struct fallback_dispatch *dispatch,
        }
 
        fallback_wheel_process_relative(dispatch, device, e, time);
+       TRACE_END();
 }
 
 static inline void
@@ -809,11 +831,13 @@ fallback_process_absolute(struct fallback_dispatch *dispatch,
                          struct input_event *e,
                          uint64_t time)
 {
+       TRACE_BEGIN(fallback_process_absolute);
        if (device->is_mt) {
                fallback_process_touch(dispatch, device, e, time);
        } else {
                fallback_process_absolute_motion(dispatch, device, e);
        }
+       TRACE_END();
 }
 
 static inline bool
index cc02e7bb6a9289738f707eca1a35226cea70cf96..6ff76385746f7d01ba613addc69317155908c60b 100644 (file)
@@ -1106,7 +1106,11 @@ evdev_process_event(struct evdev_device *device, struct input_event *e)
 
        libinput_timer_flush(evdev_libinput_context(device), time);
 
+       TRACE_BEGIN(evdev_process_event);
+
        dispatch->interface->process(dispatch, device, e, time);
+
+       TRACE_END();
 }
 
 static inline void
index c282e350029351e6c814f3a745dd788cd3616edf..19cec18b7dd5a49e78479083e919c5896b73ed04 100644 (file)
 #include "libinput-util.h"
 #include "libinput-version.h"
 
+#ifdef ENABLE_TTRACE
+#include <ttrace.h>
+
+#define TRACE_BEGIN(NAME) traceBegin(TTRACE_TAG_INPUT, "INPUT:LIBINPUT:"#NAME)
+#define TRACE_END() traceEnd(TTRACE_TAG_INPUT)
+#else
+#define TRACE_BEGIN(NAME)
+#define TRACE_END()
+#endif
+
 struct libinput_source;
 
 /* A coordinate pair in device coordinates */
index 94bdff9c6b7b02a991bf85273a3d53045635d29a..640ef0eec0e9b2607943a9c4d42ca962cffac8bc 100644 (file)
@@ -2481,6 +2481,8 @@ notify_added_device(struct libinput_device *device)
 {
        struct libinput_event_device_notify *added_device_event;
 
+       TRACE_BEGIN(notify_added_device);
+
        added_device_event = zalloc(sizeof *added_device_event);
 
        post_base_event(device,
@@ -2492,6 +2494,7 @@ notify_added_device(struct libinput_device *device)
         * pretend to free it  */
        free(added_device_event);
 #endif
+       TRACE_END();
 }
 
 void
@@ -2499,6 +2502,8 @@ notify_removed_device(struct libinput_device *device)
 {
        struct libinput_event_device_notify *removed_device_event;
 
+       TRACE_BEGIN(notify_removed_device);
+
        removed_device_event = zalloc(sizeof *removed_device_event);
 
        post_base_event(device,
@@ -2510,6 +2515,7 @@ notify_removed_device(struct libinput_device *device)
         * pretend to free it  */
        free(removed_device_event);
 #endif
+       TRACE_END();
 }
 
 static inline bool
@@ -2562,8 +2568,12 @@ keyboard_notify_key(struct libinput_device *device,
        struct libinput_event_keyboard *key_event;
        uint32_t seat_key_count;
 
-       if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_KEYBOARD))
+       TRACE_BEGIN(keyboard_notify_key);
+
+       if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_KEYBOARD)) {
+               TRACE_END();
                return;
+       }
 
        key_event = zalloc(sizeof *key_event);
 
@@ -2579,6 +2589,8 @@ keyboard_notify_key(struct libinput_device *device,
        post_device_event(device, time,
                          LIBINPUT_EVENT_KEYBOARD_KEY,
                          &key_event->base);
+
+       TRACE_END();
 }
 
 void
@@ -2589,9 +2601,13 @@ pointer_notify_motion(struct libinput_device *device,
 {
        struct libinput_event_pointer *motion_event;
 
-       if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_POINTER))
-               return;
+       TRACE_BEGIN(pointer_notify_motion);
 
+       if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_POINTER)) {
+               TRACE_END();
+               return;
+       }
+       
        motion_event = zalloc(sizeof *motion_event);
 
        *motion_event = (struct libinput_event_pointer) {
@@ -2603,6 +2619,8 @@ pointer_notify_motion(struct libinput_device *device,
        post_device_event(device, time,
                          LIBINPUT_EVENT_POINTER_MOTION,
                          &motion_event->base);
+
+       TRACE_END();
 }
 
 void
@@ -2612,8 +2630,12 @@ pointer_notify_motion_absolute(struct libinput_device *device,
 {
        struct libinput_event_pointer *motion_absolute_event;
 
-       if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_POINTER))
+       TRACE_BEGIN(pointer_notify_motion_absolute);
+
+       if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_POINTER)) {
+               TRACE_END();
                return;
+       }
 
        motion_absolute_event = zalloc(sizeof *motion_absolute_event);
 
@@ -2625,6 +2647,8 @@ pointer_notify_motion_absolute(struct libinput_device *device,
        post_device_event(device, time,
                          LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE,
                          &motion_absolute_event->base);
+
+       TRACE_END();
 }
 
 void
@@ -2636,8 +2660,12 @@ pointer_notify_button(struct libinput_device *device,
        struct libinput_event_pointer *button_event;
        int32_t seat_button_count;
 
-       if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_POINTER))
+       TRACE_BEGIN(pointer_notify_button);
+
+       if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_POINTER)) {
+               TRACE_END();
                return;
+       }
 
        button_event = zalloc(sizeof *button_event);
 
@@ -2655,6 +2683,8 @@ pointer_notify_button(struct libinput_device *device,
        post_device_event(device, time,
                          LIBINPUT_EVENT_POINTER_BUTTON,
                          &button_event->base);
+
+       TRACE_END();
 }
 
 void
@@ -2735,8 +2765,12 @@ pointer_notify_axis_legacy_wheel(struct libinput_device *device,
        struct libinput_event_pointer *axis_event;
        const struct wheel_v120 zero_v120 = {0};
 
-       if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_POINTER))
+       TRACE_BEGIN(pointer_notify_axis);
+
+       if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_POINTER)) {
+               TRACE_END();
                return;
+       }
 
        axis_event = zalloc(sizeof *axis_event);
 
@@ -2752,6 +2786,8 @@ pointer_notify_axis_legacy_wheel(struct libinput_device *device,
        post_device_event(device, time,
                          LIBINPUT_EVENT_POINTER_AXIS,
                          &axis_event->base);
+
+       TRACE_END();
 }
 
 void
@@ -2796,8 +2832,12 @@ touch_notify_touch_down(struct libinput_device *device,
 {
        struct libinput_event_touch *touch_event;
 
-       if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_TOUCH))
+       TRACE_BEGIN(touch_notify_touch_down);
+
+       if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_TOUCH)) {
+               TRACE_END();
                return;
+       }
 
        touch_event = zalloc(sizeof *touch_event);
 
@@ -2813,6 +2853,8 @@ touch_notify_touch_down(struct libinput_device *device,
        post_device_event(device, time,
                          LIBINPUT_EVENT_TOUCH_DOWN,
                          &touch_event->base);
+
+       TRACE_END();
 }
 
 void
@@ -2826,8 +2868,12 @@ touch_notify_touch_motion(struct libinput_device *device,
 {
        struct libinput_event_touch *touch_event;
 
-       if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_TOUCH))
+       TRACE_BEGIN(touch_notify_touch_motion);
+
+       if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_TOUCH)) {
+               TRACE_END();
                return;
+       }
 
        touch_event = zalloc(sizeof *touch_event);
 
@@ -2843,6 +2889,8 @@ touch_notify_touch_motion(struct libinput_device *device,
        post_device_event(device, time,
                          LIBINPUT_EVENT_TOUCH_MOTION,
                          &touch_event->base);
+
+       TRACE_END();
 }
 
 void
@@ -2853,8 +2901,12 @@ touch_notify_touch_up(struct libinput_device *device,
 {
        struct libinput_event_touch *touch_event;
 
-       if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_TOUCH))
+       TRACE_BEGIN(touch_notify_touch_up);
+
+       if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_TOUCH)) {
+               TRACE_END();
                return;
+       }
 
        touch_event = zalloc(sizeof *touch_event);
 
@@ -2867,6 +2919,8 @@ touch_notify_touch_up(struct libinput_device *device,
        post_device_event(device, time,
                          LIBINPUT_EVENT_TOUCH_UP,
                          &touch_event->base);
+
+       TRACE_END();
 }
 
 void