1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Copyright (C) 2018 BayLibre, SAS
4 * Author: Maxime Jourdan <mjourdan@baylibre.com>
7 #ifndef __MESON_VDEC_HELPERS_H_
8 #define __MESON_VDEC_HELPERS_H_
13 * amvdec_set_canvases() - Map VB2 buffers to canvases
15 * @sess: current session
16 * @reg_base: Registry bases of where to write the canvas indexes
17 * @reg_num: number of contiguous registers after each reg_base (including it)
19 int amvdec_set_canvases(struct amvdec_session *sess,
20 u32 reg_base[], u32 reg_num[]);
22 /* Helpers to read/write to the various IPs (DOS, PARSER) */
23 u32 amvdec_read_dos(struct amvdec_core *core, u32 reg);
24 void amvdec_write_dos(struct amvdec_core *core, u32 reg, u32 val);
25 void amvdec_write_dos_bits(struct amvdec_core *core, u32 reg, u32 val);
26 void amvdec_clear_dos_bits(struct amvdec_core *core, u32 reg, u32 val);
27 u32 amvdec_read_parser(struct amvdec_core *core, u32 reg);
28 void amvdec_write_parser(struct amvdec_core *core, u32 reg, u32 val);
31 * amvdec_dst_buf_done_idx() - Signal that a buffer is done decoding
33 * @sess: current session
34 * @buf_idx: hardware buffer index
35 * @offset: VIFIFO bitstream offset corresponding to the buffer
36 * @field: V4L2 interlaced field
38 void amvdec_dst_buf_done_idx(struct amvdec_session *sess, u32 buf_idx,
39 u32 offset, u32 field);
40 void amvdec_dst_buf_done(struct amvdec_session *sess,
41 struct vb2_v4l2_buffer *vbuf, u32 field);
42 void amvdec_dst_buf_done_offset(struct amvdec_session *sess,
43 struct vb2_v4l2_buffer *vbuf,
44 u32 offset, u32 field, bool allow_drop);
47 * amvdec_add_ts_reorder() - Add a timestamp to the list in chronological order
49 * @sess: current session
50 * @ts: timestamp to add
51 * @offset: offset in the VIFIFO where the associated packet was written
53 void amvdec_add_ts_reorder(struct amvdec_session *sess, u64 ts, u32 offset);
54 void amvdec_remove_ts(struct amvdec_session *sess, u64 ts);
57 * amvdec_set_par_from_dar() - Set Pixel Aspect Ratio from Display Aspect Ratio
59 * @sess: current session
60 * @dar_num: numerator of the DAR
61 * @dar_den: denominator of the DAR
63 void amvdec_set_par_from_dar(struct amvdec_session *sess,
64 u32 dar_num, u32 dar_den);
67 * amvdec_src_change() - Notify new resolution/DPB size to the core
69 * @sess: current session
70 * @width: picture width detected by the hardware
71 * @height: picture height detected by the hardware
72 * @dpb_size: Decoded Picture Buffer size (= amount of buffers for decoding)
74 void amvdec_src_change(struct amvdec_session *sess, u32 width,
75 u32 height, u32 dpb_size);
78 * amvdec_abort() - Abort the current decoding session
80 * @sess: current session
82 void amvdec_abort(struct amvdec_session *sess);