V4L/DVB (8783): v4l: add all missing video_device release callbacks
[deliverable/linux.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>
d56dc612 55#include <linux/smp_lock.h>
1da177e4
LT
56#include <stdarg.h>
57#include <linux/i2c.h>
58#include <linux/videotext.h>
59#include <linux/videodev.h>
5e87efa3 60#include <media/v4l2-common.h>
35ea11ff 61#include <media/v4l2-ioctl.h>
3593cab5
IM
62#include <linux/mutex.h>
63
1da177e4
LT
64
65#include <asm/io.h>
66#include <asm/uaccess.h>
67
68#define VTX_VER_MAJ 1
69#define VTX_VER_MIN 8
70
71
72
73#define NUM_DAUS 4
74#define NUM_BUFS 8
75#define IF_NAME "SAA5249"
76
d56410e0 77static const int disp_modes[8][3] =
1da177e4
LT
78{
79 { 0x46, 0x03, 0x03 }, /* DISPOFF */
80 { 0x46, 0xcc, 0xcc }, /* DISPNORM */
81 { 0x44, 0x0f, 0x0f }, /* DISPTRANS */
82 { 0x46, 0xcc, 0x46 }, /* DISPINS */
83 { 0x44, 0x03, 0x03 }, /* DISPOFF, interlaced */
84 { 0x44, 0xcc, 0xcc }, /* DISPNORM, interlaced */
85 { 0x44, 0x0f, 0x0f }, /* DISPTRANS, interlaced */
86 { 0x44, 0xcc, 0x46 } /* DISPINS, interlaced */
87};
88
89
90
09df5cbe 91#define PAGE_WAIT msecs_to_jiffies(300) /* Time between requesting page and */
1da177e4 92 /* checking status bits */
09df5cbe 93#define PGBUF_EXPIRE msecs_to_jiffies(15000) /* Time to wait before retransmitting */
1da177e4
LT
94 /* page regardless of infobits */
95typedef struct {
96 u8 pgbuf[VTX_VIRTUALSIZE]; /* Page-buffer */
97 u8 laststat[10]; /* Last value of infobits for DAU */
98 u8 sregs[7]; /* Page-request registers */
99 unsigned long expire; /* Time when page will be expired */
100 unsigned clrfound : 1; /* VTXIOCCLRFOUND has been called */
101 unsigned stopped : 1; /* VTXIOCSTOPDAU has been called */
102} vdau_t;
103
104struct saa5249_device
105{
106 vdau_t vdau[NUM_DAUS]; /* Data for virtual DAUs (the 5249 only has one */
107 /* real DAU, so we have to simulate some more) */
108 int vtx_use_count;
109 int is_searching[NUM_DAUS];
110 int disp_mode;
111 int virtual_mode;
112 struct i2c_client *client;
7d43cd53 113 unsigned long in_use;
3593cab5 114 struct mutex lock;
1da177e4
LT
115};
116
117