alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Lars-Peter Clausen <lars@metafoo.de>
Cc: Oder Chiou <oder_chiou@realtek.com>,
	"alsa-devel@alsa-project.org" <alsa-devel@alsa-project.org>,
	"lgirdwood@gmail.com" <lgirdwood@gmail.com>,
	"broonie@kernel.org" <broonie@kernel.org>,
	Bard Liao <bardliao@realtek.com>,
	Gustaw Lewandowski <gustaw.lewandowski@intel.com>,
	Flove <flove@realtek.com>
Subject: Re: [PATCH v5] ASoC: add RT286 CODEC driver
Date: Thu, 13 Mar 2014 09:52:14 +0100	[thread overview]
Message-ID: <s5h61nizdj5.wl%tiwai@suse.de> (raw)
In-Reply-To: <53216DDC.9090502@metafoo.de>

At Thu, 13 Mar 2014 09:35:40 +0100,
Lars-Peter Clausen wrote:
> 
> On 03/13/2014 06:29 AM, Bard Liao wrote:
> >>> +
> >> [...]
> >>> +static int rt286_update_bits(struct snd_soc_codec *codec, unsigned int vid,
> >>> +				unsigned int nid, unsigned int data,
> >>> +				unsigned int mask, unsigned int value) {
> >>> +	struct rt286_priv *rt286 = snd_soc_codec_get_drvdata(codec);
> >>> +	unsigned int old, new, verb;
> >>> +	int change, ret;
> >>> +
> >>> +	verb = VERB_CMD((vid | 0x800), nid, data);
> >>> +	regmap_read(rt286->regmap, verb, &old);
> >>> +	new = (old & ~mask) | (value & mask);
> >>> +	change = old != new;
> >>> +
> >>> +	if (change) {
> >>> +		verb = VERB_CMD(vid, nid, new);
> >>> +		ret = regmap_write(rt286->regmap, verb, 0);
> >>> +		if (ret < 0) {
> >>> +			dev_err(codec->dev,
> >>> +				"Failed to write private reg: %d\n", ret);
> >>> +			goto err;
> >>> +		}
> >>> +	}
> >>
> >> Can't this use regmap_update_bits()?
> >
> > rt286 use different data length for read/write protocol.
> > Also it uses different registers for read/write the same bit.
> >
> > verb = VERB_CMD((vid | 0x800), nid, data);
> > regmap_read(rt286->regmap, verb, &old);
> > ...
> > verb = VERB_CMD(vid, nid, new);
> > ret = regmap_write(rt286->regmap, verb, 0);
> 
> You need to differentiate between logical and physical addresses. If your 
> device uses different physical addresses for read and write then your read 
> and write functions should do the proper translation from the logical 
> address to the physical address. Looking at include/sound/hda_verbs.h it 
> seems that the GET verbs are always the same as the SET verbs but 
> additionally set bit 11. So bit 11 is your read bit that always needs to be 
> set when reading a register. This is nothing special to the rt286, in fact 
> it is so common that regmap as support for this in the core. See the 
> read_flag_mask for the regmap_config struct.

Note that get and set aren't always symmetrical for HD-audio.
You can get up to 32bit, but set only up to 8 bit, thus some verbs are
split to multiple different set verbs.  Also, some verbs expect
different values for get and set.  And, yet more tricky part is the
amplifier verbs.  These aren't suitable with regmap caching,
unfortunately.


Takashi

  reply	other threads:[~2014-03-13  8:52 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-11  7:11 [PATCH v5] ASoC: add RT286 CODEC driver bardliao
2014-03-12 21:15 ` Lars-Peter Clausen
2014-03-13  5:29   ` Bard Liao
2014-03-13  8:35     ` Lars-Peter Clausen
2014-03-13  8:52       ` Takashi Iwai [this message]
2014-03-13 19:29         ` Mark Brown
2014-03-13 20:04           ` Takashi Iwai
2014-03-13 20:43             ` Mark Brown
2014-03-14  9:38               ` Bard Liao
2014-03-14 10:16                 ` Mark Brown
2014-03-14 19:12 ` Mark Brown
2014-03-18 12:41   ` Bard Liao
2014-03-18 13:01     ` Mark Brown
2014-03-21  5:57       ` Bard Liao
2014-03-21 12:12         ` Mark Brown

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=s5h61nizdj5.wl%tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=bardliao@realtek.com \
    --cc=broonie@kernel.org \
    --cc=flove@realtek.com \
    --cc=gustaw.lewandowski@intel.com \
    --cc=lars@metafoo.de \
    --cc=lgirdwood@gmail.com \
    --cc=oder_chiou@realtek.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;
as well as URLs for NNTP newsgroup(s).