blob: c265e35b37c3e54a9ddbe0b57f0fb31e3fda8d89 [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
24#ifndef CX25821_VIDEO_H_
25#define CX25821_VIDEO_H_
26
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -030027#include <linux/init.h>
28#include <linux/list.h>
29#include <linux/module.h>
30#include <linux/moduleparam.h>
31#include <linux/kmod.h>
32#include <linux/kernel.h>
33#include <linux/slab.h>
34#include <linux/interrupt.h>
35#include <linux/delay.h>
36#include <linux/kthread.h>
37#include <asm/div64.h>
38
39#include "cx25821.h"
40#include <media/v4l2-common.h>
41#include <media/v4l2-ioctl.h>
42
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -030043#define TUNER_FLAG
44
45#define VIDEO_DEBUG 0
46
Joe Perches36d89f72010-11-07 17:48:21 -030047#define dprintk(level, fmt, arg...) \
48do { \
49 if (VIDEO_DEBUG >= level) \
50 printk(KERN_DEBUG "%s/0: " fmt, dev->name, ##arg); \
51} while (0)
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -030052
Mauro Carvalho Chehab1852a1b2010-07-04 15:21:40 -030053/* For IOCTL to identify running upstream */
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -030054#define UPSTREAM_START_VIDEO 700
55#define UPSTREAM_STOP_VIDEO 701
56#define UPSTREAM_START_AUDIO 702
57#define UPSTREAM_STOP_AUDIO 703
58#define UPSTREAM_DUMP_REGISTERS 702
59#define SET_VIDEO_STD 800
60#define SET_PIXEL_FORMAT 1000
61#define ENABLE_CIF_RESOLUTION 1001
62
63#define REG_READ 900
64#define REG_WRITE 901
65#define MEDUSA_READ 910
Leonid V. Fedorenchik9ad69022011-09-16 14:15:15 +080066#define MEDUSA_WRITE 911
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -030067
68extern struct sram_channel *channel0;
69extern struct sram_channel *channel1;
70extern struct sram_channel *channel2;
71extern struct sram_channel *channel3;
72extern struct sram_channel *channel4;
73extern struct sram_channel *channel5;
74extern struct sram_channel *channel6;
75extern struct sram_channel *channel7;
76extern struct sram_channel *channel9;
77extern struct sram_channel *channel10;
78extern struct sram_channel *channel11;
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -030079extern struct video_device cx25821_videoioctl_template;
Mauro Carvalho Chehab1852a1b2010-07-04 15:21:40 -030080/* extern const u32 *ctrl_classes[]; */
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -030081
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -030082extern unsigned int vid_limit;
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -030083
84#define FORMAT_FLAGS_PACKED 0x01
85extern struct cx25821_fmt formats[];
Mauro Carvalho Chehaba757ee22010-12-02 01:57:03 -020086extern struct cx25821_fmt *cx25821_format_by_fourcc(unsigned int fourcc);
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -030087extern struct cx25821_data timeout_data[MAX_VID_CHANNEL_NUM];
88
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -030089extern void cx25821_video_wakeup(struct cx25821_dev *dev,
90 struct cx25821_dmaqueue *q, u32 count);
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -030091
92#ifdef TUNER_FLAG
93extern int cx25821_set_tvnorm(struct cx25821_dev *dev, v4l2_std_id norm);
94#endif
95
Mauro Carvalho Chehabf2466d62010-03-24 16:33:40 -030096extern int cx25821_res_get(struct cx25821_dev *dev, struct cx25821_fh *fh,
Leonid V. Fedorenchik64eb32442011-09-16 14:15:16 +080097 unsigned int bit);
Mauro Carvalho Chehabf2466d62010-03-24 16:33:40 -030098extern int cx25821_res_check(struct cx25821_fh *fh, unsigned int bit);
Palash Bandyopadhyay6d8c2ba2010-07-04 14:15:38 -030099extern int cx25821_res_locked(struct cx25821_fh *fh, unsigned int bit);
Mauro Carvalho Chehabf2466d62010-03-24 16:33:40 -0300100extern void cx25821_res_free(struct cx25821_dev *dev, struct cx25821_fh *fh,
Leonid V. Fedorenchik64eb32442011-09-16 14:15:16 +0800101 unsigned int bits);
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300102extern int cx25821_video_mux(struct cx25821_dev *dev, unsigned int input);
103extern int cx25821_start_video_dma(struct cx25821_dev *dev,
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300104 struct cx25821_dmaqueue *q,
105 struct cx25821_buffer *buf,
106 struct sram_channel *channel);
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300107
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300108extern int cx25821_set_scale(struct cx25821_dev *dev, unsigned int width,
109 unsigned int height, enum v4l2_field field);
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300110extern int cx25821_video_irq(struct cx25821_dev *dev, int chan_num, u32 status);
111extern void cx25821_video_unregister(struct cx25821_dev *dev, int chan_num);
Palash Bandyopadhyay6d8c2ba2010-07-04 14:15:38 -0300112extern int cx25821_video_register(struct cx25821_dev *dev);
Mauro Carvalho Chehabf2466d62010-03-24 16:33:40 -0300113extern int cx25821_get_format_size(void);
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300114
Mauro Carvalho Chehabf2466d62010-03-24 16:33:40 -0300115extern int cx25821_buffer_setup(struct videobuf_queue *q, unsigned int *count,
Leonid V. Fedorenchik661d3bf2011-09-16 14:15:17 +0800116 unsigned int *size);
117extern int cx25821_buffer_prepare(struct videobuf_queue *q,
118 struct videobuf_buffer *vb,
119 enum v4l2_field field);
Mauro Carvalho Chehabf2466d62010-03-24 16:33:40 -0300120extern void cx25821_buffer_release(struct videobuf_queue *q,
Leonid V. Fedorenchik64eb32442011-09-16 14:15:16 +0800121 struct videobuf_buffer *vb);
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300122extern struct videobuf_queue *get_queue(struct cx25821_fh *fh);
Mauro Carvalho Chehabf2466d62010-03-24 16:33:40 -0300123extern int cx25821_get_resource(struct cx25821_fh *fh, int resource);
124extern int cx25821_video_mmap(struct file *file, struct vm_area_struct *vma);
125extern int cx25821_vidioc_try_fmt_vid_cap(struct file *file, void *priv,
Leonid V. Fedorenchik64eb32442011-09-16 14:15:16 +0800126 struct v4l2_format *f);
Mauro Carvalho Chehabf2466d62010-03-24 16:33:40 -0300127extern int cx25821_vidioc_querycap(struct file *file, void *priv,
Leonid V. Fedorenchik64eb32442011-09-16 14:15:16 +0800128 struct v4l2_capability *cap);
Mauro Carvalho Chehabf2466d62010-03-24 16:33:40 -0300129extern int cx25821_vidioc_enum_fmt_vid_cap(struct file *file, void *priv,
Leonid V. Fedorenchik64eb32442011-09-16 14:15:16 +0800130 struct v4l2_fmtdesc *f);
Mauro Carvalho Chehabf2466d62010-03-24 16:33:40 -0300131extern int cx25821_vidioc_reqbufs(struct file *file, void *priv,
Leonid V. Fedorenchik64eb32442011-09-16 14:15:16 +0800132 struct v4l2_requestbuffers *p);
Mauro Carvalho Chehabf2466d62010-03-24 16:33:40 -0300133extern int cx25821_vidioc_querybuf(struct file *file, void *priv,
Leonid V. Fedorenchik661d3bf2011-09-16 14:15:17 +0800134 struct v4l2_buffer *p);
135extern int cx25821_vidioc_qbuf(struct file *file, void *priv,
136 struct v4l2_buffer *p);
137extern int cx25821_vidioc_s_std(struct file *file, void *priv,
138 v4l2_std_id *tvnorms);
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300139extern int cx25821_enum_input(struct cx25821_dev *dev, struct v4l2_input *i);
Mauro Carvalho Chehabf2466d62010-03-24 16:33:40 -0300140extern int cx25821_vidioc_enum_input(struct file *file, void *priv,
Leonid V. Fedorenchik661d3bf2011-09-16 14:15:17 +0800141 struct v4l2_input *i);
142extern int cx25821_vidioc_g_input(struct file *file, void *priv,
143 unsigned int *i);
144extern int cx25821_vidioc_s_input(struct file *file, void *priv,
145 unsigned int i);
Mauro Carvalho Chehabf2466d62010-03-24 16:33:40 -0300146extern int cx25821_vidioc_g_ctrl(struct file *file, void *priv,
Leonid V. Fedorenchik64eb32442011-09-16 14:15:16 +0800147 struct v4l2_control *ctl);
Mauro Carvalho Chehabf2466d62010-03-24 16:33:40 -0300148extern int cx25821_vidioc_g_fmt_vid_cap(struct file *file, void *priv,
Leonid V. Fedorenchik64eb32442011-09-16 14:15:16 +0800149 struct v4l2_format *f);
Mauro Carvalho Chehabf2466d62010-03-24 16:33:40 -0300150extern int cx25821_vidioc_g_frequency(struct file *file, void *priv,
Leonid V. Fedorenchik64eb32442011-09-16 14:15:16 +0800151 struct v4l2_frequency *f);
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300152extern int cx25821_set_freq(struct cx25821_dev *dev, struct v4l2_frequency *f);
Mauro Carvalho Chehabf2466d62010-03-24 16:33:40 -0300153extern int cx25821_vidioc_s_frequency(struct file *file, void *priv,
Leonid V. Fedorenchik64eb32442011-09-16 14:15:16 +0800154 struct v4l2_frequency *f);
Mauro Carvalho Chehabf2466d62010-03-24 16:33:40 -0300155extern int cx25821_vidioc_g_register(struct file *file, void *fh,
Leonid V. Fedorenchik64eb32442011-09-16 14:15:16 +0800156 struct v4l2_dbg_register *reg);
Mauro Carvalho Chehabf2466d62010-03-24 16:33:40 -0300157extern int cx25821_vidioc_s_register(struct file *file, void *fh,
Leonid V. Fedorenchik661d3bf2011-09-16 14:15:17 +0800158 struct v4l2_dbg_register *reg);
159extern int cx25821_vidioc_g_tuner(struct file *file, void *priv,
160 struct v4l2_tuner *t);
161extern int cx25821_vidioc_s_tuner(struct file *file, void *priv,
162 struct v4l2_tuner *t);
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300163
Mauro Carvalho Chehabf2466d62010-03-24 16:33:40 -0300164extern int cx25821_is_valid_width(u32 width, v4l2_std_id tvnorm);
165extern int cx25821_is_valid_height(u32 height, v4l2_std_id tvnorm);
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300166
Leonid V. Fedorenchik661d3bf2011-09-16 14:15:17 +0800167extern int cx25821_vidioc_g_priority(struct file *file, void *f,
168 enum v4l2_priority *p);
Mauro Carvalho Chehabf2466d62010-03-24 16:33:40 -0300169extern int cx25821_vidioc_s_priority(struct file *file, void *f,
Leonid V. Fedorenchik64eb32442011-09-16 14:15:16 +0800170 enum v4l2_priority prio);
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300171
Mauro Carvalho Chehabf2466d62010-03-24 16:33:40 -0300172extern int cx25821_vidioc_queryctrl(struct file *file, void *priv,
Leonid V. Fedorenchik64eb32442011-09-16 14:15:16 +0800173 struct v4l2_queryctrl *qctrl);
Mauro Carvalho Chehab1a9fc852009-09-13 11:30:11 -0300174extern int cx25821_set_control(struct cx25821_dev *dev,
175 struct v4l2_control *ctrl, int chan_num);
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300176
Mauro Carvalho Chehabf2466d62010-03-24 16:33:40 -0300177extern int cx25821_vidioc_cropcap(struct file *file, void *fh,
Leonid V. Fedorenchik661d3bf2011-09-16 14:15:17 +0800178 struct v4l2_cropcap *cropcap);
179extern int cx25821_vidioc_s_crop(struct file *file, void *priv,
Hans Verkuil4f9965942012-09-05 05:10:48 -0300180 const struct v4l2_crop *crop);
Leonid V. Fedorenchik661d3bf2011-09-16 14:15:17 +0800181extern int cx25821_vidioc_g_crop(struct file *file, void *priv,
182 struct v4l2_crop *crop);
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300183
Leonid V. Fedorenchik661d3bf2011-09-16 14:15:17 +0800184extern int cx25821_vidioc_querystd(struct file *file, void *priv,
185 v4l2_std_id *norm);
Mauro Carvalho Chehab02b20b02009-09-15 11:33:54 -0300186#endif