DVBCore  20.3.0
DVBCore Documentation
ap_init.c
Go to the documentation of this file.
1 /*******************************************************************************
2  * Copyright © 2014 The DTVKit Open Software Foundation Ltd (www.dtvkit.org)
3  * Copyright © 2011 Ocean Blue Software Ltd
4  *
5  * This file is part of a DTVKit Software Component
6  * You are permitted to copy, modify or distribute this file subject to the terms
7  * of the DTVKit 1.0 Licence which can be found in licence.txt or at www.dtvkit.org
8  *
9  * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
10  * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
11  * OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
12  *
13  * If you or your organisation is not a member of DTVKit then you have access
14  * to this source code outside of the terms of the licence agreement
15  * and you are expected to delete this and any associated files immediately.
16  * Further information on DTVKit, membership and terms can be found at www.dtvkit.org
17  *******************************************************************************/
26 //---includes for this file-------------------------------------------------------------------------
27 // compiler library header files
28 #include <stdio.h>
29 #include <string.h>
30 
31 // third party header files
32 
33 // Ocean Blue Software header files
34 #include "techtype.h" //generic data definitions
35 #include "dbgfuncs.h" //debug functions
36 #include "stbhwos.h"
37 #include "stbhwav.h"
38 
39 #include "stberc.h"
40 #include "stbinit.h"
41 #include "stbuni.h"
42 #include "stbdpc.h"
43 #include "stbheap.h"
44 #include "stbllist.h"
45 #include "stbsiflt.h"
46 #include "stbsitab.h"
47 
48 #include "ap_dbacc.h"
49 #include "ap_cntrl.h"
50 #include "ap_cfg.h"
51 #include "app_nvm.h"
52 #include "ap_si.h"
53 #include "ap_events.h"
54 #include "app.h"
55 #include "ap_tmr.h"
56 #include "stbpvr.h"
57 #include "ap_pvr.h"
58 #include "ap_ipadd.h"
59 
60 #ifdef COMMON_INTERFACE
61 #include "ap_ci_int.h"
62 #endif
63 
64 #ifndef DEFAULT_ASCII_TABLE
65 #define DEFAULT_ASCII_TABLE 0
66 #endif
67 
68 #ifdef PVR_LOG
69 FILE *pvr_log;
70 #endif
71 
72 //---constant definitions for this file-------------------------------------------------------------
73 
74 
75 //---local typedefs, structs, enumerations for this file--------------------------------------------
76 
77 
78 //---local (static) variable declarations for this file---------------------------------------------
79 // (internal variables declared static to make them local)
80 static ACB_INFO_CALLBACK UiInfoCallback;
81 
82 //---local function prototypes for this file--------------------------------------------------------
83 // (internal functions declared static to make them local)
84 
85 
86 //--------------------------------------------------------------------------------------------------
87 // local function definitions
88 //--------------------------------------------------------------------------------------------------
89 
90 
91 //--------------------------------------------------------------------------------------------------
92 // global function definitions
93 //--------------------------------------------------------------------------------------------------
94 
95 BOOLEAN APP_InitialiseDVB(DVB_EVENT_HANDLER event_handler, E_DVB_INIT_SUBS_TTXT subs_ttxt)
96 {
97  E_STB_TTXT_SUBT_CONTROL subt_ctrl;
98  BOOLEAN first_boot;
99  U32BIT country_code;
100  U8BIT lang_entry;
101  U8BIT second_lang_entry;
102  U8BIT text_lang_entry;
103  U8BIT second_text_lang_entry;
104  BOOLEAN aerial_pwr;
105  U8BIT tuner;
106 
107  FUNCTION_START(APP_InitialiseDVB);
108 
109  /* Initialise the midware and platform - the order is important as it allows events
110  * to be sent during initialisation */
113 
114  /* Initialise the event handler which will also start a task to monitor and handle system events */
115  AEV_Initialise(event_handler);
116 
117  /* Now initialise the rest of the platform & midware */
118  switch (subs_ttxt)
119  {
120  case DVB_INIT_TELETEXT_ONLY:
121  subt_ctrl = EBU_SUBTITLES;
122  break;
123  case DVB_INIT_SUBTITLES_ONLY:
124  subt_ctrl = DVB_SUBTITLES;
125  break;
126  case DVB_INIT_TELETEXT_AND_SUBTITLES:
127  subt_ctrl = DVB_SUBTITLES_AND_TELETEXT;
128  break;
129  case DVB_INIT_NO_TELETEXT_OR_SUBTITLES:
130  default:
131  subt_ctrl = NO_TELETEXT_OR_SUBTITLES;
132  break;
133  }
134 
135  STB_Initialise(subt_ctrl);
136 
137  STB_SetDefaultAsciiTable(DEFAULT_ASCII_TABLE);
138 
139  /* Initialise the database and DVB settings/data */
140  ADB_Initialise();
142 
143  /* Do initial setting for IP network */
144  AIP_ConnectToNetwork(FALSE);
145 
146  #ifdef COMMON_INTERFACE
147  ACI_Initialise();
148  #endif
149 
150  /* Initialise the nvm data, application SI and control handling */
153 
154  first_boot = (BOOLEAN)APP_NvmRead(FIRST_BOOT_NVM);
155 
156  /* Do country specific initialisations */
157  country_code = ACFG_GetCountry();
158 
161 
162  /* Set default audio and subtitle language */
163  lang_entry = ACFG_GetPrimaryAudioLangId();
164  second_lang_entry = ACFG_GetSecondaryAudioLangId();
165  if (second_lang_entry == ACFG_INVALID_LANG)
166  {
167  second_lang_entry = ACFG_GetDefaultSecondaryLangId();
168  if (second_lang_entry != ACFG_INVALID_LANG)
169  {
170  ACFG_SetSecondaryAudioLangId(second_lang_entry);
171  }
172  }
173 
174  text_lang_entry = ACFG_GetPrimaryTextLangId();
175  second_text_lang_entry = ACFG_GetSecondaryTextLangId();
176  if (second_text_lang_entry == ACFG_INVALID_LANG)
177  {
178  second_text_lang_entry = ACFG_GetDefaultSecondaryLangId();
179  if (second_text_lang_entry != ACFG_INVALID_LANG)
180  {
181  ACFG_SetSecondaryTextLangId(second_lang_entry);
182  }
183  }
184 
185  ADB_SetAudioLang(country_code, lang_entry);
186  ADB_SetTextLang(country_code, text_lang_entry);
187 
188  if (second_lang_entry != ACFG_INVALID_LANG)
189  {
190  ADB_SetSecondaryAudioLang(country_code, second_lang_entry);
191  }
192 
193  if (second_text_lang_entry != ACFG_INVALID_LANG)
194  {
195  ADB_SetSecondaryTextLang(country_code, second_text_lang_entry);
196  }
197 
198  /* Set aerial power, if it's required */
199  if (ACFG_GetAerialPowerOptionReqd(country_code))
200  {
201  if (first_boot)
202  {
203  aerial_pwr = ACFG_GetDefaultAerialPower(country_code);
204  APP_NvmSave(AERIAL_POWER_ON_NVM, aerial_pwr, TRUE);
205  }
206  else
207  {
208  aerial_pwr = (BOOLEAN)APP_NvmRead(AERIAL_POWER_ON_NVM);
209  }
210 
211  /* Set active aerial power setting for each tuner */
212  for (tuner = 0; tuner < STB_HWGetTunerPaths(); tuner++)
213  {
214  STB_TuneActiveAerialPower(tuner, aerial_pwr);
215  }
216  }
217 
218  ATMR_Initialise();
219 
220  STB_PVRSetStandbyState(FALSE);
221  APVR_Initialise();
222 
223  FUNCTION_FINISH(APP_InitialiseDVB);
224 
225  return(TRUE);
226 }
227 
228 #if 0
229 void APP_TerminateDVB(void)
230 {
231  FUNCTION_START(APP_TerminateDVB);
232 
233  APVR_Terminate();
234  ATMR_Terminate();
235 
236  AEV_Terminate();
237 
238  FUNCTION_FINISH(APP_TerminateDVB);
239 }
240 
241 #endif
242 
243 void APP_RegisterUIInfoCallback(ACB_INFO_CALLBACK ui_info_callback)
244 {
245  FUNCTION_START(APP_RegisterUIInfoCallback);
246  UiInfoCallback = ui_info_callback;
247  FUNCTION_FINISH(APP_RegisterUIInfoCallback);
248 }
249 
250 BOOLEAN ACB_GetUIInformation(S_ACB_UI_INFO *info)
251 {
252  BOOLEAN retval;
253 
254  FUNCTION_START(ACB_GetUIInfo);
255  retval = UiInfoCallback ? UiInfoCallback(info) : FALSE;
256  FUNCTION_FINISH(ACB_GetUIInfo);
257 
258  return retval;
259 }
260 
U8BIT ACFG_GetRegionId(void)
Returns the internal ID of the region the DVB is configured for.
Definition: ap_cfg.c:189
macros and function prototypes for public use
U8BIT ACFG_GetPrimaryAudioLangId(void)
Returns the primary audio language ID.
Definition: ap_cfg.c:204
void STB_ERInitialise(void)
Initialises STB layer Event Reporting control.
Definition: stberc.c:487
void APVR_Initialise(void)
Initialise all PVR resources: filters, recordings etc.
Definition: ap_pvr.c:653
void ADB_Initialise(void)
Initialises database access.
Definition: ap_dbacc.c:167
void STB_OSInitialise(void)
Allows setting of initial boot time.
U8BIT STB_HWGetTunerPaths(void)
Returns the number of front end (Tuner) paths on the platform.
void ASI_InitialiseAppSi(void)
Initialises application SI handling.
Definition: ap_si.c:9369
U8BIT ACFG_GetSecondaryAudioLangId(void)
Returns the secondary audio language ID.
Definition: ap_cfg.c:219
Application configuration.
Header file - macros and function prototypes for public use.
void ACFG_SetSecondaryTextLangId(U8BIT lang_id)
Sets the secondary language id to be used for teletext/subtitles.
Definition: ap_cfg.c:490
Header file for NVM data handling functions.
void ACTL_InitialiseAppControl(void)
Control system initialisation.
Definition: ap_cntrl.c:437
void APVR_Terminate(void)
Destroy all PVR resources: filters, recordings etc.
Definition: ap_pvr.c:706
Header file - Function prototypes for A/V control.
U32BIT APP_NvmRead(E_NVM_ITEMS nvm_item)
Returns the current value for the given DVB setting.
Definition: app_nvm.c:562
void(* DVB_EVENT_HANDLER)(U32BIT event, void *event_data, U32BIT data_size)
The event notification callback function.
Definition: app.h:184
Application timer functions and defines.
void APP_NvmSave(E_NVM_ITEMS nvm_item, U32BIT new_value, BOOLEAN write_to_flash_now)
Sets the current value for the given DVB setting.
Definition: app_nvm.c:634
Header file - macros and function prototypes for public use.
U8BIT ACFG_GetPrimaryTextLangId(void)
Returns the primary DVB subtitle/teletext language ID.
Definition: ap_cfg.c:234
void STB_TuneActiveAerialPower(U8BIT path, BOOLEAN enabled)
Enables/disables aerial power for DVB-T.
BOOLEAN APP_InitialiseDVB(DVB_EVENT_HANDLER event_handler, E_DVB_INIT_SUBS_TTXT subs_ttxt)
Main function to initialise the DVB.
Definition: ap_init.c:95
U8BIT ACFG_GetDefaultSecondaryLangId(void)
Returns the default secondary language for audio and subtitles as defined for the selected country...
Definition: ap_cfg.c:1997
U8BIT ACFG_GetSecondaryTextLangId(void)
Returns the secondary DVB subtitle/teletext language ID.
Definition: ap_cfg.c:249
BOOLEAN ACFG_GetDefaultAerialPower(U32BIT country_code)
Returns the default aerial power option setting for DVB-T/T2 for the given country.
Definition: ap_cfg.c:1447
void STB_PVRSetStandbyState(BOOLEAN state)
Sets the standby state of the PVR path control.
Definition: stbpvr.c:457
Header file - macros and function prototypes for public use.
void ACFG_SetSecondaryAudioLangId(U8BIT lang_id)
Sets the secondary language id to be used for audio.
Definition: ap_cfg.c:440
Debug functions header file.
Header file - Function prototypes for linked lists.
Header file - macros and function prototypes for public use.
Application level CI - internal functions.
void ADB_SetTextLang(U32BIT country_code, U8BIT lang_id)
Sets the primary subtitle and teletext language to be used.
Definition: ap_dbacc.c:7538
Contains the initialise functions for IP.
Header file - Function prototypes for Event Reporting.
Header for STB unicode string handling routines.
void ADB_SetAudioLang(U32BIT country_code, U8BIT lang_id)
Sets the primary audio language to be used.
Definition: ap_dbacc.c:7493
U32BIT ACFG_GetCountry(void)
Returns the country code the DVB is configured for.
Definition: ap_cfg.c:150
application level SI task
Application stb layer control.
Header file - Function prototypes for operating system.
System Wide Global Technical Data Type Definitions.
void ADB_SetSecondaryAudioLang(U32BIT country_code, U8BIT lang_id)
Sets the secondary audio language to be used. This will be selected if the primary audio language isn...
Definition: ap_dbacc.c:7516
void ADB_SetSecondaryTextLang(U32BIT country_code, U8BIT lang_id)
Sets the secondary subtitle and teletext language to be used. This will be used if the primary langua...
Definition: ap_dbacc.c:7561
void ACI_Initialise(void)
Initialise CI Host Control support.
Definition: ap_ci.c:994
BOOLEAN ACFG_GetAerialPowerOptionReqd(U32BIT country_code)
Returns whether the aerial power option is required for DVB-T/T2 for the given country.
Definition: ap_cfg.c:1422
Header file - Function prototypes for heap memory.
Application header file.
void ACFG_SetCountryIds(U32BIT country_code, U8BIT region_id, U8BIT audio_lang_id, U8BIT sub_lang_id)
Saves the configured country and changes settings related to the country.
Definition: ap_cfg.c:297
void STB_SetDefaultAsciiTable(U8BIT table)
Sets default ascii table to be used, if not overridden by the table index at the start of a string...
Definition: stbuni.c:2157
BOOLEAN(* ACB_INFO_CALLBACK)(S_ACB_UI_INFO *info)
Callback function implemented in the UI. This function is called by the DVB module to query values de...
Definition: app.h:173
void ATMR_Initialise(void)
Performs initialisation of the timers, reading existing entries from the database.
Definition: ap_tmr.c:168
void AIP_ConnectToNetwork(BOOLEAN wait_for_completion)
Connect to network based on IP_MODE from NVM e.g. restore from IP NVM and connect to network...
Definition: ap_ipadd.c:92
Application database access functions.
void STB_Initialise(E_STB_TTXT_SUBT_CONTROL ttxt_subt_cntrl)
Initialises STB layer.
Definition: stbinit.c:85
Header file - macros and function prototypes for public use.
void APP_NvmInitialise(void)
Initialises the DVB core&#39;s NVM data.
Definition: app_nvm.c:473