【全志平台】A64平台 TP9950 BT656输入驱动调试(1)环境搭建&驱动编写
1. 前言
由于需要在全志A64平台上接入模拟相机,这里选型的模拟转换芯片是TP9950;
(1)TP9950可以通过CSI接口输出,也可以通过并行的BT656接口输出;
(2)由于A64平台没有MIPI接口,只有并行接口【可支持BT656输入】,
所以TP9950只能通过并行接口连接。
2. A64平台环境搭建
由于A64平台是针对android系统的,但是由于驱动部分调试只与内核有关,
所以可以只搭建内核环境,可以不用搭建android环境【这个毕竟也要点时间】。
(1)配置lichee环境
配置完后 运行 ./build.sh
(2) 打包
./build.sh pack
(3)编译完成
(4)烧写镜像
烧写时通过串口输入2,然后插上USB线即可
进入账号输入root即可,然后可以进入linux系统
3. BT656接口camera驱动编写
编写驱动和dts
参考a64/lichee/linux-3.10/drivers/media/platform/sunxi-vfe/device/tw2866.c
(1)移植驱动
a. 修改sensor name, 配置TP9950 init reg
b. i2c addr 0x44 (1000100)
我这边调试的设备TP9950,查看datasheet 得出I2C地址是0x44
另外硬件上也是可以修改I2C地址的
(2)修改平台端接口参数
使用 BT656 接口的器件时,如 TV decoder,一般是输入 PAL/NTSC 两种格式的视频信号,
其信号一般是固定为 UYVY 的,只需要填写一组即可。
static struct sensor_format_struct {
__u8 *desc;
//__u32 pixelformat;
enum v4l2_mbus_pixelcode mbus_code;
struct regval_list *regs;
int regs_size;
int bpp; /* Bytes per pixel */
} sensor_formats[] = {
{
.desc = "UYVY 4:2:2",
.mbus_code = V4L2_MBUS_FMT_UYVY8_2X8,
.regs = sensor_fmt_yuv422_uyvy,
.regs_size = ARRAY_SIZE(sensor_fmt_yuv422_uyvy),
.bpp = 2,
}
主控端需要配置成的相应参数:
并口的 sensor 填写接口参数(YUV/RAW)
static int sensor_g_mbus_config(struct v4l2_subdev *sd,
struct v4l2_mbus_config *cfg)
{
cfg->type = V4L2_MBUS_PARALLEL;
cfg->flags = V4L2_MBUS_MASTER | VREF_POL | HREF_POL | CLK_POL ;
return 0;
}
BT656 信号输入时候填写接口参数(YUV)
static int sensor_g_mbus_config(struct v4l2_subdev *sd,
struct v4l2_mbus_config *cfg)
{
cfg->type = V4L2_MBUS_BT656;
cfg->flags = 0 ;//no use here
return 0;
}
BT656 的设备可以仅仅实现 PAL/NTSC 两种 size,其中 PAL 的是每秒 50 场/25fps,NTSC
是每秒 60 场/30fps,一般是将这种信号以 frame 的形式接受下来(与主控后面显示和编码有
关,一般是接收成 frame 的形式)。如果该器件有其他格式的话逐个实现即可。
static struct sensor_win_size sensor_win_sizes[] = {
/* PAL */
{
.width = 704,
.height = 480,
.hoffset = 0,
.voffset = 0,
.regs = sensor_pal_regs,
.regs_size = ARRAY_SIZE(sensor_pal_regs),
.set_size = NULL,
},
/* NTSC */
{
.width = 704
.height = 576,
.hoffset = 0,
.voffset = 0,
.regs = sensor_ntsc_regs,
.regs_size = ARRAY_SIZE(sensor_ntsc_regs),
.set_size = NULL,
},
};
(3)加载驱动
insmod videobuf2-core.ko
insmod videobuf2-memops.ko
insmod videobuf2-dma-contig.ko
insmod vfe_io.ko
insmod tp9950.ko
insmod vfe_v4l2.ko
# [ 104.510035] [VFE]probe_work_handle start!
[ 104.514633] [VFE]vfe_runtime_resume
[ 104.530018] [VFE]..........................vfe clk open!.......................
[ 104.538011] [VFE]v4l2 subdev register input_num = 0
[ 104.543753] [VFE_ERR]get regulator csi_flvdd error!
[ 104.549074] [VFE_ERR]vfe_device_regulator_get error at input_num = 0
[ 104.556228] [VFE]v4l2 subdev register input_num = 1
[ 104.561657] axp81x_aldo1: Failed to create debugfs directory
[ 104.567839] axp81x_aldo2: Failed to create debugfs directory
[ 104.574235] axp81x_eldo3: Failed to create debugfs directory
[ 104.580526] [VFE_ERR]get regulator csi_flvdd error!
[ 104.585846] [VFE_ERR]vfe_device_regulator_get error at input_num = 1
[ 104.593000] [VFE]V4L2 device registered as (null)
[ 104.598173] [VFE]vfe_runtime_suspend
[ 104.602228] [VFE]..........................vfe clk close!.......................
[ 104.616673] [VFE]probe_work_handle end!
驱动加载出现些问题,改驱动
(4)驱动修改如下
删除flvdd
关闭csi0_dev1
驱动加载正常如下:
[ 38.626013] [VFE]cci probe end cci_sel = 0!
[ 38.631032] [VFE]cci_init end
# insmod tp9950.ko
# insmod vfe_v4l2.ko
[ 47.275979] [VFE]Welcome to Video Front End driver
[ 47.281644] [VFE]csi0 probe end!
[ 47.285597] [VFE]csi_init end
[ 47.289679] [ISP] isp platform_id = 3!
[ 47.293931] [VFE]isp0 probe end!
[ 47.297837] [VFE]sunxi_isp_platform_register end
[ 47.303322] [VFE]mipi_init end
[ 47.306654] [VFE]flash_init end
[ 47.311851] [VFE]pdev->id = 0
[ 47.315086] [VFE]dev->cci_sel = 0
[ 47.318698] [VFE]dev->csi_sel = 0
[ 47.322541] [VFE]dev->mipi_sel = 0
[ 47.326249] [VFE]dev->isp_sel = 0
[ 47.329875] [VFE_WARN]fetch csi0_dev0_twi_id from device_tree failed
[ 47.337085] [VFE_WARN]fetch csi0_dev0_afvdd from device_tree failed
[ 47.344050] [VFE_WARN]fetch csi0_dev0_afvdd_vol from device_tree failed
[ 47.351401] [VFE_WARN]fetch csi0_dev0_power_en from device_tree failed
[ 47.358555] [VFE_WARN]fetch csi0_dev0_flash_en from device_tree failed
[ 47.365930] [VFE_WARN]fetch csi0_dev0_flash_mode from device_tree failed
[ 47.373375] [VFE_WARN]fetch csi0_dev0_flvdd from device_tree failed
[ 47.380340] [VFE_WARN]fetch csi0_dev0_af_pwdn from device_tree failed
[ 47.387980] [VFE]vfe_init end
[ 47.391291] [VFE]probe_work_handle start!
[ 47.395871] [VFE]vfe_runtime_resume
# [ 47.411931] [VFE]..........................vfe clk open!.......................
[ 47.420069] [VFE]v4l2 subdev register input_num = 0
[ 47.425574] [VFE]vfe sensor detect start! input_num = 0
[ 47.431472] [VFE_WARN]NOT found this item: tp9950, you can add this sensor in the sensor_list_t!
[ 47.441325] [VFE]Sub device register "tp9950" i2c_addr = 0x44 start!
[ 47.448262] [VFE]v4l2_device_register_subdev return 0
[ 47.454003] [VFE]registered sensor subdev is OK!
[ 47.459037] [VFE]Check sensor!
[ 47.475237] [TW2866]CSI_SUBDEV_PWR_ON!
[ 47.480632] [VFE]mclk on
[ 47.551459] [TW2866]sensor_init
[ 47.555175] [VFE CCI_0 ERR] Status error at addr_8bit = 44, wr_flag = 1, val = ff
[ 47.563723] [VFE CCI_0 ERR] Status error at addr_8bit = 44, wr_flag = 1, val = ff
[ 47.572264] [VFE CCI_0 ERR] Status error at addr_8bit = 44, wr_flag = 1, val = ff
[ 47.580577] tp9950 sensor read retry=2
[ 47.584663] [TW2866]error at sensor_detect
[ 47.589129] [TW2866]chip found is not an target chip.
[ 47.594876] [TW2866]CSI_SUBDEV_PWR_OFF!
[ 47.599057] [VFE]mclk off
[ 47.638470] [VFE]vfe sensor subdev unregister!
[ 47.643407] [VFE]Sub device register "tp9950" failed!
[ 47.648918] [VFE_ERR]vfe sensor register check error at input_num = 0
[ 47.656178] [VFE]V4L2 device registered as (null)
[ 47.661442] [VFE]vfe_runtime_suspend
[ 47.665339] [VFE]..........................vfe clk close!.......................
[ 47.679781] [VFE]probe_work_handle end!
驱动里面有设备检测机制,检测不到就注销设备,所以看不到video0
(5)删除设备检测机制
驱动加载后video0设备就可以正常出来了
- 分享
- 举报
-
浏览量:8664次2020-09-08 19:26:12
-
浏览量:6984次2020-09-10 09:46:52
-
浏览量:8385次2020-11-26 14:22:19
-
浏览量:10963次2020-12-16 18:56:54
-
浏览量:5598次2020-09-18 11:28:51
-
浏览量:8317次2021-01-20 17:04:49
-
浏览量:8674次2021-01-15 16:31:31
-
浏览量:4209次2020-09-23 19:01:05
-
浏览量:7932次2021-01-08 15:04:53
-
浏览量:7091次2021-01-16 14:52:44
-
浏览量:6028次2020-10-21 16:08:13
-
浏览量:6192次2021-01-15 17:26:20
-
浏览量:10118次2021-01-22 16:07:20
-
浏览量:5535次2021-01-08 16:18:43
-
浏览量:11294次2020-12-16 19:13:45
-
浏览量:3954次2020-10-21 15:44:26
-
浏览量:6666次2020-09-28 16:30:39
-
浏览量:1143次2024-01-09 17:35:19
-
浏览量:6902次2021-01-22 15:28:47
-
广告/SPAM
-
恶意灌水
-
违规内容
-
文不对题
-
重复发帖
free-jdx
感谢您的打赏,如若您也想被打赏,可前往 发表专栏 哦~
举报类型
- 内容涉黄/赌/毒
- 内容侵权/抄袭
- 政治相关
- 涉嫌广告
- 侮辱谩骂
- 其他
详细说明