mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-21 06:50:25 +00:00

Firmware might hold the DPB buffers for reference in case of sequence
change, so skip destroying buffers for which QUEUED flag is not removed.
Cc: stable@vger.kernel.org
Fixes: 73702f45db
("media: iris: allocate, initialize and queue internal buffers")
Reviewed-by: Vikash Garodia <quic_vgarodia@quicinc.com>
Tested-by: Neil Armstrong <neil.armstrong@linaro.org> # on SM8550-QRD
Tested-by: Neil Armstrong <neil.armstrong@linaro.org> # on SM8550-HDK
Tested-by: Neil Armstrong <neil.armstrong@linaro.org> # on SM8650-QRD
Tested-by: Neil Armstrong <neil.armstrong@linaro.org> # on SM8650-HDK
Signed-off-by: Dikshita Agarwal <quic_dikshita@quicinc.com>
Tested-by: Vikash Garodia <quic_vgarodia@quicinc.com> # on sa8775p-ride
Signed-off-by: Bryan O'Donoghue <bod@kernel.org>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
118 lines
3.7 KiB
C
118 lines
3.7 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/*
|
|
* Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved.
|
|
*/
|
|
|
|
#ifndef __IRIS_BUFFER_H__
|
|
#define __IRIS_BUFFER_H__
|
|
|
|
#include <media/videobuf2-v4l2.h>
|
|
|
|
struct iris_inst;
|
|
|
|
#define to_iris_buffer(ptr) container_of(ptr, struct iris_buffer, vb2)
|
|
|
|
/**
|
|
* enum iris_buffer_type
|
|
*
|
|
* @BUF_INPUT: input buffer to the iris hardware
|
|
* @BUF_OUTPUT: output buffer from the iris hardware
|
|
* @BUF_BIN: buffer to store intermediate bin data
|
|
* @BUF_ARP: buffer for auto register programming
|
|
* @BUF_COMV: buffer to store colocated motion vectors
|
|
* @BUF_NON_COMV: buffer to hold config data for HW
|
|
* @BUF_LINE: buffer to store decoding/encoding context data for HW
|
|
* @BUF_DPB: buffer to store display picture buffers for reference
|
|
* @BUF_PERSIST: buffer to store session context data
|
|
* @BUF_SCRATCH_1: buffer to store decoding/encoding context data for HW
|
|
* @BUF_TYPE_MAX: max buffer types
|
|
*/
|
|
enum iris_buffer_type {
|
|
BUF_INPUT = 1,
|
|
BUF_OUTPUT,
|
|
BUF_BIN,
|
|
BUF_ARP,
|
|
BUF_COMV,
|
|
BUF_NON_COMV,
|
|
BUF_LINE,
|
|
BUF_DPB,
|
|
BUF_PERSIST,
|
|
BUF_SCRATCH_1,
|
|
BUF_TYPE_MAX,
|
|
};
|
|
|
|
/*
|
|
* enum iris_buffer_attributes
|
|
*
|
|
* BUF_ATTR_DEFERRED: buffer queued by client but not submitted to firmware.
|
|
* BUF_ATTR_PENDING_RELEASE: buffers requested to be released from firmware.
|
|
* BUF_ATTR_QUEUED: buffers submitted to firmware.
|
|
* BUF_ATTR_DEQUEUED: buffers received from firmware.
|
|
* BUF_ATTR_BUFFER_DONE: buffers sent back to vb2.
|
|
*/
|
|
enum iris_buffer_attributes {
|
|
BUF_ATTR_DEFERRED = BIT(0),
|
|
BUF_ATTR_PENDING_RELEASE = BIT(1),
|
|
BUF_ATTR_QUEUED = BIT(2),
|
|
BUF_ATTR_DEQUEUED = BIT(3),
|
|
BUF_ATTR_BUFFER_DONE = BIT(4),
|
|
};
|
|
|
|
/**
|
|
* struct iris_buffer
|
|
*
|
|
* @vb2: v4l2 vb2 buffer
|
|
* @list: list head for the iris_buffers structure
|
|
* @inst: iris instance structure
|
|
* @type: enum for type of iris buffer
|
|
* @index: identifier for the iris buffer
|
|
* @fd: file descriptor of the buffer
|
|
* @buffer_size: accessible buffer size in bytes starting from addr_offset
|
|
* @data_offset: accessible buffer offset from base address
|
|
* @data_size: data size in bytes
|
|
* @device_addr: device address of the buffer
|
|
* @kvaddr: kernel virtual address of the buffer
|
|
* @dma_attrs: dma attributes
|
|
* @flags: buffer flags. It is represented as bit masks.
|
|
* @timestamp: timestamp of the buffer in nano seconds (ns)
|
|
* @attr: enum for iris buffer attributes
|
|
*/
|
|
struct iris_buffer {
|
|
struct vb2_v4l2_buffer vb2;
|
|
struct list_head list;
|
|
struct iris_inst *inst;
|
|
enum iris_buffer_type type;
|
|
u32 index;
|
|
int fd;
|
|
size_t buffer_size;
|
|
u32 data_offset;
|
|
size_t data_size;
|
|
dma_addr_t device_addr;
|
|
void *kvaddr;
|
|
unsigned long dma_attrs;
|
|
u32 flags; /* V4L2_BUF_FLAG_* */
|
|
u64 timestamp;
|
|
enum iris_buffer_attributes attr;
|
|
};
|
|
|
|
struct iris_buffers {
|
|
struct list_head list;
|
|
u32 min_count;
|
|
u32 size;
|
|
};
|
|
|
|
int iris_get_buffer_size(struct iris_inst *inst, enum iris_buffer_type buffer_type);
|
|
void iris_get_internal_buffers(struct iris_inst *inst, u32 plane);
|
|
int iris_create_internal_buffers(struct iris_inst *inst, u32 plane);
|
|
int iris_queue_internal_buffers(struct iris_inst *inst, u32 plane);
|
|
int iris_destroy_internal_buffer(struct iris_inst *inst, struct iris_buffer *buffer);
|
|
int iris_destroy_all_internal_buffers(struct iris_inst *inst, u32 plane);
|
|
int iris_destroy_dequeued_internal_buffers(struct iris_inst *inst, u32 plane);
|
|
int iris_alloc_and_queue_persist_bufs(struct iris_inst *inst);
|
|
int iris_alloc_and_queue_input_int_bufs(struct iris_inst *inst);
|
|
int iris_queue_buffer(struct iris_inst *inst, struct iris_buffer *buf);
|
|
int iris_queue_deferred_buffers(struct iris_inst *inst, enum iris_buffer_type buf_type);
|
|
int iris_vb2_buffer_done(struct iris_inst *inst, struct iris_buffer *buf);
|
|
void iris_vb2_queue_error(struct iris_inst *inst);
|
|
|
|
#endif
|