forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/drivers/video/fbdev/geode/lxfb_core.c
....@@ -1,13 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Geode LX framebuffer driver.
34 *
45 * Copyright (C) 2007 Advanced Micro Devices, Inc.
56 * Built from gxfb (which is Copyright (C) 2006 Arcom Control Systems Ltd.)
6
- *
7
- * This program is free software; you can redistribute it and/or modify it
8
- * under the terms of the GNU General Public License as published by the
9
- * Free Software Foundation; either version 2 of the License, or (at your
10
- * option) any later version.
117 */
128
139 #include <linux/module.h>
....@@ -22,6 +18,8 @@
2218 #include <linux/init.h>
2319 #include <linux/pci.h>
2420 #include <linux/uaccess.h>
21
+
22
+#include <asm/olpc.h>
2523
2624 #include "lxfb.h"
2725
....@@ -216,9 +214,6 @@
216214 0, FB_VMODE_NONINTERLACED, 0 },
217215 };
218216
219
-#ifdef CONFIG_OLPC
220
-#include <asm/olpc.h>
221
-
222217 static struct fb_videomode olpc_dcon_modedb[] = {
223218 /* The only mode the DCON has is 1200x900 */
224219 { NULL, 50, 1200, 900, 17460, 24, 8, 4, 5, 8, 3,
....@@ -236,14 +231,6 @@
236231 *size = ARRAY_SIZE(geode_modedb);
237232 }
238233 }
239
-
240
-#else
241
-static void get_modedb(struct fb_videomode **modedb, unsigned int *size)
242
-{
243
- *modedb = (struct fb_videomode *) geode_modedb;
244
- *size = ARRAY_SIZE(geode_modedb);
245
-}
246
-#endif
247234
248235 static int lxfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
249236 {
....@@ -399,7 +386,7 @@
399386 return 0;
400387 }
401388
402
-static struct fb_ops lxfb_ops = {
389
+static const struct fb_ops lxfb_ops = {
403390 .owner = THIS_MODULE,
404391 .fb_check_var = lxfb_check_var,
405392 .fb_set_par = lxfb_set_par,
....@@ -456,17 +443,14 @@
456443 return info;
457444 }
458445
459
-#ifdef CONFIG_PM
460
-static int lxfb_suspend(struct pci_dev *pdev, pm_message_t state)
446
+static int __maybe_unused lxfb_suspend(struct device *dev)
461447 {
462
- struct fb_info *info = pci_get_drvdata(pdev);
448
+ struct fb_info *info = dev_get_drvdata(dev);
463449
464
- if (state.event == PM_EVENT_SUSPEND) {
465
- console_lock();
466
- lx_powerdown(info);
467
- fb_set_suspend(info, 1);
468
- console_unlock();
469
- }
450
+ console_lock();
451
+ lx_powerdown(info);
452
+ fb_set_suspend(info, 1);
453
+ console_unlock();
470454
471455 /* there's no point in setting PCI states; we emulate PCI, so
472456 * we don't end up getting power savings anyways */
....@@ -474,9 +458,9 @@
474458 return 0;
475459 }
476460
477
-static int lxfb_resume(struct pci_dev *pdev)
461
+static int __maybe_unused lxfb_resume(struct device *dev)
478462 {
479
- struct fb_info *info = pci_get_drvdata(pdev);
463
+ struct fb_info *info = dev_get_drvdata(dev);
480464 int ret;
481465
482466 console_lock();
....@@ -490,10 +474,6 @@
490474 console_unlock();
491475 return 0;
492476 }
493
-#else
494
-#define lxfb_suspend NULL
495
-#define lxfb_resume NULL
496
-#endif
497477
498478 static int lxfb_probe(struct pci_dev *pdev, const struct pci_device_id *id)
499479 {
....@@ -613,13 +593,23 @@
613593
614594 MODULE_DEVICE_TABLE(pci, lxfb_id_table);
615595
596
+static const struct dev_pm_ops lxfb_pm_ops = {
597
+#ifdef CONFIG_PM_SLEEP
598
+ .suspend = lxfb_suspend,
599
+ .resume = lxfb_resume,
600
+ .freeze = NULL,
601
+ .thaw = lxfb_resume,
602
+ .poweroff = NULL,
603
+ .restore = lxfb_resume,
604
+#endif
605
+};
606
+
616607 static struct pci_driver lxfb_driver = {
617608 .name = "lxfb",
618609 .id_table = lxfb_id_table,
619610 .probe = lxfb_probe,
620611 .remove = lxfb_remove,
621
- .suspend = lxfb_suspend,
622
- .resume = lxfb_resume,
612
+ .driver.pm = &lxfb_pm_ops,
623613 };
624614
625615 #ifndef MODULE