1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#ifndef CX25821_VIDEO_H_
25#define CX25821_VIDEO_H_
26
27#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
43#ifdef CONFIG_VIDEO_V4L1_COMPAT
44
45#include <linux/videodev.h>
46#endif
47
48#define TUNER_FLAG
49
50#define VIDEO_DEBUG 0
51
52#define dprintk(level, fmt, arg...)\
53 do { if (VIDEO_DEBUG >= level)\
54 printk(KERN_DEBUG "%s/0: " fmt, dev->name, ## arg);\
55 } while (0)
56
57
58#define UPSTREAM_START_VIDEO 700
59#define UPSTREAM_STOP_VIDEO 701
60#define UPSTREAM_START_AUDIO 702
61#define UPSTREAM_STOP_AUDIO 703
62#define UPSTREAM_DUMP_REGISTERS 702
63#define SET_VIDEO_STD 800
64#define SET_PIXEL_FORMAT 1000
65#define ENABLE_CIF_RESOLUTION 1001
66
67#define REG_READ 900
68#define REG_WRITE 901
69#define MEDUSA_READ 910
70#define MEDUSA_WRITE 911
71
72extern struct sram_channel *channel0;
73extern struct sram_channel *channel1;
74extern struct sram_channel *channel2;
75extern struct sram_channel *channel3;
76extern struct sram_channel *channel4;
77extern struct sram_channel *channel5;
78extern struct sram_channel *channel6;
79extern struct sram_channel *channel7;
80extern struct sram_channel *channel9;
81extern struct sram_channel *channel10;
82extern struct sram_channel *channel11;
83extern struct video_device cx25821_video_template0;
84extern struct video_device cx25821_video_template1;
85extern struct video_device cx25821_video_template2;
86extern struct video_device cx25821_video_template3;
87extern struct video_device cx25821_video_template4;
88extern struct video_device cx25821_video_template5;
89extern struct video_device cx25821_video_template6;
90extern struct video_device cx25821_video_template7;
91extern struct video_device cx25821_video_template9;
92extern struct video_device cx25821_video_template10;
93extern struct video_device cx25821_video_template11;
94extern struct video_device cx25821_videoioctl_template;
95
96
97extern unsigned int vid_limit;
98
99#define FORMAT_FLAGS_PACKED 0x01
100extern struct cx25821_fmt formats[];
101extern struct cx25821_fmt *format_by_fourcc(unsigned int fourcc);
102extern struct cx25821_data timeout_data[MAX_VID_CHANNEL_NUM];
103
104extern void dump_video_queue(struct cx25821_dev *dev,
105 struct cx25821_dmaqueue *q);
106extern void cx25821_video_wakeup(struct cx25821_dev *dev,
107 struct cx25821_dmaqueue *q, u32 count);
108
109#ifdef TUNER_FLAG
110extern int cx25821_set_tvnorm(struct cx25821_dev *dev, v4l2_std_id norm);
111#endif
112
113extern int res_get(struct cx25821_dev *dev, struct cx25821_fh *fh,
114 unsigned int bit);
115extern int res_check(struct cx25821_fh *fh, unsigned int bit);
116extern int res_locked(struct cx25821_dev *dev, unsigned int bit);
117extern void res_free(struct cx25821_dev *dev, struct cx25821_fh *fh,
118 unsigned int bits);
119extern int cx25821_video_mux(struct cx25821_dev *dev, unsigned int input);
120extern int cx25821_start_video_dma(struct cx25821_dev *dev,
121 struct cx25821_dmaqueue *q,
122 struct cx25821_buffer *buf,
123 struct sram_channel *channel);
124
125extern int cx25821_set_scale(struct cx25821_dev *dev, unsigned int width,
126 unsigned int height, enum v4l2_field field);
127extern int cx25821_video_irq(struct cx25821_dev *dev, int chan_num, u32 status);
128extern void cx25821_video_unregister(struct cx25821_dev *dev, int chan_num);
129extern int cx25821_video_register(struct cx25821_dev *dev, int chan_num,
130 struct video_device *video_template);
131extern int get_format_size(void);
132
133extern int buffer_setup(struct videobuf_queue *q, unsigned int *count,
134 unsigned int *size);
135extern int buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
136 enum v4l2_field field);
137extern void buffer_release(struct videobuf_queue *q,
138 struct videobuf_buffer *vb);
139extern struct videobuf_queue *get_queue(struct cx25821_fh *fh);
140extern int get_resource(struct cx25821_fh *fh, int resource);
141extern int video_mmap(struct file *file, struct vm_area_struct *vma);
142extern int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
143 struct v4l2_format *f);
144extern int vidioc_querycap(struct file *file, void *priv,
145 struct v4l2_capability *cap);
146extern int vidioc_enum_fmt_vid_cap(struct file *file, void *priv,
147 struct v4l2_fmtdesc *f);
148extern int vidiocgmbuf(struct file *file, void *priv, struct video_mbuf *mbuf);
149extern int vidioc_reqbufs(struct file *file, void *priv,
150 struct v4l2_requestbuffers *p);
151extern int vidioc_querybuf(struct file *file, void *priv,
152 struct v4l2_buffer *p);
153extern int vidioc_qbuf(struct file *file, void *priv, struct v4l2_buffer *p);
154extern int vidioc_s_std(struct file *file, void *priv, v4l2_std_id * tvnorms);
155extern int cx25821_enum_input(struct cx25821_dev *dev, struct v4l2_input *i);
156extern int vidioc_enum_input(struct file *file, void *priv,
157 struct v4l2_input *i);
158extern int vidioc_g_input(struct file *file, void *priv, unsigned int *i);
159extern int vidioc_s_input(struct file *file, void *priv, unsigned int i);
160extern int vidioc_g_ctrl(struct file *file, void *priv,
161 struct v4l2_control *ctl);
162extern int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
163 struct v4l2_format *f);
164extern int vidioc_g_frequency(struct file *file, void *priv,
165 struct v4l2_frequency *f);
166extern int cx25821_set_freq(struct cx25821_dev *dev, struct v4l2_frequency *f);
167extern int vidioc_s_frequency(struct file *file, void *priv,
168 struct v4l2_frequency *f);
169extern int vidioc_g_register(struct file *file, void *fh,
170 struct v4l2_dbg_register *reg);
171extern int vidioc_s_register(struct file *file, void *fh,
172 struct v4l2_dbg_register *reg);
173extern int vidioc_g_tuner(struct file *file, void *priv, struct v4l2_tuner *t);
174extern int vidioc_s_tuner(struct file *file, void *priv, struct v4l2_tuner *t);
175
176extern int is_valid_width(u32 width, v4l2_std_id tvnorm);
177extern int is_valid_height(u32 height, v4l2_std_id tvnorm);
178
179extern int vidioc_g_priority(struct file *file, void *f, enum v4l2_priority *p);
180extern int vidioc_s_priority(struct file *file, void *f,
181 enum v4l2_priority prio);
182
183extern int vidioc_queryctrl(struct file *file, void *priv,
184 struct v4l2_queryctrl *qctrl);
185extern int cx25821_set_control(struct cx25821_dev *dev,
186 struct v4l2_control *ctrl, int chan_num);
187
188extern int vidioc_cropcap(struct file *file, void *fh,
189 struct v4l2_cropcap *cropcap);
190extern int vidioc_s_crop(struct file *file, void *priv, struct v4l2_crop *crop);
191extern int vidioc_g_crop(struct file *file, void *priv, struct v4l2_crop *crop);
192
193extern int vidioc_querystd(struct file *file, void *priv, v4l2_std_id * norm);
194#endif
195