Android S5PV210 camera S_INPUT实现


分类: Samsung S5PV210   746人阅读  评论(0)  收藏  举报

三星平台的capture设备节点是/dev/fimc0,但是平台可能存在多个摄像头,更特殊的情况是一个video ADC芯片外接多个模拟摄像头,这几天研究了下如何选择capture的摄像头,做个总结。


先对摄像头做个分类,1. CMM CameraCompact Module 摄像头模组; 2. VIDEO ADC + 模拟摄像头

视频源的选择是通过VIDIOC_S_INPUT来实现的,这里的视频源既可以是上面第一类的CMM,也可以是第二类的ADC加一个模拟摄像头,video ADC挂几个模拟摄像头就对应几个视频源。

三星FIMC框架为每一个视频源定义了一个结构,以mach-smdkc110.c为例。

[cpp]  view plain copy
  1. 1901 static struct s3c_platform_fimc fimc_plat_lsi = {  
  2. 1902     .srclk_name = "mout_mpll",  
  3. 1903     .clk_name   = "sclk_fimc",  
  4. 1904     .lclk_name  = "sclk_fimc_lclk",  
  5. 1905     .clk_rate   = 166750000,  
  6. 1906 #if defined(CONFIG_VIDEO_S5K4EA)  
  7. 1907     .default_cam    = CAMERA_CSI_C,  
  8. 1908 #else  
  9. 1909 #ifdef CAM_ITU_CH_A  
  10. 1910     .default_cam    = CAMERA_PAR_A,  
  11. 1911 #else  
  12. 1912     .default_cam    = CAMERA_PAR_B,  
  13. 1913 #endif  
  14. 1914 #endif  
  15. 1915     .camera     = {  
  16. 1916 #ifdef CONFIG_VIDEO_S5K4ECGX  
  17. 1917             &s5k4ecgx,  
  18. 1918 #endif  
  19. 1919 #ifdef CONFIG_VIDEO_S5KA3DFX  
  20. 1920             &s5ka3dfx,  
  21. 1921 #endif  
  22. 1922 #ifdef CONFIG_VIDEO_S5K4BA  
  23. 1923             &s5k4ba,  
  24. 1924 #endif  
  25. 1925 #ifdef CONFIG_VIDEO_S5K4EA  
  26. 1926             &s5k4ea,  
  27. 1927 #endif  
  28. 1928 #ifdef CONFIG_VIDEO_CAM8000  
  29. 1929             &cam8000,  
  30. 1930 #endif  
  31. 1931 #ifdef CONFIG_VIDEO_TW9912  
  32. 1932             &tw9912_1,  
  33. 1933             &tw9912_2,  
  34. 1934 #endif  
  35. 1935     },  
  36. 1936     .hw_ver     = 0x43,  
  37. 1937 };  

1918 ~ 1938 .camera成员定义了系统可能的视频源,其中s5k4ecgx, s5ka3dfx, s5k4ba, s5k4ea是四个CMM模组, cam8000原生代码的Video ADC,tw9912_1和tw9912_2是我定义的两个camera 视频源,为什么一个TW9912 Video ADC要定义成两个,这是因为在我的项目中TW9912存在两路输入,一个是CVBS另外一个是YPbPr,我认为他们和 TW9912组成了两个camera 视频源。

下面代码演示了如何区分这两个camera通道

[cpp]  view plain copy
  1. 1831 static struct s3c_platform_camera tw9912_1 = {  
  2. 1832     .id     = CAMERA_PAR_A,  
  3. 1833     .type       = CAM_TYPE_ITU,  
  4. 1834     .fmt        = ITU_656_YCBCR422_8BIT,  
  5. 1835     .order422   = CAM_ORDER422_8BIT_CBYCRY,  
  6. 1836     .i2c_busnum = 1,  
  7. 1837     .info       = &tw9912_1_i2c_info,  
  8. 1838     .pixelformat = V4L2_PIX_FMT_YUYV,  
  9. 1839     .srclk_name = "mout_mpll",  
  10. 1840     .clk_name   = "sclk_cam0",  
  11. 1841     .clk_rate   = 44000000,  
  12. 1842     .line_length = 1440,  
  13. 1843     .width      = 720,  
  14. 1844     .height     = 576,  
  15. 1845     .window     = {  
  16. 1846         .left   = 0,  
  17. 1847         .top    = 0,  
  18. 1848         .width  = 720,  
  19. 1849         .height = 576,  
  20. 1850     },  
  21. 1851  
  22. 1852     /* Polarity */  
  23. 1853     .inv_pclk   = 0,  
  24. 1854     .inv_vsync  = 0,  
  25. 1855     .inv_href   = 0,  
  26. 1856     .inv_hsync  = 0,  
  27. 1857  
  28. 1858     .initialized    = 0,  
  29. 1859     /* 
  30. 1860      * It is too late to call camera sensor poweron in fimc_camera_init 
  31. 1861      * so we move power function to board init 
  32. 1862      */  
  33. 1863     .cam_power  = NULL,  
  34. 1864 };  
  35.   
  36. 1866 static struct s3c_platform_camera tw9912_2 = {  
  37. 1867     .id     = CAMERA_PAR_A,  
  38. 1868     .type       = CAM_TYPE_ITU,  
  39. 1869     .fmt        = ITU_656_YCBCR422_8BIT,  
  40. 1870     .order422   = CAM_ORDER422_8BIT_CBYCRY,  
  41. 1871     .i2c_busnum = 1,  
  42. 1872     .info       = &tw9912_2_i2c_info,  
  43. 1873     .pixelformat = V4L2_PIX_FMT_YUYV,  
  44. 1874     .srclk_name = "mout_mpll",  
  45. 1875     .clk_name   = "sclk_cam0",  
  46. 1876     .clk_rate   = 44000000,  
  47. 1877     .line_length = 1440,  
  48. 1878     .width      = 720,  
  49. 1879     .height     = 576,  
  50. 1880     .window     = {  
  51. 1881         .left   = 0,  
  52. 1882         .top    = 0,  
  53. 1883         .width  = 720,  
  54. 1884         .height = 576,  
  55. 1885     },  
  56. 1886  
  57. 1887     /* Polarity */  
  58. 1888     .inv_pclk   = 0,  
  59. 1889     .inv_vsync  = 0,  
  60. 1890     .inv_href   = 0,  
  61. 1891     .inv_hsync  = 0,  
  62. 1892  
  63. 1893     .initialized    = 0,  
  64. 1894     /* 
  65. 1895      * It is too late to call camera sensor poweron in fimc_camera_init 
  66. 1896      * so we move power function to board init 
  67. 1897      */  
  68. 1898     .cam_power  = NULL,  
  69. 1899 };  



他们唯一不同的地方在于.info成员,分别为tw9912_1_i2c_info 和tw9912_2_i2c_info

[cpp]  view plain copy
  1. 1796 static struct tw9912_platform_data tw9912_1_plat = {  
  2. 1797     .default_width = 720,  
  3. 1798     .default_height = 576,  
  4. 1799     .pixelformat = V4L2_PIX_FMT_YUYV,  
  5. 1800     .ifsel = 0,  
  6. 1801     .ysel = 0,  
  7. 1802     .csel = 0,  
  8. 1803     .vsel = 0,  
  9. 1804     .cam_reset = tw9912_reset,  
  10. 1805 };  
  11. 1806  
  12. 1807 static struct tw9912_platform_data tw9912_2_plat = {  
  13. 1808     .default_width = 720,  
  14. 1809     .default_height = 576,  
  15. 1810     .pixelformat = V4L2_PIX_FMT_YUYV,  
  16. 1811     .ifsel = 0x20,  
  17. 1812     .ysel = 0x08,  
  18. 1813     .csel = 0x2,  
  19. 1814     .vsel = 0,  
  20. 1815     .cam_reset = tw9912_reset,  
  21. 1816 };    
  22. 1817  
  23. 1818 static struct i2c_board_info  tw9912_1_i2c_info = {  
  24. 1819     I2C_BOARD_INFO("tw9912", (0x88 >> 1)),  
  25. 1820     .platform_data = &tw9912_1_plat,  
  26. 1821 };    
  27. 1822  
  28. 1823 static struct i2c_board_info  tw9912_2_i2c_info = {  
  29. 1824     I2C_BOARD_INFO("tw9912", (0x88 >> 1)),  
  30. 1825     .platform_data = &tw9912_2_plat,  
  31. 1826 };    

i2c_board_info不同的地方是ifsel, ysel, csel, vsel成员,这几个成员对应着tw9912 0x02寄存器(input format)寄存器位

这是tw9912_1和tw9912_2唯一有差别的地方。


当上层调用VIDIOC_S_INPUT时,调用路径如下

fimc_s_input->fimc_configure_subdev->v4l2_i2c_new_subdev_board->v4l2_subdev_call(sd, core, s_config, info->irq, info->platform_data)->

v4l2_subdev_call(sd, core, s_config, info->irq, info->platform_data)调用sd->ops->core->s_config, 这个函数需要在tw9912驱动中实现,info->platform_data就是在mach-smkvc110.c中定义的tw9912_1_i2c_info或者tw9912_2_i2c_info,因此在s_config实现中就可以根据i2c_board_info.platform_data中的ifsel, ysel, csel, vsel来设置tw9912的输入


总结一下:

1. video ADC芯片驱动要通过s_config来实现视频源的切换

2. 为video ADC的每个输入创建一个s3c_platform_camera 结构,通过i2c_board_info.platform_data来体现输入的差异性


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值