* [igt-dev] [PATCH i-g-t 0/5] Add igt_audio self-tests and check for noise/pops
@ 2019-05-29 13:32 Simon Ser
2019-05-29 13:32 ` [igt-dev] [PATCH i-g-t 1/5] lib/igt_audio: add basic audio_signal_detect tests Simon Ser
` (6 more replies)
0 siblings, 7 replies; 14+ messages in thread
From: Simon Ser @ 2019-05-29 13:32 UTC (permalink / raw)
To: igt-dev; +Cc: martin.peres
This series adds some igt_audio self-tests, so we can patch the library with
more confidence without relying on real hardware.
It also adds a check for pops/noise in audio_signal_detect (with a matching
test).
This series obsoletes the previous "lib/igt_audio: add basic
audio_signal_detect tests" patch.
Simon Ser (5):
lib/igt_audio: add basic audio_signal_detect tests
lib/tests/igt_audio: add test with missing frequency
lib/tests/igt_audio: add test with an extra frequency
lib/igt_audio: detect noise and pops
lib/tests/igt_audio: add a pop test
lib/igt_audio.c | 44 +++++++++--
lib/tests/igt_audio.c | 176 ++++++++++++++++++++++++++++++++++++++++++
lib/tests/meson.build | 7 ++
3 files changed, 222 insertions(+), 5 deletions(-)
create mode 100644 lib/tests/igt_audio.c
--
2.21.0
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply [flat|nested] 14+ messages in thread
* [igt-dev] [PATCH i-g-t 1/5] lib/igt_audio: add basic audio_signal_detect tests
2019-05-29 13:32 [igt-dev] [PATCH i-g-t 0/5] Add igt_audio self-tests and check for noise/pops Simon Ser
@ 2019-05-29 13:32 ` Simon Ser
2019-06-03 13:43 ` Martin Peres
2019-05-29 13:32 ` [igt-dev] [PATCH i-g-t 2/5] lib/tests/igt_audio: add test with missing frequency Simon Ser
` (5 subsequent siblings)
6 siblings, 1 reply; 14+ messages in thread
From: Simon Ser @ 2019-05-29 13:32 UTC (permalink / raw)
To: igt-dev; +Cc: martin.peres
This adds three basic library tests for igt_audio's audio_signal_detect: one
that checks that detection works with the generated signal unchanged, and two
that check that detection properly fails with a silent/noise input signal.
Signed-off-by: Simon Ser <simon.ser@intel.com>
---
lib/tests/igt_audio.c | 101 ++++++++++++++++++++++++++++++++++++++++++
lib/tests/meson.build | 7 +++
2 files changed, 108 insertions(+)
create mode 100644 lib/tests/igt_audio.c
diff --git a/lib/tests/igt_audio.c b/lib/tests/igt_audio.c
new file mode 100644
index 000000000000..0ca3a4342ad9
--- /dev/null
+++ b/lib/tests/igt_audio.c
@@ -0,0 +1,101 @@
+/*
+ * Copyright © 2019 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Author: Simon Ser <simon.ser@intel.com>
+ */
+
+#include "config.h"
+
+#include "igt_core.h"
+#include "igt_audio.h"
+
+#define SAMPLING_RATE 44100
+#define CHANNELS 1
+#define BUFFER_LEN 2048
+
+static void test_signal_detect_verbatim(struct audio_signal *signal)
+{
+ double buf[BUFFER_LEN];
+ bool ok;
+
+ audio_signal_fill(signal, buf, BUFFER_LEN / CHANNELS);
+ ok = audio_signal_detect(signal, SAMPLING_RATE, 0, buf, BUFFER_LEN);
+ igt_assert(ok);
+}
+
+static void test_signal_detect_silence(struct audio_signal *signal)
+{
+ double buf[BUFFER_LEN] = {0};
+ bool ok;
+
+ ok = audio_signal_detect(signal, SAMPLING_RATE, 0, buf, BUFFER_LEN);
+
+ igt_assert(!ok);
+}
+
+static void test_signal_detect_noise(struct audio_signal *signal)
+{
+ double buf[BUFFER_LEN];
+ bool ok;
+ size_t i;
+
+ for (i = 0; i < BUFFER_LEN; i++)
+ buf[i] = (double) (i % 10) / 10;
+
+ ok = audio_signal_detect(signal, SAMPLING_RATE, 0, buf, BUFFER_LEN);
+
+ igt_assert(!ok);
+}
+
+igt_main
+{
+ struct audio_signal *signal;
+ int ret;
+
+ igt_subtest_group {
+ igt_fixture {
+ signal = audio_signal_init(CHANNELS, SAMPLING_RATE);
+
+ ret = audio_signal_add_frequency(signal, 300, 0);
+ igt_assert(ret == 0);
+ ret = audio_signal_add_frequency(signal, 700, 0);
+ igt_assert(ret == 0);
+ ret = audio_signal_add_frequency(signal, 5000, 0);
+ igt_assert(ret == 0);
+
+ audio_signal_synthesize(signal);
+ }
+
+ igt_subtest("signal-detect-verbatim")
+ test_signal_detect_verbatim(signal);
+
+ igt_subtest("signal-detect-silence")
+ test_signal_detect_silence(signal);
+
+ igt_subtest("signal-detect-noise")
+ test_signal_detect_noise(signal);
+
+ igt_fixture {
+ audio_signal_fini(signal);
+ }
+ }
+}
diff --git a/lib/tests/meson.build b/lib/tests/meson.build
index 9950bd59c174..eb75cbd571b9 100644
--- a/lib/tests/meson.build
+++ b/lib/tests/meson.build
@@ -22,6 +22,13 @@ lib_fail_tests = [
'igt_timeout',
]
+lib_tests_deps = igt_deps
+
+if chamelium.found()
+ lib_deps += chamelium
+ lib_tests += 'igt_audio'
+endif
+
foreach lib_test : lib_tests
exec = executable(lib_test, lib_test + '.c', install : false,
dependencies : igt_deps)
--
2.21.0
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [igt-dev] [PATCH i-g-t 2/5] lib/tests/igt_audio: add test with missing frequency
2019-05-29 13:32 [igt-dev] [PATCH i-g-t 0/5] Add igt_audio self-tests and check for noise/pops Simon Ser
2019-05-29 13:32 ` [igt-dev] [PATCH i-g-t 1/5] lib/igt_audio: add basic audio_signal_detect tests Simon Ser
@ 2019-05-29 13:32 ` Simon Ser
2019-06-03 13:46 ` Martin Peres
2019-05-29 13:32 ` [igt-dev] [PATCH i-g-t 3/5] lib/tests/igt_audio: add test with an extra frequency Simon Ser
` (4 subsequent siblings)
6 siblings, 1 reply; 14+ messages in thread
From: Simon Ser @ 2019-05-29 13:32 UTC (permalink / raw)
To: igt-dev; +Cc: martin.peres
Make sure detection fails.
Signed-off-by: Simon Ser <simon.ser@intel.com>
---
lib/tests/igt_audio.c | 39 +++++++++++++++++++++++++++++++++------
1 file changed, 33 insertions(+), 6 deletions(-)
diff --git a/lib/tests/igt_audio.c b/lib/tests/igt_audio.c
index 0ca3a4342ad9..7b068c255973 100644
--- a/lib/tests/igt_audio.c
+++ b/lib/tests/igt_audio.c
@@ -32,6 +32,10 @@
#define CHANNELS 1
#define BUFFER_LEN 2048
+static const int test_freqs[] = { 300, 700, 5000 };
+
+static const size_t test_freqs_len = sizeof(test_freqs) / sizeof(test_freqs[0]);
+
static void test_signal_detect_verbatim(struct audio_signal *signal)
{
double buf[BUFFER_LEN];
@@ -66,21 +70,41 @@ static void test_signal_detect_noise(struct audio_signal *signal)
igt_assert(!ok);
}
+static void test_signal_detect_missing(struct audio_signal *signal)
+{
+ double buf[BUFFER_LEN];
+ struct audio_signal *missing;
+ bool ok;
+ size_t i;
+
+ /* Miss the first frequency */
+ missing = audio_signal_init(CHANNELS, SAMPLING_RATE);
+ for (i = 1; i < test_freqs_len; i++) {
+ audio_signal_add_frequency(missing, test_freqs[i], 0);
+ }
+ audio_signal_synthesize(missing);
+
+ audio_signal_fill(missing, buf, BUFFER_LEN / CHANNELS);
+ ok = audio_signal_detect(signal, SAMPLING_RATE, 0, buf, BUFFER_LEN);
+ igt_assert(!ok);
+}
+
igt_main
{
struct audio_signal *signal;
int ret;
+ size_t i;
igt_subtest_group {
igt_fixture {
signal = audio_signal_init(CHANNELS, SAMPLING_RATE);
- ret = audio_signal_add_frequency(signal, 300, 0);
- igt_assert(ret == 0);
- ret = audio_signal_add_frequency(signal, 700, 0);
- igt_assert(ret == 0);
- ret = audio_signal_add_frequency(signal, 5000, 0);
- igt_assert(ret == 0);
+ for (i = 0; i < test_freqs_len; i++) {
+ ret = audio_signal_add_frequency(signal,
+ test_freqs[i],
+ 0);
+ igt_assert(ret == 0);
+ }
audio_signal_synthesize(signal);
}
@@ -94,6 +118,9 @@ igt_main
igt_subtest("signal-detect-noise")
test_signal_detect_noise(signal);
+ igt_subtest("signal-detect-missing")
+ test_signal_detect_missing(signal);
+
igt_fixture {
audio_signal_fini(signal);
}
--
2.21.0
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [igt-dev] [PATCH i-g-t 3/5] lib/tests/igt_audio: add test with an extra frequency
2019-05-29 13:32 [igt-dev] [PATCH i-g-t 0/5] Add igt_audio self-tests and check for noise/pops Simon Ser
2019-05-29 13:32 ` [igt-dev] [PATCH i-g-t 1/5] lib/igt_audio: add basic audio_signal_detect tests Simon Ser
2019-05-29 13:32 ` [igt-dev] [PATCH i-g-t 2/5] lib/tests/igt_audio: add test with missing frequency Simon Ser
@ 2019-05-29 13:32 ` Simon Ser
2019-06-03 13:49 ` Martin Peres
2019-05-29 13:32 ` [igt-dev] [PATCH i-g-t 4/5] lib/igt_audio: detect noise and pops Simon Ser
` (3 subsequent siblings)
6 siblings, 1 reply; 14+ messages in thread
From: Simon Ser @ 2019-05-29 13:32 UTC (permalink / raw)
To: igt-dev; +Cc: martin.peres
Make sure it fails.
Signed-off-by: Simon Ser <simon.ser@intel.com>
---
lib/tests/igt_audio.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/lib/tests/igt_audio.c b/lib/tests/igt_audio.c
index 7b068c255973..0f1c39d93728 100644
--- a/lib/tests/igt_audio.c
+++ b/lib/tests/igt_audio.c
@@ -36,6 +36,8 @@ static const int test_freqs[] = { 300, 700, 5000 };
static const size_t test_freqs_len = sizeof(test_freqs) / sizeof(test_freqs[0]);
+#define TEST_EXTRA_FREQ 500
+
static void test_signal_detect_verbatim(struct audio_signal *signal)
{
double buf[BUFFER_LEN];
@@ -89,6 +91,26 @@ static void test_signal_detect_missing(struct audio_signal *signal)
igt_assert(!ok);
}
+static void test_signal_detect_extra(struct audio_signal *signal)
+{
+ double buf[BUFFER_LEN];
+ struct audio_signal *extra;
+ bool ok;
+ size_t i;
+
+ /* Add an extra, unexpected frequency */
+ extra = audio_signal_init(CHANNELS, SAMPLING_RATE);
+ for (i = 0; i < test_freqs_len; i++) {
+ audio_signal_add_frequency(extra, test_freqs[i], 0);
+ }
+ audio_signal_add_frequency(extra, TEST_EXTRA_FREQ, 0);
+ audio_signal_synthesize(extra);
+
+ audio_signal_fill(extra, buf, BUFFER_LEN / CHANNELS);
+ ok = audio_signal_detect(signal, SAMPLING_RATE, 0, buf, BUFFER_LEN);
+ igt_assert(!ok);
+}
+
igt_main
{
struct audio_signal *signal;
@@ -121,6 +143,9 @@ igt_main
igt_subtest("signal-detect-missing")
test_signal_detect_missing(signal);
+ igt_subtest("signal-detect-extra")
+ test_signal_detect_extra(signal);
+
igt_fixture {
audio_signal_fini(signal);
}
--
2.21.0
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [igt-dev] [PATCH i-g-t 4/5] lib/igt_audio: detect noise and pops
2019-05-29 13:32 [igt-dev] [PATCH i-g-t 0/5] Add igt_audio self-tests and check for noise/pops Simon Ser
` (2 preceding siblings ...)
2019-05-29 13:32 ` [igt-dev] [PATCH i-g-t 3/5] lib/tests/igt_audio: add test with an extra frequency Simon Ser
@ 2019-05-29 13:32 ` Simon Ser
2019-06-03 14:11 ` Martin Peres
2019-05-29 13:32 ` [igt-dev] [PATCH i-g-t 5/5] lib/tests/igt_audio: add a pop test Simon Ser
` (2 subsequent siblings)
6 siblings, 1 reply; 14+ messages in thread
From: Simon Ser @ 2019-05-29 13:32 UTC (permalink / raw)
To: igt-dev; +Cc: martin.peres
First, normalize the bin power by dividing it by the number of input samples.
We need to multiply by 2 since we get half as many bins as input samples.
Second, check that low frequencies are under a given threshold. If there is a
pop or some noise, the low frequencies will be affected.
Signed-off-by: Simon Ser <simon.ser@intel.com>
---
lib/igt_audio.c | 44 +++++++++++++++++++++++++++++++++++++++-----
1 file changed, 39 insertions(+), 5 deletions(-)
diff --git a/lib/igt_audio.c b/lib/igt_audio.c
index 08c0fb6af0db..423615427a4d 100644
--- a/lib/igt_audio.c
+++ b/lib/igt_audio.c
@@ -39,6 +39,8 @@
#define CHANNELS_MAX 8
#define SYNTHESIZE_AMPLITUDE 0.9
#define SYNTHESIZE_ACCURACY 0.2
+#define MIN_FREQ 200 /* Hz */
+#define NOISE_THRESHOLD 0.0005
/**
* SECTION:igt_audio
@@ -108,6 +110,7 @@ int audio_signal_add_frequency(struct audio_signal *signal, int frequency,
igt_assert(index < FREQS_MAX);
igt_assert(channel < signal->channels);
+ igt_assert(frequency >= MIN_FREQ);
/* Stay within the Nyquist–Shannon sampling theorem. */
if (frequency > signal->sampling_rate / 2) {
@@ -304,6 +307,12 @@ void audio_signal_fill(struct audio_signal *signal, double *buffer,
audio_sanity_check(buffer, signal->channels * samples);
}
+/* See https://en.wikipedia.org/wiki/Window_function#Hann_and_Hamming_windows */
+static double hann_window(double v, size_t i, size_t N)
+{
+ return v * 0.5 * (1 - cos(2.0 * M_PI * (double) i / (double) N));
+}
+
/**
* Checks that frequencies specified in signal, and only those, are included
* in the input data.
@@ -328,6 +337,11 @@ bool audio_signal_detect(struct audio_signal *signal, int sampling_rate,
data = malloc(samples_len * sizeof(double));
memcpy(data, samples, samples_len * sizeof(double));
+ /* Apply a Hann window to the input signal, to reduce frequency leaks
+ * due to the endpoints of the signal being discontinuous. */
+ for (i = 0; i < data_len; i++)
+ data[i] = hann_window(data[i], i, data_len);
+
/* Allowed error in Hz due to FFT step */
freq_accuracy = sampling_rate / data_len;
igt_debug("Allowed freq. error: %d Hz\n", freq_accuracy);
@@ -338,8 +352,7 @@ bool audio_signal_detect(struct audio_signal *signal, int sampling_rate,
igt_assert(0);
}
- /* Compute the power received by every bin of the FFT, and record the
- * maximum power received as a way to normalize all the others.
+ /* Compute the power received by every bin of the FFT.
*
* For i < data_len / 2, the real part of the i-th term is stored at
* data[i] and its imaginary part is stored at data[data_len - i].
@@ -349,15 +362,36 @@ bool audio_signal_detect(struct audio_signal *signal, int sampling_rate,
* The power is encoded as the magnitude of the complex number and the
* phase is encoded as its angle.
*/
- max = 0;
bin_power[0] = data[0];
for (i = 1; i < bin_power_len - 1; i++) {
bin_power[i] = hypot(data[i], data[data_len - i]);
- if (bin_power[i] > max)
- max = bin_power[i];
}
bin_power[bin_power_len - 1] = data[data_len / 2];
+ /* Normalize the power */
+ for (i = 0; i < bin_power_len; i++)
+ bin_power[i] = 2 * bin_power[i] / data_len;
+
+ /* Detect noise with a threshold on the power of low frequencies */
+ for (i = 0; i < bin_power_len; i++) {
+ freq = sampling_rate * i / data_len;
+ if (freq > MIN_FREQ - 100)
+ break;
+ if (bin_power[i] > NOISE_THRESHOLD) {
+ igt_debug("Noise level too high: freq=%d power=%f\n",
+ freq, bin_power[i]);
+ return false;
+ }
+ }
+
+ /* Record the maximum power received as a way to normalize all the
+ * others. */
+ max = NAN;
+ for (i = 0; i < bin_power_len; i++) {
+ if (isnan(max) || bin_power[i] > max)
+ max = bin_power[i];
+ }
+
for (i = 0; i < signal->freqs_count; i++)
detected[i] = false;
--
2.21.0
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [igt-dev] [PATCH i-g-t 5/5] lib/tests/igt_audio: add a pop test
2019-05-29 13:32 [igt-dev] [PATCH i-g-t 0/5] Add igt_audio self-tests and check for noise/pops Simon Ser
` (3 preceding siblings ...)
2019-05-29 13:32 ` [igt-dev] [PATCH i-g-t 4/5] lib/igt_audio: detect noise and pops Simon Ser
@ 2019-05-29 13:32 ` Simon Ser
2019-06-03 14:14 ` Martin Peres
2019-05-29 14:44 ` [igt-dev] ✓ Fi.CI.BAT: success for Add igt_audio self-tests and check for noise/pops Patchwork
2019-05-29 22:22 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
6 siblings, 1 reply; 14+ messages in thread
From: Simon Ser @ 2019-05-29 13:32 UTC (permalink / raw)
To: igt-dev; +Cc: martin.peres
Make sure adding a pop in the input signal makes audio_signal_detect fail.
Signed-off-by: Simon Ser <simon.ser@intel.com>
---
lib/tests/igt_audio.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/lib/tests/igt_audio.c b/lib/tests/igt_audio.c
index 0f1c39d93728..214dcea73efc 100644
--- a/lib/tests/igt_audio.c
+++ b/lib/tests/igt_audio.c
@@ -111,6 +111,26 @@ static void test_signal_detect_extra(struct audio_signal *signal)
igt_assert(!ok);
}
+static void test_signal_detect_pop(struct audio_signal *signal)
+{
+ double *buf;
+ bool ok;
+ size_t i;
+
+ buf = malloc(BUFFER_LEN * sizeof(double));
+ audio_signal_fill(signal, buf, BUFFER_LEN / CHANNELS);
+
+ /* Add a discontinuity in the signal */
+ for (i = 0; i < 5; i++)
+ buf[BUFFER_LEN / 3 + i] = 0.9;
+
+ ok = audio_signal_detect(signal, SAMPLING_RATE, 0, buf, BUFFER_LEN);
+
+ free(buf);
+
+ igt_assert(!ok);
+}
+
igt_main
{
struct audio_signal *signal;
@@ -146,6 +166,9 @@ igt_main
igt_subtest("signal-detect-extra")
test_signal_detect_extra(signal);
+ igt_subtest("signal-detect-pop")
+ test_signal_detect_pop(signal);
+
igt_fixture {
audio_signal_fini(signal);
}
--
2.21.0
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [igt-dev] ✓ Fi.CI.BAT: success for Add igt_audio self-tests and check for noise/pops
2019-05-29 13:32 [igt-dev] [PATCH i-g-t 0/5] Add igt_audio self-tests and check for noise/pops Simon Ser
` (4 preceding siblings ...)
2019-05-29 13:32 ` [igt-dev] [PATCH i-g-t 5/5] lib/tests/igt_audio: add a pop test Simon Ser
@ 2019-05-29 14:44 ` Patchwork
2019-05-29 22:22 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
6 siblings, 0 replies; 14+ messages in thread
From: Patchwork @ 2019-05-29 14:44 UTC (permalink / raw)
To: Simon Ser; +Cc: igt-dev
== Series Details ==
Series: Add igt_audio self-tests and check for noise/pops
URL : https://patchwork.freedesktop.org/series/61328/
State : success
== Summary ==
CI Bug Log - changes from CI_DRM_6162 -> IGTPW_3075
====================================================
Summary
-------
**SUCCESS**
No regressions found.
External URL: https://patchwork.freedesktop.org/api/1.0/series/61328/revisions/1/mbox/
Known issues
------------
Here are the changes found in IGTPW_3075 that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@amdgpu/amd_basic@userptr:
- fi-kbl-8809g: [PASS][1] -> [DMESG-WARN][2] ([fdo#108965])
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6162/fi-kbl-8809g/igt@amdgpu/amd_basic@userptr.html
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3075/fi-kbl-8809g/igt@amdgpu/amd_basic@userptr.html
* igt@i915_selftest@live_contexts:
- fi-bdw-gvtdvm: [PASS][3] -> [DMESG-FAIL][4] ([fdo#110235])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6162/fi-bdw-gvtdvm/igt@i915_selftest@live_contexts.html
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3075/fi-bdw-gvtdvm/igt@i915_selftest@live_contexts.html
* igt@kms_pipe_crc_basic@suspend-read-crc-pipe-a:
- fi-blb-e6850: [PASS][5] -> [INCOMPLETE][6] ([fdo#107718])
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6162/fi-blb-e6850/igt@kms_pipe_crc_basic@suspend-read-crc-pipe-a.html
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3075/fi-blb-e6850/igt@kms_pipe_crc_basic@suspend-read-crc-pipe-a.html
#### Possible fixes ####
* igt@kms_chamelium@dp-edid-read:
- fi-kbl-7500u: [FAIL][7] ([fdo#109483] / [fdo#109635 ]) -> [PASS][8]
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6162/fi-kbl-7500u/igt@kms_chamelium@dp-edid-read.html
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3075/fi-kbl-7500u/igt@kms_chamelium@dp-edid-read.html
[fdo#107718]: https://bugs.freedesktop.org/show_bug.cgi?id=107718
[fdo#108965]: https://bugs.freedesktop.org/show_bug.cgi?id=108965
[fdo#109483]: https://bugs.freedesktop.org/show_bug.cgi?id=109483
[fdo#109635 ]: https://bugs.freedesktop.org/show_bug.cgi?id=109635
[fdo#110235]: https://bugs.freedesktop.org/show_bug.cgi?id=110235
Participating hosts (45 -> 40)
------------------------------
Missing (5): fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-byt-clapper fi-bdw-samus
Build changes
-------------
* IGT: IGT_5024 -> IGTPW_3075
CI_DRM_6162: d35e150f090fed2b37052ace606850ed7780c34d @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_3075: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3075/
IGT_5024: f414756be2ac57e194919973da7b86644ba61241 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3075/
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply [flat|nested] 14+ messages in thread
* [igt-dev] ✓ Fi.CI.IGT: success for Add igt_audio self-tests and check for noise/pops
2019-05-29 13:32 [igt-dev] [PATCH i-g-t 0/5] Add igt_audio self-tests and check for noise/pops Simon Ser
` (5 preceding siblings ...)
2019-05-29 14:44 ` [igt-dev] ✓ Fi.CI.BAT: success for Add igt_audio self-tests and check for noise/pops Patchwork
@ 2019-05-29 22:22 ` Patchwork
6 siblings, 0 replies; 14+ messages in thread
From: Patchwork @ 2019-05-29 22:22 UTC (permalink / raw)
To: Simon Ser; +Cc: igt-dev
== Series Details ==
Series: Add igt_audio self-tests and check for noise/pops
URL : https://patchwork.freedesktop.org/series/61328/
State : success
== Summary ==
CI Bug Log - changes from CI_DRM_6162_full -> IGTPW_3075_full
====================================================
Summary
-------
**SUCCESS**
No regressions found.
External URL: https://patchwork.freedesktop.org/api/1.0/series/61328/revisions/1/mbox/
Known issues
------------
Here are the changes found in IGTPW_3075_full that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@i915_pm_rc6_residency@rc6-accuracy:
- shard-kbl: [PASS][1] -> [SKIP][2] ([fdo#109271])
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6162/shard-kbl3/igt@i915_pm_rc6_residency@rc6-accuracy.html
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3075/shard-kbl2/igt@i915_pm_rc6_residency@rc6-accuracy.html
- shard-snb: [PASS][3] -> [SKIP][4] ([fdo#109271])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6162/shard-snb2/igt@i915_pm_rc6_residency@rc6-accuracy.html
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3075/shard-snb6/igt@i915_pm_rc6_residency@rc6-accuracy.html
* igt@i915_suspend@fence-restore-tiled2untiled:
- shard-apl: [PASS][5] -> [DMESG-WARN][6] ([fdo#108566]) +1 similar issue
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6162/shard-apl5/igt@i915_suspend@fence-restore-tiled2untiled.html
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3075/shard-apl6/igt@i915_suspend@fence-restore-tiled2untiled.html
* igt@kms_flip@2x-flip-vs-panning-interruptible:
- shard-glk: [PASS][7] -> [INCOMPLETE][8] ([fdo#103359] / [k.org#198133])
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6162/shard-glk8/igt@kms_flip@2x-flip-vs-panning-interruptible.html
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3075/shard-glk9/igt@kms_flip@2x-flip-vs-panning-interruptible.html
* igt@kms_flip@2x-plain-flip-ts-check-interruptible:
- shard-hsw: [PASS][9] -> [SKIP][10] ([fdo#109271]) +10 similar issues
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6162/shard-hsw5/igt@kms_flip@2x-plain-flip-ts-check-interruptible.html
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3075/shard-hsw1/igt@kms_flip@2x-plain-flip-ts-check-interruptible.html
* igt@kms_setmode@basic:
- shard-kbl: [PASS][11] -> [FAIL][12] ([fdo#99912])
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6162/shard-kbl3/igt@kms_setmode@basic.html
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3075/shard-kbl3/igt@kms_setmode@basic.html
#### Possible fixes ####
* igt@gem_ctx_isolation@rcs0-s3:
- shard-apl: [DMESG-WARN][13] ([fdo#108566]) -> [PASS][14] +7 similar issues
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6162/shard-apl3/igt@gem_ctx_isolation@rcs0-s3.html
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3075/shard-apl6/igt@gem_ctx_isolation@rcs0-s3.html
* igt@kms_flip@2x-plain-flip-interruptible:
- shard-hsw: [SKIP][15] ([fdo#109271]) -> [PASS][16] +25 similar issues
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6162/shard-hsw1/igt@kms_flip@2x-plain-flip-interruptible.html
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3075/shard-hsw6/igt@kms_flip@2x-plain-flip-interruptible.html
* igt@kms_setmode@basic:
- shard-hsw: [FAIL][17] ([fdo#99912]) -> [PASS][18]
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6162/shard-hsw4/igt@kms_setmode@basic.html
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3075/shard-hsw1/igt@kms_setmode@basic.html
[fdo#103359]: https://bugs.freedesktop.org/show_bug.cgi?id=103359
[fdo#108566]: https://bugs.freedesktop.org/show_bug.cgi?id=108566
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#99912]: https://bugs.freedesktop.org/show_bug.cgi?id=99912
[k.org#198133]: https://bugzilla.kernel.org/show_bug.cgi?id=198133
Participating hosts (9 -> 5)
------------------------------
Missing (4): pig-skl-6260u shard-skl pig-hsw-4770r pig-glk-j5005
Build changes
-------------
* IGT: IGT_5024 -> IGTPW_3075
* Piglit: piglit_4509 -> None
CI_DRM_6162: d35e150f090fed2b37052ace606850ed7780c34d @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_3075: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3075/
IGT_5024: f414756be2ac57e194919973da7b86644ba61241 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_3075/
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [igt-dev] [PATCH i-g-t 1/5] lib/igt_audio: add basic audio_signal_detect tests
2019-05-29 13:32 ` [igt-dev] [PATCH i-g-t 1/5] lib/igt_audio: add basic audio_signal_detect tests Simon Ser
@ 2019-06-03 13:43 ` Martin Peres
2019-06-04 8:00 ` Ser, Simon
0 siblings, 1 reply; 14+ messages in thread
From: Martin Peres @ 2019-06-03 13:43 UTC (permalink / raw)
To: Simon Ser, igt-dev; +Cc: martin.peres
On 29/05/2019 16:32, Simon Ser wrote:
> This adds three basic library tests for igt_audio's audio_signal_detect: one
> that checks that detection works with the generated signal unchanged, and two
> that check that detection properly fails with a silent/noise input signal.
>
> Signed-off-by: Simon Ser <simon.ser@intel.com>
> ---
> lib/tests/igt_audio.c | 101 ++++++++++++++++++++++++++++++++++++++++++
> lib/tests/meson.build | 7 +++
> 2 files changed, 108 insertions(+)
> create mode 100644 lib/tests/igt_audio.c
>
> diff --git a/lib/tests/igt_audio.c b/lib/tests/igt_audio.c
> new file mode 100644
> index 000000000000..0ca3a4342ad9
> --- /dev/null
> +++ b/lib/tests/igt_audio.c
> @@ -0,0 +1,101 @@
> +/*
> + * Copyright © 2019 Intel Corporation
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice (including the next
> + * paragraph) shall be included in all copies or substantial portions of the
> + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
> + * IN THE SOFTWARE.
> + *
> + * Author: Simon Ser <simon.ser@intel.com>
> + */
> +
> +#include "config.h"
> +
> +#include "igt_core.h"
> +#include "igt_audio.h"
> +
> +#define SAMPLING_RATE 44100
> +#define CHANNELS 1
> +#define BUFFER_LEN 2048
> +
> +static void test_signal_detect_verbatim(struct audio_signal *signal)
test_signal_detect_untampered would be more understandable.
> +{
> + double buf[BUFFER_LEN];
> + bool ok;
> +
> + audio_signal_fill(signal, buf, BUFFER_LEN / CHANNELS);
> + ok = audio_signal_detect(signal, SAMPLING_RATE, 0, buf, BUFFER_LEN);
> + igt_assert(ok);
> +}
> +
> +static void test_signal_detect_silence(struct audio_signal *signal)
> +{
> + double buf[BUFFER_LEN] = {0};
> + bool ok;
> +
> + ok = audio_signal_detect(signal, SAMPLING_RATE, 0, buf, BUFFER_LEN);
> +
> + igt_assert(!ok);
> +}
> +
> +static void test_signal_detect_noise(struct audio_signal *signal)
> +{
> + double buf[BUFFER_LEN];
> + bool ok;
> + size_t i;
> +
> + for (i = 0; i < BUFFER_LEN; i++)
> + buf[i] = (double) (i % 10) / 10;
This creates a period signal with a frequency of 4.410kHz... so this is
not exactly noise.
We probably want to do:
srandom(42);
for (i = 0; i < BUFFER_LEN; i++)
buf[i] = ((double) random()) / RAND_MAX;
This will create a less periodic signal, and still be repeatable (not
sure if the random algorithm is allowed to changed between libc versions).
With the proposed changes:
Reviewed-by: Martin Peres <martin.peres@linux.intel.com>
> +
> + ok = audio_signal_detect(signal, SAMPLING_RATE, 0, buf, BUFFER_LEN);
> +
> + igt_assert(!ok);
> +}
> +
> +igt_main
> +{
> + struct audio_signal *signal;
> + int ret;
> +
> + igt_subtest_group {
> + igt_fixture {
> + signal = audio_signal_init(CHANNELS, SAMPLING_RATE);
> +
> + ret = audio_signal_add_frequency(signal, 300, 0);
> + igt_assert(ret == 0);
> + ret = audio_signal_add_frequency(signal, 700, 0);
> + igt_assert(ret == 0);
> + ret = audio_signal_add_frequency(signal, 5000, 0);
> + igt_assert(ret == 0);
> +
> + audio_signal_synthesize(signal);
> + }
> +
> + igt_subtest("signal-detect-verbatim")
> + test_signal_detect_verbatim(signal);
> +
> + igt_subtest("signal-detect-silence")
> + test_signal_detect_silence(signal);
> +
> + igt_subtest("signal-detect-noise")
> + test_signal_detect_noise(signal);
> +
> + igt_fixture {
> + audio_signal_fini(signal);
> + }
> + }
> +}
> diff --git a/lib/tests/meson.build b/lib/tests/meson.build
> index 9950bd59c174..eb75cbd571b9 100644
> --- a/lib/tests/meson.build
> +++ b/lib/tests/meson.build
> @@ -22,6 +22,13 @@ lib_fail_tests = [
> 'igt_timeout',
> ]
>
> +lib_tests_deps = igt_deps
> +
> +if chamelium.found()
> + lib_deps += chamelium
> + lib_tests += 'igt_audio'
> +endif
> +
> foreach lib_test : lib_tests
> exec = executable(lib_test, lib_test + '.c', install : false,
> dependencies : igt_deps)
>
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [igt-dev] [PATCH i-g-t 2/5] lib/tests/igt_audio: add test with missing frequency
2019-05-29 13:32 ` [igt-dev] [PATCH i-g-t 2/5] lib/tests/igt_audio: add test with missing frequency Simon Ser
@ 2019-06-03 13:46 ` Martin Peres
0 siblings, 0 replies; 14+ messages in thread
From: Martin Peres @ 2019-06-03 13:46 UTC (permalink / raw)
To: Simon Ser, igt-dev; +Cc: martin.peres
On 29/05/2019 16:32, Simon Ser wrote:
> Make sure detection fails.
>
> Signed-off-by: Simon Ser <simon.ser@intel.com>
> ---
> lib/tests/igt_audio.c | 39 +++++++++++++++++++++++++++++++++------
> 1 file changed, 33 insertions(+), 6 deletions(-)
>
> diff --git a/lib/tests/igt_audio.c b/lib/tests/igt_audio.c
> index 0ca3a4342ad9..7b068c255973 100644
> --- a/lib/tests/igt_audio.c
> +++ b/lib/tests/igt_audio.c
> @@ -32,6 +32,10 @@
> #define CHANNELS 1
> #define BUFFER_LEN 2048
>
> +static const int test_freqs[] = { 300, 700, 5000 };
> +
> +static const size_t test_freqs_len = sizeof(test_freqs) / sizeof(test_freqs[0]);
> +
> static void test_signal_detect_verbatim(struct audio_signal *signal)
> {
> double buf[BUFFER_LEN];
> @@ -66,21 +70,41 @@ static void test_signal_detect_noise(struct audio_signal *signal)
> igt_assert(!ok);
> }
>
> +static void test_signal_detect_missing(struct audio_signal *signal)
> +{
> + double buf[BUFFER_LEN];
> + struct audio_signal *missing;
> + bool ok;
> + size_t i;
> +
> + /* Miss the first frequency */
/* Generate a signal with all the expected frequencies but the first one */
With the comment updated, this is:
Reviewed-by: Martin Peres <martin.peres@linux.intel.com>
> + missing = audio_signal_init(CHANNELS, SAMPLING_RATE);
> + for (i = 1; i < test_freqs_len; i++) {
> + audio_signal_add_frequency(missing, test_freqs[i], 0);
> + }
> + audio_signal_synthesize(missing);
> +
> + audio_signal_fill(missing, buf, BUFFER_LEN / CHANNELS);
> + ok = audio_signal_detect(signal, SAMPLING_RATE, 0, buf, BUFFER_LEN);
> + igt_assert(!ok);
> +}
> +
> igt_main
> {
> struct audio_signal *signal;
> int ret;
> + size_t i;
>
> igt_subtest_group {
> igt_fixture {
> signal = audio_signal_init(CHANNELS, SAMPLING_RATE);
>
> - ret = audio_signal_add_frequency(signal, 300, 0);
> - igt_assert(ret == 0);
> - ret = audio_signal_add_frequency(signal, 700, 0);
> - igt_assert(ret == 0);
> - ret = audio_signal_add_frequency(signal, 5000, 0);
> - igt_assert(ret == 0);
> + for (i = 0; i < test_freqs_len; i++) {
> + ret = audio_signal_add_frequency(signal,
> + test_freqs[i],
> + 0);
> + igt_assert(ret == 0);
> + }
>
> audio_signal_synthesize(signal);
> }
> @@ -94,6 +118,9 @@ igt_main
> igt_subtest("signal-detect-noise")
> test_signal_detect_noise(signal);
>
> + igt_subtest("signal-detect-missing")
> + test_signal_detect_missing(signal);
> +
> igt_fixture {
> audio_signal_fini(signal);
> }
>
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [igt-dev] [PATCH i-g-t 3/5] lib/tests/igt_audio: add test with an extra frequency
2019-05-29 13:32 ` [igt-dev] [PATCH i-g-t 3/5] lib/tests/igt_audio: add test with an extra frequency Simon Ser
@ 2019-06-03 13:49 ` Martin Peres
0 siblings, 0 replies; 14+ messages in thread
From: Martin Peres @ 2019-06-03 13:49 UTC (permalink / raw)
To: Simon Ser, igt-dev; +Cc: martin.peres
On 29/05/2019 16:32, Simon Ser wrote:
> Make sure it fails.
>
> Signed-off-by: Simon Ser <simon.ser@intel.com>
> ---
> lib/tests/igt_audio.c | 25 +++++++++++++++++++++++++
> 1 file changed, 25 insertions(+)
>
> diff --git a/lib/tests/igt_audio.c b/lib/tests/igt_audio.c
> index 7b068c255973..0f1c39d93728 100644
> --- a/lib/tests/igt_audio.c
> +++ b/lib/tests/igt_audio.c
> @@ -36,6 +36,8 @@ static const int test_freqs[] = { 300, 700, 5000 };
>
> static const size_t test_freqs_len = sizeof(test_freqs) / sizeof(test_freqs[0]);
>
> +#define TEST_EXTRA_FREQ 500
> +
> static void test_signal_detect_verbatim(struct audio_signal *signal)
> {
> double buf[BUFFER_LEN];
> @@ -89,6 +91,26 @@ static void test_signal_detect_missing(struct audio_signal *signal)
> igt_assert(!ok);
> }
>
> +static void test_signal_detect_extra(struct audio_signal *signal)
test_signal_detect_with_unexpected_frequency()
> +{
> + double buf[BUFFER_LEN];
> + struct audio_signal *extra;
> + bool ok;
> + size_t i;
> +
> + /* Add an extra, unexpected frequency */
> + extra = audio_signal_init(CHANNELS, SAMPLING_RATE);
> + for (i = 0; i < test_freqs_len; i++) {
> + audio_signal_add_frequency(extra, test_freqs[i], 0);
> + }
> + audio_signal_add_frequency(extra, TEST_EXTRA_FREQ, 0);
> + audio_signal_synthesize(extra);
> +
> + audio_signal_fill(extra, buf, BUFFER_LEN / CHANNELS);
> + ok = audio_signal_detect(signal, SAMPLING_RATE, 0, buf, BUFFER_LEN);
> + igt_assert(!ok);
> +}
> +
> igt_main
> {
> struct audio_signal *signal;
> @@ -121,6 +143,9 @@ igt_main
> igt_subtest("signal-detect-missing")
Sorry, I forgot to check the name during the review of the previous
patch. Would be better-named: test_signal_detect_with_missing_frequency
With the subtest names changed:
Reviewed-by: Martin Peres <martin.peres@linux.intel.com>
> test_signal_detect_missing(signal);
>
> + igt_subtest("signal-detect-extra")
> + test_signal_detect_extra(signal);
> +
> igt_fixture {
> audio_signal_fini(signal);
> }
>
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [igt-dev] [PATCH i-g-t 4/5] lib/igt_audio: detect noise and pops
2019-05-29 13:32 ` [igt-dev] [PATCH i-g-t 4/5] lib/igt_audio: detect noise and pops Simon Ser
@ 2019-06-03 14:11 ` Martin Peres
0 siblings, 0 replies; 14+ messages in thread
From: Martin Peres @ 2019-06-03 14:11 UTC (permalink / raw)
To: Simon Ser, igt-dev; +Cc: martin.peres
On 29/05/2019 16:32, Simon Ser wrote:
> First, normalize the bin power by dividing it by the number of input samples.
> We need to multiply by 2 since we get half as many bins as input samples.
>
> Second, check that low frequencies are under a given threshold. If there is a
> pop or some noise, the low frequencies will be affected.
>
> Signed-off-by: Simon Ser <simon.ser@intel.com>
> ---
> lib/igt_audio.c | 44 +++++++++++++++++++++++++++++++++++++++-----
> 1 file changed, 39 insertions(+), 5 deletions(-)
>
> diff --git a/lib/igt_audio.c b/lib/igt_audio.c
> index 08c0fb6af0db..423615427a4d 100644
> --- a/lib/igt_audio.c
> +++ b/lib/igt_audio.c
> @@ -39,6 +39,8 @@
> #define CHANNELS_MAX 8
> #define SYNTHESIZE_AMPLITUDE 0.9
> #define SYNTHESIZE_ACCURACY 0.2
> +#define MIN_FREQ 200 /* Hz */
Add a comment to say it should at least be 100 Hz + one bin size. Best
is not touch this value.
> +#define NOISE_THRESHOLD 0.0005
How did you come up with this threshold?
Would be nice to get it as low as possible!
>
> /**
> * SECTION:igt_audio
> @@ -108,6 +110,7 @@ int audio_signal_add_frequency(struct audio_signal *signal, int frequency,
>
> igt_assert(index < FREQS_MAX);
> igt_assert(channel < signal->channels);
> + igt_assert(frequency >= MIN_FREQ);
Cool check!
>
> /* Stay within the Nyquist–Shannon sampling theorem. */
> if (frequency > signal->sampling_rate / 2) {
> @@ -304,6 +307,12 @@ void audio_signal_fill(struct audio_signal *signal, double *buffer,
> audio_sanity_check(buffer, signal->channels * samples);
> }
>
> +/* See https://en.wikipedia.org/wiki/Window_function#Hann_and_Hamming_windows */
> +static double hann_window(double v, size_t i, size_t N)
> +{
> + return v * 0.5 * (1 - cos(2.0 * M_PI * (double) i / (double) N));
> +}
Won't review that :D
> +
> /**
> * Checks that frequencies specified in signal, and only those, are included
> * in the input data.
> @@ -328,6 +337,11 @@ bool audio_signal_detect(struct audio_signal *signal, int sampling_rate,
> data = malloc(samples_len * sizeof(double));
> memcpy(data, samples, samples_len * sizeof(double));
>
> + /* Apply a Hann window to the input signal, to reduce frequency leaks
> + * due to the endpoints of the signal being discontinuous. */
Please add "See https://en.wikipedia.org/wiki/Window_function."
> + for (i = 0; i < data_len; i++)
> + data[i] = hann_window(data[i], i, data_len);
> +
> /* Allowed error in Hz due to FFT step */
> freq_accuracy = sampling_rate / data_len;
> igt_debug("Allowed freq. error: %d Hz\n", freq_accuracy);
> @@ -338,8 +352,7 @@ bool audio_signal_detect(struct audio_signal *signal, int sampling_rate,
> igt_assert(0);
> }
>
> - /* Compute the power received by every bin of the FFT, and record the
> - * maximum power received as a way to normalize all the others.
> + /* Compute the power received by every bin of the FFT.
> *
> * For i < data_len / 2, the real part of the i-th term is stored at
> * data[i] and its imaginary part is stored at data[data_len - i].
> @@ -349,15 +362,36 @@ bool audio_signal_detect(struct audio_signal *signal, int sampling_rate,
> * The power is encoded as the magnitude of the complex number and the
> * phase is encoded as its angle.
> */
> - max = 0;
> bin_power[0] = data[0];
> for (i = 1; i < bin_power_len - 1; i++) {
> bin_power[i] = hypot(data[i], data[data_len - i]);
> - if (bin_power[i] > max)
> - max = bin_power[i];
> }
> bin_power[bin_power_len - 1] = data[data_len / 2];
>
> + /* Normalize the power */
> + for (i = 0; i < bin_power_len; i++)
> + bin_power[i] = 2 * bin_power[i] / data_len;
> +
> + /* Detect noise with a threshold on the power of low frequencies */> + for (i = 0; i < bin_power_len; i++) {
> + freq = sampling_rate * i / data_len;
> + if (freq > MIN_FREQ - 100)
> + break;
> + if (bin_power[i] > NOISE_THRESHOLD) {
> + igt_debug("Noise level too high: freq=%d power=%f\n",
> + freq, bin_power[i]);
> + return false;
> + }
> + }
> +
> + /* Record the maximum power received as a way to normalize all the
> + * others. */
> + max = NAN;
> + for (i = 0; i < bin_power_len; i++) {
> + if (isnan(max) || bin_power[i] > max)
> + max = bin_power[i];
> + }
> +
> for (i = 0; i < signal->freqs_count; i++)
> detected[i] = false;
>
>
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [igt-dev] [PATCH i-g-t 5/5] lib/tests/igt_audio: add a pop test
2019-05-29 13:32 ` [igt-dev] [PATCH i-g-t 5/5] lib/tests/igt_audio: add a pop test Simon Ser
@ 2019-06-03 14:14 ` Martin Peres
0 siblings, 0 replies; 14+ messages in thread
From: Martin Peres @ 2019-06-03 14:14 UTC (permalink / raw)
To: Simon Ser, igt-dev; +Cc: martin.peres
On 29/05/2019 16:32, Simon Ser wrote:
> Make sure adding a pop in the input signal makes audio_signal_detect fail.
>
> Signed-off-by: Simon Ser <simon.ser@intel.com>
> ---
> lib/tests/igt_audio.c | 23 +++++++++++++++++++++++
> 1 file changed, 23 insertions(+)
>
> diff --git a/lib/tests/igt_audio.c b/lib/tests/igt_audio.c
> index 0f1c39d93728..214dcea73efc 100644
> --- a/lib/tests/igt_audio.c
> +++ b/lib/tests/igt_audio.c
> @@ -111,6 +111,26 @@ static void test_signal_detect_extra(struct audio_signal *signal)
> igt_assert(!ok);
> }
>
> +static void test_signal_detect_pop(struct audio_signal *signal)
> +{
> + double *buf;
> + bool ok;
> + size_t i;
> +
> + buf = malloc(BUFFER_LEN * sizeof(double));
> + audio_signal_fill(signal, buf, BUFFER_LEN / CHANNELS);
> +
> + /* Add a discontinuity in the signal */
> + for (i = 0; i < 5; i++)
> + buf[BUFFER_LEN / 3 + i] = 0.9;
Would be nice to check both for a held value (no updates for some
samples then continuing the signal as expected) and a phase shift.
Could you check both in two different tests? That would increase our
confidence in our methodology!
I'll review 4 and 5 again when this is done :)
> +
> + ok = audio_signal_detect(signal, SAMPLING_RATE, 0, buf, BUFFER_LEN);
> +
> + free(buf);
> +
> + igt_assert(!ok);
> +}
> +
> igt_main
> {
> struct audio_signal *signal;
> @@ -146,6 +166,9 @@ igt_main
> igt_subtest("signal-detect-extra")
> test_signal_detect_extra(signal);
>
> + igt_subtest("signal-detect-pop")
> + test_signal_detect_pop(signal);
> +
> igt_fixture {
> audio_signal_fini(signal);
> }
>
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [igt-dev] [PATCH i-g-t 1/5] lib/igt_audio: add basic audio_signal_detect tests
2019-06-03 13:43 ` Martin Peres
@ 2019-06-04 8:00 ` Ser, Simon
0 siblings, 0 replies; 14+ messages in thread
From: Ser, Simon @ 2019-06-04 8:00 UTC (permalink / raw)
To: igt-dev, martin.peres; +Cc: Peres, Martin
On Mon, 2019-06-03 at 16:43 +0300, Martin Peres wrote:
> On 29/05/2019 16:32, Simon Ser wrote:
> > This adds three basic library tests for igt_audio's audio_signal_detect: one
> > that checks that detection works with the generated signal unchanged, and two
> > that check that detection properly fails with a silent/noise input signal.
> >
> > Signed-off-by: Simon Ser <simon.ser@intel.com>
> > ---
> > lib/tests/igt_audio.c | 101 ++++++++++++++++++++++++++++++++++++++++++
> > lib/tests/meson.build | 7 +++
> > 2 files changed, 108 insertions(+)
> > create mode 100644 lib/tests/igt_audio.c
> >
> > diff --git a/lib/tests/igt_audio.c b/lib/tests/igt_audio.c
> > new file mode 100644
> > index 000000000000..0ca3a4342ad9
> > --- /dev/null
> > +++ b/lib/tests/igt_audio.c
> > @@ -0,0 +1,101 @@
> > +/*
> > + * Copyright © 2019 Intel Corporation
> > + *
> > + * Permission is hereby granted, free of charge, to any person obtaining a
> > + * copy of this software and associated documentation files (the "Software"),
> > + * to deal in the Software without restriction, including without limitation
> > + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> > + * and/or sell copies of the Software, and to permit persons to whom the
> > + * Software is furnished to do so, subject to the following conditions:
> > + *
> > + * The above copyright notice and this permission notice (including the next
> > + * paragraph) shall be included in all copies or substantial portions of the
> > + * Software.
> > + *
> > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
> > + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> > + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
> > + * IN THE SOFTWARE.
> > + *
> > + * Author: Simon Ser <simon.ser@intel.com>
> > + */
> > +
> > +#include "config.h"
> > +
> > +#include "igt_core.h"
> > +#include "igt_audio.h"
> > +
> > +#define SAMPLING_RATE 44100
> > +#define CHANNELS 1
> > +#define BUFFER_LEN 2048
> > +
> > +static void test_signal_detect_verbatim(struct audio_signal *signal)
>
> test_signal_detect_untampered would be more understandable.
>
> > +{
> > + double buf[BUFFER_LEN];
> > + bool ok;
> > +
> > + audio_signal_fill(signal, buf, BUFFER_LEN / CHANNELS);
> > + ok = audio_signal_detect(signal, SAMPLING_RATE, 0, buf, BUFFER_LEN);
> > + igt_assert(ok);
> > +}
> > +
> > +static void test_signal_detect_silence(struct audio_signal *signal)
> > +{
> > + double buf[BUFFER_LEN] = {0};
> > + bool ok;
> > +
> > + ok = audio_signal_detect(signal, SAMPLING_RATE, 0, buf, BUFFER_LEN);
> > +
> > + igt_assert(!ok);
> > +}
> > +
> > +static void test_signal_detect_noise(struct audio_signal *signal)
> > +{
> > + double buf[BUFFER_LEN];
> > + bool ok;
> > + size_t i;
> > +
> > + for (i = 0; i < BUFFER_LEN; i++)
> > + buf[i] = (double) (i % 10) / 10;
>
> This creates a period signal with a frequency of 4.410kHz... so this is
> not exactly noise.
>
> We probably want to do:
>
> srandom(42);
> for (i = 0; i < BUFFER_LEN; i++)
> buf[i] = ((double) random()) / RAND_MAX;
>
> This will create a less periodic signal, and still be repeatable (not
> sure if the random algorithm is allowed to changed between libc versions).
Indeed.
I chose to use this slightly modified formula:
(double) random() / RAND_MAX * 2 - 1
So that samples are generated between -1 and 1.
> With the proposed changes:
>
> Reviewed-by: Martin Peres <martin.peres@linux.intel.com>
>
> > +
> > + ok = audio_signal_detect(signal, SAMPLING_RATE, 0, buf, BUFFER_LEN);
> > +
> > + igt_assert(!ok);
> > +}
> > +
> > +igt_main
> > +{
> > + struct audio_signal *signal;
> > + int ret;
> > +
> > + igt_subtest_group {
> > + igt_fixture {
> > + signal = audio_signal_init(CHANNELS, SAMPLING_RATE);
> > +
> > + ret = audio_signal_add_frequency(signal, 300, 0);
> > + igt_assert(ret == 0);
> > + ret = audio_signal_add_frequency(signal, 700, 0);
> > + igt_assert(ret == 0);
> > + ret = audio_signal_add_frequency(signal, 5000, 0);
> > + igt_assert(ret == 0);
> > +
> > + audio_signal_synthesize(signal);
> > + }
> > +
> > + igt_subtest("signal-detect-verbatim")
> > + test_signal_detect_verbatim(signal);
> > +
> > + igt_subtest("signal-detect-silence")
> > + test_signal_detect_silence(signal);
> > +
> > + igt_subtest("signal-detect-noise")
> > + test_signal_detect_noise(signal);
> > +
> > + igt_fixture {
> > + audio_signal_fini(signal);
> > + }
> > + }
> > +}
> > diff --git a/lib/tests/meson.build b/lib/tests/meson.build
> > index 9950bd59c174..eb75cbd571b9 100644
> > --- a/lib/tests/meson.build
> > +++ b/lib/tests/meson.build
> > @@ -22,6 +22,13 @@ lib_fail_tests = [
> > 'igt_timeout',
> > ]
> >
> > +lib_tests_deps = igt_deps
> > +
> > +if chamelium.found()
> > + lib_deps += chamelium
> > + lib_tests += 'igt_audio'
> > +endif
> > +
> > foreach lib_test : lib_tests
> > exec = executable(lib_test, lib_test + '.c', install : false,
> > dependencies : igt_deps)
> >
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2019-06-04 8:01 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-29 13:32 [igt-dev] [PATCH i-g-t 0/5] Add igt_audio self-tests and check for noise/pops Simon Ser
2019-05-29 13:32 ` [igt-dev] [PATCH i-g-t 1/5] lib/igt_audio: add basic audio_signal_detect tests Simon Ser
2019-06-03 13:43 ` Martin Peres
2019-06-04 8:00 ` Ser, Simon
2019-05-29 13:32 ` [igt-dev] [PATCH i-g-t 2/5] lib/tests/igt_audio: add test with missing frequency Simon Ser
2019-06-03 13:46 ` Martin Peres
2019-05-29 13:32 ` [igt-dev] [PATCH i-g-t 3/5] lib/tests/igt_audio: add test with an extra frequency Simon Ser
2019-06-03 13:49 ` Martin Peres
2019-05-29 13:32 ` [igt-dev] [PATCH i-g-t 4/5] lib/igt_audio: detect noise and pops Simon Ser
2019-06-03 14:11 ` Martin Peres
2019-05-29 13:32 ` [igt-dev] [PATCH i-g-t 5/5] lib/tests/igt_audio: add a pop test Simon Ser
2019-06-03 14:14 ` Martin Peres
2019-05-29 14:44 ` [igt-dev] ✓ Fi.CI.BAT: success for Add igt_audio self-tests and check for noise/pops Patchwork
2019-05-29 22:22 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.