Lakka v5.x switch 6 (#1926)

* L4T: Fix/Enable NVV4l2 decoder in libreelec builds.

* L4T: LibreELEC: Allow Kodi to run as root

* L4T: Small Tree Cleanup

* Bluez: Switch: LibreELEC: Fix fast connect on all switch builds, not just lakka.

* L4T: Finish ffmpeg 6.0 patchset

* L4T: Fix building newer libcec for switch

* L4T: switch-bsp: Update dock hotplug to check distro stuff, before integrating CEC and bump version.
This commit is contained in:
GavinDarkglider 2024-01-29 10:49:02 -08:00 committed by GitHub
parent 9297f90a35
commit 66e50e96b9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
54 changed files with 2145 additions and 661 deletions

View File

@ -27,12 +27,10 @@ case "${PROJECT}" in
PKG_PATCH_DIRS+=" rpi"
;;
L4T)
if [ ! "${DISTRO}" = "LibreELEC" ]; then
PKG_DEPENDS_TARGET+=" tegra-bsp:host"
PKG_PATCH_DIRS+=" L4T"
PKG_FFMPEG_NVV4L2="--enable-nvv4l2"
EXTRA_CFLAGS="-I${SYSROOT_PREFIX}/usr/src/jetson_multimedia_api/include"
fi
;;
*)
if [ "${DISPLAYSERVER}" = "x11" ]; then

View File

@ -0,0 +1,75 @@
From ffa9de21d7415d53f2f02b674438a41daaeee209 Mon Sep 17 00:00:00 2001
From: CTCaer <ctcaer@gmail.com>
Date: Sat, 5 Mar 2022 03:30:44 +0000
Subject: [PATCH 02/39] fftools/libavformat: Enforce nvv4l2
This enforces NVV4L2 even if user requests another codec.
Additionally, it forces nvv4l2 to go through software codecs first to get context if needed.
---
fftools/ffplay.c | 25 +++++++++++++++++++++++++
libavformat/demux.c | 13 +++++++++++++
2 files changed, 38 insertions(+)
diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index d6479aef5f..86f8425a15 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -2590,6 +2590,31 @@ static int stream_component_open(VideoState *is, int stream_index)
case AVMEDIA_TYPE_SUBTITLE: is->last_subtitle_stream = stream_index; forced_codec_name = subtitle_codec_name; break;
case AVMEDIA_TYPE_VIDEO : is->last_video_stream = stream_index; forced_codec_name = video_codec_name; break;
}
+
+#if CONFIG_NVV4L2
+ /* Reset requested decoder in order to enforce NVV4L2 if possible. */
+ if (avctx->codec_type == AVMEDIA_TYPE_VIDEO && forced_codec_name) {
+ if (strcmp(forced_codec_name, "h264") == 0)
+ forced_codec_name = NULL;
+ else if (strcmp(forced_codec_name, "hevc") == 0)
+ forced_codec_name = NULL;
+ else if (strcmp(forced_codec_name, "mpeg2video") == 0)
+ forced_codec_name = NULL;
+ else if (strcmp(forced_codec_name, "mpeg4") == 0)
+ forced_codec_name = NULL;
+ else if (strcmp(forced_codec_name, "vp8") == 0)
+ forced_codec_name = NULL;
+ else if (strcmp(forced_codec_name, "vp9") == 0 &&
+ avctx->pix_fmt != AV_PIX_FMT_YUV420P10) {
+ forced_codec_name = NULL;
+ }
+ }
+
+ /* NVV4L2 does not support VP9 with YUV420P10. */
+ if (!forced_codec_name && avctx->pix_fmt == AV_PIX_FMT_YUV420P10)
+ forced_codec_name = "vp9";
+#endif
+
if (forced_codec_name)
codec = avcodec_find_decoder_by_name(forced_codec_name);
if (!codec) {
diff --git a/libavformat/demux.c b/libavformat/demux.c
index b19ab86d08..ae60a819d5 100644
--- a/libavformat/demux.c
+++ b/libavformat/demux.c
@@ -77,6 +77,19 @@ static const AVCodec *find_probe_decoder(AVFormatContext *s, const AVStream *st,
if (codec_id == AV_CODEC_ID_H264)
return avcodec_find_decoder_by_name("h264");
#endif
+#if CONFIG_NVV4L2
+ /* NVV4L2 decoders depend on context init from base decoders */
+ if (codec_id == AV_CODEC_ID_HEVC)
+ return avcodec_find_decoder_by_name("hevc");
+ else if (codec_id == AV_CODEC_ID_MPEG2VIDEO)
+ return avcodec_find_decoder_by_name("mpeg2video");
+ else if (codec_id == AV_CODEC_ID_MPEG4)
+ return avcodec_find_decoder_by_name("mpeg4");
+ else if (codec_id == AV_CODEC_ID_VP8)
+ return avcodec_find_decoder_by_name("vp8");
+ else if (codec_id == AV_CODEC_ID_VP9)
+ return avcodec_find_decoder_by_name("vp9");
+#endif
codec = ff_find_decoder(s, st, codec_id);
if (!codec)
--
2.25.1

View File

@ -1,7 +1,7 @@
From 87622041abb1387bc8580721d23ec79a03e5249c Mon Sep 17 00:00:00 2001
From c80256646ddae6d91a1ec9fe1a6cda53efaf923f Mon Sep 17 00:00:00 2001
From: CTCaer <ctcaer@gmail.com>
Date: Sun, 6 Mar 2022 04:26:06 +0000
Subject: [PATCH 04/22] codecs: nvv4l2: avoid probing
Subject: [PATCH 03/39] codecs: nvv4l2: avoid probing
NVV4L2 does not support probing for getting stream metadata.
So disallow that.

View File

@ -1,87 +0,0 @@
diff -Naur ffmpeg-6.0/fftools/ffmpeg_demux.c ffmpeg-6.0-2/fftools/ffmpeg_demux.c
--- ffmpeg-6.0/fftools/ffmpeg_demux.c 2023-06-04 21:39:14.447960833 +0200
+++ ffmpeg-6.0-2/fftools/ffmpeg_demux.c 2023-06-04 21:43:39.492669262 +0200
@@ -502,6 +502,25 @@
char *codec_name = NULL;
MATCH_PER_STREAM_OPT(codec_names, str, codec_name, s, st);
+
+#if CONFIG_NVV4L2
+ /* Reset requested decoder in order to enforce NVV4L2 if possible. */
+ if (codec_name) {
+ if (strcmp(codec_name, "h264") == 0)
+ return avcodec_find_decoder(st->codecpar->codec_id);
+ else if (strcmp(codec_name, "hevc") == 0)
+ return avcodec_find_decoder(st->codecpar->codec_id);
+ else if (strcmp(codec_name, "mpeg2video") == 0)
+ return avcodec_find_decoder(st->codecpar->codec_id);
+ else if (strcmp(codec_name, "mpeg4") == 0)
+ return avcodec_find_decoder(st->codecpar->codec_id);
+ else if (strcmp(codec_name, "vp8") == 0)
+ return avcodec_find_decoder(st->codecpar->codec_id);
+ else if (strcmp(codec_name, "vp9") == 0 && st->codecpar->format != AV_PIX_FMT_YUV420P10)
+ return avcodec_find_decoder(st->codecpar->codec_id);
+ }
+#endif
+
if (codec_name) {
const AVCodec *codec = find_codec_or_die(NULL, codec_name, st->codecpar->codec_type, 0);
st->codecpar->codec_id = codec->id;
diff -Naur ffmpeg-6.0/fftools/ffplay.c ffmpeg-6.0-2/fftools/ffplay.c
--- ffmpeg-6.0/fftools/ffplay.c 2023-06-04 21:39:14.447960833 +0200
+++ ffmpeg-6.0-2/fftools/ffplay.c 2023-06-04 21:41:40.550552101 +0200
@@ -2590,6 +2590,31 @@
case AVMEDIA_TYPE_SUBTITLE: is->last_subtitle_stream = stream_index; forced_codec_name = subtitle_codec_name; break;
case AVMEDIA_TYPE_VIDEO : is->last_video_stream = stream_index; forced_codec_name = video_codec_name; break;
}
+
+#if CONFIG_NVV4L2
+ /* Reset requested decoder in order to enforce NVV4L2 if possible. */
+ if (avctx->codec_type == AVMEDIA_TYPE_VIDEO && forced_codec_name) {
+ if (strcmp(forced_codec_name, "h264") == 0)
+ forced_codec_name = NULL;
+ else if (strcmp(forced_codec_name, "hevc") == 0)
+ forced_codec_name = NULL;
+ else if (strcmp(forced_codec_name, "mpeg2video") == 0)
+ forced_codec_name = NULL;
+ else if (strcmp(forced_codec_name, "mpeg4") == 0)
+ forced_codec_name = NULL;
+ else if (strcmp(forced_codec_name, "vp8") == 0)
+ forced_codec_name = NULL;
+ else if (strcmp(forced_codec_name, "vp9") == 0 &&
+ avctx->pix_fmt != AV_PIX_FMT_YUV420P10) {
+ forced_codec_name = NULL;
+ }
+ }
+
+ /* NVV4L2 does not support VP9 with YUV420P10. */
+ if (!forced_codec_name && avctx->pix_fmt == AV_PIX_FMT_YUV420P10)
+ forced_codec_name = "vp9";
+#endif
+
if (forced_codec_name)
codec = avcodec_find_decoder_by_name(forced_codec_name);
if (!codec) {
diff -Naur ffmpeg-6.0/libavformat/utils.c ffmpeg-6.0-2/libavformat/utils.c
--- ffmpeg-6.0/libavformat/utils.c 2023-06-04 21:39:14.379959629 +0200
+++ ffmpeg-6.0-2/libavformat/utils.c 2023-06-04 21:41:40.550552101 +0200
@@ -37,6 +37,19 @@
#if CONFIG_NETWORK
#include "network.h"
#endif
+#if CONFIG_NVV4L2
+ /* NVV4L2 decoders depend on context init from base decoders */
+ if (codec_id == AV_CODEC_ID_HEVC)
+ return avcodec_find_decoder_by_name("hevc");
+ else if (codec_id == AV_CODEC_ID_MPEG2VIDEO)
+ return avcodec_find_decoder_by_name("mpeg2video");
+ else if (codec_id == AV_CODEC_ID_MPEG4)
+ return avcodec_find_decoder_by_name("mpeg4");
+ else if (codec_id == AV_CODEC_ID_VP8)
+ return avcodec_find_decoder_by_name("vp8");
+ else if (codec_id == AV_CODEC_ID_VP9)
+ return avcodec_find_decoder_by_name("vp9");
+#endif
static AVMutex avformat_mutex = AV_MUTEX_INITIALIZER;

View File

@ -1,18 +1,18 @@
From ecdbd9b4904b71bea7d3c373690d0e6283896730 Mon Sep 17 00:00:00 2001
From 81aa7501ce56cf7df7ee7be3bf6e7e37d1952dc8 Mon Sep 17 00:00:00 2001
From: CTCaer <ctcaer@gmail.com>
Date: Sun, 6 Mar 2022 04:27:54 +0000
Subject: [PATCH 05/22] libavformat: remove nvv4l2 probing mitigation
Subject: [PATCH 04/39] libavformat: remove nvv4l2 probing mitigation
It was fixed properly with AV_CODEC_CAP_AVOID_PROBING flag.
---
libavformat/utils.c | 13 -------------
libavformat/demux.c | 13 -------------
1 file changed, 13 deletions(-)
diff --git a/libavformat/utils.c b/libavformat/utils.c
index a960f8265d..1384b56771 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -211,19 +211,6 @@ static const AVCodec *find_probe_decoder(AVFormatContext *s, const AVStream *st,
diff --git a/libavformat/demux.c b/libavformat/demux.c
index ae60a819d5..b19ab86d08 100644
--- a/libavformat/demux.c
+++ b/libavformat/demux.c
@@ -77,19 +77,6 @@ static const AVCodec *find_probe_decoder(AVFormatContext *s, const AVStream *st,
if (codec_id == AV_CODEC_ID_H264)
return avcodec_find_decoder_by_name("h264");
#endif
@ -25,12 +25,12 @@ index a960f8265d..1384b56771 100644
- else if (codec_id == AV_CODEC_ID_MPEG4)
- return avcodec_find_decoder_by_name("mpeg4");
- else if (codec_id == AV_CODEC_ID_VP8)
- return avcodec_find_decoder_by_name("vp8");
- return avcodec_find_decoder_by_name("vp8");
- else if (codec_id == AV_CODEC_ID_VP9)
- return avcodec_find_decoder_by_name("vp9");
-#endif
codec = find_decoder(s, st, codec_id);
codec = ff_find_decoder(s, st, codec_id);
if (!codec)
--
2.25.1

View File

@ -1,7 +1,7 @@
From 8e286f3ffc845709f6747d77982c60ad0ed0b37f Mon Sep 17 00:00:00 2001
From 135ad87310784e7dfd49c95ba6f7ed45e9444cd8 Mon Sep 17 00:00:00 2001
From: CTCaer <ctcaer@gmail.com>
Date: Fri, 18 Mar 2022 21:16:35 +0000
Subject: [PATCH 06/22] codecs: nvv4l2: do not use external headers
Subject: [PATCH 05/39] codecs: nvv4l2: do not use external headers
Make needed headers builtin as this will help to bring compatibility from r32.3.1 till r32.7.1 and newer with a single build.
---
@ -11,10 +11,10 @@ Make needed headers builtin as this will help to bring compatibility from r32.3.
create mode 100644 libavcodec/nvv4l2_ext_utils.h
diff --git a/configure b/configure
index 29a6d96575..ea84db929c 100755
index 889b547071..ba28526b44 100755
--- a/configure
+++ b/configure
@@ -3053,7 +3053,7 @@ qsvenc_select="qsv"
@@ -3131,7 +3131,7 @@ qsvenc_select="qsv"
qsvvpp_select="qsv"
vaapi_encode_deps="vaapi"
v4l2_m2m_deps="linux_videodev2_h sem_timedwait"
@ -22,8 +22,8 @@ index 29a6d96575..ea84db929c 100755
+nvv4l2_deps="libv4l2 pthreads linux_videodev2_h"
nvv4l2_extralibs="-lnvbuf_utils"
hwupload_cuda_filter_deps="ffnvcodec"
@@ -6798,11 +6798,8 @@ if enabled_any nvdec cuvid; then
bilateral_cuda_filter_deps="ffnvcodec"
@@ -7070,11 +7070,8 @@ if enabled_any nvdec cuvid; then
check_type "ffnvcodec/dynlink_cuda.h ffnvcodec/dynlink_cuviddec.h" "CUVIDAV1PICPARAMS"
fi

View File

@ -1,7 +1,7 @@
From fd622ef8d15cf208810f82a6a843b4db94fb28be Mon Sep 17 00:00:00 2001
From 4896ff0afcdccbb5521dee948c233dccb6616d7a Mon Sep 17 00:00:00 2001
From: CTCaer <ctcaer@gmail.com>
Date: Fri, 18 Mar 2022 21:20:48 +0000
Subject: [PATCH 07/22] codecs: nvv4l2: use atomics for pool
Subject: [PATCH 06/39] codecs: nvv4l2: use atomics for pool
Do not lock with mutexes until we need to do more in pools. Use atomics for now to lower latency.
---

View File

@ -1,7 +1,7 @@
From 0fd5fb903861c42d40f84b0468496006966e1c5d Mon Sep 17 00:00:00 2001
From 607f6a8e40b495ecb887fc046bf8cf6030036c3a Mon Sep 17 00:00:00 2001
From: CTCaer <ctcaer@gmail.com>
Date: Fri, 18 Mar 2022 21:23:33 +0000
Subject: [PATCH 08/22] codecs: nvv4l2: add new functions and update context as
Subject: [PATCH 07/39] codecs: nvv4l2: add new functions and update context as
prep
---

View File

@ -1,7 +1,7 @@
From 02d9583d32a9a8bd02dda9dd510519c04691d8d2 Mon Sep 17 00:00:00 2001
From 72f992d69e5462c2da170f4259032b5f9ff6b250 Mon Sep 17 00:00:00 2001
From: CTCaer <ctcaer@gmail.com>
Date: Fri, 18 Mar 2022 21:31:31 +0000
Subject: [PATCH 09/22] codecs: nvv4l2: support multiple L4T versions with
Subject: [PATCH 08/39] codecs: nvv4l2: support multiple L4T versions with
single build
Nvidia has the tendency to break compatibility on documented apis for no reason.

View File

@ -1,7 +1,7 @@
From 280522f4f351a045ae7288ce7f5110ae099ea8b7 Mon Sep 17 00:00:00 2001
From ade9d9b54d172437be84797300b25a85c4164cd4 Mon Sep 17 00:00:00 2001
From: CTCaer <ctcaer@gmail.com>
Date: Fri, 18 Mar 2022 21:39:48 +0000
Subject: [PATCH 10/22] codecs: nvv4l2: align line width to 64B
Subject: [PATCH 09/39] codecs: nvv4l2: align line width to 64B
Transformations of formats to formats of simply Block linear to Pitch are done in HW.

View File

@ -1,7 +1,7 @@
From 9d3282af10055fbbb81bd53654dd342682e2d09d Mon Sep 17 00:00:00 2001
From b7a72216ca1ed53f6428a3fca5949618d2059538 Mon Sep 17 00:00:00 2001
From: CTCaer <ctcaer@gmail.com>
Date: Fri, 18 Mar 2022 21:42:29 +0000
Subject: [PATCH 11/22] codecs: nvv4l2: add two-pass cbr mode support
Subject: [PATCH 10/39] codecs: nvv4l2: add two-pass cbr mode support
To enable, use `twopass=on` as encoder option.

View File

@ -1,7 +1,7 @@
From 73aba81a154a3f25efb2326a6e59949660d6a5f5 Mon Sep 17 00:00:00 2001
From 124b4a1c85f24a11de5710b8515648dae91000cf Mon Sep 17 00:00:00 2001
From: CTCaer <ctcaer@gmail.com>
Date: Fri, 18 Mar 2022 21:46:36 +0000
Subject: [PATCH 12/22] codecs: nvv4l2: various bugfixes
Subject: [PATCH 11/39] codecs: nvv4l2: various bugfixes
---
libavcodec/nvv4l2_dec.c | 105 ++++++++++++++++++++++------------------

View File

@ -1,7 +1,7 @@
From c0832ff40e14ff28c926e500525cdf839d58ff98 Mon Sep 17 00:00:00 2001
From d78e4bc70ec1d97e22c5f0365c027574e740923f Mon Sep 17 00:00:00 2001
From: CTCaer <ctcaer@gmail.com>
Date: Fri, 18 Mar 2022 21:50:20 +0000
Subject: [PATCH 13/22] codecs: nvv4l2: fix hanging on event wait if no full
Subject: [PATCH 12/39] codecs: nvv4l2: fix hanging on event wait if no full
frame info
Sometimes the decoder can be opened with no packet sent or not many for a frame to be decoded.

View File

@ -1,7 +1,7 @@
From eceaecff30fc8a1ca622de7506470d486e34695a Mon Sep 17 00:00:00 2001
From ac123e70b68b22a99b483ba5b9406e60b35f1519 Mon Sep 17 00:00:00 2001
From: CTCaer <ctcaer@gmail.com>
Date: Fri, 18 Mar 2022 21:53:34 +0000
Subject: [PATCH 14/22] codecs: nvv4l2: use sessions for transformations
Subject: [PATCH 13/39] codecs: nvv4l2: use sessions for transformations
Some apps use different processes for init and decoding.

View File

@ -1,7 +1,7 @@
From 1d0dbfb7243a12b2941a23584a2dbed7cfb7077f Mon Sep 17 00:00:00 2001
From 95ed6f305a76c588f8264406e69123e3775e6c36 Mon Sep 17 00:00:00 2001
From: CTCaer <ctcaer@gmail.com>
Date: Fri, 18 Mar 2022 21:57:58 +0000
Subject: [PATCH 15/22] codecs: nvv4l2: support all different timestamps
Subject: [PATCH 14/39] codecs: nvv4l2: support all different timestamps
Various packets and players have different timestamps defined.

View File

@ -1,7 +1,7 @@
From 04008befad133d97b7f956a21632592aaaede7ca Mon Sep 17 00:00:00 2001
From 0cd74d94cdac5e3cd7ce3e014b3af2b276389074 Mon Sep 17 00:00:00 2001
From: CTCaer <ctcaer@gmail.com>
Date: Sat, 11 Jun 2022 17:14:49 +0000
Subject: [PATCH 16/22] codecs: nvv4l2: BSP 34.1.x remarks
Subject: [PATCH 15/39] codecs: nvv4l2: BSP 34.1.x remarks
NVIDIA changed the enum again in r34 and broke compatibility for no reason.

View File

@ -1,7 +1,7 @@
From 3674076e6287c62dd39c73585521504908f25fb9 Mon Sep 17 00:00:00 2001
From 628d01310250a97fc874f3acb9405460b57e679d Mon Sep 17 00:00:00 2001
From: CTCaer <ctcaer@gmail.com>
Date: Tue, 14 Jun 2022 19:21:20 +0000
Subject: [PATCH 17/22] codecs: nvv4l2: support BT709/BT2020 colorspaces
Subject: [PATCH 16/39] codecs: nvv4l2: support BT709/BT2020 colorspaces
---
libavcodec/nvv4l2_dec.c | 62 ++++++++++++++++++++++++-----------

View File

@ -1,7 +1,7 @@
From 636c040931dff3d5febae00697a8502af396e01f Mon Sep 17 00:00:00 2001
From 9ad8d41a2aa4dcb6b552d77e04f9ce4dc26e999a Mon Sep 17 00:00:00 2001
From: CTCaer <ctcaer@gmail.com>
Date: Wed, 15 Jun 2022 13:33:10 +0000
Subject: [PATCH 18/22] codecs: nvv4l2: reorder capture buffer queueing
Subject: [PATCH 17/39] codecs: nvv4l2: reorder capture buffer queueing
Move capture buffer queueing after capture plane stream on.

View File

@ -1,7 +1,7 @@
From 7b67a0996bb80c38a923b215566c67ffc130d161 Mon Sep 17 00:00:00 2001
From ef1bcd73fa1e37982dfc24f2319e83d5932848a8 Mon Sep 17 00:00:00 2001
From: CTCaer <ctcaer@gmail.com>
Date: Tue, 28 Jun 2022 01:37:59 +0000
Subject: [PATCH 19/22] codecs: nvv4l2: align encoder plane width to 64B
Subject: [PATCH 18/39] codecs: nvv4l2: align encoder plane width to 64B
Transformations of Block linear formats to linear Pitch formats are done in HW.

View File

@ -1,7 +1,7 @@
From b0aabaeebd73e4968654f384f44ce8a4d608ae8d Mon Sep 17 00:00:00 2001
From c5751e2bb1faeb0fd8e4442461bbbcd9448c3960 Mon Sep 17 00:00:00 2001
From: CTCaer <ctcaer@gmail.com>
Date: Wed, 29 Jun 2022 06:38:26 +0000
Subject: [PATCH 20/22] codecs: nvv4l2: align enc plane width per format/plane
Subject: [PATCH 19/39] codecs: nvv4l2: align enc plane width per format/plane
Take two on creating a heuristic of the needed alignment.

View File

@ -1,7 +1,7 @@
From deac819ac20d2ccd1664c95e4d91c20a35d67cc5 Mon Sep 17 00:00:00 2001
From 1fe17b61d4221fed766069a7742a7d09eaabedbf Mon Sep 17 00:00:00 2001
From: CTCaer <ctcaer@gmail.com>
Date: Wed, 3 Aug 2022 22:04:22 +0000
Subject: [PATCH 21/22] codecs: nvv4l2: fix memleak
Subject: [PATCH 20/39] codecs: nvv4l2: fix memleak
Fixes #2

View File

@ -1,7 +1,7 @@
From 95d5bcfdc444e7d19299be64311119582c0fbab9 Mon Sep 17 00:00:00 2001
From 24b397a75e4a737c845b91771274ad1104edd54f Mon Sep 17 00:00:00 2001
From: CTCaer <ctcaer@gmail.com>
Date: Wed, 28 Dec 2022 14:22:13 +0000
Subject: [PATCH 22/22] codecs: nvv4l2: fix use after free
Subject: [PATCH 21/39] codecs: nvv4l2: fix use after free
---
libavcodec/nvv4l2_enc.c | 9 +++++++--

View File

@ -1,16 +1,27 @@
diff -Naur ffmpeg-6.0/libavcodec/nvv4l2_dec.c ffmpeg-6.0-2/libavcodec/nvv4l2_dec.c
--- ffmpeg-6.0/libavcodec/nvv4l2_dec.c 2023-06-04 21:56:37.526608261 +0200
+++ ffmpeg-6.0-2/libavcodec/nvv4l2_dec.c 2023-06-04 23:04:03.479000528 +0200
@@ -29,6 +29,8 @@
From b2a7cfdcf77cfd5c3ca864670aa949ddef17cd9a Mon Sep 17 00:00:00 2001
From: Azkali Manad <a.ffcc7@gmail.com>
Date: Wed, 25 Jan 2023 02:02:57 +0100
Subject: [PATCH 22/39] codecs: nvv4l2: rename AVCodec to fit API renames
---
libavcodec/nvv4l2_dec.c | 20 ++++++++++----------
libavcodec/nvv4l2_enc.c | 20 ++++++++++----------
2 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/libavcodec/nvv4l2_dec.c b/libavcodec/nvv4l2_dec.c
index 35784e0704..b56d35cf82 100644
--- a/libavcodec/nvv4l2_dec.c
+++ b/libavcodec/nvv4l2_dec.c
@@ -29,7 +29,7 @@
#include <string.h>
#include <fcntl.h>
#include <errno.h>
+#include "decode.h"
-#include "internal.h"
+#include "codec_internal.h"
#include "internal.h"
#include "libavutil/log.h"
@@ -1203,22 +1205,22 @@
#include "nvv4l2.h"
@@ -1203,22 +1203,22 @@ nvv4l2dec_decode(AVCodecContext *avctx, void *data, int *got_frame,
#define NVV4L2_DEC(NAME, ID, BSFS) \
NVV4L2_DEC_CLASS(NAME) \
@ -19,16 +30,15 @@ diff -Naur ffmpeg-6.0/libavcodec/nvv4l2_dec.c ffmpeg-6.0-2/libavcodec/nvv4l2_dec
- .long_name = NULL_IF_CONFIG_SMALL(#NAME " NVV4L2 HW decoder for Tegra"), \
- .type = AVMEDIA_TYPE_VIDEO, \
- .id = ID, \
+ FFCodec ff_##NAME##_nvv4l2_decoder = { \
+ const FFCodec ff_##NAME##_nvv4l2_decoder = { \
+ .p.name = #NAME "_nvv4l2", \
+ CODEC_LONG_NAME(NULL_IF_CONFIG_SMALL(#NAME " NVV4L2 HW decoder for Tegra")), \
+ .p.long_name = NULL_IF_CONFIG_SMALL(#NAME " NVV4L2 HW decoder for Tegra"), \
+ .p.type = AVMEDIA_TYPE_VIDEO, \
+ .p.id = ID, \
.priv_data_size = sizeof(nvv4l2DecodeContext), \
.init = nvv4l2dec_init, \
.close = nvv4l2dec_close, \
- .decode = nvv4l2dec_decode, \
+ FF_CODEC_DECODE_CB(nvv4l2dec_decode), \
.decode = nvv4l2dec_decode, \
.flush = nvv4l2dec_flush, \
- .priv_class = &nvv4l2_##NAME##_dec_class, \
- .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HARDWARE | \
@ -43,37 +53,20 @@ diff -Naur ffmpeg-6.0/libavcodec/nvv4l2_dec.c ffmpeg-6.0-2/libavcodec/nvv4l2_dec
AV_PIX_FMT_NV12, \
AV_PIX_FMT_NONE }, \
};
diff -Naur ffmpeg-6.0/libavcodec/nvv4l2_enc.c ffmpeg-6.0-2/libavcodec/nvv4l2_enc.c
--- ffmpeg-6.0/libavcodec/nvv4l2_enc.c 2023-06-04 21:56:41.758684320 +0200
+++ ffmpeg-6.0-2/libavcodec/nvv4l2_enc.c 2023-06-04 23:48:47.734896973 +0200
@@ -28,6 +28,8 @@
diff --git a/libavcodec/nvv4l2_enc.c b/libavcodec/nvv4l2_enc.c
index dc09236e0a..fad54868e3 100644
--- a/libavcodec/nvv4l2_enc.c
+++ b/libavcodec/nvv4l2_enc.c
@@ -28,7 +28,7 @@
#include <string.h>
#include <fcntl.h>
#include <errno.h>
+#include "encode.h"
-#include "internal.h"
+#include "codec_internal.h"
#include "internal.h"
#include "libavutil/imgutils.h"
#include "libavutil/log.h"
@@ -1265,7 +1267,7 @@
if (nvv4l2_encoder_get_packet(avctx, ctx, &packet))
return 0;
- ff_alloc_packet2(avctx, pkt, packet.payload_size, packet.payload_size);
+ ff_alloc_packet(avctx, pkt, packet.payload_size);
memcpy(pkt->data, packet.payload, packet.payload_size);
pkt->dts = pkt->pts = packet.pts;
@@ -1286,7 +1288,7 @@
return 0;
}
-static const AVCodecDefault defaults[] = {
+static const FFCodecDefault defaults[] = {
{ "b", "5M" },
{ "qmin", "-1" },
{ "qmax", "-1" },
@@ -1455,20 +1457,20 @@
#include "libavutil/opt.h"
@@ -1455,20 +1455,20 @@ static const AVOption options_hevc[] = {
#define NVV4L2_ENC(NAME, ID) \
NVV4L2_ENC_CLASS(NAME) \
@ -82,18 +75,17 @@ diff -Naur ffmpeg-6.0/libavcodec/nvv4l2_enc.c ffmpeg-6.0-2/libavcodec/nvv4l2_enc
- .long_name = NULL_IF_CONFIG_SMALL(#NAME " NVV4L2 HW encoder for Tegra"), \
- .type = AVMEDIA_TYPE_VIDEO, \
- .id = ID, \
+ FFCodec ff_##NAME##_nvv4l2_encoder = { \
+ const FFCodec ff_##NAME##_nvv4l2_encoder = { \
+ .p.name = #NAME "_nvv4l2" , \
+ CODEC_LONG_NAME(NULL_IF_CONFIG_SMALL(#NAME " NVV4L2 HW encoder for Tegra")), \
+ .p.long_name = NULL_IF_CONFIG_SMALL(#NAME " NVV4L2 HW encoder for Tegra"), \
+ .p.type = AVMEDIA_TYPE_VIDEO, \
+ .p.id = ID, \
.priv_data_size = sizeof(nvv4l2EncodeContext), \
.init = nvv4l2enc_init, \
.close = nvv4l2enc_close, \
- .encode2 = nvv4l2enc_encode, \
.encode2 = nvv4l2enc_encode, \
- .priv_class = &nvv4l2_##NAME##_enc_class, \
- .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HARDWARE, \
+ FF_CODEC_ENCODE_CB(nvv4l2enc_encode), \
+ .p.priv_class = &nvv4l2_##NAME##_enc_class, \
+ .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HARDWARE, \
.defaults = defaults, \
@ -104,3 +96,6 @@ diff -Naur ffmpeg-6.0/libavcodec/nvv4l2_enc.c ffmpeg-6.0-2/libavcodec/nvv4l2_enc
AV_PIX_FMT_YUV444P, \
AV_PIX_FMT_NV12, \
AV_PIX_FMT_P010, \
--
2.25.1

View File

@ -0,0 +1,92 @@
From 23ccbf1d6a5494c7d79e8df2c74f02358e8df7d4 Mon Sep 17 00:00:00 2001
From: Azkali Manad <a.ffcc7@gmail.com>
Date: Wed, 25 Jan 2023 03:08:02 +0100
Subject: [PATCH 23/39] codecs: nvv4l2: comment structs redefined in nvv4l2.h
---
libavcodec/nvv4l2_ext_utils.h | 32 ++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/libavcodec/nvv4l2_ext_utils.h b/libavcodec/nvv4l2_ext_utils.h
index 007306ccc5..04a2ee1c79 100644
--- a/libavcodec/nvv4l2_ext_utils.h
+++ b/libavcodec/nvv4l2_ext_utils.h
@@ -178,7 +178,7 @@ enum v4l2_mpeg_video_h265_profile {
#define V4L2_H264_SPS_FLAG_FRAME_MBS_ONLY 0x10
#define V4L2_H264_SPS_FLAG_MB_ADAPTIVE_FRAME_FIELD 0x20
#define V4L2_H264_SPS_FLAG_DIRECT_8X8_INFERENCE 0x40
-struct v4l2_ctrl_h264_sps {
+/* struct v4l2_ctrl_h264_sps {
__u8 profile_idc;
__u8 constraint_set_flags;
__u8 level_idc;
@@ -197,7 +197,7 @@ struct v4l2_ctrl_h264_sps {
__u16 pic_width_in_mbs_minus1;
__u16 pic_height_in_map_units_minus1;
__u8 flags;
-};
+}; */
#define V4L2_H264_PPS_FLAG_ENTROPY_CODING_MODE 0x0001
#define V4L2_H264_PPS_FLAG_BOTTOM_FIELD_PIC_ORDER_IN_FRAME_PRESENT 0x0002
@@ -207,7 +207,7 @@ struct v4l2_ctrl_h264_sps {
#define V4L2_H264_PPS_FLAG_REDUNDANT_PIC_CNT_PRESENT 0x0020
#define V4L2_H264_PPS_FLAG_TRANSFORM_8X8_MODE 0x0040
#define V4L2_H264_PPS_FLAG_PIC_SCALING_MATRIX_PRESENT 0x0080
-struct v4l2_ctrl_h264_pps {
+/* struct v4l2_ctrl_h264_pps {
__u8 pic_parameter_set_id;
__u8 seq_parameter_set_id;
__u8 num_slice_groups_minus1;
@@ -219,19 +219,19 @@ struct v4l2_ctrl_h264_pps {
__s8 chroma_qp_index_offset;
__s8 second_chroma_qp_index_offset;
__u8 flags;
-};
+}; */
-struct v4l2_ctrl_h264_scaling_matrix {
+/* struct v4l2_ctrl_h264_scaling_matrix {
__u8 scaling_list_4x4[6][16];
__u8 scaling_list_8x8[6][64];
-};
+}; */
-struct v4l2_h264_weight_factors {
+/* struct v4l2_h264_weight_factors {
__s8 luma_weight[32];
__s8 luma_offset[32];
__s8 chroma_weight[32][2];
__s8 chroma_offset[32][2];
-};
+}; */
struct v4l2_h264_pred_weight_table {
__u8 luma_log2_weight_denom;
@@ -289,15 +289,15 @@ struct v4l2_ctrl_h264_slice_param {
If not set, this entry is unused for reference. */
#define V4L2_H264_DPB_ENTRY_FLAG_ACTIVE 0x01
#define V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM 0x02
-struct v4l2_h264_dpb_entry {
- __u32 buf_index; /**< v4l2_buffer index. */
- __u16 frame_num;
- __u16 pic_num;
+/* struct v4l2_h264_dpb_entry { */
+/* __u32 buf_index; /**< v4l2_buffer index. */
+/* __u16 frame_num;
+ __u16 pic_num; */
/** @note `v4l2_buffer.field` specifies this field. */
- __s32 top_field_order_cnt;
- __s32 bottom_field_order_cnt;
- __u8 flags; /* V4L2_H264_DPB_ENTRY_FLAG_* */
-};
+/* __s32 top_field_order_cnt;
+ __s32 bottom_field_order_cnt; */
+/* __u8 flags; /* V4L2_H264_DPB_ENTRY_FLAG_* */
+/* }; */
struct v4l2_ctrl_h264_decode_param {
__u32 num_slices;
--
2.25.1

View File

@ -0,0 +1,68 @@
From b2f78477cf1cca514a91a4a5ecd6f93fee289f2a Mon Sep 17 00:00:00 2001
From: Azkali Manad <a.ffcc7@gmail.com>
Date: Wed, 25 Jan 2023 03:32:12 +0100
Subject: [PATCH 24/39] codecs: nvv4l2: More API related changes
decoder: add internal.h header needed for ff_get_buffer
encoder: Rename AVCodecDefault to FFCodecDefault
*: use callback defines for encode/decode struct members
---
libavcodec/nvv4l2_dec.c | 3 ++-
libavcodec/nvv4l2_enc.c | 6 +++---
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/libavcodec/nvv4l2_dec.c b/libavcodec/nvv4l2_dec.c
index b56d35cf82..26e7363823 100644
--- a/libavcodec/nvv4l2_dec.c
+++ b/libavcodec/nvv4l2_dec.c
@@ -30,6 +30,7 @@
#include <fcntl.h>
#include <errno.h>
#include "codec_internal.h"
+#include "internal.h"
#include "libavutil/log.h"
#include "nvv4l2.h"
@@ -1211,7 +1212,7 @@ nvv4l2dec_decode(AVCodecContext *avctx, void *data, int *got_frame,
.priv_data_size = sizeof(nvv4l2DecodeContext), \
.init = nvv4l2dec_init, \
.close = nvv4l2dec_close, \
- .decode = nvv4l2dec_decode, \
+ FF_CODEC_DECODE_CB(nvv4l2dec_decode) \
.flush = nvv4l2dec_flush, \
.p.priv_class = &nvv4l2_##NAME##_dec_class, \
.p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HARDWARE | \
diff --git a/libavcodec/nvv4l2_enc.c b/libavcodec/nvv4l2_enc.c
index fad54868e3..7f1aad1b32 100644
--- a/libavcodec/nvv4l2_enc.c
+++ b/libavcodec/nvv4l2_enc.c
@@ -1265,7 +1265,7 @@ nvv4l2enc_encode(AVCodecContext *avctx, AVPacket *pkt,
if (nvv4l2_encoder_get_packet(avctx, ctx, &packet))
return 0;
- ff_alloc_packet2(avctx, pkt, packet.payload_size, packet.payload_size);
+ ff_alloc_packet(avctx, pkt, packet.payload_size, packet.payload_size);
memcpy(pkt->data, packet.payload, packet.payload_size);
pkt->dts = pkt->pts = packet.pts;
@@ -1286,7 +1286,7 @@ static av_cold int nvv4l2enc_close(AVCodecContext *avctx)
return 0;
}
-static const AVCodecDefault defaults[] = {
+static const FFCodecDefault defaults[] = {
{ "b", "5M" },
{ "qmin", "-1" },
{ "qmax", "-1" },
@@ -1463,7 +1463,7 @@ static const AVOption options_hevc[] = {
.priv_data_size = sizeof(nvv4l2EncodeContext), \
.init = nvv4l2enc_init, \
.close = nvv4l2enc_close, \
- .encode2 = nvv4l2enc_encode, \
+ FF_CODEC_ENCODE_CB(nvv4l2enc_encode), \
.p.priv_class = &nvv4l2_##NAME##_enc_class, \
.p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HARDWARE, \
.defaults = defaults, \
--
2.25.1

View File

@ -0,0 +1,25 @@
From 157e6cffa1464b66809d32b5d511f62882068dcd Mon Sep 17 00:00:00 2001
From: Azkali Manad <a.ffcc7@gmail.com>
Date: Wed, 25 Jan 2023 03:42:59 +0100
Subject: [PATCH 25/39] codecs: nvv4l2: add encode.h header needed for
ff_alloc_packet
---
libavcodec/nvv4l2_enc.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/libavcodec/nvv4l2_enc.c b/libavcodec/nvv4l2_enc.c
index 7f1aad1b32..6c3d276f31 100644
--- a/libavcodec/nvv4l2_enc.c
+++ b/libavcodec/nvv4l2_enc.c
@@ -29,6 +29,7 @@
#include <fcntl.h>
#include <errno.h>
#include "codec_internal.h"
+#include "encode.h"
#include "libavutil/imgutils.h"
#include "libavutil/log.h"
#include "libavutil/opt.h"
--
2.25.1

View File

@ -0,0 +1,25 @@
From c1447a426afa49ed23384f2b135ea9748c98d568 Mon Sep 17 00:00:00 2001
From: Azkali Manad <a.ffcc7@gmail.com>
Date: Wed, 25 Jan 2023 03:45:50 +0100
Subject: [PATCH 26/39] codecs: nvv4l2: fix missing comma in FFCodec struct
---
libavcodec/nvv4l2_dec.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libavcodec/nvv4l2_dec.c b/libavcodec/nvv4l2_dec.c
index 26e7363823..fe54883522 100644
--- a/libavcodec/nvv4l2_dec.c
+++ b/libavcodec/nvv4l2_dec.c
@@ -1212,7 +1212,7 @@ nvv4l2dec_decode(AVCodecContext *avctx, void *data, int *got_frame,
.priv_data_size = sizeof(nvv4l2DecodeContext), \
.init = nvv4l2dec_init, \
.close = nvv4l2dec_close, \
- FF_CODEC_DECODE_CB(nvv4l2dec_decode) \
+ FF_CODEC_DECODE_CB(nvv4l2dec_decode), \
.flush = nvv4l2dec_flush, \
.p.priv_class = &nvv4l2_##NAME##_dec_class, \
.p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HARDWARE | \
--
2.25.1

View File

@ -0,0 +1,26 @@
From cd758dad831c7f7f115b0fcc8646e241d338c800 Mon Sep 17 00:00:00 2001
From: Azkali Manad <a.ffcc7@gmail.com>
Date: Wed, 25 Jan 2023 03:52:47 +0100
Subject: [PATCH 27/39] codecs: nvv4l2: remove second size argument as it is
unneeded
---
libavcodec/nvv4l2_enc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libavcodec/nvv4l2_enc.c b/libavcodec/nvv4l2_enc.c
index 6c3d276f31..39a179b255 100644
--- a/libavcodec/nvv4l2_enc.c
+++ b/libavcodec/nvv4l2_enc.c
@@ -1266,7 +1266,7 @@ nvv4l2enc_encode(AVCodecContext *avctx, AVPacket *pkt,
if (nvv4l2_encoder_get_packet(avctx, ctx, &packet))
return 0;
- ff_alloc_packet(avctx, pkt, packet.payload_size, packet.payload_size);
+ ff_alloc_packet(avctx, pkt, packet.payload_size);
memcpy(pkt->data, packet.payload, packet.payload_size);
pkt->dts = pkt->pts = packet.pts;
--
2.25.1

View File

@ -0,0 +1,56 @@
From 1340217cbcc40418337225ca12d1d0f5dd82e682 Mon Sep 17 00:00:00 2001
From: Azkali <a.ffcc7@gmail.com>
Date: Thu, 26 Jan 2023 03:44:07 +0100
Subject: [PATCH 28/39] codecs: nvv4l2: undo struct commenting due to
OpenBuildServic weirdness
---
libavcodec/nvv4l2_ext_utils.h | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/libavcodec/nvv4l2_ext_utils.h b/libavcodec/nvv4l2_ext_utils.h
index 04a2ee1c79..4fb66583de 100644
--- a/libavcodec/nvv4l2_ext_utils.h
+++ b/libavcodec/nvv4l2_ext_utils.h
@@ -226,12 +226,12 @@ enum v4l2_mpeg_video_h265_profile {
__u8 scaling_list_8x8[6][64];
}; */
-/* struct v4l2_h264_weight_factors {
+struct v4l2_h264_weight_factors {
__s8 luma_weight[32];
__s8 luma_offset[32];
__s8 chroma_weight[32][2];
__s8 chroma_offset[32][2];
-}; */
+};
struct v4l2_h264_pred_weight_table {
__u8 luma_log2_weight_denom;
@@ -289,15 +289,15 @@ struct v4l2_ctrl_h264_slice_param {
If not set, this entry is unused for reference. */
#define V4L2_H264_DPB_ENTRY_FLAG_ACTIVE 0x01
#define V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM 0x02
-/* struct v4l2_h264_dpb_entry { */
-/* __u32 buf_index; /**< v4l2_buffer index. */
-/* __u16 frame_num;
- __u16 pic_num; */
+struct v4l2_h264_dpb_entry {
+ __u32 buf_index; /**< v4l2_buffer index. */
+ __u16 frame_num;
+ __u16 pic_num;
/** @note `v4l2_buffer.field` specifies this field. */
-/* __s32 top_field_order_cnt;
- __s32 bottom_field_order_cnt; */
-/* __u8 flags; /* V4L2_H264_DPB_ENTRY_FLAG_* */
-/* }; */
+ __s32 top_field_order_cnt;
+ __s32 bottom_field_order_cnt;
+ __u8 flags; /* V4L2_H264_DPB_ENTRY_FLAG_* */
+};
struct v4l2_ctrl_h264_decode_param {
__u32 num_slices;
--
2.25.1

View File

@ -0,0 +1,222 @@
From a3ee3863be6268abaf331af6a12892feeb8797c6 Mon Sep 17 00:00:00 2001
From: CTCaer <ctcaer@gmail.com>
Date: Sun, 2 Jul 2023 03:18:28 +0000
Subject: [PATCH 29/39] fftools: improve nvv4l2 enforcing Now non-supported
pixel formats are properly handled. Additionally, all edge cases are handled
even if the codec is forced by user.
---
fftools/ffmpeg_demux.c | 92 ++++++++++++++++++++++++++++++------------
fftools/ffplay.c | 74 +++++++++++++++++++++++++--------
2 files changed, 124 insertions(+), 42 deletions(-)
diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index 938ec09e3d..3b58c18f3d 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -500,40 +500,80 @@ static const AVCodec *choose_decoder(const OptionsContext *o, AVFormatContext *s
{
char *codec_name = NULL;
+#if CONFIG_NVV4L2
+ int nvv4l2_pix_fmt_ok;
+#endif
MATCH_PER_STREAM_OPT(codec_names, str, codec_name, s, st);
- if (codec_name) {
- const AVCodec *codec = find_codec_or_die(NULL, codec_name, st->codecpar->codec_type, 0);
- st->codecpar->codec_id = codec->id;
- if (recast_media && st->codecpar->codec_type != codec->type)
- st->codecpar->codec_type = codec->type;
- return codec;
- } else {
- if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
- hwaccel_id == HWACCEL_GENERIC &&
- hwaccel_device_type != AV_HWDEVICE_TYPE_NONE) {
- const AVCodec *c;
- void *i = NULL;
-
- while ((c = av_codec_iterate(&i))) {
- const AVCodecHWConfig *config;
- if (c->id != st->codecpar->codec_id ||
- !av_codec_is_decoder(c))
- continue;
+#if CONFIG_NVV4L2
+ nvv4l2_pix_fmt_ok = st->codecpar->format == AV_PIX_FMT_NONE ||
+ st->codecpar->format == AV_PIX_FMT_NV12 ||
+ st->codecpar->format == AV_PIX_FMT_YUV420P;
- for (int j = 0; config = avcodec_get_hw_config(c, j); j++) {
- if (config->device_type == hwaccel_device_type) {
- av_log(NULL, AV_LOG_VERBOSE, "Selecting decoder '%s' because of requested hwaccel method %s\n",
- c->name, av_hwdevice_get_type_name(hwaccel_device_type));
- return c;
- }
- }
- }
+ /* Force software decoding if codec name not defined and pixel format not supported. */
+ if (!codec_name && !nvv4l2_pix_fmt_ok) {
+ switch (st->codecpar->codec_id) {
+ case AV_CODEC_ID_H264:
+ codec_name = (char *)"h264";
+ break;
+ case AV_CODEC_ID_HEVC:
+ codec_name = (char *)"hevc";
+ break;
+ case AV_CODEC_ID_MPEG2VIDEO:
+ codec_name = (char *)"mpeg2video";
+ break;
+ case AV_CODEC_ID_MPEG4:
+ codec_name = (char *)"mpeg4";
+ break;
+ case AV_CODEC_ID_VP8:
+ codec_name = (char *)"vp8";
+ break;
+ case AV_CODEC_ID_VP9:
+ codec_name = (char *)"vp9";
+ break;
}
+ }
+#endif
+ if (!codec_name)
return avcodec_find_decoder(st->codecpar->codec_id);
+
+#if CONFIG_NVV4L2
+ if (nvv4l2_pix_fmt_ok) {
+ /* Force hardware decoding if pixel format supported. */
+ if (strcmp(codec_name, "h264") == 0)
+ return avcodec_find_decoder(st->codecpar->codec_id);
+ else if (strcmp(codec_name, "hevc") == 0)
+ return avcodec_find_decoder(st->codecpar->codec_id);
+ else if (strcmp(codec_name, "mpeg2video") == 0)
+ return avcodec_find_decoder(st->codecpar->codec_id);
+ else if (strcmp(codec_name, "mpeg4") == 0)
+ return avcodec_find_decoder(st->codecpar->codec_id);
+ else if (strcmp(codec_name, "vp8") == 0)
+ return avcodec_find_decoder(st->codecpar->codec_id);
+ else if (strcmp(codec_name, "vp9") == 0)
+ return avcodec_find_decoder(st->codecpar->codec_id);
+ } else {
+ /* Force software decoding if pixel format not supported. */
+ if (strcmp(codec_name, "h264_nvv4l2") == 0)
+ codec_name = (char *)"h264";
+ else if (strcmp(codec_name, "hevc_nvv4l2") == 0)
+ codec_name = (char *)"hevc";
+ else if (strcmp(codec_name, "mpeg2video_nvv4l2") == 0)
+ codec_name = (char *)"mpeg2video";
+ else if (strcmp(codec_name, "mpeg4_nvv4l2") == 0)
+ codec_name = (char *)"mpeg4";
+ else if (strcmp(codec_name, "vp8_nvv4l2") == 0)
+ codec_name = (char *)"vp8";
+ else if (strcmp(codec_name, "vp9_nvv4l2") == 0)
+ codec_name = (char *)"vp9";
}
+#endif
+
+ const AVCodec *codec = find_codec_or_die(codec_name, st->codecpar->codec_type, 0);
+ st->codecpar->codec_id = codec->id;
+ return codec;
}
static int guess_input_channel_layout(InputStream *ist)
diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index 86f8425a15..a02f2a06a7 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -2570,6 +2570,9 @@ static int stream_component_open(VideoState *is, int stream_index)
AVChannelLayout ch_layout = { 0 };
int ret = 0;
int stream_lowres = lowres;
+#if CONFIG_NVV4L2
+ int nvv4l2_pix_fmt_ok;
+#endif
if (stream_index < 0 || stream_index >= ic->nb_streams)
return -1;
@@ -2593,26 +2596,65 @@ static int stream_component_open(VideoState *is, int stream_index)
#if CONFIG_NVV4L2
/* Reset requested decoder in order to enforce NVV4L2 if possible. */
+ nvv4l2_pix_fmt_ok = avctx->pix_fmt == AV_PIX_FMT_NONE ||
+ avctx->pix_fmt == AV_PIX_FMT_NV12 ||
+ avctx->pix_fmt == AV_PIX_FMT_YUV420P;
+
if (avctx->codec_type == AVMEDIA_TYPE_VIDEO && forced_codec_name) {
- if (strcmp(forced_codec_name, "h264") == 0)
- forced_codec_name = NULL;
- else if (strcmp(forced_codec_name, "hevc") == 0)
- forced_codec_name = NULL;
- else if (strcmp(forced_codec_name, "mpeg2video") == 0)
- forced_codec_name = NULL;
- else if (strcmp(forced_codec_name, "mpeg4") == 0)
- forced_codec_name = NULL;
- else if (strcmp(forced_codec_name, "vp8") == 0)
- forced_codec_name = NULL;
- else if (strcmp(forced_codec_name, "vp9") == 0 &&
- avctx->pix_fmt != AV_PIX_FMT_YUV420P10) {
- forced_codec_name = NULL;
+ if (nvv4l2_pix_fmt_ok) {
+ /* Force hardware decoding if pixel format supported. */
+ if (strcmp(forced_codec_name, "h264") == 0)
+ forced_codec_name = NULL;
+ else if (strcmp(forced_codec_name, "hevc") == 0)
+ forced_codec_name = NULL;
+ else if (strcmp(forced_codec_name, "mpeg2video") == 0)
+ forced_codec_name = NULL;
+ else if (strcmp(forced_codec_name, "mpeg4") == 0)
+ forced_codec_name = NULL;
+ else if (strcmp(forced_codec_name, "vp8") == 0)
+ forced_codec_name = NULL;
+ else if (strcmp(forced_codec_name, "vp9") == 0)
+ forced_codec_name = NULL;
+ } else {
+ /* Force software decoding if pixel format not supported. */
+ if (strcmp(forced_codec_name, "h264_nvv4l2") == 0)
+ forced_codec_name = (char *)"h264";
+ else if (strcmp(forced_codec_name, "hevc_nvv4l2") == 0)
+ forced_codec_name = (char *)"hevc";
+ else if (strcmp(forced_codec_name, "mpeg2video_nvv4l2") == 0)
+ forced_codec_name = (char *)"mpeg2video";
+ else if (strcmp(forced_codec_name, "mpeg4_nvv4l2") == 0)
+ forced_codec_name = (char *)"mpeg4";
+ else if (strcmp(forced_codec_name, "vp8_nvv4l2") == 0)
+ forced_codec_name = (char *)"vp8";
+ else if (strcmp(forced_codec_name, "vp9_nvv4l2") == 0)
+ forced_codec_name = (char *)"vp9";
}
}
- /* NVV4L2 does not support VP9 with YUV420P10. */
- if (!forced_codec_name && avctx->pix_fmt == AV_PIX_FMT_YUV420P10)
- forced_codec_name = "vp9";
+ /* Force software decoding if codec name not defined and pixel format not supported. */
+ if (avctx->codec_type == AVMEDIA_TYPE_VIDEO && !forced_codec_name && !nvv4l2_pix_fmt_ok) {
+ switch (avctx->codec_id) {
+ case AV_CODEC_ID_H264:
+ forced_codec_name = (char *)"h264";
+ break;
+ case AV_CODEC_ID_HEVC:
+ forced_codec_name = (char *)"hevc";
+ break;
+ case AV_CODEC_ID_MPEG2VIDEO:
+ forced_codec_name = (char *)"mpeg2video";
+ break;
+ case AV_CODEC_ID_MPEG4:
+ forced_codec_name = (char *)"mpeg4";
+ break;
+ case AV_CODEC_ID_VP8:
+ forced_codec_name = (char *)"vp8";
+ break;
+ case AV_CODEC_ID_VP9:
+ forced_codec_name = (char *)"vp9";
+ break;
+ }
+ }
#endif
if (forced_codec_name)
--
2.25.1

View File

@ -0,0 +1,41 @@
From 8014b28095f1b3d2559387b7b8aca93b034561cf Mon Sep 17 00:00:00 2001
From: CTCaer <ctcaer@gmail.com>
Date: Sun, 2 Jul 2023 03:23:34 +0000
Subject: [PATCH 30/39] nvv4l2: add yuv420p10 support NVENC supports yuv420p10
as p010.
---
libavcodec/nvv4l2_enc.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/libavcodec/nvv4l2_enc.c b/libavcodec/nvv4l2_enc.c
index 39a179b255..b979c93051 100644
--- a/libavcodec/nvv4l2_enc.c
+++ b/libavcodec/nvv4l2_enc.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021-2022, CTCaer <ctcaer@gmail.com>
+ * Copyright (c) 2021-2023, CTCaer <ctcaer@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -1130,6 +1130,8 @@ static int nvv4l2enc_init(AVCodecContext *avctx)
case AV_PIX_FMT_NV12:
pix_fmt = V4L2_PIX_FMT_NV12M;
break;
+ case AV_PIX_FMT_YUV420P10:
+ avctx->pix_fmt = AV_PIX_FMT_P010;
case AV_PIX_FMT_P010:
pix_fmt = V4L2_PIX_FMT_P010M;
break;
@@ -1473,6 +1475,7 @@ static const AVOption options_hevc[] = {
AV_PIX_FMT_YUV444P, \
AV_PIX_FMT_NV12, \
AV_PIX_FMT_P010, \
+ AV_PIX_FMT_YUV420P10, \
AV_PIX_FMT_NONE }, \
};
--
2.25.1

View File

@ -0,0 +1,127 @@
From ded4a192fa894768db5d1ab0e90256f28a87b834 Mon Sep 17 00:00:00 2001
From: CTCaer <ctcaer@gmail.com>
Date: Sun, 2 Jul 2023 03:49:48 +0000
Subject: [PATCH 31/39] nvv4l2: handle unsupported pixel formats NVDEC only
supports YUV420 and NV12 formats.
If a consumer starting nvv4l2 decoder with unsupported pixel format force
software decoding.
If consumer does not probe info of the media, the pixel format will be empty.
If the actual pixel format is not supported it will result in no image.
Since the normal procedure of using libavcodec is to just open a codec via id,
without passing extra info or data, except if on purpose, there's no way to
mitigate that issue in a non-invasive way.
---
libavcodec/avcodec.c | 2 --
libavcodec/nvv4l2_dec.c | 58 ++++++++++++++++++++++++++++++++++++++---
2 files changed, 54 insertions(+), 6 deletions(-)
diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c
index fb1362290f..773d0457b3 100644
--- a/libavcodec/avcodec.c
+++ b/libavcodec/avcodec.c
@@ -355,8 +355,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
goto free_and_end;
}
}
- if (codec->priv_class)
- av_assert0(*(const AVClass **)avctx->priv_data == codec->priv_class);
end:
diff --git a/libavcodec/nvv4l2_dec.c b/libavcodec/nvv4l2_dec.c
index fe54883522..0b91cf0eba 100644
--- a/libavcodec/nvv4l2_dec.c
+++ b/libavcodec/nvv4l2_dec.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021-2022, CTCaer <ctcaer@gmail.com>
+ * Copyright (c) 2021-2023, CTCaer <ctcaer@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -31,10 +31,18 @@
#include <errno.h>
#include "codec_internal.h"
#include "internal.h"
+#include "decode.h"
+#include "thread.h"
#include "libavutil/log.h"
+#include "libavutil/pixdesc.h"
+#include "libavutil/opt.h"
#include "nvv4l2.h"
+extern AVCodec ff_h264_decoder;
+extern AVCodec ff_hevc_decoder;
+extern AVCodec ff_vp9_decoder;
+
/*
** Output plane format support:
** S264 (H264 Encoded Slice bitstream)
@@ -978,6 +986,48 @@ static NvCodingType map_avcodec_id(enum AVCodecID id)
return NvVideoCodec_UNDEFINED;
}
+static int nvv4l2dec_codec_fallback(AVCodecContext *avctx)
+{
+ av_log(avctx, AV_LOG_WARNING, "Falling back to software decoding.\n");
+
+ switch (avctx->codec_id) {
+ case AV_CODEC_ID_H264:
+ avctx->codec = &ff_h264_decoder;
+ break;
+ case AV_CODEC_ID_HEVC:
+ avctx->codec = &ff_hevc_decoder;
+ break;
+ case AV_CODEC_ID_VP9:
+ avctx->codec = &ff_vp9_decoder;
+ break;
+ default:
+ av_log(avctx, AV_LOG_ERROR, "Unsupported codec fallback!\n");
+ return AVERROR_BUG;
+ }
+
+ av_opt_free(avctx->priv_data);
+
+ if (avctx->codec->priv_data_size > 0) {
+ avctx->priv_data = av_mallocz(avctx->codec->priv_data_size);
+ if (!avctx->priv_data)
+ return AVERROR(ENOMEM);
+ }
+
+ if (HAVE_THREADS
+ && !(avctx->internal->frame_thread_encoder && (avctx->active_thread_type&FF_THREAD_FRAME))) {
+ ff_thread_init(avctx);
+ }
+ if (!HAVE_THREADS && !(avctx->codec->caps_internal & FF_CODEC_CAP_AUTO_THREADS))
+ avctx->thread_count = 1;
+
+ if (avctx->codec->priv_class) {
+ *(const AVClass **)avctx->priv_data = avctx->codec->priv_class;
+ av_opt_set_defaults(avctx->priv_data);
+ }
+
+ return avctx->codec->init(avctx);
+}
+
static int nvv4l2dec_init(AVCodecContext *avctx)
{
nvv4l2DecodeContext *nvv4l2_ctx = avctx->priv_data;
@@ -1000,9 +1050,9 @@ static int nvv4l2dec_init(AVCodecContext *avctx)
pix_fmt = V4L2_PIX_FMT_NV12M;
break;
default:
- av_log(avctx, AV_LOG_ERROR, "Unsupported pixel format %d!\n",
- avctx->pix_fmt);
- return AVERROR_BUG;
+ av_log(avctx, AV_LOG_WARNING, "Unsupported pixel format %s!\n",
+ av_get_pix_fmt_name(avctx->pix_fmt));
+ return nvv4l2dec_codec_fallback(avctx);
}
nvv4l2_ctx->ctx = nvv4l2_create_decoder(avctx, nv_codec_type, pix_fmt);
--
2.25.1

View File

@ -0,0 +1,92 @@
From 9e860a0aeab0b955e627de763e9494457942222d Mon Sep 17 00:00:00 2001
From: CTCaer <ctcaer@gmail.com>
Date: Mon, 3 Jul 2023 14:19:46 +0000
Subject: [PATCH 32/39] nvv4l2: allow 10-bit HEVC The only hw support for
10-bit on NVDEC 2nd/3rd gen is on HEVC. H264 does not support it on main
spec, so as per previous changes it fallbacks to software decoding. VP8 codec
does not support it at all. The only out of spec non-support on hw decoding
is on VP9.
---
fftools/ffmpeg_demux.c | 4 ++++
fftools/ffplay.c | 4 ++++
libavcodec/nvv4l2_dec.c | 9 ++++++++-
libavcodec/nvv4l2_ext_utils.h | 6 ++++++
4 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index 3b58c18f3d..f791c3a898 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -510,6 +510,10 @@ static const AVCodec *choose_decoder(const OptionsContext *o, AVFormatContext *s
nvv4l2_pix_fmt_ok = st->codecpar->format == AV_PIX_FMT_NONE ||
st->codecpar->format == AV_PIX_FMT_NV12 ||
st->codecpar->format == AV_PIX_FMT_YUV420P;
+ if (st->codecpar->codec_id == AV_CODEC_ID_HEVC)
+ nvv4l2_pix_fmt_ok = st->codecpar->format == AV_PIX_FMT_YUV420P10LE ||
+ st->codecpar->format == AV_PIX_FMT_P010 ||
+ nvv4l2_pix_fmt_ok;
/* Force software decoding if codec name not defined and pixel format not supported. */
if (!codec_name && !nvv4l2_pix_fmt_ok) {
diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index a02f2a06a7..bbd5761115 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -2599,6 +2599,10 @@ static int stream_component_open(VideoState *is, int stream_index)
nvv4l2_pix_fmt_ok = avctx->pix_fmt == AV_PIX_FMT_NONE ||
avctx->pix_fmt == AV_PIX_FMT_NV12 ||
avctx->pix_fmt == AV_PIX_FMT_YUV420P;
+ if (avctx->codec_id == AV_CODEC_ID_HEVC)
+ nvv4l2_pix_fmt_ok = avctx->pix_fmt == AV_PIX_FMT_YUV420P10LE ||
+ avctx->pix_fmt == AV_PIX_FMT_P010 ||
+ nvv4l2_pix_fmt_ok;
if (avctx->codec_type == AVMEDIA_TYPE_VIDEO && forced_codec_name) {
if (nvv4l2_pix_fmt_ok) {
diff --git a/libavcodec/nvv4l2_dec.c b/libavcodec/nvv4l2_dec.c
index 0b91cf0eba..79116ec858 100644
--- a/libavcodec/nvv4l2_dec.c
+++ b/libavcodec/nvv4l2_dec.c
@@ -1042,13 +1042,20 @@ static int nvv4l2dec_init(AVCodecContext *avctx)
switch (avctx->pix_fmt) {
case AV_PIX_FMT_NONE:
- avctx->pix_fmt = AV_PIX_FMT_YUV420P;
case AV_PIX_FMT_YUV420P:
+ avctx->pix_fmt = AV_PIX_FMT_YUV420P;
pix_fmt = V4L2_PIX_FMT_YUV420M;
break;
case AV_PIX_FMT_NV12:
pix_fmt = V4L2_PIX_FMT_NV12M;
break;
+ case AV_PIX_FMT_YUV420P10LE:
+ case AV_PIX_FMT_P010:
+ if (avctx->codec_id == AV_CODEC_ID_HEVC) {
+ avctx->pix_fmt = AV_PIX_FMT_YUV420P;
+ pix_fmt = V4L2_PIX_FMT_YUV420M;
+ break;
+ }
default:
av_log(avctx, AV_LOG_WARNING, "Unsupported pixel format %s!\n",
av_get_pix_fmt_name(avctx->pix_fmt));
diff --git a/libavcodec/nvv4l2_ext_utils.h b/libavcodec/nvv4l2_ext_utils.h
index 4fb66583de..142b429336 100644
--- a/libavcodec/nvv4l2_ext_utils.h
+++ b/libavcodec/nvv4l2_ext_utils.h
@@ -2144,6 +2144,12 @@ typedef enum
NvBufferColorFormat_ARGB32 = 18, /* BSP 32.5.0 and up: 19 */
/** BT.601 colorspace - Y/CbCr 4:2:0 10-bit multi-planar. */
NvBufferColorFormat_NV12_10LE = 19, /* BSP 32.5.0 and up: 20 */
+ /** BT.709 colorspace - Y/CbCr 4:2:0 10-bit multi-planar. */
+ NvBufferColorFormat_NV12_10LE_709 = 20, /* BSP 32.5.0 and up: 21 */
+ /** BT.709_ER colorspace - Y/CbCr 4:2:0 10-bit multi-planar. */
+ NvBufferColorFormat_NV12_10LE_709_ER = 21, /* BSP 32.5.0 and up: 22 */
+ /** BT.2020 colorspace - Y/CbCr 4:2:0 10-bit multi-planar. */
+ NvBufferColorFormat_NV12_10LE_2020 = 22, /* BSP 32.5.0 and up: 23 */
/** BT.709 colorspace - Y/CbCr 4:2:0 multi-planar. */
NvBufferColorFormat_NV12_709 = 29, /* BSP 32.5.0 and up: 30 */
/** BT.709 colorspace - Y/CbCr ER 4:2:0 multi-planar. */
--
2.25.1

View File

@ -0,0 +1,29 @@
From b4c1473d7a0db6efb31e5d5f5c7b483736ac593a Mon Sep 17 00:00:00 2001
From: theofficialgman <28281419+theofficialgman@users.noreply.github.com>
Date: Thu, 18 Jan 2024 17:48:52 -0500
Subject: [PATCH 33/39] codecs: nvv4l2: more rename AVCodec to fit API renames
---
libavcodec/nvv4l2_dec.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/libavcodec/nvv4l2_dec.c b/libavcodec/nvv4l2_dec.c
index 79116ec858..a92b191b24 100644
--- a/libavcodec/nvv4l2_dec.c
+++ b/libavcodec/nvv4l2_dec.c
@@ -39,9 +39,9 @@
#include "nvv4l2.h"
-extern AVCodec ff_h264_decoder;
-extern AVCodec ff_hevc_decoder;
-extern AVCodec ff_vp9_decoder;
+extern const FFCodec ff_h264_decoder;
+extern const FFCodec ff_hevc_decoder;
+extern const FFCodec ff_vp9_decoder;
/*
** Output plane format support:
--
2.25.1

View File

@ -0,0 +1,58 @@
From 08ff68f2fb3175157a46a8dfb880f58870ac6b9e Mon Sep 17 00:00:00 2001
From: theofficialgman <28281419+theofficialgman@users.noreply.github.com>
Date: Wed, 17 Jan 2024 22:17:55 -0500
Subject: [PATCH 34/39] codecs: nvv4l2: more API renames
---
libavcodec/nvv4l2_dec.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/libavcodec/nvv4l2_dec.c b/libavcodec/nvv4l2_dec.c
index a92b191b24..5ccea0830b 100644
--- a/libavcodec/nvv4l2_dec.c
+++ b/libavcodec/nvv4l2_dec.c
@@ -988,6 +988,8 @@ static NvCodingType map_avcodec_id(enum AVCodecID id)
static int nvv4l2dec_codec_fallback(AVCodecContext *avctx)
{
+ const FFCodec *codec2;
+
av_log(avctx, AV_LOG_WARNING, "Falling back to software decoding.\n");
switch (avctx->codec_id) {
@@ -1005,10 +1007,12 @@ static int nvv4l2dec_codec_fallback(AVCodecContext *avctx)
return AVERROR_BUG;
}
+ codec2 = ffcodec(avctx->codec);
+
av_opt_free(avctx->priv_data);
- if (avctx->codec->priv_data_size > 0) {
- avctx->priv_data = av_mallocz(avctx->codec->priv_data_size);
+ if (codec2->priv_data_size > 0) {
+ avctx->priv_data = av_mallocz(codec2->priv_data_size);
if (!avctx->priv_data)
return AVERROR(ENOMEM);
}
@@ -1017,7 +1021,7 @@ static int nvv4l2dec_codec_fallback(AVCodecContext *avctx)
&& !(avctx->internal->frame_thread_encoder && (avctx->active_thread_type&FF_THREAD_FRAME))) {
ff_thread_init(avctx);
}
- if (!HAVE_THREADS && !(avctx->codec->caps_internal & FF_CODEC_CAP_AUTO_THREADS))
+ if (!HAVE_THREADS && !(codec2->caps_internal & FF_CODEC_CAP_AUTO_THREADS))
avctx->thread_count = 1;
if (avctx->codec->priv_class) {
@@ -1025,7 +1029,7 @@ static int nvv4l2dec_codec_fallback(AVCodecContext *avctx)
av_opt_set_defaults(avctx->priv_data);
}
- return avctx->codec->init(avctx);
+ return codec2->init(avctx);
}
static int nvv4l2dec_init(AVCodecContext *avctx)
--
2.25.1

View File

@ -0,0 +1,82 @@
From e508318655d72876d29df374c19c7edcf3134997 Mon Sep 17 00:00:00 2001
From: theofficialgman <28281419+theofficialgman@users.noreply.github.com>
Date: Wed, 17 Jan 2024 23:45:11 -0500
Subject: [PATCH 35/39] codecs: nvv4l2: find_codec_or_die to find_codec API
rename and rework
---
fftools/ffmpeg_demux.c | 47 +++++++++++++++++++++++++++---------------
1 file changed, 30 insertions(+), 17 deletions(-)
diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index f791c3a898..17b5d63bf8 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -540,24 +540,33 @@ static const AVCodec *choose_decoder(const OptionsContext *o, AVFormatContext *s
}
#endif
- if (!codec_name)
- return avcodec_find_decoder(st->codecpar->codec_id);
+ if (!codec_name) {
+ *pcodec = avcodec_find_decoder(st->codecpar->codec_id);
+ return 0;
+ }
#if CONFIG_NVV4L2
if (nvv4l2_pix_fmt_ok) {
/* Force hardware decoding if pixel format supported. */
- if (strcmp(codec_name, "h264") == 0)
- return avcodec_find_decoder(st->codecpar->codec_id);
- else if (strcmp(codec_name, "hevc") == 0)
- return avcodec_find_decoder(st->codecpar->codec_id);
- else if (strcmp(codec_name, "mpeg2video") == 0)
- return avcodec_find_decoder(st->codecpar->codec_id);
- else if (strcmp(codec_name, "mpeg4") == 0)
- return avcodec_find_decoder(st->codecpar->codec_id);
- else if (strcmp(codec_name, "vp8") == 0)
- return avcodec_find_decoder(st->codecpar->codec_id);
- else if (strcmp(codec_name, "vp9") == 0)
- return avcodec_find_decoder(st->codecpar->codec_id);
+ if (strcmp(codec_name, "h264") == 0) {
+ *pcodec = avcodec_find_decoder(st->codecpar->codec_id);
+ return 0;
+ } else if (strcmp(codec_name, "hevc") == 0) {
+ *pcodec = avcodec_find_decoder(st->codecpar->codec_id);
+ return 0;
+ } else if (strcmp(codec_name, "mpeg2video") == 0) {
+ *pcodec = avcodec_find_decoder(st->codecpar->codec_id);
+ return 0;
+ } else if (strcmp(codec_name, "mpeg4") == 0) {
+ *pcodec = avcodec_find_decoder(st->codecpar->codec_id);
+ return 0;
+ } else if (strcmp(codec_name, "vp8") == 0) {
+ *pcodec = avcodec_find_decoder(st->codecpar->codec_id);
+ return 0;
+ } else if (strcmp(codec_name, "vp9") == 0) {
+ *pcodec = avcodec_find_decoder(st->codecpar->codec_id);
+ return 0;
+ }
} else {
/* Force software decoding if pixel format not supported. */
if (strcmp(codec_name, "h264_nvv4l2") == 0)
@@ -575,9 +584,13 @@ static const AVCodec *choose_decoder(const OptionsContext *o, AVFormatContext *s
}
#endif
- const AVCodec *codec = find_codec_or_die(codec_name, st->codecpar->codec_type, 0);
- st->codecpar->codec_id = codec->id;
- return codec;
+ int ret = find_codec(NULL, codec_name, st->codecpar->codec_type, 0, pcodec);
+ if (ret < 0)
+ return ret;
+ st->codecpar->codec_id = (*pcodec)->id;
+ if (recast_media && st->codecpar->codec_type != (*pcodec)->type)
+ st->codecpar->codec_type = (*pcodec)->type;
+ return 0;
}
static int guess_input_channel_layout(InputStream *ist)
--
2.25.1

View File

@ -0,0 +1,30 @@
From 8d78a510e496ea473ea7392b828e17165bb6b6ac Mon Sep 17 00:00:00 2001
From: theofficialgman <28281419+theofficialgman@users.noreply.github.com>
Date: Sun, 21 Jan 2024 02:01:10 -0500
Subject: [PATCH 36/39] codecs: nvv4l2: update for ABI rework
---
libavcodec/nvv4l2_dec.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/libavcodec/nvv4l2_dec.c b/libavcodec/nvv4l2_dec.c
index 5ccea0830b..27e06da1b5 100644
--- a/libavcodec/nvv4l2_dec.c
+++ b/libavcodec/nvv4l2_dec.c
@@ -1175,12 +1175,11 @@ static int nvv4l2dec_close(AVCodecContext *avctx)
}
static int
-nvv4l2dec_decode(AVCodecContext *avctx, void *data, int *got_frame,
+nvv4l2dec_decode(AVCodecContext *avctx, AVFrame *avframe, int *got_frame,
AVPacket *avpkt)
{
nvv4l2DecodeContext *nvv4l2_ctx = avctx->priv_data;
nvv4l2_ctx_t *ctx = nvv4l2_ctx->ctx;
- AVFrame *avframe = (AVFrame *)data;
NvFrame _nvframe = { 0 };
int processed_size = 0;
int buf_index = -1;
--
2.25.1

View File

@ -0,0 +1,31 @@
From a18c43b29c220fa020f9cac2522608b2b4cba954 Mon Sep 17 00:00:00 2001
From: azkali <a.ffcc7@gmail.com>
Date: Tue, 23 Jan 2024 18:28:29 +0100
Subject: [PATCH 37/39] Revert "codecs: nvv4l2: update for ABI rework"
This reverts commit 8d78a510e496ea473ea7392b828e17165bb6b6ac.
---
libavcodec/nvv4l2_dec.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libavcodec/nvv4l2_dec.c b/libavcodec/nvv4l2_dec.c
index 27e06da1b5..5ccea0830b 100644
--- a/libavcodec/nvv4l2_dec.c
+++ b/libavcodec/nvv4l2_dec.c
@@ -1175,11 +1175,12 @@ static int nvv4l2dec_close(AVCodecContext *avctx)
}
static int
-nvv4l2dec_decode(AVCodecContext *avctx, AVFrame *avframe, int *got_frame,
+nvv4l2dec_decode(AVCodecContext *avctx, void *data, int *got_frame,
AVPacket *avpkt)
{
nvv4l2DecodeContext *nvv4l2_ctx = avctx->priv_data;
nvv4l2_ctx_t *ctx = nvv4l2_ctx->ctx;
+ AVFrame *avframe = (AVFrame *)data;
NvFrame _nvframe = { 0 };
int processed_size = 0;
int buf_index = -1;
--
2.25.1

View File

@ -0,0 +1,83 @@
From 4279fc32ea8b6da4a36aaf0b616408ad1fe4dcea Mon Sep 17 00:00:00 2001
From: azkali <a.ffcc7@gmail.com>
Date: Tue, 23 Jan 2024 18:35:39 +0100
Subject: [PATCH 38/39] Revert "codecs: nvv4l2: find_codec_or_die to find_codec
API rename and rework"
This reverts commit e508318655d72876d29df374c19c7edcf3134997.
---
fftools/ffmpeg_demux.c | 47 +++++++++++++++---------------------------
1 file changed, 17 insertions(+), 30 deletions(-)
diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index 17b5d63bf8..f791c3a898 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -540,33 +540,24 @@ static const AVCodec *choose_decoder(const OptionsContext *o, AVFormatContext *s
}
#endif
- if (!codec_name) {
- *pcodec = avcodec_find_decoder(st->codecpar->codec_id);
- return 0;
- }
+ if (!codec_name)
+ return avcodec_find_decoder(st->codecpar->codec_id);
#if CONFIG_NVV4L2
if (nvv4l2_pix_fmt_ok) {
/* Force hardware decoding if pixel format supported. */
- if (strcmp(codec_name, "h264") == 0) {
- *pcodec = avcodec_find_decoder(st->codecpar->codec_id);
- return 0;
- } else if (strcmp(codec_name, "hevc") == 0) {
- *pcodec = avcodec_find_decoder(st->codecpar->codec_id);
- return 0;
- } else if (strcmp(codec_name, "mpeg2video") == 0) {
- *pcodec = avcodec_find_decoder(st->codecpar->codec_id);
- return 0;
- } else if (strcmp(codec_name, "mpeg4") == 0) {
- *pcodec = avcodec_find_decoder(st->codecpar->codec_id);
- return 0;
- } else if (strcmp(codec_name, "vp8") == 0) {
- *pcodec = avcodec_find_decoder(st->codecpar->codec_id);
- return 0;
- } else if (strcmp(codec_name, "vp9") == 0) {
- *pcodec = avcodec_find_decoder(st->codecpar->codec_id);
- return 0;
- }
+ if (strcmp(codec_name, "h264") == 0)
+ return avcodec_find_decoder(st->codecpar->codec_id);
+ else if (strcmp(codec_name, "hevc") == 0)
+ return avcodec_find_decoder(st->codecpar->codec_id);
+ else if (strcmp(codec_name, "mpeg2video") == 0)
+ return avcodec_find_decoder(st->codecpar->codec_id);
+ else if (strcmp(codec_name, "mpeg4") == 0)
+ return avcodec_find_decoder(st->codecpar->codec_id);
+ else if (strcmp(codec_name, "vp8") == 0)
+ return avcodec_find_decoder(st->codecpar->codec_id);
+ else if (strcmp(codec_name, "vp9") == 0)
+ return avcodec_find_decoder(st->codecpar->codec_id);
} else {
/* Force software decoding if pixel format not supported. */
if (strcmp(codec_name, "h264_nvv4l2") == 0)
@@ -584,13 +575,9 @@ static const AVCodec *choose_decoder(const OptionsContext *o, AVFormatContext *s
}
#endif
- int ret = find_codec(NULL, codec_name, st->codecpar->codec_type, 0, pcodec);
- if (ret < 0)
- return ret;
- st->codecpar->codec_id = (*pcodec)->id;
- if (recast_media && st->codecpar->codec_type != (*pcodec)->type)
- st->codecpar->codec_type = (*pcodec)->type;
- return 0;
+ const AVCodec *codec = find_codec_or_die(codec_name, st->codecpar->codec_type, 0);
+ st->codecpar->codec_id = codec->id;
+ return codec;
}
static int guess_input_channel_layout(InputStream *ist)
--
2.25.1

View File

@ -0,0 +1,25 @@
From a8e8a2151948790f9702802aa87b65bbf5049ac1 Mon Sep 17 00:00:00 2001
From: azkali <a.ffcc7@gmail.com>
Date: Tue, 23 Jan 2024 18:50:41 +0100
Subject: [PATCH 39/39] fftools/ffmpeg: set find_codec_or_die logctx to NULL
---
fftools/ffmpeg_demux.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index f791c3a898..975a9f5f17 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -575,7 +575,7 @@ static const AVCodec *choose_decoder(const OptionsContext *o, AVFormatContext *s
}
#endif
- const AVCodec *codec = find_codec_or_die(codec_name, st->codecpar->codec_type, 0);
+ const AVCodec *codec = find_codec_or_die(NULL, codec_name, st->codecpar->codec_type, 0);
st->codecpar->codec_id = codec->id;
return codec;
}
--
2.25.1

View File

@ -0,0 +1,43 @@
From 91e53cd8349f6a6a74ef7bc9498052467345cff4 Mon Sep 17 00:00:00 2001
From: CTCaer <ctcaer@gmail.com>
Date: Sat, 27 Jan 2024 00:34:28 +0000
Subject: [PATCH] nvv4l2: do not override key_frame Some apps are managing this
by replacing the ffmpeg get buffer function. Additionally, some badly coded
apps use that for actually starting outputting to screen or framebuffer, even
though the expected frames from the decoder are always full frames.
---
libavcodec/nvv4l2_dec.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/libavcodec/nvv4l2_dec.c b/libavcodec/nvv4l2_dec.c
index b2ac349201a..751f4379e89 100644
--- a/libavcodec/nvv4l2_dec.c
+++ b/libavcodec/nvv4l2_dec.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021-2023, CTCaer <ctcaer@gmail.com>
+ * Copyright (c) 2021-2024, CTCaer <ctcaer@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -1236,12 +1236,13 @@ nvv4l2dec_decode(AVCodecContext *avctx, void *data, int *got_frame,
if (_nvframe.pts != AV_NOPTS_VALUE) {
avframe->pts = _nvframe.pts;
} else {
- avframe->pts = _nvframe.pts;
+ /*! NOTE: Investigate if setting reordered_opaque to pts instead
+ * is better for no-pts streams compatibility.
+ */
+ avframe->pts = AV_NOPTS_VALUE;
avframe->reordered_opaque = _nvframe.user_pts;
}
- avframe->key_frame = 0;
-
avctx->coded_width = _nvframe.width;
avctx->coded_height = _nvframe.height;
avctx->width = _nvframe.width;
--
GitLab

View File

@ -70,7 +70,7 @@ post_makeinstall_target() {
-e "s|^#AutoEnable.*|AutoEnable=true|g" \
-e "s|^#JustWorksRepairing.*|JustWorksRepairing=always|g"
if [ "${DISTRO}" = "Lakka" ]; then
if [ "${DISTRO}" = "Lakka" ] || [ "${PROJECT}" = "L4T" -a "${DEVICE}" = "Switch" ]; then
sed -i $INSTALL/etc/bluetooth/main.conf \
-e "s|^#FastConnectable.*|FastConnectable=true|g" \
-e "s|^# Privacy =.*|Privacy = device|g"

View File

@ -2619,7 +2619,7 @@ CONFIG_REGULATOR_PWM=y
# CONFIG_REGULATOR_PMIC_OTP is not set
CONFIG_MEDIA_SUPPORT=y
CONFIG_STAGING_MEDIA=y
CONFIG_MEDIA_CEC=y
CONFIG_MEDIA_CEC_SUPPORT=y
#
# Multimedia core support

View File

@ -27,7 +27,7 @@ else
echo "Unknown distro, expect issues"
fi
ADDITIONAL_PACKAGES+=" switch-bsp libcec v4l-utils"
ADDITIONAL_PACKAGES+=" switch-bsp v4l-utils"
#Remove since we include driver in kernel now. Module Config/udev rules
#Included in switch-bsp package, to match version in kernel(0.9.5).

View File

@ -5,8 +5,6 @@ Requires=graphical.target
Wants=network-online.target
[Service]
User=LibreELEC
Group=LibreELEC
Environment=HOME=/storage DISPLAY=:0 PULSE_SERVER=127.0.0.1
EnvironmentFile=/usr/lib/kodi/kodi.conf
EnvironmentFile=-/run/libreelec/kodi.conf

View File

@ -1,10 +1,14 @@
PKG_NAME="switch-bsp"
PKG_VERSION="1.1"
PKG_VERSION="1.2"
PKG_LICENSE="GPL"
PKG_DEPENDS_TARGET="joycond rewritefs xdotool alsa-lib alsa-ucm-conf usb-gadget-scripts v4l-utils"
PKG_DEPENDS_TARGET="joycond rewritefs xdotool alsa-lib alsa-ucm-conf usb-gadget-scripts"
PKG_SECTION="virtual"
PKG_LONGDESC="LibreELEC Nintendo Switch Board Support"
if [ ! ${PROJECT} = "LibreELEC" ]; then
PKG_DEPENDS_TARGET="v4l-utils" # We use this for CEC in lakka, in libreELEC kodi handles that via libCEC.
fi
post_install() {
enable_service xorg-configure-switch.service
enable_service var-bluetoothconfig.mount

View File

@ -69,10 +69,12 @@ if [[ "$1" -eq 1 ]]; then LOOPS=5; fi
while [ "$i" -le "$LOOPS" ]; do
if grep -q 1 "/sys/class/switch/dp/state"; then DP_ENABLED=1; else DP_ENABLED=0; fi
# Prepare CEC info.
if [ -f /tmp/.CEC ]; then
if [[ "$DP_ENABLED" -eq 0 ]]; then cec-ctl -C
else cec-ctl -s -o NintendoSwitch --playback --active-source phys-addr="$(cec-ctl | sed -n 's/.*Physical Address.*: //p')"; fi
# Prepare CEC info. ignore if libreelec, kodi will handle this.
if [ "$(cat /etc/os-release | grep LibreELEC)" = "" ]; then
if [ -f /tmp/.CEC ]; then
if [[ "$DP_ENABLED" -eq 0 ]]; then cec-ctl -C
else cec-ctl -s -o NintendoSwitch --playback --active-source phys-addr="$(cec-ctl | sed -n 's/.*Physical Address.*: //p')"; fi
fi
fi
# Configure dock

View File

@ -0,0 +1,304 @@
From 0dbacebede1e4e44bf500f94d692fad05eb2c293 Mon Sep 17 00:00:00 2001
From: Hans Verkuil <hans.verkuil@cisco.com>
Date: Wed, 2 Nov 2016 08:25:28 -0200
Subject: [PATCH] [media] cec: move the CEC framework out of staging and to
media
The last open issues have been addressed, so it is time to move
this out of staging and into the mainline and to move the public
cec headers to include/uapi/linux.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
---
Documentation/media/Makefile | 2 +-
drivers/media/Kconfig | 16 ++++++++++++++++
drivers/media/Makefile | 4 ++++
drivers/{staging => }/media/cec/Makefile | 2 +-
drivers/{staging => }/media/cec/cec-adap.c | 0
drivers/{staging => }/media/cec/cec-api.c | 0
drivers/{staging => }/media/cec/cec-core.c | 0
drivers/{staging => }/media/cec/cec-priv.h | 0
drivers/media/i2c/Kconfig | 6 +++---
drivers/media/platform/vivid/Kconfig | 2 +-
drivers/staging/media/Kconfig | 2 --
drivers/staging/media/Makefile | 1 -
drivers/staging/media/cec/Kconfig | 12 ------------
drivers/staging/media/cec/TODO | 9 ---------
drivers/staging/media/pulse8-cec/Kconfig | 2 +-
drivers/staging/media/s5p-cec/Kconfig | 2 +-
drivers/staging/media/st-cec/Kconfig | 2 +-
include/media/cec.h | 2 +-
include/uapi/linux/Kbuild | 2 ++
include/{ => uapi}/linux/cec-funcs.h | 6 ------
include/{ => uapi}/linux/cec.h | 6 ------
21 files changed, 32 insertions(+), 46 deletions(-)
rename drivers/{staging => }/media/cec/Makefile (70%)
rename drivers/{staging => }/media/cec/cec-adap.c (100%)
rename drivers/{staging => }/media/cec/cec-api.c (100%)
rename drivers/{staging => }/media/cec/cec-core.c (100%)
rename drivers/{staging => }/media/cec/cec-priv.h (100%)
delete mode 100644 drivers/staging/media/cec/Kconfig
delete mode 100644 drivers/staging/media/cec/TODO
rename include/{ => uapi}/linux/cec-funcs.h (99%)
rename include/{ => uapi}/linux/cec.h (99%)
diff --git a/Documentation/media/Makefile b/Documentation/media/Makefile
index a7fb35291f6c61..61afa052c501a1 100644
--- a/Documentation/media/Makefile
+++ b/Documentation/media/Makefile
@@ -51,7 +51,7 @@ $(BUILDDIR)/videodev2.h.rst: ${UAPI}/videodev2.h ${PARSER} $(SRC_DIR)/videodev2.
$(BUILDDIR)/media.h.rst: ${UAPI}/media.h ${PARSER} $(SRC_DIR)/media.h.rst.exceptions
@$($(quiet)gen_rst)
-$(BUILDDIR)/cec.h.rst: ${KAPI}/cec.h ${PARSER} $(SRC_DIR)/cec.h.rst.exceptions
+$(BUILDDIR)/cec.h.rst: ${UAPI}/cec.h ${PARSER} $(SRC_DIR)/cec.h.rst.exceptions
@$($(quiet)gen_rst)
$(BUILDDIR)/lirc.h.rst: ${UAPI}/lirc.h ${PARSER} $(SRC_DIR)/lirc.h.rst.exceptions
diff --git a/drivers/media/Kconfig b/drivers/media/Kconfig
index 7b854029121731..bc643cbf813ef8 100644
--- a/drivers/media/Kconfig
+++ b/drivers/media/Kconfig
@@ -80,6 +80,22 @@ config MEDIA_RC_SUPPORT
Say Y when you have a TV or an IR device.
+config MEDIA_CEC_SUPPORT
+ bool "HDMI CEC support"
+ select MEDIA_CEC_EDID
+ ---help---
+ Enable support for HDMI CEC (Consumer Electronics Control),
+ which is an optional HDMI feature.
+
+ Say Y when you have an HDMI receiver, transmitter or a USB CEC
+ adapter that supports HDMI CEC.
+
+config MEDIA_CEC_DEBUG
+ bool "HDMI CEC debugfs interface"
+ depends on MEDIA_CEC_SUPPORT && DEBUG_FS
+ ---help---
+ Turns on the DebugFS interface for CEC devices.
+
config MEDIA_CEC_EDID
bool
diff --git a/drivers/media/Makefile b/drivers/media/Makefile
index 0deaa93efdee61..d87ccb8eeabe6b 100644
--- a/drivers/media/Makefile
+++ b/drivers/media/Makefile
@@ -6,6 +6,10 @@ ifeq ($(CONFIG_MEDIA_CEC_EDID),y)
obj-$(CONFIG_MEDIA_SUPPORT) += cec-edid.o
endif
+ifeq ($(CONFIG_MEDIA_CEC_SUPPORT),y)
+ obj-$(CONFIG_MEDIA_SUPPORT) += cec/
+endif
+
media-objs := media-device.o media-devnode.o media-entity.o
#
diff --git a/drivers/staging/media/cec/Makefile b/drivers/media/cec/Makefile
similarity index 70%
rename from drivers/staging/media/cec/Makefile
rename to drivers/media/cec/Makefile
index bd7f3c5934680b..d6686337275ff8 100644
--- a/drivers/staging/media/cec/Makefile
+++ b/drivers/media/cec/Makefile
@@ -1,5 +1,5 @@
cec-objs := cec-core.o cec-adap.o cec-api.o
-ifeq ($(CONFIG_MEDIA_CEC),y)
+ifeq ($(CONFIG_MEDIA_CEC_SUPPORT),y)
obj-$(CONFIG_MEDIA_SUPPORT) += cec.o
endif
diff --git a/drivers/staging/media/cec/cec-adap.c b/drivers/media/cec/cec-adap.c
similarity index 100%
rename from drivers/staging/media/cec/cec-adap.c
rename to drivers/media/cec/cec-adap.c
diff --git a/drivers/staging/media/cec/cec-api.c b/drivers/media/cec/cec-api.c
similarity index 100%
rename from drivers/staging/media/cec/cec-api.c
rename to drivers/media/cec/cec-api.c
diff --git a/drivers/staging/media/cec/cec-core.c b/drivers/media/cec/cec-core.c
similarity index 100%
rename from drivers/staging/media/cec/cec-core.c
rename to drivers/media/cec/cec-core.c
diff --git a/drivers/staging/media/cec/cec-priv.h b/drivers/media/cec/cec-priv.h
similarity index 100%
rename from drivers/staging/media/cec/cec-priv.h
rename to drivers/media/cec/cec-priv.h
diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index 2669b4bad91068..b31fa6fae00917 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -221,7 +221,7 @@ config VIDEO_ADV7604
config VIDEO_ADV7604_CEC
bool "Enable Analog Devices ADV7604 CEC support"
- depends on VIDEO_ADV7604 && MEDIA_CEC
+ depends on VIDEO_ADV7604 && MEDIA_CEC_SUPPORT
---help---
When selected the adv7604 will support the optional
HDMI CEC feature.
@@ -242,7 +242,7 @@ config VIDEO_ADV7842
config VIDEO_ADV7842_CEC
bool "Enable Analog Devices ADV7842 CEC support"
- depends on VIDEO_ADV7842 && MEDIA_CEC
+ depends on VIDEO_ADV7842 && MEDIA_CEC_SUPPORT
---help---
When selected the adv7842 will support the optional
HDMI CEC feature.
@@ -481,7 +481,7 @@ config VIDEO_ADV7511
config VIDEO_ADV7511_CEC
bool "Enable Analog Devices ADV7511 CEC support"
- depends on VIDEO_ADV7511 && MEDIA_CEC
+ depends on VIDEO_ADV7511 && MEDIA_CEC_SUPPORT
---help---
When selected the adv7511 will support the optional
HDMI CEC feature.
diff --git a/drivers/media/platform/vivid/Kconfig b/drivers/media/platform/vivid/Kconfig
index 8e6918c5c87c5d..db0dd19d227acc 100644
--- a/drivers/media/platform/vivid/Kconfig
+++ b/drivers/media/platform/vivid/Kconfig
@@ -25,7 +25,7 @@ config VIDEO_VIVID
config VIDEO_VIVID_CEC
bool "Enable CEC emulation support"
- depends on VIDEO_VIVID && MEDIA_CEC
+ depends on VIDEO_VIVID && MEDIA_CEC_SUPPORT
---help---
When selected the vivid module will emulate the optional
HDMI CEC feature.
diff --git a/drivers/staging/media/Kconfig b/drivers/staging/media/Kconfig
index 6620d96ee44d2f..0abe5ffb49346d 100644
--- a/drivers/staging/media/Kconfig
+++ b/drivers/staging/media/Kconfig
@@ -21,8 +21,6 @@ if STAGING_MEDIA && MEDIA_SUPPORT
# Please keep them in alphabetic order
source "drivers/staging/media/bcm2048/Kconfig"
-source "drivers/staging/media/cec/Kconfig"
-
source "drivers/staging/media/cxd2099/Kconfig"
source "drivers/staging/media/davinci_vpfe/Kconfig"
diff --git a/drivers/staging/media/Makefile b/drivers/staging/media/Makefile
index 906257e94dda89..246299eff80dc3 100644
--- a/drivers/staging/media/Makefile
+++ b/drivers/staging/media/Makefile
@@ -1,5 +1,4 @@
obj-$(CONFIG_I2C_BCM2048) += bcm2048/
-obj-$(CONFIG_MEDIA_CEC) += cec/
obj-$(CONFIG_VIDEO_SAMSUNG_S5P_CEC) += s5p-cec/
obj-$(CONFIG_DVB_CXD2099) += cxd2099/
obj-$(CONFIG_LIRC_STAGING) += lirc/
diff --git a/drivers/staging/media/cec/Kconfig b/drivers/staging/media/cec/Kconfig
deleted file mode 100644
index 6e12d41b1f86a7..00000000000000
--- a/drivers/staging/media/cec/Kconfig
+++ /dev/null
@@ -1,12 +0,0 @@
-config MEDIA_CEC
- bool "CEC API (EXPERIMENTAL)"
- depends on MEDIA_SUPPORT
- select MEDIA_CEC_EDID
- ---help---
- Enable the CEC API.
-
-config MEDIA_CEC_DEBUG
- bool "CEC debugfs interface (EXPERIMENTAL)"
- depends on MEDIA_CEC && DEBUG_FS
- ---help---
- Turns on the DebugFS interface for CEC devices.
diff --git a/drivers/staging/media/pulse8-cec/Kconfig b/drivers/staging/media/pulse8-cec/Kconfig
index c6aa2d1c9df0ad..6ffc407de62fbd 100644
--- a/drivers/staging/media/pulse8-cec/Kconfig
+++ b/drivers/staging/media/pulse8-cec/Kconfig
@@ -1,6 +1,6 @@
config USB_PULSE8_CEC
tristate "Pulse Eight HDMI CEC"
- depends on USB_ACM && MEDIA_CEC
+ depends on USB_ACM && MEDIA_CEC_SUPPORT
select SERIO
select SERIO_SERPORT
---help---
diff --git a/drivers/staging/media/s5p-cec/Kconfig b/drivers/staging/media/s5p-cec/Kconfig
index 0315fd7ad0f1bd..ddfd955da0d40d 100644
--- a/drivers/staging/media/s5p-cec/Kconfig
+++ b/drivers/staging/media/s5p-cec/Kconfig
@@ -1,6 +1,6 @@
config VIDEO_SAMSUNG_S5P_CEC
tristate "Samsung S5P CEC driver"
- depends on VIDEO_DEV && MEDIA_CEC && (PLAT_S5P || ARCH_EXYNOS || COMPILE_TEST)
+ depends on VIDEO_DEV && MEDIA_CEC_SUPPORT && (PLAT_S5P || ARCH_EXYNOS || COMPILE_TEST)
---help---
This is a driver for Samsung S5P HDMI CEC interface. It uses the
generic CEC framework interface.
diff --git a/drivers/staging/media/st-cec/Kconfig b/drivers/staging/media/st-cec/Kconfig
index 784d2c600aca10..c04283db58d6d1 100644
--- a/drivers/staging/media/st-cec/Kconfig
+++ b/drivers/staging/media/st-cec/Kconfig
@@ -1,6 +1,6 @@
config VIDEO_STI_HDMI_CEC
tristate "STMicroelectronics STiH4xx HDMI CEC driver"
- depends on VIDEO_DEV && MEDIA_CEC && (ARCH_STI || COMPILE_TEST)
+ depends on VIDEO_DEV && MEDIA_CEC_SUPPORT && (ARCH_STI || COMPILE_TEST)
---help---
This is a driver for STIH4xx HDMI CEC interface. It uses the
generic CEC framework interface.
diff --git a/include/media/cec.h b/include/media/cec.h
index fdb5d600e4bb98..717eaf552f3d0c 100644
--- a/include/media/cec.h
+++ b/include/media/cec.h
@@ -196,7 +196,7 @@ static inline bool cec_is_sink(const struct cec_adapter *adap)
return adap->phys_addr == 0;
}
-#if IS_ENABLED(CONFIG_MEDIA_CEC)
+#if IS_ENABLED(CONFIG_MEDIA_CEC_SUPPORT)
struct cec_adapter *cec_allocate_adapter(const struct cec_adap_ops *ops,
void *priv, const char *name, u32 caps, u8 available_las,
struct device *parent);
diff --git a/include/linux/cec-funcs.h b/include/uapi/linux/cec-funcs.h
similarity index 99%
rename from include/linux/cec-funcs.h
rename to include/uapi/linux/cec-funcs.h
index 138bbf721e70ca..1a1de2169f4891 100644
--- a/include/linux/cec-funcs.h
+++ b/include/uapi/linux/cec-funcs.h
@@ -33,12 +33,6 @@
* SOFTWARE.
*/
-/*
- * Note: this framework is still in staging and it is likely the API
- * will change before it goes out of staging.
- *
- * Once it is moved out of staging this header will move to uapi.
- */
#ifndef _CEC_UAPI_FUNCS_H
#define _CEC_UAPI_FUNCS_H
diff --git a/include/linux/cec.h b/include/uapi/linux/cec.h
similarity index 99%
rename from include/linux/cec.h
rename to include/uapi/linux/cec.h
index 9c87711c0e1c0b..f4ec0af67707aa 100644
--- a/include/linux/cec.h
+++ b/include/uapi/linux/cec.h
@@ -33,12 +33,6 @@
* SOFTWARE.
*/
-/*
- * Note: this framework is still in staging and it is likely the API
- * will change before it goes out of staging.
- *
- * Once it is moved out of staging this header will move to uapi.
- */
#ifndef _CEC_UAPI_H
#define _CEC_UAPI_H

View File

@ -0,0 +1,12 @@
diff -Naur linux-Switch-5.1.2/nvidia/drivers/video/tegra/Kconfig linux-Switch-5.1.2-2/nvidia/drivers/video/tegra/Kconfig
--- linux-Switch-5.1.2/nvidia/drivers/video/tegra/Kconfig 2024-01-29 05:57:16.331738434 +0100
+++ linux-Switch-5.1.2-2/nvidia/drivers/video/tegra/Kconfig 2024-01-29 07:21:54.862883090 +0100
@@ -231,7 +231,7 @@
config TEGRA_DP_BRANCH_STDP2550
bool "Enable DP branch STDP2550/RTD2172N support."
- depends on TEGRA_DP && MEDIA_CEC
+ depends on TEGRA_DP && MEDIA_CEC_SUPPORT
default n
help
Say Y here to enable the DP branch MegaChips STDP2550 and Realtek

View File

@ -108,7 +108,7 @@
LINUX="L4T"
# CEC Support
#CEC_FRAMEWORK_SUPPORT="yes"
CEC_FRAMEWORK_SUPPORT="yes"
# Set Distro Specific options
if [ "${DISTRO}" = "LibreELEC" ]; then

View File

@ -1,12 +0,0 @@
diff -Naur glibc-2.27/aclocal.m4 glibc-2.27-2/aclocal.m4
--- glibc-2.27/aclocal.m4 2022-04-20 02:23:50.549365949 +0200
+++ glibc-2.27-2/aclocal.m4 2022-04-20 02:26:23.179843270 +0200
@@ -2,7 +2,7 @@
dnl the internal functions defined and used by the main configure script
dnl match those expected by the fragments. When changing this version,
dnl install.texi also needs to be updated.
-m4_define([GLIBC_AUTOCONF_VERSION], [2.69])
+m4_define([GLIBC_AUTOCONF_VERSION], [2.71])
m4_if(m4_defn([AC_AUTOCONF_VERSION]), GLIBC_AUTOCONF_VERSION, [],
[m4_fatal(m4_flatten(
Exactly version GLIBC_AUTOCONF_VERSION of Autoconf is required but you have

View File

@ -1,46 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2009-2016 Stephan Raue (stephan@openelec.tv)
# Copyright (C) 2018-present Team LibreELEC (https://libreelec.tv)
PKG_NAME="libcec"
PKG_VERSION="4.0.3"
PKG_SHA256="ef90d6e4cf9d5847c14d3ff21b71579e5110643f31e8574766d3fa6c89c6239c"
PKG_LICENSE="GPL"
PKG_SITE="http://libcec.pulse-eight.com/"
PKG_URL="https://github.com/Pulse-Eight/libcec/archive/libcec-${PKG_VERSION}.tar.gz"
PKG_DEPENDS_TARGET="toolchain systemd p8-platform swig:host"
PKG_LONGDESC="libCEC is an open-source dual licensed library designed for communicating with the Pulse-Eight USB - CEC Adaptor."
PKG_CMAKE_OPTS_TARGET="-DBUILD_SHARED_LIBS=1 \
-DCMAKE_INSTALL_LIBDIR:STRING=lib \
-DCMAKE_INSTALL_LIBDIR_NOARCH:STRING=lib \
-DSKIP_PYTHON_WRAPPER=1 \
-DHAVE_IMX_API=0 \
-DHAVE_AOCEC_API=0 -DHAVE_AMLOGIC_API=0 \
-DHAVE_GIT_BIN=0 \
-DHAVE_RPI_LIB=0"
# libX11 and xrandr to read the sink's EDID, used to determine the PC's HDMI physical address
if [ "${DISPLAYSERVER}" = "x11" ]; then
PKG_DEPENDS_TARGET+=" libX11 libXrandr"
fi
if [ "${CEC_FRAMEWORK_SUPPORT}" = "yes" ]; then
PKG_CMAKE_OPTS_TARGET+=" -DHAVE_LINUX_API=1"
else
PKG_CMAKE_OPTS_TARGET+=" -DHAVE_LINUX_API=0"
fi
if [ ${PROJECT} = "L4T" ]; then
PKG_PATCH_DIRS="${PROJECT}"
fi
post_makeinstall_target() {
# Remove the Python3 demo - useless for us
rm -f ${INSTALL}/usr/bin/pyCecClient
PYTHON_DIR=${INSTALL}/usr/lib/${PKG_PYTHON_VERSION}
if [ -d ${PYTHON_DIR}/dist-packages ]; then
mv ${PYTHON_DIR}/dist-packages ${PYTHON_DIR}/site-packages
fi
}