xref: /linux/drivers/video/videomode.c (revision 8714c0cecfc28f7ce73a520be4831f09743c4fd7)
1*8714c0ceSSteffen Trumtrar /*
2*8714c0ceSSteffen Trumtrar  * generic display timing functions
3*8714c0ceSSteffen Trumtrar  *
4*8714c0ceSSteffen Trumtrar  * Copyright (c) 2012 Steffen Trumtrar <s.trumtrar@pengutronix.de>, Pengutronix
5*8714c0ceSSteffen Trumtrar  *
6*8714c0ceSSteffen Trumtrar  * This file is released under the GPLv2
7*8714c0ceSSteffen Trumtrar  */
8*8714c0ceSSteffen Trumtrar 
9*8714c0ceSSteffen Trumtrar #include <linux/errno.h>
10*8714c0ceSSteffen Trumtrar #include <linux/export.h>
11*8714c0ceSSteffen Trumtrar #include <video/display_timing.h>
12*8714c0ceSSteffen Trumtrar #include <video/videomode.h>
13*8714c0ceSSteffen Trumtrar 
14*8714c0ceSSteffen Trumtrar int videomode_from_timing(const struct display_timings *disp,
15*8714c0ceSSteffen Trumtrar 			  struct videomode *vm, unsigned int index)
16*8714c0ceSSteffen Trumtrar {
17*8714c0ceSSteffen Trumtrar 	struct display_timing *dt;
18*8714c0ceSSteffen Trumtrar 
19*8714c0ceSSteffen Trumtrar 	dt = display_timings_get(disp, index);
20*8714c0ceSSteffen Trumtrar 	if (!dt)
21*8714c0ceSSteffen Trumtrar 		return -EINVAL;
22*8714c0ceSSteffen Trumtrar 
23*8714c0ceSSteffen Trumtrar 	vm->pixelclock = display_timing_get_value(&dt->pixelclock, TE_TYP);
24*8714c0ceSSteffen Trumtrar 	vm->hactive = display_timing_get_value(&dt->hactive, TE_TYP);
25*8714c0ceSSteffen Trumtrar 	vm->hfront_porch = display_timing_get_value(&dt->hfront_porch, TE_TYP);
26*8714c0ceSSteffen Trumtrar 	vm->hback_porch = display_timing_get_value(&dt->hback_porch, TE_TYP);
27*8714c0ceSSteffen Trumtrar 	vm->hsync_len = display_timing_get_value(&dt->hsync_len, TE_TYP);
28*8714c0ceSSteffen Trumtrar 
29*8714c0ceSSteffen Trumtrar 	vm->vactive = display_timing_get_value(&dt->vactive, TE_TYP);
30*8714c0ceSSteffen Trumtrar 	vm->vfront_porch = display_timing_get_value(&dt->vfront_porch, TE_TYP);
31*8714c0ceSSteffen Trumtrar 	vm->vback_porch = display_timing_get_value(&dt->vback_porch, TE_TYP);
32*8714c0ceSSteffen Trumtrar 	vm->vsync_len = display_timing_get_value(&dt->vsync_len, TE_TYP);
33*8714c0ceSSteffen Trumtrar 
34*8714c0ceSSteffen Trumtrar 	vm->dmt_flags = dt->dmt_flags;
35*8714c0ceSSteffen Trumtrar 	vm->data_flags = dt->data_flags;
36*8714c0ceSSteffen Trumtrar 
37*8714c0ceSSteffen Trumtrar 	return 0;
38*8714c0ceSSteffen Trumtrar }
39*8714c0ceSSteffen Trumtrar EXPORT_SYMBOL_GPL(videomode_from_timing);
40