Input: goodix - Support dynamic reconfiguration
Subsystems (4)
cover Input: goodix - Support dynamic reconfiguration
Goodix touchscreen controller supports the ability to update its settings at runtime. Currently, the driver supports this by loading a firmware and reconfiguring the panel. However, this may lead to a large quantity of firmwares being created and managed. This is a hassle since likely a preexisting firmware or even the default configuration is good enough and only a couple of changes need to be made.
This patchset adds the capability to dynamically alter the firmware utilizing several new DT properties.
These new properties will allow a user to specify the touchscreen resolution and also allow x and y coordinates to be interchanged. All of this configuration changes are done dynamically by the driver and can work using the default touchscreen controller configuration or even on top of a firmware that was loaded.
Franklin S Cooper Jr (4):
Input: goodix - Restructure cfg checksum function
Input: goodix - Allow tweaking of configuration file dynamically
Input: goodix - Tweak configuration to use passed in touchscreen
resolution
Input: goodix - Support interchanging x and y coordinates in hardware
.../bindings/input/touchscreen/goodix.txt | 4 + drivers/input/touchscreen/goodix.c | 109 +++++++++++++++++---- 2 files changed, 96 insertions(+), 17 deletions(-)
Signature · 6 lines
2.10.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 1/4 Input: goodix - Restructure cfg checksum function
Split generation of checksum into is own function. Currently it is used only to determine if the checksum for the user provided configuration file is valid or not. However, support to dynamically alter the configuration file will be supported and needs a way to calculate the updated file's checksum. Therefore, by splitting calculating checksum into its own function the code can be reused.
--- drivers/input/touchscreen/goodix.c | 42 +++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 16 deletions(-)
drivers/input/touchscreen/goodix.c +26 -16
@@ -305,35 +305,45 @@ static int goodix_request_irq(struct goodix_ts_data *ts) ts->irq_flags, ts->client->name, ts); } +static int goodix_calculate_checksum (size_t size,const u8 *data) +{ +int i, raw_cfg_len; +u8 check_sum =0 ; + + raw_cfg_len = size -2 ; +for (i =0 ; i < raw_cfg_len; i++) + check_sum += data[i]; + check_sum = (~check_sum) +1 ; + +return check_sum; +}/** * goodix_check_cfg - Checks if config fw is valid * * @ts: goodix_ts_data pointer * @cfg: firmware config data */ -static int goodix_check_cfg (struct goodix_ts_data *ts, -const struct firmware *cfg) +static int goodix_check_cfg (struct goodix_ts_data *ts,size_t size, +const u8 *data) { -int i, raw_cfg_len; +int raw_cfg_len;u8 check_sum =0 ; -if (cfg->size >GOODIX_CONFIG_MAX_LENGTH ) { +if (size >GOODIX_CONFIG_MAX_LENGTH ) {dev_err (&ts->client->dev,"The length of the config fw is not correct" );return -EINVAL ; } - raw_cfg_len = cfg->size -2 ; -for (i =0 ; i < raw_cfg_len; i++) - check_sum += cfg->data[i]; - check_sum = (~check_sum) +1 ; -if (check_sum != cfg->data[raw_cfg_len]) { + raw_cfg_len = size -2 ; + check_sum =goodix_calculate_checksum (size, data); +if (check_sum != data[raw_cfg_len]) {dev_err (&ts->client->dev,"The checksum of the config fw is not correct" );return -EINVAL ; } -if (cfg->data[raw_cfg_len +1 ] !=1 ) { +if (data[raw_cfg_len +1 ] !=1 ) {dev_err (&ts->client->dev,"Config fw must have Config_Fresh register set" );return -EINVAL ;
@@ -348,17 +358,17 @@ static int goodix_check_cfg(struct goodix_ts_data *ts,* @ts: goodix_ts_data pointer * @cfg: config firmware to write to device */ -static int goodix_send_cfg (struct goodix_ts_data *ts, -const struct firmware *cfg) +static int goodix_send_cfg (struct goodix_ts_data *ts,size_t size, +const u8 *data) {int error; - error =goodix_check_cfg (ts, cfg); + error =goodix_check_cfg (ts, size, data);if (error)return error; - error =goodix_i2c_write (ts->client,GOODIX_REG_CONFIG_DATA , cfg->data, - cfg->size); + error =goodix_i2c_write (ts->client,GOODIX_REG_CONFIG_DATA , data, + size);if (error) {dev_err (&ts->client->dev,"Failed to write config data: %d" , error);
@@ -670,7 +680,7 @@ static void goodix_config_cb(const struct firmware *cfg, void *ctx)if (cfg) {/* send device configuration to the firmware */ - error =goodix_send_cfg (ts, cfg); + error =goodix_send_cfg (ts, cfg->size, cfg->data);if (error) goto err_release_cfg; }
Signature · 1 line
2.10.0
PATCH 2/4 Input: goodix - Allow tweaking of configuration file dynamically
In reply to Franklin S Cooper JrSome goodix touchscreen controllers don't have the correct configuration firmware for the display panel it is attached to. Therefore, settings such as touchscreen x and y size may need to be passed in via DT and have the panel reprogrammed for the updated touchscreen resolution.
This patchset adds support for reading the current configuration firmware on the panel and allowing it to be modified and rewritten back to the device.
Currently this function is unused but later patches will make use of it.
--- drivers/input/touchscreen/goodix.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
drivers/input/touchscreen/goodix.c +28 -0
@@ -478,6 +478,34 @@ static int goodix_get_gpio_config(struct goodix_ts_data *ts)return 0 ; } +static void goodix_tweak_config (struct goodix_ts_data *ts) +{ +u8 config[GOODIX_CONFIG_MAX_LENGTH ]; +int error; +int raw_cfg_len; +u8 check_sum =0 ; + + raw_cfg_len = ts->cfg_len -2 ; + + error =goodix_i2c_read (ts->client,GOODIX_REG_CONFIG_DATA , + config, ts->cfg_len); +if (error) { +dev_warn (&ts->client->dev, +"Error reading config (%d), avoid tweaking config\n" , + error); +return ; + } + + check_sum =goodix_calculate_checksum (ts->cfg_len, config); + + config[raw_cfg_len] = check_sum; + config[raw_cfg_len +1 ] =1 ; + + error =goodix_send_cfg (ts, ts->cfg_len, config); +if (error) +dev_warn (&ts->client->dev, +"Error writing config (%d)\n" , error); +}/** * goodix_read_config - Read the embedded configuration of the panel *
Signature · 1 line
2.10.0
PATCH 3/4 Input: goodix - Tweak configuration to use passed in touchscreen resolution
In reply to Franklin S Cooper JrSome goodix touchscreen controllers aren't programed properly to match the display panel it is used on. Although the defaults may largely work it is also likely that the screen resolution will be incorrect. Therefore, add support to allow via DT for the touchscreen resolution to be set and reprogram the controller to use this updated resolution.
--- .../bindings/input/touchscreen/goodix.txt | 2 ++ drivers/input/touchscreen/goodix.c | 26 +++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/input/touchscreen/goodix.txt +2 -0
@@ -19,6 +19,8 @@ Optional properties: interrupt gpio pin as output to reset the device. - reset-gpios : GPIO pin used for reset + - touchscreen-size-x : horizontal resolution of touchscreen (in pixels) + - touchscreen-size-y : vertical resolution of touchscreen (in pixels) - touchscreen-inverted-x : X axis is inverted (boolean) - touchscreen-inverted-y : Y axis is inverted (boolean) - touchscreen-swapped-x-y : X and Y axis are swapped (boolean)
drivers/input/touchscreen/goodix.c +25 -1
@@ -496,6 +496,10 @@ static void goodix_tweak_config(struct goodix_ts_data *ts)return ; } +/* Setting X and Y Resolution */ +put_unaligned_le16 (ts->abs_x_max, &config[RESOLUTION_LOC ]); +put_unaligned_le16 (ts->abs_y_max, &config[RESOLUTION_LOC +2 ]); + check_sum =goodix_calculate_checksum (ts->cfg_len, config); config[raw_cfg_len] = check_sum;
@@ -669,6 +673,8 @@ static int goodix_request_input_dev(struct goodix_ts_data *ts)static int goodix_configure_dev (struct goodix_ts_data *ts) {int error; +bool alter_config = false; +u32 max_x, max_y; ts->swapped_x_y =device_property_read_bool (&ts->client->dev,"touchscreen-swapped-x-y" );
@@ -676,9 +682,27 @@ static int goodix_configure_dev(struct goodix_ts_data *ts) "touchscreen-inverted-x"); ts->inverted_y =device_property_read_bool (&ts->client->dev,"touchscreen-inverted-y" ); -goodix_read_config (ts); +if (device_property_present (&ts->client->dev,"touchscreen-size-x" ) && +device_property_present (&ts->client->dev,"touchscreen-size-y" )) { + +device_property_read_u32 (&ts->client->dev,"touchscreen-size-x" , + &max_x); + +device_property_read_u32 (&ts->client->dev,"touchscreen-size-y" , + &max_y); + +if (max_x >0 && max_y >0 ) { + ts->abs_x_max = max_x; + ts->abs_y_max = max_y; + alter_config = true; + } + } + +if (alter_config) +goodix_tweak_config (ts); + error =goodix_request_input_dev (ts);if (error)return error;
Signature · 1 line
2.10.0
PATCH 4/4 Input: goodix - Support interchanging x and y coordinates in hardware
In reply to Franklin S Cooper JrOn systems with a fixed display/touchscreen orientation it is important to pass in the "correct" x and y coordinates based on the orientation. Currently, to support landscape and portrait touchscreen-swapped-x-y simply does the following:
Assuming touchscreen is as follows:
X: 1280 Y:800 programmed in touchscreen controller and also interchange bit cleared. Assuming ts mounted in portrait mode.
1280 (X)
------
| | | | 800 (Y) | | | |
------
800 (Y)
------
| | | | 1280 (X) | | | |
------
However, the above isn't really what we want especially in distros that assumes a fixed orientation. In this case what we really want is to interchange the x and y coordinates so the Y coordinate can return a max value of 1280 and X can return a max value of 800.
800 (X)
------
| | | | 1280 (Y) | | | |
------
Since the driver is limited to the value reported by the touchscreen controller this issue can't be fixed purely in the driver. Therefore, add a new DT property that supports interchanging X and Y coordinates internally within the hardware.
--- .../devicetree/bindings/input/touchscreen/goodix.txt | 2 ++ drivers/input/touchscreen/goodix.c | 13 +++++++++++++ 2 files changed, 15 insertions(+)
Documentation/devicetree/bindings/input/touchscreen/goodix.txt +2 -0
@@ -25,6 +25,8 @@ Optional properties: - touchscreen-inverted-y : Y axis is inverted (boolean) - touchscreen-swapped-x-y : X and Y axis are swapped (boolean) (swapping is done after inverting the axis) + - touchscreen-inter-x-y : X and Y maximum values programmed in the device + are interchanged internally in hardware. (boolean) Example:
drivers/input/touchscreen/goodix.c +13 -0
@@ -39,6 +39,7 @@ struct goodix_ts_data {bool swapped_x_y;bool inverted_x;bool inverted_y; +bool interchange_x_y;unsigned int max_touch_num;unsigned int int_trigger_type;int cfg_len;
@@ -76,6 +77,9 @@ struct goodix_ts_data {#define MAX_CONTACTS_LOC 5#define TRIGGER_LOC 6 +/* Register Bits */ +#define XY_COORD_INTER 3 +static const unsigned long goodix_irq_flags[] = {IRQ_TYPE_EDGE_RISING ,IRQ_TYPE_EDGE_FALLING ,
@@ -500,6 +504,10 @@ static void goodix_tweak_config(struct goodix_ts_data *ts)put_unaligned_le16 (ts->abs_x_max, &config[RESOLUTION_LOC ]);put_unaligned_le16 (ts->abs_y_max, &config[RESOLUTION_LOC +2 ]); +if (ts->interchange_x_y) + config[TRIGGER_LOC ] = config[TRIGGER_LOC ] | + (1 <<XY_COORD_INTER ); + check_sum =goodix_calculate_checksum (ts->cfg_len, config); config[raw_cfg_len] = check_sum;
@@ -700,6 +708,11 @@ static int goodix_configure_dev(struct goodix_ts_data *ts) } } + ts->interchange_x_y =device_property_read_bool (&ts->client->dev, +"touchscreen-inter-x-y" ); +if (ts->interchange_x_y) + alter_config = true; +if (alter_config)goodix_tweak_config (ts);
Signature · 6 lines
2.10.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 3/4] Input: goodix - Tweak configuration to use passed in touchscreen resolution
In reply to Franklin S Cooper JrQuoted 9 lines · Franklin S Cooper Jr
Some goodix touchscreen controllers aren't programed properly to match the display panel it is used on. Although the defaults may largely work it is also likely that the screen resolution will be incorrect. Therefore, add support to allow via DT for the touchscreen resolution to be set and reprogram the controller to use this updated resolution.
Signed-off-by Franklin S Cooper Jr <[email protected]>--- .../bindings/input/touchscreen/goodix.txt | 2 ++
Quoted 2 lines
drivers/input/touchscreen/goodix.c | 26 +++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-)
Rob Herring
maintainerRe: [PATCH 4/4] Input: goodix - Support interchanging x and y coordinates in hardware
In reply to Franklin S Cooper JrQuoted 36 lines · Franklin S Cooper Jr
On systems with a fixed display/touchscreen orientation it is important to pass in the "correct" x and y coordinates based on the orientation. Currently, to support landscape and portrait touchscreen-swapped-x-y simply does the following:
Assuming touchscreen is as follows:
X: 1280 Y:800 programmed in touchscreen controller and also interchange bit cleared. Assuming ts mounted in portrait mode.1280 (X)
------| | | | 800 (Y) | | | |------
800 (Y)
------| | | | 1280 (X) | | | |------
However, the above isn't really what we want especially in distros that assumes a fixed orientation. In this case what we really want is to interchange the x and y coordinates so the Y coordinate can return a max value of 1280 and X can return a max value of 800.
800 (X)
------| | | | 1280 (Y) | | | |
Quoted 6 lines
------
Since the driver is limited to the value reported by the touchscreen controller this issue can't be fixed purely in the driver. Therefore, add a new DT property that supports interchanging X and Y coordinates internally within the hardware.
I'm not sure I follow why existing properties don't cover this.
Quoted 12 lines
Signed-off-by Franklin S Cooper Jr <[email protected]>--- .../devicetree/bindings/input/touchscreen/goodix.txt | 2 ++ drivers/input/touchscreen/goodix.c | 13 +++++++++++++ 2 files changed, 15 insertions(+)Documentation/devicetree/bindings/input/touchscreen/goodix.txt +0
-0
Documentation/devicetree/bindings/input/touchscreen/goodix.txt Optional properties: · line 29
Quoted 5 lines
Documentation/devicetree/bindings/input/touchscreen/goodix.txt +2
-0@@ -25,6 +25,8 @@ Optional properties: - touchscreen-inverted-y : Y axis is inverted (boolean) - touchscreen-swapped-x-y : X and Y axis are swapped (boolean) (swapping is done after inverting the axis) + - touchscreen-inter-x-y : X and Y maximum values programmed in the device + are interchanged internally in hardware. (boolean)
Minimally this should be vendor specific and have a vendor prefix I think.
Rob
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/4] Input: goodix - Restructure cfg checksum function
In reply to Franklin S Cooper JrQuoted 1 line · Franklin S Cooper Jr
Split generation of checksum into is own function. Currently it is used
"its own".
Quoted 6 lines
only to determine if the checksum for the user provided configuration file is valid or not. However, support to dynamically alter the configuration file will be supported and needs a way to calculate the updated file's checksum. Therefore, by splitting calculating checksum into its own function the code can be reused.
After the fixup above:
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/4] Input: goodix - Allow tweaking of configuration file dynamically
In reply to Franklin S Cooper JrQuoted 46 lines · Franklin S Cooper Jr
Some goodix touchscreen controllers don't have the correct configuration
firmware for the display panel it is attached to. Therefore, settings such
as touchscreen x and y size may need to be passed in via DT and have the
panel reprogrammed for the updated touchscreen resolution.This patchset adds support for reading the current configuration firmware
on the panel and allowing it to be modified and rewritten back to the device.Currently this function is unused but later patches will make use of it.
Signed-off-by Franklin S Cooper Jr <[email protected]>---
drivers/input/touchscreen/goodix.c | 28 ++++++++++++++++++++++++++++1 file changed, 28 insertions(+)drivers/input/touchscreen/goodix.c +0
-0@@ -478,6 +478,34 @@ static int goodix_get_gpio_config(struct goodix_ts_data *ts) return 0; }drivers/input/touchscreen/goodix.c +14
-0+static void goodix_tweak_config (struct goodix_ts_data *ts) +{ +u8 config[GOODIX_CONFIG_MAX_LENGTH ]; +int error; +int raw_cfg_len; +u8 check_sum =0 ; + + raw_cfg_len = ts->cfg_len -2 ; + + error =goodix_i2c_read (ts->client,GOODIX_REG_CONFIG_DATA , + config, ts->cfg_len); +if (error) { + dev_warn(&ts->client->dev, + "Error reading config (%d), avoid tweakingconfig\n",
drivers/input/touchscreen/goodix.c static int goodix_get_gpio_config(struct goodix_ts_data *ts) · line 497
Quoted 3 lines
drivers/input/touchscreen/goodix.c +3
-0+ error); +return ; + }
Please add a placeholder comment here, to go along with the commit message explanation.
Quoted 13 lines
drivers/input/touchscreen/goodix.c +10
-0+ check_sum =goodix_calculate_checksum (ts->cfg_len, config); + + config[raw_cfg_len] = check_sum; + config[raw_cfg_len +1 ] =1 ; + + error =goodix_send_cfg (ts, ts->cfg_len, config); +if (error) +dev_warn (&ts->client->dev, + "Error writing config (%d)\n", error); +}/**
*goodix_read_config- Read the embedded configuration of the panel *
Re: [PATCH 3/4] Input: goodix - Tweak configuration to use passed in touchscreen resolution
In reply to Franklin S Cooper JrQuoted 66 lines · Franklin S Cooper Jr
Some goodix touchscreen controllers aren't programed properly to match the
display panel it is used on. Although the defaults may largely work it is
also likely that the screen resolution will be incorrect. Therefore, add support to allow via DT for the touchscreen resolution to be set and
reprogram the controller to use this updated resolution.Signed-off-by Franklin S Cooper Jr <[email protected]>---
.../bindings/input/touchscreen/goodix.txt | 2 ++ drivers/input/touchscreen/goodix.c | 26
+++++++++++++++++++++-2 files changed, 27 insertions(+), 1 deletion(-)diff --git
a/Documentation/devicetree/bindings/input/touchscreen/goodix.txtb/Documentation/devicetree/bindings/input/touchscreen/goodix.txtindex c98757a..ebc7cb7 100644Documentation/devicetree/bindings/input/touchscreen/goodix.txt +0
-0@@ -19,6 +19,8 @@ Optional properties:interrupt gpio pin as output to reset the device.
- reset-gpios : GPIO pin used for reset
+ - touchscreen-size-x : horizontal resolution of touchscreen (in pixels)
+ - touchscreen-size-y : vertical resolution of touchscreen (in pixels)
- touchscreen-inverted-x : X axis is inverted (boolean)
- touchscreen-inverted-y : Y axis is inverted (boolean)
- touchscreen-swapped-x-y : X and Y axis are swapped (boolean)drivers/input/touchscreen/goodix.c +0
-0@@ -496,6 +496,10 @@ static void goodix_tweak_config(struct goodix_ts_data *ts) return; }drivers/input/touchscreen/goodix.c +3
-0+/* Setting X and Y Resolution */ +put_unaligned_le16 (ts->abs_x_max, &config[RESOLUTION_LOC ]); + put_unaligned_le16(ts->abs_y_max, &config[RESOLUTION_LOC +2]);
+
check_sum=goodix_calculate_checksum(ts->cfg_len, config);
config[raw_cfg_len] =check_sum;drivers/input/touchscreen/goodix.c +2
-0@@ -669,6 +673,8 @@ static int goodix_request_input_dev(struct goodix_ts_data *ts) static int goodix_configure_dev(struct goodix_ts_data *ts) { int error; +bool alter_config = false; +u32 max_x, max_y;
ts->swapped_x_y= device_property_read_bool(&ts->client-Quoted 1 line
dev,
"touchscreen- swapped-x-y");
drivers/input/touchscreen/goodix.c +0
-0@@ -676,9 +682,27 @@ static int goodix_configure_dev(struct goodix_ts_data *ts)
Quoted 6 lines
"touchscreen- inverted-x");
ts->inverted_y=device_property_read_bool(&ts->client->dev, "touchscreen- inverted-y");
-
No need for that linefeed removal.
Quoted 4 lines
goodix_read_config(ts);drivers/input/touchscreen/goodix.c +1
-0+ if (device_property_present(&ts->client->dev, "touchscreen-size-x") &&
Is it expected that incomplete or invalid arguments do not generate errors? I'd expect that the presence of just one of those properties, or...
drivers/input/touchscreen/goodix.c static int goodix_configure_dev(struct goodix_ts_data *ts) · line 696
Quoted 12 lines
drivers/input/touchscreen/goodix.c +1
-0+ device_property_present(&ts->client->dev, "touchscreen-size-y")) {
drivers/input/touchscreen/goodix.c +2
-0+ + device_property_read_u32(&ts->client->dev,"touchscreen-size-x",
drivers/input/touchscreen/goodix.c +3
-0+ &max_x); + + device_property_read_u32(&ts->client->dev,"touchscreen-size-y",
drivers/input/touchscreen/goodix.c +3
-0+ &max_y); + +if (max_x >0 && max_y >0 ) {
... invalid values for those properties would throw errors (either warnings, or lower severity messages).
Quoted 9 lines
drivers/input/touchscreen/goodix.c +9
-0+ ts->abs_x_max = max_x; + ts->abs_y_max = max_y; + alter_config = true; + } + } + +if (alter_config) +goodix_tweak_config (ts); +
Quoted 3 lines
error =
goodix_request_input_dev(ts);
if (error)
return error;
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 4/4] Input: goodix - Support interchanging x and y coordinates in hardware
In reply to Rob HerringQuoted 2 lines · Rob Herring
Quoted 1 line · Franklin S Cooper Jr
<snip>
Quoted 1 line
I'm not sure I follow why existing properties don't cover this.
Me neither. I certainly don't understand why the driver can't mangle the data from the touchscreen all it wants. It's not like user-space is talking to the touchscreen directly.
Re: [PATCH 2/4] Input: goodix - Allow tweaking of configuration file dynamically
In reply to Bastien NoceraQuoted 45 lines · Bastien Nocera
Quoted 44 lines · Franklin S Cooper Jr
Some goodix touchscreen controllers don't have the correct configuration
firmware for the display panel it is attached to. Therefore, settings such
as touchscreen x and y size may need to be passed in via DT and have the
panel reprogrammed for the updated touchscreen resolution.This patchset adds support for reading the current configuration firmware
on the panel and allowing it to be modified and rewritten back to the device.Currently this function is unused but later patches will make use of it.
Signed-off-by Franklin S Cooper Jr <[email protected]>--- drivers/input/touchscreen/goodix.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)drivers/input/touchscreen/goodix.c +13
-0@@ -478,6 +478,34 @@ static int goodix_get_gpio_config(struct goodix_ts_data *ts)return 0 ; } +static void goodix_tweak_config (struct goodix_ts_data *ts) +{ +u8 config[GOODIX_CONFIG_MAX_LENGTH ]; +int error; +int raw_cfg_len; +u8 check_sum =0 ; + + raw_cfg_len = ts->cfg_len -2 ; + + error =goodix_i2c_read (ts->client,GOODIX_REG_CONFIG_DATA , + config, ts->cfg_len); +if (error) { + dev_warn(&ts->client->dev,
Quoted 8 lines
drivers/input/touchscreen/goodix.c static int goodix_get_gpio_config(struct goodix_ts_data *ts) · line 497
Quoted 5 lines
drivers/input/touchscreen/goodix.c +4
-0+"Error reading config (%d), avoid tweaking config\n", + error); +return ; + }Please add a placeholder comment here, to go along with the commit message explanation.
You just want a comment here stating that changes to the firmware should be made here?
Quoted 14 lines
Quoted 4 lines
drivers/input/touchscreen/goodix.c +3
-0+ check_sum =goodix_calculate_checksum (ts->cfg_len, config); + + config[raw_cfg_len] = check_sum;drivers/input/touchscreen/goodix.c static int goodix_get_gpio_config(struct goodix_ts_data *ts) · line 511
Quoted 10 lines
drivers/input/touchscreen/goodix.c +7
-0+ config[raw_cfg_len +1 ] =1 ; + + error =goodix_send_cfg (ts, ts->cfg_len, config); +if (error) +dev_warn (&ts->client->dev, +"Error writing config (%d)\n" , error); +}/** * goodix_read_config - Read the embedded configuration of the panel *
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 3/4] Input: goodix - Tweak configuration to use passed in touchscreen resolution
In reply to Bastien NoceraQuoted 76 lines · Bastien Nocera
Quoted 65 lines · Franklin S Cooper Jr
Some goodix touchscreen controllers aren't programed properly to match the
display panel it is used on. Although the defaults may largely work it is
also likely that the screen resolution will be incorrect. Therefore, add support to allow via DT for the touchscreen resolution to be set and
reprogram the controller to use this updated resolution.Signed-off-by Franklin S Cooper Jr <[email protected]>--- .../bindings/input/touchscreen/goodix.txt | 2 ++ drivers/input/touchscreen/goodix.c | 26 +++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-)diff --git
a/Documentation/devicetree/bindings/input/touchscreen/goodix.txtb/Documentation/devicetree/bindings/input/touchscreen/goodix.txtindex c98757a..ebc7cb7 100644Documentation/devicetree/bindings/input/touchscreen/goodix.txt +0
-0@@ -19,6 +19,8 @@ Optional properties: interrupt gpio pin as output to reset thedevice.
- reset-gpios : GPIO pin used for reset+ - touchscreen-size-x : horizontal resolution of touchscreen
(in pixels)
+ - touchscreen-size-y : vertical resolution of touchscreen (in
pixels)
- touchscreen-inverted-x : X axis is inverted (boolean)
- touchscreen-inverted-y : Y axis is inverted (boolean)
- touchscreen-swapped-x-y : X and Y axis are swapped (boolean)drivers/input/touchscreen/goodix.c +4
-0@@ -496,6 +496,10 @@ static void goodix_tweak_config(struct goodix_ts_data *ts) return; } +/* Setting X and Y Resolution */ +put_unaligned_le16 (ts->abs_x_max, &config[RESOLUTION_LOC ]); +put_unaligned_le16 (ts->abs_y_max, &config[RESOLUTION_LOC +2 ]); + check_sum =goodix_calculate_checksum (ts->cfg_len, config);drivers/input/touchscreen/goodix.c +2
-0config[raw_cfg_len] = check_sum;@@ -669,6 +673,8 @@ static int goodix_request_input_dev(struct goodix_ts_data *ts)static int goodix_configure_dev (struct goodix_ts_data *ts) {int error; +bool alter_config = false; +u32 max_x, max_y; ts->swapped_x_y = device_property_read_bool(&ts->client-Quoted 1 line
dev,
"touchscreen-
swapped-x-y");drivers/input/touchscreen/goodix.c static int goodix_configure_dev(struct · line 682
Quoted 7 lines
drivers/input/touchscreen/goodix.c +0
-1@@ -676,9 +682,27 @@ static int goodix_configure_dev(struct goodix_ts_data *ts) "touchscreen- inverted-x"); ts->inverted_y = device_property_read_bool(&ts->client->dev, "touchscreen- inverted-y"); -No need for that linefeed removal.
Quoted 8 lines
Quoted 4 lines
drivers/input/touchscreen/goodix.c +1
-0goodix_read_config (ts); + if (device_property_present(&ts->client->dev, "touchscreen-size-x") &&
Is it expected that incomplete or invalid arguments do not generate errors? I'd expect that the presence of just one of those properties, or...
Looking back at this there is technically nothing wrong with only wanting to set 1 property. So I will update this to decouple these two properties.
Quoted 16 lines
drivers/input/touchscreen/goodix.c static int goodix_configure_dev(struct goodix_ts_data *ts) · line 696
Quoted 13 lines
drivers/input/touchscreen/goodix.c +1
-0+ device_property_present(&ts->client->dev, "touchscreen-size-y")) {
drivers/input/touchscreen/goodix.c +2
-0+ + device_property_read_u32(&ts->client->dev,"touchscreen-size-x",
drivers/input/touchscreen/goodix.c +3
-0+ &max_x); + + device_property_read_u32(&ts->client->dev,"touchscreen-size-y",
drivers/input/touchscreen/goodix.c +3
-0+ &max_y); + +if (max_x >0 && max_y >0 ) {... invalid values for those properties would throw errors (either warnings, or lower severity messages).
I'll add a warning here indicating that the passed in value with be ignored.
Quoted 13 lines
drivers/input/touchscreen/goodix.c static int goodix_configure_dev(struct goodix_ts_data *ts) · line 708
Quoted 13 lines
drivers/input/touchscreen/goodix.c +9
-0+ ts->abs_x_max = max_x; + ts->abs_y_max = max_y; + alter_config = true; + } + } + +if (alter_config) +goodix_tweak_config (ts); + error =goodix_request_input_dev (ts);if (error)return error;
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/4] Input: goodix - Allow tweaking of configuration file dynamically
In reply to Franklin S Cooper JrQuoted 63 lines · Franklin S Cooper Jr
Quoted 52 lines · Bastien Nocera
Quoted 51 lines · Franklin S Cooper Jr
Some goodix touchscreen controllers don't have the correct configuration
firmware for the display panel it is attached to. Therefore, settings
such
as touchscreen x and y size may need to be passed in via DT and have
the
panel reprogrammed for the updated touchscreen resolution.This patchset adds support for reading the current configuration firmware
on the panel and allowing it to be modified and rewritten back to the
device.Currently this function is unused but later patches will make use of
it.Signed-off-by Franklin S Cooper Jr <[email protected]>---
drivers/input/touchscreen/goodix.c | 28
++++++++++++++++++++++++++++1 file changed, 28 insertions(+)drivers/input/touchscreen/goodix.c +0
-0@@ -478,6 +478,34 @@ static int goodix_get_gpio_config(struct goodix_ts_data *ts) return 0; }drivers/input/touchscreen/goodix.c +10
-0+static void goodix_tweak_config (struct goodix_ts_data *ts) +{ +u8 config[GOODIX_CONFIG_MAX_LENGTH ]; +int error; +int raw_cfg_len; +u8 check_sum =0 ; + + raw_cfg_len = ts->cfg_len -2 ; + + error = goodix_i2c_read(ts->client,
GOODIX_REG_CONFIG_DATA,drivers/input/touchscreen/goodix.c +4
-0+ config, ts->cfg_len); +if (error) { + dev_warn(&ts->client->dev, + "Error reading config (%d), avoidQuoted 8 lines
drivers/input/touchscreen/goodix.c static int goodix_get_gpio_config(struct goodix_ts_data *ts) · line 497
Quoted 5 lines
tweaking
config\n",drivers/input/touchscreen/goodix.c +3
-0+ error); +return ; + }Please add a placeholder comment here, to go along with the commit message explanation.
Quoted 3 lines
You just want a comment here stating that changes to the firmware should
be made here?
Yes, at least for this intermediary patch. You can remove in in subsequent patches when it's clearer that this is where things go.
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
drivers/input/touchscreen/goodix.c +1
-0+ check_sum = goodix_calculate_checksum(ts->cfg_len,config);
drivers/input/touchscreen/goodix.c +9
-0+ + config[raw_cfg_len] = check_sum; + config[raw_cfg_len +1 ] =1 ; + + error =goodix_send_cfg (ts, ts->cfg_len, config); +if (error) +dev_warn (&ts->client->dev, + "Error writing config (%d)\n", error); +}/**
*goodix_read_config- Read the embedded configuration of the panel
*
Re: [PATCH 4/4] Input: goodix - Support interchanging x and y coordinates in hardware
In reply to Bastien NoceraQuoted 10 lines · Bastien Nocera
Quoted 2 lines · Rob Herring
Quoted 1 line · Franklin S Cooper Jr
<snip>
Quoted 1 line
I'm not sure I follow why existing properties don't cover this.
Me neither. I certainly don't understand why the driver can't mangle the data from the touchscreen all it wants. It's not like user-space is talking to the touchscreen directly.
Sorry the above could of been clearer.
Lets ignore talking about X and Y axis for a little bit since that really depends on the default touchscreen config values and the way it is mounted on the touchscreen. Now lets say when your interacting with the touchscreen the touchscreen controller outputs a max value of 1280 when moving your finger horizontally and 800 when moving your finger vertically.
<-1280->
------
| | ^ | | | | | 800 | | | ------ V
So no matter what your horizontal range is 0-1280 and your vertical range is 0-800. Now based on the above diagram you can see that usually you want the longer side to have a higher resolution. So you may want a vertical range of 0-1280 and a horizontal range from 0-800 instead.
So lets add labels to the original diagram and assume that the x and y axis from the driver/user-space perspective is as follows. <-1280-> (X)
------
| | ^ | | | | | 800 (Y) | | | ------ V
The only thing the driver (software) has the ability to do is change the "orientation".
<-1280-> (Y)
------
| | ^ | | | | | 800 (X) | | | ------ V
However, this doesn't change the resolution ie range of values in the horizontal and vertical direction the touch screen controller will report. Only the hardware can determine the resolution it will use. The interchange bit I set essentially swaps the range that the controller is currently programmed to use which in my first diagram the horizontal range was 0-1280 and my vertical range is 0-800. So by setting this interchange bit in hardware the horizontal range will now be 0-800 while the vertical range will be 0-1280 which is what we want.
Does this clarify things? I messed up the second diagram in my commit message which is probably what caused the confusion.
Re: [PATCH 4/4] Input: goodix - Support interchanging x and y coordinates in hardware
In reply to Rob HerringQuoted 53 lines · Rob Herring
Quoted 36 lines · Franklin S Cooper Jr
On systems with a fixed display/touchscreen orientation it is important to pass in the "correct" x and y coordinates based on the orientation. Currently, to support landscape and portrait touchscreen-swapped-x-y simply does the following:
Assuming touchscreen is as follows:
X: 1280 Y:800 programmed in touchscreen controller and also interchange bit cleared. Assuming ts mounted in portrait mode.1280 (X)
------| | | | 800 (Y) | | | |------
800 (Y)
------| | | | 1280 (X) | | | |------
However, the above isn't really what we want especially in distros that assumes a fixed orientation. In this case what we really want is to interchange the x and y coordinates so the Y coordinate can return a max value of 1280 and X can return a max value of 800.
800 (X)
------| | | | 1280 (Y) | | | |Quoted 6 lines
------
Since the driver is limited to the value reported by the touchscreen controller this issue can't be fixed purely in the driver. Therefore, add a new DT property that supports interchanging X and Y coordinates internally within the hardware.
I'm not sure I follow why existing properties don't cover this.
Quoted 7 lines
Signed-off-by Franklin S Cooper Jr <[email protected]>--- .../devicetree/bindings/input/touchscreen/goodix.txt | 2 ++ drivers/input/touchscreen/goodix.c | 13 +++++++++++++ 2 files changed, 15 insertions(+)
Quoted 13 lines
Documentation/devicetree/bindings/input/touchscreen/goodix.txt Optional properties: · line 29
Quoted 10 lines
Documentation/devicetree/bindings/input/touchscreen/goodix.txt +2
-0@@ -25,6 +25,8 @@ Optional properties: - touchscreen-inverted-y : Y axis is inverted (boolean) - touchscreen-swapped-x-y : X and Y axis are swapped (boolean) (swapping is done after inverting the axis) + - touchscreen-inter-x-y : X and Y maximum values programmed in the device + are interchanged internally in hardware. (boolean)Minimally this should be vendor specific and have a vendor prefix I think.
Would "goodix,inter-x-y" work?
Quoted 3 lines
Rob
Re: [PATCH 4/4] Input: goodix - Support interchanging x and y coordinates in hardware
In reply to Franklin S Cooper JrQuoted 82 lines · Franklin S Cooper Jr
Quoted 5 lines · Bastien Nocera
Quoted 3 lines · Rob Herring
Quoted 1 line · Franklin S Cooper Jr
Quoted 9 lines
<snip>
Quoted 1 line
I'm not sure I follow why existing properties don't cover this.
Me neither. I certainly don't understand why the driver can't mangle
the data from the touchscreen all it wants. It's not like user- space is
talking to the touchscreen directly.Sorry the above could of been clearer.
Lets ignore talking about X and Y axis for a little bit since that really depends on the default touchscreen config values and the way it
is mounted on the touchscreen. Now lets say when your interacting with
the touchscreen the touchscreen controller outputs a max value of 1280
when moving your finger horizontally and 800 when moving your finger vertically.<-1280->
------Quoted 4 lines
| ^ | | | 800 | |------ V
So no matter what your horizontal range is 0-1280 and your vertical range is 0-800. Now based on the above diagram you can see that usually
you want the longer side to have a higher resolution. So you may want a
vertical range of 0-1280 and a horizontal range from 0-800 instead.So lets add labels to the original diagram and assume that the x and y
axis from the driver/user-space perspective is as follows. <-1280-> (X)
------Quoted 4 lines
| ^ | | | 800 (Y) | |------ V
The only thing the driver (software) has the ability to do is change the
"orientation".<-1280-> (Y)
------Quoted 4 lines
| ^ | | | 800 (X) | |------ V
However, this doesn't change the resolution ie range of values in the horizontal and vertical direction the touch screen controller will report. Only the hardware can determine the resolution it will use. The
interchange bit I set essentially swaps the range that the controller is
currently programmed to use which in my first diagram the horizontal range was 0-1280 and my vertical range is 0-800. So by setting this interchange bit in hardware the horizontal range will now be 0-800 while
the vertical range will be 0-1280 which is what we want.
Quoted 2 lines
Does this clarify things? I messed up the second diagram in my commit message which is probably what caused the confusion.
Looks to me that this should be fixed in the firmware configuration, which is what Irina's patches allow doing.
If the goal of this series is implementing this, I wouldn't take any of those patches until we figure out why the firmware config in those devices isn't set properly.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html