From nobody Tue Mar 08 12:52:10 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 7B8E419F4205; Tue, 8 Mar 2022 12:52:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KCZwV33vdz3lTM; Tue, 8 Mar 2022 12:52:10 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646743930; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=i2Dy/GhzxHi8Y6onLUhN18G1iz9eQ72Mq9gfQuuQeBU=; b=nDdioqkXz6yDLL7luGmijYmnzTdFh9LkeBNpBh0G6j6Oz1uUNGLcxvOVjgShroiOL5aD8j 5YRJGRml9sPuYxk/CLGw1DnuLOGIwjXDWh0qZ0liwCxEHGLHI1F2wgIJfAk/pMcPf8xPLP Po/lmkq0RlSWfpfFXh4ACxERSvOjQLYABX3UzvQfoOvcUrnKHvb/ITaF/AhEMl/ayF5RdN UCpHLlCBlLNDKz8aw/QV3/Zr413AaavEuW9/1uyGOonJjlMk3ra841iVwgRA7rNy1LpLsE lKpOhilw+SsY/nSJ+65l8Kgn1vqBHtTgb5M724GE1Clh5g47HqReLzY2CtTofg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 48EEB1CF86; Tue, 8 Mar 2022 12:52:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 228CqAaX084055; Tue, 8 Mar 2022 12:52:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 228CqAqm084054; Tue, 8 Mar 2022 12:52:10 GMT (envelope-from git) Date: Tue, 8 Mar 2022 12:52:10 GMT Message-Id: <202203081252.228CqAqm084054@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Vladimir Kondratyev Subject: git: fda9ac06aaf2 - main - bcm5974(4): fix endian conversion signedness bug List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: fda9ac06aaf2a3b862f485e9690e21edb17b5824 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646743930; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=i2Dy/GhzxHi8Y6onLUhN18G1iz9eQ72Mq9gfQuuQeBU=; b=hNz/N2tuj1rR6A5ww+RXRYYoJuxsuVJetx/GaUobcpIpqQByku4w3KdlYNCzHylFe2UO2v AR9CI+3v3MheZWoOoeQcEDpRv3NxEDmkVvtZuMkz0CVhKYr/gpzpo44QiHOMJKMeNT5pGs iGJo5MctFxiuQwLrXcBbNEKSVB4XwjxnaHgqe0DPYxH5Hoz9okoSFPYHBXM+LBUd8RGIvO zdK2BFTUgh5KAZ5wgXmFIl1K2nc7wm+JT0Z8KDHqwIQvZTZzqDz+Gj4CxhftLsw+iKcYQd 3/GOznfqxu6AFW65eYrB4dq4VsKM/0x8AE7Pu7gO6TMWqfjL/doTnn8azu4AaQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1646743930; a=rsa-sha256; cv=none; b=kCjKCtJ2JSnU5yfRmN6lq1AW0YNPIPiJV1ZgxFlnX5V+i93+1v54VoG6FgrNG1pZfTRiDo gOgiyjTBxgYBqT7U2zhkUfz5vfQRIU9HMnZQQZjl3zZQkPlcKBb3vQTIHxV+32ZpvK65up WQMaHgv27cW1+OMi+KawOppwr7yIsPM2bBArBiBuuYfPIYknOjq5ZRcs51YCOuvXjOduQ0 Z+CAQeSZChY37oIibh9wMdQZTfq2Iy6QRr9CX9sltIjCu9NJySeG8/gM10ODN3J18RxS89 d2R8Jn5CmMtb47aP2nTqSXuHXGMapL3aw+7geLcMFzFespwfujW4RAlOjr4Gwg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=fda9ac06aaf2a3b862f485e9690e21edb17b5824 commit fda9ac06aaf2a3b862f485e9690e21edb17b5824 Author: Greg V AuthorDate: 2022-03-08 12:51:06 +0000 Commit: Vladimir Kondratyev CommitDate: 2022-03-08 12:51:06 +0000 bcm5974(4): fix endian conversion signedness bug This fixes wrong coordinates resulting in weird behavior. Reviewed by: wulf MFC with: 5aa839c9e2c373275091b8bf529c1311d0b84d76 Differential revision: https://reviews.freebsd.org/D34433 --- sys/dev/hid/bcm5974.c | 66 +++++++++++++++++++++++++++------------------------ 1 file changed, 35 insertions(+), 31 deletions(-) diff --git a/sys/dev/hid/bcm5974.c b/sys/dev/hid/bcm5974.c index d92c1c5c43b5..c940e022d2f1 100644 --- a/sys/dev/hid/bcm5974.c +++ b/sys/dev/hid/bcm5974.c @@ -154,22 +154,24 @@ struct tp_type_params { /* trackpad finger structure - little endian */ struct tp_finger { - int16_t origin; /* zero when switching track finger */ - int16_t abs_x; /* absolute x coodinate */ - int16_t abs_y; /* absolute y coodinate */ - int16_t rel_x; /* relative x coodinate */ - int16_t rel_y; /* relative y coodinate */ - int16_t tool_major; /* tool area, major axis */ - int16_t tool_minor; /* tool area, minor axis */ - int16_t orientation; /* 16384 when point, else 15 bit angle */ - int16_t touch_major; /* touch area, major axis */ - int16_t touch_minor; /* touch area, minor axis */ - int16_t unused[2]; /* zeros */ - int16_t pressure; /* pressure on forcetouch touchpad */ - int16_t multi; /* one finger: varies, more fingers: - * constant */ + uint16_t origin; /* zero when switching track finger */ + uint16_t abs_x; /* absolute x coodinate */ + uint16_t abs_y; /* absolute y coodinate */ + uint16_t rel_x; /* relative x coodinate */ + uint16_t rel_y; /* relative y coodinate */ + uint16_t tool_major; /* tool area, major axis */ + uint16_t tool_minor; /* tool area, minor axis */ + uint16_t orientation; /* 16384 when point, else 15 bit angle */ + uint16_t touch_major; /* touch area, major axis */ + uint16_t touch_minor; /* touch area, minor axis */ + uint16_t unused[2]; /* zeros */ + uint16_t pressure; /* pressure on forcetouch touchpad */ + uint16_t multi; /* one finger: varies, more fingers: + * constant */ } __packed; +#define BCM5974_LE2H(x) ((int32_t)(int16_t)le16toh(x)) + /* trackpad finger data size, empirically at least ten fingers */ #define MAX_FINGERS MAX_MT_SLOTS @@ -694,26 +696,28 @@ bcm5974_intr(void *context, void *data, hid_size_t len) DPRINTFN(BCM5974_LLEVEL_INFO, "[%d]ibt=%d, taps=%d, o=%4d, ax=%5d, ay=%5d, " "rx=%5d, ry=%5d, tlmaj=%4d, tlmin=%4d, ot=%4x, " - "tchmaj=%4d, tchmin=%4d, presure=%4d, m=%4x\n", - i, ibt, ntouch, le16toh(f->origin), le16toh(f->abs_x), - le16toh(f->abs_y), le16toh(f->rel_x), le16toh(f->rel_y), - le16toh(f->tool_major), le16toh(f->tool_minor), - le16toh(f->orientation), le16toh(f->touch_major), - le16toh(f->touch_minor), le16toh(f->pressure), - le16toh(f->multi)); - - if (f->touch_major == 0) + "tchmaj=%4d, tchmin=%4d, pressure=%4d, m=%4x\n", + i, ibt, ntouch, BCM5974_LE2H(f->origin), + BCM5974_LE2H(f->abs_x), BCM5974_LE2H(f->abs_y), + BCM5974_LE2H(f->rel_x), BCM5974_LE2H(f->rel_y), + BCM5974_LE2H(f->tool_major), BCM5974_LE2H(f->tool_minor), + BCM5974_LE2H(f->orientation), BCM5974_LE2H(f->touch_major), + BCM5974_LE2H(f->touch_minor), BCM5974_LE2H(f->pressure), + BCM5974_LE2H(f->multi)); + + if (BCM5974_LE2H(f->touch_major) == 0) continue; slot_data = (union evdev_mt_slot) { .id = slot, - .x = le16toh(f->abs_x), - .y = params->y.min + params->y.max - le16toh(f->abs_y), - .p = le16toh(f->pressure), - .maj = le16toh(f->touch_major) << 1, - .min = le16toh(f->touch_minor) << 1, - .w_maj = le16toh(f->tool_major) << 1, - .w_min = le16toh(f->tool_minor) << 1, - .ori = params->o.max - le16toh(f->orientation), + .x = BCM5974_LE2H(f->abs_x), + .y = params->y.min + params->y.max - + BCM5974_LE2H(f->abs_y), + .p = BCM5974_LE2H(f->pressure), + .maj = BCM5974_LE2H(f->touch_major) << 1, + .min = BCM5974_LE2H(f->touch_minor) << 1, + .w_maj = BCM5974_LE2H(f->tool_major) << 1, + .w_min = BCM5974_LE2H(f->tool_minor) << 1, + .ori = params->o.max - BCM5974_LE2H(f->orientation), }; evdev_mt_push_slot(sc->sc_evdev, slot, &slot_data); slot++;