public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
To: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: linux-media@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org,
	"Luca Ceresoli" <luca.ceresoli@bootlin.com>,
	"Matti Vaittinen" <Matti.Vaittinen@fi.rohmeurope.com>,
	"Laurent Pinchart" <laurent.pinchart@ideasonboard.com>,
	"Sakari Ailus" <sakari.ailus@linux.intel.com>,
	"Wolfram Sang" <wsa@kernel.org>,
	"Rob Herring" <robh+dt@kernel.org>,
	"Krzysztof Kozlowski" <krzysztof.kozlowski+dt@linaro.org>,
	"Mauro Carvalho Chehab" <mchehab@kernel.org>,
	"Peter Rosin" <peda@axentia.se>,
	"Liam Girdwood" <lgirdwood@gmail.com>,
	"Mark Brown" <broonie@kernel.org>,
	"Michael Tretter" <m.tretter@pengutronix.de>,
	"Hans Verkuil" <hverkuil@xs4all.nl>,
	"Mike Pagano" <mpagano@gentoo.org>,
	"Krzysztof Hałasa" <khalasa@piap.pl>,
	"Marek Vasut" <marex@denx.de>,
	"Satish Nagireddy" <satish.nagireddy@getcruise.com>
Subject: Re: [PATCH v14 18/18] media: i2c: ds90ub953: Support non-sync mode
Date: Mon, 19 Jun 2023 13:57:29 +0300	[thread overview]
Message-ID: <3dda6808-cda2-e587-88a7-00621b2cfca3@ideasonboard.com> (raw)
In-Reply-To: <ZJAyb9WHjWrdSsBw@smile.fi.intel.com>

On 19/06/2023 13:48, Andy Shevchenko wrote:
> On Mon, Jun 19, 2023 at 12:00:57PM +0300, Tomi Valkeinen wrote:
>> On 16/06/2023 17:47, Andy Shevchenko wrote:
>>> On Fri, Jun 16, 2023 at 04:59:22PM +0300, Tomi Valkeinen wrote:
>>>> Add support for FPD-Link non-sync mode with external clock. The only
>>>> thing that needs to be added is the calculation for the clkout.
> 
> ...
> 
>>>> +	switch (priv->mode) {
>>>> +	case UB953_MODE_SYNC:
>>>> +		if (priv->hw_data->is_ub971)
>>>> +			return priv->plat_data->bc_rate * 160ull;
>>>> +		else
>>>> +			return priv->plat_data->bc_rate / 2 * 160ull;
>>>
>>> Redundant 'else'.
>>
>> True, but I like the symmetry in:
>>
>> if (foo)
>> 	return 123;
>> else
>> 	return 321;
> 
> At the same time it will be symmetry with other switch-case(s). That's why the
> question about fallthrough below.
> 
>>> Do I understand correctly you don't want to fallthrough because it will give
>>> ±160 in the rate (depending if it's even or odd)?
>>
>> Sorry, can you clarify? Fallthrough to what?
> 
> To the below case since '/ 2 * 160 ~= *80'. Why ~ because it might give
> off-by-one error due to even/odd input.

The below case is different. "priv->plat_data->bc_rate" vs 
"clk_get_rate(priv->clkin)".

As to the order of the calculation (/ 2 * 160 versus * 160 / 2), 
generally speaking, I have never figured out what are the correct ways 
to calculate clock rates.

I wrote "x / 2 * 160" as that's what the documentation gives (there's a 
hardware /2 divider in non-ub971 chips, followed by a 160 multiplier). 
But does the documentation presume that the calculation is done 
precisely, not in integers? If so, "x * 160 / 2" would be better (but 
then, do we need to round?). Or does the /2 hardware divider basically 
actually work as a an integer division, in case "x / 2 * 160" is the 
correct one.

>>>> +	case UB953_MODE_NONSYNC_EXT:
>>>> +		/* CLKIN_DIV = 1 always */
>>>> +		return clk_get_rate(priv->clkin) * 80ull;
> 

  Tomi


      reply	other threads:[~2023-06-19 10:59 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-16 13:59 [PATCH v14 00/18] i2c-atr and FPDLink Tomi Valkeinen
2023-06-16 13:59 ` [PATCH v14 01/18] dt-bindings: i2c: Add I2C Address Translator (ATR) Tomi Valkeinen
2023-06-16 13:59 ` [PATCH v14 02/18] i2c: add I2C Address Translator (ATR) support Tomi Valkeinen
2023-06-16 13:59 ` [PATCH v14 03/18] dt-bindings: media: add TI DS90UB913 FPD-Link III Serializer Tomi Valkeinen
2023-06-16 13:59 ` [PATCH v14 04/18] dt-bindings: media: add TI DS90UB953 " Tomi Valkeinen
2023-06-16 13:59 ` [PATCH v14 05/18] dt-bindings: media: add TI DS90UB960 FPD-Link III Deserializer Tomi Valkeinen
2023-06-16 13:59 ` [PATCH v14 06/18] media: i2c: add DS90UB960 driver Tomi Valkeinen
2023-06-16 13:59 ` [PATCH v14 07/18] media: i2c: add DS90UB913 driver Tomi Valkeinen
2023-06-16 13:59 ` [PATCH v14 08/18] media: i2c: add DS90UB953 driver Tomi Valkeinen
2023-06-16 13:59 ` [PATCH v14 09/18] media: i2c: ds90ub960: Fix use of UB960_SR_FWD_CTL1 Tomi Valkeinen
2023-06-16 13:59 ` [PATCH v14 10/18] media: i2c: ds90ub9xx: Add COMMON_CLK kconfig dependency Tomi Valkeinen
2023-06-16 13:59 ` [PATCH v14 11/18] media: i2c: ds90ub9xx: Select GPIOLIB rather than OF_GPIO Tomi Valkeinen
2023-06-16 14:17   ` Andy Shevchenko
2023-06-19  8:40     ` Tomi Valkeinen
2023-06-16 13:59 ` [PATCH v14 12/18] media: i2c: ds90ub960: Configure CSI-2 continuous clock Tomi Valkeinen
2023-06-16 13:59 ` [PATCH v14 13/18] media: i2c: ds90ub953: Use v4l2_fwnode_endpoint_parse() Tomi Valkeinen
2023-06-16 14:24   ` Andy Shevchenko
2023-06-19  8:52     ` Tomi Valkeinen
2023-06-16 13:59 ` [PATCH v14 14/18] media: i2c: ds90ub913: " Tomi Valkeinen
2023-06-16 13:59 ` [PATCH v14 15/18] media: i2c: ds90ub953: Handle V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK Tomi Valkeinen
2023-06-16 14:33   ` Andy Shevchenko
2023-06-19 10:37     ` Tomi Valkeinen
2023-06-16 13:59 ` [PATCH v14 16/18] media: i2c: ds90ub960: Allow FPD-Link async mode Tomi Valkeinen
2023-06-16 14:34   ` Andy Shevchenko
2023-06-19  9:04     ` Tomi Valkeinen
2023-06-16 13:59 ` [PATCH v14 17/18] media: i2c: ds90ub953: Restructure clkout management Tomi Valkeinen
2023-06-16 14:37   ` Andy Shevchenko
2023-06-16 14:43     ` [PATCH v1 1/1] math.h: Introduce struct u8_fract and struct s8_fract Andy Shevchenko
2023-06-19 10:14     ` [PATCH v14 17/18] media: i2c: ds90ub953: Restructure clkout management Tomi Valkeinen
2023-06-19 10:44       ` Andy Shevchenko
2023-06-19 11:11         ` Tomi Valkeinen
2023-06-19 11:27           ` Andy Shevchenko
2023-06-16 13:59 ` [PATCH v14 18/18] media: i2c: ds90ub953: Support non-sync mode Tomi Valkeinen
2023-06-16 14:47   ` Andy Shevchenko
2023-06-19  9:00     ` Tomi Valkeinen
2023-06-19 10:48       ` Andy Shevchenko
2023-06-19 10:57         ` Tomi Valkeinen [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3dda6808-cda2-e587-88a7-00621b2cfca3@ideasonboard.com \
    --to=tomi.valkeinen@ideasonboard.com \
    --cc=Matti.Vaittinen@fi.rohmeurope.com \
    --cc=andriy.shevchenko@intel.com \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=hverkuil@xs4all.nl \
    --cc=khalasa@piap.pl \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=luca.ceresoli@bootlin.com \
    --cc=m.tretter@pengutronix.de \
    --cc=marex@denx.de \
    --cc=mchehab@kernel.org \
    --cc=mpagano@gentoo.org \
    --cc=peda@axentia.se \
    --cc=robh+dt@kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=satish.nagireddy@getcruise.com \
    --cc=wsa@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox