Steven Toth | 443c1228 | 2009-05-09 21:17:28 -0300 | [diff] [blame] | 1 | /* |
| 2 | * Driver for the NXP SAA7164 PCIe bridge |
| 3 | * |
Steven Toth | 9b8b019 | 2010-07-31 14:39:44 -0300 | [diff] [blame] | 4 | * Copyright (c) 2010 Steven Toth <stoth@kernellabs.com> |
Steven Toth | 443c1228 | 2009-05-09 21:17:28 -0300 | [diff] [blame] | 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 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 | * |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 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., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 20 | */ |
| 21 | |
| 22 | /* |
| 23 | Driver architecture |
| 24 | ******************* |
| 25 | |
| 26 | saa7164_core.c/buffer.c/cards.c/i2c.c/dvb.c |
| 27 | | : Standard Linux driver framework for creating |
| 28 | | : exposing and managing interfaces to the rest |
| 29 | | : of the kernel or userland. Also uses _fw.c to load |
| 30 | | : firmware direct into the PCIe bus, bypassing layers. |
| 31 | V |
| 32 | saa7164_api..() : Translate kernel specific functions/features |
| 33 | | : into command buffers. |
| 34 | V |
| 35 | saa7164_cmd..() : Manages the flow of command packets on/off, |
| 36 | | : the bus. Deal with bus errors, timeouts etc. |
| 37 | V |
| 38 | saa7164_bus..() : Manage a read/write memory ring buffer in the |
| 39 | | : PCIe Address space. |
| 40 | | |
| 41 | | saa7164_fw...() : Load any frimware |
| 42 | | | : direct into the device |
| 43 | V V |
| 44 | <- ----------------- PCIe address space -------------------- -> |
| 45 | */ |
| 46 | |
| 47 | #include <linux/pci.h> |
| 48 | #include <linux/i2c.h> |
| 49 | #include <linux/i2c-algo-bit.h> |
| 50 | #include <linux/kdev_t.h> |
Steven Toth | 7615e43 | 2010-07-31 14:44:53 -0300 | [diff] [blame^] | 51 | #include <linux/version.h> |
| 52 | #include <linux/mutex.h> |
Steven Toth | 443c1228 | 2009-05-09 21:17:28 -0300 | [diff] [blame] | 53 | |
| 54 | #include <media/tuner.h> |
| 55 | #include <media/tveeprom.h> |
| 56 | #include <media/videobuf-dma-sg.h> |
| 57 | #include <media/videobuf-dvb.h> |
Steven Toth | 7615e43 | 2010-07-31 14:44:53 -0300 | [diff] [blame^] | 58 | #include <linux/smp_lock.h> |
| 59 | #include <dvb_demux.h> |
| 60 | #include <dvb_frontend.h> |
| 61 | #include <dvb_net.h> |
| 62 | #include <dvbdev.h> |
| 63 | #include <dmxdev.h> |
| 64 | #include <media/v4l2-common.h> |
| 65 | #include <media/v4l2-ioctl.h> |
| 66 | #include <media/v4l2-chip-ident.h> |
Steven Toth | 443c1228 | 2009-05-09 21:17:28 -0300 | [diff] [blame] | 67 | |
| 68 | #include "saa7164-reg.h" |
| 69 | #include "saa7164-types.h" |
| 70 | |
Steven Toth | 443c1228 | 2009-05-09 21:17:28 -0300 | [diff] [blame] | 71 | #define SAA7164_MAXBOARDS 8 |
| 72 | |
| 73 | #define UNSET (-1U) |
| 74 | #define SAA7164_BOARD_NOAUTO UNSET |
| 75 | #define SAA7164_BOARD_UNKNOWN 0 |
| 76 | #define SAA7164_BOARD_UNKNOWN_REV2 1 |
| 77 | #define SAA7164_BOARD_UNKNOWN_REV3 2 |
| 78 | #define SAA7164_BOARD_HAUPPAUGE_HVR2250 3 |
| 79 | #define SAA7164_BOARD_HAUPPAUGE_HVR2200 4 |
| 80 | #define SAA7164_BOARD_HAUPPAUGE_HVR2200_2 5 |
| 81 | #define SAA7164_BOARD_HAUPPAUGE_HVR2200_3 6 |
| 82 | #define SAA7164_BOARD_HAUPPAUGE_HVR2250_2 7 |
Steven Toth | e333522 | 2009-05-11 22:03:07 -0300 | [diff] [blame] | 83 | #define SAA7164_BOARD_HAUPPAUGE_HVR2250_3 8 |
Steven Toth | 443c1228 | 2009-05-09 21:17:28 -0300 | [diff] [blame] | 84 | |
| 85 | #define SAA7164_MAX_UNITS 8 |
| 86 | #define SAA7164_TS_NUMBER_OF_LINES 312 |
| 87 | #define SAA7164_PT_ENTRIES 16 /* (312 * 188) / 4096 */ |
Steven Toth | 7615e43 | 2010-07-31 14:44:53 -0300 | [diff] [blame^] | 88 | #define SAA7164_MAX_ENCODER_BUFFERS 16 |
| 89 | |
| 90 | /* Port related defines */ |
| 91 | #define SAA7164_PORT_TS1 (0) |
| 92 | #define SAA7164_PORT_TS2 (SAA7164_PORT_TS1 + 1) |
| 93 | #define SAA7164_PORT_ENC1 (SAA7164_PORT_TS2 + 1) |
| 94 | #define SAA7164_PORT_ENC2 (SAA7164_PORT_ENC1 + 1) |
| 95 | #define SAA7164_MAX_PORTS (SAA7164_PORT_ENC2 + 1) |
Steven Toth | 443c1228 | 2009-05-09 21:17:28 -0300 | [diff] [blame] | 96 | |
| 97 | #define DBGLVL_FW 4 |
| 98 | #define DBGLVL_DVB 8 |
| 99 | #define DBGLVL_I2C 16 |
| 100 | #define DBGLVL_API 32 |
| 101 | #define DBGLVL_CMD 64 |
| 102 | #define DBGLVL_BUS 128 |
| 103 | #define DBGLVL_IRQ 256 |
| 104 | #define DBGLVL_BUF 512 |
Steven Toth | 9b8b019 | 2010-07-31 14:39:44 -0300 | [diff] [blame] | 105 | #define DBGLVL_ENC 1024 |
Steven Toth | 443c1228 | 2009-05-09 21:17:28 -0300 | [diff] [blame] | 106 | |
Steven Toth | 7615e43 | 2010-07-31 14:44:53 -0300 | [diff] [blame^] | 107 | #define SAA7164_NORMS ( V4L2_STD_NTSC_M | V4L2_STD_NTSC_M_JP | V4L2_STD_NTSC_443 ) |
| 108 | |
Steven Toth | 443c1228 | 2009-05-09 21:17:28 -0300 | [diff] [blame] | 109 | enum port_t { |
| 110 | SAA7164_MPEG_UNDEFINED = 0, |
| 111 | SAA7164_MPEG_DVB, |
Steven Toth | add3f58 | 2010-07-31 14:43:07 -0300 | [diff] [blame] | 112 | SAA7164_MPEG_ENCODER, |
Steven Toth | 443c1228 | 2009-05-09 21:17:28 -0300 | [diff] [blame] | 113 | }; |
| 114 | |
| 115 | enum saa7164_i2c_bus_nr { |
| 116 | SAA7164_I2C_BUS_0 = 0, |
| 117 | SAA7164_I2C_BUS_1, |
| 118 | SAA7164_I2C_BUS_2, |
| 119 | }; |
| 120 | |
| 121 | enum saa7164_buffer_flags { |
| 122 | SAA7164_BUFFER_UNDEFINED = 0, |
| 123 | SAA7164_BUFFER_FREE, |
| 124 | SAA7164_BUFFER_BUSY, |
| 125 | SAA7164_BUFFER_FULL |
| 126 | }; |
| 127 | |
| 128 | enum saa7164_unit_type { |
| 129 | SAA7164_UNIT_UNDEFINED = 0, |
| 130 | SAA7164_UNIT_DIGITAL_DEMODULATOR, |
| 131 | SAA7164_UNIT_ANALOG_DEMODULATOR, |
| 132 | SAA7164_UNIT_TUNER, |
| 133 | SAA7164_UNIT_EEPROM, |
| 134 | SAA7164_UNIT_ZILOG_IRBLASTER, |
| 135 | SAA7164_UNIT_ENCODER, |
| 136 | }; |
| 137 | |
| 138 | /* The PCIe bridge doesn't grant direct access to i2c. |
| 139 | * Instead, you address i2c devices using a uniqely |
| 140 | * allocated 'unitid' value via a messaging API. This |
| 141 | * is a problem. The kernel and existing demod/tuner |
| 142 | * drivers expect to talk 'i2c', so we have to maintain |
| 143 | * a translation layer, and a series of functions to |
| 144 | * convert i2c bus + device address into a unit id. |
| 145 | */ |
| 146 | struct saa7164_unit { |
| 147 | enum saa7164_unit_type type; |
| 148 | u8 id; |
| 149 | char *name; |
| 150 | enum saa7164_i2c_bus_nr i2c_bus_nr; |
| 151 | u8 i2c_bus_addr; |
| 152 | u8 i2c_reg_len; |
| 153 | }; |
| 154 | |
| 155 | struct saa7164_board { |
| 156 | char *name; |
Steven Toth | 7615e43 | 2010-07-31 14:44:53 -0300 | [diff] [blame^] | 157 | enum port_t porta, portb, portc, portd; |
Steven Toth | 443c1228 | 2009-05-09 21:17:28 -0300 | [diff] [blame] | 158 | enum { |
| 159 | SAA7164_CHIP_UNDEFINED = 0, |
| 160 | SAA7164_CHIP_REV2, |
| 161 | SAA7164_CHIP_REV3, |
| 162 | } chiprev; |
| 163 | struct saa7164_unit unit[SAA7164_MAX_UNITS]; |
| 164 | }; |
| 165 | |
| 166 | struct saa7164_subid { |
| 167 | u16 subvendor; |
| 168 | u16 subdevice; |
| 169 | u32 card; |
| 170 | }; |
| 171 | |
Steven Toth | 7615e43 | 2010-07-31 14:44:53 -0300 | [diff] [blame^] | 172 | struct saa7164_fh { |
| 173 | struct saa7164_port *port; |
| 174 | u32 freq; |
| 175 | u32 tuner_type; |
| 176 | atomic_t v4l_reading; |
| 177 | }; |
| 178 | |
| 179 | struct saa7164_user_buffer { |
| 180 | struct list_head list; |
| 181 | |
| 182 | /* Attributes */ |
| 183 | u8 *data; |
| 184 | u32 pos; |
| 185 | u32 actual_size; |
| 186 | }; |
| 187 | |
Steven Toth | 443c1228 | 2009-05-09 21:17:28 -0300 | [diff] [blame] | 188 | struct saa7164_fw_status { |
| 189 | |
| 190 | /* RISC Core details */ |
| 191 | u32 status; |
| 192 | u32 mode; |
| 193 | u32 spec; |
| 194 | u32 inst; |
| 195 | u32 cpuload; |
| 196 | u32 remainheap; |
| 197 | |
| 198 | /* Firmware version */ |
| 199 | u32 version; |
| 200 | u32 major; |
| 201 | u32 sub; |
| 202 | u32 rel; |
| 203 | u32 buildnr; |
| 204 | }; |
| 205 | |
| 206 | struct saa7164_dvb { |
| 207 | struct mutex lock; |
| 208 | struct dvb_adapter adapter; |
| 209 | struct dvb_frontend *frontend; |
| 210 | struct dvb_demux demux; |
| 211 | struct dmxdev dmxdev; |
| 212 | struct dmx_frontend fe_hw; |
| 213 | struct dmx_frontend fe_mem; |
| 214 | struct dvb_net net; |
| 215 | int feeding; |
| 216 | }; |
| 217 | |
| 218 | struct saa7164_i2c { |
| 219 | struct saa7164_dev *dev; |
| 220 | |
| 221 | enum saa7164_i2c_bus_nr nr; |
| 222 | |
| 223 | /* I2C I/O */ |
| 224 | struct i2c_adapter i2c_adap; |
| 225 | struct i2c_algo_bit_data i2c_algo; |
| 226 | struct i2c_client i2c_client; |
| 227 | u32 i2c_rc; |
| 228 | }; |
| 229 | |
Steven Toth | 7615e43 | 2010-07-31 14:44:53 -0300 | [diff] [blame^] | 230 | struct saa7164_ctrl { |
| 231 | struct v4l2_queryctrl v; |
| 232 | }; |
| 233 | |
| 234 | struct saa7164_tvnorm { |
| 235 | char *name; |
| 236 | v4l2_std_id id; |
| 237 | // u32 cxiformat; |
| 238 | // u32 cxoformat; |
| 239 | }; |
| 240 | |
| 241 | struct saa7164_encoder_params { |
| 242 | struct saa7164_tvnorm encodernorm; |
| 243 | u32 height; |
| 244 | u32 width; |
| 245 | u32 is_50hz; |
| 246 | u32 bitrate; /* bps */ |
| 247 | u32 stream_type; /* V4L2_MPEG_STREAM_TYPE_MPEG2_TS */ |
| 248 | |
| 249 | u32 audio_sampling_freq; |
| 250 | u32 ctl_mute; |
| 251 | u32 ctl_aspect; |
| 252 | }; |
| 253 | |
Steven Toth | add3f58 | 2010-07-31 14:43:07 -0300 | [diff] [blame] | 254 | struct saa7164_port; |
Steven Toth | 443c1228 | 2009-05-09 21:17:28 -0300 | [diff] [blame] | 255 | |
| 256 | struct saa7164_buffer { |
| 257 | struct list_head list; |
| 258 | |
Steven Toth | add3f58 | 2010-07-31 14:43:07 -0300 | [diff] [blame] | 259 | /* Note of which h/w buffer list index position we occupy */ |
| 260 | int idx; |
Steven Toth | 443c1228 | 2009-05-09 21:17:28 -0300 | [diff] [blame] | 261 | |
Steven Toth | add3f58 | 2010-07-31 14:43:07 -0300 | [diff] [blame] | 262 | struct saa7164_port *port; |
Steven Toth | 443c1228 | 2009-05-09 21:17:28 -0300 | [diff] [blame] | 263 | |
| 264 | /* Hardware Specific */ |
| 265 | /* PCI Memory allocations */ |
| 266 | enum saa7164_buffer_flags flags; /* Free, Busy, Full */ |
| 267 | |
| 268 | /* A block of page align PCI memory */ |
| 269 | u32 pci_size; /* PCI allocation size in bytes */ |
| 270 | u64 *cpu; /* Virtual address */ |
| 271 | dma_addr_t dma; /* Physical address */ |
| 272 | |
| 273 | /* A page table that splits the block into a number of entries */ |
| 274 | u32 pt_size; /* PCI allocation size in bytes */ |
| 275 | u64 *pt_cpu; /* Virtual address */ |
| 276 | dma_addr_t pt_dma; /* Physical address */ |
Steven Toth | add3f58 | 2010-07-31 14:43:07 -0300 | [diff] [blame] | 277 | |
| 278 | /* Encoder fops */ |
| 279 | u32 pos; |
| 280 | u32 actual_size; |
Steven Toth | 443c1228 | 2009-05-09 21:17:28 -0300 | [diff] [blame] | 281 | }; |
| 282 | |
Steven Toth | add3f58 | 2010-07-31 14:43:07 -0300 | [diff] [blame] | 283 | struct saa7164_port { |
Steven Toth | 443c1228 | 2009-05-09 21:17:28 -0300 | [diff] [blame] | 284 | |
| 285 | struct saa7164_dev *dev; |
Steven Toth | 443c1228 | 2009-05-09 21:17:28 -0300 | [diff] [blame] | 286 | enum port_t type; |
Steven Toth | add3f58 | 2010-07-31 14:43:07 -0300 | [diff] [blame] | 287 | int nr; |
Steven Toth | 443c1228 | 2009-05-09 21:17:28 -0300 | [diff] [blame] | 288 | |
Steven Toth | add3f58 | 2010-07-31 14:43:07 -0300 | [diff] [blame] | 289 | /* --- Generic port attributes --- */ |
Steven Toth | 443c1228 | 2009-05-09 21:17:28 -0300 | [diff] [blame] | 290 | |
Steven Toth | add3f58 | 2010-07-31 14:43:07 -0300 | [diff] [blame] | 291 | /* HW stream parameters */ |
Steven Toth | 443c1228 | 2009-05-09 21:17:28 -0300 | [diff] [blame] | 292 | tmHWStreamParameters_t hw_streamingparams; |
| 293 | |
| 294 | /* DMA configuration values, is seeded during initialization */ |
| 295 | tmComResDMATermDescrHeader_t hwcfg; |
| 296 | |
| 297 | /* hardware specific registers */ |
| 298 | u32 bufcounter; |
| 299 | u32 pitch; |
| 300 | u32 bufsize; |
| 301 | u32 bufoffset; |
| 302 | u32 bufptr32l; |
| 303 | u32 bufptr32h; |
| 304 | u64 bufptr64; |
| 305 | |
| 306 | u32 numpte; /* Number of entries in array, only valid in head */ |
Steven Toth | add3f58 | 2010-07-31 14:43:07 -0300 | [diff] [blame] | 307 | |
Steven Toth | 443c1228 | 2009-05-09 21:17:28 -0300 | [diff] [blame] | 308 | struct mutex dmaqueue_lock; |
Steven Toth | 443c1228 | 2009-05-09 21:17:28 -0300 | [diff] [blame] | 309 | struct saa7164_buffer dmaqueue; |
Steven Toth | add3f58 | 2010-07-31 14:43:07 -0300 | [diff] [blame] | 310 | |
| 311 | /* --- DVB Transport Specific --- */ |
| 312 | struct saa7164_dvb dvb; |
| 313 | |
| 314 | /* --- Encoder/V4L related attributes --- */ |
Steven Toth | 7615e43 | 2010-07-31 14:44:53 -0300 | [diff] [blame^] | 315 | /* Encoder */ |
| 316 | /* Defaults established in saa7164-encoder.c */ |
| 317 | struct saa7164_tvnorm encodernorm; |
| 318 | u32 height; |
| 319 | u32 width; |
| 320 | u32 freq; |
| 321 | u32 ts_packet_size; |
| 322 | u32 ts_packet_count; |
| 323 | u8 mux_input; |
| 324 | u8 encoder_profile; |
| 325 | u8 video_format; |
| 326 | u8 audio_format; |
| 327 | u8 video_resolution; |
| 328 | u16 ctl_brightness; |
| 329 | u16 ctl_contrast; |
| 330 | u16 ctl_hue; |
| 331 | u16 ctl_saturation; |
| 332 | u16 ctl_sharpness; |
| 333 | s8 ctl_volume; |
Steven Toth | 443c1228 | 2009-05-09 21:17:28 -0300 | [diff] [blame] | 334 | |
Steven Toth | 7615e43 | 2010-07-31 14:44:53 -0300 | [diff] [blame^] | 335 | tmComResAFeatureDescrHeader_t audfeat; |
| 336 | tmComResEncoderDescrHeader_t encunit; |
| 337 | tmComResProcDescrHeader_t vidproc; |
| 338 | tmComResExtDevDescrHeader_t ifunit; |
| 339 | tmComResTunerDescrHeader_t tunerunit; |
| 340 | |
| 341 | /* V4L */ |
| 342 | struct saa7164_encoder_params encoder_params; |
| 343 | struct video_device *v4l_device; |
| 344 | atomic_t v4l_reader_count; |
| 345 | // spinlock_t slock; |
| 346 | // struct mutex fops_lock; |
| 347 | |
| 348 | struct saa7164_buffer list_buf_used; |
| 349 | struct saa7164_buffer list_buf_free; |
| 350 | wait_queue_head_t wait_read; |
Steven Toth | 443c1228 | 2009-05-09 21:17:28 -0300 | [diff] [blame] | 351 | }; |
| 352 | |
| 353 | struct saa7164_dev { |
| 354 | struct list_head devlist; |
| 355 | atomic_t refcount; |
| 356 | |
| 357 | /* pci stuff */ |
| 358 | struct pci_dev *pci; |
| 359 | unsigned char pci_rev, pci_lat; |
| 360 | int pci_bus, pci_slot; |
| 361 | u32 __iomem *lmmio; |
| 362 | u8 __iomem *bmmio; |
| 363 | u32 __iomem *lmmio2; |
| 364 | u8 __iomem *bmmio2; |
| 365 | int pci_irqmask; |
| 366 | |
| 367 | /* board details */ |
| 368 | int nr; |
| 369 | int hwrevision; |
| 370 | u32 board; |
| 371 | char name[32]; |
| 372 | |
| 373 | /* firmware status */ |
| 374 | struct saa7164_fw_status fw_status; |
| 375 | |
| 376 | tmComResHWDescr_t hwdesc; |
| 377 | tmComResInterfaceDescr_t intfdesc; |
| 378 | tmComResBusDescr_t busdesc; |
| 379 | |
| 380 | tmComResBusInfo_t bus; |
| 381 | |
Steven Toth | 1a6450d | 2009-05-10 14:08:27 -0300 | [diff] [blame] | 382 | /* Interrupt status and ack registers */ |
| 383 | u32 int_status; |
| 384 | u32 int_ack; |
Steven Toth | 443c1228 | 2009-05-09 21:17:28 -0300 | [diff] [blame] | 385 | |
| 386 | struct cmd cmds[SAA_CMD_MAX_MSG_UNITS]; |
| 387 | struct mutex lock; |
| 388 | |
| 389 | /* I2c related */ |
| 390 | struct saa7164_i2c i2c_bus[3]; |
| 391 | |
| 392 | /* Transport related */ |
Steven Toth | 7615e43 | 2010-07-31 14:44:53 -0300 | [diff] [blame^] | 393 | struct saa7164_port ports[ SAA7164_MAX_PORTS ]; |
Steven Toth | 443c1228 | 2009-05-09 21:17:28 -0300 | [diff] [blame] | 394 | |
| 395 | /* Deferred command/api interrupts handling */ |
| 396 | struct work_struct workcmd; |
| 397 | |
| 398 | }; |
| 399 | |
| 400 | extern struct list_head saa7164_devlist; |
Steven Toth | dd1ee44 | 2009-07-30 09:09:30 -0300 | [diff] [blame] | 401 | extern unsigned int waitsecs; |
Steven Toth | 443c1228 | 2009-05-09 21:17:28 -0300 | [diff] [blame] | 402 | |
| 403 | /* ----------------------------------------------------------- */ |
| 404 | /* saa7164-core.c */ |
| 405 | void saa7164_dumpregs(struct saa7164_dev *dev, u32 addr); |
| 406 | void saa7164_dumphex16(struct saa7164_dev *dev, u8 *buf, int len); |
| 407 | void saa7164_getfirmwarestatus(struct saa7164_dev *dev); |
| 408 | u32 saa7164_getcurrentfirmwareversion(struct saa7164_dev *dev); |
| 409 | |
| 410 | /* ----------------------------------------------------------- */ |
| 411 | /* saa7164-fw.c */ |
| 412 | int saa7164_downloadfirmware(struct saa7164_dev *dev); |
| 413 | |
| 414 | /* ----------------------------------------------------------- */ |
| 415 | /* saa7164-i2c.c */ |
| 416 | extern int saa7164_i2c_register(struct saa7164_i2c *bus); |
| 417 | extern int saa7164_i2c_unregister(struct saa7164_i2c *bus); |
| 418 | extern void saa7164_call_i2c_clients(struct saa7164_i2c *bus, |
| 419 | unsigned int cmd, void *arg); |
| 420 | |
| 421 | /* ----------------------------------------------------------- */ |
| 422 | /* saa7164-bus.c */ |
| 423 | int saa7164_bus_setup(struct saa7164_dev *dev); |
| 424 | void saa7164_bus_dump(struct saa7164_dev *dev); |
| 425 | int saa7164_bus_set(struct saa7164_dev *dev, tmComResInfo_t* msg, void *buf); |
| 426 | int saa7164_bus_get(struct saa7164_dev *dev, tmComResInfo_t* msg, |
| 427 | void *buf, int peekonly); |
| 428 | |
| 429 | /* ----------------------------------------------------------- */ |
| 430 | /* saa7164-cmd.c */ |
| 431 | int saa7164_cmd_send(struct saa7164_dev *dev, |
| 432 | u8 id, tmComResCmd_t command, u16 controlselector, |
| 433 | u16 size, void *buf); |
| 434 | void saa7164_cmd_signal(struct saa7164_dev *dev, u8 seqno); |
Steven Toth | 39e469a | 2009-08-12 12:14:37 -0300 | [diff] [blame] | 435 | int saa7164_irq_dequeue(struct saa7164_dev *dev); |
Steven Toth | 443c1228 | 2009-05-09 21:17:28 -0300 | [diff] [blame] | 436 | |
| 437 | /* ----------------------------------------------------------- */ |
| 438 | /* saa7164-api.c */ |
Steven Toth | 443c1228 | 2009-05-09 21:17:28 -0300 | [diff] [blame] | 439 | int saa7164_api_get_fw_version(struct saa7164_dev *dev, u32 *version); |
| 440 | int saa7164_api_enum_subdevs(struct saa7164_dev *dev); |
| 441 | int saa7164_api_i2c_read(struct saa7164_i2c *bus, u8 addr, u32 reglen, u8 *reg, |
| 442 | u32 datalen, u8 *data); |
| 443 | int saa7164_api_i2c_write(struct saa7164_i2c *bus, u8 addr, |
| 444 | u32 datalen, u8 *data); |
| 445 | int saa7164_api_dif_write(struct saa7164_i2c *bus, u8 addr, |
| 446 | u32 datalen, u8 *data); |
| 447 | int saa7164_api_read_eeprom(struct saa7164_dev *dev, u8 *buf, int buflen); |
| 448 | int saa7164_api_set_gpiobit(struct saa7164_dev *dev, u8 unitid, u8 pin); |
| 449 | int saa7164_api_clear_gpiobit(struct saa7164_dev *dev, u8 unitid, u8 pin); |
Steven Toth | add3f58 | 2010-07-31 14:43:07 -0300 | [diff] [blame] | 450 | int saa7164_api_transition_port(struct saa7164_port *port, u8 mode); |
Steven Toth | 7615e43 | 2010-07-31 14:44:53 -0300 | [diff] [blame^] | 451 | int saa7164_api_initialize_dif(struct saa7164_port *port); |
| 452 | int saa7164_api_configure_dif(struct saa7164_port *port, u32 std); |
| 453 | int saa7164_api_set_encoder(struct saa7164_port *port); |
| 454 | int saa7164_api_get_encoder(struct saa7164_port *port); |
| 455 | int saa7164_api_set_aspect_ratio(struct saa7164_port *port); |
| 456 | int saa7164_api_set_usercontrol(struct saa7164_port *port, u8 ctl); |
| 457 | int saa7164_api_get_usercontrol(struct saa7164_port *port, u8 ctl); |
| 458 | int saa7164_api_set_videomux(struct saa7164_port *port); |
| 459 | int saa7164_api_audio_mute(struct saa7164_port *port, int mute); |
| 460 | int saa7164_api_set_audio_volume(struct saa7164_port *port, s8 level); |
| 461 | int saa7164_api_set_audio_std(struct saa7164_port *port); |
| 462 | int saa7164_api_set_audio_detection(struct saa7164_port *port, int autodetect); |
| 463 | int saa7164_api_get_videomux(struct saa7164_port *port); |
Steven Toth | 443c1228 | 2009-05-09 21:17:28 -0300 | [diff] [blame] | 464 | |
| 465 | /* ----------------------------------------------------------- */ |
| 466 | /* saa7164-cards.c */ |
| 467 | extern struct saa7164_board saa7164_boards[]; |
| 468 | extern const unsigned int saa7164_bcount; |
| 469 | |
| 470 | extern struct saa7164_subid saa7164_subids[]; |
| 471 | extern const unsigned int saa7164_idcount; |
| 472 | |
| 473 | extern void saa7164_card_list(struct saa7164_dev *dev); |
| 474 | extern void saa7164_gpio_setup(struct saa7164_dev *dev); |
| 475 | extern void saa7164_card_setup(struct saa7164_dev *dev); |
| 476 | |
| 477 | extern int saa7164_i2caddr_to_reglen(struct saa7164_i2c *bus, int addr); |
| 478 | extern int saa7164_i2caddr_to_unitid(struct saa7164_i2c *bus, int addr); |
| 479 | extern char *saa7164_unitid_name(struct saa7164_dev *dev, u8 unitid); |
| 480 | |
| 481 | /* ----------------------------------------------------------- */ |
| 482 | /* saa7164-dvb.c */ |
Steven Toth | add3f58 | 2010-07-31 14:43:07 -0300 | [diff] [blame] | 483 | extern int saa7164_dvb_register(struct saa7164_port *port); |
| 484 | extern int saa7164_dvb_unregister(struct saa7164_port *port); |
Steven Toth | 443c1228 | 2009-05-09 21:17:28 -0300 | [diff] [blame] | 485 | |
| 486 | /* ----------------------------------------------------------- */ |
| 487 | /* saa7164-buffer.c */ |
Steven Toth | add3f58 | 2010-07-31 14:43:07 -0300 | [diff] [blame] | 488 | extern struct saa7164_buffer *saa7164_buffer_alloc( |
| 489 | struct saa7164_port *port, u32 len); |
| 490 | extern int saa7164_buffer_dealloc(struct saa7164_buffer *buf); |
| 491 | extern void saa7164_buffer_display(struct saa7164_buffer *buf); |
| 492 | extern int saa7164_buffer_activate(struct saa7164_buffer *buf, int i); |
| 493 | extern int saa7164_buffer_cfg_port(struct saa7164_port *port); |
Steven Toth | 7615e43 | 2010-07-31 14:44:53 -0300 | [diff] [blame^] | 494 | extern struct saa7164_user_buffer *saa7164_buffer_alloc_user( |
| 495 | struct saa7164_dev *dev, u32 len); |
| 496 | extern void saa7164_buffer_dealloc_user(struct saa7164_user_buffer *buf); |
| 497 | |
| 498 | |
| 499 | /* ----------------------------------------------------------- */ |
| 500 | /* saa7164-encoder.c */ |
| 501 | int saa7164_encoder_register(struct saa7164_port *port); |
| 502 | void saa7164_encoder_unregister(struct saa7164_port *port); |
Steven Toth | 443c1228 | 2009-05-09 21:17:28 -0300 | [diff] [blame] | 503 | |
| 504 | /* ----------------------------------------------------------- */ |
| 505 | |
Ingo Molnar | b1912a85 | 2009-09-21 15:23:45 -0300 | [diff] [blame] | 506 | extern unsigned int saa_debug; |
Steven Toth | 443c1228 | 2009-05-09 21:17:28 -0300 | [diff] [blame] | 507 | #define dprintk(level, fmt, arg...)\ |
Ingo Molnar | b1912a85 | 2009-09-21 15:23:45 -0300 | [diff] [blame] | 508 | do { if (saa_debug & level)\ |
Steven Toth | 443c1228 | 2009-05-09 21:17:28 -0300 | [diff] [blame] | 509 | printk(KERN_DEBUG "%s: " fmt, dev->name, ## arg);\ |
| 510 | } while (0) |
| 511 | |
| 512 | #define log_warn(fmt, arg...)\ |
| 513 | do { \ |
| 514 | printk(KERN_WARNING "%s: " fmt, dev->name, ## arg);\ |
| 515 | } while (0) |
| 516 | |
| 517 | #define log_err(fmt, arg...)\ |
| 518 | do { \ |
| 519 | printk(KERN_ERROR "%s: " fmt, dev->name, ## arg);\ |
| 520 | } while (0) |
| 521 | |
| 522 | #define saa7164_readl(reg) readl(dev->lmmio + ((reg) >> 2)) |
Steven Toth | 207b42c | 2009-05-09 21:30:05 -0300 | [diff] [blame] | 523 | #define saa7164_writel(reg, value) writel((value), dev->lmmio + ((reg) >> 2)) |
| 524 | |
Steven Toth | 443c1228 | 2009-05-09 21:17:28 -0300 | [diff] [blame] | 525 | |
| 526 | #define saa7164_readb(reg) readl(dev->bmmio + (reg)) |
| 527 | #define saa7164_writeb(reg, value) writel((value), dev->bmmio + (reg)) |
| 528 | |