Re: [PATCH] media: v4l-utils: dvbv5: Streaming I/O for DVB

2016-05-13 Thread Mauro Carvalho Chehab
Em Tue, 06 Oct 2015 18:59:02 +0900
Junghak Sung  escreveu:

> Add a new scenario to use streaming I/O for TS recording.
> 
> Signed-off-by: Junghak Sung 
> Signed-off-by: Geunyoung Kim 
> Acked-by: Seung-Woo Kim 
> Acked-by: Inki Dae 


Due to some changes that happened after the VB2 split changes got merged,
this patch doesn't compile anymore.

The enclosed diff should make it build yet.

I intend to fold it with the original patch and do some tests,
in order to make this work merged some day upstream.

Regards,
Mauro

diff --git a/drivers/media/dvb-core/dvb_vb2.c b/drivers/media/dvb-core/dvb_vb2.c
index 1a2dc5516c4e..5b1bcc80880f 100644
--- a/drivers/media/dvb-core/dvb_vb2.c
+++ b/drivers/media/dvb-core/dvb_vb2.c
@@ -27,7 +27,7 @@ module_param(vb2_debug, int, 0644);
pr_info("vb2: %s: " fmt, __func__, ## arg); \
} while (0)
 
-static int _queue_setup(struct vb2_queue *vq, const struct vb2_format *fmt,
+static int _queue_setup(struct vb2_queue *vq,
unsigned int *nbuffers, unsigned int *nplanes,
unsigned int sizes[], void *alloc_ctxs[])
 {
@@ -120,7 +120,7 @@ static const struct vb2_ops dvb_vb2_qops = {
.wait_finish= _dmxdev_lock,
 };
 
-static int _fill_dmx_buffer(struct vb2_buffer *vb, void *pb)
+static void _fill_dmx_buffer(struct vb2_buffer *vb, void *pb)
 {
struct dvb_vb2_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue);
struct dmx_buffer *b = pb;
@@ -131,8 +131,6 @@ static int _fill_dmx_buffer(struct vb2_buffer *vb, void *pb)
b->offset = vb->planes[0].m.offset;
memset(b->reserved, 0, sizeof(b->reserved));
dprintk(3, "[%s]\n", ctx->name);
-
-   return 0;
 }
 
 static int _fill_vb2_buffer(struct vb2_buffer *vb,
@@ -335,14 +333,7 @@ int dvb_vb2_reqbufs(struct dvb_vb2_ctx *ctx, struct 
dmx_requestbuffers *req)
 
 int dvb_vb2_querybuf(struct dvb_vb2_ctx *ctx, struct dmx_buffer *b)
 {
-   int ret;
-
-   ret = vb2_core_querybuf(>vb_q, b->index, b);
-   if (ret) {
-   dprintk(1, "[%s] index=%d errno=%d\n", ctx->name,
-   b->index, ret);
-   return ret;
-   }
+   vb2_core_querybuf(>vb_q, b->index, b);
dprintk(3, "[%s] index=%d\n", ctx->name, b->index);
 
return 0;
@@ -384,7 +375,7 @@ int dvb_vb2_dqbuf(struct dvb_vb2_ctx *ctx, struct 
dmx_buffer *b)
 {
int ret;
 
-   ret = vb2_core_dqbuf(>vb_q, b, ctx->nonblocking);
+   ret = vb2_core_dqbuf(>vb_q, NULL, b, ctx->nonblocking);
if (ret) {
dprintk(1, "[%s] errno=%d\n", ctx->name, ret);
return ret;
--
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


[PATCH] media: v4l-utils: dvbv5: Streaming I/O for DVB

2015-10-06 Thread Junghak Sung
Add a new scenario to use streaming I/O for TS recording.

Signed-off-by: Junghak Sung 
Signed-off-by: Geunyoung Kim 
Acked-by: Seung-Woo Kim 
Acked-by: Inki Dae 
---
 include/linux/dvb/dmx.h |   64 
 utils/dvb/dvbv5-zap.c   |  187 ++-
 2 files changed, 249 insertions(+), 2 deletions(-)

diff --git a/include/linux/dvb/dmx.h b/include/linux/dvb/dmx.h
index 425a945..66fd43b 100644
--- a/include/linux/dvb/dmx.h
+++ b/include/linux/dvb/dmx.h
@@ -138,6 +138,64 @@ struct dmx_stc {
__u64 stc;  /* output: stc in 'base'*90 kHz units */
 };
 
+/**
+ * struct dmx_buffer - dmx buffer info
+ *
+ * @index: id number of the buffer
+ * @bytesused: number of bytes occupied by data in the buffer (payload);
+ * @offset:for buffers with memory == DMX_MEMORY_MMAP;
+ * offset from the start of the device memory for this plane,
+ * (or a "cookie" that should be passed to mmap() as offset)
+ * @length:size in bytes of the buffer
+ *
+ * Contains data exchanged by application and driver using one of the streaming
+ * I/O methods.
+ */
+struct dmx_buffer {
+   __u32   index;
+   __u32   bytesused;
+   __u32   offset;
+   __u32   length;
+   __u32   reserved[4];
+};
+
+/**
+ * struct dmx_requestbuffers - request dmx buffer information
+ *
+ * @count: number of requested buffers,
+ * @size:  size in bytes of the requested buffer
+ *
+ * Contains data used for requesting a dmx buffer.
+ * All reserved fields must be set to zero.
+ */
+struct dmx_requestbuffers {
+   __u32   count;
+   __u32   size;
+   __u32   reserved[2];
+};
+
+/**
+ * struct dmx_exportbuffer - export of dmx buffer as DMABUF file descriptor
+ *
+ * @index: id number of the buffer
+ * @flags: flags for newly created file, currently only O_CLOEXEC is
+ * supported, refer to manual of open syscall for more details
+ * @fd:file descriptor associated with DMABUF (set by driver)
+ *
+ * Contains data used for exporting a dmx buffer as DMABUF file descriptor.
+ * The buffer is identified by a 'cookie' returned by DMX_QUERYBUF
+ * (identical to the cookie used to mmap() the buffer to userspace). All
+ * reserved fields must be set to zero. The field reserved0 is expected to
+ * become a structure 'type' allowing an alternative layout of the structure
+ * content. Therefore this field should not be used for any other extensions.
+ */
+struct dmx_exportbuffer {
+   __u32   index;
+   __u32   flags;
+   __s32   fd;
+   __u32   reserved[5];
+};
+
 #define DMX_START_IO('o', 41)
 #define DMX_STOP _IO('o', 42)
 #define DMX_SET_FILTER   _IOW('o', 43, struct dmx_sct_filter_params)
@@ -150,4 +208,10 @@ struct dmx_stc {
 #define DMX_ADD_PID  _IOW('o', 51, __u16)
 #define DMX_REMOVE_PID   _IOW('o', 52, __u16)
 
+#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)
+
 #endif /* _DVBDMX_H_ */
diff --git a/utils/dvb/dvbv5-zap.c b/utils/dvb/dvbv5-zap.c
index 2812166..eac146b 100644
--- a/utils/dvb/dvbv5-zap.c
+++ b/utils/dvb/dvbv5-zap.c
@@ -33,6 +33,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -71,6 +72,7 @@ struct arguments {
unsigned n_apid, n_vpid, all_pids;
enum dvb_file_formats input_format, output_format;
unsigned traffic_monitor, low_traffic;
+   unsigned streaming;
char *search;
const char *cc;
 
@@ -94,6 +96,7 @@ static const struct argp_option options[] = {
{"pat", 'p', NULL,  0, N_("add pat and pmt 
to TS recording (implies -r)"), 0},
{"all-pids",'P', NULL,  0, N_("don't filter any 
pids. Instead, outputs all of them"), 0 },
{"record",  'r', NULL,  0, N_("set up 
/dev/dvb/adapterX/dvr0 for TS recording"), 0},
+   {"streaming",   'R', NULL,  0, N_("uses streaming 
I/O for TS recording"), 0},
{"silence", 's', NULL,  0, N_("increases 
silence (can be used more than once)"), 0},
{"sat_number",  'S', N_("satellite_number"),0, N_("satellite 
number. If not specified, disable DISEqC"), 0},
{"timeout", 't', N_("seconds"), 0, N_("timeout for 
zapping and for recording"), 0},
@@ -449,6 +452,171 @@ static void