logo

Could not compile stylesheet for simplistic. Using last compiled stylesheet.

How to enable ISP camera interface on J5

posted in Peripherals
Thursday, August 16 2012, 03:52 PM
0
I have built an image sensor board and am trying to use the V4L2 MT9T031 camera driver in drivers/media/video.

I have CONFIG_VIDEO_OMAP3 and CONFIG_OMAP_MUX set in my 2.6.37-2 .config file. Do I need to set anything else either in the kernel .config or in igep.ini in order to enable the I2C3 SCL/SDA and camera clock signals on J5?

Accepted Answer

Sunday, August 19 2012, 12:34 AM - #permalink
0
Hi petej,

We have own camera sensor support in 2.6.35-y-mt92v34 git branch.
linux-2.6.35.y-mt92v34

You could configure i2c channel in your linux driver or linux definition board file
For example:
commit

Cheers,
Agusti
The reply is currently minimized Show
Responses (25)
  • Accepted Answer

    Friday, September 07 2012, 11:39 AM - #permalink
    0
    Hi Agusti,

    Thanks for the links. I have been through this code to have a look to see how it all fits together. I am using the 2.6.37-2 kernel as it compiles without issue on my cross-compiler (gcc 4.4.3). [Unfortunately, I cannot get the mt93v34 code to compile]. I now have all of the correct structs and v4l2 function (e.g. set_clk) calls in my board-igep0030.c file.

    The issue I have is that the I2C3 port does not appear to be correctly enabled. I see the i2c_register call setting it to #3 @ 400kHz via dmesg but then see a warning message that the MT9T031 "driver needs platform data". This message is generated by the mt9t031.c probe function. I also see a few more i2c-related errors: "probe of 3-005d failed with error -22" and "i2c-3 failed to register i2c client".

    I wondered whether the I2C3 SCL/SDA pins need to be defined in the omap_board_mux board_mux[] struct in board-igep0030.c such as:

    OMAP3_MUX(I2C3_SCL, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT),
    OMAP3_MUX(I2C3_SDA, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT),


    I did try this but it didn't work (even for MODE0).

    Where else in the kernel code are the I2C3 SDA/SCL pins defined?
    The reply is currently minimized Show
  • Accepted Answer

    Wednesday, September 12 2012, 10:39 AM - #permalink
    0
    Could you provide your modifications ?
    The reply is currently minimized Show
  • Accepted Answer

    Monday, September 17 2012, 11:15 AM - #permalink
    0
    In board-igep0030.c:

    after
    extern void __init ilms0015_init(void);
    I have:

    #include 
    #include 
    
    #include "devices.h"
    #include "../../../drivers/media/video/isp/isp.h"
    #include "../../../drivers/media/video/isp/ispreg.h"
    
    static void mt9t031_set_clk(struct v4l2_subdev *subdev) /*, unsigned int hz) */
    {
    	struct isp_device *isp = v4l2_dev_to_isp_device(subdev->v4l2_dev);
    
    	isp->platform_cb.set_xclk(isp, 24000000, ISP_XCLK_A); /* 24 MHz */
    
    }
    
    static struct mt9t031_platform_data mt9t031_pdata = {
    	.clk_pol	= 1,
    	.set_clock	= mt9t031_set_clk,
    };
    
    static struct i2c_board_info camera_i2c_devices[] = {
    	{
    		I2C_BOARD_INFO("mt9t031", 0x5d),
    		.platform_data = &mt9t031_pdata,
    	},
    };
    
    static struct isp_subdev_i2c_board_info camera_primary_subdevs[] = {
    	{
    		.board_info = &camera_i2c_devices[0],
    		.i2c_adapter_id = 3,
    	},
    	{ NULL, 0, },
    };
    
    static struct isp_v4l2_subdevs_group camera_subdevs[] = {
    	{
    		.subdevs = camera_primary_subdevs,
    		.interface = ISP_INTERFACE_PARALLEL,
    		.bus = { .parallel = {
    				.width			= 10,
    				.data_lane_shift	= 0,
    				.clk_pol		= 1,
    				.bridge			= ISPCTRL_PAR_BRIDGE_DISABLE,
    		} },
    	},
    	{ NULL, 0, },
    };
    
    static struct isp_platform_data isp_pdata = {
            .subdevs = camera_subdevs,
    };


    After
    #ifdef CONFIG_OMAP_MUX
    static struct omap_board_mux board_mux[] __initdata = {

    I have:
    	OMAP3_MUX(I2C3_SCL, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT),
    	OMAP3_MUX(I2C3_SDA, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT),
    


    At the end of:
    static void __init igep0030_init(void)
    I have:
    	if (omap3_init_camera(&isp_pdata) < 0)
    		pr_err("IGEP: Unable to register camera platform\n");
    


    At the start of
    static void __init igep0030_init(void)
    I have:

    omap_register_i2c_bus(3, 400, camera_i2c_devices, ARRAY_SIZE(camera_i2c_devices));


    With the camera board attached to J5 these are the relevant messages I see during the boot sequence:
    [    0.024871] omap_i2c omap_i2c.3: bus 3 rev4.0 at 400 kHz
    [    0.036285] omap_i2c omap_i2c.1: bus 1 rev4.0 at 2600 kHz
    [    2.219024] Linux media interface: v0.10
    [    2.223358] Linux video capture interface: v2.00
    [    2.228668] mt9t031 3-005d: mt9t031_video_probe reg_write: 0xffffff87
    [    2.235595] mt9t031 3-005d: No MT9T031 chip detected, register read ffffff87
    [    2.272552] i2c i2c-3: Failed to register i2c client mt9t031 at 0x5d (-16)
    [    2.279846] isp_register_subdev_group: Unable to register subdev mt9t031
    
    The reply is currently minimized Show
  • Accepted Answer

    Monday, September 17 2012, 12:08 PM - #permalink
    0
    Hi,

    Don't add camera_i2c_devices when you register i2c3 bus, the camera i2c devices, the omap3-isp driver registers the i2c devices associated with it. Replace following line:
    omap_register_i2c_bus(3, 400, camera_i2c_devices, ARRAY_SIZE(camera_i2c_devices));
    

    for this one
    omap_register_i2c_bus(3, 100, NULL, 0);
    

    Note that omap_register_i2c_bus should be called before omap3_init_camera.

    Then you should load the omap3-isp kernel module, and the camera device should be automatically registered.

    The following code is wrong, remove it. By default the mux is correctly configured to use I2C3, with this code you reconfigure these pins to be used as GPIO not I2C
     OMAP3_MUX(I2C3_SCL, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT),
     OMAP3_MUX(I2C3_SDA, OMAP_MUX_MODE4 | OMAP_PIN_OUTPUT),
    


    Try to do these modifications, bootup your board and then try to load the omap3-isp kernel module:
    modprobe omap3-isp
    

    Now, can you provide what happens when you load the kernel module ?

    Hope it helps you.
    The reply is currently minimized Show
  • Accepted Answer

    Monday, September 17 2012, 04:24 PM - #permalink
    0
    Thanks for your help - it is much appreciated.

    I made the changes as you suggested. Here's what I now see during the boot:
    [    0.024932] omap_i2c omap_i2c.3: bus 3 rev4.0 at 100 kHz
    [    0.025329] omap_i2c omap_i2c.1: bus 1 rev4.0 at 2600 kHz
    [    2.256774] mt9t031 3-005d: MT9T031 driver needs platform data
    [    2.263336] mt9t031: probe of 3-005d failed with error -22
    [    2.269256] isp_register_subdev_group: Unable to register subdev mt9t031


    The message at [2.256774] is due to the omap_register_i2c_bus call not supplying the required camera_i2c_devices struct.

    The I2C3 omap_register_i2c_bus(3,100,NULL,0) call is being made in the igep0030_init function just after the omap_serial_init() call. The omap3_init_camera(&isp_pdata) call is the very last call in the igep0030_init routine.

    Also, I am building the code into the kernel and not loading it as a module. Could this be an issue?
    The reply is currently minimized Show
  • Accepted Answer

    Monday, September 17 2012, 05:08 PM - #permalink
    0
    I had problems in the past with omap3-isp built-in, not sure if this is your problem or not, but, can you try using as a module ?
    The reply is currently minimized Show
  • Accepted Answer

    Tuesday, September 18 2012, 10:38 AM - #permalink
    0
    Hi,

    I rebuilt the relevant parts as modules. Here's what I now see:
    [    0.024810] omap_i2c omap_i2c.3: bus 3 rev4.0 at 100 kHz
    
    root@igep00x0:~# modprobe omap3-isp
    [   43.373657] omap3isp supply VDD_CSIPHY1 not found, using dummy regulator
    [   43.380737] omap3isp supply VDD_CSIPHY2 not found, using dummy regulator
    [   43.387847] omap3isp omap3isp: Revision 15.0 found
    [   43.392883] omap-iommu omap-iommu.0: isp: version 1.1
    [   43.550598] isp_register_subdev_group: Unable to register subdev mt9t031
    


    Also, if I do 'lsmod' I see:
    root@igep00x0:~# lsmod
    Module                  Size  Used by
    videobuf_core          13831  0 
    soc_mediabus          246725  0 
    omap3_isp             104063  0 
    rfcomm                 49305  0 
    hidp                   13573  0 
    l2cap                  49726  4 rfcomm,hidp
    bluetooth              69105  3 rfcomm,hidp,l2cap
    libertas_sdio          13839  0 
    option                 13056  0 
    usb_wwan                7261  1 option
    libertas               99445  1 libertas_sdio
    usbserial              24170  2 option,usb_wwan
    twl4030_wdt             2696  0 
    omap_wdt                3487  0
    The reply is currently minimized Show
  • Accepted Answer

    Tuesday, September 18 2012, 11:32 AM - #permalink
    0
    Now seems the problem is registering subdev device because v4l2_i2c_new_subdev_board fails. You can add printk inside the function to see where it fails.

    drivers/media/video/isp/isp.c:1655:
    
    subdev = v4l2_i2c_new_subdev_board(&isp->v4l2_dev, adapter,
    			board_info->board_info, NULL, 1);
    if (subdev == NULL) {
    	printk(KERN_ERR "%s: Unable to register subdev %s\n",
    		__func__, board_info->board_info->type);
    	continue;
    }
    
    The reply is currently minimized Show
  • Accepted Answer

    Tuesday, September 18 2012, 02:43 PM - #permalink
    0
    v4l2_i2c_new_subdev_board() is inside v4l2-common.c so I did some printk's in there.

    It appears to fail in this code:
    	if (client == NULL || client->driver == NULL)
    		goto error;
    

    However, the value of client is non-NULL as a result of the client = i2c_new_device(adapter, info); call just before.

    In addition, I do not see any error messages (e.g. "Failed to register i2c client", and "Invalid %d-bit I2C address") from i2c_new_device() in i2c-core.c to indicate that it has not set client correctly. Worryingly, neither do I see the message: "client mt9t031 registered with bus id 3" in dmesg.

    What settings do I need to ensure are in the .config file for all of the I2C code to function correctly?
    The reply is currently minimized Show
  • Accepted Answer

    Tuesday, September 18 2012, 03:27 PM - #permalink
    0
    My .config has these options:
    CONFIG_I2C=y
    CONFIG_I2C_BOARDINFO=y
    CONFIG_I2C_OMAP=y
    CONFIG_VIDEO_V4L2_COMMON=m
    CONFIG_VIDEO_V4L2_SUBDEV_API=y
    CONFIG_VIDEO_V4L2=m
    CONFIG_SOC_CAMERA=m
    CONFIG_SOC_CAMERA_MT9T031=m
    

    Then the driver for the client is null "client->driver". Is your SOC CAMERA MT9T031 built as a module ?
    The reply is currently minimized Show
  • Accepted Answer

    Tuesday, September 18 2012, 04:30 PM - #permalink
    0
    In my .config is:
    CONFIG_I2C=y
    CONFIG_I2C_BOARDINFO=y
    CONFIG_I2C_COMPAT=y
    CONFIG_I2C_CHARDEV=m
    CONFIG_I2C_OMAP=y
    CONFIG_I2C_DEBUG_BUS=y
    CONFIG_VIDEO_V4L2_COMMON=y
    CONFIG_VIDEO_ALLOW_V4L1=y
    CONFIG_VIDEO_V4L1_COMPAT=y
    CONFIG_VIDEO_V4L2_SUBDEV_API=y
    CONFIG_VIDEO_V4L2=y
    CONFIG_VIDEO_V4L1=y
    CONFIG_SOC_CAMERA=m
    CONFIG_SOC_CAMERA_MT9T031=m
    CONFIG_VIDEO_OMAP3=m
    CONFIG_VIDEO_OMAP3_DEBUG=y


    Also, I have been through i2c_new_device() in i2c-core.c and have established that mt9t031 client struct is in fact being registered as 3-005d. The problem is with the code which checks if client == NULL in v4l2_i2c_new_subdev_board().

    I wonder what the BUG_ON(!v4l2_dev) call does at the start of v4l2_i2c_new_subdev_board()?
    The reply is currently minimized Show
  • Accepted Answer

    Tuesday, September 18 2012, 05:08 PM - #permalink
    0
    So, more analysis of v4l2_i2c_new_subdev_board() shows that the function is exited because client->driver == NULL.

    There is a note which precedes this call:
    Note: by loading the module first we are certain that c->driver
    	   will be set if the driver was found. If the module was not loaded
    	   first, then the i2c core tries to delay-load the module for us,
    	   and then c->driver is still NULL until the module is finally
    	   loaded. This delay-load mechanism doesn't work if other drivers
    	   want to use the i2c device, so explicitly loading the module
    	   is the best alternative.


    Does this mean I have to
    insmod mt9t031.ko
    to get the module to load? Alternatively, is the subdev driver struct somehow mangled in board-igep0030.c to cause this behaviour?
    The reply is currently minimized Show
  • Accepted Answer

    Wednesday, September 19 2012, 09:28 AM - #permalink
    0
    Interesting, then you can try to load first the camera module. This is not my case but maybe works. In my case, when I load the omap3-isp the mt9v032 module is automatically loaded.

    http://pastebin.com/RGrZdJFz
    The reply is currently minimized Show
  • Accepted Answer

    Wednesday, September 19 2012, 10:03 AM - #permalink
    0
    Many thanks for the listing. Is it possible to provide the console output when you do:
    modprobe omap3-isp
    I would like to see the correct sequence for a successful load.

    I wondered if the problem was down to:
    omap_register_i2c_bus(3, 100, NULL, 0)
    in the igep0030_init() call in board-igep0030.c? Before, I was supplying the camera_i2c_devices struct and size.

    I tried insmod mt9t031.ko and got the following:
    [  114.273956] mt9t031: Unknown symbol soc_camera_apply_sensor_flags (err 0)
    insmod: error inserting 'mt9t031.ko': -1 Unknown symbol in module


    I have my 0030-re6 board mounted in a 0010-rb4 baseboard which I'm using for the serial port output and the power input. I have no lines in my igep.ini regarding the baseboard (as I don't want to use the ethernet or other parts on it). Could this be an issue?
    The reply is currently minimized Show
  • Accepted Answer

    Wednesday, September 19 2012, 10:19 AM - #permalink
    0
    The unknow symbol error is related to a missing dependency. Try use modprobe instead insmod.

    Here are the traces :
    root@igep00x0:~# modprobe omap3-isp
    [   82.382904] Linux video capture interface: v2.00
    [   82.542266] omap3isp supply VDD_CSIPHY1 not found, using dummy regulator
    [   82.549468] omap3isp supply VDD_CSIPHY2 not found, using dummy regulator
    [   82.556610] omap3isp omap3isp: Revision 15.0 found
    [   82.561676] omap-iommu omap-iommu.0: isp: version 1.1
    [   82.897277] ** mt9v032_probe
    


    The mt9v032_probe is a printk I put into the code.

    root@igep00x0:~# lsmod
    Module                  Size  Used by
    mt9v032                 5464  1 
    omap3_isp             115233  0 
    v4l2_common             6025  2 mt9v032,omap3_isp
    videodev               57112  3 mt9v032,omap3_isp,v4l2_common
    v4l1_compat            13019  1 videodev
    iovmm                   5674  1 omap3_isp
    


    If you've the baseboard connected maybe there is a conflict. We should check if the i2c3 bus is used. I'll do.
    The reply is currently minimized Show
  • Accepted Answer

    Wednesday, September 19 2012, 10:54 AM - #permalink
    0
    The output from the modprobe is as follows:
    root@igep00x0:~# modprobe mt9t031
    [   83.934906] Linux video capture interface: v2.00
    FATAL: Error inserting mt9t031 (/lib/modules/2.6.37+/kernel/drivers/media/video/mt9t031.ko): No such device
    


    The mt9t031.ko module is definitely in the right place:
    root@igep00x0:/lib/modules/2.6.37+/kernel/drivers/media/video# ls
    isp                 soc_camera.ko       v4l2-common.ko      videobuf-core.ko
    mt9t031.ko          soc_mediabus.ko     v4l2-int-device.ko  videodev.ko


    In your board-igep0030.c file, I noticed that in igep3_i2c_init() you have a omap_register_i2c_bus() call for I2C1 but not for I2C3. That is, there appears to be no equivalent of omap_register_i2c_bus(3, 100, NULL, 0).
    The reply is currently minimized Show
  • Accepted Answer

    Wednesday, September 19 2012, 11:15 AM - #permalink
    0
    The register of i2c3 is done when the board file calls
     501         base0010_init(&igep3_twldata);
    


    See
    http://git.isee.biz/?p=pub/scm/linux-om ... .y-mt92v34
     568         omap_register_i2c_bus(3, 100, NULL, 0);
    
    The reply is currently minimized Show
  • Accepted Answer

    Wednesday, September 19 2012, 11:29 AM - #permalink
    0
    Please could you try searching and replacing mt9v032 with mt9t031 in your board-igep0030.c file. Also, on line 465, 0xb8 >> 1 will need to be replaced with 0x5d. I think you already have mt9t031 built as a module? I'd like to know what the modprobe output looks like for you.

    I am using the gcc-4.4.3 compiler and all the code is from the IGEP 2.6.37-2 git repository.
    The reply is currently minimized Show
  • Accepted Answer

    Wednesday, September 19 2012, 02:10 PM - #permalink
    0
    Would it be possible to see what you have in your igep.ini and .config files please?

    I noticed in exp-base0010.c that there is some code for I2C3:
    static struct isp_subdev_i2c_board_info base0010_camera_primary_subdevs[] = {
    	{
    		.board_info = &base0010_camera_i2c_devices[0],
    		.i2c_adapter_id = 3,
    	},
    	{ NULL, 0, },
    };
    
    However, I'm not aware that base0010_camera_init() is called so this should not be an issue?
    The reply is currently minimized Show
  • Accepted Answer

    Monday, September 24 2012, 11:12 AM - #permalink
    0
    Attached the config file I use for kernel 2.6.35.

    Maybe you can try to access to your sensor via I2C using i2c-tools.

    First you should register the I2C3 bus in board- file but not register the driver, then use i2c-get command line to try to read the chip ID.

    With this we can make sure that i2c is working.
    The reply is currently minimized Show
Your Reply

SUPPORT


This email address is being protected from spambots. You need JavaScript enabled to view it.
This email address is being protected from spambots. You need JavaScript enabled to view it.
IGEP Community Wiki
IGEP Community Forum
IGEP Community Online Chat