forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/sound/soc/codecs/wm8741.c
....@@ -1,14 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * wm8741.c -- WM8741 ALSA SoC Audio driver
34 *
45 * Copyright 2010-1 Wolfson Microelectronics plc
56 *
67 * Author: Ian Lartey <ian@opensource.wolfsonmicro.com>
7
- *
8
- *
9
- * This program is free software; you can redistribute it and/or modify
10
- * it under the terms of the GNU General Public License version 2 as
11
- * published by the Free Software Foundation.
128 */
139
1410 #include <linux/module.h>
....@@ -196,7 +192,7 @@
196192 {
197193 struct snd_soc_component *component = dai->component;
198194 struct wm8741_priv *wm8741 = snd_soc_component_get_drvdata(component);
199
- unsigned int iface;
195
+ unsigned int iface, mode;
200196 int i;
201197
202198 /* The set of sample rates that can be supported depends on the
....@@ -240,11 +236,21 @@
240236 return -EINVAL;
241237 }
242238
239
+ /* oversampling rate */
240
+ if (params_rate(params) > 96000)
241
+ mode = 0x40;
242
+ else if (params_rate(params) > 48000)
243
+ mode = 0x20;
244
+ else
245
+ mode = 0x00;
246
+
243247 dev_dbg(component->dev, "wm8741_hw_params: bit size param = %d, rate param = %d",
244248 params_width(params), params_rate(params));
245249
246250 snd_soc_component_update_bits(component, WM8741_FORMAT_CONTROL, WM8741_IWL_MASK,
247251 iface);
252
+ snd_soc_component_update_bits(component, WM8741_MODE_CONTROL_1, WM8741_OSR_MASK,
253
+ mode);
248254
249255 return 0;
250256 }
....@@ -358,6 +364,15 @@
358364 return 0;
359365 }
360366
367
+static int wm8741_mute(struct snd_soc_dai *codec_dai, int mute, int direction)
368
+{
369
+ struct snd_soc_component *component = codec_dai->component;
370
+
371
+ snd_soc_component_update_bits(component, WM8741_VOLUME_CONTROL,
372
+ WM8741_SOFT_MASK, !!mute << WM8741_SOFT_SHIFT);
373
+ return 0;
374
+}
375
+
361376 #define WM8741_RATES (SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | \
362377 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 | \
363378 SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 | \
....@@ -371,6 +386,8 @@
371386 .hw_params = wm8741_hw_params,
372387 .set_sysclk = wm8741_set_dai_sysclk,
373388 .set_fmt = wm8741_set_dai_fmt,
389
+ .mute_stream = wm8741_mute,
390
+ .no_capture_mute = 1,
374391 };
375392
376393 static struct snd_soc_dai_driver wm8741_dai = {