<?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: A Simple tutor for writing i.MX6 mipi driver, use adv7480 as an example in i.MX Processors</title>
    <link>https://community.nxp.com/t5/i-MX-Processors/A-Simple-tutor-for-writing-i-MX6-mipi-driver-use-adv7480-as-an/m-p/486596#M77882</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, Waly,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;By "turn off" do you mean "set all MIPI siganls, i.e. data_x_p/data_x_n and clk_p/clk_n to 0 or&amp;nbsp; LP11/STOP_STATE(about 1.2V single ended)", or hi-z?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. adv7480_init_mode(), I found after mipi_csi2_reset_with_dphy_freq() or mipi_csi2_reset() called, you *&lt;STRONG&gt;must&lt;/STRONG&gt;* turn off device's output and turn it on again! or you will got&lt;/P&gt;&lt;P&gt;mipi_csi2_dphy_status alwaly be 0x200 or 0x230, it means i.MX6 can't get the clock form device.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 16 Jun 2016 20:48:05 GMT</pubDate>
    <dc:creator>dehuanxin</dc:creator>
    <dc:date>2016-06-16T20:48:05Z</dc:date>
    <item>
      <title>A Simple tutor for writing i.MX6 mipi driver, use adv7480 as an example</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/A-Simple-tutor-for-writing-i-MX6-mipi-driver-use-adv7480-as-an/m-p/486595#M77881</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, folks:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; It's been a month since fighting with the i.MX6 mipi driver, I realize how dumb I am during writing i.MX6 device mipi driver; so I write this article for someone like me - whom is hopeless and frighten by this damn mipi protocol. &lt;SPAN aria-label="Cry" class="emoticon_cry emoticon-inline" style="height:16px;width:16px;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Our case is using adv7480 as TV-in function(HDMI in, and yuv422 out) on i.MX6DL, 2 mipi data lanes, attach to &amp;lt;CSI0, IPU0, virtual channel 0&amp;gt;, and wanna grab some picture form it. I choose v4l2grab for grab picture from mipi, download location: &lt;A _jive_internal="true" href="https://community.nxp.com/external-link.jspa?url=https%3A%2F%2Fgithub.com%2Ftwam%2Fv4l2grab" rel="nofollow" target="_blank"&gt;GitHub - twam/v4l2grab: utility for grabbing JPEGs from V4L2 devices&lt;/A&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; By the way, the SDK I'm using is SDK_3.0.35-4.1.0; you may use different SDK but you need to fight with arm device tree files by yourself.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; OK, the first step is to tell kernel you have the device, one can see how to do this by reference my patch file: 0001-add-adv7480-platform-data.patch&lt;/P&gt;&lt;P&gt;I strongly recommend using CSI0, IPU0, and virtual channel 0.&amp;nbsp; since every device *&lt;STRONG&gt;must&lt;/STRONG&gt;* &lt;SPAN style="color: #e23d39;"&gt;&lt;STRONG&gt;set the virtual channel&lt;/STRONG&gt;&lt;/SPAN&gt;, and the reasonable default value is 0; so if you doesn't know how to set your device's virtual channel, just use 0 on your board file.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Second, the mipi driver, I also attached it(adv7480_mipi_driver_patches.zip).&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;patch 0001&lt;/STRONG&gt; is just add an V4L2 ID for adv7480.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;patch 0002&lt;/STRONG&gt; add an func "mipi_csi2_reset_with_dphy_freq" for driver use. the main idea is dynamic change i.MX6 Dphy frequency to match the adv7480 mipi data lane output.&lt;/P&gt;&lt;P&gt;if someone is confused with "pixel clock", "mipi clock lane frequency", "mipi data lane frequency", following is an simple explanation:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="141713_141713.jpg"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/121106iFB2BBFFABB5CC81B/image-size/large?v=v2&amp;amp;px=999" role="button" title="141713_141713.jpg" alt="141713_141713.jpg" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="unnamed.jpg"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/55050i1D47F336E28E3483/image-size/large?v=v2&amp;amp;px=999" role="button" title="unnamed.jpg" alt="unnamed.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;and pixel clock can get from this website: &lt;A _jive_internal="true" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Ftinyvga.com%2Fvga-timing" rel="nofollow" target="_blank"&gt;VGA Signal Timing&lt;/A&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;patch 0003&lt;/STRONG&gt; is for &lt;STRONG&gt;v4l2grab&lt;/STRONG&gt; only, don't know why it call v4l2 ioctl "&lt;STRONG&gt;VIDIOC_S_FMT&lt;/STRONG&gt;" but kernel will use "&lt;STRONG&gt;VIDIOC_TRY_FMT&lt;/STRONG&gt;" instead.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;patch 0004&lt;/STRONG&gt; is the entire adv7480 driver, basically I just swallow the i2c commends from ov5640_mipi.c and fill my own, then change it's func name with "adv7480"。&lt;/P&gt;&lt;P&gt;I will explain some important part：&lt;/P&gt;&lt;P&gt;1. adv7480_init_mode(), I found after mipi_csi2_reset_with_dphy_freq() or mipi_csi2_reset() called, you *&lt;STRONG&gt;must&lt;/STRONG&gt;* turn off device's output and turn it on again! or you will got&lt;/P&gt;&lt;P&gt;mipi_csi2_dphy_status alwaly be 0x200 or 0x230, it means i.MX6 can't get the clock form device.&lt;/P&gt;&lt;P&gt;2. most v4l2 ioctl is not implemented, only ioctl_s_parm() and ioctl_g_parm() are implemented.&lt;/P&gt;&lt;P&gt;3. adv7480 have totally 12 i2c clients inside the chip, so we also need to add a argument "address" for different sub i2c client's address.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; adv7480_mipi_tvin.c will register an v4l2 device by mxc_v4l2_capture.c called. and mxc_v4l2_capture.c will make a device node - &lt;STRONG&gt;/dev/video0&lt;/STRONG&gt;. that's the node we can use v4l2grac to grab some picture - ./vl42grab -o /tmp/test.jpg.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;p.s: since i.MX6 DL mipi bandwidth is small, you can only retrieve picture while input resolution is lower than 1280x800. if anyone want grab 1920x1080. you must use i.MX6Q and use 4 mipi data lanes.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Original Attachment has been moved to: &lt;A _jive_internal="true" href="https://community.nxp.com/docs/DOC-336164"&gt;0001-add-adv7480-platform-data.patch.zip&lt;/A&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Original Attachment has been moved to: &lt;A _jive_internal="true" href="https://community.nxp.com/docs/DOC-336164"&gt;adv7480_mipi_driver_patches.zip&lt;/A&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Feb 2016 09:04:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/A-Simple-tutor-for-writing-i-MX6-mipi-driver-use-adv7480-as-an/m-p/486595#M77881</guid>
      <dc:creator>wallyyeh</dc:creator>
      <dc:date>2016-02-25T09:04:16Z</dc:date>
    </item>
    <item>
      <title>Re: A Simple tutor for writing i.MX6 mipi driver, use adv7480 as an example</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/A-Simple-tutor-for-writing-i-MX6-mipi-driver-use-adv7480-as-an/m-p/486596#M77882</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, Waly,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;By "turn off" do you mean "set all MIPI siganls, i.e. data_x_p/data_x_n and clk_p/clk_n to 0 or&amp;nbsp; LP11/STOP_STATE(about 1.2V single ended)", or hi-z?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. adv7480_init_mode(), I found after mipi_csi2_reset_with_dphy_freq() or mipi_csi2_reset() called, you *&lt;STRONG&gt;must&lt;/STRONG&gt;* turn off device's output and turn it on again! or you will got&lt;/P&gt;&lt;P&gt;mipi_csi2_dphy_status alwaly be 0x200 or 0x230, it means i.MX6 can't get the clock form device.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 20:48:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/A-Simple-tutor-for-writing-i-MX6-mipi-driver-use-adv7480-as-an/m-p/486596#M77882</guid>
      <dc:creator>dehuanxin</dc:creator>
      <dc:date>2016-06-16T20:48:05Z</dc:date>
    </item>
    <item>
      <title>Re: A Simple tutor for writing i.MX6 mipi driver, use adv7480 as an example</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/A-Simple-tutor-for-writing-i-MX6-mipi-driver-use-adv7480-as-an/m-p/486597#M77883</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, Dehuan:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Sorry, not an expert, so I didn't know if just reset &lt;STRONG style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;LP11/STOP_STATE&lt;/STRONG&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt; could solve the case or not.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;In my experience, every time I call &lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;mipi_csi2_reset_with_dphy_freq() or &lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;mipi_csi2_reset(), I must reset my mipi device by bunch of i2c command. you can see my patch:「0004-add-adv7480-mipi-driver.patch」 I need issue out bunch of i2c commands for reset adv7480 at line 387 of /kernel/drivers/media/video/mxc/capture/adv7480_mipi_tvin.c :&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;EM style=": ; color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;adv7480_download_firmware(adv7480_init_params_after_mapped_another_i2c, ARRAY_SIZE(adv7480_init_params_after_mapped_another_i2c));&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Jun 2016 08:31:29 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/A-Simple-tutor-for-writing-i-MX6-mipi-driver-use-adv7480-as-an/m-p/486597#M77883</guid>
      <dc:creator>wallyyeh</dc:creator>
      <dc:date>2016-06-17T08:31:29Z</dc:date>
    </item>
    <item>
      <title>Re: A Simple tutor for writing i.MX6 mipi driver, use adv7480 as an example</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/A-Simple-tutor-for-writing-i-MX6-mipi-driver-use-adv7480-as-an/m-p/486598#M77884</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I noticed your driver is using bt656 clock mode which is contrary to the guidance of the imx6 data sheet.&amp;nbsp; The data sheet recommends using non-gated mode when working with MIPI.&amp;nbsp; Based on my copy of mxc_v4l2_capture.c, you'd want to set clock_curr to -1 in order to use non-gated mode.&amp;nbsp; I'm also guessing you'd want to disable AV codes in the 7480 but I am less sure about that at this point.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Did you ever capture video from the 7480 or just single frames?&amp;nbsp; If you're just capturing single frames, it's possible you didn't see the issues which we're encountering when using your driver(incorrect frame sizes, garbage data between frames).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyway, thanks for the reference driver.&amp;nbsp; It seems like a good starting point.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Apr 2018 23:02:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/A-Simple-tutor-for-writing-i-MX6-mipi-driver-use-adv7480-as-an/m-p/486598#M77884</guid>
      <dc:creator>jasongaiser</dc:creator>
      <dc:date>2018-04-11T23:02:02Z</dc:date>
    </item>
  </channel>
</rss>

