aboutsummaryrefslogtreecommitdiff
path: root/drivers/media/platform/msm/camera/cam_cdm/cam_cdm_intf_api.h
blob: 2b00a87544fab1f1f96ae30bd93a68f01b59735b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * only version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

#ifndef _CAM_CDM_API_H_
#define _CAM_CDM_API_H_

#include <media/cam_defs.h>
#include "cam_cdm_util.h"
#include "cam_soc_util.h"

/* enum cam_cdm_id - Enum for possible CAM CDM hardwares */
enum cam_cdm_id {
	CAM_CDM_VIRTUAL,
	CAM_CDM_HW_ANY,
	CAM_CDM_CPAS_0,
	CAM_CDM_IPE0,
	CAM_CDM_IPE1,
	CAM_CDM_BPS,
	CAM_CDM_VFE,
	CAM_CDM_MAX
};

/* enum cam_cdm_cb_status - Enum for possible CAM CDM callback */
enum cam_cdm_cb_status {
	CAM_CDM_CB_STATUS_BL_SUCCESS,
	CAM_CDM_CB_STATUS_INVALID_BL_CMD,
	CAM_CDM_CB_STATUS_PAGEFAULT,
	CAM_CDM_CB_STATUS_HW_RESET_ONGOING,
	CAM_CDM_CB_STATUS_HW_RESET_DONE,
	CAM_CDM_CB_STATUS_UNKNOWN_ERROR,
};

/* enum cam_cdm_bl_cmd_addr_type - Enum for possible CDM bl cmd addr types */
enum cam_cdm_bl_cmd_addr_type {
	CAM_CDM_BL_CMD_TYPE_MEM_HANDLE,
	CAM_CDM_BL_CMD_TYPE_HW_IOVA,
	CAM_CDM_BL_CMD_TYPE_KERNEL_IOVA,
};

/**
 * struct cam_cdm_acquire_data - Cam CDM acquire data structure
 *
 * @identifier : Input identifier string which is the device label from dt
 *                    like vfe, ife, jpeg etc
 * @cell_index : Input integer identifier pointing to the cell index from dt
 *                     of the device. This can be used to form a unique string
 *                     with @identifier like vfe0, ife1, jpeg0 etc
 * @id : ID of a specific or any CDM HW which needs to be acquired.
 * @userdata : Input private data which will be returned as part
 *             of callback.
 * @cam_cdm_callback : Input callback pointer for triggering the
 *                     callbacks from CDM driver
 *                     @handle : CDM Client handle
 *                     @userdata : Private data given at the time of acquire
 *                     @status : Callback status
 *                     @cookie : Cookie if the callback is gen irq status
 * @base_array_cnt : Input number of ioremapped address pair pointing
 *                   in base_array, needed only if selected cdm is a virtual.
 * @base_array : Input pointer to ioremapped address pair arrary
 *               needed only if selected cdm is a virtual.
 * @cdm_version : CDM version is output while acquiring HW cdm and
 *                it is Input while acquiring virtual cdm, Currently fixing it
 *                to one version below acquire API.
 * @ops : Output pointer updated by cdm driver to the CDM
 *                     util ops for this HW version of CDM acquired.
 * @handle  : Output Unique handle generated for this acquire
 *
 */
struct cam_cdm_acquire_data {
	char identifier[128];
	uint32_t cell_index;
	enum cam_cdm_id id;
	void *userdata;
	void (*cam_cdm_callback)(uint32_t handle, void *userdata,
		enum cam_cdm_cb_status status, uint64_t cookie);
	uint32_t base_array_cnt;
	struct cam_soc_reg_map *base_array[CAM_SOC_MAX_BLOCK];
	struct cam_hw_version cdm_version;
	struct cam_cdm_utils_ops *ops;
	uint32_t handle;
};

/**
 * struct cam_cdm_bl_cmd - Cam CDM HW bl command
 *
 * @bl_addr : Union of all three type for CDM BL commands
 * @mem_handle : Input mem handle of bl cmd
 * @offset : Input offset of the actual bl cmd in the memory pointed
 *           by mem_handle
 * @len : Input length of the BL command, Cannot be more than 1MB and
 *           this is will be validated with offset+size of the memory pointed
 *           by mem_handle
 *
 */
struct cam_cdm_bl_cmd {
	union {
		int32_t mem_handle;
		uint32_t *hw_iova;
		void *kernel_iova;
	} bl_addr;
	uint32_t  offset;
	uint32_t  len;
};

/**
 * struct cam_cdm_bl_request - Cam CDM HW base & length (BL) request
 *
 * @flag : 1 for callback needed and 0 for no callback when this BL
 *            request is done
 * @userdata :Input private data which will be returned as part
 *             of callback if request for this bl request in flags.
 * @cookie : Cookie if the callback is gen irq status
 * @type : type of the submitted bl cmd address.
 * @cmd_arrary_count : Input number of BL commands to be submitted to CDM
 * @bl_cmd_array     : Input payload holding the BL cmd's arrary
 *                     to be sumbitted.
 *
 */
struct cam_cdm_bl_request {
	int flag;
	void *userdata;
	uint64_t cookie;
	enum cam_cdm_bl_cmd_addr_type type;
	uint32_t cmd_arrary_count;
	struct cam_cdm_bl_cmd cmd[1];
};

/**
 * @brief : API to get the CDM capabilities for a camera device type
 *
 * @identifier : Input pointer to a string which is the device label from dt
 *                   like vfe, ife, jpeg etc, We do not need cell index
 *                   assuming all devices of a single type maps to one SMMU
 *                   client
 * @cdm_handles : Input iommu handle memory pointer to update handles
 *
 * @return 0 on success
 */
int cam_cdm_get_iommu_handle(char *identifier,
	struct cam_iommu_handle *cdm_handles);

/**
 * @brief : API to acquire a CDM
 *
 * @data : Input data for the CDM to be acquired
 *
 * @return 0 on success
 */
int cam_cdm_acquire(struct cam_cdm_acquire_data *data);

/**
 * @brief : API to release a previously acquired CDM
 *
 * @handle : Input handle for the CDM to be released
 *
 * @return 0 on success
 */
int cam_cdm_release(uint32_t handle);

/**
 * @brief : API to submit the base & length (BL's) for acquired CDM
 *
 * @handle : Input cdm handle to which the BL's needs to be sumbitted.
 * @data   : Input pointer to the BL's to be sumbitted
 *
 * @return 0 on success
 */
int cam_cdm_submit_bls(uint32_t handle, struct cam_cdm_bl_request *data);

/**
 * @brief : API to stream ON a previously acquired CDM,
 *          during this we turn on/off clocks/power based on active clients.
 *
 * @handle : Input handle for the CDM to be released
 *
 * @return 0 on success
 */
int cam_cdm_stream_on(uint32_t handle);

/**
 * @brief : API to stream OFF a previously acquired CDM,
 *          during this we turn on/off clocks/power based on active clients.
 *
 * @handle : Input handle for the CDM to be released
 *
 * @return 0 on success
 */
int cam_cdm_stream_off(uint32_t handle);

/**
 * @brief : API to reset previously acquired CDM,
 *          this can be only performed only the CDM is private.
 *
 * @handle : Input handle of the CDM to reset
 *
 * @return 0 on success
 */
int cam_cdm_reset_hw(uint32_t handle);

#endif /* _CAM_CDM_API_H_ */