Android Camera (quad): Camera driver GT2005

Source: Internet
Author: User

Camera Main parameters:

1, MCLK 24MHz;

2, PCLK 48~52mhz~;

3, Voltage 1.8V (1.5V), 2.8V;

4, SCL (IIC clock) 100KHz or 400KHz.

Download: Common camera Spec book (individual with Android driver) : bf3703 30W, gc0308 30W, ov7670, gt2005 200W, gt2015 200W, NT99250 200W, S5k5ba 200W, S5k4ba

First, the camera driver

Let's take GT2005 as an example to tell a camera-driven debug process:

The diagram of the camera and the master control is as follows:

Camera driver is relatively simple, three major steps to complete a single step:

The basic condition of the camera's power-up and clock;

IIC guarantees the initialization of the camera;

The camera returns data to the master after working.

Complete these three steps to complete the basic work of the camera debugging.

1, the camera's power-up, clock these basic conditions of implementation

Power supply Section, corresponding to the specification when power on, confirm the power-on timing; MCLK the camera's main clock is available, see below is and the power and specifications in the book

(1), the idea of the camera work to two sets of voltage: 1.8V (1.5V), 2.8V and MCLK

Power control in the program: in the ARCH\ARM\MACH-SMDKV310.C, we complete the above two steps of the code, (this point may be different platform, here is an example, this part of the code is only for the Samsung platform)

[CPP]View Plaincopy
  1. #ifdef config_video_gt2005
  2. static void Set_cam2005_main_power (int onoff)
  3. {
  4. unsigned int gpio;
  5. int err;
  6. if (onoff)
  7. {
  8. Err = Gpio_request (S5PV210_GPB (2), "GPB");
  9. if (err)
  10. PRINTK (Kern_err "# # # Failed to request GPB2 for cam\n");
  11. S3c_gpio_cfgpin (S5PV210_GPB (2), s3c_gpio_output);
  12. S3c_gpio_setpull (S5PV210_GPB (2), s3c_gpio_pull_up);
  13. Gpio_direction_output (S5PV210_GPB (2), 1);
  14. Gpio_free (S5PV210_GPB (2));
  15. //reset
  16. Err = Gpio_request (S5pv210_gpe1 (4), "GPE1");
  17. if (err)
  18. PRINTK (Kern_err "# # # Failed to request gpe1_4 for cam\n");
  19. S3c_gpio_setpull (S5pv210_gpe1 (4), s3c_gpio_pull_none);
  20. Gpio_direction_output (S5pv210_gpe1 (4), 0);
  21. Mdelay (100);
  22. Gpio_direction_output (S5pv210_gpe1 (4), 1);
  23. Gpio_free (S5pv210_gpe1 (4));
  24. //PWDN Cam_back
  25. Err = Gpio_request (S5PV210_GPB (4), "GPB");
  26. if (err)
  27. PRINTK (Kern_err "# # # Failed to request GPB4 for cam\n");
  28. S3c_gpio_cfgpin (S5PV210_GPB (4), s3c_gpio_output);
  29. S3c_gpio_setpull (S5PV210_GPB (4), s3c_gpio_pull_up);
  30. Gpio_direction_output (S5PV210_GPB (4), 0);
  31. Mdelay (100);
  32. Gpio_direction_output (S5PV210_GPB (4), 1);
  33. Gpio_free (S5PV210_GPB (4));
  34. }
  35. Else
  36. {
  37. ..................
  38. }
  39. return;
  40. }
  41. #endif

Provide the MCLK code as follows:

[CPP]View Plaincopy
  1. static int smdkv210_cam_clk_init (void)
  2. {
  3. unsigned int tempvalue=0;
  4. Tempvalue = Readl (S5P_CLK_DIV1);
  5. Tempvalue = (Tempvalue &0xffff0fff);
  6. Writel (TEMPVALUE,S5P_CLK_DIV1);
  7. Tempvalue = Readl (S5P_CLK_SRC1);
  8. Tempvalue = (Tempvalue &0xffff0fff) |0x00001000;
  9. Writel (TEMPVALUE,S5P_CLK_SRC1);
  10. return 0;
  11. }

At this time take the oscilloscope caught on the power of the waveform and Mclk24mhz clock, signal that we have completed this step, in fact, in the actual work, we generally have problems when the data will be measured, confirm the problem point.

Power-up sequence:

(1), power-up sequence;

(2), mclk as shown below.

2, IIC and some parameters of the configuration

[CPP]View Plaincopy
  1. #ifdef config_video_gt2005
  2. Static struct Gt2005_platform_data Gt2005_plat = {
  3. . Default_width = 640,
  4. . Default_height = 480,
  5. . PixelFormat = V4l2_pix_fmt_uyvy, //. Freq = 24000000,
  6. . Is_mipi = 0,
  7. };
  8. Static struct I2c_board_info gt2005_i2c_info = {
  9. I2c_board_info ("GT2005", 0x78 >> 1), //1, IIC address
  10. . Platform_data = >2005_plat,
  11. };
  12. Static struct S3c_platform_camera GT2005 = {
  13. #ifdef CAM_ITU_CH_A
  14. . id = camera_par_a,
  15. #else
  16. . id = camera_par_b,
  17. #endif
  18. . Type = Cam_type_itu, //2, Data Interface selection (ITU\MIPI, etc.)
  19. . FMT = Itu_601_ycbcr422_8bit,
  20. . order422 = Cam_order422_8bit_cbycry, //3, image Data format
  21. . I2c_busnum = 1,
  22. . info = >2005_i2c_info,
  23. . PixelFormat = V4l2_pix_fmt_uyvy,
  24. . Srclk_name = "MOUT_MPLL", //4, this part relates to the clock
  25. . Clk_name = "sclk_cam1",
  26. . clk_rate = 24000000,/ * 24MHz * /
  27. . Line_length = 640,/ * 640*480 * /
  28. / * Default resol for preview kind of thing * /
  29. . width = 640,
  30. . Height = 480,
  31. . window = {
  32. . left = 16,
  33. . top = 0,
  34. . width = (640-16),
  35. . Height = 480,
  36. },
  37. /* Polarity * //5, signal polarity,. INV_PCLK = 0,
  38. . Inv_vsync = 1,
  39. . Inv_href = 0,
  40. . Inv_hsync = 1,
  41. . initialized = 0,
  42. . cam_power=set_cam2005_main_power
  43. };
  44. #endif

Note the following parameters:

(1), IIC address

(2), Data Interface selection (ITU\MIPI, etc.), these data interfaces we mentioned earlier;

(3), image Data format, this is the yvu\uvy we mentioned earlier, such as different data order;

(4), this part relates to the clock;

(5), the polarity of the output signal, is our pclk, VSYNC, hsvnc the polarity of these signals, incorrect when there will be no image and other phenomena, this also should be noted.

Complete this step to confirm that the IIC communication is normal, such as the captured waveform:

3, complete the above two steps, the basic configuration of the camera is completed, we confirm the output end PCLK, VHSN, SVSN, D1-d7



Second, the camera debugging process often encountered problems

1, video in the preview when the normal, playing the recording of the flower screen (The program is interpreted as Samsung s5pv210/s5pv310 Yes, other can refer to, find the corresponding code)

Cause Analysis:
(1) FIMC2 for recording phase,

In the Android/device/samsung/proprietary/libcamera/seccamera.cpp
int Seccamera::startrecord (void)

[CPP]View Plaincopy
    1. M_cam_fd_rec = open (camera_dev_name2, O_RDWR);
    2. Vendor\sec\sec_proprietary\smdkc110\libcamera\seccamera.h
    3. #define CAMERA_DEV_NAME2 "/dev/video2"

(2) The video format used in the

In Android/device/samsung/proprietary/libcamera/seccamerahwinterface.cpp

void camerahardwaresec::m_initdefaultparameters (int camera_id)

[CPP]View Plaincopy
  1. int default_preview_pixel_format = Mseccamera->getpreviewdefaultpixelformat ();
  2. switch (default_preview_pixel_format) {
  3. Default:
  4. Case V4L2_PIX_FMT_NV21:
  5. P.setpreviewformat (cameraparameters::P ixel_format_yuv420sp);
  6. Break ;
  7. Case v4l2_pix_fmt_nv12t:
  8. P.setpreviewformat ("yuv420sp_tiled");
  9. Break ;
  10. }
  11. where Mseccamera->getpreviewdefaultpixelformat () in
  12. Implemented in Vendor\sec\sec_proprietary\smdkc110\libcamera\seccamera.cpp,
  13. int Seccamera::getpreviewdefaultpixelformat (void)
  14. {
  15. return Default_preview_pixel_format;
  16. }
  17. Set the initial value in the Android/device/samsung/proprietary/libcamera/seccamera.h. What we've set up here is
  18. #ifdef dual_port_recording
  19. #define DEFAULT_PREVIEW_PIXEL_FORMAT (V4L2_PIX_FMT_NV21)
  20. #else
  21. #define DEFAULT_PREVIEW_PIXEL_FORMAT (V4L2_PIX_FMT_NV12T)
  22. #endif

the above results in video format V4l2_pix_fmt_nv21.

2, the image interference problem, as shown in

The reasons may be:

(1), Camera module has a problem, change a camera to try;

(2), the data line drive capacity is insufficient, this can be changed in the camera register, ask the camera module FAE, see Change those places;

(3), two cameras shared data cable, the non-working camera will reduce the working data signal;

(4), PCB traces too long, there will be interference, but I think this possibility is small, debugging good on a such, module factory Fae said, but they have problems in the module itself, two factors are: PCB (line too long), module proofing also have problems.

3, the YUV sequence is not correct:

The following behavior occurs when the YUV sequence is incorrect.

Look at the camera specification book, the corresponding register value can be changed. The following in red box is a different YUV order, find the corresponding.

4, the preview direction is not correct (the camera register can only be changed to 180 degrees for the base, 90 degrees will be in the FIMC change)

To know and more clearly explain the flip angle, the most commonly used is to write an "F", and then see the preview of how to turn.

It has a 90-degree flip, because this is a register in the FIMC, and this part of the value is generally not changed. Either change it in the module register, or it will be on the upper level. The above just shows how to confirm the image rollover.

Look at the GT2005 about the flip register:

5. Miscellaneous Light, Ghost Shadow:

The jargon of the industry is known as flare, which refers to the shadow of a light or a complete object at the edge of a source or a strong light object, and this phenomenon can only be mitigated by the fact that the lens material causes the light not only to exist in refraction but also to reflect, Machine due to lens surface to protect the lens distance is more obvious!

6, common problems related

What are the camera effects evaluations?

Above take gt2005 as an example, said the camera drive, and drive common problems, if the above problem resolution, the camera is lit, indicating that the platform is running is no problem, small problems and details, to find the module Factory fae come to help solve, but you want to study more words, also can, if the project allows, To see more, to debug a driver, all the problems are understood, so that the work experience, accumulation is very important, I hope to be useful to everyone.

Android Camera (quad): Camera driver GT2005

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.