Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2012, Code Aurora Forum. 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 | #include <linux/slab.h> |
| 15 | #include <linux/workqueue.h> |
| 16 | #include <linux/interrupt.h> |
| 17 | #include <linux/io.h> |
Vinay Kalia | 94b221b | 2012-06-25 18:50:13 -0700 | [diff] [blame] | 18 | #include <linux/delay.h> |
Vinay Kalia | bc9f60a | 2012-07-17 01:23:42 -0700 | [diff] [blame] | 19 | #include <mach/ocmem.h> |
| 20 | |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 21 | #include <asm/memory.h> |
| 22 | #include "vidc_hal.h" |
| 23 | #include "vidc_hal_io.h" |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 24 | #include "msm_vidc_debug.h" |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 25 | |
| 26 | #define FIRMWARE_SIZE 0X00A00000 |
| 27 | #define REG_ADDR_OFFSET_BITMASK 0x000FFFFF |
| 28 | |
| 29 | /*Workaround for virtio */ |
Vinay Kalia | 68398a4 | 2012-06-22 18:36:12 -0700 | [diff] [blame] | 30 | #define HFI_VIRTIO_FW_BIAS 0x0 |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 31 | |
| 32 | struct hal_device_data hal_ctxt; |
| 33 | |
| 34 | static void hal_virtio_modify_cmd_packet(u8 *packet) |
| 35 | { |
| 36 | struct hfi_cmd_sys_session_init_packet *sys_init; |
| 37 | struct hal_session *sess; |
| 38 | u8 i; |
| 39 | |
| 40 | if (!packet) { |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 41 | dprintk(VIDC_ERR, "Invalid Param"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 42 | return; |
| 43 | } |
| 44 | |
| 45 | sys_init = (struct hfi_cmd_sys_session_init_packet *)packet; |
| 46 | sess = (struct hal_session *) sys_init->session_id; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 47 | switch (sys_init->packet_type) { |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 48 | case HFI_CMD_SESSION_EMPTY_BUFFER: |
| 49 | if (sess->is_decoder) { |
| 50 | struct hfi_cmd_session_empty_buffer_compressed_packet |
| 51 | *pkt = (struct |
| 52 | hfi_cmd_session_empty_buffer_compressed_packet |
| 53 | *) packet; |
| 54 | pkt->packet_buffer -= HFI_VIRTIO_FW_BIAS; |
| 55 | } else { |
| 56 | struct |
| 57 | hfi_cmd_session_empty_buffer_uncompressed_plane0_packet |
| 58 | *pkt = (struct |
| 59 | hfi_cmd_session_empty_buffer_uncompressed_plane0_packet |
| 60 | *) packet; |
| 61 | pkt->packet_buffer -= HFI_VIRTIO_FW_BIAS; |
| 62 | } |
| 63 | break; |
| 64 | case HFI_CMD_SESSION_FILL_BUFFER: |
| 65 | { |
| 66 | struct hfi_cmd_session_fill_buffer_packet *pkt = |
| 67 | (struct hfi_cmd_session_fill_buffer_packet *)packet; |
| 68 | pkt->packet_buffer -= HFI_VIRTIO_FW_BIAS; |
| 69 | break; |
| 70 | } |
| 71 | case HFI_CMD_SESSION_SET_BUFFERS: |
| 72 | { |
| 73 | struct hfi_cmd_session_set_buffers_packet *pkt = |
| 74 | (struct hfi_cmd_session_set_buffers_packet *)packet; |
| 75 | if ((pkt->buffer_type == HFI_BUFFER_OUTPUT) || |
| 76 | (pkt->buffer_type == HFI_BUFFER_OUTPUT2)) { |
| 77 | struct hfi_buffer_info *buff; |
| 78 | buff = (struct hfi_buffer_info *) pkt->rg_buffer_info; |
| 79 | buff->buffer_addr -= HFI_VIRTIO_FW_BIAS; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 80 | buff->extra_data_addr -= HFI_VIRTIO_FW_BIAS; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 81 | } else { |
| 82 | for (i = 0; i < pkt->num_buffers; i++) |
| 83 | pkt->rg_buffer_info[i] -= HFI_VIRTIO_FW_BIAS; |
| 84 | } |
| 85 | break; |
| 86 | } |
| 87 | case HFI_CMD_SESSION_RELEASE_BUFFERS: |
| 88 | { |
| 89 | struct hfi_cmd_session_release_buffer_packet *pkt = |
| 90 | (struct hfi_cmd_session_release_buffer_packet *)packet; |
Ashray Kulkarni | 1c72b39 | 2012-06-20 10:50:00 -0700 | [diff] [blame] | 91 | if ((pkt->buffer_type == HFI_BUFFER_OUTPUT) || |
| 92 | (pkt->buffer_type == HFI_BUFFER_OUTPUT2)) { |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 93 | struct hfi_buffer_info *buff; |
| 94 | buff = (struct hfi_buffer_info *) pkt->rg_buffer_info; |
| 95 | buff->buffer_addr -= HFI_VIRTIO_FW_BIAS; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 96 | buff->extra_data_addr -= HFI_VIRTIO_FW_BIAS; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 97 | } else { |
| 98 | for (i = 0; i < pkt->num_buffers; i++) |
| 99 | pkt->rg_buffer_info[i] -= HFI_VIRTIO_FW_BIAS; |
| 100 | } |
| 101 | break; |
| 102 | } |
| 103 | case HFI_CMD_SESSION_PARSE_SEQUENCE_HEADER: |
| 104 | { |
| 105 | struct hfi_cmd_session_parse_sequence_header_packet *pkt = |
| 106 | (struct hfi_cmd_session_parse_sequence_header_packet *) |
| 107 | packet; |
| 108 | pkt->packet_buffer -= HFI_VIRTIO_FW_BIAS; |
| 109 | break; |
| 110 | } |
| 111 | case HFI_CMD_SESSION_GET_SEQUENCE_HEADER: |
| 112 | { |
| 113 | struct hfi_cmd_session_get_sequence_header_packet *pkt = |
| 114 | (struct hfi_cmd_session_get_sequence_header_packet *) |
| 115 | packet; |
| 116 | pkt->packet_buffer -= HFI_VIRTIO_FW_BIAS; |
| 117 | break; |
| 118 | } |
| 119 | default: |
| 120 | break; |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | static int write_queue(void *info, u8 *packet, u32 *rx_req_is_set) |
| 125 | { |
| 126 | struct hfi_queue_header *queue; |
| 127 | u32 packet_size_in_words, new_write_idx; |
| 128 | struct vidc_iface_q_info *qinfo; |
| 129 | u32 empty_space, read_idx; |
| 130 | u32 *write_ptr; |
| 131 | |
| 132 | if (!info || !packet || !rx_req_is_set) { |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 133 | dprintk(VIDC_ERR, "Invalid Params"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 134 | return -EINVAL; |
| 135 | } |
| 136 | |
| 137 | qinfo = (struct vidc_iface_q_info *) info; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 138 | hal_virtio_modify_cmd_packet(packet); |
| 139 | |
| 140 | queue = (struct hfi_queue_header *) qinfo->q_hdr; |
| 141 | |
| 142 | if (!queue) { |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 143 | dprintk(VIDC_ERR, "queue not present"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 144 | return -ENOENT; |
| 145 | } |
| 146 | |
| 147 | packet_size_in_words = (*(u32 *)packet) >> 2; |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 148 | dprintk(VIDC_DBG, "Packet_size in words: %d", packet_size_in_words); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 149 | |
| 150 | if (packet_size_in_words == 0) { |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 151 | dprintk(VIDC_ERR, "Zero packet size"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 152 | return -ENODATA; |
| 153 | } |
| 154 | |
| 155 | read_idx = queue->qhdr_read_idx; |
| 156 | |
| 157 | empty_space = (queue->qhdr_write_idx >= read_idx) ? |
| 158 | (queue->qhdr_q_size - (queue->qhdr_write_idx - read_idx)) : |
| 159 | (read_idx - queue->qhdr_write_idx); |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 160 | dprintk(VIDC_DBG, "Empty_space: %d", empty_space); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 161 | if (empty_space <= packet_size_in_words) { |
| 162 | queue->qhdr_tx_req = 1; |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 163 | dprintk(VIDC_ERR, "Insufficient size (%d) to write (%d)", |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 164 | empty_space, packet_size_in_words); |
| 165 | return -ENOTEMPTY; |
| 166 | } |
| 167 | |
| 168 | queue->qhdr_tx_req = 0; |
| 169 | |
| 170 | new_write_idx = (queue->qhdr_write_idx + packet_size_in_words); |
| 171 | write_ptr = (u32 *)((qinfo->q_array.align_virtual_addr) + |
| 172 | (queue->qhdr_write_idx << 2)); |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 173 | dprintk(VIDC_DBG, "Write Ptr: %d", (u32) write_ptr); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 174 | if (new_write_idx < queue->qhdr_q_size) { |
| 175 | memcpy(write_ptr, packet, packet_size_in_words << 2); |
| 176 | } else { |
| 177 | new_write_idx -= queue->qhdr_q_size; |
| 178 | memcpy(write_ptr, packet, (packet_size_in_words - |
| 179 | new_write_idx) << 2); |
Vinay Kalia | bddb1eb | 2012-09-24 18:01:57 -0700 | [diff] [blame] | 180 | memcpy((void *)qinfo->q_array.align_virtual_addr, |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 181 | packet + ((packet_size_in_words - new_write_idx) << 2), |
| 182 | new_write_idx << 2); |
| 183 | } |
| 184 | queue->qhdr_write_idx = new_write_idx; |
| 185 | *rx_req_is_set = (1 == queue->qhdr_rx_req) ? 1 : 0; |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 186 | dprintk(VIDC_DBG, "Out : "); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 187 | return 0; |
| 188 | } |
| 189 | |
| 190 | static void hal_virtio_modify_msg_packet(u8 *packet) |
| 191 | { |
| 192 | struct hfi_msg_sys_session_init_done_packet *sys_idle; |
| 193 | struct hal_session *sess; |
| 194 | |
| 195 | if (!packet) { |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 196 | dprintk(VIDC_ERR, "Invalid Param: "); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 197 | return; |
| 198 | } |
| 199 | |
| 200 | sys_idle = (struct hfi_msg_sys_session_init_done_packet *)packet; |
| 201 | sess = (struct hal_session *) sys_idle->session_id; |
| 202 | |
| 203 | switch (sys_idle->packet_type) { |
| 204 | case HFI_MSG_SESSION_FILL_BUFFER_DONE: |
| 205 | if (sess->is_decoder) { |
| 206 | struct |
| 207 | hfi_msg_session_fbd_uncompressed_plane0_packet |
| 208 | *pkt_uc = (struct |
| 209 | hfi_msg_session_fbd_uncompressed_plane0_packet |
| 210 | *) packet; |
| 211 | pkt_uc->packet_buffer += HFI_VIRTIO_FW_BIAS; |
| 212 | } else { |
| 213 | struct |
| 214 | hfi_msg_session_fill_buffer_done_compressed_packet |
| 215 | *pkt = (struct |
| 216 | hfi_msg_session_fill_buffer_done_compressed_packet |
| 217 | *) packet; |
| 218 | pkt->packet_buffer += HFI_VIRTIO_FW_BIAS; |
| 219 | } |
| 220 | break; |
| 221 | case HFI_MSG_SESSION_EMPTY_BUFFER_DONE: |
| 222 | { |
| 223 | struct hfi_msg_session_empty_buffer_done_packet *pkt = |
| 224 | (struct hfi_msg_session_empty_buffer_done_packet *)packet; |
| 225 | pkt->packet_buffer += HFI_VIRTIO_FW_BIAS; |
| 226 | break; |
| 227 | } |
| 228 | case HFI_MSG_SESSION_GET_SEQUENCE_HEADER_DONE: |
| 229 | { |
| 230 | struct |
| 231 | hfi_msg_session_get_sequence_header_done_packet |
| 232 | *pkt = |
| 233 | (struct hfi_msg_session_get_sequence_header_done_packet *) |
| 234 | packet; |
| 235 | pkt->sequence_header += HFI_VIRTIO_FW_BIAS; |
| 236 | break; |
| 237 | } |
| 238 | default: |
| 239 | break; |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | static int read_queue(void *info, u8 *packet, u32 *pb_tx_req_is_set) |
| 244 | { |
| 245 | struct hfi_queue_header *queue; |
| 246 | u32 packet_size_in_words, new_read_idx; |
| 247 | u32 *read_ptr; |
| 248 | struct vidc_iface_q_info *qinfo; |
| 249 | |
| 250 | if (!info || !packet || !pb_tx_req_is_set) { |
Ashray Kulkarni | 000b382 | 2012-10-11 18:20:58 -0700 | [diff] [blame] | 251 | dprintk(VIDC_ERR, "Invalid Params"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 252 | return -EINVAL; |
| 253 | } |
| 254 | |
| 255 | qinfo = (struct vidc_iface_q_info *) info; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 256 | queue = (struct hfi_queue_header *) qinfo->q_hdr; |
| 257 | |
| 258 | if (!queue) { |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 259 | dprintk(VIDC_ERR, "Queue memory is not allocated\n"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 260 | return -ENOMEM; |
| 261 | } |
| 262 | |
| 263 | if (queue->qhdr_read_idx == queue->qhdr_write_idx) { |
| 264 | queue->qhdr_rx_req = 1; |
| 265 | *pb_tx_req_is_set = 0; |
| 266 | return -EPERM; |
| 267 | } |
| 268 | |
| 269 | read_ptr = (u32 *)((qinfo->q_array.align_virtual_addr) + |
| 270 | (queue->qhdr_read_idx << 2)); |
| 271 | packet_size_in_words = (*read_ptr) >> 2; |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 272 | dprintk(VIDC_DBG, "packet_size_in_words: %d", packet_size_in_words); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 273 | if (packet_size_in_words == 0) { |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 274 | dprintk(VIDC_ERR, "Zero packet size"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 275 | return -ENODATA; |
| 276 | } |
| 277 | |
| 278 | new_read_idx = queue->qhdr_read_idx + packet_size_in_words; |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 279 | dprintk(VIDC_DBG, "Read Ptr: %d", (u32) new_read_idx); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 280 | if (new_read_idx < queue->qhdr_q_size) { |
| 281 | memcpy(packet, read_ptr, |
| 282 | packet_size_in_words << 2); |
| 283 | } else { |
| 284 | new_read_idx -= queue->qhdr_q_size; |
| 285 | memcpy(packet, read_ptr, |
| 286 | (packet_size_in_words - new_read_idx) << 2); |
| 287 | memcpy(packet + ((packet_size_in_words - |
Vinay Kalia | bddb1eb | 2012-09-24 18:01:57 -0700 | [diff] [blame] | 288 | new_read_idx) << 2), |
| 289 | (u8 *)qinfo->q_array.align_virtual_addr, |
| 290 | new_read_idx << 2); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 291 | } |
| 292 | |
| 293 | queue->qhdr_read_idx = new_read_idx; |
| 294 | |
| 295 | if (queue->qhdr_read_idx != queue->qhdr_write_idx) |
| 296 | queue->qhdr_rx_req = 0; |
| 297 | else |
| 298 | queue->qhdr_rx_req = 1; |
| 299 | |
| 300 | *pb_tx_req_is_set = (1 == queue->qhdr_tx_req) ? 1 : 0; |
| 301 | hal_virtio_modify_msg_packet(packet); |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 302 | dprintk(VIDC_DBG, "Out : "); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 303 | return 0; |
| 304 | } |
| 305 | |
Vinay Kalia | 68398a4 | 2012-06-22 18:36:12 -0700 | [diff] [blame] | 306 | static int vidc_hal_alloc(void *mem, void *clnt, u32 size, u32 align, u32 flags, |
| 307 | int domain) |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 308 | { |
| 309 | struct vidc_mem_addr *vmem; |
| 310 | struct msm_smem *alloc; |
Vinay Kalia | e38c55f | 2012-08-16 19:37:28 -0700 | [diff] [blame] | 311 | int rc = 0; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 312 | |
| 313 | if (!mem || !clnt || !size) { |
Ashray Kulkarni | 000b382 | 2012-10-11 18:20:58 -0700 | [diff] [blame] | 314 | dprintk(VIDC_ERR, "Invalid Params"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 315 | return -EINVAL; |
| 316 | } |
| 317 | vmem = (struct vidc_mem_addr *)mem; |
Ashray Kulkarni | 000b382 | 2012-10-11 18:20:58 -0700 | [diff] [blame] | 318 | dprintk(VIDC_INFO, "start to alloc: size:%d, Flags: %d", size, flags); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 319 | |
Vinay Kalia | e38c55f | 2012-08-16 19:37:28 -0700 | [diff] [blame] | 320 | alloc = msm_smem_alloc(clnt, size, align, flags, domain, 1, 1); |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 321 | dprintk(VIDC_DBG, "Alloc done"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 322 | if (!alloc) { |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 323 | dprintk(VIDC_ERR, "Alloc failed\n"); |
Vinay Kalia | e38c55f | 2012-08-16 19:37:28 -0700 | [diff] [blame] | 324 | rc = -ENOMEM; |
| 325 | goto fail_smem_alloc; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 326 | } |
Vinay Kalia | e38c55f | 2012-08-16 19:37:28 -0700 | [diff] [blame] | 327 | rc = msm_smem_clean_invalidate(clnt, alloc); |
| 328 | if (rc) { |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 329 | dprintk(VIDC_ERR, "NOTE: Failed to clean caches\n"); |
Vinay Kalia | e38c55f | 2012-08-16 19:37:28 -0700 | [diff] [blame] | 330 | goto fail_clean_cache; |
| 331 | } |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 332 | dprintk(VIDC_DBG, "vidc_hal_alloc:ptr=%p,size=%d", |
Vinay Kalia | e38c55f | 2012-08-16 19:37:28 -0700 | [diff] [blame] | 333 | alloc->kvaddr, size); |
| 334 | vmem->mem_size = alloc->size; |
| 335 | vmem->mem_data = alloc; |
| 336 | vmem->align_virtual_addr = (u8 *) alloc->kvaddr; |
| 337 | vmem->align_device_addr = (u8 *)alloc->device_addr; |
| 338 | return rc; |
| 339 | fail_clean_cache: |
| 340 | msm_smem_free(clnt, alloc); |
| 341 | fail_smem_alloc: |
| 342 | return rc; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 343 | } |
| 344 | |
| 345 | static void vidc_hal_free(struct smem_client *clnt, struct msm_smem *mem) |
| 346 | { |
| 347 | msm_smem_free(clnt, mem); |
| 348 | } |
| 349 | |
| 350 | static void write_register(u8 *base_addr, u32 reg, u32 value, u8 *vaddr) |
| 351 | { |
| 352 | u32 hwiosymaddr = reg; |
| 353 | |
| 354 | reg &= REG_ADDR_OFFSET_BITMASK; |
| 355 | if (reg == (u32)VIDC_CPU_CS_SCIACMDARG2) { |
| 356 | /* workaround to offset of FW bias */ |
| 357 | struct hfi_queue_header *qhdr; |
| 358 | struct hfi_queue_table_header *qtbl_hdr = |
| 359 | (struct hfi_queue_table_header *)vaddr; |
| 360 | |
| 361 | qhdr = VIDC_IFACEQ_GET_QHDR_START_ADDR(qtbl_hdr, 0); |
| 362 | qhdr->qhdr_start_addr -= HFI_VIRTIO_FW_BIAS; |
| 363 | |
| 364 | qhdr = VIDC_IFACEQ_GET_QHDR_START_ADDR(qtbl_hdr, 1); |
| 365 | qhdr->qhdr_start_addr -= HFI_VIRTIO_FW_BIAS; |
| 366 | |
| 367 | qhdr = VIDC_IFACEQ_GET_QHDR_START_ADDR(qtbl_hdr, 2); |
| 368 | qhdr->qhdr_start_addr -= HFI_VIRTIO_FW_BIAS; |
| 369 | value -= HFI_VIRTIO_FW_BIAS; |
| 370 | } |
| 371 | |
| 372 | hwiosymaddr = ((u32)base_addr + (hwiosymaddr)); |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 373 | dprintk(VIDC_DBG, "Base addr: 0x%x, written to: 0x%x, Value: 0x%x...", |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 374 | (u32)base_addr, hwiosymaddr, value); |
| 375 | writel_relaxed(value, hwiosymaddr); |
| 376 | wmb(); |
| 377 | } |
| 378 | |
| 379 | static int read_register(u8 *base_addr, u32 reg) |
| 380 | { |
| 381 | int rc = readl_relaxed((u32)base_addr + reg); |
| 382 | rmb(); |
| 383 | return rc; |
| 384 | } |
| 385 | |
| 386 | static int vidc_hal_iface_cmdq_write(struct hal_device *device, void *pkt) |
| 387 | { |
| 388 | u32 rx_req_is_set = 0; |
| 389 | struct vidc_iface_q_info *q_info; |
| 390 | int result = -EPERM; |
| 391 | |
| 392 | if (!device || !pkt) { |
Ashray Kulkarni | 000b382 | 2012-10-11 18:20:58 -0700 | [diff] [blame] | 393 | dprintk(VIDC_ERR, "Invalid Params"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 394 | return -EINVAL; |
| 395 | } |
| 396 | |
| 397 | spin_lock(&device->write_lock); |
| 398 | q_info = &device->iface_queues[VIDC_IFACEQ_CMDQ_IDX]; |
| 399 | if (!q_info) { |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 400 | dprintk(VIDC_ERR, "cannot write to shared Q's"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 401 | goto err_q_write; |
| 402 | } |
| 403 | |
| 404 | if (!write_queue(q_info, (u8 *)pkt, &rx_req_is_set)) { |
| 405 | if (rx_req_is_set) |
| 406 | write_register(device->hal_data->register_base_addr, |
| 407 | VIDC_CPU_IC_SOFTINT, |
| 408 | 1 << VIDC_CPU_IC_SOFTINT_H2A_SHFT, 0); |
| 409 | result = 0; |
| 410 | } else { |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 411 | dprintk(VIDC_ERR, "vidc_hal_iface_cmdq_write:queue_full"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 412 | } |
| 413 | err_q_write: |
| 414 | spin_unlock(&device->write_lock); |
| 415 | return result; |
| 416 | } |
| 417 | |
| 418 | int vidc_hal_iface_msgq_read(struct hal_device *device, void *pkt) |
| 419 | { |
| 420 | u32 tx_req_is_set = 0; |
| 421 | int rc = 0; |
| 422 | struct vidc_iface_q_info *q_info; |
| 423 | |
| 424 | if (!pkt) { |
Ashray Kulkarni | 000b382 | 2012-10-11 18:20:58 -0700 | [diff] [blame] | 425 | dprintk(VIDC_ERR, "Invalid Params"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 426 | return -EINVAL; |
| 427 | } |
| 428 | spin_lock(&device->read_lock); |
| 429 | if (device->iface_queues[VIDC_IFACEQ_MSGQ_IDX]. |
| 430 | q_array.align_virtual_addr == 0) { |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 431 | dprintk(VIDC_ERR, "cannot read from shared MSG Q's"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 432 | rc = -ENODATA; |
| 433 | goto read_error; |
| 434 | } |
| 435 | q_info = &device->iface_queues[VIDC_IFACEQ_MSGQ_IDX]; |
| 436 | |
| 437 | if (!read_queue(q_info, (u8 *)pkt, &tx_req_is_set)) { |
| 438 | if (tx_req_is_set) |
| 439 | write_register(device->hal_data->register_base_addr, |
| 440 | VIDC_CPU_IC_SOFTINT, |
| 441 | 1 << VIDC_CPU_IC_SOFTINT_H2A_SHFT, 0); |
| 442 | rc = 0; |
| 443 | } else { |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 444 | dprintk(VIDC_INFO, "vidc_hal_iface_msgq_read:queue_empty"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 445 | rc = -ENODATA; |
| 446 | } |
| 447 | read_error: |
| 448 | spin_unlock(&device->read_lock); |
| 449 | return rc; |
| 450 | } |
| 451 | |
| 452 | int vidc_hal_iface_dbgq_read(struct hal_device *device, void *pkt) |
| 453 | { |
| 454 | u32 tx_req_is_set = 0; |
| 455 | int rc = 0; |
| 456 | struct vidc_iface_q_info *q_info; |
| 457 | |
| 458 | if (!pkt) { |
Ashray Kulkarni | 000b382 | 2012-10-11 18:20:58 -0700 | [diff] [blame] | 459 | dprintk(VIDC_ERR, "Invalid Params"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 460 | return -EINVAL; |
| 461 | } |
| 462 | spin_lock(&device->read_lock); |
| 463 | if (device->iface_queues[VIDC_IFACEQ_DBGQ_IDX]. |
| 464 | q_array.align_virtual_addr == 0) { |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 465 | dprintk(VIDC_ERR, "cannot read from shared DBG Q's"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 466 | rc = -ENODATA; |
| 467 | goto dbg_error; |
| 468 | } |
| 469 | q_info = &device->iface_queues[VIDC_IFACEQ_DBGQ_IDX]; |
| 470 | if (!read_queue(q_info, (u8 *)pkt, &tx_req_is_set)) { |
| 471 | if (tx_req_is_set) |
| 472 | write_register(device->hal_data->register_base_addr, |
| 473 | VIDC_CPU_IC_SOFTINT, |
| 474 | 1 << VIDC_CPU_IC_SOFTINT_H2A_SHFT, 0); |
| 475 | rc = 0; |
| 476 | } else { |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 477 | dprintk(VIDC_INFO, "vidc_hal_iface_dbgq_read:queue_empty"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 478 | rc = -ENODATA; |
| 479 | } |
| 480 | dbg_error: |
| 481 | spin_unlock(&device->read_lock); |
| 482 | return rc; |
| 483 | } |
| 484 | |
| 485 | static void vidc_hal_set_queue_hdr_defaults(struct hfi_queue_header *q_hdr) |
| 486 | { |
| 487 | q_hdr->qhdr_status = 0x1; |
| 488 | q_hdr->qhdr_type = VIDC_IFACEQ_DFLT_QHDR; |
Ashray Kulkarni | 3dbe999 | 2012-08-20 12:22:57 -0700 | [diff] [blame] | 489 | q_hdr->qhdr_q_size = VIDC_IFACEQ_QUEUE_SIZE / 4; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 490 | q_hdr->qhdr_pkt_size = 0; |
| 491 | q_hdr->qhdr_rx_wm = 0x1; |
| 492 | q_hdr->qhdr_tx_wm = 0x1; |
| 493 | q_hdr->qhdr_rx_req = 0x1; |
| 494 | q_hdr->qhdr_tx_req = 0x0; |
| 495 | q_hdr->qhdr_rx_irq_status = 0x0; |
| 496 | q_hdr->qhdr_tx_irq_status = 0x0; |
| 497 | q_hdr->qhdr_read_idx = 0x0; |
| 498 | q_hdr->qhdr_write_idx = 0x0; |
| 499 | } |
| 500 | |
| 501 | static void vidc_hal_interface_queues_release(struct hal_device *device) |
| 502 | { |
| 503 | int i; |
| 504 | for (i = 0; i < VIDC_IFACEQ_NUMQ; i++) { |
| 505 | vidc_hal_free(device->hal_client, |
| 506 | device->iface_queues[i].q_array.mem_data); |
| 507 | device->iface_queues[i].q_hdr = NULL; |
| 508 | device->iface_queues[i].q_array.mem_data = NULL; |
| 509 | device->iface_queues[i].q_array.align_virtual_addr = NULL; |
| 510 | device->iface_queues[i].q_array.align_device_addr = NULL; |
| 511 | } |
| 512 | vidc_hal_free(device->hal_client, |
| 513 | device->iface_q_table.mem_data); |
| 514 | device->iface_q_table.align_virtual_addr = NULL; |
| 515 | device->iface_q_table.align_device_addr = NULL; |
| 516 | msm_smem_delete_client(device->hal_client); |
| 517 | device->hal_client = NULL; |
| 518 | } |
| 519 | |
Vinay Kalia | 68398a4 | 2012-06-22 18:36:12 -0700 | [diff] [blame] | 520 | static int vidc_hal_interface_queues_init(struct hal_device *dev, int domain) |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 521 | { |
| 522 | struct hfi_queue_table_header *q_tbl_hdr; |
| 523 | struct hfi_queue_header *q_hdr; |
| 524 | u8 i; |
| 525 | int rc = 0; |
| 526 | struct vidc_iface_q_info *iface_q; |
| 527 | |
| 528 | rc = vidc_hal_alloc((void *) &dev->iface_q_table, |
| 529 | dev->hal_client, |
Vinay Kalia | e38c55f | 2012-08-16 19:37:28 -0700 | [diff] [blame] | 530 | VIDC_IFACEQ_TABLE_SIZE, 1, SMEM_UNCACHED, domain); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 531 | if (rc) { |
Ashray Kulkarni | b673450 | 2012-08-24 13:00:22 -0700 | [diff] [blame] | 532 | dprintk(VIDC_ERR, "iface_q_table_alloc_fail"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 533 | return -ENOMEM; |
| 534 | } |
| 535 | q_tbl_hdr = (struct hfi_queue_table_header *) |
| 536 | dev->iface_q_table.align_virtual_addr; |
| 537 | q_tbl_hdr->qtbl_version = 0; |
| 538 | q_tbl_hdr->qtbl_size = VIDC_IFACEQ_TABLE_SIZE; |
| 539 | q_tbl_hdr->qtbl_qhdr0_offset = sizeof( |
| 540 | struct hfi_queue_table_header); |
| 541 | q_tbl_hdr->qtbl_qhdr_size = sizeof( |
| 542 | struct hfi_queue_header); |
| 543 | q_tbl_hdr->qtbl_num_q = VIDC_IFACEQ_NUMQ; |
| 544 | q_tbl_hdr->qtbl_num_active_q = VIDC_IFACEQ_NUMQ; |
| 545 | |
| 546 | for (i = 0; i < VIDC_IFACEQ_NUMQ; i++) { |
| 547 | iface_q = &dev->iface_queues[i]; |
| 548 | rc = vidc_hal_alloc((void *) &iface_q->q_array, |
| 549 | dev->hal_client, VIDC_IFACEQ_QUEUE_SIZE, |
Vinay Kalia | e38c55f | 2012-08-16 19:37:28 -0700 | [diff] [blame] | 550 | 1, SMEM_UNCACHED, domain); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 551 | if (rc) { |
Ashray Kulkarni | b673450 | 2012-08-24 13:00:22 -0700 | [diff] [blame] | 552 | dprintk(VIDC_ERR, "iface_q_table_alloc[%d]_fail", i); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 553 | vidc_hal_interface_queues_release(dev); |
| 554 | return -ENOMEM; |
| 555 | } else { |
| 556 | iface_q->q_hdr = |
| 557 | VIDC_IFACEQ_GET_QHDR_START_ADDR( |
| 558 | dev->iface_q_table.align_virtual_addr, i); |
| 559 | vidc_hal_set_queue_hdr_defaults(iface_q->q_hdr); |
| 560 | } |
| 561 | } |
| 562 | |
| 563 | iface_q = &dev->iface_queues[VIDC_IFACEQ_CMDQ_IDX]; |
| 564 | q_hdr = iface_q->q_hdr; |
| 565 | q_hdr->qhdr_start_addr = (u32) |
| 566 | iface_q->q_array.align_device_addr; |
| 567 | q_hdr->qhdr_type |= HFI_Q_ID_HOST_TO_CTRL_CMD_Q; |
| 568 | |
| 569 | iface_q = &dev->iface_queues[VIDC_IFACEQ_MSGQ_IDX]; |
| 570 | q_hdr = iface_q->q_hdr; |
| 571 | q_hdr->qhdr_start_addr = (u32) |
| 572 | iface_q->q_array.align_device_addr; |
| 573 | q_hdr->qhdr_type |= HFI_Q_ID_CTRL_TO_HOST_MSG_Q; |
| 574 | |
| 575 | iface_q = &dev->iface_queues[VIDC_IFACEQ_DBGQ_IDX]; |
| 576 | q_hdr = iface_q->q_hdr; |
| 577 | q_hdr->qhdr_start_addr = (u32) |
| 578 | iface_q->q_array.align_device_addr; |
| 579 | q_hdr->qhdr_type |= HFI_Q_ID_CTRL_TO_HOST_DEBUG_Q; |
| 580 | write_register(dev->hal_data->register_base_addr, |
| 581 | VIDC_CPU_CS_SCIACMDARG2, |
| 582 | (u32) dev->iface_q_table.align_device_addr, |
| 583 | dev->iface_q_table.align_virtual_addr); |
| 584 | write_register(dev->hal_data->register_base_addr, |
| 585 | VIDC_CPU_CS_SCIACMDARG1, 0x01, |
| 586 | dev->iface_q_table.align_virtual_addr); |
| 587 | return 0; |
| 588 | } |
| 589 | |
| 590 | static int vidc_hal_core_start_cpu(struct hal_device *device) |
| 591 | { |
| 592 | u32 ctrl_status = 0, count = 0, rc = 0; |
Vinay Kalia | 15e870b | 2012-09-10 15:30:23 -0700 | [diff] [blame] | 593 | int max_tries = 100; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 594 | write_register(device->hal_data->register_base_addr, |
| 595 | VIDC_WRAPPER_INTR_MASK, 0, 0); |
| 596 | write_register(device->hal_data->register_base_addr, |
| 597 | VIDC_CPU_CS_SCIACMDARG3, 1, 0); |
Vinay Kalia | 15e870b | 2012-09-10 15:30:23 -0700 | [diff] [blame] | 598 | while (!ctrl_status && count < max_tries) { |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 599 | ctrl_status = read_register( |
| 600 | device->hal_data->register_base_addr, |
| 601 | VIDC_CPU_CS_SCIACMDARG0); |
Vinay Kalia | 94b221b | 2012-06-25 18:50:13 -0700 | [diff] [blame] | 602 | usleep_range(500, 1000); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 603 | count++; |
| 604 | } |
Vinay Kalia | 15e870b | 2012-09-10 15:30:23 -0700 | [diff] [blame] | 605 | if (count >= max_tries) |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 606 | rc = -ETIME; |
| 607 | return rc; |
| 608 | } |
| 609 | |
Vinay Kalia | cdf8d0c | 2012-08-28 12:07:36 -0700 | [diff] [blame] | 610 | static void set_vbif_registers(struct hal_device *device) |
| 611 | { |
Vinay Kalia | b717b9d | 2012-09-14 12:00:45 -0700 | [diff] [blame] | 612 | /*Disable Dynamic clock gating for Venus VBIF*/ |
| 613 | write_register(device->hal_data->register_base_addr, |
| 614 | VIDC_VENUS_VBIF_CLK_ON, 1, 0); |
Vinay Kalia | cdf8d0c | 2012-08-28 12:07:36 -0700 | [diff] [blame] | 615 | write_register(device->hal_data->register_base_addr, |
Vinay Kalia | 15e870b | 2012-09-10 15:30:23 -0700 | [diff] [blame] | 616 | VIDC_VBIF_OUT_AXI_AOOO_EN, 0x00000FFF, 0); |
Vinay Kalia | cdf8d0c | 2012-08-28 12:07:36 -0700 | [diff] [blame] | 617 | write_register(device->hal_data->register_base_addr, |
Vinay Kalia | 15e870b | 2012-09-10 15:30:23 -0700 | [diff] [blame] | 618 | VIDC_VBIF_OUT_AXI_AOOO, 0x0FFF0FFF, 0); |
Vinay Kalia | cdf8d0c | 2012-08-28 12:07:36 -0700 | [diff] [blame] | 619 | write_register(device->hal_data->register_base_addr, |
Vinay Kalia | 15e870b | 2012-09-10 15:30:23 -0700 | [diff] [blame] | 620 | VIDC_VENUS_VBIF_CLK_ON, 1, 0); |
Vinay Kalia | cdf8d0c | 2012-08-28 12:07:36 -0700 | [diff] [blame] | 621 | write_register(device->hal_data->register_base_addr, |
Vinay Kalia | 15e870b | 2012-09-10 15:30:23 -0700 | [diff] [blame] | 622 | VIDC_VBIF_IN_RD_LIM_CONF0, 0x10101001, 0); |
Vinay Kalia | cdf8d0c | 2012-08-28 12:07:36 -0700 | [diff] [blame] | 623 | write_register(device->hal_data->register_base_addr, |
Vinay Kalia | 15e870b | 2012-09-10 15:30:23 -0700 | [diff] [blame] | 624 | VIDC_VBIF_IN_RD_LIM_CONF1, 0x10101010, 0); |
Vinay Kalia | cdf8d0c | 2012-08-28 12:07:36 -0700 | [diff] [blame] | 625 | write_register(device->hal_data->register_base_addr, |
Vinay Kalia | 15e870b | 2012-09-10 15:30:23 -0700 | [diff] [blame] | 626 | VIDC_VBIF_IN_RD_LIM_CONF2, 0x10101010, 0); |
Vinay Kalia | cdf8d0c | 2012-08-28 12:07:36 -0700 | [diff] [blame] | 627 | write_register(device->hal_data->register_base_addr, |
Vinay Kalia | 15e870b | 2012-09-10 15:30:23 -0700 | [diff] [blame] | 628 | VIDC_VBIF_IN_RD_LIM_CONF3, 0x00000010, 0); |
Vinay Kalia | cdf8d0c | 2012-08-28 12:07:36 -0700 | [diff] [blame] | 629 | write_register(device->hal_data->register_base_addr, |
Vinay Kalia | 15e870b | 2012-09-10 15:30:23 -0700 | [diff] [blame] | 630 | VIDC_VBIF_IN_WR_LIM_CONF0, 0x1010100f, 0); |
Vinay Kalia | cdf8d0c | 2012-08-28 12:07:36 -0700 | [diff] [blame] | 631 | write_register(device->hal_data->register_base_addr, |
Vinay Kalia | 15e870b | 2012-09-10 15:30:23 -0700 | [diff] [blame] | 632 | VIDC_VBIF_IN_WR_LIM_CONF1, 0x10101010, 0); |
| 633 | write_register(device->hal_data->register_base_addr, |
| 634 | VIDC_VBIF_IN_WR_LIM_CONF2, 0x10101010, 0); |
| 635 | write_register(device->hal_data->register_base_addr, |
| 636 | VIDC_VBIF_IN_WR_LIM_CONF3, 0x00000010, 0); |
| 637 | write_register(device->hal_data->register_base_addr, |
| 638 | VIDC_VBIF_OUT_RD_LIM_CONF0, 0x00001010, 0); |
| 639 | write_register(device->hal_data->register_base_addr, |
| 640 | VIDC_VBIF_OUT_WR_LIM_CONF0, 0x00001010, 0); |
| 641 | write_register(device->hal_data->register_base_addr, |
| 642 | VIDC_VBIF_ARB_CTL, 0x00000030, 0); |
Vinay Kalia | b717b9d | 2012-09-14 12:00:45 -0700 | [diff] [blame] | 643 | write_register(device->hal_data->register_base_addr, |
| 644 | VIDC_VENUS0_WRAPPER_VBIF_REQ_PRIORITY, 0x5555556, 0); |
Vinay Kalia | cdf8d0c | 2012-08-28 12:07:36 -0700 | [diff] [blame] | 645 | } |
| 646 | |
Vinay Kalia | 68398a4 | 2012-06-22 18:36:12 -0700 | [diff] [blame] | 647 | int vidc_hal_core_init(void *device, int domain) |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 648 | { |
| 649 | struct hfi_cmd_sys_init_packet pkt; |
| 650 | int rc = 0; |
| 651 | struct hal_device *dev; |
| 652 | |
| 653 | if (device) { |
| 654 | dev = device; |
| 655 | } else { |
Ashray Kulkarni | b673450 | 2012-08-24 13:00:22 -0700 | [diff] [blame] | 656 | dprintk(VIDC_ERR, "Invalid device"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 657 | return -ENODEV; |
| 658 | } |
| 659 | enable_irq(dev->hal_data->irq); |
| 660 | INIT_LIST_HEAD(&dev->sess_head); |
| 661 | spin_lock_init(&dev->read_lock); |
| 662 | spin_lock_init(&dev->write_lock); |
Vinay Kalia | cdf8d0c | 2012-08-28 12:07:36 -0700 | [diff] [blame] | 663 | set_vbif_registers(dev); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 664 | if (!dev->hal_client) { |
| 665 | dev->hal_client = msm_smem_new_client(SMEM_ION); |
| 666 | if (dev->hal_client == NULL) { |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 667 | dprintk(VIDC_ERR, "Failed to alloc ION_Client"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 668 | rc = -ENODEV; |
| 669 | goto err_no_mem; |
| 670 | } |
| 671 | |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 672 | dprintk(VIDC_DBG, "Device_Virt_Address : 0x%x," |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 673 | "Register_Virt_Addr: 0x%x", |
Vinay Kalia | 68398a4 | 2012-06-22 18:36:12 -0700 | [diff] [blame] | 674 | dev->hal_data->device_base_addr, |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 675 | (u32) dev->hal_data->register_base_addr); |
| 676 | |
Vinay Kalia | 68398a4 | 2012-06-22 18:36:12 -0700 | [diff] [blame] | 677 | rc = vidc_hal_interface_queues_init(dev, domain); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 678 | if (rc) { |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 679 | dprintk(VIDC_ERR, "failed to init queues"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 680 | rc = -ENOMEM; |
| 681 | goto err_no_mem; |
| 682 | } |
| 683 | } else { |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 684 | dprintk(VIDC_ERR, "hal_client exists"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 685 | rc = -EEXIST; |
| 686 | goto err_no_mem; |
| 687 | } |
| 688 | rc = vidc_hal_core_start_cpu(dev); |
| 689 | if (rc) { |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 690 | dprintk(VIDC_ERR, "Failed to start core"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 691 | rc = -ENODEV; |
| 692 | goto err_no_dev; |
| 693 | } |
| 694 | pkt.size = sizeof(struct hfi_cmd_sys_init_packet); |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 695 | pkt.packet_type = HFI_CMD_SYS_INIT; |
| 696 | pkt.arch_type = HFI_ARCH_OX_OFFSET; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 697 | if (vidc_hal_iface_cmdq_write(dev, &pkt)) { |
| 698 | rc = -ENOTEMPTY; |
| 699 | goto err_write_fail; |
| 700 | } |
| 701 | return rc; |
| 702 | err_no_dev: |
| 703 | err_write_fail: |
| 704 | err_no_mem: |
| 705 | disable_irq_nosync(dev->hal_data->irq); |
| 706 | return rc; |
| 707 | } |
| 708 | |
| 709 | int vidc_hal_core_release(void *device) |
| 710 | { |
| 711 | struct hal_device *dev; |
| 712 | if (device) { |
| 713 | dev = device; |
| 714 | } else { |
Ashray Kulkarni | b673450 | 2012-08-24 13:00:22 -0700 | [diff] [blame] | 715 | dprintk(VIDC_ERR, "invalid device"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 716 | return -ENODEV; |
| 717 | } |
| 718 | write_register(dev->hal_data->register_base_addr, |
| 719 | VIDC_CPU_CS_SCIACMDARG3, 0, 0); |
Vinay Kalia | 40c3ae8 | 2012-07-09 15:23:02 -0700 | [diff] [blame] | 720 | disable_irq_nosync(dev->hal_data->irq); |
| 721 | vidc_hal_interface_queues_release(dev); |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 722 | dprintk(VIDC_INFO, "HAL exited\n"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 723 | return 0; |
| 724 | } |
| 725 | |
| 726 | int vidc_hal_core_pc_prep(void *device) |
| 727 | { |
| 728 | struct hfi_cmd_sys_pc_prep_packet pkt; |
| 729 | int rc = 0; |
| 730 | struct hal_device *dev; |
| 731 | |
| 732 | if (device) { |
| 733 | dev = device; |
| 734 | } else { |
Ashray Kulkarni | b673450 | 2012-08-24 13:00:22 -0700 | [diff] [blame] | 735 | dprintk(VIDC_ERR, "invalid device"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 736 | return -ENODEV; |
| 737 | } |
| 738 | pkt.size = sizeof(struct hfi_cmd_sys_pc_prep_packet); |
| 739 | pkt.packet_type = HFI_CMD_SYS_PC_PREP; |
| 740 | if (vidc_hal_iface_cmdq_write(dev, &pkt)) |
| 741 | rc = -ENOTEMPTY; |
| 742 | return rc; |
| 743 | } |
| 744 | |
| 745 | static void vidc_hal_core_clear_interrupt(struct hal_device *device) |
| 746 | { |
| 747 | u32 intr_status = 0; |
| 748 | |
| 749 | if (!device->callback) |
| 750 | return; |
| 751 | |
| 752 | intr_status = read_register( |
| 753 | device->hal_data->register_base_addr, |
| 754 | VIDC_WRAPPER_INTR_STATUS); |
| 755 | |
| 756 | if ((intr_status & VIDC_WRAPPER_INTR_STATUS_A2H_BMSK) || |
| 757 | (intr_status & VIDC_WRAPPER_INTR_STATUS_A2HWD_BMSK)) { |
| 758 | device->intr_status |= intr_status; |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 759 | dprintk(VIDC_DBG, "INTERRUPT for device: 0x%x: " |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 760 | "times: %d interrupt_status: %d", |
| 761 | (u32) device, ++device->reg_count, intr_status); |
| 762 | } else { |
Ashray Kulkarni | 000b382 | 2012-10-11 18:20:58 -0700 | [diff] [blame] | 763 | dprintk(VIDC_INFO, "SPURIOUS_INTR for device: 0x%x: " |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 764 | "times: %d interrupt_status: %d", |
| 765 | (u32) device, ++device->spur_count, intr_status); |
| 766 | } |
| 767 | write_register(device->hal_data->register_base_addr, |
| 768 | VIDC_CPU_CS_A2HSOFTINTCLR, 1, 0); |
| 769 | write_register(device->hal_data->register_base_addr, |
| 770 | VIDC_WRAPPER_INTR_CLEAR, intr_status, 0); |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 771 | dprintk(VIDC_DBG, "Cleared WRAPPER/A2H interrupt"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 772 | } |
| 773 | |
| 774 | int vidc_hal_core_set_resource(void *device, |
| 775 | struct vidc_resource_hdr *resource_hdr, void *resource_value) |
| 776 | { |
| 777 | struct hfi_cmd_sys_set_resource_packet *pkt; |
| 778 | u8 packet[VIDC_IFACEQ_VAR_SMALL_PKT_SIZE]; |
| 779 | int rc = 0; |
| 780 | struct hal_device *dev; |
| 781 | |
| 782 | if (!device || !resource_hdr || !resource_value) { |
Ashray Kulkarni | b673450 | 2012-08-24 13:00:22 -0700 | [diff] [blame] | 783 | dprintk(VIDC_ERR, "set_res: Invalid Params"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 784 | return -EINVAL; |
| 785 | } else { |
| 786 | dev = device; |
| 787 | } |
| 788 | |
| 789 | pkt = (struct hfi_cmd_sys_set_resource_packet *) packet; |
| 790 | |
| 791 | pkt->size = sizeof(struct hfi_cmd_sys_set_resource_packet); |
| 792 | pkt->packet_type = HFI_CMD_SYS_SET_RESOURCE; |
| 793 | pkt->resource_handle = resource_hdr->resource_handle; |
| 794 | |
| 795 | switch (resource_hdr->resource_id) { |
| 796 | case VIDC_RESOURCE_OCMEM: |
| 797 | { |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 798 | struct hfi_resource_ocmem *hfioc_mem = |
| 799 | (struct hfi_resource_ocmem *) |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 800 | &pkt->rg_resource_data[0]; |
Vinay Kalia | bc9f60a | 2012-07-17 01:23:42 -0700 | [diff] [blame] | 801 | struct ocmem_buf *ocmem = |
| 802 | (struct ocmem_buf *) resource_value; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 803 | |
| 804 | pkt->resource_type = HFI_RESOURCE_OCMEM; |
Vinay Kalia | bc9f60a | 2012-07-17 01:23:42 -0700 | [diff] [blame] | 805 | hfioc_mem->size = (u32) ocmem->len; |
| 806 | hfioc_mem->mem = (u8 *) ocmem->addr; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 807 | pkt->size += sizeof(struct hfi_resource_ocmem); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 808 | if (vidc_hal_iface_cmdq_write(dev, pkt)) |
| 809 | rc = -ENOTEMPTY; |
| 810 | break; |
| 811 | } |
| 812 | default: |
Ashray Kulkarni | b673450 | 2012-08-24 13:00:22 -0700 | [diff] [blame] | 813 | dprintk(VIDC_INFO, "Invalid res_id in set_res %d", |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 814 | resource_hdr->resource_id); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 815 | break; |
| 816 | } |
| 817 | return rc; |
| 818 | } |
| 819 | |
| 820 | int vidc_hal_core_release_resource(void *device, |
| 821 | struct vidc_resource_hdr *resource_hdr) |
| 822 | { |
| 823 | struct hfi_cmd_sys_release_resource_packet pkt; |
| 824 | int rc = 0; |
| 825 | struct hal_device *dev; |
| 826 | |
| 827 | if (!device || !resource_hdr) { |
Ashray Kulkarni | b673450 | 2012-08-24 13:00:22 -0700 | [diff] [blame] | 828 | dprintk(VIDC_ERR, "Inv-Params in rel_res"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 829 | return -EINVAL; |
| 830 | } else { |
| 831 | dev = device; |
| 832 | } |
| 833 | |
| 834 | pkt.size = sizeof(struct hfi_cmd_sys_release_resource_packet); |
| 835 | pkt.packet_type = HFI_CMD_SYS_RELEASE_RESOURCE; |
| 836 | pkt.resource_type = resource_hdr->resource_id; |
| 837 | pkt.resource_handle = resource_hdr->resource_handle; |
| 838 | |
| 839 | if (vidc_hal_iface_cmdq_write(dev, &pkt)) |
| 840 | rc = -ENOTEMPTY; |
| 841 | return rc; |
| 842 | } |
| 843 | |
| 844 | int vidc_hal_core_ping(void *device) |
| 845 | { |
| 846 | struct hfi_cmd_sys_ping_packet pkt; |
| 847 | int rc = 0; |
| 848 | struct hal_device *dev; |
| 849 | |
| 850 | if (device) { |
| 851 | dev = device; |
| 852 | } else { |
Ashray Kulkarni | b673450 | 2012-08-24 13:00:22 -0700 | [diff] [blame] | 853 | dprintk(VIDC_ERR, "invalid device"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 854 | return -ENODEV; |
| 855 | } |
| 856 | pkt.size = sizeof(struct hfi_cmd_sys_ping_packet); |
| 857 | pkt.packet_type = HFI_CMD_SYS_PING; |
| 858 | |
| 859 | if (vidc_hal_iface_cmdq_write(dev, &pkt)) |
| 860 | rc = -ENOTEMPTY; |
| 861 | return rc; |
| 862 | } |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 863 | static u32 get_hfi_buffer(int hal_buffer) |
| 864 | { |
| 865 | u32 buffer; |
| 866 | switch (hal_buffer) { |
| 867 | case HAL_BUFFER_INPUT: |
| 868 | buffer = HFI_BUFFER_INPUT; |
| 869 | break; |
| 870 | case HAL_BUFFER_OUTPUT: |
| 871 | buffer = HFI_BUFFER_OUTPUT; |
| 872 | break; |
| 873 | case HAL_BUFFER_OUTPUT2: |
| 874 | buffer = HFI_BUFFER_OUTPUT; |
| 875 | break; |
| 876 | case HAL_BUFFER_EXTRADATA_INPUT: |
| 877 | buffer = HFI_BUFFER_EXTRADATA_INPUT; |
| 878 | break; |
| 879 | case HAL_BUFFER_EXTRADATA_OUTPUT: |
| 880 | buffer = HFI_BUFFER_EXTRADATA_OUTPUT; |
| 881 | break; |
| 882 | case HAL_BUFFER_EXTRADATA_OUTPUT2: |
| 883 | buffer = HFI_BUFFER_EXTRADATA_OUTPUT2; |
| 884 | break; |
| 885 | case HAL_BUFFER_INTERNAL_SCRATCH: |
| 886 | buffer = HFI_BUFFER_INTERNAL_SCRATCH; |
| 887 | break; |
| 888 | case HAL_BUFFER_INTERNAL_PERSIST: |
| 889 | buffer = HFI_BUFFER_INTERNAL_PERSIST; |
| 890 | break; |
| 891 | default: |
Ashray Kulkarni | b673450 | 2012-08-24 13:00:22 -0700 | [diff] [blame] | 892 | dprintk(VIDC_ERR, "Invalid buffer :0x%x\n", |
| 893 | hal_buffer); |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 894 | buffer = 0; |
| 895 | break; |
| 896 | } |
| 897 | return buffer; |
| 898 | } |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 899 | int vidc_hal_session_set_property(void *sess, |
| 900 | enum hal_property ptype, void *pdata) |
| 901 | { |
| 902 | u8 packet[VIDC_IFACEQ_VAR_LARGE_PKT_SIZE]; |
| 903 | struct hfi_cmd_session_set_property_packet *pkt = |
| 904 | (struct hfi_cmd_session_set_property_packet *) &packet; |
| 905 | struct hal_session *session; |
| 906 | |
| 907 | if (!sess || !pdata) { |
Ashray Kulkarni | b673450 | 2012-08-24 13:00:22 -0700 | [diff] [blame] | 908 | dprintk(VIDC_ERR, "Invalid Params"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 909 | return -EINVAL; |
| 910 | } else { |
| 911 | session = sess; |
| 912 | } |
| 913 | |
Ashray Kulkarni | b673450 | 2012-08-24 13:00:22 -0700 | [diff] [blame] | 914 | dprintk(VIDC_INFO, "in set_prop,with prop id: 0x%x", ptype); |
Ashray Kulkarni | 1c72b39 | 2012-06-20 10:50:00 -0700 | [diff] [blame] | 915 | pkt->size = sizeof(struct hfi_cmd_session_set_property_packet); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 916 | pkt->packet_type = HFI_CMD_SESSION_SET_PROPERTY; |
| 917 | pkt->session_id = (u32) session; |
| 918 | pkt->num_properties = 1; |
| 919 | |
| 920 | switch (ptype) { |
| 921 | case HAL_CONFIG_FRAME_RATE: |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 922 | { |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 923 | struct hfi_frame_rate *hfi; |
| 924 | u32 buffer; |
| 925 | struct hal_frame_rate *prop = |
| 926 | (struct hal_frame_rate *) pdata; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 927 | pkt->rg_property_data[0] = HFI_PROPERTY_CONFIG_FRAME_RATE; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 928 | hfi = (struct hfi_frame_rate *) &pkt->rg_property_data[1]; |
| 929 | buffer = get_hfi_buffer(prop->buffer_type); |
| 930 | if (buffer) |
| 931 | hfi->buffer_type = buffer; |
| 932 | else |
| 933 | return -EINVAL; |
| 934 | hfi->frame_rate = prop->frame_rate; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 935 | pkt->size += sizeof(u32) + sizeof(struct hfi_frame_rate); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 936 | break; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 937 | } |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 938 | case HAL_PARAM_UNCOMPRESSED_FORMAT_SELECT: |
| 939 | { |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 940 | u32 buffer; |
| 941 | struct hfi_uncompressed_format_select *hfi; |
| 942 | struct hal_uncompressed_format_select *prop = |
| 943 | (struct hal_uncompressed_format_select *) pdata; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 944 | pkt->rg_property_data[0] = |
| 945 | HFI_PROPERTY_PARAM_UNCOMPRESSED_FORMAT_SELECT; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 946 | hfi = (struct hfi_uncompressed_format_select *) |
| 947 | &pkt->rg_property_data[1]; |
| 948 | buffer = get_hfi_buffer(prop->buffer_type); |
| 949 | if (buffer) |
| 950 | hfi->buffer_type = buffer; |
| 951 | else |
| 952 | return -EINVAL; |
| 953 | hfi->format = prop->format; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 954 | pkt->size += sizeof(u32) + sizeof(struct |
| 955 | hfi_uncompressed_format_select); |
| 956 | break; |
| 957 | } |
| 958 | case HAL_PARAM_UNCOMPRESSED_PLANE_ACTUAL_CONSTRAINTS_INFO: |
| 959 | break; |
| 960 | case HAL_PARAM_UNCOMPRESSED_PLANE_ACTUAL_INFO: |
| 961 | break; |
| 962 | case HAL_PARAM_EXTRA_DATA_HEADER_CONFIG: |
| 963 | break; |
| 964 | case HAL_PARAM_FRAME_SIZE: |
| 965 | { |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 966 | u32 buffer; |
| 967 | struct hfi_frame_size *hfi; |
| 968 | struct hal_frame_size *prop = (struct hal_frame_size *) pdata; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 969 | pkt->rg_property_data[0] = HFI_PROPERTY_PARAM_FRAME_SIZE; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 970 | hfi = (struct hfi_frame_size *) &pkt->rg_property_data[1]; |
| 971 | buffer = get_hfi_buffer(prop->buffer_type); |
| 972 | if (buffer) |
| 973 | hfi->buffer_type = buffer; |
| 974 | else |
| 975 | return -EINVAL; |
| 976 | hfi->height = prop->height; |
| 977 | hfi->width = prop->width; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 978 | pkt->size += sizeof(u32) + sizeof(struct hfi_frame_size); |
| 979 | break; |
| 980 | } |
| 981 | case HAL_CONFIG_REALTIME: |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 982 | { |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 983 | struct hfi_enable *hfi; |
| 984 | pkt->rg_property_data[0] = HFI_PROPERTY_CONFIG_REALTIME; |
| 985 | hfi = (struct hfi_enable *) &pkt->rg_property_data[1]; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 986 | hfi->enable = ((struct hfi_enable *) pdata)->enable; |
| 987 | pkt->size += sizeof(u32) * 2; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 988 | break; |
| 989 | } |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 990 | case HAL_PARAM_BUFFER_COUNT_ACTUAL: |
| 991 | { |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 992 | u32 buffer; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 993 | struct hfi_buffer_count_actual *hfi; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 994 | struct hal_buffer_count_actual *prop = |
| 995 | (struct hal_buffer_count_actual *) pdata; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 996 | pkt->rg_property_data[0] = |
| 997 | HFI_PROPERTY_PARAM_BUFFER_COUNT_ACTUAL; |
| 998 | hfi = (struct hfi_buffer_count_actual *) |
| 999 | &pkt->rg_property_data[1]; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1000 | hfi->buffer_count_actual = prop->buffer_count_actual; |
| 1001 | buffer = get_hfi_buffer(prop->buffer_type); |
| 1002 | if (buffer) |
| 1003 | hfi->buffer_type = buffer; |
| 1004 | else |
| 1005 | return -EINVAL; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1006 | pkt->size += sizeof(u32) + sizeof(struct |
| 1007 | hfi_buffer_count_actual); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1008 | break; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1009 | } |
| 1010 | case HAL_PARAM_NAL_STREAM_FORMAT_SELECT: |
| 1011 | { |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1012 | struct hal_nal_stream_format_supported *prop = |
| 1013 | (struct hal_nal_stream_format_supported *)pdata; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1014 | pkt->rg_property_data[0] = |
| 1015 | HFI_PROPERTY_PARAM_NAL_STREAM_FORMAT_SELECT; |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 1016 | dprintk(VIDC_DBG, "data is :%d", |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1017 | prop->nal_stream_format_supported); |
| 1018 | switch (prop->nal_stream_format_supported) { |
| 1019 | case HAL_NAL_FORMAT_STARTCODES: |
| 1020 | pkt->rg_property_data[1] = |
| 1021 | HFI_NAL_FORMAT_STARTCODES; |
| 1022 | break; |
| 1023 | case HAL_NAL_FORMAT_ONE_NAL_PER_BUFFER: |
| 1024 | pkt->rg_property_data[1] = |
| 1025 | HFI_NAL_FORMAT_ONE_NAL_PER_BUFFER; |
| 1026 | break; |
| 1027 | case HAL_NAL_FORMAT_ONE_BYTE_LENGTH: |
| 1028 | pkt->rg_property_data[1] = |
| 1029 | HFI_NAL_FORMAT_ONE_BYTE_LENGTH; |
| 1030 | break; |
| 1031 | case HAL_NAL_FORMAT_TWO_BYTE_LENGTH: |
| 1032 | pkt->rg_property_data[1] = |
| 1033 | HFI_NAL_FORMAT_TWO_BYTE_LENGTH; |
| 1034 | break; |
| 1035 | case HAL_NAL_FORMAT_FOUR_BYTE_LENGTH: |
| 1036 | pkt->rg_property_data[1] = |
| 1037 | HFI_NAL_FORMAT_FOUR_BYTE_LENGTH; |
| 1038 | break; |
| 1039 | default: |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 1040 | dprintk(VIDC_ERR, "Invalid nal format: 0x%x", |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1041 | prop->nal_stream_format_supported); |
| 1042 | break; |
| 1043 | } |
| 1044 | pkt->size += sizeof(u32) * 2; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1045 | break; |
| 1046 | } |
| 1047 | case HAL_PARAM_VDEC_OUTPUT_ORDER: |
| 1048 | { |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1049 | int *data = (int *) pdata; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1050 | pkt->rg_property_data[0] = |
| 1051 | HFI_PROPERTY_PARAM_VDEC_OUTPUT_ORDER; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1052 | switch (*data) { |
| 1053 | case HAL_OUTPUT_ORDER_DECODE: |
Ashray Kulkarni | 995fd27 | 2012-07-02 12:57:55 -0700 | [diff] [blame] | 1054 | pkt->rg_property_data[1] = HFI_OUTPUT_ORDER_DECODE; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1055 | break; |
| 1056 | case HAL_OUTPUT_ORDER_DISPLAY: |
Ashray Kulkarni | 995fd27 | 2012-07-02 12:57:55 -0700 | [diff] [blame] | 1057 | pkt->rg_property_data[1] = HFI_OUTPUT_ORDER_DISPLAY; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1058 | break; |
| 1059 | default: |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 1060 | dprintk(VIDC_ERR, "invalid output order: 0x%x", |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1061 | *data); |
| 1062 | break; |
| 1063 | } |
| 1064 | pkt->size += sizeof(u32) * 2; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1065 | break; |
| 1066 | } |
| 1067 | case HAL_PARAM_VDEC_PICTURE_TYPE_DECODE: |
| 1068 | { |
| 1069 | struct hfi_enable_picture *hfi; |
| 1070 | pkt->rg_property_data[0] = |
| 1071 | HFI_PROPERTY_PARAM_VDEC_PICTURE_TYPE_DECODE; |
| 1072 | hfi = (struct hfi_enable_picture *) &pkt->rg_property_data[1]; |
| 1073 | hfi->picture_type = (u32) pdata; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1074 | pkt->size += sizeof(u32) * 2; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1075 | break; |
| 1076 | } |
| 1077 | case HAL_PARAM_VDEC_OUTPUT2_KEEP_ASPECT_RATIO: |
| 1078 | { |
| 1079 | struct hfi_enable *hfi; |
| 1080 | pkt->rg_property_data[0] = |
| 1081 | HFI_PROPERTY_PARAM_VDEC_OUTPUT2_KEEP_ASPECT_RATIO; |
| 1082 | hfi = (struct hfi_enable *) &pkt->rg_property_data[1]; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1083 | hfi->enable = ((struct hfi_enable *) pdata)->enable; |
| 1084 | pkt->size += sizeof(u32) * 2; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1085 | break; |
| 1086 | } |
| 1087 | case HAL_CONFIG_VDEC_POST_LOOP_DEBLOCKER: |
| 1088 | { |
| 1089 | struct hfi_enable *hfi; |
| 1090 | pkt->rg_property_data[0] = |
| 1091 | HFI_PROPERTY_CONFIG_VDEC_POST_LOOP_DEBLOCKER; |
| 1092 | hfi = (struct hfi_enable *) &pkt->rg_property_data[1]; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1093 | hfi->enable = ((struct hfi_enable *) pdata)->enable; |
| 1094 | pkt->size += sizeof(u32) * 2; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1095 | break; |
| 1096 | } |
| 1097 | case HAL_PARAM_VDEC_MULTI_STREAM: |
| 1098 | { |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1099 | u32 buffer; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1100 | struct hfi_multi_stream *hfi; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1101 | struct hal_multi_stream *prop = |
| 1102 | (struct hal_multi_stream *) pdata; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1103 | pkt->rg_property_data[0] = |
| 1104 | HFI_PROPERTY_PARAM_VDEC_MULTI_STREAM; |
| 1105 | hfi = (struct hfi_multi_stream *) &pkt->rg_property_data[1]; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1106 | buffer = get_hfi_buffer(prop->buffer_type); |
| 1107 | if (buffer) |
| 1108 | hfi->buffer_type = buffer; |
| 1109 | else |
| 1110 | return -EINVAL; |
| 1111 | hfi->enable = prop->enable; |
| 1112 | hfi->width = prop->width; |
| 1113 | hfi->height = prop->height; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1114 | pkt->size += sizeof(u32) + sizeof(struct hfi_multi_stream); |
| 1115 | break; |
| 1116 | } |
| 1117 | case HAL_PARAM_VDEC_DISPLAY_PICTURE_BUFFER_COUNT: |
| 1118 | { |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1119 | struct hfi_display_picture_buffer_count *hfi; |
| 1120 | struct hal_display_picture_buffer_count *prop = |
| 1121 | (struct hal_display_picture_buffer_count *) pdata; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1122 | pkt->rg_property_data[0] = |
| 1123 | HFI_PROPERTY_PARAM_VDEC_DISPLAY_PICTURE_BUFFER_COUNT; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1124 | hfi = (struct hfi_display_picture_buffer_count *) |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1125 | &pkt->rg_property_data[1]; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1126 | hfi->count = prop->count; |
| 1127 | hfi->enable = prop->enable; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1128 | pkt->size += sizeof(u32) + |
| 1129 | sizeof(struct hfi_display_picture_buffer_count); |
| 1130 | break; |
| 1131 | } |
| 1132 | case HAL_PARAM_DIVX_FORMAT: |
| 1133 | { |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1134 | int *data = pdata; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1135 | pkt->rg_property_data[0] = HFI_PROPERTY_PARAM_DIVX_FORMAT; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1136 | switch (*data) { |
| 1137 | case HAL_DIVX_FORMAT_4: |
| 1138 | pkt->rg_property_data[1] = HFI_DIVX_FORMAT_4; |
| 1139 | break; |
| 1140 | case HAL_DIVX_FORMAT_5: |
| 1141 | pkt->rg_property_data[1] = HFI_DIVX_FORMAT_5; |
| 1142 | break; |
| 1143 | case HAL_DIVX_FORMAT_6: |
| 1144 | pkt->rg_property_data[1] = HFI_DIVX_FORMAT_6; |
| 1145 | break; |
| 1146 | default: |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 1147 | dprintk(VIDC_ERR, "Invalid divx format: 0x%x", *data); |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1148 | break; |
| 1149 | } |
| 1150 | pkt->size += sizeof(u32) * 2; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1151 | break; |
| 1152 | } |
| 1153 | case HAL_CONFIG_VDEC_MB_ERROR_MAP_REPORTING: |
| 1154 | { |
| 1155 | struct hfi_enable *hfi; |
| 1156 | pkt->rg_property_data[0] = |
| 1157 | HFI_PROPERTY_CONFIG_VDEC_MB_ERROR_MAP_REPORTING; |
| 1158 | hfi = (struct hfi_enable *) &pkt->rg_property_data[1]; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1159 | hfi->enable = ((struct hfi_enable *) pdata)->enable; |
| 1160 | pkt->size += sizeof(u32) * 2; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1161 | break; |
| 1162 | } |
| 1163 | case HAL_PARAM_VDEC_CONTINUE_DATA_TRANSFER: |
| 1164 | { |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1165 | struct hfi_enable *hfi; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1166 | pkt->rg_property_data[0] = |
| 1167 | HFI_PROPERTY_PARAM_VDEC_CONTINUE_DATA_TRANSFER; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1168 | hfi = (struct hfi_enable *) &pkt->rg_property_data[1]; |
| 1169 | hfi->enable = ((struct hfi_enable *) pdata)->enable; |
| 1170 | pkt->size += sizeof(u32) * 2; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1171 | break; |
| 1172 | } |
Ashray Kulkarni | 8c5f34f | 2012-09-14 17:13:38 -0700 | [diff] [blame] | 1173 | case HAL_PARAM_VENC_SYNC_FRAME_SEQUENCE_HEADER: |
| 1174 | { |
| 1175 | struct hfi_enable *hfi; |
| 1176 | pkt->rg_property_data[0] = |
| 1177 | HFI_PROPERTY_PARAM_VENC_SYNC_FRAME_SEQUENCE_HEADER; |
| 1178 | hfi = (struct hfi_enable *) &pkt->rg_property_data[1]; |
| 1179 | hfi->enable = ((struct hfi_enable *) pdata)->enable; |
| 1180 | pkt->size += sizeof(u32) * 2; |
| 1181 | break; |
| 1182 | } |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1183 | case HAL_CONFIG_VENC_REQUEST_IFRAME: |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1184 | pkt->rg_property_data[0] = |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1185 | HFI_PROPERTY_CONFIG_VENC_REQUEST_SYNC_FRAME; |
Praneeth Paladugu | 951c02d | 2012-07-11 12:19:42 -0700 | [diff] [blame] | 1186 | pkt->size += sizeof(u32); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1187 | break; |
| 1188 | case HAL_PARAM_VENC_MPEG4_SHORT_HEADER: |
| 1189 | break; |
| 1190 | case HAL_PARAM_VENC_MPEG4_AC_PREDICTION: |
| 1191 | break; |
| 1192 | case HAL_CONFIG_VENC_TARGET_BITRATE: |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1193 | { |
| 1194 | struct hfi_bitrate *hfi; |
| 1195 | pkt->rg_property_data[0] = |
| 1196 | HFI_PROPERTY_CONFIG_VENC_TARGET_BITRATE; |
| 1197 | hfi = (struct hfi_bitrate *) &pkt->rg_property_data[1]; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1198 | hfi->bit_rate = ((struct hal_bitrate *)pdata)->bit_rate; |
| 1199 | pkt->size += sizeof(u32) * 2; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1200 | break; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1201 | } |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1202 | case HAL_PARAM_PROFILE_LEVEL_CURRENT: |
| 1203 | { |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1204 | struct hfi_profile_level *hfi; |
| 1205 | struct hal_profile_level *prop = |
| 1206 | (struct hal_profile_level *) pdata; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1207 | pkt->rg_property_data[0] = |
| 1208 | HFI_PROPERTY_PARAM_PROFILE_LEVEL_CURRENT; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1209 | hfi = (struct hfi_profile_level *) |
| 1210 | &pkt->rg_property_data[1]; |
| 1211 | hfi->level = (u32) prop->level; |
| 1212 | hfi->profile = prop->profile; |
| 1213 | if (!hfi->profile) |
| 1214 | hfi->profile = HFI_H264_PROFILE_HIGH; |
| 1215 | if (!hfi->level) |
| 1216 | hfi->level = 1; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1217 | pkt->size += sizeof(u32) + sizeof(struct hfi_profile_level); |
| 1218 | break; |
| 1219 | } |
| 1220 | case HAL_PARAM_VENC_H264_ENTROPY_CONTROL: |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1221 | { |
| 1222 | struct hfi_h264_entropy_control *hfi; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1223 | struct hal_h264_entropy_control *prop = |
| 1224 | (struct hal_h264_entropy_control *) pdata; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1225 | pkt->rg_property_data[0] = |
| 1226 | HFI_PROPERTY_PARAM_VENC_H264_ENTROPY_CONTROL; |
| 1227 | hfi = (struct hfi_h264_entropy_control *) |
| 1228 | &pkt->rg_property_data[1]; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1229 | switch (prop->entropy_mode) { |
| 1230 | case HAL_H264_ENTROPY_CAVLC: |
| 1231 | hfi->cabac_model = HFI_H264_ENTROPY_CAVLC; |
| 1232 | break; |
| 1233 | case HAL_H264_ENTROPY_CABAC: |
| 1234 | hfi->cabac_model = HFI_H264_ENTROPY_CABAC; |
| 1235 | switch (prop->cabac_model) { |
| 1236 | case HAL_H264_CABAC_MODEL_0: |
| 1237 | hfi->cabac_model = HFI_H264_CABAC_MODEL_0; |
| 1238 | break; |
| 1239 | case HAL_H264_CABAC_MODEL_1: |
| 1240 | hfi->cabac_model = HFI_H264_CABAC_MODEL_1; |
| 1241 | break; |
| 1242 | case HAL_H264_CABAC_MODEL_2: |
| 1243 | hfi->cabac_model = HFI_H264_CABAC_MODEL_2; |
| 1244 | break; |
| 1245 | default: |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 1246 | dprintk(VIDC_ERR, |
| 1247 | "Invalid cabac model 0x%x", |
| 1248 | prop->entropy_mode); |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1249 | break; |
| 1250 | } |
| 1251 | break; |
| 1252 | default: |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 1253 | dprintk(VIDC_ERR, |
| 1254 | "Invalid entropy selected: 0x%x", |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1255 | prop->cabac_model); |
| 1256 | break; |
| 1257 | } |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1258 | pkt->size += sizeof(u32) + sizeof( |
| 1259 | struct hfi_h264_entropy_control); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1260 | break; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1261 | } |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1262 | case HAL_PARAM_VENC_RATE_CONTROL: |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1263 | { |
Ashray Kulkarni | b673450 | 2012-08-24 13:00:22 -0700 | [diff] [blame] | 1264 | u32 *rc; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1265 | pkt->rg_property_data[0] = |
| 1266 | HFI_PROPERTY_PARAM_VENC_RATE_CONTROL; |
Ashray Kulkarni | b673450 | 2012-08-24 13:00:22 -0700 | [diff] [blame] | 1267 | rc = (u32 *)pdata; |
| 1268 | switch ((enum hal_rate_control) *rc) { |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1269 | case HAL_RATE_CONTROL_OFF: |
| 1270 | pkt->rg_property_data[1] = HFI_RATE_CONTROL_OFF; |
| 1271 | break; |
| 1272 | case HAL_RATE_CONTROL_CBR_CFR: |
| 1273 | pkt->rg_property_data[1] = HFI_RATE_CONTROL_CBR_CFR; |
| 1274 | break; |
| 1275 | case HAL_RATE_CONTROL_CBR_VFR: |
| 1276 | pkt->rg_property_data[1] = HFI_RATE_CONTROL_CBR_VFR; |
| 1277 | break; |
| 1278 | case HAL_RATE_CONTROL_VBR_CFR: |
| 1279 | pkt->rg_property_data[1] = HFI_RATE_CONTROL_VBR_CFR; |
| 1280 | break; |
| 1281 | case HAL_RATE_CONTROL_VBR_VFR: |
| 1282 | pkt->rg_property_data[1] = HFI_RATE_CONTROL_VBR_VFR; |
| 1283 | break; |
| 1284 | default: |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 1285 | dprintk(VIDC_ERR, "Invalid Rate control setting: 0x%x", |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1286 | (int) pdata); |
| 1287 | break; |
| 1288 | } |
| 1289 | pkt->size += sizeof(u32) * 2; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1290 | break; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1291 | } |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1292 | case HAL_PARAM_VENC_MPEG4_TIME_RESOLUTION: |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1293 | { |
| 1294 | struct hfi_mpeg4_time_resolution *hfi; |
| 1295 | pkt->rg_property_data[0] = |
| 1296 | HFI_PROPERTY_PARAM_VENC_MPEG4_TIME_RESOLUTION; |
| 1297 | hfi = (struct hfi_mpeg4_time_resolution *) |
| 1298 | &pkt->rg_property_data[1]; |
| 1299 | hfi->time_increment_resolution = |
| 1300 | ((struct hal_mpeg4_time_resolution *)pdata)-> |
| 1301 | time_increment_resolution; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1302 | pkt->size += sizeof(u32) * 2; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1303 | break; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1304 | } |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1305 | case HAL_PARAM_VENC_MPEG4_HEADER_EXTENSION: |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1306 | { |
| 1307 | struct hfi_mpeg4_header_extension *hfi; |
| 1308 | pkt->rg_property_data[0] = |
| 1309 | HFI_PROPERTY_PARAM_VENC_MPEG4_HEADER_EXTENSION; |
| 1310 | hfi = (struct hfi_mpeg4_header_extension *) |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1311 | &pkt->rg_property_data[1]; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1312 | hfi->header_extension = (u32) pdata; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1313 | pkt->size += sizeof(u32) * 2; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1314 | break; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1315 | } |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1316 | case HAL_PARAM_VENC_H264_DEBLOCK_CONTROL: |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1317 | { |
| 1318 | struct hfi_h264_db_control *hfi; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1319 | struct hal_h264_db_control *prop = |
| 1320 | (struct hal_h264_db_control *) pdata; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1321 | pkt->rg_property_data[0] = |
| 1322 | HFI_PROPERTY_PARAM_VENC_H264_DEBLOCK_CONTROL; |
| 1323 | hfi = (struct hfi_h264_db_control *) &pkt->rg_property_data[1]; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1324 | switch (prop->mode) { |
| 1325 | case HAL_H264_DB_MODE_DISABLE: |
| 1326 | hfi->mode = HFI_H264_DB_MODE_DISABLE; |
| 1327 | break; |
| 1328 | case HAL_H264_DB_MODE_SKIP_SLICE_BOUNDARY: |
| 1329 | hfi->mode = HFI_H264_DB_MODE_SKIP_SLICE_BOUNDARY; |
| 1330 | break; |
| 1331 | case HAL_H264_DB_MODE_ALL_BOUNDARY: |
| 1332 | hfi->mode = HFI_H264_DB_MODE_ALL_BOUNDARY; |
| 1333 | break; |
| 1334 | default: |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 1335 | dprintk(VIDC_ERR, "Invalid deblocking mode: 0x%x", |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1336 | prop->mode); |
| 1337 | break; |
| 1338 | } |
| 1339 | hfi->slice_alpha_offset = prop->slice_alpha_offset; |
| 1340 | hfi->slice_beta_offset = prop->slice_beta_offset; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1341 | pkt->size += sizeof(u32) + |
| 1342 | sizeof(struct hfi_h264_db_control); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1343 | break; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1344 | } |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1345 | case HAL_PARAM_VENC_SESSION_QP: |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1346 | { |
| 1347 | struct hfi_quantization *hfi; |
| 1348 | pkt->rg_property_data[0] = |
| 1349 | HFI_PROPERTY_PARAM_VENC_SESSION_QP; |
| 1350 | hfi = (struct hfi_quantization *) &pkt->rg_property_data[1]; |
| 1351 | memcpy(hfi, (struct hfi_quantization *) pdata, |
| 1352 | sizeof(struct hfi_quantization)); |
| 1353 | pkt->size += sizeof(u32) + sizeof(struct hfi_quantization); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1354 | break; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1355 | } |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1356 | case HAL_CONFIG_VENC_INTRA_PERIOD: |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1357 | { |
| 1358 | struct hfi_intra_period *hfi; |
| 1359 | pkt->rg_property_data[0] = |
| 1360 | HFI_PROPERTY_CONFIG_VENC_INTRA_PERIOD; |
| 1361 | hfi = (struct hfi_intra_period *) &pkt->rg_property_data[1]; |
| 1362 | memcpy(hfi, (struct hfi_intra_period *) pdata, |
| 1363 | sizeof(struct hfi_intra_period)); |
| 1364 | pkt->size += sizeof(u32) + sizeof(struct hfi_intra_period); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1365 | break; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1366 | } |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1367 | case HAL_CONFIG_VENC_IDR_PERIOD: |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1368 | { |
| 1369 | struct hfi_idr_period *hfi; |
| 1370 | pkt->rg_property_data[0] = HFI_PROPERTY_CONFIG_VENC_IDR_PERIOD; |
| 1371 | hfi = (struct hfi_idr_period *) &pkt->rg_property_data[1]; |
| 1372 | hfi->idr_period = ((struct hfi_idr_period *) pdata)->idr_period; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1373 | pkt->size += sizeof(u32) * 2; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1374 | break; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1375 | } |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1376 | case HAL_CONFIG_VPE_OPERATIONS: |
| 1377 | break; |
| 1378 | case HAL_PARAM_VENC_INTRA_REFRESH: |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1379 | { |
| 1380 | struct hfi_intra_refresh *hfi; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1381 | struct hal_intra_refresh *prop = |
| 1382 | (struct hal_intra_refresh *) pdata; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1383 | pkt->rg_property_data[0] = |
| 1384 | HFI_PROPERTY_PARAM_VENC_INTRA_REFRESH; |
| 1385 | hfi = (struct hfi_intra_refresh *) &pkt->rg_property_data[1]; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1386 | switch (prop->mode) { |
| 1387 | case HAL_INTRA_REFRESH_NONE: |
| 1388 | hfi->mode = HFI_INTRA_REFRESH_NONE; |
| 1389 | break; |
| 1390 | case HAL_INTRA_REFRESH_ADAPTIVE: |
| 1391 | hfi->mode = HFI_INTRA_REFRESH_ADAPTIVE; |
| 1392 | break; |
| 1393 | case HAL_INTRA_REFRESH_CYCLIC: |
| 1394 | hfi->mode = HFI_INTRA_REFRESH_CYCLIC; |
| 1395 | break; |
| 1396 | case HAL_INTRA_REFRESH_CYCLIC_ADAPTIVE: |
| 1397 | hfi->mode = HFI_INTRA_REFRESH_CYCLIC_ADAPTIVE; |
| 1398 | break; |
| 1399 | case HAL_INTRA_REFRESH_RANDOM: |
| 1400 | hfi->mode = HFI_INTRA_REFRESH_RANDOM; |
| 1401 | break; |
| 1402 | default: |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 1403 | dprintk(VIDC_ERR, "Invalid intra refresh setting: 0x%x", |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1404 | prop->mode); |
| 1405 | break; |
| 1406 | } |
| 1407 | hfi->air_mbs = prop->air_mbs; |
| 1408 | hfi->air_ref = prop->air_ref; |
| 1409 | hfi->cir_mbs = prop->cir_mbs; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1410 | pkt->size += sizeof(u32) + sizeof(struct hfi_intra_refresh); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1411 | break; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1412 | } |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1413 | case HAL_PARAM_VENC_MULTI_SLICE_CONTROL: |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1414 | { |
| 1415 | struct hfi_multi_slice_control *hfi; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1416 | struct hal_multi_slice_control *prop = |
| 1417 | (struct hal_multi_slice_control *) pdata; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1418 | pkt->rg_property_data[0] = |
| 1419 | HFI_PROPERTY_PARAM_VENC_MULTI_SLICE_CONTROL; |
| 1420 | hfi = (struct hfi_multi_slice_control *) |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1421 | &pkt->rg_property_data[1]; |
| 1422 | switch (prop->multi_slice) { |
| 1423 | case HAL_MULTI_SLICE_OFF: |
| 1424 | hfi->multi_slice = HFI_MULTI_SLICE_OFF; |
| 1425 | break; |
| 1426 | case HAL_MULTI_SLICE_GOB: |
| 1427 | hfi->multi_slice = HFI_MULTI_SLICE_GOB; |
| 1428 | break; |
| 1429 | case HAL_MULTI_SLICE_BY_MB_COUNT: |
| 1430 | hfi->multi_slice = HFI_MULTI_SLICE_BY_MB_COUNT; |
| 1431 | break; |
| 1432 | case HAL_MULTI_SLICE_BY_BYTE_COUNT: |
| 1433 | hfi->multi_slice = HFI_MULTI_SLICE_BY_BYTE_COUNT; |
| 1434 | break; |
| 1435 | default: |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 1436 | dprintk(VIDC_ERR, "Invalid slice settings: 0x%x", |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1437 | prop->multi_slice); |
| 1438 | break; |
| 1439 | } |
Ashray Kulkarni | 6a8803f | 2012-10-09 18:41:49 -0700 | [diff] [blame] | 1440 | hfi->slice_size = prop->slice_size; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1441 | pkt->size += sizeof(u32) + sizeof(struct |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1442 | hfi_multi_slice_control); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1443 | break; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1444 | } |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1445 | case HAL_CONFIG_VPE_DEINTERLACE: |
| 1446 | break; |
| 1447 | case HAL_SYS_DEBUG_CONFIG: |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1448 | { |
| 1449 | struct hfi_debug_config *hfi; |
| 1450 | pkt->rg_property_data[0] = HFI_PROPERTY_SYS_DEBUG_CONFIG; |
| 1451 | hfi = (struct hfi_debug_config *) &pkt->rg_property_data[1]; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1452 | hfi->debug_config = ((struct hal_debug_config *) |
| 1453 | pdata)->debug_config; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1454 | pkt->size = sizeof(struct hfi_cmd_sys_set_property_packet) + |
| 1455 | sizeof(struct hfi_debug_config); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1456 | break; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1457 | } |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1458 | /* FOLLOWING PROPERTIES ARE NOT IMPLEMENTED IN CORE YET */ |
| 1459 | case HAL_CONFIG_BUFFER_REQUIREMENTS: |
| 1460 | case HAL_CONFIG_PRIORITY: |
| 1461 | case HAL_CONFIG_BATCH_INFO: |
| 1462 | case HAL_PARAM_METADATA_PASS_THROUGH: |
| 1463 | case HAL_SYS_IDLE_INDICATOR: |
| 1464 | case HAL_PARAM_UNCOMPRESSED_FORMAT_SUPPORTED: |
| 1465 | case HAL_PARAM_INTERLACE_FORMAT_SUPPORTED: |
| 1466 | case HAL_PARAM_CHROMA_SITE: |
| 1467 | case HAL_PARAM_PROPERTIES_SUPPORTED: |
| 1468 | case HAL_PARAM_PROFILE_LEVEL_SUPPORTED: |
| 1469 | case HAL_PARAM_CAPABILITY_SUPPORTED: |
| 1470 | case HAL_PARAM_NAL_STREAM_FORMAT_SUPPORTED: |
| 1471 | case HAL_PARAM_MULTI_VIEW_FORMAT: |
| 1472 | case HAL_PARAM_MAX_SEQUENCE_HEADER_SIZE: |
| 1473 | case HAL_PARAM_CODEC_SUPPORTED: |
| 1474 | case HAL_PARAM_VDEC_MULTI_VIEW_SELECT: |
| 1475 | case HAL_PARAM_VDEC_MB_QUANTIZATION: |
| 1476 | case HAL_PARAM_VDEC_NUM_CONCEALED_MB: |
| 1477 | case HAL_PARAM_VDEC_H264_ENTROPY_SWITCHING: |
| 1478 | case HAL_PARAM_VENC_SLICE_DELIVERY_MODE: |
| 1479 | case HAL_PARAM_VENC_MPEG4_DATA_PARTITIONING: |
| 1480 | |
| 1481 | case HAL_CONFIG_BUFFER_COUNT_ACTUAL: |
| 1482 | case HAL_CONFIG_VDEC_MULTI_STREAM: |
| 1483 | case HAL_PARAM_VENC_MULTI_SLICE_INFO: |
| 1484 | case HAL_CONFIG_VENC_TIMESTAMP_SCALE: |
| 1485 | case HAL_PARAM_VENC_LOW_LATENCY: |
| 1486 | default: |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 1487 | dprintk(VIDC_INFO, "DEFAULT: Calling 0x%x", ptype); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1488 | break; |
| 1489 | } |
| 1490 | if (vidc_hal_iface_cmdq_write(session->device, pkt)) |
| 1491 | return -ENOTEMPTY; |
| 1492 | return 0; |
| 1493 | } |
| 1494 | |
| 1495 | int vidc_hal_session_get_property(void *sess, |
| 1496 | enum hal_property ptype, void *pdata) |
| 1497 | { |
| 1498 | struct hal_session *session; |
| 1499 | |
| 1500 | if (!sess || !pdata) { |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 1501 | dprintk(VIDC_ERR, "Invalid Params in "); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1502 | return -EINVAL; |
| 1503 | } else { |
| 1504 | session = sess; |
| 1505 | } |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 1506 | dprintk(VIDC_INFO, "IN func: , with property id: %d", ptype); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1507 | |
| 1508 | switch (ptype) { |
| 1509 | case HAL_CONFIG_FRAME_RATE: |
| 1510 | break; |
| 1511 | case HAL_PARAM_UNCOMPRESSED_FORMAT_SELECT: |
| 1512 | break; |
| 1513 | case HAL_PARAM_UNCOMPRESSED_PLANE_ACTUAL_CONSTRAINTS_INFO: |
| 1514 | break; |
| 1515 | case HAL_PARAM_UNCOMPRESSED_PLANE_ACTUAL_INFO: |
| 1516 | break; |
| 1517 | case HAL_PARAM_EXTRA_DATA_HEADER_CONFIG: |
| 1518 | break; |
| 1519 | case HAL_PARAM_FRAME_SIZE: |
| 1520 | break; |
| 1521 | case HAL_CONFIG_REALTIME: |
| 1522 | break; |
| 1523 | case HAL_PARAM_BUFFER_COUNT_ACTUAL: |
| 1524 | break; |
| 1525 | case HAL_PARAM_NAL_STREAM_FORMAT_SELECT: |
| 1526 | break; |
| 1527 | case HAL_PARAM_VDEC_OUTPUT_ORDER: |
| 1528 | break; |
| 1529 | case HAL_PARAM_VDEC_PICTURE_TYPE_DECODE: |
| 1530 | break; |
| 1531 | case HAL_PARAM_VDEC_OUTPUT2_KEEP_ASPECT_RATIO: |
| 1532 | break; |
| 1533 | case HAL_CONFIG_VDEC_POST_LOOP_DEBLOCKER: |
| 1534 | break; |
| 1535 | case HAL_PARAM_VDEC_MULTI_STREAM: |
| 1536 | break; |
| 1537 | case HAL_PARAM_VDEC_DISPLAY_PICTURE_BUFFER_COUNT: |
| 1538 | break; |
| 1539 | case HAL_PARAM_DIVX_FORMAT: |
| 1540 | break; |
| 1541 | case HAL_CONFIG_VDEC_MB_ERROR_MAP_REPORTING: |
| 1542 | break; |
| 1543 | case HAL_PARAM_VDEC_CONTINUE_DATA_TRANSFER: |
| 1544 | break; |
| 1545 | case HAL_CONFIG_VDEC_MB_ERROR_MAP: |
| 1546 | break; |
| 1547 | case HAL_CONFIG_VENC_REQUEST_IFRAME: |
| 1548 | break; |
| 1549 | case HAL_PARAM_VENC_MPEG4_SHORT_HEADER: |
| 1550 | break; |
| 1551 | case HAL_PARAM_VENC_MPEG4_AC_PREDICTION: |
| 1552 | break; |
| 1553 | case HAL_CONFIG_VENC_TARGET_BITRATE: |
| 1554 | break; |
| 1555 | case HAL_PARAM_PROFILE_LEVEL_CURRENT: |
| 1556 | break; |
| 1557 | case HAL_PARAM_VENC_H264_ENTROPY_CONTROL: |
| 1558 | break; |
| 1559 | case HAL_PARAM_VENC_RATE_CONTROL: |
| 1560 | break; |
| 1561 | case HAL_PARAM_VENC_MPEG4_TIME_RESOLUTION: |
| 1562 | break; |
| 1563 | case HAL_PARAM_VENC_MPEG4_HEADER_EXTENSION: |
| 1564 | break; |
| 1565 | case HAL_PARAM_VENC_H264_DEBLOCK_CONTROL: |
| 1566 | break; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1567 | case HAL_PARAM_VENC_SESSION_QP: |
| 1568 | break; |
| 1569 | case HAL_CONFIG_VENC_INTRA_PERIOD: |
| 1570 | break; |
| 1571 | case HAL_CONFIG_VENC_IDR_PERIOD: |
| 1572 | break; |
| 1573 | case HAL_CONFIG_VPE_OPERATIONS: |
| 1574 | break; |
| 1575 | case HAL_PARAM_VENC_INTRA_REFRESH: |
| 1576 | break; |
| 1577 | case HAL_PARAM_VENC_MULTI_SLICE_CONTROL: |
| 1578 | break; |
| 1579 | case HAL_CONFIG_VPE_DEINTERLACE: |
| 1580 | break; |
| 1581 | case HAL_SYS_DEBUG_CONFIG: |
| 1582 | break; |
| 1583 | /*FOLLOWING PROPERTIES ARE NOT IMPLEMENTED IN CORE YET*/ |
| 1584 | case HAL_CONFIG_BUFFER_REQUIREMENTS: |
| 1585 | case HAL_CONFIG_PRIORITY: |
| 1586 | case HAL_CONFIG_BATCH_INFO: |
| 1587 | case HAL_PARAM_METADATA_PASS_THROUGH: |
| 1588 | case HAL_SYS_IDLE_INDICATOR: |
| 1589 | case HAL_PARAM_UNCOMPRESSED_FORMAT_SUPPORTED: |
| 1590 | case HAL_PARAM_INTERLACE_FORMAT_SUPPORTED: |
| 1591 | case HAL_PARAM_CHROMA_SITE: |
| 1592 | case HAL_PARAM_PROPERTIES_SUPPORTED: |
| 1593 | case HAL_PARAM_PROFILE_LEVEL_SUPPORTED: |
| 1594 | case HAL_PARAM_CAPABILITY_SUPPORTED: |
| 1595 | case HAL_PARAM_NAL_STREAM_FORMAT_SUPPORTED: |
| 1596 | case HAL_PARAM_MULTI_VIEW_FORMAT: |
| 1597 | case HAL_PARAM_MAX_SEQUENCE_HEADER_SIZE: |
| 1598 | case HAL_PARAM_CODEC_SUPPORTED: |
| 1599 | case HAL_PARAM_VDEC_MULTI_VIEW_SELECT: |
| 1600 | case HAL_PARAM_VDEC_MB_QUANTIZATION: |
| 1601 | case HAL_PARAM_VDEC_NUM_CONCEALED_MB: |
| 1602 | case HAL_PARAM_VDEC_H264_ENTROPY_SWITCHING: |
| 1603 | case HAL_PARAM_VENC_SLICE_DELIVERY_MODE: |
| 1604 | case HAL_PARAM_VENC_MPEG4_DATA_PARTITIONING: |
| 1605 | |
| 1606 | case HAL_CONFIG_BUFFER_COUNT_ACTUAL: |
| 1607 | case HAL_CONFIG_VDEC_MULTI_STREAM: |
| 1608 | case HAL_PARAM_VENC_MULTI_SLICE_INFO: |
| 1609 | case HAL_CONFIG_VENC_TIMESTAMP_SCALE: |
| 1610 | case HAL_PARAM_VENC_LOW_LATENCY: |
| 1611 | default: |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 1612 | dprintk(VIDC_INFO, "DEFAULT: Calling 0x%x", ptype); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1613 | break; |
| 1614 | } |
| 1615 | return 0; |
| 1616 | } |
| 1617 | |
| 1618 | void *vidc_hal_session_init(void *device, u32 session_id, |
| 1619 | enum hal_domain session_type, enum hal_video_codec codec_type) |
| 1620 | { |
| 1621 | struct hfi_cmd_sys_session_init_packet pkt; |
| 1622 | struct hal_session *new_session; |
| 1623 | struct hal_device *dev; |
| 1624 | |
| 1625 | if (device) { |
| 1626 | dev = device; |
| 1627 | } else { |
Ashray Kulkarni | 000b382 | 2012-10-11 18:20:58 -0700 | [diff] [blame] | 1628 | dprintk(VIDC_ERR, "invalid device"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1629 | return NULL; |
| 1630 | } |
| 1631 | |
| 1632 | new_session = (struct hal_session *) |
| 1633 | kzalloc(sizeof(struct hal_session), GFP_KERNEL); |
| 1634 | new_session->session_id = (u32) session_id; |
| 1635 | if (session_type == 1) |
| 1636 | new_session->is_decoder = 0; |
| 1637 | else if (session_type == 2) |
| 1638 | new_session->is_decoder = 1; |
| 1639 | new_session->device = dev; |
| 1640 | list_add_tail(&new_session->list, &dev->sess_head); |
| 1641 | pkt.size = sizeof(struct hfi_cmd_sys_session_init_packet); |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1642 | pkt.packet_type = HFI_CMD_SYS_SESSION_INIT; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1643 | pkt.session_id = (u32) new_session; |
| 1644 | pkt.session_domain = session_type; |
| 1645 | pkt.session_codec = codec_type; |
| 1646 | if (vidc_hal_iface_cmdq_write(dev, &pkt)) |
| 1647 | return NULL; |
| 1648 | return (void *) new_session; |
| 1649 | } |
| 1650 | |
| 1651 | static int vidc_hal_send_session_cmd(void *session_id, |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1652 | int pkt_type) |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1653 | { |
| 1654 | struct vidc_hal_session_cmd_pkt pkt; |
| 1655 | int rc = 0; |
| 1656 | struct hal_session *session; |
| 1657 | |
| 1658 | if (session_id) { |
| 1659 | session = session_id; |
| 1660 | } else { |
Ashray Kulkarni | 000b382 | 2012-10-11 18:20:58 -0700 | [diff] [blame] | 1661 | dprintk(VIDC_ERR, "invalid session"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1662 | return -ENODEV; |
| 1663 | } |
| 1664 | |
| 1665 | pkt.size = sizeof(struct vidc_hal_session_cmd_pkt); |
| 1666 | pkt.packet_type = pkt_type; |
| 1667 | pkt.session_id = (u32) session; |
| 1668 | |
| 1669 | if (vidc_hal_iface_cmdq_write(session->device, &pkt)) |
| 1670 | rc = -ENOTEMPTY; |
| 1671 | return rc; |
| 1672 | } |
| 1673 | |
| 1674 | int vidc_hal_session_end(void *session) |
| 1675 | { |
| 1676 | return vidc_hal_send_session_cmd(session, |
| 1677 | HFI_CMD_SYS_SESSION_END); |
| 1678 | } |
| 1679 | |
| 1680 | int vidc_hal_session_abort(void *session) |
| 1681 | { |
| 1682 | return vidc_hal_send_session_cmd(session, |
| 1683 | HFI_CMD_SYS_SESSION_ABORT); |
| 1684 | } |
| 1685 | |
| 1686 | int vidc_hal_session_set_buffers(void *sess, |
| 1687 | struct vidc_buffer_addr_info *buffer_info) |
| 1688 | { |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1689 | u32 buffer; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1690 | struct hfi_cmd_session_set_buffers_packet *pkt; |
| 1691 | u8 packet[VIDC_IFACEQ_VAR_LARGE_PKT_SIZE]; |
| 1692 | int rc = 0; |
| 1693 | u16 i; |
| 1694 | struct hal_session *session; |
| 1695 | |
| 1696 | if (!sess || !buffer_info) { |
Ashray Kulkarni | 000b382 | 2012-10-11 18:20:58 -0700 | [diff] [blame] | 1697 | dprintk(VIDC_ERR, "Invalid Params"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1698 | return -EINVAL; |
| 1699 | } else { |
| 1700 | session = sess; |
| 1701 | } |
| 1702 | |
| 1703 | if (buffer_info->buffer_type == HAL_BUFFER_INPUT) |
| 1704 | return 0; |
| 1705 | |
| 1706 | pkt = (struct hfi_cmd_session_set_buffers_packet *)packet; |
| 1707 | |
| 1708 | pkt->size = sizeof(struct hfi_cmd_session_set_buffers_packet) + |
| 1709 | ((buffer_info->num_buffers - 1) * sizeof(u32)); |
| 1710 | pkt->packet_type = HFI_CMD_SESSION_SET_BUFFERS; |
| 1711 | pkt->session_id = (u32) session; |
| 1712 | pkt->buffer_mode = HFI_BUFFER_MODE_STATIC; |
| 1713 | pkt->buffer_size = buffer_info->buffer_size; |
| 1714 | pkt->min_buffer_size = buffer_info->buffer_size; |
| 1715 | pkt->num_buffers = buffer_info->num_buffers; |
| 1716 | |
| 1717 | if ((buffer_info->buffer_type == HAL_BUFFER_OUTPUT) || |
| 1718 | (buffer_info->buffer_type == HAL_BUFFER_OUTPUT2)) { |
| 1719 | struct hfi_buffer_info *buff; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1720 | pkt->extra_data_size = buffer_info->extradata_size; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1721 | pkt->size = sizeof(struct hfi_cmd_session_set_buffers_packet) - |
| 1722 | sizeof(u32) + ((buffer_info->num_buffers) * |
| 1723 | sizeof(struct hfi_buffer_info)); |
| 1724 | buff = (struct hfi_buffer_info *) pkt->rg_buffer_info; |
| 1725 | for (i = 0; i < pkt->num_buffers; i++) { |
| 1726 | buff->buffer_addr = |
| 1727 | buffer_info->align_device_addr; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1728 | buff->extra_data_addr = |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1729 | buffer_info->extradata_addr; |
| 1730 | } |
| 1731 | } else { |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1732 | pkt->extra_data_size = 0; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1733 | pkt->size = sizeof(struct hfi_cmd_session_set_buffers_packet) + |
| 1734 | ((buffer_info->num_buffers - 1) * sizeof(u32)); |
| 1735 | for (i = 0; i < pkt->num_buffers; i++) |
| 1736 | pkt->rg_buffer_info[i] = |
| 1737 | buffer_info->align_device_addr; |
| 1738 | } |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1739 | buffer = get_hfi_buffer(buffer_info->buffer_type); |
| 1740 | if (buffer) |
| 1741 | pkt->buffer_type = buffer; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1742 | else |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1743 | return -EINVAL; |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 1744 | dprintk(VIDC_INFO, "set buffers: 0x%x", buffer_info->buffer_type); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1745 | if (vidc_hal_iface_cmdq_write(session->device, pkt)) |
| 1746 | rc = -ENOTEMPTY; |
| 1747 | return rc; |
| 1748 | } |
| 1749 | |
| 1750 | int vidc_hal_session_release_buffers(void *sess, |
| 1751 | struct vidc_buffer_addr_info *buffer_info) |
| 1752 | { |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1753 | u32 buffer; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1754 | struct hfi_cmd_session_release_buffer_packet *pkt; |
| 1755 | u8 packet[VIDC_IFACEQ_VAR_LARGE_PKT_SIZE]; |
| 1756 | int rc = 0; |
| 1757 | u32 i; |
| 1758 | struct hal_session *session; |
| 1759 | |
| 1760 | if (!sess || !buffer_info) { |
Ashray Kulkarni | 000b382 | 2012-10-11 18:20:58 -0700 | [diff] [blame] | 1761 | dprintk(VIDC_ERR, "Invalid Params"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1762 | return -EINVAL; |
| 1763 | } else { |
| 1764 | session = sess; |
| 1765 | } |
| 1766 | |
| 1767 | if (buffer_info->buffer_type == HAL_BUFFER_INPUT) |
| 1768 | return 0; |
| 1769 | |
| 1770 | pkt = (struct hfi_cmd_session_release_buffer_packet *) packet; |
| 1771 | pkt->size = sizeof(struct hfi_cmd_session_release_buffer_packet) + |
| 1772 | ((buffer_info->num_buffers - 1) * sizeof(u32)); |
| 1773 | pkt->packet_type = HFI_CMD_SESSION_RELEASE_BUFFERS; |
| 1774 | pkt->session_id = (u32) session; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1775 | pkt->buffer_size = buffer_info->buffer_size; |
| 1776 | pkt->num_buffers = buffer_info->num_buffers; |
| 1777 | |
| 1778 | if ((buffer_info->buffer_type == HAL_BUFFER_OUTPUT) || |
| 1779 | (buffer_info->buffer_type == HAL_BUFFER_OUTPUT2)) { |
| 1780 | struct hfi_buffer_info *buff; |
| 1781 | buff = (struct hfi_buffer_info *) pkt->rg_buffer_info; |
| 1782 | for (i = 0; i < pkt->num_buffers; i++) { |
| 1783 | buff->buffer_addr = |
| 1784 | buffer_info->align_device_addr; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1785 | buff->extra_data_addr = |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1786 | buffer_info->extradata_addr; |
| 1787 | } |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1788 | pkt->extra_data_size = buffer_info->extradata_size; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1789 | pkt->size = sizeof(struct hfi_cmd_session_set_buffers_packet) - |
| 1790 | sizeof(u32) + ((buffer_info->num_buffers) * |
| 1791 | sizeof(struct hfi_buffer_info)); |
| 1792 | } else { |
| 1793 | for (i = 0; i < pkt->num_buffers; i++) |
| 1794 | pkt->rg_buffer_info[i] = |
| 1795 | buffer_info->align_device_addr; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1796 | pkt->extra_data_size = 0; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1797 | pkt->size = sizeof(struct hfi_cmd_session_set_buffers_packet) + |
| 1798 | ((buffer_info->num_buffers - 1) * sizeof(u32)); |
| 1799 | } |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1800 | buffer = get_hfi_buffer(buffer_info->buffer_type); |
| 1801 | if (buffer) |
| 1802 | pkt->buffer_type = buffer; |
| 1803 | else |
| 1804 | return -EINVAL; |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 1805 | dprintk(VIDC_INFO, "Release buffers: 0x%x", buffer_info->buffer_type); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1806 | if (vidc_hal_iface_cmdq_write(session->device, pkt)) |
| 1807 | rc = -ENOTEMPTY; |
| 1808 | return rc; |
| 1809 | } |
| 1810 | |
| 1811 | int vidc_hal_session_load_res(void *sess) |
| 1812 | { |
| 1813 | return vidc_hal_send_session_cmd(sess, |
| 1814 | HFI_CMD_SESSION_LOAD_RESOURCES); |
| 1815 | } |
| 1816 | |
| 1817 | int vidc_hal_session_release_res(void *sess) |
| 1818 | { |
| 1819 | return vidc_hal_send_session_cmd(sess, |
| 1820 | HFI_CMD_SESSION_RELEASE_RESOURCES); |
| 1821 | } |
| 1822 | |
| 1823 | int vidc_hal_session_start(void *sess) |
| 1824 | { |
| 1825 | return vidc_hal_send_session_cmd(sess, |
| 1826 | HFI_CMD_SESSION_START); |
| 1827 | } |
| 1828 | |
| 1829 | int vidc_hal_session_stop(void *sess) |
| 1830 | { |
| 1831 | return vidc_hal_send_session_cmd(sess, |
| 1832 | HFI_CMD_SESSION_STOP); |
| 1833 | } |
| 1834 | |
| 1835 | int vidc_hal_session_suspend(void *sess) |
| 1836 | { |
| 1837 | return vidc_hal_send_session_cmd(sess, |
| 1838 | HFI_CMD_SESSION_SUSPEND); |
| 1839 | } |
| 1840 | |
| 1841 | int vidc_hal_session_resume(void *sess) |
| 1842 | { |
| 1843 | return vidc_hal_send_session_cmd(sess, |
| 1844 | HFI_CMD_SESSION_RESUME); |
| 1845 | } |
| 1846 | |
| 1847 | int vidc_hal_session_etb(void *sess, struct vidc_frame_data *input_frame) |
| 1848 | { |
| 1849 | int rc = 0; |
| 1850 | struct hal_session *session; |
| 1851 | |
| 1852 | if (!sess || !input_frame) { |
Ashray Kulkarni | 000b382 | 2012-10-11 18:20:58 -0700 | [diff] [blame] | 1853 | dprintk(VIDC_ERR, "Invalid Params"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1854 | return -EINVAL; |
| 1855 | } else { |
| 1856 | session = sess; |
| 1857 | } |
| 1858 | |
| 1859 | if (session->is_decoder) { |
| 1860 | struct hfi_cmd_session_empty_buffer_compressed_packet pkt; |
| 1861 | pkt.size = sizeof( |
| 1862 | struct hfi_cmd_session_empty_buffer_compressed_packet); |
| 1863 | pkt.packet_type = HFI_CMD_SESSION_EMPTY_BUFFER; |
| 1864 | pkt.session_id = (u32) session; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1865 | pkt.time_stamp_hi = (int) (((u64)input_frame->timestamp) >> 32); |
| 1866 | pkt.time_stamp_lo = (int) input_frame->timestamp; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1867 | pkt.flags = input_frame->flags; |
| 1868 | pkt.mark_target = input_frame->mark_target; |
| 1869 | pkt.mark_data = input_frame->mark_data; |
| 1870 | pkt.offset = input_frame->offset; |
| 1871 | pkt.alloc_len = input_frame->alloc_len; |
| 1872 | pkt.filled_len = input_frame->filled_len; |
| 1873 | pkt.input_tag = input_frame->clnt_data; |
| 1874 | pkt.packet_buffer = (u8 *) input_frame->device_addr; |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 1875 | dprintk(VIDC_DBG, "Q DECODER INPUT BUFFER"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1876 | if (vidc_hal_iface_cmdq_write(session->device, &pkt)) |
| 1877 | rc = -ENOTEMPTY; |
| 1878 | } else { |
| 1879 | struct hfi_cmd_session_empty_buffer_uncompressed_plane0_packet |
| 1880 | pkt; |
| 1881 | pkt.size = sizeof(struct |
| 1882 | hfi_cmd_session_empty_buffer_uncompressed_plane0_packet); |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1883 | pkt.packet_type = HFI_CMD_SESSION_EMPTY_BUFFER; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1884 | pkt.session_id = (u32) session; |
| 1885 | pkt.view_id = 0; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1886 | pkt.time_stamp_hi = (u32) (((u64)input_frame->timestamp) >> 32); |
| 1887 | pkt.time_stamp_lo = (u32) input_frame->timestamp; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1888 | pkt.flags = input_frame->flags; |
| 1889 | pkt.mark_target = input_frame->mark_target; |
| 1890 | pkt.mark_data = input_frame->mark_data; |
| 1891 | pkt.offset = input_frame->offset; |
| 1892 | pkt.alloc_len = input_frame->alloc_len; |
| 1893 | pkt.filled_len = input_frame->filled_len; |
| 1894 | pkt.input_tag = input_frame->clnt_data; |
| 1895 | pkt.packet_buffer = (u8 *) input_frame->device_addr; |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 1896 | dprintk(VIDC_DBG, "Q ENCODER INPUT BUFFER"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1897 | if (vidc_hal_iface_cmdq_write(session->device, &pkt)) |
| 1898 | rc = -ENOTEMPTY; |
| 1899 | } |
| 1900 | return rc; |
| 1901 | } |
| 1902 | |
| 1903 | int vidc_hal_session_ftb(void *sess, |
| 1904 | struct vidc_frame_data *output_frame) |
| 1905 | { |
| 1906 | struct hfi_cmd_session_fill_buffer_packet pkt; |
| 1907 | int rc = 0; |
| 1908 | struct hal_session *session; |
| 1909 | |
| 1910 | if (!sess || !output_frame) { |
Ashray Kulkarni | 000b382 | 2012-10-11 18:20:58 -0700 | [diff] [blame] | 1911 | dprintk(VIDC_ERR, "Invalid Params"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1912 | return -EINVAL; |
| 1913 | } else { |
| 1914 | session = sess; |
| 1915 | } |
| 1916 | |
| 1917 | pkt.size = sizeof(struct hfi_cmd_session_fill_buffer_packet); |
| 1918 | pkt.packet_type = HFI_CMD_SESSION_FILL_BUFFER; |
| 1919 | pkt.session_id = (u32) session; |
| 1920 | if (output_frame->buffer_type == HAL_BUFFER_OUTPUT) |
| 1921 | pkt.stream_id = 0; |
| 1922 | else if (output_frame->buffer_type == HAL_BUFFER_OUTPUT2) |
| 1923 | pkt.stream_id = 1; |
| 1924 | pkt.packet_buffer = (u8 *) output_frame->device_addr; |
| 1925 | pkt.extra_data_buffer = |
| 1926 | (u8 *) output_frame->extradata_addr; |
| 1927 | |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 1928 | dprintk(VIDC_INFO, "### Q OUTPUT BUFFER ###"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1929 | if (vidc_hal_iface_cmdq_write(session->device, &pkt)) |
| 1930 | rc = -ENOTEMPTY; |
| 1931 | return rc; |
| 1932 | } |
| 1933 | |
| 1934 | int vidc_hal_session_parse_seq_hdr(void *sess, |
| 1935 | struct vidc_seq_hdr *seq_hdr) |
| 1936 | { |
| 1937 | struct hfi_cmd_session_parse_sequence_header_packet *pkt; |
| 1938 | int rc = 0; |
| 1939 | u8 packet[VIDC_IFACEQ_VAR_SMALL_PKT_SIZE]; |
| 1940 | struct hal_session *session; |
| 1941 | |
| 1942 | if (!sess || !seq_hdr) { |
Ashray Kulkarni | 000b382 | 2012-10-11 18:20:58 -0700 | [diff] [blame] | 1943 | dprintk(VIDC_ERR, "Invalid Params"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1944 | return -EINVAL; |
| 1945 | } else { |
| 1946 | session = sess; |
| 1947 | } |
| 1948 | |
| 1949 | pkt = (struct hfi_cmd_session_parse_sequence_header_packet *) packet; |
| 1950 | pkt->size = sizeof(struct hfi_cmd_session_parse_sequence_header_packet); |
| 1951 | pkt->packet_type = HFI_CMD_SESSION_PARSE_SEQUENCE_HEADER; |
| 1952 | pkt->session_id = (u32) session; |
| 1953 | pkt->header_len = seq_hdr->seq_hdr_len; |
| 1954 | pkt->packet_buffer = seq_hdr->seq_hdr; |
| 1955 | |
| 1956 | if (vidc_hal_iface_cmdq_write(session->device, pkt)) |
| 1957 | rc = -ENOTEMPTY; |
| 1958 | return rc; |
| 1959 | } |
| 1960 | |
| 1961 | int vidc_hal_session_get_seq_hdr(void *sess, |
| 1962 | struct vidc_seq_hdr *seq_hdr) |
| 1963 | { |
| 1964 | struct hfi_cmd_session_get_sequence_header_packet *pkt; |
| 1965 | int rc = 0; |
| 1966 | u8 packet[VIDC_IFACEQ_VAR_SMALL_PKT_SIZE]; |
| 1967 | struct hal_session *session; |
| 1968 | |
| 1969 | if (!sess || !seq_hdr) { |
Ashray Kulkarni | 000b382 | 2012-10-11 18:20:58 -0700 | [diff] [blame] | 1970 | dprintk(VIDC_ERR, "Invalid Params"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1971 | return -EINVAL; |
| 1972 | } else { |
| 1973 | session = sess; |
| 1974 | } |
| 1975 | |
| 1976 | pkt = (struct hfi_cmd_session_get_sequence_header_packet *) packet; |
| 1977 | pkt->size = sizeof(struct hfi_cmd_session_get_sequence_header_packet); |
| 1978 | pkt->packet_type = HFI_CMD_SESSION_GET_SEQUENCE_HEADER; |
| 1979 | pkt->session_id = (u32) session; |
| 1980 | pkt->buffer_len = seq_hdr->seq_hdr_len; |
| 1981 | pkt->packet_buffer = seq_hdr->seq_hdr; |
| 1982 | |
| 1983 | if (vidc_hal_iface_cmdq_write(session->device, pkt)) |
| 1984 | rc = -ENOTEMPTY; |
| 1985 | return rc; |
| 1986 | } |
| 1987 | |
| 1988 | int vidc_hal_session_get_buf_req(void *sess) |
| 1989 | { |
| 1990 | struct hfi_cmd_session_get_property_packet pkt; |
| 1991 | int rc = 0; |
| 1992 | struct hal_session *session; |
| 1993 | |
| 1994 | if (sess) { |
| 1995 | session = sess; |
| 1996 | } else { |
Ashray Kulkarni | 000b382 | 2012-10-11 18:20:58 -0700 | [diff] [blame] | 1997 | dprintk(VIDC_ERR, "invalid session"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1998 | return -ENODEV; |
| 1999 | } |
| 2000 | |
| 2001 | pkt.size = sizeof(struct hfi_cmd_session_get_property_packet); |
| 2002 | pkt.packet_type = HFI_CMD_SESSION_GET_PROPERTY; |
| 2003 | pkt.session_id = (u32) session; |
| 2004 | pkt.num_properties = 1; |
| 2005 | pkt.rg_property_data[0] = HFI_PROPERTY_CONFIG_BUFFER_REQUIREMENTS; |
| 2006 | if (vidc_hal_iface_cmdq_write(session->device, &pkt)) |
| 2007 | rc = -ENOTEMPTY; |
| 2008 | return rc; |
| 2009 | } |
| 2010 | |
| 2011 | int vidc_hal_session_flush(void *sess, enum hal_flush flush_mode) |
| 2012 | { |
| 2013 | struct hfi_cmd_session_flush_packet pkt; |
| 2014 | int rc = 0; |
| 2015 | struct hal_session *session; |
| 2016 | |
| 2017 | if (sess) { |
| 2018 | session = sess; |
| 2019 | } else { |
Ashray Kulkarni | 000b382 | 2012-10-11 18:20:58 -0700 | [diff] [blame] | 2020 | dprintk(VIDC_ERR, "invalid session"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 2021 | return -ENODEV; |
| 2022 | } |
| 2023 | |
| 2024 | pkt.size = sizeof(struct hfi_cmd_session_flush_packet); |
| 2025 | pkt.packet_type = HFI_CMD_SESSION_FLUSH; |
| 2026 | pkt.session_id = (u32) session; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 2027 | switch (flush_mode) { |
| 2028 | case HAL_FLUSH_INPUT: |
| 2029 | pkt.flush_type = HFI_FLUSH_INPUT; |
| 2030 | break; |
| 2031 | case HAL_FLUSH_OUTPUT: |
| 2032 | pkt.flush_type = HFI_FLUSH_OUTPUT; |
| 2033 | break; |
| 2034 | case HAL_FLUSH_OUTPUT2: |
| 2035 | pkt.flush_type = HFI_FLUSH_OUTPUT2; |
| 2036 | break; |
| 2037 | case HAL_FLUSH_ALL: |
| 2038 | pkt.flush_type = HFI_FLUSH_ALL; |
| 2039 | break; |
| 2040 | default: |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 2041 | dprintk(VIDC_ERR, "Invalid flush mode: 0x%x\n", flush_mode); |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 2042 | break; |
| 2043 | } |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 2044 | if (vidc_hal_iface_cmdq_write(session->device, &pkt)) |
| 2045 | rc = -ENOTEMPTY; |
| 2046 | return rc; |
| 2047 | } |
| 2048 | |
| 2049 | static int vidc_hal_check_core_registered( |
| 2050 | struct hal_device_data core, u32 fw_addr, |
| 2051 | u32 reg_addr, u32 reg_size, u32 irq) |
| 2052 | { |
| 2053 | struct hal_device *device; |
| 2054 | struct list_head *curr, *next; |
| 2055 | |
| 2056 | if (core.dev_count) { |
| 2057 | list_for_each_safe(curr, next, &core.dev_head) { |
| 2058 | device = list_entry(curr, struct hal_device, list); |
| 2059 | if (device && device->hal_data->irq == irq && |
Vinay Kalia | 68398a4 | 2012-06-22 18:36:12 -0700 | [diff] [blame] | 2060 | (CONTAINS(device->hal_data-> |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 2061 | device_base_addr, |
| 2062 | FIRMWARE_SIZE, fw_addr) || |
| 2063 | CONTAINS(fw_addr, FIRMWARE_SIZE, |
Vinay Kalia | 68398a4 | 2012-06-22 18:36:12 -0700 | [diff] [blame] | 2064 | device->hal_data-> |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 2065 | device_base_addr) || |
| 2066 | CONTAINS((u32)device->hal_data-> |
| 2067 | register_base_addr, |
| 2068 | reg_size, reg_addr) || |
| 2069 | CONTAINS(reg_addr, reg_size, |
| 2070 | (u32)device->hal_data-> |
| 2071 | register_base_addr) || |
| 2072 | OVERLAPS((u32)device->hal_data-> |
| 2073 | register_base_addr, |
| 2074 | reg_size, reg_addr, reg_size) || |
| 2075 | OVERLAPS(reg_addr, reg_size, |
| 2076 | (u32)device->hal_data-> |
| 2077 | register_base_addr, reg_size) || |
Vinay Kalia | 68398a4 | 2012-06-22 18:36:12 -0700 | [diff] [blame] | 2078 | OVERLAPS(device->hal_data-> |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 2079 | device_base_addr, |
| 2080 | FIRMWARE_SIZE, fw_addr, |
| 2081 | FIRMWARE_SIZE) || |
| 2082 | OVERLAPS(fw_addr, FIRMWARE_SIZE, |
Vinay Kalia | 68398a4 | 2012-06-22 18:36:12 -0700 | [diff] [blame] | 2083 | device->hal_data-> |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 2084 | device_base_addr, |
| 2085 | FIRMWARE_SIZE))) { |
| 2086 | return 0; |
| 2087 | } else { |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 2088 | dprintk(VIDC_INFO, "Device not registered"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 2089 | return -EINVAL; |
| 2090 | } |
| 2091 | } |
| 2092 | } else { |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 2093 | dprintk(VIDC_INFO, "no device Registered"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 2094 | } |
| 2095 | return -EINVAL; |
| 2096 | } |
| 2097 | |
| 2098 | static void vidc_hal_core_work_handler(struct work_struct *work) |
| 2099 | { |
Deva Ramasubramanian | c249b75 | 2012-05-18 17:31:03 -0700 | [diff] [blame] | 2100 | struct hal_device *device = list_first_entry( |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 2101 | &hal_ctxt.dev_head, struct hal_device, list); |
| 2102 | |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 2103 | dprintk(VIDC_INFO, " GOT INTERRUPT () "); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 2104 | if (!device->callback) { |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 2105 | dprintk(VIDC_ERR, "No callback function " |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 2106 | "to process interrupt: %p\n", device); |
| 2107 | return; |
| 2108 | } |
| 2109 | vidc_hal_core_clear_interrupt(device); |
| 2110 | vidc_hal_response_handler(device); |
| 2111 | enable_irq(device->hal_data->irq); |
| 2112 | } |
| 2113 | static DECLARE_WORK(vidc_hal_work, vidc_hal_core_work_handler); |
| 2114 | |
| 2115 | static irqreturn_t vidc_hal_isr(int irq, void *dev) |
| 2116 | { |
| 2117 | struct hal_device *device = dev; |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 2118 | dprintk(VIDC_INFO, "vidc_hal_isr() %d ", irq); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 2119 | disable_irq_nosync(irq); |
| 2120 | queue_work(device->vidc_workq, &vidc_hal_work); |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 2121 | dprintk(VIDC_INFO, "vidc_hal_isr() %d ", irq); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 2122 | return IRQ_HANDLED; |
| 2123 | } |
| 2124 | |
| 2125 | void *vidc_hal_add_device(u32 device_id, u32 fw_base_addr, u32 reg_base, |
| 2126 | u32 reg_size, u32 irq, |
| 2127 | void (*callback) (enum command_response cmd, void *data)) |
| 2128 | { |
| 2129 | struct hal_device *hdevice = NULL; |
| 2130 | struct hal_data *hal = NULL; |
| 2131 | int rc = 0; |
| 2132 | |
Vinay Kalia | 68398a4 | 2012-06-22 18:36:12 -0700 | [diff] [blame] | 2133 | if (device_id || !reg_base || !reg_size || |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 2134 | !irq || !callback) { |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 2135 | dprintk(VIDC_ERR, "Invalid Paramters"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 2136 | return NULL; |
| 2137 | } else { |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 2138 | dprintk(VIDC_INFO, "entered , device_id: %d", device_id); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 2139 | } |
| 2140 | |
| 2141 | if (vidc_hal_check_core_registered(hal_ctxt, fw_base_addr, |
| 2142 | reg_base, reg_size, irq)) { |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 2143 | dprintk(VIDC_DBG, "HAL_DATA will be assigned now"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 2144 | hal = (struct hal_data *) |
| 2145 | kzalloc(sizeof(struct hal_data), GFP_KERNEL); |
| 2146 | if (!hal) { |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 2147 | dprintk(VIDC_ERR, "Failed to alloc"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 2148 | return NULL; |
| 2149 | } |
| 2150 | hal->irq = irq; |
Vinay Kalia | 68398a4 | 2012-06-22 18:36:12 -0700 | [diff] [blame] | 2151 | hal->device_base_addr = fw_base_addr; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 2152 | hal->register_base_addr = |
| 2153 | ioremap_nocache(reg_base, reg_size); |
| 2154 | if (!hal->register_base_addr) { |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 2155 | dprintk(VIDC_ERR, |
| 2156 | "could not map reg addr %d of size %d", |
| 2157 | reg_base, reg_size); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 2158 | goto err_map; |
| 2159 | } |
| 2160 | INIT_LIST_HEAD(&hal_ctxt.dev_head); |
| 2161 | } else { |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 2162 | dprintk(VIDC_ERR, "Core present/Already added"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 2163 | return NULL; |
| 2164 | } |
| 2165 | |
| 2166 | hdevice = (struct hal_device *) |
| 2167 | kzalloc(sizeof(struct hal_device), GFP_KERNEL); |
| 2168 | if (!hdevice) { |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 2169 | dprintk(VIDC_ERR, "failed to allocate new device"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 2170 | goto err_map; |
| 2171 | } |
| 2172 | |
| 2173 | INIT_LIST_HEAD(&hdevice->list); |
| 2174 | list_add_tail(&hdevice->list, &hal_ctxt.dev_head); |
| 2175 | hal_ctxt.dev_count++; |
| 2176 | hdevice->device_id = device_id; |
| 2177 | hdevice->hal_data = hal; |
| 2178 | hdevice->callback = callback; |
| 2179 | |
| 2180 | hdevice->vidc_workq = create_singlethread_workqueue( |
| 2181 | "msm_vidc_workerq"); |
| 2182 | if (!hdevice->vidc_workq) { |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 2183 | dprintk(VIDC_ERR, ": create workq failed\n"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 2184 | goto error_createq; |
| 2185 | } |
| 2186 | |
| 2187 | rc = request_irq(irq, vidc_hal_isr, IRQF_TRIGGER_HIGH, |
| 2188 | "msm_vidc", hdevice); |
| 2189 | if (unlikely(rc)) { |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 2190 | dprintk(VIDC_ERR, "() :request_irq failed\n"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 2191 | goto error_irq_fail; |
| 2192 | } |
| 2193 | disable_irq_nosync(irq); |
| 2194 | return (void *) hdevice; |
| 2195 | error_irq_fail: |
| 2196 | destroy_workqueue(hdevice->vidc_workq); |
| 2197 | error_createq: |
| 2198 | hal_ctxt.dev_count--; |
| 2199 | list_del(&hal_ctxt.dev_head); |
| 2200 | err_map: |
| 2201 | kfree(hal); |
| 2202 | return NULL; |
| 2203 | } |
| 2204 | |
| 2205 | void vidc_hal_delete_device(void *device) |
| 2206 | { |
| 2207 | struct hal_device *close, *dev; |
| 2208 | |
| 2209 | if (device) { |
| 2210 | dev = (struct hal_device *) device; |
| 2211 | list_for_each_entry(close, &hal_ctxt.dev_head, list) { |
| 2212 | if (close->hal_data->irq == dev->hal_data->irq) { |
| 2213 | hal_ctxt.dev_count--; |
| 2214 | free_irq(dev->hal_data->irq, NULL); |
| 2215 | list_del(&close->list); |
| 2216 | destroy_workqueue(close->vidc_workq); |
| 2217 | kfree(close->hal_data); |
| 2218 | kfree(close); |
| 2219 | break; |
| 2220 | } |
| 2221 | } |
| 2222 | |
| 2223 | } |
| 2224 | } |