Source
/*
* OF helpers for parsing display timings
*
* Copyright (c) 2012 Steffen Trumtrar <s.trumtrar@pengutronix.de>, Pengutronix
*
* based on of_videomode.c by Sascha Hauer <s.hauer@pengutronix.de>
*
* This file is released under the GPLv2
*/
/**
* parse_timing_property - parse timing_entry from device_node
* @np: device_node with the property
* @name: name of the property
* @result: will be set to the return value
*
* DESCRIPTION:
* Every display_timing can be specified with either just the typical value or
* a range consisting of min/typ/max. This function helps handling this
**/
static int parse_timing_property(const struct device_node *np, const char *name,
struct timing_entry *result)
{
struct property *prop;
int length, cells, ret;
prop = of_find_property(np, name, &length);
if (!prop) {
pr_err("%pOF: could not find property %s\n", np, name);
return -EINVAL;
}
cells = length / sizeof(u32);
if (cells == 1) {
ret = of_property_read_u32(np, name, &result->typ);
result->min = result->typ;
result->max = result->typ;
} else if (cells == 3) {
ret = of_property_read_u32_array(np, name, &result->min, cells);
} else {
pr_err("%pOF: illegal timing specification in %s\n", np, name);
return -EINVAL;
}
return ret;
}
/**
* of_parse_display_timing - parse display_timing entry from device_node
* @np: device_node with the properties
**/
static int of_parse_display_timing(const struct device_node *np,
struct display_timing *dt)
{
u32 val = 0;
int ret = 0;
memset(dt, 0, sizeof(*dt));