Summary of Android s5pv210 camera driver (tw9912)

Source: Internet
Author: User

I have never touched Samsung's Development Board before, but I don't know about s5pv210. The ad chip tw9912 is also the first contact. Samsung Fae is not powerful (actually none). During camera debugging, I suspect that the tw9912 configuration is incorrect. I suspect that the Samsung fimc driver is faulty. It is painful. Today I finally pulled up the correct image and posted it to share it with you.

Tw9912 Configuration

The ad chip tw9912, techwell Fae, provides several sets of register configurations:

Pal in 656 P out --- pal performs input, and the output is a line-by-line method of bt656.

Pal in 656i out --- pal performs input, and the output is the line separation method of bt656.

NTSC in 656 P out --- NTSC for input, the output is line by line of bt656

NTSC in 656i out --- NTSC is used for input, and the output is the line separation method of bt656.

Considering that the backend fimc is extremely weird in line-by-line processing (I have not yet understood how to combine the four buffers It outputs into a complete frame), I chose line-by-line output, pal input (my camera is pal). The pal in 656 P out configuration provided by Fae can work normally.

The configuration register value given by techwell Fae is set one by one, and the order does not matter. This is also amazing, but I still need to expand it in the future. After automatic detection, set the corresponding parameter.

When it comes to line-by-line output, I spent a lot of time wondering if there was a problem with the line-by-line bt656 output, because the standard bt656 signal does not support line-by-line output, I don't know which rape manufacturer has extended the standard bt656. What's more awesome is that one manufacturer's products output a line-by-line bt656 signal, and another manufacturer receives and processes this line-by-line bt656 signal, they work very well together. Someone has discussed on the internet what this line-by-line bt656 is, that is, the F bit of bt656 is always 0.

After tw9912 is configured as a line-by-line output, pixclk is 54 MHz, which is doubled compared with the pixclk = 27 MHz output of the line-by-line output. Therefore, the number of frames is doubled from 25 to> 50, or 30-> 60.

There is an approximate algorithm for pixclk frequency: * number of rows * Frame Rate of row data

Pal: (1440 + 280 + 4 + 4) * 625*25 = 27000000

NTSC: (1440 + 280 + 4 + 4) * 525*30 = 2721600

Fimc driver

Samsung's camera back-end is the fimc controller. Samsung writes a fimc driver framework with the code under Drivers/Media/Video/Samsung/fimc/. I will analyze the fimc driver later.

The fimc code is much simpler and clearer than the MX51 camera driver framework. But there are still a few changes to make it possible to correctly run the camera driver.

1. Add a initi_platform_camera device to arch/ARM/mach-s5pv210/mach-smdkc210.c

       .id     = CAMERA_PAR_A,       .type       = CAM_TYPE_ITU,       .fmt        = ITU_656_YCBCR422_8BIT,       .order422   = CAM_ORDER422_8BIT_YCBYCR,       .i2c_busnum = 1,         .info       = &tw9912_i2c_info,       .pixelformat = V4L2_PIX_FMT_YUYV,       .srclk_name = "mout_mpll",       .clk_name   = "sclk_cam0",       .clk_rate   = 44000000,       .line_length = 1440,       .width      = 720,       .height     = 576,       .window     = {               .left   = 0,               .top    = 0,               .width  = 720,               .height = 576,       },       /* Polarity */       .inv_pclk   = 0,       .inv_vsync  = 0,       .inv_href   = 0,       .inv_hsync  = 0,

. ID = camera_par_a. Check your own schematic to see which physical camera interface is used.

Fimc supports three camera interfaces, two of which are ITU. The so-called ITU type supports the bt601 or bt656 protocol, and the other is the mipi interface.

. Type = cam_type_itu. There is no doubt that we are using the ITU interface type.

. Srclk_name = "mout_mpll ",

. Clk_name = "sclk_cam0 ",

. Clk_rate = 44000000

Because I use an external crystal oscillator and do not need to provide mclk, it is meaningless to provide these lines. However, if your camera requires fimc to provide mclk, set this mclk correctly.

. Line_length = 1440 is useless.

. Width = 720,

. Size = 576,

Standard width and height of PAL cameras

2. Modify the fimc working mode bt601-> bt656

For the ITU interface, the default working mode of fimc is bt601, which must be changed to bt656. I guess the sensor used by Samsung developers only supports bt601, so they only verified bt601.

3. Modify the alignment of DMA allocation

The DMA alignment problem has plagued me for a week, because by default, the fimc driver has no requirements for the DMA memory allocation alignment, in some cases, the DMA address of the fimc Hardware Must be 4 K aligned. If you give a non-4 K aligned address, such as 0x4abc5800, then, DMA will not write camera data from this address, but write data from 0x4abc5000, which leads to misplacement of the image, such as the middle left thick black line.

There is a thin black line on the left of the black line. This is a problem with tw9912. You can delete several parameters of vdelay vactive hdelay hactive. This is so funny, it is also the reason why tw9912 is suspected to be faulty during the camera driver adjustment.

Test

You can use the test program to capture the image and verify it.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.