cancel
Showing results for 
Search instead for 
Did you mean: 
Visitor
Visitor
9,766 Views
Registered: ‎05-26-2015

V4L2 YUV 4:2:0 Support

Jump to solution

I'm trying to implement an H.264 video compression pipeline on Zynq platform. I have YUV 4:2:2 sensor processing working using V4L2 and VDMA drivers. Now I want to further subsample my video input from 4:2:2 to 4:2:0 using Chroma Resampler IP. However, by looking at Linux drivers' source codes I can't see yuv420 being supported. Am I missing something or 4:2:0 chroma sampling is not supported at the moment? I checked master and master-next branches from [1]. I'm using [2] at the moment though. (I have a Zybo board)

 

Thanks,

Caglar

 

[1] https://github.com/Xilinx/linux-xlnx

[2] https://github.com/DigilentInc/Linux-Digilent-Dev.git

 

 

0 Kudos
1 Solution

Accepted Solutions
Highlighted
Xilinx Employee
Xilinx Employee
17,319 Views
Registered: ‎10-01-2013

Re: V4L2 YUV 4:2:0 Support

Jump to solution

Caglar,

 

We need to add the format descriptor for YUV 4:2:0 as below:

 

diff --git a/drivers/media/platform/xilinx/xilinx-vip.c b/drivers/media/platform/xilinx/xilinx-vip.c
index 8faa370..b6bd459 100644
--- a/drivers/media/platform/xilinx/xilinx-vip.c
+++ b/drivers/media/platform/xilinx/xilinx-vip.c
@@ -27,6 +27,8 @@
*/

static const struct xvip_video_format xvip_video_formats[] = {
+ { XVIP_VF_YUV_420, 8, NULL, MEDIA_BUS_FMT_UYVY8_1X16,
+ 2, V4L2_PIX_FMT_YUV420, "4:2:0, packed, YUYV" },
{ XVIP_VF_YUV_422, 8, NULL, MEDIA_BUS_FMT_UYVY8_1X16,
2, V4L2_PIX_FMT_YUYV, "4:2:2, packed, YUYV" },
{ XVIP_VF_YUV_444, 8, NULL, MEDIA_BUS_FMT_VUY8_1X24,

 

We only added the format descriptors based on actual use cases so far, because there's not much point of adding stuff which will never be used. I'll check this change into the repo.

 

Thanks,

-hyun

View solution in original post

0 Kudos
6 Replies
Highlighted
Xilinx Employee
Xilinx Employee
17,320 Views
Registered: ‎10-01-2013

Re: V4L2 YUV 4:2:0 Support

Jump to solution

Caglar,

 

We need to add the format descriptor for YUV 4:2:0 as below:

 

diff --git a/drivers/media/platform/xilinx/xilinx-vip.c b/drivers/media/platform/xilinx/xilinx-vip.c
index 8faa370..b6bd459 100644
--- a/drivers/media/platform/xilinx/xilinx-vip.c
+++ b/drivers/media/platform/xilinx/xilinx-vip.c
@@ -27,6 +27,8 @@
*/

static const struct xvip_video_format xvip_video_formats[] = {
+ { XVIP_VF_YUV_420, 8, NULL, MEDIA_BUS_FMT_UYVY8_1X16,
+ 2, V4L2_PIX_FMT_YUV420, "4:2:0, packed, YUYV" },
{ XVIP_VF_YUV_422, 8, NULL, MEDIA_BUS_FMT_UYVY8_1X16,
2, V4L2_PIX_FMT_YUYV, "4:2:2, packed, YUYV" },
{ XVIP_VF_YUV_444, 8, NULL, MEDIA_BUS_FMT_VUY8_1X24,

 

We only added the format descriptors based on actual use cases so far, because there's not much point of adding stuff which will never be used. I'll check this change into the repo.

 

Thanks,

-hyun

View solution in original post

0 Kudos
Highlighted
Visitor
Visitor
9,696 Views
Registered: ‎05-26-2015

Re: V4L2 YUV 4:2:0 Support

Jump to solution

Hyun,

 

I applied your patch but couldn't verified due to DMA problems with latest git head. It seems like your patch only applies after commit 5af0e4da. I think it is safe to assume that rest of the v4l2 capture pipeline will work with this change.

 

Thanks,

Caglar

0 Kudos
Highlighted
Xilinx Employee
Xilinx Employee
9,687 Views
Registered: ‎10-01-2013

Re: V4L2 YUV 4:2:0 Support

Jump to solution

Caglar,

 

The change above didn't mean to be applied as a patch, but you are correct. it's based on the latest master branch. Could you describe a little more on DMA issue? The change doesn't do anything related to DMA, so DMA should just work as before in my opinion.

 

My understanding is that you want to capture frames in YUV420, and encode those frames in DDR using your H.264( ... ->chroma resampler -> vdma -> DDR -> H.264 compression ->...). There are couple of things to be changed.

 

- DTS: The output port format should be changed to YUV_420. You may want to configure the Chroma resampler output pad format to YUV420 using media-ctl.

 

port@1 {
    reg = <1>;

    xlnx,output-video-format = <XVIP_VF_YUV_420>;
    xlnx,video-width = <8>;

    cresample0_out: endpoint {
    remote-endpoint = <&scaler0_in>;
};

 

- Chroma resampler IP configuration: The Chroma resampler IP should be configured to output in YUV420.

 

Thanks,

-hyun

0 Kudos
Highlighted
Xilinx Employee
Xilinx Employee
9,686 Views
Registered: ‎12-08-2011

Re: V4L2 YUV 4:2:0 Support

Jump to solution

To isolate the problem it would be good to first get the original pipeline running with HEAD and once that is working add the subsampler. If there is a DMA problem, then it's unrelated to this patch.

 

Once you add the subsampler you also need to modify the devicetree by adding the corresponding subdevice and links and also set the correct video format on each of the subdevice pads.

0 Kudos
Highlighted
Visitor
Visitor
9,678 Views
Registered: ‎05-26-2015

Re: V4L2 YUV 4:2:0 Support

Jump to solution

Hyun,

 

Your description of my image processing capture is pretty accurate. I think it will work with your given DTS configuration.

 

I created another topic for the DMA issue but in short dmaengine APIs, dma_request_slave_channel in particular, causes kernel oops on my hardware.

 

Thanks,

Caglar

0 Kudos
Highlighted
Visitor
Visitor
9,677 Views
Registered: ‎05-26-2015

Re: V4L2 YUV 4:2:0 Support

Jump to solution

You are right.

 

I verified my image capture pipeline with an older release kernel(3.14) and I will re-activate subsampler when I do the same with latest kernel.

0 Kudos