blob: df375c96c5d323a71767ea8794f8695ff9fbad1c [file] [log] [blame]
Steffen Trumtrar8714c0c2012-12-17 14:20:17 +01001/*
2 * generic display timing functions
3 *
4 * Copyright (c) 2012 Steffen Trumtrar <s.trumtrar@pengutronix.de>, Pengutronix
5 *
6 * This file is released under the GPLv2
7 */
8
9#include <linux/errno.h>
10#include <linux/export.h>
11#include <video/display_timing.h>
12#include <video/videomode.h>
13
Tomi Valkeinen6cd2c7d2013-03-21 14:20:12 +020014void videomode_from_timing(const struct display_timing *dt,
15 struct videomode *vm)
Steffen Trumtrar8714c0c2012-12-17 14:20:17 +010016{
Tomi Valkeinen694f0502013-03-12 10:35:16 +020017 vm->pixelclock = dt->pixelclock.typ;
18 vm->hactive = dt->hactive.typ;
19 vm->hfront_porch = dt->hfront_porch.typ;
20 vm->hback_porch = dt->hback_porch.typ;
21 vm->hsync_len = dt->hsync_len.typ;
Steffen Trumtrar8714c0c2012-12-17 14:20:17 +010022
Tomi Valkeinen694f0502013-03-12 10:35:16 +020023 vm->vactive = dt->vactive.typ;
24 vm->vfront_porch = dt->vfront_porch.typ;
25 vm->vback_porch = dt->vback_porch.typ;
26 vm->vsync_len = dt->vsync_len.typ;
Steffen Trumtrar8714c0c2012-12-17 14:20:17 +010027
Tomi Valkeinen06a33072013-03-12 10:26:45 +020028 vm->flags = dt->flags;
Tomi Valkeinen6cd2c7d2013-03-21 14:20:12 +020029}
30EXPORT_SYMBOL_GPL(videomode_from_timing);
31
32int videomode_from_timings(const struct display_timings *disp,
33 struct videomode *vm, unsigned int index)
34{
35 struct display_timing *dt;
36
37 dt = display_timings_get(disp, index);
38 if (!dt)
39 return -EINVAL;
40
41 videomode_from_timing(dt, vm);
Steffen Trumtrar8714c0c2012-12-17 14:20:17 +010042
43 return 0;
44}
Tomi Valkeinen6cd2c7d2013-03-21 14:20:12 +020045EXPORT_SYMBOL_GPL(videomode_from_timings);