From patchwork Fri Apr 17 09:13:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vinod Koul X-Patchwork-Id: 6229691 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C1D86BF4A6 for ; Fri, 17 Apr 2015 09:21:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B56CE2034B for ; Fri, 17 Apr 2015 09:21:54 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 7010320279 for ; Fri, 17 Apr 2015 09:21:53 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 80792265733; Fri, 17 Apr 2015 11:21:51 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: 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 A3B28265733; Fri, 17 Apr 2015 11:19:04 +0200 (CEST) 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 A793D26054E; Fri, 17 Apr 2015 11:19:00 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by alsa0.perex.cz (Postfix) with ESMTP id CDCB026054E for ; Fri, 17 Apr 2015 11:18:51 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 17 Apr 2015 02:18:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,593,1422950400"; d="scan'208";a="681590083" Received: from vkoul-udesk3.iind.intel.com ([10.223.84.65]) by orsmga001.jf.intel.com with ESMTP; 17 Apr 2015 02:18:33 -0700 From: Vinod Koul To: alsa-devel@alsa-project.org Date: Fri, 17 Apr 2015 14:43:16 +0530 Message-Id: <1429262000-21517-4-git-send-email-vinod.koul@intel.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1429262000-21517-1-git-send-email-vinod.koul@intel.com> References: <1429262000-21517-1-git-send-email-vinod.koul@intel.com> Cc: tiwai@suse.de, Jeeja KP , broonie@kernel.org, lgirdwood@gmail.com, Vinod Koul Subject: [alsa-devel] [PATCH v2 3/7] ASoC: hda - add soc hda codec driver wrapper 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 From: Jeeja KP This provides match function for ASoC codec driver based on id_table and driver register/unregister wrapper functions Signed-off-by: Jeeja KP Signed-off-by: Vinod Koul --- sound/soc/codecs/Kconfig | 3 ++ sound/soc/codecs/Makefile | 2 + sound/soc/codecs/soc-hda-codec.c | 79 ++++++++++++++++++++++++++++++++++++++ sound/soc/codecs/soc-hda-codec.h | 43 +++++++++++++++++++++ 4 files changed, 127 insertions(+) create mode 100644 sound/soc/codecs/soc-hda-codec.c create mode 100644 sound/soc/codecs/soc-hda-codec.h diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 061c46587628..4ce30ded2c9c 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -444,6 +444,9 @@ config SND_SOC_ES8328_SPI tristate select SND_SOC_ES8328 +config SND_SOC_HDA_CODEC + tristate "ASOC HDA Codec Core" + config SND_SOC_ISABELLE tristate diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index abe2d7edf65c..5685ec556942 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -55,6 +55,7 @@ snd-soc-dmic-objs := dmic.o snd-soc-es8328-objs := es8328.o snd-soc-es8328-i2c-objs := es8328-i2c.o snd-soc-es8328-spi-objs := es8328-spi.o +snd-soc-hda-codec-objs := soc-hda-codec.o snd-soc-isabelle-objs := isabelle.o snd-soc-jz4740-codec-objs := jz4740.o snd-soc-l3-objs := l3.o @@ -240,6 +241,7 @@ obj-$(CONFIG_SND_SOC_DMIC) += snd-soc-dmic.o obj-$(CONFIG_SND_SOC_ES8328) += snd-soc-es8328.o obj-$(CONFIG_SND_SOC_ES8328_I2C)+= snd-soc-es8328-i2c.o obj-$(CONFIG_SND_SOC_ES8328_SPI)+= snd-soc-es8328-spi.o +obj-$(CONFIG_SND_SOC_HDA_CODEC) += snd-soc-hda-codec.o obj-$(CONFIG_SND_SOC_ISABELLE) += snd-soc-isabelle.o obj-$(CONFIG_SND_SOC_JZ4740_CODEC) += snd-soc-jz4740-codec.o obj-$(CONFIG_SND_SOC_L3) += snd-soc-l3.o diff --git a/sound/soc/codecs/soc-hda-codec.c b/sound/soc/codecs/soc-hda-codec.c new file mode 100644 index 000000000000..46bfddd87a7c --- /dev/null +++ b/sound/soc/codecs/soc-hda-codec.c @@ -0,0 +1,79 @@ +/* + * soc-hda-codec.c ASoC High Definition Audio Codec interface Definitions + * + * Copyright (c) 2014-2015 Intel Corporation + * + * Author(s): Jeeja KP + * + * + * This driver is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This driver is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include "soc-hda-codec.h" + + +/* + * find a matching vendor id + */ +static int hda_codec_match(struct hdac_device *dev, struct hdac_driver *drv) +{ + struct hda_soc_codec_driver *driver = + container_of(drv, struct hda_soc_codec_driver, core); + + if (driver->id_table) { + const struct hda_soc_device_id *id = driver->id_table; + + while (id->name[0]) { + if (dev->vendor_id == id->id) + return 1; + id++; + } + } + return 0; +} + +int snd_soc_hda_codec_driver_register(struct hda_soc_codec_driver *drv) +{ + drv->core.driver.bus = &snd_hda_bus_type; + drv->core.type = HDA_DEV_ASOC; + drv->core.match = hda_codec_match; + return driver_register(&drv->core.driver); +} +EXPORT_SYMBOL_GPL(snd_soc_hda_codec_driver_register); + +void snd_soc_hda_codec_driver_unregister(struct hda_soc_codec_driver *drv) +{ + driver_unregister(&drv->core.driver); +} +EXPORT_SYMBOL_GPL(snd_soc_hda_codec_driver_unregister); + +const struct hda_soc_device_id * +snd_soc_hda_get_device_id( + struct hdac_device *hdev, + struct hda_soc_codec_driver *drv) +{ + if (drv->id_table) { + const struct hda_soc_device_id *id = drv->id_table; + + while (id->name[0]) { + if (hdev->vendor_id == id->id) + return id; + id++; + } + } + return NULL; +} +EXPORT_SYMBOL_GPL(snd_soc_hda_get_device_id); + +MODULE_DESCRIPTION("ASoC HDA codec core"); +MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/codecs/soc-hda-codec.h b/sound/soc/codecs/soc-hda-codec.h new file mode 100644 index 000000000000..6c2d107049bb --- /dev/null +++ b/sound/soc/codecs/soc-hda-codec.h @@ -0,0 +1,43 @@ +/* + * ASoC High Definition Audio Codec interface + * + * Copyright (c) 2015 Intel Corporation + * + * Author(s): Jeeja KP + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + */ + +#include + +/*HDA device table*/ +#define HDA_NAME_SIZE 20 +struct hda_soc_device_id { + __u32 id; + char name[HDA_NAME_SIZE]; + unsigned long driver_data; +}; + +struct hda_soc_codec_driver { + struct hdac_driver core; + const struct hda_soc_device_id *id_table; +}; + +#define to_hdac_driver(drv) (container_of((drv), \ + struct hdac_driver, driver)) +#define to_hda_soc_codec_driver(hdrv) (container_of((hdrv), \ + struct hda_soc_codec_driver, core)) + +int snd_soc_hda_codec_driver_register(struct hda_soc_codec_driver *drv); +void snd_soc_hda_codec_driver_unregister(struct hda_soc_codec_driver *drv); +const struct hda_soc_device_id *snd_soc_hda_get_device_id(struct hdac_device *hdev, + struct hda_soc_codec_driver *drv);