Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  * generic videomode helper
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  * Copyright (c) 2012 Steffen Trumtrar <s.trumtrar@pengutronix.de>, Pengutronix
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) #include <linux/export.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) #include <linux/of.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <video/display_timing.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <video/of_display_timing.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <video/of_videomode.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <video/videomode.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)  * of_get_videomode - get the videomode #<index> from devicetree
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)  * @np - devicenode with the display_timings
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)  * @vm - set to return value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)  * @index - index into list of display_timings
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)  *	    (Set this to OF_USE_NATIVE_MODE to use whatever mode is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)  *	     specified as native mode in the DT.)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)  * DESCRIPTION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)  * Get a list of all display timings and put the one
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)  * specified by index into *vm. This function should only be used, if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)  * only one videomode is to be retrieved. A driver that needs to work
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)  * with multiple/all videomodes should work with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)  * of_get_display_timings instead.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)  **/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) int of_get_videomode(struct device_node *np, struct videomode *vm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 		     int index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 	struct display_timings *disp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 	disp = of_get_display_timings(np);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 	if (!disp) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 		pr_err("%pOF: no timings specified\n", np);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 	if (index == OF_USE_NATIVE_MODE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 		index = disp->native_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 	ret = videomode_from_timings(disp, vm, index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 	display_timings_release(disp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) EXPORT_SYMBOL_GPL(of_get_videomode);