예제 #1
0
static int __axi_free(int mode)
{
	int rc = 0;

	if (!cam_dev_handle)
		return rc;

	rc = dalrpc_fcn_0(DALRPC_AXI_FREE, cam_dev_handle, mode);
	if (rc) {
		printk(KERN_ERR "%s: AXI bus device (%d) failed to be configured\n",
			__func__, rc);
		goto fail_dal_fcn_0;
	}

	/* close device handle */
	rc = daldevice_detach(cam_dev_handle);
	if (rc) {
		printk(KERN_ERR "%s: failed to detach AXI bus device (%d)\n",
			__func__, rc);
		goto fail_dal_attach_detach;
	}
	cam_dev_handle = NULL;
	return 0;

fail_dal_fcn_0:
	(void)daldevice_detach(cam_dev_handle);
	cam_dev_handle = NULL;
fail_dal_attach_detach:
	return rc;
}
예제 #2
0
/* this function is called when everything is going away.*/
s32 cad_rpc_deinit()
{
	u32 i;
	struct callback_function_node  *node = NULL;

	D("cad deinit function fired   ....... \n");

	/* release remote device handle*/
	if (cad_rpc_data_type.remote_handle)
		daldevice_detach(cad_rpc_data_type.remote_handle);

	mutex_destroy(&cad_rpc_data_type.resource_mutex);
	mutex_destroy(&cad_rpc_data_type.rpc_cb_mutex);


	for (i = 0; i < CAD_MAX_SESSION; i++) {

		mutex_destroy(&cad_rpc_data_type.remote_mutex_list[i]);

		/* clean callback  function array */
		while (cad_rpc_data_type.dal_callback_list[i]) {
			node = cad_rpc_data_type.dal_callback_list[i];
			cad_rpc_data_type.dal_callback_list[i] =
			(cad_rpc_data_type.dal_callback_list[i])->next;
			kfree(node);
		}
	}

	/*free shared memory first, then close file handle */
	memset(&cad_rpc_data_type, 0, sizeof(cad_rpc_data_type));
	D("DeInit the rpc resource interface!!!!!\n");
	return CAD_RES_SUCCESS;
}
예제 #3
0
static int __axi_allocate(int mode)
{
	int rc;

	/* get device handle */
	rc = daldevice_attach(DALDEVICEID_AXI, DALRPC_PORT_NAME,
				DALRPC_DEST_MODEM, &cam_dev_handle);
	if (rc) {
		printk(KERN_ERR "%s: failed to attach AXI bus device (%d)\n",
			__func__, rc);
		goto fail_dal_attach_detach;
	}

	rc = dalrpc_fcn_0(DALRPC_AXI_ALLOCATE, cam_dev_handle, mode);
	if (rc) {
		printk(KERN_ERR "%s: AXI bus device (%d) failed to be configured\n",
			__func__, rc);
		goto fail_dal_fcn_0;
	}

	return 0;

fail_dal_fcn_0:
	(void)daldevice_detach(cam_dev_handle);
	cam_dev_handle = NULL;
fail_dal_attach_detach:
	return rc;
}
예제 #4
0
static int __axi_halt(int port)
{
        int rc = 0;

        /* get device handle */
        rc = daldevice_attach(
                DALDEVICEID_AXI, DALRPC_PORT_NAME,
                DALRPC_DEST_MODEM, &halt_dev_handle
        );
        if (rc) {
                printk(KERN_ERR "%s: failed to attach AXI bus device (%d)\n",
                        __func__, rc);
                goto fail_dal_attach_detach;
        }

        rc = dalrpc_fcn_0(
                DALRPC_AXI_HALT, halt_dev_handle,
                port
        );
        if (rc) {
                printk(KERN_ERR "%s: AXI bus device (%d) failed to be HALTED\n",
                        __func__, rc);
        }
        rc = dalrpc_fcn_0(
                DALRPC_AXI_UNHALT, halt_dev_handle,
                port);
        if (rc) {
                printk(KERN_ERR "%s: AXI bus device (%d) failed to be UNHALTED\n",
                        __func__, rc);
        }
        daldevice_detach(halt_dev_handle);
        return 0;
fail_dal_attach_detach:
        return 0;
}
static int axi_configure_bridge_grfx_sync_mode(int bridge_mode)
{
	int rc;
	void *dev_handle;

	/* get device handle */
	rc = daldevice_attach(
		DALDEVICEID_AXI, DALRPC_PORT_NAME,
		DALRPC_DEST_MODEM, &dev_handle
	);
	if (rc) {
		printk(KERN_ERR "%s: failed to attach AXI bus device (%d)\n",
			__func__, rc);
		goto fail_dal_attach_detach;
	}

	/* call ConfigureBridge */
	rc = dalrpc_fcn_0(
		DALRPC_AXI_CONFIGURE_BRIDGE, dev_handle,
		bridge_mode
	);
	if (rc) {
		printk(KERN_ERR "%s: AXI bus device (%d) failed to be configured\n",
			__func__, rc);
		goto fail_dal_fcn_0;
	}

	/* close device handle */
	rc = daldevice_detach(dev_handle);
	if (rc) {
		printk(KERN_ERR "%s: failed to detach AXI bus device (%d)\n",
			__func__, rc);
		goto fail_dal_attach_detach;
	}

	return 0;

fail_dal_fcn_0:
	(void)daldevice_detach(dev_handle);
fail_dal_attach_detach:

	return rc;
}
예제 #6
0
s32 adie_dinit(void)
{
	s32	dal_rc;
	u8	dev_type;

	dal_rc = CAD_RES_SUCCESS;
	dev_type = 0;

	dal_rc = daldevice_detach(adie_state.adie_handle);
	if (CAD_RES_SUCCESS != dal_rc)
		pr_err("ARD: ADIE Device Detach failed\n");

	for (dev_type = 0; dev_type < MAX_ADIE_PATH_TYPES; dev_type++) {
		adie_state.adie_path_type[dev_type].enabled = ADIE_FALSE;
		adie_state.adie_path_type[dev_type].enable_request = ADIE_FALSE;
		adie_state.adie_path_type[dev_type].state = ADIE_STATE_RESET;
	}

	adie_state.adie_opened = ADIE_FALSE;

	return dal_rc;
}
static int __init voice_init(void)
{
    int rc, i;
    struct voice_data *v = &voice;
    MM_INFO("\n"); /* Macro prints the file name and function */

    mutex_init(&voice.voc_lock);
    mutex_init(&voice.vol_lock);
    v->handle = NULL;
    v->cb_handle = NULL;

    /* set default value */
    v->default_mute_val = 1;  /* default is mute */
    v->default_vol_val = 0;
    v->default_sample_val = 8000;
    for (i = 0; i < VOC_RX_VOL_ARRAY_NUM; i++) {
        v->max_rx_vol[i] = 0;
        v->min_rx_vol[i] = 0;
    }
    v->network = NETWORK_GSM;

    /* initialize dev_rx and dev_tx */
    memset(&v->dev_tx, 0, sizeof(struct device_data));
    memset(&v->dev_rx, 0, sizeof(struct device_data));
    v->dev_rx.volume = v->default_vol_val;
    v->dev_tx.mute = v->default_mute_val;

    v->dev_state = DEV_INIT;
    v->voc_state = VOICE_INIT;
    atomic_set(&v->rel_start_flag, 0);
    atomic_set(&v->acq_start_flag, 0);
    v->dev_event = 0;
    v->voc_event = 0;
    init_completion(&voice.complete);
    init_waitqueue_head(&v->dev_wait);
    init_waitqueue_head(&v->voc_wait);

    /* get device handle */
    rc = daldevice_attach(VOICE_DALRPC_DEVICEID,
                          VOICE_DALRPC_PORT_NAME,
                          VOICE_DALRPC_CPU,
                          &v->handle);
    if (rc) {
        MM_ERR("Voc DALRPC call to Modem attach failed\n");
        goto done;
    }

    /* Allocate the callback handle */
    v->cb_handle = dalrpc_alloc_cb(v->handle, remote_cb_function, v);
    if (v->cb_handle == NULL) {
        MM_ERR("Allocate Callback failure\n");
        goto err;
    }

    /* setup the callback */
    rc = voice_cmd_init(v);
    if (rc)
        goto err1;

    v->device_events = AUDDEV_EVT_DEV_CHG_VOICE |
                       AUDDEV_EVT_DEV_RDY |
                       AUDDEV_EVT_REL_PENDING |
                       AUDDEV_EVT_START_VOICE |
                       AUDDEV_EVT_END_VOICE |
                       AUDDEV_EVT_DEVICE_VOL_MUTE_CHG |
                       AUDDEV_EVT_FREQ_CHG;

    MM_DBG(" to register call back \n");
    /* register callback to auddev */
    auddev_register_evt_listner(v->device_events, AUDDEV_CLNT_VOC,
                                0, voice_auddev_cb_function, v);

    /* create and start thread */
    v->task = kthread_run(voice_thread, v, "voice");
    if (IS_ERR(v->task)) {
        rc = PTR_ERR(v->task);
        v->task = NULL;
    } else
        goto done;

err1:
    dalrpc_dealloc_cb(v->handle, v->cb_handle);
err:
    daldevice_detach(v->handle);
    v->handle = NULL;
done:
    return rc;
}
static int remotetest_exec(int dest, u64 *val)
{
    void *dev_handle;
    void *event_handles[3];
    void *cb_handle;
    int ret;
    u64 errmask = 0;
    uint32_t ouint;
    uint32_t oalen;

    /*                       */
    ret = daldevice_attach(REMOTE_UNITTEST_DEVICEID, NULL,
                           dest, &dev_handle);
    if (ret) {
        printk(KERN_INFO "%s: failed to attach (%d)\n", __func__, ret);
        *val = 0xffffffff;
        return 0;
    }

    /*                        */
    ret = remote_unittest_0(dev_handle, REMOTE_UNITTEST_INARG_1);
    if (ret)
        rpc_error(0);

    /*                        */
    ret = remote_unittest_1(dev_handle, REMOTE_UNITTEST_INARG_1,
                            REMOTE_UNITTEST_INARG_2);
    if (ret)
        rpc_error(1);

    /*                        */
    ouint = 0;
    ret = remote_unittest_2(dev_handle, REMOTE_UNITTEST_INARG_1, &ouint);
    if (ret)
        rpc_error(2);
    else if (ouint != REMOTE_UNITTEST_OUTARG_1)
        verify_error(2, "ouint");

    /*                        */
    ret = remote_unittest_3(dev_handle, REMOTE_UNITTEST_INARG_1,
                            REMOTE_UNITTEST_INARG_2,
                            REMOTE_UNITTEST_INARG_3);
    if (ret)
        rpc_error(3);

    /*                        */
    ouint = 0;
    ret = remote_unittest_4(dev_handle, REMOTE_UNITTEST_INARG_1,
                            REMOTE_UNITTEST_INARG_2, &ouint);
    if (ret)
        rpc_error(4);
    else if (ouint != REMOTE_UNITTEST_OUTARG_1)
        verify_error(4, "ouint");

    /*                        */
    init_data(&in_data);
    ret = remote_unittest_5(dev_handle, &in_data, sizeof(in_data));
    if (ret)
        rpc_error(5);

    /*                        */
    init_data(&in_data);
    ret = remote_unittest_6(dev_handle, REMOTE_UNITTEST_INARG_1,
                            &in_data.test, sizeof(in_data.test));
    if (ret)
        rpc_error(6);

    /*                        */
    init_data(&in_data);
    memset(&out_data, 0, sizeof(out_data));
    ret = remote_unittest_7(dev_handle, &in_data, sizeof(in_data),
                            &out_data.test, sizeof(out_data.test),
                            &oalen);
    if (ret)
        rpc_error(7);
    else if (oalen != sizeof(out_data.test))
        verify_error(7, "oalen");
    else if (verify_uint32_buffer(out_data.test))
        verify_error(7, "obuf");

    /*                        */
    init_bytebuf(in_bytebuf);
    memset(&out_data, 0, sizeof(out_data));
    ret = remote_unittest_8(dev_handle, in_bytebuf, sizeof(in_bytebuf),
                            &out_data, sizeof(out_data));
    if (ret)
        rpc_error(8);
    else if (verify_data(&out_data))
        verify_error(8, "obuf");

    /*                        */
    memset(&out_bytebuf, 0, sizeof(out_bytebuf));
    ret = remote_unittest_9(dev_handle, out_bytebuf, sizeof(out_bytebuf));
    if (ret)
        rpc_error(9);
    else if (verify_bytebuf(out_bytebuf))
        verify_error(9, "obuf");

    /*                         */
    init_bytebuf(in_bytebuf);
    memset(&out_bytebuf, 0, sizeof(out_bytebuf));
    ret = remote_unittest_10(dev_handle, REMOTE_UNITTEST_INARG_1,
                             in_bytebuf, sizeof(in_bytebuf),
                             out_bytebuf, sizeof(out_bytebuf), &oalen);
    if (ret)
        rpc_error(10);
    else if (oalen != sizeof(out_bytebuf))
        verify_error(10, "oalen");
    else if (verify_bytebuf(out_bytebuf))
        verify_error(10, "obuf");

    /*                         */
    memset(&out_bytebuf, 0, sizeof(out_bytebuf));
    ret = remote_unittest_11(dev_handle, REMOTE_UNITTEST_INARG_1,
                             out_bytebuf, sizeof(out_bytebuf));
    if (ret)
        rpc_error(11);
    else if (verify_bytebuf(out_bytebuf))
        verify_error(11, "obuf");

    /*                         */
    memset(&out_bytebuf, 0, sizeof(out_bytebuf));
    ret = remote_unittest_12(dev_handle, REMOTE_UNITTEST_INARG_1,
                             out_bytebuf, sizeof(out_bytebuf), &oalen);
    if (ret)
        rpc_error(12);
    else if (oalen != sizeof(out_bytebuf))
        verify_error(12, "oalen");
    else if (verify_bytebuf(out_bytebuf))
        verify_error(12, "obuf");

    /*                         */
    init_data(&in_data);
    memset(&out_data, 0, sizeof(out_data));
    ret = remote_unittest_13(dev_handle, in_data.test, sizeof(in_data.test),
                             &in_data, sizeof(in_data),
                             &out_data, sizeof(out_data));
    if (ret)
        rpc_error(13);
    else if (verify_data(&out_data))
        verify_error(13, "obuf");

    /*                         */
    init_data(&in_data);
    memset(out_bytebuf, 0, sizeof(out_bytebuf));
    memset(out_bytebuf2, 0, sizeof(out_bytebuf2));
    ret = remote_unittest_14(dev_handle,
                             in_data.test, sizeof(in_data.test),
                             out_bytebuf, sizeof(out_bytebuf),
                             out_bytebuf2, sizeof(out_bytebuf2), &oalen);
    if (ret)
        rpc_error(14);
    else if (verify_bytebuf(out_bytebuf))
        verify_error(14, "obuf");
    else if (oalen != sizeof(out_bytebuf2))
        verify_error(14, "oalen");
    else if (verify_bytebuf(out_bytebuf2))
        verify_error(14, "obuf2");

    /*                         */
    init_data(&in_data);
    memset(out_bytebuf, 0, sizeof(out_bytebuf));
    memset(&out_data, 0, sizeof(out_data));
    ret = remote_unittest_15(dev_handle,
                             in_data.test, sizeof(in_data.test),
                             &in_data, sizeof(in_data),
                             &out_data, sizeof(out_data), &oalen,
                             out_bytebuf, sizeof(out_bytebuf));
    if (ret)
        rpc_error(15);
    else if (oalen != sizeof(out_data))
        verify_error(15, "oalen");
    else if (verify_bytebuf(out_bytebuf))
        verify_error(15, "obuf");
    else if (verify_data(&out_data))
        verify_error(15, "obuf2");

    /*                               */
    event_handles[0] = dalrpc_alloc_event(dev_handle);
    event_handles[1] = dalrpc_alloc_event(dev_handle);
    event_handles[2] = dalrpc_alloc_event(dev_handle);
    cb_handle = dalrpc_alloc_cb(dev_handle, test_cb, &out_data);
    in_data.regular_event = (uint32_t)event_handles[2];
    in_data.payload_event = (uint32_t)cb_handle;
    ret = remote_unittest_eventcfg(dev_handle, &in_data, sizeof(in_data));
    if (ret) {
        errmask |= (1 << 16);
        printk(KERN_INFO "%s: failed to configure asynch (%d)\n",
               __func__, ret);
    }

    /*            */
    ret = remote_unittest_eventtrig(dev_handle,
                                    REMOTE_UNITTEST_REGULAR_EVENT);
    if (ret) {
        errmask |= (1 << 17);
        printk(KERN_INFO "%s: failed to trigger event (%d)\n",
               __func__, ret);
    }
    ret = dalrpc_event_wait(event_handles[2], 1000);
    if (ret) {
        errmask |= (1 << 18);
        printk(KERN_INFO "%s: failed to receive event (%d)\n",
               __func__, ret);
    }

    /*                  */
    ret = remote_unittest_eventtrig(dev_handle,
                                    REMOTE_UNITTEST_REGULAR_EVENT);
    if (ret) {
        errmask |= (1 << 19);
        printk(KERN_INFO "%s: failed to trigger event (%d)\n",
               __func__, ret);
    }
    ret = dalrpc_event_wait_multiple(3, event_handles, 1000);
    if (ret != 2) {
        errmask |= (1 << 20);
        printk(KERN_INFO "%s: failed to receive event (%d)\n",
               __func__, ret);
    }

    /*               */
    ret = remote_unittest_eventtrig(dev_handle,
                                    REMOTE_UNITTEST_CALLBACK_EVENT);
    if (ret) {
        errmask |= (1 << 21);
        printk(KERN_INFO "%s: failed to trigger callback (%d)\n",
               __func__, ret);
    } else
        while (block_until_cb)
            ;

    dalrpc_dealloc_cb(dev_handle, cb_handle);
    dalrpc_dealloc_event(dev_handle, event_handles[0]);
    dalrpc_dealloc_event(dev_handle, event_handles[1]);
    dalrpc_dealloc_event(dev_handle, event_handles[2]);

    /*                       */
    ret = daldevice_detach(dev_handle);
    if (ret) {
        errmask |= (1 << 22);
        printk(KERN_INFO "%s: failed to detach (%d)\n", __func__, ret);
    }

    printk(KERN_INFO "%s: remote_unittest complete\n", __func__);

    *val = errmask;
    return 0;
}