Andorid Camera Drive Process--MTK platform

Source: Internet
Author: User

Original address: Andorid Camera Drive process--MTK platform waiting for the heart

Camera Imaging principle:

The scene is produced by the lens of the optical image projected onto the sensor surface, and then converted to analog electrical signals, after the digital mode into the image signal, processed by the DSP, and then transmitted through the IO interface to the CPU processing. Since the camera satisfies the bus, drive, and device model, look at how Andorid is going to implement the camera process. 1. Platform platform device for camera registration

Click (here) to collapse or open

  1. Camera_hw_i2c_init
  2. Platform_driver_register (&g_stcamera_hw_driver)
  3. static struct Platform_driver G_stcamera_hw_driver = {
  4. . Probe = Camera_hw_probe,
  5. . remove = Camera_hw_remove,
  6. . Suspend = Camera_hw_suspend,
  7. . Resume = Camera_hw_resume,
  8. . Driver = {
  9. . Name = "Image_sensor",
  10. . Owner = This_module,
  11. }
  12. };
2. Platform platform device driver for camera registration

Click (here) to collapse or open

    1. Platform_device_register (&sensor_dev);
    2. static struct Platform_device Sensor_dev = {
    3. . Name = "Image_sensor",
    4. . id =-1,
    5. };
Many platform devices are registered in the Mt6575_board_init function, including the above platform devices. After the platform device of the camera matches the platform driver, the probe function of DRV is called, and its probe function mainly accomplishes the registration of the I²C platform driver.

Click (here) to collapse or open

    1. static int camera_hw_probe (struct platform_device *pdev)
    2. {
    3. Return I2c_add_driver (&camera_hw_i2c_driver);
    4. }
    5. struct I2c_driver camera_hw_i2c_driver = {
    6. . Probe = Camera_hw_i2c_probe,
    7. . remove = Camera_hw_i2c_remove,
    8. . Detect = Camera_hw_i2c_detect,
    9. . Driver.name = Camera_hw_drvname,
    10. . id_table = camera_hw_i2c_id,
    11. . Address_data = &addr_data,
    12. };
How to do the I²c drive and equipment matching? The kernel for this piece has a detailed explanation, the file for Instantiating-devices, now I²C platform driver has been registered, below to analyze how to register platform equipment. The 3rd method of the kernel should be used, when the kernel registers an I²C driver, it will eventually traverse the driver member of the bus device and call the __attach_adapter function.

Click (here) to collapse or open

    1. static int __attach_adapter (struct device *dev, void  *data)
    2. {
    3.     struct i2c_adapter *adapter;
    4.     struct I2c_driver *driver = data;
    5.     if  (dev->type != &i2c_adapter_type)
    6.          return 0;
    7.     adapter = to_i2c_adapter (dev);
    8.     i2c_detect (adapter, driver);
    9.     /* legacy drivers scan i²c busses directly */
    10.   & nbsp; if  (driver->attach_adapter)
    11.         driver- >attach_adapter (adapter);
    12.     return 0;
    13. }

The main thing about this function is to call Camera_hw_i2c_driver's detect function, complete the match between the device and the driver, and eventually call Camera_hw_i2c_probe.

Click (here) to collapse or open

    1. static int camera_hw_i2c_detect (struct i2c_client *client, int kind, struct i2c_board_info*info)
    2. {
    3. strcpy (Info->type, camera_hw_drvname);
    4. return 0;
    5. }

In the probe function, one of the most important events registercamera_hwchardrv, this function registers the character device, registers the device node, and creates the class under the device node, the key thing appears

Click (here) to collapse or open

    1. static const struct File_operations G_stcamera_hw_fops =
    2. {
    3. . Owner = This_module,
    4. . open = Camera_hw_open,
    5. . Release = Camera_hw_release,
    6. #ifdef USE_NEW_IOCTL
    7. . Unlocked_ioctl = Camera_hw_ioctl
    8. #else
    9. . IOCTL = Camera_hw_ioctl
    10. #endif
    11. };

Open just initializes an atomic variable left to the system call, Ioctrl is the core, CAMERA_HW_IOCTL is the upper level file operation of the underlying hardware method. The above is the process of Andorid on the camera i²c device.

Andorid Camera Drive Process--MTK platform

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.