diff options
author | Ben Skeggs <bskeggs@redhat.com> | 2012-07-25 19:12:47 -0400 |
---|---|---|
committer | Ben Skeggs <bskeggs@redhat.com> | 2012-10-02 23:12:58 -0400 |
commit | 51a3d3425663698a79e8a9d01998a8a32ddee13b (patch) | |
tree | 631abadec9c864cb46b441bdc46cbb444ccd972d | |
parent | 84058eb80e0b790c877962e3f4cf49725e23ffce (diff) |
drm/nouveau/backlight: remove dependence on nouveau_drv.h
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
-rw-r--r-- | drivers/gpu/drm/nouveau/Makefile | 5 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_backlight.c | 90 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_drm.h | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_drv.h | 10 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_encoder.h | 3 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nv04_display.h | 9 |
6 files changed, 60 insertions, 59 deletions
diff --git a/drivers/gpu/drm/nouveau/Makefile b/drivers/gpu/drm/nouveau/Makefile index a333c95d8bd6..72f1a1c2e56f 100644 --- a/drivers/gpu/drm/nouveau/Makefile +++ b/drivers/gpu/drm/nouveau/Makefile | |||
@@ -170,6 +170,7 @@ nouveau-y += nv50_fbcon.o nvc0_fbcon.o | |||
170 | # other random bits | 170 | # other random bits |
171 | nouveau-$(CONFIG_COMPAT) += nouveau_ioc32.o | 171 | nouveau-$(CONFIG_COMPAT) += nouveau_ioc32.o |
172 | nouveau-$(CONFIG_ACPI) += nouveau_acpi.o | 172 | nouveau-$(CONFIG_ACPI) += nouveau_acpi.o |
173 | nouveau-$(CONFIG_DRM_NOUVEAU_BACKLIGHT) += nouveau_backlight.o | ||
173 | 174 | ||
174 | ## | 175 | ## |
175 | ## unported bits below | 176 | ## unported bits below |
@@ -201,8 +202,4 @@ nouveau-y += nouveau_pm.o nouveau_volt.o nouveau_perf.o nouveau_temp.o | |||
201 | nouveau-y += nv04_pm.o nv40_pm.o nv50_pm.o nva3_pm.o nvc0_pm.o | 202 | nouveau-y += nv04_pm.o nv40_pm.o nv50_pm.o nva3_pm.o nvc0_pm.o |
202 | nouveau-y += nouveau_mem.o | 203 | nouveau-y += nouveau_mem.o |
203 | 204 | ||
204 | # optional stuff | ||
205 | nouveau-$(CONFIG_DRM_NOUVEAU_BACKLIGHT) += nouveau_backlight.o | ||
206 | |||
207 | |||
208 | obj-$(CONFIG_DRM_NOUVEAU)+= nouveau.o | 205 | obj-$(CONFIG_DRM_NOUVEAU)+= nouveau.o |
diff --git a/drivers/gpu/drm/nouveau/nouveau_backlight.c b/drivers/gpu/drm/nouveau/nouveau_backlight.c index d33e94a34517..5c4cc7a2117a 100644 --- a/drivers/gpu/drm/nouveau/nouveau_backlight.c +++ b/drivers/gpu/drm/nouveau/nouveau_backlight.c | |||
@@ -33,18 +33,17 @@ | |||
33 | #include <linux/backlight.h> | 33 | #include <linux/backlight.h> |
34 | #include <linux/acpi.h> | 34 | #include <linux/acpi.h> |
35 | 35 | ||
36 | #include "drmP.h" | 36 | #include "nouveau_drm.h" |
37 | #include "nouveau_drv.h" | ||
38 | #include <nouveau_drm.h> | ||
39 | #include "nouveau_reg.h" | 37 | #include "nouveau_reg.h" |
40 | #include "nouveau_encoder.h" | 38 | #include "nouveau_encoder.h" |
41 | 39 | ||
42 | static int | 40 | static int |
43 | nv40_get_intensity(struct backlight_device *bd) | 41 | nv40_get_intensity(struct backlight_device *bd) |
44 | { | 42 | { |
45 | struct drm_device *dev = bl_get_data(bd); | 43 | struct nouveau_drm *drm = bl_get_data(bd); |
46 | int val = (nv_rd32(dev, NV40_PMC_BACKLIGHT) & NV40_PMC_BACKLIGHT_MASK) | 44 | struct nouveau_device *device = nv_device(drm->device); |
47 | >> 16; | 45 | int val = (nv_rd32(device, NV40_PMC_BACKLIGHT) & |
46 | NV40_PMC_BACKLIGHT_MASK) >> 16; | ||
48 | 47 | ||
49 | return val; | 48 | return val; |
50 | } | 49 | } |
@@ -52,11 +51,12 @@ nv40_get_intensity(struct backlight_device *bd) | |||
52 | static int | 51 | static int |
53 | nv40_set_intensity(struct backlight_device *bd) | 52 | nv40_set_intensity(struct backlight_device *bd) |
54 | { | 53 | { |
55 | struct drm_device *dev = bl_get_data(bd); | 54 | struct nouveau_drm *drm = bl_get_data(bd); |
55 | struct nouveau_device *device = nv_device(drm->device); | ||
56 | int val = bd->props.brightness; | 56 | int val = bd->props.brightness; |
57 | int reg = nv_rd32(dev, NV40_PMC_BACKLIGHT); | 57 | int reg = nv_rd32(device, NV40_PMC_BACKLIGHT); |
58 | 58 | ||
59 | nv_wr32(dev, NV40_PMC_BACKLIGHT, | 59 | nv_wr32(device, NV40_PMC_BACKLIGHT, |
60 | (val << 16) | (reg & ~NV40_PMC_BACKLIGHT_MASK)); | 60 | (val << 16) | (reg & ~NV40_PMC_BACKLIGHT_MASK)); |
61 | 61 | ||
62 | return 0; | 62 | return 0; |
@@ -71,23 +71,20 @@ static const struct backlight_ops nv40_bl_ops = { | |||
71 | static int | 71 | static int |
72 | nv40_backlight_init(struct drm_connector *connector) | 72 | nv40_backlight_init(struct drm_connector *connector) |
73 | { | 73 | { |
74 | struct drm_device *dev = connector->dev; | 74 | struct nouveau_drm *drm = nouveau_newpriv(connector->dev); |
75 | struct drm_nouveau_private *dev_priv = dev->dev_private; | 75 | struct nouveau_device *device = nv_device(drm->device); |
76 | struct backlight_properties props; | 76 | struct backlight_properties props; |
77 | struct backlight_device *bd; | 77 | struct backlight_device *bd; |
78 | 78 | ||
79 | if (!(nv_rd32(dev, NV40_PMC_BACKLIGHT) & NV40_PMC_BACKLIGHT_MASK)) | 79 | if (!(nv_rd32(device, NV40_PMC_BACKLIGHT) & NV40_PMC_BACKLIGHT_MASK)) |
80 | return 0; | 80 | return 0; |
81 | 81 | ||
82 | memset(&props, 0, sizeof(struct backlight_properties)); | 82 | memset(&props, 0, sizeof(struct backlight_properties)); |
83 | props.type = BACKLIGHT_RAW; | 83 | props.type = BACKLIGHT_RAW; |
84 | props.max_brightness = 31; | 84 | props.max_brightness = 31; |
85 | bd = backlight_device_register("nv_backlight", &connector->kdev, dev, | 85 | bd = backlight_device_register("nv_backlight", &connector->kdev, drm, |
86 | &nv40_bl_ops, &props); | 86 | &nv40_bl_ops, &props); |
87 | if (IS_ERR(bd)) | 87 | drm->backlight = bd; |
88 | return PTR_ERR(bd); | ||
89 | |||
90 | dev_priv->backlight = bd; | ||
91 | bd->props.brightness = nv40_get_intensity(bd); | 88 | bd->props.brightness = nv40_get_intensity(bd); |
92 | backlight_update_status(bd); | 89 | backlight_update_status(bd); |
93 | 90 | ||
@@ -98,12 +95,13 @@ static int | |||
98 | nv50_get_intensity(struct backlight_device *bd) | 95 | nv50_get_intensity(struct backlight_device *bd) |
99 | { | 96 | { |
100 | struct nouveau_encoder *nv_encoder = bl_get_data(bd); | 97 | struct nouveau_encoder *nv_encoder = bl_get_data(bd); |
101 | struct drm_device *dev = nv_encoder->base.base.dev; | 98 | struct nouveau_drm *drm = nouveau_newpriv(nv_encoder->base.base.dev); |
99 | struct nouveau_device *device = nv_device(drm->device); | ||
102 | int or = nv_encoder->or; | 100 | int or = nv_encoder->or; |
103 | u32 div = 1025; | 101 | u32 div = 1025; |
104 | u32 val; | 102 | u32 val; |
105 | 103 | ||
106 | val = nv_rd32(dev, NV50_PDISP_SOR_PWM_CTL(or)); | 104 | val = nv_rd32(device, NV50_PDISP_SOR_PWM_CTL(or)); |
107 | val &= NV50_PDISP_SOR_PWM_CTL_VAL; | 105 | val &= NV50_PDISP_SOR_PWM_CTL_VAL; |
108 | return ((val * 100) + (div / 2)) / div; | 106 | return ((val * 100) + (div / 2)) / div; |
109 | } | 107 | } |
@@ -112,13 +110,14 @@ static int | |||
112 | nv50_set_intensity(struct backlight_device *bd) | 110 | nv50_set_intensity(struct backlight_device *bd) |
113 | { | 111 | { |
114 | struct nouveau_encoder *nv_encoder = bl_get_data(bd); | 112 | struct nouveau_encoder *nv_encoder = bl_get_data(bd); |
115 | struct drm_device *dev = nv_encoder->base.base.dev; | 113 | struct nouveau_drm *drm = nouveau_newpriv(nv_encoder->base.base.dev); |
114 | struct nouveau_device *device = nv_device(drm->device); | ||
116 | int or = nv_encoder->or; | 115 | int or = nv_encoder->or; |
117 | u32 div = 1025; | 116 | u32 div = 1025; |
118 | u32 val = (bd->props.brightness * div) / 100; | 117 | u32 val = (bd->props.brightness * div) / 100; |
119 | 118 | ||
120 | nv_wr32(dev, NV50_PDISP_SOR_PWM_CTL(or), | 119 | nv_wr32(device, NV50_PDISP_SOR_PWM_CTL(or), |
121 | NV50_PDISP_SOR_PWM_CTL_NEW | val); | 120 | NV50_PDISP_SOR_PWM_CTL_NEW | val); |
122 | return 0; | 121 | return 0; |
123 | } | 122 | } |
124 | 123 | ||
@@ -132,12 +131,13 @@ static int | |||
132 | nva3_get_intensity(struct backlight_device *bd) | 131 | nva3_get_intensity(struct backlight_device *bd) |
133 | { | 132 | { |
134 | struct nouveau_encoder *nv_encoder = bl_get_data(bd); | 133 | struct nouveau_encoder *nv_encoder = bl_get_data(bd); |
135 | struct drm_device *dev = nv_encoder->base.base.dev; | 134 | struct nouveau_drm *drm = nouveau_newpriv(nv_encoder->base.base.dev); |
135 | struct nouveau_device *device = nv_device(drm->device); | ||
136 | int or = nv_encoder->or; | 136 | int or = nv_encoder->or; |
137 | u32 div, val; | 137 | u32 div, val; |
138 | 138 | ||
139 | div = nv_rd32(dev, NV50_PDISP_SOR_PWM_DIV(or)); | 139 | div = nv_rd32(device, NV50_PDISP_SOR_PWM_DIV(or)); |
140 | val = nv_rd32(dev, NV50_PDISP_SOR_PWM_CTL(or)); | 140 | val = nv_rd32(device, NV50_PDISP_SOR_PWM_CTL(or)); |
141 | val &= NVA3_PDISP_SOR_PWM_CTL_VAL; | 141 | val &= NVA3_PDISP_SOR_PWM_CTL_VAL; |
142 | if (div && div >= val) | 142 | if (div && div >= val) |
143 | return ((val * 100) + (div / 2)) / div; | 143 | return ((val * 100) + (div / 2)) / div; |
@@ -149,16 +149,17 @@ static int | |||
149 | nva3_set_intensity(struct backlight_device *bd) | 149 | nva3_set_intensity(struct backlight_device *bd) |
150 | { | 150 | { |
151 | struct nouveau_encoder *nv_encoder = bl_get_data(bd); | 151 | struct nouveau_encoder *nv_encoder = bl_get_data(bd); |
152 | struct drm_device *dev = nv_encoder->base.base.dev; | 152 | struct nouveau_drm *drm = nouveau_newpriv(nv_encoder->base.base.dev); |
153 | struct nouveau_device *device = nv_device(drm->device); | ||
153 | int or = nv_encoder->or; | 154 | int or = nv_encoder->or; |
154 | u32 div, val; | 155 | u32 div, val; |
155 | 156 | ||
156 | div = nv_rd32(dev, NV50_PDISP_SOR_PWM_DIV(or)); | 157 | div = nv_rd32(device, NV50_PDISP_SOR_PWM_DIV(or)); |
157 | val = (bd->props.brightness * div) / 100; | 158 | val = (bd->props.brightness * div) / 100; |
158 | if (div) { | 159 | if (div) { |
159 | nv_wr32(dev, NV50_PDISP_SOR_PWM_CTL(or), val | | 160 | nv_wr32(device, NV50_PDISP_SOR_PWM_CTL(or), val | |
160 | NV50_PDISP_SOR_PWM_CTL_NEW | | 161 | NV50_PDISP_SOR_PWM_CTL_NEW | |
161 | NVA3_PDISP_SOR_PWM_CTL_UNK); | 162 | NVA3_PDISP_SOR_PWM_CTL_UNK); |
162 | return 0; | 163 | return 0; |
163 | } | 164 | } |
164 | 165 | ||
@@ -174,8 +175,8 @@ static const struct backlight_ops nva3_bl_ops = { | |||
174 | static int | 175 | static int |
175 | nv50_backlight_init(struct drm_connector *connector) | 176 | nv50_backlight_init(struct drm_connector *connector) |
176 | { | 177 | { |
177 | struct drm_device *dev = connector->dev; | 178 | struct nouveau_drm *drm = nouveau_newpriv(connector->dev); |
178 | struct drm_nouveau_private *dev_priv = dev->dev_private; | 179 | struct nouveau_device *device = nv_device(drm->device); |
179 | struct nouveau_encoder *nv_encoder; | 180 | struct nouveau_encoder *nv_encoder; |
180 | struct backlight_properties props; | 181 | struct backlight_properties props; |
181 | struct backlight_device *bd; | 182 | struct backlight_device *bd; |
@@ -188,12 +189,12 @@ nv50_backlight_init(struct drm_connector *connector) | |||
188 | return -ENODEV; | 189 | return -ENODEV; |
189 | } | 190 | } |
190 | 191 | ||
191 | if (!nv_rd32(dev, NV50_PDISP_SOR_PWM_CTL(nv_encoder->or))) | 192 | if (!nv_rd32(device, NV50_PDISP_SOR_PWM_CTL(nv_encoder->or))) |
192 | return 0; | 193 | return 0; |
193 | 194 | ||
194 | if (dev_priv->chipset <= 0xa0 || | 195 | if (device->chipset <= 0xa0 || |
195 | dev_priv->chipset == 0xaa || | 196 | device->chipset == 0xaa || |
196 | dev_priv->chipset == 0xac) | 197 | device->chipset == 0xac) |
197 | ops = &nv50_bl_ops; | 198 | ops = &nv50_bl_ops; |
198 | else | 199 | else |
199 | ops = &nva3_bl_ops; | 200 | ops = &nva3_bl_ops; |
@@ -206,7 +207,7 @@ nv50_backlight_init(struct drm_connector *connector) | |||
206 | if (IS_ERR(bd)) | 207 | if (IS_ERR(bd)) |
207 | return PTR_ERR(bd); | 208 | return PTR_ERR(bd); |
208 | 209 | ||
209 | dev_priv->backlight = bd; | 210 | drm->backlight = bd; |
210 | bd->props.brightness = bd->ops->get_brightness(bd); | 211 | bd->props.brightness = bd->ops->get_brightness(bd); |
211 | backlight_update_status(bd); | 212 | backlight_update_status(bd); |
212 | return 0; | 213 | return 0; |
@@ -215,12 +216,13 @@ nv50_backlight_init(struct drm_connector *connector) | |||
215 | int | 216 | int |
216 | nouveau_backlight_init(struct drm_device *dev) | 217 | nouveau_backlight_init(struct drm_device *dev) |
217 | { | 218 | { |
218 | struct drm_nouveau_private *dev_priv = dev->dev_private; | 219 | struct nouveau_drm *drm = nouveau_newpriv(dev); |
220 | struct nouveau_device *device = nv_device(drm->device); | ||
219 | struct drm_connector *connector; | 221 | struct drm_connector *connector; |
220 | 222 | ||
221 | #ifdef CONFIG_ACPI | 223 | #ifdef CONFIG_ACPI |
222 | if (acpi_video_backlight_support()) { | 224 | if (acpi_video_backlight_support()) { |
223 | NV_INFO(dev, "ACPI backlight interface available, " | 225 | NV_INFO(drm, "ACPI backlight interface available, " |
224 | "not registering our own\n"); | 226 | "not registering our own\n"); |
225 | return 0; | 227 | return 0; |
226 | } | 228 | } |
@@ -231,7 +233,7 @@ nouveau_backlight_init(struct drm_device *dev) | |||
231 | connector->connector_type != DRM_MODE_CONNECTOR_eDP) | 233 | connector->connector_type != DRM_MODE_CONNECTOR_eDP) |
232 | continue; | 234 | continue; |
233 | 235 | ||
234 | switch (dev_priv->card_type) { | 236 | switch (device->card_type) { |
235 | case NV_40: | 237 | case NV_40: |
236 | return nv40_backlight_init(connector); | 238 | return nv40_backlight_init(connector); |
237 | case NV_50: | 239 | case NV_50: |
@@ -248,10 +250,10 @@ nouveau_backlight_init(struct drm_device *dev) | |||
248 | void | 250 | void |
249 | nouveau_backlight_exit(struct drm_device *dev) | 251 | nouveau_backlight_exit(struct drm_device *dev) |
250 | { | 252 | { |
251 | struct drm_nouveau_private *dev_priv = dev->dev_private; | 253 | struct nouveau_drm *drm = nouveau_newpriv(dev); |
252 | 254 | ||
253 | if (dev_priv->backlight) { | 255 | if (drm->backlight) { |
254 | backlight_device_unregister(dev_priv->backlight); | 256 | backlight_device_unregister(drm->backlight); |
255 | dev_priv->backlight = NULL; | 257 | drm->backlight = NULL; |
256 | } | 258 | } |
257 | } | 259 | } |
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h index 2e3364d50ca0..d50352aa1a16 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.h +++ b/drivers/gpu/drm/nouveau/nouveau_drm.h | |||
@@ -95,6 +95,8 @@ struct nouveau_drm { | |||
95 | struct nouveau_drm_tile reg[15]; | 95 | struct nouveau_drm_tile reg[15]; |
96 | spinlock_t lock; | 96 | spinlock_t lock; |
97 | } tile; | 97 | } tile; |
98 | |||
99 | struct backlight_device *backlight; | ||
98 | }; | 100 | }; |
99 | 101 | ||
100 | static inline struct nouveau_drm * | 102 | static inline struct nouveau_drm * |
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h index 5d2da1bd12f2..1228ac45e24c 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drv.h +++ b/drivers/gpu/drm/nouveau/nouveau_drv.h | |||
@@ -308,9 +308,6 @@ struct drm_nouveau_private { | |||
308 | spinlock_t context_switch_lock; | 308 | spinlock_t context_switch_lock; |
309 | 309 | ||
310 | struct nvbios vbios; | 310 | struct nvbios vbios; |
311 | u8 *mxms; | ||
312 | |||
313 | struct backlight_device *backlight; | ||
314 | }; | 311 | }; |
315 | 312 | ||
316 | static inline struct drm_nouveau_private * | 313 | static inline struct drm_nouveau_private * |
@@ -544,4 +541,11 @@ nv_match_device(struct drm_device *dev, unsigned device, | |||
544 | dev->pdev->subsystem_device == sub_device; | 541 | dev->pdev->subsystem_device == sub_device; |
545 | } | 542 | } |
546 | 543 | ||
544 | static inline struct nv04_display * | ||
545 | nv04_display(struct drm_device *dev) | ||
546 | { | ||
547 | struct drm_nouveau_private *dev_priv = dev->dev_private; | ||
548 | return dev_priv->engine.display.priv; | ||
549 | } | ||
550 | |||
547 | #endif /* __NOUVEAU_DRV_H__ */ | 551 | #endif /* __NOUVEAU_DRV_H__ */ |
diff --git a/drivers/gpu/drm/nouveau/nouveau_encoder.h b/drivers/gpu/drm/nouveau/nouveau_encoder.h index 07cda5840166..5b5d0148f8bf 100644 --- a/drivers/gpu/drm/nouveau/nouveau_encoder.h +++ b/drivers/gpu/drm/nouveau/nouveau_encoder.h | |||
@@ -27,8 +27,9 @@ | |||
27 | #ifndef __NOUVEAU_ENCODER_H__ | 27 | #ifndef __NOUVEAU_ENCODER_H__ |
28 | #define __NOUVEAU_ENCODER_H__ | 28 | #define __NOUVEAU_ENCODER_H__ |
29 | 29 | ||
30 | #include <subdev/bios/dcb.h> | ||
31 | |||
30 | #include "drm_encoder_slave.h" | 32 | #include "drm_encoder_slave.h" |
31 | #include "nouveau_drv.h" | ||
32 | #include "nv04_display.h" | 33 | #include "nv04_display.h" |
33 | 34 | ||
34 | #define NV_DPMS_CLEARED 0x80 | 35 | #define NV_DPMS_CLEARED 0x80 |
diff --git a/drivers/gpu/drm/nouveau/nv04_display.h b/drivers/gpu/drm/nouveau/nv04_display.h index 29dc4f727f7e..139b8b057534 100644 --- a/drivers/gpu/drm/nouveau/nv04_display.h +++ b/drivers/gpu/drm/nouveau/nv04_display.h | |||
@@ -1,6 +1,8 @@ | |||
1 | #ifndef __NV04_DISPLAY_H__ | 1 | #ifndef __NV04_DISPLAY_H__ |
2 | #define __NV04_DISPLAY_H__ | 2 | #define __NV04_DISPLAY_H__ |
3 | 3 | ||
4 | #include <subdev/bios/pll.h> | ||
5 | |||
4 | enum nv04_fp_display_regs { | 6 | enum nv04_fp_display_regs { |
5 | FP_DISPLAY_END, | 7 | FP_DISPLAY_END, |
6 | FP_TOTAL, | 8 | FP_TOTAL, |
@@ -78,13 +80,6 @@ struct nv04_display { | |||
78 | uint32_t dac_users[4]; | 80 | uint32_t dac_users[4]; |
79 | }; | 81 | }; |
80 | 82 | ||
81 | static inline struct nv04_display * | ||
82 | nv04_display(struct drm_device *dev) | ||
83 | { | ||
84 | struct drm_nouveau_private *dev_priv = dev->dev_private; | ||
85 | return dev_priv->engine.display.priv; | ||
86 | } | ||
87 | |||
88 | /* nv04_display.c */ | 83 | /* nv04_display.c */ |
89 | int nv04_display_early_init(struct drm_device *); | 84 | int nv04_display_early_init(struct drm_device *); |
90 | void nv04_display_late_takedown(struct drm_device *); | 85 | void nv04_display_late_takedown(struct drm_device *); |