Go to the documentation of this file.
39 #include <linux/module.h>
42 #include <linux/sched.h>
44 #include <linux/pci.h>
47 #include <linux/i2c.h>
49 #include <linux/list.h>
55 #include <linux/slab.h>
56 #include <asm/uaccess.h>
57 #include <asm/byteorder.h>
59 #include <linux/dvb/video.h>
73 #define IVTV_ENCODER_OFFSET 0x00000000
74 #define IVTV_ENCODER_SIZE 0x00800000
75 #define IVTV_DECODER_OFFSET 0x01000000
76 #define IVTV_DECODER_SIZE 0x00800000
77 #define IVTV_REG_OFFSET 0x02000000
78 #define IVTV_REG_SIZE 0x00010000
82 #define IVTV_MAX_CARDS 32
84 #define IVTV_ENC_STREAM_TYPE_MPG 0
85 #define IVTV_ENC_STREAM_TYPE_YUV 1
86 #define IVTV_ENC_STREAM_TYPE_VBI 2
87 #define IVTV_ENC_STREAM_TYPE_PCM 3
88 #define IVTV_ENC_STREAM_TYPE_RAD 4
89 #define IVTV_DEC_STREAM_TYPE_MPG 5
90 #define IVTV_DEC_STREAM_TYPE_VBI 6
91 #define IVTV_DEC_STREAM_TYPE_VOUT 7
92 #define IVTV_DEC_STREAM_TYPE_YUV 8
93 #define IVTV_MAX_STREAMS 9
95 #define IVTV_DMA_SG_OSD_ENT (2883584/PAGE_SIZE)
98 #define IVTV_REG_DMAXFER (0x0000)
99 #define IVTV_REG_DMASTATUS (0x0004)
100 #define IVTV_REG_DECDMAADDR (0x0008)
101 #define IVTV_REG_ENCDMAADDR (0x000c)
102 #define IVTV_REG_DMACONTROL (0x0010)
103 #define IVTV_REG_IRQSTATUS (0x0040)
104 #define IVTV_REG_IRQMASK (0x0048)
107 #define IVTV_REG_ENC_SDRAM_REFRESH (0x07F8)
108 #define IVTV_REG_ENC_SDRAM_PRECHARGE (0x07FC)
109 #define IVTV_REG_DEC_SDRAM_REFRESH (0x08F8)
110 #define IVTV_REG_DEC_SDRAM_PRECHARGE (0x08FC)
111 #define IVTV_REG_VDM (0x2800)
112 #define IVTV_REG_AO (0x2D00)
113 #define IVTV_REG_BYTEFLUSH (0x2D24)
114 #define IVTV_REG_SPU (0x9050)
115 #define IVTV_REG_HW_BLOCKS (0x9054)
116 #define IVTV_REG_VPU (0x9058)
117 #define IVTV_REG_APU (0xA064)
120 #define IVTV_REG_DEC_LINE_FIELD (0x28C0)
124 #ifdef CONFIG_VIDEO_ADV_DEBUG
125 extern int ivtv_fw_debug;
128 #define IVTV_DBGFLG_WARN (1 << 0)
129 #define IVTV_DBGFLG_INFO (1 << 1)
130 #define IVTV_DBGFLG_MB (1 << 2)
131 #define IVTV_DBGFLG_IOCTL (1 << 3)
132 #define IVTV_DBGFLG_FILE (1 << 4)
133 #define IVTV_DBGFLG_DMA (1 << 5)
134 #define IVTV_DBGFLG_IRQ (1 << 6)
135 #define IVTV_DBGFLG_DEC (1 << 7)
136 #define IVTV_DBGFLG_YUV (1 << 8)
137 #define IVTV_DBGFLG_I2C (1 << 9)
139 #define IVTV_DBGFLG_HIGHVOL (1 << 10)
141 #define IVTV_DEBUG(x, type, fmt, args...) \
143 if ((x) & ivtv_debug) \
144 v4l2_info(&itv->v4l2_dev, " " type ": " fmt , ##args); \
146 #define IVTV_DEBUG_WARN(fmt, args...) IVTV_DEBUG(IVTV_DBGFLG_WARN, "warn", fmt , ## args)
147 #define IVTV_DEBUG_INFO(fmt, args...) IVTV_DEBUG(IVTV_DBGFLG_INFO, "info", fmt , ## args)
148 #define IVTV_DEBUG_MB(fmt, args...) IVTV_DEBUG(IVTV_DBGFLG_MB, "mb", fmt , ## args)
149 #define IVTV_DEBUG_DMA(fmt, args...) IVTV_DEBUG(IVTV_DBGFLG_DMA, "dma", fmt , ## args)
150 #define IVTV_DEBUG_IOCTL(fmt, args...) IVTV_DEBUG(IVTV_DBGFLG_IOCTL, "ioctl", fmt , ## args)
151 #define IVTV_DEBUG_FILE(fmt, args...) IVTV_DEBUG(IVTV_DBGFLG_FILE, "file", fmt , ## args)
152 #define IVTV_DEBUG_I2C(fmt, args...) IVTV_DEBUG(IVTV_DBGFLG_I2C, "i2c", fmt , ## args)
153 #define IVTV_DEBUG_IRQ(fmt, args...) IVTV_DEBUG(IVTV_DBGFLG_IRQ, "irq", fmt , ## args)
154 #define IVTV_DEBUG_DEC(fmt, args...) IVTV_DEBUG(IVTV_DBGFLG_DEC, "dec", fmt , ## args)
155 #define IVTV_DEBUG_YUV(fmt, args...) IVTV_DEBUG(IVTV_DBGFLG_YUV, "yuv", fmt , ## args)
157 #define IVTV_DEBUG_HIGH_VOL(x, type, fmt, args...) \
159 if (((x) & ivtv_debug) && (ivtv_debug & IVTV_DBGFLG_HIGHVOL)) \
160 v4l2_info(&itv->v4l2_dev, " " type ": " fmt , ##args); \
162 #define IVTV_DEBUG_HI_WARN(fmt, args...) IVTV_DEBUG_HIGH_VOL(IVTV_DBGFLG_WARN, "warn", fmt , ## args)
163 #define IVTV_DEBUG_HI_INFO(fmt, args...) IVTV_DEBUG_HIGH_VOL(IVTV_DBGFLG_INFO, "info", fmt , ## args)
164 #define IVTV_DEBUG_HI_MB(fmt, args...) IVTV_DEBUG_HIGH_VOL(IVTV_DBGFLG_MB, "mb", fmt , ## args)
165 #define IVTV_DEBUG_HI_DMA(fmt, args...) IVTV_DEBUG_HIGH_VOL(IVTV_DBGFLG_DMA, "dma", fmt , ## args)
166 #define IVTV_DEBUG_HI_IOCTL(fmt, args...) IVTV_DEBUG_HIGH_VOL(IVTV_DBGFLG_IOCTL, "ioctl", fmt , ## args)
167 #define IVTV_DEBUG_HI_FILE(fmt, args...) IVTV_DEBUG_HIGH_VOL(IVTV_DBGFLG_FILE, "file", fmt , ## args)
168 #define IVTV_DEBUG_HI_I2C(fmt, args...) IVTV_DEBUG_HIGH_VOL(IVTV_DBGFLG_I2C, "i2c", fmt , ## args)
169 #define IVTV_DEBUG_HI_IRQ(fmt, args...) IVTV_DEBUG_HIGH_VOL(IVTV_DBGFLG_IRQ, "irq", fmt , ## args)
170 #define IVTV_DEBUG_HI_DEC(fmt, args...) IVTV_DEBUG_HIGH_VOL(IVTV_DBGFLG_DEC, "dec", fmt , ## args)
171 #define IVTV_DEBUG_HI_YUV(fmt, args...) IVTV_DEBUG_HIGH_VOL(IVTV_DBGFLG_YUV, "yuv", fmt , ## args)
174 #define IVTV_ERR(fmt, args...) v4l2_err(&itv->v4l2_dev, fmt , ## args)
175 #define IVTV_WARN(fmt, args...) v4l2_warn(&itv->v4l2_dev, fmt , ## args)
176 #define IVTV_INFO(fmt, args...) v4l2_info(&itv->v4l2_dev, fmt , ## args)
182 #define OUT_UDMA_YUV 3
183 #define OUT_PASSTHROUGH 4
185 #define IVTV_MAX_PGM_INDEX (400)
188 #define IVTV_DEFAULT_I2C_CLOCK_PERIOD 20
222 #define IVTV_F_B_NEED_BUF_SWAP (1 << 0)
225 #define IVTV_F_S_DMA_PENDING 0
226 #define IVTV_F_S_DMA_HAS_VBI 1
227 #define IVTV_F_S_NEEDS_DATA 2
229 #define IVTV_F_S_CLAIMED 3
230 #define IVTV_F_S_STREAMING 4
231 #define IVTV_F_S_INTERNAL_USE 5
232 #define IVTV_F_S_PASSTHROUGH 6
233 #define IVTV_F_S_STREAMOFF 7
234 #define IVTV_F_S_APPL_IO 8
236 #define IVTV_F_S_PIO_PENDING 9
237 #define IVTV_F_S_PIO_HAS_VBI 1
240 #define IVTV_F_I_DMA 0
241 #define IVTV_F_I_UDMA 1
242 #define IVTV_F_I_UDMA_PENDING 2
243 #define IVTV_F_I_SPEED_CHANGE 3
244 #define IVTV_F_I_EOS 4
245 #define IVTV_F_I_RADIO_USER 5
246 #define IVTV_F_I_DIG_RST 6
247 #define IVTV_F_I_DEC_YUV 7
248 #define IVTV_F_I_UPDATE_CC 9
249 #define IVTV_F_I_UPDATE_WSS 10
250 #define IVTV_F_I_UPDATE_VPS 11
251 #define IVTV_F_I_DECODING_YUV 12
252 #define IVTV_F_I_ENC_PAUSED 13
253 #define IVTV_F_I_VALID_DEC_TIMINGS 14
254 #define IVTV_F_I_HAVE_WORK 15
255 #define IVTV_F_I_WORK_HANDLER_VBI 16
256 #define IVTV_F_I_WORK_HANDLER_YUV 17
257 #define IVTV_F_I_WORK_HANDLER_PIO 18
258 #define IVTV_F_I_PIO 19
259 #define IVTV_F_I_DEC_PAUSED 20
260 #define IVTV_F_I_INITED 21
261 #define IVTV_F_I_FAILED 22
262 #define IVTV_F_I_WORK_HANDLER_PCM 23
265 #define IVTV_F_I_EV_DEC_STOPPED 28
266 #define IVTV_F_I_EV_VSYNC 29
267 #define IVTV_F_I_EV_VSYNC_FIELD 30
268 #define IVTV_F_I_EV_VSYNC_ENABLED 31
420 #define IVTV_YUV_MODE_INTERLACED 0x00
421 #define IVTV_YUV_MODE_PROGRESSIVE 0x01
422 #define IVTV_YUV_MODE_AUTO 0x02
423 #define IVTV_YUV_MODE_MASK 0x03
425 #define IVTV_YUV_SYNC_EVEN 0x00
426 #define IVTV_YUV_SYNC_ODD 0x04
427 #define IVTV_YUV_SYNC_MASK 0x04
429 #define IVTV_YUV_BUFFERS 8
527 #define IVTV_VBI_FRAMES 32
795 static inline int ivtv_raw_vbi(
const struct ivtv *itv)
809 #define write_sync(val, reg) \
810 do { writel(val, reg); readl(reg); } while (0)
812 #define read_reg(reg) readl(itv->reg_mem + (reg))
813 #define write_reg(val, reg) writel(val, itv->reg_mem + (reg))
814 #define write_reg_sync(val, reg) \
815 do { write_reg(val, reg); read_reg(reg); } while (0)
817 #define read_enc(addr) readl(itv->enc_mem + (u32)(addr))
818 #define write_enc(val, addr) writel(val, itv->enc_mem + (u32)(addr))
819 #define write_enc_sync(val, addr) \
820 do { write_enc(val, addr); read_enc(addr); } while (0)
822 #define read_dec(addr) readl(itv->dec_mem + (u32)(addr))
823 #define write_dec(val, addr) writel(val, itv->dec_mem + (u32)(addr))
824 #define write_dec_sync(val, addr) \
825 do { write_dec(val, addr); read_dec(addr); } while (0)
829 #define ivtv_call_hw(itv, hw, o, f, args...) \
831 struct v4l2_subdev *__sd; \
832 __v4l2_device_call_subdevs_p(&(itv)->v4l2_dev, __sd, \
833 !(hw) || (__sd->grp_id & (hw)), o, f , ##args); \
836 #define ivtv_call_all(itv, o, f, args...) ivtv_call_hw(itv, 0, o, f , ##args)
841 #define ivtv_call_hw_err(itv, hw, o, f, args...) \
843 struct v4l2_subdev *__sd; \
844 __v4l2_device_call_subdevs_until_err_p(&(itv)->v4l2_dev, __sd, \
845 !(hw) || (__sd->grp_id & (hw)), o, f , ##args); \
848 #define ivtv_call_all_err(itv, o, f, args...) ivtv_call_hw_err(itv, 0, o, f , ##args)