alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Vinod Koul <vinod.koul@intel.com>
To: alsa-devel@alsa-project.org
Cc: tiwai@suse.de, patches.audio@intel.com,
	liam.r.girdwood@linux.intel.com,
	Vinod Koul <vinod.koul@intel.com>,
	broonie@kernel.org, Jeeja KP <jeeja.kp@intel.com>
Subject: [PATCH v4 1/7] ASoC: hda - add ASoC HDA codec match function
Date: Mon, 11 May 2015 16:23:59 +0530	[thread overview]
Message-ID: <1431341645-2457-2-git-send-email-vinod.koul@intel.com> (raw)
In-Reply-To: <1431341645-2457-1-git-send-email-vinod.koul@intel.com>

From: Jeeja KP <jeeja.kp@intel.com>

ASoC hda codec driver will use id_table for registration.
id_table has info of codec vendor_id, revision_id and name.
For ASoC device/driver matching, device vendor_id, rev_id
will be matched to id_table to identify the device/driver.

Signed-off-by: Jeeja KP <jeeja.kp@intel.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
---
 include/sound/soc-hda-codec.h | 49 ++++++++++++++++++++++++
 sound/soc/Kconfig             |  1 +
 sound/soc/Makefile            |  1 +
 sound/soc/hda/Kconfig         |  3 ++
 sound/soc/hda/Makefile        |  3 ++
 sound/soc/hda/soc-hda-codec.c | 89 +++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 146 insertions(+)
 create mode 100644 include/sound/soc-hda-codec.h
 create mode 100644 sound/soc/hda/Kconfig
 create mode 100644 sound/soc/hda/Makefile
 create mode 100644 sound/soc/hda/soc-hda-codec.c

diff --git a/include/sound/soc-hda-codec.h b/include/sound/soc-hda-codec.h
new file mode 100644
index 000000000000..850430a3855b
--- /dev/null
+++ b/include/sound/soc-hda-codec.h
@@ -0,0 +1,49 @@
+/*
+ * ASoC High Definition Audio Codec interface Definitions
+ *
+ * Copyright (c) 2014-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.
+ *
+ */
+
+#ifndef __SOUND_SOC_HDA_CODEC_H
+#define __SOUND_SOC_HDA_CODEC_H
+
+#include <sound/hdaudio.h>
+
+/* HDA device table */
+#define HDA_NAME_SIZE      20
+struct soc_hda_device_id {
+	__u32 id;
+	__u32 rev_id;
+	char name[HDA_NAME_SIZE];
+	unsigned long driver_data;
+};
+
+struct soc_hda_codec_driver {
+	struct hdac_driver core;
+	const struct soc_hda_device_id *id_table;
+};
+
+#define to_hdac_driver(drv) (container_of((drv), \
+				 struct hdac_driver, driver))
+#define to_soc_hda_codec_driver(hdrv) (container_of((hdrv), \
+				 struct soc_hda_codec_driver, core))
+
+int snd_soc_hda_codec_driver_register(struct soc_hda_codec_driver *drv);
+void snd_soc_hda_codec_driver_unregister(struct soc_hda_codec_driver *drv);
+const struct soc_hda_device_id *snd_soc_hda_get_device_id(
+	struct hdac_device *hdev, struct soc_hda_codec_driver *drv);
+
+#endif
diff --git a/sound/soc/Kconfig b/sound/soc/Kconfig
index 3ba52da18bc6..d3903580cb10 100644
--- a/sound/soc/Kconfig
+++ b/sound/soc/Kconfig
@@ -40,6 +40,7 @@ source "sound/soc/cirrus/Kconfig"
 source "sound/soc/davinci/Kconfig"
 source "sound/soc/dwc/Kconfig"
 source "sound/soc/fsl/Kconfig"
+source "sound/soc/hda/Kconfig"
 source "sound/soc/jz4740/Kconfig"
 source "sound/soc/nuc900/Kconfig"
 source "sound/soc/omap/Kconfig"
diff --git a/sound/soc/Makefile b/sound/soc/Makefile
index 974ba708b482..8741d6a38bf6 100644
--- a/sound/soc/Makefile
+++ b/sound/soc/Makefile
@@ -21,6 +21,7 @@ obj-$(CONFIG_SND_SOC)	+= cirrus/
 obj-$(CONFIG_SND_SOC)	+= davinci/
 obj-$(CONFIG_SND_SOC)	+= dwc/
 obj-$(CONFIG_SND_SOC)	+= fsl/
+obj-$(CONFIG_SND_SOC)	+= hda/
 obj-$(CONFIG_SND_SOC)	+= jz4740/
 obj-$(CONFIG_SND_SOC)	+= intel/
 obj-$(CONFIG_SND_SOC)	+= mxs/
diff --git a/sound/soc/hda/Kconfig b/sound/soc/hda/Kconfig
new file mode 100644
index 000000000000..815943360bc5
--- /dev/null
+++ b/sound/soc/hda/Kconfig
@@ -0,0 +1,3 @@
+config SND_SOC_HDA_CORE
+	tristate
+	select SND_HDA_CORE
diff --git a/sound/soc/hda/Makefile b/sound/soc/hda/Makefile
new file mode 100644
index 000000000000..9585ab180a55
--- /dev/null
+++ b/sound/soc/hda/Makefile
@@ -0,0 +1,3 @@
+snd-soc-hda-core-objs := soc-hda-codec.o
+
+obj-$(CONFIG_SND_SOC_HDA_CORE) += snd-soc-hda-core.o
diff --git a/sound/soc/hda/soc-hda-codec.c b/sound/soc/hda/soc-hda-codec.c
new file mode 100644
index 000000000000..90c8fa53e2cc
--- /dev/null
+++ b/sound/soc/hda/soc-hda-codec.c
@@ -0,0 +1,89 @@
+/*
+ * 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 <sound/soc-hda-codec.h>
+
+/**
+ * snd_soc_hda_get_device_id - gets the hdac device id entry
+ * @hdev: HD-audio core device
+ * @drv: HD-audio soc codec driver
+ *
+ * Compares the hdac device vendor_id and revision_id to the hdac_soc_codec
+ * driver id_table and returns the matching device id entry.
+ */
+const struct soc_hda_device_id *
+snd_soc_hda_get_device_id(struct hdac_device *hdev,
+				struct soc_hda_codec_driver *drv)
+{
+	if (drv->id_table) {
+		const struct soc_hda_device_id *id  = drv->id_table;
+
+		while (id->name[0]) {
+			if (hdev->vendor_id == id->id &&
+				(!id->rev_id || id->rev_id == hdev->revision_id))
+				return id;
+			id++;
+		}
+	}
+	return NULL;
+}
+EXPORT_SYMBOL_GPL(snd_soc_hda_get_device_id);
+
+/**
+ * soc_hda_codec_match - ASoC HDA codec match function
+ * @dev: HD-audio core device
+ * @@drv: HD-audio soc codec driver
+ *
+ * This tries to match the hdac device with hdac driver and return 1 on
+ * match, 0 otherwise
+ */
+static int soc_hda_codec_match(struct hdac_device *dev, struct hdac_driver *drv)
+{
+	struct soc_hda_codec_driver *driver = to_soc_hda_codec_driver(drv);
+
+	if (snd_soc_hda_get_device_id(dev, driver))
+		return 1;
+	else
+		return 0;
+}
+
+/**
+ * snd_soc_hda_codec_driver_register - register hda codec driver
+ * @drv: HD Audio soc codec driver
+ */
+int snd_soc_hda_codec_driver_register(struct soc_hda_codec_driver *drv)
+{
+	drv->core.driver.bus = &snd_hda_bus_type;
+	drv->core.type = HDA_DEV_ASOC;
+	drv->core.match = soc_hda_codec_match;
+	return driver_register(&drv->core.driver);
+}
+EXPORT_SYMBOL_GPL(snd_soc_hda_codec_driver_register);
+
+/**
+ * snd_soc_hda_codec_driver_unregister - unregister hda codec driver
+ * @drv: HD Audio soc codec driver
+ */
+void snd_soc_hda_codec_driver_unregister(struct soc_hda_codec_driver *drv)
+{
+	driver_unregister(&drv->core.driver);
+}
+EXPORT_SYMBOL_GPL(snd_soc_hda_codec_driver_unregister);
-- 
1.9.1

  reply	other threads:[~2015-05-11 10:53 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-11 10:53 [PATCH v4 0/7] ASoC: intel - add skylake PCM driver Vinod Koul
2015-05-11 10:53 ` Vinod Koul [this message]
2015-05-22 12:56   ` [PATCH v4 1/7] ASoC: hda - add ASoC HDA codec match function Mark Brown
2015-05-22 13:35     ` Takashi Iwai
2015-05-22 17:41       ` Mark Brown
2015-05-22 18:13         ` Takashi Iwai
2015-05-23  5:51           ` Vinod Koul
2015-05-25 10:48             ` Mark Brown
2015-05-25 11:21               ` Vinod Koul
2015-05-25 11:55                 ` Takashi Iwai
2015-05-25 13:58                   ` Mark Brown
2015-05-26  5:24                     ` Takashi Iwai
2015-05-26 13:32                       ` Mark Brown
2015-05-26 13:41                         ` Takashi Iwai
2015-05-26 19:43                           ` Mark Brown
2015-05-27  6:05                             ` Takashi Iwai
2015-05-27 18:34                               ` Mark Brown
2015-05-27 19:17                                 ` Takashi Iwai
2015-05-28 19:53                                   ` Mark Brown
2015-05-29  4:58                                     ` Takashi Iwai
2015-05-29  8:15                                       ` Vinod Koul
2015-05-29 17:35                                         ` Mark Brown
2015-06-01  5:05                                           ` Vinod Koul
2015-06-02 10:38                                             ` Mark Brown
2015-06-02 12:25                                               ` Vinod Koul
2015-05-11 10:54 ` [PATCH v4 2/7] ALSA: hda - add new HDA registers Vinod Koul
2015-05-22 12:58   ` Mark Brown
2015-05-22 13:32     ` Takashi Iwai
2015-05-11 10:54 ` [PATCH v4 3/7] ASoC: hda - add asoc hda core bus, controller and stream helpers Vinod Koul
2015-05-26 18:51   ` Mark Brown
2015-05-27  5:40     ` Vinod Koul
2015-05-11 10:54 ` [PATCH v4 4/7] ASoC: intel - add Skylake HDA platform driver Vinod Koul
2015-05-11 10:54 ` [PATCH v4 5/7] ASoC: intel - add Skylake HDA audio driver Vinod Koul
2015-05-29 17:41   ` Mark Brown
2015-05-29 18:25     ` Takashi Iwai
2015-06-02 10:45       ` Mark Brown
2015-06-02 10:53         ` Takashi Iwai
2015-06-02 11:07           ` Mark Brown
2015-06-02 11:57             ` Takashi Iwai
2015-06-02 12:39             ` Vinod Koul
2015-06-02 14:30               ` Mark Brown
2015-06-01  5:13     ` Vinod Koul
2015-06-01  5:32       ` Takashi Iwai
2015-06-02 10:42         ` Mark Brown
2015-06-02 10:48           ` Takashi Iwai
2015-06-02 11:10             ` Mark Brown
2015-06-02 11:44               ` Takashi Iwai
2015-06-02 12:29                 ` Vinod Koul
2015-05-11 10:54 ` [PATCH v4 6/7] ASoC: intel - add makefile support for SKL driver Vinod Koul
2015-05-11 10:54 ` [PATCH v4 7/7] ASoC: intel - adds support for decoupled mode in skl driver Vinod Koul
2015-05-22 12:20 ` [PATCH v4 0/7] ASoC: intel - add skylake PCM driver Vinod Koul
2015-05-22 13:12   ` Mark Brown
2015-05-25  6:57 ` Takashi Iwai
2015-05-25 11:24   ` Vinod Koul
2015-05-25 11:58     ` Takashi Iwai
2015-05-26  4:14       ` Vinod Koul
2015-05-26  5:27         ` 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=1431341645-2457-2-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=liam.r.girdwood@linux.intel.com \
    --cc=patches.audio@intel.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;
as well as URLs for NNTP newsgroup(s).