aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video
diff options
context:
space:
mode:
authorSteffen Trumtrar <s.trumtrar@pengutronix.de>2012-11-14 04:55:04 -0500
committerSteffen Trumtrar <s.trumtrar@pengutronix.de>2013-01-24 03:03:59 -0500
commit2db54c72395298a58f29c75ae880be9e478fdbbd (patch)
treec7d9f61e4e1776af160d3c9fc9e77c0eef9e844e /drivers/video
parentcc3f414cf2e404130584b63d373161ba6fd24bc2 (diff)
fbmon: add videomode helpers
Add a function to convert from the generic videomode to a fb_videomode. Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Reviewed-by: Thierry Reding <thierry.reding@avionic-design.de> Acked-by: Thierry Reding <thierry.reding@avionic-design.de> Tested-by: Thierry Reding <thierry.reding@avionic-design.de> Tested-by: Philipp Zabel <p.zabel@pengutronix.de> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Afzal Mohammed <Afzal@ti.com> Tested-by: Rob Clark <robclark@gmail.com> Tested-by: Leela Krishna Amudala <leelakrishna.a@gmail.com>
Diffstat (limited to 'drivers/video')
-rw-r--r--drivers/video/fbmon.c52
1 files changed, 52 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{