ERROR CameraSensor camera_sensor.cpp:127 No image format found
deva seetharam
tagsense at yahoo.com
Fri Mar 15 13:31:14 CET 2024
Thank you once again, Dave!
I have changed the code to use only the first (and only) entry in codes array as follows. However, as per dmesg, these functions are getting called repeatedly. When I run libcamera-hello or rpicam-hello, it prints one line ([0:41:31.852290414] [10447] INFO Camera camera_manager.cpp:284 libcamera v0.2.0+46-075b54d5] and hangs. I don't know how to proceed. Please advise.
As you guessed, I read the codes drivers of image sensors such as imx219 to write this driver.
I read books such as the ones by Rubini and Madieu, and many web pages such as Video for Linux 2 API pages, etc. But, I could not get a clear picture of the structure of a V4L2 driver for an image sensor.
Could you please recommend any relevant material? Thank you!
static u32 oah0428_get_format_code(struct xyz123 *xyz123, u32 code)
{
unsigned int i;
struct i2c_client *client = v4l2_get_subdevdata(&xyz123->sd);
dev_dbg(&client->dev,
"%s has been invoked to get format code of xyz123.\n",
__func__);
return codes[0];
}
static int xyz123_enum_mbus_code(struct v4l2_subdev *sd,
struct v4l2_subdev_state *sd_state,
struct v4l2_subdev_mbus_code_enum *code)
{
struct xyz123 *xyz123 = to_xyz123(sd);
struct i2c_client *client = v4l2_get_subdevdata(&xyz123->sd);
dev_dbg(&client->dev, "%s has been invoked.\n", __func__);
mutex_lock(&xyz123->mutex);
code->code = xyz123_get_format_code(xyz123, codes[0]);
mutex_unlock(&xyz123->mutex);
return 0;
}
On Wednesday, March 13, 2024 at 04:46:46 PM GMT+5:30, Dave Stevenson <dave.stevenson at raspberrypi.com> wrote:
Hi Deva
On Wed, 13 Mar 2024 at 03:28, deva seetharam <tagsense at yahoo.com> wrote:
>
> Thank you, Dave and Laurent, for your inputs. I am not the decision maker about open sourcing. But, I talked to the client. They are saying they will open source the driver, if this sensor is released as a product. At this stage, it is just a skunk project to check the feasibility.
> Here is the driver prototype source code for your review and advice: https://pastebin.com/nGkJsZP0.
> Looking forward to your advice on fixing the issues. Thank you!
So it is as I hypothesised - you're not advertising the formats correctly.
static const u32 codes[] = {MEDIA_BUS_FMT_SBGGR10_1X10};
...
static int xyz123_enum_mbus_code(struct v4l2_subdev *sd,
struct v4l2_subdev_state *sd_state,
struct v4l2_subdev_mbus_code_enum *code)
{
...
if (code->index >= (ARRAY_SIZE(codes) / 4))
{
dev_err(&client->dev, "In %s, code-> index is too large: %d.\n",
__func__, code->index);
return -EINVAL;
}
ARRAY_SIZE(codes) = 1, so ARRAY_SIZE(codes) / 4 = 0 (integer maths).
You've presumably copied from imx219 or similar which has an array in
codes due to the Bayer order changing due to flips. You've removed
bits of that, but not here.
I'd confirm whether your sensor does change Bayer order or not with
flips, and either reinstate it or totally remove it.
Dave
>
>
> On Monday, March 11, 2024 at 07:34:04 PM GMT+5:30, Dave Stevenson <dave.stevenson at raspberrypi.com> wrote:
>
>
>
>
>
> Hi Deva
>
> On Sat, 9 Mar 2024 at 11:00, deva seetharam <tagsense at yahoo.com> wrote:
> >
> > Greetings!!
> >
> > For a new image sensor (due to a restrictive NDA, cannot reveal the manufacturer or the part number), I have to create the device tree source file and the kernel driver. I have compiled and installed the device tree and kernel module. I see the kernel module is getting loaded and the overlay is getting accepted into device tree. However, when I run libcamera, I get the following error:
> >
> > [0:00:41.253567807] [1920] ERROR CameraSensor camera_sensor.cpp:127 'xyz123 10-0036': No image format found
> > [0:00:41.253599677] [1920] ERROR RPI vc4.cpp:216 Failed to register camera xyz123 10-0036: -22
>
> Address 0x36 - that'll likely be Omnivision then.
>
> > Please suggest how this error can be fixed. Thank you!
> >
> > I am also including the dts file, (relevant portions of) lsmod and dmesg outputs.
> >
> >
> > the device tree overlay file is as follows:
> > <pre>
> > /dts-v1/;
> > /plugin/;
> >
> >
> > #include <dt-bindings/gpio/gpio.h>
> >
> >
> > / {
> > compatible = "brcm,bcm2835";
> >
> >
> > fragment at 0 {
> > target = <&i2c0if>;
> > __overlay__ {
> > status = "okay";
> > };
> > };
> >
> >
> > clk_frag: fragment at 1 {
> > target = <&cam1_clk>;
> > __overlay__ {
> > status = "okay";
> > clock-frequency = <24000000>;
> > };
> > };
> >
> >
> > i2c_frag: fragment at 100 {
> > target = <&i2c_csi_dsi>;
> > __overlay__ {
> > #address-cells = <1>;
> > #size-cells = <0>;
> > status = "okay";
> >
> >
> > xyz123: xyz123 at 36 {
> > compatible = "abc,xyz123";
> > reg = <0x36>;
> >
> >
> > clocks = <&cam1_clk>;
> > clock-names = "xclk";
> >
> >
> > port {
> > cam_endpoint: endpoint {
> > clock-lanes = <0>;
> > data-lanes = <1 2>;
> > clock-noncontinuous;
> > link-frequencies = /bits/ 64 <192000000>;
> > };
> > };
> > };
> > };
> > };
> >
> >
> > csi_frag: fragment at 101 {
> > target = <&csi1>;
> > csi: __overlay__ {
> > status = "okay";
> > brcm,media-controller;
> >
> >
> > port {
> > csi_ep: endpoint {
> > remote-endpoint = <&cam_endpoint>;
> > clock-lanes = <0>;
> > data-lanes = <1 2>;
> > clock-noncontinuous;
> > };
> > };
> > };
> > };
> >
> >
> > };
> >
> >
> > &xyz123 {
> > status = "okay";
> > default-width = <720>;
> > default-height = <720>;
> > };
> >
> >
> > &cam_endpoint {
> > remote-endpoint = <&csi_ep>;
> > };
> >
> >
> >
> > the output of lsmod is as follows:
> > <pre>
> > xyz123 24576 1
> > v4l2_fwnode 24576 2 xyz123,bcm2835_unicam
> > v4l2_async 24576 3 v4l2_fwnode,xyz123,bcm2835_unicam
> > videodev 278528 10 v4l2_async,bcm2835_codec,xyz123,videobuf2_v4l2,bcm2835_unicam,bcm2835_v4l2,videobuf2_common,rpivid_hevc,v4l2_mem2mem,bcm2835_isp
> > mc 61440 10 v4l2_async,videodev,bcm2835_codec,xyz123,videobuf2_v4l2,bcm2835_unicam,videobuf2_common,rpivid_hevc,v4l2_mem2mem,bcm2835_isp
> >
> > </pre>
> >
> > the output of dmesg is as follows:
> > [Sat Mar 9 15:58:15 2024] xyz123: loading out-of-tree module taints kernel.
> > [Sat Mar 9 15:58:15 2024] xyz123 10-0036: xyz123_probe has been invoked to probe xyz123.
> > [Sat Mar 9 15:58:15 2024] xyz123 10-0036: allocated memory for xyz123.
> > [Sat Mar 9 15:58:15 2024] xyz123 10-0036: xyz123_check_hwcfg has been invoked to check xyz123 hardware config.
> > [Sat Mar 9 15:58:15 2024] xyz123 10-0036: number of csi lanes: 2.
> > [Sat Mar 9 15:58:15 2024] xyz123 10-0036: xyz123_power_on has been invoked to power xyz123 up.
> > [Sat Mar 9 15:58:15 2024] xyz123 10-0036: xyz123_write_registers has been invoked with number of registers set to: 03
> > [Sat Mar 9 15:58:15 2024] xyz123 10-0036: xyz123_write_register has been invoked with address: 0103
> > [Sat Mar 9 15:58:15 2024] xyz123 10-0036: xyz123_write_register has been invoked with address: 3205
> > [Sat Mar 9 15:58:15 2024] xyz123 10-0036: xyz123_write_register has been invoked with address: 0100
> > [Sat Mar 9 15:58:15 2024] xyz123 10-0036: xyz123_write_register has been invoked with address: 3205
> > [Sat Mar 9 15:58:15 2024] xyz123 10-0036: xyz123_identify_module has been invoked to identify xyz123.
> > [Sat Mar 9 15:58:15 2024] xyz123 10-0036: xyz123_read_register has been invoked with address: 0x302A
> > [Sat Mar 9 15:58:15 2024] xyz123 10-0036: xyz123_read_register prepared a I2C write message with: addr: 0x36, flags: 0x00, len: 0x02
> > [Sat Mar 9 15:58:15 2024] xyz123 10-0036: xyz123_read_register prepared a I2C read message with: addr: 0x36, flags: 0x01, len: 0x01
> > [Sat Mar 9 15:58:15 2024] xyz123 10-0036: chip id first byte matches: 4 == 4
> > [Sat Mar 9 15:58:15 2024] xyz123 10-0036: xyz123_read_register has been invoked with address: 0x302B
> > [Sat Mar 9 15:58:15 2024] xyz123 10-0036: xyz123_read_register prepared a I2C write message with: addr: 0x36, flags: 0x00, len: 0x02
> > [Sat Mar 9 15:58:15 2024] xyz123 10-0036: xyz123_read_register prepared a I2C read message with: addr: 0x36, flags: 0x01, len: 0x01
> > [Sat Mar 9 15:58:15 2024] xyz123 10-0036: chip id second byte matches: 28 == 28
> > [Sat Mar 9 15:58:15 2024] xyz123 10-0036: xyz123_init_ctrls has been invoked to initialize controls of xyz123.
> > [Sat Mar 9 15:58:15 2024] xyz123 10-0036: xyz123_init_ctrls succesfully initialized controls
> > [Sat Mar 9 15:58:15 2024] xyz123 10-0036: default pixel rate of xyz123: 10804320.
> > [Sat Mar 9 15:58:15 2024] xyz123 10-0036: current link frequency of xyz123: 192000000.
> > [Sat Mar 9 15:58:15 2024] xyz123 10-0036: default vblank of xyz123: 8.
> > [Sat Mar 9 15:58:15 2024] xyz123 10-0036: default hblank of xyz123: 8.
> > [Sat Mar 9 15:58:15 2024] xyz123 10-0036: Default width specified in device tree: 720
> > [Sat Mar 9 15:58:15 2024] xyz123 10-0036: Default height specified in device tree: 720
> > [Sat Mar 9 15:58:15 2024] xyz123 10-0036: xyz123_set_default_format has been invoked to set default format of xyz123.
> > [Sat Mar 9 15:58:15 2024] xyz123 10-0036: xyz123_set_default_format has set code to 12295.
> > [Sat Mar 9 15:58:15 2024] xyz123 10-0036: xyz123_set_default_format has set colorspace to 8.
> > [Sat Mar 9 15:58:15 2024] xyz123 10-0036: xyz123_set_default_format has set ycbcr_enc to 1.
> > [Sat Mar 9 15:58:15 2024] xyz123 10-0036: xyz123_set_default_format has set quantization to 1.
> > [Sat Mar 9 15:58:15 2024] xyz123 10-0036: xyz123_set_default_format has set xfer_func to 2.
> > [Sat Mar 9 15:58:15 2024] xyz123 10-0036: xyz123_set_default_format has set width to 720.
> > [Sat Mar 9 15:58:15 2024] xyz123 10-0036: xyz123_set_default_format has set height to 720.
> > [Sat Mar 9 15:58:15 2024] xyz123 10-0036: xyz123_set_default_format has set field to 1.
> > [Sat Mar 9 15:58:15 2024] xyz123 10-0036: xyz123_set_default_format has completed.
> > [Sat Mar 9 15:58:15 2024] xyz123 10-0036: xyz123_probe has initialized media entity pads for xyz123 to 0 and 2.
> > [Sat Mar 9 15:58:15 2024] xyz123 10-0036: xyz123_probe has registered the subdevice of xyz123.
> > [Sat Mar 9 15:58:15 2024] xyz123 10-0036: xyz123_probe has completed probing xyz123.
> > [Sat Mar 9 15:58:15 2024] xyz123 10-0036: xyz123_power_off has been invoked to power xyz123 down.
> > [Sat Mar 9 15:58:17 2024] xyz123 10-0036: Consider updating driver xyz123 to match on endpoints
> > [Sat Mar 9 15:58:19 2024] xyz123 10-0036: xyz123_open has been invoked to open xyz123.
> > [Sat Mar 9 15:58:19 2024] xyz123 10-0036: xyz123_get_format_code has been invoked to get format code of xyz123.
> > [Sat Mar 9 15:58:19 2024] xyz123 10-0036: h_flip: 0, v_flip: 0, code_index: 0 and 12295 of xyz123.
> > [Sat Mar 9 15:58:22 2024] xyz123 10-0036: xyz123_open has been invoked to open xyz123.
> > [Sat Mar 9 15:58:22 2024] xyz123 10-0036: xyz123_get_format_code has been invoked to get format code of xyz123.
> > [Sat Mar 9 15:58:22 2024] xyz123 10-0036: h_flip: 0, v_flip: 0, code_index: 0 and 12295 of xyz123.
> > [Sat Mar 9 15:58:22 2024] xyz123 10-0036: xyz123_enum_mbus_code has been invoked.
> > [Sat Mar 9 15:58:22 2024] xyz123 10-0036: In xyz123_enum_mbus_code, code-> index has reached limit: 0.
>
> That looks like the likely issue if your limit is 0, so you're not
> returning the supported formats via enum_mbus_code.
>
> Confirm what "v4l2-ctl -d /dev/v4l-subdev0 --list-subdev-mbus-codes
> 0" returns. It should be along the lines of:
>
> pi at raspberrypi:~ $ v4l2-ctl -d /dev/v4l-subdev0 --list-subdev-mbus-codes 0
> ioctl: VIDIOC_SUBDEV_ENUM_MBUS_CODE (pad=0)
> 0x3007: MEDIA_BUS_FMT_SBGGR10_1X10
>
> Based on your code of 12295 (0x3007 aka MEDIA_BUS_FMT_SBGGR10_1X10)
> from set_default_format, that should be returned for index 0, and
> -EINVAL otherwise.
>
> As Laurent says, anything more will need reviewing of the driver source.
>
> Dave
>
>
> > [Sat Mar 9 15:58:24 2024] xyz123 10-0036: xyz123_enum_mbus_code has been invoked.
> > [Sat Mar 9 15:58:24 2024] xyz123 10-0036: In xyz123_enum_mbus_code, code-> index has reached limit: 0.
> > [Sat Mar 9 15:58:24 2024] xyz123 10-0036: xyz123_enum_mbus_code has been invoked.
> > [Sat Mar 9 15:58:24 2024] xyz123 10-0036: In xyz123_enum_mbus_code, code-> index has reached limit: 0.
> > [Sat Mar 9 15:58:32 2024] xyz123 10-0036: xyz123_open has been invoked to open xyz123.
> > [Sat Mar 9 15:58:32 2024] xyz123 10-0036: xyz123_get_format_code has been invoked to get format code of xyz123.
> > [Sat Mar 9 15:58:32 2024] xyz123 10-0036: h_flip: 0, v_flip: 0, code_index: 0 and 12295 of xyz123.
> > [Sat Mar 9 15:58:32 2024] xyz123 10-0036: xyz123_enum_mbus_code has been invoked.
> > [Sat Mar 9 15:58:32 2024] xyz123 10-0036: In xyz123_enum_mbus_code, code-> index has reached limit: 0.
> > [Sat Mar 9 15:58:33 2024] xyz123 10-0036: xyz123_enum_mbus_code has been invoked.
> > [Sat Mar 9 15:58:33 2024] xyz123 10-0036: In xyz123_enum_mbus_code, code-> index has reached limit: 0.
> > [Sat Mar 9 15:58:33 2024] xyz123 10-0036: xyz123_enum_mbus_code has been invoked.
> > [Sat Mar 9 15:58:33 2024] xyz123 10-0036: In xyz123_enum_mbus_code, code-> index has reached limit: 0.
> > [Sat Mar 9 15:58:51 2024] xyz123 10-0036: xyz123_open has been invoked to open xyz123.
> > [Sat Mar 9 15:58:51 2024] xyz123 10-0036: xyz123_get_format_code has been invoked to get format code of xyz123.
> > [Sat Mar 9 15:58:51 2024] xyz123 10-0036: h_flip: 0, v_flip: 0, code_index: 0 and 12295 of xyz123.
> > [Sat Mar 9 15:58:51 2024] xyz123 10-0036: xyz123_enum_mbus_code has been invoked.
> > [Sat Mar 9 15:58:51 2024] xyz123 10-0036: In xyz123_enum_mbus_code, code-> index has reached limit: 0.
> >
> >
> >
More information about the libcamera-devel
mailing list