Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d2c21b18 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: vidc: enable lossless encoding via debugfs"

parents aa079722 2096f084
Loading
Loading
Loading
Loading
+42 −1
Original line number Diff line number Diff line
@@ -1333,6 +1333,14 @@ static int msm_venc_resolve_rc_enable(struct msm_vidc_inst *inst,
		rc_mode = get_ctrl(inst, V4L2_CID_MPEG_VIDEO_BITRATE_MODE);
		inst->rc_type = rc_mode->val;
	}

	if (msm_vidc_lossless_encode &&
		(inst->fmts[CAPTURE_PORT].fourcc == V4L2_PIX_FMT_H264
		|| inst->fmts[CAPTURE_PORT].fourcc == V4L2_PIX_FMT_HEVC)) {
		dprintk(VIDC_DBG,
			"Reset RC mode to RC_LOSSLESS for HEVC/AVC lossless encoding\n");
		inst->rc_type = RATE_CONTROL_LOSSLESS;
	}
	return 0;
}

@@ -1341,6 +1349,12 @@ static int msm_venc_resolve_rate_control(struct msm_vidc_inst *inst,
{
	struct v4l2_ctrl *rc_enable;

	if (inst->rc_type == RATE_CONTROL_LOSSLESS) {
		dprintk(VIDC_DBG,
			"Skip RC mode when enabling lossless encoding\n");
		return 0;
	}

	rc_enable = get_ctrl(inst, V4L2_CID_MPEG_VIDEO_FRAME_RC_ENABLE);
	if (!rc_enable->val) {
		dprintk(VIDC_ERR,
@@ -1354,7 +1368,6 @@ static int msm_venc_resolve_rate_control(struct msm_vidc_inst *inst,
		return -EINVAL;
	}
	inst->rc_type = ctrl->val;

	return 0;
}

@@ -2295,6 +2308,7 @@ int msm_venc_set_rate_control(struct msm_vidc_inst *inst)

	switch (inst->rc_type) {
	case RATE_CONTROL_OFF:
	case RATE_CONTROL_LOSSLESS:
		hfi_rc = HFI_RATE_CONTROL_OFF;
		break;
	case V4L2_MPEG_VIDEO_BITRATE_MODE_CBR:
@@ -3802,6 +3816,30 @@ int msm_venc_set_extradata(struct msm_vidc_inst *inst)
	return rc;
}

int msm_venc_set_lossless(struct msm_vidc_inst *inst)
{
	int rc = 0;
	struct hfi_device *hdev;
	struct hfi_enable enable;

	hdev = inst->core->device;

	if (inst->rc_type != RATE_CONTROL_LOSSLESS)
		return 0;

	dprintk(VIDC_DBG, "%s: enable lossless encoding\n", __func__);
	enable.enable = 1;
	rc = call_hfi_op(hdev, session_set_property,
		inst->session,
		HFI_PROPERTY_PARAM_VENC_LOSSLESS_ENCODING,
		&enable, sizeof(enable));

	if (rc)
		dprintk(VIDC_ERR, "Failed to set lossless mode\n");

	return rc;
}

int msm_venc_set_properties(struct msm_vidc_inst *inst)
{
	int rc = 0;
@@ -3934,6 +3972,9 @@ int msm_venc_set_properties(struct msm_vidc_inst *inst)
	rc = msm_venc_set_rotation(inst);
	if (rc)
		goto exit;
	rc = msm_venc_set_lossless(inst);
	if (rc)
		goto exit;

exit:
	if (rc)
+1 −0
Original line number Diff line number Diff line
@@ -34,4 +34,5 @@ int msm_venc_set_intra_refresh_mode(struct msm_vidc_inst *inst);
int msm_venc_set_hp_max_layer(struct msm_vidc_inst *inst);
int msm_venc_set_hp_layer(struct msm_vidc_inst *inst);
int msm_venc_set_base_layer_priority_id(struct msm_vidc_inst *inst);
int msm_venc_set_lossless(struct msm_vidc_inst *inst);
#endif
+3 −0
Original line number Diff line number Diff line
@@ -851,6 +851,9 @@ u32 msm_vidc_calculate_enc_output_frame_size(struct msm_vidc_inst *inst)
		(inst->rc_type == V4L2_MPEG_VIDEO_BITRATE_MODE_CQ))
		frame_size = frame_size << 1;

	if (inst->rc_type == RATE_CONTROL_LOSSLESS)
		frame_size = (width * height * 6);

	return ALIGN(frame_size, SZ_4K);
}

+2 −1
Original line number Diff line number Diff line
@@ -1541,10 +1541,11 @@ static inline int msm_vidc_power_save_mode_enable(struct msm_vidc_inst *inst,
		return 0;
	}

	/* Power saving always disabled for CQ RC mode. */
	/* Power saving always disabled for CQ and LOSSLESS RC modes. */
	mbs_per_frame = msm_vidc_get_mbs_per_frame(inst);
	mbs_per_sec = mbs_per_frame * msm_vidc_get_fps(inst);
	if (inst->rc_type == V4L2_MPEG_VIDEO_BITRATE_MODE_CQ ||
		inst->rc_type == RATE_CONTROL_LOSSLESS ||
		(mbs_per_frame <=
		 inst->core->resources.max_hq_mbs_per_frame &&
		 mbs_per_sec <=
+6 −1
Original line number Diff line number Diff line
@@ -15,6 +15,9 @@ EXPORT_SYMBOL(msm_vidc_debug);
int msm_vidc_debug_out = VIDC_OUT_PRINTK;
EXPORT_SYMBOL(msm_vidc_debug_out);

bool msm_vidc_lossless_encode = !true;
EXPORT_SYMBOL(msm_vidc_lossless_encode);

int msm_vidc_fw_debug = 0x18;
int msm_vidc_fw_debug_mode = 1;
bool msm_vidc_fw_coverage = !true;
@@ -183,7 +186,9 @@ struct dentry *msm_vidc_debugfs_init_drv(void)
	__debugfs_create(u32, "core_clock_voting",
			&msm_vidc_clock_voting) &&
	__debugfs_create(bool, "disable_video_syscache",
			&msm_vidc_syscache_disable);
			&msm_vidc_syscache_disable) &&
	__debugfs_create(bool, "lossless_encoding",
			&msm_vidc_lossless_encode);

#undef __debugfs_create

Loading