All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: alsa-devel@alsa-project.org
Subject: [PATCH 5/7] ALSA: hda - Allow driver to add vendor-specific verbs for regmap
Date: Fri, 27 Feb 2015 22:28:20 +0100	[thread overview]
Message-ID: <1425072502-3204-6-git-send-email-tiwai@suse.de> (raw)
In-Reply-To: <1425072502-3204-1-git-send-email-tiwai@suse.de>

Codecs may have own vendor-specific verbs, and we need to allow each
driver to give such verbs for cached accesses.  Here a verb can be put
into a single array and looked through it at readable and writeable
callbacks.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/pci/hda/hda_codec.h  |  1 +
 sound/pci/hda/hda_regmap.c | 20 ++++++++++++++++++++
 sound/pci/hda/hda_regmap.h |  2 ++
 3 files changed, 23 insertions(+)

diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h
index 953625c85ee4..8cf7b2870dd1 100644
--- a/sound/pci/hda/hda_codec.h
+++ b/sound/pci/hda/hda_codec.h
@@ -398,6 +398,7 @@ struct hda_codec {
 
 	/* regmap */
 	struct regmap *regmap;
+	struct snd_array vendor_verbs;
 	bool caps_overwriting; /* caps overwrite being in process */
 };
 
diff --git a/sound/pci/hda/hda_regmap.c b/sound/pci/hda/hda_regmap.c
index 8f12c23f3489..38934c06a813 100644
--- a/sound/pci/hda/hda_regmap.c
+++ b/sound/pci/hda/hda_regmap.c
@@ -35,10 +35,17 @@ static bool hda_writeable_reg(struct device *dev, unsigned int reg)
 {
 	struct hda_codec *codec = dev_to_hda_codec(dev);
 	unsigned int verb = get_verb(reg);
+	int i;
 
 	if (codec->caps_overwriting)
 		return true;
 
+	for (i = 0; i < codec->vendor_verbs.used; i++) {
+		unsigned int *v = snd_array_elem(&codec->vendor_verbs, i);
+		if (verb == *v)
+			return true;
+	}
+
 	switch (verb & 0xf00) {
 	case AC_VERB_GET_STREAM_FORMAT:
 	case AC_VERB_GET_AMP_GAIN_MUTE:
@@ -178,6 +185,7 @@ int snd_hda_regmap_init(struct hda_codec *codec)
 	if (IS_ERR(regmap))
 		return PTR_ERR(regmap);
 	codec->regmap = regmap;
+	snd_array_init(&codec->vendor_verbs, sizeof(unsigned int), 8);
 	return 0;
 }
 
@@ -187,7 +195,19 @@ void snd_hda_regmap_exit(struct hda_codec *codec)
 		regmap_exit(codec->regmap);
 		codec->regmap = NULL;
 	}
+	snd_array_free(&codec->vendor_verbs);
+}
+
+int snd_hda_regmap_add_vendor_verb(struct hda_codec *codec, unsigned int verb)
+{
+	unsigned int *p = snd_array_new(&codec->vendor_verbs);
+
+	if (!p)
+		return -ENOMEM;
+	*p = verb;
+	return 0;
 }
+EXPORT_SYMBOL_GPL(snd_hda_regmap_add_vendor_verb);
 
 /*
  * helper functions
diff --git a/sound/pci/hda/hda_regmap.h b/sound/pci/hda/hda_regmap.h
index 7d4b8be58975..562c58c4cbc1 100644
--- a/sound/pci/hda/hda_regmap.h
+++ b/sound/pci/hda/hda_regmap.h
@@ -13,6 +13,8 @@
 int snd_hda_regmap_init(struct hda_codec *codec);
 void snd_hda_regmap_exit(struct hda_codec *codec);
 
+int snd_hda_regmap_add_vendor_verb(struct hda_codec *codec, unsigned int verb);
+
 int snd_hda_regmap_write(struct hda_codec *codec, hda_nid_t nid,
 			 unsigned int verb, unsigned int val);
 int snd_hda_regmap_update_bits(struct hda_codec *codec, hda_nid_t nid,
-- 
2.3.0

  parent reply	other threads:[~2015-02-27 21:28 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-27 21:28 [PATCH 0/7] HD-audio regmap support Takashi Iwai
2015-02-27 21:28 ` [PATCH 1/7] ALSA: hda - Add " Takashi Iwai
2015-02-27 21:28 ` [PATCH 2/7] ALSA: hda - Use regmap for codec parameter reads Takashi Iwai
2015-02-27 21:28 ` [PATCH 3/7] ALSA: hda - Use regmap for amp accesses Takashi Iwai
2015-02-27 21:28 ` [PATCH 4/7] ALSA: hda - Use regmap for parameter caches, too Takashi Iwai
2015-02-27 21:28 ` Takashi Iwai [this message]
2015-02-27 21:28 ` [PATCH 6/7] ALSA: hda - Use regmap for command verb " Takashi Iwai
2015-02-27 21:28 ` [PATCH 7/7] ALSA: hda - Reduce verbs during generic parser initialization Takashi Iwai
2015-02-28  9:51   ` Lars-Peter Clausen
2015-02-28 10:01     ` Takashi Iwai
2015-02-28 10:27       ` Lars-Peter Clausen
2015-02-28 15:11         ` Takashi Iwai

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=1425072502-3204-6-git-send-email-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    /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.