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

📄 sttuner.c

📁 这是DVB tuner驱动部分和其它相关的源码和一些技术资料文档.
💻 C
📖 第 1 页 / 共 4 页
字号:
    TUNER_ControlBlock_t *Tuner_p;    /* Check the parameters */    if((Handle == 0) || (ScanList_p == NULL))    {        return ST_ERROR_BAD_PARAMETER;    }    /* Obtain the control block from the handle */    Tuner_p = GetControlBlockFromHandle(Handle);    /* Ensure the handle is valid */    if (Tuner_p != NULL)    {        /* Check device is idle before setting new list */        if (Tuner_p->TunerInfo.Status != STTUNER_STATUS_SCANNING)        {            /* Ensure the tuner is not currently scanning */            if (Tuner_p->InitParams.ScanListMax >= ScanList_p->NumElements)            {                /* Copy the supplied scan list into the                 * tuner control block.                 */                semaphore_wait(&Tuner_p->ScanTask.GuardSemaphore);                Tuner_p->ScanList.NumElements = ScanList_p->NumElements;                memcpy(Tuner_p->ScanList.ScanList,                       ScanList_p->ScanList,                       (ScanList_p->NumElements * sizeof(STTUNER_Scan_t)));                semaphore_signal(&Tuner_p->ScanTask.GuardSemaphore);            }            else            {                /* Number of elements exceeds maximum allowed */                Error = ST_ERROR_BAD_PARAMETER;            }        }        else        {            /* Scan task is busy */            Error = ST_ERROR_DEVICE_BUSY;        }    }    else    {        /* The handle is invalid */        Error = ST_ERROR_INVALID_HANDLE;    }    /* Common exit point */    return Error;} /* STTUNER_SetScanList() *//*****************************************************************************Name: STTUNER_Term()Description:    Terminates the tuner driver.  If a force terminate is required, then    the open handle will be closed also.Parameters:    DeviceName, the tuner device name as set during initialization.    TermParams_p, parameters to guide termination of the driver.Return Value:    ST_NO_ERROR,                the operation was carried out without error.    ST_ERROR_UNKNOWN_DEVICE     the device name is invalid.    ST_ERROR_OPEN_HANDLE,       a handle is still open -- unable to term.    ST_ERROR_BAD_PARAMETER      TermParams_p NULLSee Also:    STTUNER_Init()*****************************************************************************/ST_ErrorCode_t STTUNER_Term(ST_DeviceName_t DeviceName,                            const STTUNER_TermParams_t *TermParams_p){    ST_ErrorCode_t Error = ST_NO_ERROR;    TUNER_ControlBlock_t *Tuner_p;    /* Check the parameters */    if(TermParams_p == NULL)    {        return ST_ERROR_BAD_PARAMETER;    }            /* Obtain the control block from the handle */    Tuner_p = GetControlBlockFromName(DeviceName);    /* Ensure the handle is valid */    if (Tuner_p != NULL)    {        /* We should go ahead and terminate if either:         * a) the caller has specified a force terminate, or         * b) the tuner handle is not open         */        if (TermParams_p->ForceTerminate ||            Tuner_p->Handle == 0)        {            Node_t *Last_p, *This_p;            /* If the handle is open, then the we've been asked to force             * the termination.             */            if (Tuner_p->Handle != 0)            {                /* The only way this call could fail is if the handle is                 * invalid -- but we know that this is the correct handle.                 */                STTUNER_Close(Tuner_p->Handle);            }            /* Terminate all tuner components */            TUNER_Term(Tuner_p);            /* Close I2C handles */            STI2C_Close(Tuner_p->I2CTunerHandle);            STI2C_Close(Tuner_p->I2CDemodHandle);            /* Clear out the device name */            *Tuner_p->DeviceName = 0;            /* Find node associated with this control block and remove it from             * the list.             */            This_p = FindNode(DeviceQueue_p, IsDeviceName, DeviceName, &Last_p);            if (This_p != NULL)            {                RemoveNode(Last_p, This_p);                /* Free memory associated with the node */                memory_deallocate(Tuner_p->InitParams.DriverPartition,                                  This_p);                interrupt_lock();       /* This operation must be atomic */                /* If this is the root element in the device queue, nullify it */                if (This_p == DeviceQueue_p)                    DeviceQueue_p = NULL;                interrupt_unlock();            }        }        else        {            /* A handle is still open */            Error = ST_ERROR_OPEN_HANDLE;        }    }    else    {        /* The device name is invalid */        Error = ST_ERROR_UNKNOWN_DEVICE;    }    /* Common exit point */    return Error;} /* STTUNER_Term() *//*****************************************************************************Name: STTUNER_SetThresholdList()Description:    Sets the current threshold list for checking the signal quality value.    The caller-specificed callback may be invoked if the signal threshold    changes position in the threshold list.Parameters:    Handle,           the handle of the tuner device.    ThresholdList_p,  pointer to a threshold list for signal checking.    QualityFormat,    units of measurement used in threshold list values.Return Value:    ST_NO_ERROR,                the operation was carried out without error.    ST_ERROR_INVALID_HANDLE,    the handle was invalid.    ST_ERROR_BAD_PARAMETER      Handle or ThresholdList_p NULL See Also:    STTUNER_GetThresholdList()*****************************************************************************/ST_ErrorCode_t STTUNER_SetThresholdList(STTUNER_Handle_t Handle,                                        const STTUNER_ThresholdList_t *ThresholdList_p,                                        STTUNER_QualityFormat_t QualityFormat){    ST_ErrorCode_t Error = ST_NO_ERROR;    TUNER_ControlBlock_t *Tuner_p;    /* Check the parameters */    if((Handle == 0) || (ThresholdList_p == NULL) ||     ((QualityFormat != STTUNER_QUALITY_BER) &&      (QualityFormat != STTUNER_QUALITY_CN)))    {        return ST_ERROR_BAD_PARAMETER;    }        /* Obtain the control block from the handle */    Tuner_p = GetControlBlockFromHandle(Handle);    /* Ensure the handle is valid */    if (Tuner_p != NULL)    {        /* Check device is idle before setting new list */        if (Tuner_p->TunerInfo.Status != STTUNER_STATUS_SCANNING)        {            if (Tuner_p->InitParams.SignalListMax >= ThresholdList_p->NumElements)            {                /* Copy the supplied threshold list into the tuner control block.                 * Also flag the tuner to begin signal checking at this point.                 */                semaphore_wait(&Tuner_p->ScanTask.GuardSemaphore);                Tuner_p->ThresholdList.NumElements = ThresholdList_p->NumElements;                memcpy(Tuner_p->ThresholdList.ThresholdList,                       ThresholdList_p->ThresholdList,                       (ThresholdList_p->NumElements *                        sizeof(STTUNER_SignalThreshold_t)));                Tuner_p->QualityFormat = QualityFormat;                semaphore_signal(&Tuner_p->ScanTask.GuardSemaphore);            }            else            {                /* Number of elements exceeds maximum allowed */                Error = ST_ERROR_BAD_PARAMETER;            }        }        else        {            /* Scan task is busy */            Error = ST_ERROR_DEVICE_BUSY;        }    }    else    {        /* The handle is invalid */        Error = ST_ERROR_INVALID_HANDLE;    }    /* Common exit point */    return Error;} /* STTUNER_SetThresholdList() *//*****************************************************************************STTUNER_Unlock()Description:    Aborts the current scan i.e., the scan status will subsequently become    'unlocked'.Parameters:    Handle,     the handle of the tuner device.Return Value:    ST_NO_ERROR,                the operation completed without error.    ST_ERROR_INVALID_HANDLE,    the handle is invalid.    ST_ERROR_BAD_PARAMETER      Handle NULL See Also:    Nothing.*****************************************************************************/ST_ErrorCode_t STTUNER_Unlock(STTUNER_Handle_t Handle){    ST_ErrorCode_t Error = ST_NO_ERROR;    TUNER_ControlBlock_t *Tuner_p;        /* Check the parameters */    if(Handle == 0)    {        return ST_ERROR_BAD_PARAMETER;    }            /* Obtain the control block from the handle */    Tuner_p = GetControlBlockFromHandle(Handle);    /* Ensure the handle is valid */    if (Tuner_p != NULL)    {        Error = TUNER_AbortScan(Tuner_p);    }    else    {        /* The handle is invalid */        Error = ST_ERROR_INVALID_HANDLE;    }    /* Common exit point */    return Error;} /* STTUNER_Unlock() *//* Private functions ------------------------------------------------------ */static void AppendNode(Node_t *Start_p, Node_t *New_p, void *Data_p){    Node_t *qp;    qp = LastNode(Start_p);    InsertNode(qp, New_p, Data_p);} /* AppendNode() */static void InsertNode(Node_t *Start_p, Node_t *New_p, void *Data_p){    Node_t *Next_p = NULL;    if (Start_p != NULL)    {        Next_p = Start_p->Next_p;        Start_p->Next_p = New_p;    }    New_p->Next_p = Next_p;    New_p->This_p = Data_p;} /* InsertNode() */static void RemoveNode(Node_t *Before_p, Node_t *Old_p){    if (Before_p != NULL)        Before_p->Next_p = Old_p->Next_p;} /* RemoveNode() */static Node_t *FindNode(const Node_t *Start_p,                        BOOL (*CompareFunction)(const void *, const void *),                        const void *Compare_p,                        Node_t **Predecessor_p){    const Node_t *x, *qp = Start_p;    if (Predecessor_p != NULL)        *Predecessor_p = NULL;    while (qp != NULL)                  /* Iterate through the nodes */    {        /* Check for compare function match */        if (!CompareFunction(qp->This_p, Compare_p))        {            /* Next node in the queue */            x = qp;            qp = NextNode(x);        }        else        {            /* The node has been found */            break;        }        if (Predecessor_p != NULL)            *Predecessor_p = (Node_t *)x;    }    /* Return the node to the caller */    return (Node_t *)qp;} /* FindNode() */static Node_t *NextNode(const Node_t *Start_p){    if (Start_p != NULL)        return Start_p->Next_p;    else        return NULL;} /* NextNode() */static Node_t *LastNode(const Node_t *Start_p){    const Node_t *qp;    qp = Start_p;    while (NextNode(qp) != NULL)        qp = NextNode(qp);    /* Return the node to the caller */    return (Node_t *)qp;} /* LastNode() */static BOOL IsDeviceName(const void *Tuner_p, const void *DeviceName_p){    /* Check the device name for a match with the item in the queue */    if (strcmp(((TUNER_ControlBlock_t *)Tuner_p)->DeviceName,               (char *)DeviceName_p) == 0)        return TRUE;    else        return FALSE;} /* IsDeviceName() */static BOOL IsHandle(const void *Tuner_p, const void *Handle_p){    /* Check the device name for a match with the item in the queue */    if  (((TUNER_ControlBlock_t *)Tuner_p)->Handle ==         *(STTUNER_Handle_t *)Handle_p &&         *(STTUNER_Handle_t *)Handle_p != 0)        return TRUE;    else        return FALSE;} /* IsHandle() *//* End of module */

⌨️ 快捷键说明

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