Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Linux: Kernel

[PATCH 2/3] apple_bl: Rework in advance of gmux backlight support

 

 

Linux kernel RSS feed   Index | Next | Previous | View Threaded


seth.forshee at canonical

Feb 3, 2012, 12:28 PM

Post #1 of 8 (51 views)
Permalink
[PATCH 2/3] apple_bl: Rework in advance of gmux backlight support

Make it easier to support backlights without a fixed I/O range, and
remove use of global variables to allow having multiple backlights
concurrently.

Signed-off-by: Seth Forshee <seth.forshee [at] canonical>
---
drivers/video/backlight/apple_bl.c | 163 +++++++++++++++++++-----------------
1 files changed, 85 insertions(+), 78 deletions(-)

diff --git a/drivers/video/backlight/apple_bl.c b/drivers/video/backlight/apple_bl.c
index 66d5bec..e65b459 100644
--- a/drivers/video/backlight/apple_bl.c
+++ b/drivers/video/backlight/apple_bl.c
@@ -27,39 +27,30 @@
#include <linux/pci.h>
#include <linux/acpi.h>

-static struct backlight_device *apple_backlight_device;
-
-struct hw_data {
+struct apple_bl_data {
/* I/O resource to allocate. */
unsigned long iostart;
unsigned long iolen;
+
+ /* Backlight device */
+ struct backlight_device *bdev;
+
/* Backlight operations structure. */
- const struct backlight_ops backlight_ops;
- void (*set_brightness)(int);
+ int (*get_brightness)(struct apple_bl_data *);
+ void (*set_brightness)(struct apple_bl_data *, int);
};

-static const struct hw_data *hw_data;
-
/*
* Implementation for machines with Intel chipset.
*/
-static void intel_chipset_set_brightness(int intensity)
+static void intel_chipset_set_brightness(struct apple_bl_data *bl_data,
+ int intensity)
{
outb(0x04 | (intensity << 4), 0xb3);
outb(0xbf, 0xb2);
}

-static int intel_chipset_send_intensity(struct backlight_device *bd)
-{
- int intensity = bd->props.brightness;
-
- pr_debug("setting brightness to %d\n", intensity);
-
- intel_chipset_set_brightness(intensity);
- return 0;
-}
-
-static int intel_chipset_get_intensity(struct backlight_device *bd)
+static int intel_chipset_get_brightness(struct apple_bl_data *bl_data)
{
int intensity;

@@ -72,37 +63,17 @@ static int intel_chipset_get_intensity(struct backlight_device *bd)
return intensity;
}

-static const struct hw_data intel_chipset_data = {
- .iostart = 0xb2,
- .iolen = 2,
- .backlight_ops = {
- .options = BL_CORE_SUSPENDRESUME,
- .get_brightness = intel_chipset_get_intensity,
- .update_status = intel_chipset_send_intensity,
- },
- .set_brightness = intel_chipset_set_brightness,
-};
-
/*
* Implementation for machines with Nvidia chipset.
*/
-static void nvidia_chipset_set_brightness(int intensity)
+static void nvidia_chipset_set_brightness(struct apple_bl_data *bl_data,
+ int intensity)
{
outb(0x04 | (intensity << 4), 0x52f);
outb(0xbf, 0x52e);
}

-static int nvidia_chipset_send_intensity(struct backlight_device *bd)
-{
- int intensity = bd->props.brightness;
-
- pr_debug("setting brightness to %d\n", intensity);
-
- nvidia_chipset_set_brightness(intensity);
- return 0;
-}
-
-static int nvidia_chipset_get_intensity(struct backlight_device *bd)
+static int nvidia_chipset_get_brightness(struct apple_bl_data *bl_data)
{
int intensity;

@@ -115,82 +86,118 @@ static int nvidia_chipset_get_intensity(struct backlight_device *bd)
return intensity;
}

-static const struct hw_data nvidia_chipset_data = {
- .iostart = 0x52e,
- .iolen = 2,
- .backlight_ops = {
- .options = BL_CORE_SUSPENDRESUME,
- .get_brightness = nvidia_chipset_get_intensity,
- .update_status = nvidia_chipset_send_intensity
- },
- .set_brightness = nvidia_chipset_set_brightness,
+/*
+ * Backlight device class operations
+ */
+static int apple_bl_get_brightness(struct backlight_device *bd)
+{
+ struct apple_bl_data *bl_data = bl_get_data(bd);
+ return bl_data->get_brightness(bl_data);
+}
+
+static int apple_bl_update_status(struct backlight_device *bd)
+{
+ struct apple_bl_data *bl_data = bl_get_data(bd);
+
+ bl_data->set_brightness(bl_data, bd->props.brightness);
+ return 0;
+}
+
+static const struct backlight_ops apple_bl_ops = {
+ .get_brightness = apple_bl_get_brightness,
+ .update_status = apple_bl_update_status,
};

static int __devinit apple_bl_add(struct acpi_device *dev)
{
+ struct apple_bl_data *bl_data;
struct backlight_properties props;
+ struct backlight_device *bdev;
struct pci_dev *host;
+ unsigned short vendor;
int intensity;
+ int ret = -ENODEV;
+
+ bl_data = kzalloc(sizeof(*bl_data), GFP_KERNEL);
+ if (!bl_data)
+ return -ENOMEM;
+ dev->driver_data = dev;

host = pci_get_bus_and_slot(0, 0);

if (!host) {
pr_err("unable to find PCI host\n");
- return -ENODEV;
+ goto err_free;
}

- if (host->vendor == PCI_VENDOR_ID_INTEL)
- hw_data = &intel_chipset_data;
- else if (host->vendor == PCI_VENDOR_ID_NVIDIA)
- hw_data = &nvidia_chipset_data;
-
+ vendor = host->vendor;
pci_dev_put(host);

- if (!hw_data) {
+ if (vendor == PCI_VENDOR_ID_INTEL) {
+ bl_data->iostart = 0xb2;
+ bl_data->iolen = 2;
+ bl_data->get_brightness = intel_chipset_get_brightness;
+ bl_data->set_brightness = intel_chipset_set_brightness;
+ } else if (vendor == PCI_VENDOR_ID_NVIDIA) {
+ bl_data->iostart = 0x52e;
+ bl_data->iolen = 2;
+ bl_data->get_brightness = nvidia_chipset_get_brightness;
+ bl_data->set_brightness = nvidia_chipset_set_brightness;
+ } else {
pr_err("unknown hardware\n");
- return -ENODEV;
+ goto err_free;
}

/* Check that the hardware responds - this may not work under EFI */

- intensity = hw_data->backlight_ops.get_brightness(NULL);
+ intensity = bl_data->get_brightness(bl_data);

if (!intensity) {
- hw_data->set_brightness(1);
- if (!hw_data->backlight_ops.get_brightness(NULL))
- return -ENODEV;
+ bl_data->set_brightness(bl_data, 1);
+ if (!bl_data->get_brightness(bl_data))
+ goto err_free;

- hw_data->set_brightness(0);
+ bl_data->set_brightness(bl_data, 0);
}

- if (!request_region(hw_data->iostart, hw_data->iolen,
- "Apple backlight"))
- return -ENXIO;
+ if (!request_region(bl_data->iostart, bl_data->iolen,
+ "Apple backlight")) {
+ ret = -ENXIO;
+ goto err_free;
+ }

memset(&props, 0, sizeof(struct backlight_properties));
props.type = BACKLIGHT_PLATFORM;
props.max_brightness = 15;
- apple_backlight_device = backlight_device_register("apple_backlight",
- NULL, NULL, &hw_data->backlight_ops, &props);
+ bdev = backlight_device_register("apple_backlight", NULL, bl_data,
+ &apple_bl_ops, &props);

- if (IS_ERR(apple_backlight_device)) {
- release_region(hw_data->iostart, hw_data->iolen);
- return PTR_ERR(apple_backlight_device);
+ if (IS_ERR(bdev)) {
+ ret = PTR_ERR(bdev);
+ goto err_release;
}

- apple_backlight_device->props.brightness =
- hw_data->backlight_ops.get_brightness(apple_backlight_device);
- backlight_update_status(apple_backlight_device);
+ bl_data->bdev = bdev;
+ bdev->props.brightness = bl_data->get_brightness(bl_data);
+ backlight_update_status(bdev);

return 0;
+
+err_release:
+ release_region(bl_data->iostart, bl_data->iolen);
+err_free:
+ kfree(bl_data);
+ return ret;
}

static int __devexit apple_bl_remove(struct acpi_device *dev, int type)
{
- backlight_device_unregister(apple_backlight_device);
+ struct apple_bl_data *bl_data = dev->driver_data;
+
+ backlight_device_unregister(bl_data->bdev);
+ release_region(bl_data->iostart, bl_data->iolen);
+ kfree(bl_data);

- release_region(hw_data->iostart, hw_data->iolen);
- hw_data = NULL;
return 0;
}

--
1.7.8.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


lars at metafoo

Feb 3, 2012, 2:25 PM

Post #2 of 8 (51 views)
Permalink
Re: [PATCH 2/3] apple_bl: Rework in advance of gmux backlight support [In reply to]

On 02/03/2012 09:28 PM, Seth Forshee wrote:
> Make it easier to support backlights without a fixed I/O range, and
> remove use of global variables to allow having multiple backlights
> concurrently.
>
> Signed-off-by: Seth Forshee <seth.forshee [at] canonical>
> ---
> drivers/video/backlight/apple_bl.c | 163 +++++++++++++++++++-----------------
> 1 files changed, 85 insertions(+), 78 deletions(-)
>
> diff --git a/drivers/video/backlight/apple_bl.c b/drivers/video/backlight/apple_bl.c
> index 66d5bec..e65b459 100644
> --- a/drivers/video/backlight/apple_bl.c
> +++ b/drivers/video/backlight/apple_bl.c
> @@ -27,39 +27,30 @@
> #include <linux/pci.h>
> #include <linux/acpi.h>
> [...]
> + */
> +static int apple_bl_get_brightness(struct backlight_device *bd)
> +{
> + struct apple_bl_data *bl_data = bl_get_data(bd);
> + return bl_data->get_brightness(bl_data);
> +}
> +
> +static int apple_bl_update_status(struct backlight_device *bd)
> +{
> + struct apple_bl_data *bl_data = bl_get_data(bd);
> +
> + bl_data->set_brightness(bl_data, bd->props.brightness);
> + return 0;
> +}
> +
> +static const struct backlight_ops apple_bl_ops = {
> + .get_brightness = apple_bl_get_brightness,
> + .update_status = apple_bl_update_status,
> };

Adding this extra indirection here isn't so nice and isn't necessary either.
Just define one set of backlight ops for the intel case and one for the nvidia
case and use it accordingly when registering the backlight device.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


seth.forshee at canonical

Feb 3, 2012, 2:51 PM

Post #3 of 8 (48 views)
Permalink
Re: [PATCH 2/3] apple_bl: Rework in advance of gmux backlight support [In reply to]

On Fri, Feb 03, 2012 at 11:25:12PM +0100, Lars-Peter Clausen wrote:
> On 02/03/2012 09:28 PM, Seth Forshee wrote:
> > Make it easier to support backlights without a fixed I/O range, and
> > remove use of global variables to allow having multiple backlights
> > concurrently.
> >
> > Signed-off-by: Seth Forshee <seth.forshee [at] canonical>
> > ---
> > drivers/video/backlight/apple_bl.c | 163 +++++++++++++++++++-----------------
> > 1 files changed, 85 insertions(+), 78 deletions(-)
> >
> > diff --git a/drivers/video/backlight/apple_bl.c b/drivers/video/backlight/apple_bl.c
> > index 66d5bec..e65b459 100644
> > --- a/drivers/video/backlight/apple_bl.c
> > +++ b/drivers/video/backlight/apple_bl.c
> > @@ -27,39 +27,30 @@
> > #include <linux/pci.h>
> > #include <linux/acpi.h>
> > [...]
> > + */
> > +static int apple_bl_get_brightness(struct backlight_device *bd)
> > +{
> > + struct apple_bl_data *bl_data = bl_get_data(bd);
> > + return bl_data->get_brightness(bl_data);
> > +}
> > +
> > +static int apple_bl_update_status(struct backlight_device *bd)
> > +{
> > + struct apple_bl_data *bl_data = bl_get_data(bd);
> > +
> > + bl_data->set_brightness(bl_data, bd->props.brightness);
> > + return 0;
> > +}
> > +
> > +static const struct backlight_ops apple_bl_ops = {
> > + .get_brightness = apple_bl_get_brightness,
> > + .update_status = apple_bl_update_status,
> > };
>
> Adding this extra indirection here isn't so nice and isn't necessary either.
> Just define one set of backlight ops for the intel case and one for the nvidia
> case and use it accordingly when registering the backlight device.

There's a reason for the extra level of indirection to be there. The
driver uses {get,set}_brightness before the backlight device has been
allocated to test whether or not the backlight interface actually works.
This worked okay previously because the functions didn't need any extra
data; they just access fixed port addresses (really it only half-worked,
the update_status actually already has this indirection to support the
test, duplicated for each interface). But for the gmux backlight we're
getting the I/O address range from ACPI, so it needs to get at the data.

Of course there are a couple of ways we could get around this. Not
calling the backlight ops in the gmux case would be an option; then you
don't get the check, but so far as I know right now the check doesn't
work for the gmux backlight anyway. Or allocating the backlight device
first before doing the check, but I don't see that as a good option.

I feel like what I've done is the cleanest way to accommodate the test,
and the extra level of indirection really isn't all that bad imho.

Seth
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


lars at metafoo

Feb 4, 2012, 9:25 AM

Post #4 of 8 (46 views)
Permalink
Re: [PATCH 2/3] apple_bl: Rework in advance of gmux backlight support [In reply to]

On 02/03/2012 11:51 PM, Seth Forshee wrote:
> On Fri, Feb 03, 2012 at 11:25:12PM +0100, Lars-Peter Clausen wrote:
>> On 02/03/2012 09:28 PM, Seth Forshee wrote:
>>> Make it easier to support backlights without a fixed I/O range, and
>>> remove use of global variables to allow having multiple backlights
>>> concurrently.
>>>
>>> Signed-off-by: Seth Forshee <seth.forshee [at] canonical>
>>> ---
>>> drivers/video/backlight/apple_bl.c | 163 +++++++++++++++++++-----------------
>>> 1 files changed, 85 insertions(+), 78 deletions(-)
>>>
>>> diff --git a/drivers/video/backlight/apple_bl.c b/drivers/video/backlight/apple_bl.c
>>> index 66d5bec..e65b459 100644
>>> --- a/drivers/video/backlight/apple_bl.c
>>> +++ b/drivers/video/backlight/apple_bl.c
>>> @@ -27,39 +27,30 @@
>>> #include <linux/pci.h>
>>> #include <linux/acpi.h>
>>> [...]
>>> + */
>>> +static int apple_bl_get_brightness(struct backlight_device *bd)
>>> +{
>>> + struct apple_bl_data *bl_data = bl_get_data(bd);
>>> + return bl_data->get_brightness(bl_data);
>>> +}
>>> +
>>> +static int apple_bl_update_status(struct backlight_device *bd)
>>> +{
>>> + struct apple_bl_data *bl_data = bl_get_data(bd);
>>> +
>>> + bl_data->set_brightness(bl_data, bd->props.brightness);
>>> + return 0;
>>> +}
>>> +
>>> +static const struct backlight_ops apple_bl_ops = {
>>> + .get_brightness = apple_bl_get_brightness,
>>> + .update_status = apple_bl_update_status,
>>> };
>>
>> Adding this extra indirection here isn't so nice and isn't necessary either.
>> Just define one set of backlight ops for the intel case and one for the nvidia
>> case and use it accordingly when registering the backlight device.
>
> There's a reason for the extra level of indirection to be there. The
> driver uses {get,set}_brightness before the backlight device has been
> allocated to test whether or not the backlight interface actually works.
> This worked okay previously because the functions didn't need any extra
> data; they just access fixed port addresses (really it only half-worked,
> the update_status actually already has this indirection to support the
> test, duplicated for each interface). But for the gmux backlight we're
> getting the I/O address range from ACPI, so it needs to get at the data.
>

Ok, I see. Btw. am I missing something or are the intel and nvidia
{set,get}_brightness functions identical except for the IO base address? If
yes, I think they could be merged since you now pass the pass base address into
the function when calling it.

Something that would also be good to fix is to move the request_region(...) on
the IO address before actually accessing it.

> Of course there are a couple of ways we could get around this. Not
> calling the backlight ops in the gmux case would be an option; then you
> don't get the check, but so far as I know right now the check doesn't
> work for the gmux backlight anyway. Or allocating the backlight device
> first before doing the check, but I don't see that as a good option.
>

Hm, if that the check doesn't do anything for gmux is there acutally any code
shared between the gmux and the legacy path in the driver? If not would make
sense to put the gmux backlight support into its own driver?

- Lars

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


seth.forshee at canonical

Feb 6, 2012, 6:56 AM

Post #5 of 8 (43 views)
Permalink
Re: [PATCH 2/3] apple_bl: Rework in advance of gmux backlight support [In reply to]

On Sat, Feb 04, 2012 at 06:25:53PM +0100, Lars-Peter Clausen wrote:
> On 02/03/2012 11:51 PM, Seth Forshee wrote:
> > On Fri, Feb 03, 2012 at 11:25:12PM +0100, Lars-Peter Clausen wrote:
> >> On 02/03/2012 09:28 PM, Seth Forshee wrote:
> >>> Make it easier to support backlights without a fixed I/O range, and
> >>> remove use of global variables to allow having multiple backlights
> >>> concurrently.
> >>>
> >>> Signed-off-by: Seth Forshee <seth.forshee [at] canonical>
> >>> ---
> >>> drivers/video/backlight/apple_bl.c | 163 +++++++++++++++++++-----------------
> >>> 1 files changed, 85 insertions(+), 78 deletions(-)
> >>>
> >>> diff --git a/drivers/video/backlight/apple_bl.c b/drivers/video/backlight/apple_bl.c
> >>> index 66d5bec..e65b459 100644
> >>> --- a/drivers/video/backlight/apple_bl.c
> >>> +++ b/drivers/video/backlight/apple_bl.c
> >>> @@ -27,39 +27,30 @@
> >>> #include <linux/pci.h>
> >>> #include <linux/acpi.h>
> >>> [...]
> >>> + */
> >>> +static int apple_bl_get_brightness(struct backlight_device *bd)
> >>> +{
> >>> + struct apple_bl_data *bl_data = bl_get_data(bd);
> >>> + return bl_data->get_brightness(bl_data);
> >>> +}
> >>> +
> >>> +static int apple_bl_update_status(struct backlight_device *bd)
> >>> +{
> >>> + struct apple_bl_data *bl_data = bl_get_data(bd);
> >>> +
> >>> + bl_data->set_brightness(bl_data, bd->props.brightness);
> >>> + return 0;
> >>> +}
> >>> +
> >>> +static const struct backlight_ops apple_bl_ops = {
> >>> + .get_brightness = apple_bl_get_brightness,
> >>> + .update_status = apple_bl_update_status,
> >>> };
> >>
> >> Adding this extra indirection here isn't so nice and isn't necessary either.
> >> Just define one set of backlight ops for the intel case and one for the nvidia
> >> case and use it accordingly when registering the backlight device.
> >
> > There's a reason for the extra level of indirection to be there. The
> > driver uses {get,set}_brightness before the backlight device has been
> > allocated to test whether or not the backlight interface actually works.
> > This worked okay previously because the functions didn't need any extra
> > data; they just access fixed port addresses (really it only half-worked,
> > the update_status actually already has this indirection to support the
> > test, duplicated for each interface). But for the gmux backlight we're
> > getting the I/O address range from ACPI, so it needs to get at the data.
> >
>
> Ok, I see. Btw. am I missing something or are the intel and nvidia
> {set,get}_brightness functions identical except for the IO base address? If
> yes, I think they could be merged since you now pass the pass base address into
> the function when calling it.
>
> Something that would also be good to fix is to move the request_region(...) on
> the IO address before actually accessing it.

Okay, that makes sense.

> > Of course there are a couple of ways we could get around this. Not
> > calling the backlight ops in the gmux case would be an option; then you
> > don't get the check, but so far as I know right now the check doesn't
> > work for the gmux backlight anyway. Or allocating the backlight device
> > first before doing the check, but I don't see that as a good option.
> >
>
> Hm, if that the check doesn't do anything for gmux is there acutally any code
> shared between the gmux and the legacy path in the driver? If not would make
> sense to put the gmux backlight support into its own driver?

What I know is that the check doesn't work for the gmux on one
particular model. On that machine the gmux device is present but doesn't
control the backlight, yet reads and writes to the backlight ports
behave the same as if it did control the backlight. That's the only
model with a gmux that doesn't control the backlight that I've been able
to get any testing on, so I don't know how other models behave.

But you're right, by and large all the legacy and gmux paths share are
boilerplate code, other than the fact that they support the same class
of machines. The way apple_bl is done it seems natural to extended it
with other backlight interfaces for Apple hardware, but an argument can
be made for separting it out as well.

Seth
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


seth.forshee at canonical

Feb 9, 2012, 9:20 AM

Post #6 of 8 (37 views)
Permalink
Re: [PATCH 2/3] apple_bl: Rework in advance of gmux backlight support [In reply to]

On Mon, Feb 06, 2012 at 08:56:30AM -0600, Seth Forshee wrote:
> > > Of course there are a couple of ways we could get around this. Not
> > > calling the backlight ops in the gmux case would be an option; then you
> > > don't get the check, but so far as I know right now the check doesn't
> > > work for the gmux backlight anyway. Or allocating the backlight device
> > > first before doing the check, but I don't see that as a good option.
> > >
> >
> > Hm, if that the check doesn't do anything for gmux is there acutally any code
> > shared between the gmux and the legacy path in the driver? If not would make
> > sense to put the gmux backlight support into its own driver?
>
> What I know is that the check doesn't work for the gmux on one
> particular model. On that machine the gmux device is present but doesn't
> control the backlight, yet reads and writes to the backlight ports
> behave the same as if it did control the backlight. That's the only
> model with a gmux that doesn't control the backlight that I've been able
> to get any testing on, so I don't know how other models behave.
>
> But you're right, by and large all the legacy and gmux paths share are
> boilerplate code, other than the fact that they support the same class
> of machines. The way apple_bl is done it seems natural to extended it
> with other backlight interfaces for Apple hardware, but an argument can
> be made for separting it out as well.

I managed to get some more information that will allow me to do a sanity
check on the gmux. This will be completely separate from the check for
the legacy path, meaning they diverge even more. As a result I think I
will go ahead and put the gmux support in its own driver. This probably
makes the most sense anyway as the driver is likely to grow to include
support for the display mux functionality.

But with it being its own driver, I don't think it really belongs in
drivers/video/backlight even though the driver will initially only
supply backlight control. Anyone have suggestions where a driver for a
display mux device should live? I'm not seeing anywhere that looks like
an obviously correct location.

Thanks,
Seth
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


lars at metafoo

Feb 10, 2012, 1:25 AM

Post #7 of 8 (38 views)
Permalink
Re: [PATCH 2/3] apple_bl: Rework in advance of gmux backlight support [In reply to]

On 02/09/2012 06:20 PM, Seth Forshee wrote:
> On Mon, Feb 06, 2012 at 08:56:30AM -0600, Seth Forshee wrote:
>>>> Of course there are a couple of ways we could get around this. Not
>>>> calling the backlight ops in the gmux case would be an option; then you
>>>> don't get the check, but so far as I know right now the check doesn't
>>>> work for the gmux backlight anyway. Or allocating the backlight device
>>>> first before doing the check, but I don't see that as a good option.
>>>>
>>>
>>> Hm, if that the check doesn't do anything for gmux is there acutally any code
>>> shared between the gmux and the legacy path in the driver? If not would make
>>> sense to put the gmux backlight support into its own driver?
>>
>> What I know is that the check doesn't work for the gmux on one
>> particular model. On that machine the gmux device is present but doesn't
>> control the backlight, yet reads and writes to the backlight ports
>> behave the same as if it did control the backlight. That's the only
>> model with a gmux that doesn't control the backlight that I've been able
>> to get any testing on, so I don't know how other models behave.
>>
>> But you're right, by and large all the legacy and gmux paths share are
>> boilerplate code, other than the fact that they support the same class
>> of machines. The way apple_bl is done it seems natural to extended it
>> with other backlight interfaces for Apple hardware, but an argument can
>> be made for separting it out as well.
>
> I managed to get some more information that will allow me to do a sanity
> check on the gmux. This will be completely separate from the check for
> the legacy path, meaning they diverge even more. As a result I think I
> will go ahead and put the gmux support in its own driver. This probably
> makes the most sense anyway as the driver is likely to grow to include
> support for the display mux functionality.
>
> But with it being its own driver, I don't think it really belongs in
> drivers/video/backlight even though the driver will initially only
> supply backlight control. Anyone have suggestions where a driver for a
> display mux device should live? I'm not seeing anywhere that looks like
> an obviously correct location.
>

drivers/platform/x86 might be a good place to start. This were all the
laptop platform drivers go. But if the display mux is for switching between
multiple video outputs it probably wants to be integrated with the DRM
framework on the long run.

- Lars
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


seth.forshee at canonical

Feb 10, 2012, 6:50 AM

Post #8 of 8 (39 views)
Permalink
Re: [PATCH 2/3] apple_bl: Rework in advance of gmux backlight support [In reply to]

On Fri, Feb 10, 2012 at 10:25:34AM +0100, Lars-Peter Clausen wrote:
> On 02/09/2012 06:20 PM, Seth Forshee wrote:
> > On Mon, Feb 06, 2012 at 08:56:30AM -0600, Seth Forshee wrote:
> >>>> Of course there are a couple of ways we could get around this. Not
> >>>> calling the backlight ops in the gmux case would be an option; then you
> >>>> don't get the check, but so far as I know right now the check doesn't
> >>>> work for the gmux backlight anyway. Or allocating the backlight device
> >>>> first before doing the check, but I don't see that as a good option.
> >>>>
> >>>
> >>> Hm, if that the check doesn't do anything for gmux is there acutally any code
> >>> shared between the gmux and the legacy path in the driver? If not would make
> >>> sense to put the gmux backlight support into its own driver?
> >>
> >> What I know is that the check doesn't work for the gmux on one
> >> particular model. On that machine the gmux device is present but doesn't
> >> control the backlight, yet reads and writes to the backlight ports
> >> behave the same as if it did control the backlight. That's the only
> >> model with a gmux that doesn't control the backlight that I've been able
> >> to get any testing on, so I don't know how other models behave.
> >>
> >> But you're right, by and large all the legacy and gmux paths share are
> >> boilerplate code, other than the fact that they support the same class
> >> of machines. The way apple_bl is done it seems natural to extended it
> >> with other backlight interfaces for Apple hardware, but an argument can
> >> be made for separting it out as well.
> >
> > I managed to get some more information that will allow me to do a sanity
> > check on the gmux. This will be completely separate from the check for
> > the legacy path, meaning they diverge even more. As a result I think I
> > will go ahead and put the gmux support in its own driver. This probably
> > makes the most sense anyway as the driver is likely to grow to include
> > support for the display mux functionality.
> >
> > But with it being its own driver, I don't think it really belongs in
> > drivers/video/backlight even though the driver will initially only
> > supply backlight control. Anyone have suggestions where a driver for a
> > display mux device should live? I'm not seeing anywhere that looks like
> > an obviously correct location.
> >
>
> drivers/platform/x86 might be a good place to start. This were all the
> laptop platform drivers go. But if the display mux is for switching between
> multiple video outputs it probably wants to be integrated with the DRM
> framework on the long run.

Yeah, while this seems a little different than most of the platform-x86
drivers, that may be the best choice available.

The display mux is for switching between the video outputs between the
two GPUs in the system, which would be handled by registering a
vga_switcheroo handler. I hope to get to that eventually, but this
machine has more serious issues to get resolved first. The hybrid
graphics is only supported when doing native EFI booting, which atm
requires patching the video drivers anyway, so it's not a common use
case.

Thanks,
Seth
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Linux kernel RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.