Thomas Gleixner | 55716d2 | 2019-06-01 10:08:42 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Steffen Trumtrar | 8714c0c | 2012-12-17 14:20:17 +0100 | [diff] [blame] | 2 | /* |
| 3 | * generic display timing functions |
| 4 | * |
| 5 | * Copyright (c) 2012 Steffen Trumtrar <s.trumtrar@pengutronix.de>, Pengutronix |
Steffen Trumtrar | 8714c0c | 2012-12-17 14:20:17 +0100 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <linux/errno.h> |
| 9 | #include <linux/export.h> |
| 10 | #include <video/display_timing.h> |
| 11 | #include <video/videomode.h> |
| 12 | |
Tomi Valkeinen | 6cd2c7d | 2013-03-21 14:20:12 +0200 | [diff] [blame] | 13 | void videomode_from_timing(const struct display_timing *dt, |
| 14 | struct videomode *vm) |
Steffen Trumtrar | 8714c0c | 2012-12-17 14:20:17 +0100 | [diff] [blame] | 15 | { |
Tomi Valkeinen | 694f050 | 2013-03-12 10:35:16 +0200 | [diff] [blame] | 16 | vm->pixelclock = dt->pixelclock.typ; |
| 17 | vm->hactive = dt->hactive.typ; |
| 18 | vm->hfront_porch = dt->hfront_porch.typ; |
| 19 | vm->hback_porch = dt->hback_porch.typ; |
| 20 | vm->hsync_len = dt->hsync_len.typ; |
Steffen Trumtrar | 8714c0c | 2012-12-17 14:20:17 +0100 | [diff] [blame] | 21 | |
Tomi Valkeinen | 694f050 | 2013-03-12 10:35:16 +0200 | [diff] [blame] | 22 | vm->vactive = dt->vactive.typ; |
| 23 | vm->vfront_porch = dt->vfront_porch.typ; |
| 24 | vm->vback_porch = dt->vback_porch.typ; |
| 25 | vm->vsync_len = dt->vsync_len.typ; |
Steffen Trumtrar | 8714c0c | 2012-12-17 14:20:17 +0100 | [diff] [blame] | 26 | |
Tomi Valkeinen | 06a3307 | 2013-03-12 10:26:45 +0200 | [diff] [blame] | 27 | vm->flags = dt->flags; |
Tomi Valkeinen | 6cd2c7d | 2013-03-21 14:20:12 +0200 | [diff] [blame] | 28 | } |
| 29 | EXPORT_SYMBOL_GPL(videomode_from_timing); |
| 30 | |
| 31 | int videomode_from_timings(const struct display_timings *disp, |
| 32 | struct videomode *vm, unsigned int index) |
| 33 | { |
| 34 | struct display_timing *dt; |
| 35 | |
| 36 | dt = display_timings_get(disp, index); |
| 37 | if (!dt) |
| 38 | return -EINVAL; |
| 39 | |
| 40 | videomode_from_timing(dt, vm); |
Steffen Trumtrar | 8714c0c | 2012-12-17 14:20:17 +0100 | [diff] [blame] | 41 | |
| 42 | return 0; |
| 43 | } |
Tomi Valkeinen | 6cd2c7d | 2013-03-21 14:20:12 +0200 | [diff] [blame] | 44 | EXPORT_SYMBOL_GPL(videomode_from_timings); |