@@ -654,7 +654,6 @@ static int virtio_snd_desc_handler(virtio_snd_state_t *vsnd,
654654
655655 /* Return the device status */
656656 response -> code = VIRTIO_SND_S_OK ;
657- //*plen = vq_desc[2].len;
658657
659658 return 0 ;
660659}
@@ -663,7 +662,7 @@ static int virtio_snd_desc_handler(virtio_snd_state_t *vsnd,
663662typedef struct {
664663 struct virtq_desc vq_desc ;
665664 struct queue_head q ;
666- } virtq_desc_queue_t ;
665+ } virtq_desc_queue_node_t ;
667666static int virtio_snd_tx_desc_handler (virtio_snd_state_t * vsnd ,
668667 const virtio_snd_queue_t * queue ,
669668 uint32_t desc_idx ,
@@ -678,7 +677,10 @@ static int virtio_snd_tx_desc_handler(virtio_snd_state_t *vsnd,
678677 * Finally, the last descriptors contains:
679678 * (response payload structure)
680679 */
681- struct virtq_desc vq_desc [VSND_DESC_CNT ];
680+ virtq_desc_queue_node_t * node ;
681+ struct queue_head q ;
682+
683+ INIT_QUEUE_HEAD (& q );
682684
683685 /* Collect the descriptors */
684686 int i = 0 ;
@@ -687,11 +689,16 @@ static int virtio_snd_tx_desc_handler(virtio_snd_state_t *vsnd,
687689 const uint32_t * desc = & vsnd -> ram [queue -> QueueDesc + desc_idx * 4 ];
688690
689691 /* Retrieve the fields of current descriptor */
690- if (i < VSND_DESC_CNT ) {
692+ /* if (i < VSND_DESC_CNT) {
691693 vq_desc[i].addr = desc[0];
692694 vq_desc[i].len = desc[2];
693695 vq_desc[i].flags = desc[3];
694- }
696+ }*/
697+ node = (virtq_desc_queue_node_t * ) malloc (sizeof (* node ));
698+ node -> vq_desc .addr = desc [0 ];
699+ node -> vq_desc .len = desc [2 ];
700+ node -> vq_desc .flags = desc [3 ];
701+ queue_push (& node -> q , & q );
695702 desc_idx = desc [3 ] >> 16 ; /* vq_desc[desc_cnt].next */
696703
697704 i ++ ;
@@ -704,6 +711,7 @@ static int virtio_snd_tx_desc_handler(virtio_snd_state_t *vsnd,
704711 }
705712 }
706713
714+ #if 0
707715 fprintf (stderr , "TX process header\n" );
708716 /* Process the header */
709717 const virtio_snd_pcm_xfer_t * request =
@@ -723,6 +731,13 @@ static int virtio_snd_tx_desc_handler(virtio_snd_state_t *vsnd,
723731 response -> status = VIRTIO_SND_S_OK ;
724732 response -> latency_bytes = 0 ; /* TODO: show the actual latency bytes */
725733 * plen = vq_desc [1 ].len + sizeof (* response );
734+ #endif
735+ int idx = 0 ;
736+ queue_for_each_entry (node , & q , q )
737+ {
738+ printf ("node %d\n" , idx );
739+ idx ++ ;
740+ }
726741
727742 return 0 ;
728743}
0 commit comments