cyberblade_vid.c
来自「君正早期ucos系统(只有早期的才不没有打包成库),MPLAYER,文件系统,图」· C语言 代码 · 共 616 行 · 第 1/2 页
C
616 行
/* * VIDIX driver for VIA Cyberblade/i1 chipsets. * Copyright (C) 2002 Alastair M. Robinson * http://www.blackfiveservices.co.uk/EPIAVidix.shtml * * This file is part of MPlayer. * * MPlayer is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * MPlayer is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with MPlayer; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * Based on Permedia 3 driver by Måns Rullgård * Thanks to Gilles Frattini for bugfixes. * * Changes: * 18/01/03 * MMIO is no longer used, sidestepping cache issues on EPIA-800 * TV-Out modes are now better supported - this should be the end * of the magenta stripes :) * Brightness/Contrast controls disabled for the time being - they were * seriously degrading picture quality, especially with TV-Out. * * To Do: * Implement Hue/Saturation controls * Support / Test multiple frames * Test colour-key code more extensively */#include <errno.h>#include <mplaylib.h>#include <mplaylib.h>#include <mplaylib.h>#include <inttypes.h>#include <mplaylib.h>#include "vidix.h"#include "vidixlib.h"#include "fourcc.h"#include "dha.h"#include "pci_ids.h"#include "pci_names.h"#include "config.h"#include "cyberblade_regs.h"#undef memcpy#define memcpy uc_memcpystatic pciinfo_t pci_info;static char save_colourkey[6];static char *cyberblade_mem;#ifdef DEBUG_LOGFILEstatic FILE *logfile=0;#define LOGWRITE(x) {if(logfile) fprintf(logfile,x);}#else#define LOGWRITE(x)#endif/* Helper functions for reading registers. */ static void CROUTW(int reg,int val){ CROUTB(reg,val&255); CROUTB(reg+1,(val>>8)&255);}static void SROUTW(int reg,int val){ SROUTB(reg,val&255); SROUTB(reg+1,(val>>8)&255);}static vidix_capability_t cyberblade_cap ={ "Trident CyberBlade i1 driver", "Alastair M. Robinson <blackfive@fakenhamweb.co.uk>", TYPE_OUTPUT, { 0, 0, 0, 0 }, 1024, 1024, 4, 4, -1, FLAG_UPSCALER|FLAG_DOWNSCALER, VENDOR_TRIDENT, -1, { 0, 0, 0, 0 }};static unsigned short cyberblade_card_ids[] ={ DEVICE_TRIDENT_CYBERBLADE_I7, DEVICE_TRIDENT_CYBERBLADE_I7D, DEVICE_TRIDENT_CYBERBLADE_I1, DEVICE_TRIDENT_CYBERBLADE_I12, DEVICE_TRIDENT_CYBERBLADE_I13, DEVICE_TRIDENT_CYBERBLADE_XPAI1};static int find_chip(unsigned chip_id){ unsigned i; for(i = 0;i < sizeof(cyberblade_card_ids)/sizeof(unsigned short);i++) { if(chip_id == cyberblade_card_ids[i]) return i; } return -1;}static int cyberblade_probe(int verbose, int force){ pciinfo_t lst[MAX_PCI_DEVICES]; unsigned i,num_pci; int err; err = pci_scan(lst,&num_pci); if(err) { printf("[cyberblade] Error occurred during pci scan: %s\n",strerror(err)); return err; } else { err = ENXIO; for(i=0; i < num_pci; i++) { if(lst[i].vendor == VENDOR_TRIDENT) { int idx; const char *dname; idx = find_chip(lst[i].device); if(idx == -1) continue; dname = pci_device_name(VENDOR_TRIDENT, lst[i].device); dname = dname ? dname : "Unknown chip"; printf("[cyberblade] Found chip: %s\n", dname);#if 0 if ((lst[i].command & PCI_COMMAND_IO) == 0) { printf("[cyberblade] Device is disabled, ignoring\n"); continue; }#endif cyberblade_cap.device_id = lst[i].device; err = 0; memcpy(&pci_info, &lst[i], sizeof(pciinfo_t)); break; } } } if(err && verbose) printf("[cyberblade] Can't find chip\n"); return err;}static int cyberblade_init(void){ cyberblade_mem = map_phys_mem(pci_info.base0, 0x800000); enable_app_io(); save_colourkey[0]=SRINB(0x50); save_colourkey[1]=SRINB(0x51); save_colourkey[2]=SRINB(0x52); save_colourkey[3]=SRINB(0x54); save_colourkey[4]=SRINB(0x55); save_colourkey[5]=SRINB(0x56);#ifdef DEBUG_LOGFILE logfile=fopen("/tmp/cyberblade_vidix.log","w");#endif return 0;}static void cyberblade_destroy(void){ int protect;#ifdef DEBUG_LOGFILE if(logfile) fclose(logfile);#endif protect=SRINB(0x11); SROUTB(0x11, 0x92); CROUTB(0x8E, 0xc4); /* Disable overlay */ SROUTB(0x50,save_colourkey[0]); SROUTB(0x51,save_colourkey[1]); SROUTB(0x52,save_colourkey[2]); SROUTB(0x54,save_colourkey[3]); SROUTB(0x55,save_colourkey[4]); SROUTB(0x56,save_colourkey[5]); SROUTB(0x11, protect); disable_app_io(); unmap_phys_mem(cyberblade_mem, 0x800000); }static int cyberblade_get_caps(vidix_capability_t *to){ memcpy(to, &cyberblade_cap, sizeof(vidix_capability_t)); return 0;}static int is_supported_fourcc(uint32_t fourcc){ switch(fourcc) { case IMGFMT_YUY2: case IMGFMT_YV12: case IMGFMT_I420: case IMGFMT_YVU9: case IMGFMT_BGR16: return 1; default: return 0; }}static int cyberblade_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; } to->depth = to->flags = 0; return ENOSYS;}static int frames[VID_PLAY_MAXFRAMES];static vidix_grkey_t cyberblade_grkey;static int cyberblade_get_gkeys(vidix_grkey_t *grkey){ memcpy(grkey, &cyberblade_grkey, sizeof(vidix_grkey_t)); return(0);}static int cyberblade_set_gkeys(const vidix_grkey_t *grkey){ int pixfmt=CRINB(0x38); int protect; memcpy(&cyberblade_grkey, grkey, sizeof(vidix_grkey_t)); protect=SRINB(0x11); SROUTB(0x11, 0x92); if(pixfmt&0x28) /* 32 or 24 bpp */ { SROUTB(0x50, cyberblade_grkey.ckey.blue); /* Colour Key */ SROUTB(0x51, cyberblade_grkey.ckey.green); /* Colour Key */ SROUTB(0x52, cyberblade_grkey.ckey.red); /* Colour Key */ SROUTB(0x54, 0xff); /* Colour Key Mask */ SROUTB(0x55, 0xff); /* Colour Key Mask */ SROUTB(0x56, 0xff); /* Colour Key Mask */ } else { int tmp=((cyberblade_grkey.ckey.blue & 0xF8)>>3) | ((cyberblade_grkey.ckey.green & 0xfc)<<3) | ((cyberblade_grkey.ckey.red & 0xf8)<<8); SROUTB(0x50, tmp&0xff); /* Colour Key */ SROUTB(0x51, (tmp>>8)&0xff); /* Colour Key */ SROUTB(0x52, 0); /* Colour Key */ SROUTB(0x54, 0xff); /* Colour Key Mask */ SROUTB(0x55, 0xff); /* Colour Key Mask */ SROUTB(0x56, 0x00); /* Colour Key Mask */ } SROUTB(0x11,protect); return(0);}static vidix_video_eq_t equal ={ VEQ_CAP_BRIGHTNESS | VEQ_CAP_SATURATION | VEQ_CAP_HUE, 300, 100, 0, 0, 0, 0, 0, 0};static int cyberblade_get_eq( vidix_video_eq_t * eq){ memcpy(eq,&equal,sizeof(vidix_video_eq_t)); return 0;}static int cyberblade_set_eq( const vidix_video_eq_t * eq){ int br,sat,cr,protect; if(eq->cap & VEQ_CAP_BRIGHTNESS) equal.brightness = eq->brightness; if(eq->cap & VEQ_CAP_CONTRAST) equal.contrast = eq->contrast; if(eq->cap & VEQ_CAP_SATURATION) equal.saturation = eq->saturation; if(eq->cap & VEQ_CAP_HUE) equal.hue = eq->hue; if(eq->cap & VEQ_CAP_RGB_INTENSITY) { equal.red_intensity = eq->red_intensity; equal.green_intensity = eq->green_intensity; equal.blue_intensity = eq->blue_intensity;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?