aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/brcm2708/patches-4.19/950-0365-Added-mute-stream-func.patch
blob: 7445b44d1882ff8e4c22a38d6d4e7bbf008690e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
From 5feb58606710065f2032817176560cdec72f1f40 Mon Sep 17 00:00:00 2001
From: Jaikumar <jaikumar@cem-solutions.net>
Date: Thu, 7 Jun 2018 21:22:45 +0530
Subject: [PATCH 365/773] Added mute stream func

Signed-off-by: Jaikumar <jaikumar@cem-solutions.net>
---
 sound/soc/bcm/allo-katana-codec.c | 60 ++++++++++++++++++++++---------
 1 file changed, 44 insertions(+), 16 deletions(-)

--- a/sound/soc/bcm/allo-katana-codec.c
+++ b/sound/soc/bcm/allo-katana-codec.c
@@ -31,21 +31,23 @@
 
 #define KATANA_CODEC_CHIP_ID		0x30
 #define KATANA_CODEC_VIRT_BASE		0x100
-#define KATANA_CODEC_PAGE			0
+#define KATANA_CODEC_PAGE		0
 
 #define KATANA_CODEC_CHIP_ID_REG	(KATANA_CODEC_VIRT_BASE + 0)
-#define KATANA_CODEC_RESET			(KATANA_CODEC_VIRT_BASE + 1)
+#define KATANA_CODEC_RESET		(KATANA_CODEC_VIRT_BASE + 1)
 #define KATANA_CODEC_VOLUME_1		(KATANA_CODEC_VIRT_BASE + 2)
 #define KATANA_CODEC_VOLUME_2		(KATANA_CODEC_VIRT_BASE + 3)
-#define KATANA_CODEC_MUTE			(KATANA_CODEC_VIRT_BASE + 4)
+#define KATANA_CODEC_MUTE		(KATANA_CODEC_VIRT_BASE + 4)
 #define KATANA_CODEC_DSP_PROGRAM	(KATANA_CODEC_VIRT_BASE + 5)
 #define KATANA_CODEC_DEEMPHASIS		(KATANA_CODEC_VIRT_BASE + 6)
-#define KATANA_CODEC_DOP			(KATANA_CODEC_VIRT_BASE + 7)
-#define KATANA_CODEC_FORMAT			(KATANA_CODEC_VIRT_BASE + 8)
+#define KATANA_CODEC_DOP		(KATANA_CODEC_VIRT_BASE + 7)
+#define KATANA_CODEC_FORMAT		(KATANA_CODEC_VIRT_BASE + 8)
 #define KATANA_CODEC_COMMAND		(KATANA_CODEC_VIRT_BASE + 9)
-#define KATANA_CODEC_MAX_REGISTER	(KATANA_CODEC_VIRT_BASE + 9)
+#define KATANA_CODEC_MUTE_STREAM	(KATANA_CODEC_VIRT_BASE + 10)
 
-#define KATANA_CODEC_FMT			0xff
+#define KATANA_CODEC_MAX_REGISTER	(KATANA_CODEC_VIRT_BASE + 10)
+
+#define KATANA_CODEC_FMT		0xff
 #define KATANA_CODEC_CHAN_MONO		0x00
 #define KATANA_CODEC_CHAN_STEREO	0x80
 #define KATANA_CODEC_ALEN_16		0x10
@@ -135,7 +137,8 @@ static const struct snd_kcontrol_new kat
 	SOC_SINGLE("DoP Playback Switch", KATANA_CODEC_DOP, 0, 1, 1)
 };
 
-static bool katana_codec_readable_register(struct device *dev, unsigned int reg)
+static bool katana_codec_readable_register(struct device *dev,
+				unsigned int reg)
 {
 	switch (reg) {
 	case KATANA_CODEC_CHIP_ID_REG:
@@ -150,13 +153,15 @@ static int katana_codec_hw_params(struct
 			     struct snd_soc_dai *dai)
 {
 	struct snd_soc_component *component = dai->component;
-	struct katana_codec_priv *katana_codec = snd_soc_component_get_drvdata(component);
+	struct katana_codec_priv *katana_codec =
+		snd_soc_component_get_drvdata(component);
 	int fmt = 0;
 	int ret;
 
-	dev_dbg(component->card->dev, "hw_params %u Hz, %u channels\n",
+	dev_dbg(component->card->dev, "hw_params %u Hz, %u channels, %u bits\n",
 			params_rate(params),
-			params_channels(params));
+			params_channels(params),
+			params_width(params));
 
 	switch (katana_codec->fmt & SND_SOC_DAIFMT_MASTER_MASK) {
 	case SND_SOC_DAIFMT_CBM_CFM: // master
@@ -212,13 +217,17 @@ static int katana_codec_hw_params(struct
 			return -EINVAL;
 		}
 
-		ret = regmap_write(katana_codec->regmap, KATANA_CODEC_FORMAT, fmt);
+		ret = regmap_write(katana_codec->regmap, KATANA_CODEC_FORMAT,
+					fmt);
 		if (ret != 0) {
 			dev_err(component->card->dev, "Failed to set format: %d\n", ret);
 			return ret;
 		}
 		break;
 
+	case SND_SOC_DAIFMT_CBS_CFS:
+		break;
+
 	default:
 		return -EINVAL;
 	}
@@ -229,14 +238,33 @@ static int katana_codec_hw_params(struct
 static int katana_codec_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
 {
 	struct snd_soc_component *component = dai->component;
-	struct katana_codec_priv *katana_codec = snd_soc_component_get_drvdata(component);
+	struct katana_codec_priv *katana_codec =
+		snd_soc_component_get_drvdata(component);
 
 	katana_codec->fmt = fmt;
 
 	return 0;
 }
 
+int katana_codec_dai_mute_stream(struct snd_soc_dai *dai, int mute,
+						int stream)
+{
+	struct snd_soc_component *component = dai->component;
+	struct katana_codec_priv *katana_codec =
+		snd_soc_component_get_drvdata(component);
+	int ret = 0;
+
+	ret = regmap_write(katana_codec->regmap, KATANA_CODEC_MUTE_STREAM,
+				mute);
+	if (ret != 0) {
+		dev_err(component->card->dev, "Failed to set mute: %d\n", ret);
+		return ret;
+	}
+	return ret;
+}
+
 static const struct snd_soc_dai_ops katana_codec_dai_ops = {
+	.mute_stream = katana_codec_dai_mute_stream,
 	.hw_params = katana_codec_hw_params,
 	.set_fmt = katana_codec_set_fmt,
 };
@@ -300,7 +328,7 @@ static int allo_katana_component_probe(s
 		return PTR_ERR(regmap);
 
 	katana_codec = devm_kzalloc(dev, sizeof(struct katana_codec_priv),
-								GFP_KERNEL);
+					GFP_KERNEL);
 	if (!katana_codec)
 		return -ENOMEM;
 
@@ -348,8 +376,8 @@ static struct i2c_driver allo_katana_com
 	.remove		= allo_katana_component_remove,
 	.id_table	= allo_katana_component_id,
 	.driver		= {
-		.name	= "allo-katana-codec",
-		.of_match_table = allo_katana_codec_of_match,
+	.name		= "allo-katana-codec",
+	.of_match_table = allo_katana_codec_of_match,
 	},
 };