1 自研rk3566/rk3588+rgbd相机之camera-sensor设定与linux内核配置


本篇文章正式开始进入基于rk3566/rk3588 rgbd相机的开发阶段,首先介绍内核驱动编写前的准备工作,内核配置方法。

1、tof-camera-sensor设定

rgbd相机用到的模组是tof和rgb模组,要点亮tof模组需要对模组写入sensor设定,设定在模组驱动和设备驱动文件编写过程中有重要作用,其设定格式如下:
其中比较重要的几个部分是曝光,图像宽高,增益,以及行和帧长度。几个寄存器在内核驱动文件中需要进行设置与绑定。寄存器通过i2c写入芯片后最后发送 stream on 寄存器指令可以点亮模组。

{0x0100,0x00},
{0x0103,0x00},
{0x3107,0x23},
{0x3108,0x11},
{0x3d01,0x01},
{0x3d08,0x01},
{0x3641,0x00},
{0x3640,0x10},
{0x3018,0x33},
{0x3031,0x0a},
{0x3037,0x24},
{0x303f,0x81},
{0x4603,0x01},
{0x3651,0x45},
{0x3652,0x44},
{0x3652,0x44},
{0x3654,0x44},
{0x3228,0x00},
{0x3226,0x02},
{0x3227,0x00},
{0x3218,0x02},
{0x3219,0x00},
{0x3220,0x10},
{0x3e23,0x30},//exposure
{0x3e24,0x00},
{0x4816,0x41},
{0x3e01,0x03},
{0x3e02,0x03},
{0x3e04,0x03},
{0x3e05,0x03},
{0x3e08,0x03},//ana gain
{0x3e09,0x40},//ana gain fine
{0x3e06,0x01},//dig gain
{0x3e07,0x94},//dig gain fine
{0x3235,0x00},
{0x3236,0x00},
{0x3802,0x00},
{0x3221,0x00},//mirror 
{0x3208,0x80},//width
{0x3209,0x07},//width
{0x320a,0x38},//height
{0x320b,0x04},//height
{0x3210,0x08},
{0x3211,0x00},
{0x3212,0x08},
{0x3213,0x00},
{0x320c,0x4c},//line length
{0x320d,0x04},//line length
{0x320e,0x65},//frame length
{0x320f,0x04},//frame length
{0x4501,0xac},
{0x3902,0x05},
{0x0100,0x01},//streaming on 

该sensor设定会写入到内核驱动文件中与设备驱动程序一同编译。

2、linux内核配置

有了设定后可以对开始linux内核驱动程序的编写,编写前的准备工作是对linux的内核进行配置保证能够加载驱动程序到内核中。

修改内核配置文件

kernel/arch/arm64/config/firefly_linux_defconfig
增加需要添加的驱动文件增加一行 CONFIG_VIDEO_S5K33D_48=y,保证内核编译时能找到驱动文件s5k33d_48.c

CONFIG_V4L_PLATFORM_DRIVERS=y
CONFIG_SOC_CAMERA=y
CONFIG_VIDEO_ROCKCHIP_CIF=y
CONFIG_VIDEO_ROCKCHIP_ISP1=y
CONFIG_VIDEO_ROCKCHIP_ISP=y
CONFIG_V4L_MEM2MEM_DRIVERS=y
CONFIG_VIDEO_ROCKCHIP_RGA=y
# CONFIG_MEDIA_SUBDRV_AUTOSELECT is not set
CONFIG_VIDEO_TC35874X=y
CONFIG_VIDEO_OS04A10=y
CONFIG_VIDEO_OV4689=y
CONFIG_VIDEO_OV5695=y
CONFIG_VIDEO_OV7251=y
CONFIG_VIDEO_OV13850=y
CONFIG_VIDEO_S5K33D_48=y
CONFIG_VIDEO_SC2310=y
CONFIG_VIDEO_GC2053=y
CONFIG_VIDEO_GC2093=y
CONFIG_VIDEO_GC8034=y
CONFIG_VIDEO_XC7022=y
CONFIG_VIDEO_XC7160=y
# CONFIG_VGA_ARB is not set
CONFIG_DRM=y
CONFIG_DRM_IGNORE_IOTCL_PERMIT=y
CONFIG_DRM_LOAD_EDID_FIRMWARE=y
CONFIG_DRM_ROCKCHIP=y
CONFIG_ROCKCHIP_ANALOGIX_DP=y

添加新内核文件配置文件:Kconfig Makefile

目录:kernel/drivers/media/i2c/Kconfig
目录:kernel/drivers/media/i2c/Makefile
kconfig 文件增加 config VIDEO_S5K33D_48 部分,内容可以参考其他部分配置,为了内核配置时能够识别到该新增选项。


source "drivers/media/i2c/m5mols/Kconfig"

config VIDEO_RJ54N1
	tristate "Sharp RJ54N1CB0C sensor support"
	depends on I2C && VIDEO_V4L2
	depends on MEDIA_CAMERA_SUPPORT
	help
	  This is a V4L2 sensor driver for Sharp RJ54N1CB0C CMOS image
	  sensor.

	  To compile this driver as a module, choose M here: the
	  module will be called rj54n1.

config VIDEO_S5K6AA
	tristate "Samsung S5K6AAFX sensor support"
	depends on MEDIA_CAMERA_SUPPORT
	depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API
	---help---
	  This is a V4L2 sensor driver for Samsung S5K6AA(FX) 1.3M
	  camera sensor with an embedded SoC image signal processor.

config VIDEO_S5K6A3
	tristate "Samsung S5K6A3 sensor support"
	depends on MEDIA_CAMERA_SUPPORT
	depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API
	---help---
	  This is a V4L2 sensor driver for Samsung S5K6A3 raw
	  camera sensor.

config VIDEO_S5K33D_48
	tristate "Samsung S5K33D_48 sensor support"
	depends on MEDIA_CAMERA_SUPPORT
	depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API
	---help---
	  This is a V4L2 sensor driver for Samsung S5K33D_48 raw
	  camera sensor.

config VIDEO_S5KGM1SP
	tristate "Samsung S5KGM1SP sensor support"
	depends on MEDIA_CAMERA_SUPPORT
	depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API
	help
	  This is a V4L2 sensor driver for Samsung S5KGM1SP raw
	  camera sensor.

config VIDEO_S5K4H7YX
	tristate "Samsung S5K4H7YX sensor support"
	depends on MEDIA_CAMERA_SUPPORT
	depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API
	help
	  This is a V4L2 sensor driver for Samsung S5K4H7YX raw
	  camera sensor.

config VIDEO_S5K4ECGX
	tristate "Samsung S5K4ECGX sensor support"
	depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API
	select CRC32
	---help---
	  This is a V4L2 sensor driver for Samsung S5K4ECGX 5M
	  camera sensor with an embedded SoC image signal processor.

config VIDEO_S5K5BAF
	tristate "Samsung S5K5BAF sensor support"
	depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API
	select V4L2_FWNODE
	---help---
	  This is a V4L2 sensor driver for Samsung S5K5BAF 2M
	  camera sensor with an embedded SoC image signal processor.

source "drivers/media/i2c/smiapp/Kconfig"
source "drivers/media/i2c/et8ek8/Kconfig"


makefile文件增加如下内容:obj-$(CONFIG_VIDEO_S5K33D_48) += s5k33d_48.o为了编译内核时能够识别到设备驱动文件。同时makefile文件已经有了 sc2310部分因此不用新增rgb的驱动文件。可以看到makefile中已经包含了大多数sensor厂家的驱动程序因此省去了rgb模组驱动编写的工作量,因为tof模组都是新的芯片,因此大多linux内核都不支持驱动,需要自行编写。

obj-$(CONFIG_VIDEO_OV5648)	+= ov5648.o
obj-$(CONFIG_VIDEO_OV5670) += ov5670.o
obj-$(CONFIG_VIDEO_OV5695) += ov5695.o
obj-$(CONFIG_VIDEO_OV6650) += ov6650.o
obj-$(CONFIG_VIDEO_OV7251) += ov7251.o
obj-$(CONFIG_VIDEO_OV7640) += ov7640.o
obj-$(CONFIG_VIDEO_OV7670) += ov7670.o
obj-$(CONFIG_VIDEO_OV772X) += ov772x.o
obj-$(CONFIG_VIDEO_OV7740) += ov7740.o
obj-$(CONFIG_VIDEO_OV7750) += ov7750.o
obj-$(CONFIG_VIDEO_OV8858)	+= ov8858.o
obj-$(CONFIG_VIDEO_OV9281)	+= ov9281.o
obj-$(CONFIG_VIDEO_OV9650) += ov9650.o
obj-$(CONFIG_VIDEO_OV9750) += ov9750.o
obj-$(CONFIG_VIDEO_OV12D2Q) += ov12d2q.o
obj-$(CONFIG_VIDEO_OV13850) += ov13850.o
obj-$(CONFIG_VIDEO_OV13858) += ov13858.o
obj-$(CONFIG_VIDEO_OV13B10)	+= ov13b10.o
obj-$(CONFIG_VIDEO_S5K33D_48)	+= s5k33d_48.o
obj-$(CONFIG_VIDEO_MT9M032) += mt9m032.o
obj-$(CONFIG_VIDEO_MT9M111) += mt9m111.o
obj-$(CONFIG_VIDEO_MT9P031) += mt9p031.o
obj-$(CONFIG_VIDEO_MT9T001) += mt9t001.o
obj-$(CONFIG_VIDEO_MT9T112) += mt9t112.o
obj-$(CONFIG_VIDEO_MT9V011) += mt9v011.o
obj-$(CONFIG_VIDEO_MT9V032) += mt9v032.o
obj-$(CONFIG_VIDEO_MT9V111) += mt9v111.o
obj-$(CONFIG_VIDEO_AR0230)	+= ar0230.o
obj-$(CONFIG_VIDEO_SC031GS)	+= sc031gs.o
obj-$(CONFIG_VIDEO_SC035HGS)	+= sc035hgs.o
obj-$(CONFIG_VIDEO_SC1330)	+= sc1330.o
obj-$(CONFIG_VIDEO_SC132GS)	+= sc132gs.o
obj-$(CONFIG_VIDEO_SC200AI)	+= sc200ai.o
obj-$(CONFIG_VIDEO_SC210IOT)	+= sc210iot.o
obj-$(CONFIG_VIDEO_SC2232)	+= sc2232.o
obj-$(CONFIG_VIDEO_SC2239)	+= sc2239.o
obj-$(CONFIG_VIDEO_SC223A)	+= sc223a.o
obj-$(CONFIG_VIDEO_SC2310)	+= sc2310.o
obj-$(CONFIG_VIDEO_SC2335)	+= sc2335.o
obj-$(CONFIG_VIDEO_SC2355)	+= sc2355.o

以上就把tof模组的设备驱动文件增加到了rk3566的linux内核中,并且编译时会进行编译并更新到内核中,后续接上tof模组到mipi接口就会进行驱动的探测。
下一篇文章讲解设备树文件的配置

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

三十度角阳光的问候

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值