diff options
author | Otavio Salvador <otavio@ossystems.com.br> | 2023-01-10 08:59:03 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-10 08:59:03 -0300 |
commit | 1c7f17f6063d0b747d94a17059b176f3ebdb3e3e (patch) | |
tree | 5da96ff55339ea98501a9e1f7544a243b20e9983 /dynamic-layers/chromium-browser-layer/recipes-browser/chromium/chromium-ozone-wayland/0105-V4L2Buffer-Allocate-correct-v4l2-buffers-for-queues.patch | |
parent | bd8ff87bf68f52b3933c5d1e9f83c610f18a963d (diff) | |
parent | 481b7f0468b3f5928f8f0fc6aa21e4836fb3f3c5 (diff) | |
download | meta-freescale-1c7f17f6063d0b747d94a17059b176f3ebdb3e3e.tar.gz |
Merge pull request #1380 from Freescale/backport-1375-to-kirkstone
[Backport kirkstone] chromium-ozone-wayland: add bbappend and patches as per NXP 5.15.71_2…
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.patch | 101 |
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 @@ | |||
1 | From 8c5e88c38c6ef5c9864016b90dfc3ae49cc11ddb Mon Sep 17 00:00:00 2001 | ||
2 | From: Hou Qi <qi.hou@nxp.com> | ||
3 | Date: Fri, 2 Sep 2022 17:10:12 +0800 | ||
4 | Subject: [PATCH 05/17] V4L2Buffer: Allocate correct v4l2 buffers for queues | ||
5 | |||
6 | For single plane queue, need to fill v4l2_planes_[0] with | ||
7 | correct size quried from v4l2 driver. | ||
8 | |||
9 | Upstream-Status: Inappropriate [NXP specific] | ||
10 | --- | ||
11 | media/gpu/v4l2/v4l2_device.cc | 45 ++++++++++++++++++++++++----------- | ||
12 | 1 file changed, 31 insertions(+), 14 deletions(-) | ||
13 | |||
14 | diff --git a/media/gpu/v4l2/v4l2_device.cc b/media/gpu/v4l2/v4l2_device.cc | ||
15 | index 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 | -- | ||
100 | 2.17.1 | ||
101 | |||