Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 296d10aa authored by Lior Barenboim's avatar Lior Barenboim
Browse files

msm: ultrasound: Add support for general button events



The side buttons bitmap was expanded to allow sending button
events for tool type buttons (stylus, rubber) and also for a new
button which signals that the hovering icon should be displayed.

The event source field was removed as it was previously used to
set the tool type, which is now done explicitly via the buttons
bitmap.

Change-Id: Id08921c392eeec8928ca0c730988f8c83be2ba8f
Signed-off-by: default avatarLior Barenboim <liorb@codeaurora.org>
parent 42dd734f
Loading
Loading
Loading
Loading
+5 −14
Original line number Diff line number Diff line
/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.
/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -132,13 +132,6 @@ struct us_xx_info_type {
	uint8_t *params_data;
};

/* Input events sources */
enum us_input_event_src_type {
	US_INPUT_SRC_PEN,
	US_INPUT_SRC_FINGER,
	US_INPUT_SRC_UNDEF
};

struct us_input_info_type {
	/* Touch screen dimensions: min & max;for input module */
	int tsc_x_dim[MIN_MAX_DIM];
@@ -149,12 +142,10 @@ struct us_input_info_type {
	int tsc_y_tilt[MIN_MAX_DIM];
	/* Touch screen pressure limits: min & max; for input module */
	int tsc_pressure[MIN_MAX_DIM];
	/* The requested side buttons bitmap */
	uint16_t req_side_buttons_bitmap;
	/* The requested buttons bitmap */
	uint16_t req_buttons_bitmap;
	/* Bitmap of types of events (USF_X_EVENT), produced by calculator */
	uint16_t event_types;
	/* Input event source */
	enum us_input_event_src_type event_src;
	/* Bitmap of types of events from devs, conflicting with USF */
	uint16_t conflicting_event_types;
};
@@ -179,8 +170,8 @@ struct point_event_type {
	int inclinations[TILTS_DIM];
/* [0-1023] (10bits); 0 - pen up */
	uint32_t pressure;
/* Bitmap for side button state. 1 - down, 0 - up */
	uint16_t side_buttons_state_bitmap;
/* Bitmap for button state. 1 - down, 0 - up */
	uint16_t buttons_state_bitmap;
};

/* Mouse buttons, supported by USF */
+37 −48
Original line number Diff line number Diff line
/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.
/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -26,8 +26,8 @@
#include "usfcdev.h"

/* The driver version*/
#define DRV_VERSION "1.5.1"
#define USF_VERSION_ID 0x0151
#define DRV_VERSION "1.6.1"
#define USF_VERSION_ID 0x0161

/* Standard timeout in the asynchronous ops */
#define USF_TIMEOUT_JIFFIES (1*HZ) /* 1 sec */
@@ -117,14 +117,12 @@ struct usf_type {
	uint16_t event_types;
	/*  The input devices are "input" module registered clients */
	struct input_dev *input_ifs[USF_MAX_EVENT_IND];
	/*  The event source */
	int event_src;
	/* Bitmap of types of events, conflicting to USF's ones */
	uint16_t conflicting_event_types;
	/* Bitmap of types of events from devs, conflicting with USF */
	uint16_t conflicting_event_filters;
	/* The requested side buttons bitmap */
	uint16_t req_side_buttons_bitmap;
	/* The requested buttons bitmap */
	uint16_t req_buttons_bitmap;
};

struct usf_input_dev_type {
@@ -147,17 +145,22 @@ struct usf_input_dev_type {
/* The MAX number of the supported devices */
#define MAX_DEVS_NUMBER	1

/* The opened devices container */
static const int s_event_src_map[] = {
	BTN_TOOL_PEN, /* US_INPUT_SRC_PEN*/
	0,            /* US_INPUT_SRC_FINGER */
	0,            /* US_INPUT_SRC_UNDEF */
};
/*
 * code for a special button that is used to show/hide a
 * hovering cursor in the input framework. Must be in
 * sync with the button code definition in the framework
 * (EventHub.h)
 */
#define BTN_USF_HOVERING_CURSOR         0x230

/* Supported buttons container */
static const int s_button_map[] = {
	BTN_STYLUS,
	BTN_STYLUS2
	BTN_STYLUS2,
	BTN_TOOL_PEN,
	BTN_TOOL_RUBBER,
	BTN_TOOL_FINGER,
	BTN_USF_HOVERING_CURSOR
};

/* The opened devices container */
@@ -191,31 +194,32 @@ static int prepare_tsc_input_device(uint16_t ind,
				const char *name)
{
	int i = 0;
	int num_side_buttons = min(ARRAY_SIZE(s_button_map),
		sizeof(input_info->req_side_buttons_bitmap) *

	int num_buttons = min(ARRAY_SIZE(s_button_map),
		sizeof(input_info->req_buttons_bitmap) *
		BITS_IN_BYTE);
	uint16_t max_side_button_bitmap = ((1 << ARRAY_SIZE(s_button_map)) - 1);
	uint16_t max_buttons_bitmap = ((1 << ARRAY_SIZE(s_button_map)) - 1);

	struct input_dev *in_dev = allocate_dev(ind, name);
	if (in_dev == NULL)
		return -ENOMEM;

	if (input_info->req_side_buttons_bitmap > max_side_button_bitmap) {
		pr_err("%s: Requested side buttons[%d] exceeds max side buttons available[%d]\n",
	if (input_info->req_buttons_bitmap > max_buttons_bitmap) {
		pr_err("%s: Requested buttons[%d] exceeds max buttons available[%d]\n",
		__func__,
		input_info->req_side_buttons_bitmap,
		max_side_button_bitmap);
		input_info->req_buttons_bitmap,
		max_buttons_bitmap);
		return -EINVAL;
	}

	usf_info->input_ifs[ind] = in_dev;
	usf_info->req_side_buttons_bitmap =
		input_info->req_side_buttons_bitmap;
	usf_info->req_buttons_bitmap =
		input_info->req_buttons_bitmap;
	in_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
	in_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);


	for (i = 0; i < num_side_buttons; i++)
		if (input_info->req_side_buttons_bitmap & (1 << i))
	for (i = 0; i < num_buttons; i++)
		if (input_info->req_buttons_bitmap & (1 << i))
			in_dev->keybit[BIT_WORD(s_button_map[i])] |=
			BIT_MASK(s_button_map[i]);

@@ -296,8 +300,8 @@ static void notify_tsc_event(struct usf_type *usf_info,

{
	int i = 0;
	int num_side_buttons = min(ARRAY_SIZE(s_button_map),
		sizeof(usf_info->req_side_buttons_bitmap) *
	int num_buttons = min(ARRAY_SIZE(s_button_map),
		sizeof(usf_info->req_buttons_bitmap) *
		BITS_IN_BYTE);

	struct input_dev *input_if = usf_info->input_ifs[if_ind];
@@ -313,19 +317,16 @@ static void notify_tsc_event(struct usf_type *usf_info,
	input_report_abs(input_if, ABS_PRESSURE, pe->pressure);
	input_report_key(input_if, BTN_TOUCH, !!(pe->pressure));

	for (i = 0; i < num_side_buttons; i++) {
	for (i = 0; i < num_buttons; i++) {
		uint16_t mask = (1 << i),
		btn_state = !!(pe->side_buttons_state_bitmap & mask);
		if (usf_info->req_side_buttons_bitmap & mask)
		btn_state = !!(pe->buttons_state_bitmap & mask);
		if (usf_info->req_buttons_bitmap & mask)
			input_report_key(input_if, s_button_map[i], btn_state);
	}

	if (usf_info->event_src)
		input_report_key(input_if, usf_info->event_src, 1);

	input_sync(input_if);

	pr_debug("%s: TSC event: xyz[%d;%d;%d], incl[%d;%d], pressure[%d], side_buttons[%d]\n",
	pr_debug("%s: TSC event: xyz[%d;%d;%d], incl[%d;%d], pressure[%d], buttons[%d]\n",
		 __func__,
		 pe->coordinates[X_IND],
		 pe->coordinates[Y_IND],
@@ -333,7 +334,7 @@ static void notify_tsc_event(struct usf_type *usf_info,
		 pe->inclinations[X_IND],
		 pe->inclinations[Y_IND],
		 pe->pressure,
		 pe->side_buttons_state_bitmap);
		 pe->buttons_state_bitmap);
}

static void notify_mouse_event(struct usf_type *usf_info,
@@ -662,12 +663,6 @@ static int register_input_device(struct usf_type *usf_info,
		return -EINVAL;
	}

	if (input_info->event_src < ARRAY_SIZE(s_event_src_map))
		usf_info->event_src =
			s_event_src_map[input_info->event_src];
	else
		usf_info->event_src = 0;

	for (ind = 0; ind < USF_MAX_EVENT_IND; ++ind) {
		if (usf_info->input_ifs[ind] != NULL) {
			pr_err("%s: input_if[%d] is already allocated\n",
@@ -685,12 +680,6 @@ static int register_input_device(struct usf_type *usf_info,
			if (rc)
				return rc;


			if (usf_info->event_src)
				input_set_capability(usf_info->input_ifs[ind],
						     EV_KEY,
						     usf_info->event_src);

			rc = input_register_device(usf_info->input_ifs[ind]);
			if (rc) {
				pr_err("%s: input_reg_dev() failed; rc=%d\n",