From patchwork Mon Oct 30 11:47:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 739254 Delivered-To: patch@linaro.org Received: by 2002:a5d:4c47:0:b0:32d:baff:b0ca with SMTP id n7csp1069751wrt; Mon, 30 Oct 2023 04:49:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHDTk8scycFwd2LSGUH1NSPdHNSlUOJjFQ4lKdWcSpGwDk/oY+htHepONxWKTOxQZ+ACLW/ X-Received: by 2002:a05:622a:587:b0:41e:1dff:bed5 with SMTP id c7-20020a05622a058700b0041e1dffbed5mr11429449qtb.37.1698666594688; Mon, 30 Oct 2023 04:49:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698666594; cv=none; d=google.com; s=arc-20160816; b=q1AZ+6qP7JcnqjyjJ3Lq2RzeHDELkOXPU2vIZqOW0uPmzF8WPJT/UAQa+gA0Y7ujr3 aOZqb6JLxHRAJD7slMTQEdWLT1gaWjwvWhtM7lCnXbMoATRWmo/IYSblbzA56Lb15r/0 atFlCtRD5Tr1TxdCEk/pA+6VUdhnKoeGu5SElvIn96UJq320wBHMmcYhdkJ6wf0q8rUG QCUPNt5uAncVhRyQ3pc81SiSE+xdJZff2Q61UbuYaz0c0E1j+h2eak4rDFlAAv/qX8wd GBxxKulPnPU9AtGX0xPbjLmPvLoR9olaij27TFfZ8stLGoR6p1hreyaqUwvYJo9Afmh7 4F0w== 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:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=2pm1CVuPPnKuyid7/qwQ4aH08/PxePci45dgYY6sxK0=; fh=yUeHCMY0O7AHgYs4WRBJtcSGK81/h+/8SdmYaglLfmk=; b=tlgfK+WgYjftyCPisCmHHzN3zykZkobhwcNHFLoi6dkMxzIMU6jp+XtqUP/2bTEj2q ovKKt8Q9NF9f2DTmdKhmjjo9lL5p35vp/rVN1Cw+qVjajuKnr/ETGzZ2JVaWIL0FRwr8 FLrqUO+ruGSxud/oaMogrGJpqqxLJ3f9nX43j8RbxnqA8GksAPoYVlrXi18ZbDSPTXSg DbdQV9QkcqLb1oSKoW47xJz0t9cKS+t/mDrARm6IY02QbVmSN31DPWszGqC6ePaTSO9i 0hU0xjOn7UulqDGobW4IMm2+V1QRUB9dEGL05YZoP9zTOxtw0y8Q6YE/WfIVZVI/pTU4 ttKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tEhrO7c9; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id z6-20020ac87f86000000b00403cad59323si5504392qtj.779.2023.10.30.04.49.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 30 Oct 2023 04:49:54 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tEhrO7c9; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qxQkd-0007rK-CB; Mon, 30 Oct 2023 07:48:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qxQkb-0007or-Ds for qemu-devel@nongnu.org; Mon, 30 Oct 2023 07:48:09 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qxQkY-0007Hg-4i for qemu-devel@nongnu.org; Mon, 30 Oct 2023 07:48:09 -0400 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-32deb2809daso2759843f8f.3 for ; Mon, 30 Oct 2023 04:48:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698666484; x=1699271284; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2pm1CVuPPnKuyid7/qwQ4aH08/PxePci45dgYY6sxK0=; b=tEhrO7c9dNphMlRIKhcNdKcZoMOdCTWMqP2O4wcH0ywjf6m5uZ+jBqS/NgtmMbbCnm hOc2EpDRjsmTJNITJphCGaR1yfnYqOEYlu4J0GEH2Sxmz2kRJbgjw1n6lIuXnXa4hUYL jGdakFpUZM6hCJc73Qm/AB5qi+k60/dkUpvjggTCy79dYGMsXNY0ZmgLmaHLSyImGrZq 99mEVCjvbjQsbOOIH04UUGSmBtNSlfT8cHs9qPOsI5rSMeAexT3kYY+XjYyiF5u685Jn Y53PJ0zgdHOJtXUV9S9hNeCyZb3VrngyZv4B+8CcsdBml9EGQgD/u7L43sbpc+K40Flg gEgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698666484; x=1699271284; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2pm1CVuPPnKuyid7/qwQ4aH08/PxePci45dgYY6sxK0=; b=wxuqkH9tKPGuiSTS3IwVRPOTYB1AtJFcy0tEXXh1PcXsVCZFiIsHVLtROxvOm6SD7I OBxZjed8Pa0oCM01CXVkiO+ZF8j26IUh5AN1FkTfLc+lZQPC+896g3U9PzDrwNgBbeE5 GVyBoPDKkwVZhbYQzRKPQV4lbHkIhMYXKGXFKnZ9T2B/SySOVO5nHKlm+OYG5GOk/917 3aJVjZJ1QIHcIp9ALw4g8iy1iS6qIJBPo069U2+VX7vsTdwSXI7cagHq9/BD5ngYdUkx OVABbvQYW6juJh5phfOK7dA7V/qMnK79omYoeLfY4QDxAq51sk/kcsBJGw0Yi868W2LV XO7w== X-Gm-Message-State: AOJu0Yyb18Cu5IP1fxXMk89v2rDUUyZ05D3KMFv0KiNfKi5b6HNWO/9n s22Xh7JgfoV6eAgII031gpdfag== X-Received: by 2002:a5d:4c45:0:b0:32d:8961:d864 with SMTP id n5-20020a5d4c45000000b0032d8961d864mr6580246wrt.48.1698666484487; Mon, 30 Oct 2023 04:48:04 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id az30-20020adfe19e000000b0032f7d7ec4adsm5262268wrb.92.2023.10.30.04.48.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 04:48:04 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Kevin Wolf Subject: [PATCH v2 1/6] hw/input/stellaris_input: Rename to stellaris_gamepad Date: Mon, 30 Oct 2023 11:47:57 +0000 Message-Id: <20231030114802.3671871-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231030114802.3671871-1-peter.maydell@linaro.org> References: <20231030114802.3671871-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org This source file implements a stellaris gamepad device; rename it so that it is a closer match to the device name. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé --- include/hw/input/{gamepad.h => stellaris_gamepad.h} | 6 +++--- hw/arm/stellaris.c | 2 +- hw/input/{stellaris_input.c => stellaris_gamepad.c} | 2 +- hw/arm/Kconfig | 2 +- hw/input/Kconfig | 2 +- hw/input/meson.build | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) rename include/hw/input/{gamepad.h => stellaris_gamepad.h} (77%) rename hw/input/{stellaris_input.c => stellaris_gamepad.c} (98%) diff --git a/include/hw/input/gamepad.h b/include/hw/input/stellaris_gamepad.h similarity index 77% rename from include/hw/input/gamepad.h rename to include/hw/input/stellaris_gamepad.h index 6f6aa2406aa..23cfd3c95f3 100644 --- a/include/hw/input/gamepad.h +++ b/include/hw/input/stellaris_gamepad.h @@ -8,11 +8,11 @@ * See the COPYING file in the top-level directory. */ -#ifndef HW_INPUT_GAMEPAD_H -#define HW_INPUT_GAMEPAD_H +#ifndef HW_INPUT_STELLARIS_GAMEPAD_H +#define HW_INPUT_STELLARIS_GAMEPAD_H -/* stellaris_input.c */ +/* stellaris_gamepad.c */ void stellaris_gamepad_init(int n, qemu_irq *irq, const int *keycode); #endif diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c index aa5b0ddfaa5..96585dd7106 100644 --- a/hw/arm/stellaris.c +++ b/hw/arm/stellaris.c @@ -23,7 +23,7 @@ #include "sysemu/sysemu.h" #include "hw/arm/armv7m.h" #include "hw/char/pl011.h" -#include "hw/input/gamepad.h" +#include "hw/input/stellaris_gamepad.h" #include "hw/irq.h" #include "hw/watchdog/cmsdk-apb-watchdog.h" #include "migration/vmstate.h" diff --git a/hw/input/stellaris_input.c b/hw/input/stellaris_gamepad.c similarity index 98% rename from hw/input/stellaris_input.c rename to hw/input/stellaris_gamepad.c index e6ee5e11f1b..3bab557cab3 100644 --- a/hw/input/stellaris_input.c +++ b/hw/input/stellaris_gamepad.c @@ -8,7 +8,7 @@ */ #include "qemu/osdep.h" -#include "hw/input/gamepad.h" +#include "hw/input/stellaris_gamepad.h" #include "hw/irq.h" #include "migration/vmstate.h" #include "ui/console.h" diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig index 7e683484405..841f3131ea5 100644 --- a/hw/arm/Kconfig +++ b/hw/arm/Kconfig @@ -291,7 +291,7 @@ config STELLARIS select SSD0303 # OLED display select SSD0323 # OLED display select SSI_SD - select STELLARIS_INPUT + select STELLARIS_GAMEPAD select STELLARIS_ENET # ethernet select STELLARIS_GPTM # general purpose timer module select UNIMP diff --git a/hw/input/Kconfig b/hw/input/Kconfig index 55865bb3869..f86e98c8293 100644 --- a/hw/input/Kconfig +++ b/hw/input/Kconfig @@ -20,7 +20,7 @@ config PL050 config PS2 bool -config STELLARIS_INPUT +config STELLARIS_GAMEPAD bool config TSC2005 diff --git a/hw/input/meson.build b/hw/input/meson.build index c0d44821800..640556bbbcc 100644 --- a/hw/input/meson.build +++ b/hw/input/meson.build @@ -5,7 +5,7 @@ system_ss.add(when: 'CONFIG_LM832X', if_true: files('lm832x.c')) system_ss.add(when: 'CONFIG_PCKBD', if_true: files('pckbd.c')) system_ss.add(when: 'CONFIG_PL050', if_true: files('pl050.c')) system_ss.add(when: 'CONFIG_PS2', if_true: files('ps2.c')) -system_ss.add(when: 'CONFIG_STELLARIS_INPUT', if_true: files('stellaris_input.c')) +system_ss.add(when: 'CONFIG_STELLARIS_GAMEPAD', if_true: files('stellaris_gamepad.c')) system_ss.add(when: 'CONFIG_TSC2005', if_true: files('tsc2005.c')) system_ss.add(when: 'CONFIG_VIRTIO_INPUT', if_true: files('virtio-input.c')) From patchwork Mon Oct 30 11:47:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 739253 Delivered-To: patch@linaro.org Received: by 2002:a5d:4c47:0:b0:32d:baff:b0ca with SMTP id n7csp1069732wrt; Mon, 30 Oct 2023 04:49:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGYNYZN9isOiB72COb10SLsxuXm5fshw8P2iogEe4FF8YpT5YC7k6m18Uy7pmW+c8IsxZ4H X-Received: by 2002:a05:620a:6648:b0:779:859a:5ef8 with SMTP id qg8-20020a05620a664800b00779859a5ef8mr6880877qkn.31.1698666591958; Mon, 30 Oct 2023 04:49:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698666591; cv=none; d=google.com; s=arc-20160816; b=BXxQ5L4voRyZ2B/mNXu3PJAdqFcmUExDIrg/MivrCwZ50k/RkQQ8a6ZTuHEL8oBQeY VE8izPV5JavKdcT/yeCULkWlBPniFYxmez63x9pGbLlEyuLL/UEQ9IeioaahYiWXZPAG BZLIeAl+jwwNZkD81JDcwKclK7Zrv8MEhtp/gUOJWUMgFZCDiyIr70qFq3k+nj3BW3P3 wMs+Dngq84Sr7Va65QHyegsqLm4Tj+xsKbPDolRvpRW/46Cb8QODcNpn70XFZC+9NIdq P5t0rOsHwHzEJST/bKhtcIIO8+F4vkbYEnHo9unOmWV/g4vUeu0lb/E4mzaJfmDdu4eT U0lw== 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:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=HM5kf1X1PshRtDfKLySq1ZWkBYTJpS76AaPWoI9OvsM=; fh=yUeHCMY0O7AHgYs4WRBJtcSGK81/h+/8SdmYaglLfmk=; b=JCbWDhtrCKx3iU1dQW5PGN0EZTH9VIMuxJjeIuYNrBB3evmGR3v2gJFQjmnADXmQ6w 6a9SiQlBFRC9xUx+9a2MqMCscfcbK9tg0yHlP3PaKEaA1DgBHjkSCrpTMJ6IvXBed+YM aep4guzXuiIWtv0OyUhWyByyoMia+T5obAUocK3iZLHEvYSTQBZT6471zLQ8eaakVftB 5kAZ54QxAuKAdlfWJ/ppymQRQty/hZs4WJblmPWDihSzfRK/2i85p0eeu7PA5y0XgRaA 5JYp7UjXkLuFYacLR16SZtB3qa05c6sF9H8QTrAiYhoepu2KgS56jU5iqji83gvHiWK1 C2pQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OsxxYqej; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id f13-20020a37ad0d000000b00767cc0f9316si5274592qkm.289.2023.10.30.04.49.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 30 Oct 2023 04:49:51 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OsxxYqej; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qxQke-0007tK-Ma; Mon, 30 Oct 2023 07:48:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qxQkb-0007os-Fa for qemu-devel@nongnu.org; Mon, 30 Oct 2023 07:48:09 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qxQkY-0007Hq-AT for qemu-devel@nongnu.org; Mon, 30 Oct 2023 07:48:09 -0400 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-313e742a787so2503472f8f.1 for ; Mon, 30 Oct 2023 04:48:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698666485; x=1699271285; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HM5kf1X1PshRtDfKLySq1ZWkBYTJpS76AaPWoI9OvsM=; b=OsxxYqejjxHeMWeXkRwLv8vm3vIFqDXmxMK9KZKmeM2iKb/xJR23QR/jj0rDTxzyRG 9tzdOZWQQJh5lsIzwVOq32tCs5KTMoGEgQAGcVKv67w1ga1x8/UQL8YUBth0G8kw9Qtr hsYy00ktXxDPzKkbhjA7OHJJXij0HBfOkcBO0jUPem30kaZN3iXWRUe0bX2c2RjKrq8j HoJsWOI3De1emoG8egdwnFnZFQf/a6TigD1p0v16S+PHt0L9YiDRSk1oqA+Xa4HWHHL5 qKAbcdHMVVc9fR7UomjcVqYQFpSSqawAr7Qp4Di8u59tbPrgnInbsHHfB5PyWXD6FnqO TSqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698666485; x=1699271285; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HM5kf1X1PshRtDfKLySq1ZWkBYTJpS76AaPWoI9OvsM=; b=ZXVnZFiemzAte9fi86teopQqdgUcfSdZU0KkCErK6IgP/oXHzvSNiD9+Bl1Og11ca1 +RNasz2U5J3PRP607/UKUCCSeZPGYZ4ZyOMDkNTnjgo4MZGi6y6Z4wmYGPbGJxOvD0Ex yNkCZWqR+Wt1zXkhHIRiZISdnLg/bk7Xx+I1letAOGExmUCZmd4isYze8p5Boh484lON SijH5fwyr/asFpJvAC6ikAA29qdxnn8HzuagmXsUfFbO3LikMPWeCmlbfRAvXlBGoX5x d0vpkdoawhQVC+cke2FeSNl3dlEBi4Y0e3w8Y5C0MQAkXl1wgBCFLyInAV4vvjKzg+X+ ScTw== X-Gm-Message-State: AOJu0Yxtxn2vPvFtJCGOuwpl2eqonrWsSReKh6ggzr/OWSou8cRZ5Vwz HV58VPaDNWTw66BfBOX5QyqpsSEL3KWHhUjZ7ck= X-Received: by 2002:a05:6000:1544:b0:32f:803e:3a06 with SMTP id 4-20020a056000154400b0032f803e3a06mr5273549wry.7.1698666484943; Mon, 30 Oct 2023 04:48:04 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id az30-20020adfe19e000000b0032f7d7ec4adsm5262268wrb.92.2023.10.30.04.48.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 04:48:04 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Kevin Wolf Subject: [PATCH v2 2/6] hw/input/stellaris_gamepad: Rename structs to our usual convention Date: Mon, 30 Oct 2023 11:47:58 +0000 Message-Id: <20231030114802.3671871-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231030114802.3671871-1-peter.maydell@linaro.org> References: <20231030114802.3671871-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x433.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Rename the structs in stellaris_gamepad.c to our now-standard CamelCase convention. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé --- hw/input/stellaris_gamepad.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/hw/input/stellaris_gamepad.c b/hw/input/stellaris_gamepad.c index 3bab557cab3..377101a4035 100644 --- a/hw/input/stellaris_gamepad.c +++ b/hw/input/stellaris_gamepad.c @@ -17,17 +17,17 @@ typedef struct { qemu_irq irq; int keycode; uint8_t pressed; -} gamepad_button; +} StellarisGamepadButton; typedef struct { - gamepad_button *buttons; + StellarisGamepadButton *buttons; int num_buttons; int extension; -} gamepad_state; +} StellarisGamepad; static void stellaris_gamepad_put_key(void * opaque, int keycode) { - gamepad_state *s = (gamepad_state *)opaque; + StellarisGamepad *s = (StellarisGamepad *)opaque; int i; int down; @@ -55,7 +55,7 @@ static const VMStateDescription vmstate_stellaris_button = { .version_id = 0, .minimum_version_id = 0, .fields = (VMStateField[]) { - VMSTATE_UINT8(pressed, gamepad_button), + VMSTATE_UINT8(pressed, StellarisGamepadButton), VMSTATE_END_OF_LIST() } }; @@ -65,11 +65,11 @@ static const VMStateDescription vmstate_stellaris_gamepad = { .version_id = 2, .minimum_version_id = 2, .fields = (VMStateField[]) { - VMSTATE_INT32(extension, gamepad_state), - VMSTATE_STRUCT_VARRAY_POINTER_INT32(buttons, gamepad_state, + VMSTATE_INT32(extension, StellarisGamepad), + VMSTATE_STRUCT_VARRAY_POINTER_INT32(buttons, StellarisGamepad, num_buttons, vmstate_stellaris_button, - gamepad_button), + StellarisGamepadButton), VMSTATE_END_OF_LIST() } }; @@ -77,11 +77,11 @@ static const VMStateDescription vmstate_stellaris_gamepad = { /* Returns an array of 5 output slots. */ void stellaris_gamepad_init(int n, qemu_irq *irq, const int *keycode) { - gamepad_state *s; + StellarisGamepad *s; int i; - s = g_new0(gamepad_state, 1); - s->buttons = g_new0(gamepad_button, n); + s = g_new0(StellarisGamepad, 1); + s->buttons = g_new0(StellarisGamepadButton, n); for (i = 0; i < n; i++) { s->buttons[i].irq = irq[i]; s->buttons[i].keycode = keycode[i]; From patchwork Mon Oct 30 11:47:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 739256 Delivered-To: patch@linaro.org Received: by 2002:a5d:4c47:0:b0:32d:baff:b0ca with SMTP id n7csp1069814wrt; Mon, 30 Oct 2023 04:50:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH+S40cEeoZnGftdL55vsypeXr+/99YJNs0MOv9GJTe/LJZQGosCODGQQEBMs9tyP/pB/IV X-Received: by 2002:a81:9252:0:b0:5af:7330:9f1e with SMTP id j79-20020a819252000000b005af73309f1emr6836033ywg.28.1698666604421; Mon, 30 Oct 2023 04:50:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698666604; cv=none; d=google.com; s=arc-20160816; b=vo4hs2YCJQ53+E2NoAe2wLhcevq0bxoaMp8r2UpSHaw0VKllGSe/89RNkPiRPcYQor Uxu1urXvBzg8qDmhznkGLXRXTe5QKaxpzOSJXSsarfOHE2xPj6zCzKC4/4/oo4EjmjO1 4dC9fkgl7D1vjWQbc4BRk1PNRw8gaOvT20S/dwLYce7P2NreYF+HsVhv/4DhwtfwrpaE tGqm7sHS7NKfoTcdX6bXr6RwRUZZ3BV9cM3rjtcqRl+QyX+oQK2KIFap0H6lmkulT16C 7XINjnESHnk7iD/856dixTpPEnHbCIcdI3mb4cjpcn0UbiPZDKCl6WcEJIDBWkhtP14z sGcQ== 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:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=VDC5J/pIZ/iFxlh4YAZWUq7F2Xchn9VZbC5ohU+C9is=; fh=yUeHCMY0O7AHgYs4WRBJtcSGK81/h+/8SdmYaglLfmk=; b=BUsalWD4xYlAJwMaiekRKRPPbUgwuDbde28tFiETvajboGZYEX+sLQemK6Lahu6kpu oDF+Jq0f0giPWkLhIhHgZjKl70aXX/MNJxmXgLXQr+vk9bdNBaj5NG67ckQZB5+fAkXF ElR3jrolCKpPNpqkQSu4dQ45G9ZzGEj/VmfEJHm0OvwMVcmr9usBpB/TXksV4ckshcuF x7pOB6N38lAI6rIelO+7UCFR4IGFY8yL/BBQEiA9W3WC5rVYSK0TDl1BXxBUOlCy8BDJ BqxZ5tfkWmHSjNkfM0+UxahCXLZ0fSk1d0SwOAUcfSRg5s3g/QJYRGvxKCW8U8dtwaHT M0bQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qokPl5ib; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id kr20-20020a0562142b9400b0065af7163b61si5613928qvb.82.2023.10.30.04.50.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 30 Oct 2023 04:50:04 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qokPl5ib; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qxQkh-0007vq-AS; Mon, 30 Oct 2023 07:48:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qxQkd-0007rb-2U for qemu-devel@nongnu.org; Mon, 30 Oct 2023 07:48:11 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qxQkZ-0007I0-GZ for qemu-devel@nongnu.org; Mon, 30 Oct 2023 07:48:10 -0400 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-32f737deedfso1886229f8f.3 for ; Mon, 30 Oct 2023 04:48:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698666485; x=1699271285; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=VDC5J/pIZ/iFxlh4YAZWUq7F2Xchn9VZbC5ohU+C9is=; b=qokPl5ib17X73BeYe2v3FmQyUQgbI/LoKG/kwrq5D98pYbamGZAq1tjjtu/fjSMcio jKOyILx36WqBr0EsIltNVmTE2eYwgk3is57CK6nd945GcZfKpYrzTFV1IGo/5T/yG73m /6A5eMk3YsQNyEP2phAoitQTCh0fGa9nCapqph+tcbfpCvAwMdBQMvUnoExL6puHAlxc 1dwMIANbZuJCBeXKtJyMYnDyJxN2Lc5CO30Akba2xWs1i4DIBh6X09E1yZq/451yL9HK 3EUV2einoBEm/pxXxiWGf3fCft/N+T9nocGDB0RV+T5eQW0GeqFIHyAulo3rOZ0kGsi2 pTLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698666485; x=1699271285; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VDC5J/pIZ/iFxlh4YAZWUq7F2Xchn9VZbC5ohU+C9is=; b=Iqv1p7rI9dRAJBV8lK/Wb5omKDCTVlrx3Z0WXy+snu/DiXCZf0cQDx34cQWj3mEty9 SZY/EJ2Dxt+EAamQXjiW21IraC4cB9/7o5h3m7lRsHR9vCphs+72KuI3na7j2Qe1gIrk 3y63tnOVkO+iQUNH073OYls9mM2SjTYl76PWeX/6waE6u8HKeH4RMNqOQP1bddNSlBMK 1w3zlcrq/WFxrWdlOI4v20yerZRIFdU7z7CvmCdxffMkBqHO1kgAq6O4eC7y/gkurOA3 ZqEXTq0xgPOLiOtaTL28UlOqIWAWQBBiEtRh5lYKQB1nZvoMbNts/NPI84qqVzkXXY4/ Amlw== X-Gm-Message-State: AOJu0YwdlQzss/Re22B96sKXCVzoH+gfZ2GM9yO408PGBH4ZFH2TrKkc 3bq3xjslWrUOShTAWlexZicL1A== X-Received: by 2002:a5d:6d0d:0:b0:32f:7d60:d62e with SMTP id e13-20020a5d6d0d000000b0032f7d60d62emr6754847wrq.27.1698666485590; Mon, 30 Oct 2023 04:48:05 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id az30-20020adfe19e000000b0032f7d7ec4adsm5262268wrb.92.2023.10.30.04.48.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 04:48:05 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Kevin Wolf Subject: [PATCH v2 3/6] qdev: Add qdev_prop_set_array() Date: Mon, 30 Oct 2023 11:47:59 +0000 Message-Id: <20231030114802.3671871-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231030114802.3671871-1-peter.maydell@linaro.org> References: <20231030114802.3671871-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x433.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Kevin Wolf Instead of exposing the ugly hack of how we represent arrays in qdev (a static "foo-len" property and after it is set, dynamically created "foo[i]" properties) to boards, add an interface that allows setting the whole array at once. Once all internal users of devices with array properties have been converted to use this function, we can change the implementation to move away from this hack. Signed-off-by: Kevin Wolf Reviewed-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Peter Maydell Tested-by: Philippe Mathieu-Daudé --- include/hw/qdev-properties.h | 3 +++ hw/core/qdev-properties.c | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h index e1df08876c6..7fa2fdb7c94 100644 --- a/include/hw/qdev-properties.h +++ b/include/hw/qdev-properties.h @@ -206,6 +206,9 @@ void qdev_prop_set_macaddr(DeviceState *dev, const char *name, const uint8_t *value); void qdev_prop_set_enum(DeviceState *dev, const char *name, int value); +/* Takes ownership of @values */ +void qdev_prop_set_array(DeviceState *dev, const char *name, QList *values); + void *object_field_prop_ptr(Object *obj, Property *prop); void qdev_prop_register_global(GlobalProperty *prop); diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index 357b8761b54..950ef48e013 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -3,12 +3,14 @@ #include "qapi/error.h" #include "qapi/qapi-types-misc.h" #include "qapi/qmp/qerror.h" +#include "qapi/qmp/qlist.h" #include "qemu/ctype.h" #include "qemu/error-report.h" #include "qapi/visitor.h" #include "qemu/units.h" #include "qemu/cutils.h" #include "qdev-prop-internal.h" +#include "qom/qom-qobject.h" void qdev_prop_set_after_realize(DeviceState *dev, const char *name, Error **errp) @@ -739,6 +741,25 @@ void qdev_prop_set_enum(DeviceState *dev, const char *name, int value) &error_abort); } +void qdev_prop_set_array(DeviceState *dev, const char *name, QList *values) +{ + const QListEntry *entry; + g_autofree char *prop_len = g_strdup_printf("len-%s", name); + uint32_t i = 0; + + object_property_set_int(OBJECT(dev), prop_len, qlist_size(values), + &error_abort); + + QLIST_FOREACH_ENTRY(values, entry) { + g_autofree char *prop_idx = g_strdup_printf("%s[%u]", name, i); + object_property_set_qobject(OBJECT(dev), prop_idx, entry->value, + &error_abort); + i++; + } + + qobject_unref(values); +} + static GPtrArray *global_props(void) { static GPtrArray *gp; From patchwork Mon Oct 30 11:48:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 739255 Delivered-To: patch@linaro.org Received: by 2002:a5d:4c47:0:b0:32d:baff:b0ca with SMTP id n7csp1069752wrt; Mon, 30 Oct 2023 04:49:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFVa3sdTeCkenaHjqU6nyuPgBW6BMCCnUgjdYzTlxGdUlJmaeu+I5K4Aq9Zuy7BfhrY5M+y X-Received: by 2002:a05:620a:170d:b0:774:3742:31e4 with SMTP id az13-20020a05620a170d00b00774374231e4mr11261831qkb.52.1698666594703; Mon, 30 Oct 2023 04:49:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698666594; cv=none; d=google.com; s=arc-20160816; b=e2SAKeg4hDw6f7+ygrkUz6tU8UwsQ7wU62LST9PcP38aGz9bm9F1fhkcp84lBeqzp2 PnaPcZl7pJojmnwfKhlxNJIic5xZOrT1VoZKw6SJqUP0BDylZxHhM+4Qa+Lo9/wXjUNE nJZCvZCdaMeGhysxNUAlXyarGsQhL02ewU26vJIEx+VVkvES5ReVZkV7sxH6zwT92oJk frnwPmMvxr6A04Cu7ey0Uco1n4DPi13DEQadGmLxsB1YU+lXLQIa+0XY7r99HX7L0uJz bOYZLWhbAMcjR07jn80JdVthiItIhmCDsmjLMxqOjCpAOXEztPbNExXQ8UdLCaE38tCp xFfw== 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:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=5al3BpLZU+19+hYcKcyMCCRCPorsvWdV9FoD05aiewE=; fh=yUeHCMY0O7AHgYs4WRBJtcSGK81/h+/8SdmYaglLfmk=; b=E7+HzmCSeq0JwtGdxVgGsSu2EaF34yucylkp36i5i2r8ILfyh3mSSqfb7/slng/ywp 3lbG/i7G4jD93G++xoopt8LCtIpLAitUqK7ky+SJxus3xo7WHNZeFAEvrvJxjIEap3Fc rq5JreM+xI0n2wczIW5Dx57h7AN3hOsH8AWn2xPbK7aVtX59P2OZWv9tPByfbxZtntPc iZl+tCwpu7gReNP3BgSatHosqo9+DTrf17wPeZmTQbbft66dz8ykbq86az3aJvALp2hw 0Dvy04z2hngQSSzixqWt9ROOeguSOZ+sVpfgBgz3WqpveyWUzz9oH0faNCoPHxMqmK+C g1Qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="AlgzFS/W"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id f4-20020ae9ea04000000b0076daa46b2a0si5095789qkg.87.2023.10.30.04.49.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 30 Oct 2023 04:49:54 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="AlgzFS/W"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qxQkg-0007v1-0W; Mon, 30 Oct 2023 07:48:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qxQke-0007sq-4G for qemu-devel@nongnu.org; Mon, 30 Oct 2023 07:48:12 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qxQkZ-0007IM-Sb for qemu-devel@nongnu.org; Mon, 30 Oct 2023 07:48:11 -0400 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-32db8924201so2752843f8f.1 for ; Mon, 30 Oct 2023 04:48:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698666486; x=1699271286; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5al3BpLZU+19+hYcKcyMCCRCPorsvWdV9FoD05aiewE=; b=AlgzFS/W5TtSBNAon5kIkeaqvmEqJItyqR27VabsrTRUQeOmTpdsnIrU2oAnzfn/tK 9kGkvfRVu8kLrhtDAcVHbKaaZoohPdYZB/jsGuN4x2v4I6PlkMOuYsOYb+MUqd5Padim OOtNAwAF0FA3pqwfHeqXUdkevVYVLdPPg447rgjOR73FppjB1npzb0yA8NBynUwGAutx +1KUR+rBp+jyhx2xba4OTLOGdwKBy3WpLu4xblxo+oxmw3TaLMhfxUi5OXwE52Lbj1it F5wjbKc/QN8UyRRC7dcQsafqPAhS5Y7n3IWtWVZYkXg6YK1g61DFFnPaWjipJjVaBxC9 3Bug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698666486; x=1699271286; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5al3BpLZU+19+hYcKcyMCCRCPorsvWdV9FoD05aiewE=; b=mUh2mjO/48p05iGovmK1IjaU5xTEbgYvoGKPYNnxUhOFskrUhKGe775wkcSXlQ7zqn rT+cCAURhFzz8pv8k8PtSJ1Qs7HJF7Ir/QOVKvgM5GBw9XjWnI2kv65qEIKhLoGOcZRr OSaoOGRXviwQA8Fsyqf/50CS/Jco4k1Um3pcMB5m9ffwyjmRdEwu4yEc8ID2G/eF0x74 rHnJD2+YAH+n/fy48oZ/NXrfWOOLnR0OLEzm9Uw2U1toQgCcwQCxLS3EcMzzY58Uz7lf tNj/SdKqyn/TFcQOZFIAzdQx1uI8M2OQbE//MrJGwlRd57rQLEvW/krnTotbHfzif2bc J89w== X-Gm-Message-State: AOJu0YwjcgPSMeMNTHEJLnB2pSwKoK6MlFQw3INVZsiyM7wH9poxbKsr 1OiYqfE/wF9bpkd44Mc7oNY02w== X-Received: by 2002:adf:d1ca:0:b0:32f:7967:aa4d with SMTP id b10-20020adfd1ca000000b0032f7967aa4dmr5242068wrd.68.1698666486195; Mon, 30 Oct 2023 04:48:06 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id az30-20020adfe19e000000b0032f7d7ec4adsm5262268wrb.92.2023.10.30.04.48.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 04:48:05 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Kevin Wolf Subject: [PATCH v2 4/6] hw/input/stellaris_gamepad: Remove StellarisGamepadButton struct Date: Mon, 30 Oct 2023 11:48:00 +0000 Message-Id: <20231030114802.3671871-5-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231030114802.3671871-1-peter.maydell@linaro.org> References: <20231030114802.3671871-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Currently for each button on the device we have a StellarisGamepadButton struct which has the irq, keycode and pressed state for it. When we convert to qdev, the qdev property and GPIO APIs are going to require that we have separate arrays for the irqs and keycodes. Convert from array-of-structs to three separate arrays in preparation. This is a migration compatibility break for the stellaris boards (lm3s6965evb, lm3s811evb). Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé --- v1=>v2: mention migration compat break in commit message; bump version fields in vmstate --- hw/input/stellaris_gamepad.c | 47 ++++++++++++------------------------ 1 file changed, 16 insertions(+), 31 deletions(-) diff --git a/hw/input/stellaris_gamepad.c b/hw/input/stellaris_gamepad.c index 377101a4035..82ddc47a26d 100644 --- a/hw/input/stellaris_gamepad.c +++ b/hw/input/stellaris_gamepad.c @@ -14,15 +14,11 @@ #include "ui/console.h" typedef struct { - qemu_irq irq; - int keycode; - uint8_t pressed; -} StellarisGamepadButton; - -typedef struct { - StellarisGamepadButton *buttons; - int num_buttons; + uint32_t num_buttons; int extension; + qemu_irq *irqs; + uint32_t *keycodes; + uint8_t *pressed; } StellarisGamepad; static void stellaris_gamepad_put_key(void * opaque, int keycode) @@ -40,36 +36,23 @@ static void stellaris_gamepad_put_key(void * opaque, int keycode) keycode = (keycode & 0x7f) | s->extension; for (i = 0; i < s->num_buttons; i++) { - if (s->buttons[i].keycode == keycode - && s->buttons[i].pressed != down) { - s->buttons[i].pressed = down; - qemu_set_irq(s->buttons[i].irq, down); + if (s->keycodes[i] == keycode && s->pressed[i] != down) { + s->pressed[i] = down; + qemu_set_irq(s->irqs[i], down); } } s->extension = 0; } -static const VMStateDescription vmstate_stellaris_button = { - .name = "stellaris_button", - .version_id = 0, - .minimum_version_id = 0, - .fields = (VMStateField[]) { - VMSTATE_UINT8(pressed, StellarisGamepadButton), - VMSTATE_END_OF_LIST() - } -}; - static const VMStateDescription vmstate_stellaris_gamepad = { .name = "stellaris_gamepad", - .version_id = 2, - .minimum_version_id = 2, + .version_id = 3, + .minimum_version_id = 3, .fields = (VMStateField[]) { VMSTATE_INT32(extension, StellarisGamepad), - VMSTATE_STRUCT_VARRAY_POINTER_INT32(buttons, StellarisGamepad, - num_buttons, - vmstate_stellaris_button, - StellarisGamepadButton), + VMSTATE_VARRAY_UINT32(pressed, StellarisGamepad, num_buttons, + 0, vmstate_info_uint8, uint8_t), VMSTATE_END_OF_LIST() } }; @@ -81,10 +64,12 @@ void stellaris_gamepad_init(int n, qemu_irq *irq, const int *keycode) int i; s = g_new0(StellarisGamepad, 1); - s->buttons = g_new0(StellarisGamepadButton, n); + s->irqs = g_new0(qemu_irq, n); + s->keycodes = g_new0(uint32_t, n); + s->pressed = g_new0(uint8_t, n); for (i = 0; i < n; i++) { - s->buttons[i].irq = irq[i]; - s->buttons[i].keycode = keycode[i]; + s->irqs[i] = irq[i]; + s->keycodes[i] = keycode[i]; } s->num_buttons = n; qemu_add_kbd_event_handler(stellaris_gamepad_put_key, s); From patchwork Mon Oct 30 11:48:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 739250 Delivered-To: patch@linaro.org Received: by 2002:a5d:4c47:0:b0:32d:baff:b0ca with SMTP id n7csp1069600wrt; Mon, 30 Oct 2023 04:49:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF1xdOQJWjkH2NbCu/fsBmSRdp5PQ6QAa3FrUaWBL67XWAz3oOXQLgFeudBqTbTGltfozI/ X-Received: by 2002:a05:6808:159c:b0:3ae:349:7c03 with SMTP id t28-20020a056808159c00b003ae03497c03mr12360761oiw.27.1698666566662; Mon, 30 Oct 2023 04:49:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698666566; cv=none; d=google.com; s=arc-20160816; b=L+FIhb9ZB5J7g8j/O+68Alx7nGyMn/GMrd8haxsmEL1hYGVpJUUtKnnrrB+QvnC0Im Msuu4wD3Ahq+wZmUxPUuOemM9m52srxbE/i/JJcN9xPzDt0nPL10KDAtSHdGMZzZuK82 K2BVSejW3z41kD9OO8RhwLgizthWTlNl/zD0hH/dRYmwuZ3/syGc/AgFQYhYu1nKWYQn 84N5jI/KHkT4jym9FCvOd5jrurqvN+wd2M5P8EF/bppETTrcs68Q2W49RjHRImAdmJS0 HvxjrWFnVs5K1/3g38HMxNEWnMyiZMiMyYOgsQa7HLVZjOnmDL5SjlSgfIVfjTpxYU6y 1r/A== 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:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=O90ie1atxSZ2cUPAqsKjlZB5/Uff17Peypjb2gXw96c=; fh=yUeHCMY0O7AHgYs4WRBJtcSGK81/h+/8SdmYaglLfmk=; b=fbf+LdfRHic/Ij0hhfLqDTsHmNJa6GrAe0EJT5jRDhTVsSm/8CBXA5wKdgbLlfw9Z9 Y1rAe0TDX4bHdB6pmtPcdUBgsZXdQE/is2Rlvw6AiUro8a16p33Dz5SeeD64O1ms2VVR 6mc/AdFNTpnnikRCS4C0OlrnqKZe5j/4OaXXl3x1++8HKs33dIZYgMvG0C2piJUAUbvO U6nFGpV7+VklTw14z0iwBxZLUyZKNRx1lkqVcnIJI4mT43LOo8IO+dN5KDDuJla+tx+o HZiX0gaRiVfsd91d+aQ4Wiu16LWJT6z1UJtQoMx3EeyMt9OqG9GKBnbAWwQxUhvpKEB2 c5rA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=g5Indu2F; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id bt5-20020ad455c5000000b0066d1b4ce85bsi5563230qvb.532.2023.10.30.04.49.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 30 Oct 2023 04:49:26 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=g5Indu2F; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qxQkk-0007yR-CK; Mon, 30 Oct 2023 07:48:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qxQke-0007tH-FP for qemu-devel@nongnu.org; Mon, 30 Oct 2023 07:48:12 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qxQka-0007IQ-42 for qemu-devel@nongnu.org; Mon, 30 Oct 2023 07:48:12 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-407da05f05aso33342675e9.3 for ; Mon, 30 Oct 2023 04:48:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698666486; x=1699271286; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=O90ie1atxSZ2cUPAqsKjlZB5/Uff17Peypjb2gXw96c=; b=g5Indu2F2rMHDrpc3FL6HaETtNZFlBHRBn2NKBNGLUMF/yuuXtuaQ7ka0whZWHxgHR hB7Ky2+EEYSklIogXFgV4kMY+nOPMNiVIZCCNvTzJAJSakc7wqQIVUJfRRu19qHZaQhi oBUTnCkZQNBX73AXl0KtnQ1j1MnOA7gQfUXvH2sdsjBqL18hkob88FjrDcK52dI3k7lu IE9gXW5CX5cPIuvz4gjrfCEEo6aPFCivM2eQi+fLhRa9L5OK30Yi2vN3QA1U2FtKq74M tkLJGXnMNugwbWawPs0sWmA+D/DP6XuccwV+DbKK7BKdkcJKzdeZjbSLWoSu4g/rLCi0 jD4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698666486; x=1699271286; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=O90ie1atxSZ2cUPAqsKjlZB5/Uff17Peypjb2gXw96c=; b=NQf5AeTI1i6gsF+nLuCmRR2K7O5hRZbni+3fhTcbniwTmGqXJOjGBSLCj8Pmv+EfHn yUPXpELDd1AEpDZPwE5WbQyW7nWkVs+PMKLVZK7gvZFxSu7YKqLF8MwIptSY7UFA9lzO p4hrAEEU1hMgQjatY2FHfgp2hSu1yxk4to4wwQFjrkANkrQTOEK5ssiAX92myZeIYg9S YfFuEeHtEoU/idVojOZS7xpU/Sv1aD6+kH7jsRimaw03tr0iNw0XkbwZB6yYgLrIIx2A oDI/1LxraqVTfqzQH3WMitivkH+zY3JgPwS1lU3/wMZN14JTHZUmzc+tbYn/SglUQ4r/ uUvQ== X-Gm-Message-State: AOJu0Yw+WVLTIXpmxXaEHEZbtsdZv5htPKXI6S8xeAa6FkELHRMMSMuM WqEZ7xFZDF9QD0Q2Zv+kO9dQ8A== X-Received: by 2002:adf:ec52:0:b0:32d:a405:b6b7 with SMTP id w18-20020adfec52000000b0032da405b6b7mr7479988wrn.32.1698666486672; Mon, 30 Oct 2023 04:48:06 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id az30-20020adfe19e000000b0032f7d7ec4adsm5262268wrb.92.2023.10.30.04.48.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 04:48:06 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Kevin Wolf Subject: [PATCH v2 5/6] hw/input/stellaris_input: Convert to qdev Date: Mon, 30 Oct 2023 11:48:01 +0000 Message-Id: <20231030114802.3671871-6-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231030114802.3671871-1-peter.maydell@linaro.org> References: <20231030114802.3671871-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Convert the hw/input/stellaris_input device to qdev. The interface uses an array property for the board to specify the keycodes to use, so the s->keycodes memory is now allocated by the array-property machinery. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé --- v1->v2: drop private/public comment lines --- include/hw/input/stellaris_gamepad.h | 22 ++++++++- hw/arm/stellaris.c | 26 +++++++--- hw/input/stellaris_gamepad.c | 73 +++++++++++++++++++--------- 3 files changed, 89 insertions(+), 32 deletions(-) diff --git a/include/hw/input/stellaris_gamepad.h b/include/hw/input/stellaris_gamepad.h index 23cfd3c95f3..6140b889a28 100644 --- a/include/hw/input/stellaris_gamepad.h +++ b/include/hw/input/stellaris_gamepad.h @@ -11,8 +11,26 @@ #ifndef HW_INPUT_STELLARIS_GAMEPAD_H #define HW_INPUT_STELLARIS_GAMEPAD_H +#include "hw/sysbus.h" +#include "qom/object.h" -/* stellaris_gamepad.c */ -void stellaris_gamepad_init(int n, qemu_irq *irq, const int *keycode); +/* + * QEMU interface: + * + QOM array property "keycodes": uint32_t QEMU keycodes to handle + * + unnamed GPIO outputs: one per keycode, in the same order as the + * "keycodes" array property entries; asserted when key is down + */ + +#define TYPE_STELLARIS_GAMEPAD "stellaris-gamepad" +OBJECT_DECLARE_SIMPLE_TYPE(StellarisGamepad, STELLARIS_GAMEPAD) + +struct StellarisGamepad { + SysBusDevice parent_obj; + uint32_t num_buttons; + qemu_irq *irqs; + uint32_t *keycodes; + uint8_t *pressed; + int extension; +}; #endif diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c index 96585dd7106..707b0dae375 100644 --- a/hw/arm/stellaris.c +++ b/hw/arm/stellaris.c @@ -31,6 +31,7 @@ #include "hw/timer/stellaris-gptm.h" #include "hw/qdev-clock.h" #include "qom/object.h" +#include "qapi/qmp/qlist.h" #define GPIO_A 0 #define GPIO_B 1 @@ -1274,16 +1275,27 @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) sysbus_connect_irq(SYS_BUS_DEVICE(enet), 0, qdev_get_gpio_in(nvic, 42)); } if (board->peripherals & BP_GAMEPAD) { - qemu_irq gpad_irq[5]; + QList *gpad_keycode_list = qlist_new(); static const int gpad_keycode[5] = { 0xc8, 0xd0, 0xcb, 0xcd, 0x1d }; + DeviceState *gpad; - gpad_irq[0] = qemu_irq_invert(gpio_in[GPIO_E][0]); /* up */ - gpad_irq[1] = qemu_irq_invert(gpio_in[GPIO_E][1]); /* down */ - gpad_irq[2] = qemu_irq_invert(gpio_in[GPIO_E][2]); /* left */ - gpad_irq[3] = qemu_irq_invert(gpio_in[GPIO_E][3]); /* right */ - gpad_irq[4] = qemu_irq_invert(gpio_in[GPIO_F][1]); /* select */ + gpad = qdev_new(TYPE_STELLARIS_GAMEPAD); + for (i = 0; i < ARRAY_SIZE(gpad_keycode); i++) { + qlist_append_int(gpad_keycode_list, gpad_keycode[i]); + } + qdev_prop_set_array(gpad, "keycodes", gpad_keycode_list); + sysbus_realize_and_unref(SYS_BUS_DEVICE(gpad), &error_fatal); - stellaris_gamepad_init(5, gpad_irq, gpad_keycode); + qdev_connect_gpio_out(gpad, 0, + qemu_irq_invert(gpio_in[GPIO_E][0])); /* up */ + qdev_connect_gpio_out(gpad, 1, + qemu_irq_invert(gpio_in[GPIO_E][1])); /* down */ + qdev_connect_gpio_out(gpad, 2, + qemu_irq_invert(gpio_in[GPIO_E][2])); /* left */ + qdev_connect_gpio_out(gpad, 3, + qemu_irq_invert(gpio_in[GPIO_E][3])); /* right */ + qdev_connect_gpio_out(gpad, 4, + qemu_irq_invert(gpio_in[GPIO_F][1])); /* select */ } for (i = 0; i < 7; i++) { if (board->dc4 & (1 << i)) { diff --git a/hw/input/stellaris_gamepad.c b/hw/input/stellaris_gamepad.c index 82ddc47a26d..6ccf0e80adc 100644 --- a/hw/input/stellaris_gamepad.c +++ b/hw/input/stellaris_gamepad.c @@ -8,19 +8,13 @@ */ #include "qemu/osdep.h" +#include "qapi/error.h" #include "hw/input/stellaris_gamepad.h" #include "hw/irq.h" +#include "hw/qdev-properties.h" #include "migration/vmstate.h" #include "ui/console.h" -typedef struct { - uint32_t num_buttons; - int extension; - qemu_irq *irqs; - uint32_t *keycodes; - uint8_t *pressed; -} StellarisGamepad; - static void stellaris_gamepad_put_key(void * opaque, int keycode) { StellarisGamepad *s = (StellarisGamepad *)opaque; @@ -57,22 +51,55 @@ static const VMStateDescription vmstate_stellaris_gamepad = { } }; -/* Returns an array of 5 output slots. */ -void stellaris_gamepad_init(int n, qemu_irq *irq, const int *keycode) +static void stellaris_gamepad_realize(DeviceState *dev, Error **errp) { - StellarisGamepad *s; - int i; + StellarisGamepad *s = STELLARIS_GAMEPAD(dev); - s = g_new0(StellarisGamepad, 1); - s->irqs = g_new0(qemu_irq, n); - s->keycodes = g_new0(uint32_t, n); - s->pressed = g_new0(uint8_t, n); - for (i = 0; i < n; i++) { - s->irqs[i] = irq[i]; - s->keycodes[i] = keycode[i]; + if (s->num_buttons == 0) { + error_setg(errp, "keycodes property array must be set"); + return; } - s->num_buttons = n; - qemu_add_kbd_event_handler(stellaris_gamepad_put_key, s); - vmstate_register(NULL, VMSTATE_INSTANCE_ID_ANY, - &vmstate_stellaris_gamepad, s); + + s->irqs = g_new0(qemu_irq, s->num_buttons); + s->pressed = g_new0(uint8_t, s->num_buttons); + qdev_init_gpio_out(dev, s->irqs, s->num_buttons); + qemu_add_kbd_event_handler(stellaris_gamepad_put_key, dev); } + +static void stellaris_gamepad_reset_enter(Object *obj, ResetType type) +{ + StellarisGamepad *s = STELLARIS_GAMEPAD(obj); + + memset(s->pressed, 0, s->num_buttons * sizeof(uint8_t)); +} + +static Property stellaris_gamepad_properties[] = { + DEFINE_PROP_ARRAY("keycodes", StellarisGamepad, num_buttons, + keycodes, qdev_prop_uint32, uint32_t), + DEFINE_PROP_END_OF_LIST(), +}; + +static void stellaris_gamepad_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + ResettableClass *rc = RESETTABLE_CLASS(klass); + + rc->phases.enter = stellaris_gamepad_reset_enter; + dc->realize = stellaris_gamepad_realize; + dc->vmsd = &vmstate_stellaris_gamepad; + device_class_set_props(dc, stellaris_gamepad_properties); +} + +static const TypeInfo stellaris_gamepad_info = { + .name = TYPE_STELLARIS_GAMEPAD, + .parent = TYPE_SYS_BUS_DEVICE, + .instance_size = sizeof(StellarisGamepad), + .class_init = stellaris_gamepad_class_init, +}; + +static void stellaris_gamepad_register_types(void) +{ + type_register_static(&stellaris_gamepad_info); +} + +type_init(stellaris_gamepad_register_types); From patchwork Mon Oct 30 11:48:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 739251 Delivered-To: patch@linaro.org Received: by 2002:a5d:4c47:0:b0:32d:baff:b0ca with SMTP id n7csp1069604wrt; Mon, 30 Oct 2023 04:49:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFNSv3dHA5IiCwKYPul4S4NVdp1yazBus09UogYW8AvGklHkS5AeNCbEb11cpb81R9QPxYA X-Received: by 2002:a05:620a:2948:b0:76c:a952:c70f with SMTP id n8-20020a05620a294800b0076ca952c70fmr14900793qkp.35.1698666567012; Mon, 30 Oct 2023 04:49:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698666566; cv=none; d=google.com; s=arc-20160816; b=YorNOzAQsVTbvbzfHhBJk2jBphsZC0E/xyUJHD6uPHaIJdz2AVqSvlm1YplNRQu9jW LBVmsWkZPcP9U4lwbiI4QaKJ5WCTZhxcRBIDV3S4B+KZYfVAN1LgTfRf9rdVcLiY37uc e3kNtPDdfupFp48xjMcwlrO0TgQLURZ0NuqCsPQWVZ5C/tLAFP06f/az0PPTe31DLloD dpHJ47OxzlS36ROwhkSFW/SRQmBpD11Sgy9u9KgVtgHBC2t1qU3ki3NRcZD0F9A4bxBp CwS7BFtm9PQWWn/Qp3WbDaQcXnXEyhzU/Hopyf3TyrHXgcUiMshJZqo7BaeBgaIvqdha Z8ow== 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:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=m6c0EQlNr2g65vGjJ/P+58VUOTVyE8PAYRu0/EcOt8c=; fh=yUeHCMY0O7AHgYs4WRBJtcSGK81/h+/8SdmYaglLfmk=; b=YzsRuIbkP05bseYwqSEBYPXGTM0Z89j8gL1E3vBXnzDuQbLM59JZBcr6Ui3fCMWamn xI+Sb7s0p2w/1ClF2wNBSNSw+6cmPmttS+hYU2Q1uEMNr8PQslxc4PEt0bHVYGOMeNFV vrRun+0OobX5djIvZqaq/dKIJbfxtYh8N8QFkGsegSyZdojFLc0vL9Mrxm+Lsp7+VmuS Nvm+lRd668WDvc7kRzqBFoWJng7TrauGbeO2KZF9m2XP/qAO3Oj+nxCZr6wg4/yeK1DQ uah8/Bns6roZts4vL+OEMo2IetJc6o+SyXkr3ZPsKw4BL5GS5JqUi3qxhnK2bvPlqH/g HFFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="I6m2kbS/"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id a19-20020a05620a16d300b0076db59242a1si5425117qkn.468.2023.10.30.04.49.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 30 Oct 2023 04:49:26 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="I6m2kbS/"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qxQki-0007yC-RD; Mon, 30 Oct 2023 07:48:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qxQkf-0007ue-NM for qemu-devel@nongnu.org; Mon, 30 Oct 2023 07:48:13 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qxQka-0007Il-UF for qemu-devel@nongnu.org; Mon, 30 Oct 2023 07:48:13 -0400 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-32ded3eb835so3295829f8f.0 for ; Mon, 30 Oct 2023 04:48:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698666487; x=1699271287; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=m6c0EQlNr2g65vGjJ/P+58VUOTVyE8PAYRu0/EcOt8c=; b=I6m2kbS/IYypfIqt/ni5t94khWZMBhgNyY5TT0/qjH/0l6xnZ+CKW3x2uiAvgYi9EK wa/dVc8PtR1sRdIFMClxs6uPuZ24/mM71CzLa51wu/KE8EeZjC9uN+SvCNI/nWOKEc8Y acQmDN4VvPkK3Eu3caqGXMNFNNkMlQaUxB2OBTpCPsbWO22MBaS7XmTS74+q9mrJIq8Q flT57waeRa6LAhfmNQOgY4K/s5KyFyuVITORm1VwI2Dp7xTj6yEgKq3/EWfIuRzEKdwa spq7Zi+VSwQY8XBnnuaiTKbyaiC39ze0PngjigxILU5R2VJcQ5bn6TzL4yRkAvnz8Lxp 23jA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698666487; x=1699271287; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=m6c0EQlNr2g65vGjJ/P+58VUOTVyE8PAYRu0/EcOt8c=; b=SXNqbYVfRpha0OHjz6YOAa0xZaS8fUZGp1VNuEBMhwg98LxqkAmipVWQpc221VpwX2 NdiThO1kEmMZ5GLAscZz9uUo+fDj8GzpC8o4qJ0FjZA01zGKKbope7deq1AZLqyKYmkQ aHUqJmoi0od1O0K3sLpQ4mIW5RPEkVvxdxmLs7GZb15LeeO/27HMlD89EMwRH7cU0xlz n7L/87a1+KQxSh2vjDnkJTt/QzaLzuMyUbiD/vh3bcj9QlKsEwei5SbUeW0UZde87C+M qi6hgAxX0ANCrt1wAKYGGiy0AD2ZXQUWGO1Hc9GXoFeQn57oxbTB3eIhh+VyoKOV6+f5 NrvQ== X-Gm-Message-State: AOJu0YxZosEaxN1G+C3n3rhfC9ep/MzmpPUxF7yIMQWzQb/ewCxnwXhP 7HWT+3CD+4VPe2kj7VV0Wqa1JsI/i9ScfC1nlyQ= X-Received: by 2002:a05:6000:186c:b0:32f:7b59:c3a4 with SMTP id d12-20020a056000186c00b0032f7b59c3a4mr6220607wri.32.1698666487143; Mon, 30 Oct 2023 04:48:07 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id az30-20020adfe19e000000b0032f7d7ec4adsm5262268wrb.92.2023.10.30.04.48.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 04:48:06 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Kevin Wolf Subject: [PATCH v2 6/6] hw/input/stellaris_gamepad: Convert to qemu_input_handler_register() Date: Mon, 30 Oct 2023 11:48:02 +0000 Message-Id: <20231030114802.3671871-7-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231030114802.3671871-1-peter.maydell@linaro.org> References: <20231030114802.3671871-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Now that we have converted to qdev, we can use the newer qemu_input_handler_register() API rather than the legacy qemu_add_kbd_event_handler(). Since we only have one user, take the opportunity to convert from scancodes to QCodes, rather than using qemu_input_key_value_to_scancode() (which adds an 0xe0 prefix and encodes up/down indication in the scancode, which our old handler function then had to reverse). That lets us drop the old state field which was tracking whether we were halfway through a two-byte scancode. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé --- v1->v2: bump vmstate version number again mark QemuInputHandler struct as const --- include/hw/input/stellaris_gamepad.h | 2 +- hw/arm/stellaris.c | 6 ++++- hw/input/stellaris_gamepad.c | 37 +++++++++++++--------------- 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/include/hw/input/stellaris_gamepad.h b/include/hw/input/stellaris_gamepad.h index 6140b889a28..b0c66a35531 100644 --- a/include/hw/input/stellaris_gamepad.h +++ b/include/hw/input/stellaris_gamepad.h @@ -17,6 +17,7 @@ /* * QEMU interface: * + QOM array property "keycodes": uint32_t QEMU keycodes to handle + * (these are QCodes, ie the Q_KEY_* values) * + unnamed GPIO outputs: one per keycode, in the same order as the * "keycodes" array property entries; asserted when key is down */ @@ -30,7 +31,6 @@ struct StellarisGamepad { qemu_irq *irqs; uint32_t *keycodes; uint8_t *pressed; - int extension; }; #endif diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c index 707b0dae375..dd90f686bfa 100644 --- a/hw/arm/stellaris.c +++ b/hw/arm/stellaris.c @@ -32,6 +32,7 @@ #include "hw/qdev-clock.h" #include "qom/object.h" #include "qapi/qmp/qlist.h" +#include "ui/input.h" #define GPIO_A 0 #define GPIO_B 1 @@ -1276,7 +1277,10 @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) } if (board->peripherals & BP_GAMEPAD) { QList *gpad_keycode_list = qlist_new(); - static const int gpad_keycode[5] = { 0xc8, 0xd0, 0xcb, 0xcd, 0x1d }; + static const int gpad_keycode[5] = { + Q_KEY_CODE_UP, Q_KEY_CODE_DOWN, Q_KEY_CODE_LEFT, + Q_KEY_CODE_RIGHT, Q_KEY_CODE_CTRL, + }; DeviceState *gpad; gpad = qdev_new(TYPE_STELLARIS_GAMEPAD); diff --git a/hw/input/stellaris_gamepad.c b/hw/input/stellaris_gamepad.c index 6ccf0e80adc..3533becff5d 100644 --- a/hw/input/stellaris_gamepad.c +++ b/hw/input/stellaris_gamepad.c @@ -15,42 +15,39 @@ #include "migration/vmstate.h" #include "ui/console.h" -static void stellaris_gamepad_put_key(void * opaque, int keycode) +static void stellaris_gamepad_event(DeviceState *dev, QemuConsole *src, + InputEvent *evt) { - StellarisGamepad *s = (StellarisGamepad *)opaque; + StellarisGamepad *s = STELLARIS_GAMEPAD(dev); + InputKeyEvent *key = evt->u.key.data; + int qcode = qemu_input_key_value_to_qcode(key->key); int i; - int down; - - if (keycode == 0xe0 && !s->extension) { - s->extension = 0x80; - return; - } - - down = (keycode & 0x80) == 0; - keycode = (keycode & 0x7f) | s->extension; for (i = 0; i < s->num_buttons; i++) { - if (s->keycodes[i] == keycode && s->pressed[i] != down) { - s->pressed[i] = down; - qemu_set_irq(s->irqs[i], down); + if (s->keycodes[i] == qcode && s->pressed[i] != key->down) { + s->pressed[i] = key->down; + qemu_set_irq(s->irqs[i], key->down); } } - - s->extension = 0; } static const VMStateDescription vmstate_stellaris_gamepad = { .name = "stellaris_gamepad", - .version_id = 3, - .minimum_version_id = 3, + .version_id = 4, + .minimum_version_id = 4, .fields = (VMStateField[]) { - VMSTATE_INT32(extension, StellarisGamepad), VMSTATE_VARRAY_UINT32(pressed, StellarisGamepad, num_buttons, 0, vmstate_info_uint8, uint8_t), VMSTATE_END_OF_LIST() } }; +static const QemuInputHandler stellaris_gamepad_handler = { + .name = "Stellaris Gamepad", + .mask = INPUT_EVENT_MASK_KEY, + .event = stellaris_gamepad_event, +}; + static void stellaris_gamepad_realize(DeviceState *dev, Error **errp) { StellarisGamepad *s = STELLARIS_GAMEPAD(dev); @@ -63,7 +60,7 @@ static void stellaris_gamepad_realize(DeviceState *dev, Error **errp) s->irqs = g_new0(qemu_irq, s->num_buttons); s->pressed = g_new0(uint8_t, s->num_buttons); qdev_init_gpio_out(dev, s->irqs, s->num_buttons); - qemu_add_kbd_event_handler(stellaris_gamepad_put_key, dev); + qemu_input_handler_register(dev, &stellaris_gamepad_handler); } static void stellaris_gamepad_reset_enter(Object *obj, ResetType type)