summaryrefslogtreecommitdiff
path: root/drivers/amvdec_ports/vdec_drv_if.h (plain)
blob: 8b029fece3570c53a09721f461cbc600d70f6bd7
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 GET_PARAM_CONFIG_INFO
73};
74
75/*
76 * SET_PARAM_PIC_INFO : set picture info, data parsed from ucode.
77 */
78enum vdec_set_param_type {
79 SET_PARAM_WRITE_FRAME_SYNC,
80 SET_PARAM_PIC_INFO,
81 SET_PARAM_HDR_INFO
82};
83
84/**
85 * struct vdec_fb_node - decoder frame buffer node
86 * @list : list to hold this node
87 * @fb : point to frame buffer (vdec_fb), fb could point to frame buffer and
88 * working buffer this is for maintain buffers in different state
89 */
90struct vdec_fb_node {
91 struct list_head list;
92 struct vdec_fb *fb;
93};
94
95/**
96 * vdec_if_init() - initialize decode driver
97 * @ctx : [in] v4l2 context
98 * @fourcc : [in] video format fourcc, V4L2_PIX_FMT_H264/VP8/VP9..
99 */
100int vdec_if_init(struct aml_vcodec_ctx *ctx, unsigned int fourcc);
101
102int vdec_if_probe(struct aml_vcodec_ctx *ctx,
103 struct aml_vcodec_mem *bs, void *out);
104
105/**
106 * vdec_if_deinit() - deinitialize decode driver
107 * @ctx : [in] v4l2 context
108 *
109 */
110void vdec_if_deinit(struct aml_vcodec_ctx *ctx);
111
112/**
113 * vdec_if_decode() - trigger decode
114 * @ctx : [in] v4l2 context
115 * @bs : [in] input bitstream
116 * @fb : [in] frame buffer to store decoded frame, when null menas parse
117 * header only
118 * @res_chg : [out] resolution change happens if current bs have different
119 * picture width/height
120 * Note: To flush the decoder when reaching EOF, set input bitstream as NULL.
121 *
122 * Return: 0 on success. -EIO on unrecoverable error.
123 */
124int vdec_if_decode(struct aml_vcodec_ctx *ctx, struct aml_vcodec_mem *bs,
125 u64 timestamp, bool *res_chg);
126
127/**
128 * vdec_if_get_param() - get driver's parameter
129 * @ctx : [in] v4l2 context
130 * @type : [in] input parameter type
131 * @out : [out] buffer to store query result
132 */
133int vdec_if_get_param(struct aml_vcodec_ctx *ctx, enum vdec_get_param_type type,
134 void *out);
135
136#endif
137