Esempio n. 1
0
u32 vcd_reset_device_context(struct vcd_drv_ctxt *drv_ctxt,
	u32 ev_code)
{
	struct vcd_dev_ctxt *dev_ctxt = &drv_ctxt->dev_ctxt;
	u32 rc = VCD_S_SUCCESS;

	VCD_MSG_LOW("vcd_reset_device_context:");
	vcd_reset_device_channels(dev_ctxt);
	rc = vcd_power_event(&drv_ctxt->dev_ctxt, NULL,
						 VCD_EVT_PWR_DEV_TERM_BEGIN);
	VCD_FAILED_RETURN(rc, "VCD_EVT_PWR_DEV_TERM_BEGIN failed");
	if (ddl_reset_hw(0))
		VCD_MSG_HIGH("HW Reset done");
	else
		VCD_MSG_FATAL("HW Reset failed");

	(void)vcd_power_event(dev_ctxt, NULL, VCD_EVT_PWR_DEV_TERM_END);

	return VCD_S_SUCCESS;
}
Esempio n. 2
0
void vcd_ddl_callback(u32 event, u32 status, void *payload,
	size_t sz, u32 *ddl_handle, void *const client_data)
{
	struct vcd_drv_ctxt *drv_ctxt;
	struct vcd_dev_ctxt *dev_ctxt;
	struct vcd_dev_state_ctxt *dev_state;
	struct vcd_clnt_ctxt *cctxt;
	struct vcd_transc *transc;

	VCD_MSG_LOW("vcd_ddl_callback:");

	VCD_MSG_LOW("event=0x%x status=0x%x", event, status);

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

	dev_ctxt->command_continue = true;
	vcd_device_timer_stop(dev_ctxt);

	switch (dev_state->state) {
	case VCD_DEVICE_STATE_NULL:
		{
			VCD_MSG_HIGH("Callback unexpected in NULL state");
			break;
		}

	case VCD_DEVICE_STATE_NOT_INIT:
		{
			VCD_MSG_HIGH("Callback unexpected in NOT_INIT state");
			break;
		}

	case VCD_DEVICE_STATE_INITING:
		{
			if (dev_state->state_table->ev_hdlr.dev_cb) {
				dev_state->state_table->ev_hdlr.
					dev_cb(drv_ctxt, event, status,
						  payload, sz, ddl_handle,
						  client_data);
			} else {
				VCD_MSG_HIGH("No device handler in %d state",
						 dev_state->state);
			}
			break;
		}

	case VCD_DEVICE_STATE_READY:
		{
			transc = (struct vcd_transc *)client_data;

			if (!transc || !transc->in_use
				|| !transc->cctxt) {
				VCD_MSG_ERROR("Invalid clientdata "
							  "received from DDL ");
			} else {
				cctxt = transc->cctxt;

				if (cctxt->clnt_state.state_table->ev_hdlr.
					clnt_cb) {
					cctxt->clnt_state.state_table->
						ev_hdlr.clnt_cb(cctxt,
						event, status, payload,
						sz,	ddl_handle,
						client_data);
				} else {
					VCD_MSG_HIGH
					("No client handler in"
					" (dsm:READY, csm:%d) state",
					(int)cctxt->clnt_state.state);

					if (VCD_FAILED(status)) {
						VCD_MSG_FATAL("DDL callback"
						" returned failure 0x%x",
						status);
					}
				}
			}
			break;
		}

	default:
		{
			VCD_MSG_ERROR("Unknown state");
			break;
		}

	}

}
void vcd_ddl_callback(u32 event, u32 status, void *p_payload,
                      u32 n_size, u32 *ddl_handle, void *const p_client_data)
{
    struct vcd_drv_ctxt_type_t *p_drv_ctxt;
    struct vcd_dev_ctxt_type *p_dev_ctxt;
    struct vcd_dev_state_ctxt_type_t *p_dev_state;
    struct vcd_clnt_ctxt_type_t *p_cctxt;
    struct vcd_transc_type *p_transc;

    VCD_MSG_LOW("vcd_ddl_callback:");

    VCD_MSG_LOW("event=0x%x status=0x%x", event, status);

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

    p_dev_ctxt->b_continue = TRUE;
    vcd_device_timer_stop(p_dev_ctxt);

    switch (p_dev_state->e_state) {
    case VCD_DEVICE_STATE_NULL:
    {
        VCD_MSG_HIGH("Callback unexpected in NULL state");
        break;
    }

    case VCD_DEVICE_STATE_NOT_INIT:
    {
        VCD_MSG_HIGH("Callback unexpected in NOT_INIT state");
        break;
    }

    case VCD_DEVICE_STATE_INITING:
    {
        if (p_dev_state->p_state_table->ev_hdlr.pf_dev_cb) {
            p_dev_state->p_state_table->ev_hdlr.
            pf_dev_cb(p_drv_ctxt, event, status,
                      p_payload, n_size, ddl_handle,
                      p_client_data);
        } else {
            VCD_MSG_HIGH("No device handler in %d state",
                         p_dev_state->e_state);
        }
        break;
    }

    case VCD_DEVICE_STATE_READY:
    {
        p_transc = (struct vcd_transc_type *)p_client_data;

        if (!p_transc || !p_transc->b_in_use
                || !p_transc->p_cctxt) {
            VCD_MSG_ERROR("Invalid clientdata "
                          "received from DDL ");
        } else {
            p_cctxt = p_transc->p_cctxt;

            if (p_cctxt->clnt_state.p_state_table->ev_hdlr.
                    pf_clnt_cb) {
                p_cctxt->clnt_state.p_state_table->
                ev_hdlr.pf_clnt_cb(p_cctxt,
                                   event, status, p_payload,
                                   n_size,	ddl_handle,
                                   p_client_data);
            } else {
                VCD_MSG_HIGH
                ("No client handler in"
                 " (dsm:READY, csm:%d) state",
                 (int)p_cctxt->clnt_state.e_state);

                if (VCD_FAILED(status)) {
                    VCD_MSG_FATAL("DDL callback"
                                  " returned failure 0x%x",
                                  status);
                }
            }
        }
        break;
    }

    default:
    {
        VCD_MSG_ERROR("Unknown state");
        break;
    }

    }

}