blob: b422275ff4f1c1be98d93a3641f63a02753ca0a3 [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.
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -030018 */
19
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -030020#ifndef CX25821_H_
21#define CX25821_H_
22
23#include <linux/pci.h>
24#include <linux/i2c.h>
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -030025#include <linux/interrupt.h>
26#include <linux/delay.h>
27#include <linux/sched.h>
28#include <linux/kdev_t.h>
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -030029
30#include <media/v4l2-common.h>
Mauro Carvalho Chehabbb4c9a72009-09-13 11:25:45 -030031#include <media/v4l2-device.h>
Hans Verkuilf8d7ee72013-04-13 08:38:14 -030032#include <media/v4l2-ctrls.h>
Junghak Sung2d700712015-09-22 10:30:30 -030033#include <media/videobuf2-v4l2.h>
Hans Verkuilb671ae62014-12-12 10:27:58 -030034#include <media/videobuf2-dma-sg.h>
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -030035
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -030036#include "cx25821-reg.h"
37#include "cx25821-medusa-reg.h"
38#include "cx25821-sram.h"
39#include "cx25821-audio.h"
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -030040
41#include <linux/version.h>
42#include <linux/mutex.h>
43
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -030044#define UNSET (-1U)
45#define NO_SYNC_LINE (-1U)
46
47#define CX25821_MAXBOARDS 2
48
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -030049#define LINE_SIZE_D1 1440
50
Palash Bandyopadhyay6d8c2ba2010-07-04 14:15:38 -030051/* Number of decoders and encoders */
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -030052#define MAX_DECODERS 8
53#define MAX_ENCODERS 2
54#define QUAD_DECODERS 4
55#define MAX_CAMERAS 16
56
57/* Max number of inputs by card */
Leonid V. Fedorenchikc7855ee2011-10-22 01:43:56 -030058#define MAX_CX25821_INPUT 8
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -030059#define RESOURCE_VIDEO0 1
60#define RESOURCE_VIDEO1 2
61#define RESOURCE_VIDEO2 4
62#define RESOURCE_VIDEO3 8
63#define RESOURCE_VIDEO4 16
64#define RESOURCE_VIDEO5 32
65#define RESOURCE_VIDEO6 64
66#define RESOURCE_VIDEO7 128
67#define RESOURCE_VIDEO8 256
68#define RESOURCE_VIDEO9 512
69#define RESOURCE_VIDEO10 1024
70#define RESOURCE_VIDEO11 2048
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -030071
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -030072#define BUFFER_TIMEOUT (HZ) /* 0.5 seconds */
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -030073
Leonid V. Fedorenchikc7855ee2011-10-22 01:43:56 -030074#define UNKNOWN_BOARD 0
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -030075#define CX25821_BOARD 1
76
Mauro Carvalho Chehabbb4c9a72009-09-13 11:25:45 -030077/* Currently supported by the driver */
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -030078#define CX25821_NORMS (\
Ruslan Pisareve4115bb2010-09-27 10:01:36 -030079 V4L2_STD_NTSC_M | V4L2_STD_NTSC_M_JP | V4L2_STD_NTSC_M_KR | \
80 V4L2_STD_PAL_BG | V4L2_STD_PAL_DK | V4L2_STD_PAL_I | \
81 V4L2_STD_PAL_M | V4L2_STD_PAL_N | V4L2_STD_PAL_H | \
82 V4L2_STD_PAL_Nc)
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -030083
84#define CX25821_BOARD_CONEXANT_ATHENA10 1
85#define MAX_VID_CHANNEL_NUM 12
Hans Verkuilb6f21dc2014-12-12 10:28:00 -030086
87/*
88 * Maximum capture-only channels. This can go away once video/audio output
89 * is fully supported in this driver.
90 */
91#define MAX_VID_CAP_CHANNEL_NUM 10
92
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -030093#define VID_CHANNEL_NUM 8
94
95struct cx25821_fmt {
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -030096 char *name;
97 u32 fourcc; /* v4l2 format id */
98 int depth;
99 int flags;
100 u32 cxformat;
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300101};
102
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300103struct cx25821_tvnorm {
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300104 char *name;
105 v4l2_std_id id;
106 u32 cxiformat;
107 u32 cxoformat;
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300108};
109
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300110enum cx25821_src_sel_type {
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300111 CX25821_SRC_SEL_EXT_656_VIDEO = 0,
112 CX25821_SRC_SEL_PARALLEL_MPEG_VIDEO
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300113};
114
Hans Verkuil5ede94c2014-12-12 10:27:54 -0300115struct cx25821_riscmem {
116 unsigned int size;
117 __le32 *cpu;
118 __le32 *jmp;
119 dma_addr_t dma;
120};
121
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300122/* buffer for one video frame */
123struct cx25821_buffer {
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300124 /* common v4l buffer stuff -- must be first */
Junghak Sung2d700712015-09-22 10:30:30 -0300125 struct vb2_v4l2_buffer vb;
Hans Verkuilb671ae62014-12-12 10:27:58 -0300126 struct list_head queue;
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300127
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300128 /* cx25821 specific */
129 unsigned int bpl;
Hans Verkuil5ede94c2014-12-12 10:27:54 -0300130 struct cx25821_riscmem risc;
Hans Verkuil95c232a2013-04-13 07:41:29 -0300131 const struct cx25821_fmt *fmt;
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300132};
133
Leonid V. Fedorenchik7ae70c82011-09-02 11:55:29 +0800134enum port {
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300135 CX25821_UNDEFINED = 0,
136 CX25821_RAW,
137 CX25821_264
Leonid V. Fedorenchik7ae70c82011-09-02 11:55:29 +0800138};
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300139
140struct cx25821_board {
Ezequiel Garcíac854d882012-07-18 13:41:11 -0300141 const char *name;
Leonid V. Fedorenchik7ae70c82011-09-02 11:55:29 +0800142 enum port porta;
143 enum port portb;
144 enum port portc;
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300145
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300146 u32 clk_freq;
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300147};
148
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300149struct cx25821_i2c {
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300150 struct cx25821_dev *dev;
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300151
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300152 int nr;
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300153
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300154 /* i2c i/o */
155 struct i2c_adapter i2c_adap;
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300156 struct i2c_client i2c_client;
157 u32 i2c_rc;
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300158
Mauro Carvalho Chehab16790552019-02-18 14:28:59 -0500159 /* cx25821 registers used for raw address */
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300160 u32 i2c_period;
161 u32 reg_ctrl;
162 u32 reg_stat;
163 u32 reg_addr;
164 u32 reg_rdata;
165 u32 reg_wdata;
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300166};
167
168struct cx25821_dmaqueue {
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300169 struct list_head active;
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300170 u32 count;
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300171};
172
Hans Verkuilf8d7ee72013-04-13 08:38:14 -0300173struct cx25821_dev;
174
Hans Verkuil7087d312013-04-14 12:10:32 -0300175struct cx25821_channel;
176
177struct cx25821_video_out_data {
178 struct cx25821_channel *chan;
179 int _line_size;
180 int _prog_cnt;
181 int _pixel_format;
182 int _is_first_frame;
183 int _is_running;
184 int _file_status;
185 int _lines_count;
186 int _frame_count;
187 unsigned int _risc_size;
188
189 __le32 *_dma_virt_start_addr;
190 __le32 *_dma_virt_addr;
191 dma_addr_t _dma_phys_addr;
192 dma_addr_t _dma_phys_start_addr;
193
194 unsigned int _data_buf_size;
195 __le32 *_data_buf_virt_addr;
196 dma_addr_t _data_buf_phys_addr;
197
198 u32 upstream_riscbuf_size;
199 u32 upstream_databuf_size;
Hans Verkuil7087d312013-04-14 12:10:32 -0300200 int is_60hz;
201 int _frame_index;
Hans Verkuilea3f7ac2013-04-14 12:02:19 -0300202 int cur_frame_index;
203 int curpos;
204 wait_queue_head_t waitq;
Hans Verkuil7087d312013-04-14 12:10:32 -0300205};
206
Palash Bandyopadhyay6d8c2ba2010-07-04 14:15:38 -0300207struct cx25821_channel {
Hans Verkuilf8d7ee72013-04-13 08:38:14 -0300208 unsigned id;
209 struct cx25821_dev *dev;
Palash Bandyopadhyay6d8c2ba2010-07-04 14:15:38 -0300210
Hans Verkuilf8d7ee72013-04-13 08:38:14 -0300211 struct v4l2_ctrl_handler hdl;
Palash Bandyopadhyay6d8c2ba2010-07-04 14:15:38 -0300212
Hans Verkuil467870c2013-04-13 08:18:00 -0300213 struct video_device vdev;
Hans Verkuil2efe2cc2013-04-13 10:00:52 -0300214 struct cx25821_dmaqueue dma_vidq;
Hans Verkuilb671ae62014-12-12 10:27:58 -0300215 struct vb2_queue vidq;
Palash Bandyopadhyay6d8c2ba2010-07-04 14:15:38 -0300216
Hans Verkuilbfef0d32013-04-13 06:28:54 -0300217 const struct sram_channel *sram_channels;
Palash Bandyopadhyay6d8c2ba2010-07-04 14:15:38 -0300218
Hans Verkuil2efe2cc2013-04-13 10:00:52 -0300219 const struct cx25821_fmt *fmt;
Hans Verkuilb671ae62014-12-12 10:27:58 -0300220 unsigned field;
Hans Verkuil2efe2cc2013-04-13 10:00:52 -0300221 unsigned int width, height;
Ruslan Pisareve4115bb2010-09-27 10:01:36 -0300222 int pixel_formats;
223 int use_cif_resolution;
224 int cif_width;
Hans Verkuil7087d312013-04-14 12:10:32 -0300225
226 /* video output data for the video output channel */
227 struct cx25821_video_out_data *out;
Palash Bandyopadhyay6d8c2ba2010-07-04 14:15:38 -0300228};
229
Hans Verkuila8f35ce2013-04-13 07:07:40 -0300230struct snd_card;
231
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300232struct cx25821_dev {
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300233 struct v4l2_device v4l2_dev;
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300234
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300235 /* pci stuff */
236 struct pci_dev *pci;
237 unsigned char pci_rev, pci_lat;
238 int pci_bus, pci_slot;
239 u32 base_io_addr;
240 u32 __iomem *lmmio;
241 u8 __iomem *bmmio;
242 int pci_irqmask;
243 int hwrevision;
Hans Verkuila8f35ce2013-04-13 07:07:40 -0300244 /* used by cx25821-alsa */
245 struct snd_card *card;
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300246
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300247 u32 clk_freq;
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300248
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300249 /* I2C adapters: Master 1 & 2 (External) & Master 3 (Internal only) */
250 struct cx25821_i2c i2c_bus[3];
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300251
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300252 int nr;
253 struct mutex lock;
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300254
Ruslan Pisareve4115bb2010-09-27 10:01:36 -0300255 struct cx25821_channel channels[MAX_VID_CHANNEL_NUM];
Palash Bandyopadhyay6d8c2ba2010-07-04 14:15:38 -0300256
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300257 /* board details */
258 unsigned int board;
259 char name[32];
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300260
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300261 /* Analog video */
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300262 unsigned int input;
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300263 v4l2_std_id tvnorm;
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300264 unsigned short _max_num_decoders;
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300265
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300266 /* Analog Audio Upstream */
267 int _audio_is_running;
268 int _audiopixel_format;
269 int _is_first_audio_frame;
270 int _audiofile_status;
271 int _audio_lines_count;
272 int _audioframe_count;
Leonid V. Fedorenchik6100c572011-09-02 11:55:30 +0800273 int _audio_upstream_channel;
Ruslan Pisareve4115bb2010-09-27 10:01:36 -0300274 int _last_index_irq; /* The last interrupt index processed. */
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300275
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300276 __le32 *_risc_audio_jmp_addr;
277 __le32 *_risc_virt_start_addr;
278 __le32 *_risc_virt_addr;
279 dma_addr_t _risc_phys_addr;
280 dma_addr_t _risc_phys_start_addr;
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300281
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300282 unsigned int _audiorisc_size;
283 unsigned int _audiodata_buf_size;
284 __le32 *_audiodata_buf_virt_addr;
285 dma_addr_t _audiodata_buf_phys_addr;
286 char *_audiofilename;
Hans Verkuil7087d312013-04-14 12:10:32 -0300287 u32 audio_upstream_riscbuf_size;
288 u32 audio_upstream_databuf_size;
289 int _audioframe_index;
Hans Verkuil7087d312013-04-14 12:10:32 -0300290 struct work_struct _audio_work_entry;
291 char *input_audiofilename;
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300292
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300293 /* V4l */
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300294 spinlock_t slock;
Mauro Carvalho Chehabbb4c9a72009-09-13 11:25:45 -0300295
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300296 /* Video Upstream */
Hans Verkuil7087d312013-04-14 12:10:32 -0300297 struct cx25821_video_out_data vid_out_data[2];
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300298};
299
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300300static inline struct cx25821_dev *get_cx25821(struct v4l2_device *v4l2_dev)
301{
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300302 return container_of(v4l2_dev, struct cx25821_dev, v4l2_dev);
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300303}
304
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300305extern struct cx25821_board cx25821_boards[];
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300306
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300307#define SRAM_CH00 0 /* Video A */
308#define SRAM_CH01 1 /* Video B */
309#define SRAM_CH02 2 /* Video C */
310#define SRAM_CH03 3 /* Video D */
311#define SRAM_CH04 4 /* Video E */
312#define SRAM_CH05 5 /* Video F */
313#define SRAM_CH06 6 /* Video G */
314#define SRAM_CH07 7 /* Video H */
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300315
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300316#define SRAM_CH08 8 /* Audio A */
317#define SRAM_CH09 9 /* Video Upstream I */
318#define SRAM_CH10 10 /* Video Upstream J */
319#define SRAM_CH11 11 /* Audio Upstream AUD_CHANNEL_B */
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300320
321#define VID_UPSTREAM_SRAM_CHANNEL_I SRAM_CH09
322#define VID_UPSTREAM_SRAM_CHANNEL_J SRAM_CH10
323#define AUDIO_UPSTREAM_SRAM_CHANNEL_B SRAM_CH11
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300324
325struct sram_channel {
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300326 char *name;
327 u32 i;
328 u32 cmds_start;
329 u32 ctrl_start;
330 u32 cdt;
331 u32 fifo_start;
332 u32 fifo_size;
333 u32 ptr1_reg;
334 u32 ptr2_reg;
335 u32 cnt1_reg;
336 u32 cnt2_reg;
337 u32 int_msk;
338 u32 int_stat;
339 u32 int_mstat;
340 u32 dma_ctl;
341 u32 gpcnt_ctl;
342 u32 gpcnt;
343 u32 aud_length;
344 u32 aud_cfg;
345 u32 fld_aud_fifo_en;
346 u32 fld_aud_risc_en;
Mauro Carvalho Chehabbb4c9a72009-09-13 11:25:45 -0300347
Ruslan Pisareve4115bb2010-09-27 10:01:36 -0300348 /* For Upstream Video */
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300349 u32 vid_fmt_ctl;
350 u32 vid_active_ctl1;
351 u32 vid_active_ctl2;
352 u32 vid_cdt_size;
Mauro Carvalho Chehabbb4c9a72009-09-13 11:25:45 -0300353
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300354 u32 vip_ctl;
355 u32 pix_frmt;
356 u32 jumponly;
357 u32 irq_bit;
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300358};
Hans Verkuilbfef0d32013-04-13 06:28:54 -0300359
360extern const struct sram_channel cx25821_sram_channels[];
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300361
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300362#define cx_read(reg) readl(dev->lmmio + ((reg)>>2))
363#define cx_write(reg, value) writel((value), dev->lmmio + ((reg)>>2))
364
365#define cx_andor(reg, mask, value) \
Ruslan Pisareve4115bb2010-09-27 10:01:36 -0300366 writel((readl(dev->lmmio+((reg)>>2)) & ~(mask)) |\
367 ((value) & (mask)), dev->lmmio+((reg)>>2))
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300368
369#define cx_set(reg, bit) cx_andor((reg), (bit), (bit))
370#define cx_clear(reg, bit) cx_andor((reg), (bit), 0)
371
372#define Set_GPIO_Bit(Bit) (1 << Bit)
373#define Clear_GPIO_Bit(Bit) (~(1 << Bit))
374
Joe Perches36d89f72010-11-07 17:48:21 -0300375#define CX25821_ERR(fmt, args...) \
376 pr_err("(%d): " fmt, dev->board, ##args)
377#define CX25821_WARN(fmt, args...) \
378 pr_warn("(%d): " fmt, dev->board, ##args)
379#define CX25821_INFO(fmt, args...) \
380 pr_info("(%d): " fmt, dev->board, ##args)
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300381
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300382extern int cx25821_i2c_register(struct cx25821_i2c *bus);
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300383extern int cx25821_i2c_read(struct cx25821_i2c *bus, u16 reg_addr, int *value);
384extern int cx25821_i2c_write(struct cx25821_i2c *bus, u16 reg_addr, int value);
385extern int cx25821_i2c_unregister(struct cx25821_i2c *bus);
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300386extern void cx25821_gpio_init(struct cx25821_dev *dev);
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300387extern void cx25821_set_gpiopin_direction(struct cx25821_dev *dev,
388 int pin_number, int pin_logic_value);
Mauro Carvalho Chehabbb4c9a72009-09-13 11:25:45 -0300389
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300390extern int medusa_video_init(struct cx25821_dev *dev);
391extern int medusa_set_videostandard(struct cx25821_dev *dev);
392extern void medusa_set_resolution(struct cx25821_dev *dev, int width,
393 int decoder_select);
394extern int medusa_set_brightness(struct cx25821_dev *dev, int brightness,
395 int decoder);
396extern int medusa_set_contrast(struct cx25821_dev *dev, int contrast,
397 int decoder);
398extern int medusa_set_hue(struct cx25821_dev *dev, int hue, int decoder);
399extern int medusa_set_saturation(struct cx25821_dev *dev, int saturation,
400 int decoder);
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300401
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300402extern int cx25821_sram_channel_setup(struct cx25821_dev *dev,
Hans Verkuilbfef0d32013-04-13 06:28:54 -0300403 const struct sram_channel *ch, unsigned int bpl,
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300404 u32 risc);
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300405
Hans Verkuil5ede94c2014-12-12 10:27:54 -0300406extern int cx25821_riscmem_alloc(struct pci_dev *pci,
407 struct cx25821_riscmem *risc,
408 unsigned int size);
409extern int cx25821_risc_buffer(struct pci_dev *pci, struct cx25821_riscmem *risc,
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300410 struct scatterlist *sglist,
411 unsigned int top_offset,
412 unsigned int bottom_offset,
413 unsigned int bpl,
414 unsigned int padding, unsigned int lines);
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300415extern int cx25821_risc_databuffer_audio(struct pci_dev *pci,
Hans Verkuil5ede94c2014-12-12 10:27:54 -0300416 struct cx25821_riscmem *risc,
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300417 struct scatterlist *sglist,
418 unsigned int bpl,
419 unsigned int lines, unsigned int lpi);
Hans Verkuilb671ae62014-12-12 10:27:58 -0300420extern void cx25821_free_buffer(struct cx25821_dev *dev,
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300421 struct cx25821_buffer *buf);
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300422extern void cx25821_sram_channel_dump(struct cx25821_dev *dev,
Hans Verkuilbfef0d32013-04-13 06:28:54 -0300423 const struct sram_channel *ch);
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300424extern void cx25821_sram_channel_dump_audio(struct cx25821_dev *dev,
Hans Verkuilbfef0d32013-04-13 06:28:54 -0300425 const struct sram_channel *ch);
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300426
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300427extern struct cx25821_dev *cx25821_dev_get(struct pci_dev *pci);
428extern void cx25821_print_irqbits(char *name, char *tag, char **strings,
429 int len, u32 bits, u32 mask);
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300430extern void cx25821_dev_unregister(struct cx25821_dev *dev);
431extern int cx25821_sram_channel_setup_audio(struct cx25821_dev *dev,
Hans Verkuilbfef0d32013-04-13 06:28:54 -0300432 const struct sram_channel *ch,
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300433 unsigned int bpl, u32 risc);
Mauro Carvalho Chehabbb4c9a72009-09-13 11:25:45 -0300434
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300435extern void cx25821_set_pixel_format(struct cx25821_dev *dev, int channel,
436 u32 format);
Hans Verkuil95c232a2013-04-13 07:41:29 -0300437
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300438#endif