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

Commit 4ed1e15c authored by Shantanu Jain's avatar Shantanu Jain Committed by Sudhakar Manapati
Browse files

input: synaptics_i2c_rmi4: add support to change X-Y max coordinates



Add support to modify the Maximum_X_Position and
Maximum_Y_position in F11 and F12 control registers.
Re-program the maximum coordinates of touch controller
if the firmware resolution mismatches the required
touch panel resolution.

This patch is propagated from msm-3.10 kernel
(commit: a5666b220ad77098056041af94fd72087ce9f402
input: synaptics_i2c_rmi4: add support to change X-Y max coordinates)

Change-Id: I6256ff861f7830f5604f8be3552266edb5aa07ba
Signed-off-by: default avatarShantanu Jain <shjain@codeaurora.org>
parent b3fc7055
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -23,6 +23,8 @@ Optional property:
 - synaptics,i2c-pull-up	: specify to indicate pull up is needed
 - synaptics,disable-gpios	: specify to disable gpios in suspend (power saving)
 - synaptics,button-map		: virtual key code mappings to be used
 - synaptics,modify-reso	: specify to modify X-Y Maximum coordinates from driver.
				This is used only if the panel-coordinates are defined.
 - synaptics,x-flip		: modify orientation of the x axis
 - synaptics,y-flip		: modify orientation of the y axis
 - synaptics,panel-coords	: touch panel min x, min y, max x and
@@ -80,6 +82,7 @@ Example:
			synaptics,reset-gpio = <&msmgpio 16 0x00>;
			synaptics,irq-gpio = <&msmgpio 17 0x00>;
			synaptics,i2c-pull-up;
			synaptics,modify-reso;
			synaptics,detect-device;
			synaptics,device1 {
				synaptics,package-id = <3202>;
+137 −8
Original line number Diff line number Diff line
@@ -103,6 +103,11 @@ enum device_status {

#define RMI4_COORDS_ARR_SIZE 4

#define F11_MAX_X		4096
#define F11_MAX_Y		4096
#define F12_MAX_X		65536
#define F12_MAX_Y		65536

static int synaptics_rmi4_i2c_read(struct synaptics_rmi4_data *rmi4_data,
		unsigned short addr, unsigned char *data,
		unsigned short length);
@@ -1440,6 +1445,16 @@ static int synaptics_rmi4_get_dt_coords(struct device *dev, char *name,
		pdata->panel_miny = coords[1];
		pdata->panel_maxx = coords[2];
		pdata->panel_maxy = coords[3];

		if (pdata->panel_maxx == 0 || pdata->panel_minx > 0)
			rc = -EINVAL;
		else if (pdata->panel_maxy == 0 || pdata->panel_miny > 0)
			rc = -EINVAL;

		if (rc) {
			dev_err(dev, "Invalid panel resolution %d\n", rc);
			return rc;
		}
	} else if (strcmp(name, "synaptics,display-coords") == 0) {
		pdata->disp_minx = coords[0];
		pdata->disp_miny = coords[1];
@@ -1515,6 +1530,8 @@ static int synaptics_rmi4_parse_dt(struct device *dev,
			"synaptics,power-down");
	rmi4_pdata->disable_gpios = of_property_read_bool(np,
			"synaptics,disable-gpios");
	rmi4_pdata->modify_reso = of_property_read_bool(np,
			"synaptics,modify-reso");
	rmi4_pdata->x_flip = of_property_read_bool(np, "synaptics,x-flip");
	rmi4_pdata->y_flip = of_property_read_bool(np, "synaptics,y-flip");
	rmi4_pdata->do_lockdown = of_property_read_bool(np,
@@ -1706,11 +1723,64 @@ static int synaptics_rmi4_f11_init(struct synaptics_rmi4_data *rmi4_data,
	if (retval < 0)
		return retval;

	/* Maximum x and y */
	/* Maximum x */
	rmi4_data->sensor_max_x = ((control[6] & MASK_8BIT) << 0) |
		((control[7] & MASK_4BIT) << 8);

	if (rmi4_data->board->modify_reso) {
		if (rmi4_data->board->panel_maxx) {
			if (rmi4_data->board->panel_maxx >= F11_MAX_X) {
				dev_err(&rmi4_data->i2c_client->dev,
					"F11 max_x value out of bound.");
				return -EINVAL;
			}
			if (rmi4_data->sensor_max_x !=
				rmi4_data->board->panel_maxx) {
				rmi4_data->sensor_max_x =
					rmi4_data->board->panel_maxx;
				control[6] = rmi4_data->board->panel_maxx
					& MASK_8BIT;
				control[7] = (rmi4_data->board->panel_maxx >> 8)
					& MASK_4BIT;
				retval = synaptics_rmi4_i2c_write(rmi4_data,
					fhandler->full_addr.ctrl_base,
					control,
					sizeof(control));
				if (retval < 0)
					return retval;
			}
		}
	}

	/* Maximum y */
	rmi4_data->sensor_max_y = ((control[8] & MASK_8BIT) << 0) |
		((control[9] & MASK_4BIT) << 8);

	if (rmi4_data->board->modify_reso) {
		if (rmi4_data->board->panel_maxy) {
			if (rmi4_data->board->panel_maxy >= F11_MAX_Y) {
				dev_err(&rmi4_data->i2c_client->dev,
					"F11 max_y value out of bound.");
				return -EINVAL;
			}
			if (rmi4_data->sensor_max_y !=
				rmi4_data->board->panel_maxy) {
				rmi4_data->sensor_max_y =
					rmi4_data->board->panel_maxy;
				control[8] = rmi4_data->board->panel_maxy
					& MASK_8BIT;
				control[9] = (rmi4_data->board->panel_maxy >> 8)
					& MASK_4BIT;
				retval = synaptics_rmi4_i2c_write(rmi4_data,
					fhandler->full_addr.ctrl_base,
					control,
					sizeof(control));
				if (retval < 0)
					return retval;
			}
		}
	}

	dev_dbg(&rmi4_data->i2c_client->dev,
			"%s: Function %02x max x = %d max y = %d\n",
			__func__, fhandler->fn_number,
@@ -1907,13 +1977,72 @@ static int synaptics_rmi4_f12_init(struct synaptics_rmi4_data *rmi4_data,
	if (retval < 0)
		return retval;

	/* Maximum x and y */
	/* Maximum x */
	rmi4_data->sensor_max_x =
		((unsigned short)ctrl_8.max_x_coord_lsb << 0) |
		((unsigned short)ctrl_8.max_x_coord_msb << 8);

	if (rmi4_data->board->modify_reso) {
		if (rmi4_data->board->panel_maxx) {
			if (rmi4_data->board->panel_maxx >= F12_MAX_X) {
				dev_err(&rmi4_data->i2c_client->dev,
					"F12 max_x value out of bound.");
				return -EINVAL;
			}
			if (rmi4_data->sensor_max_x !=
					rmi4_data->board->panel_maxx) {
				rmi4_data->sensor_max_x =
					rmi4_data->board->panel_maxx;
				ctrl_8.max_x_coord_lsb = (unsigned char)
					(rmi4_data->board->panel_maxx
					& MASK_8BIT);
				ctrl_8.max_x_coord_msb = (unsigned char)
					((rmi4_data->board->panel_maxx >> 8)
					& MASK_8BIT);
				retval = synaptics_rmi4_i2c_write(rmi4_data,
					fhandler->full_addr.ctrl_base
						+ ctrl_8_offset,
					ctrl_8.data,
					sizeof(ctrl_8.data));
				if (retval < 0)
					return retval;
			}
		}
	}

	/* Maximum y */
	rmi4_data->sensor_max_y =
		((unsigned short)ctrl_8.max_y_coord_lsb << 0) |
		((unsigned short)ctrl_8.max_y_coord_msb << 8);

	if (rmi4_data->board->modify_reso) {
		if (rmi4_data->board->panel_maxy) {
			if (rmi4_data->board->panel_maxy >= F12_MAX_Y) {
				dev_err(&rmi4_data->i2c_client->dev,
					"F12 max_y value out of bound.");
					return -EINVAL;
			}
			if (rmi4_data->sensor_max_y !=
				rmi4_data->board->panel_maxy) {
				rmi4_data->sensor_max_y =
					rmi4_data->board->panel_maxy;
				ctrl_8.max_y_coord_lsb = (unsigned char)
					(rmi4_data->board->panel_maxy
					& MASK_8BIT);
				ctrl_8.max_y_coord_msb = (unsigned char)
					((rmi4_data->board->panel_maxy >> 8)
					& MASK_8BIT);
				retval = synaptics_rmi4_i2c_write(rmi4_data,
					fhandler->full_addr.ctrl_base
						+ ctrl_8_offset,
					ctrl_8.data,
					sizeof(ctrl_8.data));
				if (retval < 0)
					return retval;
			}
		}
	}

	dev_dbg(&rmi4_data->i2c_client->dev,
			"%s: Function %02x max x = %d max y = %d\n",
			__func__, fhandler->fn_number,
+1 −0
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ struct synaptics_rmi4_platform_data {
	bool disable_gpios;
	bool do_lockdown;
	bool detect_device;
	bool modify_reso;
	unsigned irq_gpio;
	u32 irq_flags;
	u32 reset_flags;