aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/pci/cx25821/cx25821.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/pci/cx25821/cx25821.h')
-rw-r--r--drivers/media/pci/cx25821/cx25821.h304
1 files changed, 70 insertions, 234 deletions
diff --git a/drivers/media/pci/cx25821/cx25821.h b/drivers/media/pci/cx25821/cx25821.h
index 8a9c0c869412..90bdc196929f 100644
--- a/drivers/media/pci/cx25821/cx25821.h
+++ b/drivers/media/pci/cx25821/cx25821.h
@@ -33,17 +33,14 @@
33 33
34#include <media/v4l2-common.h> 34#include <media/v4l2-common.h>
35#include <media/v4l2-device.h> 35#include <media/v4l2-device.h>
36#include <media/tuner.h> 36#include <media/v4l2-ctrls.h>
37#include <media/tveeprom.h>
38#include <media/videobuf-dma-sg.h> 37#include <media/videobuf-dma-sg.h>
39#include <media/videobuf-dvb.h>
40 38
41#include "btcx-risc.h" 39#include "btcx-risc.h"
42#include "cx25821-reg.h" 40#include "cx25821-reg.h"
43#include "cx25821-medusa-reg.h" 41#include "cx25821-medusa-reg.h"
44#include "cx25821-sram.h" 42#include "cx25821-sram.h"
45#include "cx25821-audio.h" 43#include "cx25821-audio.h"
46#include "media/cx2341x.h"
47 44
48#include <linux/version.h> 45#include <linux/version.h>
49#include <linux/mutex.h> 46#include <linux/mutex.h>
@@ -55,8 +52,6 @@
55 52
56#define CX25821_MAXBOARDS 2 53#define CX25821_MAXBOARDS 2
57 54
58#define TRUE 1
59#define FALSE 0
60#define LINE_SIZE_D1 1440 55#define LINE_SIZE_D1 1440
61 56
62/* Number of decoders and encoders */ 57/* Number of decoders and encoders */
@@ -67,7 +62,6 @@
67 62
68/* Max number of inputs by card */ 63/* Max number of inputs by card */
69#define MAX_CX25821_INPUT 8 64#define MAX_CX25821_INPUT 8
70#define INPUT(nr) (&cx25821_boards[dev->board].input[nr])
71#define RESOURCE_VIDEO0 1 65#define RESOURCE_VIDEO0 1
72#define RESOURCE_VIDEO1 2 66#define RESOURCE_VIDEO1 2
73#define RESOURCE_VIDEO2 4 67#define RESOURCE_VIDEO2 4
@@ -80,7 +74,6 @@
80#define RESOURCE_VIDEO9 512 74#define RESOURCE_VIDEO9 512
81#define RESOURCE_VIDEO10 1024 75#define RESOURCE_VIDEO10 1024
82#define RESOURCE_VIDEO11 2048 76#define RESOURCE_VIDEO11 2048
83#define RESOURCE_VIDEO_IOCTL 4096
84 77
85#define BUFFER_TIMEOUT (HZ) /* 0.5 seconds */ 78#define BUFFER_TIMEOUT (HZ) /* 0.5 seconds */
86 79
@@ -97,7 +90,6 @@
97#define CX25821_BOARD_CONEXANT_ATHENA10 1 90#define CX25821_BOARD_CONEXANT_ATHENA10 1
98#define MAX_VID_CHANNEL_NUM 12 91#define MAX_VID_CHANNEL_NUM 12
99#define VID_CHANNEL_NUM 8 92#define VID_CHANNEL_NUM 8
100#define CX25821_NR_INPUT 2
101 93
102struct cx25821_fmt { 94struct cx25821_fmt {
103 char *name; 95 char *name;
@@ -107,14 +99,6 @@ struct cx25821_fmt {
107 u32 cxformat; 99 u32 cxformat;
108}; 100};
109 101
110struct cx25821_ctrl {
111 struct v4l2_queryctrl v;
112 u32 off;
113 u32 reg;
114 u32 mask;
115 u32 shift;
116};
117
118struct cx25821_tvnorm { 102struct cx25821_tvnorm {
119 char *name; 103 char *name;
120 v4l2_std_id id; 104 v4l2_std_id id;
@@ -122,40 +106,6 @@ struct cx25821_tvnorm {
122 u32 cxoformat; 106 u32 cxoformat;
123}; 107};
124 108
125struct cx25821_fh {
126 struct cx25821_dev *dev;
127 enum v4l2_buf_type type;
128 int radio;
129 u32 resources;
130
131 enum v4l2_priority prio;
132
133 /* video overlay */
134 struct v4l2_window win;
135 struct v4l2_clip *clips;
136 unsigned int nclips;
137
138 /* video capture */
139 struct cx25821_fmt *fmt;
140 unsigned int width, height;
141 int channel_id;
142
143 /* vbi capture */
144 struct videobuf_queue vidq;
145 struct videobuf_queue vbiq;
146
147 /* H264 Encoder specifics ONLY */
148 struct videobuf_queue mpegq;
149 atomic_t v4l_reading;
150};
151
152enum cx25821_itype {
153 CX25821_VMUX_COMPOSITE = 1,
154 CX25821_VMUX_SVIDEO,
155 CX25821_VMUX_DEBUG,
156 CX25821_RADIO,
157};
158
159enum cx25821_src_sel_type { 109enum cx25821_src_sel_type {
160 CX25821_SRC_SEL_EXT_656_VIDEO = 0, 110 CX25821_SRC_SEL_EXT_656_VIDEO = 0,
161 CX25821_SRC_SEL_PARALLEL_MPEG_VIDEO 111 CX25821_SRC_SEL_PARALLEL_MPEG_VIDEO
@@ -169,16 +119,10 @@ struct cx25821_buffer {
169 /* cx25821 specific */ 119 /* cx25821 specific */
170 unsigned int bpl; 120 unsigned int bpl;
171 struct btcx_riscmem risc; 121 struct btcx_riscmem risc;
172 struct cx25821_fmt *fmt; 122 const struct cx25821_fmt *fmt;
173 u32 count; 123 u32 count;
174}; 124};
175 125
176struct cx25821_input {
177 enum cx25821_itype type;
178 unsigned int vmux;
179 u32 gpio0, gpio1, gpio2, gpio3;
180};
181
182enum port { 126enum port {
183 CX25821_UNDEFINED = 0, 127 CX25821_UNDEFINED = 0,
184 CX25821_RAW, 128 CX25821_RAW,
@@ -190,19 +134,8 @@ struct cx25821_board {
190 enum port porta; 134 enum port porta;
191 enum port portb; 135 enum port portb;
192 enum port portc; 136 enum port portc;
193 unsigned int tuner_type;
194 unsigned int radio_type;
195 unsigned char tuner_addr;
196 unsigned char radio_addr;
197 137
198 u32 clk_freq; 138 u32 clk_freq;
199 struct cx25821_input input[CX25821_NR_INPUT];
200};
201
202struct cx25821_subid {
203 u16 subvendor;
204 u16 subdevice;
205 u32 card;
206}; 139};
207 140
208struct cx25821_i2c { 141struct cx25821_i2c {
@@ -234,34 +167,70 @@ struct cx25821_dmaqueue {
234 167
235struct cx25821_data { 168struct cx25821_data {
236 struct cx25821_dev *dev; 169 struct cx25821_dev *dev;
237 struct sram_channel *channel; 170 const struct sram_channel *channel;
171};
172
173struct cx25821_dev;
174
175struct 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;
200 int is_60hz;
201 int _frame_index;
202 int cur_frame_index;
203 int curpos;
204 wait_queue_head_t waitq;
238}; 205};
239 206
240struct cx25821_channel { 207struct cx25821_channel {
241 struct v4l2_prio_state prio; 208 unsigned id;
209 struct cx25821_dev *dev;
210 struct v4l2_fh *streaming_fh;
242 211
243 int ctl_bright; 212 struct v4l2_ctrl_handler hdl;
244 int ctl_contrast;
245 int ctl_hue;
246 int ctl_saturation;
247 struct cx25821_data timeout_data; 213 struct cx25821_data timeout_data;
248 214
249 struct video_device *video_dev; 215 struct video_device vdev;
250 struct cx25821_dmaqueue vidq; 216 struct cx25821_dmaqueue dma_vidq;
251 217 struct videobuf_queue vidq;
252 struct sram_channel *sram_channels;
253 218
254 struct mutex lock; 219 const struct sram_channel *sram_channels;
255 int resources;
256 220
221 const struct cx25821_fmt *fmt;
222 unsigned int width, height;
257 int pixel_formats; 223 int pixel_formats;
258 int use_cif_resolution; 224 int use_cif_resolution;
259 int cif_width; 225 int cif_width;
226
227 /* video output data for the video output channel */
228 struct cx25821_video_out_data *out;
260}; 229};
261 230
231struct snd_card;
232
262struct cx25821_dev { 233struct cx25821_dev {
263 struct list_head devlist;
264 atomic_t refcount;
265 struct v4l2_device v4l2_dev; 234 struct v4l2_device v4l2_dev;
266 235
267 /* pci stuff */ 236 /* pci stuff */
@@ -273,6 +242,8 @@ struct cx25821_dev {
273 u8 __iomem *bmmio; 242 u8 __iomem *bmmio;
274 int pci_irqmask; 243 int pci_irqmask;
275 int hwrevision; 244 int hwrevision;
245 /* used by cx25821-alsa */
246 struct snd_card *card;
276 247
277 u32 clk_freq; 248 u32 clk_freq;
278 249
@@ -289,17 +260,8 @@ struct cx25821_dev {
289 char name[32]; 260 char name[32];
290 261
291 /* Analog video */ 262 /* Analog video */
292 u32 resources;
293 unsigned int input; 263 unsigned int input;
294 u32 tvaudio;
295 v4l2_std_id tvnorm; 264 v4l2_std_id tvnorm;
296 unsigned int tuner_type;
297 unsigned char tuner_addr;
298 unsigned int radio_type;
299 unsigned char radio_addr;
300 unsigned int has_radio;
301 unsigned int videc_type;
302 unsigned char videc_addr;
303 unsigned short _max_num_decoders; 265 unsigned short _max_num_decoders;
304 266
305 /* Analog Audio Upstream */ 267 /* Analog Audio Upstream */
@@ -323,132 +285,26 @@ struct cx25821_dev {
323 __le32 *_audiodata_buf_virt_addr; 285 __le32 *_audiodata_buf_virt_addr;
324 dma_addr_t _audiodata_buf_phys_addr; 286 dma_addr_t _audiodata_buf_phys_addr;
325 char *_audiofilename; 287 char *_audiofilename;
326
327 /* V4l */
328 u32 freq;
329 struct video_device *vbi_dev;
330 struct video_device *radio_dev;
331 struct video_device *ioctl_dev;
332
333 spinlock_t slock;
334
335 /* Video Upstream */
336 int _line_size;
337 int _prog_cnt;
338 int _pixel_format;
339 int _is_first_frame;
340 int _is_running;
341 int _file_status;
342 int _lines_count;
343 int _frame_count;
344 int _channel_upstream_select;
345 unsigned int _risc_size;
346
347 __le32 *_dma_virt_start_addr;
348 __le32 *_dma_virt_addr;
349 dma_addr_t _dma_phys_addr;
350 dma_addr_t _dma_phys_start_addr;
351
352 unsigned int _data_buf_size;
353 __le32 *_data_buf_virt_addr;
354 dma_addr_t _data_buf_phys_addr;
355 char *_filename;
356 char *_defaultname;
357
358 int _line_size_ch2;
359 int _prog_cnt_ch2;
360 int _pixel_format_ch2;
361 int _is_first_frame_ch2;
362 int _is_running_ch2;
363 int _file_status_ch2;
364 int _lines_count_ch2;
365 int _frame_count_ch2;
366 int _channel2_upstream_select;
367 unsigned int _risc_size_ch2;
368
369 __le32 *_dma_virt_start_addr_ch2;
370 __le32 *_dma_virt_addr_ch2;
371 dma_addr_t _dma_phys_addr_ch2;
372 dma_addr_t _dma_phys_start_addr_ch2;
373
374 unsigned int _data_buf_size_ch2;
375 __le32 *_data_buf_virt_addr_ch2;
376 dma_addr_t _data_buf_phys_addr_ch2;
377 char *_filename_ch2;
378 char *_defaultname_ch2;
379
380 /* MPEG Encoder ONLY settings */
381 u32 cx23417_mailbox;
382 struct cx2341x_mpeg_params mpeg_params;
383 struct video_device *v4l_device;
384 atomic_t v4l_reader_count;
385 struct cx25821_tvnorm encodernorm;
386
387 u32 upstream_riscbuf_size;
388 u32 upstream_databuf_size;
389 u32 upstream_riscbuf_size_ch2;
390 u32 upstream_databuf_size_ch2;
391 u32 audio_upstream_riscbuf_size; 288 u32 audio_upstream_riscbuf_size;
392 u32 audio_upstream_databuf_size; 289 u32 audio_upstream_databuf_size;
393 int _isNTSC;
394 int _frame_index;
395 int _audioframe_index; 290 int _audioframe_index;
396 struct workqueue_struct *_irq_queues;
397 struct work_struct _irq_work_entry;
398 struct workqueue_struct *_irq_queues_ch2;
399 struct work_struct _irq_work_entry_ch2;
400 struct workqueue_struct *_irq_audio_queues; 291 struct workqueue_struct *_irq_audio_queues;
401 struct work_struct _audio_work_entry; 292 struct work_struct _audio_work_entry;
402 char *input_filename;
403 char *input_filename_ch2;
404 int _frame_index_ch2;
405 int _isNTSC_ch2;
406 char *vid_stdname_ch2;
407 int pixel_format_ch2;
408 int channel_select_ch2;
409 int command_ch2;
410 char *input_audiofilename; 293 char *input_audiofilename;
411 char *vid_stdname;
412 int pixel_format;
413 int channel_select;
414 int command;
415 int channel_opened;
416};
417 294
418struct upstream_user_struct { 295 /* V4l */
419 char *input_filename; 296 spinlock_t slock;
420 char *vid_stdname;
421 int pixel_format;
422 int channel_select;
423 int command;
424};
425 297
426struct downstream_user_struct { 298 /* Video Upstream */
427 char *vid_stdname; 299 struct cx25821_video_out_data vid_out_data[2];
428 int pixel_format;
429 int cif_resolution_enable;
430 int cif_width;
431 int decoder_select;
432 int command;
433 int reg_address;
434 int reg_data;
435}; 300};
436 301
437extern struct upstream_user_struct *up_data;
438
439static inline struct cx25821_dev *get_cx25821(struct v4l2_device *v4l2_dev) 302static inline struct cx25821_dev *get_cx25821(struct v4l2_device *v4l2_dev)
440{ 303{
441 return container_of(v4l2_dev, struct cx25821_dev, v4l2_dev); 304 return container_of(v4l2_dev, struct cx25821_dev, v4l2_dev);
442} 305}
443 306
444#define cx25821_call_all(dev, o, f, args...) \
445 v4l2_device_call_all(&dev->v4l2_dev, 0, o, f, ##args)
446
447extern struct list_head cx25821_devlist;
448extern struct mutex cx25821_devlist_mutex;
449
450extern struct cx25821_board cx25821_boards[]; 307extern struct cx25821_board cx25821_boards[];
451extern struct cx25821_subid cx25821_subids[];
452 308
453#define SRAM_CH00 0 /* Video A */ 309#define SRAM_CH00 0 /* Video A */
454#define SRAM_CH01 1 /* Video B */ 310#define SRAM_CH01 1 /* Video B */
@@ -467,7 +323,6 @@ extern struct cx25821_subid cx25821_subids[];
467#define VID_UPSTREAM_SRAM_CHANNEL_I SRAM_CH09 323#define VID_UPSTREAM_SRAM_CHANNEL_I SRAM_CH09
468#define VID_UPSTREAM_SRAM_CHANNEL_J SRAM_CH10 324#define VID_UPSTREAM_SRAM_CHANNEL_J SRAM_CH10
469#define AUDIO_UPSTREAM_SRAM_CHANNEL_B SRAM_CH11 325#define AUDIO_UPSTREAM_SRAM_CHANNEL_B SRAM_CH11
470#define VIDEO_IOCTL_CH 11
471 326
472struct sram_channel { 327struct sram_channel {
473 char *name; 328 char *name;
@@ -503,10 +358,8 @@ struct sram_channel {
503 u32 jumponly; 358 u32 jumponly;
504 u32 irq_bit; 359 u32 irq_bit;
505}; 360};
506extern struct sram_channel cx25821_sram_channels[];
507 361
508#define STATUS_SUCCESS 0 362extern const struct sram_channel cx25821_sram_channels[];
509#define STATUS_UNSUCCESSFUL -1
510 363
511#define cx_read(reg) readl(dev->lmmio + ((reg)>>2)) 364#define cx_read(reg) readl(dev->lmmio + ((reg)>>2))
512#define cx_write(reg, value) writel((value), dev->lmmio + ((reg)>>2)) 365#define cx_write(reg, value) writel((value), dev->lmmio + ((reg)>>2))
@@ -529,8 +382,6 @@ extern struct sram_channel cx25821_sram_channels[];
529 pr_info("(%d): " fmt, dev->board, ##args) 382 pr_info("(%d): " fmt, dev->board, ##args)
530 383
531extern int cx25821_i2c_register(struct cx25821_i2c *bus); 384extern int cx25821_i2c_register(struct cx25821_i2c *bus);
532extern void cx25821_card_setup(struct cx25821_dev *dev);
533extern int cx25821_ir_init(struct cx25821_dev *dev);
534extern int cx25821_i2c_read(struct cx25821_i2c *bus, u16 reg_addr, int *value); 385extern int cx25821_i2c_read(struct cx25821_i2c *bus, u16 reg_addr, int *value);
535extern int cx25821_i2c_write(struct cx25821_i2c *bus, u16 reg_addr, int value); 386extern int cx25821_i2c_write(struct cx25821_i2c *bus, u16 reg_addr, int value);
536extern int cx25821_i2c_unregister(struct cx25821_i2c *bus); 387extern int cx25821_i2c_unregister(struct cx25821_i2c *bus);
@@ -551,7 +402,7 @@ extern int medusa_set_saturation(struct cx25821_dev *dev, int saturation,
551 int decoder); 402 int decoder);
552 403
553extern int cx25821_sram_channel_setup(struct cx25821_dev *dev, 404extern int cx25821_sram_channel_setup(struct cx25821_dev *dev,
554 struct sram_channel *ch, unsigned int bpl, 405 const struct sram_channel *ch, unsigned int bpl,
555 u32 risc); 406 u32 risc);
556 407
557extern int cx25821_risc_buffer(struct pci_dev *pci, struct btcx_riscmem *risc, 408extern int cx25821_risc_buffer(struct pci_dev *pci, struct btcx_riscmem *risc,
@@ -570,46 +421,31 @@ extern void cx25821_free_buffer(struct videobuf_queue *q,
570extern int cx25821_risc_stopper(struct pci_dev *pci, struct btcx_riscmem *risc, 421extern int cx25821_risc_stopper(struct pci_dev *pci, struct btcx_riscmem *risc,
571 u32 reg, u32 mask, u32 value); 422 u32 reg, u32 mask, u32 value);
572extern void cx25821_sram_channel_dump(struct cx25821_dev *dev, 423extern void cx25821_sram_channel_dump(struct cx25821_dev *dev,
573 struct sram_channel *ch); 424 const struct sram_channel *ch);
574extern void cx25821_sram_channel_dump_audio(struct cx25821_dev *dev, 425extern void cx25821_sram_channel_dump_audio(struct cx25821_dev *dev,
575 struct sram_channel *ch); 426 const struct sram_channel *ch);
576 427
577extern struct cx25821_dev *cx25821_dev_get(struct pci_dev *pci); 428extern struct cx25821_dev *cx25821_dev_get(struct pci_dev *pci);
578extern void cx25821_print_irqbits(char *name, char *tag, char **strings, 429extern void cx25821_print_irqbits(char *name, char *tag, char **strings,
579 int len, u32 bits, u32 mask); 430 int len, u32 bits, u32 mask);
580extern void cx25821_dev_unregister(struct cx25821_dev *dev); 431extern void cx25821_dev_unregister(struct cx25821_dev *dev);
581extern int cx25821_sram_channel_setup_audio(struct cx25821_dev *dev, 432extern int cx25821_sram_channel_setup_audio(struct cx25821_dev *dev,
582 struct sram_channel *ch, 433 const struct sram_channel *ch,
583 unsigned int bpl, u32 risc); 434 unsigned int bpl, u32 risc);
584 435
585extern int cx25821_vidupstream_init_ch1(struct cx25821_dev *dev, 436extern int cx25821_vidupstream_init(struct cx25821_channel *chan, int pixel_format);
586 int channel_select, int pixel_format);
587extern int cx25821_vidupstream_init_ch2(struct cx25821_dev *dev,
588 int channel_select, int pixel_format);
589extern int cx25821_audio_upstream_init(struct cx25821_dev *dev, 437extern int cx25821_audio_upstream_init(struct cx25821_dev *dev,
590 int channel_select); 438 int channel_select);
591extern void cx25821_free_mem_upstream_ch1(struct cx25821_dev *dev); 439extern int cx25821_write_frame(struct cx25821_channel *chan,
592extern void cx25821_free_mem_upstream_ch2(struct cx25821_dev *dev); 440 const char __user *data, size_t count);
441extern void cx25821_free_mem_upstream(struct cx25821_channel *chan);
593extern void cx25821_free_mem_upstream_audio(struct cx25821_dev *dev); 442extern void cx25821_free_mem_upstream_audio(struct cx25821_dev *dev);
594extern void cx25821_start_upstream_video_ch1(struct cx25821_dev *dev, 443extern void cx25821_stop_upstream_video(struct cx25821_channel *chan);
595 struct upstream_user_struct
596 *up_data);
597extern void cx25821_start_upstream_video_ch2(struct cx25821_dev *dev,
598 struct upstream_user_struct
599 *up_data);
600extern void cx25821_start_upstream_audio(struct cx25821_dev *dev,
601 struct upstream_user_struct *up_data);
602extern void cx25821_stop_upstream_video_ch1(struct cx25821_dev *dev);
603extern void cx25821_stop_upstream_video_ch2(struct cx25821_dev *dev);
604extern void cx25821_stop_upstream_audio(struct cx25821_dev *dev); 444extern void cx25821_stop_upstream_audio(struct cx25821_dev *dev);
605extern int cx25821_sram_channel_setup_upstream(struct cx25821_dev *dev, 445extern int cx25821_sram_channel_setup_upstream(struct cx25821_dev *dev,
606 struct sram_channel *ch, 446 const struct sram_channel *ch,
607 unsigned int bpl, u32 risc); 447 unsigned int bpl, u32 risc);
608extern void cx25821_set_pixel_format(struct cx25821_dev *dev, int channel, 448extern void cx25821_set_pixel_format(struct cx25821_dev *dev, int channel,
609 u32 format); 449 u32 format);
610extern void cx25821_videoioctl_unregister(struct cx25821_dev *dev); 450
611extern struct video_device *cx25821_vdev_init(struct cx25821_dev *dev,
612 struct pci_dev *pci,
613 struct video_device *template,
614 char *type);
615#endif 451#endif