aboutsummaryrefslogtreecommitdiffstats
path: root/host/apps
diff options
context:
space:
mode:
Diffstat (limited to 'host/apps')
-rw-r--r--host/apps/omap_debug/usrp-e-mm-loopback.c27
-rw-r--r--host/apps/omap_debug/usrp_e.h35
2 files changed, 34 insertions, 28 deletions
diff --git a/host/apps/omap_debug/usrp-e-mm-loopback.c b/host/apps/omap_debug/usrp-e-mm-loopback.c
index 71519d535..a1da926a2 100644
--- a/host/apps/omap_debug/usrp-e-mm-loopback.c
+++ b/host/apps/omap_debug/usrp-e-mm-loopback.c
@@ -1,5 +1,6 @@
#include <stdio.h>
#include <sys/types.h>
+#include <sys/ioctl.h>
#include <fcntl.h>
#include <pthread.h>
#include <stdlib.h>
@@ -20,12 +21,6 @@ struct pkt {
short data[1024-6];
};
-/* delete after usrp_e.h updated */
-struct ring_buffer_info {
- int flags;
- int len;
-};
-
struct ring_buffer_info (*rxi)[];
struct ring_buffer_info (*txi)[];
struct pkt (*rx_buf)[200];
@@ -182,6 +177,8 @@ int main(int argc, char *argv[])
struct sched_param s = {
.sched_priority = 1
};
+ struct usrp_e_ring_buffer_size_t rb_size;
+ int ret, map_size, page_size;
void *rb;
if (argc < 2) {
@@ -194,7 +191,14 @@ int main(int argc, char *argv[])
fp = open("/dev/usrp_e0", O_RDWR);
printf("fp = %d\n", fp);
- rb = mmap(0, 102 * 4096, PROT_READ|PROT_WRITE, MAP_SHARED, fp, 0);
+ page_size = getpagesize();
+
+ ret = ioctl(fp, USRP_E_GET_RB_INFO, &rb_size);
+
+ map_size = (rb_size.num_pages_rx_flags + rb_size.num_pages_tx_flags) * page_size +
+ (rb_size.num_rx_frames + rb_size.num_tx_frames) * (page_size >> 1);
+
+ rb = mmap(0, map_size, PROT_READ|PROT_WRITE, MAP_SHARED, fp, 0);
if (rb == MAP_FAILED) {
perror("mmap failed");
return -1;
@@ -203,9 +207,12 @@ int main(int argc, char *argv[])
printf("rb = %X\n", rb);
rxi = rb;
- rx_buf = rb + 4096;
- txi = rb + 4096 + 4096 * 100;
- tx_buf = rb + 4096 * 2 + 4096 * 100;
+ rx_buf = rb + (rb_size.num_pages_rx_flags * page_size);
+ txi = rb + (rb_size.num_pages_rx_flags * page_size) +
+ (rb_size.num_rx_frames * page_size >> 1);
+ tx_buf = rb + (rb_size.num_pages_rx_flags * page_size) +
+ (rb_size.num_rx_frames * page_size >> 1) +
+ (rb_size.num_pages_tx_flags * page_size);
printf("rxi = %X, rx_buf = %X, txi = %X, tx_buf = %X\n", rxi, rx_buf, txi, tx_buf);
diff --git a/host/apps/omap_debug/usrp_e.h b/host/apps/omap_debug/usrp_e.h
index b098ad114..fd38027d4 100644
--- a/host/apps/omap_debug/usrp_e.h
+++ b/host/apps/omap_debug/usrp_e.h
@@ -34,8 +34,8 @@ struct usrp_e_ctl32 {
#define UE_SPI_TXRX 1
/* Defines for spi ctrl register */
-#define UE_SPI_CTRL_TXNEG (1 << 10)
-#define UE_SPI_CTRL_RXNEG (1 << 9)
+#define UE_SPI_CTRL_TXNEG (BIT(10))
+#define UE_SPI_CTRL_RXNEG (BIT(9))
#define UE_SPI_PUSH_RISE 0
#define UE_SPI_PUSH_FALL UE_SPI_CTRL_TXNEG
@@ -64,25 +64,24 @@ struct usrp_e_i2c {
#define USRP_E_SPI _IOWR(USRP_E_IOC_MAGIC, 0x24, struct usrp_e_spi)
#define USRP_E_I2C_READ _IOWR(USRP_E_IOC_MAGIC, 0x25, struct usrp_e_i2c)
#define USRP_E_I2C_WRITE _IOW(USRP_E_IOC_MAGIC, 0x26, struct usrp_e_i2c)
+#define USRP_E_GET_RB_INFO _IOR(USRP_E_IOC_MAGIC, 0x27, struct usrp_e_ring_buffer_size_t)
-/* Data transfer frame definition */
-
-struct usrp_transfer_frame {
- __u32 status;
- __u32 len;
- __u8 buf[];
+/* Flag defines */
+#define RB_USER (1<<0)
+#define RB_KERNEL (1<<1)
+#define RB_OVERRUN (1<<2)
+#define RB_DMA_ACTIVE (1<<3)
+
+struct ring_buffer_info {
+ int flags;
+ int len;
};
-/* Flag defines */
-#define RB_USER (1 << 0)
-#define RB_KERNEL (1 << 1)
-#define RB_OVERRUN (1 << 2)
-#define RB_DMA_ACTIVE (1 << 3)
-
-struct ring_buffer_entry {
- unsigned int flags;
- unsigned long dma_addr;
- struct usrp_transfer_frame *frame_addr;
+struct usrp_e_ring_buffer_size_t {
+ int num_pages_rx_flags;
+ int num_rx_frames;
+ int num_pages_tx_flags;
+ int num_tx_frames;
};
#endif