1d722e3fbSopenharmony_ci/*
2d722e3fbSopenharmony_ci * Copyright © 2014 NVIDIA Corporation
3d722e3fbSopenharmony_ci *
4d722e3fbSopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
5d722e3fbSopenharmony_ci * copy of this software and associated documentation files (the "Software"),
6d722e3fbSopenharmony_ci * to deal in the Software without restriction, including without limitation
7d722e3fbSopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8d722e3fbSopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
9d722e3fbSopenharmony_ci * Software is furnished to do so, subject to the following conditions:
10d722e3fbSopenharmony_ci *
11d722e3fbSopenharmony_ci * The above copyright notice and this permission notice shall be included in
12d722e3fbSopenharmony_ci * all copies or substantial portions of the Software.
13d722e3fbSopenharmony_ci *
14d722e3fbSopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15d722e3fbSopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16d722e3fbSopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17d722e3fbSopenharmony_ci * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18d722e3fbSopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19d722e3fbSopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20d722e3fbSopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE.
21d722e3fbSopenharmony_ci */
22d722e3fbSopenharmony_ci
23d722e3fbSopenharmony_ci#ifndef TEGRA_DRM_TEST_H
24d722e3fbSopenharmony_ci#define TEGRA_DRM_TEST_H
25d722e3fbSopenharmony_ci
26d722e3fbSopenharmony_ci#include <stdint.h>
27d722e3fbSopenharmony_ci#include <stdlib.h>
28d722e3fbSopenharmony_ci
29d722e3fbSopenharmony_ci#include "xf86drmMode.h"
30d722e3fbSopenharmony_ci
31d722e3fbSopenharmony_cistruct drm_screen {
32d722e3fbSopenharmony_ci    int fd;
33d722e3fbSopenharmony_ci
34d722e3fbSopenharmony_ci    unsigned int width;
35d722e3fbSopenharmony_ci    unsigned int height;
36d722e3fbSopenharmony_ci    unsigned int pitch;
37d722e3fbSopenharmony_ci    unsigned int depth;
38d722e3fbSopenharmony_ci    unsigned int bpp;
39d722e3fbSopenharmony_ci
40d722e3fbSopenharmony_ci    drmModeModeInfo mode;
41d722e3fbSopenharmony_ci    uint32_t connector;
42d722e3fbSopenharmony_ci    uint32_t old_fb;
43d722e3fbSopenharmony_ci    uint32_t format;
44d722e3fbSopenharmony_ci    uint32_t crtc;
45d722e3fbSopenharmony_ci};
46d722e3fbSopenharmony_ci
47d722e3fbSopenharmony_cistruct drm_framebuffer {
48d722e3fbSopenharmony_ci    unsigned int width;
49d722e3fbSopenharmony_ci    unsigned int height;
50d722e3fbSopenharmony_ci    unsigned int pitch;
51d722e3fbSopenharmony_ci    uint32_t format;
52d722e3fbSopenharmony_ci    uint32_t handle;
53d722e3fbSopenharmony_ci    void *data;
54d722e3fbSopenharmony_ci    int fd;
55d722e3fbSopenharmony_ci};
56d722e3fbSopenharmony_ci
57d722e3fbSopenharmony_ciint drm_screen_open(struct drm_screen **screenp, int fd);
58d722e3fbSopenharmony_ciint drm_screen_close(struct drm_screen *screen);
59d722e3fbSopenharmony_ciint drm_screen_set_framebuffer(struct drm_screen *screen,
60d722e3fbSopenharmony_ci                               struct drm_framebuffer *fb);
61d722e3fbSopenharmony_ci
62d722e3fbSopenharmony_ciint drm_framebuffer_new(struct drm_framebuffer **fbp,
63d722e3fbSopenharmony_ci                        struct drm_screen *screen, uint32_t handle,
64d722e3fbSopenharmony_ci                        unsigned int width, unsigned int height,
65d722e3fbSopenharmony_ci                        unsigned int pitch, uint32_t format,
66d722e3fbSopenharmony_ci                        void *data);
67d722e3fbSopenharmony_ciint drm_framebuffer_free(struct drm_framebuffer *fb);
68d722e3fbSopenharmony_ci
69d722e3fbSopenharmony_ciint drm_open(const char *path);
70d722e3fbSopenharmony_civoid drm_close(int fd);
71d722e3fbSopenharmony_ci
72d722e3fbSopenharmony_ci#endif
73