mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-05 02:19:51 +00:00
HID: rmi: Add functions for writing to registers
Writing to registers is needed for setting configuration parameters. Signed-off-by: Andrew Duggan <aduggan@synaptics.com> Tested-by: Gabriele Mazzotta <gabriele.mzt@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
This commit is contained in:
parent
70e003f75f
commit
dd8df28459
1 changed files with 40 additions and 0 deletions
|
@ -274,6 +274,46 @@ static inline int rmi_read(struct hid_device *hdev, u16 addr, void *buf)
|
||||||
return rmi_read_block(hdev, addr, buf, 1);
|
return rmi_read_block(hdev, addr, buf, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int rmi_write_block(struct hid_device *hdev, u16 addr, void *buf,
|
||||||
|
const int len)
|
||||||
|
{
|
||||||
|
struct rmi_data *data = hid_get_drvdata(hdev);
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
mutex_lock(&data->page_mutex);
|
||||||
|
|
||||||
|
if (RMI_PAGE(addr) != data->page) {
|
||||||
|
ret = rmi_set_page(hdev, RMI_PAGE(addr));
|
||||||
|
if (ret < 0)
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
data->writeReport[0] = RMI_WRITE_REPORT_ID;
|
||||||
|
data->writeReport[1] = len;
|
||||||
|
data->writeReport[2] = addr & 0xFF;
|
||||||
|
data->writeReport[3] = (addr >> 8) & 0xFF;
|
||||||
|
memcpy(&data->writeReport[4], buf, len);
|
||||||
|
|
||||||
|
ret = rmi_write_report(hdev, data->writeReport,
|
||||||
|
data->output_report_size);
|
||||||
|
if (ret < 0) {
|
||||||
|
dev_err(&hdev->dev,
|
||||||
|
"failed to write request output report (%d)\n",
|
||||||
|
ret);
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
|
exit:
|
||||||
|
mutex_unlock(&data->page_mutex);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int rmi_write(struct hid_device *hdev, u16 addr, void *buf)
|
||||||
|
{
|
||||||
|
return rmi_write_block(hdev, addr, buf, 1);
|
||||||
|
}
|
||||||
|
|
||||||
static void rmi_f11_process_touch(struct rmi_data *hdata, int slot,
|
static void rmi_f11_process_touch(struct rmi_data *hdata, int slot,
|
||||||
u8 finger_state, u8 *touch_data)
|
u8 finger_state, u8 *touch_data)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue