summaryrefslogtreecommitdiff
path: root/chromium/media/gpu/tegra_v4l2_device.h
blob: 8529d81af1b8d523e9efa9603d5c455ddcbb5d59 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// This file contains the implementation of TegraV4L2Device used on
// Tegra platform.

#ifndef MEDIA_GPU_TEGRA_V4L2_DEVICE_H_
#define MEDIA_GPU_TEGRA_V4L2_DEVICE_H_

#include <stddef.h>
#include <stdint.h>

#include "base/macros.h"
#include "media/gpu/v4l2_device.h"
#include "ui/gl/gl_bindings.h"

namespace media {

// This class implements the V4L2Device interface for Tegra platform.
// It interfaces with libtegrav4l2 library which provides API that exhibit the
// V4L2 specification via the library API instead of system calls.
class TegraV4L2Device : public V4L2Device {
 public:
  TegraV4L2Device();

  // V4L2Device implementation.
  bool Open(Type type, uint32_t v4l2_pixfmt) override;
  int Ioctl(int flags, void* arg) override;
  bool Poll(bool poll_device, bool* event_pending) override;
  bool SetDevicePollInterrupt() override;
  bool ClearDevicePollInterrupt() override;
  void* Mmap(void* addr,
             unsigned int len,
             int prot,
             int flags,
             unsigned int offset) override;
  void Munmap(void* addr, unsigned int len) override;
  std::vector<base::ScopedFD> GetDmabufsForV4L2Buffer(
      int index,
      size_t num_planes,
      enum v4l2_buf_type buf_type) override;
  bool CanCreateEGLImageFrom(uint32_t v4l2_pixfmt) override;
  EGLImageKHR CreateEGLImage(
      EGLDisplay egl_display,
      EGLContext egl_context,
      GLuint texture_id,
      const gfx::Size& size,
      unsigned int buffer_index,
      uint32_t v4l2_pixfmt,
      const std::vector<base::ScopedFD>& dmabuf_fds) override;
  EGLBoolean DestroyEGLImage(EGLDisplay egl_display,
                             EGLImageKHR egl_image) override;
  GLenum GetTextureTarget() override;
  uint32_t PreferredInputFormat(Type type) override;

  std::vector<uint32_t> GetSupportedImageProcessorPixelformats(
      v4l2_buf_type buf_type) override;

  VideoDecodeAccelerator::SupportedProfiles GetSupportedDecodeProfiles(
      const size_t num_formats,
      const uint32_t pixelformats[]) override;

  VideoEncodeAccelerator::SupportedProfiles GetSupportedEncodeProfiles()
      override;

  bool IsImageProcessingSupported() override;

  bool IsJpegDecodingSupported() override;

 private:
  ~TegraV4L2Device() override;

  bool Initialize() override;

  bool OpenInternal(Type type);
  void Close();

  // The actual device fd.
  int device_fd_ = -1;

  DISALLOW_COPY_AND_ASSIGN(TegraV4L2Device);
};

}  //  namespace media

#endif  // MEDIA_GPU_TEGRA_V4L2_DEVICE_H_