Skip to content

ASoC: bcm: Use power-of-2 bclk_ratios #6110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions sound/soc/bcm/allo-boss-dac.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,9 @@ static int snd_allo_boss_hw_params(
struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component;
struct snd_soc_card *card = rtd->card;

/* Using powers of 2 allows for an integer clock divisor */
width = width <= 16 ? 16 : 32;

/* Mute before changing sample rate */
snd_allo_boss_gpio_mute(card);

Expand Down
3 changes: 3 additions & 0 deletions sound/soc/bcm/dionaudio_loco.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ static int snd_rpi_dionaudio_loco_hw_params(
unsigned int sample_bits =
snd_pcm_format_width(params_format(params));

/* Using powers of 2 allows for an integer clock divisor */
sample_bits = sample_bits <= 16 ? 16 : 32;

return snd_soc_dai_set_bclk_ratio(cpu_dai, sample_bits * 2);
}

Expand Down
3 changes: 3 additions & 0 deletions sound/soc/bcm/hifiberry_dacplus.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,9 @@ static int snd_rpi_hifiberry_dacplus_hw_params(
int channels = params_channels(params);
int width = snd_pcm_format_width(params_format(params));

/* Using powers of 2 allows for an integer clock divisor */
width = width <= 16 ? 16 : 32;

if (snd_rpi_hifiberry_is_dacpro) {
struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component;

Expand Down
3 changes: 3 additions & 0 deletions sound/soc/bcm/hifiberry_dacplusadc.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,9 @@ static int snd_rpi_hifiberry_dacplusadc_hw_params(
int channels = params_channels(params);
int width = snd_pcm_format_width(params_format(params));

/* Using powers of 2 allows for an integer clock divisor */
width = width <= 16 ? 16 : 32;

if (snd_rpi_hifiberry_is_dacpro) {
struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component;

Expand Down
3 changes: 3 additions & 0 deletions sound/soc/bcm/hifiberry_dacplusadcpro.c
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,9 @@ static int snd_rpi_hifiberry_dacplusadcpro_hw_params(
struct snd_soc_dai_driver *drv = dai->driver;
const struct snd_soc_dai_ops *ops = drv->ops;

/* Using powers of 2 allows for an integer clock divisor */
width = width <= 16 ? 16 : 32;

if (snd_rpi_hifiberry_is_dacpro) {
snd_rpi_hifiberry_dacplusadcpro_set_sclk(dac,
params_rate(params));
Expand Down
5 changes: 3 additions & 2 deletions sound/soc/bcm/i-sabre-q2m.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ static int snd_rpi_i_sabre_q2m_hw_params(
struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
int bclk_ratio;

bclk_ratio = snd_pcm_format_width(
params_format(params)) * params_channels(params);
/* Using powers of 2 allows for an integer clock divisor */
bclk_ratio = (snd_pcm_format_width(params_format(params)) <= 16 ? 16 : 32) *
params_channels(params);
return snd_soc_dai_set_bclk_ratio(cpu_dai, bclk_ratio);
}

Expand Down
3 changes: 3 additions & 0 deletions sound/soc/bcm/rpi-cirrus.c
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,9 @@ static int rpi_cirrus_hw_params(struct snd_pcm_substream *substream,
unsigned int rate = params_rate(params);
unsigned int clk_freq = calc_sysclk(rate);

/* Using powers of 2 allows for an integer clock divisor */
width = width <= 16 ? 16 : 32;

mutex_lock(&priv->lock);

dev_dbg(card->dev, "hw_params: setting rate to %d\n", rate);
Expand Down
5 changes: 4 additions & 1 deletion sound/soc/bcm/rpi-simple-soundcard.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,13 @@ static int snd_rpi_simple_hw_params(struct snd_pcm_substream *substream,
return 0; // BCLK is configured in .init

/* The simple drivers just set the bclk_ratio to sample_bits * 2 so
* hard-code this for now. More complex drivers could just replace
* hard-code this for now, but sticking to powers of 2 to allow for
* integer clock divisors. More complex drivers could just replace
* the hw_params routine.
*/
sample_bits = snd_pcm_format_width(params_format(params));
sample_bits = sample_bits <= 16 ? 16 : 32;

return snd_soc_dai_set_bclk_ratio(cpu_dai, sample_bits * 2);
}

Expand Down