Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * generic videomode helper
0004  *
0005  * Copyright (c) 2012 Steffen Trumtrar <s.trumtrar@pengutronix.de>, Pengutronix
0006  */
0007 #include <linux/errno.h>
0008 #include <linux/export.h>
0009 #include <linux/of.h>
0010 #include <video/display_timing.h>
0011 #include <video/of_display_timing.h>
0012 #include <video/of_videomode.h>
0013 #include <video/videomode.h>
0014 
0015 /**
0016  * of_get_videomode - get the videomode #<index> from devicetree
0017  * @np: devicenode with the display_timings
0018  * @vm: set to return value
0019  * @index: index into list of display_timings
0020  *      (Set this to OF_USE_NATIVE_MODE to use whatever mode is
0021  *       specified as native mode in the DT.)
0022  *
0023  * DESCRIPTION:
0024  * Get a list of all display timings and put the one
0025  * specified by index into *vm. This function should only be used, if
0026  * only one videomode is to be retrieved. A driver that needs to work
0027  * with multiple/all videomodes should work with
0028  * of_get_display_timings instead.
0029  **/
0030 int of_get_videomode(struct device_node *np, struct videomode *vm,
0031              int index)
0032 {
0033     struct display_timings *disp;
0034     int ret;
0035 
0036     disp = of_get_display_timings(np);
0037     if (!disp) {
0038         pr_err("%pOF: no timings specified\n", np);
0039         return -EINVAL;
0040     }
0041 
0042     if (index == OF_USE_NATIVE_MODE)
0043         index = disp->native_mode;
0044 
0045     ret = videomode_from_timings(disp, vm, index);
0046 
0047     display_timings_release(disp);
0048 
0049     return ret;
0050 }
0051 EXPORT_SYMBOL_GPL(of_get_videomode);