-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
image sync problem? #1
Comments
Hi, @lerabot. Thanks for making sure it works. I am aware of this problem and apologize for not announcing it in advance. I have tried to solve this problem by directly rewriting the registers of the ADV7280A-M, but I have not been able to solve it yet. I believe that the problem is probably in the hardware design. I am too busy with other work to tackle this problem right now, |
Thank for the quick feedback. I might try to write a script that try to detect and stitch the image together for the time being. Also, I posted on the raspberry pi forum about this. https://forums.raspberrypi.com/viewtopic.php?p=2111105#p2110939 I might try to hack together something with the ADM7280 driver at some point to try to correct the power up timing sequence. |
Hello again. I'm resuming work on this and will try hacking with the register again. If you have any clues on how to fix this in software, I'll gladly take them. |
Thanks for waiting so long. As answered in the Raspberry Pi or Analog Devices forums, the data output by the ADV7280-M with NTSC as input format, ITU-R BT.656-3 as output format, and I2P enabled is not 480 lines per frame, but The data output by ADV7280-M is not 480 lines per frame, but 507 lines per frame including blanking data. For this, I actually confirmed using an FPGA board (TE0726-03M) and MIPI CSI-2 receiver that 507 YUV422 packets come per frame. The relationship between video format settings and output resolution is described in detail in Table 72 of the device manual (UG-1176). However, the Linux kernel 6.1.y device driver running on the Raspberry Pi OS Bullseye is set to a height that reserves a buffer of 480 lines per frame, so it appears that the 27 lines of difference are overwritten at the beginning of the buffer during recording. To solve the problem, I changed the height in the device driver (adv7180.c) to 507 instead of 480. This allows the user to obtain a complete image, although the upper 27 lines contain extra blanking data. I feel that to solve all of these problems, not only the ADV7280 device driver, but also unicam and V4L2 API must be investigated thoroughly. (Dear @6by9, My environment and kernel module build procedure are shown below.
|
I'm not the author of it.
Previously referenced on the forums https://forums.raspberrypi.com/viewtopic.php?t=308902, and acknowledged by ADI in https://ez.analog.com/video/f/q-a/6495/adv7280-frame-timing-on-the-digital-output-video-bus/20601#20601
It's down to ADI to come up with some answers really, but it may actually be down to the NTSC spec based on ADI's comment "Unlike PAL, the NTSC standard does not have fixed vertical blanking specifications". Trying to fix it in the adv7180 driver is going to be slightly ugly as it only wants to be fixed for the CSI based chips when the I2P is active. Lots of conditionals to mess with.
however you have no way of telling userspace to ignore the top and bottom N lines of blanking that the chip produces. Observation: Page 51 of https://www.analog.com/media/en/technical-documentation/user-guides/adv7280_7281_7282_7283_ug-637.pdf
So you could potentially get 720x487 out of the chip by setting the BT656-4 flag - that would be the ADV7180_REG_EXTENDED_OUTPUT_CONTROL write, which looks to be set to 0x57 for CSI2 chips (https://github.com/torvalds/linux/blob/master/drivers/media/i2c/adv7180.c#L1038). Alter that to 0xd7 and you should get the 487 line mode. |
Hi @6by9, thank you for leaving your detailed comments! Also, thanks for pointing us to the specific kernel patches.
This is exactly the information I wanted to know, and for that I thought I needed to look into unicam or V4L2 implementations.
Actually, there is a slight problem with this.
I know that the ADV7280A-M sends a YUV422 long packet containing video data and then sends several blanking packets before sending a Frame End packet. but I have not confirmed what data is contained in the payload of the blanking packets, so I will try to set up a debugging environment to dump all the packets to confirm the details. |
@lerabot I have updated the procedure in the README of this commit (694bd97). I initially expected that there was something wrong with the hardware (PCB) design, but it turns out that I can work around this problem by rewriting the device driver. so please refer to the procedure and check the operation. |
Hello to both of you and thank for all your research. I'll test your version of the patch tomorrow or today and see if I can get better result. |
Whilst I did have a branch that allowed reception of interlaced content (ie I2P disabled), it was a bit too hacky to be merged as the Unicam driver needed knowledge of how the ADV signaled the field (using the frame count value IIRC). I'll see if I can find a few minutes to hack together testing with BT656-4 register tweaked, and whether it makes a useful difference. Producing 507 lines feels wrong - it'd be nice to investigate further, but I doubt I'll have time. ADI may answer further on their forums if the question is asked. Seeing as I have a couple of patches for this chip that would be worth sending upstream, I may send the trivial fix above along with it to at least start the discussion. I don't know how the crop should be advertised though, and want to confirm 507 vs 525 lines as well. |
Been working on this for the past couple of days. It's a shame that we can't get proper interlaced capture because I'm fairly sure we could get a better quality out of software deinterlacer. I've been looking at the interlaced unicam driver and it does seem quite hacky. I'll try to give a try later. |
The issue is that there is no standardisation as to how things like interlacing should be signaled on CSI2, and V4L2's frameworks don't provide a mechanism for the receiver to pass side-band information back to the source device driver to give it a chance to interpret it and amend buffer descriptors accordingly. Looking at my branch at https://github.com/6by9/linux/tree/rpi-5.10.y-unicam-interlaced, ADV728x uses the 16bit frame_count field in the frame start and end packets. The Toshiba TC358743 HDMI to CSI2 bridge can also receive interlaced content, however it sends the 2 fields with different CSI2 data types. It would therefore need a similar routine to set the interlacing flags, but based on UNICAM_CDT instead of UNICAM_CWC. (We'd also need to programme both DTs that represent the interlaced image data). IIRC The I2P block is a relatively simple line doubler, or possibly interpolate between the 2 lines in each field. Yes software could probably do a more comprehensive job. |
@rniwase I'm currently making a variant of your circuit as a raspberry pi zero hat. You mentioned making some mistake with the circuit, do you care to elaborate more? I could integrate those changes in this new version. I will post the source here https://github.com/lerabot/dvx-nebula |
@lerabot at this time, I don't believe that there is any problem with the circuit design. And I am honored that my work will be incorporated into your project. I hope it will work. |
Hello rniwase. I just received the ADV7280 Hat for the Pi Zero. If you'd like one I'll ship you one for free. |
Hello, first of all thank you for your pcb layout :) I fab'd 5 board last month and they work great.
I have an image sync issue and I'm wonderig you you had the same problem, check the screenshot.
I'm capturing using s-video NTSC, but I can see this problem even on composite.
The text was updated successfully, but these errors were encountered: