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

Commit 544101b7 authored by Vinay Kalia's avatar Vinay Kalia
Browse files

msm: vidc: Unify core_init, load_fw and core_uninit, unload_fw



core_init and load_fw always go hand-in-hand so it is not needed
to expose two different interfaces at msm_vidc_common level. Same
goes for core_uninit and unload_fw.

Change-Id: I8bbc77cfbc6da246d1f0af63c88882b2fd34aff0
Signed-off-by: default avatarVinay Kalia <vkalia@codeaurora.org>
parent 790113b6
Loading
Loading
Loading
Loading
+12 −49
Original line number Diff line number Diff line
@@ -1284,8 +1284,6 @@ static void handle_sys_error(enum hal_command_response cmd, void *data)
			return;
		}
		core->state = VIDC_CORE_UNINIT;
		call_hfi_op(hdev, unload_fw, hdev->hfi_device_data);
		dprintk(VIDC_DBG, "Firmware unloaded\n");
	}
	mutex_unlock(&core->lock);
}
@@ -2142,15 +2140,17 @@ static int msm_comm_init_core_done(struct msm_vidc_inst *inst)
	return rc;
}

int msm_comm_load_fw(struct msm_vidc_core *core)
static int msm_comm_init_core(struct msm_vidc_inst *inst)
{
	int rc = 0;
	struct hfi_device *hdev;
	struct msm_vidc_core *core;

	if (!core || !core->device)
	if (!inst || !inst->core || !inst->core->device)
		return -EINVAL;
	hdev = core->device;

	core = inst->core;
	hdev = core->device;
	mutex_lock(&core->lock);
	if (core->state >= VIDC_CORE_INIT) {
		dprintk(VIDC_INFO, "Video core: %d is already in state: %d\n",
@@ -2158,57 +2158,24 @@ int msm_comm_load_fw(struct msm_vidc_core *core)
		goto core_already_inited;
	}

	if (core->state < VIDC_CORE_LOADED) {
		rc = call_hfi_op(hdev, load_fw, hdev->hfi_device_data);
		if (rc) {
			dprintk(VIDC_ERR, "Failed to load video firmware\n");
			mutex_unlock(&core->lock);
			goto fail_load_fw;
		}
		core->state = VIDC_CORE_LOADED;
		dprintk(VIDC_DBG, "Firmware downloaded\n");
	}

	if (core->state == VIDC_CORE_LOADED) {
	init_completion(&core->completions
			[SYS_MSG_INDEX(HAL_SYS_INIT_DONE)]);
	rc = call_hfi_op(hdev, core_init, hdev->hfi_device_data);
	if (rc) {
		dprintk(VIDC_ERR, "Failed to init core, id = %d\n",
				core->id);
			mutex_unlock(&core->lock);
		goto fail_core_init;
	}
	core->state = VIDC_CORE_INIT;
	}

core_already_inited:
	change_inst_state(inst, MSM_VIDC_CORE_INIT);
	mutex_unlock(&core->lock);
	return rc;

fail_core_init:
	mutex_lock(&core->lock);
	call_hfi_op(hdev, unload_fw, hdev->hfi_device_data);
	core->state = VIDC_CORE_UNINIT;
	mutex_unlock(&core->lock);
fail_load_fw:
	return rc;
}

static int msm_comm_init_core(struct msm_vidc_inst *inst)
{
	int rc = 0;

	if (!inst || !inst->core)
		return -EINVAL;

	rc = msm_comm_load_fw(inst->core);
	if (rc) {
		dprintk(VIDC_ERR, "%s - firmware loading failed\n", __func__);
		return rc;
	}

	change_inst_state(inst, MSM_VIDC_CORE_INIT);
	return rc;
}

@@ -4679,11 +4646,7 @@ void msm_vidc_fw_unload_handler(struct work_struct *work)
				return;
			}
		}

		core->state = VIDC_CORE_UNINIT;

		call_hfi_op(hdev, unload_fw, hdev->hfi_device_data);
		dprintk(VIDC_DBG, "Firmware unloaded\n");
	}
	mutex_unlock(&core->lock);
}
+0 −1
Original line number Diff line number Diff line
@@ -75,7 +75,6 @@ int msm_comm_smem_cache_operations(struct msm_vidc_inst *inst,
struct msm_smem *msm_comm_smem_user_to_kernel(struct msm_vidc_inst *inst,
			int fd, u32 offset, enum hal_buffer buffer_type);
enum hal_video_codec get_hal_codec(int fourcc);
int msm_comm_load_fw(struct msm_vidc_core *core);
int msm_comm_check_core_init(struct msm_vidc_core *core);
int msm_comm_get_inst_load(struct msm_vidc_inst *inst,
			enum load_calc_quirks quirks);
+12 −35
Original line number Diff line number Diff line
@@ -88,6 +88,8 @@ static struct hal_session *__get_session(struct venus_hfi_device *device,
		u32 session_id);
static int __iface_cmdq_write(struct venus_hfi_device *device,
					void *pkt);
static int __load_fw(struct venus_hfi_device *device);
static void __unload_fw(struct venus_hfi_device *device);


/**
@@ -2247,6 +2249,12 @@ static int venus_hfi_core_init(void *device)
	dev = device;
	mutex_lock(&dev->lock);

	rc = __load_fw(dev);
	if (rc) {
		dprintk(VIDC_ERR, "Failed to load Venus FW\n");
		goto err_load_fw;
	}

	__set_state(dev, VENUS_STATE_INIT);

	dev->intr_status = 0;
@@ -2265,6 +2273,7 @@ static int venus_hfi_core_init(void *device)

	__set_registers(dev);

	enable_irq(dev->hal_data->irq);
	if (!dev->hal_client) {
		dev->hal_client = msm_smem_new_client(
				SMEM_ION, dev->res, MSM_VIDC_UNKNOWN);
@@ -2290,7 +2299,6 @@ static int venus_hfi_core_init(void *device)
		goto err_core_init;
	}

	enable_irq(dev->hal_data->irq);
	__write_register(dev, VIDC_CTRL_INIT, 0x1);
	rc = __core_start_cpu(dev);
	if (rc) {
@@ -2319,6 +2327,8 @@ static int venus_hfi_core_init(void *device)
err_core_init:
	__set_state(dev, VENUS_STATE_DEINIT);
	disable_irq_nosync(dev->hal_data->irq);
	__unload_fw(dev);
err_load_fw:
	mutex_unlock(&dev->lock);
	return rc;
}
@@ -2362,6 +2372,7 @@ static int venus_hfi_core_release(void *dev)

	mutex_lock(&device->lock);
	rc = __core_release(device);
	__unload_fw(device);
	mutex_unlock(&device->lock);

	return rc;
@@ -4352,24 +4363,6 @@ fail_init_res:
	return rc;
}

static int venus_hfi_load_fw(void *dev)
{
	int rc = 0;
	struct venus_hfi_device *device = dev;

	if (!device) {
		dprintk(VIDC_ERR, "%s Invalid paramter: %p\n",
			__func__, device);
		return -EINVAL;
	}

	mutex_lock(&device->lock);
	rc = __load_fw(device);
	mutex_unlock(&device->lock);

	return rc;
}

static void __unload_fw(struct venus_hfi_device *device)
{
	if (!device->resources.fw.cookie)
@@ -4394,20 +4387,6 @@ static void __unload_fw(struct venus_hfi_device *device)
	__deinit_resources(device);
}

static void venus_hfi_unload_fw(void *dev)
{
	struct venus_hfi_device *device = dev;
	if (!device) {
		dprintk(VIDC_ERR, "%s Invalid paramter: %p\n",
			__func__, device);
		return;
	}

	mutex_lock(&device->lock);
	__unload_fw(device);
	mutex_unlock(&device->lock);
}

static int venus_hfi_get_fw_info(void *dev, enum fw_info info)
{
	int rc = 0;
@@ -4638,8 +4617,6 @@ static void venus_init_hfi_callbacks(struct hfi_device *hdev)
	hdev->scale_clocks = venus_hfi_scale_clocks;
	hdev->vote_bus = venus_hfi_vote_buses;
	hdev->unvote_bus = venus_hfi_unvote_buses;
	hdev->load_fw = venus_hfi_load_fw;
	hdev->unload_fw = venus_hfi_unload_fw;
	hdev->get_fw_info = venus_hfi_get_fw_info;
	hdev->get_core_capabilities = venus_hfi_get_core_capabilities;
	hdev->suspend = venus_hfi_suspend;
+0 −2
Original line number Diff line number Diff line
@@ -1440,8 +1440,6 @@ struct hfi_device {
	int (*vote_bus)(void *dev, struct vidc_bus_vote_data *data,
			int num_data);
	int (*unvote_bus)(void *dev);
	int (*load_fw)(void *dev);
	void (*unload_fw)(void *dev);
	int (*get_fw_info)(void *dev, enum fw_info info);
	int (*session_clean)(void *sess);
	int (*get_core_capabilities)(void *dev);