DVBCore  17.9.0
Open Source DVB Engine
 All Data Structures Files Functions Typedefs Macros Pages
Macros | Enumerations | Functions
ap_ci.c File Reference

Application level CI control functions. More...

#include <stdio.h>
#include <string.h>
#include "techtype.h"
#include "dbgfuncs.h"
#include "stbhwci.h"
#include "stbhwos.h"
#include "stbhwtun.h"
#include "stbdpc.h"
#include "stbpvr.h"
#include "stberc.h"
#include "stbheap.h"
#include "stbsiflt.h"
#include "stbsitab.h"
#include "stbgc.h"
#include "ap_tmr.h"
#include "dba.h"
#include "app.h"
#include "ap_cfg.h"
#include "ap_events.h"
#include "ap_dbacc.h"
#include "ap_dbdef.h"
#include "ap_ci.h"
#include "ap_cntrl.h"
#include "ap_state.h"
#include "ap_pvr.h"
#include "app_nvm.h"
#include "stbci.h"
#include "stbcica.h"
#include "stbcicc.h"
#include "stbcikeys.h"
#include "ap_ci_int.h"
#include "ap_cihc.h"
#include "ap_ciop.h"

Macros

#define AP_CI_PRINT(x)
 
#define MAX_EVENTS   100
 
#define TASK_STACK_SIZE   4096
 
#define TASK_PRIORITY   11
 

Enumerations

enum  E_CIPLUS_TUNE_TYPE { CIPLUS_TUNE_TYPE_SERVICE, CIPLUS_TUNE_TYPE_TRANSPORT, CIPLUS_TUNE_TYPE_CI_SERVICE }
 

Functions

void ACI_Initialise (void)
 Initialise CI Host Control support.
 
U8BIT ACI_GetCamUpgradeMode (void)
 Return CAM upgrade option (Yes/No/Ask) More...
 
void ACI_SetCamUpgradeMode (U8BIT upgrade_mode)
 Sets the CAM upgrade option (Yes/No/Ask) More...
 
E_CIP_START_OPERATOR_SEARCH ACI_GetOperatorSearchMode (void)
 Return the option for starting an operator profile search (yes/no/ask) More...
 
void ACI_SetOperatorSearchMode (E_CIP_START_OPERATOR_SEARCH search_mode)
 Sets the operator profile search mode (Yes/No/Ask). This should be used by the app to control whether a search can be started, or the user should be asked first, or can't run. More...
 
void ACI_OperatorSearchRequired (U32BIT module, BOOLEAN required)
 Sets whether an operator profile search needs to be run. More...
 
void ACI_ScheduleOperatorSearch (U32BIT cicam_id, U16BIT date, U8BIT hour, U8BIT min)
 Sets the date/time that an operator search should be started for the given module. More...
 
BOOLEAN ACI_IsOperatorSearchRequired (void)
 Returns whether an operator profile search has been requested. More...
 
U32BIT ACI_GetOperatorSearchModule (void)
 Returns the module performing or requiring and operator search. More...
 
BOOLEAN ACI_GetFirstOperatorSearchModule (U32BIT *module)
 Checks all the CI+ profiles to see if any have requested an update search. More...
 
BOOLEAN ACI_GetFirstScheduledOperatorSearch (U32BIT *module, U16BIT *date, U8BIT *hours, U8BIT *mins)
 Checks all the CI+ profiles to find the one with the earliest scheduled search. All returned values are only valid if the function returns TRUE. More...
 
BOOLEAN ACI_StartOperatorSearchForModule (U32BIT module)
 Called by the app to start an operator profile search for the given module. More...
 
BOOLEAN ACI_HandlePrivateTimer (U32BIT timer_handle)
 Checks whether the given timer is associated with any of the CI+ profiles and starts the operator search if possible. More...
 
BOOLEAN ACI_SetSecureRouting (U8BIT path)
 Ensures the TS is routed securely for CI+, either by setting the TS to pass through if a CI slot contains a CI+ CAM or bypass it if it doesn't.
 
BOOLEAN ACI_AcquireCISlot (U8BIT path, void *s_ptr)
 Acquires a CI slot for the given path on the given service after releasing any slot already being used by the path. More...
 
BOOLEAN ACI_AcquireCISlotForRecording (U8BIT path, void *s_ptr)
 Acquires a CI slot for the recording path. This function may need to "steal" the CI slot from the live path (if they are not the same path). More...
 
U8BIT ACI_FindCISlotForService (void *serv_ptr)
 Looks for a CAM that's able to descramble the given service and returns its slot id. More...
 
void ACI_UsageRulesStatusChanged (U8BIT path)
 Re-evaluate current state follwing a change related to usage rules. More...
 
void ACI_ProgramMapTableChanged (U8BIT *pmt)
 Handle PMT change. More...
 
BOOLEAN ACI_IsTrustedPath (U8BIT path)
 The given decode path is only trusted if it doesn't include a CI slot or the CI slot contains a CI+ CAM. More...
 
S32BIT ACI_ReadPinForSlot (U8BIT slot_id)
 Checks if a pin has been saved for the CAM in the given slot and returns it. More...
 
BOOLEAN ACI_WritePinForSlot (U8BIT slot_id, S32BIT pin)
 Saves the given pin associated with the CAM in the given slot. If the pin for this CAM has previously been saved then the saved value will be updated. If all entries are used then the oldest will be overwritten. More...
 
void ACI_TuneToTransport (U32BIT module, void *t_ptr)
 Schedule a tune to a transport. More...
 
void ACI_TuneToService (U32BIT module, void *s_ptr)
 Schedule a tune to a service. More...
 
void ACI_TuneToDelSysDesc (U32BIT module, S_CIP_TUNE_DEL_SYS_DESC *tune)
 Tune to a service/transport defined by a delivery system descriptor, possibly with PMT data, if it's a service. More...
 
BOOLEAN ACI_AskRelease (U32BIT module)
 Ask the host control module to restore replaced PIDs and to close the session with the host control resource. More...
 
void ACI_TuneReply (U8BIT path, U32BIT module, E_CIP_TUNER_STATUS status)
 This function is called by the host to send the status of the tune operation to the module. More...
 
void ACI_UseCiModuleOnPath (U8BIT path, U32BIT module)
 Use the CI module with the given path. More...
 
BOOLEAN ACI_SendPinToCam (U8BIT slot_id, U32BIT pin)
 Converts the pin value to ASCII and sends it to the CAM An STB_EVENT_CI_PIN_STATUS event will be sent to notify the validity, or otherwise, of the pin. More...
 
BOOLEAN ACI_PathOwnedByModule (U8BIT path, U32BIT module)
 Checks whether path is owned by CI module. More...
 

Detailed Description

Application level CI control functions.

Date
February 2011
Author
Ocean Blue

Function Documentation

BOOLEAN ACI_AcquireCISlot ( U8BIT  path,
void *  s_ptr 
)

Acquires a CI slot for the given path on the given service after releasing any slot already being used by the path.

Parameters
pathdecode path
s_ptrservice to be used on the path
Returns
TRUE if a slot is acquired, FALSE otherwise
BOOLEAN ACI_AcquireCISlotForRecording ( U8BIT  path,
void *  s_ptr 
)

Acquires a CI slot for the recording path. This function may need to "steal" the CI slot from the live path (if they are not the same path).

Parameters
pathdecode path for recording
s_ptrservice to be used on the path
Returns
TRUE if a slot is acquired, FALSE otherwise
BOOLEAN ACI_AskRelease ( U32BIT  module)

Ask the host control module to restore replaced PIDs and to close the session with the host control resource.

Parameters
modulespecifies module required
Returns
TRUE if operation successful, FALSE otherwise
U8BIT ACI_FindCISlotForService ( void *  serv_ptr)

Looks for a CAM that's able to descramble the given service and returns its slot id.

Parameters
serv_ptrservice
Returns
slot id, if CAM is found, or INVALID_RES_ID if not
U8BIT ACI_GetCamUpgradeMode ( void  )

Return CAM upgrade option (Yes/No/Ask)

Returns
U8BIT the cams current upgrade mode
BOOLEAN ACI_GetFirstOperatorSearchModule ( U32BIT *  module)

Checks all the CI+ profiles to see if any have requested an update search.

Parameters
modulepointer to return the handle of the first module requiring an update Only valid if the function returns TRUE
Returns
TRUE if a profile needs updating, FALSE otherwise
BOOLEAN ACI_GetFirstScheduledOperatorSearch ( U32BIT *  module,
U16BIT *  date,
U8BIT *  hours,
U8BIT *  mins 
)

Checks all the CI+ profiles to find the one with the earliest scheduled search. All returned values are only valid if the function returns TRUE.

Parameters
modulepointer to return the handle of the first module requiring an update
datepointer to return the date code of the search
hourspointer to return the hour of the search
minspointer to return the minute of the search
Returns
TRUE if a scheduled search is found for a profile, FALSE otherwise
E_CIP_START_OPERATOR_SEARCH ACI_GetOperatorSearchMode ( void  )

Return the option for starting an operator profile search (yes/no/ask)

Returns
The current setting
U32BIT ACI_GetOperatorSearchModule ( void  )

Returns the module performing or requiring and operator search.

Returns
module
BOOLEAN ACI_HandlePrivateTimer ( U32BIT  timer_handle)

Checks whether the given timer is associated with any of the CI+ profiles and starts the operator search if possible.

Parameters
timer_handletimer handle
Returns
TRUE if the timer is associated with a profile, FALSE otherwise
BOOLEAN ACI_IsOperatorSearchRequired ( void  )

Returns whether an operator profile search has been requested.

Returns
TRUE if a search has been requested, FALSE otherwise
BOOLEAN ACI_IsTrustedPath ( U8BIT  path)

The given decode path is only trusted if it doesn't include a CI slot or the CI slot contains a CI+ CAM.

Parameters
pathdecode path
Returns
TRUE if the decode path is trusted, FALSE otherwise
void ACI_OperatorSearchRequired ( U32BIT  module,
BOOLEAN  required 
)

Sets whether an operator profile search needs to be run.

Parameters
modulemodule requesting or cancelling an operator search
requiredTRUE if a search is required, FALSE otherwise
BOOLEAN ACI_PathOwnedByModule ( U8BIT  path,
U32BIT  module 
)

Checks whether path is owned by CI module.

Parameters
modulespecifies module (host control or operator)
Returns
TRUE if path owned by module, FALSE otherwise
void ACI_ProgramMapTableChanged ( U8BIT *  pmt)

Handle PMT change.

Parameters
pmtthe new PMT
S32BIT ACI_ReadPinForSlot ( U8BIT  slot_id)

Checks if a pin has been saved for the CAM in the given slot and returns it.

Parameters
slot_idCI slot
Returns
pin value, or -1 if there's no CAM in the slot or no pin has been saved
void ACI_ScheduleOperatorSearch ( U32BIT  cicam_id,
U16BIT  date,
U8BIT  hour,
U8BIT  min 
)

Sets the date/time that an operator search should be started for the given module.

Parameters
cicam_idID of the CICAM requesting an operator search
dateUTC MJD date code
hourUTC hour
minUTC minute
BOOLEAN ACI_SendPinToCam ( U8BIT  slot_id,
U32BIT  pin 
)

Converts the pin value to ASCII and sends it to the CAM An STB_EVENT_CI_PIN_STATUS event will be sent to notify the validity, or otherwise, of the pin.

Parameters
slot_id- slot Id
pin- pin value
Returns
TRUE if the pin was sent, FALSE otherwise
void ACI_SetCamUpgradeMode ( U8BIT  upgrade_mode)

Sets the CAM upgrade option (Yes/No/Ask)

Parameters
upgrade_modecam upgrade mode
void ACI_SetOperatorSearchMode ( E_CIP_START_OPERATOR_SEARCH  search_mode)

Sets the operator profile search mode (Yes/No/Ask). This should be used by the app to control whether a search can be started, or the user should be asked first, or can't run.

Parameters
search_modesearch mode
BOOLEAN ACI_StartOperatorSearchForModule ( U32BIT  module)

Called by the app to start an operator profile search for the given module.

Parameters
moduleoperator module
Returns
TRUE if the search is started, FALSE otherwise
void ACI_TuneReply ( U8BIT  path,
U32BIT  module,
E_CIP_TUNER_STATUS  status 
)

This function is called by the host to send the status of the tune operation to the module.

Parameters
path- decode path used for tuning
module- host control module
status- tune operation status
void ACI_TuneToDelSysDesc ( U32BIT  module,
S_CIP_TUNE_DEL_SYS_DESC tune 
)

Tune to a service/transport defined by a delivery system descriptor, possibly with PMT data, if it's a service.

Parameters
module- module id
tune- tuning parameters
void ACI_TuneToService ( U32BIT  module,
void *  s_ptr 
)

Schedule a tune to a service.

Parameters
modulemodule id
s_ptrtarget service pointer
void ACI_TuneToTransport ( U32BIT  module,
void *  t_ptr 
)

Schedule a tune to a transport.

Parameters
modulemodule id
t_ptrtarget transport pointer
void ACI_UsageRulesStatusChanged ( U8BIT  path)

Re-evaluate current state follwing a change related to usage rules.

Parameters
pathdecode path
void ACI_UseCiModuleOnPath ( U8BIT  path,
U32BIT  module 
)

Use the CI module with the given path.

Parameters
path- decode path
module- CI module
BOOLEAN ACI_WritePinForSlot ( U8BIT  slot_id,
S32BIT  pin 
)

Saves the given pin associated with the CAM in the given slot. If the pin for this CAM has previously been saved then the saved value will be updated. If all entries are used then the oldest will be overwritten.

Parameters
slot_idCI slot
pinpin value to be saved
Returns
TRUE on success, FALSE otherwise