Commit ef991797 authored by Andy Walls's avatar Andy Walls Committed by Mauro Carvalho Chehab

V4L/DVB (13907): cx18: Perform automatic rotation of very old, unread IDX buffers

According to the v4l2 spec, very old MPEG index entries needs to be discarded
in favor of newer index entries.  This change ensures the firmware always has
buffers for index entries at the expense of the oldest unread buffers.
Signed-off-by: default avatarAndy Walls <awalls@radix.net>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 79f3e960
...@@ -223,8 +223,11 @@ static void epu_dma_done(struct cx18 *cx, struct cx18_in_work_order *order) ...@@ -223,8 +223,11 @@ static void epu_dma_done(struct cx18 *cx, struct cx18_in_work_order *order)
CX18_DEBUG_HI_DMA("%s recv bytesused = %d\n", CX18_DEBUG_HI_DMA("%s recv bytesused = %d\n",
s->name, mdl->bytesused); s->name, mdl->bytesused);
if (s->type != CX18_ENC_STREAM_TYPE_TS) if (s->type != CX18_ENC_STREAM_TYPE_TS) {
cx18_enqueue(s, mdl, &s->q_full); cx18_enqueue(s, mdl, &s->q_full);
if (s->type == CX18_ENC_STREAM_TYPE_IDX)
cx18_stream_rotate_idx_mdls(cx);
}
else { else {
cx18_mdl_send_to_dvb(s, mdl); cx18_mdl_send_to_dvb(s, mdl);
cx18_enqueue(s, mdl, &s->q_free); cx18_enqueue(s, mdl, &s->q_free);
......
...@@ -463,6 +463,32 @@ static void cx18_vbi_setup(struct cx18_stream *s) ...@@ -463,6 +463,32 @@ static void cx18_vbi_setup(struct cx18_stream *s)
cx18_api(cx, CX18_CPU_SET_RAW_VBI_PARAM, 6, data); cx18_api(cx, CX18_CPU_SET_RAW_VBI_PARAM, 6, data);
} }
void cx18_stream_rotate_idx_mdls(struct cx18 *cx)
{
struct cx18_stream *s = &cx->streams[CX18_ENC_STREAM_TYPE_IDX];
struct cx18_mdl *mdl;
if (!cx18_stream_enabled(s))
return;
/* Return if the firmware is not running low on MDLs */
if ((atomic_read(&s->q_free.depth) + atomic_read(&s->q_busy.depth)) >=
CX18_ENC_STREAM_TYPE_IDX_FW_MDL_MIN)
return;
/* Return if there are no MDLs to rotate back to the firmware */
if (atomic_read(&s->q_full.depth) < 2)
return;
/*
* Take the oldest IDX MDL still holding data, and discard its index
* entries by scheduling the MDL to go back to the firmware
*/
mdl = cx18_dequeue(s, &s->q_full);
if (mdl != NULL)
cx18_enqueue(s, mdl, &s->q_free);
}
static static
struct cx18_queue *_cx18_stream_put_mdl_fw(struct cx18_stream *s, struct cx18_queue *_cx18_stream_put_mdl_fw(struct cx18_stream *s,
struct cx18_mdl *mdl) struct cx18_mdl *mdl)
......
...@@ -28,6 +28,9 @@ int cx18_streams_setup(struct cx18 *cx); ...@@ -28,6 +28,9 @@ int cx18_streams_setup(struct cx18 *cx);
int cx18_streams_register(struct cx18 *cx); int cx18_streams_register(struct cx18 *cx);
void cx18_streams_cleanup(struct cx18 *cx, int unregister); void cx18_streams_cleanup(struct cx18 *cx, int unregister);
#define CX18_ENC_STREAM_TYPE_IDX_FW_MDL_MIN (3)
void cx18_stream_rotate_idx_mdls(struct cx18 *cx);
static inline bool cx18_stream_enabled(struct cx18_stream *s) static inline bool cx18_stream_enabled(struct cx18_stream *s)
{ {
return s->video_dev || s->dvb.enabled || return s->video_dev || s->dvb.enabled ||
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment