source: svn/newcon3bcm2_21bu/BSEAV/api/src/nexus/bsettop_vbi.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: 10.1 KB
Line 
1/***************************************************************************
2 *     Copyright (c) 2003-2008, Broadcom Corporation
3 *     All Rights Reserved
4 *     Confidential Property of Broadcom Corporation
5 *
6 *  THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE
7 *  AGREEMENT  BETWEEN THE USER AND BROADCOM.  YOU HAVE NO RIGHT TO USE OR
8 *  EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT.
9 *
10 * $brcm_Workfile: bsettop_vbi.c $
11 * $brcm_Revision: 8 $
12 * $brcm_Date: 8/14/08 11:25a $
13 *
14 * Module Description:
15 *
16 * Revision History:
17 *
18 * $brcm_Log: /BSEAV/api/src/nexus/bsettop_vbi.c $
19 *
20 * 8   8/14/08 11:25a vishk
21 * PR 4537: bstream_vbi_settings structure call-back is not being called
22 * when data is ready
23 *
24 * 7   6/24/08 4:28p erickson
25 * PR36068: fix warning
26 *
27 * 6   6/23/08 2:45p erickson
28 * PR36068: no VBI encoding on DTV platform
29 *
30 * 5   5/19/08 3:04p erickson
31 * PR42595: assign NEXUS_DisplayVbiSettings.vbiSource
32 *
33 * 4   4/3/08 5:42p jgarrett
34 * PR 41312: Setting callback events
35 *
36 * 3   3/19/08 3:12p erickson
37 * PR36068: remove WRN
38 *
39 * 2   3/11/08 11:10a erickson
40 * PR36068: impl vbi
41 *
42 * 1   10/15/07 2:36p erickson
43 * PR36068: initial
44 *
45 ***************************************************************************/
46#include "bsettop_impl.h"
47#include "nexus_video_input_vbi.h"
48#include "nexus_display_vbi.h"
49
50BDBG_MODULE(vbi);
51
52static NEXUS_VideoInput bstream_p_get_video_input(bstream_t stream)
53{
54    if (stream->consumers.decode && stream->consumers.decode->video_decode) {
55        if (stream->consumers.decode->video_decode->nVideoDecoder) {
56            return NEXUS_VideoDecoder_GetConnector(stream->consumers.decode->video_decode->nVideoDecoder);
57        }
58    }
59    return NULL;
60}
61
62void bstream_vbi_get_settings(bstream_t stream, bstream_vbi_settings *settings)
63{
64    *settings = stream->vbi_settings;
65}
66
67#if !NEXUS_DTV_PLATFORM
68static void cc_data_ready_callback(void *context)
69{
70    bstream_t stream = context;
71    if (stream->vbi_settings.cc_data_ready_callback) {
72        b_unlock();
73        (*stream->vbi_settings.cc_data_ready_callback)(stream->vbi_settings.callback_context);
74        b_lock();
75    }
76    stream->cc_data_ready_timer = b_timer_schedule(15, cc_data_ready_callback, stream);
77}
78#endif
79
80bresult bstream_vbi_set_settings(bstream_t stream, const bstream_vbi_settings *settings)
81{
82#if !NEXUS_DTV_PLATFORM
83    NEXUS_DisplayVbiSettings displayVbiSettings;
84    NEXUS_Error rc;
85
86    /* ignore settings->cc.line & settings->tt.lines */
87
88    if (settings->cc.display) {
89        NEXUS_Display_GetVbiSettings(settings->cc.display->nDisplay, &displayVbiSettings);
90        displayVbiSettings.closedCaptionRouting = true;
91        displayVbiSettings.closedCaptionEnabled = true;
92        displayVbiSettings.vbiSource = bstream_p_get_video_input(stream);
93        rc = NEXUS_Display_SetVbiSettings(settings->cc.display->nDisplay, &displayVbiSettings);
94        if (rc) return BSETTOP_ERROR(rc);
95    }
96    else if (stream->vbi_settings.cc.display) {
97        NEXUS_Display_GetVbiSettings(stream->vbi_settings.cc.display->nDisplay, &displayVbiSettings);
98        displayVbiSettings.closedCaptionRouting = false;
99        displayVbiSettings.closedCaptionEnabled = false;
100        rc = NEXUS_Display_SetVbiSettings(stream->vbi_settings.cc.display->nDisplay, &displayVbiSettings);
101        if (rc) return BSETTOP_ERROR(rc);
102    }
103
104    if (settings->tt.display) {
105        NEXUS_Display_GetVbiSettings(settings->tt.display->nDisplay, &displayVbiSettings);
106        displayVbiSettings.teletextRouting = true;
107        displayVbiSettings.teletextEnabled = true;
108        displayVbiSettings.vbiSource = bstream_p_get_video_input(stream);
109        rc = NEXUS_Display_SetVbiSettings(settings->tt.display->nDisplay, &displayVbiSettings);
110        if (rc) return BSETTOP_ERROR(rc);
111    }
112    else if (stream->vbi_settings.tt.display) {
113        NEXUS_Display_GetVbiSettings(stream->vbi_settings.tt.display->nDisplay, &displayVbiSettings);
114        displayVbiSettings.teletextRouting = false;
115        displayVbiSettings.teletextEnabled = false;
116        rc = NEXUS_Display_SetVbiSettings(stream->vbi_settings.tt.display->nDisplay, &displayVbiSettings);
117        if (rc) return BSETTOP_ERROR(rc);
118    }
119
120    /* don't use settings->cgms.display or settings->wss.display. this is
121    automatically enabled in the set functions. */
122
123    /* Nexus has no callback for cc data ready. If cc parsing is enabled, CC608 data will be available at 1 entry per vsync.
124    The app can time it easily. */
125    if (settings->cc_data_ready_callback) {
126        if (!stream->cc_data_ready_timer) {
127            stream->vbi_settings.cc_data_ready_callback = settings->cc_data_ready_callback;
128            stream->vbi_settings.callback_context = settings->callback_context;
129            stream->cc_data_ready_timer = b_timer_schedule(15, cc_data_ready_callback, stream);
130        }
131    }
132    else if (stream->cc_data_ready_timer) {
133        stream->vbi_settings.cc_data_ready_callback = NULL;
134        stream->vbi_settings.callback_context = NULL;
135        b_timer_cancel(stream->cc_data_ready_timer);
136        stream->cc_data_ready_timer = NULL;
137    }
138#endif
139
140    stream->vbi_settings = *settings;
141    return 0;
142}
143
144bresult bstream_vbi_cc_read(bstream_t stream, bstream_vbi_cc *data, size_t length, size_t *length_read)
145{
146    NEXUS_VideoInput videoInput = bstream_p_get_video_input(stream);
147    NEXUS_VideoInputVbiSettings inputsettings;
148   
149    *length_read = 0;
150    if (!videoInput) return 0;
151
152    NEXUS_VideoInput_GetVbiSettings(videoInput, &inputsettings);
153    inputsettings.closedCaptionEnabled = true;
154    NEXUS_VideoInput_SetVbiSettings(videoInput, &inputsettings);
155
156    for (;*length_read<length;(*length_read)++) {
157        NEXUS_Error rc;
158        NEXUS_ClosedCaptionData entry;
159        unsigned num;
160
161        rc = NEXUS_VideoInput_ReadClosedCaption(videoInput, &entry, 1, &num);
162        if (rc) return BSETTOP_ERROR(rc);
163        if (!num) {
164            break;
165        }
166        data[*length_read].data[0] = entry.data[0];
167        data[*length_read].data[1] = entry.data[1];
168        data[*length_read].field = 0; /* doesn't matter. hard code to top. */
169        data[*length_read].cc_type = 0; /* always 608 */
170    }
171    return 0;
172}
173
174bresult bstream_vbi_cc708_read(bstream_t stream, bstream_cc_708 *data, size_t length, size_t *length_read)
175{
176    /* Nexus does not have a CC708 interface and none is planned.
177    Instead, user should read & parse VideoDecoder userdata for CC708. */
178    BSTD_UNUSED(stream);
179    BSTD_UNUSED(data);
180    BSTD_UNUSED(length);
181    BSTD_UNUSED(length_read);
182    return BSETTOP_ERROR(berr_not_supported);
183}
184
185bresult bdisplay_vbi_cc_write(bdisplay_t display, const bstream_vbi_cc *data, size_t length, size_t *length_written)
186{
187    *length_written = 0;
188    for (;*length_written<length;(*length_written)++) {
189        NEXUS_Error rc;
190        NEXUS_ClosedCaptionData entry;
191        unsigned num;
192
193        entry.data[0] = data[*length_written].data[0];
194        entry.data[1] = data[*length_written].data[1];
195        rc = NEXUS_Display_WriteClosedCaption(display->nDisplay, &entry, 1, &num);
196        if (rc) return BSETTOP_ERROR(rc);
197        if (!num) {
198            break;
199        }
200    }
201    return 0;
202}
203
204bresult bstream_vbi_tt_read(bstream_t stream, bstream_vbi_tt *data, size_t length, size_t *length_read)
205{
206    NEXUS_VideoInput videoInput = bstream_p_get_video_input(stream);
207
208    *length_read = 0;
209    if (!videoInput) return 0;
210
211    for (;*length_read<length;(*length_read)++) {
212        NEXUS_Error rc;
213        NEXUS_TeletextLine entry;
214        unsigned num;
215
216        rc = NEXUS_VideoInput_ReadTeletext(videoInput, &entry, 1, &num);
217        if (rc) return BSETTOP_ERROR(rc);
218        if (!num) {
219            break;
220        }
221        data[*length_read].framingCode = entry.framingCode;
222        BKNI_Memcpy(data[*length_read].data, entry.data, NEXUS_TELETEXT_LINESIZE);
223    }
224    return 0;
225}
226
227bresult bdisplay_vbi_tt_write(bdisplay_t display, const bstream_vbi_tt *data, size_t length, uint8_t polarity)
228{
229    unsigned length_written;
230    BSTD_UNUSED(polarity);
231    /* See PR 40468. This function should be redesigned to include flow control. See TODO below. */
232
233    length_written = 0;
234    for (;length_written<length;(length_written)++) {
235        NEXUS_Error rc;
236        NEXUS_TeletextLine entry;
237        unsigned num;
238
239        entry.lineNumber = length_written; /* generate a line number from the write() call */
240        entry.framingCode = data[length_written].framingCode;
241        BKNI_Memcpy(entry.data, data[length_written].data, NEXUS_TELETEXT_LINESIZE);
242
243        rc = NEXUS_Display_WriteTeletext(display->nDisplay, &entry, 1, &num);
244        if (rc) return BSETTOP_ERROR(rc);
245
246        if (!num) {
247            BKNI_Sleep(10); /* TODO: here's the problem. we should not be sleeping. we should exit & report length_written. */
248        }
249    }
250    return 0;
251}
252
253bresult bdisplay_vbi_set_cgms(bdisplay_t display, uint32_t cgms_value)
254{
255    NEXUS_DisplayVbiSettings vbiSettings;
256    NEXUS_Error rc;
257
258    display->cgms_enabled = (cgms_value != BDISPLAY_VBI_INVALID_CGMS);
259
260    NEXUS_Display_GetVbiSettings(display->nDisplay, &vbiSettings);
261    vbiSettings.cgmsEnabled = display->cgms_enabled;
262    rc = NEXUS_Display_SetVbiSettings(display->nDisplay, &vbiSettings);
263    if (rc) return BSETTOP_ERROR(rc);
264
265    if (display->cgms_enabled) {
266        rc = NEXUS_Display_SetCgms(display->nDisplay, cgms_value);
267        if (rc) return BSETTOP_ERROR(rc);
268    }
269
270    return 0;
271}
272
273bresult bdisplay_vbi_set_wss(bdisplay_t display, uint16_t wss_value)
274{
275    NEXUS_DisplayVbiSettings vbiSettings;
276    NEXUS_Error rc;
277
278    display->wss_enabled = (wss_value != BDISPLAY_VBI_INVALID_WSS);
279
280    NEXUS_Display_GetVbiSettings(display->nDisplay, &vbiSettings);
281    vbiSettings.wssEnabled = display->wss_enabled;
282    rc = NEXUS_Display_SetVbiSettings(display->nDisplay, &vbiSettings);
283    if (rc) return BSETTOP_ERROR(rc);
284
285    if (display->wss_enabled) {
286        rc = NEXUS_Display_SetWss(display->nDisplay, wss_value);
287        if (rc) return BSETTOP_ERROR(rc);
288    }
289
290    return 0;
291}
292
293bresult bdisplay_vbi_get_cgms(bdisplay_t display, bool *enabled)
294{
295    *enabled = display->cgms_enabled;
296    return 0;
297}
298
299bresult bdisplay_vbi_get_wss(bdisplay_t display, bool *enabled)
300{
301    *enabled = display->wss_enabled;
302    return 0;
303}
Note: See TracBrowser for help on using the repository browser.