28 #if HAVE_LINUX_DMA_BUF_H
29 #include <linux/dma-buf.h>
30 #include <sys/ioctl.h>
56 hwctx->
fd = open(device, O_RDWR);
63 "from %s: probably not a DRM device?\n", device);
69 "version %d.%d.%d.\n", device,
version->name,
109 for (
int i = 0;
i <
map->nb_regions;
i++) {
110 #if HAVE_LINUX_DMA_BUF_H
111 struct dma_buf_sync sync = { .flags = DMA_BUF_SYNC_END |
map->sync_flags };
112 ioctl(
map->object[
i], DMA_BUF_IOCTL_SYNC, &sync);
114 munmap(
map->address[
i],
map->length[
i]);
125 struct dma_buf_sync sync_start = { 0 };
128 int err,
i, p, plane;
138 mmap_prot |= PROT_READ;
140 mmap_prot |= PROT_WRITE;
142 #if HAVE_LINUX_DMA_BUF_H
144 map->sync_flags |= DMA_BUF_SYNC_READ;
146 map->sync_flags |= DMA_BUF_SYNC_WRITE;
147 sync_start.flags = DMA_BUF_SYNC_START |
map->sync_flags;
151 for (
i = 0;
i <
desc->nb_objects;
i++) {
152 addr = mmap(
NULL,
desc->objects[
i].size, mmap_prot, MAP_SHARED,
153 desc->objects[
i].fd, 0);
154 if (addr == MAP_FAILED) {
157 "memory: %d.\n",
desc->objects[
i].fd, errno);
161 map->address[
i] = addr;
165 #if HAVE_LINUX_DMA_BUF_H
168 ioctl(
desc->objects[
i].fd, DMA_BUF_IOCTL_SYNC, &sync_start);
174 for (
i = 0;
i <
desc->nb_layers;
i++) {
186 dst->width =
src->width;
187 dst->height =
src->height;
197 for (
i = 0;
i <
desc->nb_objects;
i++) {
199 munmap(
map->address[
i],
map->length[
i]);
265 map->format =
src->format;
273 map->height =
src->height;
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
#define flags(name, subs,...)
#define HAVE_LINUX_DMA_BUF_H
AVBufferRef * av_buffer_pool_get(AVBufferPool *pool)
Allocate a new AVBuffer, reusing an old buffer from the pool when available.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
int av_frame_copy(AVFrame *dst, const AVFrame *src)
Copy the frame data from src to dst.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
int ff_hwframe_map_create(AVBufferRef *hwframe_ref, AVFrame *dst, const AVFrame *src, void(*unmap)(AVHWFramesContext *ctx, HWMapDescriptor *hwmap), void *priv)
AVHWFrameTransferDirection
@ AV_HWFRAME_MAP_READ
The mapping must be readable.
@ AV_HWFRAME_MAP_WRITE
The mapping must be writeable.
@ AV_HWFRAME_MAP_OVERWRITE
The mapped frame will be overwritten completely in subsequent operations, so the current frame data n...
static int drm_map_frame(AVHWFramesContext *hwfc, AVFrame *dst, const AVFrame *src, int flags)
static int drm_transfer_get_formats(AVHWFramesContext *ctx, enum AVHWFrameTransferDirection dir, enum AVPixelFormat **formats)
static int drm_transfer_data_to(AVHWFramesContext *hwfc, AVFrame *dst, const AVFrame *src)
static void drm_device_free(AVHWDeviceContext *hwdev)
static void drm_unmap_frame(AVHWFramesContext *hwfc, HWMapDescriptor *hwmap)
static int drm_device_create(AVHWDeviceContext *hwdev, const char *device, AVDictionary *opts, int flags)
const HWContextType ff_hwcontext_type_drm
static int drm_map_from(AVHWFramesContext *hwfc, AVFrame *dst, const AVFrame *src, int flags)
static int drm_get_buffer(AVHWFramesContext *hwfc, AVFrame *frame)
static int drm_transfer_data_from(AVHWFramesContext *hwfc, AVFrame *dst, const AVFrame *src)
API-specific header for AV_HWDEVICE_TYPE_DRM.
@ AV_DRM_MAX_PLANES
The maximum number of layers/planes in a DRM frame.
const VDPAUPixFmtMap * map
static enum AVPixelFormat pix_fmts[]
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_DRM_PRIME
DRM-managed buffers exposed through PRIME buffer sharing.
uint8_t * data
The data buffer.
int fd
File descriptor of DRM device.
AVDRMPlaneDescriptor planes[AV_DRM_MAX_PLANES]
Array of planes in this layer.
int nb_planes
Number of planes in the layer.
ptrdiff_t pitch
Pitch (linesize) of this plane.
int object_index
Index of the object containing this plane in the objects array of the enclosing frame descriptor.
ptrdiff_t offset
Offset within that object of this plane.
This structure describes decoded (raw) audio or video data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
void * hwctx
The format-specific data, allocated and freed by libavutil along with this context.
void(* free)(struct AVHWDeviceContext *ctx)
This field may be set by the caller before calling av_hwdevice_ctx_init().
This struct describes a set or pool of "hardware" frames (i.e.
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
int width
The allocated dimensions of the frames in this pool.
AVBufferPool * pool
A pool from which the frames are allocated by av_hwframe_get_buffer().
void * address[AV_DRM_MAX_PLANES]
size_t length[AV_DRM_MAX_PLANES]
void * priv
Hardware-specific private data associated with the mapping.
#define av_malloc_array(a, b)