OMAPDSS: VENC: fix NULL pointer dereference in DSS2 VENC sysfs debug attr on OMAP4
[zen-stable.git] / drivers / gpu / drm / gma500 / psb_drv.c
blobf14768f2b364e78da7afd88521a108e365c1b7b7
1 /**************************************************************************
2 * Copyright (c) 2007-2011, Intel Corporation.
3 * All Rights Reserved.
4 * Copyright (c) 2008, Tungsten Graphics, Inc. Cedar Park, TX., USA.
5 * All Rights Reserved.
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms and conditions of the GNU General Public License,
9 * version 2, as published by the Free Software Foundation.
11 * This program is distributed in the hope it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
16 * You should have received a copy of the GNU General Public License along with
17 * this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
20 **************************************************************************/
22 #include <drm/drmP.h>
23 #include <drm/drm.h>
24 #include "gma_drm.h"
25 #include "psb_drv.h"
26 #include "framebuffer.h"
27 #include "psb_reg.h"
28 #include "psb_intel_reg.h"
29 #include "intel_bios.h"
30 #include "mid_bios.h"
31 #include <drm/drm_pciids.h>
32 #include "power.h"
33 #include <linux/cpu.h>
34 #include <linux/notifier.h>
35 #include <linux/spinlock.h>
36 #include <linux/pm_runtime.h>
37 #include <acpi/video.h>
38 #include <linux/module.h>
40 static int drm_psb_trap_pagefaults;
42 static int psb_probe(struct pci_dev *pdev, const struct pci_device_id *ent);
44 MODULE_PARM_DESC(trap_pagefaults, "Error and reset on MMU pagefaults");
45 module_param_named(trap_pagefaults, drm_psb_trap_pagefaults, int, 0600);
48 static DEFINE_PCI_DEVICE_TABLE(pciidlist) = {
49 { 0x8086, 0x8108, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &psb_chip_ops },
50 { 0x8086, 0x8109, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &psb_chip_ops },
51 #if defined(CONFIG_DRM_GMA600)
52 { 0x8086, 0x4100, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &oaktrail_chip_ops},
53 { 0x8086, 0x4101, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &oaktrail_chip_ops},
54 { 0x8086, 0x4102, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &oaktrail_chip_ops},
55 { 0x8086, 0x4103, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &oaktrail_chip_ops},
56 { 0x8086, 0x4104, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &oaktrail_chip_ops},
57 { 0x8086, 0x4105, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &oaktrail_chip_ops},
58 { 0x8086, 0x4106, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &oaktrail_chip_ops},
59 { 0x8086, 0x4107, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &oaktrail_chip_ops},
60 /* Atom E620 */
61 { 0x8086, 0x4108, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &oaktrail_chip_ops},
62 #endif
63 #if defined(CONFIG_DRM_GMA3600)
64 { 0x8086, 0x0be0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
65 { 0x8086, 0x0be1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
66 { 0x8086, 0x0be2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
67 { 0x8086, 0x0be3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
68 { 0x8086, 0x0be4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
69 { 0x8086, 0x0be5, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
70 { 0x8086, 0x0be6, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
71 { 0x8086, 0x0be7, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
72 #endif
73 { 0, 0, 0}
75 MODULE_DEVICE_TABLE(pci, pciidlist);
78 * Standard IOCTLs.
81 #define DRM_IOCTL_PSB_ADB \
82 DRM_IOWR(DRM_GMA_ADB + DRM_COMMAND_BASE, uint32_t)
83 #define DRM_IOCTL_PSB_MODE_OPERATION \
84 DRM_IOWR(DRM_GMA_MODE_OPERATION + DRM_COMMAND_BASE, \
85 struct drm_psb_mode_operation_arg)
86 #define DRM_IOCTL_PSB_STOLEN_MEMORY \
87 DRM_IOWR(DRM_GMA_STOLEN_MEMORY + DRM_COMMAND_BASE, \
88 struct drm_psb_stolen_memory_arg)
89 #define DRM_IOCTL_PSB_GAMMA \
90 DRM_IOWR(DRM_GMA_GAMMA + DRM_COMMAND_BASE, \
91 struct drm_psb_dpst_lut_arg)
92 #define DRM_IOCTL_PSB_DPST_BL \
93 DRM_IOWR(DRM_GMA_DPST_BL + DRM_COMMAND_BASE, \
94 uint32_t)
95 #define DRM_IOCTL_PSB_GET_PIPE_FROM_CRTC_ID \
96 DRM_IOWR(DRM_GMA_GET_PIPE_FROM_CRTC_ID + DRM_COMMAND_BASE, \
97 struct drm_psb_get_pipe_from_crtc_id_arg)
98 #define DRM_IOCTL_PSB_GEM_CREATE \
99 DRM_IOWR(DRM_GMA_GEM_CREATE + DRM_COMMAND_BASE, \
100 struct drm_psb_gem_create)
101 #define DRM_IOCTL_PSB_GEM_MMAP \
102 DRM_IOWR(DRM_GMA_GEM_MMAP + DRM_COMMAND_BASE, \
103 struct drm_psb_gem_mmap)
105 static int psb_adb_ioctl(struct drm_device *dev, void *data,
106 struct drm_file *file_priv);
107 static int psb_mode_operation_ioctl(struct drm_device *dev, void *data,
108 struct drm_file *file_priv);
109 static int psb_stolen_memory_ioctl(struct drm_device *dev, void *data,
110 struct drm_file *file_priv);
111 static int psb_gamma_ioctl(struct drm_device *dev, void *data,
112 struct drm_file *file_priv);
113 static int psb_dpst_bl_ioctl(struct drm_device *dev, void *data,
114 struct drm_file *file_priv);
116 #define PSB_IOCTL_DEF(ioctl, func, flags) \
117 [DRM_IOCTL_NR(ioctl) - DRM_COMMAND_BASE] = {ioctl, flags, func}
119 static struct drm_ioctl_desc psb_ioctls[] = {
120 PSB_IOCTL_DEF(DRM_IOCTL_PSB_ADB, psb_adb_ioctl, DRM_AUTH),
121 PSB_IOCTL_DEF(DRM_IOCTL_PSB_MODE_OPERATION, psb_mode_operation_ioctl,
122 DRM_AUTH),
123 PSB_IOCTL_DEF(DRM_IOCTL_PSB_STOLEN_MEMORY, psb_stolen_memory_ioctl,
124 DRM_AUTH),
125 PSB_IOCTL_DEF(DRM_IOCTL_PSB_GAMMA, psb_gamma_ioctl, DRM_AUTH),
126 PSB_IOCTL_DEF(DRM_IOCTL_PSB_DPST_BL, psb_dpst_bl_ioctl, DRM_AUTH),
127 PSB_IOCTL_DEF(DRM_IOCTL_PSB_GET_PIPE_FROM_CRTC_ID,
128 psb_intel_get_pipe_from_crtc_id, 0),
129 PSB_IOCTL_DEF(DRM_IOCTL_PSB_GEM_CREATE, psb_gem_create_ioctl,
130 DRM_UNLOCKED | DRM_AUTH),
131 PSB_IOCTL_DEF(DRM_IOCTL_PSB_GEM_MMAP, psb_gem_mmap_ioctl,
132 DRM_UNLOCKED | DRM_AUTH),
135 static void psb_lastclose(struct drm_device *dev)
137 return;
140 static void psb_do_takedown(struct drm_device *dev)
144 static int psb_do_init(struct drm_device *dev)
146 struct drm_psb_private *dev_priv = dev->dev_private;
147 struct psb_gtt *pg = &dev_priv->gtt;
149 uint32_t stolen_gtt;
151 int ret = -ENOMEM;
153 if (pg->mmu_gatt_start & 0x0FFFFFFF) {
154 dev_err(dev->dev, "Gatt must be 256M aligned. This is a bug.\n");
155 ret = -EINVAL;
156 goto out_err;
160 stolen_gtt = (pg->stolen_size >> PAGE_SHIFT) * 4;
161 stolen_gtt = (stolen_gtt + PAGE_SIZE - 1) >> PAGE_SHIFT;
162 stolen_gtt =
163 (stolen_gtt < pg->gtt_pages) ? stolen_gtt : pg->gtt_pages;
165 dev_priv->gatt_free_offset = pg->mmu_gatt_start +
166 (stolen_gtt << PAGE_SHIFT) * 1024;
168 if (1 || drm_debug) {
169 uint32_t core_id = PSB_RSGX32(PSB_CR_CORE_ID);
170 uint32_t core_rev = PSB_RSGX32(PSB_CR_CORE_REVISION);
171 DRM_INFO("SGX core id = 0x%08x\n", core_id);
172 DRM_INFO("SGX core rev major = 0x%02x, minor = 0x%02x\n",
173 (core_rev & _PSB_CC_REVISION_MAJOR_MASK) >>
174 _PSB_CC_REVISION_MAJOR_SHIFT,
175 (core_rev & _PSB_CC_REVISION_MINOR_MASK) >>
176 _PSB_CC_REVISION_MINOR_SHIFT);
177 DRM_INFO
178 ("SGX core rev maintenance = 0x%02x, designer = 0x%02x\n",
179 (core_rev & _PSB_CC_REVISION_MAINTENANCE_MASK) >>
180 _PSB_CC_REVISION_MAINTENANCE_SHIFT,
181 (core_rev & _PSB_CC_REVISION_DESIGNER_MASK) >>
182 _PSB_CC_REVISION_DESIGNER_SHIFT);
186 spin_lock_init(&dev_priv->irqmask_lock);
187 spin_lock_init(&dev_priv->lock_2d);
189 PSB_WSGX32(0x00000000, PSB_CR_BIF_BANK0);
190 PSB_WSGX32(0x00000000, PSB_CR_BIF_BANK1);
191 PSB_RSGX32(PSB_CR_BIF_BANK1);
192 PSB_WSGX32(PSB_RSGX32(PSB_CR_BIF_CTRL) | _PSB_MMU_ER_MASK,
193 PSB_CR_BIF_CTRL);
194 psb_spank(dev_priv);
196 /* mmu_gatt ?? */
197 PSB_WSGX32(pg->gatt_start, PSB_CR_BIF_TWOD_REQ_BASE);
198 return 0;
199 out_err:
200 psb_do_takedown(dev);
201 return ret;
204 static int psb_driver_unload(struct drm_device *dev)
206 struct drm_psb_private *dev_priv = dev->dev_private;
208 /* Kill vblank etc here */
210 gma_backlight_exit(dev);
212 psb_modeset_cleanup(dev);
214 if (dev_priv) {
215 psb_lid_timer_takedown(dev_priv);
216 gma_intel_opregion_exit(dev);
218 if (dev_priv->ops->chip_teardown)
219 dev_priv->ops->chip_teardown(dev);
220 psb_do_takedown(dev);
223 if (dev_priv->pf_pd) {
224 psb_mmu_free_pagedir(dev_priv->pf_pd);
225 dev_priv->pf_pd = NULL;
227 if (dev_priv->mmu) {
228 struct psb_gtt *pg = &dev_priv->gtt;
230 down_read(&pg->sem);
231 psb_mmu_remove_pfn_sequence(
232 psb_mmu_get_default_pd
233 (dev_priv->mmu),
234 pg->mmu_gatt_start,
235 dev_priv->vram_stolen_size >> PAGE_SHIFT);
236 up_read(&pg->sem);
237 psb_mmu_driver_takedown(dev_priv->mmu);
238 dev_priv->mmu = NULL;
240 psb_gtt_takedown(dev);
241 if (dev_priv->scratch_page) {
242 __free_page(dev_priv->scratch_page);
243 dev_priv->scratch_page = NULL;
245 if (dev_priv->vdc_reg) {
246 iounmap(dev_priv->vdc_reg);
247 dev_priv->vdc_reg = NULL;
249 if (dev_priv->sgx_reg) {
250 iounmap(dev_priv->sgx_reg);
251 dev_priv->sgx_reg = NULL;
254 kfree(dev_priv);
255 dev->dev_private = NULL;
257 /*destroy VBT data*/
258 psb_intel_destroy_bios(dev);
261 gma_power_uninit(dev);
263 return 0;
267 static int psb_driver_load(struct drm_device *dev, unsigned long chipset)
269 struct drm_psb_private *dev_priv;
270 unsigned long resource_start;
271 struct psb_gtt *pg;
272 unsigned long irqflags;
273 int ret = -ENOMEM;
274 uint32_t tt_pages;
275 struct drm_connector *connector;
276 struct psb_intel_encoder *psb_intel_encoder;
278 dev_priv = kzalloc(sizeof(*dev_priv), GFP_KERNEL);
279 if (dev_priv == NULL)
280 return -ENOMEM;
282 dev_priv->ops = (struct psb_ops *)chipset;
283 dev_priv->dev = dev;
284 dev->dev_private = (void *) dev_priv;
286 if (!IS_PSB(dev)) {
287 if (pci_enable_msi(dev->pdev))
288 dev_warn(dev->dev, "Enabling MSI failed!\n");
291 dev_priv->num_pipe = dev_priv->ops->pipes;
293 resource_start = pci_resource_start(dev->pdev, PSB_MMIO_RESOURCE);
295 dev_priv->vdc_reg =
296 ioremap(resource_start + PSB_VDC_OFFSET, PSB_VDC_SIZE);
297 if (!dev_priv->vdc_reg)
298 goto out_err;
300 dev_priv->sgx_reg = ioremap(resource_start + dev_priv->ops->sgx_offset,
301 PSB_SGX_SIZE);
302 if (!dev_priv->sgx_reg)
303 goto out_err;
305 ret = dev_priv->ops->chip_setup(dev);
306 if (ret)
307 goto out_err;
309 /* Init OSPM support */
310 gma_power_init(dev);
312 ret = -ENOMEM;
314 dev_priv->scratch_page = alloc_page(GFP_DMA32 | __GFP_ZERO);
315 if (!dev_priv->scratch_page)
316 goto out_err;
318 set_pages_uc(dev_priv->scratch_page, 1);
320 ret = psb_gtt_init(dev, 0);
321 if (ret)
322 goto out_err;
324 dev_priv->mmu = psb_mmu_driver_init((void *)0,
325 drm_psb_trap_pagefaults, 0,
326 dev_priv);
327 if (!dev_priv->mmu)
328 goto out_err;
330 pg = &dev_priv->gtt;
332 tt_pages = (pg->gatt_pages < PSB_TT_PRIV0_PLIMIT) ?
333 (pg->gatt_pages) : PSB_TT_PRIV0_PLIMIT;
336 dev_priv->pf_pd = psb_mmu_alloc_pd(dev_priv->mmu, 1, 0);
337 if (!dev_priv->pf_pd)
338 goto out_err;
340 psb_mmu_set_pd_context(psb_mmu_get_default_pd(dev_priv->mmu), 0);
341 psb_mmu_set_pd_context(dev_priv->pf_pd, 1);
343 ret = psb_do_init(dev);
344 if (ret)
345 return ret;
347 PSB_WSGX32(0x20000000, PSB_CR_PDS_EXEC_BASE);
348 PSB_WSGX32(0x30000000, PSB_CR_BIF_3D_REQ_BASE);
350 /* igd_opregion_init(&dev_priv->opregion_dev); */
351 acpi_video_register();
352 if (dev_priv->lid_state)
353 psb_lid_timer_init(dev_priv);
355 ret = drm_vblank_init(dev, dev_priv->num_pipe);
356 if (ret)
357 goto out_err;
360 * Install interrupt handlers prior to powering off SGX or else we will
361 * crash.
363 dev_priv->vdc_irq_mask = 0;
364 dev_priv->pipestat[0] = 0;
365 dev_priv->pipestat[1] = 0;
366 dev_priv->pipestat[2] = 0;
367 spin_lock_irqsave(&dev_priv->irqmask_lock, irqflags);
368 PSB_WVDC32(0xFFFFFFFF, PSB_HWSTAM);
369 PSB_WVDC32(0x00000000, PSB_INT_ENABLE_R);
370 PSB_WVDC32(0xFFFFFFFF, PSB_INT_MASK_R);
371 spin_unlock_irqrestore(&dev_priv->irqmask_lock, irqflags);
372 if (IS_PSB(dev) && drm_core_check_feature(dev, DRIVER_MODESET))
373 drm_irq_install(dev);
375 dev->vblank_disable_allowed = 1;
377 dev->max_vblank_count = 0xffffff; /* only 24 bits of frame count */
379 dev->driver->get_vblank_counter = psb_get_vblank_counter;
381 psb_modeset_init(dev);
382 psb_fbdev_init(dev);
383 drm_kms_helper_poll_init(dev);
385 /* Only add backlight support if we have LVDS output */
386 list_for_each_entry(connector, &dev->mode_config.connector_list,
387 head) {
388 psb_intel_encoder = psb_intel_attached_encoder(connector);
390 switch (psb_intel_encoder->type) {
391 case INTEL_OUTPUT_LVDS:
392 case INTEL_OUTPUT_MIPI:
393 ret = gma_backlight_init(dev);
394 break;
398 if (ret)
399 return ret;
400 #if 0
401 /*enable runtime pm at last*/
402 pm_runtime_enable(&dev->pdev->dev);
403 pm_runtime_set_active(&dev->pdev->dev);
404 #endif
405 /*Intel drm driver load is done, continue doing pvr load*/
406 return 0;
407 out_err:
408 psb_driver_unload(dev);
409 return ret;
412 int psb_driver_device_is_agp(struct drm_device *dev)
414 return 0;
417 static inline void get_brightness(struct backlight_device *bd)
419 #ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
420 if (bd) {
421 bd->props.brightness = bd->ops->get_brightness(bd);
422 backlight_update_status(bd);
424 #endif
427 static int psb_dpst_bl_ioctl(struct drm_device *dev, void *data,
428 struct drm_file *file_priv)
430 struct drm_psb_private *dev_priv = psb_priv(dev);
431 uint32_t *arg = data;
433 dev_priv->blc_adj2 = *arg;
434 get_brightness(dev_priv->backlight_device);
435 return 0;
438 static int psb_adb_ioctl(struct drm_device *dev, void *data,
439 struct drm_file *file_priv)
441 struct drm_psb_private *dev_priv = psb_priv(dev);
442 uint32_t *arg = data;
444 dev_priv->blc_adj1 = *arg;
445 get_brightness(dev_priv->backlight_device);
446 return 0;
449 static int psb_gamma_ioctl(struct drm_device *dev, void *data,
450 struct drm_file *file_priv)
452 struct drm_psb_dpst_lut_arg *lut_arg = data;
453 struct drm_mode_object *obj;
454 struct drm_crtc *crtc;
455 struct drm_connector *connector;
456 struct psb_intel_crtc *psb_intel_crtc;
457 int i = 0;
458 int32_t obj_id;
460 obj_id = lut_arg->output_id;
461 obj = drm_mode_object_find(dev, obj_id, DRM_MODE_OBJECT_CONNECTOR);
462 if (!obj) {
463 dev_dbg(dev->dev, "Invalid Connector object.\n");
464 return -EINVAL;
467 connector = obj_to_connector(obj);
468 crtc = connector->encoder->crtc;
469 psb_intel_crtc = to_psb_intel_crtc(crtc);
471 for (i = 0; i < 256; i++)
472 psb_intel_crtc->lut_adj[i] = lut_arg->lut[i];
474 psb_intel_crtc_load_lut(crtc);
476 return 0;
479 static int psb_mode_operation_ioctl(struct drm_device *dev, void *data,
480 struct drm_file *file_priv)
482 uint32_t obj_id;
483 uint16_t op;
484 struct drm_mode_modeinfo *umode;
485 struct drm_display_mode *mode = NULL;
486 struct drm_psb_mode_operation_arg *arg;
487 struct drm_mode_object *obj;
488 struct drm_connector *connector;
489 struct drm_connector_helper_funcs *connector_funcs;
490 int ret = 0;
491 int resp = MODE_OK;
493 arg = (struct drm_psb_mode_operation_arg *)data;
494 obj_id = arg->obj_id;
495 op = arg->operation;
497 switch (op) {
498 case PSB_MODE_OPERATION_MODE_VALID:
499 umode = &arg->mode;
501 mutex_lock(&dev->mode_config.mutex);
503 obj = drm_mode_object_find(dev, obj_id,
504 DRM_MODE_OBJECT_CONNECTOR);
505 if (!obj) {
506 ret = -EINVAL;
507 goto mode_op_out;
510 connector = obj_to_connector(obj);
512 mode = drm_mode_create(dev);
513 if (!mode) {
514 ret = -ENOMEM;
515 goto mode_op_out;
518 /* drm_crtc_convert_umode(mode, umode); */
520 mode->clock = umode->clock;
521 mode->hdisplay = umode->hdisplay;
522 mode->hsync_start = umode->hsync_start;
523 mode->hsync_end = umode->hsync_end;
524 mode->htotal = umode->htotal;
525 mode->hskew = umode->hskew;
526 mode->vdisplay = umode->vdisplay;
527 mode->vsync_start = umode->vsync_start;
528 mode->vsync_end = umode->vsync_end;
529 mode->vtotal = umode->vtotal;
530 mode->vscan = umode->vscan;
531 mode->vrefresh = umode->vrefresh;
532 mode->flags = umode->flags;
533 mode->type = umode->type;
534 strncpy(mode->name, umode->name, DRM_DISPLAY_MODE_LEN);
535 mode->name[DRM_DISPLAY_MODE_LEN-1] = 0;
538 connector_funcs = (struct drm_connector_helper_funcs *)
539 connector->helper_private;
541 if (connector_funcs->mode_valid) {
542 resp = connector_funcs->mode_valid(connector, mode);
543 arg->data = resp;
546 /*do some clean up work*/
547 if (mode)
548 drm_mode_destroy(dev, mode);
549 mode_op_out:
550 mutex_unlock(&dev->mode_config.mutex);
551 return ret;
553 default:
554 dev_dbg(dev->dev, "Unsupported psb mode operation\n");
555 return -EOPNOTSUPP;
558 return 0;
561 static int psb_stolen_memory_ioctl(struct drm_device *dev, void *data,
562 struct drm_file *file_priv)
564 struct drm_psb_private *dev_priv = psb_priv(dev);
565 struct drm_psb_stolen_memory_arg *arg = data;
567 arg->base = dev_priv->stolen_base;
568 arg->size = dev_priv->vram_stolen_size;
570 return 0;
573 static int psb_driver_open(struct drm_device *dev, struct drm_file *priv)
575 return 0;
578 static void psb_driver_close(struct drm_device *dev, struct drm_file *priv)
582 static long psb_unlocked_ioctl(struct file *filp, unsigned int cmd,
583 unsigned long arg)
585 struct drm_file *file_priv = filp->private_data;
586 struct drm_device *dev = file_priv->minor->dev;
587 struct drm_psb_private *dev_priv = dev->dev_private;
588 static unsigned int runtime_allowed;
590 if (runtime_allowed == 1 && dev_priv->is_lvds_on) {
591 runtime_allowed++;
592 pm_runtime_allow(&dev->pdev->dev);
593 dev_priv->rpm_enabled = 1;
595 return drm_ioctl(filp, cmd, arg);
596 /* FIXME: do we need to wrap the other side of this */
600 /* When a client dies:
601 * - Check for and clean up flipped page state
603 void psb_driver_preclose(struct drm_device *dev, struct drm_file *priv)
607 static void psb_remove(struct pci_dev *pdev)
609 struct drm_device *dev = pci_get_drvdata(pdev);
610 drm_put_dev(dev);
613 static const struct dev_pm_ops psb_pm_ops = {
614 .resume = gma_power_resume,
615 .suspend = gma_power_suspend,
616 .runtime_suspend = psb_runtime_suspend,
617 .runtime_resume = psb_runtime_resume,
618 .runtime_idle = psb_runtime_idle,
621 static struct vm_operations_struct psb_gem_vm_ops = {
622 .fault = psb_gem_fault,
623 .open = drm_gem_vm_open,
624 .close = drm_gem_vm_close,
627 static const struct file_operations psb_gem_fops = {
628 .owner = THIS_MODULE,
629 .open = drm_open,
630 .release = drm_release,
631 .unlocked_ioctl = psb_unlocked_ioctl,
632 .mmap = drm_gem_mmap,
633 .poll = drm_poll,
634 .fasync = drm_fasync,
635 .read = drm_read,
638 static struct drm_driver driver = {
639 .driver_features = DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | \
640 DRIVER_IRQ_VBL | DRIVER_MODESET | DRIVER_GEM ,
641 .load = psb_driver_load,
642 .unload = psb_driver_unload,
644 .ioctls = psb_ioctls,
645 .num_ioctls = DRM_ARRAY_SIZE(psb_ioctls),
646 .device_is_agp = psb_driver_device_is_agp,
647 .irq_preinstall = psb_irq_preinstall,
648 .irq_postinstall = psb_irq_postinstall,
649 .irq_uninstall = psb_irq_uninstall,
650 .irq_handler = psb_irq_handler,
651 .enable_vblank = psb_enable_vblank,
652 .disable_vblank = psb_disable_vblank,
653 .get_vblank_counter = psb_get_vblank_counter,
654 .lastclose = psb_lastclose,
655 .open = psb_driver_open,
656 .preclose = psb_driver_preclose,
657 .postclose = psb_driver_close,
658 .reclaim_buffers = drm_core_reclaim_buffers,
660 .gem_init_object = psb_gem_init_object,
661 .gem_free_object = psb_gem_free_object,
662 .gem_vm_ops = &psb_gem_vm_ops,
663 .dumb_create = psb_gem_dumb_create,
664 .dumb_map_offset = psb_gem_dumb_map_gtt,
665 .dumb_destroy = psb_gem_dumb_destroy,
666 .fops = &psb_gem_fops,
667 .name = DRIVER_NAME,
668 .desc = DRIVER_DESC,
669 .date = PSB_DRM_DRIVER_DATE,
670 .major = PSB_DRM_DRIVER_MAJOR,
671 .minor = PSB_DRM_DRIVER_MINOR,
672 .patchlevel = PSB_DRM_DRIVER_PATCHLEVEL
675 static struct pci_driver psb_pci_driver = {
676 .name = DRIVER_NAME,
677 .id_table = pciidlist,
678 .probe = psb_probe,
679 .remove = psb_remove,
680 .driver.pm = &psb_pm_ops,
683 static int psb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
685 return drm_get_pci_dev(pdev, ent, &driver);
688 static int __init psb_init(void)
690 return drm_pci_init(&driver, &psb_pci_driver);
693 static void __exit psb_exit(void)
695 drm_pci_exit(&driver, &psb_pci_driver);
698 late_initcall(psb_init);
699 module_exit(psb_exit);
701 MODULE_AUTHOR("Alan Cox <alan@linux.intel.com> and others");
702 MODULE_DESCRIPTION(DRIVER_DESC);
703 MODULE_LICENSE("GPL");