aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/video/fbmon.c42
-rw-r--r--include/linux/fb.h4
2 files changed, 46 insertions, 0 deletions
diff --git a/drivers/video/fbmon.c b/drivers/video/fbmon.c
index 17ce135a18fd..94ad0f71383c 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/of_videomode.h>
34#include <video/videomode.h> 35#include <video/videomode.h>
35#ifdef CONFIG_PPC_OF 36#ifdef CONFIG_PPC_OF
36#include <asm/prom.h> 37#include <asm/prom.h>
@@ -1425,6 +1426,47 @@ int fb_videomode_from_videomode(const struct videomode *vm,
1425EXPORT_SYMBOL_GPL(fb_videomode_from_videomode); 1426EXPORT_SYMBOL_GPL(fb_videomode_from_videomode);
1426#endif 1427#endif
1427 1428
1429#if IS_ENABLED(CONFIG_OF_VIDEOMODE)
1430static inline void dump_fb_videomode(const struct fb_videomode *m)
1431{
1432 pr_debug("fb_videomode = %ux%u@%uHz (%ukHz) %u %u %u %u %u %u %u %u %u\n",
1433 m->xres, m->yres, m->refresh, m->pixclock, m->left_margin,
1434 m->right_margin, m->upper_margin, m->lower_margin,
1435 m->hsync_len, m->vsync_len, m->sync, m->vmode, m->flag);
1436}
1437
1438/**
1439 * of_get_fb_videomode - get a fb_videomode from devicetree
1440 * @np: device_node with the timing specification
1441 * @fb: will be set to the return value
1442 * @index: index into the list of display timings in devicetree
1443 *
1444 * DESCRIPTION:
1445 * This function is expensive and should only be used, if only one mode is to be
1446 * read from DT. To get multiple modes start with of_get_display_timings ond
1447 * work with that instead.
1448 */
1449int of_get_fb_videomode(struct device_node *np, struct fb_videomode *fb,
1450 int index)
1451{
1452 struct videomode vm;
1453 int ret;
1454
1455 ret = of_get_videomode(np, &vm, index);
1456 if (ret)
1457 return ret;
1458
1459 fb_videomode_from_videomode(&vm, fb);
1460
1461 pr_debug("%s: got %dx%d display mode from %s\n",
1462 of_node_full_name(np), vm.hactive, vm.vactive, np->name);
1463 dump_fb_videomode(fb);
1464
1465 return 0;
1466}
1467EXPORT_SYMBOL_GPL(of_get_fb_videomode);
1468#endif
1469
1428#else 1470#else
1429int fb_parse_edid(unsigned char *edid, struct fb_var_screeninfo *var) 1471int fb_parse_edid(unsigned char *edid, struct fb_var_screeninfo *var)
1430{ 1472{
diff --git a/include/linux/fb.h b/include/linux/fb.h
index 100a1765b787..58b98606ac26 100644
--- a/include/linux/fb.h
+++ b/include/linux/fb.h
@@ -20,6 +20,7 @@ struct fb_info;
20struct device; 20struct device;
21struct file; 21struct file;
22struct videomode; 22struct videomode;
23struct device_node;
23 24
24/* Definitions below are used in the parsed monitor specs */ 25/* Definitions below are used in the parsed monitor specs */
25#define FB_DPMS_ACTIVE_OFF 1 26#define FB_DPMS_ACTIVE_OFF 1
@@ -715,6 +716,9 @@ extern void fb_destroy_modedb(struct fb_videomode *modedb);
715extern int fb_find_mode_cvt(struct fb_videomode *mode, int margins, int rb); 716extern int fb_find_mode_cvt(struct fb_videomode *mode, int margins, int rb);
716extern unsigned char *fb_ddc_read(struct i2c_adapter *adapter); 717extern unsigned char *fb_ddc_read(struct i2c_adapter *adapter);
717 718
719extern int of_get_fb_videomode(struct device_node *np,
720 struct fb_videomode *fb,
721 int index);
718extern int fb_videomode_from_videomode(const struct videomode *vm, 722extern int fb_videomode_from_videomode(const struct videomode *vm,
719 struct fb_videomode *fbmode); 723 struct fb_videomode *fbmode);
720 724