/** * virtsnd_chmap_parse_cfg() - Parse the channel map configuration. * @snd: VirtIO sound device. * * This function is called during initial device initialization. * * Context: Any context that permits to sleep. * Return: 0 on success, -errno on failure.
*/ int virtsnd_chmap_parse_cfg(struct virtio_snd *snd)
{ struct virtio_device *vdev = snd->vdev;
u32 i; int rc;
virtio_cread_le(vdev, struct virtio_snd_config, chmaps, &snd->nchmaps); if (!snd->nchmaps) return 0;
snd->chmaps = devm_kcalloc(&vdev->dev, snd->nchmaps, sizeof(*snd->chmaps), GFP_KERNEL); if (!snd->chmaps) return -ENOMEM;
/* Count the number of channel maps per each PCM device/stream. */ for (i = 0; i < snd->nchmaps; ++i) { struct virtio_snd_chmap_info *info = &snd->chmaps[i];
u32 nid = le32_to_cpu(info->hdr.hda_fn_nid); struct virtio_pcm *vpcm; struct virtio_pcm_stream *vs;
vpcm = virtsnd_pcm_find_or_create(snd, nid); if (IS_ERR(vpcm)) return PTR_ERR(vpcm);
switch (info->direction) { case VIRTIO_SND_D_OUTPUT:
vs = &vpcm->streams[SNDRV_PCM_STREAM_PLAYBACK]; break; case VIRTIO_SND_D_INPUT:
vs = &vpcm->streams[SNDRV_PCM_STREAM_CAPTURE]; break; default:
dev_err(&vdev->dev, "chmap #%u: unknown direction (%u)\n", i,
info->direction); return -EINVAL;
}
vs->nchmaps++;
}
return 0;
}
/** * virtsnd_chmap_add_ctls() - Create an ALSA control for channel maps. * @pcm: ALSA PCM device. * @direction: PCM stream direction (SNDRV_PCM_STREAM_XXX). * @vs: VirtIO PCM stream. * * Context: Any context. * Return: 0 on success, -errno on failure.
*/ staticint virtsnd_chmap_add_ctls(struct snd_pcm *pcm, int direction, struct virtio_pcm_stream *vs)
{
u32 i; int max_channels = 0;
for (i = 0; i < vs->nchmaps; i++) if (max_channels < vs->chmaps[i].channels)
max_channels = vs->chmaps[i].channels;
/** * virtsnd_chmap_build_devs() - Build ALSA controls for channel maps. * @snd: VirtIO sound device. * * Context: Any context. * Return: 0 on success, -errno on failure.
*/ int virtsnd_chmap_build_devs(struct virtio_snd *snd)
{ struct virtio_device *vdev = snd->vdev; struct virtio_pcm *vpcm; struct virtio_pcm_stream *vs;
u32 i; int rc;
/* Allocate channel map elements per each PCM device/stream. */
list_for_each_entry(vpcm, &snd->pcm_list, list) { for (i = 0; i < ARRAY_SIZE(vpcm->streams); ++i) {
vs = &vpcm->streams[i];
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.