/* SPDX-License-Identifier: GPL-2.0+ */ /* * Copyright (C) 2018 BayLibre, SAS * Author: Maxime Jourdan <[email protected]> */ #ifndef __MESON_VDEC_CORE_H_ #define __MESON_VDEC_CORE_H_ #include <linux/irqreturn.h> #include <linux/regmap.h> #include <linux/list.h> #include <media/videobuf2-v4l2.h> #include <media/v4l2-ctrls.h> #include <media/v4l2-device.h> #include <linux/soc/amlogic/meson-canvas.h> #include "vdec_platform.h" /* 32 buffers in 3-plane YUV420 */ #define MAX_CANVAS … struct amvdec_buffer { … }; /** * struct amvdec_timestamp - stores a src timestamp along with a VIFIFO offset * * @list: used to make lists out of this struct * @tc: timecode from the v4l2 buffer * @ts: timestamp from the VB2 buffer * @offset: offset in the VIFIFO where the associated packet was written * @flags: flags from the v4l2 buffer * @used_count: times this timestamp was checked for a match with a dst buffer */ struct amvdec_timestamp { … }; struct amvdec_session; /** * struct amvdec_core - device parameters, singleton * * @dos_base: DOS memory base address * @esparser_base: PARSER memory base address * @regmap_ao: regmap for the AO bus * @dev: core device * @dev_dec: decoder device * @platform: platform-specific data * @canvas: canvas provider reference * @dos_parser_clk: DOS_PARSER clock * @dos_clk: DOS clock * @vdec_1_clk: VDEC_1 clock * @vdec_hevc_clk: VDEC_HEVC clock * @vdec_hevcf_clk: VDEC_HEVCF clock * @esparser_reset: RESET for the PARSER * @vdev_dec: video device for the decoder * @v4l2_dev: v4l2 device * @cur_sess: current decoding session * @lock: video device lock */ struct amvdec_core { … }; /** * struct amvdec_ops - vdec operations * * @start: mandatory call when the vdec needs to initialize * @stop: mandatory call when the vdec needs to stop * @conf_esparser: mandatory call to let the vdec configure the ESPARSER * @vififo_level: mandatory call to get the current amount of data * in the VIFIFO */ struct amvdec_ops { … }; /** * struct amvdec_codec_ops - codec operations * * @start: mandatory call when the codec needs to initialize * @stop: mandatory call when the codec needs to stop * @load_extended_firmware: optional call to load additional firmware bits * @num_pending_bufs: optional call to get the number of dst buffers on hold * @can_recycle: optional call to know if the codec is ready to recycle * a dst buffer * @recycle: optional call to tell the codec to recycle a dst buffer. Must go * in pair with @can_recycle * @drain: optional call if the codec has a custom way of draining * @resume: optional call to resume after a resolution change * @eos_sequence: optional call to get an end sequence to send to esparser * for flush. Mutually exclusive with @drain. * @isr: mandatory call when the ISR triggers * @threaded_isr: mandatory call for the threaded ISR */ struct amvdec_codec_ops { … }; /** * struct amvdec_format - describes one of the OUTPUT (src) format supported * * @pixfmt: V4L2 pixel format * @min_buffers: minimum amount of CAPTURE (dst) buffers * @max_buffers: maximum amount of CAPTURE (dst) buffers * @max_width: maximum picture width supported * @max_height: maximum picture height supported * @flags: enum flags associated with this pixfmt * @vdec_ops: the VDEC operations that support this format * @codec_ops: the codec operations that support this format * @firmware_path: Path to the firmware that supports this format * @pixfmts_cap: list of CAPTURE pixel formats available with pixfmt */ struct amvdec_format { … }; enum amvdec_status { … }; /** * struct amvdec_session - decoding session parameters * * @core: reference to the vdec core struct * @fh: v4l2 file handle * @m2m_dev: v4l2 m2m device * @m2m_ctx: v4l2 m2m context * @ctrl_handler: V4L2 control handler * @ctrl_min_buf_capture: V4L2 control V4L2_CID_MIN_BUFFERS_FOR_CAPTURE * @lock: cap & out queues lock * @fmt_out: vdec pixel format for the OUTPUT queue * @pixfmt_cap: V4L2 pixel format for the CAPTURE queue * @src_buffer_size: size in bytes of the OUTPUT buffers' only plane * @width: current picture width * @height: current picture height * @colorspace: current colorspace * @ycbcr_enc: current ycbcr_enc * @quantization: current quantization * @xfer_func: current transfer function * @pixelaspect: Pixel Aspect Ratio reported by the decoder * @esparser_queued_bufs: number of buffers currently queued into ESPARSER * @esparser_queue_work: work struct for the ESPARSER to process src buffers * @streamon_cap: stream on flag for capture queue * @streamon_out: stream on flag for output queue * @sequence_cap: capture sequence counter * @sequence_out: output sequence counter * @should_stop: flag set if userspace signaled EOS via command * or empty buffer * @keyframe_found: flag set once a keyframe has been parsed * @num_dst_bufs: number of destination buffers * @changed_format: the format changed * @canvas_alloc: array of all the canvas IDs allocated * @canvas_num: number of canvas IDs allocated * @vififo_vaddr: virtual address for the VIFIFO * @vififo_paddr: physical address for the VIFIFO * @vififo_size: size of the VIFIFO dma alloc * @bufs_recycle: list of buffers that need to be recycled * @bufs_recycle_lock: lock for the bufs_recycle list * @recycle_thread: task struct for the recycling thread * @timestamps: chronological list of src timestamps * @ts_spinlock: spinlock for the timestamps list * @last_irq_jiffies: tracks last time the vdec triggered an IRQ * @last_offset: tracks last offset of vififo * @wrap_count: number of times the vififo wrapped around * @fw_idx_to_vb2_idx: firmware buffer index to vb2 buffer index * @status: current decoding status * @priv: codec private data */ struct amvdec_session { … }; u32 amvdec_get_output_size(struct amvdec_session *sess); #endif