From 5e48b89686a59c40461d12de79db62708daa43c9 Mon Sep 17 00:00:00 2001
From: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Date: Wed, 19 Feb 2025 08:53:13 -0500
Subject: [PATCH] kmssink: Add NV12_10LE40 / NV15 support

This is needed until kmssink is ported to use libgstvideo mapping.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8525>
---
 subprojects/gst-plugins-bad/docs/plugins/gst_plugins_cache.json | 2 +-
 subprojects/gst-plugins-bad/sys/kms/gstkmsutils.c               | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/subprojects/gst-plugins-bad/docs/plugins/gst_plugins_cache.json b/subprojects/gst-plugins-bad/docs/plugins/gst_plugins_cache.json
index 96be362a33..646b7f5ad9 100644
--- a/subprojects/gst-plugins-bad/docs/plugins/gst_plugins_cache.json
+++ b/subprojects/gst-plugins-bad/docs/plugins/gst_plugins_cache.json
@@ -41598,7 +41598,7 @@
                 "long-name": "KMS video sink",
                 "pad-templates": {
                     "sink": {
-                        "caps": "video/x-raw:\n         format: { BGRA, RGBA, P016_LE, P010_10LE, NV24, BGRx, RGBx, RGB, BGR, Y42B, NV61, NV16, UYVY, YVYU, YUY2, I420, YV12, NV21, NV12, RGB16, BGR16 }\n          width: [ 1, 2147483647 ]\n         height: [ 1, 2147483647 ]\n      framerate: [ 0/1, 2147483647/1 ]\n\nvideo/x-raw(memory:DMABuf):\n         format: DMA_DRM\n          width: [ 1, 2147483647 ]\n         height: [ 1, 2147483647 ]\n      framerate: [ 0/1, 2147483647/1 ]\n",
+                        "caps": "video/x-raw:\n         format: { BGRA, RGBA, P016_LE, NV12_10LE40, P010_10LE, NV24, BGRx, RGBx, RGB, BGR, Y42B, NV61, NV16, UYVY, YVYU, YUY2, I420, YV12, NV21, NV12, RGB16, BGR16 }\n          width: [ 1, 2147483647 ]\n         height: [ 1, 2147483647 ]\n      framerate: [ 0/1, 2147483647/1 ]\n\nvideo/x-raw(memory:DMABuf):\n         format: DMA_DRM\n          width: [ 1, 2147483647 ]\n         height: [ 1, 2147483647 ]\n      framerate: [ 0/1, 2147483647/1 ]\n",
                         "direction": "sink",
                         "presence": "always"
                     }
diff --git a/subprojects/gst-plugins-bad/sys/kms/gstkmsutils.c b/subprojects/gst-plugins-bad/sys/kms/gstkmsutils.c
index 6e0b4dd8b3..bb2145f62b 100644
--- a/subprojects/gst-plugins-bad/sys/kms/gstkmsutils.c
+++ b/subprojects/gst-plugins-bad/sys/kms/gstkmsutils.c
@@ -51,6 +51,7 @@ static const struct
   DEF_FMT (P016, P016_LE),
 
   /* 16bits/c YUV 4:2:0 */
+  DEF_FMT (NV15, NV12_10LE40),
   DEF_FMT (P010, P010_10LE),
 
   /* YUV 4:4:4 */
@@ -128,6 +129,7 @@ gst_drm_bpp_from_drm (guint32 drmfmt)
     case DRM_FORMAT_NV24:
       bpp = 8;
       break;
+    case DRM_FORMAT_NV15:
     case DRM_FORMAT_P010:
       bpp = 10;
       break;