From nobody Tue Apr 25 09:21:58 2023 X-Original-To: dev-commits-src-all@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 4Q5GjL75XSz46vcy; Tue, 25 Apr 2023 09:21:58 +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 4Q5GjL5wtvz3sFr; Tue, 25 Apr 2023 09:21:58 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1682414518; 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=i0vp1K/ASFjLSByqehs9Wc2fKBhZWUlHybHlEXRQQqc=; b=Fc5jAnrKPatjGWRtPZXhJcnL3RraDYqZ4YgxgDfn4NK4P238Eb143FquvllSRun4x6GuKG IrsBGn0Cjzr2W0UgPqUg7N02PkdwajG3cHdpFuNHUlc9EHF6KTC6LHlwWzrvnLKKrs/hCW 6qwf34zS8sLLZqpXG+tt79ItsZFTEBCZsHbi+THoXwT685pxWdi/UUit3fnIFRgCsuQCBF R1nhNRwZCVOrgGdWdGnS5yyUSYd3+QEEmpJvRdsPHvcKJE5MSsqWECqLis42oenrJTelnO wnRAWh0WSt2Ri935QlpHHUFP3WmQJnBpxYDDtlkFocVO2QjY9O4LbObFFdWxpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1682414518; 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=i0vp1K/ASFjLSByqehs9Wc2fKBhZWUlHybHlEXRQQqc=; b=Ao/+0m4cXDlwwoOYPP9c4AebcoZRxM01rArJ2j3kUUSzDtUHU6b5E9y+EfbQ/eaAbBUhAl 8kgWdvKPHG8aUnrQ8lSeZCnXgtMVVkDDjKkIpJo8dqxmIo5sd57ZYjuxCfmdodKgPlgFEn bufUzVuB9pXr9YmQ6AifUWDS6i5aSIci54JZRnpw0BlKcJGAweVCrREfLjYuuWxuY/I/AY u+o5ps8w6D9egQ1CwU6Py6mrGFZhNO/ZaS8n/umfwsgMhNythQzRHRzHOGVXbD/xM7cs/q 4sJSWrPQ3rLszXX36W4UrWdj7hxO13+uCfFyfrc3gg8TDhEZHnXjsS75iSbt3Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1682414518; a=rsa-sha256; cv=none; b=Sv4gGnu1zKEQ8JPovLUHdviyrWCM4k6BV06UIhXnM6HvQ7wTlTL/XZqPhww3GXaC1KVpW0 hPsOBxjYRXswHCGYC5AMS/oklFsROZHhhDBLMq3EmsYT0NW3CXy9UESBSRy8/q1QW66HNd eksXl741pLs4D/esmCwegAUx/SNMwLd0m9tuWQXbDv5ctjll15LPsV0q4aAdHuRRe/Ar+I Q0oVt1IFYlTQHjlA/z0XImtiY0Uxvzg7gPqNPaSJaebKyP4pmrToiP60ROtuDINxU2gybv RKZ4pQ4QDrpSr3bzpUGrZ9rqb+AZ8JxYrgywmjFDIYxcrEfm3qk1w2it66lynA== 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 4Q5GjL524wz11g3; Tue, 25 Apr 2023 09:21:58 +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 33P9LwHN030617; Tue, 25 Apr 2023 09:21:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 33P9LwV4030616; Tue, 25 Apr 2023 09:21:58 GMT (envelope-from git) Date: Tue, 25 Apr 2023 09:21:58 GMT Message-Id: <202304250921.33P9LwV4030616@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: 19c804b74f67 - main - bcm5974(4): Make Magic Trackpad 2 support endian-safe. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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: 19c804b74f67b08aad6315c0f47839d56e52caa5 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=19c804b74f67b08aad6315c0f47839d56e52caa5 commit 19c804b74f67b08aad6315c0f47839d56e52caa5 Author: Vladimir Kondratyev AuthorDate: 2023-04-25 09:20:53 +0000 Commit: Vladimir Kondratyev CommitDate: 2023-04-25 09:20:53 +0000 bcm5974(4): Make Magic Trackpad 2 support endian-safe. While here make touch orientation event matching with Linux MFC after: 1 month --- sys/dev/hid/bcm5974.c | 37 +++++++++++++------------------------ 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/sys/dev/hid/bcm5974.c b/sys/dev/hid/bcm5974.c index dc0edc8dd27d..b403aa115523 100644 --- a/sys/dev/hid/bcm5974.c +++ b/sys/dev/hid/bcm5974.c @@ -167,23 +167,11 @@ struct tp_finger_compact { uint8_t touch_minor; uint8_t size; uint8_t pressure; - unsigned int orientation: 3; - unsigned int _unknown1: 1; - unsigned int id: 4; + uint8_t id_ori; } __packed; _Static_assert((sizeof(struct tp_finger_compact) == 9), "tp_finger struct size must be 9"); -union tp_finger_compact_coords { - uint32_t num; - struct { - signed int x: 13; - signed int y: 13; - signed int _unknown: 4; - signed int state: 2; - } __packed; -}; - /* trackpad finger structure - little endian */ struct tp_finger { uint16_t origin; /* zero when switching track finger */ @@ -381,8 +369,7 @@ static const struct bcm5974_dev_params bcm5974_dev_params[BCM5974_FLAG_MAX] = { .w = { SN_WIDTH, 0, 2048, 0 }, .x = { SN_COORD, -3678, 3934, 48 }, .y = { SN_COORD, -2478, 2587, 44 }, - .o = { SN_ORIENT, - -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION, 0 }, + .o = { SN_ORIENT, -3, 4, 0 }, }, }; @@ -744,7 +731,7 @@ bcm5974_intr(void *context, void *data, hid_size_t len) union evdev_mt_slot slot_data; struct tp_finger *f; struct tp_finger_compact *fc; - union tp_finger_compact_coords coords; + int coords; int ntouch; /* the finger number in touch */ int ibt; /* button status */ int i; @@ -768,24 +755,26 @@ bcm5974_intr(void *context, void *data, hid_size_t len) if ((params->tp->caps & USES_COMPACT_REPORT) != 0) { fc = (struct tp_finger_compact *)(((uint8_t *)data) + params->tp->offset + params->tp->delta + i * fsize); - coords.num = le32toh(fc->coords); + coords = (int)le32toh(fc->coords); DPRINTFN(BCM5974_LLEVEL_INFO, "[%d]ibt=%d, taps=%d, x=%5d, y=%5d, state=%4d, " "tchmaj=%4d, tchmin=%4d, size=%4d, pressure=%4d, " "ot=%4x, id=%4x\n", - i, ibt, ntouch, coords.x, coords.y, - fc->state, fc->touch_major, fc->touch_minor, fc->size, - fc->pressure, fc->orientation, fc->id); + i, ibt, ntouch, coords << 19 >> 19, + coords << 6 >> 19, (u_int)coords >> 30, + fc->touch_major, fc->touch_minor, fc->size, + fc->pressure, fc->id_ori >> 5, fc->id_ori & 0x0f); if (fc->touch_major == 0) continue; slot_data = (union evdev_mt_slot) { - .id = fc->id, - .x = coords.x, - .y = params->y.min + params->y.max - coords.y, + .id = fc->id_ori & 0x0f, + .x = coords << 19 >> 19, + .y = params->y.min + params->y.max - + ((coords << 6) >> 19), .p = fc->pressure, .maj = fc->touch_major << 2, .min = fc->touch_minor << 2, - .ori = -fc->orientation, + .ori = (int)(fc->id_ori >> 5) - 4, }; evdev_mt_push_slot(sc->sc_evdev, slot, &slot_data); slot++;