summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.bzrignore6
-rw-r--r--CMakeLists.txt2
-rw-r--r--apps/CMakeLists.txt8
-rw-r--r--apps/compare_to_value.c66
-rw-r--r--apps/heb_strip_bad_values.c98
-rwxr-xr-xapps/load.sh3
-rw-r--r--apps/pio_test.c96
-rw-r--r--apps/xilinx.c76
-rw-r--r--apps/xilinx2.c225
-rw-r--r--driver/compat.h6
-rw-r--r--driver/kmem.c17
-rw-r--r--driver/pciDriver.h2
-rw-r--r--driver/sysfs.c11
-rw-r--r--ipecamera/events.c6
-rw-r--r--ipecamera/ipecamera.c55
-rw-r--r--ipecamera/model.h189
-rw-r--r--ipecamera/private.h8
-rw-r--r--ipecamera/reader.c13
-rw-r--r--pci.c2
-rw-r--r--pci.h1
-rw-r--r--pcilib.h6
-rwxr-xr-xtests/dma/debug/test-iommu.sh19
-rwxr-xr-xtests/dma/nwl/bench.sh (renamed from tests/bench_nwl.sh)0
-rwxr-xr-xtests/dma/nwl/cleanup.sh (renamed from tests/cleanup.sh)0
-rwxr-xr-xtests/dma/xilinx/xilinx_dma.sh (renamed from tests/xilinx_dma.sh)0
-rwxr-xr-xtests/dma/xilinx/xilinx_dma_static_mem.sh (renamed from apps/counters.sh)0
-rwxr-xr-xtests/frame2.sh37
-rwxr-xr-xtests/heb/DataTaking.sh96
-rwxr-xr-xtests/heb/cfg/BoardOFF.sh11
-rwxr-xr-xtests/heb/cfg/BoardOn.sh57
-rw-r--r--tests/heb/cfg/README11
-rwxr-xr-xtests/heb/cfg/Set_ADC_1_Delay.sh10
-rwxr-xr-xtests/heb/cfg/Set_ADC_2_Delay.sh10
-rwxr-xr-xtests/heb/cfg/Set_ADC_3_Delay.sh10
-rwxr-xr-xtests/heb/cfg/Set_ADC_4_Delay.sh11
-rwxr-xr-xtests/heb/cfg/Set_Default.sh30
-rwxr-xr-xtests/heb/cfg/Set_Delay_chip.sh11
-rwxr-xr-xtests/heb/cfg/Set_FPGA_clock_delay.sh10
-rwxr-xr-xtests/heb/cfg/Set_TH_Delay.sh10
-rwxr-xr-xtests/heb/debug/debug.sh45
-rwxr-xr-xtests/heb/debug/request_data.sh27
-rwxr-xr-xtests/ipecamera/bench.sh (renamed from tests/bench_ipecamera.sh)0
-rwxr-xr-xtests/ipecamera/cfg/Reset_Init_all_reg_10bit.sh (renamed from tests/ipecamera/Reset_Init_all_reg_10bit.sh)22
-rwxr-xr-xtests/ipecamera/cfg/Reset_Init_all_reg_10bit_4Mp.sh325
-rwxr-xr-xtests/ipecamera/cfg/Reset_Init_all_reg_11bit.sh (renamed from tests/ipecamera/Reset_Init_all_reg_11bit.sh)9
-rwxr-xr-xtests/ipecamera/cfg/Reset_Init_all_reg_12bit.sh (renamed from tests/ipecamera/Reset_Init_all_reg_12bit.sh)26
-rwxr-xr-xtests/ipecamera/debug/incomplete.sh (renamed from tests/incomplete.sh)0
-rwxr-xr-xtests/ipecamera/frame.sh (renamed from tests/frame.sh)5
-rwxr-xr-xtests/ipecamera/frame_req.sh (renamed from tests/frame_req.sh)0
-rwxr-xr-xtests/ipecamera/grab-hwtrigger.sh20
-rwxr-xr-xtests/ipecamera/stimuli.sh (renamed from tests/stimuli.sh)0
-rwxr-xr-xtests/ipecamera/tests/loopback-test.sh87
-rwxr-xr-xtests/ipecamera/tests/run-and-decode-test.sh103
53 files changed, 1472 insertions, 426 deletions
diff --git a/.bzrignore b/.bzrignore
index 17e5a11..4cbe2d8 100644
--- a/.bzrignore
+++ b/.bzrignore
@@ -18,6 +18,8 @@ cmake_install.cmake
Makefile
*.so.*
install_manifest.txt
-./xilinx
apps/xilinx
-apps/xilinx2
+apps/pio_test
+apps/compare_to_value
+apps/heb_strip_bad_values
+*.out
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a756d43..b653b09 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3,7 +3,7 @@ project(pcitool)
set(PCILIB_VERSION "0.0.1")
set(PCILIB_ABI_VERSION "0")
-cmake_minimum_required(VERSION 2.8)
+cmake_minimum_required(VERSION 2.6)
set(DISABLE_PCITOOL FALSE CACHE BOOL "Build only the library")
diff --git a/apps/CMakeLists.txt b/apps/CMakeLists.txt
index 80a506f..85457a1 100644
--- a/apps/CMakeLists.txt
+++ b/apps/CMakeLists.txt
@@ -7,5 +7,9 @@ link_directories(${UFODECODE_LIBRARY_DIRS})
add_executable(xilinx xilinx.c)
target_link_libraries(xilinx pcilib rt)
-add_executable(xilinx2 xilinx2.c)
-target_link_libraries(xilinx2 pcilib rt)
+add_executable(pio_test pio_test.c)
+target_link_libraries(pio_test pcilib rt)
+
+add_executable(compare_to_value compare_to_value.c)
+
+add_executable(heb_strip_bad_values heb_strip_bad_values.c)
diff --git a/apps/compare_to_value.c b/apps/compare_to_value.c
new file mode 100644
index 0000000..75ad353
--- /dev/null
+++ b/apps/compare_to_value.c
@@ -0,0 +1,66 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+
+int main(int argc, char *argv[]) {
+ long i, j, size, num;
+ size_t count = 0, total = 0;
+ int offset = 0, toread = 1, toskip = 0;
+ uint32_t value;
+ uint32_t *buf;
+
+ if ((argc != 4)&&(argc != 7)) {
+ printf("Usage: %s <file> <dwords> <value> [offset_dwords read_dwords skip_dwords] \n", argv[0]);
+ exit(0);
+ }
+
+ FILE *f = fopen(argv[1], "r");
+ if (!f) {
+ printf("Can't open %s\n", argv[1]);
+ exit(1);
+ }
+
+ size = atol(argv[2]);
+ if (size <= 0) {
+ printf("Can't parse size %s\n", argv[2]);
+ exit(1);
+ }
+
+ if (sscanf(argv[3], "%x", &value) != 1) {
+ printf("Can't parse register %s\n", argv[3]);
+ exit(1);
+ }
+
+ buf = malloc(size * sizeof(uint32_t));
+ if (!buf) {
+ printf("Can't allocate %lu bytes of memory\n", size * sizeof(uint32_t));
+ exit(1);
+ }
+
+ if (argc == 7) {
+ offset = atoi(argv[4]);
+ toread = atoi(argv[5]);
+ toskip = atoi(argv[6]);
+ }
+
+
+ num = fread(buf, 4, size, f);
+ if (num != size) {
+ printf("Only %lu of %lu dwords in the file\n", num, size);
+ exit(1);
+ }
+ fclose(f);
+
+ for (i = offset; i < size; i += toskip) {
+ for (j = 0; j < toread; j++, i++) {
+ total++;
+ if (buf[i] != value) {
+ count++;
+ }
+ }
+ }
+ free(buf);
+
+ printf("%lu of %lu is wrong\n", count, total);
+ return 0;
+}
diff --git a/apps/heb_strip_bad_values.c b/apps/heb_strip_bad_values.c
new file mode 100644
index 0000000..e04a53c
--- /dev/null
+++ b/apps/heb_strip_bad_values.c
@@ -0,0 +1,98 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+int main(int argc, char *argv[]) {
+ long i, num;
+ size_t count = 0, total = 0, size;
+ int offset = 3, toread = 1, toskip = 3;
+ uint32_t value;
+ uint32_t *buf;
+ uint32_t expected = 0;
+ uint32_t blocks = 0, status_good = 0;
+
+ char fixed[4096];
+ struct stat st_buf;
+
+ if ((argc != 2)&&(argc != 5)) {
+ printf("Usage: %s <file> [offset_dwords read_dwords skip_dwords] \n", argv[0]);
+ exit(0);
+ }
+
+ FILE *f = fopen(argv[1], "r");
+ if (!f) {
+ printf("Can't open %s\n", argv[1]);
+ exit(1);
+ }
+
+ stat(argv[1], &st_buf);
+ size = st_buf.st_size / sizeof(uint32_t);
+
+
+ buf = malloc(size * sizeof(uint32_t));
+ if (!buf) {
+ printf("Can't allocate %lu bytes of memory\n", size * sizeof(uint32_t));
+ exit(1);
+ }
+
+ if (argc == 5) {
+ offset = atoi(argv[2]);
+ toread = atoi(argv[3]);
+ toskip = atoi(argv[4]);
+ }
+
+
+ num = fread(buf, 4, size, f);
+ if (num != size) {
+ printf("Failed to read %lu dwords, only %lu read\n", size, num);
+ exit(1);
+ }
+ fclose(f);
+
+ sprintf(fixed, "%s.fixed", argv[1]);
+ f = fopen(fixed, "w");
+ if (!f) {
+ printf("Failed to open %s for output\n", fixed);
+ exit(1);
+ }
+
+ expected = (buf[offset]>>24) + 2;
+ for (i = 1; i < size; i += (toread + toskip)) {
+ total++;
+
+ value = buf[i + offset] >> 24;
+// printf("0x%lx: value (%lx) = expected (%lx)\n", i + offset, value, expected);
+ if (value == expected) {
+ if (!status_good) {
+ status_good = 1;
+ blocks++;
+ }
+ fwrite(&buf[i], 4, toread + toskip, f);
+ expected += 2;
+ if (expected == 0xb8)
+ expected = 0;
+ } else if ((!status_good)&&(value == 0)&&((i + toread + toskip)< size)) {
+ value = buf[i + offset + toread + toskip] >> 24;
+ if (value == 2) {
+ status_good = 1;
+ blocks++;
+ fwrite(&buf[i], 4, toread + toskip, f);
+ expected = 2;
+ } else {
+ count++;
+ }
+ } else {
+ printf("0x%lx: value (%x) = expected (%x)\n", (i + offset)*sizeof(uint32_t), value, expected);
+ status_good = 0;
+ count++;
+ }
+ }
+ fclose(f);
+ free(buf);
+
+ printf("%lu of %lu is wrong\n", count, total);
+ return 0;
+}
diff --git a/apps/load.sh b/apps/load.sh
deleted file mode 100755
index 6456c63..0000000
--- a/apps/load.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-#! /bin/bash
-
-echo "10ee 6028" > /sys/bus/pci/drivers/pciDriver/new_id
diff --git a/apps/pio_test.c b/apps/pio_test.c
new file mode 100644
index 0000000..84439ee
--- /dev/null
+++ b/apps/pio_test.c
@@ -0,0 +1,96 @@
+#define _BSD_SOURCE
+#define _POSIX_C_SOURCE 199309L
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdarg.h>
+#include <time.h>
+#include <sched.h>
+#include <sys/time.h>
+
+#include "pcilib.h"
+#include "irq.h"
+#include "kmem.h"
+
+#define DEVICE "/dev/fpga0"
+//#define REALTIME
+
+#define BAR PCILIB_BAR0
+#define BITS 32
+#define MASK ((1ll << BITS) - 1)
+
+
+#define WR(addr, value) { *(uint32_t*)(bar + addr) = value; }
+#define RD(addr, value) { value = *(uint32_t*)(bar + addr); }
+
+unsigned long long bits[BITS];
+
+int main(int argc, char *argv[]) {
+ uint32_t i, j;
+ pcilib_t *pci;
+ uint32_t reg, value, diff, errors;
+ void* volatile bar;
+
+ unsigned long long attempts = 0, failures = 0;
+
+ if (argc < 2) {
+ printf("Usage: %s <register>\n", argv[0]);
+ exit(0);
+ }
+
+ if (sscanf(argv[1], "%x", &reg) != 1) {
+ printf("Can't parse register %s\n", argv[1]);
+ exit(1);
+ }
+
+#ifdef REALTIME
+ pid_t pid;
+ struct sched_param sched = {0};
+
+ pid = getpid();
+ sched.sched_priority = sched_get_priority_min(SCHED_FIFO);
+ if (sched_setscheduler(pid, SCHED_FIFO, &sched))
+ printf("Warning: not able to get real-time priority\n");
+#endif /* REALTIME */
+
+ pci = pcilib_open(DEVICE, PCILIB_MODEL_DETECT);
+ if (!pci) {
+ printf("pcilib_open\n");
+ exit(1);
+ }
+
+ bar = pcilib_map_bar(pci, BAR);
+ if (!bar) {
+ pcilib_close(pci);
+ printf("map bar\n");
+ exit(1);
+ }
+
+ for (i = 0; 1; i++) {
+ WR(reg, (i%MASK));
+ RD(reg, value);
+
+ attempts++;
+ if (value != (i%MASK)) {
+ failures++;
+
+ diff = value ^ (i%MASK);
+ for (errors = 0, j = 0; j < BITS; j++)
+ if (diff&(1<<j)) errors++;
+ bits[errors]++;
+
+ //printf("written: %x, read: %x\n", i, value);
+ }
+
+ if ((i % 1048576 ) == 0) {
+ printf("Attempts %llu, failures %llu (", attempts, failures);
+ for (j = 1; j < BITS; j++)
+ printf("%llu ", bits[j]);
+ printf(")\n");
+ }
+
+ }
+
+ pcilib_unmap_bar(pci, BAR, bar);
+ pcilib_close(pci);
+}
diff --git a/apps/xilinx.c b/apps/xilinx.c
index 1ec31d7..757c388 100644
--- a/apps/xilinx.c
+++ b/apps/xilinx.c
@@ -2,6 +2,7 @@
#define _POSIX_C_SOURCE 199309L
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <unistd.h>
#include <stdarg.h>
#include <time.h>
@@ -15,23 +16,27 @@
#define DEVICE "/dev/fpga0"
#define BAR PCILIB_BAR0
#define USE PCILIB_KMEM_USE(PCILIB_KMEM_USE_USER, 1)
-#define BUFFERS 16
-#define ITERATIONS 16384
+#define STATIC_REGION 0x80000000 // to reserve 512 MB at the specified address, add "memmap=512M$2G" to kernel parameters
+#define BUFFERS 1
+#define ITERATIONS 100
+#define TLP_SIZE 64
+#define HUGE_PAGE 4096 // number of pages per huge page
#define PAGE_SIZE 4096 // other values are not supported in the kernel
#define TIMEOUT 100000
/* IRQs are slow for some reason. REALTIME mode is slower. Adding delays does not really help,
otherall we have only 3 checks in average. Check ready seems to be not needed and adds quite
much extra time */
-//#define USE_IRQ
+#define USE_IRQ
//#define CHECK_READY
//#define REALTIME
//#define ADD_DELAYS
+#define CHECK_RESULT
//#define WR(addr, value) { val = value; pcilib_write(pci, BAR, addr, sizeof(val), &val); }
//#define RD(addr, value) { pcilib_read(pci, BAR, addr, sizeof(val), &val); value = val; }
-#define WR(addr, value) { *(uint32_t*)(bar + addr) = value; }
-#define RD(addr, value) { value = *(uint32_t*)(bar + addr); }
+#define WR(addr, value) { *(uint32_t*)(bar + addr + offset) = value; }
+#define RD(addr, value) { value = *(uint32_t*)(bar + addr + offset); }
static void fail(const char *msg, ...) {
va_list va;
@@ -63,7 +68,7 @@ void hpsleep(size_t ns) {
int main() {
int err;
- int i, j;
+ long i, j;
pcilib_t *pci;
pcilib_kmem_handle_t *kbuf;
uint32_t status;
@@ -72,12 +77,15 @@ int main() {
void* volatile bar;
uintptr_t bus_addr[BUFFERS];
+ pcilib_bar_t bar_tmp = BAR;
+ uintptr_t offset = 0;
+
pcilib_kmem_flags_t clean_flags = PCILIB_KMEM_FLAG_HARDWARE|PCILIB_KMEM_FLAG_PERSISTENT|PCILIB_KMEM_FLAG_EXCLUSIVE;
#ifdef ADD_DELAYS
long rpt = 0, rpt2 = 0;
size_t best_time;
- best_time = 1000000000L * PAGE_SIZE / (4L * 1024 * 1024 * 1024);
+ best_time = 1000000000L * HUGE_PAGE * PAGE_SIZE / (4L * 1024 * 1024 * 1024);
#endif /* ADD_DELAYS */
#ifdef REALTIME
@@ -99,22 +107,46 @@ int main() {
fail("map bar");
}
+ pcilib_detect_address(pci, &bar_tmp, &offset, 1);
+
+ // Reset
+ WR(0x00, 1)
+ usleep(1000);
+ WR(0x00, 0)
+
pcilib_enable_irq(pci, PCILIB_IRQ_TYPE_ALL, 0);
pcilib_clear_irq(pci, PCILIB_IRQ_SOURCE_DEFAULT);
pcilib_clean_kernel_memory(pci, USE, clean_flags);
+#ifdef STATIC_REGION
+ kbuf = pcilib_alloc_kernel_memory(pci, PCILIB_KMEM_TYPE_REGION_C2S, BUFFERS, HUGE_PAGE * PAGE_SIZE, STATIC_REGION, USE, 0);
+#else /* STATIC_REGION */
+ kbuf = pcilib_alloc_kernel_memory(pci, PCILIB_KMEM_TYPE_DMA_C2S_PAGE, BUFFERS, HUGE_PAGE * PAGE_SIZE, 4096, USE, 0);
+#endif /* STATIC_REGION */
- kbuf = pcilib_alloc_kernel_memory(pci, PCILIB_KMEM_TYPE_DMA_C2S_PAGE, BUFFERS, PAGE_SIZE, 4096, USE, 0);
+ if (!kbuf) {
+ printf("KMem allocation failed\n");
+ exit(0);
+ }
+
+
+#ifdef CHECK_RESULT
+ volatile uint32_t *ptr0 = pcilib_kmem_get_block_ua(pci, kbuf, 0);
+ memset((void*)ptr0, 0, (HUGE_PAGE * PAGE_SIZE));
- WR(0x00, 1)
- usleep(1000);
- WR(0x00, 0)
+ for (i = 0; i < (HUGE_PAGE * PAGE_SIZE / 4); i++) {
+ if (ptr0[i] != 0) break;
+ }
+ if (i < (HUGE_PAGE * PAGE_SIZE / 4)) {
+ printf("Initialization error in position %lu, value = %x\n", i * 4, ptr0[i]);
+ }
+#endif /* CHECK_RESULT */
+
WR(0x04, 0)
-
- WR(0x0C, 0x20)
- WR(0x10, (PAGE_SIZE / 0x80))
+ WR(0x0C, TLP_SIZE)
+ WR(0x10, (HUGE_PAGE * (PAGE_SIZE / (4 * TLP_SIZE))))
WR(0x14, 0x13131313)
for (j = 0; j < BUFFERS; j++ ) {
@@ -163,17 +195,31 @@ int main() {
}
gettimeofday(&end, NULL);
+#ifdef CHECK_RESULT
+ pcilib_kmem_sync_block(pci, kbuf, PCILIB_KMEM_SYNC_FROMDEVICE, 0);
+
+ for (i = 0; i < (HUGE_PAGE * PAGE_SIZE / 4); i++) {
+// printf("%lx ", ptr0[i]);
+ if (ptr0[i] != 0x13131313) break;
+ }
+ if (i < (HUGE_PAGE * PAGE_SIZE / 4)) {
+ printf("Error in position %lu, value = %x\n", i * 4, ptr0[i]);
+ }
+#endif /* CHECK_RESULT */
+
pcilib_free_kernel_memory(pci, kbuf, 0);
pcilib_disable_irq(pci, 0);
pcilib_unmap_bar(pci, BAR, bar);
pcilib_close(pci);
run_time = (end.tv_sec - start.tv_sec) * 1000000 + (end.tv_usec - start.tv_usec);
- size = (long long int)ITERATIONS * BUFFERS * PAGE_SIZE;
+ size = (long long int)ITERATIONS * BUFFERS * HUGE_PAGE * PAGE_SIZE;
printf("%.3lf GB/s: transfered %zu bytes in %zu us using %u buffers\n", 1000000. * size / run_time / 1024 / 1024 / 1024, size, run_time, BUFFERS);
# ifdef ADD_DELAYS
printf("Repeats: %lf, %lf\n",1. * rpt / (ITERATIONS * BUFFERS), 1. * rpt2 / (ITERATIONS * BUFFERS));
#endif /* USE_IRQ */
+
+
}
diff --git a/apps/xilinx2.c b/apps/xilinx2.c
deleted file mode 100644
index 757c388..0000000
--- a/apps/xilinx2.c
+++ /dev/null
@@ -1,225 +0,0 @@
-#define _BSD_SOURCE
-#define _POSIX_C_SOURCE 199309L
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <stdarg.h>
-#include <time.h>
-#include <sched.h>
-#include <sys/time.h>
-
-#include "pcilib.h"
-#include "irq.h"
-#include "kmem.h"
-
-#define DEVICE "/dev/fpga0"
-#define BAR PCILIB_BAR0
-#define USE PCILIB_KMEM_USE(PCILIB_KMEM_USE_USER, 1)
-#define STATIC_REGION 0x80000000 // to reserve 512 MB at the specified address, add "memmap=512M$2G" to kernel parameters
-#define BUFFERS 1
-#define ITERATIONS 100
-#define TLP_SIZE 64
-#define HUGE_PAGE 4096 // number of pages per huge page
-#define PAGE_SIZE 4096 // other values are not supported in the kernel
-#define TIMEOUT 100000
-
-/* IRQs are slow for some reason. REALTIME mode is slower. Adding delays does not really help,
-otherall we have only 3 checks in average. Check ready seems to be not needed and adds quite
-much extra time */
-#define USE_IRQ
-//#define CHECK_READY
-//#define REALTIME
-//#define ADD_DELAYS
-#define CHECK_RESULT
-
-//#define WR(addr, value) { val = value; pcilib_write(pci, BAR, addr, sizeof(val), &val); }
-//#define RD(addr, value) { pcilib_read(pci, BAR, addr, sizeof(val), &val); value = val; }
-#define WR(addr, value) { *(uint32_t*)(bar + addr + offset) = value; }
-#define RD(addr, value) { value = *(uint32_t*)(bar + addr + offset); }
-
-static void fail(const char *msg, ...) {
- va_list va;
-
- va_start(va, msg);
- vprintf(msg, va);
- va_end(va);
- printf("\n");
-
- exit(-1);
-}
-
-void hpsleep(size_t ns) {
- struct timespec wait, tv;
-
- clock_gettime(CLOCK_REALTIME, &wait);
-
- wait.tv_nsec += ns;
- if (wait.tv_nsec > 999999999) {
- wait.tv_sec += 1;
- wait.tv_nsec = 1000000000 - wait.tv_nsec;
- }
-
- do {
- clock_gettime(CLOCK_REALTIME, &tv);
- } while ((wait.tv_sec > tv.tv_sec)||((wait.tv_sec == tv.tv_sec)&&(wait.tv_nsec > tv.tv_nsec)));
-}
-
-
-int main() {
- int err;
- long i, j;
- pcilib_t *pci;
- pcilib_kmem_handle_t *kbuf;
- uint32_t status;
- struct timeval start, end;
- size_t size, run_time;
- void* volatile bar;
- uintptr_t bus_addr[BUFFERS];
-
- pcilib_bar_t bar_tmp = BAR;
- uintptr_t offset = 0;
-
- pcilib_kmem_flags_t clean_flags = PCILIB_KMEM_FLAG_HARDWARE|PCILIB_KMEM_FLAG_PERSISTENT|PCILIB_KMEM_FLAG_EXCLUSIVE;
-
-#ifdef ADD_DELAYS
- long rpt = 0, rpt2 = 0;
- size_t best_time;
- best_time = 1000000000L * HUGE_PAGE * PAGE_SIZE / (4L * 1024 * 1024 * 1024);
-#endif /* ADD_DELAYS */
-
-#ifdef REALTIME
- pid_t pid;
- struct sched_param sched = {0};
-
- pid = getpid();
- sched.sched_priority = sched_get_priority_min(SCHED_FIFO);
- if (sched_setscheduler(pid, SCHED_FIFO, &sched))
- printf("Warning: not able to get real-time priority\n");
-#endif /* REALTIME */
-
- pci = pcilib_open(DEVICE, PCILIB_MODEL_DETECT);
- if (!pci) fail("pcilib_open");
-
- bar = pcilib_map_bar(pci, BAR);
- if (!bar) {
- pcilib_close(pci);
- fail("map bar");
- }
-
- pcilib_detect_address(pci, &bar_tmp, &offset, 1);
-
- // Reset
- WR(0x00, 1)
- usleep(1000);
- WR(0x00, 0)
-
- pcilib_enable_irq(pci, PCILIB_IRQ_TYPE_ALL, 0);
- pcilib_clear_irq(pci, PCILIB_IRQ_SOURCE_DEFAULT);
-
- pcilib_clean_kernel_memory(pci, USE, clean_flags);
-
-#ifdef STATIC_REGION
- kbuf = pcilib_alloc_kernel_memory(pci, PCILIB_KMEM_TYPE_REGION_C2S, BUFFERS, HUGE_PAGE * PAGE_SIZE, STATIC_REGION, USE, 0);
-#else /* STATIC_REGION */
- kbuf = pcilib_alloc_kernel_memory(pci, PCILIB_KMEM_TYPE_DMA_C2S_PAGE, BUFFERS, HUGE_PAGE * PAGE_SIZE, 4096, USE, 0);
-#endif /* STATIC_REGION */
-
- if (!kbuf) {
- printf("KMem allocation failed\n");
- exit(0);
- }
-
-
-#ifdef CHECK_RESULT
- volatile uint32_t *ptr0 = pcilib_kmem_get_block_ua(pci, kbuf, 0);
-
- memset((void*)ptr0, 0, (HUGE_PAGE * PAGE_SIZE));
-
- for (i = 0; i < (HUGE_PAGE * PAGE_SIZE / 4); i++) {
- if (ptr0[i] != 0) break;
- }
- if (i < (HUGE_PAGE * PAGE_SIZE / 4)) {
- printf("Initialization error in position %lu, value = %x\n", i * 4, ptr0[i]);
- }
-#endif /* CHECK_RESULT */
-
- WR(0x04, 0)
- WR(0x0C, TLP_SIZE)
- WR(0x10, (HUGE_PAGE * (PAGE_SIZE / (4 * TLP_SIZE))))
- WR(0x14, 0x13131313)
-
- for (j = 0; j < BUFFERS; j++ ) {
- bus_addr[j] = pcilib_kmem_get_block_ba(pci, kbuf, j);
- }
-
- gettimeofday(&start, NULL);
-
- for (i = 0; i < ITERATIONS; i++) {
- for (j = 0; j < BUFFERS; j++ ) {
-// uintptr_t ba = pcilib_kmem_get_block_ba(pci, kbuf, j);
-// WR(0x08, ba)
- WR(0x08, bus_addr[j]);
- WR(0x04, 0x01)
-
-#ifdef USE_IRQ
- err = pcilib_wait_irq(pci, PCILIB_IRQ_SOURCE_DEFAULT, TIMEOUT, NULL);
- if (err) printf("Timeout waiting for IRQ, err: %i\n", err);
-
- RD(0x04, status);
- if ((status&0xFFFF) != 0x101) printf("Invalid status %x\n", status);
-// WR(0x04, 0x00);
-#else /* USE_IRQ */
-# ifdef ADD_DELAYS
-// hpsleep(best_time);
- do {
- rpt++;
- RD(0x04, status);
- } while (status != 0x101);
-# else /* ADD_DELAYS */
- do {
- RD(0x04, status);
- } while (status != 0x101);
-# endif /* ADD_DELAYS */
-#endif /* USE_IRQ */
-
- WR(0x00, 1)
-#ifdef CHECK_READY
- do {
- rpt2++;
- RD(0x04, status);
- } while (status != 0);
-#endif /* CHECK_READY */
- WR(0x00, 0)
- }
- }
- gettimeofday(&end, NULL);
-
-#ifdef CHECK_RESULT
- pcilib_kmem_sync_block(pci, kbuf, PCILIB_KMEM_SYNC_FROMDEVICE, 0);
-
- for (i = 0; i < (HUGE_PAGE * PAGE_SIZE / 4); i++) {
-// printf("%lx ", ptr0[i]);
- if (ptr0[i] != 0x13131313) break;
- }
- if (i < (HUGE_PAGE * PAGE_SIZE / 4)) {
- printf("Error in position %lu, value = %x\n", i * 4, ptr0[i]);
- }
-#endif /* CHECK_RESULT */
-
- pcilib_free_kernel_memory(pci, kbuf, 0);
- pcilib_disable_irq(pci, 0);
- pcilib_unmap_bar(pci, BAR, bar);
- pcilib_close(pci);
-
- run_time = (end.tv_sec - start.tv_sec) * 1000000 + (end.tv_usec - start.tv_usec);
- size = (long long int)ITERATIONS * BUFFERS * HUGE_PAGE * PAGE_SIZE;
-
- printf("%.3lf GB/s: transfered %zu bytes in %zu us using %u buffers\n", 1000000. * size / run_time / 1024 / 1024 / 1024, size, run_time, BUFFERS);
-
-# ifdef ADD_DELAYS
- printf("Repeats: %lf, %lf\n",1. * rpt / (ITERATIONS * BUFFERS), 1. * rpt2 / (ITERATIONS * BUFFERS));
-#endif /* USE_IRQ */
-
-
-}
diff --git a/driver/compat.h b/driver/compat.h
index 80f232b..25e402a 100644
--- a/driver/compat.h
+++ b/driver/compat.h
@@ -10,6 +10,12 @@
#ifndef _COMPAT_H
#define _COMPAT_H
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
+# define __devinit
+# define __devexit
+# define __devinitdata
+#endif
+
/* dev_name is the wrapper one needs to use to access what was formerly called
* bus_id in struct device. However, before 2.6.27, direct access was necessary,
* so we provide our own version. */
diff --git a/driver/kmem.c b/driver/kmem.c
index b8ce0d0..4f36e79 100644
--- a/driver/kmem.c
+++ b/driver/kmem.c
@@ -24,6 +24,11 @@
#include "kmem.h" /* prototypes for kernel memory */
#include "sysfs.h" /* prototypes for sysfs */
+/* VM_RESERVED is removed in 3.7-rc1 */
+#ifndef VM_RESERVED
+# define VM_RESERVED (VM_DONTEXPAND | VM_DONTDUMP)
+#endif
+
/**
*
* Allocates new kernel memory including the corresponding management structure, makes
@@ -32,6 +37,7 @@
*/
int pcidriver_kmem_alloc(pcidriver_privdata_t *privdata, kmem_handle_t *kmem_handle)
{
+ int flags;
pcidriver_kmem_entry_t *kmem_entry;
void *retptr;
@@ -139,12 +145,17 @@ int pcidriver_kmem_alloc(pcidriver_privdata_t *privdata, kmem_handle_t *kmem_han
}
break;
case PCILIB_KMEM_TYPE_PAGE:
+ flags = GFP_KERNEL;
+
+ if ((kmem_entry->type == PCILIB_KMEM_TYPE_DMA_S2C_PAGE)||(kmem_entry->type == PCILIB_KMEM_TYPE_DMA_C2S_PAGE))
+ flags |= __GFP_DMA;
+
if (kmem_handle->size == 0)
kmem_handle->size = PAGE_SIZE;
else if (kmem_handle->size%PAGE_SIZE)
goto kmem_alloc_mem_fail;
- retptr = (void*)__get_free_pages(GFP_KERNEL|__GFP_DMA, get_order(kmem_handle->size));
+ retptr = (void*)__get_free_pages(flags, get_order(kmem_handle->size));
kmem_entry->dma_handle = 0;
if (retptr) {
@@ -621,10 +632,6 @@ int pcidriver_mmap_kmem(pcidriver_privdata_t *privdata, struct vm_area_struct *v
page_to_pfn(virt_to_page((void*)kmem_entry->cpua)));
if ((kmem_entry->type&PCILIB_KMEM_TYPE_MASK) == PCILIB_KMEM_TYPE_REGION) {
- mod_info("Mapping address %08lx / Size %08lx\n",
- (unsigned long)kmem_entry->dma_handle,
- (vma_size < kmem_entry->size)?vma_size:kmem_entry->size);
-
ret = remap_pfn_range_compat(
vma,
vma->vm_start,
diff --git a/driver/pciDriver.h b/driver/pciDriver.h
index d548765..8e9c0bc 100644
--- a/driver/pciDriver.h
+++ b/driver/pciDriver.h
@@ -61,7 +61,7 @@
/* Identifies the PCI-E Xilinx ML605 */
#define PCIE_XILINX_VENDOR_ID 0x10ee
-#define PCIE_ML605_DEVICE_ID 0x04a0
+#define PCIE_ML605_DEVICE_ID 0x6024
/* Identifies the PCI-E IPE Camera */
#define PCIE_IPECAMERA_DEVICE_ID 0x6081
diff --git a/driver/sysfs.c b/driver/sysfs.c
index 37cf362..04bfdf3 100644
--- a/driver/sysfs.c
+++ b/driver/sysfs.c
@@ -100,13 +100,16 @@ static SYSFS_GET_FUNCTION(pcidriver_show_kmem_entry)
* sanity checks but can directly call simple_strtol() */
int id = simple_strtol(attr->attr.name + strlen("kbuf"), NULL, 10);
pcidriver_kmem_entry_t *entry = pcidriver_kmem_find_entry_id(privdata, id);
- if (entry)
+ if (entry) {
+ unsigned long addr = entry->cpua;
+ unsigned long dma_addr = entry->dma_handle;
+
if (entry->size >= 16) {
pcidriver_kmem_sync_entry(privdata, entry, PCILIB_KMEM_SYNC_FROMDEVICE);
- return snprintf(buf, PAGE_SIZE, "buffer: %d\ntype: %lx\nuse: 0x%lx\nitem: %lu\nsize: %lu\nrefs: %lu\nhw ref: %i\nmode: 0x%lx\ndata: %8x %8x %8x %8x\n", id, entry->type, entry->use, entry->item, entry->size, entry->refs&KMEM_REF_COUNT, (entry->refs&KMEM_REF_HW)?1:0, entry->mode, *(u32*)(entry->cpua), *(u32*)(entry->cpua + 4), *(u32*)(entry->cpua + 8), *(u32*)(entry->cpua + 12));
+ return snprintf(buf, PAGE_SIZE, "buffer: %d\naddr: %lx\nhw addr: %lx\nbus addr: %lx\ntype: %lx\nuse: 0x%lx\nitem: %lu\nsize: %lu\nrefs: %lu\nhw ref: %i\nmode: 0x%lx\ndata: %8x %8x %8x %8x\n", id, addr, virt_to_phys(addr), dma_addr, entry->type, entry->use, entry->item, entry->size, entry->refs&KMEM_REF_COUNT, (entry->refs&KMEM_REF_HW)?1:0, entry->mode, *(u32*)(entry->cpua), *(u32*)(entry->cpua + 4), *(u32*)(entry->cpua + 8), *(u32*)(entry->cpua + 12));
} else
- return snprintf(buf, PAGE_SIZE, "buffer: %d\ntype: %lx\nuse: 0x%lx\nitem: %lu\nsize: %lu\nrefs: %lu\nhw ref: %i\nmode: 0x%lx\n", id, entry->type, entry->use, entry->item, entry->size, entry->refs&KMEM_REF_COUNT, (entry->refs&KMEM_REF_HW)?1:0, entry->mode);
- else
+ return snprintf(buf, PAGE_SIZE, "buffer: %d\naddr: %lx\nhw addr: %lx\nbus addr: %lx\ntype: %lx\nuse: 0x%lx\nitem: %lu\nsize: %lu\nrefs: %lu\nhw ref: %i\nmode: 0x%lx\n", id, addr, virt_to_phys(addr), dma_addr, entry->type, entry->use, entry->item, entry->size, entry->refs&KMEM_REF_COUNT, (entry->refs&KMEM_REF_HW)?1:0, entry->mode);
+ } else
return snprintf(buf, PAGE_SIZE, "I am in the kmem_entry show function for buffer %d\n", id);
#else
return 0;
diff --git a/ipecamera/events.c b/ipecamera/events.c
index 58c29a1..3253fc5 100644
--- a/ipecamera/events.c
+++ b/ipecamera/events.c
@@ -139,7 +139,7 @@ int ipecamera_next_event(pcilib_context_t *vctx, pcilib_timeout_t timeout, pcili
}
retry:
- if ((ctx->event_id - ctx->reported_id) > (ctx->buffer_size - IPECAMERA_RESERVE_BUFFERS)) ctx->reported_id = ctx->event_id - (ctx->buffer_size - 1) - IPECAMERA_RESERVE_BUFFERS;
+ if ((ctx->event_id - ctx->reported_id) > (ctx->buffer_size - IPECAMERA_RESERVE_BUFFERS)) ctx->reported_id = ctx->event_id - (ctx->buffer_size - 1 - IPECAMERA_RESERVE_BUFFERS);
else ++ctx->reported_id;
if (evid) *evid = ctx->reported_id;
@@ -152,9 +152,9 @@ retry:
else
return PCILIB_ERROR_INVALID_ARGUMENT;
}
-
+
if ((ctx->event_id - ctx->reported_id) >= ctx->buffer_size) goto retry;
-
+
return 0;
}
diff --git a/ipecamera/ipecamera.c b/ipecamera/ipecamera.c
index b4bbeb8..1681f7c 100644
--- a/ipecamera/ipecamera.c
+++ b/ipecamera/ipecamera.c
@@ -124,7 +124,7 @@ pcilib_context_t *ipecamera_init(pcilib_t *pcilib) {
break;
default:
// pcilib_error("Unsupported version of firmware (%lu)", value);
- ;
+ ctx->firmware = 0;
}
#ifdef IPECAMERA_BUG_POSTPONED_READ
@@ -156,7 +156,9 @@ void ipecamera_free(pcilib_context_t *vctx) {
}
pcilib_dma_context_t *ipecamera_init_dma(pcilib_context_t *vctx) {
-// ipecamera_t *ctx = (ipecamera_t*)vctx;
+#ifdef IPECAMERA_DMA_R3
+ ipecamera_t *ctx = (ipecamera_t*)vctx;
+#endif
pcilib_model_description_t *model_info = pcilib_get_model_description(vctx->pcilib);
if ((!model_info->dma_api)||(!model_info->dma_api->init)) {
@@ -166,7 +168,11 @@ pcilib_dma_context_t *ipecamera_init_dma(pcilib_context_t *vctx) {
#ifdef IPECAMERA_DMA_R3
- return model_info->dma_api->init(vctx->pcilib, PCILIB_NWL_MODIFICATION_IPECAMERA, NULL);
+ if (ctx->firmware) {
+ return model_info->dma_api->init(vctx->pcilib, PCILIB_NWL_MODIFICATION_IPECAMERA, NULL);
+ } else {
+ return model_info->dma_api->init(vctx->pcilib, PCILIB_DMA_MODIFICATION_DEFAULT, NULL);
+ }
#else
return model_info->dma_api->init(vctx->pcilib, PCILIB_DMA_MODIFICATION_DEFAULT, NULL);
#endif
@@ -205,6 +211,11 @@ int ipecamera_reset(pcilib_context_t *vctx) {
pcilib_error("IPECamera imaging is not initialized");
return PCILIB_ERROR_NOTINITIALIZED;
}
+
+ if (!ctx->firmware) {
+ pcilib_warning("Unsupported version of firmware (%lu)", ctx->firmware);
+ return 0;
+ }
pcilib = vctx->pcilib;
control = ctx->control_reg;
@@ -279,6 +290,11 @@ int ipecamera_start(pcilib_context_t *vctx, pcilib_event_t event_mask, pcilib_ev
pcilib_error("IPECamera imaging is not initialized");
return PCILIB_ERROR_NOTINITIALIZED;
}
+
+ if (!ctx->firmware) {
+ pcilib_error("Unsupported version of firmware (%lu)", ctx->firmware);
+ return PCILIB_ERROR_INVALID_REQUEST;
+ }
if (ctx->started) {
pcilib_error("IPECamera grabbing is already started");
@@ -286,10 +302,15 @@ int ipecamera_start(pcilib_context_t *vctx, pcilib_event_t event_mask, pcilib_ev
}
// Allow readout and clean the FRAME_REQUEST mode if set for some reason
- SET_REG(control_reg, IPECAMERA_IDLE|IPECAMERA_READOUT_FLAG);
+ GET_REG(control_reg, value);
+ SET_REG(control_reg, value|IPECAMERA_READOUT_FLAG);
usleep(IPECAMERA_SLEEP_TIME);
- CHECK_STATUS_REG();
- if (err) return err;
+ if (value&0x1000) ctx->fr_mode = 1;
+ else {
+ ctx->fr_mode = 0;
+ CHECK_STATUS_REG();
+ if (err) return err;
+ }
ctx->event_id = 0;
ctx->preproc_id = 0;
@@ -447,7 +468,7 @@ int ipecamera_start(pcilib_context_t *vctx, pcilib_event_t event_mask, pcilib_ev
// it would be greate to detect hyperthreading cores and ban them
switch (ctx->n_preproc) {
case 1: break;
- case 2-3: ctx->n_preproc -= 1; break;
+ case 2 ... 3: ctx->n_preproc -= 1; break;
default: ctx->n_preproc -= 2; break;
}
@@ -576,7 +597,11 @@ int ipecamera_stop(pcilib_context_t *vctx, pcilib_event_flags_t flags) {
pcilib_stop_dma(vctx->pcilib, ctx->rdma, PCILIB_DMA_FLAGS_DEFAULT);
ctx->rdma = PCILIB_DMA_ENGINE_INVALID;
}
-
+
+ while (ctx->streaming) {
+ usleep(IPECAMERA_NOFRAME_SLEEP);
+ }
+
if (ctx->ipedec) {
ufo_decoder_free(ctx->ipedec);
ctx->ipedec = NULL;
@@ -625,7 +650,12 @@ int ipecamera_trigger(pcilib_context_t *vctx, pcilib_event_t event, size_t trigg
pcilib_error("IPECamera imaging is not initialized");
return PCILIB_ERROR_NOTINITIALIZED;
}
-
+
+ if (!ctx->firmware) {
+ pcilib_error("Unsupported version of firmware (%lu)", ctx->firmware);
+ return PCILIB_ERROR_INVALID_REQUEST;
+ }
+
pcilib_sleep_until_deadline(&ctx->next_trigger);
GET_REG(num_frames_reg, value);
@@ -638,11 +668,12 @@ int ipecamera_trigger(pcilib_context_t *vctx, pcilib_event_t event, size_t trigg
GET_REG(status3_reg, value);
} while (value&0x20000000);
*/
-
- SET_REG(control_reg, IPECAMERA_FRAME_REQUEST|IPECAMERA_READOUT_FLAG);
+
+ GET_REG(control_reg, value);
+ SET_REG(control_reg, value|IPECAMERA_FRAME_REQUEST);
usleep(IPECAMERA_WAIT_FRAME_RCVD_TIME);
//CHECK_REG(status_reg, IPECAMERA_EXPECTED_STATUS);
- SET_REG(control_reg, IPECAMERA_IDLE|IPECAMERA_READOUT_FLAG);
+ SET_REG(control_reg, value);
pcilib_calc_deadline(&ctx->next_trigger, IPECAMERA_NEXT_FRAME_DELAY);
diff --git a/ipecamera/model.h b/ipecamera/model.h
index 37f9096..26505ee 100644
--- a/ipecamera/model.h
+++ b/ipecamera/model.h
@@ -8,7 +8,7 @@
//#define IPECAMERA_DEBUG
-//#define IPECAMERA_DMA_R3
+#define IPECAMERA_DMA_R3
#define IPECAMERA_DMA_ADDRESS 1
#define IPECAMERA_DMA_PACKET_LENGTH 4096
@@ -26,97 +26,102 @@ pcilib_register_bank_description_t ipecamera_register_banks[] = {
};
pcilib_register_description_t ipecamera_registers[] = {
-{1, 0, 16, 1088, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_number_lines", ""},
-{3, 0, 16, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_start1", ""},
-{5, 0, 16, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_start2", ""},
-{7, 0, 16, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_start3", ""},
-{9, 0, 16, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_start4", ""},
-{11, 0, 16, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_start5", ""},
-{13, 0, 16, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_start6", ""},
-{15, 0, 16, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_start7", ""},
-{17, 0, 16, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_start8", ""},
-{19, 0, 16, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_number_lines1", ""},
-{21, 0, 16, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_number_lines2", ""},
-{23, 0, 16, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_number_lines3", ""},
-{25, 0, 16, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_number_lines4", ""},
-{27, 0, 16, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_number_lines5", ""},
-{29, 0, 16, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_number_lines6", ""},
-{31, 0, 16, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_number_lines7", ""},
-{33, 0, 16, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_number_lines8", ""},
-{35, 0, 16, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_sub_s", ""},
-{37, 0, 16, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_sub_a", ""},
-{39, 0, 1, 1, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_color", ""},
-{40, 0, 2, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_image_flipping", ""},
-{41, 0, 2, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_exp_flags", ""},
-{42, 0, 24, 1088, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_exp_time", ""},
-{45, 0, 24, 1088, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_exp_step", ""},
-{48, 0, 24, 1, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_exp_kp1", ""},
-{51, 0, 24, 1, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_exp_kp2", ""},
-{54, 0, 2, 1, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_nr_slopes", ""},
-{55, 0, 8, 1, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_exp_seq", ""},
-{56, 0, 24, 1088, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_exp_time2", ""},
-{59, 0, 24, 1088, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_exp_step2", ""},
-{68, 0, 2, 1, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_nr_slopes2", ""},
-{69, 0, 8, 1, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_exp_seq2", ""},
-{70, 0, 16, 1, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_number_frames", ""},
-{72, 0, 2, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_output_mode", ""},
-{78, 0, 12, 85, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_training_pattern", ""},
-{80, 0, 18, 0x3FFFF,0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_channel_en", ""},
-{82, 0, 3, 7, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_special_82", ""},
-{89, 0, 8, 96, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_vlow2", ""},
-{90, 0, 8, 96, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_vlow3", ""},
-{100, 0, 14, 16260, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_offset", ""},
-{102, 0, 2, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_pga", ""},
-{103, 0, 8, 32, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_adc_gain", ""},
-{111, 0, 1, 1, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_bit_mode", ""},
-{112, 0, 2, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_adc_resolution", ""},
-{115, 0, 1, 1, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_special_115", ""},
-/*{126, 0, 16, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "temp", ""},*/
-{0x00, 0, 32, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "spi_conf_input", ""},
-{0x10, 0, 32, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "spi_conf_output", ""},
-{0x20, 0, 32, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "spi_clk_speed", ""},
-{0x30, 0, 32, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "firmware_info", ""},
-{0x30, 0, 8, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_BITS, PCILIB_REGISTER_BANK1, "firmware_version", ""},
-{0x30, 8, 1, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_BITS, PCILIB_REGISTER_BANK1, "firmware_bitmode", ""},
-{0x30, 12, 2, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_BITS, PCILIB_REGISTER_BANK1, "adc_resolution", ""},
-{0x30, 16, 2, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_BITS, PCILIB_REGISTER_BANK1, "output_mode", ""},
-{0x40, 0, 32, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "control", ""},
-{0x50, 0, 32, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "status", ""},
-{0x54, 0, 32, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "status2", ""},
-{0x58, 0, 32, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "status3", ""},
-{0x5c, 0, 32, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "fr_status", ""},
-{0x70, 0, 32, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "start_address", ""},
-{0x74, 0, 32, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "end_address", ""},
-{0x78, 0, 32, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "rd_address", ""},
-{0xa0, 0, 32, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "fr_param1", ""},
-{0xa0, 0, 11, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_BITS, PCILIB_REGISTER_BANK1, "fr_skip_lines", ""},
-{0xa0, 11, 11, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_BITS, PCILIB_REGISTER_BANK1, "fr_num_lines", ""},
-{0xa0, 22, 10, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_BITS, PCILIB_REGISTER_BANK1, "fr_start_address", ""},
-{0xb0, 0, 32, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "fr_param2", ""},
-{0xa0, 0, 11, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_BITS, PCILIB_REGISTER_BANK1, "fr_threshold_lines", ""},
-{0xc0, 0, 32, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "skiped_lines", ""},
-{0x100, 0, 32, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "rawdata_pkt_addr", ""},
-{0x110, 0, 32, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "temperature_info", ""},
-{0x110, 0, 16, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_BITS, PCILIB_REGISTER_BANK1, "sensor_temperature", ""},
-{0x110, 16, 3, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_BITS, PCILIB_REGISTER_BANK1, "sensor_temperature_alarms", ""},
-{0x110, 19, 10, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_BITS, PCILIB_REGISTER_BANK1, "fpga_temperature", ""},
-{0x110, 29, 3, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_BITS, PCILIB_REGISTER_BANK1, "fpga_temperature_alarms", ""},
-{0x120, 0, 32, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "num_lines", ""},
-{0x130, 0, 32, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "start_line", ""},
-{0x140, 0, 32, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "exp_time", ""},
-{0x150, 0, 32, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "motor", ""},
-{0x150, 0, 5, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_BITS, PCILIB_REGISTER_BANK1, "motor_phi", ""},
-{0x150, 5, 5, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_BITS, PCILIB_REGISTER_BANK1, "motor_z", ""},
-{0x150, 10, 5, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_BITS, PCILIB_REGISTER_BANK1, "motor_y", ""},
-{0x150, 15, 5, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_BITS, PCILIB_REGISTER_BANK1, "motor_x", ""},
-{0x150, 20, 8, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_BITS, PCILIB_REGISTER_BANK1, "adc_gain", ""},
-{0x160, 0, 32, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "write_status", ""},
-{0x170, 0, 32, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "num_triggers", ""},
-{0x180, 0, 32, 0x280, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "trigger_period", ""},
-{0x190, 0, 32, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "temperature_sample_period", ""},
-{0x1a0, 0, 32, 0x64, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "ddr_max_frames", ""},
-{0x1b0, 0, 32, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "ddr_num_frames", ""},
-{0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL}
+{1, 0, 16, 1088, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_number_lines", ""},
+{3, 0, 16, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_start1", ""},
+{5, 0, 16, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_start2", ""},
+{7, 0, 16, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_start3", ""},
+{9, 0, 16, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_start4", ""},
+{11, 0, 16, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_start5", ""},
+{13, 0, 16, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_start6", ""},
+{15, 0, 16, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_start7", ""},
+{17, 0, 16, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_start8", ""},
+{19, 0, 16, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_number_lines1", ""},
+{21, 0, 16, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_number_lines2", ""},
+{23, 0, 16, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_number_lines3", ""},
+{25, 0, 16, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_number_lines4", ""},
+{27, 0, 16, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_number_lines5", ""},
+{29, 0, 16, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_number_lines6", ""},
+{31, 0, 16, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_number_lines7", ""},
+{33, 0, 16, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_number_lines8", ""},
+{35, 0, 16, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_sub_s", ""},
+{37, 0, 16, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_sub_a", ""},
+{39, 0, 1, 1, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_color", ""},
+{40, 0, 2, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_image_flipping", ""},
+{41, 0, 2, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_exp_flags", ""},
+{42, 0, 24, 1088, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_exp_time", ""},
+{45, 0, 24, 1088, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_exp_step", ""},
+{48, 0, 24, 1, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_exp_kp1", ""},
+{51, 0, 24, 1, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_exp_kp2", ""},
+{54, 0, 2, 1, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_nr_slopes", ""},
+{55, 0, 8, 1, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_exp_seq", ""},
+{56, 0, 24, 1088, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_exp_time2", ""},
+{59, 0, 24, 1088, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_exp_step2", ""},
+{68, 0, 2, 1, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_nr_slopes2", ""},
+{69, 0, 8, 1, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_exp_seq2", ""},
+{70, 0, 16, 1, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_number_frames", ""},
+{72, 0, 2, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_output_mode", ""},
+{78, 0, 12, 85, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_training_pattern", ""},
+{80, 0, 18, 0x3FFFF,0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_channel_en", ""},
+{82, 0, 3, 7, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_special_82", ""},
+{89, 0, 8, 96, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_vlow2", ""},
+{90, 0, 8, 96, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_vlow3", ""},
+{100, 0, 14, 16260, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_offset", ""},
+{102, 0, 2, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_pga", ""},
+{103, 0, 8, 32, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_adc_gain", ""},
+{111, 0, 1, 1, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_bit_mode", ""},
+{112, 0, 2, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_adc_resolution", ""},
+{115, 0, 1, 1, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "cmosis_special_115", ""},
+/*{126, 0, 16, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK0, "temp", ""},*/
+{0x00, 0, 32, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "spi_conf_input", ""},
+{0x10, 0, 32, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "spi_conf_output", ""},
+{0x20, 0, 32, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "spi_clk_speed", ""},
+{0x30, 0, 32, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "firmware_info", ""},
+{0x30, 0, 8, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_BITS, PCILIB_REGISTER_BANK1, "firmware_version", ""},
+{0x30, 8, 1, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_BITS, PCILIB_REGISTER_BANK1, "firmware_bitmode", ""},
+{0x30, 12, 2, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_BITS, PCILIB_REGISTER_BANK1, "adc_resolution", ""},
+{0x30, 16, 2, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_BITS, PCILIB_REGISTER_BANK1, "output_mode", ""},
+{0x40, 0, 32, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "control", ""},
+{0x50, 0, 32, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "status", ""},
+{0x54, 0, 32, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "status2", ""},
+{0x58, 0, 32, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "status3", ""},
+{0x5c, 0, 32, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "fr_status", ""},
+{0x70, 0, 32, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "start_address", ""},
+{0x74, 0, 32, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "end_address", ""},
+{0x78, 0, 32, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "rd_address", ""},
+{0xa0, 0, 32, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "fr_param1", ""},
+{0xa0, 0, 10, 0, PCILIB_REGISTER_ALL_BITS, PCILIB_REGISTER_RW, PCILIB_REGISTER_BITS, PCILIB_REGISTER_BANK1, "fr_skip_lines", ""},
+{0xa0, 10, 11, 0, PCILIB_REGISTER_ALL_BITS, PCILIB_REGISTER_RW, PCILIB_REGISTER_BITS, PCILIB_REGISTER_BANK1, "fr_num_lines", ""},
+{0xa0, 21, 11, 0, PCILIB_REGISTER_ALL_BITS, PCILIB_REGISTER_RW, PCILIB_REGISTER_BITS, PCILIB_REGISTER_BANK1, "fr_start_address", ""},
+{0xb0, 0, 32, 0, PCILIB_REGISTER_ALL_BITS, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "fr_param2", ""},
+{0xb0, 0, 11, 0, PCILIB_REGISTER_ALL_BITS, PCILIB_REGISTER_RW, PCILIB_REGISTER_BITS, PCILIB_REGISTER_BANK1, "fr_threshold_start_line", ""},
+{0xb0, 16, 10, 0, PCILIB_REGISTER_ALL_BITS, PCILIB_REGISTER_RW, PCILIB_REGISTER_BITS, PCILIB_REGISTER_BANK1, "fr_area_lines", ""},
+{0xc0, 0, 32, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "skiped_lines", ""},
+{0xd0, 0, 32, 0, PCILIB_REGISTER_ALL_BITS, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "fr_thresholds", ""},
+{0xd0, 0, 10, 0, PCILIB_REGISTER_ALL_BITS, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "fr_pixel_thr", ""},
+{0xd0, 10, 11, 0, PCILIB_REGISTER_ALL_BITS, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "fr_num_pixel_thr", ""},
+{0xd0, 21, 11, 0, PCILIB_REGISTER_ALL_BITS, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "fr_num_lines_thr", ""},
+{0x100, 0, 32, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "rawdata_pkt_addr", ""},
+{0x110, 0, 32, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "temperature_info", ""},
+{0x110, 0, 16, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_BITS, PCILIB_REGISTER_BANK1, "sensor_temperature", ""},
+{0x110, 16, 3, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_BITS, PCILIB_REGISTER_BANK1, "sensor_temperature_alarms", ""},
+{0x110, 19, 10, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_BITS, PCILIB_REGISTER_BANK1, "fpga_temperature", ""},
+{0x110, 29, 3, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_BITS, PCILIB_REGISTER_BANK1, "fpga_temperature_alarms", ""},
+{0x120, 0, 32, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "num_lines", ""},
+{0x130, 0, 32, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "start_line", ""},
+{0x140, 0, 32, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "exp_time", ""},
+{0x150, 0, 32, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "motor", ""},
+{0x150, 0, 5, 0, PCILIB_REGISTER_ALL_BITS, PCILIB_REGISTER_RW, PCILIB_REGISTER_BITS, PCILIB_REGISTER_BANK1, "motor_phi", ""},
+{0x150, 5, 5, 0, PCILIB_REGISTER_ALL_BITS, PCILIB_REGISTER_RW, PCILIB_REGISTER_BITS, PCILIB_REGISTER_BANK1, "motor_z", ""},
+{0x150, 10, 5, 0, PCILIB_REGISTER_ALL_BITS, PCILIB_REGISTER_RW, PCILIB_REGISTER_BITS, PCILIB_REGISTER_BANK1, "motor_y", ""},
+{0x150, 15, 5, 0, PCILIB_REGISTER_ALL_BITS, PCILIB_REGISTER_RW, PCILIB_REGISTER_BITS, PCILIB_REGISTER_BANK1, "motor_x", ""},
+{0x150, 20, 8, 0, PCILIB_REGISTER_ALL_BITS, PCILIB_REGISTER_R, PCILIB_REGISTER_BITS, PCILIB_REGISTER_BANK1, "adc_gain", ""},
+{0x160, 0, 32, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "write_status", ""},
+{0x170, 0, 32, 0, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "num_triggers", ""},
+{0x180, 0, 32, 0x280, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "trigger_period", ""},
+{0x190, 0, 32, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "temperature_sample_period", ""},
+{0x1a0, 0, 32, 0x64, 0, PCILIB_REGISTER_RW, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "ddr_max_frames", ""},
+{0x1b0, 0, 32, 0, 0, PCILIB_REGISTER_R, PCILIB_REGISTER_STANDARD, PCILIB_REGISTER_BANK1, "ddr_num_frames", ""},
+{0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL}
};
pcilib_register_range_t ipecamera_register_ranges[] = {
diff --git a/ipecamera/private.h b/ipecamera/private.h
index e43c98b..47c80a9 100644
--- a/ipecamera/private.h
+++ b/ipecamera/private.h
@@ -5,8 +5,8 @@
#define IPECAMERA_BUG_EXTRA_DATA
#define IPECAMERA_BUG_MULTIFRAME_PACKETS
-#define IPECAMERA_BUG_INCOMPLETE_PACKETS
-#define IPECAMERA_BUG_POSTPONED_READ
+//#define IPECAMERA_BUG_INCOMPLETE_PACKETS
+//#define IPECAMERA_BUG_POSTPONED_READ
//#define IPECAMERA_DEBUG_RAW_PACKETS "/mnt/fast/frames"
//#define IPECAMERA_ANNOUNCE_READY //**< announce new event only after the reconstruction is done */
@@ -19,7 +19,8 @@
#define IPECAMERA_NOFRAME_SLEEP 100
#define IPECAMERA_NOFRAME_PREPROC_SLEEP 100
-#define IPECAMERA_MAX_LINES 1088
+//#define IPECAMERA_MAX_LINES 1088
+#define IPECAMERA_MAX_LINES 2048
#define IPECAMERA_EXPECTED_STATUS_4 0x08409FFFF
#define IPECAMERA_EXPECTED_STATUS 0x08449FFFF
@@ -122,6 +123,7 @@ struct ipecamera_s {
size_t max_frames; /**< Maximal number of frames what may be buffered in camera DDR memory */
int firmware; /**< Firmware version */
+ int fr_mode; /**< Fast Reject mode */
int cmosis_outputs; /**< Number of active cmosis outputs: 4 or 16 */
int width, height;
diff --git a/ipecamera/reader.c b/ipecamera/reader.c
index c11bb9d..b9b7193 100644
--- a/ipecamera/reader.c
+++ b/ipecamera/reader.c
@@ -129,7 +129,7 @@ static int ipecamera_data_callback(void *user, pcilib_dma_flags_t flags, size_t
#endif /* IPECAMERA_DEBUG_RAW_PACKETS */
if (invalid_frame_id != ctx->event_id) {
- pcilib_warning("Invalid DMA packets received, first is %u bytes long, current event %lu", bufsize, ctx->event_id);
+ pcilib_warning("No frame magic in DMA packet of %u bytes, current event %lu", bufsize, ctx->event_id);
invalid_frame_id = ctx->event_id;
}
@@ -155,12 +155,11 @@ static int ipecamera_data_callback(void *user, pcilib_dma_flags_t flags, size_t
if ((bufsize >= 8)&&(!memcmp(buf, frame_magic, sizeof(frame_magic)))) {
size_t n_lines = ((uint32_t*)buf)[5] & 0x7FF;
ipecamera_compute_buffer_size(ctx, n_lines);
-/*
- // Not implemented in hardware yet
- ctx->frame[ctx->buffer_pos].event.info.seqnum = ((uint32_t*)buf)[6] & 0xF0000000;
- ctx->frame[ctx->buffer_pos].event.info.offset = ((uint32_t*)buf)[7] & 0xF0000000;
-*/
- ctx->frame[ctx->buffer_pos].event.info.seqnum = ctx->event_id + 1;
+
+ ctx->frame[ctx->buffer_pos].event.info.seqnum = ((uint32_t*)buf)[6] & 0x1FFFFFF;
+ ctx->frame[ctx->buffer_pos].event.info.offset = (((uint32_t*)buf)[7] & 0xFFFFFF) * 80;
+
+// ctx->frame[ctx->buffer_pos].event.info.seqnum = ctx->event_id + 1;
gettimeofday(&ctx->frame[ctx->buffer_pos].event.info.timestamp, NULL);
} else {
diff --git a/pci.c b/pci.c
index 5164111..62536ea 100644
--- a/pci.c
+++ b/pci.c
@@ -116,7 +116,7 @@ static pcilib_bar_t pcilib_detect_bar(pcilib_t *ctx, uintptr_t addr, size_t size
return PCILIB_BAR_INVALID;
}
-static int pcilib_detect_address(pcilib_t *ctx, pcilib_bar_t *bar, uintptr_t *addr, size_t size) {
+int pcilib_detect_address(pcilib_t *ctx, pcilib_bar_t *bar, uintptr_t *addr, size_t size) {
const pcilib_board_info_t *board_info = pcilib_get_board_info(ctx);
if (!board_info) return PCILIB_ERROR_NOTFOUND;
diff --git a/pci.h b/pci.h
index bdd34a7..b25aeec 100644
--- a/pci.h
+++ b/pci.h
@@ -76,6 +76,7 @@ const pcilib_dma_info_t *pcilib_get_dma_info(pcilib_t *ctx);
int pcilib_map_register_space(pcilib_t *ctx);
int pcilib_map_data_space(pcilib_t *ctx, uintptr_t addr);
+int pcilib_detect_address(pcilib_t *ctx, pcilib_bar_t *bar, uintptr_t *addr, size_t size);
#endif /* _PCITOOL_PCI_H */
diff --git a/pcilib.h b/pcilib.h
index dfe4b6c..4df7f1a 100644
--- a/pcilib.h
+++ b/pcilib.h
@@ -130,6 +130,8 @@ typedef enum {
#define PCILIB_TIMEOUT_IMMEDIATE 0
#define PCILIB_IRQ_TYPE_ALL 0
#define PCILIB_IRQ_SOURCE_DEFAULT 0
+#define PCILIB_REGISTER_NO_BITS 0
+#define PCILIB_REGISTER_ALL_BITS ((pcilib_register_value_t)-1)
typedef struct {
pcilib_event_t type;
@@ -183,7 +185,9 @@ typedef struct {
pcilib_register_size_t offset;
pcilib_register_size_t bits;
pcilib_register_value_t defvalue;
- pcilib_register_value_t rwmask; /**< 1 - read before write bits, 0 - zero should be written to preserve value */
+ pcilib_register_value_t rwmask; /**< 1 - read before write bits, 0 - zero should be written to preserve value
+ Used to define how external bits of PCILIB_REGISTER_BITS registers are treated.
+ Currently it is a bit confusing, we may find a better way in the next release */
pcilib_register_mode_t mode;
pcilib_register_type_t type;
diff --git a/tests/dma/debug/test-iommu.sh b/tests/dma/debug/test-iommu.sh
new file mode 100755
index 0000000..74e3ece
--- /dev/null
+++ b/tests/dma/debug/test-iommu.sh
@@ -0,0 +1,19 @@
+#! /bin/bash
+
+i=1
+while [ 1 ]; do
+ pci --start-dma dma1r
+ for name in /sys/class/fpga/fpga0/kbuf*; do
+ bus_addr=0x`cat $name | grep "bus addr" | cut -d ':' -f 2 | sed -e 's/\s\+//g'`
+ if [ $((bus_addr % 4096)) -ne 0 ]; then
+
+ echo "Failed at iteration $i, $name"
+ echo "----------------------"
+ cat $name
+ exit
+ fi
+
+ done
+ pci --stop-dma dma1r
+ i=$((i + 1))
+done
diff --git a/tests/bench_nwl.sh b/tests/dma/nwl/bench.sh
index b36c251..b36c251 100755
--- a/tests/bench_nwl.sh
+++ b/tests/dma/nwl/bench.sh
diff --git a/tests/cleanup.sh b/tests/dma/nwl/cleanup.sh
index 5ef568e..5ef568e 100755
--- a/tests/cleanup.sh
+++ b/tests/dma/nwl/cleanup.sh
diff --git a/tests/xilinx_dma.sh b/tests/dma/xilinx/xilinx_dma.sh
index 6aada8b..6aada8b 100755
--- a/tests/xilinx_dma.sh
+++ b/tests/dma/xilinx/xilinx_dma.sh
diff --git a/apps/counters.sh b/tests/dma/xilinx/xilinx_dma_static_mem.sh
index e3ba0f5..e3ba0f5 100755
--- a/apps/counters.sh
+++ b/tests/dma/xilinx/xilinx_dma_static_mem.sh
diff --git a/tests/frame2.sh b/tests/frame2.sh
deleted file mode 100755
index 2795caf..0000000
--- a/tests/frame2.sh
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/bin/bash
-
-function pci {
- PCILIB_PATH="/root/pcitool"
- LD_LIBRARY_PATH="$PCILIB_PATH" $PCILIB_PATH/pci $*
-}
-
-pci --stop-dma dma1
-#pci --reset
-
-echo "Set packet size 1024 .. "
-pci -w cmosis_number_lines 1088
-#pci -w xrawdata_packet_length 4096
-pci --start-dma dma1
-usleep 1000
-
-echo "Send frame request ... "
-pci -w control 1e9
-usleep 1000
-pci -w control 1e1
-usleep 300000
-pci -w control 1e9
-usleep 1000
-pci -w control 1e1
-usleep 3000
-
-echo "Enable Readout ... "
-pci -w control 3e1
-
-usleep 100000
-
-pci -r dma1 -o bench.out --multipacket --timeout 1000000
-
-pci -w control 1e1
-
-pci --stop-dma dma1
-
diff --git a/tests/heb/DataTaking.sh b/tests/heb/DataTaking.sh
new file mode 100755
index 0000000..b6046d7
--- /dev/null
+++ b/tests/heb/DataTaking.sh
@@ -0,0 +1,96 @@
+#!/bin/bash
+
+#Channel 1 --> 05
+#Channel 2 --> 0B
+#Channel 1&2 --> 0F
+#Channel 3 --> 13
+#Channel 4 --> 23
+#Channel 3&4 --> 33
+#ALL --> 3F
+
+#rm *.out
+pci -r dma1 --multipacket -o /dev/null
+
+echo "Start DMA ..... "
+#pci --start-dma dma1
+sleep 0.2
+
+echo "Data Reset ... "
+pci -w 0x9040 000003f1
+sleep 0.1
+pci -w 0x9040 000003f0
+
+sleep 0.1
+#echo "Pilot bunch emulator ..... "
+#pci -w 0x9040 400003f0
+sleep 0.2
+pci -w 0x9040 03f0
+#pci -r 0x9000 -s 40
+#sleep 0.2
+echo "Start data pci. ..... "
+pci -w 0x9040 00bf0
+
+sleep 2
+
+echo "Stop data acquis...... "
+pci -w 0x9040 003f0
+pci -r 0x9000 -s 40
+sleep 0.1
+echo "Enable data transfer.... "
+pci -w 0x9040 007f0
+exit
+sleep 2
+pci -r dma1 -o run_num_$1.out --multipacket
+sleep 2
+
+pci -w 0x9040 003f0
+#echo "Status ... "
+
+
+
+pci -r 0x9000 -s 40
+
+ status=`pci -r 0x9050 -s 1 | awk '{print $2$3$4}'`
+ if [ "$status" != "85000021" ]; then
+ echo "--------------------------------->>>> ERROR! ... "
+ error=1
+ exit
+ else
+ echo " Status 1 -> OK "
+ fi
+
+ status=`pci -r 0x9000 -s 1 | awk '{print $2$3$4}'`
+ if [ "$status" != "01000021" ]; then
+ echo "--------------------------------->>>> ERROR! ... "
+ error=1
+ exit
+ else
+ echo " Status 1 Readout -> OK "
+ fi
+
+status=`pci -r 0x9008 -s 1 | awk '{print $2$3$4}'`
+ if [ "$status" != "01000021" ]; then
+ echo "--------------------------------->>>> ERROR! ... "
+ error=1
+ exit
+ else
+ echo " Status 2 Readout -> OK "
+ fi
+
+status=`pci -r 0x9010 -s 1 | awk '{print $2$3$4}'`
+ if [ "$status" != "01000021" ]; then
+ echo "--------------------------------->>>> ERROR! ... "
+ error=1
+ exit
+ else
+ echo " Status 3 Readout -> OK "
+ fi
+
+status=`pci -r 0x9018 -s 1 | awk '{print $2$3$4}'`
+ if [ "$status" != "01000021" ]; then
+ echo "--------------------------------->>>> ERROR! ... "
+ error=1
+ exit
+ else
+ echo " Status 4 Readout -> OK "
+ fi
diff --git a/tests/heb/cfg/BoardOFF.sh b/tests/heb/cfg/BoardOFF.sh
new file mode 100755
index 0000000..351bcb8
--- /dev/null
+++ b/tests/heb/cfg/BoardOFF.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+
+echo " ************************************************************** "
+echo " Board OFF"
+echo " ************************************************************** "
+
+pci -w 0x9040 0x01
+sleep 0.5
+
+pci --stop-dma dma1
diff --git a/tests/heb/cfg/BoardOn.sh b/tests/heb/cfg/BoardOn.sh
new file mode 100755
index 0000000..b14c73b
--- /dev/null
+++ b/tests/heb/cfg/BoardOn.sh
@@ -0,0 +1,57 @@
+#!/bin/bash
+
+echo " ************************************************************** "
+echo " Start DMA"
+echo " ************************************************************** "
+
+pci --start-dma dma1
+sleep 0.5
+pci --list-dma-engines
+
+
+echo " ************************************************************** "
+echo " Board ON procedure"
+echo " ************************************************************** "
+
+pci -w 0x9040 0x01
+sleep 1
+
+echo "switch ON the power supply --> FIRST <--"
+echo "Press a key to continue ...."
+read -n 1 -s
+
+echo "Switch ON T/Hs"
+pci -w 0x9040 0x3C1
+pci -r 0x9040 -s1
+
+echo "switch ON the power supply --> SECOND <--"
+echo "Press a key to continue ...."
+read -n 1 -s
+
+echo "Switch ON ADCs"
+pci -w 0x9040 0x3F1
+pci -r 0x9040 -s1
+sleep 0.1
+
+
+pci -w 0x9040 0x3F0
+pci -r 0x9040 -s1
+sleep 1
+
+echo " Status ................... "
+pci -r 0x9000 -s 40
+
+
+
+./PLL_conf_calib_3001.sh
+
+echo " Status ................... "
+pci -r 0x9000 -s 40
+
+
+echo " ************************************************************** "
+echo " Board Ready"
+echo " ************************************************************** "
+
+
+echo " --> remember to run: ./Set_Default.sh"
diff --git a/tests/heb/cfg/README b/tests/heb/cfg/README
new file mode 100644
index 0000000..125bc0d
--- /dev/null
+++ b/tests/heb/cfg/README
@@ -0,0 +1,11 @@
+ - Initializing
+ ./BoardOn.sh
+ ./Set_Default.sh
+
+ - Configuring the size
+ pci -w 9020 0x20 (linear scale)
+
+ * Number of samples are determined by 0x9020 / 0x9028 (0x0e by default)
+ * For each sample is descibed by (184 / 2) * 128 bits
+ * Where most-significant bytes of 4 dwords (128 bit) are iterating
+ from 0x00 to 0xb8 with step 0x02
diff --git a/tests/heb/cfg/Set_ADC_1_Delay.sh b/tests/heb/cfg/Set_ADC_1_Delay.sh
new file mode 100755
index 0000000..bd8f980
--- /dev/null
+++ b/tests/heb/cfg/Set_ADC_1_Delay.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+echo "Set CH_4 clock ADC 1 delay... "
+
+upfix=000501
+fixed=4
+
+ hex_val=$(printf "%01x\n" $1)
+ echo "Set $hex_val --> Time value picosecond = `expr $1 "*" 150`."
+ pci -w 0x9060 $upfix$hex_val$fixed
diff --git a/tests/heb/cfg/Set_ADC_2_Delay.sh b/tests/heb/cfg/Set_ADC_2_Delay.sh
new file mode 100755
index 0000000..d6cdf75
--- /dev/null
+++ b/tests/heb/cfg/Set_ADC_2_Delay.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+echo "Set CH_5 clock ADC 2 delay... "
+
+upfix=000501
+fixed=5
+
+ hex_val=$(printf "%01x\n" $1)
+ echo "Set $hex_val --> Time value picosecond = `expr $1 "*" 150`."
+ pci -w 0x9060 $upfix$hex_val$fixed
diff --git a/tests/heb/cfg/Set_ADC_3_Delay.sh b/tests/heb/cfg/Set_ADC_3_Delay.sh
new file mode 100755
index 0000000..567b977
--- /dev/null
+++ b/tests/heb/cfg/Set_ADC_3_Delay.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+echo "Set CH_6 clock ADC 3 delay... "
+
+upfix=000501
+fixed=6
+
+ hex_val=$(printf "%01x\n" $1)
+ echo "Set $hex_val --> Time value picosecond = `expr $1 "*" 150`."
+ pci -w 0x9060 $upfix$hex_val$fixed
diff --git a/tests/heb/cfg/Set_ADC_4_Delay.sh b/tests/heb/cfg/Set_ADC_4_Delay.sh
new file mode 100755
index 0000000..d666595
--- /dev/null
+++ b/tests/heb/cfg/Set_ADC_4_Delay.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+echo "Set CH_7 clock ADC 4 delay... "
+
+upfix=000501
+fixed=7
+
+ hex_val=$(printf "%01x\n" $1)
+ echo "Set $hex_val --> Time value picosecond = `expr $1 "*" 150`."
+ pci -w 0x9060 $upfix$hex_val$fixed
+
diff --git a/tests/heb/cfg/Set_Default.sh b/tests/heb/cfg/Set_Default.sh
new file mode 100755
index 0000000..0149bf0
--- /dev/null
+++ b/tests/heb/cfg/Set_Default.sh
@@ -0,0 +1,30 @@
+#!/bin/bash
+
+echo "Set Defaults delay value in the board... "
+
+./Set_FPGA_clock_delay.sh 0
+sleep 0.1
+
+ ./Set_Delay_chip.sh 16 16 16 16
+sleep 0.1
+
+./Set_TH_Delay.sh 12
+sleep 0.1
+
+./Set_ADC_1_Delay.sh 5
+sleep 0.1
+
+./Set_ADC_2_Delay.sh 5
+sleep 0.1
+
+./Set_ADC_3_Delay.sh 5
+sleep 0.1
+
+./Set_ADC_4_Delay.sh 5
+
+#pci -w 0x9020 200b20
+pci -w 0x9020 20
+pci -w 0x9028 e
+
+echo " DONE ................ "
+
diff --git a/tests/heb/cfg/Set_Delay_chip.sh b/tests/heb/cfg/Set_Delay_chip.sh
new file mode 100755
index 0000000..3d15cad
--- /dev/null
+++ b/tests/heb/cfg/Set_Delay_chip.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+ zero=0
+ hex_val1=$(printf "%02x\n" $1)
+ hex_val2=$(printf "%02x\n" $2)
+ hex_val3=$(printf "%02x\n" $3)
+ hex_val4=$(printf "%02x\n" $4)
+
+ pci -w 0x9080 $zero$hex_val4$hex_val3$hex_val2$hex_val1
+ pci -r 0x9080 -s 1
+ sleep 0.5
diff --git a/tests/heb/cfg/Set_FPGA_clock_delay.sh b/tests/heb/cfg/Set_FPGA_clock_delay.sh
new file mode 100755
index 0000000..f4d0f46
--- /dev/null
+++ b/tests/heb/cfg/Set_FPGA_clock_delay.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+echo "Set delay on T/Hs signals... "
+
+upfix=000501
+fixed=0
+
+ hex_val=$(printf "%01x\n" $1)
+ echo "Set $hex_val --> Time picosecond = `expr $1 "*" 150`."
+ pci -w 0x9060 $upfix$hex_val$fixed
diff --git a/tests/heb/cfg/Set_TH_Delay.sh b/tests/heb/cfg/Set_TH_Delay.sh
new file mode 100755
index 0000000..9a6e58f
--- /dev/null
+++ b/tests/heb/cfg/Set_TH_Delay.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+echo "Set delay on T/Hs signals... "
+
+upfix=000501
+fixed=3
+
+ hex_val=$(printf "%01x\n" $1)
+ echo "Set $hex_val --> Time picosecond = `expr $1 "*" 150`."
+ pci -w 0x9060 $upfix$hex_val$fixed
diff --git a/tests/heb/debug/debug.sh b/tests/heb/debug/debug.sh
new file mode 100755
index 0000000..2db21d4
--- /dev/null
+++ b/tests/heb/debug/debug.sh
@@ -0,0 +1,45 @@
+#! /bin/bash
+
+SCRIPT_PATH="`dirname \"$0\"`"
+SCRIPT_PATH="`( cd \"$TESTS_PATH\" && pwd )`"
+PCILIB_PATH=${SCRIPT_PATH%/tests/*}
+
+function pci {
+ LD_LIBRARY_PATH="$PCILIB_PATH" $PCILIB_PATH/pci $*
+}
+
+function strip_bad_values {
+ LD_LIBRARY_PATH="$PCILIB_PATH" $PCILIB_PATH/apps/heb_strip_bad_values $*
+}
+
+function request_data {
+ $PCILIB_PATH/tests/heb/debug/request_data.sh $*
+}
+
+while [ 1 ]; do
+ from=`pci --list-dma-engines | grep C2S | sed -s 's/\s\+/ /g' | cut -d ' ' -f 6`
+ to=`pci --list-dma-engines | grep C2S | sed -s 's/\s\+/ /g' | cut -d ' ' -f 8`
+
+ if [ $from -gt $to ]; then
+ buffers="`seq $from 255` `seq 0 $to`"
+ else
+ buffers=`seq $from $to`
+ fi
+
+ echo $buffers
+
+ rm data.out
+ for i in $buffers; do
+ pci --read-dma-buffer dma1r:$i -o data.out
+ done
+
+
+ error=`strip_bad_values data.out | head -n 1 | cut -f 1 -d ':'`
+ if [ $error != "0x1140" ]; then
+ echo "Problems found"
+ exit
+ else
+ echo "Fine"
+ request_data
+ fi
+done
diff --git a/tests/heb/debug/request_data.sh b/tests/heb/debug/request_data.sh
new file mode 100755
index 0000000..b751f5d
--- /dev/null
+++ b/tests/heb/debug/request_data.sh
@@ -0,0 +1,27 @@
+#!/bin/bash
+
+pci -r dma1 --multipacket -o /dev/null
+
+#echo "Data Reset ... "
+pci -w 0x9040 000003f1
+sleep 0.1
+pci -w 0x9040 000003f0
+
+sleep 0.1
+#echo "Pilot bunch emulator ..... "
+#pci -w 0x9040 400003f0
+sleep 0.2
+pci -w 0x9040 03f0
+#pci -r 0x9000 -s 40
+#sleep 0.2
+#echo "Start data pci. ..... "
+pci -w 0x9040 00bf0
+
+sleep 2
+
+#echo "Stop data acquis...... "
+pci -w 0x9040 003f0
+pci -r 0x9000 -s 40
+sleep 0.1
+#echo "Enable data transfer.... "
+pci -w 0x9040 007f0
diff --git a/tests/bench_ipecamera.sh b/tests/ipecamera/bench.sh
index 09edae9..09edae9 100755
--- a/tests/bench_ipecamera.sh
+++ b/tests/ipecamera/bench.sh
diff --git a/tests/ipecamera/Reset_Init_all_reg_10bit.sh b/tests/ipecamera/cfg/Reset_Init_all_reg_10bit.sh
index f6a3521..f4afa06 100755
--- a/tests/ipecamera/Reset_Init_all_reg_10bit.sh
+++ b/tests/ipecamera/cfg/Reset_Init_all_reg_10bit.sh
@@ -5,10 +5,10 @@
error=0
echo " Reset Readout and CMOSIS "
-pci -w 0x9040 204
+pci -w 0x9040 80000204
sleep .1
#echo " Release Reset for Readout"
-#pci -w 0x9040 1e0
+#pci -w 0x9040 800001e0
sleep .1
##################### PLL SET #####################################
val=f501
@@ -228,7 +228,7 @@ fi
####################################################################################################################
sleep 0.01
-#pci -w 0x9040 201
+#pci -w 0x9040 80000201
sleep 0.01
########################## WRITE THE READOUT NUMBER OF LINE #######################################################
pci -w cmosis_number_lines 1088
@@ -288,16 +288,23 @@ sleep 0.01
#########################################################################################################
sleep 0.01
+
+
+##################################################
+#SET the max number of frame in DDR
+pci -w 0x91a0 0x71
+
#echo " Reset Readout and CMOSIS "
-pci -w 0x9040 0x204
+pci -w 0x9040 0x80000204
sleep .1
echo " Release Reset for Readout"
-pci -w 0x9040 0x201
+pci -w 0x9040 0x80000201
sleep .1
status=`pci -r 0x9050 -s 4 | awk '{print $2$3$4}'`
if [ "$status" != "8449ffff0f0010013ffff111" ]; then
echo "--------------------------------->>>> ERROR! in the camera status ... "
+ echo " $status "
error=1
# exit
fi
@@ -311,4 +318,9 @@ else
fi
echo
+echo "DMA reset ... "
+pci --stop-dma dma1
+sleep 0.5
+pci --start-dma dma1
+
diff --git a/tests/ipecamera/cfg/Reset_Init_all_reg_10bit_4Mp.sh b/tests/ipecamera/cfg/Reset_Init_all_reg_10bit_4Mp.sh
new file mode 100755
index 0000000..5a4e582
--- /dev/null
+++ b/tests/ipecamera/cfg/Reset_Init_all_reg_10bit_4Mp.sh
@@ -0,0 +1,325 @@
+#!/bin/bash
+
+###################### by Michele Caselle and Uros Stafanovic ##################################################
+############ Resent procedure and camera initialization for 10 -bit mode ######################################
+
+error=0
+echo " Reset Readout and CMOSIS "
+pci -w 0x9040 80000204
+sleep .1
+#echo " Release Reset for Readout"
+#pci -w 0x9040 800001e0
+sleep .1
+##################### PLL SET #####################################
+val=f501
+pci -w 0x9000 $val
+sleep 0.01
+#pci -r 0x9000 -s 10
+sleep 0.01
+value=`pci -r 0x9000 -s 8 | grep 9010 | awk '{print $2}' | cut -c 4-8`
+if [ "$value" != "b$val" ]; then
+ echo "--------------------------------->>>> ERROR! read value: ${value:1:4}, written value: $val"
+ error=1
+ # exit
+fi
+sleep 0.01
+echo " Start CMOSIS Configuration .."
+pci -w 0x9000 f301
+sleep 0.01
+#pci -r 0x9000 -s 10
+sleep 0.01
+value=`pci -r 0x9000 -s 8 | grep 9010 | awk '{print $2}' | cut -c 4-8`
+if [ "$value" != "bf301" ]; then
+ echo "--------------------------------->>>> ERROR! read value: ${value:1:4}, written value: $val"
+ error=1
+ # exit
+fi
+sleep 0.01
+val=d207
+pci -w 0x9000 $val
+sleep 0.01
+#pci -r 0x9000 -s 10
+sleep 0.01
+value=`pci -r 0x9000 -s 8 | grep 9010 | awk '{print $2}' | cut -c 4-8`
+if [ "$value" != "b$val" ]; then
+ echo "--------------------------------->>>> ERROR! read value: ${value:1:4}, written value: $val"
+ error=1
+ # exit
+fi
+sleep 0.01
+
+# Michele 10 - 12 bit mode #
+# ###################################################################################################
+echo " 10 - bit mode, set Bit_mode "
+val=ef00 ######################################################
+pci -w 0x9000 $val
+sleep 0.01
+#pci -r 0x9000 -s 10
+sleep 0.01
+value=`pci -r 0x9000 -s 8 | grep 9010 | awk '{print $2}' | cut -c 4-8`
+if [ "$value" != "b$val" ]; then
+ echo "--------------------------------->>>> ERROR! read value: ${value:1:4}, written value: $val"
+ error=1
+ # exit
+fi
+sleep 0.01
+# Michele set ADC_resolution @ 12 bits
+echo " 10 bit mode, set ADC resolution 10 bits "
+val=f000 # qui for 10 - 11 - 12 bits ########################################################
+pci -w 0x9000 $val
+sleep 0.01
+#pci -r 0x9000 -s 10
+sleep 0.01
+value=`pci -r 0x9000 -s 8 | grep 9010 | awk '{print $2}' | cut -c 4-8`
+if [ "$value" != "b$val" ]; then
+ echo "--------------------------------->>>> ERROR! read value: ${value:1:4}, written value: $val"
+ error=1
+ # exit
+fi
+sleep 0.01
+
+# adc recommended 28=44
+val=e72c
+pci -w 0x9000 $val
+sleep 0.01
+#pci -r 0x9000 -s 10
+sleep 0.01
+value=`pci -r 0x9000 -s 8 | grep 9010 | awk '{print $2}' | cut -c 4-8`
+if [ "$value" != "b$val" ]; then
+ echo "--------------------------------->>>> ERROR! read value: ${value:1:4}, written value: $val "
+ error=1
+ # exit
+fi
+sleep 0.01
+# ####################################################################################################
+
+################# CAMERA CONFIGURATION ############################################
+val=e603
+pci -w 0x9000 $val
+sleep 0.01
+#pci -r 0x9000 -s 10
+sleep 0.01
+value=`pci -r 0x9000 -s 8 | grep 9010 | awk '{print $2}' | cut -c 4-8`
+if [ "$value" != "b$val" ]; then
+ echo "--------------------------------->>>> ERROR! read value: ${value:1:4}, written value: $val"
+ error=1
+ # exit
+fi
+sleep 0.01
+
+val=d404
+pci -w 0x9000 $val
+sleep 0.01
+#pci -r 0x9000 -s 10
+sleep 0.01
+value=`pci -r 0x9000 -s 8 | grep 9010 | awk '{print $2}' | cut -c 4-8`
+if [ "$value" != "b$val" ]; then
+ echo "--------------------------------->>>> ERROR! read value: ${value:1:4}, written value: $val"
+ error=1
+ # exit
+fi
+sleep 0.01
+val=d501
+pci -w 0x9000 $val
+sleep 0.01
+#pci -r 0x9000 -s 10
+sleep 0.01
+value=`pci -r 0x9000 -s 8 | grep 9010 | awk '{print $2}' | cut -c 4-8`
+if [ "$value" != "b$val" ]; then
+ echo "--------------------------------->>>> ERROR! read value: ${value:1:4}, written value: $val"
+ error=1
+ # exit
+fi
+sleep 0.01
+# recommended is d840
+val=d840
+pci -w 0x9000 $val
+sleep 0.01
+#pci -r 0x9000 -s 10
+sleep 0.01
+value=`pci -r 0x9000 -s 8 | grep 9010 | awk '{print $2}' | cut -c 4-8`
+if [ "$value" != "b$val" ]; then
+ echo "--------------------------------->>>> ERROR! read value: ${value:1:4}, written value: $val"
+ error=1
+ # exit
+fi
+# sleep 0.01
+# recommended is db40
+val=db40
+pci -w 0x9000 $val
+sleep 0.01
+#pci -r 0x9000 -s 10
+sleep 0.01
+value=`pci -r 0x9000 -s 8 | grep 9010 | awk '{print $2}' | cut -c 4-8`
+if [ "$value" != "b$val" ]; then
+ echo "--------------------------------->>>> ERROR! read value: ${value:1:4}, written value: $val"
+ error=1
+ # exit
+fi
+sleep 0.01
+val=de65
+# val=de0
+pci -w 0x9000 $val
+sleep 0.01
+#pci -r 0x9000 -s 10
+sleep 0.01
+value=`pci -r 0x9000 -s 8 | grep 9010 | awk '{print $2}' | cut -c 4-8`
+if [ "$value" != "b$val" ]; then
+ echo "--------------------------------->>>> ERROR! read value: ${value:1:4}, written value: $val"
+ error=1
+ # exit
+fi
+sleep 0.01
+sleep 0.01
+val=df6a
+pci -w 0x9000 $val
+sleep 0.01
+#pci -r 0x9000 -s 10
+sleep 0.01
+value=`pci -r 0x9000 -s 8 | grep 9010 | awk '{print $2}' | cut -c 4-8`
+if [ "$value" != "b$val" ]; then
+ echo "--------------------------------->>>> ERROR! read value: ${value:1:4}, written value: $val"
+ error=1
+ # exit
+fi
+sleep 0.01
+echo " End CMOSIS Configuration .."
+########################################################################################################
+echo " Write exp time......"
+
+######################################### EXP TIME #######################################################
+val=aa25
+pci -w 0x9000 $val
+sleep 0.01
+#pci -r 0x9000 -s 10
+sleep 0.01
+value=`pci -r 0x9000 -s 8 | grep 9010 | awk '{print $2}' | cut -c 4-8`
+if [ "$value" != "b$val" ]; then
+ echo "--------------------------------->>>> ERROR! read value: ${value:1:4}, written value: $val"
+ error=1
+ # exit
+fi
+sleep 0.01
+# val=ab2c
+val=ab00
+pci -w 0x9000 $val
+sleep 0.01
+#pci -r 0x9000 -s 10
+sleep 0.01
+value=`pci -r 0x9000 -s 8 | grep 9010 | awk '{print $2}' | cut -c 4-8`
+if [ "$value" != "b$val" ]; then
+ echo "--------------------------------->>>> ERROR! read value: ${value:1:4}, written value: $val"
+ error=1
+ # exit
+fi
+sleep 0.01
+# val=acaa
+val=ac00
+pci -w 0x9000 $val
+sleep 0.01
+#pci -r 0x9000 -s 10
+sleep 0.01
+value=`pci -r 0x9000 -s 8 | grep 9010 | awk '{print $2}' | cut -c 4-8`
+if [ "$value" != "b$val" ]; then
+ echo "--------------------------------->>>> ERROR! read value: ${value:1:4}, written value: $val"
+ error=1
+ # exit
+fi
+####################################################################################################################
+
+sleep 0.01
+#pci -w 0x9040 80000201
+sleep 0.01
+########################## WRITE THE READOUT NUMBER OF LINE #######################################################
+pci -w cmosis_number_lines 2047
+#pci -w number_lines 8
+sleep 0.01
+#################################################################################################################
+pci --start-dma dma1
+sleep 0.01
+#VRAMP 6c is 108
+val=e26c
+pci -w 0x9000 $val
+sleep 0.01
+#pci -r 0x9000 -s 10
+sleep 0.01
+value=`pci -r 0x9000 -s 8 | grep 9010 | awk '{print $2}' | cut -c 4-8`
+if [ "$value" != "b$val" ]; then
+ echo "--------------------------------->>>> ERROR! read value: ${value:1:4}, written value: $val"
+ error=1
+ # exit
+fi
+sleep 0.01
+#VRAMP 6c is 108
+val=e36c
+pci -w 0x9000 $val
+sleep 0.01
+#pci -r 0x9000 -s 10
+sleep 0.01
+value=`pci -r 0x9000 -s 8 | grep 9010 | awk '{print $2}' | cut -c 4-8`
+if [ "$value" != "b$val" ]; then
+ echo "--------------------------------->>>> ERROR! read value: ${value:1:4}, written value: $val"
+ error=1
+ # exit
+fi
+sleep 0.01
+###################################### NUMBER OF OUTPUT ############################################################
+##pci -w 0x9000 0xc803
+sleep 0.01
+val=c800
+pci -w 0x9000 $val
+#pci -r 0x9000 -s 10
+sleep 0.01
+value=`pci -r 0x9000 -s 8 | grep 9010 | awk '{print $2}' | cut -c 4-8`
+if [ "$value" != "b$val" ]; then
+ echo "--------------------------------->>>> ERROR! read value: ${value:1:4}, written value: $val"
+ error=1
+ # exit
+fi
+#pci -r 0x9000 -s 10
+
+sleep 0.01
+#pci -w 0x9000 0xd011
+sleep 0.01
+#pci -r 0x9000 -s 10
+
+sleep 0.01
+#pci -w 0x9000 0xd111
+#########################################################################################################
+sleep 0.01
+
+
+
+##################################################
+#SET the max number of frame in DDR
+pci -w 0x91a0 0x71
+
+#echo " Reset Readout and CMOSIS "
+pci -w 0x9040 0x80000204
+sleep .1
+echo " Release Reset for Readout"
+pci -w 0x9040 0x80000201
+sleep .1
+
+status=`pci -r 0x9050 -s 4 | awk '{print $2$3$4}'`
+if [ "$status" != "8449ffff0f0010013ffff111" ]; then
+ echo "--------------------------------->>>> ERROR! in the camera status ... "
+ error=1
+ # exit
+fi
+
+#echo "--> $status"
+
+if [ "$error" = "1" ]; then
+ echo " Error in the reset and initialization"
+else
+ echo " Camera READY ........................... OK"
+fi
+echo
+
+echo "DMA reset ... "
+pci --stop-dma dma1
+sleep 0.5
+pci --start-dma dma1
+
+
diff --git a/tests/ipecamera/Reset_Init_all_reg_11bit.sh b/tests/ipecamera/cfg/Reset_Init_all_reg_11bit.sh
index 048f6b0..3c4af0e 100755
--- a/tests/ipecamera/Reset_Init_all_reg_11bit.sh
+++ b/tests/ipecamera/cfg/Reset_Init_all_reg_11bit.sh
@@ -279,6 +279,10 @@ if [ "$value" != "b$val" ]; then
fi
#pci -r 0x9000 -s 10
+##################################################
+#SET the max number of frame in DDR
+pci -w 0x91a0 0x1C
+
sleep 0.01
#pci -w 0x9000 0xd011
sleep 0.01
@@ -307,3 +311,8 @@ fi
echo
+echo "DMA reset ... "
+pci --stop-dma dma1
+sleep 0.5
+pci --start-dma dma1
+
diff --git a/tests/ipecamera/Reset_Init_all_reg_12bit.sh b/tests/ipecamera/cfg/Reset_Init_all_reg_12bit.sh
index 00c2481..b04f2cd 100755
--- a/tests/ipecamera/Reset_Init_all_reg_12bit.sh
+++ b/tests/ipecamera/cfg/Reset_Init_all_reg_12bit.sh
@@ -188,7 +188,7 @@ echo " End CMOSIS Configuration .."
echo " Write exp time......"
######################################### EXP TIME #######################################################
-val=aa01
+val=aa0f
pci -w 0x9000 $val
sleep 0.01
#pci -r 0x9000 -s 10
@@ -280,20 +280,29 @@ fi
#pci -r 0x9000 -s 10
sleep 0.01
+
+##################################################
+#SET the max number of frame in DDR
+pci -w 0x91a0 0x1C
+
+
#pci -w 0x9000 0xd011
sleep 0.01
-#pci -r 0x9000 -s 10
+pci -r 0x9000 -s 10
sleep 0.01
#pci -w 0x9000 0xd111
-#pci -r 0x9000 -s 10
-#########################################################################################################
sleep 0.01
+pci -r 0x9000 -s 10
+#########################################################################################################
+sleep 0.1
status=`pci -r 0x9050 -s 4 | awk '{print $2$3$4}'`
-if [ "$status" != "8449ffff0f0010013ffff111" ]; then
+if [ "$status" != "844950280f0010013ffff111" ]; then
+
echo "--------------------------------->>>> ERROR! in the camera status ... "
- error =1
+ echo $status
+ error=1
# exit
fi
@@ -307,3 +316,8 @@ fi
echo
+
+echo "DMA reset ... "
+pci --stop-dma dma1
+sleep 0.5
+pci --start-dma dma1
diff --git a/tests/incomplete.sh b/tests/ipecamera/debug/incomplete.sh
index 5c80198..5c80198 100755
--- a/tests/incomplete.sh
+++ b/tests/ipecamera/debug/incomplete.sh
diff --git a/tests/frame.sh b/tests/ipecamera/frame.sh
index b2b2a70..679817b 100755
--- a/tests/frame.sh
+++ b/tests/ipecamera/frame.sh
@@ -1,7 +1,10 @@
#!/bin/bash
+TESTS_PATH="`dirname \"$0\"`"
+TESTS_PATH="`( cd \"$TESTS_PATH\" && pwd )`"
+
function pci {
- PCILIB_PATH="/root/pcitool"
+ PCILIB_PATH=$TESTS_PATH/..
LD_LIBRARY_PATH="$PCILIB_PATH" $PCILIB_PATH/pci $*
}
diff --git a/tests/frame_req.sh b/tests/ipecamera/frame_req.sh
index bce89c3..bce89c3 100755
--- a/tests/frame_req.sh
+++ b/tests/ipecamera/frame_req.sh
diff --git a/tests/ipecamera/grab-hwtrigger.sh b/tests/ipecamera/grab-hwtrigger.sh
new file mode 100755
index 0000000..0279ab4
--- /dev/null
+++ b/tests/ipecamera/grab-hwtrigger.sh
@@ -0,0 +1,20 @@
+#! /bin/bash
+
+function pci {
+ PCILIB_PATH="/root/pcitool"
+ LD_LIBRARY_PATH="$PCILIB_PATH" $PCILIB_PATH/pci $*
+}
+
+function enable_hw_trigger {
+ usleep 100000
+ pci -w control 0xa01
+}
+
+rm -f images.raw
+
+enable_hw_trigger &
+pid=$!
+
+echo "Starting the grabber"
+pci -g -o images.raw --run-time 60000000 --verbose 10 -o /dev/null
+wait $pid
diff --git a/tests/stimuli.sh b/tests/ipecamera/stimuli.sh
index 33e99e1..33e99e1 100755
--- a/tests/stimuli.sh
+++ b/tests/ipecamera/stimuli.sh
diff --git a/tests/ipecamera/tests/loopback-test.sh b/tests/ipecamera/tests/loopback-test.sh
new file mode 100755
index 0000000..1c033cc
--- /dev/null
+++ b/tests/ipecamera/tests/loopback-test.sh
@@ -0,0 +1,87 @@
+#! /bin/bash
+
+TESTS_PATH="`dirname \"$0\"`"
+TESTS_PATH="`( cd \"$TESTS_PATH\" && pwd )`"
+
+function pci {
+ PCILIB_PATH=$TESTS_PATH/..
+ LD_LIBRARY_PATH="$PCILIB_PATH" $PCILIB_PATH/pci $*
+}
+
+function compare {
+ PCILIB_PATH=$TESTS_PATH/..
+ LD_LIBRARY_PATH="$PCILIB_PATH" $PCILIB_PATH/apps/compare_to_value $*
+}
+
+#size=`expr 1024 "*" 1024`
+size=`expr 1024 "*" 1`
+multiplier=2
+wait=0
+
+/root/pcitool/tests/ipecamera/frame.sh &> /dev/null
+rm -f bench.out
+
+pci --stop-dma dma1
+pci --start-dma dma1
+
+pci -r dma1 -s 16777216 --multipacket -o /dev/null &> /dev/null
+
+pci -r dma1 -s 1024 -o /dev/null | grep -i "Error (62)" &> /dev/null
+if [ $? -ne 0 ]; then
+ echo "There is data on dma..."
+ exit
+fi
+
+failed=0
+send=0
+errors=0
+err_num=0
+
+print_iters=`expr 2 + 1024 '*' 100 / $size`
+
+read_size=`expr $multiplier '*' $size`
+echo "Starting..."
+i=1
+
+pci -w 0x9040 0x201
+
+while [ 1 ]; do
+ if [ $wait -gt 0 ]; then
+ pci -w 0x9040 0x1
+ fi
+
+ pci -w dma1 -s $size "*0x$i"
+ rm -f /tmp/camera-test.out
+ pci -r dma1 --wait --multipacket -s $read_size -o /tmp/camera-test.out -t 1000000 &> /dev/null
+ if [ $wait -gt 0 ]; then
+ wrdone=0
+ while [ $wrdone -eq 0 ]; do
+# pci --list-dma-engines
+ pci --list-dma-engines | grep "DMA1 S2C" | grep "SD" #&> /dev/null
+ wrdone=$?
+ done
+ pci -w 0x9040 0x201
+ fi
+
+ res=`compare /tmp/camera-test.out $read_size "$i" 6 2 6`
+ if [ $? -eq 0 ]; then
+ err_cnt=`echo $res | cut -f 1 -d ' '`
+ if [ "$err_cnt" -ne 0 ]; then
+ pci -r dma1 --wait --multipacket -o /tmp/camera-test.out -t 1000000 &> /dev/null
+ cp /tmp/camera-test.out /tmp/camera-test.out.$err_num
+ err_num=$(($err_num + 1))
+ fi
+ byte_cnt=`echo $res | cut -f 3 -d ' '`
+ send=$(($send + $byte_cnt * 4))
+ errors=$(($errors + $err_cnt * 4))
+ else
+ failed=$(($failed + 1))
+ fi
+
+ i=$((i + 1))
+ if [ $i -eq $print_iters ]; then
+ echo "Data send: $send bytes, Errors: $errors bytes, Failed exchanges: $failed"
+# pci -r 0x9070 -s 4
+ i=1
+ fi
+done
diff --git a/tests/ipecamera/tests/run-and-decode-test.sh b/tests/ipecamera/tests/run-and-decode-test.sh
new file mode 100755
index 0000000..d355475
--- /dev/null
+++ b/tests/ipecamera/tests/run-and-decode-test.sh
@@ -0,0 +1,103 @@
+#! /bin/bash
+
+location=/mnt/fast/
+#location="./"
+duration=10000000
+wait_frame=1000000
+
+TESTS_PATH="`dirname \"$0\"`"
+TESTS_PATH="`( cd \"$TESTS_PATH\" && pwd )`"
+
+function pci {
+ PCILIB_PATH=$TESTS_PATH/..
+ LD_LIBRARY_PATH="$PCILIB_PATH" $PCILIB_PATH/pci $*
+}
+
+function stop {
+ usleep $duration
+ pci -w control 0x201 &> /dev/null
+}
+
+function reset {
+ pci -r 0x9000 -s 256 > $1.status
+ $TESTS_PATH/ipecamera/Reset_Init_all_reg_10bit.sh &> $1.reset
+}
+
+
+$TESTS_PATH/ipecamera/cfg/Reset_Init_all_reg_10bit.sh &> /dev/null
+$TESTS_PATH/ipecamera/frame.sh &> /dev/null
+rm -f bench.out
+
+pci --stop-dma
+pci --start-dma dma1
+
+
+pci -r dma1 -s 16777216 --multipacket -o /dev/null &> /dev/null
+
+pci -r dma1 -s 1 | grep -i "Error (62)" &> /dev/null
+if [ $? -ne 0 ]; then
+ echo "There is data on dma..."
+ exit
+fi
+
+echo "Starting ... "
+
+decode_failures=0
+failures=0
+failed=0
+frames=0
+fpga_failures=0
+cmosis_failures=0
+frame_rate_failures=0
+
+iter=0
+while [ 1 ]; do
+ pci -w control 0xa01 &> /dev/null
+ stop &
+
+ output="$location/test$iter.out"
+ rm -f $output
+ pci -r dma1 -o $output --wait --multipacket -t $wait_frame &> /dev/null
+
+ killall -9 usleep &> /dev/null
+ usleep 100000
+ pci -w control 0x201 &> /dev/null
+
+ if [ -f $output ]; then
+ result=`ipedec -d -v --continue $output 2>&1 | grep -iE "failed|decoded"`
+ cur_failed=`echo $result | wc -l`
+ cur_decoded=`echo $result | tail -n 1 | grep -i decoded`
+ if [ $? -ne 0 -o $cur_failed -eq 0 ]; then
+ ipedec -d -v --continue $output > $output.decode
+ decode_failures=$(($decode_failures + 1))
+ reset $output
+ else
+ cur_failed=$(($cur_failed - 1))
+ cur_frames=`echo $cur_decoded | cut -f 2 -d ' '`
+ failed=$(($failed + $cur_failed))
+ frames=$(($frames + $cur_frames))
+ fpga_status=`pci -r 0x9054 | awk '{print $2;}' | cut -c 2`
+ cmosis_status=`pci -r 0x9050 | awk '{print $2;}' | cut -c 3-4`
+ if [ "$fpga_status" != "f" ]; then
+ fpga_failures=$(($fpga_failures + 1))
+ reset $output
+ elif [ "$cmosis_status" == "7d" ]; then
+ cmosis_failures=$(($cmosis_failures + 1))
+ reset $output
+ elif [ $cur_frames -lt 10 ]; then
+ frame_rate_failures=$(($frame_rate_failures + 1))
+ reset $output
+ elif [ $cur_failed -eq 0 ]; then
+ rm -f $output
+ else
+ reset $output
+ fi
+ fi
+ else
+ failures=$(($failures + 1))
+ reset $output
+ fi
+
+ echo "Frames: $frames, Failed Frames: $failed, Failed Exchanges: $failures, Failed Decodings: $decode_failures, FPGA Failures: $fpga_failures, CMOSIS Failures: $cmosis_failures, Low Frame Rate: $frame_rate_failures"
+ iter=`expr $iter + 1`
+done