Commit d12f1061 authored by Charles Keepax's avatar Charles Keepax Committed by Mark Brown

ASoC: max98373-sdw: 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: default avatarCharles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20221123165432.594972-2-ckeepax@opensource.cirrus.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent e4587516
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <linux/slab.h> #include <linux/slab.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/tlv.h> #include <sound/tlv.h>
#include <linux/of.h> #include <linux/of.h>
...@@ -533,10 +534,8 @@ static int max98373_sdw_dai_hw_params(struct snd_pcm_substream *substream, ...@@ -533,10 +534,8 @@ static int max98373_sdw_dai_hw_params(struct snd_pcm_substream *substream,
struct snd_soc_component *component = dai->component; struct snd_soc_component *component = dai->component;
struct max98373_priv *max98373 = struct max98373_priv *max98373 =
snd_soc_component_get_drvdata(component); snd_soc_component_get_drvdata(component);
struct sdw_stream_config stream_config = {0};
struct sdw_stream_config stream_config; struct sdw_port_config port_config = {0};
struct sdw_port_config port_config;
enum sdw_data_direction direction;
struct sdw_stream_data *stream; struct sdw_stream_data *stream;
int ret, chan_sz, sampling_rate; int ret, chan_sz, sampling_rate;
...@@ -548,28 +547,20 @@ static int max98373_sdw_dai_hw_params(struct snd_pcm_substream *substream, ...@@ -548,28 +547,20 @@ static int max98373_sdw_dai_hw_params(struct snd_pcm_substream *substream,
if (!max98373->slave) if (!max98373->slave)
return -EINVAL; return -EINVAL;
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 = 1; port_config.num = 1;
} else {
direction = SDW_DATA_DIR_TX;
port_config.num = 3;
}
stream_config.frame_rate = params_rate(params);
stream_config.bps = snd_pcm_format_width(params_format(params));
stream_config.direction = direction;
if (max98373->slot && direction == SDW_DATA_DIR_RX) { if (max98373->slot) {
stream_config.ch_count = max98373->slot; stream_config.ch_count = max98373->slot;
port_config.ch_mask = max98373->rx_mask; port_config.ch_mask = max98373->rx_mask;
}
} else { } else {
port_config.num = 3;
/* only IV are supported by capture */ /* only IV are supported by capture */
if (direction == SDW_DATA_DIR_TX)
stream_config.ch_count = 2; stream_config.ch_count = 2;
else
stream_config.ch_count = params_channels(params);
port_config.ch_mask = GENMASK((int)stream_config.ch_count - 1, 0); port_config.ch_mask = GENMASK((int)stream_config.ch_count - 1, 0);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment