[PATCH 5/6] allow setting enable instead of mode, and support enable 2/3/4

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Jaap Aarts <jaap.aarts1@xxxxxxxxxxx>
---
 drivers/hwmon/asetek_gen6.c | 110 ++++++++++++++++++++++++++++++------
 1 file changed, 93 insertions(+), 17 deletions(-)

diff --git a/drivers/hwmon/asetek_gen6.c b/drivers/hwmon/asetek_gen6.c
index d657ecc78908..19f50d5cd179 100644
--- a/drivers/hwmon/asetek_gen6.c
+++ b/drivers/hwmon/asetek_gen6.c
@@ -64,38 +64,100 @@ struct hwmon_data {
 	void **channel_data;
 };
 
-struct curve_point default_curve[] = {
+struct curve_point quiet_curve[] = {
 	{
-		.temp = 0x10,
-		.pwm = 0x19,
+		.temp = 0x1F,
+		.pwm = 0x15,
 	},
 	{
-		.temp = 0x14,
-		.pwm = 0x19,
+		.temp = 0x21,
+		.pwm = 0x1E,
+	},
+	{
+		.temp = 0x24,
+		.pwm = 0x25,
+	},
+	{
+		.temp = 0x27,
+		.pwm = 0x2D,
+	},
+	{
+		.temp = 0x29,
+		.pwm = 0x38,
+	},
+	{
+		.temp = 0x2C,
+		.pwm = 0x4A,
+	},
+	{
+		.temp = 0x2F,
+		.pwm = 0x64,
+	},
+};
+
+struct curve_point balanced_curve[] = {
+	{
+		.temp = 0x1C,
+		.pwm = 0x15,
+	},
+	{
+		.temp = 0x1E,
+		.pwm = 0x1B,
 	},
 	{
 		.temp = 0x20,
-		.pwm = 0x27,
+		.pwm = 0x23,
 	},
 	{
-		.temp = 0x28,
-		.pwm = 0x32,
+		.temp = 0x22,
+		.pwm = 0x28,
 	},
 	{
-		.temp = 0x32,
-		.pwm = 0x4b,
+		.temp = 0x24,
+		.pwm = 0x32,
 	},
 	{
-		.temp = 0x37,
-		.pwm = 0x5a,
+		.temp = 0x27,
+		.pwm = 0x48,
 	},
 	{
-		.temp = 0x3c,
+		.temp = 0x29,
 		.pwm = 0x64,
 	},
+};
 
+struct curve_point extreme_curve[] = {
+	{
+		.temp = 0x19,
+		.pwm = 0x28,
+	},
+	{
+		.temp = 0x1B,
+		.pwm = 0x2E,
+	},
+	{
+		.temp = 0x1D,
+		.pwm = 0x37,
+	},
+	{
+		.temp = 0x1E,
+		.pwm = 0x41,
+	},
+	{
+		.temp = 0x1F,
+		.pwm = 0x4C,
+	},
+	{
+		.temp = 0x20,
+		.pwm = 0x56,
+	},
+	{
+		.temp = 0x21,
+		.pwm = 0x64,
+	},
 };
 
+#define default_curve quiet_curve
 static const char SUCCESS[2] = { 0x12, 0x34 };
 
 #define SUCCES_LENGTH 3
@@ -347,7 +409,7 @@ static int write_func(struct device *dev, enum hwmon_sensor_types type,
 				return retval;
 
 			goto cleanup;
-		case hwmon_pwm_mode:
+		case hwmon_pwm_enable:
 			fan_data = data->channel_data[channel];
 
 			retval = usb_autopm_get_interface(cdev->interface);
@@ -360,10 +422,12 @@ static int write_func(struct device *dev, enum hwmon_sensor_types type,
 			}
 			fan_data->mode = val;
 
-			if (val == 0) {
+			switch (val) {
+			case 0:
 				set_fan_rpm_curve(cdev, fan_data,
 						  default_curve);
-			} else if (val == 1) {
+				break;
+			case 1:
 				if (fan_data->fan_target != 0) {
 					retval = set_fan_target_rpm(
 						cdev, fan_data,
@@ -377,6 +441,18 @@ static int write_func(struct device *dev, enum hwmon_sensor_types type,
 					if (retval)
 						goto cleanup;
 				}
+				break;
+			case 2:
+				set_fan_rpm_curve(cdev, fan_data, quiet_curve);
+				break;
+			case 3:
+				set_fan_rpm_curve(cdev, fan_data,
+						  balanced_curve);
+				break;
+			case 4:
+				set_fan_rpm_curve(cdev, fan_data,
+						  extreme_curve);
+				break;
 			}
 			goto cleanup;
 		default:
@@ -465,7 +541,7 @@ int read_func(struct device *dev, enum hwmon_sensor_types type, u32 attr,
 	return retval;
 }
 #define fan_config HWMON_F_INPUT | HWMON_F_TARGET | HWMON_F_MIN
-#define pwm_config HWMON_PWM_INPUT | HWMON_PWM_MODE
+#define pwm_config HWMON_PWM_INPUT | HWMON_PWM_ENABLE
 
 static const struct hwmon_ops asetek_6_ops = {
 	.is_visible = is_visible_func,
-- 
2.27.0




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux