OpenCores
URL https://opencores.org/ocsvn/test_project/test_project/trunk

Subversion Repositories test_project

[/] [test_project/] [trunk/] [linux_sd_driver/] [drivers/] [media/] [video/] [zoran_procfs.c] - Blame information for rev 78

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 62 marcus.erl
/*
2
 * Zoran zr36057/zr36067 PCI controller driver, for the
3
 * Pinnacle/Miro DC10/DC10+/DC30/DC30+, Iomega Buz, Linux
4
 * Media Labs LML33/LML33R10.
5
 *
6
 * This part handles the procFS entries (/proc/ZORAN[%d])
7
 *
8
 * Copyright (C) 2000 Serguei Miridonov <mirsev@cicese.mx>
9
 *
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>
14
 *
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.
19
 *
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.
24
 *
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.
28
 */
29
 
30
#include <linux/types.h>
31
#include <linux/kernel.h>
32
#include <linux/module.h>
33
#include <linux/vmalloc.h>
34
 
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>
43
 
44
#include <linux/ctype.h>
45
#include <linux/poll.h>
46
#include <asm/io.h>
47
 
48
#include "videocodec.h"
49
#include "zoran.h"
50
#include "zoran_procfs.h"
51
#include "zoran_card.h"
52
 
53
#ifdef CONFIG_PROC_FS
54
struct procfs_params_zr36067 {
55
        char *name;
56
        short reg;
57
        u32 mask;
58
        short bit;
59
};
60
 
61
static const struct procfs_params_zr36067 zr67[] = {
62
        {"HSPol", 0x000, 1, 30},
63
        {"HStart", 0x000, 0x3ff, 10},
64
        {"HEnd", 0x000, 0x3ff, 0},
65
 
66
        {"VSPol", 0x004, 1, 30},
67
        {"VStart", 0x004, 0x3ff, 10},
68
        {"VEnd", 0x004, 0x3ff, 0},
69
 
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},
75
 
76
        {"HsyncStart", 0x10c, 0xffff, 16},
77
        {"LineTot", 0x10c, 0xffff, 0},
78
 
79
        {"NAX", 0x110, 0xffff, 16},
80
        {"PAX", 0x110, 0xffff, 0},
81
 
82
        {"NAY", 0x114, 0xffff, 16},
83
        {"PAY", 0x114, 0xffff, 0},
84
 
85
        /* {"",,,}, */
86
 
87
        {NULL, 0, 0, 0},
88
};
89
 
90
static void
91
setparam (struct zoran *zr,
92
          char         *name,
93
          char         *sval)
94
{
95
        int i = 0, reg0, reg, val;
96
 
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]))
102
                                break;
103
                        val = simple_strtoul(sval, NULL, 0);
104
                        if ((val & ~zr67[i].mask))
105
                                break;
106
                        reg |= (val & zr67[i].mask) << zr67[i].bit;
107
                        dprintk(4,
108
                                KERN_INFO
109
                                "%s: setparam: setting ZR36067 register 0x%03x: 0x%08x=>0x%08x %s=%d\n",
110
                                ZR_DEVNAME(zr), zr67[i].reg, reg0, reg,
111
                                zr67[i].name, val);
112
                        btwrite(reg, zr67[i].reg);
113
                        break;
114
                }
115
                i++;
116
        }
117
}
118
 
119
static int zoran_show(struct seq_file *p, void *v)
120
{
121
        struct zoran *zr = p->private;
122
        int i;
123
 
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));
128
        return 0;
129
}
130
 
131
static int zoran_open(struct inode *inode, struct file *file)
132
{
133
        struct zoran *data = PDE(inode)->data;
134
        return single_open(file, zoran_show, data);
135
}
136
 
137
static ssize_t zoran_write(struct file *file, const char __user *buffer,
138
                        size_t count, loff_t *ppos)
139
{
140
        struct zoran *zr = PDE(file->f_path.dentry->d_inode)->data;
141
        char *string, *sp;
142
        char *line, *ldelim, *varname, *svar, *tdelim;
143
 
144
        if (count > 32768)      /* Stupidity filter */
145
                return -EINVAL;
146
 
147
        string = sp = vmalloc(count + 1);
148
        if (!string) {
149
                dprintk(1,
150
                        KERN_ERR
151
                        "%s: write_proc: can not allocate memory\n",
152
                        ZR_DEVNAME(zr));
153
                return -ENOMEM;
154
        }
155
        if (copy_from_user(string, buffer, count)) {
156
                vfree (string);
157
                return -EFAULT;
158
        }
159
        string[count] = 0;
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);
162
        ldelim = " \t\n";
163
        tdelim = "=";
164
        line = strpbrk(sp, ldelim);
165
        while (line) {
166
                *line = 0;
167
                svar = strpbrk(sp, tdelim);
168
                if (svar) {
169
                        *svar = 0;
170
                        varname = sp;
171
                        svar++;
172
                        setparam(zr, varname, svar);
173
                }
174
                sp = line + 1;
175
                line = strpbrk(sp, ldelim);
176
        }
177
        vfree(string);
178
 
179
        return count;
180
}
181
 
182
static const struct file_operations zoran_operations = {
183
        .open           = zoran_open,
184
        .read           = seq_read,
185
        .write          = zoran_write,
186
        .llseek         = seq_lseek,
187
        .release        = single_release,
188
};
189
#endif
190
 
191
int
192
zoran_proc_init (struct zoran *zr)
193
{
194
#ifdef CONFIG_PROC_FS
195
        char name[8];
196
 
197
        snprintf(name, 7, "zoran%d", zr->id);
198
        if ((zr->zoran_proc = create_proc_entry(name, 0, NULL))) {
199
                zr->zoran_proc->data = zr;
200
                zr->zoran_proc->owner = THIS_MODULE;
201
                zr->zoran_proc->proc_fops = &zoran_operations;
202
                dprintk(2,
203
                        KERN_INFO
204
                        "%s: procfs entry /proc/%s allocated. data=%p\n",
205
                        ZR_DEVNAME(zr), name, zr->zoran_proc->data);
206
        } else {
207
                dprintk(1, KERN_ERR "%s: Unable to initialise /proc/%s\n",
208
                        ZR_DEVNAME(zr), name);
209
                return 1;
210
        }
211
#endif
212
        return 0;
213
}
214
 
215
void
216
zoran_proc_cleanup (struct zoran *zr)
217
{
218
#ifdef CONFIG_PROC_FS
219
        char name[8];
220
 
221
        snprintf(name, 7, "zoran%d", zr->id);
222
        if (zr->zoran_proc)
223
                remove_proc_entry(name, NULL);
224
        zr->zoran_proc = NULL;
225
#endif
226
}

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.