diff options
author | Jiri Slaby <xslaby@fi.muni.cz> | 2006-01-11 16:41:32 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@brturbo.com.br> | 2006-01-11 16:41:32 -0500 |
commit | f823f6793659e63f9f22d3d7617a457806d6d69a (patch) | |
tree | 1e562248727368f0f3120456db88b98c2d705187 /drivers | |
parent | 91fb8357c3e097a46eb6e92d03b284182172ce80 (diff) |
V4L/DVB (3344e): Stradis Lindent
Stradis Lindent + some handwork
Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/media/video/stradis.c | 803 |
1 files changed, 389 insertions, 414 deletions
diff --git a/drivers/media/video/stradis.c b/drivers/media/video/stradis.c index 48cd30d8eb5a..54fc33011ffb 100644 --- a/drivers/media/video/stradis.c +++ b/drivers/media/video/stradis.c | |||
@@ -49,9 +49,9 @@ | |||
49 | #include "saa7121.h" | 49 | #include "saa7121.h" |
50 | #include "cs8420.h" | 50 | #include "cs8420.h" |
51 | 51 | ||
52 | #define DEBUG(x) /* debug driver */ | 52 | #define DEBUG(x) /* debug driver */ |
53 | #undef IDEBUG /* debug irq handler */ | 53 | #undef IDEBUG /* debug irq handler */ |
54 | #undef MDEBUG /* debug memory management */ | 54 | #undef MDEBUG /* debug memory management */ |
55 | 55 | ||
56 | #define SAA7146_MAX 6 | 56 | #define SAA7146_MAX 6 |
57 | 57 | ||
@@ -63,7 +63,6 @@ static int video_nr = -1; | |||
63 | module_param(video_nr, int, 0); | 63 | module_param(video_nr, int, 0); |
64 | MODULE_LICENSE("GPL"); | 64 | MODULE_LICENSE("GPL"); |
65 | 65 | ||
66 | |||
67 | #define nDebNormal 0x00480000 | 66 | #define nDebNormal 0x00480000 |
68 | #define nDebNoInc 0x00480000 | 67 | #define nDebNoInc 0x00480000 |
69 | #define nDebVideo 0xd0480000 | 68 | #define nDebVideo 0xd0480000 |
@@ -99,7 +98,12 @@ MODULE_LICENSE("GPL"); | |||
99 | 98 | ||
100 | #ifdef USE_RESCUE_EEPROM_SDM275 | 99 | #ifdef USE_RESCUE_EEPROM_SDM275 |
101 | static unsigned char rescue_eeprom[64] = { | 100 | static unsigned char rescue_eeprom[64] = { |
102 | 0x00,0x01,0x04,0x13,0x26,0x0f,0x10,0x00,0x00,0x00,0x43,0x63,0x22,0x01,0x29,0x15,0x73,0x00,0x1f, 'd', 'e', 'c', 'x', 'l', 'd', 'v', 'a',0x02,0x00,0x01,0x00,0xcc,0xa4,0x63,0x09,0xe2,0x10,0x00,0x0a,0x00,0x02,0x02, 'd', 'e', 'c', 'x', 'l', 'a',0x00,0x00,0x42,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | 101 | 0x00, 0x01, 0x04, 0x13, 0x26, 0x0f, 0x10, 0x00, 0x00, 0x00, 0x43, 0x63, |
102 | 0x22, 0x01, 0x29, 0x15, 0x73, 0x00, 0x1f, 'd', 'e', 'c', 'x', 'l', | ||
103 | 'd', 'v', 'a', 0x02, 0x00, 0x01, 0x00, 0xcc, 0xa4, 0x63, 0x09, 0xe2, | ||
104 | 0x10, 0x00, 0x0a, 0x00, 0x02, 0x02, 'd', 'e', 'c', 'x', 'l', 'a', | ||
105 | 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
106 | 0x00, 0x00, 0x00, 0x00, | ||
103 | }; | 107 | }; |
104 | #endif | 108 | #endif |
105 | 109 | ||
@@ -140,17 +144,18 @@ static int I2CRead(struct saa7146 *saa, unsigned char addr, | |||
140 | 144 | ||
141 | if (saaread(SAA7146_I2C_STATUS) & 0x3c) | 145 | if (saaread(SAA7146_I2C_STATUS) & 0x3c) |
142 | I2CWipe(saa); | 146 | I2CWipe(saa); |
143 | for (i = 0; i < 1000 && | 147 | for (i = 0; |
144 | (saaread(SAA7146_I2C_STATUS) & SAA7146_I2C_BUSY); i++) | 148 | i < 1000 && (saaread(SAA7146_I2C_STATUS) & SAA7146_I2C_BUSY); |
149 | i++) | ||
145 | schedule(); | 150 | schedule(); |
146 | if (i == 1000) | 151 | if (i == 1000) |
147 | I2CWipe(saa); | 152 | I2CWipe(saa); |
148 | if (dosub) | 153 | if (dosub) |
149 | saawrite(((addr & 0xfe) << 24) | (((addr | 1) & 0xff) << 8) | | 154 | saawrite(((addr & 0xfe) << 24) | (((addr | 1) & 0xff) << 8) | |
150 | ((subaddr & 0xff) << 16) | 0xed, SAA7146_I2C_TRANSFER); | 155 | ((subaddr & 0xff) << 16) | 0xed, SAA7146_I2C_TRANSFER); |
151 | else | 156 | else |
152 | saawrite(((addr & 0xfe) << 24) | (((addr | 1) & 0xff) << 16) | | 157 | saawrite(((addr & 0xfe) << 24) | (((addr | 1) & 0xff) << 16) | |
153 | 0xf1, SAA7146_I2C_TRANSFER); | 158 | 0xf1, SAA7146_I2C_TRANSFER); |
154 | saawrite((SAA7146_MC2_UPLD_I2C << 16) | | 159 | saawrite((SAA7146_MC2_UPLD_I2C << 16) | |
155 | SAA7146_MC2_UPLD_I2C, SAA7146_MC2); | 160 | SAA7146_MC2_UPLD_I2C, SAA7146_MC2); |
156 | /* wait for i2c registers to be programmed */ | 161 | /* wait for i2c registers to be programmed */ |
@@ -163,7 +168,7 @@ static int I2CRead(struct saa7146 *saa, unsigned char addr, | |||
163 | schedule(); | 168 | schedule(); |
164 | if (saaread(SAA7146_I2C_STATUS) & SAA7146_I2C_ERR) | 169 | if (saaread(SAA7146_I2C_STATUS) & SAA7146_I2C_ERR) |
165 | return -1; | 170 | return -1; |
166 | if (i == 1000) | 171 | if (i == 1000) |
167 | printk("i2c setup read timeout\n"); | 172 | printk("i2c setup read timeout\n"); |
168 | saawrite(0x41, SAA7146_I2C_TRANSFER); | 173 | saawrite(0x41, SAA7146_I2C_TRANSFER); |
169 | saawrite((SAA7146_MC2_UPLD_I2C << 16) | | 174 | saawrite((SAA7146_MC2_UPLD_I2C << 16) | |
@@ -178,7 +183,7 @@ static int I2CRead(struct saa7146 *saa, unsigned char addr, | |||
178 | schedule(); | 183 | schedule(); |
179 | if (saaread(SAA7146_I2C_TRANSFER) & SAA7146_I2C_ERR) | 184 | if (saaread(SAA7146_I2C_TRANSFER) & SAA7146_I2C_ERR) |
180 | return -1; | 185 | return -1; |
181 | if (i == 1000) | 186 | if (i == 1000) |
182 | printk("i2c read timeout\n"); | 187 | printk("i2c read timeout\n"); |
183 | return ((saaread(SAA7146_I2C_TRANSFER) >> 24) & 0xff); | 188 | return ((saaread(SAA7146_I2C_TRANSFER) >> 24) & 0xff); |
184 | } | 189 | } |
@@ -213,20 +218,22 @@ static void attach_inform(struct saa7146 *saa, int id) | |||
213 | { | 218 | { |
214 | int i; | 219 | int i; |
215 | 220 | ||
216 | DEBUG(printk(KERN_DEBUG "stradis%d: i2c: device found=%02x\n", saa->nr, id)); | 221 | DEBUG(printk(KERN_DEBUG "stradis%d: i2c: device found=%02x\n", saa->nr, |
217 | if (id == 0xa0) { /* we have rev2 or later board, fill in info */ | 222 | id)); |
223 | if (id == 0xa0) { /* we have rev2 or later board, fill in info */ | ||
218 | for (i = 0; i < 64; i++) | 224 | for (i = 0; i < 64; i++) |
219 | saa->boardcfg[i] = I2CRead(saa, 0xa0, i, 1); | 225 | saa->boardcfg[i] = I2CRead(saa, 0xa0, i, 1); |
220 | #ifdef USE_RESCUE_EEPROM_SDM275 | 226 | #ifdef USE_RESCUE_EEPROM_SDM275 |
221 | if (saa->boardcfg[0] != 0) { | 227 | if (saa->boardcfg[0] != 0) { |
222 | printk("stradis%d: WARNING: EEPROM STORED VALUES HAVE BEEN IGNORED\n", saa->nr); | 228 | printk("stradis%d: WARNING: EEPROM STORED VALUES HAVE " |
229 | "BEEN IGNORED\n", saa->nr); | ||
223 | for (i = 0; i < 64; i++) | 230 | for (i = 0; i < 64; i++) |
224 | saa->boardcfg[i] = rescue_eeprom[i]; | 231 | saa->boardcfg[i] = rescue_eeprom[i]; |
225 | } | 232 | } |
226 | #endif | 233 | #endif |
227 | printk("stradis%d: config =", saa->nr); | 234 | printk("stradis%d: config =", saa->nr); |
228 | for (i = 0; i < 51; i++) { | 235 | for (i = 0; i < 51; i++) { |
229 | printk(" %02x",saa->boardcfg[i]); | 236 | printk(" %02x", saa->boardcfg[i]); |
230 | } | 237 | } |
231 | printk("\n"); | 238 | printk("\n"); |
232 | } | 239 | } |
@@ -254,17 +261,19 @@ static int wait_for_debi_done(struct saa7146 *saa) | |||
254 | for (i = 0; i < 500000 && | 261 | for (i = 0; i < 500000 && |
255 | (saaread(SAA7146_PSR) & SAA7146_PSR_DEBI_S); i++) | 262 | (saaread(SAA7146_PSR) & SAA7146_PSR_DEBI_S); i++) |
256 | saaread(SAA7146_MC2); | 263 | saaread(SAA7146_MC2); |
264 | |||
257 | if (i > debiwait_maxwait) | 265 | if (i > debiwait_maxwait) |
258 | printk("wait-for-debi-done maxwait: %d\n", | 266 | printk("wait-for-debi-done maxwait: %d\n", |
259 | debiwait_maxwait = i); | 267 | debiwait_maxwait = i); |
260 | 268 | ||
261 | if (i == 500000) | 269 | if (i == 500000) |
262 | return -1; | 270 | return -1; |
271 | |||
263 | return 0; | 272 | return 0; |
264 | } | 273 | } |
265 | 274 | ||
266 | static int debiwrite(struct saa7146 *saa, u32 config, int addr, | 275 | static int debiwrite(struct saa7146 *saa, u32 config, int addr, |
267 | u32 val, int count) | 276 | u32 val, int count) |
268 | { | 277 | { |
269 | u32 cmd; | 278 | u32 cmd; |
270 | if (count <= 0 || count > 32764) | 279 | if (count <= 0 || count > 32764) |
@@ -330,16 +339,15 @@ static void do_irq_send_data(struct saa7146 *saa) | |||
330 | return; | 339 | return; |
331 | } | 340 | } |
332 | /* if at least 1 block audio waiting and audio fifo isn't full */ | 341 | /* if at least 1 block audio waiting and audio fifo isn't full */ |
333 | if (audbytes >= 2048 && (debiread(saa, debNormal, | 342 | if (audbytes >= 2048 && (debiread(saa, debNormal, IBM_MP2_AUD_FIFO, 2) |
334 | IBM_MP2_AUD_FIFO, 2) & 0xff) < 60) { | 343 | & 0xff) < 60) { |
335 | if (saa->audhead > saa->audtail) | 344 | if (saa->audhead > saa->audtail) |
336 | split = 65536 - saa->audhead; | 345 | split = 65536 - saa->audhead; |
337 | else | 346 | else |
338 | split = 0; | 347 | split = 0; |
339 | audbytes = 2048; | 348 | audbytes = 2048; |
340 | if (split > 0 && split < 2048) { | 349 | if (split > 0 && split < 2048) { |
341 | memcpy(saa->dmadebi, saa->audbuf + saa->audhead, | 350 | memcpy(saa->dmadebi, saa->audbuf + saa->audhead, split); |
342 | split); | ||
343 | saa->audhead = 0; | 351 | saa->audhead = 0; |
344 | audbytes -= split; | 352 | audbytes -= split; |
345 | } else | 353 | } else |
@@ -348,20 +356,19 @@ static void do_irq_send_data(struct saa7146 *saa) | |||
348 | audbytes); | 356 | audbytes); |
349 | saa->audhead += audbytes; | 357 | saa->audhead += audbytes; |
350 | saa->audhead &= 0xffff; | 358 | saa->audhead &= 0xffff; |
351 | debiwrite(saa, debAudio, (NewCard? IBM_MP2_AUD_FIFO : | 359 | debiwrite(saa, debAudio, (NewCard ? IBM_MP2_AUD_FIFO : |
352 | IBM_MP2_AUD_FIFOW), 0, 2048); | 360 | IBM_MP2_AUD_FIFOW), 0, 2048); |
353 | wake_up_interruptible(&saa->audq); | 361 | wake_up_interruptible(&saa->audq); |
354 | /* if at least 1 block video waiting and video fifo isn't full */ | 362 | /* if at least 1 block video waiting and video fifo isn't full */ |
355 | } else if (vidbytes >= 30720 && (debiread(saa, debNormal, | 363 | } else if (vidbytes >= 30720 && (debiread(saa, debNormal, |
356 | IBM_MP2_FIFO, 2)) < 16384) { | 364 | IBM_MP2_FIFO, 2)) < 16384) { |
357 | if (saa->vidhead > saa->vidtail) | 365 | if (saa->vidhead > saa->vidtail) |
358 | split = 524288 - saa->vidhead; | 366 | split = 524288 - saa->vidhead; |
359 | else | 367 | else |
360 | split = 0; | 368 | split = 0; |
361 | vidbytes = 30720; | 369 | vidbytes = 30720; |
362 | if (split > 0 && split < 30720) { | 370 | if (split > 0 && split < 30720) { |
363 | memcpy(saa->dmadebi, saa->vidbuf + saa->vidhead, | 371 | memcpy(saa->dmadebi, saa->vidbuf + saa->vidhead, split); |
364 | split); | ||
365 | saa->vidhead = 0; | 372 | saa->vidhead = 0; |
366 | vidbytes -= split; | 373 | vidbytes -= split; |
367 | } else | 374 | } else |
@@ -371,7 +378,7 @@ static void do_irq_send_data(struct saa7146 *saa) | |||
371 | saa->vidhead += vidbytes; | 378 | saa->vidhead += vidbytes; |
372 | saa->vidhead &= 0x7ffff; | 379 | saa->vidhead &= 0x7ffff; |
373 | debiwrite(saa, debVideo, (NewCard ? IBM_MP2_FIFO : | 380 | debiwrite(saa, debVideo, (NewCard ? IBM_MP2_FIFO : |
374 | IBM_MP2_FIFOW), 0, 30720); | 381 | IBM_MP2_FIFOW), 0, 30720); |
375 | wake_up_interruptible(&saa->vidq); | 382 | wake_up_interruptible(&saa->vidq); |
376 | } | 383 | } |
377 | saawrite(SAA7146_PSR_DEBI_S | SAA7146_PSR_PIN1, SAA7146_IER); | 384 | saawrite(SAA7146_PSR_DEBI_S | SAA7146_PSR_PIN1, SAA7146_IER); |
@@ -383,10 +390,10 @@ static void send_osd_data(struct saa7146 *saa) | |||
383 | if (size > 30720) | 390 | if (size > 30720) |
384 | size = 30720; | 391 | size = 30720; |
385 | /* ensure some multiple of 8 bytes is transferred */ | 392 | /* ensure some multiple of 8 bytes is transferred */ |
386 | size = 8 * ((size + 8)>>3); | 393 | size = 8 * ((size + 8) >> 3); |
387 | if (size) { | 394 | if (size) { |
388 | debiwrite(saa, debNormal, IBM_MP2_OSD_ADDR, | 395 | debiwrite(saa, debNormal, IBM_MP2_OSD_ADDR, |
389 | (saa->osdhead>>3), 2); | 396 | (saa->osdhead >> 3), 2); |
390 | memcpy(saa->dmadebi, &saa->osdbuf[saa->osdhead], size); | 397 | memcpy(saa->dmadebi, &saa->osdbuf[saa->osdhead], size); |
391 | saa->osdhead += size; | 398 | saa->osdhead += size; |
392 | /* block transfer of next 8 bytes to ~32k bytes */ | 399 | /* block transfer of next 8 bytes to ~32k bytes */ |
@@ -400,7 +407,7 @@ static void send_osd_data(struct saa7146 *saa) | |||
400 | 407 | ||
401 | static irqreturn_t saa7146_irq(int irq, void *dev_id, struct pt_regs *regs) | 408 | static irqreturn_t saa7146_irq(int irq, void *dev_id, struct pt_regs *regs) |
402 | { | 409 | { |
403 | struct saa7146 *saa = (struct saa7146 *) dev_id; | 410 | struct saa7146 *saa = dev_id; |
404 | u32 stat, astat; | 411 | u32 stat, astat; |
405 | int count; | 412 | int count; |
406 | int handled = 0; | 413 | int handled = 0; |
@@ -449,7 +456,7 @@ static irqreturn_t saa7146_irq(int irq, void *dev_id, struct pt_regs *regs) | |||
449 | saa->vidinfo.v_size = 480; | 456 | saa->vidinfo.v_size = 480; |
450 | #if 0 | 457 | #if 0 |
451 | if (saa->endmarkhead != saa->endmarktail) { | 458 | if (saa->endmarkhead != saa->endmarktail) { |
452 | saa->audhead = | 459 | saa->audhead = |
453 | saa->endmark[saa->endmarkhead]; | 460 | saa->endmark[saa->endmarkhead]; |
454 | saa->endmarkhead++; | 461 | saa->endmarkhead++; |
455 | if (saa->endmarkhead >= MAX_MARKS) | 462 | if (saa->endmarkhead >= MAX_MARKS) |
@@ -459,7 +466,7 @@ static irqreturn_t saa7146_irq(int irq, void *dev_id, struct pt_regs *regs) | |||
459 | } | 466 | } |
460 | if (istat & 0x4000) { /* Sequence Error Code */ | 467 | if (istat & 0x4000) { /* Sequence Error Code */ |
461 | if (saa->endmarkhead != saa->endmarktail) { | 468 | if (saa->endmarkhead != saa->endmarktail) { |
462 | saa->audhead = | 469 | saa->audhead = |
463 | saa->endmark[saa->endmarkhead]; | 470 | saa->endmark[saa->endmarkhead]; |
464 | saa->endmarkhead++; | 471 | saa->endmarkhead++; |
465 | if (saa->endmarkhead >= MAX_MARKS) | 472 | if (saa->endmarkhead >= MAX_MARKS) |
@@ -578,7 +585,7 @@ static int ibm_send_command(struct saa7146 *saa, | |||
578 | int i; | 585 | int i; |
579 | 586 | ||
580 | if (chain) | 587 | if (chain) |
581 | debiwrite(saa, debNormal, IBM_MP2_COMMAND, (command << 1) | 1, 2); | 588 | debiwrite(saa, debNormal, IBM_MP2_COMMAND, (command << 1)| 1,2); |
582 | else | 589 | else |
583 | debiwrite(saa, debNormal, IBM_MP2_COMMAND, command << 1, 2); | 590 | debiwrite(saa, debNormal, IBM_MP2_COMMAND, command << 1, 2); |
584 | debiwrite(saa, debNormal, IBM_MP2_CMD_DATA, data, 2); | 591 | debiwrite(saa, debNormal, IBM_MP2_CMD_DATA, data, 2); |
@@ -628,11 +635,9 @@ static void initialize_cs8420(struct saa7146 *saa, int pro) | |||
628 | else | 635 | else |
629 | sequence = mode8420con; | 636 | sequence = mode8420con; |
630 | for (i = 0; i < INIT8420LEN; i++) | 637 | for (i = 0; i < INIT8420LEN; i++) |
631 | I2CWrite(saa, 0x20, init8420[i * 2], | 638 | I2CWrite(saa, 0x20, init8420[i * 2], init8420[i * 2 + 1], 2); |
632 | init8420[i * 2 + 1], 2); | ||
633 | for (i = 0; i < MODE8420LEN; i++) | 639 | for (i = 0; i < MODE8420LEN; i++) |
634 | I2CWrite(saa, 0x20, sequence[i * 2], | 640 | I2CWrite(saa, 0x20, sequence[i * 2], sequence[i * 2 + 1], 2); |
635 | sequence[i * 2 + 1], 2); | ||
636 | printk("stradis%d: CS8420 initialized\n", saa->nr); | 641 | printk("stradis%d: CS8420 initialized\n", saa->nr); |
637 | } | 642 | } |
638 | 643 | ||
@@ -648,35 +653,36 @@ static void initialize_saa7121(struct saa7146 *saa, int dopal) | |||
648 | /* initialize PAL/NTSC video encoder */ | 653 | /* initialize PAL/NTSC video encoder */ |
649 | for (i = 0; i < INIT7121LEN; i++) { | 654 | for (i = 0; i < INIT7121LEN; i++) { |
650 | if (NewCard) { /* handle new card encoder differences */ | 655 | if (NewCard) { /* handle new card encoder differences */ |
651 | if (sequence[i*2] == 0x3a) | 656 | if (sequence[i * 2] == 0x3a) |
652 | I2CWrite(saa, 0x88, 0x3a, 0x13, 2); | 657 | I2CWrite(saa, 0x88, 0x3a, 0x13, 2); |
653 | else if (sequence[i*2] == 0x6b) | 658 | else if (sequence[i * 2] == 0x6b) |
654 | I2CWrite(saa, 0x88, 0x6b, 0x20, 2); | 659 | I2CWrite(saa, 0x88, 0x6b, 0x20, 2); |
655 | else if (sequence[i*2] == 0x6c) | 660 | else if (sequence[i * 2] == 0x6c) |
656 | I2CWrite(saa, 0x88, 0x6c, | 661 | I2CWrite(saa, 0x88, 0x6c, |
657 | dopal ? 0x09 : 0xf5, 2); | 662 | dopal ? 0x09 : 0xf5, 2); |
658 | else if (sequence[i*2] == 0x6d) | 663 | else if (sequence[i * 2] == 0x6d) |
659 | I2CWrite(saa, 0x88, 0x6d, | 664 | I2CWrite(saa, 0x88, 0x6d, |
660 | dopal ? 0x20 : 0x00, 2); | 665 | dopal ? 0x20 : 0x00, 2); |
661 | else if (sequence[i*2] == 0x7a) | 666 | else if (sequence[i * 2] == 0x7a) |
662 | I2CWrite(saa, 0x88, 0x7a, | 667 | I2CWrite(saa, 0x88, 0x7a, |
663 | dopal ? (PALFirstActive - 1) : | 668 | dopal ? (PALFirstActive - 1) : |
664 | (NTSCFirstActive - 4), 2); | 669 | (NTSCFirstActive - 4), 2); |
665 | else if (sequence[i*2] == 0x7b) | 670 | else if (sequence[i * 2] == 0x7b) |
666 | I2CWrite(saa, 0x88, 0x7b, | 671 | I2CWrite(saa, 0x88, 0x7b, |
667 | dopal ? PALLastActive : | 672 | dopal ? PALLastActive : |
668 | NTSCLastActive, 2); | 673 | NTSCLastActive, 2); |
669 | else I2CWrite(saa, 0x88, sequence[i * 2], | 674 | else |
670 | sequence[i * 2 + 1], 2); | 675 | I2CWrite(saa, 0x88, sequence[i * 2], |
676 | sequence[i * 2 + 1], 2); | ||
671 | } else { | 677 | } else { |
672 | if (sequence[i*2] == 0x6b && mod) | 678 | if (sequence[i * 2] == 0x6b && mod) |
673 | I2CWrite(saa, 0x88, 0x6b, | 679 | I2CWrite(saa, 0x88, 0x6b, |
674 | (sequence[i * 2 + 1] ^ 0x09), 2); | 680 | (sequence[i * 2 + 1] ^ 0x09), 2); |
675 | else if (sequence[i*2] == 0x7a) | 681 | else if (sequence[i * 2] == 0x7a) |
676 | I2CWrite(saa, 0x88, 0x7a, | 682 | I2CWrite(saa, 0x88, 0x7a, |
677 | dopal ? (PALFirstActive - 1) : | 683 | dopal ? (PALFirstActive - 1) : |
678 | (NTSCFirstActive - 4), 2); | 684 | (NTSCFirstActive - 4), 2); |
679 | else if (sequence[i*2] == 0x7b) | 685 | else if (sequence[i * 2] == 0x7b) |
680 | I2CWrite(saa, 0x88, 0x7b, | 686 | I2CWrite(saa, 0x88, 0x7b, |
681 | dopal ? PALLastActive : | 687 | dopal ? PALLastActive : |
682 | NTSCLastActive, 2); | 688 | NTSCLastActive, 2); |
@@ -700,7 +706,8 @@ static void set_genlock_offset(struct saa7146 *saa, int noffset) | |||
700 | nCode = noffset + 0x100; | 706 | nCode = noffset + 0x100; |
701 | if (nCode == 1) | 707 | if (nCode == 1) |
702 | nCode = 0x401; | 708 | nCode = 0x401; |
703 | else if (nCode < 1) nCode = 0x400 + PixelsPerLine + nCode; | 709 | else if (nCode < 1) |
710 | nCode = 0x400 + PixelsPerLine + nCode; | ||
704 | debiwrite(saa, debNormal, XILINX_GLDELAY, nCode, 2); | 711 | debiwrite(saa, debNormal, XILINX_GLDELAY, nCode, 2); |
705 | } | 712 | } |
706 | 713 | ||
@@ -710,33 +717,31 @@ static void set_out_format(struct saa7146 *saa, int mode) | |||
710 | saa->boardcfg[2] = mode; | 717 | saa->boardcfg[2] = mode; |
711 | /* do not adjust analog video parameters here, use saa7121 init */ | 718 | /* do not adjust analog video parameters here, use saa7121 init */ |
712 | /* you will affect the SDI output on the new card */ | 719 | /* you will affect the SDI output on the new card */ |
713 | if (mode == VIDEO_MODE_PAL) { /* PAL */ | 720 | if (mode == VIDEO_MODE_PAL) { /* PAL */ |
714 | debiwrite(saa, debNormal, XILINX_CTL0, 0x0808, 2); | 721 | debiwrite(saa, debNormal, XILINX_CTL0, 0x0808, 2); |
715 | mdelay(50); | 722 | mdelay(50); |
716 | saawrite(0x012002c0, SAA7146_NUM_LINE_BYTE1); | 723 | saawrite(0x012002c0, SAA7146_NUM_LINE_BYTE1); |
717 | if (NewCard) { | 724 | if (NewCard) { |
718 | debiwrite(saa, debNormal, IBM_MP2_DISP_MODE, | 725 | debiwrite(saa, debNormal, IBM_MP2_DISP_MODE, 0xe100, 2); |
719 | 0xe100, 2); | ||
720 | mdelay(50); | 726 | mdelay(50); |
721 | } | 727 | } |
722 | debiwrite(saa, debNormal, IBM_MP2_DISP_MODE, | 728 | debiwrite(saa, debNormal, IBM_MP2_DISP_MODE, |
723 | NewCard ? 0xe500: 0x6500, 2); | 729 | NewCard ? 0xe500 : 0x6500, 2); |
724 | debiwrite(saa, debNormal, IBM_MP2_DISP_DLY, | 730 | debiwrite(saa, debNormal, IBM_MP2_DISP_DLY, |
725 | (1 << 8) | | 731 | (1 << 8) | |
726 | (NewCard ? PALFirstActive : PALFirstActive-6), 2); | 732 | (NewCard ? PALFirstActive : PALFirstActive - 6), 2); |
727 | } else { /* NTSC */ | 733 | } else { /* NTSC */ |
728 | debiwrite(saa, debNormal, XILINX_CTL0, 0x0800, 2); | 734 | debiwrite(saa, debNormal, XILINX_CTL0, 0x0800, 2); |
729 | mdelay(50); | 735 | mdelay(50); |
730 | saawrite(0x00f002c0, SAA7146_NUM_LINE_BYTE1); | 736 | saawrite(0x00f002c0, SAA7146_NUM_LINE_BYTE1); |
731 | debiwrite(saa, debNormal, IBM_MP2_DISP_MODE, | 737 | debiwrite(saa, debNormal, IBM_MP2_DISP_MODE, |
732 | NewCard ? 0xe100: 0x6100, 2); | 738 | NewCard ? 0xe100 : 0x6100, 2); |
733 | debiwrite(saa, debNormal, IBM_MP2_DISP_DLY, | 739 | debiwrite(saa, debNormal, IBM_MP2_DISP_DLY, |
734 | (1 << 8) | | 740 | (1 << 8) | |
735 | (NewCard ? NTSCFirstActive : NTSCFirstActive-6), 2); | 741 | (NewCard ? NTSCFirstActive : NTSCFirstActive - 6), 2); |
736 | } | 742 | } |
737 | } | 743 | } |
738 | 744 | ||
739 | |||
740 | /* Intialize bitmangler to map from a byte value to the mangled word that | 745 | /* Intialize bitmangler to map from a byte value to the mangled word that |
741 | * must be output to program the Xilinx part through the DEBI port. | 746 | * must be output to program the Xilinx part through the DEBI port. |
742 | * Xilinx Data Bit->DEBI Bit: 0->15 1->7 2->6 3->12 4->11 5->2 6->1 7->0 | 747 | * Xilinx Data Bit->DEBI Bit: 0->15 1->7 2->6 3->12 4->11 5->2 6->1 7->0 |
@@ -764,43 +769,41 @@ static int initialize_fpga(struct video_code *bitdata) | |||
764 | for (num = 0; num < saa_num; num++) { | 769 | for (num = 0; num < saa_num; num++) { |
765 | saa = &saa7146s[num]; | 770 | saa = &saa7146s[num]; |
766 | if (saa->boardcfg[0] > 20) | 771 | if (saa->boardcfg[0] > 20) |
767 | continue; /* card was programmed */ | 772 | continue; /* card was programmed */ |
768 | loadtwo = (saa->boardcfg[18] & 0x10); | 773 | loadtwo = (saa->boardcfg[18] & 0x10); |
769 | if (!NewCard) /* we have an old board */ | 774 | if (!NewCard) /* we have an old board */ |
770 | for (i = 0; i < 256; i++) | 775 | for (i = 0; i < 256; i++) |
771 | bitmangler[i] = ((i & 0x01) << 15) | | 776 | bitmangler[i] = ((i & 0x01) << 15) | |
772 | ((i & 0x02) << 6) | ((i & 0x04) << 4) | | 777 | ((i & 0x02) << 6) | ((i & 0x04) << 4) | |
773 | ((i & 0x08) << 9) | ((i & 0x10) << 7) | | 778 | ((i & 0x08) << 9) | ((i & 0x10) << 7) | |
774 | ((i & 0x20) >> 3) | ((i & 0x40) >> 5) | | 779 | ((i & 0x20) >> 3) | ((i & 0x40) >> 5) | |
775 | ((i & 0x80) >> 7); | 780 | ((i & 0x80) >> 7); |
776 | else /* else we have a new board */ | 781 | else /* else we have a new board */ |
777 | for (i = 0; i < 256; i++) | 782 | for (i = 0; i < 256; i++) |
778 | bitmangler[i] = ((i & 0x01) << 7) | | 783 | bitmangler[i] = ((i & 0x01) << 7) | |
779 | ((i & 0x02) << 5) | ((i & 0x04) << 3) | | 784 | ((i & 0x02) << 5) | ((i & 0x04) << 3) | |
780 | ((i & 0x08) << 1) | ((i & 0x10) >> 1) | | 785 | ((i & 0x08) << 1) | ((i & 0x10) >> 1) | |
781 | ((i & 0x20) >> 3) | ((i & 0x40) >> 5) | | 786 | ((i & 0x20) >> 3) | ((i & 0x40) >> 5) | |
782 | ((i & 0x80) >> 7); | 787 | ((i & 0x80) >> 7); |
783 | 788 | ||
784 | dmabuf = (u16 *) saa->dmadebi; | 789 | dmabuf = (u16 *) saa->dmadebi; |
785 | newdma = (u8 *) saa->dmadebi; | 790 | newdma = (u8 *) saa->dmadebi; |
786 | if (NewCard) { /* SDM2xxx */ | 791 | if (NewCard) { /* SDM2xxx */ |
787 | if (!strncmp(bitdata->loadwhat, "decoder2", 8)) | 792 | if (!strncmp(bitdata->loadwhat, "decoder2", 8)) |
788 | continue; /* fpga not for this card */ | 793 | continue; /* fpga not for this card */ |
789 | if (!strncmp(&saa->boardcfg[42], | 794 | if (!strncmp(&saa->boardcfg[42], bitdata->loadwhat, 8)) |
790 | bitdata->loadwhat, 8)) { | ||
791 | loadfile = 1; | 795 | loadfile = 1; |
792 | } else if (loadtwo && !strncmp(&saa->boardcfg[19], | 796 | else if (loadtwo && !strncmp(&saa->boardcfg[19], |
793 | bitdata->loadwhat, 8)) { | 797 | bitdata->loadwhat, 8)) |
794 | loadfile = 2; | 798 | loadfile = 2; |
795 | } else if (!saa->boardcfg[42] && /* special */ | 799 | else if (!saa->boardcfg[42] && !strncmp("decxl", |
796 | !strncmp("decxl", bitdata->loadwhat, 8)) { | 800 | bitdata->loadwhat, 8)) |
797 | loadfile = 1; | 801 | loadfile = 1; /* special */ |
798 | } else | 802 | else |
799 | continue; /* fpga not for this card */ | 803 | continue; /* fpga not for this card */ |
800 | if (loadfile != 1 && loadfile != 2) { | 804 | if (loadfile != 1 && loadfile != 2) |
801 | continue; /* skip to next card */ | 805 | continue; /* skip to next card */ |
802 | } | 806 | if (saa->boardcfg[0] && loadfile == 1) |
803 | if (saa->boardcfg[0] && loadfile == 1 ) | ||
804 | continue; /* skip to next card */ | 807 | continue; /* skip to next card */ |
805 | if (saa->boardcfg[0] != 1 && loadfile == 2) | 808 | if (saa->boardcfg[0] != 1 && loadfile == 2) |
806 | continue; /* skip to next card */ | 809 | continue; /* skip to next card */ |
@@ -835,8 +838,9 @@ static int initialize_fpga(struct video_code *bitdata) | |||
835 | /* Release Xilinx INIT signal (WS2) */ | 838 | /* Release Xilinx INIT signal (WS2) */ |
836 | saawrite(0x00000000, SAA7146_GPIO_CTRL); | 839 | saawrite(0x00000000, SAA7146_GPIO_CTRL); |
837 | /* Wait for the INIT to go High */ | 840 | /* Wait for the INIT to go High */ |
838 | for (i = 0; i < 10000 && | 841 | for (i = 0; |
839 | !(saaread(SAA7146_PSR) & SAA7146_PSR_PIN2); i++) | 842 | i < 10000 && !(saaread(SAA7146_PSR) & SAA7146_PSR_PIN2); |
843 | i++) | ||
840 | schedule(); | 844 | schedule(); |
841 | if (i == 1000) { | 845 | if (i == 1000) { |
842 | printk(KERN_INFO "stradis%d: no fpga INIT\n", saa->nr); | 846 | printk(KERN_INFO "stradis%d: no fpga INIT\n", saa->nr); |
@@ -846,17 +850,13 @@ send_fpga_stuff: | |||
846 | if (NewCard) { | 850 | if (NewCard) { |
847 | for (i = startindex; i < bitdata->datasize; i++) | 851 | for (i = startindex; i < bitdata->datasize; i++) |
848 | newdma[i - startindex] = | 852 | newdma[i - startindex] = |
849 | bitmangler[bitdata->data[i]]; | 853 | bitmangler[bitdata->data[i]]; |
850 | debiwrite(saa, 0x01420000, 0, 0, | 854 | debiwrite(saa, 0x01420000, 0, 0, |
851 | ((bitdata->datasize - startindex) + 5)); | 855 | ((bitdata->datasize - startindex) + 5)); |
852 | if (loadtwo) { | 856 | if (loadtwo && loadfile == 1) { |
853 | if (loadfile == 1) { | 857 | printk("stradis%d: awaiting 2nd FPGA bitfile\n", |
854 | printk("stradis%d: " | 858 | saa->nr); |
855 | "awaiting 2nd FPGA bitfile\n", | 859 | continue; /* skip to next card */ |
856 | saa->nr); | ||
857 | continue; /* skip to next card */ | ||
858 | } | ||
859 | |||
860 | } | 860 | } |
861 | } else { | 861 | } else { |
862 | for (i = startindex; i < bitdata->datasize; i++) | 862 | for (i = startindex; i < bitdata->datasize; i++) |
@@ -865,8 +865,9 @@ send_fpga_stuff: | |||
865 | debiwrite(saa, 0x014a0000, 0, 0, | 865 | debiwrite(saa, 0x014a0000, 0, 0, |
866 | ((bitdata->datasize - startindex) + 5) * 2); | 866 | ((bitdata->datasize - startindex) + 5) * 2); |
867 | } | 867 | } |
868 | for (i = 0; i < 1000 && | 868 | for (i = 0; |
869 | !(saaread(SAA7146_PSR) & SAA7146_PSR_PIN2); i++) | 869 | i < 1000 && !(saaread(SAA7146_PSR) & SAA7146_PSR_PIN2); |
870 | i++) | ||
870 | schedule(); | 871 | schedule(); |
871 | if (i == 1000) { | 872 | if (i == 1000) { |
872 | printk(KERN_INFO "stradis%d: FPGA load failed\n", | 873 | printk(KERN_INFO "stradis%d: FPGA load failed\n", |
@@ -890,14 +891,14 @@ send_fpga_stuff: | |||
890 | /* mute CS3310 */ | 891 | /* mute CS3310 */ |
891 | if (HaveCS3310) | 892 | if (HaveCS3310) |
892 | debiwrite(saa, debNormal, XILINX_CS3310_CMPLT, | 893 | debiwrite(saa, debNormal, XILINX_CS3310_CMPLT, |
893 | 0, 2); | 894 | 0, 2); |
894 | /* set VXCO to PWM mode, release reset, blank on */ | 895 | /* set VXCO to PWM mode, release reset, blank on */ |
895 | debiwrite(saa, debNormal, XILINX_CTL0, 0xffc4, 2); | 896 | debiwrite(saa, debNormal, XILINX_CTL0, 0xffc4, 2); |
896 | mdelay(10); | 897 | mdelay(10); |
897 | /* unmute CS3310 */ | 898 | /* unmute CS3310 */ |
898 | if (HaveCS3310) | 899 | if (HaveCS3310) |
899 | debiwrite(saa, debNormal, XILINX_CTL0, | 900 | debiwrite(saa, debNormal, XILINX_CTL0, |
900 | 0x2020, 2); | 901 | 0x2020, 2); |
901 | } | 902 | } |
902 | /* set source Black */ | 903 | /* set source Black */ |
903 | debiwrite(saa, debNormal, XILINX_CTL0, 0x1707, 2); | 904 | debiwrite(saa, debNormal, XILINX_CTL0, 0x1707, 2); |
@@ -923,10 +924,10 @@ send_fpga_stuff: | |||
923 | /* we must init CS8420 first since rev b pulls i2s */ | 924 | /* we must init CS8420 first since rev b pulls i2s */ |
924 | /* master clock low and CS4341 needs i2s master to */ | 925 | /* master clock low and CS4341 needs i2s master to */ |
925 | /* run the i2c port. */ | 926 | /* run the i2c port. */ |
926 | if (HaveCS8420) { | 927 | if (HaveCS8420) |
927 | /* 0=consumer, 1=pro */ | 928 | /* 0=consumer, 1=pro */ |
928 | initialize_cs8420(saa, 0); | 929 | initialize_cs8420(saa, 0); |
929 | } | 930 | |
930 | mdelay(5); | 931 | mdelay(5); |
931 | if (HaveCS4341) | 932 | if (HaveCS4341) |
932 | initialize_cs4341(saa); | 933 | initialize_cs4341(saa); |
@@ -946,6 +947,7 @@ send_fpga_stuff: | |||
946 | debiwrite(saa, debNormal, XILINX_CTL0, 0x8080, 2); | 947 | debiwrite(saa, debNormal, XILINX_CTL0, 0x8080, 2); |
947 | #endif | 948 | #endif |
948 | } | 949 | } |
950 | |||
949 | return failure; | 951 | return failure; |
950 | } | 952 | } |
951 | 953 | ||
@@ -986,10 +988,10 @@ static int do_ibm_reset(struct saa7146 *saa) | |||
986 | /* we must init CS8420 first since rev b pulls i2s */ | 988 | /* we must init CS8420 first since rev b pulls i2s */ |
987 | /* master clock low and CS4341 needs i2s master to */ | 989 | /* master clock low and CS4341 needs i2s master to */ |
988 | /* run the i2c port. */ | 990 | /* run the i2c port. */ |
989 | if (HaveCS8420) { | 991 | if (HaveCS8420) |
990 | /* 0=consumer, 1=pro */ | 992 | /* 0=consumer, 1=pro */ |
991 | initialize_cs8420(saa, 1); | 993 | initialize_cs8420(saa, 1); |
992 | } | 994 | |
993 | mdelay(5); | 995 | mdelay(5); |
994 | if (HaveCS4341) | 996 | if (HaveCS4341) |
995 | initialize_cs4341(saa); | 997 | initialize_cs4341(saa); |
@@ -1004,12 +1006,12 @@ static int do_ibm_reset(struct saa7146 *saa) | |||
1004 | debiwrite(saa, debNormal, IBM_MP2_OSD_SIZE, 0x2000, 2); | 1006 | debiwrite(saa, debNormal, IBM_MP2_OSD_SIZE, 0x2000, 2); |
1005 | debiwrite(saa, debNormal, IBM_MP2_AUD_CTL, 0x4552, 2); | 1007 | debiwrite(saa, debNormal, IBM_MP2_AUD_CTL, 0x4552, 2); |
1006 | if (ibm_send_command(saa, IBM_MP2_CONFIG_DECODER, | 1008 | if (ibm_send_command(saa, IBM_MP2_CONFIG_DECODER, |
1007 | (ChipControl == 0x43 ? 0xe800 : 0xe000), 1)) { | 1009 | (ChipControl == 0x43 ? 0xe800 : 0xe000), 1)) { |
1008 | printk(KERN_ERR "stradis%d: IBM config failed\n", saa->nr); | 1010 | printk(KERN_ERR "stradis%d: IBM config failed\n", saa->nr); |
1009 | } | 1011 | } |
1010 | if (HaveCS3310) { | 1012 | if (HaveCS3310) { |
1011 | int i = CS3310MaxLvl; | 1013 | int i = CS3310MaxLvl; |
1012 | debiwrite(saa, debNormal, XILINX_CS3310_CMPLT, ((i<<8)|i), 2); | 1014 | debiwrite(saa, debNormal, XILINX_CS3310_CMPLT, ((i << 8)| i),2); |
1013 | } | 1015 | } |
1014 | /* start video decoder */ | 1016 | /* start video decoder */ |
1015 | debiwrite(saa, debNormal, IBM_MP2_CHIP_CONTROL, ChipControl, 2); | 1017 | debiwrite(saa, debNormal, IBM_MP2_CHIP_CONTROL, ChipControl, 2); |
@@ -1022,6 +1024,7 @@ static int do_ibm_reset(struct saa7146 *saa) | |||
1022 | /* clear pending interrupts */ | 1024 | /* clear pending interrupts */ |
1023 | debiread(saa, debNormal, IBM_MP2_HOST_INT, 2); | 1025 | debiread(saa, debNormal, IBM_MP2_HOST_INT, 2); |
1024 | debiwrite(saa, debNormal, XILINX_CTL0, 0x1711, 2); | 1026 | debiwrite(saa, debNormal, XILINX_CTL0, 0x1711, 2); |
1027 | |||
1025 | return 0; | 1028 | return 0; |
1026 | } | 1029 | } |
1027 | 1030 | ||
@@ -1035,8 +1038,8 @@ static int initialize_ibmmpeg2(struct video_code *microcode) | |||
1035 | saa = &saa7146s[num]; | 1038 | saa = &saa7146s[num]; |
1036 | /* check that FPGA is loaded */ | 1039 | /* check that FPGA is loaded */ |
1037 | debiwrite(saa, debNormal, IBM_MP2_OSD_SIZE, 0xa55a, 2); | 1040 | debiwrite(saa, debNormal, IBM_MP2_OSD_SIZE, 0xa55a, 2); |
1038 | if ((i = debiread(saa, debNormal, IBM_MP2_OSD_SIZE, 2)) != | 1041 | i = debiread(saa, debNormal, IBM_MP2_OSD_SIZE, 2); |
1039 | 0xa55a) { | 1042 | if (i != 0xa55a) { |
1040 | printk(KERN_INFO "stradis%d: %04x != 0xa55a\n", | 1043 | printk(KERN_INFO "stradis%d: %04x != 0xa55a\n", |
1041 | saa->nr, i); | 1044 | saa->nr, i); |
1042 | #if 0 | 1045 | #if 0 |
@@ -1047,17 +1050,17 @@ static int initialize_ibmmpeg2(struct video_code *microcode) | |||
1047 | if (saa->boardcfg[0] > 27) | 1050 | if (saa->boardcfg[0] > 27) |
1048 | continue; /* skip to next card */ | 1051 | continue; /* skip to next card */ |
1049 | /* load video control store */ | 1052 | /* load video control store */ |
1050 | saa->boardcfg[1] = 0x13; /* no-sync default */ | 1053 | saa->boardcfg[1] = 0x13; /* no-sync default */ |
1051 | debiwrite(saa, debNormal, IBM_MP2_WR_PROT, 1, 2); | 1054 | debiwrite(saa, debNormal, IBM_MP2_WR_PROT, 1, 2); |
1052 | debiwrite(saa, debNormal, IBM_MP2_PROC_IADDR, 0, 2); | 1055 | debiwrite(saa, debNormal, IBM_MP2_PROC_IADDR, 0, 2); |
1053 | for (i = 0; i < microcode->datasize / 2; i++) | 1056 | for (i = 0; i < microcode->datasize / 2; i++) |
1054 | debiwrite(saa, debNormal, IBM_MP2_PROC_IDATA, | 1057 | debiwrite(saa, debNormal, IBM_MP2_PROC_IDATA, |
1055 | (microcode->data[i * 2] << 8) | | 1058 | (microcode->data[i * 2] << 8) | |
1056 | microcode->data[i * 2 + 1], 2); | 1059 | microcode->data[i * 2 + 1], 2); |
1057 | debiwrite(saa, debNormal, IBM_MP2_PROC_IADDR, 0, 2); | 1060 | debiwrite(saa, debNormal, IBM_MP2_PROC_IADDR, 0, 2); |
1058 | debiwrite(saa, debNormal, IBM_MP2_WR_PROT, 0, 2); | 1061 | debiwrite(saa, debNormal, IBM_MP2_WR_PROT, 0, 2); |
1059 | debiwrite(saa, debNormal, IBM_MP2_CHIP_CONTROL, | 1062 | debiwrite(saa, debNormal, IBM_MP2_CHIP_CONTROL, |
1060 | ChipControl, 2); | 1063 | ChipControl, 2); |
1061 | saa->boardcfg[0] = 28; | 1064 | saa->boardcfg[0] = 28; |
1062 | } | 1065 | } |
1063 | if (!strncmp(microcode->loadwhat, "decoder.aud", 11)) { | 1066 | if (!strncmp(microcode->loadwhat, "decoder.aud", 11)) { |
@@ -1074,34 +1077,32 @@ static int initialize_ibmmpeg2(struct video_code *microcode) | |||
1074 | debiwrite(saa, debNormal, IBM_MP2_OSD_SIZE, 0x2000, 2); | 1077 | debiwrite(saa, debNormal, IBM_MP2_OSD_SIZE, 0x2000, 2); |
1075 | debiwrite(saa, debNormal, IBM_MP2_AUD_CTL, 0x4552, 2); | 1078 | debiwrite(saa, debNormal, IBM_MP2_AUD_CTL, 0x4552, 2); |
1076 | if (ibm_send_command(saa, IBM_MP2_CONFIG_DECODER, | 1079 | if (ibm_send_command(saa, IBM_MP2_CONFIG_DECODER, |
1077 | 0xe000, 1)) { | 1080 | 0xe000, 1)) { |
1078 | printk(KERN_ERR | 1081 | printk(KERN_ERR "stradis%d: IBM config " |
1079 | "stradis%d: IBM config failed\n", | 1082 | "failed\n", saa->nr); |
1080 | saa->nr); | ||
1081 | return -1; | 1083 | return -1; |
1082 | } | 1084 | } |
1083 | /* set PWM to center value */ | 1085 | /* set PWM to center value */ |
1084 | if (NewCard) { | 1086 | if (NewCard) { |
1085 | debiwrite(saa, debNormal, XILINX_PWM, | 1087 | debiwrite(saa, debNormal, XILINX_PWM, |
1086 | saa->boardcfg[14] + | 1088 | saa->boardcfg[14] + |
1087 | (saa->boardcfg[13]<<8), 2); | 1089 | (saa->boardcfg[13] << 8), 2); |
1088 | } else | 1090 | } else |
1089 | debiwrite(saa, debNormal, XILINX_PWM, | 1091 | debiwrite(saa, debNormal, XILINX_PWM, 0x46, 2); |
1090 | 0x46, 2); | 1092 | |
1091 | if (HaveCS3310) { | 1093 | if (HaveCS3310) { |
1092 | i = CS3310MaxLvl; | 1094 | i = CS3310MaxLvl; |
1093 | debiwrite(saa, debNormal, | 1095 | debiwrite(saa, debNormal, XILINX_CS3310_CMPLT, |
1094 | XILINX_CS3310_CMPLT, ((i<<8)|i), 2); | 1096 | (i << 8) | i, 2); |
1095 | } | 1097 | } |
1096 | printk(KERN_INFO | 1098 | printk(KERN_INFO "stradis%d: IBM MPEGCD%d Inited\n", |
1097 | "stradis%d: IBM MPEGCD%d Initialized\n", | 1099 | saa->nr, 18 + (debiread(saa, debNormal, |
1098 | saa->nr, 18 + (debiread(saa, debNormal, | 1100 | IBM_MP2_CHIP_CONTROL, 2) >> 12)); |
1099 | IBM_MP2_CHIP_CONTROL, 2) >> 12)); | ||
1100 | /* start video decoder */ | 1101 | /* start video decoder */ |
1101 | debiwrite(saa, debNormal, IBM_MP2_CHIP_CONTROL, | 1102 | debiwrite(saa, debNormal, IBM_MP2_CHIP_CONTROL, |
1102 | ChipControl, 2); | 1103 | ChipControl, 2); |
1103 | debiwrite(saa, debNormal, IBM_MP2_RB_THRESHOLD, | 1104 | debiwrite(saa, debNormal, IBM_MP2_RB_THRESHOLD, 0x4037, |
1104 | 0x4037, 2); /* 256k vid, 3520 bytes aud */ | 1105 | 2); /* 256k vid, 3520 bytes aud */ |
1105 | debiwrite(saa, debNormal, IBM_MP2_AUD_CTL, 0x4573, 2); | 1106 | debiwrite(saa, debNormal, IBM_MP2_AUD_CTL, 0x4573, 2); |
1106 | ibm_send_command(saa, IBM_MP2_PLAY, 0, 0); | 1107 | ibm_send_command(saa, IBM_MP2_PLAY, 0, 0); |
1107 | /* enable buffer threshold irq */ | 1108 | /* enable buffer threshold irq */ |
@@ -1114,52 +1115,48 @@ static int initialize_ibmmpeg2(struct video_code *microcode) | |||
1114 | saa->boardcfg[0] = 37; | 1115 | saa->boardcfg[0] = 37; |
1115 | } | 1116 | } |
1116 | } | 1117 | } |
1118 | |||
1117 | return 0; | 1119 | return 0; |
1118 | } | 1120 | } |
1119 | 1121 | ||
1120 | static u32 palette2fmt[] = | 1122 | static u32 palette2fmt[] = { /* some of these YUV translations are wrong */ |
1121 | { /* some of these YUV translations are wrong */ | 1123 | 0xffffffff, 0x86000000, 0x87000000, 0x80000000, 0x8100000, 0x82000000, |
1122 | 0xffffffff, 0x86000000, 0x87000000, 0x80000000, 0x8100000, 0x82000000, | 1124 | 0x83000000, 0x00000000, 0x03000000, 0x03000000, 0x0a00000, 0x03000000, |
1123 | 0x83000000, 0x00000000, 0x03000000, 0x03000000, 0x0a00000, 0x03000000, | 1125 | 0x06000000, 0x00000000, 0x03000000, 0x0a000000, 0x0300000 |
1124 | 0x06000000, 0x00000000, 0x03000000, 0x0a000000, 0x0300000 | ||
1125 | }; | 1126 | }; |
1126 | static int bpp2fmt[4] = | 1127 | static int bpp2fmt[4] = { |
1127 | { | ||
1128 | VIDEO_PALETTE_HI240, VIDEO_PALETTE_RGB565, VIDEO_PALETTE_RGB24, | 1128 | VIDEO_PALETTE_HI240, VIDEO_PALETTE_RGB565, VIDEO_PALETTE_RGB24, |
1129 | VIDEO_PALETTE_RGB32 | 1129 | VIDEO_PALETTE_RGB32 |
1130 | }; | 1130 | }; |
1131 | 1131 | ||
1132 | /* I wish I could find a formula to calculate these... */ | 1132 | /* I wish I could find a formula to calculate these... */ |
1133 | static u32 h_prescale[64] = | 1133 | static u32 h_prescale[64] = { |
1134 | { | 1134 | 0x10000000, 0x18040202, 0x18080000, 0x380c0606, 0x38100204, 0x38140808, |
1135 | 0x10000000, 0x18040202, 0x18080000, 0x380c0606, 0x38100204, 0x38140808, | 1135 | 0x38180000, 0x381c0000, 0x3820161c, 0x38242a3b, 0x38281230, 0x382c4460, |
1136 | 0x38180000, 0x381c0000, 0x3820161c, 0x38242a3b, 0x38281230, 0x382c4460, | 1136 | 0x38301040, 0x38340080, 0x38380000, 0x383c0000, 0x3840fefe, 0x3844ee9f, |
1137 | 0x38301040, 0x38340080, 0x38380000, 0x383c0000, 0x3840fefe, 0x3844ee9f, | 1137 | 0x3848ee9f, 0x384cee9f, 0x3850ee9f, 0x38542a3b, 0x38581230, 0x385c0000, |
1138 | 0x3848ee9f, 0x384cee9f, 0x3850ee9f, 0x38542a3b, 0x38581230, 0x385c0000, | 1138 | 0x38600000, 0x38640000, 0x38680000, 0x386c0000, 0x38700000, 0x38740000, |
1139 | 0x38600000, 0x38640000, 0x38680000, 0x386c0000, 0x38700000, 0x38740000, | 1139 | 0x38780000, 0x387c0000, 0x30800000, 0x38840000, 0x38880000, 0x388c0000, |
1140 | 0x38780000, 0x387c0000, 0x30800000, 0x38840000, 0x38880000, 0x388c0000, | 1140 | 0x38900000, 0x38940000, 0x38980000, 0x389c0000, 0x38a00000, 0x38a40000, |
1141 | 0x38900000, 0x38940000, 0x38980000, 0x389c0000, 0x38a00000, 0x38a40000, | 1141 | 0x38a80000, 0x38ac0000, 0x38b00000, 0x38b40000, 0x38b80000, 0x38bc0000, |
1142 | 0x38a80000, 0x38ac0000, 0x38b00000, 0x38b40000, 0x38b80000, 0x38bc0000, | 1142 | 0x38c00000, 0x38c40000, 0x38c80000, 0x38cc0000, 0x38d00000, 0x38d40000, |
1143 | 0x38c00000, 0x38c40000, 0x38c80000, 0x38cc0000, 0x38d00000, 0x38d40000, | 1143 | 0x38d80000, 0x38dc0000, 0x38e00000, 0x38e40000, 0x38e80000, 0x38ec0000, |
1144 | 0x38d80000, 0x38dc0000, 0x38e00000, 0x38e40000, 0x38e80000, 0x38ec0000, | 1144 | 0x38f00000, 0x38f40000, 0x38f80000, 0x38fc0000, |
1145 | 0x38f00000, 0x38f40000, 0x38f80000, 0x38fc0000, | ||
1146 | }; | 1145 | }; |
1147 | static u32 v_gain[64] = | 1146 | static u32 v_gain[64] = { |
1148 | { | 1147 | 0x016000ff, 0x016100ff, 0x016100ff, 0x016200ff, 0x016200ff, 0x016200ff, |
1149 | 0x016000ff, 0x016100ff, 0x016100ff, 0x016200ff, 0x016200ff, 0x016200ff, | 1148 | 0x016200ff, 0x016300ff, 0x016300ff, 0x016300ff, 0x016300ff, 0x016300ff, |
1150 | 0x016200ff, 0x016300ff, 0x016300ff, 0x016300ff, 0x016300ff, 0x016300ff, | 1149 | 0x016300ff, 0x016300ff, 0x016300ff, 0x016400ff, 0x016400ff, 0x016400ff, |
1151 | 0x016300ff, 0x016300ff, 0x016300ff, 0x016400ff, 0x016400ff, 0x016400ff, | 1150 | 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, |
1152 | 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, | 1151 | 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, |
1153 | 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, | 1152 | 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, |
1154 | 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, | 1153 | 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, |
1155 | 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, | 1154 | 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, |
1156 | 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, | 1155 | 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, |
1157 | 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, | 1156 | 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, |
1158 | 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, | 1157 | 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, |
1159 | 0x016400ff, 0x016400ff, 0x016400ff, 0x016400ff, | ||
1160 | }; | 1158 | }; |
1161 | 1159 | ||
1162 | |||
1163 | static void saa7146_set_winsize(struct saa7146 *saa) | 1160 | static void saa7146_set_winsize(struct saa7146 *saa) |
1164 | { | 1161 | { |
1165 | u32 format; | 1162 | u32 format; |
@@ -1174,24 +1171,23 @@ static void saa7146_set_winsize(struct saa7146 *saa) | |||
1174 | saawrite(saa->win.vidadr + saa->win.bpl * saa->win.sheight, | 1171 | saawrite(saa->win.vidadr + saa->win.bpl * saa->win.sheight, |
1175 | SAA7146_PROT_ADDR1); | 1172 | SAA7146_PROT_ADDR1); |
1176 | saawrite(0, SAA7146_PAGE1); | 1173 | saawrite(0, SAA7146_PAGE1); |
1177 | saawrite(format|0x60, SAA7146_CLIP_FORMAT_CTRL); | 1174 | saawrite(format | 0x60, SAA7146_CLIP_FORMAT_CTRL); |
1178 | offset = (704 / (saa->win.width - 1)) & 0x3f; | 1175 | offset = (704 / (saa->win.width - 1)) & 0x3f; |
1179 | saawrite(h_prescale[offset], SAA7146_HPS_H_PRESCALE); | 1176 | saawrite(h_prescale[offset], SAA7146_HPS_H_PRESCALE); |
1180 | offset = (720896 / saa->win.width) / (offset + 1); | 1177 | offset = (720896 / saa->win.width) / (offset + 1); |
1181 | saawrite((offset<<12)|0x0c, SAA7146_HPS_H_SCALE); | 1178 | saawrite((offset << 12) | 0x0c, SAA7146_HPS_H_SCALE); |
1182 | if (CurrentMode == VIDEO_MODE_NTSC) { | 1179 | if (CurrentMode == VIDEO_MODE_NTSC) { |
1183 | yacl = /*(480 / saa->win.height - 1) & 0x3f*/ 0; | 1180 | yacl = /*(480 / saa->win.height - 1) & 0x3f */ 0; |
1184 | ysci = 1024 - (saa->win.height * 1024 / 480); | 1181 | ysci = 1024 - (saa->win.height * 1024 / 480); |
1185 | } else { | 1182 | } else { |
1186 | yacl = /*(576 / saa->win.height - 1) & 0x3f*/ 0; | 1183 | yacl = /*(576 / saa->win.height - 1) & 0x3f */ 0; |
1187 | ysci = 1024 - (saa->win.height * 1024 / 576); | 1184 | ysci = 1024 - (saa->win.height * 1024 / 576); |
1188 | } | 1185 | } |
1189 | saawrite((1<<31)|(ysci<<21)|(yacl<<15), SAA7146_HPS_V_SCALE); | 1186 | saawrite((1 << 31) | (ysci << 21) | (yacl << 15), SAA7146_HPS_V_SCALE); |
1190 | saawrite(v_gain[yacl], SAA7146_HPS_V_GAIN); | 1187 | saawrite(v_gain[yacl], SAA7146_HPS_V_GAIN); |
1191 | saawrite(((SAA7146_MC2_UPLD_DMA1 | SAA7146_MC2_UPLD_HPS_V | | 1188 | saawrite(((SAA7146_MC2_UPLD_DMA1 | SAA7146_MC2_UPLD_HPS_V | |
1192 | SAA7146_MC2_UPLD_HPS_H) << 16) | (SAA7146_MC2_UPLD_DMA1 | | 1189 | SAA7146_MC2_UPLD_HPS_H) << 16) | (SAA7146_MC2_UPLD_DMA1 | |
1193 | SAA7146_MC2_UPLD_HPS_V | SAA7146_MC2_UPLD_HPS_H), | 1190 | SAA7146_MC2_UPLD_HPS_V | SAA7146_MC2_UPLD_HPS_H), SAA7146_MC2); |
1194 | SAA7146_MC2); | ||
1195 | } | 1191 | } |
1196 | 1192 | ||
1197 | /* clip_draw_rectangle(cm,x,y,w,h) -- handle clipping an area | 1193 | /* clip_draw_rectangle(cm,x,y,w,h) -- handle clipping an area |
@@ -1226,8 +1222,8 @@ static void clip_draw_rectangle(u32 *clipmap, int x, int y, int w, int h) | |||
1226 | startword = (x >> 5); | 1222 | startword = (x >> 5); |
1227 | endword = ((x + w) >> 5); | 1223 | endword = ((x + w) >> 5); |
1228 | bitsleft = (0xffffffff >> (x & 31)); | 1224 | bitsleft = (0xffffffff >> (x & 31)); |
1229 | bitsright = (0xffffffff << (~((x + w) - (endword<<5)))); | 1225 | bitsright = (0xffffffff << (~((x + w) - (endword << 5)))); |
1230 | temp = &clipmap[(y<<5) + startword]; | 1226 | temp = &clipmap[(y << 5) + startword]; |
1231 | w = endword - startword; | 1227 | w = endword - startword; |
1232 | if (!w) { | 1228 | if (!w) { |
1233 | bitsleft |= bitsright; | 1229 | bitsleft |= bitsright; |
@@ -1252,13 +1248,13 @@ static void make_clip_tab(struct saa7146 *saa, struct video_clip *cr, int ncr) | |||
1252 | u32 *clipmap; | 1248 | u32 *clipmap; |
1253 | 1249 | ||
1254 | clipmap = saa->dmavid2; | 1250 | clipmap = saa->dmavid2; |
1255 | if((width=saa->win.width)>1023) | 1251 | if ((width = saa->win.width) > 1023) |
1256 | width = 1023; /* sanity check */ | 1252 | width = 1023; /* sanity check */ |
1257 | if((height=saa->win.height)>640) | 1253 | if ((height = saa->win.height) > 640) |
1258 | height = 639; /* sanity check */ | 1254 | height = 639; /* sanity check */ |
1259 | if (ncr > 0) { /* rectangles pased */ | 1255 | if (ncr > 0) { /* rectangles pased */ |
1260 | /* convert rectangular clips to a bitmap */ | 1256 | /* convert rectangular clips to a bitmap */ |
1261 | memset(clipmap, 0, VIDEO_CLIPMAP_SIZE); /* clear map */ | 1257 | memset(clipmap, 0, VIDEO_CLIPMAP_SIZE); /* clear map */ |
1262 | for (i = 0; i < ncr; i++) | 1258 | for (i = 0; i < ncr; i++) |
1263 | clip_draw_rectangle(clipmap, cr[i].x, cr[i].y, | 1259 | clip_draw_rectangle(clipmap, cr[i].x, cr[i].y, |
1264 | cr[i].width, cr[i].height); | 1260 | cr[i].width, cr[i].height); |
@@ -1266,14 +1262,15 @@ static void make_clip_tab(struct saa7146 *saa, struct video_clip *cr, int ncr) | |||
1266 | /* clip against viewing window AND screen | 1262 | /* clip against viewing window AND screen |
1267 | so we do not have to rely on the user program | 1263 | so we do not have to rely on the user program |
1268 | */ | 1264 | */ |
1269 | clip_draw_rectangle(clipmap,(saa->win.x+width>saa->win.swidth) ? | 1265 | clip_draw_rectangle(clipmap, (saa->win.x + width > saa->win.swidth) ? |
1270 | (saa->win.swidth-saa->win.x) : width, 0, 1024, 768); | 1266 | (saa->win.swidth - saa->win.x) : width, 0, 1024, 768); |
1271 | clip_draw_rectangle(clipmap,0,(saa->win.y+height>saa->win.sheight) ? | 1267 | clip_draw_rectangle(clipmap, 0, |
1272 | (saa->win.sheight-saa->win.y) : height,1024,768); | 1268 | (saa->win.y + height > saa->win.sheight) ? |
1273 | if (saa->win.x<0) | 1269 | (saa->win.sheight - saa->win.y) : height, 1024, 768); |
1274 | clip_draw_rectangle(clipmap, 0, 0, -(saa->win.x), 768); | 1270 | if (saa->win.x < 0) |
1275 | if (saa->win.y<0) | 1271 | clip_draw_rectangle(clipmap, 0, 0, -saa->win.x, 768); |
1276 | clip_draw_rectangle(clipmap, 0, 0, 1024, -(saa->win.y)); | 1272 | if (saa->win.y < 0) |
1273 | clip_draw_rectangle(clipmap, 0, 0, 1024, -saa->win.y); | ||
1277 | } | 1274 | } |
1278 | 1275 | ||
1279 | static int saa_ioctl(struct inode *inode, struct file *file, | 1276 | static int saa_ioctl(struct inode *inode, struct file *file, |
@@ -1287,11 +1284,9 @@ static int saa_ioctl(struct inode *inode, struct file *file, | |||
1287 | { | 1284 | { |
1288 | struct video_capability b; | 1285 | struct video_capability b; |
1289 | strcpy(b.name, saa->video_dev.name); | 1286 | strcpy(b.name, saa->video_dev.name); |
1290 | b.type = VID_TYPE_CAPTURE | | 1287 | b.type = VID_TYPE_CAPTURE | VID_TYPE_OVERLAY | |
1291 | VID_TYPE_OVERLAY | | 1288 | VID_TYPE_CLIPPING | VID_TYPE_FRAMERAM | |
1292 | VID_TYPE_CLIPPING | | 1289 | VID_TYPE_SCALES; |
1293 | VID_TYPE_FRAMERAM | | ||
1294 | VID_TYPE_SCALES; | ||
1295 | b.channels = 1; | 1290 | b.channels = 1; |
1296 | b.audios = 1; | 1291 | b.audios = 1; |
1297 | b.maxwidth = 768; | 1292 | b.maxwidth = 768; |
@@ -1328,17 +1323,18 @@ static int saa_ioctl(struct inode *inode, struct file *file, | |||
1328 | if (p.palette < sizeof(palette2fmt) / sizeof(u32)) { | 1323 | if (p.palette < sizeof(palette2fmt) / sizeof(u32)) { |
1329 | format = palette2fmt[p.palette]; | 1324 | format = palette2fmt[p.palette]; |
1330 | saa->win.color_fmt = format; | 1325 | saa->win.color_fmt = format; |
1331 | saawrite(format|0x60, SAA7146_CLIP_FORMAT_CTRL); | 1326 | saawrite(format | 0x60, |
1327 | SAA7146_CLIP_FORMAT_CTRL); | ||
1332 | } | 1328 | } |
1333 | saawrite(((p.brightness & 0xff00) << 16) | | 1329 | saawrite(((p.brightness & 0xff00) << 16) | |
1334 | ((p.contrast & 0xfe00) << 7) | | 1330 | ((p.contrast & 0xfe00) << 7) | |
1335 | ((p.colour & 0xfe00) >> 9), SAA7146_BCS_CTRL); | 1331 | ((p.colour & 0xfe00) >> 9), SAA7146_BCS_CTRL); |
1336 | saa->picture = p; | 1332 | saa->picture = p; |
1337 | /* upload changed registers */ | 1333 | /* upload changed registers */ |
1338 | saawrite(((SAA7146_MC2_UPLD_HPS_H | | 1334 | saawrite(((SAA7146_MC2_UPLD_HPS_H | |
1339 | SAA7146_MC2_UPLD_HPS_V) << 16) | | 1335 | SAA7146_MC2_UPLD_HPS_V) << 16) | |
1340 | SAA7146_MC2_UPLD_HPS_H | SAA7146_MC2_UPLD_HPS_V, | 1336 | SAA7146_MC2_UPLD_HPS_H | |
1341 | SAA7146_MC2); | 1337 | SAA7146_MC2_UPLD_HPS_V, SAA7146_MC2); |
1342 | return 0; | 1338 | return 0; |
1343 | } | 1339 | } |
1344 | case VIDIOCSWIN: | 1340 | case VIDIOCSWIN: |
@@ -1349,11 +1345,14 @@ static int saa_ioctl(struct inode *inode, struct file *file, | |||
1349 | if (copy_from_user(&vw, arg, sizeof(vw))) | 1345 | if (copy_from_user(&vw, arg, sizeof(vw))) |
1350 | return -EFAULT; | 1346 | return -EFAULT; |
1351 | 1347 | ||
1352 | if (vw.flags || vw.width < 16 || vw.height < 16) { /* stop capture */ | 1348 | /* stop capture */ |
1353 | saawrite((SAA7146_MC1_TR_E_1 << 16), SAA7146_MC1); | 1349 | if (vw.flags || vw.width < 16 || vw.height < 16) { |
1350 | saawrite((SAA7146_MC1_TR_E_1 << 16), | ||
1351 | SAA7146_MC1); | ||
1354 | return -EINVAL; | 1352 | return -EINVAL; |
1355 | } | 1353 | } |
1356 | if (saa->win.bpp < 4) { /* 32-bit align start and adjust width */ | 1354 | /* 32-bit align start and adjust width */ |
1355 | if (saa->win.bpp < 4) { | ||
1357 | int i = vw.x; | 1356 | int i = vw.x; |
1358 | vw.x = (vw.x + 3) & ~3; | 1357 | vw.x = (vw.x + 3) & ~3; |
1359 | i = vw.x - i; | 1358 | i = vw.x - i; |
@@ -1382,23 +1381,24 @@ static int saa_ioctl(struct inode *inode, struct file *file, | |||
1382 | */ | 1381 | */ |
1383 | if (vw.clipcount < 0) { | 1382 | if (vw.clipcount < 0) { |
1384 | if (copy_from_user(saa->dmavid2, vw.clips, | 1383 | if (copy_from_user(saa->dmavid2, vw.clips, |
1385 | VIDEO_CLIPMAP_SIZE)) | 1384 | VIDEO_CLIPMAP_SIZE)) |
1386 | return -EFAULT; | 1385 | return -EFAULT; |
1387 | } | 1386 | } else if (vw.clipcount > 16384) { |
1388 | else if (vw.clipcount > 16384) { | ||
1389 | return -EINVAL; | 1387 | return -EINVAL; |
1390 | } else if (vw.clipcount > 0) { | 1388 | } else if (vw.clipcount > 0) { |
1391 | if ((vcp = vmalloc(sizeof(struct video_clip) * | 1389 | vcp = vmalloc(sizeof(struct video_clip) * |
1392 | (vw.clipcount))) == NULL) | 1390 | vw.clipcount); |
1393 | return -ENOMEM; | 1391 | if (vcp == NULL) |
1392 | return -ENOMEM; | ||
1394 | if (copy_from_user(vcp, vw.clips, | 1393 | if (copy_from_user(vcp, vw.clips, |
1395 | sizeof(struct video_clip) * | 1394 | sizeof(struct video_clip) * |
1396 | vw.clipcount)) { | 1395 | vw.clipcount)) { |
1397 | vfree(vcp); | 1396 | vfree(vcp); |
1398 | return -EFAULT; | 1397 | return -EFAULT; |
1399 | } | 1398 | } |
1400 | } else /* nothing clipped */ | 1399 | } else /* nothing clipped */ |
1401 | memset(saa->dmavid2, 0, VIDEO_CLIPMAP_SIZE); | 1400 | memset(saa->dmavid2, 0, VIDEO_CLIPMAP_SIZE); |
1401 | |||
1402 | make_clip_tab(saa, vcp, vw.clipcount); | 1402 | make_clip_tab(saa, vcp, vw.clipcount); |
1403 | if (vw.clipcount > 0) | 1403 | if (vw.clipcount > 0) |
1404 | vfree(vcp); | 1404 | vfree(vcp); |
@@ -1431,21 +1431,21 @@ static int saa_ioctl(struct inode *inode, struct file *file, | |||
1431 | if (v == 0) { | 1431 | if (v == 0) { |
1432 | saa->cap &= ~1; | 1432 | saa->cap &= ~1; |
1433 | saawrite((SAA7146_MC1_TR_E_1 << 16), | 1433 | saawrite((SAA7146_MC1_TR_E_1 << 16), |
1434 | SAA7146_MC1); | 1434 | SAA7146_MC1); |
1435 | } else { | 1435 | } else { |
1436 | if (saa->win.vidadr == 0 || saa->win.width == 0 | 1436 | if (saa->win.vidadr == 0 || saa->win.width == 0 |
1437 | || saa->win.height == 0) | 1437 | || saa->win.height == 0) |
1438 | return -EINVAL; | 1438 | return -EINVAL; |
1439 | saa->cap |= 1; | 1439 | saa->cap |= 1; |
1440 | saawrite((SAA7146_MC1_TR_E_1 << 16) | 0xffff, | 1440 | saawrite((SAA7146_MC1_TR_E_1 << 16) | 0xffff, |
1441 | SAA7146_MC1); | 1441 | SAA7146_MC1); |
1442 | } | 1442 | } |
1443 | return 0; | 1443 | return 0; |
1444 | } | 1444 | } |
1445 | case VIDIOCGFBUF: | 1445 | case VIDIOCGFBUF: |
1446 | { | 1446 | { |
1447 | struct video_buffer v; | 1447 | struct video_buffer v; |
1448 | v.base = (void *) saa->win.vidadr; | 1448 | v.base = (void *)saa->win.vidadr; |
1449 | v.height = saa->win.sheight; | 1449 | v.height = saa->win.sheight; |
1450 | v.width = saa->win.swidth; | 1450 | v.width = saa->win.swidth; |
1451 | v.depth = saa->win.depth; | 1451 | v.depth = saa->win.depth; |
@@ -1463,19 +1463,20 @@ static int saa_ioctl(struct inode *inode, struct file *file, | |||
1463 | if (copy_from_user(&v, arg, sizeof(v))) | 1463 | if (copy_from_user(&v, arg, sizeof(v))) |
1464 | return -EFAULT; | 1464 | return -EFAULT; |
1465 | if (v.depth != 8 && v.depth != 15 && v.depth != 16 && | 1465 | if (v.depth != 8 && v.depth != 15 && v.depth != 16 && |
1466 | v.depth != 24 && v.depth != 32 && v.width > 16 && | 1466 | v.depth != 24 && v.depth != 32 && v.width > 16 && |
1467 | v.height > 16 && v.bytesperline > 16) | 1467 | v.height > 16 && v.bytesperline > 16) |
1468 | return -EINVAL; | 1468 | return -EINVAL; |
1469 | if (v.base) | 1469 | if (v.base) |
1470 | saa->win.vidadr = (unsigned long) v.base; | 1470 | saa->win.vidadr = (unsigned long)v.base; |
1471 | saa->win.sheight = v.height; | 1471 | saa->win.sheight = v.height; |
1472 | saa->win.swidth = v.width; | 1472 | saa->win.swidth = v.width; |
1473 | saa->win.bpp = ((v.depth + 7) & 0x38) / 8; | 1473 | saa->win.bpp = ((v.depth + 7) & 0x38) / 8; |
1474 | saa->win.depth = v.depth; | 1474 | saa->win.depth = v.depth; |
1475 | saa->win.bpl = v.bytesperline; | 1475 | saa->win.bpl = v.bytesperline; |
1476 | 1476 | ||
1477 | DEBUG(printk("Display at %p is %d by %d, bytedepth %d, bpl %d\n", | 1477 | DEBUG(printk("Display at %p is %d by %d, bytedepth %d, " |
1478 | v.base, v.width, v.height, saa->win.bpp, saa->win.bpl)); | 1478 | "bpl %d\n", v.base, v.width, v.height, |
1479 | saa->win.bpp, saa->win.bpl)); | ||
1479 | saa7146_set_winsize(saa); | 1480 | saa7146_set_winsize(saa); |
1480 | return 0; | 1481 | return 0; |
1481 | } | 1482 | } |
@@ -1503,21 +1504,18 @@ static int saa_ioctl(struct inode *inode, struct file *file, | |||
1503 | int i; | 1504 | int i; |
1504 | if (copy_from_user(&v, arg, sizeof(v))) | 1505 | if (copy_from_user(&v, arg, sizeof(v))) |
1505 | return -EFAULT; | 1506 | return -EFAULT; |
1506 | i = (~(v.volume>>8))&0xff; | 1507 | i = (~(v.volume >> 8)) & 0xff; |
1507 | if (!HaveCS4341) { | 1508 | if (!HaveCS4341) { |
1508 | if (v.flags & VIDEO_AUDIO_MUTE) { | 1509 | if (v.flags & VIDEO_AUDIO_MUTE) |
1509 | debiwrite(saa, debNormal, | 1510 | debiwrite(saa, debNormal, |
1510 | IBM_MP2_FRNT_ATTEN, | 1511 | IBM_MP2_FRNT_ATTEN, 0xffff, 2); |
1511 | 0xffff, 2); | ||
1512 | } | ||
1513 | if (!(v.flags & VIDEO_AUDIO_MUTE)) | 1512 | if (!(v.flags & VIDEO_AUDIO_MUTE)) |
1514 | debiwrite(saa, debNormal, | 1513 | debiwrite(saa, debNormal, |
1515 | IBM_MP2_FRNT_ATTEN, | 1514 | IBM_MP2_FRNT_ATTEN, 0x0000, 2); |
1516 | 0x0000, 2); | ||
1517 | if (v.flags & VIDEO_AUDIO_VOLUME) | 1515 | if (v.flags & VIDEO_AUDIO_VOLUME) |
1518 | debiwrite(saa, debNormal, | 1516 | debiwrite(saa, debNormal, |
1519 | IBM_MP2_FRNT_ATTEN, | 1517 | IBM_MP2_FRNT_ATTEN, |
1520 | (i<<8)|i, 2); | 1518 | (i << 8) | i, 2); |
1521 | } else { | 1519 | } else { |
1522 | if (v.flags & VIDEO_AUDIO_MUTE) | 1520 | if (v.flags & VIDEO_AUDIO_MUTE) |
1523 | cs4341_setlevel(saa, 0xff, 0xff); | 1521 | cs4341_setlevel(saa, 0xff, 0xff); |
@@ -1545,163 +1543,138 @@ static int saa_ioctl(struct inode *inode, struct file *file, | |||
1545 | case VIDIOCSPLAYMODE: | 1543 | case VIDIOCSPLAYMODE: |
1546 | { | 1544 | { |
1547 | struct video_play_mode pmode; | 1545 | struct video_play_mode pmode; |
1548 | if (copy_from_user((void *) &pmode, arg, | 1546 | if (copy_from_user((void *)&pmode, arg, |
1549 | sizeof(struct video_play_mode))) | 1547 | sizeof(struct video_play_mode))) |
1550 | return -EFAULT; | 1548 | return -EFAULT; |
1551 | switch (pmode.mode) { | 1549 | switch (pmode.mode) { |
1552 | case VID_PLAY_VID_OUT_MODE: | 1550 | case VID_PLAY_VID_OUT_MODE: |
1553 | if (pmode.p1 != VIDEO_MODE_NTSC && | 1551 | if (pmode.p1 != VIDEO_MODE_NTSC && |
1554 | pmode.p1 != VIDEO_MODE_PAL) | 1552 | pmode.p1 != VIDEO_MODE_PAL) |
1555 | return -EINVAL; | 1553 | return -EINVAL; |
1556 | set_out_format(saa, pmode.p1); | 1554 | set_out_format(saa, pmode.p1); |
1557 | return 0; | 1555 | return 0; |
1558 | case VID_PLAY_GENLOCK: | 1556 | case VID_PLAY_GENLOCK: |
1559 | debiwrite(saa, debNormal, | 1557 | debiwrite(saa, debNormal, XILINX_CTL0, |
1560 | XILINX_CTL0, | 1558 | pmode.p1 ? 0x8000 : 0x8080, 2); |
1561 | (pmode.p1 ? 0x8000 : 0x8080), | 1559 | if (NewCard) |
1562 | 2); | 1560 | set_genlock_offset(saa, pmode.p2); |
1563 | if (NewCard) | 1561 | return 0; |
1564 | set_genlock_offset(saa, | 1562 | case VID_PLAY_NORMAL: |
1565 | pmode.p2); | 1563 | debiwrite(saa, debNormal, |
1566 | return 0; | 1564 | IBM_MP2_CHIP_CONTROL, ChipControl, 2); |
1567 | case VID_PLAY_NORMAL: | 1565 | ibm_send_command(saa, IBM_MP2_PLAY, 0, 0); |
1568 | debiwrite(saa, debNormal, | 1566 | saa->playmode = pmode.mode; |
1569 | IBM_MP2_CHIP_CONTROL, | 1567 | return 0; |
1570 | ChipControl, 2); | 1568 | case VID_PLAY_PAUSE: |
1571 | ibm_send_command(saa, | 1569 | /* IBM removed the PAUSE command */ |
1572 | IBM_MP2_PLAY, 0, 0); | 1570 | /* they say use SINGLE_FRAME now */ |
1573 | saa->playmode = pmode.mode; | 1571 | case VID_PLAY_SINGLE_FRAME: |
1574 | return 0; | 1572 | ibm_send_command(saa, IBM_MP2_SINGLE_FRAME,0,0); |
1575 | case VID_PLAY_PAUSE: | 1573 | if (saa->playmode == pmode.mode) { |
1576 | /* IBM removed the PAUSE command */ | ||
1577 | /* they say use SINGLE_FRAME now */ | ||
1578 | case VID_PLAY_SINGLE_FRAME: | ||
1579 | ibm_send_command(saa, | ||
1580 | IBM_MP2_SINGLE_FRAME, | ||
1581 | 0, 0); | ||
1582 | if (saa->playmode == pmode.mode) { | ||
1583 | debiwrite(saa, debNormal, | ||
1584 | IBM_MP2_CHIP_CONTROL, | ||
1585 | ChipControl, 2); | ||
1586 | } | ||
1587 | saa->playmode = pmode.mode; | ||
1588 | return 0; | ||
1589 | case VID_PLAY_FAST_FORWARD: | ||
1590 | ibm_send_command(saa, | ||
1591 | IBM_MP2_FAST_FORWARD, 0, 0); | ||
1592 | saa->playmode = pmode.mode; | ||
1593 | return 0; | ||
1594 | case VID_PLAY_SLOW_MOTION: | ||
1595 | ibm_send_command(saa, | ||
1596 | IBM_MP2_SLOW_MOTION, | ||
1597 | pmode.p1, 0); | ||
1598 | saa->playmode = pmode.mode; | ||
1599 | return 0; | ||
1600 | case VID_PLAY_IMMEDIATE_NORMAL: | ||
1601 | /* ensure transfers resume */ | ||
1602 | debiwrite(saa, debNormal, | ||
1603 | IBM_MP2_CHIP_CONTROL, | ||
1604 | ChipControl, 2); | ||
1605 | ibm_send_command(saa, | ||
1606 | IBM_MP2_IMED_NORM_PLAY, 0, 0); | ||
1607 | saa->playmode = VID_PLAY_NORMAL; | ||
1608 | return 0; | ||
1609 | case VID_PLAY_SWITCH_CHANNELS: | ||
1610 | saa->audhead = saa->audtail = 0; | ||
1611 | saa->vidhead = saa->vidtail = 0; | ||
1612 | ibm_send_command(saa, | ||
1613 | IBM_MP2_FREEZE_FRAME, 0, 1); | ||
1614 | ibm_send_command(saa, | ||
1615 | IBM_MP2_RESET_AUD_RATE, 0, 1); | ||
1616 | debiwrite(saa, debNormal, | ||
1617 | IBM_MP2_CHIP_CONTROL, 0, 2); | ||
1618 | ibm_send_command(saa, | ||
1619 | IBM_MP2_CHANNEL_SWITCH, 0, 1); | ||
1620 | debiwrite(saa, debNormal, | 1574 | debiwrite(saa, debNormal, |
1621 | IBM_MP2_CHIP_CONTROL, | 1575 | IBM_MP2_CHIP_CONTROL, |
1622 | ChipControl, 2); | 1576 | ChipControl, 2); |
1623 | ibm_send_command(saa, | 1577 | } |
1624 | IBM_MP2_PLAY, 0, 0); | 1578 | saa->playmode = pmode.mode; |
1625 | saa->playmode = VID_PLAY_NORMAL; | 1579 | return 0; |
1626 | return 0; | 1580 | case VID_PLAY_FAST_FORWARD: |
1627 | case VID_PLAY_FREEZE_FRAME: | 1581 | ibm_send_command(saa, IBM_MP2_FAST_FORWARD,0,0); |
1628 | ibm_send_command(saa, | 1582 | saa->playmode = pmode.mode; |
1629 | IBM_MP2_FREEZE_FRAME, 0, 0); | 1583 | return 0; |
1630 | saa->playmode = pmode.mode; | 1584 | case VID_PLAY_SLOW_MOTION: |
1631 | return 0; | 1585 | ibm_send_command(saa, IBM_MP2_SLOW_MOTION, |
1632 | case VID_PLAY_STILL_MODE: | 1586 | pmode.p1, 0); |
1633 | ibm_send_command(saa, | 1587 | saa->playmode = pmode.mode; |
1634 | IBM_MP2_SET_STILL_MODE, 0, 0); | 1588 | return 0; |
1635 | saa->playmode = pmode.mode; | 1589 | case VID_PLAY_IMMEDIATE_NORMAL: |
1636 | return 0; | 1590 | /* ensure transfers resume */ |
1637 | case VID_PLAY_MASTER_MODE: | 1591 | debiwrite(saa, debNormal, |
1638 | if (pmode.p1 == VID_PLAY_MASTER_NONE) | 1592 | IBM_MP2_CHIP_CONTROL, ChipControl, 2); |
1639 | saa->boardcfg[1] = 0x13; | 1593 | ibm_send_command(saa, IBM_MP2_IMED_NORM_PLAY, |
1640 | else if (pmode.p1 == | 1594 | 0, 0); |
1641 | VID_PLAY_MASTER_VIDEO) | 1595 | saa->playmode = VID_PLAY_NORMAL; |
1642 | saa->boardcfg[1] = 0x23; | 1596 | return 0; |
1643 | else if (pmode.p1 == | 1597 | case VID_PLAY_SWITCH_CHANNELS: |
1644 | VID_PLAY_MASTER_AUDIO) | 1598 | saa->audhead = saa->audtail = 0; |
1645 | saa->boardcfg[1] = 0x43; | 1599 | saa->vidhead = saa->vidtail = 0; |
1646 | else | 1600 | ibm_send_command(saa, IBM_MP2_FREEZE_FRAME,0,1); |
1601 | ibm_send_command(saa, IBM_MP2_RESET_AUD_RATE, | ||
1602 | 0, 1); | ||
1603 | debiwrite(saa, debNormal, IBM_MP2_CHIP_CONTROL, | ||
1604 | 0, 2); | ||
1605 | ibm_send_command(saa, IBM_MP2_CHANNEL_SWITCH, | ||
1606 | 0, 1); | ||
1607 | debiwrite(saa, debNormal, IBM_MP2_CHIP_CONTROL, | ||
1608 | ChipControl, 2); | ||
1609 | ibm_send_command(saa, IBM_MP2_PLAY, 0, 0); | ||
1610 | saa->playmode = VID_PLAY_NORMAL; | ||
1611 | return 0; | ||
1612 | case VID_PLAY_FREEZE_FRAME: | ||
1613 | ibm_send_command(saa, IBM_MP2_FREEZE_FRAME,0,0); | ||
1614 | saa->playmode = pmode.mode; | ||
1615 | return 0; | ||
1616 | case VID_PLAY_STILL_MODE: | ||
1617 | ibm_send_command(saa, IBM_MP2_SET_STILL_MODE, | ||
1618 | 0, 0); | ||
1619 | saa->playmode = pmode.mode; | ||
1620 | return 0; | ||
1621 | case VID_PLAY_MASTER_MODE: | ||
1622 | if (pmode.p1 == VID_PLAY_MASTER_NONE) | ||
1623 | saa->boardcfg[1] = 0x13; | ||
1624 | else if (pmode.p1 == VID_PLAY_MASTER_VIDEO) | ||
1625 | saa->boardcfg[1] = 0x23; | ||
1626 | else if (pmode.p1 == VID_PLAY_MASTER_AUDIO) | ||
1627 | saa->boardcfg[1] = 0x43; | ||
1628 | else | ||
1629 | return -EINVAL; | ||
1630 | debiwrite(saa, debNormal, | ||
1631 | IBM_MP2_CHIP_CONTROL, ChipControl, 2); | ||
1632 | return 0; | ||
1633 | case VID_PLAY_ACTIVE_SCANLINES: | ||
1634 | if (CurrentMode == VIDEO_MODE_PAL) { | ||
1635 | if (pmode.p1 < 1 || pmode.p2 > 625) | ||
1647 | return -EINVAL; | 1636 | return -EINVAL; |
1648 | debiwrite(saa, debNormal, | 1637 | saa->boardcfg[5] = pmode.p1; |
1649 | IBM_MP2_CHIP_CONTROL, | 1638 | saa->boardcfg[55] = (pmode.p1 + |
1650 | ChipControl, 2); | 1639 | (pmode.p2 / 2) - 1) & 0xff; |
1651 | return 0; | 1640 | } else { |
1652 | case VID_PLAY_ACTIVE_SCANLINES: | 1641 | if (pmode.p1 < 4 || pmode.p2 > 525) |
1653 | if (CurrentMode == VIDEO_MODE_PAL) { | 1642 | return -EINVAL; |
1654 | if (pmode.p1 < 1 || | 1643 | saa->boardcfg[4] = pmode.p1; |
1655 | pmode.p2 > 625) | 1644 | saa->boardcfg[54] = (pmode.p1 + |
1656 | return -EINVAL; | 1645 | (pmode.p2 / 2) - 4) & 0xff; |
1657 | saa->boardcfg[5] = pmode.p1; | 1646 | } |
1658 | saa->boardcfg[55] = (pmode.p1 + | 1647 | set_out_format(saa, CurrentMode); |
1659 | (pmode.p2/2) - 1) & | 1648 | case VID_PLAY_RESET: |
1660 | 0xff; | 1649 | return do_ibm_reset(saa); |
1661 | } else { | 1650 | case VID_PLAY_END_MARK: |
1662 | if (pmode.p1 < 4 || | 1651 | if (saa->endmarktail < saa->endmarkhead) { |
1663 | pmode.p2 > 525) | 1652 | if (saa->endmarkhead - |
1664 | return -EINVAL; | ||
1665 | saa->boardcfg[4] = pmode.p1; | ||
1666 | saa->boardcfg[54] = (pmode.p1 + | ||
1667 | (pmode.p2/2) - 4) & | ||
1668 | 0xff; | ||
1669 | } | ||
1670 | set_out_format(saa, CurrentMode); | ||
1671 | case VID_PLAY_RESET: | ||
1672 | return do_ibm_reset(saa); | ||
1673 | case VID_PLAY_END_MARK: | ||
1674 | if (saa->endmarktail < | ||
1675 | saa->endmarkhead) { | ||
1676 | if (saa->endmarkhead - | ||
1677 | saa->endmarktail < 2) | 1653 | saa->endmarktail < 2) |
1678 | return -ENOSPC; | ||
1679 | } else if (saa->endmarkhead <= | ||
1680 | saa->endmarktail) { | ||
1681 | if (saa->endmarktail - | ||
1682 | saa->endmarkhead > | ||
1683 | (MAX_MARKS - 2)) | ||
1684 | return -ENOSPC; | ||
1685 | } else | ||
1686 | return -ENOSPC; | 1654 | return -ENOSPC; |
1687 | saa->endmark[saa->endmarktail] = | 1655 | } else if (saa->endmarkhead <=saa->endmarktail){ |
1688 | saa->audtail; | 1656 | if (saa->endmarktail - saa->endmarkhead |
1689 | saa->endmarktail++; | 1657 | > (MAX_MARKS - 2)) |
1690 | if (saa->endmarktail >= MAX_MARKS) | 1658 | return -ENOSPC; |
1691 | saa->endmarktail = 0; | 1659 | } else |
1660 | return -ENOSPC; | ||
1661 | saa->endmark[saa->endmarktail] = saa->audtail; | ||
1662 | saa->endmarktail++; | ||
1663 | if (saa->endmarktail >= MAX_MARKS) | ||
1664 | saa->endmarktail = 0; | ||
1692 | } | 1665 | } |
1693 | return -EINVAL; | 1666 | return -EINVAL; |
1694 | } | 1667 | } |
1695 | case VIDIOCSWRITEMODE: | 1668 | case VIDIOCSWRITEMODE: |
1696 | { | 1669 | { |
1697 | int mode; | 1670 | int mode; |
1698 | if (copy_from_user((void *) &mode, arg, sizeof(int))) | 1671 | if (copy_from_user((void *)&mode, arg, sizeof(int))) |
1699 | return -EFAULT; | 1672 | return -EFAULT; |
1700 | if (mode == VID_WRITE_MPEG_AUD || | 1673 | if (mode == VID_WRITE_MPEG_AUD || |
1701 | mode == VID_WRITE_MPEG_VID || | 1674 | mode == VID_WRITE_MPEG_VID || |
1702 | mode == VID_WRITE_CC || | 1675 | mode == VID_WRITE_CC || |
1703 | mode == VID_WRITE_TTX || | 1676 | mode == VID_WRITE_TTX || |
1704 | mode == VID_WRITE_OSD) { | 1677 | mode == VID_WRITE_OSD) { |
1705 | saa->writemode = mode; | 1678 | saa->writemode = mode; |
1706 | return 0; | 1679 | return 0; |
1707 | } | 1680 | } |
@@ -1715,7 +1688,7 @@ static int saa_ioctl(struct inode *inode, struct file *file, | |||
1715 | if (copy_from_user(&ucode, arg, sizeof(ucode))) | 1688 | if (copy_from_user(&ucode, arg, sizeof(ucode))) |
1716 | return -EFAULT; | 1689 | return -EFAULT; |
1717 | if (ucode.datasize > 65536 || ucode.datasize < 1024 || | 1690 | if (ucode.datasize > 65536 || ucode.datasize < 1024 || |
1718 | strncmp(ucode.loadwhat, "dec", 3)) | 1691 | strncmp(ucode.loadwhat, "dec", 3)) |
1719 | return -EINVAL; | 1692 | return -EINVAL; |
1720 | if ((udata = vmalloc(ucode.datasize)) == NULL) | 1693 | if ((udata = vmalloc(ucode.datasize)) == NULL) |
1721 | return -ENOMEM; | 1694 | return -ENOMEM; |
@@ -1724,8 +1697,8 @@ static int saa_ioctl(struct inode *inode, struct file *file, | |||
1724 | return -EFAULT; | 1697 | return -EFAULT; |
1725 | } | 1698 | } |
1726 | ucode.data = udata; | 1699 | ucode.data = udata; |
1727 | if (!strncmp(ucode.loadwhat, "decoder.aud", 11) | 1700 | if (!strncmp(ucode.loadwhat, "decoder.aud", 11) || |
1728 | || !strncmp(ucode.loadwhat, "decoder.vid", 11)) | 1701 | !strncmp(ucode.loadwhat, "decoder.vid", 11)) |
1729 | i = initialize_ibmmpeg2(&ucode); | 1702 | i = initialize_ibmmpeg2(&ucode); |
1730 | else | 1703 | else |
1731 | i = initialize_fpga(&ucode); | 1704 | i = initialize_fpga(&ucode); |
@@ -1770,14 +1743,14 @@ static int saa_mmap(struct file *file, struct vm_area_struct *vma) | |||
1770 | return -EINVAL; | 1743 | return -EINVAL; |
1771 | } | 1744 | } |
1772 | 1745 | ||
1773 | static ssize_t saa_read(struct file *file, char __user *buf, | 1746 | static ssize_t saa_read(struct file *file, char __user * buf, |
1774 | size_t count, loff_t *ppos) | 1747 | size_t count, loff_t * ppos) |
1775 | { | 1748 | { |
1776 | return -EINVAL; | 1749 | return -EINVAL; |
1777 | } | 1750 | } |
1778 | 1751 | ||
1779 | static ssize_t saa_write(struct file *file, const char __user *buf, | 1752 | static ssize_t saa_write(struct file *file, const char __user * buf, |
1780 | size_t count, loff_t *ppos) | 1753 | size_t count, loff_t * ppos) |
1781 | { | 1754 | { |
1782 | struct saa7146 *saa = file->private_data; | 1755 | struct saa7146 *saa = file->private_data; |
1783 | unsigned long todo = count; | 1756 | unsigned long todo = count; |
@@ -1788,20 +1761,22 @@ static ssize_t saa_write(struct file *file, const char __user *buf, | |||
1788 | if (saa->writemode == VID_WRITE_MPEG_AUD) { | 1761 | if (saa->writemode == VID_WRITE_MPEG_AUD) { |
1789 | spin_lock_irqsave(&saa->lock, flags); | 1762 | spin_lock_irqsave(&saa->lock, flags); |
1790 | if (saa->audhead <= saa->audtail) | 1763 | if (saa->audhead <= saa->audtail) |
1791 | blocksize = 65536-(saa->audtail - saa->audhead); | 1764 | blocksize = 65536 - |
1765 | (saa->audtail - saa->audhead); | ||
1792 | else | 1766 | else |
1793 | blocksize = saa->audhead - saa->audtail; | 1767 | blocksize = saa->audhead - saa->audtail; |
1794 | spin_unlock_irqrestore(&saa->lock, flags); | 1768 | spin_unlock_irqrestore(&saa->lock, flags); |
1795 | if (blocksize < 16384) { | 1769 | if (blocksize < 16384) { |
1796 | saawrite(SAA7146_PSR_DEBI_S | | 1770 | saawrite(SAA7146_PSR_DEBI_S | |
1797 | SAA7146_PSR_PIN1, SAA7146_IER); | 1771 | SAA7146_PSR_PIN1, SAA7146_IER); |
1798 | saawrite(SAA7146_PSR_PIN1, SAA7146_PSR); | 1772 | saawrite(SAA7146_PSR_PIN1, SAA7146_PSR); |
1799 | /* wait for buffer space to open */ | 1773 | /* wait for buffer space to open */ |
1800 | interruptible_sleep_on(&saa->audq); | 1774 | interruptible_sleep_on(&saa->audq); |
1801 | } | 1775 | } |
1802 | spin_lock_irqsave(&saa->lock, flags); | 1776 | spin_lock_irqsave(&saa->lock, flags); |
1803 | if (saa->audhead <= saa->audtail) { | 1777 | if (saa->audhead <= saa->audtail) { |
1804 | blocksize = 65536-(saa->audtail - saa->audhead); | 1778 | blocksize = 65536 - |
1779 | (saa->audtail - saa->audhead); | ||
1805 | split = 65536 - saa->audtail; | 1780 | split = 65536 - saa->audtail; |
1806 | } else { | 1781 | } else { |
1807 | blocksize = saa->audhead - saa->audtail; | 1782 | blocksize = saa->audhead - saa->audtail; |
@@ -1816,7 +1791,7 @@ static ssize_t saa_write(struct file *file, const char __user *buf, | |||
1816 | return -ENOSPC; | 1791 | return -ENOSPC; |
1817 | if (split < blocksize) { | 1792 | if (split < blocksize) { |
1818 | if (copy_from_user(saa->audbuf + | 1793 | if (copy_from_user(saa->audbuf + |
1819 | saa->audtail, buf, split)) | 1794 | saa->audtail, buf, split)) |
1820 | return -EFAULT; | 1795 | return -EFAULT; |
1821 | buf += split; | 1796 | buf += split; |
1822 | todo -= split; | 1797 | todo -= split; |
@@ -1824,7 +1799,7 @@ static ssize_t saa_write(struct file *file, const char __user *buf, | |||
1824 | saa->audtail = 0; | 1799 | saa->audtail = 0; |
1825 | } | 1800 | } |
1826 | if (copy_from_user(saa->audbuf + saa->audtail, buf, | 1801 | if (copy_from_user(saa->audbuf + saa->audtail, buf, |
1827 | blocksize)) | 1802 | blocksize)) |
1828 | return -EFAULT; | 1803 | return -EFAULT; |
1829 | saa->audtail += blocksize; | 1804 | saa->audtail += blocksize; |
1830 | todo -= blocksize; | 1805 | todo -= blocksize; |
@@ -1833,20 +1808,22 @@ static ssize_t saa_write(struct file *file, const char __user *buf, | |||
1833 | } else if (saa->writemode == VID_WRITE_MPEG_VID) { | 1808 | } else if (saa->writemode == VID_WRITE_MPEG_VID) { |
1834 | spin_lock_irqsave(&saa->lock, flags); | 1809 | spin_lock_irqsave(&saa->lock, flags); |
1835 | if (saa->vidhead <= saa->vidtail) | 1810 | if (saa->vidhead <= saa->vidtail) |
1836 | blocksize=524288-(saa->vidtail - saa->vidhead); | 1811 | blocksize = 524288 - |
1812 | (saa->vidtail - saa->vidhead); | ||
1837 | else | 1813 | else |
1838 | blocksize = saa->vidhead - saa->vidtail; | 1814 | blocksize = saa->vidhead - saa->vidtail; |
1839 | spin_unlock_irqrestore(&saa->lock, flags); | 1815 | spin_unlock_irqrestore(&saa->lock, flags); |
1840 | if (blocksize < 65536) { | 1816 | if (blocksize < 65536) { |
1841 | saawrite(SAA7146_PSR_DEBI_S | | 1817 | saawrite(SAA7146_PSR_DEBI_S | |
1842 | SAA7146_PSR_PIN1, SAA7146_IER); | 1818 | SAA7146_PSR_PIN1, SAA7146_IER); |
1843 | saawrite(SAA7146_PSR_PIN1, SAA7146_PSR); | 1819 | saawrite(SAA7146_PSR_PIN1, SAA7146_PSR); |
1844 | /* wait for buffer space to open */ | 1820 | /* wait for buffer space to open */ |
1845 | interruptible_sleep_on(&saa->vidq); | 1821 | interruptible_sleep_on(&saa->vidq); |
1846 | } | 1822 | } |
1847 | spin_lock_irqsave(&saa->lock, flags); | 1823 | spin_lock_irqsave(&saa->lock, flags); |
1848 | if (saa->vidhead <= saa->vidtail) { | 1824 | if (saa->vidhead <= saa->vidtail) { |
1849 | blocksize=524288-(saa->vidtail - saa->vidhead); | 1825 | blocksize = 524288 - |
1826 | (saa->vidtail - saa->vidhead); | ||
1850 | split = 524288 - saa->vidtail; | 1827 | split = 524288 - saa->vidtail; |
1851 | } else { | 1828 | } else { |
1852 | blocksize = saa->vidhead - saa->vidtail; | 1829 | blocksize = saa->vidhead - saa->vidtail; |
@@ -1861,7 +1838,7 @@ static ssize_t saa_write(struct file *file, const char __user *buf, | |||
1861 | return -ENOSPC; | 1838 | return -ENOSPC; |
1862 | if (split < blocksize) { | 1839 | if (split < blocksize) { |
1863 | if (copy_from_user(saa->vidbuf + | 1840 | if (copy_from_user(saa->vidbuf + |
1864 | saa->vidtail, buf, split)) | 1841 | saa->vidtail, buf, split)) |
1865 | return -EFAULT; | 1842 | return -EFAULT; |
1866 | buf += split; | 1843 | buf += split; |
1867 | todo -= split; | 1844 | todo -= split; |
@@ -1869,7 +1846,7 @@ static ssize_t saa_write(struct file *file, const char __user *buf, | |||
1869 | saa->vidtail = 0; | 1846 | saa->vidtail = 0; |
1870 | } | 1847 | } |
1871 | if (copy_from_user(saa->vidbuf + saa->vidtail, buf, | 1848 | if (copy_from_user(saa->vidbuf + saa->vidtail, buf, |
1872 | blocksize)) | 1849 | blocksize)) |
1873 | return -EFAULT; | 1850 | return -EFAULT; |
1874 | saa->vidtail += blocksize; | 1851 | saa->vidtail += blocksize; |
1875 | todo -= blocksize; | 1852 | todo -= blocksize; |
@@ -1887,8 +1864,8 @@ static ssize_t saa_write(struct file *file, const char __user *buf, | |||
1887 | debiwrite(saa, debNormal, IBM_MP2_OSD_LINK_ADDR, 0, 2); | 1864 | debiwrite(saa, debNormal, IBM_MP2_OSD_LINK_ADDR, 0, 2); |
1888 | debiwrite(saa, debNormal, IBM_MP2_MASK0, 0xc00d, 2); | 1865 | debiwrite(saa, debNormal, IBM_MP2_MASK0, 0xc00d, 2); |
1889 | debiwrite(saa, debNormal, IBM_MP2_DISP_MODE, | 1866 | debiwrite(saa, debNormal, IBM_MP2_DISP_MODE, |
1890 | debiread(saa, debNormal, | 1867 | debiread(saa, debNormal, |
1891 | IBM_MP2_DISP_MODE, 2) | 1, 2); | 1868 | IBM_MP2_DISP_MODE, 2) | 1, 2); |
1892 | /* trigger osd data transfer */ | 1869 | /* trigger osd data transfer */ |
1893 | saawrite(SAA7146_PSR_DEBI_S | | 1870 | saawrite(SAA7146_PSR_DEBI_S | |
1894 | SAA7146_PSR_PIN1, SAA7146_IER); | 1871 | SAA7146_PSR_PIN1, SAA7146_IER); |
@@ -1923,34 +1900,32 @@ static int saa_release(struct inode *inode, struct file *file) | |||
1923 | return 0; | 1900 | return 0; |
1924 | } | 1901 | } |
1925 | 1902 | ||
1926 | static struct file_operations saa_fops = | 1903 | static struct file_operations saa_fops = { |
1927 | { | 1904 | .owner = THIS_MODULE, |
1928 | .owner = THIS_MODULE, | 1905 | .open = saa_open, |
1929 | .open = saa_open, | 1906 | .release = saa_release, |
1930 | .release = saa_release, | 1907 | .ioctl = saa_ioctl, |
1931 | .ioctl = saa_ioctl, | 1908 | .compat_ioctl = v4l_compat_ioctl32, |
1932 | .compat_ioctl = v4l_compat_ioctl32, | 1909 | .read = saa_read, |
1933 | .read = saa_read, | 1910 | .llseek = no_llseek, |
1934 | .llseek = no_llseek, | 1911 | .write = saa_write, |
1935 | .write = saa_write, | 1912 | .mmap = saa_mmap, |
1936 | .mmap = saa_mmap, | ||
1937 | }; | 1913 | }; |
1938 | 1914 | ||
1939 | /* template for video_device-structure */ | 1915 | /* template for video_device-structure */ |
1940 | static struct video_device saa_template = | 1916 | static struct video_device saa_template = { |
1941 | { | 1917 | .name = "SAA7146A", |
1942 | .name = "SAA7146A", | 1918 | .type = VID_TYPE_CAPTURE | VID_TYPE_OVERLAY, |
1943 | .type = VID_TYPE_CAPTURE | VID_TYPE_OVERLAY, | 1919 | .hardware = VID_HARDWARE_SAA7146, |
1944 | .hardware = VID_HARDWARE_SAA7146, | 1920 | .fops = &saa_fops, |
1945 | .fops = &saa_fops, | 1921 | .minor = -1, |
1946 | .minor = -1, | ||
1947 | }; | 1922 | }; |
1948 | 1923 | ||
1949 | static int __devinit configure_saa7146(struct pci_dev *pdev, int num) | 1924 | static int __devinit configure_saa7146(struct pci_dev *pdev, int num) |
1950 | { | 1925 | { |
1951 | int retval; | 1926 | int retval; |
1952 | struct saa7146 *saa = pci_get_drvdata(pdev); | 1927 | struct saa7146 *saa = pci_get_drvdata(pdev); |
1953 | 1928 | ||
1954 | saa->endmarkhead = saa->endmarktail = 0; | 1929 | saa->endmarkhead = saa->endmarktail = 0; |
1955 | saa->win.x = saa->win.y = 0; | 1930 | saa->win.x = saa->win.y = 0; |
1956 | saa->win.width = saa->win.cropwidth = 720; | 1931 | saa->win.width = saa->win.cropwidth = 720; |
@@ -1990,7 +1965,7 @@ static int __devinit configure_saa7146(struct pci_dev *pdev, int num) | |||
1990 | dev_err(&pdev->dev, "%d: pci_enable_device failed!\n", num); | 1965 | dev_err(&pdev->dev, "%d: pci_enable_device failed!\n", num); |
1991 | goto err; | 1966 | goto err; |
1992 | } | 1967 | } |
1993 | 1968 | ||
1994 | saa->id = pdev->device; | 1969 | saa->id = pdev->device; |
1995 | saa->irq = pdev->irq; | 1970 | saa->irq = pdev->irq; |
1996 | saa->video_dev.minor = -1; | 1971 | saa->video_dev.minor = -1; |
@@ -2020,7 +1995,7 @@ static int __devinit configure_saa7146(struct pci_dev *pdev, int num) | |||
2020 | pci_set_master(pdev); | 1995 | pci_set_master(pdev); |
2021 | retval = video_register_device(&saa->video_dev, VFL_TYPE_GRABBER, | 1996 | retval = video_register_device(&saa->video_dev, VFL_TYPE_GRABBER, |
2022 | video_nr); | 1997 | video_nr); |
2023 | if (retval < 0) { | 1998 | if (retval < 0) { |
2024 | dev_err(&pdev->dev, "%d: error in registering video device!\n", | 1999 | dev_err(&pdev->dev, "%d: error in registering video device!\n", |
2025 | num); | 2000 | num); |
2026 | goto errio; | 2001 | goto errio; |
@@ -2055,16 +2030,16 @@ static int __devinit init_saa7146(struct pci_dev *pdev) | |||
2055 | saawrite(0x00000000, SAA7146_DD1_STREAM_A); | 2030 | saawrite(0x00000000, SAA7146_DD1_STREAM_A); |
2056 | saawrite(0x00000000, SAA7146_BRS_CTRL); | 2031 | saawrite(0x00000000, SAA7146_BRS_CTRL); |
2057 | saawrite(0x80400040, SAA7146_BCS_CTRL); | 2032 | saawrite(0x80400040, SAA7146_BCS_CTRL); |
2058 | saawrite(0x0000e000 /*| (1<<29)*/, SAA7146_HPS_CTRL); | 2033 | saawrite(0x0000e000 /*| (1<<29) */ , SAA7146_HPS_CTRL); |
2059 | saawrite(0x00000060, SAA7146_CLIP_FORMAT_CTRL); | 2034 | saawrite(0x00000060, SAA7146_CLIP_FORMAT_CTRL); |
2060 | saawrite(0x00000000, SAA7146_ACON1); | 2035 | saawrite(0x00000000, SAA7146_ACON1); |
2061 | saawrite(0x00000000, SAA7146_ACON2); | 2036 | saawrite(0x00000000, SAA7146_ACON2); |
2062 | saawrite(0x00000600, SAA7146_I2C_STATUS); | 2037 | saawrite(0x00000600, SAA7146_I2C_STATUS); |
2063 | saawrite(((SAA7146_MC2_UPLD_D1_B | SAA7146_MC2_UPLD_D1_A | | 2038 | saawrite(((SAA7146_MC2_UPLD_D1_B | SAA7146_MC2_UPLD_D1_A | |
2064 | SAA7146_MC2_UPLD_BRS | SAA7146_MC2_UPLD_HPS_H | | 2039 | SAA7146_MC2_UPLD_BRS | SAA7146_MC2_UPLD_HPS_H | |
2065 | SAA7146_MC2_UPLD_HPS_V | SAA7146_MC2_UPLD_DMA2 | | 2040 | SAA7146_MC2_UPLD_HPS_V | SAA7146_MC2_UPLD_DMA2 | |
2066 | SAA7146_MC2_UPLD_DMA1 | SAA7146_MC2_UPLD_I2C) << 16) | 0xffff, | 2041 | SAA7146_MC2_UPLD_DMA1 | SAA7146_MC2_UPLD_I2C) << 16) | 0xffff, |
2067 | SAA7146_MC2); | 2042 | SAA7146_MC2); |
2068 | /* setup arbitration control registers */ | 2043 | /* setup arbitration control registers */ |
2069 | saawrite(0x1412121a, SAA7146_PCI_BT_V1); | 2044 | saawrite(0x1412121a, SAA7146_PCI_BT_V1); |
2070 | 2045 | ||
@@ -2102,9 +2077,9 @@ static int __devinit init_saa7146(struct pci_dev *pdev) | |||
2102 | saawrite(virt_to_bus(saa->dmavid2), SAA7146_BASE_EVEN2); | 2077 | saawrite(virt_to_bus(saa->dmavid2), SAA7146_BASE_EVEN2); |
2103 | saawrite(virt_to_bus(saa->dmavid2) + 128, SAA7146_BASE_ODD2); | 2078 | saawrite(virt_to_bus(saa->dmavid2) + 128, SAA7146_BASE_ODD2); |
2104 | saawrite(virt_to_bus(saa->dmavid2) + VIDEO_CLIPMAP_SIZE, | 2079 | saawrite(virt_to_bus(saa->dmavid2) + VIDEO_CLIPMAP_SIZE, |
2105 | SAA7146_PROT_ADDR2); | 2080 | SAA7146_PROT_ADDR2); |
2106 | saawrite(256, SAA7146_PITCH2); | 2081 | saawrite(256, SAA7146_PITCH2); |
2107 | saawrite(4, SAA7146_PAGE2); /* dma direction: read, no byteswap */ | 2082 | saawrite(4, SAA7146_PAGE2); /* dma direction: read, no byteswap */ |
2108 | saawrite(((SAA7146_MC2_UPLD_DMA2) << 16) | SAA7146_MC2_UPLD_DMA2, | 2083 | saawrite(((SAA7146_MC2_UPLD_DMA2) << 16) | SAA7146_MC2_UPLD_DMA2, |
2109 | SAA7146_MC2); | 2084 | SAA7146_MC2); |
2110 | I2CBusScan(saa); | 2085 | I2CBusScan(saa); |
@@ -2209,13 +2184,14 @@ static struct pci_device_id stradis_pci_tbl[] = { | |||
2209 | { PCI_DEVICE(PCI_VENDOR_ID_PHILIPS, PCI_DEVICE_ID_PHILIPS_SAA7146) }, | 2184 | { PCI_DEVICE(PCI_VENDOR_ID_PHILIPS, PCI_DEVICE_ID_PHILIPS_SAA7146) }, |
2210 | { 0 } | 2185 | { 0 } |
2211 | }; | 2186 | }; |
2187 | |||
2212 | MODULE_DEVICE_TABLE(pci, stradis_pci_tbl); | 2188 | MODULE_DEVICE_TABLE(pci, stradis_pci_tbl); |
2213 | 2189 | ||
2214 | static struct pci_driver stradis_driver = { | 2190 | static struct pci_driver stradis_driver = { |
2215 | .name = "stradis", | 2191 | .name = "stradis", |
2216 | .id_table = stradis_pci_tbl, | 2192 | .id_table = stradis_pci_tbl, |
2217 | .probe = stradis_probe, | 2193 | .probe = stradis_probe, |
2218 | .remove = __devexit_p(stradis_remove) | 2194 | .remove = __devexit_p(stradis_remove) |
2219 | }; | 2195 | }; |
2220 | 2196 | ||
2221 | int __init stradis_init(void) | 2197 | int __init stradis_init(void) |
@@ -2231,7 +2207,6 @@ int __init stradis_init(void) | |||
2231 | return retval; | 2207 | return retval; |
2232 | } | 2208 | } |
2233 | 2209 | ||
2234 | |||
2235 | void __exit stradis_exit(void) | 2210 | void __exit stradis_exit(void) |
2236 | { | 2211 | { |
2237 | pci_unregister_driver(&stradis_driver); | 2212 | pci_unregister_driver(&stradis_driver); |