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

📄 dm642.c

📁 dm642的相关驱动程序
💻 C
📖 第 1 页 / 共 4 页
字号:
	if(buflen&0x03)	{		data = *(volatile unsigned long *)(iomap+0x18);		copy_to_user(pWork, (unsigned char *)&data, buflen&0x03);	}	if(getbuf_flag[tpoint.channel] != 0)	{		*(volatile unsigned long *)(iomap+4) = getbuf_flag[tpoint.channel];		getbuf[tpoint.channel * 1024] = *(volatile unsigned long *)(iomap+0x18);		getbuf[tpoint.channel * 1024 + 1] = *(volatile unsigned long *)(iomap+0x18);		if(getbuf[tpoint.channel * 1024 + 1] > 4096)		{			DEBUG_ERR_PRINT("getbuf overflow\n");			getbuf_flag[tpoint.channel] = 0;		}		else		{			for(j=2;j < (getbuf[tpoint.channel * 1024 + 1] >> 2) + 1; j++)			{				getbuf[tpoint.channel * 1024 + j] = *(volatile unsigned long *)(iomap+0x18);			}		}	}	*(volatile unsigned long *)(iomap+4) = COMPRESS_BUFFER_RECEIVEDFLAG0 + tpoint.channel * 128;	*(volatile unsigned long *)(iomap+0x0c) = 1;	copy_from_user((unsigned char*)&data, tpoint.buf+4, 4);	if(data==1)	{		put_user(g_SIZEX[tpoint.channel], tpoint.buf+7);	}	led+=1;	if(led<setled)		write_gpio_bit(GPIO_G1,1);	else if(led<setled*2)		write_gpio_bit(GPIO_G1,0);	else		led=0;	return buflen;}static void insertiframe(unsigned long point){	if(point & 1)	{		*(volatile unsigned long *)(iomap+4) = COMPRESS_INSERT_IFRAME0;		*(volatile unsigned long *)(iomap+0x0c) = 1;	}	if(point & 2)	{		*(volatile unsigned long *)(iomap+4) = COMPRESS_INSERT_IFRAME1;		*(volatile unsigned long *)(iomap+0x0c) = 1;	}	if(point & 4)	{		*(volatile unsigned long *)(iomap+4) = COMPRESS_INSERT_IFRAME2;		*(volatile unsigned long *)(iomap+0x0c) = 1;	}	if(point & 8)	{		*(volatile unsigned long *)(iomap+4) = COMPRESS_INSERT_IFRAME3;		*(volatile unsigned long *)(iomap+0x0c) = 1;	}	if(point&0x0f)	{		*(volatile unsigned long *)(iomap+0) = 0x00020002;	}}static int stopdm642status(unsigned long point){	*(volatile unsigned long *)(iomap+4) = COMPRESS_STOP_FLAG0 + point * 4;	return *(volatile unsigned long *)(iomap+0x1c);}static void dspstop(unsigned long point){	*(volatile unsigned long *)(iomap+4) = STOP_DSP_WORK;	*(volatile unsigned long *)(iomap+0x0c) = 1;	*(volatile unsigned long *)(iomap+0) = 0x00020002;}static int dspstopstatus(unsigned long point){	*(volatile unsigned long *)(iomap+4) = DSP_STOP_STATUS0 + point * 128;	return *(volatile unsigned long *)(iomap+0x1c);}static int setvideoparams(unsigned long point){	struct ioctl_set_videoparams tpoint;	copy_from_user(&tpoint, point, sizeof(struct ioctl_set_videoparams));	if(tpoint.channel > 3) return -1;	if(tpoint.brightness > 255) return -1;	if(tpoint.contrast > 255) return -1;	if(tpoint.saturation > 255) return -1;	if(tpoint.hue > 255) return -1;	if(tpoint.gain > 300) return -1;	if(tpoint.time_explosure > 100) return -1;	if(tpoint.gain_redpel > 63) return -1;	if(tpoint.gain_greenpela > 63) return -1;	if(tpoint.gain_greenpelb > 63) return -1;	if(tpoint.gain_bluepel > 63) return -1;	if(tpoint.agc_balance > 80) return -1;	if(tpoint.aperture > 255) return -1;	*(volatile unsigned long *)(iomap+4) = BRIGHTNESS0 + tpoint.channel * 128;	if(videodecoder == 0)	{		*(volatile unsigned long *)(iomap+8) = tpoint.brightness;//0~255 128		*(volatile unsigned long *)(iomap+8) = (tpoint.contrast + 128) & 0x0ff;//-128~127 68		*(volatile unsigned long *)(iomap+8) = (tpoint.saturation + 128) & 0x0ff;//-128~127 64		*(volatile unsigned long *)(iomap+8) = (tpoint.hue + 128) & 0x0ff;//-128~127 0	}	else if(videodecoder == 1)	{		*(volatile unsigned long *)(iomap+8) = (tpoint.brightness + 128) & 0x0ff;// -128~127 0		*(volatile unsigned long *)(iomap+8) = (tpoint.contrast + 0) & 0x0ff;// 0~255 128		*(volatile unsigned long *)(iomap+8) = (tpoint.saturation + 0) & 0x0ff;//0~255 128		if(tpoint.hue / 3 >= 42)//-45~45 0		{			*(volatile unsigned long *)(iomap+8) = tpoint.hue / 3 - 42;		}		else		{			*(volatile unsigned long *)(iomap+8) = 0xd6 + (tpoint.hue / 3);		}	}	else if(videodecoder == 2)	{		*(volatile unsigned long *)(iomap+8) = (tpoint.brightness + 0) & 0x0ff;//0~255 128		*(volatile unsigned long *)(iomap+8) = (tpoint.contrast + 0) & 0x0ff;//0~255 128		*(volatile unsigned long *)(iomap+8) = (tpoint.saturation + 0) & 0x0ff;//0~255 128		*(volatile unsigned long *)(iomap+8) = (tpoint.hue + 0) & 0x0ff;//0~255 128	}	else	{		*(volatile unsigned long *)(iomap+8) = (tpoint.brightness + 0) & 0x0ff;//0~255 128		*(volatile unsigned long *)(iomap+8) = (tpoint.contrast + 0) & 0x0ff;//0~255 128		*(volatile unsigned long *)(iomap+8) = (tpoint.saturation + 0) & 0x0ff;//0~255 128		*(volatile unsigned long *)(iomap+8) = (tpoint.hue + 0) & 0x0ff;//0~255 128	}	*(volatile unsigned long *)(iomap+8) = tpoint.gain;	*(volatile unsigned long *)(iomap+8) = (tpoint.time_explosure-1)*6;	*(volatile unsigned long *)(iomap+8) = tpoint.gain_redpel;	*(volatile unsigned long *)(iomap+8) = tpoint.gain_greenpela;	*(volatile unsigned long *)(iomap+8) = tpoint.gain_greenpelb;	*(volatile unsigned long *)(iomap+8) = tpoint.gain_bluepel;	*(volatile unsigned long *)(iomap+8) = tpoint.work_mode;	*(volatile unsigned long *)(iomap+8) = tpoint.agc_balance + 80;	*(volatile unsigned long *)(iomap+8) = tpoint.aperture;	*(volatile unsigned long *)(iomap+4) = SET_VIDEOPARAM_FUNC0 + tpoint.channel * 128;	*(volatile unsigned long *)(iomap+8) = 1;	*(volatile unsigned long *)(iomap+0) = 0x00020002;	return 0;}static int getvideoparams(unsigned long point){	unsigned long temp;	struct ioctl_get_videoparams tpoint;	copy_from_user(&tpoint, point, sizeof(struct ioctl_get_videoparams));	if(tpoint.channel > 3) return -1;	*(volatile unsigned long *)(iomap+4) = BRIGHTNESS0 + tpoint.channel * 128;	if(videodecoder == 0)	{		tpoint.brightness = *(volatile unsigned long *)(iomap+0x18) & 0x0ff;		tpoint.contrast = (*(volatile unsigned long *)(iomap+0x18) + 128) & 0x0ff;		tpoint.saturation = (*(volatile unsigned long *)(iomap+0x18) + 128) & 0x0ff;		tpoint.hue = (*(volatile unsigned long *)(iomap+0x18) + 128) & 0x0ff;	}	else if(videodecoder == 1)	{		tpoint.brightness = (*(volatile unsigned long *)(iomap+0x18) + 128) & 0x0ff;		tpoint.contrast = (*(volatile unsigned long *)(iomap+0x18) + 0) & 0x0ff;		tpoint.saturation = (*(volatile unsigned long *)(iomap+0x18) + 0) & 0x0ff;		temp = *(volatile unsigned long *)(iomap+0x18);		if(temp < 127)		{			tpoint.hue = (temp+42) * 3;		}		else		{			tpoint.hue = (temp-0xd6) * 3;		}	}	else if(videodecoder == 2)	{		tpoint.brightness = (*(volatile unsigned long *)(iomap+0x18) + 0) & 0x0ff;		tpoint.contrast = (*(volatile unsigned long *)(iomap+0x18) + 0) & 0x0ff;		tpoint.saturation = (*(volatile unsigned long *)(iomap+0x18) + 0) & 0x0ff;		tpoint.hue = (*(volatile unsigned long *)(iomap+0x18) + 0) & 0x0ff;	}	else	{		tpoint.brightness = (*(volatile unsigned long *)(iomap+0x18) + 0) & 0x0ff;		tpoint.contrast = (*(volatile unsigned long *)(iomap+0x18) + 0) & 0x0ff;		tpoint.saturation = (*(volatile unsigned long *)(iomap+0x18) + 0) & 0x0ff;		tpoint.hue = (*(volatile unsigned long *)(iomap+0x18) + 0) & 0x0ff;	}	tpoint.gain = *(volatile unsigned long *)(iomap+0x18);	tpoint.time_explosure = *(volatile unsigned long *)(iomap+0x18)/6+1;	tpoint.gain_redpel = *(volatile unsigned long *)(iomap+0x18);	tpoint.gain_greenpela = *(volatile unsigned long *)(iomap+0x18);	tpoint.gain_greenpelb = *(volatile unsigned long *)(iomap+0x18);	tpoint.gain_bluepel = *(volatile unsigned long *)(iomap+0x18);	tpoint.work_mode = *(volatile unsigned long *)(iomap+0x18);	tpoint.agc_balance = *(volatile unsigned long *)(iomap+0x18)-80;	tpoint.aperture = *(volatile unsigned long *)(iomap+0x18);	copy_to_user(point, &tpoint, sizeof(struct ioctl_get_videoparams));	return 0;}static int setcompressparams(unsigned long point){	struct ioctl_set_compressparams tpoint;	copy_from_user(&tpoint, point, sizeof(struct ioctl_set_compressparams));	if(tpoint.channel > 3) return -1;	*(volatile unsigned long *)(iomap+4) = COMPRESS_I_QUANT0 + tpoint.channel * 128;	*(volatile unsigned long *)(iomap+8) = tpoint.I_QUANT;	*(volatile unsigned long *)(iomap+8) = tpoint.P_QUANT;	*(volatile unsigned long *)(iomap+8) = tpoint.I_RATE;	*(volatile unsigned long *)(iomap+8) = tpoint.FRAME_ON;	*(volatile unsigned long *)(iomap+8) = tpoint.FRAME_OFF;	*(volatile unsigned long *)(iomap+8) = 0;	*(volatile unsigned long *)(iomap+8) = tpoint.SIZEX;	g_SIZEX[tpoint.channel] = tpoint.SIZEX;	g_I_QUANT[tpoint.channel] = tpoint.I_QUANT;	g_P_QUANT[tpoint.channel] = tpoint.P_QUANT;	frameon[tpoint.channel] = tpoint.FRAME_ON;	frameoff[tpoint.channel] = tpoint.FRAME_OFF;	*(volatile unsigned long *)(iomap+0) = 0x00020002;	return 0;}static int getcompressparams(unsigned long point){	unsigned long ul;	struct ioctl_get_compressparams tpoint;	copy_from_user(&tpoint, point, sizeof(struct ioctl_get_compressparams));	if(tpoint.channel > 3) return -1;	*(volatile unsigned long *)(iomap+4) = COMPRESS_I_QUANT0 + tpoint.channel * 128;	tpoint.I_QUANT = *(volatile unsigned long *)(iomap+0x18);	tpoint.P_QUANT = *(volatile unsigned long *)(iomap+0x18);	tpoint.I_RATE = *(volatile unsigned long *)(iomap+0x18);	tpoint.FRAME_ON = *(volatile unsigned long *)(iomap+0x18);	tpoint.FRAME_OFF = *(volatile unsigned long *)(iomap+0x18);	ul = *(volatile unsigned long *)(iomap+0x18);	tpoint.SIZEX = *(volatile unsigned long *)(iomap+0x18);	copy_to_user(point, &tpoint, sizeof(struct ioctl_get_compressparams));	return 0;}static int getstandard(unsigned long point){	if(point > 3) return -1;	*(volatile unsigned long *)(iomap+4) = STANDARD0 + point * 128;	return *(volatile unsigned long *)(iomap+0x1c);}static int setstandard(unsigned long point){	gStandard=point;	return 0;}static void setosdbuf(unsigned long type, unsigned long * point){	unsigned long ul1;	if((type & 0xffff0000) == 0x08040000)	{		if((type & 0x0000fffe) == 2)// 2,3		{			ul1 = __REG(0x57000088);			point[0] = '0002' + (((ul1 & 0x0f0) >> 4) << 16) + ((ul1 & 0x0f) << 24);			ul1 = __REG(0x57000084);			point[1] = '-00-' + ((((ul1 & 0x0f0) >> 4)) << 8)+ ((ul1 & 0x0f) << 16);			ul1 = __REG(0x5700007c);			point[2] = '  00' + ((ul1 & 0x0f0) >> 4) + ((ul1 & 0x0f) << 8);		}		else if((type & 0x0000fffe) == 4)// 4,5		{			ul1 = __REG(0x57000084);			point[0] = '0-00' + ((ul1 & 0x0f0) >> 4) + ((ul1 & 0x0f) << 8);			ul1 = __REG(0x5700007c);			point[0] += ((ul1 & 0x0f0) >> 4) << 24;			point[1] = '02-0' + (ul1 & 0x0f);			ul1 = __REG(0x57000088);			point[2] = '  00' + ((ul1 & 0x0f0) >> 4) + ((ul1 & 0x0f) << 8);		}		else if((type & 0x0000fffe) == 6)// 6,7		{			ul1 = __REG(0x5700007c);			point[0] = '0-00' + ((ul1 & 0x0f0) >> 4) + ((ul1 & 0x0f) << 8);			ul1 = __REG(0x57000084);			point[0] += ((ul1 & 0x0f0) >> 4) << 24;			point[1] = '02-0' + (ul1 & 0x0f);			ul1 = __REG(0x57000088);			point[2] = '  00' + ((ul1 & 0x0f0) >> 4) + ((ul1 & 0x0f) << 8);		}		else		{			point[0] = 0x20202020;			point[1] = 0x20202020;			point[2] = 0x20202020;		}		if((type & 1) == 1)		{			point[3] = 0x20202020;			point[4] = 0x20202020;		}		else		{			point[3] = 0xdac6c7d0;			ul1 = __REG(0x57000080);			if (ul1 == 1)			{				point[4] = 0x2020bbd2;			}			else if(ul1 == 2)			{				point[4] = 0x2020feb6;			}			else if(ul1 == 3)			{				point[4] = 0x2020fdc8;			}			else if(ul1 == 4)			{				point[4] = 0x2020c4cb;			}			else if(ul1 == 5)			{				point[4] = 0x2020e5ce;			}			else if(ul1 == 6)			{				point[4] = 0x2020f9c1;			}			else if(ul1 == 7)			{				point[4] = 0x2020d5c8;			}		}	}}static int setosdparams(unsigned long point){	int i;	unsigned long ul1,ul2;	struct ioctl_set_osdparams tpoint;	copy_from_user(&tpoint, point, sizeof(struct ioctl_set_osdparams));	if(tpoint.channel > 3) return -1;	osdparam[tpoint.channel].channel = tpoint.channel;	if(tpoint.MODIFY_FLAG & 0x00000001)//mask	{		if(tpoint.MASK_RGN_X_Y >> 16 > 704) goto logo;		if(tpoint.MASK_RGN_X_Y & 0x0ffff > 576) goto logo;		if(tpoint.MASK_RGN_WIDTH_HEIGHT >> 16 > 704) goto logo;		if(tpoint.MASK_RGN_WIDTH_HEIGHT & 0x0ffff > 576) goto logo;		ul1 = tpoint.MASK_RGN_X_Y + tpoint.MASK_RGN_WIDTH_HEIGHT;		if(ul1 >> 16 > 704) goto logo;		if(ul1 & 0x0ffff > 576) goto logo;		*(volatile unsigned long *)(iomap+4) = MASK_RGN_X_Y0 + tpoint.channel * 128;		*(volatile unsigned long *)(iomap+8) = tpoint.MASK_RGN_X_Y;		osdparam[tpoint.channel].MASK_RGN_X_Y = tpoint.MASK_RGN_X_Y;		*(volatile unsigned long *)(iomap+8) = tpoint.MASK_RGN_WIDTH_HEIGHT;		osdparam[tpoint.channel].MASK_RGN_WIDTH_HEIGHT = tpoint.MASK_RGN_WIDTH_HEIGHT;	}logo:	if(tpoint.MODIFY_FLAG & 0x00000100)//logo	{		if(tpoint.LOGO_RGN_X_Y >> 16 > 704) goto osd;		if(tpoint.LOGO_RGN_X_Y & 0x0ffff > 576) goto osd;		if(tpoint.LOGO_RGN_WIDTH_HEIGHT >> 16 > 704) goto osd;		if(tpoint.LOGO_RGN_WIDTH_HEIGHT & 0x0ffff > 576) goto osd;		ul1 = tpoint.LOGO_RGN_X_Y + tpoint.LOGO_RGN_WIDTH_HEIGHT;		if(ul1 >> 16 > 704) goto osd;		if(ul1 & 0x0ffff > 576) goto osd;		*(volatile unsigned long *)(iomap+4) = LOGO_RGN_X_Y0 + tpoint.channel * 128;		*(volatile unsigned long *)(iomap+8) = tpoint.LOGO_RGN_X_Y;		osdparam[tpoint.channel].LOGO_RGN_X_Y = tpoint.LOGO_RGN_X_Y;		*(volatile unsigned long *)(iomap+8) = tpoint.LOGO_RGN_WIDTH_HEIGHT;		osdparam[tpoint.channel].LOGO_RGN_WIDTH_HEIGHT = tpoint.LOGO_RGN_WIDTH_HEIGHT;	}osd:	if(tpoint.MODIFY_FLAG & 0x00010000)//osd	{		if(tpoint.LINE0_STARTX > 704 - 20) goto end;		if(tpoint.LINE0_STARTY > 576 - 20) goto end;		if(tpoint.LINE1_STARTX > 704 - 20) goto end;		if(tpoint.LINE1_STARTY > 576 - 20) goto end;		if(((tpoint.LINE0_TYPE & 0x0ffff) == 0) && (tpoint.LINE0_CHARS > 64 - 8)) goto end;		if(tpoint.LINE1_CHARS > 64) goto end;		osdparam[tpoint.channel].LINE0_TYPE = tpoint.LINE0_TYPE;		if((tpoint.LINE0_TYPE & 0x0ffff) == 0)		{			__REG(0x57000050) = 0;		}		else		{			if((tpoint.LINE0_TYPE & 0xffff0000) == 0x08040000)			{				if((tpoint.LINE0_TYPE & 1) == 1)				{					tpoint.LINE0_CHARS = 20;					tpoint.LINE0_CLOCK_POS = 12;				}				else				{					tpoint.LINE0_CHARS = 28;					tpoint.LINE0_CLOCK_POS = 20;				}			}			else			{				tpoint.LINE0_CHARS = 0;				tpoint.LINE0_CLOCK_POS = 0;			}			setosdbuf(tpoint.LINE0_TYPE, tpoint.LINE_BUF);			ul1 = __REG(0x57000078) & 0x0f;			ul2 = ((__REG(0x57000078) >> 4) * 10 + ul1) * 3600;			ul1 = __REG(0x57000074) & 0x0f;			ul2 += ((__REG(0x57000074) >> 4) * 10 + ul1) * 60;			ul1 = __REG(0x57000070) & 0x0f;			ul1 += (__REG(0x57000070) >> 4) * 10;			if(ul1 == 0)			{				ul1 = __REG(0x57000078) & 0x0f;				ul2 = ((__REG(0x57000078) >> 4) * 10 + ul1) * 3600;				ul1 = __REG(0x57000074) & 0x0f;				ul2 += ((__REG(0x57000074) >> 4) * 10 + ul1) * 60;				ul1 = __REG(0x57000070) & 0x0f;				ul1 += (__REG(0x57000070) >> 4) * 10;			}			ul2 += ul1;			tpoint.HOST_CLOCK_SECS = ul2;			tpoint.CLOCK_MODIFY = 1;			__REG(0x57000050) = 0x43;			__REG(0x57000058) = 0;			__REG(0x57000054) = 0;		}		*(volatile unsigned long *)(iomap+4) = OSD_LINE0_STARTX0 + tpoint.channel * 128;		*(volatile unsigned long *)(iomap+8) = tpoint.LINE0_STARTX;		osdparam[tpoint.channel].LINE0_STARTX = tpoint.LINE0_STARTX;		*(volatile unsigned long *)(iomap+8) = tpoint.LINE0_STARTY;		osdparam[tpoint.channel].LINE0_STARTY = tpoint.LINE0_STARTY;		*(volatile unsigned long *)(iomap+8) = tpoint.LINE0_CHARS;		osdparam[tpoint.channel].LINE0_CHARS = tpoint.LINE0_CHARS;		*(volatile unsigned long *)(iomap+8) = tpoint.LINE0_CLOCK_POS;		osdparam[tpoint.channel].LINE0_CLOCK_POS = tpoint.LINE0_CLOCK_POS;

⌨️ 快捷键说明

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