Commit da075dec authored by Enrico Scholz's avatar Enrico Scholz

barebox: fixed of_camera_selection regression

Signed-off-by: Enrico Scholz's avatarEnrico Scholz <enrico.scholz@sigma-chemnitz.de>
parent da1ae191
From: "Enrico Scholz" <enrico.scholz@sigma-chemnitz.de>
Subject: 0001-of_camera_selection-enhanced-for-MIPI-support
Date: Thu, 10 Oct 2019 16:16:30 +0200
X-Committed: Thu, 10 Oct 2019 18:28:54 +0200
Patchset containing:
a250a5ebba fixup! of_camera_selection: enhanced for MIPI support
7b60f2d804 of_camera_selection: fix clock setup for VM016-S+
9e851811df of_camera_selection: enhanced for MIPI support
commands/of_camera_selection.c | 641 ++++++++++++++++++++++++++++++---------
1 file changed, 500 insertions(+), 141 deletions(-)
commands/of_camera_selection.c | 643 ++++++++++++++++++++++++++++++---------
1 file changed, 503 insertions(+), 140 deletions(-)
diff --git a/commands/of_camera_selection.c b/commands/of_camera_selection.c
index c73003d40d..2eb650bc53 100644
index c73003d40d..4ed133ea2c 100644
--- a/commands/of_camera_selection.c
+++ b/commands/of_camera_selection.c
@@ -31,28 +31,159 @@
......@@ -300,7 +307,7 @@ index c73003d40d..2eb650bc53 100644
static int is_cam_supported(const char *name)
{
int i;
@@ -97,86 +347,124 @@ static int is_cam_supported(const char *name)
@@ -97,86 +347,128 @@ static int is_cam_supported(const char *name)
return -1;
}
......@@ -395,7 +402,6 @@ index c73003d40d..2eb650bc53 100644
- if (port == get_camera_port(tmp_node, node))
- return tmp_node;
+ ctx->cam_node = tmp_node;
+ ctx->cam = type;
+ if (get_camera_port(ctx))
+ return true;
}
......@@ -425,59 +431,63 @@ index c73003d40d..2eb650bc53 100644
+ int camera;
+ char const *name;
+ char *tmp_name;
+
+ if (find_camera_by_type(ctx, type)) {
+ ctx->cam = type;
+ return true;
+ }
- if (port == get_camera_port(tmp_node, node))
- return tmp_node;
- }
- } else if (strstr(name, "-BW")) {
+ name = type->name;
+
+ if (strstr(name, "-COL")) {
+ tmp_name = xzalloc(strlen(name) + 1);
+
+ strncpy(tmp_name, name, strlen(name) - strlen("-COL"));
+ strcat(tmp_name, "-BW");
} else if (strstr(name, "-BW")) {
- char *tmp = xzalloc(strlen(name) + 2);
+ if (find_camera_by_type(ctx, type))
+ return true;
+ tmp_name = xzalloc(strlen(name) + 2);
- strncpy(tmp, name, strlen(name) - strlen("-BW"));
- tmp = strcat(tmp, "-COL");
+ name = type->name;
+ strncpy(tmp_name, name, strlen(name) - strlen("-BW"));
+ strcat(tmp_name, "-COL");
+ } else {
+ tmp_name = NULL;
+ }
- camera = is_cam_supported(tmp);
- free(tmp);
- if (camera < 0)
- return NULL;
+ if (strstr(name, "-COL")) {
+ tmp_name = xzalloc(strlen(name) + 1);
+ if (!tmp_name)
+ return false;
- for_each_compatible_node_from(tmp_node, node, NULL,
- phytec_cameras[camera].compatible) {
- if (port == get_camera_port(tmp_node, node))
- return tmp_node;
- }
+ strncpy(tmp_name, name, strlen(name) - strlen("-COL"));
+ strcat(tmp_name, "-BW");
+ } else if (strstr(name, "-BW")) {
+ tmp_name = xzalloc(strlen(name) + 2);
+
+ strncpy(tmp_name, name, strlen(name) - strlen("-BW"));
+ strcat(tmp_name, "-COL");
+ } else {
+ tmp_name = NULL;
}
- return NULL;
+ if (!tmp_name)
+ return false;
+
+ camera = is_cam_supported(tmp_name);
+ free(tmp_name);
+
+ if (camera < 0)
+ return NULL;
+
+ type = &phytec_cameras[camera];
+
+ return find_camera_by_type(ctx, type);
+ if (find_camera_by_type(ctx, &phytec_cameras[camera])) {
+ ctx->cam = type;
+ return true;
}
- return NULL;
+ return false;
}
static int of_set_phandle_to_remote_endpoint(struct device_node *cam,
@@ -189,32 +477,40 @@ static int of_set_phandle_to_remote_endpoint(struct device_node *cam,
@@ -189,32 +481,40 @@ static int of_set_phandle_to_remote_endpoint(struct device_node *cam,
p = cpu_to_be32(p);
ret = of_set_property(port, "remote-endpoint", &p, sizeof(p), 1);
......@@ -532,7 +542,7 @@ index c73003d40d..2eb650bc53 100644
if (!deserializer) {
pr_err("Path to deserializer is not vaild.\n");
return -EINVAL;
@@ -222,96 +518,124 @@ static int set_phycam_s_remote_endpoint(struct device_node *root,
@@ -222,96 +522,124 @@ static int set_phycam_s_remote_endpoint(struct device_node *root,
of_set_property(deserializer, "phytec,phycam-s", NULL, 0, 1);
......@@ -719,7 +729,7 @@ index c73003d40d..2eb650bc53 100644
return ret;
}
@@ -319,29 +643,44 @@ static int change_camera(struct device_node *root, void *context)
@@ -319,29 +647,44 @@ static int change_camera(struct device_node *root, void *context)
static int do_of_camera_selection(int argc, char *argv[])
{
struct camera_info *cam_info = xzalloc(sizeof(struct camera_info));
......@@ -770,7 +780,7 @@ index c73003d40d..2eb650bc53 100644
break;
case 'l':
list = 1;
@@ -362,6 +701,21 @@ static int do_of_camera_selection(int argc, char *argv[])
@@ -362,6 +705,21 @@ static int do_of_camera_selection(int argc, char *argv[])
goto free;
}
......@@ -792,7 +802,7 @@ index c73003d40d..2eb650bc53 100644
if (!bus) {
ret = COMMAND_ERROR_USAGE;
goto free;
@@ -373,11 +727,15 @@ static int do_of_camera_selection(int argc, char *argv[])
@@ -373,11 +731,15 @@ static int do_of_camera_selection(int argc, char *argv[])
}
if (optind < argc) {
......@@ -811,7 +821,7 @@ index c73003d40d..2eb650bc53 100644
}
of_register_fixup(change_camera, cam_info);
@@ -390,7 +748,8 @@ free:
@@ -390,7 +752,8 @@ free:
BAREBOX_CMD_HELP_START(of_camera_selection)
BAREBOX_CMD_HELP_TEXT("Options:")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment