diff --git a/src/mailbox.c b/src/mailbox.c index a6efe07..2657824 100644 --- a/src/mailbox.c +++ b/src/mailbox.c @@ -265,3 +265,23 @@ int mbox_open() { void mbox_close(int file_desc) { close(file_desc); } + +//https://github.com/sarfata/pi-blaster/pull/38#discussion_r28041695 +unsigned get_dma_channels(int file_desc) +{ + int i=0; + unsigned p[32]; + p[i++] = 0; // size + p[i++] = 0x00000000; // process request + + p[i++] = 0x60001; // (the tag id) + p[i++] = 4; // (size of the buffer) + p[i++] = 0; // (size of the data) + p[i++] = 0; // response buffer + + p[i++] = 0x00000000; // end tag + p[0] = i*sizeof *p; // actual size + + mbox_property(file_desc, p); + return p[5]; +} diff --git a/src/mailbox.h b/src/mailbox.h index 20437f3..2d818ff 100644 --- a/src/mailbox.h +++ b/src/mailbox.h @@ -46,3 +46,4 @@ void *unmapmem(void *addr, unsigned size); unsigned execute_code(int file_desc, unsigned code, unsigned r0, unsigned r1, unsigned r2, unsigned r3, unsigned r4, unsigned r5); unsigned execute_qpu(int file_desc, unsigned num_qpus, unsigned control, unsigned noflush, unsigned timeout); unsigned qpu_enable(int file_desc, unsigned enable); +unsigned get_dma_channels(int file_desc); diff --git a/src/rpidma.c b/src/rpidma.c index 8f1b839..7c80253 100644 --- a/src/rpidma.c +++ b/src/rpidma.c @@ -32,7 +32,7 @@ char InitDma(void *FunctionTerminate) printf("Failed to open mailbox\n"); return(0); } - + printf("DMA used : %x\n",get_dma_channels(mbox.handle)); mbox.mem_ref = mem_alloc(mbox.handle, NUM_PAGES* PAGE_SIZE, PAGE_SIZE, mem_flag); /* TODO: How do we know that succeeded? */ //printf("mem_ref %x\n", mbox.mem_ref);