<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: iMX7 framebuffer ioctl fails in i.MX Processors</title>
    <link>https://community.nxp.com/t5/i-MX-Processors/iMX7-framebuffer-ioctl-fails/m-p/1399298#M185812</link>
    <description>&lt;P&gt;The ioctl in fb driver:&lt;/P&gt;
&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;/drivers/video/fbdev/core/fbmem.c&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;case FBIOPAN_DISPLAY:
		if (copy_from_user(&amp;amp;var, argp, sizeof(var)))
			return -EFAULT;
		console_lock();
		lock_fb_info(info);
		ret = fb_pan_display(info, &amp;amp;var);
		unlock_fb_info(info);
		console_unlock();
		if (ret == 0 &amp;amp;&amp;amp; copy_to_user(argp, &amp;amp;var, sizeof(var)))
			return -EFAULT;
		break;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;drivers/video/fbdev/mxsfb.c(imx7 fd driver)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;static int mxsfb_ioctl(struct fb_info *fb_info, unsigned int cmd,
			unsigned long arg)
{
	int ret = -EINVAL;

	switch (cmd) {
	case MXCFB_WAIT_FOR_VSYNC:
		ret = mxsfb_wait_for_vsync(fb_info);
		break;
	default:
		break;
	}
	return ret;
}&lt;/LI-CODE&gt;
&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need to debug these two drivers to see it's call process.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 14 Jan 2022 06:23:21 GMT</pubDate>
    <dc:creator>Zhiming_Liu</dc:creator>
    <dc:date>2022-01-14T06:23:21Z</dc:date>
    <item>
      <title>iMX7 framebuffer ioctl fails</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/iMX7-framebuffer-ioctl-fails/m-p/1398784#M185754</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I came accross strange behavior of psplash, that it draws only every second frame on the display. I have found out that it fails to wait to vsync and pan the buffers.&lt;/P&gt;&lt;P&gt;From the psplash debug messages I am getting:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Error, FB vsync ioctl [-1]
psplash_fb_flip: FBIOPAN_DISPLAY failed&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the code handling the FB, these parts are&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt; int err = ioctl(fb-&amp;gt;fd, FBIO_WAITFORVSYNC, 0);
  if (err != 0)
    fprintf(stderr, "Error, FB vsync ioctl [%d]\n", err);

...

    if (ioctl(fb-&amp;gt;fd, FBIOPAN_DISPLAY, &amp;amp;fb-&amp;gt;fb_var) == -1 ) {
      fprintf(stderr, "psplash_fb_flip: FBIOPAN_DISPLAY failed\n");
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So it means both are failing with error -1. I added some more debug code to the source code to get the exact error and these are:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Error, FB vsync ioctl [-1]: Inappropriate ioctl for device
psplash_fb_flip: FBIOPAN_DISPLAY failed: Invalid argument&lt;/LI-CODE&gt;&lt;P&gt;When the fb is created in psplash, the double buffering would be disabled by&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt; /* Setup double virtual resolution for double buffering */
  if (ioctl(fb-&amp;gt;fd, FBIOPAN_DISPLAY, &amp;amp;fb_var) == -1) {
    fprintf(stderr, "FBIOPAN_DISPLAY not supported, double buffering disabled");&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But it is not disabled, so this means the ioctl must have passed once before. By adding more verbose debug messages into the code, I see it really passes. I don't know why now and not afterwards.&lt;/P&gt;&lt;P&gt;And that is where I end, because I have no experience with framebuffers.&lt;/P&gt;&lt;P&gt;So I would like to ask for help. Is there some settings needed in DTS to enable double buffering? Disabling it completely would also be fine for me. But I don't know how.&lt;/P&gt;&lt;P&gt;Any hints will be appreciated.&lt;/P&gt;&lt;P&gt;Thanks, Michal&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jan 2022 13:35:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/iMX7-framebuffer-ioctl-fails/m-p/1398784#M185754</guid>
      <dc:creator>michalhorn</dc:creator>
      <dc:date>2022-01-13T13:35:07Z</dc:date>
    </item>
    <item>
      <title>Re: iMX7 framebuffer ioctl fails</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/iMX7-framebuffer-ioctl-fails/m-p/1399298#M185812</link>
      <description>&lt;P&gt;The ioctl in fb driver:&lt;/P&gt;
&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;/drivers/video/fbdev/core/fbmem.c&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;case FBIOPAN_DISPLAY:
		if (copy_from_user(&amp;amp;var, argp, sizeof(var)))
			return -EFAULT;
		console_lock();
		lock_fb_info(info);
		ret = fb_pan_display(info, &amp;amp;var);
		unlock_fb_info(info);
		console_unlock();
		if (ret == 0 &amp;amp;&amp;amp; copy_to_user(argp, &amp;amp;var, sizeof(var)))
			return -EFAULT;
		break;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;drivers/video/fbdev/mxsfb.c(imx7 fd driver)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;static int mxsfb_ioctl(struct fb_info *fb_info, unsigned int cmd,
			unsigned long arg)
{
	int ret = -EINVAL;

	switch (cmd) {
	case MXCFB_WAIT_FOR_VSYNC:
		ret = mxsfb_wait_for_vsync(fb_info);
		break;
	default:
		break;
	}
	return ret;
}&lt;/LI-CODE&gt;
&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need to debug these two drivers to see it's call process.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jan 2022 06:23:21 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/iMX7-framebuffer-ioctl-fails/m-p/1399298#M185812</guid>
      <dc:creator>Zhiming_Liu</dc:creator>
      <dc:date>2022-01-14T06:23:21Z</dc:date>
    </item>
    <item>
      <title>Re: iMX7 framebuffer ioctl fails</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/iMX7-framebuffer-ioctl-fails/m-p/1400287#M185904</link>
      <description>&lt;P&gt;Thanks for the pointer.&lt;/P&gt;&lt;P&gt;I have found the issue. The problem of getting the error&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;psplash_fb_flip: FBIOPAN_DISPLAY failed: Invalid argument&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;is caused by a check on&amp;nbsp;&lt;A href="https://elixir.bootlin.com/linux/v4.9.275/source/drivers/video/fbdev/core/fbmem.c#L891" target="_self"&gt;fb_pan_display&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;if&lt;/SPAN&gt; &lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;err&lt;/SPAN&gt; &lt;SPAN class=""&gt;||&lt;/SPAN&gt; &lt;SPAN class=""&gt;!&lt;/SPAN&gt;&lt;SPAN class=""&gt;info&lt;/SPAN&gt;&lt;SPAN class=""&gt;-&amp;gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;A href="https://elixir.bootlin.com/linux/v4.9.275/C/ident/fbops" target="_blank" rel="noopener"&gt;fbops&lt;/A&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;-&amp;gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;A href="https://elixir.bootlin.com/linux/v4.9.275/C/ident/fb_pan_display" target="_blank" rel="noopener"&gt;fb_pan_display&lt;/A&gt;&lt;/SPAN&gt; &lt;SPAN class=""&gt;||&lt;/SPAN&gt;
	    &lt;SPAN class=""&gt;&lt;A href="https://elixir.bootlin.com/linux/v4.9.275/C/ident/var" target="_blank" rel="noopener"&gt;var&lt;/A&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;-&amp;gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;A href="https://elixir.bootlin.com/linux/v4.9.275/C/ident/yoffset" target="_blank" rel="noopener"&gt;yoffset&lt;/A&gt;&lt;/SPAN&gt; &lt;SPAN class=""&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class=""&gt;info&lt;/SPAN&gt;&lt;SPAN class=""&gt;-&amp;gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;A href="https://elixir.bootlin.com/linux/v4.9.275/C/ident/var" target="_blank" rel="noopener"&gt;var&lt;/A&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;A href="https://elixir.bootlin.com/linux/v4.9.275/C/ident/yres_virtual" target="_blank" rel="noopener"&gt;yres_virtual&lt;/A&gt;&lt;/SPAN&gt; &lt;SPAN class=""&gt;-&lt;/SPAN&gt; &lt;SPAN class=""&gt;&lt;A href="https://elixir.bootlin.com/linux/v4.9.275/C/ident/yres" target="_blank" rel="noopener"&gt;yres&lt;/A&gt;&lt;/SPAN&gt; &lt;SPAN class=""&gt;||&lt;/SPAN&gt;
	    &lt;SPAN class=""&gt;&lt;A href="https://elixir.bootlin.com/linux/v4.9.275/C/ident/var" target="_blank" rel="noopener"&gt;var&lt;/A&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;-&amp;gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;A href="https://elixir.bootlin.com/linux/v4.9.275/C/ident/xoffset" target="_blank" rel="noopener"&gt;xoffset&lt;/A&gt;&lt;/SPAN&gt; &lt;SPAN class=""&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class=""&gt;info&lt;/SPAN&gt;&lt;SPAN class=""&gt;-&amp;gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;A href="https://elixir.bootlin.com/linux/v4.9.275/C/ident/var" target="_blank" rel="noopener"&gt;var&lt;/A&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;A href="https://elixir.bootlin.com/linux/v4.9.275/C/ident/xres_virtual" target="_blank" rel="noopener"&gt;xres_virtual&lt;/A&gt;&lt;/SPAN&gt; &lt;SPAN class=""&gt;-&lt;/SPAN&gt; &lt;SPAN class=""&gt;info&lt;/SPAN&gt;&lt;SPAN class=""&gt;-&amp;gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;A href="https://elixir.bootlin.com/linux/v4.9.275/C/ident/var" target="_blank" rel="noopener"&gt;var&lt;/A&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;A href="https://elixir.bootlin.com/linux/v4.9.275/C/ident/xres" target="_blank" rel="noopener"&gt;xres&lt;/A&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;)&lt;/SPAN&gt;
		&lt;SPAN class=""&gt;return&lt;/SPAN&gt; &lt;SPAN class=""&gt;-&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;A href="https://elixir.bootlin.com/linux/v4.9.275/C/ident/EINVAL" target="_blank" rel="noopener"&gt;EINVAL&lt;/A&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;where yres_virtual == yres, so the offset would overrun the buffer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The psplash, when creating the FB, tries to detect the yres_virtual==yres and if so, tries to set it to 2*yres by&amp;nbsp;FBIOPUT_VSCREENINFO ioctl. But his is handled in the mxsfb driver in such way that it resets the yres_virtual back to yres:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;static&lt;/SPAN&gt; &lt;SPAN class=""&gt;int&lt;/SPAN&gt; &lt;SPAN class=""&gt;&lt;A href="https://elixir.bootlin.com/linux/v4.9.275/C/ident/mxsfb_check_var" target="_blank" rel="noopener"&gt;mxsfb_check_var&lt;/A&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;struct&lt;/SPAN&gt; &lt;SPAN class=""&gt;&lt;A href="https://elixir.bootlin.com/linux/v4.9.275/C/ident/fb_var_screeninfo" target="_blank" rel="noopener"&gt;fb_var_screeninfo&lt;/A&gt;&lt;/SPAN&gt; &lt;SPAN class=""&gt;*&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;A href="https://elixir.bootlin.com/linux/v4.9.275/C/ident/var" target="_blank" rel="noopener"&gt;var&lt;/A&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;,&lt;/SPAN&gt;
		&lt;SPAN class=""&gt;struct&lt;/SPAN&gt; &lt;SPAN class=""&gt;&lt;A href="https://elixir.bootlin.com/linux/v4.9.275/C/ident/fb_info" target="_blank" rel="noopener"&gt;fb_info&lt;/A&gt;&lt;/SPAN&gt; &lt;SPAN class=""&gt;*&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;A href="https://elixir.bootlin.com/linux/v4.9.275/C/ident/fb_info" target="_blank" rel="noopener"&gt;fb_info&lt;/A&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;)&lt;/SPAN&gt;
&lt;SPAN class=""&gt;{&lt;/SPAN&gt;
	...

	&lt;SPAN class=""&gt;&lt;A href="https://elixir.bootlin.com/linux/v4.9.275/C/ident/var" target="_blank" rel="noopener"&gt;var&lt;/A&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;-&amp;gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;A href="https://elixir.bootlin.com/linux/v4.9.275/C/ident/xres_virtual" target="_blank" rel="noopener"&gt;xres_virtual&lt;/A&gt;&lt;/SPAN&gt; &lt;SPAN class=""&gt;=&lt;/SPAN&gt; &lt;SPAN class=""&gt;&lt;A href="https://elixir.bootlin.com/linux/v4.9.275/C/ident/var" target="_blank" rel="noopener"&gt;var&lt;/A&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;-&amp;gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;A href="https://elixir.bootlin.com/linux/v4.9.275/C/ident/xres" target="_blank" rel="noopener"&gt;xres&lt;/A&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;;&lt;/SPAN&gt;

	&lt;SPAN class=""&gt;&lt;A href="https://elixir.bootlin.com/linux/v4.9.275/C/ident/var" target="_blank" rel="noopener"&gt;var&lt;/A&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;-&amp;gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;A href="https://elixir.bootlin.com/linux/v4.9.275/C/ident/yres_virtual" target="_blank" rel="noopener"&gt;yres_virtual&lt;/A&gt;&lt;/SPAN&gt; &lt;SPAN class=""&gt;=&lt;/SPAN&gt; &lt;SPAN class=""&gt;&lt;A href="https://elixir.bootlin.com/linux/v4.9.275/C/ident/var" target="_blank" rel="noopener"&gt;var&lt;/A&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;-&amp;gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;A href="https://elixir.bootlin.com/linux/v4.9.275/C/ident/yres" target="_blank" rel="noopener"&gt;yres&lt;/A&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;;&lt;BR /&gt;...&lt;BR /&gt;}&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;Is that on purpose? Or is that an imperfection in the driver?&lt;/P&gt;&lt;P&gt;Anyway, I have created a &lt;A href="https://lists.yoctoproject.org/g/yocto/message/55890" target="_self"&gt;patch for psplas: Fix double buffering initialization&lt;/A&gt;, to double check the yres_virtual, should any other driver behave the same.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jan 2022 12:20:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/iMX7-framebuffer-ioctl-fails/m-p/1400287#M185904</guid>
      <dc:creator>michalhorn</dc:creator>
      <dc:date>2022-01-17T12:20:05Z</dc:date>
    </item>
  </channel>
</rss>

