Skip to content

Commit 93bd813

Browse files
Jack Yubroonie
authored andcommitted
ASoC: rt1015: add delay to fix pop noise from speaker
Add delay to fix pop noise from speaker. Signed-off-by: Jack Yu <jack.yu@realtek.com> Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Link: https://lore.kernel.org/r/20201105030804.31115-1-jack.yu@realtek.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent f9d7c6e commit 93bd813

4 files changed

Lines changed: 43 additions & 0 deletions

File tree

Documentation/devicetree/bindings/sound/rt1015.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,16 @@ Required properties:
88

99
- reg : The I2C address of the device.
1010

11+
Optional properties:
12+
13+
- realtek,power-up-delay-ms
14+
Set a delay time for flush work to be completed,
15+
this value is adjustable depending on platform.
1116

1217
Example:
1318

1419
rt1015: codec@28 {
1520
compatible = "realtek,rt1015";
1621
reg = <0x28>;
22+
realtek,power-up-delay-ms = <50>;
1723
};

include/sound/rt1015.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/* SPDX-License-Identifier: GPL-2.0-only */
2+
/*
3+
* linux/sound/rt1015.h -- Platform data for RT1015
4+
*
5+
* Copyright 2020 Realtek Microelectronics
6+
*/
7+
8+
#ifndef __LINUX_SND_RT1015_H
9+
#define __LINUX_SND_RT1015_H
10+
11+
struct rt1015_platform_data {
12+
unsigned int power_up_delay_ms;
13+
};
14+
15+
#endif

sound/soc/codecs/rt1015.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,15 @@
2727
#include <sound/soc-dapm.h>
2828
#include <sound/soc.h>
2929
#include <sound/tlv.h>
30+
#include <sound/rt1015.h>
3031

3132
#include "rl6231.h"
3233
#include "rt1015.h"
3334

35+
static const struct rt1015_platform_data i2s_default_platform_data = {
36+
.power_up_delay_ms = 50,
37+
};
38+
3439
static const struct reg_default rt1015_reg[] = {
3540
{ 0x0000, 0x0000 },
3641
{ 0x0004, 0xa000 },
@@ -650,6 +655,7 @@ static int rt1015_amp_drv_event(struct snd_soc_dapm_widget *w,
650655
case SND_SOC_DAPM_POST_PMU:
651656
if (rt1015->hw_config == RT1015_HW_28)
652657
schedule_delayed_work(&rt1015->flush_work, msecs_to_jiffies(10));
658+
msleep(rt1015->pdata.power_up_delay_ms);
653659
break;
654660
default:
655661
break;
@@ -1067,9 +1073,16 @@ static struct acpi_device_id rt1015_acpi_match[] = {
10671073
MODULE_DEVICE_TABLE(acpi, rt1015_acpi_match);
10681074
#endif
10691075

1076+
static void rt1015_parse_dt(struct rt1015_priv *rt1015, struct device *dev)
1077+
{
1078+
device_property_read_u32(dev, "realtek,power-up-delay-ms",
1079+
&rt1015->pdata.power_up_delay_ms);
1080+
}
1081+
10701082
static int rt1015_i2c_probe(struct i2c_client *i2c,
10711083
const struct i2c_device_id *id)
10721084
{
1085+
struct rt1015_platform_data *pdata = dev_get_platdata(&i2c->dev);
10731086
struct rt1015_priv *rt1015;
10741087
int ret;
10751088
unsigned int val;
@@ -1081,6 +1094,13 @@ static int rt1015_i2c_probe(struct i2c_client *i2c,
10811094

10821095
i2c_set_clientdata(i2c, rt1015);
10831096

1097+
rt1015->pdata = i2s_default_platform_data;
1098+
1099+
if (pdata)
1100+
rt1015->pdata = *pdata;
1101+
else
1102+
rt1015_parse_dt(rt1015, &i2c->dev);
1103+
10841104
rt1015->regmap = devm_regmap_init_i2c(i2c, &rt1015_regmap);
10851105
if (IS_ERR(rt1015->regmap)) {
10861106
ret = PTR_ERR(rt1015->regmap);

sound/soc/codecs/rt1015.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#ifndef __RT1015_H__
1414
#define __RT1015_H__
15+
#include <sound/rt1015.h>
1516

1617
#define RT1015_DEVICE_ID_VAL 0x1011
1718
#define RT1015_DEVICE_ID_VAL2 0x1015
@@ -380,6 +381,7 @@ enum {
380381

381382
struct rt1015_priv {
382383
struct snd_soc_component *component;
384+
struct rt1015_platform_data pdata;
383385
struct regmap *regmap;
384386
int sysclk;
385387
int sysclk_src;

0 commit comments

Comments
 (0)