@@ -146,6 +146,7 @@ typedef struct {
146
146
uint32_t chmaps ;
147
147
} virtio_snd_config_t ;
148
148
149
+ /* VirtIO sound common header */
149
150
typedef struct {
150
151
uint32_t code ;
151
152
} virtio_snd_hdr_t ;
@@ -400,12 +401,11 @@ static int virtio_snd_desc_handler(virtio_snd_state_t *vsnd,
400
401
* maybe wrong. */
401
402
/* A full virtio_snd_query_info is composed of 3 descriptors, where
402
403
* the first descriptor contains:
403
- * struct virtio_snd_hdr hdr
404
+ * struct virtio_snd_hdr hdr (for request)
404
405
* the second descriptors contains:
405
- * le32 start_id
406
- * le32 count
406
+ * struct virtio_snd_hdr hdr (for response)
407
407
* the third descriptors contains:
408
- * le32 size
408
+ * (payload)
409
409
*/
410
410
struct virtq_desc vq_desc [VSND_DESC_CNT ];
411
411
@@ -434,10 +434,13 @@ static int virtio_snd_desc_handler(virtio_snd_state_t *vsnd,
434
434
}
435
435
436
436
/* Process the header */
437
+ const virtio_snd_hdr_t * request =
438
+ (virtio_snd_hdr_t * ) ((uintptr_t ) vsnd -> ram + vq_desc [0 ].addr );
439
+ uint32_t type = request -> code ;
440
+ virtio_snd_hdr_t * response =
441
+ (virtio_snd_hdr_t * ) ((uintptr_t ) vsnd -> ram + vq_desc [1 ].addr );
437
442
const virtio_snd_query_info_t * query =
438
443
(virtio_snd_query_info_t * ) ((uintptr_t ) vsnd -> ram + vq_desc [0 ].addr );
439
- uint32_t type = query -> hdr .code ;
440
- uint32_t * status = (uint32_t * ) ((uintptr_t ) vsnd -> ram + vq_desc [2 ].addr );
441
444
442
445
/* Process the data */
443
446
switch (type ) {
@@ -467,14 +470,14 @@ static int virtio_snd_desc_handler(virtio_snd_state_t *vsnd,
467
470
break ;
468
471
default :
469
472
fprintf (stderr , "unsupported virtio-snd operation!\n" );
470
- * status = VIRTIO_SND_S_NOT_SUPP ;
473
+ response -> code = VIRTIO_SND_S_NOT_SUPP ;
471
474
* plen = 0 ;
472
475
return -1 ;
473
476
}
474
477
475
478
/* Return the device status */
476
- * status = VIRTIO_SND_S_OK ;
477
- * plen = vq_desc [1 ].len ;
479
+ response -> code = VIRTIO_SND_S_OK ;
480
+ * plen = vq_desc [2 ].len ;
478
481
479
482
return 0 ;
480
483
}
0 commit comments