Android下的摄像头驱动开发

Android下的摄像头驱动开发

这几天拿到一个MINI210开发板,于是尝试着把ov7670移植到开发板上.仔细的观察了一下友善给的驱动发现友善提供了ov9650的驱动,因为ov7670和ov9650的驱动比较类似.于是想在ov9650的基础上改动一下. 但是进入/opt/FriendlyARM/mini210/android/linux-2.6.35.7-android/drivers/media/video目录没有发现跟ov9650相关的源文件.看了一下Makefile 文件才知道友善竟然没有提供ov9650的源码(鄙视一下友善).

那只好自己动手了:

1.在”/opt/FriendlyARM/mini210/android/linux-2.6.35.7-android/drivers/media/video”目录下增加两个文件”fpov7670.c”和”fpov7670.h”.

2.在”/opt/FriendlyARM/mini210/android/linux-2.6.35.7-android/drivers/media/video”目录下找到”Makefile”这个文件.增加一行

1
2
“obj-$(CONFIG_VIDEO_FPOV7670)     += fpov7670.o”.

3.在”/opt/FriendlyARM/mini210/android/linux-2.6.35.7-android/drivers/media/video”目录下找到”Kconfig”

增加下面5行

1
2
3
4
5
6
config VIDEO_FPOV7670
  tristate "FPOV7670 Camera Sensor"
  depends on I2C && VIDEO_V4L2
  ---help---
  This driver supports FPOV7670 SoC camera module

4.最重要的是修改代码了.参照”s5k4ba.c”和”s5k4ba.h” 把”fpov7670.c”和”fpov7670.h”修改了.主要吧IIC配置修改即可.然后找到/opt/FriendlyARM/mini210/android/linux-2.6.35.7-android/arch/arm/mach-s5pv210/mach-mini210.c,加入fpov7670的配置.

01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#ifdef CONFIG_VIDEO_FPOV7670
  
static int ov7670_power_en( int onoff)
  {
  printk( "ov7670_power_en: power %s\n" , onoff ? "ON" : "Off" );
  return 0;
  }
  
static struct fpov7670_platform_data ov7670_plat = {
  .default_width = 640,
  .default_height = 480,
  .pixelformat = V4L2_PIX_FMT_YUYV,
  .freq = 40000000,
  .is_mipi = 0,
  };
  static struct i2c_board_info  ov7670_i2c_info = {
  I2C_BOARD_INFO( "FPOV7670" , (0x42>>1)),
  .platform_data = &ov7670_plat,
  };
  
static struct s3c_platform_camera ov7670 = {
  .id        = CAMERA_PAR_A,
  .type        = CAM_TYPE_ITU,
  .fmt        = ITU_601_YCBCR422_8BIT,
  .order422    = CAM_ORDER422_8BIT_CBYCRY,
  .i2c_busnum    = 0,
  .info        = &ov7670_i2c_info,
  .pixelformat    = V4L2_PIX_FMT_YUYV,
  .srclk_name    = "mout_mpll" ,
  /* .srclk_name    = "xusbxti", */
  .clk_name    = "sclk_cam1" ,
  .clk_rate    = 40000000,
  .line_length    = 640,
  .width        = 640,
  .height        = 480,
  .window        = {
  .left    = 0,
  .top    = 0,
  .width    = 640,
  .height    = 480,
  },
  /* Polarity */
  .inv_pclk    = 1,
  .inv_vsync    = 1,
  .inv_href    = 0,
  .inv_hsync    = 0,
  
.initialized    = 0,
  .cam_power    = ov7670_power_en,
  };
  
#endif

在驱动列表中加入ov7670驱动

01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/* Interface setting */
  static struct s3c_platform_fimc fimc_plat_lsi = {
  .srclk_name    = "mout_mpll" ,
  .clk_name    = "sclk_fimc" ,
  .lclk_name    = "sclk_fimc_lclk" ,
  .clk_rate    = 166750000,
  #if defined(CONFIG_VIDEO_S5K4EA)
  .default_cam    = CAMERA_CSI_C,
  #else
  #ifdef CAM_ITU_CH_A
  .default_cam    = CAMERA_PAR_A,
  #else
  .default_cam    = CAMERA_PAR_B,
  #endif
  #endif
  .camera        = {
  #ifdef CONFIG_VIDEO_S5K4ECGX
  &s5k4ecgx,
  #endif
  #ifdef CONFIG_VIDEO_S5KA3DFX
  &s5ka3dfx,
  #endif
  #ifdef CONFIG_VIDEO_S5K4BA
  &s5k4ba,
  #endif
  #ifdef CONFIG_VIDEO_S5K4EA
  &s5k4ea,
  #endif
  #ifdef CONFIG_VIDEO_OV9650
  &ov9650,
  #endif
  #ifdef CONFIG_VIDEO_FPOV7670//新加入
  &ov7670, //新加入
  #endif //新加入
  },
  .hw_ver        = 0x43,
  };

5.在”/opt/FriendlyARM/mini210/android/linux-2.6.35.7-android”目录下 输入”make menuconfig” 回车,选择FPOV7670之后,make之.成功后把zImage烧入开发板.打开摄像头测试,出图了.

注意,因为我们FPOV7670的驱动是用在指纹采集上并不需要”自动曝光””调节白平衡”等功能.如果是用在拍照上,就需要加入上述功能.

你可能感兴趣的:(Android,Camera)