Probably your best bet would be to find a binding for the pjsip library. It has a command line here but I’m not sure how that would work with incoming calls. It’s the library Asterisk is switching to so it’s pretty battle-tested.
On the GPIO side, if you’re using ioctls I would use the new GPIO2 interface - it’s not entirely obvious the older one is deprecated. It’s event driven so you don’t have to spin-poll, and can do de-bouncing kernel-side. Of course Linus’s “don’t break userspace” mantra means the old interface will work for the foreseeable future.