ソースを参照

video: driver: Enable video subcache

Enable video subcaches.

Change-Id: I193c5dd6bb02f87c4576f5b9dbbeee31116e1858
Signed-off-by: Chinmay Sawarkar <[email protected]>
Chinmay Sawarkar 4 年 前
コミット
899cd05a06
2 ファイル変更89 行追加83 行削除
  1. 0 21
      driver/vidc/inc/venus_hfi.h
  2. 89 62
      driver/vidc/src/venus_hfi.c

+ 0 - 21
driver/vidc/inc/venus_hfi.h

@@ -17,17 +17,6 @@
 #define VIDC_MAX_SUBCACHES 			4
 #define VIDC_MAX_SUBCACHE_SIZE 		52
 
-enum vidc_resource_id {
-	VIDC_RESOURCE_NONE,
-	VIDC_RESOURCE_SYSCACHE,
-	VIDC_UNUSED_RESOURCE = 0x10000000,
-};
-
-struct vidc_resource_hdr {
-	enum vidc_resource_id resource_id;
-	void *resource_handle;
-};
-
 struct vidc_buffer_addr_info {
 	enum msm_vidc_buffer_type buffer_type;
 	u32 buffer_size;
@@ -37,17 +26,7 @@ struct vidc_buffer_addr_info {
 	u32 extradata_size;
 	u32 response_required;
 };
-#if 0
-struct hfi_resource_subcache_type {
-	u32 size;
-	u32 sc_id;
-};
 
-struct hfi_resource_syscache_info_type {
-	u32 num_entries;
-	struct hfi_resource_subcache_type rg_subcache_entries[1];
-};
-#endif
 int venus_hfi_session_property(struct msm_vidc_inst *inst,
 	u32 pkt_type, u32 flags, u32 port,
 	u32 payload_type, void *payload, u32 payload_size);

+ 89 - 62
driver/vidc/src/venus_hfi.c

@@ -166,7 +166,7 @@ bool __core_in_valid_state(struct msm_vidc_core *core)
 	return core->state == MSM_VIDC_CORE_INIT;
 }
 
-static bool is_sys_cache_present(struct msm_vidc_core *core)
+bool is_sys_cache_present(struct msm_vidc_core *core)
 {
 	return core->dt->sys_cache_present;
 }
@@ -1759,46 +1759,62 @@ int __disable_regulators(struct msm_vidc_core *core)
 
 static int __release_subcaches(struct msm_vidc_core *core)
 {
-#if 0 // TODO
-	struct subcache_info *sinfo;
 	int rc = 0;
-	u32 c = 0;
-	u32 resource[VIDC_MAX_SUBCACHE_SIZE];
-	struct hfi_resource_syscache_info_type *sc_res_info;
-	struct hfi_resource_subcache_type *sc_res;
-	struct vidc_resource_hdr rhdr;
+	struct subcache_info* sinfo;
+	struct hfi_buffer buf;
 
 	if (msm_vidc_syscache_disable || !is_sys_cache_present(core))
 		return 0;
 
-	memset((void *)resource, 0x0, (sizeof(u32) * VIDC_MAX_SUBCACHE_SIZE));
+	if (!core->dt->sys_cache_res_set) {
+		d_vpr_h("Subcaches not set to Venus\n");
+		return 0;
+	}
+
+	rc = hfi_create_header(core->packet, core->packet_size,
+		0, core->header_id++);
+	if (rc)
+		return rc;
 
-	sc_res_info = (struct hfi_resource_syscache_info_type *)resource;
-	sc_res = &(sc_res_info->rg_subcache_entries[0]);
+	memset(&buf, 0, sizeof(struct hfi_buffer));
+	buf.type = HFI_BUFFER_SUBCACHE;
+	buf.flags = HFI_BUF_HOST_FLAG_RELEASE;
 
-	/* Release resource command to Venus */
 	venus_hfi_for_each_subcache_reverse(core, sinfo) {
-		if (sinfo->isset) {
-			/* Update the entry */
-			sc_res[c].size = sinfo->subcache->slice_size;
-			sc_res[c].sc_id = sinfo->subcache->slice_id;
-			c++;
-			sinfo->isset = false;
+		if (sinfo->isactive) {
+			buf.index = sinfo->subcache->slice_id;
+			buf.buffer_size = sinfo->subcache->slice_size;
+
+			rc = hfi_create_packet(core->packet,
+				core->packet_size,
+				HFI_CMD_BUFFER,
+				HFI_BUF_HOST_FLAG_NONE,
+				HFI_PAYLOAD_STRUCTURE,
+				HFI_PORT_NONE,
+				core->packet_id++,
+				&buf,
+				sizeof(buf));
+			if (rc)
+				return rc;
 		}
 	}
 
-	if (c > 0) {
-		d_vpr_h("Releasing %d subcaches\n", c);
-		rhdr.resource_handle = sc_res_info; /* cookie */
-		rhdr.resource_id = VIDC_RESOURCE_SYSCACHE;
+	/* Set resource to Venus for activated subcaches */
+	rc = __iface_cmdq_write(core, core->packet);
+	if (rc)
+		return rc;
 
-		rc = __core_release_resource(core, &rhdr);
-		if (rc)
-			d_vpr_e("Failed to release %d subcaches\n", c);
+	venus_hfi_for_each_subcache_reverse(core, sinfo) {
+		if (sinfo->isactive) {
+			sinfo->isset = false;
+			d_vpr_h("Release Subcache id %d size %d done\n",
+				sinfo->subcache->slice_id,
+				sinfo->subcache->slice_size);
+		}
 	}
 
 	core->dt->sys_cache_res_set = false;
-#endif
+
 	return 0;
 }
 
@@ -1857,69 +1873,76 @@ static int __enable_subcaches(struct msm_vidc_core *core)
 err_activate_fail:
 	__release_subcaches(core);
 	__disable_subcaches(core);
-	return 0;
+	return rc;
 }
 
 static int __set_subcaches(struct msm_vidc_core *core)
 {
-#if 0 // TODO
 	int rc = 0;
-	u32 c = 0;
 	struct subcache_info *sinfo;
-	u32 resource[VIDC_MAX_SUBCACHE_SIZE];
-	struct hfi_resource_syscache_info_type *sc_res_info;
-	struct hfi_resource_subcache_type *sc_res;
-	struct vidc_resource_hdr rhdr;
+	struct hfi_buffer buf;
+
+	if (msm_vidc_syscache_disable ||
+		!is_sys_cache_present(core)) {
+		return 0;
+	}
 
 	if (core->dt->sys_cache_res_set) {
 		d_vpr_h("Subcaches already set to Venus\n");
 		return 0;
 	}
 
-	memset((void *)resource, 0x0, (sizeof(u32) * VIDC_MAX_SUBCACHE_SIZE));
+	rc = hfi_create_header(core->packet, core->packet_size,
+		0, core->header_id++);
+	if (rc)
+		goto err_fail_set_subacaches;
 
-	sc_res_info = (struct hfi_resource_syscache_info_type *)resource;
-	sc_res = &(sc_res_info->rg_subcache_entries[0]);
+	memset(&buf, 0, sizeof(struct hfi_buffer));
+	buf.type = HFI_BUFFER_SUBCACHE;
+	buf.flags = HFI_BUF_HOST_FLAG_NONE;
 
 	venus_hfi_for_each_subcache(core, sinfo) {
 		if (sinfo->isactive) {
-			sc_res[c].size = sinfo->subcache->slice_size;
-			sc_res[c].sc_id = sinfo->subcache->slice_id;
-			c++;
+			buf.index = sinfo->subcache->slice_id;
+			buf.buffer_size = sinfo->subcache->slice_size;
+
+			rc = hfi_create_packet(core->packet,
+				core->packet_size,
+				HFI_CMD_BUFFER,
+				HFI_BUF_HOST_FLAG_NONE,
+				HFI_PAYLOAD_STRUCTURE,
+				HFI_PORT_NONE,
+				core->packet_id++,
+				&buf,
+				sizeof(buf));
+			if (rc)
+				goto err_fail_set_subacaches;
 		}
 	}
 
 	/* Set resource to Venus for activated subcaches */
-	if (c) {
-		d_vpr_h("Setting %d Subcaches\n", c);
-
-		rhdr.resource_handle = sc_res_info; /* cookie */
-		rhdr.resource_id = VIDC_RESOURCE_SYSCACHE;
-
-		sc_res_info->num_entries = c;
-
-		rc = __core_set_resource(core, &rhdr, (void *)sc_res_info);
-		if (rc) {
-			d_vpr_e("Failed to set subcaches %d\n", rc);
-			goto err_fail_set_subacaches;
-		}
-
-		venus_hfi_for_each_subcache(core, sinfo) {
-			if (sinfo->isactive)
-				sinfo->isset = true;
+	rc = __iface_cmdq_write(core, core->packet);
+	if (rc)
+		goto err_fail_set_subacaches;
+		
+	venus_hfi_for_each_subcache(core, sinfo) {
+		if (sinfo->isactive) {
+			sinfo->isset = true;
+			d_vpr_h("Set Subcache id %d size %d done\n",
+				sinfo->subcache->slice_id,
+				sinfo->subcache->slice_size);
 		}
-
-		d_vpr_h("Set Subcaches done to Venus\n");
-		core->dt->sys_cache_res_set = true;
 	}
+	
+	core->dt->sys_cache_res_set = true;
 
 	return 0;
 
 err_fail_set_subacaches:
 	__disable_subcaches(core);
-#endif
-	return 0;
+	return rc;
 }
+
 /*
 static int __set_ubwc_config(struct msm_vidc_core *core)
 {
@@ -2099,7 +2122,11 @@ static int __resume(struct msm_vidc_core *core)
 	}
 
 	__sys_set_debug(core, (msm_vidc_debug & FW_LOGMASK) >> FW_LOGSHIFT);
-	__enable_subcaches(core);
+	rc = __enable_subcaches(core);
+	if (rc) {
+		d_vpr_e("Failed to activate subcache\n");
+		goto err_reset_core;
+	}
 	__set_subcaches(core);
 
 	d_vpr_h("Resumed from power collapse\n");