示例#1
0
void vcd_handle_device_init_failed(struct vcd_drv_ctxt *drv_ctxt,
		u32 status)
{
	struct vcd_clnt_ctxt *client;
	struct vcd_clnt_ctxt *tmp_client;

	VCD_MSG_ERROR("Device init failed. status = %d", status);

	client = drv_ctxt->dev_ctxt.cctxt_list_head;
	while (client) {
		client->callback(VCD_EVT_RESP_OPEN,
				   status, NULL, 0, 0, client->client_data);

		tmp_client = client;
		client = client->next;

		vcd_destroy_client_context(tmp_client);
	}
	if (ddl_device_release(NULL))
		VCD_MSG_ERROR("Failed: ddl_device_release");

	vcd_sched_destroy(&drv_ctxt->dev_ctxt.sched_clnt_list);
	if (vcd_power_event(&drv_ctxt->dev_ctxt,
		NULL, VCD_EVT_PWR_DEV_INIT_FAIL))
		VCD_MSG_ERROR("VCD_EVT_PWR_DEV_INIT_FAIL failed");

	vcd_do_device_state_transition(drv_ctxt,
		VCD_DEVICE_STATE_NOT_INIT,
		DEVICE_STATE_EVENT_NUMBER(dev_cb));
}
示例#2
0
static u32 vcd_open_in_not_init
	(struct vcd_drv_ctxt *drv_ctxt,
	 s32 driver_handle,
	 u32 decoding,
	 void (*callback) (u32 event, u32 status, void *info, size_t sz,
			   void *handle, void *const client_data),
	 void *client_data)
{
	struct vcd_clnt_ctxt *cctxt;
	u32 rc;

	VCD_MSG_LOW("vcd_open_in_dev_not_init:");

	rc = vcd_open_cmn(drv_ctxt, driver_handle, decoding, callback,
			  client_data, &cctxt);

	VCD_FAILED_RETURN(rc, "Failed: vcd_open_cmn");

	rc = vcd_init_device_context(drv_ctxt,
					 DEVICE_STATE_EVENT_NUMBER(open));

	if (VCD_FAILED(rc))
		vcd_destroy_client_context(cctxt);

	return rc;
}
void vcd_handle_device_init_failed(struct vcd_drv_ctxt_type_t *p_drv_ctxt,
                                   u32 status)
{
    struct vcd_clnt_ctxt_type_t *p_client;
    struct vcd_clnt_ctxt_type_t *p_tmp_client;

    VCD_MSG_ERROR("Device init failed. status = %d", status);

    p_client = p_drv_ctxt->dev_ctxt.p_cctxt_list_head;
    while (p_client) {
        p_client->callback(VCD_EVT_RESP_OPEN,
                           status, NULL, 0, 0, p_client->p_client_data);

        p_tmp_client = p_client;
        p_client = p_client->p_next;

        vcd_destroy_client_context(p_tmp_client);
    }
    if (ddl_device_release(NULL))
        VCD_MSG_ERROR("Failed: ddl_device_release");

    (void)sched_destroy(p_drv_ctxt->dev_ctxt.sched_hdl);
    p_drv_ctxt->dev_ctxt.sched_hdl = NULL;

    if (vcd_power_event(&p_drv_ctxt->dev_ctxt,
                        NULL, VCD_EVT_PWR_DEV_INIT_FAIL))
        VCD_MSG_ERROR("VCD_EVT_PWR_DEV_INIT_FAIL failed");

    vcd_do_device_state_transition(p_drv_ctxt,
                                   VCD_DEVICE_STATE_NOT_INIT,
                                   DEVICE_STATE_EVENT_NUMBER(pf_dev_cb));
}
示例#4
0
static u32 vcd_close_in_open(struct vcd_clnt_ctxt *cctxt)
{
	u32 rc = VCD_S_SUCCESS;

	VCD_MSG_LOW("vcd_close_in_open:");
	if (cctxt->in_buf_pool.allocated ||
		 cctxt->out_buf_pool.allocated) {
		VCD_MSG_ERROR("\n Allocated buffers are not freed yet");
		return VCD_ERR_ILLEGAL_OP;
	}
	vcd_destroy_client_context(cctxt);
	return rc;
}
示例#5
0
static u32  vcd_close_in_invalid(struct vcd_clnt_ctxt *cctxt)
{
	VCD_MSG_LOW("vcd_close_in_invalid:");
	if (cctxt->in_buf_pool.allocated ||
		cctxt->out_buf_pool.allocated){
		VCD_MSG_ERROR("Allocated buffers are not freed yet");
		return VCD_ERR_ILLEGAL_OP;
	}

	if (cctxt->status.mask & VCD_CLEANING_UP)
		cctxt->status.mask |= VCD_CLOSE_PENDING;
	else
		vcd_destroy_client_context(cctxt);
	return VCD_S_SUCCESS;
}
示例#6
0
static u32  vcd_close_in_invalid(struct vcd_clnt_ctxt_type_t *p_cctxt)
{
	VCD_MSG_LOW("vcd_close_in_invalid:");
	if (p_cctxt->in_buf_pool.n_allocated ||
		p_cctxt->out_buf_pool.n_allocated){
		VCD_MSG_ERROR("Allocated buffers are not freed yet");
		return VCD_ERR_ILLEGAL_OP;
	}

	if (p_cctxt->status.b_cleaning_up)
		p_cctxt->status.b_close_pending = TRUE;
	else
		vcd_destroy_client_context(p_cctxt);
	return VCD_S_SUCCESS;
}
示例#7
0
void vcd_clnt_handle_device_err_fatal(struct vcd_clnt_ctxt *cctxt,
								  u32 event)
{
	if (cctxt->clnt_state.state != VCD_CLIENT_STATE_NULL) {
		cctxt->callback(VCD_EVT_RESP_OPEN, VCD_ERR_HW_FATAL, NULL, 0,
			cctxt, cctxt->client_data);
		vcd_destroy_client_context(cctxt);
		return;
	}

	if (cctxt->clnt_state.state != VCD_CLIENT_STATE_INVALID) {
		cctxt->callback(event, VCD_ERR_HW_FATAL, NULL, 0,
			cctxt, cctxt->client_data);
		vcd_flush_buffers_in_err_fatal(cctxt);
		vcd_do_client_state_transition(cctxt,
			VCD_CLIENT_STATE_INVALID,
			CLIENT_STATE_EVENT_NUMBER(clnt_cb));
	}
}
示例#8
0
static u32 vcd_close_in_ready
	(struct vcd_drv_ctxt *drv_ctxt,
	 struct vcd_clnt_ctxt *cctxt) {
	u32 rc;

	VCD_MSG_LOW("vcd_close_in_dev_ready:");

	if (cctxt->clnt_state.state_table->ev_hdlr.close) {
		rc = cctxt->clnt_state.state_table->ev_hdlr.
			close(cctxt);
	} else {
		VCD_MSG_ERROR("Unsupported API in client state %d",
				  cctxt->clnt_state.state);
		vcd_destroy_client_context(cctxt);
		rc = VCD_ERR_BAD_STATE;
	}

	if (!VCD_FAILED(rc))
		vcd_handle_for_last_clnt_close(&drv_ctxt->dev_ctxt, true);

	return rc;
}
示例#9
0
static u32 vcd_open_in_ready
	(struct vcd_drv_ctxt *drv_ctxt,
	 s32 driver_handle,
	 u32 decoding,
	 void (*callback) (u32 event, u32 status, void *info, size_t sz,
			   void *handle, void *const client_data),
	 void *client_data)
{
	struct vcd_clnt_ctxt *cctxt;
	struct vcd_handle_container container;
	u32 rc;

	VCD_MSG_LOW("vcd_open_in_dev_ready:");

	rc = vcd_open_cmn(drv_ctxt, driver_handle, decoding, callback,
			  client_data, &cctxt);

	VCD_FAILED_RETURN(rc, "Failed: vcd_open_cmn");

	rc = vcd_init_client_context(cctxt);

	if (!VCD_FAILED(rc)) {
		container.handle = (void *)cctxt;

		callback(VCD_EVT_RESP_OPEN,
			 VCD_S_SUCCESS,
			 &container,
			 sizeof(container), container.handle, client_data);
	} else {
		VCD_MSG_ERROR("rc = 0x%x. Failed: vcd_init_client_context", rc);

		vcd_destroy_client_context(cctxt);
	}

	return rc;
}
示例#10
0
static void vcd_dev_cb_in_initing
	(struct vcd_drv_ctxt *drv_ctxt,
	 u32 event,
	 u32 status,
	 void *payload, size_t sz, u32 *ddl_handle, void *const client_data)
{
	struct vcd_dev_ctxt *dev_ctxt;
	struct vcd_clnt_ctxt *client;
	struct vcd_clnt_ctxt *tmp_client;
	struct vcd_handle_container container;
	u32 rc = VCD_S_SUCCESS;
	u32 client_inited = false;
	u32 fail_all_open = false;

	VCD_MSG_LOW("vcd_dev_cb_in_initing:");

	if (event != VCD_EVT_RESP_DEVICE_INIT) {
		VCD_MSG_ERROR("vcd_dev_cb_in_initing: Unexpected event %d",
				  (int)event);
		return;
	}

	dev_ctxt = &drv_ctxt->dev_ctxt;

	dev_ctxt->command_continue = false;

	if (VCD_FAILED(status)) {
		vcd_handle_device_init_failed(drv_ctxt, status);

		return;
	}

	vcd_do_device_state_transition(drv_ctxt,
					   VCD_DEVICE_STATE_READY,
					   DEVICE_STATE_EVENT_NUMBER(open));

	if (!dev_ctxt->cctxt_list_head) {
		VCD_MSG_HIGH("All clients are closed");

		dev_ctxt->pending_cmd = VCD_CMD_DEVICE_TERM;

		return;
	}

	if (!dev_ctxt->ddl_cmd_ch_depth
		|| !dev_ctxt->trans_tbl)
		rc = vcd_setup_with_ddl_capabilities(dev_ctxt);


	if (VCD_FAILED(rc)) {
		VCD_MSG_ERROR
			("rc = 0x%x: Failed vcd_setup_with_ddl_capabilities",
			 rc);

		fail_all_open = true;
	}

	client = dev_ctxt->cctxt_list_head;
	while (client) {
		if (!fail_all_open)
			rc = vcd_init_client_context(client);


		if (!VCD_FAILED(rc)) {
			container.handle = (void *)client;
			client->callback(VCD_EVT_RESP_OPEN,
					   VCD_S_SUCCESS,
					   &container,
					   sizeof(container),
					   container.handle,
					   client->client_data);

			client = client->next;

			client_inited = true;
		} else {
			VCD_MSG_ERROR
				("rc = 0x%x, Failed: vcd_init_client_context",
				 rc);

			client->callback(VCD_EVT_RESP_OPEN,
					   rc,
					   NULL, 0, 0, client->client_data);

			tmp_client = client;
			client = client->next;

			vcd_destroy_client_context(tmp_client);
		}
	}

	if (!client_inited || fail_all_open) {
		VCD_MSG_ERROR("All client open requests failed");

		dev_ctxt->pending_cmd = VCD_CMD_DEVICE_TERM;
	} else {
		if (vcd_power_event(dev_ctxt, NULL,
					 VCD_EVT_PWR_DEV_INIT_END)) {
			VCD_MSG_ERROR("VCD_EVT_PWR_DEV_INIT_END failed");
		}
	}
}
static void vcd_dev_cb_in_initing
(struct vcd_drv_ctxt_type_t *p_drv_ctxt,
 u32 event,
 u32 status,
 void *p_payload, u32 size, u32 *ddl_handle, void *const p_client_data)
{
    struct vcd_dev_ctxt_type *p_dev_ctxt;
    struct vcd_clnt_ctxt_type_t *p_client;
    struct vcd_clnt_ctxt_type_t *p_tmp_client;
    struct vcd_handle_container_type container;
    u32 rc = VCD_S_SUCCESS;
    u32 b_client_inited = FALSE;
    u32 b_fail_all_open = FALSE;

    VCD_MSG_LOW("vcd_dev_cb_in_initing:");

    if (event != VCD_EVT_RESP_DEVICE_INIT) {
        VCD_MSG_ERROR("vcd_dev_cb_in_initing: Unexpected event %d",
                      (int)event);
        return;
    }

    p_dev_ctxt = &p_drv_ctxt->dev_ctxt;

    p_dev_ctxt->b_continue = FALSE;

    if (VCD_FAILED(status)) {
        vcd_handle_device_init_failed(p_drv_ctxt, status);

        return;
    }

    vcd_do_device_state_transition(p_drv_ctxt,
                                   VCD_DEVICE_STATE_READY,
                                   DEVICE_STATE_EVENT_NUMBER(pf_open));

    if (!p_dev_ctxt->p_cctxt_list_head) {
        VCD_MSG_HIGH("All clients are closed");

        p_dev_ctxt->e_pending_cmd = VCD_CMD_DEVICE_TERM;

        return;
    }

    if (!p_dev_ctxt->n_ddl_cmd_ch_depth
            || !p_dev_ctxt->a_trans_tbl)
        rc = vcd_setup_with_ddl_capabilities(p_dev_ctxt);


    if (VCD_FAILED(rc)) {
        VCD_MSG_ERROR
        ("rc = 0x%x: Failed vcd_setup_with_ddl_capabilities",
         rc);

        b_fail_all_open = TRUE;
    }

    p_client = p_dev_ctxt->p_cctxt_list_head;
    while (p_client) {
        if (!b_fail_all_open)
            rc = vcd_init_client_context(p_client);


        if (!VCD_FAILED(rc)) {
            container.handle = (void *)p_client;
            p_client->callback(VCD_EVT_RESP_OPEN,
                               VCD_S_SUCCESS,
                               &container,
                               sizeof(container),
                               container.handle,
                               p_client->p_client_data);

            p_client = p_client->p_next;

            b_client_inited = TRUE;
        } else {
            VCD_MSG_ERROR
            ("rc = 0x%x, Failed: vcd_init_client_context",
             rc);

            p_client->callback(VCD_EVT_RESP_OPEN,
                               rc,
                               NULL, 0, 0, p_client->p_client_data);

            p_tmp_client = p_client;
            p_client = p_client->p_next;

            vcd_destroy_client_context(p_tmp_client);
        }
    }

    if (!b_client_inited || b_fail_all_open) {
        VCD_MSG_ERROR("All client open requests failed");

        p_dev_ctxt->e_pending_cmd = VCD_CMD_DEVICE_TERM;
    } else {
        if (vcd_power_event(p_dev_ctxt, NULL,
                            VCD_EVT_PWR_DEV_INIT_END)) {
            VCD_MSG_ERROR("VCD_EVT_PWR_DEV_INIT_END failed");
        }
    }
}