linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
To: unlisted-recipients:; (no To-header on input)
Cc: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>,
	"Daniel W. S. Almeida" <dwlsalmeida@gmail.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	linux-kernel@vger.kernel.org, linux-media@vger.kernel.org
Subject: [PATCH 05/31] media: vidtv: fix the tone generator logic
Date: Tue, 24 Nov 2020 12:06:01 +0100	[thread overview]
Message-ID: <4421cda35fe8d3d80687f27030108b9dcdc924d1.1606215584.git.mchehab+huawei@kernel.org> (raw)
In-Reply-To: <cover.1606215584.git.mchehab+huawei@kernel.org>

The tone generator logic were repeating the song after the
first silent. There's also a wrong logic at the note
offset calculus, which may create some noise.

Fix it.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 drivers/media/test-drivers/vidtv/vidtv_s302m.c | 14 ++++----------
 drivers/media/test-drivers/vidtv/vidtv_s302m.h |  2 +-
 2 files changed, 5 insertions(+), 11 deletions(-)

diff --git a/drivers/media/test-drivers/vidtv/vidtv_s302m.c b/drivers/media/test-drivers/vidtv/vidtv_s302m.c
index cbf89530aafe..fdb3d649c516 100644
--- a/drivers/media/test-drivers/vidtv/vidtv_s302m.c
+++ b/drivers/media/test-drivers/vidtv/vidtv_s302m.c
@@ -253,18 +253,12 @@ static u16 vidtv_s302m_get_sample(struct vidtv_encoder *e)
 			ctx->last_duration--;
 		}
 
-		/* Handle silent */
-		if (!ctx->last_tone) {
-			e->src_buf_offset = 0;
+		/* Handle pause notes */
+		if (!ctx->last_tone)
 			return 0x8000;
-		}
 
-		pos = (2 * PI * ctx->note_offset * ctx->last_tone / S302M_SAMPLING_RATE_HZ);
-
-		if (pos == 360)
-			ctx->note_offset = 0;
-		else
-			ctx->note_offset++;
+		pos = (2 * PI * ctx->note_offset * ctx->last_tone) / S302M_SAMPLING_RATE_HZ;
+		ctx->note_offset++;
 
 		return (fixp_sin32(pos % (2 * PI)) >> 16) + 0x8000;
 	}
diff --git a/drivers/media/test-drivers/vidtv/vidtv_s302m.h b/drivers/media/test-drivers/vidtv/vidtv_s302m.h
index a0101734e758..e990b755bb20 100644
--- a/drivers/media/test-drivers/vidtv/vidtv_s302m.h
+++ b/drivers/media/test-drivers/vidtv/vidtv_s302m.h
@@ -39,7 +39,7 @@ struct vidtv_s302m_ctx {
 	u32 frame_index;
 	u32 au_count;
 	int last_duration;
-	int note_offset;
+	unsigned int note_offset;
 	enum musical_notes last_tone;
 };
 
-- 
2.28.0


  parent reply	other threads:[~2020-11-24 11:08 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-24 11:05 [PATCH 00/31] vidtv: address several issues at the driver Mauro Carvalho Chehab
2020-11-24 11:05 ` [PATCH 01/31] media: vidtv: reorganize includes Mauro Carvalho Chehab
2020-11-24 11:05 ` [PATCH 02/31] media: vidtv: add error checks Mauro Carvalho Chehab
2020-11-24 11:05 ` [PATCH 03/31] media: vidtv: don't use recursive functions Mauro Carvalho Chehab
2020-11-24 11:06 ` [PATCH 04/31] media: vidtv: fix the name of the program Mauro Carvalho Chehab
2020-11-24 11:06 ` Mauro Carvalho Chehab [this message]
2020-11-24 11:06 ` [PATCH 06/31] media: vidtv: fix some notes at the tone generator Mauro Carvalho Chehab
2020-11-24 11:06 ` [PATCH 07/31] media: vidtv: avoid data copy when initializing the multiplexer Mauro Carvalho Chehab
2020-11-24 11:06 ` [PATCH 08/31] media: vidtv: avoid copying data for PES structs Mauro Carvalho Chehab
2020-11-24 11:06 ` [PATCH 09/31] media: vidtv: do some cleanups at the driver Mauro Carvalho Chehab
2020-11-24 11:06 ` [PATCH 10/31] media: vidtv: remove some unused functions Mauro Carvalho Chehab
2020-11-24 11:06 ` [PATCH 11/31] media: vidtv: pre-initialize mux arrays Mauro Carvalho Chehab
2020-11-24 11:06 ` [PATCH 12/31] media: vidtv: cleanup null packet initialization logic Mauro Carvalho Chehab
2020-11-24 11:06 ` [PATCH 13/31] media: vidtv: improve EIT data Mauro Carvalho Chehab
2020-11-24 11:06 ` [PATCH 14/31] media: vidtv: fix the network ID range Mauro Carvalho Chehab
2020-11-24 11:06 ` [PATCH 15/31] media: vidtv: properly fill EIT service_id Mauro Carvalho Chehab
2020-11-24 11:06 ` [PATCH 16/31] media: vidtv: add a PID entry for the NIT table Mauro Carvalho Chehab
2020-11-24 11:06 ` [PATCH 17/31] media: vidtv: fix service type Mauro Carvalho Chehab
2020-11-24 11:06 ` [PATCH 18/31] media: vidtv: fix service_id at SDT table Mauro Carvalho Chehab
2020-11-24 11:06 ` [PATCH 19/31] media: vidtv: add date to the current event Mauro Carvalho Chehab
2020-11-24 11:06 ` [PATCH 20/31] media: vidtv: simplify PSI write function Mauro Carvalho Chehab
2020-11-24 11:06 ` [PATCH 21/31] media: vidtv: simplify the crc writing logic Mauro Carvalho Chehab
2020-11-24 11:06 ` [PATCH 22/31] media: vidtv: cleanup PSI descriptor write function Mauro Carvalho Chehab
2020-11-24 11:06 ` [PATCH 23/31] media: vidtv: cleanup PSI table header function Mauro Carvalho Chehab
2020-11-24 11:06 ` [PATCH 24/31] media: vidtv: cleanup PAT write function Mauro Carvalho Chehab
2020-11-24 11:06 ` [PATCH 25/31] media: vidtv: cleanup PMT write table function Mauro Carvalho Chehab
2020-11-24 11:06 ` [PATCH 26/31] media: vidtv: simplify SDT write function Mauro Carvalho Chehab
2020-11-24 11:06 ` [PATCH 27/31] media: vidtv: simplify NIT " Mauro Carvalho Chehab
2020-11-24 11:06 ` [PATCH 28/31] media: vidtv: simplify EIT " Mauro Carvalho Chehab
2020-11-24 11:06 ` [PATCH 29/31] media: vidtv.rst: update vidtv documentation Mauro Carvalho Chehab
2020-11-24 11:06 ` [PATCH 30/31] media: vidtv.rst: add kernel-doc markups Mauro Carvalho Chehab
2020-11-24 11:06 ` [PATCH 31/31] media: vidtv: cleanup a few coding style issues Mauro Carvalho Chehab

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=4421cda35fe8d3d80687f27030108b9dcdc924d1.1606215584.git.mchehab+huawei@kernel.org \
    --to=mchehab+huawei@kernel.org \
    --cc=dwlsalmeida@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).