2 * Copyright (c) 2012-2016, The Linux Foundation. All rights reserved.
3 * Copyright (C) 2017 Linaro Ltd.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 and
7 * only version 2 as published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
18 #include <linux/interrupt.h>
20 #include "hfi_helper.h"
22 #define VIDC_SESSION_TYPE_VPE 0
23 #define VIDC_SESSION_TYPE_ENC 1
24 #define VIDC_SESSION_TYPE_DEC 2
26 #define VIDC_RESOURCE_NONE 0
27 #define VIDC_RESOURCE_OCMEM 1
28 #define VIDC_RESOURCE_VMEM 2
30 struct hfi_buffer_desc
{
37 u32 response_required
;
40 struct hfi_frame_data
{
55 union hfi_get_property
{
56 struct hfi_profile_level profile_level
;
57 struct hfi_buffer_requirements bufreq
[HFI_BUFFER_TYPE_MAX
];
61 #define EVT_SYS_EVENT_CHANGE 1
62 #define EVT_SYS_WATCHDOG_TIMEOUT 2
63 #define EVT_SYS_ERROR 3
64 #define EVT_SESSION_ERROR 4
66 /* HFI event callback structure */
67 struct hfi_event_data
{
77 /* the following properties start appear from v4 onwards */
89 /* define core states */
93 /* define instance states */
96 #define INST_LOAD_RESOURCES 4
99 #define INST_RELEASE_RESOURCES 7
104 struct hfi_core_ops
{
105 void (*event_notify
)(struct venus_core
*core
, u32 event
);
108 struct hfi_inst_ops
{
109 void (*buf_done
)(struct venus_inst
*inst
, unsigned int buf_type
,
110 u32 tag
, u32 bytesused
, u32 data_offset
, u32 flags
,
111 u32 hfi_flags
, u64 timestamp_us
);
112 void (*event_notify
)(struct venus_inst
*inst
, u32 event
,
113 struct hfi_event_data
*data
);
117 int (*core_init
)(struct venus_core
*core
);
118 int (*core_deinit
)(struct venus_core
*core
);
119 int (*core_ping
)(struct venus_core
*core
, u32 cookie
);
120 int (*core_trigger_ssr
)(struct venus_core
*core
, u32 trigger_type
);
122 int (*session_init
)(struct venus_inst
*inst
, u32 session_type
,
124 int (*session_end
)(struct venus_inst
*inst
);
125 int (*session_abort
)(struct venus_inst
*inst
);
126 int (*session_flush
)(struct venus_inst
*inst
, u32 flush_mode
);
127 int (*session_start
)(struct venus_inst
*inst
);
128 int (*session_stop
)(struct venus_inst
*inst
);
129 int (*session_continue
)(struct venus_inst
*inst
);
130 int (*session_etb
)(struct venus_inst
*inst
, struct hfi_frame_data
*fd
);
131 int (*session_ftb
)(struct venus_inst
*inst
, struct hfi_frame_data
*fd
);
132 int (*session_set_buffers
)(struct venus_inst
*inst
,
133 struct hfi_buffer_desc
*bd
);
134 int (*session_unset_buffers
)(struct venus_inst
*inst
,
135 struct hfi_buffer_desc
*bd
);
136 int (*session_load_res
)(struct venus_inst
*inst
);
137 int (*session_release_res
)(struct venus_inst
*inst
);
138 int (*session_parse_seq_hdr
)(struct venus_inst
*inst
, u32 seq_hdr
,
140 int (*session_get_seq_hdr
)(struct venus_inst
*inst
, u32 seq_hdr
,
142 int (*session_set_property
)(struct venus_inst
*inst
, u32 ptype
,
144 int (*session_get_property
)(struct venus_inst
*inst
, u32 ptype
);
146 int (*resume
)(struct venus_core
*core
);
147 int (*suspend
)(struct venus_core
*core
);
149 /* interrupt operations */
150 irqreturn_t (*isr
)(struct venus_core
*core
);
151 irqreturn_t (*isr_thread
)(struct venus_core
*core
);
154 int hfi_create(struct venus_core
*core
, const struct hfi_core_ops
*ops
);
155 void hfi_destroy(struct venus_core
*core
);
157 int hfi_core_init(struct venus_core
*core
);
158 int hfi_core_deinit(struct venus_core
*core
, bool blocking
);
159 int hfi_core_suspend(struct venus_core
*core
);
160 int hfi_core_resume(struct venus_core
*core
, bool force
);
161 int hfi_core_trigger_ssr(struct venus_core
*core
, u32 type
);
162 int hfi_core_ping(struct venus_core
*core
);
163 int hfi_session_create(struct venus_inst
*inst
, const struct hfi_inst_ops
*ops
);
164 void hfi_session_destroy(struct venus_inst
*inst
);
165 int hfi_session_init(struct venus_inst
*inst
, u32 pixfmt
);
166 int hfi_session_deinit(struct venus_inst
*inst
);
167 int hfi_session_start(struct venus_inst
*inst
);
168 int hfi_session_stop(struct venus_inst
*inst
);
169 int hfi_session_continue(struct venus_inst
*inst
);
170 int hfi_session_abort(struct venus_inst
*inst
);
171 int hfi_session_load_res(struct venus_inst
*inst
);
172 int hfi_session_unload_res(struct venus_inst
*inst
);
173 int hfi_session_flush(struct venus_inst
*inst
);
174 int hfi_session_set_buffers(struct venus_inst
*inst
,
175 struct hfi_buffer_desc
*bd
);
176 int hfi_session_unset_buffers(struct venus_inst
*inst
,
177 struct hfi_buffer_desc
*bd
);
178 int hfi_session_get_property(struct venus_inst
*inst
, u32 ptype
,
179 union hfi_get_property
*hprop
);
180 int hfi_session_set_property(struct venus_inst
*inst
, u32 ptype
, void *pdata
);
181 int hfi_session_process_buf(struct venus_inst
*inst
, struct hfi_frame_data
*f
);
182 irqreturn_t
hfi_isr_thread(int irq
, void *dev_id
);
183 irqreturn_t
hfi_isr(int irq
, void *dev
);