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

📄 ircmd_switch_media.c

📁 mp3 player program please read carefully.
💻 C
📖 第 1 页 / 共 4 页
字号:
/**************************************************************************
 *                                                                        *
 *         Copyright (c) 2002 by Sunplus Technology Co., Ltd.             *
 *                                                                        *
 *  This software is copyrighted by and is the property of Sunplus        *
 *  Technology Co., Ltd. All rights are reserved by Sunplus Technology    *
 *  Co., Ltd. This software may only be used in accordance with the       *
 *  corresponding license agreement. Any unauthorized use, duplication,   *
 *  distribution, or disclosure of this software is expressly forbidden.  *
 *                                                                        *
 *  This Copyright notice MUST not be removed or modified without prior   *
 *  written consent of Sunplus Technology Co., Ltd.                       *
 *                                                                        *
 *  Sunplus Technology Co., Ltd. reserves the right to modify this        *
 *  software without notice.                                              *
 *                                                                        *
 *  Sunplus Technology Co., Ltd.                                          *
 *  19, Innovation First Road, Science-Based Industrial Park,             *
 *  Hsin-Chu, Taiwan, R.O.C.                                              *
 **************************************************************************/
/*-------------------------------------------------------------------------
|  File Name   : ircmd_switch_media.c
|
|  Description : This file was created for switching media.
| 
|  Rev	Date	        Author(s)                       Status & Comments
|--------------------------------------------------------------------------
|  0.1	2006/6/13       WangWei                         Creating
|-------------------------------------------------------------------------*/


#ifdef DIRECT_ACCESS_MEDIA

/****************************************************************************************\
**                                     Includes                                         **
\****************************************************************************************/
#include "atapi_if.h"
#include "func.h"
#include "cardfs.h"
#include "usb.h"
#include "ircmd_switch_media.h"
#if defined(SPHE8202_CARD_STORAGE)&& defined(CARD_SETUP_TYPE_ONLY_1SENSE_PIN)
UINT8 sd_ms_card_flag=1;  // Because have only one sense pin, so we check sd/mmc or ms card by turn.
                                         // We use this flag to index which card to be checked. aerliqu, 2007-08-08 
#endif

/****************************************************************************************\
**                                    Constants                                         **
\****************************************************************************************/
const BYTE* bMediaStr[] = 
{
#ifndef NO_DVD_SERVO
    "DISC",
#endif//NO_DVD_SERVO
    
#ifdef SPHE8202_CARD_STORAGE
    "CARD",
#endif//SPHE8202_CARD_STORAGE
    
#ifdef SUPPORT_USB
    "USB",
#endif//SUPPORT_USB
};

/****************************************************************************************\
**                                    Functions                                         **
\****************************************************************************************/

/****************************************************************************************\
**  Function Name : is_card_media_exists                                                **
**  Purposes      : Check if card is pluged in the socket.                              **
**  Limitations   : (none)                                                              **
**  Arguments     : (none)                                                              **
**  Returns       : card is in : ture / card is out : false                             **
**  See also      :                                                                     **
\****************************************************************************************/
#ifdef SPHE8202_CARD_STORAGE
UINT32 is_card_media_exists(void)
{
    Detect_Card_Storage();
    
    if ((detect_type & MS_CARD_DEVICE)
    || (detect_type & SD_CARD_DEVICE)
#ifdef CARD_SETUP_TYPE_3// All in 1
    || (detect_type & CF_CARD_DEVICE)
    || (detect_type & SMC_CARD_DEVICE)
#endif//CARD_SETUP_TYPE_3
    )
    {
        storage_type = detect_type;
        return TRUE;
    }
    else
    {
        return FALSE;    
    }
}
#endif//SPHE8202_CARD_STORAGE


/****************************************************************************************\
**  Function Name : is_usb_media_exists                                                 **
**  Purposes      : Check if USB device is pluged in host.                              **
**  Limitations   : (none)                                                              **
**  Arguments     : (none)                                                              **
**  Returns       : USB device is in : ture / USB device is out : false                 **
**  See also      :                                                                     **
\****************************************************************************************/
#ifdef SUPPORT_USB
UINT32 is_usb_media_exists(void)
{
    uhci_slaveDetect();
    
    if (detect_type & USB_DEVICE)
    {
        storage_type = detect_type;
        return TRUE;
    }
    else
        return FALSE;    
}
#endif//SUPPORT_USB


/****************************************************************************************\
**  Function Name : switch_2_des_media                                                  **
**  Purposes      : Switch to destination.                                              **
**  Limitations   : (none)                                                              **
**  Arguments     : uiDestination : DES_USB / DES_CARD / DES_DISC                       **
**  Returns       : (none)                                                              **
**  See also      :                                                                     **
\****************************************************************************************/
void switch_2_des_media(
    UINT32 uiDestination
)
{
	prog_cnt = 0;			//zhongshan for switch media clear prog 2007-4-28 12:01AM
	prog_func_clear();		//zhongshan for switch media clear prog 2007-4-28 12:01AM
    //interrupt AV
    AVD_SetMediaTimeout();
    //stop loader
    atapi_p_start_stop_unit(Immed_1, START_STOP_DO_STOP);
    //init variable, treat it as open tray
    InitVar();

    switch (uiDestination)
    {
    #ifdef SPHE8202_CARD_STORAGE
        case DES_CARD://switch to CARD

        #ifdef ONE_KEY_NO_GUI_TOGGLE_SWITCHING
            psprintf(RegionValStr[ REGION1 ], "[CARD MODE]");
            PrintOsdMsg(STR_OS_SPACE, REGION1, 1, 1);
        #endif//ONE_KEY_NO_GUI_TOGGLE_SWITCHING
            
            GPIO_O_SET(CARD_POWER_RESET, 0);//card power on, lighting the CARD LED.
            media_status = STATUS_CARD;
            
        #ifdef SUPPORT_USB
            SLAVE_ENUMERATED = FALSE;
        #endif//SUPPORT_USB
            
            detect_type = 0;
            card_plug_state = 0; //use this flag to distinguish if media exist. robert.chang, 2007-05-25
            if (atapi_p_mechanism_status() == ATAPI_DOOR_OPEN)
                ircmd_trayin();
            else
                atapi_p_start_stop_unit(Immed_1,START_STOP_DO_STOP);
        
            break;
    #endif//SPHE8202_CARD_STORAGE
    
    #ifdef SUPPORT_USB
        case DES_USB://switch to USB device
        
        #ifdef ONE_KEY_NO_GUI_TOGGLE_SWITCHING
            psprintf(RegionValStr[REGION1], "[USB MODE]");
            PrintOsdMsg(STR_OS_SPACE, REGION1, 1, 1);
        #endif//ONE_KEY_NO_GUI_TOGGLE_SWITCHING
            
        #ifdef SPHE8202_CARD_STORAGE
            GPIO_O_SET(CARD_POWER_RESET, 1);//CARD power off.
        #endif//SPHE8202_CARD_STORAGE
    
            media_status = STATUS_USB;
            SLAVE_ENUMERATED = FALSE;
            detect_type = 0;
            card_plug_state = 0; //use this flag to distinguish if media exist. robert.chang, 2007-05-25 
            if (atapi_p_mechanism_status() == ATAPI_DOOR_OPEN)
                ircmd_trayin();
            else
                atapi_p_start_stop_unit(Immed_1, START_STOP_DO_STOP);
            
            break;
    #endif//SUPPORT_USB
        
    #ifndef NO_DVD_SERVO
        case DES_DISC://switch to DISC

        // servo and card reader share two pins, so we have to reset the pin before running the servo. robert.chang
        #if defined(CARD_SETUP_TYPE_4)&&defined(CARD_SETUP_TYPE_ONLY_1SENSE_PIN)
            regs0->gpio_first[0] |= (0x3f<<4);	//Set Pin117~122 as GPIO
            regs0->gpio_master[0] |= (0x3f<<4);	//Set GPIO4~9 to be controlled by RISC
            regs0->gpio_oe[0] &=  ~(0x3f<<4);	//Set GPIO4~9 as Input. 
        #endif
        #if defined(SPHE8202_CARD_STORAGE)&& defined(CARD_SETUP_TYPE_ONLY_1SENSE_PIN)
	     	sd_ms_card_flag = 1;  // clear for disc to ms,aerliqu,2007-8-8;
	  	  #endif
        #ifdef ONE_KEY_NO_GUI_TOGGLE_SWITCHING
            psprintf(RegionValStr[ REGION1 ], "[DISC MODE]");
            PrintOsdMsg(STR_OS_SPACE, REGION1, 1, 1);
        #endif//ONE_KEY_NO_GUI_TOGGLE_SWITCHING
            
        #ifdef SPHE8202_CARD_STORAGE
            GPIO_O_SET(CARD_POWER_RESET, 1);//CARD power off.
        #endif
        
        #ifdef SUPPORT_USB
            SLAVE_ENUMERATED = FALSE;
        #endif//SUPPORT_USB
            media_status = STATUS_DISC;
            no_disk_cnt = DETECT_TIMES;
            system_state = SYSTEM_OPEN;
            media_type = MEDIA_CD;
            adv_search_time = 0;
            atapi_open_tray();
            atapi_close_tray(0);
            detect_type = 0;
            storage_type = 0;
            
            break;
    #endif//NO_DVD_SERVO
        
        default:
            break;
    }

    ircmd_post_func(CMD_FUNC | CMD_FUNC_OPEN);
    system_state = SYSTEM_OPEN;
    play_state = VCD_STATE_CLOSE;
    
#ifndef ONE_KEY_NO_GUI_TOGGLE_SWITCHING
    ClearOsdMsg(0);
    full_scrn = 0;
    t_disp = 0;
    osd0_state = OSD0_STATE_INIT;
    osd_init();
#endif//ONE_KEY_NO_GUI_TOGGLE_SWITCHING
}


/****************************************************************************************\
**  Function Name : osd_print_storage_detect_info                                       **
**  Purposes      : Print switch media debug message.                                   **
**  Limitations   : (none)                                                              **
**  Arguments     : (none)                                                              **
**  Returns       : (none)                                                              **
**  See also      :                                                                     **
\****************************************************************************************/
void osd_print_storage_detect_info( void )
{
    psprintf(RegionValStr[REGION2], "DET-%x STO-%x MED-%x MES-%x SYS-%x PS-%x",detect_type, storage_type, media_type, media_status, system_state, play_state);
    PrintOsdMsg(STR_OS_SPACE, REGION2, 1, 1);
}


/****************************************************************************************\
**  Function Name : card_test_ready                                                     **
**  Purposes      :                                                                     **
**  Limitations   : (none)                                                              **
**  Arguments     : (none)                                                              **
**  Returns       : (none)                                                              **
**  See also      :                                                                     **
\****************************************************************************************/
#ifdef SPHE8202_CARD_STORAGE

void card_test_ready(void)
{
    UINT8 media_exist = 0;

    if (storage_type != 0)
    {
        if (storage_type != USB_DEVICE)
            Card_power_reset();

        switch (storage_type)
        {
        #if defined(COMPACT_FLASH)
            case CF_CARD_DEVICE:

            #ifdef CARD_SETUP_TYPE_2
                regs0->fm_gpio_mode = 8;
            #elif defined(CARD_SETUP_TYPE_3)||defined(CARD_SETUP_TYPE_5)
                regs0->gpio_mode_B = 2;
                regs0->fm_gpio_mode = 3;
            #endif

                cfIdeDetect();
                media_exist = 1;
                break;
        #endif

        #if defined(SD_MMC_CARD)

⌨️ 快捷键说明

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