media: v4l2-tpg: Fix the memory layout of AYUV buffers
PATCH 1/1 media: v4l2-tpg: Fix the memory layout of AYUV buffers
From: "Kasireddy, Vivek" <[email protected]>
The memory layout of AYUV buffers (V4L2_PIX_FMT_YUV32) should be similar to V4L2_PIX_FMT_ABGR32 instead of V4L2_PIX_FMT_ARGB32.
While displaying the packed AYUV buffers generated by the Vivid driver using v4l2-tpg on Weston, it was observed that these AYUV images were not getting displayed correctly. Changing the memory layout makes them display as expected.
--- drivers/media/common/v4l2-tpg/v4l2-tpg-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/common/v4l2-tpg/v4l2-tpg-core.c +1 -1
@@ -1269,7 +1269,6 @@ static void gen_twopix(struct tpg_data *tpg,case V4L2_PIX_FMT_HSV32 : alpha =0 ;/* fall through */ -case V4L2_PIX_FMT_YUV32 :case V4L2_PIX_FMT_ARGB32 : buf[0 ][offset] = alpha; buf[0 ][offset +1 ] = r_y_h;
@@ -1280,6 +1279,7 @@ static void gen_twopix(struct tpg_data *tpg,case V4L2_PIX_FMT_XBGR32 : alpha =0 ;/* fall through */ +case V4L2_PIX_FMT_YUV32 :case V4L2_PIX_FMT_ABGR32 : buf[0 ][offset] = b_v; buf[0 ][offset +1 ] = g_u_s;
Signature · 1 line
2.14.5
Hi Vivek,
Quoted 9 lines · Vivek Kasireddy
From: "Kasireddy, Vivek" <[email protected]>
The memory layout of AYUV buffers (
V4L2_PIX_FMT_YUV32) should be similar toV4L2_PIX_FMT_ABGR32instead ofV4L2_PIX_FMT_ARGB32.While displaying the packed AYUV buffers generated by the Vivid driver using v4l2-tpg on Weston, it was observed that these AYUV images were not getting displayed correctly. Changing the memory layout makes them display as expected.
Our YUV32 fourcc is defined as follows:
https://hverkuil.home.xs4all.nl/spec/uapi/v4l/pixfmt-packed-yuv.html
As far as I see the format that the TPG generates is according to the V4L2 spec.
Philipp, can you check the YUV32 format that the imx-pxp driver uses? Is that according to our spec?
At some point we probably want to add a VUY32 format which is what Weston expects, but we certainly cannot change what the TPG generates for YUV32 since that is correct.
Regards,
Hans
Quoted 27 lines
Signed-off-by Vivek Kasireddy <[email protected]>--- drivers/media/common/v4l2-tpg/v4l2-tpg-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/media/common/v4l2-tpg/v4l2-tpg-core.c +1
-1@@ -1269,7 +1269,6 @@ static void gen_twopix(struct tpg_data *tpg,case V4L2_PIX_FMT_HSV32 : alpha =0 ;/* fall through */ -case V4L2_PIX_FMT_YUV32 :case V4L2_PIX_FMT_ARGB32 : buf[0 ][offset] = alpha; buf[0 ][offset +1 ] = r_y_h;@@ -1280,6 +1279,7 @@ static void gen_twopix(struct tpg_data *tpg,case V4L2_PIX_FMT_XBGR32 : alpha =0 ;/* fall through */ +case V4L2_PIX_FMT_YUV32 :case V4L2_PIX_FMT_ABGR32 : buf[0 ][offset] = b_v; buf[0 ][offset +1 ] = g_u_s;
On Thu, 31 Jan 2019 14:36:42 +0100
Hans Verkuil <[email protected]> wrote:
Hi Hans,
Quoted 13 lines
Hi Vivek,
Quoted 9 lines · Vivek Kasireddy
From: "Kasireddy, Vivek" <[email protected]>
The memory layout of AYUV buffers (
V4L2_PIX_FMT_YUV32) should be similar toV4L2_PIX_FMT_ABGR32instead ofV4L2_PIX_FMT_ARGB32.While displaying the packed AYUV buffers generated by the Vivid driver using v4l2-tpg on Weston, it was observed that these AYUV images were not getting displayed correctly. Changing the memory layout makes them display as expected.
Quoted 6 lines
Our YUV32 fourcc is defined as follows:
https://hverkuil.home.xs4all.nl/spec/uapi/v4l/pixfmt-packed-yuv.html
As far as I see the format that the TPG generates is according to the V4L2 spec.
I looked into the above link, and I am now wondering whether YUV32 is the same as the format referred to as AYUV here or not:
If YUV32 is not the same as AYUV, should I send another patch adding a new format named AYUV with the reversed memory layout?
Quoted 7 lines
Philipp, can you check the YUV32 format that the imx-pxp driver uses? Is that according to our spec?
At some point we probably want to add a VUY32 format which is what Weston expects, but we certainly cannot change what the TPG generates for YUV32 since that is correct.
Weston does not know much about the details of pixel formats and instead relies on the Mesa i965 DRI driver to do the heavy lifting. And, this driver implemented AYUV support looking at the above Microsoft link. Also, is the description of V4l pixel formats mentioned in the below link accurate:
https://afrantzis.com/pixel-format-guide/v4l2.html
Thanks,
Vivek
Quoted 33 lines
Regards,
Hans
Quoted 27 lines
Signed-off-by Vivek Kasireddy <[email protected]>--- drivers/media/common/v4l2-tpg/v4l2-tpg-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/media/common/v4l2-tpg/v4l2-tpg-core.cindexd9a590ae7545..825667f67c92100644 ---a/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c+++b/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c@@ -1269,7 +1269,6 @@ static void gen_twopix(structtpg_data*tpg, caseV4L2_PIX_FMT_HSV32: alpha = 0;drivers/media/common/v4l2-tpg/v4l2-tpg-core.c +1
-1/* fall through */ -case V4L2_PIX_FMT_YUV32 :case V4L2_PIX_FMT_ARGB32 : buf[0 ][offset] = alpha; buf[0 ][offset +1 ] = r_y_h;@@ -1280,6 +1279,7 @@ static void gen_twopix(struct tpg_data *tpg,case V4L2_PIX_FMT_XBGR32 : alpha =0 ;/* fall through */ +case V4L2_PIX_FMT_YUV32 :case V4L2_PIX_FMT_ABGR32 : buf[0 ][offset] = b_v; buf[0 ][offset +1 ] = g_u_s;
Quoted 22 lines · Vivek Kasireddy
On Thu, 31 Jan 2019 14:36:42 +0100
Hans Verkuil <[email protected]> wrote:Hi Hans,
Quoted 17 lines
Hi Vivek,
Quoted 9 lines · Vivek Kasireddy
From: "Kasireddy, Vivek" <[email protected]>
The memory layout of AYUV buffers (
V4L2_PIX_FMT_YUV32) should be similar toV4L2_PIX_FMT_ABGR32instead ofV4L2_PIX_FMT_ARGB32.While displaying the packed AYUV buffers generated by the Vivid driver using v4l2-tpg on Weston, it was observed that these AYUV images were not getting displayed correctly. Changing the memory layout makes them display as expected.
Our YUV32 fourcc is defined as follows:
https://hverkuil.home.xs4all.nl/spec/uapi/v4l/pixfmt-packed-yuv.html
Quoted 7 lines
Quoted 2 lines
As far as I see the format that the TPG generates is according to the V4L2 spec.
I looked into the above link, and I am now wondering whether YUV32 is the same as the format referred to as AYUV here or not:
It's not the same format.
Quoted 3 lines
If YUV32 is not the same as AYUV, should I send another patch adding a new format named AYUV with the reversed memory layout?
That can only be done if there is also a driver that uses it.
Quoted 4 lines
Quoted 4 lines
Philipp, can you check the YUV32 format that the imx-pxp driver uses? Is that according to our spec?
Philipp, would it be possible to add such a format to imx-pxp? That might be a nice approach because once imx-pxp can do it, then it can also be added to the TPG.
Quoted 10 lines
Quoted 4 lines
At some point we probably want to add a VUY32 format which is what Weston expects, but we certainly cannot change what the TPG generates for YUV32 since that is correct.
Weston does not know much about the details of pixel formats and instead relies on the Mesa i965 DRI driver to do the heavy lifting. And, this driver implemented AYUV support looking at the above Microsoft link. Also, is the description of V4l pixel formats mentioned in the below link accurate:
https://afrantzis.com/pixel-format-guide/v4l2.html
Don't use it, just use the V4L2 Specification, that's always kept up to date.
Regards,
Hans
Quoted 38 lines
Thanks,
VivekQuoted 33 lines
Regards,
Hans
Quoted 27 lines
Signed-off-by Vivek Kasireddy <[email protected]>--- drivers/media/common/v4l2-tpg/v4l2-tpg-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/media/common/v4l2-tpg/v4l2-tpg-core.cindexd9a590ae7545..825667f67c92100644 ---a/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c+++b/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c@@ -1269,7 +1269,6 @@ static void gen_twopix(structtpg_data*tpg, caseV4L2_PIX_FMT_HSV32: alpha = 0;drivers/media/common/v4l2-tpg/v4l2-tpg-core.c +1
-1/* fall through */ -case V4L2_PIX_FMT_YUV32 :case V4L2_PIX_FMT_ARGB32 : buf[0 ][offset] = alpha; buf[0 ][offset +1 ] = r_y_h;@@ -1280,6 +1279,7 @@ static void gen_twopix(struct tpg_data *tpg,case V4L2_PIX_FMT_XBGR32 : alpha =0 ;/* fall through */ +case V4L2_PIX_FMT_YUV32 :case V4L2_PIX_FMT_ABGR32 : buf[0 ][offset] = b_v; buf[0 ][offset +1 ] = g_u_s;
On Fri, 1 Feb 2019 10:08:52 +0100
Hans Verkuil <[email protected]> wrote:
Hi Hans,
Quoted 31 lines · Vivek Kasireddy
Quoted 22 lines
On Thu, 31 Jan 2019 14:36:42 +0100
Hans Verkuil <[email protected]> wrote:Hi Hans,
Quoted 17 lines
Hi Vivek,
Quoted 9 lines · Vivek Kasireddy
From: "Kasireddy, Vivek" <[email protected]>
The memory layout of AYUV buffers (
V4L2_PIX_FMT_YUV32) should be similar toV4L2_PIX_FMT_ABGR32instead ofV4L2_PIX_FMT_ARGB32.While displaying the packed AYUV buffers generated by the Vivid driver using v4l2-tpg on Weston, it was observed that these AYUV images were not getting displayed correctly. Changing the memory layout makes them display as expected.
Our YUV32 fourcc is defined as follows:
https://hverkuil.home.xs4all.nl/spec/uapi/v4l/pixfmt-packed-yuv.html
Quoted 7 lines
Quoted 2 lines
As far as I see the format that the TPG generates is according to the V4L2 spec.
I looked into the above link, and I am now wondering whether YUV32 is the same as the format referred to as AYUV here or not:
Quoted 7 lines
It's not the same format.
Quoted 3 lines
If YUV32 is not the same as AYUV, should I send another patch adding a new format named AYUV with the reversed memory layout?
That can only be done if there is also a driver that uses it.
There are some drm drivers that already use the AYUV format defined here:
https://git.linuxtv.org/media_tree.git/tree/drivers/gpu/drm/drm_fourcc.c#n228
Quoted 9 lines
Quoted 5 lines
Quoted 5 lines
Philipp, can you check the YUV32 format that the imx-pxp driver uses? Is that according to our spec?
Philipp, would it be possible to add such a format to imx-pxp? That might be a nice approach because once imx-pxp can do it, then it can also be added to the TPG.
I was going to send in a patch to add the AYUV (and maybe XYUV) format but I came across this line that leaves me confused:
https://git.linuxtv.org/media_tree.git/tree/drivers/media/platform/vivid/vivid-vid-common.c#n164
It appears that when YUV32 was added, the intention was to mimic AYUV. And, unless I am utterly mistaken, the alpha_mask of 0x000000ff suggests that the alpha component is expected to be found in the LSB (LE) bits indicating a memory layout of VUYA. Am I interpreting this incorrectly?
Thanks,
Vivek
Quoted 58 lines
Quoted 11 lines
Quoted 5 lines
At some point we probably want to add a VUY32 format which is what Weston expects, but we certainly cannot change what the TPG generates for YUV32 since that is correct.
Weston does not know much about the details of pixel formats and instead relies on the Mesa i965 DRI driver to do the heavy lifting. And, this driver implemented AYUV support looking at the above Microsoft link. Also, is the description of V4l pixel formats mentioned in the below link accurate:
https://afrantzis.com/pixel-format-guide/v4l2.htmlDon't use it, just use the V4L2 Specification, that's always kept up to date.
Regards,
Hans
Quoted 38 lines
Thanks,
VivekQuoted 33 lines
Regards,
Hans
Quoted 27 lines
Signed-off-by Vivek Kasireddy <[email protected]>--- drivers/media/common/v4l2-tpg/v4l2-tpg-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/media/common/v4l2-tpg/v4l2-tpg-core.cindexd9a590ae7545..825667f67c92100644 ---a/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c+++b/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c@@ -1269,7 +1269,6 @@ static void gen_twopix(structtpg_data*tpg, caseV4L2_PIX_FMT_HSV32: alpha = 0;drivers/media/common/v4l2-tpg/v4l2-tpg-core.c +1
-1/* fall through */ -case V4L2_PIX_FMT_YUV32 :case V4L2_PIX_FMT_ARGB32 : buf[0 ][offset] = alpha; buf[0 ][offset +1 ] = r_y_h;@@ -1280,6 +1279,7 @@ static void gen_twopix(struct tpg_data *tpg,case V4L2_PIX_FMT_XBGR32 : alpha =0 ;/* fall through */ +case V4L2_PIX_FMT_YUV32 :case V4L2_PIX_FMT_ABGR32 : buf[0 ][offset] = b_v; buf[0 ][offset +1 ] = g_u_s;
Quoted 38 lines · Vivek Kasireddy
On Fri, 1 Feb 2019 10:08:52 +0100
Hans Verkuil <[email protected]> wrote:
Hi Hans,Quoted 34 lines · Vivek Kasireddy
Quoted 22 lines
On Thu, 31 Jan 2019 14:36:42 +0100
Hans Verkuil <[email protected]> wrote:Hi Hans,
Quoted 17 lines
Hi Vivek,
Quoted 9 lines · Vivek Kasireddy
From: "Kasireddy, Vivek" <[email protected]>
The memory layout of AYUV buffers (
V4L2_PIX_FMT_YUV32) should be similar toV4L2_PIX_FMT_ABGR32instead ofV4L2_PIX_FMT_ARGB32.While displaying the packed AYUV buffers generated by the Vivid driver using v4l2-tpg on Weston, it was observed that these AYUV images were not getting displayed correctly. Changing the memory layout makes them display as expected.
Our YUV32 fourcc is defined as follows:
https://hverkuil.home.xs4all.nl/spec/uapi/v4l/pixfmt-packed-yuv.html
Quoted 7 lines
Quoted 2 lines
As far as I see the format that the TPG generates is according to the V4L2 spec.
I looked into the above link, and I am now wondering whether YUV32 is the same as the format referred to as AYUV here or not:
It's not the same format.
Quoted 1 line
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
If YUV32 is not the same as AYUV, should I send another patch adding a new format named AYUV with the reversed memory layout?
That can only be done if there is also a driver that uses it.
There are some drm drivers that already use the AYUV format defined here:
https://git.linuxtv.org/media_tree.git/tree/drivers/gpu/drm/drm_fourcc.c#n228
I would have to check this with Mauro whether this is a good enough excuse to add a new format.
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 6 lines
Philipp, can you check the YUV32 format that the imx-pxp driver uses? Is that according to our spec?
Quoted 6 lines
Quoted 3 lines
Philipp, would it be possible to add such a format to imx-pxp? That might be a nice approach because once imx-pxp can do it, then it can also be added to the TPG.
I was going to send in a patch to add the AYUV (and maybe XYUV) format but I came across this line that leaves me confused:
https://git.linuxtv.org/media_tree.git/tree/drivers/media/platform/vivid/vivid-vid-common.c#n164
It indicates the order of the components in memory, which is indeed AYUV. But it has nothing to do with the microsoft AYUV fourcc.
Quoted 5 lines
It appears that when YUV32 was added, the intention was to mimic AYUV. And, unless I am utterly mistaken, the
alpha_maskof0x000000ffsuggests that the alpha component is expected to be found in the LSB (LE) bits indicating a memory layout of VUYA. Am I interpreting this incorrectly?
Yes. When you write 0x000000ff to memory in a LE environment, it ends up as 0xff 0x00 0x00 0x00 in memory (in increasing memory addresses).
The v4l2-tpg AYUV format is really, really correct given the V4L2 specification of this format.
Regards,
Hans
Quoted 63 lines
Thanks,
VivekQuoted 58 lines
Quoted 11 lines
Quoted 5 lines
At some point we probably want to add a VUY32 format which is what Weston expects, but we certainly cannot change what the TPG generates for YUV32 since that is correct.
Weston does not know much about the details of pixel formats and instead relies on the Mesa i965 DRI driver to do the heavy lifting. And, this driver implemented AYUV support looking at the above Microsoft link. Also, is the description of V4l pixel formats mentioned in the below link accurate:
https://afrantzis.com/pixel-format-guide/v4l2.htmlDon't use it, just use the V4L2 Specification, that's always kept up to date.
Regards,
Hans
Quoted 38 lines
Thanks,
VivekQuoted 33 lines
Regards,
Hans
Quoted 27 lines
Signed-off-by Vivek Kasireddy <[email protected]>--- drivers/media/common/v4l2-tpg/v4l2-tpg-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/media/common/v4l2-tpg/v4l2-tpg-core.cindexd9a590ae7545..825667f67c92100644 ---a/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c+++b/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c@@ -1269,7 +1269,6 @@ static void gen_twopix(structtpg_data*tpg, caseV4L2_PIX_FMT_HSV32: alpha = 0;drivers/media/common/v4l2-tpg/v4l2-tpg-core.c +1
-1/* fall through */ -case V4L2_PIX_FMT_YUV32 :case V4L2_PIX_FMT_ARGB32 : buf[0 ][offset] = alpha; buf[0 ][offset +1 ] = r_y_h;@@ -1280,6 +1279,7 @@ static void gen_twopix(struct tpg_data *tpg,case V4L2_PIX_FMT_XBGR32 : alpha =0 ;/* fall through */ +case V4L2_PIX_FMT_YUV32 :case V4L2_PIX_FMT_ABGR32 : buf[0 ][offset] = b_v; buf[0 ][offset +1 ] = g_u_s;
On Sat, 2 Feb 2019 09:03:17 +0100
Hans Verkuil <[email protected]> wrote:
Hi Hans,
Quoted 61 lines · Vivek Kasireddy
Quoted 38 lines
On Fri, 1 Feb 2019 10:08:52 +0100
Hans Verkuil <[email protected]> wrote:
Hi Hans,Quoted 34 lines · Vivek Kasireddy
Quoted 22 lines
On Thu, 31 Jan 2019 14:36:42 +0100
Hans Verkuil <[email protected]> wrote:Hi Hans,
Quoted 17 lines
Hi Vivek,
Quoted 9 lines · Vivek Kasireddy
From: "Kasireddy, Vivek" <[email protected]>
The memory layout of AYUV buffers (
V4L2_PIX_FMT_YUV32) should be similar toV4L2_PIX_FMT_ABGR32instead ofV4L2_PIX_FMT_ARGB32.While displaying the packed AYUV buffers generated by the Vivid driver using v4l2-tpg on Weston, it was observed that these AYUV images were not getting displayed correctly. Changing the memory layout makes them display as expected.
Our YUV32 fourcc is defined as follows:
https://hverkuil.home.xs4all.nl/spec/uapi/v4l/pixfmt-packed-yuv.html
Quoted 7 lines
Quoted 2 lines
As far as I see the format that the TPG generates is according to the V4L2 spec.
I looked into the above link, and I am now wondering whether YUV32 is the same as the format referred to as AYUV here or not:
It's not the same format.
Quoted 1 line
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
If YUV32 is not the same as AYUV, should I send another patch adding a new format named AYUV with the reversed memory layout?
That can only be done if there is also a driver that uses it.
There are some drm drivers that already use the AYUV format defined here:
https://git.linuxtv.org/media_tree.git/tree/drivers/gpu/drm/drm_fourcc.c#n228I would have to check this with Mauro whether this is a good enough excuse to add a new format.
Quoted 10 lines
Quoted 10 lines
Quoted 6 lines
Quoted 6 lines
Philipp, can you check the YUV32 format that the imx-pxp driver uses? Is that according to our spec?
Philipp, would it be possible to add such a format to imx-pxp? That might be a nice approach because once imx-pxp can do it, then it can also be added to the TPG.
Quoted 6 lines
Quoted 3 lines
I was going to send in a patch to add the AYUV (and maybe XYUV) format but I came across this line that leaves me confused:
https://git.linuxtv.org/media_tree.git/tree/drivers/media/platform/vivid/vivid-vid-common.c#n164It indicates the order of the components in memory, which is indeed AYUV. But it has nothing to do with the microsoft AYUV fourcc.
Does it mean that based on the V4L2 spec, the order of components in memory is always guaranteed regardless of the endianness of the underlying platform? Is it the Vivid/v4l2 core driver's responsibility to make sure this happens?
Quoted 9 lines
Quoted 6 lines
It appears that when YUV32 was added, the intention was to mimic AYUV. And, unless I am utterly mistaken, the
alpha_maskof0x000000ffsuggests that the alpha component is expected to be found in the LSB (LE) bits indicating a memory layout of VUYA. Am I interpreting this incorrectly?Yes. When you write
0x000000ffto memory in a LE environment, it ends up as0xff0x000x000x00in memory (in increasing memory addresses).
This would only work if the alpha component A is always in the MSB which suggests endianness-independence. And, what would happen when writing the alpha mask 0x000000ff in a BE environment which would end up as 0x00 0x00 0x00 0xff in memory?
Quoted 3 lines
The v4l2-tpg AYUV format is really, really correct given the V4L2 specification of this format.
Ok, should I send a patch adding support for VUYA format? Should the new fourcc be VUY4?
Thanks,
Vivek
Quoted 69 lines
Regards,
Hans
Quoted 63 lines
Thanks,
VivekQuoted 58 lines
Quoted 11 lines
Quoted 5 lines
At some point we probably want to add a VUY32 format which is what Weston expects, but we certainly cannot change what the TPG generates for YUV32 since that is correct.
Weston does not know much about the details of pixel formats and instead relies on the Mesa i965 DRI driver to do the heavy lifting. And, this driver implemented AYUV support looking at the above Microsoft link. Also, is the description of V4l pixel formats mentioned in the below link accurate:
https://afrantzis.com/pixel-format-guide/v4l2.htmlDon't use it, just use the V4L2 Specification, that's always kept up to date.
Regards,
Hans
Quoted 38 lines
Thanks,
VivekQuoted 33 lines
Regards,
Hans
Quoted 27 lines
Signed-off-by Vivek Kasireddy <[email protected]>--- drivers/media/common/v4l2-tpg/v4l2-tpg-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/media/common/v4l2-tpg/v4l2-tpg-core.cindexd9a590ae7545..825667f67c92100644 ---a/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c+++b/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c@@ -1269,7 +1269,6 @@ static void gen_twopix(structtpg_data*tpg, caseV4L2_PIX_FMT_HSV32: alpha = 0;drivers/media/common/v4l2-tpg/v4l2-tpg-core.c +1
-1/* fall through */ -case V4L2_PIX_FMT_YUV32 :case V4L2_PIX_FMT_ARGB32 : buf[0 ][offset] = alpha; buf[0 ][offset +1 ] = r_y_h;@@ -1280,6 +1279,7 @@ static void gen_twopix(struct tpg_data *tpg, case V4L2_PIX_FMT_XBGR32: alpha =0 ;/* fall through */ +case V4L2_PIX_FMT_YUV32 :case V4L2_PIX_FMT_ABGR32 : buf[0 ][offset] = b_v; buf[0 ][offset +1 ] = g_u_s;
Quoted 69 lines · Vivek Kasireddy
On Sat, 2 Feb 2019 09:03:17 +0100
Hans Verkuil <[email protected]> wrote:
Hi Hans,Quoted 65 lines · Vivek Kasireddy
Quoted 38 lines
On Fri, 1 Feb 2019 10:08:52 +0100
Hans Verkuil <[email protected]> wrote:
Hi Hans,Quoted 34 lines · Vivek Kasireddy
Quoted 22 lines
On Thu, 31 Jan 2019 14:36:42 +0100
Hans Verkuil <[email protected]> wrote:Hi Hans,
Quoted 17 lines
Hi Vivek,
Quoted 9 lines · Vivek Kasireddy
From: "Kasireddy, Vivek" <[email protected]>
The memory layout of AYUV buffers (
V4L2_PIX_FMT_YUV32) should be similar toV4L2_PIX_FMT_ABGR32instead ofV4L2_PIX_FMT_ARGB32.While displaying the packed AYUV buffers generated by the Vivid driver using v4l2-tpg on Weston, it was observed that these AYUV images were not getting displayed correctly. Changing the memory layout makes them display as expected.
Our YUV32 fourcc is defined as follows:
https://hverkuil.home.xs4all.nl/spec/uapi/v4l/pixfmt-packed-yuv.html
Quoted 7 lines
Quoted 2 lines
As far as I see the format that the TPG generates is according to the V4L2 spec.
I looked into the above link, and I am now wondering whether YUV32 is the same as the format referred to as AYUV here or not:
It's not the same format.
Quoted 1 line
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
If YUV32 is not the same as AYUV, should I send another patch adding a new format named AYUV with the reversed memory layout?
That can only be done if there is also a driver that uses it.
There are some drm drivers that already use the AYUV format defined here:
https://git.linuxtv.org/media_tree.git/tree/drivers/gpu/drm/drm_fourcc.c#n228I would have to check this with Mauro whether this is a good enough excuse to add a new format.
Quoted 13 lines
Quoted 10 lines
Quoted 6 lines
Quoted 6 lines
Philipp, can you check the YUV32 format that the imx-pxp driver uses? Is that according to our spec?
Philipp, would it be possible to add such a format to imx-pxp? That might be a nice approach because once imx-pxp can do it, then it can also be added to the TPG.
I was going to send in a patch to add the AYUV (and maybe XYUV) format but I came across this line that leaves me confused:
https://git.linuxtv.org/media_tree.git/tree/drivers/media/platform/vivid/vivid-vid-common.c#n164
Quoted 6 lines
Quoted 2 lines
It indicates the order of the components in memory, which is indeed AYUV. But it has nothing to do with the microsoft AYUV fourcc.
Does it mean that based on the V4L2 spec, the order of components in memory is always guaranteed regardless of the endianness of the underlying platform? Is it the Vivid/v4l2 core driver's responsibility to make sure this happens?
Correct. But I'm sure it is likely to be horribly broken in many drivers since they are rarely if ever tested on a big endian system.
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
It appears that when YUV32 was added, the intention was to mimic AYUV. And, unless I am utterly mistaken, the
alpha_maskof0x000000ffsuggests that the alpha component is expected to be found in the LSB (LE) bits indicating a memory layout of VUYA. Am I interpreting this incorrectly?
Quoted 6 lines
Quoted 2 lines
Yes. When you write
0x000000ffto memory in a LE environment, it ends up as0xff0x000x000x00in memory (in increasing memory addresses).This would only work if the alpha component A is always in the MSB which suggests endianness-independence. And, what would happen when writing the alpha mask
0x000000ffin a BE environment which would end up as0x000x000x000xffin memory?
It would be wrong. But this alpha mask is used to test an esoteric corner case of v4l2 (video overlays), and only for RGB 5:6:5 and 1:5:5:5 formats.
If I ever would test this on a big endian system I would have to make some fixes, I'm sure.
Quoted 6 lines
Quoted 4 lines
The v4l2-tpg AYUV format is really, really correct given the V4L2 specification of this format.
Ok, should I send a patch adding support for VUYA format? Should the new fourcc be VUY4?
I would prefer to have it along the line of how RGB32 works, so:
VUYX32 and VUYA32
(slightly different from how e.g. ABGR32 since that should have been BGRA32, but let's do it right)
While you are at it, also add AYUV32 and XYUV32 for completeness. The old YUV32 didn't indicate anything about whether the hardware would use or ignore the A byte, we corrected that for RGB formats but never for this YUV32 format.
Don't forget to update the documentation and to add support for this to v4l2-tpg and vivid.
And mention that this allows you to use the tpg/vivid in combination with drm drivers that use VUYX32.
Regards,
Hans
Quoted 74 lines
Thanks,
VivekQuoted 69 lines
Regards,
Hans
Quoted 63 lines
Thanks,
VivekQuoted 58 lines
Quoted 11 lines
Quoted 5 lines
At some point we probably want to add a VUY32 format which is what Weston expects, but we certainly cannot change what the TPG generates for YUV32 since that is correct.
Weston does not know much about the details of pixel formats and instead relies on the Mesa i965 DRI driver to do the heavy lifting. And, this driver implemented AYUV support looking at the above Microsoft link. Also, is the description of V4l pixel formats mentioned in the below link accurate:
https://afrantzis.com/pixel-format-guide/v4l2.htmlDon't use it, just use the V4L2 Specification, that's always kept up to date.
Regards,
Hans
Quoted 38 lines
Thanks,
VivekQuoted 33 lines
Regards,
Hans
Quoted 27 lines
Signed-off-by Vivek Kasireddy <[email protected]>--- drivers/media/common/v4l2-tpg/v4l2-tpg-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/media/common/v4l2-tpg/v4l2-tpg-core.cindexd9a590ae7545..825667f67c92100644 ---a/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c+++b/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c@@ -1269,7 +1269,6 @@ static void gen_twopix(structtpg_data*tpg, caseV4L2_PIX_FMT_HSV32: alpha = 0;(quoted diff) +1
-1/* fall through */ - case V4L2_PIX_FMT_YUV32: case V4L2_PIX_FMT_ARGB32: buf[0][offset] = alpha; buf[0][offset + 1] = r_y_h;@@ -1280,6 +1279,7 @@ static void gen_twopix(struct tpg_data *tpg, case V4L2_PIX_FMT_XBGR32: alpha = 0; /* fall through */ + case V4L2_PIX_FMT_YUV32: case V4L2_PIX_FMT_ABGR32: buf[0][offset] = b_v; buf[0][offset + 1] = g_u_s;
Hi Hans,
On Thu, 2019-01-31 at 14:36 +0100, Hans Verkuil wrote:
[...]
Quoted 5 lines
Our YUV32 fourcc is defined as follows:
https://hverkuil.home.xs4all.nl/spec/uapi/v4l/pixfmt-packed-yuv.html
Quoted 8 lines
As far as I see the format that the TPG generates is according to the V4L2 spec.
Philipp, can you check the YUV32 format that the imx-pxp driver uses? Is that according to our spec?
At some point we probably want to add a VUY32 format which is what Weston expects, but we certainly cannot change what the TPG generates for YUV32 since that is correct.
I hadn't noticed as YUV32 doesn't show up in GStreamer, but testing with v4l2-ctl, it seems to be incorrect. This script:
#!/bin/sh
function check() {
PATTERN="$1"
NAME="$2"
echo -ne "${NAME}:\t" v4l2-ctl \
--set-fmt-video-out=width=8,height=8,pixelformat=RGBP \
--set-fmt-video=width=8,height=8,pixelformat=YUV4 \
--stream-count 1 \
--stream-poll \
--stream-out-pattern "${PATTERN}" \
--stream-out-mmap 3 \
--stream-mmap 3 \ --stream-to - 2>/dev/null | hexdump -v -n4 -e '/1 "%02x "' echo
}
check 6 "100% white"
check 7 "100% red"
check 9 "100% blue"
results in the following output:
100% white: 80 80 ea ff
100% red: f0 66 3e ff
100% blue: 74 f0 23 ff
That looks like 32-bit VUYA 8-8-8-8.
regards
Philipp
Quoted 41 lines · Philipp Zabel
Hi Hans,
On Thu, 2019-01-31 at 14:36 +0100, Hans Verkuil wrote:
[...]Quoted 5 lines
Our YUV32 fourcc is defined as follows:
https://hverkuil.home.xs4all.nl/spec/uapi/v4l/pixfmt-packed-yuv.html
Quoted 8 lines
As far as I see the format that the TPG generates is according to the V4L2 spec.
Philipp, can you check the YUV32 format that the imx-pxp driver uses? Is that according to our spec?
At some point we probably want to add a VUY32 format which is what Weston expects, but we certainly cannot change what the TPG generates for YUV32 since that is correct.
I hadn't noticed as YUV32 doesn't show up in GStreamer, but testing with v4l2-ctl, it seems to be incorrect. This script:
#!/bin/sh
function check() { PATTERN="$1" NAME="$2" echo -ne "${NAME}:\t" v4l2-ctl \ --set-fmt-video-out=width=8,height=8,pixelformat=RGBP \ --set-fmt-video=width=8,height=8,pixelformat=YUV4 \ --stream-count 1 \ --stream-poll \ --stream-out-pattern "${PATTERN}" \ --stream-out-mmap 3 \ --stream-mmap 3 \--stream-to - 2>/dev/null | hexdump -v -n4 -e '/1 "%02x "' echo
}
check 6 "100% white"
check 7 "100% red"
check 9 "100% blue"
Quoted 7 lines
results in the following output:
100% white: 80 80 ea ff
100% red: f0 66 3e ff
100% blue: 74 f0 23 ffThat looks like 32-bit VUYA 8-8-8-8.
Right. So Vivek, can you make the patches to add a proper VUYA pixelformat?
And a final patch updating imx-pxp so it uses the right pixelformat?
Since there is now a driver using it, it is also not a problem anymore to get the new pixelformat patches merged.
Regards,
Hans
On Wed, 6 Feb 2019 11:46:21 +0100
Hans Verkuil <[email protected]> wrote:
Hi Hans,
Quoted 45 lines · Philipp Zabel
Quoted 44 lines
Hi Hans,
On Thu, 2019-01-31 at 14:36 +0100, Hans Verkuil wrote:
[...]Quoted 8 lines
Our YUV32 fourcc is defined as follows:
https://hverkuil.home.xs4all.nl/spec/uapi/v4l/pixfmt-packed-yuv.html
As far as I see the format that the TPG generates is according to the V4L2 spec.
Quoted 6 lines
Philipp, can you check the YUV32 format that the imx-pxp driver uses? Is that according to our spec?
At some point we probably want to add a VUY32 format which is what Weston expects, but we certainly cannot change what the TPG generates for YUV32 since that is correct.
I hadn't noticed as YUV32 doesn't show up in GStreamer, but testing with v4l2-ctl, it seems to be incorrect. This script:
#!/bin/sh
function check() { PATTERN="$1" NAME="$2" echo -ne "${NAME}:\t" v4l2-ctl \ --set-fmt-video-out=width=8,height=8,pixelformat=RGBP \ --set-fmt-video=width=8,height=8,pixelformat=YUV4 \ --stream-count 1 \ --stream-poll \ --stream-out-pattern "${PATTERN}" \ --stream-out-mmap 3 \ --stream-mmap 3 \--stream-to - 2>/dev/null | hexdump -v -n4 -e '/1 "%02x "' echo
}
check 6 "100% white"
check 7 "100% red"
check 9 "100% blue"results in the following output:
Quoted 8 lines
Quoted 5 lines
100% white: 80 80 ea ff
100% red: f0 66 3e ff
100% blue: 74 f0 23 ffThat looks like 32-bit VUYA 8-8-8-8.
Right. So Vivek, can you make the patches to add a proper VUYA pixelformat?
Sure, let me send the patches soon.
Quoted 2 lines
And a final patch updating imx-pxp so it uses the right pixelformat?
Ok, will do.
Thanks,
Vivek
Quoted 7 lines
Since there is now a driver using it, it is also not a problem anymore to get the new pixelformat patches merged.
Regards,
Hans
Quoted 13 lines · Philipp Zabel
Hi Hans,
On Thu, 2019-01-31 at 14:36 +0100, Hans Verkuil wrote:
[...]Quoted 9 lines
Our YUV32 fourcc is defined as follows:
https://hverkuil.home.xs4all.nl/spec/uapi/v4l/pixfmt-packed-yuv.html
As far as I see the format that the TPG generates is according to the V4L2 spec.
Philipp, can you check the YUV32 format that the imx-pxp driver uses? Is that according to our spec?
Quoted 6 lines
Quoted 3 lines
At some point we probably want to add a VUY32 format which is what Weston expects, but we certainly cannot change what the TPG generates for YUV32 since that is correct.
I hadn't noticed as YUV32 doesn't show up in GStreamer, but testing with v4l2-ctl, it seems to be incorrect. This script:
Oops, noted, I have filed an issue for that.
https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/issues/565
It was skipped because I always assumed this was not a real format. It was added in GStreamer for software color conversion as a YUV unpack format (same for AYUV64 16-16-16-16). This is used in the generic color conversion path, or the slow path.
Quoted 31 lines
#!/bin/sh function check() { PATTERN="$1" NAME="$2" echo -ne "${NAME}:\t" v4l2-ctl \ --set-fmt-video-out=width=8,height=8,pixelformat=RGBP \ --set-fmt-video=width=8,height=8,pixelformat=YUV4 \ --stream-count 1 \ --stream-poll \ --stream-out-pattern "${PATTERN}" \ --stream-out-mmap 3 \ --stream-mmap 3 \ --stream-to - 2>/dev/null | hexdump -v -n4 -e '/1 "%02x "' echo } check 6 "100% white" check 7 "100% red" check 9 "100% blue"results in the following output:
100% white: 80 80 ea ff
100% red: f0 66 3e ff
100% blue: 74 f0 23 ffThat looks like 32-bit VUYA 8-8-8-8.
regards
Philipp