rt711.c (14e77332e74603efab8347c89d3cda447c3b97c9) rt711.c (754bef6752259ce5633814a0333f96fa06f6e3e8)
1// SPDX-License-Identifier: GPL-2.0
2//
3// rt711.c -- rt711 ALSA SoC audio driver
4//
5// Copyright(c) 2019 Realtek Semiconductor Corp.
6//
7//
8

--- 5 unchanged lines hidden (view full) ---

14#include <linux/pm_runtime.h>
15#include <linux/pm.h>
16#include <linux/soundwire/sdw.h>
17#include <linux/regmap.h>
18#include <linux/slab.h>
19#include <sound/core.h>
20#include <sound/pcm.h>
21#include <sound/pcm_params.h>
1// SPDX-License-Identifier: GPL-2.0
2//
3// rt711.c -- rt711 ALSA SoC audio driver
4//
5// Copyright(c) 2019 Realtek Semiconductor Corp.
6//
7//
8

--- 5 unchanged lines hidden (view full) ---

14#include <linux/pm_runtime.h>
15#include <linux/pm.h>
16#include <linux/soundwire/sdw.h>
17#include <linux/regmap.h>
18#include <linux/slab.h>
19#include <sound/core.h>
20#include <sound/pcm.h>
21#include <sound/pcm_params.h>
22#include <sound/sdw.h>
22#include <sound/soc.h>
23#include <sound/soc-dapm.h>
24#include <sound/initval.h>
25#include <sound/tlv.h>
26#include <sound/hda_verbs.h>
27#include <sound/jack.h>
28
29#include "rt711.h"

--- 964 unchanged lines hidden (view full) ---

994}
995
996static int rt711_pcm_hw_params(struct snd_pcm_substream *substream,
997 struct snd_pcm_hw_params *params,
998 struct snd_soc_dai *dai)
999{
1000 struct snd_soc_component *component = dai->component;
1001 struct rt711_priv *rt711 = snd_soc_component_get_drvdata(component);
23#include <sound/soc.h>
24#include <sound/soc-dapm.h>
25#include <sound/initval.h>
26#include <sound/tlv.h>
27#include <sound/hda_verbs.h>
28#include <sound/jack.h>
29
30#include "rt711.h"

--- 964 unchanged lines hidden (view full) ---

995}
996
997static int rt711_pcm_hw_params(struct snd_pcm_substream *substream,
998 struct snd_pcm_hw_params *params,
999 struct snd_soc_dai *dai)
1000{
1001 struct snd_soc_component *component = dai->component;
1002 struct rt711_priv *rt711 = snd_soc_component_get_drvdata(component);
1002 struct sdw_stream_config stream_config;
1003 struct sdw_port_config port_config;
1004 enum sdw_data_direction direction;
1003 struct sdw_stream_config stream_config = {0};
1004 struct sdw_port_config port_config = {0};
1005 struct sdw_stream_data *stream;
1005 struct sdw_stream_data *stream;
1006 int retval, port, num_channels;
1006 int retval;
1007 unsigned int val = 0;
1008
1009 dev_dbg(dai->dev, "%s %s", __func__, dai->name);
1010 stream = snd_soc_dai_get_dma_data(dai, substream);
1011
1012 if (!stream)
1013 return -EINVAL;
1014
1015 if (!rt711->slave)
1016 return -EINVAL;
1017
1018 /* SoundWire specific configuration */
1007 unsigned int val = 0;
1008
1009 dev_dbg(dai->dev, "%s %s", __func__, dai->name);
1010 stream = snd_soc_dai_get_dma_data(dai, substream);
1011
1012 if (!stream)
1013 return -EINVAL;
1014
1015 if (!rt711->slave)
1016 return -EINVAL;
1017
1018 /* SoundWire specific configuration */
1019 snd_sdw_params_to_config(substream, params, &stream_config, &port_config);
1020
1019 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
1021 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
1020 direction = SDW_DATA_DIR_RX;
1021 port = 3;
1022 port_config.num = 3;
1022 } else {
1023 } else {
1023 direction = SDW_DATA_DIR_TX;
1024 if (dai->id == RT711_AIF1)
1024 if (dai->id == RT711_AIF1)
1025 port = 4;
1025 port_config.num = 4;
1026 else if (dai->id == RT711_AIF2)
1026 else if (dai->id == RT711_AIF2)
1027 port = 2;
1027 port_config.num = 2;
1028 else
1029 return -EINVAL;
1030 }
1031
1028 else
1029 return -EINVAL;
1030 }
1031
1032 stream_config.frame_rate = params_rate(params);
1033 stream_config.ch_count = params_channels(params);
1034 stream_config.bps = snd_pcm_format_width(params_format(params));
1035 stream_config.direction = direction;
1036
1037 num_channels = params_channels(params);
1038 port_config.ch_mask = (1 << (num_channels)) - 1;
1039 port_config.num = port;
1040
1041 retval = sdw_stream_add_slave(rt711->slave, &stream_config,
1042 &port_config, 1, stream->sdw_stream);
1043 if (retval) {
1044 dev_err(dai->dev, "Unable to configure port\n");
1045 return retval;
1046 }
1047
1048 if (params_channels(params) <= 16) {

--- 308 unchanged lines hidden ---
1032 retval = sdw_stream_add_slave(rt711->slave, &stream_config,
1033 &port_config, 1, stream->sdw_stream);
1034 if (retval) {
1035 dev_err(dai->dev, "Unable to configure port\n");
1036 return retval;
1037 }
1038
1039 if (params_channels(params) <= 16) {

--- 308 unchanged lines hidden ---