Skip to content

Commit ab6bad0

Browse files
committed
media: vidtv: fix the tone generator logic
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>
1 parent af66e03 commit ab6bad0

2 files changed

Lines changed: 5 additions & 11 deletions

File tree

drivers/media/test-drivers/vidtv/vidtv_s302m.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -253,18 +253,12 @@ static u16 vidtv_s302m_get_sample(struct vidtv_encoder *e)
253253
ctx->last_duration--;
254254
}
255255

256-
/* Handle silent */
257-
if (!ctx->last_tone) {
258-
e->src_buf_offset = 0;
256+
/* Handle pause notes */
257+
if (!ctx->last_tone)
259258
return 0x8000;
260-
}
261-
262-
pos = (2 * PI * ctx->note_offset * ctx->last_tone / S302M_SAMPLING_RATE_HZ);
263259

264-
if (pos == 360)
265-
ctx->note_offset = 0;
266-
else
267-
ctx->note_offset++;
260+
pos = (2 * PI * ctx->note_offset * ctx->last_tone) / S302M_SAMPLING_RATE_HZ;
261+
ctx->note_offset++;
268262

269263
return (fixp_sin32(pos % (2 * PI)) >> 16) + 0x8000;
270264
}

drivers/media/test-drivers/vidtv/vidtv_s302m.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ struct vidtv_s302m_ctx {
3939
u32 frame_index;
4040
u32 au_count;
4141
int last_duration;
42-
int note_offset;
42+
unsigned int note_offset;
4343
enum musical_notes last_tone;
4444
};
4545

0 commit comments

Comments
 (0)