Skip to contentSkip to conversation

ASoC: add RT286 CODEC driver

PATCH Superseded [email protected] 3 participants 4 messages Feb 25, 2014

Subsystems (3)

v4 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 ASoC: add RT286 CODEC driver

From: Bard Liao <[email protected]>

This patch adds the ALC286 codec driver.

---

ALC286 is a dual mode codec, which can run as HD-A or I2S mode.
It is controlled by HD-A verb commands via I2C protocol.
The following is the I/O difference between ALC286 and general I2S codecs.
1. A HD-A verb command contains three parts, NID, VID, and PID.
And an I2S command contains only two parts: address and data.
2. Not only the register address is written, but the read command also includes the entire write command.
3. rt286 uses different registers for read and write the same bits. As a result, standard regmap is difficult to be used on ALC286.
We don't request a standard I/O by snd_soc_codec_set_cache_io anymore. Now we have ,reg_write and .reg_read functions for ALC286's I/O. And we don't use cache due to item 3 above.
Some dummy registers (address <= 0xff) are defined for dapm routing. Thhe dummy registers are cache only.
Due to item 2 above, HD-A verb commands are put into the address part of regmap. When we issue HD-A verb write commands, the data part of regmap is zero.

The jack detection function is done by Lewandowski Gustaw. So I add Gustaw's Signed-off-by line in this patch

The difference between this version and previous version is listed below.
* Use regmap_read/write instead of rt286_read/write to read write codec.
* Use the standard jack detection APIs for jack detection.
* Power off on bias level STANDBY.
* Add .symmetric_rates = 1.
* Add gpio2_en and remove irq_en in platform data.
* Other minor changes.

---
 include/sound/rt286.h     |   19 +
 sound/soc/codecs/Kconfig  |    4 +
 sound/soc/codecs/Makefile |    2 +
 sound/soc/codecs/rt286.c  | 1369 +++++++++++++++++++++++++++++++++++++++++++++
 sound/soc/codecs/rt286.h  |  159 ++++++
 5 files changed, 1553 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..eb773d1
@@ -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 gpio2_en; /*GPIO2 enable*/
+};
+
+#endif
sound/soc/codecs/Kconfig +4 -0
index f2383eb..889b69f 100644
@@ -67,6 +67,7 @@ config SND_SOC_ALL_CODECS
 	select SND_SOC_PCM1792A if SPI_MASTER
 	select SND_SOC_PCM3008
 	select SND_SOC_PCM512x if SND_SOC_I2C_AND_SPI
+	select SND_SOC_RT286 if I2C
 	select SND_SOC_RT5631 if I2C
 	select SND_SOC_RT5640 if I2C
 	select SND_SOC_SGTL5000 if I2C
@@ -365,6 +366,9 @@ config SND_SOC_PCM512x
        tristate "Texas Instruments PCM512x CODECs"
        select REGMAP
 
+config SND_SOC_RT286
+	tristate
+
 config SND_SOC_RT5631
 	tristate
 
sound/soc/codecs/Makefile +2 -0
index 6af7a55..2c42f88 100644
@@ -54,6 +54,7 @@ snd-soc-pcm1681-objs := pcm1681.o
 snd-soc-pcm1792a-codec-objs := pcm1792a.o
 snd-soc-pcm3008-objs := pcm3008.o
 snd-soc-pcm512x-objs := pcm512x.o
+snd-soc-rt286-objs := rt286.o
 snd-soc-rt5631-objs := rt5631.o
 snd-soc-rt5640-objs := rt5640.o
 snd-soc-sgtl5000-objs := sgtl5000.o
@@ -197,6 +198,7 @@ obj-$(CONFIG_SND_SOC_PCM1681)	+= snd-soc-pcm1681.o
 obj-$(CONFIG_SND_SOC_PCM1792A)	+= snd-soc-pcm1792a-codec.o
 obj-$(CONFIG_SND_SOC_PCM3008)	+= snd-soc-pcm3008.o
 obj-$(CONFIG_SND_SOC_PCM512x)	+= snd-soc-pcm512x.o
+obj-$(CONFIG_SND_SOC_RT286)	+= snd-soc-rt286.o
 obj-$(CONFIG_SND_SOC_RT5631)	+= snd-soc-rt5631.o
 obj-$(CONFIG_SND_SOC_RT5640)	+= snd-soc-rt5640.o
 obj-$(CONFIG_SND_SOC_SGTL5000)  += snd-soc-sgtl5000.o
sound/soc/codecs/rt286.c new file +1369 -0

1,369 lines not on this page · raw message

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

159 lines not on this page · raw message

Signature · 1 line
1.8.1.1.439.g50a6b54
#1 lore raw

At Tue, 25 Feb 2014 14:59:49 +0800,

Quoted 30 lines · <[email protected]> wrote:

From: Bard Liao <[email protected]>

This patch adds the ALC286 codec driver.

---

ALC286 is a dual mode codec, which can run as HD-A or I2S mode.
It is controlled by HD-A verb commands via I2C protocol.
The following is the I/O difference between ALC286 and general I2S codecs.
1. A HD-A verb command contains three parts, NID, VID, and PID.
And an I2S command contains only two parts: address and data.
2. Not only the register address is written, but the read command also includes the entire write command.
3. rt286 uses different registers for read and write the same bits. As a result, standard regmap is difficult to be used on ALC286.
We don't request a standard I/O by snd_soc_codec_set_cache_io anymore. Now we have ,reg_write and .reg_read functions for ALC286's I/O. And we don't use cache due to item 3 above.
Some dummy registers (address <= 0xff) are defined for dapm routing. Thhe dummy registers are cache only.
Due to item 2 above, HD-A verb commands are put into the address part of regmap. When we issue HD-A verb write commands, the data part of regmap is zero.

The jack detection function is done by Lewandowski Gustaw. So I add Gustaw's Signed-off-by line in this patch

Quoted 7 lines

The difference between this version and previous version is listed below.
* Use regmap_read/write instead of rt286_read/write to read write codec.
* Use the standard jack detection APIs for jack detection.
* Power off on bias level STANDBY.
* Add .symmetric_rates = 1.
* Add gpio2_en and remove irq_en in platform data.
* Other minor changes.

You should put these in the patch changelog. The texts after the line "---" are ignored when applied to git.

Quoted 24 lines
sound/soc/codecs/rt286.c new file +21 -0
@@ -0,0 +1,1369 @@
+/*
+ * 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>

sound/soc/codecs/rt286.c line 31

Quoted 10 lines
sound/soc/codecs/rt286.c new file +10 -0
+#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/jack.h>
+#include <sound/rt286.h>
+
+#include "../../pci/hda/hda_codec.h"

Don't include this header here.
The HD-audio verbs are defined in sound/hda_verbs.h in the usptream tree, so include it instead.

Takashi

author
#2 lore raw
Quoted 4 lines

Don't include this header here.
The HD-audio verbs are defined in sound/hda_verbs.h in the usptream tree, so include it instead.

I will modify it.
Thanks.

Quoted 4 lines

Takashi

------Please consider the environment before printing this e-mail.

#3 lore raw
Quoted 7 lines · Bard Liao
Quoted 4 lines

Don't include this header here.
The HD-audio verbs are defined in sound/hda_verbs.h in the usptream tree, so include it instead.

I will modify it.
Thanks.

Best to make sure it builds too. Can you apply the following diff for v5:-

@@ -1131,16 +1131,16 @@ static int rt286_set_dai_sysclk(struct snd_soc_dai *dai,
rt286->sys_clk = freq;

return 0;
}

-static int rt286_set_dai_dfs(struct snd_soc_dai *dai, unsigned int fs) +static int rt286_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio)
{
struct snd_soc_codec *codec = dai->codec;

- dev_dbg(codec->dev, "%s fs=%d\n", __func__, fs);
- if (50 == fs)
+ dev_dbg(codec->dev, "%s ratio=%d\n", __func__, ratio);
+ if (50 == ratio)
rt286_index_update_bits(codec, RT286_VENDOR_REGISTERS,
RT286_I2S_CTRL1, 0x1000, 0x1000);
else
rt286_index_update_bits(codec, RT286_VENDOR_REGISTERS,
RT286_I2S_CTRL1, 0x1000, 0x0);
@@ -1175,14 +1175,14 @@ static int rt286_set_bias_level(struct snd_soc_codec *codec,
static irqreturn_t rt286_irq(int irq, void *data)
{
struct rt286_priv *rt286 = data;
bool hp = false;
bool mic = false;
+ int status = 0;

rt286_jack_detect(rt286->codec, &hp, &mic);

- int status = 0;
if (hp == true)
status |= SND_JACK_HEADPHONE;

if (mic == true)
status |= SND_JACK_MICROPHONE;
@@ -1257,11 +1257,11 @@ static int rt286_probe(struct snd_soc_codec *codec)

struct snd_soc_dai_ops rt286_aif_dai_ops = {
.hw_params = rt286_hw_params,
.set_fmt = rt286_set_dai_fmt,
.set_sysclk = rt286_set_dai_sysclk,
- .set_dfs = rt286_set_dai_dfs,
+ .set_bclk_ratio = rt286_set_bclk_ratio,
};

struct snd_soc_dai_driver rt286_dai[] = {
{
.name = "rt286-aif1",

---------------------------------------------------------------------
Intel Corporation (UK) Limited
Registered No. 1134945 (England)
Registered Office: Pipers Way, Swindon SN3 1RJ
VAT No: 860 2173 47

This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.