hc
2024-01-05 071106ecf68c401173c58808b1cf5f68cc50d390
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;
....@@ -766,6 +763,8 @@
766763 int pitch, err = 0;
767764
768765 NVTRACE_ENTER();
766
+ if (!var->pixclock)
767
+ return -EINVAL;
769768
770769 var->transp.offset = 0;
771770 var->transp.length = 0;
....@@ -1040,10 +1039,9 @@
10401039 .fb_sync = nvidiafb_sync,
10411040 };
10421041
1043
-#ifdef CONFIG_PM
1044
-static int nvidiafb_suspend(struct pci_dev *dev, pm_message_t mesg)
1042
+static int nvidiafb_suspend_late(struct device *dev, pm_message_t mesg)
10451043 {
1046
- struct fb_info *info = pci_get_drvdata(dev);
1044
+ struct fb_info *info = dev_get_drvdata(dev);
10471045 struct nvidia_par *par = info->par;
10481046
10491047 if (mesg.event == PM_EVENT_PRETHAW)
....@@ -1055,46 +1053,54 @@
10551053 fb_set_suspend(info, 1);
10561054 nvidiafb_blank(FB_BLANK_POWERDOWN, info);
10571055 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));
10611056 }
1062
- dev->dev.power.power_state = mesg;
1057
+ dev->power.power_state = mesg;
10631058
10641059 console_unlock();
10651060 return 0;
10661061 }
10671062
1068
-static int nvidiafb_resume(struct pci_dev *dev)
1063
+static int __maybe_unused nvidiafb_suspend(struct device *dev)
10691064 {
1070
- struct fb_info *info = pci_get_drvdata(dev);
1065
+ return nvidiafb_suspend_late(dev, PMSG_SUSPEND);
1066
+}
1067
+
1068
+static int __maybe_unused nvidiafb_hibernate(struct device *dev)
1069
+{
1070
+ return nvidiafb_suspend_late(dev, PMSG_HIBERNATE);
1071
+}
1072
+
1073
+static int __maybe_unused nvidiafb_freeze(struct device *dev)
1074
+{
1075
+ return nvidiafb_suspend_late(dev, PMSG_FREEZE);
1076
+}
1077
+
1078
+static int __maybe_unused nvidiafb_resume(struct device *dev)
1079
+{
1080
+ struct fb_info *info = dev_get_drvdata(dev);
10711081 struct nvidia_par *par = info->par;
10721082
10731083 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
- }
10841084
10851085 par->pm_state = PM_EVENT_ON;
10861086 nvidiafb_set_par(info);
10871087 fb_set_suspend (info, 0);
10881088 nvidiafb_blank(FB_BLANK_UNBLANK, info);
10891089
1090
-fail:
10911090 console_unlock();
10921091 return 0;
10931092 }
1094
-#else
1095
-#define nvidiafb_suspend NULL
1096
-#define nvidiafb_resume NULL
1097
-#endif
1093
+
1094
+static const struct dev_pm_ops nvidiafb_pm_ops = {
1095
+#ifdef CONFIG_PM_SLEEP
1096
+ .suspend = nvidiafb_suspend,
1097
+ .resume = nvidiafb_resume,
1098
+ .freeze = nvidiafb_freeze,
1099
+ .thaw = nvidiafb_resume,
1100
+ .poweroff = nvidiafb_hibernate,
1101
+ .restore = nvidiafb_resume,
1102
+#endif /* CONFIG_PM_SLEEP */
1103
+};
10981104
10991105 static int nvidia_set_fbinfo(struct fb_info *info)
11001106 {
....@@ -1165,7 +1171,7 @@
11651171 info->pixmap.flags = FB_PIXMAP_SYSTEM;
11661172
11671173 if (!hwcur)
1168
- info->fbops->fb_cursor = NULL;
1174
+ nvidia_fb_ops.fb_cursor = NULL;
11691175
11701176 info->var.accel_flags = (!noaccel);
11711177
....@@ -1495,12 +1501,11 @@
14951501 #endif /* !MODULE */
14961502
14971503 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,
1504
+ .name = "nvidiafb",
1505
+ .id_table = nvidiafb_pci_tbl,
1506
+ .probe = nvidiafb_probe,
1507
+ .driver.pm = &nvidiafb_pm_ops,
1508
+ .remove = nvidiafb_remove,
15041509 };
15051510
15061511 /* ------------------------------------------------------------------------- *