[RFC 05/10] fbmon: Add extra video helper

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This function converts the fb_var_screeninfo to the videomode
structure, to be used in fbdev drivers working with the
Common Display Framework.

Signed-off-by: Pawel Moll <pawel.moll@xxxxxxx>
---
 drivers/video/fbmon.c |   29 +++++++++++++++++++++++++++++
 include/linux/fb.h    |    3 +++
 2 files changed, 32 insertions(+)

diff --git a/drivers/video/fbmon.c b/drivers/video/fbmon.c
index 7f67099..f0ff2bf 100644
--- a/drivers/video/fbmon.c
+++ b/drivers/video/fbmon.c
@@ -1424,6 +1424,35 @@ int fb_videomode_from_videomode(const struct videomode *vm,
 	return 0;
 }
 EXPORT_SYMBOL_GPL(fb_videomode_from_videomode);
+
+void videomode_from_fb_var_screeninfo(const struct fb_var_screeninfo *var,
+				      struct videomode *vm)
+{
+	vm->pixelclock = PICOS2KHZ(var->pixclock) * 1000;
+
+	vm->hactive = var->xres;
+	vm->hfront_porch = var->right_margin;
+	vm->hback_porch = var->left_margin;
+	vm->hsync_len = var->hsync_len;
+
+	vm->vactive = var->yres;
+	vm->vfront_porch = var->lower_margin;
+	vm->vback_porch = var->upper_margin;
+	vm->vsync_len = var->vsync_len;
+
+	vm->dmt_flags = 0;
+	if (var->sync & FB_SYNC_HOR_HIGH_ACT)
+		vm->dmt_flags |= VESA_DMT_HSYNC_HIGH;
+	if (var->sync & FB_SYNC_VERT_HIGH_ACT)
+		vm->dmt_flags |= VESA_DMT_VSYNC_HIGH;
+
+	vm->data_flags = 0;
+	if (var->vmode & FB_VMODE_INTERLACED)
+		vm->data_flags |= DISPLAY_FLAGS_INTERLACED;
+	if (var->vmode & FB_VMODE_DOUBLE)
+		vm->data_flags |= DISPLAY_FLAGS_DOUBLESCAN;
+}
+EXPORT_SYMBOL_GPL(videomode_from_fb_var_screeninfo);
 #endif
 
 #if IS_ENABLED(CONFIG_OF_VIDEOMODE)
diff --git a/include/linux/fb.h b/include/linux/fb.h
index 58b9860..aae2ed3 100644
--- a/include/linux/fb.h
+++ b/include/linux/fb.h
@@ -721,6 +721,9 @@ extern int of_get_fb_videomode(struct device_node *np,
 			       int index);
 extern int fb_videomode_from_videomode(const struct videomode *vm,
 				       struct fb_videomode *fbmode);
+extern void videomode_from_fb_var_screeninfo(
+				const struct fb_var_screeninfo *var,
+				struct videomode *vm);
 
 /* drivers/video/modedb.c */
 #define VESA_MODEDB_SIZE 34
-- 
1.7.10.4


_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux