Commit 90e7aa79 authored by Federico Vaga's avatar Federico Vaga

lib:zio: bugfix select channel to acquire

Select the channel to acquire instead of defaulting to 'interleave'
using a completely wrong flag
Signed-off-by: Federico Vaga's avatarFederico Vaga <federico.vaga@cern.ch>
parent cdbfe658
......@@ -84,6 +84,7 @@ extern struct adc_board_type adc_genericfake;
*/
struct __adc_dev_zio {
unsigned int cset; /**< channel-set index */
int chan; /**< channel index: -1 for interleaved */
int fdc; /**< control file descriptor */
int fdd; /**< data file descriptor */
uint32_t dev_id; /**< ZIO device ID */
......@@ -136,10 +137,11 @@ extern struct adc_board_type adc_ziofake;
/* ZIO boards */
struct adc_dev *adc_zio_open(const struct adc_board_type *b,
unsigned int dev_id,
unsigned long totalsamples,
unsigned int nbuffer,
unsigned long flags);
unsigned int dev_id,
unsigned int cset, int chan,
unsigned long totalsamples,
unsigned int nbuffer,
unsigned long flags);
int adc_zio_close(struct adc_dev *dev);
......
......@@ -53,6 +53,7 @@ static int adc_flush_input(struct __adc_dev_zio *fa)
struct adc_dev *adc_zio_open(const struct adc_board_type *b,
unsigned int dev_id,
unsigned int cset, int chan,
unsigned long totalsamples,
unsigned int nbuffer,
unsigned long flags)
......@@ -61,7 +62,6 @@ struct adc_dev *adc_zio_open(const struct adc_board_type *b,
struct stat st;
char *syspath, *devpath, fname[128];
int udev_zio_dir = 1;
unsigned long chan = flags;
/* Check if device exists by looking in sysfs */
asprintf(&syspath, "%s/%s-%04x", ZIO_SYS_PATH, b->devname, dev_id);
......@@ -80,16 +80,24 @@ struct adc_dev *adc_zio_open(const struct adc_board_type *b,
goto out_fa_alloc;
fa->sysbase = syspath;
fa->devbase = devpath;
fa->cset = 0;
fa->cset = cset;
fa->chan = chan;
/* Open char devices */
if (flags & ADC_F_FLUSH)
chan = (unsigned long)'i';
if (chan == ~0) {
sprintf(fname, "%s-%d-i-ctrl", fa->devbase, fa->cset);
fa->fdc = open(fname, O_RDONLY);
sprintf(fname, "%s-%d-i-data", fa->devbase, fa->cset);
fa->fdd = open(fname, O_RDONLY);
} else {
sprintf(fname, "%s-%d-%d-ctrl",
fa->devbase, fa->cset, fa->chan);
fa->fdc = open(fname, O_RDONLY);
sprintf(fname, "%s-%d-%d-data",
fa->devbase, fa->cset, fa->chan);
fa->fdd = open(fname, O_RDONLY);
}
sprintf(fname, "%s-0-%c-ctrl", fa->devbase, (char)chan);
fa->fdc = open(fname, O_RDONLY);
sprintf(fname, "%s-0-%c-data", fa->devbase, (char)chan);
fa->fdd = open(fname, O_RDONLY);
if (fa->fdc < 0 || fa->fdd < 0)
goto out_fa_open;
......
......@@ -24,7 +24,7 @@ static struct adc_dev *adc_ziofake_open(const struct adc_board_type *b,
unsigned int nbuffer,
unsigned long flags)
{
struct adc_dev *dev = adc_zio_open(b, dev_id, totalsamples,
struct adc_dev *dev = adc_zio_open(b, dev_id, 0, 0, totalsamples,
nbuffer, flags);
struct __adc_dev_zio *fk = to_dev_zio(dev);
......
......@@ -153,7 +153,7 @@ static struct adc_dev *adc_100m14b4cha_open(const struct adc_board_type *b,
unsigned int nbuffer,
unsigned long flags)
{
struct adc_dev *dev = adc_zio_open(b, dev_id, totalsamples,
struct adc_dev *dev = adc_zio_open(b, dev_id, 0, -1, totalsamples,
nbuffer, 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