forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/video/fbdev/aty/atyfb_base.c
....@@ -48,7 +48,7 @@
4848
4949 ******************************************************************************/
5050
51
-
51
+#include <linux/compat.h>
5252 #include <linux/module.h>
5353 #include <linux/moduleparam.h>
5454 #include <linux/kernel.h>
....@@ -126,14 +126,14 @@
126126 #ifdef DEBUG
127127 #define DPRINTK(fmt, args...) printk(KERN_DEBUG "atyfb: " fmt, ## args)
128128 #else
129
-#define DPRINTK(fmt, args...)
129
+#define DPRINTK(fmt, args...) no_printk(fmt, ##args)
130130 #endif
131131
132132 #define PRINTKI(fmt, args...) printk(KERN_INFO "atyfb: " fmt, ## args)
133133 #define PRINTKE(fmt, args...) printk(KERN_ERR "atyfb: " fmt, ## args)
134134
135
-#if defined(CONFIG_PM) || defined(CONFIG_PMAC_BACKLIGHT) || \
136
-defined (CONFIG_FB_ATY_GENERIC_LCD) || defined(CONFIG_FB_ATY_BACKLIGHT)
135
+#if defined(CONFIG_PMAC_BACKLIGHT) || defined(CONFIG_FB_ATY_GENERIC_LCD) || \
136
+defined(CONFIG_FB_ATY_BACKLIGHT)
137137 static const u32 lt_lcd_regs[] = {
138138 CNFG_PANEL_LG,
139139 LCD_GEN_CNTL_LG,
....@@ -175,7 +175,7 @@
175175 return aty_ld_le32(LCD_DATA, par);
176176 }
177177 }
178
-#endif /* defined(CONFIG_PM) || defined(CONFIG_PMAC_BACKLIGHT) || defined (CONFIG_FB_ATY_GENERIC_LCD) */
178
+#endif /* defined(CONFIG_PMAC_BACKLIGHT) || defined (CONFIG_FB_ATY_GENERIC_LCD) */
179179
180180 #ifdef CONFIG_FB_ATY_GENERIC_LCD
181181 /*
....@@ -235,6 +235,13 @@
235235 struct fb_info *info);
236236 static int atyfb_blank(int blank, struct fb_info *info);
237237 static int atyfb_ioctl(struct fb_info *info, u_int cmd, u_long arg);
238
+#ifdef CONFIG_COMPAT
239
+static int atyfb_compat_ioctl(struct fb_info *info, u_int cmd, u_long arg)
240
+{
241
+ return atyfb_ioctl(info, cmd, (u_long)compat_ptr(arg));
242
+}
243
+#endif
244
+
238245 #ifdef __sparc__
239246 static int atyfb_mmap(struct fb_info *info, struct vm_area_struct *vma);
240247 #endif
....@@ -290,6 +297,9 @@
290297 .fb_pan_display = atyfb_pan_display,
291298 .fb_blank = atyfb_blank,
292299 .fb_ioctl = atyfb_ioctl,
300
+#ifdef CONFIG_COMPAT
301
+ .fb_compat_ioctl = atyfb_compat_ioctl,
302
+#endif
293303 .fb_fillrect = atyfb_fillrect,
294304 .fb_copyarea = atyfb_copyarea,
295305 .fb_imageblit = atyfb_imageblit,
....@@ -307,12 +317,7 @@
307317 static int xclk;
308318 static int comp_sync = -1;
309319 static char *mode;
310
-
311
-#ifdef CONFIG_PMAC_BACKLIGHT
312
-static int backlight = 1;
313
-#else
314
-static int backlight = 0;
315
-#endif
320
+static int backlight = IS_BUILTIN(CONFIG_PMAC_BACKLIGHT);
316321
317322 #ifdef CONFIG_PPC
318323 static int default_vmode = VMODE_CHOOSE;
....@@ -1188,19 +1193,6 @@
11881193 (c_sync ? FB_SYNC_COMP_HIGH_ACT : 0);
11891194
11901195 switch (pix_width) {
1191
-#if 0
1192
- case CRTC_PIX_WIDTH_4BPP:
1193
- bpp = 4;
1194
- var->red.offset = 0;
1195
- var->red.length = 8;
1196
- var->green.offset = 0;
1197
- var->green.length = 8;
1198
- var->blue.offset = 0;
1199
- var->blue.length = 8;
1200
- var->transp.offset = 0;
1201
- var->transp.length = 0;
1202
- break;
1203
-#endif
12041196 case CRTC_PIX_WIDTH_8BPP:
12051197 bpp = 8;
12061198 var->red.offset = 0;
....@@ -1329,10 +1321,10 @@
13291321 par->accel_flags = var->accel_flags; /* hack */
13301322
13311323 if (var->accel_flags) {
1332
- info->fbops->fb_sync = atyfb_sync;
1324
+ atyfb_ops.fb_sync = atyfb_sync;
13331325 info->flags &= ~FBINFO_HWACCEL_DISABLED;
13341326 } else {
1335
- info->fbops->fb_sync = NULL;
1327
+ atyfb_ops.fb_sync = NULL;
13361328 info->flags |= FBINFO_HWACCEL_DISABLED;
13371329 }
13381330
....@@ -1466,11 +1458,6 @@
14661458 var->bits_per_pixel,
14671459 par->crtc.vxres * var->bits_per_pixel / 8);
14681460 #endif /* CONFIG_BOOTX_TEXT */
1469
-#if 0
1470
- /* switch to accelerator mode */
1471
- if (!(par->crtc.gen_cntl & CRTC_EXT_DISP_EN))
1472
- aty_st_le32(CRTC_GEN_CNTL, par->crtc.gen_cntl | CRTC_EXT_DISP_EN, par);
1473
-#endif
14741461 #ifdef DEBUG
14751462 {
14761463 /* dump non shadow CRTC, pll, LCD registers */
....@@ -1480,24 +1467,28 @@
14801467 base = 0x2000;
14811468 printk("debug atyfb: Mach64 non-shadow register values:");
14821469 for (i = 0; i < 256; i = i+4) {
1483
- if (i % 16 == 0)
1484
- printk("\ndebug atyfb: 0x%04X: ", base + i);
1485
- printk(" %08X", aty_ld_le32(i, par));
1470
+ if (i % 16 == 0) {
1471
+ pr_cont("\n");
1472
+ printk("debug atyfb: 0x%04X: ", base + i);
1473
+ }
1474
+ pr_cont(" %08X", aty_ld_le32(i, par));
14861475 }
1487
- printk("\n\n");
1476
+ pr_cont("\n\n");
14881477
14891478 #ifdef CONFIG_FB_ATY_CT
14901479 /* PLL registers */
14911480 base = 0x00;
14921481 printk("debug atyfb: Mach64 PLL register values:");
14931482 for (i = 0; i < 64; i++) {
1494
- if (i % 16 == 0)
1495
- printk("\ndebug atyfb: 0x%02X: ", base + i);
1483
+ if (i % 16 == 0) {
1484
+ pr_cont("\n");
1485
+ printk("debug atyfb: 0x%02X: ", base + i);
1486
+ }
14961487 if (i % 4 == 0)
1497
- printk(" ");
1498
- printk("%02X", aty_ld_pll_ct(i, par));
1488
+ pr_cont(" ");
1489
+ pr_cont("%02X", aty_ld_pll_ct(i, par));
14991490 }
1500
- printk("\n\n");
1491
+ pr_cont("\n\n");
15011492 #endif /* CONFIG_FB_ATY_CT */
15021493
15031494 #ifdef CONFIG_FB_ATY_GENERIC_LCD
....@@ -1509,19 +1500,19 @@
15091500 for (i = 0; i <= POWER_MANAGEMENT; i++) {
15101501 if (i == EXT_VERT_STRETCH)
15111502 continue;
1512
- printk("\ndebug atyfb: 0x%04X: ",
1503
+ pr_cont("\ndebug atyfb: 0x%04X: ",
15131504 lt_lcd_regs[i]);
1514
- printk(" %08X", aty_ld_lcd(i, par));
1505
+ pr_cont(" %08X", aty_ld_lcd(i, par));
15151506 }
15161507 } else {
15171508 for (i = 0; i < 64; i++) {
15181509 if (i % 4 == 0)
1519
- printk("\ndebug atyfb: 0x%02X: ",
1510
+ pr_cont("\ndebug atyfb: 0x%02X: ",
15201511 base + i);
1521
- printk(" %08X", aty_ld_lcd(i, par));
1512
+ pr_cont(" %08X", aty_ld_lcd(i, par));
15221513 }
15231514 }
1524
- printk("\n\n");
1515
+ pr_cont("\n\n");
15251516 }
15261517 #endif /* CONFIG_FB_ATY_GENERIC_LCD */
15271518 }
....@@ -1998,7 +1989,7 @@
19981989
19991990
20001991
2001
-#if defined(CONFIG_PM) && defined(CONFIG_PCI)
1992
+#if defined(CONFIG_PCI)
20021993
20031994 #ifdef CONFIG_PPC_PMAC
20041995 /* Power management routines. Those are used for PowerBook sleep.
....@@ -2059,8 +2050,9 @@
20592050 }
20602051 #endif /* CONFIG_PPC_PMAC */
20612052
2062
-static int atyfb_pci_suspend(struct pci_dev *pdev, pm_message_t state)
2053
+static int atyfb_pci_suspend_late(struct device *dev, pm_message_t state)
20632054 {
2055
+ struct pci_dev *pdev = to_pci_dev(dev);
20642056 struct fb_info *info = pci_get_drvdata(pdev);
20652057 struct atyfb_par *par = (struct atyfb_par *) info->par;
20662058
....@@ -2086,7 +2078,6 @@
20862078 * first save the config space content so the core can
20872079 * restore it properly on resume.
20882080 */
2089
- pci_save_state(pdev);
20902081
20912082 #ifdef CONFIG_PPC_PMAC
20922083 /* Set chip to "suspend" mode */
....@@ -2098,8 +2089,6 @@
20982089 console_unlock();
20992090 return -EIO;
21002091 }
2101
-#else
2102
- pci_set_power_state(pdev, pci_choose_state(pdev, state));
21032092 #endif
21042093
21052094 console_unlock();
....@@ -2107,6 +2096,21 @@
21072096 pdev->dev.power.power_state = state;
21082097
21092098 return 0;
2099
+}
2100
+
2101
+static int __maybe_unused atyfb_pci_suspend(struct device *dev)
2102
+{
2103
+ return atyfb_pci_suspend_late(dev, PMSG_SUSPEND);
2104
+}
2105
+
2106
+static int __maybe_unused atyfb_pci_hibernate(struct device *dev)
2107
+{
2108
+ return atyfb_pci_suspend_late(dev, PMSG_HIBERNATE);
2109
+}
2110
+
2111
+static int __maybe_unused atyfb_pci_freeze(struct device *dev)
2112
+{
2113
+ return atyfb_pci_suspend_late(dev, PMSG_FREEZE);
21102114 }
21112115
21122116 static void aty_resume_chip(struct fb_info *info)
....@@ -2123,8 +2127,9 @@
21232127 aty_ld_le32(BUS_CNTL, par) | BUS_APER_REG_DIS, par);
21242128 }
21252129
2126
-static int atyfb_pci_resume(struct pci_dev *pdev)
2130
+static int __maybe_unused atyfb_pci_resume(struct device *dev)
21272131 {
2132
+ struct pci_dev *pdev = to_pci_dev(dev);
21282133 struct fb_info *info = pci_get_drvdata(pdev);
21292134 struct atyfb_par *par = (struct atyfb_par *) info->par;
21302135
....@@ -2166,7 +2171,18 @@
21662171 return 0;
21672172 }
21682173
2169
-#endif /* defined(CONFIG_PM) && defined(CONFIG_PCI) */
2174
+static const struct dev_pm_ops atyfb_pci_pm_ops = {
2175
+#ifdef CONFIG_PM_SLEEP
2176
+ .suspend = atyfb_pci_suspend,
2177
+ .resume = atyfb_pci_resume,
2178
+ .freeze = atyfb_pci_freeze,
2179
+ .thaw = atyfb_pci_resume,
2180
+ .poweroff = atyfb_pci_hibernate,
2181
+ .restore = atyfb_pci_resume,
2182
+#endif /* CONFIG_PM_SLEEP */
2183
+};
2184
+
2185
+#endif /* defined(CONFIG_PCI) */
21702186
21712187 /* Backlight */
21722188 #ifdef CONFIG_FB_ATY_BACKLIGHT
....@@ -2392,17 +2408,6 @@
23922408 par->pll_ops = &aty_pll_ibm514;
23932409 break;
23942410 #endif
2395
-#if 0 /* dead code */
2396
- case CLK_STG1703:
2397
- par->pll_ops = &aty_pll_stg1703;
2398
- break;
2399
- case CLK_CH8398:
2400
- par->pll_ops = &aty_pll_ch8398;
2401
- break;
2402
- case CLK_ATT20C408:
2403
- par->pll_ops = &aty_pll_att20c408;
2404
- break;
2405
-#endif
24062411 default:
24072412 PRINTKI("aty_init: CLK type not implemented yet!");
24082413 par->pll_ops = &aty_pll_unsupported;
....@@ -2597,8 +2602,8 @@
25972602 aty_ld_le32(DSP_ON_OFF, par),
25982603 aty_ld_le32(CLOCK_CNTL, par));
25992604 for (i = 0; i < 40; i++)
2600
- printk(" %02x", aty_ld_pll_ct(i, par));
2601
- printk("\n");
2605
+ pr_cont(" %02x", aty_ld_pll_ct(i, par));
2606
+ pr_cont("\n");
26022607 }
26032608 #endif
26042609 if (par->pll_ops->init_pll)
....@@ -2727,7 +2732,7 @@
27272732
27282733 #ifdef CONFIG_FB_ATY_CT
27292734 if (!noaccel && M64_HAS(INTEGRATED))
2730
- aty_init_cursor(info);
2735
+ aty_init_cursor(info, &atyfb_ops);
27312736 #endif /* CONFIG_FB_ATY_CT */
27322737 info->var = var;
27332738
....@@ -3546,10 +3551,9 @@
35463551
35473552 /* Allocate framebuffer */
35483553 info = framebuffer_alloc(sizeof(struct atyfb_par), &pdev->dev);
3549
- if (!info) {
3550
- PRINTKE("atyfb_pci_probe() can't alloc fb_info\n");
3554
+ if (!info)
35513555 return -ENOMEM;
3552
- }
3556
+
35533557 par = info->par;
35543558 par->bus_type = PCI;
35553559 info->fix = atyfb_fix;
....@@ -3639,10 +3643,9 @@
36393643 }
36403644
36413645 info = framebuffer_alloc(sizeof(struct atyfb_par), NULL);
3642
- if (!info) {
3643
- PRINTKE("atyfb_atari_probe() can't alloc fb_info\n");
3646
+ if (!info)
36443647 return -ENOMEM;
3645
- }
3648
+
36463649 par = info->par;
36473650
36483651 info->fix = atyfb_fix;
....@@ -3818,10 +3821,7 @@
38183821 .id_table = atyfb_pci_tbl,
38193822 .probe = atyfb_pci_probe,
38203823 .remove = atyfb_pci_remove,
3821
-#ifdef CONFIG_PM
3822
- .suspend = atyfb_pci_suspend,
3823
- .resume = atyfb_pci_resume,
3824
-#endif /* CONFIG_PM */
3824
+ .driver.pm = &atyfb_pci_pm_ops,
38253825 };
38263826
38273827 #endif /* CONFIG_PCI */
....@@ -3836,9 +3836,9 @@
38363836
38373837 while ((this_opt = strsep(&options, ",")) != NULL) {
38383838 if (!strncmp(this_opt, "noaccel", 7)) {
3839
- noaccel = 1;
3839
+ noaccel = true;
38403840 } else if (!strncmp(this_opt, "nomtrr", 6)) {
3841
- nomtrr = 1;
3841
+ nomtrr = true;
38423842 } else if (!strncmp(this_opt, "vram:", 5))
38433843 vram = simple_strtoul(this_opt + 5, NULL, 0);
38443844 else if (!strncmp(this_opt, "pll:", 4))
....@@ -3912,8 +3912,7 @@
39123912 if (!reboot_info)
39133913 goto out;
39143914
3915
- if (!lock_fb_info(reboot_info))
3916
- goto out;
3915
+ lock_fb_info(reboot_info);
39173916
39183917 par = reboot_info->par;
39193918