Hi xcy,
See below, please!
As for porting camera sensor to android, you should follow these steps:
1. Devie tree
Below source code is for ov5640 mipi in device tree:
&mipi_csi_1 {
#address-cells = <1>;
#size-cells = <0>;
status = "okay";
port {
mipi1_sensor_ep: endpoint1 {
remote-endpoint = <&ov5640_mipi1_ep>;
data-lanes = <2>;
csis-hs-settle = <13>;
csis-clk-settle = <2>;
csis-wclk;
};
csi1_mipi_ep: endpoint2 {
remote-endpoint = <&csi1_ep>;
};
};
};
&i2c3 {
clock-frequency = <100000>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_i2c3>;
status = "okay";
......
ov5640_mipi: ov5640_mipi@3c {
compatible = "ovti,ov5640_mipi";
reg = <0x3c>;
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_csi_pwn>, <&pinctrl_csi_rst>;
clocks = <&clk IMX8MM_CLK_CLKO1_DIV>;
clock-names = "csi_mclk";
assigned-clocks = <&clk IMX8MM_CLK_CLKO1_SRC>,
<&clk IMX8MM_CLK_CLKO1_DIV>;
assigned-clock-parents = <&clk IMX8MM_CLK_24M>;
assigned-clock-rates = <0>, <24000000>;
csi_id = <0>;
pwn-gpios = <&gpio1 7 GPIO_ACTIVE_HIGH>;
mclk = <24000000>;
mclk_source = <0>;
port {
ov5640_mipi1_ep: endpoint {
remote-endpoint = <&mipi1_sensor_ep>;
};
};
};
......
}
you should change above source code to be your camera's.
2. Linux Kernel.
you should add your camera driver to path "~/android_build/vendor/nxp-opensource/kernel_imx/drivers/media/platform/mxc/capture"
(On i.MX8MM EVK board, ov5640 mipi is used, whose driver is ov5640_mipi_v2.c, and camera driver name is "ov5640_mipi")
If you have your camera's driver from provider or wrritten by yourself, you should check if settings in driver are in accordance with configurations in device tree.
3. Camera HAL in android
Our android BSP's source code for camera is ~/android_build/vendor/nxp-opensource/imx/libcamera3, Camera HAL code uses a modular design, it is very convenient to add a new camera.
So you can refer to the implementation of ov5640 Mipi to add your own camera.
for your question:
1. Sensor's name
./CameraUtils.h:62:#define OV5640MIPI_SENSOR_NAME "ov5640_mipi"
./ov5640_mipi_v2.c:433: {"ov5640_mipi", 0},
So Sensor name in HAL should be the same as that of in camera driver.
2. Capture driver name
On i.MX8MM, capture driver is ~/android_build/vendor/nxp-opensource/kernel_imx/drivers/media/platform/mxc/capture/mx6s_capture.c, so defined in init.rc:
setprop back_camera_name mx6s-csi
so you don't need to modify it, even if you use other cameras, here name mx6s-csi shouldn't be modified.
Have a nice day!
BR,
Weidong