1823a7300SMaxime Jourdan /* SPDX-License-Identifier: GPL-2.0+ */ 2823a7300SMaxime Jourdan /* 3823a7300SMaxime Jourdan * Copyright (C) 2018 BayLibre, SAS 4823a7300SMaxime Jourdan * Author: Maxime Jourdan <mjourdan@baylibre.com> 5823a7300SMaxime Jourdan */ 6823a7300SMaxime Jourdan 7823a7300SMaxime Jourdan #ifndef __MESON_VDEC_HEVC_COMMON_H_ 8823a7300SMaxime Jourdan #define __MESON_VDEC_HEVC_COMMON_H_ 9823a7300SMaxime Jourdan 10823a7300SMaxime Jourdan #include "vdec.h" 11823a7300SMaxime Jourdan 12823a7300SMaxime Jourdan #define PARSER_CMD_SKIP_CFG_0 0x0000090b 13823a7300SMaxime Jourdan #define PARSER_CMD_SKIP_CFG_1 0x1b14140f 14823a7300SMaxime Jourdan #define PARSER_CMD_SKIP_CFG_2 0x001b1910 15823a7300SMaxime Jourdan 16823a7300SMaxime Jourdan #define VDEC_HEVC_PARSER_CMD_LEN 37 17823a7300SMaxime Jourdan extern const u16 vdec_hevc_parser_cmd[VDEC_HEVC_PARSER_CMD_LEN]; 18823a7300SMaxime Jourdan 19823a7300SMaxime Jourdan #define MAX_REF_PIC_NUM 24 20823a7300SMaxime Jourdan 21823a7300SMaxime Jourdan struct codec_hevc_common { 22823a7300SMaxime Jourdan void *fbc_buffer_vaddr[MAX_REF_PIC_NUM]; 23823a7300SMaxime Jourdan dma_addr_t fbc_buffer_paddr[MAX_REF_PIC_NUM]; 24823a7300SMaxime Jourdan 25823a7300SMaxime Jourdan void *mmu_header_vaddr[MAX_REF_PIC_NUM]; 26823a7300SMaxime Jourdan dma_addr_t mmu_header_paddr[MAX_REF_PIC_NUM]; 27823a7300SMaxime Jourdan 28823a7300SMaxime Jourdan void *mmu_map_vaddr; 29823a7300SMaxime Jourdan dma_addr_t mmu_map_paddr; 30823a7300SMaxime Jourdan }; 31823a7300SMaxime Jourdan 32823a7300SMaxime Jourdan /* Returns 1 if we must use framebuffer compression */ 33823a7300SMaxime Jourdan static inline int codec_hevc_use_fbc(u32 pixfmt, int is_10bit) 34823a7300SMaxime Jourdan { 35823a7300SMaxime Jourdan /* TOFIX: Handle Amlogic Compressed buffer for 8bit also */ 36823a7300SMaxime Jourdan return is_10bit; 37823a7300SMaxime Jourdan } 38823a7300SMaxime Jourdan 39823a7300SMaxime Jourdan /* Returns 1 if we are decoding 10-bit but outputting 8-bit NV12 */ 40823a7300SMaxime Jourdan static inline int codec_hevc_use_downsample(u32 pixfmt, int is_10bit) 41823a7300SMaxime Jourdan { 42823a7300SMaxime Jourdan return is_10bit; 43823a7300SMaxime Jourdan } 44823a7300SMaxime Jourdan 45823a7300SMaxime Jourdan /* Returns 1 if we are decoding using the IOMMU */ 46823a7300SMaxime Jourdan static inline int codec_hevc_use_mmu(u32 revision, u32 pixfmt, int is_10bit) 47823a7300SMaxime Jourdan { 48823a7300SMaxime Jourdan return revision >= VDEC_REVISION_G12A && 49823a7300SMaxime Jourdan codec_hevc_use_fbc(pixfmt, is_10bit); 50823a7300SMaxime Jourdan } 51823a7300SMaxime Jourdan 52823a7300SMaxime Jourdan /** 53823a7300SMaxime Jourdan * Configure decode head read mode 54823a7300SMaxime Jourdan */ 55823a7300SMaxime Jourdan void codec_hevc_setup_decode_head(struct amvdec_session *sess, int is_10bit); 56823a7300SMaxime Jourdan 57823a7300SMaxime Jourdan void codec_hevc_free_fbc_buffers(struct amvdec_session *sess, 58823a7300SMaxime Jourdan struct codec_hevc_common *comm); 59823a7300SMaxime Jourdan 60823a7300SMaxime Jourdan void codec_hevc_free_mmu_headers(struct amvdec_session *sess, 61823a7300SMaxime Jourdan struct codec_hevc_common *comm); 62823a7300SMaxime Jourdan 63823a7300SMaxime Jourdan int codec_hevc_setup_buffers(struct amvdec_session *sess, 64823a7300SMaxime Jourdan struct codec_hevc_common *comm, 65823a7300SMaxime Jourdan int is_10bit); 66823a7300SMaxime Jourdan 67823a7300SMaxime Jourdan void codec_hevc_fill_mmu_map(struct amvdec_session *sess, 68823a7300SMaxime Jourdan struct codec_hevc_common *comm, 69823a7300SMaxime Jourdan struct vb2_buffer *vb); 70823a7300SMaxime Jourdan 71823a7300SMaxime Jourdan #endif 72