diff options
Diffstat (limited to 'drivers/media/video/em28xx/em28xx.h')
-rw-r--r-- | drivers/media/video/em28xx/em28xx.h | 148 |
1 files changed, 110 insertions, 38 deletions
diff --git a/drivers/media/video/em28xx/em28xx.h b/drivers/media/video/em28xx/em28xx.h index 5956e9b3062f..b5eddc26388e 100644 --- a/drivers/media/video/em28xx/em28xx.h +++ b/drivers/media/video/em28xx/em28xx.h | |||
@@ -67,7 +67,6 @@ | |||
67 | #define EM2820_BOARD_HERCULES_SMART_TV_USB2 26 | 67 | #define EM2820_BOARD_HERCULES_SMART_TV_USB2 26 |
68 | #define EM2820_BOARD_PINNACLE_USB_2_FM1216ME 27 | 68 | #define EM2820_BOARD_PINNACLE_USB_2_FM1216ME 27 |
69 | #define EM2820_BOARD_LEADTEK_WINFAST_USBII_DELUXE 28 | 69 | #define EM2820_BOARD_LEADTEK_WINFAST_USBII_DELUXE 28 |
70 | #define EM2820_BOARD_PINNACLE_DVC_100 29 | ||
71 | #define EM2820_BOARD_VIDEOLOGY_20K14XUSB 30 | 70 | #define EM2820_BOARD_VIDEOLOGY_20K14XUSB 30 |
72 | #define EM2821_BOARD_USBGEAR_VD204 31 | 71 | #define EM2821_BOARD_USBGEAR_VD204 31 |
73 | #define EM2821_BOARD_SUPERCOMP_USB_2 32 | 72 | #define EM2821_BOARD_SUPERCOMP_USB_2 32 |
@@ -97,6 +96,8 @@ | |||
97 | #define EM2882_BOARD_PINNACLE_HYBRID_PRO 56 | 96 | #define EM2882_BOARD_PINNACLE_HYBRID_PRO 56 |
98 | #define EM2883_BOARD_KWORLD_HYBRID_A316 57 | 97 | #define EM2883_BOARD_KWORLD_HYBRID_A316 57 |
99 | #define EM2820_BOARD_COMPRO_VIDEOMATE_FORYOU 58 | 98 | #define EM2820_BOARD_COMPRO_VIDEOMATE_FORYOU 58 |
99 | #define EM2883_BOARD_HAUPPAUGE_WINTV_HVR_850 60 | ||
100 | #define EM2820_BOARD_PROLINK_PLAYTV_BOX4_USB2 61 | ||
100 | 101 | ||
101 | /* Limits minimum and default number of buffers */ | 102 | /* Limits minimum and default number of buffers */ |
102 | #define EM28XX_MIN_BUF 4 | 103 | #define EM28XX_MIN_BUF 4 |
@@ -159,7 +160,7 @@ | |||
159 | #define EM2800_I2C_WRITE_TIMEOUT 20 | 160 | #define EM2800_I2C_WRITE_TIMEOUT 20 |
160 | 161 | ||
161 | enum em28xx_mode { | 162 | enum em28xx_mode { |
162 | EM28XX_MODE_UNDEFINED, | 163 | EM28XX_SUSPEND, |
163 | EM28XX_ANALOG_MODE, | 164 | EM28XX_ANALOG_MODE, |
164 | EM28XX_DIGITAL_MODE, | 165 | EM28XX_DIGITAL_MODE, |
165 | }; | 166 | }; |
@@ -207,9 +208,12 @@ struct em28xx_usb_isoc_ctl { | |||
207 | 208 | ||
208 | }; | 209 | }; |
209 | 210 | ||
211 | /* Struct to enumberate video formats */ | ||
210 | struct em28xx_fmt { | 212 | struct em28xx_fmt { |
211 | char *name; | 213 | char *name; |
212 | u32 fourcc; /* v4l2 format id */ | 214 | u32 fourcc; /* v4l2 format id */ |
215 | int depth; | ||
216 | int reg; | ||
213 | }; | 217 | }; |
214 | 218 | ||
215 | /* buffer for one video frame */ | 219 | /* buffer for one video frame */ |
@@ -255,54 +259,105 @@ enum enum28xx_itype { | |||
255 | EM28XX_RADIO, | 259 | EM28XX_RADIO, |
256 | }; | 260 | }; |
257 | 261 | ||
262 | enum em28xx_ac97_mode { | ||
263 | EM28XX_NO_AC97 = 0, | ||
264 | EM28XX_AC97_EM202, | ||
265 | EM28XX_AC97_SIGMATEL, | ||
266 | EM28XX_AC97_OTHER, | ||
267 | }; | ||
268 | |||
269 | struct em28xx_audio_mode { | ||
270 | enum em28xx_ac97_mode ac97; | ||
271 | |||
272 | u16 ac97_feat; | ||
273 | u32 ac97_vendor_id; | ||
274 | |||
275 | unsigned int has_audio:1; | ||
276 | |||
277 | unsigned int i2s_3rates:1; | ||
278 | unsigned int i2s_5rates:1; | ||
279 | }; | ||
280 | |||
281 | /* em28xx has two audio inputs: tuner and line in. | ||
282 | However, on most devices, an auxiliary AC97 codec device is used. | ||
283 | The AC97 device may have several different inputs and outputs, | ||
284 | depending on their model. So, it is possible to use AC97 mixer to | ||
285 | address more than two different entries. | ||
286 | */ | ||
258 | enum em28xx_amux { | 287 | enum em28xx_amux { |
259 | EM28XX_AMUX_VIDEO, | 288 | /* This is the only entry for em28xx tuner input */ |
260 | EM28XX_AMUX_LINE_IN, | 289 | EM28XX_AMUX_VIDEO, /* em28xx tuner, AC97 mixer Video */ |
261 | EM28XX_AMUX_AC97_VIDEO, | 290 | |
262 | EM28XX_AMUX_AC97_LINE_IN, | 291 | EM28XX_AMUX_LINE_IN, /* AC97 mixer Line In */ |
292 | |||
293 | /* Some less-common mixer setups */ | ||
294 | EM28XX_AMUX_VIDEO2, /* em28xx Line in, AC97 mixer Video */ | ||
295 | EM28XX_AMUX_PHONE, | ||
296 | EM28XX_AMUX_MIC, | ||
297 | EM28XX_AMUX_CD, | ||
298 | EM28XX_AMUX_AUX, | ||
299 | EM28XX_AMUX_PCM_OUT, | ||
300 | }; | ||
301 | |||
302 | enum em28xx_aout { | ||
303 | EM28XX_AOUT_MASTER = 1 << 0, | ||
304 | EM28XX_AOUT_LINE = 1 << 1, | ||
305 | EM28XX_AOUT_MONO = 1 << 2, | ||
306 | EM28XX_AOUT_LFE = 1 << 3, | ||
307 | EM28XX_AOUT_SURR = 1 << 4, | ||
308 | }; | ||
309 | |||
310 | struct em28xx_reg_seq { | ||
311 | int reg; | ||
312 | unsigned char val, mask; | ||
313 | int sleep; | ||
263 | }; | 314 | }; |
264 | 315 | ||
265 | struct em28xx_input { | 316 | struct em28xx_input { |
266 | enum enum28xx_itype type; | 317 | enum enum28xx_itype type; |
267 | unsigned int vmux; | 318 | unsigned int vmux; |
268 | enum em28xx_amux amux; | 319 | enum em28xx_amux amux; |
320 | enum em28xx_aout aout; | ||
321 | struct em28xx_reg_seq *gpio; | ||
269 | }; | 322 | }; |
270 | 323 | ||
271 | #define INPUT(nr) (&em28xx_boards[dev->model].input[nr]) | 324 | #define INPUT(nr) (&em28xx_boards[dev->model].input[nr]) |
272 | 325 | ||
273 | enum em28xx_decoder { | 326 | enum em28xx_decoder { |
327 | EM28XX_NODECODER, | ||
274 | EM28XX_TVP5150, | 328 | EM28XX_TVP5150, |
275 | EM28XX_SAA7113, | 329 | EM28XX_SAA711X, |
276 | EM28XX_SAA7114 | ||
277 | }; | ||
278 | |||
279 | struct em28xx_reg_seq { | ||
280 | int reg; | ||
281 | unsigned char val, mask; | ||
282 | int sleep; | ||
283 | }; | 330 | }; |
284 | 331 | ||
285 | struct em28xx_board { | 332 | struct em28xx_board { |
286 | char *name; | 333 | char *name; |
287 | int vchannels; | 334 | int vchannels; |
288 | int tuner_type; | 335 | int tuner_type; |
336 | int tuner_addr; | ||
289 | 337 | ||
290 | /* i2c flags */ | 338 | /* i2c flags */ |
291 | unsigned int tda9887_conf; | 339 | unsigned int tda9887_conf; |
292 | 340 | ||
341 | /* GPIO sequences */ | ||
342 | struct em28xx_reg_seq *dvb_gpio; | ||
343 | struct em28xx_reg_seq *suspend_gpio; | ||
344 | struct em28xx_reg_seq *tuner_gpio; | ||
345 | |||
293 | unsigned int is_em2800:1; | 346 | unsigned int is_em2800:1; |
294 | unsigned int has_msp34xx:1; | 347 | unsigned int has_msp34xx:1; |
295 | unsigned int mts_firmware:1; | 348 | unsigned int mts_firmware:1; |
296 | unsigned int has_12mhz_i2s:1; | ||
297 | unsigned int max_range_640_480:1; | 349 | unsigned int max_range_640_480:1; |
298 | unsigned int has_dvb:1; | 350 | unsigned int has_dvb:1; |
299 | unsigned int has_snapshot_button:1; | 351 | unsigned int has_snapshot_button:1; |
300 | unsigned int valid:1; | 352 | unsigned int valid:1; |
301 | 353 | ||
354 | unsigned char xclk, i2c_speed; | ||
355 | |||
302 | enum em28xx_decoder decoder; | 356 | enum em28xx_decoder decoder; |
303 | 357 | ||
304 | struct em28xx_input input[MAX_EM28XX_INPUT]; | 358 | struct em28xx_input input[MAX_EM28XX_INPUT]; |
305 | struct em28xx_input radio; | 359 | struct em28xx_input radio; |
360 | IR_KEYTAB_TYPE *ir_codes; | ||
306 | }; | 361 | }; |
307 | 362 | ||
308 | struct em28xx_eeprom { | 363 | struct em28xx_eeprom { |
@@ -369,32 +424,26 @@ struct em28xx { | |||
369 | char name[30]; /* name (including minor) of the device */ | 424 | char name[30]; /* name (including minor) of the device */ |
370 | int model; /* index in the device_data struct */ | 425 | int model; /* index in the device_data struct */ |
371 | int devno; /* marks the number of this device */ | 426 | int devno; /* marks the number of this device */ |
372 | unsigned int is_em2800:1; | 427 | enum em28xx_chip_id chip_id; |
373 | unsigned int has_msp34xx:1; | 428 | |
374 | unsigned int has_tda9887:1; | 429 | struct em28xx_board board; |
430 | |||
375 | unsigned int stream_on:1; /* Locks streams */ | 431 | unsigned int stream_on:1; /* Locks streams */ |
376 | unsigned int has_audio_class:1; | 432 | unsigned int has_audio_class:1; |
377 | unsigned int has_12mhz_i2s:1; | 433 | unsigned int has_alsa_audio:1; |
378 | unsigned int max_range_640_480:1; | ||
379 | unsigned int has_dvb:1; | ||
380 | unsigned int has_snapshot_button:1; | ||
381 | unsigned int valid:1; /* report for validated boards */ | ||
382 | 434 | ||
383 | /* Some older em28xx chips needs a waiting time after writing */ | 435 | struct em28xx_fmt *format; |
384 | unsigned int wait_after_write; | ||
385 | 436 | ||
386 | /* GPIO sequences for analog and digital mode */ | 437 | struct em28xx_IR *ir; |
387 | struct em28xx_reg_seq *analog_gpio, *digital_gpio; | ||
388 | 438 | ||
389 | /* GPIO sequences for tuner callbacks */ | 439 | /* Some older em28xx chips needs a waiting time after writing */ |
390 | struct em28xx_reg_seq *tun_analog_gpio, *tun_digital_gpio; | 440 | unsigned int wait_after_write; |
391 | 441 | ||
392 | int video_inputs; /* number of video inputs */ | ||
393 | struct list_head devlist; | 442 | struct list_head devlist; |
394 | 443 | ||
395 | u32 i2s_speed; /* I2S speed for audio digital stream */ | 444 | u32 i2s_speed; /* I2S speed for audio digital stream */ |
396 | 445 | ||
397 | enum em28xx_decoder decoder; | 446 | struct em28xx_audio_mode audio_mode; |
398 | 447 | ||
399 | int tuner_type; /* type of the tuner */ | 448 | int tuner_type; /* type of the tuner */ |
400 | int tuner_addr; /* tuner address */ | 449 | int tuner_addr; /* tuner address */ |
@@ -409,6 +458,7 @@ struct em28xx { | |||
409 | int ctl_freq; /* selected frequency */ | 458 | int ctl_freq; /* selected frequency */ |
410 | unsigned int ctl_input; /* selected input */ | 459 | unsigned int ctl_input; /* selected input */ |
411 | unsigned int ctl_ainput;/* selected audio input */ | 460 | unsigned int ctl_ainput;/* selected audio input */ |
461 | unsigned int ctl_aoutput;/* selected audio output */ | ||
412 | int mute; | 462 | int mute; |
413 | int volume; | 463 | int volume; |
414 | /* frame properties */ | 464 | /* frame properties */ |
@@ -469,6 +519,9 @@ struct em28xx { | |||
469 | 519 | ||
470 | enum em28xx_mode mode; | 520 | enum em28xx_mode mode; |
471 | 521 | ||
522 | /* register numbers for GPO/GPIO registers */ | ||
523 | u16 reg_gpo_num, reg_gpio_num; | ||
524 | |||
472 | /* Caches GPO and GPIO registers */ | 525 | /* Caches GPO and GPIO registers */ |
473 | unsigned char reg_gpo, reg_gpio; | 526 | unsigned char reg_gpo, reg_gpio; |
474 | 527 | ||
@@ -508,11 +561,17 @@ int em28xx_read_reg(struct em28xx *dev, u16 reg); | |||
508 | int em28xx_write_regs_req(struct em28xx *dev, u8 req, u16 reg, char *buf, | 561 | int em28xx_write_regs_req(struct em28xx *dev, u8 req, u16 reg, char *buf, |
509 | int len); | 562 | int len); |
510 | int em28xx_write_regs(struct em28xx *dev, u16 reg, char *buf, int len); | 563 | int em28xx_write_regs(struct em28xx *dev, u16 reg, char *buf, int len); |
564 | int em28xx_write_reg(struct em28xx *dev, u16 reg, u8 val); | ||
565 | |||
566 | int em28xx_read_ac97(struct em28xx *dev, u8 reg); | ||
567 | int em28xx_write_ac97(struct em28xx *dev, u8 reg, u16 val); | ||
568 | |||
511 | int em28xx_audio_analog_set(struct em28xx *dev); | 569 | int em28xx_audio_analog_set(struct em28xx *dev); |
570 | int em28xx_audio_setup(struct em28xx *dev); | ||
512 | 571 | ||
513 | int em28xx_colorlevels_set_default(struct em28xx *dev); | 572 | int em28xx_colorlevels_set_default(struct em28xx *dev); |
514 | int em28xx_capture_start(struct em28xx *dev, int start); | 573 | int em28xx_capture_start(struct em28xx *dev, int start); |
515 | int em28xx_outfmt_set_yuv422(struct em28xx *dev); | 574 | int em28xx_set_outfmt(struct em28xx *dev); |
516 | int em28xx_resolution_set(struct em28xx *dev); | 575 | int em28xx_resolution_set(struct em28xx *dev); |
517 | int em28xx_set_alternate(struct em28xx *dev); | 576 | int em28xx_set_alternate(struct em28xx *dev); |
518 | int em28xx_init_isoc(struct em28xx *dev, int max_packets, | 577 | int em28xx_init_isoc(struct em28xx *dev, int max_packets, |
@@ -521,10 +580,20 @@ int em28xx_init_isoc(struct em28xx *dev, int max_packets, | |||
521 | void em28xx_uninit_isoc(struct em28xx *dev); | 580 | void em28xx_uninit_isoc(struct em28xx *dev); |
522 | int em28xx_set_mode(struct em28xx *dev, enum em28xx_mode set_mode); | 581 | int em28xx_set_mode(struct em28xx *dev, enum em28xx_mode set_mode); |
523 | int em28xx_gpio_set(struct em28xx *dev, struct em28xx_reg_seq *gpio); | 582 | int em28xx_gpio_set(struct em28xx *dev, struct em28xx_reg_seq *gpio); |
524 | 583 | void em28xx_wake_i2c(struct em28xx *dev); | |
525 | /* Provided by em28xx-video.c */ | 584 | void em28xx_remove_from_devlist(struct em28xx *dev); |
585 | void em28xx_add_into_devlist(struct em28xx *dev); | ||
586 | struct em28xx *em28xx_get_device(struct inode *inode, | ||
587 | enum v4l2_buf_type *fh_type, | ||
588 | int *has_radio); | ||
526 | int em28xx_register_extension(struct em28xx_ops *dev); | 589 | int em28xx_register_extension(struct em28xx_ops *dev); |
527 | void em28xx_unregister_extension(struct em28xx_ops *dev); | 590 | void em28xx_unregister_extension(struct em28xx_ops *dev); |
591 | void em28xx_init_extension(struct em28xx *dev); | ||
592 | void em28xx_close_extension(struct em28xx *dev); | ||
593 | |||
594 | /* Provided by em28xx-video.c */ | ||
595 | int em28xx_register_analog_devices(struct em28xx *dev); | ||
596 | void em28xx_release_analog_resources(struct em28xx *dev); | ||
528 | 597 | ||
529 | /* Provided by em28xx-cards.c */ | 598 | /* Provided by em28xx-cards.c */ |
530 | extern int em2800_variant_detect(struct usb_device *udev, int model); | 599 | extern int em2800_variant_detect(struct usb_device *udev, int model); |
@@ -535,9 +604,9 @@ extern struct usb_device_id em28xx_id_table[]; | |||
535 | extern const unsigned int em28xx_bcount; | 604 | extern const unsigned int em28xx_bcount; |
536 | void em28xx_set_ir(struct em28xx *dev, struct IR_i2c *ir); | 605 | void em28xx_set_ir(struct em28xx *dev, struct IR_i2c *ir); |
537 | int em28xx_tuner_callback(void *ptr, int component, int command, int arg); | 606 | int em28xx_tuner_callback(void *ptr, int component, int command, int arg); |
607 | void em28xx_release_resources(struct em28xx *dev); | ||
538 | 608 | ||
539 | /* Provided by em28xx-input.c */ | 609 | /* Provided by em28xx-input.c */ |
540 | /* TODO: Check if the standard get_key handlers on ir-common can be used */ | ||
541 | int em28xx_get_key_terratec(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw); | 610 | int em28xx_get_key_terratec(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw); |
542 | int em28xx_get_key_em_haup(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw); | 611 | int em28xx_get_key_em_haup(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw); |
543 | int em28xx_get_key_pinnacle_usb_grey(struct IR_i2c *ir, u32 *ir_key, | 612 | int em28xx_get_key_pinnacle_usb_grey(struct IR_i2c *ir, u32 *ir_key, |
@@ -545,6 +614,9 @@ int em28xx_get_key_pinnacle_usb_grey(struct IR_i2c *ir, u32 *ir_key, | |||
545 | void em28xx_register_snapshot_button(struct em28xx *dev); | 614 | void em28xx_register_snapshot_button(struct em28xx *dev); |
546 | void em28xx_deregister_snapshot_button(struct em28xx *dev); | 615 | void em28xx_deregister_snapshot_button(struct em28xx *dev); |
547 | 616 | ||
617 | int em28xx_ir_init(struct em28xx *dev); | ||
618 | int em28xx_ir_fini(struct em28xx *dev); | ||
619 | |||
548 | /* printk macros */ | 620 | /* printk macros */ |
549 | 621 | ||
550 | #define em28xx_err(fmt, arg...) do {\ | 622 | #define em28xx_err(fmt, arg...) do {\ |
@@ -564,7 +636,7 @@ void em28xx_deregister_snapshot_button(struct em28xx *dev); | |||
564 | static inline int em28xx_compression_disable(struct em28xx *dev) | 636 | static inline int em28xx_compression_disable(struct em28xx *dev) |
565 | { | 637 | { |
566 | /* side effect of disabling scaler and mixer */ | 638 | /* side effect of disabling scaler and mixer */ |
567 | return em28xx_write_regs(dev, EM28XX_R26_COMPR, "\x00", 1); | 639 | return em28xx_write_reg(dev, EM28XX_R26_COMPR, 0x00); |
568 | } | 640 | } |
569 | 641 | ||
570 | static inline int em28xx_contrast_get(struct em28xx *dev) | 642 | static inline int em28xx_contrast_get(struct em28xx *dev) |
@@ -636,7 +708,7 @@ static inline int em28xx_gamma_set(struct em28xx *dev, s32 val) | |||
636 | /*FIXME: maxw should be dependent of alt mode */ | 708 | /*FIXME: maxw should be dependent of alt mode */ |
637 | static inline unsigned int norm_maxw(struct em28xx *dev) | 709 | static inline unsigned int norm_maxw(struct em28xx *dev) |
638 | { | 710 | { |
639 | if (dev->max_range_640_480) | 711 | if (dev->board.max_range_640_480) |
640 | return 640; | 712 | return 640; |
641 | else | 713 | else |
642 | return 720; | 714 | return 720; |
@@ -644,7 +716,7 @@ static inline unsigned int norm_maxw(struct em28xx *dev) | |||
644 | 716 | ||
645 | static inline unsigned int norm_maxh(struct em28xx *dev) | 717 | static inline unsigned int norm_maxh(struct em28xx *dev) |
646 | { | 718 | { |
647 | if (dev->max_range_640_480) | 719 | if (dev->board.max_range_640_480) |
648 | return 480; | 720 | return 480; |
649 | else | 721 | else |
650 | return (dev->norm & V4L2_STD_625_50) ? 576 : 480; | 722 | return (dev->norm & V4L2_STD_625_50) ? 576 : 480; |