public inbox for alsa-devel@alsa-project.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Vinod Koul <vinod.koul@intel.com>
Cc: liam.r.girdwood@linux.intel.com, patches.audio@intel.com,
	alsa-devel@alsa-project.org, broonie@kernel.org,
	Jeeja KP <jeeja.kp@intel.com>
Subject: Re: [PATCH v3 3/7] ASoC: hda - adds SoC controller and stream operations
Date: Wed, 29 Apr 2015 14:26:40 +0200	[thread overview]
Message-ID: <s5hzj5rf7cv.wl-tiwai@suse.de> (raw)
In-Reply-To: <1430250870-3169-4-git-send-email-vinod.koul@intel.com>

At Wed, 29 Apr 2015 01:24:26 +0530,
Vinod Koul wrote:
> 
> +struct soc_hdac_stream {
> +	struct hdac_stream hstream;
> +	unsigned int decoupled:1;
> +	void __iomem *pphc_addr; /* processing pipe host stream reg pointer */
> +	void __iomem *pplc_addr; /* processing pipe link stream reg pointer */
> +	bool link_locked:1;
> +	struct snd_pcm_substream *link_substream;
> +	bool link_prepared;

The bit fields should be gathered into the same place so that the
struct can be packed better.  Also, use bool consistently for bit
fields, too.


> +/**
> + * snd_soc_hdac_bus_parse_capabilities - parse capablity structure
> + * @sbus - HD-audio soc core bus
> + */
> +int snd_soc_hdac_bus_parse_capabilities(struct soc_hdac_bus *sbus)
> +{
> +	unsigned int cur_cap;
> +	unsigned int offset;
> +	struct hdac_bus *bus = &sbus->bus;
> +
> +	offset = snd_hdac_chip_readl(bus, LLCH);
> +
> +	sbus->ppcap = false;
> +	sbus->mlcap = false;
> +	sbus->spbcap = false;
> +	sbus->gtscap = false;
> +
> +	/* Lets walk the linked capabilities list */
> +	do {

I'd check the validity of the offset value, at least, to a negative
value.  When a chip or bus is screwed up, it would return -1.


> +/**
> + * snd_soc_hdac_bus_get_ml_capablities - get multilink capablity
> + * @sbus - HD-audio soc core bus
> + */
> +int snd_soc_hdac_bus_get_ml_capablities(struct soc_hdac_bus *sbus)
> +{
> +	int idx = 0;

Superfluous initialization.

> +	u32 link_count = 0;

Ditto.

> +	struct soc_hdac_link *hlink;
> +	struct hdac_bus *bus = &sbus->bus;
> +
> +	INIT_LIST_HEAD(&sbus->hlink_list);

This should be done better in the initializer of soc_hdac_bus object.

> +
> +	link_count = soc_hdac_bus_mlcap_readb(sbus, ML_MLCD) + 1;
> +
> +	dev_dbg(bus->dev, "In %s Link count: %d\n", __func__, link_count);
> +
> +	for (idx = 0; idx < link_count; idx++) {
> +		hlink  = devm_kzalloc(bus->dev, sizeof(*hlink), GFP_KERNEL);
> +		if (!hlink)
> +			return -ENOMEM;
> +		hlink->index = idx;
> +		hlink->bus = bus;
> +		hlink->ml_addr = sbus->mlcap_addr +
> +					ML_BASE +
> +					(ML_INTERVAL *
> +					idx);
> +		hlink->lcaps  = soc_hdac_link_readw(hlink, ML_LCAP);
> +		hlink->lsdiid = soc_hdac_link_readw(hlink, ML_LSDIID);
> +
> +		list_add(&hlink->list, &sbus->hlink_list);

list_add_tail() is used more often.  (Does the order matter?)

> +/**
> + * snd_soc_hdac_bus_map_codec_to_link - maps codec to link
> + * @sbus - HD-audio soc core bus
> + * @addr - codec address
> + */
> +int snd_soc_hdac_bus_map_codec_to_link(struct soc_hdac_bus *sbus, int addr)
> +{
> +	struct soc_hdac_link *hlink;
> +	struct hdac_bus *bus = &sbus->bus;
> +
> +	list_for_each_entry(hlink, &sbus->hlink_list, list) {
> +		/*check if SDI bit number == Codec address */
> +		dev_dbg(bus->dev, "lsdid for %d link %x\n", hlink->index, hlink->lsdiid);
> +		if (!(hlink->lsdiid))

Superfluous parentheses.

> +			continue;
> +
> +		if (hlink->lsdiid && (0x1 << addr)) {
> +			snprintf(hlink->codec[addr],
> +					sizeof(hlink->codec[addr]),
> +					"codec#%03x.%d", addr, addr);

Does repeating the address twice make sense?


> +			break;
> +		}
> +	}
> +	return 0;
> +}
> +EXPORT_SYMBOL_GPL(snd_soc_hdac_bus_map_codec_to_link);
> +
> +/**
> + * snd_soc_hdac_bus_get_link_index - get link based on codec name
> + * @sbus - HD-audio soc core bus
> + * @codec_name - codec name
> + */
> +struct soc_hdac_link *snd_soc_hdac_bus_get_link(struct soc_hdac_bus *sbus,
> +						 const char *codec_name)
> +{
> +	int i = 0;
> +	struct soc_hdac_link *hlink = NULL;
> +
> +	list_for_each_entry(hlink, &sbus->hlink_list, list) {
> +		for (i = 0; i < 16 ; i++) {

Where does 16 comes from?  Not HDA_MAX_CODECS?

> +			if (strlen(hlink->codec[i]) == 0)
> +				break;

It can be simplified like
			if (!hlink->codec[i][0])

> +			if (!strncmp(hlink->codec[i], codec_name,
> +					sizeof(codec_name)))

This looks buggy.  sizeof(codec_name) == sizeof(const char *) == 4 or 8.

> +				return hlink;
> +		}
> +	}
> +	return hlink;

This also looks buggy.  When the loop is out, hlink isn't NULL.

> +}
> +EXPORT_SYMBOL_GPL(snd_soc_hdac_bus_get_link);
> +
> +/**
> + * snd_soc_hdac_bus_link_power_up -power up hda link
> + * @link - HD-audio soc link
> + */
> +int snd_soc_hdac_bus_link_power_up(struct soc_hdac_link *link)
> +{
> +	int timeout;
> +	u32 val;
> +	int mask = (1 << MLCTL_CPA);
> +
> +	soc_hdac_link_updatel(link, ML_LCTL, 0, MLCTL_SPA);
> +	udelay(3);
> +	timeout = 300;
> +
> +	do {
> +		val = soc_hdac_link_readl(link, ML_LCTL);
> +		if (((val & mask) >> MLCTL_CPA))
> +			return 0;
> +	} while (--timeout);

How 300 reads timeout calculated?  There is no delay in the loop, so
it's quite short.


> +/* Module information */
> +MODULE_AUTHOR("Jeeja KP <jeeja.kp@intel.com>");
> +MODULE_DESCRIPTION("HDA SoC core");
> +MODULE_LICENSE("GPL v2");

There is already module information in soc-hda-codec.c.


Takashi

  reply	other threads:[~2015-04-29 12:26 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-28 19:54 [PATCH v3 0/7] ASoC: intel - add skylake PCM driver Vinod Koul
2015-04-28 19:54 ` [PATCH v3 1/7] ASoC: hda - add soc hda codec driver wrapper Vinod Koul
2015-04-29 11:59   ` Takashi Iwai
2015-05-04 13:12   ` Mark Brown
2015-05-06  3:47     ` Vinod Koul
2015-05-06 12:51       ` Mark Brown
2015-05-06 16:51         ` Vinod Koul
2015-04-28 19:54 ` [PATCH v3 2/7] ALSA: hda - add new HDA registers Vinod Koul
2015-04-29 10:41   ` Takashi Iwai
2015-04-29 10:57     ` Vinod Koul
2015-04-29 12:02   ` Takashi Iwai
2015-04-28 19:54 ` [PATCH v3 3/7] ASoC: hda - adds SoC controller and stream operations Vinod Koul
2015-04-29 12:26   ` Takashi Iwai [this message]
2015-04-30  9:35     ` Vinod Koul
2015-04-30  9:49       ` Takashi Iwai
2015-04-28 19:54 ` [PATCH v3 4/7] ASoC: intel - add Skylake HDA platform driver Vinod Koul
2015-04-29 12:31   ` Takashi Iwai
2015-04-30  9:42     ` Vinod Koul
2015-04-30  9:52       ` Takashi Iwai
2015-04-30 10:39         ` Vinod Koul
2015-04-28 19:54 ` [PATCH v3 5/7] ASoC: intel - add Skylake HDA audio driver Vinod Koul
2015-04-29 12:49   ` Takashi Iwai
2015-04-30 10:11     ` Vinod Koul
2015-04-30 10:18       ` Takashi Iwai
2015-04-28 19:54 ` [PATCH v3 6/7] ASoC: intel - add makefile support for SKL driver Vinod Koul
2015-04-28 19:54 ` [PATCH v3 7/7] ASoC: intel - adds support for decoupled mode in skl driver Vinod Koul

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=s5hzj5rf7cv.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=jeeja.kp@intel.com \
    --cc=liam.r.girdwood@linux.intel.com \
    --cc=patches.audio@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox