savage_vid.c
来自「君正早期ucos系统(只有早期的才不没有打包成库),MPLAYER,文件系统,图」· C语言 代码 · 共 1,412 行 · 第 1/3 页
C
1,412 行
break; } printf("###### videoRam = %d\n",videoRam); info->chip.fbsize = videoRam * 1024; /* reset graphics engine to avoid memory corruption *//* VGAOUT8 (0x3d4, 0x66); cr66 = VGAIN8 (0x3d5); VGAOUT8 (0x3d5, cr66 | 0x02); udelay (10000); VGAOUT8 (0x3d4, 0x66); VGAOUT8 (0x3d5, cr66 & ~0x02); */ // clear reset flag /* udelay (10000); */ /* This maps framebuffer @6MB, thus 2MB are left for video. */ if (info->chip.arch == S3_SAVAGE3D) { info->video_base = map_phys_mem(pci_info.base0, info->chip.fbsize); info->picture_offset = 1024*768* 4 * ((info->chip.fbsize > 4194304)?2:1); } else { info->video_base = map_phys_mem(pci_info.base1, info->chip.fbsize); info->picture_offset = info->chip.fbsize - FRAMEBUFFER_SIZE;// info->picture_offset = 1024*1024* 4 * 2; } if ( info->video_base == NULL){ printf("errno = %s\n", strerror(errno)); return -1; } info->picture_base = (uint32_t) info->video_base + info->picture_offset; if ( info->chip.arch == S3_SAVAGE3D ){ mtrr = mtrr_set_type(pci_info.base0, info->chip.fbsize, MTRR_TYPE_WRCOMB); } else{ mtrr = mtrr_set_type(pci_info.base1, info->chip.fbsize, MTRR_TYPE_WRCOMB); } if (mtrr!= 0) printf("[savage_vid] unable to setup MTRR: %s\n", strerror(mtrr)); else printf("[savage_vid] MTRR set up\n"); /* This may trash your screen for resolutions greater than 1024x768, sorry. */ savage_getscreenproperties(info);// return -1; info->videoFlags = 0; SavageStreamsOn(); //getc(stdin); //FIXME ADD return 0;}/** * @brief Destroys driver. */static voidsavage_destroy (void){ unmap_phys_mem(info->video_base, info->chip.fbsize); unmap_phys_mem(info->control_base, SAVAGE_NEWMMIO_REGSIZE); //FIXME ADD}/** * @brief Get chipset's hardware capabilities. * * @param to Pointer to the vidix_capability_t structure to be filled. * * @returns 0. */static intsavage_get_caps (vidix_capability_t * to){ memcpy (to, &savage_cap, sizeof (vidix_capability_t)); return 0;}/** * @brief Report if the video FourCC is supported by hardware. * * @param fourcc input image format. * * @returns 1 if the fourcc is supported. * 0 otherwise. */static intis_supported_fourcc (uint32_t fourcc){ switch (fourcc) {//FIXME: YV12 isnt working properly yet // case IMGFMT_YV12:// case IMGFMT_I420: case IMGFMT_UYVY: case IMGFMT_YVYU: case IMGFMT_YUY2: case IMGFMT_RGB15: case IMGFMT_RGB16:// case IMGFMT_BGR32: return 1; default: return 0; }}/** * @brief Try to configure video memory for given fourcc. * * @param to Pointer to the vidix_fourcc_t structure to be filled. * * @returns 0 if ok. * errno otherwise. */static intsavage_query_fourcc (vidix_fourcc_t * to){ if (is_supported_fourcc (to->fourcc)) { to->depth = VID_DEPTH_ALL; to->flags = VID_CAP_EXPAND | VID_CAP_SHRINK | VID_CAP_COLORKEY; return 0; } else to->depth = to->flags = 0; return ENOSYS;}/** * @brief Get the GrKeys * * @param grkey Pointer to the vidix_grkey_t structure to be filled by driver. * * @return 0. *//*intvixGetGrKeys (vidix_grkey_t * grkey){// if(info->d_width && info->d_height)savage_overlay_start(info,0); return (0);} * *//** * @brief Set the GrKeys * * @param grkey Colorkey to be set. * * @return 0. */static intsavage_set_gkeys (const vidix_grkey_t * grkey){ if (grkey->ckey.op == CKEY_FALSE) { info->use_colorkey = 0; info->vidixcolorkey=0; printf("[savage_vid] colorkeying disabled\n"); } else { info->use_colorkey = 1; info->vidixcolorkey = ((grkey->ckey.red<<16)|(grkey->ckey.green<<8)|grkey->ckey.blue); printf("[savage_vid] set colorkey 0x%x\n",info->vidixcolorkey); } //FIXME: freezes if streams arent enabled SavageSetColorKeyOld(); return (0);}/** * @brief Unichrome driver equalizer capabilities. */static vidix_video_eq_t equal = { VEQ_CAP_BRIGHTNESS | VEQ_CAP_SATURATION | VEQ_CAP_HUE, 300, 100, 0, 0, 0, 0, 0, 0};/** * @brief Get the equalizer capabilities. * * @param eq Pointer to the vidix_video_eq_t structure to be filled by driver. * * @return 0. */static intsavage_get_eq (vidix_video_eq_t * eq){ memcpy (eq, &equal, sizeof (vidix_video_eq_t)); return 0;}/** * @brief Set the equalizer capabilities for color correction * * @param eq equalizer capabilities to be set. * * @return 0. */static intsavage_set_eq (const vidix_video_eq_t * eq){ return 0;}/** * @brief Configure driver for playback. Driver should prepare BES. * * @param info configuration description for playback. * * @returns 0 in case of success. * -1 otherwise. */static intsavage_config_playback (vidix_playback_t * vinfo){ int uv_size, swap_uv; unsigned int i; if (!is_supported_fourcc (vinfo->fourcc)) return -1; info->src_w = vinfo->src.w; info->src_h = vinfo->src.h; info->drw_w = vinfo->dest.w; info->drw_h = vinfo->dest.h; info->wx = vinfo->dest.x; info->wy = vinfo->dest.y; info->format = vinfo->fourcc; info->lastKnownPitch = 0; info->brightness = 0; info->contrast = 128; info->saturation = 128; info->hue = 0; vinfo->dga_addr=(void*)(info->picture_base); vinfo->offset.y = 0; vinfo->offset.v = 0; vinfo->offset.u = 0; vinfo->dest.pitch.y = 32; vinfo->dest.pitch.u = 32; vinfo->dest.pitch.v = 32; // vinfo->dest.pitch.u = 0; // vinfo->dest.pitch.v = 0; info->pitch = ((info->src_w << 1) + 15) & ~15; swap_uv = 0; switch (vinfo->fourcc) { case IMGFMT_YUY2: case IMGFMT_UYVY: info->pitch = ((info->src_w << 1) + (vinfo->dest.pitch.y-1)) & ~(vinfo->dest.pitch.y-1); info->pitch = info->src_w << 1; info->pitch = ALIGN_TO (info->src_w << 1, 32); uv_size = 0; break; case IMGFMT_YV12: swap_uv = 1; /* srcPitch = (info->src_w + 3) & ~3; vinfo->offset.u = srcPitch * info->src_h; srcPitch2 = ((info->src_w >> 1) + 3) & ~3; vinfo->offset.v = (srcPitch2 * (info->src_h >> 1)) + vinfo->offset.v; vinfo->dest.pitch.y=srcPitch ; vinfo->dest.pitch.v=srcPitch2 ; vinfo->dest.pitch.u=srcPitch2 ; */ info->pitch = ALIGN_TO (info->src_w, 32); uv_size = (info->pitch >> 1) * (info->src_h >> 1); vinfo->offset.y = 0; vinfo->offset.v = vinfo->offset.y + info->pitch * info->src_h; vinfo->offset.u = vinfo->offset.v + uv_size; vinfo->frame_size = vinfo->offset.u + uv_size;/* YOffs = info->offset.y; UOffs = (swap_uv ? vinfo->offset.v : vinfo->offset.u); VOffs = (swap_uv ? vinfo->offset.u : vinfo->offset.v); */// vinfo->offset.y = info->src_w;// vinfo->offset.v = vinfo->offset.y + info->src_w /2 * info->src_h;// vinfo->offset.u = vinfo->offset.v + (info->src_w >> 1) * (info->src_h >> 1) ; break; } info->pitch |= ((info->pitch >> 1) << 16); vinfo->frame_size = info->pitch * info->src_h; printf("$#### destination pitch = %u\n", info->pitch&0xffff); info->buffer_size = vinfo->frame_size; info->num_frames = vinfo->num_frames= (info->chip.fbsize - info->picture_offset)/vinfo->frame_size; if(vinfo->num_frames > MAX_FRAMES)vinfo->num_frames = MAX_FRAMES;// vinfo->num_frames = 1;// printf("[nvidia_vid] Number of frames %i\n",vinfo->num_frames); for(i=0;i <vinfo->num_frames;i++)vinfo->offsets[i] = vinfo->frame_size*i; return 0;}/** * @brief Set playback on : driver should activate BES on this call. * * @return 0. */static intsavage_playback_on (void){ // FIXME: enable SavageDisplayVideoOld();//FIXME ADD return 0;}/** * @brief Set playback off : driver should deactivate BES on this call. * * @return 0. */static intsavage_playback_off (void){ // otherwise we wont disable streams properly in new xorg // FIXME: shouldnt this be enabled?// SavageStreamsOn(); SavageStreamsOff();// info->vidixcolorkey=0x0;// OUTREG( SSTREAM_WINDOW_START_REG, OS_XY(0xfffe, 0xfffe) );// SavageSetColorKeyOld();//FIXME ADD return 0;}static void debugout(unsigned int addr, unsigned int val){ return ; switch ( addr ){ case PSTREAM_CONTROL_REG: fprintf(stderr,"PSTREAM_CONTROL_REG"); break; case COL_CHROMA_KEY_CONTROL_REG: fprintf(stderr,"COL_CHROMA_KEY_CONTROL_REG"); break; case SSTREAM_CONTROL_REG: fprintf(stderr,"SSTREAM_CONTROL_REG"); break; case CHROMA_KEY_UPPER_BOUND_REG: fprintf(stderr,"CHROMA_KEY_UPPER_BOUND_REG"); break; case SSTREAM_STRETCH_REG: fprintf(stderr,"SSTREAM_STRETCH_REG"); break; case COLOR_ADJUSTMENT_REG: fprintf(stderr,"COLOR_ADJUSTMENT_REG"); break; case BLEND_CONTROL_REG: fprintf(stderr,"BLEND_CONTROL_REG"); break; case PSTREAM_FBADDR0_REG: fprintf(stderr,"PSTREAM_FBADDR0_REG"); break; case PSTREAM_FBADDR1_REG: fprintf(stderr,"PSTREAM_FBADDR1_REG"); break; case PSTREAM_STRIDE_REG: fprintf(stderr,"PSTREAM_STRIDE_REG"); break; case DOUBLE_BUFFER_REG: fprintf(stderr,"DOUBLE_BUFFER_REG"); break; case SSTREAM_FBADDR0_REG: fprintf(stderr,"SSTREAM_FBADDR0_REG"); break; case SSTREAM_FBADDR1_REG: fprintf(stderr,"SSTREAM_FBADDR1_REG"); break; case SSTREAM_STRIDE_REG: fprintf(stderr,"SSTREAM_STRIDE_REG"); break; case SSTREAM_VSCALE_REG: fprintf(stderr,"SSTREAM_VSCALE_REG"); break; case SSTREAM_VINITIAL_REG: fprintf(stderr,"SSTREAM_VINITIAL_REG"); break; case SSTREAM_LINES_REG: fprintf(stderr,"SSTREAM_LINES_REG"); break; case STREAMS_FIFO_REG: fprintf(stderr,"STREAMS_FIFO_REG"); break; case PSTREAM_WINDOW_START_REG: fprintf(stderr,"PSTREAM_WINDOW_START_REG"); break; case PSTREAM_WINDOW_SIZE_REG: fprintf(stderr,"PSTREAM_WINDOW_SIZE_REG"); break; case SSTREAM_WINDOW_START_REG: fprintf(stderr,"SSTREAM_WINDOW_START_REG"); break; case SSTREAM_WINDOW_SIZE_REG: fprintf(stderr,"SSTREAM_WINDOW_SIZE_REG"); break; case FIFO_CONTROL: fprintf(stderr,"FIFO_CONTROL"); break; case PSTREAM_FBSIZE_REG: fprintf(stderr,"PSTREAM_FBSIZE_REG"); break; case SSTREAM_FBSIZE_REG: fprintf(stderr,"SSTREAM_FBSIZE_REG"); break; case SSTREAM_FBADDR2_REG: fprintf(stderr,"SSTREAM_FBADDR2_REG"); break; } fprintf(stderr,":\t\t 0x%08X = %u\n",val,val);}VDXDriver savage_drv = { "savage", NULL, .probe = savage_probe, .get_caps = savage_get_caps, .query_fourcc = savage_query_fourcc, .init = savage_init, .destroy = savage_destroy, .config_playback = savage_config_playback, .playback_on = savage_playback_on, .playback_off = savage_playback_off, .get_eq = savage_get_eq, .set_eq = savage_set_eq, .set_gkey = savage_set_gkeys,};
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?