ASoC: rt711: Switch to new snd_sdw_params_to_config helper
The conversion from hw_params to SoundWire config is pretty standard as such most of the conversion can be handled by the new snd_sdw_params_to_config helper function. Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Link: https://lore.kernel.org/r/20221123165432.594972-7-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Родитель
ae7ad90e7c
Коммит
754bef6752
|
@ -18,6 +18,7 @@
|
||||||
#include <sound/core.h>
|
#include <sound/core.h>
|
||||||
#include <sound/pcm.h>
|
#include <sound/pcm.h>
|
||||||
#include <sound/pcm_params.h>
|
#include <sound/pcm_params.h>
|
||||||
|
#include <sound/sdw.h>
|
||||||
#include <sound/soc-dapm.h>
|
#include <sound/soc-dapm.h>
|
||||||
#include <sound/initval.h>
|
#include <sound/initval.h>
|
||||||
#include <sound/tlv.h>
|
#include <sound/tlv.h>
|
||||||
|
@ -1257,11 +1258,10 @@ static int rt711_sdca_pcm_hw_params(struct snd_pcm_substream *substream,
|
||||||
{
|
{
|
||||||
struct snd_soc_component *component = dai->component;
|
struct snd_soc_component *component = dai->component;
|
||||||
struct rt711_sdca_priv *rt711 = snd_soc_component_get_drvdata(component);
|
struct rt711_sdca_priv *rt711 = snd_soc_component_get_drvdata(component);
|
||||||
struct sdw_stream_config stream_config;
|
struct sdw_stream_config stream_config = {0};
|
||||||
struct sdw_port_config port_config;
|
struct sdw_port_config port_config = {0};
|
||||||
enum sdw_data_direction direction;
|
|
||||||
struct sdw_stream_data *stream;
|
struct sdw_stream_data *stream;
|
||||||
int retval, port, num_channels;
|
int retval;
|
||||||
unsigned int sampling_rate;
|
unsigned int sampling_rate;
|
||||||
|
|
||||||
dev_dbg(dai->dev, "%s %s", __func__, dai->name);
|
dev_dbg(dai->dev, "%s %s", __func__, dai->name);
|
||||||
|
@ -1274,28 +1274,19 @@ static int rt711_sdca_pcm_hw_params(struct snd_pcm_substream *substream,
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
/* SoundWire specific configuration */
|
/* SoundWire specific configuration */
|
||||||
|
snd_sdw_params_to_config(substream, params, &stream_config, &port_config);
|
||||||
|
|
||||||
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
|
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
|
||||||
direction = SDW_DATA_DIR_RX;
|
port_config.num = 3;
|
||||||
port = 3;
|
|
||||||
} else {
|
} else {
|
||||||
direction = SDW_DATA_DIR_TX;
|
|
||||||
if (dai->id == RT711_AIF1)
|
if (dai->id == RT711_AIF1)
|
||||||
port = 2;
|
port_config.num = 2;
|
||||||
else if (dai->id == RT711_AIF2)
|
else if (dai->id == RT711_AIF2)
|
||||||
port = 4;
|
port_config.num = 4;
|
||||||
else
|
else
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
stream_config.frame_rate = params_rate(params);
|
|
||||||
stream_config.ch_count = params_channels(params);
|
|
||||||
stream_config.bps = snd_pcm_format_width(params_format(params));
|
|
||||||
stream_config.direction = direction;
|
|
||||||
|
|
||||||
num_channels = params_channels(params);
|
|
||||||
port_config.ch_mask = GENMASK(num_channels - 1, 0);
|
|
||||||
port_config.num = port;
|
|
||||||
|
|
||||||
retval = sdw_stream_add_slave(rt711->slave, &stream_config,
|
retval = sdw_stream_add_slave(rt711->slave, &stream_config,
|
||||||
&port_config, 1, stream->sdw_stream);
|
&port_config, 1, stream->sdw_stream);
|
||||||
if (retval) {
|
if (retval) {
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include <sound/core.h>
|
#include <sound/core.h>
|
||||||
#include <sound/pcm.h>
|
#include <sound/pcm.h>
|
||||||
#include <sound/pcm_params.h>
|
#include <sound/pcm_params.h>
|
||||||
|
#include <sound/sdw.h>
|
||||||
#include <sound/soc.h>
|
#include <sound/soc.h>
|
||||||
#include <sound/soc-dapm.h>
|
#include <sound/soc-dapm.h>
|
||||||
#include <sound/initval.h>
|
#include <sound/initval.h>
|
||||||
|
@ -999,11 +1000,10 @@ static int rt711_pcm_hw_params(struct snd_pcm_substream *substream,
|
||||||
{
|
{
|
||||||
struct snd_soc_component *component = dai->component;
|
struct snd_soc_component *component = dai->component;
|
||||||
struct rt711_priv *rt711 = snd_soc_component_get_drvdata(component);
|
struct rt711_priv *rt711 = snd_soc_component_get_drvdata(component);
|
||||||
struct sdw_stream_config stream_config;
|
struct sdw_stream_config stream_config = {0};
|
||||||
struct sdw_port_config port_config;
|
struct sdw_port_config port_config = {0};
|
||||||
enum sdw_data_direction direction;
|
|
||||||
struct sdw_stream_data *stream;
|
struct sdw_stream_data *stream;
|
||||||
int retval, port, num_channels;
|
int retval;
|
||||||
unsigned int val = 0;
|
unsigned int val = 0;
|
||||||
|
|
||||||
dev_dbg(dai->dev, "%s %s", __func__, dai->name);
|
dev_dbg(dai->dev, "%s %s", __func__, dai->name);
|
||||||
|
@ -1016,28 +1016,19 @@ static int rt711_pcm_hw_params(struct snd_pcm_substream *substream,
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
/* SoundWire specific configuration */
|
/* SoundWire specific configuration */
|
||||||
|
snd_sdw_params_to_config(substream, params, &stream_config, &port_config);
|
||||||
|
|
||||||
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
|
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
|
||||||
direction = SDW_DATA_DIR_RX;
|
port_config.num = 3;
|
||||||
port = 3;
|
|
||||||
} else {
|
} else {
|
||||||
direction = SDW_DATA_DIR_TX;
|
|
||||||
if (dai->id == RT711_AIF1)
|
if (dai->id == RT711_AIF1)
|
||||||
port = 4;
|
port_config.num = 4;
|
||||||
else if (dai->id == RT711_AIF2)
|
else if (dai->id == RT711_AIF2)
|
||||||
port = 2;
|
port_config.num = 2;
|
||||||
else
|
else
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
stream_config.frame_rate = params_rate(params);
|
|
||||||
stream_config.ch_count = params_channels(params);
|
|
||||||
stream_config.bps = snd_pcm_format_width(params_format(params));
|
|
||||||
stream_config.direction = direction;
|
|
||||||
|
|
||||||
num_channels = params_channels(params);
|
|
||||||
port_config.ch_mask = (1 << (num_channels)) - 1;
|
|
||||||
port_config.num = port;
|
|
||||||
|
|
||||||
retval = sdw_stream_add_slave(rt711->slave, &stream_config,
|
retval = sdw_stream_add_slave(rt711->slave, &stream_config,
|
||||||
&port_config, 1, stream->sdw_stream);
|
&port_config, 1, stream->sdw_stream);
|
||||||
if (retval) {
|
if (retval) {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче