Skip to content

Commit

Permalink
Apply clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
Cuda-Chen committed Sep 2, 2024
1 parent cb56b62 commit 0f34e7b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
7 changes: 4 additions & 3 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ static void emu_update_vblk_interrupts(vm_t *vm)
}
#endif

static void emu_update_timer_interrupt(hart_t *hart) {
static void emu_update_timer_interrupt(hart_t *hart)
{
emu_state_t *data = PRIV(hart);

/* Sync global timer with local timer */
Expand Down Expand Up @@ -634,8 +635,8 @@ static int semu_start(int argc, char **argv)
#endif

#if SEMU_HAS(VIRTIOSND)
if (emu.vsnd.InterruptStatus)
emu_update_vsnd_interrupts(&vm);
if (emu.vsnd.InterruptStatus)
emu_update_vsnd_interrupts(&vm);
#endif
}

Expand Down
27 changes: 14 additions & 13 deletions virtio-snd.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ enum {
VIRTIO_SND_R_CHMAP_INFO = 0x0200,
VIRTIO_SND_S_OK = 0x8000,
VIRTIO_SND_S_BAD_MSG,
VIRTIO_SND_S_NOT_SUPP,
VIRTIO_SND_S_IO_ERR,
VIRTIO_SND_S_NOT_SUPP,
VIRTIO_SND_S_IO_ERR,
};

enum {
Expand Down Expand Up @@ -228,9 +228,9 @@ static void cnfa_audio_callback(struct CNFADriver *dev,
}

static int virtio_snd_desc_handler(virtio_snd_state_t *vsnd,
const virtio_snd_queue_t *queue,
uint32_t desc_idx,
uint32_t *plen)
const virtio_snd_queue_t *queue,
uint32_t desc_idx,
uint32_t *plen)
{
struct virtq_desc vq_desc[3];

Expand Down Expand Up @@ -260,15 +260,14 @@ static int virtio_snd_desc_handler(virtio_snd_state_t *vsnd,

/* Process the header */
const virtio_snd_query_info *query =
(virtio_snd_query_info *) ((uintptr_t) vsnd->ram +
vq_desc[0].addr);
(virtio_snd_query_info *) ((uintptr_t) vsnd->ram + vq_desc[0].addr);
uint32_t type = query->hdr.code;
uint8_t *status = (uint8_t *) ((uintptr_t) vsnd->ram + vq_desc[2].addr);

/* Process the data */
switch (type) {
case VIRTIO_SND_R_JACK_INFO: {
virtio_snd_jack_info *info = (virtio_snd_jack_info *)(vq_desc[2].addr);
virtio_snd_jack_info *info = (virtio_snd_jack_info *) (vq_desc[2].addr);
for (int i = 0; i < query->count; i++) {
info[i].hdr.hda_fn_nid = 0;
info[i].features = 0;
Expand All @@ -278,9 +277,9 @@ static int virtio_snd_desc_handler(virtio_snd_state_t *vsnd,
memset(&info[i].padding, 0, sizeof(info[i].padding));
}
break;
}
}
case VIRTIO_SND_R_PCM_INFO: {
virtio_snd_pcm_info *info = (virtio_snd_pcm_info *)(vq_desc[2].addr);
virtio_snd_pcm_info *info = (virtio_snd_pcm_info *) (vq_desc[2].addr);
for (int i = 0; i < query->count; i++) {
info[0].features = 0;
info[0].formats = (1 << VIRTIO_SND_PCM_FMT_S16);
Expand All @@ -290,16 +289,18 @@ static int virtio_snd_desc_handler(virtio_snd_state_t *vsnd,
info[0].channels_max = 1;
memset(&info[i].padding, 0, sizeof(info[i].padding));
}
break;}
break;
}
case VIRTIO_SND_R_CHMAP_INFO: {
virtio_snd_chmap_info *info = (virtio_snd_chmap_info *)(vq_desc[2].addr);
virtio_snd_chmap_info *info =
(virtio_snd_chmap_info *) (vq_desc[2].addr);
for (int i = 0; i < query->count; i++) {
info[i].direction = VIRTIO_SND_D_OUTPUT;
info[i].channels = 1;
info[i].positions[0] = VIRTIO_SND_CHMAP_MONO;
}
break;
}
}
default:
fprintf(stderr, "unsupported virtio-snd operation!\n");
*status = VIRTIO_SND_S_NOT_SUPP;
Expand Down

0 comments on commit 0f34e7b

Please sign in to comment.