Camera Kernel module load order

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Camera Kernel module load order

跳至解决方案
4,843 次查看
dennis3
Contributor V

I'm working on bringing up a mipi camera on the imx8mp board.   Android 11 2.2.0 is using GKI kernel config, which means all the custom modules we use for our board are compiled as .ko objects.  Even if I select to compile them as built in modules, the build process modifies the .config and creates kernel modules anyway.  But I think whether it is built in or external isn't the most important issue.

The problem is, that the imx8_media_dev module is loading before my camera module.  So when that module loads, it isn't finding any cameras.  Here is the output:

[    1.304994] mxc-isi 32e00000.isi: mxc_isi.0 registered successfully
[    1.338977] mx8-img-md: Registered mxc_isi.0.capture as /dev/video2
[    1.351040] unregister ISI channel: mxc_isi.0

After unregister, there is no longer a /dev/video2 device.

My camera kernel module loads slightly thereafter and never does anything because no video links are created.

The Basler kernel module loads before the imx8_media_dev module and if we're using that camera, video links are created and all works as expected.  In addition, if I manually unload the imx8_media_dev module after boot, and manually load it again (having already loaded our camera driver), the video links are created properly and our camera can work.

So I seem to be missing something in the build process or setup of our system that ensures our camera driver loads before imx8_media_dev.  Can someone suggest how this is accomplished?  I've placed my kernel module in the vendor_ramdisk, same location as the Basler kernel module is located but that doesn't seem to do the trick.

 

标记 (1)
0 项奖励
回复
1 解答
4,609 次查看
dennis3
Contributor V

In case anyone comes across this, it seems the module load order can be controlled.  We just needed to put our camera module after the appropriate CSI modules in SharedBoardConfig.mk.  The CSI modules can then load first and the camera module does cause the appropriate channels to be created.

在原帖中查看解决方案

0 项奖励
回复
8 回复数
4,610 次查看
dennis3
Contributor V

In case anyone comes across this, it seems the module load order can be controlled.  We just needed to put our camera module after the appropriate CSI modules in SharedBoardConfig.mk.  The CSI modules can then load first and the camera module does cause the appropriate channels to be created.

0 项奖励
回复
4,788 次查看
joanxie
NXP TechSupport
NXP TechSupport

did you try the demo images? what board do you use? nxp board or customized board? I haven't tested this version before, let me reproduce this

0 项奖励
回复
4,786 次查看
dennis3
Contributor V

The demo image works fine with the Basler camera demo.  (Variscite Development Board).

Only our custom camera driver (which is very similar to Basler) loads AFTER media-dev instead of before.. causing the issue.

I have worked around the issue by modifying the gki_config to have built in mipi and csi drivers as well as our camera driver and this allows our camera to load before media dev and establish a camera media channel.  This doesn't seem to be the correct solution though as it would be more desirable to not modify the default gki_config for the board.

0 项奖励
回复
4,832 次查看
artsiomstaliaro
Contributor IV

Did you add I2C handle of the camera? Which camera are you using?

0 项奖励
回复
4,818 次查看
dennis3
Contributor V

We use a custom camera and ISP.  The driver is very similar to the OV5640 or Basler sample cameras though.

I'm not sure what you mean by an I2C handle.  This is our v4l subbev init code though:

    v4l2_i2c_subdev_init(sd, client, &camera_subdev_ops);

    sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE|V4L2_SUBDEV_FL_IS_I2C;
    sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
    camera_data.pad.flags = MEDIA_PAD_FL_SOURCE;
    sd->entity.ops = &camera_sd_media_ops;
    retval = media_entity_pads_init(&sd->entity, 1, &camera_data.pad);
    if (retval<0) {
        dev_err(&client->dev, "media entity pad init fail: %d", retval );
        return retval;
     }

    retval = v4l2_async_register_subdev_sensor_common(sd);
0 项奖励
回复
4,774 次查看
joanxie
NXP TechSupport
NXP TechSupport

which camera do you refer to? basler or ov5640, they use the different path

0 项奖励
回复
4,769 次查看
dennis3
Contributor V

Our camera driver is more similar to the ov5640 driver.

0 项奖励
回复
4,740 次查看
joanxie
NXP TechSupport
NXP TechSupport

what source code do you change? pls share your dts file with me

0 项奖励
回复