Skip to content

Commit

Permalink
demux_sample: Add support ofr 64-bit samples
Browse files Browse the repository at this point in the history
This commit adds support for 64-bit wide sample.

Signed-off-by: Sergiu Cuciurean <[email protected]>
  • Loading branch information
scuciurean authored and dNechita committed May 11, 2022
1 parent 9292f5e commit 2cbff21
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
9 changes: 8 additions & 1 deletion osc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1184,13 +1184,20 @@ static ssize_t demux_sample(const struct iio_channel *chn,
*(info->data_ref + info->offset++) = (gfloat) val;
else
*(info->data_ref + info->offset++) = (gfloat) (uint16_t)val;
} else {
} else if (size == 4) {
int32_t val;
iio_channel_convert(chn, &val, sample);
if (format->is_signed)
*(info->data_ref + info->offset++) = (gfloat) val;
else
*(info->data_ref + info->offset++) = (gfloat) (uint32_t)val;
} else {
int64_t val;
iio_channel_convert(chn, &val, sample);
if (format->is_signed)
*(info->data_ref + info->offset++) = (gfloat) val;
else
*(info->data_ref + info->offset++) = (gfloat) (uint64_t)val;
}

return size;
Expand Down
9 changes: 8 additions & 1 deletion plugins/spectrum_analyzer.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,20 @@ static ssize_t demux_sample(const struct iio_channel *chn,
*(info->data_ref + info->offset++) = (gfloat) val;
else
*(info->data_ref + info->offset++) = (gfloat) (uint16_t)val;
} else {
} else if (size == 4) {
int32_t val;
iio_channel_convert(chn, &val, sample);
if (format->is_signed)
*(info->data_ref + info->offset++) = (gfloat) val;
else
*(info->data_ref + info->offset++) = (gfloat) (uint32_t)val;
} else {
int64_t val;
iio_channel_convert(chn, &val, sample);
if (format->is_signed)
*(info->data_ref + info->offset++) = (gfloat) val;
else
*(info->data_ref + info->offset++) = (gfloat) (uint64_t)val;
}

return size;
Expand Down

0 comments on commit 2cbff21

Please sign in to comment.