Hello everybody,

I would like to introduce a new uAPI for DVB streaming I/O.
Current DVB framework uses ringbuffer mechanism to demux MPEG-2 TS data
and pass it to userspace. However, this mechanism requires extra memory copy
because DVB framework provides only read() system call, which copies the kernel
data in ringbuffer to user-space buffer.
New uAPIs can remove the memory copy by using videobuf2 framework (a.k.a VB2)
which supports ioctl() calls related to streaming I/O, including buffer
allocation and queue management.

In this patch series, I have tried to implement DVB streaming I/O without
breaking existing legacy interfaces and cover all functionalities of
read() system call with new ioctl() calls.
The user scenario is very similar to v4l2's, but belows are different.

1. Support only CAPTURE buffer type with single plane.
2. Support only MMAP memory type.
3. STREAMON will execute automatically when the first buffer is queued.
4. STREANOFF will also execute automatically when dvr or dmxdev_filter
  are released.
5. User can decide not only buffer count but also buffer size by REQBUFS.

New ioctl() calls and data structure are belows - defined in
include/uapi/linux/dvb/dmx.h.

struct dmx_buffer {
        __u32                   index;
        __u32                   bytesused;
        __u32                   offset;
        __u32                   length;
        __u32                   reserved[4];
};

struct dmx_requestbuffers {
        __u32                   count;
        __u32                   size;
        __u32                   reserved[2];
};

struct dmx_exportbuffer {
        __u32           index;
        __u32           flags;
        __s32           fd;
        __u32           reserved;
};

#define DMX_REQBUFS              _IOWR('o', 60, struct dmx_requestbuffers)
#define DMX_QUERYBUF             _IOWR('o', 61, struct dmx_buffer)
#define DMX_EXPBUF               _IOWR('o', 62, struct dmx_exportbuffer)
#define DMX_QBUF                 _IOWR('o', 63, struct dmx_buffer)
#define DMX_DQBUF                _IOWR('o', 64, struct dmx_buffer)


This patch series is consisted of two parts - kernel changes and test patch
for dvbv5-zap.

1. Kernel changes
It includes implementation of the helper framework for DVB to use Videobuf2
and changes of the DVB framework inside.
If you want to probe this patch, firstly, you should apply the patch for VB2
refactoring before do that.
Please refer to this link for more information about VB2 refactoring.

[1] RFC PATCH v5 - Refactoring Videobuf2 for common use
 http://www.spinics.net/lists/linux-media/msg93810.html

This patch also have been applied to my own git.
[2] jsung/dvb-vb2.git - http://git.linuxtv.org/cgit.cgi/jsung/dvb-vb2.git/
    (branch: dvb-vb2)

2. Patch for testing DVB streaming I/O with dvbv5-zap
You can use '-R' option instead of '-r' to record TS data via DVR, when you
launch the dvbv5-zap application. If you do, dvbv5-zap will use following
ioctl() calls instead of read() system call.

- DMX_REQBUFS : Request kernel to allocate buffers which count and size are
  dedicated by user.
- DMX_QUERYBUF : Get the buffer information like a memory offset which will
  mmap() and be shared with user-space.
- DMX_EXPBUF : Just for testing whether buffer-exporting success or not.
- DMX_QBUF : Pass the buffer to kernel-space.
- DMX_DQBUF : Get back the buffer which may contain TS data gathered by DVR.


Any suggestions and comments are welcome.

Regards,
Junghak

Junghak Sung (1):
  media: videobuf2: Add new uAPI for DVB streaming I/O

 drivers/media/dvb-core/Makefile  |    2 +-
 drivers/media/dvb-core/dmxdev.c  |  189 +++++++++++++++---
 drivers/media/dvb-core/dmxdev.h  |    4 +
 drivers/media/dvb-core/dvb_vb2.c |  406 ++++++++++++++++++++++++++++++++++++++
 drivers/media/dvb-core/dvb_vb2.h |   69 +++++++
 include/uapi/linux/dvb/dmx.h     |   66 ++++++-
 6 files changed, 709 insertions(+), 27 deletions(-)
 create mode 100644 drivers/media/dvb-core/dvb_vb2.c
 create mode 100644 drivers/media/dvb-core/dvb_vb2.h

-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to