linux_driver: fixup a few flash write bugs

This commits fixes a buffer length issues and pipe directionality issues.
lib: Fix RXVGA1 set/get to convert from dB to raw value

The formula used is a very crude quadratic approximation from the
3 data points given in the programming manual ... for something more
precise, we'd need a LUT. But it may vary with temp and device anyway.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
lib: Fix TXVGA2/RXVGA2, avoid casting (int*) to (uint8_t *)

Not everyone is little endian !

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
lib: Fix band selection

There was two issues :
 - Swap between the RX/TX GPIOs controlling the switch
 - The proper LNA was not being selected inside the LMS

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
lib: Avoid warning in lib when using lms_printf in 'if'

When you have something like:

if (bad_thing_happenned)
    lms_printf("Panic !");

defining lms_printf to nothing creates a warning.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
lib/lms: Clean up of the PLL parameters setting

Using 64 bit math is just way easier to read and
just as safe and precise.

Also cleanup random bits in that area

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
lib/lms: New VCOCAP search algorithm

Seems more resilient to errors than the previous one.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
lib/lms: Add a function to convert a lms_freq struct to frequency in Hz

... and use it.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
cli: Added rx/tx threads and buffers. TODO is read/writes
cli: [Untested] First "full" cut at RX/TX implementation
cli: Fixed incorrect execution of -b -s <script>
linux_driver: Added patch from mainline that I failed to merge
cli: Fixed race condition. Split rxtx alloc/free routines up.

The corruption we were seeing was due to the RX task starting to
execute before the rxtx_data = rxtx_data_alloc() returned.
Therefore, the cli_state didn't yet have a valid rxtx_data pointer.

To address this, the rxtx data allocation has been split to
an allocation and a start_task, as it was poor design to have
allocation/init routines kicking off threads. There's a analagous
pair of routines for stopping the tasks before deinitializing.

Misc cleanup was also performed on buffer naming and general line
sizes and such.