From patchwork Sun Feb 10 10:13:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolai Kondrashov X-Patchwork-Id: 10804677 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D901417E6 for ; Sun, 10 Feb 2019 10:14:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C7A0829F4A for ; Sun, 10 Feb 2019 10:14:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BC54D29F51; Sun, 10 Feb 2019 10:14:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DFF1B29F4A for ; Sun, 10 Feb 2019 10:14:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726042AbfBJKO5 (ORCPT ); Sun, 10 Feb 2019 05:14:57 -0500 Received: from mail-lf1-f66.google.com ([209.85.167.66]:38274 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725994AbfBJKO5 (ORCPT ); Sun, 10 Feb 2019 05:14:57 -0500 Received: by mail-lf1-f66.google.com with SMTP id n15so1463956lfe.5 for ; Sun, 10 Feb 2019 02:14:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7B8Q3XJHYFZkX+3LUqYPNglwUSc3/w36EcJnFsGUeqc=; b=QZQkht8+Sply3tSWnB59DqNppYWhafogE8bSzejNUE7bo/UsqieF9D1u7M3sM5RMyI ZQwnu8pTVh2PfigGNX79inxQw6gaqBSwI14V2/2OEmT9iTQHUY6Km0x4KpzKaY/97U3s SB5p9sXaHkF1L/au2/mVCxUM3OSeQMNV7ygzExJpLjSkI6lrNfiCUdHnkis22bm6pHRA rW+NUO/PYbRglMbkCl2DTI4vHS/yU6vrGp0WSd0OhNXiyq3OhZFjqPCYeBr/TUR9r429 SIUf4EMMH80Dc2LOsYfROgFhPCMRCGxsYOwUOHfF4vURqb2qJYeHvq1qOibIP1N71Jdo kZjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7B8Q3XJHYFZkX+3LUqYPNglwUSc3/w36EcJnFsGUeqc=; b=cmbr7UAapMhP+zFvGLd8PUYNWRaeVGYFQpZMfdL4adhcQ3f75/jVyGAccHZCHeHQOD HTcLDtqoAd7UBDB8BR89FyK2N/PRR5oZoG237/l7mTGvMlqF7uBhe2uu5YOtWUEvimuw frOgCKekFW8HZoxC4BxBa1J228AA1eOWZuZABdyIW9HFHU+Xb++fqJhSsjzQSMVyxrZA wbEM2BvAkow3ytQNQWaDz/838odUwo07CR1ra3aAINH8epnnNBCD/O+0lnF7vDu5Vxsi awxReF6sM5H/KqNQv63FEIk4+gAJ7C+JgZt7mLN68qSbT5Y0YLLPXSWY7poMs4cjio4c nfgA== X-Gm-Message-State: AHQUAuaZbouO31AcYfckfd91n7VitqDKopwooJczNz3OPh1YXFYpwYZh nG/NAin/pZ14ghfhyBhwCOMciZy4WEY= X-Google-Smtp-Source: AHgI3IYyJktIW47cNDRMHxSabQXgoxUleHUGLwJi+w2NsphTeoRfiZyvyf84+man/AQHPg1T9l8K0g== X-Received: by 2002:a19:aa87:: with SMTP id t129mr19631744lfe.139.1549793694305; Sun, 10 Feb 2019 02:14:54 -0800 (PST) Received: from bard.ponomarevs.fi (88-112-122-53.elisa-laajakaista.fi. [88.112.122.53]) by smtp.gmail.com with ESMTPSA id l21-v6sm1472010ljj.48.2019.02.10.02.14.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Feb 2019 02:14:53 -0800 (PST) From: Nikolai Kondrashov To: Benjamin Tissoires Cc: Jiri Kosina , linux-input@vger.kernel.org, Nikolai Kondrashov Subject: [PATCH v2 09/23] HID: uclogic: Support fragmented high-res reports Date: Sun, 10 Feb 2019 12:13:55 +0200 Message-Id: <20190210101409.3511-10-spbnick@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190210101409.3511-1-spbnick@gmail.com> References: <20181227171625.11164-1-spbnick@gmail.com> <20190210101409.3511-1-spbnick@gmail.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Support parsing fragmented high-resolution reports in hid-uclogic to support v2 reporting protocol. Signed-off-by: Nikolai Kondrashov --- drivers/hid/hid-uclogic-core.c | 25 +++++++++++++++++++++++++ drivers/hid/hid-uclogic-params.h | 8 ++++++++ 2 files changed, 33 insertions(+) diff --git a/drivers/hid/hid-uclogic-core.c b/drivers/hid/hid-uclogic-core.c index 206642802ca5..81693183d647 100644 --- a/drivers/hid/hid-uclogic-core.c +++ b/drivers/hid/hid-uclogic-core.c @@ -265,6 +265,31 @@ static int uclogic_raw_event(struct hid_device *hdev, /* Invert the in-range bit */ data[1] ^= 0x40; } + /* + * If report contains fragmented high-resolution pen + * coordinates + */ + if (size >= 10 && params->pen.fragmented_hires) { + u8 pressure_low_byte; + u8 pressure_high_byte; + + /* Lift pressure bytes */ + pressure_low_byte = data[6]; + pressure_high_byte = data[7]; + /* + * Move Y coord to make space for high-order X + * coord byte + */ + data[6] = data[5]; + data[5] = data[4]; + /* Move high-order X coord byte */ + data[4] = data[8]; + /* Move high-order Y coord byte */ + data[7] = data[9]; + /* Place pressure bytes */ + data[8] = pressure_low_byte; + data[9] = pressure_high_byte; + } /* If we need to emulate in-range detection */ if (params->pen.inrange == UCLOGIC_PARAMS_PEN_INRANGE_NONE) { /* Set in-range bit */ diff --git a/drivers/hid/hid-uclogic-params.h b/drivers/hid/hid-uclogic-params.h index 665954d6ba57..1060f70d647d 100644 --- a/drivers/hid/hid-uclogic-params.h +++ b/drivers/hid/hid-uclogic-params.h @@ -56,6 +56,12 @@ struct uclogic_params_pen { unsigned int id; /* Type of in-range reporting, only valid if "id" is not zero */ enum uclogic_params_pen_inrange inrange; + /* + * True, if reports include fragmented high resolution coords, with + * high-order X and then Y bytes following the pressure field. + * Only valid if "id" is not zero. + */ + bool fragmented_hires; }; /* @@ -151,6 +157,7 @@ extern int uclogic_params_init(struct uclogic_params *params, ".pen.desc_size = %u\n" \ ".pen.id = %u\n" \ ".pen.inrange = %s\n" \ + ".pen.fragmented_hires = %s\n" \ ".frame.desc_ptr = %p\n" \ ".frame.desc_size = %u\n" \ ".frame.id = %u\n" \ @@ -166,6 +173,7 @@ extern int uclogic_params_init(struct uclogic_params *params, (_params)->pen.desc_size, \ (_params)->pen.id, \ uclogic_params_pen_inrange_to_str((_params)->pen.inrange), \ + ((_params)->pen.fragmented_hires ? "true" : "false"), \ (_params)->frame.desc_ptr, \ (_params)->frame.desc_size, \ (_params)->frame.id, \