From patchwork Sun Jul 14 19:49:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 812560 Delivered-To: patch@linaro.org Received: by 2002:adf:fac3:0:b0:367:895a:4699 with SMTP id a3csp1541508wrs; Sun, 14 Jul 2024 12:50:18 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWDtGkaDZ57a7sESUkiRYMbzzSXSE3nGJtH3nkgQBe+UfcbdTiZWuVKRQHVRaCH0asCvVVqmpoj8/+mS5PKQ71/ X-Google-Smtp-Source: AGHT+IEOHBvpEcDXF+stg313EMxXOZm6uCkXtpop/Wiv3KkwBZrxLA4VxDvxSr8Z9VJ0BmEl6lqB X-Received: by 2002:a05:6512:128a:b0:52c:d76f:7f61 with SMTP id 2adb3069b0e04-52eb99d58eamr14406805e87.56.1720986618540; Sun, 14 Jul 2024 12:50:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720986618; cv=none; d=google.com; s=arc-20160816; b=Ae4/zCK4hf1zptjMz9SGOMiGoVWQ5BjjWWSjhFO8oXa3urPKLAZwjBjXFEjSaKTyi2 TPcTQoyA5Cl10Zg0nKwmTd96I/Ypz7dXEdCVB2knl+/A3z6/P33mliDX8OOuUEigNu8w m6R58VojAGpoqqTIF5D+pR2QcgMxP8MoEMnKljRA/BDlsa9aqzPEP40FvoXfHS1tnKtH sKAGT4VNRhTY71tBpzpTTT6CFTmEpnP5aI5H8qYszh5cUJ32aiBZGuPSh1eggIkFTQ/0 6sozrVe3jC402APlQJEOHLEbd91Ipgo/bqpcF4cSerGj9y2YbMGtTbatC0DZu8oqDxqo ld6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=rvSHxBLY3I0soeeO+CMW9EjW4B8Tehw4jM+stn+a8wg=; fh=kM36PmYlNpXyracI3ZIX8umvEKWcCp0VlKCQlD7DZfA=; b=LfUe9YJwsUfzPXuovrOon9CwjHlvtkUaGRdYX4RWHiCEqTn8fFBsXPcKHTZYOszpBT Cv2hjz4hZgm3w54EGoqhQI+Bb9toIm1dGpVlIBecGNUZ9S1uaw0fPud2OGzhayBd2idX dEQ4jSiHO+IeTv8CudfY2xXK2aMbEvKHScI/0x63Pp2hcrO8wDsPec6UAExhp3ewAuMT cfc7Rhr8fCGG3tHqyxSe38dLwd9VSpRhV1pN4XxVYyFfkmWCubg68qUJLqJlr9R3p4fE uVKpcZmfUy2hE6MP9Chl2Jk1G+gxoqOzPrydd+UAzkFBIHp322bYEp1HBeGmptdLE8jX 24Wg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=e9JSmO8Q; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id a640c23a62f3a-a79bc58b3c7si186097766b.77.2024.07.14.12.50.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jul 2024 12:50:18 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=e9JSmO8Q; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 57B3088168; Sun, 14 Jul 2024 21:50:17 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="e9JSmO8Q"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id F3A30883AC; Sun, 14 Jul 2024 21:50:16 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=0.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SORTED_RECIPS,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id EF2218780A for ; Sun, 14 Jul 2024 21:50:14 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=caleb.connolly@linaro.org Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-a7527afa23cso438243666b.2 for ; Sun, 14 Jul 2024 12:50:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720986614; x=1721591414; darn=lists.denx.de; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=rvSHxBLY3I0soeeO+CMW9EjW4B8Tehw4jM+stn+a8wg=; b=e9JSmO8QRlCzStbAa5RMkvhqB9zqB6lc41AshK7xXaV4iONqMSVUxx/Lg2Pj+tW1vm O0ha5NQu27veJpryzYSBtx5tmZrCK/wCd5FjBhbIQmmihk0yWlh3Zd4iSQen3Wq3bCRu OB2+XJ2V1KhDlkxnwcaVIcB4cxa1OwyBfs0u3y6OT+zr5isAvi88HMkvQeXDig85uiRG IZ65w7M25rjoZhfrHtqpwKfark3LtwTxMuo+S6l8o+haRzbn8mBFMGznDtQmTywraPMY D+VW/ii1YNYpFQaeeuEhVv4SxrkFiYXfd7nU5hShor3OmKpDBOOWSiTTkot/jMT2gHfz EMjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720986614; x=1721591414; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=rvSHxBLY3I0soeeO+CMW9EjW4B8Tehw4jM+stn+a8wg=; b=WvahMMmZNC4KGS58jtMAbe2kr7hgOqIU1oViGiE032cfE42vMcjueCEIDs/o5ZAAjS ul39jP3ZxQepqrIG9tyjY6NorNe1AECQLeIQyDcDApjrfMECmPKiSEc/KRQmDWkOoEgv xjDNpi32aLk3qgZr0v5e1kzqIJftj6lGogjEzWqvPzPOaxvrICpMQMYaNVvUIFMsbGHi EwYtugw9hTC0nUXdvv3LUeZ6tTLEwS4aXaGYMJgpJZoAz1B2q+a3BgfMqIwS3T2Ez63G ooWINAevTnYOBQA7Y3i5/N3OVxqtsCxvQpcGpGmblHw5eSs05hmCTnLISaLkjL5iDQmz 1/fQ== X-Forwarded-Encrypted: i=1; AJvYcCX8Z2oirYeI7EBNgE7cGCLo+IYzjh9EWrSlZPGGE7KItoqEGaFVlUUQsY5pMwbVO35rszjiDLqFF491tzKaJz25lXE9zg== X-Gm-Message-State: AOJu0Yyu89OEbEAbxm913HAou/bA/qkKmoZDiL2GmSgd5eFhWp6oJeYi B39zo+LwcM8JhXjdaP5X+ObF3OOx1MHeeFoRKdI8vNtD/eE5xUv8pqjx/1sW9sk= X-Received: by 2002:a17:906:27d6:b0:a72:74d5:8a9a with SMTP id a640c23a62f3a-a780b89cc52mr1185358666b.65.1720986614420; Sun, 14 Jul 2024 12:50:14 -0700 (PDT) Received: from cymric.caleb.rex.connolly.tech ([2a02:8109:aa0d:be00::7424]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a79bc820e92sm152948566b.205.2024.07.14.12.50.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jul 2024 12:50:13 -0700 (PDT) From: Caleb Connolly To: Caleb Connolly , Neil Armstrong , Quentin Schulz , Simon Glass , Sumit Garg , Tom Rini Cc: u-boot-qcom@groups.io, u-boot@lists.denx.de Subject: [PATCH] dm: button: support remapping phone keys Date: Sun, 14 Jul 2024 21:49:19 +0200 Message-ID: <20240714194948.1271135-1-caleb.connolly@linaro.org> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean We don't have audio support in U-Boot, but we do have boot menus. Add an option to re-map the volume and power buttons to up/down/enter so that in situations where these are the only available buttons (such as on mobile phones) it's still possible to navigate menus built in U-Boot or an external EFI app like GRUB or systemd-boot. Signed-off-by: Caleb Connolly Reviewed-by: Dragan Simic --- Cc: u-boot-qcom@groups.io --- drivers/button/Kconfig | 11 +++++++++++ drivers/button/button-uclass.c | 22 +++++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/drivers/button/Kconfig b/drivers/button/Kconfig index 3918b05ae03e..6cae16fcc8bf 100644 --- a/drivers/button/Kconfig +++ b/drivers/button/Kconfig @@ -8,8 +8,19 @@ config BUTTON U-Boot provides a uclass API to implement this feature. Button drivers can provide access to board-specific buttons. Use of the device tree for configuration is encouraged. +config BUTTON_REMAP_PHONE_KEYS + bool "Remap phone keys for navigation" + depends on BUTTON + help + Enable remapping of phone keys to navigation keys. This is useful for + devices with phone keys that are not used in U-Boot. The phone keys + are remapped to the following navigation keys: + - Volume up: Up + - Volume down: Down + - Power: Enter + config BUTTON_ADC bool "Button adc" depends on BUTTON depends on ADC diff --git a/drivers/button/button-uclass.c b/drivers/button/button-uclass.c index cda243389df3..729983d58701 100644 --- a/drivers/button/button-uclass.c +++ b/drivers/button/button-uclass.c @@ -9,8 +9,9 @@ #include #include #include +#include int button_get_by_label(const char *label, struct udevice **devp) { struct udevice *dev; @@ -36,16 +37,35 @@ enum button_state_t button_get_state(struct udevice *dev) return ops->get_state(dev); } +static int button_remap_phone_keys(int code) +{ + switch (code) { + case KEY_VOLUMEUP: + return KEY_UP; + case KEY_VOLUMEDOWN: + return KEY_DOWN; + case KEY_POWER: + return KEY_ENTER; + default: + return code; + } +} + int button_get_code(struct udevice *dev) { struct button_ops *ops = button_get_ops(dev); + int code; if (!ops->get_code) return -ENOSYS; - return ops->get_code(dev); + code = ops->get_code(dev); + if (CONFIG_IS_ENABLED(BUTTON_REMAP_PHONE_KEYS)) + return button_remap_phone_keys(code); + else + return code; } UCLASS_DRIVER(button) = { .id = UCLASS_BUTTON,