chen.wang1 | d548345 | 2024-02-28 06:18:16 +0000 | [diff] [blame] | 1 | /* SPDX-License-Identifier: MIT */ |
| 2 | /* |
| 3 | * Copyright © 2019-2022 Amlogic Inc. |
| 4 | */ |
Ao Xu | 0733c43 | 2018-11-02 17:35:02 +0800 | [diff] [blame] | 5 | #ifndef _MESON_DRM_H |
| 6 | #define _MESON_DRM_H |
Yalong Liu | bdcf912 | 2018-01-19 18:35:02 +0800 | [diff] [blame] | 7 | |
Ao Xu | 0733c43 | 2018-11-02 17:35:02 +0800 | [diff] [blame] | 8 | #include <drm/drm.h> |
| 9 | |
| 10 | /* Use flags */ |
| 11 | #define MESON_USE_NONE 0 |
| 12 | #define MESON_USE_SCANOUT (1ull << 0) |
| 13 | #define MESON_USE_CURSOR (1ull << 1) |
| 14 | #define MESON_USE_RENDERING (1ull << 2) |
| 15 | #define MESON_USE_LINEAR (1ull << 3) |
| 16 | #define MESON_USE_PROTECTED (1ull << 11) |
| 17 | #define MESON_USE_HW_VIDEO_ENCODER (1ull << 12) |
| 18 | #define MESON_USE_CAMERA_WRITE (1ull << 13) |
| 19 | #define MESON_USE_CAMERA_READ (1ull << 14) |
| 20 | #define MESON_USE_TEXTURE (1ull << 17) |
Ao Xu | 6fbd032 | 2020-04-14 18:08:22 +0800 | [diff] [blame] | 21 | #define MESON_USE_VIDEO_PLANE (1ull << 18) |
| 22 | #define MESON_USE_VIDEO_AFBC (1ull << 19) |
Ao Xu | 6747bbd | 2020-09-28 20:02:09 +0800 | [diff] [blame] | 23 | #define MESON_USE_VD1 (1ull << 20) |
| 24 | #define MESON_USE_VD2 (1ull << 21) |
Yalong Liu | bdcf912 | 2018-01-19 18:35:02 +0800 | [diff] [blame] | 25 | |
| 26 | /** |
| 27 | * User-desired buffer creation information structure. |
| 28 | * |
| 29 | * @size: user-desired memory allocation size. |
Yalong Liu | bdcf912 | 2018-01-19 18:35:02 +0800 | [diff] [blame] | 30 | * @flags: user request for setting memory type or cache attributes. |
| 31 | * @handle: returned a handle to created gem object. |
Ao Xu | 0733c43 | 2018-11-02 17:35:02 +0800 | [diff] [blame] | 32 | * - this handle will be set by gem module of kernel side. |
Yalong Liu | bdcf912 | 2018-01-19 18:35:02 +0800 | [diff] [blame] | 33 | */ |
Yalong Liu | 22dc0a5 | 2018-02-22 10:27:20 +0800 | [diff] [blame] | 34 | struct drm_meson_gem_create { |
Ao Xu | 0733c43 | 2018-11-02 17:35:02 +0800 | [diff] [blame] | 35 | __u64 size; |
| 36 | __u32 flags; |
| 37 | __u32 handle; |
Yalong Liu | bdcf912 | 2018-01-19 18:35:02 +0800 | [diff] [blame] | 38 | }; |
chen.wang1 | d548345 | 2024-02-28 06:18:16 +0000 | [diff] [blame] | 39 | /** |
| 40 | * struct drm_meson_dma_buf_export_sync_file - Get a sync_file from a dma-buf |
| 41 | * |
| 42 | * Userspace can perform a DMA_BUF_IOCTL_EXPORT_SYNC_FILE to retrieve the |
| 43 | * current set of fences on a dma-buf file descriptor as a sync_file. CPU |
| 44 | * waits via poll() or other driver-specific mechanisms typically wait on |
| 45 | * whatever fences are on the dma-buf at the time the wait begins. This |
| 46 | * is similar except that it takes a snapshot of the current fences on the |
| 47 | * dma-buf for waiting later instead of waiting immediately. This is |
| 48 | * useful for modern graphics APIs such as Vulkan which assume an explicit |
| 49 | * synchronization model but still need to inter-operate with dma-buf. |
| 50 | */ |
| 51 | struct drm_meson_dma_buf_export_sync_file { |
| 52 | /** |
| 53 | * @flags: Read/write flags |
| 54 | * |
| 55 | * Must be DMA_BUF_SYNC_READ, DMA_BUF_SYNC_WRITE, or both. |
| 56 | * |
| 57 | * If DMA_BUF_SYNC_READ is set and DMA_BUF_SYNC_WRITE is not set, |
| 58 | * the returned sync file waits on any writers of the dma-buf to |
| 59 | * complete. Waiting on the returned sync file is equivalent to |
| 60 | * poll() with POLLIN. |
| 61 | * |
| 62 | * If DMA_BUF_SYNC_WRITE is set, the returned sync file waits on |
| 63 | * any users of the dma-buf (read or write) to complete. Waiting |
| 64 | * on the returned sync file is equivalent to poll() with POLLOUT. |
| 65 | * If both DMA_BUF_SYNC_WRITE and DMA_BUF_SYNC_READ are set, this |
| 66 | * is equivalent to just DMA_BUF_SYNC_WRITE. |
| 67 | */ |
| 68 | __u32 flags; |
| 69 | __u32 dmabuf_fd; |
| 70 | /** @fd: Returned sync file descriptor */ |
| 71 | __s32 fd; |
| 72 | }; |
Yalong Liu | bdcf912 | 2018-01-19 18:35:02 +0800 | [diff] [blame] | 73 | |
chen.wang1 | d548345 | 2024-02-28 06:18:16 +0000 | [diff] [blame] | 74 | struct drm_meson_video_zpos_target { |
chen.wang1 | 33a5c83 | 2023-07-12 04:23:36 +0000 | [diff] [blame] | 75 | __u32 index; |
| 76 | __u32 zpos; |
| 77 | __u32 flag; |
| 78 | }; |
chen.wang1 | d548345 | 2024-02-28 06:18:16 +0000 | [diff] [blame] | 79 | |
| 80 | struct drm_meson_plane_mute { |
| 81 | int plane_type; /* 0:osd plane, 1:video plane */ |
| 82 | int plane_mute; /* 0:umute plane, 1:mute plane */ |
| 83 | }; |
| 84 | |
| 85 | struct drm_mode_test_attr { |
| 86 | char modename[32]; |
| 87 | char attr[32]; |
| 88 | __u32 valid; |
| 89 | }; |
| 90 | /*hdmitx relatde*/ |
| 91 | #define DRM_IOCTL_MESON_TESTATTR DRM_IOWR(DRM_COMMAND_BASE + \ |
| 92 | 0x11, struct drm_mode_test_attr) |
| 93 | |
chen.wang1 | 33a5c83 | 2023-07-12 04:23:36 +0000 | [diff] [blame] | 94 | |
sky zhou | f05ca46 | 2020-10-29 18:07:40 +0800 | [diff] [blame] | 95 | /*Memory related.*/ |
Ao Xu | 0733c43 | 2018-11-02 17:35:02 +0800 | [diff] [blame] | 96 | #define DRM_IOCTL_MESON_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + \ |
sky zhou | f05ca46 | 2020-10-29 18:07:40 +0800 | [diff] [blame] | 97 | 0x00, struct drm_meson_gem_create) |
chen.wang1 | d548345 | 2024-02-28 06:18:16 +0000 | [diff] [blame] | 98 | #define DRM_IOCTL_MESON_DMABUF_EXPORT_SYNC_FILE DRM_IOWR(DRM_COMMAND_BASE + \ |
| 99 | 0x02, struct drm_meson_dma_buf_export_sync_file) |
| 100 | |
wenlong.zhang | 7d32ed9 | 2023-04-12 06:08:17 +0000 | [diff] [blame] | 101 | #define DRM_IOCTL_MESON_RMFB DRM_IOWR(DRM_COMMAND_BASE + \ |
| 102 | 0x01, unsigned int) |
sky zhou | f05ca46 | 2020-10-29 18:07:40 +0800 | [diff] [blame] | 103 | |
| 104 | /*KMS related.*/ |
| 105 | #define DRM_IOCTL_MESON_ASYNC_ATOMIC DRM_IOWR(DRM_COMMAND_BASE + \ |
| 106 | 0x10, struct drm_mode_atomic) |
chen.wang1 | d548345 | 2024-02-28 06:18:16 +0000 | [diff] [blame] | 107 | |
chen.wang1 | 33a5c83 | 2023-07-12 04:23:36 +0000 | [diff] [blame] | 108 | #define DRM_IOCTL_MESON_SET_VIDEO_ZPOS DRM_IOWR(DRM_COMMAND_BASE + \ |
| 109 | 0x11, struct drm_meson_video_zpos_target) |
chen.wang1 | d548345 | 2024-02-28 06:18:16 +0000 | [diff] [blame] | 110 | #define DRM_IOCTL_MESON_MUTE_PLANE DRM_IOWR(DRM_COMMAND_BASE + \ |
| 111 | 0x12, struct drm_meson_plane_mute) |
| 112 | |
Ao Xu | 0733c43 | 2018-11-02 17:35:02 +0800 | [diff] [blame] | 113 | #endif /* _MESON_DRM_H */ |