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

📄 pe_iconfig.cpp

📁 这是DVD中伺服部分的核心代码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
 */
PE_STATUS PEiConfigureAMCloseSound(PE_HANDLE handle, PE_ICONFIGURE_AUDIO_INTERACTIVE_ID iaudio_id)
{
    PE_STATUS status = PE_SUCCESS;

    if (handle == NULL)
    {
        return (PE_INVALID_HANDLE);
    }

    status = PE_NOT_IMPLEMENTED;

    return (status);
}

/**
 * Set the video output to either NTSC or PAL format.
 *
 * @param handle - iConfigure handle.
 * @param VideoFormat - Enumerated video output format.
 *
 * @return PE_STATUS - PE Error code.
 *
 * @notes -- When video output format is changed, the graphics engine will automatically
 *           be disabled. The graphics engine will be re-enabled, but if there were graphics being
 *           displayed at the time of a video output format change, the graphics will NOT
 *           be re-displayed when the graphics engine is re-enabled, so the application
 *           may want to redraw the graphics.
 */
PE_STATUS PEiConfigureSetVideoOutput(PE_HANDLE handle, PE_ICONFIGURE_VIDEO_FORMAT VideoFormat)
{
    PE_ICONFIGURE_VIDEO_FORMAT     format;
    BOOLEAN                    new_video_format = false;
    BOOLEAN                    enable_hdmi_after_change = false;
    BOOLEAN                    enable_comp0_after_change = false;
    BOOLEAN                    enable_comp1_after_change = false;

    if (handle == NULL)
    {
        return (PE_INVALID_HANDLE);
    }
    if (VideoFormat > VIDEO_STANDBY)
    {
        return (PE_INVALID_PARAM);
    }

    new_video_format = (((PEHANDLE *)handle)->iConfigure->VideoFormat != VideoFormat)?true:false;

    if (new_video_format || ApplyEvent)
    {
        PE_ISPLASHSCREEN_ID splashScreenId = PE_ISPLASHCREEN_ID_INVALID;

        PEiSplashScreenGetDisplayedId(handle, &splashScreenId);

        /* Hide splashscreen if changing format */
        if ((splashScreenId != PE_ISPLASHCREEN_ID_INVALID) && new_video_format){
            PEiSplashScreenHide(handle);
        }
        
        /* TODO-SDK - Disable HDMI and component if enabled during format change */
        if ( new_video_format )
        {
        }

        if (VideoFormat == VIDEO_STANDBY)
        {
            /* TODO-SDK - Disable video outputs. */
            DBGPRINT(DBG_ON(DBG_TRACE), ("PEiConfigureSetVideoOutput -- VIDEO_STANDBY\n"));
        }
        else
        {
            if (new_video_format) {
                enable_hdmi_after_change = true;
            }

            /* We update the video format in two passess since all the code for
             * setting HD resolutions is the same, as well the code for NTSC and 
             * PAL are the same. The first pass prints out the detected format 
             * and sets the format variable, the second pass does all the work.
             */
            switch (VideoFormat)
            {
            case VIDEO_FORMAT_NTSC:
                DBGPRINT(DBG_ON(DBG_TRACE), ("PEiConfigureSetVideoOutput -- VIDEO_FORMAT_NTSC\n"));
                format = VIDEO_FORMAT_NTSC;
                break;
            case VIDEO_FORMAT_PAL:
            case VIDEO_FORMAT_576P:            
                DBGPRINT(DBG_ON(DBG_TRACE), ("PEiConfigureSetVideoOutput -- VIDEO_FORMAT_PAL\n"));
                format = VIDEO_FORMAT_PAL;
                break;
            case VIDEO_FORMAT_480P:
                DBGPRINT(DBG_ON(DBG_TRACE), ("PEiConfigureSetVideoOutput -- VIDEO_FORMAT_480P\n"));
                format = VIDEO_FORMAT_480P;
                break;
            case VIDEO_FORMAT_720P:
                DBGPRINT(DBG_ON(DBG_TRACE), ("PEiConfigureSetVideoOutput -- VIDEO_FORMAT_720P\n"));
                format = VIDEO_FORMAT_720P;
                break;
            case VIDEO_FORMAT_720P_24:
            case VIDEO_FORMAT_720P_23_976:
                DBGPRINT(DBG_ON(DBG_TRACE), ("PEiConfigureSetVideoOutput -- VIDEO_FORMAT_720P_24\n"));
                format = VIDEO_FORMAT_720P_24;
                break;
            case VIDEO_FORMAT_720P_50:
                DBGPRINT(DBG_ON(DBG_TRACE), ("PEiConfigureSetVideoOutput -- VIDEO_FORMAT_720P_50\n"));
                format = VIDEO_FORMAT_720P_50;
                break;
            case VIDEO_FORMAT_1080I:
                DBGPRINT(DBG_ON(DBG_TRACE), ("PEiConfigureSetVideoOutput -- VIDEO_FORMAT_1080I\n"));
                format = VIDEO_FORMAT_1080I;
                break;
            case VIDEO_FORMAT_1080I_25:
                DBGPRINT(DBG_ON(DBG_TRACE), ("PEiConfigureSetVideoOutput -- VIDEO_FORMAT_1080I_25\n"));
                format = VIDEO_FORMAT_1080I;
                break;
            case VIDEO_FORMAT_1080P_24:
            case VIDEO_FORMAT_1080P_23_976:
                DBGPRINT(DBG_ON(DBG_TRACE), ("PEiConfigureSetVideoOutput -- VIDEO_FORMAT_1080P_24\n"));
                format = VIDEO_FORMAT_1080P;
                break;
            default:
                DBGPRINT(DBG_ON(DBG_ERROR), ("PEiConfigureSetVideoOutput -- FORMAT NOT SUPPORTED\n")); 
                return PE_FAILURE;
                break;
            }

            
            /* Now we do a second pass to Process the SD & HD Formats */
            switch (VideoFormat)
            {
            /* Process SD Formats */
            case VIDEO_FORMAT_NTSC:
            case VIDEO_FORMAT_PAL:
                DBGPRINT(DBG_ON(DBG_TRACE), ("PEiConfigureSetVideoOutput -- Processing SD\n"));
                switch (primaryDisplay)
                {
                case PRIMARY_DISPLAY_COMPOSITE:
                case PRIMARY_DISPLAY_SVIDEO:
                    // format;
#ifdef SECONDARY_DISPLAY_SUPPORT
                    // format;
                    enable_comp1_after_change   = (dotPresent)?false:true;
#endif
                break;
                default:
                    // format;
                    enable_comp0_after_change   = (dotPresent)?false:true;
#ifdef SECONDARY_DISPLAY_SUPPORT
                    // format;
#endif
                break;
                }
                break;

            /* HD Formats (we can use default because the previous switch
             * case took care of removing unsupported video formats */                
            default:
                DBGPRINT(DBG_ON(DBG_TRACE), ("PEiConfigureSetVideoOutput -- Processing HD\n"));
                switch (primaryDisplay)
                {
                case PRIMARY_DISPLAY_COMPOSITE:
                case PRIMARY_DISPLAY_SVIDEO:
                    // format     = (dotPresent)?format:VIDEO_FORMAT_NTSC;
                    VideoFormat                 = (dotPresent)?VideoFormat:VIDEO_FORMAT_NTSC;
                    /* We can only put either component or composite/s-video on the first display */
#ifdef SECONDARY_DISPLAY_SUPPORT
                    // format    = VIDEO_FORMAT_NTSC;
                    enable_comp1_after_change   = (dotPresent)?false:true;
#endif
                break;
                case PRIMARY_DISPLAY_HDMI:
                    // format     = format;
                    enable_comp0_after_change    = (dotPresent||ictPresent)?false:true;
#ifdef SECONDARY_DISPLAY_SUPPORT
                    // format    = VIDEO_FORMAT_NTSC;
                    /* component and composite/s-video can be on the second display at the same time */
                    if (dotPresent) {
                    }
                    else {
                        enable_comp1_after_change   = (ictPresent)?true:false;
                    }
#endif
                break;
                default:
                    // format     = (ictPresent)?VIDEO_FORMAT_480P:format;
                    VideoFormat                 = (ictPresent)?VIDEO_FORMAT_480P:VideoFormat;
                    enable_comp0_after_change   = (dotPresent)?false:true;
#ifdef SECONDARY_DISPLAY_SUPPORT
                    // format    = VIDEO_FORMAT_NTSC;
#endif
                break;
                }
            break;
            }
        }

        /* apply display settings */

 #ifdef SECONDARY_DISPLAY_SUPPORT

#endif

        if ( (enable_hdmi_after_change || enable_comp0_after_change) && (new_video_format || ApplyEvent))
        {
            if (enable_hdmi_after_change) {
                // dvi hdcp = false;

            }

            if (enable_comp0_after_change) {
            }

            /* apply display settings */
        }
        if (enable_comp1_after_change && (new_video_format || ApplyEvent))
        {

            /* apply display settings */
        }

        /* Re-build the Line 20 information with new Macrovision/CGMS/WSS
         * to conform to IEC-61880*/
        PEiConfigureUpdateVBI(handle);

        if (new_video_format) {
            /* re-enable the graphics engine and signal DirectFB of the
             * display resolution change */
            switch (VideoFormat)
            {
                case VIDEO_FORMAT_NTSC:
                case VIDEO_FORMAT_480P:
                    DFBCHECK( pDfb->SetVideoMode(pDfb, 720, 480, 32) );
                    break;
                case VIDEO_FORMAT_720P_59_94:
                case VIDEO_FORMAT_720P_50:
                case VIDEO_FORMAT_720P_24:
                case VIDEO_FORMAT_720P_23_976:
                    DFBCHECK( pDfb->SetVideoMode(pDfb, 1280, 720, 32) );
                    break;
                case VIDEO_FORMAT_1080I_29_97:
                case VIDEO_FORMAT_1080I_25:
                case VIDEO_FORMAT_1080P_24:
                case VIDEO_FORMAT_1080P_23_976:
                    DFBCHECK( pDfb->SetVideoMode(pDfb, 1920, 1080, 32) );
                    break;
                case VIDEO_FORMAT_PAL:
                case VIDEO_FORMAT_576P:
                    DFBCHECK( pDfb->SetVideoMode(pDfb, 720, 576, 32) );
                    break;
                default:
                    break;
            }
        }

        /* TODO: The following code might have to change if there is support
         * in the osd to turn on and off the CC
         */
        if (((primaryDisplay==PRIMARY_DISPLAY_HDMI)||(primaryDisplay==PRIMARY_DISPLAY_COMPONENT)) &&
            (VideoFormat == VIDEO_FORMAT_NTSC))
        {
            // setup close caption
        }
#ifdef SECONDARY_DISPLAY_SUPPORT
        else
        {
            /* TODO-SDK - Enable video outputs based on input parameters. */
            // setup close caption
        }  
#endif
        

        if (new_video_format){
            if (splashScreenId != PE_ISPLASHCREEN_ID_INVALID) {
                PEiSplashScreenDisplay(handle, splashScreenId);
            }
        }

        ((PEHANDLE *)handle)->iConfigure->VideoFormat = VideoFormat;
        
        ApplyEvent = FALSE;
    }

    return (PE_SUCCESS);
}

/**
 * Returns the current video output format.
 *
 * @param handle - iConfigure handle.
 * @param pVideoFormat - Pointer returned to enumerated variable indicating current video output format.
 *
 * @return PE_STATUS - PE Error code.
 */
PE_STATUS PEiConfigureGetVideoOutput(PE_HANDLE handle, PE_ICONFIGURE_VIDEO_FORMAT *pVideoFormat)
{
    if (handle == NULL)
    {
        return (PE_INVALID_HANDLE);
    }
    DbgAssert(pVideoFormat != NULL);

    *pVideoFormat = ((PEHANDLE *)handle)->iConfigure->VideoFormat;

    return (PE_SUCCESS);
}

/**
 * PEiConfigureSetAspectRatio() Sets the video aspect ratio.
 *
 * @param handle [IN] iConfigure handle.
 * @param AspectRatio [IN] Enumerated aspect ratio value.
 *
 * @return PE_STATUS Error code.
 *
 * @notes Valid ratios: 4:3 PanScan, 4:3 Letterbox, 4:3 Letterbox removed, 16:9.
 */
PE_STATUS PEiConfigureSetAspectRatio(PE_HANDLE handle, PE_ICONFIGURE_ASPECT_RATIO AspectRatio)
{
    PE_STATUS               status = PE_SUCCESS;
    
    DBGPRINT(DBG_ON(DBG_TRACE), ("PEiConfigureSetAspectRatio\n"));

    if (handle == NULL)
    {
        return (PE_INVALID_HANDLE);
    }
    if (AspectRatio >= ASPECT_RATIO_INVALID)
    {
        return (PE_INVALID_PARAM);
    }

    /* TODO-SDK - Apply the proper aspect ratio */

    switch (AspectRatio)
    {
    case ASPECT_RATIO_4X3_PANSCAN:
        DBGPRINT(DBG_ON(DBG_TRACE), ("PEiConfigureSetAspectRatio: ASPECT_RATIO_4X3_PANSCAN\n"));
        // aspect_ratio = AspectRatio;
        // content_mode = AspectRatio;
        status = PE_SUCCESS;
        break;

    case ASPECT_RATIO_4X3_LETTERBOX:
        DBGPRINT(DBG_ON(DBG_TRACE), ("PEiConfigureSetAspectRatio: ASPECT_RATIO_4X3_LETTERBOX\n"));
        // aspect_ratio = AspectRatio;
        // content_mode = AspectRatio;
        status = PE_SUCCESS;
        break;

    case ASPECT_RATIO_4X3_LETTERBOX_REMOVED:
        DBGPRINT(DBG_ON(DBG_TRACE), ("PEiConfigureSetAspectRatio: ASPECT_RATIO_4X3_LETTERBOX_REMOVED\n"));
        // aspect_ratio = AspectRatio;
        // content_mode = AspectRatio;
        status = PE_SUCCESS;
        break;

    case ASPECT_RATIO_16X9_WINDOWBOX:
        DBGPRINT(DBG_ON(DBG_TRACE), ("PEiConfigureSetAspectRatio: ASPECT_RATIO_16x9_WINDOWBOX\n"));
        // aspect_ratio = AspectRatio;
        // content_mode = AspectRatio;
        status = PE_SUCCESS;
        break;

    case ASPECT_RATIO_16X9:
        DBGPRINT(DBG_ON(DBG_TRACE), ("PEiConfigureSetAspectRatio: ASPECT_RATIO_16X9\n"));
        // aspect_ratio = AspectRatio;
        // content_mode = AspectRatio;
        status = PE_SUCCESS;
        break;

    default:
        DbgPrint(("pe_iconfig ERROR: AspectRatio unknown\n"));
        status = PE_INVALID_PARAM;
        break;
    }


#ifdef SECONDARY_DISPLAY_SUPPORT
    if (status == PE_SUCCESS)
    {
        // aspect_ratio = display_settings.aspect_ratio;
        // content_mode = display_settings.content_mode;
    }
#endif

    if (status == PE_SUCCESS)
    {
        ((PEHANDLE *)handle)->iConfigure->AspectRatio = AspectRatio;
    }

    status = PEiConfigureUpdateVBI(handle);

    return (status);
}

/**
 * Returns the current video aspect ratio.
 *
 * @param handle [IN] iConfigure handle.
 * @param pAspectRatio [IN] Pointer to returned aspect ratio value.
 *
 * @return PE_STATUS - Error code.
 *
 * @notes Valid ratios: 4:3 PanScan, 4:3 Letterbox, 4:3 Letterbox removed, 16:9.
 */
PE_STATUS PEiConfigureGetAspectRatio(PE_HANDLE handle, PE_ICONFIGURE_ASPECT_RATIO *pAspectRatio)
{
    if (handle == NULL)
    {
        return (PE_INVALID_HANDLE);
    }
    if (pAspectRatio == NULL)
    {
        return (PE_NULL_POINTER);
    }

    *pAspectRatio = ((PEHANDLE *)handle)->iConfigure->AspectRatio;

    return (PE_SUCCESS);
}

/**
 * Calls the platform api to write CGMS data on the video output.
 * This function will implement the "AACS Interm Adoption Agreement 2006/02/15"
 * that states (related to CGMS-A):
 *      480i:  Line 20 & 283 (IEC 61880:1998) & line 21 (EIA/CEA-608-C)
 *      480p:  Line 41 (IEC 61880-2:2002) (first generation)
 *      720p:  Line 24 (JEITA EIAJ CPR 1204-2 & IEC 61880:1998)
 *      1080i: Line 19 & 582 (JEITA EIAJ CPR 1204-2 & IEC 61880:1998)
 *
 * @param handle [IN] iConfigure handle.
 * @param cgmsData [IN] Value to output persistantly
 *
 * @return PE_STATUS - Error code.
 *
 */

PE_STATUS PEiConfigureSetCGMS(PE_HANDLE handle, USHORT cgmsData)
{
    PE_STATUS result;
    if (!handle)
        return (PE_INVALID_HANDLE);

    ((PEHANDLE *)handle)->iConfigure->CGMS = cgmsData;
    result = PEiConfigureUpdateVBI(handle);

    return result;
}


static PE_STATUS PEiConfigureUpdateVBI(PE_HANDLE handle)
{
    uint8   wss = 0;

 
    DBGPRINT(DBG_ON(DBG_TRACE), ("PEiConfigureUpdateVBI\n"));

    if (!handle)
        return (PE_INVALID_HANDLE);

    /* WSS: Word 0 bits 1 & 2 */
    switch (((PEHANDLE *)handle)->iConfigure->VideoFormat)
    {
        /* HD format */
        case VIDEO_FORMAT_720P:
        case VIDEO_FORMAT_720P_24:
        case VIDEO_FORMAT_720P_23_976:
        case VIDEO_FORMAT_720P_50:
        case VIDEO_FORMAT_1080I:
        case VIDEO_FORMAT_1080I_25:
        case VIDEO_FORMAT_1080P_24:
        case VIDEO_FORMAT_1080P_23_976:
            wss = 0x2;             
        break;

        default: /* SD Format */
            switch (((PEHANDLE *)handle)->iConfigure->AspectRatio)
            {
                case ASPECT_RATIO_4X3_LETTERBOX_REMOVED: 
                    wss = 0x0;    
                break;
                    
                case ASPECT_RATIO_4X3_PANSCAN:                  
                case ASPECT_RATIO_4X3_LETTERBOX:         
                    wss = 0x1;
                break;

⌨️ 快捷键说明

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