2 * ngene.h: nGene PCIe bridge driver
4 * Copyright (C) 2005-2007 Micronas
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * version 2 only, as published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
28 #define NGENE_COMMAND_API
31 #include <linux/types.h>
32 #include <linux/sched.h>
33 #include <linux/interrupt.h>
34 #include <linux/i2c.h>
36 #include <asm/scatterlist.h>
37 #include <sound/driver.h>
38 #include <sound/core.h>
39 #include <sound/initval.h>
40 #include <sound/control.h>
41 #include <sound/pcm.h>
42 #include <sound/pcm_params.h>
44 #include <linux/dvb/frontend.h>
45 #include <linux/dvb/ca.h>
46 #include <linux/dvb/video.h>
47 #include <linux/dvb/audio.h>
51 #include "dvb_demux.h"
52 #include "dvb_frontend.h"
53 #include "dvb_ringbuffer.h"
62 #include <media/v4l2-dev.h>
63 #include <media/videobuf-core.h>
64 #include <linux/videodev.h>
67 #define NGENE_VID 0x18c3
68 #define NGENE_PID 0x0720
71 #define VIDEO_CAP_AVC 128
72 #define VIDEO_CAP_H264 128
73 #define VIDEO_CAP_VC1 256
74 #define VIDEO_CAP_WMV9 256
75 #define VIDEO_CAP_MPEG4 512
79 STREAM_VIDEOIN1
= 0, /* ITU656 or TS Input */
81 STREAM_AUDIOIN1
, /* I2S or SPI Input */
88 SMODE_AUDIO_SPDIF
= 0x20,
90 SMODE_TRANSPORT_STREAM
= 0x08,
91 SMODE_AUDIO_CAPTURE
= 0x04,
92 SMODE_VBI_CAPTURE
= 0x02,
93 SMODE_VIDEO_CAPTURE
= 0x01
96 enum STREAM_FLAG_BITS
{
97 SFLAG_CHROMA_FORMAT_2COMP
= 0x01, /* Chroma Format : 2's complement */
98 SFLAG_CHROMA_FORMAT_OFFSET
= 0x00, /* Chroma Format : Binary offset */
99 SFLAG_ORDER_LUMA_CHROMA
= 0x02, /* Byte order: Y,Cb,Y,Cr */
100 SFLAG_ORDER_CHROMA_LUMA
= 0x00, /* Byte order: Cb,Y,Cr,Y */
101 SFLAG_COLORBAR
= 0x04, /* Select colorbar */
104 #define PROGRAM_ROM 0x0000
105 #define PROGRAM_SRAM 0x1000
106 #define PERIPHERALS0 0x8000
107 #define PERIPHERALS1 0x9000
108 #define SHARED_BUFFER 0xC000
110 #define HOST_TO_NGENE (SHARED_BUFFER+0x0000)
111 #define NGENE_TO_HOST (SHARED_BUFFER+0x0100)
112 #define NGENE_COMMAND (SHARED_BUFFER+0x0200)
113 #define NGENE_COMMAND_HI (SHARED_BUFFER+0x0204)
114 #define NGENE_STATUS (SHARED_BUFFER+0x0208)
115 #define NGENE_STATUS_HI (SHARED_BUFFER+0x020C)
116 #define NGENE_EVENT (SHARED_BUFFER+0x0210)
117 #define NGENE_EVENT_HI (SHARED_BUFFER+0x0214)
118 #define VARIABLES (SHARED_BUFFER+0x0210)
120 #define NGENE_INT_COUNTS (SHARED_BUFFER+0x0260)
121 #define NGENE_INT_ENABLE (SHARED_BUFFER+0x0264)
122 #define NGENE_VBI_LINE_COUNT (SHARED_BUFFER+0x0268)
124 #define BUFFER_GP_XMIT (SHARED_BUFFER+0x0800)
125 #define BUFFER_GP_RECV (SHARED_BUFFER+0x0900)
126 #define EEPROM_AREA (SHARED_BUFFER+0x0A00)
128 #define SG_V_IN_1 (SHARED_BUFFER+0x0A80)
129 #define SG_VBI_1 (SHARED_BUFFER+0x0B00)
130 #define SG_A_IN_1 (SHARED_BUFFER+0x0B80)
131 #define SG_V_IN_2 (SHARED_BUFFER+0x0C00)
132 #define SG_VBI_2 (SHARED_BUFFER+0x0C80)
133 #define SG_A_IN_2 (SHARED_BUFFER+0x0D00)
134 #define SG_V_OUT (SHARED_BUFFER+0x0D80)
135 #define SG_A_OUT2 (SHARED_BUFFER+0x0E00)
137 #define DATA_A_IN_1 (SHARED_BUFFER+0x0E80)
138 #define DATA_A_IN_2 (SHARED_BUFFER+0x0F00)
139 #define DATA_A_OUT (SHARED_BUFFER+0x0F80)
140 #define DATA_V_IN_1 (SHARED_BUFFER+0x1000)
141 #define DATA_V_IN_2 (SHARED_BUFFER+0x2000)
142 #define DATA_V_OUT (SHARED_BUFFER+0x3000)
144 #define DATA_FIFO_AREA (SHARED_BUFFER+0x1000)
146 #define TIMESTAMPS 0xA000
147 #define SCRATCHPAD 0xA080
148 #define FORCE_INT 0xA088
149 #define FORCE_NMI 0xA090
150 #define INT_STATUS 0xA0A0
152 #define DEV_VER 0x9004
154 #define FW_DEBUG_DEFAULT (PROGRAM_SRAM+0x00FF)
162 } __attribute__ ((__packed__
));
164 struct SHARED_MEMORY
{
177 u8 pad1
[0xc260 - 0xc218];
184 u8 pad2
[0xd000 - 0xc268];
186 } __attribute__ ((__packed__
));
188 struct BUFFER_STREAM_RESULTS
{
189 u32 Clock
; /* Stream time in 100ns units */
190 u16 RemainingLines
; /* Remaining lines in this field.
191 0 for complete field */
192 u8 FieldCount
; /* Video field number */
193 u8 Flags
; /* Bit 7 = Done, Bit 6 = seen, Bit 5 = overflow,
195 u16 BlockCount
; /* Audio block count (unused) */
198 } __attribute__ ((__packed__
));
200 struct HW_SCATTER_GATHER_ELEMENT
{
204 } __attribute__ ((__packed__
));
206 struct BUFFER_HEADER
{
208 struct BUFFER_STREAM_RESULTS SR
;
210 u32 Number_of_entries_1
;
212 u64 Address_of_first_entry_1
;
214 u32 Number_of_entries_2
;
216 u64 Address_of_first_entry_2
;
217 } __attribute__ ((__packed__
));
219 struct EVENT_BUFFER
{
226 } __attribute__ ((__packed__
));
228 typedef struct EVENT_BUFFER
*PEVENT_BUFFER
;
230 /* Firmware commands. */
234 CMD_FWLOAD_PREPARE
= 0x01,
235 CMD_FWLOAD_FINISH
= 0x02,
237 CMD_I2C_WRITE
= 0x04,
239 CMD_I2C_WRITE_NOSTOP
= 0x05,
240 CMD_I2C_CONTINUE_WRITE
= 0x06,
241 CMD_I2C_CONTINUE_WRITE_NOSTOP
= 0x07,
243 CMD_DEBUG_OUTPUT
= 0x09,
246 CMD_CONFIGURE_BUFFER
= 0x11,
247 CMD_CONFIGURE_FREE_BUFFER
= 0x12,
250 CMD_SPI_WRITE
= 0x14,
253 CMD_MEM_WRITE
= 0x21,
255 CMD_SFR_WRITE
= 0x23,
256 CMD_IRAM_READ
= 0x24,
257 CMD_IRAM_WRITE
= 0x25,
258 CMD_SET_GPIO_PIN
= 0x26,
259 CMD_SET_GPIO_INT
= 0x27,
260 CMD_CONFIGURE_UART
= 0x28,
261 CMD_WRITE_UART
= 0x29,
273 } __attribute__ ((__packed__
));
275 struct FW_I2C_WRITE
{
276 struct FW_HEADER hdr
;
279 } __attribute__ ((__packed__
));
281 struct FW_I2C_CONTINUE_WRITE
{
282 struct FW_HEADER hdr
;
284 } __attribute__ ((__packed__
));
287 struct FW_HEADER hdr
;
289 u8 Data
[252]; /* followed by two bytes of read data count */
290 } __attribute__ ((__packed__
));
292 struct FW_SPI_WRITE
{
293 struct FW_HEADER hdr
;
296 } __attribute__ ((__packed__
));
299 struct FW_HEADER hdr
;
301 u8 Data
[252]; /* followed by two bytes of read data count */
302 } __attribute__ ((__packed__
));
304 struct FW_FWLOAD_PREPARE
{
305 struct FW_HEADER hdr
;
306 } __attribute__ ((__packed__
));
308 struct FW_FWLOAD_FINISH
{
309 struct FW_HEADER hdr
;
310 u16 Address
; /* address of final block */
312 } __attribute__ ((__packed__
));
315 * Meaning of FW_STREAM_CONTROL::Mode bits:
316 * Bit 7: Loopback PEXin to PEXout using TVOut channel
318 * Bit 5: Audio select; 0=I2S, 1=SPDIF
320 * Bit 3: Enable transport stream
321 * Bit 2: Enable audio capture
322 * Bit 1: Enable ITU-Video VBI capture
323 * Bit 0: Enable ITU-Video capture
325 * Meaning of FW_STREAM_CONTROL::Control bits (see UVI1_CTL)
326 * Bit 7: continuous capture
327 * Bit 6: capture one field
328 * Bit 5: capture one frame
330 * Bit 3: starting field; 0=odd, 1=even
331 * Bit 2: sample size; 0=8-bit, 1=10-bit
332 * Bit 1: data format; 0=UYVY, 1=YUY2
333 * Bit 0: resets buffer pointers
337 SMODE_LOOPBACK
= 0x80,
339 _SMODE_AUDIO_SPDIF
= 0x20,
340 _SMODE_AVSYNC
= 0x10,
341 _SMODE_TRANSPORT_STREAM
= 0x08,
342 _SMODE_AUDIO_CAPTURE
= 0x04,
343 _SMODE_VBI_CAPTURE
= 0x02,
344 _SMODE_VIDEO_CAPTURE
= 0x01
348 /* Meaning of FW_STREAM_CONTROL::Stream bits:
349 * Bit 3: Audio sample count: 0 = relative, 1 = absolute
350 * Bit 2: color bar select; 1=color bars, 0=CV3 decoder
351 * Bits 1-0: stream select, UVI1, UVI2, TVOUT
354 struct FW_STREAM_CONTROL
{
355 struct FW_HEADER hdr
;
356 u8 Stream
; /* Stream number (UVI1, UVI2, TVOUT) */
357 u8 Control
; /* Value written to UVI1_CTL */
358 u8 Mode
; /* Controls clock source */
359 u8 SetupDataLen
; /* Length of setup data, MSB=1 write
361 u16 CaptureBlockCount
; /* Blocks (a 256 Bytes) to capture per buffer
363 u64 Buffer_Address
; /* Address of first buffer header */
364 u16 BytesPerVideoLine
;
365 u16 MaxLinesPerField
;
366 u16 MinLinesPerField
;
369 u16 MaxVBILinesPerField
;
370 u16 MinVBILinesPerField
;
371 u16 SetupDataAddr
; /* ngene relative address of setup data */
372 u8 SetupData
[32]; /* setup data */
373 } __attribute__((__packed__
));
375 #define AUDIO_BLOCK_SIZE 256
376 #define TS_BLOCK_SIZE 256
379 struct FW_HEADER hdr
;
381 } __attribute__ ((__packed__
));
383 struct FW_MEM_WRITE
{
384 struct FW_HEADER hdr
;
387 } __attribute__ ((__packed__
));
389 struct FW_SFR_IRAM_READ
{
390 struct FW_HEADER hdr
;
392 } __attribute__ ((__packed__
));
394 struct FW_SFR_IRAM_WRITE
{
395 struct FW_HEADER hdr
;
398 } __attribute__ ((__packed__
));
400 struct FW_SET_GPIO_PIN
{
401 struct FW_HEADER hdr
;
403 } __attribute__ ((__packed__
));
405 struct FW_SET_GPIO_INT
{
406 struct FW_HEADER hdr
;
408 } __attribute__ ((__packed__
));
410 struct FW_SET_DEBUGMODE
{
411 struct FW_HEADER hdr
;
413 } __attribute__ ((__packed__
));
415 struct FW_CONFIGURE_BUFFERS
{
416 struct FW_HEADER hdr
;
418 } __attribute__ ((__packed__
));
420 enum _BUFFER_CONFIGS
{
421 /* 4k UVI1, 4k UVI2, 2k AUD1, 2k AUD2 (standard usage) */
422 BUFFER_CONFIG_4422
= 0,
423 /* 3k UVI1, 3k UVI2, 3k AUD1, 3k AUD2 (4x TS input usage) */
424 BUFFER_CONFIG_3333
= 1,
425 /* 8k UVI1, 0k UVI2, 2k AUD1, 2k I2SOut (HDTV decoder usage) */
426 BUFFER_CONFIG_8022
= 2,
427 BUFFER_CONFIG_FW17
= 255, /* Use new FW 17 command */
430 struct FW_CONFIGURE_FREE_BUFFERS
{
431 struct FW_HEADER hdr
;
432 u8 UVI1_BufferLength
;
433 u8 UVI2_BufferLength
;
435 u8 AUD1_BufferLength
;
436 u8 AUD2_BufferLength
;
438 } __attribute__ ((__packed__
));
440 struct FW_CONFIGURE_UART
{
441 struct FW_HEADER hdr
;
443 } __attribute__ ((__packed__
));
446 _UART_BAUDRATE_19200
= 0,
447 _UART_BAUDRATE_9600
= 1,
448 _UART_BAUDRATE_4800
= 2,
449 _UART_BAUDRATE_2400
= 3,
450 _UART_RX_ENABLE
= 0x40,
451 _UART_TX_ENABLE
= 0x80,
454 struct FW_WRITE_UART
{
455 struct FW_HEADER hdr
;
457 } __attribute__ ((__packed__
));
460 struct ngene_command
{
466 struct FW_HEADER hdr
;
467 struct FW_I2C_WRITE I2CWrite
;
468 struct FW_I2C_CONTINUE_WRITE I2CContinueWrite
;
469 struct FW_I2C_READ I2CRead
;
470 struct FW_STREAM_CONTROL StreamControl
;
471 struct FW_FWLOAD_PREPARE FWLoadPrepare
;
472 struct FW_FWLOAD_FINISH FWLoadFinish
;
473 struct FW_MEM_READ MemoryRead
;
474 struct FW_MEM_WRITE MemoryWrite
;
475 struct FW_SFR_IRAM_READ SfrIramRead
;
476 struct FW_SFR_IRAM_WRITE SfrIramWrite
;
477 struct FW_SPI_WRITE SPIWrite
;
478 struct FW_SPI_READ SPIRead
;
479 struct FW_SET_GPIO_PIN SetGpioPin
;
480 struct FW_SET_GPIO_INT SetGpioInt
;
481 struct FW_SET_DEBUGMODE SetDebugMode
;
482 struct FW_CONFIGURE_BUFFERS ConfigureBuffers
;
483 struct FW_CONFIGURE_FREE_BUFFERS ConfigureFreeBuffers
;
484 struct FW_CONFIGURE_UART ConfigureUart
;
485 struct FW_WRITE_UART WriteUart
;
487 } __attribute__ ((__packed__
));
489 #define NGENE_INTERFACE_VERSION 0x103
490 #define MAX_VIDEO_BUFFER_SIZE (417792) /* 288*1440 rounded up to next page */
491 #define MAX_AUDIO_BUFFER_SIZE (8192) /* Gives room for about 23msec@48KHz */
492 #define MAX_VBI_BUFFER_SIZE (28672) /* 1144*18 rounded up to next page */
493 #define MAX_TS_BUFFER_SIZE (98304) /* 512*188 rounded up to next page */
494 #define MAX_HDTV_BUFFER_SIZE (2080768) /* 541*1920*2 rounded up to next page
495 Max: (1920x1080i60) */
497 #define OVERFLOW_BUFFER_SIZE (8192)
499 #define RING_SIZE_VIDEO 4
500 #define RING_SIZE_AUDIO 8
501 #define RING_SIZE_TS 8
503 #define NUM_SCATTER_GATHER_ENTRIES 8
505 #define MAX_DMA_LENGTH (((MAX_VIDEO_BUFFER_SIZE + MAX_VBI_BUFFER_SIZE) * \
506 RING_SIZE_VIDEO * 2) + \
507 (MAX_AUDIO_BUFFER_SIZE * RING_SIZE_AUDIO * 2) + \
508 (MAX_TS_BUFFER_SIZE * RING_SIZE_TS * 4) + \
509 (RING_SIZE_VIDEO * PAGE_SIZE * 2) + \
510 (RING_SIZE_AUDIO * PAGE_SIZE * 2) + \
511 (RING_SIZE_TS * PAGE_SIZE * 4) + \
512 8 * PAGE_SIZE + OVERFLOW_BUFFER_SIZE + PAGE_SIZE)
514 #define EVENT_QUEUE_SIZE 16
516 typedef struct HW_SCATTER_GATHER_ELEMENT
*PHW_SCATTER_GATHER_ELEMENT
;
517 typedef struct FWRB
*PFWRB
;
519 /* Gathers the current state of a single channel. */
521 struct SBufferHeader
{
522 struct BUFFER_HEADER ngeneBuffer
; /* Physical descriptor */
523 struct SBufferHeader
*Next
;
525 PHW_SCATTER_GATHER_ELEMENT scList1
;
527 PHW_SCATTER_GATHER_ELEMENT scList2
;
530 /* Sizeof SBufferHeader aligned to next 64 Bit boundary (hw restriction) */
531 #define SIZEOF_SBufferHeader ((sizeof(struct SBufferHeader) + 63) & ~63)
547 struct SRingBufferDescriptor
{
548 struct SBufferHeader
*Head
; /* Points to first buffer in ring buffer
550 u64 PAHead
; /* Physical address of first buffer */
551 u32 MemSize
; /* Memory size of allocated ring buffers
552 (needed for freeing) */
553 u32 NumBuffers
; /* Number of buffers in the ring */
554 u32 Buffer1Length
; /* Allocated length of Buffer 1 */
555 u32 Buffer2Length
; /* Allocated length of Buffer 2 */
556 void *SCListMem
; /* Memory to hold scatter gather lists for this
558 u64 PASCListMem
; /* Physical address .. */
559 u32 SCListMemSize
; /* Size of this memory */
562 enum STREAMMODEFLAGS
{
563 StreamMode_NONE
= 0, /* Stream not used */
564 StreamMode_ANALOG
= 1, /* Analog: Stream 0,1 = Video, 2,3 = Audio */
565 StreamMode_TSIN
= 2, /* Transport stream input (all) */
566 StreamMode_HDTV
= 4, /* HDTV: Maximum 1920x1080p30,1920x1080i60
568 StreamMode_TSOUT
= 8, /* Transport stream output (only stream 3) */
572 enum BufferExchangeFlags
{
573 BEF_EVEN_FIELD
= 0x00000001,
574 BEF_CONTINUATION
= 0x00000002,
575 BEF_MORE_DATA
= 0x00000004,
576 BEF_OVERFLOW
= 0x00000008,
577 DF_SWAP32
= 0x00010000,
580 typedef void *(IBufferExchange
)(void *, void *, u32
, u32
, u32
);
583 IBufferExchange
*pExchange
;
584 IBufferExchange
*pExchangeVBI
; /* Secondary (VBI, ancillary) */
590 u16 nBytesPerLineVideo
;
592 u16 nBytesPerLineVBI
;
593 u32 CaptureLength
; /* Used for audio and transport stream */
594 } MICI_STREAMINFO
, *PMICI_STREAMINFO
;
596 /****************************************************************************/
597 /* STRUCTS ******************************************************************/
598 /****************************************************************************/
600 /* sound hardware definition */
601 #define MIXER_ADDR_TVTUNER 0
602 #define MIXER_ADDR_LAST 0
604 struct ngene_channel
;
606 /*struct sound chip*/
609 struct ngene_channel
*chan
;
610 struct snd_card
*card
;
612 struct snd_pcm_substream
*substream
;
616 spinlock_t mixer_lock
;
618 int mixer_volume
[MIXER_ADDR_LAST
+ 1][2];
619 int capture_source
[MIXER_ADDR_LAST
+ 1][2];
623 struct ngene_overlay
{
626 enum v4l2_field field
;
627 struct v4l2_clip
*clips
;
632 struct ngene_tvnorm
{
635 u16 swidth
, sheight
; /* scaled standard width, height */
641 struct ngene_channel
*ch
;
642 enum v4l2_priority prio
;
646 struct videobuf_queue vbuf_q
;
647 struct videobuf_queue vbi
;
651 enum v4l2_buf_type type
;
652 const struct ngene_format
*fmt
;
654 const struct ngene_format
*ovfmt
;
655 struct ngene_overlay ov
;
659 struct ngene_channel
{
660 struct device device
;
661 struct i2c_adapter i2c_adapter
;
668 struct dvb_frontend
*fe
;
669 struct dmxdev dmxdev
;
670 struct dvb_demux demux
;
671 struct dmx_frontend hw_frontend
;
672 struct dmx_frontend mem_frontend
;
674 struct video_device
*v4l_dev
;
676 struct dvb_adapter dvb_adapter
;
678 struct dvb_device
*command_dev
;
679 struct dvb_device
*audio_dev
;
680 struct dvb_device
*video_dev
;
681 struct tasklet_struct demux_tasklet
;
683 struct SBufferHeader
*nextBuffer
;
685 enum HWSTATE HWState
;
689 IBufferExchange
*pBufferExchange
;
690 IBufferExchange
*pBufferExchange2
;
692 spinlock_t state_lock
;
696 u16 nBytesPerVBILine
;
700 struct SRingBufferDescriptor RingBuffer
;
701 struct SRingBufferDescriptor TSRingBuffer
;
702 struct SRingBufferDescriptor TSIdleBuffer
;
709 int (*set_tone
)(struct dvb_frontend
*, fe_sec_tone_mode_t
);
712 /* stuff from analog driver */
715 struct mychip
*mychip
;
716 struct snd_card
*soundcard
;
722 int soundbuffisallocated
;
729 struct ngene_tvnorm
*tvnorms
;
735 struct v4l2_prio_state prio
;
736 struct ngene_vopen init
;
738 struct v4l2_framebuffer fbuf
;
739 struct ngene_buffer
*screen
; /* overlay */
740 struct list_head capture
; /* video capture queue */
742 struct semaphore reslock
;
750 typedef void (rx_cb_t
)(struct ngene
*, u32
, u8
);
751 typedef void (tx_cb_t
)(struct ngene
*, u32
);
755 struct pci_dev
*pci_dev
;
756 unsigned char *iomem
;
759 struct dvb_adapter dvb_adapter
;
761 /*struct i2c_adapter i2c_adapter;*/
764 u32 fw_interface_version
;
769 void *OverflowBuffer
;
770 dma_addr_t PAOverflowBuffer
;
771 void *FWInterfaceBuffer
;
772 dma_addr_t PAFWInterfaceBuffer
;
776 struct EVENT_BUFFER EventQueue
[EVENT_QUEUE_SIZE
];
777 int EventQueueOverflowCount
;
778 int EventQueueOverflowFlag
;
779 struct tasklet_struct event_tasklet
;
780 struct EVENT_BUFFER
*EventBuffer
;
781 int EventQueueWriteIndex
;
782 int EventQueueReadIndex
;
784 wait_queue_head_t cmd_wq
;
786 struct semaphore cmd_mutex
;
787 struct semaphore stream_mutex
;
788 struct semaphore pll_mutex
;
789 struct semaphore i2c_switch_mutex
;
790 int i2c_current_channel
;
794 struct ngene_channel channel
[MAX_STREAM
];
796 struct ngene_info
*card_info
;
798 tx_cb_t
*TxEventNotify
;
799 rx_cb_t
*RxEventNotify
;
801 wait_queue_head_t tx_wq
;
802 wait_queue_head_t rx_wq
;
803 #define UART_RBUF_LEN 4096
804 u8 uart_rbuf
[UART_RBUF_LEN
];
805 int uart_rp
, uart_wp
;
808 #define TSOUT_BUF_SIZE (512*188*8)
809 struct dvb_ringbuffer tsout_rbuf
;
812 #define AIN_BUF_SIZE (128*1024)
813 struct dvb_ringbuffer ain_rbuf
;
817 #define VIN_BUF_SIZE (4*1920*1080)
818 struct dvb_ringbuffer vin_rbuf
;
820 unsigned long exp_val
;
824 struct channel_info
{
826 #define NGENE_IO_NONE 0
827 #define NGENE_IO_TV 1
828 #define NGENE_IO_HDTV 2
829 #define NGENE_IO_TSIN 4
830 #define NGENE_IO_TSOUT 8
831 #define NGENE_IO_AIN 16
836 int (*demod_attach
)(struct ngene_channel
*);
838 #define NGENE_DEMOD_NONE 0
839 #define NGENE_DEMOD_DRXD 1
840 #define NGENE_DEMOD_STB0899 2
841 #define NGENE_DEMOD_DRXH 3
843 int (*tuner_attach
)(struct ngene_channel
*);
845 #define NGENE_TUNER_NONE 0
846 #define NGENE_TUNER_MT2060 1
859 #define NGENE_TERRATEC 1
860 #define NGENE_SIDEWINDER 2
861 #define NGENE_RACER 3
862 #define NGENE_VIPER 4
863 #define NGENE_PYTHON 5
864 #define NGENE_VBOX_V1 6
865 #define NGENE_VBOX_V2 7
870 int io_type
[MAX_STREAM
];
871 #define NGENE_IO_NONE 0
872 #define NGENE_IO_TV 1
873 #define NGENE_IO_HDTV 2
874 #define NGENE_IO_TSIN 4
875 #define NGENE_IO_TSOUT 8
876 #define NGENE_IO_AIN 16
879 void *tuner_config
[4];
881 int (*demod_attach
[4])(struct ngene_channel
*);
882 int (*tuner_attach
[4])(struct ngene_channel
*);
895 int (*gate_ctrl
)(struct dvb_frontend
*, int);
896 int (*switch_ctrl
)(struct ngene_channel
*, int, int);
902 int fourcc
; /* video4linux 2 */
903 int btformat
; /* BT848_COLOR_FMT_* */
905 int btswap
; /* BT848_COLOR_CTL_* */
906 int depth
; /* bit/pixel */
908 int hshift
, vshift
; /* for planar modes */
912 #define RESOURCE_OVERLAY 1
913 #define RESOURCE_VIDEO 2
914 #define RESOURCE_VBI 4
916 struct ngene_buffer
{
917 /* common v4l buffer stuff -- must be first */
918 struct videobuf_buffer vb
;
921 const struct ngene_format
*fmt
;
928 int ngene_command_stream_control(struct ngene
*dev
,
929 u8 stream
, u8 control
, u8 mode
, u8 flags
);
930 int ngene_command_nop(struct ngene
*dev
);
931 int ngene_command_i2c_read(struct ngene
*dev
, u8 adr
,
932 u8
*out
, u8 outlen
, u8
*in
, u8 inlen
, int flag
);
933 int ngene_command_i2c_write(struct ngene
*dev
, u8 adr
, u8
*out
, u8 outlen
);
934 int ngene_command_imem_read(struct ngene
*dev
, u8 adr
, u8
*data
, int type
);
935 int ngene_command_imem_write(struct ngene
*dev
, u8 adr
, u8 data
, int type
);
936 int ngene_stream_control(struct ngene
*dev
, u8 stream
, u8 control
, u8 mode
,
937 u16 lines
, u16 bpl
, u16 vblines
, u16 vbibpl
);
938 int ngene_v4l2_init(struct ngene_channel
*chan
);
939 void ngene_v4l2_remove(struct ngene_channel
*chan
);
940 int ngene_snd_exit(struct ngene_channel
*chan
);
941 int ngene_snd_init(struct ngene_channel
*chan
);
943 struct i2c_client
*avf4910a_attach(struct i2c_adapter
*adap
, int addr
);