mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-01 11:21:51 +00:00
[media] of: move common endpoint parsing to drivers/of
This patch adds a new struct of_endpoint which is then embedded in struct v4l2_of_endpoint and contains the endpoint properties that are not V4L2 (or even media) specific: the port number, endpoint id, local device tree node and remote endpoint phandle. of_graph_parse_endpoint parses those properties and is used by v4l2_of_parse_endpoint, which just adds the V4L2 MBUS information to the containing v4l2_of_endpoint structure. Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Acked-by: Tomi Valkeinen <tomi.valkeinen@ti.com> Acked-by: Mauro Carvalho Chehab <m.chehab@samsung.com> Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
This commit is contained in:
parent
4329b93b28
commit
f2a575f676
6 changed files with 59 additions and 25 deletions
|
@ -469,10 +469,10 @@ static int fimc_md_parse_port_node(struct fimc_md *fmd,
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
v4l2_of_parse_endpoint(ep, &endpoint);
|
v4l2_of_parse_endpoint(ep, &endpoint);
|
||||||
if (WARN_ON(endpoint.port == 0) || index >= FIMC_MAX_SENSORS)
|
if (WARN_ON(endpoint.base.port == 0) || index >= FIMC_MAX_SENSORS)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
pd->mux_id = (endpoint.port - 1) & 0x1;
|
pd->mux_id = (endpoint.base.port - 1) & 0x1;
|
||||||
|
|
||||||
rem = of_graph_get_remote_port_parent(ep);
|
rem = of_graph_get_remote_port_parent(ep);
|
||||||
of_node_put(ep);
|
of_node_put(ep);
|
||||||
|
@ -494,13 +494,13 @@ static int fimc_md_parse_port_node(struct fimc_md *fmd,
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fimc_input_is_parallel(endpoint.port)) {
|
if (fimc_input_is_parallel(endpoint.base.port)) {
|
||||||
if (endpoint.bus_type == V4L2_MBUS_PARALLEL)
|
if (endpoint.bus_type == V4L2_MBUS_PARALLEL)
|
||||||
pd->sensor_bus_type = FIMC_BUS_TYPE_ITU_601;
|
pd->sensor_bus_type = FIMC_BUS_TYPE_ITU_601;
|
||||||
else
|
else
|
||||||
pd->sensor_bus_type = FIMC_BUS_TYPE_ITU_656;
|
pd->sensor_bus_type = FIMC_BUS_TYPE_ITU_656;
|
||||||
pd->flags = endpoint.bus.parallel.flags;
|
pd->flags = endpoint.bus.parallel.flags;
|
||||||
} else if (fimc_input_is_mipi_csi(endpoint.port)) {
|
} else if (fimc_input_is_mipi_csi(endpoint.base.port)) {
|
||||||
/*
|
/*
|
||||||
* MIPI CSI-2: only input mux selection and
|
* MIPI CSI-2: only input mux selection and
|
||||||
* the sensor's clock frequency is needed.
|
* the sensor's clock frequency is needed.
|
||||||
|
@ -508,7 +508,7 @@ static int fimc_md_parse_port_node(struct fimc_md *fmd,
|
||||||
pd->sensor_bus_type = FIMC_BUS_TYPE_MIPI_CSI2;
|
pd->sensor_bus_type = FIMC_BUS_TYPE_MIPI_CSI2;
|
||||||
} else {
|
} else {
|
||||||
v4l2_err(&fmd->v4l2_dev, "Wrong port id (%u) at node %s\n",
|
v4l2_err(&fmd->v4l2_dev, "Wrong port id (%u) at node %s\n",
|
||||||
endpoint.port, rem->full_name);
|
endpoint.base.port, rem->full_name);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* For FIMC-IS handled sensors, that are placed under i2c-isp device
|
* For FIMC-IS handled sensors, that are placed under i2c-isp device
|
||||||
|
|
|
@ -772,7 +772,7 @@ static int s5pcsis_parse_dt(struct platform_device *pdev,
|
||||||
/* Get port node and validate MIPI-CSI channel id. */
|
/* Get port node and validate MIPI-CSI channel id. */
|
||||||
v4l2_of_parse_endpoint(node, &endpoint);
|
v4l2_of_parse_endpoint(node, &endpoint);
|
||||||
|
|
||||||
state->index = endpoint.port - FIMC_INPUT_MIPI_CSI2_0;
|
state->index = endpoint.base.port - FIMC_INPUT_MIPI_CSI2_0;
|
||||||
if (state->index < 0 || state->index >= CSIS_MAX_ENTITIES)
|
if (state->index < 0 || state->index >= CSIS_MAX_ENTITIES)
|
||||||
return -ENXIO;
|
return -ENXIO;
|
||||||
|
|
||||||
|
|
|
@ -127,17 +127,9 @@ static void v4l2_of_parse_parallel_bus(const struct device_node *node,
|
||||||
int v4l2_of_parse_endpoint(const struct device_node *node,
|
int v4l2_of_parse_endpoint(const struct device_node *node,
|
||||||
struct v4l2_of_endpoint *endpoint)
|
struct v4l2_of_endpoint *endpoint)
|
||||||
{
|
{
|
||||||
struct device_node *port_node = of_get_parent(node);
|
of_graph_parse_endpoint(node, &endpoint->base);
|
||||||
|
endpoint->bus_type = 0;
|
||||||
memset(endpoint, 0, offsetof(struct v4l2_of_endpoint, head));
|
memset(&endpoint->bus, 0, sizeof(endpoint->bus));
|
||||||
|
|
||||||
endpoint->local_node = node;
|
|
||||||
/*
|
|
||||||
* It doesn't matter whether the two calls below succeed.
|
|
||||||
* If they don't then the default value 0 is used.
|
|
||||||
*/
|
|
||||||
of_property_read_u32(port_node, "reg", &endpoint->port);
|
|
||||||
of_property_read_u32(node, "reg", &endpoint->id);
|
|
||||||
|
|
||||||
v4l2_of_parse_csi_bus(node, endpoint);
|
v4l2_of_parse_csi_bus(node, endpoint);
|
||||||
/*
|
/*
|
||||||
|
@ -147,8 +139,6 @@ int v4l2_of_parse_endpoint(const struct device_node *node,
|
||||||
if (endpoint->bus.mipi_csi2.flags == 0)
|
if (endpoint->bus.mipi_csi2.flags == 0)
|
||||||
v4l2_of_parse_parallel_bus(node, endpoint);
|
v4l2_of_parse_parallel_bus(node, endpoint);
|
||||||
|
|
||||||
of_node_put(port_node);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(v4l2_of_parse_endpoint);
|
EXPORT_SYMBOL(v4l2_of_parse_endpoint);
|
||||||
|
|
|
@ -1984,6 +1984,34 @@ struct device_node *of_find_next_cache_node(const struct device_node *np)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* of_graph_parse_endpoint() - parse common endpoint node properties
|
||||||
|
* @node: pointer to endpoint device_node
|
||||||
|
* @endpoint: pointer to the OF endpoint data structure
|
||||||
|
*
|
||||||
|
* The caller should hold a reference to @node.
|
||||||
|
*/
|
||||||
|
int of_graph_parse_endpoint(const struct device_node *node,
|
||||||
|
struct of_endpoint *endpoint)
|
||||||
|
{
|
||||||
|
struct device_node *port_node = of_get_parent(node);
|
||||||
|
|
||||||
|
memset(endpoint, 0, sizeof(*endpoint));
|
||||||
|
|
||||||
|
endpoint->local_node = node;
|
||||||
|
/*
|
||||||
|
* It doesn't matter whether the two calls below succeed.
|
||||||
|
* If they don't then the default value 0 is used.
|
||||||
|
*/
|
||||||
|
of_property_read_u32(port_node, "reg", &endpoint->port);
|
||||||
|
of_property_read_u32(node, "reg", &endpoint->id);
|
||||||
|
|
||||||
|
of_node_put(port_node);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(of_graph_parse_endpoint);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* of_graph_get_next_endpoint() - get next endpoint node
|
* of_graph_get_next_endpoint() - get next endpoint node
|
||||||
* @parent: pointer to the parent device node
|
* @parent: pointer to the parent device node
|
||||||
|
|
|
@ -14,7 +14,21 @@
|
||||||
#ifndef __LINUX_OF_GRAPH_H
|
#ifndef __LINUX_OF_GRAPH_H
|
||||||
#define __LINUX_OF_GRAPH_H
|
#define __LINUX_OF_GRAPH_H
|
||||||
|
|
||||||
|
/**
|
||||||
|
* struct of_endpoint - the OF graph endpoint data structure
|
||||||
|
* @port: identifier (value of reg property) of a port this endpoint belongs to
|
||||||
|
* @id: identifier (value of reg property) of this endpoint
|
||||||
|
* @local_node: pointer to device_node of this endpoint
|
||||||
|
*/
|
||||||
|
struct of_endpoint {
|
||||||
|
unsigned int port;
|
||||||
|
unsigned int id;
|
||||||
|
const struct device_node *local_node;
|
||||||
|
};
|
||||||
|
|
||||||
#ifdef CONFIG_OF
|
#ifdef CONFIG_OF
|
||||||
|
int of_graph_parse_endpoint(const struct device_node *node,
|
||||||
|
struct of_endpoint *endpoint);
|
||||||
struct device_node *of_graph_get_next_endpoint(const struct device_node *parent,
|
struct device_node *of_graph_get_next_endpoint(const struct device_node *parent,
|
||||||
struct device_node *previous);
|
struct device_node *previous);
|
||||||
struct device_node *of_graph_get_remote_port_parent(
|
struct device_node *of_graph_get_remote_port_parent(
|
||||||
|
@ -22,6 +36,12 @@ struct device_node *of_graph_get_remote_port_parent(
|
||||||
struct device_node *of_graph_get_remote_port(const struct device_node *node);
|
struct device_node *of_graph_get_remote_port(const struct device_node *node);
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
static inline int of_graph_parse_endpoint(const struct device_node *node,
|
||||||
|
struct of_endpoint *endpoint);
|
||||||
|
{
|
||||||
|
return -ENOSYS;
|
||||||
|
}
|
||||||
|
|
||||||
static inline struct device_node *of_graph_get_next_endpoint(
|
static inline struct device_node *of_graph_get_next_endpoint(
|
||||||
const struct device_node *parent,
|
const struct device_node *parent,
|
||||||
struct device_node *previous)
|
struct device_node *previous)
|
||||||
|
|
|
@ -51,17 +51,13 @@ struct v4l2_of_bus_parallel {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* struct v4l2_of_endpoint - the endpoint data structure
|
* struct v4l2_of_endpoint - the endpoint data structure
|
||||||
* @port: identifier (value of reg property) of a port this endpoint belongs to
|
* @base: struct of_endpoint containing port, id, and local of_node
|
||||||
* @id: identifier (value of reg property) of this endpoint
|
|
||||||
* @local_node: pointer to device_node of this endpoint
|
|
||||||
* @bus_type: bus type
|
* @bus_type: bus type
|
||||||
* @bus: bus configuration data structure
|
* @bus: bus configuration data structure
|
||||||
* @head: list head for this structure
|
* @head: list head for this structure
|
||||||
*/
|
*/
|
||||||
struct v4l2_of_endpoint {
|
struct v4l2_of_endpoint {
|
||||||
unsigned int port;
|
struct of_endpoint base;
|
||||||
unsigned int id;
|
|
||||||
const struct device_node *local_node;
|
|
||||||
enum v4l2_mbus_type bus_type;
|
enum v4l2_mbus_type bus_type;
|
||||||
union {
|
union {
|
||||||
struct v4l2_of_bus_parallel parallel;
|
struct v4l2_of_bus_parallel parallel;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue