int biosmptable_detect(void) { mpfps_t mpfps; mpcth_t mpcth; char *entry_type_p; proc_entry_ptr proc; int ncpu, i; if (!memopen()) return -1; /* XXX 0? */ /* locate and validate the mpfps */ mpfps = biosmptable_find_mpfps(); mpcth = NULL; if (mpfps == NULL) { ncpu = 0; } else if (mpfps->config_type != 0) { /* * If thie config_type is nonzero then this is a default configuration * from Chapter 5 in the MP spec. Report 2 cpus and 1 I/O APIC. */ ncpu = 2; } else { ncpu = 0; mpcth = biosmptable_check_mpcth(PTOV(mpfps->pap)); if (mpcth != NULL) { entry_type_p = (char *)(mpcth + 1); for (i = 0; i < mpcth->entry_count; i++) { switch (*entry_type_p) { case 0: entry_type_p += sizeof(struct PROCENTRY); proc = (proc_entry_ptr) entry_type_p; warnx("MPTable: Found CPU APIC ID %d %s", proc->apic_id, proc->cpu_flags & PROCENTRY_FLAG_EN ? "enabled" : "disabled"); if (proc->cpu_flags & PROCENTRY_FLAG_EN) ncpu++; break; case 1: entry_type_p += sizeof(struct BUSENTRY); break; case 2: entry_type_p += sizeof(struct IOAPICENTRY); break; case 3: case 4: entry_type_p += sizeof(struct INTENTRY); break; default: warnx("unknown mptable entry type (%d)", *entry_type_p); goto done; /* XXX error return? */ } } done: ; } } memclose(); if (mpcth != NULL) free(mpcth); if (mpfps != NULL) free(mpfps); return ncpu; }
HI_S32 vo_video_csc_config(HI_U32 u32LayerId, HI_U32 enCscMatrix, HI_U32 u32Luma, HI_U32 u32Contrast, HI_U32 u32Hue, HI_U32 u32Satuature, HI_U32 u32Gain) { HI_S32 s32Ret; CscCoef_S stCscCoef; HI_U8 *pAddr = NULL; HI_U32 *pRegAddr = NULL; HI_U32 u32CscIdc, u32CscOdc, u32CscP0, u32CscP1, u32CscP2, u32CscP3, u32CscP4; HI_U32 u32DacCtrl0_2; HI_S32 s32Matrix; usage(); if (u32LayerId < 0 || u32LayerId > 3) { printf ("layer err \n"); usage(); return -1; } if (u32Contrast < 0 || u32Contrast > 100) { printf ("u32Contrast err \n"); usage(); return -1; } if (u32Hue < 0 || u32Hue > 100) { printf ("u32Hue err \n"); usage(); return -1; } if (u32Luma < 0 || u32Luma > 100) { printf ("u32Luma err \n"); usage(); return -1; } if (u32Satuature < 0 || u32Satuature > 100) { printf ("u32Satuature err \n"); usage(); return -1; } if (u32Gain < 0x0 || u32Gain > 0x3F) { printf ("u32Gain err \n"); usage(); return -1; } if (enCscMatrix < 0 || enCscMatrix > 2) { printf ("enCscMatrix err \n"); usage(); return -1; } switch(enCscMatrix) { case 0:s32Matrix = HAL_CSC_MODE_RGB_TO_RGB;break; case 1:s32Matrix = HAL_CSC_MODE_BT601_TO_BT709;break; case 2:s32Matrix = HAL_CSC_MODE_BT709_TO_BT601;break; default: return -1; } vou_cal_csc_matrix(u32Luma, u32Contrast, u32Hue, u32Satuature,s32Matrix, &stCscCoef); u32CscIdc = ((get_xdc_buma(stCscCoef.csc_in_dc2) & 0x1ff) | ((get_xdc_buma(stCscCoef.csc_in_dc1) & 0x1ff) << 9) | ((get_xdc_buma(stCscCoef.csc_in_dc0) & 0x1ff) << 18)); u32CscOdc = ((get_xdc_buma(stCscCoef.csc_out_dc2) & 0x1ff) | ((get_xdc_buma(stCscCoef.csc_out_dc1) & 0x1ff) << 9) | ((get_xdc_buma(stCscCoef.csc_out_dc0) & 0x1ff) << 18)); u32CscP0 = ((conver_csc_coef(stCscCoef.csc_coef00) & 0x1fff) | ((conver_csc_coef(stCscCoef.csc_coef01) & 0x1fff) << 16)); u32CscP1 = ((conver_csc_coef(stCscCoef.csc_coef02) & 0x1fff) | ((conver_csc_coef(stCscCoef.csc_coef10) & 0x1fff) << 16)); u32CscP2 = ((conver_csc_coef(stCscCoef.csc_coef11) & 0x1fff) | ((conver_csc_coef(stCscCoef.csc_coef12) & 0x1fff) << 16)); u32CscP3 = ((conver_csc_coef(stCscCoef.csc_coef20) & 0x1fff) | ((conver_csc_coef(stCscCoef.csc_coef21) & 0x1fff) << 16)); u32CscP4 = (conver_csc_coef(stCscCoef.csc_coef22) & 0x1fff); memopen(); pAddr = (HI_U8 *)memmap(VO_BASE_REG, VO_VIDEO_CSC_SIZE); if(NULL == pAddr) { printf("err: memmap failure\n"); return HI_FAILURE; } //printf("sys_map 0x%x\n", pAddr); pRegAddr = (HI_U32 *)(vo_get_layer_addr(u32LayerId, pAddr + VHDCSCIDC)); u32CscIdc |= (*pRegAddr & 0x08000000); //csc_en //printf("addr 0x%x, old value 0x%x, new value 0x%x\n", pRegAddr, *pRegAddr, u32VgaCscIdc); *pRegAddr = u32CscIdc; pRegAddr = (HI_U32 *)(vo_get_layer_addr(u32LayerId, pAddr + VHDCSCODC)); //printf("addr 0x%x, old value 0x%x, new value 0x%x\n", pRegAddr, *pRegAddr, u32VgaCscOdc); *pRegAddr = u32CscOdc; pRegAddr = (HI_U32 *)(vo_get_layer_addr(u32LayerId, pAddr + VHDCSCP0)); //printf("addr 0x%x, old value 0x%x, new value 0x%x\n", pRegAddr, *pRegAddr, u32VgaCscP0); *pRegAddr = u32CscP0; pRegAddr = (HI_U32 *)(vo_get_layer_addr(u32LayerId, pAddr + VHDCSCP1)); //printf("addr 0x%x, old value 0x%x, new value 0x%x\n", pRegAddr, *pRegAddr, u32VgaCscP1); *pRegAddr = u32CscP1; pRegAddr = (HI_U32 *)(vo_get_layer_addr(u32LayerId, pAddr + VHDCSCP2)); //printf("addr 0x%x, old value 0x%x, new value 0x%x\n", pRegAddr, *pRegAddr, u32VgaCscP2); *pRegAddr = u32CscP2; pRegAddr = (HI_U32 *)(vo_get_layer_addr(u32LayerId, pAddr + VHDCSCP3)); //printf("addr 0x%x, old value 0x%x, new value 0x%x\n", pRegAddr, *pRegAddr, u32VgaCscP3); *pRegAddr = u32CscP3; pRegAddr = (HI_U32 *)(vo_get_layer_addr(u32LayerId, pAddr + VHDCSCP4)); //printf("addr 0x%x, old value 0x%x, new value 0x%x\n", pRegAddr, *pRegAddr, u32VgaCscP4); *pRegAddr = u32CscP4; pRegAddr = (HI_U32 *)(pAddr + (DACCTRL0_2 - VO_BASE_REG)); set_cvbs_gain(u32LayerId, pRegAddr, u32Gain); memunmap(VO_BASE_REG, VO_VIDEO_CSC_SIZE); memclose(); return HI_SUCCESS; }
HI_S32 SAMPLE_MISC_VoDump(VO_DEV VoDev, HI_U32 u32Cnt) { HI_S32 i, s32Ret; VIDEO_FRAME_INFO_S stFrame; //VIDEO_FRAME_INFO_S astFrame[256]; HI_CHAR szYuvName[128]; HI_CHAR szPixFrm[10]; FILE *pfd; printf("\nNOTICE: This tool only can be used for TESTING !!!\n"); printf("usage: ./vo_screen_dump [vodev] [frmcnt]. sample: ./vo_screen_dump 0 1\n\n"); /* Get Frame to make file name*/ s32Ret = HI_MPI_VO_GetScreenFrame(VoDev, &stFrame); if (HI_SUCCESS != s32Ret) { printf("HI_MPI_VO(%d)_GetScreenFrame errno %#x\n", VoDev, s32Ret); return -1; } /* make file name */ strcpy(szPixFrm, (PIXEL_FORMAT_YUV_SEMIPLANAR_420 == stFrame.stVFrame.enPixelFormat)?"p420":"p422"); sprintf(szYuvName, "./vo(%d)_%d_%d_%s_%d.yuv",VoDev, stFrame.stVFrame.u32Width, stFrame.stVFrame.u32Height,szPixFrm,u32Cnt); printf("Dump YUV frame of vo(%d) to file: \"%s\"\n",VoDev, szYuvName); HI_MPI_VO_ReleaseScreenFrame(VoDev, &stFrame); /* open file */ pfd = fopen(szYuvName, "wb"); if (NULL == pfd) { return -1; } memopen(); /* get VO frame */ for (i=0; i<u32Cnt; i++) { s32Ret = HI_MPI_VO_GetScreenFrame(VoDev, &stFrame); if (HI_SUCCESS != s32Ret) { printf("get vo(%d) frame err\n", VoDev); printf("only get %d frame\n", i); break; } printf("addr 0x%x\n", stFrame.stVFrame.u32PhyAddr[0]); /* save VO frame to file */ sample_yuv_dump(&stFrame.stVFrame, pfd); /* release frame after using */ s32Ret = HI_MPI_VO_ReleaseScreenFrame(VoDev, &stFrame); if (HI_SUCCESS != s32Ret) { printf("Release vo(%d) frame err\n", VoDev); printf("only get %d frame\n", i); break; } } memclose(); fclose(pfd); return 0; }