File: mock_drm.cpp

package info (click to toggle)
mir 2.25.2-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 22,080 kB
  • sloc: cpp: 192,777; xml: 13,784; ansic: 8,207; python: 1,304; sh: 794; makefile: 258
file content (829 lines) | stat: -rw-r--r-- 23,730 bytes parent folder | download | duplicates (2)
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
/*
 * Copyright © Canonical Ltd.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 or 3 as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <mir/test/doubles/mock_drm.h>
#include <mir_test_framework/mmap_wrapper.h>
#include <mir_test_framework/open_wrapper.h>
#include <mir/geometry/size.h>
#include <gtest/gtest.h>

#include <stdexcept>
#include <unistd.h>
#include <dlfcn.h>
#include <system_error>
#include <boost/throw_exception.hpp>

namespace mtd=mir::test::doubles;
namespace geom = mir::geometry;

namespace
{
mtd::MockDRM* global_mock = nullptr;
}

mtd::FakeDRMResources::FakeDRMResources()
    : pipe_fds{-1, -1}
{
    /* Use the read end of a pipe as the fake DRM fd */
    if (pipe(pipe_fds) < 0 || pipe_fds[0] < 0)
        throw std::runtime_error("Failed to create fake DRM fd");

    /* Add some default resources */
    uint32_t const invalid_id{0};
    uint32_t const crtc0_id{10};
    uint32_t const crtc1_id{11};
    uint32_t const encoder0_id{20};
    uint32_t const encoder1_id{21};
    uint32_t const connector0_id{30};
    uint32_t const connector1_id{31};
    uint32_t const all_crtcs_mask{0x3};

    modes.push_back(create_mode(1920, 1080, 138500, 2080, 1111, PreferredMode));
    modes.push_back(create_mode(832, 624, 57284, 1152, 667, NormalMode));
    connector_encoder_ids.push_back(encoder0_id);
    connector_encoder_ids.push_back(encoder1_id);

    add_crtc(crtc0_id, drmModeModeInfo());
    add_crtc(crtc1_id, modes[1]);

    add_encoder(encoder0_id, invalid_id, all_crtcs_mask);
    add_encoder(encoder1_id, crtc1_id, all_crtcs_mask);

    add_connector(connector0_id, DRM_MODE_CONNECTOR_VGA,
                  DRM_MODE_DISCONNECTED, invalid_id,
                  modes_empty, connector_encoder_ids, geom::Size());
    add_connector(connector1_id, DRM_MODE_CONNECTOR_DVID,
                  DRM_MODE_CONNECTED, encoder1_id,
                  modes, connector_encoder_ids,
                  geom::Size{121, 144});

    prepare();
}

mtd::FakeDRMResources::~FakeDRMResources()
{
    if (pipe_fds[0] >= 0)
        close(pipe_fds[0]);

    if (pipe_fds[1] >= 0)
        close(pipe_fds[1]);
}

int mtd::FakeDRMResources::fd() const
{
    return pipe_fds[0];
}

int mtd::FakeDRMResources::write_fd() const
{
    return pipe_fds[1];
}

drmModeRes* mtd::FakeDRMResources::resources_ptr()
{
    return &resources;
}

void mtd::FakeDRMResources::prepare()
{
    resources.count_crtcs = crtcs.size();
    for (auto const& crtc: crtcs)
        crtc_ids.push_back(crtc.crtc_id);
    resources.crtcs = crtc_ids.data();

    resources.count_encoders = encoders.size();
    for (auto const& encoder: encoders)
        encoder_ids.push_back(encoder.encoder_id);
    resources.encoders = encoder_ids.data();

    resources.count_connectors = connectors.size();
    for (auto const& connector: connectors)
        connector_ids.push_back(connector.connector_id);
    resources.connectors = connector_ids.data();
}

void mtd::FakeDRMResources::reset()
{
    resources = drmModeRes();

    crtcs.clear();
    encoders.clear();
    connectors.clear();

    crtc_ids.clear();
    encoder_ids.clear();
    connector_ids.clear();
}

void mtd::FakeDRMResources::add_crtc(uint32_t id, drmModeModeInfo mode)
{
    drmModeCrtc crtc = drmModeCrtc();

    crtc.crtc_id = id;
    crtc.mode = mode;

    crtcs.push_back(crtc);
}

void mtd::FakeDRMResources::add_encoder(uint32_t encoder_id, uint32_t crtc_id,
                                        uint32_t possible_crtcs_mask)
{
    drmModeEncoder encoder = drmModeEncoder();

    encoder.encoder_id = encoder_id;
    encoder.crtc_id = crtc_id;
    encoder.possible_crtcs = possible_crtcs_mask;

    encoders.push_back(encoder);
}

void mtd::FakeDRMResources::add_connector(uint32_t connector_id,
                                          uint32_t type,
                                          drmModeConnection connection,
                                          uint32_t encoder_id,
                                          std::vector<drmModeModeInfo>& modes,
                                          std::vector<uint32_t>& possible_encoder_ids,
                                          geom::Size const& physical_size,
                                          drmModeSubPixel subpixel_arrangement)
{
    drmModeConnector connector = drmModeConnector();

    connector.connector_id = connector_id;
    connector.connector_type = type;
    connector.connection = connection;
    connector.encoder_id = encoder_id;
    connector.modes = modes.data();
    connector.count_modes = modes.size();
    connector.encoders = possible_encoder_ids.data();
    connector.count_encoders = possible_encoder_ids.size();
    connector.mmWidth = physical_size.width.as_uint32_t();
    connector.mmHeight = physical_size.height.as_uint32_t();
    connector.subpixel = subpixel_arrangement;

    connectors.push_back(connector);
}

drmModeCrtc* mtd::FakeDRMResources::find_crtc(uint32_t id)
{
    for (auto& crtc : crtcs)
    {
        if (crtc.crtc_id == id)
            return &crtc;
    }
    return nullptr;
}

drmModeEncoder* mtd::FakeDRMResources::find_encoder(uint32_t id)
{
    for (auto& encoder : encoders)
    {
        if (encoder.encoder_id == id)
            return &encoder;
    }
    return nullptr;
}

drmModeConnector* mtd::FakeDRMResources::find_connector(uint32_t id)
{
    for (auto& connector : connectors)
    {
        if (connector.connector_id == id)
            return &connector;
    }
    return nullptr;
}


drmModeModeInfo mtd::FakeDRMResources::create_mode(uint16_t hdisplay, uint16_t vdisplay,
                                                   uint32_t clock, uint16_t htotal,
                                                   uint16_t vtotal,
                                                   ModePreference preferred)
{
    drmModeModeInfo mode = drmModeModeInfo();

    mode.hdisplay = hdisplay;
    mode.vdisplay = vdisplay;
    mode.clock = clock;
    mode.htotal = htotal;
    mode.vtotal = vtotal;

    uint32_t total = htotal;
    total *= vtotal;  // extend to 32 bits
    mode.vrefresh = clock * 1000UL / total;

    if (preferred)
        mode.type |= DRM_MODE_TYPE_PREFERRED;

    return mode;
}

mtd::MockDRM::MockDRM()
    : open_interposer{mir_test_framework::add_open_handler(
        [this](char const* path, int flags, std::optional<mode_t>) -> std::optional<int>
        {
            char const* const drm_prefix = "/dev/dri/";
            if (!strncmp(path, drm_prefix, strlen(drm_prefix)))
            {
                // I don't think we need to be able to distinguish based on mode. ppc64el (at least) *does*
                // call the 3-parameter open()
                return this->open(path, flags);
            }
            return std::nullopt;
        })},
      mmap_interposer{mir_test_framework::add_mmap_handler(
        [this](void* addr, size_t length, int prot, int flags, int fd, off_t offset) -> std::optional<void*>
        {
            // The dumb buffer API uses a call of mmap() on the DRM fd, so we want to handle that.
            if (this->fd_to_drm.contains(fd))
            {
                return this->mmap(addr, length, prot, flags, fd, offset);
            }
            return std::nullopt;
        })},
      munmap_interposer{mir_test_framework::add_munmap_handler(
        [this](void* addr, size_t length) -> std::optional<int>
        {
            auto maybe_mapping = mmapings.find(addr);
            if (maybe_mapping != mmapings.end())
            {
                if (maybe_mapping->second != length)
                {
                    /* It's technically possible to unmap only *part* of the mapping
                     * A more fancy mock would check whether addr + length overlaps
                     * any existing mappings and punch holes, but 🤷‍♀️
                     */
                    BOOST_THROW_EXCEPTION((std::runtime_error{"munmap mock does not support partial unmappings"}));
                }
                return this->munmap(addr, length);
            }
            return std::nullopt;
        })}
{
    using namespace testing;
    assert(global_mock == NULL && "Only one mock object per process is allowed");

    global_mock = this;

    memset(&empty_object_props, 0, sizeof(empty_object_props));

    ON_CALL(*this, open(_,_))
        .WillByDefault(
            WithArg<0>(
                Invoke(
                    [this](char const* device_path)
                    {
                        auto fd = fake_drms[device_path].fd();
                        fd_to_drm.insert({fd, fake_drms[device_path]});
                        return fd;
                    })));

    ON_CALL(*this, drmOpen(_,_))
        .WillByDefault(
            InvokeWithoutArgs(
                [this]()
                {
                    auto fd = fake_drms["/dev/dri/card0"].fd();
                    fd_to_drm.insert({fd, fake_drms["/dev/dri/card0"]});
                    return fd;
                }));

    ON_CALL(*this, drmModeGetResources(_))
        .WillByDefault(
            Invoke(
                [this](int fd)
                {
                    return fd_to_drm.at(fd).resources_ptr();
                }));

    ON_CALL(*this, drmModeGetCrtc(_, _))
        .WillByDefault(
            Invoke(
                [this](int fd, uint32_t crtc_id)
                {
                    return fd_to_drm.at(fd).find_crtc(crtc_id);
                }));

    ON_CALL(*this, drmModeGetEncoder(_, _))
        .WillByDefault(
            Invoke(
                [this](int fd, uint32_t encoder_id)
                {
                    return fd_to_drm.at(fd).find_encoder(encoder_id);
                }));

    ON_CALL(*this, drmModeGetConnector(_, _))
        .WillByDefault(
            Invoke(
                [this](int fd, uint32_t connector_id)
                {
                    return fd_to_drm.at(fd).find_connector(connector_id);
                }));

    ON_CALL(*this, drmModeObjectGetProperties(_, _, _))
        .WillByDefault(Return(&empty_object_props));

    ON_CALL(*this, drmSetInterfaceVersion(_, _))
        .WillByDefault(
            Invoke(
                [this](auto fd, auto version)
                {
                    if (version->drm_di_major != 1 || version->drm_di_minor != 4)
                    {
                        ADD_FAILURE() << "We should only ever request DRM version 1.4";
                        errno = EINVAL;
                        return -1;
                    }

                    fd_to_drm.at(fd).drm_setversion_called = true;
                    return 0;
                }));

    ON_CALL(*this, drmGetBusid(_))
        .WillByDefault(
            Invoke(
                [this](auto fd) -> char*
                {
                    if (!fd_to_drm.at(fd).drm_setversion_called)
                    {
                        return nullptr;
                    }
                    return static_cast<char*>(malloc(10));
                }));

    ON_CALL(*this, drmFreeBusid(_))
        .WillByDefault(WithArg<0>(Invoke([&](const char* busid) { free(const_cast<char*>(busid)); })));

    ON_CALL(*this, drmGetPrimaryDeviceNameFromFd(_))
        .WillByDefault(InvokeWithoutArgs([]() { return strdup("/dev/dri/card0"); }));

    static drmVersion const version{
        1,
        2,
        3,
        static_cast<int>(strlen("mock_driver")),
        const_cast<char*>("mock_driver"),
        static_cast<int>(strlen("1 Jan 1970")),
        const_cast<char*>("1 Jan 1970"),
        static_cast<int>(strlen("Not really a driver")),
        const_cast<char*>("Not really a driver")
    };
    ON_CALL(*this, drmGetVersion(_))
        .WillByDefault(Return(const_cast<drmVersionPtr>(&version)));

    ON_CALL(*this, drmCheckModesettingSupported(NotNull()))
        .WillByDefault(Return(0));
    ON_CALL(*this, drmCheckModesettingSupported(IsNull()))
        .WillByDefault(Return(-EINVAL));

    ON_CALL(*this, mmap(_, _, _, _, _, _))
        .WillByDefault(
            WithArg<1>(Invoke(
                [this](auto size) -> void*
                {
                    auto allocation = std::make_unique<char[]>(size);
                    void* const address = allocation.get();
                    mmapings.insert(std::make_pair(std::move(allocation), size));
                    return address;
                })));

    ON_CALL(*this, munmap(_, _))
        .WillByDefault(
            WithArg<0>(Invoke(
                [this](void* addr) -> int
                {
                    auto iter = mmapings.find(addr);
                    mmapings.erase(iter);
                    return 0;
                })));

    ON_CALL(*this, drmGetCap(_, DRM_CAP_DUMB_BUFFER, _))
        .WillByDefault(
            [](auto, auto, uint64_t* value)
            {
                *value = 1;
                return 0;
            });
}

mtd::MockDRM::~MockDRM() noexcept
{
    global_mock = nullptr;
}

void mtd::MockDRM::add_crtc(char const *device, uint32_t id, drmModeModeInfo mode)
{
    fake_drms[device].add_crtc(id, mode);
}

void mtd::MockDRM::add_encoder(
    char const *device,
    uint32_t encoder_id,
    uint32_t crtc_id,
    uint32_t possible_crtcs_mask)
{
    fake_drms[device].add_encoder(encoder_id, crtc_id, possible_crtcs_mask);
}

void mtd::MockDRM::prepare(char const *device)
{
    fake_drms[device].prepare();
}

void mtd::MockDRM::reset(char const *device)
{
    fake_drms[device].reset();
}

void mtd::MockDRM::generate_event_on(char const *device)
{
    auto const fd = fake_drms[device].write_fd();

    if (write(fd, "a", 1) != 1)
    {
        BOOST_THROW_EXCEPTION(
            std::system_error(errno, std::system_category(), "Failed to make fake DRM event"));
    }
}

void mtd::MockDRM::consume_event_on(char const* device)
{
    auto const fd = fake_drms[device].fd();

    char consume_buf;
    if (::read(fd, &consume_buf, 1) != 1)
    {
        BOOST_THROW_EXCEPTION(
            std::system_error(errno, std::system_category(), "Failed to consume fake DRM event"));
    }
}

void mtd::MockDRM::add_connector(
    char const *device,
    uint32_t connector_id,
    uint32_t type,
    drmModeConnection connection,
    uint32_t encoder_id,
    std::vector<drmModeModeInfo> &modes,
    std::vector<uint32_t> &possible_encoder_ids,
    geometry::Size const &physical_size,
    drmModeSubPixel subpixel_arrangement)
{
    fake_drms[device].add_connector(
        connector_id,
        type,
        connection,
        encoder_id,
        modes,
        possible_encoder_ids,
        physical_size,
        subpixel_arrangement);
}

MATCHER_P2(IsFdOfDevice, devname, fds, "")
{
    return std::find(
        fds.begin(),
        fds.end(),
        arg) != fds.end();
}

class mtd::MockDRM::IsFdOfDeviceMatcher : public ::testing::MatcherInterface<int>
{
public:
    IsFdOfDeviceMatcher(char const* device)
        : device{device}
    {
    }

    void DescribeTo(::std::ostream *os) const override
    {

        *os
            << "Is an fd of DRM device "
            << device
            << " (one of: "
            << ::testing::PrintToString(fds_for_device(device.c_str()))
            << ")";
    }

    bool MatchAndExplain(int x, testing::MatchResultListener *listener) const override
    {
        testing::Matcher<std::vector<int>> matcher = testing::Contains(x);
        return matcher.MatchAndExplain(fds_for_device(device.c_str()), listener);
    }

private:
    std::vector<int> fds_for_device(char const* device) const
    {
        std::vector<int> device_fds;
        for (auto const& pair : global_mock->fd_to_drm)
        {
            if (&global_mock->fake_drms[device] == &pair.second)
            {
                device_fds.push_back(pair.first);
            }
        }
        return device_fds;
    }

    std::string const device;
};

testing::Matcher<int> mtd::IsFdOfDevice(char const* device)
{
    return ::testing::MakeMatcher(new mtd::MockDRM::IsFdOfDeviceMatcher(device));
}

// The signature of drmModeCrtcSetGamma() changes from passing the gamma as `uint16_t*` to `uint16_t const*`
// We need to provide a definition that matches
namespace
{
template<typename Any>
struct Decode_drmModeCrtcSetGamma_signature;

template<typename Arg>
struct Decode_drmModeCrtcSetGamma_signature<int(int fd, uint32_t crtc_id, uint32_t size, Arg red, Arg gree, Arg blue)>
{
    using gamma_t = Arg;
};
using gamma_t = Decode_drmModeCrtcSetGamma_signature<decltype(drmModeCrtcSetGamma)>::gamma_t;
}

// Ensure we get a compile error if the definition doesn't match the declaration (instead of providing an overload)
extern "C"
{
int drmOpen(const char *name, const char *busid)
{
    return global_mock->drmOpen(name, busid);
}

int drmIoctl(int fd, unsigned long request, void *arg)
{
    return global_mock->drmIoctl(fd, request, arg);
}

drmModeResPtr drmModeGetResources(int fd)
{
    return global_mock->drmModeGetResources(fd);
}

drmModeConnectorPtr drmModeGetConnector(int fd, uint32_t connectorId)
{
    return global_mock->drmModeGetConnector(fd, connectorId);
}

drmModeEncoderPtr drmModeGetEncoder(int fd, uint32_t encoder_id)
{
    return global_mock->drmModeGetEncoder(fd, encoder_id);
}

drmModePlaneResPtr drmModeGetPlaneResources(int fd)
{
    return global_mock->drmModeGetPlaneResources(fd);
}

drmModePlanePtr drmModeGetPlane(int fd, uint32_t plane_id)
{
    return global_mock->drmModeGetPlane(fd, plane_id);
}

drmModeObjectPropertiesPtr drmModeObjectGetProperties(int fd, uint32_t id, uint32_t type)
{
    return global_mock->drmModeObjectGetProperties(fd, id, type);
}

drmModeCrtcPtr drmModeGetCrtc(int fd, uint32_t crtcId)
{
    return global_mock->drmModeGetCrtc(fd, crtcId);
}

int drmModeSetCrtc(int fd, uint32_t crtcId, uint32_t bufferId,
                   uint32_t x, uint32_t y, uint32_t *connectors, int count,
                   drmModeModeInfoPtr mode)
{
    return global_mock->drmModeSetCrtc(fd, crtcId, bufferId, x, y,
                                       connectors, count, mode);
}

int drmModeCrtcGetGamma(int fd, uint32_t crtc_id, uint32_t size,
                        uint16_t* red, uint16_t* green, uint16_t* blue)
{
    return global_mock->drmModeCrtcGetGamma(fd, crtc_id, size, red, green, blue);
}

int drmModeCrtcSetGamma(int fd, uint32_t crtc_id, uint32_t size, gamma_t red, gamma_t green, gamma_t blue)
{
    return global_mock->drmModeCrtcSetGamma(fd, crtc_id, size, red, green, blue);
}

void drmModeFreeResources(drmModeResPtr ptr)
{
    global_mock->drmModeFreeResources(ptr);
}

void drmModeFreeProperty(drmModePropertyPtr ptr)
{
    global_mock->drmModeFreeProperty(ptr);
}

int drmGetCap(int fd, uint64_t capability, uint64_t *value)
{
    return global_mock->drmGetCap(fd, capability, value);
}

drmVersionPtr drmGetVersion(int fd)
{
    return global_mock->drmGetVersion(fd);
}

void drmFreeVersion(drmVersionPtr version)
{
    return global_mock->drmFreeVersion(version);
}

int drmSetClientCap(int fd, uint64_t capability, uint64_t value)
{
    return global_mock->drmSetClientCap(fd, capability, value);
}

drmModePropertyPtr drmModeGetProperty(int fd, uint32_t propertyId)
{
    return global_mock->drmModeGetProperty(fd, propertyId);
}

int drmModeConnectorSetProperty(int fd, uint32_t connector_id, uint32_t property_id, uint64_t value)
{
    return global_mock->drmModeConnectorSetProperty(fd, connector_id, property_id, value);
}

void drmModeFreeConnector(drmModeConnectorPtr ptr)
{
    global_mock->drmModeFreeConnector(ptr);
}

void drmModeFreeEncoder(drmModeEncoderPtr ptr)
{
    global_mock->drmModeFreeEncoder(ptr);
}

void drmModeFreeCrtc(drmModeCrtcPtr ptr)
{
    global_mock->drmModeFreeCrtc(ptr);
}

void drmModeFreePlaneResources(drmModePlaneResPtr ptr)
{
    global_mock->drmModeFreePlaneResources(ptr);
}

void drmModeFreePlane(drmModePlanePtr ptr)
{
    global_mock->drmModeFreePlane(ptr);
}

void drmModeFreeObjectProperties(drmModeObjectPropertiesPtr ptr)
{
    global_mock->drmModeFreeObjectProperties(ptr);
}

int drmModeAddFB(int fd, uint32_t width, uint32_t height,
                 uint8_t depth, uint8_t bpp, uint32_t pitch,
                 uint32_t bo_handle, uint32_t *buf_id)
{

    return global_mock->drmModeAddFB(fd, width, height, depth, bpp,
                                     pitch, bo_handle, buf_id);
}

int drmModeAddFB2(int fd, uint32_t width, uint32_t height,
                  uint32_t pixel_format, uint32_t const bo_handles[4],
                  uint32_t const pitches[4], uint32_t const offsets[4],
                  uint32_t* buf_id, uint32_t flags)
{
    return global_mock->drmModeAddFB2(fd, width, height, pixel_format,
                                      bo_handles, pitches, offsets,
                                      buf_id, flags);
}

int drmModeAddFB2WithModifiers(
    int fd,
    uint32_t width,
    uint32_t height,
    uint32_t fourcc,
    uint32_t const handles[4],
    uint32_t const pitches[4],
    uint32_t const offsets[4],
    uint64_t const modifiers[4],
    uint32_t *buf_id,
    uint32_t flags)
{
    return global_mock->drmModeAddFB2WithModifiers(
        fd, width, height, fourcc, handles, pitches, offsets, modifiers, buf_id, flags);
}

int drmModeRmFB(int fd, uint32_t bufferId)
{
    return global_mock->drmModeRmFB(fd, bufferId);
}


int drmModePageFlip(int fd, uint32_t crtc_id, uint32_t fb_id,
                    uint32_t flags, void *user_data)
{
    return global_mock->drmModePageFlip(fd, crtc_id, fb_id,
                                        flags, user_data);
}

int drmHandleEvent(int fd, drmEventContextPtr evctx)
{
    return global_mock->drmHandleEvent(fd, evctx);
}

int drmGetMagic(int fd, drm_magic_t *magic)
{
    return global_mock->drmGetMagic(fd, magic);
}

int drmAuthMagic(int fd, drm_magic_t magic)
{
    return global_mock->drmAuthMagic(fd, magic);
}

int drmPrimeHandleToFD(int fd, uint32_t handle, uint32_t flags, int *prime_fd)
{
    return global_mock->drmPrimeHandleToFD(fd, handle, flags, prime_fd);
}

int drmPrimeFDToHandle(int fd, int prime_fd, uint32_t *handle)
{
    return global_mock->drmPrimeFDToHandle(fd, prime_fd, handle);
}

int drmIsMaster(int fd)
{
    return global_mock->drmIsMaster(fd);
}

int drmSetMaster(int fd)
{
    return global_mock->drmSetMaster(fd);
}

int drmDropMaster(int fd)
{
    return global_mock->drmDropMaster(fd);
}

int drmModeSetCursor(int fd, uint32_t crtcId, uint32_t bo_handle, uint32_t width, uint32_t height)
{
    return global_mock->drmModeSetCursor(fd, crtcId, bo_handle, width, height);
}

int drmModeMoveCursor(int fd, uint32_t crtcId, int x, int y)
{
    return global_mock->drmModeMoveCursor(fd, crtcId, x, y);
}

int drmSetInterfaceVersion(int fd, drmSetVersion* sv)
{
    return global_mock->drmSetInterfaceVersion(fd, sv);
}

char* drmGetBusid(int fd)
{
    return global_mock->drmGetBusid(fd);
}

void drmFreeBusid(const char* busid)
{
    return global_mock->drmFreeBusid(busid);
}

char* drmGetDeviceNameFromFd(int fd)
{
    return global_mock->drmGetDeviceNameFromFd(fd);
}

char* drmGetPrimaryDeviceNameFromFd(int fd)
{
    return global_mock->drmGetPrimaryDeviceNameFromFd(fd);
}

int drmCheckModesettingSupported(char const* busid)
{
    return global_mock->drmCheckModesettingSupported(busid);
}
}