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.
26 #include <linux/types.h>
27 #include <linux/kernel.h>
28 #include <linux/module.h>
29 #include <linux/vmalloc.h>
31 #include <linux/proc_fs.h>
32 #include <linux/pci.h>
33 #include <linux/i2c.h>
34 #include <linux/i2c-algo-bit.h>
35 #include <linux/videodev2.h>
36 #include <linux/spinlock.h>
37 #include <linux/sem.h>
38 #include <linux/seq_file.h>
40 #include <linux/ctype.h>
41 #include <linux/poll.h>
44 #include "videocodec.h"
46 #include "zoran_procfs.h"
47 #include "zoran_card.h"
50 struct procfs_params_zr36067 {
57 static const struct procfs_params_zr36067 zr67[] = {
58 {"HSPol", 0x000, 1, 30},
59 {"HStart", 0x000, 0x3ff, 10},
60 {"HEnd", 0x000, 0x3ff, 0},
62 {"VSPol", 0x004, 1, 30},
63 {"VStart", 0x004, 0x3ff, 10},
64 {"VEnd", 0x004, 0x3ff, 0},
66 {"ExtFl", 0x008, 1, 26},
67 {"TopField", 0x008, 1, 25},
68 {"VCLKPol", 0x008, 1, 24},
69 {"DupFld", 0x008, 1, 20},
70 {"LittleEndian", 0x008, 1, 0},
72 {"HsyncStart", 0x10c, 0xffff, 16},
73 {"LineTot", 0x10c, 0xffff, 0},
75 {"NAX", 0x110, 0xffff, 16},
76 {"PAX", 0x110, 0xffff, 0},
78 {"NAY", 0x114, 0xffff, 16},
79 {"PAY", 0x114, 0xffff, 0},
87 setparam (struct zoran *zr,
91 int i = 0, reg0, reg, val;
93 while (zr67[i].name != NULL) {
94 if (!strncmp(name, zr67[i].name, strlen(zr67[i].name))) {
95 reg = reg0 = btread(zr67[i].reg);
96 reg &= ~(zr67[i].mask << zr67[i].bit);
97 if (!isdigit(sval[0]))
99 val = simple_strtoul(sval, NULL, 0);
100 if ((val & ~zr67[i].mask))
102 reg |= (val & zr67[i].mask) << zr67[i].bit;
105 "%s: setparam: setting ZR36067 register 0x%03x: 0x%08x=>0x%08x %s=%d\n",
106 ZR_DEVNAME(zr), zr67[i].reg, reg0, reg,
108 btwrite(reg, zr67[i].reg);
115 static int zoran_show(struct seq_file *p, void *v)
117 struct zoran *zr = p->private;
120 seq_printf(p, "ZR36067 registers:\n");
121 for (i = 0; i < 0x130; i += 16)
122 seq_printf(p, "%03X %08X %08X %08X %08X \n", i,
123 btread(i), btread(i+4), btread(i+8), btread(i+12));
127 static int zoran_open(struct inode *inode, struct file *file)
129 struct zoran *data = PDE_DATA(inode);
130 return single_open(file, zoran_show, data);
133 static ssize_t zoran_write(struct file *file, const char __user *buffer,
134 size_t count, loff_t *ppos)
136 struct zoran *zr = PDE_DATA(file_inode(file));
138 char *line, *ldelim, *varname, *svar, *tdelim;
140 if (count > 32768) /* Stupidity filter */
143 string = sp = vmalloc(count + 1);
147 "%s: write_proc: can not allocate memory\n",
151 if (copy_from_user(string, buffer, count)) {
156 dprintk(4, KERN_INFO "%s: write_proc: name=%pD count=%zu zr=%p\n",
157 ZR_DEVNAME(zr), file, count, zr);
160 line = strpbrk(sp, ldelim);
163 svar = strpbrk(sp, tdelim);
168 setparam(zr, varname, svar);
171 line = strpbrk(sp, ldelim);
178 static const struct file_operations zoran_operations = {
179 .owner = THIS_MODULE,
182 .write = zoran_write,
184 .release = single_release,
189 zoran_proc_init (struct zoran *zr)
191 #ifdef CONFIG_PROC_FS
194 snprintf(name, 7, "zoran%d", zr->id);
195 zr->zoran_proc = proc_create_data(name, 0, NULL, &zoran_operations, zr);
196 if (zr->zoran_proc != NULL) {
199 "%s: procfs entry /proc/%s allocated. data=%p\n",
200 ZR_DEVNAME(zr), name, zr);
202 dprintk(1, KERN_ERR "%s: Unable to initialise /proc/%s\n",
203 ZR_DEVNAME(zr), name);
211 zoran_proc_cleanup (struct zoran *zr)
213 #ifdef CONFIG_PROC_FS
216 snprintf(name, 7, "zoran%d", zr->id);
218 remove_proc_entry(name, NULL);
219 zr->zoran_proc = NULL;