I tryed to get the filter running, but it does not really work.
I configured the frame reader, the FIR-Filter and the SG-DMA as you can see in the attached pictures.
In my software I do the following:
1. Init. and start the sg-dma
In my main function:
// Open a SG-DMA for ST-->MM
alt_sgdma_dev* receive_DMA = alt_avalon_sgdma_open("/dev/stream_to_memory");
alt_sgdma_descriptor *receive_descriptors, *receive_descriptors_copy;
alt_u32 return_code;
if(receive_DMA == NULL) {
printf("Could not open the receive SG-DMA\n");
setState(STATE_SEND_TIME, 0);
}
return_code = descriptor_allocation(&receive_descriptors, &receive_descriptors_copy, 1);
alt_avalon_sgdma_construct_stream_to_mem_desc(&receive_descriptors, // descriptor
&receive_descriptors, // next descriptor
FILT_IMAGE, // write buffer location (0x140000)
(alt_u16)(iImageSize), // length of the buffer (4096 in my test -> 64x64 image)
0); // writes are not to a fixed location
alt_avalon_sgdma_register_callback(receive_DMA, &receive_callback_function, (ALTERA_AVALON_SGDMA_CONTROL_IE_GLOBAL_MSK |ALTERA_AVALON_SGDMA_CONTROL_IE_CHAIN_COMPLETED_MSK), NULL);
The descriptor allocation:
alt_u32 descriptor_allocation(alt_sgdma_descriptor ** receive_descriptors,
alt_sgdma_descriptor ** receive_descriptors_copy,
alt_u32 number_of_buffers)
{
void * temp_ptr_1;
temp_ptr_1 = malloc((number_of_buffers + 2) * ALTERA_AVALON_SGDMA_DESCRIPTOR_SIZE);
if(temp_ptr_1 == NULL)
{
printf("Failed to allocate memory for the receive descriptors\n");
return 1;
}
*receive_descriptors_copy = (alt_sgdma_descriptor *)temp_ptr_1;
while((((alt_u32)temp_ptr_1) % ALTERA_AVALON_SGDMA_DESCRIPTOR_SIZE) != 0)
{
temp_ptr_1++; // slide the pointer until 32 byte boundary is found
}
*receive_descriptors = (alt_sgdma_descriptor *)temp_ptr_1;
// Clear out the null descriptor owned by hardware bit.
receive_descriptors->control = 0;
return 0; // no failures in allocation
}
2. Init. and start the frame reader
static const int pb0_base_addressoffset = 4;
static const int pb0_words_addressoffset = 5;
static const int pb0_samples_addressoffset = 6;
static const int pb0_width_addressoffset = 8;
static const int pb0_height_addressoffset = 9;
static const int pb0_interlaced_addressoffset = 10;
static const int packet_bank_addressoffset = 3;
//register isr
alt_ic_isr_register(ALT_VIP_VFR_0_IRQ_INTERRUPT_CONTROLLER_ID, irq, FR_ISR, 0, 0);
//config
FR_do_write(pb0_base_addressoffset, base_address); //address of my image in the sram (0x100000)
FR_do_write(pb0_words_addressoffset, words); // words = (64x64) / (32/8) --> 1024
FR_do_write(pb0_samples_addressoffset, samples); // samples = 4096
FR_do_write(pb0_width_addressoffset, width); // width = 64
FR_do_write(pb0_height_addressoffset, height); // height = 64
FR_do_write(pb0_interlaced_addressoffset, interlaced);//interlaced = 3 --> progressiv?!
FR_do_write(packet_bank_addressoffset, 0);
//start
FR_enable_interrupt(INTERRUPT);
control = control | 1;
FR_do_write(GO, control);
void FR_do_write(int offset, int value)
{
IOWR(ALT_VIP_VFR_0_BASE, offset, value);
}
The frame reader interrupt fires, but the sg-dma interrupt does not.
And there is nothing written to my target memory.
Does anybody see, what I am doing wrong here?