|
@@ -2547,33 +2547,6 @@ int msm_vidc_process_readonly_buffers(struct msm_vidc_inst *inst,
|
|
return rc;
|
|
return rc;
|
|
}
|
|
}
|
|
|
|
|
|
-int msm_vidc_memory_unmap_completely(struct msm_vidc_inst *inst,
|
|
|
|
- struct msm_vidc_map *map)
|
|
|
|
-{
|
|
|
|
- int rc = 0;
|
|
|
|
-
|
|
|
|
- if (!inst || !map) {
|
|
|
|
- d_vpr_e("%s: invalid params\n", __func__);
|
|
|
|
- return -EINVAL;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (!map->refcount)
|
|
|
|
- return 0;
|
|
|
|
-
|
|
|
|
- while (map->refcount) {
|
|
|
|
- rc = msm_vidc_memory_unmap(inst->core, map);
|
|
|
|
- if (rc)
|
|
|
|
- break;
|
|
|
|
- if (!map->refcount) {
|
|
|
|
- msm_vidc_memory_put_dmabuf(inst, map->dmabuf);
|
|
|
|
- list_del(&map->list);
|
|
|
|
- msm_memory_pool_free(inst, map);
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return rc;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
int msm_vidc_set_auto_framerate(struct msm_vidc_inst *inst, u64 timestamp)
|
|
int msm_vidc_set_auto_framerate(struct msm_vidc_inst *inst, u64 timestamp)
|
|
{
|
|
{
|
|
struct msm_vidc_core *core;
|
|
struct msm_vidc_core *core;
|
|
@@ -2978,159 +2951,6 @@ int msm_vidc_ts_reorder_flush(struct msm_vidc_inst *inst)
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
-int msm_vidc_get_delayed_unmap(struct msm_vidc_inst *inst, struct msm_vidc_map *map)
|
|
|
|
-{
|
|
|
|
- int rc = 0;
|
|
|
|
-
|
|
|
|
- if (!inst || !map) {
|
|
|
|
- d_vpr_e("%s: invalid params\n", __func__);
|
|
|
|
- return -EINVAL;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- rc = msm_vidc_memory_map(inst->core, map);
|
|
|
|
- if (rc)
|
|
|
|
- return rc;
|
|
|
|
- map->skip_delayed_unmap = 1;
|
|
|
|
-
|
|
|
|
- return 0;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-int msm_vidc_put_delayed_unmap(struct msm_vidc_inst *inst, struct msm_vidc_map *map)
|
|
|
|
-{
|
|
|
|
- int rc = 0;
|
|
|
|
-
|
|
|
|
- if (!inst || !map) {
|
|
|
|
- d_vpr_e("%s: invalid params\n", __func__);
|
|
|
|
- return -EINVAL;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (!map->skip_delayed_unmap) {
|
|
|
|
- i_vpr_e(inst, "%s: no delayed unmap, addr %#llx\n",
|
|
|
|
- __func__, map->device_addr);
|
|
|
|
- return -EINVAL;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- map->skip_delayed_unmap = 0;
|
|
|
|
- rc = msm_vidc_memory_unmap(inst->core, map);
|
|
|
|
- if (rc)
|
|
|
|
- i_vpr_e(inst, "%s: unmap failed\n", __func__);
|
|
|
|
-
|
|
|
|
- return rc;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-int msm_vidc_unmap_driver_buf(struct msm_vidc_inst *inst,
|
|
|
|
- struct msm_vidc_buffer *buf)
|
|
|
|
-{
|
|
|
|
- int rc = 0;
|
|
|
|
- struct msm_vidc_mappings *mappings;
|
|
|
|
- struct msm_vidc_map *map = NULL;
|
|
|
|
- bool found = false;
|
|
|
|
-
|
|
|
|
- if (!inst || !buf) {
|
|
|
|
- d_vpr_e("%s: invalid params\n", __func__);
|
|
|
|
- return -EINVAL;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- mappings = msm_vidc_get_mappings(inst, buf->type, __func__);
|
|
|
|
- if (!mappings)
|
|
|
|
- return -EINVAL;
|
|
|
|
-
|
|
|
|
- /* sanity check to see if it was not removed */
|
|
|
|
- list_for_each_entry(map, &mappings->list, list) {
|
|
|
|
- if (map->dmabuf == buf->dmabuf) {
|
|
|
|
- found = true;
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (!found) {
|
|
|
|
- print_vidc_buffer(VIDC_ERR, "err ", "no buf in mappings", inst, buf);
|
|
|
|
- return -EINVAL;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- rc = msm_vidc_memory_unmap(inst->core, map);
|
|
|
|
- if (rc) {
|
|
|
|
- print_vidc_buffer(VIDC_ERR, "err ", "unmap failed", inst, buf);
|
|
|
|
- return -EINVAL;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /* finally delete if refcount is zero */
|
|
|
|
- if (!map->refcount) {
|
|
|
|
- msm_vidc_memory_put_dmabuf(inst, map->dmabuf);
|
|
|
|
- list_del(&map->list);
|
|
|
|
- msm_memory_pool_free(inst, map);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return rc;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-int msm_vidc_map_driver_buf(struct msm_vidc_inst *inst,
|
|
|
|
- struct msm_vidc_buffer *buf)
|
|
|
|
-{
|
|
|
|
- int rc = 0;
|
|
|
|
- struct msm_vidc_mappings *mappings;
|
|
|
|
- struct msm_vidc_map *map;
|
|
|
|
- bool found = false;
|
|
|
|
-
|
|
|
|
- if (!inst || !buf) {
|
|
|
|
- d_vpr_e("%s: invalid params\n", __func__);
|
|
|
|
- return -EINVAL;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- mappings = msm_vidc_get_mappings(inst, buf->type, __func__);
|
|
|
|
- if (!mappings)
|
|
|
|
- return -EINVAL;
|
|
|
|
-
|
|
|
|
- /*
|
|
|
|
- * new buffer: map twice for delayed unmap feature sake
|
|
|
|
- * existing buffer: map once
|
|
|
|
- */
|
|
|
|
- list_for_each_entry(map, &mappings->list, list) {
|
|
|
|
- if (map->dmabuf == buf->dmabuf) {
|
|
|
|
- found = true;
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (!found) {
|
|
|
|
- /* new buffer case */
|
|
|
|
- map = msm_memory_pool_alloc(inst, MSM_MEM_POOL_MAP);
|
|
|
|
- if (!map) {
|
|
|
|
- i_vpr_e(inst, "%s: alloc failed\n", __func__);
|
|
|
|
- return -ENOMEM;
|
|
|
|
- }
|
|
|
|
- INIT_LIST_HEAD(&map->list);
|
|
|
|
- list_add_tail(&map->list, &mappings->list);
|
|
|
|
- map->type = buf->type;
|
|
|
|
- map->dmabuf = msm_vidc_memory_get_dmabuf(inst, buf->fd);
|
|
|
|
- if (!map->dmabuf) {
|
|
|
|
- rc = -EINVAL;
|
|
|
|
- goto error;
|
|
|
|
- }
|
|
|
|
- map->region = msm_vidc_get_buffer_region(inst, buf->type, __func__);
|
|
|
|
- /* delayed unmap feature needed for decoder output buffers */
|
|
|
|
- if (is_decode_session(inst) && is_output_buffer(buf->type)) {
|
|
|
|
- rc = msm_vidc_get_delayed_unmap(inst, map);
|
|
|
|
- if (rc)
|
|
|
|
- goto error;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- rc = msm_vidc_memory_map(inst->core, map);
|
|
|
|
- if (rc)
|
|
|
|
- goto error;
|
|
|
|
-
|
|
|
|
- buf->device_addr = map->device_addr;
|
|
|
|
-
|
|
|
|
- return 0;
|
|
|
|
-error:
|
|
|
|
- if (!found) {
|
|
|
|
- if (is_decode_session(inst) && is_output_buffer(buf->type))
|
|
|
|
- msm_vidc_put_delayed_unmap(inst, map);
|
|
|
|
- msm_vidc_memory_put_dmabuf(inst, map->dmabuf);
|
|
|
|
- list_del_init(&map->list);
|
|
|
|
- msm_memory_pool_free(inst, map);
|
|
|
|
- }
|
|
|
|
- return rc;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
struct msm_vidc_buffer *msm_vidc_get_driver_buf(struct msm_vidc_inst *inst,
|
|
struct msm_vidc_buffer *msm_vidc_get_driver_buf(struct msm_vidc_inst *inst,
|
|
struct vb2_buffer *vb2)
|
|
struct vb2_buffer *vb2)
|
|
{
|
|
{
|