Skip to contentSkip to conversation

ASoC: add RT286 CODEC driver

PATCH Superseded [email protected] 2 participants 4 messages Dec 4, 2013 – Dec 10, 2013 1 message not in the archive

Subsystems (3)

v2 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ASoC: add RT286 CODEC driver

From: Bard Liao <[email protected]>

This patch adds the ALC286 codec driver.

---

This is the initial codec driver of ALC286.
I tested Headset recording and Speaker playback.
I tested with snd_soc_register_codec because my kernel doesn't support devm_snd_soc_register_codec yet.

---
 include/sound/rt286.h     |   19 +
 sound/soc/codecs/Kconfig  |    4 +
 sound/soc/codecs/Makefile |    2 +
 sound/soc/codecs/rt286.c  | 1367 +++++++++++++++++++++++++++++++++++++++++++++
 sound/soc/codecs/rt286.h  |   89 +++
 5 files changed, 1481 insertions(+)
 create mode 100644 include/sound/rt286.h
 create mode 100644 sound/soc/codecs/rt286.c
 create mode 100644 sound/soc/codecs/rt286.h
include/sound/rt286.h new file +19 -0
new file mode 100644
index 0000000..6c0c1c9
@@ -0,0 +1,19 @@
+/*
+ * linux/sound/rt286.h -- Platform data for RT286
+ *
+ * Copyright 2013 Realtek Microelectronics
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __LINUX_SND_RT286_H
+#define __LINUX_SND_RT286_H
+
+struct rt286_platform_data {
+	bool cbj_en; /*combo jack enable*/
+	bool irq_en; /*IRQ enable*/
+};
+
+#endif
sound/soc/codecs/Kconfig +4 -0
index 983d087a..755a39d 100644
@@ -61,6 +61,7 @@ config SND_SOC_ALL_CODECS
 	select SND_SOC_PCM3008
 	select SND_SOC_RT5631 if I2C
 	select SND_SOC_RT5640 if I2C
+	select SND_SOC_RT286 if I2C
 	select SND_SOC_SGTL5000 if I2C
 	select SND_SOC_SI476X if MFD_SI476X_CORE
 	select SND_SOC_SN95031 if INTEL_SCU_IPC
@@ -319,6 +320,9 @@ config SND_SOC_RT5631
 config SND_SOC_RT5640
 	tristate
 
+config SND_SOC_RT286
+	tristate
+
 #Freescale sgtl5000 codec
 config SND_SOC_SGTL5000
 	tristate
sound/soc/codecs/Makefile +2 -0
index bc12676..b31615c 100644
@@ -48,6 +48,7 @@ snd-soc-pcm1792a-codec-objs := pcm1792a.o
 snd-soc-pcm3008-objs := pcm3008.o
 snd-soc-rt5631-objs := rt5631.o
 snd-soc-rt5640-objs := rt5640.o
+snd-soc-rt286-objs := rt286.o
 snd-soc-sgtl5000-objs := sgtl5000.o
 snd-soc-alc5623-objs := alc5623.o
 snd-soc-alc5632-objs := alc5632.o
@@ -181,6 +182,7 @@ obj-$(CONFIG_SND_SOC_PCM1792A)	+= snd-soc-pcm1792a-codec.o
 obj-$(CONFIG_SND_SOC_PCM3008)	+= snd-soc-pcm3008.o
 obj-$(CONFIG_SND_SOC_RT5631)	+= snd-soc-rt5631.o
 obj-$(CONFIG_SND_SOC_RT5640)	+= snd-soc-rt5640.o
+obj-$(CONFIG_SND_SOC_RT286)	+= snd-soc-rt286.o
 obj-$(CONFIG_SND_SOC_SGTL5000)  += snd-soc-sgtl5000.o
 obj-$(CONFIG_SND_SOC_SIGMADSP)	+= snd-soc-sigmadsp.o
 obj-$(CONFIG_SND_SOC_SI476X)	+= snd-soc-si476x.o
sound/soc/codecs/rt286.c new file +1367 -0

1,367 lines not on this page · raw message

sound/soc/codecs/rt286.h new file +89 -0

89 lines not on this page · raw message

Signature · 1 line
1.8.1.1.439.g50a6b54
#1 lore raw
Quoted 6 lines · On Wed, Dec 4, 2013 at 3:41 PM, <[email protected]> wrote:

From: Bard Liao <[email protected]>

This patch adds the ALC286 codec driver.

Please add change log while you are sending verX patch.

Quoted 119 lines

---

This is the initial codec driver of ALC286.
I tested Headset recording and Speaker playback.
I tested with snd_soc_register_codec because my kernel doesn't support devm_snd_soc_register_codec yet.

---
 include/sound/rt286.h     |   19 +
 sound/soc/codecs/Kconfig  |    4 +
 sound/soc/codecs/Makefile |    2 +
 sound/soc/codecs/rt286.c  | 1367 +++++++++++++++++++++++++++++++++++++++++++++
 sound/soc/codecs/rt286.h  |   89 +++
 5 files changed, 1481 insertions(+)
 create mode 100644 include/sound/rt286.h
 create mode 100644 sound/soc/codecs/rt286.c
 create mode 100644 sound/soc/codecs/rt286.h
include/sound/rt286.h new file +19 -0
new file mode 100644
index 0000000..6c0c1c9
@@ -0,0 +1,19 @@
+/*
+ * linux/sound/rt286.h -- Platform data for RT286
+ *
+ * Copyright 2013 Realtek Microelectronics
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __LINUX_SND_RT286_H
+#define __LINUX_SND_RT286_H
+
+struct rt286_platform_data {
+       bool cbj_en; /*combo jack enable*/
+       bool irq_en; /*IRQ enable*/
+};
+
+#endif
sound/soc/codecs/Kconfig +4 -0
index 983d087a..755a39d 100644
@@ -61,6 +61,7 @@ config SND_SOC_ALL_CODECS
        select SND_SOC_PCM3008
        select SND_SOC_RT5631 if I2C
        select SND_SOC_RT5640 if I2C
+       select SND_SOC_RT286 if I2C
        select SND_SOC_SGTL5000 if I2C
        select SND_SOC_SI476X if MFD_SI476X_CORE
        select SND_SOC_SN95031 if INTEL_SCU_IPC
@@ -319,6 +320,9 @@ config SND_SOC_RT5631
 config SND_SOC_RT5640
        tristate
 
+config SND_SOC_RT286
+       tristate
+
 #Freescale sgtl5000 codec
 config SND_SOC_SGTL5000
        tristate
sound/soc/codecs/Makefile +2 -0
index bc12676..b31615c 100644
@@ -48,6 +48,7 @@ snd-soc-pcm1792a-codec-objs := pcm1792a.o
 snd-soc-pcm3008-objs := pcm3008.o
 snd-soc-rt5631-objs := rt5631.o
 snd-soc-rt5640-objs := rt5640.o
+snd-soc-rt286-objs := rt286.o
 snd-soc-sgtl5000-objs := sgtl5000.o
 snd-soc-alc5623-objs := alc5623.o
 snd-soc-alc5632-objs := alc5632.o
@@ -181,6 +182,7 @@ obj-$(CONFIG_SND_SOC_PCM1792A)      += snd-soc-pcm1792a-codec.o
 obj-$(CONFIG_SND_SOC_PCM3008)  += snd-soc-pcm3008.o
 obj-$(CONFIG_SND_SOC_RT5631)   += snd-soc-rt5631.o
 obj-$(CONFIG_SND_SOC_RT5640)   += snd-soc-rt5640.o
+obj-$(CONFIG_SND_SOC_RT286)    += snd-soc-rt286.o
 obj-$(CONFIG_SND_SOC_SGTL5000)  += snd-soc-sgtl5000.o
 obj-$(CONFIG_SND_SOC_SIGMADSP) += snd-soc-sigmadsp.o
 obj-$(CONFIG_SND_SOC_SI476X)   += snd-soc-si476x.o
sound/soc/codecs/rt286.c new file +29 -0
new file mode 100644
index 0000000..e7aef0d
@@ -0,0 +1,1367 @@
+/*
+ * rt286.c  --  RT286 ALSA SoC audio codec driver
+ *
+ * Copyright 2013 Realtek Semiconductor Corp.
+ * Author: Bard Liao <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/init.h>
+#include <linux/delay.h>
+#include <linux/pm.h>
+#include <linux/i2c.h>
+#include <linux/platform_device.h>
+#include <linux/spi/spi.h>
+#include <linux/acpi.h>
+#include <sound/core.h>
+#include <sound/pcm.h>
+#include <sound/pcm_params.h>
+#include <sound/soc.h>
+#include <sound/soc-dapm.h>
+#include <sound/initval.h>
+#include <sound/tlv.h>
+#include <sound/rt286.h>
+

sound/soc/codecs/rt286.c line 39

Quoted 10 lines
sound/soc/codecs/rt286.c new file +10 -0
+#include "../../pci/hda/hda_codec.h"
+#include "rt286.h"
+
+struct rt286_priv {
+       struct regmap *regmap;
+       struct rt286_platform_data pdata;
+       int sys_clk;
+};
+
+static unsigned int rt286_reg_cache[TOTAL_NODE_ID + 1] = {

You don't need TOTAL_NODE_ID + 1 in array declaration.

Quoted 14 lines
sound/soc/codecs/rt286.c new file +14 -0
+       [NODE_ID_DAC_OUT1] = 0x7f7f,
+       [NODE_ID_DAC_OUT2] = 0x7f7f,
+       [NODE_ID_SPDIF] = 0x0000,
+       [NODE_ID_ADC_IN1] = 0x4343,
+       [NODE_ID_ADC_IN2] = 0x4343,
+       [NODE_ID_MIC1] = 0x0000,
+       [NODE_ID_MIXER_IN] = 0x000b,
+       [NODE_ID_MIXER_OUT1] = 0x0002,
+       [NODE_ID_MIXER_OUT2] = 0x0000,
+       [NODE_ID_SPK_OUT] = 0x0000,
+       [NODE_ID_HP_OUT] = 0x0000,
+       [NODE_ID_MIXER_IN1] = 0x0000,
+       [NODE_ID_MIXER_IN2] = 0x0000,
+};

A message that is not in the archive (sent off-list or not yet received): [email protected]

author
#3 lore raw
Quoted 9 lines

-----Original Message-----
From: Leon Romanovsky [mailto:[email protected]]
Sent: Wednesday, December 04, 2013 10:37 PM
To: Bard Liao
Cc: Mark Brown; Liam Girdwood; Oder Chiou; [email protected]; Flove
Subject: Re: [alsa-devel] [PATCH V2] ASoC: add RT286 CODEC driver

On Wed, Dec 4, 2013 at 3:41 PM, <[email protected]> wrote:

Quoted 8 lines
Quoted 6 lines

From: Bard Liao <[email protected]>

This patch adds the ALC286 codec driver.

Please add change log while you are sending verX patch.

Please see the change log as below.
* Add platform data to determine if combo jack and/or IRQ is using or not.
* Implement rt286_hw_read/write in regmap.
* Configure codec in runtime instead of in probe.
* Other minor changes (coding style, remove version control, remove empty functions, share code ...)

Should I send another patch with these change log?

Quoted 5 lines

Review

Quoted 4 lines
(quoted diff) +2 -0
+
+static unsigned int rt286_reg_cache[TOTAL_NODE_ID + 1] = {

You don't need TOTAL_NODE_ID + 1 in array declaration.

Without "TOTAL_NODE_ID + 1", I should always set [NODE_ID_MIXER_IN2] = 0x0000, right? Ie. Assign the latest array item a value.

Quoted 15 lines
Quoted 5 lines
sound/soc/codecs/rt286.c new file +4 -0
+       [NODE_ID_DAC_OUT1] = 0x7f7f,
+       [NODE_ID_DAC_OUT2] = 0x7f7f,
+       [NODE_ID_SPDIF] = 0x0000,
+       [NODE_ID_ADC_IN1] = 0x4343,

sound/soc/codecs/rt286.c line 53

Quoted 10 lines
sound/soc/codecs/rt286.c new file +10 -0
+       [NODE_ID_ADC_IN2] = 0x4343,
+       [NODE_ID_MIC1] = 0x0000,
+       [NODE_ID_MIXER_IN] = 0x000b,
+       [NODE_ID_MIXER_OUT1] = 0x0002,
+       [NODE_ID_MIXER_OUT2] = 0x0000,
+       [NODE_ID_SPK_OUT] = 0x0000,
+       [NODE_ID_HP_OUT] = 0x0000,
+       [NODE_ID_MIXER_IN1] = 0x0000,
+       [NODE_ID_MIXER_IN2] = 0x0000,
+};

Thanks.

#4 lore raw
Quoted 18 lines · Bard Liao
Quoted 9 lines

-----Original Message-----
From: Leon Romanovsky [mailto:[email protected]]
Sent: Wednesday, December 04, 2013 10:37 PM
To: Bard Liao
Cc: Mark Brown; Liam Girdwood; Oder Chiou; [email protected]; Flove
Subject: Re: [alsa-devel] [PATCH V2] ASoC: add RT286 CODEC driver

On Wed, Dec 4, 2013 at 3:41 PM, <[email protected]> wrote:

Quoted 8 lines
Quoted 6 lines

From: Bard Liao <[email protected]>

This patch adds the ALC286 codec driver.

Please add change log while you are sending verX patch.

Quoted 7 lines

Please see the change log as below.
* Add platform data to determine if combo jack and/or IRQ is using or not.
* Implement rt286_hw_read/write in regmap.
* Configure codec in runtime instead of in probe.
* Other minor changes (coding style, remove version control, remove empty functions, share code ...)

Should I send another patch with these change log?

I don't think so, just remember it for future submissions.

Quoted 24 lines
Quoted 5 lines

Review

Quoted 4 lines
(quoted diff) +2 -0
+
+static unsigned int rt286_reg_cache[TOTAL_NODE_ID + 1] = {

You don't need TOTAL_NODE_ID + 1 in array declaration.

Without "TOTAL_NODE_ID + 1", I should always set [NODE_ID_MIXER_IN2] = 0x0000, right? Ie. Assign the latest array item a value.

Quoted 15 lines
Quoted 15 lines
sound/soc/codecs/rt286.c new file +14 -0
+       [NODE_ID_DAC_OUT1] = 0x7f7f,
+       [NODE_ID_DAC_OUT2] = 0x7f7f,
+       [NODE_ID_SPDIF] = 0x0000,
+       [NODE_ID_ADC_IN1] = 0x4343,
+       [NODE_ID_ADC_IN2] = 0x4343,
+       [NODE_ID_MIC1] = 0x0000,
+       [NODE_ID_MIXER_IN] = 0x000b,
+       [NODE_ID_MIXER_OUT1] = 0x0002,
+       [NODE_ID_MIXER_OUT2] = 0x0000,
+       [NODE_ID_SPK_OUT] = 0x0000,
+       [NODE_ID_HP_OUT] = 0x0000,
+       [NODE_ID_MIXER_IN1] = 0x0000,
+       [NODE_ID_MIXER_IN2] = 0x0000,
+};

1. static variable is always initialized to 0x0 by C standard.
2. It is better to initialize all cache registers in one place (rt286_reg_cache), including zero values. In such case TOTAL_NODE_ID + 1 is redundant.

Quoted 3 lines

Thanks.

Signature · 2 lines
Leon Romanovsky | Independent Linux Consultant
        www.leon.nu | [email protected]