Merge "video: driver: use helper functions wherever applicable"
This commit is contained in:
gecommit door
Gerrit - the friendly Code Review server
commit
75351f36a5
@@ -36,7 +36,7 @@ u64 msm_vidc_calc_freq_iris2(struct msm_vidc_inst *inst, u32 data_size)
|
||||
fw_cycles = fps * inst->capabilities[MB_CYCLES_FW].value;
|
||||
fw_vpp_cycles = fps * inst->capabilities[MB_CYCLES_FW_VPP].value;
|
||||
|
||||
if (inst->domain == MSM_VIDC_ENCODER) {
|
||||
if (is_encode_session(inst)) {
|
||||
vpp_cycles_per_mb = is_low_power_session(inst) ?
|
||||
inst->capabilities[MB_CYCLES_LP].value :
|
||||
inst->capabilities[MB_CYCLES_VPP].value;
|
||||
@@ -99,7 +99,7 @@ u64 msm_vidc_calc_freq_iris2(struct msm_vidc_inst *inst, u32 data_size)
|
||||
|
||||
vsp_cycles += mbs_per_second * base_cycles;
|
||||
|
||||
} else if (inst->domain == MSM_VIDC_DECODER) {
|
||||
} else if (is_decode_session(inst)) {
|
||||
/* VPP */
|
||||
vpp_cycles = mbs_per_second * inst->capabilities[MB_CYCLES_VPP].value /
|
||||
inst->capabilities[PIPE].value;
|
||||
|
@@ -23,9 +23,9 @@ static int msm_vidc_init_codec_input_freq(struct msm_vidc_inst *inst, u32 data_s
|
||||
enum msm_vidc_port_type port;
|
||||
u32 color_fmt;
|
||||
|
||||
if (inst->domain == MSM_VIDC_ENCODER) {
|
||||
if (is_encode_session(inst)) {
|
||||
codec_input->decoder_or_encoder = CODEC_ENCODER;
|
||||
} else if (inst->domain == MSM_VIDC_DECODER) {
|
||||
} else if (is_decode_session(inst)) {
|
||||
codec_input->decoder_or_encoder = CODEC_DECODER;
|
||||
} else {
|
||||
d_vpr_e("%s: invalid domain %d\n", __func__, inst->domain);
|
||||
@@ -59,7 +59,7 @@ static int msm_vidc_init_codec_input_freq(struct msm_vidc_inst *inst, u32 data_s
|
||||
codec_input->pipe_num = inst->capabilities[PIPE].value;
|
||||
codec_input->frame_rate = inst->max_rate;
|
||||
|
||||
port = inst->domain == MSM_VIDC_DECODER ? INPUT_PORT : OUTPUT_PORT;
|
||||
port = is_decode_session(inst) ? INPUT_PORT : OUTPUT_PORT;
|
||||
codec_input->frame_width = inst->fmts[port].fmt.pix_mp.width;
|
||||
codec_input->frame_height = inst->fmts[port].fmt.pix_mp.height;
|
||||
|
||||
@@ -88,7 +88,7 @@ static int msm_vidc_init_codec_input_freq(struct msm_vidc_inst *inst, u32 data_s
|
||||
/* set as IPP */
|
||||
codec_input->hierachical_layer = 0;
|
||||
|
||||
if (inst->domain == MSM_VIDC_DECODER)
|
||||
if (is_decode_session(inst))
|
||||
color_fmt = v4l2_colorformat_to_driver(inst,
|
||||
inst->fmts[OUTPUT_PORT].fmt.pix_mp.pixelformat, __func__);
|
||||
else
|
||||
@@ -397,7 +397,7 @@ static u64 msm_vidc_calc_freq_iris3_legacy(struct msm_vidc_inst *inst, u32 data_
|
||||
fw_cycles = fps * inst->capabilities[MB_CYCLES_FW].value;
|
||||
fw_vpp_cycles = fps * inst->capabilities[MB_CYCLES_FW_VPP].value;
|
||||
|
||||
if (inst->domain == MSM_VIDC_ENCODER) {
|
||||
if (is_encode_session(inst)) {
|
||||
vpp_cycles_per_mb = is_low_power_session(inst) ?
|
||||
inst->capabilities[MB_CYCLES_LP].value :
|
||||
inst->capabilities[MB_CYCLES_VPP].value;
|
||||
@@ -464,7 +464,7 @@ static u64 msm_vidc_calc_freq_iris3_legacy(struct msm_vidc_inst *inst, u32 data_
|
||||
|
||||
vsp_cycles += mbs_per_second * base_cycles;
|
||||
|
||||
} else if (inst->domain == MSM_VIDC_DECODER) {
|
||||
} else if (is_decode_session(inst)) {
|
||||
/* VPP */
|
||||
vpp_cycles = mbs_per_second * inst->capabilities[MB_CYCLES_VPP].value /
|
||||
inst->capabilities[PIPE].value;
|
||||
|
@@ -24,7 +24,7 @@ static int msm_vidc_get_hier_layer_val(struct msm_vidc_inst *inst)
|
||||
{
|
||||
int hierachical_layer = CODEC_GOP_IPP;
|
||||
|
||||
if (inst->domain == MSM_VIDC_ENCODER) {
|
||||
if (is_encode_session(inst)) {
|
||||
if (inst->capabilities[ALL_INTRA].value) {
|
||||
/* no P and B frames case */
|
||||
hierachical_layer = CODEC_GOP_IONLY;
|
||||
@@ -51,9 +51,9 @@ static int msm_vidc_init_codec_input_freq(struct msm_vidc_inst *inst, u32 data_s
|
||||
enum msm_vidc_port_type port;
|
||||
u32 color_fmt, tile_rows_columns = 0;
|
||||
|
||||
if (inst->domain == MSM_VIDC_ENCODER) {
|
||||
if (is_encode_session(inst)) {
|
||||
codec_input->decoder_or_encoder = CODEC_ENCODER;
|
||||
} else if (inst->domain == MSM_VIDC_DECODER) {
|
||||
} else if (is_decode_session(inst)) {
|
||||
codec_input->decoder_or_encoder = CODEC_DECODER;
|
||||
} else {
|
||||
d_vpr_e("%s: invalid domain %d\n", __func__, inst->domain);
|
||||
@@ -91,7 +91,7 @@ static int msm_vidc_init_codec_input_freq(struct msm_vidc_inst *inst, u32 data_s
|
||||
codec_input->pipe_num = inst->capabilities[PIPE].value;
|
||||
codec_input->frame_rate = inst->max_rate;
|
||||
|
||||
port = inst->domain == MSM_VIDC_DECODER ? INPUT_PORT : OUTPUT_PORT;
|
||||
port = is_decode_session(inst) ? INPUT_PORT : OUTPUT_PORT;
|
||||
codec_input->frame_width = inst->fmts[port].fmt.pix_mp.width;
|
||||
codec_input->frame_height = inst->fmts[port].fmt.pix_mp.height;
|
||||
|
||||
@@ -113,7 +113,7 @@ static int msm_vidc_init_codec_input_freq(struct msm_vidc_inst *inst, u32 data_s
|
||||
codec_input->hierachical_layer =
|
||||
msm_vidc_get_hier_layer_val(inst);
|
||||
|
||||
if (inst->domain == MSM_VIDC_DECODER)
|
||||
if (is_decode_session(inst))
|
||||
color_fmt = v4l2_colorformat_to_driver(inst,
|
||||
inst->fmts[OUTPUT_PORT].fmt.pix_mp.pixelformat, __func__);
|
||||
else
|
||||
@@ -122,7 +122,7 @@ static int msm_vidc_init_codec_input_freq(struct msm_vidc_inst *inst, u32 data_s
|
||||
|
||||
codec_input->linear_opb = is_linear_colorformat(color_fmt);
|
||||
|
||||
if (inst->domain == MSM_VIDC_DECODER)
|
||||
if (is_decode_session(inst))
|
||||
codec_input->bitrate_mbps =
|
||||
(codec_input->frame_rate * data_size * 8) / 1000000;
|
||||
else
|
||||
@@ -428,7 +428,7 @@ static u64 msm_vidc_calc_freq_iris33_new(struct msm_vidc_inst *inst, u32 data_si
|
||||
if (ret)
|
||||
return freq;
|
||||
|
||||
if (inst->domain == MSM_VIDC_ENCODER) {
|
||||
if (is_encode_session(inst)) {
|
||||
if (!inst->capabilities[ENC_RING_BUFFER_COUNT].value &&
|
||||
is_vpp_cycles_close_to_freq_corner(core,
|
||||
codec_output.vpp_min_freq)) {
|
||||
@@ -546,7 +546,7 @@ u64 msm_vidc_calc_freq_iris33_legacy(struct msm_vidc_inst *inst, u32 data_size)
|
||||
fw_cycles = fps * inst->capabilities[MB_CYCLES_FW].value;
|
||||
fw_vpp_cycles = fps * inst->capabilities[MB_CYCLES_FW_VPP].value;
|
||||
|
||||
if (inst->domain == MSM_VIDC_ENCODER) {
|
||||
if (is_encode_session(inst)) {
|
||||
vpp_cycles_per_mb = is_low_power_session(inst) ?
|
||||
inst->capabilities[MB_CYCLES_LP].value :
|
||||
inst->capabilities[MB_CYCLES_VPP].value;
|
||||
@@ -613,7 +613,7 @@ u64 msm_vidc_calc_freq_iris33_legacy(struct msm_vidc_inst *inst, u32 data_size)
|
||||
|
||||
vsp_cycles += mbs_per_second * base_cycles;
|
||||
|
||||
} else if (inst->domain == MSM_VIDC_DECODER) {
|
||||
} else if (is_decode_session(inst)) {
|
||||
/* VPP */
|
||||
vpp_cycles = mbs_per_second * inst->capabilities[MB_CYCLES_VPP].value /
|
||||
inst->capabilities[PIPE].value;
|
||||
|
@@ -211,13 +211,13 @@ u32 get_hfi_codec(struct msm_vidc_inst *inst)
|
||||
{
|
||||
switch (inst->codec) {
|
||||
case MSM_VIDC_H264:
|
||||
if (inst->domain == MSM_VIDC_ENCODER)
|
||||
if (is_encode_session(inst))
|
||||
return HFI_CODEC_ENCODE_AVC;
|
||||
else
|
||||
return HFI_CODEC_DECODE_AVC;
|
||||
case MSM_VIDC_HEVC:
|
||||
case MSM_VIDC_HEIC:
|
||||
if (inst->domain == MSM_VIDC_ENCODER)
|
||||
if (is_encode_session(inst))
|
||||
return HFI_CODEC_ENCODE_HEVC;
|
||||
else
|
||||
return HFI_CODEC_DECODE_HEVC;
|
||||
|
@@ -102,9 +102,9 @@ int msm_vidc_querycap(struct msm_vidc_inst *inst, struct v4l2_capability *cap)
|
||||
|
||||
memset(cap->reserved, 0, sizeof(cap->reserved));
|
||||
|
||||
if (inst->domain == MSM_VIDC_DECODER)
|
||||
if (is_decode_session(inst))
|
||||
strlcpy(cap->card, "msm_vidc_decoder", sizeof(cap->card));
|
||||
else if (inst->domain == MSM_VIDC_ENCODER)
|
||||
else if (is_encode_session(inst))
|
||||
strlcpy(cap->card, "msm_vidc_encoder", sizeof(cap->card));
|
||||
else
|
||||
return -EINVAL;
|
||||
@@ -114,9 +114,9 @@ int msm_vidc_querycap(struct msm_vidc_inst *inst, struct v4l2_capability *cap)
|
||||
|
||||
int msm_vidc_enum_fmt(struct msm_vidc_inst *inst, struct v4l2_fmtdesc *f)
|
||||
{
|
||||
if (inst->domain == MSM_VIDC_DECODER)
|
||||
if (is_decode_session(inst))
|
||||
return msm_vdec_enum_fmt(inst, f);
|
||||
if (inst->domain == MSM_VIDC_ENCODER)
|
||||
if (is_encode_session(inst))
|
||||
return msm_venc_enum_fmt(inst, f);
|
||||
|
||||
return -EINVAL;
|
||||
@@ -179,9 +179,9 @@ int msm_vidc_try_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
if (inst->domain == MSM_VIDC_DECODER)
|
||||
if (is_decode_session(inst))
|
||||
rc = msm_vdec_try_fmt(inst, f);
|
||||
if (inst->domain == MSM_VIDC_ENCODER)
|
||||
if (is_encode_session(inst))
|
||||
rc = msm_venc_try_fmt(inst, f);
|
||||
|
||||
if (rc)
|
||||
@@ -194,9 +194,9 @@ int msm_vidc_s_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
if (inst->domain == MSM_VIDC_DECODER)
|
||||
if (is_decode_session(inst))
|
||||
rc = msm_vdec_s_fmt(inst, f);
|
||||
if (inst->domain == MSM_VIDC_ENCODER)
|
||||
if (is_encode_session(inst))
|
||||
rc = msm_venc_s_fmt(inst, f);
|
||||
|
||||
if (rc)
|
||||
@@ -657,9 +657,9 @@ int msm_vidc_subscribe_event(struct msm_vidc_inst *inst,
|
||||
|
||||
i_vpr_h(inst, "%s: type %d id %d\n", __func__, sub->type, sub->id);
|
||||
|
||||
if (inst->domain == MSM_VIDC_DECODER)
|
||||
if (is_decode_session(inst))
|
||||
rc = msm_vdec_subscribe_event(inst, sub);
|
||||
if (inst->domain == MSM_VIDC_ENCODER)
|
||||
if (is_encode_session(inst))
|
||||
rc = msm_venc_subscribe_event(inst, sub);
|
||||
|
||||
return rc;
|
||||
|
@@ -599,7 +599,7 @@ static ssize_t inst_info_read(struct file *file, char __user *buf,
|
||||
f = &inst->fmts[OUTPUT_PORT];
|
||||
cur += write_str(cur, end - cur, "==============================\n");
|
||||
cur += write_str(cur, end - cur, "INSTANCE: %pK (%s)\n", inst,
|
||||
inst->domain == MSM_VIDC_ENCODER ? "Encoder" : "Decoder");
|
||||
is_encode_session(inst) ? "Encoder" : "Decoder");
|
||||
cur += write_str(cur, end - cur, "==============================\n");
|
||||
cur += write_str(cur, end - cur, "core: %pK\n", inst->core);
|
||||
cur += write_str(cur, end - cur, "height: %d\n", f->fmt.pix_mp.height);
|
||||
|
@@ -250,14 +250,14 @@ int msm_vidc_add_buffer_stats(struct msm_vidc_inst *inst,
|
||||
return 0;
|
||||
|
||||
/* stats applicable only to input & output buffers */
|
||||
if (buf->type != MSM_VIDC_BUF_INPUT && buf->type != MSM_VIDC_BUF_OUTPUT)
|
||||
if (!is_input_buffer(buf->type) && !is_output_buffer(buf->type))
|
||||
return -EINVAL;
|
||||
|
||||
/* update start timestamp */
|
||||
buf->start_time_ms = (ktime_get_ns() / 1000 - inst->initial_time_us) / 1000;
|
||||
|
||||
/* add buffer stats only in ETB path */
|
||||
if (buf->type != MSM_VIDC_BUF_INPUT)
|
||||
if (!is_input_buffer(buf->type))
|
||||
return 0;
|
||||
|
||||
stats = msm_vidc_pool_alloc(inst, MSM_MEM_POOL_BUF_STATS);
|
||||
@@ -287,7 +287,7 @@ int msm_vidc_remove_buffer_stats(struct msm_vidc_inst *inst,
|
||||
return 0;
|
||||
|
||||
/* stats applicable only to input & output buffers */
|
||||
if (buf->type != MSM_VIDC_BUF_INPUT && buf->type != MSM_VIDC_BUF_OUTPUT)
|
||||
if (!is_input_buffer(buf->type) && !is_output_buffer(buf->type))
|
||||
return -EINVAL;
|
||||
|
||||
/* update end timestamp */
|
||||
@@ -298,7 +298,7 @@ int msm_vidc_remove_buffer_stats(struct msm_vidc_inst *inst,
|
||||
continue;
|
||||
|
||||
remove_stat = false;
|
||||
if (buf->type == MSM_VIDC_BUF_INPUT) {
|
||||
if (is_input_buffer(buf->type)) {
|
||||
/* skip - ebd already updated(multiple input - single output case) */
|
||||
if (stats->ebd_time_ms)
|
||||
continue;
|
||||
@@ -320,7 +320,7 @@ int msm_vidc_remove_buffer_stats(struct msm_vidc_inst *inst,
|
||||
/* remove entry - no output attached */
|
||||
remove_stat = !!(stats->flags & MSM_VIDC_STATS_FLAG_NO_OUTPUT);
|
||||
remove_stat |= stats->ebd_time_ms && stats->fbd_time_ms;
|
||||
} else if (buf->type == MSM_VIDC_BUF_OUTPUT) {
|
||||
} else if (is_output_buffer(buf->type)) {
|
||||
/* skip - ebd already updated(encoder superframe case) */
|
||||
if (stats->fbd_time_ms)
|
||||
continue;
|
||||
@@ -952,7 +952,7 @@ bool is_hevc_10bit_decode_session(struct msm_vidc_inst *inst)
|
||||
if (colorformat == MSM_VIDC_FMT_TP10C || colorformat == MSM_VIDC_FMT_P010)
|
||||
is10bit = true;
|
||||
|
||||
return inst->domain == MSM_VIDC_DECODER &&
|
||||
return is_decode_session(inst) &&
|
||||
inst->codec == MSM_VIDC_HEVC &&
|
||||
is10bit;
|
||||
}
|
||||
@@ -1497,9 +1497,9 @@ int msm_vidc_num_buffers(struct msm_vidc_inst *inst,
|
||||
struct msm_vidc_buffer *vbuf;
|
||||
struct msm_vidc_buffers *buffers;
|
||||
|
||||
if (type == MSM_VIDC_BUF_OUTPUT) {
|
||||
if (is_output_buffer(type)) {
|
||||
buffers = &inst->buffers.output;
|
||||
} else if (type == MSM_VIDC_BUF_INPUT) {
|
||||
} else if (is_input_buffer(type)) {
|
||||
buffers = &inst->buffers.input;
|
||||
} else {
|
||||
i_vpr_e(inst, "%s: invalid buffer type %#x\n",
|
||||
@@ -2087,9 +2087,9 @@ struct msm_vidc_buffer *get_meta_buffer(struct msm_vidc_inst *inst,
|
||||
struct msm_vidc_buffers *buffers;
|
||||
bool found = false;
|
||||
|
||||
if (buf->type == MSM_VIDC_BUF_INPUT) {
|
||||
if (is_input_buffer(buf->type)) {
|
||||
buffers = &inst->buffers.input_meta;
|
||||
} else if (buf->type == MSM_VIDC_BUF_OUTPUT) {
|
||||
} else if (is_output_buffer(buf->type)) {
|
||||
buffers = &inst->buffers.output_meta;
|
||||
} else {
|
||||
i_vpr_e(inst, "%s: invalid buffer type %d\n",
|
||||
@@ -3916,7 +3916,7 @@ int msm_vidc_print_inst_info(struct msm_vidc_inst *inst)
|
||||
int i = 0;
|
||||
|
||||
is_secure = is_secure_session(inst);
|
||||
is_decode = inst->domain == MSM_VIDC_DECODER;
|
||||
is_decode = is_decode_session(inst);
|
||||
port = is_decode ? INPUT_PORT : OUTPUT_PORT;
|
||||
width = inst->fmts[port].fmt.pix_mp.width;
|
||||
height = inst->fmts[port].fmt.pix_mp.height;
|
||||
@@ -4213,10 +4213,10 @@ int msm_vidc_flush_buffers(struct msm_vidc_inst *inst,
|
||||
int i;
|
||||
core = inst->core;
|
||||
|
||||
if (type == MSM_VIDC_BUF_INPUT) {
|
||||
if (is_input_buffer(type)) {
|
||||
buffer_type[0] = MSM_VIDC_BUF_INPUT_META;
|
||||
buffer_type[1] = MSM_VIDC_BUF_INPUT;
|
||||
} else if (type == MSM_VIDC_BUF_OUTPUT) {
|
||||
} else if (is_output_buffer(type)) {
|
||||
buffer_type[0] = MSM_VIDC_BUF_OUTPUT_META;
|
||||
buffer_type[1] = MSM_VIDC_BUF_OUTPUT;
|
||||
} else {
|
||||
|
@@ -242,7 +242,7 @@ int msm_vidc_scale_buses(struct msm_vidc_inst *inst)
|
||||
inst->capabilities[SUPER_BLOCK].value ? 128 : 64;
|
||||
vote_data->fps = inst->max_rate;
|
||||
|
||||
if (inst->domain == MSM_VIDC_ENCODER) {
|
||||
if (is_encode_session(inst)) {
|
||||
vote_data->domain = MSM_VIDC_ENCODER;
|
||||
vote_data->bitrate = inst->capabilities[BIT_RATE].value;
|
||||
vote_data->rotation = inst->capabilities[ROTATION].value;
|
||||
@@ -260,7 +260,7 @@ int msm_vidc_scale_buses(struct msm_vidc_inst *inst)
|
||||
inst->fmts[INPUT_PORT].fmt.pix_mp.pixelformat, __func__);
|
||||
vote_data->vpss_preprocessing_enabled =
|
||||
inst->capabilities[REQUEST_PREPROCESS].value;
|
||||
} else if (inst->domain == MSM_VIDC_DECODER) {
|
||||
} else if (is_decode_session(inst)) {
|
||||
u32 color_format;
|
||||
|
||||
vote_data->domain = MSM_VIDC_DECODER;
|
||||
|
@@ -748,13 +748,13 @@ static int msm_vidc_input_streaming_state(struct msm_vidc_inst *inst,
|
||||
}
|
||||
|
||||
/* disallow */
|
||||
if (buf->type != MSM_VIDC_BUF_INPUT && buf->type != MSM_VIDC_BUF_OUTPUT) {
|
||||
if (!is_input_buffer(buf->type) && !is_output_buffer(buf->type)) {
|
||||
i_vpr_e(inst, "%s: invalid buf type %u\n", __func__, buf->type);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* defer output port */
|
||||
if (buf->type == MSM_VIDC_BUF_OUTPUT) {
|
||||
if (is_output_buffer(buf->type)) {
|
||||
print_vidc_buffer(VIDC_LOW, "low ", "qbuf deferred", inst, buf);
|
||||
return 0;
|
||||
}
|
||||
@@ -945,13 +945,13 @@ static int msm_vidc_output_streaming_state(struct msm_vidc_inst *inst,
|
||||
}
|
||||
|
||||
/* disallow */
|
||||
if (buf->type != MSM_VIDC_BUF_INPUT && buf->type != MSM_VIDC_BUF_OUTPUT) {
|
||||
if (!is_input_buffer(buf->type) && !is_output_buffer(buf->type)) {
|
||||
i_vpr_e(inst, "%s: invalid buf type %u\n", __func__, buf->type);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* defer input port */
|
||||
if (buf->type == MSM_VIDC_BUF_INPUT) {
|
||||
if (is_input_buffer(buf->type)) {
|
||||
print_vidc_buffer(VIDC_LOW, "low ", "qbuf deferred", inst, buf);
|
||||
return 0;
|
||||
}
|
||||
@@ -1134,7 +1134,7 @@ static int msm_vidc_streaming_state(struct msm_vidc_inst *inst,
|
||||
}
|
||||
|
||||
/* disallow */
|
||||
if (buf->type != MSM_VIDC_BUF_INPUT && buf->type != MSM_VIDC_BUF_OUTPUT) {
|
||||
if (!is_input_buffer(buf->type) && !is_output_buffer(buf->type)) {
|
||||
i_vpr_e(inst, "%s: invalid buf type %u\n", __func__, buf->type);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
Verwijs in nieuw issue
Block a user