static void dm_pvr_timer_start(UINT32 interval) { if (pvr_timer_id == OSAL_INVALID_ID) { pvr_timer_id = api_start_timer("DM_PVR", interval, dm_pvr_timer_handler); ASSERT(pvr_timer_id != OSAL_INVALID_ID); DM_DEBUG("start to wait PVR default volumes\n"); } }
/* It will cost a long time when register PVR partitions and do read/write test. * In order not to block the control task, create pvr_part_init_task() to do that. */ static void pvr_part_init_task(UINT32 param1, UINT32 param2) { struct pvr_register_info *info = (struct pvr_register_info *)param1; if (pvr_register(param1, 0) == SUCCESS) DM_DEBUG("pvr init %s to %d done!\n", info->mount_name, info->disk_usage); else DM_ERROR("pvr init %s to %d failed!\n", info->mount_name, info->disk_usage); pvr_part_init_task_id = OSAL_INVALID_ID; }
static int mp_disk_attach_proc() { if (mp_udisk_id == INVALID_UDISK_ID) { #ifdef NEW_DEMO_FRAME #if((!defined SUPPORT_CAS9)|| (defined MEDIAPLAYER_SUPPORT)) win_media_player_init((mp_callback_func)(mp_apcallback)); file_list_init_parameter(); mp_udisk_id = 0; // only used to indicate media player is inited #endif #else mp_udisk_id = udisk_init(mp_udisk_id, (mp_callback_func)(mp_apcallback), __MM_MP_BUFFER_ADDR, __MM_MP_BUFFER_LEN);//TODO:Should be modified to function with paramater UDISK_ID file_list_init_parameter(); if (mp_udisk_id == INVALID_UDISK_ID) { ASSERT(0); return -1; } #endif DM_DEBUG("media player init\n"); } return 0; }
static PedFileSystemType dm_get_fs_type(const char *vol_path) { struct statvfs buf; if (fs_statvfs(vol_path, &buf) < 0) { DM_DEBUG("Get %s file system type failed!\n", vol_path); return PED_FS_TYPE_NONE; } else { if (STRCMP(buf.f_fsh_name, "FAT12") == 0) return PED_FS_TYPE_FAT12; else if (STRCMP(buf.f_fsh_name, "FAT16") == 0) return PED_FS_TYPE_FAT16; else if (STRCMP(buf.f_fsh_name, "FAT32") == 0) return PED_FS_TYPE_FAT32; else if (STRCMP(buf.f_fsh_name, "NTFS") == 0) return PED_FS_TYPE_NTFS; else return PED_FS_TYPE_NONE; } }
static void debug_hook() { DM_DEBUG(dmp, ((struct wgl_vars *)dmp->dm_vars.priv_vars)->mvars.debug); }
/* Register volume for PVR record or timeshift. * 1. it should be call when volume mounted * @b_force: force to select volumes for pvr, don't wait other devices */ static int pvr_disk_attach_proc(BOOL b_force) { SYSTEM_DATA *sys_data = sys_data_get();; enum PVR_DISKMODE pvr_mode; char rec_vol[16], tms_vol[16]; struct statvfs buf; struct pvr_register_info pvr_reg_info; BOOL b_wait = TRUE; if (pvr_part_init_task_id != OSAL_INVALID_ID) { DM_DEBUG("pvr partition %s is initializing to %d\n", l_pvr_reg_info.mount_name, l_pvr_reg_info.disk_usage); return 0; } DM_DEBUG("Enter %s(%d) ...\n", __FUNCTION__, b_force); pvr_mode = pvr_get_cur_mode(rec_vol, tms_vol); switch (pvr_mode) { case PVR_DISK_REC_AND_TMS: case PVR_DISK_REC_WITH_TMS: DM_DEBUG("pvr partition already init (%s, %s)\n", rec_vol, tms_vol); return 0; case PVR_DISK_ONLY_REC: /* check if tms volume valid */ DM_DEBUG("pvr rec partition already init (%s, %s)\n", rec_vol, tms_vol); if ((tms_vol[0] == 0) && (STRLEN(sys_data->tms_disk) > 0) && (fs_statvfs(sys_data->tms_disk, &buf) >= 0)) { MEMSET(&pvr_reg_info, 0, sizeof(struct pvr_register_info)); STRCPY(pvr_reg_info.mount_name, sys_data->tms_disk); pvr_reg_info.disk_usage = PVR_TMS_ONLY_DISK; pvr_reg_info.sync = 1; pvr_reg_info.init_list = 0; #ifndef PVR_SPEED_PRETEST_DISABLE /* --doy, 2011-3-21*/ pvr_reg_info.check_speed = 1; #endif pvr_part_init_task_create(&pvr_reg_info); } return 0; case PVR_DISK_ONLY_TMS: /* check if rec volume valid */ DM_DEBUG("pvr tms partition already init (%s, %s)\n", rec_vol, tms_vol); if ((rec_vol[0] == 0) && (STRLEN(sys_data->rec_disk) > 0) && (fs_statvfs(sys_data->rec_disk, &buf) >= 0)) { MEMSET(&pvr_reg_info, 0, sizeof(struct pvr_register_info)); STRCPY(pvr_reg_info.mount_name, sys_data->rec_disk); pvr_reg_info.disk_usage = PVR_REC_ONLY_DISK; pvr_reg_info.sync = 1; pvr_reg_info.init_list = 1; #ifndef PVR_SPEED_PRETEST_DISABLE /* --doy, 2011-3-21*/ pvr_reg_info.check_speed = 1; #endif pvr_part_init_task_create(&pvr_reg_info); } return 0; default: DM_DEBUG("pvr partition not init\n"); break; } STRCPY(rec_vol, sys_data->rec_disk); STRCPY(tms_vol, sys_data->tms_disk); rec_vol[1] = tms_vol[1] = 'd'; rec_vol[2] = tms_vol[2] = 'e'; rec_vol[3] = tms_vol[3] = 'v'; rec_vol[8] = tms_vol[8] = '\0'; // temp for disk path, eg. "/dev/uda" if ((rec_vol[0] == 0 && tms_vol[0] == 0) || (tms_vol[0] == 0 && fs_statvfs(rec_vol, &buf) >= 0) || (rec_vol[0] == 0 && fs_statvfs(tms_vol, &buf) >= 0) || (fs_statvfs(rec_vol, &buf) >= 0 && fs_statvfs(tms_vol, &buf) >= 0)) { b_wait = FALSE; } if (b_force || !b_wait) { // register rec and tms partition dm_pvr_timer_stop(); DM_DEBUG("To register volume for PVR ...\n"); pvr_select_part(rec_vol, tms_vol); if (STRLEN(tms_vol) > 0 && STRCMP(rec_vol, tms_vol) != 0) { MEMSET(&pvr_reg_info, 0, sizeof(struct pvr_register_info)); STRCPY(pvr_reg_info.mount_name, tms_vol); pvr_reg_info.disk_usage = PVR_TMS_ONLY_DISK; pvr_reg_info.init_list = 0; #ifndef PVR_SPEED_PRETEST_DISABLE /* --doy, 2011-3-21*/ pvr_reg_info.check_speed = 1; #endif if (STRLEN(rec_vol) > 0) { // init partition takes no time when (sync == 0), call pvr_register() directly pvr_reg_info.sync = 0; pvr_register((UINT32)&pvr_reg_info, 0); } else { pvr_reg_info.sync = 1; pvr_part_init_task_create(&pvr_reg_info); } } if (STRLEN(rec_vol) > 0) { MEMSET(&pvr_reg_info, 0, sizeof(struct pvr_register_info)); STRCPY(pvr_reg_info.mount_name, rec_vol); pvr_reg_info.disk_usage = (!STRCMP(rec_vol, tms_vol)) ? PVR_REC_AND_TMS_DISK : PVR_REC_ONLY_DISK; pvr_reg_info.sync = 1; pvr_reg_info.init_list = 1; #ifndef PVR_SPEED_PRETEST_DISABLE /* --doy, 2011-3-21*/ pvr_reg_info.check_speed = 1; #endif pvr_part_init_task_create(&pvr_reg_info); } if (rec_vol) STRCPY(sys_data->rec_disk, rec_vol); if (tms_vol) STRCPY(sys_data->tms_disk, tms_vol); sys_data_save(0); } else /* we need to wait default disk ready */ { dm_pvr_timer_start(5000); } return 0; }
/* change partition @part_path to @part_mode, for pvr */ int pvr_change_part(const char *part_path, UINT8 part_mode) { struct dvr_HDD_info hdd_info; struct pvr_register_info pvr_reg_info; char rec_part[16], tms_part[16]; enum PVR_DISKMODE cur_pvr_mode; SYSTEM_DATA *sys_data; BOOL register_part = FALSE; int ret = 0; if (part_path == NULL || part_path[0] == 0) return -1; DM_DEBUG("%s() change %s to %d\n", __FUNCTION__, part_path, part_mode); sys_data = sys_data_get(); cur_pvr_mode = pvr_get_cur_mode(rec_part, tms_part); MEMSET(&pvr_reg_info, 0, sizeof(struct pvr_register_info)); STRCPY(pvr_reg_info.mount_name, part_path); pvr_reg_info.disk_usage = part_mode; pvr_reg_info.sync = 1; switch (part_mode) { case PVR_REC_AND_TMS_DISK: if (cur_pvr_mode == PVR_DISK_REC_AND_TMS) { pvr_detach_part(rec_part, PVR_REC_AND_TMS_DISK); } else { pvr_detach_part(rec_part, PVR_REC_ONLY_DISK); pvr_detach_part(tms_part, PVR_TMS_ONLY_DISK); } pvr_reg_info.init_list = 1; #ifndef PVR_SPEED_PRETEST_DISABLE /* --doy, 2011-3-21*/ pvr_reg_info.check_speed = 1; #endif if (pvr_register((UINT32)&pvr_reg_info, 0) != SUCCESS) { api_pvr_clear_up_all(); ret = -1; } STRCPY(sys_data->rec_disk, part_path); STRCPY(sys_data->tms_disk, part_path); sys_data_save(0); break; case PVR_REC_ONLY_DISK: if ((STRLEN(rec_part) > 0) && (STRCMP(rec_part, part_path) == 0)) { // same partition if ((cur_pvr_mode == PVR_DISK_ONLY_REC) || (cur_pvr_mode == PVR_DISK_REC_WITH_TMS)) { break; } else if (cur_pvr_mode == PVR_DISK_REC_AND_TMS) { pvr_set_disk_use(PVR_REC_ONLY_DISK, part_path); } else { DM_DEBUG("rec_part: %s, mount_name: %s, mode: %d, %d\n", rec_part, part_path, cur_pvr_mode, part_mode); register_part = TRUE; //SDBBP(); } } else // diff partition { register_part = TRUE; if (cur_pvr_mode == PVR_DISK_REC_AND_TMS) { pvr_set_disk_use(PVR_TMS_ONLY_DISK, tms_part); } if ((cur_pvr_mode == PVR_DISK_ONLY_REC) || (cur_pvr_mode == PVR_DISK_REC_WITH_TMS)) { pvr_detach_part(rec_part, PVR_REC_ONLY_DISK); } if ((STRCMP(tms_part, part_path) == 0) && ((cur_pvr_mode == PVR_DISK_ONLY_TMS) || (cur_pvr_mode == PVR_DISK_REC_WITH_TMS))) { pvr_detach_part(tms_part, PVR_TMS_ONLY_DISK); } } if (register_part) { pvr_reg_info.init_list = (part_mode != PVR_TMS_ONLY_DISK); #ifndef PVR_SPEED_PRETEST_DISABLE /* --doy, 2011-3-21*/ pvr_reg_info.check_speed = 1; #endif //osal_task_sleep(1000); // wait for pvr cleanup finished if (pvr_register((UINT32)&pvr_reg_info, 0) != SUCCESS) { ret = -1; } } STRCPY(sys_data->rec_disk, part_path); if(!STRCMP(sys_data->tms_disk, part_path)) STRCPY(sys_data->tms_disk, ""); sys_data_save(0); break; case PVR_TMS_ONLY_DISK: if ((STRLEN(tms_part) > 0) && (STRCMP(tms_part, part_path) == 0)) { // same partition if ((cur_pvr_mode == PVR_DISK_ONLY_TMS) || (cur_pvr_mode == PVR_DISK_REC_WITH_TMS)) { break; } else if (cur_pvr_mode == PVR_DISK_REC_AND_TMS) { pvr_set_disk_use(PVR_TMS_ONLY_DISK, part_path); } else { DM_DEBUG("rec_part: %s, mount_name: %s, mode: %d, %d\n", rec_part, part_path, cur_pvr_mode, part_mode); register_part = TRUE; //SDBBP(); } } else // diff partition { register_part = TRUE; if (cur_pvr_mode == PVR_DISK_REC_AND_TMS) { pvr_set_disk_use(PVR_REC_ONLY_DISK, rec_part); } if ((cur_pvr_mode == PVR_DISK_ONLY_TMS) || (cur_pvr_mode == PVR_DISK_REC_WITH_TMS)) { pvr_detach_part(tms_part, PVR_TMS_ONLY_DISK); } if ((STRCMP(rec_part, part_path) == 0) && ((cur_pvr_mode == PVR_DISK_ONLY_REC) || (cur_pvr_mode == PVR_DISK_REC_WITH_TMS))) { pvr_detach_part(rec_part, PVR_REC_ONLY_DISK); } } if (register_part) { pvr_reg_info.init_list = (part_mode != PVR_TMS_ONLY_DISK); #ifndef PVR_SPEED_PRETEST_DISABLE /* --doy, 2011-3-21*/ pvr_reg_info.check_speed = 1; #endif //osal_task_sleep(1000); // wait for pvr cleanup finished if (pvr_register((UINT32)&pvr_reg_info, 0) != SUCCESS) { ret = -1; } } STRCPY(sys_data->tms_disk, part_path); if(!STRCMP(sys_data->rec_disk, part_path)) STRCPY(sys_data->rec_disk, ""); sys_data_save(0); break; default: break; } api_pvr_adjust_tms_space(); pvr_get_HDD_info(&hdd_info); api_pvr_check_level(&hdd_info); return ret; }
/* select partitions for pvr to record or timeshift automatically */ int pvr_select_part(char *rec_vol, char *tms_vol) { int i, j; char vol_path[16]; struct statvfs buf; SYSTEM_DATA *sys_data = sys_data_get(); DiskInfo *p_disk; if (rec_vol) { if ((sys_data->rec_disk[0] != 0) && (fs_statvfs(sys_data->rec_disk, &buf) >= 0)) STRCPY(rec_vol, sys_data->rec_disk); else rec_vol[0] = 0; } if (tms_vol) { if ((sys_data->tms_disk[0] != 0) && (fs_statvfs(sys_data->tms_disk, &buf) >= 0)) STRCPY(tms_vol, sys_data->tms_disk); else tms_vol[0] = 0; } MEMSET(vol_path, 0, 16); if ((rec_vol && rec_vol[0] == 0) || (tms_vol && tms_vol[0] == 0)) { /* select the first volume for pvr */ for (i = 0; i < MAX_USB_DISK_NUM; ++i) { if (vol_path[0] != 0) break; if ((p_disk = g_dm.UsbDisks[i]) == NULL) continue; for (j = 0; j < MAX_PARTS_IN_DISK; ++j) { if ((p_disk->parts[j].PartExist == 1) && (p_disk->parts[j].FileSystemType != PED_FS_TYPE_NONE)) { sprintf(vol_path, "/mnt/ud%c%c", i+'a', j+'1'); break; } } } for (i = 0; i < MAX_IDE_DISK_NUM; ++i) { if (vol_path[0] != 0) break; if ((p_disk = g_dm.IdeDisks[i]) == NULL) continue; for (j = 0; j < MAX_PARTS_IN_DISK; ++j) { if ((p_disk->parts[j].PartExist == 1) && (p_disk->parts[j].FileSystemType != PED_FS_TYPE_NONE)) { sprintf(vol_path, "/mnt/hd%c%c", i+'a', j+'1'); break; } } } } if (vol_path[0] != 0) { if (rec_vol && rec_vol[0] == 0) STRCPY(rec_vol, vol_path); if (tms_vol && tms_vol[0] == 0) STRCPY(tms_vol, vol_path); } if (rec_vol && rec_vol[0] != 0) DM_DEBUG("%s() select REC vol: %s\n", __FUNCTION__, rec_vol); if (tms_vol && tms_vol[0] != 0) DM_DEBUG("%s() select TMS vol: %s\n", __FUNCTION__, tms_vol); return 0; }
static void dm_pvr_timer_handler() { DM_DEBUG("waiting PVR default volumes times out\n"); pvr_timer_id = OSAL_INVALID_ID; ap_send_msg(CTRL_MSG_SUBTYPE_STATUS_USBREMOUNT, 0, FALSE); }
int dm_ioctl(DM_CMD cmd, UINT32 param, void *buf, int len) { DiskInfo **pp_disk; DiskInfo *p_disk; int i, j; int max_disk_num = 0; int ret = -1; UINT32 disk_type = DM_CMD_DISK_TYPE(param); UINT32 disk_idx = DM_CMD_DISK_IDX(param); UINT32 part_idx = DM_CMD_PART_IDX(param); switch (disk_type) { case MNT_TYPE_USB: pp_disk = g_dm.UsbDisks; max_disk_num = MAX_USB_DISK_NUM; break; case MNT_TYPE_SD: pp_disk = g_dm.SdDisks; max_disk_num = MAX_SD_DISK_NUM; break; case MNT_TYPE_IDE: pp_disk = g_dm.IdeDisks; max_disk_num = MAX_IDE_DISK_NUM; break; case MNT_TYPE_SATA: pp_disk = g_dm.SataDisks; max_disk_num = MAX_SATA_DISK_NUM; break; default: pp_disk = NULL; max_disk_num = 0; break; } if (pp_disk == NULL || max_disk_num == 0) { DM_DEBUG("%s() unknown disk type: %d\n", __FUNCTION__, disk_type); return -1; } DMLock(); switch (cmd) { case DM_CMD1_GET_DISK_NUM: { int disk_num = 0; for (i = 0; i < max_disk_num; ++i) { if ((p_disk = pp_disk[i]) != NULL) { disk_num++; } } if (buf && (len >= (int)sizeof(int))) { *(int *)buf = disk_num; ret = 0; } break; } case DM_CMD1_GET_PART_NUM: case DM_CMD1_GET_VOL_NUM: { int part_num = 0; int vol_num = 0; for (i = 0; i < max_disk_num; ++i) { if ((p_disk = pp_disk[i]) == NULL) continue; part_num += p_disk->part_num; vol_num += p_disk->vol_num; } if (buf && (len >= (int)sizeof(int))) { if (cmd == DM_CMD1_GET_PART_NUM) *(int *)buf = part_num; else *(int *)buf = vol_num; ret = 0; } break; } case DM_CMD2_GET_DISK_SIZE: { p_disk = pp_disk[disk_idx]; if ((p_disk != NULL) && buf && (len >= (int)sizeof(UINT64))) { *(UINT64 *)buf = p_disk->DiskSize; ret = 0; } break; } case DM_CMD2_GET_PART_NUM: case DM_CMD2_GET_VOL_NUM: { p_disk = pp_disk[disk_idx]; if ((p_disk != NULL) && buf && (len >= (int)sizeof(int))) { if (cmd == DM_CMD2_GET_PART_NUM) *(int *)buf = p_disk->part_num; else *(int *)buf = p_disk->vol_num; ret = 0; } break; } case DM_CMD3_UPDATE_VOL_INFO: { p_disk = pp_disk[disk_idx]; if ((p_disk != NULL) && p_disk->parts[part_idx].PartExist == 1) { char vol_path[16], tmp[8]; diskType2NamePrefix(disk_type, tmp, 8); sprintf(vol_path, "/mnt/%s%c%c", tmp, disk_idx+'a', part_idx+'1'); if (p_disk->parts[part_idx].FileSystemType != PED_FS_TYPE_NONE) p_disk->vol_num--; p_disk->parts[part_idx].FileSystemType = dm_get_fs_type(vol_path); if (p_disk->parts[part_idx].FileSystemType != PED_FS_TYPE_NONE) p_disk->vol_num++; ret = 0; } break; } default: break; } DMUnlock(); return ret; }
static int dm_update(UINT32 dev_type, UINT32 dev_id) { char disk_name[8]; char dev_path[16]; char vol_path[16]; DiskInfo *p_disk = NULL; DiskInfo **pp_disk = NULL; int ret = -1; if (((dev_type == MNT_TYPE_USB) && (dev_id >= MAX_USB_DISK_NUM)) || ((dev_type == MNT_TYPE_SD) && (dev_id >= MAX_SD_DISK_NUM)) || ((dev_type == MNT_TYPE_SATA) && (dev_id >= MAX_SATA_DISK_NUM)) || ((dev_type == MNT_TYPE_IDE) && (dev_id >= MAX_IDE_DISK_NUM))) { DM_ERROR("Unsupport device (%d, %d)\n", dev_type, dev_id); return ret; } DM_DEBUG("DM update device (%d, %d)\n", dev_type, dev_id); DMLock(); do { switch (dev_type) { case MNT_TYPE_USB: sprintf(disk_name, "ud%c", dev_id+'a'); pp_disk = &g_dm.UsbDisks[dev_id]; break; case MNT_TYPE_SD: sprintf(disk_name, "sd%c", dev_id+'a'); pp_disk = &g_dm.SdDisks[dev_id]; break; case MNT_TYPE_IDE: sprintf(disk_name, "hd%c", dev_id+'a'); pp_disk = &g_dm.IdeDisks[dev_id]; break; case MNT_TYPE_SATA: sprintf(disk_name, "sh%c", dev_id+'a'); pp_disk = &g_dm.SataDisks[dev_id]; break; default: disk_name[0] = 0; break; } if (disk_name[0] == 0) { DM_DEBUG("Unknown device (%d, %d)\n", dev_type, dev_id); break; } if (*pp_disk != NULL) { #if (DM_DEBUG_LEVEL & DM_DEBUG_MALLOC_FREE) dm_malloc_cnt--; #endif FREE(*pp_disk); *pp_disk = NULL; } if ((p_disk = (DiskInfo *)MALLOC(sizeof(DiskInfo))) == NULL) { #if (DM_DEBUG_LEVEL & DM_DEBUG_MALLOC_FREE) dm_malloc_cnt++; #endif DM_DEBUG("Memory exhausted!\n", dev_type, dev_id); break; } MEMSET(p_disk, 0, sizeof(DiskInfo)); sprintf(dev_path, "/dev/%s", disk_name); int fd, fd_dir; device_geometry geo; char dirbuf[sizeof(struct dirent) + 32]; struct dirent *pdir = (struct dirent *)dirbuf; /* get disk info */ fd = fs_open(dev_path, O_RDONLY, 0); if (fd < 0) { DM_DEBUG("device %s not exist!\n", dev_path); break; } if (fs_ioctl(fd, IOCTL_GET_DEVICE_GEOMETRY, &geo, sizeof(struct device_geometry)) < 0) { fs_close(fd); break; } p_disk->DiskSize = geo.sector_count * geo.bytes_per_sector; fs_close(fd); if ((fd_dir = fs_opendir("/dev")) < 0) { DM_DEBUG("open /dev failed!\n"); break; } ret = 0; /* get necessary disk info successfully */ int part_idx; while (fs_readdir(fd_dir, pdir) > 0) { /* find partitions */ if ((STRLEN(pdir->d_name) == 4) && (strncmp(pdir->d_name, disk_name, 3) == 0)) { part_idx = pdir->d_name[3] - '1'; if ((part_idx < 0) || (part_idx >= MAX_PARTS_IN_DISK)) { continue; } sprintf(dev_path, "/dev/%s", pdir->d_name); sprintf(vol_path, "/mnt/%s", pdir->d_name); /* get part info */ fd = fs_open(dev_path, O_RDONLY, 0); if (fs_ioctl(fd, IOCTL_GET_DEVICE_GEOMETRY, &geo, sizeof(struct device_geometry)) < 0) { fs_close(fd); continue; } fs_close(fd); p_disk->parts[part_idx].PartExist = 1; p_disk->parts[part_idx].FileSystemType = dm_get_fs_type(vol_path); p_disk->parts[part_idx].PartSize = geo.sector_count * geo.bytes_per_sector; p_disk->part_num++; if (p_disk->parts[part_idx].FileSystemType != PED_FS_TYPE_NONE) p_disk->vol_num++; } } fs_closedir(fd_dir); } while(0); if (ret == 0) { *pp_disk = p_disk; // p_disk = NULL; } else if (p_disk != NULL) { #if (DM_DEBUG_LEVEL & DM_DEBUG_MALLOC_FREE) dm_malloc_cnt--; #endif FREE(p_disk); } DMUnlock(); return ret; }
static void dm_disk_show_hint(UINT32 dev_type, UINT32 dev_id, UINT32 hint_type) { UINT8 i; UINT16 hint[128]={0}; char strUsb[128]; char strA[128]; char strCon[128]; char strUcon[128]; char strSd[128]; char strIde[128]; char strSata[128]; UINT8 back_saved; UINT16 *unistr=NULL; #ifdef SUPPORT_CAS9 if(get_mmi_showed()!=0)//mmi pri is high than this popup return; #endif #ifndef _SYSTEM_DVBC switch (dev_type) { case MNT_TYPE_USB: //sprintf(hint, "USB disk %c", dev_id+'A'); ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_USB_DISK),strUsb); ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_KEY_A),strA); sprintf(hint," %c ",dev_id); strcat(strUsb,hint); strcat(strUsb,strA); strcat(strUsb," "); STRCPY(hint,strUsb); break; case MNT_TYPE_SD: ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_SD_CARD),strSd); sprintf(hint, strSd); break; case MNT_TYPE_IDE: ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_IDE_DISK),strIde); sprintf(hint, strIde); break; case MNT_TYPE_SATA: ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_SATA_DISK),strSata); sprintf(hint, strSata); break; default: return; } switch (hint_type) { case DM_HINT_CONNECT: ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_CONNECTED),strCon); strcat(hint,strCon); break; case DM_HINT_DISCONNECT: ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_DISCONNECTED),strUcon); strcat(hint,strUcon); break; default: return; } DM_DEBUG("%s() show message: %s\n", __FUNCTION__, hint); win_compopup_init(WIN_POPUP_TYPE_SMSG); win_compopup_set_msg_ext(hint, NULL, 0); #else if(hint_type==DM_HINT_CONNECT) { if(dev_type==MNT_TYPE_USB) { unistr=OSD_GetUnicodeString(RS_USB_DISK_CONNECTED); ComUniStrCopyChar(&hint,(UINT16 *)unistr); } else if(dev_type==MNT_TYPE_SD) { unistr=OSD_GetUnicodeString(RS_SD_CARD_CONNECTED); ComUniStrCopyChar(&hint,(UINT16 *)unistr); } else if(dev_type==MNT_TYPE_IDE) { unistr=OSD_GetUnicodeString(RS_IDE_DISK_CONNECTED); ComUniStrCopyChar(&hint,(UINT16 *)unistr); } else if(dev_type==MNT_TYPE_SATA) { unistr=OSD_GetUnicodeString(RS_SATA_DISK_CONNECTED); ComUniStrCopyChar(&hint,(UINT16 *)unistr); } } else if(hint_type==DM_HINT_DISCONNECT) { if(dev_type==MNT_TYPE_USB) { unistr=OSD_GetUnicodeString(RS_USB_DISK_DISCONNECTED); ComUniStrCopyChar(&hint,(UINT16 *)unistr); } else if(dev_type==MNT_TYPE_SD) { unistr=OSD_GetUnicodeString(RS_SD_CARD_DISCONNECTED); ComUniStrCopyChar(&hint,(UINT16 *)unistr); } else if(dev_type==MNT_TYPE_IDE) { unistr=OSD_GetUnicodeString(RS_IDE_DISK_DISCONNECTED); ComUniStrCopyChar(&hint,(UINT16 *)unistr); } else if(dev_type==MNT_TYPE_SATA) { unistr=OSD_GetUnicodeString(RS_SATA_DISK_DISCONNECTED); ComUniStrCopyChar(&hint,(UINT16 *)unistr); } } DM_DEBUG("%s() show message: %s\n", __FUNCTION__, hint); win_compopup_init(WIN_POPUP_TYPE_SMSG); win_compopup_set_msg_ext(NULL,hint, 0); #endif #ifdef SUPPORT_CAS9 win_compopup_set_frame(290, 250, 448, 100); #endif win_compopup_open_ext(&back_saved); osal_task_sleep(1000); win_compopup_smsg_restoreback(); }
/* Un-register pvr volume if necessary * 1. it should be call when disk detach */ static int pvr_disk_detach_proc() { struct statvfs buf; enum PVR_DISKMODE pvr_mode; char rec_vol[16], tms_vol[16], initing_vol[16]; UINT8 initing_vol_usage = 0; BOOL b_pvr_part_detached = FALSE; DM_DEBUG("Enter %s() ...\n", __FUNCTION__); if (pvr_part_init_task_id != OSAL_INVALID_ID) { DM_DEBUG("pvr partition %s is initializing to %d\n", l_pvr_reg_info.mount_name, l_pvr_reg_info.disk_usage); STRCPY(initing_vol, l_pvr_reg_info.mount_name); initing_vol_usage = l_pvr_reg_info.disk_usage; } else { initing_vol[0] = 0; } pvr_mode = pvr_get_cur_mode(rec_vol, tms_vol); BOOL rec_vol_detach = ((rec_vol[0] != 0) && (fs_statvfs(rec_vol, &buf) < 0)); BOOL tms_vol_detach = ((tms_vol[0] != 0) && (fs_statvfs(tms_vol, &buf) < 0)); if ((initing_vol[0] != 0) && (fs_statvfs(initing_vol, &buf) < 0)) { if (STRCMP(initing_vol, rec_vol) != 0) { DM_DEBUG("pvr detach initializing volume %s\n", initing_vol); pvr_detach_part(initing_vol, initing_vol_usage); b_pvr_part_detached = TRUE; } initing_vol[0] = 0; } if (rec_vol_detach || tms_vol_detach) { /* a disk that used by pvr is detached */ if (STRCMP(rec_vol, tms_vol) == 0) { DM_DEBUG("pvr detach %s\n", rec_vol); pvr_detach_part(rec_vol, PVR_REC_AND_TMS_DISK); b_pvr_part_detached = TRUE; } else { if (rec_vol_detach) { DM_DEBUG("pvr detach %s\n", rec_vol); pvr_detach_part(rec_vol, PVR_REC_ONLY_DISK); b_pvr_part_detached = TRUE; } if (tms_vol_detach) { DM_DEBUG("pvr detach %s\n", tms_vol); pvr_detach_part(tms_vol, PVR_TMS_ONLY_DISK); b_pvr_part_detached = TRUE; } } } if ((pvr_get_cur_mode(rec_vol, tms_vol) == PVR_DISK_INVALID) && (initing_vol[0] == 0)) { DM_DEBUG("pvr detach all volume, do clean up!\n"); api_pvr_clear_up_all(); } if (b_pvr_part_detached) { struct dvr_HDD_info hdd_info; pvr_get_HDD_info(&hdd_info); api_pvr_check_level(&hdd_info); } return 0; }