summaryrefslogtreecommitdiff
path: root/drivers/amvdec_ports/vdec_drv_if.h (plain)
blob: 29e48d32ae845cd3dcf6ef0eb004f50f68334c41
1/*
2* Copyright (C) 2017 Amlogic, Inc. All rights reserved.
3*
4* This program is free software; you can redistribute it and/or modify
5* it under the terms of the GNU General Public License as published by
6* the Free Software Foundation; either version 2 of the License, or
7* (at your option) any later version.
8*
9* This program is distributed in the hope that it will be useful, but WITHOUT
10* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12* more details.
13*
14* You should have received a copy of the GNU General Public License along
15* with this program; if not, write to the Free Software Foundation, Inc.,
16* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17*
18* Description:
19*/
20#ifndef _VDEC_DRV_IF_H_
21#define _VDEC_DRV_IF_H_
22
23#include "aml_vcodec_drv.h"
24#include "aml_vcodec_dec.h"
25#include "aml_vcodec_util.h"
26#include "../stream_input/parser/streambuf.h"
27
28#define NORe CODEC_MODE('N', 'O', 'R', 'e') // normal es
29#define NORn CODEC_MODE('N', 'O', 'R', 'n') // normal nalu
30#define DRMe CODEC_MODE('D', 'R', 'M', 'e') // drm es
31#define DRMn CODEC_MODE('D', 'R', 'M', 'n') // drm nalu
32
33struct stream_info {
34 u32 magic;
35 u32 type;
36 union {
37 struct drm_info drm;
38 u8 buf[128];
39 } m;
40 u32 length;
41 u8 data[0];
42};
43
44/**
45 * struct vdec_fb_status - decoder frame buffer status
46 * @FB_ST_NORMAL : initial state
47 * @FB_ST_DISPLAY : frmae buffer is ready to be displayed
48 * @FB_ST_FREE : frame buffer is not used by decoder any more
49 */
50enum vdec_fb_status {
51 FB_ST_NORMAL,
52 FB_ST_DISPLAY,
53 FB_ST_FREE
54};
55
56/* For GET_PARAM_DISP_FRAME_BUFFER and GET_PARAM_FREE_FRAME_BUFFER,
57 * the caller does not own the returned buffer. The buffer will not be
58 * released before vdec_if_deinit.
59 * GET_PARAM_DISP_FRAME_BUFFER : get next displayable frame buffer,
60 * struct vdec_fb**
61 * GET_PARAM_FREE_FRAME_BUFFER : get non-referenced framebuffer, vdec_fb**
62 * GET_PARAM_PIC_INFO : get picture info, struct vdec_pic_info*
63 * GET_PARAM_CROP_INFO : get crop info, struct v4l2_crop*
64 * GET_PARAM_DPB_SIZE : get dpb size, unsigned int*
65 */
66enum vdec_get_param_type {
67 GET_PARAM_DISP_FRAME_BUFFER,
68 GET_PARAM_FREE_FRAME_BUFFER,
69 GET_PARAM_PIC_INFO,
70 GET_PARAM_CROP_INFO,
71 GET_PARAM_DPB_SIZE
72};
73
74/*
75 * SET_PARAM_PIC_INFO : set picture info, data parsed from ucode.
76 */
77enum vdec_set_param_type {
78 SET_PARAM_WRITE_FRAME_SYNC,
79 SET_PARAM_PIC_INFO,
80};
81
82/**
83 * struct vdec_fb_node - decoder frame buffer node
84 * @list : list to hold this node
85 * @fb : point to frame buffer (vdec_fb), fb could point to frame buffer and
86 * working buffer this is for maintain buffers in different state
87 */
88struct vdec_fb_node {
89 struct list_head list;
90 struct vdec_fb *fb;
91};
92
93/**
94 * vdec_if_init() - initialize decode driver
95 * @ctx : [in] v4l2 context
96 * @fourcc : [in] video format fourcc, V4L2_PIX_FMT_H264/VP8/VP9..
97 */
98int vdec_if_init(struct aml_vcodec_ctx *ctx, unsigned int fourcc);
99
100int vdec_if_probe(struct aml_vcodec_ctx *ctx,
101 struct aml_vcodec_mem *bs, void *out);
102
103/**
104 * vdec_if_deinit() - deinitialize decode driver
105 * @ctx : [in] v4l2 context
106 *
107 */
108void vdec_if_deinit(struct aml_vcodec_ctx *ctx);
109
110/**
111 * vdec_if_decode() - trigger decode
112 * @ctx : [in] v4l2 context
113 * @bs : [in] input bitstream
114 * @fb : [in] frame buffer to store decoded frame, when null menas parse
115 * header only
116 * @res_chg : [out] resolution change happens if current bs have different
117 * picture width/height
118 * Note: To flush the decoder when reaching EOF, set input bitstream as NULL.
119 *
120 * Return: 0 on success. -EIO on unrecoverable error.
121 */
122int vdec_if_decode(struct aml_vcodec_ctx *ctx, struct aml_vcodec_mem *bs,
123 u64 timestamp, bool *res_chg);
124
125/**
126 * vdec_if_get_param() - get driver's parameter
127 * @ctx : [in] v4l2 context
128 * @type : [in] input parameter type
129 * @out : [out] buffer to store query result
130 */
131int vdec_if_get_param(struct aml_vcodec_ctx *ctx, enum vdec_get_param_type type,
132 void *out);
133
134#endif
135