Exemplo n.º 1
0
u32 vcd_close(void *handle)
{
	struct vcd_clnt_ctxt *cctxt =
	    (struct vcd_clnt_ctxt *)handle;
	struct vcd_drv_ctxt *drv_ctxt;
	u32 rc;
	int is_secure = 0;
	VCD_MSG_MED("vcd_close:");

	if (!cctxt || cctxt->signature != VCD_SIGNATURE) {
		VCD_MSG_ERROR("Bad client handle");

		return VCD_ERR_BAD_HANDLE;
	}

	is_secure = cctxt->secure;
	drv_ctxt = vcd_get_drv_context();
	mutex_lock(&drv_ctxt->dev_mutex);
	if (drv_ctxt->dev_state.state_table->ev_hdlr.close) {
		rc = drv_ctxt->dev_state.state_table->ev_hdlr.
		    close(drv_ctxt, cctxt);
	} else {
		VCD_MSG_ERROR("Unsupported API in device state %d",
			      drv_ctxt->dev_state.state);

		rc = VCD_ERR_BAD_STATE;
	}
	mutex_unlock(&drv_ctxt->dev_mutex);
	if (is_secure)
		res_trk_secure_unset();
	return rc;

}
Exemplo n.º 2
0
u32 vcd_open(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, int flags)
{
	u32 rc = 0, num_of_instances = 0;
	struct vcd_drv_ctxt *drv_ctxt;
	struct vcd_clnt_ctxt *cctxt;
	int is_secure = (flags & VCD_CP_SESSION) ? 1 : 0;
	VCD_MSG_MED("vcd_open:");

	if (!callback) {
		VCD_MSG_ERROR("Bad parameters");
		return -EINVAL;
	}

	drv_ctxt = vcd_get_drv_context();
	cctxt = drv_ctxt->dev_ctxt.cctxt_list_head;
	while (cctxt) {
		num_of_instances++;
		cctxt = cctxt->next;
	}
	if (num_of_instances == VIDC_MAX_NUM_CLIENTS) {
		pr_err(" %s(): Max number of clients reached\n", __func__);
		return -ENODEV;
	}
	rc = is_session_invalid(decoding, flags);
	if (rc) {
		VCD_MSG_ERROR("Invalid Session: is_decoder: %d, secure: %d\n",
				decoding, flags);
		return rc;
	}
	if (is_secure)
		res_trk_secure_set();
	mutex_lock(&drv_ctxt->dev_mutex);

	if (drv_ctxt->dev_state.state_table->ev_hdlr.open) {
		rc = drv_ctxt->dev_state.state_table->ev_hdlr.
		    open(drv_ctxt, driver_handle, decoding, callback,
			    client_data);
		if (rc) {
			rc = -ENODEV;
		}
	} else {
		VCD_MSG_ERROR("Unsupported API in device state %d",
			      drv_ctxt->dev_state.state);
		rc = -EPERM;
	}
	if (!rc) {
		cctxt = drv_ctxt->dev_ctxt.cctxt_list_head;
		cctxt->secure = is_secure;
	} else if (is_secure)
		res_trk_secure_unset();

	mutex_unlock(&drv_ctxt->dev_mutex);
	return rc;
}