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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
|
/*
* Copyright (C) 2012 Spreadtrum Communications Inc.
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* 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/module.h>
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/poll.h>
#include <linux/fs.h>
#include <linux/irq.h>
#include <linux/mm.h>
#include <linux/interrupt.h>
#include <linux/platform_device.h>
#include <linux/miscdevice.h>
#include <asm/io.h>
#include <linux/file.h>
#include <linux/slab.h>
#include <linux/err.h>
#include <linux/types.h>
#include <linux/string.h>
#include <linux/sched.h>
#include <linux/spinlock_types.h>
#include <linux/semaphore.h>
#include <linux/delay.h>
#include <linux/proc_fs.h>
#include <video/isp_drv_kernel.h>
#include <linux/clk.h>
#include <asm/cacheflush.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include "Shark_reg_isp.h"
#define DEBUG_ISP_DRV
#ifdef DEBUG_ISP_DRV
#define ISP_PRINT printk
#else
#define ISP_PRINT(...)
#endif
#define ISP_MINOR MISC_DYNAMIC_MINOR/*isp minor number*/
static struct proc_dir_entry* isp_proc_file;
/**file operation functions declare**/
static int32_t _isp_kernel_open(struct inode *node, struct file *filp);
static int32_t _isp_kernel_release(struct inode *node, struct file *filp);
static long _isp_kernel_ioctl( struct file *fl, unsigned int cmd, unsigned long param);
/**driver' functions declare**/
static int32_t _isp_probe(struct platform_device *pdev);
static int32_t _isp_remove(struct platform_device *dev);
/**module' functions declare**/
static int32_t __init isp_kernel_init(void);
static void isp_kernel_exit(void);
static struct file_operations isp_fops = {
.owner = THIS_MODULE,
.open = _isp_kernel_open,
.unlocked_ioctl = _isp_kernel_ioctl,
.release = _isp_kernel_release,
};
static struct miscdevice isp_dev = {
.minor = ISP_MINOR,
.name = "sprd_isp",
.fops = &isp_fops,
};
static const struct of_device_id of_match_table_isp[] = {
{ .compatible = "sprd,sprd_isp", },
{ },
};
static struct platform_driver isp_driver = {
.probe = _isp_probe,
.remove = _isp_remove,
.driver = {
.owner = THIS_MODULE,
.name = "sprd_isp",
.of_match_table = of_match_ptr(of_match_table_isp),
},
};
/**********************************************************
*open the device
*
***********************************************************/
static int32_t _isp_kernel_open (struct inode *node, struct file *pf)
{
int32_t ret = 0;
ISP_PRINT ("isp_k: open start \n");
return ret;
}
//static irqreturn_t _dcam_irq_root(int irq, void *dev_id)
void _dcam_isp_root(void)
{
int32_t ret = 0;
return IRQ_HANDLED;
}
/**********************************************************
*release the device
*
***********************************************************/
static int32_t _isp_kernel_release (struct inode *node, struct file *pf)
{
int ret = 0;
ISP_PRINT ("isp_k: release start \n");
ISP_PRINT ("isp_k: release end \n");
return ret;
}
/**********************************************************
*read info from file
*size_t size:
*loff_t p:
***********************************************************/
static int32_t _isp_kernel_proc_read (char *page, char **start, off_t off, int count, int *eof, void *data)
{
int len = 0;
#if 0
uint32_t reg_buf_len = 200;
uint32_t print_len = 0, print_cnt = 0;
uint32_t *reg_ptr = 0;
ISP_PRINT ("isp_k: _isp_kernel_proc_read 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x \n", (uint32_t)page, (uint32_t)start, (uint32_t)off, (uint32_t)count, (uint32_t)eof, (uint32_t)data);
(void)start; (void)off; (void)count; (void)eof;
if(0x00==g_isp_device.reg_base_addr)
{
return 0x00;
}
reg_ptr = (uint32_t*)g_isp_device.reg_base_addr;
len += sprintf(page + len, "Context for ISP device \n");
len += sprintf(page + len, "********************************************* \n");
while (print_len < reg_buf_len) {
len += sprintf(page + len, "offset 0x%x : 0x%x, 0x%x, 0x%x, 0x%x \n",
print_len,
reg_ptr[print_cnt],
reg_ptr[print_cnt+1],
reg_ptr[print_cnt+2],
reg_ptr[print_cnt+3]);
print_cnt += 4;
print_len += 16;
}
len += sprintf(page + len, "********************************************* \n");
len += sprintf(page + len, "The end of ISP device \n");
#endif
return len;
}
/**********************************************************
*the io controller of isp
*unsigned int cmd:
*unsigned long param:
***********************************************************/
static long _isp_kernel_ioctl( struct file *fl, unsigned int cmd, unsigned long param)
{
long ret = 0;
if(ISP_IO_IRQ==cmd)
{
} else {
switch (cmd)
{
case ISP_IO_READ: {
}
break;
case ISP_IO_WRITE: {
}
break;
case ISP_IO_RST: {
ISP_PRINT(" isp_k:ioctl restet start \n");
}
break;
case ISP_IO_SETCLK:
ISP_PRINT(" isp_k:ioctl set clock start \n");
break;
case ISP_IO_STOP: {
}
break;
case ISP_IO_INT: {
}
break;
case ISP_IO_DCAM_INT: {
}
break;
case ISP_IO_LNC_PARAM: {
}
break;
case ISP_IO_LNC: {
}
break;
case ISP_IO_ALLOC: {
}
break;
default:
ISP_PRINT("isp_k:_ioctl cmd is unsupported, cmd = %x\n", (int32_t)cmd);
return -EFAULT;
}
}
//ISP_PRINT("isp_k:_ioctl finished\n");
ISP_IOCTL_EXIT:
return ret;
}
static int _isp_probe(struct platform_device *pdev)
{
int ret = 0;
ISP_PRINT ("isp_k:probe start\n");
ret = misc_register(&isp_dev);
if (ret) {
ISP_PRINT ( "isp_k:probe cannot register miscdev on minor=%d (%d)\n",(int32_t)ISP_MINOR, (int32_t)ret);
return ret;
}
/*
isp_proc_file = create_proc_read_entry("driver/sprd_isp" ,
0444,
NULL,
_isp_kernel_proc_read,
NULL);
if (unlikely(NULL == isp_proc_file)) {
ISP_PRINT("isp_k:probe Can't create an entry for isp in /proc \n");
ret = ENOMEM;
return ret;
}
*/
isp_dev.this_device->of_node = pdev->dev.of_node;
ISP_PRINT (" isp_k:probe end\n");
return 0;
}
static int _isp_remove(struct platform_device * dev)
{
ISP_PRINT ("isp_k: remove start \n");
misc_deregister(&isp_dev);
if (isp_proc_file) {
remove_proc_entry("driver/sprd_isp", NULL);
}
ISP_PRINT ("isp_k: remove end !\n");
return 0;
}
static int32_t __init isp_kernel_init(void)
{
int32_t ret = 0;
uint32_t addr = 0;
ISP_PRINT ("isp_k: init start \n");
if (platform_driver_register(&isp_driver) != 0) {
ISP_PRINT ("isp_kernel_init: platform device register error \n");
return -1;
}
ISP_PRINT ("isp_k: init end\n");
return ret;
}
static void isp_kernel_exit(void)
{
ISP_PRINT ("isp_k: exit start \n");
platform_driver_unregister(&isp_driver);
ISP_PRINT ("isp_k: exit end \n");
}
module_init(isp_kernel_init);
module_exit(isp_kernel_exit);
MODULE_DESCRIPTION("Isp Driver");
MODULE_LICENSE("GPL");
|