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

📄 skeletonfb.c

📁 《linux驱动程序设计从入门到精通》一书中所有的程序代码含驱动和相应的应用程序
💻 C
📖 第 1 页 / 共 2 页
字号:
 *      xxxfb_pan_display - NOT a required function. Pans the display. *      @var: frame buffer variable screen structure *      @info: frame buffer structure that represents a single frame buffer * *	Pan (or wrap, depending on the `vmode' field) the display using the *  	`xoffset' and `yoffset' fields of the `var' structure. *  	If the values don't fit, return -EINVAL. * *      Returns negative errno on error, or zero on success. */static int xxxfb_pan_display(struct fb_var_screeninfo *var,			     const struct fb_info *info){    /* ... */    return 0;}/** *      xxxfb_blank - NOT a required function. Blanks the display. *      @blank_mode: the blank mode we want.  *      @info: frame buffer structure that represents a single frame buffer * *      Blank the screen if blank_mode != 0, else unblank. Return 0 if *      blanking succeeded, != 0 if un-/blanking failed due to e.g. a  *      video mode which doesn't support it. Implements VESA suspend *      and powerdown modes on hardware that supports disabling hsync/vsync: *      blank_mode == 2: suspend vsync *      blank_mode == 3: suspend hsync *      blank_mode == 4: powerdown * *      Returns negative errno on error, or zero on success. * */static int xxxfb_blank(int blank_mode, const struct fb_info *info){    /* ... */    return 0;}/* ------------ Accelerated Functions --------------------- *//* * We provide our own functions if we have hardware acceleration * or non packed pixel format layouts. If we have no hardware  * acceleration, we can use a generic unaccelerated function. If using * a pack pixel format just use the functions in cfb_*.c. Each file  * has one of the three different accel functions we support. *//** *      xxxfb_fillrect - REQUIRED function. Can use generic routines if  *		 	 non acclerated hardware and packed pixel based. *			 Draws a rectangle on the screen.		 * *      @info: frame buffer structure that represents a single frame buffer *	@region: The structure representing the rectangular region we  *		 wish to draw to. * *	This drawing operation places/removes a retangle on the screen  *	depending on the rastering operation with the value of color which *	is in the current color depth format. */void xxfb_fillrect(struct fb_info *p, const struct fb_fillrect *region){/*	Meaning of struct fb_fillrect * *	@dx: The x and y corrdinates of the upper left hand corner of the  *	@dy: area we want to draw to.  *	@width: How wide the rectangle is we want to draw. *	@height: How tall the rectangle is we want to draw. *	@color:	The color to fill in the rectangle with.  *	@rop: The raster operation. We can draw the rectangle with a COPY *	      of XOR which provides erasing effect.  */}/** *      xxxfb_copyarea - REQUIRED function. Can use generic routines if *                       non acclerated hardware and packed pixel based. *                       Copies one area of the screen to another area. * *      @info: frame buffer structure that represents a single frame buffer *      @area: Structure providing the data to copy the framebuffer contents *	       from one region to another. * *      This drawing operation copies a rectangular area from one area of the *	screen to another area. */void xxxfb_copyarea(struct fb_info *p, const struct fb_copyarea *area) {/* *      @dx: The x and y coordinates of the upper left hand corner of the *	@dy: destination area on the screen. *      @width: How wide the rectangle is we want to copy. *      @height: How tall the rectangle is we want to copy. *      @sx: The x and y coordinates of the upper left hand corner of the *      @sy: source area on the screen. */}/** *      xxxfb_imageblit - REQUIRED function. Can use generic routines if *                        non acclerated hardware and packed pixel based. *                        Copies a image from system memory to the screen.  * *      @info: frame buffer structure that represents a single frame buffer *	@image:	structure defining the image. * *      This drawing operation draws a image on the screen. It can be a  *	mono image (needed for font handling) or a color image (needed for *	tux).  */void xxxfb_imageblit(struct fb_info *p, const struct fb_image *image) {/* *      @dx: The x and y coordinates of the upper left hand corner of the *	@dy: destination area to place the image on the screen. *      @width: How wide the image is we want to copy. *      @height: How tall the image is we want to copy. *      @fg_color: For mono bitmap images this is color data for      *      @bg_color: the foreground and background of the image to *		   write directly to the frmaebuffer. *	@depth:	How many bits represent a single pixel for this image. *	@data: The actual data used to construct the image on the display. *	@cmap: The colormap used for color images.    */}/** *	xxxfb_cursor - 	REQUIRED function. If your hardware lacks support *			for a cursor you can use the default cursor whose *			function is called soft_cursor. It will always  *			work since it uses xxxfb_imageblit function which  *			is required. 	  	  * *      @info: frame buffer structure that represents a single frame buffer *	@cursor: structure defining the cursor to draw. * *      This operation is used to set or alter the properities of the *	cursor. * *	Returns negative errno on error, or zero on success. */int xxxfb_cursor(struct fb_info *info, struct fb_cursor *cursor){/* *      @set: 	Which fields we are altering in struct fb_cursor  *	@enable: Disable or enable the cursor  *      @rop: 	The bit operation we want to do.  *      @mask:  This is the cursor mask bitmap.  *      @dest:  A image of the area we are going to display the cursor. *		Used internally by the driver.	  *      @hot:	The hot spot.  *	@image:	The actual data for the cursor image. */}/** *	xxxfb_rotate -  NOT a required function. If your hardware *			supports rotation the whole screen then  *			you would provide a hook for this.  * *      @info: frame buffer structure that represents a single frame buffer *	@angle: The angle we rotate the screen.    * *      This operation is used to set or alter the properities of the *	cursor. */void xxxfb_rotate(struct fb_info *info, int angle){}/** *	xxxfb_poll - NOT a required function. The purpose of this *		     function is to provide a way for some process *		     to wait until a specific hardware event occurs *		     for the framebuffer device. * 				  *      @info: frame buffer structure that represents a single frame buffer *	@wait: poll table where we store process that await a event.      */void xxxfb_poll(struct fb_info *info, poll_table *wait){}/** *	xxxfb_sync - NOT a required function. Normally the accel engine  *		     for a graphics card take a specific amount of time. *		     Often we have to wait for the accelerator to finish *		     its operation before we can write to the framebuffer *		     so we can have consistent display output.  * *      @info: frame buffer structure that represents a single frame buffer */void xxxfb_sync(struct fb_info *info){}    /*     *  Initialization     */int __init xxxfb_init(void){    int cmap_len, retval;	       /*      * Here we set the screen_base to the vitrual memory address     * for the framebuffer. Usually we obtain the resource address     * from the bus layer and then translate it to virtual memory     * space via ioremap. Consult ioport.h.      */    info.screen_base = framebuffer_virtual_memory;	    info.fbops = &xxxfb_ops;    info.fix = xxxfb_fix;    info.pseudo_palette = pseudo_palette;    /*     * Set up flags to indicate what sort of acceleration your     * driver can provide (pan/wrap/copyarea/etc.) and whether it     * is a module -- see FBINFO_* in include/linux/fb.h     */    info.flags = FBINFO_DEFAULT;    info.par = current_par;    /*     * This should give a reasonable default video mode. The following is     * done when we can set a video mode.      */    if (!mode_option)	mode_option = "640x480@60";	 	    retval = fb_find_mode(&info.var, &info, mode_option, NULL, 0, NULL, 8);      if (!retval || retval == 4)	return -EINVAL;			    /* This has to been done !!! */	    fb_alloc_cmap(&info.cmap, cmap_len, 0);	    /*      * The following is done in the case of having hardware with a static      * mode. If we are setting the mode ourselves we don't call this.      */	    info.var = xxxfb_var;	    if (register_framebuffer(&info) < 0)	return -EINVAL;    printk(KERN_INFO "fb%d: %s frame buffer device\n", info.node,	   info.fix.id);    return 0;}    /*     *  Cleanup     */static void __exit xxxfb_cleanup(void){    /*     *  If your driver supports multiple boards, you should unregister and     *  clean up all instances.     */    unregister_framebuffer(info);    /* ... */}    /*     *  Setup     *//*  * Only necessary if your driver takes special options, * otherwise we fall back on the generic fb_setup(). */int __init xxxfb_setup(char *options){    /* Parse user speficied options (`video=xxxfb:') */}/* ------------------------------------------------------------------------- */    /*     *  Frame buffer operations     */static struct fb_ops xxxfb_ops = {	.owner		= THIS_MODULE,	.fb_open	= xxxfb_open,	.fb_read	= xxxfb_read,	.fb_write	= xxxfb_write,	.fb_release	= xxxfb_release,	.fb_check_var	= xxxfb_check_var,	.fb_set_par	= xxxfb_set_par,		.fb_setcolreg	= xxxfb_setcolreg,	.fb_blank	= xxxfb_blank,	.fb_pan_display	= xxxfb_pan_display,		.fb_fillrect	= xxxfb_fillrect, 	/* Needed !!! */ 	.fb_copyarea	= xxxfb_copyarea,	/* Needed !!! */ 	.fb_imageblit	= xxxfb_imageblit,	/* Needed !!! */	.fb_cursor	= xxxfb_cursor,		/* Needed !!! */	.fb_rotate	= xxxfb_rotate,	.fb_poll	= xxxfb_poll,	.fb_sync	= xxxfb_sync,	.fb_ioctl	= xxxfb_ioctl,	.fb_mmap	= xxxfb_mmap,	};/* ------------------------------------------------------------------------- */    /*     *  Modularization     */#ifdef MODULEmodule_init(xxxfb_init);#endif module_exit(xxxfb_cleanup);MODULE_LICENSE("GPL");

⌨️ 快捷键说明

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