aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMatthew Garrett <mjg@redhat.com>2011-03-22 19:30:24 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-03-22 20:43:59 -0400
commit7eae3efa13c5d1c8e7d8dd0504ad524963b8add1 (patch)
tree3e8326d5a377b55916ffd48c179821148881f4f1 /drivers
parent63ec0119d3720034dfd626c9785aefa5a6f972ca (diff)
nouveau: change the backlight parent device to the connector, not the PCI dev
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>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_backlight.c24
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_connector.c9
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_drv.h8
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_state.c6
4 files changed, 27 insertions, 20 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_backlight.c b/drivers/gpu/drm/nouveau/nouveau_backlight.c
index 18d7bcc54ce0..00a55dfdba82 100644
--- a/drivers/gpu/drm/nouveau/nouveau_backlight.c
+++ b/drivers/gpu/drm/nouveau/nouveau_backlight.c
@@ -88,10 +88,11 @@ static const struct backlight_ops nv50_bl_ops = {
88 .update_status = nv50_set_intensity, 88 .update_status = nv50_set_intensity,
89}; 89};
90 90
91static int nouveau_nv40_backlight_init(struct drm_device *dev) 91static int nouveau_nv40_backlight_init(struct drm_connector *connector)
92{ 92{
93 struct backlight_properties props; 93 struct drm_device *dev = connector->dev;
94 struct drm_nouveau_private *dev_priv = dev->dev_private; 94 struct drm_nouveau_private *dev_priv = dev->dev_private;
95 struct backlight_properties props;
95 struct backlight_device *bd; 96 struct backlight_device *bd;
96 97
97 if (!(nv_rd32(dev, NV40_PMC_BACKLIGHT) & NV40_PMC_BACKLIGHT_MASK)) 98 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)
100 memset(&props, 0, sizeof(struct backlight_properties)); 101 memset(&props, 0, sizeof(struct backlight_properties));
101 props.type = BACKLIGHT_RAW; 102 props.type = BACKLIGHT_RAW;
102 props.max_brightness = 31; 103 props.max_brightness = 31;
103 bd = backlight_device_register("nv_backlight", &dev->pdev->dev, dev, 104 bd = backlight_device_register("nv_backlight", &connector->kdev, dev,
104 &nv40_bl_ops, &props); 105 &nv40_bl_ops, &props);
105 if (IS_ERR(bd)) 106 if (IS_ERR(bd))
106 return PTR_ERR(bd); 107 return PTR_ERR(bd);
@@ -112,10 +113,11 @@ static int nouveau_nv40_backlight_init(struct drm_device *dev)
112 return 0; 113 return 0;
113} 114}
114 115
115static int nouveau_nv50_backlight_init(struct drm_device *dev) 116static int nouveau_nv50_backlight_init(struct drm_connector *connector)
116{ 117{
117 struct backlight_properties props; 118 struct drm_device *dev = connector->dev;
118 struct drm_nouveau_private *dev_priv = dev->dev_private; 119 struct drm_nouveau_private *dev_priv = dev->dev_private;
120 struct backlight_properties props;
119 struct backlight_device *bd; 121 struct backlight_device *bd;
120 122
121 if (!nv_rd32(dev, NV50_PDISPLAY_SOR_BACKLIGHT)) 123 if (!nv_rd32(dev, NV50_PDISPLAY_SOR_BACKLIGHT))
@@ -124,7 +126,7 @@ static int nouveau_nv50_backlight_init(struct drm_device *dev)
124 memset(&props, 0, sizeof(struct backlight_properties)); 126 memset(&props, 0, sizeof(struct backlight_properties));
125 props.type = BACKLIGHT_RAW; 127 props.type = BACKLIGHT_RAW;
126 props.max_brightness = 1025; 128 props.max_brightness = 1025;
127 bd = backlight_device_register("nv_backlight", &dev->pdev->dev, dev, 129 bd = backlight_device_register("nv_backlight", &connector->kdev, dev,
128 &nv50_bl_ops, &props); 130 &nv50_bl_ops, &props);
129 if (IS_ERR(bd)) 131 if (IS_ERR(bd))
130 return PTR_ERR(bd); 132 return PTR_ERR(bd);
@@ -135,8 +137,9 @@ static int nouveau_nv50_backlight_init(struct drm_device *dev)
135 return 0; 137 return 0;
136} 138}
137 139
138int nouveau_backlight_init(struct drm_device *dev) 140int nouveau_backlight_init(struct drm_connector *connector)
139{ 141{
142 struct drm_device *dev = connector->dev;
140 struct drm_nouveau_private *dev_priv = dev->dev_private; 143 struct drm_nouveau_private *dev_priv = dev->dev_private;
141 144
142#ifdef CONFIG_ACPI 145#ifdef CONFIG_ACPI
@@ -149,9 +152,9 @@ int nouveau_backlight_init(struct drm_device *dev)
149 152
150 switch (dev_priv->card_type) { 153 switch (dev_priv->card_type) {
151 case NV_40: 154 case NV_40:
152 return nouveau_nv40_backlight_init(dev); 155 return nouveau_nv40_backlight_init(connector);
153 case NV_50: 156 case NV_50:
154 return nouveau_nv50_backlight_init(dev); 157 return nouveau_nv50_backlight_init(connector);
155 default: 158 default:
156 break; 159 break;
157 } 160 }
@@ -159,8 +162,9 @@ int nouveau_backlight_init(struct drm_device *dev)
159 return 0; 162 return 0;
160} 163}
161 164
162void nouveau_backlight_exit(struct drm_device *dev) 165void nouveau_backlight_exit(struct drm_connector *connector)
163{ 166{
167 struct drm_device *dev = connector->dev;
164 struct drm_nouveau_private *dev_priv = dev->dev_private; 168 struct drm_nouveau_private *dev_priv = dev->dev_private;
165 169
166 if (dev_priv->backlight) { 170 if (dev_priv->backlight) {
diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c b/drivers/gpu/drm/nouveau/nouveau_connector.c
index 390d82c3c4b0..7ae151109a66 100644
--- a/drivers/gpu/drm/nouveau/nouveau_connector.c
+++ b/drivers/gpu/drm/nouveau/nouveau_connector.c
@@ -116,6 +116,10 @@ nouveau_connector_destroy(struct drm_connector *connector)
116 nouveau_connector_hotplug, connector); 116 nouveau_connector_hotplug, connector);
117 } 117 }
118 118
119 if (connector->connector_type == DRM_MODE_CONNECTOR_LVDS ||
120 connector->connector_type == DRM_MODE_CONNECTOR_eDP)
121 nouveau_backlight_exit(connector);
122
119 kfree(nv_connector->edid); 123 kfree(nv_connector->edid);
120 drm_sysfs_connector_remove(connector); 124 drm_sysfs_connector_remove(connector);
121 drm_connector_cleanup(connector); 125 drm_connector_cleanup(connector);
@@ -894,6 +898,11 @@ nouveau_connector_create(struct drm_device *dev, int index)
894 } 898 }
895 899
896 drm_sysfs_connector_add(connector); 900 drm_sysfs_connector_add(connector);
901
902 if (connector->connector_type == DRM_MODE_CONNECTOR_LVDS ||
903 connector->connector_type == DRM_MODE_CONNECTOR_eDP)
904 nouveau_backlight_init(connector);
905
897 dcb->drm = connector; 906 dcb->drm = connector;
898 return dcb->drm; 907 return dcb->drm;
899 908
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h
index 06111887b789..fff180a99867 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.h
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.h
@@ -999,15 +999,15 @@ static inline int nouveau_acpi_edid(struct drm_device *dev, struct drm_connector
999 999
1000/* nouveau_backlight.c */ 1000/* nouveau_backlight.c */
1001#ifdef CONFIG_DRM_NOUVEAU_BACKLIGHT 1001#ifdef CONFIG_DRM_NOUVEAU_BACKLIGHT
1002extern int nouveau_backlight_init(struct drm_device *); 1002extern int nouveau_backlight_init(struct drm_connector *);
1003extern void nouveau_backlight_exit(struct drm_device *); 1003extern void nouveau_backlight_exit(struct drm_connector *);
1004#else 1004#else
1005static inline int nouveau_backlight_init(struct drm_device *dev) 1005static inline int nouveau_backlight_init(struct drm_connector *dev)
1006{ 1006{
1007 return 0; 1007 return 0;
1008} 1008}
1009 1009
1010static inline void nouveau_backlight_exit(struct drm_device *dev) { } 1010static inline void nouveau_backlight_exit(struct drm_connector *dev) { }
1011#endif 1011#endif
1012 1012
1013/* nouveau_bios.c */ 1013/* nouveau_bios.c */
diff --git a/drivers/gpu/drm/nouveau/nouveau_state.c b/drivers/gpu/drm/nouveau/nouveau_state.c
index 05294910e135..4fcbd091a117 100644
--- a/drivers/gpu/drm/nouveau/nouveau_state.c
+++ b/drivers/gpu/drm/nouveau/nouveau_state.c
@@ -704,10 +704,6 @@ nouveau_card_init(struct drm_device *dev)
704 goto out_fence; 704 goto out_fence;
705 } 705 }
706 706
707 ret = nouveau_backlight_init(dev);
708 if (ret)
709 NV_ERROR(dev, "Error %d registering backlight\n", ret);
710
711 nouveau_fbcon_init(dev); 707 nouveau_fbcon_init(dev);
712 drm_kms_helper_poll_init(dev); 708 drm_kms_helper_poll_init(dev);
713 return 0; 709 return 0;
@@ -759,8 +755,6 @@ static void nouveau_card_takedown(struct drm_device *dev)
759 struct drm_nouveau_private *dev_priv = dev->dev_private; 755 struct drm_nouveau_private *dev_priv = dev->dev_private;
760 struct nouveau_engine *engine = &dev_priv->engine; 756 struct nouveau_engine *engine = &dev_priv->engine;
761 757
762 nouveau_backlight_exit(dev);
763
764 if (!engine->graph.accel_blocked) { 758 if (!engine->graph.accel_blocked) {
765 nouveau_fence_fini(dev); 759 nouveau_fence_fini(dev);
766 nouveau_channel_put_unlocked(&dev_priv->channel); 760 nouveau_channel_put_unlocked(&dev_priv->channel);