X86 platform drivers
 help / color / mirror / Atom feed
From: Mattia Dongili <malattia@linux.it>
To: Matthew Garrett <mjg59@srcf.ucam.org>
Cc: platform-driver-x86@vger.kernel.org,
	Mattia Dongili <malattia@linux.it>,
	Jingoo Han <jg1.han@samsung.com>
Subject: [PATCH 09/11] backlight: introduce inter-driver notification of changes
Date: Fri, 21 Mar 2014 08:01:20 +0900	[thread overview]
Message-ID: <1395356482-7446-10-git-send-email-malattia@linux.it> (raw)
In-Reply-To: <1395356482-7446-1-git-send-email-malattia@linux.it>

Allow registered backlight drivers to receive a notification when a
backlight change is triggered via one of the siblings.
sony-laptop needs this notification to be able to set backlight when ALS
is enabled and setting brightness via _BCM becomes a no-op and only
notifies SNC that "a change to the brightness level" was requested
without giving any actual value.

Cc: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Mattia Dongili <malattia@linux.it>
---
 drivers/video/backlight/backlight.c | 10 ++++++++++
 include/linux/backlight.h           |  3 +++
 2 files changed, 13 insertions(+)

diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
index 5d05555..0f9d6ce 100644
--- a/drivers/video/backlight/backlight.c
+++ b/drivers/video/backlight/backlight.c
@@ -88,6 +88,7 @@ static inline void backlight_unregister_fb(struct backlight_device *bd)
 static void backlight_generate_event(struct backlight_device *bd,
 				     enum backlight_update_reason reason)
 {
+	struct backlight_device *obd;
 	char *envp[2];
 
 	switch (reason) {
@@ -104,6 +105,15 @@ static void backlight_generate_event(struct backlight_device *bd,
 	envp[1] = NULL;
 	kobject_uevent_env(&bd->dev.kobj, KOBJ_CHANGE, envp);
 	sysfs_notify(&bd->dev.kobj, NULL, "actual_brightness");
+
+	/* notify other bl devices */
+	list_for_each_entry(obd, &backlight_dev_list, entry) {
+		if (bd == obd || !obd->ops || !obd->ops->brightness_changed)
+			continue;
+
+		obd->ops->brightness_changed(obd, bd->props.brightness,
+				bd->props.max_brightness);
+	}
 }
 
 static ssize_t bl_power_show(struct device *dev, struct device_attribute *attr,
diff --git a/include/linux/backlight.h b/include/linux/backlight.h
index 5f9cd96..974ae3c 100644
--- a/include/linux/backlight.h
+++ b/include/linux/backlight.h
@@ -55,6 +55,9 @@ struct backlight_ops {
 	/* Check if given framebuffer device is the one bound to this backlight;
 	   return 0 if not, !=0 if it is. If NULL, backlight always matches the fb. */
 	int (*check_fb)(struct backlight_device *, struct fb_info *);
+	/* Callback to receive notification of a backlight change triggered by
+	   a different backlight driver */
+	void (*brightness_changed)(struct backlight_device *, int, int);
 };
 
 /* This structure defines all the properties of a backlight */
-- 
1.9.0

  parent reply	other threads:[~2014-03-20 23:09 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-20 23:01 [PATCH 00/11] ALS and other new functions Mattia Dongili
2014-03-20 23:01 ` [PATCH 01/11] sony-laptop: add support as Fn+1 as a hot key Mattia Dongili
2014-03-20 23:01 ` [PATCH 02/11] sony-laptop: Add support for lid resume settings on Vaio Pro Mattia Dongili
2014-03-20 23:01 ` [PATCH 03/11] sony-laptop: add panel_id function Mattia Dongili
2014-03-20 23:01 ` [PATCH 04/11] sony-laptop: add usb charge function Mattia Dongili
2014-03-20 23:01 ` [PATCH 05/11] sony-laptop: add fan speed regulation function Mattia Dongili
2014-03-20 23:01 ` [PATCH 06/11] sony-laptop: add hibernate on low battery function Mattia Dongili
2014-03-20 23:01 ` [PATCH 07/11] sony-laptop: adjust keyboard backlight values for off/auto/on Mattia Dongili
2014-03-20 23:01 ` [PATCH 08/11] sony-laptop: add smart connect control function Mattia Dongili
2014-03-20 23:01 ` Mattia Dongili [this message]
     [not found] ` <1395356482-7446-1-git-send-email-malattia-k2GhghHVRtY@public.gmane.org>
2014-03-20 23:01   ` [PATCH 10/11] sony-laptop: als support Mattia Dongili
2014-03-23 19:32     ` Jonathan Cameron
2014-03-24 23:06       ` Mattia Dongili
     [not found]         ` <20140324230607.GA2035-K/RcPn9UbNN4Eiagz67IpQ@public.gmane.org>
2014-03-25  6:50           ` Jonathan Cameron
2014-03-25 11:57       ` Javier Achirica
2014-03-20 23:01 ` [PATCH 11/11] sony-laptop: remove useless sony-laptop versioning Mattia Dongili
2014-03-27 21:23 ` [PATCH 00/11] ALS and other new functions Mattia Dongili

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1395356482-7446-10-git-send-email-malattia@linux.it \
    --to=malattia@linux.it \
    --cc=jg1.han@samsung.com \
    --cc=mjg59@srcf.ucam.org \
    --cc=platform-driver-x86@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox