From: Vinod Koul <vinod.koul@intel.com>
To: alsa-devel@alsa-project.org
Cc: tiwai@suse.de, Jeeja KP <jeeja.kp@intel.com>,
broonie@kernel.org, lgirdwood@gmail.com,
Vinod Koul <vinod.koul@intel.com>
Subject: [PATCH v2 3/7] ASoC: hda - add soc hda codec driver wrapper
Date: Fri, 17 Apr 2015 14:43:16 +0530 [thread overview]
Message-ID: <1429262000-21517-4-git-send-email-vinod.koul@intel.com> (raw)
In-Reply-To: <1429262000-21517-1-git-send-email-vinod.koul@intel.com>
From: Jeeja KP <jeeja.kp@intel.com>
This provides match function for ASoC
codec driver based on id_table and driver
register/unregister wrapper functions
Signed-off-by: Jeeja KP <jeeja.kp@intel.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
---
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 <jeeja.kp@intel.com>
+ *
+ *
+ * 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 <linux/module.h>
+#include <sound/hdaudio.h>
+#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 <jeeja.kp@intel.com>
+ *
+ * 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 <sound/hdaudio.h>
+
+/*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);
--
1.7.9.5
next prev parent reply other threads:[~2015-04-17 9:18 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-17 9:13 [PATCH v2 0/7] ASoC: hda - add ASoC Skylake HD audio driver Vinod Koul
2015-04-17 9:13 ` [PATCH v2 1/7] ALSA: hda - add ASoC device type for hda core Vinod Koul
2015-04-17 9:13 ` [PATCH v2 2/7] ALSA: hda - add generic functions to set hdac stream params Vinod Koul
2015-04-17 9:39 ` Takashi Iwai
2015-04-17 11:33 ` Vinod Koul
2015-04-17 9:13 ` Vinod Koul [this message]
2015-04-17 9:42 ` [PATCH v2 3/7] ASoC: hda - add soc hda codec driver wrapper Takashi Iwai
2015-04-17 11:34 ` Vinod Koul
2015-04-17 9:13 ` [PATCH v2 4/7] ASoC: hda - add Skylake platform driver Vinod Koul
2015-04-17 9:57 ` Takashi Iwai
2015-04-17 11:47 ` Takashi Iwai
2015-04-17 11:51 ` Vinod Koul
2015-04-17 9:13 ` [PATCH v2 5/7] ASoC: hda - add Skylake HD audio driver Vinod Koul
2015-04-17 10:06 ` Takashi Iwai
2015-04-17 12:02 ` Vinod Koul
2015-04-19 7:27 ` Takashi Iwai
2015-04-22 3:01 ` Vinod Koul
2015-04-17 9:13 ` [PATCH v2 6/7] ASoC: hda - enable ASoC " Vinod Koul
2015-04-17 9:13 ` [PATCH v2 7/7] ASoC: hda - added Skylake I2S machine driver Vinod Koul
2015-04-17 9:44 ` Lars-Peter Clausen
2015-04-17 19:06 ` Vinod Koul
2015-04-17 19:14 ` Lars-Peter Clausen
2015-04-22 3:00 ` 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=1429262000-21517-4-git-send-email-vinod.koul@intel.com \
--to=vinod.koul@intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=jeeja.kp@intel.com \
--cc=lgirdwood@gmail.com \
--cc=tiwai@suse.de \
/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