Esempio n. 1
0
static bool check_events(struct dsp_node *node, struct dsp_msg *msg)
{
	unsigned int index = 0;
	pr_debug("waiting for events");
	if (!dsp_wait_for_events(dsp_handle, events, 3, &index, 1000)) {
		pr_warning("failed waiting for events");
		return false;
	}

	switch (index) {
	case 0:
		dsp_node_get_message(dsp_handle, node, msg, 100);
		pr_debug("got dsp message: 0x%0x 0x%0x 0x%0x",
				msg->cmd, msg->arg_1, msg->arg_2);
		return true;
	case 1:
		pr_err("got DSP MMUFAULT");
		return false;
	case 2:
		pr_err("got DSP SYSERROR");
		return false;
	default:
		pr_err("wrong event index");
		return false;
	}
}
Esempio n. 2
0
static GstFlowReturn
pad_chain(GstPad *pad,
	  GstBuffer *buf)
{
	GstDspDummy *self;
	GstFlowReturn ret;
	GstBuffer *out_buf;

	self = GST_DSP_DUMMY(GST_OBJECT_PARENT(pad));

	ret = gst_pad_alloc_buffer_and_set_caps(self->srcpad,
						GST_BUFFER_OFFSET_NONE,
						GST_BUFFER_SIZE(buf),
						GST_BUFFER_CAPS(buf),
						&out_buf);

	if (G_UNLIKELY(ret != GST_FLOW_OK)) {
		GST_ERROR_OBJECT(self, "couldn't allocate buffer");
		ret = GST_FLOW_ERROR;
		goto leave;
	}

	/* map dsp to gpp address */
	map_buffer(self, buf, self->in_buffer);
	map_buffer(self, out_buf, self->out_buffer);

	configure_dsp_node(self->dsp_handle, self->node, self->in_buffer, self->out_buffer);

	if (self->in_buffer->need_copy) {
		memcpy(self->in_buffer->data, GST_BUFFER_DATA(buf), GST_BUFFER_SIZE(buf));
		self->in_buffer->need_copy = false;
	}

	{
		dsp_msg_t msg;

		dmm_buffer_clean(self->in_buffer, self->in_buffer->size);
		msg.cmd = 1;
		msg.arg_1 = self->in_buffer->size;
		dsp_node_put_message(self->dsp_handle, self->node, &msg, -1);
		dsp_node_get_message(self->dsp_handle, self->node, &msg, -1);
		dmm_buffer_invalidate(self->out_buffer, self->out_buffer->size);
	}

	if (self->out_buffer->need_copy) {
		memcpy(GST_BUFFER_DATA(out_buf), self->out_buffer->data, GST_BUFFER_SIZE(out_buf));
		self->out_buffer->need_copy = false;
	}

	GST_BUFFER_TIMESTAMP(out_buf) = GST_BUFFER_TIMESTAMP(buf);

	ret = gst_pad_push(self->srcpad, out_buf);

leave:
	gst_buffer_unref(buf);

	return ret;
}
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;
}
Esempio n. 4
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;
}