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