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
{
79 /* define core states */
83 /* define instance states */
86 #define INST_LOAD_RESOURCES 4
89 #define INST_RELEASE_RESOURCES 7
95 void (*event_notify
)(struct venus_core
*core
, u32 event
);
99 void (*buf_done
)(struct venus_inst
*inst
, unsigned int buf_type
,
100 u32 tag
, u32 bytesused
, u32 data_offset
, u32 flags
,
101 u32 hfi_flags
, u64 timestamp_us
);
102 void (*event_notify
)(struct venus_inst
*inst
, u32 event
,
103 struct hfi_event_data
*data
);
107 int (*core_init
)(struct venus_core
*core
);
108 int (*core_deinit
)(struct venus_core
*core
);
109 int (*core_ping
)(struct venus_core
*core
, u32 cookie
);
110 int (*core_trigger_ssr
)(struct venus_core
*core
, u32 trigger_type
);
112 int (*session_init
)(struct venus_inst
*inst
, u32 session_type
,
114 int (*session_end
)(struct venus_inst
*inst
);
115 int (*session_abort
)(struct venus_inst
*inst
);
116 int (*session_flush
)(struct venus_inst
*inst
, u32 flush_mode
);
117 int (*session_start
)(struct venus_inst
*inst
);
118 int (*session_stop
)(struct venus_inst
*inst
);
119 int (*session_continue
)(struct venus_inst
*inst
);
120 int (*session_etb
)(struct venus_inst
*inst
, struct hfi_frame_data
*fd
);
121 int (*session_ftb
)(struct venus_inst
*inst
, struct hfi_frame_data
*fd
);
122 int (*session_set_buffers
)(struct venus_inst
*inst
,
123 struct hfi_buffer_desc
*bd
);
124 int (*session_unset_buffers
)(struct venus_inst
*inst
,
125 struct hfi_buffer_desc
*bd
);
126 int (*session_load_res
)(struct venus_inst
*inst
);
127 int (*session_release_res
)(struct venus_inst
*inst
);
128 int (*session_parse_seq_hdr
)(struct venus_inst
*inst
, u32 seq_hdr
,
130 int (*session_get_seq_hdr
)(struct venus_inst
*inst
, u32 seq_hdr
,
132 int (*session_set_property
)(struct venus_inst
*inst
, u32 ptype
,
134 int (*session_get_property
)(struct venus_inst
*inst
, u32 ptype
);
136 int (*resume
)(struct venus_core
*core
);
137 int (*suspend
)(struct venus_core
*core
);
139 /* interrupt operations */
140 irqreturn_t (*isr
)(struct venus_core
*core
);
141 irqreturn_t (*isr_thread
)(struct venus_core
*core
);
144 int hfi_create(struct venus_core
*core
, const struct hfi_core_ops
*ops
);
145 void hfi_destroy(struct venus_core
*core
);
147 int hfi_core_init(struct venus_core
*core
);
148 int hfi_core_deinit(struct venus_core
*core
, bool blocking
);
149 int hfi_core_suspend(struct venus_core
*core
);
150 int hfi_core_resume(struct venus_core
*core
, bool force
);
151 int hfi_core_trigger_ssr(struct venus_core
*core
, u32 type
);
152 int hfi_core_ping(struct venus_core
*core
);
153 int hfi_session_create(struct venus_inst
*inst
, const struct hfi_inst_ops
*ops
);
154 void hfi_session_destroy(struct venus_inst
*inst
);
155 int hfi_session_init(struct venus_inst
*inst
, u32 pixfmt
);
156 int hfi_session_deinit(struct venus_inst
*inst
);
157 int hfi_session_start(struct venus_inst
*inst
);
158 int hfi_session_stop(struct venus_inst
*inst
);
159 int hfi_session_continue(struct venus_inst
*inst
);
160 int hfi_session_abort(struct venus_inst
*inst
);
161 int hfi_session_load_res(struct venus_inst
*inst
);
162 int hfi_session_unload_res(struct venus_inst
*inst
);
163 int hfi_session_flush(struct venus_inst
*inst
);
164 int hfi_session_set_buffers(struct venus_inst
*inst
,
165 struct hfi_buffer_desc
*bd
);
166 int hfi_session_unset_buffers(struct venus_inst
*inst
,
167 struct hfi_buffer_desc
*bd
);
168 int hfi_session_get_property(struct venus_inst
*inst
, u32 ptype
,
169 union hfi_get_property
*hprop
);
170 int hfi_session_set_property(struct venus_inst
*inst
, u32 ptype
, void *pdata
);
171 int hfi_session_process_buf(struct venus_inst
*inst
, struct hfi_frame_data
*f
);
172 irqreturn_t
hfi_isr_thread(int irq
, void *dev_id
);
173 irqreturn_t
hfi_isr(int irq
, void *dev
);