From patchwork Tue Oct 17 12:22: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: 734373 Delivered-To: patch@linaro.org Received: by 2002:adf:f0cd:0:b0:32d:baff:b0ca with SMTP id x13csp449302wro; Tue, 17 Oct 2023 05:25:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHWHTYvrXhBHZcOgst91bnOYIZ5kXG+2dAE1VkAzBTJSTj2y7FIfJhBELft2Q0NDsbxV2Bo X-Received: by 2002:a05:6214:dae:b0:65b:150e:604b with SMTP id h14-20020a0562140dae00b0065b150e604bmr3102899qvh.49.1697545519370; Tue, 17 Oct 2023 05:25:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697545519; cv=none; d=google.com; s=arc-20160816; b=mHqjPMw+fpU0vNZbYFjyQJrWvLhsVF0V7ZK9j6ZATE/AX6HLPbLP1KW1xvopVmdEmn Zn4enEnn2OCEyrgwtUaMa/gfvoXGLlfNV3gqdzuSLIFLDAYDBPTun/PIynJ8MJUwPb1Q OmL7Y1rjArz+snzjBW+hJ9hRwUmLcaixbLt7tfb9NGOZ5ZlIKT6L7eyVgkLT7shgjtNl KXSpjM7qAV2ORCDaF7fuD3Aq7oHb+3h1WRK6Fp5RIXYVBksWokVB9w7zw/mcTAARMpN2 umLkK/7vMdTthwQXL+O1ojFs2bbF7v6GKyFHiNpPQirrYJKqsP2eBfKJReItReMtRDtB ZkEQ== 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:to:from :dkim-signature; bh=z+dBuj8Vl8/qNTxYaFNacqekLLopYIUokXsNr5A2Ax0=; fh=H2AmuqulvQE+T5zu97MCEUC3z9wF9NssS7895NhR/+c=; b=VhRWNlRDUxsErHd28jijzho/Z008rs2nlNJGPqxx3z3zSqgm9Vwx1aIezur1lyLlBo /JJe7cZlFiixlUlDqVIzymgJ5cylqdBPHUrcPPGuGvshfFBUNCkkW7vGJ6fCY9a9QLkB Ui2nu+NWGd9fJa4z7xy2r3ObnyGpc3Y+MmE4/pZEnPwI3ZDnlkaqOgirTFBLAKhpLSev 0qVkTwUnllXyx6gckyGWon3rhiACONlsSN1Yq9QiRF9xZG7z3x9X9ERSssI9gD3d6dXm SaoTE4Ib3+bINqGd52DZiOWA4NqKTE9xpBLmLVPArLTLYMF0ZPT3MEBOwk8yLKfU45GH U7Ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nbQemaBD; 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 mx23-20020a0562142e1700b00656262151b7si875621qvb.256.2023.10.17.05.25.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Oct 2023 05:25:19 -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=nbQemaBD; 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 1qsj6N-0006Xh-EI; Tue, 17 Oct 2023 08:23: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 1qsj6K-0006WW-Q2 for qemu-devel@nongnu.org; Tue, 17 Oct 2023 08:23:08 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qsj6I-0003uE-Rv for qemu-devel@nongnu.org; Tue, 17 Oct 2023 08:23:08 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-4056ce55e7eso54067855e9.2 for ; Tue, 17 Oct 2023 05:23:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697545385; x=1698150185; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=z+dBuj8Vl8/qNTxYaFNacqekLLopYIUokXsNr5A2Ax0=; b=nbQemaBD6mN3ypdwiDW+xa3XVsFTpTk04eumBwonl5G7MtDVWSFI2CyU4Y1N7lztN4 I/IaxgNi27qhcoHIOlqREsdpD5d7QrsOeKE5WyeX4kY4t/d2gw/ZGFR4CHqqtGv2S6hi iDt5EdctNAvWdSlvCQoYFgSNBW/0apO4qsUWVK5Od2ZGS2lRhvCFnUnt1JJDcCvxaLPe M6HPOsr3CkYH43PSzVvmBPMDaOdihYZWYVsyLgxpKgGbmmkXfZ27NDl0g7M69Fkm7Kut ZanwEgrQtZs5hx3ij2gfW/maa9bY5aoDdT3I2Kze+ZsDpkgLB18a+G7ts1Xc0b33m97G EYeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697545385; x=1698150185; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=z+dBuj8Vl8/qNTxYaFNacqekLLopYIUokXsNr5A2Ax0=; b=FUp+8fIjMYBHd48mE9WuEta/BMwKUaeb8wISNKgE9Nh5y0vVIp9gOj/otocqITbniD u00o6JaTrbf9rcW1KcRyY7YCO3n9x9yVFo1F4MY0rs+E8ffXWHUBXOjpvQutialYmiSe YUhOEhVxA4haqYDsMMB+8Z/BQynw46nmXogj97BntzNIWIsilw5mF3IlAc6kgYyuEIY+ O+NfBuTiiHikAsjCOcH61p5pSMiRtHL/y6Jx461stVYRq+6KH3FJeU8QxclMN61GiltC 2nOlTJRJ0cI8YUN7Ity8SRnKzhcK0wjqPVpatpMhhTnGofRGpI94Rzst4SfrPY4ssImm VqPw== X-Gm-Message-State: AOJu0YytBza94gdlp2W9iNnza/h0TA8aKoMa7UoQ+ENoGjb1QOd4qt8H EUc93QLNa9HuNhdv+Qu91nzV2HljcI4W3L7bhkA= X-Received: by 2002:adf:f882:0:b0:32d:9a36:b518 with SMTP id u2-20020adff882000000b0032d9a36b518mr1594160wrp.69.1697545384721; Tue, 17 Oct 2023 05:23:04 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id w17-20020a5d4b51000000b0032da4c98ab2sm1590905wrs.35.2023.10.17.05.23.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 05:23:04 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 1/6] hw/input/stellaris_input: Rename to stellaris_gamepad Date: Tue, 17 Oct 2023 13:22:57 +0100 Message-Id: <20231017122302.1692902-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231017122302.1692902-1-peter.maydell@linaro.org> References: <20231017122302.1692902-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x332.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 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é --- 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 Tue Oct 17 12:22: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: 734370 Delivered-To: patch@linaro.org Received: by 2002:adf:f0cd:0:b0:32d:baff:b0ca with SMTP id x13csp448998wro; Tue, 17 Oct 2023 05:24:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFAkm2tyq2dOxr2FzsPFY8fZBjxJvfdgh/IOdiVM2koTJpsCYlIez4ep6V0+pv5xCpt4+i+ X-Received: by 2002:a05:622a:18c:b0:418:164f:2365 with SMTP id s12-20020a05622a018c00b00418164f2365mr2244112qtw.62.1697545479234; Tue, 17 Oct 2023 05:24:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697545479; cv=none; d=google.com; s=arc-20160816; b=mM2gPy7polwhDd7Cha4bguKSzAu0NlK1EEKe0aRa4ofydcvedpeIGXyLwATRXPwjy9 mxdGsNcXH7+fb7mG3/UJFrrN765oqDRnShguaUyIk7hWI0wR+rYwhgwRFxpcjgzqPwoT yyIQprUw7VZw72LNXLDaXDb5ZNkw15BFEtYvz4IQym/nYF103gK70RXvwfiXr0sRVThE fipeDmt2teifjxn+f570V3a/me71xSWFvoePPG24ydhZh1MTPbbSzzZitymBdWg33K27 dqFD5/tmWHEG9pcsAItdv+W4kp3V39CjBoq1ezAPXtpt3kZsGffr1lf8LVc7qcZeHIXC 0AGA== 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:to:from :dkim-signature; bh=Ef3VyVefq+kXZQrOwVAifLvgHJQILqSEiKZ6PIGal1A=; fh=H2AmuqulvQE+T5zu97MCEUC3z9wF9NssS7895NhR/+c=; b=T8Rt69sujBV03sqBWtGw3T9jPIcggAgE5H1LTUgFBG59G7FkRvaiusrUqmbG3GFxF9 t7xg1hpcgbPtJWeFPwjNoEZC6FQrZzlXwy9zc45ffk6Yx9SjU50p4MCWdCobVAsCY+DY n/6HJGNw+vd7CSLKPEGjvNb5/ZOZhmYHXCIpDDEM60l4FZkKIynuRxy4UIyocA87dz3W d+MKNAdKuVVjviwZnB+YaeL/YC6dzVvq1YNxNgLfTyV3M+pmxNKqXAfxS5HdiALdAs3P hqSATIbdYP9y63kNQk4MQ+edI8wC7aD2IAZOKwN7x/uM3XH/oEYJqUjbQRSAZs9vrdbn jieQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YkXU0yo+; 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 e3-20020ac85983000000b00419ce76ad38si983837qte.76.2023.10.17.05.24.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Oct 2023 05:24:39 -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=YkXU0yo+; 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 1qsj6O-0006YM-3I; Tue, 17 Oct 2023 08:23: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 1qsj6M-0006X6-87 for qemu-devel@nongnu.org; Tue, 17 Oct 2023 08:23:10 -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 1qsj6J-0003uO-6h for qemu-devel@nongnu.org; Tue, 17 Oct 2023 08:23:09 -0400 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-31c5cac3ae2so4968249f8f.3 for ; Tue, 17 Oct 2023 05:23:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697545385; x=1698150185; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=Ef3VyVefq+kXZQrOwVAifLvgHJQILqSEiKZ6PIGal1A=; b=YkXU0yo+pd5+4KZYInlTlRE/4cGpegvjH91v/ZZlLzGbXSOk8BNjv6V5hYn/d4lzfA vRznfRCo6tKVDlmm5DqxaRC9qkqLT428Os3nd+x6k/IHcZbuCPsUtOtfgowLSoyxoJAy 5TivsW/xolRfyLJI91CI1aSW3X+xUDfuNZyvTk1a65+0x7D4n4TVy0pVewnaCxee9Yhn iA+rVSY5QkzcRqcBfCyepWP9W2G3lkKUK+zH95Ai8hMulFrsR5J1jI8kZaJ+UzVZjmdh P1Fhat6Vfzt1c/z9W/2YuloH85QuO+phU9f/9JhugCLDf7RMbdjAn8GYc7y9kQiFKfI3 XODw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697545385; x=1698150185; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ef3VyVefq+kXZQrOwVAifLvgHJQILqSEiKZ6PIGal1A=; b=oenswuRhA1wIdxv57BcyYb7vDyptHFbeiMqduRf1kYv4y+TZJc1D7LTsBlIDmuU22B Q1F02d2lAwV5F4rchw20UDtzGC0p1UrDv4GAC9QUSZh5lt6hahu6LOqmKIo85GWKHE27 hGgPixOXHDtM5KY9DPmL4BtDihtO0S2WavSBkLjPrvlC9hUIsjPo6raf/Y/iIGsTfXIo JSqNEAHsOadGdMh1eok07wBgxNVzNZ5BTgxuMDr2C5zxpo+DyhgekhI2UpCeS3NbYK2w yzEOHCPiMN+L6wLVAvKQ0hx9GTEh7403jBK9u+sdO7GcPdTFfvxmImMFNWqhWJJhvZLj ju5A== X-Gm-Message-State: AOJu0Yxv8fzaH2gzbt2/yXRL7SPNrynHqJLOT43232u5zpS47D5kxZpu zeGoPZ22Fjjajmgeg5UcGNO1nlgMQeycaOJ5dbY= X-Received: by 2002:a5d:668d:0:b0:32d:9789:6066 with SMTP id l13-20020a5d668d000000b0032d97896066mr1876964wru.5.1697545385138; Tue, 17 Oct 2023 05:23:05 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id w17-20020a5d4b51000000b0032da4c98ab2sm1590905wrs.35.2023.10.17.05.23.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 05:23:04 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 2/6] hw/input/stellaris_gamepad: Rename structs to our usual convention Date: Tue, 17 Oct 2023 13:22:58 +0100 Message-Id: <20231017122302.1692902-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231017122302.1692902-1-peter.maydell@linaro.org> References: <20231017122302.1692902-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 Rename the structs in stellaris_gamepad.c to our now-standard CamelCase convention. Signed-off-by: Peter Maydell Reviewed-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 Tue Oct 17 12:22: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: 734374 Delivered-To: patch@linaro.org Received: by 2002:adf:f0cd:0:b0:32d:baff:b0ca with SMTP id x13csp449346wro; Tue, 17 Oct 2023 05:25:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFKULz6V/7/5qOLp9PGULFO26HeDS7AHtzzqULJqq6G0bcnjgnElij4Nm3hPM0mkg3a9+wt X-Received: by 2002:a05:6102:3973:b0:452:8f88:a782 with SMTP id ho19-20020a056102397300b004528f88a782mr2041453vsb.32.1697545524733; Tue, 17 Oct 2023 05:25:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697545524; cv=none; d=google.com; s=arc-20160816; b=fSxoMrzL0m4qDdw/wACoVk/Fci0vdIuBVsoN9YpgN3Y3j2xf/TyeyiDr4qjncX70BJ OmyxNsa4DOF+y2arRBdtiKrwtzOJkH5cV0dsfQYPTt6mbDwzo7aaCa1MSOCZqH0g1QyC AOa5LEJ0OXmI3sieX0aoE1HdswO5L3pgB8tDf7APZGuFlSgbNnacS6BtHZR2yn0ck4TN /iXBd+x0ub27boDPDwh7A5gE5skKc+XbiHYjMKN0lO/merI08lq0fu45On9Zv5+sRGOH M237IyefNKmegikWCbluPODeVFeLnWm693HilMIa/l2cp32PhBTIcD6q6WIK+a9PjUOH TqNQ== 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:to:from :dkim-signature; bh=ETA1o9XFiY+ehXIdPxFRChEwkK1zNu0/OcYc52Xsbos=; fh=H2AmuqulvQE+T5zu97MCEUC3z9wF9NssS7895NhR/+c=; b=F+vqbhbMBHo96edAzMxLqO3Hbi12RVbI+yddMKvwGS3e+1/KrfV9isZ0aw9Z6wuMK8 zkJg5tlP/gxkdBIajY+MnIOkIzEhGHFdv8mRLdk07AeiFFI2YsKA1nrXFBBuDb1qcNhG UJ+RsPWW+Bcl2t+m4coVIbKEIBCHM9TMnPFyPDTKzn5PIUAfOkNSh7LE3lwyL8TRbVvF NO2StY85fJeZPcPNe/xWw/uwz9e6eOtBtzyTgzEemRDNUVnaBA+1JewIuaXZAbf7DpWk 6lekS2P8pD+cI1diSSp3V6MKay95A4/D6aH63Y+s/ZIxu6TFgtvqKjeyDqHLF7U+jB2F n2Dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kpGR2zSU; 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 h10-20020a05622a170a00b004180f8c4f04si1018986qtk.571.2023.10.17.05.25.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Oct 2023 05:25:24 -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=kpGR2zSU; 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 1qsj6R-0006Zq-JB; Tue, 17 Oct 2023 08:23: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 1qsj6N-0006Xr-L6 for qemu-devel@nongnu.org; Tue, 17 Oct 2023 08:23:11 -0400 Received: from mail-lf1-x12e.google.com ([2a00:1450:4864:20::12e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qsj6J-0003ui-Dz for qemu-devel@nongnu.org; Tue, 17 Oct 2023 08:23:11 -0400 Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-507bd64814fso863976e87.1 for ; Tue, 17 Oct 2023 05:23:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697545385; x=1698150185; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=ETA1o9XFiY+ehXIdPxFRChEwkK1zNu0/OcYc52Xsbos=; b=kpGR2zSUo+TP8poNQVX5jPs8qi7Qs+rhWPnX4WNclbTbWZqrQHfxohAQ1PX25VB+3d ohNwUePZh+0TjGvidaVAW3QivYSd+e36vC6Pl+g25tWSzyXft60m/aCy1/UWIiuA/ttt xcrYhOT1L/THKGzkKJ+yoP88IkNBUq4Ygm46bYdkQUI8Fdv+9iyMsh/WcYhxWDLFDBTG nRLxM6HDYvU2GFPT9/9OsYXM8z6Lwpuqia1zaDurgu6A4jziLxGcrr7jnXhe5afRpuSW JFjBEIZTI6sqjfkMuUgKE+IAh2FUQ8JXldPtP/R6IoZDM35sdXqO7hlC7fFpt3JOoLYT xjqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697545385; x=1698150185; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ETA1o9XFiY+ehXIdPxFRChEwkK1zNu0/OcYc52Xsbos=; b=KPQvG2knwDwbhYvAxRkUp+Swh406MqxV0nPsepwCDomsd7U57AFkb5/wYisQ2pVo2T p4qv/OekMAkjYvBK684J65jKc2gnTXXu3mX9qaLbb3voHgUbP97yspSO3cTZuE4JxuXZ 1auISojWYabyTNzEMA0iQJ/64Q7DyYJ012xqStm138EiL8FyMugBTWt9F7ntZkvq8LnB VKQbAdbL2h6yHRyhV0k0H/fcEksvZFg0BmhQybNVagXWteldp01vVdlLlpplYnb38FPt 0SGHh8/sPnwwWkxHnkLat2Ezo1D/Lj9LS+4YYsQaYEzVyI7MyAMUOSFmdfRMoI4pPLyq VmxA== X-Gm-Message-State: AOJu0YzZjd3lSXz3KUFDtdw/1wvV1cFINvjXmcZNod4rt4OROKTXzg6l SrItYoAK/UraF3OiX66oZQzRVA== X-Received: by 2002:ac2:4ac7:0:b0:507:b836:f836 with SMTP id m7-20020ac24ac7000000b00507b836f836mr1395686lfp.0.1697545385607; Tue, 17 Oct 2023 05:23:05 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id w17-20020a5d4b51000000b0032da4c98ab2sm1590905wrs.35.2023.10.17.05.23.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 05:23:05 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 3/6] qdev: Add qdev_prop_set_array() Date: Tue, 17 Oct 2023 13:22:59 +0100 Message-Id: <20231017122302.1692902-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231017122302.1692902-1-peter.maydell@linaro.org> References: <20231017122302.1692902-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::12e; envelope-from=peter.maydell@linaro.org; helo=mail-lf1-x12e.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 --- 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 Tue Oct 17 12:23: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: 734372 Delivered-To: patch@linaro.org Received: by 2002:adf:f0cd:0:b0:32d:baff:b0ca with SMTP id x13csp449266wro; Tue, 17 Oct 2023 05:25:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHwB2hoghpaKUcw+Cfwcy9toqtFDCtnGhhfNdbWnCfkMnfksqR/GUO5AtQm4+jwgUisHBem X-Received: by 2002:a05:622a:164e:b0:41b:7773:aa5b with SMTP id y14-20020a05622a164e00b0041b7773aa5bmr2263429qtj.63.1697545513927; Tue, 17 Oct 2023 05:25:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697545513; cv=none; d=google.com; s=arc-20160816; b=E9GcqRXY0+owGA3Q/DPuJo9GBrr27tOcMKfWbKDjxq3a+DW0aXnM7/YX4fh6KW5iD/ RovxDqgq8G7q0CM3gPrkD/ZkUMjb4JYGLGnlAI8onUNsmbnE69in7qAFpf63QS+EnkKJ Zk4BAgO/T+OG5coy57wzotNpYhiaqsbe0WShRMe28WFSDIViWfCtBzNk6ZESNw6MLjdm isXbcwnA7+PA4HLpdXDWfsceY5/DIBLNospjMILqRQBAzU9A/ZQBPNt9QJpk5gP9BQCr AfpjB4/LP8z3PtHqxZc3JtVBDgXJJxJNbC3uTVw1yVvo8/KOMeCBA0uY3dCXzoDKLb0K BOyQ== 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:to:from :dkim-signature; bh=rmBaCpSuRrDiGRxAI74uVjYQUdlqV4XGWEbKnwTHtmk=; fh=H2AmuqulvQE+T5zu97MCEUC3z9wF9NssS7895NhR/+c=; b=pw6FuWO+W7CvGpMTwZLQ/KmuPbhDTwUa7ZiTioTLlwPV22gNEJwUtQZnKa6rHYWV3H hdwXIAATo/phY6yQ3VB8t2H/nqBCvuzcN9h58wkhsUDImhzQHP4jWWICR/Yc7Nt6aWYy GwFe6GW/we5UHVyglY1qGfGy8gqgQoDZB/sQLfS7FNJfidxZq7VdtFemiljaMSS4m6Bv mmaBuC1IIJyJaSQCZPPtaY1jfnx5SyhGp65mio09AAeVdmtTOUWfwNCvkPYZT2Yeml72 +sn00pC4P1eReEAathKTWxY5CK75pFwpbzeq9Nob/cfFTRyVUpgcfxEvSOA3OdOcGaLz VrFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Nfcytsnc; 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 t12-20020a05622a148c00b0041822134c6asi1023965qtx.158.2023.10.17.05.25.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Oct 2023 05:25:13 -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=Nfcytsnc; 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 1qsj6P-0006Zi-OV; Tue, 17 Oct 2023 08:23:13 -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 1qsj6N-0006Xx-Pc for qemu-devel@nongnu.org; Tue, 17 Oct 2023 08:23:11 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qsj6J-0003ux-KW for qemu-devel@nongnu.org; Tue, 17 Oct 2023 08:23:11 -0400 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-323168869daso5218985f8f.2 for ; Tue, 17 Oct 2023 05:23:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697545386; x=1698150186; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=rmBaCpSuRrDiGRxAI74uVjYQUdlqV4XGWEbKnwTHtmk=; b=NfcytsncPReH7EnG7ZG/Do8owe4ZVVLdYCIuLB5CP9YDeJ4Bs9d38Z8Euf/S92fWIe mVW9vr7lxpppRhzh6xlLEsb3QVStFUEFLxsoULMNf/haf2oDD9b73rFGBuOD1hgLTYXR gLny28aL38L5B/XT+tJPCF1TgU7xenVVlzyNFce1Fg7IX0B3F/0XjLJ7C3BS3en7xmDO ejtgi6DA1LKlxL46YwDXcaN0k9fEJ/9BnIVzDFmMh6oXsIUa/bH/Ri8y4VYQDJivhcIM eLlp4EuPGtxMK/nZ0aWhzcstJZnnOuNhfMMTnkepAiN1AZGho03eE/dEeoAa85tNAWca CnDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697545386; x=1698150186; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rmBaCpSuRrDiGRxAI74uVjYQUdlqV4XGWEbKnwTHtmk=; b=FkxMQQ/aWR4w8ZADF0da5Zy5mzNw5r2PEIviGB/q/s/04iBltEPblsCX/98j4vaJZ4 n6UvVl3BMX2ARDQf7rPp+MfAPwTPqRRtn163vOJ4eQjqQWE65GjpG9+EIQU1CUfieHYi KxH07AFSkzbsPTSsQWBoPnjHDjKS1QkrJzPMFXGSNw6Ch+axboL83wMpWccF8X4ryacg y+PQ3iVruRXc8XA/LAdmd1KMFJmKbF5NDRzb/xe9rugJb1BSCwECBnEqwLLxOqoeRu71 br3hn0QCk50dW2i36iv5VYK/x6R60EAzR+8uzGxomjonihzUXo2PeBYVZ35noCu7Y2rK xAjg== X-Gm-Message-State: AOJu0Yzcx/9d3HjjkUjkk9PpRQBmQXEDuCnPLYDw3RzI3iYgdyvkWye5 X106Id3CE9ZI3/THpVO/qEzkcVDIKto3AW3osow= X-Received: by 2002:a5d:4245:0:b0:32d:aa56:c0c7 with SMTP id s5-20020a5d4245000000b0032daa56c0c7mr1781058wrr.54.1697545386281; Tue, 17 Oct 2023 05:23:06 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id w17-20020a5d4b51000000b0032da4c98ab2sm1590905wrs.35.2023.10.17.05.23.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 05:23:05 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 4/6] hw/input/stellaris_gamepad: Remove StellarisGamepadButton struct Date: Tue, 17 Oct 2023 13:23:00 +0100 Message-Id: <20231017122302.1692902-5-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231017122302.1692902-1-peter.maydell@linaro.org> References: <20231017122302.1692902-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x434.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. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé --- hw/input/stellaris_gamepad.c | 43 ++++++++++++------------------------ 1 file changed, 14 insertions(+), 29 deletions(-) diff --git a/hw/input/stellaris_gamepad.c b/hw/input/stellaris_gamepad.c index 377101a4035..da974400b59 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, .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 Tue Oct 17 12:23: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: 734369 Delivered-To: patch@linaro.org Received: by 2002:adf:f0cd:0:b0:32d:baff:b0ca with SMTP id x13csp449000wro; Tue, 17 Oct 2023 05:24:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGdjxv9sNYUmSsUvVgcjiYFvivrumikIeDPZSVecwqwl/sgCc7mYny5SzlmUMpHtdGI8wZL X-Received: by 2002:a81:48cb:0:b0:583:d8d4:7dfe with SMTP id v194-20020a8148cb000000b00583d8d47dfemr2185553ywa.31.1697545479360; Tue, 17 Oct 2023 05:24:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697545479; cv=none; d=google.com; s=arc-20160816; b=0qSa7h6o2LQasHHUELv1YZbD8DX9FfpnO2MJj/awO/CDeqKNsnPUcWdPyOtevg9Y1Y 6s4L3oJJN6m/5tKYVgr1sybX7QYjmc4+8Su4hAB/47FZ7bvbIjldPAZsAE5p5/7MUWoK cCJIx5kVpX+NXfUTxZPITITS6YooPxMaumfsA3mxUCHBIZfpiK4dnHQhChACmlie7+b6 bIMuR4mOCQMKKtnxYHh8OZPafIIn9rN0TJ7hNRVZaWQtWcuVI00rbKv3rSQQbPc3IstE P5C96JGN3GKokdjV7E94R6z1mHHXUplFjjzUIlI92C4TPP25ATks50geKF7gBywitQ1R nV1g== 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:to:from :dkim-signature; bh=sW2pyrUMoN7MAwOg+RbuKX+jV96qwsneZRNARMZQCGw=; fh=H2AmuqulvQE+T5zu97MCEUC3z9wF9NssS7895NhR/+c=; b=LuigoQxSqnTOXKVb05lzzM+Tfk/MrWA7vohVAy2wk1QIG5XhnE1KSb/iiH432oHMm5 Mm4Sw53ctQbcukUSHkmS3OjmuR6rZaxGCoqScvFJZjEcWJvPj5jy1do2N5+Nf/cc3Y1L kpUgldxGArTay/oifoVBOf0HlNkYqnYgZb5CnQwKOOX2M/tuf1p5dhgi7QxXFMOJ38sP Cc5T906+PO9IN4A1ARH11Gw2InFZ8O9TUuer8v6aF6WZ+0AUKaFQEeo6yxTjNItqBeHy xP8D3tWJFEVtrZYqX9m8rO32sf0yLONaPLNL665PDW+8w1kxcQGWzW5+QTPPLgzLmYq0 ui4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pPb6PxFd; 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 l12-20020ad44bcc000000b0066d1348bddbsi875177qvw.441.2023.10.17.05.24.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Oct 2023 05:24:39 -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=pPb6PxFd; 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 1qsj6S-0006bM-7z; Tue, 17 Oct 2023 08:23: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 1qsj6N-0006YE-Uy for qemu-devel@nongnu.org; Tue, 17 Oct 2023 08:23:11 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qsj6J-0003v7-Vz for qemu-devel@nongnu.org; Tue, 17 Oct 2023 08:23:11 -0400 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-32d569e73acso5018297f8f.1 for ; Tue, 17 Oct 2023 05:23:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697545386; x=1698150186; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=sW2pyrUMoN7MAwOg+RbuKX+jV96qwsneZRNARMZQCGw=; b=pPb6PxFdBzUrBXAkz9ChmdzdHV3CeYtxPF7FQDjOU2NhYcxh/gDI5zSCNIeG7/4GIe LTOIM3Erm6ApDd/fSluvlMegbIt53xoRn4GH9h3RNmkiHQUerhl3C5hUJZygwUgFaRkK 5eE2/YBzLdX/yRzw53AePRqPA4r6YmauncxJWSDHEf00bcDGdDCqbSeyiDu51GkZGZxJ XI52rNgqJ5jZohhl6N0Q9SuJ63IQLXLw1HWlBBI2eGkvfn77wEtHZHFy0EZdS3+keRjY npnwcO8JhWq+Ov2AdcT687gRtFfIS+9jqANiDqb0EOJydTQMKTNg498qxwCl8Ts3PZhw 8Jng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697545386; x=1698150186; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sW2pyrUMoN7MAwOg+RbuKX+jV96qwsneZRNARMZQCGw=; b=X+cY81Kx3PxxLo5wDGy1AYXo5ciIabo5Ri0qUoVaQ6chYz4/asmwlFVd1AEFQ8/z/T dnPShIH48KDZOUEYVI6Ytpq3VbiB9t5h7K9srcky+p77ZuIOsqqEQ+/WVL088Jr3k073 yOut7LwzL+y0QN4csKIjUxz6JOR14/ATYxyZtNpw224rTq86nq4MaHmMew7XqL8ft0Ti TYTVySS8h+Zo3EY1+hCW0eJM6ImjKhOeRCU2EPgfrvMKDhiGnffvYTHbLaNq/oqRK9fJ 8WK9syBO7C/+N/KdobNA2AcKFo5Ucya+lG9VwJa6MCr9cZQ2nxN6hjZ+sQ7NcbomR91o XBxA== X-Gm-Message-State: AOJu0Yy8O1pNtcyh4MIFbLAEj+eBFrn3fXgu+vlV+1dcTPYFw+/fP4oJ L9/NYWcAN9pG1VbqamrjmHDkL6/7ZBMLtl1Culc= X-Received: by 2002:a05:6000:1282:b0:32d:84a3:f3fe with SMTP id f2-20020a056000128200b0032d84a3f3femr1940788wrx.41.1697545386722; Tue, 17 Oct 2023 05:23:06 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id w17-20020a5d4b51000000b0032da4c98ab2sm1590905wrs.35.2023.10.17.05.23.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 05:23:06 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 5/6] hw/input/stellaris_input: Convert to qdev Date: Tue, 17 Oct 2023 13:23:01 +0100 Message-Id: <20231017122302.1692902-6-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231017122302.1692902-1-peter.maydell@linaro.org> References: <20231017122302.1692902-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42c.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é --- include/hw/input/stellaris_gamepad.h | 25 +++++++++- hw/arm/stellaris.c | 26 +++++++--- hw/input/stellaris_gamepad.c | 73 +++++++++++++++++++--------- 3 files changed, 92 insertions(+), 32 deletions(-) diff --git a/include/hw/input/stellaris_gamepad.h b/include/hw/input/stellaris_gamepad.h index 23cfd3c95f3..50c17041121 100644 --- a/include/hw/input/stellaris_gamepad.h +++ b/include/hw/input/stellaris_gamepad.h @@ -11,8 +11,29 @@ #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 { + /*< private >*/ + SysBusDevice parent_obj; + + /*< public >*/ + 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 da974400b59..48d37bd6275 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 Tue Oct 17 12:23: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: 734368 Delivered-To: patch@linaro.org Received: by 2002:adf:f0cd:0:b0:32d:baff:b0ca with SMTP id x13csp449001wro; Tue, 17 Oct 2023 05:24:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF07N69s0Iqpk5ulsCx/vOVuduRtrg7fC6tLaJdMj5BD4mxGAX9wbbsrfwNOEC4rx23Lzjt X-Received: by 2002:a05:6214:f26:b0:66d:1112:e870 with SMTP id iw6-20020a0562140f2600b0066d1112e870mr2859228qvb.22.1697545479413; Tue, 17 Oct 2023 05:24:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697545479; cv=none; d=google.com; s=arc-20160816; b=dytnHQYfQgUy2NYfkY4sMS1SCgVaba0pLhwvZrsEgqB5jv4rb4TGsPTqO8YnMimlyt WlJgIBbA97bj9C7HHF5U6GdPh1PNVqQE0QbVWOIlka6HALeKc8CiWtYa0t3+FJLYflyV kOjOWBMBMMZ1EdrKeeeOKs7/1Lcck0h2XhgWIhXbdSsbVWm2zpGR2DCM1ctkqMOyLPFl gTdTsDmqE6l/bMneNfgqLWw6wSoXlyb5DXVcYJpn2I0qCCOqKNJ2GEluzi1zF/i+f78M 87rPefBHaO/mknvJV9CbPlJKNx1bvaS5ndNN+9TwjQYW2OoYCavl1wElR5FvmMmqVi/U ZXnA== 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:to:from :dkim-signature; bh=X23rCmHj7vrKivIk0sTOGLiGuYEJTV79DlPVDDS4fB8=; fh=H2AmuqulvQE+T5zu97MCEUC3z9wF9NssS7895NhR/+c=; b=z0qAho1Q1jFzXhH222W98FtBq8oPKi3L+RX6c3eqq7Gf0RCOCvSRuFV18ZAQk1mJIn Z2BCVFvbwZpQxL0TqIsxRyt13/a6nLMfPuPpuCYjBlQz834A6gXpMvCOCtbm/rQpCszm w7JvpObi242PWlAlmWSV6hitls5RxnWWqYVzMa0SY3cSRxb1u+UJI1e0n6BREo50hssn absezdTzNp1JMo/QRgf4ZMHMUTLmDewpFAX5rkgukE+aokxnVf8H8npQjrxp4rT+kVIG iY3NegPfmOhBZMryQakmgSTR8d9H0YIASE0lAB/JWmCfwHenQmkzpJ6W4b+8gQPEBwHu njew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OUYC+WgY; 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 c5-20020a0cfb05000000b00649089daebasi891042qvp.237.2023.10.17.05.24.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 17 Oct 2023 05:24:39 -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=OUYC+WgY; 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 1qsj6S-0006bN-94; Tue, 17 Oct 2023 08:23: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 1qsj6P-0006ZJ-7T for qemu-devel@nongnu.org; Tue, 17 Oct 2023 08:23:13 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qsj6K-0003vK-Jx for qemu-devel@nongnu.org; Tue, 17 Oct 2023 08:23:12 -0400 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-32d895584f1so4791766f8f.1 for ; Tue, 17 Oct 2023 05:23:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697545387; x=1698150187; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=X23rCmHj7vrKivIk0sTOGLiGuYEJTV79DlPVDDS4fB8=; b=OUYC+WgYYIQaht1FSlb2CSWgKNCHrdMThNvDbUloXdVaAXki7XVF+IgfXLMHLLWyy7 u8ReWJpUBd7jBa+uiZSJfZaKUgqUoyUXGuqYDDpmZbJb2NojAS3e4jHAH0pwNNGGJMCr 9vdS3FsdqxFLVlIhOysB9wxIqX558VHWRP3+yz6kx44mWH8xSvVcSv+Qt9EUfBqWZx9c oKOOPlscC+fSyvsyzFuFWtV3y2IRdLUsVctf/SOg/57yKf29RFCztrHVav1QU7ybF72p 15wzJtl5/Yc894imlYTNJ9gLEChUr8JWUpt08sOhuv8P5hcJkpVLxIajHYW2jbD8kWCi W/wA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697545387; x=1698150187; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=X23rCmHj7vrKivIk0sTOGLiGuYEJTV79DlPVDDS4fB8=; b=d/GND+/H4MlIhViPLjkezH1+KzMvaUDIIHrjT/AYgt++hsigbBev66f025FsS5s75S y5xkZQf9gwxEm6K5ScxcIwPqGDrU77Iw2RfCGrIn9/EOTuX9h2DU+3VtS0dSt6OGLXkm l7y1qFM6H9S3pWroD04xb6tCxfaWAhlHjAR8QpnzgoMpl2wkDTK3eOrMizF7tN+AtTfn hDdUnG0FjZKQSUPUj470+Jmi1N1ob8m1GQsT43pJqTsGDQoll/72n/o9yxGCAMPgkO6S HMjqZySwYQWexIXw3RY8qoprxq0OEBo7iVPQ0quQaKyUk97IftH0mKwW7cxq/KuqY0fQ QUWQ== X-Gm-Message-State: AOJu0YzbMFrtMbY2icprBhfKq8kf4zy9fjT28rT3/kk4N+R6G0A1LsYj FXEzQWlahXLN/xWrKqaPiMHdUA== X-Received: by 2002:a5d:4528:0:b0:31c:804b:5ec3 with SMTP id j8-20020a5d4528000000b0031c804b5ec3mr1922351wra.67.1697545387116; Tue, 17 Oct 2023 05:23:07 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id w17-20020a5d4b51000000b0032da4c98ab2sm1590905wrs.35.2023.10.17.05.23.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 05:23:06 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 6/6] hw/input/stellaris_gamepad: Convert to qemu_input_handler_register() Date: Tue, 17 Oct 2023 13:23:02 +0100 Message-Id: <20231017122302.1692902-7-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231017122302.1692902-1-peter.maydell@linaro.org> References: <20231017122302.1692902-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42b; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42b.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é --- include/hw/input/stellaris_gamepad.h | 2 +- hw/arm/stellaris.c | 6 ++++- hw/input/stellaris_gamepad.c | 33 +++++++++++++--------------- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/include/hw/input/stellaris_gamepad.h b/include/hw/input/stellaris_gamepad.h index 50c17041121..979e7243fd8 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 */ @@ -33,7 +34,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 48d37bd6275..65247ecd782 100644 --- a/hw/input/stellaris_gamepad.c +++ b/hw/input/stellaris_gamepad.c @@ -15,28 +15,20 @@ #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 = { @@ -44,13 +36,18 @@ static const VMStateDescription vmstate_stellaris_gamepad = { .version_id = 2, .minimum_version_id = 2, .fields = (VMStateField[]) { - VMSTATE_INT32(extension, StellarisGamepad), VMSTATE_VARRAY_UINT32(pressed, StellarisGamepad, num_buttons, 0, vmstate_info_uint8, uint8_t), VMSTATE_END_OF_LIST() } }; +static 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)