[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <ff37ea9b-e162-4d6f-ae33-26ec2e342cc6@linux.dev>
Date: Tue, 7 Jan 2025 13:19:54 -0600
From: Pierre-Louis Bossart <pierre-louis.bossart@...ux.dev>
To: Bard Liao <yung-chuan.liao@...ux.intel.com>, linux-sound@...r.kernel.org,
vkoul@...nel.org
Cc: vinod.koul@...aro.org, linux-kernel@...r.kernel.org, bard.liao@...el.com
Subject: Re: [PATCH 1/2] soundwire: cadence_master: set frame shape and
divider based on actual clk freq
> -static void cdns_init_clock_ctrl(struct sdw_cdns *cdns)
> +static int cdns_init_clock_ctrl(struct sdw_cdns *cdns)
> {
> struct sdw_bus *bus = &cdns->bus;
> struct sdw_master_prop *prop = &bus->prop;
> u32 val;
> u32 ssp_interval;
> int divider;
> + int freq;
>
> dev_dbg(cdns->dev, "mclk %d max %d row %d col %d\n",
> prop->mclk_freq,
> @@ -1356,13 +1357,25 @@ static void cdns_init_clock_ctrl(struct sdw_cdns *cdns)
> prop->default_col);
>
> /* Set clock divider */
> - divider = (prop->mclk_freq / prop->max_clk_freq) - 1;
> + divider = (prop->mclk_freq * SDW_DOUBLE_RATE_FACTOR /
> + bus->params.curr_dr_freq) - 1;
> + freq = bus->params.curr_dr_freq >> 1;
do you actually need this intermediate variable? see below [1] ...
>
> cdns_updatel(cdns, CDNS_MCP_CLK_CTRL0,
> CDNS_MCP_CLK_MCLKD_MASK, divider);
> cdns_updatel(cdns, CDNS_MCP_CLK_CTRL1,
> CDNS_MCP_CLK_MCLKD_MASK, divider);
>
> + /* Set frame shape base on the actual bus frequency. */
> + if (!prop->default_frame_rate || !prop->default_row) {
> + dev_err(cdns->dev, "Default frame_rate %d or row %d is invalid\n",
> + prop->default_frame_rate, prop->default_row);
> + return -EINVAL;
> + }
maybe check the values before writing the divider registers?
> +
> + prop->default_col = freq * SDW_DOUBLE_RATE_FACTOR /
> + prop->default_frame_rate / prop->default_row;
[1] ... this is the only place where 'freq' is used, and you multiply it by two after dividing it by two.
couldn't this just be:
prop->default_col = bus->params.curr_dr_freq /
prop->default_frame_rate / prop->default_row;
Powered by blists - more mailing lists