2012-09-26 12:24:03 +04:00
|
|
|
/*
|
|
|
|
* V4L2 OF binding parsing library
|
|
|
|
*
|
2013-04-02 18:41:19 +04:00
|
|
|
* Copyright (C) 2012 - 2013 Samsung Electronics Co., Ltd.
|
|
|
|
* Author: Sylwester Nawrocki <s.nawrocki@samsung.com>
|
|
|
|
*
|
2012-09-26 12:24:03 +04:00
|
|
|
* Copyright (C) 2012 Renesas Electronics Corp.
|
|
|
|
* Author: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of version 2 of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*/
|
|
|
|
#ifndef _V4L2_OF_H
|
|
|
|
#define _V4L2_OF_H
|
|
|
|
|
|
|
|
#include <linux/list.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/errno.h>
|
2014-02-11 01:01:48 +04:00
|
|
|
#include <linux/of_graph.h>
|
2012-09-26 12:24:03 +04:00
|
|
|
|
|
|
|
#include <media/v4l2-mediabus.h>
|
|
|
|
|
|
|
|
struct device_node;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct v4l2_of_bus_mipi_csi2 - MIPI CSI-2 bus data structure
|
|
|
|
* @flags: media bus (V4L2_MBUS_*) flags
|
|
|
|
* @data_lanes: an array of physical data lane indexes
|
|
|
|
* @clock_lane: physical lane index of the clock lane
|
|
|
|
* @num_data_lanes: number of data lanes
|
2015-03-26 01:57:37 +03:00
|
|
|
* @lane_polarities: polarity of the lanes. The order is the same of
|
|
|
|
* the physical lanes.
|
2012-09-26 12:24:03 +04:00
|
|
|
*/
|
|
|
|
struct v4l2_of_bus_mipi_csi2 {
|
|
|
|
unsigned int flags;
|
|
|
|
unsigned char data_lanes[4];
|
|
|
|
unsigned char clock_lane;
|
|
|
|
unsigned short num_data_lanes;
|
2015-03-26 01:57:37 +03:00
|
|
|
bool lane_polarities[5];
|
2012-09-26 12:24:03 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct v4l2_of_bus_parallel - parallel data bus data structure
|
|
|
|
* @flags: media bus (V4L2_MBUS_*) flags
|
|
|
|
* @bus_width: bus width in bits
|
|
|
|
* @data_shift: data shift in bits
|
|
|
|
*/
|
|
|
|
struct v4l2_of_bus_parallel {
|
|
|
|
unsigned int flags;
|
|
|
|
unsigned char bus_width;
|
|
|
|
unsigned char data_shift;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct v4l2_of_endpoint - the endpoint data structure
|
2014-02-14 14:53:56 +04:00
|
|
|
* @base: struct of_endpoint containing port, id, and local of_node
|
2012-09-26 12:24:03 +04:00
|
|
|
* @bus_type: bus type
|
|
|
|
* @bus: bus configuration data structure
|
[media] v4l: of: Parse variable length properties --- link-frequencies
The link-frequencies property is a variable length array of link frequencies
in an endpoint. The array is needed by an increasing number of drivers, so
it makes sense to add it to struct v4l2_of_endpoint.
However, the length of the array is variable and the size of struct
v4l2_of_endpoint is fixed since it is allocated by the caller. The options
here are
1. to define a fixed maximum limit of link frequencies that has to be the
global maximum of all boards. This is seen as problematic since the maximum
could be largish, and everyone hitting the problem would need to submit a
patch to fix it, or
2. parse the property in every driver. This doesn't sound appealing as two
of the three implementations submitted to linux-media were wrong, and one of
them was even merged before this was noticed, or
3. change the interface so that allocating and releasing memory according to
the size of the array is possible. This is what the patch does.
v4l2_of_alloc_parse_endpoint() is just like v4l2_of_parse_endpoint(), but it
will allocate the memory resources needed to store struct v4l2_of_endpoint
and the additional arrays pointed to by this struct. A corresponding release
function v4l2_of_free_endpoint() is provided to release the memory allocated
by v4l2_of_alloc_parse_endpoint().
In addition to this, the link-frequencies property is parsed as well, and
the result is stored to struct v4l2_of_endpoint field link_frequencies.
Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Tested-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-22 23:48:26 +03:00
|
|
|
* @link_frequencies: array of supported link frequencies
|
|
|
|
* @nr_of_link_frequencies: number of elements in link_frequenccies array
|
2012-09-26 12:24:03 +04:00
|
|
|
*/
|
|
|
|
struct v4l2_of_endpoint {
|
2014-02-14 14:53:56 +04:00
|
|
|
struct of_endpoint base;
|
2015-03-22 23:42:31 +03:00
|
|
|
/* Fields below this line will be zeroed by v4l2_of_parse_endpoint() */
|
2012-09-26 12:24:03 +04:00
|
|
|
enum v4l2_mbus_type bus_type;
|
|
|
|
union {
|
|
|
|
struct v4l2_of_bus_parallel parallel;
|
|
|
|
struct v4l2_of_bus_mipi_csi2 mipi_csi2;
|
|
|
|
} bus;
|
[media] v4l: of: Parse variable length properties --- link-frequencies
The link-frequencies property is a variable length array of link frequencies
in an endpoint. The array is needed by an increasing number of drivers, so
it makes sense to add it to struct v4l2_of_endpoint.
However, the length of the array is variable and the size of struct
v4l2_of_endpoint is fixed since it is allocated by the caller. The options
here are
1. to define a fixed maximum limit of link frequencies that has to be the
global maximum of all boards. This is seen as problematic since the maximum
could be largish, and everyone hitting the problem would need to submit a
patch to fix it, or
2. parse the property in every driver. This doesn't sound appealing as two
of the three implementations submitted to linux-media were wrong, and one of
them was even merged before this was noticed, or
3. change the interface so that allocating and releasing memory according to
the size of the array is possible. This is what the patch does.
v4l2_of_alloc_parse_endpoint() is just like v4l2_of_parse_endpoint(), but it
will allocate the memory resources needed to store struct v4l2_of_endpoint
and the additional arrays pointed to by this struct. A corresponding release
function v4l2_of_free_endpoint() is provided to release the memory allocated
by v4l2_of_alloc_parse_endpoint().
In addition to this, the link-frequencies property is parsed as well, and
the result is stored to struct v4l2_of_endpoint field link_frequencies.
Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Tested-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-22 23:48:26 +03:00
|
|
|
u64 *link_frequencies;
|
|
|
|
unsigned int nr_of_link_frequencies;
|
2012-09-26 12:24:03 +04:00
|
|
|
};
|
|
|
|
|
2013-05-17 14:31:04 +04:00
|
|
|
/**
|
|
|
|
* struct v4l2_of_link - a link between two endpoints
|
|
|
|
* @local_node: pointer to device_node of this endpoint
|
|
|
|
* @local_port: identifier of the port this endpoint belongs to
|
|
|
|
* @remote_node: pointer to device_node of the remote endpoint
|
|
|
|
* @remote_port: identifier of the port the remote endpoint belongs to
|
|
|
|
*/
|
|
|
|
struct v4l2_of_link {
|
|
|
|
struct device_node *local_node;
|
|
|
|
unsigned int local_port;
|
|
|
|
struct device_node *remote_node;
|
|
|
|
unsigned int remote_port;
|
|
|
|
};
|
|
|
|
|
2012-09-26 12:24:03 +04:00
|
|
|
#ifdef CONFIG_OF
|
2013-05-17 14:31:04 +04:00
|
|
|
int v4l2_of_parse_endpoint(const struct device_node *node,
|
|
|
|
struct v4l2_of_endpoint *endpoint);
|
[media] v4l: of: Parse variable length properties --- link-frequencies
The link-frequencies property is a variable length array of link frequencies
in an endpoint. The array is needed by an increasing number of drivers, so
it makes sense to add it to struct v4l2_of_endpoint.
However, the length of the array is variable and the size of struct
v4l2_of_endpoint is fixed since it is allocated by the caller. The options
here are
1. to define a fixed maximum limit of link frequencies that has to be the
global maximum of all boards. This is seen as problematic since the maximum
could be largish, and everyone hitting the problem would need to submit a
patch to fix it, or
2. parse the property in every driver. This doesn't sound appealing as two
of the three implementations submitted to linux-media were wrong, and one of
them was even merged before this was noticed, or
3. change the interface so that allocating and releasing memory according to
the size of the array is possible. This is what the patch does.
v4l2_of_alloc_parse_endpoint() is just like v4l2_of_parse_endpoint(), but it
will allocate the memory resources needed to store struct v4l2_of_endpoint
and the additional arrays pointed to by this struct. A corresponding release
function v4l2_of_free_endpoint() is provided to release the memory allocated
by v4l2_of_alloc_parse_endpoint().
In addition to this, the link-frequencies property is parsed as well, and
the result is stored to struct v4l2_of_endpoint field link_frequencies.
Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Tested-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-22 23:48:26 +03:00
|
|
|
struct v4l2_of_endpoint *v4l2_of_alloc_parse_endpoint(
|
|
|
|
const struct device_node *node);
|
|
|
|
void v4l2_of_free_endpoint(struct v4l2_of_endpoint *endpoint);
|
2013-05-17 14:31:04 +04:00
|
|
|
int v4l2_of_parse_link(const struct device_node *node,
|
|
|
|
struct v4l2_of_link *link);
|
|
|
|
void v4l2_of_put_link(struct v4l2_of_link *link);
|
2012-09-26 12:24:03 +04:00
|
|
|
#else /* CONFIG_OF */
|
|
|
|
|
|
|
|
static inline int v4l2_of_parse_endpoint(const struct device_node *node,
|
|
|
|
struct v4l2_of_endpoint *link)
|
|
|
|
{
|
|
|
|
return -ENOSYS;
|
|
|
|
}
|
|
|
|
|
2015-04-28 09:41:00 +03:00
|
|
|
static inline struct v4l2_of_endpoint *v4l2_of_alloc_parse_endpoint(
|
[media] v4l: of: Parse variable length properties --- link-frequencies
The link-frequencies property is a variable length array of link frequencies
in an endpoint. The array is needed by an increasing number of drivers, so
it makes sense to add it to struct v4l2_of_endpoint.
However, the length of the array is variable and the size of struct
v4l2_of_endpoint is fixed since it is allocated by the caller. The options
here are
1. to define a fixed maximum limit of link frequencies that has to be the
global maximum of all boards. This is seen as problematic since the maximum
could be largish, and everyone hitting the problem would need to submit a
patch to fix it, or
2. parse the property in every driver. This doesn't sound appealing as two
of the three implementations submitted to linux-media were wrong, and one of
them was even merged before this was noticed, or
3. change the interface so that allocating and releasing memory according to
the size of the array is possible. This is what the patch does.
v4l2_of_alloc_parse_endpoint() is just like v4l2_of_parse_endpoint(), but it
will allocate the memory resources needed to store struct v4l2_of_endpoint
and the additional arrays pointed to by this struct. A corresponding release
function v4l2_of_free_endpoint() is provided to release the memory allocated
by v4l2_of_alloc_parse_endpoint().
In addition to this, the link-frequencies property is parsed as well, and
the result is stored to struct v4l2_of_endpoint field link_frequencies.
Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Tested-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-22 23:48:26 +03:00
|
|
|
const struct device_node *node)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2015-04-28 09:41:00 +03:00
|
|
|
static inline void v4l2_of_free_endpoint(struct v4l2_of_endpoint *endpoint)
|
[media] v4l: of: Parse variable length properties --- link-frequencies
The link-frequencies property is a variable length array of link frequencies
in an endpoint. The array is needed by an increasing number of drivers, so
it makes sense to add it to struct v4l2_of_endpoint.
However, the length of the array is variable and the size of struct
v4l2_of_endpoint is fixed since it is allocated by the caller. The options
here are
1. to define a fixed maximum limit of link frequencies that has to be the
global maximum of all boards. This is seen as problematic since the maximum
could be largish, and everyone hitting the problem would need to submit a
patch to fix it, or
2. parse the property in every driver. This doesn't sound appealing as two
of the three implementations submitted to linux-media were wrong, and one of
them was even merged before this was noticed, or
3. change the interface so that allocating and releasing memory according to
the size of the array is possible. This is what the patch does.
v4l2_of_alloc_parse_endpoint() is just like v4l2_of_parse_endpoint(), but it
will allocate the memory resources needed to store struct v4l2_of_endpoint
and the additional arrays pointed to by this struct. A corresponding release
function v4l2_of_free_endpoint() is provided to release the memory allocated
by v4l2_of_alloc_parse_endpoint().
In addition to this, the link-frequencies property is parsed as well, and
the result is stored to struct v4l2_of_endpoint field link_frequencies.
Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Tested-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2015-03-22 23:48:26 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-05-17 14:31:04 +04:00
|
|
|
static inline int v4l2_of_parse_link(const struct device_node *node,
|
|
|
|
struct v4l2_of_link *link)
|
|
|
|
{
|
|
|
|
return -ENOSYS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void v4l2_of_put_link(struct v4l2_of_link *link)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-09-26 12:24:03 +04:00
|
|
|
#endif /* CONFIG_OF */
|
|
|
|
|
|
|
|
#endif /* _V4L2_OF_H */
|