Exemplo n.º 1
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 inline void configure_dsp_node(void *node, struct dmm_buffer *input_buffer, struct dmm_buffer *output_buffer)
{
	struct dsp_msg msg;

	msg.cmd = 0;
	msg.arg_1 = (uint32_t) input_buffer->map;
	msg.arg_2 = (uint32_t) output_buffer->map;
	dsp_node_put_message(dsp_handle, node, &msg, -1);
}
Exemplo n.º 3
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);
}
Exemplo n.º 4
0
static inline void
configure_dsp_node(void *node,
		dmm_buffer_t *input_buffer,
		dmm_buffer_t *output_buffer)
{
	struct dsp_msg msg;

	msg.cmd = 0;
	msg.arg_1 = (uint32_t) input_buffer->map;
	msg.arg_2 = (uint32_t) output_buffer->map;
	if (do_fault)
		msg.arg_2 = 0x12345678;
	dsp_node_put_message(dsp_handle, node, &msg, -1);
}
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;
}
Exemplo n.º 6
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;
}