Re: [systemd-devel] [PATCH] hostnamed: regard convertible chassis type as laptop

2017-02-27 Thread Jani Nikula
On Mon, 27 Feb 2017, David Herrmann <dh.herrm...@gmail.com> wrote:
> Turned into a github PR [1]. Can we continue the discussion there?

Sure thing. Thanks, David!

BR,
Jani.

-- 
Jani Nikula, Intel Open Source Technology Center
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] hostnamed: regard convertible chassis type as laptop

2017-02-24 Thread Jani Nikula
On Fri, 24 Feb 2017, Jani Nikula <jani.nik...@intel.com> wrote:
> While both the DMI and ACPI data are regarded as unreliable in hostnamed
> source, consumers of the chassis type use it to make rather drastic
> policy decisions.

BTW, since the implementation seems to think the data is unreliable,
perhaps it would be prudent to say so in hostnamectl documentation, so
the consumers of the data might be more thoughtful about what to use it
for?

BR,
Jani.


-- 
Jani Nikula, Intel Open Source Technology Center
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] hostnamed: regard convertible chassis type as laptop

2017-02-24 Thread Jani Nikula
Currently the DMI convertible chassis type is disregarded by
hostnamed. The fallback ACPI data might indicate either laptop or
tablet. For example, Lenovo Yoga 910 is convertible per DMI data, but
tablet per ACPI data, and therefore receives tablet chassis type. Regard
convertibles as laptops to avoid the risk of them being labeled as
tablets.

While both the DMI and ACPI data are regarded as unreliable in hostnamed
source, consumers of the chassis type use it to make rather drastic
policy decisions. For example, Gnome forcefully autosuspends all tablet
type machines when the screen is blanked, regardless of other
autosuspend options. Arguably that's a bug in Gnome (and it's being
argued at [1]), but some of the issues there, and elsewhere, can be
mitigated by considering convertibles as laptops here.

[1] https://bugzilla.gnome.org/show_bug.cgi?id=764723

---

Alas, I failed to build systemd, so I'm afraid you'll have to consider
this a bug report more than a real submission. :(
---
 src/hostname/hostnamed.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/hostname/hostnamed.c b/src/hostname/hostnamed.c
index 4657cf8c77b2..bcc3d457403b 100644
--- a/src/hostname/hostnamed.c
+++ b/src/hostname/hostnamed.c
@@ -187,6 +187,7 @@ static const char* fallback_chassis(void) {
 case 0x9: /* Laptop */
 case 0xA: /* Notebook */
 case 0xE: /* Sub Notebook */
+case 0x1F: /* Convertible */
 return "laptop";
 
 case 0xB: /* Hand Held */
-- 
2.1.4

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] backlight: handle saved brightness exceeding max brightness

2014-05-07 Thread Jani Nikula
On Wed, 07 May 2014, Jani Nikula jani.nik...@intel.com wrote:
 If too high a brightness value has been saved (e.g. due to kernel
 mechanism changing from one kernel version to another, or booting the
 userspace on another system), the brightness update fails and the
 process exits.

 Clamp saved brightness between the policy minimum introduced in

 commit 7b909d7407965c03caaba30daae7aee113627a83
 Author: Josh Triplett j...@joshtriplett.org
 Date:   Tue Mar 11 21:16:33 2014 -0700

 backlight: Avoid restoring brightness to an unreadably dim level

 and the absolute maximum.

 ---

 UNCOMPILED AND UNTESTED; please consider this more a bug report than a
 real contribution... Based on reading the source while debugging
 https://bugs.freedesktop.org/show_bug.cgi?id=78200
 ---
  src/backlight/backlight.c | 11 ---
  1 file changed, 8 insertions(+), 3 deletions(-)

 diff --git a/src/backlight/backlight.c b/src/backlight/backlight.c
 index c708391612a2..d48a73e69364 100644
 --- a/src/backlight/backlight.c
 +++ b/src/backlight/backlight.c
 @@ -229,7 +229,7 @@ static unsigned get_max_brightness(struct udev_device 
 *device) {
   * would otherwise force the user to disable state restoration. */
  static void clamp_brightness(struct udev_device *device, char **value, 
 unsigned max_brightness) {
  int r;
 -unsigned brightness, new_brightness;
 +unsigned brightness, new_brightness, min_brightness;
  
  r = safe_atou(*value, brightness);
  if (r  0) {
 @@ -237,7 +237,8 @@ static void clamp_brightness(struct udev_device *device, 
 char **value, unsigned
  return;
  }
  
 -new_brightness = MAX3(brightness, 1U, max_brightness/20);
 +min_brightness = MAX(1U, max_brightness/20);
 +new_brightness = CLAMP(brightness, min_brightness, max_brightness);
  if (new_brightness != brightness) {
  char *old_value = *value;
  
 @@ -247,7 +248,11 @@ static void clamp_brightness(struct udev_device *device, 
 char **value, unsigned
  return;
  }
  
 -log_debug(Saved brightness %s too low; increasing to %s., 
 old_value, *value);
 +log_debug(Saved brightness %s %s to %s., old_value,
 +  new_brightness  min_brightness ?

Should be brightness  min_brightness; the above is never true.

 +  too low; increasing : too high; decreasing,
 +  *value);
 +
  free(old_value);
  }
  }
 -- 
 1.9.1


-- 
Jani Nikula, Intel Open Source Technology Center
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel