forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/drivers/video/fbdev/vga16fb.c
....@@ -184,6 +184,25 @@
184184 vga_io_w(VGA_GFX_I, index);
185185 }
186186
187
+/* Check if the video mode is supported by the driver */
188
+static inline int check_mode_supported(void)
189
+{
190
+ /* non-x86 architectures treat orig_video_isVGA as a boolean flag */
191
+#if defined(CONFIG_X86)
192
+ /* 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)
195
+ return -ENODEV;
196
+
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) */
201
+ return -ENODEV;
202
+#endif
203
+ return 0;
204
+}
205
+
187206 static void vga16fb_pan_var(struct fb_info *info,
188207 struct fb_var_screeninfo *var)
189208 {
....@@ -1270,7 +1289,7 @@
12701289 framebuffer_release(info);
12711290 }
12721291
1273
-static struct fb_ops vga16fb_ops = {
1292
+static const struct fb_ops vga16fb_ops = {
12741293 .owner = THIS_MODULE,
12751294 .fb_open = vga16fb_open,
12761295 .fb_release = vga16fb_release,
....@@ -1422,6 +1441,11 @@
14221441
14231442 vga16fb_setup(option);
14241443 #endif
1444
+
1445
+ ret = check_mode_supported();
1446
+ if (ret)
1447
+ return ret;
1448
+
14251449 ret = platform_driver_register(&vga16fb_driver);
14261450
14271451 if (!ret) {