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

Side by Side Diff: media/gpu/generic_v4l2_device.cc

Issue 2559423002: media/gpu: switch v4l2_jpeg_decode_accelerator to use multi-planar APIs (Closed)
Patch Set: let's see if I get the number of patches to upload right this time... Created 4 years 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 unified diff | Download patch
OLDNEW
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 5
6 #include "media/gpu/generic_v4l2_device.h" 6 #include "media/gpu/generic_v4l2_device.h"
7 7
8 #include <errno.h> 8 #include <errno.h>
9 #include <fcntl.h> 9 #include <fcntl.h>
10 #include <libdrm/drm_fourcc.h> 10 #include <libdrm/drm_fourcc.h>
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 #endif 411 #endif
412 } 412 }
413 413
414 void GenericV4L2Device::EnumerateDevicesForType(Type type) { 414 void GenericV4L2Device::EnumerateDevicesForType(Type type) {
415 static const std::string kDecoderDevicePattern = "/dev/video-dec"; 415 static const std::string kDecoderDevicePattern = "/dev/video-dec";
416 static const std::string kEncoderDevicePattern = "/dev/video-enc"; 416 static const std::string kEncoderDevicePattern = "/dev/video-enc";
417 static const std::string kImageProcessorDevicePattern = "/dev/image-proc"; 417 static const std::string kImageProcessorDevicePattern = "/dev/image-proc";
418 static const std::string kJpegDecoderDevicePattern = "/dev/jpeg-dec"; 418 static const std::string kJpegDecoderDevicePattern = "/dev/jpeg-dec";
419 419
420 std::string device_pattern; 420 std::string device_pattern;
421 v4l2_buf_type buf_type; 421 std::vector<v4l2_buf_type> buf_types;
422 switch (type) { 422 switch (type) {
423 case Type::kDecoder: 423 case Type::kDecoder:
424 device_pattern = kDecoderDevicePattern; 424 device_pattern = kDecoderDevicePattern;
425 buf_type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; 425 buf_types.push_back(V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE);
426 break; 426 break;
427 case Type::kEncoder: 427 case Type::kEncoder:
428 device_pattern = kEncoderDevicePattern; 428 device_pattern = kEncoderDevicePattern;
429 buf_type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; 429 buf_types.push_back(V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE);
430 break; 430 break;
431 case Type::kImageProcessor: 431 case Type::kImageProcessor:
432 device_pattern = kImageProcessorDevicePattern; 432 device_pattern = kImageProcessorDevicePattern;
433 buf_type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; 433 buf_types.push_back(V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE);
434 break; 434 break;
435 case Type::kJpegDecoder: 435 case Type::kJpegDecoder:
436 device_pattern = kJpegDecoderDevicePattern; 436 device_pattern = kJpegDecoderDevicePattern;
437 buf_type = V4L2_BUF_TYPE_VIDEO_OUTPUT; 437 buf_types.push_back(V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE);
438 buf_types.push_back(V4L2_BUF_TYPE_VIDEO_OUTPUT);
438 break; 439 break;
439 } 440 }
440 441
441 std::vector<std::string> candidate_paths; 442 std::vector<std::string> candidate_paths;
442 443
443 // TODO(posciak): Remove this legacy unnumbered device once 444 // TODO(posciak): Remove this legacy unnumbered device once
444 // all platforms are updated to use numbered devices. 445 // all platforms are updated to use numbered devices.
445 candidate_paths.push_back(device_pattern); 446 candidate_paths.push_back(device_pattern);
446 447
447 // We are sandboxed, so we can't query directory contents to check which 448 // We are sandboxed, so we can't query directory contents to check which
448 // devices are actually available. Try to open the first 10; if not present, 449 // devices are actually available. Try to open the first 10; if not present,
449 // we will just fail to open immediately. 450 // we will just fail to open immediately.
450 for (int i = 0; i < 10; ++i) { 451 for (int i = 0; i < 10; ++i) {
451 candidate_paths.push_back( 452 candidate_paths.push_back(
452 base::StringPrintf("%s%d", device_pattern.c_str(), i)); 453 base::StringPrintf("%s%d", device_pattern.c_str(), i));
453 } 454 }
454 455
455 Devices devices; 456 Devices devices;
456 for (const auto& path : candidate_paths) { 457 for (const auto& path : candidate_paths) {
457 if (!OpenDevicePath(path, type)) 458 if (!OpenDevicePath(path, type))
458 continue; 459 continue;
459 460
460 const auto& supported_pixelformats = 461 for (const auto& buf_type : buf_types) {
461 EnumerateSupportedPixelformats(buf_type); 462 const auto& supported_pixelformats =
462 if (!supported_pixelformats.empty()) { 463 EnumerateSupportedPixelformats(buf_type);
463 DVLOG(1) << "Found device: " << path; 464 if (!supported_pixelformats.empty()) {
464 devices.push_back(std::make_pair(path, supported_pixelformats)); 465 DVLOG(1) << "Found device: " << path;
466 devices.push_back(std::make_pair(path, supported_pixelformats));
467 }
465 } 468 }
466 469
467 CloseDevice(); 470 CloseDevice();
468 } 471 }
469 472
470 DCHECK_EQ(devices_by_type_.count(type), 0u); 473 DCHECK_EQ(devices_by_type_.count(type), 0u);
471 devices_by_type_[type] = devices; 474 devices_by_type_[type] = devices;
472 } 475 }
473 476
474 const GenericV4L2Device::Devices& GenericV4L2Device::GetDevicesForType( 477 const GenericV4L2Device::Devices& GenericV4L2Device::GetDevicesForType(
(...skipping 11 matching lines...) Expand all
486 for (const auto& device : devices) { 489 for (const auto& device : devices) {
487 if (std::find(device.second.begin(), device.second.end(), pixfmt) != 490 if (std::find(device.second.begin(), device.second.end(), pixfmt) !=
488 device.second.end()) 491 device.second.end())
489 return device.first; 492 return device.first;
490 } 493 }
491 494
492 return std::string(); 495 return std::string();
493 } 496 }
494 497
495 } // namespace media 498 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/gpu/jpeg_decode_accelerator_unittest.cc » ('j') | media/gpu/v4l2_jpeg_decode_accelerator.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698