media: vidtv: fix build on 32bit architectures
Fix the following error for builds on 32bit architectures:
ERROR: modpost: "__udivdi3"
[drivers/media/test-drivers/vidtv/dvb-vidtv-bridge.ko] undefined!
Which is due to 64bit divisions that did not go through the helpers
in linux/math64.h
As vidtv_mux_check_mux_rate was not operational in its current form,
drop the entire function while it is not fixed properly.
For now, call vidtv_mux_pad_with_nulls with a constant number of packets
to avoid warnings due to unused functions when building this driver.
The 64bit division used in the s302m is not needed, remove them and use
a fixed number of frames and a constant PTS increment instead.
Fixes: f90cf6079b
("media: vidtv: add a bridge driver")
Signed-off-by: Daniel W. S. Almeida <dwlsalmeida@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
This commit is contained in:
parent
c5d83ba23e
commit
37b288f54b
|
@ -148,7 +148,7 @@ struct vidtv_encoder {
|
||||||
|
|
||||||
__be16 es_pid;
|
__be16 es_pid;
|
||||||
|
|
||||||
void *(*encode)(struct vidtv_encoder *e, u64 elapsed_time_usecs);
|
void *(*encode)(struct vidtv_encoder *e);
|
||||||
|
|
||||||
u32 (*clear)(struct vidtv_encoder *e);
|
u32 (*clear)(struct vidtv_encoder *e);
|
||||||
|
|
||||||
|
|
|
@ -281,17 +281,11 @@ static u32 vidtv_mux_poll_encoders(struct vidtv_mux *m)
|
||||||
struct vidtv_channel *cur_chnl = m->channels;
|
struct vidtv_channel *cur_chnl = m->channels;
|
||||||
struct vidtv_encoder *e = NULL;
|
struct vidtv_encoder *e = NULL;
|
||||||
|
|
||||||
u64 elapsed_time_usecs = jiffies_to_usecs(m->timing.current_jiffies -
|
|
||||||
m->timing.past_jiffies);
|
|
||||||
|
|
||||||
elapsed_time_usecs = min_t(u64, elapsed_time_usecs, (u64)VIDTV_MAX_SLEEP_USECS);
|
|
||||||
|
|
||||||
while (cur_chnl) {
|
while (cur_chnl) {
|
||||||
e = cur_chnl->encoders;
|
e = cur_chnl->encoders;
|
||||||
|
|
||||||
while (e) {
|
while (e) {
|
||||||
/* encode for 'elapsed_time_usecs' */
|
e->encode(e);
|
||||||
e->encode(e, elapsed_time_usecs);
|
|
||||||
/* get the TS packets into the mux buffer */
|
/* get the TS packets into the mux buffer */
|
||||||
au_nbytes = vidtv_mux_packetize_access_units(m, e);
|
au_nbytes = vidtv_mux_packetize_access_units(m, e);
|
||||||
nbytes += au_nbytes;
|
nbytes += au_nbytes;
|
||||||
|
@ -337,38 +331,6 @@ static u32 vidtv_mux_pad_with_nulls(struct vidtv_mux *m, u32 npkts)
|
||||||
return nbytes;
|
return nbytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
static u32 vidtv_mux_check_mux_rate(struct vidtv_mux *m)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* attempt to maintain a constant mux rate, padding with null packets
|
|
||||||
* if needed
|
|
||||||
*/
|
|
||||||
|
|
||||||
u32 nbytes = 0; /* the number of bytes written by this function */
|
|
||||||
|
|
||||||
u64 nbytes_expected; /* the number of bytes we should have written */
|
|
||||||
u64 nbytes_streamed; /* the number of bytes we actually wrote */
|
|
||||||
u32 num_null_pkts; /* number of null packets to bridge the gap */
|
|
||||||
|
|
||||||
u64 elapsed_time_msecs = jiffies_to_usecs(m->timing.current_jiffies -
|
|
||||||
m->timing.past_jiffies);
|
|
||||||
|
|
||||||
elapsed_time_msecs = min(elapsed_time_msecs, (u64)VIDTV_MAX_SLEEP_USECS / 1000);
|
|
||||||
nbytes_expected = div64_u64(m->mux_rate_kbytes_sec * 1000, MSEC_PER_SEC);
|
|
||||||
nbytes_expected *= elapsed_time_msecs;
|
|
||||||
|
|
||||||
nbytes_streamed = m->mux_buf_offset;
|
|
||||||
|
|
||||||
if (nbytes_streamed < nbytes_expected) {
|
|
||||||
/* can't write half a packet: roundup to a 188 multiple */
|
|
||||||
nbytes_expected = roundup(nbytes_expected - nbytes_streamed, TS_PACKET_LEN);
|
|
||||||
num_null_pkts = nbytes_expected / TS_PACKET_LEN;
|
|
||||||
nbytes += vidtv_mux_pad_with_nulls(m, num_null_pkts);
|
|
||||||
}
|
|
||||||
|
|
||||||
return nbytes;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void vidtv_mux_clear(struct vidtv_mux *m)
|
static void vidtv_mux_clear(struct vidtv_mux *m)
|
||||||
{
|
{
|
||||||
/* clear the packets currently in the mux */
|
/* clear the packets currently in the mux */
|
||||||
|
@ -400,7 +362,7 @@ static void vidtv_mux_tick(struct work_struct *work)
|
||||||
nbytes += vidtv_mux_push_si(m);
|
nbytes += vidtv_mux_push_si(m);
|
||||||
|
|
||||||
nbytes += vidtv_mux_poll_encoders(m);
|
nbytes += vidtv_mux_poll_encoders(m);
|
||||||
nbytes += vidtv_mux_check_mux_rate(m);
|
nbytes += vidtv_mux_pad_with_nulls(m, 256);
|
||||||
|
|
||||||
npkts = nbytes / TS_PACKET_LEN;
|
npkts = nbytes / TS_PACKET_LEN;
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,11 @@
|
||||||
#define S302M_BLOCK_SZ 192
|
#define S302M_BLOCK_SZ 192
|
||||||
#define S302M_SIN_LUT_NUM_ELEM 1024
|
#define S302M_SIN_LUT_NUM_ELEM 1024
|
||||||
|
|
||||||
|
/* these are retrieved empirically from ffmpeg/libavcodec */
|
||||||
|
#define FF_S302M_DEFAULT_NUM_FRAMES 1115
|
||||||
|
#define FF_S302M_DEFAULT_PTS_INCREMENT 2090
|
||||||
|
#define FF_S302M_DEFAULT_PTS_OFFSET 100000
|
||||||
|
|
||||||
/* Used by the tone generator: number of samples for PI */
|
/* Used by the tone generator: number of samples for PI */
|
||||||
#define PI 180
|
#define PI 180
|
||||||
|
|
||||||
|
@ -189,7 +194,7 @@ static void vidtv_s302m_alloc_au(struct vidtv_encoder *e)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vidtv_s302m_compute_sample_count_v(struct vidtv_encoder *e)
|
vidtv_s302m_compute_sample_count_from_video(struct vidtv_encoder *e)
|
||||||
{
|
{
|
||||||
struct vidtv_access_unit *au = e->access_units;
|
struct vidtv_access_unit *au = e->access_units;
|
||||||
struct vidtv_access_unit *sync_au = e->sync->access_units;
|
struct vidtv_access_unit *sync_au = e->sync->access_units;
|
||||||
|
@ -208,33 +213,7 @@ vidtv_s302m_compute_sample_count_v(struct vidtv_encoder *e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void vidtv_s302m_compute_pts_from_video(struct vidtv_encoder *e)
|
||||||
vidtv_s302m_compute_sample_count(struct vidtv_encoder *e,
|
|
||||||
u64 elapsed_time_usecs)
|
|
||||||
{
|
|
||||||
/* compute sample count for 'elapsed_time_usecs' */
|
|
||||||
u32 sample_duration_usecs = USEC_PER_SEC / e->sampling_rate_hz;
|
|
||||||
struct vidtv_access_unit *au = e->access_units;
|
|
||||||
|
|
||||||
au->num_samples = (u32)div64_u64(elapsed_time_usecs, sample_duration_usecs);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void vidtv_s302m_compute_pts(struct vidtv_encoder *e)
|
|
||||||
{
|
|
||||||
u64 count = e->sample_count;
|
|
||||||
struct vidtv_access_unit *au = e->access_units;
|
|
||||||
|
|
||||||
while (au) {
|
|
||||||
count += au->num_samples;
|
|
||||||
|
|
||||||
au->pts = count *
|
|
||||||
CLOCK_UNIT_90KHZ / e->sampling_rate_hz;
|
|
||||||
|
|
||||||
au = au->next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void vidtv_s302m_compute_pts_v(struct vidtv_encoder *e)
|
|
||||||
{
|
{
|
||||||
struct vidtv_access_unit *au = e->access_units;
|
struct vidtv_access_unit *au = e->access_units;
|
||||||
struct vidtv_access_unit *sync_au = e->sync->access_units;
|
struct vidtv_access_unit *sync_au = e->sync->access_units;
|
||||||
|
@ -366,6 +345,7 @@ static u32 vidtv_s302m_write_h(struct vidtv_encoder *e, u32 p_sz)
|
||||||
static void vidtv_s302m_write_frames(struct vidtv_encoder *e)
|
static void vidtv_s302m_write_frames(struct vidtv_encoder *e)
|
||||||
{
|
{
|
||||||
struct vidtv_access_unit *au = e->access_units;
|
struct vidtv_access_unit *au = e->access_units;
|
||||||
|
struct vidtv_s302m_ctx *ctx = e->ctx;
|
||||||
u32 nbytes_per_unit = 0;
|
u32 nbytes_per_unit = 0;
|
||||||
u32 nbytes = 0;
|
u32 nbytes = 0;
|
||||||
u32 au_sz = 0;
|
u32 au_sz = 0;
|
||||||
|
@ -400,12 +380,13 @@ static void vidtv_s302m_write_frames(struct vidtv_encoder *e)
|
||||||
au->offset = nbytes - nbytes_per_unit;
|
au->offset = nbytes - nbytes_per_unit;
|
||||||
|
|
||||||
nbytes_per_unit = 0;
|
nbytes_per_unit = 0;
|
||||||
|
ctx->au_count++;
|
||||||
|
|
||||||
au = au->next;
|
au = au->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *vidtv_s302m_encode(struct vidtv_encoder *e, u64 elapsed_time)
|
static void *vidtv_s302m_encode(struct vidtv_encoder *e)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* According to SMPTE 302M, an audio access unit is specified as those
|
* According to SMPTE 302M, an audio access unit is specified as those
|
||||||
|
@ -416,27 +397,26 @@ static void *vidtv_s302m_encode(struct vidtv_encoder *e, u64 elapsed_time)
|
||||||
*
|
*
|
||||||
* Assuming that it is also possible to send audio without any
|
* Assuming that it is also possible to send audio without any
|
||||||
* associated video, as in a radio-like service, a single audio access unit
|
* associated video, as in a radio-like service, a single audio access unit
|
||||||
* is created with enough audio data for 'elapsed_time'
|
* is created with values for 'num_samples' and 'pts' taken empirically from
|
||||||
* The value of PTS is computed manually.
|
* ffmpeg
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!elapsed_time)
|
struct vidtv_s302m_ctx *ctx = e->ctx;
|
||||||
goto out;
|
|
||||||
|
|
||||||
vidtv_s302m_access_unit_destroy(e);
|
vidtv_s302m_access_unit_destroy(e);
|
||||||
vidtv_s302m_alloc_au(e);
|
vidtv_s302m_alloc_au(e);
|
||||||
|
|
||||||
if (e->sync && e->sync->is_video_encoder) {
|
if (e->sync && e->sync->is_video_encoder) {
|
||||||
vidtv_s302m_compute_sample_count_v(e);
|
vidtv_s302m_compute_sample_count_from_video(e);
|
||||||
vidtv_s302m_compute_pts_v(e);
|
vidtv_s302m_compute_pts_from_video(e);
|
||||||
} else {
|
} else {
|
||||||
vidtv_s302m_compute_sample_count(e, elapsed_time);
|
e->access_units->num_samples = FF_S302M_DEFAULT_NUM_FRAMES;
|
||||||
vidtv_s302m_compute_pts(e);
|
e->access_units->pts = (ctx->au_count * FF_S302M_DEFAULT_PTS_INCREMENT) +
|
||||||
|
FF_S302M_DEFAULT_PTS_OFFSET;
|
||||||
}
|
}
|
||||||
|
|
||||||
vidtv_s302m_write_frames(e);
|
vidtv_s302m_write_frames(e);
|
||||||
|
|
||||||
out:
|
|
||||||
return e->encoder_buf;
|
return e->encoder_buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,10 +33,12 @@
|
||||||
* struct vidtv_s302m_ctx - s302m encoder context.
|
* struct vidtv_s302m_ctx - s302m encoder context.
|
||||||
* @enc: A pointer to the containing encoder structure.
|
* @enc: A pointer to the containing encoder structure.
|
||||||
* @frame_index: The current frame in a block
|
* @frame_index: The current frame in a block
|
||||||
|
* @au_count: The total number of access units encoded up to now
|
||||||
*/
|
*/
|
||||||
struct vidtv_s302m_ctx {
|
struct vidtv_s302m_ctx {
|
||||||
struct vidtv_encoder *enc;
|
struct vidtv_encoder *enc;
|
||||||
u32 frame_index;
|
u32 frame_index;
|
||||||
|
u32 au_count;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue