Skip to content

Commit 67a5fb9

Browse files
committed
tests: drivers: video: test_pattern: new test from the sample
Turn the test part of the sample code into a dedicated test into the tests/ directory instead of just samples/. Signed-off-by: Josuah Demangeon <me@josuah.net>
1 parent d964140 commit 67a5fb9

File tree

8 files changed

+334
-180
lines changed

8 files changed

+334
-180
lines changed

samples/drivers/video/capture/src/check_test_pattern.h

Lines changed: 0 additions & 154 deletions
This file was deleted.

samples/drivers/video/capture/src/main.c

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,7 @@
1313
#include <zephyr/drivers/video-controls.h>
1414

1515
#include <zephyr/logging/log.h>
16-
17-
#ifdef CONFIG_TEST
18-
#include "check_test_pattern.h"
19-
20-
LOG_MODULE_REGISTER(main, LOG_LEVEL_DBG);
21-
#else
2216
LOG_MODULE_REGISTER(main, CONFIG_LOG_DEFAULT_LEVEL);
23-
#endif
2417

2518
#if !DT_HAS_CHOSEN(zephyr_camera)
2619
#error No camera chosen in devicetree. Missing "--shield" or "--snippet video-sw-generator" flag?
@@ -252,7 +245,6 @@ int main(void)
252245
}
253246

254247
/* Set controls */
255-
int tp_set_ret = -ENOTSUP;
256248

257249
if (IS_ENABLED(CONFIG_VIDEO_CTRL_HFLIP)) {
258250
struct video_control ctrl = {.id = VIDEO_CID_HFLIP, .val = 1};
@@ -274,16 +266,6 @@ int main(void)
274266
}
275267
}
276268

277-
if (IS_ENABLED(CONFIG_TEST)) {
278-
struct video_control ctrl = {.id = VIDEO_CID_TEST_PATTERN, .val = 1};
279-
280-
ret = video_set_ctrl(video_dev, &ctrl);
281-
if (ret < 0 && ret != -ENOTSUP) {
282-
LOG_WRN("Failed to set the test pattern");
283-
}
284-
tp_set_ret = ret;
285-
}
286-
287269
#if DT_HAS_CHOSEN(zephyr_display)
288270
const struct device *const display_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_display));
289271

@@ -353,14 +335,6 @@ int main(void)
353335
LOG_INF("Got frame %u! size: %u; timestamp %u ms",
354336
frame++, vbuf->bytesused, vbuf->timestamp);
355337

356-
#ifdef CONFIG_TEST
357-
if (tp_set_ret < 0) {
358-
LOG_DBG("Test pattern control was not successful. Skip test");
359-
} else if (is_colorbar_ok(vbuf->buffer, fmt)) {
360-
LOG_DBG("Pattern OK!\n");
361-
}
362-
#endif
363-
364338
#if DT_HAS_CHOSEN(zephyr_display)
365339
ret = app_display_frame(display_dev, vbuf, fmt);
366340
if (ret != 0) {
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Copyright The Zephyr Project Contributors
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
cmake_minimum_required(VERSION 3.20.0)
5+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
6+
project(integration)
7+
8+
target_sources(app PRIVATE src/main.c)
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Copyright The Zephyr Project Contributors
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
mainmenu "Video test pattern testing"
5+
6+
menu "Video capture configuration"
7+
8+
config VIDEO_FRAME_HEIGHT
9+
int "Height of the video frame"
10+
default 0
11+
help
12+
Height of the video frame. If set to 0, the default height is used.
13+
14+
config VIDEO_FRAME_WIDTH
15+
int "Width of the video frame"
16+
default 0
17+
help
18+
Width of the video frame. If set to 0, the default width is used.
19+
20+
config VIDEO_PIXEL_FORMAT
21+
string "Pixel format of the video frame"
22+
help
23+
Pixel format of the video frame. If not set, the default pixel format is used.
24+
25+
config LAB_THRESHOLD
26+
int "CIE LAB acceptance threshold"
27+
default 10
28+
help
29+
Margin value to consider the color similarity to be close enough.
30+
The default is 10 to allow slight difference to be ignored, and complete swaps to
31+
always be detected. This can be raised in case the colors are all slightly off but
32+
correctly ordered.
33+
34+
endmenu
35+
36+
source "Kconfig.zephyr"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CONFIG_VIDEO_BUFFER_POOL_SZ_MAX=33000
2+
CONFIG_VIDEO_BUFFER_POOL_NUM_MAX=1
3+
CONFIG_VIDEO_FRAME_HEIGHT=64
4+
CONFIG_VIDEO_FRAME_WIDTH=256
5+
CONFIG_VIDEO_PIXEL_FORMAT="RGBP"
6+
CONFIG_LAB_THRESHOLD=30
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
CONFIG_LOG=y
2+
CONFIG_VIDEO=y
3+
CONFIG_ZTEST=y

0 commit comments

Comments
 (0)