hidraw: add a feature report get/set helper functions

No real functional changes since they just forward to the existing function.
But it reduces the cognitive load a bit when reading the code.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer
2019-07-23 13:28:59 +10:00
committed by Filipe Laíns
parent 43def1b3a5
commit d46251900c
2 changed files with 53 additions and 1 deletions

View File

@@ -1586,6 +1586,23 @@ ratbag_hidraw_raw_request(struct ratbag_device *device, unsigned char reportnum,
return -EINVAL;
}
int
ratbag_hidraw_get_feature_report(struct ratbag_device *device, unsigned char reportnum,
uint8_t *buf, size_t len)
{
return ratbag_hidraw_raw_request(device, reportnum, buf, len,
HID_FEATURE_REPORT, HID_REQ_GET_REPORT);
}
int
ratbag_hidraw_set_feature_report(struct ratbag_device *device, unsigned char reportnum,
uint8_t *buf, size_t len)
{
return ratbag_hidraw_raw_request(device, reportnum, buf, len,
HID_FEATURE_REPORT, HID_REQ_SET_REPORT);
}
int
ratbag_hidraw_output_report(struct ratbag_device *device, uint8_t *buf, size_t len)
{

View File

@@ -101,7 +101,7 @@ void ratbag_close_hidraw_index(struct ratbag_device *device, int idx);
*
* @param device the ratbag device
* @param reportnum report ID
* @param buf in/out data to transfer
* @param buf[in/out] data to transfer
* @param len length of buf
* @param rtype HID report type
* @param reqtype HID_REQ_GET_REPORT or HID_REQ_SET_REPORT
@@ -114,6 +114,41 @@ int ratbag_hidraw_raw_request(struct ratbag_device *device, unsigned char report
uint8_t *buf, size_t len, unsigned char rtype,
int reqtype);
/**
* Get feature report from device.
*
* This call sends a HID_REQ_GET_REPORT to the device for the given feature
* and returns the data in the caller-allocated buffer buf of size len.
*
* @param device the ratbag device
* @param reportnum report ID
* @param buf[out] data returned from device
* @param len length of buf
*
* @return count of data transfered, or a negative errno on error
*
* Convenience wrapper around ratbag_hidraw_raw_request()
*/
int ratbag_hidraw_get_feature_report(struct ratbag_device *device, unsigned char reportnum,
uint8_t *buf, size_t len);
/**
* Set feature report on device.
*
* This call sends a HID_REQ_SET_REPORT to the device for the given feature
* and the buffer buf of size len.
*
* @param device the ratbag device
* @param reportnum report ID
* @param buf[in] data returned from device
* @param len length of buf
*
* @return count of data transfered, or a negative errno on error
*
* Convenience wrapper around ratbag_hidraw_raw_request()
*/
int ratbag_hidraw_set_feature_report(struct ratbag_device *device, unsigned char reportnum,
uint8_t *buf, size_t len);
/**
* Send output report to device
*