In preparation for YUV/YCbCr pixel format support in the writeback
connector. The implementation is meant to mirror the existing
get_conversion_matrix_to_argb_u16() as close as possible.
Signed-off-by: Robert Mader <[email protected]>
---
drivers/gpu/drm/vkms/vkms_formats.c | 153 ++++++++++++++++++++++++++++
drivers/gpu/drm/vkms/vkms_formats.h | 4 +
2 files changed, 157 insertions(+)
diff --git a/drivers/gpu/drm/vkms/vkms_formats.c
b/drivers/gpu/drm/vkms/vkms_formats.c
index dfb8e13cba87..560b56fbf4fb 100644
--- a/drivers/gpu/drm/vkms/vkms_formats.c
+++ b/drivers/gpu/drm/vkms/vkms_formats.c
@@ -787,6 +787,20 @@ static const struct conversion_matrix yuv_bt601_full = {
.y_offset = 0,
};
+/*
+ * numpy.around(numpy.linalg.inv(colour.matrix_YCbCr(K=colour.WEIGHTS_YCBCR["ITU-R
BT.601"],
+ * is_legal = False,
+ * bits = 8)) *
2**32).astype(int)
+ */
+static const struct conversion_matrix rgb_to_yuv_bt601_full = {
+ .matrix = {
+ { 1284195222, 2521145803, 489626272 },
+ { -724715136, -1422768512, 2147483648 },
+ { 2147483648, -1798249503, -349234145 },
+ },
+ .y_offset = 0,
+};
+
/*
* numpy.around(colour.matrix_YCbCr(K=colour.WEIGHTS_YCBCR["ITU-R BT.601"],
* is_legal = True,
@@ -801,6 +815,20 @@ static const struct conversion_matrix yuv_bt601_limited = {
.y_offset = 16,
};
+/*
+ * numpy.around(numpy.linalg.inv(colour.matrix_YCbCr(K=colour.WEIGHTS_YCBCR["ITU-R
BT.601"],
+ * is_legal = True,
+ * bits = 8)) *
2**32).astype(int)
+ */
+static const struct conversion_matrix rgb_to_yuv_bt601_limited = {
+ .matrix = {
+ { 1102897073, 2165219336, 420502563 },
+ { -636612512, -1249804497, 1886417008 },
+ { 1886417008, -1579638779, -306778230 },
+ },
+ .y_offset = 16,
+};
+
/*
* numpy.around(colour.matrix_YCbCr(K=colour.WEIGHTS_YCBCR["ITU-R BT.709"],
* is_legal = False,
@@ -815,6 +843,20 @@ static const struct conversion_matrix yuv_bt709_full = {
.y_offset = 0,
};
+/*
+ * numpy.around(numpy.linalg.inv(colour.matrix_YCbCr(K=colour.WEIGHTS_YCBCR["ITU-R
BT.709"],
+ * is_legal = False,
+ * bits = 8)) *
2**32).astype(int)
+ */
+static const struct conversion_matrix rgb_to_yuv_bt709_full = {
+ .matrix = {
+ { 913110047, 3071760610, 310096639 },
+ { -492083449, -1655400199, 2147483648 },
+ { 2147483648, -1950571889, -196911759 },
+ },
+ .y_offset = 0,
+};
+
/*
* numpy.around(colour.matrix_YCbCr(K=colour.WEIGHTS_YCBCR["ITU-R BT.709"],
* is_legal = True,
@@ -829,6 +871,20 @@ static const struct conversion_matrix yuv_bt709_limited = {
.y_offset = 16,
};
+/*
+ * numpy.around(numpy.linalg.inv(colour.matrix_YCbCr(K=colour.WEIGHTS_YCBCR["ITU-R
BT.709"],
+ * is_legal = True,
+ * bits = 8)) *
2**32).astype(int)
+ */
+static const struct conversion_matrix rgb_to_yuv_bt709_limited = {
+ .matrix = {
+ { 784200393, 2638100289, 266318290 },
+ { -432261539, -1454155469, 1886417008 },
+ { 1886417008, -1713443541, -172973467 },
+ },
+ .y_offset = 16,
+};
+
/*
* numpy.around(colour.matrix_YCbCr(K=colour.WEIGHTS_YCBCR["ITU-R BT.2020"],
* is_legal = False,
@@ -843,6 +899,20 @@ static const struct conversion_matrix yuv_bt2020_full = {
.y_offset = 0,
};
+/*
+ * numpy.around(numpy.linalg.inv(colour.matrix_YCbCr(K=colour.WEIGHTS_YCBCR["ITU-R
BT.2020"],
+ * is_legal = False,
+ * bits = 8)) *
2**32).astype(int)
+ */
+static const struct conversion_matrix rgb_to_yuv_bt2020_full = {
+ .matrix = {
+ { 1128287909, 2911987827, 254691561 },
+ { -599706553, -1547777095, 2147483648 },
+ { 2147483648, -1974764564, -172719084 },
+ },
+ .y_offset = 0,
+};
+
/*
* numpy.around(colour.matrix_YCbCr(K=colour.WEIGHTS_YCBCR["ITU-R BT.2020"],
* is_legal = True,
@@ -857,6 +927,20 @@ static const struct conversion_matrix yuv_bt2020_limited =
{
.y_offset = 16,
};
+/*
+ * numpy.around(numpy.linalg.inv(colour.matrix_YCbCr(K=colour.WEIGHTS_YCBCR["ITU-R
BT.2020"],
+ * is_legal = True,
+ * bits = 8)) *
2**32).astype(int)
+ */
+static const struct conversion_matrix rgb_to_yuv_bt2020_limited = {
+ .matrix = {
+ { 969000204, 2500883663, 218735105 },
+ { -526801050, -1359615958, 1886417008 },
+ { 1886417008, -1734695147, -151721862 },
+ },
+ .y_offset = 16,
+};
+
/**
* swap_uv_columns() - Swap u and v column of a given matrix
*
@@ -869,6 +953,18 @@ static void swap_uv_columns(struct conversion_matrix
*matrix)
swap(matrix->matrix[2][2], matrix->matrix[2][1]);
}
+/**
+ * swap_uv_columns_transposed() - Swap u and v column of a given matrix
+ *
+ * @matrix: Matrix in which column are swapped
+ */