Browse Source

video: driver: driver fixes required for latest firmware

Update debug packet structure to use waipio related debug
packet structure. Also add HFI_INFORMATION_END cmd
packets handling in reverse thread.

Change-Id: Idbd421d8ada0e8c9d33df54e6f3708b1079c8b47
Signed-off-by: Akshata Sahukar <[email protected]>
Akshata Sahukar 4 years ago
parent
commit
e970285cda

+ 1 - 1
driver/platform/waipio/src/msm_vidc_waipio.c

@@ -64,7 +64,7 @@ static struct msm_platform_core_capability core_data_waipio[] = {
 	{SW_PC_DELAY, 1500}, /* 1500 ms */
 	{SW_PC_DELAY, 1500}, /* 1500 ms */
 	{FW_UNLOAD, 0},
 	{FW_UNLOAD, 0},
 	{FW_UNLOAD_DELAY, 1000}, /* 1000 ms */
 	{FW_UNLOAD_DELAY, 1000}, /* 1000 ms */
-	{HW_RESPONSE_TIMEOUT, 3000}, /* 1000 ms */
+	{HW_RESPONSE_TIMEOUT, 5000}, /* 1000 ms */
 	{DEBUG_TIMEOUT, 0},
 	{DEBUG_TIMEOUT, 0},
 	{PREFIX_BUF_COUNT_PIX, 18},
 	{PREFIX_BUF_COUNT_PIX, 18},
 	{PREFIX_BUF_SIZE_PIX, 13434880}, /* Calculated by VENUS_BUFFER_SIZE for 4096x2160 UBWC */
 	{PREFIX_BUF_SIZE_PIX, 13434880}, /* Calculated by VENUS_BUFFER_SIZE for 4096x2160 UBWC */

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

@@ -21,5 +21,7 @@ int msm_vdec_inst_init(struct msm_vidc_inst *inst);
 int msm_vdec_input_port_settings_change(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_output_port_settings_change(struct msm_vidc_inst *inst);
 int msm_vdec_process_cmd(struct msm_vidc_inst *inst, u32 cmd);
 int msm_vdec_process_cmd(struct msm_vidc_inst *inst, u32 cmd);
+int msm_vdec_subscribe_port_settings_change(struct msm_vidc_inst *inst,
+	enum msm_vidc_port_type port);
 
 
 #endif // _MSM_VDEC_H_
 #endif // _MSM_VDEC_H_

+ 1 - 1
driver/vidc/inc/msm_vidc_inst.h

@@ -118,7 +118,7 @@ struct msm_vidc_inst {
 	struct list_head                   input_ts;
 	struct list_head                   input_ts;
 	struct list_head                   enc_input_crs;
 	struct list_head                   enc_input_crs;
 	struct list_head                   decode_bitrate_data;
 	struct list_head                   decode_bitrate_data;
-	bool                               codec_set;
+	bool                               once_per_session_set;
 	struct dentry                     *debugfs_root;
 	struct dentry                     *debugfs_root;
 	struct msm_vidc_debug              debug;
 	struct msm_vidc_debug              debug;
 	struct msm_vidc_inst_capability   *capabilities;
 	struct msm_vidc_inst_capability   *capabilities;

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

@@ -131,6 +131,7 @@ enum msm_vidc_buffer_type {
 	MSM_VIDC_BUF_LINE,
 	MSM_VIDC_BUF_LINE,
 	MSM_VIDC_BUF_DPB,
 	MSM_VIDC_BUF_DPB,
 	MSM_VIDC_BUF_PERSIST,
 	MSM_VIDC_BUF_PERSIST,
+	MSM_VIDC_BUF_VPSS,
 };
 };
 
 
 /* always match with v4l2 flags V4L2_BUF_FLAG_* */
 /* always match with v4l2 flags V4L2_BUF_FLAG_* */

+ 10 - 14
driver/vidc/src/msm_vdec.c

@@ -736,16 +736,20 @@ static int msm_vdec_get_input_internal_buffers(struct msm_vidc_inst *inst)
 	}
 	}
 	core = inst->core;
 	core = inst->core;
 
 
+	/*
+	 * TODO: Remove the hack of sending bigger buffer sizes
+	 * once internal buffer calculations are finalised
+	 */
 	inst->buffers.bin.size = call_session_op(core, buffer_size,
 	inst->buffers.bin.size = call_session_op(core, buffer_size,
-			inst, MSM_VIDC_BUF_BIN);
+			inst, MSM_VIDC_BUF_BIN) + 100000000;
 	inst->buffers.comv.size = call_session_op(core, buffer_size,
 	inst->buffers.comv.size = call_session_op(core, buffer_size,
-			inst, MSM_VIDC_BUF_COMV);
+			inst, MSM_VIDC_BUF_COMV) + 100000000;
 	inst->buffers.non_comv.size = call_session_op(core, buffer_size,
 	inst->buffers.non_comv.size = call_session_op(core, buffer_size,
-			inst, MSM_VIDC_BUF_NON_COMV);
+			inst, MSM_VIDC_BUF_NON_COMV) + 100000000;
 	inst->buffers.line.size = call_session_op(core, buffer_size,
 	inst->buffers.line.size = call_session_op(core, buffer_size,
-			inst, MSM_VIDC_BUF_LINE);
+			inst, MSM_VIDC_BUF_LINE) + 100000000;
 	inst->buffers.persist.size = call_session_op(core, buffer_size,
 	inst->buffers.persist.size = call_session_op(core, buffer_size,
-			inst, MSM_VIDC_BUF_PERSIST);
+			inst, MSM_VIDC_BUF_PERSIST) + 100000000;
 
 
 	inst->buffers.bin.min_count = call_session_op(core, min_count,
 	inst->buffers.bin.min_count = call_session_op(core, min_count,
 			inst, MSM_VIDC_BUF_BIN);
 			inst, MSM_VIDC_BUF_BIN);
@@ -866,7 +870,7 @@ static int msm_vdec_release_input_internal_buffers(struct msm_vidc_inst *inst)
 	return 0;
 	return 0;
 }
 }
 
 
-static int msm_vdec_subscribe_port_settings_change(struct msm_vidc_inst *inst,
+int msm_vdec_subscribe_port_settings_change(struct msm_vidc_inst *inst,
 	enum msm_vidc_port_type port)
 	enum msm_vidc_port_type port)
 {
 {
 	int rc = 0;
 	int rc = 0;
@@ -1212,10 +1216,6 @@ int msm_vdec_start_input(struct msm_vidc_inst *inst)
 	if (rc)
 	if (rc)
 		goto error;
 		goto error;
 
 
-	rc = msm_vdec_subscribe_port_settings_change(inst, INPUT_PORT);
-	if (rc)
-		return rc;
-
 	rc = msm_vdec_subscribe_property(inst, INPUT_PORT);
 	rc = msm_vdec_subscribe_property(inst, INPUT_PORT);
 	if (rc)
 	if (rc)
 		return rc;
 		return rc;
@@ -1267,10 +1267,6 @@ int msm_vdec_start_output(struct msm_vidc_inst *inst)
 	if (rc)
 	if (rc)
 		goto error;
 		goto error;
 
 
-	rc = msm_vdec_subscribe_port_settings_change(inst, OUTPUT_PORT);
-	if (rc)
-		return rc;
-
 	rc = msm_vdec_subscribe_metadata(inst, OUTPUT_PORT);
 	rc = msm_vdec_subscribe_metadata(inst, OUTPUT_PORT);
 	if (rc)
 	if (rc)
 		return rc;
 		return rc;

+ 0 - 4
driver/vidc/src/msm_vidc_driver.c

@@ -1253,14 +1253,10 @@ int msm_vidc_session_set_codec(struct msm_vidc_inst *inst)
 		return -EINVAL;
 		return -EINVAL;
 	}
 	}
 
 
-	if (inst->codec_set)
-		return 0;
-
 	rc = venus_hfi_session_set_codec(inst);
 	rc = venus_hfi_session_set_codec(inst);
 	if (rc)
 	if (rc)
 		return rc;
 		return rc;
 
 
-	inst->codec_set = true;
 	return 0;
 	return 0;
 }
 }
 
 

+ 16 - 2
driver/vidc/src/msm_vidc_vb2.c

@@ -164,10 +164,24 @@ int msm_vidc_start_streaming(struct vb2_queue *q, unsigned int count)
 	}
 	}
 	s_vpr_h(inst->sid, "Streamon: %d\n", q->type);
 	s_vpr_h(inst->sid, "Streamon: %d\n", q->type);
 
 
-	if (!inst->codec_set) {
+	if (!inst->once_per_session_set) {
+		inst->once_per_session_set = true;
 		rc = msm_vidc_session_set_codec(inst);
 		rc = msm_vidc_session_set_codec(inst);
 		if (rc)
 		if (rc)
-			return -EINVAL;
+			return rc;
+		if (is_decode_session(inst)) {
+			if (q->type == INPUT_MPLANE) {
+				rc = msm_vdec_subscribe_port_settings_change(
+					inst, INPUT_PORT);
+				if (rc)
+					return rc;
+			} else if (q->type == OUTPUT_MPLANE) {
+				rc = msm_vdec_subscribe_port_settings_change(
+					inst, OUTPUT_PORT);
+				if (rc)
+					return rc;
+			}
+		}
 	}
 	}
 
 
 	/*
 	/*

+ 27 - 53
driver/vidc/src/venus_hfi.c

@@ -921,24 +921,11 @@ dbg_error_null:
 	return rc;
 	return rc;
 }
 }
 
 
-// TODO: revisit once firmware updated to latest interface headers
-struct hfi_packet_header {
-	u32 size;
-	u32 packet_type;
-};
-
-struct hfi_msg_sys_debug_packet {
-	u32 size;
-	u32 packet_type;
-	u32 msg_type;
-	u32 msg_size;
-	u32 time_stamp_hi;
-	u32 time_stamp_lo;
-	u8 rg_msg_data[1];
-};
-
-static void __flush_debug_queue(struct msm_vidc_core *core, u8 *packet)
+static void __flush_debug_queue(struct msm_vidc_core *core,
+	u8 *packet, u32 packet_size)
 {
 {
+	u8 *log;
+	struct hfi_debug_header *pkt;
 	bool local_packet = false;
 	bool local_packet = false;
 	enum vidc_msg_prio log_level = msm_vidc_debug;
 	enum vidc_msg_prio log_level = msm_vidc_debug;
 
 
@@ -947,12 +934,13 @@ static void __flush_debug_queue(struct msm_vidc_core *core, u8 *packet)
 		return;
 		return;
 	}
 	}
 
 
-	if (!packet) {
+	if (!packet || !packet_size) {
 		packet = kzalloc(VIDC_IFACEQ_VAR_HUGE_PKT_SIZE, GFP_KERNEL);
 		packet = kzalloc(VIDC_IFACEQ_VAR_HUGE_PKT_SIZE, GFP_KERNEL);
 		if (!packet) {
 		if (!packet) {
 			d_vpr_e("%s: fail to allocate\n", __func__);
 			d_vpr_e("%s: fail to allocate\n", __func__);
 			return;
 			return;
 		}
 		}
+		packet_size = VIDC_IFACEQ_VAR_HUGE_PKT_SIZE;
 
 
 		local_packet = true;
 		local_packet = true;
 
 
@@ -963,45 +951,31 @@ static void __flush_debug_queue(struct msm_vidc_core *core, u8 *packet)
 		log_level |= FW_PRINTK;
 		log_level |= FW_PRINTK;
 	}
 	}
 
 
-#define SKIP_INVALID_PKT(pkt_size, payload_size, pkt_hdr_size) { \
-		if (pkt_size < pkt_hdr_size || \
-			payload_size < MIN_PAYLOAD_SIZE || \
-			payload_size > \
-			(pkt_size - pkt_hdr_size + sizeof(u8))) { \
-			d_vpr_e("%s: invalid msg size - %d\n", \
-				__func__, payload_size); \
-			continue; \
-		} \
-	}
-
 	while (!__iface_dbgq_read(core, packet)) {
 	while (!__iface_dbgq_read(core, packet)) {
-		struct hfi_packet_header *pkt =
-			(struct hfi_packet_header *) packet;
+		pkt = (struct hfi_debug_header *) packet;
 
 
-		if (pkt->size < sizeof(struct hfi_packet_header)) {
-			d_vpr_e("Invalid pkt size - %s\n", __func__);
+		if (pkt->size < sizeof(struct hfi_debug_header)) {
+			d_vpr_e("%s: invalid pkt size %d\n",
+				__func__, pkt->size);
 			continue;
 			continue;
 		}
 		}
-
-		if (1) {
-			struct hfi_msg_sys_debug_packet *pkt =
-				(struct hfi_msg_sys_debug_packet *) packet;
-
-			SKIP_INVALID_PKT(pkt->size,
-				pkt->msg_size, sizeof(*pkt));
-
-			/*
-			 * All fw messages starts with new line character. This
-			 * causes dprintk to print this message in two lines
-			 * in the kernel log. Ignoring the first character
-			 * from the message fixes this to print it in a single
-			 * line.
-			 */
-			pkt->rg_msg_data[pkt->msg_size-1] = '\0';
-			dprintk_firmware(log_level, "%s", &pkt->rg_msg_data[1]);
+		if (pkt->size > packet_size) {
+			d_vpr_e("%s: pkt size[%d] > packet_size[%d]\n",
+				__func__, pkt->size, packet_size);
+			continue;
 		}
 		}
+
+		packet[packet_size - 1] = '\0';
+		/*
+		 * All fw messages starts with new line character. This
+		 * causes dprintk to print this message in two lines
+		 * in the kernel log. Ignoring the first character
+		 * from the message fixes this to print it in a single
+		 * line.
+		 */
+		log = (u8 *)packet + sizeof(struct hfi_debug_header) + 1;
+		dprintk_firmware(log_level, "%s", log);
 	}
 	}
-#undef SKIP_INVALID_PKT
 
 
 	if (local_packet)
 	if (local_packet)
 		kfree(packet);
 		kfree(packet);
@@ -1104,7 +1078,7 @@ static int __power_collapse(struct msm_vidc_core *core, bool force)
 	if (rc)
 	if (rc)
 		goto skip_power_off;
 		goto skip_power_off;
 
 
-	__flush_debug_queue(core, core->packet);
+	__flush_debug_queue(core, core->packet, core->packet_size);
 
 
 	rc = __suspend(core);
 	rc = __suspend(core);
 	if (rc)
 	if (rc)
@@ -2439,7 +2413,7 @@ static int __response_handler(struct msm_vidc_core *core)
 	}
 	}
 
 
 	__schedule_power_collapse_work(core);
 	__schedule_power_collapse_work(core);
-	__flush_debug_queue(core, core->response_packet);
+	__flush_debug_queue(core, core->response_packet, core->packet_size);
 
 
 	return rc;
 	return rc;
 }
 }

+ 32 - 4
driver/vidc/src/venus_hfi_response.c

@@ -130,6 +130,30 @@ int validate_packet(u8 *response_pkt, u8 *core_resp_pkt,
 	return 0;
 	return 0;
 }
 }
 
 
+static int handle_session_info(struct msm_vidc_inst *inst,
+	struct hfi_packet *pkt)
+{
+
+	int rc = 0;
+	char *info;
+
+	switch (pkt->type) {
+	case HFI_INFO_UNSUPPORTED:
+		info = "unsupported";
+		break;
+	case HFI_INFO_DATA_CORRUPT:
+		info = "data corrupt";
+		break;
+	default:
+		info = "unknown";
+		break;
+	}
+
+	s_vpr_e(inst->sid, "session info (%#x): %s\n", pkt->type, info);
+
+	return rc;
+}
+
 static int handle_session_error(struct msm_vidc_inst *inst,
 static int handle_session_error(struct msm_vidc_inst *inst,
 	struct hfi_packet *pkt)
 	struct hfi_packet *pkt)
 {
 {
@@ -633,7 +657,8 @@ static int handle_session_buffer(struct msm_vidc_inst *inst,
 	buffer = (struct hfi_buffer *)((u8 *)pkt + sizeof(struct hfi_packet));
 	buffer = (struct hfi_buffer *)((u8 *)pkt + sizeof(struct hfi_packet));
 	buf_type = buffer->type;
 	buf_type = buffer->type;
 	if (!is_valid_hfi_buffer_type(inst, buf_type, __func__)) {
 	if (!is_valid_hfi_buffer_type(inst, buf_type, __func__)) {
-		msm_vidc_change_inst_state(inst, MSM_VIDC_ERROR, __func__);
+		/* TODO */
+		//msm_vidc_change_inst_state(inst, MSM_VIDC_ERROR, __func__);
 		return 0;
 		return 0;
 	}
 	}
 
 
@@ -915,9 +940,9 @@ static int handle_session_response(struct msm_vidc_core *core,
 			goto exit;
 			goto exit;
 		}
 		}
 		packet = (struct hfi_packet *)pkt;
 		packet = (struct hfi_packet *)pkt;
-		if (packet->type < HFI_CMD_END &&
-		    packet->type > HFI_CMD_BEGIN) {
-			if (inst->hfi_cmd_type || inst->hfi_port) {
+		if (packet->type > HFI_CMD_BEGIN &&
+		    packet->type < HFI_CMD_END) {
+			if (inst->hfi_cmd_type == HFI_CMD_SETTINGS_CHANGE) {
 				s_vpr_e(inst->sid,
 				s_vpr_e(inst->sid,
 					"%s: invalid cmd %d, port %d \n",
 					"%s: invalid cmd %d, port %d \n",
 					__func__, inst->hfi_cmd_type,
 					__func__, inst->hfi_cmd_type,
@@ -933,6 +958,9 @@ static int handle_session_response(struct msm_vidc_core *core,
 		} else if (packet->type > HFI_SESSION_ERROR_BEGIN &&
 		} else if (packet->type > HFI_SESSION_ERROR_BEGIN &&
 			   packet->type < HFI_SESSION_ERROR_END) {
 			   packet->type < HFI_SESSION_ERROR_END) {
 			rc = handle_session_error(inst, packet);
 			rc = handle_session_error(inst, packet);
+		} else if (packet->type > HFI_INFORMATION_BEGIN &&
+				packet->type < HFI_INFORMATION_END) {
+			rc = handle_session_info(inst, packet);
 		} else {
 		} else {
 			s_vpr_e(inst->sid, "%s: Unknown packet type: %#x\n",
 			s_vpr_e(inst->sid, "%s: Unknown packet type: %#x\n",
 				__func__, packet->type);
 				__func__, packet->type);