patch-2.4.19 linux-2.4.19/drivers/media/video/planb.h

Next file: linux-2.4.19/drivers/media/video/pms.c
Previous file: linux-2.4.19/drivers/media/video/planb.c
Back to the patch index
Back to the overall index

diff -urN linux-2.4.18/drivers/media/video/planb.h linux-2.4.19/drivers/media/video/planb.h
@@ -1,14 +1,16 @@
 /* 
-    planb - PlanB frame grabber driver
+    planb - v4l-compatible frame grabber driver for the PlanB hardware
 
     PlanB is used in the 7x00/8x00 series of PowerMacintosh
     Computers as video input DMA controller.
 
-    Copyright (C) 1998 Michel Lanners (mlan@cpu.lu)
+    Copyright (C) 1998 - 2002  Michel Lanners <mailto:mlan@cpu.lu>
 
-    Based largely on the bttv driver by Ralph Metzler (rjkm@thp.uni-koeln.de)
+    Based largely on the old bttv driver by Ralph Metzler
 
-    Additional debugging and coding by Takashi Oe (toe@unlserve.unl.edu)
+    Additional debugging and coding by Takashi Oe <mailto:toe@unlserve.unl.edu>
+
+    For more information, see <http://www.cpu.lu/~mlan/planb.html>
 
 
     This program is free software; you can redistribute it and/or modify
@@ -26,18 +28,17 @@
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
-/* $Id: planb.h,v 1.13 1999/05/03 19:28:56 mlan Exp $ */
+/* $Id: planb.h,v 2.9 2002/04/03 15:57:57 mlan Exp mlan $ */
 
 #ifndef _PLANB_H_
 #define _PLANB_H_
 
-#ifdef __KERNEL__
-#include <asm/dbdma.h>
-#include "saa7196.h"
-#endif /* __KERNEL__ */
-
 #define PLANB_DEVICE_NAME	"Apple PlanB Video-In"
-#define PLANB_REV		"1.0"
+#define PLANB_VBI_NAME		"Apple PlanB VBI"
+#define PLANB_REV		"2.11"
+
+#define APPLE_VENDOR_ID		0x106b
+#define PLANB_DEV_ID		0x0004
 
 #ifdef __KERNEL__
 //#define PLANB_GSCANLINE	/* use this if apps have the notion of */
@@ -47,15 +48,24 @@
 #define PLANB_MAXLINES 576
 #define PLANB_NTSC_MAXLINES 480
 
+/* Max VBI data buffer size */
+#define VBI_LINESIZE 1024	/* on SAA7196, a line can be max. 1024 pixels */
+#define VBI_START 7		/* VBI starts at line 7 */
+#define VBI_MAXLINES 16		/* 16 lines per field */
+/* We have 2 of these, but return them one at a time */
+#define VBIBUF_SIZE (VBI_LINESIZE * VBI_MAXLINES)
+
+#define LINE_OFFSET 1		/* between line 1 and SAA's first valid line */
+
 /* Uncomment your preferred norm ;-) */
 #define PLANB_DEF_NORM VIDEO_MODE_PAL
 //#define PLANB_DEF_NORM VIDEO_MODE_NTSC
 //#define PLANB_DEF_NORM VIDEO_MODE_SECAM
 
 /* fields settings */
-#define PLANB_GRAY	0x1	/*  8-bit mono? */
-#define PLANB_COLOUR15	0x2	/* 16-bit mode */
-#define PLANB_COLOUR32	0x4	/* 32-bit mode */
+#define PLANB_SIZE8	0x1	/*  8-bit mono? */
+#define PLANB_SIZE16	0x2	/* 16-bit mode */
+#define PLANB_SIZE32	0x4	/* 32-bit mode */
 #define PLANB_CLIPMASK	0x8	/* hardware clipmasking */
 
 /* misc. flags for PlanB DMA operation */
@@ -67,6 +77,41 @@
 #define DMA_ABORT	0x2	/* error or just out of sync if set */
 #define ODD_FIELD	0x4	/* odd field is detected if set */
 
+/* format info and correspondance */
+struct fmts {
+	int	bpp;		/* bytes per pixel */
+	int	pb_fmt;		/* planb format (DMA engine sub 0x40/0x44 ) */
+	int	saa_fmt;	/* saa format:				bit
+				   SAA7196 sub 0x20: bits FS0		0
+				   			  FS1		1
+					   sub 0x30: bit  MCT		4
+							  LLV		5 */
+};
+
+/* This is supposed to match the VIDEO_PALETTE_* defines in
+ * struct video_picture in videodev.h */
+static struct fmts palette2fmt[] = {
+	{ 0, 0,			   0 },
+	{ 1, PLANB_SIZE8,	0x33 },	/* VIDEO_PALETTE_GREY */
+	{ 0, 0,			   0 },
+	{ 0, 0,			   0 },
+	{ 0, 0,			   0 },
+	{ 4, PLANB_SIZE32,	   2 },	/* VIDEO_PALETTE_RGB32 */
+	{ 2, PLANB_SIZE16,	   0 },	/* VIDEO_PALETTE_RGB555 */
+	{ 2, PLANB_SIZE16,	0x21 },	/* VIDEO_PALETTE_YUV422 */
+	{ 0, 0,			   0 },
+	{ 0, 0,			   0 },
+	{ 0, 0,			   0 },
+	{ 0, 0,			   0 },
+	{ 0, 0,			   0 },
+	{ 0, 0,			   0 },
+	{ 0, 0,			   0 },
+	{ 0, 0,			   0 },
+	{ 0, 0,			   0 },
+};
+
+#define PLANB_PALETTE_MAX (sizeof palette2fmt / sizeof (struct fmts))
+
 /* for capture operations */
 #define MAX_GBUFFERS	2
 /* note PLANB_MAX_FBUF must be divisible by PAGE_SIZE */
@@ -87,6 +132,10 @@
 struct planb_stat_regs {
 	unsigned int ch1_stat;
 	unsigned int ch2_stat;
+	unsigned long ch1_cmdbase;
+	unsigned long ch2_cmdbase;
+	unsigned int ch1_cmdptr;
+	unsigned int ch2_cmdptr;
 	unsigned char saa_stat0;
 	unsigned char saa_stat1;
 };
@@ -97,23 +146,43 @@
 	unsigned char data[128];
 };
 
+struct planb_buf_regs {
+	unsigned int start;
+	unsigned int end;
+};
+
 /* planb private ioctls */
-#define PLANBIOCGSAAREGS	_IOWR('v', BASE_VIDIOCPRIVATE, struct planb_saa_regs)	/* Read a saa7196 reg value */
-#define PLANBIOCSSAAREGS	_IOW('v', BASE_VIDIOCPRIVATE + 1, struct planb_saa_regs)	/* Set a saa7196 reg value */
-#define PLANBIOCGSTAT		_IOR('v', BASE_VIDIOCPRIVATE + 2, struct planb_stat_regs)	/* Read planb status */
+/* Read a saa7196 reg value */
+#define PLANBIOCGSAAREGS	_IOWR('v', BASE_VIDIOCPRIVATE, struct planb_saa_regs)
+/* Set a saa7196 reg value */
+#define PLANBIOCSSAAREGS	_IOW('v', BASE_VIDIOCPRIVATE + 1, struct planb_saa_regs)
+/* Read planb status */
+#define PLANBIOCGSTAT		_IOR('v', BASE_VIDIOCPRIVATE + 2, struct planb_stat_regs)
+/* Get TV/VTR mode */
 #define PLANB_TV_MODE		1
 #define PLANB_VTR_MODE		2
-#define PLANBIOCGMODE		_IOR('v', BASE_VIDIOCPRIVATE + 3, int)	/* Get TV/VTR mode */
-#define PLANBIOCSMODE		_IOW('v', BASE_VIDIOCPRIVATE + 4, int)	/* Set TV/VTR mode */
+#define PLANBIOCGMODE		_IOR('v', BASE_VIDIOCPRIVATE + 3, int)
+/* Set TV/VTR mode */
+#define PLANBIOCSMODE		_IOW('v', BASE_VIDIOCPRIVATE + 4, int)
 
 #ifdef PLANB_GSCANLINE
-#define PLANBG_GRAB_BPL		_IOR('v', BASE_VIDIOCPRIVATE + 5, int)	/* # of bytes per scanline in grab buffer */
+/* # of bytes per scanline in grab buffer */
+#define PLANBG_GRAB_BPL		_IOR('v', BASE_VIDIOCPRIVATE + 5, int)
 #endif
 
+/* This doesn't really belong here, but until someone cleans up (or defines
+   in the first place ;-) the VBI API, it helps alevt... */
+#define BTTV_VBISIZE		_IOR('v', BASE_VIDIOCPRIVATE + 8, int)
+
+/* Various debugging IOCTLs */
+#ifdef DEBUG
 /* call wake_up_interruptible() with appropriate actions */
 #define PLANB_INTR_DEBUG	_IOW('v', BASE_VIDIOCPRIVATE + 20, int)
 /* investigate which reg does what */
 #define PLANB_INV_REGS		_IOWR('v', BASE_VIDIOCPRIVATE + 21, struct planb_any_regs)
+/* Dump DBDMA command buffer from (int) to (int) */
+#define PLANBIOCGDBDMABUF	_IOW('v', BASE_VIDIOCPRIVATE + 22, struct planb_buf_regs)
+#endif /* DEBUG */
 
 #ifdef __KERNEL__
 
@@ -121,27 +190,44 @@
 #define PLANB_SET(x)	((x) << 16 | (x))
 #define PLANB_CLR(x)	((x) << 16)
 
-/* This represents the physical register layout */
-struct planb_registers {
-	volatile struct dbdma_regs	ch1;		/* 0x00: video in */
-	volatile unsigned int		even;		/* 0x40: even field setting */
-	volatile unsigned int		odd;		/* 0x44; odd field setting */
-	unsigned int			pad1[14];	/* empty? */
-	volatile struct dbdma_regs	ch2;		/* 0x80: clipmask out */
-	unsigned int			pad2[16];	/* 0xc0: empty? */
-	volatile unsigned int		reg3;		/* 0x100: ???? */
-	volatile unsigned int		intr_stat;	/* 0x104: irq status */
+typedef volatile struct dbdma_cmd dbdma_cmd_t;
+typedef volatile struct dbdma_cmd *dbdma_cmd_ptr;
+typedef volatile struct dbdma_regs dbdma_regs_t;
+typedef volatile struct dbdma_regs *dbdma_regs_ptr;
+
+typedef struct gbuffer gbuf_t;
+typedef struct gbuffer *gbuf_ptr;
+
+/* grab buffer status */
+#define GBUFFER_UNUSED		0x00U
+#define GBUFFER_GRABBING	0x01U
+#define GBUFFER_DONE		0x02U
+
+/* planb interrupt status values (0x104: irq status) */
 #define PLANB_CLR_IRQ		0x00		/* clear Plan B interrupt */
 #define PLANB_GEN_IRQ		0x01		/* assert Plan B interrupt */
 #define PLANB_FRM_IRQ		0x0100		/* end of frame */
-	unsigned int			pad3[1];	/* empty? */
-	volatile unsigned int		reg5;		/* 0x10c: ??? */
-	unsigned int			pad4[60];	/* empty? */
-	volatile unsigned char		saa_addr;	/* 0x200: SAA subadr */
-	char				pad5[3];
-	volatile unsigned char		saa_regval;	/* SAA7196 write reg. val */
-	char				pad6[3];
-	volatile unsigned char		saa_status;	/* SAA7196 status byte */
+
+#define PLANB_DUMMY 40	/* # of command buf's allocated for pre-capture seq. */
+
+/* This represents the physical register layout */
+struct planb_registers {
+	dbdma_regs_t		ch1;		/* 0x00: video in */
+	volatile u32		even;		/* 0x40: even field setting */
+	volatile u32		odd;		/* 0x44; odd field setting */
+	u32			pad1[14];	/* empty? */
+	dbdma_regs_t		ch2;		/* 0x80: clipmask out */
+	u32			pad2[16];	/* 0xc0: empty? */
+	volatile u32		reg3;		/* 0x100: ???? */
+	volatile u32		intr_stat;	/* 0x104: irq status */
+	u32			pad3[1];	/* empty? */
+	volatile u32		reg5;		/* 0x10c: ??? */
+	u32			pad4[60];	/* empty? */
+	volatile u8		saa_addr;	/* 0x200: SAA subadr */
+	u8			pad5[3];
+	volatile u8		saa_regval;	/* SAA7196 write reg. val */
+	u8			pad6[3];
+	volatile u8		saa_status;	/* SAA7196 status byte */
 	/* There is more unused stuff here */
 };
 
@@ -163,67 +249,105 @@
 	struct dbdma_cmd cmd;
 };
 
+/* Framebuffer info */
+struct planb_fb {
+	unsigned long	phys;		/* Framebuffer phys. base address */
+	int		offset;		/* offset of pixel 1 */
+};
+
+/* DBDMA command buffer descriptor */
+struct dbdma_cmd_buf {
+	dbdma_cmd_ptr	start;
+	dbdma_cmd_ptr	jumpaddr;	/* where are we called from? */
+	unsigned int	size;
+	unsigned long	bus;		/* start address as seen from the bus */
+};
+
+/* grab buffer descriptor */
+struct gbuffer {
+	dbdma_cmd_ptr		cap_cmd;
+	dbdma_cmd_ptr		last_cmd;
+	dbdma_cmd_ptr		pre_cmd;
+	int			idx;
+	int			need_pre_capture;
+	int			width;
+	int			height;
+	unsigned int		fmt;
+	int			norm_switch;
+#ifndef PLANB_GSCANLINE
+	int			l_fr_addr_idx;
+	int			lsize;
+	int			lnum;
+#endif
+        volatile unsigned int	*status;	/* ptr to status value */
+};
+
 struct planb {
-	struct	video_device video_dev;
-	struct	video_picture picture;		/* Current picture params */
-	struct	video_audio audio_dev;		/* Current audio params */
+/* the video device: */
+	struct video_device	video_dev;
+	struct video_picture	picture;	/* Current picture params */
+	int			vid_user;	/* Users on video device */
+	void			*vid_raw;	/* Org. alloc. mem for kfree */
+	struct dbdma_cmd_buf	vid_cbo;	/* odd video dbdma cmd buf */
+	struct dbdma_cmd_buf	vid_cbe;	/* even */
+	void			*clip_raw;
+	struct dbdma_cmd_buf	clip_cbo;	/* odd clip dbdma cmd buf */
+	struct dbdma_cmd_buf	clip_cbe;	/* even */
+	dbdma_cmd_ptr		overlay_last1;
+	dbdma_cmd_ptr		overlay_last2;
   
-	volatile struct planb_registers *planb_base;	/* virt base of planb */
-	struct planb_registers *planb_base_phys;	/* phys base of planb */
-	void	*priv_space;			/* Org. alloc. mem for kfree */
-	int	user;
-	unsigned int tab_size;
-	int     maxlines;
-	struct semaphore lock;
-	unsigned int	irq;			/* interrupt number */
-	volatile unsigned int intr_mask;
-
-	int	overlay;			/* overlay running? */
-	struct	planb_window win;
-	unsigned long frame_buffer_phys;	/* We need phys for DMA */
-	int	offset;				/* offset of pixel 1 */
-	volatile struct dbdma_cmd *ch1_cmd;	/* Video In DMA cmd buffer */
-	volatile struct dbdma_cmd *ch2_cmd;	/* Clip Out DMA cmd buffer */
-	volatile struct dbdma_cmd *overlay_last1;
-	volatile struct dbdma_cmd *overlay_last2;
-	unsigned long ch1_cmd_phys;
-	volatile unsigned char *mask;		/* Clipmask buffer */
-	int suspend;
-	wait_queue_head_t suspendq;
-	struct planb_suspend suspended;
-	int	cmd_buff_inited;		/* cmd buffer inited? */
-
-	int grabbing;
-	unsigned int gcount;
-	wait_queue_head_t capq;
-	int last_fr;
-	int prev_last_fr;
-	unsigned char **rawbuf;
-	int rawbuf_size;
-	int gbuf_idx[MAX_GBUFFERS];
-	volatile struct dbdma_cmd *cap_cmd[MAX_GBUFFERS];
-	volatile struct dbdma_cmd *last_cmd[MAX_GBUFFERS];
-	volatile struct dbdma_cmd *pre_cmd[MAX_GBUFFERS];
-	int need_pre_capture[MAX_GBUFFERS];
-#define PLANB_DUMMY 40	/* # of command buf's allocated for pre-capture seq. */
-	int gwidth[MAX_GBUFFERS], gheight[MAX_GBUFFERS];
-	unsigned int gfmt[MAX_GBUFFERS];
-	int gnorm_switch[MAX_GBUFFERS];
-        volatile unsigned int *frame_stat;
-#define GBUFFER_UNUSED       0x00U
-#define GBUFFER_GRABBING     0x01U
-#define GBUFFER_DONE         0x02U
+/* the hardware: */
+	volatile struct planb_registers
+				*planb_base;	/* virt base of planb */
+	struct planb_registers	*planb_base_bus; /* phys base of planb */
+	unsigned int		tab_size;
+	int     		maxlines;
+	unsigned int		irq;		/* interrupt number */
+	volatile unsigned int	intr_mask;
+	struct planb_fb		fb;		/* Framebuffer info */
+
+/* generic stuff: */
+	void			*jump_raw;	/* jump buffer raw space */
+	dbdma_cmd_ptr		jumpbuf;	/* same, DBDMA_ALIGN'ed */
+	struct semaphore	lock;
+	int			overlay;	/* overlay running? */
+	struct planb_window	win;
+	volatile unsigned char	*mask;		/* Clipmask buffer */
+	int			suspend;
+	wait_queue_head_t	suspendq;
+	struct planb_suspend	suspended;
+	int			cmd_buff_inited; /* cmd buffer inited? */
+
+/* grabbing stuff: */ 
+	int			grabbing;
+	unsigned int		gcount;
+	wait_queue_head_t	capq;
+	int			last_fr;
+	int			prev_last_fr;
+	unsigned char		**rawbuf;
+	int			rawbuf_nchunks;
+	struct gbuffer		gbuf[MAX_GBUFFERS];
+
 #ifdef PLANB_GSCANLINE
-	int gbytes_per_line;
+	int			gbytes_per_line;
 #else
-#define MAX_LNUM 431	/* change this if PLANB_MAXLINES or */
+#define MAX_LNUM 576	/* change this if PLANB_MAXLINES or */
 			/* PLANB_MAXPIXELS changes */
-	int l_fr_addr_idx[MAX_GBUFFERS];
-	unsigned char *l_to_addr[MAX_GBUFFERS][MAX_LNUM];
-	int l_to_next_idx[MAX_GBUFFERS][MAX_LNUM];
-	int l_to_next_size[MAX_GBUFFERS][MAX_LNUM];
-	int lsize[MAX_GBUFFERS], lnum[MAX_GBUFFERS];
-#endif
+	unsigned char		*l_to_addr[MAX_GBUFFERS][MAX_LNUM];
+	int			l_to_next_idx[MAX_GBUFFERS][MAX_LNUM];
+	int			l_to_next_size[MAX_GBUFFERS][MAX_LNUM];
+#endif /* PLANB_GSCANLINE */
+
+/* VBI stuff: */
+	struct video_device	vbi_dev;	/* VBI data device */
+	int			vbi_user;	/* Users on vbi device */
+	void			*vbi_raw;
+	struct dbdma_cmd_buf	vbi_cbo;	/* odd VBI dbdma cmd buf */
+	struct dbdma_cmd_buf	vbi_cbe;	/* even */
+	int			vbirunning;
+	int			vbip;		/* pointer into VBI buffer */
+	unsigned char		*vbibuf;	/* buffer for VBI data */
+	wait_queue_head_t	vbiq;
 };
 
 #endif /* __KERNEL__ */

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)