Commit 9ef108c4 authored by Dorota Czaplejewicz's avatar Dorota Czaplejewicz
Browse files

New algo

parent 95b548ae
...@@ -716,11 +716,35 @@ static int s5k3l6xx_enum_mbus_code(struct v4l2_subdev *sd, ...@@ -716,11 +716,35 @@ static int s5k3l6xx_enum_mbus_code(struct v4l2_subdev *sd,
struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_pad_config *cfg,
struct v4l2_subdev_mbus_code_enum *code) struct v4l2_subdev_mbus_code_enum *code)
{ {
if (code->index >= ARRAY_SIZE(s5k3l6xx_frames)) unsigned repeats[ARRAY_SIZE(s5k3l6xx_frames)] = {0};
return -EINVAL; unsigned i, j;
code->code = s5k3l6xx_frames[code->index].code; unsigned matching = 0;
dev_err(sd->dev, "code_call index %d code %d", code->index, s5k3l6xx_frames[code->index].code);
return 0; /* Find unique codes within the frame configs array.
* The algorithm is O(n^2), but there's only a handful of configs,
* meaning that it's unlikely to take a long time.
* The repeats array's size is determined at compile time.
*/
for (i = 0; i < ARRAY_SIZE(s5k3l6xx_frames); i++) {
for (j = 0; j < i; j++) {
if (s5k3l6xx_frames[j].code == s5k3l6xx_frames[i].code) {
repeats[i]++;
}
}
}
for (i = 0; i < ARRAY_SIZE(s5k3l6xx_frames); i++) {
if (repeats[i] != 0)
continue;
if (matching == code->index) {
code->code = s5k3l6xx_frames[i].code;
return 0;
}
matching++;
}
return -EINVAL;
} }
static int s5k3l6xx_enum_frame_size(struct v4l2_subdev *sd, static int s5k3l6xx_enum_frame_size(struct v4l2_subdev *sd,
...@@ -736,6 +760,7 @@ static int s5k3l6xx_enum_frame_size(struct v4l2_subdev *sd, ...@@ -736,6 +760,7 @@ static int s5k3l6xx_enum_frame_size(struct v4l2_subdev *sd,
dev_err(sd->dev, "index %d code %d", i, s5k3l6xx_frames[i].code); dev_err(sd->dev, "index %d code %d", i, s5k3l6xx_frames[i].code);
if (fse->code != s5k3l6xx_frames[i].code) if (fse->code != s5k3l6xx_frames[i].code)
continue; continue;
if (fse->index == matching) { if (fse->index == matching) {
fse->code = s5k3l6xx_frames[i].code; fse->code = s5k3l6xx_frames[i].code;
fse->min_width = s5k3l6xx_frames[i].width; fse->min_width = s5k3l6xx_frames[i].width;
......
Supports Markdown
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