diff options
Diffstat (limited to 'drivers/media/video/cx18/cx18-driver.h')
-rw-r--r-- | drivers/media/video/cx18/cx18-driver.h | 71 |
1 files changed, 23 insertions, 48 deletions
diff --git a/drivers/media/video/cx18/cx18-driver.h b/drivers/media/video/cx18/cx18-driver.h index 4801bc7fb5b2..fa8be0731a3f 100644 --- a/drivers/media/video/cx18/cx18-driver.h +++ b/drivers/media/video/cx18/cx18-driver.h | |||
@@ -38,7 +38,6 @@ | |||
38 | #include <linux/i2c-algo-bit.h> | 38 | #include <linux/i2c-algo-bit.h> |
39 | #include <linux/list.h> | 39 | #include <linux/list.h> |
40 | #include <linux/unistd.h> | 40 | #include <linux/unistd.h> |
41 | #include <linux/byteorder/swab.h> | ||
42 | #include <linux/pagemap.h> | 41 | #include <linux/pagemap.h> |
43 | #include <linux/workqueue.h> | 42 | #include <linux/workqueue.h> |
44 | #include <linux/mutex.h> | 43 | #include <linux/mutex.h> |
@@ -64,6 +63,9 @@ | |||
64 | # error "This driver requires kernel PCI support." | 63 | # error "This driver requires kernel PCI support." |
65 | #endif | 64 | #endif |
66 | 65 | ||
66 | /* Default delay to throttle mmio access to the CX23418 */ | ||
67 | #define CX18_DEFAULT_MMIO_NDELAY 0 /* 0 ns = 0 PCI clock(s) / 33 MHz */ | ||
68 | |||
67 | #define CX18_MEM_OFFSET 0x00000000 | 69 | #define CX18_MEM_OFFSET 0x00000000 |
68 | #define CX18_MEM_SIZE 0x04000000 | 70 | #define CX18_MEM_SIZE 0x04000000 |
69 | #define CX18_REG_OFFSET 0x02000000 | 71 | #define CX18_REG_OFFSET 0x02000000 |
@@ -77,7 +79,9 @@ | |||
77 | #define CX18_CARD_COMPRO_H900 2 /* Compro VideoMate H900 */ | 79 | #define CX18_CARD_COMPRO_H900 2 /* Compro VideoMate H900 */ |
78 | #define CX18_CARD_YUAN_MPC718 3 /* Yuan MPC718 */ | 80 | #define CX18_CARD_YUAN_MPC718 3 /* Yuan MPC718 */ |
79 | #define CX18_CARD_CNXT_RAPTOR_PAL 4 /* Conexant Raptor PAL */ | 81 | #define CX18_CARD_CNXT_RAPTOR_PAL 4 /* Conexant Raptor PAL */ |
80 | #define CX18_CARD_LAST 4 | 82 | #define CX18_CARD_TOSHIBA_QOSMIO_DVBT 5 /* Toshiba Qosmio Interal DVB-T/Analog*/ |
83 | #define CX18_CARD_LEADTEK_PVR2100 6 /* Leadtek WinFast PVR2100 */ | ||
84 | #define CX18_CARD_LAST 6 | ||
81 | 85 | ||
82 | #define CX18_ENC_STREAM_TYPE_MPG 0 | 86 | #define CX18_ENC_STREAM_TYPE_MPG 0 |
83 | #define CX18_ENC_STREAM_TYPE_TS 1 | 87 | #define CX18_ENC_STREAM_TYPE_TS 1 |
@@ -97,6 +101,8 @@ | |||
97 | #define CX18_PCI_ID_COMPRO 0x185b | 101 | #define CX18_PCI_ID_COMPRO 0x185b |
98 | #define CX18_PCI_ID_YUAN 0x12ab | 102 | #define CX18_PCI_ID_YUAN 0x12ab |
99 | #define CX18_PCI_ID_CONEXANT 0x14f1 | 103 | #define CX18_PCI_ID_CONEXANT 0x14f1 |
104 | #define CX18_PCI_ID_TOSHIBA 0x1179 | ||
105 | #define CX18_PCI_ID_LEADTEK 0x107D | ||
100 | 106 | ||
101 | /* ======================================================================== */ | 107 | /* ======================================================================== */ |
102 | /* ========================== START USER SETTABLE DMA VARIABLES =========== */ | 108 | /* ========================== START USER SETTABLE DMA VARIABLES =========== */ |
@@ -169,6 +175,7 @@ | |||
169 | 175 | ||
170 | #define CX18_MAX_PGM_INDEX (400) | 176 | #define CX18_MAX_PGM_INDEX (400) |
171 | 177 | ||
178 | extern int cx18_retry_mmio; /* enable check & retry of mmio accesses */ | ||
172 | extern int cx18_debug; | 179 | extern int cx18_debug; |
173 | 180 | ||
174 | 181 | ||
@@ -177,6 +184,7 @@ struct cx18_options { | |||
177 | int cardtype; /* force card type on load */ | 184 | int cardtype; /* force card type on load */ |
178 | int tuner; /* set tuner on load */ | 185 | int tuner; /* set tuner on load */ |
179 | int radio; /* enable/disable radio */ | 186 | int radio; /* enable/disable radio */ |
187 | unsigned long mmio_ndelay; /* delay in ns after every PCI mmio access */ | ||
180 | }; | 188 | }; |
181 | 189 | ||
182 | /* per-buffer bit flags */ | 190 | /* per-buffer bit flags */ |
@@ -216,8 +224,7 @@ struct cx18_buffer { | |||
216 | 224 | ||
217 | struct cx18_queue { | 225 | struct cx18_queue { |
218 | struct list_head list; | 226 | struct list_head list; |
219 | u32 buffers; | 227 | atomic_t buffers; |
220 | u32 length; | ||
221 | u32 bytesused; | 228 | u32 bytesused; |
222 | }; | 229 | }; |
223 | 230 | ||
@@ -237,6 +244,8 @@ struct cx18_dvb { | |||
237 | struct cx18; /* forward reference */ | 244 | struct cx18; /* forward reference */ |
238 | struct cx18_scb; /* forward reference */ | 245 | struct cx18_scb; /* forward reference */ |
239 | 246 | ||
247 | #define CX18_INVALID_TASK_HANDLE 0xffffffff | ||
248 | |||
240 | struct cx18_stream { | 249 | struct cx18_stream { |
241 | /* These first four fields are always set, even if the stream | 250 | /* These first four fields are always set, even if the stream |
242 | is not actually created. */ | 251 | is not actually created. */ |
@@ -259,7 +268,6 @@ struct cx18_stream { | |||
259 | /* Buffer Stats */ | 268 | /* Buffer Stats */ |
260 | u32 buffers; | 269 | u32 buffers; |
261 | u32 buf_size; | 270 | u32 buf_size; |
262 | u32 buffers_stolen; | ||
263 | 271 | ||
264 | /* Buffer Queues */ | 272 | /* Buffer Queues */ |
265 | struct cx18_queue q_free; /* free buffers */ | 273 | struct cx18_queue q_free; /* free buffers */ |
@@ -341,6 +349,13 @@ struct cx18_i2c_algo_callback_data { | |||
341 | int bus_index; /* 0 or 1 for the cx23418's 1st or 2nd I2C bus */ | 349 | int bus_index; /* 0 or 1 for the cx23418's 1st or 2nd I2C bus */ |
342 | }; | 350 | }; |
343 | 351 | ||
352 | #define CX18_MAX_MMIO_RETRIES 10 | ||
353 | |||
354 | struct cx18_mmio_stats { | ||
355 | atomic_t retried_write[CX18_MAX_MMIO_RETRIES+1]; | ||
356 | atomic_t retried_read[CX18_MAX_MMIO_RETRIES+1]; | ||
357 | }; | ||
358 | |||
344 | /* Struct to hold info about cx18 cards */ | 359 | /* Struct to hold info about cx18 cards */ |
345 | struct cx18 { | 360 | struct cx18 { |
346 | int num; /* board number, -1 during init! */ | 361 | int num; /* board number, -1 during init! */ |
@@ -430,6 +445,9 @@ struct cx18 { | |||
430 | u32 gpio_val; | 445 | u32 gpio_val; |
431 | struct mutex gpio_lock; | 446 | struct mutex gpio_lock; |
432 | 447 | ||
448 | /* Statistics */ | ||
449 | struct cx18_mmio_stats mmio_stats; | ||
450 | |||
433 | /* v4l2 and User settings */ | 451 | /* v4l2 and User settings */ |
434 | 452 | ||
435 | /* codec settings */ | 453 | /* codec settings */ |
@@ -458,47 +476,4 @@ void cx18_read_eeprom(struct cx18 *cx, struct tveeprom *tv); | |||
458 | /* First-open initialization: load firmware, etc. */ | 476 | /* First-open initialization: load firmware, etc. */ |
459 | int cx18_init_on_first_open(struct cx18 *cx); | 477 | int cx18_init_on_first_open(struct cx18 *cx); |
460 | 478 | ||
461 | /* This is a PCI post thing, where if the pci register is not read, then | ||
462 | the write doesn't always take effect right away. By reading back the | ||
463 | register any pending PCI writes will be performed (in order), and so | ||
464 | you can be sure that the writes are guaranteed to be done. | ||
465 | |||
466 | Rarely needed, only in some timing sensitive cases. | ||
467 | Apparently if this is not done some motherboards seem | ||
468 | to kill the firmware and get into the broken state until computer is | ||
469 | rebooted. */ | ||
470 | #define write_sync(val, reg) \ | ||
471 | do { writel(val, reg); readl(reg); } while (0) | ||
472 | |||
473 | #define read_reg(reg) readl(cx->reg_mem + (reg)) | ||
474 | #define write_reg(val, reg) writel(val, cx->reg_mem + (reg)) | ||
475 | #define write_reg_sync(val, reg) \ | ||
476 | do { write_reg(val, reg); read_reg(reg); } while (0) | ||
477 | |||
478 | #define read_enc(addr) readl(cx->enc_mem + (u32)(addr)) | ||
479 | #define write_enc(val, addr) writel(val, cx->enc_mem + (u32)(addr)) | ||
480 | #define write_enc_sync(val, addr) \ | ||
481 | do { write_enc(val, addr); read_enc(addr); } while (0) | ||
482 | |||
483 | #define sw1_irq_enable(val) do { \ | ||
484 | write_reg(val, SW1_INT_STATUS); \ | ||
485 | write_reg(read_reg(SW1_INT_ENABLE_PCI) | (val), SW1_INT_ENABLE_PCI); \ | ||
486 | } while (0) | ||
487 | |||
488 | #define sw1_irq_disable(val) \ | ||
489 | write_reg(read_reg(SW1_INT_ENABLE_PCI) & ~(val), SW1_INT_ENABLE_PCI); | ||
490 | |||
491 | #define sw2_irq_enable(val) do { \ | ||
492 | write_reg(val, SW2_INT_STATUS); \ | ||
493 | write_reg(read_reg(SW2_INT_ENABLE_PCI) | (val), SW2_INT_ENABLE_PCI); \ | ||
494 | } while (0) | ||
495 | |||
496 | #define sw2_irq_disable(val) \ | ||
497 | write_reg(read_reg(SW2_INT_ENABLE_PCI) & ~(val), SW2_INT_ENABLE_PCI); | ||
498 | |||
499 | #define setup_page(addr) do { \ | ||
500 | u32 val = read_reg(0xD000F8) & ~0x1f00; \ | ||
501 | write_reg(val | (((addr) >> 17) & 0x1f00), 0xD000F8); \ | ||
502 | } while (0) | ||
503 | |||
504 | #endif /* CX18_DRIVER_H */ | 479 | #endif /* CX18_DRIVER_H */ |