From: ykzhao <yakui.zhao@intel.com>
To: Matthew Garrett <mjg@redhat.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-acpi@vger.kernel.org" <linux-acpi@vger.kernel.org>,
"rpurdie@rpsys.net" <rpurdie@rpsys.net>,
"lenb@kernel.org" <lenb@kernel.org>,
"Zhang, Rui" <rui.zhang@intel.com>,
"corentincj@iksaif.net" <corentincj@iksaif.net>
Subject: Re: [PATCH 1/3] backlight: Allow drivers to update the core, and generate events on changes
Date: Tue, 14 Jul 2009 08:58:48 +0800 [thread overview]
Message-ID: <1247533128.3704.9.camel@localhost.localdomain> (raw)
In-Reply-To: <1247517685-7719-1-git-send-email-mjg@redhat.com>
On Tue, 2009-07-14 at 04:41 +0800, Matthew Garrett wrote:
> Certain hardware will send us events when the backlight brightness
> changes. Add a function to update the value in the core, and
> additionally send a uevent so that userspace can pop up appropriate
> UI. The uevents are flagged depending on whether the update originated
> in the kernel or from userspace, making it easier to only display UI
> at the appropriate time.
>
> Signed-off-by: Matthew Garrett <mjg@redhat.com>
> ---
> drivers/video/backlight/backlight.c | 23 +++++++++++++++++++++++
> include/linux/backlight.h | 1 +
> 2 files changed, 24 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
> index 157057c..98ab76c 100644
> --- a/drivers/video/backlight/backlight.c
> +++ b/drivers/video/backlight/backlight.c
> @@ -120,6 +120,7 @@ static ssize_t backlight_store_brightness(struct device *dev,
> {
> int rc;
> struct backlight_device *bd = to_backlight_device(dev);
> + char *envp[] = { "SOURCE=userspace", NULL };
> unsigned long brightness;
>
> rc = strict_strtoul(buf, 0, &brightness);
> @@ -142,6 +143,8 @@ static ssize_t backlight_store_brightness(struct device *dev,
> }
> mutex_unlock(&bd->ops_lock);
>
> + kobject_uevent_env(&bd->dev.kobj, KOBJ_CHANGE, envp);
> +
It will be better to send the event to user space only when the
brightness is updated successfully.
> return rc;
> }
>
> @@ -214,6 +217,26 @@ static struct device_attribute bl_device_attributes[] = {
> };
>
> /**
> + * backlight_force_update - tell the backlight subsystem that hardware state
> + * has changed
> + * @bd: the backlight device to update
> + *
> + * Updates the internal state of the backlight in response to a hardware event,
> + * and generate a uevent to notify userspace
> + */
> +void backlight_force_update(struct backlight_device *bd)
> +{
> + char *envp[] = { "SOURCE=kernel", NULL };
> +
> + mutex_lock(&bd->ops_lock);
> + if (bd->ops && bd->ops->get_brightness)
> + bd->props.brightness = bd->ops->get_brightness(bd);
> + mutex_unlock(&bd->ops_lock);
> + kobject_uevent_env(&bd->dev.kobj, KOBJ_CHANGE, envp);
> +}
> +EXPORT_SYMBOL(backlight_force_update);
It seems that the acpi video driver will send the ACPI event to user
space when updating the brightness.
Is it necessary to send the udev-event again?
Thanks.
> +
> +/**
> * backlight_device_register - create and register a new object of
> * backlight_device class.
> * @name: the name of the new object(must be the same as the name of the
> diff --git a/include/linux/backlight.h b/include/linux/backlight.h
> index 79ca2da..8298c43 100644
> --- a/include/linux/backlight.h
> +++ b/include/linux/backlight.h
> @@ -100,6 +100,7 @@ static inline void backlight_update_status(struct backlight_device *bd)
> extern struct backlight_device *backlight_device_register(const char *name,
> struct device *dev, void *devdata, struct backlight_ops *ops);
> extern void backlight_device_unregister(struct backlight_device *bd);
> +extern void backlight_force_update(struct backlight_device *bd);
>
> #define to_backlight_device(obj) container_of(obj, struct backlight_device, dev)
>
next prev parent reply other threads:[~2009-07-14 0:58 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-13 20:41 [PATCH 1/3] backlight: Allow drivers to update the core, and generate events on changes Matthew Garrett
2009-07-13 20:41 ` [PATCH 2/3] ACPI: Update the backlight state when we change brightness Matthew Garrett
2009-07-13 20:41 ` [PATCH 3/3] eeepc-laptop: " Matthew Garrett
2009-07-14 0:58 ` ykzhao [this message]
2009-07-14 1:53 ` [PATCH 1/3] backlight: Allow drivers to update the core, and generate events on changes Matthew Garrett
2009-07-14 15:48 ` Matthew Garrett
2009-07-14 10:30 ` Henrique de Moraes Holschuh
2009-07-14 13:21 ` Matthew Garrett
2009-07-14 15:54 ` Henrique de Moraes Holschuh
2009-07-14 12:29 ` Richard Purdie
2009-07-14 12:55 ` Matthew Garrett
2009-07-15 7:55 ` Zhang Rui
2009-07-15 8:22 ` Richard Purdie
2009-07-15 8:38 ` Zhang Rui
2009-07-15 9:11 ` Richard Purdie
2009-07-15 13:58 ` Matthew Garrett
2009-07-16 2:39 ` Zhang Rui
2009-07-16 2:40 ` Matthew Garrett
2009-07-29 15:05 ` Pavel Machek
2009-07-29 15:20 ` Matthew Garrett
2009-07-29 15:31 ` Richard Purdie
-- strict thread matches above, loose matches on Subject: below --
2009-07-14 16:06 Matthew Garrett
2009-07-16 21:33 ` Michal Schmidt
2009-07-16 21:33 ` Michal Schmidt
2009-07-18 11:48 ` Pavel Machek
2009-09-19 23:24 ` Henrique de Moraes Holschuh
2009-09-20 4:15 ` Matthew Garrett
2009-09-20 11:16 ` Henrique de Moraes Holschuh
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=1247533128.3704.9.camel@localhost.localdomain \
--to=yakui.zhao@intel.com \
--cc=corentincj@iksaif.net \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mjg@redhat.com \
--cc=rpurdie@rpsys.net \
--cc=rui.zhang@intel.com \
/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.