IMX6 support for a 8 bit grey scale sensor

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

IMX6 support for a 8 bit grey scale sensor

3,555 Views
Selea
Senior Contributor I

Dear all,

I'm trying to acquire pictures from a 8 bit greyscale sensor (AR0134 from aptina) but i cannot succeed on it. (I'm working on 3.10.17_1.0.1_ga )

What i obtain (acquiring using gstreame pipeline) is a someting bad. tried to acquire a jpeg or a raw snapshot.

first take a look to this other thread:

IPU2 parallel port on IMX6Q

imx6 support for 8-bit RAW camera

I decided to open a new thread with a specific question on grey scale (but i think could be the same problem with a raw sensor), So maybe with a very specific question is easy to have a answer that could help me.

and here the gstreamer pipe for jpeg and for raw snapshot:

gst-launch mfw_v4lsrc num-buffers=1 device=/dev/video3 ! filesink location=/mnt/nfs/home/sample.raw

gst-launch mfw_v4lsrc num-buffers=1 device=/dev/video3 !  jpegenc ! filesink location=/mnt/nfs/home/sample.jpeg

I attach to this question the two jpeg and raw snapshot.

Please note that the sensor is 1280x960 so the raw should be 1228800 bytes, instead it is 1.8Mbyte the exact dimension of a 420 image ... soi think something is bad configurated in the IPU that make some kind of conversion....

I added around the code the supprto for the grey scale pix format V4L2_PIX_FMT_GREY... but it is not sufficent yet...

here i put the dmesg (i enable a lot of debug print around and some added by myself to understand what is going wrong)

[   85.106229] mxc_v4l_open: Mxc Camera ipu1/csi1

[   85.106329] mxc_v4l_open: 1 ipu1/csi1

[   85.106337]    clock_curr=mclk=27000000

[   85.108874]    clock_curr=mclk=27000000

[   85.108879] vsync_pol(1) hsync_pol(1) ext_vsync(1)

[   85.108884] ioctl_g_fmt_cap: 1

[   85.108888] ioctl_g_fmt_cap: 1280x960

[   85.108892]    g_fmt_cap returns widthxheight of input as 1280 x 960

[   85.108896] On Open: Input to ipu size is 1280 x 960

[   85.108901] End of setup_ifparm: v2f pix widthxheight 1280 x 960

[   85.108906] End of setup_ifparm: crop_bounds widthxheight 1280 x 960

[   85.108910] End of setup_ifparm: crop_defrect widthxheight 1280 x 960

[   85.108914] End of setup_ifparm: crop_current widthxheight 1280 x 960

[   85.108918] ioctl_g_fmt_cap: b

[   85.108922] ioctl_g_fmt_cap: left=0, top=0, 0x0

[   85.108943] imx-ipuv3 2800000.ipu: ipu_csi_init_interface: 1280x960

[   85.108953] imx-ipuv3 2800000.ipu: CSI_SENS_CONF = 0x80008B03

[   85.108960] imx-ipuv3 2800000.ipu: CSI_ACT_FRM_SIZE = 0x03BF04FF

[   85.108969] power_up_camera: ipu1/csi1

[   85.130541] ioctl_init

[   85.131604]    Setting mclk to 27 MHz

[   85.133965] AR0134_init

[   85.550613] mxc_v4l_ioctl

[   85.550828] mxc_v4l_do_ioctl: c02c5651 ipu1/csi1

[   85.550847] mxc_v4l_ioctl

[   85.550860] mxc_v4l_do_ioctl: c02c564a ipu1/csi1

[   85.550874] mxc_v4l_ioctl

[   85.550887] mxc_v4l_do_ioctl: c0045627 ipu1/csi1

[   85.550896]    case VIDIOC_S_INPUT

[   85.550907] mxc_v4l_ioctl

[   85.550920] mxc_v4l_do_ioctl: c0cc5616 ipu1/csi1

[   85.550930]    case VIDIOC_S_PARM

[   85.550938] mxc_v4l2_s_param

[   85.550947]    Current capabilities are 1001

[   85.550956]    Current capturemode is 0  change to 0

[   85.550965]    Current framerate is 54  change to 30

[   85.572065]    clock_curr=mclk=27000000

[   85.574614]    clock_curr=mclk=27000000

[   85.574628] vsync_pol(1) hsync_pol(1) ext_vsync(1)

[   85.574639] ioctl_g_fmt_cap: 1

[   85.574649] ioctl_g_fmt_cap: 1280x960

[   85.574659]    g_fmt_cap returns widthxheight of input as 1280 x 960

[   85.574668] ioctl_g_fmt_cap: b

[   85.574679] ioctl_g_fmt_cap: left=0, top=0, 0x0

[   85.574717] imx-ipuv3 2800000.ipu: ipu_csi_init_interface: 1280x960

[   85.574739] imx-ipuv3 2800000.ipu: CSI_SENS_CONF = 0x80008B03

[   85.574756] imx-ipuv3 2800000.ipu: CSI_ACT_FRM_SIZE = 0x03BF04FF

[   85.574775] mxc_v4l_ioctl

[   85.574791] mxc_v4l_do_ioctl: c0cc5605 ipu1/csi1

[   85.574800]    case VIDIOC_S_FMT

[   85.574808] mxc_v4l2_s_fmt

[   85.574815]    type=V4L2_BUF_TYPE_VIDEO_CAPTURE

[   85.574830] End of mxc_v4l2_s_fmt: v2f pix widthxheight 1280 x 960

[   85.574842] End of mxc_v4l2_s_fmt: crop_bounds widthxheight 1280 x 960

[   85.574852] End of mxc_v4l2_s_fmt: crop_defrect widthxheight 1280 x 960

[   85.574863] End of mxc_v4l2_s_fmt: crop_current widthxheight 1280 x 960

[   85.574874] mxc_v4l_ioctl

[   85.574887] mxc_v4l_do_ioctl: c008561c ipu1/csi1

[   85.574896]    case VIDIOC_S_CTRL

[   85.574904] mxc_v4l2_s_ctrl

[   85.574915] mxc_v4l_ioctl

[   85.574928] mxc_v4l_do_ioctl: c0145608 ipu1/csi1

[   85.574936]    case VIDIOC_REQBUFS

[   85.574950] mxc_streamoff: ipu1/csi1 capture_on=0 CSI MEM

[   85.574959] mxc_free_frame_buf

[   85.574971] mxc_allocate_frame_buf: size=1843200

[   85.643157] mxc_v4l_ioctl

[   85.643184] mxc_v4l_do_ioctl: c0cc5604 ipu1/csi1

[   85.643194]    case VIDIOC_G_FMT

[   85.643204] mxc_v4l2_g_fmt: type=1

[   85.643213]    type is V4L2_BUF_TYPE_VIDEO_CAPTURE

[   85.643225] End of mxc_v4l2_g_fmt: v2f pix widthxheight 1280 x 960

[   85.643236] End of mxc_v4l2_g_fmt: crop_bounds widthxheight 1280 x 960

[   85.643247] End of mxc_v4l2_g_fmt: crop_defrect widthxheight 1280 x 960

[   85.643257] End of mxc_v4l2_g_fmt: crop_current widthxheight 1280 x 960

[   85.643403] mxc_v4l_ioctl

[   85.643419] mxc_v4l_do_ioctl: c0445609 ipu1/csi1

[   85.643430]    case VIDIOC_QUERYBUF

[   85.643440] mxc_v4l2_buffer_status

[   85.643476] mxc_mmap:pgoff=0x40300, start=0x76661000, end=0x76823000

[   85.646940] mxc_v4l_ioctl

[   85.646959] mxc_v4l_do_ioctl: c044560f ipu1/csi1

[   85.646969]    case VIDIOC_QBUF

[   85.646991] mxc_v4l_ioctl

[   85.647003] mxc_v4l_do_ioctl: c0445609 ipu1/csi1

[   85.647011]    case VIDIOC_QUERYBUF

[   85.647019] mxc_v4l2_buffer_status

[   85.647045] mxc_mmap:pgoff=0x40500, start=0x7649f000, end=0x76661000

[   85.650373] mxc_v4l_ioctl

[   85.650387] mxc_v4l_do_ioctl: c044560f ipu1/csi1

[   85.650395]    case VIDIOC_QBUF

[   85.650411] mxc_v4l_ioctl

[   85.650423] mxc_v4l_do_ioctl: c0445609 ipu1/csi1

[   85.650431]    case VIDIOC_QUERYBUF

[   85.650439] mxc_v4l2_buffer_status

[   85.650462] mxc_mmap:pgoff=0x40700, start=0x762dd000, end=0x7649f000

[   85.653270] mxc_v4l_ioctl

[   85.653278] mxc_v4l_do_ioctl: c044560f ipu1/csi1

[   85.653283]    case VIDIOC_QBUF

[   85.653292] mxc_v4l_ioctl

[   85.653297] mxc_v4l_do_ioctl: c0445609 ipu1/csi1

[   85.653300]    case VIDIOC_QUERYBUF

[   85.653304] mxc_v4l2_buffer_status

[   85.653315] mxc_mmap:pgoff=0x40900, start=0x7611b000, end=0x762dd000

[   85.654871] mxc_v4l_ioctl

[   85.654877] mxc_v4l_do_ioctl: c044560f ipu1/csi1

[   85.654881]    case VIDIOC_QBUF

[   85.654888] mxc_v4l_ioctl

[   85.654893] mxc_v4l_do_ioctl: c0445609 ipu1/csi1

[   85.654897]    case VIDIOC_QUERYBUF

[   85.654900] mxc_v4l2_buffer_status

[   85.654912] mxc_mmap:pgoff=0x40b00, start=0x75f59000, end=0x7611b000

[   85.656461] mxc_v4l_ioctl

[   85.656466] mxc_v4l_do_ioctl: c044560f ipu1/csi1

[   85.656470]    case VIDIOC_QBUF

[   85.656477] mxc_v4l_ioctl

[   85.656481] mxc_v4l_do_ioctl: c0445609 ipu1/csi1

[   85.656485]    case VIDIOC_QUERYBUF

[   85.656489] mxc_v4l2_buffer_status

[   85.656498] mxc_mmap:pgoff=0x40d00, start=0x75d97000, end=0x75f59000

[   85.658052] mxc_v4l_ioctl

[   85.658057] mxc_v4l_do_ioctl: c044560f ipu1/csi1

[   85.658061]    case VIDIOC_QBUF

[   85.658070] mxc_v4l_ioctl

[   85.658075] mxc_v4l_do_ioctl: 40045612 ipu1/csi1

[   85.658080]    case VIDIOC_STREAMON

[   85.658084] mxc_streamon

[   85.658088] IPU:In csi_enc_enabling_tasks

[   85.661379] In csi_enc_setup

[   85.662971] imx-ipuv3 2800000.ipu: init channel req= 15

[   85.662981] imx-ipuv3 2800000.ipu: init channel= 15

[   85.662993] imx-ipuv3 2800000.ipu: ipu busfreq high requst.

[   85.663007] imx-ipuv3 2800000.ipu: channel = 268435392

[   85.663019] imx-ipuv3 2800000.ipu: _ipu_csi_init:CSI_SENS_CONF: ipu=80d20998,csi=1,data=84008b03

[   85.663031] imx-ipuv3 2800000.ipu: initializing idma ch 0 @ c0980000

[   85.663053] imx-ipuv3 2800000.ipu: ch 0 word 0 - 00000000 96000000 002EE000 E0000000 000EFC9F

[   85.663063] imx-ipuv3 2800000.ipu: ch 0 word 1 - 06F20000 00DE4000 0047C000 00013FC0 0000027F

[   85.663069] imx-ipuv3 2800000.ipu: PFS 0x2,

[   85.663076] imx-ipuv3 2800000.ipu: BPP 0x0,

[   85.663082] imx-ipuv3 2800000.ipu: NPB 0x1f

[   85.663089] imx-ipuv3 2800000.ipu: FW 1279,

[   85.663095] imx-ipuv3 2800000.ipu: FH 959,

[   85.663101] imx-ipuv3 2800000.ipu: EBA0 0x37900000

[   85.663107] imx-ipuv3 2800000.ipu: EBA1 0x37900000

[   85.663114] imx-ipuv3 2800000.ipu: Stride 1279

[   85.663119] imx-ipuv3 2800000.ipu: scan_order 0

[   85.663125] imx-ipuv3 2800000.ipu: uv_stride 639

[   85.663132] imx-ipuv3 2800000.ipu: u_offset 0x12c000

[   85.663138] imx-ipuv3 2800000.ipu: v_offset 0x177000

[   85.663144] imx-ipuv3 2800000.ipu: Width0 0+1,

[   85.663150] imx-ipuv3 2800000.ipu: Width1 0+1,

[   85.663156] imx-ipuv3 2800000.ipu: Width2 0+1,

[   85.663162] imx-ipuv3 2800000.ipu: Width3 0+1,

[   85.663168] imx-ipuv3 2800000.ipu: Offset0 31,

[   85.663174] imx-ipuv3 2800000.ipu: Offset1 19,

[   85.663180] imx-ipuv3 2800000.ipu: Offset2 0,

[   85.663186] imx-ipuv3 2800000.ipu: Offset3 0

[   85.663196] eba 40300000

[   85.663201] eba 40500000

[   85.665400] mxc_v4l_ioctl

[   85.665409] mxc_v4l_do_ioctl: c0445611 ipu1/csi1

[   85.665412]    case VIDIOC_DQBUF

[   85.665416] mxc_v4l_dqueue

[   85.751112] camera_callback

[   85.751139] eba 40700000

[   85.815804] mxc_v4l_ioctl

[   85.815821] mxc_v4l_do_ioctl: c044560f ipu1/csi1

[   85.815826]    case VIDIOC_QBUF

[   85.815986] mxc_v4l_ioctl

[   85.815995] mxc_v4l_do_ioctl: 40045613 ipu1/csi1

[   85.815999]    case VIDIOC_STREAMOFF

[   85.816005] mxc_streamoff: ipu1/csi1 capture_on=1 CSI MEM

[   85.824867] imx-ipuv3 2800000.ipu: CSI stop timeout - -44 * 10ms

[   85.824901] imx-ipuv3 2800000.ipu: ipu busfreq high release.

[   85.824909] mxc_free_frames

[   85.825283] mxc_v4l_close

[   85.825291] mxc_streamoff: ipu1/csi1 capture_on=0 CSI MEM

[   85.825297] mxc_v4l_close: release resource

[   85.825302] mxc_free_frame_buf

[   85.827188] mxc_free_frames

[   87.820602] power_down_callback: ipu1/csi1

Hope this could be helpfull...I think i'm not the only one that it is trying to acquire a BW or bayer sensor...

Thanks

Omar

Labels (4)
Tags (4)
5 Replies

1,212 Views
nathanmak
Contributor II

Hi Omar,

I've been stalking your posts because they are indeed helpful. Earlier in September you posted a patch to get your Aptina parallel CSI interface running. IPU2 parallel port on IMX6Q

I notice that this patch doesn't have the same changes. Did you remove those changes? I'm suffering from a gstreamer dequeue timeout and figure my IPU2 isn't configured correctly. Re: V4L not getting ioctl interrupts from IPU2 of IMX6Q

Even if you don't answer, thank you for taking the time to show your work. I really respect what you're doing and hope things work out for you and your company.

Grazie

0 Kudos

1,212 Views
Selea
Senior Contributor I

well I solved.. in some manner.

the problem is that the fmt.pix.pixelformat is always overwrite in several differ way.

I set it as V4L2_PIX_FMT_GREY in the sensor driver (cam.fmt.pix.pixelformat)...

but is overwrited to V4L2_PIX_FMT_YUV420

so I changed some lines in mxc_v4l2_capture.c to make that the pixelformat setted in the sensor driver is not overwrited.... (maybe i have to make an if ==V4L2_PIX_FMT_GREY

si I have what i expect...

Omar

0 Kudos

1,212 Views
SergioSolis
NXP Employee
NXP Employee

Thank you for posting the solution Omar, it'll definitely help someone else in the communities!

1,212 Views
Selea
Senior Contributor I

here my complete patch.

It is based on linux_boundary_3.10.17_1.0.1_ga

Omar

1,212 Views
amadeusholmer
Contributor I

Hello all,

we try to get images from a AR0130 sensor that is almost identical to the AR0134 camera sensor. We use a Variscite DART-MX6 board.

I tried to compile your sensor patch from above but got some errors according to some variables:

drivers/media/platform/mxc/capture/ar0134.c: In function 'ioctl_g_fmt_cap':

drivers/media/platform/mxc/capture/ar0134.c:968:7: error: 'V4L2_BUF_TYPE_SENSOR' undeclared (first use in this function)

  case V4L2_BUF_TYPE_SENSOR:

       ^

drivers/media/platform/mxc/capture/ar0134.c:968:7: note: each undeclared identifier is reported only once for each function it appears in

In file included from include/linux/kernel.h:13:0,

                 from include/linux/clk.h:16,

                 from drivers/media/platform/mxc/capture/ar0134.c:21:

drivers/media/platform/mxc/capture/ar0134.c:970:10: error: 'struct sensor_data' has no member named 'spix'

    sensor->spix.left, sensor->spix.top,

          ^

include/linux/printk.h:246:38: note: in definition of macro 'pr_debug'

  no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)

                                      ^

drivers/media/platform/mxc/capture/ar0134.c:970:29: error: 'struct sensor_data' has no member named 'spix'

    sensor->spix.left, sensor->spix.top,

                             ^

include/linux/printk.h:246:38: note: in definition of macro 'pr_debug'

  no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)

                                      ^

drivers/media/platform/mxc/capture/ar0134.c:971:10: error: 'struct sensor_data' has no member named 'spix'

    sensor->spix.swidth, sensor->spix.sheight);

          ^

include/linux/printk.h:246:38: note: in definition of macro 'pr_debug'

  no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)

                                      ^

drivers/media/platform/mxc/capture/ar0134.c:971:31: error: 'struct sensor_data' has no member named 'spix'

    sensor->spix.swidth, sensor->spix.sheight);

                               ^

include/linux/printk.h:246:38: note: in definition of macro 'pr_debug'

  no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)

                                      ^

drivers/media/platform/mxc/capture/ar0134.c:972:9: error: 'union <anonymous>' has no member named 'spix'

   f->fmt.spix = sensor->spix;

         ^

drivers/media/platform/mxc/capture/ar0134.c:972:23: error: 'struct sensor_data' has no member named 'spix'

   f->fmt.spix = sensor->spix;

                       ^

drivers/media/platform/mxc/capture/ar0134.c: In function 'ioctl_enum_frameintervals':

drivers/media/platform/mxc/capture/ar0134.c:1117:6: warning: unused variable 'i' [-Wunused-variable]

  int i, j, count;

      ^

drivers/media/platform/mxc/capture/ar0134.c: In function 'ar0134_probe':

drivers/media/platform/mxc/capture/ar0134.c:1371:13: error: 'struct sensor_data' has no member named 'ipu_id'

      &sensor->ipu_id);

             ^

Then I tried to solve the errors by uncommenting the respective lines:

--- drivers/media/platform/mxc/capture/ar0134.c    2016-01-15 14:15:47.132697363 +0100

+++ drivers/media/platform/mxc/capture/ar0134.c.edited    2016-01-15 13:59:55.716655847 +0100

@@ -965,13 +965,13 @@

         pr_debug("%s: %dx%d\n", __func__, sensor->pix.width, sensor->pix.height);

         break;

-    case V4L2_BUF_TYPE_SENSOR:

+    /*case V4L2_BUF_TYPE_SENSOR:

         pr_debug("%s: left=%d, top=%d, %dx%d\n", __func__,

             sensor->spix.left, sensor->spix.top,

             sensor->spix.swidth, sensor->spix.sheight);

         f->fmt.spix = sensor->spix;

                 f->fmt.pix.pixelformat =V4L2_PIX_FMT_GREY;               

-        break;

+        break;*/

     case V4L2_BUF_TYPE_PRIVATE:

                 f->fmt.pix.pixelformat =V4L2_PIX_FMT_GREY;       

@@ -1366,13 +1366,13 @@

         dev_err(dev, "mclk_source invalid\n");

         return retval;

     }

-

+/*

     retval = of_property_read_u32(dev->of_node, "ipu_id",

                     &sensor->ipu_id);

     if (retval) {

         dev_err(dev, "ipu_id missing or invalid\n");

-        return retval;

-    }

+        return retval;

+    }*/

     retval = of_property_read_u32(dev->of_node, "csi_id",

                     &(ar0134_data.csi));

@@ -1422,11 +1422,11 @@

         if (of_machine_is_compatible("fsl,imx6q")) {

             int mask = (3 << 19);

             int val;

-             

+              /*

             if (sensor->csi != sensor->ipu_id) {

                 pr_warning("%s: csi_id != ipu_id\n", __func__);

-                return -ENODEV;

-            }

+                return -ENODEV;

+            }*/

With this edits the ar0134.o file was compiled. But when I try to load the module, the message

insmod: ERROR: could not insert module ar0134.o: Invalid module format.

Do you have a newer version of the driver or can you help me in another way?

I am currently not very firm with linux driver programming.

Thanks a lot for your efforts.

Bests

Amadeus

0 Kudos