blob: 623b6f0a5e05cd58fab2e974a70a45b59afc08ec [file] [log] [blame]
Praneeth Paladugu6e6fbdb2017-01-16 15:43:01 -08001/* Copyright (c) 2012-2017, 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_H_
15#define _MSM_VIDC_H_
16
17#include <linux/poll.h>
18#include <linux/videodev2.h>
19#include <linux/types.h>
20#include <linux/msm_ion.h>
21#include <uapi/media/msm_vidc.h>
22
Chinmay Sawarkar02f8f852017-06-26 12:05:38 -070023#define HAL_BUFFER_MAX 0xd
Praneeth Paladugu6e6fbdb2017-01-16 15:43:01 -080024
25enum smem_type {
26 SMEM_ION,
27};
28
29enum smem_prop {
30 SMEM_CACHED,
31 SMEM_SECURE,
32};
33
34/* NOTE: if you change this enum you MUST update the
35 * "buffer-type-tz-usage-table" for any affected target
36 * in arch/arm/boot/dts/<arch>.dtsi
37 */
38enum hal_buffer {
39 HAL_BUFFER_NONE = 0x0,
40 HAL_BUFFER_INPUT = 0x1,
41 HAL_BUFFER_OUTPUT = 0x2,
42 HAL_BUFFER_OUTPUT2 = 0x4,
43 HAL_BUFFER_EXTRADATA_INPUT = 0x8,
44 HAL_BUFFER_EXTRADATA_OUTPUT = 0x10,
45 HAL_BUFFER_EXTRADATA_OUTPUT2 = 0x20,
46 HAL_BUFFER_INTERNAL_SCRATCH = 0x40,
47 HAL_BUFFER_INTERNAL_SCRATCH_1 = 0x80,
48 HAL_BUFFER_INTERNAL_SCRATCH_2 = 0x100,
49 HAL_BUFFER_INTERNAL_PERSIST = 0x200,
50 HAL_BUFFER_INTERNAL_PERSIST_1 = 0x400,
51 HAL_BUFFER_INTERNAL_CMD_QUEUE = 0x800,
Praneeth Paladugu319e7922017-03-16 11:09:06 -070052 HAL_BUFFER_INTERNAL_RECON = 0x1000,
Praneeth Paladugu6e6fbdb2017-01-16 15:43:01 -080053};
54
55struct dma_mapping_info {
56 struct device *dev;
57 struct dma_iommu_mapping *mapping;
58 struct sg_table *table;
59 struct dma_buf_attachment *attach;
60 struct dma_buf *buf;
61};
62
63struct msm_smem {
Maheshwar Ajjac6407c02017-06-09 18:53:20 -070064 u32 refcount;
65 int fd;
66 void *dma_buf;
67 void *handle;
Praneeth Paladugu6e6fbdb2017-01-16 15:43:01 -080068 void *kvaddr;
Maheshwar Ajjac6407c02017-06-09 18:53:20 -070069 u32 device_addr;
70 unsigned int offset;
71 unsigned int size;
Praneeth Paladugu6e6fbdb2017-01-16 15:43:01 -080072 unsigned long flags;
Praneeth Paladugu6e6fbdb2017-01-16 15:43:01 -080073 enum hal_buffer buffer_type;
74 struct dma_mapping_info mapping_info;
Praneeth Paladugu6e6fbdb2017-01-16 15:43:01 -080075};
76
77enum smem_cache_ops {
78 SMEM_CACHE_CLEAN,
79 SMEM_CACHE_INVALIDATE,
80 SMEM_CACHE_CLEAN_INVALIDATE,
81};
82
83enum core_id {
84 MSM_VIDC_CORE_VENUS = 0,
85 MSM_VIDC_CORE_Q6,
86 MSM_VIDC_CORES_MAX,
87};
88enum session_type {
89 MSM_VIDC_ENCODER = 0,
90 MSM_VIDC_DECODER,
91 MSM_VIDC_UNKNOWN,
92 MSM_VIDC_MAX_DEVICES = MSM_VIDC_UNKNOWN,
93};
94
95union msm_v4l2_cmd {
96 struct v4l2_decoder_cmd dec;
97 struct v4l2_encoder_cmd enc;
98};
99
100void *msm_vidc_open(int core_id, int session_type);
101int msm_vidc_close(void *instance);
102int msm_vidc_suspend(int core_id);
103int msm_vidc_querycap(void *instance, struct v4l2_capability *cap);
104int msm_vidc_enum_fmt(void *instance, struct v4l2_fmtdesc *f);
105int msm_vidc_s_fmt(void *instance, struct v4l2_format *f);
106int msm_vidc_g_fmt(void *instance, struct v4l2_format *f);
107int msm_vidc_s_ctrl(void *instance, struct v4l2_control *a);
108int msm_vidc_s_ext_ctrl(void *instance, struct v4l2_ext_controls *a);
Praneeth Paladugu13c90962017-04-24 13:15:28 -0700109int msm_vidc_g_ext_ctrl(void *instance, struct v4l2_ext_controls *a);
Praneeth Paladugu6e6fbdb2017-01-16 15:43:01 -0800110int msm_vidc_g_ctrl(void *instance, struct v4l2_control *a);
111int msm_vidc_reqbufs(void *instance, struct v4l2_requestbuffers *b);
Praneeth Paladuguceec6d82016-12-21 15:09:57 -0800112int msm_vidc_release_buffer(void *instance, int buffer_type,
113 unsigned int buffer_index);
Praneeth Paladugu6e6fbdb2017-01-16 15:43:01 -0800114int msm_vidc_qbuf(void *instance, struct v4l2_buffer *b);
115int msm_vidc_dqbuf(void *instance, struct v4l2_buffer *b);
116int msm_vidc_streamon(void *instance, enum v4l2_buf_type i);
Praneeth Paladugue1679112017-01-27 10:07:15 -0800117int msm_vidc_query_ctrl(void *instance, struct v4l2_queryctrl *ctrl);
Praneeth Paladugu6e6fbdb2017-01-16 15:43:01 -0800118int msm_vidc_streamoff(void *instance, enum v4l2_buf_type i);
119int msm_vidc_comm_cmd(void *instance, union msm_v4l2_cmd *cmd);
120int msm_vidc_poll(void *instance, struct file *filp,
121 struct poll_table_struct *pt);
122int msm_vidc_subscribe_event(void *instance,
123 const struct v4l2_event_subscription *sub);
124int msm_vidc_unsubscribe_event(void *instance,
125 const struct v4l2_event_subscription *sub);
126int msm_vidc_dqevent(void *instance, struct v4l2_event *event);
Praneeth Paladugu72fa67b2017-05-30 11:20:01 -0700127int msm_vidc_g_crop(void *instance, struct v4l2_crop *a);
Praneeth Paladugu6e6fbdb2017-01-16 15:43:01 -0800128int msm_vidc_enum_framesizes(void *instance, struct v4l2_frmsizeenum *fsize);
129#endif