Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7392d73b authored by Stefan Achatz's avatar Stefan Achatz Committed by Jiri Kosina
Browse files

HID: roccat: rename roccat_common functions to roccat_common2



Did this to illustrate my understanding of the firmware generations:
Valo and Kone were 1st generation
Arvo was externaly developed and lies in the middle
All others until now are considered 2nd generation

Signed-off-by: default avatarStefan Achatz <erazor_de@users.sourceforge.net>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent 4ec141ad
Loading
Loading
Loading
Loading
+8 −8
Original line number Original line Diff line number Diff line
@@ -39,7 +39,7 @@ static ssize_t arvo_sysfs_show_mode_key(struct device *dev,
	int retval;
	int retval;


	mutex_lock(&arvo->arvo_lock);
	mutex_lock(&arvo->arvo_lock);
	retval = roccat_common_receive(usb_dev, ARVO_COMMAND_MODE_KEY,
	retval = roccat_common2_receive(usb_dev, ARVO_COMMAND_MODE_KEY,
			&temp_buf, sizeof(struct arvo_mode_key));
			&temp_buf, sizeof(struct arvo_mode_key));
	mutex_unlock(&arvo->arvo_lock);
	mutex_unlock(&arvo->arvo_lock);
	if (retval)
	if (retval)
@@ -67,7 +67,7 @@ static ssize_t arvo_sysfs_set_mode_key(struct device *dev,
	temp_buf.state = state;
	temp_buf.state = state;


	mutex_lock(&arvo->arvo_lock);
	mutex_lock(&arvo->arvo_lock);
	retval = roccat_common_send(usb_dev, ARVO_COMMAND_MODE_KEY,
	retval = roccat_common2_send(usb_dev, ARVO_COMMAND_MODE_KEY,
			&temp_buf, sizeof(struct arvo_mode_key));
			&temp_buf, sizeof(struct arvo_mode_key));
	mutex_unlock(&arvo->arvo_lock);
	mutex_unlock(&arvo->arvo_lock);
	if (retval)
	if (retval)
@@ -87,7 +87,7 @@ static ssize_t arvo_sysfs_show_key_mask(struct device *dev,
	int retval;
	int retval;


	mutex_lock(&arvo->arvo_lock);
	mutex_lock(&arvo->arvo_lock);
	retval = roccat_common_receive(usb_dev, ARVO_COMMAND_KEY_MASK,
	retval = roccat_common2_receive(usb_dev, ARVO_COMMAND_KEY_MASK,
			&temp_buf, sizeof(struct arvo_key_mask));
			&temp_buf, sizeof(struct arvo_key_mask));
	mutex_unlock(&arvo->arvo_lock);
	mutex_unlock(&arvo->arvo_lock);
	if (retval)
	if (retval)
@@ -115,7 +115,7 @@ static ssize_t arvo_sysfs_set_key_mask(struct device *dev,
	temp_buf.key_mask = key_mask;
	temp_buf.key_mask = key_mask;


	mutex_lock(&arvo->arvo_lock);
	mutex_lock(&arvo->arvo_lock);
	retval = roccat_common_send(usb_dev, ARVO_COMMAND_KEY_MASK,
	retval = roccat_common2_send(usb_dev, ARVO_COMMAND_KEY_MASK,
			&temp_buf, sizeof(struct arvo_key_mask));
			&temp_buf, sizeof(struct arvo_key_mask));
	mutex_unlock(&arvo->arvo_lock);
	mutex_unlock(&arvo->arvo_lock);
	if (retval)
	if (retval)
@@ -130,7 +130,7 @@ static int arvo_get_actual_profile(struct usb_device *usb_dev)
	struct arvo_actual_profile temp_buf;
	struct arvo_actual_profile temp_buf;
	int retval;
	int retval;


	retval = roccat_common_receive(usb_dev, ARVO_COMMAND_ACTUAL_PROFILE,
	retval = roccat_common2_receive(usb_dev, ARVO_COMMAND_ACTUAL_PROFILE,
			&temp_buf, sizeof(struct arvo_actual_profile));
			&temp_buf, sizeof(struct arvo_actual_profile));


	if (retval)
	if (retval)
@@ -170,7 +170,7 @@ static ssize_t arvo_sysfs_set_actual_profile(struct device *dev,
	temp_buf.actual_profile = profile;
	temp_buf.actual_profile = profile;


	mutex_lock(&arvo->arvo_lock);
	mutex_lock(&arvo->arvo_lock);
	retval = roccat_common_send(usb_dev, ARVO_COMMAND_ACTUAL_PROFILE,
	retval = roccat_common2_send(usb_dev, ARVO_COMMAND_ACTUAL_PROFILE,
			&temp_buf, sizeof(struct arvo_actual_profile));
			&temp_buf, sizeof(struct arvo_actual_profile));
	if (!retval) {
	if (!retval) {
		arvo->actual_profile = profile;
		arvo->actual_profile = profile;
@@ -194,7 +194,7 @@ static ssize_t arvo_sysfs_write(struct file *fp,
		return -EINVAL;
		return -EINVAL;


	mutex_lock(&arvo->arvo_lock);
	mutex_lock(&arvo->arvo_lock);
	retval = roccat_common_send(usb_dev, command, buf, real_size);
	retval = roccat_common2_send(usb_dev, command, buf, real_size);
	mutex_unlock(&arvo->arvo_lock);
	mutex_unlock(&arvo->arvo_lock);


	return (retval ? retval : real_size);
	return (retval ? retval : real_size);
@@ -217,7 +217,7 @@ static ssize_t arvo_sysfs_read(struct file *fp,
		return -EINVAL;
		return -EINVAL;


	mutex_lock(&arvo->arvo_lock);
	mutex_lock(&arvo->arvo_lock);
	retval = roccat_common_receive(usb_dev, command, buf, real_size);
	retval = roccat_common2_receive(usb_dev, command, buf, real_size);
	mutex_unlock(&arvo->arvo_lock);
	mutex_unlock(&arvo->arvo_lock);


	return (retval ? retval : real_size);
	return (retval ? retval : real_size);
+17 −17
Original line number Original line Diff line number Diff line
@@ -16,12 +16,12 @@
#include <linux/module.h>
#include <linux/module.h>
#include "hid-roccat-common.h"
#include "hid-roccat-common.h"


static inline uint16_t roccat_common_feature_report(uint8_t report_id)
static inline uint16_t roccat_common2_feature_report(uint8_t report_id)
{
{
	return 0x300 | report_id;
	return 0x300 | report_id;
}
}


int roccat_common_receive(struct usb_device *usb_dev, uint report_id,
int roccat_common2_receive(struct usb_device *usb_dev, uint report_id,
		void *data, uint size)
		void *data, uint size)
{
{
	char *buf;
	char *buf;
@@ -34,16 +34,16 @@ int roccat_common_receive(struct usb_device *usb_dev, uint report_id,
	len = usb_control_msg(usb_dev, usb_rcvctrlpipe(usb_dev, 0),
	len = usb_control_msg(usb_dev, usb_rcvctrlpipe(usb_dev, 0),
			HID_REQ_GET_REPORT,
			HID_REQ_GET_REPORT,
			USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN,
			USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN,
			roccat_common_feature_report(report_id),
			roccat_common2_feature_report(report_id),
			0, buf, size, USB_CTRL_SET_TIMEOUT);
			0, buf, size, USB_CTRL_SET_TIMEOUT);


	memcpy(data, buf, size);
	memcpy(data, buf, size);
	kfree(buf);
	kfree(buf);
	return ((len < 0) ? len : ((len != size) ? -EIO : 0));
	return ((len < 0) ? len : ((len != size) ? -EIO : 0));
}
}
EXPORT_SYMBOL_GPL(roccat_common_receive);
EXPORT_SYMBOL_GPL(roccat_common2_receive);


int roccat_common_send(struct usb_device *usb_dev, uint report_id,
int roccat_common2_send(struct usb_device *usb_dev, uint report_id,
		void const *data, uint size)
		void const *data, uint size)
{
{
	char *buf;
	char *buf;
@@ -56,31 +56,31 @@ int roccat_common_send(struct usb_device *usb_dev, uint report_id,
	len = usb_control_msg(usb_dev, usb_sndctrlpipe(usb_dev, 0),
	len = usb_control_msg(usb_dev, usb_sndctrlpipe(usb_dev, 0),
			HID_REQ_SET_REPORT,
			HID_REQ_SET_REPORT,
			USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_OUT,
			USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_OUT,
			roccat_common_feature_report(report_id),
			roccat_common2_feature_report(report_id),
			0, buf, size, USB_CTRL_SET_TIMEOUT);
			0, buf, size, USB_CTRL_SET_TIMEOUT);


	kfree(buf);
	kfree(buf);
	return ((len < 0) ? len : ((len != size) ? -EIO : 0));
	return ((len < 0) ? len : ((len != size) ? -EIO : 0));
}
}
EXPORT_SYMBOL_GPL(roccat_common_send);
EXPORT_SYMBOL_GPL(roccat_common2_send);


enum roccat_common_control_states {
enum roccat_common2_control_states {
	ROCCAT_COMMON_CONTROL_STATUS_OVERLOAD = 0,
	ROCCAT_COMMON_CONTROL_STATUS_OVERLOAD = 0,
	ROCCAT_COMMON_CONTROL_STATUS_OK = 1,
	ROCCAT_COMMON_CONTROL_STATUS_OK = 1,
	ROCCAT_COMMON_CONTROL_STATUS_INVALID = 2,
	ROCCAT_COMMON_CONTROL_STATUS_INVALID = 2,
	ROCCAT_COMMON_CONTROL_STATUS_WAIT = 3,
	ROCCAT_COMMON_CONTROL_STATUS_WAIT = 3,
};
};


static int roccat_common_receive_control_status(struct usb_device *usb_dev)
static int roccat_common2_receive_control_status(struct usb_device *usb_dev)
{
{
	int retval;
	int retval;
	struct roccat_common_control control;
	struct roccat_common2_control control;


	do {
	do {
		msleep(50);
		msleep(50);
		retval = roccat_common_receive(usb_dev,
		retval = roccat_common2_receive(usb_dev,
				ROCCAT_COMMON_COMMAND_CONTROL,
				ROCCAT_COMMON_COMMAND_CONTROL,
				&control, sizeof(struct roccat_common_control));
				&control, sizeof(struct roccat_common2_control));


		if (retval)
		if (retval)
			return retval;
			return retval;
@@ -98,7 +98,7 @@ static int roccat_common_receive_control_status(struct usb_device *usb_dev)
			return -EINVAL;
			return -EINVAL;
		default:
		default:
			dev_err(&usb_dev->dev,
			dev_err(&usb_dev->dev,
					"roccat_common_receive_control_status: "
					"roccat_common2_receive_control_status: "
					"unknown response value 0x%x\n",
					"unknown response value 0x%x\n",
					control.value);
					control.value);
			return -EINVAL;
			return -EINVAL;
@@ -107,20 +107,20 @@ static int roccat_common_receive_control_status(struct usb_device *usb_dev)
	} while (1);
	} while (1);
}
}


int roccat_common_send_with_status(struct usb_device *usb_dev,
int roccat_common2_send_with_status(struct usb_device *usb_dev,
		uint command, void const *buf, uint size)
		uint command, void const *buf, uint size)
{
{
	int retval;
	int retval;


	retval = roccat_common_send(usb_dev, command, buf, size);
	retval = roccat_common2_send(usb_dev, command, buf, size);
	if (retval)
	if (retval)
		return retval;
		return retval;


	msleep(100);
	msleep(100);


	return roccat_common_receive_control_status(usb_dev);
	return roccat_common2_receive_control_status(usb_dev);
}
}
EXPORT_SYMBOL_GPL(roccat_common_send_with_status);
EXPORT_SYMBOL_GPL(roccat_common2_send_with_status);


MODULE_AUTHOR("Stefan Achatz");
MODULE_AUTHOR("Stefan Achatz");
MODULE_DESCRIPTION("USB Roccat common driver");
MODULE_DESCRIPTION("USB Roccat common driver");
+5 −5
Original line number Original line Diff line number Diff line
@@ -15,21 +15,21 @@
#include <linux/usb.h>
#include <linux/usb.h>
#include <linux/types.h>
#include <linux/types.h>


enum roccat_common_commands {
enum roccat_common2_commands {
	ROCCAT_COMMON_COMMAND_CONTROL = 0x4,
	ROCCAT_COMMON_COMMAND_CONTROL = 0x4,
};
};


struct roccat_common_control {
struct roccat_common2_control {
	uint8_t command;
	uint8_t command;
	uint8_t value;
	uint8_t value;
	uint8_t request; /* always 0 on requesting write check */
	uint8_t request; /* always 0 on requesting write check */
} __packed;
} __packed;


int roccat_common_receive(struct usb_device *usb_dev, uint report_id,
int roccat_common2_receive(struct usb_device *usb_dev, uint report_id,
		void *data, uint size);
		void *data, uint size);
int roccat_common_send(struct usb_device *usb_dev, uint report_id,
int roccat_common2_send(struct usb_device *usb_dev, uint report_id,
		void const *data, uint size);
		void const *data, uint size);
int roccat_common_send_with_status(struct usb_device *usb_dev,
int roccat_common2_send_with_status(struct usb_device *usb_dev,
		uint command, void const *buf, uint size);
		uint command, void const *buf, uint size);


#endif
#endif
+3 −3
Original line number Original line Diff line number Diff line
@@ -36,7 +36,7 @@ static void isku_profile_activated(struct isku_device *isku, uint new_profile)
static int isku_receive(struct usb_device *usb_dev, uint command,
static int isku_receive(struct usb_device *usb_dev, uint command,
		void *buf, uint size)
		void *buf, uint size)
{
{
	return roccat_common_receive(usb_dev, command, buf, size);
	return roccat_common2_receive(usb_dev, command, buf, size);
}
}


static int isku_get_actual_profile(struct usb_device *usb_dev)
static int isku_get_actual_profile(struct usb_device *usb_dev)
@@ -56,7 +56,7 @@ static int isku_set_actual_profile(struct usb_device *usb_dev, int new_profile)
	buf.command = ISKU_COMMAND_ACTUAL_PROFILE;
	buf.command = ISKU_COMMAND_ACTUAL_PROFILE;
	buf.size = sizeof(struct isku_actual_profile);
	buf.size = sizeof(struct isku_actual_profile);
	buf.actual_profile = new_profile;
	buf.actual_profile = new_profile;
	return roccat_common_send_with_status(usb_dev,
	return roccat_common2_send_with_status(usb_dev,
			ISKU_COMMAND_ACTUAL_PROFILE, &buf,
			ISKU_COMMAND_ACTUAL_PROFILE, &buf,
			sizeof(struct isku_actual_profile));
			sizeof(struct isku_actual_profile));
}
}
@@ -154,7 +154,7 @@ static ssize_t isku_sysfs_write(struct file *fp, struct kobject *kobj,
		return -EINVAL;
		return -EINVAL;


	mutex_lock(&isku->isku_lock);
	mutex_lock(&isku->isku_lock);
	retval = roccat_common_send_with_status(usb_dev, command,
	retval = roccat_common2_send_with_status(usb_dev, command,
			(void *)buf, real_size);
			(void *)buf, real_size);
	mutex_unlock(&isku->isku_lock);
	mutex_unlock(&isku->isku_lock);


+12 −12
Original line number Original line Diff line number Diff line
@@ -39,7 +39,7 @@ static void koneplus_profile_activated(struct koneplus_device *koneplus,
static int koneplus_send_control(struct usb_device *usb_dev, uint value,
static int koneplus_send_control(struct usb_device *usb_dev, uint value,
		enum koneplus_control_requests request)
		enum koneplus_control_requests request)
{
{
	struct roccat_common_control control;
	struct roccat_common2_control control;


	if ((request == KONEPLUS_CONTROL_REQUEST_PROFILE_SETTINGS ||
	if ((request == KONEPLUS_CONTROL_REQUEST_PROFILE_SETTINGS ||
			request == KONEPLUS_CONTROL_REQUEST_PROFILE_BUTTONS) &&
			request == KONEPLUS_CONTROL_REQUEST_PROFILE_BUTTONS) &&
@@ -50,15 +50,15 @@ static int koneplus_send_control(struct usb_device *usb_dev, uint value,
	control.value = value;
	control.value = value;
	control.request = request;
	control.request = request;


	return roccat_common_send_with_status(usb_dev,
	return roccat_common2_send_with_status(usb_dev,
			ROCCAT_COMMON_COMMAND_CONTROL,
			ROCCAT_COMMON_COMMAND_CONTROL,
			&control, sizeof(struct roccat_common_control));
			&control, sizeof(struct roccat_common2_control));
}
}


static int koneplus_get_info(struct usb_device *usb_dev,
static int koneplus_get_info(struct usb_device *usb_dev,
		struct koneplus_info *buf)
		struct koneplus_info *buf)
{
{
	return roccat_common_receive(usb_dev, KONEPLUS_COMMAND_INFO,
	return roccat_common2_receive(usb_dev, KONEPLUS_COMMAND_INFO,
			buf, sizeof(struct koneplus_info));
			buf, sizeof(struct koneplus_info));
}
}


@@ -72,14 +72,14 @@ static int koneplus_get_profile_settings(struct usb_device *usb_dev,
	if (retval)
	if (retval)
		return retval;
		return retval;


	return roccat_common_receive(usb_dev, KONEPLUS_COMMAND_PROFILE_SETTINGS,
	return roccat_common2_receive(usb_dev, KONEPLUS_COMMAND_PROFILE_SETTINGS,
			buf, sizeof(struct koneplus_profile_settings));
			buf, sizeof(struct koneplus_profile_settings));
}
}


static int koneplus_set_profile_settings(struct usb_device *usb_dev,
static int koneplus_set_profile_settings(struct usb_device *usb_dev,
		struct koneplus_profile_settings const *settings)
		struct koneplus_profile_settings const *settings)
{
{
	return roccat_common_send_with_status(usb_dev,
	return roccat_common2_send_with_status(usb_dev,
			KONEPLUS_COMMAND_PROFILE_SETTINGS,
			KONEPLUS_COMMAND_PROFILE_SETTINGS,
			settings, sizeof(struct koneplus_profile_settings));
			settings, sizeof(struct koneplus_profile_settings));
}
}
@@ -94,14 +94,14 @@ static int koneplus_get_profile_buttons(struct usb_device *usb_dev,
	if (retval)
	if (retval)
		return retval;
		return retval;


	return roccat_common_receive(usb_dev, KONEPLUS_COMMAND_PROFILE_BUTTONS,
	return roccat_common2_receive(usb_dev, KONEPLUS_COMMAND_PROFILE_BUTTONS,
			buf, sizeof(struct koneplus_profile_buttons));
			buf, sizeof(struct koneplus_profile_buttons));
}
}


static int koneplus_set_profile_buttons(struct usb_device *usb_dev,
static int koneplus_set_profile_buttons(struct usb_device *usb_dev,
		struct koneplus_profile_buttons const *buttons)
		struct koneplus_profile_buttons const *buttons)
{
{
	return roccat_common_send_with_status(usb_dev,
	return roccat_common2_send_with_status(usb_dev,
			KONEPLUS_COMMAND_PROFILE_BUTTONS,
			KONEPLUS_COMMAND_PROFILE_BUTTONS,
			buttons, sizeof(struct koneplus_profile_buttons));
			buttons, sizeof(struct koneplus_profile_buttons));
}
}
@@ -112,7 +112,7 @@ static int koneplus_get_actual_profile(struct usb_device *usb_dev)
	struct koneplus_actual_profile buf;
	struct koneplus_actual_profile buf;
	int retval;
	int retval;


	retval = roccat_common_receive(usb_dev, KONEPLUS_COMMAND_ACTUAL_PROFILE,
	retval = roccat_common2_receive(usb_dev, KONEPLUS_COMMAND_ACTUAL_PROFILE,
			&buf, sizeof(struct koneplus_actual_profile));
			&buf, sizeof(struct koneplus_actual_profile));


	return retval ? retval : buf.actual_profile;
	return retval ? retval : buf.actual_profile;
@@ -127,7 +127,7 @@ static int koneplus_set_actual_profile(struct usb_device *usb_dev,
	buf.size = sizeof(struct koneplus_actual_profile);
	buf.size = sizeof(struct koneplus_actual_profile);
	buf.actual_profile = new_profile;
	buf.actual_profile = new_profile;


	return roccat_common_send_with_status(usb_dev,
	return roccat_common2_send_with_status(usb_dev,
			KONEPLUS_COMMAND_ACTUAL_PROFILE,
			KONEPLUS_COMMAND_ACTUAL_PROFILE,
			&buf, sizeof(struct koneplus_actual_profile));
			&buf, sizeof(struct koneplus_actual_profile));
}
}
@@ -149,7 +149,7 @@ static ssize_t koneplus_sysfs_read(struct file *fp, struct kobject *kobj,
		return -EINVAL;
		return -EINVAL;


	mutex_lock(&koneplus->koneplus_lock);
	mutex_lock(&koneplus->koneplus_lock);
	retval = roccat_common_receive(usb_dev, command, buf, real_size);
	retval = roccat_common2_receive(usb_dev, command, buf, real_size);
	mutex_unlock(&koneplus->koneplus_lock);
	mutex_unlock(&koneplus->koneplus_lock);


	if (retval)
	if (retval)
@@ -172,7 +172,7 @@ static ssize_t koneplus_sysfs_write(struct file *fp, struct kobject *kobj,
		return -EINVAL;
		return -EINVAL;


	mutex_lock(&koneplus->koneplus_lock);
	mutex_lock(&koneplus->koneplus_lock);
	retval = roccat_common_send_with_status(usb_dev, command,
	retval = roccat_common2_send_with_status(usb_dev, command,
			buf, real_size);
			buf, real_size);
	mutex_unlock(&koneplus->koneplus_lock);
	mutex_unlock(&koneplus->koneplus_lock);


Loading