* Media Labs LML33/LML33R10.
*
* This part handles device access (PCI/I2C/codec/...)
- *
+ *
* Copyright (C) 2000 Serguei Miridonov <mirsev@cicese.mx>
*
* Currently maintained by:
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-#include <linux/config.h>
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/vmalloc.h>
+#include <linux/byteorder/generic.h>
#include <linux/interrupt.h>
#include <linux/proc_fs.h>
#include <linux/video_decoder.h>
#include <linux/video_encoder.h>
#include <linux/delay.h>
+#include <linux/wait.h>
#include <asm/io.h>
ZR36057_ISR_JPEGRepIRQ )
extern const struct zoran_format zoran_formats[];
-extern const int zoran_num_formats;
extern int *zr_debug;
* load on Bt819 input, there will be
* some image imperfections */
-MODULE_PARM(lml33dpath, "i");
+module_param(lml33dpath, bool, 0);
MODULE_PARM_DESC(lml33dpath,
"Use digital path capture mode (on LML33 cards)");
+static void
+zr36057_init_vfe (struct zoran *zr);
+
/*
* General Purpose I/O and Guest bus access
*/
reg |= (HorDcm << ZR36057_VFESPFR_HorDcm);
reg |= (VerDcm << ZR36057_VFESPFR_VerDcm);
reg |= (DispMode << ZR36057_VFESPFR_DispMode);
- if (format->palette != VIDEO_PALETTE_YUV422)
+ if (format->palette != VIDEO_PALETTE_YUV422 && format->palette != VIDEO_PALETTE_YUYV)
reg |= ZR36057_VFESPFR_LittleEndian;
/* RJ: I don't know, why the following has to be the opposite
* of the corresponding ZR36060 setting, but only this way
reg |= ZR36057_VFESPFR_TopField;
switch (format->palette) {
+ case VIDEO_PALETTE_YUYV:
case VIDEO_PALETTE_YUV422:
reg |= ZR36057_VFESPFR_YUV422;
break;
/* (Ronald) don't write this if overlay_mask = NULL */
if (zr->overlay_mask) {
/* Write overlay clipping mask data, but don't enable overlay clipping */
- /* RJ: since this makes only sense on the screen, we use
+ /* RJ: since this makes only sense on the screen, we use
* zr->overlay_settings.width instead of video_width */
mask_line_size = (BUZ_MAX_WIDTH + 31) / 32;
* All error messages are internal driver checking only! */
/* video display top and bottom registers */
- reg = (u32) zr->buffer.base +
+ reg = (long) zr->buffer.base +
zr->overlay_settings.x *
((zr->overlay_settings.format->depth + 7) / 8) +
zr->overlay_settings.y *
if (!zr->v4l_memgrab_active)
return 0;
- while (zr->v4l_pend_tail != zr->v4l_pend_head) {
- interruptible_sleep_on(&zr->v4l_capq);
- if (signal_pending(current))
- return -ERESTARTSYS;
- }
+ wait_event_interruptible(zr->v4l_capq,
+ (zr->v4l_pend_tail == zr->v4l_pend_head));
+ if (signal_pending(current))
+ return -ERESTARTSYS;
spin_lock_irqsave(&zr->spinlock, flags);
zr36057_set_memgrab(zr, 0);
zr->jpg_buffers.buffer[i].state = BUZ_STATE_USER; /* nothing going on */
}
for (i = 0; i < BUZ_NUM_STAT_COM; i++) {
- zr->stat_com[i] = 1; /* mark as unavailable to zr36057 */
+ zr->stat_com[i] = cpu_to_le32(1); /* mark as unavailable to zr36057 */
}
}
if (zr->card.vfe_pol.hsync_pol)
btor(ZR36057_VFEHCR_HSPol, ZR36057_VFEHCR);
else
- btand(~ZR36057_VFEHCR_HSPol, ZR36057_VFEHCR);
+ btand(~ZR36057_VFEHCR_HSPol, ZR36057_VFEHCR);
reg = ((tvn->HSyncStart) << ZR36057_HSP_HsyncStart) |
(tvn->Wt << ZR36057_HSP_LineTot);
btwrite(reg, ZR36057_HSP);
reg = ((zr->jpg_settings.img_x +
- tvn->HStart + 4) << ZR36057_FHAP_NAX) |
+ tvn->HStart + 4) << ZR36057_FHAP_NAX) |
(zr->jpg_settings.img_width << ZR36057_FHAP_PAX);
btwrite(reg, ZR36057_FHAP);
switch (mode) {
- case BUZ_MODE_MOTION_COMPRESS:
+ case BUZ_MODE_MOTION_COMPRESS: {
+ struct jpeg_app_marker app;
+ struct jpeg_com_marker com;
+
/* In motion compress mode, the decoder output must be enabled, and
* the video bus direction set to input.
*/
/* Take the JPEG codec and the VFE out of sleep */
jpeg_codec_sleep(zr, 0);
+
+ /* set JPEG app/com marker */
+ app.appn = zr->jpg_settings.jpg_comp.APPn;
+ app.len = zr->jpg_settings.jpg_comp.APP_len;
+ memcpy(app.data, zr->jpg_settings.jpg_comp.APP_data, 60);
+ zr->codec->control(zr->codec, CODEC_S_JPEG_APP_DATA,
+ sizeof(struct jpeg_app_marker), &app);
+
+ com.len = zr->jpg_settings.jpg_comp.COM_len;
+ memcpy(com.data, zr->jpg_settings.jpg_comp.COM_data, 60);
+ zr->codec->control(zr->codec, CODEC_S_JPEG_COM_DATA,
+ sizeof(struct jpeg_com_marker), &com);
+
/* Setup the JPEG codec */
zr->codec->control(zr->codec, CODEC_S_JPEG_TDS_BYTE,
sizeof(int), &field_size);
dprintk(2, KERN_INFO "%s: enable_jpg(MOTION_COMPRESS)\n",
ZR_DEVNAME(zr));
break;
+ }
case BUZ_MODE_MOTION_DECOMPRESS:
/* In motion decompression mode, the decoder output must be disabled, and
/* fill 1 stat_com entry */
i = (zr->jpg_dma_head -
zr->jpg_err_shift) & BUZ_MASK_STAT_COM;
- if (!(zr->stat_com[i] & 1))
+ if (!(zr->stat_com[i] & cpu_to_le32(1)))
break;
zr->stat_com[i] =
- zr->jpg_buffers.buffer[frame].frag_tab_bus;
+ cpu_to_le32(zr->jpg_buffers.buffer[frame].frag_tab_bus);
} else {
/* fill 2 stat_com entries */
i = ((zr->jpg_dma_head -
zr->jpg_err_shift) & 1) * 2;
- if (!(zr->stat_com[i] & 1))
+ if (!(zr->stat_com[i] & cpu_to_le32(1)))
break;
zr->stat_com[i] =
- zr->jpg_buffers.buffer[frame].frag_tab_bus;
+ cpu_to_le32(zr->jpg_buffers.buffer[frame].frag_tab_bus);
zr->stat_com[i + 1] =
- zr->jpg_buffers.buffer[frame].frag_tab_bus;
+ cpu_to_le32(zr->jpg_buffers.buffer[frame].frag_tab_bus);
}
zr->jpg_buffers.buffer[frame].state = BUZ_STATE_DMA;
zr->jpg_dma_head++;
i = ((zr->jpg_dma_tail -
zr->jpg_err_shift) & 1) * 2 + 1;
- stat_com = zr->stat_com[i];
+ stat_com = le32_to_cpu(zr->stat_com[i]);
if ((stat_com & 1) == 0) {
return;
if (zr->JPEG_error != 1) {
/*
* First entry: error just happened during normal operation
- *
+ *
* In BUZ_MODE_MOTION_COMPRESS:
- *
+ *
* Possible glitch in TV signal. In this case we should
* stop the codec and wait for good quality signal before
* restarting it to avoid further problems
- *
+ *
* In BUZ_MODE_MOTION_DECOMPRESS:
- *
+ *
* Bad JPEG frame: we have to mark it as processed (codec crashed
* and was not able to do it itself), and to remove it from queue.
*/
for (i = 0;
i < zr->jpg_buffers.num_buffers;
i++) {
- if (zr->stat_com[j] ==
+ if (le32_to_cpu(zr->stat_com[j]) ==
zr->jpg_buffers.
buffer[i].
frag_tab_bus) {
printk("\n");
}
}
-
/* Find an entry in stat_com and rotate contents */
{
int i;
zr->jpg_err_shift) & 1) * 2;
if (zr->codec_mode == BUZ_MODE_MOTION_DECOMPRESS) {
/* Mimic zr36067 operation */
- zr->stat_com[i] |= 1;
+ zr->stat_com[i] |= cpu_to_le32(1);
if (zr->jpg_settings.TmpDcm != 1)
- zr->stat_com[i + 1] |= 1;
+ zr->stat_com[i + 1] |= cpu_to_le32(1);
/* Refill */
zoran_reap_stat_com(zr);
zoran_feed_stat_com(zr);
int j;
u32 bus_addr[BUZ_NUM_STAT_COM];
+ /* Here we are copying the stat_com array, which
+ * is already in little endian format, so
+ * no endian conversions here
+ */
memcpy(bus_addr, zr->stat_com,
sizeof(bus_addr));
for (j = 0; j < BUZ_NUM_STAT_COM; j++) {
zr->stat_com[j] =
bus_addr[(i + j) &
BUZ_MASK_STAT_COM];
+
}
zr->jpg_err_shift += i;
zr->jpg_err_shift &= BUZ_MASK_STAT_COM;
irqreturn_t
zoran_irq (int irq,
- void *dev_id,
- struct pt_regs *regs)
+ void *dev_id)
{
u32 stat, astat;
int count;
struct zoran *zr;
unsigned long flags;
- zr = (struct zoran *) dev_id;
+ zr = dev_id;
count = 0;
if (zr->testing) {
int i;
strcpy(sv, sc);
for (i = 0; i < 4; i++) {
- if (zr->stat_com[i] & 1)
+ if (le32_to_cpu(zr->stat_com[i]) & 1)
sv[i] = '1';
}
sv[4] = 0;
ZR_DEVNAME(zr), zr->jpg_seq_num);
for (i = 0; i < 4; i++) {
printk(" %08x",
- zr->stat_com[i]);
+ le32_to_cpu(zr->stat_com[i]));
}
printk("\n");
}
* initialize video front end
*/
-void
+static void
zr36057_init_vfe (struct zoran *zr)
{
u32 reg;