Skip to content

Commit e4af84f

Browse files
Aakarsh JainHans Verkuil
authored andcommitted
media: s5p-mfc: DPB Count Independent of VIDIOC_REQBUF
Add allocation of DPB buffers based on MFC requirement so, codec buffers allocations has been moved after state MFCINST_HEAD_PRODUCED. It is taken care that codec buffer allocation is performed in process context from userspace IOCTL call. Cc: linux-fsd@tesla.com Signed-off-by: Smitha T Murthy <smithatmurthy@gmail.com> Signed-off-by: Aakarsh Jain <aakarsh.jain@samsung.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
1 parent f30d7cf commit e4af84f

2 files changed

Lines changed: 9 additions & 16 deletions

File tree

drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,7 +1164,6 @@ static int enc_post_seq_start(struct s5p_mfc_ctx *ctx)
11641164
struct s5p_mfc_dev *dev = ctx->dev;
11651165
struct s5p_mfc_enc_params *p = &ctx->enc_params;
11661166
struct s5p_mfc_buf *dst_mb;
1167-
unsigned int enc_pb_count;
11681167

11691168
if (p->seq_hdr_mode == V4L2_MPEG_VIDEO_HEADER_MODE_SEPARATE) {
11701169
if (!list_empty(&ctx->dst_queue)) {
@@ -1186,10 +1185,7 @@ static int enc_post_seq_start(struct s5p_mfc_ctx *ctx)
11861185
set_work_bit_irqsave(ctx);
11871186
s5p_mfc_hw_call(dev->mfc_ops, try_run, dev);
11881187
} else {
1189-
enc_pb_count = s5p_mfc_hw_call(dev->mfc_ops,
1190-
get_enc_dpb_count, dev);
1191-
if (ctx->pb_count < enc_pb_count)
1192-
ctx->pb_count = enc_pb_count;
1188+
ctx->pb_count = s5p_mfc_hw_call(dev->mfc_ops, get_enc_dpb_count, dev);
11931189
if (FW_HAS_E_MIN_SCRATCH_BUF(dev)) {
11941190
ctx->scratch_buf_size = s5p_mfc_hw_call(dev->mfc_ops,
11951191
get_e_min_scratch_buf_size, dev);
@@ -1564,14 +1560,6 @@ static int vidioc_reqbufs(struct file *file, void *priv,
15641560
}
15651561
ctx->capture_state = QUEUE_BUFS_REQUESTED;
15661562

1567-
ret = s5p_mfc_hw_call(ctx->dev->mfc_ops,
1568-
alloc_codec_buffers, ctx);
1569-
if (ret) {
1570-
mfc_err("Failed to allocate encoding buffers\n");
1571-
reqbufs->count = 0;
1572-
ret = vb2_reqbufs(&ctx->vq_dst, reqbufs);
1573-
return -ENOMEM;
1574-
}
15751563
} else if (reqbufs->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
15761564
if (reqbufs->count == 0) {
15771565
mfc_debug(2, "Freeing buffers\n");
@@ -1587,15 +1575,13 @@ static int vidioc_reqbufs(struct file *file, void *priv,
15871575
return -EINVAL;
15881576
}
15891577

1590-
if (IS_MFCV6_PLUS(dev)) {
1578+
if (IS_MFCV6_PLUS(dev) && (!IS_MFCV12(dev))) {
15911579
/* Check for min encoder buffers */
15921580
if (ctx->pb_count &&
15931581
(reqbufs->count < ctx->pb_count)) {
15941582
reqbufs->count = ctx->pb_count;
15951583
mfc_debug(2, "Minimum %d output buffers needed\n",
15961584
ctx->pb_count);
1597-
} else {
1598-
ctx->pb_count = reqbufs->count;
15991585
}
16001586
}
16011587

drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2110,6 +2110,13 @@ static inline int s5p_mfc_run_init_enc_buffers(struct s5p_mfc_ctx *ctx)
21102110
struct s5p_mfc_dev *dev = ctx->dev;
21112111
int ret;
21122112

2113+
ret = s5p_mfc_hw_call(ctx->dev->mfc_ops, alloc_codec_buffers, ctx);
2114+
if (ret) {
2115+
mfc_err("Failed to allocate encoding buffers\n");
2116+
return -ENOMEM;
2117+
}
2118+
mfc_debug(2, "Allocated Internal Encoding Buffers\n");
2119+
21132120
dev->curr_ctx = ctx->num;
21142121
ret = s5p_mfc_set_enc_ref_buffer_v6(ctx);
21152122
if (ret) {

0 commit comments

Comments
 (0)