DVBCore  20.3.0
DVBCore Documentation
stbdpc.c
Go to the documentation of this file.
1 /*******************************************************************************
2  * Copyright © 2014 The DTVKit Open Software Foundation Ltd (www.dtvkit.org)
3  * Copyright © 2004 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  *******************************************************************************/
25 /* #define DEBUG_PRINTING_ENABLED */
26 
27 // gives direct COM port access
28 /*#define STB_DEBUG*/
29 /*#define STB_RES_DEBUG*/
30 /*#define STB_TUNE_DEBUG*/
31 
32 //---includes for this file----------------------------------------------------
33 // compiler library header files
34 #include <string.h>
35 #include <stdlib.h>
36 
37 // third party header files
38 
39 // Ocean Blue Software header files
40 
41 #include <techtype.h>
42 #include <dbgfuncs.h>
43 
44 #include "stbhwav.h"
45 #include "stbdpc.h"
46 #include "stbheap.h"
47 #include "stbsic.h"
48 #include "stberc.h"
49 #include "stbpvr.h"
50 #include "stbpvrpr.h"
51 #include "stbhwav.h"
52 #include "stbhwtun.h"
53 #include "stbhwdmx.h"
54 #include "stbhwos.h"
55 #include "stbdpc.h"
56 #include "stbresmgr.h"
57 
58 #ifdef COMMON_INTERFACE
59 #include "stbhwci.h"
60 #endif
61 
62 #include "stbsitab.h"
63 #include "ca_glue.h"
64 
65 
66 //---constant definitions for this file----------------------------------------
67 #ifdef STB_DP_PRINT_REQUIRED
68  #define STB_DP_PRINT(x) DEBUG_PRINTX_CONDITIONAL(DEBUG_STB_DP) x
69 #else
70  #ifdef STB_DEBUG
71  #define STB_DP_PRINT(x) STB_SPDebugWrite x
72  #else
73  #define STB_DP_PRINT(x)
74  #endif
75 #endif
76 
77 #ifdef STB_RES_DEBUG
78  #define STB_RES_PRINT(x) STB_SPDebugWrite x
79 #else
80  #define STB_RES_PRINT(x)
81 #endif
82 
83 #ifdef STB_TUNE_DEBUG
84  #define STB_TUNE_PRINT(x) STB_SPDebugWrite x
85 #else
86  #define STB_TUNE_PRINT(x)
87 #endif
88 
89 #define IS_LIVE_PATH(path) (path_status[path].in_use && \
90  (path_status[path].tuner_no != INVALID_RES_ID) && \
91  (path_status[path].audio_decoder_no != INVALID_RES_ID) && \
92  (path_status[path].video_decoder_no != INVALID_RES_ID))
93 
94 #define IS_RECORDING_PATH(path) (path_status[path].in_use && \
95  (path_status[path].tuner_no != INVALID_RES_ID) && \
96  (path_status[path].is_recording))
97 
98 #define IS_PLAYBACK_PATH(path) (path_status[path].in_use && \
99  (path_status[path].tuner_no == INVALID_RES_ID) && \
100  (path_status[path].audio_decoder_no != INVALID_RES_ID) && \
101  (path_status[path].video_decoder_no != INVALID_RES_ID))
102 
103 #define ACTION_DISH 0x01
104 #define ACTION_SKEW 0x02
105 #define ACTION_TUNE 0x04
106 #define ACTION_SI_NEW 0x08
107 
108 #define ACTION_VIDEO 0x10
109 #define ACTION_AUDIO 0x20
110 #define ACTION_AD 0x40
111 #define ACTION_DECODE_MASK 0xf0
112 
113 /* AD Status */
114 #define AD_ENABLED 0x01
115 #define AD_PID_PRESENT 0x02
116 #define AD_PAUSED 0x04
117 
118 #define TUNER_MIN_SRATE 2000
119 #define TUNER_MAX_SRATE 45000
120 
121 #define UNICABLE_COMMAND_SIZE 5
122 #define UNICABLE_SIGNAL_THRESHOLD 50
123 
124 #define DISEQC_MESSAGE_DELAY 25
125 #define DISEQC_REPEAT_DELAY 100
126 
127 //---local typedef structs for this file---------------------------------------
128 
129 typedef struct
130 {
131  BOOLEAN in_use; /* Flag indicating whether a path is being used */
132  E_STB_DP_PRIORITY priority; /* Priority used when acquiring the path */
133  void *service; /* Service that the path is tuned to */
134 
135  U8BIT tuner_no; /* Tuner being used by this path */
136  U8BIT demux_no; /* Demux being used by this path */
137  U8BIT video_decoder_no; /* Video decoder being used by this path */
138  U8BIT secondary_video_decoder_no; /* Secondary video decoder being used by this path */
139  U8BIT audio_decoder_no; /* Audio decoder being used by this path */
140  U8BIT ad_decoder_no; /* AD decoder being used by this path */
141  U8BIT slot_id; /* id of CI slot assigned to the path */
142  BOOLEAN ca_acquired; /* Is CA handle valid? */
143  U32BIT ca_handle; /* Handle of CA assigned to the path */
144  BOOLEAN lock_enable; /* TRUE if the path is parentally locked */
145  BOOLEAN lock_mode;
146  BOOLEAN search_mode;
147  BOOLEAN is_recording;
148  E_STB_DP_RES_OWNER owner; /* Owner of the decode path */
149  void *owner_data; /* Data held for the owner of the path */
150  U32BIT owner_data_size;
151 } PATH_STATUS;
152 
153 typedef struct
154 {
155  U8BIT number_of_bands;
156  S_STB_DP_LNB_BAND *band_list;
158 
159 typedef struct
160 {
161  E_STB_DP_TUNE_STATUS tune_stat;
162  U8BIT actions;
163  E_STB_DP_SIGNAL_TYPE signal_type;
164  BOOLEAN auto_relock;
165  BOOLEAN tv_search;
166  BOOLEAN rad_search;
167  BOOLEAN fta_search;
168  BOOLEAN scram_search;
169  BOOLEAN net_search;
170  U32BIT si_rparam1;
171  U32BIT si_rparam2;
172  U32BIT si_rparam3;
173  E_STB_OTA_SW_UPGRADE_SEARCH_MODE ota_search_status;
174  E_STB_DP_LNB_POWER lnb_power;
175  E_STB_DP_LNB_TYPE lnb_type;
176  S_LNB_DEFINITION lnb_definition[LNB_TYPE_MAX];
177  BOOLEAN lnb_22k;
178  BOOLEAN lnb_12v;
179  BOOLEAN pulse_position;
180  BOOLEAN diseqc_position;
181  E_STB_DP_DISEQC_CSWITCH diseqc_cswitch;
182  U8BIT diseqc_uswitch;
183  E_STB_DP_DISEQC_TONE diseqc_tone;
184  BOOLEAN diseqc_smatv;
185  U8BIT diseqc_repeats;
186  U16BIT dish_pos;
187  U16BIT skew_pos;
188  U32BIT frequency;
189  E_STB_DP_POLARITY polarity;
190  U16BIT sym_rate;
191  E_STB_DP_FEC fec;
192  BOOLEAN dvb_s2;
193  E_STB_DP_MODULATION modulation;
194  E_STB_DP_TMODE terr_mode;
195  E_STB_DP_TBWIDTH terr_bwidth;
196  E_STB_DP_TTYPE terr_type;
197  U8BIT plp_id;
198  S8BIT freq_offset; /* used for both digital terrestrial and analog frequency offset */
199  E_STB_DP_CMODE cable_mode;
200  E_STB_DP_ANALOG_VIDEO_TYPE anlg_vtype;
201  U32BIT unicable_if;
202  U8BIT unicable_chan;
203  BOOLEAN unicable_position_b;
204  U32BIT diseqc_msg_time;
205  U8BIT num_additional_frequencies;
206  U32BIT *additional_frequencies;
207 } TUNER_STATUS;
208 
209 typedef struct
210 {
211  U16BIT pcr_pid;
212  U16BIT video_pid;
213  U16BIT audio_pid;
214  U16BIT AD_pid;
215  U16BIT text_pid;
216  U16BIT data_pid;
217 
218  E_STB_DP_VIDEO_CODEC video_codec;
219  E_STB_DP_AUDIO_CODEC audio_codec;
220  E_STB_DP_AUDIO_CODEC ad_codec;
221 
222  U8BIT actions;
223 
224  E_STB_DP_DEMUX_SOURCE source_type;
225  U32BIT source_param;
226 } DEMUX_STATUS;
227 
228 typedef struct
229 {
230  E_STB_DP_DECODE_STATUS audio_stat;
231 
232  U8BIT actions;
233 
234  E_STB_DP_DECODE_SOURCE source_type;
235  U32BIT source_param;
236 
237  E_STB_DP_AUDIO_MODE audio_mode;
238 
239  E_STB_DP_AUDIO_CODEC codec;
240 
241  U8BIT source_dmx;
243 
244 typedef struct
245 {
246  E_STB_DP_DECODE_STATUS audio_stat;
247  E_STB_DP_AD_AUDIO ad_audio;
248  U8BIT ad_status;
249  U8BIT actions;
250 
251  E_STB_DP_DECODE_SOURCE source_type;
252  U32BIT source_param;
253  E_STB_DP_AUDIO_MODE audio_mode;
254  E_STB_DP_AUDIO_CODEC codec;
255 
256  U8BIT source_dmx;
258 
259 typedef struct
260 {
261  E_STB_DP_DECODE_STATUS video_stat;
262  U8BIT actions;
263  E_STB_DP_DECODE_SOURCE source_type;
264  U32BIT source_param;
265 
266  E_STB_DP_VIDEO_CODEC codec;
267 
268  U8BIT source_dmx;
270 
271 //---local (static) variable declarations for this file------------------------
272 // (internal variables declared static to make them local)
273 
274 static U8BIT num_paths;
275 static PATH_STATUS *path_status;
276 
277 static U8BIT num_tuners;
278 static TUNER_STATUS *tuner_status;
279 
280 static U8BIT num_demuxes;
281 static DEMUX_STATUS *demux_status;
282 
283 static U8BIT num_audio_decoders;
284 static AUDIO_DECODE_STATUS *audio_decoder_status;
285 static AD_DECODE_STATUS *ad_decoder_status;
286 static U8BIT num_video_decoders;
287 static VIDEO_DECODE_STATUS *video_decoder_status;
288 
289 static void *dp_protect;
290 static BOOLEAN lnb_currently_powered;
291 static BOOLEAN lnb_awake;
292 
293 static S_STB_DP_LNB_BAND lnb_single[2] = {
294  /* polarity, min_freq, max_freq, local_oscillator_frequency, lnb_power, tone_22k */
295  {POLARITY_HORIZONTAL, 0, 0, 5150, LNB_VOLTAGE_18V, FALSE},
296  {POLARITY_VERTICAL, 0, 0, 5150, LNB_VOLTAGE_14V, FALSE}
297 };
298 static S_STB_DP_LNB_BAND lnb_universal[4] = {
299  /* polarity, min_freq, max_freq, local_oscillator_frequency, lnb_power, tone_22k */
300  {POLARITY_HORIZONTAL, 0, 11750, 9750, LNB_VOLTAGE_18V, FALSE},
301  {POLARITY_HORIZONTAL, 11750, 0, 10600, LNB_VOLTAGE_18V, TRUE},
302  {POLARITY_VERTICAL, 0, 11750, 9750, LNB_VOLTAGE_14V, FALSE},
303  {POLARITY_VERTICAL, 11750, 0, 10600, LNB_VOLTAGE_14V, TRUE}
304 };
305 static S_STB_DP_LNB_BAND lnb_unicable[4] = {
306  /* polarity, min_freq, max_freq, local_oscillator_frequency, lnb_power, tone_22k */
307  {POLARITY_HORIZONTAL, 0, 11750, 9750, LNB_VOLTAGE_14V, FALSE},
308  {POLARITY_HORIZONTAL, 11750, 0, 10600, LNB_VOLTAGE_14V, FALSE},
309  {POLARITY_VERTICAL, 0, 11750, 9750, LNB_VOLTAGE_14V, FALSE},
310  {POLARITY_VERTICAL, 11750, 0, 10600, LNB_VOLTAGE_14V, FALSE}
311 };
312 
313 
314 //---local function prototypes for this file-----------------------------------
315 // (internal functions declared static to make them local)
316 
317 static BOOLEAN AcquireResources(U8BIT path, U16BIT demux_caps, BOOLEAN with_decoders);
318 static BOOLEAN StartTune(U8BIT path);
319 static U8BIT GetADEnabled(U8BIT path);
320 static void UnicableSendCommand(U8BIT path, U8BIT cmd[UNICABLE_COMMAND_SIZE]);
321 static void SendDISEQCMessage(U8BIT tuner, U8BIT *msg_data, U8BIT msg_size);
322 static S_STB_DP_LNB_BAND *FindLNBBand(U8BIT path);
323 
324 
325 //---global function definitions-----------------------------------------------
326 
327 /*!**************************************************************************
328  * @brief Initialises decode path control and sets up the structures for
329  * restricting access to resources
330  ****************************************************************************/
332 {
333  E_STB_DMX_DEMUX_SOURCE dmx_source;
334  U8BIT dmx_param;
335  U8BIT i;
336 
337  FUNCTION_START(STB_DPInitialise);
338 
339  num_tuners = STB_HWGetTunerPaths();
340  num_demuxes = STB_HWGetDemuxPaths();
341  num_audio_decoders = STB_HWGetAudioDecodePaths();
342  num_video_decoders = STB_HWGetVideoDecodePaths();
343 
344  num_paths = num_demuxes;
345 
346  STB_RES_PRINT(("STB_DPInitialise(tuners = %d, demuxes = %d, audio/video decoders = %d/%d)",
347  num_tuners, num_demuxes, num_audio_decoders, num_video_decoders));
348  STB_RES_PRINT(("STB_DPInitialise: Max number of paths = %d", num_paths));
349 
350  tuner_status = (TUNER_STATUS *)STB_GetMemory((U32BIT)(sizeof(TUNER_STATUS) * num_tuners));
351  if (tuner_status != NULL)
352  {
353  memset(tuner_status, 0, num_tuners * sizeof(TUNER_STATUS));
354 
355  for (i = 0; i < num_tuners; i++)
356  {
357  tuner_status[i].tune_stat = TUNE_NO_LOCK;
358  tuner_status[i].actions = 0;
359  tuner_status[i].signal_type = SIGNAL_NONE;
360  tuner_status[i].auto_relock = TRUE;
361  tuner_status[i].tv_search = TRUE;
362  tuner_status[i].rad_search = TRUE;
363  tuner_status[i].fta_search = TRUE;
364  tuner_status[i].scram_search = TRUE;
365  tuner_status[i].net_search = TRUE;
366  tuner_status[i].si_rparam1 = 0;
367  tuner_status[i].si_rparam2 = 0;
368  tuner_status[i].si_rparam3 = 0;
369  tuner_status[i].ota_search_status = OTA_SEARCH_OFF;
370  tuner_status[i].lnb_power = LNB_POWER_AUTO;
371  tuner_status[i].lnb_type = LNB_TYPE_UNIVERSAL;
372 
373  memset(tuner_status[i].lnb_definition, 0, LNB_TYPE_MAX * sizeof(S_LNB_DEFINITION));
374 
375  tuner_status[i].lnb_definition[LNB_TYPE_SINGLE].band_list = lnb_single;
376  tuner_status[i].lnb_definition[LNB_TYPE_SINGLE].number_of_bands =
377  sizeof(lnb_single) / sizeof(S_STB_DP_LNB_BAND);
378 
379  tuner_status[i].lnb_definition[LNB_TYPE_UNIVERSAL].band_list = lnb_universal;
380  tuner_status[i].lnb_definition[LNB_TYPE_UNIVERSAL].number_of_bands =
381  sizeof(lnb_universal) / sizeof(S_STB_DP_LNB_BAND);
382 
383  tuner_status[i].lnb_definition[LNB_TYPE_UNICABLE].band_list = lnb_unicable;
384  tuner_status[i].lnb_definition[LNB_TYPE_UNICABLE].number_of_bands =
385  sizeof(lnb_unicable) / sizeof(S_STB_DP_LNB_BAND);
386 
387  tuner_status[i].lnb_22k = FALSE;
388  tuner_status[i].lnb_12v = FALSE;
389  tuner_status[i].pulse_position = FALSE;
390  tuner_status[i].diseqc_position = FALSE;
391  tuner_status[i].diseqc_cswitch = DISEQC_CSWITCH_OFF;
392  tuner_status[i].diseqc_uswitch = 0;
393  tuner_status[i].diseqc_tone = DISEQC_TONE_OFF;
394  tuner_status[i].diseqc_smatv = FALSE;
395  tuner_status[i].diseqc_repeats = 0;
396  tuner_status[i].dish_pos = 0;
397  tuner_status[i].skew_pos = 0;
398  tuner_status[i].frequency = 0;
399  tuner_status[i].polarity = POLARITY_HORIZONTAL;
400  tuner_status[i].sym_rate = 0;
401  tuner_status[i].fec = FEC_AUTOMATIC;
402  tuner_status[i].dvb_s2 = FALSE;
403  tuner_status[i].modulation = MOD_QPSK;
404  tuner_status[i].terr_mode = MODE_COFDM_2K;
405  tuner_status[i].terr_bwidth = TBWIDTH_8MHZ;
406  tuner_status[i].terr_type = TERR_TYPE_UNKNOWN;
407  tuner_status[i].plp_id = 0;
408  tuner_status[i].freq_offset = 0;
409  tuner_status[i].cable_mode = MODE_QAM_AUTO;
410  tuner_status[i].diseqc_msg_time = 0;
411  }
412  }
413 
414  demux_status = (DEMUX_STATUS *)STB_GetMemory((U32BIT)(sizeof(DEMUX_STATUS) * num_demuxes));
415  if (demux_status != NULL)
416  {
417  for (i = 0; i < num_demuxes; i++)
418  {
419  demux_status[i].pcr_pid = 0;
420  demux_status[i].video_pid = 0;
421  demux_status[i].audio_pid = 0;
422  demux_status[i].AD_pid = 0;
423  demux_status[i].text_pid = 0;
424  demux_status[i].data_pid = 0;
425 
426  demux_status[i].actions = 0;
427 
428  STB_DMXGetDemuxSource(i, &dmx_source, &dmx_param);
429 
430  switch (dmx_source)
431  {
432  case DMX_TUNER:
433  demux_status[i].source_type = DEMUX_SOURCE_TUNER;
434  break;
435 
436  case DMX_MEMORY:
437  demux_status[i].source_type = DEMUX_SOURCE_FILE;
438  break;
439 
440  default:
441  demux_status[i].source_type = DEMUX_SOURCE_LINEIN;
442  break;
443  }
444 
445  demux_status[i].source_param = (U32BIT)dmx_param;
446  }
447  }
448 
449  ad_decoder_status = (AD_DECODE_STATUS *)STB_GetMemory((U32BIT)(sizeof(AD_DECODE_STATUS) * num_audio_decoders));
450  if (ad_decoder_status != NULL)
451  {
452  for (i = 0; i < num_audio_decoders; i++)
453  {
454  ad_decoder_status[i].audio_stat = DECODE_STOPPED;
455  ad_decoder_status[i].ad_audio = AD_AUDIO_OFF;
456  ad_decoder_status[i].ad_status = 0;
457  ad_decoder_status[i].actions = 0;
458  ad_decoder_status[i].source_type = DECODE_SOURCE_DEMUX;
459  ad_decoder_status[i].source_param = i;
460  ad_decoder_status[i].audio_mode = AUDIO_MONO;
461  ad_decoder_status[i].codec = AUDIO_CODEC_AUTO;
462  }
463  }
464 
465  audio_decoder_status = (AUDIO_DECODE_STATUS *)STB_GetMemory((U32BIT)(sizeof(AUDIO_DECODE_STATUS) * num_audio_decoders));
466  if (audio_decoder_status != NULL)
467  {
468  for (i = 0; i < num_audio_decoders; i++)
469  {
470  audio_decoder_status[i].audio_stat = DECODE_STOPPED;
471  audio_decoder_status[i].actions = 0;
472  audio_decoder_status[i].source_type = DECODE_SOURCE_DEMUX;
473  audio_decoder_status[i].source_param = i;
474 
475  audio_decoder_status[i].audio_mode = AUDIO_STEREO;
476  audio_decoder_status[i].codec = AUDIO_CODEC_AUTO;
477  }
478  }
479 
480  video_decoder_status = (VIDEO_DECODE_STATUS *)STB_GetMemory((U32BIT)(sizeof(VIDEO_DECODE_STATUS) * num_video_decoders));
481  if (video_decoder_status != NULL)
482  {
483  for (i = 0; i < num_video_decoders; i++)
484  {
485  video_decoder_status[i].video_stat = DECODE_STOPPED;
486  video_decoder_status[i].actions = 0;
487  video_decoder_status[i].source_type = DECODE_SOURCE_DEMUX;
488  video_decoder_status[i].source_param = i;
489  video_decoder_status[i].codec = VIDEO_CODEC_AUTO;
490  }
491  }
492 
493  path_status = (PATH_STATUS *)STB_GetMemory((U32BIT)(sizeof(PATH_STATUS) * num_paths));
494  if (path_status != NULL)
495  {
496  for (i = 0; i < num_paths; i++)
497  {
498  memset(&path_status[i], 0, sizeof(PATH_STATUS));
499 
500  path_status[i].tuner_no = INVALID_RES_ID;
501  path_status[i].demux_no = INVALID_RES_ID;
502  path_status[i].video_decoder_no = INVALID_RES_ID;
503  path_status[i].secondary_video_decoder_no = INVALID_RES_ID;
504  path_status[i].audio_decoder_no = INVALID_RES_ID;
505  path_status[i].ad_decoder_no = INVALID_RES_ID;
506  path_status[i].slot_id = INVALID_RES_ID;
507  path_status[i].ca_acquired = FALSE;
508  path_status[i].ca_handle = INVALID_CA_DESCRAMBLER_HANDLE;
509  path_status[i].lock_enable = FALSE;
510  path_status[i].lock_mode = FALSE;
511  path_status[i].search_mode = FALSE;
512  path_status[i].is_recording = FALSE;
513  path_status[i].owner = RES_OWNER_NONE;
514  path_status[i].owner_data = NULL;
515  path_status[i].owner_data_size = 0;
516  }
517  }
518 
519  lnb_awake = FALSE;
520  lnb_currently_powered = FALSE;
521 
522  dp_protect = STB_OSCreateSemaphore();
523 
524  FUNCTION_FINISH(STB_DPInitialise);
525 }
526 
527 /*!**************************************************************************
528  * @brief Returns the maximum number of decode paths
529  * @param None
530  * @return Number of decode paths
531  ****************************************************************************/
532 U8BIT STB_DPGetNumPaths(void)
533 {
534  FUNCTION_START(STB_DPGetNumPaths);
535  FUNCTION_FINISH(STB_DPGetNumPaths);
536  return(num_paths);
537 }
538 
539 /*!**************************************************************************
540  * @brief Acquires a decode path and all the required resources (tuner, demux, audio
541  * and video decoders). If no tuners are available for live
542  * viewing then a tuner currently being used for recording will be acquired.
543  * It's assumed that there's only one live path in existence and if there's an
544  * attempt to acquire a live path but one exists with a different tuner type then
545  * the acquire will fail, so paths must be released before a new one is acquired.
546  * @param tuner_type - type of tuner to be acquired
547  * @param service - the service that the path will be tuned to, can be NULL
548  * @param transport - the transport that the path will be tuned to, can be NULL
549  * @param owner - module that's acquiring ownership of the path
550  * @param priority - used to control acquisition of a tuner; high priority may result in
551  * a tuner that's already in use by a lower priority path being acquired,
552  * but low priority will never reuse a tuner if the tuner isn't already
553  * tuned to the correct transport.
554  * @param with_decoders - TRUE if decoding resources are to be acquired
555  * @param for_recording - TRUE if the path will be used for recording
556  * @return ID of acquired decode path, or INVALID_RES_ID if none are available
557  ****************************************************************************/
558 U8BIT STB_DPAcquireTunerPath(E_STB_DP_SIGNAL_TYPE tuner_type, void *service, void *transport,
559  E_STB_DP_RES_OWNER owner, E_STB_DP_PRIORITY priority, BOOLEAN with_decoders, BOOLEAN for_recording)
560 {
561  U8BIT path, i, j;
562  U8BIT tuner_num;
563  BOOLEAN high_priority;
564  BOOLEAN tuner_taken;
565  U16BIT dmx_caps;
566 
567  FUNCTION_START(STB_DPAcquireTunerPath);
568 
569  STB_RES_PRINT(("STB_DPAcquireTunerPath(type=%u, serv=%p, trans=%p, owner=%u, priority=%u, decoders=%u, recording=%u)",
570  tuner_type, service, transport, owner, priority, with_decoders, for_recording));
571 
572  path = INVALID_RES_ID;
573 
574  /* Find a free path */
575  for (i = 0; (i < num_paths) && (path == INVALID_RES_ID); i++)
576  {
577  if (!path_status[i].in_use)
578  {
579  if (priority == DP_PRIORITY_HIGH)
580  {
581  high_priority = TRUE;
582  }
583  else
584  {
585  high_priority = FALSE;
586  }
587 
588  /* Acquire a tuner */
589  tuner_num = STB_RESAcquireTuner(tuner_type, transport, owner, high_priority, &tuner_taken);
590  if (tuner_num != INVALID_RES_ID)
591  {
592  path_status[i].tuner_no = tuner_num;
593 
594  if (for_recording)
595  {
596  dmx_caps = DMX_CAPS_RECORDING;
597  }
598  else if (with_decoders)
599  {
600  dmx_caps = DMX_CAPS_LIVE;
601  }
602  else
603  {
604  /* Need a demux that can monitor SI data */
605  dmx_caps = DMX_CAPS_MONITOR_SI;
606  }
607 
608  if (AcquireResources(i, dmx_caps, with_decoders))
609  {
610  if (tuner_taken || (STB_RESGetTunedTransport(tuner_num) != transport))
611  {
612  /* Tuner needs to be retuned so set the tuner status to not locked */
613  tuner_status[tuner_num].tune_stat = TUNE_NO_LOCK;
614  STB_RESSetTunedTransport(tuner_num, transport);
615 
616  if (tuner_taken)
617  {
618  /* The tuner being used by another path is about to be retuned.
619  * Find all paths using this tuner so they can be updated */
620  for (j = 0; j < num_paths; j++)
621  {
622  if ((j != i) && path_status[j].in_use &&
623  (path_status[j].tuner_no == tuner_num) && (path_status[j].service != service))
624  {
625  /* This path is using the tuner that's just been taken, so the service
626  * it's tuned to will change */
627  path_status[j].service = service;
628 
629  STB_ERSendEvent(FALSE, FALSE, EV_CLASS_APPLICATION, EV_TYPE_FORCED_SERVICE_CHANGE,
630  &j, sizeof(U8BIT));
631  }
632  }
633  }
634  }
635 
636  tuner_status[tuner_num].signal_type = tuner_type;
637 
638  path_status[i].in_use = TRUE;
639  path_status[i].priority = priority;
640  path_status[i].service = service;
641  path_status[i].owner = owner;
642  path_status[i].is_recording = for_recording;
643  path = i;
644  }
645  else
646  {
647  /* Release the tuner */
648  STB_RESReleaseTuner(tuner_num, high_priority, owner);
649  path_status[i].tuner_no = INVALID_RES_ID;
650  }
651  }
652  }
653  }
654 
655 #ifdef STB_RES_DEBUG
656  if (path != INVALID_RES_ID)
657  {
658  STB_RES_PRINT(("STB_DPAcquireTunerPath: Acquired path %u, tuner=%u, demux=%u, video=%u, audio=%u",
659  path, path_status[path].tuner_no, path_status[path].demux_no,
660  path_status[path].video_decoder_no, path_status[path].audio_decoder_no));
661  }
662  else
663  {
664  STB_RES_PRINT(("STB_DPAcquireTunerPath: Failed to acquired tuner path"));
665  }
666 #endif
667 
668  FUNCTION_FINISH(STB_DPAcquireTunerPath);
669 
670  return(path);
671 }
672 
673 /*!**************************************************************************
674  * @brief Acquires a decode path and all the required resources (demux, audio and
675  * video decoders) for playing back a recording.
676  * @param void *service - service pointer associated to the playback
677  * @return ID of the acquired playback path, or INVALID_RES_ID if none are available
678  ****************************************************************************/
679 U8BIT STB_DPAcquirePlaybackPath(void *service)
680 {
681  U8BIT path, i;
682  U32BIT param;
683 
684  FUNCTION_START(STB_DPAcquirePlaybackPath);
685 
686  path = INVALID_RES_ID;
687 
688  /* See if there's a playback path already. A playback path is identified as having audio and
689  * video decoders, but no tuner */
690  for (i = 0; (i < num_paths) && (path == INVALID_RES_ID); i++)
691  {
692  if (IS_PLAYBACK_PATH(i))
693  {
694  path = i;
695  }
696  }
697 
698  if (path == INVALID_RES_ID)
699  {
700  /* Look for a path that hasn't been acquired */
701  for (i = 0; (i < num_paths) && (path == INVALID_RES_ID); i++)
702  {
703  if (!path_status[i].in_use)
704  {
705  /* Found an unused path, now acquire the resources needed for playback */
706  path_status[i].demux_no = STB_RESAcquireDemux(INVALID_RES_ID, DMX_CAPS_PLAYBACK);
707  if (path_status[i].demux_no != INVALID_RES_ID)
708  {
709  path_status[i].video_decoder_no = STB_RESAcquireVideoDecoder();
710  if (path_status[i].video_decoder_no != INVALID_RES_ID)
711  {
712  param = (INVALID_RES_ID << 8) | path_status[i].demux_no;
713  STB_RES_PRINT(("STB_DPAcquirePlaybackPath: path=%u, setting video source=0x%x param=0x%x", i, AV_DEMUX, param));
714  STB_AVSetVideoSource(path_status[i].video_decoder_no, AV_DEMUX, param);
715 
716  path_status[i].audio_decoder_no = STB_RESAcquireAudioDecoder();
717  if (path_status[i].audio_decoder_no != INVALID_RES_ID)
718  {
719  /* Acquired all necessary resources */
720  STB_RES_PRINT(("STB_DPAcquirePlaybackPath: path=%u, setting audio source=0x%x param=0x%x", i, AV_DEMUX, param));
721 
722  STB_AVSetAudioSource(path_status[i].audio_decoder_no, AV_DEMUX, param);
723 
724  path_status[i].ad_decoder_no = STB_RESAcquireADDecoder();
725  if (path_status[i].ad_decoder_no != INVALID_RES_ID)
726  {
727  STB_AVSetADSource(path_status[i].ad_decoder_no, AV_DEMUX, param);
728  }
729 
730  path_status[i].in_use = TRUE;
731  path_status[i].service = service;
732  path_status[i].owner = RES_OWNER_NONE;
733  path = i;
734 
735  /* Set the demux to get its data from memory */
736  STB_DMXSetDemuxSource(path_status[i].demux_no, DMX_MEMORY, 0);
737  }
738  else
739  {
740  /* Not all resources are available so release acquired resources */
741  STB_RESReleaseVideoDecoder(path_status[i].video_decoder_no);
742  path_status[i].video_decoder_no = INVALID_RES_ID;
743 
744  STB_RESReleaseDemux(path_status[i].demux_no);
745  path_status[i].demux_no = INVALID_RES_ID;
746  }
747  }
748  else
749  {
750  /* Not all resources are available so release acquired resources */
751  STB_RESReleaseDemux(path_status[i].demux_no);
752  path_status[i].demux_no = INVALID_RES_ID;
753  }
754  }
755  }
756  }
757  }
758 
759 #ifdef STB_RES_DEBUG
760  if (path != INVALID_RES_ID)
761  {
762  STB_RES_PRINT(("STB_DPAcquirePlaybackPath: Acquired playback path %u, demux=%u, video=%u, audio=%u",
763  path, path_status[path].demux_no, path_status[path].video_decoder_no,
764  path_status[path].audio_decoder_no));
765  }
766  else
767  {
768  STB_RES_PRINT(("STB_DPAcquirePlaybackPath: Acquired playback path %u", path));
769  }
770 #endif
771 
772  FUNCTION_FINISH(STB_DPAcquirePlaybackPath);
773 
774  return(path);
775 }
776 
777 /*!**************************************************************************
778  * @brief Releases the decode path and all resources no longer needed.
779  * The path won't be released if the path is owned by a module and the
780  * owner argument doesn't match the path's owner
781  * @param path - decode path
782  * @param owner - module releasing the path
783  * @return TRUE if the path is released, FALSE otherwise
784  ****************************************************************************/
785 BOOLEAN STB_DPReleasePath(U8BIT path, E_STB_DP_RES_OWNER owner)
786 {
787  BOOLEAN retval;
788  BOOLEAN high_priority;
789 
790  FUNCTION_START(STB_DPReleasePath);
791 
792  ASSERT(path < num_paths);
793 
794  retval = FALSE;
795 
796  if (path < num_paths)
797  {
798  STB_RES_PRINT(("STB_DPReleasePath(path=%u, owner=%u): in_use=%u, owner=%u",
799  path, owner, path_status[path].in_use, path_status[path].owner));
800 
801  if (path_status[path].in_use &&
802  ((path_status[path].owner == RES_OWNER_NONE) || (path_status[path].owner == owner)))
803  {
804  path_status[path].in_use = FALSE;
805 
806  /* This path isn't being used anymore so all resources can be released */
808 
809  if (path_status[path].tuner_no != INVALID_RES_ID)
810  {
811  if (path_status[path].priority == DP_PRIORITY_HIGH)
812  {
813  high_priority = TRUE;
814  }
815  else
816  {
817  high_priority = FALSE;
818  }
819 
820  STB_RESReleaseTuner(path_status[path].tuner_no, high_priority, owner);
821  path_status[path].tuner_no = INVALID_RES_ID;
822  }
823 
824  path_status[path].service = NULL;
825 
826  STB_RESReleaseDemux(path_status[path].demux_no);
827  path_status[path].demux_no = INVALID_RES_ID;
828 
829  if (path_status[path].video_decoder_no != INVALID_RES_ID)
830  {
831  STB_RESReleaseVideoDecoder(path_status[path].video_decoder_no);
832  path_status[path].video_decoder_no = INVALID_RES_ID;
833  }
834 
835  if (path_status[path].secondary_video_decoder_no != INVALID_RES_ID)
836  {
837  STB_RESReleaseVideoDecoder(path_status[path].secondary_video_decoder_no);
838  path_status[path].secondary_video_decoder_no = INVALID_RES_ID;
839  }
840 
841  if (path_status[path].audio_decoder_no != INVALID_RES_ID)
842  {
843  STB_RESReleaseAudioDecoder(path_status[path].audio_decoder_no);
844  path_status[path].audio_decoder_no = INVALID_RES_ID;
845  }
846 
847  if (path_status[path].ad_decoder_no != INVALID_RES_ID)
848  {
849  STB_RESReleaseADDecoder(path_status[path].ad_decoder_no);
850  path_status[path].ad_decoder_no = INVALID_RES_ID;
851  }
852 
853  if (path_status[path].ca_acquired)
854  {
855  path_status[path].ca_acquired = !STB_CAReleaseDescrambler(path_status[path].ca_handle);
856  }
857 #ifdef STB_RES_DEBUG
858  else
859  {
860  STB_RES_PRINT(("STB_DPReleasePath(path=%u): no CA slot on this path", path));
861  }
862 #endif
863 
864  path_status[path].owner = RES_OWNER_NONE;
865 
866  if (path_status[path].owner_data != NULL)
867  {
868  STB_FreeMemory(path_status[path].owner_data);
869  path_status[path].owner_data = NULL;
870  path_status[path].owner_data_size = 0;
871  }
872 
873  retval = TRUE;
874  }
875 #ifdef STB_RES_DEBUG
876  else
877  {
878  STB_RES_PRINT(("STB_DPReleasePath(path=%u): Failed to release path", path));
879  }
880 #endif
881  }
882 
883  FUNCTION_FINISH(STB_DPReleasePath);
884 
885  return(retval);
886 }
887 
888 /*!**************************************************************************
889  * @brief Releases all decoders from the given path
890  ****************************************************************************/
891 void STB_DPReleaseDecoders(U8BIT path)
892 {
893  FUNCTION_START(STB_DPReleaseDecoders);
894 
895  ASSERT(path < num_paths);
896 
897  STB_RES_PRINT(("STB_DPReleaseDecoders(%u)", path));
898 
899  if (path < num_paths)
900  {
901  if (path_status[path].video_decoder_no != INVALID_RES_ID)
902  {
903  STB_RESReleaseVideoDecoder(path_status[path].video_decoder_no);
904  path_status[path].video_decoder_no = INVALID_RES_ID;
905  }
906 
907  if (path_status[path].secondary_video_decoder_no != INVALID_RES_ID)
908  {
909  STB_RESReleaseVideoDecoder(path_status[path].secondary_video_decoder_no);
910  path_status[path].secondary_video_decoder_no = INVALID_RES_ID;
911  }
912 
913  if (path_status[path].audio_decoder_no != INVALID_RES_ID)
914  {
915  STB_RESReleaseAudioDecoder(path_status[path].audio_decoder_no);
916  path_status[path].audio_decoder_no = INVALID_RES_ID;
917  }
918 
919  if (path_status[path].ad_decoder_no != INVALID_RES_ID)
920  {
921  STB_RESReleaseADDecoder(path_status[path].ad_decoder_no);
922  path_status[path].ad_decoder_no = INVALID_RES_ID;
923  }
924  }
925 
926  FUNCTION_FINISH(STB_DPReleaseDecoders);
927 }
928 
929 /*!**************************************************************************
930  * @brief Releases all decode paths and all the resources they are using
931  * @return None
932  ****************************************************************************/
934 {
935  U8BIT path, num_paths;
936 
937  FUNCTION_START(STB_DPReleaseAllPaths);
938 
939  STB_RES_PRINT(("STB_DPReleaseAllPaths()"));
940 
941  num_paths = STB_DPGetNumPaths();
942 
943  for (path = 0; path < num_paths; path++)
944  {
945  STB_DPReleasePath(path, RES_OWNER_NONE);
946  }
947 
948  FUNCTION_FINISH(STB_DPReleaseAllPaths);
949 }
950 
951 /*!**************************************************************************
952  * @brief Acquire a CI slot and assign it to the given path
953  * @param path - decode path wanting the CI slot resource
954  * @return slot id acquired, INVALID_RES_ID if none acquired
955  ****************************************************************************/
956 U8BIT STB_DPAcquireCISlotForPath(U8BIT path, U8BIT *pmt_data, U8BIT *ci_protection_desc)
957 {
958  U8BIT retval;
959 
960  FUNCTION_START(STB_DPAcquireCISlotForPath);
961 
962 #ifndef COMMON_INTERFACE
963  USE_UNWANTED_PARAM(path);
964  USE_UNWANTED_PARAM(pmt_data);
965  USE_UNWANTED_PARAM(ci_protection_desc);
966 #endif
967 
968  ASSERT(path < num_paths);
969 
970  retval = INVALID_RES_ID;
971 
972 #ifdef COMMON_INTERFACE
973  if (path < num_paths)
974  {
975  if (path_status[path].slot_id == INVALID_RES_ID)
976  {
977  retval = STB_RESAcquireCISlot(path_status[path].service,
978  pmt_data, ci_protection_desc);
979  if (retval != INVALID_RES_ID)
980  {
981  /* Route the TS from the path's tuner through the CI slot if the tuner is valid
982  * and the slot wasn't already being used */
983  if ((path_status[path].tuner_no != INVALID_RES_ID) &&
984  (STB_RESGetCISlotUsageCount(retval) == 1))
985  {
986  STB_CIRouteTS(path_status[path].tuner_no, retval, TRUE);
987  }
988  path_status[path].slot_id = retval;
989  }
990  }
991  else
992  {
993  retval = path_status[path].slot_id;
994  STB_RES_PRINT(("%s(%u): Path already has CI slot %u", __FUNCTION__, path,
995  path_status[path].slot_id));
996  }
997  }
998 #endif
999 
1000  FUNCTION_FINISH(STB_DPAcquireCISlotForPath);
1001 
1002  return(retval);
1003 }
1004 
1005 /*!**************************************************************************
1006  * @brief Use the given CI slot with the given path
1007  * @param path - decode path
1008  * @param slot_id - CI slot id
1009  * @return TRUE if the slot can be used, FALSE otherwise
1010  ****************************************************************************/
1011 BOOLEAN STB_DPUseCISlotWithPath(U8BIT path, U8BIT slot_id)
1012 {
1013  BOOLEAN retval;
1014 
1015  FUNCTION_START(STB_DPUseCISlotWithPath);
1016 
1017 #ifndef COMMON_INTERFACE
1018  USE_UNWANTED_PARAM(path);
1019  USE_UNWANTED_PARAM(slot_id);
1020 #endif
1021 
1022  retval = FALSE;
1023 
1024  STB_RES_PRINT(("%s(path=%u, slot=%u)", __FUNCTION__, path, slot_id));
1025 
1026 #ifdef COMMON_INTERFACE
1027  if (STB_RESUseCISlot(slot_id))
1028  {
1029  path_status[path].slot_id = slot_id;
1030 
1031  /* Route the TS from the path's tuner through the CI slot if the tuner is valid
1032  * and the slot wasn't already being used */
1033  if (path_status[path].tuner_no != INVALID_RES_ID)
1034  {
1035  STB_CIRouteTS(path_status[path].tuner_no, slot_id, TRUE);
1036  }
1037 
1038  retval = TRUE;
1039  }
1040 #endif
1041 
1042  FUNCTION_FINISH(STB_DPUseCISlotWithPath);
1043 
1044  return(retval);
1045 }
1046 
1047 /*!**************************************************************************
1048  * @brief Release the CI slot associated with the given path
1049  * @param path - decode path using the CI slot
1050  ****************************************************************************/
1052 {
1053  FUNCTION_START(STB_DPReleaseCISlotFromPath);
1054 
1055  ASSERT(path < num_paths);
1056 
1057  STB_RES_PRINT(("STB_DPReleaseCISlotFromPath(%u): slot_id=%u", path, path_status[path].slot_id));
1058 
1059  if ((path < num_paths) && (path_status[path].slot_id != INVALID_RES_ID))
1060  {
1061  STB_RESReleaseCISlot(path_status[path].slot_id);
1062 
1063 #ifdef COMMON_INTERFACE
1064  if ((path_status[path].tuner_no != INVALID_RES_ID) &&
1065  (STB_RESGetCISlotUsageCount(path_status[path].slot_id) == 0))
1066  {
1067  /* Stop routing the TS from this tuner through the CI slot */
1068  STB_CIRouteTS(path_status[path].tuner_no, path_status[path].slot_id, FALSE);
1069  }
1070 #endif
1071 
1072  path_status[path].slot_id = INVALID_RES_ID;
1073  }
1074 
1075  FUNCTION_FINISH(STB_DPReleaseCISlotFromPath);
1076 }
1077 
1078 /*!**************************************************************************
1079  * @brief Returns the CI slot id associated with the given path
1080  * @return id of assigned CI slot or INVALID_RES_ID if not assigned
1081  ****************************************************************************/
1082 U8BIT STB_DPGetPathCISlot(U8BIT path)
1083 {
1084  U8BIT slot_id;
1085 
1086  FUNCTION_START(STB_DPGetPathCISlot);
1087 
1088  slot_id = INVALID_RES_ID;
1089 
1090  if (path < num_paths)
1091  {
1092  slot_id = path_status[path].slot_id;
1093  }
1094 
1095  FUNCTION_FINISH(STB_DPGetPathCISlot);
1096 
1097  return(slot_id);
1098 }
1099 
1100 /*!**************************************************************************
1101  * @brief Checks whether a given CI slot is in use
1102  * @param start_path - path id to start the search with. Use INVALID_RES_ID to start from first path
1103  * @param slot_id - CI slot to be checked
1104  * @param ignore_path - decode path to be ignored (i.e. don't check if current
1105  * path is using a slot). This can be INVALID_RES_ID to
1106  * check all paths
1107  * @return decode path using the slot or INVALID_RES_ID if not in use
1108  ****************************************************************************/
1109 U8BIT STB_DPIsCISlotInUse(U8BIT start_path, U8BIT slot_id, U8BIT ignore_path)
1110 {
1111  U8BIT retval;
1112  U8BIT path;
1113 
1114  FUNCTION_START(STB_DPIsCISlotInUse);
1115 
1116  retval = INVALID_RES_ID;
1117 
1118  if (start_path == INVALID_RES_ID)
1119  {
1120  start_path = 0;
1121  }
1122 
1123  for (path = start_path; (path < num_paths) && (retval == INVALID_RES_ID); path++)
1124  {
1125  if (path_status[path].slot_id == slot_id)
1126  {
1127  if ((ignore_path == INVALID_RES_ID) || (path != ignore_path))
1128  {
1129  retval = path;
1130  }
1131  }
1132  }
1133 
1134  FUNCTION_FINISH(STB_DPIsCISlotInUse);
1135 
1136  return(retval);
1137 }
1138 
1139 /*!**************************************************************************
1140  * @brief Acquire a CA descrambler and assign it to the given path
1141  * @param path - decode path wanting the CI slot resource
1142  * @param pmt_data - pmt section data for the present service on the path
1143  * @param ca_handle - pointer in which the CA descrambler handle is returned
1144  * @return TRUE if a CA descrambler is already associated with the given path,
1145  * or one is successfully acquired, FALSE otherwise
1146  ****************************************************************************/
1147 BOOLEAN STB_DPAcquireCADescramblerForPath(U8BIT path, U8BIT *pmt_data, U32BIT *ca_handle)
1148 {
1149  BOOLEAN retval;
1150  U16BIT num_pmt_ca_ids;
1151  U16BIT *pmt_ca_ids;
1152  U8BIT demux_path;
1153  U16BIT serv_id;
1154 
1155  FUNCTION_START(STB_DPAcquireCADescramblerForPath);
1156 
1157  ASSERT(path < num_paths);
1158 
1159  if (path < num_paths)
1160  {
1161  retval = path_status[path].ca_acquired;
1162  if ((pmt_data != NULL) && !path_status[path].ca_acquired)
1163  {
1164  demux_path = STB_DPGetPathDemux(path);
1165  if (demux_path != INVALID_RES_ID)
1166  {
1167  /* Service ID is the xtid in the PMT */
1168  serv_id = (pmt_data[3] << 8) + pmt_data[4];
1169 
1170  num_pmt_ca_ids = STB_SIGetPmtCaIdDescArray(pmt_data, &pmt_ca_ids);
1171 
1172  /* Always attempt to acquire a CA descrambler even if there aren't any CA IDs
1173  * in the PMT, because some CA systems want full control over free services too */
1174  path_status[path].ca_acquired = STB_CAAcquireDescrambler(demux_path, serv_id,
1175  pmt_ca_ids, num_pmt_ca_ids, &path_status[path].ca_handle);
1176  if (path_status[path].ca_acquired)
1177  {
1178  retval = TRUE;
1179  *ca_handle = path_status[path].ca_handle;
1180  STB_RES_PRINT(("%s(%u): Acquired CA descrambler 0x%lx", __FUNCTION__, path,
1181  path_status[path].ca_handle));
1182  }
1183 #ifdef STB_RES_DEBUG
1184  else
1185  {
1186  STB_RES_PRINT(("%s(%u): No CA descrambler acquired", __FUNCTION__, path));
1187  }
1188 #endif
1189  STB_SIReleaseCaIdDescArray(pmt_ca_ids, num_pmt_ca_ids);
1190  }
1191 #ifdef STB_RES_DEBUG
1192  else
1193  {
1194  STB_RES_PRINT(("%s(%u), invalid demux path", __FUNCTION__, path));
1195  }
1196 #endif
1197  }
1198 #ifdef STB_RES_DEBUG
1199  else
1200  {
1201  STB_RES_PRINT(("%s(%u): Path already has a CA descrambler", __FUNCTION__, path));
1202  }
1203 #endif
1204  }
1205  else
1206  {
1207  retval = FALSE;
1208  STB_RES_PRINT(("%s(%u): Invalid path", __FUNCTION__, path));
1209  }
1210 
1211  FUNCTION_FINISH(STB_DPAcquireCADescramblerForPath);
1212 
1213  return(retval);
1214 }
1215 
1216 /*!**************************************************************************
1217  * @brief Release the CA descrambler associated with the given path
1218  * @param path - decode path from which the CA descrambler is to be released
1219  ****************************************************************************/
1221 {
1222  FUNCTION_START(STB_DPReleaseCADescramblerFromPath);
1223 
1224  ASSERT(path < num_paths);
1225 
1226  STB_RES_PRINT(("%s(path=%u): acquired=%u, handle=0x%lx", __FUNCTION__, path,
1227  path_status[path].ca_acquired, path_status[path].ca_handle));
1228 
1229  if ((path < num_paths) && path_status[path].ca_acquired)
1230  {
1231  path_status[path].ca_acquired = !STB_CAReleaseDescrambler(path_status[path].ca_handle);
1232  }
1233 
1234  FUNCTION_FINISH(STB_DPReleaseCADescramblerFromPath);
1235 }
1236 
1237 /*!**************************************************************************
1238  * @brief Get the handle of the CA descrambler associated with the given path
1239  * @param path - decode path
1240  * @param handle - pointer in which the CA descrambler handle will be returned
1241  * @return TRUE if the path has a CA descrambler associated with it and the handle
1242  * is returned, FALSE otherwise
1243  ****************************************************************************/
1244 BOOLEAN STB_DPGetPathCADescrambler(U8BIT path, U32BIT *handle)
1245 {
1246  BOOLEAN retval;
1247 
1248  FUNCTION_START(STB_DPGetPathCADescrambler);
1249 
1250  retval = FALSE;
1251  *handle = INVALID_CA_DESCRAMBLER_HANDLE;
1252 
1253  if (path < num_paths)
1254  {
1255  retval = path_status[path].ca_acquired;
1256  if (retval)
1257  {
1258  *handle = path_status[path].ca_handle;
1259  }
1260  }
1261 
1262  FUNCTION_FINISH(STB_DPGetPathCADescrambler);
1263 
1264  return(retval);
1265 }
1266 
1267 /*!**************************************************************************
1268  * @brief Returns the ID of the decode path being used for live viewing
1269  * @return ID of live path or INVALID_RES_ID if none found
1270  ****************************************************************************/
1272 {
1273  U8BIT path, i;
1274 
1275  FUNCTION_START(STB_DPGetLivePath);
1276 
1277  path = INVALID_RES_ID;
1278 
1279  for (i = 0; (i < num_paths) && (path == INVALID_RES_ID); i++)
1280  {
1281  if (IS_LIVE_PATH(i))
1282  {
1283  path = i;
1284  }
1285  }
1286 
1287  FUNCTION_FINISH(STB_DPGetLivePath);
1288 
1289  return(path);
1290 }
1291 
1292 /*!**************************************************************************
1293  * @brief Is the given decode path being used for live viewing
1294  * @param path - ID of decode path
1295  * @return TRUE if the path is being used for live viewing
1296  ****************************************************************************/
1297 BOOLEAN STB_DPIsLivePath(U8BIT path)
1298 {
1299  BOOLEAN is_live = FALSE;
1300 
1301  FUNCTION_START(STB_DPIsLivePath);
1302 
1303  ASSERT(path < num_paths);
1304 
1305  if (path < num_paths)
1306  {
1307  is_live = IS_LIVE_PATH(path);
1308  }
1309 
1310  FUNCTION_FINISH(STB_DPIsLivePath);
1311 
1312  return(is_live);
1313 }
1314 
1315 /*!**************************************************************************
1316  * @brief Is the given decode path being used for recording
1317  * @param path - ID of decode path
1318  * @return TRUE if the path is being used for recording
1319  ****************************************************************************/
1320 BOOLEAN STB_DPIsRecordingPath(U8BIT path)
1321 {
1322  BOOLEAN is_recording = FALSE;
1323 
1324  FUNCTION_START(STB_DPIsRecordingPath);
1325 
1326  ASSERT(path < num_paths);
1327 
1328  if (path < num_paths)
1329  {
1330  if (IS_RECORDING_PATH(path))
1331  {
1332  is_recording = TRUE;
1333  }
1334  }
1335 
1336  FUNCTION_FINISH(STB_DPIsRecordingPath);
1337 
1338  return(is_recording);
1339 }
1340 
1341 /*!**************************************************************************
1342  * @brief Is the given decode path being used for decoding
1343  * @param path - ID of decode path
1344  * @return TRUE if the path has an audio or video decoder assigned to it
1345  ****************************************************************************/
1346 BOOLEAN STB_DPIsDecodingPath(U8BIT path)
1347 {
1348  BOOLEAN is_decoding = FALSE;
1349 
1350  FUNCTION_START(STB_DPIsDecodingPath);
1351 
1352  ASSERT(path < num_paths);
1353 
1354  if (path < num_paths)
1355  {
1356  if ((path_status[path].video_decoder_no != INVALID_RES_ID) ||
1357  (path_status[path].audio_decoder_no != INVALID_RES_ID))
1358  {
1359  is_decoding = TRUE;
1360  }
1361  }
1362 
1363  FUNCTION_FINISH(STB_DPIsDecodingPath);
1364 
1365  return(is_decoding);
1366 }
1367 
1368 /*!**************************************************************************
1369  * @brief Returns the ID of the decode path being used for playback
1370  * @param None
1371  * @return ID of playback path or INVALID_RES_ID if none found
1372  ****************************************************************************/
1374 {
1375  U8BIT path, i;
1376 
1377  FUNCTION_START(STB_DPGetPlaybackPath);
1378 
1379  path = INVALID_RES_ID;
1380 
1381  for (i = 0; (i < num_paths) && (path == INVALID_RES_ID); i++)
1382  {
1383  if (IS_PLAYBACK_PATH(i))
1384  {
1385  path = i;
1386  }
1387  }
1388 
1389  FUNCTION_FINISH(STB_DPGetPlaybackPath);
1390 
1391  return(path);
1392 }
1393 
1394 /*!**************************************************************************
1395  * @brief Returns the decode path that is using the given tuner ID
1396  * @param start_path - path to start searching from, use INVALID_RES_ID to start from 0
1397  * @param tuner_num - ID of tuner
1398  * @return ID of the decode path or INVALID_RES_ID if none found
1399  ****************************************************************************/
1400 U8BIT STB_DPPathForTuner(U8BIT start_path, U8BIT tuner_num)
1401 {
1402  U8BIT path = INVALID_RES_ID;
1403  U8BIT i;
1404 
1405  FUNCTION_START(STB_DPPathForTuner);
1406 
1407  ASSERT(tuner_num < num_tuners);
1408 
1409  if (start_path == INVALID_RES_ID)
1410  {
1411  i = 0;
1412  }
1413  else
1414  {
1415  i = start_path + 1;
1416  }
1417 
1418  for (; (i < num_paths) && (path == INVALID_RES_ID); i++)
1419  {
1420  if (path_status[i].tuner_no == tuner_num)
1421  {
1422  path = i;
1423  }
1424  }
1425 
1426  FUNCTION_FINISH(STB_DPPathForTuner);
1427 
1428  return(path);
1429 }
1430 
1431 /*!**************************************************************************
1432  * @brief Returns the decode path that is using the given audio decoder
1433  * @param decoder_num - ID of the audio decoder
1434  * @return ID of the decode path or INVALID_RES_ID if none found
1435  ****************************************************************************/
1436 U8BIT STB_DPPathForAudioDecoder(U8BIT decoder_num)
1437 {
1438  U8BIT path = INVALID_RES_ID;
1439  U8BIT i;
1440 
1441  FUNCTION_START(STB_DPPathForAudioDecoder);
1442 
1443  ASSERT(decoder_num < num_audio_decoders);
1444 
1445  for (i = 0; (i < num_paths) && (path == INVALID_RES_ID); i++)
1446  {
1447  if (path_status[i].audio_decoder_no == decoder_num)
1448  {
1449  path = i;
1450  }
1451  }
1452 
1453  FUNCTION_FINISH(STB_DPPathForAudioDecoder);
1454 
1455  return(path);
1456 }
1457 
1458 /*!**************************************************************************
1459  * @brief Returns the decode path that is using the given AD decoder
1460  * @param decoder_num - ID of the AD decoder
1461  * @return ID of the decode path or INVALID_RES_ID if none found
1462  ****************************************************************************/
1463 U8BIT STB_DPPathForADDecoder(U8BIT decoder_num)
1464 {
1465  U8BIT path = INVALID_RES_ID;
1466  U8BIT i;
1467 
1468  FUNCTION_START(STB_DPPathForADDecoder);
1469 
1470  ASSERT(decoder_num < num_audio_decoders);
1471 
1472  for (i = 0; (i < num_paths) && (path == INVALID_RES_ID); i++)
1473  {
1474  if (path_status[i].ad_decoder_no == decoder_num)
1475  {
1476  path = i;
1477  }
1478  }
1479 
1480  FUNCTION_FINISH(STB_DPPathForADDecoder);
1481 
1482  return(path);
1483 }
1484 
1485 /*!**************************************************************************
1486  * @brief Returns the decode path that is using the given video decoder
1487  * @param decoder_num - ID of the video decoder
1488  * @return ID of the decode path or INVALID_RES_ID if none found
1489  ****************************************************************************/
1490 U8BIT STB_DPPathForVideoDecoder(U8BIT decoder_num)
1491 {
1492  U8BIT path = INVALID_RES_ID;
1493  U8BIT i;
1494 
1495  FUNCTION_START(STB_DPPathForVideoDecoder);
1496 
1497  ASSERT(decoder_num < num_video_decoders);
1498 
1499  for (i = 0; (i < num_paths) && (path == INVALID_RES_ID); i++)
1500  {
1501  if (path_status[i].video_decoder_no == decoder_num)
1502  {
1503  path = i;
1504  }
1505  }
1506 
1507  FUNCTION_FINISH(STB_DPPathForVideoDecoder);
1508 
1509  return(path);
1510 }
1511 
1512 /*!**************************************************************************
1513  * @brief Saves the given transport with the specified decode path
1514  * @param path - ID of decode path
1515  * @param transport - pointer to transport to be saved
1516  * @return None
1517  ****************************************************************************/
1518 void STB_DPSetTunedTransport(U8BIT path, void *transport)
1519 {
1520  FUNCTION_START(STB_DPSetTunedTransport);
1521 
1522  ASSERT(path < num_paths);
1523 
1524  if ((path < num_paths) && (path_status[path].tuner_no != INVALID_RES_ID))
1525  {
1526  STB_RESSetTunedTransport(path_status[path].tuner_no, transport);
1527  }
1528 
1529  FUNCTION_FINISH(STB_DPSetTunedTransport);
1530 }
1531 
1532 /*!**************************************************************************
1533  * @brief Returns the transport saved with the given decode path
1534  * @param path - ID of decode path
1535  * @return Pointer to saved transport
1536  ****************************************************************************/
1537 void* STB_DPGetTunedTransport(U8BIT path)
1538 {
1539  void *transport = NULL;
1540 
1541  FUNCTION_START(STB_DPGetTunedTransport);
1542 
1543  ASSERT(path < num_paths);
1544 
1545  if ((path < num_paths) && (path_status[path].tuner_no != INVALID_RES_ID))
1546  {
1547  if (tuner_status[path_status[path].tuner_no].tune_stat == TUNE_LOCKED)
1548  {
1549  transport = STB_RESGetTunedTransport(path_status[path].tuner_no);
1550  }
1551  }
1552 
1553  FUNCTION_FINISH(STB_DPGetTunedTransport);
1554 
1555  return(transport);
1556 }
1557 
1558 /*!**************************************************************************
1559  * @brief Saves the given service with the specified decode path
1560  * @param path - ID of decode path
1561  * @param service - pointer to service to be saved
1562  ****************************************************************************/
1563 void STB_DPSetTunedService(U8BIT path, void *service)
1564 {
1565  FUNCTION_START(STB_DPSetTunedService);
1566 
1567  ASSERT(path < num_paths);
1568 
1569  if ((path < num_paths) && path_status[path].in_use)
1570  {
1571  path_status[path].service = service;
1572  }
1573 
1574  FUNCTION_FINISH(STB_DPSetTunedService);
1575 }
1576 
1577 /*!**************************************************************************
1578  * @brief Returns the service saved with the given decode path
1579  * @param path - ID of decode path
1580  * @return Pointer to saved service
1581  ****************************************************************************/
1582 void* STB_DPGetTunedService(U8BIT path)
1583 {
1584  void *service = NULL;
1585 
1586  FUNCTION_START(STB_DPGetTunedService);
1587 
1588  ASSERT(path < num_paths);
1589 
1590  if ((path < num_paths) && path_status[path].in_use)
1591  {
1592  service = path_status[path].service;
1593  }
1594 
1595  FUNCTION_FINISH(STB_DPGetTunedService);
1596 
1597  return(service);
1598 }
1599 
1600 /*!**************************************************************************
1601  * @brief Returns the tuner ID acquired by the given decode path
1602  * @param path - ID of decode path
1603  * @return ID of tuner used by the decode path
1604  ****************************************************************************/
1605 U8BIT STB_DPGetPathTuner(U8BIT path)
1606 {
1607  U8BIT tuner_num = INVALID_RES_ID;
1608 
1609  FUNCTION_START(STB_DPGetPathTuner);
1610 
1611  ASSERT(path < num_paths);
1612 
1613  if (path < num_paths)
1614  {
1615  tuner_num = path_status[path].tuner_no;
1616  }
1617 
1618  FUNCTION_FINISH(STB_DPGetPathTuner);
1619 
1620  return(tuner_num);
1621 }
1622 
1623 /*!**************************************************************************
1624  * @brief Returns the tuner type for the given path
1625  * @param path - ID of decode path
1626  * @return tuner type
1627  ****************************************************************************/
1628 E_STB_DP_SIGNAL_TYPE STB_DPGetPathTunerType(U8BIT path)
1629 {
1630  E_STB_DP_SIGNAL_TYPE type;
1631 
1632  FUNCTION_START(STB_DPGetPathTunerType);
1633 
1634  ASSERT(path < num_paths);
1635 
1636  type = SIGNAL_NONE;
1637 
1638  if (path < num_paths)
1639  {
1640  type = STB_RESGetTunerType(path_status[path].tuner_no);
1641  }
1642 
1643  FUNCTION_FINISH(STB_DPGetPathTunerType);
1644 
1645  return(type);
1646 }
1647 
1653 {
1654  U8BIT id;
1655 
1656  FUNCTION_START(STB_DPEnableAllTuners);
1657 
1658  for (id = 0; id < num_tuners; id++)
1659  {
1660  STB_RESSetTunerDisabled(id, FALSE);
1661  }
1662 
1663  FUNCTION_FINISH(STB_DPEnableAllTuners);
1664 }
1665 
1671 void STB_DPSetTunerDisabled(U8BIT path, BOOLEAN disabled)
1672 {
1673  FUNCTION_START(STB_DPSetTunerDisabled);
1674 
1675  if ((path < num_paths) && (path_status[path].tuner_no != INVALID_RES_ID))
1676  {
1677  STB_RESSetTunerDisabled(path_status[path].tuner_no, disabled);
1678  }
1679 
1680  FUNCTION_FINISH(STB_DPSetTunerDisabled);
1681 }
1682 
1688 {
1689  FUNCTION_START(STB_DPGetNumEnabledTuners);
1690  FUNCTION_FINISH(STB_DPGetNumEnabledTuners);
1691  return(STB_RESNumEnabledTuners());
1692 }
1693 
1699 BOOLEAN STB_DPIsTunerEnabled(U8BIT tuner_num)
1700 {
1701  FUNCTION_START(STB_DPIsTunerEnabled);
1702  FUNCTION_FINISH(STB_DPIsTunerEnabled);
1703  return(!STB_RESIsTunerDisabled(tuner_num));
1704 }
1705 
1706 /*!**************************************************************************
1707  * @brief Returns the demux path ID acquired by the given decode path
1708  * @param path - ID of decode path
1709  * @return ID of demux path used by the decode path
1710  ****************************************************************************/
1711 U8BIT STB_DPGetPathDemux(U8BIT path)
1712 {
1713  U8BIT demux_num = INVALID_RES_ID;
1714 
1715  FUNCTION_START(STB_DPGetPathDemux);
1716 
1717  ASSERT(path < num_paths);
1718 
1719  if (path < num_paths)
1720  {
1721  demux_num = path_status[path].demux_no;
1722  }
1723 
1724  FUNCTION_FINISH(STB_DPGetPathDemux);
1725 
1726  return(demux_num);
1727 }
1728 
1729 /*!**************************************************************************
1730  * @brief Returns the audio decoder ID acquired by the given decode path
1731  * @param path - ID of decode path
1732  * @return ID of audio decoder used by the decode path
1733  ****************************************************************************/
1734 U8BIT STB_DPGetPathAudioDecoder(U8BIT path)
1735 {
1736  U8BIT decoder_num = INVALID_RES_ID;
1737 
1738  FUNCTION_START(STB_DPGetPathAudioDecoder);
1739 
1740  ASSERT(path < num_paths);
1741 
1742  if (path < num_paths)
1743  {
1744  decoder_num = path_status[path].audio_decoder_no;
1745  }
1746 
1747  FUNCTION_FINISH(STB_DPGetPathAudioDecoder);
1748 
1749  return(decoder_num);
1750 }
1751 
1752 /*!**************************************************************************
1753  * @brief Returns the video decoder ID acquired by the given decode path
1754  * @param path - ID of decode path
1755  * @return ID of video decoder used by the decode path
1756  ****************************************************************************/
1757 U8BIT STB_DPGetPathVideoDecoder(U8BIT path)
1758 {
1759  U8BIT decoder_num = INVALID_RES_ID;
1760 
1761  FUNCTION_START(STB_DPGetPathVideoDecoder);
1762 
1763  ASSERT(path < num_paths);
1764 
1765  if (path < num_paths)
1766  {
1767  decoder_num = path_status[path].video_decoder_no;
1768  }
1769 
1770  FUNCTION_FINISH(STB_DPGetPathVideoDecoder);
1771 
1772  return(decoder_num);
1773 }
1774 
1775 /*!**************************************************************************
1776  * @brief Returns the secondary video decoder ID acquired by the given
1777  * decode path
1778  * @param path - ID of decode path
1779  * @return ID of secondary video decoder used by the decode path
1780  ****************************************************************************/
1782 {
1783  U8BIT decoder_num = INVALID_RES_ID;
1784 
1785  FUNCTION_START(STB_DPGetPathSecondaryVideoDecoder);
1786 
1787  ASSERT(path < num_paths);
1788 
1789  if (path < num_paths)
1790  {
1791  decoder_num = path_status[path].secondary_video_decoder_no;
1792  }
1793 
1794  FUNCTION_FINISH(STB_DPGetPathSecondaryVideoDecoder);
1795 
1796  return(decoder_num);
1797 }
1798 
1799 /*!**************************************************************************
1800  * @brief Checks whether any of the paths are tuned to the given service
1801  * @param service - service to look for
1802  * @return The path of the given service, or INVALID_RES_ID if it isn't found
1803  ****************************************************************************/
1804 U8BIT STB_DPGetPathForService(void *service)
1805 {
1806  U8BIT path;
1807  U8BIT tuned_path = INVALID_RES_ID;
1808 
1809  FUNCTION_START(STB_DPGetPathForService);
1810 
1811  for (path = 0; (path < num_paths) && (tuned_path == INVALID_RES_ID); path++)
1812  {
1813  if (path_status[path].in_use && (path_status[path].service == service))
1814  {
1815  tuned_path = path;
1816  }
1817  }
1818 
1819  FUNCTION_FINISH(STB_DPGetPathForService);
1820 
1821  return(tuned_path);
1822 }
1823 
1830 BOOLEAN STB_DPCanTuneTo(E_STB_DP_SIGNAL_TYPE tuner_type, void *service, void *transport)
1831 {
1832  BOOLEAN can_tune;
1833  U8BIT i;
1834 
1835  FUNCTION_START(STB_DPCanTuneTo);
1836 
1837  can_tune = FALSE;
1838 
1839  if (service != NULL)
1840  {
1841  /* Check if there's a path already tuned to this service */
1842  for (i = 0; (i < num_paths) && !can_tune; i++)
1843  {
1844  if (path_status[i].in_use && (path_status[i].service == service))
1845  {
1846  can_tune = TRUE;
1847  }
1848  }
1849  }
1850 
1851  if (!can_tune)
1852  {
1853  /* See if there's a tuner tuned to the transport */
1854  can_tune = STB_RESCanTuneToTransport(tuner_type, transport);
1855  }
1856 
1857  FUNCTION_FINISH(STB_DPCanTuneTo);
1858 
1859  return(can_tune);
1860 }
1861 
1874 {
1875  FUNCTION_START(STB_DPGetMHEGPath);
1876  FUNCTION_FINISH(STB_DPGetMHEGPath);
1877  return(STB_DPGetLivePath());
1878 }
1879 
1880 /*!**************************************************************************
1881  * @brief Sets the owner of the given path
1882  * @param path - decode path
1883  * @param owner - owner module
1884  ****************************************************************************/
1885 void STB_DPSetOwner(U8BIT path, E_STB_DP_RES_OWNER owner)
1886 {
1887  FUNCTION_START(STB_DPSetOwner);
1888 
1889  if (path < num_paths)
1890  {
1891  path_status[path].owner = owner;
1892 
1893  if (path_status[path].tuner_no != INVALID_RES_ID)
1894  {
1895  STB_RESSetTunerOwner(path_status[path].tuner_no, owner);
1896  }
1897  }
1898 
1899  FUNCTION_FINISH(STB_DPSetOwner);
1900 }
1901 
1902 /*!**************************************************************************
1903  * @brief Saves a copy of the given data with the path. If data is passed as NULL
1904  * and owner data already exists, then it will be freed. if data isn't NULL
1905  * and owner data exists then the new data will replace the existing data.
1906  * @param path - decode path
1907  * @param data - data to be saved with the path, can be NULL
1908  * @param data_size - size of data, 0 if data is NULL
1909  * @return TRUE if data is successfully saved, FALSE otherwise
1910  ****************************************************************************/
1911 BOOLEAN STB_DPSetOwnerData(U8BIT path, void *data, U32BIT data_size)
1912 {
1913  BOOLEAN retval;
1914 
1915  FUNCTION_START(STB_DPSetOwnerData);
1916 
1917  retval = FALSE;
1918 
1919  if (path < num_paths)
1920  {
1921  if (data != NULL)
1922  {
1923  if (path_status[path].owner_data != NULL)
1924  {
1925  /* Free existing data */
1926  STB_FreeMemory(path_status[path].owner_data);
1927 
1928  path_status[path].owner_data = NULL;
1929  path_status[path].owner_data_size = 0;
1930  }
1931 
1932  /* Copy the data */
1933  if ((path_status[path].owner_data = STB_GetMemory(data_size)) != NULL)
1934  {
1935  memcpy(path_status[path].owner_data, data, data_size);
1936  path_status[path].owner_data_size = data_size;
1937  retval = TRUE;
1938  }
1939  }
1940  else
1941  {
1942  if (path_status[path].owner_data != NULL)
1943  {
1944  /* Free existing data */
1945  STB_FreeMemory(path_status[path].owner_data);
1946 
1947  path_status[path].owner_data = NULL;
1948  path_status[path].owner_data_size = 0;
1949  }
1950 
1951  retval = TRUE;
1952  }
1953  }
1954 
1955  FUNCTION_FINISH(STB_DPSetOwnerData);
1956 
1957  return(retval);
1958 }
1959 
1960 /*!**************************************************************************
1961  * @brief Checks whether the path is owned by the given owner
1962  * @param path - decode path
1963  * @param owner - is path owned by this module
1964  * @return TRUE if owned by the given module, FALSE otherwise
1965  ****************************************************************************/
1966 BOOLEAN STB_DPIsOwnedBy(U8BIT path, E_STB_DP_RES_OWNER owner)
1967 {
1968  BOOLEAN retval;
1969 
1970  FUNCTION_START(STB_DPIsOwnedBy);
1971 
1972  retval = FALSE;
1973 
1974  if (path < num_paths)
1975  {
1976  if (path_status[path].owner == owner)
1977  {
1978  retval = TRUE;
1979  }
1980  }
1981 
1982  FUNCTION_FINISH(STB_DPIsOwnedBy);
1983 
1984  return(retval);
1985 }
1986 
1987 /*!**************************************************************************
1988  * @brief Returns the owner data saved with the path. This data should not be freed.
1989  * @param path - decode path
1990  * @param data_size - size of the returned data, 0 if return is NULL
1991  * @return Pointer to the owner data, which can be NULL.
1992  ****************************************************************************/
1993 void* STB_DPGetOwnerData(U8BIT path, U32BIT *data_size)
1994 {
1995  void *data;
1996 
1997  FUNCTION_START(STB_DPGetTunerOwnerData);
1998 
1999  if (path < num_paths)
2000  {
2001  data = path_status[path].owner_data;
2002  *data_size = path_status[path].owner_data_size;
2003  }
2004  else
2005  {
2006  data = NULL;
2007  *data_size = 0;
2008  }
2009 
2010  FUNCTION_FINISH(STB_DPGetTunerOwnerData);
2011 
2012  return(data);
2013 }
2014 
2021 void STB_DPSetDecodeSource(U8BIT path, E_STB_DP_DECODE_SOURCE source, U32BIT param)
2022 {
2023  U8BIT audio_num, video_num;
2024  U8BIT ad_num;
2025  U8BIT demux_num;
2026  E_STB_AV_DECODE_SOURCE av_source;
2027 
2028  FUNCTION_START(STB_DPSetDecodeSource);
2029 
2030  ASSERT(path < num_paths);
2031 
2032  STB_DP_PRINT(("STB_DPSetDecodeSource(%d): %d 0x%x", path, source, param));
2033 
2034  ad_num = path_status[path].ad_decoder_no;
2035  audio_num = path_status[path].audio_decoder_no;
2036  video_num = path_status[path].video_decoder_no;
2037  demux_num = path_status[path].demux_no;
2038 
2039  STB_DP_PRINT(("STB_DPSetDecodeSource(%d): audio = %d, AD = %d, video = %d", path, audio_num, ad_num, video_num));
2040 
2041  if ((audio_num != INVALID_RES_ID) && (video_num != INVALID_RES_ID))
2042  {
2043  if ((source != audio_decoder_status[audio_num].source_type) ||
2044  (param != audio_decoder_status[audio_num].source_param) ||
2045  (source != video_decoder_status[video_num].source_type) ||
2046  (param != video_decoder_status[video_num].source_param) ||
2047  (source != ad_decoder_status[ad_num].source_type) ||
2048  (param != ad_decoder_status[ad_num].source_param) ||
2049  (demux_num != ad_decoder_status[ad_num].source_dmx) ||
2050  (demux_num != audio_decoder_status[audio_num].source_dmx) ||
2051  (demux_num != video_decoder_status[video_num].source_dmx))
2052  {
2053  ad_decoder_status[ad_num].source_type = source;
2054  ad_decoder_status[ad_num].source_param = param;
2055  ad_decoder_status[ad_num].actions |= ACTION_AD;
2056 
2057  audio_decoder_status[audio_num].source_type = source;
2058  audio_decoder_status[audio_num].source_param = param;
2059  audio_decoder_status[audio_num].actions |= ACTION_AUDIO;
2060 
2061  video_decoder_status[video_num].source_type = source;
2062  video_decoder_status[video_num].source_param = param;
2063  video_decoder_status[video_num].actions |= ACTION_VIDEO;
2064 
2065  // select correct av source
2066  switch (source)
2067  {
2068  case DECODE_SOURCE_DEMUX: {av_source = AV_DEMUX; break; }
2069  case DECODE_SOURCE_FILE: {av_source = AV_MEMORY; break; }
2070  default: {av_source = AV_DEMUX; break; }
2071  }
2072  STB_AVSetADSource(ad_num, av_source, demux_num);
2073  STB_AVSetAudioSource(audio_num, av_source, demux_num);
2074  STB_AVSetVideoSource(video_num, av_source, demux_num);
2075  }
2076  }
2077 
2078  FUNCTION_FINISH(STB_DPSetDecodeSource);
2079 }
2080 
2087 void STB_DPGetDecodeSource(U8BIT path, E_STB_DP_DECODE_SOURCE *source, U32BIT *param)
2088 {
2089  U8BIT decode_num;
2090 
2091  FUNCTION_START(STB_DPGetDecodeSource);
2092 
2093  ASSERT(path < num_paths);
2094 
2095  decode_num = path_status[path].video_decoder_no;
2096 
2097  if (decode_num != INVALID_RES_ID)
2098  {
2099  *source = video_decoder_status[decode_num].source_type;
2100  *param = video_decoder_status[decode_num].source_param;
2101  }
2102 
2103  FUNCTION_FINISH(STB_DPGetDecodeSource);
2104 }
2105 
2112 BOOLEAN STB_DPStartRecording(U8BIT path, U32BIT param)
2113 {
2114  U32BIT temp_val;
2115  U8BIT demux_num;
2116  BOOLEAN retval = FALSE;
2117 
2118  FUNCTION_START(STB_DPStartRecording);
2119 
2120  ASSERT(path < num_paths);
2121 
2122  STB_DP_PRINT(("STB_DPStartRecording(%d)", path));
2123 
2124  if (STB_PVRIsInitialised())
2125  {
2126  /* Stop old PVR recording? */
2127  if (STB_PVRIsRecording(path, &temp_val) == TRUE)
2128  {
2129  STB_PVRStopRecording(path);
2130  }
2131 
2132  demux_num = path_status[path].demux_no;
2133 
2134  ASSERT(demux_num != INVALID_RES_ID);
2135 
2136  if ((demux_status[demux_num].actions & ACTION_DECODE_MASK) != 0)
2137  {
2138  STB_DP_PRINT(("STB_DPStartRecording(%u): Updating audio/video/pcr/AD PIDs (%u/%u/%u/%u) for demux %u", path,
2139  demux_status[demux_num].audio_pid, demux_status[demux_num].video_pid,
2140  demux_status[demux_num].pcr_pid, demux_status[demux_num].AD_pid, demux_num));
2141 
2142  /* Change of decode params - so update PIDs before recording is started */
2143  demux_status[demux_num].actions &= ~ACTION_DECODE_MASK;
2144 
2145  STB_DMXChangeDecodePIDs(demux_num, demux_status[demux_num].pcr_pid,
2146  demux_status[demux_num].video_pid, demux_status[demux_num].audio_pid,
2147  demux_status[demux_num].text_pid, demux_status[demux_num].data_pid,
2148  demux_status[demux_num].AD_pid);
2149  }
2150 
2151  /* Start new PVR recording */
2152  retval = STB_PVRStartRecording(path, param);
2153  }
2154 
2155  FUNCTION_FINISH(STB_DPStartRecording);
2156 
2157  return(retval);
2158 }
2159 
2164 void STB_DPStopRecording(U8BIT path)
2165 {
2166  U32BIT temp_val;
2167 
2168  FUNCTION_START(STB_DPStopRecording);
2169 
2170  ASSERT(path < num_paths);
2171 
2172  STB_DP_PRINT(("STB_DPStopRecording(%d)", path));
2173 
2174  // stop current PVR recording
2175  if (STB_PVRIsRecording(path, &temp_val) == TRUE)
2176  {
2177  STB_PVRStopRecording(path);
2178  }
2179 
2180  FUNCTION_FINISH(STB_DPStopRecording);
2181 }
2182 
2189 BOOLEAN STB_DPIsRecording(U8BIT path, U32BIT *handle)
2190 {
2191  BOOLEAN ret_val;
2192 
2193  FUNCTION_START(STB_DPIsRecording);
2194 
2195  ret_val = STB_PVRIsRecording(path, handle);
2196 
2197  FUNCTION_FINISH(STB_DPIsRecording);
2198 
2199  return(ret_val);
2200 }
2201 
2206 void STB_DPStartTune(U8BIT path)
2207 {
2208  E_STB_DP_TUNE_STATUS status;
2209  U8BIT tuner_num;
2210 
2211  FUNCTION_START(STB_DPStartTune);
2212 
2213  ASSERT(path < num_paths);
2214 
2215  tuner_num = path_status[path].tuner_no;
2216  status = STB_DPGetTuneStatus(path);
2217  STB_TUNE_PRINT(("STB_DPStartTune(%d): Tuner %d, status=%d", path, tuner_num, status));
2218 
2219  if ((tuner_status[tuner_num].actions & ACTION_TUNE) != 0)
2220  {
2221  // change of tuning params - so stop SI and force re-tune
2222  tuner_status[tuner_num].actions &= ~ACTION_TUNE;
2223  STB_DPStopSI(path);
2224 
2225  status = TUNE_NO_LOCK;
2226  tuner_status[tuner_num].actions |= ACTION_SI_NEW;
2227  }
2228 
2229  switch (status)
2230  {
2231  case TUNE_WAITING:
2232  case TUNE_NO_LOCK:
2233  case TUNE_STOPPED:
2234  {
2235  STB_TUNE_PRINT(("STB_DPStartTune(%d): re-tune", path));
2236 
2237  // setup dish / lnb / DiSEqC and request tune
2238  if (StartTune(path) == FALSE)
2239  {
2240  STB_TUNE_PRINT(("STB_DPStartTune(%d): Tune failed", path));
2241  /* If StartTune fails then it won't have attempted to start tuning so
2242  * send tune event from here */
2243  STB_DPSetTuneStatus(path, TUNE_NO_LOCK);
2244  STB_ERSendEvent(FALSE, FALSE, EV_CLASS_TUNE, EV_TYPE_NOTLOCKED, &tuner_num, sizeof(U8BIT));
2245  }
2246  break;
2247  }
2248 
2249  case TUNE_LOCKED:
2250  {
2251  STB_TUNE_PRINT(("STB_DPStartTune(%d): re-tune not required", path));
2252  STB_ERSendEvent(FALSE, FALSE, EV_CLASS_TUNE, EV_TYPE_LOCKED, &tuner_num, sizeof(U8BIT));
2253  break;
2254  }
2255 
2256  default:
2257  {
2258  STB_TUNE_PRINT(("STB_DPStartTune(%d): no action", path));
2259  break;
2260  }
2261  }
2262 
2263  FUNCTION_FINISH(STB_DPStartTune);
2264 }
2265 
2270 void STB_DPStartScan(U8BIT path)
2271 {
2272  FUNCTION_START(STB_DPStartScan);
2273 
2274  USE_UNWANTED_PARAM(path);
2275 
2276  ASSERT(path < num_paths);
2277 
2278  FUNCTION_FINISH(STB_DPStartScan);
2279 }
2280 
2285 void STB_DPStopTune(U8BIT path)
2286 {
2287  U8BIT tuner_num;
2288 
2289  FUNCTION_START(STB_DPStopTune);
2290 
2291  ASSERT(path < num_paths);
2292 
2293  switch (STB_DPGetTuneStatus(path))
2294  {
2295  case TUNE_WAITING:
2296  case TUNE_NO_LOCK:
2297  case TUNE_LOCKED:
2298  {
2299  tuner_num = path_status[path].tuner_no;
2300 
2301  STB_TUNE_PRINT(("STB_DPStopTune(%d): stop tuner %d", path, tuner_num));
2302 
2303  STB_DPStopSI(path);
2304 
2305  /* Set path status */
2306  STB_DPSetTuneStatus(path, TUNE_STOPPED);
2307 
2308  /* Only stop the tuner if it isn't being used by another path */
2309  if (STB_RESTunerUsageCount(tuner_num) < 2)
2310  {
2311  STB_TuneStopTuner(tuner_num);
2312  STB_ERSendEvent(FALSE, FALSE, EV_CLASS_TUNE, EV_TYPE_STOPPED, &tuner_num, sizeof(U8BIT));
2313  }
2314  break;
2315  }
2316 
2317  default:
2318  {
2319  STB_TUNE_PRINT(("STB_DPStopTune(%d): no action", path));
2320  break;
2321  }
2322  }
2323 
2324  FUNCTION_FINISH(STB_DPStopTune);
2325 }
2326 
2331 void STB_DPTuneOff(U8BIT path)
2332 {
2333  U8BIT tuner_num;
2334 
2335  FUNCTION_START(STB_DPTuneOff);
2336 
2337  ASSERT(path < num_paths);
2338 
2339  switch (STB_DPGetTuneStatus(path))
2340  {
2341  case TUNE_WAITING:
2342  case TUNE_NO_LOCK:
2343  case TUNE_LOCKED:
2344  tuner_num = path_status[path].tuner_no;
2345  if (tuner_num != INVALID_RES_ID)
2346  {
2347  STB_TUNE_PRINT(("STB_DPTuneOff(%d): Tuner %d off", path, tuner_num));
2348 
2349  STB_DPStopSI(path);
2350 
2351  /* Set path status */
2352  STB_DPSetTuneStatus(path, TUNE_STOPPED);
2353 
2354  /* Only stop the tuner if it isn't being used by another path */
2355  if (STB_RESTunerUsageCount(tuner_num) < 2)
2356  {
2357  STB_TuneStopTuner(tuner_num);
2358 
2359  if (tuner_status[tuner_num].signal_type == SIGNAL_QPSK)
2360  {
2361  if (tuner_status[tuner_num].lnb_power == LNB_POWER_AUTO)
2362  {
2363  STB_TuneSetLNBVoltage(tuner_num, LNB_VOLTAGE_OFF);
2364  STB_TuneSet22kState(tuner_num, FALSE);
2365  }
2366  }
2367 
2368  /* Send an event to indicate the tuner has been stopped */
2369  STB_ERSendEvent(FALSE, FALSE, EV_CLASS_TUNE, EV_TYPE_STOPPED, &tuner_num, sizeof(U8BIT));
2370  }
2371  }
2372  break;
2373 
2374  default:
2375  STB_TUNE_PRINT(("STB_DPTuneOff(%d): status=%u, no action", path, STB_DPGetTuneStatus(path)));
2376  break;
2377  }
2378 
2379  // On any applying of power will now cause a delay of 1s
2380  // ONLY if a DiSEqC 1.2 motor is fitted.
2381  lnb_currently_powered = FALSE;
2382 
2383  FUNCTION_FINISH(STB_DPTuneOff);
2384 }
2385 
2391 {
2392  BOOLEAN lock = FALSE;
2393  E_STB_DP_DECODE_STATUS status;
2394  U8BIT decoder_num;
2395  U8BIT demux_num;
2396 
2397  FUNCTION_START(STB_DPStartVideoDecoding);
2398 
2399  ASSERT(path < num_paths);
2400 
2401  status = STB_DPGetVideoStatus(path);
2402 
2403  decoder_num = path_status[path].video_decoder_no;
2404  demux_num = path_status[path].demux_no;
2405 
2406  if ((demux_status[demux_num].actions & ACTION_VIDEO) != 0)
2407  {
2408  /* Change of demux params so force re-start */
2409  demux_status[demux_num].actions &= ~ACTION_VIDEO;
2410  status = DECODE_STOPPED;
2411 
2412  /* Only use PIDs if source is from demux */
2413  if (video_decoder_status[decoder_num].source_type == DECODE_SOURCE_DEMUX)
2414  {
2415  STB_DP_PRINT(("STB_DPStartVideoDecoding(%d): setting pids (video=%u, audio=%u, ad=%u)", path,
2416  demux_status[demux_num].video_pid, demux_status[demux_num].audio_pid, demux_status[demux_num].AD_pid));
2417  /* Update PIDs */
2418  STB_DMXChangeDecodePIDs(demux_num, demux_status[demux_num].pcr_pid,
2419  demux_status[demux_num].video_pid, demux_status[demux_num].audio_pid,
2420  demux_status[demux_num].text_pid, demux_status[demux_num].data_pid,
2421  demux_status[demux_num].AD_pid);
2422  }
2423  }
2424 
2425  if ((video_decoder_status[decoder_num].actions & ACTION_VIDEO) != 0)
2426  {
2427  /* Change of video decoder params so force re-start */
2428  video_decoder_status[decoder_num].actions &= ~ACTION_VIDEO;
2429  status = DECODE_STOPPED;
2430  }
2431 
2432  lock = (path_status[path].lock_mode && path_status[path].lock_enable);
2433 
2434  if (lock == TRUE)
2435  {
2436  STB_DP_PRINT(("STB_DPStartVideoDecoding(%d): locked", path));
2437  STB_DPSetVideoStatus(path, DECODE_LOCKED);
2438  STB_AVBlankVideo(decoder_num, TRUE);
2439  STB_AVStopVideoDecoding(decoder_num);
2440  STB_ERSendEvent(FALSE, FALSE, EV_CLASS_DECODE, EV_TYPE_LOCKED, &decoder_num, sizeof(U8BIT));
2441  }
2442  else
2443  {
2444  switch (status)
2445  {
2446  case DECODE_STOPPING:
2447  case DECODE_STOPPED:
2448  case DECODE_LOCKED:
2449  {
2450  // request start decode
2451  STB_DP_PRINT(("STB_DPStartVideoDecoding(%d): starting video decoder %d", path, decoder_num));
2452  STB_DPSetVideoStatus(path, DECODE_STARTING);
2453  STB_AVStartVideoDecoding(decoder_num);
2454  break;
2455  }
2456 
2457  case DECODE_RUNNING:
2458  {
2459  STB_DP_PRINT(("STB_DPStartVideoDecoding(%d): re-start not required", path));
2460  STB_ERSendEvent(FALSE, FALSE, EV_CLASS_DECODE, EV_TYPE_VIDEO_STARTED, &decoder_num, sizeof(U8BIT));
2461  break;
2462  }
2463 
2464  default:
2465  {
2466  STB_DP_PRINT(("STB_DPStartVideoDecoding(%d): no action", path));
2467  break;
2468  }
2469  }
2470  }
2471 
2472  FUNCTION_FINISH(STB_DPStartVideoDecoding);
2473 }
2474 
2479 void STB_DPStartADDecoding(U8BIT path)
2480 {
2481  E_STB_AV_AUDIO_MODE audio_mode;
2482  BOOLEAN lock = FALSE;
2483  E_STB_DP_DECODE_STATUS status;
2484  U8BIT decoder_num;
2485  U8BIT demux_num;
2486  U8BIT ad_status;
2487 
2488  FUNCTION_START(STB_DPStartADDecoding);
2489 
2490  ASSERT(path < num_paths);
2491 
2492  status = STB_DPGetADStatus(path);
2493  ad_status = GetADEnabled(path);
2494  decoder_num = path_status[path].ad_decoder_no;
2495  demux_num = path_status[path].demux_no;
2496  ASSERT(demux_num < num_demuxes);
2497 
2498  STB_DP_PRINT(("STB_DPStartADDecoding %s, %s\n", (ad_status & AD_ENABLED) ? "On" : "Off",
2499  (ad_status & AD_PID_PRESENT) ? "PID" : "No PID"));
2500 
2501  if ((demux_status[demux_num].actions & ACTION_AD) != 0)
2502  {
2503  /* Change of demux params so force re-start */
2504  demux_status[demux_num].actions &= ~ACTION_AD;
2505  status = DECODE_STOPPED;
2506  if (ad_decoder_status[decoder_num].source_type == DECODE_SOURCE_DEMUX)
2507  {
2508  STB_DMXChangeDecodePIDs(demux_num, demux_status[demux_num].pcr_pid,
2509  demux_status[demux_num].video_pid, demux_status[demux_num].audio_pid,
2510  demux_status[demux_num].text_pid, demux_status[demux_num].data_pid,
2511  demux_status[demux_num].AD_pid);
2512  }
2513  }
2514 
2515  if ((ad_status & AD_ENABLED) && (ad_status & AD_PID_PRESENT))
2516  {
2517  if ((ad_decoder_status[decoder_num].actions & ACTION_AD) != 0)
2518  {
2519  // change of decode params - so force re-start
2520  ad_decoder_status[decoder_num].actions &= ~ACTION_AD;
2521  status = DECODE_STOPPED;
2522  }
2523 
2524  /* Note that AD is mono but in the future it may be stereo, also broadcasters may play on one channel */
2525  switch (ad_decoder_status[decoder_num].audio_mode)
2526  {
2527  case AUDIO_MONO: {audio_mode = AV_AUDIO_MONO; break; }
2528  case AUDIO_STEREO: {audio_mode = AV_AUDIO_STEREO; break; }
2529  case AUDIO_LEFT: {audio_mode = AV_AUDIO_LEFT; break; }
2530  case AUDIO_RIGHT: {audio_mode = AV_AUDIO_RIGHT; break; }
2531  case AUDIO_MULTICHANNEL: {audio_mode = AV_AUDIO_MULTICHANNEL; break; }
2532  default: {audio_mode = AV_AUDIO_MONO; break; }
2533  }
2534 
2535  STB_AVChangeADMode(decoder_num, audio_mode);
2536 
2537  lock = (path_status[path].lock_mode && path_status[path].lock_enable);
2538  if (lock == TRUE)
2539  {
2540  STB_DP_PRINT(("STB_DPStartADDecoding(%d): locked", path));
2541  STB_DPSetADStatus(path, DECODE_LOCKED);
2542  STB_AVStopADDecoding(decoder_num);
2543  STB_DPSetADAudio(path, AD_AUDIO_OFF);
2544  STB_ERSendEvent(FALSE, FALSE, EV_CLASS_DECODE, EV_TYPE_LOCKED, &decoder_num, sizeof(U8BIT));
2545  }
2546  else
2547  {
2548  switch (status)
2549  {
2550  case DECODE_STOPPING:
2551  case DECODE_STOPPED:
2552  case DECODE_LOCKED:
2553  {
2554  // request start decode
2555  STB_DP_PRINT(("STB_DPStartADDecoding(%d): start", path));
2556  STB_DPSetADStatus(path, DECODE_STARTING);
2557  ad_decoder_status[decoder_num].ad_status |= AD_ENABLED;
2558  STB_AVStartADDecoding(decoder_num);
2559  STB_DPSetADAudio(path, AD_AUDIO_PLAYING);
2560  break;
2561  }
2562  case DECODE_RUNNING:
2563  {
2564  STB_DP_PRINT(("STB_DPStartADDecoding(%d): re-start not required", path));
2565  ad_decoder_status[decoder_num].ad_audio = AD_AUDIO_PLAYING;
2566  STB_ERSendEvent(FALSE, FALSE, EV_CLASS_DECODE, EV_TYPE_AD_STARTED, &decoder_num, sizeof(U8BIT));
2567  break;
2568  }
2569  default:
2570  {
2571  STB_DP_PRINT(("STB_DPStartADDecoding(%d): no action", path));
2572  break;
2573  }
2574  }
2575  }
2576  }
2577 
2578  FUNCTION_FINISH(STB_DPStartADDecoding);
2579 }
2580 
2586 {
2587  E_STB_AV_AUDIO_MODE audio_mode;
2588  BOOLEAN lock = FALSE;
2589  E_STB_DP_DECODE_STATUS status;
2590  U8BIT decoder_num;
2591  U8BIT demux_num;
2592 
2593  FUNCTION_START(STB_DPStartAudioDecoding);
2594 
2595  ASSERT(path < num_paths);
2596 
2597  status = STB_DPGetAudioStatus(path);
2598 
2599  decoder_num = path_status[path].audio_decoder_no;
2600  demux_num = path_status[path].demux_no;
2601 
2602  ASSERT(demux_num < num_demuxes);
2603 
2604  if ((demux_status[demux_num].actions & ACTION_AUDIO) != 0)
2605  {
2606  /* Change of demux params so force re-start */
2607  demux_status[demux_num].actions &= ~ACTION_AUDIO;
2608  status = DECODE_STOPPED;
2609 
2610  if (audio_decoder_status[decoder_num].source_type == DECODE_SOURCE_DEMUX)
2611  {
2612  STB_DMXChangeDecodePIDs(demux_num, demux_status[demux_num].pcr_pid,
2613  demux_status[demux_num].video_pid, demux_status[demux_num].audio_pid,
2614  demux_status[demux_num].text_pid, demux_status[demux_num].data_pid,
2615  demux_status[demux_num].AD_pid);
2616  }
2617  }
2618 
2619  if ((audio_decoder_status[decoder_num].actions & ACTION_AUDIO) != 0)
2620  {
2621  // change of decode params - so force re-start
2622  audio_decoder_status[decoder_num].actions &= ~ACTION_AUDIO;
2623  status = DECODE_STOPPED;
2624  }
2625 
2626  // select correct audio mode
2627  switch (audio_decoder_status[decoder_num].audio_mode)
2628  {
2629  case AUDIO_MONO: {audio_mode = AV_AUDIO_MONO; break; }
2630  case AUDIO_STEREO: {audio_mode = AV_AUDIO_STEREO; break; }
2631  case AUDIO_LEFT: {audio_mode = AV_AUDIO_LEFT; break; }
2632  case AUDIO_RIGHT: {audio_mode = AV_AUDIO_RIGHT; break; }
2633  case AUDIO_MULTICHANNEL: {audio_mode = AV_AUDIO_MULTICHANNEL; break; }
2634  default: {audio_mode = AV_AUDIO_STEREO; break; }
2635  }
2636 
2637  STB_AVChangeAudioMode(decoder_num, audio_mode);
2638 
2639  lock = (path_status[path].lock_mode && path_status[path].lock_enable);
2640 
2641  if (lock == TRUE)
2642  {
2643  STB_DP_PRINT(("STB_DPStartAudioDecoding(%d): locked", path));
2644  STB_DPSetAudioStatus(path, DECODE_LOCKED);
2645  STB_AVStopADDecoding(decoder_num);
2646  STB_AVStopAudioDecoding(decoder_num);
2647  STB_ERSendEvent(FALSE, FALSE, EV_CLASS_DECODE, EV_TYPE_LOCKED, &decoder_num, sizeof(U8BIT));
2648  }
2649  else
2650  {
2651  switch (status)
2652  {
2653  case DECODE_STOPPING:
2654  case DECODE_STOPPED:
2655  case DECODE_LOCKED:
2656  {
2657  // request start decode
2658  STB_DP_PRINT(("STB_DPStartAudioDecoding(%d): start", path));
2659  STB_DPSetAudioStatus(path, DECODE_STARTING);
2660  STB_AVStartAudioDecoding(decoder_num);
2661  break;
2662  }
2663 
2664  case DECODE_RUNNING:
2665  {
2666  STB_DP_PRINT(("STB_DPStartAudioDecoding(%d): re-start not required", path));
2667  STB_ERSendEvent(FALSE, FALSE, EV_CLASS_DECODE, EV_TYPE_AUDIO_STARTED, &decoder_num, sizeof(U8BIT));
2668  break;
2669  }
2670 
2671  default:
2672  {
2673  STB_DP_PRINT(("STB_DPStartAudioDecoding(%d): no action", path));
2674  break;
2675  }
2676  }
2677  }
2678 
2679  FUNCTION_FINISH(STB_DPStartAudioDecoding);
2680 }
2681 
2686 void STB_DPStartDecoding(U8BIT path)
2687 {
2688  U8BIT decoder_num;
2689 
2690  FUNCTION_START(STB_DPStartDecoding);
2691 
2692  ASSERT(path < num_paths);
2693 
2694  STB_DP_PRINT(("%s(%u)", __FUNCTION__, path));
2695 
2696  if (path_status[path].ca_acquired)
2697  {
2698  STB_CADescrambleServiceStart(path_status[path].ca_handle);
2699  }
2700 
2703 
2704  if ((decoder_num = path_status[path].ad_decoder_no) != INVALID_RES_ID)
2705  {
2706  if ((ad_decoder_status[decoder_num].ad_status & AD_ENABLED) != 0)
2707  {
2708  STB_DPStartADDecoding(path);
2709  }
2710  }
2711 
2712  FUNCTION_FINISH(STB_DPStartDecoding);
2713 }
2714 
2719 void STB_DPStopVideoDecoding(U8BIT path)
2720 {
2721  U8BIT demux_num, decoder_num;
2722 
2723  FUNCTION_START(STB_DPStopVideoDecoding);
2724 
2725  ASSERT(path < num_paths);
2726 
2727  decoder_num = path_status[path].video_decoder_no;
2728  demux_num = path_status[path].demux_no;
2729 
2730  ASSERT(demux_num < num_demuxes);
2731 
2732  switch (STB_DPGetVideoStatus(path))
2733  {
2734  case DECODE_RUNNING:
2735  {
2736  // request stop decode
2737  STB_DP_PRINT(("STB_DPStopVideoDecoding(%d): stop (was running)", path));
2738  STB_DPSetVideoStatus(path, DECODE_STOPPING);
2739  if ((demux_num != INVALID_RES_ID) && (decoder_num != INVALID_RES_ID))
2740  {
2741  STB_AVStopVideoDecoding(decoder_num);
2742  }
2743  break;
2744  }
2745 
2746  case DECODE_STARTING:
2747  {
2748  STB_DP_PRINT(("STB_DPStopVideoDecoding(%d): stop (was starting)", path));
2749  STB_DPSetVideoStatus(path, DECODE_STOPPED);
2750  if ((demux_num != INVALID_RES_ID) && (decoder_num != INVALID_RES_ID))
2751  {
2752  STB_AVStopVideoDecoding(decoder_num);
2753  }
2754  STB_ERSendEvent(FALSE, FALSE, EV_CLASS_DECODE, EV_TYPE_VIDEO_STOPPED, &decoder_num, sizeof(U8BIT));
2755  break;
2756  }
2757 
2758  case DECODE_STOPPED:
2759  case DECODE_LOCKED:
2760  {
2761  STB_DP_PRINT(("STB_DPStopVideoDecoding(%d): already stopped", path));
2762  STB_DPSetVideoStatus(path, DECODE_STOPPED);
2763  STB_ERSendEvent(FALSE, FALSE, EV_CLASS_DECODE, EV_TYPE_VIDEO_STOPPED, &decoder_num, sizeof(U8BIT));
2764  break;
2765  }
2766 
2767  default:
2768  {
2769  STB_DP_PRINT(("STB_DPStopVideoDecoding(%d): no action", path));
2770  break;
2771  }
2772  }
2773 
2774  FUNCTION_FINISH(STB_DPStopVideoDecoding);
2775 }
2776 
2781 void STB_DPStopADDecoding(U8BIT path)
2782 {
2783  U8BIT demux_num, decoder_num;
2784  FUNCTION_START(STB_DPStopADDecoding);
2785 
2786  STB_DP_PRINT(("STB_DPStopADDecoding"));
2787  ASSERT(path < num_paths);
2788 
2789  decoder_num = path_status[path].ad_decoder_no;
2790  demux_num = path_status[path].demux_no;
2791 
2792  ASSERT(decoder_num < num_audio_decoders);
2793  ASSERT(demux_num < num_demuxes);
2794 
2795  switch (STB_DPGetADStatus(path))
2796  {
2797  case DECODE_RUNNING:
2798  {
2799  // request stop decode
2800  STB_DP_PRINT(("STB_DPStopADDecoding(%d): stop (was running)", path));
2801  STB_DPSetADStatus(path, DECODE_STOPPING);
2802  if ((demux_num != INVALID_RES_ID) && (decoder_num != INVALID_RES_ID))
2803  {
2804  STB_AVStopADDecoding(decoder_num);
2805  STB_DPSetADAudio(path, AD_AUDIO_OFF);
2806  }
2807  break;
2808  }
2809 
2810  case DECODE_STARTING:
2811  {
2812  STB_DP_PRINT(("STB_DPStopADDecoding(%d): stop (was starting)", path));
2813  STB_DPSetADStatus(path, DECODE_STOPPED);
2814  if ((demux_num != INVALID_RES_ID) && (decoder_num != INVALID_RES_ID))
2815  {
2816  STB_AVStopADDecoding(decoder_num);
2817  STB_DPSetADAudio(path, AD_AUDIO_OFF);
2818  }
2819  STB_ERSendEvent(FALSE, FALSE, EV_CLASS_DECODE, EV_TYPE_AD_STOPPED, &decoder_num, sizeof(U8BIT));
2820  break;
2821  }
2822 
2823  case DECODE_STOPPED:
2824  case DECODE_LOCKED:
2825  {
2826  STB_DP_PRINT(("STB_DPStopADDecoding(%d): already stopped", path));
2827  STB_DPSetADStatus(path, DECODE_STOPPED);
2828  STB_ERSendEvent(FALSE, FALSE, EV_CLASS_DECODE, EV_TYPE_AD_STOPPED, &decoder_num, sizeof(U8BIT));
2829  break;
2830  }
2831 
2832  default:
2833  {
2834  STB_DP_PRINT(("STB_DPStopADDecoding(%d): no action", path));
2835  break;
2836  }
2837  }
2838 
2839  FUNCTION_FINISH(STB_DPStopADDecoding);
2840 }
2841 
2846 void STB_DPStopAudioDecoding(U8BIT path)
2847 {
2848  U8BIT demux_num, decoder_num;
2849 
2850  FUNCTION_START(STB_DPStopAudioDecoding);
2851 
2852  ASSERT(path < num_paths);
2853 
2854  decoder_num = path_status[path].audio_decoder_no;
2855  demux_num = path_status[path].demux_no;
2856 
2857  ASSERT(decoder_num < num_audio_decoders);
2858  ASSERT(demux_num < num_demuxes);
2859 
2860  switch (STB_DPGetAudioStatus(path))
2861  {
2862  case DECODE_RUNNING:
2863  {
2864  // request stop decode
2865  STB_DP_PRINT(("STB_DPStopAudioDecoding(%d): stop (was running)", path));
2866  STB_DPSetAudioStatus(path, DECODE_STOPPING);
2867  if ((demux_num != INVALID_RES_ID) && (decoder_num != INVALID_RES_ID))
2868  {
2869  STB_AVStopADDecoding(decoder_num);
2870  STB_AVStopAudioDecoding(decoder_num);
2871  }
2872  break;
2873  }
2874 
2875  case DECODE_STARTING:
2876  {
2877  STB_DP_PRINT(("STB_DPStopAudioDecoding(%d): stop (was starting)", path));
2878  STB_DPSetAudioStatus(path, DECODE_STOPPED);
2879  if ((demux_num != INVALID_RES_ID) && (decoder_num != INVALID_RES_ID))
2880  {
2881  STB_AVStopAudioDecoding(decoder_num);
2882  }
2883  STB_ERSendEvent(FALSE, FALSE, EV_CLASS_DECODE, EV_TYPE_AUDIO_STOPPED, &decoder_num, sizeof(U8BIT));
2884  break;
2885  }
2886 
2887  case DECODE_STOPPED:
2888  case DECODE_LOCKED:
2889  {
2890  STB_DP_PRINT(("STB_DPStopAudioDecoding(%d): already stopped", path));
2891  STB_DPSetAudioStatus(path, DECODE_STOPPED);
2892  STB_ERSendEvent(FALSE, FALSE, EV_CLASS_DECODE, EV_TYPE_AUDIO_STOPPED, &decoder_num, sizeof(U8BIT));
2893  break;
2894  }
2895 
2896  default:
2897  {
2898  STB_DP_PRINT(("STB_DPStopAudioDecoding(%d): no action", path));
2899  break;
2900  }
2901  }
2902 
2903  FUNCTION_FINISH(STB_DPStopAudioDecoding);
2904 }
2905 
2910 void STB_DPStopDecoding(U8BIT path)
2911 {
2912  FUNCTION_START(STB_DPStopDecoding);
2913 
2914  ASSERT(path < num_paths);
2915 
2916  STB_DP_PRINT(("%s(%u)", __FUNCTION__, path));
2917 
2918  STB_DPStopADDecoding(path);
2921 
2922  if (path_status[path].ca_acquired)
2923  {
2924  STB_CADescrambleServiceStop(path_status[path].ca_handle);
2925  }
2926 
2927  FUNCTION_FINISH(STB_DPStopDecoding);
2928 }
2929 
2934 void STB_DPStartSI(U8BIT path)
2935 {
2936  U8BIT tuner_num;
2937  E_STB_SI_STATUS status;
2938 
2939  FUNCTION_START(STB_DPStartSI);
2940 
2941  ASSERT(path < num_paths);
2942 
2943  tuner_num = path_status[path].tuner_no;
2944 
2945  if (tuner_num != INVALID_RES_ID)
2946  {
2947 #ifdef STB_DEBUG
2948  if (tuner_status[tuner_num].signal_type == SIGNAL_COFDM)
2949  {
2950  STB_DP_PRINT(("Signal Type = COFDM..."));
2951  }
2952  else if (tuner_status[tuner_num].signal_type == SIGNAL_QPSK)
2953  {
2954  STB_DP_PRINT(("Signal Type = QPSK..."));
2955  }
2956  else if (tuner_status[tuner_num].signal_type == SIGNAL_QAM)
2957  {
2958  STB_DP_PRINT(("Signal Type = QAM..."));
2959  }
2960  else
2961  {
2962  STB_DP_PRINT(("Signal type = UNRECOGNISED!"));
2963  }
2964 #endif
2965 
2966  status = STB_SITerrGetStatus(path);
2967 
2968  if ((tuner_status[tuner_num].actions & ACTION_SI_NEW) != 0)
2969  {
2970  // change of transport - so force SI re-start
2971  tuner_status[tuner_num].actions &= ~ACTION_SI_NEW;
2972  status = SI_STOPPED;
2973  }
2974 
2975  // start SI task
2976  if (path_status[path].search_mode == TRUE)
2977  {
2978  switch (status)
2979  {
2980  case SI_STOPPED:
2981  {
2982  STB_DP_PRINT(("STB_DPStartSI(%d): tuner %d - search invoked", path, tuner_num));
2983  STB_SITerrSendEvent(path, SI_EVENT_SEARCH);
2984  break;
2985  }
2986 
2987  default:
2988  {
2989  STB_DP_PRINT(("STB_DPStartSI(%d): tuner %d - no action", path, tuner_num));
2990  break;
2991  }
2992  }
2993  }
2994  else
2995  {
2996  switch (status)
2997  {
2998  case SI_UPDATING:
2999  {
3000  STB_DP_PRINT(("STB_DPStartSI(%d): tuner %d - service change", path, tuner_num));
3001  STB_SITerrSendEvent(path, SI_EVENT_SERVICE_CHANGE);
3002  break;
3003  }
3004 
3005  case SI_STOPPED:
3006  {
3007  STB_DP_PRINT(("STB_DPStartSI(%d): tuner %d - start update", path, tuner_num));
3008  STB_SITerrSendEvent(path, SI_EVENT_UPDATE);
3009  break;
3010  }
3011 
3012  default:
3013  {
3014  STB_DP_PRINT(("STB_DPStartSI(%d): tuner %d - no action", path, tuner_num));
3015  break;
3016  }
3017  }
3018  }
3019  }
3020  else
3021  {
3022  /* Assume we want to get SI data from the playback path (no tuner associated) */
3023  status = STB_SITerrGetStatus(path);
3024  if (path_status[path].search_mode == TRUE)
3025  {
3026  switch (status)
3027  {
3028  case SI_STOPPED:
3029  {
3030  STB_DP_PRINT(("STB_DPStartSI(%d): playback - search", path));
3031  STB_SITerrSendEvent(path, SI_EVENT_SEARCH);
3032  break;
3033  }
3034 
3035  default:
3036  {
3037  STB_DP_PRINT(("STB_DPStartSI(%d): playback - no action", path));
3038  break;
3039  }
3040  }
3041  }
3042  else
3043  {
3044  switch (status)
3045  {
3046  case SI_UPDATING:
3047  {
3048  STB_DP_PRINT(("STB_DPStartSI(%d): playback - service change", path));
3049  STB_SITerrSendEvent(path, SI_EVENT_SERVICE_CHANGE);
3050  break;
3051  }
3052 
3053  case SI_STOPPED:
3054  {
3055  STB_DP_PRINT(("STB_DPStartSI(%d): playback - start update", path));
3056  STB_SITerrSendEvent(path, SI_EVENT_UPDATE);
3057  break;
3058  }
3059 
3060  default:
3061  {
3062  STB_DP_PRINT(("STB_DPStartSI(%d): playback - no action", path));
3063  break;
3064  }
3065  }
3066  }
3067  }
3068 
3069  FUNCTION_FINISH(STB_DPStartSI);
3070 }
3071 
3076 void STB_DPStopSI(U8BIT path)
3077 {
3078  U8BIT tuner_num;
3079 
3080  FUNCTION_START(STB_DPStopSI);
3081 
3082  ASSERT(path < num_paths);
3083 
3084  tuner_num = STB_DPGetPathTuner(path);
3085  STB_DP_PRINT(("STB_DPStopSI(path=%d), tuner_num=%d", path, tuner_num));
3086 
3087  if (tuner_num != INVALID_RES_ID)
3088  {
3089 #ifdef STB_DEBUG
3090  if (tuner_status[tuner_num].signal_type == SIGNAL_COFDM)
3091  {
3092  STB_DP_PRINT(("Signal Type = COFDM..."));
3093  }
3094  else if (tuner_status[tuner_num].signal_type == SIGNAL_QPSK)
3095  {
3096  STB_DP_PRINT(("Signal Type = QPSK..."));
3097  }
3098  else if (tuner_status[tuner_num].signal_type == SIGNAL_QAM)
3099  {
3100  STB_DP_PRINT(("Signal Type = QAM..."));
3101  }
3102  else
3103  {
3104  STB_DP_PRINT(("Signal Type = UNRECOGNISED!"));
3105  }
3106 #endif
3107 
3108  // stop SI task
3109  switch (STB_SITerrGetStatus(path))
3110  {
3111  case SI_SEARCHING:
3112  case SI_UPDATING:
3113  {
3114  STB_DP_PRINT(("STB_DPStopSI(%d): tuner %d - stop invoked", path, tuner_num));
3115  STB_SITerrSendEvent(path, SI_EVENT_STOP);
3116  // wait for SI task to have stopped
3117  while (STB_SITerrGetStatus(path) != SI_STOPPED)
3118  {
3119  STB_OSTaskDelay(10);
3120  }
3121  STB_DP_PRINT(("STB_DPStopSI(%d): tuner %d - stopped", path, tuner_num));
3122  break;
3123  }
3124 
3125  default:
3126  {
3127  STB_DP_PRINT(("STB_DPStopSI(%d) : tuner %d - no action", path, tuner_num));
3128  break;
3129  }
3130  }
3131  }
3132  else
3133  {
3134  /* Assume we want to get SI data from the playback path (no tuner associated) */
3135  switch (STB_SITerrGetStatus(path))
3136  {
3137  case SI_SEARCHING:
3138  case SI_UPDATING:
3139  {
3140  STB_DP_PRINT(("STB_DPStopSI(%d): terrestrial - stop", path));
3141  STB_SITerrSendEvent(path, SI_EVENT_STOP);
3142  // wait for SI task to have stopped
3143  while (STB_SITerrGetStatus(path) != SI_STOPPED)
3144  {
3145  STB_OSTaskDelay(10);
3146  }
3147  STB_DP_PRINT(("STB_DPStopSI(%d): Stopped", path));
3148  break;
3149  }
3150 
3151  default:
3152  {
3153  STB_DP_PRINT(("STB_DPStopSI(%d): status = 0x%x terrestrial - no action", path, STB_SITerrGetStatus(path)));
3154  break;
3155  }
3156  }
3157  }
3158 
3159  FUNCTION_FINISH(STB_DPStopSI);
3160 }
3161 
3169 void STB_DPRequestSIExtendedEvent(U8BIT path, U32BIT start_date, U32BIT start_hour, U32BIT start_min)
3170 {
3171  U8BIT tuner_num;
3172 
3173  FUNCTION_START(STB_DPRequestSIExtendedEvent);
3174 
3175  ASSERT(path < num_paths);
3176 
3177  tuner_num = path_status[path].tuner_no;
3178 
3179  ASSERT(tuner_num < num_tuners);
3180 
3181  tuner_status[tuner_num].si_rparam1 = start_date;
3182  tuner_status[tuner_num].si_rparam2 = start_hour;
3183  tuner_status[tuner_num].si_rparam3 = start_min;
3184 
3185 #ifdef STB_DEBUG
3186  if (tuner_status[tuner_num].signal_type == SIGNAL_COFDM)
3187  {
3188  STB_DP_PRINT(("Signal Type = COFDM..."));
3189  }
3190  else if (tuner_status[tuner_num].signal_type == SIGNAL_QPSK)
3191  {
3192  STB_DP_PRINT(("Signal Type = QPSK..."));
3193  }
3194  else if (tuner_status[tuner_num].signal_type == SIGNAL_QAM)
3195  {
3196  STB_DP_PRINT(("Signal Type = QAM..."));
3197  }
3198  else
3199  {
3200  STB_DP_PRINT(("Signal Type = UNRECOGNISED!"));
3201  }
3202 #endif
3203 
3204  // send request to terrestrial SI task
3205  switch (STB_SITerrGetStatus(path))
3206  {
3207  case SI_UPDATING:
3208  {
3209  STB_DP_PRINT(("STB_DPRequestSIExtendedEvent(%d): tuner %d - request", path, tuner_num));
3210  STB_SITerrSendEvent(path, SI_EVENT_EXTENDED_EVENT);
3211  break;
3212  }
3213 
3214  default:
3215  {
3216  STB_DP_PRINT(("STB_DPRequestSIExtendedEvent(%d): tuner %d - no action", path, tuner_num));
3217  break;
3218  }
3219  }
3220 
3221  FUNCTION_FINISH(STB_DPRequestSIExtendedEvent);
3222 }
3223 
3229 U32BIT STB_DPGetSIRequestParam1(U8BIT path)
3230 {
3231  U8BIT tuner_num;
3232  U32BIT ret_val;
3233 
3234  FUNCTION_START(STB_DPGetSIRequestParam1);
3235 
3236  ASSERT(path < num_paths);
3237 
3238  tuner_num = path_status[path].tuner_no;
3239 
3240  ASSERT(tuner_num < num_tuners);
3241 
3242  ret_val = tuner_status[tuner_num].si_rparam1;
3243 
3244  FUNCTION_FINISH(STB_DPGetSIRequestParam1);
3245 
3246  return(ret_val);
3247 }
3248 
3254 U32BIT STB_DPGetSIRequestParam2(U8BIT path)
3255 {
3256  U8BIT tuner_num;
3257  U32BIT ret_val;
3258 
3259  FUNCTION_START(STB_DPGetSIRequestParam2);
3260 
3261  ASSERT(path < num_paths);
3262 
3263  tuner_num = path_status[path].tuner_no;
3264 
3265  ASSERT(tuner_num < num_tuners);
3266 
3267  ret_val = tuner_status[tuner_num].si_rparam2;
3268 
3269  FUNCTION_FINISH(STB_DPGetSIRequestParam2);
3270 
3271  return(ret_val);
3272 }
3273 
3279 U32BIT STB_DPGetSIRequestParam3(U8BIT path)
3280 {
3281  U8BIT tuner_num;
3282  U32BIT ret_val;
3283 
3284  FUNCTION_START(STB_DPGetSIRequestParam3);
3285 
3286  ASSERT(path < num_paths);
3287 
3288  tuner_num = path_status[path].tuner_no;
3289 
3290  ASSERT(tuner_num < num_tuners);
3291 
3292  ret_val = tuner_status[tuner_num].si_rparam3;
3293 
3294  FUNCTION_FINISH(STB_DPGetSIRequestParam3);
3295 
3296  return(ret_val);
3297 }
3298 
3304 void STB_DPSetTuneStatus(U8BIT path, E_STB_DP_TUNE_STATUS state)
3305 {
3306  U8BIT tuner_num;
3307 
3308  FUNCTION_START(STB_DPSetTuneStatus);
3309 
3310  ASSERT(path < num_paths);
3311 
3312  STB_OSSemaphoreWait(dp_protect);
3313 
3314  tuner_num = path_status[path].tuner_no;
3315 
3316  STB_TUNE_PRINT(("STB_DPSetTuneStatus(%u, %u): tuner=%u", path, state, tuner_num));
3317 
3318  ASSERT(tuner_num < num_tuners);
3319 
3320  tuner_status[tuner_num].tune_stat = state;
3321 
3322  STB_OSSemaphoreSignal(dp_protect);
3323 
3324  FUNCTION_FINISH(STB_DPSetTuneStatus);
3325 }
3326 
3332 E_STB_DP_TUNE_STATUS STB_DPGetTuneStatus(U8BIT path)
3333 {
3334  U8BIT tuner_num;
3335  E_STB_DP_TUNE_STATUS ret_val;
3336 
3337  FUNCTION_START(STB_DPGetTuneStatus);
3338 
3339  ASSERT(path < num_paths);
3340 
3341  tuner_num = path_status[path].tuner_no;
3342 
3343  ASSERT(tuner_num < num_tuners);
3344 
3345  STB_OSSemaphoreWait(dp_protect);
3346 
3347  ret_val = tuner_status[tuner_num].tune_stat;
3348 
3349  STB_TUNE_PRINT(("STB_DPGetTuneStatus(%u): tuner=%u, state=%u", path, tuner_num, ret_val));
3350 
3351  STB_OSSemaphoreSignal(dp_protect);
3352 
3353  FUNCTION_FINISH(STB_DPGetTuneStatus);
3354 
3355  return(ret_val);
3356 }
3357 
3371 void STB_DPSetADEnabled(U8BIT path, BOOLEAN state)
3372 {
3373  U8BIT decoder_num;
3374 
3375  FUNCTION_START(STB_DPSetADEnabled);
3376 
3377  STB_DP_PRINT(("STB_DPSetADEnabled"));
3378  ASSERT(path < num_paths);
3379 
3380  decoder_num = path_status[path].ad_decoder_no;
3381 
3382  ASSERT(decoder_num < num_audio_decoders);
3383 
3384  STB_DP_PRINT(("STB_DPSetADEnabled(%d): decoder=%d, audio state=%d", path, decoder_num, state));
3385 
3386  STB_OSSemaphoreWait(dp_protect);
3387 
3388  if (state == FALSE)
3389  {
3390  ad_decoder_status[decoder_num].ad_status &= ~AD_ENABLED;
3391  }
3392  else
3393  {
3394  ad_decoder_status[decoder_num].ad_status |= AD_ENABLED;
3395  }
3396 
3397  STB_OSSemaphoreSignal(dp_protect);
3398 
3399  FUNCTION_FINISH(STB_DPSetADEnabled);
3400 }
3401 
3415 static U8BIT GetADEnabled(U8BIT path)
3416 {
3417  U8BIT decoder_num;
3418  U8BIT ad_status;
3419 
3420  FUNCTION_START(GetADEnabled);
3421 
3422  ASSERT(path < num_paths);
3423 
3424  decoder_num = path_status[path].ad_decoder_no;
3425 
3426  ASSERT(decoder_num < num_audio_decoders);
3427 
3428  STB_OSSemaphoreWait(dp_protect);
3429 
3430  ad_status = ad_decoder_status[decoder_num].ad_status;
3431 
3432  STB_OSSemaphoreSignal(dp_protect);
3433 
3434  STB_DP_PRINT(("GetADEnabled(%d): decoder=%d, ad status=%d", path, decoder_num, ad_status));
3435 
3436  FUNCTION_FINISH(GetADEnabled);
3437 
3438  return(ad_status);
3439 }
3440 
3452 void STB_DPSetADAudio(U8BIT path, E_STB_DP_AD_AUDIO ad_audio)
3453 {
3454  U8BIT decoder_num;
3455 
3456  FUNCTION_START(STB_DPSetADAudio);
3457 
3458  ASSERT(path < num_paths);
3459 
3460  decoder_num = path_status[path].ad_decoder_no;
3461 
3462  ASSERT(decoder_num < num_audio_decoders);
3463 
3464  STB_OSSemaphoreWait(dp_protect);
3465 
3466  ad_decoder_status[decoder_num].ad_audio = ad_audio;
3467 
3468  STB_OSSemaphoreSignal(dp_protect);
3469 
3470  STB_DP_PRINT(("STB_DPSetADAudio = %d\n", ad_audio));
3471  FUNCTION_FINISH(STB_DPSetADAudio);
3472 
3473  return;
3474 }
3475 
3487 E_STB_DP_AD_AUDIO STB_DPGetADAudio(U8BIT path)
3488 {
3489  U8BIT decoder_num;
3490  E_STB_DP_AD_AUDIO ret_val;
3491 
3492  FUNCTION_START(STB_DPGetADAudio);
3493 
3494  ASSERT(path < num_paths);
3495 
3496  decoder_num = path_status[path].ad_decoder_no;
3497 
3498  ASSERT(decoder_num < num_audio_decoders);
3499 
3500  STB_OSSemaphoreWait(dp_protect);
3501 
3502  ret_val = ad_decoder_status[decoder_num].ad_audio;
3503 
3504  STB_OSSemaphoreSignal(dp_protect);
3505 
3506  STB_DP_PRINT(("STB_DPGetADAudio = %d\n", ret_val));
3507  FUNCTION_FINISH(STB_DPGetADAudio);
3508 
3509  return(ret_val);
3510 }
3511 
3524 void STB_DPSetADStatus(U8BIT path, E_STB_DP_DECODE_STATUS state)
3525 {
3526  U8BIT decoder_num;
3527 
3528  FUNCTION_START(STB_DPSetADStatus);
3529 
3530  ASSERT(path < num_paths);
3531 
3532  decoder_num = path_status[path].ad_decoder_no;
3533 
3534  ASSERT(decoder_num < num_audio_decoders);
3535 
3536  STB_DP_PRINT(("STB_DPSetADStatus(%d): decoder=%d, state=%d", path, decoder_num, state));
3537 
3538  STB_OSSemaphoreWait(dp_protect);
3539 
3540  if ((ad_decoder_status[decoder_num].audio_stat != state) &&
3541  path_status[path].ca_acquired)
3542  {
3543  /* Inform the CA system of the change in the AD decoding state */
3544  switch (state)
3545  {
3546  case DECODE_STARTING:
3547  STB_CADecodeADStatus(path_status[path].ca_handle, CA_DECODE_STATUS_STARTING);
3548  break;
3549 
3550  case DECODE_RUNNING:
3551  STB_CADecodeADStatus(path_status[path].ca_handle, CA_DECODE_STATUS_STARTED);
3552  break;
3553 
3554  case DECODE_STOPPED:
3555  STB_CADecodeADStatus(path_status[path].ca_handle, CA_DECODE_STATUS_STOPPED);
3556  break;
3557 
3558  default:
3559  break;
3560  }
3561  }
3562 
3563  ad_decoder_status[decoder_num].audio_stat = state;
3564 
3565  STB_OSSemaphoreSignal(dp_protect);
3566 
3567  FUNCTION_FINISH(STB_DPSetADStatus);
3568 }
3569 
3581 E_STB_DP_DECODE_STATUS STB_DPGetADStatus(U8BIT path)
3582 {
3583  U8BIT decoder_num;
3584  E_STB_DP_DECODE_STATUS ret_val;
3585 
3586  FUNCTION_START(STB_DPGetADStatus);
3587 
3588  ASSERT(path < num_paths);
3589 
3590  decoder_num = path_status[path].ad_decoder_no;
3591 
3592  ASSERT(decoder_num < num_audio_decoders);
3593 
3594  STB_OSSemaphoreWait(dp_protect);
3595 
3596  ret_val = ad_decoder_status[decoder_num].audio_stat;
3597 
3598  STB_OSSemaphoreSignal(dp_protect);
3599 
3600  FUNCTION_FINISH(STB_DPGetADStatus);
3601 
3602  return(ret_val);
3603 }
3604 
3617 void STB_DPSetAudioStatus(U8BIT path, E_STB_DP_DECODE_STATUS state)
3618 {
3619  U8BIT decoder_num;
3620 
3621  FUNCTION_START(STB_DPSetAudioStatus);
3622 
3623  ASSERT(path < num_paths);
3624 
3625  decoder_num = path_status[path].audio_decoder_no;
3626 
3627  ASSERT(decoder_num < num_audio_decoders);
3628 
3629  STB_DP_PRINT(("STB_DPSetAudioStatus(%d): decoder=%d, state=%d", path, decoder_num, state));
3630 
3631  STB_OSSemaphoreWait(dp_protect);
3632 
3633  if ((audio_decoder_status[decoder_num].audio_stat != state) &&
3634  path_status[path].ca_acquired)
3635  {
3636  /* Inform the CA system of the change in the audio decoding state */
3637  switch (state)
3638  {
3639  case DECODE_STARTING:
3640  STB_CADecodeAudioStatus(path_status[path].ca_handle, CA_DECODE_STATUS_STARTING);
3641  break;
3642 
3643  case DECODE_RUNNING:
3644  STB_CADecodeAudioStatus(path_status[path].ca_handle, CA_DECODE_STATUS_STARTED);
3645  break;
3646 
3647  case DECODE_STOPPED:
3648  STB_CADecodeAudioStatus(path_status[path].ca_handle, CA_DECODE_STATUS_STOPPED);
3649  break;
3650 
3651  default:
3652  break;
3653  }
3654  }
3655 
3656  audio_decoder_status[decoder_num].audio_stat = state;
3657 
3658  STB_OSSemaphoreSignal(dp_protect);
3659 
3660  FUNCTION_FINISH(STB_DPSetAudioStatus);
3661 }
3662 
3674 E_STB_DP_DECODE_STATUS STB_DPGetAudioStatus(U8BIT path)
3675 {
3676  U8BIT decoder_num;
3677  E_STB_DP_DECODE_STATUS ret_val;
3678 
3679  FUNCTION_START(STB_DPGetAudioStatus);
3680 
3681  ASSERT(path < num_paths);
3682 
3683  decoder_num = path_status[path].audio_decoder_no;
3684 
3685  ASSERT(decoder_num < num_audio_decoders);
3686 
3687  STB_OSSemaphoreWait(dp_protect);
3688 
3689  ret_val = audio_decoder_status[decoder_num].audio_stat;
3690 
3691  STB_OSSemaphoreSignal(dp_protect);
3692 
3693  FUNCTION_FINISH(STB_DPGetAudioStatus);
3694 
3695  return(ret_val);
3696 }
3697 
3710 void STB_DPSetVideoStatus(U8BIT path, E_STB_DP_DECODE_STATUS state)
3711 {
3712  U8BIT decoder_num;
3713 
3714  FUNCTION_START(STB_DPSetVideoStatus);
3715 
3716  ASSERT(path < num_paths);
3717 
3718  decoder_num = path_status[path].video_decoder_no;
3719 
3720  ASSERT(decoder_num < num_video_decoders);
3721 
3722  STB_DP_PRINT(("STB_DPSetVideoStatus(%d): decoder=%d, state=%d", path, decoder_num, state));
3723 
3724  STB_OSSemaphoreWait(dp_protect);
3725 
3726  if ((video_decoder_status[decoder_num].video_stat != state) &&
3727  path_status[path].ca_acquired)
3728  {
3729  /* Inform the CA system of the change in the video decoding state */
3730  switch (state)
3731  {
3732  case DECODE_STARTING:
3733  STB_CADecodeVideoStatus(path_status[path].ca_handle, CA_DECODE_STATUS_STARTING);
3734  break;
3735 
3736  case DECODE_RUNNING:
3737  STB_CADecodeVideoStatus(path_status[path].ca_handle, CA_DECODE_STATUS_STARTED);
3738  break;
3739 
3740  case DECODE_STOPPED:
3741  STB_CADecodeVideoStatus(path_status[path].ca_handle, CA_DECODE_STATUS_STOPPED);
3742  break;
3743 
3744  default:
3745  break;
3746  }
3747  }
3748 
3749  video_decoder_status[decoder_num].video_stat = state;
3750 
3751  STB_OSSemaphoreSignal(dp_protect);
3752 
3753  FUNCTION_FINISH(STB_DPSetVideoStatus);
3754 }
3755 
3767 E_STB_DP_DECODE_STATUS STB_DPGetVideoStatus(U8BIT path)
3768 {
3769  U8BIT decoder_num;
3770  E_STB_DP_DECODE_STATUS ret_val;
3771 
3772  FUNCTION_START(STB_DPGetVideoStatus);
3773 
3774  ASSERT(path < num_paths);
3775 
3776  decoder_num = path_status[path].video_decoder_no;
3777 
3778  ASSERT(decoder_num < num_video_decoders);
3779 
3780  STB_OSSemaphoreWait(dp_protect);
3781 
3782  ret_val = video_decoder_status[decoder_num].video_stat;
3783 
3784  STB_OSSemaphoreSignal(dp_protect);
3785 
3786  FUNCTION_FINISH(STB_DPGetVideoStatus);
3787 
3788  return(ret_val);
3789 }
3790 
3803 void STB_DPSetSignalType(U8BIT path, E_STB_DP_SIGNAL_TYPE sigtype)
3804 {
3805  U8BIT tuner_num;
3806 
3807  FUNCTION_START(STB_DPSetSignalType);
3808 
3809  ASSERT(path < num_paths);
3810 
3811  tuner_num = path_status[path].tuner_no;
3812 
3813  ASSERT(tuner_num < num_tuners);
3814 
3815  STB_TUNE_PRINT(("STB_DPSetSignalType(%d): sigtype %d", path, sigtype));
3816  if (sigtype != tuner_status[tuner_num].signal_type)
3817  {
3818  tuner_status[tuner_num].signal_type = sigtype;
3819  tuner_status[tuner_num].actions |= ACTION_TUNE;
3820  }
3821 
3822  FUNCTION_FINISH(STB_DPSetSignalType);
3823 }
3824 
3836 E_STB_DP_SIGNAL_TYPE STB_DPGetSignalType(U8BIT path)
3837 {
3838  U8BIT tuner_num;
3839  E_STB_DP_SIGNAL_TYPE ret_val;
3840 
3841  FUNCTION_START(STB_DPGetSignalType);
3842 
3843  ASSERT(path < num_paths);
3844 
3845  tuner_num = path_status[path].tuner_no;
3846 
3847  ASSERT(tuner_num < num_tuners);
3848 
3849  ret_val = tuner_status[tuner_num].signal_type;
3850 
3851  FUNCTION_FINISH(STB_DPGetSignalType);
3852 
3853  return(ret_val);
3854 }
3855 
3868 void STB_DPSetTuneRelock(U8BIT path, BOOLEAN state)
3869 {
3870  U8BIT tuner_num;
3871 
3872  FUNCTION_START(STB_DPSetTuneRelock);
3873 
3874  ASSERT(path < num_paths);
3875 
3876  tuner_num = path_status[path].tuner_no;
3877 
3878  ASSERT(tuner_num < num_tuners);
3879 
3880  STB_TUNE_PRINT(("STB_DPSetTuneRelock(%d): tuner %d state %d", path, tuner_num, state));
3881  tuner_status[tuner_num].auto_relock = state;
3882 
3883  STB_TuneAutoRelock(tuner_num, state);
3884 
3885  FUNCTION_FINISH(STB_DPSetTuneRelock);
3886 }
3887 
3899 BOOLEAN STB_DPGetTuneRelock(U8BIT path)
3900 {
3901  U8BIT tuner_num;
3902  BOOLEAN ret_val;
3903 
3904  FUNCTION_START(STB_DPGetTuneRelock);
3905 
3906  ASSERT(path < num_paths);
3907 
3908  tuner_num = path_status[path].tuner_no;
3909 
3910  ASSERT(tuner_num < num_tuners);
3911 
3912  ret_val = tuner_status[tuner_num].auto_relock;
3913 
3914  FUNCTION_FINISH(STB_DPGetTuneRelock);
3915 
3916  return(ret_val);
3917 }
3918 
3931 void STB_DPSetLockEnable(U8BIT path, BOOLEAN state)
3932 {
3933  FUNCTION_START(STB_DPSetLockEnable);
3934 
3935  ASSERT(path < num_paths);
3936 
3937  STB_DP_PRINT(("STB_DPSetLockEnable(%d): state %d", path, state));
3938  path_status[path].lock_enable = state;
3939 
3940  FUNCTION_FINISH(STB_DPSetLockEnable);
3941 }
3942 
3954 BOOLEAN STB_DPGetLockEnable(U8BIT path)
3955 {
3956  BOOLEAN ret_val;
3957 
3958  FUNCTION_START(STB_DPGetLockEnable);
3959 
3960  ASSERT(path < num_paths);
3961 
3962  ret_val = path_status[path].lock_enable;
3963 
3964  FUNCTION_FINISH(STB_DPGetLockEnable);
3965 
3966  return(ret_val);
3967 }
3968 
3981 void STB_DPSetSearchMode(U8BIT path, BOOLEAN state)
3982 {
3983  FUNCTION_START(STB_DPSetSearchMode);
3984 
3985  ASSERT(path < num_paths);
3986 
3987  STB_DP_PRINT(("STB_DPSetSearchMode(%d): state %d", path, state));
3988  path_status[path].search_mode = state;
3989 
3990  FUNCTION_FINISH(STB_DPSetSearchMode);
3991 }
3992 
4004 BOOLEAN STB_DPGetSearchMode(U8BIT path)
4005 {
4006  BOOLEAN ret_val;
4007 
4008  FUNCTION_START(STB_DPGetSearchMode);
4009 
4010  ASSERT(path < num_paths);
4011 
4012  ret_val = path_status[path].search_mode;
4013 
4014  FUNCTION_FINISH(STB_DPGetSearchMode);
4015 
4016  return(ret_val);
4017 }
4018 
4031 void STB_DPSetTVSearch(U8BIT path, BOOLEAN state)
4032 {
4033  U8BIT tuner_num;
4034 
4035  FUNCTION_START(STB_DPSetTVSearch);
4036 
4037  ASSERT(path < num_paths);
4038 
4039  tuner_num = path_status[path].tuner_no;
4040 
4041  ASSERT(tuner_num < num_tuners);
4042 
4043  STB_DP_PRINT(("STB_DPSetTVSearch(%d): tuner %d state %d", path, tuner_num, state));
4044  tuner_status[tuner_num].tv_search = state;
4045 
4046  FUNCTION_FINISH(STB_DPSetTVSearch);
4047 }
4048 
4060 BOOLEAN STB_DPGetTVSearch(U8BIT path)
4061 {
4062  U8BIT tuner_num;
4063  BOOLEAN ret_val;
4064 
4065  FUNCTION_START(STB_DPGetTVSearch);
4066 
4067  ASSERT(path < num_paths);
4068 
4069  tuner_num = path_status[path].tuner_no;
4070 
4071  ASSERT(tuner_num < num_tuners);
4072 
4073  ret_val = tuner_status[tuner_num].tv_search;
4074 
4075  FUNCTION_FINISH(STB_DPGetTVSearch);
4076 
4077  return(ret_val);
4078 }
4079 
4092 void STB_DPSetRadioSearch(U8BIT path, BOOLEAN state)
4093 {
4094  U8BIT tuner_num;
4095 
4096  FUNCTION_START(STB_DPSetRadioSearch);
4097 
4098  ASSERT(path < num_paths);
4099 
4100  tuner_num = path_status[path].tuner_no;
4101 
4102  ASSERT(tuner_num < num_tuners);
4103 
4104  STB_DP_PRINT(("STB_DPSetRadioSearch(%d): tuner %d state %d", path, tuner_num, state));
4105  tuner_status[tuner_num].rad_search = state;
4106 
4107  FUNCTION_FINISH(STB_DPSetRadioSearch);
4108 }
4109 
4121 BOOLEAN STB_DPGetRadioSearch(U8BIT path)
4122 {
4123  U8BIT tuner_num;
4124  BOOLEAN ret_val;
4125 
4126  FUNCTION_START(STB_DPGetRadioSearch);
4127 
4128  ASSERT(path < num_paths);
4129 
4130  tuner_num = path_status[path].tuner_no;
4131 
4132  ASSERT(tuner_num < num_tuners);
4133 
4134  ret_val = tuner_status[tuner_num].rad_search;
4135 
4136  FUNCTION_FINISH(STB_DPGetRadioSearch);
4137 
4138  return(ret_val);
4139 }
4140 
4153 void STB_DPSetFTASearch(U8BIT path, BOOLEAN state)
4154 {
4155  U8BIT tuner_num;
4156 
4157  FUNCTION_START(STB_DPSetFTASearch);
4158 
4159  ASSERT(path < num_paths);
4160 
4161  tuner_num = path_status[path].tuner_no;
4162 
4163  ASSERT(tuner_num < num_tuners);
4164 
4165  STB_DP_PRINT(("STB_DPSetFTASearch(%d): tuner %d state %d", path, tuner_num, state));
4166  tuner_status[tuner_num].fta_search = state;
4167 
4168  FUNCTION_FINISH(STB_DPSetFTASearch);
4169 }
4170 
4182 BOOLEAN STB_DPGetFTASearch(U8BIT path)
4183 {
4184  U8BIT tuner_num;
4185  BOOLEAN ret_val;
4186 
4187  FUNCTION_START(STB_DPGetFTASearch);
4188 
4189  ASSERT(path < num_paths);
4190 
4191  tuner_num = path_status[path].tuner_no;
4192 
4193  ASSERT(tuner_num < num_tuners);
4194 
4195  ret_val = tuner_status[tuner_num].fta_search;
4196 
4197  FUNCTION_FINISH(STB_DPGetFTASearch);
4198 
4199  return(ret_val);
4200 }
4201 
4214 void STB_DPSetScramSearch(U8BIT path, BOOLEAN state)
4215 {
4216  U8BIT tuner_num;
4217 
4218  FUNCTION_START(STB_DPSetScramSearch);
4219 
4220  ASSERT(path < num_paths);
4221 
4222  tuner_num = path_status[path].tuner_no;
4223 
4224  ASSERT(tuner_num < num_tuners);
4225 
4226  STB_DP_PRINT(("STB_DPSetScramSearch(%d): tuner %d state %d", path, tuner_num, state));
4227  tuner_status[tuner_num].scram_search = state;
4228 
4229  FUNCTION_FINISH(STB_DPSetScramSearch);
4230 }
4231 
4243 BOOLEAN STB_DPGetScramSearch(U8BIT path)
4244 {
4245  U8BIT tuner_num;
4246  BOOLEAN ret_val;
4247 
4248  FUNCTION_START(STB_DPGetScramSearch);
4249 
4250  ASSERT(path < num_paths);
4251 
4252  tuner_num = path_status[path].tuner_no;
4253 
4254  ASSERT(tuner_num < num_tuners);
4255 
4256  ret_val = tuner_status[tuner_num].scram_search;
4257 
4258  FUNCTION_FINISH(STB_DPGetScramSearch);
4259 
4260  return(ret_val);
4261 }
4262 
4275 void STB_DPSetNetworkSearch(U8BIT path, BOOLEAN state)
4276 {
4277  U8BIT tuner_num;
4278 
4279  FUNCTION_START(STB_DPSetNetworkSearch);
4280 
4281  ASSERT(path < num_paths);
4282 
4283  tuner_num = path_status[path].tuner_no;
4284 
4285  ASSERT(tuner_num < num_tuners);
4286 
4287  STB_DP_PRINT(("STB_DPSetNetworkSearch(%d): tuner %d state %d", path, tuner_num, state));
4288  tuner_status[tuner_num].net_search = state;
4289 
4290  FUNCTION_FINISH(STB_DPSetNetworkSearch);
4291 }
4292 
4304 BOOLEAN STB_DPGetNetworkSearch(U8BIT path)
4305 {
4306  U8BIT tuner_num;
4307  BOOLEAN ret_val;
4308 
4309  FUNCTION_START(STB_DPGetNetworkSearch);
4310 
4311  ASSERT(path < num_paths);
4312 
4313  tuner_num = path_status[path].tuner_no;
4314 
4315  ASSERT(tuner_num < num_tuners);
4316 
4317  ret_val = tuner_status[tuner_num].net_search;
4318 
4319  FUNCTION_FINISH(STB_DPGetNetworkSearch);
4320 
4321  return(ret_val);
4322 }
4323 
4338 void STB_DPSetOTASearchMode(U8BIT path, E_STB_OTA_SW_UPGRADE_SEARCH_MODE mode)
4339 {
4340  U8BIT tuner_num;
4341 
4342  FUNCTION_START(STB_DPSetOTASearchMode);
4343 
4344  ASSERT(path < num_paths);
4345 
4346  tuner_num = path_status[path].tuner_no;
4347 
4348  ASSERT(tuner_num < num_tuners);
4349 
4350  STB_DP_PRINT(("STB_DPSetOTASearchMode(%d): tuner %d mode %d", path, tuner_num, mode));
4351  tuner_status[tuner_num].ota_search_status = mode;
4352 
4353  FUNCTION_FINISH(STB_DPSetOTASearchMode);
4354 }
4355 
4369 E_STB_OTA_SW_UPGRADE_SEARCH_MODE STB_DPGetOTASearchMode(U8BIT path)
4370 {
4371  U8BIT tuner_num;
4372  E_STB_OTA_SW_UPGRADE_SEARCH_MODE ret_val;
4373 
4374  FUNCTION_START(STB_DPGetOTASearchMode);
4375 
4376  ASSERT(path < num_paths);
4377 
4378  tuner_num = path_status[path].tuner_no;
4379 
4380  ASSERT(tuner_num < num_tuners);
4381 
4382  ret_val = tuner_status[tuner_num].ota_search_status;
4383 
4384  FUNCTION_FINISH(STB_DPGetOTASearchMode);
4385 
4386  return(ret_val);
4387 }
4388 
4401 BOOLEAN STB_DPOTASearchEnabled(U8BIT path)
4402 {
4403  U8BIT tuner_num;
4404  BOOLEAN ret_val;
4405 
4406  FUNCTION_START(STB_DPOTASearchEnabled);
4407 
4408  ASSERT(path < num_paths);
4409 
4410  tuner_num = path_status[path].tuner_no;
4411 
4412  ASSERT(tuner_num < num_tuners);
4413 
4414  ret_val = (tuner_status[tuner_num].ota_search_status != OTA_SEARCH_OFF);
4415 
4416  FUNCTION_FINISH(STB_DPOTASearchEnabled);
4417 
4418  return(ret_val);
4419 }
4420 
4433 void STB_DPSetLNBPower(U8BIT path, E_STB_DP_LNB_POWER state)
4434 {
4435  U8BIT tuner_num;
4436 
4437  FUNCTION_START(STB_DPSetLNBPower);
4438 
4439  ASSERT(path < num_paths);
4440 
4441  tuner_num = path_status[path].tuner_no;
4442 
4443  ASSERT(tuner_num < num_tuners);
4444 
4445  STB_TUNE_PRINT(("STB_DPSetLNBPower(%d) : tuner %d state %d", path, tuner_num, state));
4446  if (state != tuner_status[tuner_num].lnb_power)
4447  {
4448  tuner_status[tuner_num].lnb_power = state;
4449  tuner_status[tuner_num].actions |= ACTION_TUNE;
4450  }
4451 
4452  FUNCTION_FINISH(STB_DPSetLNBPower);
4453 }
4454 
4466 E_STB_DP_LNB_POWER STB_DPGetLNBPower(U8BIT path)
4467 {
4468  U8BIT tuner_num;
4469  E_STB_DP_LNB_POWER ret_val;
4470 
4471  FUNCTION_START(STB_DPGetLNBPower);
4472 
4473  ASSERT(path < num_paths);
4474 
4475  tuner_num = path_status[path].tuner_no;
4476 
4477  ASSERT(tuner_num < num_tuners);
4478 
4479  ret_val = tuner_status[tuner_num].lnb_power;
4480 
4481  FUNCTION_FINISH(STB_DPGetLNBPower);
4482 
4483  return(ret_val);
4484 }
4485 
4498 void STB_DPSetLNBType(U8BIT path, E_STB_DP_LNB_TYPE type)
4499 {
4500  U8BIT tuner_num;
4501 
4502  FUNCTION_START(STB_DPSetLNBType);
4503 
4504  ASSERT(path < num_paths);
4505 
4506  tuner_num = path_status[path].tuner_no;
4507 
4508  ASSERT(tuner_num < num_tuners);
4509 
4510  STB_TUNE_PRINT(("STB_DPSetLNBType(%d) : tuner %d type %d", path, tuner_num, type));
4511  if (type != tuner_status[tuner_num].lnb_type)
4512  {
4513  tuner_status[tuner_num].lnb_type = type;
4514  tuner_status[tuner_num].actions |= ACTION_TUNE;
4515  }
4516 
4517  FUNCTION_FINISH(STB_DPSetLNBType);
4518 }
4519 
4531 E_STB_DP_LNB_TYPE STB_DPGetLNBType(U8BIT path)
4532 {
4533  U8BIT tuner_num;
4534  E_STB_DP_LNB_TYPE ret_val;
4535 
4536  FUNCTION_START(STB_DPGetLNBType);
4537 
4538  ASSERT(path < num_paths);
4539 
4540  tuner_num = path_status[path].tuner_no;
4541 
4542  ASSERT(tuner_num < num_tuners);
4543 
4544  ret_val = tuner_status[tuner_num].lnb_type;
4545 
4546  FUNCTION_FINISH(STB_DPGetLNBType);
4547 
4548  return(ret_val);
4549 }
4550 
4560 void STB_DPSetUserDefinedLNBBands(U8BIT path, U8BIT number_of_bands, S_STB_DP_LNB_BAND *band_definitions)
4561 {
4562  U8BIT tuner_num;
4563 
4564  FUNCTION_START(STB_DPSetUserDefinedLNBBands);
4565 
4566  ASSERT(path < num_paths);
4567 
4568  tuner_num = path_status[path].tuner_no;
4569 
4570  ASSERT(tuner_num < num_tuners);
4571 
4572  tuner_status[tuner_num].lnb_definition[LNB_TYPE_USER_DEFINED].number_of_bands = number_of_bands;
4573  tuner_status[tuner_num].lnb_definition[LNB_TYPE_USER_DEFINED].band_list = band_definitions;
4574 
4575  FUNCTION_FINISH(STB_DPSetUserDefinedLNBBands);
4576 }
4577 
4590 void STB_DPSetLNB22k(U8BIT path, BOOLEAN state)
4591 {
4592  U8BIT tuner_num;
4593 
4594  FUNCTION_START(STB_DPSetLNB22k);
4595 
4596  ASSERT(path < num_paths);
4597 
4598  tuner_num = path_status[path].tuner_no;
4599 
4600  ASSERT(tuner_num < num_tuners);
4601 
4602  STB_TUNE_PRINT(("STB_DPSetLNB22k(%d) : tuner %d state %d", path, tuner_num, state));
4603  if (state != tuner_status[tuner_num].lnb_22k)
4604  {
4605  tuner_status[tuner_num].lnb_22k = state;
4606 
4607  // check if we need to turn on/off 22KHz
4608  if (tuner_status[tuner_num].lnb_power != LNB_POWER_OFF)
4609  {
4610  // only switch tone if single LNB
4611  if (tuner_status[tuner_num].lnb_type == LNB_TYPE_SINGLE)
4612  {
4613  tuner_status[tuner_num].actions |= ACTION_TUNE;
4614  }
4615  }
4616  }
4617 
4618  FUNCTION_FINISH(STB_DPSetLNB22k);
4619 }
4620 
4632 BOOLEAN STB_DPGetLNB22k(U8BIT path)
4633 {
4634  U8BIT tuner_num;
4635  BOOLEAN ret_val;
4636 
4637  FUNCTION_START(STB_DPGetLNB22k);
4638 
4639  ASSERT(path < num_paths);
4640 
4641  tuner_num = path_status[path].tuner_no;
4642 
4643  ASSERT(tuner_num < num_tuners);
4644 
4645  ret_val = tuner_status[tuner_num].lnb_22k;
4646 
4647  FUNCTION_FINISH(STB_DPGetLNB22k);
4648 
4649  return(ret_val);
4650 }
4651 
4664 void STB_DPSetLNB12v(U8BIT path, BOOLEAN state)
4665 {
4666  U8BIT tuner_num;
4667 
4668  FUNCTION_START(STB_DPSetLNB12v);
4669 
4670  ASSERT(path < num_paths);
4671 
4672  tuner_num = path_status[path].tuner_no;
4673 
4674  ASSERT(tuner_num < num_tuners);
4675 
4676  STB_TUNE_PRINT(("STB_DPSetLNB12v(%d) : tuner %d state %d", path, tuner_num, state));
4677  if (state != tuner_status[tuner_num].lnb_12v)
4678  {
4679  tuner_status[tuner_num].lnb_12v = state;
4680  tuner_status[tuner_num].actions |= ACTION_TUNE;
4681  }
4682 
4683  FUNCTION_FINISH(STB_DPSetLNB12v);
4684 }
4685 
4697 BOOLEAN STB_DPGetLNB12v(U8BIT path)
4698 {
4699  U8BIT tuner_num;
4700  BOOLEAN ret_val;
4701 
4702  FUNCTION_START(STB_DPGetLNB12v);
4703 
4704  ASSERT(path < num_paths);
4705 
4706  tuner_num = path_status[path].tuner_no;
4707 
4708  ASSERT(tuner_num < num_tuners);
4709 
4710  ret_val = tuner_status[tuner_num].lnb_12v;
4711 
4712  FUNCTION_FINISH(STB_DPGetLNB12v);
4713 
4714  return(ret_val);
4715 }
4716 
4729 void STB_DPSetPulsePosition(U8BIT path, BOOLEAN state)
4730 {
4731  U8BIT tuner_num;
4732 
4733  FUNCTION_START(STB_DPSetPulsePosition);
4734 
4735  ASSERT(path < num_paths);
4736 
4737  tuner_num = path_status[path].tuner_no;
4738 
4739  ASSERT(tuner_num < num_tuners);
4740 
4741  STB_TUNE_PRINT(("STB_DPSetPulsePosition(%d): state %d", path, state));
4742  tuner_status[tuner_num].pulse_position = state;
4743 
4744  FUNCTION_FINISH(STB_DPSetPulsePosition);
4745 }
4746 
4758 BOOLEAN STB_DPGetPulsePosition(U8BIT path)
4759 {
4760  U8BIT tuner_num;
4761  BOOLEAN ret_val;
4762 
4763  FUNCTION_START(STB_DPGetPulsePosition);
4764 
4765  ASSERT(path < num_paths);
4766 
4767  tuner_num = path_status[path].tuner_no;
4768 
4769  ASSERT(tuner_num < num_tuners);
4770 
4771  ret_val = tuner_status[tuner_num].pulse_position;
4772 
4773  FUNCTION_FINISH(STB_DPGetPulsePosition);
4774 
4775  return(ret_val);
4776 }
4777 
4790 void STB_DPSetDISEQCPosition(U8BIT path, BOOLEAN state)
4791 {
4792  U8BIT tuner_num;
4793 
4794  FUNCTION_START(STB_DPSetDISEQCPosition);
4795 
4796  ASSERT(path < num_paths);
4797 
4798  tuner_num = path_status[path].tuner_no;
4799 
4800  ASSERT(tuner_num < num_tuners);
4801 
4802  STB_TUNE_PRINT(("STB_DPSetDISEQCPosition(%d): state %d", path, state));
4803  tuner_status[tuner_num].diseqc_position = state;
4804 
4805  FUNCTION_FINISH(STB_DPSetDISEQCPosition);
4806 }
4807 
4819 BOOLEAN STB_DPGetDISEQCPosition(U8BIT path)
4820 {
4821  U8BIT tuner_num;
4822  BOOLEAN ret_val;
4823 
4824  FUNCTION_START(STB_DPGetDISEQCPosition);
4825 
4826  ASSERT(path < num_paths);
4827 
4828  tuner_num = path_status[path].tuner_no;
4829 
4830  ASSERT(tuner_num < num_tuners);
4831 
4832  ret_val = tuner_status[tuner_num].diseqc_position;
4833 
4834  FUNCTION_FINISH(STB_DPGetDISEQCPosition);
4835 
4836  return(ret_val);
4837 }
4838 
4851 void STB_DPSetDISEQCCSwitch(U8BIT path, E_STB_DP_DISEQC_CSWITCH state)
4852 {
4853  U8BIT tuner_num;
4854 
4855  FUNCTION_START(STB_DPSetDISEQCCSwitch);
4856 
4857  ASSERT(path < num_paths);
4858 
4859  tuner_num = path_status[path].tuner_no;
4860 
4861  ASSERT(tuner_num < num_tuners);
4862 
4863  STB_TUNE_PRINT(("STB_DPSetDISEQCCSwitch(%d): state %d", path, state));
4864  if (state != tuner_status[tuner_num].diseqc_cswitch)
4865  {
4866  tuner_status[tuner_num].diseqc_cswitch = state;
4867  tuner_status[tuner_num].actions |= ACTION_TUNE;
4868  }
4869 
4870  FUNCTION_FINISH(STB_DPSetDISEQCCSwitch);
4871 }
4872 
4884 E_STB_DP_DISEQC_CSWITCH STB_DPGetDISEQCCSwitch(U8BIT path)
4885 {
4886  U8BIT tuner_num;
4887  E_STB_DP_DISEQC_CSWITCH ret_val;
4888 
4889  FUNCTION_START(STB_DPGetDISEQCCSwitch);
4890 
4891  ASSERT(path < num_paths);
4892 
4893  tuner_num = path_status[path].tuner_no;
4894 
4895  ASSERT(tuner_num < num_tuners);
4896 
4897  ret_val = tuner_status[tuner_num].diseqc_cswitch;
4898 
4899  FUNCTION_FINISH(STB_DPGetDISEQCCSwitch);
4900 
4901  return(ret_val);
4902 }
4903 
4916 void STB_DPSetDISEQCUSwitch(U8BIT path, U8BIT state)
4917 {
4918  U8BIT tuner_num;
4919 
4920  FUNCTION_START(STB_DPSetDISEQCUSwitch);
4921 
4922  ASSERT(path < num_paths);
4923 
4924  tuner_num = path_status[path].tuner_no;
4925 
4926  ASSERT(tuner_num < num_tuners);
4927 
4928  STB_TUNE_PRINT(("STB_DPSetDISEQCUSwitch(%d): state %d", path, state));
4929  if (state != tuner_status[tuner_num].diseqc_uswitch)
4930  {
4931  tuner_status[tuner_num].diseqc_uswitch = state;
4932  tuner_status[tuner_num].actions |= ACTION_TUNE;
4933  }
4934 
4935  FUNCTION_FINISH(STB_DPSetDISEQCUSwitch);
4936 }
4937 
4949 U8BIT STB_DPGetDISEQCUSwitch(U8BIT path)
4950 {
4951  U8BIT tuner_num;
4952  U8BIT ret_val;
4953 
4954  FUNCTION_START(STB_DPGetDISEQCUSwitch);
4955 
4956  ASSERT(path < num_paths);
4957 
4958  tuner_num = path_status[path].tuner_no;
4959 
4960  ASSERT(tuner_num < num_tuners);
4961 
4962  ret_val = tuner_status[tuner_num].diseqc_uswitch;
4963 
4964  FUNCTION_FINISH(STB_DPGetDISEQCUSwitch);
4965 
4966  return(ret_val);
4967 }
4968 
4981 void STB_DPSetDISEQCTone(U8BIT path, E_STB_DP_DISEQC_TONE state)
4982 {
4983  U8BIT tuner_num;
4984 
4985  FUNCTION_START(STB_DPSetDISEQCTone);
4986 
4987  ASSERT(path < num_paths);
4988 
4989  tuner_num = path_status[path].tuner_no;
4990 
4991  ASSERT(tuner_num < num_tuners);
4992 
4993  STB_TUNE_PRINT(("STB_DPSetDISEQCTone(%d): state %d", path, state));
4994  if (state != tuner_status[tuner_num].diseqc_tone)
4995  {
4996  tuner_status[tuner_num].diseqc_tone = state;
4997  tuner_status[tuner_num].actions |= ACTION_TUNE;
4998  }
4999 
5000  FUNCTION_FINISH(STB_DPSetDISEQCTone);
5001 }
5002 
5014 E_STB_DP_DISEQC_TONE STB_DPGetDISEQCTone(U8BIT path)
5015 {
5016  U8BIT tuner_num;
5017  E_STB_DP_DISEQC_TONE ret_val;
5018 
5019  FUNCTION_START(STB_DPGetDISEQCTone);
5020 
5021  ASSERT(path < num_paths);
5022 
5023  tuner_num = path_status[path].tuner_no;
5024 
5025  ASSERT(tuner_num < num_tuners);
5026 
5027  ret_val = tuner_status[tuner_num].diseqc_tone;
5028 
5029  FUNCTION_FINISH(STB_DPGetDISEQCTone);
5030 
5031  return(ret_val);
5032 }
5033 
5046 void STB_DPSetDISEQCSMATV(U8BIT path, BOOLEAN state)
5047 {
5048  U8BIT tuner_num;
5049 
5050  FUNCTION_START(STB_DPSetDISEQCSMATV);
5051 
5052  ASSERT(path < num_paths);
5053 
5054  tuner_num = path_status[path].tuner_no;
5055 
5056  ASSERT(tuner_num < num_tuners);
5057 
5058  STB_TUNE_PRINT(("STB_DPSetDISEQCSMATV(%d): state %d", path, state));
5059  if (state != tuner_status[tuner_num].diseqc_smatv)
5060  {
5061  tuner_status[tuner_num].diseqc_smatv = state;
5062  tuner_status[tuner_num].actions |= ACTION_TUNE;
5063  }
5064 
5065  FUNCTION_FINISH(STB_DPSetDISEQCSMATV);
5066 }
5067 
5079 BOOLEAN STB_DPGetDISEQCSMATV(U8BIT path)
5080 {
5081  U8BIT tuner_num;
5082  BOOLEAN ret_val;
5083 
5084  FUNCTION_START(STB_DPGetDISEQCSMATV);
5085 
5086  ASSERT(path < num_paths);
5087 
5088  tuner_num = path_status[path].tuner_no;
5089 
5090  ASSERT(tuner_num < num_tuners);
5091 
5092  ret_val = tuner_status[tuner_num].diseqc_smatv;
5093 
5094  FUNCTION_FINISH(STB_DPGetDISEQCSMATV);
5095 
5096  return(ret_val);
5097 }
5098 
5111 void STB_DPSetDISEQCRepeats(U8BIT path, U8BIT count)
5112 {
5113  U8BIT tuner_num;
5114 
5115  FUNCTION_START(STB_DPSetDISEQCRepeats);
5116 
5117  ASSERT(path < num_paths);
5118 
5119  tuner_num = path_status[path].tuner_no;
5120 
5121  ASSERT(tuner_num < num_tuners);
5122 
5123  STB_TUNE_PRINT(("STB_DPSetDISEQCRepeats(%u, %u): current count=%u", path, count,
5124  tuner_status[tuner_num].diseqc_repeats));
5125 
5126  if (count != tuner_status[tuner_num].diseqc_repeats)
5127  {
5128  tuner_status[tuner_num].diseqc_repeats = count;
5129  tuner_status[tuner_num].actions |= ACTION_TUNE;
5130  }
5131 
5132  FUNCTION_FINISH(STB_DPSetDISEQCRepeats);
5133 }
5134 
5146 U8BIT STB_DPGetDISEQCRepeats(U8BIT path)
5147 {
5148  U8BIT tuner_num;
5149  BOOLEAN ret_val;
5150 
5151  FUNCTION_START(STB_DPGetDISEQCRepeats);
5152 
5153  ASSERT(path < num_paths);
5154 
5155  tuner_num = path_status[path].tuner_no;
5156 
5157  ASSERT(tuner_num < num_tuners);
5158 
5159  ret_val = tuner_status[tuner_num].diseqc_repeats;
5160 
5161  FUNCTION_FINISH(STB_DPGetDISEQCRepeats);
5162 
5163  return(ret_val);
5164 }
5165 
5180 U8BIT STB_DPGetUnicableParams(U8BIT path, U32BIT unicable_if[MAX_UNICABLE_BANKS], U32BIT *lnb_lo_freq, U32BIT *lnb_hi_freq)
5181 {
5182  U8BIT tuner;
5183  U8BIT cmd_signals_on[5] = {0xe0, 0x10, 0x5b, 0x00, 0x00};
5184  U8BIT cmd_lofreq[5] = {0xe0, 0x10, 0x5b, 0x02, 0x00};
5185  U8BIT stren = 0;
5186  U32BIT f;
5187  U8BIT bank_n = 0;
5188  U8BIT lut;
5189  // Unicable LO frequencies look-up table
5190  U32BIT lofreq_lut[0x0c] = {9750000, 10000000, 10600000, 10750000, 11000000, 11250000, 11475000, 20250000, 5150000, 1585000, 13850000};
5191 
5192  tuner = path_status[path].tuner_no;
5193  *lnb_lo_freq = 0;
5194  *lnb_hi_freq = 0;
5195 
5196  STB_TuneSetLNBVoltage(tuner, LNB_VOLTAGE_14V);
5197  STB_OSTaskDelay(1000);
5198  UnicableSendCommand(tuner, cmd_signals_on);
5199 
5200  // First find what frequencies the banks are located at
5201  for (f = 950000; f < 2150000; f += 4000)
5202  {
5203  stren = STB_TuneSatGetCarrierStrength(tuner, f);
5204  if (stren > UNICABLE_SIGNAL_THRESHOLD)
5205  {
5206  unicable_if[bank_n] = f;
5207  bank_n++;
5208  }
5209  }
5210 
5211  // If banks were found, get the LO frequencies for this LNB
5212  // assume LO frequencies are same for all banks
5213  if (bank_n > 0)
5214  {
5215  // Now query the device's local oscillator frequencies
5216  for (lut = 0x02; lut < 0x0c; lut++)
5217  {
5218  cmd_lofreq[4] = lut;
5219  UnicableSendCommand(tuner, cmd_lofreq);
5220  // "No" answer is flagged by carrier 20MHz above bank freq
5221  stren = STB_TuneSatGetCarrierStrength(tuner, unicable_if[bank_n] + 20000);
5222  if (stren < UNICABLE_SIGNAL_THRESHOLD)
5223  {
5224  // "Yes" answer is flagged by carrier at bank freq
5225  stren = STB_TuneSatGetCarrierStrength(tuner, unicable_if[bank_n]);
5226  if (stren > UNICABLE_SIGNAL_THRESHOLD)
5227  {
5228  // Populate the lo/hi osc frequencies (in ascending order)
5229  if (*lnb_lo_freq == 0)
5230  {
5231  *lnb_lo_freq = lofreq_lut[lut];
5232  }
5233  else if (*lnb_hi_freq == 0)
5234  {
5235  *lnb_hi_freq = lofreq_lut[lut];
5236  }
5237  }
5238  }
5239  }
5240  }
5241 
5242  // Return number of Unicable banks found (0 if error or none found)
5243  return bank_n;
5244 }
5245 
5258 void STB_DPSetUnicablePositionB(U8BIT path, BOOLEAN position_b)
5259 {
5260  U8BIT tuner_num;
5261 
5262  FUNCTION_START(STB_DPSetUnicablePositionB);
5263 
5264  ASSERT(path < num_paths);
5265 
5266  tuner_num = path_status[path].tuner_no;
5267 
5268  ASSERT(tuner_num < num_tuners);
5269 
5270  tuner_status[tuner_num].unicable_position_b = position_b;
5271 
5272  FUNCTION_FINISH(STB_DPSetUnicablePositionB);
5273 }
5274 
5286 BOOLEAN STB_DPGetUnicablePositionB(U8BIT path)
5287 {
5288  U8BIT tuner_num;
5289  U8BIT ret_val;
5290 
5291  FUNCTION_START(STB_DPGetUnicablePositionB);
5292 
5293  ASSERT(path < num_paths);
5294 
5295  tuner_num = path_status[path].tuner_no;
5296 
5297  ASSERT(tuner_num < num_tuners);
5298 
5299  ret_val = tuner_status[tuner_num].unicable_position_b;
5300 
5301  FUNCTION_FINISH(STB_DPGetUnicablePositionB);
5302 
5303  return(ret_val);
5304 }
5305 
5318 void STB_DPSetUnicableChannel(U8BIT path, U8BIT chan)
5319 {
5320  U8BIT tuner_num;
5321 
5322  FUNCTION_START(STB_DPSetUnicableChannel);
5323 
5324  ASSERT(path < num_paths);
5325 
5326  tuner_num = path_status[path].tuner_no;
5327 
5328  ASSERT(tuner_num < num_tuners);
5329 
5330  tuner_status[tuner_num].unicable_chan = chan;
5331 
5332  FUNCTION_FINISH(STB_DPSetUnicableChannel);
5333 }
5334 
5346 U8BIT STB_DPGetUnicableChannel(U8BIT path)
5347 {
5348  U8BIT tuner_num;
5349  U8BIT ret_val;
5350 
5351  FUNCTION_START(STB_DPGetUnicableChannel);
5352 
5353  ASSERT(path < num_paths);
5354 
5355  tuner_num = path_status[path].tuner_no;
5356 
5357  ASSERT(tuner_num < num_tuners);
5358 
5359  ret_val = tuner_status[tuner_num].unicable_chan;
5360 
5361  FUNCTION_FINISH(STB_DPGetUnicableChannel);
5362 
5363  return(ret_val);
5364 }
5365 
5378 void STB_DPSetUnicableFrequency(U8BIT path, U32BIT freq)
5379 {
5380  U8BIT tuner_num;
5381 
5382  FUNCTION_START(STB_DPSetUnicableFrequency);
5383 
5384  ASSERT(path < num_paths);
5385 
5386  tuner_num = path_status[path].tuner_no;
5387 
5388  ASSERT(tuner_num < num_tuners);
5389 
5390  tuner_status[tuner_num].unicable_if = freq;
5391 
5392  FUNCTION_FINISH(STB_DPSetUnicableFrequency);
5393 }
5394 
5406 U32BIT STB_DPGetUnicableFrequency(U8BIT path)
5407 {
5408  U8BIT tuner_num;
5409  U32BIT ret_val;
5410 
5411  FUNCTION_START(STB_DPGetUnicableFrequency);
5412 
5413  ASSERT(path < num_paths);
5414 
5415  tuner_num = path_status[path].tuner_no;
5416 
5417  ASSERT(tuner_num < num_tuners);
5418 
5419  ret_val = tuner_status[tuner_num].unicable_if;
5420 
5421  FUNCTION_FINISH(STB_DPGetUnicableFrequency);
5422 
5423  return(ret_val);
5424 }
5425 
5437 void STB_DPSetDishLimitE(U8BIT path)
5438 {
5439  U8BIT tuner_num;
5440  U8BIT dmsg_data[4];
5441  U16BIT pos;
5442 
5443  FUNCTION_START(STB_DPSetDishLimitE);
5444 
5445  ASSERT(path < num_paths);
5446 
5447  tuner_num = path_status[path].tuner_no;
5448 
5449  ASSERT(tuner_num < num_tuners);
5450 
5451  STB_TUNE_PRINT(("STB_DPSetDishLimitE(%d)", path));
5452 
5453  if (tuner_status[tuner_num].pulse_position == TRUE)
5454  {
5455  pos = STB_TuneGetPulsePosition(tuner_num);
5456  STB_TuneSetPulseLimitEast(tuner_num, pos);
5457  }
5458 
5459  if (tuner_status[tuner_num].diseqc_position == TRUE)
5460  {
5461  dmsg_data[0] = 0xe0;
5462  dmsg_data[1] = 0x31;
5463  dmsg_data[2] = 0x66;
5464  SendDISEQCMessage(tuner_num, dmsg_data, 3);
5465  }
5466 
5467  FUNCTION_FINISH(STB_DPSetDishLimitE);
5468 }
5469 
5481 void STB_DPSetDishLimitW(U8BIT path)
5482 {
5483  U8BIT tuner_num;
5484  U8BIT dmsg_data[4];
5485  U16BIT pos;
5486 
5487  FUNCTION_START(STB_DPSetDishLimitW);
5488 
5489  ASSERT(path < num_paths);
5490 
5491  tuner_num = path_status[path].tuner_no;
5492 
5493  ASSERT(tuner_num < num_tuners);
5494 
5495  STB_TUNE_PRINT(("STB_DPSetDishLimitW(%d)", path));
5496 
5497  if (tuner_status[tuner_num].pulse_position == TRUE)
5498  {
5499  pos = STB_TuneGetPulsePosition(tuner_num);
5500  STB_TuneSetPulseLimitWest(tuner_num, pos);
5501  }
5502 
5503  if (tuner_status[tuner_num].diseqc_position == TRUE)
5504  {
5505  dmsg_data[0] = 0xe0;
5506  dmsg_data[1] = 0x31;
5507  dmsg_data[2] = 0x67;
5508  SendDISEQCMessage(tuner_num, dmsg_data, 3);
5509  }
5510 
5511  FUNCTION_FINISH(STB_DPSetDishLimitW);
5512 }
5513 
5527 void STB_DPEnableDishLimits(U8BIT path, U16BIT ecount, U16BIT wcount)
5528 {
5529  U8BIT tuner_num;
5530  U8BIT dmsg_data[4];
5531 
5532  FUNCTION_START(STB_DPEnableDishLimits);
5533 
5534  ASSERT(path < num_paths);
5535 
5536  tuner_num = path_status[path].tuner_no;
5537 
5538  ASSERT(tuner_num < num_tuners);
5539 
5540  STB_TUNE_PRINT(("STB_DPEnableDishLimits(%d)", path));
5541 
5542  if (tuner_status[tuner_num].pulse_position == TRUE)
5543  {
5544  STB_TuneSetPulseLimitEast(tuner_num, ecount);
5545  STB_TuneSetPulseLimitWest(tuner_num, wcount);
5546  }
5547 
5548  if (tuner_status[tuner_num].diseqc_position == TRUE)
5549  {
5550  dmsg_data[0] = 0xe0;
5551  dmsg_data[1] = 0x31;
5552  dmsg_data[2] = 0x6a;
5553  dmsg_data[3] = 0x00;
5554  SendDISEQCMessage(tuner_num, dmsg_data, 4);
5555  }
5556 
5557  FUNCTION_FINISH(STB_DPEnableDishLimits);
5558 }
5559 
5571 void STB_DPDisableDishLimits(U8BIT path)
5572 {
5573  U8BIT tuner_num;
5574  U8BIT dmsg_data[4];
5575 
5576  FUNCTION_START(STB_DPDisableDishLimits);
5577 
5578  ASSERT(path < num_paths);
5579 
5580  tuner_num = path_status[path].tuner_no;
5581 
5582  ASSERT(tuner_num < num_tuners);
5583 
5584  STB_TUNE_PRINT(("STB_DPDisableDishLimits(%d)", path));
5585 
5586  if (tuner_status[tuner_num].pulse_position == TRUE)
5587  {
5588  STB_TuneSetPulseLimitEast(tuner_num, 1);
5589  STB_TuneSetPulseLimitWest(tuner_num, 9999);
5590  }
5591 
5592  if (tuner_status[tuner_num].diseqc_position == TRUE)
5593  {
5594  dmsg_data[0] = 0xe0;
5595  dmsg_data[1] = 0x31;
5596  dmsg_data[2] = 0x63;
5597  SendDISEQCMessage(tuner_num, dmsg_data, 3);
5598  }
5599 
5600  FUNCTION_FINISH(STB_DPDisableDishLimits);
5601 }
5602 
5615 void STB_DPStartDishMoveE(U8BIT path, U16BIT count)
5616 {
5617  U8BIT tuner_num;
5618  U8BIT dmsg_data[4];
5619  U16BIT pos;
5620 
5621  FUNCTION_START(STB_DPStartDishMoveE);
5622 
5623  ASSERT(path < num_paths);
5624 
5625  tuner_num = path_status[path].tuner_no;
5626 
5627  ASSERT(tuner_num < num_tuners);
5628 
5629  STB_TUNE_PRINT(("STB_DPStartDishMoveE(%d): count %d", path, count));
5630 
5631  tuner_status[tuner_num].actions |= (ACTION_TUNE | ACTION_DISH);
5632 
5633  if (tuner_status[tuner_num].pulse_position == TRUE)
5634  {
5635  pos = STB_TuneGetPulsePosition(tuner_num);
5636  if ((pos > count) && (count != 0))
5637  {
5638  pos -= count;
5639  }
5640  else
5641  {
5642  pos = 1;
5643  }
5644 
5645  STB_TuneChangePulsePosition(tuner_num, pos);
5646  }
5647 
5648  if (tuner_status[tuner_num].diseqc_position == TRUE)
5649  {
5650  if ((U8BIT)count < 0x80)
5651  {
5652  dmsg_data[0] = 0xe0;
5653  dmsg_data[1] = 0x31;
5654  dmsg_data[2] = 0x68;
5655  if (count == 0)
5656  {
5657  dmsg_data[3] = 0x00;
5658  }
5659  else
5660  {
5661  dmsg_data[3] = (0xff - (U8BIT)count + 1);
5662  }
5663 
5664  SendDISEQCMessage(tuner_num, dmsg_data, 4);
5665  }
5666  }
5667 
5668  FUNCTION_FINISH(STB_DPStartDishMoveE);
5669 }
5670 
5683 void STB_DPStartDishMoveW(U8BIT path, U16BIT count)
5684 {
5685  U8BIT tuner_num;
5686  U8BIT dmsg_data[4];
5687  U16BIT pos;
5688 
5689  FUNCTION_START(STB_DPStartDishMoveW);
5690 
5691  ASSERT(path < num_paths);
5692 
5693  tuner_num = path_status[path].tuner_no;
5694 
5695  ASSERT(tuner_num < num_tuners);
5696 
5697  STB_TUNE_PRINT(("STB_DPStartDishMoveW(%d): count %d", path, count));
5698 
5699  tuner_status[tuner_num].actions |= (ACTION_TUNE | ACTION_DISH);
5700 
5701  if (tuner_status[tuner_num].pulse_position == TRUE)
5702  {
5703  pos = STB_TuneGetPulsePosition(tuner_num);
5704  if ((pos < (9999 - count)) && (count != 0))
5705  {
5706  pos += count;
5707  }
5708  else
5709  {
5710  pos = 9999;
5711  }
5712  STB_TuneChangePulsePosition(tuner_num, pos);
5713  }
5714 
5715  if (tuner_status[tuner_num].diseqc_position == TRUE)
5716  {
5717  if ((U8BIT)count < 0x80)
5718  {
5719  dmsg_data[0] = 0xe0;
5720  dmsg_data[1] = 0x31;
5721  dmsg_data[2] = 0x69;
5722  if (count == 0)
5723  {
5724  dmsg_data[3] = 0x00;
5725  }
5726  else
5727  {
5728  dmsg_data[3] = (0xff - (U8BIT)count + 1);
5729  }
5730  SendDISEQCMessage(tuner_num, dmsg_data, 4);
5731  }
5732  }
5733 
5734  FUNCTION_FINISH(STB_DPStartDishMoveW);
5735 }
5736 
5748 void STB_DPStopDishMove(U8BIT path)
5749 {
5750  U8BIT tuner_num;
5751  U8BIT dmsg_data[4];
5752  U16BIT pos;
5753 
5754  FUNCTION_START(STB_DPStopDishMove);
5755 
5756  ASSERT(path < num_paths);
5757 
5758  tuner_num = path_status[path].tuner_no;
5759 
5760  ASSERT(tuner_num < num_tuners);
5761 
5762  STB_TUNE_PRINT(("STB_DPStopDishMove(%d)", path));
5763 
5764  if (tuner_status[tuner_num].pulse_position == TRUE)
5765  {
5766  pos = 0xffff;
5767  STB_TuneChangePulsePosition(tuner_num, pos);
5768  }
5769 
5770  if (tuner_status[tuner_num].diseqc_position == TRUE)
5771  {
5772  dmsg_data[0] = 0xe0;
5773  dmsg_data[1] = 0x31;
5774  dmsg_data[2] = 0x60;
5775  SendDISEQCMessage(tuner_num, dmsg_data, 3);
5776  }
5777 
5778  FUNCTION_FINISH(STB_DPStopDishMove);
5779 }
5780 
5792 void STB_DPCentreDishMove(U8BIT path)
5793 {
5794  U8BIT tuner_num;
5795  U8BIT dmsg_data[4];
5796 
5797  FUNCTION_START(STB_DPCentreDishMove);
5798 
5799  ASSERT(path < num_paths);
5800 
5801  tuner_num = path_status[path].tuner_no;
5802 
5803  ASSERT(tuner_num < num_tuners);
5804 
5805  STB_TUNE_PRINT(("STB_DPCentreDishMove(%d)", path));
5806 
5807  tuner_status[tuner_num].actions |= (ACTION_TUNE | ACTION_DISH);
5808 
5809  if (tuner_status[tuner_num].diseqc_position == TRUE)
5810  {
5811  dmsg_data[0] = 0xe0;
5812  dmsg_data[1] = 0x31;
5813  dmsg_data[2] = 0x6b;
5814  dmsg_data[3] = 0x00;
5815  SendDISEQCMessage(tuner_num, dmsg_data, 4);
5816  }
5817 
5818  FUNCTION_FINISH(STB_DPCentreDishMove);
5819 }
5820 
5833 void STB_DPStoreDishPosition(U8BIT path, U16BIT count)
5834 {
5835  U8BIT tuner_num;
5836  U8BIT dmsg_data[4];
5837 
5838  FUNCTION_START(STB_DPStoreDishPosition);
5839 
5840  ASSERT(path < num_paths);
5841 
5842  tuner_num = path_status[path].tuner_no;
5843 
5844  ASSERT(tuner_num < num_tuners);
5845 
5846  STB_TUNE_PRINT(("STB_DPStoreDishPosition(%d): count %d", path, count));
5847 
5848  if (tuner_status[tuner_num].pulse_position == TRUE)
5849  {
5850  if (count == 0)
5851  {
5852  count = STB_TuneGetPulsePosition(tuner_num);
5853  }
5854  STB_TuneAtPulsePosition(tuner_num, count);
5855  }
5856 
5857  if (tuner_status[tuner_num].diseqc_position == TRUE)
5858  {
5859  if (count != 0)
5860  {
5861  dmsg_data[0] = 0xe0;
5862  dmsg_data[1] = 0x31;
5863  dmsg_data[2] = 0x6a;
5864  dmsg_data[3] = (U8BIT)count;
5865  SendDISEQCMessage(tuner_num, dmsg_data, 4);
5866  }
5867  }
5868 
5869  tuner_status[tuner_num].dish_pos = count;
5870 
5871  FUNCTION_FINISH(STB_DPStoreDishPosition);
5872 }
5873 
5886 void STB_DPSetDishPosition(U8BIT path, U16BIT count)
5887 {
5888  U8BIT tuner_num;
5889 
5890  FUNCTION_START(STB_DPSetDishPosition);
5891 
5892  ASSERT(path < num_paths);
5893 
5894  tuner_num = path_status[path].tuner_no;
5895 
5896  ASSERT(tuner_num < num_tuners);
5897 
5898  STB_TUNE_PRINT(("STB_DPSetDishPosition(p%d): count %d", path, count));
5899  if (count != tuner_status[tuner_num].dish_pos)
5900  {
5901  // Zero is NOT a valid position to store a satellite. But allowed to be entered into the
5902  // decode path so that the move to position command is force to be sent for the current
5903  // service; hence allowed to set but is not flagged as to be actioned.
5904  tuner_status[tuner_num].dish_pos = count;
5905  if (count != 0)
5906  {
5907  tuner_status[tuner_num].actions |= (ACTION_TUNE | ACTION_DISH);
5908  }
5909  }
5910 
5911  FUNCTION_FINISH(STB_DPSetDishPosition);
5912 }
5913 
5925 U16BIT STB_DPGetDishPosition(U8BIT path)
5926 {
5927  U8BIT tuner_num;
5928  U16BIT ret_val;
5929 
5930  FUNCTION_START(STB_DPGetDishPosition);
5931 
5932  ASSERT(path < num_paths);
5933 
5934  tuner_num = path_status[path].tuner_no;
5935 
5936  ASSERT(tuner_num < num_tuners);
5937 
5938  ret_val = tuner_status[tuner_num].dish_pos;
5939 
5940  // return current position for pulse
5941  if (tuner_status[tuner_num].pulse_position == TRUE)
5942  {
5943  ret_val = STB_TuneGetPulsePosition(tuner_num);
5944  }
5945 
5946  FUNCTION_FINISH(STB_DPGetDishPosition);
5947 
5948  return(ret_val);
5949 }
5950 
5962 U16BIT STB_DPGetDishRequest(U8BIT path)
5963 {
5964  U8BIT tuner_num;
5965  U16BIT ret_val;
5966 
5967  FUNCTION_START(STB_DPGetDishRequest);
5968 
5969  ASSERT(path < num_paths);
5970 
5971  tuner_num = path_status[path].tuner_no;
5972 
5973  ASSERT(tuner_num < num_tuners);
5974 
5975  ret_val = tuner_status[tuner_num].dish_pos;
5976 
5977  FUNCTION_FINISH(STB_DPGetDishRequest);
5978 
5979  return(ret_val);
5980 }
5981 
5994 void STB_DPSetSkewPosition(U8BIT path, U16BIT count)
5995 {
5996  U8BIT tuner_num;
5997 
5998  FUNCTION_START(STB_DPSetSkewPosition);
5999 
6000  ASSERT(path < num_paths);
6001 
6002  tuner_num = path_status[path].tuner_no;
6003 
6004  ASSERT(tuner_num < num_tuners);
6005 
6006  STB_TUNE_PRINT(("STB_DPSetSkewPosition(p%d,t%d): count %d", path, tuner_num, count));
6007  if (count != tuner_status[tuner_num].skew_pos)
6008  {
6009  tuner_status[tuner_num].skew_pos = count;
6010  tuner_status[tuner_num].actions |= (ACTION_TUNE | ACTION_SKEW);
6011  }
6012 
6013  FUNCTION_FINISH(STB_DPSetSkewPosition);
6014 }
6015 
6027 U16BIT STB_DPGetSkewPosition(U8BIT path)
6028 {
6029  U8BIT tuner_num;
6030  U16BIT ret_val;
6031 
6032  FUNCTION_START(STB_DPGetSkewPosition);
6033 
6034  ASSERT(path < num_paths);
6035 
6036  tuner_num = path_status[path].tuner_no;
6037 
6038  ASSERT(tuner_num < num_tuners);
6039 
6040  ret_val = tuner_status[tuner_num].skew_pos;
6041 
6042  FUNCTION_FINISH(STB_DPGetSkewPosition);
6043 
6044  return(ret_val);
6045 }
6046 
6059 void STB_DPSetFrequency(U8BIT path, U32BIT freq)
6060 {
6061  U8BIT tuner_num;
6062 
6063  FUNCTION_START(STB_DPSetFrequency);
6064 
6065  ASSERT(path < num_paths);
6066 
6067  tuner_num = path_status[path].tuner_no;
6068 
6069  ASSERT(tuner_num < num_tuners);
6070 
6071  STB_TUNE_PRINT(("STB_DPSetFrequency(%d) : tuner %d freq %d", path, tuner_num, freq));
6072  if (freq != tuner_status[tuner_num].frequency)
6073  {
6074  tuner_status[tuner_num].frequency = freq;
6075  tuner_status[tuner_num].actions |= ACTION_TUNE;
6076  }
6077 
6078  FUNCTION_FINISH(STB_DPSetFrequency);
6079 }
6080 
6092 U32BIT STB_DPGetFrequency(U8BIT path)
6093 {
6094  U8BIT tuner_num;
6095  U32BIT ret_val;
6096 
6097  FUNCTION_START(STB_DPGetFrequency);
6098 
6099  ASSERT(path < num_paths);
6100 
6101  tuner_num = path_status[path].tuner_no;
6102 
6103  ASSERT(tuner_num < num_tuners);
6104 
6105  ret_val = tuner_status[tuner_num].frequency;
6106 
6107  FUNCTION_FINISH(STB_DPGetFrequency);
6108 
6109  return(ret_val);
6110 }
6111 
6124 void STB_DPSetPolarity(U8BIT path, E_STB_DP_POLARITY pol)
6125 {
6126  U8BIT tuner_num;
6127 
6128  FUNCTION_START(STB_DPSetPolarity);
6129 
6130  ASSERT(path < num_paths);
6131 
6132  tuner_num = path_status[path].tuner_no;
6133 
6134  ASSERT(tuner_num < num_tuners);
6135 
6136  STB_TUNE_PRINT(("STB_DPSetPolarity(%d) : tuner %d pol %d", path, tuner_num, pol));
6137  if (pol != tuner_status[tuner_num].polarity)
6138  {
6139  tuner_status[tuner_num].polarity = pol;
6140  tuner_status[tuner_num].actions |= ACTION_TUNE;
6141  }
6142 
6143  FUNCTION_FINISH(STB_DPSetPolarity);
6144 }
6145 
6157 E_STB_DP_POLARITY STB_DPGetPolarity(U8BIT path)
6158 {
6159  U8BIT tuner_num;
6160  E_STB_DP_POLARITY ret_val;
6161 
6162  FUNCTION_START(STB_DPGetPolarity);
6163 
6164  ASSERT(path < num_paths);
6165 
6166  tuner_num = path_status[path].tuner_no;
6167 
6168  ASSERT(tuner_num < num_tuners);
6169 
6170  ret_val = tuner_status[tuner_num].polarity;
6171 
6172  FUNCTION_FINISH(STB_DPGetPolarity);
6173 
6174  return(ret_val);
6175 }
6176 
6189 void STB_DPSetSymbolRate(U8BIT path, U16BIT sym)
6190 {
6191  U8BIT tuner_num;
6192 
6193  FUNCTION_START(STB_DPSetSymbolRate);
6194 
6195  ASSERT(path < num_paths);
6196 
6197  tuner_num = path_status[path].tuner_no;
6198 
6199  ASSERT(tuner_num < num_tuners);
6200 
6201  STB_TUNE_PRINT(("STB_DPSetSymbolRate(%d): tuner %d sym %d", path, tuner_num, sym));
6202  if (sym != tuner_status[tuner_num].sym_rate)
6203  {
6204  tuner_status[tuner_num].sym_rate = sym;
6205  tuner_status[tuner_num].actions |= ACTION_TUNE;
6206  }
6207 
6208  FUNCTION_FINISH(STB_DPSetSymbolRate);
6209 }
6210 
6222 U16BIT STB_DPGetSymbolRate(U8BIT path)
6223 {
6224  U8BIT tuner_num;
6225  U16BIT ret_val;
6226 
6227  FUNCTION_START(STB_DPGetSymbolRate);
6228 
6229  ASSERT(path < num_paths);
6230 
6231  tuner_num = path_status[path].tuner_no;
6232 
6233  ASSERT(tuner_num < num_tuners);
6234 
6235  ret_val = tuner_status[tuner_num].sym_rate;
6236 
6237  FUNCTION_FINISH(STB_DPGetSymbolRate);
6238 
6239  return(ret_val);
6240 }
6241 
6254 void STB_DPSetFEC(U8BIT path, E_STB_DP_FEC fec)
6255 {
6256  U8BIT tuner_num;
6257 
6258  FUNCTION_START(STB_DPSetFEC);
6259 
6260  ASSERT(path < num_paths);
6261 
6262  tuner_num = path_status[path].tuner_no;
6263 
6264  ASSERT(tuner_num < num_tuners);
6265 
6266  STB_TUNE_PRINT(("STB_DPSetFEC(%d) : tuner %d fec %d", path, tuner_num, fec));
6267  if (fec != tuner_status[tuner_num].fec)
6268  {
6269  tuner_status[tuner_num].fec = fec;
6270  tuner_status[tuner_num].actions |= ACTION_TUNE;
6271  }
6272 
6273  FUNCTION_FINISH(STB_DPSetFEC);
6274 }
6275 
6287 E_STB_DP_FEC STB_DPGetFEC(U8BIT path)
6288 {
6289  U8BIT tuner_num;
6290  E_STB_DP_FEC ret_val;
6291 
6292  FUNCTION_START(STB_DPGetFEC);
6293 
6294  ASSERT(path < num_paths);
6295 
6296  tuner_num = path_status[path].tuner_no;
6297 
6298  ASSERT(tuner_num < num_tuners);
6299 
6300  ret_val = tuner_status[tuner_num].fec;
6301 
6302  FUNCTION_FINISH(STB_DPGetFEC);
6303 
6304  return(ret_val);
6305 }
6306 
6307 /*!**************************************************************************
6308  * @brief Set whether the satellite should be tuned to DVB-S/S2 for the tuner in the given decode path
6309  * @param path - decode path
6310  * @param dvb_s2 - TRUE for DVB-S2
6311  ****************************************************************************/
6312 void STB_DPSetDVBS2(U8BIT path, BOOLEAN dvb_s2)
6313 {
6314  U8BIT tuner_num;
6315 
6316  FUNCTION_START(STB_DPSetDVBS2);
6317 
6318  tuner_num = path_status[path].tuner_no;
6319 
6320  ASSERT(tuner_num < num_tuners);
6321 
6322  STB_TUNE_PRINT(("STB_DPSetDVBS2(%u): tuner %u DVB-S2 %d", path, tuner_num, dvb_s2));
6323 
6324  if (dvb_s2 != tuner_status[tuner_num].dvb_s2)
6325  {
6326  tuner_status[tuner_num].dvb_s2 = dvb_s2;
6327  tuner_status[tuner_num].actions |= ACTION_TUNE;
6328  }
6329 
6330  FUNCTION_FINISH(STB_DPSetDVBS2);
6331 }
6332 
6333 /*!**************************************************************************
6334  * @brief Returns whether the sat tuner is tuned to DVB-S or DVB-S2
6335  * @param path - decode path
6336  * @return DVB-S/DVB-S2 for the decode path
6337  ****************************************************************************/
6338 BOOLEAN STB_DPGetDVBS2(U8BIT path)
6339 {
6340  U8BIT tuner_num;
6341  BOOLEAN retval;
6342 
6343  FUNCTION_START(STB_DPGetDVBS2);
6344 
6345  tuner_num = path_status[path].tuner_no;
6346  ASSERT(tuner_num < num_tuners);
6347  retval = tuner_status[tuner_num].dvb_s2;
6348 
6349  FUNCTION_FINISH(STB_DPGetDVBS2);
6350 
6351  return(retval);
6352 }
6353 
6354 /*!**************************************************************************
6355  * @brief Set the satellite modulation for the tuner in the given decode path
6356  * @param path - decode path
6357  * @param modulation - satellite modulation type
6358  ****************************************************************************/
6359 void STB_DPSetModulation(U8BIT path, E_STB_DP_MODULATION modulation)
6360 {
6361  U8BIT tuner_num;
6362 
6363  FUNCTION_START(STB_DPSetModulation);
6364 
6365  tuner_num = path_status[path].tuner_no;
6366 
6367  ASSERT(tuner_num < num_tuners);
6368 
6369  STB_TUNE_PRINT(("STB_DPSetModulation(%u): tuner %u modulation %d", path, tuner_num, modulation));
6370 
6371  if (modulation != tuner_status[tuner_num].modulation)
6372  {
6373  tuner_status[tuner_num].modulation = modulation;
6374  tuner_status[tuner_num].actions |= ACTION_TUNE;
6375  }
6376 
6377  FUNCTION_FINISH(STB_DPSetModulation);
6378 }
6379 
6380 /*!**************************************************************************
6381  * @brief Returns the satellite modulation type for the give decode path
6382  * @param path - decode path
6383  * @return Satellite modulation type for the decode path
6384  ****************************************************************************/
6385 E_STB_DP_MODULATION STB_DPGetModulation(U8BIT path)
6386 {
6387  U8BIT tuner_num;
6388  E_STB_DP_MODULATION retval;
6389 
6390  FUNCTION_START(STB_DPGetModulation);
6391 
6392  tuner_num = path_status[path].tuner_no;
6393  ASSERT(tuner_num < num_tuners);
6394  retval = tuner_status[tuner_num].modulation;
6395 
6396  FUNCTION_FINISH(STB_DPGetModulation);
6397 
6398  return(retval);
6399 }
6400 
6413 void STB_DPSetTerrMode(U8BIT path, E_STB_DP_TMODE mode)
6414 {
6415  U8BIT tuner_num;
6416 
6417  FUNCTION_START(STB_DPSetTerrMode);
6418 
6419  ASSERT(path < num_paths);
6420 
6421  tuner_num = path_status[path].tuner_no;
6422 
6423  ASSERT(tuner_num < num_tuners);
6424 
6425  STB_TUNE_PRINT(("STB_DPSetTerrMode(%d): mode %d", path, mode));
6426  if (mode != tuner_status[tuner_num].terr_mode)
6427  {
6428  tuner_status[tuner_num].terr_mode = mode;
6429  tuner_status[tuner_num].actions |= ACTION_TUNE;
6430  }
6431 
6432  FUNCTION_FINISH(STB_DPSetTerrMode);
6433 }
6434 
6446 E_STB_DP_TMODE STB_DPGetTerrMode(U8BIT path)
6447 {
6448  U8BIT tuner_num;
6449  E_STB_DP_TMODE ret_val;
6450 
6451  FUNCTION_START(STB_DPGetTerrMode);
6452 
6453  ASSERT(path < num_paths);
6454 
6455  tuner_num = path_status[path].tuner_no;
6456 
6457  ASSERT(tuner_num < num_tuners);
6458 
6459  ret_val = tuner_status[tuner_num].terr_mode;
6460 
6461  FUNCTION_FINISH(STB_DPGetTerrMode);
6462 
6463  return(ret_val);
6464 }
6465 
6478 void STB_DPSetTerrBandwidth(U8BIT path, E_STB_DP_TBWIDTH bwidth)
6479 {
6480  U8BIT tuner_num;
6481 
6482  FUNCTION_START(STB_DPSetTerrBandwidth);
6483 
6484  ASSERT(path < num_paths);
6485 
6486  tuner_num = path_status[path].tuner_no;
6487 
6488  ASSERT(tuner_num < num_tuners);
6489 
6490  STB_TUNE_PRINT(("STB_DPSetTerrBandwidth(%d): bwidth %d", path, bwidth));
6491  if (bwidth != tuner_status[tuner_num].terr_bwidth)
6492  {
6493  tuner_status[tuner_num].terr_bwidth = bwidth;
6494  tuner_status[tuner_num].actions |= ACTION_TUNE;
6495  }
6496 
6497  FUNCTION_FINISH(STB_DPSetTerrBandwidth);
6498 }
6499 
6511 E_STB_DP_TBWIDTH STB_DPGetTerrBandwidth(U8BIT path)
6512 {
6513  U8BIT tuner_num;
6514  E_STB_DP_TBWIDTH ret_val;
6515 
6516  FUNCTION_START(STB_DPGetTerrBandwidth);
6517 
6518  ASSERT(path < num_paths);
6519 
6520  tuner_num = path_status[path].tuner_no;
6521 
6522  ASSERT(tuner_num < num_tuners);
6523 
6524  ret_val = tuner_status[tuner_num].terr_bwidth;
6525 
6526  FUNCTION_FINISH(STB_DPGetTerrBandwidth);
6527 
6528  return(ret_val);
6529 }
6530 
6543 void STB_DPSetTerrFreqOff(U8BIT path, S8BIT offset)
6544 {
6545  U8BIT tuner_num;
6546 
6547  FUNCTION_START(STB_DPSetTerrFreqOff);
6548 
6549  ASSERT(path < num_paths);
6550 
6551  tuner_num = path_status[path].tuner_no;
6552 
6553  ASSERT(tuner_num < num_tuners);
6554 
6555  STB_TUNE_PRINT(("STB_DPSetTerrFreqOff(%d): offset %d", path, offset));
6556  if (offset != tuner_status[tuner_num].freq_offset)
6557  {
6558  tuner_status[tuner_num].freq_offset = offset;
6559  tuner_status[tuner_num].actions |= ACTION_TUNE;
6560  }
6561 
6562  FUNCTION_FINISH(STB_DPSetTerrFreqOff);
6563 }
6564 
6576 S8BIT STB_DPGetTerrFreqOff(U8BIT path)
6577 {
6578  U8BIT tuner_num;
6579  S8BIT ret_val;
6580 
6581  FUNCTION_START(STB_DPGetTerrFreqOff);
6582 
6583  ASSERT(path < num_paths);
6584 
6585  tuner_num = path_status[path].tuner_no;
6586 
6587  ASSERT(tuner_num < num_tuners);
6588 
6589  ret_val = tuner_status[tuner_num].freq_offset;
6590 
6591  FUNCTION_FINISH(STB_DPGetTerrFreqOff);
6592 
6593  return(ret_val);
6594 }
6595 
6608 void STB_DPSetTerrType(U8BIT path, E_STB_DP_TTYPE type)
6609 {
6610  U8BIT tuner_num;
6611 
6612  FUNCTION_START(STB_DPSetTerrType);
6613 
6614  ASSERT(path < num_paths);
6615 
6616  tuner_num = path_status[path].tuner_no;
6617 
6618  ASSERT(tuner_num < num_tuners);
6619 
6620  STB_TUNE_PRINT(("STB_DPSetTerrType(%d): DVB-%s", path, ((type == TERR_TYPE_DVBT) ? "T" :
6621  ((type == TERR_TYPE_DVBT2) ? "T2" : "unknown"))));
6622 
6623  if (type != tuner_status[tuner_num].terr_type)
6624  {
6625  tuner_status[tuner_num].terr_type = type;
6626  tuner_status[tuner_num].actions |= ACTION_TUNE;
6627  }
6628 
6629  FUNCTION_FINISH(STB_DPSetTerrType);
6630 }
6631 
6643 E_STB_DP_TTYPE STB_DPGetTerrType(U8BIT path)
6644 {
6645  U8BIT tuner_num;
6646  E_STB_DP_TTYPE ret_val;
6647 
6648  FUNCTION_START(STB_DPGetTerrType);
6649 
6650  ASSERT(path < num_paths);
6651 
6652  tuner_num = path_status[path].tuner_no;
6653 
6654  ASSERT(tuner_num < num_tuners);
6655 
6656  ret_val = tuner_status[tuner_num].terr_type;
6657 
6658  FUNCTION_FINISH(STB_DPGetTerrType);
6659 
6660  return(ret_val);
6661 }
6662 
6675 void STB_DPSetTerrPLP(U8BIT path, U8BIT plp_id)
6676 {
6677  U8BIT tuner_num;
6678 
6679  FUNCTION_START(STB_DPSetTerrPLP);
6680 
6681  ASSERT(path < num_paths);
6682 
6683  tuner_num = path_status[path].tuner_no;
6684 
6685  ASSERT(tuner_num < num_tuners);
6686 
6687  STB_TUNE_PRINT(("STB_DPSetTerrPLP(%d, %u)", path, plp_id));
6688 
6689  if (plp_id != tuner_status[tuner_num].plp_id)
6690  {
6691  tuner_status[tuner_num].plp_id = plp_id;
6692  tuner_status[tuner_num].actions |= ACTION_TUNE;
6693  }
6694 
6695  FUNCTION_FINISH(STB_DPSetTerrPLP);
6696 }
6697 
6709 U8BIT STB_DPGetTerrPLP(U8BIT path)
6710 {
6711  U8BIT tuner_num;
6712  U8BIT ret_val;
6713 
6714  FUNCTION_START(STB_DPGetTerrPLP);
6715 
6716  ASSERT(path < num_paths);
6717 
6718  tuner_num = path_status[path].tuner_no;
6719 
6720  ASSERT(tuner_num < num_tuners);
6721 
6722  ret_val = tuner_status[tuner_num].plp_id;
6723 
6724  STB_TUNE_PRINT(("STB_DPGetTerrPLP(%d): %u", path, tuner_status[tuner_num].plp_id));
6725 
6726  FUNCTION_FINISH(STB_DPGetTerrPLP);
6727 
6728  return(ret_val);
6729 }
6730 
6743 void STB_DPSetCableMode(U8BIT path, E_STB_DP_CMODE mode)
6744 {
6745  U8BIT tuner_num;
6746 
6747  FUNCTION_START(STB_DPSetCableMode);
6748 
6749  ASSERT(path < num_paths);
6750 
6751  tuner_num = path_status[path].tuner_no;
6752 
6753  ASSERT(tuner_num < num_tuners);
6754 
6755  STB_TUNE_PRINT(("STB_DPSetCableMode(%d): mode %d", path, mode));
6756  if (mode != tuner_status[tuner_num].cable_mode)
6757  {
6758  tuner_status[tuner_num].cable_mode = mode;
6759  tuner_status[tuner_num].actions |= ACTION_TUNE;
6760  }
6761 
6762  FUNCTION_FINISH(STB_DPSetCableMode);
6763 }
6764 
6776 E_STB_DP_CMODE STB_DPGetCableMode(U8BIT path)
6777 {
6778  U8BIT tuner_num;
6779  E_STB_DP_CMODE ret_val;
6780 
6781  FUNCTION_START(STB_DPGetCableMode);
6782 
6783  ASSERT(path < num_paths);
6784 
6785  tuner_num = path_status[path].tuner_no;
6786 
6787  ASSERT(tuner_num < num_tuners);
6788 
6789  ret_val = tuner_status[tuner_num].cable_mode;
6790 
6791  FUNCTION_FINISH(STB_DPGetCableMode);
6792 
6793  return(ret_val);
6794 }
6795 
6808 void STB_DPSetAnalogVideoType(U8BIT path, E_STB_DP_ANALOG_VIDEO_TYPE vtype)
6809 {
6810  U8BIT tuner_num;
6811 
6812  FUNCTION_START(STB_DPSetAnalogVideoType);
6813 
6814  ASSERT(path < num_paths);
6815 
6816  tuner_num = path_status[path].tuner_no;
6817 
6818  ASSERT(tuner_num < num_tuners);
6819 
6820  STB_TUNE_PRINT(("STB_DPSetAnalogVideoType(%d): type %d", path, vtype));
6821  if (vtype != tuner_status[tuner_num].anlg_vtype)
6822  {
6823  tuner_status[tuner_num].anlg_vtype = vtype;
6824  tuner_status[tuner_num].actions |= ACTION_TUNE;
6825  }
6826 
6827  FUNCTION_FINISH(STB_DPSetAnalogVideoType);
6828 }
6829 
6841 E_STB_DP_ANALOG_VIDEO_TYPE STB_DPGetAnalogVideoType(U8BIT path)
6842 {
6843  U8BIT tuner_num;
6844  E_STB_DP_ANALOG_VIDEO_TYPE ret_val;
6845 
6846  FUNCTION_START(STB_DPGetAnalogVideoType);
6847 
6848  ASSERT(path < num_paths);
6849 
6850  tuner_num = path_status[path].tuner_no;
6851 
6852  ASSERT(tuner_num < num_tuners);
6853 
6854  ret_val = tuner_status[tuner_num].anlg_vtype;
6855 
6856  FUNCTION_FINISH(STB_DPGetAnalogVideoType);
6857 
6858  return(ret_val);
6859 }
6860 
6873 void STB_DPSetAnalogFreqOff(U8BIT path, S8BIT offset)
6874 {
6875  U8BIT tuner_num;
6876 
6877  FUNCTION_START(STB_DPSetAnalogFreqOff);
6878 
6879  ASSERT(path < num_paths);
6880 
6881  tuner_num = path_status[path].tuner_no;
6882 
6883  ASSERT(tuner_num < num_tuners);
6884 
6885  STB_TUNE_PRINT(("STB_DPSetAnalogFreqOff(%d): offset %d", path, offset));
6886  if (offset != tuner_status[tuner_num].freq_offset)
6887  {
6888  tuner_status[tuner_num].freq_offset = offset;
6889  tuner_status[tuner_num].actions |= ACTION_TUNE;
6890  }
6891 
6892  FUNCTION_FINISH(STB_DPSetAnalogFreqOff);
6893 }
6894 
6906 S8BIT STB_DPGetAnalogFreqOff(U8BIT path)
6907 {
6908  U8BIT tuner_num;
6909  S8BIT ret_val;
6910 
6911  FUNCTION_START(STB_DPGetAnalogFreqOff);
6912 
6913  ASSERT(path < num_paths);
6914 
6915  tuner_num = path_status[path].tuner_no;
6916 
6917  ASSERT(tuner_num < num_tuners);
6918 
6919  ret_val = tuner_status[tuner_num].freq_offset;
6920 
6921  FUNCTION_FINISH(STB_DPGetAnalogFreqOff);
6922 
6923  return(ret_val);
6924 }
6925 
6933 void STB_DPSetAdditionalFrequencies(U8BIT path, U8BIT num_freqs, U32BIT *frequencies)
6934 {
6935  U8BIT tuner_num;
6936 
6937  FUNCTION_START(STB_DPSetAdditionalFrequencies);
6938 
6939  if (path < num_paths)
6940  {
6941  tuner_num = path_status[path].tuner_no;
6942  if (tuner_num < num_tuners)
6943  {
6944  if (tuner_status[tuner_num].additional_frequencies != NULL)
6945  {
6946  STB_FreeMemory(tuner_status[tuner_num].additional_frequencies);
6947 
6948  tuner_status[tuner_num].additional_frequencies = NULL;
6949  tuner_status[tuner_num].num_additional_frequencies = 0;
6950  }
6951 
6952  if ((num_freqs != 0) && (frequencies != NULL))
6953  {
6954  tuner_status[tuner_num].additional_frequencies = STB_GetMemory(num_freqs * sizeof(U32BIT));
6955  if (tuner_status[tuner_num].additional_frequencies != NULL)
6956  {
6957  memcpy(tuner_status[tuner_num].additional_frequencies, frequencies, num_freqs * sizeof(U32BIT));
6958  tuner_status[tuner_num].num_additional_frequencies = num_freqs;
6959  }
6960  }
6961  }
6962  }
6963 
6964  FUNCTION_FINISH(STB_DPSetAdditionalFrequencies);
6965 }
6966 
6973 BOOLEAN STB_DPTryAdditionalFrequency(U8BIT tuner_num)
6974 {
6975  BOOLEAN retval;
6976 
6977  FUNCTION_START(STB_DPTryAdditionalFrequency);
6978 
6979  retval = FALSE;
6980 
6981  if (tuner_num < num_tuners)
6982  {
6983  if ((tuner_status[tuner_num].additional_frequencies != NULL) &&
6984  (tuner_status[tuner_num].num_additional_frequencies != 0))
6985  {
6986  /* Set the next frequency to be tried.
6987  * We work backwards through the array so the count will be zero when
6988  * all frequencies have been used */
6989  tuner_status[tuner_num].num_additional_frequencies--;
6990  tuner_status[tuner_num].frequency = tuner_status[tuner_num].additional_frequencies[tuner_status[tuner_num].num_additional_frequencies];
6991  tuner_status[tuner_num].actions |= ACTION_TUNE;
6992  retval = TRUE;
6993  }
6994  }
6995 
6996  FUNCTION_FINISH(STB_DPTryAdditionalFrequency);
6997 
6998  return(retval);
6999 }
7000 
7013 void STB_DPSetPCRPID(U8BIT path, U16BIT pid)
7014 {
7015  U8BIT demux_num;
7016 
7017  FUNCTION_START(STB_DPSetPCRPID);
7018 
7019  ASSERT(path < num_paths);
7020 
7021  demux_num = path_status[path].demux_no;
7022 
7023  ASSERT(demux_num < num_demuxes);
7024 
7025  STB_DP_PRINT(("STB_DPSetPCRPID(%d): pid %x", path, pid));
7026 
7027  if (pid != demux_status[demux_num].pcr_pid)
7028  {
7029  demux_status[demux_num].pcr_pid = pid;
7030  demux_status[demux_num].actions |= (ACTION_VIDEO | ACTION_AUDIO);
7031  }
7032 
7033  FUNCTION_FINISH(STB_DPSetPCRPID);
7034 }
7035 
7047 U16BIT STB_DPGetPCRPID(U8BIT path)
7048 {
7049  U8BIT demux_num;
7050  U16BIT ret_val;
7051 
7052  FUNCTION_START(STB_DPGetPCRPID);
7053 
7054  ASSERT(path < num_paths);
7055 
7056  demux_num = path_status[path].demux_no;
7057 
7058  ASSERT(demux_num < num_demuxes);
7059 
7060  ret_val = demux_status[demux_num].pcr_pid;
7061 
7062  FUNCTION_FINISH(STB_DPGetPCRPID);
7063 
7064  return(ret_val);
7065 }
7066 
7079 void STB_DPSetVideoPID(U8BIT path, U16BIT pid)
7080 {
7081  U8BIT demux_num;
7082 
7083  FUNCTION_START(STB_DPSetVideoPID);
7084 
7085  ASSERT(path < num_paths);
7086 
7087  demux_num = path_status[path].demux_no;
7088 
7089  ASSERT(demux_num < num_demuxes);
7090 
7091  STB_DP_PRINT(("STB_DPSetVideoPID(%d): pid %u", path, pid));
7092 
7093  if (pid != demux_status[demux_num].video_pid)
7094  {
7095  demux_status[demux_num].video_pid = pid;
7096  demux_status[demux_num].actions |= ACTION_VIDEO;
7097  }
7098 
7099  FUNCTION_FINISH(STB_DPSetVideoPID);
7100 }
7101 
7113 U16BIT STB_DPGetVideoPID(U8BIT path)
7114 {
7115  U8BIT demux_num;
7116  U16BIT ret_val;
7117 
7118  FUNCTION_START(STB_DPGetVideoPID);
7119 
7120  ASSERT(path < num_paths);
7121 
7122  demux_num = path_status[path].demux_no;
7123 
7124  ASSERT(demux_num < num_demuxes);
7125 
7126  ret_val = demux_status[demux_num].video_pid;
7127 
7128  FUNCTION_FINISH(STB_DPGetVideoPID);
7129 
7130  return(ret_val);
7131 }
7132 
7145 void STB_DPSetAudioPID(U8BIT path, U16BIT pid)
7146 {
7147  U8BIT demux_num;
7148 
7149  FUNCTION_START(STB_DPSetAudioPID);
7150 
7151  ASSERT(path < num_paths);
7152 
7153  demux_num = path_status[path].demux_no;
7154 
7155  ASSERT(demux_num < num_demuxes);
7156 
7157  STB_DP_PRINT(("STB_DPSetAudioPID(%d): pid %u", path, pid));
7158 
7159  if (pid != demux_status[demux_num].audio_pid)
7160  {
7161  demux_status[demux_num].audio_pid = pid;
7162  demux_status[demux_num].actions |= ACTION_AUDIO;
7163  }
7164 
7165  FUNCTION_FINISH(STB_DPSetAudioPID);
7166 }
7167 
7179 U16BIT STB_DPGetAudioPID(U8BIT path)
7180 {
7181  U8BIT demux_num;
7182  U16BIT ret_val;
7183 
7184  FUNCTION_START(STB_DPGetAudioPID);
7185 
7186  ASSERT(path < num_paths);
7187 
7188  demux_num = path_status[path].demux_no;
7189 
7190  ASSERT(demux_num < num_demuxes);
7191 
7192  ret_val = demux_status[demux_num].audio_pid;
7193 
7194  FUNCTION_FINISH(STB_DPGetAudioPID);
7195 
7196  return(ret_val);
7197 }
7198 
7211 void STB_DPSetADPID(U8BIT path, U16BIT pid)
7212 {
7213  U8BIT demux_num;
7214  U8BIT decoder_num;
7215 
7216  FUNCTION_START(STB_DPSetADPID);
7217 
7218  ASSERT(path < num_paths);
7219 
7220  demux_num = path_status[path].demux_no;
7221  decoder_num = path_status[path].ad_decoder_no;
7222 
7223  ASSERT(demux_num < num_demuxes);
7224 
7225  STB_DP_PRINT(("STB_DPSetADPID(%d): pid %u", path, pid));
7226 
7227  if (pid == 0)
7228  {
7229  ad_decoder_status[decoder_num].ad_status &= ~AD_PID_PRESENT;
7230  }
7231  else
7232  {
7233  ad_decoder_status[decoder_num].ad_status |= AD_PID_PRESENT;
7234  }
7235 
7236  if (pid != demux_status[demux_num].AD_pid)
7237  {
7238  demux_status[demux_num].AD_pid = pid;
7239  demux_status[demux_num].actions |= ACTION_AD;
7240  }
7241 
7242  FUNCTION_FINISH(STB_DPSetADPID);
7243 }
7244 
7256 U16BIT STB_DPGetADPID(U8BIT path)
7257 {
7258  U8BIT demux_num;
7259  U16BIT ret_val;
7260 
7261  FUNCTION_START(STB_DPGetADPID);
7262 
7263  ASSERT(path < num_paths);
7264 
7265  demux_num = path_status[path].demux_no;
7266 
7267  ASSERT(demux_num < num_demuxes);
7268 
7269  ret_val = demux_status[demux_num].AD_pid;
7270 
7271  FUNCTION_FINISH(STB_DPGetADPID);
7272 
7273  return(ret_val);
7274 }
7275 
7288 void STB_DPSetTextPID(U8BIT path, U16BIT pid)
7289 {
7290  U8BIT demux_num;
7291 
7292  FUNCTION_START(STB_DPSetTextPID);
7293 
7294  ASSERT(path < num_paths);
7295 
7296  if ((demux_num = path_status[path].demux_no) != INVALID_RES_ID)
7297  {
7298  STB_DP_PRINT(("STB_DPSetTextPID(%d): pid %u", path, pid));
7299 
7300  if (pid != demux_status[demux_num].text_pid)
7301  {
7302  demux_status[demux_num].text_pid = pid;
7303 
7304  STB_DMXChangeTextPID(demux_num, pid);
7305  /* demux_status[demux_num].actions |= (ACTION_VIDEO | ACTION_AUDIO);*/
7306  }
7307  }
7308 
7309  FUNCTION_FINISH(STB_DPSetTextPID);
7310 }
7311 
7323 U16BIT STB_DPGetTextPID(U8BIT path)
7324 {
7325  U8BIT demux_num;
7326  U16BIT ret_val;
7327 
7328  FUNCTION_START(STB_DPGetTextPID);
7329 
7330  ASSERT(path < num_paths);
7331 
7332  demux_num = path_status[path].demux_no;
7333 
7334  ASSERT(demux_num < num_demuxes);
7335 
7336  ret_val = demux_status[demux_num].text_pid;
7337 
7338  FUNCTION_FINISH(STB_DPGetTextPID);
7339 
7340  return(ret_val);
7341 }
7342 
7355 void STB_DPSetDataPID(U8BIT path, U16BIT pid)
7356 {
7357  U8BIT demux_num;
7358 
7359  FUNCTION_START(STB_DPSetDataPID);
7360 
7361  ASSERT(path < num_paths);
7362 
7363  demux_num = path_status[path].demux_no;
7364 
7365  ASSERT(demux_num < num_demuxes);
7366 
7367  STB_DP_PRINT(("STB_DPSetDataPID(%d): pid %u", path, pid));
7368 
7369  if (pid != demux_status[demux_num].data_pid)
7370  {
7371  demux_status[demux_num].data_pid = pid;
7372  demux_status[demux_num].actions |= (ACTION_VIDEO | ACTION_AUDIO);
7373  }
7374 
7375  FUNCTION_FINISH(STB_DPSetDataPID);
7376 }
7377 
7389 U16BIT STB_DPGetDataPID(U8BIT path)
7390 {
7391  U8BIT demux_num;
7392  U16BIT ret_val;
7393 
7394  FUNCTION_START(STB_DPGetDataPID);
7395 
7396  ASSERT(path < num_paths);
7397 
7398  demux_num = path_status[path].demux_no;
7399 
7400  ASSERT(demux_num < num_demuxes);
7401 
7402  ret_val = demux_status[demux_num].data_pid;
7403 
7404  FUNCTION_FINISH(STB_DPGetDataPID);
7405 
7406  return(ret_val);
7407 }
7408 
7409 /*!**************************************************************************
7410  * @brief
7411  * @param
7412  * @return
7413  ****************************************************************************/
7414 void STB_DPSetDecodePIDs(U8BIT path, U16BIT pcr_pid, U16BIT video_pid, U16BIT audio_pid,
7415  U16BIT text_pid, U16BIT data_pid, U16BIT AD_pid)
7416 {
7417  U8BIT demux_num;
7418 
7419  FUNCTION_START(STB_DPSetDecodePIDs);
7420 
7421  ASSERT(path < num_paths);
7422 
7423  demux_num = path_status[path].demux_no;
7424 
7425  ASSERT(demux_num < num_demuxes);
7426 
7427  STB_DP_PRINT(("STB_DPSetDecodePIDs(%u): PIDs = %u/%u/%u/%u/%u/%u", path, pcr_pid, video_pid,
7428  audio_pid, text_pid, data_pid, AD_pid));
7429 
7430  demux_status[demux_num].pcr_pid = pcr_pid;
7431  demux_status[demux_num].video_pid = video_pid;
7432  demux_status[demux_num].audio_pid = audio_pid;
7433  demux_status[demux_num].AD_pid = AD_pid;
7434  demux_status[demux_num].text_pid = text_pid;
7435  demux_status[demux_num].data_pid = data_pid;
7436 
7437  STB_DMXChangeDecodePIDs(demux_num, pcr_pid, video_pid, audio_pid, text_pid, data_pid, AD_pid);
7438 
7439  FUNCTION_FINISH(STB_DPSetDecodePIDs);
7440 }
7441 
7454 void STB_DPSetADMode(U8BIT path, E_STB_DP_AUDIO_MODE mode)
7455 {
7456  U8BIT decoder_num;
7457 
7458  FUNCTION_START(STB_DPSetADMode);
7459 
7460  ASSERT(path < num_paths);
7461 
7462  decoder_num = path_status[path].ad_decoder_no;
7463 
7464  ASSERT(decoder_num < num_audio_decoders);
7465 
7466  STB_DP_PRINT(("STB_DPSetADMode(%d): mode %d", path, mode));
7467 
7468  if (mode != ad_decoder_status[decoder_num].audio_mode)
7469  {
7470  ad_decoder_status[decoder_num].audio_mode = mode;
7471  }
7472 
7473  FUNCTION_FINISH(STB_DPSetADMode);
7474 }
7475 
7487 E_STB_DP_AUDIO_MODE STB_DPGetADMode(U8BIT path)
7488 {
7489  U8BIT decoder_num;
7490  E_STB_DP_AUDIO_MODE ret_val;
7491 
7492  FUNCTION_START(STB_DPGetADMode);
7493 
7494  ASSERT(path < num_paths);
7495 
7496  decoder_num = path_status[path].ad_decoder_no;
7497 
7498  ASSERT(decoder_num < num_audio_decoders);
7499 
7500  ret_val = ad_decoder_status[decoder_num].audio_mode;
7501 
7502  FUNCTION_FINISH(STB_DPGetADMode);
7503 
7504  return(ret_val);
7505 }
7506 
7519 void STB_DPSetAudioMode(U8BIT path, E_STB_DP_AUDIO_MODE mode)
7520 {
7521  U8BIT decoder_num;
7522 
7523  FUNCTION_START(STB_DPSetAudioMode);
7524 
7525  ASSERT(path < num_paths);
7526 
7527  decoder_num = path_status[path].audio_decoder_no;
7528 
7529  ASSERT(decoder_num < num_audio_decoders);
7530 
7531  STB_DP_PRINT(("STB_DPSetAudioMode(%d): mode %d", path, mode));
7532 
7533  if (mode != audio_decoder_status[decoder_num].audio_mode)
7534  {
7535  audio_decoder_status[decoder_num].audio_mode = mode;
7536  }
7537 
7538  FUNCTION_FINISH(STB_DPSetAudioMode);
7539 }
7540 
7552 E_STB_DP_AUDIO_MODE STB_DPGetAudioMode(U8BIT path)
7553 {
7554  U8BIT decoder_num;
7555  E_STB_DP_AUDIO_MODE ret_val;
7556 
7557  FUNCTION_START(STB_DPGetAudioMode);
7558 
7559  ASSERT(path < num_paths);
7560 
7561  decoder_num = path_status[path].audio_decoder_no;
7562 
7563  ASSERT(decoder_num < num_audio_decoders);
7564 
7565  ret_val = audio_decoder_status[decoder_num].audio_mode;
7566 
7567  FUNCTION_FINISH(STB_DPGetAudioMode);
7568 
7569  return(ret_val);
7570 }
7571 
7584 void STB_DPSetLockMode(U8BIT path, BOOLEAN mode)
7585 {
7586  FUNCTION_START(STB_DPSetLockMode);
7587 
7588  ASSERT(path < num_paths);
7589 
7590  STB_DP_PRINT(("STB_DPSetLockMode(%d): mode %d", path, mode));
7591 
7592  if (mode != path_status[path].lock_mode)
7593  {
7594  path_status[path].lock_mode = mode;
7595  }
7596 
7597  FUNCTION_FINISH(STB_DPSetLockMode);
7598 }
7599 
7611 BOOLEAN STB_DPGetLockMode(U8BIT path)
7612 {
7613  BOOLEAN ret_val;
7614 
7615  FUNCTION_START(STB_DPGetLockMode);
7616 
7617  ASSERT(path < num_paths);
7618 
7619  ret_val = path_status[path].lock_mode;
7620 
7621  FUNCTION_FINISH(STB_DPGetLockMode);
7622 
7623  return(ret_val);
7624 }
7625 
7638 BOOLEAN STB_DPSetVideoCodec(U8BIT path, E_STB_DP_VIDEO_CODEC codec)
7639 {
7640  U8BIT demux_num;
7641  U8BIT decoder_num;
7642  E_STB_AV_VIDEO_CODEC av_codec;
7643  BOOLEAN ret_val;
7644 
7645  FUNCTION_START(STB_DPSetVideoCodec);
7646 
7647  ASSERT(path < num_paths);
7648 
7649  demux_num = path_status[path].demux_no;
7650  decoder_num = path_status[path].video_decoder_no;
7651 
7652  ASSERT(demux_num < num_demuxes);
7653 
7654  demux_status[demux_num].video_codec = codec;
7655  ret_val = TRUE;
7656 
7657  if (decoder_num < num_video_decoders)
7658  {
7659  switch (codec)
7660  {
7661  case VIDEO_CODEC_MPEG1:
7662  av_codec = AV_VIDEO_CODEC_MPEG1;
7663  break;
7664 
7665  case VIDEO_CODEC_MPEG2:
7666  av_codec = AV_VIDEO_CODEC_MPEG2;
7667  break;
7668 
7669  case VIDEO_CODEC_H264:
7670  av_codec = AV_VIDEO_CODEC_H264;
7671  break;
7672 
7673  case VIDEO_CODEC_H265:
7674  av_codec = AV_VIDEO_CODEC_H265;
7675  break;
7676 
7677  default:
7678  av_codec = AV_VIDEO_CODEC_AUTO;
7679  break;
7680  }
7681 
7682  ret_val = STB_AVSetVideoCodec(decoder_num, av_codec);
7683  if (ret_val)
7684  {
7685  video_decoder_status[decoder_num].codec = codec;
7686  }
7687  }
7688 
7689  FUNCTION_FINISH(STB_DPSetVideoCodec);
7690 
7691  return ret_val;
7692 }
7693 
7705 E_STB_DP_VIDEO_CODEC STB_DPGetVideoCodec(U8BIT path)
7706 {
7707  U8BIT demux_num;
7708  U8BIT decoder_num;
7709  E_STB_DP_VIDEO_CODEC ret_val;
7710 
7711  FUNCTION_START(STB_DPGetVideoCodec);
7712 
7713  ASSERT(path < num_paths);
7714 
7715  decoder_num = path_status[path].video_decoder_no;
7716 
7717  if (decoder_num < num_video_decoders)
7718  {
7719  ret_val = video_decoder_status[decoder_num].codec;
7720  }
7721  else
7722  {
7723  demux_num = path_status[path].demux_no;
7724  ASSERT(demux_num < num_demuxes);
7725  ret_val = demux_status[demux_num].video_codec;
7726  }
7727 
7728  FUNCTION_FINISH(STB_DPGetVideoCodec);
7729 
7730  return(ret_val);
7731 }
7732 
7745 BOOLEAN STB_DPSetADCodec(U8BIT path, E_STB_DP_AUDIO_CODEC codec)
7746 {
7747  U8BIT demux_num;
7748  U8BIT decoder_num;
7749  E_STB_AV_AUDIO_CODEC av_codec;
7750  BOOLEAN ret_val;
7751 
7752  FUNCTION_START(STB_DPSetADCodec);
7753 
7754  ASSERT(path < num_paths);
7755 
7756  demux_num = path_status[path].demux_no;
7757  decoder_num = path_status[path].ad_decoder_no;
7758 
7759  ASSERT(demux_num < num_demuxes);
7760 
7761  demux_status[demux_num].ad_codec = codec;
7762  ret_val = TRUE;
7763 
7764  if (decoder_num < num_audio_decoders)
7765  {
7766  switch (codec)
7767  {
7768  case AUDIO_CODEC_MP2:
7769  av_codec = AV_AUDIO_CODEC_MP2;
7770  break;
7771 
7772  case AUDIO_CODEC_AC3:
7773  av_codec = AV_AUDIO_CODEC_AC3;
7774  break;
7775 
7776  case AUDIO_CODEC_EAC3:
7777  av_codec = AV_AUDIO_CODEC_EAC3;
7778  break;
7779 
7780  case AUDIO_CODEC_AAC:
7781  av_codec = AV_AUDIO_CODEC_AAC;
7782  break;
7783 
7784  case AUDIO_CODEC_HEAAC:
7785  av_codec = AV_AUDIO_CODEC_HEAAC;
7786  break;
7787 
7788  default:
7789  av_codec = AV_AUDIO_CODEC_MP2;
7790  break;
7791  }
7792 
7793  ret_val = STB_AVSetADCodec(decoder_num, av_codec);
7794  if (ret_val)
7795  {
7796  ad_decoder_status[decoder_num].codec = codec;
7797  }
7798  }
7799 
7800  FUNCTION_FINISH(STB_DPSetADCodec);
7801 
7802  return ret_val;
7803 }
7804 
7816 E_STB_DP_AUDIO_CODEC STB_DPGetADCodec(U8BIT path)
7817 {
7818  U8BIT demux_num;
7819  E_STB_DP_AUDIO_CODEC ret_val;
7820 
7821  FUNCTION_START(STB_DPGetADCodec);
7822 
7823  ASSERT(path < num_paths);
7824 
7825  demux_num = path_status[path].demux_no;
7826  ASSERT(demux_num < num_demuxes);
7827  ret_val = demux_status[demux_num].ad_codec;
7828 
7829  FUNCTION_FINISH(STB_DPGetADCodec);
7830 
7831  return(ret_val);
7832 }
7833 
7846 BOOLEAN STB_DPSetAudioCodec(U8BIT path, E_STB_DP_AUDIO_CODEC codec)
7847 {
7848  U8BIT demux_num;
7849  U8BIT decoder_num;
7850  E_STB_AV_AUDIO_CODEC av_codec;
7851  BOOLEAN ret_val;
7852 
7853  FUNCTION_START(STB_DPSetAudioCodec);
7854 
7855  ASSERT(path < num_paths);
7856 
7857  demux_num = path_status[path].demux_no;
7858  decoder_num = path_status[path].audio_decoder_no;
7859 
7860  ASSERT(demux_num < num_demuxes);
7861 
7862  demux_status[demux_num].audio_codec = codec;
7863  ret_val = TRUE;
7864 
7865  if (decoder_num < num_video_decoders)
7866  {
7867  switch (codec)
7868  {
7869  case AUDIO_CODEC_MP2:
7870  av_codec = AV_AUDIO_CODEC_MP2;
7871  break;
7872 
7873  case AUDIO_CODEC_MP3:
7874  av_codec = AV_AUDIO_CODEC_MP3;
7875  break;
7876 
7877  case AUDIO_CODEC_AC3:
7878  av_codec = AV_AUDIO_CODEC_AC3;
7879  break;
7880 
7881  case AUDIO_CODEC_EAC3:
7882  av_codec = AV_AUDIO_CODEC_EAC3;
7883  break;
7884 
7885  case AUDIO_CODEC_AAC:
7886  av_codec = AV_AUDIO_CODEC_AAC;
7887  break;
7888 
7889  case AUDIO_CODEC_HEAAC:
7890  av_codec = AV_AUDIO_CODEC_HEAAC;
7891  break;
7892 
7893  case AUDIO_CODEC_AAC_ADTS:
7894  av_codec = AV_AUDIO_CODEC_AAC_ADTS;
7895  break;
7896 
7897  default:
7898  av_codec = AV_AUDIO_CODEC_AUTO;
7899  break;
7900  }
7901 
7902  ret_val = STB_AVSetAudioCodec(decoder_num, av_codec);
7903  if (ret_val)
7904  {
7905  audio_decoder_status[decoder_num].codec = codec;
7906  }
7907  }
7908 
7909  FUNCTION_FINISH(STB_DPSetAudioCodec);
7910 
7911  return ret_val;
7912 }
7913 
7925 E_STB_DP_AUDIO_CODEC STB_DPGetAudioCodec(U8BIT path)
7926 {
7927  U8BIT demux_num;
7928  U8BIT decoder_num;
7929  E_STB_DP_AUDIO_CODEC ret_val;
7930 
7931  FUNCTION_START(STB_DPGetAudioCodec);
7932 
7933  ASSERT(path < num_paths);
7934 
7935  decoder_num = path_status[path].audio_decoder_no;
7936 
7937  if (decoder_num < num_audio_decoders)
7938  {
7939  ret_val = audio_decoder_status[decoder_num].codec;
7940  }
7941  else
7942  {
7943  demux_num = path_status[path].demux_no;
7944  ASSERT(demux_num < num_demuxes);
7945  ret_val = demux_status[demux_num].audio_codec;
7946  }
7947 
7948  FUNCTION_FINISH(STB_DPGetAudioCodec);
7949 
7950  return(ret_val);
7951 }
7952 
7953 //---local function definitions------------------------------------------------
7954 
7955 /*!**************************************************************************
7956  * @brief Acquires all the resources needed for live viewing except the tuner
7957  * @param path - The ID of the decode path being acquired for live viewing
7958  * @param tuner_num - ID of an already acquired tuner that will be assigned to the path
7959  * @param with_decoders - TRUE if decoding resources are to be acquired
7960  * @return TRUE if the resources are acquired successfully
7961  ****************************************************************************/
7962 static BOOLEAN AcquireResources(U8BIT path, U16BIT demux_caps, BOOLEAN with_decoders)
7963 {
7964  U32BIT param;
7965  BOOLEAN result = FALSE;
7966 
7967  FUNCTION_START(AcquireResources);
7968 
7969  if (path != INVALID_RES_ID)
7970  {
7971  /* Acquire any resources that aren't currently available to this path */
7972  path_status[path].demux_no = STB_RESAcquireDemux(INVALID_RES_ID, demux_caps);
7973  if (path_status[path].demux_no != INVALID_RES_ID)
7974  {
7975  if (with_decoders)
7976  {
7977  path_status[path].video_decoder_no = STB_RESAcquireVideoDecoder();
7978  if (path_status[path].video_decoder_no != INVALID_RES_ID)
7979  {
7980  path_status[path].audio_decoder_no = STB_RESAcquireAudioDecoder();
7981  if (path_status[path].audio_decoder_no != INVALID_RES_ID)
7982  {
7983  /* Acquired all necessary resources */
7984  result = TRUE;
7985 
7986  /* Set the demux to get its data from the tuner */
7987  STB_DMXSetDemuxSource(path_status[path].demux_no, DMX_TUNER, path_status[path].tuner_no);
7988 
7989  /* Set the source of the A/V decoders */
7990  param = ((U32BIT)path_status[path].tuner_no << 8) | path_status[path].demux_no;
7991  STB_AVSetAudioSource(path_status[path].audio_decoder_no, AV_DEMUX, param);
7992  STB_AVSetVideoSource(path_status[path].video_decoder_no, AV_DEMUX, param);
7993 
7994  /* Failing to acquire an AD decoder isn't seen as a failure */
7995  path_status[path].ad_decoder_no = STB_RESAcquireADDecoder();
7996  if (path_status[path].ad_decoder_no != INVALID_RES_ID)
7997  {
7998  STB_AVSetADSource(path_status[path].ad_decoder_no, AV_DEMUX, param);
7999  }
8000 
8001  /* Try to acquire a secondary video decoder */
8002  path_status[path].secondary_video_decoder_no = STB_RESAcquireVideoDecoder();
8003  if (path_status[path].secondary_video_decoder_no != INVALID_RES_ID)
8004  {
8005  STB_AVSetVideoSource(path_status[path].secondary_video_decoder_no, AV_MEMORY, 0);
8006  }
8007  }
8008  else
8009  {
8010  /* Not all resources are available so release acquired resources */
8011  STB_RESReleaseVideoDecoder(path_status[path].video_decoder_no);
8012  path_status[path].video_decoder_no = INVALID_RES_ID;
8013 
8014  STB_RESReleaseDemux(path_status[path].demux_no);
8015  path_status[path].demux_no = INVALID_RES_ID;
8016  }
8017  }
8018  else
8019  {
8020  /* Not all resources are available so release acquired resources */
8021  STB_RESReleaseDemux(path_status[path].demux_no);
8022  path_status[path].demux_no = INVALID_RES_ID;
8023  }
8024  }
8025  else
8026  {
8027  /* No decoding required */
8028  path_status[path].video_decoder_no = INVALID_RES_ID;
8029  path_status[path].secondary_video_decoder_no = INVALID_RES_ID;
8030  path_status[path].audio_decoder_no = INVALID_RES_ID;
8031  path_status[path].ad_decoder_no = INVALID_RES_ID;
8032 
8033  /* Acquired all necessary resources */
8034  result = TRUE;
8035 
8036  /* Set the demux to get its data from a tuner */
8037  STB_DMXSetDemuxSource(path_status[path].demux_no, DMX_TUNER, path_status[path].tuner_no);
8038  }
8039  }
8040  }
8041 
8042  FUNCTION_FINISH(AcquireResources);
8043 
8044  return(result);
8045 }
8046 
8047 /*!**************************************************************************
8048  * @brief Sends a DiSEqC message, ensuring that at least 25ms has lapsed since
8049  * the previous message was sent.
8050  * @param tuner - tuner path
8051  * @param msg_data - DiSEqC message data to be sent
8052  * @param msg_size - number of bytes in the message
8053  ****************************************************************************/
8054 static void SendDISEQCMessage(U8BIT tuner, U8BIT *msg_data, U8BIT msg_size)
8055 {
8056  U32BIT delay_time;
8057  U32BIT repeat_time;
8058  U8BIT i;
8059  U8BIT dmsg_data[3];
8060 
8061  FUNCTION_START(SendDISEQCMessage);
8062 
8063  if (!lnb_awake)
8064  {
8065  /* This is the first DiSEqC message being sent so make sure everything
8066  * is ready to receive messages by sending the Awake message first */
8067  repeat_time = 0;
8068 
8069  for (i = 0; i < (tuner_status[tuner].diseqc_repeats + 1); i++)
8070  {
8071  if (i == 0)
8072  {
8073  dmsg_data[0] = 0xe0;
8074  }
8075  else
8076  {
8077  dmsg_data[0] = 0xe1;
8078  }
8079 
8080  dmsg_data[1] = 0x10;
8081  dmsg_data[2] = 0x31;
8082 
8083  /* Make sure we wait at least 100ms before sending any repeated commands */
8084  if (i != 0)
8085  {
8086  if ((delay_time = STB_OSGetClockDiff(repeat_time)) < DISEQC_REPEAT_DELAY)
8087  {
8088  STB_OSTaskDelay(DISEQC_REPEAT_DELAY - delay_time);
8089  }
8090  }
8091 
8092  STB_TuneSendDISEQCMessage(tuner, dmsg_data, 3);
8093 
8094  tuner_status[tuner].diseqc_msg_time = STB_OSGetClockMilliseconds();
8095  repeat_time = STB_OSGetClockMilliseconds();
8096  }
8097 
8098  lnb_awake = TRUE;
8099  }
8100 
8101  /* The time of the last diseqc message will be 0 if nothing has been sent yet */
8102  if (tuner_status[tuner].diseqc_msg_time != 0)
8103  {
8104  /* There must be at least 25ms from the end of the last DiSEqC message to this one being sent */
8105  if ((delay_time = STB_OSGetClockDiff(tuner_status[tuner].diseqc_msg_time)) < DISEQC_MESSAGE_DELAY)
8106  {
8107  STB_OSTaskDelay(DISEQC_MESSAGE_DELAY - delay_time);
8108  }
8109  }
8110 
8111  STB_TuneSendDISEQCMessage(tuner, msg_data, msg_size);
8112 
8113  tuner_status[tuner].diseqc_msg_time = STB_OSGetClockMilliseconds();
8114 
8115  FUNCTION_FINISH(SendDISEQCMessage);
8116 }
8117 
8129 static BOOLEAN StartTune(U8BIT path)
8130 {
8131  U8BIT tuner;
8132 
8133  E_STB_TUNE_SYSTEM_TYPE system_type;
8134  // SAT
8135  E_STB_TUNE_MODULATION tnr_mod;
8136  E_STB_TUNE_FEC tnr_fec;
8137  E_STB_TUNE_LNB_VOLTAGE lnb_volts;
8138  S_STB_DP_LNB_BAND *band;
8139 
8140  // Terrestrial
8141  E_STB_TUNE_TMODE tnr_tmode;
8142  E_STB_TUNE_TBWIDTH tnr_tbwidth;
8143  E_STB_TUNE_ANALOG_VIDEO_TYPE tnr_avtype;
8144 
8145  E_STB_TUNE_CMODE cmode;
8146 
8147  U8BIT dmsg_data[6];
8148  U8BIT i;
8149  S32BIT tnr_freq;
8150  S32BIT tnr_min_freq;
8151  S32BIT tnr_max_freq;
8152  S32BIT sig_freq;
8153  S32BIT lo_freq;
8154  U8BIT data_1;
8155  U8BIT data_2;
8156  U16BIT t_word;
8157  U8BIT unicablecmd[UNICABLE_COMMAND_SIZE];
8158  BOOLEAN high_band;
8159  BOOLEAN tone_22khz_on;
8160  U32BIT repeat_time;
8161  U32BIT delay_time;
8162  BOOLEAN retval = FALSE;
8163 
8164  FUNCTION_START(StartTune);
8165 
8166  tuner = path_status[path].tuner_no;
8167 
8168  switch (tuner_status[tuner].signal_type)
8169  {
8170  case SIGNAL_QPSK:
8171  {
8172  sig_freq = tuner_status[tuner].frequency * 1000;
8173 
8174  // work out lnb band to be used (and set 22kHz tone at the same time)
8175  tnr_min_freq = (S32BIT)STB_TuneGetMinTunerFreqKHz(tuner);
8176  tnr_max_freq = (S32BIT)STB_TuneGetMaxTunerFreqKHz(tuner);
8177 
8178  band = FindLNBBand(tuner);
8179  if (band != NULL)
8180  {
8181  lo_freq = band->local_oscillator_frequency * 1000; // convert to kHz
8182  }
8183  else
8184  {
8185  lo_freq = 0;
8186  }
8187 
8188  DBGPRINT("QPSK f(%d,%d,%d) sr=%d", tnr_min_freq, sig_freq, tnr_max_freq, tuner_status[tuner].sym_rate);
8189 
8190  tone_22khz_on = FALSE;
8191  high_band = FALSE;
8192 
8193  // now calculate tuner frequency from required signal frequency and lnb lo freq
8194  switch (tuner_status[tuner].lnb_type)
8195  {
8196  case LNB_TYPE_SINGLE:
8197  {
8198  high_band = FALSE;
8199  tone_22khz_on = tuner_status[tuner].lnb_22k;
8200 
8201  /* Calculate the IF frequency to tune to.
8202  * Tuning to C band satellites can result in negative frequencies,
8203  * so check for this and use the absolute value */
8204  if ((tnr_freq = sig_freq - lo_freq) < 0)
8205  {
8206  tnr_freq = -tnr_freq;
8207  }
8208  break;
8209  }
8210 
8211  case LNB_TYPE_UNICABLE:
8212  {
8213  /* Only two bands for this type, it's high band if the mininum frequency is
8214  not 0 */
8215  if ((band != NULL) && (band->min_freq > 0))
8216  {
8217  high_band = TRUE;
8218  }
8219  else
8220  {
8221  high_band = FALSE;
8222  }
8223 
8224  // Fixed IF frequency
8225  // Actual sig_freq will be tuned by LNB via DiSEqC command
8226  tnr_freq = tuner_status[tuner].unicable_if;
8227  break;
8228  }
8229 
8230  case LNB_TYPE_USER_DEFINED:
8231  {
8232  if (band != NULL)
8233  {
8234  tone_22khz_on = band->tone_22k;
8235  high_band = FALSE;
8236  }
8237 
8238  // Calculate the IF frequency to tune to
8239  tnr_freq = sig_freq - lo_freq;
8240  break;
8241  }
8242 
8243  case LNB_TYPE_UNIVERSAL:
8244  default:
8245  {
8246  /* Only two bands for this type, it's high band if the mininum frequency is
8247  not 0 */
8248  if (band != NULL)
8249  {
8250  tone_22khz_on = band->tone_22k;
8251  if (band->min_freq > 0)
8252  {
8253  high_band = TRUE;
8254  }
8255  else
8256  {
8257  high_band = FALSE;
8258  }
8259  }
8260 
8261  // Calculate the IF frequency to tune to
8262  tnr_freq = sig_freq - lo_freq;
8263  break;
8264  }
8265  }
8266 
8267  if ((tnr_min_freq <= tnr_freq) && (tnr_freq <= tnr_max_freq) &&
8268  (tuner_status[tuner].sym_rate >= TUNER_MIN_SRATE) &&
8269  (tuner_status[tuner].sym_rate <= TUNER_MAX_SRATE))
8270  {
8271  // work out required lnb voltage
8272  switch (tuner_status[tuner].lnb_power)
8273  {
8274  case LNB_POWER_ON:
8275  case LNB_POWER_AUTO:
8276  {
8277  if (band != NULL)
8278  {
8279  lnb_volts = band->lnb_voltage;
8280  }
8281  else
8282  {
8283  lnb_volts = LNB_VOLTAGE_OFF;
8284  }
8285  break;
8286  }
8287 
8288  case LNB_POWER_OFF:
8289  default:
8290  {
8291  lnb_volts = LNB_VOLTAGE_OFF;
8292  break;
8293  }
8294  }
8295 
8296  // Now ready to start controlling front end...
8297  // first set lnb voltage to required level and set 12v switch state
8298  STB_TuneSetLNBVoltage(tuner, lnb_volts);
8299  STB_TuneSet12VSwitch(tuner, tuner_status[tuner].lnb_12v);
8300  STB_TuneSetLOFrequency(tuner, lo_freq);
8301 
8302  if ((tuner_status[tuner].diseqc_position == TRUE) &&
8303  (lnb_currently_powered == FALSE) &&
8304  (lnb_volts != LNB_VOLTAGE_OFF))
8305  {
8306  // On applying power to LNB, if there is a DiSEqC 1.2 motor fitted then wait
8307  // after applying power to the LNB. This allows enough time for the DiSEqC
8308  // IC to power up to receive the message.
8309  STB_OSTaskDelay(1000);
8310 
8311  lnb_currently_powered = TRUE;
8312  }
8313 
8314  // if lnb voltage is not off, send any diseqc messages
8315  if (lnb_volts != LNB_VOLTAGE_OFF)
8316  {
8317  repeat_time = 0;
8318 
8319  for (i = 0; i < (tuner_status[tuner].diseqc_repeats + 1); i++)
8320  {
8321  // send DiSEqC committed switch messages
8322  if (i == 0)
8323  {
8324  dmsg_data[0] = 0xe0;
8325  }
8326  else
8327  {
8328  dmsg_data[0] = 0xe1;
8329  }
8330 
8331  dmsg_data[1] = 0x10;
8332  dmsg_data[2] = 0x38;
8333  dmsg_data[3] = 0xf0;
8334 
8335  if (tuner_status[tuner].polarity == POLARITY_HORIZONTAL)
8336  {
8337  dmsg_data[3] |= 0x02;
8338  }
8339  if (high_band == TRUE)
8340  {
8341  dmsg_data[3] |= 0x01;
8342  }
8343 
8344  if (i != 0)
8345  {
8346  /* Make sure we wait at least 100ms before sending any repeated commands */
8347  if ((delay_time = STB_OSGetClockDiff(repeat_time)) < DISEQC_REPEAT_DELAY)
8348  {
8349  STB_OSTaskDelay(DISEQC_REPEAT_DELAY - delay_time);
8350  }
8351  }
8352 
8353  switch (tuner_status[tuner].diseqc_cswitch)
8354  {
8355  case DISEQC_CSWITCH_A:
8356  {
8357  dmsg_data[3] |= 0x00;
8358  SendDISEQCMessage(tuner, dmsg_data, 4);
8359  repeat_time = STB_OSGetClockMilliseconds();
8360  break;
8361  }
8362  case DISEQC_CSWITCH_B:
8363  {
8364  dmsg_data[3] |= 0x04;
8365  SendDISEQCMessage(tuner, dmsg_data, 4);
8366  repeat_time = STB_OSGetClockMilliseconds();
8367  break;
8368  }
8369  case DISEQC_CSWITCH_C:
8370  {
8371  dmsg_data[3] |= 0x08;
8372  SendDISEQCMessage(tuner, dmsg_data, 4);
8373  repeat_time = STB_OSGetClockMilliseconds();
8374  break;
8375  }
8376  case DISEQC_CSWITCH_D:
8377  {
8378  dmsg_data[3] |= 0x0c;
8379  SendDISEQCMessage(tuner, dmsg_data, 4);
8380  repeat_time = STB_OSGetClockMilliseconds();
8381  break;
8382  }
8383  default:
8384  {
8385  break;
8386  }
8387  }
8388 
8389  // send DiSEqC uncommitted switch messages
8390  if (tuner_status[tuner].diseqc_uswitch != 0)
8391  {
8392  dmsg_data[1] = 0x10;
8393  dmsg_data[2] = 0x39;
8394  dmsg_data[3] = 0xf0;
8395  dmsg_data[3] |= (tuner_status[tuner].diseqc_uswitch - 1);
8396  SendDISEQCMessage(tuner, dmsg_data, 4);
8397  }
8398  }
8399 
8400  // check if SMATV is enabled
8401  if (tuner_status[tuner].diseqc_smatv == TRUE)
8402  {
8403  // send DiSEqC committed switch message if not already sent
8404  if (tuner_status[tuner].diseqc_cswitch == DISEQC_CSWITCH_OFF)
8405  {
8406  dmsg_data[0] = 0xe0;
8407  dmsg_data[1] = 0x10;
8408  dmsg_data[2] = 0x38;
8409  dmsg_data[3] = 0xf0;
8410  if (tuner_status[tuner].polarity == POLARITY_HORIZONTAL)
8411  {
8412  dmsg_data[3] |= 0x02;
8413  }
8414  if (high_band == TRUE)
8415  {
8416  dmsg_data[3] |= 0x01;
8417  }
8418  SendDISEQCMessage(tuner, dmsg_data, 4);
8419  }
8420 
8421  // send DiSEqC SMATV messages
8422  sig_freq = tuner_status[tuner].frequency;
8423  dmsg_data[0] = 0xe0;
8424  dmsg_data[1] = 0x10;
8425  dmsg_data[2] = 0x58;
8426  dmsg_data[3] = (U8BIT)((sig_freq / 10000) << 4);
8427  sig_freq = (sig_freq % 10000);
8428  dmsg_data[3] |= (U8BIT)(sig_freq / 1000);
8429  sig_freq = (sig_freq % 1000);
8430  dmsg_data[4] = (U8BIT)((sig_freq / 100) << 4);
8431  sig_freq = (sig_freq % 100);
8432  dmsg_data[4] |= (U8BIT)(sig_freq / 10);
8433  sig_freq = (sig_freq % 10);
8434  dmsg_data[5] = (U8BIT)((sig_freq / 1) << 4);
8435  SendDISEQCMessage(tuner, dmsg_data, 6);
8436  }
8437 
8438  if (tuner_status[tuner].diseqc_tone != DISEQC_TONE_OFF)
8439  {
8440  // send DiSEqC tone burst
8441  switch (tuner_status[tuner].diseqc_tone)
8442  {
8443  case DISEQC_TONE_A:
8444  dmsg_data[0] = 0x00;
8445  SendDISEQCMessage(tuner, dmsg_data, 1);
8446  break;
8447 
8448  case DISEQC_TONE_B:
8449  dmsg_data[0] = 0xff;
8450  SendDISEQCMessage(tuner, dmsg_data, 1);
8451  break;
8452 
8453  default:
8454  break;
8455  }
8456  }
8457  }
8458 
8459  // check if skew position has changed
8460  if ((tuner_status[tuner].actions & ACTION_SKEW) != 0)
8461  {
8462  tuner_status[tuner].actions &= ~ACTION_SKEW;
8463  STB_TuneChangeSkewPosition(tuner, tuner_status[tuner].skew_pos);
8464  }
8465 
8466  // check if dish position has changed
8467  if ((tuner_status[tuner].actions & ACTION_DISH) != 0)
8468  {
8469  tuner_status[tuner].actions &= ~ACTION_DISH;
8470  if (tuner_status[tuner].pulse_position == TRUE)
8471  {
8472  STB_TuneChangePulsePosition(tuner, tuner_status[tuner].dish_pos);
8473  }
8474  if ((tuner_status[tuner].diseqc_position == TRUE) && (lnb_volts != LNB_VOLTAGE_OFF))
8475  {
8476  dmsg_data[0] = 0xe0;
8477  dmsg_data[1] = 0x31;
8478  dmsg_data[2] = 0x6b;
8479  dmsg_data[3] = (U8BIT)(tuner_status[tuner].dish_pos & 0x00ff);
8480 
8481  // If zero has been placed in the decode path, it should not be sent as not a
8482  // valid position; but is a reference position and has a function of its own to
8483  // centre dish.
8484  if (dmsg_data[3] != 0x00)
8485  {
8486  SendDISEQCMessage(tuner, dmsg_data, 4);
8487  }
8488  }
8489  }
8490 
8491  /* Set modulation */
8492  switch (tuner_status[tuner].modulation)
8493  {
8494  case MOD_QPSK:
8495  tnr_mod = TUNE_MOD_QPSK;
8496  break;
8497 
8498  case MOD_8PSK:
8499  tnr_mod = TUNE_MOD_8PSK;
8500  break;
8501 
8502  case MOD_16QAM:
8503  tnr_mod = TUNE_MOD_16QAM;
8504  break;
8505 
8506  case MOD_AUTO:
8507  default:
8508  tnr_mod = TUNE_MOD_AUTO;
8509  break;
8510  }
8511 
8512  STB_TuneSetModulation(tuner, tnr_mod);
8513 
8514  // set FEC param
8515  switch (tuner_status[tuner].fec)
8516  {
8517  case FEC_AUTOMATIC: {tnr_fec = TUNE_FEC_AUTOMATIC; break; }
8518  case FEC_1_2: {tnr_fec = TUNE_FEC_1_2; break; }
8519  case FEC_2_3: {tnr_fec = TUNE_FEC_2_3; break; }
8520  case FEC_3_4: {tnr_fec = TUNE_FEC_3_4; break; }
8521  case FEC_5_6: {tnr_fec = TUNE_FEC_5_6; break; }
8522  case FEC_7_8: {tnr_fec = TUNE_FEC_7_8; break; }
8523  case FEC_1_4: {tnr_fec = TUNE_FEC_1_4; break; }
8524  case FEC_1_3: {tnr_fec = TUNE_FEC_1_3; break; }
8525  case FEC_2_5: {tnr_fec = TUNE_FEC_2_5; break; }
8526  case FEC_8_9: {tnr_fec = TUNE_FEC_8_9; break; }
8527  case FEC_9_10: {tnr_fec = TUNE_FEC_9_10; break; }
8528  case FEC_3_5: {tnr_fec = TUNE_FEC_3_5; break; }
8529  case FEC_4_5: {tnr_fec = TUNE_FEC_4_5; break; }
8530  default: {tnr_fec = TUNE_FEC_AUTOMATIC; break; }
8531  }
8532 
8533  // Set system type (S/S2)
8534  if (tuner_status[tuner].dvb_s2 == TRUE)
8535  {
8536  system_type = TUNE_SYSTEM_TYPE_DVBS2;
8537  }
8538  else
8539  {
8540  system_type = TUNE_SYSTEM_TYPE_DVBS;
8541  }
8542  STB_TuneSetSystemType(tuner, system_type);
8543 
8544  STB_TUNE_PRINT(("STB_DP:StartTune(%d,%d): %d %s fec %d (%s_BAND, LO %d, LNB_%s, %s)",
8545  path, tuner, tnr_freq / 1000,
8546  (tuner_status[tuner].polarity == POLARITY_VERTICAL) ? "V" : "H",
8547  tuner_status[tuner].fec,
8548  high_band == TRUE ? "HIGH" : "LOW",
8549  lo_freq / 1000,
8550  (tone_22khz_on == TRUE) ? "22khz" : "OFF",
8551  (lnb_volts == LNB_VOLTAGE_18V) ? "18V" : ((lnb_volts == LNB_VOLTAGE_14V) ? "14V" : "OFF")));
8552 
8553  if (tuner_status[tuner].lnb_type == LNB_TYPE_UNICABLE)
8554  {
8555  // User Bank 0 - 7 on bits 7-5
8556  data_1 = (tuner_status[path].unicable_chan & 0x07) << 5;
8557 
8558  // Signal Bank 0 - 7 on bits 4-2
8559  if (tuner_status[path].unicable_position_b == TRUE)
8560  {
8561  data_1 |= (1 << 4);
8562  }
8563  if (tuner_status[tuner].polarity == POLARITY_HORIZONTAL)
8564  {
8565  data_1 |= (1 << 3);
8566  }
8567  if (high_band == TRUE)
8568  {
8569  data_1 |= (1 << 2);
8570  }
8571 
8572  // Tuning word
8573  t_word = (U16BIT)(((abs((sig_freq / 1000) - (lo_freq / 1000)) + (tnr_freq / 1000)) / 4) - 350);
8574  data_1 |= (((U8BIT) (t_word >> 8)) & 0x03);
8575  data_2 = (U8BIT) (t_word & 0x00ff);
8576 
8577  // Send DiSEqC code E0 10 5A channel_byte_1 channel_byte_2
8578  unicablecmd[0] = 0xE0; // FRAMING
8579  unicablecmd[1] = 0x10; // ADDRESS
8580  unicablecmd[2] = 0x5A; // NORMAL COMMAND
8581  unicablecmd[3] = data_1;
8582  unicablecmd[4] = data_2;
8583  UnicableSendCommand(tuner, unicablecmd);
8584  }
8585  else
8586  {
8587  // Now set the 22kHz tone state
8588  STB_TuneSet22kState(tuner, tone_22khz_on);
8589  }
8590 
8591  STB_DPSetTuneStatus(path, TUNE_WAITING);
8592  STB_TuneStartTuner(tuner, tnr_freq, tuner_status[tuner].sym_rate * 1000, tnr_fec, 0, 0, 0, 0, 0);
8593  retval = TRUE;
8594  }
8595  break;
8596  }
8597 
8598  case SIGNAL_COFDM:
8599  {
8600  // get required signal freq and check it is valid. For cofdm frequency is stored in Hz.
8601  tnr_freq = tuner_status[tuner].frequency;
8602  tnr_min_freq = (S32BIT)STB_TuneGetMinTunerFreqKHz(tuner) * 1000;
8603  tnr_max_freq = (S32BIT)STB_TuneGetMaxTunerFreqKHz(tuner) * 1000;
8604  if ((tnr_min_freq <= tnr_freq) && (tnr_freq <= tnr_max_freq))
8605  {
8606  // set tmode param
8607  switch (tuner_status[tuner].terr_mode)
8608  {
8609  case MODE_COFDM_2K: {tnr_tmode = TUNE_MODE_COFDM_2K; break; }
8610  case MODE_COFDM_8K: {tnr_tmode = TUNE_MODE_COFDM_8K; break; }
8611  default: {tnr_tmode = TUNE_MODE_COFDM_UNDEFINED; break; }
8612  }
8613  // set tbwidth param
8614  switch (tuner_status[tuner].terr_bwidth)
8615  {
8616  case TBWIDTH_8MHZ: {tnr_tbwidth = TUNE_TBWIDTH_8MHZ; break; }
8617  case TBWIDTH_7MHZ: {tnr_tbwidth = TUNE_TBWIDTH_7MHZ; break; }
8618  case TBWIDTH_6MHZ: {tnr_tbwidth = TUNE_TBWIDTH_6MHZ; break; }
8619  default: {tnr_tbwidth = TUNE_TBWIDTH_8MHZ; break; }
8620  }
8621 
8622  // start the tuner tuning - for COFDM only freq, tfoff, tmode and tbwidth are used
8623  STB_DPSetTuneStatus(path, TUNE_WAITING);
8624  switch (tuner_status[tuner].terr_type)
8625  {
8626  case TERR_TYPE_DVBT: {system_type = TUNE_SYSTEM_TYPE_DVBT; break; }
8627  case TERR_TYPE_DVBT2: {system_type = TUNE_SYSTEM_TYPE_DVBT2; break; }
8628  default: {system_type = TUNE_SYSTEM_TYPE_DVBT; break; }
8629  }
8630  STB_TuneSetSystemType(tuner, system_type);
8631  STB_TuneSetPLP(tuner, tuner_status[tuner].plp_id);
8632  STB_TuneStartTuner(tuner, tnr_freq, 0, 0, tuner_status[tuner].freq_offset, tnr_tmode,
8633  tnr_tbwidth, TUNE_MODE_QAM_UNDEFINED, 0);
8634  retval = TRUE;
8635  }
8636  break;
8637  }
8638 
8639  case SIGNAL_QAM:
8640  {
8641  tnr_freq = tuner_status[tuner].frequency;
8642  tnr_min_freq = (S32BIT)STB_TuneGetMinTunerFreqKHz(tuner) * 1000;
8643  tnr_max_freq = (S32BIT)STB_TuneGetMaxTunerFreqKHz(tuner) * 1000;
8644  if ((tnr_min_freq <= tnr_freq) && (tnr_freq <= tnr_max_freq))
8645  {
8646  switch (tuner_status[tuner].cable_mode)
8647  {
8648  case MODE_QAM_4:
8649  cmode = TUNE_MODE_QAM_4;
8650  break;
8651 
8652  case MODE_QAM_8:
8653  cmode = TUNE_MODE_QAM_8;
8654  break;
8655 
8656  case MODE_QAM_16:
8657  cmode = TUNE_MODE_QAM_16;
8658  break;
8659 
8660  case MODE_QAM_32:
8661  cmode = TUNE_MODE_QAM_32;
8662  break;
8663 
8664  case MODE_QAM_64:
8665  cmode = TUNE_MODE_QAM_64;
8666  break;
8667 
8668  case MODE_QAM_128:
8669  cmode = TUNE_MODE_QAM_128;
8670  break;
8671 
8672  case MODE_QAM_256:
8673  cmode = TUNE_MODE_QAM_256;
8674  break;
8675 
8676  default:
8677  cmode = TUNE_MODE_QAM_UNDEFINED;
8678  break;
8679  }
8680 
8681  switch (tuner_status[tuner].fec)
8682  {
8683  case FEC_AUTOMATIC:
8684  tnr_fec = TUNE_FEC_AUTOMATIC;
8685  break;
8686  case FEC_1_2:
8687  tnr_fec = TUNE_FEC_1_2;
8688  break;
8689  case FEC_2_3:
8690  tnr_fec = TUNE_FEC_2_3;
8691  break;
8692  case FEC_3_4:
8693  tnr_fec = TUNE_FEC_3_4;
8694  break;
8695  case FEC_5_6:
8696  tnr_fec = TUNE_FEC_5_6;
8697  break;
8698  case FEC_7_8:
8699  tnr_fec = TUNE_FEC_7_8;
8700  break;
8701  default:
8702  tnr_fec = TUNE_FEC_AUTOMATIC;
8703  break;
8704  }
8705 
8706  // start the tuner tuning - for COFDM only freq, tfoff, tmode and tbwidth are used
8707  STB_DPSetTuneStatus(path, TUNE_WAITING);
8708  STB_TuneStartTuner(tuner, tnr_freq, tuner_status[tuner].sym_rate * 1000, tnr_fec, 0, 0,
8709  0, cmode, 0);
8710  retval = TRUE;
8711  }
8712  break;
8713  }
8714 
8715  case SIGNAL_ANALOG:
8716  {
8717  // get required signal freq and check it is valid. For analogue frequency is stored in Hz.
8718  tnr_freq = tuner_status[tuner].frequency;
8719  tnr_min_freq = (S32BIT)STB_TuneGetMinTunerFreqKHz(tuner) * 1000;
8720  tnr_max_freq = (S32BIT)STB_TuneGetMaxTunerFreqKHz(tuner) * 1000;
8721  if ((tnr_min_freq <= tnr_freq) && (tnr_freq <= tnr_max_freq))
8722  {
8723  // set analog video type param
8724  switch (tuner_status[tuner].anlg_vtype)
8725  {
8726  case ANLG_VIDEO_PAL_I: {tnr_avtype = TUNE_ANLG_VIDEO_PAL_I; break; }
8727  case ANLG_VIDEO_PAL_B: {tnr_avtype = TUNE_ANLG_VIDEO_PAL_B; break; }
8728  case ANLG_VIDEO_PAL_G: {tnr_avtype = TUNE_ANLG_VIDEO_PAL_G; break; }
8729  case ANLG_VIDEO_PAL_D: {tnr_avtype = TUNE_ANLG_VIDEO_PAL_D; break; }
8730  case ANLG_VIDEO_PAL_K: {tnr_avtype = TUNE_ANLG_VIDEO_PAL_K; break; }
8731  case ANLG_VIDEO_PAL_L: {tnr_avtype = TUNE_ANLG_VIDEO_PAL_L; break; }
8732  case ANLG_VIDEO_PAL_LDASH: {tnr_avtype = TUNE_ANLG_VIDEO_PAL_LDASH; break; }
8733  default: {tnr_avtype = TUNE_ANLG_VIDEO_PAL_I; break; }
8734  }
8735 
8736  // start the tuner tuning - for analog only freq, and video type are used
8737  STB_DPSetTuneStatus(path, TUNE_WAITING);
8738  STB_TuneStartTuner(tuner, tnr_freq, 0, 0, tuner_status[tuner].freq_offset, 0, 0, 0,
8739  tnr_avtype);
8740  retval = TRUE;
8741  }
8742  break;
8743  }
8744 
8745  default:
8746  {
8747  STB_TUNE_PRINT(("Unhandled SIGNAL_TYPE %d", tuner_status[tuner].signal_type));
8748  break;
8749  }
8750  }
8751 
8752  FUNCTION_FINISH(StartTune);
8753 
8754  return(retval);
8755 }
8756 
8757 /*!**************************************************************************
8758  * @brief Sends a Unicable command (modulated onto 18V DC level)
8759  * @param path - The tuner path to use
8760  * @param cmd - The unicable command bytes to send
8761  ****************************************************************************/
8762 static void UnicableSendCommand(U8BIT path, U8BIT cmd[UNICABLE_COMMAND_SIZE])
8763 {
8764  STB_TuneSetLNBVoltage(path, LNB_VOLTAGE_18V);
8765  SendDISEQCMessage(path, cmd, UNICABLE_COMMAND_SIZE);
8766  STB_TuneSetLNBVoltage(path, LNB_VOLTAGE_14V);
8767 }
8768 
8769 static S_STB_DP_LNB_BAND *FindLNBBand(U8BIT tuner)
8770 {
8771  S_STB_DP_LNB_BAND *band;
8772  U8BIT n, i;
8773 
8774  FUNCTION_START(FindLNBBand);
8775 
8776  if (tuner_status[tuner].lnb_definition[tuner_status[tuner].lnb_type].band_list != NULL)
8777  {
8778  n = tuner_status[tuner].lnb_definition[tuner_status[tuner].lnb_type].number_of_bands;
8779  band = tuner_status[tuner].lnb_definition[tuner_status[tuner].lnb_type].band_list;
8780  i = 0;
8781  while ((band != NULL) && (i < n))
8782  {
8783  if ((band->polarity == tuner_status[tuner].polarity) &&
8784  (tuner_status[tuner].frequency > band->min_freq) &&
8785  ((band->max_freq == 0) || (tuner_status[tuner].frequency <= band->max_freq)))
8786  {
8787  break;
8788  }
8789  band++;
8790  i++;
8791  if (i >= n)
8792  {
8793  band = NULL;
8794  }
8795  }
8796  }
8797  else
8798  {
8799  band = NULL;
8800  }
8801 
8802  FUNCTION_FINISH(FindLNBBand);
8803 
8804  return band;
8805 }
8806 
8807 //*****************************************************************************
8808 // End of file
8809 //*****************************************************************************
8810 
void STB_DPSetModulation(U8BIT path, E_STB_DP_MODULATION modulation)
Set the satellite modulation for the tuner in the given decode path.
Definition: stbdpc.c:6359
E_STB_OTA_SW_UPGRADE_SEARCH_MODE STB_DPGetOTASearchMode(U8BIT path)
Returns the current &#39;Over The Air&#39; Software Upgrade Search Mode for the given path.
Definition: stbdpc.c:4369
BOOLEAN STB_CAReleaseDescrambler(U32BIT handle)
Will be called when a CA descrambler is no longer required.
Definition: ca_glue.c:111
void STB_DPDisableDishLimits(U8BIT path)
Disables sat dish limits.
Definition: stbdpc.c:5571
U8BIT STB_DPGetPlaybackPath(void)
Returns the ID of the decode path being used for playback.
Definition: stbdpc.c:1373
void STB_TuneSendDISEQCMessage(U8BIT path, U8BIT *data, U8BIT size)
Sends the DisEqc message.
BOOLEAN STB_DPGetLNB22k(U8BIT path)
Reads the status of LNB 22kHz from decode path store.
Definition: stbdpc.c:4632
void STB_DPSetDishLimitE(U8BIT path)
Sets current sat dish position as East limit.
Definition: stbdpc.c:5437
BOOLEAN STB_DPSetAudioCodec(U8BIT path, E_STB_DP_AUDIO_CODEC codec)
Sets the type of CODEC to be used for Audio decoding.
Definition: stbdpc.c:7846
void STB_DPSetPolarity(U8BIT path, E_STB_DP_POLARITY pol)
Writes polarity value into decode path store.
Definition: stbdpc.c:6124
void STB_DPSetADEnabled(U8BIT path, BOOLEAN state)
Writes the AD Audio into decode path store. To be set to ON or OFF. The exact ON state is depends if ...
Definition: stbdpc.c:3371
void STB_DPStartDecoding(U8BIT path)
Requests start of channel decoding process.
Definition: stbdpc.c:2686
void * STB_GetMemory(U32BIT bytes)
Attempts to allocate memory from the heap.
Definition: stbheap.c:221
void STB_DPSetDISEQCTone(U8BIT path, E_STB_DP_DISEQC_TONE state)
Sets DiSEqC tone and writes status into decode path store.
Definition: stbdpc.c:4981
void STB_AVChangeADMode(U8BIT path, E_STB_AV_AUDIO_MODE mode)
Configures the audio description channel mode (stereo/left/right) in the case where dual-mono audio i...
void STB_DPStoreDishPosition(U8BIT path, U16BIT count)
Stores sat dish position as given DiSEqC index number, or pulse count.
Definition: stbdpc.c:5833
U8BIT STB_DPGetPathDemux(U8BIT path)
Returns the demux path ID acquired by the given decode path.
Definition: stbdpc.c:1711
U8BIT STB_DPGetTerrPLP(U8BIT path)
Reads the terrestrial T2 PLP id from decode path store.
Definition: stbdpc.c:6709
void STB_DPReleaseCISlotFromPath(U8BIT path)
Release the CI slot associated with the given path.
Definition: stbdpc.c:1051
E_STB_DP_TTYPE STB_DPGetTerrType(U8BIT path)
Reads the terrestrial tuner type from decode path store.
Definition: stbdpc.c:6643
void STB_DPSetTerrFreqOff(U8BIT path, S8BIT offset)
Writes terrestrial frequency offset value into decode path store.
Definition: stbdpc.c:6543
void STB_TuneSetModulation(U8BIT path, E_STB_TUNE_MODULATION modulation)
Sets the type of modulation for the specified tuner.
BOOLEAN STB_DPGetNetworkSearch(U8BIT path)
Reads the SI network search flag state from decode path store.
Definition: stbdpc.c:4304
U8BIT STB_DPAcquirePlaybackPath(void *service)
Acquires a decode path and all the required resources (demux, audio and video decoders) for playing b...
Definition: stbdpc.c:679
void STB_RESReleaseAudioDecoder(U8BIT decoder_id)
Releases a previously acquired audio decoder.
Definition: stbresmgr.c:933
void STB_DPSetTerrMode(U8BIT path, E_STB_DP_TMODE mode)
Writes terrestrial tuning mode value into decode path store.
Definition: stbdpc.c:6413
BOOLEAN STB_DPGetSearchMode(U8BIT path)
Reads the SI search mode flag state from decode path store.
Definition: stbdpc.c:4004
void STB_DPSetVideoPID(U8BIT path, U16BIT pid)
Writes video PID value into decode path store.
Definition: stbdpc.c:7079
U8BIT STB_HWGetTunerPaths(void)
Returns the number of front end (Tuner) paths on the platform.
void STB_RESSetTunerDisabled(U8BIT tuner_id, BOOLEAN disable)
Set the disable state for a tuner. When disabled, a tuner will be ignored when acquiring a new tuner ...
Definition: stbresmgr.c:457
E_STB_SI_STATUS STB_SITerrGetStatus(U8BIT path)
Reads the SI status.
Definition: stbsiflt.c:2175
void STB_DPReleaseDecoders(U8BIT path)
Releases all decoders from the given path.
Definition: stbdpc.c:891
E_STB_DP_LNB_POWER STB_DPGetLNBPower(U8BIT path)
Reads the LNB power status from decode path store.
Definition: stbdpc.c:4466
U8BIT STB_DPGetUnicableParams(U8BIT path, U32BIT unicable_if[MAX_UNICABLE_BANKS], U32BIT *lnb_lo_freq, U32BIT *lnb_hi_freq)
Interrogates Unicable LNB for its user and local oscillator frequencies.
Definition: stbdpc.c:5180
BOOLEAN STB_RESCanTuneToTransport(E_STB_DP_SIGNAL_TYPE tuner_type, void *transport)
Returns whether there&#39;s a tuner available to tune to the given transport.
Definition: stbresmgr.c:633
E_STB_DP_TBWIDTH STB_DPGetTerrBandwidth(U8BIT path)
Reads the terrestrial frequency offset value from decode path store.
Definition: stbdpc.c:6511
void STB_DPSetFEC(U8BIT path, E_STB_DP_FEC fec)
Writes FEC value into decode path store.
Definition: stbdpc.c:6254
BOOLEAN STB_DPGetFTASearch(U8BIT path)
Reads the SI FTA chan search flag state from decode path store.
Definition: stbdpc.c:4182
void STB_DPSetAnalogFreqOff(U8BIT path, S8BIT offset)
Writes analogue frequency offset value into decode path store.
Definition: stbdpc.c:6873
U16BIT STB_DPGetVideoPID(U8BIT path)
Reads the video PID value from decode path store.
Definition: stbdpc.c:7113
E_STB_DP_CMODE STB_DPGetCableMode(U8BIT path)
Reads the cable tuning mode value from decode path store.
Definition: stbdpc.c:6776
U8BIT STB_DPAcquireTunerPath(E_STB_DP_SIGNAL_TYPE tuner_type, void *service, void *transport, E_STB_DP_RES_OWNER owner, E_STB_DP_PRIORITY priority, BOOLEAN with_decoders, BOOLEAN for_recording)
Acquires a decode path and all the required resources (tuner, demux, audio and video decoders)...
Definition: stbdpc.c:558
U32BIT STB_OSGetClockDiff(U32BIT timestamp)
Get Difference between Given Time and Current Time.
void STB_DPSetTunedTransport(U8BIT path, void *transport)
Saves the given transport with the specified decode path.
Definition: stbdpc.c:1518
E_STB_DP_SIGNAL_TYPE STB_DPGetSignalType(U8BIT path)
Reads the signal type value from decode path store.
Definition: stbdpc.c:3836
Header file - macros and function prototypes for public use.
void STB_DPStartSI(U8BIT path)
Requests start of SI engine, mode is determined by flags in general control.
Definition: stbdpc.c:2934
void * STB_OSCreateSemaphore(void)
Create a Semaphore.
U32BIT STB_DPGetSIRequestParam3(U8BIT path)
Returns parameters for previous SI request.
Definition: stbdpc.c:3279
BOOLEAN STB_DPGetTVSearch(U8BIT path)
Reads the SI TV chan search flag state from decode path store.
Definition: stbdpc.c:4060
void STB_DPSetTunerDisabled(U8BIT path, BOOLEAN disabled)
Disables/enables the tuner associated with this decode path.
Definition: stbdpc.c:1671
U8BIT STB_DPPathForVideoDecoder(U8BIT decoder_num)
Returns the decode path that is using the given video decoder.
Definition: stbdpc.c:1490
void STB_DPSetDishPosition(U8BIT path, U16BIT count)
Writes sat dish position value into decode path store.
Definition: stbdpc.c:5886
void STB_DPSetAudioStatus(U8BIT path, E_STB_DP_DECODE_STATUS state)
Writes the audio status into decode path store.
Definition: stbdpc.c:3617
void STB_DPStopRecording(U8BIT path)
Requests stop of recording on specified path.
Definition: stbdpc.c:2164
void STB_RESSetTunerOwner(U8BIT tuner_id, E_STB_DP_RES_OWNER owner)
Sets the owner of the tuner.
Definition: stbresmgr.c:532
U32BIT STB_TuneGetMinTunerFreqKHz(U8BIT path)
Returns the minimum tuner frequency in KHz.
void STB_DPSetPCRPID(U8BIT path, U16BIT pid)
Writes PCR PID value into decode path store.
Definition: stbdpc.c:7013
void STB_DPSetUnicablePositionB(U8BIT path, BOOLEAN position_b)
Sets whether to use the alternate satellite position (Position B)
Definition: stbdpc.c:5258
U8BIT STB_DPGetLivePath(void)
Returns the ID of the decode path being used for live viewing.
Definition: stbdpc.c:1271
void STB_DPSetADMode(U8BIT path, E_STB_DP_AUDIO_MODE mode)
Writes AD mode value into decode path store.
Definition: stbdpc.c:7454
void STB_DPSetDISEQCCSwitch(U8BIT path, E_STB_DP_DISEQC_CSWITCH state)
Sets DiSEqC committed switch and writes status into decode path store.
Definition: stbdpc.c:4851
U8BIT STB_RESAcquireADDecoder(void)
Acquires an AD decoder and marks it as used.
Definition: stbresmgr.c:841
BOOLEAN STB_DPReleasePath(U8BIT path, E_STB_DP_RES_OWNER owner)
Releases the decode path and all resources no longer needed. The path won&#39;t be released if the path i...
Definition: stbdpc.c:785
U32BIT STB_DPGetUnicableFrequency(U8BIT path)
Gets the currently set Unicable (IF) frequency.
Definition: stbdpc.c:5406
void STB_AVStopAudioDecoding(U8BIT decoder)
Stops audio decoding on the given audio path.
void STB_DPSetLNB22k(U8BIT path, BOOLEAN state)
Sets LNB 22kHz on or off and writes status into decode path store.
Definition: stbdpc.c:4590
void STB_DPSetTerrPLP(U8BIT path, U8BIT plp_id)
Sets terrestrial T2 PLP id into decode path store.
Definition: stbdpc.c:6675
void STB_DMXChangeDecodePIDs(U8BIT path, U16BIT pcr_pid, U16BIT video_pid, U16BIT audio_pid, U16BIT text_pid, U16BIT data_pid, U16BIT ad_pid)
Changes the packet IDs for the PCR Video, Audio, Text and Data.
BOOLEAN STB_DPGetLNB12v(U8BIT path)
Reads the status of LNB 12v from decode path store.
Definition: stbdpc.c:4697
void STB_DPSetVideoStatus(U8BIT path, E_STB_DP_DECODE_STATUS state)
Writes the video status into decode path store.
Definition: stbdpc.c:3710
void * STB_DPGetTunedTransport(U8BIT path)
Returns the transport saved with the given decode path.
Definition: stbdpc.c:1537
void STB_DPSetDISEQCSMATV(U8BIT path, BOOLEAN state)
Enables/disables DiSEqC SMATV and writes status into decode path store.
Definition: stbdpc.c:5046
void STB_DMXGetDemuxSource(U8BIT path, E_STB_DMX_DEMUX_SOURCE *source, U8BIT *param)
Gets the current source of a given demux.
void STB_AVStopADDecoding(U8BIT decoder)
Stops decoding audio description on the given audio path.
BOOLEAN STB_DPSetVideoCodec(U8BIT path, E_STB_DP_VIDEO_CODEC codec)
Sets the type of CODEC to be used for Video decoding.
Definition: stbdpc.c:7638
BOOLEAN STB_DPStartRecording(U8BIT path, U32BIT param)
Requests start of recording on specified path.
Definition: stbdpc.c:2112
U8BIT STB_TuneSatGetCarrierStrength(U8BIT path, U32BIT freq)
Returns the carrier signal strength as a percentage.
BOOLEAN STB_DPGetLockMode(U8BIT path)
Reads the lock mode value from decode path store.
Definition: stbdpc.c:7611
BOOLEAN STB_DPUseCISlotWithPath(U8BIT path, U8BIT slot_id)
Use the given CI slot with the given path.
Definition: stbdpc.c:1011
BOOLEAN STB_DPAcquireCADescramblerForPath(U8BIT path, U8BIT *pmt_data, U32BIT *ca_handle)
Acquire a CA descrambler and assign it to the given path.
Definition: stbdpc.c:1147
U32BIT STB_DPGetSIRequestParam1(U8BIT path)
Returns parameters for previous SI request.
Definition: stbdpc.c:3229
void STB_DPSetADPID(U8BIT path, U16BIT pid)
Writes AD PID value into decode path store.
Definition: stbdpc.c:7211
U8BIT STB_RESAcquireDemux(U8BIT demux_id, U16BIT caps)
Acquires a demux path and marks it as being used.
Definition: stbresmgr.c:702
void STB_DPSetADStatus(U8BIT path, E_STB_DP_DECODE_STATUS state)
Writes the AD status into decode path store.
Definition: stbdpc.c:3524
U16BIT STB_DPGetSkewPosition(U8BIT path)
Reads the sat skew position value from decode path store.
Definition: stbdpc.c:6027
void STB_DPSetAudioMode(U8BIT path, E_STB_DP_AUDIO_MODE mode)
Writes audio mode value into decode path store.
Definition: stbdpc.c:7519
U8BIT STB_DPGetNumPaths(void)
Returns the maximum number of decode paths.
Definition: stbdpc.c:532
Header file - Function prototypes for A/V control.
void STB_DPReleaseCADescramblerFromPath(U8BIT path)
Release the CA descrambler associated with the given path.
Definition: stbdpc.c:1220
U8BIT STB_DPPathForAudioDecoder(U8BIT decoder_num)
Returns the decode path that is using the given audio decoder.
Definition: stbdpc.c:1436
E_STB_DP_TUNE_STATUS STB_DPGetTuneStatus(U8BIT path)
Reads the tuning status from decode path store.
Definition: stbdpc.c:3332
void STB_DMXSetDemuxSource(U8BIT path, E_STB_DMX_DEMUX_SOURCE source, U8BIT param)
Configures the source of the demux.
void STB_OSSemaphoreSignal(void *semaphore)
Signal a Semaphore to Release it by decrementing its counter.
BOOLEAN STB_DPGetUnicablePositionB(U8BIT path)
Gets whether Satellite Position B is currently set.
Definition: stbdpc.c:5286
void STB_TuneSetPLP(U8BIT path, U8BIT plp)
Sets the Physical Layer Pipe to be acquired.
void STB_TuneSetLNBVoltage(U8BIT path, E_STB_TUNE_LNB_VOLTAGE voltage)
Sets the LNB voltage for the given tuner.
U8BIT STB_DPGetPathVideoDecoder(U8BIT path)
Returns the video decoder ID acquired by the given decode path.
Definition: stbdpc.c:1757
U16BIT STB_DPGetPCRPID(U8BIT path)
Reads the PCR PID value from decode path store.
Definition: stbdpc.c:7047
void * STB_DPGetTunedService(U8BIT path)
Returns the service saved with the given decode path.
Definition: stbdpc.c:1582
void STB_TuneSetPulseLimitWest(U8BIT path, U16BIT count)
Sets the pulse limit for the west.
void STB_DPSetCableMode(U8BIT path, E_STB_DP_CMODE mode)
Writes cable tuning mode value into decode path store.
Definition: stbdpc.c:6743
void STB_CADecodeVideoStatus(U32BIT handle, E_CA_DECODE_STATUS decode_status)
Notifies the CA system of a change in the video decoding state.
Definition: ca_glue.c:243
void STB_AVSetAudioSource(U8BIT path, E_STB_AV_DECODE_SOURCE source, U32BIT param)
Sets the source of the input for the main audio on the given audio decoder path.
void STB_DPRequestSIExtendedEvent(U8BIT path, U32BIT start_date, U32BIT start_hour, U32BIT start_min)
Requests SI engine to get extended event data for specified event.
Definition: stbdpc.c:3169
BOOLEAN STB_PVRStartRecording(U8BIT path, U32BIT handle)
Start the PVR record tasks.
Definition: stbpvr.c:4642
void STB_DPSetTerrType(U8BIT path, E_STB_DP_TTYPE type)
Sets terrestrial tuning type into decode path store.
Definition: stbdpc.c:6608
E_STB_DP_DISEQC_TONE STB_DPGetDISEQCTone(U8BIT path)
Reads the status of DiSEqC tone from decode path store.
Definition: stbdpc.c:5014
void STB_TuneAutoRelock(U8BIT path, BOOLEAN state)
Enables or disabled auto tuner relocking.
BOOLEAN STB_DPIsLivePath(U8BIT path)
Is the given decode path being used for live viewing.
Definition: stbdpc.c:1297
BOOLEAN STB_PVRIsInitialised(void)
Returns Initialised status.
Definition: stbpvr.c:480
U8BIT STB_DPGetUnicableChannel(U8BIT path)
Gets the currently set Unicable Channel (User Band).
Definition: stbdpc.c:5346
void STB_TuneSet22kState(U8BIT path, BOOLEAN state)
Turns the 22 kHz tone on or off.
void STB_DPStartVideoDecoding(U8BIT path)
Requests start of channel decoding process.
Definition: stbdpc.c:2390
void * STB_RESGetTunedTransport(U8BIT tuner_id)
Returns the transport record saved with the specified tuner.
Definition: stbresmgr.c:606
void STB_OSSemaphoreWait(void *semaphore)
Wait on Semaphore Indefinity or Until Released.
Header file - macros and function prototypes for public use.
U8BIT STB_DPGetPathTuner(U8BIT path)
Returns the tuner ID acquired by the given decode path.
Definition: stbdpc.c:1605
void STB_DPSetLockMode(U8BIT path, BOOLEAN mode)
Writes lock mode value into decode path store.
Definition: stbdpc.c:7584
BOOLEAN STB_DPGetDVBS2(U8BIT path)
Returns whether the sat tuner is tuned to DVB-S or DVB-S2.
Definition: stbdpc.c:6338
E_STB_DP_SIGNAL_TYPE STB_RESGetTunerType(U8BIT tuner_id)
Returns the type of the given tuner.
Definition: stbresmgr.c:554
void STB_DPEnableAllTuners(void)
Sets the &#39;disabled&#39; state of all tuners to FALSE so they can all be used by the resource manager...
Definition: stbdpc.c:1652
void STB_ERSendEvent(BOOLEAN latched, BOOLEAN repeat, U16BIT path_class, U16BIT type, void *data, U32BIT data_size)
Sends an event to event reporting control module.
Definition: stberc.c:571
void STB_DPSetTerrBandwidth(U8BIT path, E_STB_DP_TBWIDTH bwidth)
Writes terrestrial bandwidth value into decode path store.
Definition: stbdpc.c:6478
void STB_DPSetLockEnable(U8BIT path, BOOLEAN state)
Writes lock enable flag into decode path store.
Definition: stbdpc.c:3931
void STB_TuneChangeSkewPosition(U8BIT path, U16BIT count)
Changes the value of skew position count.
BOOLEAN STB_DPGetScramSearch(U8BIT path)
Reads the SI scram chan search flag state from decode path store.
Definition: stbdpc.c:4243
void * STB_DPGetOwnerData(U8BIT path, U32BIT *data_size)
Returns the owner data saved with the path. This data should not be freed.
Definition: stbdpc.c:1993
BOOLEAN STB_AVSetAudioCodec(U8BIT path, E_STB_AV_AUDIO_CODEC codec)
Sets the audio codec to be used when decoding audio with the given audio decoder path.
void STB_DPSetOwner(U8BIT path, E_STB_DP_RES_OWNER owner)
Sets the owner of the given path.
Definition: stbdpc.c:1885
void STB_DPSetDISEQCRepeats(U8BIT path, U8BIT count)
Sets DiSEqC repeats and writes value into decode path store.
Definition: stbdpc.c:5111
void STB_DPSetTuneRelock(U8BIT path, BOOLEAN state)
Writes tuner auto relock flag into decode path store.
Definition: stbdpc.c:3868
E_STB_DP_AUDIO_CODEC STB_DPGetAudioCodec(U8BIT path)
Returns the type of CODEC to be used for Audio decoding.
Definition: stbdpc.c:7925
BOOLEAN STB_AVSetVideoCodec(U8BIT path, E_STB_AV_VIDEO_CODEC codec)
Sets the video codec to be used when decoding video with the given video decoder path.
BOOLEAN STB_RESIsTunerDisabled(U8BIT tuner_id)
Returns whether a tuner has been disabled or not.
Definition: stbresmgr.c:479
void STB_DPCentreDishMove(U8BIT path)
Moves dish to centre.
Definition: stbdpc.c:5792
void STB_DPSetSignalType(U8BIT path, E_STB_DP_SIGNAL_TYPE sigtype)
Writes signal type value into decode path store.
Definition: stbdpc.c:3803
void STB_DPStartAudioDecoding(U8BIT path)
Requests start of channel decoding process.
Definition: stbdpc.c:2585
void STB_PVRStopRecording(U8BIT path)
Stop the PVR recording.
Definition: stbpvr.c:4858
void STB_DMXChangeTextPID(U8BIT path, U16BIT text_pid)
Changes just the teletext PID.
void STB_CADescrambleServiceStop(U32BIT handle)
This function will be called when decoding of a service is stopped.
Definition: ca_glue.c:144
U8BIT STB_DPGetNumEnabledTuners(void)
Returns the number of enabled tuners (i.e. that haven&#39;t been disabled)
Definition: stbdpc.c:1687
U8BIT STB_DPPathForADDecoder(U8BIT decoder_num)
Returns the decode path that is using the given AD decoder.
Definition: stbdpc.c:1463
E_STB_DP_DECODE_STATUS STB_DPGetAudioStatus(U8BIT path)
Reads the audio status from decode path store.
Definition: stbdpc.c:3674
BOOLEAN STB_DPGetPulsePosition(U8BIT path)
Reads the status of pulse positioning from decode path store.
Definition: stbdpc.c:4758
void STB_TuneSetPulseLimitEast(U8BIT path, U16BIT count)
Sets the pulse limit for the east.
void STB_DPStopVideoDecoding(U8BIT path)
Requests stop of channel decoding (blanks screen).
Definition: stbdpc.c:2719
void STB_DPSetDecodePIDs(U8BIT path, U16BIT pcr_pid, U16BIT video_pid, U16BIT audio_pid, U16BIT text_pid, U16BIT data_pid, U16BIT AD_pid)
Definition: stbdpc.c:7414
BOOLEAN STB_DPCanTuneTo(E_STB_DP_SIGNAL_TYPE tuner_type, void *service, void *transport)
Checks whether there&#39;s a tuner available to tune to the given service or transport.
Definition: stbdpc.c:1830
void STB_DPStartScan(U8BIT path)
Requests start of tuning signal scan process.
Definition: stbdpc.c:2270
U16BIT STB_DPGetADPID(U8BIT path)
Reads the audio PID value from decode path store.
Definition: stbdpc.c:7256
void STB_FreeMemory(void *addr)
Releases previously allocated heap memory.
Definition: stbheap.c:336
void STB_AVSetVideoSource(U8BIT path, E_STB_AV_DECODE_SOURCE source, U32BIT param)
Sets the source of the input to the given video decoder path.
U8BIT STB_HWGetVideoDecodePaths(void)
Returns the number of video decoding paths on the platform.
void STB_DPSetTunedService(U8BIT path, void *service)
Saves the given service with the specified decode path.
Definition: stbdpc.c:1563
void STB_DPSetDISEQCPosition(U8BIT path, BOOLEAN state)
Enables/disables DiSEqC positioning and writes status into decode path store.
Definition: stbdpc.c:4790
void STB_DPSetLNBPower(U8BIT path, E_STB_DP_LNB_POWER state)
Sets LNB power on or off and writes status into decode path store.
Definition: stbdpc.c:4433
BOOLEAN STB_CAAcquireDescrambler(U8BIT demux, U16BIT serv_id, U16BIT *ca_ids, U16BIT num_ca_ids, U32BIT *handle)
This function is used by the resource manager to acquire a CA descrambler that&#39;s able to descramble a...
Definition: ca_glue.c:87
void STB_DPSetLNB12v(U8BIT path, BOOLEAN state)
Sets LNB 12v on or off and writes status into decode path store.
Definition: stbdpc.c:4664
U16BIT STB_TuneGetPulsePosition(U8BIT path)
Returns the current pulse position.
void STB_DPSetDISEQCUSwitch(U8BIT path, U8BIT state)
Sets DiSEqC uncommitted switch and writes status into decode path store.
Definition: stbdpc.c:4916
E_STB_DP_DECODE_STATUS STB_DPGetADStatus(U8BIT path)
Reads the AD status from decode path store.
Definition: stbdpc.c:3581
BOOLEAN STB_DPIsDecodingPath(U8BIT path)
Is the given decode path being used for decoding.
Definition: stbdpc.c:1346
void STB_DPSetAdditionalFrequencies(U8BIT path, U8BIT num_freqs, U32BIT *frequencies)
Sets an array of frequencies that can be tried when tuning to a transport if the tuner fails to lock ...
Definition: stbdpc.c:6933
U8BIT STB_DPGetDISEQCUSwitch(U8BIT path)
Reads the status of DiSEqC uncommitted switch from decode path store.
Definition: stbdpc.c:4949
Debug functions header file.
void STB_DPSetTuneStatus(U8BIT path, E_STB_DP_TUNE_STATUS state)
Writes the tuning status into decode path store.
Definition: stbdpc.c:3304
Header file - macros and function prototypes for public use.
void STB_DPStopAudioDecoding(U8BIT path)
Requests stop of channel decoding.
Definition: stbdpc.c:2846
E_STB_DP_AD_AUDIO STB_DPGetADAudio(U8BIT path)
Reads the AD audio status from decode path store.
Definition: stbdpc.c:3487
U16BIT STB_DPGetTextPID(U8BIT path)
Reads the teletext PID value from decode path store.
Definition: stbdpc.c:7323
E_STB_DP_AUDIO_CODEC STB_DPGetADCodec(U8BIT path)
Returns the type of CODEC to be used for AD decoding.
Definition: stbdpc.c:7816
void STB_AVStartVideoDecoding(U8BIT path)
Starts video decoding on the given video path.
void STB_TuneStopTuner(U8BIT path)
Stops any locking attempt, or unlocks if locked.
void STB_AVStopVideoDecoding(U8BIT decoder)
Stops video decoding on the given video path. The video is not expected to be blanked.
E_STB_DP_POLARITY STB_DPGetPolarity(U8BIT path)
Reads the polarity value from decode path store.
Definition: stbdpc.c:6157
U8BIT STB_RESAcquireAudioDecoder(void)
Acquires an audio decoder and marks it as used.
Definition: stbresmgr.c:896
U32BIT STB_DPGetSIRequestParam2(U8BIT path)
Returns parameters for previous SI request.
Definition: stbdpc.c:3254
void STB_DPEnableDishLimits(U8BIT path, U16BIT ecount, U16BIT wcount)
Enables sat dish limits.
Definition: stbdpc.c:5527
void STB_DPReleaseAllPaths(void)
Releases all decode paths and all the resources they are using.
Definition: stbdpc.c:933
U16BIT STB_DPGetSymbolRate(U8BIT path)
Reads the symbol rate value from decode path store.
Definition: stbdpc.c:6222
E_STB_DP_ANALOG_VIDEO_TYPE STB_DPGetAnalogVideoType(U8BIT path)
Reads the analogue video type value from decode path store.
Definition: stbdpc.c:6841
U32BIT STB_TuneGetMaxTunerFreqKHz(U8BIT path)
Returns the maximum tuner frequency in KHz.
void STB_DPSetAnalogVideoType(U8BIT path, E_STB_DP_ANALOG_VIDEO_TYPE vtype)
Writes analogue video type into decode path store.
Definition: stbdpc.c:6808
void STB_DPSetFTASearch(U8BIT path, BOOLEAN state)
Writes SI FTA chan search flag into decode path store.
Definition: stbdpc.c:4153
void STB_RESReleaseADDecoder(U8BIT decoder_id)
Releases a previously acquired AD decoder.
Definition: stbresmgr.c:875
void STB_DPGetDecodeSource(U8BIT path, E_STB_DP_DECODE_SOURCE *source, U32BIT *param)
Gets source for specified decoder.
Definition: stbdpc.c:2087
void STB_CADescrambleServiceStart(U32BIT handle)
This function will be called when decoding of a service is about to start and there&#39;s an associated d...
Definition: ca_glue.c:129
U8BIT STB_DPPathForTuner(U8BIT start_path, U8BIT tuner_num)
Returns the decode path that is using the given tuner ID.
Definition: stbdpc.c:1400
void STB_DPStopDishMove(U8BIT path)
Stops sat dish moving.
Definition: stbdpc.c:5748
Header file - Function prototypes for Event Reporting.
U8BIT STB_DPIsCISlotInUse(U8BIT start_path, U8BIT slot_id, U8BIT ignore_path)
Checks whether a given CI slot is in use.
Definition: stbdpc.c:1109
U32BIT STB_DPGetFrequency(U8BIT path)
Reads the frequency value from decode path store.
Definition: stbdpc.c:6092
BOOLEAN STB_DPGetRadioSearch(U8BIT path)
Reads the SI radio chan search flag state from decode path store.
Definition: stbdpc.c:4121
void STB_DPSetTVSearch(U8BIT path, BOOLEAN state)
Writes SI TV chan search flag into decode path store.
Definition: stbdpc.c:4031
U8BIT STB_HWGetAudioDecodePaths(void)
Returns the number of audio decoding paths on the platform.
Glue layer between DVB and conditional access systems.
void STB_DPSetDVBS2(U8BIT path, BOOLEAN dvb_s2)
Set whether the satellite should be tuned to DVB-S/S2 for the tuner in the given decode path...
Definition: stbdpc.c:6312
void STB_RESReleaseDemux(U8BIT demux_id)
Releases a previously acquired demux path.
Definition: stbresmgr.c:770
void STB_DPTuneOff(U8BIT path)
Requests stop of tuning and powers down tuner.
Definition: stbdpc.c:2331
void STB_DPSetPulsePosition(U8BIT path, BOOLEAN state)
Enables/disables pulse positioning and writes status into decode path store.
Definition: stbdpc.c:4729
BOOLEAN STB_DPSetOwnerData(U8BIT path, void *data, U32BIT data_size)
Saves a copy of the given data with the path. If data is passed as NULL and owner data already exists...
Definition: stbdpc.c:1911
E_STB_DP_LNB_TYPE STB_DPGetLNBType(U8BIT path)
Reads the LNB type value from decode path store.
Definition: stbdpc.c:4531
E_STB_DP_AUDIO_MODE STB_DPGetADMode(U8BIT path)
Reads the AD mode value from decode path store.
Definition: stbdpc.c:7487
void STB_TuneSetSystemType(U8BIT path, E_STB_TUNE_SYSTEM_TYPE type)
Set the demodulator&#39;s signal type. This function must be called before each call to STB_TuneStartTune...
void STB_AVStartADDecoding(U8BIT decoder)
Starts decoding audio description on the given audio path.
BOOLEAN STB_DPSetADCodec(U8BIT path, E_STB_DP_AUDIO_CODEC codec)
Sets the type of CODEC to be used for AD decoding.
Definition: stbdpc.c:7745
E_STB_DP_FEC STB_DPGetFEC(U8BIT path)
Reads the FEC value from decode path store.
Definition: stbdpc.c:6287
E_STB_DP_VIDEO_CODEC STB_DPGetVideoCodec(U8BIT path)
Returns the type of CODEC to be used for Video decoding.
Definition: stbdpc.c:7705
Header file - Function prototypes for operating system.
U16BIT STB_DPGetAudioPID(U8BIT path)
Reads the audio PID value from decode path store.
Definition: stbdpc.c:7179
System Wide Global Technical Data Type Definitions.
BOOLEAN STB_AVSetADCodec(U8BIT path, E_STB_AV_AUDIO_CODEC codec)
Sets the codec to be used for audio description when decoding audio with the given audio decoder path...
E_STB_DP_SIGNAL_TYPE STB_DPGetPathTunerType(U8BIT path)
Returns the tuner type for the given path.
Definition: stbdpc.c:1628
STB middleware resource management module header file.
void STB_DPSetAudioPID(U8BIT path, U16BIT pid)
Writes audio PID value into decode path store.
Definition: stbdpc.c:7145
S8BIT STB_DPGetTerrFreqOff(U8BIT path)
Reads the terrestrial frequency offset value from decode path store.
Definition: stbdpc.c:6576
Header file - macros and function prototypes for public use.
void STB_TuneSet12VSwitch(U8BIT path, BOOLEAN state)
Sets the 12V switch for the given tuner.
void STB_DPSetSymbolRate(U8BIT path, U16BIT sym)
Writes symbol rate value into decode path store.
Definition: stbdpc.c:6189
E_STB_DP_TMODE STB_DPGetTerrMode(U8BIT path)
Reads the terrestrial tuning mode value from decode path store.
Definition: stbdpc.c:6446
void STB_DPStopSI(U8BIT path)
Requests stop of SI engine.
Definition: stbdpc.c:3076
void STB_CADecodeAudioStatus(U32BIT handle, E_CA_DECODE_STATUS decode_status)
Notifies the CA system of a change in the audio decoding state.
Definition: ca_glue.c:260
BOOLEAN STB_PVRIsRecording(U8BIT path, U32BIT *handle)
Reads the PVR record status.
Definition: stbpvr.c:4938
BOOLEAN STB_DPIsOwnedBy(U8BIT path, E_STB_DP_RES_OWNER owner)
Checks whether the path is owned by the given owner.
Definition: stbdpc.c:1966
U8BIT STB_DPGetPathAudioDecoder(U8BIT path)
Returns the audio decoder ID acquired by the given decode path.
Definition: stbdpc.c:1734
void STB_DPSetNetworkSearch(U8BIT path, BOOLEAN state)
Writes SI network search flag into decode path store.
Definition: stbdpc.c:4275
void STB_AVStartAudioDecoding(U8BIT decoder)
Starts audio decoding on the given audio path.
U8BIT STB_DPGetPathSecondaryVideoDecoder(U8BIT path)
Returns the secondary video decoder ID acquired by the given decode path.
Definition: stbdpc.c:1781
BOOLEAN STB_DPGetDISEQCSMATV(U8BIT path)
Reads the status of DiSEqC SMATV from decode path store.
Definition: stbdpc.c:5079
U8BIT STB_RESAcquireVideoDecoder(void)
Acquires a video decoder and marks it as used.
Definition: stbresmgr.c:968
E_STB_DP_DECODE_STATUS STB_DPGetVideoStatus(U8BIT path)
Reads the video status from decode path store.
Definition: stbdpc.c:3767
void STB_AVChangeAudioMode(U8BIT path, E_STB_AV_AUDIO_MODE mode)
Configures the main audio channel mode (stereo/left/right) in the case where dual-mono audio is used...
E_STB_DP_DISEQC_CSWITCH STB_DPGetDISEQCCSwitch(U8BIT path)
Reads the status of DiSEqC committed switch from decode path store.
Definition: stbdpc.c:4884
Header file - macros and function prototypes for public use.
U16BIT STB_SIGetPmtCaIdDescArray(U8BIT *pmt_data, U16BIT **pmt_ca_ids)
Parses the given PMT to produce an array of the CA system IDs required by the service or streams on t...
Definition: stbsitab.c:13038
BOOLEAN STB_DPIsRecordingPath(U8BIT path)
Is the given decode path being used for recording.
Definition: stbdpc.c:1320
BOOLEAN STB_DPGetTuneRelock(U8BIT path)
Reads the tuner auto relock flag state from decode path store.
Definition: stbdpc.c:3899
Header file - Function prototypes for heap memory.
BOOLEAN STB_DPGetLockEnable(U8BIT path)
Reads the lock enable flag state from decode path store.
Definition: stbdpc.c:3954
void STB_DPInitialise(void)
Initialises decode path control and sets up the structures for restricting access to resources...
Definition: stbdpc.c:331
S8BIT STB_DPGetAnalogFreqOff(U8BIT path)
Reads the analogue frequency offset value from decode path store.
Definition: stbdpc.c:6906
void STB_DPSetDishLimitW(U8BIT path)
Sets current sat dish position as West limit.
Definition: stbdpc.c:5481
U8BIT STB_DPGetMHEGPath(void)
Returns the path for Cabot MHEG software to use.
Definition: stbdpc.c:1873
void STB_RESSetTunedTransport(U8BIT tuner_id, void *t_ptr)
Saves the transport pointer with the specified tuner.
Definition: stbresmgr.c:583
void STB_DPSetOTASearchMode(U8BIT path, E_STB_OTA_SW_UPGRADE_SEARCH_MODE mode)
Sets the &#39;Over The Air&#39; Software Upgrade Search Mode for a given path.
Definition: stbdpc.c:4338
BOOLEAN STB_DPGetDISEQCPosition(U8BIT path)
Reads the status of DiSEqC positioning from decode path store.
Definition: stbdpc.c:4819
E_STB_DP_MODULATION STB_DPGetModulation(U8BIT path)
Returns the satellite modulation type for the give decode path.
Definition: stbdpc.c:6385
void STB_DPStartDishMoveE(U8BIT path, U16BIT count)
Starts sat dish moving east.
Definition: stbdpc.c:5615
void STB_DPSetScramSearch(U8BIT path, BOOLEAN state)
Writes SI scram chan search flag into decode path store.
Definition: stbdpc.c:4214
E_STB_DP_AUDIO_MODE STB_DPGetAudioMode(U8BIT path)
Reads the audio mode value from decode path store.
Definition: stbdpc.c:7552
void STB_DPSetLNBType(U8BIT path, E_STB_DP_LNB_TYPE type)
Writes LNB type value into decode path store.
Definition: stbdpc.c:4498
U16BIT STB_DPGetDishRequest(U8BIT path)
Reads the sat dish position value from decode path store.
Definition: stbdpc.c:5962
U16BIT STB_DPGetDataPID(U8BIT path)
Reads the data PID value from decode path store.
Definition: stbdpc.c:7389
void STB_SIReleaseCaIdDescArray(U16BIT *desc_array, U8BIT num_entries)
Frees the memory used by the descriptor array specified.
Definition: stbsitab.c:12090
U8BIT STB_DPGetPathCISlot(U8BIT path)
Returns the CI slot id associated with the given path.
Definition: stbdpc.c:1082
void STB_DPStartDishMoveW(U8BIT path, U16BIT count)
Starts sat dish moving west.
Definition: stbdpc.c:5683
void STB_DPSetSearchMode(U8BIT path, BOOLEAN state)
Writes SI search mode flag into decode path store.
Definition: stbdpc.c:3981
void STB_DPSetDecodeSource(U8BIT path, E_STB_DP_DECODE_SOURCE source, U32BIT param)
Sets source for specified decoder.
Definition: stbdpc.c:2021
void STB_SITerrSendEvent(U8BIT path, U32BIT events)
Sends an event to STB layer SI Terrestrial engine.
Definition: stbsiflt.c:2140
void STB_OSTaskDelay(U16BIT timeout)
Delay Task for Specifed Time Period.
BOOLEAN STB_DPTryAdditionalFrequency(U8BIT tuner_num)
Checks to see if there&#39;s an additional frequency available on the given decode path that hasn&#39;t yet b...
Definition: stbdpc.c:6973
U8BIT STB_RESNumEnabledTuners(void)
Returns the number of tuners that aren&#39;t disabled.
Definition: stbresmgr.c:506
void STB_RESReleaseTuner(U8BIT tuner_id, BOOLEAN high_priority, E_STB_DP_RES_OWNER owner)
Releases a tuner that has previously been acquired.
Definition: stbresmgr.c:404
Header file - Function prototypes for Demux control.
U8BIT STB_HWGetDemuxPaths(void)
Queries the number of demux paths available.
void STB_AVSetADSource(U8BIT path, E_STB_AV_DECODE_SOURCE source, U32BIT param)
Sets the source of the input for the audio description audio on the given audio decoder path...
U8BIT STB_DPAcquireCISlotForPath(U8BIT path, U8BIT *pmt_data, U8BIT *ci_protection_desc)
Acquire a CI slot and assign it to the given path.
Definition: stbdpc.c:956
U32BIT STB_OSGetClockMilliseconds(void)
Get Current Computer Clock Time.
void STB_DPStopDecoding(U8BIT path)
Requests stop of channel decoding (blanks screen).
Definition: stbdpc.c:2910
U16BIT STB_DPGetDishPosition(U8BIT path)
Reads the actual sat dish position value.
Definition: stbdpc.c:5925
BOOLEAN STB_DPGetPathCADescrambler(U8BIT path, U32BIT *handle)
Get the handle of the CA descrambler associated with the given path.
Definition: stbdpc.c:1244
void STB_DPSetSkewPosition(U8BIT path, U16BIT count)
Writes sat skew position value into decode path store.
Definition: stbdpc.c:5994
BOOLEAN STB_DPIsTunerEnabled(U8BIT tuner_num)
Returns the &#39;enabled&#39; status for the given tuner number.
Definition: stbdpc.c:1699
void STB_AVBlankVideo(U8BIT path, BOOLEAN blank)
Blanks or unblanks the video display.
void STB_DPSetUnicableChannel(U8BIT path, U8BIT chan)
Sets the current Unicable Channel (User Band).
Definition: stbdpc.c:5318
void STB_TuneStartTuner(U8BIT path, U32BIT freq, U32BIT srate, E_STB_TUNE_FEC fec, S8BIT freq_off, E_STB_TUNE_TMODE tmode, E_STB_TUNE_TBWIDTH tbwidth, E_STB_TUNE_CMODE cmode, E_STB_TUNE_ANALOG_VIDEO_TYPE anlg_vtype)
Starts the tuner, it will then attempt to lock specified signal. Unrequired parameters can be passed ...
#define DBGPRINT(...)
Definition: dbgfuncs.h:74
U8BIT STB_RESAcquireTuner(E_STB_DP_SIGNAL_TYPE tuner_type, void *transport, E_STB_DP_RES_OWNER owner, BOOLEAN high_priority, BOOLEAN *tuner_taken)
Acquires a tuner. Tuners will be reused if possible.
Definition: stbresmgr.c:297
void STB_CADecodeADStatus(U32BIT handle, E_CA_DECODE_STATUS decode_status)
Notifies the CA system of a change in the AD decoding state.
Definition: ca_glue.c:277
void STB_RESReleaseCISlot(U8BIT slot_id)
Releases a previously acquired CI slot.
Definition: stbresmgr.c:1157
void STB_DPSetDataPID(U8BIT path, U16BIT pid)
Writes data PID value into decode path store.
Definition: stbdpc.c:7355
U8BIT STB_RESTunerUsageCount(U8BIT tuner_id)
Returns the number of paths using the tuner.
Definition: stbresmgr.c:662
void STB_DPStopTune(U8BIT path)
Stops of tuning signal scan and unlocks.
Definition: stbdpc.c:2285
void STB_DPSetRadioSearch(U8BIT path, BOOLEAN state)
Writes SI radio chan search flag into decode path store.
Definition: stbdpc.c:4092
void STB_DPSetTextPID(U8BIT path, U16BIT pid)
Writes teletext PID value into decode path store.
Definition: stbdpc.c:7288
void STB_DPSetFrequency(U8BIT path, U32BIT freq)
Writes frequency value into decode path store.
Definition: stbdpc.c:6059
void STB_DPStopADDecoding(U8BIT path)
Requests stop of channel decoding.
Definition: stbdpc.c:2781
BOOLEAN STB_DPOTASearchEnabled(U8BIT path)
Returns TRUE if the current &#39;Over The Air&#39; Software Upgrade Search Mode is manual or automatic...
Definition: stbdpc.c:4401
U8BIT STB_DPGetPathForService(void *service)
Checks whether any of the paths are tuned to the given service.
Definition: stbdpc.c:1804
void STB_DPStartTune(U8BIT path)
Requests start of tuning process.
Definition: stbdpc.c:2206
void STB_DPSetADAudio(U8BIT path, E_STB_DP_AD_AUDIO ad_audio)
Reads the AD audio status from decode path store.
Definition: stbdpc.c:3452
void STB_DPSetUnicableFrequency(U8BIT path, U32BIT freq)
Sets the Unicable (IF) frequency.
Definition: stbdpc.c:5378
void STB_DPSetUserDefinedLNBBands(U8BIT path, U8BIT number_of_bands, S_STB_DP_LNB_BAND *band_definitions)
Stores the pointer to the array of band definitions for the user defined LNB.
Definition: stbdpc.c:4560
void STB_RESReleaseVideoDecoder(U8BIT decoder_id)
Releases a previously acquired video decoder.
Definition: stbresmgr.c:1005
U8BIT STB_RESGetCISlotUsageCount(U8BIT slot_id)
Returns the number of times the given slot is in use.
Definition: stbresmgr.c:1130
void STB_TuneSetLOFrequency(U8BIT tuner, U16BIT lo_freq)
Sets the local oscillator frequency used by the LNB.
Header file - Function prototypes for tuner control.
BOOLEAN STB_DPIsRecording(U8BIT path, U32BIT *handle)
Returns status of recording on specified path.
Definition: stbdpc.c:2189
U8BIT STB_DPGetDISEQCRepeats(U8BIT path)
Reads the value of DiSEqC repeats from decode path store.
Definition: stbdpc.c:5146
void STB_DPStartADDecoding(U8BIT path)
Requests start of channel decoding process.
Definition: stbdpc.c:2479