From: "Pandruvada, Srinivas" <srinivas.pandruvada-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
To: "linux-input-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-input-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"Song,
Hongyan" <hongyan.song-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
"linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Cc: "jikos-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org"
<jikos-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
"jic23-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org"
<jic23-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Subject: Re: [PATCH] iio: hid: hid-sensor-accel-3d: Add second ACC sensor support
Date: Fri, 17 Mar 2017 02:13:35 +0000 [thread overview]
Message-ID: <1489716812.10281.4.camel@intel.com> (raw)
In-Reply-To: <1489659652-35608-1-git-send-email-hongyan.song-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
On Thu, 2017-03-16 at 18:20 +0800, Song Hongyan wrote:
> As accelerometer sensor becomes more and more popular, there are more
> user scenarios have been developed, "Hinge" is a very important
> usecase
> which needs two accelerometer sensors to calculate the included angle
> of keyboard and screen.
> In this case, two accelerometer sensors will be exposed. Currently,
> IIO interface hasn't other way to distinguish two sensors with same
> sensor type, except sensor name. So a new sensor name "accel_2nd_3d"
> is added for secondary accelerometer sensor.
This type of interface will not satisfy all cases. We have some hubs
with many accelerometers attached. Same case is also true even for
discrete sensors. So there should be some framework way to expose
location of sensors.
ACPI has special method called _PLD (Physical Device Location), which
can be used to specify location of any device. So we need to be able
to export such information to user space. We can add for each sensor
the location information.
I can propose some ABI for exporting location information.
Thought?
Thanks,
Srinivas
>
> In HID level, connection type is a good common property to
> differentiate two sensors with same sensor type.
>
> Signed-off-by: Song Hongyan <hongyan.song@intel.com>
> ---
> drivers/iio/accel/hid-sensor-accel-3d.c | 35
> ++++++++++++++++++++--
> .../iio/common/hid-sensors/hid-sensor-attributes.c | 5 ++++
> include/linux/hid-sensor-hub.h | 1 +
> include/linux/hid-sensor-ids.h | 1 +
> 4 files changed, 40 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c
> b/drivers/iio/accel/hid-sensor-accel-3d.c
> index ca5759c..cc4366e 100644
> --- a/drivers/iio/accel/hid-sensor-accel-3d.c
> +++ b/drivers/iio/accel/hid-sensor-accel-3d.c
> @@ -31,6 +31,13 @@
> #include <linux/iio/triggered_buffer.h>
> #include "../common/hid-sensors/hid-sensor-trigger.h"
>
> +enum connection_type {
> + CONN_PC_INTEGRATED_SEL,
> + CONN_PC_ATTACHED_SEL,
> + CONN_PC_EXTERNAL_SEL,
> + CONN_TYPE_MAX,
> +};
> +
> enum accel_3d_channel {
> CHANNEL_SCAN_INDEX_X,
> CHANNEL_SCAN_INDEX_Y,
> @@ -343,6 +350,19 @@ static int accel_3d_parse_report(struct
> platform_device *pdev,
> return ret;
> }
>
> +int connection_type_check(struct hid_sensor_common *st, int
> *conn_tp)
> +{
> + int ret;
> +
> + ret = sensor_hub_get_feature(st->hsdev, st-
> >conn_type.report_id,
> + st->conn_type.index, sizeof(*conn_tp), conn_tp);
> +
> + if (ret < 0 || conn_tp < 0)
> + return -EINVAL;
> +
> + return ret;
> +}
> +
> /* Function to initialize the processing for usage id */
> static int hid_accel_3d_probe(struct platform_device *pdev)
> {
> @@ -352,6 +372,7 @@ static int hid_accel_3d_probe(struct
> platform_device *pdev)
> struct accel_3d_state *accel_state;
> const struct iio_chan_spec *channel_spec;
> int channel_size;
> + s32 conn_type;
>
> struct hid_sensor_hub_device *hsdev = pdev-
> >dev.platform_data;
>
> @@ -367,11 +388,9 @@ static int hid_accel_3d_probe(struct
> platform_device *pdev)
> accel_state->common_attributes.pdev = pdev;
>
> if (hsdev->usage == HID_USAGE_SENSOR_ACCEL_3D) {
> - name = "accel_3d";
> channel_spec = accel_3d_channels;
> channel_size = sizeof(accel_3d_channels);
> } else {
> - name = "gravity";
> channel_spec = gravity_channels;
> channel_size = sizeof(gravity_channels);
> }
> @@ -387,6 +406,18 @@ static int hid_accel_3d_probe(struct
> platform_device *pdev)
> dev_err(&pdev->dev, "failed to duplicate
> channels\n");
> return -ENOMEM;
> }
> +
> + ret = connection_type_check(&accel_state->common_attributes,
> + &conn_type);
> +
> + if (hsdev->usage == HID_USAGE_SENSOR_ACCEL_3D) {
> + if (conn_type == CONN_PC_EXTERNAL_SEL)
> + name = "accel_2nd_3d";
> + else
> + name = "accel_3d";
> + } else
> + name = "gravity";
> +
> ret = accel_3d_parse_report(pdev, hsdev,
> (struct iio_chan_spec *)indio_dev-
> >channels,
> hsdev->usage, accel_state);
> diff --git a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
> b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
> index 4f280ae..cc2ce2a 100644
> --- a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
> +++ b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
> @@ -400,6 +400,11 @@ int hid_sensor_parse_common_attributes(struct
> hid_sensor_hub_device *hsdev,
> &st->sensitivity);
>
> sensor_hub_input_get_attribute_info(hsdev,
> + HID_FEATURE_REPORT,
> usage_id,
> + HID_USAGE_SENSOR_PROP_CONN_T
> YPE,
> + &st->conn_type);
> +
> + sensor_hub_input_get_attribute_info(hsdev,
> HID_INPUT_REPORT,
> usage_id,
> HID_USAGE_SENSOR_TIME_TI
> MESTAMP,
> ×tamp);
> diff --git a/include/linux/hid-sensor-hub.h b/include/linux/hid-
> sensor-hub.h
> index 7ef111d..08756a9 100644
> --- a/include/linux/hid-sensor-hub.h
> +++ b/include/linux/hid-sensor-hub.h
> @@ -237,6 +237,7 @@ struct hid_sensor_common {
> struct hid_sensor_hub_attribute_info report_state;
> struct hid_sensor_hub_attribute_info power_state;
> struct hid_sensor_hub_attribute_info sensitivity;
> + struct hid_sensor_hub_attribute_info conn_type;
> struct work_struct work;
> };
>
> diff --git a/include/linux/hid-sensor-ids.h b/include/linux/hid-
> sensor-ids.h
> index 719c928..2d349f7 100644
> --- a/include/linux/hid-sensor-ids.h
> +++ b/include/linux/hid-sensor-ids.h
> @@ -135,6 +135,7 @@
> #define HID_USAGE_SENSOR_UNITS_DEGREES_PER_SECOND 0x1
> 5
>
> /* Common selectors */
> +#define HID_USAGE_SENSOR_PROP_CONN_TYPE
> 0x200309
> #define HID_USAGE_SENSOR_PROP_REPORT_INTERVAL
> 0x20030E
> #define HID_USAGE_SENSOR_PROP_SENSITIVITY_ABS
> 0x20030F
> #define HID_USAGE_SENSOR_PROP_SENSITIVITY_RANGE_PCT 0
> x200310
next prev parent reply other threads:[~2017-03-17 2:13 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-16 10:20 [PATCH] iio: hid: hid-sensor-accel-3d: Add second ACC sensor support Song Hongyan
2017-03-16 12:01 ` Bastien Nocera
[not found] ` <1489665702.18490.12.camel-0MeiytkfxGOsTnJN9+BGXg@public.gmane.org>
2017-03-17 1:21 ` Song, Hongyan
2017-03-17 13:14 ` Bastien Nocera
[not found] ` <1489659652-35608-1-git-send-email-hongyan.song-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-03-17 2:13 ` Pandruvada, Srinivas [this message]
2017-03-17 13:16 ` Bastien Nocera
[not found] ` <1489756594.18490.22.camel-0MeiytkfxGOsTnJN9+BGXg@public.gmane.org>
2017-03-17 13:31 ` Jonathan Cameron
2017-03-17 16:22 ` Pandruvada, Srinivas
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=1489716812.10281.4.camel@intel.com \
--to=srinivas.pandruvada-ral2jqcrhueavxtiumwx3w@public.gmane.org \
--cc=hongyan.song-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=jic23-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=jikos-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-input-u79uwXL29TY76Z2rM5mHXA@public.gmane.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;
as well as URLs for NNTP newsgroup(s).