OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <dlfcn.h> | 5 #include <dlfcn.h> |
6 #include <fcntl.h> | 6 #include <fcntl.h> |
7 #include <linux/videodev2.h> | 7 #include <linux/videodev2.h> |
8 | 8 |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/posix/eintr_wrapper.h" | 10 #include "base/posix/eintr_wrapper.h" |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
165 } | 165 } |
166 device_fd_ = HANDLE_EINTR( | 166 device_fd_ = HANDLE_EINTR( |
167 TegraV4L2_Open(device_path, O_RDWR | O_NONBLOCK | O_CLOEXEC)); | 167 TegraV4L2_Open(device_path, O_RDWR | O_NONBLOCK | O_CLOEXEC)); |
168 if (device_fd_ == -1) { | 168 if (device_fd_ == -1) { |
169 DLOG(ERROR) << "Unable to open device " << device_path; | 169 DLOG(ERROR) << "Unable to open device " << device_path; |
170 return false; | 170 return false; |
171 } | 171 } |
172 return true; | 172 return true; |
173 } | 173 } |
174 | 174 |
175 std::vector<base::ScopedFD> TegraV4L2Device::GetDmabufsForV4L2Buffer( | |
176 int index, | |
kcwu
2016/03/22 05:42:54
/* index */ and /* type */
Pawel Osciak
2016/03/28 01:31:28
Done.
| |
177 size_t num_planes, | |
178 enum v4l2_buf_type type) { | |
179 std::vector<base::ScopedFD> dmabuf_fds; | |
180 // Tegra does not actually provide dmabuf fds currently. Fill the vector with | |
181 // invalid descriptors to prevent the caller from failing on an empty vector | |
182 // being returned. TegraV4L2Device::CreateEGLImage() will ignore the invalid | |
183 // descriptors and create images based on V4L2 index passed to it. | |
184 dmabuf_fds.resize(num_planes); | |
185 return dmabuf_fds; | |
186 } | |
187 | |
175 bool TegraV4L2Device::CanCreateEGLImageFrom(uint32_t v4l2_pixfmt) { | 188 bool TegraV4L2Device::CanCreateEGLImageFrom(uint32_t v4l2_pixfmt) { |
176 return v4l2_pixfmt == V4L2_PIX_FMT_NV12M; | 189 return v4l2_pixfmt == V4L2_PIX_FMT_NV12M; |
177 } | 190 } |
178 | 191 |
179 EGLImageKHR TegraV4L2Device::CreateEGLImage(EGLDisplay egl_display, | 192 EGLImageKHR TegraV4L2Device::CreateEGLImage( |
180 EGLContext egl_context, | 193 EGLDisplay egl_display, |
181 GLuint texture_id, | 194 EGLContext egl_context, |
182 gfx::Size /* frame_buffer_size */, | 195 GLuint texture_id, |
183 unsigned int buffer_index, | 196 const gfx::Size& /* size */, |
184 uint32_t v4l2_pixfmt, | 197 unsigned int buffer_index, |
185 size_t /* num_v4l2_planes */) { | 198 uint32_t v4l2_pixfmt, |
199 const std::vector<base::ScopedFD>& /* dmabuf_fds */) { | |
186 DVLOG(3) << "CreateEGLImage()"; | 200 DVLOG(3) << "CreateEGLImage()"; |
187 if (!CanCreateEGLImageFrom(v4l2_pixfmt)) { | 201 if (!CanCreateEGLImageFrom(v4l2_pixfmt)) { |
188 LOG(ERROR) << "Unsupported V4L2 pixel format"; | 202 LOG(ERROR) << "Unsupported V4L2 pixel format"; |
189 return EGL_NO_IMAGE_KHR; | 203 return EGL_NO_IMAGE_KHR; |
190 } | 204 } |
191 | 205 |
192 EGLint attr = EGL_NONE; | 206 EGLint attr = EGL_NONE; |
193 EGLImageKHR egl_image = | 207 EGLImageKHR egl_image = |
194 eglCreateImageKHR(egl_display, | 208 eglCreateImageKHR(egl_display, |
195 egl_context, | 209 egl_context, |
(...skipping 20 matching lines...) Expand all Loading... | |
216 GLenum TegraV4L2Device::GetTextureTarget() { return GL_TEXTURE_2D; } | 230 GLenum TegraV4L2Device::GetTextureTarget() { return GL_TEXTURE_2D; } |
217 | 231 |
218 uint32_t TegraV4L2Device::PreferredInputFormat() { | 232 uint32_t TegraV4L2Device::PreferredInputFormat() { |
219 // TODO(posciak): We should support "dontcare" returns here once we | 233 // TODO(posciak): We should support "dontcare" returns here once we |
220 // implement proper handling (fallback, negotiation) for this in users. | 234 // implement proper handling (fallback, negotiation) for this in users. |
221 CHECK_EQ(type_, kEncoder); | 235 CHECK_EQ(type_, kEncoder); |
222 return V4L2_PIX_FMT_YUV420M; | 236 return V4L2_PIX_FMT_YUV420M; |
223 } | 237 } |
224 | 238 |
225 } // namespace content | 239 } // namespace content |
OLD | NEW |