]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
media: dvb-core: dmxdevfilter must always flush bufs
authorHans Verkuil <hverkuil@xs4all.nl>
Thu, 5 Jun 2025 06:57:35 +0000 (08:57 +0200)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Thu, 18 Dec 2025 10:14:56 +0000 (11:14 +0100)
Currently the buffers are being filled until full, which works fine
for the transport stream, but not when reading sections, those have
to be returned to userspace immediately, otherwise dvbv5-scan will
just wait forever.

Add a 'flush' argument to dvb_vb2_fill_buffer to indicate whether
the buffer must be flushed or wait until it is full.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/media/dvb-core/dmxdev.c
drivers/media/dvb-core/dvb_vb2.c
include/media/dvb_vb2.h

index 8c6f5aafda1d619a6f042f1f2abb1a7a158c5729..17184b367490442862b55d15b54af8fb67c0181e 100644 (file)
@@ -397,11 +397,11 @@ static int dvb_dmxdev_section_callback(const u8 *buffer1, size_t buffer1_len,
        if (dvb_vb2_is_streaming(&dmxdevfilter->vb2_ctx)) {
                ret = dvb_vb2_fill_buffer(&dmxdevfilter->vb2_ctx,
                                          buffer1, buffer1_len,
-                                         buffer_flags);
+                                         buffer_flags, true);
                if (ret == buffer1_len)
                        ret = dvb_vb2_fill_buffer(&dmxdevfilter->vb2_ctx,
                                                  buffer2, buffer2_len,
-                                                 buffer_flags);
+                                                 buffer_flags, true);
        } else {
                ret = dvb_dmxdev_buffer_write(&dmxdevfilter->buffer,
                                              buffer1, buffer1_len);
@@ -452,10 +452,10 @@ static int dvb_dmxdev_ts_callback(const u8 *buffer1, size_t buffer1_len,
 
        if (dvb_vb2_is_streaming(ctx)) {
                ret = dvb_vb2_fill_buffer(ctx, buffer1, buffer1_len,
-                                         buffer_flags);
+                                         buffer_flags, false);
                if (ret == buffer1_len)
                        ret = dvb_vb2_fill_buffer(ctx, buffer2, buffer2_len,
-                                                 buffer_flags);
+                                                 buffer_flags, false);
        } else {
                if (buffer->error) {
                        spin_unlock(&dmxdevfilter->dev->lock);
index 29edaaff7a5c9d6286b5cfa4762d40d7ca7190d8..7444bbc2f24d9b4d191eb93013b6a6881031d32e 100644 (file)
@@ -249,7 +249,8 @@ int dvb_vb2_is_streaming(struct dvb_vb2_ctx *ctx)
 
 int dvb_vb2_fill_buffer(struct dvb_vb2_ctx *ctx,
                        const unsigned char *src, int len,
-                       enum dmx_buffer_flags *buffer_flags)
+                       enum dmx_buffer_flags *buffer_flags,
+                       bool flush)
 {
        unsigned long flags = 0;
        void *vbuf = NULL;
@@ -306,7 +307,7 @@ int dvb_vb2_fill_buffer(struct dvb_vb2_ctx *ctx,
                }
        }
 
-       if (ctx->nonblocking && ctx->buf) {
+       if (flush && ctx->buf) {
                vb2_set_plane_payload(&ctx->buf->vb, 0, ll);
                vb2_buffer_done(&ctx->buf->vb, VB2_BUF_STATE_DONE);
                list_del(&ctx->buf->list);
index 8cb88452cd6c287ced6cea133419096ef1a22955..0fbbfc65157e648a5ce565126f9139cb9aef1c67 100644 (file)
@@ -124,7 +124,7 @@ static inline int dvb_vb2_release(struct dvb_vb2_ctx *ctx)
        return 0;
 };
 #define dvb_vb2_is_streaming(ctx) (0)
-#define dvb_vb2_fill_buffer(ctx, file, wait, flags) (0)
+#define dvb_vb2_fill_buffer(ctx, file, wait, flags, flush) (0)
 
 static inline __poll_t dvb_vb2_poll(struct dvb_vb2_ctx *ctx,
                                    struct file *file,
@@ -166,10 +166,12 @@ int dvb_vb2_is_streaming(struct dvb_vb2_ctx *ctx);
  * @buffer_flags:
  *             pointer to buffer flags as defined by &enum dmx_buffer_flags.
  *             can be NULL.
+ * @flush:     flush the buffer, even if it isn't full.
  */
 int dvb_vb2_fill_buffer(struct dvb_vb2_ctx *ctx,
                        const unsigned char *src, int len,
-                       enum dmx_buffer_flags *buffer_flags);
+                       enum dmx_buffer_flags *buffer_flags,
+                       bool flush);
 
 /**
  * dvb_vb2_poll - Wrapper to vb2_core_streamon() for Digital TV