Merge master.kernel.org:/pub/scm/linux/kernel/git/wim/linux-2.6-watchdog
[linux-block.git] / drivers / media / video / saa5249.c
CommitLineData
1da177e4
LT
1/*
2 * Modified in order to keep it compatible both with new and old videotext IOCTLs by
3 * Michael Geng <linux@MichaelGeng.de>
4 *
5 * Cleaned up to use existing videodev interface and allow the idea
6 * of multiple teletext decoders on the video4linux iface. Changed i2c
7 * to cover addressing clashes on device busses. It's also rebuilt so
8 * you can add arbitary multiple teletext devices to Linux video4linux
9 * now (well 32 anyway).
10 *
11 * Alan Cox <Alan.Cox@linux.org>
12 *
13 * The original driver was heavily modified to match the i2c interface
14 * It was truncated to use the WinTV boards, too.
15 *
16 * Copyright (c) 1998 Richard Guenther <richard.guenther@student.uni-tuebingen.de>
17 *
18 * $Id: saa5249.c,v 1.1 1998/03/30 22:23:23 alan Exp $
19 *
20 * Derived From
21 *
22 * vtx.c:
23 * This is a loadable character-device-driver for videotext-interfaces
24 * (aka teletext). Please check the Makefile/README for a list of supported
25 * interfaces.
26 *
27 * Copyright (c) 1994-97 Martin Buck <martin-2.buck@student.uni-ulm.de>
28 *
29 *
30 * This program is free software; you can redistribute it and/or modify
31 * it under the terms of the GNU General Public License as published by
32 * the Free Software Foundation; either version 2 of the License, or
33 * (at your option) any later version.
34 *
35 * This program is distributed in the hope that it will be useful,
36 * but WITHOUT ANY WARRANTY; without even the implied warranty of
37 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
38 * GNU General Public License for more details.
39 *
40 * You should have received a copy of the GNU General Public License
41 * along with this program; if not, write to the Free Software
42 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
43 * USA.
44 */
45
46#include <linux/module.h>
47#include <linux/kernel.h>
48#include <linux/sched.h>
49#include <linux/mm.h>
50#include <linux/errno.h>
51#include <linux/delay.h>
52#include <linux/ioport.h>
53#include <linux/slab.h>
54#include <linux/init.h>
55#include <stdarg.h>
56#include <linux/i2c.h>
57#include <linux/videotext.h>
58#include <linux/videodev.h>
5e87efa3 59#include <media/v4l2-common.h>
3593cab5
IM
60#include <linux/mutex.h>
61
1da177e4
LT
62
63#include <asm/io.h>
64#include <asm/uaccess.h>
65
66#define VTX_VER_MAJ 1
67#define VTX_VER_MIN 8
68
69
70
71#define NUM_DAUS 4
72#define NUM_BUFS 8
73#define IF_NAME "SAA5249"
74
d56410e0 75static const int disp_modes[8][3] =
1da177e4
LT
76{
77 { 0x46, 0x03, 0x03 }, /* DISPOFF */
78 { 0x46, 0xcc, 0xcc }, /* DISPNORM */
79 { 0x44, 0x0f, 0x0f }, /* DISPTRANS */
80 { 0x46, 0xcc, 0x46 }, /* DISPINS */
81 { 0x44, 0x03, 0x03 }, /* DISPOFF, interlaced */
82 { 0x44, 0xcc, 0xcc }, /* DISPNORM, interlaced */
83 { 0x44, 0x0f, 0x0f }, /* DISPTRANS, interlaced */
84 { 0x44, 0xcc, 0x46 } /* DISPINS, interlaced */
85};
86
87
88
89#define PAGE_WAIT (300*HZ/1000) /* Time between requesting page and */
90 /* checking status bits */
91#define PGBUF_EXPIRE (15*HZ) /* Time to wait before retransmitting */
92 /* page regardless of infobits */
93typedef struct {
94 u8 pgbuf[VTX_VIRTUALSIZE]; /* Page-buffer */
95 u8 laststat[10]; /* Last value of infobits for DAU */
96 u8 sregs[7]; /* Page-request registers */
97 unsigned long expire; /* Time when page will be expired */
98 unsigned clrfound : 1; /* VTXIOCCLRFOUND has been called */
99 unsigned stopped : 1; /* VTXIOCSTOPDAU has been called */
100} vdau_t;
101
102struct saa5249_device
103{
104 vdau_t vdau[NUM_DAUS]; /* Data for virtual DAUs (the 5249 only has one */
105 /* real DAU, so we have to simulate some more) */
106 int vtx_use_count;
107 int is_searching[NUM_DAUS];
108 int disp_mode;
109 int virtual_mode;
110 struct i2c_client *client;
3593cab5 111 struct mutex lock;
1da177e4
LT
112};
113
114
115