Beispiel #1
0
static void run_dmm(struct dsp_node *node, unsigned long times)
{
	dmm_buffer_t *input_buffer;
	dmm_buffer_t *output_buffer;
	unsigned long total_times;

	input_buffer = dmm_buffer_new(dsp_handle, proc, DMA_TO_DEVICE);
	output_buffer = dmm_buffer_new(dsp_handle, proc, DMA_FROM_DEVICE);

	dmm_buffer_allocate(input_buffer, input_buffer_size);
	dmm_buffer_allocate(output_buffer, output_buffer_size);

	dmm_buffer_map(output_buffer);
	dmm_buffer_map(input_buffer);

	configure_dsp_node(node, input_buffer, output_buffer);

	total_times = times;
	pr_info("running %lu times", times);

	while (!done) {
		struct dsp_msg msg;

		if (do_write) {
			static unsigned char foo = 1;
			unsigned int i;
			for (i = 0; i < input_buffer->size; i++)
				((char *) input_buffer->data)[i] = foo;
			foo++;
		}

		dmm_buffer_begin(input_buffer, input_buffer->size);
		dmm_buffer_begin(output_buffer, output_buffer->size);
		msg.cmd = 1;
		msg.arg_1 = input_buffer->size;
		dsp_node_put_message(dsp_handle, node, &msg, -1);
		if (!check_events(node, &msg)) {
			done = true;
			break;
		}

		dmm_buffer_end(input_buffer, input_buffer->size);
		dmm_buffer_end(output_buffer, output_buffer->size);

		if (--times == 0)
			break;
	}

	dmm_buffer_unmap(output_buffer);
	dmm_buffer_unmap(input_buffer);

	dmm_buffer_free(output_buffer);
	dmm_buffer_free(input_buffer);

	printf("copied %lu times successfully\n", total_times);
}
static bool run_task(struct dsp_node *node)
{
  char text_send[] = "Hello";
  char text_receive[31];
  
  unsigned long exit_status;
  
  struct dsp_msg msg;

	struct dmm_buffer *input_buffer;
	struct dmm_buffer *output_buffer;

	if (!dsp_node_run(dsp_handle, node)) {
		pr_err("dsp node run failed");
		return false;
	}

	pr_info("dsp node running");

  // init memory
	input_buffer = dmm_buffer_new(dsp_handle, proc, DMA_TO_DEVICE);
	output_buffer = dmm_buffer_new(dsp_handle, proc, DMA_FROM_DEVICE);

	dmm_buffer_allocate(input_buffer, input_buffer_size);
	dmm_buffer_allocate(output_buffer, output_buffer_size);

  dmm_buffer_map(input_buffer);
	dmm_buffer_map(output_buffer);

	configure_dsp_node(node, input_buffer, output_buffer);

	pr_info("now sending string \"%s\" to DSP", text_send);

  // copy data into input buffer
  memcpy(input_buffer->data, text_send, strlen(text_send) + 1);

	dmm_buffer_begin(input_buffer, input_buffer->size);
	dmm_buffer_begin(output_buffer, output_buffer->size);
	
	// tell DSP to do some work
	msg.cmd = 1;
	msg.arg_1 = input_buffer->size;
	dsp_node_put_message(dsp_handle, node, &msg, -1);
	dsp_node_get_message(dsp_handle, node, &msg, -1);
	
	if(msg.cmd != 2)
	  pr_err("returned message has wrong command!");
	else
	{
	  memcpy(text_receive, output_buffer->data, 31);
	  pr_info("received string \"%s\" from DSP", text_receive);
	  
	  printf("%s\n", text_receive);
	}
	  
	dmm_buffer_end(input_buffer, input_buffer->size);
	dmm_buffer_end(output_buffer, output_buffer->size);

	dmm_buffer_unmap(output_buffer);
	dmm_buffer_unmap(input_buffer);

	dmm_buffer_free(output_buffer);
	dmm_buffer_free(input_buffer);

	if (!dsp_node_terminate(dsp_handle, node, &exit_status)) {
		pr_err("dsp node terminate failed: %lx", exit_status);
		return false;
	}

	pr_info("dsp node terminated");

	return true;
}
Beispiel #3
0
static bool
run_task(struct dsp_node *node,
		unsigned long times)
{
	unsigned long exit_status;

	dmm_buffer_t *input_buffer;
	dmm_buffer_t *output_buffer;

	if (!dsp_node_run(dsp_handle, node)) {
		pr_err("dsp node run failed");
		return false;
	}

	pr_info("dsp node running");

	input_buffer = dmm_buffer_new(dsp_handle, proc, DMA_TO_DEVICE);
	output_buffer = dmm_buffer_new(dsp_handle, proc, DMA_FROM_DEVICE);

	dmm_buffer_allocate(input_buffer, input_buffer_size);
	dmm_buffer_allocate(output_buffer, output_buffer_size);

	dmm_buffer_map(output_buffer);
	dmm_buffer_map(input_buffer);

	configure_dsp_node(node, input_buffer, output_buffer);

	pr_info("running %lu times", times);

	while (!done) {
		struct dsp_msg msg;

#ifdef FILL_DATA
		{
			static unsigned char foo = 1;
			unsigned int i;
			for (i = 0; i < input_buffer->size; i++)
				((char *) input_buffer->data)[i] = foo;
			foo++;
		}
#endif
		dmm_buffer_begin(input_buffer, input_buffer->size);
		dmm_buffer_begin(output_buffer, output_buffer->size);
		msg.cmd = 1;
		msg.arg_1 = input_buffer->size;
		dsp_node_put_message(dsp_handle, node, &msg, -1);
		dsp_node_get_message(dsp_handle, node, &msg, -1);
		dmm_buffer_end(input_buffer, input_buffer->size);
		dmm_buffer_end(output_buffer, output_buffer->size);

		if (--times == 0)
			break;
	}

	dmm_buffer_unmap(output_buffer);
	dmm_buffer_unmap(input_buffer);

	dmm_buffer_free(output_buffer);
	dmm_buffer_free(input_buffer);

	if (!dsp_node_terminate(dsp_handle, node, &exit_status)) {
		pr_err("dsp node terminate failed: %lx", exit_status);
		return false;
	}

	pr_info("dsp node terminated");

	return true;
}