video: driver: refine queue work functionality

[1] remove unwanted switch cases to reduce code complexity
[2] refine queue_response_work functionality.

Change-Id: I91aabb2eb4c64caea09a26895358544972a7d427
Signed-off-by: Govindaraj Rajagopal <grajagop@codeaurora.org>
此提交包含在:
Govindaraj Rajagopal
2021-03-08 21:49:09 +05:30
父節點 74f2907a9f
當前提交 6d97dd3795
共有 8 個檔案被更改,包括 752 行新增790 行删除

查看文件

@@ -455,91 +455,69 @@ static u32 msm_vidc_encoder_vpss_size_iris2(struct msm_vidc_inst* inst)
return size;
}
struct msm_vidc_buf_type_handle {
enum msm_vidc_buffer_type type;
u32 (*handle)(struct msm_vidc_inst *inst);
};
int msm_buffer_size_iris2(struct msm_vidc_inst *inst,
enum msm_vidc_buffer_type buffer_type)
{
int size = 0;
int i, size = 0;
u32 buf_type_handle_size = 0;
const struct msm_vidc_buf_type_handle *buf_type_handle_arr = NULL;
static const struct msm_vidc_buf_type_handle dec_buf_type_handle[] = {
{MSM_VIDC_BUF_INPUT, msm_vidc_decoder_input_size },
{MSM_VIDC_BUF_OUTPUT, msm_vidc_decoder_output_size },
{MSM_VIDC_BUF_INPUT_META, msm_vidc_decoder_input_meta_size },
{MSM_VIDC_BUF_OUTPUT_META, msm_vidc_decoder_output_meta_size },
{MSM_VIDC_BUF_BIN, msm_vidc_decoder_bin_size_iris2 },
{MSM_VIDC_BUF_COMV, msm_vidc_decoder_comv_size_iris2 },
{MSM_VIDC_BUF_NON_COMV, msm_vidc_decoder_non_comv_size_iris2 },
{MSM_VIDC_BUF_LINE, msm_vidc_decoder_line_size_iris2 },
{MSM_VIDC_BUF_PERSIST, msm_vidc_decoder_persist_size_iris2 },
{MSM_VIDC_BUF_DPB, msm_vidc_decoder_dpb_size_iris2 },
};
static const struct msm_vidc_buf_type_handle enc_buf_type_handle[] = {
{MSM_VIDC_BUF_INPUT, msm_vidc_encoder_input_size },
{MSM_VIDC_BUF_OUTPUT, msm_vidc_encoder_output_size },
{MSM_VIDC_BUF_INPUT_META, msm_vidc_encoder_input_meta_size },
{MSM_VIDC_BUF_OUTPUT_META, msm_vidc_encoder_output_meta_size },
{MSM_VIDC_BUF_BIN, msm_vidc_encoder_bin_size_iris2 },
{MSM_VIDC_BUF_COMV, msm_vidc_encoder_comv_size_iris2 },
{MSM_VIDC_BUF_NON_COMV, msm_vidc_encoder_non_comv_size_iris2 },
{MSM_VIDC_BUF_LINE, msm_vidc_encoder_line_size_iris2 },
{MSM_VIDC_BUF_DPB, msm_vidc_encoder_dpb_size_iris2 },
{MSM_VIDC_BUF_ARP, msm_vidc_encoder_arp_size_iris2 },
{MSM_VIDC_BUF_VPSS, msm_vidc_encoder_vpss_size_iris2 },
};
if (!inst) {
d_vpr_e("%s: invalid params\n", __func__);
if (is_decode_session(inst)) {
buf_type_handle_size = ARRAY_SIZE(dec_buf_type_handle);
buf_type_handle_arr = dec_buf_type_handle;
} else if (is_encode_session(inst)) {
buf_type_handle_size = ARRAY_SIZE(enc_buf_type_handle);
buf_type_handle_arr = enc_buf_type_handle;
}
/* handle invalid session */
if (!buf_type_handle_arr || !buf_type_handle_size) {
i_vpr_e(inst, "%s: invalid session %d\n", __func__, inst->domain);
return size;
}
if (is_decode_session(inst)) {
switch (buffer_type) {
case MSM_VIDC_BUF_INPUT:
size = msm_vidc_decoder_input_size(inst);
break;
case MSM_VIDC_BUF_OUTPUT:
size = msm_vidc_decoder_output_size(inst);
break;
case MSM_VIDC_BUF_INPUT_META:
size = msm_vidc_decoder_input_meta_size(inst);
break;
case MSM_VIDC_BUF_OUTPUT_META:
size = msm_vidc_decoder_output_meta_size(inst);
break;
case MSM_VIDC_BUF_BIN:
size = msm_vidc_decoder_bin_size_iris2(inst);
break;
case MSM_VIDC_BUF_COMV:
size = msm_vidc_decoder_comv_size_iris2(inst);
break;
case MSM_VIDC_BUF_NON_COMV:
size = msm_vidc_decoder_non_comv_size_iris2(inst);
break;
case MSM_VIDC_BUF_LINE:
size = msm_vidc_decoder_line_size_iris2(inst);
break;
case MSM_VIDC_BUF_PERSIST:
size = msm_vidc_decoder_persist_size_iris2(inst);
break;
case MSM_VIDC_BUF_DPB:
size = msm_vidc_decoder_dpb_size_iris2(inst);
break;
default:
break;
}
} else if (is_encode_session(inst)) {
switch (buffer_type) {
case MSM_VIDC_BUF_INPUT:
size = msm_vidc_encoder_input_size(inst);
break;
case MSM_VIDC_BUF_OUTPUT:
size = msm_vidc_encoder_output_size(inst);
break;
case MSM_VIDC_BUF_INPUT_META:
size = msm_vidc_encoder_input_meta_size(inst);
break;
case MSM_VIDC_BUF_OUTPUT_META:
size = msm_vidc_encoder_output_meta_size(inst);
break;
case MSM_VIDC_BUF_BIN:
size = msm_vidc_encoder_bin_size_iris2(inst);
break;
case MSM_VIDC_BUF_COMV:
size = msm_vidc_encoder_comv_size_iris2(inst);
break;
case MSM_VIDC_BUF_NON_COMV:
size = msm_vidc_encoder_non_comv_size_iris2(inst);
break;
case MSM_VIDC_BUF_LINE:
size = msm_vidc_encoder_line_size_iris2(inst);
break;
case MSM_VIDC_BUF_DPB:
size = msm_vidc_encoder_dpb_size_iris2(inst);
break;
case MSM_VIDC_BUF_ARP:
size = msm_vidc_encoder_arp_size_iris2(inst);
break;
case MSM_VIDC_BUF_VPSS:
size = msm_vidc_encoder_vpss_size_iris2(inst);
break;
default:
/* fetch buffer size */
for (i = 0; i < buf_type_handle_size; i++) {
if (buf_type_handle_arr[i].type == buffer_type) {
size = buf_type_handle_arr[i].handle(inst);
break;
}
}
/* handle unknown buffer type */
if (i == buf_type_handle_size)
i_vpr_e(inst, "%s: unknown buffer type %#x\n", __func__, buffer_type);
return size;
}

查看文件

@@ -185,6 +185,7 @@ static inline bool is_session_error(struct msm_vidc_inst* inst)
return inst->state == MSM_VIDC_ERROR;
}
const char *cap_name(enum msm_vidc_inst_capability_type cap);
void print_vidc_buffer(u32 tag, const char *tag_str, const char *str, struct msm_vidc_inst *inst,
struct msm_vidc_buffer *vbuf);
void print_vb2_buffer(const char *str, struct msm_vidc_inst *inst,

查看文件

@@ -22,7 +22,7 @@
#define MAX_DEC_BATCH_SIZE 6
#define SKIP_BATCH_WINDOW 100
u32 msm_vdec_subscribe_for_psc_avc[] = {
static const u32 msm_vdec_subscribe_for_psc_avc[] = {
HFI_PROP_BITSTREAM_RESOLUTION,
HFI_PROP_CROP_OFFSETS,
HFI_PROP_CODED_FRAMES,
@@ -33,7 +33,7 @@ u32 msm_vdec_subscribe_for_psc_avc[] = {
HFI_PROP_SIGNAL_COLOR_INFO,
};
u32 msm_vdec_subscribe_for_psc_hevc[] = {
static const u32 msm_vdec_subscribe_for_psc_hevc[] = {
HFI_PROP_BITSTREAM_RESOLUTION,
HFI_PROP_CROP_OFFSETS,
HFI_PROP_LUMA_CHROMA_BIT_DEPTH,
@@ -44,7 +44,7 @@ u32 msm_vdec_subscribe_for_psc_hevc[] = {
HFI_PROP_SIGNAL_COLOR_INFO,
};
u32 msm_vdec_subscribe_for_psc_vp9[] = {
static const u32 msm_vdec_subscribe_for_psc_vp9[] = {
HFI_PROP_BITSTREAM_RESOLUTION,
HFI_PROP_CROP_OFFSETS,
HFI_PROP_LUMA_CHROMA_BIT_DEPTH,
@@ -53,16 +53,28 @@ u32 msm_vdec_subscribe_for_psc_vp9[] = {
HFI_PROP_LEVEL,
};
u32 msm_vdec_input_subscribe_for_properties[] = {
static const u32 msm_vdec_input_subscribe_for_properties[] = {
HFI_PROP_NO_OUTPUT,
HFI_PROP_CABAC_SESSION,
};
u32 msm_vdec_output_subscribe_for_properties[] = {
static const u32 msm_vdec_output_subscribe_for_properties[] = {
HFI_PROP_WORST_COMPRESSION_RATIO,
HFI_PROP_WORST_COMPLEXITY_FACTOR,
};
static const u32 msm_vdec_internal_buffer_type[] = {
MSM_VIDC_BUF_BIN,
MSM_VIDC_BUF_COMV,
MSM_VIDC_BUF_NON_COMV,
MSM_VIDC_BUF_LINE,
};
struct msm_vdec_prop_type_handle {
u32 type;
int (*handle)(struct msm_vidc_inst *inst, enum msm_vidc_port_type port);
};
static int msm_vdec_codec_change(struct msm_vidc_inst *inst, u32 v4l2_codec)
{
int rc = 0;
@@ -817,27 +829,18 @@ static int msm_vdec_set_output_properties(struct msm_vidc_inst *inst)
static int msm_vdec_get_input_internal_buffers(struct msm_vidc_inst *inst)
{
int rc = 0;
u32 i = 0;
if (!inst) {
d_vpr_e("%s: invalid params\n", __func__);
return -EINVAL;
}
rc = msm_vidc_get_internal_buffers(inst, MSM_VIDC_BUF_BIN);
if (rc)
return rc;
rc = msm_vidc_get_internal_buffers(inst, MSM_VIDC_BUF_COMV);
if (rc)
return rc;
rc = msm_vidc_get_internal_buffers(inst, MSM_VIDC_BUF_NON_COMV);
if (rc)
return rc;
rc = msm_vidc_get_internal_buffers(inst, MSM_VIDC_BUF_LINE);
if (rc)
return rc;
for (i = 0; i < ARRAY_SIZE(msm_vdec_internal_buffer_type); i++) {
rc = msm_vidc_get_internal_buffers(inst, msm_vdec_internal_buffer_type[i]);
if (rc)
return rc;
}
i_vpr_h(inst, "input internal buffer: min size reuse\n");
i_vpr_h(inst, "bin buffer: %d %d %d\n",
@@ -885,25 +888,14 @@ static int msm_vdec_get_output_internal_buffers(struct msm_vidc_inst *inst)
static int msm_vdec_create_input_internal_buffers(struct msm_vidc_inst *inst)
{
int rc = 0;
u32 i = 0;
if (!inst || !inst->core) {
d_vpr_e("%s: invalid params\n", __func__);
return -EINVAL;
for (i = 0; i < ARRAY_SIZE(msm_vdec_internal_buffer_type); i++) {
rc = msm_vidc_create_internal_buffers(inst, msm_vdec_internal_buffer_type[i]);
if (rc)
return rc;
}
rc = msm_vidc_create_internal_buffers(inst, MSM_VIDC_BUF_BIN);
if (rc)
return rc;
rc = msm_vidc_create_internal_buffers(inst, MSM_VIDC_BUF_COMV);
if (rc)
return rc;
rc = msm_vidc_create_internal_buffers(inst, MSM_VIDC_BUF_NON_COMV);
if (rc)
return rc;
rc = msm_vidc_create_internal_buffers(inst, MSM_VIDC_BUF_LINE);
if (rc)
return rc;
return 0;
}
@@ -911,11 +903,6 @@ static int msm_vdec_create_output_internal_buffers(struct msm_vidc_inst *inst)
{
int rc = 0;
if (!inst || !inst->core) {
d_vpr_e("%s: invalid params\n", __func__);
return -EINVAL;
}
rc = msm_vidc_create_internal_buffers(inst, MSM_VIDC_BUF_DPB);
if (rc)
return rc;
@@ -926,25 +913,14 @@ static int msm_vdec_create_output_internal_buffers(struct msm_vidc_inst *inst)
static int msm_vdec_queue_input_internal_buffers(struct msm_vidc_inst *inst)
{
int rc = 0;
u32 i = 0;
if (!inst || !inst->core) {
d_vpr_e("%s: invalid params\n", __func__);
return -EINVAL;
for (i = 0; i < ARRAY_SIZE(msm_vdec_internal_buffer_type); i++) {
rc = msm_vidc_queue_internal_buffers(inst, msm_vdec_internal_buffer_type[i]);
if (rc)
return rc;
}
rc = msm_vidc_queue_internal_buffers(inst, MSM_VIDC_BUF_BIN);
if (rc)
return rc;
rc = msm_vidc_queue_internal_buffers(inst, MSM_VIDC_BUF_COMV);
if (rc)
return rc;
rc = msm_vidc_queue_internal_buffers(inst, MSM_VIDC_BUF_NON_COMV);
if (rc)
return rc;
rc = msm_vidc_queue_internal_buffers(inst, MSM_VIDC_BUF_LINE);
if (rc)
return rc;
return 0;
}
@@ -952,11 +928,6 @@ static int msm_vdec_queue_output_internal_buffers(struct msm_vidc_inst *inst)
{
int rc = 0;
if (!inst || !inst->core) {
d_vpr_e("%s: invalid params\n", __func__);
return -EINVAL;
}
rc = msm_vidc_queue_internal_buffers(inst, MSM_VIDC_BUF_DPB);
if (rc)
return rc;
@@ -967,25 +938,15 @@ static int msm_vdec_queue_output_internal_buffers(struct msm_vidc_inst *inst)
static int msm_vdec_release_input_internal_buffers(struct msm_vidc_inst *inst)
{
int rc = 0;
u32 i = 0;
if (!inst || !inst->core) {
d_vpr_e("%s: invalid params\n", __func__);
return -EINVAL;
}
i_vpr_h(inst, "%s()\n",__func__);
rc = msm_vidc_release_internal_buffers(inst, MSM_VIDC_BUF_BIN);
if (rc)
return rc;
rc = msm_vidc_release_internal_buffers(inst, MSM_VIDC_BUF_COMV);
if (rc)
return rc;
rc = msm_vidc_release_internal_buffers(inst, MSM_VIDC_BUF_NON_COMV);
if (rc)
return rc;
rc = msm_vidc_release_internal_buffers(inst, MSM_VIDC_BUF_LINE);
if (rc)
return rc;
for (i = 0; i < ARRAY_SIZE(msm_vdec_internal_buffer_type); i++) {
rc = msm_vidc_release_internal_buffers(inst, msm_vdec_internal_buffer_type[i]);
if (rc)
return rc;
}
return 0;
}
@@ -994,12 +955,7 @@ static int msm_vdec_release_output_internal_buffers(struct msm_vidc_inst *inst)
{
int rc = 0;
if (!inst || !inst->core) {
d_vpr_e("%s: invalid params\n", __func__);
return -EINVAL;
}
i_vpr_h(inst, "%s()\n",__func__);
rc = msm_vidc_release_internal_buffers(inst, MSM_VIDC_BUF_DPB);
if (rc)
return rc;
@@ -1013,9 +969,21 @@ static int msm_vdec_subscribe_input_port_settings_change(struct msm_vidc_inst *i
int rc = 0;
struct msm_vidc_core *core;
u32 payload[32] = {0};
u32 i;
u32 subscribe_psc_size = 0;
u32 *psc = NULL;
u32 i, j;
u32 subscribe_psc_size;
const u32 *psc;
static const struct msm_vdec_prop_type_handle prop_type_handle_arr[] = {
{HFI_PROP_BITSTREAM_RESOLUTION, msm_vdec_set_bitstream_resolution },
{HFI_PROP_CROP_OFFSETS, msm_vdec_set_crop_offsets },
{HFI_PROP_LUMA_CHROMA_BIT_DEPTH, msm_vdec_set_bit_depth },
{HFI_PROP_CODED_FRAMES, msm_vdec_set_coded_frames },
{HFI_PROP_BUFFER_FW_MIN_OUTPUT_COUNT, msm_vdec_set_min_output_count },
{HFI_PROP_PIC_ORDER_CNT_TYPE, msm_vdec_set_picture_order_count },
{HFI_PROP_SIGNAL_COLOR_INFO, msm_vdec_set_colorspace },
{HFI_PROP_PROFILE, msm_vdec_set_profile },
{HFI_PROP_LEVEL, msm_vdec_set_level },
{HFI_PROP_TIER, msm_vdec_set_tier },
};
if (!inst || !inst->core) {
d_vpr_e("%s: invalid params\n", __func__);
@@ -1057,46 +1025,19 @@ static int msm_vdec_subscribe_input_port_settings_change(struct msm_vidc_inst *i
sizeof(u32)));
for (i = 0; i < subscribe_psc_size; i++) {
switch (psc[i]) {
case HFI_PROP_BITSTREAM_RESOLUTION:
rc = msm_vdec_set_bitstream_resolution(inst, port);
break;
case HFI_PROP_CROP_OFFSETS:
rc = msm_vdec_set_crop_offsets(inst, port);
break;
case HFI_PROP_LUMA_CHROMA_BIT_DEPTH:
rc = msm_vdec_set_bit_depth(inst, port);
break;
case HFI_PROP_CODED_FRAMES:
rc = msm_vdec_set_coded_frames(inst, port);
break;
case HFI_PROP_BUFFER_FW_MIN_OUTPUT_COUNT:
rc = msm_vdec_set_min_output_count(inst, port);
break;
case HFI_PROP_PIC_ORDER_CNT_TYPE:
rc = msm_vdec_set_picture_order_count(inst, port);
break;
case HFI_PROP_SIGNAL_COLOR_INFO:
rc = msm_vdec_set_colorspace(inst, port);
break;
case HFI_PROP_PROFILE:
rc = msm_vdec_set_profile(inst, port);
break;
case HFI_PROP_LEVEL:
rc = msm_vdec_set_level(inst, port);
break;
case HFI_PROP_TIER:
rc = msm_vdec_set_tier(inst, port);
break;
default:
i_vpr_e(inst, "%s: unknown property %#x\n", __func__,
psc[i]);
rc = -EINVAL;
break;
/* set session properties */
for (j = 0; j < ARRAY_SIZE(prop_type_handle_arr); j++) {
if (prop_type_handle_arr[j].type == psc[i]) {
rc = prop_type_handle_arr[j].handle(inst, port);
if (rc)
goto exit;
break;
}
}
if (rc)
goto exit;
/* is property type unknown ? */
if (j == ARRAY_SIZE(prop_type_handle_arr))
i_vpr_e(inst, "%s: unknown property %#x\n", __func__, psc[i]);
}
exit:
@@ -1156,7 +1097,7 @@ static int msm_vdec_subscribe_metadata(struct msm_vidc_inst *inst,
u32 payload[32] = {0};
u32 i, count = 0;
struct msm_vidc_inst_capability *capability;
u32 metadata_list[] = {
static const u32 metadata_list[] = {
META_DPB_MISR,
META_OPB_MISR,
META_INTERLACE,
@@ -1209,7 +1150,7 @@ static int msm_vdec_set_delivery_mode_metadata(struct msm_vidc_inst *inst,
u32 payload[32] = {0};
u32 i, count = 0;
struct msm_vidc_inst_capability *capability;
u32 metadata_list[] = {
static const u32 metadata_list[] = {
META_BUF_TAG,
};
@@ -1248,12 +1189,7 @@ static int msm_vdec_session_resume(struct msm_vidc_inst *inst,
{
int rc = 0;
if (!inst) {
d_vpr_e("%s: invalid params\n", __func__);
return -EINVAL;
}
i_vpr_h(inst, "%s()\n", __func__);
rc = venus_hfi_session_command(inst,
HFI_CMD_RESUME,
port,
@@ -1631,7 +1567,7 @@ static int msm_vdec_subscribe_output_port_settings_change(struct msm_vidc_inst *
u32 i;
struct msm_vidc_subscription_params subsc_params;
u32 subscribe_psc_size = 0;
u32 *psc = NULL;
const u32 *psc = NULL;
if (!inst) {
d_vpr_e("%s: invalid params\n", __func__);

查看文件

@@ -17,7 +17,7 @@
#include "venus_hfi.h"
#include "hfi_packet.h"
u32 msm_venc_input_set_prop[] = {
static const u32 msm_venc_input_set_prop[] = {
HFI_PROP_COLOR_FORMAT,
HFI_PROP_RAW_RESOLUTION,
HFI_PROP_LINEAR_STRIDE_SCANLINE,
@@ -25,23 +25,36 @@ u32 msm_venc_input_set_prop[] = {
HFI_PROP_SIGNAL_COLOR_INFO,
};
u32 msm_venc_output_set_prop[] = {
static const u32 msm_venc_output_set_prop[] = {
HFI_PROP_BITSTREAM_RESOLUTION,
HFI_PROP_CROP_OFFSETS,
HFI_PROP_BUFFER_HOST_MAX_COUNT,
HFI_PROP_CSC,
};
u32 msm_venc_input_subscribe_for_properties[] = {
static const u32 msm_venc_input_subscribe_for_properties[] = {
HFI_PROP_NO_OUTPUT,
};
u32 msm_venc_output_subscribe_for_properties[] = {
static const u32 msm_venc_output_subscribe_for_properties[] = {
HFI_PROP_PICTURE_TYPE,
HFI_PROP_BUFFER_MARK,
HFI_PROP_WORST_COMPRESSION_RATIO,
};
static const u32 msm_venc_internal_buffer_type[] = {
MSM_VIDC_BUF_BIN,
MSM_VIDC_BUF_COMV,
MSM_VIDC_BUF_NON_COMV,
MSM_VIDC_BUF_LINE,
MSM_VIDC_BUF_DPB,
};
struct msm_venc_prop_type_handle {
u32 type;
int (*handle)(struct msm_vidc_inst *inst, enum msm_vidc_port_type port);
};
static int msm_venc_codec_change(struct msm_vidc_inst *inst, u32 v4l2_codec)
{
int rc = 0;
@@ -458,42 +471,36 @@ static int msm_venc_set_quality_mode(struct msm_vidc_inst *inst)
static int msm_venc_set_input_properties(struct msm_vidc_inst *inst)
{
int rc = 0;
int i = 0;
int i, j, rc = 0;
static const struct msm_venc_prop_type_handle prop_type_handle_arr[] = {
{HFI_PROP_COLOR_FORMAT, msm_venc_set_colorformat },
{HFI_PROP_RAW_RESOLUTION, msm_venc_set_raw_resolution },
{HFI_PROP_LINEAR_STRIDE_SCANLINE, msm_venc_set_linear_alignment_factor },
{HFI_PROP_BUFFER_HOST_MAX_COUNT, msm_venc_set_host_max_buf_count },
{HFI_PROP_SIGNAL_COLOR_INFO, msm_venc_set_colorspace },
};
if (!inst) {
d_vpr_e("%s: invalid params\n", __func__);
return -EINVAL;
}
i_vpr_h(inst, "%s()\n", __func__);
for (i = 0; i < ARRAY_SIZE(msm_venc_input_set_prop);
i++) {
switch (msm_venc_input_set_prop[i]) {
case HFI_PROP_COLOR_FORMAT:
rc = msm_venc_set_colorformat(inst, INPUT_PORT);
break;
case HFI_PROP_RAW_RESOLUTION:
rc = msm_venc_set_raw_resolution(inst, INPUT_PORT);
break;
case HFI_PROP_LINEAR_STRIDE_SCANLINE:
rc = msm_venc_set_linear_alignment_factor(inst, INPUT_PORT);
break;
case HFI_PROP_BUFFER_HOST_MAX_COUNT:
rc = msm_venc_set_host_max_buf_count(inst, INPUT_PORT);
break;
case HFI_PROP_SIGNAL_COLOR_INFO:
rc = msm_venc_set_colorspace(inst, INPUT_PORT);
break;
default:
i_vpr_e(inst, "%s: unknown property %#x\n", __func__,
msm_venc_input_set_prop[i]);
rc = -EINVAL;
break;
i_vpr_h(inst, "%s()\n", __func__);
for (i = 0; i < ARRAY_SIZE(msm_venc_input_set_prop); i++) {
/* set session input properties */
for (j = 0; j < ARRAY_SIZE(prop_type_handle_arr); j++) {
if (prop_type_handle_arr[j].type == msm_venc_input_set_prop[i]) {
rc = prop_type_handle_arr[j].handle(inst, INPUT_PORT);
if (rc)
goto exit;
break;
}
}
if (rc)
goto exit;
/* is property type unknown ? */
if (j == ARRAY_SIZE(prop_type_handle_arr))
i_vpr_e(inst, "%s: unknown property %#x\n", __func__,
msm_venc_input_set_prop[i]);
}
exit:
@@ -502,39 +509,35 @@ exit:
static int msm_venc_set_output_properties(struct msm_vidc_inst *inst)
{
int rc = 0;
int i = 0;
int i, j, rc = 0;
static const struct msm_venc_prop_type_handle prop_type_handle_arr[] = {
{HFI_PROP_BITSTREAM_RESOLUTION, msm_venc_set_bitstream_resolution },
{HFI_PROP_CROP_OFFSETS, msm_venc_set_crop_offsets },
{HFI_PROP_BUFFER_HOST_MAX_COUNT, msm_venc_set_host_max_buf_count },
{HFI_PROP_CSC, msm_venc_set_csc },
};
if (!inst) {
d_vpr_e("%s: invalid params\n", __func__);
return -EINVAL;
}
i_vpr_h(inst, "%s()\n", __func__);
for (i = 0; i < ARRAY_SIZE(msm_venc_output_set_prop);
i++) {
switch (msm_venc_output_set_prop[i]) {
case HFI_PROP_BITSTREAM_RESOLUTION:
rc = msm_venc_set_bitstream_resolution(inst, OUTPUT_PORT);
break;
case HFI_PROP_CROP_OFFSETS:
rc = msm_venc_set_crop_offsets(inst, OUTPUT_PORT);
break;
case HFI_PROP_BUFFER_HOST_MAX_COUNT:
rc = msm_venc_set_host_max_buf_count(inst, OUTPUT_PORT);
break;
case HFI_PROP_CSC:
rc = msm_venc_set_csc(inst, OUTPUT_PORT);
break;
default:
i_vpr_e(inst, "%s: unknown property %#x\n", __func__,
msm_venc_output_set_prop[i]);
rc = -EINVAL;
break;
i_vpr_h(inst, "%s()\n", __func__);
for (i = 0; i < ARRAY_SIZE(msm_venc_output_set_prop); i++) {
/* set session output properties */
for (j = 0; j < ARRAY_SIZE(prop_type_handle_arr); j++) {
if (prop_type_handle_arr[j].type == msm_venc_output_set_prop[i]) {
rc = prop_type_handle_arr[j].handle(inst, OUTPUT_PORT);
if (rc)
goto exit;
break;
}
}
if (rc)
goto exit;
/* is property type unknown ? */
if (j == ARRAY_SIZE(prop_type_handle_arr))
i_vpr_e(inst, "%s: unknown property %#x\n", __func__,
msm_venc_output_set_prop[i]);
}
exit:
@@ -628,7 +631,7 @@ static int msm_venc_queue_input_internal_buffers(struct msm_vidc_inst *inst)
static int msm_venc_get_output_internal_buffers(struct msm_vidc_inst *inst)
{
int rc = 0;
int i, rc = 0;
struct msm_vidc_core *core;
if (!inst || !inst->core) {
@@ -637,25 +640,11 @@ static int msm_venc_get_output_internal_buffers(struct msm_vidc_inst *inst)
}
core = inst->core;
rc = msm_vidc_get_internal_buffers(inst, MSM_VIDC_BUF_BIN);
if (rc)
return rc;
rc = msm_vidc_get_internal_buffers(inst, MSM_VIDC_BUF_COMV);
if (rc)
return rc;
rc = msm_vidc_get_internal_buffers(inst, MSM_VIDC_BUF_NON_COMV);
if (rc)
return rc;
rc = msm_vidc_get_internal_buffers(inst, MSM_VIDC_BUF_LINE);
if (rc)
return rc;
rc = msm_vidc_get_internal_buffers(inst, MSM_VIDC_BUF_DPB);
if (rc)
return rc;
for (i = 0; i < ARRAY_SIZE(msm_venc_internal_buffer_type); i++) {
rc = msm_vidc_get_internal_buffers(inst, msm_venc_internal_buffer_type[i]);
if (rc)
return rc;
}
i_vpr_h(inst, "internal buffer: min size\n");
i_vpr_h(inst, "bin buffer: %d %d\n",
@@ -679,56 +668,36 @@ static int msm_venc_get_output_internal_buffers(struct msm_vidc_inst *inst)
static int msm_venc_create_output_internal_buffers(struct msm_vidc_inst *inst)
{
int rc = 0;
int i, rc = 0;
if (!inst || !inst->core) {
d_vpr_e("%s: invalid params\n", __func__);
return -EINVAL;
}
rc = msm_vidc_create_internal_buffers(inst, MSM_VIDC_BUF_BIN);
if (rc)
return rc;
rc = msm_vidc_create_internal_buffers(inst, MSM_VIDC_BUF_COMV);
if (rc)
return rc;
rc = msm_vidc_create_internal_buffers(inst, MSM_VIDC_BUF_NON_COMV);
if (rc)
return rc;
rc = msm_vidc_create_internal_buffers(inst, MSM_VIDC_BUF_LINE);
if (rc)
return rc;
rc = msm_vidc_create_internal_buffers(inst, MSM_VIDC_BUF_DPB);
if (rc)
return rc;
for (i = 0; i < ARRAY_SIZE(msm_venc_internal_buffer_type); i++) {
rc = msm_vidc_create_internal_buffers(inst, msm_venc_internal_buffer_type[i]);
if (rc)
return rc;
}
return 0;
}
static int msm_venc_queue_output_internal_buffers(struct msm_vidc_inst *inst)
{
int rc = 0;
int i, rc = 0;
if (!inst || !inst->core) {
d_vpr_e("%s: invalid params\n", __func__);
return -EINVAL;
}
rc = msm_vidc_queue_internal_buffers(inst, MSM_VIDC_BUF_BIN);
if (rc)
return rc;
rc = msm_vidc_queue_internal_buffers(inst, MSM_VIDC_BUF_COMV);
if (rc)
return rc;
rc = msm_vidc_queue_internal_buffers(inst, MSM_VIDC_BUF_NON_COMV);
if (rc)
return rc;
rc = msm_vidc_queue_internal_buffers(inst, MSM_VIDC_BUF_LINE);
if (rc)
return rc;
rc = msm_vidc_queue_internal_buffers(inst, MSM_VIDC_BUF_DPB);
if (rc)
return rc;
for (i = 0; i < ARRAY_SIZE(msm_venc_internal_buffer_type); i++) {
rc = msm_vidc_queue_internal_buffers(inst, msm_venc_internal_buffer_type[i]);
if (rc)
return rc;
}
return 0;
}
@@ -783,7 +752,7 @@ static int msm_venc_metadata_delivery(struct msm_vidc_inst *inst,
u32 payload[32] = {0};
u32 i, count = 0;
struct msm_vidc_inst_capability *capability;
u32 metadata_list[] = {
static const u32 metadata_list[] = {
META_SEI_MASTERING_DISP,
META_SEI_CLL,
META_HDR10PLUS,
@@ -831,7 +800,7 @@ static int msm_venc_metadata_subscription(struct msm_vidc_inst *inst,
u32 payload[32] = {0};
u32 i, count = 0;
struct msm_vidc_inst_capability *capability;
u32 metadata_list[] = {
static const u32 metadata_list[] = {
META_LTR_MARK_USE,
META_SEQ_HDR_NAL,
META_TIMESTAMP,

查看文件

@@ -119,135 +119,6 @@ static const char * const * msm_vidc_get_qmenu_type(
}
}
static const char *msm_vidc_get_priv_ctrl_name_list2(struct msm_vidc_inst *inst,
u32 control_id)
{
switch (control_id) {
case V4L2_CID_MPEG_VIDC_HEVC_I_FRAME_MIN_QP:
return "HEVC I Frame Min QP";
case V4L2_CID_MPEG_VIDC_HEVC_P_FRAME_MIN_QP:
return "HEVC P Frame Min QP";
case V4L2_CID_MPEG_VIDC_HEVC_I_FRAME_MAX_QP:
return "HEVC I Frame Max QP";
case V4L2_CID_MPEG_VIDC_HEVC_P_FRAME_MAX_QP:
return "HEVC P Frame Max QP";
case V4L2_CID_MPEG_VIDC_METADATA_LTR_MARK_USE_DETAILS:
return "LTR Mark Use Details Metadata";
case V4L2_CID_MPEG_VIDC_METADATA_SEQ_HEADER_NAL:
return "Seq Header NAL Metadata";
case V4L2_CID_MPEG_VIDC_METADATA_DPB_LUMA_CHROMA_MISR:
return "DPB Luma-Chroma MISR Metadata";
case V4L2_CID_MPEG_VIDC_METADATA_OPB_LUMA_CHROMA_MISR:
return "OPB Luma-Chroma MISR Metadata";
case V4L2_CID_MPEG_VIDC_METADATA_INTERLACE:
return "Interlace Metadata";
case V4L2_CID_MPEG_VIDC_METADATA_CONCEALED_MB_COUNT:
return "Concealed MB Count Metadata";
case V4L2_CID_MPEG_VIDC_METADATA_HISTOGRAM_INFO:
return "Historgram Info Metadata";
case V4L2_CID_MPEG_VIDC_METADATA_SEI_MASTERING_DISPLAY_COLOUR:
return "SEI Mastering Display Color Metadata";
case V4L2_CID_MPEG_VIDC_METADATA_SEI_CONTENT_LIGHT_LEVEL:
return "SEI Content Lighting Level Metadata";
case V4L2_CID_MPEG_VIDC_METADATA_HDR10PLUS:
return "HDR10PLUS Metadata";
case V4L2_CID_MPEG_VIDC_METADATA_EVA_STATS:
return "EVA Stats Metadata";
case V4L2_CID_MPEG_VIDC_METADATA_BUFFER_TAG:
return "Buffer Tag Metadata";
case V4L2_CID_MPEG_VIDC_METADATA_SUBFRAME_OUTPUT:
return "Subframe Output Metadata";
case V4L2_CID_MPEG_VIDC_METADATA_ROI_INFO:
return "ROI Info Metadata";
case V4L2_CID_MPEG_VIDC_METADATA_TIMESTAMP:
return "Timestamp Metadata";
case V4L2_CID_MPEG_VIDC_METADATA_ENC_QP_METADATA:
return "Encoder QP Metadata";
case V4L2_CID_MPEG_VIDC_METADATA_DPB_TAG_LIST:
return "DPB Tag List";
default:
return NULL;
}
}
static const char *msm_vidc_get_priv_ctrl_name_list1(struct msm_vidc_inst *inst,
u32 control_id)
{
switch (control_id) {
case V4L2_CID_MPEG_VIDC_SECURE:
return "Secure Mode";
case V4L2_CID_MPEG_VIDC_HEIC:
return "HEIC";
case V4L2_CID_MPEG_VIDC_LOWLATENCY_REQUEST:
return "Low Latency Mode";
case V4L2_CID_MPEG_VIDC_CODEC_CONFIG:
return "Codec Config";
case V4L2_CID_MPEG_VIDC_B_FRAME_MIN_QP:
return "B frame Min QP";
case V4L2_CID_MPEG_VIDC_B_FRAME_MAX_QP:
return "B frame Max QP";
case V4L2_CID_MPEG_VIDC_LTRCOUNT:
return "LTR count";
case V4L2_CID_MPEG_VIDC_USELTRFRAME:
return "Use LTR Frame";
case V4L2_CID_MPEG_VIDC_MARKLTRFRAME:
return "Mark LTR Frame";
case V4L2_CID_MPEG_VIDC_BASELAYER_PRIORITY:
return "Baselayer Priority";
case V4L2_CID_MPEG_VIDC_INTRA_REFRESH_PERIOD:
return "Intra Refresh Period";
case V4L2_CID_MPEG_VIDC_AU_DELIMITER:
return "AU Delimiter";
case V4L2_CID_MPEG_VIDC_TIME_DELTA_BASED_RC:
return "Time Delta Based RC";
case V4L2_CID_MPEG_VIDC_CONTENT_ADAPTIVE_CODING:
return "Content Adaptive Coding";
case V4L2_CID_MPEG_VIDC_QUALITY_BITRATE_BOOST:
return "Quality Bitrate Boost";
case V4L2_CID_MPEG_VIDC_VIDEO_BLUR_TYPES:
return "Blur Types";
case V4L2_CID_MPEG_VIDC_VIDEO_BLUR_RESOLUTION:
return "Blur Resolution";
case V4L2_CID_MPEG_VIDC_VIDEO_VPE_CSC_CUSTOM_MATRIX:
return "CSC Custom Matrix";
case V4L2_CID_MPEG_MFC51_VIDEO_DECODER_H264_DISPLAY_DELAY:
return "H264 Display Delay";
case V4L2_CID_MPEG_MFC51_VIDEO_DECODER_H264_DISPLAY_DELAY_ENABLE:
return "H264 Display Delay Enable";
case V4L2_CID_MPEG_VIDC_MIN_BITSTREAM_SIZE_OVERWRITE:
return "Bitstream Size Overwrite";
case V4L2_CID_MPEG_VIDC_SUPERFRAME:
return "Encoder Batching Superframe";
case V4L2_CID_MPEG_VIDC_THUMBNAIL_MODE:
return "Thumbnail Mode";
case V4L2_CID_MPEG_VIDC_PRIORITY:
return "Priority";
default:
return NULL;
}
}
/*
* Due to a long switch case function, ccn failure was observed. Hence the
* below function is split into msm_vidc_get_priv_ctrl_name_list1() and
* msm_vidc_get_priv_ctrl_name_list2()
*/
static const char *msm_vidc_get_priv_ctrl_name(struct msm_vidc_inst *inst,
u32 control_id)
{
const char *ctrl_name;
ctrl_name = msm_vidc_get_priv_ctrl_name_list1(inst, control_id);
if (ctrl_name)
return ctrl_name;
ctrl_name = msm_vidc_get_priv_ctrl_name_list2(inst, control_id);
if (ctrl_name)
return ctrl_name;
i_vpr_e(inst, "%s: ctrl name not available for ctrl id %#x\n",
__func__, control_id);
return NULL;
}
static int msm_vidc_packetize_control(struct msm_vidc_inst *inst,
enum msm_vidc_inst_capability_type cap_id, u32 payload_type,
void *hfi_val, u32 payload_size, const char *func)
@@ -371,9 +242,9 @@ int msm_vidc_update_cap_value(struct msm_vidc_inst *inst, u32 cap,
if (inst->capabilities->cap[cap].value != adjusted_val)
i_vpr_h(inst,
"%s: updated database value from %#x to %#x\n",
func, inst->capabilities->cap[cap].value,
adjusted_val);
"%s: updated database: name %s, value %#x -> %#x\n",
func, cap_name(cap),
inst->capabilities->cap[cap].value, adjusted_val);
inst->capabilities->cap[cap].value = adjusted_val;
@@ -643,8 +514,7 @@ int msm_vidc_ctrl_init(struct msm_vidc_inst *inst)
ctrl_cfg.step =
capability->cap[idx].step_or_mask;
}
ctrl_cfg.name = msm_vidc_get_priv_ctrl_name(inst,
capability->cap[idx].v4l2_id);
ctrl_cfg.name = cap_name(capability->cap[idx].cap);
if (!ctrl_cfg.name) {
i_vpr_e(inst, "%s: %#x ctrl name is null\n",
__func__, ctrl_cfg.id);

查看文件

@@ -30,11 +30,239 @@ extern struct msm_vidc_core *g_core;
} \
}
struct msm_vidc_buf_details {
struct msm_vidc_buf_type_name {
enum msm_vidc_buffer_type type;
char *name;
};
struct msm_vidc_cap_name {
enum msm_vidc_inst_capability_type cap;
char *name;
};
static const struct msm_vidc_cap_name cap_name_arr[] = {
{INST_CAP_NONE, "INST_CAP_NONE" },
{FRAME_WIDTH, "FRAME_WIDTH" },
{LOSSLESS_FRAME_WIDTH, "LOSSLESS_FRAME_WIDTH" },
{SECURE_FRAME_WIDTH, "SECURE_FRAME_WIDTH" },
{HEVC_IMAGE_FRAME_WIDTH, "HEVC_IMAGE_FRAME_WIDTH" },
{HEIC_IMAGE_FRAME_WIDTH, "HEIC_IMAGE_FRAME_WIDTH" },
{FRAME_HEIGHT, "FRAME_HEIGHT" },
{LOSSLESS_FRAME_HEIGHT, "LOSSLESS_FRAME_HEIGHT" },
{SECURE_FRAME_HEIGHT, "SECURE_FRAME_HEIGHT" },
{HEVC_IMAGE_FRAME_HEIGHT, "HEVC_IMAGE_FRAME_HEIGHT" },
{HEIC_IMAGE_FRAME_HEIGHT, "HEIC_IMAGE_FRAME_HEIGHT" },
{PIX_FMTS, "PIX_FMTS" },
{MIN_BUFFERS_INPUT, "MIN_BUFFERS_INPUT" },
{MIN_BUFFERS_OUTPUT, "MIN_BUFFERS_OUTPUT" },
{MBPF, "MBPF" },
{LOSSLESS_MBPF, "LOSSLESS_MBPF" },
{BATCH_MBPF, "BATCH_MBPF" },
{BATCH_FPS, "BATCH_FPS" },
{SECURE_MBPF, "SECURE_MBPF" },
{MBPS, "MBPS" },
{POWER_SAVE_MBPS, "POWER_SAVE_MBPS" },
{FRAME_RATE, "FRAME_RATE" },
{OPERATING_RATE, "OPERATING_RATE" },
{SCALE_X, "SCALE_X" },
{SCALE_Y, "SCALE_Y" },
{B_FRAME, "B_FRAME" },
{MB_CYCLES_VSP, "MB_CYCLES_VSP" },
{MB_CYCLES_VPP, "MB_CYCLES_VPP" },
{MB_CYCLES_LP, "MB_CYCLES_LP" },
{MB_CYCLES_FW, "MB_CYCLES_FW" },
{MB_CYCLES_FW_VPP, "MB_CYCLES_FW_VPP" },
{SECURE_MODE, "SECURE_MODE" },
{HFLIP, "HFLIP" },
{VFLIP, "VFLIP" },
{ROTATION, "ROTATION" },
{SUPER_FRAME, "SUPER_FRAME" },
{SLICE_INTERFACE, "SLICE_INTERFACE" },
{HEADER_MODE, "HEADER_MODE" },
{PREPEND_SPSPPS_TO_IDR, "PREPEND_SPSPPS_TO_IDR" },
{META_SEQ_HDR_NAL, "META_SEQ_HDR_NAL" },
{WITHOUT_STARTCODE, "WITHOUT_STARTCODE" },
{NAL_LENGTH_FIELD, "NAL_LENGTH_FIELD" },
{REQUEST_I_FRAME, "REQUEST_I_FRAME" },
{BIT_RATE, "BIT_RATE" },
{BITRATE_MODE, "BITRATE_MODE" },
{LOSSLESS, "LOSSLESS" },
{FRAME_SKIP_MODE, "FRAME_SKIP_MODE" },
{FRAME_RC_ENABLE, "FRAME_RC_ENABLE" },
{CONSTANT_QUALITY, "CONSTANT_QUALITY" },
{GOP_SIZE, "GOP_SIZE" },
{GOP_CLOSURE, "GOP_CLOSURE" },
{BLUR_TYPES, "BLUR_TYPES" },
{BLUR_RESOLUTION, "BLUR_RESOLUTION" },
{CSC, "CSC" },
{CSC_CUSTOM_MATRIX, "CSC_CUSTOM_MATRIX" },
{HEIC, "HEIC" },
{LOWLATENCY_MODE, "LOWLATENCY_MODE" },
{LTR_COUNT, "LTR_COUNT" },
{USE_LTR, "USE_LTR" },
{MARK_LTR, "MARK_LTR" },
{BASELAYER_PRIORITY, "BASELAYER_PRIORITY" },
{IR_RANDOM, "IR_RANDOM" },
{AU_DELIMITER, "AU_DELIMITER" },
{TIME_DELTA_BASED_RC, "TIME_DELTA_BASED_RC" },
{CONTENT_ADAPTIVE_CODING, "CONTENT_ADAPTIVE_CODING" },
{BITRATE_BOOST, "BITRATE_BOOST" },
{VBV_DELAY, "VBV_DELAY" },
{MIN_FRAME_QP, "MIN_FRAME_QP" },
{I_FRAME_MIN_QP, "I_FRAME_MIN_QP" },
{P_FRAME_MIN_QP, "P_FRAME_MIN_QP" },
{B_FRAME_MIN_QP, "B_FRAME_MIN_QP" },
{MAX_FRAME_QP, "MAX_FRAME_QP" },
{I_FRAME_MAX_QP, "I_FRAME_MAX_QP" },
{P_FRAME_MAX_QP, "P_FRAME_MAX_QP" },
{B_FRAME_MAX_QP, "B_FRAME_MAX_QP" },
{HEVC_HIER_QP, "HEVC_HIER_QP" },
{I_FRAME_QP, "I_FRAME_QP" },
{P_FRAME_QP, "P_FRAME_QP" },
{B_FRAME_QP, "B_FRAME_QP" },
{L0_QP, "L0_QP" },
{L1_QP, "L1_QP" },
{L2_QP, "L2_QP" },
{L3_QP, "L3_QP" },
{L4_QP, "L4_QP" },
{L5_QP, "L5_QP" },
{HIER_LAYER_QP, "HIER_LAYER_QP" },
{HIER_CODING_TYPE, "HIER_CODING_TYPE" },
{HIER_CODING, "HIER_CODING" },
{HIER_CODING_LAYER, "HIER_CODING_LAYER" },
{L0_BR, "L0_BR" },
{L1_BR, "L1_BR" },
{L2_BR, "L2_BR" },
{L3_BR, "L3_BR" },
{L4_BR, "L4_BR" },
{L5_BR, "L5_BR" },
{ENTROPY_MODE, "ENTROPY_MODE" },
{PROFILE, "PROFILE" },
{LEVEL, "LEVEL" },
{HEVC_TIER, "HEVC_TIER" },
{LF_MODE, "LF_MODE" },
{LF_ALPHA, "LF_ALPHA" },
{LF_BETA, "LF_BETA" },
{SLICE_MODE, "SLICE_MODE" },
{SLICE_MAX_BYTES, "SLICE_MAX_BYTES" },
{SLICE_MAX_MB, "SLICE_MAX_MB" },
{MB_RC, "MB_RC" },
{TRANSFORM_8X8, "TRANSFORM_8X8" },
{CHROMA_QP_INDEX_OFFSET, "CHROMA_QP_INDEX_OFFSET" },
{DISPLAY_DELAY_ENABLE, "DISPLAY_DELAY_ENABLE" },
{DISPLAY_DELAY, "DISPLAY_DELAY" },
{CONCEAL_COLOR_8BIT, "CONCEAL_COLOR_8BIT" },
{CONCEAL_COLOR_10BIT, "CONCEAL_COLOR_10BIT" },
{STAGE, "STAGE" },
{PIPE, "PIPE" },
{POC, "POC" },
{QUALITY_MODE, "QUALITY_MODE" },
{CODED_FRAMES, "CODED_FRAMES" },
{BIT_DEPTH, "BIT_DEPTH" },
{CODEC_CONFIG, "CODEC_CONFIG" },
{BITSTREAM_SIZE_OVERWRITE, "BITSTREAM_SIZE_OVERWRITE" },
{THUMBNAIL_MODE, "THUMBNAIL_MODE" },
{DEFAULT_HEADER, "DEFAULT_HEADER" },
{RAP_FRAME, "RAP_FRAME" },
{SEQ_CHANGE_AT_SYNC_FRAME, "SEQ_CHANGE_AT_SYNC_FRAME" },
{PRIORITY, "PRIORITY" },
{META_LTR_MARK_USE, "META_LTR_MARK_USE" },
{META_DPB_MISR, "META_DPB_MISR" },
{META_OPB_MISR, "META_OPB_MISR" },
{META_INTERLACE, "META_INTERLACE" },
{META_TIMESTAMP, "META_TIMESTAMP" },
{META_CONCEALED_MB_CNT, "META_CONCEALED_MB_CNT" },
{META_HIST_INFO, "META_HIST_INFO" },
{META_SEI_MASTERING_DISP, "META_SEI_MASTERING_DISP" },
{META_SEI_CLL, "META_SEI_CLL" },
{META_HDR10PLUS, "META_HDR10PLUS" },
{META_EVA_STATS, "META_EVA_STATS" },
{META_BUF_TAG, "META_BUF_TAG" },
{META_DPB_TAG_LIST, "META_DPB_TAG_LIST" },
{META_SUBFRAME_OUTPUT, "META_SUBFRAME_OUTPUT" },
{META_ENC_QP_METADATA, "META_ENC_QP_METADATA" },
{META_ROI_INFO, "META_ROI_INFO" },
{INST_CAP_MAX, "INST_CAP_MAX" },
};
const char *cap_name(enum msm_vidc_inst_capability_type cap)
{
const char *name = "UNKNOWN CAP";
if (cap > ARRAY_SIZE(cap_name_arr))
goto exit;
if (cap_name_arr[cap].cap != cap)
goto exit;
name = cap_name_arr[cap].name;
exit:
return name;
}
struct msm_vidc_inst_state_name {
enum msm_vidc_inst_state state;
char *name;
};
static const struct msm_vidc_inst_state_name inst_state_name_arr[] = {
{MSM_VIDC_OPEN, "OPEN" },
{MSM_VIDC_START_INPUT, "START_INPUT" },
{MSM_VIDC_START_OUTPUT, "START_OUTPUT" },
{MSM_VIDC_START, "START" },
{MSM_VIDC_DRC, "DRC" },
{MSM_VIDC_DRC_LAST_FLAG, "DRC_LAST_FLAG" },
{MSM_VIDC_DRAIN, "DRAIN" },
{MSM_VIDC_DRAIN_LAST_FLAG, "DRAIN_LAST_FLAG" },
{MSM_VIDC_DRC_DRAIN, "DRC_DRAIN" },
{MSM_VIDC_DRC_DRAIN_LAST_FLAG, "DRC_DRAIN_LAST_FLAG" },
{MSM_VIDC_DRAIN_START_INPUT, "DRAIN_START_INPUT" },
{MSM_VIDC_ERROR, "ERROR" },
};
const char *state_name(enum msm_vidc_inst_state state)
{
const char *name = "UNKNOWN STATE";
if (!state || state > ARRAY_SIZE(inst_state_name_arr))
goto exit;
if (inst_state_name_arr[state - 1].state != state)
goto exit;
name = inst_state_name_arr[state - 1].name;
exit:
return name;
}
struct msm_vidc_core_state_name {
enum msm_vidc_core_state state;
char *name;
};
static const struct msm_vidc_core_state_name core_state_name_arr[] = {
{MSM_VIDC_CORE_DEINIT, "CORE_DEINIT" },
{MSM_VIDC_CORE_INIT, "CORE_INIT" },
};
const char *core_state_name(enum msm_vidc_core_state state)
{
const char *name = "UNKNOWN STATE";
if (state >= ARRAY_SIZE(core_state_name_arr))
goto exit;
if (core_state_name_arr[state].state != state)
goto exit;
name = core_state_name_arr[state].name;
exit:
return name;
}
void print_vidc_buffer(u32 tag, const char *tag_str, const char *str, struct msm_vidc_inst *inst,
struct msm_vidc_buffer *vbuf)
{
@@ -65,12 +293,21 @@ void print_vb2_buffer(const char *str, struct msm_vidc_inst *inst,
if (!inst || !vb2)
return;
i_vpr_e(inst,
"%s: %s: idx %2d fd %d off %d size %d filled %d\n",
str, vb2->type == INPUT_MPLANE ? "INPUT" : "OUTPUT",
vb2->index, vb2->planes[0].m.fd,
vb2->planes[0].data_offset, vb2->planes[0].length,
vb2->planes[0].bytesused);
if (vb2->type == INPUT_MPLANE || vb2->type == OUTPUT_MPLANE) {
i_vpr_e(inst,
"%s: %s: idx %2d fd %d off %d size %d filled %d\n",
str, vb2->type == INPUT_MPLANE ? "INPUT" : "OUTPUT",
vb2->index, vb2->planes[0].m.fd,
vb2->planes[0].data_offset, vb2->planes[0].length,
vb2->planes[0].bytesused);
} else if (vb2->type == INPUT_META_PLANE || vb2->type == OUTPUT_META_PLANE) {
i_vpr_e(inst,
"%s: %s: idx %2d fd %d off %d size %d filled %d\n",
str, vb2->type == INPUT_MPLANE ? "INPUT_META" : "OUTPUT_META",
vb2->index, vb2->planes[0].m.fd,
vb2->planes[0].data_offset, vb2->planes[0].length,
vb2->planes[0].bytesused);
}
}
enum msm_vidc_buffer_type v4l2_type_to_driver(u32 type, const char *func)
@@ -692,25 +929,6 @@ struct msm_vidc_allocations *msm_vidc_get_allocations(
}
}
const char *core_state_name(enum msm_vidc_core_state state)
{
const char* name = "UNKNOWN";
switch (state) {
case MSM_VIDC_CORE_INIT:
name = "CORE_INIT";
break;
case MSM_VIDC_CORE_DEINIT:
name = "CORE_DEINIT";
break;
default:
name = "UNKNOWN";
break;
}
return name;
}
int msm_vidc_change_core_state(struct msm_vidc_core *core,
enum msm_vidc_core_state request_state, const char *func)
{
@@ -726,55 +944,6 @@ int msm_vidc_change_core_state(struct msm_vidc_core *core,
return 0;
}
const char *state_name(enum msm_vidc_inst_state state)
{
const char *name = "UNKNOWN";
switch (state) {
case MSM_VIDC_OPEN:
name = "OPEN";
break;
case MSM_VIDC_START_INPUT:
name = "START_INPUT";
break;
case MSM_VIDC_START_OUTPUT:
name = "START_OUTPUT";
break;
case MSM_VIDC_START:
name = "START";
break;
case MSM_VIDC_DRC:
name = "DRC";
break;
case MSM_VIDC_DRC_LAST_FLAG:
name = "DRC_LAST_FLAG";
break;
case MSM_VIDC_DRAIN:
name = "DRAIN";
break;
case MSM_VIDC_DRAIN_LAST_FLAG:
name = "DRAIN_LAST_FLAG";
break;
case MSM_VIDC_DRC_DRAIN:
name = "DRC_DRAIN";
break;
case MSM_VIDC_DRC_DRAIN_LAST_FLAG:
name = "DRC_DRAIN_LAST_FLAG";
break;
case MSM_VIDC_DRAIN_START_INPUT:
name = "DRAIN_START_INPUT";
break;
case MSM_VIDC_ERROR:
name = "ERROR";
break;
default:
name = "UNKNOWN";
break;
}
return name;
}
int msm_vidc_change_inst_state(struct msm_vidc_inst *inst,
enum msm_vidc_inst_state request_state, const char *func)
{
@@ -3079,7 +3248,7 @@ int msm_vidc_print_inst_info(struct msm_vidc_inst *inst)
struct dma_buf *dbuf;
int i = 0;
struct msm_vidc_buf_details buffer_details[] = {
static const struct msm_vidc_buf_type_name buf_type_name[] = {
{MSM_VIDC_BUF_INPUT, "INPUT" },
{MSM_VIDC_BUF_OUTPUT, "OUTPUT" },
{MSM_VIDC_BUF_INPUT_META, "IN_META" },
@@ -3114,13 +3283,13 @@ int msm_vidc_print_inst_info(struct msm_vidc_inst *inst)
frame_rate, bit_rate, bit_depth);
/* Print buffer details */
for (i = 0; i < ARRAY_SIZE(buffer_details); i++) {
buffers = msm_vidc_get_buffers(inst, buffer_details[i].type, __func__);
for (i = 0; i < ARRAY_SIZE(buf_type_name); i++) {
buffers = msm_vidc_get_buffers(inst, buf_type_name[i].type, __func__);
if (!buffers)
continue;
i_vpr_e(inst, "count: type: %8s, min: %2d, extra: %2d, actual: %2d\n",
buffer_details[i].name, buffers->min_count,
buf_type_name[i].name, buffers->min_count,
buffers->extra_count, buffers->actual_count);
list_for_each_entry(buf, &buffers->list, list) {
@@ -3129,7 +3298,7 @@ int msm_vidc_print_inst_info(struct msm_vidc_inst *inst)
dbuf = (struct dma_buf *)buf->dmabuf;
i_vpr_e(inst,
"buf: type: %8s, index: %2d, fd: %4d, size: %9u, off: %8u, filled: %9u, iova: %8x, inode: %9ld, flags: %8x, ts: %16lld, attr: %8x\n",
buffer_details[i].name, buf->index, buf->fd, buf->buffer_size,
buf_type_name[i].name, buf->index, buf->fd, buf->buffer_size,
buf->data_offset, buf->data_size, buf->device_addr,
file_inode(dbuf->file)->i_ino,
buf->flags, buf->timestamp, buf->attr);
@@ -3259,7 +3428,8 @@ void msm_vidc_batch_handler(struct work_struct *work)
allow = msm_vidc_allow_qbuf(inst, OUTPUT_MPLANE);
if (allow != MSM_VIDC_ALLOW) {
i_vpr_e(inst, "%s: not allowed in state: %s\n", __func__, state_name(inst->state));
i_vpr_e(inst, "%s: not allowed in state: %s\n", __func__,
state_name(inst->state));
goto exit;
}
@@ -3323,7 +3493,7 @@ void msm_vidc_destroy_buffers(struct msm_vidc_inst *inst)
{
struct msm_vidc_buffers *buffers;
struct msm_vidc_buffer *buf, *dummy;
enum msm_vidc_buffer_type buf_types[] = {
static const enum msm_vidc_buffer_type buf_types[] = {
MSM_VIDC_BUF_INPUT,
MSM_VIDC_BUF_OUTPUT,
MSM_VIDC_BUF_INPUT_META,

查看文件

@@ -14,30 +14,31 @@
#include "msm_vidc_dt.h"
#include "msm_vidc_core.h"
struct msm_vidc_buf_region_name {
enum msm_vidc_buffer_region region;
char *name;
};
struct context_bank_info *get_context_bank(struct msm_vidc_core *core,
enum msm_vidc_buffer_region region)
{
char *name;
const char *name;
struct context_bank_info *cb = NULL, *match = NULL;
static const struct msm_vidc_buf_region_name buf_region_name[] = {
{MSM_VIDC_REGION_NONE, "none" },
{MSM_VIDC_NON_SECURE, "venus_ns" },
{MSM_VIDC_SECURE_PIXEL, "venus_sec_pixel" },
{MSM_VIDC_SECURE_NONPIXEL, "venus_sec_non_pixel" },
{MSM_VIDC_SECURE_BITSTREAM, "venus_sec_bitstream" },
};
switch (region) {
case MSM_VIDC_NON_SECURE:
name = "venus_ns";
break;
case MSM_VIDC_SECURE_PIXEL:
name = "venus_sec_pixel";
break;
case MSM_VIDC_SECURE_NONPIXEL:
name = "venus_sec_non_pixel";
break;
case MSM_VIDC_SECURE_BITSTREAM:
name = "venus_sec_bitstream";
break;
default:
d_vpr_e("invalid region : %#x\n", region);
return NULL;
}
if (!region || region > ARRAY_SIZE(buf_region_name))
goto exit;
if (buf_region_name[region].region != region)
goto exit;
name = buf_region_name[region].name;
list_for_each_entry(cb, &core->dt->context_banks, list) {
if (!strcmp(cb->name, name)) {
@@ -49,6 +50,10 @@ struct context_bank_info *get_context_bank(struct msm_vidc_core *core,
d_vpr_e("cb not found for region %#x\n", region);
return match;
exit:
d_vpr_e("Invalid region %#x\n", region);
return NULL;
}
struct dma_buf *msm_vidc_memory_get_dmabuf(int fd)

查看文件

@@ -13,9 +13,25 @@
#define in_range(range, val) (((range.begin) < (val)) && ((range.end) > (val)))
extern struct msm_vidc_core *g_core;
struct msm_vidc_hfi_range {
struct msm_vidc_core_hfi_range {
u32 begin;
u32 end;
int (*handle)(struct msm_vidc_core *core, struct hfi_packet *pkt);
};
struct msm_vidc_inst_hfi_range {
u32 begin;
u32 end;
int (*handle)(struct msm_vidc_inst *inst, struct hfi_packet *pkt);
};
struct msm_vidc_hfi_buffer_handle {
enum hfi_buffer_type type;
int (*handle)(struct msm_vidc_inst *inst, struct hfi_buffer *buffer);
};
struct msm_vidc_hfi_packet_handle {
enum hfi_buffer_type type;
int (*handle)(struct msm_vidc_inst *inst, struct hfi_packet *pkt);
};
@@ -187,6 +203,33 @@ int validate_packet(u8 *response_pkt, u8 *core_resp_pkt,
return 0;
}
static int validate_hdr_packet(struct msm_vidc_core *core,
struct hfi_header *hdr, const char *function)
{
struct hfi_packet *packet;
u8 *pkt;
int i, rc = 0;
if (!core || !hdr || !function) {
d_vpr_e("%s: invalid params\n", __func__);
return -EINVAL;
}
pkt = (u8 *)((u8 *)hdr + sizeof(struct hfi_header));
/* validate all packets */
for (i = 0; i < hdr->num_packets; i++) {
packet = (struct hfi_packet *)pkt;
rc = validate_packet(pkt, core->response_packet, core->packet_size, function);
if (rc)
return rc;
pkt += packet->size;
}
return 0;
}
static bool check_last_flag(struct msm_vidc_inst *inst,
struct hfi_packet *pkt)
{
@@ -666,7 +709,7 @@ static int handle_dequeue_buffers(struct msm_vidc_inst* inst)
struct msm_vidc_buffers* buffers;
struct msm_vidc_buffer* buf;
struct msm_vidc_buffer* dummy;
enum msm_vidc_buffer_type buffer_type[] = {
static const enum msm_vidc_buffer_type buffer_type[] = {
MSM_VIDC_BUF_INPUT_META,
MSM_VIDC_BUF_INPUT,
MSM_VIDC_BUF_OUTPUT_META,
@@ -908,9 +951,38 @@ static int handle_arp_buffer(struct msm_vidc_inst *inst,
static int handle_session_buffer(struct msm_vidc_inst *inst,
struct hfi_packet *pkt)
{
int rc = 0;
int i, rc = 0;
struct hfi_buffer *buffer;
u32 buf_type = 0, port_type = 0;
u32 hfi_handle_size = 0;
const struct msm_vidc_hfi_buffer_handle *hfi_handle_arr = NULL;
static const struct msm_vidc_hfi_buffer_handle enc_input_hfi_handle[] = {
{HFI_BUFFER_METADATA, handle_input_metadata_buffer },
{HFI_BUFFER_RAW, handle_input_buffer },
};
static const struct msm_vidc_hfi_buffer_handle enc_output_hfi_handle[] = {
{HFI_BUFFER_METADATA, handle_output_metadata_buffer },
{HFI_BUFFER_BITSTREAM, handle_output_buffer },
{HFI_BUFFER_BIN, handle_bin_buffer },
{HFI_BUFFER_COMV, handle_comv_buffer },
{HFI_BUFFER_NON_COMV, handle_non_comv_buffer },
{HFI_BUFFER_LINE, handle_line_buffer },
{HFI_BUFFER_ARP, handle_arp_buffer },
{HFI_BUFFER_DPB, handle_dpb_buffer },
};
static const struct msm_vidc_hfi_buffer_handle dec_input_hfi_handle[] = {
{HFI_BUFFER_METADATA, handle_input_metadata_buffer },
{HFI_BUFFER_BITSTREAM, handle_input_buffer },
{HFI_BUFFER_BIN, handle_bin_buffer },
{HFI_BUFFER_COMV, handle_comv_buffer },
{HFI_BUFFER_NON_COMV, handle_non_comv_buffer },
{HFI_BUFFER_LINE, handle_line_buffer },
{HFI_BUFFER_PERSIST, handle_persist_buffer },
};
static const struct msm_vidc_hfi_buffer_handle dec_output_hfi_handle[] = {
{HFI_BUFFER_METADATA, handle_output_metadata_buffer },
{HFI_BUFFER_RAW, handle_output_buffer },
{HFI_BUFFER_DPB, handle_dpb_buffer },
};
if (pkt->flags & HFI_FW_FLAGS_SESSION_ERROR) {
i_vpr_e(inst, "%s: received session error\n", __func__);
@@ -924,86 +996,56 @@ static int handle_session_buffer(struct msm_vidc_inst *inst,
return 0;
}
port_type = pkt->port;
buffer = (struct hfi_buffer *)((u8 *)pkt + sizeof(struct hfi_packet));
buf_type = buffer->type;
if (!is_valid_hfi_buffer_type(inst, buf_type, __func__)) {
if (!is_valid_hfi_buffer_type(inst, buffer->type, __func__)) {
msm_vidc_change_inst_state(inst, MSM_VIDC_ERROR, __func__);
return 0;
}
if (!is_valid_hfi_port(inst, port_type, buf_type, __func__)) {
if (!is_valid_hfi_port(inst, pkt->port, buffer->type, __func__)) {
msm_vidc_change_inst_state(inst, MSM_VIDC_ERROR, __func__);
return 0;
}
if (is_encode_session(inst)) {
if (port_type == HFI_PORT_BITSTREAM) {
if (buf_type == HFI_BUFFER_METADATA)
rc = handle_output_metadata_buffer(inst, buffer);
else if (buf_type == HFI_BUFFER_BITSTREAM)
rc = handle_output_buffer(inst, buffer);
else if (buf_type == HFI_BUFFER_BIN)
rc = handle_bin_buffer(inst, buffer);
else if (buf_type == HFI_BUFFER_COMV)
rc = handle_comv_buffer(inst, buffer);
else if (buf_type == HFI_BUFFER_NON_COMV)
rc = handle_non_comv_buffer(inst, buffer);
else if (buf_type == HFI_BUFFER_LINE)
rc = handle_line_buffer(inst, buffer);
else if (buf_type == HFI_BUFFER_ARP)
rc = handle_arp_buffer(inst, buffer);
else if (buf_type == HFI_BUFFER_DPB)
rc = handle_dpb_buffer(inst, buffer);
else
i_vpr_e(inst, "%s: unknown bitstream port buffer type %#x\n",
__func__, buf_type);
} else if (port_type == HFI_PORT_RAW) {
if (buf_type == HFI_BUFFER_METADATA)
rc = handle_input_metadata_buffer(inst, buffer);
else if (buf_type == HFI_BUFFER_RAW)
rc = handle_input_buffer(inst, buffer);
else
i_vpr_e(inst, "%s: unknown raw port buffer type %#x\n",
__func__, buf_type);
if (pkt->port == HFI_PORT_RAW) {
hfi_handle_size = ARRAY_SIZE(enc_input_hfi_handle);
hfi_handle_arr = enc_input_hfi_handle;
} else if (pkt->port == HFI_PORT_BITSTREAM) {
hfi_handle_size = ARRAY_SIZE(enc_output_hfi_handle);
hfi_handle_arr = enc_output_hfi_handle;
}
} else if (is_decode_session(inst)) {
if (port_type == HFI_PORT_BITSTREAM) {
if (buf_type == HFI_BUFFER_METADATA)
rc = handle_input_metadata_buffer(inst, buffer);
else if (buf_type == HFI_BUFFER_BITSTREAM)
rc = handle_input_buffer(inst, buffer);
else if (buf_type == HFI_BUFFER_BIN)
rc = handle_bin_buffer(inst, buffer);
else if (buf_type == HFI_BUFFER_COMV)
rc = handle_comv_buffer(inst, buffer);
else if (buf_type == HFI_BUFFER_NON_COMV)
rc = handle_non_comv_buffer(inst, buffer);
else if (buf_type == HFI_BUFFER_LINE)
rc = handle_line_buffer(inst, buffer);
else if (buf_type == HFI_BUFFER_PERSIST)
rc = handle_persist_buffer(inst, buffer);
else
i_vpr_e(inst, "%s: unknown bitstream port buffer type %#x\n",
__func__, buf_type);
} else if (port_type == HFI_PORT_RAW) {
if (buf_type == HFI_BUFFER_METADATA)
rc = handle_output_metadata_buffer(inst, buffer);
else if (buf_type == HFI_BUFFER_RAW)
rc = handle_output_buffer(inst, buffer);
else if (buf_type == HFI_BUFFER_DPB)
rc = handle_dpb_buffer(inst, buffer);
else
i_vpr_e(inst, "%s: unknown raw port buffer type %#x\n",
__func__, buf_type);
if (pkt->port == HFI_PORT_BITSTREAM) {
hfi_handle_size = ARRAY_SIZE(dec_input_hfi_handle);
hfi_handle_arr = dec_input_hfi_handle;
} else if (pkt->port == HFI_PORT_RAW) {
hfi_handle_size = ARRAY_SIZE(dec_output_hfi_handle);
hfi_handle_arr = dec_output_hfi_handle;
}
} else {
i_vpr_e(inst, "%s: invalid session %d\n",
__func__, inst->domain);
}
/* handle invalid session */
if (!hfi_handle_arr || !hfi_handle_size) {
i_vpr_e(inst, "%s: invalid session %d\n", __func__, inst->domain);
return -EINVAL;
}
/* handle session buffer */
for (i = 0; i < hfi_handle_size; i++) {
if (hfi_handle_arr[i].type == buffer->type) {
rc = hfi_handle_arr[i].handle(inst, buffer);
if (rc)
return rc;
break;
}
}
/* handle unknown buffer type */
if (i == hfi_handle_size)
i_vpr_e(inst, "%s: port %u, unknown buffer type %#x\n", __func__,
pkt->port, buffer->type);
return rc;
}
@@ -1072,32 +1114,36 @@ static int handle_session_resume(struct msm_vidc_inst *inst,
static int handle_session_command(struct msm_vidc_inst *inst,
struct hfi_packet *pkt)
{
switch (pkt->type) {
case HFI_CMD_OPEN:
return handle_session_open(inst, pkt);
case HFI_CMD_CLOSE:
return handle_session_close(inst, pkt);
case HFI_CMD_START:
return handle_session_start(inst, pkt);
case HFI_CMD_STOP:
return handle_session_stop(inst, pkt);
case HFI_CMD_DRAIN:
return handle_session_drain(inst, pkt);
case HFI_CMD_BUFFER:
return handle_session_buffer(inst, pkt);
case HFI_CMD_SETTINGS_CHANGE:
return handle_port_settings_change(inst, pkt);
case HFI_CMD_SUBSCRIBE_MODE:
return handle_session_subscribe_mode(inst, pkt);
case HFI_CMD_DELIVERY_MODE:
return handle_session_delivery_mode(inst, pkt);
case HFI_CMD_RESUME:
return handle_session_resume(inst, pkt);
default:
i_vpr_e(inst, "%s: Unsupported command type: %#x\n",
__func__, pkt->type);
int i, rc;
static const struct msm_vidc_hfi_packet_handle hfi_pkt_handle[] = {
{HFI_CMD_OPEN, handle_session_open },
{HFI_CMD_CLOSE, handle_session_close },
{HFI_CMD_START, handle_session_start },
{HFI_CMD_STOP, handle_session_stop },
{HFI_CMD_DRAIN, handle_session_drain },
{HFI_CMD_BUFFER, handle_session_buffer },
{HFI_CMD_SETTINGS_CHANGE, handle_port_settings_change },
{HFI_CMD_SUBSCRIBE_MODE, handle_session_subscribe_mode },
{HFI_CMD_DELIVERY_MODE, handle_session_delivery_mode },
{HFI_CMD_RESUME, handle_session_resume },
};
/* handle session pkt */
for (i = 0; i < ARRAY_SIZE(hfi_pkt_handle); i++) {
if (hfi_pkt_handle[i].type == pkt->type) {
rc = hfi_pkt_handle[i].handle(inst, pkt);
if (rc)
return rc;
break;
}
}
/* handle unknown buffer type */
if (i == ARRAY_SIZE(hfi_pkt_handle)) {
i_vpr_e(inst, "%s: Unsupported command type: %#x\n", __func__, pkt->type);
return -EINVAL;
}
return 0;
}
@@ -1244,35 +1290,99 @@ static int handle_system_response(struct msm_vidc_core *core,
{
int rc = 0;
struct hfi_packet *packet;
u8 *pkt;
int i;
u8 *pkt, *start_pkt;
bool parsed = false;
int i, j, k;
static const struct msm_vidc_core_hfi_range be[] = {
{HFI_SYSTEM_ERROR_BEGIN, HFI_SYSTEM_ERROR_END, handle_system_error },
{HFI_PROP_BEGIN, HFI_PROP_END, handle_system_property },
{HFI_CMD_BEGIN, HFI_CMD_END, handle_system_init },
};
pkt = (u8 *)((u8 *)hdr + sizeof(struct hfi_header));
start_pkt = (u8 *)((u8 *)hdr + sizeof(struct hfi_header));
for (i = 0; i < ARRAY_SIZE(be); i++) {
pkt = start_pkt;
for (j = 0; j < hdr->num_packets; j++) {
packet = (struct hfi_packet *)pkt;
parsed = false;
if (in_range(be[i], packet->type)) {
parsed = true;
rc = be[i].handle(core, packet);
if (rc)
return -EINVAL;
}
for (i = 0; i < hdr->num_packets; i++) {
if (validate_packet((u8 *)pkt, core->response_packet,
core->packet_size, __func__)) {
rc = -EINVAL;
goto exit;
/* is pkt type unknown ? */
if (!parsed) {
for (k = 0; k < ARRAY_SIZE(be); k++)
if (in_range(be[k], packet->type))
parsed |= true;
if (!parsed)
d_vpr_e("%s: unknown packet received %#x\n",
__func__, packet->type);
}
pkt += packet->size;
}
packet = (struct hfi_packet *)pkt;
if (packet->type == HFI_CMD_INIT) {
rc = handle_system_init(core, packet);
} else if (packet->type > HFI_SYSTEM_ERROR_BEGIN &&
packet->type < HFI_SYSTEM_ERROR_END) {
rc = handle_system_error(core, packet);
} else if (packet->type > HFI_PROP_BEGIN &&
packet->type < HFI_PROP_CODEC) {
rc = handle_system_property(core, packet);
} else {
d_vpr_e("%s: Unknown packet type: %#x\n",
__func__, packet->type);
rc = -EINVAL;
goto exit;
}
pkt += packet->size;
}
return 0;
}
static int __handle_session_response(struct msm_vidc_inst *inst,
struct hfi_header *hdr)
{
int rc = 0;
struct hfi_packet *packet;
u8 *pkt, *start_pkt;
bool dequeue = false, parsed = false;
int i, j, k;
static const struct msm_vidc_inst_hfi_range be[] = {
{HFI_SESSION_ERROR_BEGIN, HFI_SESSION_ERROR_END, handle_session_error },
{HFI_INFORMATION_BEGIN, HFI_INFORMATION_END, handle_session_info },
{HFI_PROP_BEGIN, HFI_PROP_END, handle_session_property },
{HFI_CMD_BEGIN, HFI_CMD_END, handle_session_command },
};
memset(&inst->hfi_frame_info, 0, sizeof(struct msm_vidc_hfi_frame_info));
start_pkt = (u8 *)((u8 *)hdr + sizeof(struct hfi_header));
for (i = 0; i < ARRAY_SIZE(be); i++) {
pkt = start_pkt;
for (j = 0; j < hdr->num_packets; j++) {
packet = (struct hfi_packet *)pkt;
parsed = false;
if (in_range(be[i], packet->type)) {
parsed = true;
dequeue |= (packet->type == HFI_CMD_BUFFER);
rc = be[i].handle(inst, packet);
if (rc)
goto exit;
}
/* is pkt type unknown ? */
if (!parsed) {
for (k = 0; k < ARRAY_SIZE(be); k++)
if (in_range(be[k], packet->type))
parsed |= true;
if (!parsed)
d_vpr_e("%s: unknown packet received %#x\n",
__func__, packet->type);
}
pkt += packet->size;
}
}
if (dequeue) {
rc = handle_dequeue_buffers(inst);
if (rc)
goto exit;
}
exit:
memset(&inst->hfi_frame_info, 0, sizeof(struct msm_vidc_hfi_frame_info));
return rc;
}
@@ -1281,18 +1391,8 @@ int handle_session_response_work(struct msm_vidc_inst *inst,
{
int rc = 0;
struct hfi_header *hdr = NULL;
struct hfi_packet *packet;
u8 *pkt, *start_pkt;
u32 hfi_cmd_type = 0;
int i, j;
struct msm_vidc_hfi_range be[] = {
{HFI_SESSION_ERROR_BEGIN, HFI_SESSION_ERROR_END, handle_session_error},
{HFI_INFORMATION_BEGIN, HFI_INFORMATION_END, handle_session_info},
{HFI_PROP_BEGIN, HFI_PROP_END, handle_session_property},
{HFI_CMD_BEGIN, HFI_CMD_END, handle_session_command},
};
if (!inst || !resp_work) {
if (!inst || !inst->core || !resp_work) {
d_vpr_e("%s: invalid params\n", __func__);
return -EINVAL;
}
@@ -1302,58 +1402,14 @@ int handle_session_response_work(struct msm_vidc_inst *inst,
i_vpr_e(inst, "%s: invalid params\n", __func__);
return -EINVAL;
}
hfi_cmd_type = 0;
pkt = (u8 *)((u8 *)hdr + sizeof(struct hfi_header));
start_pkt = pkt;
/* validate all packets */
for (i = 0; i < hdr->num_packets; i++) {
packet = (struct hfi_packet * ) pkt;
if (validate_packet(pkt, resp_work->data,
resp_work->data_size, __func__)) {
rc = -EINVAL;
goto exit;
}
pkt += packet->size;
}
if (resp_work->type == RESP_WORK_INPUT_PSC)
msm_vdec_init_input_subcr_params(inst);
memset(&inst->hfi_frame_info, 0,
sizeof(struct msm_vidc_hfi_frame_info));
for (i = 0; i < ARRAY_SIZE(be); i++) {
pkt = start_pkt;
for (j = 0; j < hdr->num_packets; j++) {
packet = (struct hfi_packet * ) pkt;
if (in_range(be[i], packet->type)) {
if (hfi_cmd_type == HFI_CMD_SETTINGS_CHANGE) {
i_vpr_e(inst,
"%s: invalid packet type %d in port settings change\n",
__func__, packet->type);
rc = -EINVAL;
}
hfi_cmd_type = packet->type;
rc = be[i].handle(inst, packet);
if (rc)
goto exit;
}
pkt += packet->size;
}
}
rc = __handle_session_response(inst, hdr);
if (rc)
return rc;
if (hfi_cmd_type == HFI_CMD_BUFFER) {
rc = handle_dequeue_buffers(inst);
if (rc)
goto exit;
}
memset(&inst->hfi_frame_info, 0,
sizeof(struct msm_vidc_hfi_frame_info));
exit:
return rc;
return 0;
}
void handle_session_response_work_handler(struct work_struct *work)
@@ -1448,89 +1504,63 @@ static int queue_response_work(struct msm_vidc_inst *inst,
static int handle_session_response(struct msm_vidc_core *core,
struct hfi_header *hdr)
{
int rc = 0;
struct msm_vidc_inst *inst;
struct hfi_packet *packet;
u8 *pkt, *start_pkt;
u32 hfi_cmd_type = 0;
u32 hfi_port = 0;
int i, j;
struct msm_vidc_hfi_range be[] = {
{HFI_SESSION_ERROR_BEGIN, HFI_SESSION_ERROR_END, handle_session_error},
{HFI_INFORMATION_BEGIN, HFI_INFORMATION_END, handle_session_info},
{HFI_PROP_BEGIN, HFI_PROP_END, handle_session_property},
{HFI_CMD_BEGIN, HFI_CMD_END, handle_session_command},
};
u8 *pkt;
enum response_work_type type;
int i, rc = 0;
bool offload = false;
if (!core || !hdr) {
d_vpr_e("%s: Invalid params\n", __func__);
return -EINVAL;
}
inst = get_inst(core, hdr->session_id);
if (!inst) {
d_vpr_e("%s: invalid params\n", __func__);
d_vpr_e("%s: Invalid params\n", __func__);
return -EINVAL;
}
mutex_lock(&inst->lock);
hfi_cmd_type = 0;
hfi_port = 0;
/* search for special pkt */
pkt = (u8 *)((u8 *)hdr + sizeof(struct hfi_header));
start_pkt = pkt;
/* validate all packets */
for (i = 0; i < hdr->num_packets; i++) {
packet = (struct hfi_packet * ) pkt;
if (validate_packet(pkt, core->response_packet,
core->packet_size, __func__)) {
rc = -EINVAL;
goto exit;
}
pkt += packet->size;
}
packet = (struct hfi_packet *)pkt;
pkt = start_pkt;
for (j = 0; j < hdr->num_packets; j++) {
packet = (struct hfi_packet * ) pkt;
if (packet->type == HFI_CMD_SETTINGS_CHANGE) {
if (packet->port == HFI_PORT_BITSTREAM)
rc = queue_response_work(inst,
RESP_WORK_INPUT_PSC,
(void *)hdr, hdr->size);
else if (packet->port == HFI_PORT_RAW)
rc = queue_response_work(inst,
RESP_WORK_OUTPUT_PSC,
(void *)hdr, hdr->size);
goto exit;
if (packet->port == HFI_PORT_BITSTREAM) {
offload = true;
type = RESP_WORK_INPUT_PSC;
} else if (packet->port == HFI_PORT_RAW) {
offload = true;
type = RESP_WORK_OUTPUT_PSC;
}
} else if (packet->type == HFI_CMD_BUFFER &&
packet->port == HFI_PORT_RAW &&
check_last_flag(inst, packet)) {
rc = queue_response_work(inst,
RESP_WORK_LAST_FLAG,
(void *)hdr, hdr->size);
goto exit;
packet->port == HFI_PORT_RAW) {
if (check_last_flag(inst, packet)) {
offload = true;
type = RESP_WORK_LAST_FLAG;
}
}
if (offload)
break;
pkt += packet->size;
}
memset(&inst->hfi_frame_info, 0, sizeof(struct msm_vidc_hfi_frame_info));
for (i = 0; i < ARRAY_SIZE(be); i++) {
pkt = start_pkt;
for (j = 0; j < hdr->num_packets; j++) {
packet = (struct hfi_packet * ) pkt;
if (in_range(be[i], packet->type)) {
hfi_cmd_type = packet->type;
rc = be[i].handle(inst, packet);
if (rc)
goto exit;
}
pkt += packet->size;
}
}
if (hfi_cmd_type == HFI_CMD_BUFFER) {
rc = handle_dequeue_buffers(inst);
if (offload) {
i_vpr_h(inst, "%s: queue response work %#x\n", __func__, type);
rc = queue_response_work(inst, type, (void *)hdr, hdr->size);
if (rc)
goto exit;
i_vpr_e(inst, "%s: Offload response work failed\n", __func__);
goto exit;
}
memset(&inst->hfi_frame_info, 0, sizeof(struct msm_vidc_hfi_frame_info));
rc = __handle_session_response(inst, hdr);
if (rc)
goto exit;
exit:
mutex_unlock(&inst->lock);
@@ -1541,6 +1571,7 @@ exit:
int handle_response(struct msm_vidc_core *core, void *response)
{
struct hfi_header *hdr;
int rc = 0;
if (!core || !response) {
d_vpr_e("%s: invalid params\n", __func__);
@@ -1548,9 +1579,11 @@ int handle_response(struct msm_vidc_core *core, void *response)
}
hdr = (struct hfi_header *)response;
if (validate_packet((u8 *)hdr, core->response_packet,
core->packet_size, __func__))
rc = validate_hdr_packet(core, hdr, __func__);
if (rc) {
d_vpr_e("%s: hdr pkt validation failed\n", __func__);
return -EINVAL;
}
if (!hdr->session_id)
return handle_system_response(core, hdr);