Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 1 | /* 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 Sawarkar | 02f8f85 | 2017-06-26 12:05:38 -0700 | [diff] [blame] | 23 | #define HAL_BUFFER_MAX 0xd |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 24 | |
| 25 | enum smem_type { |
| 26 | SMEM_ION, |
| 27 | }; |
| 28 | |
| 29 | enum 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 | */ |
| 38 | enum 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 Paladugu | 319e792 | 2017-03-16 11:09:06 -0700 | [diff] [blame] | 52 | HAL_BUFFER_INTERNAL_RECON = 0x1000, |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 53 | }; |
| 54 | |
| 55 | struct 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 | |
| 63 | struct msm_smem { |
Maheshwar Ajja | c6407c0 | 2017-06-09 18:53:20 -0700 | [diff] [blame] | 64 | u32 refcount; |
| 65 | int fd; |
| 66 | void *dma_buf; |
| 67 | void *handle; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 68 | void *kvaddr; |
Maheshwar Ajja | c6407c0 | 2017-06-09 18:53:20 -0700 | [diff] [blame] | 69 | u32 device_addr; |
| 70 | unsigned int offset; |
| 71 | unsigned int size; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 72 | unsigned long flags; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 73 | enum hal_buffer buffer_type; |
| 74 | struct dma_mapping_info mapping_info; |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 75 | }; |
| 76 | |
| 77 | enum smem_cache_ops { |
| 78 | SMEM_CACHE_CLEAN, |
| 79 | SMEM_CACHE_INVALIDATE, |
| 80 | SMEM_CACHE_CLEAN_INVALIDATE, |
| 81 | }; |
| 82 | |
| 83 | enum core_id { |
| 84 | MSM_VIDC_CORE_VENUS = 0, |
| 85 | MSM_VIDC_CORE_Q6, |
| 86 | MSM_VIDC_CORES_MAX, |
| 87 | }; |
| 88 | enum 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 | |
| 95 | union msm_v4l2_cmd { |
| 96 | struct v4l2_decoder_cmd dec; |
| 97 | struct v4l2_encoder_cmd enc; |
| 98 | }; |
| 99 | |
| 100 | void *msm_vidc_open(int core_id, int session_type); |
| 101 | int msm_vidc_close(void *instance); |
| 102 | int msm_vidc_suspend(int core_id); |
| 103 | int msm_vidc_querycap(void *instance, struct v4l2_capability *cap); |
| 104 | int msm_vidc_enum_fmt(void *instance, struct v4l2_fmtdesc *f); |
| 105 | int msm_vidc_s_fmt(void *instance, struct v4l2_format *f); |
| 106 | int msm_vidc_g_fmt(void *instance, struct v4l2_format *f); |
| 107 | int msm_vidc_s_ctrl(void *instance, struct v4l2_control *a); |
| 108 | int msm_vidc_s_ext_ctrl(void *instance, struct v4l2_ext_controls *a); |
Praneeth Paladugu | 13c9096 | 2017-04-24 13:15:28 -0700 | [diff] [blame] | 109 | int msm_vidc_g_ext_ctrl(void *instance, struct v4l2_ext_controls *a); |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 110 | int msm_vidc_g_ctrl(void *instance, struct v4l2_control *a); |
| 111 | int msm_vidc_reqbufs(void *instance, struct v4l2_requestbuffers *b); |
Praneeth Paladugu | ceec6d8 | 2016-12-21 15:09:57 -0800 | [diff] [blame] | 112 | int msm_vidc_release_buffer(void *instance, int buffer_type, |
| 113 | unsigned int buffer_index); |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 114 | int msm_vidc_qbuf(void *instance, struct v4l2_buffer *b); |
| 115 | int msm_vidc_dqbuf(void *instance, struct v4l2_buffer *b); |
| 116 | int msm_vidc_streamon(void *instance, enum v4l2_buf_type i); |
Praneeth Paladugu | e167911 | 2017-01-27 10:07:15 -0800 | [diff] [blame] | 117 | int msm_vidc_query_ctrl(void *instance, struct v4l2_queryctrl *ctrl); |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 118 | int msm_vidc_streamoff(void *instance, enum v4l2_buf_type i); |
| 119 | int msm_vidc_comm_cmd(void *instance, union msm_v4l2_cmd *cmd); |
| 120 | int msm_vidc_poll(void *instance, struct file *filp, |
| 121 | struct poll_table_struct *pt); |
| 122 | int msm_vidc_subscribe_event(void *instance, |
| 123 | const struct v4l2_event_subscription *sub); |
| 124 | int msm_vidc_unsubscribe_event(void *instance, |
| 125 | const struct v4l2_event_subscription *sub); |
| 126 | int msm_vidc_dqevent(void *instance, struct v4l2_event *event); |
Praneeth Paladugu | 72fa67b | 2017-05-30 11:20:01 -0700 | [diff] [blame] | 127 | int msm_vidc_g_crop(void *instance, struct v4l2_crop *a); |
Praneeth Paladugu | 6e6fbdb | 2017-01-16 15:43:01 -0800 | [diff] [blame] | 128 | int msm_vidc_enum_framesizes(void *instance, struct v4l2_frmsizeenum *fsize); |
| 129 | #endif |