--- zzzz-none-000/linux-3.10.107/drivers/media/pci/cx88/cx88.h 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/drivers/media/pci/cx88/cx88.h 2021-02-04 17:41:59.000000000 +0000 @@ -29,20 +29,18 @@ #include #include #include -#include -#include +#include #include -#include +#include #include #include -#include "btcx-risc.h" #include "cx88-reg.h" #include "tuner-xc2028.h" #include -#define CX88_VERSION "0.0.9" +#define CX88_VERSION "1.0.0" #define UNSET (-1U) @@ -63,7 +61,8 @@ #define FORMAT_FLAGS_PACKED 0x01 #define FORMAT_FLAGS_PLANAR 0x02 -#define VBI_LINE_COUNT 17 +#define VBI_LINE_PAL_COUNT 18 +#define VBI_LINE_NTSC_COUNT 12 #define VBI_LINE_LENGTH 2048 #define AUD_RDS_LINES 4 @@ -96,13 +95,13 @@ static inline unsigned int norm_maxw(v4l2_std_id norm) { - return (norm & (V4L2_STD_MN & ~V4L2_STD_PAL_Nc)) ? 720 : 768; + return 720; } static inline unsigned int norm_maxh(v4l2_std_id norm) { - return (norm & V4L2_STD_625_50) ? 576 : 480; + return (norm & V4L2_STD_525_60) ? 480 : 576; } /* ----------------------------------------------------------- */ @@ -259,6 +258,11 @@ unsigned int audioroute:4; }; +enum cx88_audio_chip { + CX88_AUDIO_WM8775 = 1, + CX88_AUDIO_TVAUDIO, +}; + struct cx88_board { const char *name; unsigned int tuner_type; @@ -269,7 +273,7 @@ struct cx88_input input[MAX_CX88_INPUT]; struct cx88_input radio; enum cx88_board_type mpeg; - unsigned int audio_chip; + enum cx88_audio_chip audio_chip; int num_frontends; /* Used for I2S devices */ @@ -307,26 +311,32 @@ #define BUFFER_TIMEOUT msecs_to_jiffies(2000) +struct cx88_riscmem { + unsigned int size; + __le32 *cpu; + __le32 *jmp; + dma_addr_t dma; +}; + /* buffer for one video frame */ struct cx88_buffer { /* common v4l buffer stuff -- must be first */ - struct videobuf_buffer vb; + struct vb2_v4l2_buffer vb; + struct list_head list; /* cx88 specific */ unsigned int bpl; - struct btcx_riscmem risc; - const struct cx8800_fmt *fmt; - u32 count; + struct cx88_riscmem risc; }; struct cx88_dmaqueue { struct list_head active; - struct list_head queued; - struct timer_list timeout; - struct btcx_riscmem stopper; u32 count; }; +struct cx8800_dev; +struct cx8802_dev; + struct cx88_core { struct list_head devlist; atomic_t refcount; @@ -365,13 +375,16 @@ /* config info -- dvb */ #if IS_ENABLED(CONFIG_VIDEO_CX88_DVB) - int (*prev_set_voltage)(struct dvb_frontend *fe, fe_sec_voltage_t voltage); + int (*prev_set_voltage)(struct dvb_frontend *fe, + enum fe_sec_voltage voltage); #endif - void (*gate_ctrl)(struct cx88_core *core, int open); + void (*gate_ctrl)(struct cx88_core *core, int open); /* state info */ struct task_struct *kthread; v4l2_std_id tvnorm; + unsigned width, height; + unsigned field; enum cx88_tvaudio tvaudio; u32 audiomode_manual; u32 audiomode_current; @@ -391,11 +404,14 @@ struct mutex lock; /* various v4l controls */ u32 freq; - int users; - int mpeg_users; - /* cx88-video needs to access cx8802 for hybrid tuner pll access. */ + /* + * cx88-video needs to access cx8802 for hybrid tuner pll access and + * for vb2_is_busy() checks. + */ struct cx8802_dev *dvbdev; + /* cx88-blackbird needs to access cx8800 for vb2_is_busy() checks */ + struct cx8800_dev *v4ldev; enum cx88_board_type active_type_id; int active_ref; int active_fe_id; @@ -449,24 +465,9 @@ val; \ }) -struct cx8800_dev; -struct cx8802_dev; - /* ----------------------------------------------------------- */ /* function 0: video stuff */ -struct cx8800_fh { - struct v4l2_fh fh; - struct cx8800_dev *dev; - unsigned int resources; - - /* video capture */ - struct videobuf_queue vidq; - - /* vbi capture */ - struct videobuf_queue vbiq; -}; - struct cx8800_suspend_state { int disabled; }; @@ -477,20 +478,22 @@ /* various device info */ unsigned int resources; - struct video_device *video_dev; - struct video_device *vbi_dev; - struct video_device *radio_dev; + struct video_device video_dev; + struct video_device vbi_dev; + struct video_device radio_dev; /* pci i/o */ struct pci_dev *pci; unsigned char pci_rev,pci_lat; + void *alloc_ctx; const struct cx8800_fmt *fmt; - unsigned int width, height; /* capture queues */ struct cx88_dmaqueue vidq; + struct vb2_queue vb2_vidq; struct cx88_dmaqueue vbiq; + struct vb2_queue vb2_vbiq; /* various v4l controls */ @@ -506,12 +509,6 @@ /* ----------------------------------------------------------- */ /* function 2: mpeg stuff */ -struct cx8802_fh { - struct v4l2_fh fh; - struct cx8802_dev *dev; - struct videobuf_queue mpegq; -}; - struct cx8802_suspend_state { int disabled; }; @@ -552,9 +549,11 @@ /* pci i/o */ struct pci_dev *pci; unsigned char pci_rev,pci_lat; + void *alloc_ctx; /* dma queues */ struct cx88_dmaqueue mpegq; + struct vb2_queue vb2_mpegq; u32 ts_packet_size; u32 ts_packet_count; @@ -564,11 +563,8 @@ /* for blackbird only */ struct list_head devlist; #if IS_ENABLED(CONFIG_VIDEO_CX88_BLACKBIRD) - struct video_device *mpeg_dev; + struct video_device mpeg_dev; u32 mailbox; - int width; - int height; - unsigned char mpeg_active; /* nonzero if mpeg encoder is active */ /* mpeg params */ struct cx2341x_handler cxhdl; @@ -576,7 +572,7 @@ #if IS_ENABLED(CONFIG_VIDEO_CX88_DVB) /* for dvb only */ - struct videobuf_dvb_frontends frontends; + struct vb2_dvb_frontends frontends; #endif #if IS_ENABLED(CONFIG_VIDEO_CX88_VP3054) @@ -630,22 +626,17 @@ extern int cx88_reset(struct cx88_core *core); extern int -cx88_risc_buffer(struct pci_dev *pci, struct btcx_riscmem *risc, +cx88_risc_buffer(struct pci_dev *pci, struct cx88_riscmem *risc, struct scatterlist *sglist, unsigned int top_offset, unsigned int bottom_offset, unsigned int bpl, unsigned int padding, unsigned int lines); extern int -cx88_risc_databuffer(struct pci_dev *pci, struct btcx_riscmem *risc, +cx88_risc_databuffer(struct pci_dev *pci, struct cx88_riscmem *risc, struct scatterlist *sglist, unsigned int bpl, unsigned int lines, unsigned int lpi); -extern int -cx88_risc_stopper(struct pci_dev *pci, struct btcx_riscmem *risc, - u32 reg, u32 mask, u32 value); -extern void -cx88_free_buffer(struct videobuf_queue *q, struct cx88_buffer *buf); extern void cx88_risc_disasm(struct cx88_core *core, - struct btcx_riscmem *risc); + struct cx88_riscmem *risc); extern int cx88_sram_channel_setup(struct cx88_core *core, const struct sram_channel *ch, unsigned int bpl, u32 risc); @@ -656,11 +647,12 @@ unsigned int height, enum v4l2_field field); extern int cx88_set_tvnorm(struct cx88_core *core, v4l2_std_id norm); -extern struct video_device *cx88_vdev_init(struct cx88_core *core, - struct pci_dev *pci, - const struct video_device *template_, - const char *type); -extern struct cx88_core* cx88_core_get(struct pci_dev *pci); +extern void cx88_vdev_init(struct cx88_core *core, + struct pci_dev *pci, + struct video_device *vfd, + const struct video_device *template_, + const char *type); +extern struct cx88_core *cx88_core_get(struct pci_dev *pci); extern void cx88_core_put(struct cx88_core *core, struct pci_dev *pci); @@ -680,12 +672,10 @@ struct cx88_dmaqueue *q, struct cx88_buffer *buf); */ -int cx8800_stop_vbi_dma(struct cx8800_dev *dev); -int cx8800_restart_vbi_queue(struct cx8800_dev *dev, - struct cx88_dmaqueue *q); -void cx8800_vbi_timeout(unsigned long data); +void cx8800_stop_vbi_dma(struct cx8800_dev *dev); +int cx8800_restart_vbi_queue(struct cx8800_dev *dev, struct cx88_dmaqueue *q); -extern const struct videobuf_queue_ops cx8800_vbi_qops; +extern const struct vb2_ops cx8800_vbi_qops; /* ----------------------------------------------------------- */ /* cx88-i2c.c */ @@ -735,14 +725,17 @@ /* ----------------------------------------------------------- */ /* cx88-mpeg.c */ -int cx8802_buf_prepare(struct videobuf_queue *q,struct cx8802_dev *dev, - struct cx88_buffer *buf, enum v4l2_field field); +int cx8802_buf_prepare(struct vb2_queue *q, struct cx8802_dev *dev, + struct cx88_buffer *buf); void cx8802_buf_queue(struct cx8802_dev *dev, struct cx88_buffer *buf); void cx8802_cancel_buffers(struct cx8802_dev *dev); +int cx8802_start_dma(struct cx8802_dev *dev, + struct cx88_dmaqueue *q, + struct cx88_buffer *buf); /* ----------------------------------------------------------- */ /* cx88-video.c*/ -int cx88_enum_input (struct cx88_core *core,struct v4l2_input *i); +int cx88_enum_input(struct cx88_core *core, struct v4l2_input *i); int cx88_set_freq(struct cx88_core *core, const struct v4l2_frequency *f); int cx88_video_mux(struct cx88_core *core, unsigned int input); void cx88_querycap(struct file *file, struct cx88_core *core,