From: Jonathan Cameron <jic23@kernel.org>
To: Tomas Novotny <tomas@novotny.cz>
Cc: linux-iio@vger.kernel.org, "Hartmut Knaack" <knaack.h@gmx.de>,
"Lars-Peter Clausen" <lars@metafoo.de>,
"Peter Meerwald-Stadler" <pmeerw@pmeerw.net>,
"Angus Ainslie" <angus@akkea.ca>,
"Marco Felsch" <m.felsch@pengutronix.de>,
"Thomas Gleixner" <tglx@linutronix.de>,
"Guido Günther" <agx@sigxcpu.org>
Subject: Re: [PATCH 5/5] iio: light: vcnl4000: add control of multi pulse
Date: Sat, 8 Feb 2020 15:17:10 +0000 [thread overview]
Message-ID: <20200208151710.4a9cbc13@archlinux> (raw)
In-Reply-To: <20200205101655.11728-6-tomas@novotny.cz>
On Wed, 5 Feb 2020 11:16:55 +0100
Tomas Novotny <tomas@novotny.cz> wrote:
> Multi pulse settings allow to emit more pulses during one measurement
> (up to 8 on vcnl4040 and vcnl4200). The raw reading is approximately
> multiplied by the multi pulse settings. More information is available in
> the added documentation.
>
> Multi pulse is specific only for proximity sensor. Only the vcnl4040 and
> vcnl4200 hardware supports this settings.
A few comments but this one is more or less good.
Thanks,
Jonathan
>
> Signed-off-by: Tomas Novotny <tomas@novotny.cz>
> ---
> Documentation/ABI/testing/sysfs-bus-iio-vcnl4000 | 21 +++++++++
> drivers/iio/light/vcnl4000.c | 60 ++++++++++++++++++++++++
> 2 files changed, 81 insertions(+)
>
> diff --git a/Documentation/ABI/testing/sysfs-bus-iio-vcnl4000 b/Documentation/ABI/testing/sysfs-bus-iio-vcnl4000
> index 4860f409dbf0..923a78dc9869 100644
> --- a/Documentation/ABI/testing/sysfs-bus-iio-vcnl4000
> +++ b/Documentation/ABI/testing/sysfs-bus-iio-vcnl4000
> @@ -16,3 +16,24 @@ KernelVersion: 5.7
> Contact: linux-iio@vger.kernel.org
> Description:
> The on/off available duty ratios.
> +
> +What: /sys/bus/iio/devices/iio:deviceX/in_proximity_multi_pulse
This is less ambiguous than duty_cycle, but perhaps something
in_proximity_led_pulse_count is more specific?
> +Date: February 2020
> +KernelVersion: 5.7
> +Contact: linux-iio@vger.kernel.org
> +Description:
> + Instead of one single pulse per every measurement, more pulses
> + may be programmed. This leads to a longer led current on-time
> + for each proximity measurement, which also results in a higher
> + detection range. The raw reading is approximately multiplied by
> + the multi pulse settings. The duty ration is not changed. The
Hmm. Normal meaning of duty ratio would be changed by this... It's uneven but
multiple pulses == more on time hence lower duty ratio.
> + settings cannot be changed when the proximity channel is
> + enabled. Valid values are in the respective '_available'
> + attribute.
> +
> +What: /sys/bus/iio/devices/iio:deviceX/in_proximity_multi_pulse_available
> +Date: February 2020
> +KernelVersion: 5.7
> +Contact: linux-iio@vger.kernel.org
> +Description:
> + List of multi pulse values.
> diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c
> index a8c2ce1056a6..cc75e5e7e634 100644
> --- a/drivers/iio/light/vcnl4000.c
> +++ b/drivers/iio/light/vcnl4000.c
> @@ -46,6 +46,7 @@
>
> #define VCNL4200_AL_CONF 0x00 /* Ambient light configuration */
> #define VCNL4200_PS_CONF1 0x03 /* Proximity configuration */
> +#define VCNL4200_PS_CONF3 0x04 /* Proximity conf., white channel, LED I */
> #define VCNL4200_PS_DATA 0x08 /* Proximity data */
> #define VCNL4200_AL_DATA 0x09 /* Ambient light data */
> #define VCNL4200_DEV_ID 0x0e /* Device ID, slave address and version */
> @@ -65,6 +66,8 @@
> #define VCNL4200_PS_DUTY_MASK GENMASK(7, 6) /* Proximity duty ratio */
> #define VCNL4200_PS_DUTY_SHIFT 6
> #define VCNL4200_PS_SD BIT(0) /* Proximity shutdown */
> +#define VCNL4200_PS_MPS_MASK GENMASK(6, 5)
> +#define VCNL4200_PS_MPS_SHIFT 5
You could probably use the FIELD_PREP macros etc to avoid having both mask and
shift defines.
>
> enum vcnl4000_device_ids {
> VCNL4000,
> @@ -223,11 +226,24 @@ static const char * const vcnl4200_ps_duty_ratio_items[] = {
> "1/1280"
> };
>
> +/* Values are directly mapped to register values. */
> +static const char * const vcnl4200_ps_multi_pulse_items[] = {
> + "1",
> + "2",
> + "4",
> + "8"
> +};
> +
> static int vcnl4200_get_ps_duty_ratio(struct iio_dev *indio_dev,
> const struct iio_chan_spec *chan);
> static int vcnl4200_set_ps_duty_ratio(struct iio_dev *indio_dev,
> const struct iio_chan_spec *chan,
> unsigned int mode);
> +static int vcnl4200_get_ps_multi_pulse(struct iio_dev *indio_dev,
> + const struct iio_chan_spec *chan);
> +static int vcnl4200_set_ps_multi_pulse(struct iio_dev *indio_dev,
> + const struct iio_chan_spec *chan,
> + unsigned int mode);
>
> static const struct iio_enum vcnl4040_ps_duty_ratio_enum = {
> .items = vcnl4040_ps_duty_ratio_items,
> @@ -243,15 +259,26 @@ static const struct iio_enum vcnl4200_ps_duty_ratio_enum = {
> .set = vcnl4200_set_ps_duty_ratio,
> };
>
> +static const struct iio_enum vcnl4200_ps_multi_pulse_enum = {
> + .items = vcnl4200_ps_multi_pulse_items,
> + .num_items = ARRAY_SIZE(vcnl4200_ps_multi_pulse_items),
> + .get = vcnl4200_get_ps_multi_pulse,
> + .set = vcnl4200_set_ps_multi_pulse,
> +};
> +
> static const struct iio_chan_spec_ext_info vcnl4040_ps_ext_info[] = {
> IIO_ENUM("duty_ratio", IIO_SEPARATE, &vcnl4040_ps_duty_ratio_enum),
> IIO_ENUM_AVAILABLE("duty_ratio", &vcnl4040_ps_duty_ratio_enum),
> + IIO_ENUM("multi_pulse", IIO_SEPARATE, &vcnl4200_ps_multi_pulse_enum),
> + IIO_ENUM_AVAILABLE("multi_pulse", &vcnl4200_ps_multi_pulse_enum),
> { },
> };
>
> static const struct iio_chan_spec_ext_info vcnl4200_ps_ext_info[] = {
> IIO_ENUM("duty_ratio", IIO_SEPARATE, &vcnl4200_ps_duty_ratio_enum),
> IIO_ENUM_AVAILABLE("duty_ratio", &vcnl4200_ps_duty_ratio_enum),
> + IIO_ENUM("multi_pulse", IIO_SEPARATE, &vcnl4200_ps_multi_pulse_enum),
> + IIO_ENUM_AVAILABLE("multi_pulse", &vcnl4200_ps_multi_pulse_enum),
> { },
> };
>
> @@ -638,6 +665,39 @@ static int vcnl4200_set_ps_duty_ratio(struct iio_dev *indio_dev,
> return vcnl4200_set_samp_rate(data, IIO_PROXIMITY);
> };
>
> +static int vcnl4200_get_ps_multi_pulse(struct iio_dev *indio_dev,
> + const struct iio_chan_spec *chan)
> +{
> + int ret;
> + unsigned int val;
> + struct vcnl4000_data *data = iio_priv(indio_dev);
> +
> + ret = regmap_read(data->regmap, VCNL4200_PS_CONF3, &val);
> + if (ret < 0)
> + return ret;
> +
> + val &= VCNL4200_PS_MPS_MASK;
> + val >>= VCNL4200_PS_MPS_SHIFT;
> +
> + return val;
> +};
> +
> +static int vcnl4200_set_ps_multi_pulse(struct iio_dev *indio_dev,
> + const struct iio_chan_spec *chan,
> + unsigned int mode)
> +{
> + int ret;
> + struct vcnl4000_data *data = iio_priv(indio_dev);
> +
> + ret = vcnl4200_check_enabled(data, IIO_PROXIMITY);
> + if (ret < 0)
> + return ret;
> +
> + return regmap_update_bits(data->regmap, VCNL4200_PS_CONF3,
> + VCNL4200_PS_MPS_MASK,
> + mode << VCNL4200_PS_MPS_SHIFT);
> +};
> +
> static const struct vcnl4000_chip_spec vcnl4000_chip_spec_cfg[] = {
> [VCNL4000] = {
> .prod = "VCNL4000",
next prev parent reply other threads:[~2020-02-08 15:17 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-05 10:16 [PATCH 0/5] iio: light: vcnl4000: make some settings configurable Tomas Novotny
2020-02-05 10:16 ` [PATCH 1/5] iio: light: vcnl4000: convert to regmap Tomas Novotny
2020-02-05 11:46 ` Marco Felsch
2020-02-07 13:40 ` Tomas Novotny
2020-02-05 10:16 ` [PATCH 2/5] iio: light: vcnl4000: add enable attributes for vcnl4040/4200 Tomas Novotny
2020-02-08 14:53 ` Jonathan Cameron
2020-02-11 15:37 ` Tomas Novotny
2020-02-14 13:12 ` Jonathan Cameron
2020-02-05 10:16 ` [PATCH 3/5] iio: light: vcnl4000: add proximity integration time " Tomas Novotny
2020-02-08 15:03 ` Jonathan Cameron
2020-02-11 16:25 ` Tomas Novotny
2020-02-14 13:14 ` Jonathan Cameron
2020-02-05 10:16 ` [PATCH 4/5] iio: light: vcnl4000: add control of duty ratio Tomas Novotny
2020-02-08 15:11 ` Jonathan Cameron
2020-02-11 16:50 ` Tomas Novotny
2020-02-14 13:16 ` Jonathan Cameron
2020-02-05 10:16 ` [PATCH 5/5] iio: light: vcnl4000: add control of multi pulse Tomas Novotny
2020-02-08 15:17 ` Jonathan Cameron [this message]
2020-02-11 17:01 ` Tomas Novotny
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=20200208151710.4a9cbc13@archlinux \
--to=jic23@kernel.org \
--cc=agx@sigxcpu.org \
--cc=angus@akkea.ca \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=m.felsch@pengutronix.de \
--cc=pmeerw@pmeerw.net \
--cc=tglx@linutronix.de \
--cc=tomas@novotny.cz \
/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.