~fitzsim/video_si21xx_superset

ec0ea801b34cf8dfe7e15cbc637066d0a9d866fb — Thomas Fitzsimmons 2 years ago b659ad5
Valgrind: Fix memory leaks due to not closing USB

SiLabs_API_L3_Console.c: Call L0_Disconnect and SiLabs_API_SW_Exit at
the end of main.

SiLabs_API_L3_Wrapper.c: Add SiLabs_API_SW_Exit function.

Si2183_L2_API.c: Add Si2183_L2_SW_Exit function.

Silabs_L0_Connection.c: Add L0_Disconnect function.
M SILABS_SUPERSET/Si2183/Si2183_L2_API.c => SILABS_SUPERSET/Si2183/Si2183_L2_API.c +16 -0
@@ 3137,6 3137,22 @@ char          Si2183_L2_SW_Init            (Si2183_L2_Context *front_end
    return 1;
}
/************************************************************************************************************************
  Si2183_L2_SW_Exit function
  Use:        software deinitialization function
              Used to deinitialize the Si2183 and tuner structures
  Behavior:   This function frees dynamically allocated memory pointed to by the Si2183 and tuner instances
  Parameter:  front_end, a pointer to the Si2183_L2_Context context to be deinitialized
  Return:     1
************************************************************************************************************************/
char          Si2183_L2_SW_Exit            (Si2183_L2_Context *front_end)
{
    SiTRACE_X("Si2183_L2_SW_Exit starting...\n");
    free(front_end->demod->fw_table);
    free(front_end->demod->spi_table);
    SiTRACE("Si2183_L2_SW_Exit complete\n");
    return 1;
}
/************************************************************************************************************************
  Si2183_L2_Set_Index_and_Tag function
  Use:        Front-End index and tag function
              Used to store the frontend index and tag, which will be used in traces called from L2 level

M SILABS_SUPERSET/Si2183/Si2183_L2_API.h => SILABS_SUPERSET/Si2183/Si2183_L2_API.h +1 -0
@@ 274,6 274,7 @@ char           Si2183_L2_SW_Init                  (Si2183_L2_Context *front_end
#endif /* SATELLITE_FRONT_END */
                                   , void *p_context
                                   );
char           Si2183_L2_SW_Exit                  (Si2183_L2_Context   *front_end);
signed   int   Si2183_L2_Set_Index_and_Tag        (Si2183_L2_Context   *front_end, unsigned char index, const char* tag);
void           Si2183_L2_HW_Connect               (Si2183_L2_Context   *front_end, CONNECTION_TYPE mode);
    /*  Locking and status functions */

M SILABS_SUPERSET/Si2183/SiLabs_API_L3_Console.c => SILABS_SUPERSET/Si2183/SiLabs_API_L3_Console.c +6 -0
@@ 3467,6 3467,12 @@ II("SiLabs_API_HW_Connect               (front_end, %d);\n", mode);

  while (Silabs_demoloop(""));

#ifdef    USB_Capability
  if (mode == USB) {
    L0_Disconnect(i2c, mode);
  }
#endif /* USB_Capability */
  SiLabs_API_SW_Exit(front_end);
  exit(0);

  return 0;

M SILABS_SUPERSET/Si2183/SiLabs_API_L3_Wrapper.c => SILABS_SUPERSET/Si2183/SiLabs_API_L3_Wrapper.c +16 -0
@@ 3801,6 3801,22 @@ signed   char SiLabs_API_SW_Init                    (SILABS_FE_Context *front_en
  return 0;
}
/************************************************************************************************************************
  SiLabs_API_SW_Exit function
  Use:        software deinitialization function
              Used to deinitialize the DTV demodulator and tuner structures
  Behavior:   This function performs all the steps necessary to deinitialize the demod and tuner instances
  Parameter:  front_end, a pointer to the SILABS_FE_Context context to be deinitialized
  Return:     1 if successful, 0 otherwise
************************************************************************************************************************/
signed   char SiLabs_API_SW_Exit                    (SILABS_FE_Context *front_end)
{
  SiTRACE("API CALL CONFIG: SiLabs_API_SW_Exit                       (front_end);\n");
#ifdef    Si2183_COMPATIBLE
  return Si2183_L2_SW_Exit(front_end->Si2183_FE);
#endif /* Si2183_COMPATIBLE */
  return 0;
}
/************************************************************************************************************************
  SiLabs_API_Set_Index_and_Tag function
  Use:        Front-End index and tag function
              Used to store the frontend index and tag, which will be used in traces called from L3 level

M SILABS_SUPERSET/Si2183/SiLabs_API_L3_Wrapper.h => SILABS_SUPERSET/Si2183/SiLabs_API_L3_Wrapper.h +1 -0
@@ 1043,6 1043,7 @@ signed   int  SiLabs_API_Text_status_selection      (SILABS_FE_Context *front_en
/*****************************************************************************************/
/* Main SW init function (to be called first)                                            */
signed   char SiLabs_API_SW_Init                    (SILABS_FE_Context *front_end,    signed   int  demodAdd, signed   int  tunerAdd_Ter, signed   int  tunerAdd_Sat);
signed   char SiLabs_API_SW_Exit                    (SILABS_FE_Context *front_end);
signed   int  SiLabs_API_Set_Index_and_Tag          (SILABS_FE_Context *front_end,    unsigned char index, const char* tag);
signed   int  SiLabs_API_Frontend_Chip              (SILABS_FE_Context *front_end,    signed   int  demod_id);
signed   int  SiLabs_API_Handshake_Setup            (SILABS_FE_Context *front_end,    signed   int  handshake_mode, signed   int  handshake_period_ms);

M SILABS_SUPERSET/Si_I2C/Silabs_L0_API.h => SILABS_SUPERSET/Si_I2C/Silabs_L0_API.h +1 -0
@@ 246,6 246,7 @@ extern "C" {

    void             L0_Init              (L0_Context* i2c); /* initialize the Layer 0 DLL. It sets the layer 0 context parameters to startup values. It must be called first. It is automatically called by the Layer 1 init function.*/
    signed   int     L0_Connect           (L0_Context* i2c, CONNECTION_TYPE connType); /* Select the connection mode */
    signed   int     L0_Disconnect        (L0_Context* i2c, CONNECTION_TYPE connType); /* Disconnect */
    const    char*   L0_InterfaceType     (L0_Context* i2c);
    signed   int     L0_SetAddress        (L0_Context* i2c, unsigned int add, int addSize); /* set the IP's i2c address. It must be called only once at startup, as the IP's address is not expected to change over time.*/
    signed   int     L0_ReadBytes         (L0_Context* i2c, unsigned int iI2CIndex, int iNbBytes, unsigned char *pbtDataBuffer) ;/* read  iNbBytes bytes from the IP. A buffer large enough to hold the values needs to be reserved by the upper layer.*/

M SILABS_SUPERSET/Si_I2C/Silabs_L0_Connection.c => SILABS_SUPERSET/Si_I2C/Silabs_L0_Connection.c +14 -0
@@ 1290,6 1290,20 @@ int     L0_Connect           (L0_Context *i2c, CONNECTION_TYPE connType) {
  return 0;
}
/************************************************************************************************************************
  L0_Disconnect function
  Use:        Core layer 0 disconnection function
              Used to close connections at exit to eliminate memory leaks
  Returns:    1 if close was successful
************************************************************************************************************************/
int     L0_Disconnect        (L0_Context *i2c, CONNECTION_TYPE connType) {
  #ifdef    USB_Capability
  if (i2c->connectionType == USB) {
    return Cypress_USB_Close();
  }
  #endif /* USB_Capability */
  return 0;
}
/************************************************************************************************************************
  L0_TrackRead function
  Use:        layer 0 initialization function
              Used to toggle the read traces for the related Layer 1 instance.