view src/g23m-fad/l2r/tra_dnf.c @ 78:c632896652ba

mfw/ti1_key.c: properly initialize notified_keys array The code in this ti1_key.c layer needs to call kpd_subscribe() and kpd_define_key_notification() functions in order to register with the KPD driver. The original code passed KPD_NB_PHYSICAL_KEYS in nb_notified_keys - this constant is defined to 24 in kpd_cfg.h on all platforms of interest to us - but it only filled the first 23 slots in the notified_keys array, resulting in stack garbage being passed to KPD API functions. The fix consists of initializing the last missed array slot to KPD_KEY_RECORD, the key ID for the right side button on the D-Sample handset. On our current hw targets this "Record" button exists as the EXTRA button on our Luna keypad board and as the camera button on the Pirelli DP-L10. There is no support whatsoever for this button in current BMI+MFW, we have no plans of doing anything with Pirelli's camera button even if we do get our UI fw running on that phone, and the Mother's dream of building our own FreeCalypso handset with the same button arrangement as D-Sample (including the right side button) is currently very nebulous - but let us nonetheless handle the full set of buttons on the KPD to MFW interface, and let upper layers weed out unsupported buttons.
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 25 Oct 2020 23:41:01 +0000
parents fa8dc04885d8
children
line wrap: on
line source

/* 
+----------------------------------------------------------------------------- 
|  Project :  CSD (8411)
|  Modul   :  tra_dnf.c
+----------------------------------------------------------------------------- 
|  Copyright 2002 Texas Instruments Berlin, AG 
|                 All rights reserved. 
| 
|                 This file is confidential and a trade secret of Texas 
|                 Instruments Berlin, AG 
|                 The receipt of or possession of this file does not convey 
|                 any rights to reproduce or disclose its contents or to 
|                 manufacture, use, or sell anything it may describe, in 
|                 whole, or in part, without the specific written consent of 
|                 Texas Instruments Berlin, AG. 
+----------------------------------------------------------------------------- 
|  Purpose :  This Modul defines the procedures and functions for TRA
+----------------------------------------------------------------------------- 
*/ 

#ifndef TRA_DNF_C
#define TRA_DNF_C
#endif

#define ENTITY_L2R

/*==== INCLUDES ===================================================*/

#include <string.h>
#include "typedefs.h"
#include "pconst.cdg"
#include "vsi.h"
#include "macdef.h"
#include "custom.h"
#include "gsm.h"
#include "prim.h"
#include "pei.h"
#include "tok.h"
#include "dti.h"

#include "cl_ribu.h"
#include "tra_pei.h"
#include "tra.h"

/*==== CONST =======================================================*/

/*==== TYPES =======================================================*/

/*==== VAR EXPORT ==================================================*/

/*==== VAR LOCAL ===================================================*/

/*==== FUNCTIONS ===================================================*/

/*
+------------------------------------------------------------------------------
|  Function    : dl_init
+------------------------------------------------------------------------------
|  Description : initialise the l2r data for the downlink process
|
|  Parameters  : T_TRA_DN *ddl
|
|
|  Return      : -
+------------------------------------------------------------------------------
*/

GLOBAL void dl_init(T_TRA_DN *ddl)
{
  TRACE_FUNCTION ("dl_init()");

  ddl->sa               = FL_INACTIVE;
  ddl->sb               = FL_INACTIVE;
  ddl->x                = FL_INACTIVE;
  ddl->prim             = NULL;       /* meaning: no DTI2_DATA_IND allocated yet */
  ddl->Brk_dti_data_ind = NULL;

  SET_STATE (DN, DN_INACTIVE);
}

/*
+------------------------------------------------------------------------------
|  Function    : dl_send_data_ind
+------------------------------------------------------------------------------
|  Description : This procedure copies data from the downlink ring buffer
|                into a a dti_data_ind primitive and sends this primitive
|                to the upper layer.
|                (Just the SDU data are copied into the ring buffer by RA!)
|  Parameters  : -
|
|
|  Return      : -
+------------------------------------------------------------------------------
*/

GLOBAL BOOL dl_send_data_ind(void)
{
  T_TRA_DN *ddl = &tra_data->dn;

  TRACE_FUNCTION ("dl_send_data_ind()");

  if (ddl->prim NEQ NULL) /* check for existing dti_data_ind */
  {
    ddl->prim->parameters.st_lines.st_line_sa   = ddl->sa;
    ddl->prim->parameters.st_lines.st_line_sb   = ddl->sb;
    ddl->prim->parameters.st_lines.st_flow      = ddl->x;
    ddl->prim->parameters.st_lines.st_break_len = DTI_BREAK_OFF;
    
    ddl->prim->parameters.p_id = DTI_PID_UOS;
    ddl->prim->link_id = 0; /* dummy init */

    dti_send_data (l2r_hDTI, TRA_DTI_UP_INSTANCE, TRA_DTI_UP_INTERFACE, TRA_DTI_UP_CHANNEL, ddl->prim);
    ddl->prim = NULL;
    return TRUE;
  }
  else
  {
    TRACE_EVENT("no prim to send");
  }
  return FALSE;
}

/*
+------------------------------------------------------------------------------
|  Function    : dl_prep_data_ind
+------------------------------------------------------------------------------
|  Description : This procedure appends data from the downlink ring buffer
|                to a already allocated dti_data_ind primitive
|
|  Parameters  : -
|
|
|  Return      : -
+------------------------------------------------------------------------------
*/

GLOBAL void dl_prep_data_ind(T_FD *pFD)
{
  T_desc2* desc;   /* block to be copied to */
  T_desc2* p_desc; /* prim to be copied to */

  T_TRA_DN *ddl = &tra_data->dn;

  TRACE_FUNCTION ("dl_prep_data_ind()");

  if (ddl->prim EQ NULL) /* check for existing dti_data_ind */
  {
    PALLOC (dti_data_ind, DTI2_DATA_IND); /* start new prim */
    ddl->prim = dti_data_ind;

    ddl->prim->desc_list2.list_len = 0;

    MALLOC (desc, TRA_DTI_BUF_SIZE);      /* contains header bytes, too! */

    dti_data_ind->desc_list2.first =(ULONG) desc;

    p_desc         = (T_desc2 *) dti_data_ind->desc_list2.first;
    p_desc->len    = 0;
    p_desc->size   = 0;
    p_desc->offset = 0;
    p_desc->next   = 0;

    ddl->list_end = desc;   /* set flag for next entrance without sending */
  }
  else
  {
    p_desc = ddl->list_end; /* append to remembered list end */
  }

  if (!pFD) /* status bits changed; no data received */
  {
    return;
  }

  if ((TRA_DTI_BUF_SIZE - p_desc->len - sizeof(T_desc2) + 1) >= MAX_SDU_SIZE)
  {
    memcpy(&p_desc->buffer[p_desc->len], pFD->buf, pFD->len); /* copy data from ring buffer */
  }
  else /* start new block */
  {
    MALLOC (desc, (USHORT)TRA_DTI_BUF_SIZE);
    p_desc->next   = (ULONG) desc;

    /* Initialize the new block's fields to zero */
    p_desc = (T_desc2 *)p_desc->next;
    p_desc->len    = 0;
    p_desc->next   = 0;
    p_desc->size   = 0;
    p_desc->offset = 0; /* temporary solution */

    memcpy(&p_desc->buffer[p_desc->len], pFD->buf, pFD->len); /* copy data from ring buffer */
    ddl->list_end = p_desc;                                     /* write back start of last list */
  }
  p_desc->len += pFD->len;
  p_desc->size = p_desc->len;
  ddl->prim->desc_list2.list_len += pFD->len;
}

/*
+------------------------------------------------------------------------------
|  Function    : rbm_init
+------------------------------------------------------------------------------
|  Description :
|
|  Parameters  :
|
|  Return      : -
+------------------------------------------------------------------------------
*/

GLOBAL void rbm_init(T_TRA_DN *ddl)
{
  TRACE_FUNCTION ("rbm_init()");

  cl_ribu_create(&tra_data->dn.ribu, MAX_SDU_SIZE, TRA_DLR_DEPTH);
}

/*
+------------------------------------------------------------------------------
|  Function    : tra_get_next_FrameDesc
+------------------------------------------------------------------------------
|  Description : This function is called from the RA.
|                It returns the frame descriptor for that buffer,
|                which the RA has to write in the received frame.
|
|                WRAPPER: Get frame descriptor for Layer 1 (TI)
|  Parameters  : -
|
|  Return      : -
+------------------------------------------------------------------------------
*/

GLOBAL T_FD *tra_get_next_FrameDesc(void)
{
  return (cl_ribu_get_new_frame_desc(tra_data->dn.ribu));
}