Bläddra i källkod

video: driver: initialize subscribe parameters

Initialize subscribe parameters before input port settings
change event from firmware to avoid uninitialized subscribe
params usage in video driver.

Change-Id: I39a1e6646a845836a406193ace7a5fb71edee192
Depends-On: I07c7c8b4faaccc896249b2da84148ec05c2047da
Signed-off-by: Maheshwar Ajja <[email protected]>
Maheshwar Ajja 4 år sedan
förälder
incheckning
b297e04dee

+ 6 - 2
driver/variant/iris2/src/msm_vidc_buffer_iris2.c

@@ -23,7 +23,7 @@ static u32 msm_vidc_decoder_bin_size_iris2(struct msm_vidc_inst *inst)
 	bool is_interlaced;
 	u32 vpp_delay;
 
-	if (!inst || !inst->core) {
+	if (!inst || !inst->core || !inst->capabilities) {
 		d_vpr_e("%s: invalid params\n", __func__);
 		return size;
 	}
@@ -38,7 +38,11 @@ static u32 msm_vidc_decoder_bin_size_iris2(struct msm_vidc_inst *inst)
 		vpp_delay = inst->decode_vpp_delay.size;
 	else
 		vpp_delay = DEFAULT_BSE_VPP_DELAY;
-	is_interlaced = false; //TODO: (inst->pic_struct == MSM_VIDC_PIC_STRUCT_MAYBE_INTERLACED);
+	if (inst->capabilities->cap[CODED_FRAMES].value ==
+			CODED_FRAMES_PROGRESSIVE)
+		is_interlaced = false;
+	else
+		is_interlaced = true;
 	f = &inst->fmts[INPUT_PORT];
 	width = f->fmt.pix_mp.width;
 	height = f->fmt.pix_mp.height;

+ 1 - 0
driver/vidc/inc/msm_vdec.h

@@ -25,6 +25,7 @@ int msm_vdec_g_param(struct msm_vidc_inst *inst,
 int msm_vdec_enum_fmt(struct msm_vidc_inst *inst, struct v4l2_fmtdesc *f);
 int msm_vdec_inst_init(struct msm_vidc_inst *inst);
 int msm_vdec_inst_deinit(struct msm_vidc_inst *inst);
+int msm_vdec_init_input_subcr_params(struct msm_vidc_inst *inst);
 int msm_vdec_input_port_settings_change(struct msm_vidc_inst *inst);
 int msm_vdec_output_port_settings_change(struct msm_vidc_inst *inst);
 int msm_vdec_process_cmd(struct msm_vidc_inst *inst, u32 cmd);

+ 71 - 4
driver/vidc/src/msm_vdec.c

@@ -253,14 +253,16 @@ static int msm_vdec_set_coded_frames(struct msm_vidc_inst *inst,
 	enum msm_vidc_port_type port)
 {
 	int rc = 0;
-	u32 coded_frames;
+	u32 coded_frames = 0;
 
 	if (port != INPUT_PORT && port != OUTPUT_PORT) {
 		i_vpr_e(inst, "%s: invalid port %d\n", __func__, port);
 		return -EINVAL;
 	}
 
-	coded_frames = inst->capabilities->cap[CODED_FRAMES].value;
+	if (inst->capabilities->cap[CODED_FRAMES].value ==
+			CODED_FRAMES_PROGRESSIVE)
+		coded_frames = HFI_BITMASK_FRAME_MBS_ONLY_FLAG;
 	inst->subcr_params[port].coded_frames = coded_frames;
 	i_vpr_h(inst, "%s: coded frames: %d", __func__, coded_frames);
 	rc = venus_hfi_session_property(inst,
@@ -1237,7 +1239,72 @@ static int msm_vdec_session_resume(struct msm_vidc_inst *inst,
 	return rc;
 }
 
-static int msm_vdec_update_properties(struct msm_vidc_inst *inst)
+int msm_vdec_init_input_subcr_params(struct msm_vidc_inst *inst)
+{
+	struct msm_vidc_subscription_params *subsc_params;
+	struct msm_vidc_core *core;
+	u32 left_offset, top_offset, right_offset, bottom_offset;
+	u32 primaries, matrix_coeff, transfer_char;
+	u32 full_range = 0, video_format = 0;
+	u32 colour_description_present_flag = 0;
+	u32 video_signal_type_present_flag = 0;
+
+	if (!inst || !inst->core || !inst->capabilities) {
+		d_vpr_e("%s: invalid params\n", __func__);
+		return -EINVAL;
+	}
+	core = inst->core;
+	subsc_params = &inst->subcr_params[INPUT_PORT];
+
+	subsc_params->bitstream_resolution =
+		inst->fmts[INPUT_PORT].fmt.pix_mp.width << 16 |
+		inst->fmts[INPUT_PORT].fmt.pix_mp.height;
+
+	left_offset = inst->crop.left;
+	top_offset = inst->crop.top;
+	right_offset = (inst->fmts[INPUT_PORT].fmt.pix_mp.width -
+			inst->crop.width);
+	bottom_offset = (inst->fmts[INPUT_PORT].fmt.pix_mp.height -
+			inst->crop.height);
+	subsc_params->crop_offsets[0] =
+			left_offset << 16 | top_offset;
+	subsc_params->crop_offsets[1] =
+			right_offset << 16 | bottom_offset;
+
+	subsc_params->fw_min_count = inst->buffers.output.min_count;
+
+	primaries = v4l2_color_primaries_from_driver(inst,
+		inst->fmts[INPUT_PORT].fmt.pix_mp.colorspace);
+	matrix_coeff = v4l2_matrix_coeff_from_driver(inst,
+		inst->fmts[INPUT_PORT].fmt.pix_mp.ycbcr_enc);
+	transfer_char = v4l2_transfer_char_from_driver(inst,
+		inst->fmts[INPUT_PORT].fmt.pix_mp.xfer_func);
+	full_range = inst->fmts[INPUT_PORT].fmt.pix_mp.quantization ==
+		V4L2_QUANTIZATION_FULL_RANGE ? 1 : 0;
+	subsc_params->color_info =
+		(matrix_coeff & 0xFF) |
+		((transfer_char << 8) & 0xFF00) |
+		((primaries << 16) & 0xFF0000) |
+		((colour_description_present_flag << 24) & 0x1000000) |
+		((full_range << 25) & 0x2000000) |
+		((video_format << 26) & 0x1C000000) |
+		((video_signal_type_present_flag << 29) & 0x20000000);
+
+	subsc_params->profile = inst->capabilities->cap[PROFILE].value;
+	subsc_params->level = inst->capabilities->cap[LEVEL].value;
+	subsc_params->tier = inst->capabilities->cap[HEVC_TIER].value;
+	subsc_params->pic_order_cnt = inst->capabilities->cap[POC].value;
+	subsc_params->bit_depth = inst->capabilities->cap[BIT_DEPTH].value;
+	if (inst->capabilities->cap[CODED_FRAMES].value ==
+			CODED_FRAMES_PROGRESSIVE)
+		subsc_params->coded_frames = HFI_BITMASK_FRAME_MBS_ONLY_FLAG;
+	else
+		subsc_params->coded_frames = 0;
+
+	return 0;
+}
+
+static int msm_vdec_read_input_subcr_params(struct msm_vidc_inst *inst)
 {
 	struct msm_vidc_subscription_params subsc_params;
 	struct msm_vidc_core *core;
@@ -1345,7 +1412,7 @@ int msm_vdec_input_port_settings_change(struct msm_vidc_inst *inst)
 		return 0;
 	}
 
-	rc = msm_vdec_update_properties(inst);
+	rc = msm_vdec_read_input_subcr_params(inst);
 	if (rc)
 		return rc;
 

+ 3 - 0
driver/vidc/src/venus_hfi_response.c

@@ -1312,6 +1312,9 @@ int handle_session_response_work(struct msm_vidc_inst *inst,
 		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++) {