[RFC,v2,10/11] ASoC: patch_realtek: add ASoC based Realtek HDA codec driver patch
diff mbox

Message ID 1512989583-10877-11-git-send-email-rakesh.a.ughreja@intel.com
State New
Headers show

Commit Message

Ughreja, Rakesh A Dec. 11, 2017, 10:53 a.m. UTC
This patch adds support for ASoC HDA codec driver for realtek
codecs.

Signed-off-by: Rakesh Ughreja <rakesh.a.ughreja@intel.com>
---
 sound/pci/hda/patch_realtek.c    |  3 ++-
 sound/soc/codecs/Kconfig         |  6 +++++
 sound/soc/codecs/Makefile        |  2 ++
 sound/soc/codecs/patch_realtek.c | 48 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 58 insertions(+), 1 deletion(-)
 create mode 100644 sound/soc/codecs/patch_realtek.c

Patch
diff mbox

diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 921a10e..88a965c 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -7903,7 +7903,7 @@  static int patch_alc680(struct hda_codec *codec)
 /*
  * patch entries
  */
-static const struct hda_device_id snd_hda_id_realtek[] = {
+const struct hda_device_id snd_hda_id_realtek[] = {
 	HDA_CODEC_ENTRY(0x10ec0215, "ALC215", patch_alc269),
 	HDA_CODEC_ENTRY(0x10ec0221, "ALC221", patch_alc269),
 	HDA_CODEC_ENTRY(0x10ec0225, "ALC225", patch_alc269),
@@ -7974,6 +7974,7 @@  static const struct hda_device_id snd_hda_id_realtek[] = {
 	HDA_CODEC_ENTRY(0x10ec1220, "ALC1220", patch_alc882),
 	{} /* terminator */
 };
+EXPORT_SYMBOL_GPL(snd_hda_id_realtek);
 MODULE_DEVICE_TABLE(hdaudio, snd_hda_id_realtek);
 
 MODULE_LICENSE("GPL");
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index 1d41d11..97fd997 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -80,6 +80,7 @@  config SND_SOC_ALL_CODECS
 	select SND_SOC_GTM601
 	select SND_SOC_HDAC_HDMI
 	select SND_SOC_HDAC_HDA
+	select SND_SOC_HDA_REALTEK
 	select SND_SOC_ICS43432
 	select SND_SOC_INNO_RK3036
 	select SND_SOC_ISABELLE if I2C
@@ -587,6 +588,11 @@  config SND_SOC_HDAC_HDA
 	select SND_HDA_EXT_CORE
 	select SND_PCM_ELD
 
+config SND_SOC_HDA_REALTEK
+	select SND_HDA_CODEC_REALTEK
+	select SND_SOC_HDAC_HDA
+	tristate "Realtek ASoC HDA Codec Driver patch"
+
 config SND_SOC_ICS43432
 	tristate
 
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
index dd5f90f..158ee89 100644
--- a/sound/soc/codecs/Makefile
+++ b/sound/soc/codecs/Makefile
@@ -102,6 +102,7 @@  snd-soc-nau8810-objs := nau8810.o
 snd-soc-nau8824-objs := nau8824.o
 snd-soc-nau8825-objs := nau8825.o
 snd-soc-hdmi-codec-objs := hdmi-codec.o
+snd-soc-patch_realtek-objs := patch_realtek.o
 snd-soc-pcm1681-objs := pcm1681.o
 snd-soc-pcm179x-codec-objs := pcm179x.o
 snd-soc-pcm179x-i2c-objs := pcm179x-i2c.o
@@ -319,6 +320,7 @@  obj-$(CONFIG_SND_SOC_ES8328_SPI)+= snd-soc-es8328-spi.o
 obj-$(CONFIG_SND_SOC_GTM601)    += snd-soc-gtm601.o
 obj-$(CONFIG_SND_SOC_HDAC_HDMI) += snd-soc-hdac-hdmi.o
 obj-$(CONFIG_SND_SOC_HDAC_HDA) += snd-soc-hdac-hda.o
+obj-$(CONFIG_SND_SOC_HDA_REALTEK)	+= snd-soc-patch_realtek.o
 obj-$(CONFIG_SND_SOC_ICS43432)	+= snd-soc-ics43432.o
 obj-$(CONFIG_SND_SOC_INNO_RK3036)	+= snd-soc-inno-rk3036.o
 obj-$(CONFIG_SND_SOC_ISABELLE)	+= snd-soc-isabelle.o
diff --git a/sound/soc/codecs/patch_realtek.c b/sound/soc/codecs/patch_realtek.c
new file mode 100644
index 0000000..80772c3
--- /dev/null
+++ b/sound/soc/codecs/patch_realtek.c
@@ -0,0 +1,48 @@ 
+/*
+ * Universal Interface for Intel High Definition Audio Codec
+ *
+ * ASoC HD audio interface patch for Realtek ALC codecs
+ *
+ * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
+ *                    PeiSen Hou <pshou@realtek.com.tw>
+ *                    Takashi Iwai <tiwai@suse.de>
+ *                    Jonathan Woithe <jwoithe@just42.net>
+ *
+ *  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.
+ */
+
+/*
+ * license header and copyright is copy/pasted from the legacy realtek HDA
+ * driver, is that fine or I need to create a new one?
+ */
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <sound/soc.h>
+#include <sound/hdaudio_ext.h>
+#include "../../pci/hda/hda_codec.h"
+#include "hdac_hda.h"
+
+/*
+ * Is snd_hda_id_realtek okay to keep it here or better to move into
+ * hda_codec.h file?
+ * Is it okay to define this as extern ?
+ */
+extern struct hda_device_id snd_hda_id_realtek[];
+
+static struct hdac_driver realtek_driver = {
+	.id_table = snd_hda_id_realtek,
+};
+
+module_hdac_hda_codec_driver(realtek_driver);
+
+MODULE_DESCRIPTION("Realtek ASoC HDA Codec driver");
+MODULE_LICENSE("GPL");