All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Cc: Vinod Koul <vinod.koul@intel.com>,
	alsa-devel@alsa-project.org, Mark Brown <broonie@kernel.org>
Subject: Re: [PATCH v2 05/13] topology: Add PCM parser.
Date: Wed, 01 Jul 2015 18:14:47 +0200	[thread overview]
Message-ID: <s5hbnfvlurs.wl-tiwai@suse.de> (raw)
In-Reply-To: <1435758275-4047-5-git-send-email-liam.r.girdwood@linux.intel.com>

At Wed,  1 Jul 2015 14:44:27 +0100,
Liam Girdwood wrote:
> 
> +/* copy referenced caps to the pcm */
> +static void copy_pcm_caps(const char *id, struct snd_soc_tplg_stream_caps *caps,
> +	struct tplg_elem *ref_elem)
> +{
> +	struct snd_soc_tplg_stream_caps *ref_caps = ref_elem->stream_caps;
> +
> +	tplg_dbg("Copy pcm caps (%ld bytes) from '%s' to '%s' \n",
> +		sizeof(*caps), ref_elem->id, id);
> +
> +	memcpy((void*)caps, ref_caps, sizeof(*caps));

This can be simply
	*caps = *ref_caps;

> +/* copy referenced config to the pcm */
> +static void copy_pcm_config(const char *id,
> +	struct snd_soc_tplg_stream_config *cfg, struct tplg_elem *ref_elem)
> +{
> +	struct snd_soc_tplg_stream_config *ref_cfg = ref_elem->stream_cfg;
> +
> +	tplg_dbg("Copy pcm config (%ld bytes) from '%s' to '%s' \n",
> +		sizeof(*cfg), ref_elem->id, id);
> +
> +	memcpy((void*)cfg, ref_cfg, sizeof(*cfg));

Ditto.


> +int tplg_build_pcm_dai(snd_tplg_t *tplg, unsigned int type)
> +{
> +	struct list_head *base, *pos, *npos;
> +	struct tplg_elem *elem;
> +	int err = 0;
> +
> +	switch (type) {
> +	case PARSER_TYPE_PCM:
> +		base = &tplg->pcm_list;
> +		break;
> +	case PARSER_TYPE_BE:
> +		base = &tplg->be_list;
> +		break;
> +	case PARSER_TYPE_CC:
> +		base = &tplg->cc_list;
> +		break;
> +	default:
> +		return -EINVAL;
> +	}
> +
> +	list_for_each_safe(pos, npos, base) {

Does it need to be the safe version?

> +		elem = list_entry(pos, struct tplg_elem, list);
> +		if (elem->type != type) {
> +			fprintf(stderr, "error: invalid elem '%s'\n", elem->id);
> +			return -EINVAL;
> +		}
> +
> +		err = tplg_build_pcm_cfg_caps(tplg, elem);
> +		if (err < 0)
> +			return err;
> +	}
> +
> +	return 0;
> +}
> +
> +/* PCM stream configuration
> + *
> + * Describes the PCM configuration for playback and capture streams.
> + *
> + *	config."name" {
> + *		format "S24_LE"
> + *		rate "48000"
> + *		channels "2"
> + *		tdm_slot "0xf"
> + *      }

Such a description should go to doxygen comment, no?
Also, it'd be better to mention more clearly that "name" here
corresponds to the stream direction.

> +int tplg_parse_pcm(snd_tplg_t *tplg,
> +	snd_config_t *cfg, void *private ATTRIBUTE_UNUSED)
> +{
> +	struct snd_soc_tplg_pcm_dai *pcm_dai;
> +	struct tplg_elem *elem;
> +	snd_config_iterator_t i, next;
> +	snd_config_t *n;
> +	const char *id, *val = NULL;
> +	int err;
> +
> +	elem = tplg_elem_new_common(tplg, cfg, PARSER_TYPE_PCM);
> +	if (!elem)
> +		return -ENOMEM;
> +
> +	pcm_dai = elem->pcm;
> +	pcm_dai->size = elem->size;
> +	strncpy(pcm_dai->name, elem->id, SNDRV_CTL_ELEM_ID_NAME_MAXLEN);
> +	pcm_dai->name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN - 1] = 0;
> +
> +	tplg_dbg(" PCM: %s\n", elem->id);
> +
> +	snd_config_for_each(i, next, cfg) {
> +
> +		n = snd_config_iterator_entry(i);
> +		if (snd_config_get_id(n, &id) < 0)
> +			continue;
> +
> +		/* skip comments */
> +		if (strcmp(id, "comment") == 0)
> +			continue;
> +		if (id[0] == '#')
> +			continue;
> +
> +		if (strcmp(id, "index") == 0) {
> +			if (snd_config_get_string(n, &val) < 0)
> +				return -EINVAL;
> +
> +			elem->index = atoi(val);
> +			tplg_dbg("\t%s: %d\n", id, elem->index);
> +			continue;
> +		}
> +
> +		if (strcmp(id, "ID") == 0) {

Only this word is capital letters while others are not?
I don't mind too much, but just wondered, because currently the parser
is case-sensitive.


Takashi

  reply	other threads:[~2015-07-01 16:14 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-01 13:44 [PATCH v2 01/13] topology: uapi: Add UAPI headers for topology ABI Liam Girdwood
2015-07-01 13:44 ` [PATCH v2 02/13] conf: topology: Add topology file for broadwell audio DSP Liam Girdwood
2015-07-01 15:47   ` Takashi Iwai
2015-07-01 16:16     ` Liam Girdwood
2015-07-01 13:44 ` [PATCH v2 03/13] topology: Add topology core parser Liam Girdwood
2015-07-01 16:00   ` Takashi Iwai
2015-07-01 13:44 ` [PATCH v2 04/13] topology: Add text section parser Liam Girdwood
2015-07-01 16:03   ` Takashi Iwai
2015-07-01 13:44 ` [PATCH v2 05/13] topology: Add PCM parser Liam Girdwood
2015-07-01 16:14   ` Takashi Iwai [this message]
2015-07-01 16:20     ` Liam Girdwood
2015-07-01 13:44 ` [PATCH v2 06/13] topology: Add operations parser Liam Girdwood
2015-07-01 13:44 ` [PATCH v2 07/13] topology: Add private data parser Liam Girdwood
2015-07-01 16:20   ` Takashi Iwai
2015-07-07 15:54     ` Liam Girdwood
2015-07-07 16:19       ` Takashi Iwai
2015-07-08  8:57         ` Liam Girdwood
2015-07-08 13:31           ` Jin, Yao
2015-07-08 14:14             ` Takashi Iwai
2015-07-08 14:21               ` Liam Girdwood
2015-07-01 13:44 ` [PATCH v2 08/13] topology: Add DAPM object parser Liam Girdwood
2015-07-01 13:44 ` [PATCH v2 09/13] topology: Add CTL parser Liam Girdwood
2015-07-01 13:44 ` [PATCH v2 10/13] topology: Add Channel map parser Liam Girdwood
2015-07-01 13:44 ` [PATCH v2 11/13] topology: Add binary file builder Liam Girdwood
2015-07-01 13:44 ` [PATCH v2 12/13] topology: autotools: Add build support for topology core Liam Girdwood
2015-07-01 13:44 ` [PATCH v2 13/13] topology: doxygen: Add doxygen " Liam Girdwood

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=s5hbnfvlurs.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=liam.r.girdwood@linux.intel.com \
    --cc=vinod.koul@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.