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

📄 init_osd1.c

📁 TI dm6446 video subsytem window blending programme
💻 C
字号:
/* * osd1: the attribute window * */#include <stdio.h>#include <stdlib.h>#include <fcntl.h>#include <unistd.h>#include <string.h>#include <sys/ioctl.h>#include <sys/mman.h>#include <asm/page.h>#include <linux/fb.h>#include "davinci_fb.h"/****************************************************************************** * setOsdTransparency ******************************************************************************/#define TRANS_ALL  ((char)0x77)#define TRANS_NONE ((char)0x0)#ifdef SVIDEO_OUTPUT# define IMAGE_REGION_X0 0# define IMAGE_REGION_Y0 0# define IMAGE_REGION_XL 720# define IMAGE_REGION_YH 480#else# define IMAGE_REGION_X0 0# define IMAGE_REGION_Y0 0# define IMAGE_REGION_XL 800# define IMAGE_REGION_YH 600#endif#define IMAGE_REGION_TRANS     TRANS_NONE#define NONIMAGE_REGION_TRANS  TRANS_ALLvoid setTransBuffer(unsigned char *buf, unsigned int xres, unsigned int yres){	int i, j;	unsigned int bufsize = xres * yres / 2;	unsigned int imagesize;	unsigned char *imageshadow;	unsigned int x0, y0, xl, yh;	x0 = IMAGE_REGION_X0;	y0 = IMAGE_REGION_Y0;	xl = IMAGE_REGION_XL;	yh = IMAGE_REGION_YH;	DBG("xres: %d, yres:%d\n", xres, yres);	memset(buf, NONIMAGE_REGION_TRANS, bufsize);	imagesize = xl * yh / 2;	imageshadow = malloc(imagesize);	memset(imageshadow, IMAGE_REGION_TRANS, imagesize);	{		unsigned char * pi, * po;		unsigned int image_startx = (y0 * xres + x0) / 2, imagelinelen = xl / 2;		unsigned int screenlinelen = xres / 2;		pi = imageshadow;		po = buf + image_startx;		for(i = 0; i < yh; i++)		{			//DBG("0x%x -> 0x%x, len=%d\n", pi - imageshadow, po - buf, imagelinelen);			memcpy(po, pi, imagelinelen);			pi += imagelinelen;			po += screenlinelen;		}	}}static int setOsdTransparency(int on){    struct fb_var_screeninfo vInfo;    unsigned short          *attrDisplay;    int                      attrSize;    int                      fd;    fd = open(ATTR_DEVICE, O_RDWR);    if (fd == -1) {        ERR("Failed to open attribute window %s\n", ATTR_DEVICE);        return FAILURE;    }	DBG("Open device %s OK.\n", ATTR_DEVICE);    if (ioctl(fd, FBIOGET_VSCREENINFO, &vInfo) == -1) {        ERR("Error reading variable information.\n");        return FAILURE;    }    /* One nibble per pixel */    attrSize = vInfo.xres_virtual * vInfo.yres / 2;     attrDisplay = (unsigned short *) mmap(NULL, attrSize,                                          PROT_READ | PROT_WRITE,                                          MAP_SHARED, fd, 0);    if (attrDisplay == MAP_FAILED) {        ERR("Failed mmap on %s\n", ATTR_DEVICE);        return FAILURE;    }    /* Fill the window with the new attribute value */    if(on == 0)    {		memset(attrDisplay, TRANS_ALL, attrSize);	}	else	{		setTransBuffer(attrDisplay, vInfo.xres_virtual, vInfo.yres);	}    munmap(attrDisplay, attrSize);    close(fd);    return SUCCESS;}int init_osd1(int on){	return setOsdTransparency(on);}

⌨️ 快捷键说明

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