2 * Zoran zr36057/zr36067 PCI controller driver, for the
3 * Pinnacle/Miro DC10/DC10+/DC30/DC30+, Iomega Buz, Linux
4 * Media Labs LML33/LML33R10.
6 * This part handles the procFS entries (/proc/ZORAN[%d])
8 * Copyright (C) 2000 Serguei Miridonov <mirsev@cicese.mx>
10 * Currently maintained by:
11 * Ronald Bultje <rbultje@ronald.bitfreak.net>
12 * Laurent Pinchart <laurent.pinchart@skynet.be>
13 * Mailinglist <mjpeg-users@lists.sf.net>
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
30 #include <linux/types.h>
31 #include <linux/kernel.h>
32 #include <linux/module.h>
33 #include <linux/vmalloc.h>
35 #include <linux/proc_fs.h>
36 #include <linux/pci.h>
37 #include <linux/i2c.h>
38 #include <linux/i2c-algo-bit.h>
39 #include <linux/videodev.h>
40 #include <linux/spinlock.h>
41 #include <linux/sem.h>
42 #include <linux/seq_file.h>
44 #include <linux/ctype.h>
45 #include <linux/poll.h>
48 #include "videocodec.h"
50 #include "zoran_procfs.h"
51 #include "zoran_card.h"
54 struct procfs_params_zr36067
{
61 static const struct procfs_params_zr36067 zr67
[] = {
62 {"HSPol", 0x000, 1, 30},
63 {"HStart", 0x000, 0x3ff, 10},
64 {"HEnd", 0x000, 0x3ff, 0},
66 {"VSPol", 0x004, 1, 30},
67 {"VStart", 0x004, 0x3ff, 10},
68 {"VEnd", 0x004, 0x3ff, 0},
70 {"ExtFl", 0x008, 1, 26},
71 {"TopField", 0x008, 1, 25},
72 {"VCLKPol", 0x008, 1, 24},
73 {"DupFld", 0x008, 1, 20},
74 {"LittleEndian", 0x008, 1, 0},
76 {"HsyncStart", 0x10c, 0xffff, 16},
77 {"LineTot", 0x10c, 0xffff, 0},
79 {"NAX", 0x110, 0xffff, 16},
80 {"PAX", 0x110, 0xffff, 0},
82 {"NAY", 0x114, 0xffff, 16},
83 {"PAY", 0x114, 0xffff, 0},
91 setparam (struct zoran
*zr
,
95 int i
= 0, reg0
, reg
, val
;
97 while (zr67
[i
].name
!= NULL
) {
98 if (!strncmp(name
, zr67
[i
].name
, strlen(zr67
[i
].name
))) {
99 reg
= reg0
= btread(zr67
[i
].reg
);
100 reg
&= ~(zr67
[i
].mask
<< zr67
[i
].bit
);
101 if (!isdigit(sval
[0]))
103 val
= simple_strtoul(sval
, NULL
, 0);
104 if ((val
& ~zr67
[i
].mask
))
106 reg
|= (val
& zr67
[i
].mask
) << zr67
[i
].bit
;
109 "%s: setparam: setting ZR36067 register 0x%03x: 0x%08x=>0x%08x %s=%d\n",
110 ZR_DEVNAME(zr
), zr67
[i
].reg
, reg0
, reg
,
112 btwrite(reg
, zr67
[i
].reg
);
119 static int zoran_show(struct seq_file
*p
, void *v
)
121 struct zoran
*zr
= p
->private;
124 seq_printf(p
, "ZR36067 registers:\n");
125 for (i
= 0; i
< 0x130; i
+= 16)
126 seq_printf(p
, "%03X %08X %08X %08X %08X \n", i
,
127 btread(i
), btread(i
+4), btread(i
+8), btread(i
+12));
131 static int zoran_open(struct inode
*inode
, struct file
*file
)
133 struct zoran
*data
= PDE(inode
)->data
;
134 return single_open(file
, zoran_show
, data
);
137 static ssize_t
zoran_write(struct file
*file
, const char __user
*buffer
,
138 size_t count
, loff_t
*ppos
)
140 struct zoran
*zr
= PDE(file
->f_path
.dentry
->d_inode
)->data
;
142 char *line
, *ldelim
, *varname
, *svar
, *tdelim
;
144 if (count
> 32768) /* Stupidity filter */
147 string
= sp
= vmalloc(count
+ 1);
151 "%s: write_proc: can not allocate memory\n",
155 if (copy_from_user(string
, buffer
, count
)) {
160 dprintk(4, KERN_INFO
"%s: write_proc: name=%s count=%zu zr=%p\n",
161 ZR_DEVNAME(zr
), file
->f_path
.dentry
->d_name
.name
, count
, zr
);
164 line
= strpbrk(sp
, ldelim
);
167 svar
= strpbrk(sp
, tdelim
);
172 setparam(zr
, varname
, svar
);
175 line
= strpbrk(sp
, ldelim
);
182 static const struct file_operations zoran_operations
= {
183 .owner
= THIS_MODULE
,
186 .write
= zoran_write
,
188 .release
= single_release
,
193 zoran_proc_init (struct zoran
*zr
)
195 #ifdef CONFIG_PROC_FS
198 snprintf(name
, 7, "zoran%d", zr
->id
);
199 zr
->zoran_proc
= proc_create_data(name
, 0, NULL
, &zoran_operations
, zr
);
200 if (zr
->zoran_proc
!= NULL
) {
203 "%s: procfs entry /proc/%s allocated. data=%p\n",
204 ZR_DEVNAME(zr
), name
, zr
->zoran_proc
->data
);
206 dprintk(1, KERN_ERR
"%s: Unable to initialise /proc/%s\n",
207 ZR_DEVNAME(zr
), name
);
215 zoran_proc_cleanup (struct zoran
*zr
)
217 #ifdef CONFIG_PROC_FS
220 snprintf(name
, 7, "zoran%d", zr
->id
);
222 remove_proc_entry(name
, NULL
);
223 zr
->zoran_proc
= NULL
;