[PATCH] dvb: b2c2/flexcop driver refactoring part 2: add modular Flexcop driver
[safe/jmp/linux-2.6] / drivers / media / dvb / b2c2 / flexcop-usb.h
1 #ifndef __FLEXCOP_USB_H_INCLUDED__
2 #define __FLEXCOP_USB_H_INCLUDED__
3
4 #include <linux/usb.h>
5
6 /* transfer parameters */
7 #define B2C2_USB_FRAMES_PER_ISO         4
8 #define B2C2_USB_NUM_ISO_URB            4
9
10 #define B2C2_USB_CTRL_PIPE_IN           usb_rcvctrlpipe(fc_usb->udev,0)
11 #define B2C2_USB_CTRL_PIPE_OUT          usb_sndctrlpipe(fc_usb->udev,0)
12 #define B2C2_USB_DATA_PIPE                      usb_rcvisocpipe(fc_usb->udev,0x81)
13
14 struct flexcop_usb {
15         struct usb_device *udev;
16         struct usb_interface *uintf;
17
18         u8 *iso_buffer;
19         int buffer_size;
20         dma_addr_t dma_addr;
21         struct urb *iso_urb[B2C2_USB_NUM_ISO_URB];
22
23         struct flexcop_device *fc_dev;
24 };
25
26 #if 0
27 /* request types TODO What is its use?*/
28 typedef enum {
29
30 /* something is wrong with this part
31         RTYPE_READ_DW         = (1 << 6),
32         RTYPE_WRITE_DW_1      = (3 << 6),
33         RTYPE_READ_V8_MEMORY  = (6 << 6),
34         RTYPE_WRITE_V8_MEMORY = (7 << 6),
35         RTYPE_WRITE_V8_FLASH  = (8 << 6),
36         RTYPE_GENERIC         = (9 << 6),
37 */
38 } flexcop_usb_request_type_t;
39 #endif
40
41 /* request */
42 typedef enum {
43         B2C2_USB_WRITE_V8_MEM = 0x04,
44         B2C2_USB_READ_V8_MEM  = 0x05,
45         B2C2_USB_READ_REG     = 0x08,
46         B2C2_USB_WRITE_REG    = 0x0A,
47 /*      B2C2_USB_WRITEREGLO   = 0x0A, */
48         B2C2_USB_WRITEREGHI   = 0x0B,
49         B2C2_USB_FLASH_BLOCK  = 0x10,
50         B2C2_USB_I2C_REQUEST  = 0x11,
51         B2C2_USB_UTILITY      = 0x12,
52 } flexcop_usb_request_t;
53
54 /* function definition for I2C_REQUEST */
55 typedef enum {
56         USB_FUNC_I2C_WRITE       = 0x01,
57         USB_FUNC_I2C_MULTIWRITE  = 0x02,
58         USB_FUNC_I2C_READ        = 0x03,
59         USB_FUNC_I2C_REPEATWRITE = 0x04,
60         USB_FUNC_GET_DESCRIPTOR  = 0x05,
61         USB_FUNC_I2C_REPEATREAD  = 0x06,
62 /* DKT 020208 - add this to support special case of DiSEqC */
63         USB_FUNC_I2C_CHECKWRITE  = 0x07,
64         USB_FUNC_I2C_CHECKRESULT = 0x08,
65 } flexcop_usb_i2c_function_t;
66
67 /*
68  * function definition for UTILITY request 0x12
69  * DKT 020304 - new utility function
70  */
71 typedef enum {
72         UTILITY_SET_FILTER          = 0x01,
73         UTILITY_DATA_ENABLE         = 0x02,
74         UTILITY_FLEX_MULTIWRITE     = 0x03,
75         UTILITY_SET_BUFFER_SIZE     = 0x04,
76         UTILITY_FLEX_OPERATOR       = 0x05,
77         UTILITY_FLEX_RESET300_START = 0x06,
78         UTILITY_FLEX_RESET300_STOP  = 0x07,
79         UTILITY_FLEX_RESET300       = 0x08,
80         UTILITY_SET_ISO_SIZE        = 0x09,
81         UTILITY_DATA_RESET          = 0x0A,
82         UTILITY_GET_DATA_STATUS     = 0x10,
83         UTILITY_GET_V8_REG          = 0x11,
84 /* DKT 020326 - add function for v1.14 */
85         UTILITY_SRAM_WRITE          = 0x12,
86         UTILITY_SRAM_READ           = 0x13,
87         UTILITY_SRAM_TESTFILL       = 0x14,
88         UTILITY_SRAM_TESTSET        = 0x15,
89         UTILITY_SRAM_TESTVERIFY     = 0x16,
90 } flexcop_usb_utility_function_t;
91
92 #define B2C2_WAIT_FOR_OPERATION_RW  1*HZ       /* 1 s */
93 #define B2C2_WAIT_FOR_OPERATION_RDW 3*HZ       /* 3 s */
94 #define B2C2_WAIT_FOR_OPERATION_WDW 1*HZ       /* 1 s */
95
96 #define B2C2_WAIT_FOR_OPERATION_V8READ   3*HZ  /* 3 s */
97 #define B2C2_WAIT_FOR_OPERATION_V8WRITE  3*HZ  /* 3 s */
98 #define B2C2_WAIT_FOR_OPERATION_V8FLASH  3*HZ  /* 3 s */
99
100 typedef enum {
101         V8_MEMORY_PAGE_DVB_CI = 0x20,
102         V8_MEMORY_PAGE_DVB_DS = 0x40,
103         V8_MEMORY_PAGE_MULTI2 = 0x60,
104         V8_MEMORY_PAGE_FLASH  = 0x80
105 } flexcop_usb_mem_page_t;
106
107 #define V8_MEMORY_EXTENDED      (1 << 15)
108
109 #define USB_MEM_READ_MAX                32
110 #define USB_MEM_WRITE_MAX               1
111 #define USB_FLASH_MAX                   8
112
113 #define V8_MEMORY_PAGE_SIZE     0x8000      // 32K
114 #define V8_MEMORY_PAGE_MASK     0x7FFF
115
116 #endif