Merge f2c416e44e on remote branch

Change-Id: Ie12f89f6e178948f7a1cfa815a0f47b207775fb2
This commit is contained in:
Linux Build Service Account 2020-09-08 01:09:31 -07:00
commit 60544fa814
19 changed files with 299 additions and 186 deletions

View file

@ -27,8 +27,7 @@ endif
endif
LINUXINCLUDE += -I$(srctree)/techpack/video/include \
-I$(srctree)/techpack/video/include/uapi \
-I$(srctree)/techpack/video/include/uapi/vidc
-I$(srctree)/techpack/video/include/uapi
USERINCLUDE += -I$(srctree)/techpack/video/include/uapi

View file

@ -1,6 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
/*
* Copyright (c) 2019, The Linux Foundation. All rights reserved.
* Copyright (c) 2019-2020, The Linux Foundation. All rights reserved.
*/
#ifndef __MSM_MEDIA_INFO_H__
@ -57,6 +57,41 @@ enum color_fmts {
* + UV_Stride * UV_Scanlines, 4096)
*/
COLOR_FMT_NV12,
/* Venus NV12:
* YUV 4:2:0 image with a plane of 8 bit Y samples followed
* by an interleaved U/V plane containing 8 bit 2x2 subsampled
* colour difference samples.
*
* <-------- Y/UV_Stride -------->
* <------- Width ------->
* Y Y Y Y Y Y Y Y Y Y Y Y . . . . ^ ^
* Y Y Y Y Y Y Y Y Y Y Y Y . . . . | |
* Y Y Y Y Y Y Y Y Y Y Y Y . . . . Height |
* Y Y Y Y Y Y Y Y Y Y Y Y . . . . | Y_Scanlines
* Y Y Y Y Y Y Y Y Y Y Y Y . . . . | |
* Y Y Y Y Y Y Y Y Y Y Y Y . . . . | |
* Y Y Y Y Y Y Y Y Y Y Y Y . . . . | |
* Y Y Y Y Y Y Y Y Y Y Y Y . . . . V |
* . . . . . . . . . . . . . . . . |
* . . . . . . . . . . . . . . . . |
* . . . . . . . . . . . . . . . . |
* . . . . . . . . . . . . . . . . V
* U V U V U V U V U V U V . . . . ^
* U V U V U V U V U V U V . . . . |
* U V U V U V U V U V U V . . . . |
* U V U V U V U V U V U V . . . . UV_Scanlines
* . . . . . . . . . . . . . . . . |
* . . . . . . . . . . . . . . . . V
* . . . . . . . . . . . . . . . . --> Buffer size alignment
*
* Y_Stride : Width aligned to 128
* UV_Stride : Width aligned to 128
* Y_Scanlines: Height aligned to 32
* UV_Scanlines: Height/2 aligned to 16
* Total size = align(Y_Stride * Y_Scanlines
* + UV_Stride * UV_Scanlines, 4096)
*/
COLOR_FMT_NV12_128,
/* Venus NV21:
* YUV 4:2:0 image with a plane of 8 bit Y samples followed
* by an interleaved V/U plane containing 8 bit 2x2 subsampled
@ -790,6 +825,7 @@ static inline unsigned int VENUS_Y_STRIDE(unsigned int color_fmt,
alignment = 512;
stride = MSM_MEDIA_ALIGN(width, alignment);
break;
case COLOR_FMT_NV12_128:
case COLOR_FMT_NV12_UBWC:
alignment = 128;
stride = MSM_MEDIA_ALIGN(width, alignment);
@ -833,6 +869,7 @@ static inline unsigned int VENUS_UV_STRIDE(unsigned int color_fmt,
alignment = 512;
stride = MSM_MEDIA_ALIGN(width, alignment);
break;
case COLOR_FMT_NV12_128:
case COLOR_FMT_NV12_UBWC:
alignment = 128;
stride = MSM_MEDIA_ALIGN(width, alignment);
@ -875,6 +912,7 @@ static inline unsigned int VENUS_Y_SCANLINES(unsigned int color_fmt,
case COLOR_FMT_NV12_512:
alignment = 512;
break;
case COLOR_FMT_NV12_128:
case COLOR_FMT_NV12_UBWC:
case COLOR_FMT_P010:
alignment = 32;
@ -912,6 +950,7 @@ static inline unsigned int VENUS_UV_SCANLINES(unsigned int color_fmt,
case COLOR_FMT_NV12_512:
alignment = 256;
break;
case COLOR_FMT_NV12_128:
case COLOR_FMT_NV12_BPP10_UBWC:
case COLOR_FMT_P010_UBWC:
case COLOR_FMT_P010:
@ -1212,6 +1251,7 @@ static inline unsigned int VENUS_BUFFER_SIZE(unsigned int color_fmt,
case COLOR_FMT_NV12:
case COLOR_FMT_P010:
case COLOR_FMT_NV12_512:
case COLOR_FMT_NV12_128:
y_plane = y_stride * y_sclines;
uv_plane = uv_stride * uv_sclines;
size = y_plane + uv_plane;

View file

@ -14,6 +14,8 @@
#define V4L2_PIX_FMT_NV12_UBWC v4l2_fourcc('Q', '1', '2', '8')
/* NV12_512 8-bit Y/CbCr 4:2:0 */
#define V4L2_PIX_FMT_NV12_512 v4l2_fourcc('Q', '5', '1', '2')
/* NV12_128 8-bit Y/CbCr 4:2:0 */
#define V4L2_PIX_FMT_NV12_128 v4l2_fourcc('N', '1', '2', '8')
/* NV12 10-bit Y/CbCr 4:2:0 */
#define V4L2_PIX_FMT_NV12_P010_UBWC v4l2_fourcc('Q', '1', '2', 'B')
/* UBWC 10-bit Y/CbCr 4:2:0 */
@ -252,6 +254,8 @@ enum v4l2_mpeg_vidc_video_bitrate_savings_type {
(V4L2_CID_MPEG_MSM_VIDC_BASE + 132)
#define V4L2_CID_MPEG_VIDC_VIDEO_LOWLATENCY_HINT \
(V4L2_CID_MPEG_MSM_VIDC_BASE + 133)
#define V4L2_CID_MPEG_VIDC_VDEC_HEIF_MODE \
(V4L2_CID_MPEG_MSM_VIDC_BASE + 134)
#define V4L2_CID_MPEG_VIDC_VIDEO_UNKNOWN \
(V4L2_CID_MPEG_MSM_VIDC_BASE + 0xFFF)

View file

@ -434,6 +434,15 @@ static struct msm_vidc_ctrl msm_vdec_ctrls[] = {
.default_value = 0,
.step = 1,
},
{
.id = V4L2_CID_MPEG_VIDC_VDEC_HEIF_MODE,
.name = "HEIF Decoder",
.type = V4L2_CTRL_TYPE_BOOLEAN,
.minimum = V4L2_MPEG_MSM_VIDC_DISABLE,
.maximum = V4L2_MPEG_MSM_VIDC_ENABLE,
.default_value = V4L2_MPEG_MSM_VIDC_DISABLE,
.step = 1,
},
};
#define NUM_CTRLS ARRAY_SIZE(msm_vdec_ctrls)
@ -948,6 +957,15 @@ int msm_vdec_s_ctrl(struct msm_vidc_inst *inst, struct v4l2_ctrl *ctrl)
break;
case V4L2_CID_MPEG_VIDC_VIDEO_LOWLATENCY_HINT:
break;
case V4L2_CID_MPEG_VIDC_VDEC_HEIF_MODE:
if(get_v4l2_codec(inst) != V4L2_PIX_FMT_HEVC)
break;
inst->flags &= ~VIDC_TURBO;
if (ctrl->val)
inst->flags |= VIDC_TURBO;
if (inst->state < MSM_VIDC_LOAD_RESOURCES)
msm_vidc_calculate_buffer_counts(inst);
break;
default:
s_vpr_e(inst->sid, "Unknown control %#x\n", ctrl->id);
break;
@ -1326,6 +1344,7 @@ int msm_vdec_set_priority(struct msm_vidc_inst *inst)
int msm_vdec_set_seqchng_at_syncframe(struct msm_vidc_inst *inst)
{
int rc = 0;
u32 codec;
struct hfi_device *hdev;
struct hfi_enable hfi_property;
@ -1339,6 +1358,13 @@ int msm_vdec_set_seqchng_at_syncframe(struct msm_vidc_inst *inst)
if (!hfi_property.enable)
return 0;
codec = get_v4l2_codec(inst);
if (!(codec == V4L2_PIX_FMT_HEVC || codec == V4L2_PIX_FMT_H264)) {
s_vpr_e(inst->sid,
"%s: low latency hint supported for HEVC/H264\n",
__func__);
return -EINVAL;
}
s_vpr_h(inst->sid, "%s: %#x\n", __func__, hfi_property.enable);
rc = call_hfi_op(hdev, session_set_property, inst->session,
HFI_PROPERTY_PARAM_VDEC_SEQCHNG_AT_SYNCFRM, &hfi_property,

View file

@ -1036,6 +1036,11 @@ static struct msm_vidc_format_desc venc_input_formats[] = {
.description = "Y/CbCr 4:2:0 10bit",
.fourcc = V4L2_PIX_FMT_SDE_Y_CBCR_H2V2_P010_VENUS,
},
{
.name = "YCbCr Semiplanar 4:2:0 128 aligned",
.description = "Y/CbCr 4:2:0 128 aligned",
.fourcc = V4L2_PIX_FMT_NV12_128,
},
{
.name = "YCbCr Semiplanar 4:2:0 512 aligned",
.description = "Y/CbCr 4:2:0 512 aligned",
@ -1070,6 +1075,14 @@ struct msm_vidc_format_constraint enc_pix_format_constraints[] = {
.uv_max_stride = 8192,
.uv_buffer_alignment = 256,
},
{
.fourcc = V4L2_PIX_FMT_NV12_128,
.num_planes = 2,
.y_max_stride = 8192,
.y_buffer_alignment = 128,
.uv_max_stride = 8192,
.uv_buffer_alignment = 32,
},
{
.fourcc = V4L2_PIX_FMT_NV12_512,
.num_planes = 2,

View file

@ -432,7 +432,8 @@ int msm_vidc_qbuf(void *instance, struct media_device *mdev,
timestamp_us = (s64)((b->timestamp.tv_sec * 1000000) +
b->timestamp.tv_usec);
if (is_decode_session(inst) && b->type == INPUT_MPLANE) {
if (is_decode_session(inst) && b->type == INPUT_MPLANE &&
!is_heif_decoder(inst)) {
if (inst->flush_timestamps)
msm_comm_release_timestamps(inst);
inst->flush_timestamps = false;
@ -513,7 +514,8 @@ int msm_vidc_dqbuf(void *instance, struct v4l2_buffer *b)
}
if (is_decode_session(inst) &&
b->type == OUTPUT_MPLANE &&
!(b->flags & V4L2_BUF_FLAG_CODECCONFIG))
!(b->flags & V4L2_BUF_FLAG_CODECCONFIG) &&
!is_heif_decoder(inst))
msm_comm_fetch_ts_framerate(inst, b);
return rc;
@ -1534,6 +1536,7 @@ void *msm_vidc_open(int core_id, int session_type)
inst->bse_vpp_delay = DEFAULT_BSE_VPP_DELAY;
inst->first_reconfig_done = 0;
inst->active = true;
inst->has_bframe = 0;
for (i = SESSION_MSG_INDEX(SESSION_MSG_START);
i <= SESSION_MSG_INDEX(SESSION_MSG_END); i++) {

View file

@ -8,7 +8,7 @@
#include <linux/videodev2.h>
#include <linux/msm_ion.h>
#include <media/msm_vidc_utils.h>
#include "vidc/media/msm_vidc_utils.h"
#include <media/media-device.h>
#define HAL_BUFFER_MAX 0xe

View file

@ -27,6 +27,10 @@
/* extra output buffers for encoder HEIF usecase */
#define HEIF_ENC_TOTAL_OUTPUT_BUFFERS 12
/* extra buffer count for heif decoder */
#define HEIF_DEC_TOTAL_INPUT_BUFFERS 12
#define HEIF_DEC_EXTRA_OUTPUT_BUFFERS 8
#define HFI_COLOR_FORMAT_YUV420_NV12_UBWC_Y_TILE_WIDTH 32
#define HFI_COLOR_FORMAT_YUV420_NV12_UBWC_Y_TILE_HEIGHT 8
#define HFI_COLOR_FORMAT_YUV420_NV12_UBWC_UV_TILE_WIDTH 16
@ -789,6 +793,9 @@ static int msm_vidc_get_extra_input_buff_count(struct msm_vidc_inst *inst)
core = inst->core;
if (is_heif_decoder(inst))
return (HEIF_DEC_TOTAL_INPUT_BUFFERS - MIN_INPUT_BUFFERS);
/*
* For thumbnail session, extra buffers are not required as
* neither dcvs nor batching will be enabled.
@ -821,6 +828,9 @@ static int msm_vidc_get_extra_output_buff_count(struct msm_vidc_inst *inst)
core = inst->core;
if (is_heif_decoder(inst))
return HEIF_DEC_EXTRA_OUTPUT_BUFFERS;
/*
* For a non-realtime session, extra buffers are not required.
* For thumbnail session, extra buffers are not required as
@ -829,7 +839,7 @@ static int msm_vidc_get_extra_output_buff_count(struct msm_vidc_inst *inst)
if (!is_realtime_session(inst) || is_thumbnail_session(inst))
return extra_output_count;
/* For HEIF, we are increasing buffer count */
/* For HEIF encoder, we are increasing buffer count */
if (is_image_session(inst)) {
extra_output_count = (HEIF_ENC_TOTAL_OUTPUT_BUFFERS -
MIN_ENC_OUTPUT_BUFFERS);
@ -889,6 +899,11 @@ u32 msm_vidc_calculate_dec_input_frame_size(struct msm_vidc_inst *inst)
base_res_mbs = inst->capability.cap[CAP_MBS_PER_FRAME].max;
div_factor = 1;
}
/* For HEIF image, use the actual resolution to calc buffer size */
if (is_heif_decoder(inst)) {
base_res_mbs = num_mbs;
div_factor = 1;
}
frame_size = base_res_mbs * MB_SIZE_IN_PIXEL * 3 / 2 / div_factor;

View file

@ -1,6 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (c) 2019, The Linux Foundation. All rights reserved.
* Copyright (c) 2019-2020, The Linux Foundation. All rights reserved.
*/
#ifndef __H_MSM_VIDC_BUS_DEFS_H__
@ -228,30 +228,30 @@ struct lut const *__lut(int width, int height, int fps);
fp_t __compression_ratio(struct lut const *entry, int bpp);
void __dump(struct dump dump[], int len, u32 sid);
static inline bool __ubwc(enum hal_uncompressed_format f)
static inline bool __ubwc(u32 format)
{
switch (f) {
case HAL_COLOR_FORMAT_NV12_UBWC:
case HAL_COLOR_FORMAT_NV12_TP10_UBWC:
switch (format) {
case HFI_COLOR_FORMAT_NV12_UBWC:
case HFI_COLOR_FORMAT_YUV420_TP10_UBWC:
return true;
default:
return false;
}
}
static inline int __bpp(enum hal_uncompressed_format f, u32 sid)
static inline int __bpp(u32 format, u32 sid)
{
switch (f) {
case HAL_COLOR_FORMAT_NV12:
case HAL_COLOR_FORMAT_NV21:
case HAL_COLOR_FORMAT_NV12_UBWC:
case HAL_COLOR_FORMAT_RGBA8888_UBWC:
switch (format) {
case HFI_COLOR_FORMAT_NV12:
case HFI_COLOR_FORMAT_NV21:
case HFI_COLOR_FORMAT_NV12_UBWC:
case HFI_COLOR_FORMAT_RGBA8888_UBWC:
return 8;
case HAL_COLOR_FORMAT_NV12_TP10_UBWC:
case HAL_COLOR_FORMAT_P010:
case HFI_COLOR_FORMAT_YUV420_TP10_UBWC:
case HFI_COLOR_FORMAT_P010:
return 10;
default:
s_vpr_e(sid, "Unsupported colorformat (%x)", f);
s_vpr_e(sid, "Unsupported colorformat (%x)", format);
return INT_MAX;
}
}

View file

@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2019, The Linux Foundation. All rights reserved.
* Copyright (c) 2019-2020, The Linux Foundation. All rights reserved.
*/
#include "msm_vidc_bus.h"
@ -9,33 +9,35 @@
static unsigned long __calculate_encoder(struct vidc_bus_vote_data *d)
{
/* Encoder Parameters */
int width, height, fps, bitrate, lcu_size;
int width, height, fps, bitrate, lcu_size, lcu_per_frame,
collocated_bytes_per_lcu, search_range_v, search_range_h,
vertical_tile_size, num_tiles;
/* Derived Parameter */
int search_range, lcu_per_frame;
unsigned int bins_to_bit_factor;
fp_t y_bw;
bool is_h264_category = true;
fp_t orig_read_factor, recon_write_factor,
ref_y_read_factor, ref_c_read_factor, lb_factor,
rest_factor, total_read_factor, total_write_factor,
total_factor, overhead_factor;
ref_y_read_factor, ref_c_read_factor, overhead_factor;
/* Output parameters */
fp_t orig_read, recon_write,
ref_y_read, ref_c_read,
lb_read, lb_write,
bse_read, bse_write,
total_read, total_write,
total;
ref_y_read, ref_c_read,
bse_lb_read, bse_lb_write,
collocated_read, collocated_write,
bitstream_read, bitstream_write,
total_read, total_write,
total;
unsigned long ret = 0;
/* Encoder Fixed Parameters */
/* Encoder Fixed Parameters setup */
search_range_h = 96;
search_range_v = 48;
bins_to_bit_factor = 4;
overhead_factor = FP(1, 3, 100);
orig_read_factor = FP(1, 50, 100); /* L + C */
recon_write_factor = FP(1, 50, 100); /* L + C */
ref_c_read_factor = FP(0, 75, 100); /* 1.5/2 ( 1.5 Cache efficiency )*/
lb_factor = FP(1, 25, 100); /* Worst case : HEVC 720p = 1.25 */
fps = d->fps;
width = max(d->output_width, BASELINE_DIMENSIONS.width);
@ -55,40 +57,46 @@ static unsigned long __calculate_encoder(struct vidc_bus_vote_data *d)
is_h264_category = false;
}
search_range = 48;
collocated_bytes_per_lcu = lcu_size == 16 ? 16 :
lcu_size == 32 ? 64 : 256;
if (width >= 1296 && width <= 1536)
vertical_tile_size = 768;
else
vertical_tile_size = 640;
num_tiles = DIV_ROUND_UP(width, vertical_tile_size);
y_bw = fp_mult(fp_mult(FP_INT(width), FP_INT(height)), FP_INT(fps));
y_bw = fp_div(y_bw, FP_INT(1000000));
y_bw = fp_div(y_bw, FP_INT(bps(1)));
ref_y_read_factor = fp_div(FP_INT(search_range * 2), FP_INT(lcu_size));
/* -1 for 1 less tile boundary penalty */
ref_y_read_factor = (num_tiles - 1) * 2;
ref_y_read_factor = fp_div(fp_mult(FP_INT(ref_y_read_factor),
FP_INT(search_range_h)), FP_INT(width));
ref_y_read_factor = ref_y_read_factor + FP_INT(1);
rest_factor = FP_INT(bitrate) + fp_div(FP_INT(bitrate), FP_INT(8));
rest_factor = fp_div(rest_factor, y_bw);
total_read_factor = fp_div(rest_factor, FP_INT(2)) +
fp_div(lb_factor, FP_INT(2));
total_read_factor = total_read_factor + orig_read_factor +
ref_y_read_factor + ref_c_read_factor;
total_write_factor = fp_div(rest_factor, FP_INT(2)) +
fp_div(lb_factor, FP_INT(2));
total_write_factor = total_write_factor + recon_write_factor;
total_factor = total_read_factor + total_write_factor;
orig_read = fp_mult(y_bw, orig_read_factor);
recon_write = fp_mult(y_bw, recon_write_factor);
ref_y_read = fp_mult(y_bw, ref_y_read_factor);
ref_c_read = fp_mult(y_bw, ref_c_read_factor);
lb_read = fp_div(fp_mult(y_bw, lb_factor), FP_INT(2));
lb_write = lb_read;
bse_read = fp_mult(y_bw, fp_div(rest_factor, FP_INT(2)));
bse_write = bse_read;
bse_lb_read = fp_div(FP_INT(16 * fps * lcu_per_frame),
FP_INT(bps(1)));
bse_lb_write = bse_lb_read;
collocated_read = fp_div(FP_INT(lcu_per_frame *
collocated_bytes_per_lcu * fps), FP_INT(bps(1)));
collocated_write = collocated_read;
bitstream_read = fp_mult(fp_div(FP_INT(bitrate), FP_INT(8)),
FP_INT(bins_to_bit_factor));
bitstream_write = fp_div(FP_INT(bitrate), FP_INT(8));
bitstream_write = bitstream_write + bitstream_read;
total_read = orig_read + ref_y_read + ref_c_read +
lb_read + bse_read;
total_write = recon_write + lb_write + bse_write;
bse_lb_read + collocated_read + bitstream_read;
total_write = recon_write + bse_lb_write +
collocated_write + bitstream_write;
total = total_read + total_write;
total = fp_mult(total, overhead_factor);
@ -101,20 +109,21 @@ static unsigned long __calculate_encoder(struct vidc_bus_vote_data *d)
{"fps", "%d", fps},
{"bitrate (Mbit/sec)", "%lu", bitrate},
{"lcu size", "%d", lcu_size},
{"collocated byter per lcu", "%d", collocated_bytes_per_lcu},
{"horizontal search range", "%d", search_range_h},
{"vertical search range", "%d", search_range_v},
{"bins to bit factor", "%d", bins_to_bit_factor},
{"DERIVED PARAMETERS", "", DUMP_HEADER_MAGIC},
{"lcu/frame", "%d", lcu_per_frame},
{"vertical tile size", "%d", vertical_tile_size},
{"number of tiles", "%d", num_tiles},
{"Y BW", DUMP_FP_FMT, y_bw},
{"search range", "%d", search_range},
{"original read factor", DUMP_FP_FMT, orig_read_factor},
{"recon write factor", DUMP_FP_FMT, recon_write_factor},
{"ref read Y factor", DUMP_FP_FMT, ref_y_read_factor},
{"ref read C factor", DUMP_FP_FMT, ref_c_read_factor},
{"lb factor", DUMP_FP_FMT, lb_factor},
{"rest factor", DUMP_FP_FMT, rest_factor},
{"total_read_factor", DUMP_FP_FMT, total_read_factor},
{"total_write_factor", DUMP_FP_FMT, total_write_factor},
{"total_factor", DUMP_FP_FMT, total_factor},
{"overhead_factor", DUMP_FP_FMT, overhead_factor},
{"INTERMEDIATE B/W DDR", "", DUMP_HEADER_MAGIC},
@ -122,10 +131,12 @@ static unsigned long __calculate_encoder(struct vidc_bus_vote_data *d)
{"recon write", DUMP_FP_FMT, recon_write},
{"ref read Y", DUMP_FP_FMT, ref_y_read},
{"ref read C", DUMP_FP_FMT, ref_c_read},
{"lb read", DUMP_FP_FMT, lb_read},
{"lb write", DUMP_FP_FMT, lb_write},
{"bse read", DUMP_FP_FMT, bse_read},
{"bse write", DUMP_FP_FMT, bse_write},
{"BSE lb read", DUMP_FP_FMT, bse_lb_read},
{"BSE lb write", DUMP_FP_FMT, bse_lb_write},
{"collocated read", DUMP_FP_FMT, collocated_read},
{"collocated write", DUMP_FP_FMT, collocated_write},
{"bitstream read", DUMP_FP_FMT, bitstream_read},
{"bitstream write", DUMP_FP_FMT, bitstream_write},
{"total read", DUMP_FP_FMT, total_read},
{"total write", DUMP_FP_FMT, total_write},
{"total", DUMP_FP_FMT, total},
@ -142,24 +153,24 @@ static unsigned long __calculate_encoder(struct vidc_bus_vote_data *d)
static unsigned long __calculate_decoder(struct vidc_bus_vote_data *d)
{
/* Decoder parameters */
int width, height, fps, bitrate, lcu_size;
int width, height, fps, bitrate, lcu_size,
lcu_per_frame, collocated_bytes_per_lcu,
motion_complexity;
/* Derived parameters */
int lcu_per_frame, motion_complexity;
unsigned int bins_to_bits_factor, vsp_read_factor;
fp_t y_bw;
bool is_h264_category = true;
fp_t recon_write_factor, ref_read_factor, lb_factor,
rest_factor, opb_factor,
total_read_factor, total_write_factor,
total_factor, overhead_factor;
fp_t recon_write_factor, ref_read_factor,
opb_factor, overhead_factor;
/* Output parameters */
fp_t opb_write, recon_write,
ref_read,
lb_read, lb_write,
bse_read, bse_write,
total_read, total_write,
total;
ref_read,
bse_lb_read, bse_lb_write,
collocated_read, collocated_write,
bitstream_read, bitstream_write,
total_read, total_write,
total;
unsigned long ret = 0;
@ -167,8 +178,9 @@ static unsigned long __calculate_decoder(struct vidc_bus_vote_data *d)
overhead_factor = FP(1, 3, 100);
recon_write_factor = FP(1, 50, 100); /* L + C */
opb_factor = FP(1, 50, 100); /* L + C */
lb_factor = FP(1, 13, 100); /* Worst case : H264 1080p = 1.125 */
motion_complexity = 5; /* worst case complexity */
bins_to_bits_factor = 4;
vsp_read_factor = 6;
fps = d->fps;
width = max(d->output_width, BASELINE_DIMENSIONS.width);
@ -188,35 +200,42 @@ static unsigned long __calculate_decoder(struct vidc_bus_vote_data *d)
is_h264_category = false;
}
collocated_bytes_per_lcu = lcu_size == 16 ? 16 :
lcu_size == 32 ? 64 : 256;
y_bw = fp_mult(fp_mult(FP_INT(width), FP_INT(height)), FP_INT(fps));
y_bw = fp_div(y_bw, FP_INT(1000000));
y_bw = fp_div(y_bw, FP_INT(bps(1)));
ref_read_factor = FP(1, 50, 100); /* L + C */
ref_read_factor = fp_mult(ref_read_factor, FP_INT(motion_complexity));
rest_factor = FP_INT(bitrate) + fp_div(FP_INT(bitrate), FP_INT(8));
rest_factor = fp_div(rest_factor, y_bw);
total_read_factor = fp_div(rest_factor, FP_INT(2)) +
fp_div(lb_factor, FP_INT(2));
total_read_factor = total_read_factor + ref_read_factor;
total_write_factor = fp_div(rest_factor, FP_INT(2));
total_write_factor = total_write_factor +
recon_write_factor + opb_factor;
total_factor = total_read_factor + total_write_factor;
recon_write = fp_mult(y_bw, recon_write_factor);
ref_read = fp_mult(y_bw, ref_read_factor);
lb_read = fp_div(fp_mult(y_bw, lb_factor), FP_INT(2));
lb_write = lb_read;
bse_read = fp_div(fp_mult(y_bw, rest_factor), FP_INT(2));
bse_write = bse_read;
if (d->codec == HAL_VIDEO_CODEC_HEVC)
bse_lb_read = FP_INT(lcu_size == 32 ? 64 :
lcu_size == 16 ? 32 : 128);
else
bse_lb_read = FP_INT(128);
bse_lb_read = fp_div(fp_mult(FP_INT(lcu_per_frame * fps), bse_lb_read),
FP_INT(bps(1)));
bse_lb_write = bse_lb_read;
collocated_read = fp_div(FP_INT(lcu_per_frame *
collocated_bytes_per_lcu * fps), FP_INT(bps(1)));
collocated_write = collocated_read;
bitstream_read = fp_mult(fp_div(FP_INT(bitrate), FP_INT(8)),
FP_INT(vsp_read_factor));
bitstream_write = fp_mult(fp_div(FP_INT(bitrate), FP_INT(8)),
FP_INT(bins_to_bits_factor));
opb_write = fp_mult(y_bw, opb_factor);
total_read = ref_read + lb_read + bse_read;
total_write = recon_write + lb_write + bse_write + opb_write;
total_read = ref_read + bse_lb_read + collocated_read +
bitstream_read;
total_write = recon_write + bse_lb_write + bitstream_write +
opb_write;
total = total_read + total_write;
total = fp_mult(total, overhead_factor);
@ -229,28 +248,28 @@ static unsigned long __calculate_decoder(struct vidc_bus_vote_data *d)
{"fps", "%d", fps},
{"bitrate (Mbit/sec)", "%lu", bitrate},
{"lcu size", "%d", lcu_size},
{"collocated byter per lcu", "%d", collocated_bytes_per_lcu},
{"vsp read factor", "%d", vsp_read_factor},
{"bins to bits factor", "%d", bins_to_bits_factor},
{"motion complexity", "%d", motion_complexity},
{"DERIVED PARAMETERS", "", DUMP_HEADER_MAGIC},
{"lcu/frame", "%d", lcu_per_frame},
{"Y BW", DUMP_FP_FMT, y_bw},
{"motion complexity", "%d", motion_complexity},
{"recon write factor", DUMP_FP_FMT, recon_write_factor},
{"ref_read_factor", DUMP_FP_FMT, ref_read_factor},
{"lb factor", DUMP_FP_FMT, lb_factor},
{"rest factor", DUMP_FP_FMT, rest_factor},
{"opb factor", DUMP_FP_FMT, opb_factor},
{"total_read_factor", DUMP_FP_FMT, total_read_factor},
{"total_write_factor", DUMP_FP_FMT, total_write_factor},
{"total_factor", DUMP_FP_FMT, total_factor},
{"overhead_factor", DUMP_FP_FMT, overhead_factor},
{"INTERMEDIATE B/W DDR", "", DUMP_HEADER_MAGIC},
{"recon write", DUMP_FP_FMT, recon_write},
{"ref read", DUMP_FP_FMT, ref_read},
{"lb read", DUMP_FP_FMT, lb_read},
{"lb write", DUMP_FP_FMT, lb_write},
{"bse read", DUMP_FP_FMT, bse_read},
{"bse write", DUMP_FP_FMT, bse_write},
{"BSE lb read", DUMP_FP_FMT, bse_lb_read},
{"BSE lb write", DUMP_FP_FMT, bse_lb_write},
{"collocated read", DUMP_FP_FMT, collocated_read},
{"collocated write", DUMP_FP_FMT, collocated_write},
{"bitstream read", DUMP_FP_FMT, bitstream_read},
{"bitstream write", DUMP_FP_FMT, bitstream_write},
{"opb write", DUMP_FP_FMT, opb_write},
{"total read", DUMP_FP_FMT, total_read},
{"total write", DUMP_FP_FMT, total_write},

View file

@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2015-2019, The Linux Foundation. All rights reserved.
* Copyright (c) 2015-2020, The Linux Foundation. All rights reserved.
*/
#include "msm_vidc_bus.h"
@ -337,7 +337,7 @@ static unsigned long __calculate_encoder(struct vidc_bus_vote_data *d)
b_frames_enabled = d->b_frames_enabled;
original_color_format = d->num_formats >= 1 ?
d->color_formats[0] : HAL_UNUSED_COLOR;
d->color_formats[0] : HFI_COLOR_FORMAT_NV12_UBWC;
original_compression_enabled = __ubwc(original_color_format);

View file

@ -438,16 +438,16 @@ int msm_comm_vote_bus(struct msm_vidc_inst *inst)
if (msm_comm_get_stream_output_mode(inst) ==
HAL_VIDEO_DECODER_PRIMARY) {
vote_data->color_formats[0] =
msm_comm_get_hal_uncompressed(
inst->clk_data.opb_fourcc);
msm_comm_get_hfi_uncompressed(
inst->clk_data.opb_fourcc, inst->sid);
vote_data->num_formats = 1;
} else {
vote_data->color_formats[0] =
msm_comm_get_hal_uncompressed(
inst->clk_data.dpb_fourcc);
msm_comm_get_hfi_uncompressed(
inst->clk_data.dpb_fourcc, inst->sid);
vote_data->color_formats[1] =
msm_comm_get_hal_uncompressed(
inst->clk_data.opb_fourcc);
msm_comm_get_hfi_uncompressed(
inst->clk_data.opb_fourcc, inst->sid);
vote_data->num_formats = 2;
}
vote_data->work_mode = inst->clk_data.work_mode;
@ -701,9 +701,14 @@ static unsigned long msm_vidc_calc_freq_iris2(struct msm_vidc_inst *inst,
vpp_cycles = mbs_per_second * vpp_cycles_per_mb /
inst->clk_data.work_route;
/* 1.25 factor for IbP GOP structure */
if (msm_comm_g_ctrl_for_id(inst, V4L2_CID_MPEG_VIDEO_B_FRAMES))
/* Factor 1.25 for IbP and 1.375 for I1B2b1P GOP structure */
if (is_hier_b_session(inst)) {
vpp_cycles += (vpp_cycles / 4) + (vpp_cycles / 8);
} else if (msm_comm_g_ctrl_for_id(inst,
V4L2_CID_MPEG_VIDEO_B_FRAMES)) {
vpp_cycles += vpp_cycles / 4;
}
/* 21 / 20 is minimum overhead factor */
vpp_cycles += max(div_u64(vpp_cycles, 20), fw_vpp_cycles);
/* 1.01 is multi-pipe overhead */
@ -758,7 +763,8 @@ static unsigned long msm_vidc_calc_freq_iris2(struct msm_vidc_inst *inst,
/* VSP */
codec = get_v4l2_codec(inst);
base_cycles = inst->clk_data.entry->vsp_cycles;
base_cycles = inst->has_bframe ?
80 : inst->clk_data.entry->vsp_cycles;
vsp_cycles = fps * filled_len * 8;
if (codec == V4L2_PIX_FMT_VP9) {
@ -1293,6 +1299,7 @@ int msm_vidc_set_bse_vpp_delay(struct msm_vidc_inst *inst)
if (!inst->core->resources.has_vpp_delay ||
!is_decode_session(inst) ||
is_thumbnail_session(inst) ||
is_heif_decoder(inst) ||
inst->clk_data.work_mode != HFI_WORKMODE_2) {
s_vpr_hp(inst->sid, "%s: Skip bse-vpp\n", __func__);
return 0;

View file

@ -852,48 +852,13 @@ enum hal_video_codec get_hal_codec(int fourcc, u32 sid)
return codec;
}
enum hal_uncompressed_format msm_comm_get_hal_uncompressed(int fourcc)
{
enum hal_uncompressed_format format = HAL_UNUSED_COLOR;
switch (fourcc) {
case V4L2_PIX_FMT_NV12:
format = HAL_COLOR_FORMAT_NV12;
break;
case V4L2_PIX_FMT_NV12_512:
format = HAL_COLOR_FORMAT_NV12_512;
break;
case V4L2_PIX_FMT_NV21:
format = HAL_COLOR_FORMAT_NV21;
break;
case V4L2_PIX_FMT_NV12_UBWC:
format = HAL_COLOR_FORMAT_NV12_UBWC;
break;
case V4L2_PIX_FMT_NV12_TP10_UBWC:
format = HAL_COLOR_FORMAT_NV12_TP10_UBWC;
break;
case V4L2_PIX_FMT_SDE_Y_CBCR_H2V2_P010_VENUS:
format = HAL_COLOR_FORMAT_P010;
break;
case V4L2_PIX_FMT_RGBA8888_UBWC:
format = HAL_COLOR_FORMAT_RGBA8888_UBWC;
break;
default:
format = HAL_UNUSED_COLOR;
break;
}
return format;
}
u32 msm_comm_get_hfi_uncompressed(int fourcc, u32 sid)
{
u32 format;
switch (fourcc) {
case V4L2_PIX_FMT_NV12:
format = HFI_COLOR_FORMAT_NV12;
break;
case V4L2_PIX_FMT_NV12_128:
case V4L2_PIX_FMT_NV12_512:
format = HFI_COLOR_FORMAT_NV12;
break;
@ -2650,6 +2615,7 @@ static void handle_fbd(enum hal_command_response cmd, void *data)
break;
case HFI_PICTURE_TYPE_B:
mbuf->vvb.flags |= V4L2_BUF_FLAG_BFRAME;
inst->has_bframe = 1;
break;
case HFI_FRAME_NOTCODED:
case HFI_UNUSED_PICT:
@ -2839,6 +2805,7 @@ bool is_batching_allowed(struct msm_vidc_inst *inst)
is_decode_session(inst) &&
!is_thumbnail_session(inst) &&
is_realtime_session(inst) &&
!is_heif_decoder(inst) &&
!inst->clk_data.low_latency_mode &&
(op_pixelformat == V4L2_PIX_FMT_NV12_UBWC ||
op_pixelformat == V4L2_PIX_FMT_NV12_TP10_UBWC) &&
@ -3717,6 +3684,8 @@ u32 msm_comm_convert_color_fmt(u32 v4l2_fmt, u32 sid)
return COLOR_FMT_NV12;
case V4L2_PIX_FMT_NV21:
return COLOR_FMT_NV21;
case V4L2_PIX_FMT_NV12_128:
return COLOR_FMT_NV12_128;
case V4L2_PIX_FMT_NV12_512:
return COLOR_FMT_NV12_512;
case V4L2_PIX_FMT_SDE_Y_CBCR_H2V2_P010_VENUS:

View file

@ -121,6 +121,17 @@ static inline bool is_grid_session(struct msm_vidc_inst *inst)
return 0;
}
static inline bool is_heif_decoder(struct msm_vidc_inst *inst)
{
struct v4l2_ctrl *ctrl = NULL;
if (inst->session_type == MSM_VIDC_DECODER &&
get_v4l2_codec(inst) == V4L2_PIX_FMT_HEVC) {
ctrl = get_ctrl(inst, V4L2_CID_MPEG_VIDC_VDEC_HEIF_MODE);
return (ctrl->val > 0);
}
return 0;
}
static inline bool is_video_session(struct msm_vidc_inst *inst)
{
return !is_grid_session(inst);
@ -333,7 +344,6 @@ int msm_comm_get_v4l2_profile(int fourcc, int profile, u32 sid);
int msm_comm_get_v4l2_level(int fourcc, int level, u32 sid);
int msm_comm_session_continue(void *instance);
int msm_vidc_send_pending_eos_buffers(struct msm_vidc_inst *inst);
enum hal_uncompressed_format msm_comm_get_hal_uncompressed(int fourcc);
u32 msm_comm_get_hfi_uncompressed(int fourcc, u32 sid);
u32 msm_comm_convert_color_fmt(u32 v4l2_fmt, u32 sid);
struct vb2_buffer *msm_comm_get_vb_using_vidc_buffer(

View file

@ -15,7 +15,7 @@
#include <media/videobuf2-v4l2.h>
#include <linux/interconnect.h>
#include "msm_vidc.h"
#include <media/msm_media_info.h>
#include "vidc/media/msm_media_info.h"
#include "vidc_hfi_api.h"
#include "vidc_hfi_helper.h"
@ -411,7 +411,7 @@ struct vidc_bus_vote_data {
u32 sid;
enum hal_domain domain;
enum hal_video_codec codec;
enum hal_uncompressed_format color_formats[2];
u32 color_formats[2];
int num_formats; /* 1 = DPB-OPB unified; 2 = split */
int input_height, input_width, bitrate;
int output_height, output_width;
@ -574,6 +574,7 @@ struct msm_vidc_inst {
u32 first_reconfig_done;
u64 last_qbuf_time_ns;
bool active;
bool has_bframe;
};
extern struct msm_vidc_drv *vidc_driver;

View file

@ -448,7 +448,7 @@ static struct msm_vidc_codec_capability shima_capabilities_v0[] = {
{CAP_SCALE_Y, DEC, CODECS_ALL, 65536, 65536, 1, 65536},
{CAP_BFRAME, ENC, H264|HEVC, 0, 1, 1, 0},
{CAP_HIER_P_NUM_ENH_LAYERS, ENC, H264|HEVC, 0, 6, 1, 0},
{CAP_LTR_COUNT, ENC, H264|HEVC, 0, 4, 1, 0},
{CAP_LTR_COUNT, ENC, H264|HEVC, 0, 2, 1, 0},
/* ((1920 * 1088) / 256) * 60 fps */
{CAP_MBS_PER_SECOND_POWER_SAVE, ENC, CODECS_ALL,
0, 489600, 1, 489600},
@ -470,6 +470,16 @@ static struct msm_vidc_codec_capability shima_capabilities_v0[] = {
{CAP_FRAMERATE, DEC, MPEG2, 1, 30, 1, 30},
{CAP_BITRATE, DEC, MPEG2, 1, 40000000, 1, 20000000},
/* VP9 decoder-specific */
{CAP_FRAME_WIDTH, DEC, VP9, 96, 4096, 1, 1920},
{CAP_FRAME_HEIGHT, DEC, VP9, 96, 4096, 1, 1080},
/* (4096 * 2304) / 256 */
{CAP_MBS_PER_FRAME, DEC, VP9, 36, 36864, 1, 36864},
/* ((4096 * 2304) / 256) * 60 */
{CAP_MBS_PER_SECOND, DEC, VP9, 36, 2211840, 1, 2211840},
{CAP_FRAMERATE, DEC, VP9, 1, 60, 1, 60},
{CAP_BITRATE, DEC, VP9, 1, 100000000, 1, 20000000},
/* Secure usecase specific */
{CAP_SECURE_FRAME_WIDTH, DEC, CODECS_ALL, 96, 4096, 1, 1920},
{CAP_SECURE_FRAME_HEIGHT, DEC, CODECS_ALL, 96, 4096, 1, 1080},
@ -545,7 +555,7 @@ static struct msm_vidc_codec_capability shima_capabilities_v1[] = {
{CAP_SCALE_Y, DEC, CODECS_ALL, 65536, 65536, 1, 65536},
{CAP_BFRAME, ENC, H264|HEVC, 0, 1, 1, 0},
{CAP_HIER_P_NUM_ENH_LAYERS, ENC, H264|HEVC, 0, 6, 1, 0},
{CAP_LTR_COUNT, ENC, H264|HEVC, 0, 4, 1, 0},
{CAP_LTR_COUNT, ENC, H264|HEVC, 0, 2, 1, 0},
/* ((1920 * 1088) / 256) * 30 fps */
{CAP_MBS_PER_SECOND_POWER_SAVE, ENC, CODECS_ALL,
0, 244800, 1, 244800},
@ -567,6 +577,16 @@ static struct msm_vidc_codec_capability shima_capabilities_v1[] = {
{CAP_FRAMERATE, DEC, MPEG2, 1, 30, 1, 30},
{CAP_BITRATE, DEC, MPEG2, 1, 40000000, 1, 20000000},
/* VP9 decoder-specific */
{CAP_FRAME_WIDTH, DEC, VP9, 96, 4096, 1, 1920},
{CAP_FRAME_HEIGHT, DEC, VP9, 96, 4096, 1, 1080},
/* (4096 * 2304) / 256 */
{CAP_MBS_PER_FRAME, DEC, VP9, 36, 36864, 1, 36864},
/* ((4096 * 2304) / 256) * 60 */
{CAP_MBS_PER_SECOND, DEC, VP9, 36, 2211840, 1, 2211840},
{CAP_FRAMERATE, DEC, VP9, 1, 60, 1, 60},
{CAP_BITRATE, DEC, VP9, 1, 100000000, 1, 20000000},
/* Secure usecase specific */
{CAP_SECURE_FRAME_WIDTH, DEC, CODECS_ALL, 96, 4096, 1, 1920},
{CAP_SECURE_FRAME_HEIGHT, DEC, CODECS_ALL, 96, 4096, 1, 1080},
@ -663,6 +683,16 @@ static struct msm_vidc_codec_capability shima_capabilities_v2[] = {
{CAP_FRAMERATE, DEC, MPEG2, 1, 30, 1, 30},
{CAP_BITRATE, DEC, MPEG2, 1, 40000000, 1, 20000000},
/* VP9 decoder-specific */
{CAP_FRAME_WIDTH, DEC, VP9, 96, 4096, 1, 1920},
{CAP_FRAME_HEIGHT, DEC, VP9, 96, 4096, 1, 1080},
/* (4096 * 2304) / 256 */
{CAP_MBS_PER_FRAME, DEC, VP9, 36, 36864, 1, 36864},
/* ((4096 * 2304) / 256) * 30 */
{CAP_MBS_PER_SECOND, DEC, VP9, 36, 1105920, 1, 1105920},
{CAP_FRAMERATE, DEC, VP9, 1, 60, 1, 60},
{CAP_BITRATE, DEC, VP9, 1, 100000000, 1, 20000000},
/* Secure usecase specific */
{CAP_SECURE_FRAME_WIDTH, DEC, CODECS_ALL, 96, 4096, 1, 1920},
{CAP_SECURE_FRAME_HEIGHT, DEC, CODECS_ALL, 96, 4096, 1, 1080},

View file

@ -5,7 +5,7 @@
#ifndef __H_VIDC_HFI_H__
#define __H_VIDC_HFI_H__
#include <media/msm_media_info.h>
#include "vidc/media/msm_media_info.h"
#include "vidc_hfi_helper.h"
#include "vidc_hfi_api.h"

View file

@ -129,29 +129,6 @@ enum hal_video_codec {
HAL_UNUSED_CODEC = 0x10000000,
};
enum hal_uncompressed_format {
HAL_COLOR_FORMAT_MONOCHROME = 0x00000001,
HAL_COLOR_FORMAT_NV12 = 0x00000002,
HAL_COLOR_FORMAT_NV21 = 0x00000004,
HAL_COLOR_FORMAT_NV12_4x4TILE = 0x00000008,
HAL_COLOR_FORMAT_NV21_4x4TILE = 0x00000010,
HAL_COLOR_FORMAT_YUYV = 0x00000020,
HAL_COLOR_FORMAT_YVYU = 0x00000040,
HAL_COLOR_FORMAT_UYVY = 0x00000080,
HAL_COLOR_FORMAT_VYUY = 0x00000100,
HAL_COLOR_FORMAT_RGB565 = 0x00000200,
HAL_COLOR_FORMAT_BGR565 = 0x00000400,
HAL_COLOR_FORMAT_RGB888 = 0x00000800,
HAL_COLOR_FORMAT_BGR888 = 0x00001000,
HAL_COLOR_FORMAT_NV12_UBWC = 0x00002000,
HAL_COLOR_FORMAT_NV12_TP10_UBWC = 0x00004000,
HAL_COLOR_FORMAT_RGBA8888 = 0x00008000,
HAL_COLOR_FORMAT_RGBA8888_UBWC = 0x00010000,
HAL_COLOR_FORMAT_P010 = 0x00020000,
HAL_COLOR_FORMAT_NV12_512 = 0x00040000,
HAL_UNUSED_COLOR = 0x10000000,
};
enum hal_ssr_trigger_type {
SSR_ERR_FATAL = 1,
SSR_SW_DIV_BY_ZERO,

View file

@ -6,7 +6,7 @@
#ifndef __H_VIDC_HFI_HELPER_H__
#define __H_VIDC_HFI_HELPER_H__
#include <media/msm_vidc_utils.h>
#include "vidc/media/msm_vidc_utils.h"
#define HFI_COMMON_BASE (0)
#define HFI_OX_BASE (0x01000000)