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

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

13#include <linux/delay.h>
14#include <linux/pm_runtime.h>
15#include <linux/soundwire/sdw_registers.h>
16#include <linux/slab.h>
17#include <linux/bitops.h>
18#include <sound/core.h>
19#include <sound/pcm.h>
20#include <sound/pcm_params.h>
1// SPDX-License-Identifier: GPL-2.0-only
2//
3// rt711-sdca.c -- rt711 SDCA ALSA SoC audio driver
4//
5// Copyright(c) 2021 Realtek Semiconductor Corp.
6//
7//
8

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

13#include <linux/delay.h>
14#include <linux/pm_runtime.h>
15#include <linux/soundwire/sdw_registers.h>
16#include <linux/slab.h>
17#include <linux/bitops.h>
18#include <sound/core.h>
19#include <sound/pcm.h>
20#include <sound/pcm_params.h>
21#include <sound/sdw.h>
21#include <sound/soc-dapm.h>
22#include <sound/initval.h>
23#include <sound/tlv.h>
24#include <sound/jack.h>
25
26#include "rt711-sdca.h"
27
28static int rt711_sdca_index_write(struct rt711_sdca_priv *rt711,

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

1252}
1253
1254static int rt711_sdca_pcm_hw_params(struct snd_pcm_substream *substream,
1255 struct snd_pcm_hw_params *params,
1256 struct snd_soc_dai *dai)
1257{
1258 struct snd_soc_component *component = dai->component;
1259 struct rt711_sdca_priv *rt711 = snd_soc_component_get_drvdata(component);
22#include <sound/soc-dapm.h>
23#include <sound/initval.h>
24#include <sound/tlv.h>
25#include <sound/jack.h>
26
27#include "rt711-sdca.h"
28
29static int rt711_sdca_index_write(struct rt711_sdca_priv *rt711,

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

1253}
1254
1255static int rt711_sdca_pcm_hw_params(struct snd_pcm_substream *substream,
1256 struct snd_pcm_hw_params *params,
1257 struct snd_soc_dai *dai)
1258{
1259 struct snd_soc_component *component = dai->component;
1260 struct rt711_sdca_priv *rt711 = snd_soc_component_get_drvdata(component);
1260 struct sdw_stream_config stream_config;
1261 struct sdw_port_config port_config;
1262 enum sdw_data_direction direction;
1261 struct sdw_stream_config stream_config = {0};
1262 struct sdw_port_config port_config = {0};
1263 struct sdw_stream_data *stream;
1263 struct sdw_stream_data *stream;
1264 int retval, port, num_channels;
1264 int retval;
1265 unsigned int sampling_rate;
1266
1267 dev_dbg(dai->dev, "%s %s", __func__, dai->name);
1268 stream = snd_soc_dai_get_dma_data(dai, substream);
1269
1270 if (!stream)
1271 return -EINVAL;
1272
1273 if (!rt711->slave)
1274 return -EINVAL;
1275
1276 /* SoundWire specific configuration */
1265 unsigned int sampling_rate;
1266
1267 dev_dbg(dai->dev, "%s %s", __func__, dai->name);
1268 stream = snd_soc_dai_get_dma_data(dai, substream);
1269
1270 if (!stream)
1271 return -EINVAL;
1272
1273 if (!rt711->slave)
1274 return -EINVAL;
1275
1276 /* SoundWire specific configuration */
1277 snd_sdw_params_to_config(substream, params, &stream_config, &port_config);
1278
1277 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
1279 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
1278 direction = SDW_DATA_DIR_RX;
1279 port = 3;
1280 port_config.num = 3;
1280 } else {
1281 } else {
1281 direction = SDW_DATA_DIR_TX;
1282 if (dai->id == RT711_AIF1)
1282 if (dai->id == RT711_AIF1)
1283 port = 2;
1283 port_config.num = 2;
1284 else if (dai->id == RT711_AIF2)
1284 else if (dai->id == RT711_AIF2)
1285 port = 4;
1285 port_config.num = 4;
1286 else
1287 return -EINVAL;
1288 }
1289
1286 else
1287 return -EINVAL;
1288 }
1289
1290 stream_config.frame_rate = params_rate(params);
1291 stream_config.ch_count = params_channels(params);
1292 stream_config.bps = snd_pcm_format_width(params_format(params));
1293 stream_config.direction = direction;
1294
1295 num_channels = params_channels(params);
1296 port_config.ch_mask = GENMASK(num_channels - 1, 0);
1297 port_config.num = port;
1298
1299 retval = sdw_stream_add_slave(rt711->slave, &stream_config,
1300 &port_config, 1, stream->sdw_stream);
1301 if (retval) {
1302 dev_err(dai->dev, "Unable to configure port\n");
1303 return retval;
1304 }
1305
1306 if (params_channels(params) > 16) {

--- 289 unchanged lines hidden ---
1290 retval = sdw_stream_add_slave(rt711->slave, &stream_config,
1291 &port_config, 1, stream->sdw_stream);
1292 if (retval) {
1293 dev_err(dai->dev, "Unable to configure port\n");
1294 return retval;
1295 }
1296
1297 if (params_channels(params) > 16) {

--- 289 unchanged lines hidden ---