【分享】解决VPSS设计中没有media设备的问题
【分享】解决VPSS设计中没有media设备的问题
作者: 付汉杰 hankf@xilinx.com hankf@amd.com
使用hdmi-rx, vpss, frmbuf_write,设计了video输入的pipeline。使用PetaLinux基于XSA做了linux,编译成功,启动也成功。
但是后来查找视频设备,只有video设备,没有media设备。
root@dapd-0330-tpg-peta:~# ls /dev/vid*
/dev/video0 /dev/video1 /dev/video2 /dev/video3 /dev/video4 /dev/video5
root@dapd-0330-tpg-peta:~# ls /dev/medi*
ls: /dev/medi*: No such file or directory
检查启动日志,发现一些异常。比如of_reserved_mem_device_init返回值是负数,表示出错。
[ 3.949086] xlnx,scaler-bridge a4440000.v_proc_ss: xlnx drm scaler experimental driver probed
[ 3.957768] debugfs: File 'xlnx_bridge-v_proc_ss' in directory 'xlnx-bridge' already present!
[ 3.966288] xlnx,scaler-bridge a4480000.v_proc_ss: xlnx drm scaler experimental driver probed
[ 3.974966] debugfs: File 'xlnx_bridge-v_proc_ss' in directory 'xlnx-bridge' already present!
[ 3.983485] xlnx,scaler-bridge a44c0000.v_proc_ss: xlnx drm scaler experimental driver probed
[ 4.307936] xvip_dma_init:1613.
[ 4.311071] xvip_graph_dma_init_one:733.
[ 4.314988] xilinx-video amba_pl@0:vcap_v_proc_ss_12: parsing node ffff0501fdfe7f18
[ 4.314993] xilinx-video amba_pl@0:vcap_v_proc_ss_12: handling endpoint ffff0501fdfe85e0
[ 4.315002] xilinx-video amba_pl@0:vcap_v_proc_ss_12: parsing node ffff0501fdfda748
[ 4.315006] xilinx-video amba_pl@0:vcap_v_proc_ss_12: handling endpoint ffff0501fdfdb648
[ 4.315037] xilinx-video amba_pl@0:vcap_v_proc_ss_12: handling endpoint ffff0501fdfdbac8
[ 4.315046] xilinx-video amba_pl@0:vcap_v_proc_ss_12: parsing node ffff0501fdfe27b8
[ 4.315050] xilinx-video amba_pl@0:vcap_v_proc_ss_12: handling endpoint ffff0501fdfe31c8
[ 4.315057] xilinx-video amba_pl@0:vcap_v_proc_ss_12: xdev->atomic_streamon:0
[ 4.322188] xilinx-video amba_pl@0:vcap_v_proc_ss_12: of_reserved_mem_device_init: -19
[ 4.322192] xilinx-video amba_pl@0:vcap_v_proc_ss_12: device registered
[ 4.328940] xvip_graph_init:798.
[ 4.332163] xvip_graph_dma_init:756.
[ 4.335734] xvip_graph_dma_init:766.
[ 4.339303] xvip_graph_dma_init_one:720.
[ 4.343221] xvip_dma_init:1408.
[ 4.346354] xvip_dma_init:1416.
[ 4.349487] xvip_dma_init:1459.
[ 4.352617] xvip_dma_init:1485.
但是检查下面代码,驱动中虽然报错,但也继续初始化了。看样子,这部分代码不是必须的。
ret = of_reserved_mem_device_init(&pdev->dev);
if (ret) {
dev_dbg(&pdev->dev, "of_reserved_mem_device_init: %d\n", ret);
}
注意到打印中的DRM,意识到这是用于显示的驱动。仔细检查devicetree,PetaLinux自动生成的devicetree如下:
v_proc_ss_12: v_proc_ss@a4380000 {
clock-names = "aclk_axis", "aclk_ctrl";
clocks = <&misc_clk_2>, <&misc_clk_2>;
compatible = "xlnx,v-proc-ss-2.3", "xlnx,vpss-scaler-2.2", "xlnx,v-vpss-scaler-2.2", "xlnx,vpss-scaler";
}
检查Linux代码,发现有两个vpss的驱动。第一个驱动是V4L2的驱动drivers\media\platform\xilinx\xilinx-vpss-scaler.c,它的匹配字符串如下:
static const struct of_device_id xscaler_of_id_table[] = {
{
.compatible = "xlnx,v-vpss-scaler",
.data = &xlnx_scaler
},
{
.compatible = "xlnx,v-vpss-scaler-1.0",
.data = &xlnx_scaler_v1_0
},
{
.compatible = "xlnx,v-vpss-scaler-2.2",
.data = &xlnx_scaler_v2_2
},
{ /* end of table */ }
};
第一个驱动是DRM的驱动drivers\gpu\drm\xlnx\Xlnx_scaler.c,它的匹配字符串如下:
static const struct of_device_id xilinx_scaler_of_match[] = {
{ .compatible = "xlnx,vpss-scaler",
.data = &xlnx_scaler},
{ .compatible = "xlnx,vpss-scaler-2.2",
.data = &xlnx_scaler_v2_2},
{ }
};
PetaLinux自动生成的devicetree的第一个字符串是 "xlnx,v-proc-ss-2.3",都没有匹配。第二个字符串是"xlnx,vpss-scaler-2.2",匹配了DRM的驱动,所以加载了VPSS的DRM驱动。
目前需求是做V4L2的设备,把匹配字符串改为"xlnx,v-vpss-scaler-2.2"。重新编译后,再启动,media设备能够被成功创建。
带调试信息的log如下:
[ 2.880740] xilinx-video amba_pl@0:vcap_v_proc_ss_12: 0 ctrl = 0x98ca21
[ 2.880749] xvip_dma_init:1498.
[ 2.883912] xvip_dma_s_ctrl:1289.
[ 2.887249] xvip_dma_init:1512.
[ 2.890411] xvip_dma_init:1553.
[ 2.893574] xvip_dma_init:1583, dma_request_chan: port0.
[ 2.898928] dma_request_chan:854.
[ 2.902267] dma_request_chan:867.
[ 2.905604] xvip_dma_init:1587: dma_request_chan failed.
[ 2.910963] xilinx-video amba_pl@0:vcap_v_proc_ss_12: /amba_pl@0/vcap_v_proc_ss_12/ports/port@0 initialization failed
[ 2.921656] xvip_graph_dma_init:771 failed.
[ 2.925871] xilinx-video amba_pl@0:vcap_v_proc_ss_12: DMA initialization failed
[ 4.173879] xilinx-video amba_pl@0:vcap_v_proc_ss_12: media_gobj_create id 1: entity 'vcap_v_proc_ss_12 output 0'
[ 4.173883] xilinx-video amba_pl@0:vcap_v_proc_ss_12: media_gobj_create id 2: sink pad 'vcap_v_proc_ss_12 output 0':0
[ 4.173889] xilinx-video amba_pl@0:vcap_v_proc_ss_12: media_gobj_create id 3: intf_devnode v4l-video - major: 81, minor: 0
[ 4.173893] xilinx-video amba_pl@0:vcap_v_proc_ss_12: media_gobj_create id 4: interface link id 3 ==> id 1
[ 4.173896] xvip_dma_init:1613.
[ 4.177026] xvip_graph_dma_init_one:733.
[ 4.180944] xilinx-video amba_pl@0:vcap_v_proc_ss_12: parsing node ffff0501fdfe7f18
[ 4.180949] xilinx-video amba_pl@0:vcap_v_proc_ss_12: handling endpoint ffff0501fdfe85e0
[ 4.180958] xilinx-video amba_pl@0:vcap_v_proc_ss_12: parsing node ffff0501fdfda748
[ 4.180962] xilinx-video amba_pl@0:vcap_v_proc_ss_12: handling endpoint ffff0501fdfdb648
[ 4.180992] xilinx-video amba_pl@0:vcap_v_proc_ss_12: handling endpoint ffff0501fdfdbac8
[ 4.181002] xilinx-video amba_pl@0:vcap_v_proc_ss_12: parsing node ffff0501fdfe27b8
[ 4.181005] xilinx-video amba_pl@0:vcap_v_proc_ss_12: handling endpoint ffff0501fdfe31c8
[ 4.181012] xilinx-video amba_pl@0:vcap_v_proc_ss_12: xdev->atomic_streamon:0
[ 4.188141] xilinx-video amba_pl@0:vcap_v_proc_ss_12: of_reserved_mem_device_init: -19
[ 4.188145] xilinx-video amba_pl@0:vcap_v_proc_ss_12: device registered
[ 4.652349] xilinx-video amba_pl@0:vcap_v_proc_ss_12: Entity type for entity a4570000.v_tpg was not initialized!
[ 4.662530] xilinx-video amba_pl@0:vcap_v_proc_ss_12: media_gobj_create id 5: entity 'a4570000.v_tpg'
[ 4.662535] xilinx-video amba_pl@0:vcap_v_proc_ss_12: media_gobj_create id 6: sink pad 'a4570000.v_tpg':0
[ 4.662538] xilinx-video amba_pl@0:vcap_v_proc_ss_12: media_gobj_create id 7: source pad 'a4570000.v_tpg':1
[ 4.662543] xilinx-video amba_pl@0:vcap_v_proc_ss_12: subdev a4570000.v_tpg bound
[ 4.714757] xilinx-video amba_pl@0:vcap_v_proc_ss_12: Entity type for entity a4380000.v_proc_ss was not initialized!
[ 4.725276] xilinx-video amba_pl@0:vcap_v_proc_ss_12: media_gobj_create id 8: entity 'a4380000.v_proc_ss'
[ 4.725280] xilinx-video amba_pl@0:vcap_v_proc_ss_12: media_gobj_create id 9: sink pad 'a4380000.v_proc_ss':0
[ 4.725284] xilinx-video amba_pl@0:vcap_v_proc_ss_12: media_gobj_create id 10: source pad 'a4380000.v_proc_ss':1
[ 4.725287] xilinx-video amba_pl@0:vcap_v_proc_ss_12: subdev a4380000.v_proc_ss bound
[ 4.725291] xilinx-video amba_pl@0:vcap_v_proc_ss_12: notify complete, all subdevs registered
[ 4.725294] xilinx-video amba_pl@0:vcap_v_proc_ss_12: creating links for entity a4380000.v_proc_ss
[ 4.725299] xilinx-video amba_pl@0:vcap_v_proc_ss_12: processing endpoint ffff0501fdfdb648
[ 4.725308] xilinx-video amba_pl@0:vcap_v_proc_ss_12: skipping DMA port ffff0501fdfda748:1
[ 4.725312] xilinx-video amba_pl@0:vcap_v_proc_ss_12: processing endpoint ffff0501fdfdbac8
[ 4.725319] xilinx-video amba_pl@0:vcap_v_proc_ss_12: skipping sink port ffff0501fdfda748:0
[ 4.725322] xilinx-video amba_pl@0:vcap_v_proc_ss_12: creating links for entity a4570000.v_tpg
[ 4.725326] xilinx-video amba_pl@0:vcap_v_proc_ss_12: processing endpoint ffff0501fdfe31c8
[ 4.725333] xilinx-video amba_pl@0:vcap_v_proc_ss_12: creating a4570000.v_tpg:1 -> a4380000.v_proc_ss:0 link
[ 4.725337] xilinx-video amba_pl@0:vcap_v_proc_ss_12: media_gobj_create id 11: data link id 7 ==> id 9
[ 4.725341] xilinx-video amba_pl@0:vcap_v_proc_ss_12: media_gobj_create id 12: data link id 7 ==> id 9
[ 4.725345] xilinx-video amba_pl@0:vcap_v_proc_ss_12: creating links for DMA engines
[ 4.725354] xilinx-video amba_pl@0:vcap_v_proc_ss_12: processing endpoint /amba_pl@0/vcap_v_proc_ss_12/ports/port@0/endpoint
[ 4.725360] xilinx-video amba_pl@0:vcap_v_proc_ss_12: creating link for DMA engine vcap_v_proc_ss_12 output 0
[ 4.725364] xilinx-video amba_pl@0:vcap_v_proc_ss_12: creating a4380000.v_proc_ss:1 -> vcap_v_proc_ss_12 output 0:0 link
[ 4.725368] xilinx-video amba_pl@0:vcap_v_proc_ss_12: media_gobj_create id 13: data link id 10 ==> id 2
[ 4.725372] xilinx-video amba_pl@0:vcap_v_proc_ss_12: media_gobj_create id 14: data link id 10 ==> id 2
[ 4.725458] xilinx-video amba_pl@0:vcap_v_proc_ss_12: media_gobj_create id 15: intf_devnode v4l-subdev - major: 81, minor: 6
[ 4.725462] xilinx-video amba_pl@0:vcap_v_proc_ss_12: media_gobj_create id 16: interface link id 15 ==> id 5
[ 4.725511] xilinx-video amba_pl@0:vcap_v_proc_ss_12: media_gobj_create id 17: intf_devnode v4l-subdev - major: 81, minor: 7
[ 4.725515] xilinx-video amba_pl@0:vcap_v_proc_ss_12: media_gobj_create id 18: interface link id 17 ==> id 8
[ 4.725561] xilinx-vpss-scaler a4380000.v_proc_ss: Num Hori Taps 6
[ 4.731739] xilinx-vpss-scaler a4380000.v_proc_ss: Num Vert Taps 6
[ 4.737913] xilinx-vpss-scaler a4380000.v_proc_ss: VPSS Scaler Probe Successful
设备信息如下:
root@dapd-0330-tpg-peta:~# ls /dev/video*
/dev/video0 /dev/video1 /dev/video2 /dev/video3 /dev/video4 /dev/video5
root@dapd-0330-tpg-peta:~# ls /dev/med*
/dev/media0 /dev/media1 /dev/media2 /dev/media3 /dev/media4 /dev/media5