-
Notifications
You must be signed in to change notification settings - Fork 0
/
vcodec.c
156 lines (124 loc) · 3.33 KB
/
vcodec.c
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/*
* SIC LABORATORY, LG ELECTRONICS INC., SEOUL, KOREA
* Copyright(c) 2013 by LG Electronics Inc.
* Youngki Lyu <youngki.lyu@lge.com>
* Jungmin Park <jungmin016.park@lge.com>
* Younghyun Jo <younghyun.jo@lge.com>
*
* 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include <linux/fs.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/list.h>
#include <linux/major.h>
#include <linux/miscdevice.h>
#include <linux/module.h>
#include <linux/odin_iommu.h>
#include <linux/odin_mailbox.h>
#include <linux/of.h>
#include <linux/of_irq.h>
#include <linux/of_address.h>
#include <linux/platform_device.h>
#include <linux/spinlock.h>
#include <linux/vmalloc.h>
#include <media/odin/vcodec/vcore/device.h>
#include <media/odin/vcodec/vdec_io.h>
#include <media/odin/vcodec/venc_io.h>
#include <media/odin/vcodec/vppu_io.h>
#include <media/odin/vcodec/vlog.h>
#include <media/odin/vcodec/vppu_drv.h>
#include "vcodec_io.h"
#include "vcodec_vcore.h"
#include "./common/vcodec_rate.h"
#include "./common/vcodec_timer.h"
#include "./common/vcodec_dpb.h"
#include "misc/vbuf/vbuf.h"
#include "vdec/vdec_drv.h"
#include "venc/venc_drv.h"
struct vcodec_desc
{
struct miscdevice miscdev;
};
static struct vcodec_desc *vcodec_desc;
static struct file_operations fops =
{
.open = vcodec_io_open,
.release = vcodec_io_close,
.unlocked_ioctl = vcodec_io_unlocked_ioctl,
};
static int _vcodec_probe(void)
{
int errno = 0;
vlog_info("vcodec_probe start\n");
if (vbuf_init() < 0) {
vlog_error("vbuf_init failed\n");
return -ENOBUFS;
}
vcodec_desc = vzalloc(sizeof(struct vcodec_desc));
if (vcodec_desc == NULL) {
vlog_error("vzalloc failed\n");
errno = -ENOMEM;
goto err_vzalloc;
}
vcodec_rate_init();
vcodec_timer_init();
vcodec_dpb_init();
vdec_init(vcodec_vcore_get_dec, vcodec_vcore_put_dec);
venc_init(vcodec_vcore_get_enc, vcodec_vcore_put_enc);
vppu_init(vcodec_vcore_get_ppu, vcodec_vcore_put_ppu);
vcodec_desc->miscdev.minor = MISC_DYNAMIC_MINOR;
vcodec_desc->miscdev.name = "vcodec";
vcodec_desc->miscdev.mode = 0777;
vcodec_desc->miscdev.fops = &fops;
errno = misc_register(&vcodec_desc->miscdev);
if (errno < 0) {
vlog_error("misc_register failed\n");
goto err_misc_register;
}
vlog_init(vcodec_desc->miscdev.this_device);
vlog_info("vcodec_probe success\n");
return 0;
err_misc_register:
if (vcodec_desc) {
vfree(vcodec_desc);
vcodec_desc = NULL;
}
err_vzalloc:
vbuf_cleanup();
return errno;
}
static int _vcodec_remove(void)
{
misc_deregister(&vcodec_desc->miscdev);
vdec_cleanup();
venc_cleanup();
vppu_cleanup();
vcodec_timer_cleanup();
vcodec_rate_cleanup();
vcodec_dpb_cleanup();
vfree(vcodec_desc);
vbuf_cleanup();
return 0;
}
static int __init vcodec_init(void)
{
_vcodec_probe();
return 0;
}
static void __exit vcodec_cleanup(void)
{
_vcodec_remove();
}
late_initcall(vcodec_init);
module_exit(vcodec_cleanup);
MODULE_AUTHOR("LGE");
MODULE_DESCRIPTION("VIDEO CODEC DRIVER");
MODULE_LICENSE("GPL");