zr36050.c (0337966d121ebebf73a1c346123e8112796e684e) | zr36050.c (2a0c28063de23646bb56152095ce73ea2284dc26) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-or-later |
|
1/* 2 * Zoran ZR36050 basic configuration functions 3 * 4 * Copyright (C) 2001 Wolfgang Scherr <scherr@net4you.at> | 2/* 3 * Zoran ZR36050 basic configuration functions 4 * 5 * Copyright (C) 2001 Wolfgang Scherr <scherr@net4you.at> |
5 * 6 * $Id: zr36050.c,v 1.1.2.11 2003/08/03 14:54:53 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 ZR050_VERSION "v0.7.1" 24 | |
25#include <linux/module.h> 26#include <linux/init.h> 27#include <linux/slab.h> 28#include <linux/delay.h> 29 30#include <linux/types.h> 31#include <linux/wait.h> 32 33/* I/O commands, error codes */ | 8#include <linux/module.h> 9#include <linux/init.h> 10#include <linux/slab.h> 11#include <linux/delay.h> 12 13#include <linux/types.h> 14#include <linux/wait.h> 15 16/* I/O commands, error codes */ |
34#include <asm/io.h> | 17#include <linux/io.h> |
35 36/* headerfile of this module */ 37#include "zr36050.h" 38 39/* codec io API */ 40#include "videocodec.h" 41 | 18 19/* headerfile of this module */ 20#include "zr36050.h" 21 22/* codec io API */ 23#include "videocodec.h" 24 |
42/* it doesn't make sense to have more than 20 or so, 43 just to prevent some unwanted loops */ | 25/* 26 * it doesn't make sense to have more than 20 or so, 27 * just to prevent some unwanted loops 28 */ |
44#define MAX_CODECS 20 45 46/* amount of chips attached via this driver */ 47static int zr36050_codecs; 48 | 29#define MAX_CODECS 20 30 31/* amount of chips attached via this driver */ 32static int zr36050_codecs; 33 |
49/* debugging is available via module parameter */ 50static int debug; 51module_param(debug, int, 0); 52MODULE_PARM_DESC(debug, "Debug level (0-4)"); | 34/* 35 * Local hardware I/O functions: 36 * 37 * read/write via codec layer (registers are located in the master device) 38 */ |
53 | 39 |
54#define dprintk(num, format, args...) \ 55 do { \ 56 if (debug >= num) \ 57 printk(format, ##args); \ 58 } while (0) 59 60/* ========================================================================= 61 Local hardware I/O functions: 62 63 read/write via codec layer (registers are located in the master device) 64 ========================================================================= */ 65 | |
66/* read and write functions */ | 40/* read and write functions */ |
67static u8 68zr36050_read (struct zr36050 *ptr, 69 u16 reg) | 41static u8 zr36050_read(struct zr36050 *ptr, u16 reg) |
70{ | 42{ |
43 struct zoran *zr = videocodec_to_zoran(ptr->codec); |
|
71 u8 value = 0; 72 | 44 u8 value = 0; 45 |
73 // just in case something is wrong... | 46 /* just in case something is wrong... */ |
74 if (ptr->codec->master_data->readreg) | 47 if (ptr->codec->master_data->readreg) |
75 value = (ptr->codec->master_data->readreg(ptr->codec, 76 reg)) & 0xFF; | 48 value = (ptr->codec->master_data->readreg(ptr->codec, reg)) & 0xFF; |
77 else | 49 else |
78 dprintk(1, 79 KERN_ERR "%s: invalid I/O setup, nothing read!\n", 80 ptr->name); | 50 zrdev_err(zr, "%s: invalid I/O setup, nothing read!\n", ptr->name); |
81 | 51 |
82 dprintk(4, "%s: reading from 0x%04x: %02x\n", ptr->name, reg, 83 value); | 52 zrdev_dbg(zr, "%s: reading from 0x%04x: %02x\n", ptr->name, reg, value); |
84 85 return value; 86} 87 | 53 54 return value; 55} 56 |
88static void 89zr36050_write (struct zr36050 *ptr, 90 u16 reg, 91 u8 value) | 57static void zr36050_write(struct zr36050 *ptr, u16 reg, u8 value) |
92{ | 58{ |
93 dprintk(4, "%s: writing 0x%02x to 0x%04x\n", ptr->name, value, 94 reg); | 59 struct zoran *zr = videocodec_to_zoran(ptr->codec); |
95 | 60 |
96 // just in case something is wrong... | 61 zrdev_dbg(zr, "%s: writing 0x%02x to 0x%04x\n", ptr->name, value, reg); 62 63 /* just in case something is wrong... */ |
97 if (ptr->codec->master_data->writereg) 98 ptr->codec->master_data->writereg(ptr->codec, reg, value); 99 else | 64 if (ptr->codec->master_data->writereg) 65 ptr->codec->master_data->writereg(ptr->codec, reg, value); 66 else |
100 dprintk(1, 101 KERN_ERR 102 "%s: invalid I/O setup, nothing written!\n", 103 ptr->name); | 67 zrdev_err(zr, "%s: invalid I/O setup, nothing written!\n", 68 ptr->name); |
104} 105 | 69} 70 |
106/* ========================================================================= 107 Local helper function: 108 109 status read 110 ========================================================================= */ 111 | |
112/* status is kept in datastructure */ | 71/* status is kept in datastructure */ |
113static u8 114zr36050_read_status1 (struct zr36050 *ptr) | 72static u8 zr36050_read_status1(struct zr36050 *ptr) |
115{ 116 ptr->status1 = zr36050_read(ptr, ZR050_STATUS_1); 117 118 zr36050_read(ptr, 0); 119 return ptr->status1; 120} 121 | 73{ 74 ptr->status1 = zr36050_read(ptr, ZR050_STATUS_1); 75 76 zr36050_read(ptr, 0); 77 return ptr->status1; 78} 79 |
122/* ========================================================================= 123 Local helper function: 124 125 scale factor read 126 ========================================================================= */ 127 | |
128/* scale factor is kept in datastructure */ | 80/* scale factor is kept in datastructure */ |
129static u16 130zr36050_read_scalefactor (struct zr36050 *ptr) | 81static u16 zr36050_read_scalefactor(struct zr36050 *ptr) |
131{ 132 ptr->scalefact = (zr36050_read(ptr, ZR050_SF_HI) << 8) | 133 (zr36050_read(ptr, ZR050_SF_LO) & 0xFF); 134 135 /* leave 0 selected for an eventually GO from master */ 136 zr36050_read(ptr, 0); 137 return ptr->scalefact; 138} 139 | 82{ 83 ptr->scalefact = (zr36050_read(ptr, ZR050_SF_HI) << 8) | 84 (zr36050_read(ptr, ZR050_SF_LO) & 0xFF); 85 86 /* leave 0 selected for an eventually GO from master */ 87 zr36050_read(ptr, 0); 88 return ptr->scalefact; 89} 90 |
140/* ========================================================================= 141 Local helper function: | 91/* 92 * Local helper function: 93 * 94 * wait if codec is ready to proceed (end of processing) or time is over 95 */ |
142 | 96 |
143 wait if codec is ready to proceed (end of processing) or time is over 144 ========================================================================= */ 145 146static void 147zr36050_wait_end (struct zr36050 *ptr) | 97static void zr36050_wait_end(struct zr36050 *ptr) |
148{ | 98{ |
99 struct zoran *zr = videocodec_to_zoran(ptr->codec); |
|
149 int i = 0; 150 151 while (!(zr36050_read_status1(ptr) & 0x4)) { 152 udelay(1); 153 if (i++ > 200000) { // 200ms, there is for sure something wrong!!! | 100 int i = 0; 101 102 while (!(zr36050_read_status1(ptr) & 0x4)) { 103 udelay(1); 104 if (i++ > 200000) { // 200ms, there is for sure something wrong!!! |
154 dprintk(1, 155 "%s: timeout at wait_end (last status: 0x%02x)\n", 156 ptr->name, ptr->status1); | 105 zrdev_err(zr, 106 "%s: timeout at wait_end (last status: 0x%02x)\n", 107 ptr->name, ptr->status1); |
157 break; 158 } 159 } 160} 161 | 108 break; 109 } 110 } 111} 112 |
162/* ========================================================================= 163 Local helper function: | 113/* 114 * Local helper function: basic test of "connectivity", writes/reads 115 * to/from memory the SOF marker 116 */ |
164 | 117 |
165 basic test of "connectivity", writes/reads to/from memory the SOF marker 166 ========================================================================= */ 167 168static int 169zr36050_basic_test (struct zr36050 *ptr) | 118static int zr36050_basic_test(struct zr36050 *ptr) |
170{ | 119{ |
120 struct zoran *zr = videocodec_to_zoran(ptr->codec); 121 |
|
171 zr36050_write(ptr, ZR050_SOF_IDX, 0x00); 172 zr36050_write(ptr, ZR050_SOF_IDX + 1, 0x00); 173 if ((zr36050_read(ptr, ZR050_SOF_IDX) | 174 zr36050_read(ptr, ZR050_SOF_IDX + 1)) != 0x0000) { | 122 zr36050_write(ptr, ZR050_SOF_IDX, 0x00); 123 zr36050_write(ptr, ZR050_SOF_IDX + 1, 0x00); 124 if ((zr36050_read(ptr, ZR050_SOF_IDX) | 125 zr36050_read(ptr, ZR050_SOF_IDX + 1)) != 0x0000) { |
175 dprintk(1, 176 KERN_ERR 177 "%s: attach failed, can't connect to jpeg processor!\n", 178 ptr->name); | 126 zrdev_err(zr, 127 "%s: attach failed, can't connect to jpeg processor!\n", 128 ptr->name); |
179 return -ENXIO; 180 } 181 zr36050_write(ptr, ZR050_SOF_IDX, 0xff); 182 zr36050_write(ptr, ZR050_SOF_IDX + 1, 0xc0); 183 if (((zr36050_read(ptr, ZR050_SOF_IDX) << 8) | 184 zr36050_read(ptr, ZR050_SOF_IDX + 1)) != 0xffc0) { | 129 return -ENXIO; 130 } 131 zr36050_write(ptr, ZR050_SOF_IDX, 0xff); 132 zr36050_write(ptr, ZR050_SOF_IDX + 1, 0xc0); 133 if (((zr36050_read(ptr, ZR050_SOF_IDX) << 8) | 134 zr36050_read(ptr, ZR050_SOF_IDX + 1)) != 0xffc0) { |
185 dprintk(1, 186 KERN_ERR 187 "%s: attach failed, can't connect to jpeg processor!\n", 188 ptr->name); | 135 zrdev_err(zr, 136 "%s: attach failed, can't connect to jpeg processor!\n", 137 ptr->name); |
189 return -ENXIO; 190 } 191 192 zr36050_wait_end(ptr); 193 if ((ptr->status1 & 0x4) == 0) { | 138 return -ENXIO; 139 } 140 141 zr36050_wait_end(ptr); 142 if ((ptr->status1 & 0x4) == 0) { |
194 dprintk(1, 195 KERN_ERR 196 "%s: attach failed, jpeg processor failed (end flag)!\n", 197 ptr->name); | 143 zrdev_err(zr, 144 "%s: attach failed, jpeg processor failed (end flag)!\n", 145 ptr->name); |
198 return -EBUSY; 199 } 200 201 return 0; /* looks good! */ 202} 203 | 146 return -EBUSY; 147 } 148 149 return 0; /* looks good! */ 150} 151 |
204/* ========================================================================= 205 Local helper function: | 152/* Local helper function: simple loop for pushing the init datasets */ |
206 | 153 |
207 simple loop for pushing the init datasets 208 ========================================================================= */ 209 210static int 211zr36050_pushit (struct zr36050 *ptr, 212 u16 startreg, 213 u16 len, 214 const char *data) | 154static int zr36050_pushit(struct zr36050 *ptr, u16 startreg, u16 len, const char *data) |
215{ | 155{ |
156 struct zoran *zr = videocodec_to_zoran(ptr->codec); |
|
216 int i = 0; 217 | 157 int i = 0; 158 |
218 dprintk(4, "%s: write data block to 0x%04x (len=%d)\n", ptr->name, 219 startreg, len); 220 while (i < len) { | 159 zrdev_dbg(zr, "%s: write data block to 0x%04x (len=%d)\n", ptr->name, 160 startreg, len); 161 while (i < len) |
221 zr36050_write(ptr, startreg++, data[i++]); | 162 zr36050_write(ptr, startreg++, data[i++]); |
222 } | |
223 224 return i; 225} 226 | 163 164 return i; 165} 166 |
227/* ========================================================================= 228 Basic datasets: | 167/* 168 * Basic datasets: 169 * 170 * jpeg baseline setup data (you find it on lots places in internet, or just 171 * extract it from any regular .jpg image...) 172 * 173 * Could be variable, but until it's not needed it they are just fixed to save 174 * memory. Otherwise expand zr36050 structure with arrays, push the values to 175 * it and initialize from there, as e.g. the linux zr36057/60 driver does it. 176 */ |
229 | 177 |
230 jpeg baseline setup data (you find it on lots places in internet, or just 231 extract it from any regular .jpg image...) 232 233 Could be variable, but until it's not needed it they are just fixed to save 234 memory. Otherwise expand zr36050 structure with arrays, push the values to 235 it and initialize from there, as e.g. the linux zr36057/60 driver does it. 236 ========================================================================= */ 237 | |
238static const char zr36050_dqt[0x86] = { 239 0xff, 0xdb, //Marker: DQT 240 0x00, 0x84, //Length: 2*65+2 241 0x00, //Pq,Tq first table 242 0x10, 0x0b, 0x0c, 0x0e, 0x0c, 0x0a, 0x10, 0x0e, 243 0x0d, 0x0e, 0x12, 0x11, 0x10, 0x13, 0x18, 0x28, 244 0x1a, 0x18, 0x16, 0x16, 0x18, 0x31, 0x23, 0x25, 245 0x1d, 0x28, 0x3a, 0x33, 0x3d, 0x3c, 0x39, 0x33, --- 75 unchanged lines hidden (view full) --- 321static const char zr36050_tq[8] = { 0, 1, 1, 0, 0, 0, 0, 0 }; //table idx's QT 322static const char zr36050_td[8] = { 0, 1, 1, 0, 0, 0, 0, 0 }; //table idx's DC 323static const char zr36050_ta[8] = { 0, 1, 1, 0, 0, 0, 0, 0 }; //table idx's AC 324 325/* horizontal 422 decimation setup (maybe we support 411 or so later, too) */ 326static const char zr36050_decimation_h[8] = { 2, 1, 1, 0, 0, 0, 0, 0 }; 327static const char zr36050_decimation_v[8] = { 1, 1, 1, 0, 0, 0, 0, 0 }; 328 | 178static const char zr36050_dqt[0x86] = { 179 0xff, 0xdb, //Marker: DQT 180 0x00, 0x84, //Length: 2*65+2 181 0x00, //Pq,Tq first table 182 0x10, 0x0b, 0x0c, 0x0e, 0x0c, 0x0a, 0x10, 0x0e, 183 0x0d, 0x0e, 0x12, 0x11, 0x10, 0x13, 0x18, 0x28, 184 0x1a, 0x18, 0x16, 0x16, 0x18, 0x31, 0x23, 0x25, 185 0x1d, 0x28, 0x3a, 0x33, 0x3d, 0x3c, 0x39, 0x33, --- 75 unchanged lines hidden (view full) --- 261static const char zr36050_tq[8] = { 0, 1, 1, 0, 0, 0, 0, 0 }; //table idx's QT 262static const char zr36050_td[8] = { 0, 1, 1, 0, 0, 0, 0, 0 }; //table idx's DC 263static const char zr36050_ta[8] = { 0, 1, 1, 0, 0, 0, 0, 0 }; //table idx's AC 264 265/* horizontal 422 decimation setup (maybe we support 411 or so later, too) */ 266static const char zr36050_decimation_h[8] = { 2, 1, 1, 0, 0, 0, 0, 0 }; 267static const char zr36050_decimation_v[8] = { 1, 1, 1, 0, 0, 0, 0, 0 }; 268 |
329/* ========================================================================= 330 Local helper functions: | 269/* 270 * Local helper functions: 271 * 272 * calculation and setup of parameter-dependent JPEG baseline segments 273 * (needed for compression only) 274 */ |
331 | 275 |
332 calculation and setup of parameter-dependent JPEG baseline segments 333 (needed for compression only) 334 ========================================================================= */ 335 | |
336/* ------------------------------------------------------------------------- */ 337 | 276/* ------------------------------------------------------------------------- */ 277 |
338/* SOF (start of frame) segment depends on width, height and sampling ratio 339 of each color component */ 340 341static int 342zr36050_set_sof (struct zr36050 *ptr) | 278/* 279 * SOF (start of frame) segment depends on width, height and sampling ratio 280 * of each color component 281 */ 282static int zr36050_set_sof(struct zr36050 *ptr) |
343{ | 283{ |
284 struct zoran *zr = videocodec_to_zoran(ptr->codec); |
|
344 char sof_data[34]; // max. size of register set 345 int i; 346 | 285 char sof_data[34]; // max. size of register set 286 int i; 287 |
347 dprintk(3, "%s: write SOF (%dx%d, %d components)\n", ptr->name, 348 ptr->width, ptr->height, NO_OF_COMPONENTS); | 288 zrdev_dbg(zr, "%s: write SOF (%dx%d, %d components)\n", ptr->name, 289 ptr->width, ptr->height, NO_OF_COMPONENTS); |
349 sof_data[0] = 0xff; 350 sof_data[1] = 0xc0; 351 sof_data[2] = 0x00; 352 sof_data[3] = (3 * NO_OF_COMPONENTS) + 8; 353 sof_data[4] = BASELINE_PRECISION; // only '8' possible with zr36050 354 sof_data[5] = (ptr->height) >> 8; 355 sof_data[6] = (ptr->height) & 0xff; 356 sof_data[7] = (ptr->width) >> 8; 357 sof_data[8] = (ptr->width) & 0xff; 358 sof_data[9] = NO_OF_COMPONENTS; 359 for (i = 0; i < NO_OF_COMPONENTS; i++) { 360 sof_data[10 + (i * 3)] = i; // index identifier | 290 sof_data[0] = 0xff; 291 sof_data[1] = 0xc0; 292 sof_data[2] = 0x00; 293 sof_data[3] = (3 * NO_OF_COMPONENTS) + 8; 294 sof_data[4] = BASELINE_PRECISION; // only '8' possible with zr36050 295 sof_data[5] = (ptr->height) >> 8; 296 sof_data[6] = (ptr->height) & 0xff; 297 sof_data[7] = (ptr->width) >> 8; 298 sof_data[8] = (ptr->width) & 0xff; 299 sof_data[9] = NO_OF_COMPONENTS; 300 for (i = 0; i < NO_OF_COMPONENTS; i++) { 301 sof_data[10 + (i * 3)] = i; // index identifier |
361 sof_data[11 + (i * 3)] = (ptr->h_samp_ratio[i] << 4) | (ptr->v_samp_ratio[i]); // sampling ratios | 302 sof_data[11 + (i * 3)] = (ptr->h_samp_ratio[i] << 4) | 303 (ptr->v_samp_ratio[i]); // sampling ratios |
362 sof_data[12 + (i * 3)] = zr36050_tq[i]; // Q table selection 363 } 364 return zr36050_pushit(ptr, ZR050_SOF_IDX, 365 (3 * NO_OF_COMPONENTS) + 10, sof_data); 366} 367 368/* ------------------------------------------------------------------------- */ 369 | 304 sof_data[12 + (i * 3)] = zr36050_tq[i]; // Q table selection 305 } 306 return zr36050_pushit(ptr, ZR050_SOF_IDX, 307 (3 * NO_OF_COMPONENTS) + 10, sof_data); 308} 309 310/* ------------------------------------------------------------------------- */ 311 |
370/* SOS (start of scan) segment depends on the used scan components 371 of each color component */ | 312/* 313 * SOS (start of scan) segment depends on the used scan components 314 * of each color component 315 */ |
372 | 316 |
373static int 374zr36050_set_sos (struct zr36050 *ptr) | 317static int zr36050_set_sos(struct zr36050 *ptr) |
375{ | 318{ |
319 struct zoran *zr = videocodec_to_zoran(ptr->codec); |
|
376 char sos_data[16]; // max. size of register set 377 int i; 378 | 320 char sos_data[16]; // max. size of register set 321 int i; 322 |
379 dprintk(3, "%s: write SOS\n", ptr->name); | 323 zrdev_dbg(zr, "%s: write SOS\n", ptr->name); |
380 sos_data[0] = 0xff; 381 sos_data[1] = 0xda; 382 sos_data[2] = 0x00; 383 sos_data[3] = 2 + 1 + (2 * NO_OF_COMPONENTS) + 3; 384 sos_data[4] = NO_OF_COMPONENTS; 385 for (i = 0; i < NO_OF_COMPONENTS; i++) { 386 sos_data[5 + (i * 2)] = i; // index 387 sos_data[6 + (i * 2)] = (zr36050_td[i] << 4) | zr36050_ta[i]; // AC/DC tbl.sel. --- 5 unchanged lines hidden (view full) --- 393 4 + 1 + (2 * NO_OF_COMPONENTS) + 3, 394 sos_data); 395} 396 397/* ------------------------------------------------------------------------- */ 398 399/* DRI (define restart interval) */ 400 | 324 sos_data[0] = 0xff; 325 sos_data[1] = 0xda; 326 sos_data[2] = 0x00; 327 sos_data[3] = 2 + 1 + (2 * NO_OF_COMPONENTS) + 3; 328 sos_data[4] = NO_OF_COMPONENTS; 329 for (i = 0; i < NO_OF_COMPONENTS; i++) { 330 sos_data[5 + (i * 2)] = i; // index 331 sos_data[6 + (i * 2)] = (zr36050_td[i] << 4) | zr36050_ta[i]; // AC/DC tbl.sel. --- 5 unchanged lines hidden (view full) --- 337 4 + 1 + (2 * NO_OF_COMPONENTS) + 3, 338 sos_data); 339} 340 341/* ------------------------------------------------------------------------- */ 342 343/* DRI (define restart interval) */ 344 |
401static int 402zr36050_set_dri (struct zr36050 *ptr) | 345static int zr36050_set_dri(struct zr36050 *ptr) |
403{ | 346{ |
347 struct zoran *zr = videocodec_to_zoran(ptr->codec); |
|
404 char dri_data[6]; // max. size of register set 405 | 348 char dri_data[6]; // max. size of register set 349 |
406 dprintk(3, "%s: write DRI\n", ptr->name); | 350 zrdev_dbg(zr, "%s: write DRI\n", ptr->name); |
407 dri_data[0] = 0xff; 408 dri_data[1] = 0xdd; 409 dri_data[2] = 0x00; 410 dri_data[3] = 0x04; 411 dri_data[4] = ptr->dri >> 8; 412 dri_data[5] = ptr->dri & 0xff; 413 return zr36050_pushit(ptr, ZR050_DRI_IDX, 6, dri_data); 414} 415 | 351 dri_data[0] = 0xff; 352 dri_data[1] = 0xdd; 353 dri_data[2] = 0x00; 354 dri_data[3] = 0x04; 355 dri_data[4] = ptr->dri >> 8; 356 dri_data[5] = ptr->dri & 0xff; 357 return zr36050_pushit(ptr, ZR050_DRI_IDX, 6, dri_data); 358} 359 |
416/* ========================================================================= 417 Setup function: 418 419 Setup compression/decompression of Zoran's JPEG processor 420 ( see also zoran 36050 manual ) 421 422 ... sorry for the spaghetti code ... 423 ========================================================================= */ 424static void 425zr36050_init (struct zr36050 *ptr) | 360/* 361 * Setup function: 362 * 363 * Setup compression/decompression of Zoran's JPEG processor 364 * ( see also zoran 36050 manual ) 365 * 366 * ... sorry for the spaghetti code ... 367 */ 368static void zr36050_init(struct zr36050 *ptr) |
426{ 427 int sum = 0; 428 long bitcnt, tmp; | 369{ 370 int sum = 0; 371 long bitcnt, tmp; |
372 struct zoran *zr = videocodec_to_zoran(ptr->codec); |
|
429 430 if (ptr->mode == CODEC_DO_COMPRESSION) { | 373 374 if (ptr->mode == CODEC_DO_COMPRESSION) { |
431 dprintk(2, "%s: COMPRESSION SETUP\n", ptr->name); | 375 zrdev_dbg(zr, "%s: COMPRESSION SETUP\n", ptr->name); |
432 433 /* 050 communicates with 057 in master mode */ 434 zr36050_write(ptr, ZR050_HARDWARE, ZR050_HW_MSTR); 435 436 /* encoding table preload for compression */ 437 zr36050_write(ptr, ZR050_MODE, 438 ZR050_MO_COMP | ZR050_MO_TLM); 439 zr36050_write(ptr, ZR050_OPTIONS, 0); --- 11 unchanged lines hidden (view full) --- 451 zr36050_write(ptr, ZR050_AF_M, 0xff); 452 zr36050_write(ptr, ZR050_AF_LO, 0xff); 453 454 /* setup the variable jpeg tables */ 455 sum += zr36050_set_sof(ptr); 456 sum += zr36050_set_sos(ptr); 457 sum += zr36050_set_dri(ptr); 458 | 376 377 /* 050 communicates with 057 in master mode */ 378 zr36050_write(ptr, ZR050_HARDWARE, ZR050_HW_MSTR); 379 380 /* encoding table preload for compression */ 381 zr36050_write(ptr, ZR050_MODE, 382 ZR050_MO_COMP | ZR050_MO_TLM); 383 zr36050_write(ptr, ZR050_OPTIONS, 0); --- 11 unchanged lines hidden (view full) --- 395 zr36050_write(ptr, ZR050_AF_M, 0xff); 396 zr36050_write(ptr, ZR050_AF_LO, 0xff); 397 398 /* setup the variable jpeg tables */ 399 sum += zr36050_set_sof(ptr); 400 sum += zr36050_set_sos(ptr); 401 sum += zr36050_set_dri(ptr); 402 |
459 /* setup the fixed jpeg tables - maybe variable, though - 460 * (see table init section above) */ 461 dprintk(3, "%s: write DQT, DHT, APP\n", ptr->name); | 403 /* 404 * setup the fixed jpeg tables - maybe variable, though - 405 * (see table init section above) 406 */ 407 zrdev_dbg(zr, "%s: write DQT, DHT, APP\n", ptr->name); |
462 sum += zr36050_pushit(ptr, ZR050_DQT_IDX, 463 sizeof(zr36050_dqt), zr36050_dqt); 464 sum += zr36050_pushit(ptr, ZR050_DHT_IDX, 465 sizeof(zr36050_dht), zr36050_dht); 466 zr36050_write(ptr, ZR050_APP_IDX, 0xff); 467 zr36050_write(ptr, ZR050_APP_IDX + 1, 0xe0 + ptr->app.appn); 468 zr36050_write(ptr, ZR050_APP_IDX + 2, 0x00); 469 zr36050_write(ptr, ZR050_APP_IDX + 3, ptr->app.len + 2); --- 6 unchanged lines hidden (view full) --- 476 sum += zr36050_pushit(ptr, ZR050_COM_IDX + 4, 60, 477 ptr->com.data) + 4; 478 479 /* do the internal huffman table preload */ 480 zr36050_write(ptr, ZR050_MARKERS_EN, ZR050_ME_DHTI); 481 482 zr36050_write(ptr, ZR050_GO, 1); // launch codec 483 zr36050_wait_end(ptr); | 408 sum += zr36050_pushit(ptr, ZR050_DQT_IDX, 409 sizeof(zr36050_dqt), zr36050_dqt); 410 sum += zr36050_pushit(ptr, ZR050_DHT_IDX, 411 sizeof(zr36050_dht), zr36050_dht); 412 zr36050_write(ptr, ZR050_APP_IDX, 0xff); 413 zr36050_write(ptr, ZR050_APP_IDX + 1, 0xe0 + ptr->app.appn); 414 zr36050_write(ptr, ZR050_APP_IDX + 2, 0x00); 415 zr36050_write(ptr, ZR050_APP_IDX + 3, ptr->app.len + 2); --- 6 unchanged lines hidden (view full) --- 422 sum += zr36050_pushit(ptr, ZR050_COM_IDX + 4, 60, 423 ptr->com.data) + 4; 424 425 /* do the internal huffman table preload */ 426 zr36050_write(ptr, ZR050_MARKERS_EN, ZR050_ME_DHTI); 427 428 zr36050_write(ptr, ZR050_GO, 1); // launch codec 429 zr36050_wait_end(ptr); |
484 dprintk(2, "%s: Status after table preload: 0x%02x\n", 485 ptr->name, ptr->status1); | 430 zrdev_dbg(zr, "%s: Status after table preload: 0x%02x\n", 431 ptr->name, ptr->status1); |
486 487 if ((ptr->status1 & 0x4) == 0) { | 432 433 if ((ptr->status1 & 0x4) == 0) { |
488 dprintk(1, KERN_ERR "%s: init aborted!\n", 489 ptr->name); | 434 zrdev_err(zr, "%s: init aborted!\n", ptr->name); |
490 return; // something is wrong, its timed out!!!! 491 } 492 493 /* setup misc. data for compression (target code sizes) */ 494 495 /* size of compressed code to reach without header data */ 496 sum = ptr->real_code_vol - sum; 497 bitcnt = sum << 3; /* need the size in bits */ 498 499 tmp = bitcnt >> 16; | 435 return; // something is wrong, its timed out!!!! 436 } 437 438 /* setup misc. data for compression (target code sizes) */ 439 440 /* size of compressed code to reach without header data */ 441 sum = ptr->real_code_vol - sum; 442 bitcnt = sum << 3; /* need the size in bits */ 443 444 tmp = bitcnt >> 16; |
500 dprintk(3, 501 "%s: code: csize=%d, tot=%d, bit=%ld, highbits=%ld\n", 502 ptr->name, sum, ptr->real_code_vol, bitcnt, tmp); | 445 zrdev_dbg(zr, 446 "%s: code: csize=%d, tot=%d, bit=%ld, highbits=%ld\n", 447 ptr->name, sum, ptr->real_code_vol, bitcnt, tmp); |
503 zr36050_write(ptr, ZR050_TCV_NET_HI, tmp >> 8); 504 zr36050_write(ptr, ZR050_TCV_NET_MH, tmp & 0xff); 505 tmp = bitcnt & 0xffff; 506 zr36050_write(ptr, ZR050_TCV_NET_ML, tmp >> 8); 507 zr36050_write(ptr, ZR050_TCV_NET_LO, tmp & 0xff); 508 509 bitcnt -= bitcnt >> 7; // bits without stuffing 510 bitcnt -= ((bitcnt * 5) >> 6); // bits without eob 511 512 tmp = bitcnt >> 16; | 448 zr36050_write(ptr, ZR050_TCV_NET_HI, tmp >> 8); 449 zr36050_write(ptr, ZR050_TCV_NET_MH, tmp & 0xff); 450 tmp = bitcnt & 0xffff; 451 zr36050_write(ptr, ZR050_TCV_NET_ML, tmp >> 8); 452 zr36050_write(ptr, ZR050_TCV_NET_LO, tmp & 0xff); 453 454 bitcnt -= bitcnt >> 7; // bits without stuffing 455 bitcnt -= ((bitcnt * 5) >> 6); // bits without eob 456 457 tmp = bitcnt >> 16; |
513 dprintk(3, "%s: code: nettobit=%ld, highnettobits=%ld\n", 514 ptr->name, bitcnt, tmp); | 458 zrdev_dbg(zr, "%s: code: nettobit=%ld, highnettobits=%ld\n", 459 ptr->name, bitcnt, tmp); |
515 zr36050_write(ptr, ZR050_TCV_DATA_HI, tmp >> 8); 516 zr36050_write(ptr, ZR050_TCV_DATA_MH, tmp & 0xff); 517 tmp = bitcnt & 0xffff; 518 zr36050_write(ptr, ZR050_TCV_DATA_ML, tmp >> 8); 519 zr36050_write(ptr, ZR050_TCV_DATA_LO, tmp & 0xff); 520 521 /* compression setup with or without bitrate control */ 522 zr36050_write(ptr, ZR050_MODE, 523 ZR050_MO_COMP | ZR050_MO_PASS2 | 524 (ptr->bitrate_ctrl ? ZR050_MO_BRC : 0)); 525 526 /* this headers seem to deliver "valid AVI" jpeg frames */ 527 zr36050_write(ptr, ZR050_MARKERS_EN, 528 ZR050_ME_DQT | ZR050_ME_DHT | 529 ((ptr->app.len > 0) ? ZR050_ME_APP : 0) | 530 ((ptr->com.len > 0) ? ZR050_ME_COM : 0)); 531 } else { | 460 zr36050_write(ptr, ZR050_TCV_DATA_HI, tmp >> 8); 461 zr36050_write(ptr, ZR050_TCV_DATA_MH, tmp & 0xff); 462 tmp = bitcnt & 0xffff; 463 zr36050_write(ptr, ZR050_TCV_DATA_ML, tmp >> 8); 464 zr36050_write(ptr, ZR050_TCV_DATA_LO, tmp & 0xff); 465 466 /* compression setup with or without bitrate control */ 467 zr36050_write(ptr, ZR050_MODE, 468 ZR050_MO_COMP | ZR050_MO_PASS2 | 469 (ptr->bitrate_ctrl ? ZR050_MO_BRC : 0)); 470 471 /* this headers seem to deliver "valid AVI" jpeg frames */ 472 zr36050_write(ptr, ZR050_MARKERS_EN, 473 ZR050_ME_DQT | ZR050_ME_DHT | 474 ((ptr->app.len > 0) ? ZR050_ME_APP : 0) | 475 ((ptr->com.len > 0) ? ZR050_ME_COM : 0)); 476 } else { |
532 dprintk(2, "%s: EXPANSION SETUP\n", ptr->name); | 477 zrdev_dbg(zr, "%s: EXPANSION SETUP\n", ptr->name); |
533 534 /* 050 communicates with 055 in master mode */ 535 zr36050_write(ptr, ZR050_HARDWARE, 536 ZR050_HW_MSTR | ZR050_HW_CFIS_2_CLK); 537 538 /* encoding table preload */ 539 zr36050_write(ptr, ZR050_MODE, ZR050_MO_TLM); 540 541 /* disable all IRQs */ 542 zr36050_write(ptr, ZR050_INT_REQ_0, 0); 543 zr36050_write(ptr, ZR050_INT_REQ_1, 3); // low 2 bits always 1 544 | 478 479 /* 050 communicates with 055 in master mode */ 480 zr36050_write(ptr, ZR050_HARDWARE, 481 ZR050_HW_MSTR | ZR050_HW_CFIS_2_CLK); 482 483 /* encoding table preload */ 484 zr36050_write(ptr, ZR050_MODE, ZR050_MO_TLM); 485 486 /* disable all IRQs */ 487 zr36050_write(ptr, ZR050_INT_REQ_0, 0); 488 zr36050_write(ptr, ZR050_INT_REQ_1, 3); // low 2 bits always 1 489 |
545 dprintk(3, "%s: write DHT\n", ptr->name); | 490 zrdev_dbg(zr, "%s: write DHT\n", ptr->name); |
546 zr36050_pushit(ptr, ZR050_DHT_IDX, sizeof(zr36050_dht), 547 zr36050_dht); 548 549 /* do the internal huffman table preload */ 550 zr36050_write(ptr, ZR050_MARKERS_EN, ZR050_ME_DHTI); 551 552 zr36050_write(ptr, ZR050_GO, 1); // launch codec 553 zr36050_wait_end(ptr); | 491 zr36050_pushit(ptr, ZR050_DHT_IDX, sizeof(zr36050_dht), 492 zr36050_dht); 493 494 /* do the internal huffman table preload */ 495 zr36050_write(ptr, ZR050_MARKERS_EN, ZR050_ME_DHTI); 496 497 zr36050_write(ptr, ZR050_GO, 1); // launch codec 498 zr36050_wait_end(ptr); |
554 dprintk(2, "%s: Status after table preload: 0x%02x\n", 555 ptr->name, ptr->status1); | 499 zrdev_dbg(zr, "%s: Status after table preload: 0x%02x\n", 500 ptr->name, ptr->status1); |
556 557 if ((ptr->status1 & 0x4) == 0) { | 501 502 if ((ptr->status1 & 0x4) == 0) { |
558 dprintk(1, KERN_ERR "%s: init aborted!\n", 559 ptr->name); | 503 zrdev_err(zr, "%s: init aborted!\n", ptr->name); |
560 return; // something is wrong, its timed out!!!! 561 } 562 563 /* setup misc. data for expansion */ 564 zr36050_write(ptr, ZR050_MODE, 0); 565 zr36050_write(ptr, ZR050_MARKERS_EN, 0); 566 } 567 568 /* adr on selected, to allow GO from master */ 569 zr36050_read(ptr, 0); 570} 571 | 504 return; // something is wrong, its timed out!!!! 505 } 506 507 /* setup misc. data for expansion */ 508 zr36050_write(ptr, ZR050_MODE, 0); 509 zr36050_write(ptr, ZR050_MARKERS_EN, 0); 510 } 511 512 /* adr on selected, to allow GO from master */ 513 zr36050_read(ptr, 0); 514} 515 |
572/* ========================================================================= 573 CODEC API FUNCTIONS | 516/* 517 * CODEC API FUNCTIONS 518 * 519 * this functions are accessed by the master via the API structure 520 */ |
574 | 521 |
575 this functions are accessed by the master via the API structure 576 ========================================================================= */ 577 578/* set compression/expansion mode and launches codec - 579 this should be the last call from the master before starting processing */ 580static int 581zr36050_set_mode (struct videocodec *codec, 582 int mode) | 522/* 523 * set compression/expansion mode and launches codec - 524 * this should be the last call from the master before starting processing 525 */ 526static int zr36050_set_mode(struct videocodec *codec, int mode) |
583{ | 527{ |
584 struct zr36050 *ptr = (struct zr36050 *) codec->data; | 528 struct zr36050 *ptr = (struct zr36050 *)codec->data; 529 struct zoran *zr = videocodec_to_zoran(codec); |
585 | 530 |
586 dprintk(2, "%s: set_mode %d call\n", ptr->name, mode); | 531 zrdev_dbg(zr, "%s: set_mode %d call\n", ptr->name, mode); |
587 588 if ((mode != CODEC_DO_EXPANSION) && (mode != CODEC_DO_COMPRESSION)) 589 return -EINVAL; 590 591 ptr->mode = mode; 592 zr36050_init(ptr); 593 594 return 0; 595} 596 597/* set picture size (norm is ignored as the codec doesn't know about it) */ | 532 533 if ((mode != CODEC_DO_EXPANSION) && (mode != CODEC_DO_COMPRESSION)) 534 return -EINVAL; 535 536 ptr->mode = mode; 537 zr36050_init(ptr); 538 539 return 0; 540} 541 542/* set picture size (norm is ignored as the codec doesn't know about it) */ |
598static int 599zr36050_set_video (struct videocodec *codec, 600 struct tvnorm *norm, 601 struct vfe_settings *cap, 602 struct vfe_polarity *pol) | 543static int zr36050_set_video(struct videocodec *codec, const struct tvnorm *norm, 544 struct vfe_settings *cap, struct vfe_polarity *pol) |
603{ | 545{ |
604 struct zr36050 *ptr = (struct zr36050 *) codec->data; | 546 struct zr36050 *ptr = (struct zr36050 *)codec->data; 547 struct zoran *zr = videocodec_to_zoran(codec); |
605 int size; 606 | 548 int size; 549 |
607 dprintk(2, "%s: set_video %d.%d, %d/%d-%dx%d (0x%x) q%d call\n", 608 ptr->name, norm->HStart, norm->VStart, 609 cap->x, cap->y, cap->width, cap->height, 610 cap->decimation, cap->quality); 611 /* if () return -EINVAL; | 550 zrdev_dbg(zr, "%s: set_video %d.%d, %d/%d-%dx%d (0x%x) q%d call\n", 551 ptr->name, norm->h_start, norm->v_start, 552 cap->x, cap->y, cap->width, cap->height, 553 cap->decimation, cap->quality); 554 /* |
612 * trust the master driver that it knows what it does - so | 555 * trust the master driver that it knows what it does - so |
613 * we allow invalid startx/y and norm for now ... */ | 556 * we allow invalid startx/y and norm for now ... 557 */ |
614 ptr->width = cap->width / (cap->decimation & 0xff); 615 ptr->height = cap->height / ((cap->decimation >> 8) & 0xff); 616 617 /* (KM) JPEG quality */ 618 size = ptr->width * ptr->height; 619 size *= 16; /* size in bits */ 620 /* apply quality setting */ 621 size = size * cap->quality / 200; 622 623 /* Minimum: 1kb */ 624 if (size < 8192) 625 size = 8192; 626 /* Maximum: 7/8 of code buffer */ 627 if (size > ptr->total_code_vol * 7) 628 size = ptr->total_code_vol * 7; 629 630 ptr->real_code_vol = size >> 3; /* in bytes */ 631 | 558 ptr->width = cap->width / (cap->decimation & 0xff); 559 ptr->height = cap->height / ((cap->decimation >> 8) & 0xff); 560 561 /* (KM) JPEG quality */ 562 size = ptr->width * ptr->height; 563 size *= 16; /* size in bits */ 564 /* apply quality setting */ 565 size = size * cap->quality / 200; 566 567 /* Minimum: 1kb */ 568 if (size < 8192) 569 size = 8192; 570 /* Maximum: 7/8 of code buffer */ 571 if (size > ptr->total_code_vol * 7) 572 size = ptr->total_code_vol * 7; 573 574 ptr->real_code_vol = size >> 3; /* in bytes */ 575 |
632 /* Set max_block_vol here (previously in zr36050_init, moved 633 * here for consistency with zr36060 code */ | 576 /* 577 * Set max_block_vol here (previously in zr36050_init, moved 578 * here for consistency with zr36060 code 579 */ |
634 zr36050_write(ptr, ZR050_MBCV, ptr->max_block_vol); 635 636 return 0; 637} 638 639/* additional control functions */ | 580 zr36050_write(ptr, ZR050_MBCV, ptr->max_block_vol); 581 582 return 0; 583} 584 585/* additional control functions */ |
640static int 641zr36050_control (struct videocodec *codec, 642 int type, 643 int size, 644 void *data) | 586static int zr36050_control(struct videocodec *codec, int type, int size, void *data) |
645{ | 587{ |
646 struct zr36050 *ptr = (struct zr36050 *) codec->data; 647 int *ival = (int *) data; | 588 struct zr36050 *ptr = (struct zr36050 *)codec->data; 589 struct zoran *zr = videocodec_to_zoran(codec); 590 int *ival = (int *)data; |
648 | 591 |
649 dprintk(2, "%s: control %d call with %d byte\n", ptr->name, type, 650 size); | 592 zrdev_dbg(zr, "%s: control %d call with %d byte\n", ptr->name, type, 593 size); |
651 652 switch (type) { 653 case CODEC_G_STATUS: /* get last status */ 654 if (size != sizeof(int)) 655 return -EFAULT; 656 zr36050_read_status1(ptr); 657 *ival = ptr->status1; 658 break; --- 26 unchanged lines hidden (view full) --- 685 return -EFAULT; 686 *ival = ptr->total_code_vol; 687 break; 688 689 case CODEC_S_JPEG_TDS_BYTE: /* get target volume in byte */ 690 if (size != sizeof(int)) 691 return -EFAULT; 692 ptr->total_code_vol = *ival; | 594 595 switch (type) { 596 case CODEC_G_STATUS: /* get last status */ 597 if (size != sizeof(int)) 598 return -EFAULT; 599 zr36050_read_status1(ptr); 600 *ival = ptr->status1; 601 break; --- 26 unchanged lines hidden (view full) --- 628 return -EFAULT; 629 *ival = ptr->total_code_vol; 630 break; 631 632 case CODEC_S_JPEG_TDS_BYTE: /* get target volume in byte */ 633 if (size != sizeof(int)) 634 return -EFAULT; 635 ptr->total_code_vol = *ival; |
693 /* (Kieran Morrissey) 694 * code copied from zr36060.c to ensure proper bitrate */ | |
695 ptr->real_code_vol = (ptr->total_code_vol * 6) >> 3; 696 break; 697 698 case CODEC_G_JPEG_SCALE: /* get scaling factor */ 699 if (size != sizeof(int)) 700 return -EFAULT; 701 *ival = zr36050_read_scalefactor(ptr); 702 break; --- 46 unchanged lines hidden (view full) --- 749 750 default: 751 return -EINVAL; 752 } 753 754 return size; 755} 756 | 636 ptr->real_code_vol = (ptr->total_code_vol * 6) >> 3; 637 break; 638 639 case CODEC_G_JPEG_SCALE: /* get scaling factor */ 640 if (size != sizeof(int)) 641 return -EFAULT; 642 *ival = zr36050_read_scalefactor(ptr); 643 break; --- 46 unchanged lines hidden (view full) --- 690 691 default: 692 return -EINVAL; 693 } 694 695 return size; 696} 697 |
757/* ========================================================================= 758 Exit and unregister function: | 698/* Exit and unregister function: Deinitializes Zoran's JPEG processor */ |
759 | 699 |
760 Deinitializes Zoran's JPEG processor 761 ========================================================================= */ 762 763static int 764zr36050_unset (struct videocodec *codec) | 700static int zr36050_unset(struct videocodec *codec) |
765{ 766 struct zr36050 *ptr = codec->data; | 701{ 702 struct zr36050 *ptr = codec->data; |
703 struct zoran *zr = videocodec_to_zoran(codec); |
|
767 768 if (ptr) { 769 /* do wee need some codec deinit here, too ???? */ 770 | 704 705 if (ptr) { 706 /* do wee need some codec deinit here, too ???? */ 707 |
771 dprintk(1, "%s: finished codec #%d\n", ptr->name, 772 ptr->num); | 708 zrdev_dbg(zr, "%s: finished codec #%d\n", ptr->name, 709 ptr->num); |
773 kfree(ptr); 774 codec->data = NULL; 775 776 zr36050_codecs--; 777 return 0; 778 } 779 780 return -EFAULT; 781} 782 | 710 kfree(ptr); 711 codec->data = NULL; 712 713 zr36050_codecs--; 714 return 0; 715 } 716 717 return -EFAULT; 718} 719 |
783/* ========================================================================= 784 Setup and registry function: | 720/* 721 * Setup and registry function: 722 * 723 * Initializes Zoran's JPEG processor 724 * 725 * Also sets pixel size, average code size, mode (compr./decompr.) 726 * (the given size is determined by the processor with the video interface) 727 */ |
785 | 728 |
786 Initializes Zoran's JPEG processor 787 788 Also sets pixel size, average code size, mode (compr./decompr.) 789 (the given size is determined by the processor with the video interface) 790 ========================================================================= */ 791 792static int 793zr36050_setup (struct videocodec *codec) | 729static int zr36050_setup(struct videocodec *codec) |
794{ 795 struct zr36050 *ptr; | 730{ 731 struct zr36050 *ptr; |
732 struct zoran *zr = videocodec_to_zoran(codec); |
|
796 int res; 797 | 733 int res; 734 |
798 dprintk(2, "zr36050: initializing MJPEG subsystem #%d.\n", 799 zr36050_codecs); | 735 zrdev_dbg(zr, "zr36050: initializing MJPEG subsystem #%d.\n", 736 zr36050_codecs); |
800 801 if (zr36050_codecs == MAX_CODECS) { | 737 738 if (zr36050_codecs == MAX_CODECS) { |
802 dprintk(1, 803 KERN_ERR "zr36050: Can't attach more codecs!\n"); | 739 zrdev_err(zr, 740 "zr36050: Can't attach more codecs!\n"); |
804 return -ENOSPC; 805 } 806 //mem structure init | 741 return -ENOSPC; 742 } 743 //mem structure init |
807 codec->data = ptr = kzalloc(sizeof(struct zr36050), GFP_KERNEL); 808 if (NULL == ptr) { 809 dprintk(1, KERN_ERR "zr36050: Can't get enough memory!\n"); | 744 ptr = kzalloc(sizeof(*ptr), GFP_KERNEL); 745 codec->data = ptr; 746 if (!ptr) |
810 return -ENOMEM; | 747 return -ENOMEM; |
811 } | |
812 813 snprintf(ptr->name, sizeof(ptr->name), "zr36050[%d]", 814 zr36050_codecs); 815 ptr->num = zr36050_codecs++; 816 ptr->codec = codec; 817 818 //testing 819 res = zr36050_basic_test(ptr); 820 if (res < 0) { 821 zr36050_unset(codec); 822 return res; 823 } 824 //final setup 825 memcpy(ptr->h_samp_ratio, zr36050_decimation_h, 8); 826 memcpy(ptr->v_samp_ratio, zr36050_decimation_v, 8); 827 | 748 749 snprintf(ptr->name, sizeof(ptr->name), "zr36050[%d]", 750 zr36050_codecs); 751 ptr->num = zr36050_codecs++; 752 ptr->codec = codec; 753 754 //testing 755 res = zr36050_basic_test(ptr); 756 if (res < 0) { 757 zr36050_unset(codec); 758 return res; 759 } 760 //final setup 761 memcpy(ptr->h_samp_ratio, zr36050_decimation_h, 8); 762 memcpy(ptr->v_samp_ratio, zr36050_decimation_v, 8); 763 |
828 ptr->bitrate_ctrl = 0; /* 0 or 1 - fixed file size flag 829 * (what is the difference?) */ | 764 /* 0 or 1 - fixed file size flag (what is the difference?) */ 765 ptr->bitrate_ctrl = 0; |
830 ptr->mode = CODEC_DO_COMPRESSION; 831 ptr->width = 384; 832 ptr->height = 288; 833 ptr->total_code_vol = 16000; 834 ptr->max_block_vol = 240; 835 ptr->scalefact = 0x100; 836 ptr->dri = 1; 837 838 /* no app/com marker by default */ 839 ptr->app.appn = 0; 840 ptr->app.len = 0; 841 ptr->com.len = 0; 842 843 zr36050_init(ptr); 844 | 766 ptr->mode = CODEC_DO_COMPRESSION; 767 ptr->width = 384; 768 ptr->height = 288; 769 ptr->total_code_vol = 16000; 770 ptr->max_block_vol = 240; 771 ptr->scalefact = 0x100; 772 ptr->dri = 1; 773 774 /* no app/com marker by default */ 775 ptr->app.appn = 0; 776 ptr->app.len = 0; 777 ptr->com.len = 0; 778 779 zr36050_init(ptr); 780 |
845 dprintk(1, KERN_INFO "%s: codec attached and running\n", 846 ptr->name); | 781 zrdev_info(zr, "%s: codec attached and running\n", 782 ptr->name); |
847 848 return 0; 849} 850 851static const struct videocodec zr36050_codec = { | 783 784 return 0; 785} 786 787static const struct videocodec zr36050_codec = { |
852 .owner = THIS_MODULE, | |
853 .name = "zr36050", 854 .magic = 0L, // magic not used 855 .flags = 856 CODEC_FLAG_JPEG | CODEC_FLAG_HARDWARE | CODEC_FLAG_ENCODER | 857 CODEC_FLAG_DECODER, 858 .type = CODEC_TYPE_ZR36050, 859 .setup = zr36050_setup, // functionality 860 .unset = zr36050_unset, 861 .set_mode = zr36050_set_mode, 862 .set_video = zr36050_set_video, 863 .control = zr36050_control, 864 // others are not used 865}; 866 | 788 .name = "zr36050", 789 .magic = 0L, // magic not used 790 .flags = 791 CODEC_FLAG_JPEG | CODEC_FLAG_HARDWARE | CODEC_FLAG_ENCODER | 792 CODEC_FLAG_DECODER, 793 .type = CODEC_TYPE_ZR36050, 794 .setup = zr36050_setup, // functionality 795 .unset = zr36050_unset, 796 .set_mode = zr36050_set_mode, 797 .set_video = zr36050_set_video, 798 .control = zr36050_control, 799 // others are not used 800}; 801 |
867/* ========================================================================= 868 HOOK IN DRIVER AS KERNEL MODULE 869 ========================================================================= */ | 802/* HOOK IN DRIVER AS KERNEL MODULE */ |
870 | 803 |
871static int __init 872zr36050_init_module (void) | 804int zr36050_init_module(void) |
873{ | 805{ |
874 //dprintk(1, "ZR36050 driver %s\n",ZR050_VERSION); | |
875 zr36050_codecs = 0; 876 return videocodec_register(&zr36050_codec); 877} 878 | 806 zr36050_codecs = 0; 807 return videocodec_register(&zr36050_codec); 808} 809 |
879static void __exit 880zr36050_cleanup_module (void) | 810void zr36050_cleanup_module(void) |
881{ 882 if (zr36050_codecs) { | 811{ 812 if (zr36050_codecs) { |
883 dprintk(1, 884 "zr36050: something's wrong - %d codecs left somehow.\n", 885 zr36050_codecs); | 813 pr_debug("zr36050: something's wrong - %d codecs left somehow.\n", 814 zr36050_codecs); |
886 } 887 videocodec_unregister(&zr36050_codec); 888} | 815 } 816 videocodec_unregister(&zr36050_codec); 817} |
889 890module_init(zr36050_init_module); 891module_exit(zr36050_cleanup_module); 892 893MODULE_AUTHOR("Wolfgang Scherr <scherr@net4you.at>"); 894MODULE_DESCRIPTION("Driver module for ZR36050 jpeg processors " 895 ZR050_VERSION); 896MODULE_LICENSE("GPL"); | |