Commit 65a2c177 authored by Tristan Gingold's avatar Tristan Gingold

software/kernel: add a flag to disable endianness swap

parent 892b0630
......@@ -5,51 +5,31 @@
*/
#include <linux/errno.h>
#include <asm/byteorder.h>
#ifdef CONFIG_FMC_ADC_SVEC
#include "vmebus.h"
#endif
#include "fmc-adc-100m14b4cha-private.h"
/* Endianess */
#ifndef LITTLE_ENDIAN
#define LITTLE_ENDIAN 0
#endif
#ifndef BIG_ENDIAN
#define BIG_ENDIAN 1
#endif
static void zfad_dma_done(struct zio_cset *cset);
static int __get_endian(void)
{
int i = 1;
char *p = (char *)&i;
if (p[0] == 1)
return LITTLE_ENDIAN;
else
return BIG_ENDIAN;
}
/**
* Fix endianess from big to host endianess (32bit)
*/
static void __endianness(unsigned int byte_length, void *buffer)
{
/* CPU may be little endian, VME is big endian */
if (__get_endian() == LITTLE_ENDIAN) {
/* swap samples and trig timetag all seen as 32bits words */
int i;
int size = byte_length / 4;
uint32_t *ptr = buffer;
#ifdef __LITTLE_ENDIAN
/* CPU may be little endian, VME is big endian */
/* swap samples and trig timetag all seen as 32bits words */
int i;
int size = byte_length / 4;
uint32_t *ptr = buffer;
for (i = 0; i < size; ++i, ++ptr)
*ptr = __be32_to_cpu(*ptr);
}
for (i = 0; i < size; ++i, ++ptr)
*ptr = __be32_to_cpu(*ptr);
#endif
}
struct zfad_timetag {
......@@ -310,23 +290,20 @@ static int zfad_dma_block_to_pages(struct page **pages, unsigned int nr_pages,
}
static void zfad_dma_context_exit_svec(struct zio_cset *cset,
struct zfad_block *zfad_block)
{
__endianness(zfad_block->block->datalen,
zfad_block->block->data);
kfree(zfad_block->dma_ctx);
}
static void zfad_dma_context_exit(struct zio_cset *cset,
struct zfad_block *zfad_block)
{
struct fa_dev *fa = cset->zdev->priv_d;
if (fa_is_flag_set(fa, FMC_ADC_SVEC))
zfad_dma_context_exit_svec(cset, zfad_block);
if (fa_is_flag_set(fa, FMC_ADC_SVEC)) {
/* Fix data endianness */
if (!fa_is_flag_set(fa, FMC_ADC_DMA_LITTLE_ENDIAN))
__endianness(zfad_block->block->datalen,
zfad_block->block->data);
/* Free DMA descriptor */
kfree(zfad_block->dma_ctx);
}
}
static int zfad_dma_context_init_svec(struct zio_cset *cset,
......
......@@ -16,6 +16,7 @@
* NOTE any other carrier is not supported!
*/
#define FMC_ADC_SVEC BIT(3)
#define FMC_ADC_DMA_LITTLE_ENDIAN BIT(4)
struct fmc_adc_platform_data {
unsigned long flags;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment