Skip to content

Commit 604a0a3

Browse files
committed
ASoC: codecs: aw88399: Add hw_params callback for validation
Add minimal hw_params callback to: - Log stream parameters (rate, width, channels) for debugging - Validate sample rate matches topology (48kHz expected) - Warn if unexpected configuration detected The firmware/profile system handles actual I2S register configuration, but this callback provides visibility and early warning of mismatches. This addresses concerns about missing DAI ops that could cause format/rate mismatches leading to distorted or no audio. Related-to: thesofproject#8 - Missing DAI operations
1 parent b7bb856 commit 604a0a3

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

sound/soc/codecs/aw88399.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/minmax.h>
1515
#include <linux/regmap.h>
1616
#include <linux/sort.h>
17+
#include <sound/pcm_params.h>
1718
#include <sound/soc.h>
1819
#include "aw88399.h"
1920
#include "aw88395/aw88395_device.h"
@@ -1436,8 +1437,34 @@ static int aw88399_dai_trigger(struct snd_pcm_substream *substream, int cmd,
14361437
return ret;
14371438
}
14381439

1440+
static int aw88399_dai_hw_params(struct snd_pcm_substream *substream,
1441+
struct snd_pcm_hw_params *params,
1442+
struct snd_soc_dai *dai)
1443+
{
1444+
struct snd_soc_component *component = dai->component;
1445+
unsigned int rate = params_rate(params);
1446+
unsigned int width = params_width(params);
1447+
unsigned int channels = params_channels(params);
1448+
1449+
dev_dbg(component->dev, "%s: rate=%u, width=%u, channels=%u, stream=%s\n",
1450+
__func__, rate, width, channels,
1451+
substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? "playback" : "capture");
1452+
1453+
/* Topology is configured for 48kHz, warn if mismatch */
1454+
if (rate != 48000) {
1455+
dev_warn(component->dev, "Unexpected sample rate %u (expected 48000)\n", rate);
1456+
dev_warn(component->dev, "Audio may be distorted or not work\n");
1457+
}
1458+
1459+
/* Firmware handles I2S/format configuration via profile */
1460+
/* No additional register writes needed here */
1461+
1462+
return 0;
1463+
}
1464+
14391465
static const struct snd_soc_dai_ops aw88399_dai_ops = {
14401466
.trigger = aw88399_dai_trigger,
1467+
.hw_params = aw88399_dai_hw_params,
14411468
};
14421469

14431470
static struct snd_soc_dai_driver aw88399_dai[] = {

0 commit comments

Comments
 (0)