hidpp10: implement refresh rate

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer
2015-08-24 14:30:41 +10:00
parent adf1b9a99d
commit a0d882d2e5
2 changed files with 32 additions and 0 deletions

View File

@@ -383,6 +383,25 @@ hidpp10_get_optical_sensor_settings(struct ratbag_device *device, struct hidpp10
return 0;
}
static int
hidpp10_get_usb_refresh_rate(struct ratbag_device *device, struct hidpp10_device *dev)
{
unsigned idx = dev->index;
union hidpp10_message refresh = CMD_USB_REFRESH_RATE(idx, GET_REGISTER_REQ);
int res;
int rate;
res = hidpp10_request_command(device, &refresh);
if (res)
return res;
rate = 1000/refresh.msg.parameters[0];
log_debug(device->ratbag, "Refresh rate: %dHz\n", rate);
return 0;
}
static int
hidpp10_get_device_info(struct ratbag_device *device, struct hidpp10_device *dev)
{
@@ -395,6 +414,7 @@ hidpp10_get_device_info(struct ratbag_device *device, struct hidpp10_device *dev
hidpp10_get_current_resolution(device, dev);
hidpp10_get_led_status(device, dev);
hidpp10_get_optical_sensor_settings(device, dev);
hidpp10_get_usb_refresh_rate(device, dev);
return 0;
}

View File

@@ -93,6 +93,8 @@
#define __CMD_OPTICAL_SENSOR_SETTINGS 0x61
#define __CMD_USB_REFRESH_RATE 0x64
#define CMD_PAIRING_INFORMATION(idx, type) { \
.msg = { \
.report_id = REPORT_ID_SHORT, \
@@ -163,6 +165,16 @@
} \
}
#define CMD_USB_REFRESH_RATE(idx, sub) { \
.msg = { \
.report_id = REPORT_ID_SHORT, \
.device_idx = idx, \
.sub_id = sub, \
.address = __CMD_USB_REFRESH_RATE, \
.parameters = {0x00, 0x00, 0x00 }, \
} \
}
#define CMD_OPTICAL_SENSOR_SETTINGS(idx, sub) { \
.msg = { \
.report_id = REPORT_ID_SHORT, \