public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] platform: add support for samsung nc210/nc110
@ 2011-04-20  5:07 Jason Stubbs
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Stubbs @ 2011-04-20  5:07 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-kernel

From: Jason Stubbs <jasonbstubbs@gmail.com>

Note, I don't expect this patch to go in and would actually just like some
feedback on how to better handle the set_brightness problem. Note also that
this patch won't apply on top of my brightness min/max fixes patch and I'll
redo this one as necessary.

This patch adds support for the NC210/NC110 to the samsung-laptop driver.

All SABI commands except for set_brightness work as expected. The behaviour
of set_brightness is as follows:

- Setting a new brightness will only step one level toward the new brightness
  level. For example, setting a level of 5 when the current level is 2 will
  result in a brightness level of 3.
- A spurious KEY_BRIGHTNESS_UP or KEY_BRIGHTNESS_DOWN event is also generated
  along with the change in brightness.
- Neither of the above two issues occur when changing from/to brightness level 0.

The changes in set_brightness() work around the above while attempting to
minimize flicker due to jumping to and from brightness level 0.

Signed-off-by: Jason Stubbs <jasonbstubbs@gmail.com>
---
diff --git a/drivers/platform/x86/samsung-laptop.c b/drivers/platform/x86/samsung-laptop.c
index d347116..01d5278 100644
--- a/drivers/platform/x86/samsung-laptop.c
+++ b/drivers/platform/x86/samsung-laptop.c
@@ -380,6 +380,14 @@ static void set_brightness(u8 user_brightness)
 {
 	u8 user_level = user_brightness - sabi_config->min_brightness;
 
+	if (user_level == read_brightness()) {
+		return;
+	}
+
+	if (sabi_config->min_brightness == 0 && user_level != 0) {
+		sabi_set_command(sabi_config->commands.set_brightness, 0);
+	}
+
 	sabi_set_command(sabi_config->commands.set_brightness, user_level);
 }
 
@@ -666,6 +674,15 @@ static struct dmi_system_id __initdata samsung_dmi_table[] = {
 		},
 		.callback = dmi_check_cb,
 	},
+	{
+		.ident = "NC210/NC110",
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "NC210/NC110"),
+			DMI_MATCH(DMI_BOARD_NAME, "NC210/NC110"),
+		},
+		.callback = dmi_check_cb,
+	},
 	{ },
 };
 MODULE_DEVICE_TABLE(dmi, samsung_dmi_table);

^ permalink raw reply related	[flat|nested] 2+ messages in thread
* [PATCH] platform: fix samsung brightness min/max calculations
@ 2011-04-20  3:58 Jason Stubbs
  2011-05-12 16:44 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Jason Stubbs @ 2011-04-20  3:58 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-kernel

From: Jason Stubbs <jasonbstubbs@gmail.com>

For one of the SABI configs, the valid brightness levels are 1 through 8 with
0 being reserved for the BIOS. To make the range 0-based, the driver is meant
to offset values to/from userspace by 1 giving valid levels of 0 through 7.

This patch fixes the reporting of the maximum level and the interpretation of
the value passed from userspace as per the above logic. It also fixes the
assumption that min_brightness will be either 0 or 1.

Signed-off-by: Jason Stubbs <jasonbstubbs@gmail.com>
---
diff --git a/drivers/platform/x86/samsung-laptop.c 
b/drivers/platform/x86/samsung-laptop.c
index d347116..ebf1b07 100644
--- a/drivers/platform/x86/samsung-laptop.c
+++ b/drivers/platform/x86/samsung-laptop.c
@@ -370,15 +370,17 @@ static u8 read_brightness(void)
 				  &sretval);
 	if (!retval) {
 		user_brightness = sretval.retval[0];
-		if (user_brightness != 0)
+		if (user_brightness > sabi_config->min_brightness)
 			user_brightness -= sabi_config->min_brightness;
+		else
+			user_brightness = 0;
 	}
 	return user_brightness;
 }
 
 static void set_brightness(u8 user_brightness)
 {
-	u8 user_level = user_brightness - sabi_config->min_brightness;
+	u8 user_level = user_brightness + sabi_config->min_brightness;
 
 	sabi_set_command(sabi_config->commands.set_brightness, user_level);
 }
@@ -782,7 +784,8 @@ static int __init samsung_init(void)
 	/* create a backlight device to talk to this one */
 	memset(&props, 0, sizeof(struct backlight_properties));
 	props.type = BACKLIGHT_PLATFORM;
-	props.max_brightness = sabi_config->max_brightness;
+	props.max_brightness = sabi_config->max_brightness -
+				sabi_config->min_brightness;
 	backlight_device = backlight_device_register("samsung", &sdev->dev,
 						     NULL, &backlight_ops,
 						     &props);

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-05-13 10:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-20  5:07 [PATCH] platform: add support for samsung nc210/nc110 Jason Stubbs
  -- strict thread matches above, loose matches on Subject: below --
2011-04-20  3:58 [PATCH] platform: fix samsung brightness min/max calculations Jason Stubbs
2011-05-12 16:44 ` Greg KH
2011-05-13 10:44   ` Jason Stubbs
2011-05-13 10:47     ` [PATCH] platform: add support for samsung nc210/nc110 Jason Stubbs

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox