Debian Codegraph @

src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_vsp2/qlinuxmediadevice.h

raw
1 // Copyright (C) 2017 The Qt Company Ltd.
2 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4 #ifndef QLINUXMEDIADEVICE_H
5 #define QLINUXMEDIADEVICE_H
6
7 #include <linux/v4l2-mediabus.h>
8
9 #include <QtCore/qglobal.h>
10 #include <QtCore/QString>
11
12 QT_BEGIN_NAMESPACE
13
14 class QSize;
15 class QRect;
16
17 class QLinuxMediaDevice
18 {
19 public:
20 QLinuxMediaDevice(const QString &devicePath);
21 ~QLinuxMediaDevice();
22
23 QString model();
24 QString deviceName();
25 bool resetLinks();
26 struct media_link *parseLink(const QString &link);
27 struct media_pad *parsePad(const QString &pad);
28 bool enableLink(struct media_link *link);
29 bool disableLink(struct media_link *link);
30 struct media_entity *getEntity(const QString &name);
31 int openVideoDevice(const QString &name);
32
33 class CaptureSubDevice
34 {
35 public:
36 CaptureSubDevice(QLinuxMediaDevice *mediaDevice, const QString &name);
37 bool setFormat(const QSize &size, uint32_t pixelFormat = V4L2_PIX_FMT_ABGR32); //TODO: fix to match output device
38 bool clearBuffers();
39 bool requestBuffer();
40 bool queueBuffer(int dmabufFd, const QSize &bufferSize);
41 bool dequeueBuffer();
42 bool streamOn();
43 bool streamOff();
44 private:
45 int m_subdevFd = -1;
46 };
47
48 class OutputSubDevice
49 {
50 public:
51 OutputSubDevice(QLinuxMediaDevice *mediaDevice, const QString &name);
52 bool setFormat(const QSize &size, uint32_t pixelFormat, uint32_t bytesPerLine);
53 bool clearBuffers();
54 bool requestBuffer();
55 bool queueBuffer(int dmabufFd, uint bytesUsed, uint length);
56 bool streamOn();
57 bool streamOff();
58 private:
59 int m_subdevFd = -1;
60 };
61
62 static int openVideoDevice(media_pad *pad);
63
64 static bool setSubdevFormat(struct media_pad *pad, const QSize &size, uint32_t mbusFormat = MEDIA_BUS_FMT_ARGB8888_1X32);
65 static bool setSubdevAlpha(int subdevFd, qreal alpha);
66
67 static bool setSubdevSelection(struct media_pad *pad, const QRect &geometry, uint target);
68 static bool setSubdevCrop(struct media_pad *pad, const QRect &geometry);
69 static bool setSubdevCompose(struct media_pad *pad, const QRect &geometry);
70
71 private:
72 static bool streamOn(int subDeviceFd, v4l2_buf_type bufferType);
73 static bool streamOff(int subDeviceFd, v4l2_buf_type bufferType);
74 struct media_device *m_mediaDevice = nullptr;
75 const struct media_device_info *m_info = nullptr;
76 };
77
78 QT_END_NAMESPACE
79
80 #endif // QLINUXMEDIADEVICE_H