mxcfb late_init

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

mxcfb late_init

869 Views
lyashmik
Contributor II

I was looking into how could I make linux not to redraw the framebuffer right after it takes over from u-boot, because I need the image to stay until psplash is started. I've found out through looking into the linux's source code (mxc_ipuv3_fb.c), that late_init could help, so I've found it in the device tree and set to 1:

	mxcfb1: fb@0 {
		compatible = "fsl,mxc_sdc_fb";
		disp_dev = "ldb";
		interface_pix_fmt = "RGB666";
		default_bpp = <16>;
		int_clk = <0>;
		late_init = <1>;
		status = "okay";
	};
And it indeed helped, the image stayed, when the linux started, but now the new problem arose, which is that psplash was not working anymore, further more it seemed that the framebuffer was locked, because I could not output anything on the screen.

So my question is, what is the right sequence of steps here to give control of framebuffer back to linux?
Tags (4)
0 Kudos
Reply
2 Replies

860 Views
Bio_TICFSL
NXP TechSupport
NXP TechSupport

Hello,

I don't see anything wrong with the device tree, but frame buffer need to IPU driver before is up maybe that's the case.

Regards

0 Kudos
Reply

857 Views
lyashmik
Contributor II

@Bio_TICFSL do you mean, that when late_init is enabled, ipu is not getting the framebuffer address from u-boot? In either case IPU should be running and when late_init is set to 0, the display blinks and after a while psplash image is seen.
In mxc_ipuv3_fb.c I've identified, that the crusial piece of code involving late_init is mxcfb_register function:

if (!mxcfbi->late_init) {
		fbi->var.activate |= FB_ACTIVATE_FORCE;
		console_lock();
		ret = fb_set_var(fbi, &fbi->var);
		if (!ret)
			fbcon_update_vcs(fbi, fbi->var.activate & FB_ACTIVATE_ALL);
		console_unlock();
		if (ret < 0) {
			dev_err(fbi->device, "Error fb_set_var ret:%d\n", ret);
			goto err3;
		}

		if (mxcfbi->next_blank == FB_BLANK_UNBLANK) {
			console_lock();
			ret = fb_blank(fbi, FB_BLANK_UNBLANK);
			console_unlock();
			if (ret < 0) {
				dev_err(fbi->device,
					"Error fb_blank ret:%d\n", ret);
				goto err4;
			}
		}
	} else {
		/*
		 * Setup the channel again though bootloader
		 * has done this, then set_par() can stop the
		 * channel neatly and re-initialize it .
		 */
		if (mxcfbi->next_blank == FB_BLANK_UNBLANK) {
			console_lock();
			_setup_disp_channel1(fbi);
			ipu_enable_channel(mxcfbi->ipu, mxcfbi->ipu_ch);
			console_unlock();
		}
	}

So I've create a function in mxc_ipuv3_fb.c base on that if part of the statement, which is not getting called when late_init is 1:

int mxcfb_reinit(struct fb_info *fbi)
{
	struct mxcfb_info *mxcfbi = (struct mxcfb_info *)fbi->par;
	int ret = 0;
	
	if (!fbi || !mxcfbi)
		return -EINVAL;

	fbi->var.activate |= FB_ACTIVATE_FORCE;

	// console_lock();
	ret = fb_set_var(fbi, &fbi->var);
	if (!ret)
		fbcon_update_vcs(fbi, fbi->var.activate & FB_ACTIVATE_ALL);
	// console_unlock();

	if (ret < 0)
		return ret;

	// console_lock();
	ret = fb_blank(fbi, FB_BLANK_UNBLANK);
	//console_unlock();

	return 0;
}
EXPORT_SYMBOL(mxcfb_reinit);

And I've added it to mxcfb_ioctl, so I could call it from user space, but the problem is that I get a lot of warnings about deadlock, when the function is called and sometimes the deadlock really happens, which is of consern, but at least the display is refreshed and if I call psplash explicitly, then display is updated with the psplash image, but the progress bar is not working, but it could be another problem. This could be a solution, but I would really appreceate a more cleaner one.

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2138399%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3Emxcfb%20late_init%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2138399%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EI%20was%20looking%20into%20how%20could%20I%20make%20linux%20not%20to%20redraw%20the%20framebuffer%20right%20after%20it%20takes%20over%20from%20u-boot%2C%20because%20I%20need%20the%20image%20to%20stay%20until%20psplash%20is%20started.%20I've%20found%20out%20through%20looking%20into%20the%20linux's%20source%20code%20(mxc_ipuv3_fb.c)%2C%20that%20%3CSTRONG%3Elate_init%3C%2FSTRONG%3E%20could%20help%2C%20so%20I've%20found%20it%20in%20the%20device%20tree%20and%20set%20to%201%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%09mxcfb1%3A%20fb%400%20%7B%0A%09%09compatible%20%3D%20%22fsl%2Cmxc_sdc_fb%22%3B%0A%09%09disp_dev%20%3D%20%22ldb%22%3B%0A%09%09interface_pix_fmt%20%3D%20%22RGB666%22%3B%0A%09%09default_bpp%20%3D%20%26lt%3B16%26gt%3B%3B%0A%09%09int_clk%20%3D%20%26lt%3B0%26gt%3B%3B%0A%09%09late_init%20%3D%20%26lt%3B1%26gt%3B%3B%0A%09%09status%20%3D%20%22okay%22%3B%0A%09%7D%3B%3C%2FCODE%3E%3C%2FPRE%3E%3CDIV%3EAnd%20it%20indeed%20helped%2C%20the%20image%20stayed%2C%20when%20the%20linux%20started%2C%20but%20now%20the%20new%20problem%20arose%2C%20which%20is%20that%20psplash%20was%20not%20working%20anymore%2C%20further%20more%20it%20seemed%20that%20the%20framebuffer%20was%20locked%2C%20because%20I%20could%20not%20output%20anything%20on%20the%20screen.%3CBR%20%2F%3E%3CBR%20%2F%3ESo%20my%20question%20is%2C%20what%20is%20the%20right%20sequence%20of%20steps%20here%20to%20give%20control%20of%20framebuffer%20back%20to%20linux%3F%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2138617%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20mxcfb%20late_init%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2138617%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F34846%22%20target%3D%22_blank%22%3E%40Bio_TICFSL%3C%2FA%3E%26nbsp%3Bdo%20you%20mean%2C%20that%20when%20late_init%20is%20enabled%2C%20ipu%20is%20not%20getting%20the%20framebuffer%20address%20from%20u-boot%3F%20In%20either%20case%20IPU%20should%20be%20running%20and%20when%20late_init%20is%20set%20to%200%2C%20the%20display%20blinks%20and%20after%20a%20while%20psplash%20image%20is%20seen.%3CBR%20%2F%3EIn%20%3CSTRONG%3Emxc_ipuv3_fb.c%3C%2FSTRONG%3E%20I've%20identified%2C%20that%20the%20crusial%20piece%20of%20code%20involving%20%3CSTRONG%3Elate_init%26nbsp%3B%3C%2FSTRONG%3Eis%20mxcfb_register%20function%3A%3CBR%20%2F%3E%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3Eif%20(!mxcfbi-%26gt%3Blate_init)%20%7B%0A%09%09fbi-%26gt%3Bvar.activate%20%7C%3D%20FB_ACTIVATE_FORCE%3B%0A%09%09console_lock()%3B%0A%09%09ret%20%3D%20fb_set_var(fbi%2C%20%26amp%3Bfbi-%26gt%3Bvar)%3B%0A%09%09if%20(!ret)%0A%09%09%09fbcon_update_vcs(fbi%2C%20fbi-%26gt%3Bvar.activate%20%26amp%3B%20FB_ACTIVATE_ALL)%3B%0A%09%09console_unlock()%3B%0A%09%09if%20(ret%20%26lt%3B%200)%20%7B%0A%09%09%09dev_err(fbi-%26gt%3Bdevice%2C%20%22Error%20fb_set_var%20ret%3A%25d%5Cn%22%2C%20ret)%3B%0A%09%09%09goto%20err3%3B%0A%09%09%7D%0A%0A%09%09if%20(mxcfbi-%26gt%3Bnext_blank%20%3D%3D%20FB_BLANK_UNBLANK)%20%7B%0A%09%09%09console_lock()%3B%0A%09%09%09ret%20%3D%20fb_blank(fbi%2C%20FB_BLANK_UNBLANK)%3B%0A%09%09%09console_unlock()%3B%0A%09%09%09if%20(ret%20%26lt%3B%200)%20%7B%0A%09%09%09%09dev_err(fbi-%26gt%3Bdevice%2C%0A%09%09%09%09%09%22Error%20fb_blank%20ret%3A%25d%5Cn%22%2C%20ret)%3B%0A%09%09%09%09goto%20err4%3B%0A%09%09%09%7D%0A%09%09%7D%0A%09%7D%20else%20%7B%0A%09%09%2F*%0A%09%09%20*%20Setup%20the%20channel%20again%20though%20bootloader%0A%09%09%20*%20has%20done%20this%2C%20then%20set_par()%20can%20stop%20the%0A%09%09%20*%20channel%20neatly%20and%20re-initialize%20it%20.%0A%09%09%20*%2F%0A%09%09if%20(mxcfbi-%26gt%3Bnext_blank%20%3D%3D%20FB_BLANK_UNBLANK)%20%7B%0A%09%09%09console_lock()%3B%0A%09%09%09_setup_disp_channel1(fbi)%3B%0A%09%09%09ipu_enable_channel(mxcfbi-%26gt%3Bipu%2C%20mxcfbi-%26gt%3Bipu_ch)%3B%0A%09%09%09console_unlock()%3B%0A%09%09%7D%0A%09%7D%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3ESo%20I've%20create%20a%20function%20in%20%3CSTRONG%3Emxc_ipuv3_fb.c%26nbsp%3B%3C%2FSTRONG%3Ebase%20on%20that%20if%20part%20of%20the%20statement%2C%20which%20is%20not%20getting%20called%20when%20late_init%20is%201%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3Eint%20mxcfb_reinit(struct%20fb_info%20*fbi)%0A%7B%0A%09struct%20mxcfb_info%20*mxcfbi%20%3D%20(struct%20mxcfb_info%20*)fbi-%26gt%3Bpar%3B%0A%09int%20ret%20%3D%200%3B%0A%09%0A%09if%20(!fbi%20%7C%7C%20!mxcfbi)%0A%09%09return%20-EINVAL%3B%0A%0A%09fbi-%26gt%3Bvar.activate%20%7C%3D%20FB_ACTIVATE_FORCE%3B%0A%0A%09%2F%2F%20console_lock()%3B%0A%09ret%20%3D%20fb_set_var(fbi%2C%20%26amp%3Bfbi-%26gt%3Bvar)%3B%0A%09if%20(!ret)%0A%09%09fbcon_update_vcs(fbi%2C%20fbi-%26gt%3Bvar.activate%20%26amp%3B%20FB_ACTIVATE_ALL)%3B%0A%09%2F%2F%20console_unlock()%3B%0A%0A%09if%20(ret%20%26lt%3B%200)%0A%09%09return%20ret%3B%0A%0A%09%2F%2F%20console_lock()%3B%0A%09ret%20%3D%20fb_blank(fbi%2C%20FB_BLANK_UNBLANK)%3B%0A%09%2F%2Fconsole_unlock()%3B%0A%0A%09return%200%3B%0A%7D%0AEXPORT_SYMBOL(mxcfb_reinit)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3EAnd%20I've%20added%20it%20to%20mxcfb_ioctl%2C%20so%20I%20could%20call%20it%20from%20user%20space%2C%20but%20the%20problem%20is%20that%20I%20get%20a%20lot%20of%20warnings%20about%20deadlock%2C%20when%20the%20function%20is%20called%20and%20sometimes%20the%20deadlock%20really%20happens%2C%20which%20is%20of%20consern%2C%20but%20at%20least%20the%20display%20is%20refreshed%20and%20if%20I%20call%20psplash%20explicitly%2C%20then%20display%20is%20updated%20with%20the%20psplash%20image%2C%20but%20the%20progress%20bar%20is%20not%20working%2C%20but%20it%20could%20be%20another%20problem.%20This%20could%20be%20a%20solution%2C%20but%20I%20would%20really%20appreceate%20a%20more%20cleaner%20one.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2138485%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20mxcfb%20late_init%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2138485%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%2C%3C%2FP%3E%0A%3CP%3EI%20don't%20see%20anything%20wrong%20with%20the%20device%20tree%2C%20but%20frame%20buffer%20need%20to%20IPU%20driver%20before%20is%20up%20maybe%20that's%20the%20case.%3C%2FP%3E%0A%3CP%3ERegards%3C%2FP%3E%3C%2FLINGO-BODY%3E