From patchwork Mon Apr 22 13:13:55 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: 790960 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp2350928wrm; Mon, 22 Apr 2024 06:14:19 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCULlxXK/ynk4M8LGMo0FMoWaC/ifDcBD5lIxKYeqKslxP4/r5v/Vef62/Xo7gm0I86AM0JP82xT0IalT+z6VLJX X-Google-Smtp-Source: AGHT+IEa+oihPrSS0xO1nAMu2OA3Q3aD838qQbFA6Dv9efINFyAUSsJKXz6jrp6e+zjNrmuAQH9m X-Received: by 2002:a05:620a:215b:b0:78e:e09d:1e72 with SMTP id m27-20020a05620a215b00b0078ee09d1e72mr11784112qkm.52.1713791659501; Mon, 22 Apr 2024 06:14:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713791659; cv=none; d=google.com; s=arc-20160816; b=JqOA+fCGPmXMatE2dIAUY8X3w5gB+nv4aRjCxaBuG7Amr0xdEmG3NMZA3YV1Dqg1dy kCFq3knLptOCcTI3ZA/i9J4kvFXUeJnrvGHvL8rbq8gim/IutxtyU6ORHJMJ5L91vYwg w4PFGdR+X0LUy+h1GaE4qaTh2gJwd2TRPqlobN1aaIV1xNlkRxK//AbRXRIh6GBuhpZq H00xc5csdzrvxZWaMUnWdzYIOO+uGJp4pGzkg8Th77GEtsxiC6be0TwFE9uBbLqO2tJJ TMa7N7q2J1mzdU0YVdNh2DrOA3AfTtphvOo14fKcBNyvjou8ejZhKY+Sp1dUx4wsiKkB cnWQ== 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=0CfwgkjbzgYAXblJxs9gNejxswFCkLFrV38LRL8E1yU=; fh=BXj+w4afM6fNltuY8NGkONBfKYf/0fiMC2tBS46+ud4=; b=lsUWsPeJoSR5rhAfqlJL3f7nA899wsMpfY8BMXQuVPMTvgkZqP6aMtHmJwvpo+RzVW aCPskWQ7s88HzH4y+nAC6xpuzI1Q0ELu8JaU6rjYkoIIvwAIXJZ7Z4KNBE0MlKmF99Bm /zSu9UEa0BkRFfX2KJhPbFwVlmzb3l8OgXTAHE8ir14peTDqJplsQqm20wvhiHhEBtar re0x9OJ39y5V9X6d34X1RHAgYFIoFnGnIzaY033fobbQZDUGuXNRkIEzccYUhlJPMYRw fZk0oFHqLIfYetOieLzYJpZHtV/F57CrjP7itlfBuwLdAnJf0UQyGJzeJtsbUY1uN68C HEaQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="tyvl/BI7"; 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 c22-20020a05620a269600b0078d67aa06a8si11597253qkp.414.2024.04.22.06.14.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Apr 2024 06:14: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="tyvl/BI7"; 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 1rytUq-0004uG-0i; Mon, 22 Apr 2024 09:14: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 1rytUe-0004ie-P4 for qemu-devel@nongnu.org; Mon, 22 Apr 2024 09:14:02 -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 1rytUc-0002Ih-SA for qemu-devel@nongnu.org; Mon, 22 Apr 2024 09:14:00 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-41a5b68ed0aso5793795e9.2 for ; Mon, 22 Apr 2024 06:13:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713791636; x=1714396436; 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=0CfwgkjbzgYAXblJxs9gNejxswFCkLFrV38LRL8E1yU=; b=tyvl/BI70G1Xk+WD+Qk7e3MM8Qd5VggIYvW93mqBow72QiwfFIjekrCyBTYPJ7bwbm h5P1jn+hSJ17dyyrRajjoZ4/tD24/aqueYqIteJq7dHLvb1grixObvwvstmSXF2K8Mhg GctTmirbVX98fZyFCeUuM031jDapgIcPYpaFhOZcgGO7euowYGeWNNmIayi/mXnb1bxW oM6Acx4vVGWsuBpBLunwjPgn1a2MZR5x+cDwz2oVrGj8V9dK9KZTwng51SshYxawZ1nS L3ngpe6Fa3XBtOtuSgWJMi5WshMhLJFsPbARiMn5PZXFImIC9Y/QfRkGucVJTAOKsBLb 6K9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713791636; x=1714396436; 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=0CfwgkjbzgYAXblJxs9gNejxswFCkLFrV38LRL8E1yU=; b=XIllD2gL72diXSdtWjby6yi3Pix8g0W6Ic8ssU647eNifDOrOc43Ug87tRsII55t1g ye+BRFYEminhKMM4oJWbprv+flkNimP9Ziycog0v1JW28uZJdz8Xf2Tl7cdlGzpTCMDd gXrGedeT0xUYf6xzHYNsX03KKoaFc8kAIU9wrEd6LOoD/HkCqTVDRzSBfdbN/t01HQ0V kSCLjbtV98/AWB3ZBCB2s3wIXe7NDvD7DoPLh9mWF32gwYSu3LvUesLpHjCN3ykvP4Rl ovqY8bFC9Its3Acb6Qh9sz/ivSBeKIk0CeO1pC5iUg71PQgI1zjtBiTByaVRulDouPrF Nasg== X-Gm-Message-State: AOJu0Yz8+WxAi9XdtkzBu9DORqlfJ+hV4BZTtA5Cjnjyk0yk6oRuTzUd jDgZyRIkNIOwiQFYWaa2pv4KtnLXgLtWmmRUsCzgHhINfnkmptZCo9D79srp10PopkZUV7Ay52T 0 X-Received: by 2002:a05:600c:5489:b0:41a:43ae:baf2 with SMTP id iv9-20020a05600c548900b0041a43aebaf2mr2528021wmb.34.1713791636480; Mon, 22 Apr 2024 06:13:56 -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 j10-20020adfff8a000000b0034335f13570sm11917566wrr.116.2024.04.22.06.13.55 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 22 Apr 2024 06:13:56 -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 v2] hw/audio/virtio-snd: Use device endianness instead of target one Date: Mon, 22 Apr 2024 15:13:55 +0200 Message-ID: <20240422131355.2264-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::32d; envelope-from=philmd@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=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é --- hw/audio/virtio-snd.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/hw/audio/virtio-snd.c b/hw/audio/virtio-snd.c index c80b58bf5d..82c5647660 100644 --- a/hw/audio/virtio-snd.c +++ b/hw/audio/virtio-snd.c @@ -395,13 +395,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 +466,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;