All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dongchun Zhu <dongchun.zhu@mediatek.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: <linus.walleij@linaro.org>, <bgolaszewski@baylibre.com>,
	<mchehab@kernel.org>, <robh+dt@kernel.org>,
	<mark.rutland@arm.com>, <sakari.ailus@linux.intel.com>,
	<drinkcat@chromium.org>, <tfiga@chromium.org>,
	<matthias.bgg@gmail.com>, <bingbu.cao@intel.com>,
	<srv_heupstream@mediatek.com>,
	<linux-mediatek@lists.infradead.org>,
	<linux-arm-kernel@lists.infradead.org>, <sj.huang@mediatek.com>,
	<linux-media@vger.kernel.org>, <devicetree@vger.kernel.org>,
	<louis.kuo@mediatek.com>, <shengnan.wang@mediatek.com>
Subject: Re: [V7, 2/2] media: i2c: dw9768: Add DW9768 VCM driver
Date: Tue, 9 Jun 2020 11:45:41 +0800	[thread overview]
Message-ID: <1591674341.8804.628.camel@mhfsdcap03> (raw)
In-Reply-To: <20200608132720.GS2428291@smile.fi.intel.com>

Hi Andy,

On Mon, 2020-06-08 at 16:27 +0300, Andy Shevchenko wrote:
> On Sat, Jun 06, 2020 at 02:19:18PM +0800, Dongchun Zhu wrote:
> > On Fri, 2020-06-05 at 15:46 +0300, Andy Shevchenko wrote:
> > > On Fri, Jun 05, 2020 at 06:54:12PM +0800, Dongchun Zhu wrote:
> 
> ...
> 
> > > > +	depends on I2C && VIDEO_V4L2
> > > 
> > > No compile test?
> > > 
> > 
> > Sorry?
> > Kconfig here is based on the current media tree master branch.
> > It is also what the other similar drivers from Dongwoon do. 
> 
> COMPILE_TEST.
> I dunno if it's established or not practice in media subsystem.
> 
> ...
> 
> > > > +/*
> > > > + * DW9768 requires waiting time (delay time) of t_OPR after power-up,
> > > > + * or in the case of PD reset taking place.
> > > > + */
> > > > +#define DW9768_T_OPR_US				1000
> > > > +#define DW9768_Tvib_MS_BASE10			(64 - 1)
> > > > +#define DW9768_AAC_MODE_DEFAULT			2
> > > 
> > > > +#define DW9768_AAC_TIME_DEFAULT			0x20
> > > 
> > > Hex? Why not decimal?
> > > 
> > 
> > There is one optional property 'dongwoon,aac-timing' defined in DT.
> > I don't know whether you have noticed that.
> > 
> > 'DW9768_AAC_TIME_DEFAULT' is the value set to AACT[5:0] register.
> > I thought the Hex unit should be proper as it is directly written to the
> > Hex register.
> 
> I see. I would rather put it like (BIT(6) / 2) to show explicitly that we
> choose half of the resolution.
> 

I knew your idea.
'(BIT(6) / 2)' may somewhat show the meaning of 'median of the total
range of AACT[5:0]'.

But this value is still very obscure relative to '0x20'.
As I thought that simple is the best, especially for kernel upstream
patch.

> ...
> 
> > > > +	val = ((unsigned char)ret & ~mask) | (val & mask);
> > > 
> > > This cast is weird.
> > > 
> > 
> > Thanks for the review, but this cast is using classical pattern from
> > your suggestion on OV02A10 v5:
> > https://patchwork.linuxtv.org/patch/59788/
> > 
> > So I wonder whether it is still required to be refined currently.
> > Or what would it be supposed to do for the cast?
> 
> Okay, does it produce a warning w/o cast?
> If yes, replace it at least to be the same type as mask and val.
> 

No.

> ...
> 
> > > > +	for ( ; val >= 0; val -= DW9768_MOVE_STEPS) {
> > > > +		ret = dw9768_set_dac(dw9768, val);
> > > > +		if (ret) {
> > > > +			dev_err(&client->dev, "I2C write fail: %d", ret);
> > > > +			return ret;
> > > > +		}
> > > > +		usleep_range(move_delay_us, move_delay_us + 1000);
> > > > +	}
> > > 
> > > 
> > > It will look more naturally in the multiplier kind of value.
> > > 
> > > 	unsigned int steps = DIV_ROUND_UP(...);
> > > 
> > > 	while (steps--) {
> > > 		...(..., steps * ..._MOVE_STEPS);
> > > 		...
> > > 	}
> > > 
> > > but double check arithmetics.
> > 
> > The current coding style is actually updated with reference to your
> > previous comments on DW9768 v3:
> > https://patchwork.linuxtv.org/patch/61856/
> 
> I understand, but can you consider to go further and see if the proposal works?
> 

In fact, your suggestion is something like one another method to set DAC
value to actuator.
It is like there may be several solutions to a question.

Yes. I just tried the new method and it works as expected.
u32 steps = DIV_ROUND_UP(dw9768->focus->val, DW9768_MOVE_STEPS);
while (steps--) {
	ret = dw9768_set_dac(dw9768, steps * DW9768_MOVE_STEPS);
	if (ret)
		return ret;
	usleep_range(move_delay_us, move_delay_us + 1000);
}

But from my perspective, I may prefer to the original method.
As here what we really care is the DAC value,
'dw9768_set_dac(dw9768, val)' seems more simple.


WARNING: multiple messages have this Message-ID (diff)
From: Dongchun Zhu <dongchun.zhu@mediatek.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: mark.rutland@arm.com, devicetree@vger.kernel.org,
	drinkcat@chromium.org, louis.kuo@mediatek.com,
	srv_heupstream@mediatek.com, linus.walleij@linaro.org,
	shengnan.wang@mediatek.com, tfiga@chromium.org,
	bgolaszewski@baylibre.com, sj.huang@mediatek.com,
	robh+dt@kernel.org, linux-mediatek@lists.infradead.org,
	sakari.ailus@linux.intel.com, matthias.bgg@gmail.com,
	bingbu.cao@intel.com, mchehab@kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-media@vger.kernel.org
Subject: Re: [V7, 2/2] media: i2c: dw9768: Add DW9768 VCM driver
Date: Tue, 9 Jun 2020 11:45:41 +0800	[thread overview]
Message-ID: <1591674341.8804.628.camel@mhfsdcap03> (raw)
In-Reply-To: <20200608132720.GS2428291@smile.fi.intel.com>

Hi Andy,

On Mon, 2020-06-08 at 16:27 +0300, Andy Shevchenko wrote:
> On Sat, Jun 06, 2020 at 02:19:18PM +0800, Dongchun Zhu wrote:
> > On Fri, 2020-06-05 at 15:46 +0300, Andy Shevchenko wrote:
> > > On Fri, Jun 05, 2020 at 06:54:12PM +0800, Dongchun Zhu wrote:
> 
> ...
> 
> > > > +	depends on I2C && VIDEO_V4L2
> > > 
> > > No compile test?
> > > 
> > 
> > Sorry?
> > Kconfig here is based on the current media tree master branch.
> > It is also what the other similar drivers from Dongwoon do. 
> 
> COMPILE_TEST.
> I dunno if it's established or not practice in media subsystem.
> 
> ...
> 
> > > > +/*
> > > > + * DW9768 requires waiting time (delay time) of t_OPR after power-up,
> > > > + * or in the case of PD reset taking place.
> > > > + */
> > > > +#define DW9768_T_OPR_US				1000
> > > > +#define DW9768_Tvib_MS_BASE10			(64 - 1)
> > > > +#define DW9768_AAC_MODE_DEFAULT			2
> > > 
> > > > +#define DW9768_AAC_TIME_DEFAULT			0x20
> > > 
> > > Hex? Why not decimal?
> > > 
> > 
> > There is one optional property 'dongwoon,aac-timing' defined in DT.
> > I don't know whether you have noticed that.
> > 
> > 'DW9768_AAC_TIME_DEFAULT' is the value set to AACT[5:0] register.
> > I thought the Hex unit should be proper as it is directly written to the
> > Hex register.
> 
> I see. I would rather put it like (BIT(6) / 2) to show explicitly that we
> choose half of the resolution.
> 

I knew your idea.
'(BIT(6) / 2)' may somewhat show the meaning of 'median of the total
range of AACT[5:0]'.

But this value is still very obscure relative to '0x20'.
As I thought that simple is the best, especially for kernel upstream
patch.

> ...
> 
> > > > +	val = ((unsigned char)ret & ~mask) | (val & mask);
> > > 
> > > This cast is weird.
> > > 
> > 
> > Thanks for the review, but this cast is using classical pattern from
> > your suggestion on OV02A10 v5:
> > https://patchwork.linuxtv.org/patch/59788/
> > 
> > So I wonder whether it is still required to be refined currently.
> > Or what would it be supposed to do for the cast?
> 
> Okay, does it produce a warning w/o cast?
> If yes, replace it at least to be the same type as mask and val.
> 

No.

> ...
> 
> > > > +	for ( ; val >= 0; val -= DW9768_MOVE_STEPS) {
> > > > +		ret = dw9768_set_dac(dw9768, val);
> > > > +		if (ret) {
> > > > +			dev_err(&client->dev, "I2C write fail: %d", ret);
> > > > +			return ret;
> > > > +		}
> > > > +		usleep_range(move_delay_us, move_delay_us + 1000);
> > > > +	}
> > > 
> > > 
> > > It will look more naturally in the multiplier kind of value.
> > > 
> > > 	unsigned int steps = DIV_ROUND_UP(...);
> > > 
> > > 	while (steps--) {
> > > 		...(..., steps * ..._MOVE_STEPS);
> > > 		...
> > > 	}
> > > 
> > > but double check arithmetics.
> > 
> > The current coding style is actually updated with reference to your
> > previous comments on DW9768 v3:
> > https://patchwork.linuxtv.org/patch/61856/
> 
> I understand, but can you consider to go further and see if the proposal works?
> 

In fact, your suggestion is something like one another method to set DAC
value to actuator.
It is like there may be several solutions to a question.

Yes. I just tried the new method and it works as expected.
u32 steps = DIV_ROUND_UP(dw9768->focus->val, DW9768_MOVE_STEPS);
while (steps--) {
	ret = dw9768_set_dac(dw9768, steps * DW9768_MOVE_STEPS);
	if (ret)
		return ret;
	usleep_range(move_delay_us, move_delay_us + 1000);
}

But from my perspective, I may prefer to the original method.
As here what we really care is the DAC value,
'dw9768_set_dac(dw9768, val)' seems more simple.

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

WARNING: multiple messages have this Message-ID (diff)
From: Dongchun Zhu <dongchun.zhu@mediatek.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: mark.rutland@arm.com, devicetree@vger.kernel.org,
	drinkcat@chromium.org, louis.kuo@mediatek.com,
	srv_heupstream@mediatek.com, linus.walleij@linaro.org,
	shengnan.wang@mediatek.com, tfiga@chromium.org,
	bgolaszewski@baylibre.com, sj.huang@mediatek.com,
	robh+dt@kernel.org, linux-mediatek@lists.infradead.org,
	sakari.ailus@linux.intel.com, matthias.bgg@gmail.com,
	bingbu.cao@intel.com, mchehab@kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-media@vger.kernel.org
Subject: Re: [V7, 2/2] media: i2c: dw9768: Add DW9768 VCM driver
Date: Tue, 9 Jun 2020 11:45:41 +0800	[thread overview]
Message-ID: <1591674341.8804.628.camel@mhfsdcap03> (raw)
In-Reply-To: <20200608132720.GS2428291@smile.fi.intel.com>

Hi Andy,

On Mon, 2020-06-08 at 16:27 +0300, Andy Shevchenko wrote:
> On Sat, Jun 06, 2020 at 02:19:18PM +0800, Dongchun Zhu wrote:
> > On Fri, 2020-06-05 at 15:46 +0300, Andy Shevchenko wrote:
> > > On Fri, Jun 05, 2020 at 06:54:12PM +0800, Dongchun Zhu wrote:
> 
> ...
> 
> > > > +	depends on I2C && VIDEO_V4L2
> > > 
> > > No compile test?
> > > 
> > 
> > Sorry?
> > Kconfig here is based on the current media tree master branch.
> > It is also what the other similar drivers from Dongwoon do. 
> 
> COMPILE_TEST.
> I dunno if it's established or not practice in media subsystem.
> 
> ...
> 
> > > > +/*
> > > > + * DW9768 requires waiting time (delay time) of t_OPR after power-up,
> > > > + * or in the case of PD reset taking place.
> > > > + */
> > > > +#define DW9768_T_OPR_US				1000
> > > > +#define DW9768_Tvib_MS_BASE10			(64 - 1)
> > > > +#define DW9768_AAC_MODE_DEFAULT			2
> > > 
> > > > +#define DW9768_AAC_TIME_DEFAULT			0x20
> > > 
> > > Hex? Why not decimal?
> > > 
> > 
> > There is one optional property 'dongwoon,aac-timing' defined in DT.
> > I don't know whether you have noticed that.
> > 
> > 'DW9768_AAC_TIME_DEFAULT' is the value set to AACT[5:0] register.
> > I thought the Hex unit should be proper as it is directly written to the
> > Hex register.
> 
> I see. I would rather put it like (BIT(6) / 2) to show explicitly that we
> choose half of the resolution.
> 

I knew your idea.
'(BIT(6) / 2)' may somewhat show the meaning of 'median of the total
range of AACT[5:0]'.

But this value is still very obscure relative to '0x20'.
As I thought that simple is the best, especially for kernel upstream
patch.

> ...
> 
> > > > +	val = ((unsigned char)ret & ~mask) | (val & mask);
> > > 
> > > This cast is weird.
> > > 
> > 
> > Thanks for the review, but this cast is using classical pattern from
> > your suggestion on OV02A10 v5:
> > https://patchwork.linuxtv.org/patch/59788/
> > 
> > So I wonder whether it is still required to be refined currently.
> > Or what would it be supposed to do for the cast?
> 
> Okay, does it produce a warning w/o cast?
> If yes, replace it at least to be the same type as mask and val.
> 

No.

> ...
> 
> > > > +	for ( ; val >= 0; val -= DW9768_MOVE_STEPS) {
> > > > +		ret = dw9768_set_dac(dw9768, val);
> > > > +		if (ret) {
> > > > +			dev_err(&client->dev, "I2C write fail: %d", ret);
> > > > +			return ret;
> > > > +		}
> > > > +		usleep_range(move_delay_us, move_delay_us + 1000);
> > > > +	}
> > > 
> > > 
> > > It will look more naturally in the multiplier kind of value.
> > > 
> > > 	unsigned int steps = DIV_ROUND_UP(...);
> > > 
> > > 	while (steps--) {
> > > 		...(..., steps * ..._MOVE_STEPS);
> > > 		...
> > > 	}
> > > 
> > > but double check arithmetics.
> > 
> > The current coding style is actually updated with reference to your
> > previous comments on DW9768 v3:
> > https://patchwork.linuxtv.org/patch/61856/
> 
> I understand, but can you consider to go further and see if the proposal works?
> 

In fact, your suggestion is something like one another method to set DAC
value to actuator.
It is like there may be several solutions to a question.

Yes. I just tried the new method and it works as expected.
u32 steps = DIV_ROUND_UP(dw9768->focus->val, DW9768_MOVE_STEPS);
while (steps--) {
	ret = dw9768_set_dac(dw9768, steps * DW9768_MOVE_STEPS);
	if (ret)
		return ret;
	usleep_range(move_delay_us, move_delay_us + 1000);
}

But from my perspective, I may prefer to the original method.
As here what we really care is the DAC value,
'dw9768_set_dac(dw9768, val)' seems more simple.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2020-06-09  3:48 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-05 10:54 [V7, 0/2] media: i2c: Add support for DW9768 VCM driver Dongchun Zhu
2020-06-05 10:54 ` Dongchun Zhu
2020-06-05 10:54 ` Dongchun Zhu
2020-06-05 10:54 ` [V7, 1/2] media: dt-bindings: media: i2c: Document DW9768 bindings Dongchun Zhu
2020-06-05 10:54   ` Dongchun Zhu
2020-06-05 10:54   ` Dongchun Zhu
2020-06-09 19:47   ` Rob Herring
2020-06-09 19:47     ` Rob Herring
2020-06-09 19:47     ` Rob Herring
2020-06-05 10:54 ` [V7, 2/2] media: i2c: dw9768: Add DW9768 VCM driver Dongchun Zhu
2020-06-05 10:54   ` Dongchun Zhu
2020-06-05 10:54   ` Dongchun Zhu
2020-06-05 12:14   ` Sakari Ailus
2020-06-05 12:14     ` Sakari Ailus
2020-06-05 12:14     ` Sakari Ailus
2020-06-05 13:02     ` Tomasz Figa
2020-06-05 13:02       ` Tomasz Figa
2020-06-05 13:02       ` Tomasz Figa
2020-06-05 13:37       ` Sakari Ailus
2020-06-05 13:37         ` Sakari Ailus
2020-06-05 13:37         ` Sakari Ailus
2020-06-06  6:24     ` Dongchun Zhu
2020-06-06  6:24       ` Dongchun Zhu
2020-06-06  6:24       ` Dongchun Zhu
2020-06-05 12:46   ` Andy Shevchenko
2020-06-05 12:46     ` Andy Shevchenko
2020-06-05 12:46     ` Andy Shevchenko
2020-06-05 13:10     ` Tomasz Figa
2020-06-05 13:10       ` Tomasz Figa
2020-06-05 13:10       ` Tomasz Figa
2020-06-06  6:19     ` Dongchun Zhu
2020-06-06  6:19       ` Dongchun Zhu
2020-06-06  6:19       ` Dongchun Zhu
2020-06-08 13:27       ` Andy Shevchenko
2020-06-08 13:27         ` Andy Shevchenko
2020-06-08 13:27         ` Andy Shevchenko
2020-06-09  3:45         ` Dongchun Zhu [this message]
2020-06-09  3:45           ` Dongchun Zhu
2020-06-09  3:45           ` Dongchun Zhu
2020-06-09 11:14           ` Andy Shevchenko
2020-06-09 11:14             ` Andy Shevchenko
2020-06-09 11:14             ` Andy Shevchenko
2020-06-10 12:58             ` Sakari Ailus
2020-06-10 12:58               ` Sakari Ailus
2020-06-10 12:58               ` Sakari Ailus
2020-06-05 13:44   ` Tomasz Figa
2020-06-05 13:44     ` Tomasz Figa
2020-06-05 13:44     ` Tomasz Figa
2020-06-06  6:42     ` Dongchun Zhu
2020-06-06  6:42       ` Dongchun Zhu
2020-06-06  6:42       ` Dongchun Zhu

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=1591674341.8804.628.camel@mhfsdcap03 \
    --to=dongchun.zhu@mediatek.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=bgolaszewski@baylibre.com \
    --cc=bingbu.cao@intel.com \
    --cc=devicetree@vger.kernel.org \
    --cc=drinkcat@chromium.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=louis.kuo@mediatek.com \
    --cc=mark.rutland@arm.com \
    --cc=matthias.bgg@gmail.com \
    --cc=mchehab@kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=shengnan.wang@mediatek.com \
    --cc=sj.huang@mediatek.com \
    --cc=srv_heupstream@mediatek.com \
    --cc=tfiga@chromium.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.