blob: d81a08a2df4f3a8d808b8552d4fc189bc44394ce [file] [log] [blame]
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -03001/*
2 * Driver for the Conexant CX25821 PCIe bridge
3 *
Mauro Carvalho Chehabbb4c9a72009-09-13 11:25:45 -03004 * Copyright (C) 2009 Conexant Systems Inc.
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -03005 * Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com>
6 * Based on Steven Toth <stoth@linuxtv.org> cx23885 driver
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 *
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */
23
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -030024#ifndef CX25821_H_
25#define CX25821_H_
26
27#include <linux/pci.h>
28#include <linux/i2c.h>
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -030029#include <linux/interrupt.h>
30#include <linux/delay.h>
31#include <linux/sched.h>
32#include <linux/kdev_t.h>
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -030033
34#include <media/v4l2-common.h>
Mauro Carvalho Chehabbb4c9a72009-09-13 11:25:45 -030035#include <media/v4l2-device.h>
Hans Verkuilf8d7ee72013-04-13 08:38:14 -030036#include <media/v4l2-ctrls.h>
Hans Verkuilb671ae62014-12-12 10:27:58 -030037#include <media/videobuf2-dma-sg.h>
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -030038
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -030039#include "cx25821-reg.h"
40#include "cx25821-medusa-reg.h"
41#include "cx25821-sram.h"
42#include "cx25821-audio.h"
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -030043
44#include <linux/version.h>
45#include <linux/mutex.h>
46
47#define CX25821_VERSION_CODE KERNEL_VERSION(0, 0, 106)
48
49#define UNSET (-1U)
50#define NO_SYNC_LINE (-1U)
51
52#define CX25821_MAXBOARDS 2
53
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -030054#define LINE_SIZE_D1 1440
55
Palash Bandyopadhyay6d8c2ba2010-07-04 14:15:38 -030056/* Number of decoders and encoders */
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -030057#define MAX_DECODERS 8
58#define MAX_ENCODERS 2
59#define QUAD_DECODERS 4
60#define MAX_CAMERAS 16
61
62/* Max number of inputs by card */
Leonid V. Fedorenchikc7855ee2011-10-22 01:43:56 -030063#define MAX_CX25821_INPUT 8
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -030064#define RESOURCE_VIDEO0 1
65#define RESOURCE_VIDEO1 2
66#define RESOURCE_VIDEO2 4
67#define RESOURCE_VIDEO3 8
68#define RESOURCE_VIDEO4 16
69#define RESOURCE_VIDEO5 32
70#define RESOURCE_VIDEO6 64
71#define RESOURCE_VIDEO7 128
72#define RESOURCE_VIDEO8 256
73#define RESOURCE_VIDEO9 512
74#define RESOURCE_VIDEO10 1024
75#define RESOURCE_VIDEO11 2048
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -030076
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -030077#define BUFFER_TIMEOUT (HZ) /* 0.5 seconds */
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -030078
Leonid V. Fedorenchikc7855ee2011-10-22 01:43:56 -030079#define UNKNOWN_BOARD 0
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -030080#define CX25821_BOARD 1
81
Mauro Carvalho Chehabbb4c9a72009-09-13 11:25:45 -030082/* Currently supported by the driver */
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -030083#define CX25821_NORMS (\
Ruslan Pisareve4115bb2010-09-27 10:01:36 -030084 V4L2_STD_NTSC_M | V4L2_STD_NTSC_M_JP | V4L2_STD_NTSC_M_KR | \
85 V4L2_STD_PAL_BG | V4L2_STD_PAL_DK | V4L2_STD_PAL_I | \
86 V4L2_STD_PAL_M | V4L2_STD_PAL_N | V4L2_STD_PAL_H | \
87 V4L2_STD_PAL_Nc)
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -030088
89#define CX25821_BOARD_CONEXANT_ATHENA10 1
90#define MAX_VID_CHANNEL_NUM 12
Hans Verkuilb6f21dc2014-12-12 10:28:00 -030091
92/*
93 * Maximum capture-only channels. This can go away once video/audio output
94 * is fully supported in this driver.
95 */
96#define MAX_VID_CAP_CHANNEL_NUM 10
97
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -030098#define VID_CHANNEL_NUM 8
99
100struct cx25821_fmt {
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300101 char *name;
102 u32 fourcc; /* v4l2 format id */
103 int depth;
104 int flags;
105 u32 cxformat;
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300106};
107
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300108struct cx25821_tvnorm {
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300109 char *name;
110 v4l2_std_id id;
111 u32 cxiformat;
112 u32 cxoformat;
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300113};
114
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300115enum cx25821_src_sel_type {
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300116 CX25821_SRC_SEL_EXT_656_VIDEO = 0,
117 CX25821_SRC_SEL_PARALLEL_MPEG_VIDEO
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300118};
119
Hans Verkuil5ede94c2014-12-12 10:27:54 -0300120struct cx25821_riscmem {
121 unsigned int size;
122 __le32 *cpu;
123 __le32 *jmp;
124 dma_addr_t dma;
125};
126
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300127/* buffer for one video frame */
128struct cx25821_buffer {
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300129 /* common v4l buffer stuff -- must be first */
Hans Verkuilb671ae62014-12-12 10:27:58 -0300130 struct vb2_buffer vb;
131 struct list_head queue;
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300132
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300133 /* cx25821 specific */
134 unsigned int bpl;
Hans Verkuil5ede94c2014-12-12 10:27:54 -0300135 struct cx25821_riscmem risc;
Hans Verkuil95c232a2013-04-13 07:41:29 -0300136 const struct cx25821_fmt *fmt;
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300137};
138
Leonid V. Fedorenchik7ae70c82011-09-02 11:55:29 +0800139enum port {
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300140 CX25821_UNDEFINED = 0,
141 CX25821_RAW,
142 CX25821_264
Leonid V. Fedorenchik7ae70c82011-09-02 11:55:29 +0800143};
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300144
145struct cx25821_board {
Ezequiel Garcíac854d882012-07-18 13:41:11 -0300146 const char *name;
Leonid V. Fedorenchik7ae70c82011-09-02 11:55:29 +0800147 enum port porta;
148 enum port portb;
149 enum port portc;
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300150
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300151 u32 clk_freq;
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300152};
153
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300154struct cx25821_i2c {
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300155 struct cx25821_dev *dev;
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300156
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300157 int nr;
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300158
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300159 /* i2c i/o */
160 struct i2c_adapter i2c_adap;
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300161 struct i2c_client i2c_client;
162 u32 i2c_rc;
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300163
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300164 /* cx25821 registers used for raw addess */
165 u32 i2c_period;
166 u32 reg_ctrl;
167 u32 reg_stat;
168 u32 reg_addr;
169 u32 reg_rdata;
170 u32 reg_wdata;
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300171};
172
173struct cx25821_dmaqueue {
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300174 struct list_head active;
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300175 u32 count;
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300176};
177
Hans Verkuilf8d7ee72013-04-13 08:38:14 -0300178struct cx25821_dev;
179
Hans Verkuil7087d312013-04-14 12:10:32 -0300180struct cx25821_channel;
181
182struct cx25821_video_out_data {
183 struct cx25821_channel *chan;
184 int _line_size;
185 int _prog_cnt;
186 int _pixel_format;
187 int _is_first_frame;
188 int _is_running;
189 int _file_status;
190 int _lines_count;
191 int _frame_count;
192 unsigned int _risc_size;
193
194 __le32 *_dma_virt_start_addr;
195 __le32 *_dma_virt_addr;
196 dma_addr_t _dma_phys_addr;
197 dma_addr_t _dma_phys_start_addr;
198
199 unsigned int _data_buf_size;
200 __le32 *_data_buf_virt_addr;
201 dma_addr_t _data_buf_phys_addr;
202
203 u32 upstream_riscbuf_size;
204 u32 upstream_databuf_size;
Hans Verkuil7087d312013-04-14 12:10:32 -0300205 int is_60hz;
206 int _frame_index;
Hans Verkuilea3f7ac2013-04-14 12:02:19 -0300207 int cur_frame_index;
208 int curpos;
209 wait_queue_head_t waitq;
Hans Verkuil7087d312013-04-14 12:10:32 -0300210};
211
Palash Bandyopadhyay6d8c2ba2010-07-04 14:15:38 -0300212struct cx25821_channel {
Hans Verkuilf8d7ee72013-04-13 08:38:14 -0300213 unsigned id;
214 struct cx25821_dev *dev;
Palash Bandyopadhyay6d8c2ba2010-07-04 14:15:38 -0300215
Hans Verkuilf8d7ee72013-04-13 08:38:14 -0300216 struct v4l2_ctrl_handler hdl;
Palash Bandyopadhyay6d8c2ba2010-07-04 14:15:38 -0300217
Hans Verkuil467870c2013-04-13 08:18:00 -0300218 struct video_device vdev;
Hans Verkuil2efe2cc2013-04-13 10:00:52 -0300219 struct cx25821_dmaqueue dma_vidq;
Hans Verkuilb671ae62014-12-12 10:27:58 -0300220 struct vb2_queue vidq;
Palash Bandyopadhyay6d8c2ba2010-07-04 14:15:38 -0300221
Hans Verkuilbfef0d32013-04-13 06:28:54 -0300222 const struct sram_channel *sram_channels;
Palash Bandyopadhyay6d8c2ba2010-07-04 14:15:38 -0300223
Hans Verkuil2efe2cc2013-04-13 10:00:52 -0300224 const struct cx25821_fmt *fmt;
Hans Verkuilb671ae62014-12-12 10:27:58 -0300225 unsigned field;
Hans Verkuil2efe2cc2013-04-13 10:00:52 -0300226 unsigned int width, height;
Ruslan Pisareve4115bb2010-09-27 10:01:36 -0300227 int pixel_formats;
228 int use_cif_resolution;
229 int cif_width;
Hans Verkuil7087d312013-04-14 12:10:32 -0300230
231 /* video output data for the video output channel */
232 struct cx25821_video_out_data *out;
Palash Bandyopadhyay6d8c2ba2010-07-04 14:15:38 -0300233};
234
Hans Verkuila8f35ce2013-04-13 07:07:40 -0300235struct snd_card;
236
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300237struct cx25821_dev {
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300238 struct v4l2_device v4l2_dev;
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300239
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300240 /* pci stuff */
241 struct pci_dev *pci;
242 unsigned char pci_rev, pci_lat;
243 int pci_bus, pci_slot;
244 u32 base_io_addr;
245 u32 __iomem *lmmio;
246 u8 __iomem *bmmio;
247 int pci_irqmask;
248 int hwrevision;
Hans Verkuila8f35ce2013-04-13 07:07:40 -0300249 /* used by cx25821-alsa */
250 struct snd_card *card;
Hans Verkuilb671ae62014-12-12 10:27:58 -0300251 void *alloc_ctx;
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300252
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300253 u32 clk_freq;
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300254
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300255 /* I2C adapters: Master 1 & 2 (External) & Master 3 (Internal only) */
256 struct cx25821_i2c i2c_bus[3];
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300257
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300258 int nr;
259 struct mutex lock;
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300260
Ruslan Pisareve4115bb2010-09-27 10:01:36 -0300261 struct cx25821_channel channels[MAX_VID_CHANNEL_NUM];
Palash Bandyopadhyay6d8c2ba2010-07-04 14:15:38 -0300262
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300263 /* board details */
264 unsigned int board;
265 char name[32];
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300266
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300267 /* Analog video */
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300268 unsigned int input;
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300269 v4l2_std_id tvnorm;
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300270 unsigned short _max_num_decoders;
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300271
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300272 /* Analog Audio Upstream */
273 int _audio_is_running;
274 int _audiopixel_format;
275 int _is_first_audio_frame;
276 int _audiofile_status;
277 int _audio_lines_count;
278 int _audioframe_count;
Leonid V. Fedorenchik6100c572011-09-02 11:55:30 +0800279 int _audio_upstream_channel;
Ruslan Pisareve4115bb2010-09-27 10:01:36 -0300280 int _last_index_irq; /* The last interrupt index processed. */
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300281
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300282 __le32 *_risc_audio_jmp_addr;
283 __le32 *_risc_virt_start_addr;
284 __le32 *_risc_virt_addr;
285 dma_addr_t _risc_phys_addr;
286 dma_addr_t _risc_phys_start_addr;
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300287
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300288 unsigned int _audiorisc_size;
289 unsigned int _audiodata_buf_size;
290 __le32 *_audiodata_buf_virt_addr;
291 dma_addr_t _audiodata_buf_phys_addr;
292 char *_audiofilename;
Hans Verkuil7087d312013-04-14 12:10:32 -0300293 u32 audio_upstream_riscbuf_size;
294 u32 audio_upstream_databuf_size;
295 int _audioframe_index;
296 struct workqueue_struct *_irq_audio_queues;
297 struct work_struct _audio_work_entry;
298 char *input_audiofilename;
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300299
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300300 /* V4l */
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300301 spinlock_t slock;
Mauro Carvalho Chehabbb4c9a72009-09-13 11:25:45 -0300302
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300303 /* Video Upstream */
Hans Verkuil7087d312013-04-14 12:10:32 -0300304 struct cx25821_video_out_data vid_out_data[2];
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300305};
306
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300307static inline struct cx25821_dev *get_cx25821(struct v4l2_device *v4l2_dev)
308{
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300309 return container_of(v4l2_dev, struct cx25821_dev, v4l2_dev);
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300310}
311
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300312extern struct cx25821_board cx25821_boards[];
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300313
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300314#define SRAM_CH00 0 /* Video A */
315#define SRAM_CH01 1 /* Video B */
316#define SRAM_CH02 2 /* Video C */
317#define SRAM_CH03 3 /* Video D */
318#define SRAM_CH04 4 /* Video E */
319#define SRAM_CH05 5 /* Video F */
320#define SRAM_CH06 6 /* Video G */
321#define SRAM_CH07 7 /* Video H */
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300322
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300323#define SRAM_CH08 8 /* Audio A */
324#define SRAM_CH09 9 /* Video Upstream I */
325#define SRAM_CH10 10 /* Video Upstream J */
326#define SRAM_CH11 11 /* Audio Upstream AUD_CHANNEL_B */
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300327
328#define VID_UPSTREAM_SRAM_CHANNEL_I SRAM_CH09
329#define VID_UPSTREAM_SRAM_CHANNEL_J SRAM_CH10
330#define AUDIO_UPSTREAM_SRAM_CHANNEL_B SRAM_CH11
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300331
332struct sram_channel {
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300333 char *name;
334 u32 i;
335 u32 cmds_start;
336 u32 ctrl_start;
337 u32 cdt;
338 u32 fifo_start;
339 u32 fifo_size;
340 u32 ptr1_reg;
341 u32 ptr2_reg;
342 u32 cnt1_reg;
343 u32 cnt2_reg;
344 u32 int_msk;
345 u32 int_stat;
346 u32 int_mstat;
347 u32 dma_ctl;
348 u32 gpcnt_ctl;
349 u32 gpcnt;
350 u32 aud_length;
351 u32 aud_cfg;
352 u32 fld_aud_fifo_en;
353 u32 fld_aud_risc_en;
Mauro Carvalho Chehabbb4c9a72009-09-13 11:25:45 -0300354
Ruslan Pisareve4115bb2010-09-27 10:01:36 -0300355 /* For Upstream Video */
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300356 u32 vid_fmt_ctl;
357 u32 vid_active_ctl1;
358 u32 vid_active_ctl2;
359 u32 vid_cdt_size;
Mauro Carvalho Chehabbb4c9a72009-09-13 11:25:45 -0300360
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300361 u32 vip_ctl;
362 u32 pix_frmt;
363 u32 jumponly;
364 u32 irq_bit;
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300365};
Hans Verkuilbfef0d32013-04-13 06:28:54 -0300366
367extern const struct sram_channel cx25821_sram_channels[];
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300368
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300369#define cx_read(reg) readl(dev->lmmio + ((reg)>>2))
370#define cx_write(reg, value) writel((value), dev->lmmio + ((reg)>>2))
371
372#define cx_andor(reg, mask, value) \
Ruslan Pisareve4115bb2010-09-27 10:01:36 -0300373 writel((readl(dev->lmmio+((reg)>>2)) & ~(mask)) |\
374 ((value) & (mask)), dev->lmmio+((reg)>>2))
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300375
376#define cx_set(reg, bit) cx_andor((reg), (bit), (bit))
377#define cx_clear(reg, bit) cx_andor((reg), (bit), 0)
378
379#define Set_GPIO_Bit(Bit) (1 << Bit)
380#define Clear_GPIO_Bit(Bit) (~(1 << Bit))
381
Joe Perches36d89f72010-11-07 17:48:21 -0300382#define CX25821_ERR(fmt, args...) \
383 pr_err("(%d): " fmt, dev->board, ##args)
384#define CX25821_WARN(fmt, args...) \
385 pr_warn("(%d): " fmt, dev->board, ##args)
386#define CX25821_INFO(fmt, args...) \
387 pr_info("(%d): " fmt, dev->board, ##args)
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300388
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300389extern int cx25821_i2c_register(struct cx25821_i2c *bus);
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300390extern int cx25821_i2c_read(struct cx25821_i2c *bus, u16 reg_addr, int *value);
391extern int cx25821_i2c_write(struct cx25821_i2c *bus, u16 reg_addr, int value);
392extern int cx25821_i2c_unregister(struct cx25821_i2c *bus);
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300393extern void cx25821_gpio_init(struct cx25821_dev *dev);
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300394extern void cx25821_set_gpiopin_direction(struct cx25821_dev *dev,
395 int pin_number, int pin_logic_value);
Mauro Carvalho Chehabbb4c9a72009-09-13 11:25:45 -0300396
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300397extern int medusa_video_init(struct cx25821_dev *dev);
398extern int medusa_set_videostandard(struct cx25821_dev *dev);
399extern void medusa_set_resolution(struct cx25821_dev *dev, int width,
400 int decoder_select);
401extern int medusa_set_brightness(struct cx25821_dev *dev, int brightness,
402 int decoder);
403extern int medusa_set_contrast(struct cx25821_dev *dev, int contrast,
404 int decoder);
405extern int medusa_set_hue(struct cx25821_dev *dev, int hue, int decoder);
406extern int medusa_set_saturation(struct cx25821_dev *dev, int saturation,
407 int decoder);
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300408
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300409extern int cx25821_sram_channel_setup(struct cx25821_dev *dev,
Hans Verkuilbfef0d32013-04-13 06:28:54 -0300410 const struct sram_channel *ch, unsigned int bpl,
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300411 u32 risc);
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300412
Hans Verkuil5ede94c2014-12-12 10:27:54 -0300413extern int cx25821_riscmem_alloc(struct pci_dev *pci,
414 struct cx25821_riscmem *risc,
415 unsigned int size);
416extern int cx25821_risc_buffer(struct pci_dev *pci, struct cx25821_riscmem *risc,
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300417 struct scatterlist *sglist,
418 unsigned int top_offset,
419 unsigned int bottom_offset,
420 unsigned int bpl,
421 unsigned int padding, unsigned int lines);
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300422extern int cx25821_risc_databuffer_audio(struct pci_dev *pci,
Hans Verkuil5ede94c2014-12-12 10:27:54 -0300423 struct cx25821_riscmem *risc,
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300424 struct scatterlist *sglist,
425 unsigned int bpl,
426 unsigned int lines, unsigned int lpi);
Hans Verkuilb671ae62014-12-12 10:27:58 -0300427extern void cx25821_free_buffer(struct cx25821_dev *dev,
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300428 struct cx25821_buffer *buf);
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300429extern void cx25821_sram_channel_dump(struct cx25821_dev *dev,
Hans Verkuilbfef0d32013-04-13 06:28:54 -0300430 const struct sram_channel *ch);
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300431extern void cx25821_sram_channel_dump_audio(struct cx25821_dev *dev,
Hans Verkuilbfef0d32013-04-13 06:28:54 -0300432 const struct sram_channel *ch);
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300433
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300434extern struct cx25821_dev *cx25821_dev_get(struct pci_dev *pci);
435extern void cx25821_print_irqbits(char *name, char *tag, char **strings,
436 int len, u32 bits, u32 mask);
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300437extern void cx25821_dev_unregister(struct cx25821_dev *dev);
438extern int cx25821_sram_channel_setup_audio(struct cx25821_dev *dev,
Hans Verkuilbfef0d32013-04-13 06:28:54 -0300439 const struct sram_channel *ch,
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300440 unsigned int bpl, u32 risc);
Mauro Carvalho Chehabbb4c9a72009-09-13 11:25:45 -0300441
Hans Verkuil7087d312013-04-14 12:10:32 -0300442extern int cx25821_vidupstream_init(struct cx25821_channel *chan, int pixel_format);
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300443extern int cx25821_audio_upstream_init(struct cx25821_dev *dev,
444 int channel_select);
Hans Verkuilea3f7ac2013-04-14 12:02:19 -0300445extern int cx25821_write_frame(struct cx25821_channel *chan,
446 const char __user *data, size_t count);
Hans Verkuil7087d312013-04-14 12:10:32 -0300447extern void cx25821_free_mem_upstream(struct cx25821_channel *chan);
Mauro Carvalho Chehabbb4c9a72009-09-13 11:25:45 -0300448extern void cx25821_free_mem_upstream_audio(struct cx25821_dev *dev);
Hans Verkuil7087d312013-04-14 12:10:32 -0300449extern void cx25821_stop_upstream_video(struct cx25821_channel *chan);
Mauro Carvalho Chehabbb4c9a72009-09-13 11:25:45 -0300450extern void cx25821_stop_upstream_audio(struct cx25821_dev *dev);
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300451extern int cx25821_sram_channel_setup_upstream(struct cx25821_dev *dev,
Hans Verkuilbfef0d32013-04-13 06:28:54 -0300452 const struct sram_channel *ch,
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300453 unsigned int bpl, u32 risc);
454extern void cx25821_set_pixel_format(struct cx25821_dev *dev, int channel,
455 u32 format);
Hans Verkuil95c232a2013-04-13 07:41:29 -0300456
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300457#endif