1
2
3
4
5
6
7
8
9
10
11
12
13
14
15#include "s5p_mfc_debug.h"
16#include "s5p_mfc_opr.h"
17#include "s5p_mfc_opr_v5.h"
18#include "s5p_mfc_opr_v6.h"
19
20static struct s5p_mfc_hw_ops *s5p_mfc_ops;
21
22void s5p_mfc_init_hw_ops(struct s5p_mfc_dev *dev)
23{
24 if (IS_MFCV6(dev)) {
25 s5p_mfc_ops = s5p_mfc_init_hw_ops_v6();
26 dev->warn_start = S5P_FIMV_ERR_WARNINGS_START_V6;
27 } else {
28 s5p_mfc_ops = s5p_mfc_init_hw_ops_v5();
29 dev->warn_start = S5P_FIMV_ERR_WARNINGS_START;
30 }
31 dev->mfc_ops = s5p_mfc_ops;
32}
33
34int s5p_mfc_alloc_priv_buf(struct device *dev,
35 struct s5p_mfc_priv_buf *b)
36{
37
38 mfc_debug(3, "Allocating priv: %d\n", b->size);
39
40 b->virt = dma_alloc_coherent(dev, b->size, &b->dma, GFP_KERNEL);
41
42 if (!b->virt) {
43 mfc_err("Allocating private buffer failed\n");
44 return -ENOMEM;
45 }
46
47 mfc_debug(3, "Allocated addr %p %08x\n", b->virt, b->dma);
48 return 0;
49}
50
51void s5p_mfc_release_priv_buf(struct device *dev,
52 struct s5p_mfc_priv_buf *b)
53{
54 if (b->virt) {
55 dma_free_coherent(dev, b->size, b->virt, b->dma);
56 b->virt = NULL;
57 b->dma = 0;
58 b->size = 0;
59 }
60}
61
62