zr36016.c (0337966d121ebebf73a1c346123e8112796e684e) zr36016.c (2a0c28063de23646bb56152095ce73ea2284dc26)
1// SPDX-License-Identifier: GPL-2.0-or-later
1/*
2 * Zoran ZR36016 basic configuration functions
3 *
4 * Copyright (C) 2001 Wolfgang Scherr <scherr@net4you.at>
2/*
3 * Zoran ZR36016 basic configuration functions
4 *
5 * Copyright (C) 2001 Wolfgang Scherr <scherr@net4you.at>
5 *
6 * $Id: zr36016.c,v 1.1.2.14 2003/08/20 19:46:55 rbultje Exp $
7 *
8 * ------------------------------------------------------------------------
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * ------------------------------------------------------------------------
21 */
22
6 */
7
23#define ZR016_VERSION "v0.7"
24
25#include <linux/module.h>
26#include <linux/init.h>
27#include <linux/slab.h>
8#include <linux/module.h>
9#include <linux/init.h>
10#include <linux/slab.h>
28#include <linux/delay.h>
29
11
30#include <linux/types.h>
31#include <linux/wait.h>
32
33/* I/O commands, error codes */
34#include <asm/io.h>
35
36/* v4l API */
37
38/* headerfile of this module */
39#include "zr36016.h"
40
41/* codec io API */
42#include "videocodec.h"
43
12/* headerfile of this module */
13#include "zr36016.h"
14
15/* codec io API */
16#include "videocodec.h"
17
44/* it doesn't make sense to have more than 20 or so,
45 just to prevent some unwanted loops */
18/*
19 * it doesn't make sense to have more than 20 or so,
20 * just to prevent some unwanted loops
21 */
46#define MAX_CODECS 20
47
48/* amount of chips attached via this driver */
49static int zr36016_codecs;
50
22#define MAX_CODECS 20
23
24/* amount of chips attached via this driver */
25static int zr36016_codecs;
26
51/* debugging is available via module parameter */
52static int debug;
53module_param(debug, int, 0);
54MODULE_PARM_DESC(debug, "Debug level (0-4)");
27/*
28 * Local hardware I/O functions: read/write via codec layer
29 * (registers are located in the master device)
30 */
55
31
56#define dprintk(num, format, args...) \
57 do { \
58 if (debug >= num) \
59 printk(format, ##args); \
60 } while (0)
61
62/* =========================================================================
63 Local hardware I/O functions:
64
65 read/write via codec layer (registers are located in the master device)
66 ========================================================================= */
67
68/* read and write functions */
32/* read and write functions */
69static u8
70zr36016_read (struct zr36016 *ptr,
71 u16 reg)
33static u8 zr36016_read(struct zr36016 *ptr, u16 reg)
72{
73 u8 value = 0;
34{
35 u8 value = 0;
36 struct zoran *zr = videocodec_to_zoran(ptr->codec);
74
37
75 // just in case something is wrong...
38 /* just in case something is wrong... */
76 if (ptr->codec->master_data->readreg)
39 if (ptr->codec->master_data->readreg)
77 value =
78 (ptr->codec->master_data->
79 readreg(ptr->codec, reg)) & 0xFF;
40 value = (ptr->codec->master_data->readreg(ptr->codec, reg)) & 0xFF;
80 else
41 else
81 dprintk(1,
82 KERN_ERR "%s: invalid I/O setup, nothing read!\n",
83 ptr->name);
42 zrdev_err(zr, "%s: invalid I/O setup, nothing read!\n", ptr->name);
84
43
85 dprintk(4, "%s: reading from 0x%04x: %02x\n", ptr->name, reg,
86 value);
44 zrdev_dbg(zr, "%s: reading from 0x%04x: %02x\n", ptr->name, reg, value);
87
88 return value;
89}
90
45
46 return value;
47}
48
91static void
92zr36016_write (struct zr36016 *ptr,
93 u16 reg,
94 u8 value)
49static void zr36016_write(struct zr36016 *ptr, u16 reg, u8 value)
95{
50{
96 dprintk(4, "%s: writing 0x%02x to 0x%04x\n", ptr->name, value,
97 reg);
51 struct zoran *zr = videocodec_to_zoran(ptr->codec);
98
52
53 zrdev_dbg(zr, "%s: writing 0x%02x to 0x%04x\n", ptr->name, value, reg);
54
99 // just in case something is wrong...
55 // just in case something is wrong...
100 if (ptr->codec->master_data->writereg) {
56 if (ptr->codec->master_data->writereg)
101 ptr->codec->master_data->writereg(ptr->codec, reg, value);
57 ptr->codec->master_data->writereg(ptr->codec, reg, value);
102 } else
103 dprintk(1,
104 KERN_ERR
105 "%s: invalid I/O setup, nothing written!\n",
106 ptr->name);
58 else
59 zrdev_err(zr, "%s: invalid I/O setup, nothing written!\n", ptr->name);
107}
108
60}
61
109/* indirect read and write functions */
110/* the 016 supports auto-addr-increment, but
111 * writing it all time cost not much and is safer... */
112static u8
113zr36016_readi (struct zr36016 *ptr,
114 u16 reg)
62/*
63 * indirect read and write functions
64 *
65 * the 016 supports auto-addr-increment, but
66 * writing it all time cost not much and is safer...
67 */
68static u8 zr36016_readi(struct zr36016 *ptr, u16 reg)
115{
116 u8 value = 0;
69{
70 u8 value = 0;
71 struct zoran *zr = videocodec_to_zoran(ptr->codec);
117
72
118 // just in case something is wrong...
119 if ((ptr->codec->master_data->writereg) &&
120 (ptr->codec->master_data->readreg)) {
121 ptr->codec->master_data->writereg(ptr->codec, ZR016_IADDR, reg & 0x0F); // ADDR
122 value = (ptr->codec->master_data->readreg(ptr->codec, ZR016_IDATA)) & 0xFF; // DATA
123 } else
124 dprintk(1,
125 KERN_ERR
126 "%s: invalid I/O setup, nothing read (i)!\n",
127 ptr->name);
73 /* just in case something is wrong... */
74 if ((ptr->codec->master_data->writereg) && (ptr->codec->master_data->readreg)) {
75 ptr->codec->master_data->writereg(ptr->codec, ZR016_IADDR, reg & 0x0F);
76 value = (ptr->codec->master_data->readreg(ptr->codec, ZR016_IDATA)) & 0xFF;
77 } else {
78 zrdev_err(zr, "%s: invalid I/O setup, nothing read (i)!\n", ptr->name);
79 }
128
80
129 dprintk(4, "%s: reading indirect from 0x%04x: %02x\n", ptr->name,
130 reg, value);
81 zrdev_dbg(zr, "%s: reading indirect from 0x%04x: %02x\n",
82 ptr->name, reg, value);
131 return value;
132}
133
83 return value;
84}
85
134static void
135zr36016_writei (struct zr36016 *ptr,
136 u16 reg,
137 u8 value)
86static void zr36016_writei(struct zr36016 *ptr, u16 reg, u8 value)
138{
87{
139 dprintk(4, "%s: writing indirect 0x%02x to 0x%04x\n", ptr->name,
140 value, reg);
88 struct zoran *zr = videocodec_to_zoran(ptr->codec);
141
89
142 // just in case something is wrong...
90 zrdev_dbg(zr, "%s: writing indirect 0x%02x to 0x%04x\n", ptr->name,
91 value, reg);
92
93 /* just in case something is wrong... */
143 if (ptr->codec->master_data->writereg) {
94 if (ptr->codec->master_data->writereg) {
144 ptr->codec->master_data->writereg(ptr->codec, ZR016_IADDR, reg & 0x0F); // ADDR
145 ptr->codec->master_data->writereg(ptr->codec, ZR016_IDATA, value & 0x0FF); // DATA
146 } else
147 dprintk(1,
148 KERN_ERR
149 "%s: invalid I/O setup, nothing written (i)!\n",
150 ptr->name);
95 ptr->codec->master_data->writereg(ptr->codec, ZR016_IADDR, reg & 0x0F);
96 ptr->codec->master_data->writereg(ptr->codec, ZR016_IDATA, value & 0x0FF);
97 } else {
98 zrdev_err(zr, "%s: invalid I/O setup, nothing written (i)!\n", ptr->name);
99 }
151}
152
100}
101
153/* =========================================================================
154 Local helper function:
102/* Local helper function: version read */
155
103
156 version read
157 ========================================================================= */
158
159/* version kept in datastructure */
104/* version kept in datastructure */
160static u8
161zr36016_read_version (struct zr36016 *ptr)
105static u8 zr36016_read_version(struct zr36016 *ptr)
162{
163 ptr->version = zr36016_read(ptr, 0) >> 4;
164 return ptr->version;
165}
166
106{
107 ptr->version = zr36016_read(ptr, 0) >> 4;
108 return ptr->version;
109}
110
167/* =========================================================================
168 Local helper function:
111/*
112 * Local helper function: basic test of "connectivity", writes/reads
113 * to/from PAX-Lo register
114 */
169
115
170 basic test of "connectivity", writes/reads to/from PAX-Lo register
171 ========================================================================= */
172
173static int
174zr36016_basic_test (struct zr36016 *ptr)
116static int zr36016_basic_test(struct zr36016 *ptr)
175{
117{
176 if (debug) {
118 struct zoran *zr = videocodec_to_zoran(ptr->codec);
119
120 if (*KERN_INFO <= CONSOLE_LOGLEVEL_DEFAULT) {
177 int i;
121 int i;
122
178 zr36016_writei(ptr, ZR016I_PAX_LO, 0x55);
123 zr36016_writei(ptr, ZR016I_PAX_LO, 0x55);
179 dprintk(1, KERN_INFO "%s: registers: ", ptr->name);
124 zrdev_dbg(zr, "%s: registers: ", ptr->name);
180 for (i = 0; i <= 0x0b; i++)
125 for (i = 0; i <= 0x0b; i++)
181 dprintk(1, "%02x ", zr36016_readi(ptr, i));
182 dprintk(1, "\n");
126 zrdev_dbg(zr, "%02x ", zr36016_readi(ptr, i));
127 zrdev_dbg(zr, "\n");
183 }
184 // for testing just write 0, then the default value to a register and read
185 // it back in both cases
186 zr36016_writei(ptr, ZR016I_PAX_LO, 0x00);
187 if (zr36016_readi(ptr, ZR016I_PAX_LO) != 0x0) {
128 }
129 // for testing just write 0, then the default value to a register and read
130 // it back in both cases
131 zr36016_writei(ptr, ZR016I_PAX_LO, 0x00);
132 if (zr36016_readi(ptr, ZR016I_PAX_LO) != 0x0) {
188 dprintk(1,
189 KERN_ERR
190 "%s: attach failed, can't connect to vfe processor!\n",
191 ptr->name);
133 zrdev_err(zr, "%s: attach failed, can't connect to vfe processor!\n", ptr->name);
192 return -ENXIO;
193 }
194 zr36016_writei(ptr, ZR016I_PAX_LO, 0x0d0);
195 if (zr36016_readi(ptr, ZR016I_PAX_LO) != 0x0d0) {
134 return -ENXIO;
135 }
136 zr36016_writei(ptr, ZR016I_PAX_LO, 0x0d0);
137 if (zr36016_readi(ptr, ZR016I_PAX_LO) != 0x0d0) {
196 dprintk(1,
197 KERN_ERR
198 "%s: attach failed, can't connect to vfe processor!\n",
199 ptr->name);
138 zrdev_err(zr, "%s: attach failed, can't connect to vfe processor!\n", ptr->name);
200 return -ENXIO;
201 }
202 // we allow version numbers from 0-3, should be enough, though
203 zr36016_read_version(ptr);
204 if (ptr->version & 0x0c) {
139 return -ENXIO;
140 }
141 // we allow version numbers from 0-3, should be enough, though
142 zr36016_read_version(ptr);
143 if (ptr->version & 0x0c) {
205 dprintk(1,
206 KERN_ERR
207 "%s: attach failed, suspicious version %d found...\n",
208 ptr->name, ptr->version);
144 zrdev_err(zr, "%s: attach failed, suspicious version %d found...\n", ptr->name,
145 ptr->version);
209 return -ENXIO;
210 }
211
212 return 0; /* looks good! */
213}
214
146 return -ENXIO;
147 }
148
149 return 0; /* looks good! */
150}
151
215/* =========================================================================
216 Local helper function:
152/* Basic datasets & init */
217
153
218 simple loop for pushing the init datasets - NO USE --
219 ========================================================================= */
220
221#if 0
222static int zr36016_pushit (struct zr36016 *ptr,
223 u16 startreg,
224 u16 len,
225 const char *data)
154static void zr36016_init(struct zr36016 *ptr)
226{
155{
227 int i=0;
228
229 dprintk(4, "%s: write data block to 0x%04x (len=%d)\n",
230 ptr->name, startreg,len);
231 while (i<len) {
232 zr36016_writei(ptr, startreg++, data[i++]);
233 }
234
235 return i;
236}
237#endif
238
239/* =========================================================================
240 Basic datasets & init:
241
242 //TODO//
243 ========================================================================= */
244
245static void
246zr36016_init (struct zr36016 *ptr)
247{
248 // stop any processing
249 zr36016_write(ptr, ZR016_GOSTOP, 0);
250
251 // mode setup (yuv422 in and out, compression/expansuon due to mode)
252 zr36016_write(ptr, ZR016_MODE,
253 ZR016_YUV422 | ZR016_YUV422_YUV422 |
254 (ptr->mode == CODEC_DO_COMPRESSION ?
255 ZR016_COMPRESSION : ZR016_EXPANSION));

--- 14 unchanged lines hidden (view full) ---

270 zr36016_writei(ptr, ZR016I_NAX_LO, ptr->xoff & 0xFF);
271 zr36016_writei(ptr, ZR016I_NAY_HI, ptr->yoff >> 8);
272 zr36016_writei(ptr, ZR016I_NAY_LO, ptr->yoff & 0xFF);
273
274 /* shall we continue now, please? */
275 zr36016_write(ptr, ZR016_GOSTOP, 1);
276}
277
156 // stop any processing
157 zr36016_write(ptr, ZR016_GOSTOP, 0);
158
159 // mode setup (yuv422 in and out, compression/expansuon due to mode)
160 zr36016_write(ptr, ZR016_MODE,
161 ZR016_YUV422 | ZR016_YUV422_YUV422 |
162 (ptr->mode == CODEC_DO_COMPRESSION ?
163 ZR016_COMPRESSION : ZR016_EXPANSION));

--- 14 unchanged lines hidden (view full) ---

178 zr36016_writei(ptr, ZR016I_NAX_LO, ptr->xoff & 0xFF);
179 zr36016_writei(ptr, ZR016I_NAY_HI, ptr->yoff >> 8);
180 zr36016_writei(ptr, ZR016I_NAY_LO, ptr->yoff & 0xFF);
181
182 /* shall we continue now, please? */
183 zr36016_write(ptr, ZR016_GOSTOP, 1);
184}
185
278/* =========================================================================
279 CODEC API FUNCTIONS
186/*
187 * CODEC API FUNCTIONS
188 *
189 * These functions are accessed by the master via the API structure
190 */
280
191
281 this functions are accessed by the master via the API structure
282 ========================================================================= */
283
284/* set compression/expansion mode and launches codec -
285 this should be the last call from the master before starting processing */
286static int
287zr36016_set_mode (struct videocodec *codec,
288 int mode)
192/*
193 * set compression/expansion mode and launches codec -
194 * this should be the last call from the master before starting processing
195 */
196static int zr36016_set_mode(struct videocodec *codec, int mode)
289{
197{
290 struct zr36016 *ptr = (struct zr36016 *) codec->data;
198 struct zr36016 *ptr = (struct zr36016 *)codec->data;
199 struct zoran *zr = videocodec_to_zoran(codec);
291
200
292 dprintk(2, "%s: set_mode %d call\n", ptr->name, mode);
201 zrdev_dbg(zr, "%s: set_mode %d call\n", ptr->name, mode);
293
294 if ((mode != CODEC_DO_EXPANSION) && (mode != CODEC_DO_COMPRESSION))
295 return -EINVAL;
296
297 ptr->mode = mode;
298 zr36016_init(ptr);
299
300 return 0;
301}
302
303/* set picture size */
202
203 if ((mode != CODEC_DO_EXPANSION) && (mode != CODEC_DO_COMPRESSION))
204 return -EINVAL;
205
206 ptr->mode = mode;
207 zr36016_init(ptr);
208
209 return 0;
210}
211
212/* set picture size */
304static int
305zr36016_set_video (struct videocodec *codec,
306 struct tvnorm *norm,
307 struct vfe_settings *cap,
308 struct vfe_polarity *pol)
213static int zr36016_set_video(struct videocodec *codec, const struct tvnorm *norm,
214 struct vfe_settings *cap, struct vfe_polarity *pol)
309{
215{
310 struct zr36016 *ptr = (struct zr36016 *) codec->data;
216 struct zr36016 *ptr = (struct zr36016 *)codec->data;
217 struct zoran *zr = videocodec_to_zoran(codec);
311
218
312 dprintk(2, "%s: set_video %d.%d, %d/%d-%dx%d (0x%x) call\n",
313 ptr->name, norm->HStart, norm->VStart,
314 cap->x, cap->y, cap->width, cap->height,
315 cap->decimation);
219 zrdev_dbg(zr, "%s: set_video %d.%d, %d/%d-%dx%d (0x%x) call\n",
220 ptr->name, norm->h_start, norm->v_start,
221 cap->x, cap->y, cap->width, cap->height,
222 cap->decimation);
316
223
317 /* if () return -EINVAL;
224 /*
225 * if () return -EINVAL;
318 * trust the master driver that it knows what it does - so
226 * trust the master driver that it knows what it does - so
319 * we allow invalid startx/y for now ... */
227 * we allow invalid startx/y for now ...
228 */
320 ptr->width = cap->width;
321 ptr->height = cap->height;
229 ptr->width = cap->width;
230 ptr->height = cap->height;
322 /* (Ronald) This is ugly. zoran_device.c, line 387
323 * already mentions what happens if HStart is even
231 /*
232 * (Ronald) This is ugly. zoran_device.c, line 387
233 * already mentions what happens if h_start is even
324 * (blue faces, etc., cr/cb inversed). There's probably
234 * (blue faces, etc., cr/cb inversed). There's probably
325 * some good reason why HStart is 0 instead of 1, so I'm
235 * some good reason why h_start is 0 instead of 1, so I'm
326 * leaving it to this for now, but really... This can be
236 * leaving it to this for now, but really... This can be
327 * done a lot simpler */
328 ptr->xoff = (norm->HStart ? norm->HStart : 1) + cap->x;
329 /* Something to note here (I don't understand it), setting
330 * VStart too high will cause the codec to 'not work'. I
331 * really don't get it. values of 16 (VStart) already break
332 * it here. Just '0' seems to work. More testing needed! */
333 ptr->yoff = norm->VStart + cap->y;
237 * done a lot simpler
238 */
239 ptr->xoff = (norm->h_start ? norm->h_start : 1) + cap->x;
240 /*
241 * Something to note here (I don't understand it), setting
242 * v_start too high will cause the codec to 'not work'. I
243 * really don't get it. values of 16 (v_start) already break
244 * it here. Just '0' seems to work. More testing needed!
245 */
246 ptr->yoff = norm->v_start + cap->y;
334 /* (Ronald) dzjeeh, can't this thing do hor_decimation = 4? */
335 ptr->xdec = ((cap->decimation & 0xff) == 1) ? 0 : 1;
336 ptr->ydec = (((cap->decimation >> 8) & 0xff) == 1) ? 0 : 1;
337
338 return 0;
339}
340
341/* additional control functions */
247 /* (Ronald) dzjeeh, can't this thing do hor_decimation = 4? */
248 ptr->xdec = ((cap->decimation & 0xff) == 1) ? 0 : 1;
249 ptr->ydec = (((cap->decimation >> 8) & 0xff) == 1) ? 0 : 1;
250
251 return 0;
252}
253
254/* additional control functions */
342static int
343zr36016_control (struct videocodec *codec,
344 int type,
345 int size,
346 void *data)
255static int zr36016_control(struct videocodec *codec, int type, int size, void *data)
347{
256{
348 struct zr36016 *ptr = (struct zr36016 *) codec->data;
349 int *ival = (int *) data;
257 struct zr36016 *ptr = (struct zr36016 *)codec->data;
258 struct zoran *zr = videocodec_to_zoran(codec);
259 int *ival = (int *)data;
350
260
351 dprintk(2, "%s: control %d call with %d byte\n", ptr->name, type,
352 size);
261 zrdev_dbg(zr, "%s: control %d call with %d byte\n",
262 ptr->name, type, size);
353
354 switch (type) {
355 case CODEC_G_STATUS: /* get last status - we don't know it ... */
356 if (size != sizeof(int))
357 return -EFAULT;
358 *ival = 0;
359 break;
360

--- 21 unchanged lines hidden (view full) ---

382
383 default:
384 return -EINVAL;
385 }
386
387 return size;
388}
389
263
264 switch (type) {
265 case CODEC_G_STATUS: /* get last status - we don't know it ... */
266 if (size != sizeof(int))
267 return -EFAULT;
268 *ival = 0;
269 break;
270

--- 21 unchanged lines hidden (view full) ---

292
293 default:
294 return -EINVAL;
295 }
296
297 return size;
298}
299
390/* =========================================================================
391 Exit and unregister function:
300/*
301 * Exit and unregister function:
302 *
303 * Deinitializes Zoran's JPEG processor
304 */
392
305
393 Deinitializes Zoran's JPEG processor
394 ========================================================================= */
395
396static int
397zr36016_unset (struct videocodec *codec)
306static int zr36016_unset(struct videocodec *codec)
398{
399 struct zr36016 *ptr = codec->data;
307{
308 struct zr36016 *ptr = codec->data;
309 struct zoran *zr = videocodec_to_zoran(codec);
400
401 if (ptr) {
402 /* do wee need some codec deinit here, too ???? */
403
310
311 if (ptr) {
312 /* do wee need some codec deinit here, too ???? */
313
404 dprintk(1, "%s: finished codec #%d\n", ptr->name,
405 ptr->num);
314 zrdev_dbg(zr, "%s: finished codec #%d\n", ptr->name, ptr->num);
406 kfree(ptr);
407 codec->data = NULL;
408
409 zr36016_codecs--;
410 return 0;
411 }
412
413 return -EFAULT;
414}
415
315 kfree(ptr);
316 codec->data = NULL;
317
318 zr36016_codecs--;
319 return 0;
320 }
321
322 return -EFAULT;
323}
324
416/* =========================================================================
417 Setup and registry function:
325/*
326 * Setup and registry function:
327 *
328 * Initializes Zoran's JPEG processor
329 *
330 * Also sets pixel size, average code size, mode (compr./decompr.)
331 * (the given size is determined by the processor with the video interface)
332 */
418
333
419 Initializes Zoran's JPEG processor
420
421 Also sets pixel size, average code size, mode (compr./decompr.)
422 (the given size is determined by the processor with the video interface)
423 ========================================================================= */
424
425static int
426zr36016_setup (struct videocodec *codec)
334static int zr36016_setup(struct videocodec *codec)
427{
428 struct zr36016 *ptr;
335{
336 struct zr36016 *ptr;
337 struct zoran *zr = videocodec_to_zoran(codec);
429 int res;
430
338 int res;
339
431 dprintk(2, "zr36016: initializing VFE subsystem #%d.\n",
432 zr36016_codecs);
340 zrdev_dbg(zr, "zr36016: initializing VFE subsystem #%d.\n", zr36016_codecs);
433
434 if (zr36016_codecs == MAX_CODECS) {
341
342 if (zr36016_codecs == MAX_CODECS) {
435 dprintk(1,
436 KERN_ERR "zr36016: Can't attach more codecs!\n");
343 zrdev_err(zr, "zr36016: Can't attach more codecs!\n");
437 return -ENOSPC;
438 }
439 //mem structure init
344 return -ENOSPC;
345 }
346 //mem structure init
440 codec->data = ptr = kzalloc(sizeof(struct zr36016), GFP_KERNEL);
441 if (NULL == ptr) {
442 dprintk(1, KERN_ERR "zr36016: Can't get enough memory!\n");
347 ptr = kzalloc(sizeof(*ptr), GFP_KERNEL);
348 codec->data = ptr;
349 if (!ptr)
443 return -ENOMEM;
350 return -ENOMEM;
444 }
445
351
446 snprintf(ptr->name, sizeof(ptr->name), "zr36016[%d]",
447 zr36016_codecs);
352 snprintf(ptr->name, sizeof(ptr->name), "zr36016[%d]", zr36016_codecs);
448 ptr->num = zr36016_codecs++;
449 ptr->codec = codec;
450
451 //testing
452 res = zr36016_basic_test(ptr);
453 if (res < 0) {
454 zr36016_unset(codec);
455 return res;
456 }
457 //final setup
458 ptr->mode = CODEC_DO_COMPRESSION;
459 ptr->width = 768;
460 ptr->height = 288;
461 ptr->xdec = 1;
462 ptr->ydec = 0;
463 zr36016_init(ptr);
464
353 ptr->num = zr36016_codecs++;
354 ptr->codec = codec;
355
356 //testing
357 res = zr36016_basic_test(ptr);
358 if (res < 0) {
359 zr36016_unset(codec);
360 return res;
361 }
362 //final setup
363 ptr->mode = CODEC_DO_COMPRESSION;
364 ptr->width = 768;
365 ptr->height = 288;
366 ptr->xdec = 1;
367 ptr->ydec = 0;
368 zr36016_init(ptr);
369
465 dprintk(1, KERN_INFO "%s: codec v%d attached and running\n",
466 ptr->name, ptr->version);
370 zrdev_dbg(zr, "%s: codec v%d attached and running\n",
371 ptr->name, ptr->version);
467
468 return 0;
469}
470
471static const struct videocodec zr36016_codec = {
372
373 return 0;
374}
375
376static const struct videocodec zr36016_codec = {
472 .owner = THIS_MODULE,
473 .name = "zr36016",
377 .name = "zr36016",
474 .magic = 0L, // magic not used
378 .magic = 0L, /* magic not used */
475 .flags =
476 CODEC_FLAG_HARDWARE | CODEC_FLAG_VFE | CODEC_FLAG_ENCODER |
477 CODEC_FLAG_DECODER,
478 .type = CODEC_TYPE_ZR36016,
379 .flags =
380 CODEC_FLAG_HARDWARE | CODEC_FLAG_VFE | CODEC_FLAG_ENCODER |
381 CODEC_FLAG_DECODER,
382 .type = CODEC_TYPE_ZR36016,
479 .setup = zr36016_setup, // functionality
383 .setup = zr36016_setup, /* functionality */
480 .unset = zr36016_unset,
481 .set_mode = zr36016_set_mode,
482 .set_video = zr36016_set_video,
483 .control = zr36016_control,
384 .unset = zr36016_unset,
385 .set_mode = zr36016_set_mode,
386 .set_video = zr36016_set_video,
387 .control = zr36016_control,
484 // others are not used
388 /* others are not used */
485};
486
389};
390
487/* =========================================================================
488 HOOK IN DRIVER AS KERNEL MODULE
489 ========================================================================= */
391/* HOOK IN DRIVER AS KERNEL MODULE */
490
392
491static int __init
492zr36016_init_module (void)
393int zr36016_init_module(void)
493{
394{
494 //dprintk(1, "ZR36016 driver %s\n",ZR016_VERSION);
495 zr36016_codecs = 0;
496 return videocodec_register(&zr36016_codec);
497}
498
395 zr36016_codecs = 0;
396 return videocodec_register(&zr36016_codec);
397}
398
499static void __exit
500zr36016_cleanup_module (void)
399void zr36016_cleanup_module(void)
501{
502 if (zr36016_codecs) {
400{
401 if (zr36016_codecs) {
503 dprintk(1,
504 "zr36016: something's wrong - %d codecs left somehow.\n",
505 zr36016_codecs);
402 pr_debug("zr36016: something's wrong - %d codecs left somehow.\n",
403 zr36016_codecs);
506 }
507 videocodec_unregister(&zr36016_codec);
508}
404 }
405 videocodec_unregister(&zr36016_codec);
406}
509
510module_init(zr36016_init_module);
511module_exit(zr36016_cleanup_module);
512
513MODULE_AUTHOR("Wolfgang Scherr <scherr@net4you.at>");
514MODULE_DESCRIPTION("Driver module for ZR36016 video frontends "
515 ZR016_VERSION);
516MODULE_LICENSE("GPL");