FILE
zoran.h
File preview with syntax highlighting.
linux-6.19.14/drivers/media/pci/zoran/zoran.h
1/* SPDX-License-Identifier: GPL-2.0-or-later */ 2/* 3 * zoran - Iomega Buz driver 4 * 5 * Copyright (C) 1999 Rainer Johanni <Rainer@Johanni.de> 6 * 7 * based on 8 * 9 * zoran.0.0.3 Copyright (C) 1998 Dave Perks <dperks@ibm.net> 10 * 11 * and 12 * 13 * bttv - Bt848 frame grabber driver 14 * Copyright (C) 1996,97,98 Ralph Metzler (rjkm@thp.uni-koeln.de) 15 * & Marcus Metzler (mocm@thp.uni-koeln.de) 16 */ 17 18#ifndef _BUZ_H_ 19#define _BUZ_H_ 20 21#include <linux/debugfs.h> 22#include <linux/pci.h> 23#include <linux/i2c-algo-bit.h> 24#include <media/v4l2-device.h> 25#include <media/v4l2-ctrls.h> 26#include <media/videobuf2-core.h> 27#include <media/videobuf2-v4l2.h> 28#include <media/videobuf2-dma-contig.h> 29 30#define ZR_NORM_PAL 0 31#define ZR_NORM_NTSC 1 32#define ZR_NORM_SECAM 2 33 34struct zr_buffer { 35 /* common v4l buffer stuff -- must be first */ 36 struct vb2_v4l2_buffer vbuf; 37 struct list_head queue; 38}; 39 40static inline struct zr_buffer *vb2_to_zr_buffer(struct vb2_buffer *vb) 41{ 42 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); 43 44 return container_of(vbuf, struct zr_buffer, vbuf); 45} 46 47#define ZORAN_NAME "ZORAN" /* name of the device */ 48 49#define ZR_DEVNAME(zr) ((zr)->name) 50 51#define BUZ_MAX_WIDTH (zr->timing->wa) 52#define BUZ_MAX_HEIGHT (zr->timing->ha) 53#define BUZ_MIN_WIDTH 32 /* never display less than 32 pixels */ 54#define BUZ_MIN_HEIGHT 24 /* never display less than 24 rows */ 55 56#define BUZ_NUM_STAT_COM 4 57#define BUZ_MASK_STAT_COM 3 58 59#define BUZ_MAX_INPUT 16 60 61#include "zr36057.h" 62 63enum card_type { 64 UNKNOWN = -1, 65 66 /* Pinnacle/Miro */ 67 DC10_OLD, /* DC30 like */ 68 DC10_NEW, /* DC10_PLUS like */ 69 DC10_PLUS, 70 DC30, 71 DC30_PLUS, 72 73 /* Linux Media Labs */ 74 LML33, 75 LML33R10, 76 77 /* Iomega */ 78 BUZ, 79 80 /* AverMedia */ 81 AVS6EYES, 82 83 /* total number of cards */ 84 NUM_CARDS 85}; 86 87enum zoran_codec_mode { 88 BUZ_MODE_IDLE, /* nothing going on */ 89 BUZ_MODE_MOTION_COMPRESS, /* grabbing frames */ 90 BUZ_MODE_MOTION_DECOMPRESS, /* playing frames */ 91 BUZ_MODE_STILL_COMPRESS, /* still frame conversion */ 92 BUZ_MODE_STILL_DECOMPRESS /* still frame conversion */ 93}; 94 95enum zoran_map_mode { 96 ZORAN_MAP_MODE_NONE, 97 ZORAN_MAP_MODE_RAW, 98 ZORAN_MAP_MODE_JPG_REC, 99 ZORAN_MAP_MODE_JPG_PLAY, 100}; 101 102enum gpio_type { 103 ZR_GPIO_JPEG_SLEEP = 0, 104 ZR_GPIO_JPEG_RESET, 105 ZR_GPIO_JPEG_FRAME, 106 ZR_GPIO_VID_DIR, 107 ZR_GPIO_VID_EN, 108 ZR_GPIO_VID_RESET, 109 ZR_GPIO_CLK_SEL1, 110 ZR_GPIO_CLK_SEL2, 111 ZR_GPIO_MAX, 112}; 113 114enum gpcs_type { 115 GPCS_JPEG_RESET = 0, 116 GPCS_JPEG_START, 117 GPCS_MAX, 118}; 119 120struct zoran_format { 121 char *name; 122 __u32 fourcc; 123 int colorspace; 124 int depth; 125 __u32 flags; 126 __u32 vfespfr; 127}; 128 129/* flags */ 130#define ZORAN_FORMAT_COMPRESSED BIT(0) 131#define ZORAN_FORMAT_OVERLAY BIT(1) 132#define ZORAN_FORMAT_CAPTURE BIT(2) 133#define ZORAN_FORMAT_PLAYBACK BIT(3) 134 135/* v4l-capture settings */ 136struct zoran_v4l_settings { 137 int width, height, bytesperline; /* capture size */ 138 const struct zoran_format *format; /* capture format */ 139}; 140 141/* jpg-capture/-playback settings */ 142struct zoran_jpg_settings { 143 /* this bit is used to set everything to default */ 144 int decimation; 145 /* capture decimation settings (tmp_dcm=1 means both fields) */ 146 int hor_dcm, ver_dcm, tmp_dcm; 147 /* field-settings (odd_even=1 (+tmp_dcm=1) means top-field-first) */ 148 int field_per_buff, odd_even; 149 /* crop settings (subframe capture) */ 150 int img_x, img_y, img_width, img_height; 151 /* JPEG-specific capture settings */ 152 struct v4l2_jpegcompression jpg_comp; 153}; 154 155struct zoran; 156 157struct card_info { 158 enum card_type type; 159 char name[32]; 160 const char *i2c_decoder; /* i2c decoder device */ 161 const unsigned short *addrs_decoder; 162 const char *i2c_encoder; /* i2c encoder device */ 163 const unsigned short *addrs_encoder; 164 u16 video_vfe, video_codec; /* videocodec types */ 165 u16 audio_chip; /* audio type */ 166 167 int inputs; /* number of video inputs */ 168 struct input { 169 int muxsel; 170 char name[32]; 171 } input[BUZ_MAX_INPUT]; 172 173 v4l2_std_id norms; 174 const struct tvnorm *tvn[3]; /* supported TV norms */ 175 176 u32 jpeg_int; /* JPEG interrupt */ 177 u32 vsync_int; /* VSYNC interrupt */ 178 s8 gpio[ZR_GPIO_MAX]; 179 u8 gpcs[GPCS_MAX]; 180 181 struct vfe_polarity vfe_pol; 182 u8 gpio_pol[ZR_GPIO_MAX]; 183 184 /* is the /GWS line connected? */ 185 u8 gws_not_connected; 186 187 /* avs6eyes mux setting */ 188 u8 input_mux; 189 190 void (*init)(struct zoran *zr); 191}; 192 193struct zoran { 194 struct v4l2_device v4l2_dev; 195 struct v4l2_ctrl_handler hdl; 196 struct video_device *video_dev; 197 struct vb2_queue vq; 198 199 struct i2c_adapter i2c_adapter; /* */ 200 struct i2c_algo_bit_data i2c_algo; /* */ 201 u32 i2cbr; 202 203 struct v4l2_subdev *decoder; /* video decoder sub-device */ 204 struct v4l2_subdev *encoder; /* video encoder sub-device */ 205 206 struct videocodec *codec; /* video codec */ 207 struct videocodec *vfe; /* video front end */ 208 209 struct mutex lock; /* file ops serialize lock */ 210 211 u8 initialized; /* flag if zoran has been correctly initialized */ 212 struct card_info card; 213 const struct tvnorm *timing; 214 215 unsigned short id; /* number of this device */ 216 char name[40]; /* name of this device */ 217 struct pci_dev *pci_dev; /* PCI device */ 218 unsigned char revision; /* revision of zr36057 */ 219 unsigned char __iomem *zr36057_mem;/* pointer to mapped IO memory */ 220 221 spinlock_t spinlock; /* Spinlock */ 222 223 /* Video for Linux parameters */ 224 int input; /* card's norm and input */ 225 v4l2_std_id norm; 226 227 /* Current buffer params */ 228 unsigned int buffer_size; 229 230 struct zoran_v4l_settings v4l_settings; /* structure with a lot of things to play with */ 231 232 /* Buz MJPEG parameters */ 233 enum zoran_codec_mode codec_mode; /* status of codec */ 234 struct zoran_jpg_settings jpg_settings; /* structure with a lot of things to play with */ 235 236 /* grab queue counts/indices, mask with BUZ_MASK_STAT_COM before using as index */ 237 /* (dma_head - dma_tail) is number active in DMA, must be <= BUZ_NUM_STAT_COM */ 238 /* (value & BUZ_MASK_STAT_COM) corresponds to index in stat_com table */ 239 unsigned long jpg_que_head; /* Index where to put next buffer which is queued */ 240 unsigned long jpg_dma_head; /* Index of next buffer which goes into stat_com */ 241 unsigned long jpg_dma_tail; /* Index of last buffer in stat_com */ 242 unsigned long jpg_que_tail; /* Index of last buffer in queue */ 243 unsigned long jpg_seq_num; /* count of frames since grab/play started */ 244 unsigned long jpg_err_seq; /* last seq_num before error */ 245 unsigned long jpg_err_shift; 246 unsigned long jpg_queued_num; /* count of frames queued since grab/play started */ 247 unsigned long vbseq; 248 249 /* zr36057's code buffer table */ 250 /* stat_com[i] is indexed by dma_head/tail & BUZ_MASK_STAT_COM */ 251 __le32 *stat_com; 252 253 /* Additional stuff for testing */ 254 unsigned int ghost_int; 255 int intr_counter_GIRQ1; 256 int intr_counter_GIRQ0; 257 int intr_counter_cod_rep_irq; 258 int intr_counter_jpeg_rep_irq; 259 int field_counter; 260 int irq1_in; 261 int irq1_out; 262 int jpeg_in; 263 int jpeg_out; 264 int JPEG_0; 265 int JPEG_1; 266 int end_event_missed; 267 int jpeg_missed; 268 int jpeg_error; 269 int num_errors; 270 int jpeg_max_missed; 271 int jpeg_min_missed; 272 unsigned int prepared; 273 unsigned int queued; 274 275 u32 last_isr; 276 unsigned long frame_num; 277 int running; 278 int buf_in_reserve; 279 280 dma_addr_t p_sc; 281 __le32 *stat_comb; 282 dma_addr_t p_scb; 283 enum zoran_map_mode map_mode; 284 struct list_head queued_bufs; 285 spinlock_t queued_bufs_lock; /* Protects queued_bufs */ 286 struct zr_buffer *inuse[BUZ_NUM_STAT_COM * 2]; 287 struct dentry *dbgfs_dir; 288}; 289 290static inline struct zoran *to_zoran(struct v4l2_device *v4l2_dev) 291{ 292 return container_of(v4l2_dev, struct zoran, v4l2_dev); 293} 294 295/* 296 * There was something called _ALPHA_BUZ that used the PCI address instead of 297 * the kernel iomapped address for btread/btwrite. 298 */ 299#define btwrite(dat, adr) writel((dat), zr->zr36057_mem + (adr)) 300#define btread(adr) readl(zr->zr36057_mem + (adr)) 301 302#define btand(dat, adr) btwrite((dat) & btread(adr), (adr)) 303#define btor(dat, adr) btwrite((dat) | btread(adr), (adr)) 304#define btaor(dat, mask, adr) btwrite((dat) | ((mask) & btread(adr)), (adr)) 305 306#endif 307 308/* 309 * Debugging macros 310 */ 311#define zrdev_dbg(zr, format, args...) \ 312 pci_dbg((zr)->pci_dev, format, ##args) \ 313 314#define zrdev_err(zr, format, args...) \ 315 pci_err((zr)->pci_dev, format, ##args) \ 316 317#define zrdev_info(zr, format, args...) \ 318 pci_info((zr)->pci_dev, format, ##args) \ 319 320int zoran_queue_init(struct zoran *zr, struct vb2_queue *vq, int dir); 321void zoran_queue_exit(struct zoran *zr); 322int zr_set_buf(struct zoran *zr);
~/
Read-only file preview.