brcm2708: rename target to bcm27xx
[openwrt/staging/wigyori.git] / target / linux / bcm27xx / patches-4.19 / 950-0315-Added-mute-stream-func.patch
1 From 193dc2529db3cfee676aae2b18f059363e151e09 Mon Sep 17 00:00:00 2001
2 From: Jaikumar <jaikumar@cem-solutions.net>
3 Date: Thu, 7 Jun 2018 21:22:45 +0530
4 Subject: [PATCH] Added mute stream func
5
6 Signed-off-by: Jaikumar <jaikumar@cem-solutions.net>
7 ---
8 sound/soc/bcm/allo-katana-codec.c | 60 ++++++++++++++++++++++---------
9 1 file changed, 44 insertions(+), 16 deletions(-)
10
11 --- a/sound/soc/bcm/allo-katana-codec.c
12 +++ b/sound/soc/bcm/allo-katana-codec.c
13 @@ -31,21 +31,23 @@
14
15 #define KATANA_CODEC_CHIP_ID 0x30
16 #define KATANA_CODEC_VIRT_BASE 0x100
17 -#define KATANA_CODEC_PAGE 0
18 +#define KATANA_CODEC_PAGE 0
19
20 #define KATANA_CODEC_CHIP_ID_REG (KATANA_CODEC_VIRT_BASE + 0)
21 -#define KATANA_CODEC_RESET (KATANA_CODEC_VIRT_BASE + 1)
22 +#define KATANA_CODEC_RESET (KATANA_CODEC_VIRT_BASE + 1)
23 #define KATANA_CODEC_VOLUME_1 (KATANA_CODEC_VIRT_BASE + 2)
24 #define KATANA_CODEC_VOLUME_2 (KATANA_CODEC_VIRT_BASE + 3)
25 -#define KATANA_CODEC_MUTE (KATANA_CODEC_VIRT_BASE + 4)
26 +#define KATANA_CODEC_MUTE (KATANA_CODEC_VIRT_BASE + 4)
27 #define KATANA_CODEC_DSP_PROGRAM (KATANA_CODEC_VIRT_BASE + 5)
28 #define KATANA_CODEC_DEEMPHASIS (KATANA_CODEC_VIRT_BASE + 6)
29 -#define KATANA_CODEC_DOP (KATANA_CODEC_VIRT_BASE + 7)
30 -#define KATANA_CODEC_FORMAT (KATANA_CODEC_VIRT_BASE + 8)
31 +#define KATANA_CODEC_DOP (KATANA_CODEC_VIRT_BASE + 7)
32 +#define KATANA_CODEC_FORMAT (KATANA_CODEC_VIRT_BASE + 8)
33 #define KATANA_CODEC_COMMAND (KATANA_CODEC_VIRT_BASE + 9)
34 -#define KATANA_CODEC_MAX_REGISTER (KATANA_CODEC_VIRT_BASE + 9)
35 +#define KATANA_CODEC_MUTE_STREAM (KATANA_CODEC_VIRT_BASE + 10)
36
37 -#define KATANA_CODEC_FMT 0xff
38 +#define KATANA_CODEC_MAX_REGISTER (KATANA_CODEC_VIRT_BASE + 10)
39 +
40 +#define KATANA_CODEC_FMT 0xff
41 #define KATANA_CODEC_CHAN_MONO 0x00
42 #define KATANA_CODEC_CHAN_STEREO 0x80
43 #define KATANA_CODEC_ALEN_16 0x10
44 @@ -135,7 +137,8 @@ static const struct snd_kcontrol_new kat
45 SOC_SINGLE("DoP Playback Switch", KATANA_CODEC_DOP, 0, 1, 1)
46 };
47
48 -static bool katana_codec_readable_register(struct device *dev, unsigned int reg)
49 +static bool katana_codec_readable_register(struct device *dev,
50 + unsigned int reg)
51 {
52 switch (reg) {
53 case KATANA_CODEC_CHIP_ID_REG:
54 @@ -150,13 +153,15 @@ static int katana_codec_hw_params(struct
55 struct snd_soc_dai *dai)
56 {
57 struct snd_soc_component *component = dai->component;
58 - struct katana_codec_priv *katana_codec = snd_soc_component_get_drvdata(component);
59 + struct katana_codec_priv *katana_codec =
60 + snd_soc_component_get_drvdata(component);
61 int fmt = 0;
62 int ret;
63
64 - dev_dbg(component->card->dev, "hw_params %u Hz, %u channels\n",
65 + dev_dbg(component->card->dev, "hw_params %u Hz, %u channels, %u bits\n",
66 params_rate(params),
67 - params_channels(params));
68 + params_channels(params),
69 + params_width(params));
70
71 switch (katana_codec->fmt & SND_SOC_DAIFMT_MASTER_MASK) {
72 case SND_SOC_DAIFMT_CBM_CFM: // master
73 @@ -212,13 +217,17 @@ static int katana_codec_hw_params(struct
74 return -EINVAL;
75 }
76
77 - ret = regmap_write(katana_codec->regmap, KATANA_CODEC_FORMAT, fmt);
78 + ret = regmap_write(katana_codec->regmap, KATANA_CODEC_FORMAT,
79 + fmt);
80 if (ret != 0) {
81 dev_err(component->card->dev, "Failed to set format: %d\n", ret);
82 return ret;
83 }
84 break;
85
86 + case SND_SOC_DAIFMT_CBS_CFS:
87 + break;
88 +
89 default:
90 return -EINVAL;
91 }
92 @@ -229,14 +238,33 @@ static int katana_codec_hw_params(struct
93 static int katana_codec_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
94 {
95 struct snd_soc_component *component = dai->component;
96 - struct katana_codec_priv *katana_codec = snd_soc_component_get_drvdata(component);
97 + struct katana_codec_priv *katana_codec =
98 + snd_soc_component_get_drvdata(component);
99
100 katana_codec->fmt = fmt;
101
102 return 0;
103 }
104
105 +int katana_codec_dai_mute_stream(struct snd_soc_dai *dai, int mute,
106 + int stream)
107 +{
108 + struct snd_soc_component *component = dai->component;
109 + struct katana_codec_priv *katana_codec =
110 + snd_soc_component_get_drvdata(component);
111 + int ret = 0;
112 +
113 + ret = regmap_write(katana_codec->regmap, KATANA_CODEC_MUTE_STREAM,
114 + mute);
115 + if (ret != 0) {
116 + dev_err(component->card->dev, "Failed to set mute: %d\n", ret);
117 + return ret;
118 + }
119 + return ret;
120 +}
121 +
122 static const struct snd_soc_dai_ops katana_codec_dai_ops = {
123 + .mute_stream = katana_codec_dai_mute_stream,
124 .hw_params = katana_codec_hw_params,
125 .set_fmt = katana_codec_set_fmt,
126 };
127 @@ -300,7 +328,7 @@ static int allo_katana_component_probe(s
128 return PTR_ERR(regmap);
129
130 katana_codec = devm_kzalloc(dev, sizeof(struct katana_codec_priv),
131 - GFP_KERNEL);
132 + GFP_KERNEL);
133 if (!katana_codec)
134 return -ENOMEM;
135
136 @@ -348,8 +376,8 @@ static struct i2c_driver allo_katana_com
137 .remove = allo_katana_component_remove,
138 .id_table = allo_katana_component_id,
139 .driver = {
140 - .name = "allo-katana-codec",
141 - .of_match_table = allo_katana_codec_of_match,
142 + .name = "allo-katana-codec",
143 + .of_match_table = allo_katana_codec_of_match,
144 },
145 };
146