Skip to content

Commit

Permalink
meson-vdec: Honor app requested encoded size
Browse files Browse the repository at this point in the history
The application request a specific endoded buffer size using S_FMT on
the OUTPUT device. This patch honor this requested size, along with
properly implementing a default selection. This also increase the
default buffer size to 1 Mb, which is more suitable for Internet HD
streams.

[endlessm/eos-shell#5955]
  • Loading branch information
ndufresne committed Nov 6, 2015
1 parent 4498370 commit 2717fc5
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions drivers/media/platform/meson/meson_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
* decoded frame data. Maybe it doesn't have to be contiguous. */
#define VDEC_HW_BUF_SIZE (64*1024*1024)

/* This is the default encoded v4l2_buffer size */
#define VDEC_ENCODED_BUF_SIZE (1*1024*1024)

static int debug;
module_param(debug, int, 0644);
MODULE_PARM_DESC(debug, "debug level (0-1)");
Expand Down Expand Up @@ -132,6 +135,7 @@ struct vdec_ctx {
*/
spinlock_t data_lock;

int src_bufs_size;
int src_bufs_cnt;
int dst_bufs_cnt;
struct vdec_buf src_bufs[VDEC_MAX_BUFFERS];
Expand Down Expand Up @@ -546,10 +550,13 @@ static int vidioc_try_fmt_vid_out(struct file *file, void *priv,

v4l2_dbg(1, debug, &ctx->dev->v4l2_dev, "ioc_try_fmt_vid_out\n");

/* FIXME: set sizeimage too? */
f->fmt.pix_mp.pixelformat = V4L2_PIX_FMT_H264;
f->fmt.pix_mp.num_planes = 1;
f->fmt.pix_mp.plane_fmt[0].bytesperline = 0;

if (f->fmt.pix_mp.plane_fmt[0].sizeimage == 0)
f->fmt.pix_mp.plane_fmt[0].sizeimage = VDEC_ENCODED_BUF_SIZE;

return 0;
}

Expand All @@ -576,11 +583,15 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
static int vidioc_s_fmt_vid_out(struct file *file, void *priv,
struct v4l2_format *f)
{
/* FIXME should check format */
// FIXME how does this hook up with the buffer sizes used in reqbufs? */
f->fmt.pix_mp.plane_fmt[0].sizeimage = 512 * 1024;
struct vdec_ctx *ctx = file2ctx(file);
int ret;

return 0;
ret = vidioc_try_fmt_vid_out (file, priv, f);

if (ret == 0)
ctx->src_bufs_size = f->fmt.pix_mp.plane_fmt[0].sizeimage;

return ret;
}

static int vidioc_reqbufs(struct file *file, void *priv,
Expand Down Expand Up @@ -801,8 +812,7 @@ static int vdec_src_queue_setup(struct vb2_queue *vq,

*nplanes = 1;

// FIXME is 512kb sensible?
sizes[0] = 512 * 1024;
sizes[0] = ctx->src_bufs_size;

alloc_ctxs[0] = ctx->dev->vb_alloc_ctx;

Expand Down

0 comments on commit 2717fc5

Please sign in to comment.