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, |
Ashray Kulkarni | ae3e91a | 2012-10-12 17:37:37 -0700 | [diff] [blame] | 595 | VIDC_WRAPPER_INTR_MASK, 0x8, 0); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 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, |
Ashray Kulkarni | 36f8d36 | 2012-10-18 17:01:06 -0700 | [diff] [blame] | 616 | VIDC_VBIF_OUT_AXI_AOOO_EN, 0x00001FFF, 0); |
Vinay Kalia | cdf8d0c | 2012-08-28 12:07:36 -0700 | [diff] [blame] | 617 | write_register(device->hal_data->register_base_addr, |
Ashray Kulkarni | 36f8d36 | 2012-10-18 17:01:06 -0700 | [diff] [blame] | 618 | VIDC_VBIF_OUT_AXI_AOOO, 0x1FFF1FFF, 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_VBIF_IN_RD_LIM_CONF0, 0x10101001, 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_CONF1, 0x10101010, 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_CONF2, 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_CONF3, 0x00000010, 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_WR_LIM_CONF0, 0x1010100f, 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_CONF1, 0x10101010, 0); |
| 631 | write_register(device->hal_data->register_base_addr, |
| 632 | VIDC_VBIF_IN_WR_LIM_CONF2, 0x10101010, 0); |
| 633 | write_register(device->hal_data->register_base_addr, |
| 634 | VIDC_VBIF_IN_WR_LIM_CONF3, 0x00000010, 0); |
| 635 | write_register(device->hal_data->register_base_addr, |
| 636 | VIDC_VBIF_OUT_RD_LIM_CONF0, 0x00001010, 0); |
| 637 | write_register(device->hal_data->register_base_addr, |
| 638 | VIDC_VBIF_OUT_WR_LIM_CONF0, 0x00001010, 0); |
| 639 | write_register(device->hal_data->register_base_addr, |
| 640 | VIDC_VBIF_ARB_CTL, 0x00000030, 0); |
Vinay Kalia | b717b9d | 2012-09-14 12:00:45 -0700 | [diff] [blame] | 641 | write_register(device->hal_data->register_base_addr, |
Ashray Kulkarni | 36f8d36 | 2012-10-18 17:01:06 -0700 | [diff] [blame] | 642 | VIDC_VENUS_VBIF_DDR_OUT_MAX_BURST, 0x00000707, 0); |
| 643 | write_register(device->hal_data->register_base_addr, |
| 644 | VIDC_VENUS_VBIF_OCMEM_OUT_MAX_BURST, 0x00000707, 0); |
| 645 | write_register(device->hal_data->register_base_addr, |
| 646 | VIDC_VENUS_VBIF_ROUND_ROBIN_QOS_ARB, 0x00000001, 0); |
| 647 | write_register(device->hal_data->register_base_addr, |
Vinay Kalia | b717b9d | 2012-09-14 12:00:45 -0700 | [diff] [blame] | 648 | VIDC_VENUS0_WRAPPER_VBIF_REQ_PRIORITY, 0x5555556, 0); |
Ashray Kulkarni | 36f8d36 | 2012-10-18 17:01:06 -0700 | [diff] [blame] | 649 | write_register(device->hal_data->register_base_addr, |
| 650 | VIDC_VENUS0_WRAPPER_VBIF_PRIORITY_LEVEL, 0, 0); |
Vinay Kalia | cdf8d0c | 2012-08-28 12:07:36 -0700 | [diff] [blame] | 651 | } |
| 652 | |
Ashray Kulkarni | cde7852 | 2012-06-28 18:14:50 -0700 | [diff] [blame] | 653 | static int vidc_hal_sys_set_debug(struct hal_device *device, int debug) |
| 654 | { |
| 655 | struct hfi_debug_config *hfi; |
| 656 | u8 packet[VIDC_IFACEQ_VAR_SMALL_PKT_SIZE]; |
| 657 | struct hfi_cmd_sys_set_property_packet *pkt = |
| 658 | (struct hfi_cmd_sys_set_property_packet *) &packet; |
| 659 | pkt->size = sizeof(struct hfi_cmd_sys_set_property_packet) + |
| 660 | sizeof(struct hfi_debug_config) + sizeof(u32); |
| 661 | pkt->packet_type = HFI_CMD_SYS_SET_PROPERTY; |
| 662 | pkt->num_properties = 1; |
| 663 | pkt->rg_property_data[0] = HFI_PROPERTY_SYS_DEBUG_CONFIG; |
| 664 | hfi = (struct hfi_debug_config *) &pkt->rg_property_data[1]; |
| 665 | hfi->debug_config = debug; |
| 666 | if (vidc_hal_iface_cmdq_write(device, pkt)) |
| 667 | return -ENOTEMPTY; |
| 668 | return 0; |
| 669 | } |
| 670 | |
Vinay Kalia | 68398a4 | 2012-06-22 18:36:12 -0700 | [diff] [blame] | 671 | int vidc_hal_core_init(void *device, int domain) |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 672 | { |
| 673 | struct hfi_cmd_sys_init_packet pkt; |
| 674 | int rc = 0; |
| 675 | struct hal_device *dev; |
| 676 | |
| 677 | if (device) { |
| 678 | dev = device; |
| 679 | } else { |
Ashray Kulkarni | b673450 | 2012-08-24 13:00:22 -0700 | [diff] [blame] | 680 | dprintk(VIDC_ERR, "Invalid device"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 681 | return -ENODEV; |
| 682 | } |
| 683 | enable_irq(dev->hal_data->irq); |
| 684 | INIT_LIST_HEAD(&dev->sess_head); |
| 685 | spin_lock_init(&dev->read_lock); |
| 686 | spin_lock_init(&dev->write_lock); |
Vinay Kalia | cdf8d0c | 2012-08-28 12:07:36 -0700 | [diff] [blame] | 687 | set_vbif_registers(dev); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 688 | if (!dev->hal_client) { |
| 689 | dev->hal_client = msm_smem_new_client(SMEM_ION); |
| 690 | if (dev->hal_client == NULL) { |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 691 | dprintk(VIDC_ERR, "Failed to alloc ION_Client"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 692 | rc = -ENODEV; |
| 693 | goto err_no_mem; |
| 694 | } |
| 695 | |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 696 | dprintk(VIDC_DBG, "Device_Virt_Address : 0x%x," |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 697 | "Register_Virt_Addr: 0x%x", |
Vinay Kalia | 68398a4 | 2012-06-22 18:36:12 -0700 | [diff] [blame] | 698 | dev->hal_data->device_base_addr, |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 699 | (u32) dev->hal_data->register_base_addr); |
| 700 | |
Vinay Kalia | 68398a4 | 2012-06-22 18:36:12 -0700 | [diff] [blame] | 701 | rc = vidc_hal_interface_queues_init(dev, domain); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 702 | if (rc) { |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 703 | dprintk(VIDC_ERR, "failed to init queues"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 704 | rc = -ENOMEM; |
| 705 | goto err_no_mem; |
| 706 | } |
| 707 | } else { |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 708 | dprintk(VIDC_ERR, "hal_client exists"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 709 | rc = -EEXIST; |
| 710 | goto err_no_mem; |
| 711 | } |
| 712 | rc = vidc_hal_core_start_cpu(dev); |
| 713 | if (rc) { |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 714 | dprintk(VIDC_ERR, "Failed to start core"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 715 | rc = -ENODEV; |
| 716 | goto err_no_dev; |
| 717 | } |
| 718 | pkt.size = sizeof(struct hfi_cmd_sys_init_packet); |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 719 | pkt.packet_type = HFI_CMD_SYS_INIT; |
| 720 | pkt.arch_type = HFI_ARCH_OX_OFFSET; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 721 | if (vidc_hal_iface_cmdq_write(dev, &pkt)) { |
| 722 | rc = -ENOTEMPTY; |
| 723 | goto err_write_fail; |
| 724 | } |
| 725 | return rc; |
| 726 | err_no_dev: |
| 727 | err_write_fail: |
| 728 | err_no_mem: |
| 729 | disable_irq_nosync(dev->hal_data->irq); |
| 730 | return rc; |
| 731 | } |
| 732 | |
| 733 | int vidc_hal_core_release(void *device) |
| 734 | { |
| 735 | struct hal_device *dev; |
| 736 | if (device) { |
| 737 | dev = device; |
| 738 | } else { |
Ashray Kulkarni | b673450 | 2012-08-24 13:00:22 -0700 | [diff] [blame] | 739 | dprintk(VIDC_ERR, "invalid device"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 740 | return -ENODEV; |
| 741 | } |
| 742 | write_register(dev->hal_data->register_base_addr, |
| 743 | VIDC_CPU_CS_SCIACMDARG3, 0, 0); |
Vinay Kalia | 40c3ae8 | 2012-07-09 15:23:02 -0700 | [diff] [blame] | 744 | disable_irq_nosync(dev->hal_data->irq); |
| 745 | vidc_hal_interface_queues_release(dev); |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 746 | dprintk(VIDC_INFO, "HAL exited\n"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 747 | return 0; |
| 748 | } |
| 749 | |
| 750 | int vidc_hal_core_pc_prep(void *device) |
| 751 | { |
| 752 | struct hfi_cmd_sys_pc_prep_packet pkt; |
| 753 | int rc = 0; |
| 754 | struct hal_device *dev; |
| 755 | |
| 756 | if (device) { |
| 757 | dev = device; |
| 758 | } else { |
Ashray Kulkarni | b673450 | 2012-08-24 13:00:22 -0700 | [diff] [blame] | 759 | dprintk(VIDC_ERR, "invalid device"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 760 | return -ENODEV; |
| 761 | } |
| 762 | pkt.size = sizeof(struct hfi_cmd_sys_pc_prep_packet); |
| 763 | pkt.packet_type = HFI_CMD_SYS_PC_PREP; |
| 764 | if (vidc_hal_iface_cmdq_write(dev, &pkt)) |
| 765 | rc = -ENOTEMPTY; |
| 766 | return rc; |
| 767 | } |
| 768 | |
| 769 | static void vidc_hal_core_clear_interrupt(struct hal_device *device) |
| 770 | { |
| 771 | u32 intr_status = 0; |
| 772 | |
| 773 | if (!device->callback) |
| 774 | return; |
| 775 | |
| 776 | intr_status = read_register( |
| 777 | device->hal_data->register_base_addr, |
| 778 | VIDC_WRAPPER_INTR_STATUS); |
| 779 | |
| 780 | if ((intr_status & VIDC_WRAPPER_INTR_STATUS_A2H_BMSK) || |
| 781 | (intr_status & VIDC_WRAPPER_INTR_STATUS_A2HWD_BMSK)) { |
| 782 | device->intr_status |= intr_status; |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 783 | dprintk(VIDC_DBG, "INTERRUPT for device: 0x%x: " |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 784 | "times: %d interrupt_status: %d", |
| 785 | (u32) device, ++device->reg_count, intr_status); |
| 786 | } else { |
Ashray Kulkarni | 000b382 | 2012-10-11 18:20:58 -0700 | [diff] [blame] | 787 | dprintk(VIDC_INFO, "SPURIOUS_INTR for device: 0x%x: " |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 788 | "times: %d interrupt_status: %d", |
| 789 | (u32) device, ++device->spur_count, intr_status); |
| 790 | } |
| 791 | write_register(device->hal_data->register_base_addr, |
| 792 | VIDC_CPU_CS_A2HSOFTINTCLR, 1, 0); |
| 793 | write_register(device->hal_data->register_base_addr, |
| 794 | VIDC_WRAPPER_INTR_CLEAR, intr_status, 0); |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 795 | dprintk(VIDC_DBG, "Cleared WRAPPER/A2H interrupt"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 796 | } |
| 797 | |
| 798 | int vidc_hal_core_set_resource(void *device, |
| 799 | struct vidc_resource_hdr *resource_hdr, void *resource_value) |
| 800 | { |
| 801 | struct hfi_cmd_sys_set_resource_packet *pkt; |
| 802 | u8 packet[VIDC_IFACEQ_VAR_SMALL_PKT_SIZE]; |
| 803 | int rc = 0; |
| 804 | struct hal_device *dev; |
| 805 | |
| 806 | if (!device || !resource_hdr || !resource_value) { |
Ashray Kulkarni | b673450 | 2012-08-24 13:00:22 -0700 | [diff] [blame] | 807 | dprintk(VIDC_ERR, "set_res: Invalid Params"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 808 | return -EINVAL; |
| 809 | } else { |
| 810 | dev = device; |
| 811 | } |
| 812 | |
| 813 | pkt = (struct hfi_cmd_sys_set_resource_packet *) packet; |
| 814 | |
| 815 | pkt->size = sizeof(struct hfi_cmd_sys_set_resource_packet); |
| 816 | pkt->packet_type = HFI_CMD_SYS_SET_RESOURCE; |
| 817 | pkt->resource_handle = resource_hdr->resource_handle; |
| 818 | |
| 819 | switch (resource_hdr->resource_id) { |
| 820 | case VIDC_RESOURCE_OCMEM: |
| 821 | { |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 822 | struct hfi_resource_ocmem *hfioc_mem = |
| 823 | (struct hfi_resource_ocmem *) |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 824 | &pkt->rg_resource_data[0]; |
Vinay Kalia | bc9f60a | 2012-07-17 01:23:42 -0700 | [diff] [blame] | 825 | struct ocmem_buf *ocmem = |
| 826 | (struct ocmem_buf *) resource_value; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 827 | |
| 828 | pkt->resource_type = HFI_RESOURCE_OCMEM; |
Vinay Kalia | bc9f60a | 2012-07-17 01:23:42 -0700 | [diff] [blame] | 829 | hfioc_mem->size = (u32) ocmem->len; |
| 830 | hfioc_mem->mem = (u8 *) ocmem->addr; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 831 | pkt->size += sizeof(struct hfi_resource_ocmem); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 832 | if (vidc_hal_iface_cmdq_write(dev, pkt)) |
| 833 | rc = -ENOTEMPTY; |
| 834 | break; |
| 835 | } |
| 836 | default: |
Ashray Kulkarni | b673450 | 2012-08-24 13:00:22 -0700 | [diff] [blame] | 837 | dprintk(VIDC_INFO, "Invalid res_id in set_res %d", |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 838 | resource_hdr->resource_id); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 839 | break; |
| 840 | } |
| 841 | return rc; |
| 842 | } |
| 843 | |
| 844 | int vidc_hal_core_release_resource(void *device, |
| 845 | struct vidc_resource_hdr *resource_hdr) |
| 846 | { |
| 847 | struct hfi_cmd_sys_release_resource_packet pkt; |
| 848 | int rc = 0; |
| 849 | struct hal_device *dev; |
| 850 | |
| 851 | if (!device || !resource_hdr) { |
Ashray Kulkarni | b673450 | 2012-08-24 13:00:22 -0700 | [diff] [blame] | 852 | dprintk(VIDC_ERR, "Inv-Params in rel_res"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 853 | return -EINVAL; |
| 854 | } else { |
| 855 | dev = device; |
| 856 | } |
| 857 | |
| 858 | pkt.size = sizeof(struct hfi_cmd_sys_release_resource_packet); |
| 859 | pkt.packet_type = HFI_CMD_SYS_RELEASE_RESOURCE; |
| 860 | pkt.resource_type = resource_hdr->resource_id; |
| 861 | pkt.resource_handle = resource_hdr->resource_handle; |
| 862 | |
| 863 | if (vidc_hal_iface_cmdq_write(dev, &pkt)) |
| 864 | rc = -ENOTEMPTY; |
| 865 | return rc; |
| 866 | } |
| 867 | |
| 868 | int vidc_hal_core_ping(void *device) |
| 869 | { |
| 870 | struct hfi_cmd_sys_ping_packet pkt; |
| 871 | int rc = 0; |
| 872 | struct hal_device *dev; |
| 873 | |
| 874 | if (device) { |
| 875 | dev = device; |
| 876 | } else { |
Ashray Kulkarni | b673450 | 2012-08-24 13:00:22 -0700 | [diff] [blame] | 877 | dprintk(VIDC_ERR, "invalid device"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 878 | return -ENODEV; |
| 879 | } |
| 880 | pkt.size = sizeof(struct hfi_cmd_sys_ping_packet); |
| 881 | pkt.packet_type = HFI_CMD_SYS_PING; |
| 882 | |
| 883 | if (vidc_hal_iface_cmdq_write(dev, &pkt)) |
| 884 | rc = -ENOTEMPTY; |
| 885 | return rc; |
| 886 | } |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 887 | static u32 get_hfi_buffer(int hal_buffer) |
| 888 | { |
| 889 | u32 buffer; |
| 890 | switch (hal_buffer) { |
| 891 | case HAL_BUFFER_INPUT: |
| 892 | buffer = HFI_BUFFER_INPUT; |
| 893 | break; |
| 894 | case HAL_BUFFER_OUTPUT: |
| 895 | buffer = HFI_BUFFER_OUTPUT; |
| 896 | break; |
| 897 | case HAL_BUFFER_OUTPUT2: |
| 898 | buffer = HFI_BUFFER_OUTPUT; |
| 899 | break; |
| 900 | case HAL_BUFFER_EXTRADATA_INPUT: |
| 901 | buffer = HFI_BUFFER_EXTRADATA_INPUT; |
| 902 | break; |
| 903 | case HAL_BUFFER_EXTRADATA_OUTPUT: |
| 904 | buffer = HFI_BUFFER_EXTRADATA_OUTPUT; |
| 905 | break; |
| 906 | case HAL_BUFFER_EXTRADATA_OUTPUT2: |
| 907 | buffer = HFI_BUFFER_EXTRADATA_OUTPUT2; |
| 908 | break; |
| 909 | case HAL_BUFFER_INTERNAL_SCRATCH: |
| 910 | buffer = HFI_BUFFER_INTERNAL_SCRATCH; |
| 911 | break; |
| 912 | case HAL_BUFFER_INTERNAL_PERSIST: |
| 913 | buffer = HFI_BUFFER_INTERNAL_PERSIST; |
| 914 | break; |
| 915 | default: |
Ashray Kulkarni | b673450 | 2012-08-24 13:00:22 -0700 | [diff] [blame] | 916 | dprintk(VIDC_ERR, "Invalid buffer :0x%x\n", |
| 917 | hal_buffer); |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 918 | buffer = 0; |
| 919 | break; |
| 920 | } |
| 921 | return buffer; |
| 922 | } |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 923 | int vidc_hal_session_set_property(void *sess, |
| 924 | enum hal_property ptype, void *pdata) |
| 925 | { |
| 926 | u8 packet[VIDC_IFACEQ_VAR_LARGE_PKT_SIZE]; |
| 927 | struct hfi_cmd_session_set_property_packet *pkt = |
| 928 | (struct hfi_cmd_session_set_property_packet *) &packet; |
| 929 | struct hal_session *session; |
| 930 | |
| 931 | if (!sess || !pdata) { |
Ashray Kulkarni | b673450 | 2012-08-24 13:00:22 -0700 | [diff] [blame] | 932 | dprintk(VIDC_ERR, "Invalid Params"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 933 | return -EINVAL; |
| 934 | } else { |
| 935 | session = sess; |
| 936 | } |
| 937 | |
Ashray Kulkarni | b673450 | 2012-08-24 13:00:22 -0700 | [diff] [blame] | 938 | dprintk(VIDC_INFO, "in set_prop,with prop id: 0x%x", ptype); |
Ashray Kulkarni | 1c72b39 | 2012-06-20 10:50:00 -0700 | [diff] [blame] | 939 | pkt->size = sizeof(struct hfi_cmd_session_set_property_packet); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 940 | pkt->packet_type = HFI_CMD_SESSION_SET_PROPERTY; |
| 941 | pkt->session_id = (u32) session; |
| 942 | pkt->num_properties = 1; |
| 943 | |
| 944 | switch (ptype) { |
| 945 | case HAL_CONFIG_FRAME_RATE: |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 946 | { |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 947 | struct hfi_frame_rate *hfi; |
| 948 | u32 buffer; |
| 949 | struct hal_frame_rate *prop = |
| 950 | (struct hal_frame_rate *) pdata; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 951 | pkt->rg_property_data[0] = HFI_PROPERTY_CONFIG_FRAME_RATE; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 952 | hfi = (struct hfi_frame_rate *) &pkt->rg_property_data[1]; |
| 953 | buffer = get_hfi_buffer(prop->buffer_type); |
| 954 | if (buffer) |
| 955 | hfi->buffer_type = buffer; |
| 956 | else |
| 957 | return -EINVAL; |
| 958 | hfi->frame_rate = prop->frame_rate; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 959 | pkt->size += sizeof(u32) + sizeof(struct hfi_frame_rate); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 960 | break; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 961 | } |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 962 | case HAL_PARAM_UNCOMPRESSED_FORMAT_SELECT: |
| 963 | { |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 964 | u32 buffer; |
| 965 | struct hfi_uncompressed_format_select *hfi; |
| 966 | struct hal_uncompressed_format_select *prop = |
| 967 | (struct hal_uncompressed_format_select *) pdata; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 968 | pkt->rg_property_data[0] = |
| 969 | HFI_PROPERTY_PARAM_UNCOMPRESSED_FORMAT_SELECT; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 970 | hfi = (struct hfi_uncompressed_format_select *) |
| 971 | &pkt->rg_property_data[1]; |
| 972 | buffer = get_hfi_buffer(prop->buffer_type); |
| 973 | if (buffer) |
| 974 | hfi->buffer_type = buffer; |
| 975 | else |
| 976 | return -EINVAL; |
| 977 | hfi->format = prop->format; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 978 | pkt->size += sizeof(u32) + sizeof(struct |
| 979 | hfi_uncompressed_format_select); |
| 980 | break; |
| 981 | } |
| 982 | case HAL_PARAM_UNCOMPRESSED_PLANE_ACTUAL_CONSTRAINTS_INFO: |
| 983 | break; |
| 984 | case HAL_PARAM_UNCOMPRESSED_PLANE_ACTUAL_INFO: |
| 985 | break; |
| 986 | case HAL_PARAM_EXTRA_DATA_HEADER_CONFIG: |
| 987 | break; |
| 988 | case HAL_PARAM_FRAME_SIZE: |
| 989 | { |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 990 | u32 buffer; |
| 991 | struct hfi_frame_size *hfi; |
| 992 | struct hal_frame_size *prop = (struct hal_frame_size *) pdata; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 993 | pkt->rg_property_data[0] = HFI_PROPERTY_PARAM_FRAME_SIZE; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 994 | hfi = (struct hfi_frame_size *) &pkt->rg_property_data[1]; |
| 995 | buffer = get_hfi_buffer(prop->buffer_type); |
| 996 | if (buffer) |
| 997 | hfi->buffer_type = buffer; |
| 998 | else |
| 999 | return -EINVAL; |
| 1000 | hfi->height = prop->height; |
| 1001 | hfi->width = prop->width; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1002 | pkt->size += sizeof(u32) + sizeof(struct hfi_frame_size); |
| 1003 | break; |
| 1004 | } |
| 1005 | case HAL_CONFIG_REALTIME: |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1006 | { |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1007 | struct hfi_enable *hfi; |
| 1008 | pkt->rg_property_data[0] = HFI_PROPERTY_CONFIG_REALTIME; |
| 1009 | hfi = (struct hfi_enable *) &pkt->rg_property_data[1]; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1010 | hfi->enable = ((struct hfi_enable *) pdata)->enable; |
| 1011 | pkt->size += sizeof(u32) * 2; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1012 | break; |
| 1013 | } |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1014 | case HAL_PARAM_BUFFER_COUNT_ACTUAL: |
| 1015 | { |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1016 | u32 buffer; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1017 | struct hfi_buffer_count_actual *hfi; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1018 | struct hal_buffer_count_actual *prop = |
| 1019 | (struct hal_buffer_count_actual *) pdata; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1020 | pkt->rg_property_data[0] = |
| 1021 | HFI_PROPERTY_PARAM_BUFFER_COUNT_ACTUAL; |
| 1022 | hfi = (struct hfi_buffer_count_actual *) |
| 1023 | &pkt->rg_property_data[1]; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1024 | hfi->buffer_count_actual = prop->buffer_count_actual; |
| 1025 | buffer = get_hfi_buffer(prop->buffer_type); |
| 1026 | if (buffer) |
| 1027 | hfi->buffer_type = buffer; |
| 1028 | else |
| 1029 | return -EINVAL; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1030 | pkt->size += sizeof(u32) + sizeof(struct |
| 1031 | hfi_buffer_count_actual); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1032 | break; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1033 | } |
| 1034 | case HAL_PARAM_NAL_STREAM_FORMAT_SELECT: |
| 1035 | { |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1036 | struct hal_nal_stream_format_supported *prop = |
| 1037 | (struct hal_nal_stream_format_supported *)pdata; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1038 | pkt->rg_property_data[0] = |
| 1039 | HFI_PROPERTY_PARAM_NAL_STREAM_FORMAT_SELECT; |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 1040 | dprintk(VIDC_DBG, "data is :%d", |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1041 | prop->nal_stream_format_supported); |
| 1042 | switch (prop->nal_stream_format_supported) { |
| 1043 | case HAL_NAL_FORMAT_STARTCODES: |
| 1044 | pkt->rg_property_data[1] = |
| 1045 | HFI_NAL_FORMAT_STARTCODES; |
| 1046 | break; |
| 1047 | case HAL_NAL_FORMAT_ONE_NAL_PER_BUFFER: |
| 1048 | pkt->rg_property_data[1] = |
| 1049 | HFI_NAL_FORMAT_ONE_NAL_PER_BUFFER; |
| 1050 | break; |
| 1051 | case HAL_NAL_FORMAT_ONE_BYTE_LENGTH: |
| 1052 | pkt->rg_property_data[1] = |
| 1053 | HFI_NAL_FORMAT_ONE_BYTE_LENGTH; |
| 1054 | break; |
| 1055 | case HAL_NAL_FORMAT_TWO_BYTE_LENGTH: |
| 1056 | pkt->rg_property_data[1] = |
| 1057 | HFI_NAL_FORMAT_TWO_BYTE_LENGTH; |
| 1058 | break; |
| 1059 | case HAL_NAL_FORMAT_FOUR_BYTE_LENGTH: |
| 1060 | pkt->rg_property_data[1] = |
| 1061 | HFI_NAL_FORMAT_FOUR_BYTE_LENGTH; |
| 1062 | break; |
| 1063 | default: |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 1064 | dprintk(VIDC_ERR, "Invalid nal format: 0x%x", |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1065 | prop->nal_stream_format_supported); |
| 1066 | break; |
| 1067 | } |
| 1068 | pkt->size += sizeof(u32) * 2; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1069 | break; |
| 1070 | } |
| 1071 | case HAL_PARAM_VDEC_OUTPUT_ORDER: |
| 1072 | { |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1073 | int *data = (int *) pdata; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1074 | pkt->rg_property_data[0] = |
| 1075 | HFI_PROPERTY_PARAM_VDEC_OUTPUT_ORDER; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1076 | switch (*data) { |
| 1077 | case HAL_OUTPUT_ORDER_DECODE: |
Ashray Kulkarni | 995fd27 | 2012-07-02 12:57:55 -0700 | [diff] [blame] | 1078 | pkt->rg_property_data[1] = HFI_OUTPUT_ORDER_DECODE; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1079 | break; |
| 1080 | case HAL_OUTPUT_ORDER_DISPLAY: |
Ashray Kulkarni | 995fd27 | 2012-07-02 12:57:55 -0700 | [diff] [blame] | 1081 | pkt->rg_property_data[1] = HFI_OUTPUT_ORDER_DISPLAY; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1082 | break; |
| 1083 | default: |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 1084 | dprintk(VIDC_ERR, "invalid output order: 0x%x", |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1085 | *data); |
| 1086 | break; |
| 1087 | } |
| 1088 | pkt->size += sizeof(u32) * 2; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1089 | break; |
| 1090 | } |
| 1091 | case HAL_PARAM_VDEC_PICTURE_TYPE_DECODE: |
| 1092 | { |
| 1093 | struct hfi_enable_picture *hfi; |
| 1094 | pkt->rg_property_data[0] = |
| 1095 | HFI_PROPERTY_PARAM_VDEC_PICTURE_TYPE_DECODE; |
| 1096 | hfi = (struct hfi_enable_picture *) &pkt->rg_property_data[1]; |
| 1097 | hfi->picture_type = (u32) pdata; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1098 | pkt->size += sizeof(u32) * 2; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1099 | break; |
| 1100 | } |
| 1101 | case HAL_PARAM_VDEC_OUTPUT2_KEEP_ASPECT_RATIO: |
| 1102 | { |
| 1103 | struct hfi_enable *hfi; |
| 1104 | pkt->rg_property_data[0] = |
| 1105 | HFI_PROPERTY_PARAM_VDEC_OUTPUT2_KEEP_ASPECT_RATIO; |
| 1106 | hfi = (struct hfi_enable *) &pkt->rg_property_data[1]; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1107 | hfi->enable = ((struct hfi_enable *) pdata)->enable; |
| 1108 | pkt->size += sizeof(u32) * 2; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1109 | break; |
| 1110 | } |
| 1111 | case HAL_CONFIG_VDEC_POST_LOOP_DEBLOCKER: |
| 1112 | { |
| 1113 | struct hfi_enable *hfi; |
| 1114 | pkt->rg_property_data[0] = |
| 1115 | HFI_PROPERTY_CONFIG_VDEC_POST_LOOP_DEBLOCKER; |
| 1116 | hfi = (struct hfi_enable *) &pkt->rg_property_data[1]; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1117 | hfi->enable = ((struct hfi_enable *) pdata)->enable; |
| 1118 | pkt->size += sizeof(u32) * 2; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1119 | break; |
| 1120 | } |
| 1121 | case HAL_PARAM_VDEC_MULTI_STREAM: |
| 1122 | { |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1123 | u32 buffer; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1124 | struct hfi_multi_stream *hfi; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1125 | struct hal_multi_stream *prop = |
| 1126 | (struct hal_multi_stream *) pdata; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1127 | pkt->rg_property_data[0] = |
| 1128 | HFI_PROPERTY_PARAM_VDEC_MULTI_STREAM; |
| 1129 | hfi = (struct hfi_multi_stream *) &pkt->rg_property_data[1]; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1130 | buffer = get_hfi_buffer(prop->buffer_type); |
| 1131 | if (buffer) |
| 1132 | hfi->buffer_type = buffer; |
| 1133 | else |
| 1134 | return -EINVAL; |
| 1135 | hfi->enable = prop->enable; |
| 1136 | hfi->width = prop->width; |
| 1137 | hfi->height = prop->height; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1138 | pkt->size += sizeof(u32) + sizeof(struct hfi_multi_stream); |
| 1139 | break; |
| 1140 | } |
| 1141 | case HAL_PARAM_VDEC_DISPLAY_PICTURE_BUFFER_COUNT: |
| 1142 | { |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1143 | struct hfi_display_picture_buffer_count *hfi; |
| 1144 | struct hal_display_picture_buffer_count *prop = |
| 1145 | (struct hal_display_picture_buffer_count *) pdata; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1146 | pkt->rg_property_data[0] = |
| 1147 | HFI_PROPERTY_PARAM_VDEC_DISPLAY_PICTURE_BUFFER_COUNT; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1148 | hfi = (struct hfi_display_picture_buffer_count *) |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1149 | &pkt->rg_property_data[1]; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1150 | hfi->count = prop->count; |
| 1151 | hfi->enable = prop->enable; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1152 | pkt->size += sizeof(u32) + |
| 1153 | sizeof(struct hfi_display_picture_buffer_count); |
| 1154 | break; |
| 1155 | } |
| 1156 | case HAL_PARAM_DIVX_FORMAT: |
| 1157 | { |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1158 | int *data = pdata; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1159 | pkt->rg_property_data[0] = HFI_PROPERTY_PARAM_DIVX_FORMAT; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1160 | switch (*data) { |
| 1161 | case HAL_DIVX_FORMAT_4: |
| 1162 | pkt->rg_property_data[1] = HFI_DIVX_FORMAT_4; |
| 1163 | break; |
| 1164 | case HAL_DIVX_FORMAT_5: |
| 1165 | pkt->rg_property_data[1] = HFI_DIVX_FORMAT_5; |
| 1166 | break; |
| 1167 | case HAL_DIVX_FORMAT_6: |
| 1168 | pkt->rg_property_data[1] = HFI_DIVX_FORMAT_6; |
| 1169 | break; |
| 1170 | default: |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 1171 | dprintk(VIDC_ERR, "Invalid divx format: 0x%x", *data); |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1172 | break; |
| 1173 | } |
| 1174 | pkt->size += sizeof(u32) * 2; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1175 | break; |
| 1176 | } |
| 1177 | case HAL_CONFIG_VDEC_MB_ERROR_MAP_REPORTING: |
| 1178 | { |
| 1179 | struct hfi_enable *hfi; |
| 1180 | pkt->rg_property_data[0] = |
| 1181 | HFI_PROPERTY_CONFIG_VDEC_MB_ERROR_MAP_REPORTING; |
| 1182 | hfi = (struct hfi_enable *) &pkt->rg_property_data[1]; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1183 | hfi->enable = ((struct hfi_enable *) pdata)->enable; |
| 1184 | pkt->size += sizeof(u32) * 2; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1185 | break; |
| 1186 | } |
| 1187 | case HAL_PARAM_VDEC_CONTINUE_DATA_TRANSFER: |
| 1188 | { |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1189 | struct hfi_enable *hfi; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1190 | pkt->rg_property_data[0] = |
| 1191 | HFI_PROPERTY_PARAM_VDEC_CONTINUE_DATA_TRANSFER; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1192 | hfi = (struct hfi_enable *) &pkt->rg_property_data[1]; |
| 1193 | hfi->enable = ((struct hfi_enable *) pdata)->enable; |
| 1194 | pkt->size += sizeof(u32) * 2; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1195 | break; |
| 1196 | } |
Praneeth Paladugu | 131aaac | 2012-10-16 17:30:22 -0700 | [diff] [blame] | 1197 | case HAL_PARAM_VDEC_SYNC_FRAME_DECODE: |
| 1198 | { |
| 1199 | struct hfi_enable *hfi; |
| 1200 | pkt->rg_property_data[0] = |
| 1201 | HFI_PROPERTY_PARAM_VDEC_THUMBNAIL_MODE; |
| 1202 | hfi = (struct hfi_enable *) &pkt->rg_property_data[1]; |
| 1203 | hfi->enable = ((struct hfi_enable *) pdata)->enable; |
| 1204 | pkt->size += sizeof(u32) * 2; |
| 1205 | break; |
| 1206 | } |
Ashray Kulkarni | 8c5f34f | 2012-09-14 17:13:38 -0700 | [diff] [blame] | 1207 | case HAL_PARAM_VENC_SYNC_FRAME_SEQUENCE_HEADER: |
| 1208 | { |
| 1209 | struct hfi_enable *hfi; |
| 1210 | pkt->rg_property_data[0] = |
| 1211 | HFI_PROPERTY_PARAM_VENC_SYNC_FRAME_SEQUENCE_HEADER; |
| 1212 | hfi = (struct hfi_enable *) &pkt->rg_property_data[1]; |
| 1213 | hfi->enable = ((struct hfi_enable *) pdata)->enable; |
| 1214 | pkt->size += sizeof(u32) * 2; |
| 1215 | break; |
| 1216 | } |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1217 | case HAL_CONFIG_VENC_REQUEST_IFRAME: |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1218 | pkt->rg_property_data[0] = |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1219 | HFI_PROPERTY_CONFIG_VENC_REQUEST_SYNC_FRAME; |
Praneeth Paladugu | 951c02d | 2012-07-11 12:19:42 -0700 | [diff] [blame] | 1220 | pkt->size += sizeof(u32); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1221 | break; |
| 1222 | case HAL_PARAM_VENC_MPEG4_SHORT_HEADER: |
| 1223 | break; |
| 1224 | case HAL_PARAM_VENC_MPEG4_AC_PREDICTION: |
| 1225 | break; |
| 1226 | case HAL_CONFIG_VENC_TARGET_BITRATE: |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1227 | { |
| 1228 | struct hfi_bitrate *hfi; |
| 1229 | pkt->rg_property_data[0] = |
| 1230 | HFI_PROPERTY_CONFIG_VENC_TARGET_BITRATE; |
| 1231 | hfi = (struct hfi_bitrate *) &pkt->rg_property_data[1]; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1232 | hfi->bit_rate = ((struct hal_bitrate *)pdata)->bit_rate; |
| 1233 | pkt->size += sizeof(u32) * 2; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1234 | break; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1235 | } |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1236 | case HAL_PARAM_PROFILE_LEVEL_CURRENT: |
| 1237 | { |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1238 | struct hfi_profile_level *hfi; |
| 1239 | struct hal_profile_level *prop = |
| 1240 | (struct hal_profile_level *) pdata; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1241 | pkt->rg_property_data[0] = |
| 1242 | HFI_PROPERTY_PARAM_PROFILE_LEVEL_CURRENT; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1243 | hfi = (struct hfi_profile_level *) |
| 1244 | &pkt->rg_property_data[1]; |
| 1245 | hfi->level = (u32) prop->level; |
| 1246 | hfi->profile = prop->profile; |
| 1247 | if (!hfi->profile) |
| 1248 | hfi->profile = HFI_H264_PROFILE_HIGH; |
| 1249 | if (!hfi->level) |
| 1250 | hfi->level = 1; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1251 | pkt->size += sizeof(u32) + sizeof(struct hfi_profile_level); |
| 1252 | break; |
| 1253 | } |
| 1254 | case HAL_PARAM_VENC_H264_ENTROPY_CONTROL: |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1255 | { |
| 1256 | struct hfi_h264_entropy_control *hfi; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1257 | struct hal_h264_entropy_control *prop = |
| 1258 | (struct hal_h264_entropy_control *) pdata; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1259 | pkt->rg_property_data[0] = |
| 1260 | HFI_PROPERTY_PARAM_VENC_H264_ENTROPY_CONTROL; |
| 1261 | hfi = (struct hfi_h264_entropy_control *) |
| 1262 | &pkt->rg_property_data[1]; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1263 | switch (prop->entropy_mode) { |
| 1264 | case HAL_H264_ENTROPY_CAVLC: |
| 1265 | hfi->cabac_model = HFI_H264_ENTROPY_CAVLC; |
| 1266 | break; |
| 1267 | case HAL_H264_ENTROPY_CABAC: |
| 1268 | hfi->cabac_model = HFI_H264_ENTROPY_CABAC; |
| 1269 | switch (prop->cabac_model) { |
| 1270 | case HAL_H264_CABAC_MODEL_0: |
| 1271 | hfi->cabac_model = HFI_H264_CABAC_MODEL_0; |
| 1272 | break; |
| 1273 | case HAL_H264_CABAC_MODEL_1: |
| 1274 | hfi->cabac_model = HFI_H264_CABAC_MODEL_1; |
| 1275 | break; |
| 1276 | case HAL_H264_CABAC_MODEL_2: |
| 1277 | hfi->cabac_model = HFI_H264_CABAC_MODEL_2; |
| 1278 | break; |
| 1279 | default: |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 1280 | dprintk(VIDC_ERR, |
| 1281 | "Invalid cabac model 0x%x", |
| 1282 | prop->entropy_mode); |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1283 | break; |
| 1284 | } |
| 1285 | break; |
| 1286 | default: |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 1287 | dprintk(VIDC_ERR, |
| 1288 | "Invalid entropy selected: 0x%x", |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1289 | prop->cabac_model); |
| 1290 | break; |
| 1291 | } |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1292 | pkt->size += sizeof(u32) + sizeof( |
| 1293 | struct hfi_h264_entropy_control); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1294 | break; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1295 | } |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1296 | case HAL_PARAM_VENC_RATE_CONTROL: |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1297 | { |
Ashray Kulkarni | b673450 | 2012-08-24 13:00:22 -0700 | [diff] [blame] | 1298 | u32 *rc; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1299 | pkt->rg_property_data[0] = |
| 1300 | HFI_PROPERTY_PARAM_VENC_RATE_CONTROL; |
Ashray Kulkarni | b673450 | 2012-08-24 13:00:22 -0700 | [diff] [blame] | 1301 | rc = (u32 *)pdata; |
| 1302 | switch ((enum hal_rate_control) *rc) { |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1303 | case HAL_RATE_CONTROL_OFF: |
| 1304 | pkt->rg_property_data[1] = HFI_RATE_CONTROL_OFF; |
| 1305 | break; |
| 1306 | case HAL_RATE_CONTROL_CBR_CFR: |
| 1307 | pkt->rg_property_data[1] = HFI_RATE_CONTROL_CBR_CFR; |
| 1308 | break; |
| 1309 | case HAL_RATE_CONTROL_CBR_VFR: |
| 1310 | pkt->rg_property_data[1] = HFI_RATE_CONTROL_CBR_VFR; |
| 1311 | break; |
| 1312 | case HAL_RATE_CONTROL_VBR_CFR: |
| 1313 | pkt->rg_property_data[1] = HFI_RATE_CONTROL_VBR_CFR; |
| 1314 | break; |
| 1315 | case HAL_RATE_CONTROL_VBR_VFR: |
| 1316 | pkt->rg_property_data[1] = HFI_RATE_CONTROL_VBR_VFR; |
| 1317 | break; |
| 1318 | default: |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 1319 | dprintk(VIDC_ERR, "Invalid Rate control setting: 0x%x", |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1320 | (int) pdata); |
| 1321 | break; |
| 1322 | } |
| 1323 | pkt->size += sizeof(u32) * 2; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1324 | break; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1325 | } |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1326 | case HAL_PARAM_VENC_MPEG4_TIME_RESOLUTION: |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1327 | { |
| 1328 | struct hfi_mpeg4_time_resolution *hfi; |
| 1329 | pkt->rg_property_data[0] = |
| 1330 | HFI_PROPERTY_PARAM_VENC_MPEG4_TIME_RESOLUTION; |
| 1331 | hfi = (struct hfi_mpeg4_time_resolution *) |
| 1332 | &pkt->rg_property_data[1]; |
| 1333 | hfi->time_increment_resolution = |
| 1334 | ((struct hal_mpeg4_time_resolution *)pdata)-> |
| 1335 | time_increment_resolution; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1336 | pkt->size += sizeof(u32) * 2; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1337 | break; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1338 | } |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1339 | case HAL_PARAM_VENC_MPEG4_HEADER_EXTENSION: |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1340 | { |
| 1341 | struct hfi_mpeg4_header_extension *hfi; |
| 1342 | pkt->rg_property_data[0] = |
| 1343 | HFI_PROPERTY_PARAM_VENC_MPEG4_HEADER_EXTENSION; |
| 1344 | hfi = (struct hfi_mpeg4_header_extension *) |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1345 | &pkt->rg_property_data[1]; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1346 | hfi->header_extension = (u32) pdata; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1347 | pkt->size += sizeof(u32) * 2; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1348 | break; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1349 | } |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1350 | case HAL_PARAM_VENC_H264_DEBLOCK_CONTROL: |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1351 | { |
| 1352 | struct hfi_h264_db_control *hfi; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1353 | struct hal_h264_db_control *prop = |
| 1354 | (struct hal_h264_db_control *) pdata; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1355 | pkt->rg_property_data[0] = |
| 1356 | HFI_PROPERTY_PARAM_VENC_H264_DEBLOCK_CONTROL; |
| 1357 | hfi = (struct hfi_h264_db_control *) &pkt->rg_property_data[1]; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1358 | switch (prop->mode) { |
| 1359 | case HAL_H264_DB_MODE_DISABLE: |
| 1360 | hfi->mode = HFI_H264_DB_MODE_DISABLE; |
| 1361 | break; |
| 1362 | case HAL_H264_DB_MODE_SKIP_SLICE_BOUNDARY: |
| 1363 | hfi->mode = HFI_H264_DB_MODE_SKIP_SLICE_BOUNDARY; |
| 1364 | break; |
| 1365 | case HAL_H264_DB_MODE_ALL_BOUNDARY: |
| 1366 | hfi->mode = HFI_H264_DB_MODE_ALL_BOUNDARY; |
| 1367 | break; |
| 1368 | default: |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 1369 | dprintk(VIDC_ERR, "Invalid deblocking mode: 0x%x", |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1370 | prop->mode); |
| 1371 | break; |
| 1372 | } |
| 1373 | hfi->slice_alpha_offset = prop->slice_alpha_offset; |
| 1374 | hfi->slice_beta_offset = prop->slice_beta_offset; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1375 | pkt->size += sizeof(u32) + |
| 1376 | sizeof(struct hfi_h264_db_control); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1377 | break; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1378 | } |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1379 | case HAL_PARAM_VENC_SESSION_QP: |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1380 | { |
| 1381 | struct hfi_quantization *hfi; |
| 1382 | pkt->rg_property_data[0] = |
| 1383 | HFI_PROPERTY_PARAM_VENC_SESSION_QP; |
| 1384 | hfi = (struct hfi_quantization *) &pkt->rg_property_data[1]; |
| 1385 | memcpy(hfi, (struct hfi_quantization *) pdata, |
| 1386 | sizeof(struct hfi_quantization)); |
| 1387 | pkt->size += sizeof(u32) + sizeof(struct hfi_quantization); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1388 | break; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1389 | } |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1390 | case HAL_CONFIG_VENC_INTRA_PERIOD: |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1391 | { |
| 1392 | struct hfi_intra_period *hfi; |
| 1393 | pkt->rg_property_data[0] = |
| 1394 | HFI_PROPERTY_CONFIG_VENC_INTRA_PERIOD; |
| 1395 | hfi = (struct hfi_intra_period *) &pkt->rg_property_data[1]; |
| 1396 | memcpy(hfi, (struct hfi_intra_period *) pdata, |
| 1397 | sizeof(struct hfi_intra_period)); |
| 1398 | pkt->size += sizeof(u32) + sizeof(struct hfi_intra_period); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1399 | break; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1400 | } |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1401 | case HAL_CONFIG_VENC_IDR_PERIOD: |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1402 | { |
| 1403 | struct hfi_idr_period *hfi; |
| 1404 | pkt->rg_property_data[0] = HFI_PROPERTY_CONFIG_VENC_IDR_PERIOD; |
| 1405 | hfi = (struct hfi_idr_period *) &pkt->rg_property_data[1]; |
| 1406 | hfi->idr_period = ((struct hfi_idr_period *) pdata)->idr_period; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1407 | pkt->size += sizeof(u32) * 2; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1408 | break; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1409 | } |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1410 | case HAL_CONFIG_VPE_OPERATIONS: |
| 1411 | break; |
| 1412 | case HAL_PARAM_VENC_INTRA_REFRESH: |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1413 | { |
| 1414 | struct hfi_intra_refresh *hfi; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1415 | struct hal_intra_refresh *prop = |
| 1416 | (struct hal_intra_refresh *) pdata; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1417 | pkt->rg_property_data[0] = |
| 1418 | HFI_PROPERTY_PARAM_VENC_INTRA_REFRESH; |
| 1419 | hfi = (struct hfi_intra_refresh *) &pkt->rg_property_data[1]; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1420 | switch (prop->mode) { |
| 1421 | case HAL_INTRA_REFRESH_NONE: |
| 1422 | hfi->mode = HFI_INTRA_REFRESH_NONE; |
| 1423 | break; |
| 1424 | case HAL_INTRA_REFRESH_ADAPTIVE: |
| 1425 | hfi->mode = HFI_INTRA_REFRESH_ADAPTIVE; |
| 1426 | break; |
| 1427 | case HAL_INTRA_REFRESH_CYCLIC: |
| 1428 | hfi->mode = HFI_INTRA_REFRESH_CYCLIC; |
| 1429 | break; |
| 1430 | case HAL_INTRA_REFRESH_CYCLIC_ADAPTIVE: |
| 1431 | hfi->mode = HFI_INTRA_REFRESH_CYCLIC_ADAPTIVE; |
| 1432 | break; |
| 1433 | case HAL_INTRA_REFRESH_RANDOM: |
| 1434 | hfi->mode = HFI_INTRA_REFRESH_RANDOM; |
| 1435 | break; |
| 1436 | default: |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 1437 | dprintk(VIDC_ERR, "Invalid intra refresh setting: 0x%x", |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1438 | prop->mode); |
| 1439 | break; |
| 1440 | } |
| 1441 | hfi->air_mbs = prop->air_mbs; |
| 1442 | hfi->air_ref = prop->air_ref; |
| 1443 | hfi->cir_mbs = prop->cir_mbs; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1444 | pkt->size += sizeof(u32) + sizeof(struct hfi_intra_refresh); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1445 | break; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1446 | } |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1447 | case HAL_PARAM_VENC_MULTI_SLICE_CONTROL: |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1448 | { |
| 1449 | struct hfi_multi_slice_control *hfi; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1450 | struct hal_multi_slice_control *prop = |
| 1451 | (struct hal_multi_slice_control *) pdata; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1452 | pkt->rg_property_data[0] = |
| 1453 | HFI_PROPERTY_PARAM_VENC_MULTI_SLICE_CONTROL; |
| 1454 | hfi = (struct hfi_multi_slice_control *) |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1455 | &pkt->rg_property_data[1]; |
| 1456 | switch (prop->multi_slice) { |
| 1457 | case HAL_MULTI_SLICE_OFF: |
| 1458 | hfi->multi_slice = HFI_MULTI_SLICE_OFF; |
| 1459 | break; |
| 1460 | case HAL_MULTI_SLICE_GOB: |
| 1461 | hfi->multi_slice = HFI_MULTI_SLICE_GOB; |
| 1462 | break; |
| 1463 | case HAL_MULTI_SLICE_BY_MB_COUNT: |
| 1464 | hfi->multi_slice = HFI_MULTI_SLICE_BY_MB_COUNT; |
| 1465 | break; |
| 1466 | case HAL_MULTI_SLICE_BY_BYTE_COUNT: |
| 1467 | hfi->multi_slice = HFI_MULTI_SLICE_BY_BYTE_COUNT; |
| 1468 | break; |
| 1469 | default: |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 1470 | dprintk(VIDC_ERR, "Invalid slice settings: 0x%x", |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1471 | prop->multi_slice); |
| 1472 | break; |
| 1473 | } |
Ashray Kulkarni | 6a8803f | 2012-10-09 18:41:49 -0700 | [diff] [blame] | 1474 | hfi->slice_size = prop->slice_size; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1475 | pkt->size += sizeof(u32) + sizeof(struct |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1476 | hfi_multi_slice_control); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1477 | break; |
Ashray Kulkarni | 1ccbc91 | 2012-03-23 16:26:52 -0700 | [diff] [blame] | 1478 | } |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1479 | case HAL_CONFIG_VPE_DEINTERLACE: |
| 1480 | break; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1481 | /* FOLLOWING PROPERTIES ARE NOT IMPLEMENTED IN CORE YET */ |
| 1482 | case HAL_CONFIG_BUFFER_REQUIREMENTS: |
| 1483 | case HAL_CONFIG_PRIORITY: |
| 1484 | case HAL_CONFIG_BATCH_INFO: |
| 1485 | case HAL_PARAM_METADATA_PASS_THROUGH: |
| 1486 | case HAL_SYS_IDLE_INDICATOR: |
| 1487 | case HAL_PARAM_UNCOMPRESSED_FORMAT_SUPPORTED: |
| 1488 | case HAL_PARAM_INTERLACE_FORMAT_SUPPORTED: |
| 1489 | case HAL_PARAM_CHROMA_SITE: |
| 1490 | case HAL_PARAM_PROPERTIES_SUPPORTED: |
| 1491 | case HAL_PARAM_PROFILE_LEVEL_SUPPORTED: |
| 1492 | case HAL_PARAM_CAPABILITY_SUPPORTED: |
| 1493 | case HAL_PARAM_NAL_STREAM_FORMAT_SUPPORTED: |
| 1494 | case HAL_PARAM_MULTI_VIEW_FORMAT: |
| 1495 | case HAL_PARAM_MAX_SEQUENCE_HEADER_SIZE: |
| 1496 | case HAL_PARAM_CODEC_SUPPORTED: |
| 1497 | case HAL_PARAM_VDEC_MULTI_VIEW_SELECT: |
| 1498 | case HAL_PARAM_VDEC_MB_QUANTIZATION: |
| 1499 | case HAL_PARAM_VDEC_NUM_CONCEALED_MB: |
| 1500 | case HAL_PARAM_VDEC_H264_ENTROPY_SWITCHING: |
| 1501 | case HAL_PARAM_VENC_SLICE_DELIVERY_MODE: |
| 1502 | case HAL_PARAM_VENC_MPEG4_DATA_PARTITIONING: |
| 1503 | |
| 1504 | case HAL_CONFIG_BUFFER_COUNT_ACTUAL: |
| 1505 | case HAL_CONFIG_VDEC_MULTI_STREAM: |
| 1506 | case HAL_PARAM_VENC_MULTI_SLICE_INFO: |
| 1507 | case HAL_CONFIG_VENC_TIMESTAMP_SCALE: |
| 1508 | case HAL_PARAM_VENC_LOW_LATENCY: |
| 1509 | default: |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 1510 | dprintk(VIDC_INFO, "DEFAULT: Calling 0x%x", ptype); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1511 | break; |
| 1512 | } |
| 1513 | if (vidc_hal_iface_cmdq_write(session->device, pkt)) |
| 1514 | return -ENOTEMPTY; |
| 1515 | return 0; |
| 1516 | } |
| 1517 | |
| 1518 | int vidc_hal_session_get_property(void *sess, |
| 1519 | enum hal_property ptype, void *pdata) |
| 1520 | { |
| 1521 | struct hal_session *session; |
| 1522 | |
| 1523 | if (!sess || !pdata) { |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 1524 | dprintk(VIDC_ERR, "Invalid Params in "); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1525 | return -EINVAL; |
| 1526 | } else { |
| 1527 | session = sess; |
| 1528 | } |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 1529 | dprintk(VIDC_INFO, "IN func: , with property id: %d", ptype); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1530 | |
| 1531 | switch (ptype) { |
| 1532 | case HAL_CONFIG_FRAME_RATE: |
| 1533 | break; |
| 1534 | case HAL_PARAM_UNCOMPRESSED_FORMAT_SELECT: |
| 1535 | break; |
| 1536 | case HAL_PARAM_UNCOMPRESSED_PLANE_ACTUAL_CONSTRAINTS_INFO: |
| 1537 | break; |
| 1538 | case HAL_PARAM_UNCOMPRESSED_PLANE_ACTUAL_INFO: |
| 1539 | break; |
| 1540 | case HAL_PARAM_EXTRA_DATA_HEADER_CONFIG: |
| 1541 | break; |
| 1542 | case HAL_PARAM_FRAME_SIZE: |
| 1543 | break; |
| 1544 | case HAL_CONFIG_REALTIME: |
| 1545 | break; |
| 1546 | case HAL_PARAM_BUFFER_COUNT_ACTUAL: |
| 1547 | break; |
| 1548 | case HAL_PARAM_NAL_STREAM_FORMAT_SELECT: |
| 1549 | break; |
| 1550 | case HAL_PARAM_VDEC_OUTPUT_ORDER: |
| 1551 | break; |
| 1552 | case HAL_PARAM_VDEC_PICTURE_TYPE_DECODE: |
| 1553 | break; |
| 1554 | case HAL_PARAM_VDEC_OUTPUT2_KEEP_ASPECT_RATIO: |
| 1555 | break; |
| 1556 | case HAL_CONFIG_VDEC_POST_LOOP_DEBLOCKER: |
| 1557 | break; |
| 1558 | case HAL_PARAM_VDEC_MULTI_STREAM: |
| 1559 | break; |
| 1560 | case HAL_PARAM_VDEC_DISPLAY_PICTURE_BUFFER_COUNT: |
| 1561 | break; |
| 1562 | case HAL_PARAM_DIVX_FORMAT: |
| 1563 | break; |
| 1564 | case HAL_CONFIG_VDEC_MB_ERROR_MAP_REPORTING: |
| 1565 | break; |
| 1566 | case HAL_PARAM_VDEC_CONTINUE_DATA_TRANSFER: |
| 1567 | break; |
| 1568 | case HAL_CONFIG_VDEC_MB_ERROR_MAP: |
| 1569 | break; |
| 1570 | case HAL_CONFIG_VENC_REQUEST_IFRAME: |
| 1571 | break; |
| 1572 | case HAL_PARAM_VENC_MPEG4_SHORT_HEADER: |
| 1573 | break; |
| 1574 | case HAL_PARAM_VENC_MPEG4_AC_PREDICTION: |
| 1575 | break; |
| 1576 | case HAL_CONFIG_VENC_TARGET_BITRATE: |
| 1577 | break; |
| 1578 | case HAL_PARAM_PROFILE_LEVEL_CURRENT: |
| 1579 | break; |
| 1580 | case HAL_PARAM_VENC_H264_ENTROPY_CONTROL: |
| 1581 | break; |
| 1582 | case HAL_PARAM_VENC_RATE_CONTROL: |
| 1583 | break; |
| 1584 | case HAL_PARAM_VENC_MPEG4_TIME_RESOLUTION: |
| 1585 | break; |
| 1586 | case HAL_PARAM_VENC_MPEG4_HEADER_EXTENSION: |
| 1587 | break; |
| 1588 | case HAL_PARAM_VENC_H264_DEBLOCK_CONTROL: |
| 1589 | break; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1590 | case HAL_PARAM_VENC_SESSION_QP: |
| 1591 | break; |
| 1592 | case HAL_CONFIG_VENC_INTRA_PERIOD: |
| 1593 | break; |
| 1594 | case HAL_CONFIG_VENC_IDR_PERIOD: |
| 1595 | break; |
| 1596 | case HAL_CONFIG_VPE_OPERATIONS: |
| 1597 | break; |
| 1598 | case HAL_PARAM_VENC_INTRA_REFRESH: |
| 1599 | break; |
| 1600 | case HAL_PARAM_VENC_MULTI_SLICE_CONTROL: |
| 1601 | break; |
| 1602 | case HAL_CONFIG_VPE_DEINTERLACE: |
| 1603 | break; |
| 1604 | case HAL_SYS_DEBUG_CONFIG: |
| 1605 | break; |
| 1606 | /*FOLLOWING PROPERTIES ARE NOT IMPLEMENTED IN CORE YET*/ |
| 1607 | case HAL_CONFIG_BUFFER_REQUIREMENTS: |
| 1608 | case HAL_CONFIG_PRIORITY: |
| 1609 | case HAL_CONFIG_BATCH_INFO: |
| 1610 | case HAL_PARAM_METADATA_PASS_THROUGH: |
| 1611 | case HAL_SYS_IDLE_INDICATOR: |
| 1612 | case HAL_PARAM_UNCOMPRESSED_FORMAT_SUPPORTED: |
| 1613 | case HAL_PARAM_INTERLACE_FORMAT_SUPPORTED: |
| 1614 | case HAL_PARAM_CHROMA_SITE: |
| 1615 | case HAL_PARAM_PROPERTIES_SUPPORTED: |
| 1616 | case HAL_PARAM_PROFILE_LEVEL_SUPPORTED: |
| 1617 | case HAL_PARAM_CAPABILITY_SUPPORTED: |
| 1618 | case HAL_PARAM_NAL_STREAM_FORMAT_SUPPORTED: |
| 1619 | case HAL_PARAM_MULTI_VIEW_FORMAT: |
| 1620 | case HAL_PARAM_MAX_SEQUENCE_HEADER_SIZE: |
| 1621 | case HAL_PARAM_CODEC_SUPPORTED: |
| 1622 | case HAL_PARAM_VDEC_MULTI_VIEW_SELECT: |
| 1623 | case HAL_PARAM_VDEC_MB_QUANTIZATION: |
| 1624 | case HAL_PARAM_VDEC_NUM_CONCEALED_MB: |
| 1625 | case HAL_PARAM_VDEC_H264_ENTROPY_SWITCHING: |
| 1626 | case HAL_PARAM_VENC_SLICE_DELIVERY_MODE: |
| 1627 | case HAL_PARAM_VENC_MPEG4_DATA_PARTITIONING: |
| 1628 | |
| 1629 | case HAL_CONFIG_BUFFER_COUNT_ACTUAL: |
| 1630 | case HAL_CONFIG_VDEC_MULTI_STREAM: |
| 1631 | case HAL_PARAM_VENC_MULTI_SLICE_INFO: |
| 1632 | case HAL_CONFIG_VENC_TIMESTAMP_SCALE: |
| 1633 | case HAL_PARAM_VENC_LOW_LATENCY: |
| 1634 | default: |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 1635 | dprintk(VIDC_INFO, "DEFAULT: Calling 0x%x", ptype); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1636 | break; |
| 1637 | } |
| 1638 | return 0; |
| 1639 | } |
| 1640 | |
| 1641 | void *vidc_hal_session_init(void *device, u32 session_id, |
| 1642 | enum hal_domain session_type, enum hal_video_codec codec_type) |
| 1643 | { |
| 1644 | struct hfi_cmd_sys_session_init_packet pkt; |
| 1645 | struct hal_session *new_session; |
| 1646 | struct hal_device *dev; |
| 1647 | |
| 1648 | if (device) { |
| 1649 | dev = device; |
| 1650 | } else { |
Ashray Kulkarni | 000b382 | 2012-10-11 18:20:58 -0700 | [diff] [blame] | 1651 | dprintk(VIDC_ERR, "invalid device"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1652 | return NULL; |
| 1653 | } |
| 1654 | |
| 1655 | new_session = (struct hal_session *) |
| 1656 | kzalloc(sizeof(struct hal_session), GFP_KERNEL); |
| 1657 | new_session->session_id = (u32) session_id; |
| 1658 | if (session_type == 1) |
| 1659 | new_session->is_decoder = 0; |
| 1660 | else if (session_type == 2) |
| 1661 | new_session->is_decoder = 1; |
| 1662 | new_session->device = dev; |
| 1663 | list_add_tail(&new_session->list, &dev->sess_head); |
| 1664 | pkt.size = sizeof(struct hfi_cmd_sys_session_init_packet); |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1665 | pkt.packet_type = HFI_CMD_SYS_SESSION_INIT; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1666 | pkt.session_id = (u32) new_session; |
| 1667 | pkt.session_domain = session_type; |
| 1668 | pkt.session_codec = codec_type; |
| 1669 | if (vidc_hal_iface_cmdq_write(dev, &pkt)) |
| 1670 | return NULL; |
Ashray Kulkarni | cde7852 | 2012-06-28 18:14:50 -0700 | [diff] [blame] | 1671 | if (vidc_hal_sys_set_debug(dev, msm_fw_debug)) |
| 1672 | dprintk(VIDC_ERR, "Setting fw_debug msg ON failed"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1673 | return (void *) new_session; |
| 1674 | } |
| 1675 | |
| 1676 | static int vidc_hal_send_session_cmd(void *session_id, |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1677 | int pkt_type) |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1678 | { |
| 1679 | struct vidc_hal_session_cmd_pkt pkt; |
| 1680 | int rc = 0; |
| 1681 | struct hal_session *session; |
| 1682 | |
| 1683 | if (session_id) { |
| 1684 | session = session_id; |
| 1685 | } else { |
Ashray Kulkarni | 000b382 | 2012-10-11 18:20:58 -0700 | [diff] [blame] | 1686 | dprintk(VIDC_ERR, "invalid session"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1687 | return -ENODEV; |
| 1688 | } |
| 1689 | |
| 1690 | pkt.size = sizeof(struct vidc_hal_session_cmd_pkt); |
| 1691 | pkt.packet_type = pkt_type; |
| 1692 | pkt.session_id = (u32) session; |
| 1693 | |
| 1694 | if (vidc_hal_iface_cmdq_write(session->device, &pkt)) |
| 1695 | rc = -ENOTEMPTY; |
| 1696 | return rc; |
| 1697 | } |
| 1698 | |
| 1699 | int vidc_hal_session_end(void *session) |
| 1700 | { |
| 1701 | return vidc_hal_send_session_cmd(session, |
| 1702 | HFI_CMD_SYS_SESSION_END); |
| 1703 | } |
| 1704 | |
| 1705 | int vidc_hal_session_abort(void *session) |
| 1706 | { |
| 1707 | return vidc_hal_send_session_cmd(session, |
| 1708 | HFI_CMD_SYS_SESSION_ABORT); |
| 1709 | } |
| 1710 | |
| 1711 | int vidc_hal_session_set_buffers(void *sess, |
| 1712 | struct vidc_buffer_addr_info *buffer_info) |
| 1713 | { |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1714 | u32 buffer; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1715 | struct hfi_cmd_session_set_buffers_packet *pkt; |
| 1716 | u8 packet[VIDC_IFACEQ_VAR_LARGE_PKT_SIZE]; |
| 1717 | int rc = 0; |
| 1718 | u16 i; |
| 1719 | struct hal_session *session; |
| 1720 | |
| 1721 | if (!sess || !buffer_info) { |
Ashray Kulkarni | 000b382 | 2012-10-11 18:20:58 -0700 | [diff] [blame] | 1722 | dprintk(VIDC_ERR, "Invalid Params"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1723 | return -EINVAL; |
| 1724 | } else { |
| 1725 | session = sess; |
| 1726 | } |
| 1727 | |
| 1728 | if (buffer_info->buffer_type == HAL_BUFFER_INPUT) |
| 1729 | return 0; |
| 1730 | |
| 1731 | pkt = (struct hfi_cmd_session_set_buffers_packet *)packet; |
| 1732 | |
| 1733 | pkt->size = sizeof(struct hfi_cmd_session_set_buffers_packet) + |
| 1734 | ((buffer_info->num_buffers - 1) * sizeof(u32)); |
| 1735 | pkt->packet_type = HFI_CMD_SESSION_SET_BUFFERS; |
| 1736 | pkt->session_id = (u32) session; |
| 1737 | pkt->buffer_mode = HFI_BUFFER_MODE_STATIC; |
| 1738 | pkt->buffer_size = buffer_info->buffer_size; |
| 1739 | pkt->min_buffer_size = buffer_info->buffer_size; |
| 1740 | pkt->num_buffers = buffer_info->num_buffers; |
| 1741 | |
| 1742 | if ((buffer_info->buffer_type == HAL_BUFFER_OUTPUT) || |
| 1743 | (buffer_info->buffer_type == HAL_BUFFER_OUTPUT2)) { |
| 1744 | struct hfi_buffer_info *buff; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1745 | pkt->extra_data_size = buffer_info->extradata_size; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1746 | pkt->size = sizeof(struct hfi_cmd_session_set_buffers_packet) - |
| 1747 | sizeof(u32) + ((buffer_info->num_buffers) * |
| 1748 | sizeof(struct hfi_buffer_info)); |
| 1749 | buff = (struct hfi_buffer_info *) pkt->rg_buffer_info; |
| 1750 | for (i = 0; i < pkt->num_buffers; i++) { |
| 1751 | buff->buffer_addr = |
| 1752 | buffer_info->align_device_addr; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1753 | buff->extra_data_addr = |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1754 | buffer_info->extradata_addr; |
| 1755 | } |
| 1756 | } else { |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1757 | pkt->extra_data_size = 0; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1758 | pkt->size = sizeof(struct hfi_cmd_session_set_buffers_packet) + |
| 1759 | ((buffer_info->num_buffers - 1) * sizeof(u32)); |
| 1760 | for (i = 0; i < pkt->num_buffers; i++) |
| 1761 | pkt->rg_buffer_info[i] = |
| 1762 | buffer_info->align_device_addr; |
| 1763 | } |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1764 | buffer = get_hfi_buffer(buffer_info->buffer_type); |
| 1765 | if (buffer) |
| 1766 | pkt->buffer_type = buffer; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1767 | else |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1768 | return -EINVAL; |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 1769 | dprintk(VIDC_INFO, "set buffers: 0x%x", buffer_info->buffer_type); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1770 | if (vidc_hal_iface_cmdq_write(session->device, pkt)) |
| 1771 | rc = -ENOTEMPTY; |
| 1772 | return rc; |
| 1773 | } |
| 1774 | |
| 1775 | int vidc_hal_session_release_buffers(void *sess, |
| 1776 | struct vidc_buffer_addr_info *buffer_info) |
| 1777 | { |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1778 | u32 buffer; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1779 | struct hfi_cmd_session_release_buffer_packet *pkt; |
| 1780 | u8 packet[VIDC_IFACEQ_VAR_LARGE_PKT_SIZE]; |
| 1781 | int rc = 0; |
| 1782 | u32 i; |
| 1783 | struct hal_session *session; |
| 1784 | |
| 1785 | if (!sess || !buffer_info) { |
Ashray Kulkarni | 000b382 | 2012-10-11 18:20:58 -0700 | [diff] [blame] | 1786 | dprintk(VIDC_ERR, "Invalid Params"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1787 | return -EINVAL; |
| 1788 | } else { |
| 1789 | session = sess; |
| 1790 | } |
| 1791 | |
| 1792 | if (buffer_info->buffer_type == HAL_BUFFER_INPUT) |
| 1793 | return 0; |
| 1794 | |
| 1795 | pkt = (struct hfi_cmd_session_release_buffer_packet *) packet; |
| 1796 | pkt->size = sizeof(struct hfi_cmd_session_release_buffer_packet) + |
| 1797 | ((buffer_info->num_buffers - 1) * sizeof(u32)); |
| 1798 | pkt->packet_type = HFI_CMD_SESSION_RELEASE_BUFFERS; |
| 1799 | pkt->session_id = (u32) session; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1800 | pkt->buffer_size = buffer_info->buffer_size; |
| 1801 | pkt->num_buffers = buffer_info->num_buffers; |
| 1802 | |
| 1803 | if ((buffer_info->buffer_type == HAL_BUFFER_OUTPUT) || |
| 1804 | (buffer_info->buffer_type == HAL_BUFFER_OUTPUT2)) { |
| 1805 | struct hfi_buffer_info *buff; |
| 1806 | buff = (struct hfi_buffer_info *) pkt->rg_buffer_info; |
| 1807 | for (i = 0; i < pkt->num_buffers; i++) { |
| 1808 | buff->buffer_addr = |
| 1809 | buffer_info->align_device_addr; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1810 | buff->extra_data_addr = |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1811 | buffer_info->extradata_addr; |
| 1812 | } |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1813 | pkt->extra_data_size = buffer_info->extradata_size; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1814 | pkt->size = sizeof(struct hfi_cmd_session_set_buffers_packet) - |
| 1815 | sizeof(u32) + ((buffer_info->num_buffers) * |
| 1816 | sizeof(struct hfi_buffer_info)); |
| 1817 | } else { |
| 1818 | for (i = 0; i < pkt->num_buffers; i++) |
| 1819 | pkt->rg_buffer_info[i] = |
| 1820 | buffer_info->align_device_addr; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1821 | pkt->extra_data_size = 0; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1822 | pkt->size = sizeof(struct hfi_cmd_session_set_buffers_packet) + |
| 1823 | ((buffer_info->num_buffers - 1) * sizeof(u32)); |
| 1824 | } |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1825 | buffer = get_hfi_buffer(buffer_info->buffer_type); |
| 1826 | if (buffer) |
| 1827 | pkt->buffer_type = buffer; |
| 1828 | else |
| 1829 | return -EINVAL; |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 1830 | dprintk(VIDC_INFO, "Release buffers: 0x%x", buffer_info->buffer_type); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1831 | if (vidc_hal_iface_cmdq_write(session->device, pkt)) |
| 1832 | rc = -ENOTEMPTY; |
| 1833 | return rc; |
| 1834 | } |
| 1835 | |
| 1836 | int vidc_hal_session_load_res(void *sess) |
| 1837 | { |
| 1838 | return vidc_hal_send_session_cmd(sess, |
| 1839 | HFI_CMD_SESSION_LOAD_RESOURCES); |
| 1840 | } |
| 1841 | |
| 1842 | int vidc_hal_session_release_res(void *sess) |
| 1843 | { |
| 1844 | return vidc_hal_send_session_cmd(sess, |
| 1845 | HFI_CMD_SESSION_RELEASE_RESOURCES); |
| 1846 | } |
| 1847 | |
| 1848 | int vidc_hal_session_start(void *sess) |
| 1849 | { |
| 1850 | return vidc_hal_send_session_cmd(sess, |
| 1851 | HFI_CMD_SESSION_START); |
| 1852 | } |
| 1853 | |
| 1854 | int vidc_hal_session_stop(void *sess) |
| 1855 | { |
| 1856 | return vidc_hal_send_session_cmd(sess, |
| 1857 | HFI_CMD_SESSION_STOP); |
| 1858 | } |
| 1859 | |
| 1860 | int vidc_hal_session_suspend(void *sess) |
| 1861 | { |
| 1862 | return vidc_hal_send_session_cmd(sess, |
| 1863 | HFI_CMD_SESSION_SUSPEND); |
| 1864 | } |
| 1865 | |
| 1866 | int vidc_hal_session_resume(void *sess) |
| 1867 | { |
| 1868 | return vidc_hal_send_session_cmd(sess, |
| 1869 | HFI_CMD_SESSION_RESUME); |
| 1870 | } |
| 1871 | |
| 1872 | int vidc_hal_session_etb(void *sess, struct vidc_frame_data *input_frame) |
| 1873 | { |
| 1874 | int rc = 0; |
| 1875 | struct hal_session *session; |
| 1876 | |
| 1877 | if (!sess || !input_frame) { |
Ashray Kulkarni | 000b382 | 2012-10-11 18:20:58 -0700 | [diff] [blame] | 1878 | dprintk(VIDC_ERR, "Invalid Params"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1879 | return -EINVAL; |
| 1880 | } else { |
| 1881 | session = sess; |
| 1882 | } |
| 1883 | |
| 1884 | if (session->is_decoder) { |
| 1885 | struct hfi_cmd_session_empty_buffer_compressed_packet pkt; |
| 1886 | pkt.size = sizeof( |
| 1887 | struct hfi_cmd_session_empty_buffer_compressed_packet); |
| 1888 | pkt.packet_type = HFI_CMD_SESSION_EMPTY_BUFFER; |
| 1889 | pkt.session_id = (u32) session; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1890 | pkt.time_stamp_hi = (int) (((u64)input_frame->timestamp) >> 32); |
| 1891 | pkt.time_stamp_lo = (int) input_frame->timestamp; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1892 | pkt.flags = input_frame->flags; |
| 1893 | pkt.mark_target = input_frame->mark_target; |
| 1894 | pkt.mark_data = input_frame->mark_data; |
| 1895 | pkt.offset = input_frame->offset; |
| 1896 | pkt.alloc_len = input_frame->alloc_len; |
| 1897 | pkt.filled_len = input_frame->filled_len; |
| 1898 | pkt.input_tag = input_frame->clnt_data; |
| 1899 | pkt.packet_buffer = (u8 *) input_frame->device_addr; |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 1900 | dprintk(VIDC_DBG, "Q DECODER INPUT BUFFER"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1901 | if (vidc_hal_iface_cmdq_write(session->device, &pkt)) |
| 1902 | rc = -ENOTEMPTY; |
| 1903 | } else { |
| 1904 | struct hfi_cmd_session_empty_buffer_uncompressed_plane0_packet |
| 1905 | pkt; |
| 1906 | pkt.size = sizeof(struct |
| 1907 | hfi_cmd_session_empty_buffer_uncompressed_plane0_packet); |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1908 | pkt.packet_type = HFI_CMD_SESSION_EMPTY_BUFFER; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1909 | pkt.session_id = (u32) session; |
| 1910 | pkt.view_id = 0; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 1911 | pkt.time_stamp_hi = (u32) (((u64)input_frame->timestamp) >> 32); |
| 1912 | pkt.time_stamp_lo = (u32) input_frame->timestamp; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1913 | pkt.flags = input_frame->flags; |
| 1914 | pkt.mark_target = input_frame->mark_target; |
| 1915 | pkt.mark_data = input_frame->mark_data; |
| 1916 | pkt.offset = input_frame->offset; |
| 1917 | pkt.alloc_len = input_frame->alloc_len; |
| 1918 | pkt.filled_len = input_frame->filled_len; |
| 1919 | pkt.input_tag = input_frame->clnt_data; |
| 1920 | pkt.packet_buffer = (u8 *) input_frame->device_addr; |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 1921 | dprintk(VIDC_DBG, "Q ENCODER INPUT BUFFER"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1922 | if (vidc_hal_iface_cmdq_write(session->device, &pkt)) |
| 1923 | rc = -ENOTEMPTY; |
| 1924 | } |
| 1925 | return rc; |
| 1926 | } |
| 1927 | |
| 1928 | int vidc_hal_session_ftb(void *sess, |
| 1929 | struct vidc_frame_data *output_frame) |
| 1930 | { |
| 1931 | struct hfi_cmd_session_fill_buffer_packet pkt; |
| 1932 | int rc = 0; |
| 1933 | struct hal_session *session; |
| 1934 | |
| 1935 | if (!sess || !output_frame) { |
Ashray Kulkarni | 000b382 | 2012-10-11 18:20:58 -0700 | [diff] [blame] | 1936 | dprintk(VIDC_ERR, "Invalid Params"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1937 | return -EINVAL; |
| 1938 | } else { |
| 1939 | session = sess; |
| 1940 | } |
| 1941 | |
| 1942 | pkt.size = sizeof(struct hfi_cmd_session_fill_buffer_packet); |
| 1943 | pkt.packet_type = HFI_CMD_SESSION_FILL_BUFFER; |
| 1944 | pkt.session_id = (u32) session; |
| 1945 | if (output_frame->buffer_type == HAL_BUFFER_OUTPUT) |
| 1946 | pkt.stream_id = 0; |
| 1947 | else if (output_frame->buffer_type == HAL_BUFFER_OUTPUT2) |
| 1948 | pkt.stream_id = 1; |
| 1949 | pkt.packet_buffer = (u8 *) output_frame->device_addr; |
| 1950 | pkt.extra_data_buffer = |
| 1951 | (u8 *) output_frame->extradata_addr; |
| 1952 | |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 1953 | dprintk(VIDC_INFO, "### Q OUTPUT BUFFER ###"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1954 | if (vidc_hal_iface_cmdq_write(session->device, &pkt)) |
| 1955 | rc = -ENOTEMPTY; |
| 1956 | return rc; |
| 1957 | } |
| 1958 | |
| 1959 | int vidc_hal_session_parse_seq_hdr(void *sess, |
| 1960 | struct vidc_seq_hdr *seq_hdr) |
| 1961 | { |
| 1962 | struct hfi_cmd_session_parse_sequence_header_packet *pkt; |
| 1963 | int rc = 0; |
| 1964 | u8 packet[VIDC_IFACEQ_VAR_SMALL_PKT_SIZE]; |
| 1965 | struct hal_session *session; |
| 1966 | |
| 1967 | if (!sess || !seq_hdr) { |
Ashray Kulkarni | 000b382 | 2012-10-11 18:20:58 -0700 | [diff] [blame] | 1968 | dprintk(VIDC_ERR, "Invalid Params"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1969 | return -EINVAL; |
| 1970 | } else { |
| 1971 | session = sess; |
| 1972 | } |
| 1973 | |
| 1974 | pkt = (struct hfi_cmd_session_parse_sequence_header_packet *) packet; |
| 1975 | pkt->size = sizeof(struct hfi_cmd_session_parse_sequence_header_packet); |
| 1976 | pkt->packet_type = HFI_CMD_SESSION_PARSE_SEQUENCE_HEADER; |
| 1977 | pkt->session_id = (u32) session; |
| 1978 | pkt->header_len = seq_hdr->seq_hdr_len; |
| 1979 | pkt->packet_buffer = seq_hdr->seq_hdr; |
| 1980 | |
| 1981 | if (vidc_hal_iface_cmdq_write(session->device, pkt)) |
| 1982 | rc = -ENOTEMPTY; |
| 1983 | return rc; |
| 1984 | } |
| 1985 | |
| 1986 | int vidc_hal_session_get_seq_hdr(void *sess, |
| 1987 | struct vidc_seq_hdr *seq_hdr) |
| 1988 | { |
| 1989 | struct hfi_cmd_session_get_sequence_header_packet *pkt; |
| 1990 | int rc = 0; |
| 1991 | u8 packet[VIDC_IFACEQ_VAR_SMALL_PKT_SIZE]; |
| 1992 | struct hal_session *session; |
| 1993 | |
| 1994 | if (!sess || !seq_hdr) { |
Ashray Kulkarni | 000b382 | 2012-10-11 18:20:58 -0700 | [diff] [blame] | 1995 | dprintk(VIDC_ERR, "Invalid Params"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 1996 | return -EINVAL; |
| 1997 | } else { |
| 1998 | session = sess; |
| 1999 | } |
| 2000 | |
| 2001 | pkt = (struct hfi_cmd_session_get_sequence_header_packet *) packet; |
| 2002 | pkt->size = sizeof(struct hfi_cmd_session_get_sequence_header_packet); |
| 2003 | pkt->packet_type = HFI_CMD_SESSION_GET_SEQUENCE_HEADER; |
| 2004 | pkt->session_id = (u32) session; |
| 2005 | pkt->buffer_len = seq_hdr->seq_hdr_len; |
| 2006 | pkt->packet_buffer = seq_hdr->seq_hdr; |
| 2007 | |
| 2008 | if (vidc_hal_iface_cmdq_write(session->device, pkt)) |
| 2009 | rc = -ENOTEMPTY; |
| 2010 | return rc; |
| 2011 | } |
| 2012 | |
| 2013 | int vidc_hal_session_get_buf_req(void *sess) |
| 2014 | { |
| 2015 | struct hfi_cmd_session_get_property_packet pkt; |
| 2016 | int rc = 0; |
| 2017 | struct hal_session *session; |
| 2018 | |
| 2019 | if (sess) { |
| 2020 | session = sess; |
| 2021 | } else { |
Ashray Kulkarni | 000b382 | 2012-10-11 18:20:58 -0700 | [diff] [blame] | 2022 | dprintk(VIDC_ERR, "invalid session"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 2023 | return -ENODEV; |
| 2024 | } |
| 2025 | |
| 2026 | pkt.size = sizeof(struct hfi_cmd_session_get_property_packet); |
| 2027 | pkt.packet_type = HFI_CMD_SESSION_GET_PROPERTY; |
| 2028 | pkt.session_id = (u32) session; |
| 2029 | pkt.num_properties = 1; |
| 2030 | pkt.rg_property_data[0] = HFI_PROPERTY_CONFIG_BUFFER_REQUIREMENTS; |
| 2031 | if (vidc_hal_iface_cmdq_write(session->device, &pkt)) |
| 2032 | rc = -ENOTEMPTY; |
| 2033 | return rc; |
| 2034 | } |
| 2035 | |
| 2036 | int vidc_hal_session_flush(void *sess, enum hal_flush flush_mode) |
| 2037 | { |
| 2038 | struct hfi_cmd_session_flush_packet pkt; |
| 2039 | int rc = 0; |
| 2040 | struct hal_session *session; |
| 2041 | |
| 2042 | if (sess) { |
| 2043 | session = sess; |
| 2044 | } else { |
Ashray Kulkarni | 000b382 | 2012-10-11 18:20:58 -0700 | [diff] [blame] | 2045 | dprintk(VIDC_ERR, "invalid session"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 2046 | return -ENODEV; |
| 2047 | } |
| 2048 | |
| 2049 | pkt.size = sizeof(struct hfi_cmd_session_flush_packet); |
| 2050 | pkt.packet_type = HFI_CMD_SESSION_FLUSH; |
| 2051 | pkt.session_id = (u32) session; |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 2052 | switch (flush_mode) { |
| 2053 | case HAL_FLUSH_INPUT: |
| 2054 | pkt.flush_type = HFI_FLUSH_INPUT; |
| 2055 | break; |
| 2056 | case HAL_FLUSH_OUTPUT: |
| 2057 | pkt.flush_type = HFI_FLUSH_OUTPUT; |
| 2058 | break; |
| 2059 | case HAL_FLUSH_OUTPUT2: |
| 2060 | pkt.flush_type = HFI_FLUSH_OUTPUT2; |
| 2061 | break; |
| 2062 | case HAL_FLUSH_ALL: |
| 2063 | pkt.flush_type = HFI_FLUSH_ALL; |
| 2064 | break; |
| 2065 | default: |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 2066 | dprintk(VIDC_ERR, "Invalid flush mode: 0x%x\n", flush_mode); |
Ashray Kulkarni | fe72c45 | 2012-05-29 19:52:00 -0700 | [diff] [blame] | 2067 | break; |
| 2068 | } |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 2069 | if (vidc_hal_iface_cmdq_write(session->device, &pkt)) |
| 2070 | rc = -ENOTEMPTY; |
| 2071 | return rc; |
| 2072 | } |
| 2073 | |
| 2074 | static int vidc_hal_check_core_registered( |
| 2075 | struct hal_device_data core, u32 fw_addr, |
| 2076 | u32 reg_addr, u32 reg_size, u32 irq) |
| 2077 | { |
| 2078 | struct hal_device *device; |
| 2079 | struct list_head *curr, *next; |
| 2080 | |
| 2081 | if (core.dev_count) { |
| 2082 | list_for_each_safe(curr, next, &core.dev_head) { |
| 2083 | device = list_entry(curr, struct hal_device, list); |
| 2084 | if (device && device->hal_data->irq == irq && |
Vinay Kalia | 68398a4 | 2012-06-22 18:36:12 -0700 | [diff] [blame] | 2085 | (CONTAINS(device->hal_data-> |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 2086 | device_base_addr, |
| 2087 | FIRMWARE_SIZE, fw_addr) || |
| 2088 | CONTAINS(fw_addr, FIRMWARE_SIZE, |
Vinay Kalia | 68398a4 | 2012-06-22 18:36:12 -0700 | [diff] [blame] | 2089 | device->hal_data-> |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 2090 | device_base_addr) || |
| 2091 | CONTAINS((u32)device->hal_data-> |
| 2092 | register_base_addr, |
| 2093 | reg_size, reg_addr) || |
| 2094 | CONTAINS(reg_addr, reg_size, |
| 2095 | (u32)device->hal_data-> |
| 2096 | register_base_addr) || |
| 2097 | OVERLAPS((u32)device->hal_data-> |
| 2098 | register_base_addr, |
| 2099 | reg_size, reg_addr, reg_size) || |
| 2100 | OVERLAPS(reg_addr, reg_size, |
| 2101 | (u32)device->hal_data-> |
| 2102 | register_base_addr, reg_size) || |
Vinay Kalia | 68398a4 | 2012-06-22 18:36:12 -0700 | [diff] [blame] | 2103 | OVERLAPS(device->hal_data-> |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 2104 | device_base_addr, |
| 2105 | FIRMWARE_SIZE, fw_addr, |
| 2106 | FIRMWARE_SIZE) || |
| 2107 | OVERLAPS(fw_addr, FIRMWARE_SIZE, |
Vinay Kalia | 68398a4 | 2012-06-22 18:36:12 -0700 | [diff] [blame] | 2108 | device->hal_data-> |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 2109 | device_base_addr, |
| 2110 | FIRMWARE_SIZE))) { |
| 2111 | return 0; |
| 2112 | } else { |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 2113 | dprintk(VIDC_INFO, "Device not registered"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 2114 | return -EINVAL; |
| 2115 | } |
| 2116 | } |
| 2117 | } else { |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 2118 | dprintk(VIDC_INFO, "no device Registered"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 2119 | } |
| 2120 | return -EINVAL; |
| 2121 | } |
| 2122 | |
| 2123 | static void vidc_hal_core_work_handler(struct work_struct *work) |
| 2124 | { |
Deva Ramasubramanian | c249b75 | 2012-05-18 17:31:03 -0700 | [diff] [blame] | 2125 | struct hal_device *device = list_first_entry( |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 2126 | &hal_ctxt.dev_head, struct hal_device, list); |
| 2127 | |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 2128 | dprintk(VIDC_INFO, " GOT INTERRUPT () "); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 2129 | if (!device->callback) { |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 2130 | dprintk(VIDC_ERR, "No callback function " |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 2131 | "to process interrupt: %p\n", device); |
| 2132 | return; |
| 2133 | } |
| 2134 | vidc_hal_core_clear_interrupt(device); |
| 2135 | vidc_hal_response_handler(device); |
| 2136 | enable_irq(device->hal_data->irq); |
| 2137 | } |
| 2138 | static DECLARE_WORK(vidc_hal_work, vidc_hal_core_work_handler); |
| 2139 | |
| 2140 | static irqreturn_t vidc_hal_isr(int irq, void *dev) |
| 2141 | { |
| 2142 | struct hal_device *device = dev; |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 2143 | dprintk(VIDC_INFO, "vidc_hal_isr() %d ", irq); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 2144 | disable_irq_nosync(irq); |
| 2145 | queue_work(device->vidc_workq, &vidc_hal_work); |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 2146 | dprintk(VIDC_INFO, "vidc_hal_isr() %d ", irq); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 2147 | return IRQ_HANDLED; |
| 2148 | } |
| 2149 | |
| 2150 | void *vidc_hal_add_device(u32 device_id, u32 fw_base_addr, u32 reg_base, |
| 2151 | u32 reg_size, u32 irq, |
| 2152 | void (*callback) (enum command_response cmd, void *data)) |
| 2153 | { |
| 2154 | struct hal_device *hdevice = NULL; |
| 2155 | struct hal_data *hal = NULL; |
| 2156 | int rc = 0; |
| 2157 | |
Vinay Kalia | 68398a4 | 2012-06-22 18:36:12 -0700 | [diff] [blame] | 2158 | if (device_id || !reg_base || !reg_size || |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 2159 | !irq || !callback) { |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 2160 | dprintk(VIDC_ERR, "Invalid Paramters"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 2161 | return NULL; |
| 2162 | } else { |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 2163 | dprintk(VIDC_INFO, "entered , device_id: %d", device_id); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 2164 | } |
| 2165 | |
| 2166 | if (vidc_hal_check_core_registered(hal_ctxt, fw_base_addr, |
| 2167 | reg_base, reg_size, irq)) { |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 2168 | dprintk(VIDC_DBG, "HAL_DATA will be assigned now"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 2169 | hal = (struct hal_data *) |
| 2170 | kzalloc(sizeof(struct hal_data), GFP_KERNEL); |
| 2171 | if (!hal) { |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 2172 | dprintk(VIDC_ERR, "Failed to alloc"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 2173 | return NULL; |
| 2174 | } |
| 2175 | hal->irq = irq; |
Vinay Kalia | 68398a4 | 2012-06-22 18:36:12 -0700 | [diff] [blame] | 2176 | hal->device_base_addr = fw_base_addr; |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 2177 | hal->register_base_addr = |
| 2178 | ioremap_nocache(reg_base, reg_size); |
| 2179 | if (!hal->register_base_addr) { |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 2180 | dprintk(VIDC_ERR, |
| 2181 | "could not map reg addr %d of size %d", |
| 2182 | reg_base, reg_size); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 2183 | goto err_map; |
| 2184 | } |
| 2185 | INIT_LIST_HEAD(&hal_ctxt.dev_head); |
| 2186 | } else { |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 2187 | dprintk(VIDC_ERR, "Core present/Already added"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 2188 | return NULL; |
| 2189 | } |
| 2190 | |
| 2191 | hdevice = (struct hal_device *) |
| 2192 | kzalloc(sizeof(struct hal_device), GFP_KERNEL); |
| 2193 | if (!hdevice) { |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 2194 | dprintk(VIDC_ERR, "failed to allocate new device"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 2195 | goto err_map; |
| 2196 | } |
| 2197 | |
| 2198 | INIT_LIST_HEAD(&hdevice->list); |
| 2199 | list_add_tail(&hdevice->list, &hal_ctxt.dev_head); |
| 2200 | hal_ctxt.dev_count++; |
| 2201 | hdevice->device_id = device_id; |
| 2202 | hdevice->hal_data = hal; |
| 2203 | hdevice->callback = callback; |
| 2204 | |
| 2205 | hdevice->vidc_workq = create_singlethread_workqueue( |
| 2206 | "msm_vidc_workerq"); |
| 2207 | if (!hdevice->vidc_workq) { |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 2208 | dprintk(VIDC_ERR, ": create workq failed\n"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 2209 | goto error_createq; |
| 2210 | } |
| 2211 | |
| 2212 | rc = request_irq(irq, vidc_hal_isr, IRQF_TRIGGER_HIGH, |
| 2213 | "msm_vidc", hdevice); |
| 2214 | if (unlikely(rc)) { |
Blaine Dietrich | f1a7cff | 2012-07-23 12:14:18 -0700 | [diff] [blame] | 2215 | dprintk(VIDC_ERR, "() :request_irq failed\n"); |
Ashray Kulkarni | 6ab782b | 2012-01-26 16:58:01 -0800 | [diff] [blame] | 2216 | goto error_irq_fail; |
| 2217 | } |
| 2218 | disable_irq_nosync(irq); |
| 2219 | return (void *) hdevice; |
| 2220 | error_irq_fail: |
| 2221 | destroy_workqueue(hdevice->vidc_workq); |
| 2222 | error_createq: |
| 2223 | hal_ctxt.dev_count--; |
| 2224 | list_del(&hal_ctxt.dev_head); |
| 2225 | err_map: |
| 2226 | kfree(hal); |
| 2227 | return NULL; |
| 2228 | } |
| 2229 | |
| 2230 | void vidc_hal_delete_device(void *device) |
| 2231 | { |
| 2232 | struct hal_device *close, *dev; |
| 2233 | |
| 2234 | if (device) { |
| 2235 | dev = (struct hal_device *) device; |
| 2236 | list_for_each_entry(close, &hal_ctxt.dev_head, list) { |
| 2237 | if (close->hal_data->irq == dev->hal_data->irq) { |
| 2238 | hal_ctxt.dev_count--; |
| 2239 | free_irq(dev->hal_data->irq, NULL); |
| 2240 | list_del(&close->list); |
| 2241 | destroy_workqueue(close->vidc_workq); |
| 2242 | kfree(close->hal_data); |
| 2243 | kfree(close); |
| 2244 | break; |
| 2245 | } |
| 2246 | } |
| 2247 | |
| 2248 | } |
| 2249 | } |