Loading drivers/media/platform/msm/vidc/msm_vidc.c +67 −13 Original line number Diff line number Diff line Loading @@ -386,7 +386,7 @@ static struct msm_smem *map_buffer(struct msm_vidc_inst *inst, struct v4l2_plane *p, enum hal_buffer buffer_type) { struct msm_smem *handle = NULL; handle = msm_smem_user_to_kernel(inst->mem_client, handle = msm_comm_smem_user_to_kernel(inst, p->reserved[0], p->reserved[1], buffer_type); Loading @@ -395,7 +395,7 @@ static struct msm_smem *map_buffer(struct msm_vidc_inst *inst, "%s: Failed to get device buffer address\n", __func__); return NULL; } if (msm_smem_cache_operations(inst->mem_client, handle, if (msm_comm_smem_cache_operations(inst, handle, SMEM_CACHE_CLEAN)) dprintk(VIDC_WARN, "CACHE Clean failed: %d, %d, %d\n", Loading Loading @@ -614,7 +614,7 @@ int unmap_and_deregister_buf(struct msm_vidc_inst *inst, dprintk(VIDC_DBG, "[UNMAP] - handle[%d] = %p fd[%d] = %d", i, temp->handle[i], i, temp->fd[i]); msm_smem_free(inst->mem_client, msm_comm_smem_free(inst, temp->handle[i]); } Loading Loading @@ -690,7 +690,7 @@ int output_buffer_cache_invalidate(struct msm_vidc_inst *inst, for (i = 0; i < binfo->num_planes; i++) { if (binfo->handle[i]) { rc = msm_smem_cache_operations(inst->mem_client, rc = msm_comm_smem_cache_operations(inst, binfo->handle[i], SMEM_CACHE_INVALIDATE); if (rc) { dprintk(VIDC_ERR, Loading Loading @@ -776,7 +776,7 @@ int msm_vidc_release_buffers(void *instance, int buffer_type) list_del(&bi->list); for (i = 0; i < bi->num_planes; i++) { if (bi->handle[i]) msm_smem_free(inst->mem_client, msm_comm_smem_free(inst, bi->handle[i]); } kfree(bi); Loading Loading @@ -858,7 +858,7 @@ int msm_vidc_qbuf(void *instance, struct v4l2_buffer *b) if ((inst->fmts[OUTPUT_PORT]->fourcc == V4L2_PIX_FMT_HEVC_HYBRID) && binfo->handle[i] && (b->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)) { rc = msm_smem_cache_operations(inst->mem_client, rc = msm_comm_smem_cache_operations(inst, binfo->handle[i], SMEM_CACHE_INVALIDATE); if (rc) { dprintk(VIDC_ERR, Loading @@ -869,7 +869,7 @@ int msm_vidc_qbuf(void *instance, struct v4l2_buffer *b) if (binfo->handle[i] && (b->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)) { rc = msm_smem_cache_operations(inst->mem_client, rc = msm_comm_smem_cache_operations(inst, binfo->handle[i], SMEM_CACHE_CLEAN); if (rc) { dprintk(VIDC_ERR, Loading Loading @@ -1009,6 +1009,61 @@ int msm_vidc_enum_framesizes(void *instance, struct v4l2_frmsizeenum *fsize) } EXPORT_SYMBOL(msm_vidc_enum_framesizes); struct msm_smem *msm_vidc_smem_alloc(void *instance, size_t size, u32 align, u32 flags, enum hal_buffer buffer_type, int map_kernel) { return msm_comm_smem_alloc((struct msm_vidc_inst *)instance, size, align, flags, buffer_type, map_kernel); } EXPORT_SYMBOL(msm_vidc_smem_alloc); void msm_vidc_smem_free(void *instance, struct msm_smem *mem) { msm_comm_smem_free((struct msm_vidc_inst *)instance, mem); } EXPORT_SYMBOL(msm_vidc_smem_free); int msm_vidc_smem_cache_operations(void *instance, struct msm_smem *mem, enum smem_cache_ops cache_ops) { return msm_comm_smem_cache_operations( (struct msm_vidc_inst *)instance, mem, cache_ops); } EXPORT_SYMBOL(msm_vidc_smem_cache_operations); struct msm_smem *msm_vidc_smem_user_to_kernel(void *instance, int fd, u32 offset, enum hal_buffer buffer_type) { return msm_comm_smem_user_to_kernel( (struct msm_vidc_inst *)instance, fd, offset, buffer_type); } EXPORT_SYMBOL(msm_vidc_smem_user_to_kernel); int msm_vidc_smem_get_domain_partition(void *instance, u32 flags, enum hal_buffer buffer_type, int *domain_num, int *partition_num) { return msm_comm_smem_get_domain_partition( (struct msm_vidc_inst *)instance, flags, buffer_type, domain_num, partition_num); } EXPORT_SYMBOL(msm_vidc_smem_get_domain_partition); void *msm_vidc_smem_get_client(void *instance) { struct msm_vidc_inst *inst = instance; if (!inst || !inst->mem_client) { dprintk(VIDC_ERR, "%s: invalid instance or client = %p %p\n", __func__, inst, inst->mem_client); return NULL; } return inst->mem_client; } static void *vidc_get_userptr(void *alloc_ctx, unsigned long vaddr, unsigned long size, int write) { Loading Loading @@ -1235,7 +1290,7 @@ static void cleanup_instance(struct msm_vidc_inst *inst) list); list_del(&buf->list); mutex_unlock(&inst->lock); msm_smem_free(inst->mem_client, buf->handle); msm_comm_smem_free(inst, buf->handle); kfree(buf); mutex_lock(&inst->lock); } Loading @@ -1246,7 +1301,7 @@ static void cleanup_instance(struct msm_vidc_inst *inst) list); list_del(&buf->list); mutex_unlock(&inst->lock); msm_smem_free(inst->mem_client, buf->handle); msm_comm_smem_free(inst, buf->handle); kfree(buf); mutex_lock(&inst->lock); } Loading @@ -1257,14 +1312,14 @@ static void cleanup_instance(struct msm_vidc_inst *inst) list); list_del(&buf->list); mutex_unlock(&inst->lock); msm_smem_free(inst->mem_client, buf->handle); msm_comm_smem_free(inst, buf->handle); kfree(buf); mutex_lock(&inst->lock); } } if (inst->extradata_handle) { mutex_unlock(&inst->lock); msm_smem_free(inst->mem_client, inst->extradata_handle); msm_comm_smem_free(inst, inst->extradata_handle); mutex_lock(&inst->lock); } mutex_unlock(&inst->lock); Loading Loading @@ -1294,8 +1349,7 @@ int msm_vidc_close(void *instance) for (i = 0; (i < bi->num_planes) && (i < VIDEO_MAX_PLANES); i++) { if (bi->handle[i]) msm_smem_free(inst->mem_client, bi->handle[i]); msm_comm_smem_free(inst, bi->handle[i]); } kfree(bi); } Loading drivers/media/platform/msm/vidc/msm_vidc_common.c +94 −12 Original line number Diff line number Diff line Loading @@ -2006,7 +2006,7 @@ static int set_output_buffers(struct msm_vidc_inst *inst, if (output_buf->buffer_size) { for (i = 0; i < output_buf->buffer_count_actual; i++) { handle = msm_smem_alloc(inst->mem_client, handle = msm_comm_smem_alloc(inst, buffer_size, 1, smem_flags, buffer_type, 0); if (!handle) { Loading @@ -2015,7 +2015,7 @@ static int set_output_buffers(struct msm_vidc_inst *inst, rc = -ENOMEM; goto err_no_mem; } rc = msm_smem_cache_operations(inst->mem_client, rc = msm_comm_smem_cache_operations(inst, handle, SMEM_CACHE_CLEAN); if (rc) { dprintk(VIDC_WARN, Loading Loading @@ -2060,7 +2060,7 @@ static int set_output_buffers(struct msm_vidc_inst *inst, fail_set_buffers: kfree(binfo); fail_kzalloc: msm_smem_free(inst->mem_client, handle); msm_comm_smem_free(inst, handle); err_no_mem: return rc; } Loading Loading @@ -2097,7 +2097,7 @@ static int set_scratch_buffers(struct msm_vidc_inst *inst, if (scratch_buf->buffer_size) { for (i = 0; i < scratch_buf->buffer_count_actual; i++) { handle = msm_smem_alloc(inst->mem_client, handle = msm_comm_smem_alloc(inst, scratch_buf->buffer_size, 1, smem_flags, buffer_type, 0); if (!handle) { Loading @@ -2106,7 +2106,7 @@ static int set_scratch_buffers(struct msm_vidc_inst *inst, rc = -ENOMEM; goto err_no_mem; } rc = msm_smem_cache_operations(inst->mem_client, rc = msm_comm_smem_cache_operations(inst, handle, SMEM_CACHE_CLEAN); if (rc) { dprintk(VIDC_WARN, Loading Loading @@ -2142,7 +2142,7 @@ static int set_scratch_buffers(struct msm_vidc_inst *inst, fail_set_buffers: kfree(binfo); fail_kzalloc: msm_smem_free(inst->mem_client, handle); msm_comm_smem_free(inst, handle); err_no_mem: return rc; } Loading Loading @@ -2184,7 +2184,7 @@ static int set_persist_buffers(struct msm_vidc_inst *inst, if (persist_buf->buffer_size) { for (i = 0; i < persist_buf->buffer_count_actual; i++) { handle = msm_smem_alloc(inst->mem_client, handle = msm_comm_smem_alloc(inst, persist_buf->buffer_size, 1, smem_flags, buffer_type, 0); if (!handle) { Loading @@ -2193,7 +2193,7 @@ static int set_persist_buffers(struct msm_vidc_inst *inst, rc = -ENOMEM; goto err_no_mem; } rc = msm_smem_cache_operations(inst->mem_client, rc = msm_comm_smem_cache_operations(inst, handle, SMEM_CACHE_CLEAN); if (rc) { dprintk(VIDC_WARN, Loading Loading @@ -2229,7 +2229,7 @@ static int set_persist_buffers(struct msm_vidc_inst *inst, fail_set_buffers: kfree(binfo); fail_kzalloc: msm_smem_free(inst->mem_client, handle); msm_comm_smem_free(inst, handle); err_no_mem: return rc; } Loading Loading @@ -2677,7 +2677,7 @@ int msm_comm_release_output_buffers(struct msm_vidc_inst *inst) } list_del(&buf->list); mutex_unlock(&inst->lock); msm_smem_free(inst->mem_client, buf->handle); msm_comm_smem_free(inst, buf->handle); kfree(buf); mutex_lock(&inst->lock); } Loading Loading @@ -2748,7 +2748,7 @@ int msm_comm_release_scratch_buffers(struct msm_vidc_inst *inst) } list_del(&buf->list); mutex_unlock(&inst->lock); msm_smem_free(inst->mem_client, buf->handle); msm_comm_smem_free(inst, buf->handle); kfree(buf); mutex_lock(&inst->lock); } Loading Loading @@ -2819,7 +2819,7 @@ int msm_comm_release_persist_buffers(struct msm_vidc_inst *inst) } list_del(&buf->list); mutex_unlock(&inst->lock); msm_smem_free(inst->mem_client, buf->handle); msm_comm_smem_free(inst, buf->handle); kfree(buf); mutex_lock(&inst->lock); } Loading Loading @@ -3420,3 +3420,85 @@ int msm_comm_recover_from_session_error(struct msm_vidc_inst *inst) change_inst_state(inst, MSM_VIDC_CLOSE_DONE); return rc; } static inline int power_on_for_smem(struct msm_vidc_inst *inst) { struct hfi_device *hdev = NULL; int rc = 0; if (!inst || !inst->core || !inst->core->device) { dprintk(VIDC_ERR, "%s: invalid inst handle\n", __func__); return -EINVAL; } hdev = inst->core->device; rc = call_hfi_op(hdev, power_enable, hdev->hfi_device_data); if (rc) dprintk(VIDC_ERR, "%s: failed to power on fw\n", __func__); return rc; } struct msm_smem *msm_comm_smem_alloc(struct msm_vidc_inst *inst, size_t size, u32 align, u32 flags, enum hal_buffer buffer_type, int map_kernel) { if (!inst) { dprintk(VIDC_ERR, "%s: invalid inst: %p\n", __func__, inst); return NULL; } if (power_on_for_smem(inst)) return NULL; return msm_smem_alloc(inst->mem_client, size, align, flags, buffer_type, map_kernel); } void msm_comm_smem_free(struct msm_vidc_inst *inst, struct msm_smem *mem) { if (!inst || !mem) { dprintk(VIDC_ERR, "%s: invalid params: %p %p\n", __func__, inst, mem); return; } if (power_on_for_smem(inst)) return; return msm_smem_free(inst->mem_client, mem); } int msm_comm_smem_cache_operations(struct msm_vidc_inst *inst, struct msm_smem *mem, enum smem_cache_ops cache_ops) { if (!inst || !mem) { dprintk(VIDC_ERR, "%s: invalid params: %p %p\n", __func__, inst, mem); return -EINVAL; } return msm_smem_cache_operations(inst->mem_client, mem, cache_ops); } struct msm_smem *msm_comm_smem_user_to_kernel(struct msm_vidc_inst *inst, int fd, u32 offset, enum hal_buffer buffer_type) { if (!inst) { dprintk(VIDC_ERR, "%s: invalid inst: %p\n", __func__, inst); return NULL; } if (power_on_for_smem(inst)) return NULL; return msm_smem_user_to_kernel(inst->mem_client, fd, offset, buffer_type); } int msm_comm_smem_get_domain_partition(struct msm_vidc_inst *inst, u32 flags, enum hal_buffer buffer_type, int *domain_num, int *partition_num) { if (!inst || !domain_num || !partition_num) { dprintk(VIDC_ERR, "%s: invalid params: %p %p %p\n", __func__, inst, domain_num, partition_num); return -EINVAL; } return msm_smem_get_domain_partition(inst->mem_client, flags, buffer_type, domain_num, partition_num); } drivers/media/platform/msm/vidc/msm_vidc_common.h +11 −1 Original line number Diff line number Diff line Loading @@ -53,5 +53,15 @@ struct hal_buffer_requirements *get_buff_req_buffer( int msm_comm_recover_from_session_error(struct msm_vidc_inst *inst); enum multi_stream msm_comm_get_stream_output_mode(struct msm_vidc_inst *inst); enum hal_buffer msm_comm_get_hal_output_buffer(struct msm_vidc_inst *inst); struct msm_smem *msm_comm_smem_alloc(struct msm_vidc_inst *inst, size_t size, u32 align, u32 flags, enum hal_buffer buffer_type, int map_kernel); void msm_comm_smem_free(struct msm_vidc_inst *inst, struct msm_smem *mem); int msm_comm_smem_cache_operations(struct msm_vidc_inst *inst, struct msm_smem *mem, enum smem_cache_ops cache_ops); struct msm_smem *msm_comm_smem_user_to_kernel(struct msm_vidc_inst *inst, int fd, u32 offset, enum hal_buffer buffer_type); int msm_comm_smem_get_domain_partition(struct msm_vidc_inst *inst, u32 flags, enum hal_buffer buffer_type, int *domain_num, int *partition_num); #endif drivers/media/platform/msm/vidc/venus_hfi.c +46 −19 Original line number Diff line number Diff line Loading @@ -75,6 +75,8 @@ struct tzbsp_video_set_state_req { u32 spare; /*reserved for future, should be zero*/ }; static int venus_hfi_power_enable(void *dev); static void venus_hfi_dump_packet(u8 *packet) { u32 c = 0, packet_size = *(u32 *)packet; Loading Loading @@ -435,21 +437,24 @@ static int venus_hfi_read_queue(void *info, u8 *packet, u32 *pb_tx_req_is_set) return rc; } static int venus_hfi_alloc(void *mem, void *clnt, u32 size, u32 align, u32 flags, u32 usage) static int venus_hfi_alloc(struct venus_hfi_device *dev, void *mem, u32 size, u32 align, u32 flags, u32 usage) { struct vidc_mem_addr *vmem; struct msm_smem *alloc; struct vidc_mem_addr *vmem = NULL; struct msm_smem *alloc = NULL; int rc = 0; if (!mem || !clnt || !size) { if (!dev || !dev->hal_client || !mem || !size) { dprintk(VIDC_ERR, "Invalid Params"); return -EINVAL; } vmem = (struct vidc_mem_addr *)mem; dprintk(VIDC_INFO, "start to alloc: size:%d, Flags: %d", size, flags); alloc = msm_smem_alloc(clnt, size, align, flags, usage, 1); venus_hfi_power_enable(dev); alloc = msm_smem_alloc(dev->hal_client, size, align, flags, usage, 1); dprintk(VIDC_DBG, "Alloc done"); if (!alloc) { dprintk(VIDC_ERR, "Alloc failed\n"); Loading @@ -458,7 +463,7 @@ static int venus_hfi_alloc(void *mem, void *clnt, u32 size, u32 align, } dprintk(VIDC_DBG, "venus_hfi_alloc:ptr=%p,size=%d", alloc->kvaddr, size); rc = msm_smem_cache_operations(clnt, alloc, rc = msm_smem_cache_operations(dev->hal_client, alloc, SMEM_CACHE_CLEAN); if (rc) { dprintk(VIDC_WARN, "Failed to clean cache\n"); Loading @@ -473,9 +478,14 @@ fail_smem_alloc: return rc; } static void venus_hfi_free(struct smem_client *clnt, struct msm_smem *mem) static void venus_hfi_free(struct venus_hfi_device *dev, struct msm_smem *mem) { msm_smem_free(clnt, mem); if (!dev || !mem) { dprintk(VIDC_ERR, "invalid param %p %p\n", dev, mem); return; } venus_hfi_power_enable(dev); msm_smem_free(dev->hal_client, mem); } static void venus_hfi_write_register(struct venus_hfi_device *device, u32 reg, Loading Loading @@ -1012,6 +1022,22 @@ err_scale_buses: return rc; } static int venus_hfi_power_enable(void *dev) { int rc = 0; struct venus_hfi_device *device = dev; if (!device) { dprintk(VIDC_ERR, "Invalid params: %p\n", device); return -EINVAL; } mutex_lock(&device->clk_pwr_lock); if (!device->power_enabled) rc = venus_hfi_power_on(device); mutex_unlock(&device->clk_pwr_lock); return rc; } static void venus_hfi_pm_hndlr(struct work_struct *work); static DECLARE_DELAYED_WORK(venus_hfi_pm_work, venus_hfi_pm_hndlr); Loading Loading @@ -1269,10 +1295,10 @@ static void venus_hfi_interface_queues_release(struct venus_hfi_device *device) (unsigned long)(mem_map[i].virtual_addr), domain, partition, SZ_4K); } venus_hfi_free(device->hal_client, device->qdss.mem_data); venus_hfi_free(device, device->qdss.mem_data); } venus_hfi_free(device->hal_client, device->iface_q_table.mem_data); venus_hfi_free(device->hal_client, device->sfr.mem_data); venus_hfi_free(device, device->iface_q_table.mem_data); venus_hfi_free(device, device->sfr.mem_data); for (i = 0; i < VIDC_IFACEQ_NUMQ; i++) { device->iface_queues[i].q_hdr = NULL; Loading Loading @@ -1348,8 +1374,8 @@ static int venus_hfi_interface_queues_init(struct venus_hfi_device *dev) int num_entries = sizeof(venus_qdss_entries)/(2 * sizeof(u32)); int domain, partition; mem_addr = &dev->mem_addr; rc = venus_hfi_alloc((void *) mem_addr, dev->hal_client, QUEUE_SIZE, 1, 0, rc = venus_hfi_alloc(dev, (void *) mem_addr, QUEUE_SIZE, 1, 0, HAL_BUFFER_INTERNAL_CMD_QUEUE); if (rc) { dprintk(VIDC_ERR, "iface_q_table_alloc_fail"); Loading @@ -1375,8 +1401,8 @@ static int venus_hfi_interface_queues_init(struct venus_hfi_device *dev) venus_hfi_set_queue_hdr_defaults(iface_q->q_hdr); } rc = venus_hfi_alloc((void *) mem_addr, dev->hal_client, QDSS_SIZE, 1, 0, rc = venus_hfi_alloc(dev, (void *) mem_addr, QDSS_SIZE, 1, 0, HAL_BUFFER_INTERNAL_CMD_QUEUE); if (rc) { dprintk(VIDC_WARN, Loading @@ -1388,8 +1414,8 @@ static int venus_hfi_interface_queues_init(struct venus_hfi_device *dev) dev->qdss.mem_size = QDSS_SIZE; dev->qdss.mem_data = mem_addr->mem_data; } rc = venus_hfi_alloc((void *) mem_addr, dev->hal_client, SFR_SIZE, 1, 0, rc = venus_hfi_alloc(dev, (void *) mem_addr, SFR_SIZE, 1, 0, HAL_BUFFER_INTERNAL_CMD_QUEUE); if (rc) { dprintk(VIDC_WARN, "sfr_alloc_fail: SFR not will work"); Loading Loading @@ -1454,7 +1480,7 @@ static int venus_hfi_interface_queues_init(struct venus_hfi_device *dev) if (rc) { dprintk(VIDC_ERR, "IOMMU mapping failed, Freeing qdss memdata"); venus_hfi_free(dev->hal_client, dev->qdss.mem_data); venus_hfi_free(dev, dev->qdss.mem_data); dev->qdss.mem_data = NULL; } if (!IS_ERR_OR_NULL(dev->qdss.align_device_addr)) Loading Loading @@ -3676,6 +3702,7 @@ static void venus_init_hfi_callbacks(struct hfi_device *hdev) hdev->get_stride_scanline = venus_hfi_get_stride_scanline; hdev->capability_check = venus_hfi_capability_check; hdev->get_core_capabilities = venus_hfi_get_core_capabilities; hdev->power_enable = venus_hfi_power_enable; } int venus_hfi_initialize(struct hfi_device *hdev, u32 device_id, Loading drivers/media/platform/msm/vidc/vidc_hfi_api.h +1 −0 Original line number Diff line number Diff line Loading @@ -1190,6 +1190,7 @@ struct hfi_device { u32 *max_width, u32 *max_height); int (*session_clean)(void *sess); int (*get_core_capabilities)(void); int (*power_enable)(void *dev); }; typedef void (*hfi_cmd_response_callback) (enum command_response cmd, Loading Loading
drivers/media/platform/msm/vidc/msm_vidc.c +67 −13 Original line number Diff line number Diff line Loading @@ -386,7 +386,7 @@ static struct msm_smem *map_buffer(struct msm_vidc_inst *inst, struct v4l2_plane *p, enum hal_buffer buffer_type) { struct msm_smem *handle = NULL; handle = msm_smem_user_to_kernel(inst->mem_client, handle = msm_comm_smem_user_to_kernel(inst, p->reserved[0], p->reserved[1], buffer_type); Loading @@ -395,7 +395,7 @@ static struct msm_smem *map_buffer(struct msm_vidc_inst *inst, "%s: Failed to get device buffer address\n", __func__); return NULL; } if (msm_smem_cache_operations(inst->mem_client, handle, if (msm_comm_smem_cache_operations(inst, handle, SMEM_CACHE_CLEAN)) dprintk(VIDC_WARN, "CACHE Clean failed: %d, %d, %d\n", Loading Loading @@ -614,7 +614,7 @@ int unmap_and_deregister_buf(struct msm_vidc_inst *inst, dprintk(VIDC_DBG, "[UNMAP] - handle[%d] = %p fd[%d] = %d", i, temp->handle[i], i, temp->fd[i]); msm_smem_free(inst->mem_client, msm_comm_smem_free(inst, temp->handle[i]); } Loading Loading @@ -690,7 +690,7 @@ int output_buffer_cache_invalidate(struct msm_vidc_inst *inst, for (i = 0; i < binfo->num_planes; i++) { if (binfo->handle[i]) { rc = msm_smem_cache_operations(inst->mem_client, rc = msm_comm_smem_cache_operations(inst, binfo->handle[i], SMEM_CACHE_INVALIDATE); if (rc) { dprintk(VIDC_ERR, Loading Loading @@ -776,7 +776,7 @@ int msm_vidc_release_buffers(void *instance, int buffer_type) list_del(&bi->list); for (i = 0; i < bi->num_planes; i++) { if (bi->handle[i]) msm_smem_free(inst->mem_client, msm_comm_smem_free(inst, bi->handle[i]); } kfree(bi); Loading Loading @@ -858,7 +858,7 @@ int msm_vidc_qbuf(void *instance, struct v4l2_buffer *b) if ((inst->fmts[OUTPUT_PORT]->fourcc == V4L2_PIX_FMT_HEVC_HYBRID) && binfo->handle[i] && (b->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)) { rc = msm_smem_cache_operations(inst->mem_client, rc = msm_comm_smem_cache_operations(inst, binfo->handle[i], SMEM_CACHE_INVALIDATE); if (rc) { dprintk(VIDC_ERR, Loading @@ -869,7 +869,7 @@ int msm_vidc_qbuf(void *instance, struct v4l2_buffer *b) if (binfo->handle[i] && (b->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)) { rc = msm_smem_cache_operations(inst->mem_client, rc = msm_comm_smem_cache_operations(inst, binfo->handle[i], SMEM_CACHE_CLEAN); if (rc) { dprintk(VIDC_ERR, Loading Loading @@ -1009,6 +1009,61 @@ int msm_vidc_enum_framesizes(void *instance, struct v4l2_frmsizeenum *fsize) } EXPORT_SYMBOL(msm_vidc_enum_framesizes); struct msm_smem *msm_vidc_smem_alloc(void *instance, size_t size, u32 align, u32 flags, enum hal_buffer buffer_type, int map_kernel) { return msm_comm_smem_alloc((struct msm_vidc_inst *)instance, size, align, flags, buffer_type, map_kernel); } EXPORT_SYMBOL(msm_vidc_smem_alloc); void msm_vidc_smem_free(void *instance, struct msm_smem *mem) { msm_comm_smem_free((struct msm_vidc_inst *)instance, mem); } EXPORT_SYMBOL(msm_vidc_smem_free); int msm_vidc_smem_cache_operations(void *instance, struct msm_smem *mem, enum smem_cache_ops cache_ops) { return msm_comm_smem_cache_operations( (struct msm_vidc_inst *)instance, mem, cache_ops); } EXPORT_SYMBOL(msm_vidc_smem_cache_operations); struct msm_smem *msm_vidc_smem_user_to_kernel(void *instance, int fd, u32 offset, enum hal_buffer buffer_type) { return msm_comm_smem_user_to_kernel( (struct msm_vidc_inst *)instance, fd, offset, buffer_type); } EXPORT_SYMBOL(msm_vidc_smem_user_to_kernel); int msm_vidc_smem_get_domain_partition(void *instance, u32 flags, enum hal_buffer buffer_type, int *domain_num, int *partition_num) { return msm_comm_smem_get_domain_partition( (struct msm_vidc_inst *)instance, flags, buffer_type, domain_num, partition_num); } EXPORT_SYMBOL(msm_vidc_smem_get_domain_partition); void *msm_vidc_smem_get_client(void *instance) { struct msm_vidc_inst *inst = instance; if (!inst || !inst->mem_client) { dprintk(VIDC_ERR, "%s: invalid instance or client = %p %p\n", __func__, inst, inst->mem_client); return NULL; } return inst->mem_client; } static void *vidc_get_userptr(void *alloc_ctx, unsigned long vaddr, unsigned long size, int write) { Loading Loading @@ -1235,7 +1290,7 @@ static void cleanup_instance(struct msm_vidc_inst *inst) list); list_del(&buf->list); mutex_unlock(&inst->lock); msm_smem_free(inst->mem_client, buf->handle); msm_comm_smem_free(inst, buf->handle); kfree(buf); mutex_lock(&inst->lock); } Loading @@ -1246,7 +1301,7 @@ static void cleanup_instance(struct msm_vidc_inst *inst) list); list_del(&buf->list); mutex_unlock(&inst->lock); msm_smem_free(inst->mem_client, buf->handle); msm_comm_smem_free(inst, buf->handle); kfree(buf); mutex_lock(&inst->lock); } Loading @@ -1257,14 +1312,14 @@ static void cleanup_instance(struct msm_vidc_inst *inst) list); list_del(&buf->list); mutex_unlock(&inst->lock); msm_smem_free(inst->mem_client, buf->handle); msm_comm_smem_free(inst, buf->handle); kfree(buf); mutex_lock(&inst->lock); } } if (inst->extradata_handle) { mutex_unlock(&inst->lock); msm_smem_free(inst->mem_client, inst->extradata_handle); msm_comm_smem_free(inst, inst->extradata_handle); mutex_lock(&inst->lock); } mutex_unlock(&inst->lock); Loading Loading @@ -1294,8 +1349,7 @@ int msm_vidc_close(void *instance) for (i = 0; (i < bi->num_planes) && (i < VIDEO_MAX_PLANES); i++) { if (bi->handle[i]) msm_smem_free(inst->mem_client, bi->handle[i]); msm_comm_smem_free(inst, bi->handle[i]); } kfree(bi); } Loading
drivers/media/platform/msm/vidc/msm_vidc_common.c +94 −12 Original line number Diff line number Diff line Loading @@ -2006,7 +2006,7 @@ static int set_output_buffers(struct msm_vidc_inst *inst, if (output_buf->buffer_size) { for (i = 0; i < output_buf->buffer_count_actual; i++) { handle = msm_smem_alloc(inst->mem_client, handle = msm_comm_smem_alloc(inst, buffer_size, 1, smem_flags, buffer_type, 0); if (!handle) { Loading @@ -2015,7 +2015,7 @@ static int set_output_buffers(struct msm_vidc_inst *inst, rc = -ENOMEM; goto err_no_mem; } rc = msm_smem_cache_operations(inst->mem_client, rc = msm_comm_smem_cache_operations(inst, handle, SMEM_CACHE_CLEAN); if (rc) { dprintk(VIDC_WARN, Loading Loading @@ -2060,7 +2060,7 @@ static int set_output_buffers(struct msm_vidc_inst *inst, fail_set_buffers: kfree(binfo); fail_kzalloc: msm_smem_free(inst->mem_client, handle); msm_comm_smem_free(inst, handle); err_no_mem: return rc; } Loading Loading @@ -2097,7 +2097,7 @@ static int set_scratch_buffers(struct msm_vidc_inst *inst, if (scratch_buf->buffer_size) { for (i = 0; i < scratch_buf->buffer_count_actual; i++) { handle = msm_smem_alloc(inst->mem_client, handle = msm_comm_smem_alloc(inst, scratch_buf->buffer_size, 1, smem_flags, buffer_type, 0); if (!handle) { Loading @@ -2106,7 +2106,7 @@ static int set_scratch_buffers(struct msm_vidc_inst *inst, rc = -ENOMEM; goto err_no_mem; } rc = msm_smem_cache_operations(inst->mem_client, rc = msm_comm_smem_cache_operations(inst, handle, SMEM_CACHE_CLEAN); if (rc) { dprintk(VIDC_WARN, Loading Loading @@ -2142,7 +2142,7 @@ static int set_scratch_buffers(struct msm_vidc_inst *inst, fail_set_buffers: kfree(binfo); fail_kzalloc: msm_smem_free(inst->mem_client, handle); msm_comm_smem_free(inst, handle); err_no_mem: return rc; } Loading Loading @@ -2184,7 +2184,7 @@ static int set_persist_buffers(struct msm_vidc_inst *inst, if (persist_buf->buffer_size) { for (i = 0; i < persist_buf->buffer_count_actual; i++) { handle = msm_smem_alloc(inst->mem_client, handle = msm_comm_smem_alloc(inst, persist_buf->buffer_size, 1, smem_flags, buffer_type, 0); if (!handle) { Loading @@ -2193,7 +2193,7 @@ static int set_persist_buffers(struct msm_vidc_inst *inst, rc = -ENOMEM; goto err_no_mem; } rc = msm_smem_cache_operations(inst->mem_client, rc = msm_comm_smem_cache_operations(inst, handle, SMEM_CACHE_CLEAN); if (rc) { dprintk(VIDC_WARN, Loading Loading @@ -2229,7 +2229,7 @@ static int set_persist_buffers(struct msm_vidc_inst *inst, fail_set_buffers: kfree(binfo); fail_kzalloc: msm_smem_free(inst->mem_client, handle); msm_comm_smem_free(inst, handle); err_no_mem: return rc; } Loading Loading @@ -2677,7 +2677,7 @@ int msm_comm_release_output_buffers(struct msm_vidc_inst *inst) } list_del(&buf->list); mutex_unlock(&inst->lock); msm_smem_free(inst->mem_client, buf->handle); msm_comm_smem_free(inst, buf->handle); kfree(buf); mutex_lock(&inst->lock); } Loading Loading @@ -2748,7 +2748,7 @@ int msm_comm_release_scratch_buffers(struct msm_vidc_inst *inst) } list_del(&buf->list); mutex_unlock(&inst->lock); msm_smem_free(inst->mem_client, buf->handle); msm_comm_smem_free(inst, buf->handle); kfree(buf); mutex_lock(&inst->lock); } Loading Loading @@ -2819,7 +2819,7 @@ int msm_comm_release_persist_buffers(struct msm_vidc_inst *inst) } list_del(&buf->list); mutex_unlock(&inst->lock); msm_smem_free(inst->mem_client, buf->handle); msm_comm_smem_free(inst, buf->handle); kfree(buf); mutex_lock(&inst->lock); } Loading Loading @@ -3420,3 +3420,85 @@ int msm_comm_recover_from_session_error(struct msm_vidc_inst *inst) change_inst_state(inst, MSM_VIDC_CLOSE_DONE); return rc; } static inline int power_on_for_smem(struct msm_vidc_inst *inst) { struct hfi_device *hdev = NULL; int rc = 0; if (!inst || !inst->core || !inst->core->device) { dprintk(VIDC_ERR, "%s: invalid inst handle\n", __func__); return -EINVAL; } hdev = inst->core->device; rc = call_hfi_op(hdev, power_enable, hdev->hfi_device_data); if (rc) dprintk(VIDC_ERR, "%s: failed to power on fw\n", __func__); return rc; } struct msm_smem *msm_comm_smem_alloc(struct msm_vidc_inst *inst, size_t size, u32 align, u32 flags, enum hal_buffer buffer_type, int map_kernel) { if (!inst) { dprintk(VIDC_ERR, "%s: invalid inst: %p\n", __func__, inst); return NULL; } if (power_on_for_smem(inst)) return NULL; return msm_smem_alloc(inst->mem_client, size, align, flags, buffer_type, map_kernel); } void msm_comm_smem_free(struct msm_vidc_inst *inst, struct msm_smem *mem) { if (!inst || !mem) { dprintk(VIDC_ERR, "%s: invalid params: %p %p\n", __func__, inst, mem); return; } if (power_on_for_smem(inst)) return; return msm_smem_free(inst->mem_client, mem); } int msm_comm_smem_cache_operations(struct msm_vidc_inst *inst, struct msm_smem *mem, enum smem_cache_ops cache_ops) { if (!inst || !mem) { dprintk(VIDC_ERR, "%s: invalid params: %p %p\n", __func__, inst, mem); return -EINVAL; } return msm_smem_cache_operations(inst->mem_client, mem, cache_ops); } struct msm_smem *msm_comm_smem_user_to_kernel(struct msm_vidc_inst *inst, int fd, u32 offset, enum hal_buffer buffer_type) { if (!inst) { dprintk(VIDC_ERR, "%s: invalid inst: %p\n", __func__, inst); return NULL; } if (power_on_for_smem(inst)) return NULL; return msm_smem_user_to_kernel(inst->mem_client, fd, offset, buffer_type); } int msm_comm_smem_get_domain_partition(struct msm_vidc_inst *inst, u32 flags, enum hal_buffer buffer_type, int *domain_num, int *partition_num) { if (!inst || !domain_num || !partition_num) { dprintk(VIDC_ERR, "%s: invalid params: %p %p %p\n", __func__, inst, domain_num, partition_num); return -EINVAL; } return msm_smem_get_domain_partition(inst->mem_client, flags, buffer_type, domain_num, partition_num); }
drivers/media/platform/msm/vidc/msm_vidc_common.h +11 −1 Original line number Diff line number Diff line Loading @@ -53,5 +53,15 @@ struct hal_buffer_requirements *get_buff_req_buffer( int msm_comm_recover_from_session_error(struct msm_vidc_inst *inst); enum multi_stream msm_comm_get_stream_output_mode(struct msm_vidc_inst *inst); enum hal_buffer msm_comm_get_hal_output_buffer(struct msm_vidc_inst *inst); struct msm_smem *msm_comm_smem_alloc(struct msm_vidc_inst *inst, size_t size, u32 align, u32 flags, enum hal_buffer buffer_type, int map_kernel); void msm_comm_smem_free(struct msm_vidc_inst *inst, struct msm_smem *mem); int msm_comm_smem_cache_operations(struct msm_vidc_inst *inst, struct msm_smem *mem, enum smem_cache_ops cache_ops); struct msm_smem *msm_comm_smem_user_to_kernel(struct msm_vidc_inst *inst, int fd, u32 offset, enum hal_buffer buffer_type); int msm_comm_smem_get_domain_partition(struct msm_vidc_inst *inst, u32 flags, enum hal_buffer buffer_type, int *domain_num, int *partition_num); #endif
drivers/media/platform/msm/vidc/venus_hfi.c +46 −19 Original line number Diff line number Diff line Loading @@ -75,6 +75,8 @@ struct tzbsp_video_set_state_req { u32 spare; /*reserved for future, should be zero*/ }; static int venus_hfi_power_enable(void *dev); static void venus_hfi_dump_packet(u8 *packet) { u32 c = 0, packet_size = *(u32 *)packet; Loading Loading @@ -435,21 +437,24 @@ static int venus_hfi_read_queue(void *info, u8 *packet, u32 *pb_tx_req_is_set) return rc; } static int venus_hfi_alloc(void *mem, void *clnt, u32 size, u32 align, u32 flags, u32 usage) static int venus_hfi_alloc(struct venus_hfi_device *dev, void *mem, u32 size, u32 align, u32 flags, u32 usage) { struct vidc_mem_addr *vmem; struct msm_smem *alloc; struct vidc_mem_addr *vmem = NULL; struct msm_smem *alloc = NULL; int rc = 0; if (!mem || !clnt || !size) { if (!dev || !dev->hal_client || !mem || !size) { dprintk(VIDC_ERR, "Invalid Params"); return -EINVAL; } vmem = (struct vidc_mem_addr *)mem; dprintk(VIDC_INFO, "start to alloc: size:%d, Flags: %d", size, flags); alloc = msm_smem_alloc(clnt, size, align, flags, usage, 1); venus_hfi_power_enable(dev); alloc = msm_smem_alloc(dev->hal_client, size, align, flags, usage, 1); dprintk(VIDC_DBG, "Alloc done"); if (!alloc) { dprintk(VIDC_ERR, "Alloc failed\n"); Loading @@ -458,7 +463,7 @@ static int venus_hfi_alloc(void *mem, void *clnt, u32 size, u32 align, } dprintk(VIDC_DBG, "venus_hfi_alloc:ptr=%p,size=%d", alloc->kvaddr, size); rc = msm_smem_cache_operations(clnt, alloc, rc = msm_smem_cache_operations(dev->hal_client, alloc, SMEM_CACHE_CLEAN); if (rc) { dprintk(VIDC_WARN, "Failed to clean cache\n"); Loading @@ -473,9 +478,14 @@ fail_smem_alloc: return rc; } static void venus_hfi_free(struct smem_client *clnt, struct msm_smem *mem) static void venus_hfi_free(struct venus_hfi_device *dev, struct msm_smem *mem) { msm_smem_free(clnt, mem); if (!dev || !mem) { dprintk(VIDC_ERR, "invalid param %p %p\n", dev, mem); return; } venus_hfi_power_enable(dev); msm_smem_free(dev->hal_client, mem); } static void venus_hfi_write_register(struct venus_hfi_device *device, u32 reg, Loading Loading @@ -1012,6 +1022,22 @@ err_scale_buses: return rc; } static int venus_hfi_power_enable(void *dev) { int rc = 0; struct venus_hfi_device *device = dev; if (!device) { dprintk(VIDC_ERR, "Invalid params: %p\n", device); return -EINVAL; } mutex_lock(&device->clk_pwr_lock); if (!device->power_enabled) rc = venus_hfi_power_on(device); mutex_unlock(&device->clk_pwr_lock); return rc; } static void venus_hfi_pm_hndlr(struct work_struct *work); static DECLARE_DELAYED_WORK(venus_hfi_pm_work, venus_hfi_pm_hndlr); Loading Loading @@ -1269,10 +1295,10 @@ static void venus_hfi_interface_queues_release(struct venus_hfi_device *device) (unsigned long)(mem_map[i].virtual_addr), domain, partition, SZ_4K); } venus_hfi_free(device->hal_client, device->qdss.mem_data); venus_hfi_free(device, device->qdss.mem_data); } venus_hfi_free(device->hal_client, device->iface_q_table.mem_data); venus_hfi_free(device->hal_client, device->sfr.mem_data); venus_hfi_free(device, device->iface_q_table.mem_data); venus_hfi_free(device, device->sfr.mem_data); for (i = 0; i < VIDC_IFACEQ_NUMQ; i++) { device->iface_queues[i].q_hdr = NULL; Loading Loading @@ -1348,8 +1374,8 @@ static int venus_hfi_interface_queues_init(struct venus_hfi_device *dev) int num_entries = sizeof(venus_qdss_entries)/(2 * sizeof(u32)); int domain, partition; mem_addr = &dev->mem_addr; rc = venus_hfi_alloc((void *) mem_addr, dev->hal_client, QUEUE_SIZE, 1, 0, rc = venus_hfi_alloc(dev, (void *) mem_addr, QUEUE_SIZE, 1, 0, HAL_BUFFER_INTERNAL_CMD_QUEUE); if (rc) { dprintk(VIDC_ERR, "iface_q_table_alloc_fail"); Loading @@ -1375,8 +1401,8 @@ static int venus_hfi_interface_queues_init(struct venus_hfi_device *dev) venus_hfi_set_queue_hdr_defaults(iface_q->q_hdr); } rc = venus_hfi_alloc((void *) mem_addr, dev->hal_client, QDSS_SIZE, 1, 0, rc = venus_hfi_alloc(dev, (void *) mem_addr, QDSS_SIZE, 1, 0, HAL_BUFFER_INTERNAL_CMD_QUEUE); if (rc) { dprintk(VIDC_WARN, Loading @@ -1388,8 +1414,8 @@ static int venus_hfi_interface_queues_init(struct venus_hfi_device *dev) dev->qdss.mem_size = QDSS_SIZE; dev->qdss.mem_data = mem_addr->mem_data; } rc = venus_hfi_alloc((void *) mem_addr, dev->hal_client, SFR_SIZE, 1, 0, rc = venus_hfi_alloc(dev, (void *) mem_addr, SFR_SIZE, 1, 0, HAL_BUFFER_INTERNAL_CMD_QUEUE); if (rc) { dprintk(VIDC_WARN, "sfr_alloc_fail: SFR not will work"); Loading Loading @@ -1454,7 +1480,7 @@ static int venus_hfi_interface_queues_init(struct venus_hfi_device *dev) if (rc) { dprintk(VIDC_ERR, "IOMMU mapping failed, Freeing qdss memdata"); venus_hfi_free(dev->hal_client, dev->qdss.mem_data); venus_hfi_free(dev, dev->qdss.mem_data); dev->qdss.mem_data = NULL; } if (!IS_ERR_OR_NULL(dev->qdss.align_device_addr)) Loading Loading @@ -3676,6 +3702,7 @@ static void venus_init_hfi_callbacks(struct hfi_device *hdev) hdev->get_stride_scanline = venus_hfi_get_stride_scanline; hdev->capability_check = venus_hfi_capability_check; hdev->get_core_capabilities = venus_hfi_get_core_capabilities; hdev->power_enable = venus_hfi_power_enable; } int venus_hfi_initialize(struct hfi_device *hdev, u32 device_id, Loading
drivers/media/platform/msm/vidc/vidc_hfi_api.h +1 −0 Original line number Diff line number Diff line Loading @@ -1190,6 +1190,7 @@ struct hfi_device { u32 *max_width, u32 *max_height); int (*session_clean)(void *sess); int (*get_core_capabilities)(void); int (*power_enable)(void *dev); }; typedef void (*hfi_cmd_response_callback) (enum command_response cmd, Loading