blob: 9b717096a29140753f2751723057af32e32727fb [file] [log] [blame]
Srinu Gorlecf8c6752018-01-19 18:36:13 +05301/*Copyright (c) 2012-2016, 2018 The Linux Foundation. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 */
13
14#ifndef _MSM_VIDC_COMMON_H_
15#define _MSM_VIDC_COMMON_H_
16#include "msm_vidc_internal.h"
17struct vb2_buf_entry {
18 struct list_head list;
19 struct vb2_buffer *vb;
20};
21
22extern const char *const mpeg_video_vidc_extradata[];
23
24enum load_calc_quirks {
25 LOAD_CALC_NO_QUIRKS = 0,
26 LOAD_CALC_IGNORE_TURBO_LOAD = 1 << 0,
27 LOAD_CALC_IGNORE_THUMBNAIL_LOAD = 1 << 1,
28 LOAD_CALC_IGNORE_NON_REALTIME_LOAD = 1 << 2,
29};
30
31struct msm_vidc_core *get_vidc_core(int core_id);
32const struct msm_vidc_format *msm_comm_get_pixel_fmt_index(
33 const struct msm_vidc_format fmt[], int size, int index, int fmt_type);
34struct msm_vidc_format *msm_comm_get_pixel_fmt_fourcc(
35 struct msm_vidc_format fmt[], int size, int fourcc, int fmt_type);
36struct buf_queue *msm_comm_get_vb2q(
37 struct msm_vidc_inst *inst, enum v4l2_buf_type type);
38int msm_comm_try_state(struct msm_vidc_inst *inst, int state);
39int msm_comm_try_get_bufreqs(struct msm_vidc_inst *inst);
40int msm_comm_try_set_prop(struct msm_vidc_inst *inst,
41 enum hal_property ptype, void *pdata);
42int msm_comm_try_get_prop(struct msm_vidc_inst *inst,
43 enum hal_property ptype, union hal_get_property *hprop);
44int msm_comm_set_scratch_buffers(struct msm_vidc_inst *inst);
45int msm_comm_set_persist_buffers(struct msm_vidc_inst *inst);
46int msm_comm_set_output_buffers(struct msm_vidc_inst *inst);
47int msm_comm_queue_output_buffers(struct msm_vidc_inst *inst);
48int msm_comm_qbuf(struct msm_vidc_inst *inst, struct vb2_buffer *vb);
49void msm_comm_scale_clocks_and_bus(struct msm_vidc_inst *inst);
50int msm_comm_scale_clocks(struct msm_vidc_core *core);
51int msm_comm_scale_clocks_load(struct msm_vidc_core *core,
52 int num_mbs_per_sec, enum load_calc_quirks quirks);
53void msm_comm_flush_dynamic_buffers(struct msm_vidc_inst *inst);
54int msm_comm_flush(struct msm_vidc_inst *inst, u32 flags);
55int msm_comm_release_scratch_buffers(struct msm_vidc_inst *inst,
56 bool check_for_reuse);
57int msm_comm_release_persist_buffers(struct msm_vidc_inst *inst);
58int msm_comm_release_output_buffers(struct msm_vidc_inst *inst);
59int msm_comm_force_cleanup(struct msm_vidc_inst *inst);
60int msm_comm_suspend(int core_id);
61enum hal_extradata_id msm_comm_get_hal_extradata_index(
62 enum v4l2_mpeg_vidc_extradata index);
63enum hal_buffer_layout_type msm_comm_get_hal_buffer_layout(
64 enum v4l2_mpeg_vidc_video_mvc_layout index);
65struct hal_buffer_requirements *get_buff_req_buffer(
66 struct msm_vidc_inst *inst, u32 buffer_type);
67#define IS_PRIV_CTRL(idx) (\
68 (V4L2_CTRL_ID2WHICH(idx) == V4L2_CTRL_CLASS_MPEG) && \
69 V4L2_CTRL_DRIVER_PRIV(idx))
70void msm_comm_session_clean(struct msm_vidc_inst *inst);
71int msm_comm_kill_session(struct msm_vidc_inst *inst);
72enum multi_stream msm_comm_get_stream_output_mode(struct msm_vidc_inst *inst);
73enum hal_buffer msm_comm_get_hal_output_buffer(struct msm_vidc_inst *inst);
74struct msm_smem *msm_comm_smem_alloc(struct msm_vidc_inst *inst,
75 size_t size, u32 align, u32 flags,
76 enum hal_buffer buffer_type, int map_kernel);
77void msm_comm_smem_free(struct msm_vidc_inst *inst, struct msm_smem *mem);
78int msm_comm_smem_cache_operations(struct msm_vidc_inst *inst,
79 struct msm_smem *mem, enum smem_cache_ops cache_ops);
80struct msm_smem *msm_comm_smem_user_to_kernel(struct msm_vidc_inst *inst,
81 int fd, u32 offset, enum hal_buffer buffer_type);
82enum hal_video_codec get_hal_codec(int fourcc);
83enum hal_domain get_hal_domain(int session_type);
84int msm_comm_check_core_init(struct msm_vidc_core *core);
85int msm_comm_get_inst_load(struct msm_vidc_inst *inst,
86 enum load_calc_quirks quirks);
87int msm_comm_get_load(struct msm_vidc_core *core,
88 enum session_type type, enum load_calc_quirks quirks);
89int msm_comm_set_color_format(struct msm_vidc_inst *inst,
90 enum hal_buffer buffer_type, int fourcc);
91int msm_comm_g_ctrl(struct msm_vidc_inst *inst, struct v4l2_control *ctrl);
92int msm_comm_s_ctrl(struct msm_vidc_inst *inst, struct v4l2_control *ctrl);
93int msm_comm_g_ctrl_for_id(struct msm_vidc_inst *inst, int id);
94int msm_comm_ctrl_init(struct msm_vidc_inst *inst,
95 struct msm_vidc_ctrl *drv_ctrls, u32 num_ctrls,
96 const struct v4l2_ctrl_ops *ctrl_ops);
97int msm_comm_ctrl_deinit(struct msm_vidc_inst *inst);
98void msm_comm_cleanup_internal_buffers(struct msm_vidc_inst *inst);
99int msm_vidc_comm_s_parm(struct msm_vidc_inst *inst, struct v4l2_streamparm *a);
100bool msm_comm_turbo_session(struct msm_vidc_inst *inst);
101struct msm_vidc_inst *get_inst(struct msm_vidc_core *core, void *session_id);
102void put_inst(struct msm_vidc_inst *inst);
103#endif