hw/audio/virtio-snd: Use device endianness instead of target one
PATCH 1/1 hw/audio/virtio-snd: Use device endianness instead of target one
Since VirtIO devices can change endianness at runtime, we need to use the device endianness, not the target one.
Fixes eb9ad377bb ("virtio-sound: handle control messages and streams")
Signed-off-by Philippe Mathieu-Daudé <[email protected]>
--- hw/audio/virtio-snd.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
hw/audio/virtio-snd.c +5 -3
@@ -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 = vdev->device_endian ?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 ;
Signature · 1 line
2.41.0
Quoted 13 lines · Philippe Mathieu-Daudé
Since VirtIO devices can change endianness at runtime, we need to use the device endianness, not the target one.
Fixes eb9ad377bb ("virtio-sound: handle control messages and streams")Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/audio/virtio-snd.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)hw/audio/virtio-snd.c +0
-1-static void virtio_snd_get_qemu_audsettings(audsettings *as,
hw/audio/virtio-snd.c static uint32_t virtio_snd_get_qemu_freq(uint32_t rate) · line 406
Quoted 10 lines
hw/audio/virtio-snd.c +4
-1+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 = vdev->device_endian ?1 :0 ;
Err, I neglected to consider VIRTIO_DEVICE_ENDIAN_UNKNOWN :/
Quoted 1 line
}