public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Steve Longerbeam <slongerbeam@gmail.com>
To: "Philipp Zabel" <p.zabel@pengutronix.de>,
	"Krzysztof Hałasa" <khalasa@piap.pl>
Cc: linux-media@vger.kernel.org, Tim Harvey <tharvey@gateworks.com>
Subject: Re: i.MX6 IPU CSI analog video input on Ventana
Date: Sat, 2 Jun 2018 10:45:37 -0700	[thread overview]
Message-ID: <05703b20-3280-3bdd-c438-dfce8e475aaa@gmail.com> (raw)
In-Reply-To: <1527858788.5913.2.camel@pengutronix.de>



On 06/01/2018 06:13 AM, Philipp Zabel wrote:
> Hi Krzysztof,
>
> On Fri, 2018-06-01 at 12:02 +0200, Krzysztof Hałasa wrote:
>> Steve Longerbeam <slongerbeam@gmail.com> writes:
>>
>>> I tend to agree, I've found conflicting info out there regarding
>>> PAL vs. NTSC field order. And I've never liked having to guess
>>> at input analog standard based on input # lines. I will go ahead
>>> and remove the field order override code.
>> I've merged your current fix-csi-interlaced.2 branch (2018-06-01
>> 00:06:45 UTC 22ad9f30454b6e46979edf6f8122243591910a3e) along with
>> "media: adv7180: fix field type" commit and NTSC camera:
>>
>> media-ctl -V "'adv7180 2-0020':0 [fmt:UYVY2X8/720x480 field:alternate]"
>> media-ctl -V "'ipu2_csi1_mux':2 [fmt:UYVY2X8/720x480]"
>> media-ctl -V "'ipu2_csi1':2 [fmt:AYUV32/720x480 field:interlaced/-bt/-tb]"
>>
>> correctly sets:
>>
>> "adv7180 2-0020":0 [fmt:UYVY2X8/720x480 field:alternate]
>> "ipu2_csi1_mux":1  [fmt:UYVY2X8/720x480 field:alternate]
>> "ipu2_csi1_mux":2  [fmt:UYVY2X8/720x480 field:alternate]
>> "ipu2_csi1":0      [fmt:UYVY2X8/720x480 field:alternate]
>> "ipu2_csi1":2      [fmt:AYUV32/720x480 field:interlaced/-bt/-tb]
>>
>> but all 3 cases seem to produce top-first interlaced frames.
>> The CCIR_CODE_* register dump shows no differences:
>> 2a38014: 010D07DF 00040596 00FF0000
>>
>> ...it's because the code in drivers/gpu/ipu-v3/ipu-csi.c still sets the
>> registers depending on the height of the image.
> Exactly.
>
>>   Hovewer, I'm using 480
>> lines here, so it should be B-T instead.
> My understanding is that the CCIR codes for height == 480 (NTSC)
> currently capture the second field (top) first, assuming that for NTSC
> the EAV/SAV codes are bottom-field-first.
>
> So the CSI captures SEQ_TB for both PAL and NTSC: The three-bit values
> in CCIR_CODE_2/3 are in H,V,F order, and the NTSC case has F=1 for the
> field that is captured first, where F=1 is the field that is marked as
> second field on the wire, so top. Which means that the captured frame
> has two fields captured across frame boundaries, which might be
> problematic if the source data was originally progressive.

I agree, for NTSC the CSI will drop the first B field and start capturing
at the T field, and then capture fields across frame boundaries. At
least, that is if we understand how these CCIR registers work: the
CSI will look for H-S-V codes for the start and end of active and blanking
lines, that match the codes written to CCIR_CODE_1/2 for fields 0/1.

I think this must be legacy code from a Freescale BSP requirement
that the CSI must always capture in T-B order. We should remove this
code, so that the CSI always captures field 0 followed by field 1, 
irrespective
of field affinity, as in:

diff --git a/drivers/gpu/ipu-v3/ipu-csi.c b/drivers/gpu/ipu-v3/ipu-csi.c
index 5450a2d..b8b9b6d 100644
--- a/drivers/gpu/ipu-v3/ipu-csi.c
+++ b/drivers/gpu/ipu-v3/ipu-csi.c
@@ -398,41 +398,20 @@ int ipu_csi_init_interface(struct ipu_csi *csi,
                 break;
         case IPU_CSI_CLK_MODE_CCIR656_INTERLACED:
                 if (mbus_fmt->width == 720 && mbus_fmt->height == 576) {
-                       /*
-                        * PAL case
-                        *
-                        * Field0BlankEnd = 0x6, Field0BlankStart = 0x2,
-                        * Field0ActiveEnd = 0x4, Field0ActiveStart = 0
-                        * Field1BlankEnd = 0x7, Field1BlankStart = 0x3,
-                        * Field1ActiveEnd = 0x5, Field1ActiveStart = 0x1
-                        */
                         height = 625; /* framelines for PAL */
-
-                       ipu_csi_write(csi, 0x40596 | CSI_CCIR_ERR_DET_EN,
-                                         CSI_CCIR_CODE_1);
-                       ipu_csi_write(csi, 0xD07DF, CSI_CCIR_CODE_2);
-                       ipu_csi_write(csi, 0xFF0000, CSI_CCIR_CODE_3);
                 } else if (mbus_fmt->width == 720 && mbus_fmt->height 
== 480) {
-                       /*
-                        * NTSC case
-                        *
-                        * Field0BlankEnd = 0x7, Field0BlankStart = 0x3,
-                        * Field0ActiveEnd = 0x5, Field0ActiveStart = 0x1
-                        * Field1BlankEnd = 0x6, Field1BlankStart = 0x2,
-                        * Field1ActiveEnd = 0x4, Field1ActiveStart = 0
-                        */
                         height = 525; /* framelines for NTSC */
-
-                       ipu_csi_write(csi, 0xD07DF | CSI_CCIR_ERR_DET_EN,
-                                         CSI_CCIR_CODE_1);
-                       ipu_csi_write(csi, 0x40596, CSI_CCIR_CODE_2);
-                       ipu_csi_write(csi, 0xFF0000, CSI_CCIR_CODE_3);
                 } else {
                         dev_err(csi->ipu->dev,
                                 "Unsupported CCIR656 interlaced video 
mode\n");
                         spin_unlock_irqrestore(&csi->lock, flags);
                         return -EINVAL;
                 }
+
+               ipu_csi_write(csi, 0x40596 | CSI_CCIR_ERR_DET_EN,
+                             CSI_CCIR_CODE_1);
+               ipu_csi_write(csi, 0xD07DF, CSI_CCIR_CODE_2);
+               ipu_csi_write(csi, 0xFF0000, CSI_CCIR_CODE_3);
                 break;
         case IPU_CSI_CLK_MODE_CCIR1120_PROGRESSIVE_DDR:
         case IPU_CSI_CLK_MODE_CCIR1120_PROGRESSIVE_SDR:

  reply	other threads:[~2018-06-02 17:45 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-10  8:19 i.MX6 IPU CSI analog video input on Ventana Krzysztof Hałasa
2018-05-10 16:32 ` Steve Longerbeam
2018-05-11  5:37   ` Krzysztof Hałasa
2018-05-11 17:35     ` Steve Longerbeam
2018-05-18 17:28       ` Krzysztof Hałasa
2018-05-18 17:56         ` Tim Harvey
2018-05-21  5:51           ` Krzysztof Hałasa
2018-05-21  8:09         ` Krzysztof Hałasa
2018-05-21 15:55           ` Tim Harvey
2018-05-21 21:25           ` Steve Longerbeam
2018-05-22 10:48             ` Krzysztof Hałasa
2018-05-24 15:56             ` Krzysztof Hałasa
2018-05-24 18:12               ` Steve Longerbeam
2018-05-24 20:48                 ` Steve Longerbeam
2018-05-24 21:33                   ` Steve Longerbeam
2018-05-25  6:34                     ` Philipp Zabel
2018-05-25  5:21                   ` Krzysztof Hałasa
2018-05-25  6:32                 ` Philipp Zabel
2018-05-25  7:18                   ` Krzysztof Hałasa
2018-05-25 23:39                     ` Steve Longerbeam
2018-05-29  7:26                       ` Krzysztof Hałasa
2018-05-29 14:00                         ` Steve Longerbeam
2018-05-30  8:53                           ` Krzysztof Hałasa
2018-05-30 17:57                             ` Steve Longerbeam
2018-05-30 18:46                               ` Krzysztof Hałasa
2018-05-30 20:56                                 ` Steve Longerbeam
2018-05-31  6:29                                   ` Philipp Zabel
2018-06-01  5:23                                     ` Krzysztof Hałasa
2018-06-02 17:33                                     ` Steve Longerbeam
2018-06-04  8:38                                       ` Philipp Zabel
2018-06-01 10:02                                   ` Krzysztof Hałasa
2018-06-01 13:13                                     ` Philipp Zabel
2018-06-02 17:45                                       ` Steve Longerbeam [this message]
2018-06-04  7:33                                         ` Krzysztof Hałasa
2018-06-04  8:47                                         ` Philipp Zabel
2018-06-04  8:58                                           ` Krzysztof Hałasa
2018-10-17 20:38                                             ` Tim Harvey
     [not found]                                               ` <57dfdc0b-5f04-e10a-2ffd-c7ba561fe7ce@gmail.com>
2018-10-17 23:05                                                 ` Tim Harvey
2018-10-17 23:37                                                   ` Steve Longerbeam
2018-10-18 17:56                                                     ` Tim Harvey
2018-10-19 20:06                                                       ` Steve Longerbeam
2018-10-19  9:45                                                 ` Philipp Zabel
2018-06-04  7:06                                       ` Krzysztof Hałasa
2018-05-25 23:21                   ` Steve Longerbeam
2018-06-01 13:52                     ` Philipp Zabel
2018-05-25  7:07                 ` Krzysztof Hałasa
2018-05-22  9:41           ` Franz Melchior
2018-05-11  6:11 ` Franz Melchior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=05703b20-3280-3bdd-c438-dfce8e475aaa@gmail.com \
    --to=slongerbeam@gmail.com \
    --cc=khalasa@piap.pl \
    --cc=linux-media@vger.kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=tharvey@gateworks.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox