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

Commit 630ccdd0 authored by Amy Maloche's avatar Amy Maloche
Browse files

input: synaptics_i2c_rmi4: Read display resolution from dt



Read display resolution from platform data in order
to properly use all virtual key implementations.

Change-Id: Ic0a13d6a8166379f08c5bfb49d5ea47ac22b3229
Signed-off-by: default avatarAmy Maloche <amaloche@codeaurora.org>
parent bdde824c
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -18,8 +18,10 @@ Optional property:
 - synaptics,button-map		: virtual key code mappings to be used
 - synaptics,x-flip		: modify orientation of the x axis
 - synaptics,y-flip		: modify orientation of the y axis
 - synaptics,panel-x		: panel x dimension
 - synaptics,panel-y		: panel y dimension
 - synaptics,panel-coords	: touch panel min x, min y, max x and
					max y resolution
 - synaptics,display-coords	: display min x, min y, max x and
					max y resolution
 - synaptics,reset-delay	: reset delay for controller (ms), default 100
 - synaptics,fw-image-name	: name of firmware .img file in /etc/firmware
 - synaptics,power-down		: fully power down regulators in suspend
+79 −20
Original line number Diff line number Diff line
@@ -96,6 +96,8 @@ enum device_status {
#define F12_FINGERS_TO_SUPPORT 10
#define MAX_F11_TOUCH_WIDTH 15

#define RMI4_COORDS_ARR_SIZE 4

static int synaptics_rmi4_i2c_read(struct synaptics_rmi4_data *rmi4_data,
		unsigned short addr, unsigned char *data,
		unsigned short length);
@@ -1306,6 +1308,50 @@ static irqreturn_t synaptics_rmi4_irq(int irq, void *data)
}

#ifdef CONFIG_OF
static int synaptics_rmi4_get_dt_coords(struct device *dev, char *name,
				struct synaptics_rmi4_platform_data *pdata)
{
	u32 coords[RMI4_COORDS_ARR_SIZE];
	struct property *prop;
	struct device_node *np = dev->of_node;
	int coords_size, rc;

	prop = of_find_property(np, name, NULL);
	if (!prop)
		return -EINVAL;
	if (!prop->value)
		return -ENODATA;

	coords_size = prop->length / sizeof(u32);
	if (coords_size != RMI4_COORDS_ARR_SIZE) {
		dev_err(dev, "invalid %s\n", name);
		return -EINVAL;
	}

	rc = of_property_read_u32_array(np, name, coords, coords_size);
	if (rc && (rc != -EINVAL)) {
		dev_err(dev, "Unable to read %s\n", name);
		return rc;
	}

	if (strcmp(name, "synaptics,panel-coords") == 0) {
		pdata->panel_minx = coords[0];
		pdata->panel_miny = coords[1];
		pdata->panel_maxx = coords[2];
		pdata->panel_maxy = coords[3];
	} else if (strcmp(name, "synaptics,display-coords") == 0) {
		pdata->disp_minx = coords[0];
		pdata->disp_miny = coords[1];
		pdata->disp_maxx = coords[2];
		pdata->disp_maxy = coords[3];
	} else {
		dev_err(dev, "unsupported property %s\n", name);
		return -EINVAL;
	}

	return 0;
}

static int synaptics_rmi4_parse_dt(struct device *dev,
				struct synaptics_rmi4_platform_data *rmi4_pdata)
{
@@ -1326,21 +1372,15 @@ static int synaptics_rmi4_parse_dt(struct device *dev,
	rmi4_pdata->do_lockdown = of_property_read_bool(np,
			"synaptics,do-lockdown");

	rc = of_property_read_u32(np, "synaptics,panel-x", &temp_val);
	if (rc && (rc != -EINVAL)) {
		dev_err(dev, "Unable to read panel X dimension\n");
	rc = synaptics_rmi4_get_dt_coords(dev, "synaptics,display-coords",
				rmi4_pdata);
	if (rc && (rc != -EINVAL))
		return rc;
	} else {
		rmi4_pdata->panel_x = temp_val;
	}

	rc = of_property_read_u32(np, "synaptics,panel-y", &temp_val);
	if (rc && (rc != -EINVAL)) {
		dev_err(dev, "Unable to read panel Y dimension\n");
	rc = synaptics_rmi4_get_dt_coords(dev, "synaptics,panel-coords",
				rmi4_pdata);
	if (rc && (rc != -EINVAL))
		return rc;
	} else {
		rmi4_pdata->panel_y = temp_val;
	}

	rmi4_pdata->reset_delay = RESET_DELAY;
	rc = of_property_read_u32(np, "synaptics,reset-delay", &temp_val);
@@ -1804,11 +1844,10 @@ static int synaptics_rmi4_capacitance_button_map(
	const struct synaptics_rmi4_platform_data *pdata = rmi4_data->board;

	if (!pdata->capacitance_button_map) {
		dev_err(&rmi4_data->i2c_client->dev,
				"%s: capacitance_button_map is" \
				"NULL in board file\n",
		dev_info(&rmi4_data->i2c_client->dev,
				"%s: capacitance_button_map not in use\n",
				__func__);
		return -ENODEV;
		return 0;
	} else if (!pdata->capacitance_button_map->map) {
		dev_err(&rmi4_data->i2c_client->dev,
				"%s: Button map is missing in board file\n",
@@ -2761,12 +2800,32 @@ static int synaptics_rmi4_probe(struct i2c_client *client,
		goto err_free_gpios;
	}

	if (rmi4_data->board->disp_maxx)
		rmi4_data->disp_maxx = rmi4_data->board->disp_maxx;
	else
		rmi4_data->disp_maxx = rmi4_data->sensor_max_x;

	if (rmi4_data->board->disp_maxy)
		rmi4_data->disp_maxy = rmi4_data->board->disp_maxy;
	else
		rmi4_data->disp_maxy = rmi4_data->sensor_max_y;

	if (rmi4_data->board->disp_minx)
		rmi4_data->disp_minx = rmi4_data->board->disp_minx;
	else
		rmi4_data->disp_minx = 0;

	if (rmi4_data->board->disp_miny)
		rmi4_data->disp_miny = rmi4_data->board->disp_miny;
	else
		rmi4_data->disp_miny = 0;

	input_set_abs_params(rmi4_data->input_dev,
			ABS_MT_POSITION_X, 0,
			rmi4_data->sensor_max_x, 0, 0);
			ABS_MT_POSITION_X, rmi4_data->disp_minx,
			rmi4_data->disp_maxx, 0, 0);
	input_set_abs_params(rmi4_data->input_dev,
			ABS_MT_POSITION_Y, 0,
			rmi4_data->sensor_max_y, 0, 0);
			ABS_MT_POSITION_Y, rmi4_data->disp_miny,
			rmi4_data->disp_maxy, 0, 0);
	input_set_abs_params(rmi4_data->input_dev,
			ABS_PRESSURE, 0, 255, 0, 0);
#ifdef REPORT_2D_W
+8 −0
Original line number Diff line number Diff line
@@ -186,6 +186,10 @@ struct synaptics_rmi4_device_info {
 * @irq: attention interrupt
 * @sensor_max_x: sensor maximum x value
 * @sensor_max_y: sensor maximum y value
 * @disp_maxx: max x value of display
 * @disp_maxy: max y value of display
 * @disp_minx: min x value of display
 * @disp_miny: min y value of display
 * @irq_enabled: flag for indicating interrupt enable status
 * @touch_stopped: flag to stop interrupt thread processing
 * @fingers_on_2d: flag to indicate presence of fingers in 2d area
@@ -230,6 +234,10 @@ struct synaptics_rmi4_data {
	int irq;
	int sensor_max_x;
	int sensor_max_y;
	int disp_maxx;
	int disp_maxy;
	int disp_minx;
	int disp_miny;
	bool irq_enabled;
	bool touch_stopped;
	bool fingers_on_2d;
+16 −2
Original line number Diff line number Diff line
@@ -43,6 +43,14 @@ struct synaptics_rmi4_capacitance_button_map {
 * @reset_gpio: reset gpio
 * @panel_x: panel maximum values on the x
 * @panel_y: panel maximum values on the y
 * @disp_maxx: display panel maximum values on the x
 * @disp_maxy: display panel maximum values on the y
 * @disp_minx: display panel minimum values on the x
 * @disp_miny: display panel minimum values on the y
 * @panel_maxx: touch panel maximum values on the x
 * @panel_maxy: touch panel maximum values on the y
 * @panel_minx: touch panel minimum values on the x
 * @panel_miny: touch panel minimum values on the y
 * @reset_delay: reset delay
 * @gpio_config: pointer to gpio configuration function
 * @capacitance_button_map: pointer to 0d button map
@@ -58,8 +66,14 @@ struct synaptics_rmi4_platform_data {
	u32 irq_flags;
	u32 reset_flags;
	unsigned reset_gpio;
	unsigned panel_x;
	unsigned panel_y;
	unsigned panel_minx;
	unsigned panel_miny;
	unsigned panel_maxx;
	unsigned panel_maxy;
	unsigned disp_minx;
	unsigned disp_miny;
	unsigned disp_maxx;
	unsigned disp_maxy;
	unsigned reset_delay;
	const char *fw_image_name;
	int (*gpio_config)(unsigned gpio, bool configure);