Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp24336lqz; Fri, 29 Mar 2024 07:29:41 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWsN/jQ+2fDVw4I9fBiAZT/xSnwzLcOsHjXtb1pZEAcSWx/ep634Vxf13DzDs8+2CnGx+4zf//WGrns0HK642D6upQhC9oJywvq+p+2tQ== X-Google-Smtp-Source: AGHT+IFTQWv9k7rD1u3DU02oH2cslTuo7Cqz+xW5e00mfuBApdT80H80ftlJpLNnETdjBBCMZNvr X-Received: by 2002:a17:90a:dc01:b0:2a0:3e51:d671 with SMTP id i1-20020a17090adc0100b002a03e51d671mr8052723pjv.7.1711722580731; Fri, 29 Mar 2024 07:29:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711722580; cv=pass; d=google.com; s=arc-20160816; b=s5kb+oKdCVcBZ7k9alPdlq2Jaei87Urqifwl4HnJwSoswPQma1mUSAT72I9POtG77+ Hkkfj3uLVdbEXn2jsTUpeumy+VhoPs4rwiRFTbaz3REZJUE7v7aL+55MM7L9CdllccBR CZIRJv20TcdDcwHDWXHPKZmE2VrQ95aXIS1b8xn5DoVDGUPDoCUO55qE8My3zlc1/VWA Yosd94xz7mlNS1I1zTmtiL1HAu13RxhHLMSTlo/05xt9ra7J7uSn3h5khsZRWLm+QA3/ CfWEqICKT4W0DkysMY3OW0/4svn5HKyPCxt1ZFBmZoWu1YcqCcqgVUeK0mcy49FX1jTx 7OpQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=tJJ4084Y7Cig1M1W3nmw5SqKP5Hb1lYm2whg1TB/uuo=; fh=TWTyTjU6SFQTzyWjbOYv6OxpKkNnC4lPeb9vj3E1sW4=; b=UOAUD6HB5ctL9rWEWc6e4Z8OM3HzLGjM5w7WvSUECT/j0H7r3FauYhY7BMX15w1O9D faFdj0B59bIdKfT+Pj2gCTHEdFriQrDTznldGGCll3XOBSa+nQHblV7e5fvd3pAktFV9 VcKr/h7NB1R/pWye7g1zNu5Ns4+LYN+qxJ5ZUlp55vOi/5zBb3LXoD2DsqKo9GShz1AQ WTw3P2bb9FGQ5cqu9snmdqljoRkheNkY8HW4CLcNJyRPaxZHEWH5lipUxMjFh8rUh0mV R5vo2LVKycdveDzYRzgi/PonjjfSMDL3pImkLijywpebpigkDZT2bVF8XXcSnBzaTvT5 pg7w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CwjPIeqn; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-124931-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-124931-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id g8-20020a17090a4b0800b0029befba1032si3785912pjh.170.2024.03.29.07.29.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 07:29:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-124931-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CwjPIeqn; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-124931-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-124931-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 69AC8283EDF for ; Fri, 29 Mar 2024 14:29:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CB08316C61B; Fri, 29 Mar 2024 12:47:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CwjPIeqn" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E73DB14C5A5; Fri, 29 Mar 2024 12:47:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711716447; cv=none; b=VIbe3hHiDYP9crPjPULYxEpna7UFO2kNE439h+kCnkAUrIkazg2u6pYHIhYP4HsnsVeqBAeMb9QePcOP0CL4y05tynzSFNzF+Ft3LDpe+gy+7/Fk7OxyCrlYflaOiWyXviN8eK/14FdzeYpjWnH5zKV4S6T/F9tOODZiuBVXK7U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711716447; c=relaxed/simple; bh=0k5UfdUIJcVykpK7hntGJKP6a9KIgQp5eZxlwLzgd0Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PrzbND7X8Qf8ocOWdU6BXbPx4iRMi+ZpNZa6DsmgL1EWY2TODgxjngUEr6N1ifukck5I9b+yPKSK33G5MyDUQMq3P+NL292/muHGOzf1fCE+zirhPq49FaIB9FJ9vrWmgIoqsa0ebvZ5A8zfFFZLVZrmx4NYT6aP+EjE34tu1WQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CwjPIeqn; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 07EFEC43390; Fri, 29 Mar 2024 12:47:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711716446; bh=0k5UfdUIJcVykpK7hntGJKP6a9KIgQp5eZxlwLzgd0Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CwjPIeqnsctw53Gp6P60iG+h8XuE1AvpBtYwtiyCzyvgT8romQXcO/EvLjb82+Bji gmuaLyRKRjbVJEJdFRLMirwnezHu+jriW4cph+ofCjs6o048+LqMJdWUXRClQL6o7W Zs+bxsO/2I3GJcnZDjADj3gqJgjXOzBbFKuwBgHO51RP7Y3AElqeh9n+FTWkeocFRe QTSNYxsRISwqsB3GbN7wqCymGwxFpYdCRQEha174sWdl/xphU71hkrtPsvFJMty3cI ne3IFXznUEO4ZombSPSajVYpkKJshyda/LHLTj2H9Z4pgH0/E9xmC61PrOeGs/8JlR pQ9Yl3mFRx6ew== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: =?UTF-8?q?Duje=20Mihanovi=C4=87?= , Dmitry Torokhov , Sasha Levin , markuss.broks@gmail.com, linux-input@vger.kernel.org Subject: [PATCH AUTOSEL 6.1 47/52] Input: imagis - add touch key support Date: Fri, 29 Mar 2024 08:45:41 -0400 Message-ID: <20240329124605.3091273-47-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240329124605.3091273-1-sashal@kernel.org> References: <20240329124605.3091273-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.1.83 Content-Transfer-Encoding: 8bit From: Duje Mihanović [ Upstream commit 2d77f70bb7180060072b9c2406d67e4b3872af15 ] IST3032C (and possibly some other models) has touch keys. Add support for them to the imagis driver. Signed-off-by: Duje Mihanović Link: https://lore.kernel.org/r/20240306-b4-imagis-keys-v3-3-2c429afa8420@skole.hr Signed-off-by: Dmitry Torokhov Signed-off-by: Sasha Levin --- drivers/input/touchscreen/imagis.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/drivers/input/touchscreen/imagis.c b/drivers/input/touchscreen/imagis.c index fecda5cdc482b..fff13114775e0 100644 --- a/drivers/input/touchscreen/imagis.c +++ b/drivers/input/touchscreen/imagis.c @@ -34,6 +34,7 @@ #define IST3038C_AREA_MASK GENMASK(27, 24) #define IST3038C_FINGER_COUNT_MASK GENMASK(15, 12) #define IST3038C_FINGER_STATUS_MASK GENMASK(9, 0) +#define IST3032C_KEY_STATUS_MASK GENMASK(20, 16) struct imagis_properties { unsigned int interrupt_msg_cmd; @@ -41,6 +42,7 @@ struct imagis_properties { unsigned int whoami_cmd; unsigned int whoami_val; bool protocol_b; + bool touch_keys_supported; }; struct imagis_ts { @@ -49,6 +51,8 @@ struct imagis_ts { struct input_dev *input_dev; struct touchscreen_properties prop; struct regulator_bulk_data supplies[2]; + u32 keycodes[5]; + int num_keycodes; }; static int imagis_i2c_read_reg(struct imagis_ts *ts, @@ -93,7 +97,7 @@ static irqreturn_t imagis_interrupt(int irq, void *dev_id) { struct imagis_ts *ts = dev_id; u32 intr_message, finger_status; - unsigned int finger_count, finger_pressed; + unsigned int finger_count, finger_pressed, key_pressed; int i; int error; @@ -140,6 +144,12 @@ static irqreturn_t imagis_interrupt(int irq, void *dev_id) FIELD_GET(IST3038C_AREA_MASK, finger_status)); } + key_pressed = FIELD_GET(IST3032C_KEY_STATUS_MASK, intr_message); + + for (int i = 0; i < ts->num_keycodes; i++) + input_report_key(ts->input_dev, ts->keycodes[i], + key_pressed & BIT(i)); + input_mt_sync_frame(ts->input_dev); input_sync(ts->input_dev); @@ -225,6 +235,23 @@ static int imagis_init_input_dev(struct imagis_ts *ts) input_set_capability(input_dev, EV_ABS, ABS_MT_POSITION_X); input_set_capability(input_dev, EV_ABS, ABS_MT_POSITION_Y); input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, 16, 0, 0); + if (ts->tdata->touch_keys_supported) { + ts->num_keycodes = of_property_read_variable_u32_array( + ts->client->dev.of_node, "linux,keycodes", + ts->keycodes, 0, ARRAY_SIZE(ts->keycodes)); + if (ts->num_keycodes <= 0) { + ts->keycodes[0] = KEY_APPSELECT; + ts->keycodes[1] = KEY_BACK; + ts->num_keycodes = 2; + } + + input_dev->keycodemax = ts->num_keycodes; + input_dev->keycodesize = sizeof(ts->keycodes[0]); + input_dev->keycode = ts->keycodes; + } + + for (int i = 0; i < ts->num_keycodes; i++) + input_set_capability(input_dev, EV_KEY, ts->keycodes[i]); touchscreen_parse_properties(input_dev, true, &ts->prop); if (!ts->prop.max_x || !ts->prop.max_y) { @@ -366,6 +393,7 @@ static const struct imagis_properties imagis_3032c_data = { .touch_coord_cmd = IST3038C_REG_TOUCH_COORD, .whoami_cmd = IST3038C_REG_CHIPID, .whoami_val = IST3032C_WHOAMI, + .touch_keys_supported = true, }; static const struct imagis_properties imagis_3038b_data = { -- 2.43.0