cx88.h (6f11adc6a5e3378aeb13d9a19c427cbec05805be) | cx88.h (0b6b6302d983236f8b5d6d6602b91a6d1e144896) |
---|---|
1/* 2 * 3 * v4l2 device driver for cx2388x based TV cards 4 * 5 * (c) 2003,04 Gerd Knorr <kraxel@bytesex.org> [SUSE Labs] 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by --- 15 unchanged lines hidden (view full) --- 24#include <linux/i2c-algo-bit.h> 25#include <linux/videodev2.h> 26#include <linux/kdev_t.h> 27 28#include <media/v4l2-device.h> 29#include <media/v4l2-fh.h> 30#include <media/tuner.h> 31#include <media/tveeprom.h> | 1/* 2 * 3 * v4l2 device driver for cx2388x based TV cards 4 * 5 * (c) 2003,04 Gerd Knorr <kraxel@bytesex.org> [SUSE Labs] 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by --- 15 unchanged lines hidden (view full) --- 24#include <linux/i2c-algo-bit.h> 25#include <linux/videodev2.h> 26#include <linux/kdev_t.h> 27 28#include <media/v4l2-device.h> 29#include <media/v4l2-fh.h> 30#include <media/tuner.h> 31#include <media/tveeprom.h> |
32#include <media/videobuf-dma-sg.h> | 32#include <media/videobuf2-dma-sg.h> |
33#include <media/cx2341x.h> | 33#include <media/cx2341x.h> |
34#include <media/videobuf-dvb.h> | 34#include <media/videobuf2-dvb.h> |
35#include <media/ir-kbd-i2c.h> 36#include <media/wm8775.h> 37 38#include "btcx-risc.h" 39#include "cx88-reg.h" 40#include "tuner-xc2028.h" 41 42#include <linux/mutex.h> 43 | 35#include <media/ir-kbd-i2c.h> 36#include <media/wm8775.h> 37 38#include "btcx-risc.h" 39#include "cx88-reg.h" 40#include "tuner-xc2028.h" 41 42#include <linux/mutex.h> 43 |
44#define CX88_VERSION "0.0.9" | 44#define CX88_VERSION "1.0.0" |
45 46#define UNSET (-1U) 47 48#define CX88_MAXBOARDS 8 49 50/* Max number of inputs by card */ 51#define MAX_CX88_INPUT 8 52 --- 37 unchanged lines hidden (view full) --- 90 CX8802_DRVCTL_EXCLUSIVE = 2, 91}; 92 93/* ----------------------------------------------------------- */ 94/* tv norms */ 95 96static inline unsigned int norm_maxw(v4l2_std_id norm) 97{ | 45 46#define UNSET (-1U) 47 48#define CX88_MAXBOARDS 8 49 50/* Max number of inputs by card */ 51#define MAX_CX88_INPUT 8 52 --- 37 unchanged lines hidden (view full) --- 90 CX8802_DRVCTL_EXCLUSIVE = 2, 91}; 92 93/* ----------------------------------------------------------- */ 94/* tv norms */ 95 96static inline unsigned int norm_maxw(v4l2_std_id norm) 97{ |
98 return (norm & (V4L2_STD_MN & ~V4L2_STD_PAL_Nc)) ? 720 : 768; | 98 return 720; |
99} 100 101 102static inline unsigned int norm_maxh(v4l2_std_id norm) 103{ | 99} 100 101 102static inline unsigned int norm_maxh(v4l2_std_id norm) 103{ |
104 return (norm & V4L2_STD_625_50) ? 576 : 480; | 104 return (norm & V4L2_STD_525_60) ? 480 : 576; |
105} 106 107/* ----------------------------------------------------------- */ 108/* static data */ 109 110struct cx8800_fmt { 111 const char *name; 112 u32 fourcc; /* v4l2 format id */ --- 196 unchanged lines hidden (view full) --- 309#define RESOURCE_VIDEO 2 310#define RESOURCE_VBI 4 311 312#define BUFFER_TIMEOUT msecs_to_jiffies(2000) 313 314/* buffer for one video frame */ 315struct cx88_buffer { 316 /* common v4l buffer stuff -- must be first */ | 105} 106 107/* ----------------------------------------------------------- */ 108/* static data */ 109 110struct cx8800_fmt { 111 const char *name; 112 u32 fourcc; /* v4l2 format id */ --- 196 unchanged lines hidden (view full) --- 309#define RESOURCE_VIDEO 2 310#define RESOURCE_VBI 4 311 312#define BUFFER_TIMEOUT msecs_to_jiffies(2000) 313 314/* buffer for one video frame */ 315struct cx88_buffer { 316 /* common v4l buffer stuff -- must be first */ |
317 struct videobuf_buffer vb; | 317 struct vb2_buffer vb; 318 struct list_head list; |
318 319 /* cx88 specific */ 320 unsigned int bpl; 321 struct btcx_riscmem risc; 322 u32 count; 323}; 324 325struct cx88_dmaqueue { 326 struct list_head active; | 319 320 /* cx88 specific */ 321 unsigned int bpl; 322 struct btcx_riscmem risc; 323 u32 count; 324}; 325 326struct cx88_dmaqueue { 327 struct list_head active; |
327 struct timer_list timeout; 328 struct btcx_riscmem stopper; | |
329 u32 count; 330}; 331 332struct cx88_core { 333 struct list_head devlist; 334 atomic_t refcount; 335 336 /* board name */ --- 51 unchanged lines hidden (view full) --- 388 389 /* I2C remote data */ 390 struct IR_i2c_init_data init_data; 391 struct wm8775_platform_data wm8775_data; 392 393 struct mutex lock; 394 /* various v4l controls */ 395 u32 freq; | 328 u32 count; 329}; 330 331struct cx88_core { 332 struct list_head devlist; 333 atomic_t refcount; 334 335 /* board name */ --- 51 unchanged lines hidden (view full) --- 387 388 /* I2C remote data */ 389 struct IR_i2c_init_data init_data; 390 struct wm8775_platform_data wm8775_data; 391 392 struct mutex lock; 393 /* various v4l controls */ 394 u32 freq; |
396 int users; 397 int mpeg_users; | |
398 399 /* cx88-video needs to access cx8802 for hybrid tuner pll access. */ 400 struct cx8802_dev *dvbdev; 401 enum cx88_board_type active_type_id; 402 int active_ref; 403 int active_fe_id; 404}; 405 --- 46 unchanged lines hidden (view full) --- 452 }) 453 454struct cx8800_dev; 455struct cx8802_dev; 456 457/* ----------------------------------------------------------- */ 458/* function 0: video stuff */ 459 | 395 396 /* cx88-video needs to access cx8802 for hybrid tuner pll access. */ 397 struct cx8802_dev *dvbdev; 398 enum cx88_board_type active_type_id; 399 int active_ref; 400 int active_fe_id; 401}; 402 --- 46 unchanged lines hidden (view full) --- 449 }) 450 451struct cx8800_dev; 452struct cx8802_dev; 453 454/* ----------------------------------------------------------- */ 455/* function 0: video stuff */ 456 |
460struct cx8800_fh { 461 struct v4l2_fh fh; 462 struct cx8800_dev *dev; 463 unsigned int resources; 464 465 /* video capture */ 466 struct videobuf_queue vidq; 467 468 /* vbi capture */ 469 struct videobuf_queue vbiq; 470}; 471 | |
472struct cx8800_suspend_state { 473 int disabled; 474}; 475 476struct cx8800_dev { 477 struct cx88_core *core; 478 spinlock_t slock; 479 --- 4 unchanged lines hidden (view full) --- 484 struct video_device *radio_dev; 485 486 /* pci i/o */ 487 struct pci_dev *pci; 488 unsigned char pci_rev,pci_lat; 489 490 const struct cx8800_fmt *fmt; 491 unsigned int width, height; | 457struct cx8800_suspend_state { 458 int disabled; 459}; 460 461struct cx8800_dev { 462 struct cx88_core *core; 463 spinlock_t slock; 464 --- 4 unchanged lines hidden (view full) --- 469 struct video_device *radio_dev; 470 471 /* pci i/o */ 472 struct pci_dev *pci; 473 unsigned char pci_rev,pci_lat; 474 475 const struct cx8800_fmt *fmt; 476 unsigned int width, height; |
477 unsigned field; |
|
492 493 /* capture queues */ 494 struct cx88_dmaqueue vidq; | 478 479 /* capture queues */ 480 struct cx88_dmaqueue vidq; |
481 struct vb2_queue vb2_vidq; |
|
495 struct cx88_dmaqueue vbiq; | 482 struct cx88_dmaqueue vbiq; |
483 struct vb2_queue vb2_vbiq; |
|
496 497 /* various v4l controls */ 498 499 /* other global state info */ 500 struct cx8800_suspend_state state; 501}; 502 503/* ----------------------------------------------------------- */ 504/* function 1: audio/alsa stuff */ 505/* =============> moved to cx88-alsa.c <====================== */ 506 507 508/* ----------------------------------------------------------- */ 509/* function 2: mpeg stuff */ 510 | 484 485 /* various v4l controls */ 486 487 /* other global state info */ 488 struct cx8800_suspend_state state; 489}; 490 491/* ----------------------------------------------------------- */ 492/* function 1: audio/alsa stuff */ 493/* =============> moved to cx88-alsa.c <====================== */ 494 495 496/* ----------------------------------------------------------- */ 497/* function 2: mpeg stuff */ 498 |
511struct cx8802_fh { 512 struct v4l2_fh fh; 513 struct cx8802_dev *dev; 514 struct videobuf_queue mpegq; 515}; 516 | |
517struct cx8802_suspend_state { 518 int disabled; 519}; 520 521struct cx8802_driver { 522 struct cx88_core *core; 523 524 /* List of drivers attached to device */ --- 27 unchanged lines hidden (view full) --- 552 spinlock_t slock; 553 554 /* pci i/o */ 555 struct pci_dev *pci; 556 unsigned char pci_rev,pci_lat; 557 558 /* dma queues */ 559 struct cx88_dmaqueue mpegq; | 499struct cx8802_suspend_state { 500 int disabled; 501}; 502 503struct cx8802_driver { 504 struct cx88_core *core; 505 506 /* List of drivers attached to device */ --- 27 unchanged lines hidden (view full) --- 534 spinlock_t slock; 535 536 /* pci i/o */ 537 struct pci_dev *pci; 538 unsigned char pci_rev,pci_lat; 539 540 /* dma queues */ 541 struct cx88_dmaqueue mpegq; |
542 struct vb2_queue vb2_mpegq; |
|
560 u32 ts_packet_size; 561 u32 ts_packet_count; 562 563 /* other global state info */ 564 struct cx8802_suspend_state state; 565 566 /* for blackbird only */ 567 struct list_head devlist; 568#if IS_ENABLED(CONFIG_VIDEO_CX88_BLACKBIRD) 569 struct video_device *mpeg_dev; 570 u32 mailbox; 571 int width; 572 int height; | 543 u32 ts_packet_size; 544 u32 ts_packet_count; 545 546 /* other global state info */ 547 struct cx8802_suspend_state state; 548 549 /* for blackbird only */ 550 struct list_head devlist; 551#if IS_ENABLED(CONFIG_VIDEO_CX88_BLACKBIRD) 552 struct video_device *mpeg_dev; 553 u32 mailbox; 554 int width; 555 int height; |
556 unsigned field; |
|
573 unsigned char mpeg_active; /* nonzero if mpeg encoder is active */ 574 575 /* mpeg params */ 576 struct cx2341x_handler cxhdl; 577#endif 578 579#if IS_ENABLED(CONFIG_VIDEO_CX88_DVB) 580 /* for dvb only */ | 557 unsigned char mpeg_active; /* nonzero if mpeg encoder is active */ 558 559 /* mpeg params */ 560 struct cx2341x_handler cxhdl; 561#endif 562 563#if IS_ENABLED(CONFIG_VIDEO_CX88_DVB) 564 /* for dvb only */ |
581 struct videobuf_dvb_frontends frontends; | 565 struct vb2_dvb_frontends frontends; |
582#endif 583 584#if IS_ENABLED(CONFIG_VIDEO_CX88_VP3054) 585 /* For VP3045 secondary I2C bus support */ 586 struct vp3054_i2c_state *vp3054; 587#endif 588 /* for switching modulation types */ 589 unsigned char ts_gen_cntrl; --- 45 unchanged lines hidden (view full) --- 635cx88_risc_buffer(struct pci_dev *pci, struct btcx_riscmem *risc, 636 struct scatterlist *sglist, 637 unsigned int top_offset, unsigned int bottom_offset, 638 unsigned int bpl, unsigned int padding, unsigned int lines); 639extern int 640cx88_risc_databuffer(struct pci_dev *pci, struct btcx_riscmem *risc, 641 struct scatterlist *sglist, unsigned int bpl, 642 unsigned int lines, unsigned int lpi); | 566#endif 567 568#if IS_ENABLED(CONFIG_VIDEO_CX88_VP3054) 569 /* For VP3045 secondary I2C bus support */ 570 struct vp3054_i2c_state *vp3054; 571#endif 572 /* for switching modulation types */ 573 unsigned char ts_gen_cntrl; --- 45 unchanged lines hidden (view full) --- 619cx88_risc_buffer(struct pci_dev *pci, struct btcx_riscmem *risc, 620 struct scatterlist *sglist, 621 unsigned int top_offset, unsigned int bottom_offset, 622 unsigned int bpl, unsigned int padding, unsigned int lines); 623extern int 624cx88_risc_databuffer(struct pci_dev *pci, struct btcx_riscmem *risc, 625 struct scatterlist *sglist, unsigned int bpl, 626 unsigned int lines, unsigned int lpi); |
643extern int 644cx88_risc_stopper(struct pci_dev *pci, struct btcx_riscmem *risc, 645 u32 reg, u32 mask, u32 value); | |
646extern void | 627extern void |
647cx88_free_buffer(struct videobuf_queue *q, struct cx88_buffer *buf); | 628cx88_free_buffer(struct vb2_queue *q, struct cx88_buffer *buf); |
648 649extern void cx88_risc_disasm(struct cx88_core *core, 650 struct btcx_riscmem *risc); 651extern int cx88_sram_channel_setup(struct cx88_core *core, 652 const struct sram_channel *ch, 653 unsigned int bpl, u32 risc); 654extern void cx88_sram_channel_dump(struct cx88_core *core, 655 const struct sram_channel *ch); 656 657extern int cx88_set_scale(struct cx88_core *core, unsigned int width, 658 unsigned int height, enum v4l2_field field); 659extern int cx88_set_tvnorm(struct cx88_core *core, v4l2_std_id norm); 660 661extern struct video_device *cx88_vdev_init(struct cx88_core *core, 662 struct pci_dev *pci, 663 const struct video_device *template_, 664 const char *type); | 629 630extern void cx88_risc_disasm(struct cx88_core *core, 631 struct btcx_riscmem *risc); 632extern int cx88_sram_channel_setup(struct cx88_core *core, 633 const struct sram_channel *ch, 634 unsigned int bpl, u32 risc); 635extern void cx88_sram_channel_dump(struct cx88_core *core, 636 const struct sram_channel *ch); 637 638extern int cx88_set_scale(struct cx88_core *core, unsigned int width, 639 unsigned int height, enum v4l2_field field); 640extern int cx88_set_tvnorm(struct cx88_core *core, v4l2_std_id norm); 641 642extern struct video_device *cx88_vdev_init(struct cx88_core *core, 643 struct pci_dev *pci, 644 const struct video_device *template_, 645 const char *type); |
665extern struct cx88_core* cx88_core_get(struct pci_dev *pci); | 646extern struct cx88_core *cx88_core_get(struct pci_dev *pci); |
666extern void cx88_core_put(struct cx88_core *core, 667 struct pci_dev *pci); 668 669extern int cx88_start_audio_dma(struct cx88_core *core); 670extern int cx88_stop_audio_dma(struct cx88_core *core); 671 672 673/* ----------------------------------------------------------- */ 674/* cx88-vbi.c */ 675 676/* Can be used as g_vbi_fmt, try_vbi_fmt and s_vbi_fmt */ 677int cx8800_vbi_fmt (struct file *file, void *priv, 678 struct v4l2_format *f); 679 680/* 681int cx8800_start_vbi_dma(struct cx8800_dev *dev, 682 struct cx88_dmaqueue *q, 683 struct cx88_buffer *buf); 684*/ | 647extern void cx88_core_put(struct cx88_core *core, 648 struct pci_dev *pci); 649 650extern int cx88_start_audio_dma(struct cx88_core *core); 651extern int cx88_stop_audio_dma(struct cx88_core *core); 652 653 654/* ----------------------------------------------------------- */ 655/* cx88-vbi.c */ 656 657/* Can be used as g_vbi_fmt, try_vbi_fmt and s_vbi_fmt */ 658int cx8800_vbi_fmt (struct file *file, void *priv, 659 struct v4l2_format *f); 660 661/* 662int cx8800_start_vbi_dma(struct cx8800_dev *dev, 663 struct cx88_dmaqueue *q, 664 struct cx88_buffer *buf); 665*/ |
685int cx8800_stop_vbi_dma(struct cx8800_dev *dev); 686int cx8800_restart_vbi_queue(struct cx8800_dev *dev, 687 struct cx88_dmaqueue *q); 688void cx8800_vbi_timeout(unsigned long data); | 666void cx8800_stop_vbi_dma(struct cx8800_dev *dev); 667int cx8800_restart_vbi_queue(struct cx8800_dev *dev, struct cx88_dmaqueue *q); |
689 | 668 |
690extern const struct videobuf_queue_ops cx8800_vbi_qops; | 669extern const struct vb2_ops cx8800_vbi_qops; |
691 692/* ----------------------------------------------------------- */ 693/* cx88-i2c.c */ 694 695extern int cx88_i2c_init(struct cx88_core *core, struct pci_dev *pci); 696 697 698/* ----------------------------------------------------------- */ --- 33 unchanged lines hidden (view full) --- 732void cx88_ir_irq(struct cx88_core *core); 733int cx88_ir_start(struct cx88_core *core); 734void cx88_ir_stop(struct cx88_core *core); 735extern void cx88_i2c_init_ir(struct cx88_core *core); 736 737/* ----------------------------------------------------------- */ 738/* cx88-mpeg.c */ 739 | 670 671/* ----------------------------------------------------------- */ 672/* cx88-i2c.c */ 673 674extern int cx88_i2c_init(struct cx88_core *core, struct pci_dev *pci); 675 676 677/* ----------------------------------------------------------- */ --- 33 unchanged lines hidden (view full) --- 711void cx88_ir_irq(struct cx88_core *core); 712int cx88_ir_start(struct cx88_core *core); 713void cx88_ir_stop(struct cx88_core *core); 714extern void cx88_i2c_init_ir(struct cx88_core *core); 715 716/* ----------------------------------------------------------- */ 717/* cx88-mpeg.c */ 718 |
740int cx8802_buf_prepare(struct videobuf_queue *q,struct cx8802_dev *dev, | 719int cx8802_buf_prepare(struct vb2_queue *q, struct cx8802_dev *dev, |
741 struct cx88_buffer *buf, enum v4l2_field field); 742void cx8802_buf_queue(struct cx8802_dev *dev, struct cx88_buffer *buf); 743void cx8802_cancel_buffers(struct cx8802_dev *dev); | 720 struct cx88_buffer *buf, enum v4l2_field field); 721void cx8802_buf_queue(struct cx8802_dev *dev, struct cx88_buffer *buf); 722void cx8802_cancel_buffers(struct cx8802_dev *dev); |
723int cx8802_start_dma(struct cx8802_dev *dev, 724 struct cx88_dmaqueue *q, 725 struct cx88_buffer *buf); |
|
744 745/* ----------------------------------------------------------- */ 746/* cx88-video.c*/ | 726 727/* ----------------------------------------------------------- */ 728/* cx88-video.c*/ |
747int cx88_enum_input (struct cx88_core *core,struct v4l2_input *i); | 729int cx88_enum_input(struct cx88_core *core, struct v4l2_input *i); |
748int cx88_set_freq(struct cx88_core *core, const struct v4l2_frequency *f); 749int cx88_video_mux(struct cx88_core *core, unsigned int input); 750void cx88_querycap(struct file *file, struct cx88_core *core, 751 struct v4l2_capability *cap); | 730int cx88_set_freq(struct cx88_core *core, const struct v4l2_frequency *f); 731int cx88_video_mux(struct cx88_core *core, unsigned int input); 732void cx88_querycap(struct file *file, struct cx88_core *core, 733 struct v4l2_capability *cap); |