aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan O'Donoghue <bryan.odonoghue@linaro.org>2021-01-10 16:22:14 +0000
committerBryan O'Donoghue <bryan.odonoghue@linaro.org>2021-01-11 15:52:20 +0000
commitd1b506e106055ca155e451ba822e8f4c1a2ca1f8 (patch)
treee7d4534393e3780db2a69796343be361f548f268
parentc0cbac6720e877480fada632e7506c5fe8c08c3f (diff)
media: venus: hfi: Align NV12/NV21 plane stries to 512 for 6xxtracking-qcomlt-sm8250-venus-07
Referencing code from downstream and from Jonathan Marek we see that the stride size alignment for NV12 and NV21 output buffers should be set to 512 bytes not 128 bytes. Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
-rw-r--r--drivers/media/platform/qcom/venus/helpers.c8
-rw-r--r--drivers/media/platform/qcom/venus/helpers.h4
-rw-r--r--drivers/media/platform/qcom/venus/hfi_plat_bufs_v6.c7
-rw-r--r--drivers/media/platform/qcom/venus/vdec.c30
-rw-r--r--drivers/media/platform/qcom/venus/venc.c6
5 files changed, 38 insertions, 17 deletions
diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c
index 174d5bc5e0bb..6e3c783973b6 100644
--- a/drivers/media/platform/qcom/venus/helpers.c
+++ b/drivers/media/platform/qcom/venus/helpers.c
@@ -1009,11 +1009,13 @@ static u32 get_framesize_raw_yuv420_tp10_ubwc(u32 width, u32 height)
return ALIGN(size, SZ_4K);
}
-u32 venus_helper_get_framesz_raw(u32 hfi_fmt, u32 width, u32 height)
+u32 venus_helper_get_framesz_raw(u32 hfi_fmt, u32 width, u32 height, u32 align)
{
switch (hfi_fmt) {
case HFI_COLOR_FORMAT_NV12:
case HFI_COLOR_FORMAT_NV21:
+ if (align)
+ width = ALIGN(width, align);
return get_framesize_raw_nv12(width, height);
case HFI_COLOR_FORMAT_NV12_UBWC:
return get_framesize_raw_nv12_ubwc(width, height);
@@ -1029,7 +1031,7 @@ u32 venus_helper_get_framesz_raw(u32 hfi_fmt, u32 width, u32 height)
}
EXPORT_SYMBOL_GPL(venus_helper_get_framesz_raw);
-u32 venus_helper_get_framesz(u32 v4l2_fmt, u32 width, u32 height)
+u32 venus_helper_get_framesz(u32 v4l2_fmt, u32 width, u32 height, u32 align)
{
u32 hfi_fmt, sz;
bool compressed;
@@ -1067,7 +1069,7 @@ u32 venus_helper_get_framesz(u32 v4l2_fmt, u32 width, u32 height)
if (!hfi_fmt)
return 0;
- return venus_helper_get_framesz_raw(hfi_fmt, width, height);
+ return venus_helper_get_framesz_raw(hfi_fmt, width, height, align);
}
EXPORT_SYMBOL_GPL(venus_helper_get_framesz);
diff --git a/drivers/media/platform/qcom/venus/helpers.h b/drivers/media/platform/qcom/venus/helpers.h
index 5407979bf234..83bbbd96397a 100644
--- a/drivers/media/platform/qcom/venus/helpers.h
+++ b/drivers/media/platform/qcom/venus/helpers.h
@@ -25,8 +25,8 @@ void venus_helper_m2m_device_run(void *priv);
void venus_helper_m2m_job_abort(void *priv);
int venus_helper_get_bufreq(struct venus_inst *inst, u32 type,
struct hfi_buffer_requirements *req);
-u32 venus_helper_get_framesz_raw(u32 hfi_fmt, u32 width, u32 height);
-u32 venus_helper_get_framesz(u32 v4l2_fmt, u32 width, u32 height);
+u32 venus_helper_get_framesz_raw(u32 hfi_fmt, u32 width, u32 height, u32 align);
+u32 venus_helper_get_framesz(u32 v4l2_fmt, u32 width, u32 height, u32 align);
int venus_helper_set_input_resolution(struct venus_inst *inst,
unsigned int width, unsigned int height);
int venus_helper_set_output_resolution(struct venus_inst *inst,
diff --git a/drivers/media/platform/qcom/venus/hfi_plat_bufs_v6.c b/drivers/media/platform/qcom/venus/hfi_plat_bufs_v6.c
index 072e349dd46c..9ea0eefe45d7 100644
--- a/drivers/media/platform/qcom/venus/hfi_plat_bufs_v6.c
+++ b/drivers/media/platform/qcom/venus/hfi_plat_bufs_v6.c
@@ -9,6 +9,7 @@
#include "hfi.h"
#include "hfi_plat_bufs.h"
#include "helpers.h"
+#include "core.h"
#define MIN_INPUT_BUFFERS 4
#define MIN_ENC_OUTPUT_BUFFERS 4
@@ -1181,6 +1182,7 @@ static int bufreq_dec(struct hfi_plat_buffers_params *params, u32 buftype,
u32 max_mbs_per_frame = params->dec.max_mbs_per_frame;
u32 buffer_size_limit = params->dec.buffer_size_limit;
u32 num_vpp_pipes = params->num_vpp_pipes;
+ u32 align = 0;
switch (codec) {
case V4L2_PIX_FMT_H264:
@@ -1211,6 +1213,7 @@ static int bufreq_dec(struct hfi_plat_buffers_params *params, u32 buftype,
bufreq->hold_count = 1;
bufreq->contiguous = 1;
bufreq->alignment = 256;
+ align = 512;
if (buftype == HFI_BUFFER_INPUT) {
bufreq->count_min = MIN_INPUT_BUFFERS;
@@ -1223,7 +1226,7 @@ static int bufreq_dec(struct hfi_plat_buffers_params *params, u32 buftype,
bufreq->count_min = out_min_count;
bufreq->size =
venus_helper_get_framesz_raw(params->hfi_color_fmt,
- width, height);
+ width, height, align);
} else if (buftype == HFI_BUFFER_INTERNAL_SCRATCH(version)) {
bufreq->size = dec_ops->scratch(width, height, is_interlaced);
} else if (buftype == HFI_BUFFER_INTERNAL_SCRATCH_1(version)) {
@@ -1282,7 +1285,7 @@ int bufreq_enc(struct hfi_plat_buffers_params *params, u32 buftype,
bufreq->count_min = MIN_INPUT_BUFFERS;
bufreq->size =
venus_helper_get_framesz_raw(params->hfi_color_fmt,
- width, height);
+ width, height, 0);
} else if (buftype == HFI_BUFFER_OUTPUT ||
buftype == HFI_BUFFER_OUTPUT2) {
bufreq->count_min =
diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c
index 84c16f33e01b..16c50d315871 100644
--- a/drivers/media/platform/qcom/venus/vdec.c
+++ b/drivers/media/platform/qcom/venus/vdec.c
@@ -145,6 +145,9 @@ vdec_try_fmt_common(struct venus_inst *inst, struct v4l2_format *f)
struct v4l2_plane_pix_format *pfmt = pixmp->plane_fmt;
const struct venus_format *fmt;
u32 szimage;
+ u32 height;
+ u32 width;
+ u32 align = 0;
memset(pfmt[0].reserved, 0, sizeof(pfmt[0].reserved));
memset(pixmp->reserved, 0, sizeof(pixmp->reserved));
@@ -173,12 +176,17 @@ vdec_try_fmt_common(struct venus_inst *inst, struct v4l2_format *f)
pixmp->num_planes = fmt->num_planes;
pixmp->flags = 0;
- szimage = venus_helper_get_framesz(pixmp->pixelformat, pixmp->width,
- pixmp->height);
+ if (IS_V6(inst->core))
+ align = 512;
+
+ szimage = venus_helper_get_framesz(pixmp->pixelformat, width,
+ height, align);
if (f->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
pfmt[0].sizeimage = szimage;
- pfmt[0].bytesperline = ALIGN(pixmp->width, 128);
+ if (!align)
+ align = 128;
+ pfmt[0].bytesperline = ALIGN(pixmp->width, align);
} else {
pfmt[0].sizeimage = clamp_t(u32, pfmt[0].sizeimage, 0, SZ_8M);
pfmt[0].sizeimage = max(pfmt[0].sizeimage, szimage);
@@ -645,6 +653,7 @@ static int vdec_output_conf(struct venus_inst *inst)
u32 out_fmt, out2_fmt;
bool ubwc = false;
u32 ptype;
+ u32 align;
int ret;
ret = venus_helper_set_work_mode(inst, VIDC_WORK_MODE_2);
@@ -671,10 +680,13 @@ static int vdec_output_conf(struct venus_inst *inst)
if (ret)
return ret;
+ if (IS_V6(inst->core))
+ align = 512;
+
inst->output_buf_size =
- venus_helper_get_framesz_raw(out_fmt, width, height);
+ venus_helper_get_framesz_raw(out_fmt, width, height, align);
inst->output2_buf_size =
- venus_helper_get_framesz_raw(out2_fmt, width, height);
+ venus_helper_get_framesz_raw(out2_fmt, width, height, align);
if (is_ubwc_fmt(out_fmt)) {
inst->opb_buftype = HFI_BUFFER_OUTPUT2;
@@ -807,6 +819,7 @@ static int vdec_queue_setup(struct vb2_queue *q,
{
struct venus_inst *inst = vb2_get_drv_priv(q);
unsigned int in_num, out_num;
+ u32 align = 0;
int ret = 0;
if (*num_planes) {
@@ -847,12 +860,15 @@ static int vdec_queue_setup(struct vb2_queue *q,
if (ret)
return ret;
+ if (IS_V6(inst->core))
+ align = 512;
+
switch (q->type) {
case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
*num_planes = inst->fmt_out->num_planes;
sizes[0] = venus_helper_get_framesz(inst->fmt_out->pixfmt,
inst->out_width,
- inst->out_height);
+ inst->out_height, align);
sizes[0] = max(sizes[0], inst->input_buf_size);
inst->input_buf_size = sizes[0];
*num_buffers = max(*num_buffers, in_num);
@@ -863,7 +879,7 @@ static int vdec_queue_setup(struct vb2_queue *q,
*num_planes = inst->fmt_cap->num_planes;
sizes[0] = venus_helper_get_framesz(inst->fmt_cap->pixfmt,
inst->width,
- inst->height);
+ inst->height, align);
inst->output_buf_size = sizes[0];
*num_buffers = max(*num_buffers, out_num);
inst->num_output_bufs = *num_buffers;
diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c
index 6e830fc83b09..027bb747b973 100644
--- a/drivers/media/platform/qcom/venus/venc.c
+++ b/drivers/media/platform/qcom/venus/venc.c
@@ -203,7 +203,7 @@ venc_try_fmt_common(struct venus_inst *inst, struct v4l2_format *f)
sizeimage = venus_helper_get_framesz(pixmp->pixelformat,
pixmp->width,
- pixmp->height);
+ pixmp->height, 0);
pfmt[0].sizeimage = max(ALIGN(pfmt[0].sizeimage, SZ_4K), sizeimage);
if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
@@ -818,7 +818,7 @@ static int venc_queue_setup(struct vb2_queue *q,
sizes[0] = venus_helper_get_framesz(inst->fmt_out->pixfmt,
inst->width,
- inst->height);
+ inst->height, 0);
inst->input_buf_size = sizes[0];
break;
case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
@@ -827,7 +827,7 @@ static int venc_queue_setup(struct vb2_queue *q,
inst->num_output_bufs = *num_buffers;
sizes[0] = venus_helper_get_framesz(inst->fmt_cap->pixfmt,
inst->width,
- inst->height);
+ inst->height, 0);
sizes[0] = max(sizes[0], inst->output_buf_size);
inst->output_buf_size = sizes[0];
break;