forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/drivers/video/fbdev/nvidia/nvidia.c
....@@ -74,11 +74,7 @@
7474 static int bpp = 8;
7575 static int reverse_i2c;
7676 static bool nomtrr = false;
77
-#ifdef CONFIG_PMAC_BACKLIGHT
78
-static int backlight = 1;
79
-#else
80
-static int backlight = 0;
81
-#endif
77
+static int backlight = IS_BUILTIN(CONFIG_PMAC_BACKLIGHT);
8278
8379 static char *mode_option = NULL;
8480
....@@ -168,27 +164,26 @@
168164 {
169165 int tweak = 0;
170166
171
- if (par->paneltweak) {
172
- tweak = par->paneltweak;
173
- } else {
174
- /* begin flat panel hacks */
175
- /* This is unfortunate, but some chips need this register
176
- tweaked or else you get artifacts where adjacent pixels are
177
- swapped. There are no hard rules for what to set here so all
178
- we can do is experiment and apply hacks. */
167
+ if (par->paneltweak) {
168
+ tweak = par->paneltweak;
169
+ } else {
170
+ /* Begin flat panel hacks.
171
+ * This is unfortunate, but some chips need this register
172
+ * tweaked or else you get artifacts where adjacent pixels are
173
+ * swapped. There are no hard rules for what to set here so all
174
+ * we can do is experiment and apply hacks.
175
+ */
176
+ if (((par->Chipset & 0xffff) == 0x0328) && (state->bpp == 32)) {
177
+ /* At least one NV34 laptop needs this workaround. */
178
+ tweak = -1;
179
+ }
179180
180
- if(((par->Chipset & 0xffff) == 0x0328) && (state->bpp == 32)) {
181
- /* At least one NV34 laptop needs this workaround. */
182
- tweak = -1;
183
- }
181
+ if ((par->Chipset & 0xfff0) == 0x0310)
182
+ tweak = 1;
183
+ /* end flat panel hacks */
184
+ }
184185
185
- if((par->Chipset & 0xfff0) == 0x0310) {
186
- tweak = 1;
187
- }
188
- /* end flat panel hacks */
189
- }
190
-
191
- return tweak;
186
+ return tweak;
192187 }
193188
194189 static void nvidia_screen_off(struct nvidia_par *par, int on)
....@@ -607,6 +602,8 @@
607602 return 0;
608603 }
609604
605
+static struct fb_ops nvidia_fb_ops;
606
+
610607 static int nvidiafb_set_par(struct fb_info *info)
611608 {
612609 struct nvidia_par *par = info->par;
....@@ -660,19 +657,19 @@
660657 info->fix.line_length = (info->var.xres_virtual *
661658 info->var.bits_per_pixel) >> 3;
662659 if (info->var.accel_flags) {
663
- info->fbops->fb_imageblit = nvidiafb_imageblit;
664
- info->fbops->fb_fillrect = nvidiafb_fillrect;
665
- info->fbops->fb_copyarea = nvidiafb_copyarea;
666
- info->fbops->fb_sync = nvidiafb_sync;
660
+ nvidia_fb_ops.fb_imageblit = nvidiafb_imageblit;
661
+ nvidia_fb_ops.fb_fillrect = nvidiafb_fillrect;
662
+ nvidia_fb_ops.fb_copyarea = nvidiafb_copyarea;
663
+ nvidia_fb_ops.fb_sync = nvidiafb_sync;
667664 info->pixmap.scan_align = 4;
668665 info->flags &= ~FBINFO_HWACCEL_DISABLED;
669666 info->flags |= FBINFO_READS_FAST;
670667 NVResetGraphics(info);
671668 } else {
672
- info->fbops->fb_imageblit = cfb_imageblit;
673
- info->fbops->fb_fillrect = cfb_fillrect;
674
- info->fbops->fb_copyarea = cfb_copyarea;
675
- info->fbops->fb_sync = NULL;
669
+ nvidia_fb_ops.fb_imageblit = cfb_imageblit;
670
+ nvidia_fb_ops.fb_fillrect = cfb_fillrect;
671
+ nvidia_fb_ops.fb_copyarea = cfb_copyarea;
672
+ nvidia_fb_ops.fb_sync = NULL;
676673 info->pixmap.scan_align = 1;
677674 info->flags |= FBINFO_HWACCEL_DISABLED;
678675 info->flags &= ~FBINFO_READS_FAST;
....@@ -1040,10 +1037,9 @@
10401037 .fb_sync = nvidiafb_sync,
10411038 };
10421039
1043
-#ifdef CONFIG_PM
1044
-static int nvidiafb_suspend(struct pci_dev *dev, pm_message_t mesg)
1040
+static int nvidiafb_suspend_late(struct device *dev, pm_message_t mesg)
10451041 {
1046
- struct fb_info *info = pci_get_drvdata(dev);
1042
+ struct fb_info *info = dev_get_drvdata(dev);
10471043 struct nvidia_par *par = info->par;
10481044
10491045 if (mesg.event == PM_EVENT_PRETHAW)
....@@ -1055,46 +1051,54 @@
10551051 fb_set_suspend(info, 1);
10561052 nvidiafb_blank(FB_BLANK_POWERDOWN, info);
10571053 nvidia_write_regs(par, &par->SavedReg);
1058
- pci_save_state(dev);
1059
- pci_disable_device(dev);
1060
- pci_set_power_state(dev, pci_choose_state(dev, mesg));
10611054 }
1062
- dev->dev.power.power_state = mesg;
1055
+ dev->power.power_state = mesg;
10631056
10641057 console_unlock();
10651058 return 0;
10661059 }
10671060
1068
-static int nvidiafb_resume(struct pci_dev *dev)
1061
+static int __maybe_unused nvidiafb_suspend(struct device *dev)
10691062 {
1070
- struct fb_info *info = pci_get_drvdata(dev);
1063
+ return nvidiafb_suspend_late(dev, PMSG_SUSPEND);
1064
+}
1065
+
1066
+static int __maybe_unused nvidiafb_hibernate(struct device *dev)
1067
+{
1068
+ return nvidiafb_suspend_late(dev, PMSG_HIBERNATE);
1069
+}
1070
+
1071
+static int __maybe_unused nvidiafb_freeze(struct device *dev)
1072
+{
1073
+ return nvidiafb_suspend_late(dev, PMSG_FREEZE);
1074
+}
1075
+
1076
+static int __maybe_unused nvidiafb_resume(struct device *dev)
1077
+{
1078
+ struct fb_info *info = dev_get_drvdata(dev);
10711079 struct nvidia_par *par = info->par;
10721080
10731081 console_lock();
1074
- pci_set_power_state(dev, PCI_D0);
1075
-
1076
- if (par->pm_state != PM_EVENT_FREEZE) {
1077
- pci_restore_state(dev);
1078
-
1079
- if (pci_enable_device(dev))
1080
- goto fail;
1081
-
1082
- pci_set_master(dev);
1083
- }
10841082
10851083 par->pm_state = PM_EVENT_ON;
10861084 nvidiafb_set_par(info);
10871085 fb_set_suspend (info, 0);
10881086 nvidiafb_blank(FB_BLANK_UNBLANK, info);
10891087
1090
-fail:
10911088 console_unlock();
10921089 return 0;
10931090 }
1094
-#else
1095
-#define nvidiafb_suspend NULL
1096
-#define nvidiafb_resume NULL
1097
-#endif
1091
+
1092
+static const struct dev_pm_ops nvidiafb_pm_ops = {
1093
+#ifdef CONFIG_PM_SLEEP
1094
+ .suspend = nvidiafb_suspend,
1095
+ .resume = nvidiafb_resume,
1096
+ .freeze = nvidiafb_freeze,
1097
+ .thaw = nvidiafb_resume,
1098
+ .poweroff = nvidiafb_hibernate,
1099
+ .restore = nvidiafb_resume,
1100
+#endif /* CONFIG_PM_SLEEP */
1101
+};
10981102
10991103 static int nvidia_set_fbinfo(struct fb_info *info)
11001104 {
....@@ -1165,7 +1169,7 @@
11651169 info->pixmap.flags = FB_PIXMAP_SYSTEM;
11661170
11671171 if (!hwcur)
1168
- info->fbops->fb_cursor = NULL;
1172
+ nvidia_fb_ops.fb_cursor = NULL;
11691173
11701174 info->var.accel_flags = (!noaccel);
11711175
....@@ -1495,12 +1499,11 @@
14951499 #endif /* !MODULE */
14961500
14971501 static struct pci_driver nvidiafb_driver = {
1498
- .name = "nvidiafb",
1499
- .id_table = nvidiafb_pci_tbl,
1500
- .probe = nvidiafb_probe,
1501
- .suspend = nvidiafb_suspend,
1502
- .resume = nvidiafb_resume,
1503
- .remove = nvidiafb_remove,
1502
+ .name = "nvidiafb",
1503
+ .id_table = nvidiafb_pci_tbl,
1504
+ .probe = nvidiafb_probe,
1505
+ .driver.pm = &nvidiafb_pm_ops,
1506
+ .remove = nvidiafb_remove,
15041507 };
15051508
15061509 /* ------------------------------------------------------------------------- *