Hello community,

here is the log from the commit of package airspyhf for openSUSE:Factory 
checked in at 2018-02-26 23:25:12
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/airspyhf (Old)
 and      /work/SRC/openSUSE:Factory/.airspyhf.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "airspyhf"

Mon Feb 26 23:25:12 2018 rev:2 rq:579908 version:1.1.0+git.20180217

Changes:
--------
--- /work/SRC/openSUSE:Factory/airspyhf/airspyhf.changes        2017-07-30 
11:26:47.510374589 +0200
+++ /work/SRC/openSUSE:Factory/.airspyhf.new/airspyhf.changes   2018-02-26 
23:25:13.950160317 +0100
@@ -1,0 +2,23 @@
+Sun Feb 25 10:44:46 UTC 2018 - [email protected]
+
+- Update to version 1.1.0+git.20180217:
+  * Updated the version number to 1.1.0
+  * Added LNA, ATT, AGC and Threshold settings for the HF tuner.
+  * Improved the convergence of the IQ balancer - again.
+  * New heuristic for faster convergence in the IQ correction algorithm.
+  * Bugfix airspyhf_open_device() with given serial for device identification
+  * allow static compilation with definition of 'STATIC_AIRSPYHFPLUS'
+  * airspyhf_list_devices accepts NULL as serials pointer to only get the 
number of devices
+  * remove a compile warning under Linux
+  * Improved the image rejection algorithm for the Airspy HF+
+
+-------------------------------------------------------------------
+Sat Oct 21 11:29:42 UTC 2017 - [email protected]
+
+- Update to version 0.0.0+git.20170930:
+  * Fixed enum prefix
+  * Added API for user application output pins
+  * Added APIs for getting library and firmware version
+  * Added API for enumerating multiple devices
+
+-------------------------------------------------------------------

Old:
----
  airspyhf-0.0.0+git.20170718.tar.xz

New:
----
  airspyhf-1.1.0+git.20180217.tar.xz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ airspyhf.spec ++++++
--- /var/tmp/diff_new_pack.dMuu9L/_old  2018-02-26 23:25:14.950124354 +0100
+++ /var/tmp/diff_new_pack.dMuu9L/_new  2018-02-26 23:25:14.962123923 +0100
@@ -1,6 +1,7 @@
 #
 # spec file for package airspyhf
 #
+# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
 # Copyright (c) 2017, Martin Hauke <[email protected]>
 #
 # All modifications and additions to the file contributed by third parties
@@ -20,7 +21,7 @@
 %define airspyhf_group    airspyhf
 %define libname lib%{name}%{sover}
 Name:           airspyhf
-Version:        0.0.0+git.20170718
+Version:        1.1.0+git.20180217
 Release:        0
 Summary:        Support programs for Airspy HF+ SDR
 License:        BSD-3-Clause

++++++ _service ++++++
--- /var/tmp/diff_new_pack.dMuu9L/_old  2018-02-26 23:25:15.022121766 +0100
+++ /var/tmp/diff_new_pack.dMuu9L/_new  2018-02-26 23:25:15.022121766 +0100
@@ -5,7 +5,7 @@
     <param name="scm">git</param>
     <param name="changesgenerate">enable</param>
     <param name="filename">airspyhf</param>
-    <param name="versionformat">0.0.0+git.%cd</param>
+    <param name="versionformat">1.1.0+git.%cd</param>
   </service>
   <service mode="disabled" name="recompress">
     <param name="file">*.tar</param>

++++++ _servicedata ++++++
--- /var/tmp/diff_new_pack.dMuu9L/_old  2018-02-26 23:25:15.066120183 +0100
+++ /var/tmp/diff_new_pack.dMuu9L/_new  2018-02-26 23:25:15.066120183 +0100
@@ -1,4 +1,4 @@
 <servicedata>
 <service name="tar_scm">
                 <param 
name="url">https://github.com/airspy/airspyhf.git</param>
-              <param 
name="changesrevision">4f1467032fea8bed2e672aa265b96897303acea0</param></service></servicedata>
\ No newline at end of file
+              <param 
name="changesrevision">12de1d5e40223e31f71d59ab07caab81e6c3d733</param></service></servicedata>
\ No newline at end of file

++++++ airspyhf-0.0.0+git.20170718.tar.xz -> airspyhf-1.1.0+git.20180217.tar.xz 
++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/airspyhf-0.0.0+git.20170718/libairspyhf/src/airspyhf.c 
new/airspyhf-1.1.0+git.20180217/libairspyhf/src/airspyhf.c
--- old/airspyhf-0.0.0+git.20170718/libairspyhf/src/airspyhf.c  2017-07-18 
01:39:52.000000000 +0200
+++ new/airspyhf-1.1.0+git.20180217/libairspyhf/src/airspyhf.c  2018-02-17 
14:48:26.000000000 +0100
@@ -45,7 +45,9 @@
 #define false 0
 #endif
 
+#ifndef M_PI
 #define M_PI (3.14159265359)
+#endif
 
 #define MAX(a,b) ((a) > (b) ? a : b)
 #define MIN(a,b) ((a) < (b) ? a : b)
@@ -113,7 +115,6 @@
        volatile int received_buffer_count;
        airspyhf_complex_float_t *output_buffer;
        void* ctx;
-//     enum airspyhf_sample_type sample_type;
 };
 
 typedef struct calibration_record
@@ -125,6 +126,8 @@
 static const uint16_t airspyhf_usb_vid = 0x03EB;
 static const uint16_t airspyhf_usb_pid = 0x800C;
 
+static int airspyhf_config_read(airspyhf_device_t* device, uint8_t *buffer, 
uint16_t length);
+
 static int cancel_transfers(airspyhf_device_t* device)
 {
        uint32_t transfer_index;
@@ -574,10 +577,7 @@
        ssize_t cnt;
        int serial_descriptor_index;
        struct libusb_device_descriptor device_descriptor;
-       char serial_number_expected[AIRSPYHF_SERIAL_SIZE + 1];
        unsigned char serial_number[AIRSPYHF_SERIAL_SIZE + 1];
-       uint32_t serial_number_msb_val;
-       uint32_t serial_number_lsb_val;
 
        libusb_dev_handle = &device->usb_device;
        *libusb_dev_handle = NULL;
@@ -612,19 +612,19 @@
                                                serial_descriptor_index,
                                                serial_number,
                                                sizeof(serial_number));
-                                       if (serial_number_len == 
AIRSPYHF_SERIAL_SIZE)
-                                       {
-                                               
serial_number[AIRSPYHF_SERIAL_SIZE] = 0;
-                                               upper_string(serial_number, 
AIRSPYHF_SERIAL_SIZE);
-                                               serial_number_msb_val = 
(uint32_t)(serial_number_val >> 32);
-                                               serial_number_lsb_val = 
(uint32_t)(serial_number_val & 0xFFFFFFFF);
-
-                                               sprintf(serial_number_expected, 
"%s%08X%08X",
-                                                       
str_prefix_serial_airspyhf,
-                                                       serial_number_msb_val,
-                                                       serial_number_lsb_val);
 
-                                               if (strncmp((const 
char*)serial_number, serial_number_expected, AIRSPYHF_SERIAL_SIZE) == 0)
+                                       if (serial_number_len == 
AIRSPYHF_SERIAL_SIZE && !memcmp(str_prefix_serial_airspyhf, serial_number, 
STR_PREFIX_SERIAL_AIRSPYHF_SIZE))
+                                       {
+                                               uint64_t serial = 
SERIAL_NUMBER_UNUSED;
+                                               // use same code to detemine 
device's serial number as in airspyhf_list_devices()
+                                               {
+                                                       char *start, *end;
+                                                       
serial_number[AIRSPYHF_SERIAL_SIZE] = 0;
+                                                       start = 
(char*)(serial_number + STR_PREFIX_SERIAL_AIRSPYHF_SIZE);
+                                                       end = NULL;
+                                                       serial = 
strtoull(start, &end, 16);
+                                               }
+                                               if (serial == serial_number_val)
                                                {
                                                        result = 
libusb_set_configuration(dev_handle, 1);
                                                        if (result != 0)
@@ -711,7 +711,88 @@
        return;
 }
 
-static int airspyhf_config_read(airspyhf_device_t* device, uint8_t *buffer, 
uint16_t length);
+int airspyhf_list_devices(uint64_t *serials, int count)
+{
+       libusb_device_handle* libusb_dev_handle;
+       struct libusb_context *context;
+       libusb_device** devices = NULL;
+       libusb_device *dev;
+       struct libusb_device_descriptor device_descriptor;
+
+       int serial_descriptor_index;
+       int serial_number_len;
+       int output_count;
+       int i;
+       unsigned char serial_number[AIRSPYHF_SERIAL_SIZE + 1];
+
+       if (serials)
+       {
+               memset(serials, 0, sizeof(uint64_t) * count);
+       }
+
+       if (libusb_init(&context) != 0)
+       {
+               return AIRSPYHF_ERROR;
+       }
+
+       if (libusb_get_device_list(context, &devices) < 0)
+       {
+               return AIRSPYHF_ERROR;
+       }
+
+       i = 0;
+       output_count = 0;
+       while ((dev = devices[i++]) != NULL && (!serials || output_count < 
count))
+       {
+               libusb_get_device_descriptor(dev, &device_descriptor);
+
+               if ((device_descriptor.idVendor == airspyhf_usb_vid) &&
+                       (device_descriptor.idProduct == airspyhf_usb_pid))
+               {
+                       serial_descriptor_index = 
device_descriptor.iSerialNumber;
+                       if (serial_descriptor_index > 0)
+                       {
+                               if (libusb_open(dev, &libusb_dev_handle) != 0)
+                               {
+                                       continue;
+                               }
+
+                               serial_number_len = 
libusb_get_string_descriptor_ascii(libusb_dev_handle,
+                                       serial_descriptor_index,
+                                       serial_number,
+                                       sizeof(serial_number));
+
+                               if (serial_number_len == AIRSPYHF_SERIAL_SIZE 
&& !memcmp(str_prefix_serial_airspyhf, serial_number, 
STR_PREFIX_SERIAL_AIRSPYHF_SIZE))
+                               {
+                                       char *start, *end;
+                                       uint64_t serial;
+
+                                       serial_number[AIRSPYHF_SERIAL_SIZE] = 0;
+                                       start = (char*)(serial_number + 
STR_PREFIX_SERIAL_AIRSPYHF_SIZE);
+                                       end = NULL;
+                                       serial = strtoull(start, &end, 16);
+                                       if (serial == 0 && start == end)
+                                       {
+                                               libusb_close(libusb_dev_handle);
+                                               continue;
+                                       }
+
+                                       if (serials)
+                                       {
+                                               serials[output_count] = serial;
+                                       }
+                                       output_count++;
+                               }
+
+                               libusb_close(libusb_dev_handle);
+                       }
+               }
+       }
+
+       libusb_free_device_list(devices, 1);
+       libusb_exit(context);
+       return output_count;
+}
 
 static int airspyhf_open_init(airspyhf_device_t** device, uint64_t 
serial_number)
 {
@@ -816,6 +897,13 @@
        return AIRSPYHF_SUCCESS;
 }
 
+void ADDCALL airspyhf_lib_version(airspyhf_lib_version_t* lib_version)
+{
+       lib_version->major_version = AIRSPYHF_VER_MAJOR;
+       lib_version->minor_version = AIRSPYHF_VER_MINOR;
+       lib_version->revision = AIRSPYHF_VER_REVISION;
+}
+
 int ADDCALL airspyhf_open_sn(airspyhf_device_t** device, uint64_t 
serial_number)
 {
        int result;
@@ -988,7 +1076,7 @@
 {
        const int tuning_alignment = 1000;
        const int if_shift = 5000;
-       const uint32_t lo_low_khz = 150;
+       const uint32_t lo_low_khz = 200;
 
        int result;
        uint8_t buf[4];
@@ -1133,3 +1221,147 @@
        
        return AIRSPYHF_SUCCESS;        
 }
+
+int ADDCALL airspyhf_version_string_read(airspyhf_device_t* device, char* 
version, uint8_t length)
+{
+       int result;
+       char version_local[MAX_VERSION_STRING_SIZE];
+
+       result = libusb_control_transfer(
+               device->usb_device,
+               LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_VENDOR | 
LIBUSB_RECIPIENT_DEVICE,
+               AIRSPYHF_GET_VERSION_STRING,
+               0,
+               0,
+               (unsigned char*) version_local,
+               (MAX_VERSION_STRING_SIZE - 1),
+               0);
+
+       if (result < 0)
+       {
+               return AIRSPYHF_ERROR;
+       }
+       else
+       {
+               if (length > 0)
+               {
+                       memcpy(version, version_local, length - 1);
+                       version[length - 1] = 0;
+                       return AIRSPYHF_SUCCESS;
+               }
+               else
+               {
+                       return AIRSPYHF_ERROR;
+               }
+       }
+}
+
+int ADDCALL airspyhf_set_user_output(airspyhf_device_t* device, 
airspyhf_user_output_t pin, airspyhf_user_output_state_t value)
+{
+       int result;
+
+       result = libusb_control_transfer(
+               device->usb_device,
+               LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_VENDOR | 
LIBUSB_RECIPIENT_DEVICE,
+               AIRSPYHF_SET_USER_OUTPUT,
+               (uint16_t)pin,
+               (uint16_t)value,
+               NULL,
+               0,
+               0);
+
+       if (result < 0)
+       {
+               return AIRSPYHF_ERROR;
+       }
+
+       return AIRSPYHF_SUCCESS;
+}
+
+int ADDCALL airspyhf_set_hf_agc(airspyhf_device_t* device, uint8_t flag)
+{
+       int result;
+
+       result = libusb_control_transfer(
+               device->usb_device,
+               LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_VENDOR | 
LIBUSB_RECIPIENT_DEVICE,
+               AIRSPYHF_SET_HF_AGC,
+               (uint16_t) flag,
+               0,
+               NULL,
+               0,
+               0);
+
+       if (result < 0)
+       {
+               return AIRSPYHF_ERROR;
+       }
+
+       return AIRSPYHF_SUCCESS;
+}
+
+int ADDCALL airspyhf_set_hf_agc_threshold(airspyhf_device_t* device, uint8_t 
flag)
+{
+       int result;
+
+       result = libusb_control_transfer(
+               device->usb_device,
+               LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_VENDOR | 
LIBUSB_RECIPIENT_DEVICE,
+               AIRSPYHF_SET_HF_AGC_THRESHOLD,
+               (uint16_t) flag,
+               0,
+               NULL,
+               0,
+               0);
+
+       if (result < 0)
+       {
+               return AIRSPYHF_ERROR;
+       }
+
+       return AIRSPYHF_SUCCESS;
+}
+
+int ADDCALL airspyhf_set_hf_att(airspyhf_device_t* device, uint8_t value)
+{
+       int result;
+
+       result = libusb_control_transfer(
+               device->usb_device,
+               LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_VENDOR | 
LIBUSB_RECIPIENT_DEVICE,
+               AIRSPYHF_SET_HF_ATT,
+               (uint16_t) value,
+               0,
+               NULL,
+               0,
+               0);
+
+       if (result < 0)
+       {
+               return AIRSPYHF_ERROR;
+       }
+
+       return AIRSPYHF_SUCCESS;
+}
+
+int ADDCALL airspyhf_set_hf_lna(airspyhf_device_t* device, uint8_t flag)
+{
+       int result;
+
+       result = libusb_control_transfer(
+               device->usb_device,
+               LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_VENDOR | 
LIBUSB_RECIPIENT_DEVICE,
+               AIRSPYHF_SET_HF_LNA,
+               (uint16_t) flag,
+               0,
+               NULL,
+               0,
+               0);
+
+       if (result < 0)
+       {
+               return AIRSPYHF_ERROR;
+       }
+
+       return AIRSPYHF_SUCCESS;
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/airspyhf-0.0.0+git.20170718/libairspyhf/src/airspyhf.h 
new/airspyhf-1.1.0+git.20180217/libairspyhf/src/airspyhf.h
--- old/airspyhf-0.0.0+git.20170718/libairspyhf/src/airspyhf.h  2017-07-18 
01:39:52.000000000 +0200
+++ new/airspyhf-1.1.0+git.20180217/libairspyhf/src/airspyhf.h  2018-02-17 
14:48:26.000000000 +0100
@@ -28,14 +28,14 @@
 
 #include <stdint.h>
 
-#define AIRSPYHF_VERSION "1.0.0"
+#define AIRSPYHF_VERSION "1.1.0"
 #define AIRSPYHF_VER_MAJOR 1
-#define AIRSPYHF_VER_MINOR 0
+#define AIRSPYHF_VER_MINOR 1
 #define AIRSPYHF_VER_REVISION 0
 
 #define AIRSPYHF_ENDPOINT_IN (1)
 
-#ifdef _WIN32
+#if defined(_WIN32) && !defined(STATIC_AIRSPYHFPLUS)
         #define ADD_EXPORTS
         
        /* You should define ADD_EXPORTS *only* when building the DLL. */
@@ -84,6 +84,20 @@
        AIRSPYHF_BOARD_ID_INVALID = 0xFF,
 };
 
+typedef enum
+{
+       AIRSPYHF_USER_OUTPUT_0 = 0,
+       AIRSPYHF_USER_OUTPUT_1 = 1,
+       AIRSPYHF_USER_OUTPUT_2 = 2,
+       AIRSPYHF_USER_OUTPUT_3 = 3
+} airspyhf_user_output_t;
+
+typedef enum
+{
+       AIRSPYHF_USER_OUTPUT_LOW        = 0,
+       AIRSPYHF_USER_OUTPUT_HIGH       = 1
+} airspyhf_user_output_state_t;
+
 typedef struct airspyhf_device airspyhf_device_t;
 
 typedef struct {
@@ -94,8 +108,18 @@
        uint64_t dropped_samples;
 } airspyhf_transfer_t;
 
+typedef struct {
+       uint32_t major_version;
+       uint32_t minor_version;
+       uint32_t revision;
+} airspyhf_lib_version_t;
+
+#define MAX_VERSION_STRING_SIZE (64)
+
 typedef int (*airspyhf_sample_block_cb_fn) (airspyhf_transfer_t* transfer_fn);
 
+extern ADDAPI void ADDCALL airspyhf_lib_version(airspyhf_lib_version_t* 
lib_version);
+extern ADDAPI int ADDCALL airspyhf_list_devices(uint64_t *serials, int count);
 extern ADDAPI int ADDCALL airspyhf_open(airspyhf_device_t** device);
 extern ADDAPI int ADDCALL airspyhf_open_sn(airspyhf_device_t** device, 
uint64_t serial_number);
 extern ADDAPI int ADDCALL airspyhf_close(airspyhf_device_t* device);
@@ -109,6 +133,12 @@
 extern ADDAPI int ADDCALL airspyhf_set_calibration(airspyhf_device_t* device, 
int32_t ppb);
 extern ADDAPI int ADDCALL airspyhf_flash_calibration(airspyhf_device_t* 
device);
 extern ADDAPI int ADDCALL 
airspyhf_board_partid_serialno_read(airspyhf_device_t* device, 
airspyhf_read_partid_serialno_t* read_partid_serialno);
+extern ADDAPI int ADDCALL airspyhf_version_string_read(airspyhf_device_t* 
device, char* version, uint8_t length);
+extern ADDAPI int ADDCALL airspyhf_set_user_output(airspyhf_device_t* device, 
airspyhf_user_output_t pin, airspyhf_user_output_state_t value);
+extern ADDAPI int ADDCALL airspyhf_set_hf_agc(airspyhf_device_t* device, 
uint8_t flag);
+extern ADDAPI int ADDCALL airspyhf_set_hf_agc_threshold(airspyhf_device_t* 
device, uint8_t flag);
+extern ADDAPI int ADDCALL airspyhf_set_hf_att(airspyhf_device_t* device, 
uint8_t value);
+extern ADDAPI int ADDCALL airspyhf_set_hf_lna(airspyhf_device_t* device, 
uint8_t flag);
 
 #ifdef __cplusplus
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/airspyhf-0.0.0+git.20170718/libairspyhf/src/airspyhf_commands.h 
new/airspyhf-1.1.0+git.20180217/libairspyhf/src/airspyhf_commands.h
--- old/airspyhf-0.0.0+git.20170718/libairspyhf/src/airspyhf_commands.h 
2017-07-18 01:39:52.000000000 +0200
+++ new/airspyhf-1.1.0+git.20180217/libairspyhf/src/airspyhf_commands.h 
2018-02-17 14:48:26.000000000 +0100
@@ -32,7 +32,7 @@
     RECEIVER_MODE_ON                    = 1
 } receiver_mode_t;
 
-#define AIRSPYHF_CMD_MAX (7)
+#define AIRSPYHF_CMD_MAX (13)
 typedef enum
 {
     AIRSPYHF_INVALID                    = 0,
@@ -42,7 +42,13 @@
     AIRSPYHF_SET_SAMPLERATE             = 4,
     AIRSPYHF_CONFIG_READ                = 5,
     AIRSPYHF_CONFIG_WRITE               = 6,
-    AIRSPYHF_GET_SERIALNO_BOARDID       = AIRSPYHF_CMD_MAX
+    AIRSPYHF_GET_SERIALNO_BOARDID       = 7,
+       AIRSPYHF_SET_USER_OUTPUT                        = 8,
+       AIRSPYHF_GET_VERSION_STRING         = 9,
+       AIRSPYHF_SET_HF_AGC                 = 10,
+       AIRSPYHF_SET_HF_AGC_THRESHOLD       = 11,
+       AIRSPYHF_SET_HF_ATT                 = 12,
+       AIRSPYHF_SET_HF_LNA                 = AIRSPYHF_CMD_MAX,
 } airspyhf_vendor_request;
 
 #endif
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/airspyhf-0.0.0+git.20170718/libairspyhf/src/iqbalancer.c 
new/airspyhf-1.1.0+git.20180217/libairspyhf/src/iqbalancer.c
--- old/airspyhf-0.0.0+git.20170718/libairspyhf/src/iqbalancer.c        
2017-07-18 01:39:52.000000000 +0200
+++ new/airspyhf-1.1.0+git.20180217/libairspyhf/src/iqbalancer.c        
2018-02-17 14:48:26.000000000 +0100
@@ -174,10 +174,23 @@
        }
 }
 
+static void multiply_complex_complex(airspyhf_complex_float_t *a, const 
airspyhf_complex_float_t *b)
+{
+       float re = a->re * b->re - a->im * b->im;
+       a->im = a->im * b->re + a->re * b->im;
+       a->re = re;
+}
+
+static float fsign(const float x)
+{
+       return x >= 0 ? 1.0f : -1.0f;
+}
+
 static float utility(iq_balancer_t *iq_balancer, airspyhf_complex_float_t* iq, 
float phase)
 {
        int i, j;
-       float result;
+       airspyhf_complex_float_t acc;
+       airspyhf_complex_float_t prod;
 
        airspyhf_complex_float_t fftPtr[FFTBins * 
sizeof(airspyhf_complex_float_t)];
 
@@ -188,16 +201,18 @@
        window(fftPtr, FFTBins);
        fft(fftPtr, FFTBins);
 
-       result = 0.0f;
+       acc.re = 0.0f;
+       acc.im = 0.0f;
 
        for (i = 1, j = FFTBins - 1; i < FFTBins / 2; i++, j--)
        {
-               float binMag = fabsf(fftPtr[i].re) + fabsf(fftPtr[i].im);
-               float imageMag = fabsf(fftPtr[j].re) + fabsf(fftPtr[j].im);
-               result += fabsf(binMag - imageMag);
+               prod = fftPtr[i];
+               multiply_complex_complex(&prod, fftPtr + j);
+               acc.re += prod.re;
+               acc.im += prod.im;
        }
 
-       return result;
+       return acc.re * acc.re + acc.im * acc.im;
 }
 
 static void estimate_phase_imbalance(iq_balancer_t *iq_balancer, 
airspyhf_complex_float_t* iq)
@@ -216,22 +231,30 @@
 
        float candidateUtility = utility(iq_balancer, iq, phase);
 
-       if (candidateUtility > u)
+       if (candidateUtility < u)
        {
+               iq_balancer->fail = 0;
                iq_balancer->phase += PhaseAlpha * (phase - iq_balancer->phase);
+               iq_balancer->step *= StepIncrement;
+               if (fabsf(iq_balancer->step) > MaximumStep)
+               {
+                       iq_balancer->step = MaximumStep * 
fsign(iq_balancer->step);
+               }
        }
        else
        {
-               float stepmag = fabsf(iq_balancer->step);
-               if (stepmag < MinimumStep)
+               if (++iq_balancer->fail > MaximumFail)
                {
-                       iq_balancer->step_factor = -StepIncrement;
+                       iq_balancer->fail = 0;
+                       iq_balancer->step = -iq_balancer->step;
                }
-               else if (stepmag > MaximumStep)
+
+               iq_balancer->step *= StepDecrement;
+
+               if (fabsf(iq_balancer->step) < MinimumStep)
                {
-                       iq_balancer->step_factor = -StepDecrement;
+                       iq_balancer->step = MinimumStep * 
fsign(iq_balancer->step);
                }
-               iq_balancer->step *= iq_balancer->step_factor;
        }
 }
 
@@ -291,7 +314,7 @@
        iq_balancer->phase = 0.0f;
        iq_balancer->last_phase = 0.0f;
        iq_balancer->step = MinimumStep;
-       iq_balancer->step_factor = StepIncrement;
+       iq_balancer->fail = 0;
        iq_balancer->gain = 1.0;
        iq_balancer->iampavg = 1.0;
        iq_balancer->qampavg = 1.0;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/airspyhf-0.0.0+git.20170718/libairspyhf/src/iqbalancer.h 
new/airspyhf-1.1.0+git.20180217/libairspyhf/src/iqbalancer.h
--- old/airspyhf-0.0.0+git.20170718/libairspyhf/src/iqbalancer.h        
2017-07-18 01:39:52.000000000 +0200
+++ new/airspyhf-1.1.0+git.20180217/libairspyhf/src/iqbalancer.h        
2018-02-17 14:48:26.000000000 +0100
@@ -24,13 +24,14 @@
 
 #include "airspyhf.h"
 
-#define FFTBins 128
+#define FFTBins 512
 #define SkippedBuffers 4
-#define MaximumStep 1e-3f
-#define MinimumStep 1e-5f
+#define MaximumFail 10
+#define MaximumStep 1e-2f
+#define MinimumStep 1e-7f
 #define StepIncrement 1.1f
 #define StepDecrement 0.9f
-#define MaxPhaseCorrection 0.1f
+#define MaxPhaseCorrection 0.2f
 #define PhaseAlpha 0.01f
 #define GainAlpha 0.01f
 #define DCAlpha 2.68744225e-5f
@@ -42,7 +43,7 @@
        float phase;
        float last_phase;
        float step;
-       float step_factor;
+       int fail;
        double gain;
        double iampavg;
        double qampavg;


Reply via email to