Skip to contentSkip to conversation

virtio-snd: add virtio sound device specification

PATCH Superseded Anton Yakovlev 3 participants 6 messages Jan 9, 2020 – Mar 2, 2020

v5 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

PATCH v5 1/1 virtio-snd: add virtio sound device specification

This patch proposes virtio specification for a new virtio sound device, that may be useful in case when having audio is required but a device passthrough or emulation is not an option.

---

v4 -> v5 changes:
1. Insert the virtio_snd_hdr to the virtio_snd_event structure.
2. Rephrase field description in structures.
3. Resize the features and rates fields in a stream configuration.
4. Replace MUST with SHOULD in queued buffer size requirements.

 conformance.tex  |  24 ++
 content.tex      |   1 +
 introduction.tex |   3 +
 virtio-sound.tex | 700 +++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 728 insertions(+)
 create mode 100644 virtio-sound.tex
conformance.tex +24 -0
index 50969e5..b8c6836 100644
@@ -191,6 +191,17 @@ \section{Conformance Targets}\label{sec:Conformance / Conformance Targets}
 \item \ref{drivernormative:Device Types / RPMB Device / Device Operation}
 \end{itemize}
 
+\conformance{\subsection}{Sound Driver Conformance}\label{sec:Conformance / Driver Conformance / Sound Driver Conformance}
+
+A sound driver MUST conform to the following normative statements:
+
+\begin{itemize}
+\item \ref{drivernormative:Device Types / Sound Device / Device Initialization}
+\item \ref{drivernormative:Device Types / Sound Device / Device Operation / PCM Stream Parameters}
+\item \ref{drivernormative:Device Types / Sound Device / Device Operation / PCM Output Stream}
+\item \ref{drivernormative:Device Types / Sound Device / Device Operation / PCM Input Stream}
+\end{itemize}
+
 \conformance{\section}{Device Conformance}\label{sec:Conformance / Device Conformance}
 
 A device MUST conform to the following normative statements:
@@ -360,6 +371,19 @@ \section{Conformance Targets}\label{sec:Conformance / Conformance Targets}
 \item \ref{devicenormative:Device Types / RPMB Device / Device Operation}
 \end{itemize}
 
+\conformance{\subsection}{Sound Device Conformance}\label{sec:Conformance / Device Conformance / Sound Device Conformance}
+
+A sound device MUST conform to the following normative statements:
+
+\begin{itemize}
+\item \ref{devicenormative:Device Types / Sound Device / Device Initialization}
+\item \ref{devicenormative:Device Types / Sound Device / Device Operation / Jack Configuration}
+\item \ref{devicenormative:Device Types / Sound Device / Device Operation / PCM Stream Configuration}
+\item \ref{devicenormative:Device Types / Sound Device / Device Operation / PCM Stream Parameters}
+\item \ref{devicenormative:Device Types / Sound Device / Device Operation / PCM Output Stream}
+\item \ref{devicenormative:Device Types / Sound Device / Device Operation / PCM Input Stream}
+\end{itemize}
+
 \conformance{\section}{Legacy Interface: Transitional Device and Transitional Driver Conformance}\label{sec:Conformance / Legacy Interface: Transitional Device and Transitional Driver Conformance}
 A conformant implementation MUST be either transitional or
 non-transitional, see \ref{intro:Legacy
content.tex +1 -0
index d68cfaf..70ad066 100644
@@ -5739,6 +5739,7 @@ \subsubsection{Legacy Interface: Framing Requirements}\label{sec:Device
 \input{virtio-vsock.tex}
 \input{virtio-fs.tex}
 \input{virtio-rpmb.tex}
+\input{virtio-sound.tex}
 
 \chapter{Reserved Feature Bits}\label{sec:Reserved Feature Bits}
 
introduction.tex +3 -0
index 33da3ec..07674f8 100644
@@ -66,6 +66,9 @@ \section{Normative References}\label{sec:Normative References}
         \phantomsection\label{intro:eMMC}\textbf{[eMMC]} &
         eMMC Electrical Standard (5.1), JESD84-B51,
         \newline\url{http://www.jedec.org/sites/default/files/docs/JESD84-B51.pdf}\\
+	\phantomsection\label{intro:HDA}\textbf{[HDA]} &
+	High Definition Audio Specification,
+	\newline\url{https://www.intel.com/content/dam/www/public/us/en/documents/product-specifications/high-definition-audio-specification.pdf}\\
 
 \end{longtable}
 
virtio-sound.tex new file +700 -0

700 lines not on this page · raw message

Signature · 6 lines
2.25.0.rc2


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
#1 lore raw
Quoted 3 lines · Anton Yakovlev

This patch proposes virtio specification for a new virtio sound device, that may be useful in case when having audio is required but a device passthrough or emulation is not an option.

Looks good to me. Where do we stand in terms of device/driver implementations? Trying to actually implement things sometimes finds problems in the specification ...

cheers,
Gerd

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

#2 lore raw

Hi Gert!

Great news.
We are in the process of the implementation process now. Will upstream ASAP.

BR,
Mikhail.

Quoted 9 lines · Gerd Hoffmann
Quoted 3 lines · Anton Yakovlev

This patch proposes virtio specification for a new virtio sound device, that may be useful in case when having audio is required but a device passthrough or emulation is not an option.

Looks good to me. Where do we stand in terms of device/driver implementations? Trying to actually implement things sometimes finds problems in the specification ...

Quoted 9 lines

cheers,
Gerd

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

#3 lore raw
In reply to Gerd Hoffmann

Hello all,

We have completed the implementation of the PoC specification v5. Below are our comments on what might or should be improved in the specification.

Initialization:

1. I think we should add the direction of the jack (in/out) to the configuration of the jack. Because some properties (for example, a label for some jack types) are based on this direction. The Linux HDA subsystem takes this information from a pin/complex configuration. But we don't have (and don't need) such entities.

2. The stream configuration contains “features” that partially work as normal virtio features, and partially do not. Maybe it is better to rename the field to “flags” (as well as in the set_params request) and enter two sets of flags:
one is reported in the stream configuration, and the other is used in the set_params request? This should make things less confusing.

Message-based PCM transport:

1. In the latest version of the specification, we resized the “features” field in the stream configuration (u8->le32), but forgot to do the same in the set_params request. This should be fixed.

2. The device may report polling support for message-based transport. In this case, the driver can be optimized so that it does not kick virtqueue for each message.

3. For the input stream (capture), we decided to report the actual filled size using the len field in the virtqueue descriptor. Should the specification clearly indicate that the value contains sizeof(struct virtio_snd_pcm_status)
+ the size of the recorded frames?

4. We also need to add a device requirement to complete all pending messages for a stream on a RELEASE request. Otherwise, they may become stuck in the virtqueue.

We are looking forward for your comments.

Signature · 9 lines
Anton Yakovlev
Senior Software Engineer

OpenSynergy GmbH
Rotherstr. 20, 10245 Berlin

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
#4 lore raw
Quoted 5 lines · Anton Yakovlev

Hello all,

We have completed the implementation of the PoC specification v5. Below are our comments on what might or should be improved in the specification.

Quoted 7 lines

Initialization:

1. I think we should add the direction of the jack (in/out) to the configuration of the jack. Because some properties (for example, a label for some jack types) are based on this direction. The Linux HDA subsystem takes this information from a pin/complex configuration. But we don't have (and don't need) such entities.

Sounds good.

Quoted 5 lines

2. The stream configuration contains “features” that partially work as normal virtio features, and partially do not. Maybe it is better to rename the field to “flags” (as well as in the set_params request) and enter two sets of flags:
one is reported in the stream configuration, and the other is used in the set_params request? This should make things less confusing.

Maybe have both features and flags fields?

Quoted 3 lines

1. In the latest version of the specification, we resized the “features” field in the stream configuration (u8->le32), but forgot to do the same in the set_params request. This should be fixed.

Sure.

Quoted 3 lines

2. The device may report polling support for message-based transport. In this case, the driver can be optimized so that it does not kick virtqueue for each message.

Makes sense too, especially given that the packets should arrive at regular intervals and not (unlike for example network packets) at unpredictable times.

Quoted 4 lines

3. For the input stream (capture), we decided to report the actual filled size using the len field in the virtqueue descriptor. Should the specification clearly indicate that the value contains sizeof(struct virtio_snd_pcm_status)
+ the size of the recorded frames?

Doesn't hurt to explicitly say so even though it should be clear that the descriptor size covers the complete payload and not only the recorded frames.

Quoted 3 lines

4. We also need to add a device requirement to complete all pending messages for a stream on a RELEASE request. Otherwise, they may become stuck in the virtqueue.

Yes, that makes sense. Maybe also explicitly say that the RELEASE request should be completed last (only after all other pending messages are completed).

cheers,
Gerd

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

#5 lore raw
Quoted 16 lines · Gerd Hoffmann
Quoted 5 lines · Anton Yakovlev

Hello all,

We have completed the implementation of the PoC specification v5. Below are our comments on what might or should be improved in the specification.

Quoted 7 lines

Initialization:

1. I think we should add the direction of the jack (in/out) to the configuration of the jack. Because some properties (for example, a label for some jack types) are based on this direction. The Linux HDA subsystem takes this information from a pin/complex configuration. But we don't have (and don't need) such entities.

Sounds good.

Quoted 7 lines
Quoted 5 lines

2. The stream configuration contains “features” that partially work as normal virtio features, and partially do not. Maybe it is better to rename the field to “flags” (as well as in the set_params request) and enter two sets of flags:
one is reported in the stream configuration, and the other is used in the set_params request? This should make things less confusing.

Maybe have both features and flags fields?

Yes, that's a good idea.

Quoted 6 lines
Quoted 3 lines

1. In the latest version of the specification, we resized the “features” field in the stream configuration (u8->le32), but forgot to do the same in the set_params request. This should be fixed.

Sure.

Quoted 7 lines
Quoted 3 lines

2. The device may report polling support for message-based transport. In this case, the driver can be optimized so that it does not kick virtqueue for each message.

Makes sense too, especially given that the packets should arrive at regular intervals and not (unlike for example network packets) at unpredictable times.

Then this will be an additional feature.

Quoted 9 lines
Quoted 4 lines

3. For the input stream (capture), we decided to report the actual filled size using the len field in the virtqueue descriptor. Should the specification clearly indicate that the value contains sizeof(struct virtio_snd_pcm_status)
+ the size of the recorded frames?

Doesn't hurt to explicitly say so even though it should be clear that the descriptor size covers the complete payload and not only the recorded frames.

Quoted 7 lines
Quoted 3 lines

4. We also need to add a device requirement to complete all pending messages for a stream on a RELEASE request. Otherwise, they may become stuck in the virtqueue.

Yes, that makes sense. Maybe also explicitly say that the RELEASE request should be completed last (only after all other pending messages are completed).

Makes sense, I will add this as well.

Quoted 10 lines

cheers,
Gerd

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

Signature · 9 lines
Anton Yakovlev
Senior Software Engineer

OpenSynergy GmbH
Rotherstr. 20, 10245 Berlin

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]