forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-11 04dd17822334871b23ea2862f7798fb0e0007777
kernel/drivers/gpu/drm/gma500/psb_drv.c
....@@ -1,41 +1,38 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /**************************************************************************
23 * Copyright (c) 2007-2011, Intel Corporation.
34 * All Rights Reserved.
45 * Copyright (c) 2008, Tungsten Graphics, Inc. Cedar Park, TX., USA.
56 * All Rights Reserved.
67 *
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.
10
- *
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.
15
- *
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.
19
- *
208 **************************************************************************/
219
22
-#include <drm/drmP.h>
10
+#include <linux/cpu.h>
11
+#include <linux/module.h>
12
+#include <linux/notifier.h>
13
+#include <linux/pm_runtime.h>
14
+#include <linux/spinlock.h>
15
+
16
+#include <asm/set_memory.h>
17
+
18
+#include <acpi/video.h>
19
+
2320 #include <drm/drm.h>
24
-#include "psb_drv.h"
21
+#include <drm/drm_drv.h>
22
+#include <drm/drm_fb_helper.h>
23
+#include <drm/drm_file.h>
24
+#include <drm/drm_ioctl.h>
25
+#include <drm/drm_irq.h>
26
+#include <drm/drm_pciids.h>
27
+#include <drm/drm_vblank.h>
28
+
2529 #include "framebuffer.h"
26
-#include "psb_reg.h"
27
-#include "psb_intel_reg.h"
2830 #include "intel_bios.h"
2931 #include "mid_bios.h"
30
-#include <drm/drm_pciids.h>
3132 #include "power.h"
32
-#include <linux/cpu.h>
33
-#include <linux/notifier.h>
34
-#include <linux/spinlock.h>
35
-#include <linux/pm_runtime.h>
36
-#include <acpi/video.h>
37
-#include <linux/module.h>
38
-#include <asm/set_memory.h>
33
+#include "psb_drv.h"
34
+#include "psb_intel_reg.h"
35
+#include "psb_reg.h"
3936
4037 static struct drm_driver driver;
4138 static int psb_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent);
....@@ -259,7 +256,7 @@
259256 PSB_AUX_RESOURCE);
260257 resource_len = pci_resource_len(dev_priv->aux_pdev,
261258 PSB_AUX_RESOURCE);
262
- dev_priv->aux_reg = ioremap_nocache(resource_start,
259
+ dev_priv->aux_reg = ioremap(resource_start,
263260 resource_len);
264261 if (!dev_priv->aux_reg)
265262 goto out_err;
....@@ -368,7 +365,6 @@
368365 drm_irq_install(dev, dev->pdev->irq);
369366
370367 dev->max_vblank_count = 0xffffff; /* only 24 bits of frame count */
371
- dev->driver->get_vblank_counter = psb_get_vblank_counter;
372368
373369 psb_modeset_init(dev);
374370 psb_fbdev_init(dev);
....@@ -431,14 +427,48 @@
431427
432428 static int psb_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
433429 {
434
- return drm_get_pci_dev(pdev, ent, &driver);
435
-}
430
+ struct drm_device *dev;
431
+ int ret;
436432
433
+ ret = pci_enable_device(pdev);
434
+ if (ret)
435
+ return ret;
436
+
437
+ dev = drm_dev_alloc(&driver, &pdev->dev);
438
+ if (IS_ERR(dev)) {
439
+ ret = PTR_ERR(dev);
440
+ goto err_pci_disable_device;
441
+ }
442
+
443
+ dev->pdev = pdev;
444
+ pci_set_drvdata(pdev, dev);
445
+
446
+ ret = psb_driver_load(dev, ent->driver_data);
447
+ if (ret)
448
+ goto err_drm_dev_put;
449
+
450
+ ret = drm_dev_register(dev, ent->driver_data);
451
+ if (ret)
452
+ goto err_psb_driver_unload;
453
+
454
+ return 0;
455
+
456
+err_psb_driver_unload:
457
+ psb_driver_unload(dev);
458
+err_drm_dev_put:
459
+ drm_dev_put(dev);
460
+err_pci_disable_device:
461
+ pci_disable_device(pdev);
462
+ return ret;
463
+}
437464
438465 static void psb_pci_remove(struct pci_dev *pdev)
439466 {
440467 struct drm_device *dev = pci_get_drvdata(pdev);
441
- drm_put_dev(dev);
468
+
469
+ drm_dev_unregister(dev);
470
+ psb_driver_unload(dev);
471
+ drm_dev_put(dev);
442472 }
443473
444474 static const struct dev_pm_ops psb_pm_ops = {
....@@ -470,10 +500,7 @@
470500 };
471501
472502 static struct drm_driver driver = {
473
- .driver_features = DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | \
474
- DRIVER_MODESET | DRIVER_GEM,
475
- .load = psb_driver_load,
476
- .unload = psb_driver_unload,
503
+ .driver_features = DRIVER_MODESET | DRIVER_GEM,
477504 .lastclose = drm_fb_helper_lastclose,
478505
479506 .num_ioctls = ARRAY_SIZE(psb_ioctls),
....@@ -481,11 +508,8 @@
481508 .irq_postinstall = psb_irq_postinstall,
482509 .irq_uninstall = psb_irq_uninstall,
483510 .irq_handler = psb_irq_handler,
484
- .enable_vblank = psb_enable_vblank,
485
- .disable_vblank = psb_disable_vblank,
486
- .get_vblank_counter = psb_get_vblank_counter,
487511
488
- .gem_free_object = psb_gem_free_object,
512
+ .gem_free_object_unlocked = psb_gem_free_object,
489513 .gem_vm_ops = &psb_gem_vm_ops,
490514
491515 .dumb_create = psb_gem_dumb_create,