saa7146.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  1. #ifndef __SAA7146__
  2. #define __SAA7146__
  3. #include <linux/delay.h> /* for delay-stuff */
  4. #include <linux/slab.h> /* for kmalloc/kfree */
  5. #include <linux/pci.h> /* for pci-config-stuff, vendor ids etc. */
  6. #include <linux/init.h> /* for "__init" */
  7. #include <linux/interrupt.h> /* for IMMEDIATE_BH */
  8. #include <linux/kmod.h> /* for kernel module loader */
  9. #include <linux/i2c.h> /* for i2c subsystem */
  10. #include <asm/io.h> /* for accessing devices */
  11. #include <linux/stringify.h>
  12. #include <linux/mutex.h>
  13. #include <linux/scatterlist.h>
  14. #include <media/v4l2-device.h>
  15. #include <media/v4l2-ctrls.h>
  16. #include <linux/vmalloc.h> /* for vmalloc() */
  17. #include <linux/mm.h> /* for vmalloc_to_page() */
  18. #define saa7146_write(sxy,adr,dat) writel((dat),(sxy->mem+(adr)))
  19. #define saa7146_read(sxy,adr) readl(sxy->mem+(adr))
  20. extern unsigned int saa7146_debug;
  21. #ifndef DEBUG_VARIABLE
  22. #define DEBUG_VARIABLE saa7146_debug
  23. #endif
  24. #define ERR(fmt, ...) pr_err("%s: " fmt, __func__, ##__VA_ARGS__)
  25. #define _DBG(mask, fmt, ...) \
  26. do { \
  27. if (DEBUG_VARIABLE & mask) \
  28. pr_debug("%s(): " fmt, __func__, ##__VA_ARGS__); \
  29. } while (0)
  30. /* simple debug messages */
  31. #define DEB_S(fmt, ...) _DBG(0x01, fmt, ##__VA_ARGS__)
  32. /* more detailed debug messages */
  33. #define DEB_D(fmt, ...) _DBG(0x02, fmt, ##__VA_ARGS__)
  34. /* print enter and exit of functions */
  35. #define DEB_EE(fmt, ...) _DBG(0x04, fmt, ##__VA_ARGS__)
  36. /* i2c debug messages */
  37. #define DEB_I2C(fmt, ...) _DBG(0x08, fmt, ##__VA_ARGS__)
  38. /* vbi debug messages */
  39. #define DEB_VBI(fmt, ...) _DBG(0x10, fmt, ##__VA_ARGS__)
  40. /* interrupt debug messages */
  41. #define DEB_INT(fmt, ...) _DBG(0x20, fmt, ##__VA_ARGS__)
  42. /* capture debug messages */
  43. #define DEB_CAP(fmt, ...) _DBG(0x40, fmt, ##__VA_ARGS__)
  44. #define SAA7146_ISR_CLEAR(x,y) \
  45. saa7146_write(x, ISR, (y));
  46. struct module;
  47. struct saa7146_dev;
  48. struct saa7146_extension;
  49. struct saa7146_vv;
  50. /* saa7146 page table */
  51. struct saa7146_pgtable {
  52. unsigned int size;
  53. __le32 *cpu;
  54. dma_addr_t dma;
  55. /* used for offsets for u,v planes for planar capture modes */
  56. unsigned long offset;
  57. /* used for custom pagetables (used for example by budget dvb cards) */
  58. struct scatterlist *slist;
  59. int nents;
  60. };
  61. struct saa7146_pci_extension_data {
  62. struct saa7146_extension *ext;
  63. void *ext_priv; /* most likely a name string */
  64. };
  65. #define MAKE_EXTENSION_PCI(x_var, x_vendor, x_device) \
  66. { \
  67. .vendor = PCI_VENDOR_ID_PHILIPS, \
  68. .device = PCI_DEVICE_ID_PHILIPS_SAA7146, \
  69. .subvendor = x_vendor, \
  70. .subdevice = x_device, \
  71. .driver_data = (unsigned long)& x_var, \
  72. }
  73. struct saa7146_extension
  74. {
  75. char name[32]; /* name of the device */
  76. #define SAA7146_USE_I2C_IRQ 0x1
  77. #define SAA7146_I2C_SHORT_DELAY 0x2
  78. int flags;
  79. /* pairs of subvendor and subdevice ids for
  80. supported devices, last entry 0xffff, 0xfff */
  81. struct module *module;
  82. struct pci_driver driver;
  83. struct pci_device_id *pci_tbl;
  84. /* extension functions */
  85. int (*probe)(struct saa7146_dev *);
  86. int (*attach)(struct saa7146_dev *, struct saa7146_pci_extension_data *);
  87. int (*detach)(struct saa7146_dev*);
  88. u32 irq_mask; /* mask to indicate, which irq-events are handled by the extension */
  89. void (*irq_func)(struct saa7146_dev*, u32* irq_mask);
  90. };
  91. struct saa7146_dma
  92. {
  93. dma_addr_t dma_handle;
  94. __le32 *cpu_addr;
  95. };
  96. struct saa7146_dev
  97. {
  98. struct module *module;
  99. struct v4l2_device v4l2_dev;
  100. struct v4l2_ctrl_handler ctrl_handler;
  101. /* different device locks */
  102. spinlock_t slock;
  103. struct mutex v4l2_lock;
  104. unsigned char __iomem *mem; /* pointer to mapped IO memory */
  105. u32 revision; /* chip revision; needed for bug-workarounds*/
  106. /* pci-device & irq stuff*/
  107. char name[32];
  108. struct pci_dev *pci;
  109. u32 int_todo;
  110. spinlock_t int_slock;
  111. /* extension handling */
  112. struct saa7146_extension *ext; /* indicates if handled by extension */
  113. void *ext_priv; /* pointer for extension private use (most likely some private data) */
  114. struct saa7146_ext_vv *ext_vv_data;
  115. /* per device video/vbi informations (if available) */
  116. struct saa7146_vv *vv_data;
  117. void (*vv_callback)(struct saa7146_dev *dev, unsigned long status);
  118. /* i2c-stuff */
  119. struct mutex i2c_lock;
  120. u32 i2c_bitrate;
  121. struct saa7146_dma d_i2c; /* pointer to i2c memory */
  122. wait_queue_head_t i2c_wq;
  123. int i2c_op;
  124. /* memories */
  125. struct saa7146_dma d_rps0;
  126. struct saa7146_dma d_rps1;
  127. };
  128. static inline struct saa7146_dev *to_saa7146_dev(struct v4l2_device *v4l2_dev)
  129. {
  130. return container_of(v4l2_dev, struct saa7146_dev, v4l2_dev);
  131. }
  132. /* from saa7146_i2c.c */
  133. int saa7146_i2c_adapter_prepare(struct saa7146_dev *dev, struct i2c_adapter *i2c_adapter, u32 bitrate);
  134. /* from saa7146_core.c */
  135. int saa7146_register_extension(struct saa7146_extension*);
  136. int saa7146_unregister_extension(struct saa7146_extension*);
  137. struct saa7146_format* saa7146_format_by_fourcc(struct saa7146_dev *dev, int fourcc);
  138. int saa7146_pgtable_alloc(struct pci_dev *pci, struct saa7146_pgtable *pt);
  139. void saa7146_pgtable_free(struct pci_dev *pci, struct saa7146_pgtable *pt);
  140. int saa7146_pgtable_build_single(struct pci_dev *pci, struct saa7146_pgtable *pt, struct scatterlist *list, int length );
  141. void *saa7146_vmalloc_build_pgtable(struct pci_dev *pci, long length, struct saa7146_pgtable *pt);
  142. void saa7146_vfree_destroy_pgtable(struct pci_dev *pci, void *mem, struct saa7146_pgtable *pt);
  143. void saa7146_setgpio(struct saa7146_dev *dev, int port, u32 data);
  144. int saa7146_wait_for_debi_done(struct saa7146_dev *dev, int nobusyloop);
  145. /* some memory sizes */
  146. #define SAA7146_I2C_MEM ( 1*PAGE_SIZE)
  147. #define SAA7146_RPS_MEM ( 1*PAGE_SIZE)
  148. /* some i2c constants */
  149. #define SAA7146_I2C_TIMEOUT 100 /* i2c-timeout-value in ms */
  150. #define SAA7146_I2C_RETRIES 3 /* how many times shall we retry an i2c-operation? */
  151. #define SAA7146_I2C_DELAY 5 /* time we wait after certain i2c-operations */
  152. /* unsorted defines */
  153. #define ME1 0x0000000800
  154. #define PV1 0x0000000008
  155. /* gpio defines */
  156. #define SAA7146_GPIO_INPUT 0x00
  157. #define SAA7146_GPIO_IRQHI 0x10
  158. #define SAA7146_GPIO_IRQLO 0x20
  159. #define SAA7146_GPIO_IRQHL 0x30
  160. #define SAA7146_GPIO_OUTLO 0x40
  161. #define SAA7146_GPIO_OUTHI 0x50
  162. /* debi defines */
  163. #define DEBINOSWAP 0x000e0000
  164. /* define for the register programming sequencer (rps) */
  165. #define CMD_NOP 0x00000000 /* No operation */
  166. #define CMD_CLR_EVENT 0x00000000 /* Clear event */
  167. #define CMD_SET_EVENT 0x10000000 /* Set signal event */
  168. #define CMD_PAUSE 0x20000000 /* Pause */
  169. #define CMD_CHECK_LATE 0x30000000 /* Check late */
  170. #define CMD_UPLOAD 0x40000000 /* Upload */
  171. #define CMD_STOP 0x50000000 /* Stop */
  172. #define CMD_INTERRUPT 0x60000000 /* Interrupt */
  173. #define CMD_JUMP 0x80000000 /* Jump */
  174. #define CMD_WR_REG 0x90000000 /* Write (load) register */
  175. #define CMD_RD_REG 0xa0000000 /* Read (store) register */
  176. #define CMD_WR_REG_MASK 0xc0000000 /* Write register with mask */
  177. #define CMD_OAN MASK_27
  178. #define CMD_INV MASK_26
  179. #define CMD_SIG4 MASK_25
  180. #define CMD_SIG3 MASK_24
  181. #define CMD_SIG2 MASK_23
  182. #define CMD_SIG1 MASK_22
  183. #define CMD_SIG0 MASK_21
  184. #define CMD_O_FID_B MASK_14
  185. #define CMD_E_FID_B MASK_13
  186. #define CMD_O_FID_A MASK_12
  187. #define CMD_E_FID_A MASK_11
  188. /* some events and command modifiers for rps1 squarewave generator */
  189. #define EVT_HS (1<<15) // Source Line Threshold reached
  190. #define EVT_VBI_B (1<<9) // VSYNC Event
  191. #define RPS_OAN (1<<27) // 1: OR events, 0: AND events
  192. #define RPS_INV (1<<26) // Invert (compound) event
  193. #define GPIO3_MSK 0xFF000000 // GPIO #3 control bits
  194. /* Bit mask constants */
  195. #define MASK_00 0x00000001 /* Mask value for bit 0 */
  196. #define MASK_01 0x00000002 /* Mask value for bit 1 */
  197. #define MASK_02 0x00000004 /* Mask value for bit 2 */
  198. #define MASK_03 0x00000008 /* Mask value for bit 3 */
  199. #define MASK_04 0x00000010 /* Mask value for bit 4 */
  200. #define MASK_05 0x00000020 /* Mask value for bit 5 */
  201. #define MASK_06 0x00000040 /* Mask value for bit 6 */
  202. #define MASK_07 0x00000080 /* Mask value for bit 7 */
  203. #define MASK_08 0x00000100 /* Mask value for bit 8 */
  204. #define MASK_09 0x00000200 /* Mask value for bit 9 */
  205. #define MASK_10 0x00000400 /* Mask value for bit 10 */
  206. #define MASK_11 0x00000800 /* Mask value for bit 11 */
  207. #define MASK_12 0x00001000 /* Mask value for bit 12 */
  208. #define MASK_13 0x00002000 /* Mask value for bit 13 */
  209. #define MASK_14 0x00004000 /* Mask value for bit 14 */
  210. #define MASK_15 0x00008000 /* Mask value for bit 15 */
  211. #define MASK_16 0x00010000 /* Mask value for bit 16 */
  212. #define MASK_17 0x00020000 /* Mask value for bit 17 */
  213. #define MASK_18 0x00040000 /* Mask value for bit 18 */
  214. #define MASK_19 0x00080000 /* Mask value for bit 19 */
  215. #define MASK_20 0x00100000 /* Mask value for bit 20 */
  216. #define MASK_21 0x00200000 /* Mask value for bit 21 */
  217. #define MASK_22 0x00400000 /* Mask value for bit 22 */
  218. #define MASK_23 0x00800000 /* Mask value for bit 23 */
  219. #define MASK_24 0x01000000 /* Mask value for bit 24 */
  220. #define MASK_25 0x02000000 /* Mask value for bit 25 */
  221. #define MASK_26 0x04000000 /* Mask value for bit 26 */
  222. #define MASK_27 0x08000000 /* Mask value for bit 27 */
  223. #define MASK_28 0x10000000 /* Mask value for bit 28 */
  224. #define MASK_29 0x20000000 /* Mask value for bit 29 */
  225. #define MASK_30 0x40000000 /* Mask value for bit 30 */
  226. #define MASK_31 0x80000000 /* Mask value for bit 31 */
  227. #define MASK_B0 0x000000ff /* Mask value for byte 0 */
  228. #define MASK_B1 0x0000ff00 /* Mask value for byte 1 */
  229. #define MASK_B2 0x00ff0000 /* Mask value for byte 2 */
  230. #define MASK_B3 0xff000000 /* Mask value for byte 3 */
  231. #define MASK_W0 0x0000ffff /* Mask value for word 0 */
  232. #define MASK_W1 0xffff0000 /* Mask value for word 1 */
  233. #define MASK_PA 0xfffffffc /* Mask value for physical address */
  234. #define MASK_PR 0xfffffffe /* Mask value for protection register */
  235. #define MASK_ER 0xffffffff /* Mask value for the entire register */
  236. #define MASK_NONE 0x00000000 /* No mask */
  237. /* register aliases */
  238. #define BASE_ODD1 0x00 /* Video DMA 1 registers */
  239. #define BASE_EVEN1 0x04
  240. #define PROT_ADDR1 0x08
  241. #define PITCH1 0x0C
  242. #define BASE_PAGE1 0x10 /* Video DMA 1 base page */
  243. #define NUM_LINE_BYTE1 0x14
  244. #define BASE_ODD2 0x18 /* Video DMA 2 registers */
  245. #define BASE_EVEN2 0x1C
  246. #define PROT_ADDR2 0x20
  247. #define PITCH2 0x24
  248. #define BASE_PAGE2 0x28 /* Video DMA 2 base page */
  249. #define NUM_LINE_BYTE2 0x2C
  250. #define BASE_ODD3 0x30 /* Video DMA 3 registers */
  251. #define BASE_EVEN3 0x34
  252. #define PROT_ADDR3 0x38
  253. #define PITCH3 0x3C
  254. #define BASE_PAGE3 0x40 /* Video DMA 3 base page */
  255. #define NUM_LINE_BYTE3 0x44
  256. #define PCI_BT_V1 0x48 /* Video/FIFO 1 */
  257. #define PCI_BT_V2 0x49 /* Video/FIFO 2 */
  258. #define PCI_BT_V3 0x4A /* Video/FIFO 3 */
  259. #define PCI_BT_DEBI 0x4B /* DEBI */
  260. #define PCI_BT_A 0x4C /* Audio */
  261. #define DD1_INIT 0x50 /* Init setting of DD1 interface */
  262. #define DD1_STREAM_B 0x54 /* DD1 B video data stream handling */
  263. #define DD1_STREAM_A 0x56 /* DD1 A video data stream handling */
  264. #define BRS_CTRL 0x58 /* BRS control register */
  265. #define HPS_CTRL 0x5C /* HPS control register */
  266. #define HPS_V_SCALE 0x60 /* HPS vertical scale */
  267. #define HPS_V_GAIN 0x64 /* HPS vertical ACL and gain */
  268. #define HPS_H_PRESCALE 0x68 /* HPS horizontal prescale */
  269. #define HPS_H_SCALE 0x6C /* HPS horizontal scale */
  270. #define BCS_CTRL 0x70 /* BCS control */
  271. #define CHROMA_KEY_RANGE 0x74
  272. #define CLIP_FORMAT_CTRL 0x78 /* HPS outputs formats & clipping */
  273. #define DEBI_CONFIG 0x7C
  274. #define DEBI_COMMAND 0x80
  275. #define DEBI_PAGE 0x84
  276. #define DEBI_AD 0x88
  277. #define I2C_TRANSFER 0x8C
  278. #define I2C_STATUS 0x90
  279. #define BASE_A1_IN 0x94 /* Audio 1 input DMA */
  280. #define PROT_A1_IN 0x98
  281. #define PAGE_A1_IN 0x9C
  282. #define BASE_A1_OUT 0xA0 /* Audio 1 output DMA */
  283. #define PROT_A1_OUT 0xA4
  284. #define PAGE_A1_OUT 0xA8
  285. #define BASE_A2_IN 0xAC /* Audio 2 input DMA */
  286. #define PROT_A2_IN 0xB0
  287. #define PAGE_A2_IN 0xB4
  288. #define BASE_A2_OUT 0xB8 /* Audio 2 output DMA */
  289. #define PROT_A2_OUT 0xBC
  290. #define PAGE_A2_OUT 0xC0
  291. #define RPS_PAGE0 0xC4 /* RPS task 0 page register */
  292. #define RPS_PAGE1 0xC8 /* RPS task 1 page register */
  293. #define RPS_THRESH0 0xCC /* HBI threshold for task 0 */
  294. #define RPS_THRESH1 0xD0 /* HBI threshold for task 1 */
  295. #define RPS_TOV0 0xD4 /* RPS timeout for task 0 */
  296. #define RPS_TOV1 0xD8 /* RPS timeout for task 1 */
  297. #define IER 0xDC /* Interrupt enable register */
  298. #define GPIO_CTRL 0xE0 /* GPIO 0-3 register */
  299. #define EC1SSR 0xE4 /* Event cnt set 1 source select */
  300. #define EC2SSR 0xE8 /* Event cnt set 2 source select */
  301. #define ECT1R 0xEC /* Event cnt set 1 thresholds */
  302. #define ECT2R 0xF0 /* Event cnt set 2 thresholds */
  303. #define ACON1 0xF4
  304. #define ACON2 0xF8
  305. #define MC1 0xFC /* Main control register 1 */
  306. #define MC2 0x100 /* Main control register 2 */
  307. #define RPS_ADDR0 0x104 /* RPS task 0 address register */
  308. #define RPS_ADDR1 0x108 /* RPS task 1 address register */
  309. #define ISR 0x10C /* Interrupt status register */
  310. #define PSR 0x110 /* Primary status register */
  311. #define SSR 0x114 /* Secondary status register */
  312. #define EC1R 0x118 /* Event counter set 1 register */
  313. #define EC2R 0x11C /* Event counter set 2 register */
  314. #define PCI_VDP1 0x120 /* Video DMA pointer of FIFO 1 */
  315. #define PCI_VDP2 0x124 /* Video DMA pointer of FIFO 2 */
  316. #define PCI_VDP3 0x128 /* Video DMA pointer of FIFO 3 */
  317. #define PCI_ADP1 0x12C /* Audio DMA pointer of audio out 1 */
  318. #define PCI_ADP2 0x130 /* Audio DMA pointer of audio in 1 */
  319. #define PCI_ADP3 0x134 /* Audio DMA pointer of audio out 2 */
  320. #define PCI_ADP4 0x138 /* Audio DMA pointer of audio in 2 */
  321. #define PCI_DMA_DDP 0x13C /* DEBI DMA pointer */
  322. #define LEVEL_REP 0x140,
  323. #define A_TIME_SLOT1 0x180, /* from 180 - 1BC */
  324. #define A_TIME_SLOT2 0x1C0, /* from 1C0 - 1FC */
  325. /* isr masks */
  326. #define SPCI_PPEF 0x80000000 /* PCI parity error */
  327. #define SPCI_PABO 0x40000000 /* PCI access error (target or master abort) */
  328. #define SPCI_PPED 0x20000000 /* PCI parity error on 'real time data' */
  329. #define SPCI_RPS_I1 0x10000000 /* Interrupt issued by RPS1 */
  330. #define SPCI_RPS_I0 0x08000000 /* Interrupt issued by RPS0 */
  331. #define SPCI_RPS_LATE1 0x04000000 /* RPS task 1 is late */
  332. #define SPCI_RPS_LATE0 0x02000000 /* RPS task 0 is late */
  333. #define SPCI_RPS_E1 0x01000000 /* RPS error from task 1 */
  334. #define SPCI_RPS_E0 0x00800000 /* RPS error from task 0 */
  335. #define SPCI_RPS_TO1 0x00400000 /* RPS timeout task 1 */
  336. #define SPCI_RPS_TO0 0x00200000 /* RPS timeout task 0 */
  337. #define SPCI_UPLD 0x00100000 /* RPS in upload */
  338. #define SPCI_DEBI_S 0x00080000 /* DEBI status */
  339. #define SPCI_DEBI_E 0x00040000 /* DEBI error */
  340. #define SPCI_IIC_S 0x00020000 /* I2C status */
  341. #define SPCI_IIC_E 0x00010000 /* I2C error */
  342. #define SPCI_A2_IN 0x00008000 /* Audio 2 input DMA protection / limit */
  343. #define SPCI_A2_OUT 0x00004000 /* Audio 2 output DMA protection / limit */
  344. #define SPCI_A1_IN 0x00002000 /* Audio 1 input DMA protection / limit */
  345. #define SPCI_A1_OUT 0x00001000 /* Audio 1 output DMA protection / limit */
  346. #define SPCI_AFOU 0x00000800 /* Audio FIFO over- / underflow */
  347. #define SPCI_V_PE 0x00000400 /* Video protection address */
  348. #define SPCI_VFOU 0x00000200 /* Video FIFO over- / underflow */
  349. #define SPCI_FIDA 0x00000100 /* Field ID video port A */
  350. #define SPCI_FIDB 0x00000080 /* Field ID video port B */
  351. #define SPCI_PIN3 0x00000040 /* GPIO pin 3 */
  352. #define SPCI_PIN2 0x00000020 /* GPIO pin 2 */
  353. #define SPCI_PIN1 0x00000010 /* GPIO pin 1 */
  354. #define SPCI_PIN0 0x00000008 /* GPIO pin 0 */
  355. #define SPCI_ECS 0x00000004 /* Event counter 1, 2, 4, 5 */
  356. #define SPCI_EC3S 0x00000002 /* Event counter 3 */
  357. #define SPCI_EC0S 0x00000001 /* Event counter 0 */
  358. /* i2c */
  359. #define SAA7146_I2C_ABORT (1<<7)
  360. #define SAA7146_I2C_SPERR (1<<6)
  361. #define SAA7146_I2C_APERR (1<<5)
  362. #define SAA7146_I2C_DTERR (1<<4)
  363. #define SAA7146_I2C_DRERR (1<<3)
  364. #define SAA7146_I2C_AL (1<<2)
  365. #define SAA7146_I2C_ERR (1<<1)
  366. #define SAA7146_I2C_BUSY (1<<0)
  367. #define SAA7146_I2C_START (0x3)
  368. #define SAA7146_I2C_CONT (0x2)
  369. #define SAA7146_I2C_STOP (0x1)
  370. #define SAA7146_I2C_NOP (0x0)
  371. #define SAA7146_I2C_BUS_BIT_RATE_6400 (0x500)
  372. #define SAA7146_I2C_BUS_BIT_RATE_3200 (0x100)
  373. #define SAA7146_I2C_BUS_BIT_RATE_480 (0x400)
  374. #define SAA7146_I2C_BUS_BIT_RATE_320 (0x600)
  375. #define SAA7146_I2C_BUS_BIT_RATE_240 (0x700)
  376. #define SAA7146_I2C_BUS_BIT_RATE_120 (0x000)
  377. #define SAA7146_I2C_BUS_BIT_RATE_80 (0x200)
  378. #define SAA7146_I2C_BUS_BIT_RATE_60 (0x300)
  379. static inline void SAA7146_IER_DISABLE(struct saa7146_dev *x, unsigned y)
  380. {
  381. unsigned long flags;
  382. spin_lock_irqsave(&x->int_slock, flags);
  383. saa7146_write(x, IER, saa7146_read(x, IER) & ~y);
  384. spin_unlock_irqrestore(&x->int_slock, flags);
  385. }
  386. static inline void SAA7146_IER_ENABLE(struct saa7146_dev *x, unsigned y)
  387. {
  388. unsigned long flags;
  389. spin_lock_irqsave(&x->int_slock, flags);
  390. saa7146_write(x, IER, saa7146_read(x, IER) | y);
  391. spin_unlock_irqrestore(&x->int_slock, flags);
  392. }
  393. #endif