perf tools: Don't clone maps from parent when synthesizing forks
[linux/fpc-iii.git] / drivers / media / platform / mtk-vcodec / venc_drv_if.h
bloba6e7d32e55cb48057ec6ba2aa715b409a804d6ed
1 /*
2 * Copyright (c) 2016 MediaTek Inc.
3 * Author: Daniel Hsiao <daniel.hsiao@mediatek.com>
4 * Jungchang Tsao <jungchang.tsao@mediatek.com>
5 * Tiffany Lin <tiffany.lin@mediatek.com>
7 * This program is free software; you can redistribute it and/or
8 * modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
18 #ifndef _VENC_DRV_IF_H_
19 #define _VENC_DRV_IF_H_
21 #include "mtk_vcodec_drv.h"
22 #include "mtk_vcodec_util.h"
25 * enum venc_yuv_fmt - The type of input yuv format
26 * (VPU related: If you change the order, you must also update the VPU codes.)
27 * @VENC_YUV_FORMAT_I420: I420 YUV format
28 * @VENC_YUV_FORMAT_YV12: YV12 YUV format
29 * @VENC_YUV_FORMAT_NV12: NV12 YUV format
30 * @VENC_YUV_FORMAT_NV21: NV21 YUV format
32 enum venc_yuv_fmt {
33 VENC_YUV_FORMAT_I420 = 3,
34 VENC_YUV_FORMAT_YV12 = 5,
35 VENC_YUV_FORMAT_NV12 = 6,
36 VENC_YUV_FORMAT_NV21 = 7,
40 * enum venc_start_opt - encode frame option used in venc_if_encode()
41 * @VENC_START_OPT_ENCODE_SEQUENCE_HEADER: encode SPS/PPS for H264
42 * @VENC_START_OPT_ENCODE_FRAME: encode normal frame
44 enum venc_start_opt {
45 VENC_START_OPT_ENCODE_SEQUENCE_HEADER,
46 VENC_START_OPT_ENCODE_FRAME,
50 * enum venc_set_param_type - The type of set parameter used in
51 * venc_if_set_param()
52 * (VPU related: If you change the order, you must also update the VPU codes.)
53 * @VENC_SET_PARAM_ENC: set encoder parameters
54 * @VENC_SET_PARAM_FORCE_INTRA: force an intra frame
55 * @VENC_SET_PARAM_ADJUST_BITRATE: adjust bitrate (in bps)
56 * @VENC_SET_PARAM_ADJUST_FRAMERATE: set frame rate
57 * @VENC_SET_PARAM_GOP_SIZE: set IDR interval
58 * @VENC_SET_PARAM_INTRA_PERIOD: set I frame interval
59 * @VENC_SET_PARAM_SKIP_FRAME: set H264 skip one frame
60 * @VENC_SET_PARAM_PREPEND_HEADER: set H264 prepend SPS/PPS before IDR
61 * @VENC_SET_PARAM_TS_MODE: set VP8 temporal scalability mode
63 enum venc_set_param_type {
64 VENC_SET_PARAM_ENC,
65 VENC_SET_PARAM_FORCE_INTRA,
66 VENC_SET_PARAM_ADJUST_BITRATE,
67 VENC_SET_PARAM_ADJUST_FRAMERATE,
68 VENC_SET_PARAM_GOP_SIZE,
69 VENC_SET_PARAM_INTRA_PERIOD,
70 VENC_SET_PARAM_SKIP_FRAME,
71 VENC_SET_PARAM_PREPEND_HEADER,
72 VENC_SET_PARAM_TS_MODE,
76 * struct venc_enc_prm - encoder settings for VENC_SET_PARAM_ENC used in
77 * venc_if_set_param()
78 * @input_fourcc: input yuv format
79 * @h264_profile: V4L2 defined H.264 profile
80 * @h264_level: V4L2 defined H.264 level
81 * @width: image width
82 * @height: image height
83 * @buf_width: buffer width
84 * @buf_height: buffer height
85 * @frm_rate: frame rate in fps
86 * @intra_period: intra frame period
87 * @bitrate: target bitrate in bps
88 * @gop_size: group of picture size
90 struct venc_enc_param {
91 enum venc_yuv_fmt input_yuv_fmt;
92 unsigned int h264_profile;
93 unsigned int h264_level;
94 unsigned int width;
95 unsigned int height;
96 unsigned int buf_width;
97 unsigned int buf_height;
98 unsigned int frm_rate;
99 unsigned int intra_period;
100 unsigned int bitrate;
101 unsigned int gop_size;
105 * struct venc_frm_buf - frame buffer information used in venc_if_encode()
106 * @fb_addr: plane frame buffer addresses
108 struct venc_frm_buf {
109 struct mtk_vcodec_mem fb_addr[MTK_VCODEC_MAX_PLANES];
113 * struct venc_done_result - This is return information used in venc_if_encode()
114 * @bs_size: output bitstream size
115 * @is_key_frm: output is key frame or not
117 struct venc_done_result {
118 unsigned int bs_size;
119 bool is_key_frm;
123 * venc_if_init - Create the driver handle
124 * @ctx: device context
125 * @fourcc: encoder input format
126 * Return: 0 if creating handle successfully, otherwise it is failed.
128 int venc_if_init(struct mtk_vcodec_ctx *ctx, unsigned int fourcc);
131 * venc_if_deinit - Release the driver handle
132 * @ctx: device context
133 * Return: 0 if releasing handle successfully, otherwise it is failed.
135 int venc_if_deinit(struct mtk_vcodec_ctx *ctx);
138 * venc_if_set_param - Set parameter to driver
139 * @ctx: device context
140 * @type: parameter type
141 * @in: input parameter
142 * Return: 0 if setting param successfully, otherwise it is failed.
144 int venc_if_set_param(struct mtk_vcodec_ctx *ctx,
145 enum venc_set_param_type type,
146 struct venc_enc_param *in);
149 * venc_if_encode - Encode one frame
150 * @ctx: device context
151 * @opt: encode frame option
152 * @frm_buf: input frame buffer information
153 * @bs_buf: output bitstream buffer infomraiton
154 * @result: encode result
155 * Return: 0 if encoding frame successfully, otherwise it is failed.
157 int venc_if_encode(struct mtk_vcodec_ctx *ctx,
158 enum venc_start_opt opt,
159 struct venc_frm_buf *frm_buf,
160 struct mtk_vcodec_mem *bs_buf,
161 struct venc_done_result *result);
163 #endif /* _VENC_DRV_IF_H_ */