Chromium Code Reviews| Index: content/common/gpu/media/exynos_v4l2_video_device.cc |
| diff --git a/content/common/gpu/media/exynos_v4l2_video_device.cc b/content/common/gpu/media/exynos_v4l2_video_device.cc |
| index 214a4311ab39466d8a7b37b9940fa119a8dabadb..20efe2c9e9fbd68b5d66b24402e5c50ae06ea132 100644 |
| --- a/content/common/gpu/media/exynos_v4l2_video_device.cc |
| +++ b/content/common/gpu/media/exynos_v4l2_video_device.cc |
| @@ -17,6 +17,29 @@ |
| #include "content/common/gpu/media/exynos_v4l2_video_device.h" |
| #include "ui/gl/gl_bindings.h" |
| +#ifdef USE_LIBV4L2 |
| +# include<libv4l2.h> |
|
Pawel Osciak
2014/11/18 08:36:30
No indent please. And space before '<'.
henryhsu
2014/11/19 03:49:47
Done.
|
| +# include "content/common/gpu/media/v4l2_stubs.h" |
| + |
| +using content_common_gpu_media::kModuleV4l2; |
| +using content_common_gpu_media::InitializeStubs; |
| +using content_common_gpu_media::StubPathMap; |
| + |
| +static const base::FilePath::CharType kV4l2Lib[] = |
| + FILE_PATH_LITERAL("libv4l2.so"); |
| +#else |
| +# define V4L2_DISABLE_CONVERSION 0x01 |
| +# define v4l2_close close |
|
Pawel Osciak
2014/11/18 08:36:30
No indent please.
henryhsu
2014/11/19 03:49:46
Done.
|
| +# define v4l2_ioctl ioctl |
| +# define v4l2_read read |
|
Pawel Osciak
2014/11/18 08:36:29
We don't use read or write.
henryhsu
2014/11/19 03:49:47
Done.
|
| +# define v4l2_write write |
| +# define v4l2_mmap mmap |
|
Pawel Osciak
2014/11/18 08:36:30
We don't want to do this if we don't do conversion
henryhsu
2014/11/19 03:49:47
Agree. use mmap first and then add a patch at the
|
| +# define v4l2_munmap munmap |
|
Pawel Osciak
2014/11/18 08:36:30
Ditto.
henryhsu
2014/11/19 03:49:46
Done.
|
| +int v4l2_fd_open(int fd, int v4l2_flags) { |
|
Pawel Osciak
2014/11/18 08:36:30
Better just ifdef the call out instead of this and
henryhsu
2014/11/19 03:49:46
Done.
|
| + return 0; |
| +} |
| +#endif |
| + |
| namespace content { |
| namespace { |
| @@ -28,21 +51,28 @@ const char kImageProcessorDevice[] = "/dev/gsc1"; |
| ExynosV4L2Device::ExynosV4L2Device(Type type) |
| : type_(type), |
| device_fd_(-1), |
| - device_poll_interrupt_fd_(-1) {} |
| + device_poll_interrupt_fd_(-1) { |
| +#ifdef USE_LIBV4L2 |
|
Pawel Osciak
2014/11/18 08:36:30
Please extract this to PostSandboxInitialization()
henryhsu
2014/11/19 03:49:46
Done.
|
| + StubPathMap paths; |
| + paths[kModuleV4l2].push_back(kV4l2Lib); |
| + if (!InitializeStubs(paths)) |
| + LOG(ERROR) << "Failed to initialize LIBV4L2 libs"; |
|
Pawel Osciak
2014/11/18 08:36:30
Shouldn't this be a critical error? Please do this
henryhsu
2014/11/19 03:49:46
Done.
|
| +#endif |
| +} |
| ExynosV4L2Device::~ExynosV4L2Device() { |
| if (device_poll_interrupt_fd_ != -1) { |
| - close(device_poll_interrupt_fd_); |
| + v4l2_close(device_poll_interrupt_fd_); |
|
Pawel Osciak
2014/11/18 08:36:30
We should not use v4l2_* functions on interrupt fd
henryhsu
2014/11/19 03:49:47
Done.
|
| device_poll_interrupt_fd_ = -1; |
| } |
| if (device_fd_ != -1) { |
| - close(device_fd_); |
| + v4l2_close(device_fd_); |
| device_fd_ = -1; |
| } |
| } |
| int ExynosV4L2Device::Ioctl(int request, void* arg) { |
| - return HANDLE_EINTR(ioctl(device_fd_, request, arg)); |
| + return HANDLE_EINTR(v4l2_ioctl(device_fd_, request, arg)); |
| } |
| bool ExynosV4L2Device::Poll(bool poll_device, bool* event_pending) { |
| @@ -75,18 +105,19 @@ void* ExynosV4L2Device::Mmap(void* addr, |
| int prot, |
| int flags, |
| unsigned int offset) { |
| - return mmap(addr, len, prot, flags, device_fd_, offset); |
| + return v4l2_mmap(addr, len, prot, flags, device_fd_, offset); |
| } |
| void ExynosV4L2Device::Munmap(void* addr, unsigned int len) { |
| - munmap(addr, len); |
| + v4l2_munmap(addr, len); |
| } |
| bool ExynosV4L2Device::SetDevicePollInterrupt() { |
| DVLOG(3) << "SetDevicePollInterrupt()"; |
| const uint64 buf = 1; |
| - if (HANDLE_EINTR(write(device_poll_interrupt_fd_, &buf, sizeof(buf))) == -1) { |
| + if (HANDLE_EINTR( |
| + v4l2_write(device_poll_interrupt_fd_, &buf, sizeof(buf))) == -1) { |
| DPLOG(ERROR) << "SetDevicePollInterrupt(): write() failed"; |
| return false; |
| } |
| @@ -97,7 +128,8 @@ bool ExynosV4L2Device::ClearDevicePollInterrupt() { |
| DVLOG(3) << "ClearDevicePollInterrupt()"; |
| uint64 buf; |
| - if (HANDLE_EINTR(read(device_poll_interrupt_fd_, &buf, sizeof(buf))) == -1) { |
| + if (HANDLE_EINTR( |
| + v4l2_read(device_poll_interrupt_fd_, &buf, sizeof(buf))) == -1) { |
| if (errno == EAGAIN) { |
| // No interrupt flag set, and we're reading nonblocking. Not an error. |
| return true; |
| @@ -129,6 +161,10 @@ bool ExynosV4L2Device::Initialize() { |
| if (device_fd_ == -1) { |
| return false; |
| } |
| + if (v4l2_fd_open(device_fd_, V4L2_DISABLE_CONVERSION) == -1) { |
|
Pawel Osciak
2014/11/18 08:36:30
Do we need to HANDLE_EINTR?
henryhsu
2014/11/19 03:49:47
Done.
|
| + v4l2_close(device_fd_); |
| + return false; |
| + } |
| device_poll_interrupt_fd_ = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC); |
| if (device_poll_interrupt_fd_ == -1) { |