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
6 Signed-off-by: Jaikumar <jaikumar@cem-solutions.net>
8 sound/soc/bcm/allo-katana-codec.c | 60 ++++++++++++++++++++++---------
9 1 file changed, 44 insertions(+), 16 deletions(-)
11 --- a/sound/soc/bcm/allo-katana-codec.c
12 +++ b/sound/soc/bcm/allo-katana-codec.c
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
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)
37 -#define KATANA_CODEC_FMT 0xff
38 +#define KATANA_CODEC_MAX_REGISTER (KATANA_CODEC_VIRT_BASE + 10)
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)
48 -static bool katana_codec_readable_register(struct device *dev, unsigned int reg)
49 +static bool katana_codec_readable_register(struct device *dev,
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)
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);
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",
67 - params_channels(params));
68 + params_channels(params),
69 + params_width(params));
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
77 - ret = regmap_write(katana_codec->regmap, KATANA_CODEC_FORMAT, fmt);
78 + ret = regmap_write(katana_codec->regmap, KATANA_CODEC_FORMAT,
81 dev_err(component->card->dev, "Failed to set format: %d\n", ret);
86 + case SND_SOC_DAIFMT_CBS_CFS:
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)
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);
100 katana_codec->fmt = fmt;
105 +int katana_codec_dai_mute_stream(struct snd_soc_dai *dai, int mute,
108 + struct snd_soc_component *component = dai->component;
109 + struct katana_codec_priv *katana_codec =
110 + snd_soc_component_get_drvdata(component);
113 + ret = regmap_write(katana_codec->regmap, KATANA_CODEC_MUTE_STREAM,
116 + dev_err(component->card->dev, "Failed to set mute: %d\n", ret);
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,
127 @@ -300,7 +328,7 @@ static int allo_katana_component_probe(s
128 return PTR_ERR(regmap);
130 katana_codec = devm_kzalloc(dev, sizeof(struct katana_codec_priv),
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,
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,