nouveau: change the backlight parent device to the connector, not the PCI dev
authorMatthew Garrett <mjg@redhat.com>
Tue, 22 Mar 2011 23:30:24 +0000 (16:30 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 23 Mar 2011 00:43:59 +0000 (17:43 -0700)
We may eventually end up with per-connector backlights, especially with
ddcci devices.  Make sure that the parent node for the backlight device is
the connector rather than the PCI device.

Signed-off-by: Matthew Garrett <mjg@redhat.com>
Cc: Richard Purdie <rpurdie@rpsys.net>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: David Airlie <airlied@linux.ie>
Cc: Alex Deucher <alexdeucher@gmail.com>
Acked-by: Ben Skeggs <bskeggs@redhat.com>
Cc: Zhang Rui <rui.zhang@intel.com>
Cc: Len Brown <lenb@kernel.org>
Cc: Jesse Barnes <jbarnes@virtuousgeek.org>
Tested-by: Sedat Dilek <sedat.dilek@googlemail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/gpu/drm/nouveau/nouveau_backlight.c
drivers/gpu/drm/nouveau/nouveau_connector.c
drivers/gpu/drm/nouveau/nouveau_drv.h
drivers/gpu/drm/nouveau/nouveau_state.c

index 18d7bcc54ce0371ccadc272af9eb68ca1ae0c76e..00a55dfdba82dc2d6a8a26ad91168774a71fc06c 100644 (file)
@@ -88,10 +88,11 @@ static const struct backlight_ops nv50_bl_ops = {
        .update_status = nv50_set_intensity,
 };
 
-static int nouveau_nv40_backlight_init(struct drm_device *dev)
+static int nouveau_nv40_backlight_init(struct drm_connector *connector)
 {
-       struct backlight_properties props;
+       struct drm_device *dev = connector->dev;
        struct drm_nouveau_private *dev_priv = dev->dev_private;
+       struct backlight_properties props;
        struct backlight_device *bd;
 
        if (!(nv_rd32(dev, NV40_PMC_BACKLIGHT) & NV40_PMC_BACKLIGHT_MASK))
@@ -100,7 +101,7 @@ static int nouveau_nv40_backlight_init(struct drm_device *dev)
        memset(&props, 0, sizeof(struct backlight_properties));
        props.type = BACKLIGHT_RAW;
        props.max_brightness = 31;
-       bd = backlight_device_register("nv_backlight", &dev->pdev->dev, dev,
+       bd = backlight_device_register("nv_backlight", &connector->kdev, dev,
                                       &nv40_bl_ops, &props);
        if (IS_ERR(bd))
                return PTR_ERR(bd);
@@ -112,10 +113,11 @@ static int nouveau_nv40_backlight_init(struct drm_device *dev)
        return 0;
 }
 
-static int nouveau_nv50_backlight_init(struct drm_device *dev)
+static int nouveau_nv50_backlight_init(struct drm_connector *connector)
 {
-       struct backlight_properties props;
+       struct drm_device *dev = connector->dev;
        struct drm_nouveau_private *dev_priv = dev->dev_private;
+       struct backlight_properties props;
        struct backlight_device *bd;
 
        if (!nv_rd32(dev, NV50_PDISPLAY_SOR_BACKLIGHT))
@@ -124,7 +126,7 @@ static int nouveau_nv50_backlight_init(struct drm_device *dev)
        memset(&props, 0, sizeof(struct backlight_properties));
        props.type = BACKLIGHT_RAW;
        props.max_brightness = 1025;
-       bd = backlight_device_register("nv_backlight", &dev->pdev->dev, dev,
+       bd = backlight_device_register("nv_backlight", &connector->kdev, dev,
                                       &nv50_bl_ops, &props);
        if (IS_ERR(bd))
                return PTR_ERR(bd);
@@ -135,8 +137,9 @@ static int nouveau_nv50_backlight_init(struct drm_device *dev)
        return 0;
 }
 
-int nouveau_backlight_init(struct drm_device *dev)
+int nouveau_backlight_init(struct drm_connector *connector)
 {
+       struct drm_device *dev = connector->dev;
        struct drm_nouveau_private *dev_priv = dev->dev_private;
 
 #ifdef CONFIG_ACPI
@@ -149,9 +152,9 @@ int nouveau_backlight_init(struct drm_device *dev)
 
        switch (dev_priv->card_type) {
        case NV_40:
-               return nouveau_nv40_backlight_init(dev);
+               return nouveau_nv40_backlight_init(connector);
        case NV_50:
-               return nouveau_nv50_backlight_init(dev);
+               return nouveau_nv50_backlight_init(connector);
        default:
                break;
        }
@@ -159,8 +162,9 @@ int nouveau_backlight_init(struct drm_device *dev)
        return 0;
 }
 
-void nouveau_backlight_exit(struct drm_device *dev)
+void nouveau_backlight_exit(struct drm_connector *connector)
 {
+       struct drm_device *dev = connector->dev;
        struct drm_nouveau_private *dev_priv = dev->dev_private;
 
        if (dev_priv->backlight) {
index 390d82c3c4b04a8450c661090e0e680f5154a6ab..7ae151109a66f76eb467557f66f055c5ea7cb5c7 100644 (file)
@@ -116,6 +116,10 @@ nouveau_connector_destroy(struct drm_connector *connector)
                                      nouveau_connector_hotplug, connector);
        }
 
+       if (connector->connector_type == DRM_MODE_CONNECTOR_LVDS ||
+           connector->connector_type == DRM_MODE_CONNECTOR_eDP)
+               nouveau_backlight_exit(connector);
+
        kfree(nv_connector->edid);
        drm_sysfs_connector_remove(connector);
        drm_connector_cleanup(connector);
@@ -894,6 +898,11 @@ nouveau_connector_create(struct drm_device *dev, int index)
        }
 
        drm_sysfs_connector_add(connector);
+
+       if (connector->connector_type == DRM_MODE_CONNECTOR_LVDS ||
+           connector->connector_type == DRM_MODE_CONNECTOR_eDP)
+               nouveau_backlight_init(connector);
+
        dcb->drm = connector;
        return dcb->drm;
 
index 06111887b7895105008ccc7cdf1c80bbde0894a1..fff180a99867f43ca09d61fab78bcfba1468a631 100644 (file)
@@ -999,15 +999,15 @@ static inline int nouveau_acpi_edid(struct drm_device *dev, struct drm_connector
 
 /* nouveau_backlight.c */
 #ifdef CONFIG_DRM_NOUVEAU_BACKLIGHT
-extern int nouveau_backlight_init(struct drm_device *);
-extern void nouveau_backlight_exit(struct drm_device *);
+extern int nouveau_backlight_init(struct drm_connector *);
+extern void nouveau_backlight_exit(struct drm_connector *);
 #else
-static inline int nouveau_backlight_init(struct drm_device *dev)
+static inline int nouveau_backlight_init(struct drm_connector *dev)
 {
        return 0;
 }
 
-static inline void nouveau_backlight_exit(struct drm_device *dev) { }
+static inline void nouveau_backlight_exit(struct drm_connector *dev) { }
 #endif
 
 /* nouveau_bios.c */
index 05294910e135630ca7516e34a4dfea4076883c22..4fcbd091a117caea61fb684374a4fe9f0e661886 100644 (file)
@@ -704,10 +704,6 @@ nouveau_card_init(struct drm_device *dev)
                        goto out_fence;
        }
 
-       ret = nouveau_backlight_init(dev);
-       if (ret)
-               NV_ERROR(dev, "Error %d registering backlight\n", ret);
-
        nouveau_fbcon_init(dev);
        drm_kms_helper_poll_init(dev);
        return 0;
@@ -759,8 +755,6 @@ static void nouveau_card_takedown(struct drm_device *dev)
        struct drm_nouveau_private *dev_priv = dev->dev_private;
        struct nouveau_engine *engine = &dev_priv->engine;
 
-       nouveau_backlight_exit(dev);
-
        if (!engine->graph.accel_blocked) {
                nouveau_fence_fini(dev);
                nouveau_channel_put_unlocked(&dev_priv->channel);