From: "Daniel W. S. Almeida" <dwlsalmeida@gmail.com>
To: mchehab+huawei@kernel.org, r.verdejo@samsung.com, nicolas@ndufresne.ca
Cc: "Daniel W . S . Almeida" <dwlsalmeida@gmail.com>,
linux-media@vger.kernel.org, skhan@linuxfoundation.org,
linux-kernel-mentees@lists.linuxfoundation.org,
linux-kernel@vger.kernel.org
Subject: [PATCH WIP 5/6] media: vidtv: Move s302m specific fields into encoder context
Date: Tue, 29 Sep 2020 00:26:24 -0300 [thread overview]
Message-ID: <20200929032625.1548909-5-dwlsalmeida@gmail.com> (raw)
In-Reply-To: <20200929032625.1548909-1-dwlsalmeida@gmail.com>
From: Daniel W. S. Almeida <dwlsalmeida@gmail.com>
A few fields used only by the tone generator in the s302m encoder
are stored in struct vidtv_encoder. Move them into
struct vidtv_s302m_ctx instead. While we are at it: fix a
checkpatch warning for long lines.
Signed-off-by: Daniel W. S. Almeida <dwlsalmeida@gmail.com>
---
.../media/test-drivers/vidtv/vidtv_encoder.h | 3 --
.../media/test-drivers/vidtv/vidtv_s302m.c | 30 +++++++++++--------
.../media/test-drivers/vidtv/vidtv_s302m.h | 3 ++
3 files changed, 20 insertions(+), 16 deletions(-)
diff --git a/drivers/media/test-drivers/vidtv/vidtv_encoder.h b/drivers/media/test-drivers/vidtv/vidtv_encoder.h
index 65d81daef4c3..f742d566fbcb 100644
--- a/drivers/media/test-drivers/vidtv/vidtv_encoder.h
+++ b/drivers/media/test-drivers/vidtv/vidtv_encoder.h
@@ -131,9 +131,6 @@ struct vidtv_encoder {
u32 encoder_buf_offset;
u64 sample_count;
- int last_duration;
- int note_offset;
- enum musical_notes last_tone;
struct vidtv_access_unit *access_units;
diff --git a/drivers/media/test-drivers/vidtv/vidtv_s302m.c b/drivers/media/test-drivers/vidtv/vidtv_s302m.c
index 6e5e72ce90d0..f7afbda6335d 100644
--- a/drivers/media/test-drivers/vidtv/vidtv_s302m.c
+++ b/drivers/media/test-drivers/vidtv/vidtv_s302m.c
@@ -233,36 +233,38 @@ static u16 vidtv_s302m_get_sample(struct vidtv_encoder *e)
{
u16 sample;
int pos;
+ struct vidtv_s302m_ctx *ctx = e->ctx;
if (!e->src_buf) {
/*
* Simple tone generator: play the tones at the
* beethoven_5th_symphony array.
*/
- if (e->last_duration <= 0) {
+ if (ctx->last_duration <= 0) {
if (e->src_buf_offset >= ARRAY_SIZE(beethoven_5th_symphony))
e->src_buf_offset = 0;
- e->last_tone = beethoven_5th_symphony[e->src_buf_offset].note;
- e->last_duration = beethoven_5th_symphony[e->src_buf_offset].duration * S302M_SAMPLING_RATE_HZ / COMPASS / 5;
+ ctx->last_tone = beethoven_5th_symphony[e->src_buf_offset].note;
+ ctx->last_duration = beethoven_5th_symphony[e->src_buf_offset].duration *
+ S302M_SAMPLING_RATE_HZ / COMPASS / 5;
e->src_buf_offset++;
- e->note_offset = 0;
+ ctx->note_offset = 0;
} else {
- e->last_duration--;
+ ctx->last_duration--;
}
/* Handle silent */
- if (!e->last_tone) {
+ if (!ctx->last_tone) {
e->src_buf_offset = 0;
return 0x8000;
}
- pos = (2 * PI * e->note_offset * e->last_tone / S302M_SAMPLING_RATE_HZ);
+ pos = (2 * PI * ctx->note_offset * ctx->last_tone / S302M_SAMPLING_RATE_HZ);
if (pos == 360)
- e->note_offset = 0;
+ ctx->note_offset = 0;
else
- e->note_offset++;
+ ctx->note_offset++;
return (fixp_sin32(pos % (2 * PI)) >> 16) + 0x8000;
}
@@ -445,6 +447,10 @@ struct vidtv_encoder
{
struct vidtv_encoder *e;
u32 priv_sz = sizeof(struct vidtv_s302m_ctx);
+ struct vidtv_s302m_ctx *ctx = kzalloc(priv_sz, GFP_KERNEL);
+
+ if (!ctx)
+ return NULL;
e = kzalloc(sizeof(*e), GFP_KERNEL);
if (!e)
@@ -460,16 +466,14 @@ struct vidtv_encoder
e->encoder_buf_offset = 0;
e->sample_count = 0;
- e->last_duration = 0;
e->src_buf = (args.src_buf) ? args.src_buf : NULL;
e->src_buf_sz = (args.src_buf) ? args.src_buf_sz : 0;
e->src_buf_offset = 0;
e->is_video_encoder = false;
- e->ctx = kzalloc(priv_sz, GFP_KERNEL);
- if (!e->ctx)
- return NULL;
+ e->ctx = ctx;
+ ctx->last_duration = 0;
e->encode = vidtv_s302m_encode;
e->clear = vidtv_s302m_clear;
diff --git a/drivers/media/test-drivers/vidtv/vidtv_s302m.h b/drivers/media/test-drivers/vidtv/vidtv_s302m.h
index eafe457e761d..a0101734e758 100644
--- a/drivers/media/test-drivers/vidtv/vidtv_s302m.h
+++ b/drivers/media/test-drivers/vidtv/vidtv_s302m.h
@@ -38,6 +38,9 @@ struct vidtv_s302m_ctx {
struct vidtv_encoder *enc;
u32 frame_index;
u32 au_count;
+ int last_duration;
+ int note_offset;
+ enum musical_notes last_tone;
};
/**
--
2.28.0
next prev parent reply other threads:[~2020-09-29 3:26 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-29 3:26 [PATCH WIP 1/6] media: vidtv: extract the initial CRC value to into a #define Daniel W. S. Almeida
2020-09-29 3:26 ` [PATCH WIP 2/6] media: vidtv: psi: add a Network Information Table (NIT) Daniel W. S. Almeida
2020-09-29 3:26 ` [PATCH WIP 3/6] media: vidtv: psi: Implement an Event Information Table (EIT) Daniel W. S. Almeida
2020-09-29 3:26 ` [PATCH WIP 4/6] media: vidtv: psi: extract descriptor chaining code into a helper Daniel W. S. Almeida
2020-09-29 3:26 ` Daniel W. S. Almeida [this message]
2020-09-29 3:26 ` [PATCH WIP 6/6] media: vidtv: psi: fix missing assignments in while loops Daniel W. S. Almeida
2020-09-29 5:19 ` [PATCH WIP 1/6] media: vidtv: extract the initial CRC value to into a #define Mauro Carvalho Chehab
2020-09-29 9:30 ` Daniel W. S. Almeida
2020-09-29 14:51 ` 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=20200929032625.1548909-5-dwlsalmeida@gmail.com \
--to=dwlsalmeida@gmail.com \
--cc=linux-kernel-mentees@lists.linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab+huawei@kernel.org \
--cc=nicolas@ndufresne.ca \
--cc=r.verdejo@samsung.com \
--cc=skhan@linuxfoundation.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
all inboxes | Powered by JetHome®