if (bclk) {
bclk_rate = frame_size * sr;
+ /*
+ * Rounding the rate here avoids failure trying to set a
+ * new rate on an already enabled bclk. In that
+ * instance this will just set the same rate as is
+ * currently in use, and so should continue without
+ * problem, as long as the BCLK rate is suitable for the
+ * desired frame size.
+ */
+ bclk_rate = clk_round_rate(bclk, bclk_rate);
+ if ((bclk_rate / sr) < frame_size) {
+ dev_err(component->dev,
+ "BCLK rate mismatch against frame size");
+ return -EINVAL;
+ }
+
ret = clk_set_rate(bclk, bclk_rate);
if (ret) {
dev_err(component->dev,
struct snd_soc_component *component = da7219->component;
u8 fs = snd_soc_component_read32(component, DA7219_SR);
- if (!da7219->master)
- return 0;
-
switch (fs & DA7219_SR_MASK) {
case DA7219_SR_8000:
return 8000;
u8 bclks_per_wclk = snd_soc_component_read32(component,
DA7219_DAI_CLK_MODE);
- if (!da7219->master)
- return 0;
-
switch (bclks_per_wclk & DA7219_DAI_BCLKS_PER_WCLK_MASK) {
case DA7219_DAI_BCLKS_PER_WCLK_32:
return parent_rate * 32;