diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-05-24 15:42:54 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-05-24 15:42:54 -0400 |
commit | f2fde3a65e88330017b816faf2ef75f141d21375 (patch) | |
tree | 57152ab5756e7ed1c58742e7e16f13a45ff11f21 /drivers/gpu/drm/gma500/opregion.c | |
parent | 28f3d717618156c0dcd2f497d791b578a7931d87 (diff) | |
parent | 8c914028f5ddaa417b7d0f4b7fdc24caceaa8043 (diff) |
Merge branch 'drm-core-next' of git://people.freedesktop.org/~airlied/linux
Pull main drm updates from Dave Airlie:
"This is the main merge window request for the drm.
It's big, but jam packed will lots of features and of course 0
regressions. (okay maybe there'll be one).
Highlights:
- new KMS drivers for server GPU chipsets: ast, mgag200 and cirrus
(qemu only). These drivers use the generic modesetting drivers.
- initial prime/dma-buf support for i915, nouveau, radeon, udl and
exynos
- switcheroo audio support: so GPUs with HDMI can turn off the sound
driver without crashing stuff.
- There are some patches drifting outside drivers/gpu into x86 and
EFI for better handling of multiple video adapters in Apple Macs,
they've got correct acks except one trivial fixup.
- Core:
edid parser has better DMT and reduced blanking support,
crtc properties,
plane properties,
- Drivers:
exynos: add 2D core accel support, prime support, hdmi features
intel: more Haswell support, initial Valleyview support, more
hdmi infoframe fixes, update MAINTAINERS for Daniel, lots of
cleanups and fixes
radeon: more HDMI audio support, improved GPU lockup recovery
support, remove nested mutexes, less memory copying on PCIE, fix
bus master enable race (kexec), improved fence handling
gma500: cleanups, 1080p support, acpi fixes
nouveau: better nva3 memory reclocking, kepler accel (needs
external firmware rip), async buffer moves on nv84+ hw.
I've some more dma-buf patches that rely on the dma-buf merge for vmap
stuff, and I've a few fixes building up, but I'd decided I'd better
get rid of the main pull sooner rather than later, so the audio guys
are also unblocked."
Fix up trivial conflict due to some duplicated changes in
drivers/gpu/drm/i915/intel_ringbuffer.c
* 'drm-core-next' of git://people.freedesktop.org/~airlied/linux: (605 commits)
drm/nouveau/nvd9: Fix GPIO initialisation sequence.
drm/nouveau: Unregister switcheroo client on exit
drm/nouveau: Check dsm on switcheroo unregister
drm/nouveau: fix a minor annoyance in an output string
drm/nouveau: turn a BUG into a WARN
drm/nv50: decode PGRAPH DATA_ERROR = 0x24
drm/nouveau/disp: fix dithering not being enabled on some eDP macbooks
drm/nvd9/copy: initialise copy engine, seems to work like nvc0
drm/nvc0/ttm: use copy engines for async buffer moves
drm/nva3/ttm: use copy engine for async buffer moves
drm/nv98/ttm: add in a (disabled) crypto engine buffer copy method
drm/nv84/ttm: use crypto engine for async buffer copies
drm/nouveau/ttm: untangle code to support accelerated buffer moves
drm/nouveau/fbcon: use fence for sync, rather than notifier
drm/nv98/crypt: non-stub implementation of the engine hooks
drm/nouveau/fifo: turn all fifo modules into engine modules
drm/nv50/graph: remove ability to do interrupt-driven context switching
drm/nv50: remove manual context unload on context destruction
drm/nv50: remove execution engine context saves on suspend
drm/nv50/fifo: use hardware channel kickoff functionality
...
Diffstat (limited to 'drivers/gpu/drm/gma500/opregion.c')
-rw-r--r-- | drivers/gpu/drm/gma500/opregion.c | 344 |
1 files changed, 344 insertions, 0 deletions
diff --git a/drivers/gpu/drm/gma500/opregion.c b/drivers/gpu/drm/gma500/opregion.c new file mode 100644 index 000000000000..4f186eca3a30 --- /dev/null +++ b/drivers/gpu/drm/gma500/opregion.c | |||
@@ -0,0 +1,344 @@ | |||
1 | /* | ||
2 | * Copyright 2011 Intel Corporation | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice (including the next | ||
12 | * paragraph) shall be included in all copies or substantial portions of the | ||
13 | * Software. | ||
14 | * | ||
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
21 | * DEALINGS IN THE SOFTWARE. | ||
22 | * | ||
23 | */ | ||
24 | #include <linux/acpi.h> | ||
25 | #include <linux/acpi_io.h> | ||
26 | #include "psb_drv.h" | ||
27 | #include "psb_intel_reg.h" | ||
28 | |||
29 | #define PCI_ASLE 0xe4 | ||
30 | #define PCI_ASLS 0xfc | ||
31 | |||
32 | #define OPREGION_HEADER_OFFSET 0 | ||
33 | #define OPREGION_ACPI_OFFSET 0x100 | ||
34 | #define ACPI_CLID 0x01ac /* current lid state indicator */ | ||
35 | #define ACPI_CDCK 0x01b0 /* current docking state indicator */ | ||
36 | #define OPREGION_SWSCI_OFFSET 0x200 | ||
37 | #define OPREGION_ASLE_OFFSET 0x300 | ||
38 | #define OPREGION_VBT_OFFSET 0x400 | ||
39 | |||
40 | #define OPREGION_SIGNATURE "IntelGraphicsMem" | ||
41 | #define MBOX_ACPI (1<<0) | ||
42 | #define MBOX_SWSCI (1<<1) | ||
43 | #define MBOX_ASLE (1<<2) | ||
44 | |||
45 | struct opregion_header { | ||
46 | u8 signature[16]; | ||
47 | u32 size; | ||
48 | u32 opregion_ver; | ||
49 | u8 bios_ver[32]; | ||
50 | u8 vbios_ver[16]; | ||
51 | u8 driver_ver[16]; | ||
52 | u32 mboxes; | ||
53 | u8 reserved[164]; | ||
54 | } __packed; | ||
55 | |||
56 | /* OpRegion mailbox #1: public ACPI methods */ | ||
57 | struct opregion_acpi { | ||
58 | u32 drdy; /* driver readiness */ | ||
59 | u32 csts; /* notification status */ | ||
60 | u32 cevt; /* current event */ | ||
61 | u8 rsvd1[20]; | ||
62 | u32 didl[8]; /* supported display devices ID list */ | ||
63 | u32 cpdl[8]; /* currently presented display list */ | ||
64 | u32 cadl[8]; /* currently active display list */ | ||
65 | u32 nadl[8]; /* next active devices list */ | ||
66 | u32 aslp; /* ASL sleep time-out */ | ||
67 | u32 tidx; /* toggle table index */ | ||
68 | u32 chpd; /* current hotplug enable indicator */ | ||
69 | u32 clid; /* current lid state*/ | ||
70 | u32 cdck; /* current docking state */ | ||
71 | u32 sxsw; /* Sx state resume */ | ||
72 | u32 evts; /* ASL supported events */ | ||
73 | u32 cnot; /* current OS notification */ | ||
74 | u32 nrdy; /* driver status */ | ||
75 | u8 rsvd2[60]; | ||
76 | } __packed; | ||
77 | |||
78 | /* OpRegion mailbox #2: SWSCI */ | ||
79 | struct opregion_swsci { | ||
80 | /*FIXME: add it later*/ | ||
81 | } __packed; | ||
82 | |||
83 | /* OpRegion mailbox #3: ASLE */ | ||
84 | struct opregion_asle { | ||
85 | u32 ardy; /* driver readiness */ | ||
86 | u32 aslc; /* ASLE interrupt command */ | ||
87 | u32 tche; /* technology enabled indicator */ | ||
88 | u32 alsi; /* current ALS illuminance reading */ | ||
89 | u32 bclp; /* backlight brightness to set */ | ||
90 | u32 pfit; /* panel fitting state */ | ||
91 | u32 cblv; /* current brightness level */ | ||
92 | u16 bclm[20]; /* backlight level duty cycle mapping table */ | ||
93 | u32 cpfm; /* current panel fitting mode */ | ||
94 | u32 epfm; /* enabled panel fitting modes */ | ||
95 | u8 plut[74]; /* panel LUT and identifier */ | ||
96 | u32 pfmb; /* PWM freq and min brightness */ | ||
97 | u8 rsvd[102]; | ||
98 | } __packed; | ||
99 | |||
100 | /* ASLE irq request bits */ | ||
101 | #define ASLE_SET_ALS_ILLUM (1 << 0) | ||
102 | #define ASLE_SET_BACKLIGHT (1 << 1) | ||
103 | #define ASLE_SET_PFIT (1 << 2) | ||
104 | #define ASLE_SET_PWM_FREQ (1 << 3) | ||
105 | #define ASLE_REQ_MSK 0xf | ||
106 | |||
107 | /* response bits of ASLE irq request */ | ||
108 | #define ASLE_ALS_ILLUM_FAILED (1<<10) | ||
109 | #define ASLE_BACKLIGHT_FAILED (1<<12) | ||
110 | #define ASLE_PFIT_FAILED (1<<14) | ||
111 | #define ASLE_PWM_FREQ_FAILED (1<<16) | ||
112 | |||
113 | /* ASLE backlight brightness to set */ | ||
114 | #define ASLE_BCLP_VALID (1<<31) | ||
115 | #define ASLE_BCLP_MSK (~(1<<31)) | ||
116 | |||
117 | /* ASLE panel fitting request */ | ||
118 | #define ASLE_PFIT_VALID (1<<31) | ||
119 | #define ASLE_PFIT_CENTER (1<<0) | ||
120 | #define ASLE_PFIT_STRETCH_TEXT (1<<1) | ||
121 | #define ASLE_PFIT_STRETCH_GFX (1<<2) | ||
122 | |||
123 | /* response bits of ASLE irq request */ | ||
124 | #define ASLE_ALS_ILLUM_FAILED (1<<10) | ||
125 | #define ASLE_BACKLIGHT_FAILED (1<<12) | ||
126 | #define ASLE_PFIT_FAILED (1<<14) | ||
127 | #define ASLE_PWM_FREQ_FAILED (1<<16) | ||
128 | |||
129 | /* ASLE backlight brightness to set */ | ||
130 | #define ASLE_BCLP_VALID (1<<31) | ||
131 | #define ASLE_BCLP_MSK (~(1<<31)) | ||
132 | |||
133 | /* ASLE panel fitting request */ | ||
134 | #define ASLE_PFIT_VALID (1<<31) | ||
135 | #define ASLE_PFIT_CENTER (1<<0) | ||
136 | #define ASLE_PFIT_STRETCH_TEXT (1<<1) | ||
137 | #define ASLE_PFIT_STRETCH_GFX (1<<2) | ||
138 | |||
139 | /* PWM frequency and minimum brightness */ | ||
140 | #define ASLE_PFMB_BRIGHTNESS_MASK (0xff) | ||
141 | #define ASLE_PFMB_BRIGHTNESS_VALID (1<<8) | ||
142 | #define ASLE_PFMB_PWM_MASK (0x7ffffe00) | ||
143 | #define ASLE_PFMB_PWM_VALID (1<<31) | ||
144 | |||
145 | #define ASLE_CBLV_VALID (1<<31) | ||
146 | |||
147 | static u32 asle_set_backlight(struct drm_device *dev, u32 bclp) | ||
148 | { | ||
149 | struct drm_psb_private *dev_priv = dev->dev_private; | ||
150 | struct opregion_asle *asle = dev_priv->opregion.asle; | ||
151 | struct backlight_device *bd = dev_priv->backlight_device; | ||
152 | |||
153 | DRM_DEBUG_DRIVER("asle set backlight %x\n", bclp); | ||
154 | |||
155 | if (!(bclp & ASLE_BCLP_VALID)) | ||
156 | return ASLE_BACKLIGHT_FAILED; | ||
157 | |||
158 | if (bd == NULL) | ||
159 | return ASLE_BACKLIGHT_FAILED; | ||
160 | |||
161 | bclp &= ASLE_BCLP_MSK; | ||
162 | if (bclp > 255) | ||
163 | return ASLE_BACKLIGHT_FAILED; | ||
164 | |||
165 | if (config_enabled(CONFIG_BACKLIGHT_CLASS_DEVICE)) { | ||
166 | int max = bd->props.max_brightness; | ||
167 | bd->props.brightness = bclp * max / 255; | ||
168 | backlight_update_status(bd); | ||
169 | } | ||
170 | |||
171 | asle->cblv = (bclp * 0x64) / 0xff | ASLE_CBLV_VALID; | ||
172 | |||
173 | return 0; | ||
174 | } | ||
175 | |||
176 | void psb_intel_opregion_asle_intr(struct drm_device *dev) | ||
177 | { | ||
178 | struct drm_psb_private *dev_priv = dev->dev_private; | ||
179 | struct opregion_asle *asle = dev_priv->opregion.asle; | ||
180 | u32 asle_stat = 0; | ||
181 | u32 asle_req; | ||
182 | |||
183 | if (!asle) | ||
184 | return; | ||
185 | |||
186 | asle_req = asle->aslc & ASLE_REQ_MSK; | ||
187 | if (!asle_req) { | ||
188 | DRM_DEBUG_DRIVER("non asle set request??\n"); | ||
189 | return; | ||
190 | } | ||
191 | |||
192 | if (asle_req & ASLE_SET_BACKLIGHT) | ||
193 | asle_stat |= asle_set_backlight(dev, asle->bclp); | ||
194 | |||
195 | asle->aslc = asle_stat; | ||
196 | } | ||
197 | |||
198 | #define ASLE_ALS_EN (1<<0) | ||
199 | #define ASLE_BLC_EN (1<<1) | ||
200 | #define ASLE_PFIT_EN (1<<2) | ||
201 | #define ASLE_PFMB_EN (1<<3) | ||
202 | |||
203 | void psb_intel_opregion_enable_asle(struct drm_device *dev) | ||
204 | { | ||
205 | struct drm_psb_private *dev_priv = dev->dev_private; | ||
206 | struct opregion_asle *asle = dev_priv->opregion.asle; | ||
207 | |||
208 | if (asle) { | ||
209 | /* Don't do this on Medfield or other non PC like devices, they | ||
210 | use the bit for something different altogether */ | ||
211 | psb_enable_pipestat(dev_priv, 0, PIPE_LEGACY_BLC_EVENT_ENABLE); | ||
212 | psb_enable_pipestat(dev_priv, 1, PIPE_LEGACY_BLC_EVENT_ENABLE); | ||
213 | |||
214 | asle->tche = ASLE_ALS_EN | ASLE_BLC_EN | ASLE_PFIT_EN | ||
215 | | ASLE_PFMB_EN; | ||
216 | asle->ardy = 1; | ||
217 | } | ||
218 | } | ||
219 | |||
220 | #define ACPI_EV_DISPLAY_SWITCH (1<<0) | ||
221 | #define ACPI_EV_LID (1<<1) | ||
222 | #define ACPI_EV_DOCK (1<<2) | ||
223 | |||
224 | static struct psb_intel_opregion *system_opregion; | ||
225 | |||
226 | static int psb_intel_opregion_video_event(struct notifier_block *nb, | ||
227 | unsigned long val, void *data) | ||
228 | { | ||
229 | /* The only video events relevant to opregion are 0x80. These indicate | ||
230 | either a docking event, lid switch or display switch request. In | ||
231 | Linux, these are handled by the dock, button and video drivers. | ||
232 | We might want to fix the video driver to be opregion-aware in | ||
233 | future, but right now we just indicate to the firmware that the | ||
234 | request has been handled */ | ||
235 | |||
236 | struct opregion_acpi *acpi; | ||
237 | |||
238 | if (!system_opregion) | ||
239 | return NOTIFY_DONE; | ||
240 | |||
241 | acpi = system_opregion->acpi; | ||
242 | acpi->csts = 0; | ||
243 | |||
244 | return NOTIFY_OK; | ||
245 | } | ||
246 | |||
247 | static struct notifier_block psb_intel_opregion_notifier = { | ||
248 | .notifier_call = psb_intel_opregion_video_event, | ||
249 | }; | ||
250 | |||
251 | void psb_intel_opregion_init(struct drm_device *dev) | ||
252 | { | ||
253 | struct drm_psb_private *dev_priv = dev->dev_private; | ||
254 | struct psb_intel_opregion *opregion = &dev_priv->opregion; | ||
255 | |||
256 | if (!opregion->header) | ||
257 | return; | ||
258 | |||
259 | if (opregion->acpi) { | ||
260 | /* Notify BIOS we are ready to handle ACPI video ext notifs. | ||
261 | * Right now, all the events are handled by the ACPI video | ||
262 | * module. We don't actually need to do anything with them. */ | ||
263 | opregion->acpi->csts = 0; | ||
264 | opregion->acpi->drdy = 1; | ||
265 | |||
266 | system_opregion = opregion; | ||
267 | register_acpi_notifier(&psb_intel_opregion_notifier); | ||
268 | } | ||
269 | |||
270 | if (opregion->asle) | ||
271 | psb_intel_opregion_enable_asle(dev); | ||
272 | } | ||
273 | |||
274 | void psb_intel_opregion_fini(struct drm_device *dev) | ||
275 | { | ||
276 | struct drm_psb_private *dev_priv = dev->dev_private; | ||
277 | struct psb_intel_opregion *opregion = &dev_priv->opregion; | ||
278 | |||
279 | if (!opregion->header) | ||
280 | return; | ||
281 | |||
282 | if (opregion->acpi) { | ||
283 | opregion->acpi->drdy = 0; | ||
284 | |||
285 | system_opregion = NULL; | ||
286 | unregister_acpi_notifier(&psb_intel_opregion_notifier); | ||
287 | } | ||
288 | |||
289 | /* just clear all opregion memory pointers now */ | ||
290 | iounmap(opregion->header); | ||
291 | opregion->header = NULL; | ||
292 | opregion->acpi = NULL; | ||
293 | opregion->swsci = NULL; | ||
294 | opregion->asle = NULL; | ||
295 | opregion->vbt = NULL; | ||
296 | } | ||
297 | |||
298 | int psb_intel_opregion_setup(struct drm_device *dev) | ||
299 | { | ||
300 | struct drm_psb_private *dev_priv = dev->dev_private; | ||
301 | struct psb_intel_opregion *opregion = &dev_priv->opregion; | ||
302 | u32 opregion_phy, mboxes; | ||
303 | void __iomem *base; | ||
304 | int err = 0; | ||
305 | |||
306 | pci_read_config_dword(dev->pdev, PCI_ASLS, &opregion_phy); | ||
307 | if (opregion_phy == 0) { | ||
308 | DRM_DEBUG_DRIVER("ACPI Opregion not supported\n"); | ||
309 | return -ENOTSUPP; | ||
310 | } | ||
311 | DRM_DEBUG("OpRegion detected at 0x%8x\n", opregion_phy); | ||
312 | base = acpi_os_ioremap(opregion_phy, 8*1024); | ||
313 | if (!base) | ||
314 | return -ENOMEM; | ||
315 | |||
316 | if (memcmp(base, OPREGION_SIGNATURE, 16)) { | ||
317 | DRM_DEBUG_DRIVER("opregion signature mismatch\n"); | ||
318 | err = -EINVAL; | ||
319 | goto err_out; | ||
320 | } | ||
321 | |||
322 | opregion->header = base; | ||
323 | opregion->vbt = base + OPREGION_VBT_OFFSET; | ||
324 | |||
325 | opregion->lid_state = base + ACPI_CLID; | ||
326 | |||
327 | mboxes = opregion->header->mboxes; | ||
328 | if (mboxes & MBOX_ACPI) { | ||
329 | DRM_DEBUG_DRIVER("Public ACPI methods supported\n"); | ||
330 | opregion->acpi = base + OPREGION_ACPI_OFFSET; | ||
331 | } | ||
332 | |||
333 | if (mboxes & MBOX_ASLE) { | ||
334 | DRM_DEBUG_DRIVER("ASLE supported\n"); | ||
335 | opregion->asle = base + OPREGION_ASLE_OFFSET; | ||
336 | } | ||
337 | |||
338 | return 0; | ||
339 | |||
340 | err_out: | ||
341 | iounmap(base); | ||
342 | return err; | ||
343 | } | ||
344 | |||