summaryrefslogtreecommitdiffstats
path: root/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0105-V4L2Buffer-Allocate-correct-v4l2-buffers-for-queues.patch
diff options
context:
space:
mode:
Diffstat (limited to 'dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0105-V4L2Buffer-Allocate-correct-v4l2-buffers-for-queues.patch')
-rw-r--r--dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0105-V4L2Buffer-Allocate-correct-v4l2-buffers-for-queues.patch101
1 files changed, 101 insertions, 0 deletions
diff --git a/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0105-V4L2Buffer-Allocate-correct-v4l2-buffers-for-queues.patch b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0105-V4L2Buffer-Allocate-correct-v4l2-buffers-for-queues.patch
new file mode 100644
index 00000000..b790b9ff
--- /dev/null
+++ b/dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0105-V4L2Buffer-Allocate-correct-v4l2-buffers-for-queues.patch
@@ -0,0 +1,101 @@
1From 8c5e88c38c6ef5c9864016b90dfc3ae49cc11ddb Mon Sep 17 00:00:00 2001
2From: Hou Qi <qi.hou@nxp.com>
3Date: Fri, 2 Sep 2022 17:10:12 +0800
4Subject: [PATCH 05/17] V4L2Buffer: Allocate correct v4l2 buffers for queues
5
6For single plane queue, need to fill v4l2_planes_[0] with
7correct size quried from v4l2 driver.
8
9Upstream-Status: Inappropriate [NXP specific]
10---
11 media/gpu/v4l2/v4l2_device.cc | 45 ++++++++++++++++++++++++-----------
12 1 file changed, 31 insertions(+), 14 deletions(-)
13
14diff --git a/media/gpu/v4l2/v4l2_device.cc b/media/gpu/v4l2/v4l2_device.cc
15index 8194d8646637c..9614eb8e71668 100644
16--- a/media/gpu/v4l2/v4l2_device.cc
17+++ b/media/gpu/v4l2/v4l2_device.cc
18@@ -210,24 +210,30 @@ V4L2Buffer::V4L2Buffer(scoped_refptr<V4L2Device> device,
19 DCHECK(V4L2_TYPE_IS_MULTIPLANAR(type));
20 DCHECK_LE(format.fmt.pix_mp.num_planes, std::size(v4l2_planes_));
21
22- memset(&v4l2_buffer_, 0, sizeof(v4l2_buffer_));
23- memset(v4l2_planes_, 0, sizeof(v4l2_planes_));
24- v4l2_buffer_.m.planes = v4l2_planes_;
25- // Just in case we got more planes than we want.
26- v4l2_buffer_.length =
27- std::min(static_cast<size_t>(format.fmt.pix_mp.num_planes),
28- std::size(v4l2_planes_));
29+ if (V4L2_TYPE_IS_MULTIPLANAR(type)) {
30+ memset(&v4l2_buffer_, 0, sizeof(v4l2_buffer_));
31+ memset(v4l2_planes_, 0, sizeof(v4l2_planes_));
32+ v4l2_buffer_.m.planes = v4l2_planes_;
33+ // Just in case we got more planes than we want.
34+ v4l2_buffer_.length =
35+ std::min(static_cast<size_t>(format.fmt.pix_mp.num_planes),
36+ std::size(v4l2_planes_));
37+ }
38 v4l2_buffer_.index = buffer_id;
39 v4l2_buffer_.type = type;
40 v4l2_buffer_.memory = memory;
41- plane_mappings_.resize(v4l2_buffer_.length);
42+ plane_mappings_.resize(V4L2_TYPE_IS_MULTIPLANAR(type) ? v4l2_buffer_.length : 1);
43 }
44
45 V4L2Buffer::~V4L2Buffer() {
46 if (v4l2_buffer_.memory == V4L2_MEMORY_MMAP) {
47- for (size_t i = 0; i < plane_mappings_.size(); i++)
48- if (plane_mappings_[i] != nullptr)
49- device_->Munmap(plane_mappings_[i], v4l2_buffer_.m.planes[i].length);
50+ for (size_t i = 0; i < plane_mappings_.size(); i++) {
51+ if (plane_mappings_[i] != nullptr) {
52+ unsigned int length = V4L2_TYPE_IS_MULTIPLANAR(v4l2_buffer_.type) ?
53+ v4l2_buffer_.m.planes[i].length : v4l2_buffer_.length;
54+ device_->Munmap(plane_mappings_[i], length);
55+ }
56+ }
57 }
58 }
59
60@@ -238,6 +244,13 @@ bool V4L2Buffer::Query() {
61 return false;
62 }
63
64+ if (!V4L2_TYPE_IS_MULTIPLANAR(v4l2_buffer_.type)) {
65+ v4l2_planes_[0].bytesused = v4l2_buffer_.bytesused;
66+ v4l2_planes_[0].length = v4l2_buffer_.length;
67+ v4l2_planes_[0].data_offset = 0;
68+ memcpy (&v4l2_planes_[0].m, &v4l2_buffer_.m, sizeof (v4l2_buffer_.m));
69+ }
70+
71 DCHECK(plane_mappings_.size() == v4l2_buffer_.length);
72
73 return true;
74@@ -260,9 +273,13 @@ void* V4L2Buffer::GetPlaneMapping(const size_t plane) {
75 return nullptr;
76 }
77
78- p = device_->Mmap(nullptr, v4l2_buffer_.m.planes[plane].length,
79+ unsigned int length = V4L2_TYPE_IS_MULTIPLANAR(v4l2_buffer_.type) ?
80+ v4l2_buffer_.m.planes[plane].length : v4l2_planes_[plane].length;
81+ unsigned int mem_offset = V4L2_TYPE_IS_MULTIPLANAR(v4l2_buffer_.type) ?
82+ v4l2_buffer_.m.planes[plane].m.mem_offset : v4l2_planes_[plane].m.mem_offset;
83+ p = device_->Mmap(nullptr, length,
84 PROT_READ | PROT_WRITE, MAP_SHARED,
85- v4l2_buffer_.m.planes[plane].m.mem_offset);
86+ mem_offset);
87 if (p == MAP_FAILED) {
88 VPLOGF(1) << "mmap() failed: ";
89 return nullptr;
90@@ -1131,7 +1148,7 @@ size_t V4L2Queue::AllocateBuffers(size_t count, enum v4l2_memory memory) {
91 VQLOGF(1) << "Cannot get format.";
92 return 0;
93 }
94- planes_count_ = format->fmt.pix_mp.num_planes;
95+ planes_count_ = V4L2_TYPE_IS_MULTIPLANAR(format->type) ? format->fmt.pix_mp.num_planes : 1;
96 DCHECK_LE(planes_count_, static_cast<size_t>(VIDEO_MAX_PLANES));
97
98 struct v4l2_requestbuffers reqbufs;
99--
1002.17.1
101