Detailed explanation of LCD driver (2)

Keywords: Linux

LCD driver source address of S2C2440 development board: linux-2.6.22.6/drivers/video/s3c2410fb.c

The first thing to look at the driver source is, of course, the entry function. Here is the s3c2410fb_init function.

int __devinit s3c2410fb_init(void)
{
    //Register a Platform Driver Architecture s3c2410fb_driver
	return platform_driver_register(&s3c2410fb_driver); 
}

The exit function is naturally driven by canceling s3c2410fb_driver platform.

static void __exit s3c2410fb_cleanup(void)
{
    //Cancel platform driver s3c2410fb_driver structure
	platform_driver_unregister(&s3c2410fb_driver);
}

We study s3c2440. We only care about s3c2410fb_driver, but s3c2412fb_driver doesn't care.

static struct platform_driver s3c2410fb_driver = {
	.probe		= s3c2410fb_probe,
	.remove		= s3c2410fb_remove,
	.suspend	= s3c2410fb_suspend,
	.resume		= s3c2410fb_resume,
	.driver		= {
		.name	= "s3c2410-lcd",
		.owner	= THIS_MODULE,
	},
};

Here you see that the name field of s3c2410fb_driver is s3c2410-lcd. Looking back at the previous chapters, if a platform device with the same name exists in a linux system, the platform-driven probe function is invoked. Here, if there is a platform device with the same name "s3c2410-lcd", the s3c2410fb_probe function of s3c2410fb_driver will be called.

Searching s3c2410-lcd in source insight will soon find a section in linux-2.6.22.6/arch/arm/plat-s3c24xx\devs.c:

struct platform_device s3c_device_lcd = {
	.name		  = "s3c2410-lcd",
	.id		  = -1,
	.num_resources	  = ARRAY_SIZE(s3c_lcd_resource),
	.resource	  = s3c_lcd_resource,
	.dev              = {
		.dma_mask		= &s3c_device_lcd_dmamask,
		.coherent_dma_mask	= 0xffffffffUL
	}
};

Among them, the most important member of platform equipment is resource, which is s3c_lcd_resource.

/* LCD Controller */
static struct resource s3c_lcd_resource[] = {
	[0] = {
		.start = S3C24XX_PA_LCD,
		.end   = S3C24XX_PA_LCD + S3C24XX_SZ_LCD - 1,
		.flags = IORESOURCE_MEM,
	},
	[1] = {
		.start = IRQ_LCD,
		.end   = IRQ_LCD,
		.flags = IORESOURCE_IRQ,
	}

};

Then, of course, the next step is to analyze the probe function.

static int __init s3c2410fb_probe(struct platform_device *pdev)  
{  
    return s3c24xxfb_probe(pdev, DRV_S3C2410);  
}  

The s3c2410fb_probe function calls the s3c24xfb_probe function, which is one of the key functions of the lcd driver. It is reserved for "linux lcd device driver analysis III" to be analyzed again. But before analyzing this function, we need to familiarize ourselves with several structures.

Linux There is a key word in the lcd driver called frame buffer, which is linux In order to provide an interface for display devices, it allows applications to read and write directly to the display buffer in graphical mode. Users do not need to care about the specific location and storage mode of the physical display buffer, which is accomplished by the frame buffer device driver itself.

Frame buffer device is a standard character device, the main device number is 29, corresponding to / dev/fbn device files, frame buffer device is the most critical one. data structure It is a fb_info structure, which includes a complete description of the attributes and operations of frame buffer devices.

The source address of frame buffer device driver: linux-2.6.22.6/drivers/video/fbmem.c;

struct fb_info {
	int node;    //Used as index of secondary device number
	int flags;
    struct mutex lock;              //Locks for open/release/ioctl functions  
	struct fb_var_screeninfo var;	//Variable parameters, emphasis  
	struct fb_fix_screeninfo fix;	//Fixed parameters, emphasis 
	struct fb_monspecs monspecs;	//Display Standard  
	struct work_struct queue;	    //Frame Buffer Queue
	struct fb_pixmap pixmap;	    //Image Hardware Mapping  
	struct fb_pixmap sprite;	    //Cursor Hardware Mapping  
	struct fb_cmap cmap;		    //Current color table 
	struct list_head modelist;      //Schema Link List
	struct fb_videomode *mode;	    //Current video mode

#ifdef CONFIG_FB_BACKLIGHT
	/* assigned backlight device */
	/* set before framebuffer registration, 
	   remove after unregister */
	struct backlight_device *bl_dev;

	/* Backlight level curve */
	struct mutex bl_curve_mutex;	
	u8 bl_curve[FB_BACKLIGHT_LEVELS];
#endif
#ifdef CONFIG_FB_DEFERRED_IO
	struct delayed_work deferred_work;
	struct fb_deferred_io *fbdefio;
#endif

	struct fb_ops *fbops;
	struct device *device;		/* This is the parent */
	struct device *dev;		/* This is this fb device */
	int class_flag;                    /* private sysfs flags */
#ifdef CONFIG_FB_TILEBLITTING
	struct fb_tile_ops *tileops;    /* Tile Blitting */
#endif
	char __iomem *screen_base;	 //Display Base Address
	unsigned long screen_size;	 //memory size
	void *pseudo_palette;		 //Pseudo-16 Colour Table 
#define FBINFO_STATE_RUNNING	0
#define FBINFO_STATE_SUSPENDED	1
	u32 state;			         //Hardware status, such as suspension 
	void *fbcon_par;             //Used as a private data area
	/* From here on everything is device dependent */
	void *par;	                 //Info - > par points to the first address where additional memory space is requested  
};


 

 

 

 

 

 

 

 

 

 

 

 

 

 

This paper refers to: http://blog.csdn.net/lwj103862095/article/details/18188259

Posted by guymclaren on Wed, 19 Jun 2019 12:10:39 -0700