2 * Driver for the Conexant CX23885 PCIe bridge
4 * Copyright (c) 2006 Steven Toth <stoth@hauppauge.com>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #include <linux/pci.h>
23 #include <linux/i2c.h>
24 #include <linux/i2c-algo-bit.h>
25 #include <linux/kdev_t.h>
27 #include <media/v4l2-common.h>
28 #include <media/tuner.h>
29 #include <media/tveeprom.h>
30 #include <media/video-buf.h>
31 #if defined(CONFIG_VIDEO_BUF_DVB) || defined(CONFIG_VIDEO_BUF_DVB_MODULE)
32 #include <media/video-buf-dvb.h>
35 #include "btcx-risc.h"
36 #include "cx23885-reg.h"
38 #include <linux/version.h>
39 #include <linux/mutex.h>
41 #define CX88_VERSION_CODE KERNEL_VERSION(0,0,6)
45 #define CX23885_MAXBOARDS 8
47 /* Max number of inputs by card */
48 #define MAX_CX23885_INPUT 8
50 //#define SHADOW_MAX 3
52 #define BUFFER_TIMEOUT (HZ) /* 0.5 seconds */
54 #define CX23885_BOARD_NOAUTO UNSET
55 #define CX23885_BOARD_UNKNOWN 0
56 #define CX23885_BOARD_HAUPPAUGE_HVR1800lp 1
57 #define CX23885_BOARD_HAUPPAUGE_HVR1800 2
60 CX23885_VMUX_COMPOSITE1 = 1,
61 CX23885_VMUX_COMPOSITE2,
62 CX23885_VMUX_COMPOSITE3,
63 CX23885_VMUX_COMPOSITE4,
65 CX23885_VMUX_TELEVISION,
74 u32 fourcc; /* v4l2 format id */
80 /* buffer for one video frame */
81 struct cx23885_buffer {
82 /* common v4l buffer stuff -- must be first */
83 struct videobuf_buffer vb;
85 /* cx23885 specific */
87 struct btcx_riscmem risc;
88 struct cx23885_fmt *fmt;
92 struct cx23885_input {
93 enum cx23885_itype type;
95 u32 gpio0, gpio1, gpio2, gpio3;
98 struct cx23885_board {
101 CX23885_MPEG_UNDEFINED = 0,
105 CX23885_BRIDGE_UNDEFINED = 0,
106 CX23885_BRIDGE_885 = 885,
107 CX23885_BRIDGE_887 = 887,
109 struct cx23885_input input[MAX_CX23885_INPUT];
112 struct cx23885_subid {
119 struct cx23885_dev *dev;
124 struct i2c_adapter i2c_adap;
125 struct i2c_algo_bit_data i2c_algo;
126 struct i2c_client i2c_client;
129 /* 885 registers used for raw addess */
138 struct cx23885_dmaqueue {
139 struct list_head active;
140 struct list_head queued;
141 struct timer_list timeout;
142 struct btcx_riscmem stopper;
146 struct cx23885_tsport {
147 struct cx23885_dev *dev;
152 struct videobuf_dvb dvb;
155 struct cx23885_dmaqueue mpegq;
171 u32 reg_bd_pkt_status;
173 u32 reg_fifo_ovfl_stat;
178 /* Default register vals */
187 struct list_head devlist;
192 unsigned char pci_rev, pci_lat;
193 int pci_bus, pci_slot;
196 //u32 shadow[SHADOW_MAX];
199 /* I2C adapters: Master 1 and 2 (External) and Master 3 (Internal only) */
200 struct cx23885_i2c i2c_bus[3];
209 struct cx23885_tsport ts2;
211 /* sram configuration */
212 struct sram_channel *sram_channels;
215 #define SRAM_CH01 0 /* Video A */
216 #define SRAM_CH02 1 /* VBI A */
217 #define SRAM_CH03 2 /* Video B */
218 #define SRAM_CH04 3 /* Transport via B */
219 #define SRAM_CH05 4 /* VBI B */
220 #define SRAM_CH06 5 /* Video C */
221 #define SRAM_CH07 6 /* Transport via C */
222 #define SRAM_CH08 7 /* Audio Internal A */
223 #define SRAM_CH09 8 /* Audio Internal B */
224 #define SRAM_CH10 9 /* Audio External */
225 #define SRAM_CH11 10 /* COMB_3D_N */
226 #define SRAM_CH12 11 /* Comb 3D N1 */
227 #define SRAM_CH13 12 /* Comb 3D N2 */
228 #define SRAM_CH14 13 /* MOE Vid */
229 #define SRAM_CH15 14 /* MOE RSLT */
231 struct sram_channel {
245 /* ----------------------------------------------------------- */
247 #define cx_read(reg) readl(dev->lmmio + ((reg)>>2))
248 #define cx_write(reg,value) writel((value), dev->lmmio + ((reg)>>2))
250 #define cx_andor(reg,mask,value) \
251 writel((readl(dev->lmmio+((reg)>>2)) & ~(mask)) |\
252 ((value) & (mask)), dev->lmmio+((reg)>>2))
254 #define cx_set(reg,bit) cx_andor((reg),(bit),(bit))
255 #define cx_clear(reg,bit) cx_andor((reg),(bit),0)
258 extern int cx23885_sram_channel_setup(struct cx23885_dev *dev,
259 struct sram_channel *ch,
260 unsigned int bpl, u32 risc);
262 /* ----------------------------------------------------------- */
263 /* cx23885-cards.c */
265 extern struct cx23885_board cx23885_boards[];
266 extern const unsigned int cx23885_bcount;
268 extern struct cx23885_subid cx23885_subids[];
269 extern const unsigned int cx23885_idcount;
271 extern void cx23885_card_list(struct cx23885_dev *dev);
272 extern void cx23885_card_setup(struct cx23885_dev *dev);
273 extern void cx23885_card_setup_pre_i2c(struct cx23885_dev *dev);
275 extern int cx23885_dvb_register(struct cx23885_tsport *port);
276 extern int cx23885_dvb_unregister(struct cx23885_tsport *port);
278 extern int cx23885_buf_prepare(struct videobuf_queue *q, struct cx23885_tsport *port,
279 struct cx23885_buffer *buf, enum v4l2_field field);
281 extern void cx23885_buf_queue(struct cx23885_tsport *port, struct cx23885_buffer *buf);
282 extern void cx23885_free_buffer(struct videobuf_queue *q, struct cx23885_buffer *buf);
284 /* ----------------------------------------------------------- */
286 extern int cx23885_i2c_register(struct cx23885_i2c *bus);
287 extern int cx23885_i2c_unregister(struct cx23885_i2c *bus);
288 extern void cx23885_call_i2c_clients(struct cx23885_i2c *bus, unsigned int cmd, void *arg);
294 * kate: eol "unix"; indent-width 3; remove-trailing-space on; replace-trailing-space-save on; tab-width 8; replace-tabs off; space-indent off; mixed-indent off