From ad899506a71c6c247011688dd597f21869df74e2 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 25 Aug 2015 11:07:31 +1000 Subject: [PATCH] hidpp10: convert get_usb_refresh_rate to a proper function Signed-off-by: Peter Hutterer --- src/hidpp10.c | 15 +++++++-------- src/hidpp10.h | 9 +++++++++ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/hidpp10.c b/src/hidpp10.c index 9b9178bc..0735f7f8 100644 --- a/src/hidpp10.c +++ b/src/hidpp10.c @@ -433,23 +433,22 @@ hidpp10_get_current_resolution(struct ratbag_device *device, struct hidpp10_devi } \ } -static int -hidpp10_get_usb_refresh_rate(struct ratbag_device *device, struct hidpp10_device *dev) +int +hidpp10_get_usb_refresh_rate(struct ratbag_device *device, + struct hidpp10_device *dev, + uint16_t *rate) { 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]; + *rate = 1000/refresh.msg.parameters[0]; - log_debug(device->ratbag, "Refresh rate: %dHz\n", rate); - - dev->refresh_rate = rate; + log_debug(device->ratbag, "Refresh rate: %dHz\n", *rate); return 0; } @@ -637,7 +636,7 @@ hidpp10_get_device_info(struct ratbag_device *device, struct hidpp10_device *dev hidpp10_get_current_resolution(device, dev, &dev->xres, &dev->yres); hidpp10_get_led_status(device, dev, dev->led); hidpp10_get_optical_sensor_settings(device, dev); - hidpp10_get_usb_refresh_rate(device, dev); + hidpp10_get_usb_refresh_rate(device, dev, &dev->refresh_rate); return 0; } diff --git a/src/hidpp10.h b/src/hidpp10.h index c55495b1..dc6a0256 100644 --- a/src/hidpp10.h +++ b/src/hidpp10.h @@ -140,6 +140,15 @@ int hidpp10_get_current_resolution(struct ratbag_device *device, struct hidpp10_device *dev, uint16_t *xres, uint16_t *yres); + +/* -------------------------------------------------------------------------- */ +/* 0x64: Device Firmware Information */ +/* -------------------------------------------------------------------------- */ +int +hidpp10_get_usb_refresh_rate(struct ratbag_device *device, + struct hidpp10_device *dev, + uint16_t *rate); + /* -------------------------------------------------------------------------- */ /* 0xF1: Device Firmware Information */ /* -------------------------------------------------------------------------- */