| 1 | /****************************************************************************** |
|---|
| 2 | * (c)2008-2009 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: $ |
|---|
| 39 | * $brcm_Revision: $ |
|---|
| 40 | * $brcm_Date: $ |
|---|
| 41 | * |
|---|
| 42 | * Module Description: |
|---|
| 43 | * |
|---|
| 44 | * Utility to handle the frontend configuration and tuning. |
|---|
| 45 | * |
|---|
| 46 | * Revision History: |
|---|
| 47 | * |
|---|
| 48 | * Created: 09/28/2009 by Jeff Fisher |
|---|
| 49 | * |
|---|
| 50 | * $brcm_Log: $ |
|---|
| 51 | * |
|---|
| 52 | * |
|---|
| 53 | *****************************************************************************/ |
|---|
| 54 | #include "bapp_tune.h" |
|---|
| 55 | #include "bapp.h" |
|---|
| 56 | #include "nexus_frontend.h" |
|---|
| 57 | #include "nexus_platform.h" |
|---|
| 58 | #include "nexus_parser_band.h" |
|---|
| 59 | #include "nexus_video_decoder.h" |
|---|
| 60 | |
|---|
| 61 | #define MAX_EVENT 4 |
|---|
| 62 | |
|---|
| 63 | enum |
|---|
| 64 | { |
|---|
| 65 | eFE_EVENT_NONE, |
|---|
| 66 | eFE_EVENT_LOCK, |
|---|
| 67 | eFE_EVENT_MAX |
|---|
| 68 | }; |
|---|
| 69 | |
|---|
| 70 | struct bapp_tune |
|---|
| 71 | { |
|---|
| 72 | bapp_tune_event_t signal_evt; |
|---|
| 73 | bapp_freq_table_type_t fe_type; |
|---|
| 74 | NEXUS_FrontendHandle frontend; |
|---|
| 75 | NEXUS_ParserBand parserBand; |
|---|
| 76 | NEXUS_FrontendVsbSettings vsbSettings; |
|---|
| 77 | NEXUS_FrontendQamSettings qamSettings; |
|---|
| 78 | bapp_task_queue_t queue; |
|---|
| 79 | bapp_task_event_t event[MAX_EVENT]; |
|---|
| 80 | unsigned int timeout_ms; |
|---|
| 81 | }; |
|---|
| 82 | |
|---|
| 83 | |
|---|
| 84 | |
|---|
| 85 | /** |
|---|
| 86 | Summary: |
|---|
| 87 | Return a bapp_tune handle if frontend exists. NEXUS init should be called before calling this function. |
|---|
| 88 | **/ |
|---|
| 89 | bapp_result_t bapp_tune_open(bapp_tune_type_t fe_type, bapp_tune_t *p_app_tune, int *band) |
|---|
| 90 | { |
|---|
| 91 | bapp_tune_t p_tune = NULL; |
|---|
| 92 | bool found_frontend = false; |
|---|
| 93 | int i; |
|---|
| 94 | |
|---|
| 95 | p_tune = (bapp_tune_t)bapp_util_malloc(sizeof(struct bapp_tune)); |
|---|
| 96 | |
|---|
| 97 | if (!p_tune) |
|---|
| 98 | return eBAPP_RESULT_ALLOC_FAILURE; |
|---|
| 99 | |
|---|
| 100 | bapp_util_memset(p_tune,0,sizeof(struct bapp_tune)); |
|---|
| 101 | |
|---|
| 102 | if (bapp_task_create_queue(&p_tune->queue,p_tune->event,MAX_EVENT) != eBAPP_RESULT_OK) |
|---|
| 103 | { |
|---|
| 104 | bapp_util_free(p_tune); |
|---|
| 105 | return eBAPP_RESULT_ALLOC_FAILURE; |
|---|
| 106 | } |
|---|
| 107 | |
|---|
| 108 | p_tune->fe_type = fe_type; |
|---|
| 109 | p_tune->frontend = NULL; |
|---|
| 110 | p_tune->parserBand = NEXUS_ParserBand_e0; |
|---|
| 111 | *band = p_tune->parserBand; |
|---|
| 112 | *p_app_tune = p_tune; |
|---|
| 113 | return eBAPP_RESULT_OK; |
|---|
| 114 | } |
|---|
| 115 | |
|---|
| 116 | /** |
|---|
| 117 | Summary: |
|---|
| 118 | Release resources. |
|---|
| 119 | **/ |
|---|
| 120 | bapp_result_t bapp_tune_close(bapp_tune_t p_tune) |
|---|
| 121 | { |
|---|
| 122 | bapp_task_delete_queue(p_tune->queue); |
|---|
| 123 | bapp_util_free(p_tune); |
|---|
| 124 | return eBAPP_RESULT_OK; |
|---|
| 125 | } |
|---|
| 126 | |
|---|
| 127 | |
|---|
| 128 | /** |
|---|
| 129 | Summary: |
|---|
| 130 | Lock the frontend. |
|---|
| 131 | **/ |
|---|
| 132 | bapp_result_t bapp_tune_lock(bapp_tune_t p_tune, |
|---|
| 133 | unsigned int freq_hz) |
|---|
| 134 | { |
|---|
| 135 | bapp_task_event_t event; |
|---|
| 136 | bapp_task_reset_queue(p_tune->queue); |
|---|
| 137 | |
|---|
| 138 | |
|---|
| 139 | return eBAPP_RESULT_OK; |
|---|
| 140 | } |
|---|
| 141 | |
|---|
| 142 | /** |
|---|
| 143 | Summary: |
|---|
| 144 | Unlock the frontend. |
|---|
| 145 | **/ |
|---|
| 146 | bapp_result_t bapp_tune_unlock(bapp_tune_t p_tune) |
|---|
| 147 | { |
|---|
| 148 | return eBAPP_RESULT_OK; |
|---|
| 149 | } |
|---|
| 150 | |
|---|
| 151 | /* |
|---|
| 152 | Summary: |
|---|
| 153 | Send frontend status event to the application. |
|---|
| 154 | */ |
|---|
| 155 | |
|---|
| 156 | void bapp_tune_send_status(bapp_tune_t p_tune) |
|---|
| 157 | { |
|---|
| 158 | |
|---|
| 159 | } |
|---|
| 160 | |
|---|