videomodes: add helper function to convert from ctfb to display_timing
authorGiulio Benetti <giulio.benetti@benettiengineering.com>
Wed, 8 Apr 2020 15:10:11 +0000 (17:10 +0200)
committerStefano Babic <sbabic@denx.de>
Sat, 18 Apr 2020 10:54:43 +0000 (12:54 +0200)
This function converts from "struct ctf_res_modes" to
"struct display_timing".

Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
Reviewed-by: Anatolij Gustschin <agust@denx.de>
drivers/video/videomodes.c
drivers/video/videomodes.h

index ac25b45f8196e67a34cd61182f35695090879b7c..89003eea7276972b202abe9a56c622b7e21336a5 100644 (file)
@@ -444,3 +444,32 @@ int video_edid_dtd_to_ctfb_res_modes(struct edid_detailed_timing *t,
 
        return 0;
 }
+
+void video_ctfb_mode_to_display_timing(const struct ctfb_res_modes *mode,
+                                      struct display_timing *timing)
+{
+       timing->pixelclock.typ = mode->pixclock_khz * 1000;
+
+       timing->hactive.typ = mode->xres;
+       timing->hfront_porch.typ = mode->right_margin;
+       timing->hback_porch.typ = mode->left_margin;
+       timing->hsync_len.typ = mode->hsync_len;
+
+       timing->vactive.typ = mode->yres;
+       timing->vfront_porch.typ = mode->lower_margin;
+       timing->vback_porch.typ = mode->upper_margin;
+       timing->vsync_len.typ = mode->vsync_len;
+
+       timing->flags = 0;
+
+       if (mode->sync & FB_SYNC_HOR_HIGH_ACT)
+               timing->flags |= DISPLAY_FLAGS_HSYNC_HIGH;
+       else
+               timing->flags |= DISPLAY_FLAGS_HSYNC_LOW;
+       if (mode->sync & FB_SYNC_VERT_HIGH_ACT)
+               timing->flags |= DISPLAY_FLAGS_VSYNC_HIGH;
+       else
+               timing->flags |= DISPLAY_FLAGS_VSYNC_LOW;
+       if (mode->vmode == FB_VMODE_INTERLACED)
+               timing->flags |= DISPLAY_FLAGS_INTERLACED;
+}
index 29a3db4ae3c5fbc40115cdb1664d47f6062538a9..aefe4ef94ab130d00c6486bcd2e81b8b4780f70a 100644 (file)
@@ -92,3 +92,14 @@ int video_get_option_int(const char *options, const char *name, int def);
 
 int video_edid_dtd_to_ctfb_res_modes(struct edid_detailed_timing *t,
                                     struct ctfb_res_modes *mode);
+/**
+ * video_ctfb_mode_to_display_timing() - Convert a ctfb(Cathode Tube Frame
+ *                                      Buffer)_res_modes struct to a
+ *                                      display_timing struct.
+ *
+ * @mode:      Input ctfb_res_modes structure pointer to be converted
+ *             from
+ * @timing:    Output display_timing structure pointer to be converted to
+ */
+void video_ctfb_mode_to_display_timing(const struct ctfb_res_modes *mode,
+                                      struct display_timing *timing);