Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(991)

Unified Diff: media/gpu/tegra_v4l2_device.cc

Issue 2398883002: Add support for multiple V4L2 video devices of the same type. (Closed)
Patch Set: Address comments, reorganize V4L2Device::Type. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/gpu/tegra_v4l2_device.cc
diff --git a/media/gpu/tegra_v4l2_device.cc b/media/gpu/tegra_v4l2_device.cc
index 25b1c6a5180c8ff481ab9bc72d324c3d9a005929..df595c5c878e5c9b1ecf9981257641e15be71d32 100644
--- a/media/gpu/tegra_v4l2_device.cc
+++ b/media/gpu/tegra_v4l2_device.cc
@@ -56,10 +56,8 @@ class TegraFunctionSymbolFinder {
public:
TegraFunctionSymbolFinder() : initialized_(false) {
if (!dlopen("/usr/lib/libtegrav4l2.so",
- RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE)) {
- DLOG(ERROR) << "Failed to load libtegrav4l2.so";
+ RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE))
kcwu 2016/10/07 11:19:04 Why removed the DLOG ? It may silently fallback to
Pawel Osciak 2016/10/11 06:13:45 It is now the normal flow to try TegraV4L2Device f
return;
- }
#define TEGRAV4L2_DLSYM_OR_RETURN_ON_ERROR(name) \
do { \
TegraV4L2_##name = reinterpret_cast<TegraV4L2##name>( \
@@ -92,8 +90,7 @@ class TegraFunctionSymbolFinder {
base::LazyInstance<TegraFunctionSymbolFinder> g_tegra_function_symbol_finder_ =
LAZY_INSTANCE_INITIALIZER;
-TegraV4L2Device::TegraV4L2Device(Type type)
- : V4L2Device(type), device_fd_(-1) {}
+TegraV4L2Device::TegraV4L2Device() {}
TegraV4L2Device::~TegraV4L2Device() {
if (device_fd_ != -1) {
@@ -144,23 +141,29 @@ bool TegraV4L2Device::ClearDevicePollInterrupt() {
}
bool TegraV4L2Device::Initialize() {
- const char* device_path = NULL;
- switch (type_) {
- case kDecoder:
+ return g_tegra_function_symbol_finder_.Get().initialized();
+}
+
+bool TegraV4L2Device::Open(Type type, uint32_t /* v4l2_pixfmt */) {
+ return OpenInternal(type);
+}
+
+bool TegraV4L2Device::OpenInternal(Type type) {
+ const char* device_path = nullptr;
kcwu 2016/10/07 11:19:04 DCHECK_EQ(device_fd_, -1);
Pawel Osciak 2016/10/11 06:13:45 Done.
+
+ switch (type) {
+ case Type::kDecoder:
device_path = kDecoderDevice;
break;
- case kEncoder:
+ case Type::kEncoder:
device_path = kEncoderDevice;
break;
default:
- DVLOG(1) << "Device type " << type_ << " not supported on this platform";
+ DVLOG(1) << "Device type " << static_cast<int>(type)
+ << " not supported on this platform";
return false;
}
- if (!g_tegra_function_symbol_finder_.Get().initialized()) {
- DLOG(ERROR) << "Unable to initialize functions";
- return false;
- }
device_fd_ = HANDLE_EINTR(
TegraV4L2_Open(device_path, O_RDWR | O_NONBLOCK | O_CLOEXEC));
if (device_fd_ == -1) {
@@ -173,7 +176,7 @@ bool TegraV4L2Device::Initialize() {
std::vector<base::ScopedFD> TegraV4L2Device::GetDmabufsForV4L2Buffer(
int /* index */,
size_t num_planes,
- enum v4l2_buf_type /* type */) {
+ enum v4l2_buf_type /* buf_type */) {
std::vector<base::ScopedFD> dmabuf_fds;
// Tegra does not actually provide dmabuf fds currently. Fill the vector with
// invalid descriptors to prevent the caller from failing on an empty vector
@@ -226,11 +229,41 @@ GLenum TegraV4L2Device::GetTextureTarget() {
return GL_TEXTURE_2D;
}
-uint32_t TegraV4L2Device::PreferredInputFormat() {
- // TODO(posciak): We should support "dontcare" returns here once we
- // implement proper handling (fallback, negotiation) for this in users.
- CHECK_EQ(type_, kEncoder);
- return V4L2_PIX_FMT_YUV420M;
+uint32_t TegraV4L2Device::PreferredInputFormat(Type type) {
+ if (type == Type::kEncoder)
+ return V4L2_PIX_FMT_YUV420M;
+
+ return 0;
+}
+
+std::vector<uint32_t> TegraV4L2Device::GetSupportedImageProcessorPixelformats(
+ v4l2_buf_type /* buf_type */) {
+ return std::vector<uint32_t>();
+}
+
+VideoDecodeAccelerator::SupportedProfiles
+TegraV4L2Device::GetSupportedDecodeProfiles(const size_t num_formats,
+ const uint32_t pixelformats[]) {
+ if (!OpenInternal(Type::kDecoder))
+ return VideoDecodeAccelerator::SupportedProfiles();
+
+ return EnumerateSupportedDecodeProfiles(num_formats, pixelformats);
kcwu 2016/10/07 11:19:04 don't forget to close, otherwise fd leak.
Pawel Osciak 2016/10/11 06:13:45 Done.
+}
+
+VideoEncodeAccelerator::SupportedProfiles
+TegraV4L2Device::GetSupportedEncodeProfiles() {
+ if (!OpenInternal(Type::kEncoder))
+ return VideoEncodeAccelerator::SupportedProfiles();
+
+ return EnumerateSupportedEncodeProfiles();
kcwu 2016/10/07 11:19:04 don't forget to close, otherwise fd leak.
Pawel Osciak 2016/10/11 06:13:45 Done.
+}
+
+bool TegraV4L2Device::IsImageProcessingSupported() {
+ return false;
+}
+
+bool TegraV4L2Device::IsJpegDecodingSupported() {
+ return false;
}
} // namespace media

Powered by Google App Engine
This is Rietveld 408576698