}
trace_mfc_node_open(ctx->num, dev->num_inst, ctx->type, ctx->is_drm);
- mfc_info_ctx("MFC open completed [%d:%d] dev = %p, ctx = %p, version = %d\n",
+ mfc_info_ctx("MFC open completed [%d:%d] dev = 0x%p, ctx = 0x%p, version = %d\n",
dev->num_drm_inst, dev->num_inst, dev, ctx, MFC_DRIVER_INFO);
mutex_unlock(&dev->mfc_mutex);
return ret;
dev->ctx[ctx->num] = 0;
kfree(ctx);
- mfc_info_dev("mfc driver release finished [%d:%d], dev = %p\n",
+ mfc_info_dev("mfc driver release finished [%d:%d], dev = 0x%p\n",
dev->num_drm_inst, dev->num_inst, dev);
if (s5p_mfc_is_work_to_do(dev))
dev->mfc_trace = g_mfc_trace;
dev->mfc_trace_hwlock = g_mfc_trace_hwlock;
+ dma_set_mask(&pdev->dev, DMA_BIT_MASK(36));
+
s5p_mfc_pm_init(dev);
ret = mfc_register_resource(pdev, dev);
if (ret)
}
INIT_WORK(&dev->butler_work, s5p_mfc_butler_worker);
-#ifdef CONFIG_ION_EXYNOS
- dev->mfc_ion_client = exynos_ion_client_create("mfc");
- if (IS_ERR(dev->mfc_ion_client)) {
- dev_err(&pdev->dev, "failed to ion_client_create\n");
- goto err_ion_client;
- }
-#endif
-
#ifdef CONFIG_MFC_USE_BUS_DEVFREQ
atomic_set(&dev->qos_req_cur, 0);
err_alloc_debug:
iovmm_deactivate(&pdev->dev);
err_iovmm_active:
-#ifdef CONFIG_ION_EXYNOS
- ion_client_destroy(dev->mfc_ion_client);
-err_ion_client:
-#endif
destroy_workqueue(dev->butler_wq);
err_butler_wq:
destroy_workqueue(dev->watchdog_wq);
remove_proc_entry(MFC_PROC_ROOT, NULL);
#endif
s5p_mfc_destroy_listable_wq_dev(dev);
-#ifdef CONFIG_ION_EXYNOS
- ion_client_destroy(dev->mfc_ion_client);
-#endif
iovmm_deactivate(&pdev->dev);
mfc_debug(2, "Will now deinit HW\n");
s5p_mfc_deinit_hw(dev);
firmware_size = dev->variant->buf_size->firmware_code;
- ctx_buf->handle = NULL;
+ ctx_buf->dma_buf = NULL;
ctx_buf->vaddr = NULL;
ctx_buf->daddr = fw_daddr + firmware_size;
ctx_buf = &dev->drm_common_ctx_buf;
#endif
- ctx_buf->handle = NULL;
+ ctx_buf->dma_buf = NULL;
ctx_buf->vaddr = NULL;
ctx_buf->daddr = 0;
}
return -ENOMEM;
}
- ctx->instance_ctx_buf.vaddr = s5p_mfc_mem_get_vaddr(dev, &ctx->instance_ctx_buf);
-
- if (!ctx->instance_ctx_buf.vaddr) {
- mfc_err_dev("failed to get instance ctx buffer vaddr\n");
- s5p_mfc_mem_ion_free(dev, &ctx->instance_ctx_buf);
- return -ENOMEM;
- }
-
mfc_debug(2, "Instance buf alloc, ctx: %d, size: %ld, addr: 0x%08llx\n",
ctx->num, ctx->instance_ctx_buf.size, ctx->instance_ctx_buf.daddr);
mfc_err_ctx("Allocating codec buffer failed\n");
return -ENOMEM;
}
-
- ctx->codec_buf.vaddr = s5p_mfc_mem_get_vaddr(dev, &ctx->codec_buf);
- if (!ctx->codec_buf.vaddr) {
- mfc_err_dev("failed to get codec buffer vaddr\n");
- s5p_mfc_mem_ion_free(dev, &ctx->codec_buf);
- return -ENOMEM;
- }
ctx->codec_buffer_allocated = 1;
} else if (ctx->codec_mode == S5P_FIMV_CODEC_MPEG2_DEC) {
ctx->codec_buffer_allocated = 1;
mfc_err_dev("Allocating debug info buffer failed\n");
return -ENOMEM;
}
- mfc_debug(2, "dev->dbg_info_buf.daddr = 0x%08llx\n",
- dev->dbg_info_buf.daddr);
-
- dev->dbg_info_buf.vaddr = s5p_mfc_mem_get_vaddr(dev, &dev->dbg_info_buf);
- if (!dev->dbg_info_buf.vaddr) {
- mfc_err_dev("failed to get debug info buffer vaddr\n");
- s5p_mfc_mem_ion_free(dev, &dev->dbg_info_buf);
- return -ENOMEM;
- }
- mfc_debug(2, "dev->dbg_info_buf.vaddr = 0x%p\n",
- dev->dbg_info_buf.vaddr);
+ mfc_debug(2, "dev->dbg_info_buf.daddr = 0x%08llx, vaddr = 0x%p\n",
+ dev->dbg_info_buf.daddr, dev->dbg_info_buf.vaddr);
return 0;
}
return -EINVAL;
}
- if (!dev->dbg_info_buf.handle) {
+ if (!dev->dbg_info_buf.dma_buf) {
mfc_debug(2, "debug info buffer is already freed\n");
return 0;
}
mfc_err_ctx("Allocating ROI buffer failed\n");
return -ENOMEM;
}
- mfc_debug(2, "roi_buf.daddr = 0x%08llx\n", roi_buf->daddr);
-
- roi_buf->vaddr = s5p_mfc_mem_get_vaddr(dev, roi_buf);
- if (!roi_buf->vaddr) {
- mfc_err_dev("failed to get ROI buffer vaddr\n");
- s5p_mfc_mem_ion_free(dev, roi_buf);
- return -ENOMEM;
- }
+ mfc_debug(2, "roi_buf.daddr = 0x%08llx, vaddr = 0x%p\n",
+ roi_buf->daddr, roi_buf->vaddr);
memset(roi_buf->vaddr, 0, buf_size->shared_buf);
int i;
for (i = 0; i < MFC_MAX_EXTRA_BUF; i++)
- if (enc->roi_buf[i].handle)
+ if (enc->roi_buf[i].dma_buf)
s5p_mfc_mem_ion_free(ctx->dev, &enc->roi_buf[i]);
}
mfc_err_ctx("OTF: Allocating stream buffer failed\n");
return -EINVAL;
}
- buf->vaddr = s5p_mfc_mem_get_vaddr(dev, buf);
- if (!buf->vaddr) {
- mfc_err_dev("OTF: failed to get stream buffer vaddr\n");
- s5p_mfc_mem_ion_free(dev, buf);
- return -EINVAL;
- }
memset(buf->vaddr, 0, raw->total_plane_size);
}
for (i = 0; i < OTF_MAX_BUF; i++) {
buf = &debug->stream_buf[i];
- if (buf->handle)
+ if (buf->dma_buf)
s5p_mfc_mem_ion_free(dev, buf);
}
firmware_size = dev->variant->buf_size->firmware_code;
dev->fw.size = firmware_size + buf_size->dev_ctx;
- if (dev->fw_buf.handle)
+ if (dev->fw_buf.dma_buf)
return 0;
mfc_debug(2, "Allocating memory for firmware.\n");
return -ENOMEM;
}
- dev->fw_buf.vaddr = s5p_mfc_mem_get_vaddr(dev, &dev->fw_buf);
- if (!dev->fw_buf.vaddr) {
- mfc_err_dev("failed to get normal firmware buffer vaddr\n");
- s5p_mfc_mem_ion_free(dev, &dev->fw_buf);
- return -EIO;
- }
mfc_debug(2, "FW normal: 0x%08llx (vaddr: 0x%p), size: %08zu\n",
dev->fw_buf.daddr, dev->fw_buf.vaddr,
dev->fw_buf.size);
return -ENOMEM;
}
- dev->drm_fw_buf.vaddr = s5p_mfc_mem_get_vaddr(dev, &dev->drm_fw_buf);
- if (!dev->drm_fw_buf.vaddr) {
- mfc_err_dev("failed to get DRM firmware buffer vaddr\n");
- s5p_mfc_mem_ion_free(dev, &dev->fw_buf);
- s5p_mfc_mem_ion_free(dev, &dev->drm_fw_buf);
- return -EIO;
- }
-
mfc_debug(2, "FW DRM: 0x%08llx (vaddr: 0x%p), size: %08zu\n",
dev->drm_fw_buf.daddr, dev->drm_fw_buf.vaddr,
dev->drm_fw_buf.size);
return -ENOMEM;
}
- if (dev->fw_buf.handle == NULL || dev->fw_buf.daddr == 0) {
+ if (dev->fw_buf.dma_buf == NULL || dev->fw_buf.daddr == 0) {
mfc_err_dev("MFC firmware is not allocated or was not mapped correctly.\n");
release_firmware(fw_blob);
return -EINVAL;
return -EINVAL;
}
- if (!dev->fw_buf.handle) {
+ if (!dev->fw_buf.dma_buf) {
mfc_err_dev("firmware memory is already freed\n");
return -EINVAL;
}
/* Header was generated now starting processing
* First set the reference frame buffers
*/
- if (!ctx->codec_buf.handle) {
+ if (!ctx->codec_buf.dma_buf) {
mfc_info_ctx("there isn't codec buffer, re-alloc!\n");
ret = s5p_mfc_alloc_codec_buffers(ctx);
if (ret) {
#include <linux/io.h>
#include <linux/slab.h>
#include <linux/sched/clock.h>
-#include <linux/exynos_ion.h>
+#include <linux/ion_exynos.h>
#include <media/videobuf2-dma-sg.h>
#include <asm/cacheflush.h>
curr_ctx_is_drm_backup = dev->curr_ctx_is_drm;
- if (!dev->fw_buf.handle)
+ if (!dev->fw_buf.dma_buf)
return -EINVAL;
/* 0. MFC reset */
*/
struct s5p_mfc_special_buf {
enum mfc_buf_usage_type buftype;
- struct ion_handle *handle;
struct dma_buf *dma_buf;
struct dma_buf_attachment *attachment;
struct sg_table *sgt;
struct video_device *vfd_enc_otf;
struct video_device *vfd_enc_otf_drm;
struct device *device;
-#ifdef CONFIG_ION_EXYNOS
- struct ion_client *mfc_ion_client;
-#endif
void __iomem *regs_base;
void __iomem *sysmmu0_base;
struct mfc_user_shared_handle {
int fd;
- struct ion_handle *ion_handle;
+ struct dma_buf *dma_buf;
void *vaddr;
};
int ncount = 0;
mfc_debug_enter();
- mfc_debug(2, "Addr: %p %p %p Type: %d\n", &ctx->vq_src, buf, buf->m.planes,
+ mfc_debug(2, "Addr: 0x%p 0x%p 0x%p Type: %d\n", &ctx->vq_src, buf, buf->m.planes,
buf->type);
if (ctx->state == MFCINST_ERROR) {
mfc_err_ctx("Call on DQBUF after unrecoverable error.\n");
mfc_err_dev("is_dynamic_dpb is 0. it has to be enabled.\n");
break;
case V4L2_CID_MPEG_MFC_SET_USER_SHARED_HANDLE:
- dec->sh_handle.fd = ctrl->value;
- if (s5p_mfc_mem_get_user_shared_handle(ctx, &dec->sh_handle)) {
- dec->sh_handle.fd = -1;
- return -EINVAL;
+ if (dec->sh_handle.fd == -1) {
+ dec->sh_handle.fd = ctrl->value;
+ if (s5p_mfc_mem_get_user_shared_handle(ctx, &dec->sh_handle))
+ return -EINVAL;
}
break;
case V4L2_CID_MPEG_MFC_SET_BUF_PROCESS_TYPE:
}
if (vq->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
- mfc_debug(2, "Src queue: %p\n", &ctx->src_buf_queue);
- mfc_debug(2, "Adding to src: %p (0x%08llx, 0x%08llx)\n", vb,
+ mfc_debug(2, "Src queue: 0x%p\n", &ctx->src_buf_queue);
+ mfc_debug(2, "Adding to src: 0x%p (0x%08llx, 0x%08llx)\n", vb,
s5p_mfc_mem_get_daddr_vb(vb, 0),
buf->addr[0]);
if (dec->dst_memtype == V4L2_MEMORY_DMABUF &&
vb->index, vb->planes[0].m.fd, buf->addr[0]);
} else if (vq->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
index = vb->index;
- mfc_debug(2, "Dst queue: %p\n", &ctx->dst_buf_queue);
- mfc_debug(2, "Adding to dst: %p (0x%08llx)\n", vb,
+ mfc_debug(2, "Dst queue: 0x%p\n", &ctx->dst_buf_queue);
+ mfc_debug(2, "Adding to dst: 0x%p (0x%08llx)\n", vb,
s5p_mfc_mem_get_daddr_vb(vb, 0));
for (i = 0; i < ctx->dst_fmt->num_planes; i++)
mfc_debug(2, "dec dst plane[%d]: %08llx\n",
return 0;
}
- mfc_debug(2, "Addr: %p %p %p Type: %d\n", &ctx->vq_src, buf, buf->m.planes,
+ mfc_debug(2, "Addr: 0x%p 0x%p 0x%p Type: %d\n", &ctx->vq_src, buf, buf->m.planes,
buf->type);
if (ctx->state == MFCINST_ERROR) {
mfc_err_ctx("Call on DQBUF after unrecoverable error.\n");
(enc->sh_handle_svc.fd == -1)) {
enc->sh_handle_svc.fd = ctrl->value;
if (s5p_mfc_mem_get_user_shared_handle(ctx,
- &enc->sh_handle_svc)) {
- enc->sh_handle_svc.fd = -1;
+ &enc->sh_handle_svc))
return -EINVAL;
- }
}
if (ctx_ctrl->id == V4L2_CID_MPEG_MFC51_VIDEO_I_PERIOD_CH &&
p->i_frm_ctrl_mode) {
ctx_ctrl->val = mfc_enc_h264_level((enum v4l2_mpeg_video_h264_level)(ctrl->value));
if (ctx_ctrl->id == V4L2_CID_MPEG_VIDEO_H264_PROFILE)
ctx_ctrl->val = mfc_enc_h264_profile(ctx, (enum v4l2_mpeg_video_h264_profile)(ctrl->value));
- if (ctx_ctrl->id == \
- V4L2_CID_MPEG_VIDEO_ROI_CONTROL) {
- enc->sh_handle_roi.fd = ctrl->value;
- if (s5p_mfc_mem_get_user_shared_handle(ctx,
- &enc->sh_handle_roi)) {
- enc->sh_handle_roi.fd = -1;
- return -EINVAL;
+ if (ctx_ctrl->id == V4L2_CID_MPEG_VIDEO_ROI_CONTROL) {
+ if (enc->sh_handle_roi.fd == -1) {
+ enc->sh_handle_roi.fd = ctrl->value;
+ if (s5p_mfc_mem_get_user_shared_handle(ctx,
+ &enc->sh_handle_roi))
+ return -EINVAL;
}
index = enc->roi_index;
memcpy(&enc->roi_info[index],
mfc_debug_enter();
if (vq->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
- mfc_debug(2, "dst queue: %p\n", &ctx->dst_buf_queue);
- mfc_debug(2, "Adding to dst vb: %p, addr: %08llx\n", vb, buf->addr[0]);
+ mfc_debug(2, "dst queue: 0x%p\n", &ctx->dst_buf_queue);
+ mfc_debug(2, "Adding to dst vb: 0x%p, addr: %08llx\n", vb, buf->addr[0]);
/* Mark destination as available for use by MFC */
s5p_mfc_add_tail_buf(&ctx->buf_queue_lock, &ctx->dst_buf_queue, buf);
mfc_err_dev("no mfc device to run\n");
return;
}
- mfc_debug(2, "Try run dev: %p\n", dev);
+ mfc_debug(2, "Try run dev: 0x%p\n", dev);
spin_lock_irqsave(&dev->hwlock.lock, flags);
mfc_print_hwlock(dev);
int s5p_mfc_mem_get_user_shared_handle(struct s5p_mfc_ctx *ctx,
struct mfc_user_shared_handle *handle)
{
- struct s5p_mfc_dev *dev = ctx->dev;
int ret = 0;
- handle->ion_handle =
- ion_import_dma_buf_fd(dev->mfc_ion_client, handle->fd);
- if (IS_ERR(handle->ion_handle)) {
+ handle->dma_buf = dma_buf_get(handle->fd);
+ if (IS_ERR(handle->dma_buf)) {
mfc_err_ctx("Failed to import fd\n");
- ret = PTR_ERR(handle->ion_handle);
+ ret = PTR_ERR(handle->dma_buf);
goto import_dma_fail;
}
- handle->vaddr =
- ion_map_kernel(dev->mfc_ion_client, handle->ion_handle);
+ handle->vaddr = dma_buf_vmap(handle->dma_buf);
if (handle->vaddr == NULL) {
mfc_err_ctx("Failed to get kernel virtual address\n");
ret = -EINVAL;
return 0;
map_kernel_fail:
- ion_free(dev->mfc_ion_client, handle->ion_handle);
+ handle->vaddr = NULL;
+ dma_buf_put(handle->dma_buf);
import_dma_fail:
+ handle->dma_buf = NULL;
+ handle->fd = -1;
return ret;
}
-int s5p_mfc_mem_cleanup_user_shared_handle(struct s5p_mfc_ctx *ctx,
+void s5p_mfc_mem_cleanup_user_shared_handle(struct s5p_mfc_ctx *ctx,
struct mfc_user_shared_handle *handle)
{
- struct s5p_mfc_dev *dev = ctx->dev;
-
- if (handle->fd == -1)
- return 0;
-
if (handle->vaddr)
- ion_unmap_kernel(dev->mfc_ion_client,
- handle->ion_handle);
-
- ion_free(dev->mfc_ion_client, handle->ion_handle);
-
- return 0;
-}
+ dma_buf_vunmap(handle->dma_buf, handle->vaddr);
+ if (handle->dma_buf)
+ dma_buf_put(handle->dma_buf);
-void *s5p_mfc_mem_get_vaddr(struct s5p_mfc_dev *dev,
- struct s5p_mfc_special_buf *special_buf)
-{
- return ion_map_kernel(dev->mfc_ion_client, special_buf->handle);
-}
-
-void s5p_mfc_mem_ion_free(struct s5p_mfc_dev *dev,
- struct s5p_mfc_special_buf *special_buf)
-{
- if (!special_buf->handle)
- return;
-
- if (special_buf->daddr)
- ion_iovmm_unmap(special_buf->attachment, special_buf->daddr);
-
- if (special_buf->handle) {
- dma_buf_unmap_attachment(special_buf->attachment,
- special_buf->sgt, DMA_BIDIRECTIONAL);
- dma_buf_detach(special_buf->dma_buf, special_buf->attachment);
- dma_buf_put(special_buf->dma_buf);
- ion_free(dev->mfc_ion_client, special_buf->handle);
- }
-
- memset(&special_buf->handle, 0, sizeof(struct ion_handle *));
- memset(&special_buf->daddr, 0, sizeof(special_buf->daddr));
-
- special_buf->handle = NULL;
- special_buf->dma_buf = NULL;
- special_buf->attachment = NULL;
- special_buf->sgt = NULL;
- special_buf->daddr = 0;
- special_buf->vaddr = NULL;
+ handle->dma_buf = NULL;
+ handle->vaddr = NULL;
+ handle->fd = -1;
}
int s5p_mfc_mem_ion_alloc(struct s5p_mfc_dev *dev,
struct s5p_mfc_special_buf *special_buf)
{
struct s5p_mfc_ctx *ctx = dev->ctx[dev->curr_ctx];
- int ion_mask, flag;
+ int flag;
+ const char *heapname;
switch (special_buf->buftype) {
case MFCBUF_NORMAL:
- ion_mask = EXYNOS_ION_HEAP_SYSTEM_MASK;
+ heapname = "ion_system_heap";
flag = 0;
break;
case MFCBUF_NORMAL_FW:
- ion_mask = EXYNOS_ION_HEAP_VIDEO_NFW_MASK;
+ heapname = "vnfw_heap";
flag = 0;
break;
case MFCBUF_DRM:
- ion_mask = EXYNOS_ION_HEAP_VIDEO_FRAME_MASK;
+ heapname = "vframe_heap";
flag = ION_FLAG_PROTECTED;
break;
case MFCBUF_DRM_FW:
- ion_mask = EXYNOS_ION_HEAP_VIDEO_FW_MASK;
+ heapname = "vfw_heap";
flag = ION_FLAG_PROTECTED;
break;
default:
- mfc_err_ctx("not supported mfc mem type: %d\n",
- special_buf->buftype);
+ mfc_err_ctx("not supported mfc mem type: %d, heapname: %s\n",
+ special_buf->buftype, heapname);
return -EINVAL;
}
- special_buf->handle = ion_alloc(dev->mfc_ion_client,
- special_buf->size, 0, ion_mask, flag);
- if (IS_ERR(special_buf->handle)) {
- mfc_err_ctx("Failed to allocate buffer (err %ld)",
- PTR_ERR(special_buf->handle));
- special_buf->handle = NULL;
- goto err_ion_alloc;
- }
-
- special_buf->dma_buf = ion_share_dma_buf(dev->mfc_ion_client,
- special_buf->handle);
+ special_buf->dma_buf =
+ ion_alloc_dmabuf(heapname, special_buf->size, flag);
if (IS_ERR(special_buf->dma_buf)) {
- mfc_err_ctx("Failed to get dma_buf (err %ld)",
+ mfc_err_ctx("Failed to allocate buffer (err %ld)\n",
PTR_ERR(special_buf->dma_buf));
- special_buf->dma_buf = NULL;
goto err_ion_alloc;
}
special_buf->attachment = dma_buf_attach(special_buf->dma_buf, dev->device);
if (IS_ERR(special_buf->attachment)) {
- mfc_err_ctx("Failed to get dma_buf_attach (err %ld)",
+ mfc_err_ctx("Failed to get dma_buf_attach (err %ld)\n",
PTR_ERR(special_buf->attachment));
- special_buf->attachment = NULL;
- goto err_ion_alloc;
+ goto err_attach;
}
special_buf->sgt = dma_buf_map_attachment(special_buf->attachment,
DMA_BIDIRECTIONAL);
if (IS_ERR(special_buf->sgt)) {
- mfc_err_ctx("Failed to get sgt (err %ld)",
+ mfc_err_ctx("Failed to get sgt (err %ld)\n",
PTR_ERR(special_buf->sgt));
- special_buf->sgt = NULL;
- goto err_ion_alloc;
+ goto err_map;
}
special_buf->daddr = ion_iovmm_map(special_buf->attachment, 0,
special_buf->size, DMA_BIDIRECTIONAL, 0);
if (IS_ERR_VALUE(special_buf->daddr)) {
- mfc_err_ctx("Failed to allocate iova (err %pa)",
+ mfc_err_ctx("Failed to allocate iova (err 0x%p)\n",
&special_buf->daddr);
- special_buf->daddr = 0;
- goto err_ion_alloc;
+ goto err_iovmm;
+ }
+
+ special_buf->vaddr = dma_buf_vmap(special_buf->dma_buf);
+ if (IS_ERR(special_buf->vaddr)) {
+ mfc_err_ctx("Failed to get vaddr (err 0x%p)\n",
+ &special_buf->vaddr);
+ goto err_vaddr;
}
return 0;
+err_vaddr:
+ special_buf->vaddr = NULL;
+ ion_iovmm_unmap(special_buf->attachment, special_buf->daddr);
+err_iovmm:
+ special_buf->daddr = 0;
+ dma_buf_unmap_attachment(special_buf->attachment, special_buf->sgt,
+ DMA_BIDIRECTIONAL);
+err_map:
+ special_buf->sgt = NULL;
+ dma_buf_detach(special_buf->dma_buf, special_buf->attachment);
+err_attach:
+ special_buf->attachment = NULL;
+ dma_buf_put(special_buf->dma_buf);
err_ion_alloc:
- s5p_mfc_mem_ion_free(dev, special_buf);
+ special_buf->dma_buf = NULL;
return -ENOMEM;
}
+
+void s5p_mfc_mem_ion_free(struct s5p_mfc_dev *dev,
+ struct s5p_mfc_special_buf *special_buf)
+{
+ if (special_buf->vaddr)
+ dma_buf_vunmap(special_buf->dma_buf, special_buf->vaddr);
+ if (special_buf->daddr)
+ ion_iovmm_unmap(special_buf->attachment, special_buf->daddr);
+ if (special_buf->sgt)
+ dma_buf_unmap_attachment(special_buf->attachment,
+ special_buf->sgt, DMA_BIDIRECTIONAL);
+ if (special_buf->attachment)
+ dma_buf_detach(special_buf->dma_buf, special_buf->attachment);
+ if (special_buf->dma_buf)
+ dma_buf_put(special_buf->dma_buf);
+
+ special_buf->dma_buf = NULL;
+ special_buf->attachment = NULL;
+ special_buf->sgt = NULL;
+ special_buf->daddr = 0;
+ special_buf->vaddr = NULL;
+}
int s5p_mfc_mem_get_user_shared_handle(struct s5p_mfc_ctx *ctx,
struct mfc_user_shared_handle *handle);
-int s5p_mfc_mem_cleanup_user_shared_handle(struct s5p_mfc_ctx *ctx,
+void s5p_mfc_mem_cleanup_user_shared_handle(struct s5p_mfc_ctx *ctx,
struct mfc_user_shared_handle *handle);
-void *s5p_mfc_mem_get_vaddr(struct s5p_mfc_dev *dev,
+int s5p_mfc_mem_ion_alloc(struct s5p_mfc_dev *dev,
struct s5p_mfc_special_buf *special_buf);
void s5p_mfc_mem_ion_free(struct s5p_mfc_dev *dev,
struct s5p_mfc_special_buf *special_buf);
-int s5p_mfc_mem_ion_alloc(struct s5p_mfc_dev *dev,
- struct s5p_mfc_special_buf *special_buf);
#endif /* __S5P_MFC_MEM_H */
kfree(nal_q_in_handle);
return NULL;
}
-
- nal_q_in_handle->nal_q_in_addr
- = (nal_in_queue *)s5p_mfc_mem_get_vaddr(dev, &nal_q_in_handle->in_buf);
- if (!nal_q_in_handle->nal_q_in_addr) {
- mfc_err_dev("NAL Q: failed to get vaddr\n");
- s5p_mfc_mem_ion_free(dev, &nal_q_in_handle->in_buf);
- kfree(nal_q_in_handle);
- return NULL;
- }
+ nal_q_in_handle->nal_q_in_addr = (nal_in_queue *)nal_q_in_handle->in_buf.vaddr;
mfc_debug_leave();
kfree(nal_q_out_handle);
return NULL;
}
-
- nal_q_out_handle->nal_q_out_addr
- = (nal_out_queue *)s5p_mfc_mem_get_vaddr(dev, &nal_q_out_handle->out_buf);
- if (!nal_q_out_handle->nal_q_out_addr) {
- mfc_err_dev("NAL Q : failed to get vaddr\n");
- s5p_mfc_mem_ion_free(dev, &nal_q_out_handle->out_buf);
- kfree(nal_q_out_handle);
- return NULL;
- }
+ nal_q_out_handle->nal_q_out_addr = (nal_out_queue *)nal_q_out_handle->out_buf.vaddr;
mfc_debug_leave();
mfc_debug(2, "OTF: buffer count: %d\n", buf_info->buffer_count);
/* map buffers */
for (i = 0; i < buf_info->buffer_count; i++) {
- mfc_debug(2, "OTF: dma_buf: %p\n", buf_info->bufs[i]);
+ mfc_debug(2, "OTF: dma_buf: 0x%p\n", buf_info->bufs[i]);
buf_addr->otf_buf_attach[i] = dma_buf_attach(buf_info->bufs[i], dev->device);
if (IS_ERR(buf_addr->otf_buf_attach[i])) {
mfc_err_ctx("OTF: Failed to get attachment (err %ld)",
raw = &ctx->raw_buf;
if (!handle) {
- mfc_err_ctx("OTF: There is no otf_handle, handle: %p\n", handle);
+ mfc_err_ctx("OTF: There is no otf_handle, handle: 0x%p\n", handle);
return -EINVAL;
}
spin_lock_irqsave(plock, flags);
- mfc_debug(2, "queue address: %p\n", queue);
- mfc_debug(2, "mfc_buf: %p\n", mfc_buf);
+ mfc_debug(2, "queue address: 0x%p\n", queue);
+ mfc_debug(2, "mfc_buf: 0x%p\n", mfc_buf);
mfc_buf->used = 0;
list_add_tail(&mfc_buf->list, &queue->head);
csd = mfc_buf->vb.reserved2 & FLAG_CSD ? 1 : 0;
- mfc_debug(2, "mfc_buf: %p\n", mfc_buf);
+ mfc_debug(2, "mfc_buf: 0x%p\n", mfc_buf);
mfc_debug(2, "First plane address: 0x%08llx\n", mfc_buf->addr[0]);
spin_unlock_irqrestore(plock, flags);
if ((used == MFC_BUF_RESET_USED) || (used == MFC_BUF_SET_USED))
mfc_buf->used = used;
- mfc_debug(2, "mfc_buf: %p\n", mfc_buf);
+ mfc_debug(2, "mfc_buf: 0x%p\n", mfc_buf);
mfc_debug(2, "First plane address: 0x%08llx\n", mfc_buf->addr[0]);
spin_unlock_irqrestore(plock, flags);
if ((used == MFC_BUF_RESET_USED) || (used == MFC_BUF_SET_USED))
mfc_buf->used = used;
- mfc_debug(2, "mfc_buf: %p\n", mfc_buf);
+ mfc_debug(2, "mfc_buf: 0x%p\n", mfc_buf);
mfc_debug(2, "First plane address: 0x%08llx\n", mfc_buf->addr[0]);
list_del(&mfc_buf->list);
mfc_buf = list_entry(queue->head.next, struct s5p_mfc_buf, list);
- mfc_debug(2, "mfc_buf: %p\n", mfc_buf);
+ mfc_debug(2, "mfc_buf: 0x%p\n", mfc_buf);
mfc_debug(2, "First plane address: 0x%08llx\n", mfc_buf->addr[0]);
remained = (unsigned int)(mfc_buf->vb.vb2_buf.planes[0].bytesused - consumed);
if ((used == MFC_BUF_RESET_USED) || (used == MFC_BUF_SET_USED))
mfc_buf->used = used;
- mfc_debug(2, "mfc_buf: %p\n", mfc_buf);
+ mfc_debug(2, "mfc_buf: 0x%p\n", mfc_buf);
mfc_debug(2, "First plane address: 0x%08llx\n", mfc_buf->addr[0]);
list_del(&mfc_buf->list);
mfc_buf = list_entry(from_queue->head.next, struct s5p_mfc_buf, list);
if (mfc_buf->used) {
- mfc_debug(2, "mfc_buf: %p\n", mfc_buf);
+ mfc_debug(2, "mfc_buf: 0x%p\n", mfc_buf);
mfc_debug(2, "First plane address: 0x%08llx\n", mfc_buf->addr[0]);
list_del(&mfc_buf->list);
src_mb = list_entry(ctx->src_buf_queue.head.next, struct s5p_mfc_buf, list);
- mfc_debug(2, "mfc_buf: %p\n", src_mb);
+ mfc_debug(2, "mfc_buf: 0x%p\n", src_mb);
mfc_debug(2, "First plane address: 0x%08llx\n", src_mb->addr[0]);
if (src_mb->vb.reserved2 & FLAG_LAST_FRAME) {
buf_addr1 = ctx->codec_buf.daddr;
buf_size1 = ctx->codec_buf.size;
- mfc_debug(2, "Buf1: %p (%d)\n", (void *)buf_addr1, buf_size1);
+ mfc_debug(2, "Buf1: 0x%p (%d)\n", (void *)buf_addr1, buf_size1);
mfc_debug(2, "Total DPB COUNT: %d\n", dec->total_dpb_count);
mfc_debug(2, "Setting display delay to %d\n", dec->display_delay);
align_gap = buf_addr1 - align_gap;
buf_size1 -= align_gap;
- mfc_debug(2, "\tBuf1: %p, size: %d\n", (void *)buf_addr1, buf_size1);
+ mfc_debug(2, "\tBuf1: 0x%p, size: %d\n", (void *)buf_addr1, buf_size1);
MFC_WRITEL(buf_addr1, S5P_FIMV_D_MV_BUFFER0 + i * 4);
buf_addr1 += frame_size_mv;
buf_size1 -= frame_size_mv;
}
}
- mfc_debug(2, "Buf1: %p, buf_size1: %d (frames %d)\n",
+ mfc_debug(2, "Buf1: 0x%p, buf_size1: %d (frames %d)\n",
(void *)buf_addr1, buf_size1, dec->total_dpb_count);
if (buf_size1 < 0) {
mfc_debug(2, "Not enough memory has been allocated.\n");
buf_addr1 = ctx->codec_buf.daddr;
buf_size1 = ctx->codec_buf.size;
- mfc_debug(2, "Buf1: %p (%d)\n", (void *)buf_addr1, buf_size1);
+ mfc_debug(2, "Buf1: 0x%p (%d)\n", (void *)buf_addr1, buf_size1);
MFC_WRITEL(buf_addr1, S5P_FIMV_E_SCRATCH_BUFFER_ADDR);
MFC_WRITEL(ctx->scratch_buf_size, S5P_FIMV_E_SCRATCH_BUFFER_SIZE);
buf_addr1 += enc->tmv_buffer_size >> 1;
buf_size1 -= enc->tmv_buffer_size;
- mfc_debug(2, "Buf1: %p, buf_size1: %d (ref frames %d)\n",
+ mfc_debug(2, "Buf1: 0x%p, buf_size1: %d (ref frames %d)\n",
(void *)buf_addr1, buf_size1, ctx->dpb_count);
if (buf_size1 < 0) {
mfc_debug(2, "Not enough memory has been allocated.\n");
{ 0xD000, 0x74 },
};
- pr_err("-----------dumping MFC registers (SFR base = %p, dev = %p)\n",
+ pr_err("-----------dumping MFC registers (SFR base = 0x%p, dev = 0x%p)\n",
dev->regs_base, dev);
s5p_mfc_enable_all_clocks(dev);