1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3 * Copyright (C) 2018 BayLibre, SAS
4 * Author: Maxime Jourdan <mjourdan@baylibre.com>
5 */
6
7 #ifndef __MESON_VDEC_HEVC_COMMON_H_
8 #define __MESON_VDEC_HEVC_COMMON_H_
9
10 #include "vdec.h"
11
12 #define PARSER_CMD_SKIP_CFG_0 0x0000090b
13 #define PARSER_CMD_SKIP_CFG_1 0x1b14140f
14 #define PARSER_CMD_SKIP_CFG_2 0x001b1910
15
16 #define VDEC_HEVC_PARSER_CMD_LEN 37
17 extern const u16 vdec_hevc_parser_cmd[VDEC_HEVC_PARSER_CMD_LEN];
18
19 #define MAX_REF_PIC_NUM 24
20
21 struct codec_hevc_common {
22 void *fbc_buffer_vaddr[MAX_REF_PIC_NUM];
23 dma_addr_t fbc_buffer_paddr[MAX_REF_PIC_NUM];
24
25 void *mmu_header_vaddr[MAX_REF_PIC_NUM];
26 dma_addr_t mmu_header_paddr[MAX_REF_PIC_NUM];
27
28 void *mmu_map_vaddr;
29 dma_addr_t mmu_map_paddr;
30 };
31
32 /* Returns 1 if we must use framebuffer compression */
codec_hevc_use_fbc(u32 pixfmt,int is_10bit)33 static inline int codec_hevc_use_fbc(u32 pixfmt, int is_10bit)
34 {
35 /* TOFIX: Handle Amlogic Compressed buffer for 8bit also */
36 return is_10bit;
37 }
38
39 /* Returns 1 if we are decoding 10-bit but outputting 8-bit NV12 */
codec_hevc_use_downsample(u32 pixfmt,int is_10bit)40 static inline int codec_hevc_use_downsample(u32 pixfmt, int is_10bit)
41 {
42 return is_10bit;
43 }
44
45 /* Returns 1 if we are decoding using the IOMMU */
codec_hevc_use_mmu(u32 revision,u32 pixfmt,int is_10bit)46 static inline int codec_hevc_use_mmu(u32 revision, u32 pixfmt, int is_10bit)
47 {
48 return revision >= VDEC_REVISION_G12A &&
49 codec_hevc_use_fbc(pixfmt, is_10bit);
50 }
51
52 /**
53 * Configure decode head read mode
54 */
55 void codec_hevc_setup_decode_head(struct amvdec_session *sess, int is_10bit);
56
57 void codec_hevc_free_fbc_buffers(struct amvdec_session *sess,
58 struct codec_hevc_common *comm);
59
60 void codec_hevc_free_mmu_headers(struct amvdec_session *sess,
61 struct codec_hevc_common *comm);
62
63 int codec_hevc_setup_buffers(struct amvdec_session *sess,
64 struct codec_hevc_common *comm,
65 int is_10bit);
66
67 void codec_hevc_fill_mmu_map(struct amvdec_session *sess,
68 struct codec_hevc_common *comm,
69 struct vb2_buffer *vb);
70
71 #endif
72