Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

imxv4l2videosrc: support for iMX6 SoloX #93

Closed
lfauster opened this issue Apr 15, 2016 · 11 comments
Closed

imxv4l2videosrc: support for iMX6 SoloX #93

lfauster opened this issue Apr 15, 2016 · 11 comments

Comments

@lfauster
Copy link

Hi,

I would like to use gstreamer-imx with an iMX6 SoloX.
Unfortunately I get an error when creating a pipeline with following command:
gst-launch-1.0 imxv4l2videosrc device=/dev/video1 ! fakesink

The imxv4l2videosrc element seems to have a problem (output with GST_DEBUG=3):

ERROR        imxv4l2videosrc v4l2src.c:152:gst_imx_v4l2src_capture_setup:<imxv4l2videosrc0> VIDIOC_S_STD failed
ERROR        imxv4l2videosrc v4l2src.c:251:gst_imx_v4l2src_start:<imxv4l2videosrc0> capture_setup failed
WARN         basesrc gstbasesrc.c:3717:gst_base_src_activate_push:<imxv4l2videosrc0> Failed to start in push mode
WARN         GST_PADS gstpad.c:1098:gst_pad_set_active:<imxv4l2videosrc0:src> Failed to activate pad

video1 appears to be the correct device:

~# v4l2-ctl --list-devices
i.MX6S_CSI (platform:221c000.csi):
        /dev/video1

pxp (pxp_v4l2_out):
        /dev/video0

Is the iMX6 SoloX supported by the plugins? Especially usage together with the Video-ADC integrated in the iMX6SX is of much interest for me.

@sasamy
Copy link
Contributor

sasamy commented Apr 15, 2016

As far as I see s_std isn't implemented in the mxc_vadc.c driver, it would be quite good if someone can check a simple fix for imxv4l2videosrc on the i.MX6SX processor

diff -uprN gstreamer-imx-0.12.1/src/v4l2src/v4l2src.c gstreamer-imx-0.12.1-solox/src/v4l2src/v4l2src.c
--- gstreamer-imx-0.12.1/src/v4l2src/v4l2src.c  2016-04-06 02:20:50.000000000 +0300
+++ gstreamer-imx-0.12.1-solox/src/v4l2src/v4l2src.c    2016-04-16 00:40:53.153785976 +0300
@@ -149,9 +149,7 @@ static gint gst_imx_v4l2src_capture_setu

        if (ioctl(fd_v4l, VIDIOC_S_STD, &std_id) < 0)
        {
-           GST_ERROR_OBJECT(v4l2src, "VIDIOC_S_STD failed");
-           close(fd_v4l);
-           return -1;
+           GST_WARNING_OBJECT(v4l2src, "VIDIOC_S_STD failed");
        }

        if (std_id)


@lfauster
Copy link
Author

I tried your patch and unfortunately there are several other ioctls which are not implemented in mxc_vadc. I pushed my luck and modified imxv4l2videosrc to tolerate all the other failing ones too, but to I guess doing so, some necessary setup steps are not performed anymore:

~# gst-launch-1.0 imxv4l2videosrc device=/dev/video1 ! fakesink
Setting pipeline to PAUSED ...
0:00:00.345731334   394   0xa77b40 WARN         imxv4l2videosrc v4l2src.c:138:gst_imx_v4l2src_capture_setup:<imxv4l2videosrc0> VIDIOC_G_STD failed: Inappropriate ioctl for device
0:00:00.345914334   394   0xa77b40 WARN         imxv4l2videosrc v4l2src.c:171:gst_imx_v4l2src_capture_setup:<imxv4l2videosrc0> VIDIOC_G_FMT failed
0:00:00.345983334   394   0xa77b40 WARN         imxv4l2videosrc v4l2src.c:180:gst_imx_v4l2src_capture_setup:<imxv4l2videosrc0> VIDIOC_ENUM_FRAMESIZES failed: Inappropriate ioctl for device
0:00:00.346049334   394   0xa77b40 WARN         imxv4l2videosrc v4l2src.c:191:gst_imx_v4l2src_capture_setup:<imxv4l2videosrc0> VIDIOC_S_INPUT failed: Inappropriate ioctl for device
0:00:00.346110667   394   0xa77b40 WARN         imxv4l2videosrc v4l2src.c:200:gst_imx_v4l2src_capture_setup:<imxv4l2videosrc0> VIDIOC_S_PARM failed: Inappropriate ioctl for device
0:00:00.346171334   394   0xa77b40 WARN         imxv4l2videosrc v4l2src.c:222:gst_imx_v4l2src_capture_setup:<imxv4l2videosrc0> VIDIOC_S_FMT failed: Invalid argument
0:00:00.346339000   394   0xa77b40 WARN         imxv4l2videosrc v4l2src.c:248:gst_imx_v4l2src_start:<imxv4l2videosrc0> VIDIOC_G_FMT failed
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
0:00:00.350478334   394   0xaef580 WARN         imxv4l2videosrc v4l2src.c:375:gst_imx_v4l2src_caps_for_current_setup:<imxv4l2videosrc0> VIDIOC_G_FMT failed

** (gst-launch-1.0:394): CRITICAL **: gst_video_format_to_string: assertion 'format != GST_VIDEO_FORMAT_UNKNOWN' failed
0:00:00.351198000   394   0xaef580 WARN         imxv4l2videosrc v4l2src.c:318:gst_imx_v4l2src_decide_allocation:<imxv4l2videosrc0> VIDIOC_G_FMT failed
0:00:00.356280000   394   0xaef580 ERROR             video-info video-info.c:420:gst_video_info_from_caps: no format given
0:00:00.356386667   394   0xaef580 ERROR      imxv4l2bufferpool v4l2_buffer_pool.c:99:gst_imx_v4l2_buffer_pool_set_config:<imxv4l2bufferpool0> caps cannot be parsed for video info
0:00:00.356498334   394   0xaef580 ERROR             bufferpool gstbufferpool.c:525:gst_buffer_pool_set_active:<imxv4l2bufferpool0> pool was not configured
0:00:00.356560000   394   0xaef580 ERROR                basesrc gstbasesrc.c:3005:gst_base_src_set_allocation:<imxv4l2videosrc0> failed to activate bufferpool.
0:00:00.357357334   394   0xaef580 WARN                 basesrc gstbasesrc.c:2943:gst_base_src_loop:<imxv4l2videosrc0> error: Internal data flow error.
0:00:00.357470000   394   0xaef580 WARN                 basesrc gstbasesrc.c:2943:gst_base_src_loop:<imxv4l2videosrc0> error: streaming task paused, reason not-negotiated (-4)

@lfauster
Copy link
Author

lfauster commented Apr 18, 2016

my mistake; the text above can be ignored. For testing puproses I recompiled the linux kernel and my video-devices video0 and video1 were switched leading to the errors from above.
Nonetheless, after applying the above patch, I now get the following output and at the end a kernel oops:

~# GST_DEBUG=3 gst-launch-1.0 imxv4l2videosrc device=/dev/video0 ! fakesink
[...]
0:00:02.676272667   337   0x1c7400 DEBUG                basesrc gstbasesrc.c:3694:gst_base_src_activate_push:<imxv4l2videosrc0> Activating in push mode
0:00:02.683128001   337   0x1c7400 WARN         imxv4l2videosrc v4l2src.c:152:gst_imx_v4l2src_capture_setup:<imxv4l2videosrc0> VIDIOC_S_STD failed
0:00:02.683687001   337   0x1c7400 DEBUG        imxv4l2videosrc v4l2src.c:164:gst_imx_v4l2src_capture_setup:<imxv4l2videosrc0> found TV decoder, adjusted fps 30/1
0:00:02.684267334   337   0x1c7400 DEBUG        imxv4l2videosrc v4l2src.c:176:gst_imx_v4l2src_capture_setup:<imxv4l2videosrc0> pixelformat = 0  field = 0  std id = 0xb000

[  124.838402] unknown pixelformat:'    '
[  124.842733] Unable to handle kernel NULL pointer dereference at virtual address 00000024
[  124.850914] pgd = a8fbc000
[  124.853971] [00000024] *pgd=a8458831, *pte=00000000, *ppte=00000000
[  124.860375] Internal error: Oops: 17 [#1] PREEMPT ARM
[  124.865432] Modules linked in:
[  124.868509] CPU: 0 PID: 337 Comm: gst-launch-1.0 Not tainted 4.1.20-ttc_fslc_4.1-1.0.x-imx-01622-gd034af9-dirty #21
[  124.878944] Hardware name: Freescale i.MX6 SoloX (Device Tree)
[  124.884779] task: a8261980 ti: a8f9e000 task.ti: a8f9e000
[  124.890192] PC is at mx6s_vidioc_enum_framesizes+0x44/0x10c
[  124.895768] LR is at format_by_fourcc+0x58/0x94
[  124.900303] pc : [<80436190>]    lr : [<8043602c>]    psr: 40070013
[  124.900303] sp : a8f9fdc0  ip : 00000000  fp : 00000000
[  124.911782] r10: a8375c10  r9 : a8c6b9c0  r8 : 00000000
[  124.917007] r7 : 808f7758  r6 : 00000001  r5 : a82bf86c  r4 : a8f9fe78
[  124.923535] r3 : 00000000  r2 : 00200000  r1 : 00000000  r0 : 00000000
[  124.930065] Flags: nZcv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment user
[  124.937201] Control: 10c53c7d  Table: a8fbc059  DAC: 00000015
[  124.942949] Process gst-launch-1.0 (pid: 337, stack limit = 0xa8f9e208)
[  124.949565] Stack: (0xa8f9fdc0 to 0xa8fa0000)
[  124.953927] fdc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000001
[  124.962109] fde0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  124.970291] fe00: 00000003 c02c564a a83ac000 80409b5c 80907088 00000002 a8afc000 a8f9fe78
[  124.978473] fe20: 808f77b0 00000000 00000128 000004a0 808ca2a0 00000000 a8f9fe6c 80652b5c
[  124.986654] fe40: 00000001 a8b03800 a8b03600 c02c564a 0000002c 00000000 00000003 7eeb43c4
[  124.994835] fe60: a8f9fe78 8040993c 00000008 80409668 a8c6b9c0 00000000 00000000 00000000
[  125.003016] fe80: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  125.011197] fea0: 00000000 000000ca 802d9228 8004d6d0 00000004 7eeb1d48 a623b6f0 a8b03800
[  125.019379] fec0: 7eeb1e12 000000ca a8f9e000 802d58c0 a8443bc0 000000ca a8f9e000 a8d5df00
[  125.027561] fee0: 00000001 8095146c 7eeb425c 8005d0a4 a8d5df00 00000002 a623b6f0 a83ac000
[  125.035742] ff00: a8c6b9c0 c02c564a 7eeb43c4 a8375de4 a8f9e000 00000000 76a6bb1c 80405b98
[  125.043924] ff20: 7eeb43c4 a855e2b0 a8c6b9c0 00000005 7eeb43c4 800e19f4 00000000 00000000
[  125.052106] ff40: 1501fb12 a8d5df00 000000ca a623b6f0 00000002 a8d5df08 a8f9e000 00000000
[  125.060288] ff60: 7eeb425c 800d0e30 00000000 00000000 a8c6b9c0 00000005 a8c6b9c0 c02c564a
[  125.068469] ff80: 7eeb43c4 a8f9e000 00000000 800e1c64 002760c8 00000005 76fade28 00000036
[  125.076651] ffa0: 8000f464 8000f2e0 002760c8 00000005 00000005 c02c564a 7eeb43c4 00000000
[  125.084832] ffc0: 002760c8 00000005 76fade28 00000036 7eeb44bc 7eeb43f0 7eeb43c4 76a6bb1c
[  125.093014] ffe0: 76a9ba5c 7eeb4384 76a88bc4 76caf43c 60010010 00000005 a43bfa4c 9eb0783a
[  125.101206] [<80436190>] (mx6s_vidioc_enum_framesizes) from [<80409b5c>] (__video_do_ioctl+0x220/0x324)
[  125.110607] [<80409b5c>] (__video_do_ioctl) from [<80409668>] (video_usercopy+0x1b8/0x480)
[  125.118882] [<80409668>] (video_usercopy) from [<80405b98>] (v4l2_ioctl+0x118/0x150)
[  125.126638] [<80405b98>] (v4l2_ioctl) from [<800e19f4>] (do_vfs_ioctl+0x414/0x650)
[  125.134217] [<800e19f4>] (do_vfs_ioctl) from [<800e1c64>] (SyS_ioctl+0x34/0x5c)
[  125.141538] [<800e1c64>] (SyS_ioctl) from [<8000f2e0>] (ret_fast_syscall+0x0/0x3c)
[  125.149114] Code: e58d3000 e58d601c ebffff91 e5943004 (e5902024)
[  125.157973] ---[ end trace 376f111085f44e14 ]---

@sasamy
Copy link
Contributor

sasamy commented Apr 19, 2016

Hi,
couldn't you try this patch?

sasamy@192bbcc

Unfortunately I have no i.MX6SX processor.

@lfauster
Copy link
Author

Thanks for your support!

I tried the patch with following insights:

  • I need to specify the property "input=0" for imxv4l2videosrc as otherwise the call of VIDIOC_S_INPUT fails as it only accepts "0" as valid value; I guess this ioctl should switch between the 4 available (analog-)camera-inputs on the SoloX, but apparently is currently not implemented (see mx6s_vidioc_s_input in mx6s_capture.c)
  • I get following error with the patch:
~# GST_DEBUG=3 gst-launch-1.0 imxv4l2videosrc device=/dev/video0 input=0 ! fakesink
Setting pipeline to PAUSED ...
0:00:00.618724000   343  0x18eb9a0 WARN         imxv4l2videosrc v4l2src.c:139:gst_imx_v4l2src_is_tvin:<imxv4l2videosrc0> VIDIOC_S_STD failed: Inappropriate ioctl for device
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock

** (gst-launch-1.0:343): CRITICAL **: gst_video_format_to_string: assertion 'format != GST_VIDEO_FORMAT_UNKNOWN' failed
0:00:00.674146334   343  0x18f7580 ERROR             video-info video-info.c:420:gst_video_info_from_caps: no format given
0:00:00.674667000   343  0x18f7580 ERROR      imxv4l2bufferpool v4l2_buffer_pool.c:99:gst_imx_v4l2_buffer_pool_set_config:<imxv4l2bufferpool0> caps cannot be parsed for video info
0:00:00.675106000   343  0x18f7580 ERROR             bufferpool gstbufferpool.c:525:gst_buffer_pool_set_active:<imxv4l2bufferpool0> pool was not configured
0:00:00.675453000   343  0x18f7580 ERROR                basesrc gstbasesrc.c:3005:gst_base_src_set_allocation:<imxv4l2videosrc0> failed to activate bufferpool.
0:00:00.676593334   343  0x18f7580 WARN                 basesrc gstbasesrc.c:2943:gst_base_src_loop:<imxv4l2videosrc0> error: Internal data flow error.
0:00:00.677078667   343  0x18f7580 WARN                 basesrc gstbasesrc.c:2943:gst_base_src_loop:<imxv4l2videosrc0> error: streaming task paused, reason not-negotiated (-4)
ERROR: from element /GstPipeline:pipeline0/GstImxV4l2VideoSrc:imxv4l2videosrc0: Internal data flow error.
Additional debug info:
../../../../gstreamer-1.6.3/libs/gst/base/gstbasesrc.c(2943): gst_base_src_loop (): /GstPipeline:pipeline0/GstImxV4l2VideoSrc:imxv4l2videosrc0:
streaming task paused, reason not-negotiated (-4)
Execution ended after 0:00:00.022870000
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...

I guess the reason for that is that VIDIOC_G_FMT always returns "0" as pixelformat. I don't know if this is intended, however I changed the mx6s_capture driver to return something meaningful:

diff --git a/drivers/media/platform/mxc/subdev/mx6s_capture.c b/drivers/media/platform/mxc/subdev/mx6s_capture.c
index a5b2d3d..b868862 100644
--- a/drivers/media/platform/mxc/subdev/mx6s_capture.c
+++ b/drivers/media/platform/mxc/subdev/mx6s_capture.c
@@ -1458,6 +1458,7 @@ static int mx6s_vidioc_s_fmt_vid_cap(struct file *file, void *priv,
        csi_dev->pix.height    = f->fmt.pix.height;
        csi_dev->pix.sizeimage = f->fmt.pix.sizeimage;
        csi_dev->pix.field     = f->fmt.pix.field;
+       csi_dev->pix.pixelformat = csi_dev->fmt->pixelformat;
        csi_dev->type          = f->type;
        dev_dbg(csi_dev->dev, "set to pixelformat '%4.6s'\n",
                        (char *)&csi_dev->fmt->name);
  • Afterwards I was able to launch the pipline with the "fakesink". As the mx6s_capture driver prints some debug-information in form of repeated "queue" and "csi_frame_done" operations I assume that at least something is working.
  • However, I'm still not able to use another sink, e.g. imxpxpvideosink or fbdevsink (which work together with videotestsrc):
~# GST_DEBUG=3 gst-launch-1.0 imxv4l2videosrc device=/dev/video0 input=0 ! imxpxpvideosink
Setting pipeline to PAUSED ...
0:00:00.600840667   353  0x2079a40 WARN         imxv4l2videosrc v4l2src.c:139:gst_imx_v4l2src_is_tvin:<imxv4l2videosrc0> VIDIOC_S_STD failed: Inappropriate ioctl for device
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
0:00:00.639791667   353  0x20819b0 WARN                GST_PADS gstpad.c:3990:gst_pad_peer_query:<imxv4l2videosrc0:src> could not send sticky events
0:00:00.896320667   353  0x20819b0 WARN                 basesrc gstbasesrc.c:2943:gst_base_src_loop:<imxv4l2videosrc0> error: Internal data flow error.
0:00:00.896762334   353  0x20819b0 WARN                 basesrc gstbasesrc.c:2943:gst_base_src_loop:<imxv4l2videosrc0> error: streaming task paused, reason not-negotiated (-4)
ERROR: from element /GstPipeline:pipeline0/GstImxV4l2VideoSrc:imxv4l2videosrc0: Internal data flow error.
Additional debug info:
../../../../gstreamer-1.6.3/libs/gst/base/gstbasesrc.c(2943): gst_base_src_loop (): /GstPipeline:pipeline0/GstImxV4l2VideoSrc:imxv4l2videosrc0:
streaming task paused, reason not-negotiated (-4)
Execution ended after 0:00:00.266246333
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...

@lfauster
Copy link
Author

lfauster commented Apr 20, 2016

Where is that format broken? In the PxP or the gstreamer-imx plugins? When I try to use imxeglvivsink or imxg2dvideosink I see the same error. Is this something that can be fixed?
It works with the official freescale plugins (imxv4l2src & imxv4l2sink).

Thanks for your help!

EDIT: Great... the freescale plugins do "work", but cause a very high cpu load. So I guess there is some software-conversion going on.

@sasamy
Copy link
Contributor

sasamy commented Apr 20, 2016

I think that a problem in PxP because the unit test uses software CSC. You can try videoconvert

gst-launch-1.0 imxv4l2videosrc ! videoconvert ! imxg2dvideosink

@lfauster
Copy link
Author

With videoconvert in the pipeline I can successfully create&start it. However, the picture shown on the display is very greenish (I can recognize the camera-picture so the streaming works, the colors are just way off). Also, the CPU load gets quite high which of course makes sense due to the software-conversion.

I guess with the broken formats you mean the problem described here: https://lists.yoctoproject.org/pipermail/meta-freescale/2015-April/013376.html
As far as I understood, this should only affect the PxP sink/converter?

@sasamy
Copy link
Contributor

sasamy commented Apr 21, 2016

Unfortunately I don't know about functionality of PxP, but it can be checked.
Theoretically, this patch should enable the desired format for VADC

sasamy@c11a454

gst-launch-1.0 imxv4l2videosrc ! imxpxpvideosink

@dv1
Copy link
Collaborator

dv1 commented Jul 19, 2016

@lfauster @sasamy Any updates on this? I want to include SoloX support in the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants