source: svn/newcon3bcm2_21bu/magnum/portinginterface/vbi/7552/bvbi_a656.c

Last change on this file was 76, checked in by megakiss, 10 years ago

1W 대기전력을 만족시키기 위하여 POWEROFF시 튜너를 Standby 상태로 함

  • Property svn:executable set to *
File size: 11.6 KB
Line 
1
2/***************************************************************************
3 *     Copyright (c) 2003-2012, Broadcom Corporation
4 *     All Rights Reserved
5 *     Confidential Property of Broadcom Corporation
6 *
7 *  THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE
8 *  AGREEMENT  BETWEEN THE USER AND BROADCOM.  YOU HAVE NO RIGHT TO USE OR
9 *  EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT.
10 *
11 * $brcm_Workfile: bvbi_a656.c $
12 * $brcm_Revision: Hydra_Software_Devel/7 $
13 * $brcm_Date: 2/20/12 2:53p $
14 *
15 * Module Description:
16 *
17 * This module provides access to the ANCI_656 cores for the VBI porting
18 * interface (BVBI).  This module is private to BVBI.
19 *
20 * Revision History:
21 *
22 * $brcm_Log: /magnum/portinginterface/vbi/7420/bvbi_a656.c $
23 *
24 * Hydra_Software_Devel/7   2/20/12 2:53p darnstein
25 * SW7425-2434: more detail in error messages.
26 *
27 * Hydra_Software_Devel/6   2/20/12 12:56p darnstein
28 * SW7425-2434: when an unsupported video format is entered, the BDBG
29 * error message should be informative.
30 *
31 * Hydra_Software_Devel/5   10/1/10 2:35p darnstein
32 * SW7422-46: Adapt to 7422 and 7425 chipsets.
33 *
34 * Hydra_Software_Devel/4   12/21/09 6:58p darnstein
35 * SW7550-120: Add support for SECAM variants.
36 *
37 * Hydra_Software_Devel/3   12/5/08 11:14a darnstein
38 * PR45819: register names were all wrong.
39 *
40 * Hydra_Software_Devel/2   12/4/08 6:07p darnstein
41 * PR45819: 7420 software will now compile, but not link.
42 *
43 * Hydra_Software_Devel/1   12/3/08 8:56p darnstein
44 * PR45819: copied over from 7400 area.
45 *
46 * Hydra_Software_Devel/2   12/3/08 7:56p darnstein
47 * PR45819: New, more modular form of most BVBI source files.
48 *
49 * Hydra_Software_Devel/12   10/10/07 4:00p darnstein
50 * PR35440: handle ancillary VEC and passthrough VEC in the same fashion.
51 * Since there is already a #define macro for modular VEC, this seems
52 * more graceful than before.
53 *
54 * Hydra_Software_Devel/11   2/26/07 2:28p darnstein
55 * PR25990: Some minor changes were required for compiling on 7400-B0.
56 *
57 * Hydra_Software_Devel/10   1/2/07 4:20p darnstein
58 * PR26872: Mechanically add SECAM to all cases where PAL formats are
59 * accepted.
60 *
61 * Hydra_Software_Devel/9   12/14/06 7:19p darnstein
62 * PR25990: Can compile for BCM97400-B0 now.
63 *
64 * Hydra_Software_Devel/8   7/20/06 2:22p darnstein
65 * PR21688: Use the new hardware soft reset scheme for later model chips.
66 *
67 * Hydra_Software_Devel/7   4/12/06 1:56p darnstein
68 * PR18010: Add ANCI656_PRIM_ANCI656_CNTRL setting to the PR18010
69 * backwards compatibility option.
70 *
71 * Hydra_Software_Devel/6   9/23/05 2:47p darnstein
72 * PR13750: Proper use of BERR_TRACE and BERR_CODEs.
73 *
74 * Hydra_Software_Devel/5   8/22/05 8:11p darnstein
75 * PR16057: To support many different chips, use private #defines that
76 * specify number of VECs, VDECs, and (separately) pass-through VECs.
77 *
78 * Hydra_Software_Devel/4   8/8/05 3:07p darnstein
79 * PR16057: Avoid non-existent cores on BCM97401 chip.
80 *
81 * Hydra_Software_Devel/3   3/17/05 6:05p darnstein
82 * PR 14472: Eliminate references to secondary VEC if chip is 3560.
83 *
84 * Hydra_Software_Devel/2   3/14/05 4:16p darnstein
85 * PR 14382: Code DCount value according to D. Perrier, for SMPTE 291M
86 * format.
87 *
88 * Hydra_Software_Devel/1   7/21/04 2:39p darnstein
89 * PR9080: Finish merging ITU-R 656 software to main branch.
90 *
91 * I656/2   7/15/04 5:53p darnstein
92 * Allow choice of sdid field in ancillary data packets written out.  Try
93 * to get dcount field right too.
94 *
95 * I656/1   6/25/04 3:24p darnstein
96 * Initial version.
97 *
98 ***************************************************************************/
99
100#include "bstd.h"                       /* standard types */
101#include "bdbg.h"                       /* Dbglib */
102#include "bvbi.h"                       /* VBI processing, this module. */
103#include "bvbi_priv.h"          /* VBI internal data structures */
104
105#if (BVBI_P_NUM_ANCI656_656 > 0) /** { **/
106
107#include "bchp_anci656_ancil_0.h"       /* RDB info for ANCI_656_656 registers */
108#if (BVBI_P_NUM_ANCI656_656 >= 2)
109#include "bchp_anci656_ancil_1.h"
110#endif
111
112BDBG_MODULE(BVBI);
113
114/***************************************************************************
115* Forward declarations of static (private) functions
116***************************************************************************/
117static void BVBI_P_A656_Enc_Init (BREG_Handle hReg);
118static uint32_t P_GetCoreOffset (uint8_t hwCoreIndex);
119
120
121/***************************************************************************
122* Implementation of "BVBI_" API functions
123***************************************************************************/
124
125
126/***************************************************************************
127* Implementation of supporting VBI_ENC functions that are not in API
128***************************************************************************/
129
130
131BERR_Code BVBI_P_A656_Init( BVBI_P_Handle *pVbi )
132{
133        BDBG_ENTER(BVBI_P_A656_Init);
134
135        /* Initialize ANCI656 cores */
136        BVBI_P_A656_Enc_Init (pVbi->hReg);
137
138        BDBG_LEAVE(BVBI_P_A656_Init);
139        return BERR_SUCCESS;
140}
141
142
143BERR_Code BVBI_P_A656_Enc_Program (
144        BREG_Handle hReg,
145        uint8_t hwCoreIndex,
146        BVBI_P_Encode_656_Options* h656options,
147        bool bPR18010_bad_line_number,
148        BFMT_VideoFmt eVideoFormat)
149{
150/*
151        Programming note: the implementation here assumes that the bitfield layout
152        within registers is the same for all ANCI656 cores in the chip. 
153
154        If a chip is built that has multiple ANCI656 encoder cores that are not
155        identical, then this routine will have to be redesigned.
156*/
157        uint32_t ulCoreOffset;
158        uint32_t ulReg;
159        uint8_t sdid;
160        uint8_t dcountCC;
161        uint8_t dcountTT;
162        uint8_t dcountWSS;
163        bool    isPal;
164
165        BDBG_ENTER(BVBI_P_A656_Enc_Program);
166
167        /* Figure out which encoder core to use */
168        ulCoreOffset = P_GetCoreOffset (hwCoreIndex);
169        if (ulCoreOffset == 0xFFFFFFFF)
170        {
171                /* This should never happen!  This parameter was checked by
172                   BVBI_Encode_Create() */
173                BDBG_LEAVE(BVBI_P_A656_Enc_Program);
174                return BERR_TRACE (BERR_INVALID_PARAMETER);
175        }
176
177        /* Determine whether PAL or NTSC.  The hardware can only handle straight
178           PAL or NTSC, so some of the video standards are "don't cares." */
179        /* Select video format */
180        switch (eVideoFormat)
181        {
182    case BFMT_VideoFmt_eNTSC:
183    case BFMT_VideoFmt_eNTSC_J:
184        case BFMT_VideoFmt_e1080i:
185        case BFMT_VideoFmt_e720p:
186        case BFMT_VideoFmt_e480p:
187                isPal = false;
188                break;
189
190    case BFMT_VideoFmt_ePAL_B:
191    case BFMT_VideoFmt_ePAL_B1:
192    case BFMT_VideoFmt_ePAL_D:
193    case BFMT_VideoFmt_ePAL_D1:
194    case BFMT_VideoFmt_ePAL_G:
195    case BFMT_VideoFmt_ePAL_H:
196    case BFMT_VideoFmt_ePAL_K:
197    case BFMT_VideoFmt_ePAL_I:
198    case BFMT_VideoFmt_ePAL_M:
199    case BFMT_VideoFmt_ePAL_N:
200    case BFMT_VideoFmt_ePAL_NC:
201    case BFMT_VideoFmt_eSECAM_L:
202    case BFMT_VideoFmt_eSECAM_B:
203    case BFMT_VideoFmt_eSECAM_G:
204    case BFMT_VideoFmt_eSECAM_D:
205    case BFMT_VideoFmt_eSECAM_K:
206    case BFMT_VideoFmt_eSECAM_H:
207        case BFMT_VideoFmt_e1080i_50Hz:
208        case BFMT_VideoFmt_e720p_50Hz:
209    case BFMT_VideoFmt_e576p_50Hz:
210                isPal = true;
211                break;
212
213        default:
214                BDBG_LEAVE(BVBI_P_A656_Enc_Program);
215                BDBG_ERR(("BVBI_A656: video format %d not supported", eVideoFormat));
216                return BERR_TRACE (BERR_NOT_SUPPORTED);
217                break;
218        }
219
220        /* Figure out the data ID and length fields for ancillary data packets */
221        /* TODO: some of this is likely wrong, especially SAA7113. */
222        switch (h656options->e656Format)
223        {
224        case BVBI_656Fmt_SAA7113:
225        case BVBI_656Fmt_Modified_SAA7113:
226                dcountCC = (isPal ? 1 : 5);
227                dcountTT = (isPal ? 8 : 12);
228                dcountWSS = 3;
229                break;
230                break;
231        case BVBI_656Fmt_SMPTE291:
232                dcountCC = 1;
233                dcountTT = (isPal ? 21 : 17);
234                dcountWSS = 2;
235                break;
236        default:
237                BDBG_LEAVE(BVBI_P_A656_Enc_Program);
238                BDBG_ERR(("BVBI_A656: ITU-R 656 encoding format %d not supported", 
239                        h656options->e656Format));
240                return BERR_TRACE (BERR_INVALID_PARAMETER);
241                break;
242        }
243        sdid = h656options->sdid;
244
245        /* Program the "type A" register for closed caption */
246        if (h656options->e656Format != BVBI_656Fmt_SMPTE291)
247                dcountCC = BVBI_P_p656_SetEEbits (dcountCC);
248        ulReg = (
249                BCHP_FIELD_DATA(ANCI656_ANCIL_0_TYPE_A_VBI_HEADER,        SDID,     sdid) |
250                BCHP_FIELD_DATA(ANCI656_ANCIL_0_TYPE_A_VBI_HEADER, DWORD_COUNT, dcountCC) 
251        );
252        if (isPal)
253        {
254                ulReg |= 
255                        BCHP_FIELD_ENUM(ANCI656_ANCIL_0_TYPE_A_VBI_HEADER, TYPE, 
256                                EURO_CLOSED_CAPTION);
257        }
258        else
259        {
260                ulReg |= 
261                        BCHP_FIELD_ENUM(ANCI656_ANCIL_0_TYPE_A_VBI_HEADER, TYPE, 
262                                US_CLOSED_CAPTION);
263        }
264    BREG_Write32 (
265                hReg, BCHP_ANCI656_ANCIL_0_TYPE_A_VBI_HEADER + ulCoreOffset, ulReg);
266
267        /* Program the "type B" register for teletext */
268        if (h656options->e656Format != BVBI_656Fmt_SMPTE291)
269                dcountTT = BVBI_P_p656_SetEEbits (dcountTT);
270        ulReg = (
271                BCHP_FIELD_DATA(ANCI656_ANCIL_0_TYPE_B_VBI_HEADER,        SDID,     sdid) |
272                BCHP_FIELD_DATA(ANCI656_ANCIL_0_TYPE_B_VBI_HEADER, DWORD_COUNT, dcountTT) 
273        );
274        if (isPal)
275        {
276                ulReg |= 
277                        BCHP_FIELD_ENUM(ANCI656_ANCIL_0_TYPE_B_VBI_HEADER, TYPE, 
278                                TELETEXT);
279        }
280        else
281        {
282                ulReg |= 
283                        BCHP_FIELD_ENUM(ANCI656_ANCIL_0_TYPE_B_VBI_HEADER, TYPE, 
284                                US_NABTS);
285        }
286    BREG_Write32 (
287                hReg, BCHP_ANCI656_ANCIL_0_TYPE_B_VBI_HEADER + ulCoreOffset, ulReg);
288
289        /* Program the "type C" register for WSS */
290        if (h656options->e656Format != BVBI_656Fmt_SMPTE291)
291                dcountWSS = BVBI_P_p656_SetEEbits (dcountWSS);
292        ulReg = (
293                BCHP_FIELD_DATA(ANCI656_ANCIL_0_TYPE_C_VBI_HEADER,        SDID,      sdid)|
294                BCHP_FIELD_DATA(ANCI656_ANCIL_0_TYPE_C_VBI_HEADER, DWORD_COUNT, dcountWSS) 
295        );
296        ulReg |= 
297                BCHP_FIELD_ENUM(ANCI656_ANCIL_0_TYPE_C_VBI_HEADER, TYPE, 
298                        WIDE_SCREEN);
299    BREG_Write32 (
300                hReg, BCHP_ANCI656_ANCIL_0_TYPE_C_VBI_HEADER + ulCoreOffset, ulReg);
301
302        /* Program the ITU-R 656 data encoding format */
303        ulReg = 
304                BREG_Read32 ( hReg,  BCHP_ANCI656_ANCIL_0_ANCI656_CNTRL + ulCoreOffset );
305        ulReg &= 
306                 ~BCHP_MASK      (ANCI656_ANCIL_0_ANCI656_CNTRL, FORMAT         );
307        switch (h656options->e656Format)
308        {
309        case BVBI_656Fmt_SAA7113:
310                ulReg |= 
311                        BCHP_FIELD_ENUM(ANCI656_ANCIL_0_ANCI656_CNTRL, FORMAT, SAA7113H);
312                break;
313        case BVBI_656Fmt_Modified_SAA7113:
314                ulReg |= 
315                        BCHP_FIELD_ENUM(ANCI656_ANCIL_0_ANCI656_CNTRL, FORMAT, 
316                                MODIFIED_SAA7113H);
317                break;
318        case BVBI_656Fmt_SMPTE291:
319                ulReg |= 
320                        BCHP_FIELD_ENUM(ANCI656_ANCIL_0_ANCI656_CNTRL, FORMAT, SMPTE291M);
321                break;
322        default:
323                BDBG_LEAVE(BVBI_P_A656_Enc_Program);
324                BDBG_ERR(("BVBI_A656: ITU-R 656 encoding format %d not supported",
325                        h656options->e656Format));
326                return BERR_TRACE (BERR_INVALID_PARAMETER);
327                break;
328        }
329
330        /* Take care of the PR18010 backwards compatibility issue */
331        if (bPR18010_bad_line_number)
332        {
333                ulReg |= (
334                        BCHP_FIELD_ENUM(ANCI656_ANCIL_0_ANCI656_CNTRL, V_BIT_SEL, REG) |
335                        BCHP_FIELD_ENUM(ANCI656_ANCIL_0_ANCI656_CNTRL, F_BIT_SEL, REG) 
336                );
337        }
338
339    BREG_Write32 (hReg, BCHP_ANCI656_ANCIL_0_ANCI656_CNTRL + ulCoreOffset, ulReg);
340
341        BDBG_LEAVE(BVBI_P_A656_Enc_Program);
342        return BERR_SUCCESS;
343}
344
345/***************************************************************************
346* Static (private) functions
347***************************************************************************/
348
349/***************************************************************************
350 *
351 */
352static void BVBI_P_A656_Enc_Init (BREG_Handle hReg)
353{
354        BDBG_ENTER(BVBI_P_A656_Enc_Init);
355
356        /* Just reset the core(s).  Probably not necessary. */
357        BVBI_P_VIE_AncilSoftReset (hReg, 0);
358#if (BVBI_P_NUM_ANCI656_656 >= 2)
359        BVBI_P_VIE_AncilSoftReset (hReg, 1);
360#endif
361
362        BDBG_LEAVE(BVBI_P_A656_Enc_Init);
363}
364
365/***************************************************************************
366 *
367 */
368static uint32_t P_GetCoreOffset (uint8_t hwCoreIndex)
369{
370        uint32_t ulCoreOffset = 0xFFFFFFFF;
371
372        if (hwCoreIndex == 0) 
373                ulCoreOffset = 0x0;
374#if (BVBI_P_NUM_ANCI656_656 >= 2)
375        if (hwCoreIndex == 0) 
376                ulCoreOffset = 
377                        BCHP_ANCI656_ANCIL_1_ANCI656_REV_ID - 
378                        BCHP_ANCI656_ANCIL_0_ANCI656_REV_ID;
379#endif
380
381        return ulCoreOffset;
382}
383
384#endif /** } (BVBI_P_NUM_ANCI656_ANCIL_0 > 0) **/
385
386/* End of file */
Note: See TracBrowser for help on using the repository browser.