⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 0229.c

📁 Zoran V966 DVD 解码 Soc芯片的源程序
💻 C
📖 第 1 页 / 共 2 页
字号:

    return bOn;
}

void D299_SetIdle(BOOL bIdle)
{
	if (TRUE == bIdle)
	{
		i2c_write(DEMOD_WRITE_ID, 0x28, 1);
	}
	else
	{
		i2c_write(DEMOD_WRITE_ID, 0x28, 0);
	}
}

BOOL D299_Connect( DEMOD_HANDLE handle, DEMOD_DELIVERY_INFO *tuning_info )
{
	SEARCHRESULT result;
	unsigned long freq,sym;
      
	// when user input a too low symbol rate(less than 100) we will not run the search algorithm
	// especially, the symbol rate equal zero, we must not run the search algorithm because of the bug of 
	// this tuner's driver.
	// Alfred Chen 2003_9_3
	if (tuning_info->ulSymbolRate < (200UL * 1024UL))
	{
		return FALSE;
	}

    // if signal lost, need to select DisEqC1.0 again
	//d229_DisEqC10Send(handle, &sLastDisEqC1_0);
	
	switch (3 & (tuning_info->uiWEPolModFec >> 9))
	{
		case 0: // Horizontal linear
			SetPolarization(handle,HORIZONTAL);				/* Select Horizontal polarization	*/
			break;

		case 1:	// Vertical linear
			SetPolarization(handle,VERTICAL);				/* Select Horizontal polarization	*/
			break;

		case 2:	// Circular left
		case 3: // Circular right
			tr_printf(("Not support circular LNB\n"));
			break;
	}

	freq = tuning_info->ulFrequency;

#ifdef LNB_SEPERATE
    //22k is set in ts_tune
    freq = ABS((long)(tuning_info->ulLnbSwitchFreq - freq));
#else
    // <<< [ZCH:Nick030902] charge 22k on/off
	if (0 != tuning_info->ulLnbSwitchFreq)
	{
        freq = ABS((long)(tuning_info->ulLnbSwitchFreq - freq));
        if (0 != (tuning_info->uiWEPolModFec & SATELLITE_FEC_22K_MASK))
        {
            SetLnb(handle, 1);
        }
        else
		{
            SetLnb(handle, 0);
        }
	}
	else
	{
		//
		// UNIVERSAL
		//
		if (freq > UNIVERSAL_SWITCH)
		{
			freq -= UNIVERSAL_HIGH;
			SetLnb(handle,1);		/* Select high band	*/
		}
		else
		{
			freq -= UNIVERSAL_LOW;
			SetLnb(handle,0);		/* Select low band	*/
		}
	}
#endif

    // [ZCH:Nick030902] >>>
	sym = tuning_info->ulSymbolRate;
	InitSearch(handle, freq, sym, 20000000L, 6, DRV_SEARCH);	/* Parameters for the search algorithm	*/
	AutoSearchAlgo(handle);										/* run the search algorithm				*/
	
	GetSearchResult(handle, &result);				/* retrieve the result of the search	*/ 

    // [zch:jz] now we have the accurate frequency and symbol rate, now modify the input parameters

	if (result.SignalType == RANGEOK)
    {
        UINT32 nRealV;

#ifdef LNB_SEPERATE
        //for C band. The freq is always less than 5150000,we can set switch to 6000000
        if(tuning_info->LnbSwitchFreq < 6000000)
        {
            nRealV = tuning_info->LnbSwitchFreq - result.Frequency;
        }
        else
        {
            nRealV = tuning_info->LnbSwitchFreq + result.Frequency;
        }

        tr_printf(("Real freq: %d sr:%d\n", nRealV, result.SymbolRate));
#else
        if (0 == tuning_info->ulLnbSwitchFreq)
        {
            // [zch:jz] this is for the universal lnb used in ZML
            nRealV = tuning_info->ulFrequency;            
    		if (nRealV > UNIVERSAL_SWITCH)
    		{
    			nRealV = result.Frequency + UNIVERSAL_HIGH;
    		}
    		else
    		{
    			nRealV = result.Frequency + UNIVERSAL_LOW;
    		}
        } 
		else
        {
            //for KU band. The LNB is always larger than 5150000,we can set switch to 6000000
            if (tuning_info->ulLnbSwitchFreq > 6000000L)
            {
                nRealV = tuning_info->ulLnbSwitchFreq + result.Frequency;
            }
            else
            {
                nRealV = tuning_info->ulLnbSwitchFreq - result.Frequency;
            }
            tr_printf(("Real freq: %d sr:%d\n", nRealV, result.SymbolRate));
        }
#endif
        tuning_info->ulFrequency = nRealV;

        // for symbol rate
        tuning_info->ulSymbolRate = result.SymbolRate;
	}
    //<<<

#ifdef _DEBUG	
	if (result.SignalType == RANGEOK) /* Display results */
	{
		tr_printf(("Transport FOUND: "));
		tr_printf(("Tuner frequency: %ld MHz ", result.Frequency));
		tr_printf(("Tuner symbol_rate: %ld MBd ", result.SymbolRate)); 
		
		switch (result.PunctureRate)
		{
			case PR1_2:
				tr_printf(("Rate 1/2"));
				break;
			
			case PR2_3:
				tr_printf(("Rate 2/3"));
				break;
			
			case PR3_4:
				tr_printf(("Rate 3/4"));
				break;
			
			case PR5_6:
				tr_printf(("Rate 5/6 (DVB) 6/7 (DirecTV)"));
				break;
			
			case PR7_8:
				tr_printf(("Rate 7/8"));
				break;
		}
		
		switch (result.Polarization)
		{
			case HORIZONTAL:
				tr_printf((" Horizontal polarization\n"));
				break;
			
			case VERTICAL:
				tr_printf((" Vertical polarization\n"));
				break;
		}

		tr_printf(("\n\n"));
	}
	else
	{
		tr_printf(("Transport NOT found!!\n\n"));
	}
#endif // _DEBUG

	return (result.SignalType == RANGEOK);
}

// //////////////////////////////////////////////////////////////////////////
// Function Name: 
//   D299_ScanRequest
//
// Input Parameters:
//   pRequest - Pointer to DEMOD_SCAN_REQUEST defined in OpenTV
//
// Return Value:
//  If the scanning operation is still in progress or an error was encountered, the
//  demodulator control driver should return FAILURE for a get request. Similarly,
//  the demodulator control driver should return FAILURE for a set operation if a
//  scanning operation is in progress or a located signal source has not been
//  unlocked.
//
// Description: 
//  Initiates a scanning operation for the demodulator identified by the 
//  last successful D299_SetScanMode (per demodulator).
//  When the demodulator locates a signal or encounters an error, a callback 
//  called with NOTIFY_D299_LOCKED.
// //////////////////////////////////////////////////////////////////////////
BOOL D299_ScanRequest(DEMOD_HANDLE handle, DEMOD_SCAN_REQUEST *pRequest)
{
	DEMOD_SAT_DATA *sDemodData = (DEMOD_SAT_DATA*)handle;
	int index;

	if (bAutoScanStarted == FALSE)
	{
		for (index=0 ; index<=MAX_NUMBER_OF_SYMBOL_RATES ; index++)
		{
			sDemodData->Params.SymbolRates[index] = 0;
		}	
		// select LNB, frequescies and SymbolRates accordind to Universal / C-Band / KU-Band:
		if (pRequest->descriptor.ulLnbSwitchFreq > 0)
		{
			sDemodData->Params.lnb[0] = 0;
			sDemodData->Params.lnb[1] = 0;
			if (pRequest->descriptor.ulLnbSwitchFreq == LNB_C_FREQ)
			{
	            // for c-band
				pRequest->descriptor.ulFrequency = LOW_C_FREQ;
				sDemodData->Params.lnb[2] = LNB_C_FREQ;
				sDemodData->Params.SymbolRates[0] = 26000000L;
				sDemodData->Params.SymbolRates[1] = 4420000L;
				sDemodData->Params.SymbolRates[2] = 27500000L;
				sDemodData->Params.SymbolRates[3] = 27250000L;
				sDemodData->Params.SymbolRates[4] = 13240000L;
				sDemodData->Params.SymbolRates[5] = 7272000L;
				sDemodData->Params.SymbolRates[6] = 28125000L;
				sDemodData->Params.SymbolRates[7] = 28000000L;
				sDemodData->Params.SymbolRates[8] = 3428000L;
				sDemodData->Params.SymbolRates[9] = 30000000L;
			}
			else
			{
				// for ku band
				pRequest->descriptor.ulFrequency = LOW_KU_FREQ;
				sDemodData->Params.lnb[2] = pRequest->descriptor.ulLnbSwitchFreq;
				sDemodData->Params.SymbolRates[0] = 27500000L;
				sDemodData->Params.SymbolRates[1] = 3677000L;
				sDemodData->Params.SymbolRates[2] = 28800000L;
				sDemodData->Params.SymbolRates[3] = 28066000L;
				sDemodData->Params.SymbolRates[4] = 32553000L;
				sDemodData->Params.SymbolRates[5] = 6000000L;
			}
		}
		else
		{
	         // universal
			pRequest->descriptor.ulFrequency = LOW_KU_FREQ;
			sDemodData->Params.lnb[0] = 9750000L;
			sDemodData->Params.lnb[1] = 10600000L;
			sDemodData->Params.lnb[2] = 11600000L;
			sDemodData->Params.SymbolRates[0] = 27500000L;
			sDemodData->Params.SymbolRates[1] = 28000000L;
			sDemodData->Params.SymbolRates[2] = 29900000L;
		}
											
		//dbg_printf(("direction = %d\n",pRequest->direction));	

		sDemodData->StartScanFrequency = pRequest->descriptor.ulFrequency;
		sDemodData->ScanCurrentFrequency = sDemodData->StartScanFrequency;
		switch (pRequest->direction)
		{
			case SCAN_LOCATE_PREVIOUS:
				// Scan down
				if (sDemodData->Params.lnb[2] == LNB_C_FREQ)
				{
					sDemodData->EndScanFrequency = LOW_C_FREQ;
				}
				else
				{
					sDemodData->EndScanFrequency = LOW_KU_FREQ;
				}
				break;

			case SCAN_LOCATE_EXACT:
				sDemodData->EndScanFrequency = pRequest->descriptor.ulFrequency;
				break;
				
			case SCAN_LOCATE_NEXT: // Scan up
				if (sDemodData->Params.lnb[2] == LNB_C_FREQ)
				{
					sDemodData->EndScanFrequency = HIGH_C_FREQ;
				}
				else
				{
					sDemodData->EndScanFrequency = HIGH_KU_FREQ;
				}
				break;
		}
		
		//dbg_printf(("Scan from %d to %d\n",sDemodData->StartScanFrequency, sDemodData->EndScanFrequency));
		StartAutoFrequencyScan(handle,6);
		bAutoScanStarted = TRUE;
    }

	ContinueAutoFrequencyScan(handle);

	return TRUE;
}

void D299_AbortScan(void)
{
	bAutoScanStarted = FALSE;
}

// //////////////////////////////////////////////////////////////////////////
// Function Name: 
//  D299_GetScanProgress
//
// Input Parameters:
//  demodulator - demodulator ID
//
// Return Value:
//   Number between 0 to 100 which represent the location of the current 
//   demodulator frequency in the demodulator frequency range  
//
// Description: 
//  This function return the percentage of the current frequency in the totlal 
//  possible frequency range of the specify demodulator. It may use for
//  display a progress bar while the auto scanning is active
// //////////////////////////////////////////////////////////////////////////
int D299_GetScanProgress(DEMOD_HANDLE handle)
{
	UINT32 range;
	DEMOD_SAT_DATA *sDemodData = (DEMOD_SAT_DATA*)handle;
	int iRetVal = 0;

	if (!bAutoScanStarted)
	{
		iRetVal = 0;
	}
	else if (sDemodData->EndScanFrequency > sDemodData->StartScanFrequency)
	{
		// Up scan
		range = sDemodData->EndScanFrequency-sDemodData->StartScanFrequency;
		iRetVal = (int)(100*(sDemodData->ScanCurrentFrequency-sDemodData->StartScanFrequency + 
				 ((sDemodData->ScanPolarization == HORIZONTAL) ? 0:range))/(2*range));
	}
	else
	{
		// Down scan
		range = sDemodData->StartScanFrequency-sDemodData->EndScanFrequency;
		iRetVal = (int)(min(100,100*(sDemodData->StartScanFrequency-sDemodData->ScanCurrentFrequency + 
				  ((sDemodData->ScanPolarization == HORIZONTAL) ? 0:range))/(2*range)));
	}
//	dbprintf(("D299_GetScanProgress %d\n", iRetVal));
	return iRetVal;
}

#endif // SATELLITE_299

#endif // FTA_SUPPORT

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -