Skip to content

Commit 0db5b61

Browse files
author
Thomas Zimmermann
committed
fbdev/vga16fb: Create EGA/VGA devices in sysfb code
Move the device-creation from vga16fb to sysfb code. The driver's videomode checks are independent from device creation, so move them into vga16fb's probe function. This will allow to create the module init/exit code automatically. The vga16fb driver requires a screen_info for type VIDEO_TYPE_VGAC or VIDEO_TYPE_EGAC. Such code is nowhere present in the kernel, except for some MIPS systems. It's not clear if the vga16fb driver actually works in practice. v2: * keep driver name to "vga16fb" (Javier) * give rational for moving mode checks (Javier) Signed-off-by: Thomas Zimmermann <[email protected]> Reviewed-by: Javier Martinez Canillas <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 729d687 commit 0db5b61

File tree

2 files changed

+31
-30
lines changed

2 files changed

+31
-30
lines changed

drivers/firmware/sysfb.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ static __init int sysfb_init(void)
9494
name = "efi-framebuffer";
9595
else if (si->orig_video_isVGA == VIDEO_TYPE_VLFB)
9696
name = "vesa-framebuffer";
97+
else if (si->orig_video_isVGA == VIDEO_TYPE_VGAC)
98+
name = "vga-framebuffer";
99+
else if (si->orig_video_isVGA == VIDEO_TYPE_EGAC)
100+
name = "ega-framebuffer";
97101
else
98102
name = "platform-framebuffer";
99103

drivers/video/fbdev/vga16fb.c

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -185,19 +185,19 @@ static inline void setindex(int index)
185185
}
186186

187187
/* Check if the video mode is supported by the driver */
188-
static inline int check_mode_supported(void)
188+
static inline int check_mode_supported(const struct screen_info *si)
189189
{
190190
/* non-x86 architectures treat orig_video_isVGA as a boolean flag */
191191
#if defined(CONFIG_X86)
192192
/* only EGA and VGA in 16 color graphic mode are supported */
193-
if (screen_info.orig_video_isVGA != VIDEO_TYPE_EGAC &&
194-
screen_info.orig_video_isVGA != VIDEO_TYPE_VGAC)
193+
if (si->orig_video_isVGA != VIDEO_TYPE_EGAC &&
194+
si->orig_video_isVGA != VIDEO_TYPE_VGAC)
195195
return -ENODEV;
196196

197-
if (screen_info.orig_video_mode != 0x0D && /* 320x200/4 (EGA) */
198-
screen_info.orig_video_mode != 0x0E && /* 640x200/4 (EGA) */
199-
screen_info.orig_video_mode != 0x10 && /* 640x350/4 (EGA) */
200-
screen_info.orig_video_mode != 0x12) /* 640x480/4 (VGA) */
197+
if (si->orig_video_mode != 0x0D && /* 320x200/4 (EGA) */
198+
si->orig_video_mode != 0x0E && /* 640x200/4 (EGA) */
199+
si->orig_video_mode != 0x10 && /* 640x350/4 (EGA) */
200+
si->orig_video_mode != 0x12) /* 640x480/4 (VGA) */
201201
return -ENODEV;
202202
#endif
203203
return 0;
@@ -1321,11 +1321,20 @@ static int __init vga16fb_setup(char *options)
13211321

13221322
static int vga16fb_probe(struct platform_device *dev)
13231323
{
1324+
struct screen_info *si;
13241325
struct fb_info *info;
13251326
struct vga16fb_par *par;
13261327
int i;
13271328
int ret = 0;
13281329

1330+
si = dev_get_platdata(&dev->dev);
1331+
if (!si)
1332+
return -ENODEV;
1333+
1334+
ret = check_mode_supported(si);
1335+
if (ret)
1336+
return ret;
1337+
13291338
printk(KERN_DEBUG "vga16fb: initializing\n");
13301339
info = framebuffer_alloc(sizeof(struct vga16fb_par), &dev->dev);
13311340

@@ -1352,10 +1361,10 @@ static int vga16fb_probe(struct platform_device *dev)
13521361
par = info->par;
13531362

13541363
#if defined(CONFIG_X86)
1355-
par->isVGA = screen_info.orig_video_isVGA == VIDEO_TYPE_VGAC;
1364+
par->isVGA = si->orig_video_isVGA == VIDEO_TYPE_VGAC;
13561365
#else
13571366
/* non-x86 architectures treat orig_video_isVGA as a boolean flag */
1358-
par->isVGA = screen_info.orig_video_isVGA;
1367+
par->isVGA = si->orig_video_isVGA;
13591368
#endif
13601369
par->palette_blanked = 0;
13611370
par->vesa_blanked = 0;
@@ -1425,16 +1434,21 @@ static int vga16fb_remove(struct platform_device *dev)
14251434
return 0;
14261435
}
14271436

1437+
static const struct platform_device_id vga16fb_driver_id_table[] = {
1438+
{"ega-framebuffer", 0},
1439+
{"vga-framebuffer", 0},
1440+
{ }
1441+
};
1442+
14281443
static struct platform_driver vga16fb_driver = {
14291444
.probe = vga16fb_probe,
14301445
.remove = vga16fb_remove,
14311446
.driver = {
14321447
.name = "vga16fb",
14331448
},
1449+
.id_table = vga16fb_driver_id_table,
14341450
};
14351451

1436-
static struct platform_device *vga16fb_device;
1437-
14381452
static int __init vga16fb_init(void)
14391453
{
14401454
int ret;
@@ -1447,32 +1461,15 @@ static int __init vga16fb_init(void)
14471461
vga16fb_setup(option);
14481462
#endif
14491463

1450-
ret = check_mode_supported();
1464+
ret = platform_driver_register(&vga16fb_driver);
14511465
if (ret)
14521466
return ret;
14531467

1454-
ret = platform_driver_register(&vga16fb_driver);
1455-
1456-
if (!ret) {
1457-
vga16fb_device = platform_device_alloc("vga16fb", 0);
1458-
1459-
if (vga16fb_device)
1460-
ret = platform_device_add(vga16fb_device);
1461-
else
1462-
ret = -ENOMEM;
1463-
1464-
if (ret) {
1465-
platform_device_put(vga16fb_device);
1466-
platform_driver_unregister(&vga16fb_driver);
1467-
}
1468-
}
1469-
1470-
return ret;
1468+
return 0;
14711469
}
14721470

14731471
static void __exit vga16fb_exit(void)
14741472
{
1475-
platform_device_unregister(vga16fb_device);
14761473
platform_driver_unregister(&vga16fb_driver);
14771474
}
14781475

0 commit comments

Comments
 (0)