mirror of
https://github.com/wessel-novacustom/clevo-keyboard.git
synced 2024-11-15 03:34:01 +01:00
tuxedo_io: Add uw perf prof ioctl interface
This commit is contained in:
parent
ad8d42454e
commit
feca6dbcf4
|
@ -358,6 +358,41 @@ static int uw_set_tdp(u8 tdp_index, u8 tdp_data)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set profile 1-3 to 0xa0, 0x00 or 0x10 depending on
|
||||||
|
* device support.
|
||||||
|
*/
|
||||||
|
static u32 uw_set_performance_profile_v1(u8 profile_index)
|
||||||
|
{
|
||||||
|
u8 current_value = 0x00, next_value;
|
||||||
|
u8 clear_bits = 0xa0 | 0x10;
|
||||||
|
u32 result;
|
||||||
|
result = uniwill_read_ec_ram(0x0751, ¤t_value);
|
||||||
|
if (result >= 0) {
|
||||||
|
next_value = current_value & ~clear_bits;
|
||||||
|
switch (profile_index) {
|
||||||
|
case 0x01:
|
||||||
|
next_value |= 0xa0;
|
||||||
|
break;
|
||||||
|
case 0x02:
|
||||||
|
next_value |= 0x00;
|
||||||
|
break;
|
||||||
|
case 0x03:
|
||||||
|
next_value |= 0x10;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
result = -EINVAL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result != -EINVAL) {
|
||||||
|
result = uniwill_write_ec_ram(0x0751, next_value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
static long uniwill_ioctl_interface(struct file *file, unsigned int cmd, unsigned long arg)
|
static long uniwill_ioctl_interface(struct file *file, unsigned int cmd, unsigned long arg)
|
||||||
{
|
{
|
||||||
u32 result = 0;
|
u32 result = 0;
|
||||||
|
@ -452,6 +487,14 @@ static long uniwill_ioctl_interface(struct file *file, unsigned int cmd, unsigne
|
||||||
result = uw_get_tdp_max(2);
|
result = uw_get_tdp_max(2);
|
||||||
copy_result = copy_to_user((void *) arg, &result, sizeof(result));
|
copy_result = copy_to_user((void *) arg, &result, sizeof(result));
|
||||||
break;
|
break;
|
||||||
|
case R_UW_PROFS_AVAILABLE:
|
||||||
|
result = 0;
|
||||||
|
if (uniwill_profile_v1_two_profs)
|
||||||
|
result = 2;
|
||||||
|
else if (uniwill_profile_v1_three_profs)
|
||||||
|
result = 3;
|
||||||
|
copy_result = copy_to_user((void *) arg, &result, sizeof(result));
|
||||||
|
break;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
case R_TF_BC:
|
case R_TF_BC:
|
||||||
|
@ -508,6 +551,10 @@ static long uniwill_ioctl_interface(struct file *file, unsigned int cmd, unsigne
|
||||||
copy_result = copy_from_user(&argument, (int32_t *) arg, sizeof(argument));
|
copy_result = copy_from_user(&argument, (int32_t *) arg, sizeof(argument));
|
||||||
uw_set_tdp(2, argument);
|
uw_set_tdp(2, argument);
|
||||||
break;
|
break;
|
||||||
|
case W_UW_PERF_PROF:
|
||||||
|
copy_result = copy_from_user(&argument, (int32_t *) arg, sizeof(argument));
|
||||||
|
uw_set_performance_profile_v1(argument);
|
||||||
|
break;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
case W_TF_BC:
|
case W_TF_BC:
|
||||||
reg_write_return.dword = 0;
|
reg_write_return.dword = 0;
|
||||||
|
|
|
@ -90,6 +90,8 @@
|
||||||
#define R_UW_TDP1_MAX _IOR(MAGIC_READ_UW, 0x1d, int32_t*)
|
#define R_UW_TDP1_MAX _IOR(MAGIC_READ_UW, 0x1d, int32_t*)
|
||||||
#define R_UW_TDP2_MAX _IOR(MAGIC_READ_UW, 0x1e, int32_t*)
|
#define R_UW_TDP2_MAX _IOR(MAGIC_READ_UW, 0x1e, int32_t*)
|
||||||
|
|
||||||
|
#define R_UW_PROFS_AVAILABLE _IOR(MAGIC_READ_UW, 0x1f, int32_t*)
|
||||||
|
|
||||||
// Write
|
// Write
|
||||||
#define W_UW_FANSPEED _IOW(MAGIC_WRITE_UW, 0x10, int32_t*)
|
#define W_UW_FANSPEED _IOW(MAGIC_WRITE_UW, 0x10, int32_t*)
|
||||||
#define W_UW_FANSPEED2 _IOW(MAGIC_WRITE_UW, 0x11, int32_t*)
|
#define W_UW_FANSPEED2 _IOW(MAGIC_WRITE_UW, 0x11, int32_t*)
|
||||||
|
@ -101,4 +103,6 @@
|
||||||
#define W_UW_TDP1 _IOW(MAGIC_WRITE_UW, 0x16, int32_t*)
|
#define W_UW_TDP1 _IOW(MAGIC_WRITE_UW, 0x16, int32_t*)
|
||||||
#define W_UW_TDP2 _IOW(MAGIC_WRITE_UW, 0x17, int32_t*)
|
#define W_UW_TDP2 _IOW(MAGIC_WRITE_UW, 0x17, int32_t*)
|
||||||
|
|
||||||
|
#define W_UW_PERF_PROF _IOW(MAGIC_WRITE_UW, 0x18, int32_t*)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue