mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 17:47:41 +02:00
media: qcom: iris: Add B frames support for encoder
Add support for B-frame configuration on both gen1 and gen2 encoders by enabling V4L2_CID_MPEG_VIDEO_B_FRAMES control. Reviewed-by: Dikshita Agarwal <dikshita.agarwal@oss.qualcomm.com> Tested-by: Neil Armstrong <neil.armstrong@linaro.org> # on SM8650-HDK Signed-off-by: Wangao Wang <wangao.wang@oss.qualcomm.com> Signed-off-by: Bryan O'Donoghue <bod@kernel.org>
This commit is contained in:
parent
6870381285
commit
e4d067d5e9
|
|
@ -118,6 +118,8 @@ static enum platform_inst_fw_cap_type iris_get_cap_id(u32 id)
|
|||
return USE_LTR;
|
||||
case V4L2_CID_MPEG_VIDEO_FRAME_LTR_INDEX:
|
||||
return MARK_LTR;
|
||||
case V4L2_CID_MPEG_VIDEO_B_FRAMES:
|
||||
return B_FRAME;
|
||||
default:
|
||||
return INST_FW_CAP_MAX;
|
||||
}
|
||||
|
|
@ -225,6 +227,8 @@ static u32 iris_get_v4l2_id(enum platform_inst_fw_cap_type cap_id)
|
|||
return V4L2_CID_MPEG_VIDEO_USE_LTR_FRAMES;
|
||||
case MARK_LTR:
|
||||
return V4L2_CID_MPEG_VIDEO_FRAME_LTR_INDEX;
|
||||
case B_FRAME:
|
||||
return V4L2_CID_MPEG_VIDEO_B_FRAMES;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1161,6 +1165,32 @@ int iris_set_use_and_mark_ltr(struct iris_inst *inst, enum platform_inst_fw_cap_
|
|||
&hfi_val, sizeof(u32));
|
||||
}
|
||||
|
||||
int iris_set_intra_period(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id)
|
||||
{
|
||||
const struct iris_hfi_session_ops *hfi_ops = inst->hfi_session_ops;
|
||||
u32 gop_size = inst->fw_caps[GOP_SIZE].value;
|
||||
u32 b_frame = inst->fw_caps[B_FRAME].value;
|
||||
u32 hfi_id = inst->fw_caps[cap_id].hfi_id;
|
||||
struct hfi_intra_period intra_period;
|
||||
|
||||
if (!gop_size || b_frame >= gop_size)
|
||||
return -EINVAL;
|
||||
|
||||
/*
|
||||
* intra_period represents the length of a GOP, which includes both P-frames
|
||||
* and B-frames. The counts of P-frames and B-frames within a GOP must be
|
||||
* communicated to the firmware.
|
||||
*/
|
||||
intra_period.pframes = (gop_size - 1) / (b_frame + 1);
|
||||
intra_period.bframes = b_frame;
|
||||
|
||||
return hfi_ops->session_set_property(inst, hfi_id,
|
||||
HFI_HOST_FLAGS_NONE,
|
||||
iris_get_port_info(inst, cap_id),
|
||||
HFI_PAYLOAD_STRUCTURE,
|
||||
&intra_period, sizeof(intra_period));
|
||||
}
|
||||
|
||||
int iris_set_properties(struct iris_inst *inst, u32 plane)
|
||||
{
|
||||
const struct iris_hfi_session_ops *hfi_ops = inst->hfi_session_ops;
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ int iris_set_ltr_count_gen2(struct iris_inst *inst, enum platform_inst_fw_cap_ty
|
|||
int iris_set_use_ltr(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id);
|
||||
int iris_set_mark_ltr(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id);
|
||||
int iris_set_use_and_mark_ltr(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id);
|
||||
int iris_set_intra_period(struct iris_inst *inst, enum platform_inst_fw_cap_type cap_id);
|
||||
int iris_set_properties(struct iris_inst *inst, u32 plane);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -273,6 +273,24 @@ static const struct platform_inst_fw_cap inst_fw_cap_sm8250_enc[] = {
|
|||
.flags = CAP_FLAG_INPUT_PORT | CAP_FLAG_DYNAMIC_ALLOWED,
|
||||
.set = iris_set_mark_ltr,
|
||||
},
|
||||
{
|
||||
.cap_id = B_FRAME,
|
||||
.min = 0,
|
||||
.max = 3,
|
||||
.step_or_mask = 1,
|
||||
.value = 0,
|
||||
.flags = CAP_FLAG_OUTPUT_PORT,
|
||||
},
|
||||
{
|
||||
.cap_id = INTRA_PERIOD,
|
||||
.min = 0,
|
||||
.max = 1,
|
||||
.step_or_mask = 1,
|
||||
.value = 0,
|
||||
.hfi_id = HFI_PROPERTY_CONFIG_VENC_INTRA_PERIOD,
|
||||
.flags = CAP_FLAG_OUTPUT_PORT,
|
||||
.set = iris_set_intra_period,
|
||||
},
|
||||
};
|
||||
|
||||
static const u32 sm8250_vdec_input_config_param_default[] = {
|
||||
|
|
|
|||
|
|
@ -720,6 +720,14 @@ iris_hfi_gen1_packet_session_set_property(struct hfi_session_set_property_pkt *p
|
|||
packet->shdr.hdr.size += sizeof(u32) + sizeof(*ltr_mark);
|
||||
break;
|
||||
}
|
||||
case HFI_PROPERTY_CONFIG_VENC_INTRA_PERIOD: {
|
||||
struct hfi_intra_period *in = pdata, *intra_period = prop_data;
|
||||
|
||||
intra_period->pframes = in->pframes;
|
||||
intra_period->bframes = in->bframes;
|
||||
packet->shdr.hdr.size += sizeof(u32) + sizeof(*intra_period);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -155,6 +155,7 @@
|
|||
#define HFI_PROPERTY_PARAM_VENC_LTRMODE 0x200501c
|
||||
#define HFI_PROPERTY_PARAM_VENC_MAX_NUM_B_FRAMES 0x2005020
|
||||
#define HFI_PROPERTY_CONFIG_VENC_TARGET_BITRATE 0x2006001
|
||||
#define HFI_PROPERTY_CONFIG_VENC_INTRA_PERIOD 0x2006003
|
||||
#define HFI_PROPERTY_CONFIG_VENC_MARKLTRFRAME 0x2006009
|
||||
#define HFI_PROPERTY_CONFIG_VENC_USELTRFRAME 0x200600a
|
||||
#define HFI_PROPERTY_CONFIG_VENC_SYNC_FRAME_SEQUENCE_HEADER 0x2006008
|
||||
|
|
@ -484,6 +485,15 @@ struct hfi_ltr_mark {
|
|||
u32 mark_frame;
|
||||
};
|
||||
|
||||
struct hfi_max_num_b_frames {
|
||||
u32 max_num_b_frames;
|
||||
};
|
||||
|
||||
struct hfi_intra_period {
|
||||
u32 pframes;
|
||||
u32 bframes;
|
||||
};
|
||||
|
||||
struct hfi_event_data {
|
||||
u32 error;
|
||||
u32 height;
|
||||
|
|
|
|||
|
|
@ -745,6 +745,16 @@ static const struct platform_inst_fw_cap inst_fw_cap_sm8550_enc[] = {
|
|||
.flags = CAP_FLAG_INPUT_PORT | CAP_FLAG_DYNAMIC_ALLOWED,
|
||||
.set = iris_set_use_and_mark_ltr,
|
||||
},
|
||||
{
|
||||
.cap_id = B_FRAME,
|
||||
.min = 0,
|
||||
.max = 1,
|
||||
.step_or_mask = 1,
|
||||
.value = 0,
|
||||
.hfi_id = HFI_PROP_MAX_B_FRAMES,
|
||||
.flags = CAP_FLAG_OUTPUT_PORT,
|
||||
.set = iris_set_u32,
|
||||
},
|
||||
};
|
||||
|
||||
static const u32 sm8550_vdec_input_config_params_default[] = {
|
||||
|
|
|
|||
|
|
@ -157,6 +157,8 @@ enum platform_inst_fw_cap_type {
|
|||
LTR_COUNT,
|
||||
USE_LTR,
|
||||
MARK_LTR,
|
||||
B_FRAME,
|
||||
INTRA_PERIOD,
|
||||
INST_FW_CAP_MAX,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -936,11 +936,15 @@ static u32 iris_vpu_enc_bin_size(struct iris_inst *inst)
|
|||
|
||||
static inline u32 hfi_buffer_get_recon_count(struct iris_inst *inst)
|
||||
{
|
||||
u32 bframe_count, ltr_count;
|
||||
u32 num_ref = 1;
|
||||
u32 ltr_count;
|
||||
|
||||
bframe_count = inst->fw_caps[B_FRAME].value;
|
||||
ltr_count = inst->fw_caps[LTR_COUNT].value;
|
||||
|
||||
if (bframe_count)
|
||||
num_ref = 2;
|
||||
|
||||
if (ltr_count)
|
||||
num_ref = num_ref + ltr_count;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user