Commit e4f2b5d5 authored by Ville Syrjälä's avatar Ville Syrjälä Committed by Chris Wilson
Browse files

sna/video: Add XV_COLORSPACE attribute for the textured Xv adaptor



Allow the client to select between BT.601 and BT.709 via the
XV_COLORSPACE port attribute with the textured Xv adaptor as well.

Since the BT.601 coefficients are currently hardcoded in the
yuv->rgb shader, let's just add a mostly duplicated shader with
hardcoded BT.709 coefficients instead. Not the most elegant solution
but avoids having to touch any state setup etc.
Signed-off-by: Ville Syrjälä's avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Chris Wilson's avatarChris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Chris Wilson's avatarChris Wilson <chris@chris-wilson.co.uk>
parent 35a9e969
......@@ -16,6 +16,7 @@ INTEL_G4A = \
exa_wm_ca_srcalpha.g4a \
exa_wm_write.g4a \
exa_wm_yuv_rgb_bt601.g4a \
exa_wm_yuv_rgb_bt709.g4a \
exa_wm_xy.g4a \
$(NULL)
......@@ -46,6 +47,7 @@ INTEL_G4B = \
exa_wm_ca_srcalpha.g4b \
exa_wm_write.g4b \
exa_wm_yuv_rgb_bt601.g4b \
exa_wm_yuv_rgb_bt709.g4b \
exa_wm_xy.g4b \
$(NULL)
......@@ -68,6 +70,7 @@ INTEL_G4B_GEN5 = \
exa_wm_ca_srcalpha.g4b.gen5 \
exa_wm_write.g4b.gen5 \
exa_wm_yuv_rgb_bt601.g4b.gen5 \
exa_wm_yuv_rgb_bt709.g4b.gen5 \
exa_wm_xy.g4b.gen5 \
$(NULL)
......@@ -89,6 +92,7 @@ INTEL_G5A = \
exa_wm_ca_srcalpha.g5a \
exa_wm_write.g5a \
exa_wm_yuv_rgb_bt601.g5a \
exa_wm_yuv_rgb_bt709.g5a \
exa_wm_xy.g5a \
$(NULL)
......@@ -110,6 +114,7 @@ INTEL_G5B = \
exa_wm_ca_srcalpha.g5b \
exa_wm_write.g5b \
exa_wm_yuv_rgb_bt601.g5b \
exa_wm_yuv_rgb_bt709.g5b \
exa_wm_xy.g5b \
$(NULL)
......@@ -134,6 +139,7 @@ INTEL_G6A = \
exa_wm_noca.g6a \
exa_wm_write.g6a \
exa_wm_yuv_rgb_bt601.g6a \
exa_wm_yuv_rgb_bt709.g6a \
$(NULL)
INTEL_G6B = \
......@@ -152,6 +158,7 @@ INTEL_G6B = \
exa_wm_noca.g6b \
exa_wm_write.g6b \
exa_wm_yuv_rgb_bt601.g6b \
exa_wm_yuv_rgb_bt709.g6b \
$(NULL)
INTEL_G7A = \
......@@ -167,6 +174,7 @@ INTEL_G7A = \
exa_wm_src_sample_planar.g7a \
exa_wm_write.g7a \
exa_wm_yuv_rgb_bt601.g7a \
exa_wm_yuv_rgb_bt709.g7a \
$(NULL)
INTEL_G7B = \
......@@ -182,6 +190,7 @@ INTEL_G7B = \
exa_wm_src_sample_planar.g7b \
exa_wm_write.g7b \
exa_wm_yuv_rgb_bt601.g7b \
exa_wm_yuv_rgb_bt709.g7b \
$(NULL)
INTEL_G8A = \
......@@ -191,6 +200,7 @@ INTEL_G8A = \
exa_wm_src_sample_planar.g8a \
exa_wm_write.g8a \
exa_wm_yuv_rgb_bt601.g8a \
exa_wm_yuv_rgb_bt709.g8a \
$(NULL)
INTEL_G8B = \
......@@ -200,6 +210,7 @@ INTEL_G8B = \
exa_wm_src_sample_planar.g8b \
exa_wm_write.g8b \
exa_wm_yuv_rgb_bt601.g8b \
exa_wm_yuv_rgb_bt709.g8b \
$(NULL)
EXTRA_DIST = \
......
......@@ -55,14 +55,24 @@ define(`Cbn_01', `mask_sample_b_01')
define(`Cbn_23', `mask_sample_b_23')
/* color space conversion function:
* R = Clamp ( 1.164(Y-16/255) + 1.596(Cr-128/255), 0, 1)
* G = Clamp ( 1.164(Y-16/255) - 0.813(Cr-128/255) - 0.392(Cb-128/255), 0, 1)
* B = Clamp ( 1.164(Y-16/255) + 2.017(Cb-128/255), 0, 1)
* Cy = 255/(235-16)
* R = Clamp ( 255/(235-16)(Y-16/255) +
* 255/112(1.0-Kr)(Cr-128/255), 0, 1)
* G = Clamp ( 255/(235-16)(Y-16/255) -
* 255/112(1.0-Kr)Kr/Kg(Cr-128/255) -
* 255/112(1.0-Kb)Kb/Kg(Cb-128/255), 0, 1)
* B = Clamp ( 255/(235-16)(Y-16/255) +
* 255/112(1.0-Kb)(Cb-128/255), 0, 1)
*
* BT.601:
* Kr = 0.299
* Kb = 0.114
* Kg = (1.0 - Kr - Kb) = 0.587
*/
/* Normalize Y, Cb and Cr:
*
* Yn = (Y - 16/255) * 1.164
* Yn = (Y - 16/255) * 255/(235-16)
* Crn = Cr - 128 / 255
* Cbn = Cb - 128 / 255
*/
......@@ -73,21 +83,25 @@ add (16) Crn<1>F Cr<8,8,1>F -0.501961F { compr align1 };
add (16) Cbn<1>F Cb<8,8,1>F -0.501961F { compr align1 };
/*
* R = Y + Cr * 1.596
/*
* R = Yn +
* Crn * 255/112 * (1.0 - Kr)
*/
mov (16) acc0<1>F Yn<8,8,1>F { compr align1 };
mac.sat(16) src_sample_r<1>F Crn<8,8,1>F 1.596F { compr align1 };
/*
* G = Crn * -0.813 + Cbn * -0.392 + Y
* G = Yn -
* Crn * 255/112 * (1.0 - Kr) * Kr / Kg -
* Cbn * 255/112 * (1.0 - Kb) * Kb / Kg
*/
mov (16) acc0<1>F Yn<8,8,1>F { compr align1 };
mac (16) acc0<1>F Crn<8,8,1>F -0.813F { compr align1 };
mac.sat(16) src_sample_g<1>F Cbn<8,8,1>F -0.392F { compr align1 };
/*
* B = Cbn * 2.017 + Y
* B = Yn +
* Cbn * 255/112 * (1.0 - Kb)
*/
mov (16) acc0<1>F Yn<8,8,1>F { compr align1 };
mac.sat(16) src_sample_b<1>F Cbn<8,8,1>F 2.017F { compr align1 };
......
......@@ -55,14 +55,23 @@ define(`Cbn_01', `mask_sample_b_01')
define(`Cbn_23', `mask_sample_b_23')
/* color space conversion function:
* R = Clamp ( 1.164(Y-16/255) + 1.596(Cr-128/255), 0, 1)
* G = Clamp ( 1.164(Y-16/255) - 0.813(Cr-128/255) - 0.392(Cb-128/255), 0, 1)
* B = Clamp ( 1.164(Y-16/255) + 2.017(Cb-128/255), 0, 1)
* R = Clamp ( 255/(235-16)(Y-16/255) +
* 255/112(1.0-Kr)(Cr-128/255), 0, 1)
* G = Clamp ( 255/(235-16)(Y-16/255) -
* 255/112(1.0-Kr)Kr/Kg(Cr-128/255) -
* 255/112(1.0-Kb)Kb/Kg(Cb-128/255), 0, 1)
* B = Clamp ( 255/(235-16)(Y-16/255) +
* 255/112(1.0-Kb)(Cb-128/255), 0, 1)
*
* BT.601:
* Kr = 0.299
* Kb = 0.114
* Kg = (1.0 - Kr - Kb) = 0.587
*/
/* Normalize Y, Cb and Cr:
*
* Yn = (Y - 16/255) * 1.164
* Yn = (Y - 16/255) * 255/(235-16)
* Crn = Cr - 128 / 255
* Cbn = Cb - 128 / 255
*/
......@@ -73,16 +82,19 @@ add (16) Crn<1>F Cr<8,8,1>F -0.501961F { compr align1 };
add (16) Cbn<1>F Cb<8,8,1>F -0.501961F { compr align1 };
/*
* R = Y + Cr * 1.596
/*
* R = Yn +
* Crn * 255/112 * (1.0 - Kr)
*/
mov (8) acc0<1>F Yn_01<8,8,1>F { compr align1 };
mac.sat(8) src_sample_r_01<1>F Crn_01<8,8,1>F 1.596F { compr align1 };
mov (8) acc0<1>F Yn_23<8,8,1>F { compr align1 };
mac.sat(8) src_sample_r_23<1>F Crn_23<8,8,1>F 1.596F { compr align1 };
/*
* G = Crn * -0.813 + Cbn * -0.392 + Y
* G = Yn -
* Crn * 255/112 * (1.0 - Kr) * Kr / Kg -
* Cbn * 255/112 * (1.0 - Kb) * Kb / Kg
*/
mov (8) acc0<1>F Yn_01<8,8,1>F { compr align1 };
mac (8) acc0<1>F Crn_01<8,8,1>F -0.813F { compr align1 };
......@@ -92,7 +104,8 @@ mov (8) acc0<1>F Yn_23<8,8,1>F { compr align1 };
mac (8) acc0<1>F Crn_23<8,8,1>F -0.813F { compr align1 };
mac.sat(16) src_sample_g_23<1>F Cbn_23<8,8,1>F -0.392F { compr align1 };
/*
* B = Cbn * 2.017 + Y
* B = Yn +
* Cbn * 255/112 * (1.0 - Kb)
*/
mov (8) acc0<1>F Yn_01<8,8,1>F { compr align1 };
mac.sat(8) src_sample_b_01<1>F Cbn_01<8,8,1>F 2.017F { compr align1 };
......
/*
* Copyright © 2006 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*
* Authors:
* Keith Packard <keithp@keithp.com>
* Eric Anholt <eric@anholt.net>
*
*/
include(`exa_wm.g4i')
define(`YCbCr_base', `src_sample_base')
define(`Cr', `src_sample_r')
define(`Cr_01', `src_sample_r_01')
define(`Cr_23', `src_sample_r_23')
define(`Y', `src_sample_g')
define(`Y_01', `src_sample_g_01')
define(`Y_23', `src_sample_g_23')
define(`Cb', `src_sample_b')
define(`Cb_01', `src_sample_b_01')
define(`Cb_23', `src_sample_b_23')
define(`Crn', `mask_sample_r')
define(`Crn_01', `mask_sample_r_01')
define(`Crn_23', `mask_sample_r_23')
define(`Yn', `mask_sample_g')
define(`Yn_01', `mask_sample_g_01')
define(`Yn_23', `mask_sample_g_23')
define(`Cbn', `mask_sample_b')
define(`Cbn_01', `mask_sample_b_01')
define(`Cbn_23', `mask_sample_b_23')
/* color space conversion function:
* R = Clamp ( 255/(235-16)(Y-16/255) +
* 255/112(1.0-Kr)(Cr-128/255), 0, 1)
* G = Clamp ( 255/(235-16)(Y-16/255) -
* 255/112(1.0-Kr)Kr/Kg(Cr-128/255) -
* 255/112(1.0-Kb)Kb/Kg(Cb-128/255), 0, 1)
* B = Clamp ( 255/(235-16)(Y-16/255) +
* 255/112(1.0-Kb)(Cb-128/255), 0, 1)
*
* BT.709:
* Kr = .2126
* Kb = .0722
* Kg = (1.0 - Kr - Kb) = 0.7152
*/
/* Normalize Y, Cb and Cr:
*
* Yn = (Y - 16/255) * 255/(235-16)
* Crn = Cr - 128 / 255
* Cbn = Cb - 128 / 255
*/
add (16) Yn<1>F Y<8,8,1>F -0.0627451F { compr align1 };
mul (16) Yn<1>F Yn<8,8,1>F 1.164F { compr align1 };
add (16) Crn<1>F Cr<8,8,1>F -0.501961F { compr align1 };
add (16) Cbn<1>F Cb<8,8,1>F -0.501961F { compr align1 };
/*
* R = Yn +
* Crn * 255/112 * (1.0 - Kr)
*/
mov (16) acc0<1>F Yn<8,8,1>F { compr align1 };
mac.sat(16) src_sample_r<1>F Crn<8,8,1>F 1.793F { compr align1 };
/*
* G = Yn -
* Crn * 255/112 * (1.0 - Kr) * Kr / Kg -
* Cbn * 255/112 * (1.0 - Kb) * Kb / Kg
*/
mov (16) acc0<1>F Yn<8,8,1>F { compr align1 };
mac (16) acc0<1>F Crn<8,8,1>F -0.533F { compr align1 };
mac.sat(16) src_sample_g<1>F Cbn<8,8,1>F -0.213F { compr align1 };
/*
* B = Yn +
* Cbn * 255/112 * (1.0 - Kb)
*/
mov (16) acc0<1>F Yn<8,8,1>F { compr align1 };
mac.sat(16) src_sample_b<1>F Cbn<8,8,1>F 2.112F { compr align1 };
/*
* A = 1.0
*/
mov (16) src_sample_a<1>F 1.0F { compr align1 };
{ 0x00802040, 0x23007fbd, 0x008d0200, 0xbd808081 },
{ 0x00802041, 0x23007fbd, 0x008d0300, 0x3f94fdf4 },
{ 0x00802040, 0x22c07fbd, 0x008d01c0, 0xbf008084 },
{ 0x00802040, 0x23407fbd, 0x008d0240, 0xbf008084 },
{ 0x00802001, 0x240003bc, 0x008d0300, 0x00000000 },
{ 0x80802048, 0x21c07fbd, 0x008d02c0, 0x3fe58106 },
{ 0x00802001, 0x240003bc, 0x008d0300, 0x00000000 },
{ 0x00802048, 0x24007fbc, 0x008d02c0, 0xbf0872b0 },
{ 0x80802048, 0x22007fbd, 0x008d0340, 0xbe5a1cac },
{ 0x00802001, 0x240003bc, 0x008d0300, 0x00000000 },
{ 0x80802048, 0x22407fbd, 0x008d0340, 0x40072b02 },
{ 0x00802001, 0x228003fd, 0x00000000, 0x3f800000 },
{ 0x00802040, 0x23007fbd, 0x008d0200, 0xbd808081 },
{ 0x00802041, 0x23007fbd, 0x008d0300, 0x3f94fdf4 },
{ 0x00802040, 0x22c07fbd, 0x008d01c0, 0xbf008084 },
{ 0x00802040, 0x23407fbd, 0x008d0240, 0xbf008084 },
{ 0x00802001, 0x240003bc, 0x008d0300, 0x00000000 },
{ 0x80802048, 0x21c07fbd, 0x008d02c0, 0x3fe58106 },
{ 0x00802001, 0x240003bc, 0x008d0300, 0x00000000 },
{ 0x00802048, 0x24007fbc, 0x008d02c0, 0xbf0872b0 },
{ 0x80802048, 0x22007fbd, 0x008d0340, 0xbe5a1cac },
{ 0x00802001, 0x240003bc, 0x008d0300, 0x00000000 },
{ 0x80802048, 0x22407fbd, 0x008d0340, 0x40072b02 },
{ 0x00802001, 0x228003fd, 0x00000000, 0x3f800000 },
exa_wm_yuv_rgb_bt709.g4a
\ No newline at end of file
{ 0x00802040, 0x23007fbd, 0x008d0200, 0xbd808081 },
{ 0x00802041, 0x23007fbd, 0x008d0300, 0x3f94fdf4 },
{ 0x00802040, 0x22c07fbd, 0x008d01c0, 0xbf008084 },
{ 0x00802040, 0x23407fbd, 0x008d0240, 0xbf008084 },
{ 0x00802001, 0x240003bc, 0x008d0300, 0x00000000 },
{ 0x80802048, 0x21c07fbd, 0x008d02c0, 0x3fe58106 },
{ 0x00802001, 0x240003bc, 0x008d0300, 0x00000000 },
{ 0x00802048, 0x24007fbc, 0x008d02c0, 0xbf0872b0 },
{ 0x80802048, 0x22007fbd, 0x008d0340, 0xbe5a1cac },
{ 0x00802001, 0x240003bc, 0x008d0300, 0x00000000 },
{ 0x80802048, 0x22407fbd, 0x008d0340, 0x40072b02 },
{ 0x00802001, 0x228003fd, 0x00000000, 0x3f800000 },
exa_wm_yuv_rgb_bt709.g4a
\ No newline at end of file
{ 0x00800040, 0x23007fbd, 0x008d0200, 0xbd808081 },
{ 0x00800041, 0x23007fbd, 0x008d0300, 0x3f94fdf4 },
{ 0x00800040, 0x22c07fbd, 0x008d01c0, 0xbf008084 },
{ 0x00800040, 0x23407fbd, 0x008d0240, 0xbf008084 },
{ 0x00800001, 0x240003bc, 0x008d0300, 0x00000000 },
{ 0x80800048, 0x21c07fbd, 0x008d02c0, 0x3fe58106 },
{ 0x00800001, 0x240003bc, 0x008d0300, 0x00000000 },
{ 0x00800048, 0x24007fbc, 0x008d02c0, 0xbf0872b0 },
{ 0x80800048, 0x22007fbd, 0x008d0340, 0xbe5a1cac },
{ 0x00800001, 0x240003bc, 0x008d0300, 0x00000000 },
{ 0x80800048, 0x22407fbd, 0x008d0340, 0x40072b02 },
{ 0x00800001, 0x228003fd, 0x00000000, 0x3f800000 },
exa_wm_yuv_rgb_bt709.g4a
\ No newline at end of file
{ 0x00800040, 0x23007fbd, 0x008d0200, 0xbd808081 },
{ 0x00800041, 0x23007fbd, 0x008d0300, 0x3f94fdf4 },
{ 0x00800040, 0x22c07fbd, 0x008d01c0, 0xbf008084 },
{ 0x00800040, 0x23407fbd, 0x008d0240, 0xbf008084 },
{ 0x00800001, 0x240003bc, 0x008d0300, 0x00000000 },
{ 0x80800048, 0x21c07fbd, 0x008d02c0, 0x3fe58106 },
{ 0x00800001, 0x240003bc, 0x008d0300, 0x00000000 },
{ 0x00800048, 0x24007fbc, 0x008d02c0, 0xbf0872b0 },
{ 0x80800048, 0x22007fbd, 0x008d0340, 0xbe5a1cac },
{ 0x00800001, 0x240003bc, 0x008d0300, 0x00000000 },
{ 0x80800048, 0x22407fbd, 0x008d0340, 0x40072b02 },
{ 0x00800001, 0x228003fd, 0x00000000, 0x3f800000 },
/*
* Copyright © 2006 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*
* Authors:
* Keith Packard <keithp@keithp.com>
* Eric Anholt <eric@anholt.net>
*
*/
include(`exa_wm.g4i')
define(`YCbCr_base', `src_sample_base')
define(`Cr', `src_sample_r')
define(`Cr_01', `src_sample_r_01')
define(`Cr_23', `src_sample_r_23')
define(`Y', `src_sample_g')
define(`Y_01', `src_sample_g_01')
define(`Y_23', `src_sample_g_23')
define(`Cb', `src_sample_b')
define(`Cb_01', `src_sample_b_01')
define(`Cb_23', `src_sample_b_23')
define(`Crn', `mask_sample_r')
define(`Crn_01', `mask_sample_r_01')
define(`Crn_23', `mask_sample_r_23')
define(`Yn', `mask_sample_g')
define(`Yn_01', `mask_sample_g_01')
define(`Yn_23', `mask_sample_g_23')
define(`Cbn', `mask_sample_b')
define(`Cbn_01', `mask_sample_b_01')
define(`Cbn_23', `mask_sample_b_23')
/* color space conversion function:
* R = Clamp ( 255/(235-16)(Y-16/255) +
* 255/112(1.0-Kr)(Cr-128/255), 0, 1)
* G = Clamp ( 255/(235-16)(Y-16/255) -
* 255/112(1.0-Kr)Kr/Kg(Cr-128/255) -
* 255/112(1.0-Kb)Kb/Kg(Cb-128/255), 0, 1)
* B = Clamp ( 255/(235-16)(Y-16/255) +
* 255/112(1.0-Kb)(Cb-128/255), 0, 1)
*
* BT.709:
* Kr = .2126
* Kb = .0722
* Kg = (1.0 - Kr - Kb) = 0.7152
*/
/* Normalize Y, Cb and Cr:
*
* Yn = (Y - 16/255) * 255/(235-16)
* Crn = Cr - 128 / 255
* Cbn = Cb - 128 / 255
*/
add (16) Yn<1>F Y<8,8,1>F -0.0627451F { compr align1 };
mul (16) Yn<1>F Yn<8,8,1>F 1.164F { compr align1 };
add (16) Crn<1>F Cr<8,8,1>F -0.501961F { compr align1 };
add (16) Cbn<1>F Cb<8,8,1>F -0.501961F { compr align1 };
/*
* R = Yn +
* Crn * 255/112 * (1.0 - Kr)
*/
mov (8) acc0<1>F Yn_01<8,8,1>F { compr align1 };
mac.sat(8) src_sample_r_01<1>F Crn_01<8,8,1>F 1.793F { compr align1 };
mov (8) acc0<1>F Yn_23<8,8,1>F { compr align1 };
mac.sat(8) src_sample_r_23<1>F Crn_23<8,8,1>F 1.793F { compr align1 };
/*
* G = Yn -
* Crn * 255/112 * (1.0 - Kr) * Kr / Kg
* Cbn * 255/112 * (1.0 - Kb) * Kb / Kg
*/
mov (8) acc0<1>F Yn_01<8,8,1>F { compr align1 };
mac (8) acc0<1>F Crn_01<8,8,1>F -0.533F { compr align1 };
mac.sat(8) src_sample_g_01<1>F Cbn_01<8,8,1>F -0.213F { compr align1 };
mov (8) acc0<1>F Yn_23<8,8,1>F { compr align1 };
mac (8) acc0<1>F Crn_23<8,8,1>F -0.533F { compr align1 };
mac.sat(16) src_sample_g_23<1>F Cbn_23<8,8,1>F -0.213F { compr align1 };
/*
* B = Yn +
* Cbn * 255/112 * (1.0 - Kb)
*/
mov (8) acc0<1>F Yn_01<8,8,1>F { compr align1 };
mac.sat(8) src_sample_b_01<1>F Cbn_01<8,8,1>F 2.112F { compr align1 };
mov (8) acc0<1>F Yn_23<8,8,1>F { compr align1 };
mac.sat(8) src_sample_b_23<1>F Cbn_23<8,8,1>F 2.112F { compr align1 };
/*
* A = 1.0
*/
mov (16) src_sample_a<1>F 1.0F { compr align1 };
{ 0x00800040, 0x23003ae8, 0x3e8d0200, 0xbd808081 },
{ 0x00800041, 0x23003ae8, 0x3e8d0300, 0x3f94fdf4 },
{ 0x00800040, 0x22c03ae8, 0x3e8d01c0, 0xbf008084 },
{ 0x00800040, 0x23403ae8, 0x3e8d0240, 0xbf008084 },
{ 0x00600001, 0x24003ae0, 0x008d0300, 0x00000000 },
{ 0x80600048, 0x21c03ae8, 0x3e8d02c0, 0x3fe58106 },
{ 0x00600001, 0x24003ae0, 0x008d0320, 0x00000000 },
{ 0x80600048, 0x21e03ae8, 0x3e8d02e0, 0x3fe58106 },
{ 0x00600001, 0x24003ae0, 0x008d0300, 0x00000000 },
{ 0x00600048, 0x24003ae0, 0x3e8d02c0, 0xbf0872b0 },
{ 0x80600048, 0x22003ae8, 0x3e8d0340, 0xbe5a1cac },
{ 0x00600001, 0x24003ae0, 0x008d0320, 0x00000000 },
{ 0x00600048, 0x24003ae0, 0x3e8d02e0, 0xbf0872b0 },
{ 0x80800048, 0x22203ae8, 0x3e8d0360, 0xbe5a1cac },
{ 0x00600001, 0x24003ae0, 0x008d0300, 0x00000000 },
{ 0x80600048, 0x22403ae8, 0x3e8d0340, 0x40072b02 },
{ 0x00600001, 0x24003ae0, 0x008d0320, 0x00000000 },
{ 0x80600048, 0x22603ae8, 0x3e8d0360, 0x40072b02 },
{ 0x00800001, 0x22803ee8, 0x38000000, 0x3f800000 },
......@@ -99,7 +99,7 @@
#define GEN4_MAX_WM_THREADS 32
#define G4X_MAX_WM_THREADS 50
static const uint32_t ps_kernel_packed_static[][4] = {
static const uint32_t ps_kernel_packed_bt601_static[][4] = {
#include "exa_wm_xy.g4b"
#include "exa_wm_src_affine.g4b"
#include "exa_wm_src_sample_argb.g4b"
......@@ -107,7 +107,7 @@ static const uint32_t ps_kernel_packed_static[][4] = {
#include "exa_wm_write.g4b"
};
static const uint32_t ps_kernel_planar_static[][4] = {
static const uint32_t ps_kernel_planar_bt601_static[][4] = {
#include "exa_wm_xy.g4b"
#include "exa_wm_src_affine.g4b"
#include "exa_wm_src_sample_planar.g4b"
......@@ -115,7 +115,7 @@ static const uint32_t ps_kernel_planar_static[][4] = {
#include "exa_wm_write.g4b"
};
static const uint32_t ps_kernel_nv12_static[][4] = {
static const uint32_t ps_kernel_nv12_bt601_static[][4] = {
#include "exa_wm_xy.g4b"
#include "exa_wm_src_affine.g4b"
#include "exa_wm_src_sample_nv12.g4b"
......@@ -123,6 +123,30 @@ static const uint32_t ps_kernel_nv12_static[][4] = {
#include "exa_wm_write.g4b"
};
static const uint32_t ps_kernel_packed_bt709_static[][4] = {
#include "exa_wm_xy.g4b"
#include "exa_wm_src_affine.g4b"
#include "exa_wm_src_sample_argb.g4b"
#include "exa_wm_yuv_rgb_bt709.g4b"
#include "exa_wm_write.g4b"
};
static const uint32_t ps_kernel_planar_bt709_static[][4] = {
#include "exa_wm_xy.g4b"
#include "exa_wm_src_affine.g4b"
#include "exa_wm_src_sample_planar.g4b"
#include "exa_wm_yuv_rgb_bt709.g4b"
#include "exa_wm_write.g4b"
};
static const uint32_t ps_kernel_nv12_bt709_static[][4] = {
#include "exa_wm_xy.g4b"
#include "exa_wm_src_affine.g4b"
#include "exa_wm_src_sample_nv12.g4b"
#include "exa_wm_yuv_rgb_bt709.g4b"
#include "exa_wm_write.g4b"
};
#define NOKERNEL(kernel_enum, func, masked) \
[kernel_enum] = {func, 0, masked}
#define KERNEL(kernel_enum, kernel, masked) \
......@@ -147,9 +171,13 @@ static const struct wm_kernel_info {
NOKERNEL(WM_KERNEL_OPACITY, brw_wm_kernel__affine_opacity, true),
NOKERNEL(WM_KERNEL_OPACITY_P, brw_wm_kernel__projective_opacity, true),
KERNEL(WM_KERNEL_VIDEO_PLANAR, ps_kernel_planar_static, false),
KERNEL(WM_KERNEL_VIDEO_NV12, ps_kernel_nv12_static, false),
KERNEL(WM_KERNEL_VIDEO_PACKED, ps_kernel_packed_static, false),
KERNEL(WM_KERNEL_VIDEO_PLANAR_BT601, ps_kernel_planar_bt601_static, false),
KERNEL(WM_KERNEL_VIDEO_NV12_BT601, ps_kernel_nv12_bt601_static, false),
KERNEL(WM_KERNEL_VIDEO_PACKED_BT601, ps_kernel_packed_bt601_static, false),
KERNEL(WM_KERNEL_VIDEO_PLANAR_BT709, ps_kernel_planar_bt709_static, false),
KERNEL(WM_KERNEL_VIDEO_NV12_BT709, ps_kernel_nv12_bt709_static, false),
KERNEL(WM_KERNEL_VIDEO_PACKED_BT709, ps_kernel_packed_bt709_static, false),
};
#undef KERNEL
......@@ -1404,6 +1432,29 @@ static void gen4_video_bind_surfaces(struct sna *sna,
gen4_emit_state(sna, op, offset | dirty);
}
static unsigned select_video_kernel(const struct sna_video *video,
const struct sna_video_frame *frame)
{
switch (frame->id) {
case FOURCC_YV12:
case FOURCC_I420:
case FOURCC_XVMC:
return video->colorspace ?
WM_KERNEL_VIDEO_PLANAR_BT709 :
WM_KERNEL_VIDEO_PLANAR_BT601;
case FOURCC_NV12:
return video->colorspace ?
WM_KERNEL_VIDEO_NV12_BT709 :
WM_KERNEL_VIDEO_NV12_BT601;
default:
return video->colorspace ?
WM_KERNEL_VIDEO_PACKED_BT709 :
WM_KERNEL_VIDEO_PACKED_BT601;
}
}
static bool
gen4_render_video(struct sna *sna,
struct sna_video *video,
......@@ -1442,9 +1493,7 @@ gen4_render_video(struct sna *sna,