sasamy / tw6869

tw6869/65 media bridge driver
11 stars 10 forks source link

Failure to start capture with V4L2_MEMORY_USERPTR #2

Open dreampet opened 8 years ago

dreampet commented 8 years ago

Use JNI to capture Video , It works fine in V4L2_MEMORY_MMAP method, but failure in V4L2_MEMORY_USERPTR with IPU and G2D

HW: SABRESD_6DL Android: 5.1.1 Kernal: Linux version 3.14.52-141236-g279192c-dirty (dev@hejiadev) (gcc version 4.6.x-google 20120106 (prerelease) (GCC) ) #8 SMP PREEMPT Wed Apr 6 10:15:44 CST 2016

Unable to handle kernel NULL pointer dereference at virtual address 00000000 pgd = c8f84000 [00000000] *pgd=00000000 Internal error: Oops: 805 [#1] PREEMPT SMP ARM Modules linked in: CPU: 0 PID: 1283 Comm: d.openxc.webcam Not tainted 3.14.52-141236-g279192c-dirty #8 task: c9a99700 ti: c8f80000 task.ti: c8f80000 PC is at buffer_init+0x34/0x40 LR is at vb2_plane_vaddr+0x40/0x4c pc : [] lr : [] psr: a00f0013 sp : c8f81b80 ip : 000cb000 fp : c9ebfc00 r10: 00000001 r9 : 00000000 r8 : d49403c4 r7 : d49403c0 r6 : c9ebfc0c r5 : c8f81bd4 r4 : c9ebfc00 r3 : 26200000 r2 : d49403c0 r1 : 00000000 r0 : 00000000 Flags: NzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment user Control: 10c53c7d Table: 18f8404a DAC: 00000015

PC: 0xc05c7054: 7054 e5812004 e5821000 e585b2a0 e58592a4 e1a05007 e5b372a0 e1580003 e2477e2a 7074 1afffff0 e1a00006 e1a0100a eb0bb2b0 e2840014 ebea0879 e3a00000 e8bd8ff8 7094 c0c92500 c09307f8 c0b529c8 e92d4010 e3a01000 e1a04000 ebff48a1 e2843e2a 70b4 e3a01000 e5902000 e1a00004 e58432a0 e58432a4 e58422a8 ebff4886 e59432a8 70d4 e5803000 e3a00000 e8bd8010 e92d41f0 e2805060 e1a04000 e590707c e24dd008 70f4 e1a00005 eb0bb344 e5943084 e3530000 0a000035 e5943004 e3530000 0a000032 7114 e5943008 e3530000 0a00002f e5946408 e2843b01 e2833008 e1560003 0a00002a 7134 e2077001 e5960004 e596c000 e3a01c01 e0843107 e3401010 e3a02c02 e3402020

LR: 0xc05992ac: 92ac e59d5004 e1530005 0afffff1 e599300c e3e0b00d e59302c0 e2800038 ebeb444f 92cc eaffffa5 e3e0b015 eaffffee e59f0008 eb0c45b0 e7f001f2 c0b4ca64 c0b4c9fc 92ec e92d4008 e5903228 e5902224 e1530001 33a00000 38bd8008 e0811081 e0800101 930c e5900240 e3500000 08bd8008 e5923018 e593302c e3530000 0a000001 e12fff33 932c e8bd8008 e1a00003 e8bd8008 e92d4008 e5903228 e5902224 e1530001 33a00000 934c 38bd8008 e0811081 e0800101 e5900240 e3500000 08bd8008 e5923018 e5933030 936c e3530000 0a000001 e12fff33 e8bd8008 e1a00003 e8bd8008 e92d0070 e1a03001 938c e5911004 e1a0c000 e2410009 e3500001 9a00002a e3510002 1a000018 e5931008

SP: 0xc8f81b00: 1b00 00000000 00000001 c0c9c5e8 d45e2468 00000000 c94e67c0 000000cb c059eb2c 1b20 00000000 c05c70d4 a00f0013 ffffffff c8f81b6c c0012498 00000000 00000000 1b40 d49403c0 26200000 c9ebfc00 c8f81bd4 c9ebfc0c d49403c0 d49403c4 00000000 1b60 00000001 c9ebfc00 000cb000 c8f81b80 c059932c c05c70d4 a00f0013 ffffffff 1b80 c9ebfc3c c05998b0 00000000 00000001 d4c13f1c 000cb000 944a1000 d49dfd34 1ba0 00000018 d45b08e8 d4001f00 d4001f00 8040003f c08ab8c4 00000000 c8f80000 1bc0 80400040 000002d0 d4001e80 d4001e80 80200012 80400040 d4001f00 d4001f00 1be0 8040003f c08ab8c4 d4001f00 d4001f00 8040003f c08ab8c4 00000000 c8f80000

FP: 0xc9ebfb80: fb80 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 fba0 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 fbc0 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 fbe0 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 fc00 00000000 00000001 00000000 00000000 00000000 00000000 00000000 00000000 fc20 00000000 00000000 00000000 00000000 00000002 00000000 00000000 00000000 fc40 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 fc60 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000

R2: 0xd4940340: 0340 00000004 00000002 00000003 00000000 00070007 c97bec40 c97bec40 00000000 0360 00ffffff 00000000 c05865e8 c093089c 1fef8335 800000f0 1e020fc1 00000000 0380 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 03a0 d49403a8 00000000 00000000 00000000 d49403b0 d49403b0 c9a99700 00000000 03c0 00000001 00000013 00000000 d49403a8 c97bec40 c0d083f0 c092d004 d49400d8 03e0 000002ac 00002000 00000004 00000002 c9ebfc00 c9ebf000 c9ebdc00 c9ebd800 0400 c9ebec00 c9ebe800 00000000 00000000 00000000 00000000 00000000 00000000 0420 00000000max11801_ts 1-0048: FIFO_RD_AUX_MSB read fails

00000000 00000000 00000000 00000000 00000000 00000000 00000000

R4: 0xc9ebfb80: fb80 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 fba0 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 fbc0 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 fbe0 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 fc00 00000000 00000001 00000000 00000000 00000000 00000000 00000000 00000000 fc20 00000000 00000000 00000000 00000000 00000002 00000000 00000000 00000000 fc40 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 fc60 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000

R5: 0xc8f81b54: 1b54 d49403c0 d49403c4 00000000 00000001 c9ebfc00 000cb000 c8f81b80 c059932c 1b74 c05c70d4 a00f0013 ffffffff c9ebfc3c c05998b0 00000000 00000001 d4c13f1c 1b94 000cb000 944a1000 d49dfd34 00000018 d45b08e8 d4001f00 d4001f00 8040003f 1bb4 c08ab8c4 00000000 c8f80000 80400040 000002d0 d4001e80 d4001e80 80200012 1bd4 80400040 d4001f00 d4001f00 8040003f c08ab8c4 d4001f00 d4001f00 8040003f 1bf4 c08ab8c4 00000000 c8f80000 80400040 000002d0 d4c89f24 d4001f00 00000000 1c14 80400040 c8f80000 2da89000 00000000 80400040 d4609100 c0620594 d4505900 1c34 80400040 c9732080 d4001f00 00000000 000002d0 c8f80000 d4001f00 00000000

R6: 0xc9ebfb8c: fb8c 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 fbac 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 fbcc 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 fbec 00000000 00000000 00000000 00000000 00000000 00000000 00000001 00000000 fc0c 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 fc2c 00000000 00000002 00000000 00000000 00000000 00000000 00000000 00000000 fc4c 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 fc6c 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000

R7: 0xd4940340: 0340 00000004 00000002 00000003 00000000 00070007 c97bec40 c97bec40 00000000 0360 00ffffff 00000000 c05865e8 c093089c 1fef8335 800000f0 1e020fc1 00000000 0380 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 03a0 d49403a8 00000000 00000000 00000000 d49403b0 d49403b0 c9a99700 00000000 03c0 00000001 00000013 00000000 d49403a8 c97bec40 c0d083f0 c092d004 d49400d8 03e0 000002ac 00002000 00000004 00000002 c9ebfc00 c9ebf000 c9ebdc00 c9ebd800 0400 c9ebec00 c9ebe800 00000000 00000000 00000000 00000000 00000000 00000000 0420 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000

R8: 0xd4940344: 0344 00000002 00000003 00000000 00070007 c97bec40 c97bec40 00000000 00ffffff 0364 00000000 c05865e8 c093089c 1fef8335 800000f0 1e020fc1 00000000 00000000 0384 00000000 00000000 00000000 00000000 00000000 00000000 00000000 d49403a8 03a4 00000000 00000000 00000000 d49403b0 d49403b0 c9a99700 00000000 00000001 03c4 00000013 00000000 d49403a8 c97bec40 c0d083f0 c092d004 d49400d8 000002ac 03e4 00002000 00000004 00000002 c9ebfc00 c9ebf000 c9ebdc00 c9ebd800 c9ebec00 0404 c9ebe800 00000000 00000000 00000000 00000000 00000000 00000000 00000000 0424 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 Process d.openxc.webcam (pid: 1283, stack limit = 0xc8f80238) Stack: (0xc8f81b80 to 0xc8f82000) 1b80: c9ebfc3c c05998b0 00000000 00000001 d4c13f1c 000cb000 944a1000 d49dfd34 1ba0: 00000018 d45b08e8 d4001f00 d4001f00 8040003f c08ab8c4 00000000 c8f80000 1bc0: 80400040 000002d0 d4001e80 d4001e80 80200012 80400040 d4001f00 d4001f00 1be0: 8040003f c08ab8c4 d4001f00 d4001f00 8040003f c08ab8c4 00000000 c8f80000 1c00: 80400040 000002d0 d4c89f24 d4001f00 00000000 80400040 c8f80000 2da89000 1c20: 00000000 80400040 d4609100 c0620594 d4505900 80400040 c9732080 d4001f00 1c40: 00000000 000002d0 c8f80000 d4001f00 00000000 000002d0 c8f80000 2da89000 1c60: 00000000 0005ab38 00000000 c00e9ee0 d4505600 c8f81cb8 d4609100 c0620594 1c80: d4505900 00000503 d4506780 c062d520 c9732080 c0620594 c8563dc0 0000001e 1ca0: d4c1d000 c06299c8 c9a99700 00000000 d4505900 0000001e 00000001 c06343a8 1cc0: c97326c0 c8563dc0 c9732b40 00000001 d4505900 c8f81da8 00000000 00000000 1ce0: d4505900 c0628104 00000000 c8f81e40 00000001 00000001 c8f81d18 c8f81d18 1d00: 00040000 c02c4958 00000000 c8f81da8 c8f81d5c c08b3e78 c8f81d5c c08b3b70 1d20: 00000000 c005a0e0 00000000 000004d0 c072b178 00000100 00000069 d49a3438 1d40: c00ffc6c 00000000 d49a3444 00000001 000000c3 00000001 00000001 c00ffccc 1d60: 00000000 c08b3e78 00000000 c08b3b70 00000001 c9ebfc00 c8f81e48 d49403c0 1d80: d4c17df8 00000002 c97bec40 c093089c 00000000 c059a9b0 c82a2300 d49403c0 1da0: c9ebfc00 c8f81e48 00000002 c059c2cc c059c42c c82a2300 c8f81e48 c093089c 1dc0: c97bec40 c05886dc c8f81e48 d4940180 c044560f c0ce3c3c c82a2300 c058b4a8 1de0: c872fcc0 00000000 c8f80000 00000000 c8f81e48 00000000 00000000 00000000 1e00: 00000000 00000000 00000000 ffffffff ffffffff c044560f befabf10 00000000 1e20: 00000044 00000000 00000000 c8f81e48 00000000 c058a694 00000000 00000003 1e40: c82a2300 c058b260 00000000 00000001 00000000 00000000 00000000 00000000 1e60: 00000000 00000000 00000000 00000000 00000000 00000000 00000002 944a1000 1e80: 000cb000 00000000 00000000 00000000 d22e5520 c0126a84 00000000 00000000 1ea0: d49cb180 00000000 00000000 d49cb188 00000000 00000000 00000000 00000000 1ec0: 00000000 0000002a d49cb180 c82a2300 d49403a8 c044560f d4940180 befabf10 1ee0: c8f80000 00000000 12c01080 c0586b84 d4a05dd8 befabf10 c82a2300 c044560f 1f00: 00000019 c00fee70 befaba4e 00000002 befaba58 00000008 befaba84 d4a05dd8 1f20: 00000001 0000560f d4a07330 00000001 c8f80000 00000000 12c01080 c02cba9c 1f40: 0000560f c8f81f58 00000006 c8726550 d21cb770 0000560f 0000000b c8f81f4c 1f60: 12c01080 c82a2301 c82a2300 befabf10 c044560f 00000019 c8f80000 00000000 1f80: 12c01080 c00ff40c befabee8 00000000 00000019 c044560f 00000036 c000e564 1fa0: 00000000 c000e3e0 00000000 00000019 00000019 c044560f befabf10 befabee8 1fc0: 00000000 00000019 c044560f 00000036 befabf10 000002d0 a3d13a20 12c01080 1fe0: befabf10 befabed8 b6ea6799 b6e8e44c 800f0010 00000019 b68d2205 b68d0c2d from from from from from from from from from from Code: e58432a4 e58422a8 ebff4886 e59432a8 (e5803000) ---[ end trace 65d4fd5acf6a79b6 ]--- Kernel panic - not syncing: Fatal exception CPU1: stopping CPU: 1 PID: 1296 Comm: GCDaemon Tainted: G D 3.14.52-141236-g279192c-dirty #8 from from from from from Exception stack(0xc808bfb0 to 0xc808bff8) bfa0: b48df1f0 4ffdfa28 4fe9b000 b4874120 bfc0: 504a7c3c 504a6600 b3c0a458 00005be8 0000058a b3c0a458 b3c0a450 00000001 bfe0: 00010000 b3c0a3e8 b46267ef b46267e8 80070030 ffffffff Rebooting in 5 seconds..

dreampet commented 8 years ago

update: I use the same app(use JNI to capture video to IPU with deinterlacing to G2D ) on Android 4.4.2 use the tw6869 driver from https://community.freescale.com/docs/DOC-95143 , it works fine.

sasamy commented 8 years ago

I deleted an unnecessary code which caused this error

https://github.com/sasamy/tw6869/commit/99d4c21cc25c5980d367d5f6c6cc071997d65865

but I am not sure that the driver will correctly work with V4L2_MEMORY_USERPTR. If you need to transmit a physical address through userptr (zero-copy) as it is done in examples of Freescale/NXP (mxc_v4l2_tvin_isl79985.tar.gz)

https://community.freescale.com/docs/DOC-158531

then the small patch for a kernel (userptr callbacks of videobuf2-dma-contig.c) and small addition for this driver is necessary.

dreampet commented 8 years ago

tks, use the latest code, and the new problem find:

HW: SABRESD_6DL Android: 5.1.1 Kernal: Linux version 3.14.52-141236-g279192c-dirty (dev@hejiadev) (gcc version 4.6.x-google 20120106 (prerelease) (GCC) ) #8 SMP PREEMPT Wed Apr 6 10:15:44 CST 2016

log:

ERROR: v4l2 capture: mxc_v4l_dqueue timeout enc_counter 0 YUYV imx-ipuv3 2400000.ipu: IPU Warning - IPU_INT_STAT_10 = 0x20000000 imx-ipuv3 2400000.ipu: IPU Warning - IPU_INT_STAT_10 = 0x20000000 imx-ipuv3 2400000.ipu: ERR:[0xc8085400]-no:0xf0 "init_ic only_ic" ret:-22,line:2778 imx-ipuv3 2400000.ipu: ERR:[0xc8085400]-no:0xf0"ipu_disable_ch only_ic" ret:-13,line:2629 imx-ipuv3 2400000.ipu: ERR:[0xc8085400]-no:0xf0"ipu_disable_ch only_ic_p" ret:-13,line:2634 imx-ipuv3 2400000.ipu: ERR:[0xc8085400]-no:0xf0"ipu_disable_ch only_ic_n" ret:-13,line:2638 imx-ipuv3 2400000.ipu: IPU Warning - IPU_INT_STAT_10 = 0x20000000 imx-ipuv3 2400000.ipu: ERR:[0xd5e37600]-no:0x100 "init_ic only_ic" ret:-22,line:2778 imx-ipuv3 2400000.ipu: ERR:[0xd5e37600]-no:0x100"ipu_disable_ch only_ic" ret:-13,line:2629 imx-ipuv3 2400000.ipu: ERR:[0xd5e37600]-no:0x100"ipu_disable_ch only_ic_p" ret:-13,line:2634 imx-ipuv3 2400000.ipu: ERR:[0xd5e37600]-no:0x100"ipu_disable_ch only_ic_n" ret:-13,line:2638 ERROR: v4l2 capture: VIDIOC_QBUF: overwrite done buffer. imx-ipuv3 2400000.ipu: IPU Warning - IPU_INT_STAT_10 = 0x20000000 imx-ipuv3 2400000.ipu: ERR:[0xd5e37c00]-no:0x110 "init_ic only_ic" ret:-22,line:2778 imx-ipuv3 2400000.ipu: ERR:[0xd5e37c00]-no:0x110"ipu_disable_ch only_ic" ret:-13,line:2629 imx-ipuv3 2400000.ipu: ERR:[0xd5e37c00]-no:0x110"ipu_disable_ch only_ic_p" ret:-13,line:2634 imx-ipuv3 2400000.ipu: ERR:[0xd5e37c00]-no:0x110"ipu_disable_ch only_ic_n" ret:-13,line:2638 ERROR: v4l2 capture: VIDIOC_QBUF: buffer already queued imx-ipuv3 2400000.ipu: ERR:[0xc8084200]-no:0x120 "init_ic only_ic" ret:-22,line:2778 imx-ipuv3 2400000.ipu: ERR:[0xc8084200]-no:0x120"ipu_disable_ch only_ic" ret:-13,line:2629 imx-ipuv3 2400000.ipu: ERR:[0xc8084200]-no:0x120"ipu_disable_ch only_ic_p" ret:-13,line:2634 imx-ipuv3 2400000.ipu: ERR:[0xc8084200]-no:0x120"ipu_disable_ch only_ic_n" ret:-13,line:2638 ERROR: v4l2 capture: VIDIOC_QBUF: buffer already queued ERROR: v4l2 capture: VIDIOC_DQBUF: Buffer not filled. ERROR: v4l2 capture: mxc_v4l_dqueue() interrupt received

sasamy commented 8 years ago

I added support for NXP userptr DMA:

https://github.com/sasamy/tw6869/commit/06781a4e70d980c5d3668833a997c47797ca530c

a patch for a Linux kernel:

https://github.com/sasamy/mxc-v4l2-tvin-tw6869-vdi/commit/97641da300b667db6ddc8d5edaf3d18006dba99b

and an example:

https://github.com/sasamy/mxc-v4l2-tvin-tw6869-vdi

In our case use of DMA is preferred choice.

For standard API (the virtual memory is allocated in the user application through malloc) it is possible to try another driver

https://github.com/boundarydevices/linux-imx6/tree/boundary-imx_3.14.52_1.1.0_ga/drivers/media/pci/tw686x

dreampet commented 8 years ago

thks the new commit, I will test tomorrow ! I also try to capture and process the video frame with DMA today, you are right, DMA method is more flexible.

dreampet commented 8 years ago

with the latest commit and patch, but still can not work in Android 5.1.1 now only the ipu error msg found when exec ioctl(fd_ipu, IPU_QUEUE_TASK, &task) :

imx-ipuv3 2400000.ipu: IPU Warning - IPU_INT_STAT_5 = 0x00100000 imx-ipuv3 2400000.ipu: ERR:[0xd3cad800]-no:0x10 "init_ic only_ic" ret:-22,line:2784 imx-ipuv3 2400000.ipu: ERR:[0xd3cad800]-no:0x10"ipu_disable_ch only_ic" ret:-13,line:2635 imx-ipuv3 2400000.ipu: ERR:[0xd3cad800]-no:0x10"ipu_disable_ch only_ic_p" ret:-13,line:2640 imx-ipuv3 2400000.ipu: ERR:[0xd3cad800]-no:0x10"ipu_disable_ch only_ic_n" ret:-13,line:2644 imx-ipuv3 2400000.ipu: ERR:[0xd3ee4200]-no:0x20 "init_ic only_ic" ret:-22,line:2784 imx-ipuv3 2400000.ipu: ERR:[0xd3ee4200]-no:0x20"ipu_disable_ch only_ic" ret:-13,line:2635 imx-ipuv3 2400000.ipu: ERR:[0xd3ee4200]-no:0x20"ipu_disable_ch only_ic_p" ret:-13,line:2640 imx-ipuv3 2400000.ipu: ERR:[0xd3ee4200]-no:0x20"ipu_disable_ch only_ic_n" ret:-13,line:2644 imx-ipuv3 2400000.ipu: ERR:[0xd3ee4200]-no:0x30 "init_ic only_ic" ret:-22,line:2784 imx-ipuv3 2400000.ipu: ERR:[0xd3ee4200]-no:0x30"ipu_disable_ch only_ic" ret:-13,line:2635 imx-ipuv3 2400000.ipu: ERR:[0xd3ee4200]-no:0x30"ipu_disable_ch only_ic_p" ret:-13,line:2640 imx-ipuv3 2400000.ipu: ERR:[0xd3ee4200]-no:0x30"ipu_disable_ch only_ic_n" ret:-13,line:2644 imx-ipuv3 2400000.ipu: ERR:[0xd3cad200]-no:0x40 "init_ic only_ic" ret:-22,line:2784 imx-ipuv3 2400000.ipu: ERR:[0xd3cad200]-no:0x40"ipu_disable_ch only_ic" ret:-13,line:2635 imx-ipuv3 2400000.ipu: ERR:[0xd3cad200]-no:0x40"ipu_disable_ch only_ic_p" ret:-13,line:2640 imx-ipuv3 2400000.ipu: ERR:[0xd3cad200]-no:0x40"ipu_disable_ch only_ic_n" ret:-13,line:2644 imx-ipuv3 2400000.ipu: ERR:[0xd3ee4c00]-no:0x50 "init_ic only_ic" ret:-22,line:2784 imx-ipuv3 2400000.ipu: ERR:[0xd3ee4c00]-no:0x50"ipu_disable_ch only_ic" ret:-13,line:2635 imx-ipuv3 2400000.ipu: ERR:[0xd3ee4c00]-no:0x50"ipu_disable_ch only_ic_p" ret:-13,line:2640 imx-ipuv3 2400000.ipu: ERR:[0xd3ee4c00]-no:0x50"ipu_disable_ch only_ic_n" ret:-13,line:2644 imx-ipuv3 2400000.ipu: ERR:[0xd3ee4c00]-no:0x60 "init_ic only_ic" ret:-22,line:2784

sasamy commented 8 years ago

Unfortunately I don't know why the error in Android appears - in Linux the example https://github.com/sasamy/mxc-v4l2-tvin-tw6869-vdi works without problems and I can check only for Linux now.

yinyan1031 commented 6 years ago

hello, dear how did u fix this kernel crash issue finally? Thanks so much! "Failure to start capture with V4L2_MEMORY_USERPTR"