lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Tue, 26 Jan 2021 08:40:41 +0100 (CET)
From:   Guennadi Liakhovetski <guennadi.liakhovetski@...ux.intel.com>
To:     Anton Yakovlev <anton.yakovlev@...nsynergy.com>
cc:     virtualization@...ts.linux-foundation.org,
        alsa-devel@...a-project.org, virtio-dev@...ts.oasis-open.org,
        linux-kernel@...r.kernel.org, Jaroslav Kysela <perex@...ex.cz>,
        Takashi Iwai <tiwai@...e.com>,
        "Michael S. Tsirkin" <mst@...hat.com>
Subject: Re: [PATCH v2 7/9] ALSA: virtio: introduce jack support


On Sun, 24 Jan 2021, Anton Yakovlev wrote:

> Enumerate all available jacks and create ALSA controls.
>
> At the moment jacks have a simple implementation and can only be used
> to receive notifications about a plugged in/out device.
>
> Signed-off-by: Anton Yakovlev <anton.yakovlev@...nsynergy.com>
> ---
> sound/virtio/Makefile      |   1 +
> sound/virtio/virtio_card.c |  18 +++
> sound/virtio/virtio_card.h |  12 ++
> sound/virtio/virtio_jack.c | 255 +++++++++++++++++++++++++++++++++++++
> 4 files changed, 286 insertions(+)
> create mode 100644 sound/virtio/virtio_jack.c

[snip]

> diff --git a/sound/virtio/virtio_jack.c b/sound/virtio/virtio_jack.c
> new file mode 100644
> index 000000000000..83593c59f6bf
> --- /dev/null
> +++ b/sound/virtio/virtio_jack.c
> @@ -0,0 +1,255 @@

[snip]

> +/**
> + * virtsnd_jack_parse_cfg() - Parse the jack 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_jack_parse_cfg(struct virtio_snd *snd)
> +{
> +	struct virtio_device *vdev = snd->vdev;
> +	struct virtio_snd_jack_info *info;
> +	unsigned int i;
> +	int rc;
> +
> +	virtio_cread(vdev, struct virtio_snd_config, jacks, &snd->njacks);
> +	if (!snd->njacks)
> +		return 0;
> +
> +	snd->jacks = devm_kcalloc(&vdev->dev, snd->njacks, sizeof(*snd->jacks),
> +				  GFP_KERNEL);
> +	if (!snd->jacks)
> +		return -ENOMEM;
> +
> +	info = devm_kcalloc(&vdev->dev, snd->njacks, sizeof(*info), GFP_KERNEL);

just kcalloc()

> +	if (!info)
> +		return -ENOMEM;
> +
> +	rc = virtsnd_ctl_query_info(snd, VIRTIO_SND_R_JACK_INFO, 0, snd->njacks,
> +				    sizeof(*info), info);
> +	if (rc)
> +		return rc;
> +
> +	for (i = 0; i < snd->njacks; ++i) {
> +		struct virtio_jack *jack = &snd->jacks[i];
> +		struct virtio_pcm *pcm;
> +
> +		jack->nid = le32_to_cpu(info[i].hdr.hda_fn_nid);
> +		jack->features = le32_to_cpu(info[i].features);
> +		jack->defconf = le32_to_cpu(info[i].hda_reg_defconf);
> +		jack->caps = le32_to_cpu(info[i].hda_reg_caps);
> +		jack->connected = info[i].connected;
> +
> +		pcm = virtsnd_pcm_find_or_create(snd, jack->nid);
> +		if (IS_ERR(pcm))
> +			return PTR_ERR(pcm);
> +	}
> +
> +	devm_kfree(&vdev->dev, info);
> +
> +	return 0;
> +}

Thanks
Guennadi

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ