Commit 22a66c15 authored by Federico Vaga's avatar Federico Vaga

kernel: directly count trigger sample as post_sample

It should make the code clear since the +1 and -1 (for the trigger sample)
is done only when accessing the hardware. Otherwise, we cansider the
trigger sample as part of the post samples
Signed-off-by: Federico Vaga's avatarFederico Vaga <federico.vaga@cern.ch>
Signed-off-by: 's avatarDimitris Lampridis <Dimitris.Lampridis@cern.ch>
parent 68ca1db3
......@@ -143,12 +143,8 @@ void zfad_dma_done(struct zio_cset *cset)
ctrl->attr_channel.ext_val[FA100M14B4C_DATTR_ACQ_START_F] =
ztstamp.bins;
/*
* resize the datalen, by removing the trigger tstamp and the
* extra samples (trigger samples, 1 for each channel)
*/
block->datalen = block->datalen - FA_TRIG_TIMETAG_BYTES
- (ctrl->ssize * FA100M14B4C_NCHAN);
/* resize the datalen, by removing the trigger tstamp */
block->datalen = block->datalen - FA_TRIG_TIMETAG_BYTES;
/* update seq num */
ctrl->seq_num = i;
......
......@@ -109,10 +109,11 @@ static int zfat_conf_set(struct device *dev, struct zio_attribute *zattr,
}
break;
case ZFAT_POST:
if (!tmp_val) {
dev_err(dev, "post samples cannot be 0 (minimum 1)\n");
if (tmp_val < 2) {
dev_err(dev, "minimum post samples 2 (HW limitation)\n");
return -EINVAL;
}
tmp_val--; /* Remove one sample for the trigger */
break;
case ZFAT_SW:
/* Fire if software trigger is enabled (index 5) */
......@@ -163,9 +164,13 @@ static int zfat_info_get(struct device *dev, struct zio_attribute *zattr,
*usr_val = fa_readl(fa, fa->fa_adc_csr_base, &zfad_regs[zattr->id]);
switch (zattr->id) {
case ZFAT_POST:
(*usr_val)++; /* add the trigger sample */
break;
case ZFAT_DLY:
/* Add channel signal transmission delay */
*usr_val -= fa->trig_compensation;
break;
}
return 0;
......@@ -339,12 +344,8 @@ static int zfat_arm_trigger(struct zio_ti *ti)
* (4*32bits word) size should be 32bits word aligned
* ti->nsamples is the sum of (pre-samp+ post-samp)*4chan
* because it's the interleave channel.
*
* +FA_NCHAN because of the trigger samples (1 for each channel) which
* will discard later on DMA done (Actually, we will discard the last
* post-sample because we count the trigger sample as post-sample)
*/
size = (interleave->current_ctrl->ssize * (ti->nsamples + FA100M14B4C_NCHAN))
size = (interleave->current_ctrl->ssize * ti->nsamples)
+ FA_TRIG_TIMETAG_BYTES;
/* check if size is 32 bits word aligned: should be always the case */
if (size % 4) {
......
......@@ -423,11 +423,9 @@ static inline int zfat_overflow_detection(struct zio_ti *ti, unsigned int addr,
ti_zattr[ZIO_ATTR_TRIG_N_SHOTS].value;
/*
* +1 because of the trigger samples, which is not counted as
* post-sample by the ADC
* +2 because of the timetag at the end
*/
nsamples = pre_t + post_t + 1;
nsamples = pre_t + post_t;
shot_size = ((nsamples + 2) * ti->cset->ssize) * FA100M14B4C_NCHAN;
if ( (shot_size * nshot_t) > FA100M14B4C_MAX_ACQ_BYTE ) {
dev_err(&ti->head.dev, "Cannot acquire, dev memory overflow\n");
......
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