All of lore.kernel.org
 help / color / mirror / Atom feed
From: Aaron Lu <aaron.lu@intel.com>
To: linux-acpi@vger.kernel.org, intel-gfx@lists.freedesktop.org,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Cc: "Daniel Vetter" <daniel@ffwll.ch>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	"Matthew Garrett" <matthew.garrett@nebula.com>,
	"Seth Forshee" <seth.forshee@canonical.com>,
	"Lee Chun-Yi" <joeyli.kernel@gmail.com>,
	"Richard Purdie" <rpurdie@rpsys.net>,
	"Igor Gnatenko" <i.gnatenko.brain@gmail.com>,
	"Yves-Alexis Perez" <corsac@debian.org>,
	"Felipe Contreras" <felipe.contreras@gmail.com>,
	"Jani Nikula" <jani.nikula@linux.intel.com>,
	"Aaron Lu" <aaron.lu@intel.com>, "Ben Jencks" <ben@bjencks.net>,
	"Steven Newbury" <steve@snewbury.org.uk>,
	"James Hogan" <james@albanarts.com>,
	"Kamal Mostafa" <kamal@canonical.com>,
	"Joerg Platte" <jplatte@naasa.net>,
	"Kalle Valo" <kvalo@adurom.com>,
	"Martin Steigerwald" <Martin@lichtvoll.de>,
	"Jörg Otte" <jrg.otte@gmail.com>,
	"Mike Galbraith" <bitbucket@online.de>,
	platform-driver-x86@vger.kernel.org,
	"Mika Westerberg" <mika.westerberg@linux.intel.com>
Subject: [PATCH v5 1/4] backlight: introduce backlight_device_registered
Date: Fri, 11 Oct 2013 21:27:43 +0800	[thread overview]
Message-ID: <1381498066-16011-2-git-send-email-aaron.lu@intel.com> (raw)
In-Reply-To: <1381498066-16011-1-git-send-email-aaron.lu@intel.com>

Introduce a new API for modules to query if a specific type of backlight
device has been registered. This is useful for some backlight device
provider module(e.g. ACPI video) to know if a native control
interface(e.g. the interface created by i915) is available and then do
things accordingly(e.g. avoid register its own on Win8 systems).

Signed-off-by: Aaron Lu <aaron.lu@intel.com>
---
 drivers/video/backlight/backlight.c | 31 +++++++++++++++++++++++++++++++
 include/linux/backlight.h           |  4 ++++
 2 files changed, 35 insertions(+)

diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
index 94a403a..5d05555 100644
--- a/drivers/video/backlight/backlight.c
+++ b/drivers/video/backlight/backlight.c
@@ -21,6 +21,9 @@
 #include <asm/backlight.h>
 #endif
 
+static struct list_head backlight_dev_list;
+static struct mutex backlight_dev_list_mutex;
+
 static const char *const backlight_types[] = {
 	[BACKLIGHT_RAW] = "raw",
 	[BACKLIGHT_PLATFORM] = "platform",
@@ -349,10 +352,32 @@ struct backlight_device *backlight_device_register(const char *name,
 	mutex_unlock(&pmac_backlight_mutex);
 #endif
 
+	mutex_lock(&backlight_dev_list_mutex);
+	list_add(&new_bd->entry, &backlight_dev_list);
+	mutex_unlock(&backlight_dev_list_mutex);
+
 	return new_bd;
 }
 EXPORT_SYMBOL(backlight_device_register);
 
+bool backlight_device_registered(enum backlight_type type)
+{
+	bool found = false;
+	struct backlight_device *bd;
+
+	mutex_lock(&backlight_dev_list_mutex);
+	list_for_each_entry(bd, &backlight_dev_list, entry) {
+		if (bd->props.type == type) {
+			found = true;
+			break;
+		}
+	}
+	mutex_unlock(&backlight_dev_list_mutex);
+
+	return found;
+}
+EXPORT_SYMBOL(backlight_device_registered);
+
 /**
  * backlight_device_unregister - unregisters a backlight device object.
  * @bd: the backlight device object to be unregistered and freed.
@@ -364,6 +389,10 @@ void backlight_device_unregister(struct backlight_device *bd)
 	if (!bd)
 		return;
 
+	mutex_lock(&backlight_dev_list_mutex);
+	list_del(&bd->entry);
+	mutex_unlock(&backlight_dev_list_mutex);
+
 #ifdef CONFIG_PMAC_BACKLIGHT
 	mutex_lock(&pmac_backlight_mutex);
 	if (pmac_backlight == bd)
@@ -499,6 +528,8 @@ static int __init backlight_class_init(void)
 
 	backlight_class->dev_groups = bl_device_groups;
 	backlight_class->pm = &backlight_class_dev_pm_ops;
+	INIT_LIST_HEAD(&backlight_dev_list);
+	mutex_init(&backlight_dev_list_mutex);
 	return 0;
 }
 
diff --git a/include/linux/backlight.h b/include/linux/backlight.h
index 53b7794..5f9cd96 100644
--- a/include/linux/backlight.h
+++ b/include/linux/backlight.h
@@ -100,6 +100,9 @@ struct backlight_device {
 	/* The framebuffer notifier block */
 	struct notifier_block fb_notif;
 
+	/* list entry of all registered backlight devices */
+	struct list_head entry;
+
 	struct device dev;
 };
 
@@ -123,6 +126,7 @@ extern void devm_backlight_device_unregister(struct device *dev,
 					struct backlight_device *bd);
 extern void backlight_force_update(struct backlight_device *bd,
 				   enum backlight_update_reason reason);
+extern bool backlight_device_registered(enum backlight_type type);
 
 #define to_backlight_device(obj) container_of(obj, struct backlight_device, dev)
 
-- 
1.8.4.12.g2ea3df6

WARNING: multiple messages have this Message-ID (diff)
From: Aaron Lu <aaron.lu@intel.com>
To: linux-acpi@vger.kernel.org, intel-gfx@lists.freedesktop.org,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Cc: "Daniel Vetter" <daniel@ffwll.ch>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	"Matthew Garrett" <matthew.garrett@nebula.com>,
	"Seth Forshee" <seth.forshee@canonical.com>,
	"Lee Chun-Yi" <joeyli.kernel@gmail.com>,
	"Richard Purdie" <rpurdie@rpsys.net>,
	"Igor Gnatenko" <i.gnatenko.brain@gmail.com>,
	"Yves-Alexis Perez" <corsac@debian.org>,
	"Felipe Contreras" <felipe.contreras@gmail.com>,
	"Jani Nikula" <jani.nikula@linux.intel.com>,
	"Aaron Lu" <aaron.lu@intel.com>, "Ben Jencks" <ben@bjencks.net>,
	"Steven Newbury" <steve@snewbury.org.uk>,
	"James Hogan" <james@albanarts.com>,
	"Kamal Mostafa" <kamal@canonical.com>,
	"Joerg Platte" <jplatte@naasa.net>,
	"Kalle Valo" <kvalo@adurom.com>,
	"Martin Steigerwald" <Martin@lichtvoll.de>,
	"Jörg Otte" <jrg.otte@gmail.com>,
	"Mike Galbraith" <bitbucket@online.de>,
	platform-driver-x86@vger.kernel.org,
	"Mika Westerberg" <mika.westerberg@linux.intel.com>,
	"Henrique de Moraes Holschuh" <hmh@hmh.eng.br>
Subject: [PATCH v5 1/4] backlight: introduce backlight_device_registered
Date: Fri, 11 Oct 2013 21:27:43 +0800	[thread overview]
Message-ID: <1381498066-16011-2-git-send-email-aaron.lu@intel.com> (raw)
In-Reply-To: <1381498066-16011-1-git-send-email-aaron.lu@intel.com>

Introduce a new API for modules to query if a specific type of backlight
device has been registered. This is useful for some backlight device
provider module(e.g. ACPI video) to know if a native control
interface(e.g. the interface created by i915) is available and then do
things accordingly(e.g. avoid register its own on Win8 systems).

Signed-off-by: Aaron Lu <aaron.lu@intel.com>
---
 drivers/video/backlight/backlight.c | 31 +++++++++++++++++++++++++++++++
 include/linux/backlight.h           |  4 ++++
 2 files changed, 35 insertions(+)

diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
index 94a403a..5d05555 100644
--- a/drivers/video/backlight/backlight.c
+++ b/drivers/video/backlight/backlight.c
@@ -21,6 +21,9 @@
 #include <asm/backlight.h>
 #endif
 
+static struct list_head backlight_dev_list;
+static struct mutex backlight_dev_list_mutex;
+
 static const char *const backlight_types[] = {
 	[BACKLIGHT_RAW] = "raw",
 	[BACKLIGHT_PLATFORM] = "platform",
@@ -349,10 +352,32 @@ struct backlight_device *backlight_device_register(const char *name,
 	mutex_unlock(&pmac_backlight_mutex);
 #endif
 
+	mutex_lock(&backlight_dev_list_mutex);
+	list_add(&new_bd->entry, &backlight_dev_list);
+	mutex_unlock(&backlight_dev_list_mutex);
+
 	return new_bd;
 }
 EXPORT_SYMBOL(backlight_device_register);
 
+bool backlight_device_registered(enum backlight_type type)
+{
+	bool found = false;
+	struct backlight_device *bd;
+
+	mutex_lock(&backlight_dev_list_mutex);
+	list_for_each_entry(bd, &backlight_dev_list, entry) {
+		if (bd->props.type == type) {
+			found = true;
+			break;
+		}
+	}
+	mutex_unlock(&backlight_dev_list_mutex);
+
+	return found;
+}
+EXPORT_SYMBOL(backlight_device_registered);
+
 /**
  * backlight_device_unregister - unregisters a backlight device object.
  * @bd: the backlight device object to be unregistered and freed.
@@ -364,6 +389,10 @@ void backlight_device_unregister(struct backlight_device *bd)
 	if (!bd)
 		return;
 
+	mutex_lock(&backlight_dev_list_mutex);
+	list_del(&bd->entry);
+	mutex_unlock(&backlight_dev_list_mutex);
+
 #ifdef CONFIG_PMAC_BACKLIGHT
 	mutex_lock(&pmac_backlight_mutex);
 	if (pmac_backlight == bd)
@@ -499,6 +528,8 @@ static int __init backlight_class_init(void)
 
 	backlight_class->dev_groups = bl_device_groups;
 	backlight_class->pm = &backlight_class_dev_pm_ops;
+	INIT_LIST_HEAD(&backlight_dev_list);
+	mutex_init(&backlight_dev_list_mutex);
 	return 0;
 }
 
diff --git a/include/linux/backlight.h b/include/linux/backlight.h
index 53b7794..5f9cd96 100644
--- a/include/linux/backlight.h
+++ b/include/linux/backlight.h
@@ -100,6 +100,9 @@ struct backlight_device {
 	/* The framebuffer notifier block */
 	struct notifier_block fb_notif;
 
+	/* list entry of all registered backlight devices */
+	struct list_head entry;
+
 	struct device dev;
 };
 
@@ -123,6 +126,7 @@ extern void devm_backlight_device_unregister(struct device *dev,
 					struct backlight_device *bd);
 extern void backlight_force_update(struct backlight_device *bd,
 				   enum backlight_update_reason reason);
+extern bool backlight_device_registered(enum backlight_type type);
 
 #define to_backlight_device(obj) container_of(obj, struct backlight_device, dev)
 
-- 
1.8.4.12.g2ea3df6


  reply	other threads:[~2013-10-11 13:27 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-11 13:27 [PATCH v5 0/4] Fix Win8 backlight issue Aaron Lu
2013-10-11 13:27 ` Aaron Lu
2013-10-11 13:27 ` Aaron Lu [this message]
2013-10-11 13:27   ` [PATCH v5 1/4] backlight: introduce backlight_device_registered Aaron Lu
2013-10-11 13:27 ` [PATCH v5 2/4] ACPI / video: seperate backlight control and event interface Aaron Lu
2013-10-11 13:27   ` Aaron Lu
2013-10-11 13:27 ` [PATCH v5 3/4] ACPI / video: Do not register backlight if win8 and native interface exists Aaron Lu
2013-10-11 13:27   ` Aaron Lu
2013-10-11 13:27 ` [PATCH v5 4/4] thinkpad-acpi: fix handle locate for video and query of _BCL Aaron Lu
2013-10-11 13:27   ` Aaron Lu
2013-10-11 16:42 ` [PATCH v5 0/4] Fix Win8 backlight issue Josh Boyer
2013-10-11 21:01   ` Igor Gnatenko
2013-10-11 22:10   ` Rafael J. Wysocki
2013-10-11 22:01     ` Josh Boyer
2013-10-11 22:45       ` Rafael J. Wysocki
2013-10-11 22:53         ` Igor Gnatenko
2013-10-11 23:10           ` Rafael J. Wysocki
2013-10-11 23:27       ` Rafael J. Wysocki
2013-10-12  5:54         ` Yves-Alexis Perez
2013-10-12  5:54           ` Yves-Alexis Perez
2013-10-12 14:10           ` Rafael J. Wysocki
2013-10-12 14:10             ` Rafael J. Wysocki
2013-10-12 11:44         ` Josh Boyer
2013-10-12 13:34           ` Seth Forshee
2013-10-12 14:08             ` Rafael J. Wysocki
2013-10-12  6:00     ` Yves-Alexis Perez
2013-10-12  6:00       ` Yves-Alexis Perez
2013-10-12 11:47       ` Josh Boyer
2013-10-15 23:33 ` Rafael J. Wysocki
2013-10-15 23:33   ` Rafael J. Wysocki
2013-10-24  8:13   ` Aaron Lu
2013-10-25  6:35     ` Igor Gnatenko
2013-10-28  2:45       ` Aaron Lu
2013-10-28  8:09         ` Jani Nikula
2013-10-29  7:18           ` Aaron Lu
2013-11-15  6:07             ` [PATCH v2] ACPI / video: Add systems that should favor native backlight interface Aaron Lu
2013-11-20 20:56               ` Igor Gnatenko
2013-11-21  5:29                 ` [PATCH v2 rebased] " Aaron Lu
2013-12-24 12:20                   ` Igor Gnatenko
2013-12-24 13:59                   ` Igor Gnatenko
2013-10-30  0:40   ` [PATCH v5 0/4] Fix Win8 backlight issue Matthew Garrett
2013-10-30  0:56     ` Rafael J. Wysocki

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=1381498066-16011-2-git-send-email-aaron.lu@intel.com \
    --to=aaron.lu@intel.com \
    --cc=Martin@lichtvoll.de \
    --cc=ben@bjencks.net \
    --cc=bitbucket@online.de \
    --cc=corsac@debian.org \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=felipe.contreras@gmail.com \
    --cc=i.gnatenko.brain@gmail.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=james@albanarts.com \
    --cc=jani.nikula@linux.intel.com \
    --cc=joeyli.kernel@gmail.com \
    --cc=jplatte@naasa.net \
    --cc=jrg.otte@gmail.com \
    --cc=kamal@canonical.com \
    --cc=kvalo@adurom.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matthew.garrett@nebula.com \
    --cc=mika.westerberg@linux.intel.com \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=rpurdie@rpsys.net \
    --cc=seth.forshee@canonical.com \
    --cc=steve@snewbury.org.uk \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.