Commit 3211e8c4 authored by Federico Vaga's avatar Federico Vaga

[fix] fa-zio-drv.c: fix device address offset in single-shot mode

In single-shot mode, the ADC use the DDR memory as a circular buffer
and it continuously writes into the memory until the trigger fire
occurs. When the trigger occur we know where our samples are stored
thanks to the trigger_position register.
Signed-off-by: 's avatarFederico Vaga <federico.vaga@gmail.com>
Signed-off-by: Michel Arruat's avatarMichel Arruat <michel.arruat@cern.ch>
parent e95ee40e
......@@ -761,6 +761,9 @@ static void zfat_get_time_stamp(struct fa_dev *fa, struct zio_timestamp *ts)
* Trigger fires. This function stores the time-stamp in the current_ctrl and
* in the pre-allocated block. Then it increments the sequence number both in
* current_ctrl and in the pre-allocated block.
*
* If the device is working in single-shot mode, once the trigger fire
* interrupt occurs we must fix the dev_mem_addr of the block.
*/
static void zfat_irq_trg_fire(struct zio_cset *cset)
{
......@@ -768,6 +771,7 @@ static void zfat_irq_trg_fire(struct zio_cset *cset)
struct fa_dev *fa = cset->zdev->priv_d;
struct zfad_block *zfad_block = interleave->priv_d;
struct zio_control *ctrl;
uint32_t fixed_mem_ptr, trg_pos, pre_samp;
dev_dbg(fa->fmc->hwdev, "Trigger fire %i/%i\n",
fa->n_fires + 1, fa->n_shots);
......@@ -777,6 +781,19 @@ static void zfat_irq_trg_fire(struct zio_cset *cset)
return;
}
/* Fix dev_mem_addr in single-shot mode */
if (fa->n_shots == 1) {
pre_samp = cset->trig->zattr_set
.std_zattr[ZIO_ATTR_TRIG_PRE_SAMP].value;
/* Get trigger position in DDR */
zfa_common_info_get(fa, ZFAT_POS, &trg_pos);
/* translate from sample count to memory offset */
fixed_mem_ptr = (trg_pos - pre_samp) * cset->ssize;
fixed_mem_ptr *= cset->n_chan;
zfad_block[fa->n_fires].dev_mem_ptr = fixed_mem_ptr;
}
/* Get control from pre-allocated block */
ctrl = zio_get_ctrl(zfad_block[fa->n_fires].block);
/* Update timestamp */
......
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