<div dir="ltr">Here's what I'm doing which isn't clean either <a href="https://github.com/iafilatov/libfprint/blob/elan/libfprint/drivers/elan.c#L525" target="_blank">https://github.com/iafilatov/libfprint/blob/elan/libfprint/drivers/elan.c#L525</a> but allows to contain the ugliness to a small part of code. You actually don't need to deactivate manually until libfprint calls dev_deactivate. You only need to keep submitting images till dev_deactivate is called. How you do it is up to you. The only quirk is that you need to give libfprint a chance to do it asynchronously.<div><br></div><div>And I'm not sure but I think this is because initially there were no enroll stages (just a theory) so everything was fine. And then the stages were added and it became somewhat awkward. Maybe there should just be a callback that the drivers should call after they've submitted the image, and libfprint would either do nothing if it needs more images (and the drivers would then repeat capture as they do now) or call dev_deactivate. I think the drivers should already handle dev_deactivate properly on any stage. The changes to the drivers should be minimal this way.</div><div><br></div><div><br></div><div class="gmail_quote"><div dir="ltr">On Fri, Feb 16, 2018 at 3:08 PM Marco Trevisan (Treviño) <<a href="mailto:mail@3v1n0.net" target="_blank">mail@3v1n0.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Igor,<br>
<br>
2018-02-16 8:58 GMT+01:00 Igor Filatov <<a href="mailto:ia.filatov@gmail.com" target="_blank">ia.filatov@gmail.com</a>>:<br>
> I think it would be better if libfprint simply called dev_activate each time<br>
> it needed an image, including each enroll step, and then called<br>
> dev_deactivate when it's done. Drivers should know whether they need to<br>
> reactivate or not. But this will require changes to all the drivers of the<br>
> devices that return images... which should actually amount to a few deleted<br>
> lines.<br>
<br>
Yeah, well I thought about changing this in all the places, but I<br>
didn't want to break drivers that I could not test, so I though this<br>
was safer, although I recognize isn't the cleanest code. But if you<br>
think this flag is acceptable, we can probably add helper functions to<br>
keep this a bit nicer.<br>
<br>
At the beginning I was doing this at my driver level (see<br>
<a href="https://github.com/3v1n0/libfprint/commit/8cb5e6945cc26" rel="noreferrer" target="_blank">https://github.com/3v1n0/libfprint/commit/8cb5e6945cc26</a>), but I didn't<br>
like to keep it there (nor I wanted to introduce other flags for the<br>
driver to keep the state, since imgdrv is supposed to do this already.<br>
So, while I could go back to that solution, I'd really prefer not to<br>
make the driver to handle such things.<br>
<br>
And yes, having this flag to be more generic to ENROLL only is<br>
something we can do too, let me know if there's any preference and I<br>
can look into that.<br>
</blockquote></div></div>