From patchwork Fri Feb 27 21:28:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 5903471 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 2CF499F269 for ; Fri, 27 Feb 2015 21:28:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 45D8320253 for ; Fri, 27 Feb 2015 21:28:49 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 0CEF220142 for ; Fri, 27 Feb 2015 21:28:46 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 39A67265268; Fri, 27 Feb 2015 22:28:44 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id B3CCE26128B; Fri, 27 Feb 2015 22:28:36 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id BA3612651CB; Fri, 27 Feb 2015 22:28:34 +0100 (CET) Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id C713A26128B for ; Fri, 27 Feb 2015 22:28:27 +0100 (CET) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 6BCA7AC70 for ; Fri, 27 Feb 2015 21:28:27 +0000 (UTC) From: Takashi Iwai To: alsa-devel@alsa-project.org Date: Fri, 27 Feb 2015 22:28:20 +0100 Message-Id: <1425072502-3204-6-git-send-email-tiwai@suse.de> X-Mailer: git-send-email 2.3.0 In-Reply-To: <1425072502-3204-1-git-send-email-tiwai@suse.de> References: <1425072502-3204-1-git-send-email-tiwai@suse.de> Subject: [alsa-devel] [PATCH 5/7] ALSA: hda - Allow driver to add vendor-specific verbs for regmap X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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,