/* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (c) 2012-2016, The Linux Foundation. All rights reserved. * Copyright (C) 2017 Linaro Ltd. */ #ifndef __VENUS_CORE_H_ #define __VENUS_CORE_H_ #include <linux/bitops.h> #include <linux/list.h> #include <media/videobuf2-v4l2.h> #include <media/v4l2-ctrls.h> #include <media/v4l2-device.h> #include "dbgfs.h" #include "hfi.h" #include "hfi_platform.h" #include "hfi_helper.h" #define VDBGL … #define VDBGM … #define VDBGH … #define VDBGFW … #define VIDC_CLKS_NUM_MAX … #define VIDC_VCODEC_CLKS_NUM_MAX … #define VIDC_RESETS_NUM_MAX … extern int venus_fw_debug; struct freq_tbl { … }; struct reg_val { … }; struct bw_tbl { … }; enum vpu_version { … }; struct venus_resources { … }; enum venus_fmt { … }; struct venus_format { … }; /** * struct venus_core - holds core parameters valid for all instances * * @base: IO memory base address * @vbif_base: IO memory vbif base address * @cpu_base: IO memory cpu base address * @cpu_cs_base: IO memory cpu_cs base address * @cpu_ic_base: IO memory cpu_ic base address * @wrapper_base: IO memory wrapper base address * @wrapper_tz_base: IO memory wrapper TZ base address * @aon_base: AON base address * @irq: Venus irq * @clks: an array of struct clk pointers * @vcodec0_clks: an array of vcodec0 struct clk pointers * @vcodec1_clks: an array of vcodec1 struct clk pointers * @video_path: an interconnect handle to video to/from memory path * @cpucfg_path: an interconnect handle to cpu configuration path * @has_opp_table: does OPP table exist * @pmdomains: a pointer to a list of pmdomains * @opp_dl_venus: an device-link for device OPP * @opp_pmdomain: an OPP power-domain * @resets: an array of reset signals * @vdev_dec: a reference to video device structure for decoder instances * @vdev_enc: a reference to video device structure for encoder instances * @v4l2_dev: a holder for v4l2 device structure * @res: a reference to venus resources structure * @dev: convenience struct device pointer * @dev_dec: convenience struct device pointer for decoder device * @dev_enc: convenience struct device pointer for encoder device * @use_tz: a flag that suggests presence of trustzone * @fw: structure of firmware parameters * @lock: a lock for this strucure * @instances: a list_head of all instances * @insts_count: num of instances * @state: the state of the venus core * @done: a completion for sync HFI operations * @error: an error returned during last HFI sync operations * @sys_error: an error flag that signal system error event * @sys_err_done: a waitqueue to wait for system error recovery end * @core_ops: the core operations * @pm_ops: a pointer to pm operations * @pm_lock: a lock for PM operations * @enc_codecs: encoders supported by this core * @dec_codecs: decoders supported by this core * @max_sessions_supported: holds the maximum number of sessions * @priv: a private filed for HFI operations * @ops: the core HFI operations * @work: a delayed work for handling system fatal error * @caps: an array of supported HFI capabilities * @codecs_count: platform codecs count * @core0_usage_count: usage counter for core0 * @core1_usage_count: usage counter for core1 * @root: debugfs root directory * @venus_ver: the venus firmware version * @dump_core: a flag indicating that a core dump is required */ struct venus_core { … }; struct vdec_controls { … }; struct venc_controls { … }; struct venus_buffer { … }; struct clock_data { … }; #define to_venus_buffer(ptr) … enum venus_dec_state { … }; enum venus_enc_state { … }; struct venus_ts_metadata { … }; enum venus_inst_modes { … }; /** * struct venus_inst - holds per instance parameters * * @list: used for attach an instance to the core * @lock: instance lock * @core: a reference to the core struct * @clk_data: clock data per core ID * @dpbbufs: a list of decoded picture buffers * @internalbufs: a list of internal bufferes * @registeredbufs: a list of registered capture bufferes * @delayed_process: a list of delayed buffers * @delayed_process_work: a work_struct for process delayed buffers * @nonblock: nonblocking flag * @ctrl_handler: v4l control handler * @controls: a union of decoder and encoder control parameters * @fh: a holder of v4l file handle structure * @streamon_cap: stream on flag for capture queue * @streamon_out: stream on flag for output queue * @width: current capture width * @height: current capture height * @crop: current crop rectangle * @fw_min_cnt: firmware minimum buffer count * @out_width: current output width * @out_height: current output height * @colorspace: current color space * @ycbcr_enc: current YCbCr encoding * @quantization: current quantization * @xfer_func: current xfer function * @codec_state: current decoder API state (see DEC_STATE_) * @enc_state: current encoder API state (see ENC_STATE_) * @reconf_wait: wait queue for resolution change event * @subscriptions: used to hold current events subscriptions * @buf_count: used to count number of buffers (reqbuf(0)) * @tss: timestamp metadata * @payloads: cache plane payload to use it for clock/BW scaling * @fps: holds current FPS * @timeperframe: holds current time per frame structure * @fmt_out: a reference to output format structure * @fmt_cap: a reference to capture format structure * @num_input_bufs: holds number of input buffers * @num_output_bufs: holds number of output buffers * @input_buf_size: holds input buffer size * @output_buf_size: holds output buffer size * @output2_buf_size: holds secondary decoder output buffer size * @dpb_buftype: decoded picture buffer type * @dpb_fmt: decoded picture buffer raw format * @opb_buftype: output picture buffer type * @opb_fmt: output picture buffer raw format * @reconfig: a flag raised by decoder when the stream resolution changed * @hfi_codec: current codec for this instance in HFI space * @sequence_cap: a sequence counter for capture queue * @sequence_out: a sequence counter for output queue * @m2m_dev: a reference to m2m device structure * @m2m_ctx: a reference to m2m context structure * @ctx_q_lock: a lock to serialize video device ioctl calls * @state: current state of the instance * @done: a completion for sync HFI operation * @error: an error returned during last HFI sync operation * @session_error: a flag rised by HFI interface in case of session error * @ops: HFI operations * @session_type: the type of the session (decoder or encoder) * @hprop: a union used as a holder by get property * @core_acquired: the Core has been acquired * @bit_depth: current bitstream bit-depth * @pic_struct: bitstream progressive vs interlaced * @next_buf_last: a flag to mark next queued capture buffer as last * @drain_active: Drain sequence is in progress * @flags: bitmask flags describing current instance mode * @dpb_ids: DPB buffer ID's */ struct venus_inst { … }; #define IS_V1(core) … #define IS_V3(core) … #define IS_V4(core) … #define IS_V6(core) … #define IS_AR50(core) … #define IS_AR50_LITE(core) … #define IS_IRIS1(core) … #define IS_IRIS2(core) … #define IS_IRIS2_1(core) … #define ctrl_to_inst(ctrl) … static inline struct venus_inst *to_inst(struct file *filp) { … } static inline void *to_hfi_priv(struct venus_core *core) { … } static inline struct hfi_plat_caps * venus_caps_by_codec(struct venus_core *core, u32 codec, u32 domain) { … } static inline bool is_fw_rev_or_newer(struct venus_core *core, u32 vmajor, u32 vminor, u32 vrev) { … } static inline bool is_fw_rev_or_older(struct venus_core *core, u32 vmajor, u32 vminor, u32 vrev) { … } #endif