+/* Software trigger to determine exact trigger position. */
+static int get_trigger_offset(uint16_t *samples, uint16_t last_sample,
+ struct sigma_trigger *t)
+{
+ int i;
+
+ for (i = 0; i < 8; ++i) {
+ if (i > 0)
+ last_sample = samples[i-1];
+
+ /* Simple triggers. */
+ if ((samples[i] & t->simplemask) != t->simplevalue)
+ continue;
+
+ /* Rising edge. */
+ if ((last_sample & t->risingmask) != 0 || (samples[i] &
+ t->risingmask) != t->risingmask)
+ continue;
+
+ /* Falling edge. */
+ if ((last_sample & t->fallingmask) != t->fallingmask ||
+ (samples[i] & t->fallingmask) != 0)
+ continue;
+
+ break;
+ }
+
+ /* If we did not match, return original trigger pos. */
+ return i & 0x7;
+}
+