virtio_pcm.c (29b96bf50ba958eb5f097cdc3fbd4c1acf9547a2) | virtio_pcm.c (f40a28679e0b7cb3a9cc6627a8dbb40961990f0a) |
---|---|
1// SPDX-License-Identifier: GPL-2.0+ 2/* 3 * virtio-snd: Virtio sound device 4 * Copyright (C) 2021 OpenSynergy GmbH 5 */ 6#include <linux/moduleparam.h> 7#include <linux/virtio_config.h> 8 --- 339 unchanged lines hidden (view full) --- 348 349 for (i = 0; i < snd->nsubstreams; ++i) { 350 struct virtio_pcm_substream *vss = &snd->substreams[i]; 351 struct virtio_pcm *vpcm; 352 353 vss->snd = snd; 354 vss->sid = i; 355 INIT_WORK(&vss->elapsed_period, virtsnd_pcm_period_elapsed); | 1// SPDX-License-Identifier: GPL-2.0+ 2/* 3 * virtio-snd: Virtio sound device 4 * Copyright (C) 2021 OpenSynergy GmbH 5 */ 6#include <linux/moduleparam.h> 7#include <linux/virtio_config.h> 8 --- 339 unchanged lines hidden (view full) --- 348 349 for (i = 0; i < snd->nsubstreams; ++i) { 350 struct virtio_pcm_substream *vss = &snd->substreams[i]; 351 struct virtio_pcm *vpcm; 352 353 vss->snd = snd; 354 vss->sid = i; 355 INIT_WORK(&vss->elapsed_period, virtsnd_pcm_period_elapsed); |
356 init_waitqueue_head(&vss->msg_empty); 357 spin_lock_init(&vss->lock); |
|
356 357 rc = virtsnd_pcm_build_hw(vss, &info[i]); 358 if (rc) 359 goto on_exit; 360 361 vss->nid = le32_to_cpu(info[i].hdr.hda_fn_nid); 362 363 vpcm = virtsnd_pcm_find_or_create(snd, vss->nid); --- 108 unchanged lines hidden (view full) --- 472 473 snd_pcm_set_managed_buffer_all(vpcm->pcm, 474 SNDRV_DMA_TYPE_VMALLOC, NULL, 475 0, 0); 476 } 477 478 return 0; 479} | 358 359 rc = virtsnd_pcm_build_hw(vss, &info[i]); 360 if (rc) 361 goto on_exit; 362 363 vss->nid = le32_to_cpu(info[i].hdr.hda_fn_nid); 364 365 vpcm = virtsnd_pcm_find_or_create(snd, vss->nid); --- 108 unchanged lines hidden (view full) --- 474 475 snd_pcm_set_managed_buffer_all(vpcm->pcm, 476 SNDRV_DMA_TYPE_VMALLOC, NULL, 477 0, 0); 478 } 479 480 return 0; 481} |
482 483/** 484 * virtsnd_pcm_event() - Handle the PCM device event notification. 485 * @snd: VirtIO sound device. 486 * @event: VirtIO sound event. 487 * 488 * Context: Interrupt context. 489 */ 490void virtsnd_pcm_event(struct virtio_snd *snd, struct virtio_snd_event *event) 491{ 492 struct virtio_pcm_substream *vss; 493 u32 sid = le32_to_cpu(event->data); 494 495 if (sid >= snd->nsubstreams) 496 return; 497 498 vss = &snd->substreams[sid]; 499 500 switch (le32_to_cpu(event->hdr.code)) { 501 case VIRTIO_SND_EVT_PCM_PERIOD_ELAPSED: 502 /* TODO: deal with shmem elapsed period */ 503 break; 504 case VIRTIO_SND_EVT_PCM_XRUN: 505 spin_lock(&vss->lock); 506 if (vss->xfer_enabled) 507 vss->xfer_xrun = true; 508 spin_unlock(&vss->lock); 509 break; 510 } 511} |
|