hc
2023-11-06 9df731a176aab8e03b984b681b1bea01ccff6644
u-boot/drivers/video/drm/drm_modes.c
....@@ -60,6 +60,19 @@
6060 }
6161
6262 /**
63
+ * drm_mode_copy - copy the mode
64
+ * @dst: mode to overwrite
65
+ * @src: mode to copy
66
+ *
67
+ * Copy an existing mode into another mode, preserving the object id and
68
+ * list head of the destination mode.
69
+ */
70
+void drm_mode_copy(struct drm_display_mode *dst, const struct drm_display_mode *src)
71
+{
72
+ *dst = *src;
73
+}
74
+
75
+/**
6376 * drm_mode_destroy - remove a mode
6477 * @mode: mode to remove
6578 */
....@@ -185,6 +198,45 @@
185198 }
186199
187200 /**
201
+ * drm_display_mode_from_videomode - fill in @dmode using @vm,
202
+ * @vm: videomode structure to use as source
203
+ * @dmode: drm_display_mode structure to use as destination
204
+ *
205
+ * Fills out @dmode using the display mode specified in @vm.
206
+ */
207
+void drm_display_mode_from_videomode(const struct videomode *vm,
208
+ struct drm_display_mode *dmode)
209
+{
210
+ dmode->hdisplay = vm->hactive;
211
+ dmode->hsync_start = dmode->hdisplay + vm->hfront_porch;
212
+ dmode->hsync_end = dmode->hsync_start + vm->hsync_len;
213
+ dmode->htotal = dmode->hsync_end + vm->hback_porch;
214
+
215
+ dmode->vdisplay = vm->vactive;
216
+ dmode->vsync_start = dmode->vdisplay + vm->vfront_porch;
217
+ dmode->vsync_end = dmode->vsync_start + vm->vsync_len;
218
+ dmode->vtotal = dmode->vsync_end + vm->vback_porch;
219
+
220
+ dmode->clock = vm->pixelclock / 1000;
221
+
222
+ dmode->flags = 0;
223
+ if (vm->flags & DISPLAY_FLAGS_HSYNC_HIGH)
224
+ dmode->flags |= DRM_MODE_FLAG_PHSYNC;
225
+ else if (vm->flags & DISPLAY_FLAGS_HSYNC_LOW)
226
+ dmode->flags |= DRM_MODE_FLAG_NHSYNC;
227
+ if (vm->flags & DISPLAY_FLAGS_VSYNC_HIGH)
228
+ dmode->flags |= DRM_MODE_FLAG_PVSYNC;
229
+ else if (vm->flags & DISPLAY_FLAGS_VSYNC_LOW)
230
+ dmode->flags |= DRM_MODE_FLAG_NVSYNC;
231
+ if (vm->flags & DISPLAY_FLAGS_INTERLACED)
232
+ dmode->flags |= DRM_MODE_FLAG_INTERLACE;
233
+ if (vm->flags & DISPLAY_FLAGS_DOUBLESCAN)
234
+ dmode->flags |= DRM_MODE_FLAG_DBLSCAN;
235
+ if (vm->flags & DISPLAY_FLAGS_DOUBLECLK)
236
+ dmode->flags |= DRM_MODE_FLAG_DBLCLK;
237
+}
238
+
239
+/**
188240 * drm_display_mode_to_videomode - fill in @vm using @dmode,
189241 * @dmode: drm_display_mode structure to use as source
190242 * @vm: videomode structure to use as destination