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

📄 voosd.c~

📁 cam ui application for linux
💻 C~
字号:
/*************************************************************************//** This file and the information contain herein is provided "AS IS"    **//** without warranty of any kind, either expressed or implied,          **//** including but not limited to the implied warranties of              **//** merchantability and/or fitness for a particular purpose.            **//**                                                                     **//** Copyright (C) 2007 QPixel Technology Inc                            **//** All rights reserved.                                                **//** William Zhang 2007-7-18                                             **//*************************************************************************/#if 1 //def  VO_OSD#include <stdio.h>#include <unistd.h>#include <sys/mman.h>#include <fcntl.h>#include <termios.h>#include <unistd.h>#include <ctype.h>#include <stdlib.h>#include <string.h>#include <sys/ioctl.h>#include <sys/time.h>#include <time.h>#include <mntent.h>#include <signal.h>#include <asm/types.h>#define __user#include "../common/videodev2.h"#include "../common/qlioctl.h"#include "../common/qltypes.h"#include "../qlvoosd/qlosdfunc.h"#include "voosd.h"#include "menu.h"#define wprintf   printf#define FALSE  -1#define TRUE   0unsigned int Osd_hDev= 0;//unsigned char *Font_File = "courf00.fd";unsigned char *Font_File = "courf01.fd";//unsigned char *Font_File = "courf02.fd";FONT_INFO fontInfo;unsigned int QL_R_Mem(unsigned int memaddr,unsigned int memsize){    QLMEM_RW Reg;        unsigned int Err = 0;    unsigned int data;     Reg.size= memsize;    Reg.addr= memaddr;    Reg.pbuff = malloc(Reg.size);    Err = ioctl(Osd_hDev, QL201_DIAG_RDMEM, &Reg);    data = *(unsigned int *)Reg.pbuff;    wprintf("Read Mem %x returns %x  Err = %d\n",memaddr,*(unsigned int *)Reg.pbuff,Err);    free(Reg.pbuff);    return data;}unsigned int QL_W_Reg(unsigned int addr,unsigned int Data,unsigned int Type){  QLMEM_RW  Reg;  unsigned int value;  unsigned int Err = 0;  value = Data;  Reg.addr = addr;  Reg.pbuff =(unsigned char *)&value;  Reg.rdtype = Type;  Reg.size = 4;  Err = ioctl(Osd_hDev,QL201_DIAG_WRREG,&Reg);  if(Err < 0)    {     wprintf("Reg 0x%x, Data 0x%x Error !\n",Reg.addr, value);     return FALSE;    }     wprintf("Reg 0x%x, Data 0x%x OK!\n",Reg.addr,*(unsigned long *)Reg.pbuff); return TRUE;}unsigned int QL_R_Reg(unsigned int regaddr){    QLMEM_RW Reg;    unsigned int dwVal;    Reg.pbuff= (unsigned char *)&dwVal;    Reg.size= sizeof(dwVal);    Reg.addr= regaddr;    Reg.rdtype= RWREG_ARM;    ioctl(Osd_hDev, QL201_DIAG_RDREG, &Reg);    wprintf("Read reg %x returns %x \n", regaddr, dwVal);    return dwVal;}unsigned int SET_VO_MODE(unsigned char mode){    unsigned long Err = 0;  if(mode == VID_BYPASS || mode == VID_ENCODE)     Err = QL_W_Reg(0x50, 0x601,RWREG_ARM);  else     Err = QL_W_Reg(0x50, 0x600,RWREG_ARM);    if(Err < 0)     wprintf("Set Vo mode Fail %x \n", Err);     return Err; }unsigned int Enable_VO(void){    unsigned long Err = 0;    unsigned int Reg_val;    Reg_val =  QL_R_Reg(0x00);    if((Reg_val & 0xc) == 0xc)        return Err;    else        Reg_val |= 0xc;     Err = QL_W_Reg(0x00, Reg_val,RWREG_ARM);      if(Err < 0)       wprintf("Enable Vo Fail %x \n", Err);       return Err; }static int QLVOSetinterlace(void){   int Err = 0;   Err = QL_W_Reg(0x224,2,RWREG_ARM);  if(Err < 0)    {     wprintf("VO interlace set Err ! \n");     return Err;    } return Err;}int QLVOClutSetColor(unsigned char type) {	COLOR_DATA color;	COLOR_DATA color1;        color1.Read = OSD_RED | 0xff;        if(type == VID_BYPASS)        {color.Read  = OSD_WHITE;}        else if(type == VID_DECODE)        {color.Read  = OSD_BLACK;}         else if(type == VID_ENCODE)        {color.Read  = OSD_RED;}          SetCLUT(color1,color);}void osd_draw_high_light(int x, int y,unsigned char *Text){   //wprintf("Hilight text = %s \n",sizeof(*Text));   //wprintf("X = %d  Y = %d \n",x,y);  SetHiLight(0,Text,&fontInfo,x,y,4,OSD_HILIGHT_16B_COLOR);}void osd_window_show(int x, int y, int width,int height){	COLOR_DATA color;        color.Read = MENU_WINDOW_BACKGROUND;        DrawRectangle(0,x,y-4,width,height+8,color );}void osd_window_clear(int x, int y, int width,int height){	COLOR_DATA color;        color.Read = 0xff;        DrawRectangle(0,x,y-4,width,height+8,color );}void osd_text_show(int x, int y, unsigned char * Text,int font_color){	COLOR_DATA color;	COLOR_DATA color1;	color.Read = font_color;	color1.Read = MENU_WINDOW_BACKGROUND;        DrawText(0,Text,x,y,color,color1,&fontInfo,0);}//  bg_set 0: remove osd background color //         1: don't remove void osd_text_clear(int x, int y,int bg_set, unsigned char *Text){        unsigned char *Str = Text;          int i;	COLOR_DATA color;	COLOR_DATA color1;	color.Read = OSD_WHITE;        if(bg_set)	 color1.Read = OSD_BLUE | IN_TRANSPARENCY;        else           color1.Read = OSD_BLUE | ALL_TRANSPARENCY;        while(*Text != '\0')             *Text++ = ' ';          DrawText(0,Str,x,y,color,color1,&fontInfo,0);}int ql201_osd_init(unsigned char mode,unsigned char type){        int Err = 0;        int i;          VOOSD_CONFIG cfg;          QLDEV_OSD_PARAMETER param;  	  QLDEV_OSD_CONTROL 	ctrl;           Osd_hDev = open("/dev/video10", O_RDWR); // open dialog ioctl          if(Osd_hDev < 0)          {              wprintf("OSD Video Open Failure !\n");               return FALSE;           }          Err = LoadOSDFont( Font_File, &fontInfo); // load osd font          if(Err < 0)           {              close(Osd_hDev);              Osd_hDev= 0;              wprintf("Can't open OSD Font file !\n");              return Err;           }          SetOSDDev( Osd_hDev );          if(mode == RGB24BIT_720X480){                cfg.format = 1;                cfg.resolution = 0;                cfg.hx2 = 0;                cfg.vx2 = 0;            } else if(mode == LUT1BIT_720X480){                cfg.format = 2;                cfg.resolution = 0;                cfg.hx2 = 0;                cfg.vx2 = 0;            }else if(mode == RGB24BIT_352X240){                cfg.format = 1;                cfg.resolution = 1;                cfg.hx2 = 1;                cfg.vx2 = 1;            }else if(mode == LUT1BIT_352X240){                cfg.format = 2;                cfg.resolution = 1;                cfg.hx2 = 1;                cfg.vx2 = 1;            }                             SetOSDPixelFormat(cfg.format);          SetOSDResolution(cfg.resolution);          SetHorizontalx2(cfg.hx2);          SetVerticalx2(cfg.vx2);                      if(mode == LUT1BIT_352X240 || mode == LUT1BIT_720X480)             QLVOClutSetColor(type);          AllocateOSDMemory( );          SetCurrentOSD(0);            QLVOSetinterlace();          EnableOSD( );                    //QL_W_Reg(0x224, 4,RWREG_ARM);          wprintf("OSD Initialized !\n");                    return 0; }int ql201_osd_exit(void){	int err = 0;        ReleaseOSDMemory(0);        DisableOSD();	if (Osd_hDev > 0){		close(Osd_hDev);	}else{		err = FALSE;	}	return err;}#endif

⌨️ 快捷键说明

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