1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
/*
* Samsung Exynos5 SoC series FIMC-IS driver
*
* exynos5 fimc-is core functions
*
* Copyright (c) 2011 Samsung Electronics Co., Ltd
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#include <linux/module.h>
#include <linux/delay.h>
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/interrupt.h>
#include <linux/device.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
#include <video/videonode.h>
#include <media/exynos_mc.h>
#include <asm/cacheflush.h>
#include <asm/pgtable.h>
#include <linux/firmware.h>
#include <linux/dma-mapping.h>
#include <linux/scatterlist.h>
#include <linux/videodev2.h>
#include <linux/videodev2_exynos_camera.h>
#include <linux/vmalloc.h>
#include <linux/interrupt.h>
#include <linux/of.h>
#include "fimc-is-core.h"
#include "fimc-is-cmd.h"
#include "fimc-is-regs.h"
#include "fimc-is-err.h"
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0))
#include <linux/exynos_iovmm.h>
#else
#include <plat/iovmm.h>
#endif
static void *fimc_is_ion_init(struct platform_device *pdev)
{
return vb2_ion_create_context(&pdev->dev, SZ_4K,
VB2ION_CTX_IOMMU |
VB2ION_CTX_VMCONTIG);
}
static ulong plane_dvaddr(ulong cookie, u32 plane_no)
{
dma_addr_t dva = 0;
WARN_ON(vb2_ion_dma_address((void *)cookie, &dva) != 0);
return (ulong)dva;
}
static ulong plane_kvaddr(struct vb2_buffer *vb, u32 plane_no)
{
void *kvaddr = vb2_plane_vaddr(vb, plane_no);
return (ulong)kvaddr;
}
static ulong plane_cookie(struct vb2_buffer *vb, u32 plane_no)
{
void *cookie = vb2_plane_cookie(vb, plane_no);
return (ulong)cookie;
}
const struct fimc_is_vb2 fimc_is_vb2_ion = {
.ops = &vb2_ion_memops,
.init = fimc_is_ion_init,
.cleanup = vb2_ion_destroy_context,
.plane_dvaddr = plane_dvaddr,
.plane_kvaddr = plane_kvaddr,
.plane_cookie = plane_cookie,
.resume = vb2_ion_attach_iommu,
.suspend = vb2_ion_detach_iommu,
.set_cacheable = vb2_ion_set_cached,
};
int fimc_is_mem_probe(struct fimc_is_mem *this,
struct platform_device *pdev)
{
u32 ret = 0;
this->vb2 = &fimc_is_vb2_ion;
this->alloc_ctx = this->vb2->init(pdev);
if (IS_ERR(this->alloc_ctx)) {
ret = PTR_ERR(this->alloc_ctx);
goto p_err;
}
p_err:
return ret;
}
|