Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement VirtIO sound device #53

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Cuda-Chen
Copy link
Contributor

@Cuda-Chen Cuda-Chen commented Aug 31, 2024

Implement VirtIO sound device supporting these operations (the item with checked box checked means it is implemented right now):

  • For setting up the device:
    • VIRTIO_SND_R_JACK_INFO
    • VIRTIO_SND_R_PCM_INFO
    • VIRTIO_SND_R_CHMAP_INFO
  • For playing the sound (PCM):
    • VIRTIO_SND_R_PCM_SET_PARAMS
    • VIRTIO_SND_R_PCM_PREPARE
    • VIRTIO_SND_R_PCM_RELEASE
    • VIRTIO_SND_R_PCM_START
    • VIRTIO_SND_R_PCM_STOP

Test Cases

The test cases are subjected to be altered.

boot up test

test procedures

  1. Execute make check to run semu.
  2. Check kernel message (dmesg).

expected results

  1. The following message should appear while booting up:
[    4.011962] ALSA device list:
[    4.015962]   #0: Loopback 1
[    4.015962]   #1: VirtIO SoundCard at platform/f4400000.virtio/virtio2

check driver configuration

test procedures

  1. Execute aplay -l in emulator.
  2. Check the output messages.

expected results

  1. The following message should appear after Step 1:
$ aplay -l          
**** List of PLAYBACK Hardware Devices ****

<other sound device here>

card 1: SoundCard [VirtIO SoundCard], device 0: virtio-snd [VirtIO PCM 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

play sound

test procedures

  1. Execute speaker-test in emulator.
  2. Check the host speaker.

expected results

  1. A white noise will be played by host speaker while speaker-test is executing.

@shengwen-tw
Copy link
Collaborator

Please provide testing procedures once the change is ready.

CNFA_sf.h Outdated Show resolved Hide resolved
virtio-snd.c Outdated Show resolved Hide resolved
configs/linux.config Outdated Show resolved Hide resolved
configs/linux.config Outdated Show resolved Hide resolved
os_generic.h Outdated Show resolved Hide resolved
@Cuda-Chen Cuda-Chen force-pushed the add-virtio-snd branch 3 times, most recently from 2b1009d to be7ad90 Compare September 1, 2024 13:24
Makefile Outdated Show resolved Hide resolved
configs/linux.config Outdated Show resolved Hide resolved
virtio-snd.c Outdated Show resolved Hide resolved
virtio-snd.c Outdated Show resolved Hide resolved
Copy link
Collaborator

@jserv jserv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Run clang-format before submitting.

.gitmodules Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
Copy link
Collaborator

@jserv jserv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consult https://github.com/cntools/cnfa/blob/master/.github/workflows/build-cnfa.yml and mention the build dependency in top-level README.md.

configs/linux.config Outdated Show resolved Hide resolved
feature.h Outdated Show resolved Hide resolved
@Cuda-Chen Cuda-Chen force-pushed the add-virtio-snd branch 2 times, most recently from a67216b to 1fc471c Compare September 3, 2024 09:02
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
configs/linux.config Outdated Show resolved Hide resolved
@Cuda-Chen Cuda-Chen force-pushed the add-virtio-snd branch 2 times, most recently from 862cb51 to da29ce5 Compare September 3, 2024 12:05
mk/check-libs.mk Outdated Show resolved Hide resolved
@Cuda-Chen Cuda-Chen force-pushed the add-virtio-snd branch 2 times, most recently from 2ea04d1 to e3c991a Compare September 24, 2024 12:35
virtio-snd.c Outdated Show resolved Hide resolved
@Cuda-Chen Cuda-Chen force-pushed the add-virtio-snd branch 3 times, most recently from 862eecf to 6017721 Compare September 27, 2024 04:04
jserv

This comment was marked as resolved.

@Cuda-Chen

This comment was marked as duplicate.

@jserv
Copy link
Collaborator

jserv commented Oct 2, 2024

Execute speaker-test in emulator.
Check the host speaker.
expected results
A white noise will be played by host speaker while speaker-test is executing.

What features or functionalities are missing that prevent aplay from playing wave files?

@Cuda-Chen
Copy link
Contributor Author

Cuda-Chen commented Oct 2, 2024

What features or functionalities are missing that prevent aplay from playing wave files?

For my understanding and observation, two things are missing:

  1. sound card: While aplay selects a sound card, there is no information regarding the VirtIO SoundCard at platform/f4400000.virtio/virtio2.
  2. PCM: aplay triggers PCM related function to play sound. However, for virtio-snd, I am still working on the PCM part (VIRTIO_SND_R_PCM_*) especially filling the buffer to ALSA.

virtio-snd.c Outdated Show resolved Hide resolved
@Cuda-Chen Cuda-Chen force-pushed the add-virtio-snd branch 4 times, most recently from 347e761 to 34f8503 Compare October 10, 2024 13:35
@Cuda-Chen Cuda-Chen force-pushed the add-virtio-snd branch 2 times, most recently from dc4c861 to 164a0ad Compare October 22, 2024 12:50
@Cuda-Chen Cuda-Chen force-pushed the add-virtio-snd branch 4 times, most recently from c28a3c5 to f0f9978 Compare October 30, 2024 12:01
@Cuda-Chen Cuda-Chen force-pushed the add-virtio-snd branch 2 times, most recently from 8e6b6a1 to 083dc24 Compare November 5, 2024 01:59
Enable ALSA driver and System V IPC in Linux Kernel. For
ALSA, the debug is enabled and will be removed once
this commit is ready.

Add description of descriptor chaining, yet need refactoring
the description as well as code (exists uncertainty of
the query struct).

Succeed to initialize virtio-snd.

Handle requests in control queue, and print the address and length
of each virtq element to check the validness of self-implement
queue.

For macOS, an experimental core audio library check is implemented.

Create critical section when receiving frames. Need to investigate
whether we should dispatch an event to event queue to notify
the completion of receiving frames so that the device can move to
pcm_start state.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants