mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-09 09:01:35 +00:00
usb_update: Add support for touchpad debugging feature
We support touchpad-specific debugging feature over the USB update protocol. This will be used to fetch raw data from the sensor, without requiring to remove the write-protect screw. BRANCH=none BUG=b:63993891 TEST=./usb_updater2 -g 00 -d 18d1:502b Change-Id: I46dfd97aaa17b73a5893fe1e8c62327a302f829b Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/763574 Reviewed-by: Chun-ta Lin <itspeter@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
This commit is contained in:
committed by
chrome-bot
parent
b3c9986802
commit
7fdcb8bf86
@@ -326,6 +326,31 @@ static int try_vendor_command(struct consumer const *consumer, size_t count)
|
||||
&tp, response_size);
|
||||
return 1;
|
||||
}
|
||||
case UPDATE_EXTRA_CMD_TOUCHPAD_DEBUG: {
|
||||
uint8_t *data = NULL;
|
||||
unsigned int write_count = 0;
|
||||
|
||||
/*
|
||||
* Let the touchpad driver decide what it wants to do
|
||||
* with the payload data, and put the response in data.
|
||||
*/
|
||||
response = touchpad_debug(buffer + header_size,
|
||||
data_count, &data, &write_count);
|
||||
|
||||
/*
|
||||
* On error, or if there is no data to write back, just
|
||||
* write back response.
|
||||
*/
|
||||
if (response != EC_RES_SUCCESS || write_count == 0)
|
||||
break;
|
||||
|
||||
/* Check that we can write all the data to the queue. */
|
||||
if (write_count > queue_space(&update_to_usb))
|
||||
return EC_RES_BUSY;
|
||||
|
||||
QUEUE_ADD_UNITS(&update_to_usb, data, write_count);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
response = EC_RES_INVALID_COMMAND;
|
||||
|
||||
@@ -505,6 +505,13 @@ int touchpad_update_write(int offset, int size, const uint8_t *data)
|
||||
}
|
||||
return EC_SUCCESS;
|
||||
}
|
||||
|
||||
/* TODO(b:63993891): Implement debugging mode for Elan touchpad. */
|
||||
int touchpad_debug(const uint8_t *param, unsigned int param_size,
|
||||
uint8_t **data, unsigned int *data_size)
|
||||
{
|
||||
return EC_RES_INVALID_COMMAND;
|
||||
}
|
||||
#endif
|
||||
|
||||
void elan_tp_interrupt(enum gpio_signal signal)
|
||||
|
||||
@@ -165,6 +165,7 @@ enum update_extra_command {
|
||||
UPDATE_EXTRA_CMD_INJECT_ENTROPY = 5,
|
||||
UPDATE_EXTRA_CMD_PAIR_CHALLENGE = 6,
|
||||
UPDATE_EXTRA_CMD_TOUCHPAD_INFO = 7,
|
||||
UPDATE_EXTRA_CMD_TOUCHPAD_DEBUG = 8,
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -247,6 +248,23 @@ int touchpad_get_info(struct touchpad_info *tp);
|
||||
/* Touchpad FW update: Write a FW block. */
|
||||
int touchpad_update_write(int offset, int size, const uint8_t *data);
|
||||
|
||||
/**
|
||||
* Touchpad debugging interface, called whenever UPDATE_EXTRA_CMD_TOUCHPAD_DEBUG
|
||||
* is received. Behaviour is touchpad-vendor dependent, with the following
|
||||
* restrictions: data must be allocated statically, and must not be larger than
|
||||
* 64 bytes.
|
||||
*
|
||||
* @param param Data passed as parameter to command.
|
||||
* @param param_size Number of bytes passed as parameter.
|
||||
* @param data Data to write back to host, needs to be allocated
|
||||
* statically by touchpad handler.
|
||||
* @param data_size Amount of data to write back to host (up to 64 bytes).
|
||||
*
|
||||
* @return EC_RES_SUCCESS on success, any other EC_RES_* status on error.
|
||||
*/
|
||||
int touchpad_debug(const uint8_t *param, unsigned int param_size,
|
||||
uint8_t **data, unsigned int *data_size);
|
||||
|
||||
/* SHA256 hash of the touchpad firmware expected by this image. */
|
||||
extern const uint8_t touchpad_fw_full_hash[32];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user