source: svn/newcon3bcm2_21bu/nexus/modules/display/7552/src/nexus_hddvi_input.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: 12.9 KB
Line 
1/***************************************************************************
2 *     (c)2007-2011 Broadcom Corporation
3 *
4 *  This program is the proprietary software of Broadcom Corporation and/or its licensors,
5 *  and may only be used, duplicated, modified or distributed pursuant to the terms and
6 *  conditions of a separate, written license agreement executed between you and Broadcom
7 *  (an "Authorized License").  Except as set forth in an Authorized License, Broadcom grants
8 *  no license (express or implied), right to use, or waiver of any kind with respect to the
9 *  Software, and Broadcom expressly reserves all rights in and to the Software and all
10 *  intellectual property rights therein.  IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU
11 *  HAVE NO RIGHT TO USE THIS SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY
12 *  NOTIFY BROADCOM AND DISCONTINUE ALL USE OF THE SOFTWARE.
13 *
14 *  Except as expressly set forth in the Authorized License,
15 *
16 *  1.     This program, including its structure, sequence and organization, constitutes the valuable trade
17 *  secrets of Broadcom, and you shall use all reasonable efforts to protect the confidentiality thereof,
18 *  and to use this information only in connection with your use of Broadcom integrated circuit products.
19 *
20 *  2.     TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
21 *  AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES, REPRESENTATIONS OR
22 *  WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO
23 *  THE SOFTWARE.  BROADCOM SPECIFICALLY DISCLAIMS ANY AND ALL IMPLIED WARRANTIES
24 *  OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE,
25 *  LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION
26 *  OR CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING OUT OF
27 *  USE OR PERFORMANCE OF THE SOFTWARE.
28 *
29 *  3.     TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM OR ITS
30 *  LICENSORS BE LIABLE FOR (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR
31 *  EXEMPLARY DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO YOUR
32 *  USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM HAS BEEN ADVISED OF
33 *  THE POSSIBILITY OF SUCH DAMAGES; OR (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT
34 *  ACTUALLY PAID FOR THE SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE
35 *  LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF ESSENTIAL PURPOSE OF
36 *  ANY LIMITED REMEDY.
37 *
38 * $brcm_Workfile: nexus_hddvi_input.c $
39 * $brcm_Revision: 4 $
40 * $brcm_Date: 11/17/11 4:57p $
41 *
42 * Module Description:
43 *
44 * Revision History:
45 *
46 * $brcm_Log: /nexus/modules/display/7400/src/nexus_hddvi_input.c $
47 *
48 * 4   11/17/11 4:57p erickson
49 * SW7231-387: autoFormat should default to true
50 *
51 * 3   12/2/10 8:14p spothana
52 * SW7420-1177: Adding format and autoformat variables to HDDVI.
53 *
54 * SW7420-1177/2   11/5/10 4:04p spothana
55 * SW7420-1177: Set the DVI port to external input.
56 *
57 * SW7420-1177/1   11/5/10 3:28p spothana
58 * SW7420-1177: Updating nexus_hddvi module
59 *
60 * 2   7/31/09 3:27p nickh
61 * PR56969: Set default inputDataMode
62 *
63 * 1   7/23/09 10:39a erickson
64 * PR56969: add hddvi input
65 *
66 **************************************************************************/
67#include "nexus_display_module.h"
68#include "nexus_power_management.h"
69#include "bfmt.h"
70BDBG_MODULE(nexus_hddvi_input);
71
72BDBG_OBJECT_ID(NEXUS_HdDviInput);
73
74struct NEXUS_HdDviInput {
75    BDBG_OBJECT(NEXUS_HdDviInput)
76    NEXUS_HdDviInputSettings settings;
77    NEXUS_VideoInputObject input;
78    BAVC_SourceId sourceId;
79    BAVC_VDC_HdDvi_Picture stHdDviPic;
80    unsigned index;
81};
82static const BFMT_VideoFmt g_autoDetectFormats[] = {
83    BFMT_VideoFmt_eNTSC ,                   
84    BFMT_VideoFmt_e1080i,                   
85    BFMT_VideoFmt_e1080p,                   
86    BFMT_VideoFmt_e720p,                       
87    BFMT_VideoFmt_e480p,                       
88    BFMT_VideoFmt_e1080p_30Hz                 
89};
90
91#if NEXUS_NUM_HDDVI_INPUTS
92static void NEXUS_VideoInput_P_HdDviInputPictureCallback_isr(void *pvParm1, int iParm2,
93      BAVC_Polarity ePolarity, BAVC_SourceState eSourceState, void **ppvPicture)
94{
95    NEXUS_HdDviInputHandle hdDviInput =(NEXUS_HdDviInputHandle)pvParm1;
96    BSTD_UNUSED(iParm2);
97    BSTD_UNUSED(ePolarity);
98    BSTD_UNUSED(eSourceState);
99    *ppvPicture = &hdDviInput->stHdDviPic;
100    BDBG_MSG(("NEXUS_VideoInput_P_HdDviInputPictureCallback_isr"));
101    return;
102}
103#endif
104
105void NEXUS_HdDviInput_GetDefaultSettings( NEXUS_HdDviInputSettings *pSettings )
106{
107    BKNI_Memset(pSettings, 0, sizeof(*pSettings));
108    pSettings->autoFormat = true;
109    pSettings->inputDataMode = 24; /* 24 bit */
110    pSettings->format = NEXUS_VideoFormat_eNtsc;
111}
112
113NEXUS_HdDviInputHandle NEXUS_HdDviInput_Open( unsigned index, const NEXUS_HdDviInputSettings *pSettings )
114{
115#if NEXUS_NUM_HDDVI_INPUTS
116    NEXUS_HdDviInputHandle hdDviInput;
117    NEXUS_HdDviInputSettings defaultSettings;
118
119    if (index >= NEXUS_NUM_HDDVI_INPUTS) {
120        BDBG_ERR(("Cannot open HdDviInput %d. NEXUS_NUM_HDDVI_INPUTS is %d.", index, NEXUS_NUM_HDDVI_INPUTS));
121        return NULL;
122    }
123
124    if (!pSettings) {
125        NEXUS_HdDviInput_GetDefaultSettings(&defaultSettings);
126        pSettings = &defaultSettings;
127    }
128
129    hdDviInput = BKNI_Malloc(sizeof(*hdDviInput));
130    BKNI_Memset(hdDviInput, 0, sizeof(*hdDviInput));
131    BDBG_OBJECT_SET(hdDviInput, NEXUS_HdDviInput);
132    NEXUS_VIDEO_INPUT_INIT(&hdDviInput->input, NEXUS_VideoInputType_eHdDvi, hdDviInput);
133    hdDviInput->index = index;
134    hdDviInput->settings = *pSettings;
135
136    hdDviInput->stHdDviPic.eCscMode                 = BAVC_CscMode_e709RgbFullRange;
137    hdDviInput->stHdDviPic.eColorSpace              = BAVC_Colorspace_eRGB;
138    hdDviInput->stHdDviPic.eMatrixCoefficients      = BAVC_MatrixCoefficients_eItu_R_BT_709;
139    hdDviInput->stHdDviPic.eTransferCharacteristics = BAVC_TransferCharacteristics_eItu_R_BT_709;
140   
141    switch (index) {
142    case 0: hdDviInput->sourceId = BAVC_SourceId_eHdDvi0; break;
143    case 1: hdDviInput->sourceId = BAVC_SourceId_eHdDvi1; break;
144    /* add each one explicitly. don't assume BAVC_SourceId enums are contiguous */
145    default: BERR_TRACE(NEXUS_INVALID_PARAMETER); goto error;
146    }
147
148    return hdDviInput;
149
150error:
151    NEXUS_HdDviInput_Close(hdDviInput);
152    return NULL;
153#else
154    BSTD_UNUSED(index);
155    BSTD_UNUSED(pSettings);
156    BERR_TRACE(NEXUS_NOT_SUPPORTED);
157    return NULL;
158#endif
159}
160
161void NEXUS_HdDviInput_Close( NEXUS_HdDviInputHandle hdDviInput )
162{
163    BDBG_OBJECT_ASSERT(hdDviInput, NEXUS_HdDviInput);
164
165    /* This input is in the Display module, so we can auto-disconnect & shutdown */
166    if (hdDviInput->input.destination) {
167        NEXUS_VideoWindow_RemoveInput(hdDviInput->input.destination, &hdDviInput->input);
168        BDBG_ASSERT(!hdDviInput->input.destination);
169    }
170    if (hdDviInput->input.ref_cnt) {
171        NEXUS_VideoInput_Shutdown(&hdDviInput->input);
172        BDBG_ASSERT(!hdDviInput->input.ref_cnt);
173    }
174
175    BDBG_OBJECT_DESTROY(hdDviInput, NEXUS_HdDviInput);
176    BKNI_Free(hdDviInput);
177}
178
179void NEXUS_HdDviInput_GetSettings( NEXUS_HdDviInputHandle hdDviInput, NEXUS_HdDviInputSettings *pSettings )
180{
181    BDBG_OBJECT_ASSERT(hdDviInput, NEXUS_HdDviInput);
182    *pSettings = hdDviInput->settings;
183}
184
185#if NEXUS_NUM_HDDVI_INPUTS
186static NEXUS_Error NEXUS_HdDviInput_P_ApplyVdcSettings(NEXUS_VideoInput_P_Link *link, const NEXUS_HdDviInputSettings *pSettings)
187{
188    BERR_Code rc;
189    BVDC_HdDvi_Settings vdcSettings;
190    BFMT_VideoFmt formatVdc;
191    const NEXUS_DisplayModule_State *video= &g_NEXUS_DisplayModule_State;
192    BDBG_MSG((" > NEXUS_HdDviInput_P_ApplyVdcSettings"));
193
194    rc = BVDC_Source_SetAutoFormat(link->sourceVdc, pSettings->autoFormat, (void *)g_autoDetectFormats, sizeof(g_autoDetectFormats)/sizeof(*g_autoDetectFormats));
195    if(rc!=BERR_SUCCESS) {return BERR_TRACE(rc);}
196    if(!pSettings->autoFormat && pSettings->format != NEXUS_VideoFormat_eUnknown) {
197        rc = NEXUS_P_VideoFormat_ToMagnum(pSettings->format, &formatVdc);
198        if (rc!=BERR_SUCCESS) {return BERR_TRACE(rc);}
199        rc = BVDC_Source_SetVideoFormat(link->sourceVdc, formatVdc);
200        if (rc!=BERR_SUCCESS) {return BERR_TRACE(rc);}
201    }
202
203    (void)BVDC_Source_GetHdDviConfiguration(link->sourceVdc, &vdcSettings);
204    vdcSettings.bEnableDe = pSettings->enableDe;
205    vdcSettings.stFmtTolerence.ulWidth = pSettings->formatDetectionTolerance.width;
206    vdcSettings.stFmtTolerence.ulHeight = pSettings->formatDetectionTolerance.height;
207
208    switch (pSettings->inputDataMode) {
209    case 24: vdcSettings.eInputDataMode = BVDC_HdDvi_InputDataMode_e24Bit; break;
210    case 30: vdcSettings.eInputDataMode = BVDC_HdDvi_InputDataMode_e30Bit; break;
211    case 36: vdcSettings.eInputDataMode = BVDC_HdDvi_InputDataMode_e36Bit; break;
212    default: return BERR_TRACE(NEXUS_INVALID_PARAMETER);
213    }
214    BVDC_Source_SetInputPort(link->sourceVdc, 0);
215    rc = BVDC_Source_SetHdDviConfiguration(link->sourceVdc, &vdcSettings);
216    if (rc) return BERR_TRACE(rc);
217
218    rc = BVDC_ApplyChanges(video->vdc);
219    if ( rc )
220    {
221        return BERR_TRACE(rc);
222    }
223    BDBG_MSG((" < NEXUS_HdDviInput_P_ApplyVdcSettings"));
224    return 0;
225}
226#endif
227
228NEXUS_Error NEXUS_HdDviInput_SetSettings( NEXUS_HdDviInputHandle hdDviInput, const NEXUS_HdDviInputSettings *pSettings )
229{
230#if NEXUS_NUM_HDDVI_INPUTS
231    NEXUS_VideoInput_P_Link *link;
232
233    BDBG_OBJECT_ASSERT(hdDviInput, NEXUS_HdDviInput);
234    BDBG_MSG((" > NEXUS_HdDviInput_SetSettings"));
235    hdDviInput->settings = *pSettings;
236
237    link = hdDviInput->input.source;
238    if (!link) return 0; /* not connected */
239    BDBG_MSG((" < NEXUS_HdDviInput_SetSettings"));
240    return NEXUS_HdDviInput_P_ApplyVdcSettings(link, &hdDviInput->settings);
241#else
242    BDBG_OBJECT_ASSERT(hdDviInput, NEXUS_HdDviInput);
243    hdDviInput->settings = *pSettings;
244    return BERR_TRACE(NEXUS_NOT_SUPPORTED);
245#endif
246}
247
248NEXUS_VideoInput NEXUS_HdDviInput_GetConnector( NEXUS_HdDviInputHandle hdDviInput )
249{
250    BDBG_OBJECT_ASSERT(hdDviInput, NEXUS_HdDviInput);
251    return &hdDviInput->input;
252}
253
254NEXUS_Error NEXUS_HdDviInput_GetStatus( NEXUS_HdDviInputHandle hdDviInput, NEXUS_HdDviInputStatus *pStatus )
255{
256    BFMT_AspectRatio vdcAspectRatio;
257    BFMT_VideoFmt vdcVideoFormat;
258    NEXUS_VideoInput_P_Link *link;
259    BERR_Code rc;
260
261    BDBG_OBJECT_ASSERT(hdDviInput, NEXUS_HdDviInput);
262    BKNI_Memset(pStatus, 0, sizeof(*pStatus));
263
264    link = hdDviInput->input.source;
265    if (!link) return 0; /* not connected */
266
267    BDBG_ASSERT(link->sourceVdc);
268
269    rc = BVDC_Source_GetAspectRatio(link->sourceVdc, &vdcAspectRatio);
270    if (rc) return BERR_TRACE(rc);
271    pStatus->aspectRatio = NEXUS_P_AspectRatio_FromMagnum(vdcAspectRatio);
272
273    rc = BVDC_Source_GetVideoFormat(link->sourceVdc, &vdcVideoFormat);
274    if (rc) return BERR_TRACE(rc);
275    pStatus->videoFormat = NEXUS_P_VideoFormat_FromMagnum(vdcVideoFormat);
276
277    return 0;
278}
279
280#if NEXUS_NUM_HDDVI_INPUTS
281static NEXUS_Error
282NEXUS_VideoInput_P_ConnectHdDviInput(NEXUS_VideoInput_P_Link *link)
283{
284    NEXUS_HdDviInputHandle hdDviInput;
285
286    BDBG_ASSERT(link->input);
287    BDBG_ASSERT(link->input->type == NEXUS_VideoInputType_eHdDvi);
288    hdDviInput = link->input->source;
289    BDBG_OBJECT_ASSERT(hdDviInput, NEXUS_HdDviInput);
290    BDBG_MSG((" < NEXUS_VideoInput_P_ConnectHdDviInput"));
291    NEXUS_PowerManagement_SetCoreState(NEXUS_PowerManagementCore_eHdDviInput, true);
292    BVDC_Source_InstallPictureCallback(link->sourceVdc,NEXUS_VideoInput_P_HdDviInputPictureCallback_isr, 
293                                       (void *)link->input->source, (BAVC_SourceId_eHdDvi0 == hdDviInput->sourceId) ? 0 : 1);
294    BDBG_MSG((" > NEXUS_VideoInput_P_ConnectHdDviInput"));
295    return NEXUS_HdDviInput_P_ApplyVdcSettings(link, &hdDviInput->settings);
296}
297
298static void
299NEXUS_VideoInput_P_DisconnectHdDviInput(NEXUS_VideoInput_P_Link *link)
300{
301    NEXUS_HdDviInputHandle hdDviInput;
302
303    BDBG_ASSERT(link->input);
304    BDBG_ASSERT(link->input->type == NEXUS_VideoInputType_eHdDvi);
305    hdDviInput = link->input->source;
306    BDBG_OBJECT_ASSERT(hdDviInput, NEXUS_HdDviInput);
307    BDBG_MSG((" > NEXUS_VideoInput_P_DisconnectHdDviInput"));
308    NEXUS_PowerManagement_SetCoreState(NEXUS_PowerManagementCore_eHdDviInput, false);
309    return;
310}
311
312NEXUS_VideoInput_P_Link *
313NEXUS_VideoInput_P_OpenHdDviInput(NEXUS_VideoInput input)
314{
315    NEXUS_VideoInput_P_Iface iface;
316    NEXUS_VideoInput_P_Link *link;
317    NEXUS_VideoInput_P_LinkData data;
318    NEXUS_HdDviInputHandle hdDviInput;
319    BDBG_MSG((" > NEXUS_VideoInput_P_OpenHdDviInput"));
320    BDBG_ASSERT(input->type == NEXUS_VideoInputType_eHdDvi);
321    hdDviInput = input->source;
322    BDBG_OBJECT_ASSERT(hdDviInput, NEXUS_HdDviInput);
323
324    iface.connect = NEXUS_VideoInput_P_ConnectHdDviInput;
325    iface.disconnect = NEXUS_VideoInput_P_DisconnectHdDviInput;
326    NEXUS_VideoInput_P_LinkData_Init(&data, hdDviInput->sourceId);
327    link = NEXUS_VideoInput_P_CreateLink(input, &data, &iface);
328    if(!link) {
329        return NULL;
330    }
331    BDBG_MSG((" < NEXUS_VideoInput_P_OpenHdDviInput"));
332    return link;
333}
334#endif
335
336/*
337Other possible VDC HdDvi functions to be added:
338BVDC_Source_SetAutoFormat
339BVDC_Source_SetVideoFormat
340BVDC_Window_SetUserPanScan
341BVDC_Source_OverrideAspectRatio
342*/
343
Note: See TracBrowser for help on using the repository browser.