display.c

来自「omap3 linux 2.6 用nocc去除了冗余代码」· C语言 代码 · 共 2,061 行 · 第 1/5 页

C
2,061
字号
		if (((gfx_posX + gfx_sizeX) <= vid_posX) || ((gfx_posY + gfx_sizeY) <= vid_posY)) {			overlay_opt_enable = 0;		}	}	else {		overlay_opt_enable = 0;	}	/* Enable overlay optimization */	if (overlay_opt_enable) {		X = vid_sizeX;		if ((vid_posX == 0) && (gfx_sizeX <= (vid_posX + vid_sizeX))) {			X = gfx_sizeX + 1;			Y = vid_sizeY + 1;			skip_val = Y * ((X - 1) * (gfx_pix_inc - 1 + bytesperpixel) +					(gfx_row_inc - 1 + bytesperpixel));			goto skip;		}		if ((vid_posX + vid_sizeX) >= gfx_sizeX) {			X = gfx_sizeX - vid_posX + 1;		}		if ((vid_posX == 0) || (gfx_sizeX <= (vid_posX + vid_sizeX))) {			overlay_opt_delta = 0;		}		else {			overlay_opt_delta = 1;		}		skip_val = (X * (gfx_pix_inc + bytesperpixel - 1) + overlay_opt_delta);skip:	        /*dispc_reg_out(DISPC_GFX_WINDOW_SKIP,skip_val);		dispc_reg_merge(DISPC_CONTROL, DISPC_CONTROL_OVERLAYOPTIMIZATION,				DISPC_CONTROL_OVERLAYOPTIMIZATION);*/		;	}}/* Configure VIDEO1 or VIDEO2 layer parameters*/voidomap2_disp_config_vlayer(int ltype, struct v4l2_pix_format *pix,			 struct v4l2_rect *crop, struct v4l2_window *win,			 int rotation_deg, int mirroring){	int vid_position_x, vid_position_y, ps = 2,vr_ps = 1;	unsigned long vid_position, vid_size, vid_picture_size;	unsigned long vid_attributes;	unsigned long firvinc, firhinc;	int winheight, winwidth, cropheight, cropwidth, pixheight, pixwidth;	int cleft, ctop;	int panelwidth, panelheight, row_inc_value=0, pixel_inc_value=0;	int flicker_filter = 0;	/* vertical resizing matrix */	const static short int vc_u[3][8] =	{ {   0,   3,  12,  32,   0,   7,   5,   2 },		{ 128, 123, 111,  89,  64,  89, 111, 123 },		{   0,   2,   5,   7,  64,  32,  12,   3 } };	/* horizontal resizing matrix */	const static short int hc_u[5][8] =	{ {   0,  -1,  -2,  -5,   0,  -2,  -1,   0 },		{   0,  13,  30,  51,  -9, -11, -11,  -8 },		{ 128, 124, 112,  95,  73,  95, 112, 124 },		{   0,  -8, -11, -11,  73,  51,  30,  13 },		{   0,   0,  -1,  -2,  -9,  -5,  -2,  -1 } };	const static short int vc_d[3][8] =	{ {   36,   40,  45,  50,   18,   23,   27,   31 },		{ 56, 57, 56,  55,  55,  55, 56, 57 },		{   36,   31,   27,   23,  55,  50,  45,   40 } };	/* horizontal resizing matrix */	const static short int hc_d[5][8] =	{ {   0,  4,  8,  -12,   -9,  -7,  -5,  -2 },		{   36,  40,  44,  48,  17, 22, 27, 31 },		{ 56, 55, 54,  53,  52,  53, 54, 55 },		{   36,  31, 27, 22,  51,  48,  44,  40 },		{   0,   -2,  -5,  -7,  17,  12,  8,  4 } };	short int* vc= (short int *) vc_u;	short int* hc= (short int *) hc_u;	int v;	if (ltype == OMAP2_VIDEO1) v = 0;	else if (ltype == OMAP2_VIDEO2) v = 1;	else return;/*	if ((omap2_disp_get_output_dev(ltype) == OMAP2_OUTPUT_TV) && 			((win->w.width == crop->width) && (win->w.height == crop->height)))		flicker_filter = 1;*/	/* make sure the video overlay is disabled before we reconfigure it */	omap2_disp_disable_layer(ltype);	/* configure the video attributes register */	vid_attributes = 0;	switch (pix->pixelformat) {		case V4L2_PIX_FMT_YUYV:		case V4L2_PIX_FMT_UYVY:			if(pix->pixelformat == V4L2_PIX_FMT_YUYV){				vid_attributes |= DISPC_VID_ATTRIBUTES_VIDFORMAT_YUV2;				vid_attributes |= DISPC_VID_ATTRIBUTES_VIDCOLORCONVENABLE;			}			else{				vid_attributes |= DISPC_VID_ATTRIBUTES_VIDFORMAT_UYVY;				vid_attributes |= DISPC_VID_ATTRIBUTES_VIDCOLORCONVENABLE;			}			if (mirroring == 1 || rotation_deg >=0){				/* 				 * ps      - In VRFB space the pixel size for YUYV/UYVY is 4 bytes				 * vr_ps - Actual pixel size for YUYV/UYVY  is 2 bytes				 */				ps = 4;vr_ps = 2;			}			if (rotation_deg >= 0) {				if(mirroring == 1){					vid_attributes |= (rotation_deg == 90)?						((0x3) << DISPC_VID_ATTRIBUTES_VIDROT):						(rotation_deg == 270)?((0x1) << DISPC_VID_ATTRIBUTES_VIDROT):						(rotation_deg == 0)?(0x2 << DISPC_VID_ATTRIBUTES_VIDROT):						(0<<DISPC_VID_ATTRIBUTES_VIDROT);				}				else{					vid_attributes |= (rotation_deg == 90)?						((0x3) << DISPC_VID_ATTRIBUTES_VIDROT):						(rotation_deg == 270)?((0x1) << DISPC_VID_ATTRIBUTES_VIDROT):						((rotation_deg / 90) << DISPC_VID_ATTRIBUTES_VIDROT);				}				vid_attributes |= (rotation_deg == 90 || rotation_deg == 270)? 					(1 << DISPC_VID_ATTRIBUTES_VIDROWREPEAT):					(0 << DISPC_VID_ATTRIBUTES_VIDROWREPEAT);			}			if (mirroring == 1 && rotation_deg == -1){				vid_attributes |= (0x2 << DISPC_VID_ATTRIBUTES_VIDROT);			}			break;		case V4L2_PIX_FMT_RGB24:			ps = 3; /* pixel size is 3 bytes */			vid_attributes |= DISPC_VID_ATTRIBUTES_VIDFORMAT_RGB24P;			vid_attributes |= ((dispc_reg_in(DISPC_GFX_ATTRIBUTES) &						DISPC_GFX_ATTRIBUTES_GFXREPLICATIONENABLE)					<< DISPC_GFX_ATTRIBUTES_GFXREPEN);			break;			/* The picture format is a bit confusing in V4L2.. as per the V4L2 spec			 * RGB32 and BGR32 are always with alpha bits enabled.. (i.e always in			 * packed mode) */		case V4L2_PIX_FMT_RGB32:			ps = 4; /* pixel size is 4 bytes */			if ((is_sil_rev_less_than(OMAP3430_REV_ES2_0)) || (ltype == OMAP2_VIDEO1)) {				vid_attributes |= DISPC_VID_ATTRIBUTES_VIDFORMAT_RGB24;				vid_attributes |= ((dispc_reg_in(DISPC_GFX_ATTRIBUTES) &							DISPC_GFX_ATTRIBUTES_GFXREPLICATIONENABLE)						<< DISPC_GFX_ATTRIBUTES_GFXREPEN);			}			else {				vid_attributes |= DISPC_VID_ATTRIBUTES_VIDFORMAT_ARGB32;				vid_attributes |= DISPC_VID_ATTRIBUTES_VIDENDIANNESS;			}			break;		case V4L2_PIX_FMT_BGR32:			ps = 4; /* pixel size is 4 bytes */			if ((is_sil_rev_less_than(OMAP3430_REV_ES2_0)) || (ltype == OMAP2_VIDEO1)) {				vid_attributes |= DISPC_VID_ATTRIBUTES_VIDFORMAT_RGB24;				vid_attributes |= ((dispc_reg_in(DISPC_GFX_ATTRIBUTES) &							DISPC_GFX_ATTRIBUTES_GFXREPLICATIONENABLE)						<< DISPC_GFX_ATTRIBUTES_GFXREPEN);			}			else {					vid_attributes |= DISPC_VID_ATTRIBUTES_VIDFORMAT_ARGB32;			}				break;		case V4L2_PIX_FMT_RGB565:		default:			ps = 2; /* pixel size is 2 bytes */			vid_attributes |= DISPC_VID_ATTRIBUTES_VIDFORMAT_RGB16;			vid_attributes |= ((dispc_reg_in(DISPC_GFX_ATTRIBUTES) &						DISPC_GFX_ATTRIBUTES_GFXREPLICATIONENABLE)					<< DISPC_GFX_ATTRIBUTES_GFXREPEN);			break;		case V4L2_PIX_FMT_RGB565X:			ps = 2; /* pixel size is 2 bytes */			vid_attributes |= DISPC_VID_ATTRIBUTES_VIDFORMAT_RGB16;			vid_attributes |= DISPC_VID_ATTRIBUTES_VIDENDIANNESS;			vid_attributes |= ((dispc_reg_in(DISPC_GFX_ATTRIBUTES) &						DISPC_GFX_ATTRIBUTES_GFXREPLICATIONENABLE) 					<< DISPC_GFX_ATTRIBUTES_GFXREPEN);			break;	}	if (omap2_disp_get_output_dev(ltype) == OMAP2_OUTPUT_TV)		vid_attributes |= DISPC_VID_ATTRIBUTES_VIDCHANNELOUT;	/* Enable 16 x 32 burst size */	vid_attributes |= DISPC_VID_ATTRIBUTES_VIDBURSTSIZE_BURST16X32;	/* Set FIFO threshold to 0xFF (high) and 0xFF - (16x4bytes) = 0xC0 (low)*/ 	// dispc_reg_out(DISPC_VID_FIFO_THRESHOLD(v),0x00FF00C0);	dispc_reg_out(DISPC_VID_FIFO_THRESHOLD(v),0x03FC03BC);	/* Set the color converion parameters */	set_colorconv(v,pix->colorspace);	if (rotation_deg == 90 || rotation_deg == 270) {		winheight = win->w.width;		winwidth = win->w.height;		cropheight = crop->width;		cropwidth = crop->height;		pixheight = pix->width;		pixwidth = pix->height;		cleft = crop->top;		ctop = crop->left;	} else {		winwidth = win->w.width;		winheight = win->w.height;		cropwidth = crop->width;		cropheight = crop->height;		pixheight = pix->height;		pixwidth = pix->width;		ctop = crop->top;		cleft = crop->left;	}	if (winwidth != cropwidth) {		vid_attributes |= DISPC_VID_ATTRIBUTES_VIDRESIZEENABLE_HRESIZE;		if (winwidth < cropwidth){			vid_attributes |= DISPC_VID_ATTRIBUTES_VIDHRESIZECONF;			hc = (short int *) hc_d;		}	}	if (winheight != cropheight) {		vid_attributes |= DISPC_VID_ATTRIBUTES_VIDRESIZEENABLE_VRESIZE;		if (winheight < cropheight){			vid_attributes |= DISPC_VID_ATTRIBUTES_VIDVRESIZECONF;			vc = (short int *) vc_d;		}	}	if (flicker_filter == 1) {		vid_attributes |= DISPC_VID_ATTRIBUTES_VIDRESIZEENABLE_VRESIZE;		vid_attributes |= DISPC_VID_ATTRIBUTES_VIDVRESIZECONF;		vc = (short int *) vc_d;	}	dispc_reg_out(DISPC_VID_ATTRIBUTES(v), vid_attributes);	/* initialize the resizing filter */	omap2_disp_set_resize(v, vc, hc);	dispc_reg_out(DISPC_VID_ACCU0(v), 0);	if(flicker_filter == 1)		dispc_reg_out(DISPC_VID_ACCU1(v), 0x01000000);	else		dispc_reg_out(DISPC_VID_ACCU1(v), 0);	firhinc = (1024 * (cropwidth - 1)) / (winwidth - 1);	if (firhinc < 1)		firhinc = 1;	else if (firhinc > 2047)		firhinc = 2047;	firvinc = (1024 * (cropheight - 1)) / (winheight - 1);	if (firvinc < 1)		firvinc = 1;	else if (firvinc > 2047)		firvinc = 2047;	if(flicker_filter == 0)		dispc_reg_out(DISPC_VID_FIR(v), firhinc | (firvinc << 16));	else		dispc_reg_out(DISPC_VID_FIR(v), 0x08000000);		omap2_disp_get_panel_size(omap2_disp_get_output_dev(ltype), &panelwidth,			&panelheight);	/* configure the target window on the display */	switch (rotation_deg) {		case 90:			vid_position_y = (panelheight - win->w.width) - win->w.left;			vid_position_x = win->w.top;			break;		case 180:			vid_position_x = (panelwidth - win->w.width) - win->w.left;			vid_position_y = (panelheight - win->w.height) - win->w.top;			break;		case 270:			vid_position_y = win->w.left;			vid_position_x = (panelwidth - win->w.height) - win->w.top;			break;		default:			vid_position_x = win->w.left;			vid_position_y = win->w.top;			break;	}	if (omap2_disp_get_output_dev(ltype) == OMAP2_OUTPUT_TV) 		vid_position_y = vid_position_y/2;	/*	 * 	If Scaling is enabled for TV then the window height should be divided by two	 */	if (((omap2_disp_get_output_dev(ltype) == OMAP2_OUTPUT_TV) && 				(winheight != cropheight)) || flicker_filter) {		vid_size = (((winwidth - 1) << DISPC_VID_SIZE_VIDSIZEX_SHIFT)				& DISPC_VID_SIZE_VIDSIZEX)			| ((((winheight - 1)/2) << DISPC_VID_SIZE_VIDSIZEY_SHIFT)					& DISPC_VID_SIZE_VIDSIZEY);	} else {		vid_size = (((winwidth - 1) << DISPC_VID_SIZE_VIDSIZEX_SHIFT)				& DISPC_VID_SIZE_VIDSIZEX)			| (((winheight - 1) << DISPC_VID_SIZE_VIDSIZEY_SHIFT)					& DISPC_VID_SIZE_VIDSIZEY);	}	/* configure the source window in the framebuffer */	if(flicker_filter == 1){		vid_picture_size =			(((cropwidth - 1) << DISPC_VID_PICTURE_SIZE_VIDORGSIZEX_SHIFT)			 & DISPC_VID_PICTURE_SIZE_VIDORGSIZEX) |			(((cropheight - 1) << DISPC_VID_PICTURE_SIZE_VIDORGSIZEY_SHIFT)			 & DISPC_VID_PICTURE_SIZE_VIDORGSIZEY);	} else if((omap2_disp_get_output_dev(ltype) == OMAP2_OUTPUT_TV) && (flicker_filter == 0)) {		vid_picture_size =			(((cropwidth -			   1) << DISPC_VID_PICTURE_SIZE_VIDORGSIZEX_SHIFT)			 & DISPC_VID_PICTURE_SIZE_VIDORGSIZEX) |			(((cropheight / 2 -			   1) << DISPC_VID_PICTURE_SIZE_VIDORGSIZEY_SHIFT)			 & DISPC_VID_PICTURE_SIZE_VIDORGSIZEY);	} else {		vid_picture_size =			(((cropwidth -			   1) << DISPC_VID_PICTURE_SIZE_VIDORGSIZEX_SHIFT)			 & DISPC_VID_PICTURE_SIZE_VIDORGSIZEX) |			(((cropheight -			   1) << DISPC_VID_PICTURE_SIZE_VIDORGSIZEY_SHIFT)			 & DISPC_VID_PICTURE_SIZE_VIDORGSIZEY);	}	switch (mirroring) {		case 0:		/* No mirroring */			if (rotation_deg == 90 || rotation_deg == 270) {				row_inc_value =					1 + (MAX_PIXELS_PER_LINE - pixwidth + 							(pixwidth - cropwidth - cleft) + cleft) * ps;			}			else if (rotation_deg == 180 || rotation_deg == 0) {				if (V4L2_PIX_FMT_YUYV == pix->pixelformat						|| V4L2_PIX_FMT_UYVY == pix->pixelformat)					row_inc_value =						1 + (MAX_PIXELS_PER_LINE - 								(pixwidth/ vr_ps) + ((pixwidth - cropwidth - cleft)/vr_ps)								+ (cleft / vr_ps) ) * ps;				else					row_inc_value =						1 + (MAX_PIXELS_PER_LINE - pixwidth +								(pixwidth -								 cropwidth - cleft) + cleft) * ps;			} 			else {				row_inc_value = 1 + (pix->width * ps) - cropwidth * ps;			}			pixel_inc_value = 1;			break;		case 1:		/* Mirroring */			if (rotation_deg == 90 || rotation_deg == 270) {				row_inc_value = (-(MAX_PIXELS_PER_LINE + cropwidth) * ps) + 1;				pixel_inc_value = 1;			} else if (rotation_deg == 180 || rotation_deg == 0) {				row_inc_value = (-(MAX_PIXELS_PER_LINE + (cropwidth / vr_ps))						* ps) + 1;				pixel_inc_value = 1;			} else {				row_inc_value =					2 * ((cropwidth / vr_ps) -							1) * ps + 1 +					((pix->width * ps) / vr_ps) -					(cropwidth / vr_ps) * ps;				pixel_inc_value = (-2 * ps) + 1;			}			break;	}			/* Mirroring Switch */	/*	 * For LCD row inc and pixel inc	 */	layer[ltype].dma[0].row_inc = row_inc_value;	layer[ltype].dma[0].pix_inc = pixel_inc_value;	if (omap2_disp_get_output_dev(ltype) == OMAP2_OUTPUT_LCD || flicker_filter == 1) {		dispc_reg_out(DISPC_VID_ROW_INC(v), row_inc_value);		dispc_reg_out(DISPC_VID_PIXEL_INC(v), pixel_inc_value);	}	/*	 * For TV the row increment should be done twice as the 	 * TV operates in interlaced mode	 */	else {		if (rotation_deg >= 0){

⌨️ 快捷键说明

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