diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2018-04-30 20:12:42 +0200 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2018-05-20 19:45:38 +0200 |
commit | eb11e68412b49b0945ab6bb332ac9486f1ebeb9e (patch) | |
tree | 768091baf5dd8150d33b3f8275316bb92d31608e /src/libosmo-fl2k.c | |
parent | 16b102efcdae6c33b1761e4f2da8c507eed03bb4 (diff) | |
download | osmo-fl2k-eb11e68412b49b0945ab6bb332ac9486f1ebeb9e.tar.gz osmo-fl2k-eb11e68412b49b0945ab6bb332ac9486f1ebeb9e.tar.bz2 osmo-fl2k-eb11e68412b49b0945ab6bb332ac9486f1ebeb9e.zip |
Add support for interleaved R/G samples
This is useful for transmitting complex I/Q data on the
red and green DACs
Diffstat (limited to 'src/libosmo-fl2k.c')
-rw-r--r-- | src/libosmo-fl2k.c | 51 |
1 files changed, 44 insertions, 7 deletions
diff --git a/src/libosmo-fl2k.c b/src/libosmo-fl2k.c index 0285f9a..09380b6 100644 --- a/src/libosmo-fl2k.c +++ b/src/libosmo-fl2k.c @@ -767,6 +767,37 @@ static void *fl2k_usb_worker(void *arg) } /* Buffer format conversion functions for R, G, B DACs */ +static inline void fl2k_convert_rg_interleaved( + char *out, + char *in, + uint32_t len, + uint8_t offset) +{ + unsigned int i, j = 0; + + if (!in || !out) + return; + + for (i = 0; i < len; i += 24) { + out[i+ 6] = in[j++] + offset; + out[i+ 5] = in[j++] + offset; + out[i+ 1] = in[j++] + offset; + out[i+ 0] = in[j++] + offset; + out[i+12] = in[j++] + offset; + out[i+ 3] = in[j++] + offset; + out[i+15] = in[j++] + offset; + out[i+14] = in[j++] + offset; + out[i+10] = in[j++] + offset; + out[i+ 9] = in[j++] + offset; + out[i+21] = in[j++] + offset; + out[i+20] = in[j++] + offset; + out[i+16] = in[j++] + offset; + out[i+23] = in[j++] + offset; + out[i+19] = in[j++] + offset; + out[i+18] = in[j++] + offset; + } +} + static inline void fl2k_convert_r(char *out, char *in, uint32_t len, @@ -882,15 +913,21 @@ static void *fl2k_sample_worker(void *arg) xfer_info = (fl2k_xfer_info_t *)xfer->user_data; out_buf = (char *)xfer->buffer; - /* Re-arrange and copy bytes in buffer for DACs */ - fl2k_convert_r(out_buf, data_info.r_buf, dev->xfer_buf_len, - data_info.sampletype_signed ? 128 : 0); + if (data_info.iq_buf) { + /* Re-arrange interleaved samples and copy bytes in buffer for DACs */ + fl2k_convert_rg_interleaved(out_buf, data_info.iq_buf, + dev->xfer_buf_len, data_info.sampletype_signed ? 128 : 0); + } else { + /* Re-arrange and copy bytes in buffer for DACs */ + fl2k_convert_r(out_buf, data_info.r_buf, dev->xfer_buf_len, + data_info.sampletype_signed ? 128 : 0); - fl2k_convert_g(out_buf, data_info.g_buf, dev->xfer_buf_len, - data_info.sampletype_signed ? 128 : 0); + fl2k_convert_g(out_buf, data_info.g_buf, dev->xfer_buf_len, + data_info.sampletype_signed ? 128 : 0); - fl2k_convert_b(out_buf, data_info.b_buf, dev->xfer_buf_len, - data_info.sampletype_signed ? 128 : 0); + fl2k_convert_b(out_buf, data_info.b_buf, dev->xfer_buf_len, + data_info.sampletype_signed ? 128 : 0); + } xfer_info->seq = buf_cnt++; xfer_info->state = BUF_FILLED; |