Repository navigation
drivers: sensor: lsm6dsv16x: fix ODR handling in FIFO streaming setup - #126834
Open
MaureenHelm wants to merge 4 commits into
Open
MaureenHelm wants to merge 4 commits into
MaureenHelm wants to merge 4 commits into
Conversation
lsm6dsv16x_config_fifo() moves accel and gyro to the SFLP ODR to apply the gbias, then restores data->accel_freq and data->gyro_freq. But lsm6dsv16x_accel_set_odr_raw() updates those fields, so the restore writes back the SFLP ODR and any accel-odr above it is ignored when streaming. Save the configured ODRs before the switch. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Maureen Helm <maureen.helm@analog.com>
Changing the accel ODR right before the FIFO starts puts a settling sample at the head of every stream. The switch is only needed to apply the SFLP gbias, so skip it unless SFLP data is batched. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Maureen Helm <maureen.helm@analog.com>
TheArkadiuszGrzelka
approved these changes
Nov 25, 2026
TheArkadiuszGrzelka
left a comment
Contributor
There was a problem hiding this comment.
Fixes the SFLP gbias ODR switch in lsm6dsv16x_config_fifo(): the restore wrote back the SFLP ODR because *_set_odr_raw() overwrites accel_freq and gyro_freq, and the switch now runs only when SFLP data is batched. Both changes make sense and belong in this driver.
Read both commits against lsm6dsv16x.c (*_set_odr_raw() updates the cached fields at lines 169 and 198, so saving accel_odr and gyro_odr first is right) and the callers of lsm6dsv16x_config_fifo(). sflp_fifo is only set inside the trigger branch, so the new guard also skips the switch when the FIFO is being turned off. Nothing to raise. I did not build or run it.
lsm6dsv16x_decoder_get_frame_count() counted the words of each FIFO tag in uint8_t, while the FIFO holds up to 511 words. A capture of 256 accelerometer words reported zero frames, and a client streaming through libiio failed with -ENODATA. Count in uint16_t, the type the frame count is returned in. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Maureen Helm <maureen.helm@analog.com>
The FIFO is reconfigured, and so flushed, only when the requested FIFO triggers change. After a stream is cancelled the FIFO keeps batching, so the next stream with the same triggers starts with stale samples. If the FIFO is past its watermark, the interrupt line is already asserted when the edge interrupt is armed, and the stream never triggers. Clear the cached FIFO trigger setup when completing a cancelled request, so the next stream reconfigures and flushes the FIFO. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Maureen Helm <maureen.helm@analog.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
lsm6dsv16x_config_fifo()temporarily switches accel and gyro to the SFLP ODR so that the SFLP gbias takes effect, then restores the previous ODRs. This PR fixes two problems with that switch.lsm6dsv16x_accel_set_odr_raw()andlsm6dsv16x_gyro_set_odr_raw()updatedata->accel_freqanddata->gyro_freq, so by the time of the restore they already held the SFLP ODR. Anyaccel-odrabove the SFLP ODR was ignored when streaming. The configured ODRs are now saved before the switch.Found while testing analogdevicesinc/libiio#1631 with an
x_nucleo_iks4a1shield