aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/video/fbmon.c52
-rw-r--r--include/linux/fb.h4
2 files changed, 56 insertions, 0 deletions
diff --git a/drivers/video/fbmon.c b/drivers/video/fbmon.c
index cef65574db6c..17ce135a18fd 100644
--- a/drivers/video/fbmon.c
+++ b/drivers/video/fbmon.c
@@ -31,6 +31,7 @@
31#include <linux/pci.h> 31#include <linux/pci.h>
32#include <linux/slab.h> 32#include <linux/slab.h>
33#include <video/edid.h> 33#include <video/edid.h>
34#include <video/videomode.h>
34#ifdef CONFIG_PPC_OF 35#ifdef CONFIG_PPC_OF
35#include <asm/prom.h> 36#include <asm/prom.h>
36#include <asm/pci-bridge.h> 37#include <asm/pci-bridge.h>
@@ -1373,6 +1374,57 @@ int fb_get_mode(int flags, u32 val, struct fb_var_screeninfo *var, struct fb_inf
1373 kfree(timings); 1374 kfree(timings);
1374 return err; 1375 return err;
1375} 1376}
1377
1378#if IS_ENABLED(CONFIG_VIDEOMODE)
1379int fb_videomode_from_videomode(const struct videomode *vm,
1380 struct fb_videomode *fbmode)
1381{
1382 unsigned int htotal, vtotal;
1383
1384 fbmode->xres = vm->hactive;
1385 fbmode->left_margin = vm->hback_porch;
1386 fbmode->right_margin = vm->hfront_porch;
1387 fbmode->hsync_len = vm->hsync_len;
1388
1389 fbmode->yres = vm->vactive;
1390 fbmode->upper_margin = vm->vback_porch;
1391 fbmode->lower_margin = vm->vfront_porch;
1392 fbmode->vsync_len = vm->vsync_len;
1393
1394 /* prevent division by zero in KHZ2PICOS macro */
1395 fbmode->pixclock = vm->pixelclock ?
1396 KHZ2PICOS(vm->pixelclock / 1000) : 0;
1397
1398 fbmode->sync = 0;
1399 fbmode->vmode = 0;
1400 if (vm->dmt_flags & VESA_DMT_HSYNC_HIGH)
1401 fbmode->sync |= FB_SYNC_HOR_HIGH_ACT;
1402 if (vm->dmt_flags & VESA_DMT_HSYNC_HIGH)
1403 fbmode->sync |= FB_SYNC_VERT_HIGH_ACT;
1404 if (vm->data_flags & DISPLAY_FLAGS_INTERLACED)
1405 fbmode->vmode |= FB_VMODE_INTERLACED;
1406 if (vm->data_flags & DISPLAY_FLAGS_DOUBLESCAN)
1407 fbmode->vmode |= FB_VMODE_DOUBLE;
1408 fbmode->flag = 0;
1409
1410 htotal = vm->hactive + vm->hfront_porch + vm->hback_porch +
1411 vm->hsync_len;
1412 vtotal = vm->vactive + vm->vfront_porch + vm->vback_porch +
1413 vm->vsync_len;
1414 /* prevent division by zero */
1415 if (htotal && vtotal) {
1416 fbmode->refresh = vm->pixelclock / (htotal * vtotal);
1417 /* a mode must have htotal and vtotal != 0 or it is invalid */
1418 } else {
1419 fbmode->refresh = 0;
1420 return -EINVAL;
1421 }
1422
1423 return 0;
1424}
1425EXPORT_SYMBOL_GPL(fb_videomode_from_videomode);
1426#endif
1427
1376#else 1428#else
1377int fb_parse_edid(unsigned char *edid, struct fb_var_screeninfo *var) 1429int fb_parse_edid(unsigned char *edid, struct fb_var_screeninfo *var)
1378{ 1430{
diff --git a/include/linux/fb.h b/include/linux/fb.h
index c7a95714b1fe..100a1765b787 100644
--- a/include/linux/fb.h
+++ b/include/linux/fb.h
@@ -19,6 +19,7 @@ struct vm_area_struct;
19struct fb_info; 19struct fb_info;
20struct device; 20struct device;
21struct file; 21struct file;
22struct videomode;
22 23
23/* Definitions below are used in the parsed monitor specs */ 24/* Definitions below are used in the parsed monitor specs */
24#define FB_DPMS_ACTIVE_OFF 1 25#define FB_DPMS_ACTIVE_OFF 1
@@ -714,6 +715,9 @@ extern void fb_destroy_modedb(struct fb_videomode *modedb);
714extern int fb_find_mode_cvt(struct fb_videomode *mode, int margins, int rb); 715extern int fb_find_mode_cvt(struct fb_videomode *mode, int margins, int rb);
715extern unsigned char *fb_ddc_read(struct i2c_adapter *adapter); 716extern unsigned char *fb_ddc_read(struct i2c_adapter *adapter);
716 717
718extern int fb_videomode_from_videomode(const struct videomode *vm,
719 struct fb_videomode *fbmode);
720
717/* drivers/video/modedb.c */ 721/* drivers/video/modedb.c */
718#define VESA_MODEDB_SIZE 34 722#define VESA_MODEDB_SIZE 34
719extern void fb_var_to_videomode(struct fb_videomode *mode, 723extern void fb_var_to_videomode(struct fb_videomode *mode,