All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Ser <simon.ser@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: martin.peres@intel.com
Subject: [igt-dev] [PATCH i-g-t 3/5] lib/igt_audio: add support for S24_LE and S32_LE signal generation
Date: Fri, 17 May 2019 19:02:40 +0300	[thread overview]
Message-ID: <20190517160242.28247-3-simon.ser@intel.com> (raw)
In-Reply-To: <20190517160242.28247-1-simon.ser@intel.com>

This adds two new helpers to generate S24_LE and S32_LE signals.

Signed-off-by: Simon Ser <simon.ser@intel.com>
---
 lib/igt_audio.c | 30 ++++++++++++++++++++++++++++++
 lib/igt_audio.h |  4 ++++
 2 files changed, 34 insertions(+)

diff --git a/lib/igt_audio.c b/lib/igt_audio.c
index 90d16fe4bd11..876084a994c3 100644
--- a/lib/igt_audio.c
+++ b/lib/igt_audio.c
@@ -262,6 +262,36 @@ void audio_signal_fill_s16_le(struct audio_signal *signal, int16_t *buffer,
 	free(tmp);
 }
 
+void audio_signal_fill_s24_le(struct audio_signal *signal, int32_t *buffer,
+			      size_t samples)
+{
+	double *tmp;
+	size_t i;
+
+	tmp = malloc(sizeof(double) * signal->channels * samples);
+	audio_signal_fill(signal, tmp, samples);
+
+	for (i = 0; i < signal->channels * samples; ++i)
+		buffer[i] = 0xFFFFFF * tmp[i];
+
+	free(tmp);
+}
+
+void audio_signal_fill_s32_le(struct audio_signal *signal, int32_t *buffer,
+			      size_t samples)
+{
+	double *tmp;
+	size_t i;
+
+	tmp = malloc(sizeof(double) * signal->channels * samples);
+	audio_signal_fill(signal, tmp, samples);
+
+	for (i = 0; i < signal->channels * samples; ++i)
+		buffer[i] = UINT32_MAX * tmp[i];
+
+	free(tmp);
+}
+
 /**
  * Checks that frequencies specified in signal, and only those, are included
  * in the input data.
diff --git a/lib/igt_audio.h b/lib/igt_audio.h
index f915d55d63fc..c8de70871faa 100644
--- a/lib/igt_audio.h
+++ b/lib/igt_audio.h
@@ -44,6 +44,10 @@ void audio_signal_fill(struct audio_signal *signal, double *buffer,
 		       size_t buffer_len);
 void audio_signal_fill_s16_le(struct audio_signal *signal, int16_t *buffer,
 			      size_t buffer_len);
+void audio_signal_fill_s24_le(struct audio_signal *signal, int32_t *buffer,
+			      size_t buffer_len);
+void audio_signal_fill_s32_le(struct audio_signal *signal, int32_t *buffer,
+			      size_t buffer_len);
 bool audio_signal_detect(struct audio_signal *signal, int sampling_rate,
 			 int channel, const double *samples, size_t samples_len);
 size_t audio_extract_channel_s32_le(double *dst, size_t dst_cap,
-- 
2.21.0

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

  parent reply	other threads:[~2019-05-17 16:02 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-17 16:02 [igt-dev] [PATCH i-g-t 1/5] lib/igt_alsa: support all alsa formats Simon Ser
2019-05-17 16:02 ` [igt-dev] [PATCH i-g-t 2/5] lib/igt_alsa: add format argument to alsa_test_output_configuration Simon Ser
2019-05-20 12:08   ` Martin Peres
2019-05-17 16:02 ` Simon Ser [this message]
2019-05-20 12:14   ` [igt-dev] [PATCH i-g-t 3/5] lib/igt_audio: add support for S24_LE and S32_LE signal generation Martin Peres
2019-05-20 13:08     ` Ser, Simon
2019-05-17 16:02 ` [igt-dev] [PATCH i-g-t 4/5] tests/kms_chamelium: add S24_LE and S32_LE audio tests Simon Ser
2019-05-20 12:20   ` Peres, Martin
2019-05-20 13:10     ` Ser, Simon
2019-05-20 13:43       ` Martin Peres
2019-05-17 16:02 ` [igt-dev] [PATCH i-g-t 5/5] tests/kms_chamelium: skip audio tests Chamelium doesn't support Simon Ser
2019-05-20 12:21   ` Peres, Martin
2019-05-20 13:12     ` Ser, Simon
2019-05-17 16:44 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/5] lib/igt_alsa: support all alsa formats Patchwork
2019-05-18  4:26 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2019-05-20 10:11 ` [igt-dev] [PATCH i-g-t 1/5] " Martin Peres
2019-05-20 10:38   ` Ser, Simon
2019-05-20 10:46     ` Martin Peres

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190517160242.28247-3-simon.ser@intel.com \
    --to=simon.ser@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=martin.peres@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.