Skip to content

Commit a126bea

Browse files
committed
Clarify the usage of TX descriptors
1 parent 581b817 commit a126bea

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

virtio-snd.c

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,6 @@ static int virtio_snd_desc_handler(virtio_snd_state_t *vsnd,
724724
uint32_t desc_idx,
725725
uint32_t *plen)
726726
{
727-
/* TODO: clarify the use of the third descriptor */
728727
/* virtio-snd command uses at most 3 virtqueue descriptors, where
729728
* the first descriptor contains:
730729
* struct virtio_snd_hdr hdr (for request)
@@ -759,9 +758,6 @@ static int virtio_snd_desc_handler(virtio_snd_state_t *vsnd,
759758
(virtio_snd_hdr_t *) ((uintptr_t) vsnd->ram + vq_desc[1].addr);
760759
const void *query = (void *) ((uintptr_t) vsnd->ram + vq_desc[0].addr);
761760

762-
/* TODO: let the program use this variable selectively according to
763-
* the type.
764-
*/
765761
/* As there are plenty of structures for response payload,
766762
* use a void pointer for generic type support.
767763
*/
@@ -840,14 +836,14 @@ static int virtio_snd_tx_desc_handler(virtio_snd_state_t *vsnd,
840836
uint32_t desc_idx,
841837
uint32_t *plen)
842838
{
843-
/* TODO: clarify the usage of the last descriptor. */
844-
/* virtio-snd TX uses arbitrary number of virtqueue descriptors.
845-
* The first descritor descriptor contains:
846-
* struct virtio_snd_hdr hdr (for request)
847-
* Next, the payload consists of one or more descriptors
839+
/* A PCM I/O message uses at least 3 virtqueue descriptors to
840+
* represent a PCM data of a period size.
841+
* The first part contains one descriptor as follows:
842+
* struct virtio_snd_pcm_xfer
843+
* The second part contains one or more descriptors
848844
* representing PCM frames.
849-
* Finally, the last descriptors contains:
850-
* (response payload structure)
845+
* the last part contains one descriptor as follows:
846+
* struct virtio_snd_pcm_status
851847
*/
852848
virtq_desc_queue_node_t *node;
853849
struct list_head q;
@@ -891,7 +887,6 @@ static int virtio_snd_tx_desc_handler(virtio_snd_state_t *vsnd,
891887
(virtio_snd_pcm_status_t *) (base + addr);
892888
response->status = VIRTIO_SND_S_OK;
893889
response->latency_bytes = ret_len;
894-
printf("=== TX queue get %" PRIu32 " bytes ===\n", ret_len);
895890
*plen = sizeof(*response);
896891
goto early_continue;
897892
}
@@ -985,7 +980,7 @@ static void virtio_queue_notify_handler(
985980
}
986981

987982
/* TX thread context */
988-
/* Control the callback to prepare the buffer */
983+
/* Receive PCM frames from driver. */
989984
static void *func(void *args)
990985
{
991986
virtio_snd_state_t *vsnd = (virtio_snd_state_t *) args;

0 commit comments

Comments
 (0)