Jump to content


Photo

Get image from decoder memory.


  • Please log in to reply
No replies to this topic

#1 Speedy1985

  • Senior Member
  • 120 posts

+18
Neutral

Posted 11 September 2012 - 10:34

Hi Pli developers.

I'am the developer from boblight for enigma2.

I hope anyone can help me with my problem in my new Boblight.
I have this code to get a pic from the decoder memory.

memory = (unsigned char*)mmap(0, offset + stride*(ofs2+64), PROT_READ, MAP_SHARED, mem_fd, adr);
if (memory == MAP_FAILED) {
printf("[grabber] mmap failed\n");
return false;
}

usleep(1000);  // we try to get a full picture, its not possible to get a sync from the decoder so we use a delay
// and hope we get a good timing. dont ask me why, but every DM800 i tested so far produced a good
// result with a 50ms delay

How can i check if the mmap is complete ?
I have used the sleep(50000) this work better but then the frames wil be later in lights.
pieterg from this forum says, that mem2mem dma must work, dma wil wait for complete he suggest.

PieterG
well, if you look at the remainder of the grabber code, you see that some hardware does not allow direct access to the videodecoder memory.
mem2mem dma is used on those platforms to transfer the frame into memory.
You could use this aproach on all platforms of course, perhaps the dma controller would wait for the frame to be valid/complete (just guessing).

I have tryed this, but no result. only green lights.

this is the mem2mem DMA code:

unsigned int i = 0;
unsigned int tmp_len = DMA_BLOCKSIZE;
unsigned int tmp_size = offset + stride * (ofs2 + 64);
if (tmp_size > 2 * DMA_BLOCKSIZE)
{
printf("[grabber] DMA length exceeds maximum (0x%x)\n", tmp_size);
return false;
}

memory = (unsigned char*)mmap(0, DMA_BLOCKSIZE + 0x1000, PROT_READ|PROT_WRITE, MAP_SHARED, mem_fd, SPARE_RAM);

if (memory == MAP_FAILED) {
printf("[grabber] mmap failed\n");
return false;
}

volatile unsigned long *mem_dma;
mem_dma = (unsigned long*)mmap(0, 0x1000, PROT_READ|PROT_WRITE, MAP_SHARED, mem_fd, 0x10100000);
if (mem_dma == MAP_FAILED) {
printf("[grabber] mmap failed\n");
return false;
}

for (i=0; i < tmp_size; i += DMA_BLOCKSIZE)
{
unsigned long *descriptor = (unsigned long*)memory;
if (i + DMA_BLOCKSIZE > tmp_size)
tmp_len = tmp_size - i;

descriptor[0] = /* READ */ adr + i;
descriptor[1] = /* WRITE */ SPARE_RAM + 0x1000;
descriptor[2] = 0x40000000 | /* LEN */ tmp_len;
descriptor[3] = 0;
descriptor[4] = 0;
descriptor[5] = 0;
descriptor[6] = 0;
descriptor[7] = 0;
mem_dma[1] = /* FIRST_DESCRIPTOR */ SPARE_RAM;
mem_dma[3] = /* DMA WAKE CTRL */ 3;
mem_dma[2] = 1;
while (mem_dma[5] == 1)
usleep(2);
mem_dma[2] = 0;
}

See the pictures to see my problem:

-pic1 Ok
-pic2 you see pic3 in top (the problem)
-pic3 Ok.

I hope any can help.

Attached Files


 
Support: webchat.freenode.net #boblight-enigma2


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users