From patchwork Mon Apr 22 14:20:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 790961 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp2385989wrm; Mon, 22 Apr 2024 07:21:17 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVcyLUrN6aAKZ/bAjueapzIA8CtIPsEf9eMGVjgxAx2MZheZl6tQb1n2KsUHTW+q7vXrHV0W2JHTnUQkN17XMNs X-Google-Smtp-Source: AGHT+IEehanCubcZBAHOO8ADAysSNXGkkrkUFPlYmzXEdyMu/39p/pa30c65qMb6hD7p91rwJvLF X-Received: by 2002:a67:f458:0:b0:47b:b468:89d8 with SMTP id r24-20020a67f458000000b0047bb46889d8mr11902332vsn.2.1713795676870; Mon, 22 Apr 2024 07:21:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713795676; cv=none; d=google.com; s=arc-20160816; b=ubr55REU4P4yWQ8O3FA0H7+AoM/+L4R5dqIHtBR/iw75I/3dFbU4zMKCrHROQYCOWe kxksvxpBxelV9LOtyq2xrqACKO62AjpR+KvrCGsxP0JTQQ9hjI6m1dTrM64STooCAzEC hvxZ9obpYfPl/Onl8IfCNdDX0H32juOGyKihBSUsLHwGH/6lqUa27er4HJ1vvWXoepj1 LDu6KGnxljItx2YDTMuGnUMUKtKGsxT45RuPLXvaGhFR26FQjv63c+ITotKpYpw51d2N HRsPrHvEEIhuPzEIWmM40Fw29cgEcuBWNH2y3g192mbDjXmYQNemfwd91Aq+PW1lH6SE mjXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=4YWpEqod8VkCFbiBd1V4s0E6yoxlRHNnLW4c6hmROsc=; fh=BXj+w4afM6fNltuY8NGkONBfKYf/0fiMC2tBS46+ud4=; b=eJ8+WDrWcMfMdf8WiQNt9asYMudEEjrNG6pmOu8H7mVoRYJjTRYUV+oweU/r2iMu8h I0gR7q1YmS51SVt/qJMyaU+YbopvSjYellXkFSOWyl0h3akndAtGqtJUb6QQcR9n8jxB KQ6pOUb030xDt7RzIuTKe+i1vemyLIFMjcnAr/MpNdqrrUHvpF1SijNoiRdQEwCOf2wM 0R8tMPr840XaRrKhemjhcG+Nsj/XyDSiaAAhLtR8wOk8jtIhEC+wQjwIdz1TW0FNKDUn MOjuTzslZhoTlP3Yo8HPHYmZM1NSMkaW+zIl1DQTbjYuhtbfbuFFdbs+0CbREXjcwE9I xLqw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dWMQoMbw; 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 j14-20020a056102000e00b00479d5b7fc74si1527830vsp.101.2024.04.22.07.21.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Apr 2024 07:21:16 -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=dWMQoMbw; 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 1ryuXW-0002Xp-Tg; Mon, 22 Apr 2024 10:21:02 -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 1ryuXV-0002X6-PR for qemu-devel@nongnu.org; Mon, 22 Apr 2024 10:21:01 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ryuXU-0007Qm-6F for qemu-devel@nongnu.org; Mon, 22 Apr 2024 10:21:01 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-41a7aa24c4fso4515435e9.1 for ; Mon, 22 Apr 2024 07:20:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713795658; x=1714400458; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=4YWpEqod8VkCFbiBd1V4s0E6yoxlRHNnLW4c6hmROsc=; b=dWMQoMbwzZa4d3nnHKFYsgpu8FK+LhZIW5O7Kue8JYgFqB7PkvtAULewFzfzIN5ytO YMaLn+c1A2W6VsDPS8OeggWTutHItLfe5gqSV5ECzMRrGZWcagQtHKc/7iTGR8LJUJcS 3YwYOk3EuMul84nWd4xy+fExuxbhi8isBvyeTjNPN5Ef6/ohKTP8zfAhRdSUh5K7PMpT 7lrqX6IXnVs6ySZ51/h6sG9Lik2E+zQhz0Kuavby0wH4S75/BR3qwEr/XVZ7XtRyv88z +N/NzK5X697qvFlBmDN4iYKz2AetARU3LcRiVgyNgUQRRd3LTpqJ1m0GG6bhX9asm7xY wAdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713795658; x=1714400458; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=4YWpEqod8VkCFbiBd1V4s0E6yoxlRHNnLW4c6hmROsc=; b=lwqfuJzLWZrfDQqBSQQ+ymA81+gIcYMXQcWXNZ+RTC6FIq7nG8ChY6gkVkFTPZqhVn obm2xt9QBsvHi/wa4N2S8zJaxg8LVkZlPKCZk27c3V4KD1HJ67ltHrRRuCSRPSrgQzJa SkakRzv1TBhfODbALEnld8g8HVpAt8FQcgqCCP65wxJut6wWcX3jbEkMFE7XyD9TZ/5t uKSyfIx7hs+fy/2GKApP/2e5hTBPbixiTHSXitlZqi5pPoEADzEq3FE9FWpi6CLEJRSG EVtldYIHW/bk1Ur0CQJGA5U+Dn98JU3SwDzYdAwimTG7EsuViCrZndoy1T1YlBgoeKjq X85A== X-Gm-Message-State: AOJu0YyEmDfcWsTLQsgYGNSXUwvRf2iY7OWZSyujCaijtXiy+6QVjGcm tE42WXJLhydJJDRZqZxwGhikY0WgWJoi4ul/zrRcAEvNm/rFOn9vVxQSsigBU86YnmTG/nv9vRM C X-Received: by 2002:adf:cb83:0:b0:34a:4b5b:a4a with SMTP id q3-20020adfcb83000000b0034a4b5b0a4amr6865799wrh.47.1713795658015; Mon, 22 Apr 2024 07:20:58 -0700 (PDT) Received: from m1.home (lfbn-bay-1-170-196.w83-193.abo.wanadoo.fr. [83.193.250.196]) by smtp.gmail.com with ESMTPSA id a7-20020adfeec7000000b00349cadc5024sm12161612wrp.61.2024.04.22.07.20.57 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 22 Apr 2024 07:20:57 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , "Michael S. Tsirkin" , Manos Pitsidianakis , =?utf-8?q?Philippe_Ma?= =?utf-8?q?thieu-Daud=C3=A9?= , qemu-stable@nongnu.org Subject: [PATCH v3] hw/audio/virtio-snd: Use device endianness instead of target one Date: Mon, 22 Apr 2024 16:20:56 +0200 Message-ID: <20240422142056.3023-1-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=philmd@linaro.org; helo=mail-wm1-x336.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 Since VirtIO devices can change endianness at runtime, we need to use the device endianness, not the target one. Cc: qemu-stable@nongnu.org Fixes: eb9ad377bb ("virtio-sound: handle control messages and streams") Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Manos Pitsidianakis --- v2: Use virtio_is_big_endian() v3: Remove "hw/core/cpu.h --- hw/audio/virtio-snd.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/hw/audio/virtio-snd.c b/hw/audio/virtio-snd.c index c80b58bf5d..939cd78026 100644 --- a/hw/audio/virtio-snd.c +++ b/hw/audio/virtio-snd.c @@ -24,7 +24,6 @@ #include "trace.h" #include "qapi/error.h" #include "hw/audio/virtio-snd.h" -#include "hw/core/cpu.h" #define VIRTIO_SOUND_VM_VERSION 1 #define VIRTIO_SOUND_JACK_DEFAULT 0 @@ -395,13 +394,15 @@ static uint32_t virtio_snd_get_qemu_freq(uint32_t rate) * Get QEMU Audiosystem compatible audsettings from virtio based pcm stream * params. */ -static void virtio_snd_get_qemu_audsettings(audsettings *as, +static void virtio_snd_get_qemu_audsettings(VirtIOSound *s, audsettings *as, virtio_snd_pcm_set_params *params) { + VirtIODevice *vdev = VIRTIO_DEVICE(s); + as->nchannels = MIN(AUDIO_MAX_CHANNELS, params->channels); as->fmt = virtio_snd_get_qemu_format(params->format); as->freq = virtio_snd_get_qemu_freq(params->rate); - as->endianness = target_words_bigendian() ? 1 : 0; + as->endianness = virtio_is_big_endian(vdev) ? 1 : 0; } /* @@ -464,7 +465,7 @@ static uint32_t virtio_snd_pcm_prepare(VirtIOSound *s, uint32_t stream_id) s->pcm->streams[stream_id] = stream; } - virtio_snd_get_qemu_audsettings(&as, params); + virtio_snd_get_qemu_audsettings(s, &as, params); stream->info.direction = stream_id < s->snd_conf.streams / 2 + (s->snd_conf.streams & 1) ? VIRTIO_SND_D_OUTPUT : VIRTIO_SND_D_INPUT; stream->info.hdr.hda_fn_nid = VIRTIO_SOUND_HDA_FN_NID;