Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1409798 > unrolled thread

[RFC 0/4] Intel Integrated Sensor Hub Support (ISH)

Started bySrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
First post2016-05-31 06:30 +0200
Last post2016-06-10 16:10 +0200
Articles 14 — 4 participants

Back to article view | Back to linux.kernel


Contents

  [RFC 0/4] Intel Integrated Sensor Hub Support (ISH) Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> - 2016-05-31 06:30 +0200
    [RFC 4/4] hid: intel-ish-hid: ISH HID client driver Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> - 2016-05-31 06:30 +0200
    [RFC 1/4] Documentation: hid: Intel ISH HID document Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> - 2016-05-31 06:40 +0200
    Re: [RFC 0/4] Intel Integrated Sensor Hub Support (ISH) Atri Bhattacharya <badshah400@aim.com> - 2016-06-01 15:50 +0200
    Re: [RFC 0/4] Intel Integrated Sensor Hub Support (ISH) Grant Likely <grant.likely@secretlab.ca> - 2016-06-09 23:50 +0200
      Re: [RFC 0/4] Intel Integrated Sensor Hub Support (ISH) Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> - 2016-06-10 00:00 +0200
        Re: [RFC 0/4] Intel Integrated Sensor Hub Support (ISH) Grant Likely <grant.likely@secretlab.ca> - 2016-06-10 11:50 +0200
          Re: [RFC 0/4] Intel Integrated Sensor Hub Support (ISH) Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> - 2016-06-10 16:00 +0200
            Re: [RFC 0/4] Intel Integrated Sensor Hub Support (ISH) Bastien Nocera <hadess@hadess.net> - 2016-06-10 16:30 +0200
              Re: [RFC 0/4] Intel Integrated Sensor Hub Support (ISH) Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> - 2016-06-10 16:50 +0200
                Re: [RFC 0/4] Intel Integrated Sensor Hub Support (ISH) Bastien Nocera <hadess@hadess.net> - 2016-06-10 17:10 +0200
                  Re: [RFC 0/4] Intel Integrated Sensor Hub Support (ISH) Bastien Nocera <hadess@hadess.net> - 2016-06-10 17:30 +0200
                  Re: [RFC 0/4] Intel Integrated Sensor Hub Support (ISH) Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> - 2016-06-10 17:30 +0200
          Re: [RFC 0/4] Intel Integrated Sensor Hub Support (ISH) Grant Likely <grant.likely@secretlab.ca> - 2016-06-10 16:10 +0200

#1409798 — [RFC 0/4] Intel Integrated Sensor Hub Support (ISH)

FromSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Date2016-05-31 06:30 +0200
Subject[RFC 0/4] Intel Integrated Sensor Hub Support (ISH)
Message-ID<rEJtv-61m-7@gated-at.bofh.it>
Starting from Cherrytrail, multiple generation of Intel processors offers
on package sensor hub. Several recent tablets, 2-in-1 convertible laptops
are using ISH instead of external sensor hubs. This resulted in lack of
support of sensor function like device rotation and auto backlight
adjustment. In addition, depending on the OEM implementation, support of ISH
is required to support low power sleep states.

The support of ISH on Linux platforms is not new. Android platforms with
Intel SoCs had this support for a while submitted by Daniel Drubin. 
This patcheset is reusing most of those changes with  clean up and
removing Android platform specific changes.

This series is tested on:
- Lenovo Yoga 260 with Skylake processor
- HP Pavilion x2 detachable with Cherrytrail 

The user mode ABI is still same as external sensor hubs using Linux
IIO. So existing user mode software should still work without change.
This series primarily brings in new HID transport used in ISH.

This series submitted as a RFC to try on several devices. We have 
received request from Linux users who wanted this support. So I hope all
those users try and give feedback.

Daniel Drubin (3):
  hid: intel_ish-hid: ISH Transport layer
  hid: intel-ish-hid: ipc layer
  hid: intel-ish-hid: ISH HID client driver

Srinivas Pandruvada (1):
  Documentation: hid: Intel ISH HID document

 Documentation/hid/intel-ish-hid.txt          |  375 +++++++++
 drivers/hid/Kconfig                          |    2 +
 drivers/hid/Makefile                         |    2 +
 drivers/hid/intel-ish-hid/Kconfig            |   27 +
 drivers/hid/intel-ish-hid/Makefile           |   20 +
 drivers/hid/intel-ish-hid/ipc/hw-ish-regs.h  |  220 +++++
 drivers/hid/intel-ish-hid/ipc/hw-ish.h       |   71 ++
 drivers/hid/intel-ish-hid/ipc/ipc.c          |  710 ++++++++++++++++
 drivers/hid/intel-ish-hid/ipc/pci-ish.c      |  238 ++++++
 drivers/hid/intel-ish-hid/ipc/utils.h        |   65 ++
 drivers/hid/intel-ish-hid/ishtp-hid-client.c |  672 +++++++++++++++
 drivers/hid/intel-ish-hid/ishtp-hid.c        |  201 +++++
 drivers/hid/intel-ish-hid/ishtp-hid.h        |  157 ++++
 drivers/hid/intel-ish-hid/ishtp/bus.c        |  670 +++++++++++++++
 drivers/hid/intel-ish-hid/ishtp/bus.h        |   99 +++
 drivers/hid/intel-ish-hid/ishtp/client.c     | 1131 ++++++++++++++++++++++++++
 drivers/hid/intel-ish-hid/ishtp/client.h     |  196 +++++
 drivers/hid/intel-ish-hid/ishtp/dma-if.c     |  175 ++++
 drivers/hid/intel-ish-hid/ishtp/hbm.c        |  911 +++++++++++++++++++++
 drivers/hid/intel-ish-hid/ishtp/hbm.h        |  319 ++++++++
 drivers/hid/intel-ish-hid/ishtp/init.c       |   94 +++
 drivers/hid/intel-ish-hid/ishtp/ishtp-dev.h  |  276 +++++++
 include/trace/events/intel_ish.h             |   30 +
 23 files changed, 6661 insertions(+)
 create mode 100644 Documentation/hid/intel-ish-hid.txt
 create mode 100644 drivers/hid/intel-ish-hid/Kconfig
 create mode 100644 drivers/hid/intel-ish-hid/Makefile
 create mode 100644 drivers/hid/intel-ish-hid/ipc/hw-ish-regs.h
 create mode 100644 drivers/hid/intel-ish-hid/ipc/hw-ish.h
 create mode 100644 drivers/hid/intel-ish-hid/ipc/ipc.c
 create mode 100644 drivers/hid/intel-ish-hid/ipc/pci-ish.c
 create mode 100644 drivers/hid/intel-ish-hid/ipc/utils.h
 create mode 100644 drivers/hid/intel-ish-hid/ishtp-hid-client.c
 create mode 100644 drivers/hid/intel-ish-hid/ishtp-hid.c
 create mode 100644 drivers/hid/intel-ish-hid/ishtp-hid.h
 create mode 100644 drivers/hid/intel-ish-hid/ishtp/bus.c
 create mode 100644 drivers/hid/intel-ish-hid/ishtp/bus.h
 create mode 100644 drivers/hid/intel-ish-hid/ishtp/client.c
 create mode 100644 drivers/hid/intel-ish-hid/ishtp/client.h
 create mode 100644 drivers/hid/intel-ish-hid/ishtp/dma-if.c
 create mode 100644 drivers/hid/intel-ish-hid/ishtp/hbm.c
 create mode 100644 drivers/hid/intel-ish-hid/ishtp/hbm.h
 create mode 100644 drivers/hid/intel-ish-hid/ishtp/init.c
 create mode 100644 drivers/hid/intel-ish-hid/ishtp/ishtp-dev.h
 create mode 100644 include/trace/events/intel_ish.h

-- 
1.9.1

[toc] | [next] | [standalone]


#1409800 — [RFC 4/4] hid: intel-ish-hid: ISH HID client driver

FromSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Date2016-05-31 06:30 +0200
Subject[RFC 4/4] hid: intel-ish-hid: ISH HID client driver
Message-ID<rEJtv-61m-11@gated-at.bofh.it>
In reply to#1409798
From: Daniel Drubin <daniel.drubin@intel.com>

This driver is responsible for implementing ISH HID client, which
gets HID description and report. Once it has completely gets
report descriptors, it registers as a HID LL drivers. This implements
necessary callbacks so that it can be used by HID sensor hub driver.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
 drivers/hid/intel-ish-hid/Makefile           |   4 +
 drivers/hid/intel-ish-hid/ishtp-hid-client.c | 672 +++++++++++++++++++++++++++
 drivers/hid/intel-ish-hid/ishtp-hid.c        | 201 ++++++++
 drivers/hid/intel-ish-hid/ishtp-hid.h        | 157 +++++++
 4 files changed, 1034 insertions(+)
 create mode 100644 drivers/hid/intel-ish-hid/ishtp-hid-client.c
 create mode 100644 drivers/hid/intel-ish-hid/ishtp-hid.c
 create mode 100644 drivers/hid/intel-ish-hid/ishtp-hid.h

diff --git a/drivers/hid/intel-ish-hid/Makefile b/drivers/hid/intel-ish-hid/Makefile
index 2c83cb9..6727c66 100644
--- a/drivers/hid/intel-ish-hid/Makefile
+++ b/drivers/hid/intel-ish-hid/Makefile
@@ -13,4 +13,8 @@ obj-$(CONFIG_INTEL_ISH_HID_IPC) += intel-ish-ipc.o
 intel-ish-ipc-objs := ipc/ipc.o
 intel-ish-ipc-objs += ipc/pci-ish.o
 
+obj-$(CONFIG_INTEL_ISH_HID) += intel-ishtp-hid.o
+intel-ishtp-hid-objs := ishtp-hid.o
+intel-ishtp-hid-objs += ishtp-hid-client.o
+
 ccflags-y += -Idrivers/hid/intel-ish-hid/ishtp
diff --git a/drivers/hid/intel-ish-hid/ishtp-hid-client.c b/drivers/hid/intel-ish-hid/ishtp-hid-client.c
new file mode 100644
index 0000000..5d22be6
--- /dev/null
+++ b/drivers/hid/intel-ish-hid/ishtp-hid-client.c
@@ -0,0 +1,672 @@
+/*
+ * ISHTP client driver for HID (ISH)
+ *
+ * Copyright (c) 2014-2016, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ */
+
+#include <linux/module.h>
+#include <linux/hid.h>
+#include "ishtp/ishtp-dev.h"
+#include "ishtp/client.h"
+#include "ishtp-hid.h"
+
+/* Rx ring buffer pool size */
+#define HID_CL_RX_RING_SIZE	32
+#define HID_CL_TX_RING_SIZE	16
+
+/**
+ * report_bad_packets() - Report bad packets
+ * @hid_ishtp_cl:	Client instance to get stats
+ * @recv_buf:		Raw received host interface message
+ * @cur_pos:		Current position index in payload
+ * @payload_len:	Length of payload expected
+ *
+ * Dumps error in case bad packet is received
+ */
+static void report_bad_packet(struct ishtp_cl *hid_ishtp_cl, void *recv_buf,
+			      size_t cur_pos,  size_t payload_len)
+{
+	struct hostif_msg *recv_msg = recv_buf;
+	struct ishtp_cl_data *client_data = hid_ishtp_cl->client_data;
+
+	dev_err(&hid_ishtp_cl->device->dev, "[hid-ish]: BAD packet %02X\n"
+		"total_bad=%u cur_pos=%u\n"
+		"[%02X %02X %02X %02X]\n"
+		"payload_len=%u\n"
+		"multi_packet_cnt=%u\n"
+		"is_response=%02X\n",
+		recv_msg->hdr.command, client_data->bad_recv_cnt,
+		(unsigned int)cur_pos,
+		((unsigned char *)recv_msg)[0], ((unsigned char *)recv_msg)[1],
+		((unsigned char *)recv_msg)[2], ((unsigned char *)recv_msg)[3],
+		(unsigned int)payload_len, client_data->multi_packet_cnt,
+		recv_msg->hdr.command & ~CMD_MASK);
+}
+
+/**
+ * process_recv() - Received and parse incoming packet
+ * @hid_ishtp_cl:	Client instance to get stats
+ * @recv_buf:		Raw received host interface message
+ * @data_len:		length of the message
+ *
+ * Parse the incoming packet. If it is a response packet then it will update
+ * per instance flags and wake up the caller waiting to for the response.
+ */
+static void process_recv(struct ishtp_cl *hid_ishtp_cl, void *recv_buf,
+			 size_t data_len)
+{
+	struct hostif_msg *recv_msg;
+	unsigned char *payload;
+	struct device_info *dev_info;
+	int i, j;
+	size_t	payload_len, total_len, cur_pos;
+	int report_type;
+	struct report_list *reports_list;
+	char *reports;
+	size_t report_len;
+	struct ishtp_cl_data *client_data = hid_ishtp_cl->client_data;
+
+	if (data_len < sizeof(struct hostif_msg_hdr)) {
+		dev_err(&hid_ishtp_cl->device->dev,
+			"[hid-ish]: error, received %u which is "
+			"less than data header %u\n",
+			(unsigned int)data_len,
+			(unsigned int)sizeof(struct hostif_msg_hdr));
+		++client_data->bad_recv_cnt;
+		ish_hw_reset(hid_ishtp_cl->dev);
+		return;
+	}
+
+	payload = recv_buf + sizeof(struct hostif_msg_hdr);
+	total_len = data_len;
+	cur_pos = 0;
+
+	do {
+		recv_msg = (struct hostif_msg *)(recv_buf + cur_pos);
+		payload_len = recv_msg->hdr.size;
+
+		/* Sanity checks */
+		if (cur_pos + payload_len + sizeof(struct hostif_msg) >
+				total_len) {
+			++client_data->bad_recv_cnt;
+			report_bad_packet(hid_ishtp_cl, recv_msg, cur_pos,
+					  payload_len);
+			ish_hw_reset(hid_ishtp_cl->dev);
+			break;
+		}
+
+
+		switch (recv_msg->hdr.command & CMD_MASK) {
+		case HOSTIF_DM_ENUM_DEVICES:
+			if ((!(recv_msg->hdr.command & ~CMD_MASK) ||
+					client_data->init_done)) {
+				++client_data->bad_recv_cnt;
+				report_bad_packet(hid_ishtp_cl, recv_msg,
+						  cur_pos,
+						  payload_len);
+				ish_hw_reset(hid_ishtp_cl->dev);
+				break;
+			}
+			client_data->hid_dev_count = (unsigned int)*payload;
+			client_data->hid_devices = devm_kzalloc(
+						&hid_ishtp_cl->device->dev,
+						client_data->hid_dev_count *
+						sizeof(struct device_info),
+						GFP_KERNEL);
+			if (!client_data->hid_devices) {
+				dev_err(&hid_ishtp_cl->device->dev,
+				"Mem alloc failed for hid device info\n");
+				wake_up(&client_data->init_wait);
+				break;
+			}
+			for (i = 0; i < client_data->hid_dev_count; ++i) {
+				if (1 + sizeof(struct device_info) * i >=
+						payload_len) {
+					dev_err(&hid_ishtp_cl->device->dev,
+						"[hid-ish]: [ENUM_DEVICES]:"
+						" content size %lu "
+						"is bigger than "
+						"payload_len %u\n",
+						1 + sizeof(struct device_info)
+						* i,
+						(unsigned int)payload_len);
+				}
+
+				if (1 + sizeof(struct device_info) * i >=
+						data_len)
+					break;
+
+				dev_info = (struct device_info *)(payload + 1 +
+					sizeof(struct device_info) * i);
+				if (client_data->hid_devices)
+					memcpy(client_data->hid_devices + i,
+					       dev_info,
+					       sizeof(struct device_info));
+			}
+
+			client_data->enum_devices_done = 1;
+			wake_up(&client_data->init_wait);
+
+			break;
+
+		case HOSTIF_GET_HID_DESCRIPTOR:
+			if ((!(recv_msg->hdr.command & ~CMD_MASK) ||
+					client_data->init_done)) {
+				++client_data->bad_recv_cnt;
+				report_bad_packet(hid_ishtp_cl, recv_msg,
+						  cur_pos,
+						  payload_len);
+				ish_hw_reset(hid_ishtp_cl->dev);
+				break;
+			}
+			client_data->hid_descr[client_data->cur_hid_dev] =
+				devm_kmalloc(&hid_ishtp_cl->device->dev,
+					     payload_len, GFP_KERNEL);
+			if (client_data->hid_descr[client_data->cur_hid_dev]) {
+				memcpy(client_data->hid_descr[
+						client_data->cur_hid_dev],
+				       payload, payload_len);
+				client_data->hid_descr_size[
+				client_data->cur_hid_dev] = payload_len;
+				client_data->hid_descr_done = 1;
+			}
+			wake_up(&client_data->init_wait);
+
+			break;
+
+		case HOSTIF_GET_REPORT_DESCRIPTOR:
+			if ((!(recv_msg->hdr.command & ~CMD_MASK) ||
+					client_data->init_done)) {
+				++client_data->bad_recv_cnt;
+				report_bad_packet(hid_ishtp_cl, recv_msg,
+						  cur_pos,
+						  payload_len);
+				ish_hw_reset(hid_ishtp_cl->dev);
+				break;
+			}
+			client_data->report_descr[client_data->cur_hid_dev] =
+				devm_kmalloc(&hid_ishtp_cl->device->dev,
+					     payload_len, GFP_KERNEL);
+			if (client_data->report_descr[
+						client_data->cur_hid_dev]) {
+				memcpy(client_data->report_descr[
+					client_data->cur_hid_dev], payload,
+				       payload_len);
+				client_data->report_descr_size[
+				client_data->cur_hid_dev] = payload_len;
+				client_data->report_descr_done = 1;
+			}
+			wake_up(&client_data->init_wait);
+
+			break;
+
+		case HOSTIF_GET_FEATURE_REPORT:
+			report_type = HID_FEATURE_REPORT;
+			goto	do_get_report;
+
+		case HOSTIF_GET_INPUT_REPORT:
+			report_type = HID_INPUT_REPORT;
+do_get_report:
+			/* Get index of device that matches this id */
+			for (i = 0; i < client_data->num_hid_devices; ++i) {
+				if (recv_msg->hdr.device_id ==
+					client_data->hid_devices[i].dev_id)
+					if (client_data->hid_sensor_hubs[i]) {
+						hid_input_report(
+						client_data->hid_sensor_hubs[
+									i],
+						report_type, payload,
+						payload_len, 0);
+						break;
+					}
+			}
+			client_data->get_report_done = 1;
+			wake_up(&client_data->ishtp_hid_wait);
+			break;
+
+		case HOSTIF_SET_FEATURE_REPORT:
+			client_data->get_report_done = 1;
+			wake_up(&client_data->ishtp_hid_wait);
+			break;
+
+		case HOSTIF_PUBLISH_INPUT_REPORT:
+			report_type = HID_INPUT_REPORT;
+			for (i = 0; i < client_data->num_hid_devices; ++i)
+				if (recv_msg->hdr.device_id ==
+					client_data->hid_devices[i].dev_id)
+					if (client_data->hid_sensor_hubs[i])
+						hid_input_report(
+						client_data->hid_sensor_hubs[
+									i],
+						report_type, payload,
+						payload_len, 0);
+			break;
+
+		case HOSTIF_PUBLISH_INPUT_REPORT_LIST:
+			report_type = HID_INPUT_REPORT;
+			reports_list = (struct report_list *)payload;
+			reports = (char *)reports_list->reports;
+
+			for (j = 0; j < reports_list->num_of_reports; j++) {
+				recv_msg = (struct hostif_msg *)(reports +
+					sizeof(uint16_t));
+				report_len = *(uint16_t *)reports;
+				payload = reports + sizeof(uint16_t) +
+					sizeof(struct hostif_msg_hdr);
+				payload_len = report_len -
+					sizeof(struct hostif_msg_hdr);
+
+				for (i = 0; i < client_data->num_hid_devices;
+				     ++i)
+					if (recv_msg->hdr.device_id ==
+					client_data->hid_devices[i].dev_id &&
+					client_data->hid_sensor_hubs[i]) {
+						hid_input_report(
+						client_data->hid_sensor_hubs[
+									i],
+						report_type,
+						payload, payload_len,
+						0);
+					}
+
+				reports += sizeof(uint16_t) + report_len;
+			}
+			break;
+		default:
+			++client_data->bad_recv_cnt;
+			report_bad_packet(hid_ishtp_cl, recv_msg, cur_pos,
+					  payload_len);
+			ish_hw_reset(hid_ishtp_cl->dev);
+			break;
+
+		}
+
+		if (!cur_pos && cur_pos + payload_len +
+				sizeof(struct hostif_msg) < total_len)
+			++client_data->multi_packet_cnt;
+
+		cur_pos += payload_len + sizeof(struct hostif_msg);
+		payload += payload_len + sizeof(struct hostif_msg);
+
+	} while (cur_pos < total_len);
+}
+
+/**
+ * ish_cl_event_cb() - bus driver callback for incoming message/packet
+ * @device:	Pointer to the the ishtp client device for which this message
+ *		is targeted
+ *
+ * Remove the packet from the list and process the message by calling
+ * process_recv
+ */
+static void ish_cl_event_cb(struct ishtp_cl_device *device)
+{
+	struct ishtp_cl	*hid_ishtp_cl = device->driver_data;
+	struct ishtp_cl_rb *rb_in_proc;
+	size_t r_length;
+	unsigned long flags;
+
+	if (!hid_ishtp_cl)
+		return;
+
+	spin_lock_irqsave(&hid_ishtp_cl->in_process_spinlock, flags);
+	while (!list_empty(&hid_ishtp_cl->in_process_list.list)) {
+		rb_in_proc = list_entry(
+			hid_ishtp_cl->in_process_list.list.next,
+			struct ishtp_cl_rb, list);
+		list_del_init(&rb_in_proc->list);
+		spin_unlock_irqrestore(&hid_ishtp_cl->in_process_spinlock,
+			flags);
+
+		if (!rb_in_proc->buffer.data)
+			return;
+
+		r_length = rb_in_proc->buf_idx;
+
+		/* decide what to do with received data */
+		process_recv(hid_ishtp_cl, rb_in_proc->buffer.data, r_length);
+
+		ishtp_io_rb_recycle(rb_in_proc);
+		spin_lock_irqsave(&hid_ishtp_cl->in_process_spinlock, flags);
+	}
+	spin_unlock_irqrestore(&hid_ishtp_cl->in_process_spinlock, flags);
+}
+
+/**
+ * hid_ishtp_set_feature() - send request to ISH FW to set a feature request
+ * @hid:	hid device instance for this request
+ * @buf:	feature buffer
+ * @len:	Length of feature buffer
+ * @report_id:	Report id for the feature set request
+ *
+ * This is called from hid core .request() callback. This function doesn't wait
+ * for response.
+ */
+void hid_ishtp_set_feature(struct hid_device *hid, char *buf, unsigned int len,
+			   int report_id)
+{
+	struct ishtp_cl *hid_ishtp_cl = hid->driver_data;
+	struct ishtp_cl_data *client_data = hid_ishtp_cl->client_data;
+	struct hostif_msg *msg = (struct hostif_msg *)buf;
+	int	rv;
+	int	i;
+
+	memset(msg, 0, sizeof(struct hostif_msg));
+	msg->hdr.command = HOSTIF_SET_FEATURE_REPORT;
+	for (i = 0; i < client_data->num_hid_devices; ++i) {
+		if (hid == client_data->hid_sensor_hubs[i]) {
+			msg->hdr.device_id =
+				client_data->hid_devices[i].dev_id;
+			break;
+		}
+	}
+
+	if (i == client_data->num_hid_devices)
+		return;
+
+	rv = ishtp_cl_send(hid_ishtp_cl, buf, len);
+}
+
+/**
+ * hid_ishtp_get_report() - request to get feature/input report
+ * @hid:	hid device instance for this request
+ * @report_id:	Report id for the get request
+ * @report_type:	Report type for the this request
+ *
+ * This is called from hid core .request() callback. This function will send
+ * request to FW and return without waiting for response.
+ */
+void hid_ishtp_get_report(struct hid_device *hid, int report_id,
+			  int report_type)
+{
+	struct ishtp_cl *hid_ishtp_cl = hid->driver_data;
+	struct ishtp_cl_data *client_data = hid_ishtp_cl->client_data;
+	static unsigned char	buf[10];
+	unsigned int	len;
+	struct hostif_msg_to_sensor *msg = (struct hostif_msg_to_sensor *)buf;
+	int	rv;
+	int	i;
+
+	len = sizeof(struct hostif_msg_to_sensor);
+
+	memset(msg, 0, sizeof(struct hostif_msg_to_sensor));
+	msg->hdr.command = (report_type == HID_FEATURE_REPORT) ?
+		HOSTIF_GET_FEATURE_REPORT : HOSTIF_GET_INPUT_REPORT;
+	for (i = 0; i < client_data->num_hid_devices; ++i) {
+		if (hid == client_data->hid_sensor_hubs[i]) {
+			msg->hdr.device_id =
+				client_data->hid_devices[i].dev_id;
+			break;
+		}
+	}
+
+	if (i == client_data->num_hid_devices)
+		return;
+
+	msg->report_id = report_id;
+	rv = ishtp_cl_send(hid_ishtp_cl, buf, len);
+}
+
+/**
+ * hid_ishtp_cl_init() - Init function for ISHTP client
+ * @hid_istp_cl:	ISHTP client instance
+ *
+ * This function complete the initializtion of the client. The summary of
+ * processing:
+ * - Send request to enumerate the hid clients
+ *	Get the HID descriptor for each enumearated device
+ *	Get report description of each device
+ *	Register each device wik hid core by calling ishtp_hid_probe
+ */
+static int hid_ishtp_cl_init(struct ishtp_cl *hid_ishtp_cl)
+{
+	static unsigned char buf[512];
+	unsigned int len;
+	struct hostif_msg *msg = (struct hostif_msg *)buf;
+	struct ishtp_device *dev;
+	int retry_count;
+	unsigned long flags;
+	struct ishtp_cl_data *client_data = hid_ishtp_cl->client_data;
+	int i;
+	int rv;
+
+	init_waitqueue_head(&client_data->init_wait);
+	init_waitqueue_head(&client_data->ishtp_hid_wait);
+
+	rv = ishtp_cl_link(hid_ishtp_cl, ISHTP_HOST_CLIENT_ID_ANY);
+	if (rv)
+		return	-ENOMEM;
+
+	client_data->init_done = 0;
+
+	dev = hid_ishtp_cl->dev;
+
+	/* Connect to FW client */
+	hid_ishtp_cl->rx_ring_size = HID_CL_RX_RING_SIZE;
+	hid_ishtp_cl->tx_ring_size = HID_CL_TX_RING_SIZE;
+
+	spin_lock_irqsave(&dev->fw_clients_lock, flags);
+	i = ishtp_fw_cl_by_uuid(dev, &hid_ishtp_guid);
+	if (i < 0) {
+		spin_unlock_irqrestore(&dev->fw_clients_lock, flags);
+		return i;
+	}
+	hid_ishtp_cl->fw_client_id = dev->fw_clients[i].client_id;
+	spin_unlock_irqrestore(&dev->fw_clients_lock, flags);
+	hid_ishtp_cl->state = ISHTP_CL_CONNECTING;
+
+	rv = ishtp_cl_connect(hid_ishtp_cl);
+	if (rv)
+		goto ret;
+
+	/* Register read callback */
+	ishtp_register_event_cb(hid_ishtp_cl->device, ish_cl_event_cb);
+
+	/* Send HOSTIF_DM_ENUM_DEVICES */
+	memset(msg, 0, sizeof(struct hostif_msg));
+	msg->hdr.command = HOSTIF_DM_ENUM_DEVICES;
+	len = sizeof(struct hostif_msg);
+	rv = ishtp_cl_send(hid_ishtp_cl, buf, len);
+	if (rv)
+		goto ret;
+
+	rv = 0;
+
+	retry_count = 0;
+	while (!client_data->enum_devices_done &&
+	       retry_count < 10) {
+		wait_event_timeout(client_data->init_wait,
+				   client_data->enum_devices_done,
+				   3 * HZ);
+		++retry_count;
+		if (!client_data->enum_devices_done)
+			/* Send HOSTIF_DM_ENUM_DEVICES */
+			rv = ishtp_cl_send(hid_ishtp_cl, buf, len);
+	}
+	if (!client_data->enum_devices_done) {
+		dev_err(&hid_ishtp_cl->device->dev,
+			"[hid-ish]: timed out waiting for enum_devices\n");
+		rv = -ETIMEDOUT;
+		goto ret;
+	}
+	if (!client_data->hid_devices) {
+		dev_err(&hid_ishtp_cl->device->dev,
+			"[hid-ish]: failed to allocate HID dev structures\n");
+		rv = -ENOMEM;
+		goto ret;
+	}
+
+	client_data->num_hid_devices = client_data->hid_dev_count;
+	dev_warn(&hid_ishtp_cl->device->dev,
+		"[hid-ish]: enum_devices_done OK, num_hid_devices=%d\n",
+		client_data->num_hid_devices);
+
+	for (i = 0; i < client_data->num_hid_devices; ++i) {
+		client_data->cur_hid_dev = i;
+
+		/* Get HID descriptor */
+		client_data->hid_descr_done = 0;
+		memset(msg, 0, sizeof(struct hostif_msg));
+		msg->hdr.command = HOSTIF_GET_HID_DESCRIPTOR;
+		msg->hdr.device_id = client_data->hid_devices[i].dev_id;
+		len = sizeof(struct hostif_msg);
+		rv = ishtp_cl_send(hid_ishtp_cl, buf, len);
+		rv = 0;
+
+		if (!client_data->hid_descr_done)
+			wait_event_timeout(client_data->init_wait,
+					   client_data->hid_descr_done,
+					   30 * HZ);
+		if (!client_data->hid_descr_done) {
+			dev_err(&hid_ishtp_cl->device->dev,
+				"[hid-ish]: timed out for hid_descr_done\n");
+			continue;
+		}
+
+		if (!client_data->hid_descr[i]) {
+			dev_err(&hid_ishtp_cl->device->dev,
+				"[hid-ish]: allocation HID desc fail\n");
+			continue;
+		}
+
+		/* Get report descriptor */
+		client_data->report_descr_done = 0;
+		memset(msg, 0, sizeof(struct hostif_msg));
+		msg->hdr.command = HOSTIF_GET_REPORT_DESCRIPTOR;
+		msg->hdr.device_id = client_data->hid_devices[i].dev_id;
+		len = sizeof(struct hostif_msg);
+		rv = ishtp_cl_send(hid_ishtp_cl, buf, len);
+
+		rv = 0;
+
+		if (!client_data->report_descr_done)
+			wait_event_timeout(client_data->init_wait,
+					   client_data->report_descr_done,
+					   30 * HZ);
+		if (!client_data->report_descr_done) {
+			dev_err(&hid_ishtp_cl->device->dev,
+				"[hid-ish]: timed out for report descr\n");
+			continue;
+		}
+
+		if (!client_data->report_descr[i]) {
+			dev_err(&hid_ishtp_cl->device->dev,
+				"[hid-ish]: failed to alloc report descr\n");
+			continue;
+		}
+
+		rv = ishtp_hid_probe(i, hid_ishtp_cl);
+		if (rv) {
+			dev_err(&hid_ishtp_cl->device->dev,
+				"[hid-ish]: HID probe for #%u failed: %d\n",
+				i, rv);
+			continue;
+		}
+	} /* for() on all hid devices */
+
+ret:
+	client_data->init_done = 1;
+
+	return rv;
+}
+
+/**
+ * hid_ishtp_cl_probe() - ISHTP client driver probe
+ * @cl_device:		ISHTP client device instance
+ *
+ * This function calls on device create on ISHTP bus
+ */
+static int hid_ishtp_cl_probe(struct ishtp_cl_device *cl_device)
+{
+	struct ishtp_cl *hid_ishtp_cl;
+	struct ishtp_cl_data *client_data;
+	int rv;
+
+	if (!cl_device)
+		return	-ENODEV;
+
+	if (uuid_le_cmp(hid_ishtp_guid,
+			cl_device->fw_client->props.protocol_name) != 0)
+		return	-ENODEV;
+
+	client_data = devm_kzalloc(&cl_device->dev, sizeof(*client_data),
+				   GFP_KERNEL);
+	if (!client_data)
+		return -ENOMEM;
+
+	hid_ishtp_cl = ishtp_cl_allocate(cl_device->ishtp_dev);
+	if (!hid_ishtp_cl)
+		return -ENOMEM;
+
+	cl_device->driver_data = hid_ishtp_cl;
+	hid_ishtp_cl->client_data = client_data;
+
+	rv = hid_ishtp_cl_init(hid_ishtp_cl);
+	if (rv) {
+		ishtp_cl_free(hid_ishtp_cl);
+		return rv;
+	}
+
+	return 0;
+}
+
+/**
+ * hid_ishtp_cl_remove() - ISHTP client driver remove
+ * @cl_device:		ISHTP client device instance
+ *
+ * This function calls on device create on ISHTP bus
+ */
+static int hid_ishtp_cl_remove(struct ishtp_cl_device *cl_device)
+{
+	struct ishtp_cl *hid_ishtp_cl = cl_device->driver_data;
+	struct ishtp_cl_data *client_data = hid_ishtp_cl->client_data;
+
+	ishtp_hid_remove(hid_ishtp_cl);
+
+	ishtp_cl_unlink(hid_ishtp_cl);
+	ishtp_cl_flush_queues(hid_ishtp_cl);
+
+	/* disband and free all Tx and Rx client-level rings */
+	ishtp_cl_free(hid_ishtp_cl);
+	hid_ishtp_cl = NULL;
+
+	client_data->num_hid_devices = 0;
+
+	return 0;
+}
+
+
+struct ishtp_cl_driver	hid_ishtp_cl_driver = {
+	.name = "ish",
+	.probe = hid_ishtp_cl_probe,
+	.remove = hid_ishtp_cl_remove,
+};
+
+static int __init ish_hid_init(void)
+{
+	int	rv;
+
+	/* Register ISHTP client device driver with ISHTP Bus */
+	rv = ishtp_cl_driver_register(&hid_ishtp_cl_driver);
+
+	return rv;
+
+}
+late_initcall(ish_hid_init);
+
+MODULE_DESCRIPTION("ISH ISHTP HID client driver");
+/* Primary author */
+MODULE_AUTHOR("Daniel Drubin <daniel.drubin@intel.com>");
+/* Modification for multi instance support and clean up */
+MODULE_AUTHOR("Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>");
+
+MODULE_LICENSE("GPL");
diff --git a/drivers/hid/intel-ish-hid/ishtp-hid.c b/drivers/hid/intel-ish-hid/ishtp-hid.c
new file mode 100644
index 0000000..f0c5569
--- /dev/null
+++ b/drivers/hid/intel-ish-hid/ishtp-hid.c
@@ -0,0 +1,201 @@
+/*
+ * ISHTP-HID glue driver.
+ *
+ * Copyright (c) 2012-2016, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ */
+
+#include <linux/hid.h>
+#include "ishtp/client.h"
+#include "ishtp-hid.h"
+
+/**
+ * ishtp_hid_parse() - hid-core .parse() callback
+ * @hid:	hid device instance
+ *
+ * This function gets called during call to hid_add_device
+ */
+static int ishtp_hid_parse(struct hid_device *hid)
+{
+	struct ishtp_cl *hid_ishtp_cl = hid->driver_data;
+	struct ishtp_cl_data *client_data = hid_ishtp_cl->client_data;
+	int	rv;
+
+	rv = hid_parse_report(hid,
+		client_data->report_descr[client_data->cur_hid_dev],
+		client_data->report_descr_size[client_data->cur_hid_dev]);
+	if (rv)
+		return	rv;
+
+	return 0;
+}
+
+/* Empty callbacks with success return code */
+static int ishtp_hid_start(struct hid_device *hid)
+{
+	return 0;
+}
+
+static void ishtp_hid_stop(struct hid_device *hid)
+{
+}
+
+static int ishtp_hid_open(struct hid_device *hid)
+{
+	return 0;
+}
+
+static void ishtp_hid_close(struct hid_device *hid)
+{
+}
+
+static int ishtp_raw_request(struct hid_device *hdev, unsigned char reportnum,
+	__u8 *buf, size_t len, unsigned char rtype, int reqtype)
+{
+	return 0;
+}
+
+/**
+ * ishtp_hid_request() - hid-core .request() callback
+ * @hid:	hid device instance
+ * @rep:	pointer to hid_report
+ * @reqtype:	type of req. [GET|SET]_REPORT
+ *
+ * This function is used to set/get feaure/input report.
+ */
+static void ishtp_hid_request(struct hid_device *hid, struct hid_report *rep,
+	int reqtype)
+{
+	/* the specific report length, just HID part of it */
+	unsigned int len = ((rep->size - 1) >> 3) + 1 + (rep->id > 0);
+	char *buf;
+	unsigned int header_size = sizeof(struct hostif_msg);
+
+	len += header_size;
+
+	switch (reqtype) {
+	case HID_REQ_GET_REPORT:
+		hid_ishtp_get_report(hid, rep->id, rep->type);
+		break;
+	case HID_REQ_SET_REPORT:
+		/*
+		 * Spare 7 bytes for 64b accesses through
+		 * get/put_unaligned_le64()
+		 */
+		buf = kzalloc(len + 7, GFP_KERNEL);
+		if (!buf)
+			return;
+
+		hid_output_report(rep, buf + header_size);
+		hid_ishtp_set_feature(hid, buf, len, rep->id);
+		kfree(buf);
+		break;
+	}
+}
+
+/**
+ * ishtp_wait_for_response() - hid-core .wait() callback
+ * @hid:	hid device instance
+ *
+ * This function is used to wait after get feaure/input report.
+ */
+static int ishtp_wait_for_response(struct hid_device *hid)
+{
+	struct ishtp_cl *hid_ishtp_cl = hid->driver_data;
+	struct ishtp_cl_data *client_data = hid_ishtp_cl->client_data;
+
+	if (!client_data->get_report_done)
+		wait_event_timeout(client_data->ishtp_hid_wait,
+				   client_data->get_report_done, 3 * HZ);
+
+	if (!client_data->get_report_done) {
+		hid_err(hid,
+			"timeout waiting for response from ISHTP device\n");
+		return -1;
+	}
+
+	client_data->get_report_done = 0;
+
+	return 0;
+}
+
+static struct hid_ll_driver ishtp_hid_ll_driver = {
+	.parse = ishtp_hid_parse,
+	.start = ishtp_hid_start,
+	.stop = ishtp_hid_stop,
+	.open = ishtp_hid_open,
+	.close = ishtp_hid_close,
+	.request = ishtp_hid_request,
+	.wait = ishtp_wait_for_response,
+	.raw_request = ishtp_raw_request
+};
+
+/**
+ * ishtp_hid_probe() - hid register ll driver
+ * @curr_hid_dev:	Index of hid device calling to register
+ * @hid_ishtp_cl:	ISHTP Client instance
+ *
+ * This function is used to allocate and add HID device.
+ */
+int ishtp_hid_probe(unsigned int cur_hid_dev, struct ishtp_cl *hid_ishtp_cl)
+{
+	int rv;
+	struct hid_device	*hid;
+	struct ishtp_cl_data *client_data = hid_ishtp_cl->client_data;
+
+	hid = hid_allocate_device();
+	if (IS_ERR(hid)) {
+		rv = PTR_ERR(hid);
+		return	-ENOMEM;
+	}
+
+	hid->driver_data = hid_ishtp_cl;
+
+	client_data->hid_sensor_hubs[cur_hid_dev] = hid;
+
+	hid->ll_driver = &ishtp_hid_ll_driver;
+	hid->bus = BUS_ISHTP;
+	hid->version = le16_to_cpu(ISH_HID_VERSION);
+	hid->vendor = le16_to_cpu(ISH_HID_VENDOR);
+	hid->product = le16_to_cpu(ISH_HID_PRODUCT);
+
+	snprintf(hid->name, sizeof(hid->name), "%s %04hX:%04hX", "hid-ishtp",
+		hid->vendor, hid->product);
+
+	rv = hid_add_device(hid);
+	if (rv) {
+		if (rv != -ENODEV)
+			hid_err(hid, "[hid-ishtp]: can't add HID device: %d\n",
+				rv);
+		kfree(hid);
+		return	rv;
+	}
+
+	return 0;
+}
+
+/**
+ * ishtp_hid_probe() - Remove registered hid device
+ * @hid_ishtp_cl:	ISHTP Client instance
+ *
+ * This function is used to destroy allocatd HID device.
+ */
+void ishtp_hid_remove(struct ishtp_cl *hid_ishtp_cl)
+{
+	struct ishtp_cl_data *client_data = hid_ishtp_cl->client_data;
+	int	i;
+
+	for (i = 0; i < client_data->num_hid_devices; ++i)
+		if (client_data->hid_sensor_hubs[i]) {
+			hid_destroy_device(client_data->hid_sensor_hubs[i]);
+			client_data->hid_sensor_hubs[i] = NULL;
+		}
+}
diff --git a/drivers/hid/intel-ish-hid/ishtp-hid.h b/drivers/hid/intel-ish-hid/ishtp-hid.h
new file mode 100644
index 0000000..9bf9198
--- /dev/null
+++ b/drivers/hid/intel-ish-hid/ishtp-hid.h
@@ -0,0 +1,157 @@
+/*
+ * ISHTP-HID glue driver's definitions.
+ *
+ * Copyright (c) 2014-2016, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ */
+#ifndef ISHTP_HID__H
+#define	ISHTP_HID__H
+
+/* ISH Transport protocol id */
+#define	BUS_ISHTP	0x44
+
+/* The fixed ISH product and vendor id */
+#define	ISH_HID_VENDOR	0x8086
+#define	ISH_HID_PRODUCT	0x22D8
+#define	ISH_HID_VERSION	0x0200
+
+#define	CMD_MASK	0x7F
+#define	IS_RESPONSE	0x80
+
+/* ISH Transport protocol (ISHTP in short) GUID */
+static const uuid_le hid_ishtp_guid = UUID_LE(0x33AECD58, 0xB679, 0x4E54,
+					      0x9B, 0xD9, 0xA0, 0x4D, 0x34,
+					      0xF0, 0xC2, 0x26);
+
+/* ISH HID message structure */
+struct hostif_msg_hdr {
+	uint8_t	command; /* Bit 7: is_response */
+	uint8_t	device_id;
+	uint8_t	status;
+	uint8_t	flags;
+	uint16_t size;
+} __packed;
+
+struct hostif_msg {
+	struct hostif_msg_hdr	hdr;
+} __packed;
+
+struct hostif_msg_to_sensor {
+	struct hostif_msg_hdr	hdr;
+	uint8_t	report_id;
+} __packed;
+
+struct device_info {
+	uint32_t dev_id;
+	uint8_t dev_class;
+	uint16_t pid;
+	uint16_t vid;
+} __packed;
+
+struct ishtp_version {
+	uint8_t	major;
+	uint8_t	minor;
+	uint8_t	hotfix;
+	uint16_t build;
+} __packed;
+
+/* struct for ISHTP aggregated input data */
+struct report_list {
+	uint16_t total_size;
+	uint8_t	num_of_reports;
+	uint8_t	flags;
+	struct {
+		uint16_t	size_of_report;
+		uint8_t report[1];
+	} __packed reports[1];
+} __packed;
+
+/* HOSTIF commands */
+#define	HOSTIF_HID_COMMAND_BASE			0
+#define	HOSTIF_GET_HID_DESCRIPTOR		0
+#define	HOSTIF_GET_REPORT_DESCRIPTOR		1
+#define HOSTIF_GET_FEATURE_REPORT		2
+#define	HOSTIF_SET_FEATURE_REPORT		3
+#define	HOSTIF_GET_INPUT_REPORT			4
+#define	HOSTIF_PUBLISH_INPUT_REPORT		5
+#define	HOSTIF_PUBLISH_INPUT_REPORT_LIST	6
+#define	HOSTIF_DM_COMMAND_BASE			32
+#define	HOSTIF_DM_ENUM_DEVICES			33
+#define	HOSTIF_DM_ADD_DEVICE			34
+
+#define	MAX_HID_DEVICES				32
+
+/**
+ * struct ishtp_cl_data - Encapsulate per ISH TP HID Client
+ * @enum_device_done:	Enum devices response complete flag
+ * @hid_descr_done:	HID descriptor complete flag
+ * @report_descr_done:	Get report descriptor complete flag
+ * @get_report_done:	Get Feature/Input report complete flag
+ *			used during get/set request from hid core
+ * @init_done:		Init process completed successfully
+ * @num_hid_devices:	Number of HID devices enumerated in this client
+ * @cur_hid_dev:	This keeps track of the device index for which
+ *			initialization and registration with HID core
+ *			in progress.
+ * @hid_devices:	Store vid/pid/devid for each enumerated HID device
+ * @report_descr:	Stores the raw report descriptors for each HID device
+ * @report_descr_size:	Report description of size of above repo_descr[]
+ * @hid_sensor_hubs:	Pointer to hid_device for all HID device, so that
+ *			when clients are removed, they can be freed
+ * @hid_descr:		Pointer to hid descriptor for each enumerated hid
+ *			device
+ * @hid_descr_size:	Size of each above report descriptor
+ * @init_wait:		Wait queue to wait during initialization, where the
+ *			client send message to ISH FW and wait for response
+ * @ishtp_hid_wait:	The wait for get report during wait callback from hid
+ *			core
+ * @bad_recv_cnt:	Running count of packets received with error
+ * @multi_packet_cnt:	Count of fragmented packet count
+ *
+ * This structure is used to store completion flags and per client data like
+ * like report description, number of HID devices etc.
+ */
+struct ishtp_cl_data {
+	/* completion flags */
+	int enum_devices_done;
+	int hid_descr_done;
+	int report_descr_done;
+	int get_report_done;
+	int init_done;
+
+	unsigned int num_hid_devices;
+	unsigned int cur_hid_dev;
+	unsigned int hid_dev_count;
+
+	struct device_info *hid_devices;
+	unsigned char *report_descr[MAX_HID_DEVICES];
+	int report_descr_size[MAX_HID_DEVICES];
+	struct hid_device *hid_sensor_hubs[MAX_HID_DEVICES];
+	unsigned char *hid_descr[MAX_HID_DEVICES];
+	int hid_descr_size[MAX_HID_DEVICES];
+
+	wait_queue_head_t init_wait;
+	wait_queue_head_t ishtp_hid_wait;
+
+	/* Statistics */
+	unsigned int bad_recv_cnt;
+	int multi_packet_cnt;
+};
+
+/* Interface functions between HID LL driver and ISH TP client */
+void hid_ishtp_set_feature(struct hid_device *hid, char *buf, unsigned int len,
+			   int report_id);
+void hid_ishtp_get_report(struct hid_device *hid, int report_id,
+			  int report_type);
+int ishtp_hid_probe(unsigned int cur_hid_dev, struct ishtp_cl *hid_ishtp_cl);
+void ishtp_hid_remove(struct ishtp_cl *hid_ishtp_cl);
+
+#endif	/* ISHTP_HID__H */
-- 
1.9.1

[toc] | [prev] | [next] | [standalone]


#1409801 — [RFC 1/4] Documentation: hid: Intel ISH HID document

FromSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Date2016-05-31 06:40 +0200
Subject[RFC 1/4] Documentation: hid: Intel ISH HID document
Message-ID<rEJDb-64j-1@gated-at.bofh.it>
In reply to#1409798
Document explaining ISH HID operation and implementation.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
 Documentation/hid/intel-ish-hid.txt | 375 ++++++++++++++++++++++++++++++++++++
 1 file changed, 375 insertions(+)
 create mode 100644 Documentation/hid/intel-ish-hid.txt

diff --git a/Documentation/hid/intel-ish-hid.txt b/Documentation/hid/intel-ish-hid.txt
new file mode 100644
index 0000000..83a636e
--- /dev/null
+++ b/Documentation/hid/intel-ish-hid.txt
@@ -0,0 +1,375 @@
+Intel Integrated Sensor Hub (ISH)
+===============================
+
+A sensor hub enables the ability to offload sensor polling and algorithm
+processing to a dedicated low power co-processor. This allows the core
+processor to go into low power modes more often, resulting in the increased
+battery life.
+There are many vendors providing external sensor hubs confirming to HID
+Sensor usage tables, and used in several tablets, 2 in 1 convertible laptops
+and embedded products. Linux had this support since Linux 3.9.
+
+Intel® introduced integrated sensor hubs as a part of the SoC starting from
+Cherry Trail and now supported on multiple generations of CPU packages. There
+are many commercial devices already shipped with Integrated Sensor Hubs (ISH).
+These ISH also comply to HID sensor specification, but the  difference is the
+transport protocol used for communication. The current external sensor hubs
+mainly use HID over i2C or USB. But ISH doesn't use either i2c or USB.
+
+This document provides an overview of transport protocol and how it is
+implemented.
+
+
+ISH Implementation: Block Diagram
+----------------------------------------
+	 ---------------------------
+	|  User Space Applications  |
+	 ---------------------------
+
+----------------IIO ABI----------------
+	 --------------------------
+	|  IIO Sensor Drivers 	  |
+	 --------------------------
+	 --------------------------
+	|   	 IIO core 	  |
+	 --------------------------
+	 --------------------------
+	|   HID Sensor Hub MFD 	  |
+	 --------------------------
+	 --------------------------
+	|       HID Core 	  |
+	 --------------------------
+ 	 --------------------------
+	|   HID over ISH Client   |
+	 --------------------------
+	 --------------------------
+	|   ISH Client over ISHTP |
+	 --------------------------
+	 --------------------------
+	|   ISH Transport (ISHTP) |
+	 --------------------------
+	 --------------------------
+	|      IPC Drivers  	  |
+	 --------------------------
+OS
+----------------   PCI -----------------
+Hardware + Firmware
+	 ----------------------------
+	| ISH Hardware/Firmware(FW) |
+	 ----------------------------
+
+------------------------------------------
+
+High level processing in above blocks:
+
+---
+Hardware Interface
+The ISH is exposed as "Non-VGA unclassified PCI device" to the host. The PCI
+product and vendor IDs are changed from different generations of processors. So
+the source code which enumerate drivers needs to update from generation to
+generation.
+
+---
+Inter Processor Communication (IPC) driver:
+Location: drivers/hid/intel-ish-hid/ipc
+
+The IPC message used memory mapped I/O. The registers are defined in
+hw-ish-regs.h.
+
+IPC/FW message types
+There are two types of messages, one for management of link and other messages
+are to and from transport layers.
+
+TX and RX of Transport messages:
+A set of memory mapped register offers support of multi byte messages TX and
+RX (E.g.IPC_REG_ISH2HOST_MSG, IPC_REG_HOST2ISH_MSG). The messaging uses
+doorbell register to trigger processing on client and server side.
+The IPC layer maintains internal queues to sequence messages and send them in
+order to the FW. Optionally the caller can register handler to get notification
+of completion.
+
+Transport layer interface
+To abstract HW level IPC communication a set of callbacks are registered.
+The transport layer uses them to send and receive messages.
+Refer to  struct ishtp_hw_ops for callbacks.
+
+---
+ISH Transport layer
+Location: drivers/hid/intel-ish-hid/ishtp/
+
+A Generic Transport Layer
+The transport layer is a bi-directional protocol, which defines:
+- Set of commands to start, stop, connect, disconnect and flow control
+(ishtp/hbm.h) for details
+- A flow control mechanism to avoid buffer overflows
+
+This protocol resembles bus messages described in the following document:
+http://www.intel.com/content/dam/www/public/us/en/documents/technical-\
+specifications/dcmi-hi-1-0-spec.pdf
+Chater 7: Bus Message Layer
+
+DMA
+The transport layer allocate 1 MB TX and 1 MB RX buffer. This buffer is divided
+into slots of 4K buffer. This buffer is shared among all connected clients.
+So when a message is to be sent or received by a client, it finds an empty
+slot and either fill for TX or send DMA address to FW for RX.
+By default all RX messages uses DMA as there is more upstream data for sensors
+than downstream. For TX client send interface has flag to send via DMA, which
+is not set by default as there is less TX data other setting some feature
+reports by HID sensor hub driver.
+
+Ring Buffers
+When a client initiate a connection, a ring or RX and TX buffers are allocated.
+The size of ring can be specified by the client. HID client set 16 and 32 for
+TX and RX buffers respectively. On send request from client, the data to be
+sent is copied to one of the send ring buffer and scheduled to be sent using
+bus message protocol. These buffers are required because the FW may have not
+processed last message and may not have enough flow control credits to send.
+Same thing holds true on receive side and flow control is required.
+
+Host Enumeration
+The host enumeration bus command allow discovery of clients present in
+the FW. There can be multiple sensor clients and clients for calibration
+function.
+To ease in implantation and allow independent driver handle each client
+this transport layer takes advantage of Linux Bus driver model. Each
+client is registered as device on the the transport bus (ishtp bus).
+
+ISH Client over generic transport layer
+The ISH client defines interface to send and receive HID style command
+and responses. Refer to ishtp-hid.h.
+These commands are for"
+- Get HID descriptor
+- Get report descriptor
+- Get/Set feature report
+- Get input reports
+
+---
+HID over ISH Client
+Location: drivers/hid/intel-ish-hid
+
+This implanted as ISHTP client driver, which
+- enumerate HID devices under FW ISH client
+- Get Report descriptor
+- Register with HID core as a LL driver
+- Process Get/Set feature request
+- Get input reports
+
+----
+HID Sensor Hub MFD and IIO sensor drivers
+
+The functionality in these drivers is the same as an external sensor hub.
+These drivers don't require changes to handle ISH other than some
+optimizations.
+----
+
+========================================================================================
+End to End Startup HID transport Sequence Diagram
+
+HID-ISH-CLN			ISHTP			IPC				HW
+	|			|			|				|
+	|	   		|			|-----WAKE UP------------------>|
+	|			|			|				|
+	|	   		|			|-----HOST READY--------------->|
+	|			|			|				|
+	|	   		|			|<----MNG_RESET_NOTIFY_ACK----- |
+	|			|			|				|
+	|			|<----ISHTP_START------ |				|
+	|			|			|				|
+	|			|<-----------------HOST_START_RES_CMD-------------------|
+	|			|			|				|
+	|			|------------------QUERY_SUBSCRIBER-------------------->|
+	|			|			|				|
+	|			|------------------HOST_ENUM_REQ_CMD------------------->|
+	|			|			|				|
+	|			|<-----------------HOST_ENUM_RES_CMD--------------------|
+	|			|			|				|
+	|			|------------------HOST_CLIENT_PROPERTIES_REQ_CMD------>|
+	|			|			|				|
+	|			|<-----------------HOST_CLIENT_PROPERTIES_RES_CMD-------|
+	|	Create new device on in ishtp bus	|				|
+	|			|			|				|
+	|			|------------------HOST_CLIENT_PROPERTIES_REQ_CMD------>|
+	|			|			|				|
+	|			|<-----------------HOST_CLIENT_PROPERTIES_RES_CMD-------|
+	|	Create new device on in ishtp bus	|				|
+	|			|			|				|
+	|			|--Repeat HOST_CLIENT_PROPERTIES_REQ_CMD-till last one--|
+	|			|			|				|
+     probed()
+	|----ishtp_cl_connect-->|----------------- CLIENT_CONNECT_REQ_CMD-------------->|
+	|			|			|				|
+	|			|<----------------CLIENT_CONNECT_RES_CMD----------------|
+	|			|			|				|
+	|register event callback|			|				|
+	|			|			|				|
+	|ishtp_cl_send(
+	HOSTIF_DM_ENUM_DEVICES) |----------fill ishtp_msg_hdr struct write to HW-----  >|
+	|			|			|				|
+	|			|			|<-----IRQ(IPC_PROTOCOL_ISHTP---|
+	|			|			|				|
+	|			|<------------ DMA_XFER---------------------------------|
+	|<--ENUM_DEVICE RSP-----|			|				|
+	|			|------------ DMA_XFER_ACK----------------------------->|
+	|			|			|				|
+for each enumerated device
+	|ishtp_cl_send(
+	HOSTIF_GET_HID_DESCRIPTOR |----------fill ishtp_msg_hdr struct write to HW---  >|
+	|			|			|				|
+	...Response
+	|			|			|				|
+for each enumerated device
+	|ishtp_cl_send(
+	HOSTIF_GET_REPORT_DESCRIPTOR |----------fill ishtp_msg_hdr struct write to HW- >|
+	|			|			|				|
+	|			|			|				|
+ hid_allocate_device
+	|			|			|				|
+ hid_add_device			|			|				|
+	|			|			|				|
+
+
+========================================================================================
+ISH Debugging
+
+To debug ISH, event tracing mechanism is used. To enable debug logs
+echo 1 > /sys/kernel/debug/tracing/events/intel_ish/enable
+cat sys/kernel/debug/tracing/trace
+
+========================================================================================
+ISH IIO sysfs Example on Lenovo thinkpad Yoga 260
+
+root@otcpl-ThinkPad-Yoga-260:~# tree -l /sys/bus/iio/devices/
+/sys/bus/iio/devices/
+├── iio:device0 -> ../../../devices/0044:8086:22D8.0001/HID-SENSOR-200073.9.auto/iio:device0
+│   ├── buffer
+│   │   ├── enable
+│   │   ├── length
+│   │   └── watermark
+...
+│   ├── in_accel_hysteresis
+│   ├── in_accel_offset
+│   ├── in_accel_sampling_frequency
+│   ├── in_accel_scale
+│   ├── in_accel_x_raw
+│   ├── in_accel_y_raw
+│   ├── in_accel_z_raw
+│   ├── name
+│   ├── scan_elements
+│   │   ├── in_accel_x_en
+│   │   ├── in_accel_x_index
+│   │   ├── in_accel_x_type
+│   │   ├── in_accel_y_en
+│   │   ├── in_accel_y_index
+│   │   ├── in_accel_y_type
+│   │   ├── in_accel_z_en
+│   │   ├── in_accel_z_index
+│   │   └── in_accel_z_type
+...
+│   │   ├── devices
+│   │   │   │   ├── buffer
+│   │   │   │   │   ├── enable
+│   │   │   │   │   ├── length
+│   │   │   │   │   └── watermark
+│   │   │   │   ├── dev
+│   │   │   │   ├── in_intensity_both_raw
+│   │   │   │   ├── in_intensity_hysteresis
+│   │   │   │   ├── in_intensity_offset
+│   │   │   │   ├── in_intensity_sampling_frequency
+│   │   │   │   ├── in_intensity_scale
+│   │   │   │   ├── name
+│   │   │   │   ├── scan_elements
+│   │   │   │   │   ├── in_intensity_both_en
+│   │   │   │   │   ├── in_intensity_both_index
+│   │   │   │   │   └── in_intensity_both_type
+│   │   │   │   ├── trigger
+│   │   │   │   │   └── current_trigger
+...
+│   │   │   │   ├── buffer
+│   │   │   │   │   ├── enable
+│   │   │   │   │   ├── length
+│   │   │   │   │   └── watermark
+│   │   │   │   ├── dev
+│   │   │   │   ├── in_magn_hysteresis
+│   │   │   │   ├── in_magn_offset
+│   │   │   │   ├── in_magn_sampling_frequency
+│   │   │   │   ├── in_magn_scale
+│   │   │   │   ├── in_magn_x_raw
+│   │   │   │   ├── in_magn_y_raw
+│   │   │   │   ├── in_magn_z_raw
+│   │   │   │   ├── in_rot_from_north_magnetic_tilt_comp_raw
+│   │   │   │   ├── in_rot_hysteresis
+│   │   │   │   ├── in_rot_offset
+│   │   │   │   ├── in_rot_sampling_frequency
+│   │   │   │   ├── in_rot_scale
+│   │   │   │   ├── name
+...
+│   │   │   │   ├── scan_elements
+│   │   │   │   │   ├── in_magn_x_en
+│   │   │   │   │   ├── in_magn_x_index
+│   │   │   │   │   ├── in_magn_x_type
+│   │   │   │   │   ├── in_magn_y_en
+│   │   │   │   │   ├── in_magn_y_index
+│   │   │   │   │   ├── in_magn_y_type
+│   │   │   │   │   ├── in_magn_z_en
+│   │   │   │   │   ├── in_magn_z_index
+│   │   │   │   │   ├── in_magn_z_type
+│   │   │   │   │   ├── in_rot_from_north_magnetic_tilt_comp_en
+│   │   │   │   │   ├── in_rot_from_north_magnetic_tilt_comp_index
+│   │   │   │   │   └── in_rot_from_north_magnetic_tilt_comp_type
+│   │   │   │   ├── trigger
+│   │   │   │   │   └── current_trigger
+...
+│   │   │   │   ├── buffer
+│   │   │   │   │   ├── enable
+│   │   │   │   │   ├── length
+│   │   │   │   │   └── watermark
+│   │   │   │   ├── dev
+│   │   │   │   ├── in_anglvel_hysteresis
+│   │   │   │   ├── in_anglvel_offset
+│   │   │   │   ├── in_anglvel_sampling_frequency
+│   │   │   │   ├── in_anglvel_scale
+│   │   │   │   ├── in_anglvel_x_raw
+│   │   │   │   ├── in_anglvel_y_raw
+│   │   │   │   ├── in_anglvel_z_raw
+│   │   │   │   ├── name
+│   │   │   │   ├── scan_elements
+│   │   │   │   │   ├── in_anglvel_x_en
+│   │   │   │   │   ├── in_anglvel_x_index
+│   │   │   │   │   ├── in_anglvel_x_type
+│   │   │   │   │   ├── in_anglvel_y_en
+│   │   │   │   │   ├── in_anglvel_y_index
+│   │   │   │   │   ├── in_anglvel_y_type
+│   │   │   │   │   ├── in_anglvel_z_en
+│   │   │   │   │   ├── in_anglvel_z_index
+│   │   │   │   │   └── in_anglvel_z_type
+│   │   │   │   ├── trigger
+│   │   │   │   │   └── current_trigger
+...
+│   │   │   │   ├── buffer
+│   │   │   │   │   ├── enable
+│   │   │   │   │   ├── length
+│   │   │   │   │   └── watermark
+│   │   │   │   ├── dev
+│   │   │   │   ├── in_anglvel_hysteresis
+│   │   │   │   ├── in_anglvel_offset
+│   │   │   │   ├── in_anglvel_sampling_frequency
+│   │   │   │   ├── in_anglvel_scale
+│   │   │   │   ├── in_anglvel_x_raw
+│   │   │   │   ├── in_anglvel_y_raw
+│   │   │   │   ├── in_anglvel_z_raw
+│   │   │   │   ├── name
+│   │   │   │   ├── scan_elements
+│   │   │   │   │   ├── in_anglvel_x_en
+│   │   │   │   │   ├── in_anglvel_x_index
+│   │   │   │   │   ├── in_anglvel_x_type
+│   │   │   │   │   ├── in_anglvel_y_en
+│   │   │   │   │   ├── in_anglvel_y_index
+│   │   │   │   │   ├── in_anglvel_y_type
+│   │   │   │   │   ├── in_anglvel_z_en
+│   │   │   │   │   ├── in_anglvel_z_index
+│   │   │   │   │   └── in_anglvel_z_type
+│   │   │   │   ├── trigger
+│   │   │   │   │   └── current_trigger
+...
+
-- 
1.9.1

[toc] | [prev] | [next] | [standalone]


#1411239

FromAtri Bhattacharya <badshah400@aim.com>
Date2016-06-01 15:50 +0200
Message-ID<rFeH0-BQ-29@gated-at.bofh.it>
In reply to#1409798
Hi!

On Mon, 2016-05-30 at 21:27 -0700, Srinivas Pandruvada wrote:
> Starting from Cherrytrail, multiple generation of Intel processors
> offers
> on package sensor hub. Several recent tablets, 2-in-1 convertible
> laptops
> are using ISH instead of external sensor hubs. This resulted in lack
> of
> support of sensor function like device rotation and auto backlight
> adjustment. In addition, depending on the OEM implementation, support
> of ISH
> is required to support low power sleep states.
> 
> The support of ISH on Linux platforms is not new. Android platforms
> with
> Intel SoCs had this support for a while submitted by Daniel Drubin. 
> This patcheset is reusing most of those changes with  clean up and
> removing Android platform specific changes.
> 
> This series is tested on:
> - Lenovo Yoga 260 with Skylake processor
> - HP Pavilion x2 detachable with Cherrytrail 
> 
> The user mode ABI is still same as external sensor hubs using Linux
> IIO. So existing user mode software should still work without change.
> This series primarily brings in new HID transport used in ISH.
> 
> This series submitted as a RFC to try on several devices. We have 
> received request from Linux users who wanted this support. So I hope
> all
> those users try and give feedback.
> 

Thanks a lot for adding support for this. I have a Lenovo Thinkpad Yoga
260, so I decided to give it a try. I used your patches on kernel 4.6.0
and installed the patched kernel. Now, I see that the device is
recognised immediately. I use the iio-sensor-proxy application from
[1], and it now recognises the sensors. But changing orientation
doesn't seem to do anything, and moreover upon a wakeup from suspend I
see the following messages on the journal:

Jun 01 15:15:09 tp-yoga260 kernel: [drm] RC6 on
Jun 01 15:15:09 tp-yoga260 kernel: hid-sensor-hub 0044:8086:22D8.0001:
timeout waiting for response from ISHTP device
Jun 01 15:15:09 tp-yoga260 kernel: hid-sensor-hub 0044:8086:22D8.0001:
timeout waiting for response from ISHTP device
Jun 01 15:15:09 tp-yoga260 kernel: hid-sensor-hub 0044:8086:22D8.0001:
timeout waiting for response from ISHTP device
Jun 01 15:15:09 tp-yoga260 kernel: hid-sensor-hub 0044:8086:22D8.0001:
timeout waiting for response from ISHTP device
Jun 01 15:15:09 tp-yoga260 kernel: hid-sensor-hub 0044:8086:22D8.0001:
timeout waiting for response from ISHTP device
Jun 01 15:15:09 tp-yoga260 kernel: hid-sensor-hub 0044:8086:22D8.0001:
timeout waiting for response from ISHTP device
Jun 01 15:15:09 tp-yoga260 kernel: hid-sensor-hub 0044:8086:22D8.0001:
timeout waiting for response from ISHTP device
Jun 01 15:15:09 tp-yoga260 kernel: hid-sensor-hub 0044:8086:22D8.0001:
timeout waiting for response from ISHTP device
Jun 01 15:15:09 tp-yoga260 kernel: hid-sensor-hub 0044:8086:22D8.0002:
timeout waiting for response from ISHTP device
Jun 01 15:15:09 tp-yoga260 kernel: hid-sensor-hub 0044:8086:22D8.0002:
timeout waiting for response from ISHTP device
Jun 01 15:15:09 tp-yoga260 kernel: hid-sensor-hub 0044:8086:22D8.0002:
timeout waiting for response from ISHTP device
Jun 01 15:15:09 tp-yoga260 kernel: hid-sensor-hub 0044:8086:22D8.0002:
timeout waiting for response from ISHTP device
Jun 01 15:15:09 tp-yoga260 kernel: PM: resume of devices complete after
37095.288 msecs

Also suspend and wakeup seems to be really slow now. Please let me know
if there is any other info I can provide.

Thanks and best wishes.

[1] https://github.com/hadess/iio-sensor-proxy

-- 
Atri Bhattacharya
Wed  1 Jun 15:22:32 CEST 2016

Sent from openSUSE Tumbleweed (20160529) (x86_64) on my laptop.

[toc] | [prev] | [next] | [standalone]


#1418803

FromGrant Likely <grant.likely@secretlab.ca>
Date2016-06-09 23:50 +0200
Message-ID<rIfZV-3GB-67@gated-at.bofh.it>
In reply to#1409798
On Tue, May 31, 2016 at 5:27 AM, Srinivas Pandruvada
<srinivas.pandruvada@linux.intel.com> wrote:
> Starting from Cherrytrail, multiple generation of Intel processors offers
> on package sensor hub. Several recent tablets, 2-in-1 convertible laptops
> are using ISH instead of external sensor hubs. This resulted in lack of
> support of sensor function like device rotation and auto backlight
> adjustment. In addition, depending on the OEM implementation, support of ISH
> is required to support low power sleep states.
>
> The support of ISH on Linux platforms is not new. Android platforms with
> Intel SoCs had this support for a while submitted by Daniel Drubin.
> This patcheset is reusing most of those changes with  clean up and
> removing Android platform specific changes.

Hi Srinivas,

Thanks for this patch series. I've got an HP Spectre x360 G2
(skylake), and I've built a 4.6.0 kernel with this driver patched in.
It detects the sensors hub, and creates IIO devices under
/sys/bus/iio/devices:

$ ls /sys/bus/iio/devices/
iio:device0  iio:device1  iio:device2  iio:device3  iio:device4
iio:device5  iio:device6  iio:device7  iio:device8  iio:device9
trigger0  trigger1  trigger2  trigger3  trigger4  trigger5  trigger6
trigger7  trigger8  trigger9

However, I haven't figured out how to test it yet. (This is the first
time I'm working with IIO). Do you have any test code or test
procedures to show if it is working?

Thanks,
g.

>
> This series is tested on:
> - Lenovo Yoga 260 with Skylake processor
> - HP Pavilion x2 detachable with Cherrytrail
>
> The user mode ABI is still same as external sensor hubs using Linux
> IIO. So existing user mode software should still work without change.
> This series primarily brings in new HID transport used in ISH.
>
> This series submitted as a RFC to try on several devices. We have
> received request from Linux users who wanted this support. So I hope all
> those users try and give feedback.
>
> Daniel Drubin (3):
>   hid: intel_ish-hid: ISH Transport layer
>   hid: intel-ish-hid: ipc layer
>   hid: intel-ish-hid: ISH HID client driver
>
> Srinivas Pandruvada (1):
>   Documentation: hid: Intel ISH HID document
>
>  Documentation/hid/intel-ish-hid.txt          |  375 +++++++++
>  drivers/hid/Kconfig                          |    2 +
>  drivers/hid/Makefile                         |    2 +
>  drivers/hid/intel-ish-hid/Kconfig            |   27 +
>  drivers/hid/intel-ish-hid/Makefile           |   20 +
>  drivers/hid/intel-ish-hid/ipc/hw-ish-regs.h  |  220 +++++
>  drivers/hid/intel-ish-hid/ipc/hw-ish.h       |   71 ++
>  drivers/hid/intel-ish-hid/ipc/ipc.c          |  710 ++++++++++++++++
>  drivers/hid/intel-ish-hid/ipc/pci-ish.c      |  238 ++++++
>  drivers/hid/intel-ish-hid/ipc/utils.h        |   65 ++
>  drivers/hid/intel-ish-hid/ishtp-hid-client.c |  672 +++++++++++++++
>  drivers/hid/intel-ish-hid/ishtp-hid.c        |  201 +++++
>  drivers/hid/intel-ish-hid/ishtp-hid.h        |  157 ++++
>  drivers/hid/intel-ish-hid/ishtp/bus.c        |  670 +++++++++++++++
>  drivers/hid/intel-ish-hid/ishtp/bus.h        |   99 +++
>  drivers/hid/intel-ish-hid/ishtp/client.c     | 1131 ++++++++++++++++++++++++++
>  drivers/hid/intel-ish-hid/ishtp/client.h     |  196 +++++
>  drivers/hid/intel-ish-hid/ishtp/dma-if.c     |  175 ++++
>  drivers/hid/intel-ish-hid/ishtp/hbm.c        |  911 +++++++++++++++++++++
>  drivers/hid/intel-ish-hid/ishtp/hbm.h        |  319 ++++++++
>  drivers/hid/intel-ish-hid/ishtp/init.c       |   94 +++
>  drivers/hid/intel-ish-hid/ishtp/ishtp-dev.h  |  276 +++++++
>  include/trace/events/intel_ish.h             |   30 +
>  23 files changed, 6661 insertions(+)
>  create mode 100644 Documentation/hid/intel-ish-hid.txt
>  create mode 100644 drivers/hid/intel-ish-hid/Kconfig
>  create mode 100644 drivers/hid/intel-ish-hid/Makefile
>  create mode 100644 drivers/hid/intel-ish-hid/ipc/hw-ish-regs.h
>  create mode 100644 drivers/hid/intel-ish-hid/ipc/hw-ish.h
>  create mode 100644 drivers/hid/intel-ish-hid/ipc/ipc.c
>  create mode 100644 drivers/hid/intel-ish-hid/ipc/pci-ish.c
>  create mode 100644 drivers/hid/intel-ish-hid/ipc/utils.h
>  create mode 100644 drivers/hid/intel-ish-hid/ishtp-hid-client.c
>  create mode 100644 drivers/hid/intel-ish-hid/ishtp-hid.c
>  create mode 100644 drivers/hid/intel-ish-hid/ishtp-hid.h
>  create mode 100644 drivers/hid/intel-ish-hid/ishtp/bus.c
>  create mode 100644 drivers/hid/intel-ish-hid/ishtp/bus.h
>  create mode 100644 drivers/hid/intel-ish-hid/ishtp/client.c
>  create mode 100644 drivers/hid/intel-ish-hid/ishtp/client.h
>  create mode 100644 drivers/hid/intel-ish-hid/ishtp/dma-if.c
>  create mode 100644 drivers/hid/intel-ish-hid/ishtp/hbm.c
>  create mode 100644 drivers/hid/intel-ish-hid/ishtp/hbm.h
>  create mode 100644 drivers/hid/intel-ish-hid/ishtp/init.c
>  create mode 100644 drivers/hid/intel-ish-hid/ishtp/ishtp-dev.h
>  create mode 100644 include/trace/events/intel_ish.h
>
> --
> 1.9.1
>

[toc] | [prev] | [next] | [standalone]


#1418836

FromSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Date2016-06-10 00:00 +0200
Message-ID<rIg9B-3KD-61@gated-at.bofh.it>
In reply to#1418803
Hi,
On Thu, 2016-06-09 at 22:45 +0100, Grant Likely wrote:
> On Tue, May 31, 2016 at 5:27 AM, Srinivas Pandruvada
> <srinivas.pandruvada@linux.intel.com> wrote:
> > 
> > Starting from Cherrytrail, multiple generation of Intel processors
> > offers
> > on package sensor hub. Several recent tablets, 2-in-1 convertible
> > laptops
> > are using ISH instead of external sensor hubs. This resulted in
> > lack of
> > support of sensor function like device rotation and auto backlight
> > adjustment. In addition, depending on the OEM implementation,
> > support of ISH
> > is required to support low power sleep states.
> > 
> > The support of ISH on Linux platforms is not new. Android platforms
> > with
> > Intel SoCs had this support for a while submitted by Daniel Drubin.
> > This patcheset is reusing most of those changes with  clean up and
> > removing Android platform specific changes.
> Hi Srinivas,
> 
> Thanks for this patch series. I've got an HP Spectre x360 G2
> (skylake), and I've built a 4.6.0 kernel with this driver patched in.
> It detects the sensors hub, and creates IIO devices under
> /sys/bus/iio/devices:
> 
> $ ls /sys/bus/iio/devices/
> iio:device0  iio:device1  iio:device2  iio:device3  iio:device4
> iio:device5  iio:device6  iio:device7  iio:device8  iio:device9
> trigger0  trigger1  trigger2  trigger3  trigger4  trigger5  trigger6
> trigger7  trigger8  trigger9
> 
> However, I haven't figured out how to test it yet. (This is the first
> time I'm working with IIO). Do you have any test code or test
> procedures to show if it is working?
> 
If you use Fedora 23 (or any distro with iio-sensor-proxy with gnome
rotation stuff), you should be able to do screen rotation and
brightness using ALS.
Each of these folders should have some raw sysfs files 
in_xxx_raw_xx

You should be able to use "cat" on them.

Thanks,
Srinivas


> Thanks,
> g.
> 
> > 
> > 
> > This series is tested on:
> > - Lenovo Yoga 260 with Skylake processor
> > - HP Pavilion x2 detachable with Cherrytrail
> > 
> > The user mode ABI is still same as external sensor hubs using Linux
> > IIO. So existing user mode software should still work without
> > change.
> > This series primarily brings in new HID transport used in ISH.
> > 
> > This series submitted as a RFC to try on several devices. We have
> > received request from Linux users who wanted this support. So I
> > hope all
> > those users try and give feedback.
> > 
> > Daniel Drubin (3):
> >   hid: intel_ish-hid: ISH Transport layer
> >   hid: intel-ish-hid: ipc layer
> >   hid: intel-ish-hid: ISH HID client driver
> > 
> > Srinivas Pandruvada (1):
> >   Documentation: hid: Intel ISH HID document
> > 
> >  Documentation/hid/intel-ish-hid.txt          |  375 +++++++++
> >  drivers/hid/Kconfig                          |    2 +
> >  drivers/hid/Makefile                         |    2 +
> >  drivers/hid/intel-ish-hid/Kconfig            |   27 +
> >  drivers/hid/intel-ish-hid/Makefile           |   20 +
> >  drivers/hid/intel-ish-hid/ipc/hw-ish-regs.h  |  220 +++++
> >  drivers/hid/intel-ish-hid/ipc/hw-ish.h       |   71 ++
> >  drivers/hid/intel-ish-hid/ipc/ipc.c          |  710
> > ++++++++++++++++
> >  drivers/hid/intel-ish-hid/ipc/pci-ish.c      |  238 ++++++
> >  drivers/hid/intel-ish-hid/ipc/utils.h        |   65 ++
> >  drivers/hid/intel-ish-hid/ishtp-hid-client.c |  672
> > +++++++++++++++
> >  drivers/hid/intel-ish-hid/ishtp-hid.c        |  201 +++++
> >  drivers/hid/intel-ish-hid/ishtp-hid.h        |  157 ++++
> >  drivers/hid/intel-ish-hid/ishtp/bus.c        |  670
> > +++++++++++++++
> >  drivers/hid/intel-ish-hid/ishtp/bus.h        |   99 +++
> >  drivers/hid/intel-ish-hid/ishtp/client.c     | 1131
> > ++++++++++++++++++++++++++
> >  drivers/hid/intel-ish-hid/ishtp/client.h     |  196 +++++
> >  drivers/hid/intel-ish-hid/ishtp/dma-if.c     |  175 ++++
> >  drivers/hid/intel-ish-hid/ishtp/hbm.c        |  911
> > +++++++++++++++++++++
> >  drivers/hid/intel-ish-hid/ishtp/hbm.h        |  319 ++++++++
> >  drivers/hid/intel-ish-hid/ishtp/init.c       |   94 +++
> >  drivers/hid/intel-ish-hid/ishtp/ishtp-dev.h  |  276 +++++++
> >  include/trace/events/intel_ish.h             |   30 +
> >  23 files changed, 6661 insertions(+)
> >  create mode 100644 Documentation/hid/intel-ish-hid.txt
> >  create mode 100644 drivers/hid/intel-ish-hid/Kconfig
> >  create mode 100644 drivers/hid/intel-ish-hid/Makefile
> >  create mode 100644 drivers/hid/intel-ish-hid/ipc/hw-ish-regs.h
> >  create mode 100644 drivers/hid/intel-ish-hid/ipc/hw-ish.h
> >  create mode 100644 drivers/hid/intel-ish-hid/ipc/ipc.c
> >  create mode 100644 drivers/hid/intel-ish-hid/ipc/pci-ish.c
> >  create mode 100644 drivers/hid/intel-ish-hid/ipc/utils.h
> >  create mode 100644 drivers/hid/intel-ish-hid/ishtp-hid-client.c
> >  create mode 100644 drivers/hid/intel-ish-hid/ishtp-hid.c
> >  create mode 100644 drivers/hid/intel-ish-hid/ishtp-hid.h
> >  create mode 100644 drivers/hid/intel-ish-hid/ishtp/bus.c
> >  create mode 100644 drivers/hid/intel-ish-hid/ishtp/bus.h
> >  create mode 100644 drivers/hid/intel-ish-hid/ishtp/client.c
> >  create mode 100644 drivers/hid/intel-ish-hid/ishtp/client.h
> >  create mode 100644 drivers/hid/intel-ish-hid/ishtp/dma-if.c
> >  create mode 100644 drivers/hid/intel-ish-hid/ishtp/hbm.c
> >  create mode 100644 drivers/hid/intel-ish-hid/ishtp/hbm.h
> >  create mode 100644 drivers/hid/intel-ish-hid/ishtp/init.c
> >  create mode 100644 drivers/hid/intel-ish-hid/ishtp/ishtp-dev.h
> >  create mode 100644 include/trace/events/intel_ish.h
> > 
> > --
> > 1.9.1
> > 

[toc] | [prev] | [next] | [standalone]


#1419173

FromGrant Likely <grant.likely@secretlab.ca>
Date2016-06-10 11:50 +0200
Message-ID<rIreG-2SG-25@gated-at.bofh.it>
In reply to#1418836
On Thu, Jun 9, 2016 at 10:54 PM, Srinivas Pandruvada
<srinivas.pandruvada@linux.intel.com> wrote:
> Hi,
> On Thu, 2016-06-09 at 22:45 +0100, Grant Likely wrote:
>> On Tue, May 31, 2016 at 5:27 AM, Srinivas Pandruvada
>> <srinivas.pandruvada@linux.intel.com> wrote:
>> >
>> > Starting from Cherrytrail, multiple generation of Intel processors
>> > offers
>> > on package sensor hub. Several recent tablets, 2-in-1 convertible
>> > laptops
>> > are using ISH instead of external sensor hubs. This resulted in
>> > lack of
>> > support of sensor function like device rotation and auto backlight
>> > adjustment. In addition, depending on the OEM implementation,
>> > support of ISH
>> > is required to support low power sleep states.
>> >
>> > The support of ISH on Linux platforms is not new. Android platforms
>> > with
>> > Intel SoCs had this support for a while submitted by Daniel Drubin.
>> > This patcheset is reusing most of those changes with  clean up and
>> > removing Android platform specific changes.
>> Hi Srinivas,
>>
>> Thanks for this patch series. I've got an HP Spectre x360 G2
>> (skylake), and I've built a 4.6.0 kernel with this driver patched in.
>> It detects the sensors hub, and creates IIO devices under
>> /sys/bus/iio/devices:
>>
>> $ ls /sys/bus/iio/devices/
>> iio:device0  iio:device1  iio:device2  iio:device3  iio:device4
>> iio:device5  iio:device6  iio:device7  iio:device8  iio:device9
>> trigger0  trigger1  trigger2  trigger3  trigger4  trigger5  trigger6
>> trigger7  trigger8  trigger9
>>
>> However, I haven't figured out how to test it yet. (This is the first
>> time I'm working with IIO). Do you have any test code or test
>> procedures to show if it is working?
>>
> If you use Fedora 23 (or any distro with iio-sensor-proxy with gnome
> rotation stuff), you should be able to do screen rotation and
> brightness using ALS.
> Each of these folders should have some raw sysfs files
> in_xxx_raw_xx
>
> You should be able to use "cat" on them.

Yes, I do see the in_*_raw_* files in sysfs, and I'm able to get data
out of them. Gnome also seems to recognize that the accelerometers are
there because it adds a rotation lock button to the system menu.

However, the events are getting through yet. It may be that I'm
missing something in my kernel config. I'm rebuilding the kernel with
Debian's config for the 4.5.5 kernel as a quick sanity test. I'll
report back when I've tried.

I'll also take some time and review the patch series later this afternoon.

g.

>
> Thanks,
> Srinivas
>
>
>> Thanks,
>> g.
>>
>> >
>> >
>> > This series is tested on:
>> > - Lenovo Yoga 260 with Skylake processor
>> > - HP Pavilion x2 detachable with Cherrytrail
>> >
>> > The user mode ABI is still same as external sensor hubs using Linux
>> > IIO. So existing user mode software should still work without
>> > change.
>> > This series primarily brings in new HID transport used in ISH.
>> >
>> > This series submitted as a RFC to try on several devices. We have
>> > received request from Linux users who wanted this support. So I
>> > hope all
>> > those users try and give feedback.
>> >
>> > Daniel Drubin (3):
>> >   hid: intel_ish-hid: ISH Transport layer
>> >   hid: intel-ish-hid: ipc layer
>> >   hid: intel-ish-hid: ISH HID client driver
>> >
>> > Srinivas Pandruvada (1):
>> >   Documentation: hid: Intel ISH HID document
>> >
>> >  Documentation/hid/intel-ish-hid.txt          |  375 +++++++++
>> >  drivers/hid/Kconfig                          |    2 +
>> >  drivers/hid/Makefile                         |    2 +
>> >  drivers/hid/intel-ish-hid/Kconfig            |   27 +
>> >  drivers/hid/intel-ish-hid/Makefile           |   20 +
>> >  drivers/hid/intel-ish-hid/ipc/hw-ish-regs.h  |  220 +++++
>> >  drivers/hid/intel-ish-hid/ipc/hw-ish.h       |   71 ++
>> >  drivers/hid/intel-ish-hid/ipc/ipc.c          |  710
>> > ++++++++++++++++
>> >  drivers/hid/intel-ish-hid/ipc/pci-ish.c      |  238 ++++++
>> >  drivers/hid/intel-ish-hid/ipc/utils.h        |   65 ++
>> >  drivers/hid/intel-ish-hid/ishtp-hid-client.c |  672
>> > +++++++++++++++
>> >  drivers/hid/intel-ish-hid/ishtp-hid.c        |  201 +++++
>> >  drivers/hid/intel-ish-hid/ishtp-hid.h        |  157 ++++
>> >  drivers/hid/intel-ish-hid/ishtp/bus.c        |  670
>> > +++++++++++++++
>> >  drivers/hid/intel-ish-hid/ishtp/bus.h        |   99 +++
>> >  drivers/hid/intel-ish-hid/ishtp/client.c     | 1131
>> > ++++++++++++++++++++++++++
>> >  drivers/hid/intel-ish-hid/ishtp/client.h     |  196 +++++
>> >  drivers/hid/intel-ish-hid/ishtp/dma-if.c     |  175 ++++
>> >  drivers/hid/intel-ish-hid/ishtp/hbm.c        |  911
>> > +++++++++++++++++++++
>> >  drivers/hid/intel-ish-hid/ishtp/hbm.h        |  319 ++++++++
>> >  drivers/hid/intel-ish-hid/ishtp/init.c       |   94 +++
>> >  drivers/hid/intel-ish-hid/ishtp/ishtp-dev.h  |  276 +++++++
>> >  include/trace/events/intel_ish.h             |   30 +
>> >  23 files changed, 6661 insertions(+)
>> >  create mode 100644 Documentation/hid/intel-ish-hid.txt
>> >  create mode 100644 drivers/hid/intel-ish-hid/Kconfig
>> >  create mode 100644 drivers/hid/intel-ish-hid/Makefile
>> >  create mode 100644 drivers/hid/intel-ish-hid/ipc/hw-ish-regs.h
>> >  create mode 100644 drivers/hid/intel-ish-hid/ipc/hw-ish.h
>> >  create mode 100644 drivers/hid/intel-ish-hid/ipc/ipc.c
>> >  create mode 100644 drivers/hid/intel-ish-hid/ipc/pci-ish.c
>> >  create mode 100644 drivers/hid/intel-ish-hid/ipc/utils.h
>> >  create mode 100644 drivers/hid/intel-ish-hid/ishtp-hid-client.c
>> >  create mode 100644 drivers/hid/intel-ish-hid/ishtp-hid.c
>> >  create mode 100644 drivers/hid/intel-ish-hid/ishtp-hid.h
>> >  create mode 100644 drivers/hid/intel-ish-hid/ishtp/bus.c
>> >  create mode 100644 drivers/hid/intel-ish-hid/ishtp/bus.h
>> >  create mode 100644 drivers/hid/intel-ish-hid/ishtp/client.c
>> >  create mode 100644 drivers/hid/intel-ish-hid/ishtp/client.h
>> >  create mode 100644 drivers/hid/intel-ish-hid/ishtp/dma-if.c
>> >  create mode 100644 drivers/hid/intel-ish-hid/ishtp/hbm.c
>> >  create mode 100644 drivers/hid/intel-ish-hid/ishtp/hbm.h
>> >  create mode 100644 drivers/hid/intel-ish-hid/ishtp/init.c
>> >  create mode 100644 drivers/hid/intel-ish-hid/ishtp/ishtp-dev.h
>> >  create mode 100644 include/trace/events/intel_ish.h
>> >
>> > --
>> > 1.9.1
>> >

[toc] | [prev] | [next] | [standalone]


#1419443

FromSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Date2016-06-10 16:00 +0200
Message-ID<rIv8C-5fJ-27@gated-at.bofh.it>
In reply to#1419173
On Fri, 2016-06-10 at 10:44 +0100, Grant Likely wrote:
[...]
> 
> Yes, I do see the in_*_raw_* files in sysfs, and I'm able to get data
> out of them. Gnome also seems to recognize that the accelerometers
> are
> there because it adds a rotation lock button to the system menu.
> 
> However, the events are getting through yet. It may be that I'm
> missing something in my kernel config. I'm rebuilding the kernel with
> Debian's config for the 4.5.5 kernel as a quick sanity test. I'll
> report back when I've tried.
> 
You need to add in /usr/lib/system/systemd/iio-sensor-*

After=multi-user.target


This service starts too early.

> I'll also take some time and review the patch series later this
> afternoon.

Atri Bhattacharya reported issues with suspend/resume. With my test
patches it is fixed for him

If you want to hold on, I will repost with fixes for susend/resume.

Thanks,
Srinivas

> 

> g.
> 
> > 
> > Thanks,
> > Srinivas
> > 
> > 
> > > Thanks,
> > > g.
> > > 
> > > > 
> > > > 
> > > > This series is tested on:
> > > > - Lenovo Yoga 260 with Skylake processor
> > > > - HP Pavilion x2 detachable with Cherrytrail
> > > > 
> > > > The user mode ABI is still same as external sensor hubs using
> > > > Linux
> > > > IIO. So existing user mode software should still work without
> > > > change.
> > > > This series primarily brings in new HID transport used in ISH.
> > > > 
> > > > This series submitted as a RFC to try on several devices. We
> > > > have
> > > > received request from Linux users who wanted this support. So I
> > > > hope all
> > > > those users try and give feedback.
> > > > 
> > > > Daniel Drubin (3):
> > > >   hid: intel_ish-hid: ISH Transport layer
> > > >   hid: intel-ish-hid: ipc layer
> > > >   hid: intel-ish-hid: ISH HID client driver
> > > > 
> > > > Srinivas Pandruvada (1):
> > > >   Documentation: hid: Intel ISH HID document
> > > > 
> > > >  Documentation/hid/intel-ish-hid.txt          |  375 +++++++++
> > > >  drivers/hid/Kconfig                          |    2 +
> > > >  drivers/hid/Makefile                         |    2 +
> > > >  drivers/hid/intel-ish-hid/Kconfig            |   27 +
> > > >  drivers/hid/intel-ish-hid/Makefile           |   20 +
> > > >  drivers/hid/intel-ish-hid/ipc/hw-ish-regs.h  |  220 +++++
> > > >  drivers/hid/intel-ish-hid/ipc/hw-ish.h       |   71 ++
> > > >  drivers/hid/intel-ish-hid/ipc/ipc.c          |  710
> > > > ++++++++++++++++
> > > >  drivers/hid/intel-ish-hid/ipc/pci-ish.c      |  238 ++++++
> > > >  drivers/hid/intel-ish-hid/ipc/utils.h        |   65 ++
> > > >  drivers/hid/intel-ish-hid/ishtp-hid-client.c |  672
> > > > +++++++++++++++
> > > >  drivers/hid/intel-ish-hid/ishtp-hid.c        |  201 +++++
> > > >  drivers/hid/intel-ish-hid/ishtp-hid.h        |  157 ++++
> > > >  drivers/hid/intel-ish-hid/ishtp/bus.c        |  670
> > > > +++++++++++++++
> > > >  drivers/hid/intel-ish-hid/ishtp/bus.h        |   99 +++
> > > >  drivers/hid/intel-ish-hid/ishtp/client.c     | 1131
> > > > ++++++++++++++++++++++++++
> > > >  drivers/hid/intel-ish-hid/ishtp/client.h     |  196 +++++
> > > >  drivers/hid/intel-ish-hid/ishtp/dma-if.c     |  175 ++++
> > > >  drivers/hid/intel-ish-hid/ishtp/hbm.c        |  911
> > > > +++++++++++++++++++++
> > > >  drivers/hid/intel-ish-hid/ishtp/hbm.h        |  319 ++++++++
> > > >  drivers/hid/intel-ish-hid/ishtp/init.c       |   94 +++
> > > >  drivers/hid/intel-ish-hid/ishtp/ishtp-dev.h  |  276 +++++++
> > > >  include/trace/events/intel_ish.h             |   30 +
> > > >  23 files changed, 6661 insertions(+)
> > > >  create mode 100644 Documentation/hid/intel-ish-hid.txt
> > > >  create mode 100644 drivers/hid/intel-ish-hid/Kconfig
> > > >  create mode 100644 drivers/hid/intel-ish-hid/Makefile
> > > >  create mode 100644 drivers/hid/intel-ish-hid/ipc/hw-ish-regs.h
> > > >  create mode 100644 drivers/hid/intel-ish-hid/ipc/hw-ish.h
> > > >  create mode 100644 drivers/hid/intel-ish-hid/ipc/ipc.c
> > > >  create mode 100644 drivers/hid/intel-ish-hid/ipc/pci-ish.c
> > > >  create mode 100644 drivers/hid/intel-ish-hid/ipc/utils.h
> > > >  create mode 100644 drivers/hid/intel-ish-hid/ishtp-hid-
> > > > client.c
> > > >  create mode 100644 drivers/hid/intel-ish-hid/ishtp-hid.c
> > > >  create mode 100644 drivers/hid/intel-ish-hid/ishtp-hid.h
> > > >  create mode 100644 drivers/hid/intel-ish-hid/ishtp/bus.c
> > > >  create mode 100644 drivers/hid/intel-ish-hid/ishtp/bus.h
> > > >  create mode 100644 drivers/hid/intel-ish-hid/ishtp/client.c
> > > >  create mode 100644 drivers/hid/intel-ish-hid/ishtp/client.h
> > > >  create mode 100644 drivers/hid/intel-ish-hid/ishtp/dma-if.c
> > > >  create mode 100644 drivers/hid/intel-ish-hid/ishtp/hbm.c
> > > >  create mode 100644 drivers/hid/intel-ish-hid/ishtp/hbm.h
> > > >  create mode 100644 drivers/hid/intel-ish-hid/ishtp/init.c
> > > >  create mode 100644 drivers/hid/intel-ish-hid/ishtp/ishtp-dev.h
> > > >  create mode 100644 include/trace/events/intel_ish.h
> > > > 
> > > > --
> > > > 1.9.1
> > > > 

[toc] | [prev] | [next] | [standalone]


#1419472

FromBastien Nocera <hadess@hadess.net>
Date2016-06-10 16:30 +0200
Message-ID<rIvBD-5Ff-7@gated-at.bofh.it>
In reply to#1419443
On Fri, 2016-06-10 at 06:55 -0700, Srinivas Pandruvada wrote:
> On Fri, 2016-06-10 at 10:44 +0100, Grant Likely wrote:
> [...]
> > 
> > Yes, I do see the in_*_raw_* files in sysfs, and I'm able to get
> > data
> > out of them. Gnome also seems to recognize that the accelerometers
> > are
> > there because it adds a rotation lock button to the system menu.
> > 
> > However, the events are getting through yet. It may be that I'm
> > missing something in my kernel config. I'm rebuilding the kernel
> > with
> > Debian's config for the 4.5.5 kernel as a quick sanity test. I'll
> > report back when I've tried.
> > 
> You need to add in /usr/lib/system/systemd/iio-sensor-*
> 
> After=multi-user.target
> 
> 
> This service starts too early.

Nobody has been able to explain to me why that would be a problem.

Can you back this up with some data? Does iio-sensor-proxy exit too
early? Does that leave time to the IIO sub-system to do some init work
it should already have done?

See also https://github.com/hadess/iio-sensor-proxy/issues/82

> > I'll also take some time and review the patch series later this
> > afternoon.
> 
> Atri Bhattacharya reported issues with suspend/resume. With my test
> patches it is fixed for him
> 
> If you want to hold on, I will repost with fixes for susend/resume.

[toc] | [prev] | [next] | [standalone]


#1419488

FromSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Date2016-06-10 16:50 +0200
Message-ID<rIvUZ-5O9-1@gated-at.bofh.it>
In reply to#1419472
On Fri, 2016-06-10 at 16:26 +0200, Bastien Nocera wrote:
> On Fri, 2016-06-10 at 06:55 -0700, Srinivas Pandruvada wrote:
> > On Fri, 2016-06-10 at 10:44 +0100, Grant Likely wrote:
> > [...]
> > > 
> > > Yes, I do see the in_*_raw_* files in sysfs, and I'm able to get
> > > data
> > > out of them. Gnome also seems to recognize that the
> > > accelerometers
> > > are
> > > there because it adds a rotation lock button to the system menu.
> > > 
> > > However, the events are getting through yet. It may be that I'm
> > > missing something in my kernel config. I'm rebuilding the kernel
> > > with
> > > Debian's config for the 4.5.5 kernel as a quick sanity test. I'll
> > > report back when I've tried.
> > > 
> > You need to add in /usr/lib/system/systemd/iio-sensor-*
> > 
> > After=multi-user.target
> > 
> > 
> > This service starts too early.
> 
> Nobody has been able to explain to me why that would be a problem.
> 
> Can you back this up with some data? Does iio-sensor-proxy exit too
> early? Does that leave time to the IIO sub-system to do some init
> work
> it should already have done?
The driver's  trigger callback doesn't even get called to take any
action or provide any data. So to get called need to restart the
service or do suspend/resume.
After=multi-user.target, is not the ideal solution as it is too late.
So need further debug.

> 
> See also https://github.com/hadess/iio-sensor-proxy/issues/82
> 
> > > I'll also take some time and review the patch series later this
> > > afternoon.
> > 
> > Atri Bhattacharya reported issues with suspend/resume. With my test
> > patches it is fixed for him
> > 
> > If you want to hold on, I will repost with fixes for susend/resume.
> 

[toc] | [prev] | [next] | [standalone]


#1419505

FromBastien Nocera <hadess@hadess.net>
Date2016-06-10 17:10 +0200
Message-ID<rIwel-6ae-15@gated-at.bofh.it>
In reply to#1419488
On Fri, 2016-06-10 at 07:45 -0700, Srinivas Pandruvada wrote:
> On Fri, 2016-06-10 at 16:26 +0200, Bastien Nocera wrote:
> > On Fri, 2016-06-10 at 06:55 -0700, Srinivas Pandruvada wrote:
> > > On Fri, 2016-06-10 at 10:44 +0100, Grant Likely wrote:
> > > [...]
> > > > 
> > > > Yes, I do see the in_*_raw_* files in sysfs, and I'm able to
> > > > get
> > > > data
> > > > out of them. Gnome also seems to recognize that the
> > > > accelerometers
> > > > are
> > > > there because it adds a rotation lock button to the system
> > > > menu.
> > > > 
> > > > However, the events are getting through yet. It may be that I'm
> > > > missing something in my kernel config. I'm rebuilding the
> > > > kernel
> > > > with
> > > > Debian's config for the 4.5.5 kernel as a quick sanity test.
> > > > I'll
> > > > report back when I've tried.
> > > > 
> > > You need to add in /usr/lib/system/systemd/iio-sensor-*
> > > 
> > > After=multi-user.target
> > > 
> > > 
> > > This service starts too early.
> > 
> > Nobody has been able to explain to me why that would be a problem.
> > 
> > Can you back this up with some data? Does iio-sensor-proxy exit too
> > early? Does that leave time to the IIO sub-system to do some init
> > work
> > it should already have done?
> The driver's  trigger callback doesn't even get called to take any
> action or provide any data. So to get called need to restart the
> service or do suspend/resume.

Are there any errors when setting the triggers?

The code there is probably a bit naive, but I'd rather fix that rather
than postpone the start of the daemon.

> After=multi-user.target, is not the ideal solution as it is too late.
> So need further debug.
> 
> > 
> > See also https://github.com/hadess/iio-sensor-proxy/issues/82
> > 
> > > > I'll also take some time and review the patch series later this
> > > > afternoon.
> > > 
> > > Atri Bhattacharya reported issues with suspend/resume. With my
> > > test
> > > patches it is fixed for him
> > > 
> > > If you want to hold on, I will repost with fixes for
> > > susend/resume.
> > 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-
> input" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

[toc] | [prev] | [next] | [standalone]


#1419516

FromBastien Nocera <hadess@hadess.net>
Date2016-06-10 17:30 +0200
Message-ID<rIwxH-6gP-7@gated-at.bofh.it>
In reply to#1419505
On Fri, 2016-06-10 at 08:23 -0700, Srinivas Pandruvada wrote:
> On Fri, 2016-06-10 at 17:04 +0200, Bastien Nocera wrote:
> > > 
> 
> [...]
> 
> > Are there any errors when setting the triggers?
> > 
> Is there any debug option in this service to give more verbose
> output?

Add:
Environment="G_MESSAGES_DEBUG=all"

To the service file. You should see the debug in systemctl:
systemctl status iio-sensor-proxy.service

Or in journalctl if there's too much data:
journalctl --reverse -u iio-sensor-proxy.service

Cheers

[toc] | [prev] | [next] | [standalone]


#1419518

FromSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Date2016-06-10 17:30 +0200
Message-ID<rIwxH-6gP-9@gated-at.bofh.it>
In reply to#1419505
On Fri, 2016-06-10 at 17:04 +0200, Bastien Nocera wrote:
> > 

[...]

> Are there any errors when setting the triggers?
> 
Is there any debug option in this service to give more verbose output?


> The code there is probably a bit naive, but I'd rather fix that
> rather
> than postpone the start of the daemon.
Agree, we shouldn't postpone. 

Thanks,
Srinivas

> 
> > 
> > After=multi-user.target, is not the ideal solution as it is too
> > late.
> > So need further debug.
> > 
> > > 
> > > 
> > > See also https://github.com/hadess/iio-sensor-proxy/issues/82
> > > 
> > > > 
> > > > > 
> > > > > I'll also take some time and review the patch series later
> > > > > this
> > > > > afternoon.
> > > > Atri Bhattacharya reported issues with suspend/resume. With my
> > > > test
> > > > patches it is fixed for him
> > > > 
> > > > If you want to hold on, I will repost with fixes for
> > > > susend/resume.
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-
> > input" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html

[toc] | [prev] | [next] | [standalone]


#1419456

FromGrant Likely <grant.likely@secretlab.ca>
Date2016-06-10 16:10 +0200
Message-ID<rIvii-5yi-25@gated-at.bofh.it>
In reply to#1419173
On Fri, Jun 10, 2016 at 10:44 AM, Grant Likely
<grant.likely@secretlab.ca> wrote:
> On Thu, Jun 9, 2016 at 10:54 PM, Srinivas Pandruvada
> <srinivas.pandruvada@linux.intel.com> wrote:
>> Hi,
>> On Thu, 2016-06-09 at 22:45 +0100, Grant Likely wrote:
>>> On Tue, May 31, 2016 at 5:27 AM, Srinivas Pandruvada
>>> <srinivas.pandruvada@linux.intel.com> wrote:
>>> >
>>> > Starting from Cherrytrail, multiple generation of Intel processors
>>> > offers
>>> > on package sensor hub. Several recent tablets, 2-in-1 convertible
>>> > laptops
>>> > are using ISH instead of external sensor hubs. This resulted in
>>> > lack of
>>> > support of sensor function like device rotation and auto backlight
>>> > adjustment. In addition, depending on the OEM implementation,
>>> > support of ISH
>>> > is required to support low power sleep states.
>>> >
>>> > The support of ISH on Linux platforms is not new. Android platforms
>>> > with
>>> > Intel SoCs had this support for a while submitted by Daniel Drubin.
>>> > This patcheset is reusing most of those changes with  clean up and
>>> > removing Android platform specific changes.
>>> Hi Srinivas,
>>>
>>> Thanks for this patch series. I've got an HP Spectre x360 G2
>>> (skylake), and I've built a 4.6.0 kernel with this driver patched in.
>>> It detects the sensors hub, and creates IIO devices under
>>> /sys/bus/iio/devices:
>>>
>>> $ ls /sys/bus/iio/devices/
>>> iio:device0  iio:device1  iio:device2  iio:device3  iio:device4
>>> iio:device5  iio:device6  iio:device7  iio:device8  iio:device9
>>> trigger0  trigger1  trigger2  trigger3  trigger4  trigger5  trigger6
>>> trigger7  trigger8  trigger9
>>>
>>> However, I haven't figured out how to test it yet. (This is the first
>>> time I'm working with IIO). Do you have any test code or test
>>> procedures to show if it is working?
>>>
>> If you use Fedora 23 (or any distro with iio-sensor-proxy with gnome
>> rotation stuff), you should be able to do screen rotation and
>> brightness using ALS.
>> Each of these folders should have some raw sysfs files
>> in_xxx_raw_xx
>>
>> You should be able to use "cat" on them.
>
> Yes, I do see the in_*_raw_* files in sysfs, and I'm able to get data
> out of them. Gnome also seems to recognize that the accelerometers are
> there because it adds a rotation lock button to the system menu.
>
> However, the events are getting through yet. It may be that I'm
> missing something in my kernel config. I'm rebuilding the kernel with
> Debian's config for the 4.5.5 kernel as a quick sanity test. I'll
> report back when I've tried.

Still no joy here on getting wired up to Gnome. The sensors exist, and
I can view the output. For example, the following shell command will
give a live view of the accelerometer settings:

while true; clear; do { for f in iio\:device*/in_accel*raw; do echo $f
`cat $f`; done }; sleep 0.25s; done

In "Laptop mode":
iio:device1/in_accel_x_raw 2184
iio:device1/in_accel_y_raw -968620
iio:device1/in_accel_z_raw -224273
iio:device3/in_accel_x_raw 5784
iio:device3/in_accel_y_raw -946324
iio:device3/in_accel_z_raw -218647

When rotated clockwise 90 degrees:
iio:device1/in_accel_x_raw 1013843
iio:device1/in_accel_y_raw 8523
iio:device1/in_accel_z_raw -12259
iio:device3/in_accel_x_raw 1012352
iio:device3/in_accel_y_raw 14487
iio:device3/in_accel_z_raw -6891

When lying flat:
iio:device1/in_accel_x_raw 6995
iio:device1/in_accel_y_raw -32824
iio:device1/in_accel_z_raw -986080
iio:device3/in_accel_x_raw 5797
iio:device3/in_accel_y_raw -31402
iio:device3/in_accel_z_raw -984732

However, Gnome isn't picking up the rotation events. I don't know
where in the stack things are falling down. I do have iio-sensor-proxy
running. Any hints on debugging this?

Yet, some stuff is working now. The keyboard (but not the trackpad)
gets disabled when folded back in tablet mode.

g.

>
> I'll also take some time and review the patch series later this afternoon.
>
> g.
>
>>
>> Thanks,
>> Srinivas
>>
>>
>>> Thanks,
>>> g.
>>>
>>> >
>>> >
>>> > This series is tested on:
>>> > - Lenovo Yoga 260 with Skylake processor
>>> > - HP Pavilion x2 detachable with Cherrytrail
>>> >
>>> > The user mode ABI is still same as external sensor hubs using Linux
>>> > IIO. So existing user mode software should still work without
>>> > change.
>>> > This series primarily brings in new HID transport used in ISH.
>>> >
>>> > This series submitted as a RFC to try on several devices. We have
>>> > received request from Linux users who wanted this support. So I
>>> > hope all
>>> > those users try and give feedback.
>>> >
>>> > Daniel Drubin (3):
>>> >   hid: intel_ish-hid: ISH Transport layer
>>> >   hid: intel-ish-hid: ipc layer
>>> >   hid: intel-ish-hid: ISH HID client driver
>>> >
>>> > Srinivas Pandruvada (1):
>>> >   Documentation: hid: Intel ISH HID document
>>> >
>>> >  Documentation/hid/intel-ish-hid.txt          |  375 +++++++++
>>> >  drivers/hid/Kconfig                          |    2 +
>>> >  drivers/hid/Makefile                         |    2 +
>>> >  drivers/hid/intel-ish-hid/Kconfig            |   27 +
>>> >  drivers/hid/intel-ish-hid/Makefile           |   20 +
>>> >  drivers/hid/intel-ish-hid/ipc/hw-ish-regs.h  |  220 +++++
>>> >  drivers/hid/intel-ish-hid/ipc/hw-ish.h       |   71 ++
>>> >  drivers/hid/intel-ish-hid/ipc/ipc.c          |  710
>>> > ++++++++++++++++
>>> >  drivers/hid/intel-ish-hid/ipc/pci-ish.c      |  238 ++++++
>>> >  drivers/hid/intel-ish-hid/ipc/utils.h        |   65 ++
>>> >  drivers/hid/intel-ish-hid/ishtp-hid-client.c |  672
>>> > +++++++++++++++
>>> >  drivers/hid/intel-ish-hid/ishtp-hid.c        |  201 +++++
>>> >  drivers/hid/intel-ish-hid/ishtp-hid.h        |  157 ++++
>>> >  drivers/hid/intel-ish-hid/ishtp/bus.c        |  670
>>> > +++++++++++++++
>>> >  drivers/hid/intel-ish-hid/ishtp/bus.h        |   99 +++
>>> >  drivers/hid/intel-ish-hid/ishtp/client.c     | 1131
>>> > ++++++++++++++++++++++++++
>>> >  drivers/hid/intel-ish-hid/ishtp/client.h     |  196 +++++
>>> >  drivers/hid/intel-ish-hid/ishtp/dma-if.c     |  175 ++++
>>> >  drivers/hid/intel-ish-hid/ishtp/hbm.c        |  911
>>> > +++++++++++++++++++++
>>> >  drivers/hid/intel-ish-hid/ishtp/hbm.h        |  319 ++++++++
>>> >  drivers/hid/intel-ish-hid/ishtp/init.c       |   94 +++
>>> >  drivers/hid/intel-ish-hid/ishtp/ishtp-dev.h  |  276 +++++++
>>> >  include/trace/events/intel_ish.h             |   30 +
>>> >  23 files changed, 6661 insertions(+)
>>> >  create mode 100644 Documentation/hid/intel-ish-hid.txt
>>> >  create mode 100644 drivers/hid/intel-ish-hid/Kconfig
>>> >  create mode 100644 drivers/hid/intel-ish-hid/Makefile
>>> >  create mode 100644 drivers/hid/intel-ish-hid/ipc/hw-ish-regs.h
>>> >  create mode 100644 drivers/hid/intel-ish-hid/ipc/hw-ish.h
>>> >  create mode 100644 drivers/hid/intel-ish-hid/ipc/ipc.c
>>> >  create mode 100644 drivers/hid/intel-ish-hid/ipc/pci-ish.c
>>> >  create mode 100644 drivers/hid/intel-ish-hid/ipc/utils.h
>>> >  create mode 100644 drivers/hid/intel-ish-hid/ishtp-hid-client.c
>>> >  create mode 100644 drivers/hid/intel-ish-hid/ishtp-hid.c
>>> >  create mode 100644 drivers/hid/intel-ish-hid/ishtp-hid.h
>>> >  create mode 100644 drivers/hid/intel-ish-hid/ishtp/bus.c
>>> >  create mode 100644 drivers/hid/intel-ish-hid/ishtp/bus.h
>>> >  create mode 100644 drivers/hid/intel-ish-hid/ishtp/client.c
>>> >  create mode 100644 drivers/hid/intel-ish-hid/ishtp/client.h
>>> >  create mode 100644 drivers/hid/intel-ish-hid/ishtp/dma-if.c
>>> >  create mode 100644 drivers/hid/intel-ish-hid/ishtp/hbm.c
>>> >  create mode 100644 drivers/hid/intel-ish-hid/ishtp/hbm.h
>>> >  create mode 100644 drivers/hid/intel-ish-hid/ishtp/init.c
>>> >  create mode 100644 drivers/hid/intel-ish-hid/ishtp/ishtp-dev.h
>>> >  create mode 100644 include/trace/events/intel_ish.h
>>> >
>>> > --
>>> > 1.9.1
>>> >

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web