Esempio n. 1
0
void vcd_handle_device_err_fatal(struct vcd_dev_ctxt *dev_ctxt,
	struct vcd_clnt_ctxt *trig_clnt)
{
	struct vcd_clnt_ctxt *cctxt = dev_ctxt->cctxt_list_head;
	struct vcd_clnt_ctxt *tmp_clnt = NULL;
	VCD_MSG_LOW("vcd_handle_device_err_fatal:");
	while (cctxt) {
		tmp_clnt = cctxt;
		cctxt = cctxt->next;
		if (tmp_clnt != trig_clnt)
/*HTC_START*/
			vcd_clnt_handle_device_err_fatal(tmp_clnt,
				VCD_EVT_IND_HWERRFATAL);
/*HTC_END*/
	}
	dev_ctxt->pending_cmd = VCD_CMD_DEVICE_RESET;
	if (!dev_ctxt->cctxt_list_head)
		vcd_do_device_state_transition(vcd_get_drv_context(),
			VCD_DEVICE_STATE_NOT_INIT,
			DEVICE_STATE_EVENT_NUMBER(timeout));
	else
		vcd_do_device_state_transition(vcd_get_drv_context(),
			VCD_DEVICE_STATE_INVALID,
			DEVICE_STATE_EVENT_NUMBER(dev_cb));
}
Esempio n. 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;
}
Esempio n. 3
0
static u32 vcd_init_in_null
	(struct vcd_drv_ctxt *drv_ctxt,
	 struct vcd_init_config *config, s32 *driver_handle) {
	u32 rc = VCD_S_SUCCESS;
	struct vcd_dev_ctxt *dev_ctxt = &drv_ctxt->dev_ctxt;
	u32 done_create_timer = false;
	VCD_MSG_LOW("vcd_init_in_dev_null:");


	dev_ctxt->config = *config;

	dev_ctxt->device_base_addr =
		(u8 *)config->map_dev_base_addr(
			dev_ctxt->config.device_name);

	if (!dev_ctxt->device_base_addr) {
		VCD_MSG_ERROR("NULL Device_base_addr");

		return VCD_ERR_FAIL;
	}

	if (config->register_isr) {
		config->register_isr(dev_ctxt->config.
			device_name);
	}

	if (config->timer_create) {
		if (config->timer_create(vcd_hw_timeout_handler,
			NULL, &dev_ctxt->hw_timer_handle))
			done_create_timer = true;
		else {
			VCD_MSG_ERROR("timercreate failed");
			return VCD_ERR_FAIL;
		}
	}


	rc = vcd_init_cmn(drv_ctxt, config, driver_handle);

	if (!VCD_FAILED(rc)) {
		vcd_do_device_state_transition(drv_ctxt,
						   VCD_DEVICE_STATE_NOT_INIT,
						   DEVICE_STATE_EVENT_NUMBER
						   (init));
	} else {
		if (dev_ctxt->config.un_map_dev_base_addr)
			dev_ctxt->config.un_map_dev_base_addr();

		if (dev_ctxt->config.deregister_isr)
			dev_ctxt->config.deregister_isr();

		if (done_create_timer && dev_ctxt->config.timer_release)
			dev_ctxt->config.timer_release(dev_ctxt->
				hw_timer_handle);

	}

	return rc;

}
Esempio n. 4
0
void vcd_term_driver_context(struct vcd_drv_ctxt *drv_ctxt)
{
	struct vcd_dev_ctxt *dev_ctxt = &drv_ctxt->dev_ctxt;

	VCD_MSG_HIGH("All driver instances terminated");

	if (dev_ctxt->config.deregister_isr)
		dev_ctxt->config.deregister_isr();

	if (dev_ctxt->config.un_map_dev_base_addr)
		dev_ctxt->config.un_map_dev_base_addr();

	if (dev_ctxt->config.timer_release)
		dev_ctxt->config.timer_release(
			dev_ctxt->hw_timer_handle);

	kfree(dev_ctxt->trans_tbl);

	memset(dev_ctxt, 0, sizeof(struct vcd_dev_ctxt));

	vcd_do_device_state_transition(drv_ctxt,
					   VCD_DEVICE_STATE_NULL,
					   DEVICE_STATE_EVENT_NUMBER(term));

}
Esempio n. 5
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));
}
static u32 vcd_init_in_null
(struct vcd_drv_ctxt_type_t *p_drv_ctxt,
 struct vcd_init_config_type *p_config, s32 *p_driver_handle) {
    u32 rc = VCD_S_SUCCESS;
    struct vcd_dev_ctxt_type *p_dev_ctxt = &p_drv_ctxt->dev_ctxt;
    u32 b_done_create_timer = FALSE;
    VCD_MSG_LOW("vcd_init_in_dev_null:");


    p_dev_ctxt->config = *p_config;

    p_dev_ctxt->p_device_base_addr =
        (u8 *)p_config->pf_map_dev_base_addr(
            p_dev_ctxt->config.p_device_name);

    if (!p_dev_ctxt->p_device_base_addr) {
        VCD_MSG_ERROR("NULL Device_base_addr");

        return VCD_ERR_FAIL;
    }

    if (p_config->pf_register_isr) {
        p_config->pf_register_isr(p_dev_ctxt->config.
                                  p_device_name);
    }

    if (p_config->pf_timer_create) {
        if (p_config->pf_timer_create(vcd_hw_timeout_handler,
                                      NULL, &p_dev_ctxt->p_hw_timer_handle))
            b_done_create_timer = TRUE;
        else {
            VCD_MSG_ERROR("timercreate failed");
            return VCD_ERR_FAIL;
        }
    }


    rc = vcd_init_cmn(p_drv_ctxt, p_config, p_driver_handle);

    if (!VCD_FAILED(rc)) {
        vcd_do_device_state_transition(p_drv_ctxt,
                                       VCD_DEVICE_STATE_NOT_INIT,
                                       DEVICE_STATE_EVENT_NUMBER
                                       (pf_init));
    } else {
        if (p_dev_ctxt->config.pf_un_map_dev_base_addr)
            p_dev_ctxt->config.pf_un_map_dev_base_addr();

        if (p_dev_ctxt->config.pf_deregister_isr)
            p_dev_ctxt->config.pf_deregister_isr();

        if (b_done_create_timer && p_dev_ctxt->config.pf_timer_release)
            p_dev_ctxt->config.pf_timer_release(p_dev_ctxt->
                                                p_hw_timer_handle);

    }

    return rc;

}
void vcd_term_driver_context(struct vcd_drv_ctxt_type_t *p_drv_ctxt)
{
    struct vcd_dev_ctxt_type *p_dev_ctxt = &p_drv_ctxt->dev_ctxt;

    VCD_MSG_HIGH("All driver instances terminated");

    if (p_dev_ctxt->config.pf_deregister_isr)
        p_dev_ctxt->config.pf_deregister_isr();

    if (p_dev_ctxt->config.pf_un_map_dev_base_addr)
        p_dev_ctxt->config.pf_un_map_dev_base_addr();

    if (p_dev_ctxt->config.pf_timer_release)
        p_dev_ctxt->config.pf_timer_release(
            p_dev_ctxt->p_hw_timer_handle);

    vcd_free(p_dev_ctxt->a_trans_tbl);

    memset(p_dev_ctxt, 0, sizeof(struct vcd_dev_ctxt_type));

    vcd_do_device_state_transition(p_drv_ctxt,
                                   VCD_DEVICE_STATE_NULL,
                                   DEVICE_STATE_EVENT_NUMBER(pf_term));

}
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));
}
Esempio n. 9
0
static void  vcd_hw_timeout_cmn(struct vcd_drv_ctxt *drv_ctxt,
							  void *user_data)
{
	struct vcd_dev_ctxt *dev_ctxt = &drv_ctxt->dev_ctxt;
	VCD_MSG_LOW("vcd_hw_timeout_cmn:");
	vcd_device_timer_stop(dev_ctxt);

	vcd_handle_device_err_fatal(dev_ctxt, NULL);

	/* Reset HW. */
	(void) vcd_reset_device_context(drv_ctxt,
		DEVICE_STATE_EVENT_NUMBER(timeout));
}
Esempio n. 10
0
void vcd_handle_for_last_clnt_close(
	struct vcd_dev_ctxt *dev_ctxt, u32 send_deinit)
{
	if (!dev_ctxt->cctxt_list_head) {
		VCD_MSG_HIGH("All clients are closed");
		if (send_deinit)
			(void) vcd_deinit_device_context(
				vcd_get_drv_context(),
				DEVICE_STATE_EVENT_NUMBER(close));
		else
			dev_ctxt->pending_cmd =
			VCD_CMD_DEVICE_TERM;
	}
}
void vcd_handle_device_err_fatal(struct vcd_dev_ctxt_type *p_dev_ctxt,
                                 struct vcd_clnt_ctxt_type_t *p_trig_clnt)
{
    struct vcd_clnt_ctxt_type_t *p_cctxt = p_dev_ctxt->p_cctxt_list_head;
    struct vcd_clnt_ctxt_type_t *p_tmp_clnt = NULL;
    VCD_MSG_LOW("vcd_handle_device_err_fatal:");
    while (p_cctxt) {
        p_tmp_clnt = p_cctxt;
        p_cctxt = p_cctxt->p_next;
        if (p_tmp_clnt != p_trig_clnt)
            vcd_clnt_handle_device_err_fatal(p_tmp_clnt,
                                             VCD_EVT_IND_HWERRFATAL);
    }
    p_dev_ctxt->e_pending_cmd = VCD_CMD_DEVICE_RESET;
    if (!p_dev_ctxt->p_cctxt_list_head)
        vcd_do_device_state_transition(vcd_get_drv_context(),
                                       VCD_DEVICE_STATE_NOT_INIT,
                                       DEVICE_STATE_EVENT_NUMBER(pf_timeout));
    else
        vcd_do_device_state_transition(vcd_get_drv_context(),
                                       VCD_DEVICE_STATE_INVALID,
                                       DEVICE_STATE_EVENT_NUMBER(pf_dev_cb));
}
Esempio n. 12
0
static u32  vcd_close_in_dev_invalid(struct vcd_drv_ctxt *drv_ctxt,
	struct vcd_clnt_ctxt *cctxt)
{
	u32 rc;
	VCD_MSG_LOW("vcd_close_in_dev_invalid:");
	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);
		rc = VCD_ERR_BAD_STATE;
	}
	if (!VCD_FAILED(rc) && !drv_ctxt->dev_ctxt.
		cctxt_list_head) {
		VCD_MSG_HIGH("All INVALID clients are closed");
		vcd_do_device_state_transition(drv_ctxt,
			VCD_DEVICE_STATE_NOT_INIT,
			DEVICE_STATE_EVENT_NUMBER(close));
	}
	return rc;
}
Esempio n. 13
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");
		}
	}
}
Esempio n. 14
0
void vcd_continue(void)
{
	struct vcd_drv_ctxt *drv_ctxt;
	struct vcd_dev_ctxt *dev_ctxt;
	u32 command_continue;
	struct vcd_transc *transc;
	u32 rc;
	VCD_MSG_LOW("vcd_continue:");

	drv_ctxt = vcd_get_drv_context();
	dev_ctxt = &drv_ctxt->dev_ctxt;

	dev_ctxt->command_continue = false;

	if (dev_ctxt->pending_cmd == VCD_CMD_DEVICE_INIT) {
		VCD_MSG_HIGH("VCD_CMD_DEVICE_INIT is pending");

		dev_ctxt->pending_cmd = VCD_CMD_NONE;

		(void)vcd_init_device_context(drv_ctxt,
			DEVICE_STATE_EVENT_NUMBER(open));
	} else if (dev_ctxt->pending_cmd == VCD_CMD_DEVICE_TERM) {
		VCD_MSG_HIGH("VCD_CMD_DEVICE_TERM is pending");

		dev_ctxt->pending_cmd = VCD_CMD_NONE;

		(void)vcd_deinit_device_context(drv_ctxt,
			DEVICE_STATE_EVENT_NUMBER(close));
	} else if (dev_ctxt->pending_cmd == VCD_CMD_DEVICE_RESET) {
		VCD_MSG_HIGH("VCD_CMD_DEVICE_RESET is pending");
		dev_ctxt->pending_cmd = VCD_CMD_NONE;
		(void)vcd_reset_device_context(drv_ctxt,
			DEVICE_STATE_EVENT_NUMBER(dev_cb));
	} else {
		if (dev_ctxt->set_perf_lvl_pending) {
			rc = vcd_power_event(dev_ctxt, NULL,
						 VCD_EVT_PWR_DEV_SET_PERFLVL);

			if (VCD_FAILED(rc)) {
				VCD_MSG_ERROR
					("VCD_EVT_PWR_CLNT_SET_PERFLVL failed");
				VCD_MSG_HIGH
					("Not running at desired perf level."
					 "curr=%d, reqd=%d",
					 dev_ctxt->curr_perf_lvl,
					 dev_ctxt->reqd_perf_lvl);
			} else {
				dev_ctxt->set_perf_lvl_pending = false;
			}
		}

		do {
			command_continue = false;

			if (vcd_get_command_channel_in_loop
				(dev_ctxt, &transc)) {
				if (vcd_submit_command_in_continue(dev_ctxt,
					transc))
					command_continue = true;
				else {
					VCD_MSG_MED
						("No more commands to submit");

					vcd_release_command_channel(dev_ctxt,
						transc);

					vcd_release_interim_command_channels
						(dev_ctxt);
				}
			}
		} while (command_continue);

		do {
			command_continue = false;

			if (vcd_get_frame_channel_in_loop
				(dev_ctxt, &transc)) {
				if (vcd_try_submit_frame_in_continue(dev_ctxt,
					transc)) {
					command_continue = true;
				} else {
					VCD_MSG_MED("No more frames to submit");

					vcd_release_frame_channel(dev_ctxt,
								  transc);

					vcd_release_interim_frame_channels
						(dev_ctxt);
				}
			}

		} while (command_continue);

		if (!vcd_core_is_busy(dev_ctxt)) {
			rc = vcd_power_event(dev_ctxt, NULL,
				VCD_EVT_PWR_CLNT_CMD_END);

			if (VCD_FAILED(rc))
				VCD_MSG_ERROR("Failed:"
					"VCD_EVT_PWR_CLNT_CMD_END");
		}
	}
}
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");
        }
    }
}
void vcd_continue(void)
{
    struct vcd_drv_ctxt_type_t *p_drv_ctxt;
    struct vcd_dev_ctxt_type *p_dev_ctxt;
    u32 b_continue;
    struct vcd_transc_type *p_transc;
    u32 rc;
    VCD_MSG_LOW("vcd_continue:");

    p_drv_ctxt = vcd_get_drv_context();
    p_dev_ctxt = &p_drv_ctxt->dev_ctxt;

    p_dev_ctxt->b_continue = FALSE;

    if (p_dev_ctxt->e_pending_cmd == VCD_CMD_DEVICE_INIT) {
        VCD_MSG_HIGH("VCD_CMD_DEVICE_INIT is pending");

        p_dev_ctxt->e_pending_cmd = VCD_CMD_NONE;

        (void)vcd_init_device_context(p_drv_ctxt,
                                      DEVICE_STATE_EVENT_NUMBER(pf_open));
    } else if (p_dev_ctxt->e_pending_cmd == VCD_CMD_DEVICE_TERM) {
        VCD_MSG_HIGH("VCD_CMD_DEVICE_TERM is pending");

        p_dev_ctxt->e_pending_cmd = VCD_CMD_NONE;

        (void)vcd_deinit_device_context(p_drv_ctxt,
                                        DEVICE_STATE_EVENT_NUMBER(pf_close));
    } else if (p_dev_ctxt->e_pending_cmd == VCD_CMD_DEVICE_RESET) {
        VCD_MSG_HIGH("VCD_CMD_DEVICE_RESET is pending");
        p_dev_ctxt->e_pending_cmd = VCD_CMD_NONE;
        (void)vcd_reset_device_context(p_drv_ctxt,
                                       DEVICE_STATE_EVENT_NUMBER(pf_dev_cb));
    } else {
        if (p_dev_ctxt->b_set_perf_lvl_pending) {
            rc = vcd_power_event(p_dev_ctxt, NULL,
                                 VCD_EVT_PWR_DEV_SET_PERFLVL);

            if (VCD_FAILED(rc)) {
                VCD_MSG_ERROR
                ("VCD_EVT_PWR_CLNT_SET_PERFLVL failed");
                VCD_MSG_HIGH
                ("Not running at desired perf level."
                 "curr=%d, reqd=%d",
                 p_dev_ctxt->n_curr_perf_lvl,
                 p_dev_ctxt->n_reqd_perf_lvl);
            } else {
                p_dev_ctxt->b_set_perf_lvl_pending = FALSE;
            }
        }

        do {
            b_continue = FALSE;

            if (vcd_get_command_channel_in_loop
                    (p_dev_ctxt, &p_transc)) {
                if (vcd_submit_command_in_continue(p_dev_ctxt,
                                                   p_transc))
                    b_continue = TRUE;
                else {
                    VCD_MSG_MED
                    ("No more commands to submit");

                    vcd_release_command_channel(p_dev_ctxt,
                                                p_transc);

                    vcd_release_interim_command_channels
                    (p_dev_ctxt);
                }
            }
        } while (b_continue);

        do {
            b_continue = FALSE;

            if (vcd_get_frame_channel_in_loop
                    (p_dev_ctxt, &p_transc)) {
                if (vcd_try_submit_frame_in_continue(p_dev_ctxt,
                                                     p_transc)) {
                    b_continue = TRUE;
                } else {
                    VCD_MSG_MED("No more frames to submit");

                    vcd_release_frame_channel(p_dev_ctxt,
                                              p_transc);

                    vcd_release_interim_frame_channels
                    (p_dev_ctxt);
                }
            }

        } while (b_continue);

        if (!vcd_core_is_busy(p_dev_ctxt)) {
            rc = vcd_power_event(p_dev_ctxt, NULL,
                                 VCD_EVT_PWR_CLNT_CMD_END);

            if (VCD_FAILED(rc))
                VCD_MSG_ERROR("Failed:"
                              "VCD_EVT_PWR_CLNT_CMD_END");
        }
    }
}