media: v4l: fwnode: Let the caller provide V4L2 fwnode endpoint
Instead of allocating the V4L2 fwnode endpoint in v4l2_fwnode_endpoint_alloc_parse, let the caller to do this. This allows setting default parameters for the endpoint which is a very common need for drivers. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Tested-by: Steve Longerbeam <steve_longerbeam@mentor.com> Tested-by: Jacopo Mondi <jacopo+renesas@jmondi.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
This commit is contained in:

committed by
Mauro Carvalho Chehab

parent
2d95e7ed07
commit
6970d37cc9
@@ -1895,11 +1895,11 @@ static void tc358743_gpio_reset(struct tc358743_state *state)
|
||||
static int tc358743_probe_of(struct tc358743_state *state)
|
||||
{
|
||||
struct device *dev = &state->i2c_client->dev;
|
||||
struct v4l2_fwnode_endpoint *endpoint;
|
||||
struct v4l2_fwnode_endpoint endpoint = { .bus_type = 0 };
|
||||
struct device_node *ep;
|
||||
struct clk *refclk;
|
||||
u32 bps_pr_lane;
|
||||
int ret = -EINVAL;
|
||||
int ret;
|
||||
|
||||
refclk = devm_clk_get(dev, "refclk");
|
||||
if (IS_ERR(refclk)) {
|
||||
@@ -1915,26 +1915,28 @@ static int tc358743_probe_of(struct tc358743_state *state)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
endpoint = v4l2_fwnode_endpoint_alloc_parse(of_fwnode_handle(ep));
|
||||
if (IS_ERR(endpoint)) {
|
||||
ret = v4l2_fwnode_endpoint_alloc_parse(of_fwnode_handle(ep), &endpoint);
|
||||
if (ret) {
|
||||
dev_err(dev, "failed to parse endpoint\n");
|
||||
ret = PTR_ERR(endpoint);
|
||||
ret = ret;
|
||||
goto put_node;
|
||||
}
|
||||
|
||||
if (endpoint->bus_type != V4L2_MBUS_CSI2_DPHY ||
|
||||
endpoint->bus.mipi_csi2.num_data_lanes == 0 ||
|
||||
endpoint->nr_of_link_frequencies == 0) {
|
||||
if (endpoint.bus_type != V4L2_MBUS_CSI2_DPHY ||
|
||||
endpoint.bus.mipi_csi2.num_data_lanes == 0 ||
|
||||
endpoint.nr_of_link_frequencies == 0) {
|
||||
dev_err(dev, "missing CSI-2 properties in endpoint\n");
|
||||
ret = -EINVAL;
|
||||
goto free_endpoint;
|
||||
}
|
||||
|
||||
if (endpoint->bus.mipi_csi2.num_data_lanes > 4) {
|
||||
if (endpoint.bus.mipi_csi2.num_data_lanes > 4) {
|
||||
dev_err(dev, "invalid number of lanes\n");
|
||||
ret = -EINVAL;
|
||||
goto free_endpoint;
|
||||
}
|
||||
|
||||
state->bus = endpoint->bus.mipi_csi2;
|
||||
state->bus = endpoint.bus.mipi_csi2;
|
||||
|
||||
ret = clk_prepare_enable(refclk);
|
||||
if (ret) {
|
||||
@@ -1967,7 +1969,7 @@ static int tc358743_probe_of(struct tc358743_state *state)
|
||||
* The CSI bps per lane must be between 62.5 Mbps and 1 Gbps.
|
||||
* The default is 594 Mbps for 4-lane 1080p60 or 2-lane 720p60.
|
||||
*/
|
||||
bps_pr_lane = 2 * endpoint->link_frequencies[0];
|
||||
bps_pr_lane = 2 * endpoint.link_frequencies[0];
|
||||
if (bps_pr_lane < 62500000U || bps_pr_lane > 1000000000U) {
|
||||
dev_err(dev, "unsupported bps per lane: %u bps\n", bps_pr_lane);
|
||||
goto disable_clk;
|
||||
@@ -2013,7 +2015,7 @@ static int tc358743_probe_of(struct tc358743_state *state)
|
||||
disable_clk:
|
||||
clk_disable_unprepare(refclk);
|
||||
free_endpoint:
|
||||
v4l2_fwnode_endpoint_free(endpoint);
|
||||
v4l2_fwnode_endpoint_free(&endpoint);
|
||||
put_node:
|
||||
of_node_put(ep);
|
||||
return ret;
|
||||
|
Reference in New Issue
Block a user