linux/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_common.h

/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
 * Samsung S5P Multi Format Codec v 5.0
 *
 * This file contains definitions of enums and structs used by the codec
 * driver.
 *
 * Copyright (C) 2011 Samsung Electronics Co., Ltd.
 * Kamil Debski, <[email protected]>
 */

#ifndef S5P_MFC_COMMON_H_
#define S5P_MFC_COMMON_H_

#include <linux/platform_device.h>
#include <linux/videodev2.h>
#include <media/v4l2-ctrls.h>
#include <media/v4l2-device.h>
#include <media/v4l2-ioctl.h>
#include <media/videobuf2-v4l2.h>
#include "regs-mfc.h"
#include "regs-mfc-v12.h"

#define S5P_MFC_NAME

/* Definitions related to MFC memory */

/* Offset base used to differentiate between CAPTURE and OUTPUT
*  while mmaping */
#define DST_QUEUE_OFF_BASE

#define BANK_L_CTX
#define BANK_R_CTX
#define BANK_CTX_NUM

#define MFC_BANK1_ALIGN_ORDER
#define MFC_BANK2_ALIGN_ORDER
#define MFC_BASE_ALIGN_ORDER

#define MFC_FW_MAX_VERSIONS

#include <media/videobuf2-dma-contig.h>

/* MFC definitions */
#define MFC_MAX_EXTRA_DPB
#define MFC_MAX_BUFFERS
#define MFC_NUM_CONTEXTS
/* Interrupt timeout */
#define MFC_INT_TIMEOUT
/* Busy wait timeout */
#define MFC_BW_TIMEOUT
/* Watchdog interval */
#define MFC_WATCHDOG_INTERVAL
/* After how many executions watchdog should assume lock up */
#define MFC_WATCHDOG_CNT
#define MFC_NO_INSTANCE_SET
#define MFC_ENC_CAP_PLANE_COUNT
#define MFC_ENC_OUT_PLANE_COUNT
#define VB2_MAX_PLANE_COUNT
#define STUFF_BYTE
#define MFC_MAX_CTRLS

#define S5P_MFC_CODEC_NONE
#define S5P_MFC_CODEC_H264_DEC
#define S5P_MFC_CODEC_H264_MVC_DEC
#define S5P_MFC_CODEC_VC1_DEC
#define S5P_MFC_CODEC_MPEG4_DEC
#define S5P_MFC_CODEC_MPEG2_DEC
#define S5P_MFC_CODEC_H263_DEC
#define S5P_MFC_CODEC_VC1RCV_DEC
#define S5P_MFC_CODEC_VP8_DEC
#define S5P_MFC_CODEC_HEVC_DEC
#define S5P_MFC_CODEC_VP9_DEC

#define S5P_MFC_CODEC_H264_ENC
#define S5P_MFC_CODEC_H264_MVC_ENC
#define S5P_MFC_CODEC_MPEG4_ENC
#define S5P_MFC_CODEC_H263_ENC
#define S5P_MFC_CODEC_VP8_ENC
#define S5P_MFC_CODEC_HEVC_ENC

#define S5P_MFC_R2H_CMD_EMPTY
#define S5P_MFC_R2H_CMD_SYS_INIT_RET
#define S5P_MFC_R2H_CMD_OPEN_INSTANCE_RET
#define S5P_MFC_R2H_CMD_SEQ_DONE_RET
#define S5P_MFC_R2H_CMD_INIT_BUFFERS_RET
#define S5P_MFC_R2H_CMD_CLOSE_INSTANCE_RET
#define S5P_MFC_R2H_CMD_SLEEP_RET
#define S5P_MFC_R2H_CMD_WAKEUP_RET
#define S5P_MFC_R2H_CMD_COMPLETE_SEQ_RET
#define S5P_MFC_R2H_CMD_DPB_FLUSH_RET
#define S5P_MFC_R2H_CMD_NAL_ABORT_RET
#define S5P_MFC_R2H_CMD_FW_STATUS_RET
#define S5P_MFC_R2H_CMD_FRAME_DONE_RET
#define S5P_MFC_R2H_CMD_FIELD_DONE_RET
#define S5P_MFC_R2H_CMD_SLICE_DONE_RET
#define S5P_MFC_R2H_CMD_ENC_BUFFER_FUL_RET
#define S5P_MFC_R2H_CMD_ERR_RET

#define MFC_MAX_CLOCKS

#define mfc_read(dev, offset)
#define mfc_write(dev, data, offset)

/*
 * enum s5p_mfc_fmt_type - type of the pixelformat
 */
enum s5p_mfc_fmt_type {};

/*
 * enum s5p_mfc_inst_type - The type of an MFC instance.
 */
enum s5p_mfc_inst_type {};

/*
 * enum s5p_mfc_inst_state - The state of an MFC instance.
 */
enum s5p_mfc_inst_state {};

/*
 * enum s5p_mfc_queue_state - The state of buffer queue.
 */
enum s5p_mfc_queue_state {};

/*
 * enum s5p_mfc_decode_arg - type of frame decoding
 */
enum s5p_mfc_decode_arg {};

enum s5p_mfc_fw_ver {};

#define MFC_BUF_FLAG_USED
#define MFC_BUF_FLAG_EOS

struct s5p_mfc_ctx;

/*
 * struct s5p_mfc_buf - MFC buffer
 */
struct s5p_mfc_buf {};

/*
 * struct s5p_mfc_pm - power management data structure
 */
struct s5p_mfc_pm {};

struct s5p_mfc_buf_size_v5 {};

struct s5p_mfc_buf_size_v6 {};

struct s5p_mfc_buf_size {};

struct s5p_mfc_variant {};

/**
 * struct s5p_mfc_priv_buf - represents internal used buffer
 * @ofs:		offset of each buffer, will be used for MFC
 * @virt:		kernel virtual address, only valid when the
 *			buffer accessed by driver
 * @dma:		DMA address, only valid when kernel DMA API used
 * @size:		size of the buffer
 * @ctx:		memory context (bank) used for this allocation
 */
struct s5p_mfc_priv_buf {};

/**
 * struct s5p_mfc_dev - The struct containing driver internal parameters.
 *
 * @v4l2_dev:		v4l2_device
 * @vfd_dec:		video device for decoding
 * @vfd_enc:		video device for encoding
 * @plat_dev:		platform device
 * @mem_dev:		child devices of the memory banks
 * @regs_base:		base address of the MFC hw registers
 * @irq:		irq resource
 * @dec_ctrl_handler:	control framework handler for decoding
 * @enc_ctrl_handler:	control framework handler for encoding
 * @pm:			power management control
 * @variant:		MFC hardware variant information
 * @num_inst:		counter of active MFC instances
 * @irqlock:		lock for operations on videobuf2 queues
 * @condlock:		lock for changing/checking if a context is ready to be
 *			processed
 * @mfc_mutex:		lock for video_device
 * @int_cond:		variable used by the waitqueue
 * @int_type:		type of last interrupt
 * @int_err:		error number for last interrupt
 * @queue:		waitqueue for waiting for completion of device commands
 * @fw_buf:		the firmware buffer data structure
 * @mem_size:		size of the firmware operation memory
 * @mem_base:		base DMA address of the firmware operation memory
 * @mem_bitmap:		bitmap for managing MFC internal buffer allocations
 * @mem_virt:		virtual address of the firmware operation memory
 * @dma_base:		address of the beginning of memory banks
 * @hw_lock:		used for hardware locking
 * @ctx:		array of driver contexts
 * @curr_ctx:		number of the currently running context
 * @ctx_work_bits:	used to mark which contexts are waiting for hardware
 * @watchdog_cnt:	counter for the watchdog
 * @watchdog_timer:	timer for the watchdog
 * @watchdog_workqueue:	workqueue for the watchdog
 * @watchdog_work:	worker for the watchdog
 * @enter_suspend:	flag set when entering suspend
 * @ctx_buf:		common context memory (MFCv6)
 * @warn_start:		hardware error code from which warnings start
 * @mfc_ops:		ops structure holding HW operation function pointers
 * @mfc_cmds:		cmd structure holding HW commands function pointers
 * @mfc_regs:		structure holding MFC registers
 * @fw_ver:		loaded firmware sub-version
 * @fw_get_done:	flag set when request_firmware() is complete and
 *			copied into fw_buf
 * @risc_on:		flag indicates RISC is on or off
 *
 */
struct s5p_mfc_dev {};

/*
 * struct s5p_mfc_h264_enc_params - encoding parameters for h264
 */
struct s5p_mfc_h264_enc_params {};

/*
 * struct s5p_mfc_mpeg4_enc_params - encoding parameters for h263 and mpeg4
 */
struct s5p_mfc_mpeg4_enc_params {};

/*
 * struct s5p_mfc_vp8_enc_params - encoding parameters for vp8
 */
struct s5p_mfc_vp8_enc_params {};

struct s5p_mfc_hevc_enc_params {};

/*
 * struct s5p_mfc_enc_params - general encoding parameters
 */
struct s5p_mfc_enc_params {};

/*
 * struct s5p_mfc_codec_ops - codec ops, used by encoding
 */
struct s5p_mfc_codec_ops {};

#define call_cop(c, op, args...)

/**
 * struct s5p_mfc_ctx - This struct contains the instance context
 *
 * @dev:		pointer to the s5p_mfc_dev of the device
 * @fh:			struct v4l2_fh
 * @num:		number of the context that this structure describes
 * @int_cond:		variable used by the waitqueue
 * @int_type:		type of the last interrupt
 * @int_err:		error number received from MFC hw in the interrupt
 * @queue:		waitqueue that can be used to wait for this context to
 *			finish
 * @src_fmt:		source pixelformat information
 * @dst_fmt:		destination pixelformat information
 * @vq_src:		vb2 queue for source buffers
 * @vq_dst:		vb2 queue for destination buffers
 * @src_queue:		driver internal queue for source buffers
 * @dst_queue:		driver internal queue for destination buffers
 * @src_queue_cnt:	number of buffers queued on the source internal queue
 * @dst_queue_cnt:	number of buffers queued on the dest internal queue
 * @type:		type of the instance - decoder or encoder
 * @state:		state of the context
 * @inst_no:		number of hw instance associated with the context
 * @img_width:		width of the image that is decoded or encoded
 * @img_height:		height of the image that is decoded or encoded
 * @buf_width:		width of the buffer for processed image
 * @buf_height:		height of the buffer for processed image
 * @luma_size:		size of a luma plane
 * @chroma_size:	size of a chroma plane
 * @mv_size:		size of a motion vectors buffer
 * @consumed_stream:	number of bytes that have been used so far from the
 *			decoding buffer
 * @dpb_flush_flag:	flag used to indicate that a DPB buffers are being
 *			flushed
 * @head_processed:	flag mentioning whether the header data is processed
 *			completely or not
 * @bank1:		handle to memory allocated for temporary buffers from
 *			memory bank 1
 * @bank2:		handle to memory allocated for temporary buffers from
 *			memory bank 2
 * @capture_state:	state of the capture buffers queue
 * @output_state:	state of the output buffers queue
 * @src_bufs:		information on allocated source buffers
 * @src_bufs_cnt:	number of allocated source buffers
 * @dst_bufs:		information on allocated destination buffers
 * @dst_bufs_cnt:	number of allocated destination buffers
 * @sequence:		counter for the sequence number for v4l2
 * @dec_dst_flag:	flags for buffers queued in the hardware
 * @dec_src_buf_size:	size of the buffer for source buffers in decoding
 * @codec_mode:		number of codec mode used by MFC hw
 * @slice_interface:	slice interface flag
 * @loop_filter_mpeg4:	loop filter for MPEG4 flag
 * @display_delay:	value of the display delay for H264
 * @display_delay_enable:	display delay for H264 enable flag
 * @after_packed_pb:	flag used to track buffer when stream is in
 *			Packed PB format
 * @sei_fp_parse:	enable/disable parsing of frame packing SEI information
 * @pb_count:		count of the DPB buffers required by MFC hw
 * @total_dpb_count:	count of DPB buffers with additional buffers
 *			requested by the application
 * @ctx:		context buffer information
 * @dsc:		descriptor buffer information
 * @shm:		shared memory buffer information
 * @mv_count:		number of MV buffers allocated for decoding
 * @enc_params:		encoding parameters for MFC
 * @enc_dst_buf_size:	size of the buffers for encoder output
 * @luma_dpb_size:	dpb buffer size for luma
 * @chroma_dpb_size:	dpb buffer size for chroma
 * @me_buffer_size:	size of the motion estimation buffer
 * @tmv_buffer_size:	size of temporal predictor motion vector buffer
 * @ref_queue:		list of the reference buffers for encoding
 * @force_frame_type:	encoder's frame type forcing control
 * @ref_queue_cnt:	number of the buffers in the reference list
 * @slice_size:		slice size
 * @slice_mode:		mode of dividing frames into slices
 * @c_ops:		ops for encoding
 * @ctrls:		array of controls, used when adding controls to the
 *			v4l2 control framework
 * @ctrl_handler:	handler for v4l2 framework
 * @scratch_buf_size:	scratch buffer size
 * @is_10bit:		state to check 10bit support
 * @is_422:		state to check YUV422 10bit format
 * @chroma_size_1:	size of a chroma third plane
 * @stride:		size of stride for all planes
 */
struct s5p_mfc_ctx {};

/*
 * struct s5p_mfc_fmt -	structure used to store information about pixelformats
 *			used by the MFC
 */
struct s5p_mfc_fmt {};

/*
 * struct mfc_control -	structure used to store information about MFC controls
 *			it is used to initialize the control framework.
 */
struct mfc_control {};

/* Macro for making hardware specific calls */
#define s5p_mfc_hw_call(f, op, args...)

#define fh_to_ctx(__fh)
#define ctrl_to_ctx(__ctrl)

void clear_work_bit(struct s5p_mfc_ctx *ctx);
void set_work_bit(struct s5p_mfc_ctx *ctx);
void clear_work_bit_irqsave(struct s5p_mfc_ctx *ctx);
void set_work_bit_irqsave(struct s5p_mfc_ctx *ctx);
int s5p_mfc_get_new_ctx(struct s5p_mfc_dev *dev);
void s5p_mfc_cleanup_queue(struct list_head *lh, struct vb2_queue *vq);

#define HAS_PORTNUM(dev)
#define IS_TWOPORT(dev)
#define IS_MFCV6_PLUS(dev)
#define IS_MFCV7_PLUS(dev)
#define IS_MFCV8_PLUS(dev)
#define IS_MFCV10_PLUS(dev)
#define IS_MFCV12(dev)
#define FW_HAS_E_MIN_SCRATCH_BUF(dev)

#define MFC_V5_BIT
#define MFC_V6_BIT
#define MFC_V7_BIT
#define MFC_V8_BIT
#define MFC_V10_BIT
#define MFC_V12_BIT

#define MFC_V5PLUS_BITS
#define MFC_V6PLUS_BITS
#define MFC_V7PLUS_BITS

#define MFC_V10PLUS_BITS

#endif /* S5P_MFC_COMMON_H_ */