When client queued a buffer, v4l2 framework compares the client Dmabuf with the existing dmabuf in the bufs array at the same index. If the dmabuf is different then v4l2 framework would call unmap_dmabuf, detach_dmabuf callbacks for the old buffer and then calls attach_dmabuf, map_dmabuf callbacks for the new buffer before qbuf callback is made to driver. If the dmabuf is same then qbuf callback will be made directly. V4l2 framework expects that clients recycles the same buffers in the same indices so that when v4l2 framework compares dmabuf it won't unmap or map buffers. If client recycle the buffers in different indices still usecase works but there will be unnecessary unmap, map overhead will be incurred. If client does not recycle the buffers at all, meaning every time client queues new buffers then special handling is required for decoder output buffers which are used for reference by video hardware.If any buffers are used by video hardware as reference buffers then firmware returns those buffers with READ_ONLY flag and they are kept in read_only list and when read_only grows beyond some limit then driver would ask firmware to release those READ_ONLY buffers and when firmware responds driver would delete these READ_ONLY buffers. Change-Id: I8a0b11c986dd0b9464895498efd8c1831a754198 Signed-off-by: Darshana Patil <quic_darshana@quicinc.com>
81 строка
2.5 KiB
C
81 строка
2.5 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/*
|
|
* Copyright (c) 2020-2021,, The Linux Foundation. All rights reserved.
|
|
*/
|
|
|
|
#ifndef _MSM_VIDC_MEMORY_H_
|
|
#define _MSM_VIDC_MEMORY_H_
|
|
|
|
#include "msm_vidc_internal.h"
|
|
#include "msm_vidc_dt.h"
|
|
|
|
struct msm_vidc_core;
|
|
struct msm_vidc_inst;
|
|
|
|
#define MSM_MEM_POOL_PACKET_SIZE 1024
|
|
|
|
struct msm_memory_dmabuf {
|
|
struct list_head list;
|
|
struct dma_buf *dmabuf;
|
|
u32 refcount;
|
|
};
|
|
|
|
enum msm_memory_pool_type {
|
|
MSM_MEM_POOL_BUFFER = 0,
|
|
MSM_MEM_POOL_MAP,
|
|
MSM_MEM_POOL_ALLOC,
|
|
MSM_MEM_POOL_TIMESTAMP,
|
|
MSM_MEM_POOL_DMABUF,
|
|
MSM_MEM_POOL_PACKET,
|
|
MSM_MEM_POOL_BUF_TIMER,
|
|
MSM_MEM_POOL_BUF_STATS,
|
|
MSM_MEM_POOL_MAX,
|
|
};
|
|
|
|
struct msm_memory_alloc_header {
|
|
struct list_head list;
|
|
u32 type;
|
|
bool busy;
|
|
void *buf;
|
|
};
|
|
|
|
struct msm_memory_pool {
|
|
u32 size;
|
|
char *name;
|
|
struct list_head free_pool; /* list of struct msm_memory_alloc_header */
|
|
struct list_head busy_pool; /* list of struct msm_memory_alloc_header */
|
|
};
|
|
|
|
int msm_vidc_memory_alloc(struct msm_vidc_core *core,
|
|
struct msm_vidc_alloc *alloc);
|
|
int msm_vidc_memory_free(struct msm_vidc_core *core,
|
|
struct msm_vidc_alloc *alloc);
|
|
int msm_vidc_memory_map(struct msm_vidc_core *core,
|
|
struct msm_vidc_map *map);
|
|
int msm_vidc_memory_unmap(struct msm_vidc_core *core,
|
|
struct msm_vidc_map *map);
|
|
struct dma_buf *msm_vidc_memory_get_dmabuf(struct msm_vidc_inst *inst,
|
|
int fd);
|
|
void msm_vidc_memory_put_dmabuf(struct msm_vidc_inst *inst,
|
|
struct dma_buf *dmabuf);
|
|
void msm_vidc_memory_put_dmabuf_completely(struct msm_vidc_inst *inst,
|
|
struct msm_memory_dmabuf *buf);
|
|
int msm_memory_pools_init(struct msm_vidc_inst *inst);
|
|
void msm_memory_pools_deinit(struct msm_vidc_inst *inst);
|
|
void *msm_memory_pool_alloc(struct msm_vidc_inst *inst,
|
|
enum msm_memory_pool_type type);
|
|
void msm_memory_pool_free(struct msm_vidc_inst *inst, void *vidc_buf);
|
|
int msm_vidc_vmem_alloc(unsigned long size, void **mem, const char *msg);
|
|
void msm_vidc_vmem_free(void **addr);
|
|
struct context_bank_info *msm_vidc_get_context_bank(struct msm_vidc_core *core,
|
|
enum msm_vidc_buffer_region region);
|
|
struct dma_buf_attachment *msm_vidc_dma_buf_attach(struct dma_buf *dbuf,
|
|
struct device *dev);
|
|
int msm_vidc_dma_buf_detach(struct dma_buf *dbuf,
|
|
struct dma_buf_attachment *attach);
|
|
struct sg_table *msm_vidc_dma_buf_map_attachment(
|
|
struct dma_buf_attachment *attach);
|
|
int msm_vidc_dma_buf_unmap_attachment(struct dma_buf_attachment *attach,
|
|
struct sg_table *table);
|
|
|
|
#endif // _MSM_VIDC_MEMORY_H_
|