cx88.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712
  1. /*
  2. *
  3. * v4l2 device driver for cx2388x based TV cards
  4. *
  5. * (c) 2003,04 Gerd Knorr <kraxel@bytesex.org> [SUSE Labs]
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  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. #include <linux/pci.h>
  22. #include <linux/i2c.h>
  23. #include <linux/i2c-algo-bit.h>
  24. #include <linux/videodev2.h>
  25. #include <linux/kdev_t.h>
  26. #include <media/v4l2-device.h>
  27. #include <media/tuner.h>
  28. #include <media/tveeprom.h>
  29. #include <media/videobuf-dma-sg.h>
  30. #include <media/v4l2-chip-ident.h>
  31. #include <media/cx2341x.h>
  32. #include <media/videobuf-dvb.h>
  33. #include <media/ir-kbd-i2c.h>
  34. #include "btcx-risc.h"
  35. #include "cx88-reg.h"
  36. #include "tuner-xc2028.h"
  37. #include <linux/version.h>
  38. #include <linux/mutex.h>
  39. #define CX88_VERSION_CODE KERNEL_VERSION(0, 0, 8)
  40. #define UNSET (-1U)
  41. #define CX88_MAXBOARDS 8
  42. /* Max number of inputs by card */
  43. #define MAX_CX88_INPUT 8
  44. /* ----------------------------------------------------------- */
  45. /* defines and enums */
  46. /* Currently unsupported by the driver: PAL/H, NTSC/Kr, SECAM/LC */
  47. #define CX88_NORMS (V4L2_STD_ALL \
  48. & ~V4L2_STD_PAL_H \
  49. & ~V4L2_STD_NTSC_M_KR \
  50. & ~V4L2_STD_SECAM_LC)
  51. #define FORMAT_FLAGS_PACKED 0x01
  52. #define FORMAT_FLAGS_PLANAR 0x02
  53. #define VBI_LINE_COUNT 17
  54. #define VBI_LINE_LENGTH 2048
  55. #define AUD_RDS_LINES 4
  56. /* need "shadow" registers for some write-only ones ... */
  57. #define SHADOW_AUD_VOL_CTL 1
  58. #define SHADOW_AUD_BAL_CTL 2
  59. #define SHADOW_MAX 3
  60. /* FM Radio deemphasis type */
  61. enum cx88_deemph_type {
  62. FM_NO_DEEMPH = 0,
  63. FM_DEEMPH_50,
  64. FM_DEEMPH_75
  65. };
  66. enum cx88_board_type {
  67. CX88_BOARD_NONE = 0,
  68. CX88_MPEG_DVB,
  69. CX88_MPEG_BLACKBIRD
  70. };
  71. enum cx8802_board_access {
  72. CX8802_DRVCTL_SHARED = 1,
  73. CX8802_DRVCTL_EXCLUSIVE = 2,
  74. };
  75. /* ----------------------------------------------------------- */
  76. /* tv norms */
  77. static unsigned int inline norm_maxw(v4l2_std_id norm)
  78. {
  79. return (norm & (V4L2_STD_MN & ~V4L2_STD_PAL_Nc)) ? 720 : 768;
  80. }
  81. static unsigned int inline norm_maxh(v4l2_std_id norm)
  82. {
  83. return (norm & V4L2_STD_625_50) ? 576 : 480;
  84. }
  85. /* ----------------------------------------------------------- */
  86. /* static data */
  87. struct cx8800_fmt {
  88. const char *name;
  89. u32 fourcc; /* v4l2 format id */
  90. int depth;
  91. int flags;
  92. u32 cxformat;
  93. };
  94. struct cx88_ctrl {
  95. struct v4l2_queryctrl v;
  96. u32 off;
  97. u32 reg;
  98. u32 sreg;
  99. u32 mask;
  100. u32 shift;
  101. };
  102. /* ----------------------------------------------------------- */
  103. /* SRAM memory management data (see cx88-core.c) */
  104. #define SRAM_CH21 0 /* video */
  105. #define SRAM_CH22 1
  106. #define SRAM_CH23 2
  107. #define SRAM_CH24 3 /* vbi */
  108. #define SRAM_CH25 4 /* audio */
  109. #define SRAM_CH26 5
  110. #define SRAM_CH28 6 /* mpeg */
  111. #define SRAM_CH27 7 /* audio rds */
  112. /* more */
  113. struct sram_channel {
  114. const char *name;
  115. u32 cmds_start;
  116. u32 ctrl_start;
  117. u32 cdt;
  118. u32 fifo_start;
  119. u32 fifo_size;
  120. u32 ptr1_reg;
  121. u32 ptr2_reg;
  122. u32 cnt1_reg;
  123. u32 cnt2_reg;
  124. };
  125. extern const struct sram_channel const cx88_sram_channels[];
  126. /* ----------------------------------------------------------- */
  127. /* card configuration */
  128. #define CX88_BOARD_NOAUTO UNSET
  129. #define CX88_BOARD_UNKNOWN 0
  130. #define CX88_BOARD_HAUPPAUGE 1
  131. #define CX88_BOARD_GDI 2
  132. #define CX88_BOARD_PIXELVIEW 3
  133. #define CX88_BOARD_ATI_WONDER_PRO 4
  134. #define CX88_BOARD_WINFAST2000XP_EXPERT 5
  135. #define CX88_BOARD_AVERTV_STUDIO_303 6
  136. #define CX88_BOARD_MSI_TVANYWHERE_MASTER 7
  137. #define CX88_BOARD_WINFAST_DV2000 8
  138. #define CX88_BOARD_LEADTEK_PVR2000 9
  139. #define CX88_BOARD_IODATA_GVVCP3PCI 10
  140. #define CX88_BOARD_PROLINK_PLAYTVPVR 11
  141. #define CX88_BOARD_ASUS_PVR_416 12
  142. #define CX88_BOARD_MSI_TVANYWHERE 13
  143. #define CX88_BOARD_KWORLD_DVB_T 14
  144. #define CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1 15
  145. #define CX88_BOARD_KWORLD_LTV883 16
  146. #define CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q 17
  147. #define CX88_BOARD_HAUPPAUGE_DVB_T1 18
  148. #define CX88_BOARD_CONEXANT_DVB_T1 19
  149. #define CX88_BOARD_PROVIDEO_PV259 20
  150. #define CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS 21
  151. #define CX88_BOARD_PCHDTV_HD3000 22
  152. #define CX88_BOARD_DNTV_LIVE_DVB_T 23
  153. #define CX88_BOARD_HAUPPAUGE_ROSLYN 24
  154. #define CX88_BOARD_DIGITALLOGIC_MEC 25
  155. #define CX88_BOARD_IODATA_GVBCTV7E 26
  156. #define CX88_BOARD_PIXELVIEW_PLAYTV_ULTRA_PRO 27
  157. #define CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T 28
  158. #define CX88_BOARD_ADSTECH_DVB_T_PCI 29
  159. #define CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1 30
  160. #define CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD 31
  161. #define CX88_BOARD_AVERMEDIA_ULTRATV_MC_550 32
  162. #define CX88_BOARD_KWORLD_VSTREAM_EXPERT_DVD 33
  163. #define CX88_BOARD_ATI_HDTVWONDER 34
  164. #define CX88_BOARD_WINFAST_DTV1000 35
  165. #define CX88_BOARD_AVERTV_303 36
  166. #define CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1 37
  167. #define CX88_BOARD_HAUPPAUGE_NOVASE2_S1 38
  168. #define CX88_BOARD_KWORLD_DVBS_100 39
  169. #define CX88_BOARD_HAUPPAUGE_HVR1100 40
  170. #define CX88_BOARD_HAUPPAUGE_HVR1100LP 41
  171. #define CX88_BOARD_DNTV_LIVE_DVB_T_PRO 42
  172. #define CX88_BOARD_KWORLD_DVB_T_CX22702 43
  173. #define CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL 44
  174. #define CX88_BOARD_KWORLD_HARDWARE_MPEG_TV_XPERT 45
  175. #define CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID 46
  176. #define CX88_BOARD_PCHDTV_HD5500 47
  177. #define CX88_BOARD_KWORLD_MCE200_DELUXE 48
  178. #define CX88_BOARD_PIXELVIEW_PLAYTV_P7000 49
  179. #define CX88_BOARD_NPGTECH_REALTV_TOP10FM 50
  180. #define CX88_BOARD_WINFAST_DTV2000H 51
  181. #define CX88_BOARD_GENIATECH_DVBS 52
  182. #define CX88_BOARD_HAUPPAUGE_HVR3000 53
  183. #define CX88_BOARD_NORWOOD_MICRO 54
  184. #define CX88_BOARD_TE_DTV_250_OEM_SWANN 55
  185. #define CX88_BOARD_HAUPPAUGE_HVR1300 56
  186. #define CX88_BOARD_ADSTECH_PTV_390 57
  187. #define CX88_BOARD_PINNACLE_PCTV_HD_800i 58
  188. #define CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO 59
  189. #define CX88_BOARD_PINNACLE_HYBRID_PCTV 60
  190. #define CX88_BOARD_WINFAST_TV2000_XP_GLOBAL 61
  191. #define CX88_BOARD_POWERCOLOR_REAL_ANGEL 62
  192. #define CX88_BOARD_GENIATECH_X8000_MT 63
  193. #define CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PRO 64
  194. #define CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD 65
  195. #define CX88_BOARD_PROLINK_PV_8000GT 66
  196. #define CX88_BOARD_KWORLD_ATSC_120 67
  197. #define CX88_BOARD_HAUPPAUGE_HVR4000 68
  198. #define CX88_BOARD_HAUPPAUGE_HVR4000LITE 69
  199. #define CX88_BOARD_TEVII_S460 70
  200. #define CX88_BOARD_OMICOM_SS4_PCI 71
  201. #define CX88_BOARD_TBS_8920 72
  202. #define CX88_BOARD_TEVII_S420 73
  203. #define CX88_BOARD_PROLINK_PV_GLOBAL_XTREME 74
  204. #define CX88_BOARD_PROF_7300 75
  205. #define CX88_BOARD_SATTRADE_ST4200 76
  206. #define CX88_BOARD_TBS_8910 77
  207. #define CX88_BOARD_PROF_6200 78
  208. #define CX88_BOARD_TERRATEC_CINERGY_HT_PCI_MKII 79
  209. #define CX88_BOARD_HAUPPAUGE_IRONLY 80
  210. #define CX88_BOARD_WINFAST_DTV1800H 81
  211. #define CX88_BOARD_WINFAST_DTV2000H_J 82
  212. #define CX88_BOARD_PROF_7301 83
  213. #define CX88_BOARD_SAMSUNG_SMT_7020 84
  214. #define CX88_BOARD_TWINHAN_VP1027_DVBS 85
  215. enum cx88_itype {
  216. CX88_VMUX_COMPOSITE1 = 1,
  217. CX88_VMUX_COMPOSITE2,
  218. CX88_VMUX_COMPOSITE3,
  219. CX88_VMUX_COMPOSITE4,
  220. CX88_VMUX_SVIDEO,
  221. CX88_VMUX_TELEVISION,
  222. CX88_VMUX_CABLE,
  223. CX88_VMUX_DVB,
  224. CX88_VMUX_DEBUG,
  225. CX88_RADIO,
  226. };
  227. struct cx88_input {
  228. enum cx88_itype type;
  229. u32 gpio0, gpio1, gpio2, gpio3;
  230. unsigned int vmux:2;
  231. unsigned int audioroute:4;
  232. };
  233. struct cx88_board {
  234. const char *name;
  235. unsigned int tuner_type;
  236. unsigned int radio_type;
  237. unsigned char tuner_addr;
  238. unsigned char radio_addr;
  239. int tda9887_conf;
  240. struct cx88_input input[MAX_CX88_INPUT];
  241. struct cx88_input radio;
  242. enum cx88_board_type mpeg;
  243. unsigned int audio_chip;
  244. int num_frontends;
  245. };
  246. struct cx88_subid {
  247. u16 subvendor;
  248. u16 subdevice;
  249. u32 card;
  250. };
  251. enum cx88_tvaudio {
  252. WW_NONE = 1,
  253. WW_BTSC,
  254. WW_BG,
  255. WW_DK,
  256. WW_I,
  257. WW_L,
  258. WW_EIAJ,
  259. WW_I2SPT,
  260. WW_FM,
  261. WW_I2SADC,
  262. WW_M
  263. };
  264. #define INPUT(nr) (core->board.input[nr])
  265. /* ----------------------------------------------------------- */
  266. /* device / file handle status */
  267. #define RESOURCE_OVERLAY 1
  268. #define RESOURCE_VIDEO 2
  269. #define RESOURCE_VBI 4
  270. #define BUFFER_TIMEOUT msecs_to_jiffies(2000)
  271. /* buffer for one video frame */
  272. struct cx88_buffer {
  273. /* common v4l buffer stuff -- must be first */
  274. struct videobuf_buffer vb;
  275. /* cx88 specific */
  276. unsigned int bpl;
  277. struct btcx_riscmem risc;
  278. const struct cx8800_fmt *fmt;
  279. u32 count;
  280. };
  281. struct cx88_dmaqueue {
  282. struct list_head active;
  283. struct list_head queued;
  284. struct timer_list timeout;
  285. struct btcx_riscmem stopper;
  286. u32 count;
  287. };
  288. struct cx88_core {
  289. struct list_head devlist;
  290. atomic_t refcount;
  291. /* board name */
  292. int nr;
  293. char name[32];
  294. /* pci stuff */
  295. int pci_bus;
  296. int pci_slot;
  297. u32 __iomem *lmmio;
  298. u8 __iomem *bmmio;
  299. u32 shadow[SHADOW_MAX];
  300. int pci_irqmask;
  301. /* i2c i/o */
  302. struct i2c_adapter i2c_adap;
  303. struct i2c_algo_bit_data i2c_algo;
  304. struct i2c_client i2c_client;
  305. u32 i2c_state, i2c_rc;
  306. /* config info -- analog */
  307. struct v4l2_device v4l2_dev;
  308. struct i2c_client *i2c_rtc;
  309. unsigned int boardnr;
  310. struct cx88_board board;
  311. /* Supported V4L _STD_ tuner formats */
  312. unsigned int tuner_formats;
  313. /* config info -- dvb */
  314. #if defined(CONFIG_VIDEO_CX88_DVB) || defined(CONFIG_VIDEO_CX88_DVB_MODULE)
  315. int (*prev_set_voltage)(struct dvb_frontend *fe, fe_sec_voltage_t voltage);
  316. #endif
  317. void (*gate_ctrl)(struct cx88_core *core, int open);
  318. /* state info */
  319. struct task_struct *kthread;
  320. v4l2_std_id tvnorm;
  321. enum cx88_tvaudio tvaudio;
  322. u32 audiomode_manual;
  323. u32 audiomode_current;
  324. u32 input;
  325. u32 astat;
  326. u32 use_nicam;
  327. unsigned long last_change;
  328. /* IR remote control state */
  329. struct cx88_IR *ir;
  330. /* I2C remote data */
  331. struct IR_i2c_init_data init_data;
  332. struct mutex lock;
  333. /* various v4l controls */
  334. u32 freq;
  335. atomic_t users;
  336. atomic_t mpeg_users;
  337. /* cx88-video needs to access cx8802 for hybrid tuner pll access. */
  338. struct cx8802_dev *dvbdev;
  339. enum cx88_board_type active_type_id;
  340. int active_ref;
  341. int active_fe_id;
  342. };
  343. static inline struct cx88_core *to_core(struct v4l2_device *v4l2_dev)
  344. {
  345. return container_of(v4l2_dev, struct cx88_core, v4l2_dev);
  346. }
  347. #define call_all(core, o, f, args...) \
  348. do { \
  349. if (!core->i2c_rc) { \
  350. if (core->gate_ctrl) \
  351. core->gate_ctrl(core, 1); \
  352. v4l2_device_call_all(&core->v4l2_dev, 0, o, f, ##args); \
  353. if (core->gate_ctrl) \
  354. core->gate_ctrl(core, 0); \
  355. } \
  356. } while (0)
  357. struct cx8800_dev;
  358. struct cx8802_dev;
  359. /* ----------------------------------------------------------- */
  360. /* function 0: video stuff */
  361. struct cx8800_fh {
  362. struct cx8800_dev *dev;
  363. enum v4l2_buf_type type;
  364. int radio;
  365. unsigned int resources;
  366. /* video overlay */
  367. struct v4l2_window win;
  368. struct v4l2_clip *clips;
  369. unsigned int nclips;
  370. /* video capture */
  371. const struct cx8800_fmt *fmt;
  372. unsigned int width,height;
  373. struct videobuf_queue vidq;
  374. /* vbi capture */
  375. struct videobuf_queue vbiq;
  376. };
  377. struct cx8800_suspend_state {
  378. int disabled;
  379. };
  380. struct cx8800_dev {
  381. struct cx88_core *core;
  382. spinlock_t slock;
  383. /* various device info */
  384. unsigned int resources;
  385. struct video_device *video_dev;
  386. struct video_device *vbi_dev;
  387. struct video_device *radio_dev;
  388. /* pci i/o */
  389. struct pci_dev *pci;
  390. unsigned char pci_rev,pci_lat;
  391. /* capture queues */
  392. struct cx88_dmaqueue vidq;
  393. struct cx88_dmaqueue vbiq;
  394. /* various v4l controls */
  395. /* other global state info */
  396. struct cx8800_suspend_state state;
  397. };
  398. /* ----------------------------------------------------------- */
  399. /* function 1: audio/alsa stuff */
  400. /* =============> moved to cx88-alsa.c <====================== */
  401. /* ----------------------------------------------------------- */
  402. /* function 2: mpeg stuff */
  403. struct cx8802_fh {
  404. struct cx8802_dev *dev;
  405. struct videobuf_queue mpegq;
  406. };
  407. struct cx8802_suspend_state {
  408. int disabled;
  409. };
  410. struct cx8802_driver {
  411. struct cx88_core *core;
  412. /* List of drivers attached to device */
  413. struct list_head drvlist;
  414. /* Type of driver and access required */
  415. enum cx88_board_type type_id;
  416. enum cx8802_board_access hw_access;
  417. /* MPEG 8802 internal only */
  418. int (*suspend)(struct pci_dev *pci_dev, pm_message_t state);
  419. int (*resume)(struct pci_dev *pci_dev);
  420. /* MPEG 8802 -> mini driver - Driver probe and configuration */
  421. int (*probe)(struct cx8802_driver *drv);
  422. int (*remove)(struct cx8802_driver *drv);
  423. /* MPEG 8802 -> mini driver - Access for hardware control */
  424. int (*advise_acquire)(struct cx8802_driver *drv);
  425. int (*advise_release)(struct cx8802_driver *drv);
  426. /* MPEG 8802 <- mini driver - Access for hardware control */
  427. int (*request_acquire)(struct cx8802_driver *drv);
  428. int (*request_release)(struct cx8802_driver *drv);
  429. };
  430. struct cx8802_dev {
  431. struct cx88_core *core;
  432. spinlock_t slock;
  433. /* pci i/o */
  434. struct pci_dev *pci;
  435. unsigned char pci_rev,pci_lat;
  436. /* dma queues */
  437. struct cx88_dmaqueue mpegq;
  438. u32 ts_packet_size;
  439. u32 ts_packet_count;
  440. /* other global state info */
  441. struct cx8802_suspend_state state;
  442. /* for blackbird only */
  443. struct list_head devlist;
  444. #if defined(CONFIG_VIDEO_CX88_BLACKBIRD) || \
  445. defined(CONFIG_VIDEO_CX88_BLACKBIRD_MODULE)
  446. struct video_device *mpeg_dev;
  447. u32 mailbox;
  448. int width;
  449. int height;
  450. unsigned char mpeg_active; /* nonzero if mpeg encoder is active */
  451. /* mpeg params */
  452. struct cx2341x_mpeg_params params;
  453. #endif
  454. #if defined(CONFIG_VIDEO_CX88_DVB) || defined(CONFIG_VIDEO_CX88_DVB_MODULE)
  455. /* for dvb only */
  456. struct videobuf_dvb_frontends frontends;
  457. #endif
  458. #if defined(CONFIG_VIDEO_CX88_VP3054) || \
  459. defined(CONFIG_VIDEO_CX88_VP3054_MODULE)
  460. /* For VP3045 secondary I2C bus support */
  461. struct vp3054_i2c_state *vp3054;
  462. #endif
  463. /* for switching modulation types */
  464. unsigned char ts_gen_cntrl;
  465. /* List of attached drivers */
  466. struct list_head drvlist;
  467. struct work_struct request_module_wk;
  468. };
  469. /* ----------------------------------------------------------- */
  470. #define cx_read(reg) readl(core->lmmio + ((reg)>>2))
  471. #define cx_write(reg,value) writel((value), core->lmmio + ((reg)>>2))
  472. #define cx_writeb(reg,value) writeb((value), core->bmmio + (reg))
  473. #define cx_andor(reg,mask,value) \
  474. writel((readl(core->lmmio+((reg)>>2)) & ~(mask)) |\
  475. ((value) & (mask)), core->lmmio+((reg)>>2))
  476. #define cx_set(reg,bit) cx_andor((reg),(bit),(bit))
  477. #define cx_clear(reg,bit) cx_andor((reg),(bit),0)
  478. #define cx_wait(d) { if (need_resched()) schedule(); else udelay(d); }
  479. /* shadow registers */
  480. #define cx_sread(sreg) (core->shadow[sreg])
  481. #define cx_swrite(sreg,reg,value) \
  482. (core->shadow[sreg] = value, \
  483. writel(core->shadow[sreg], core->lmmio + ((reg)>>2)))
  484. #define cx_sandor(sreg,reg,mask,value) \
  485. (core->shadow[sreg] = (core->shadow[sreg] & ~(mask)) | ((value) & (mask)), \
  486. writel(core->shadow[sreg], core->lmmio + ((reg)>>2)))
  487. /* ----------------------------------------------------------- */
  488. /* cx88-core.c */
  489. extern void cx88_print_irqbits(const char *name, const char *tag, const char *strings[],
  490. int len, u32 bits, u32 mask);
  491. extern int cx88_core_irq(struct cx88_core *core, u32 status);
  492. extern void cx88_wakeup(struct cx88_core *core,
  493. struct cx88_dmaqueue *q, u32 count);
  494. extern void cx88_shutdown(struct cx88_core *core);
  495. extern int cx88_reset(struct cx88_core *core);
  496. extern int
  497. cx88_risc_buffer(struct pci_dev *pci, struct btcx_riscmem *risc,
  498. struct scatterlist *sglist,
  499. unsigned int top_offset, unsigned int bottom_offset,
  500. unsigned int bpl, unsigned int padding, unsigned int lines);
  501. extern int
  502. cx88_risc_databuffer(struct pci_dev *pci, struct btcx_riscmem *risc,
  503. struct scatterlist *sglist, unsigned int bpl,
  504. unsigned int lines, unsigned int lpi);
  505. extern int
  506. cx88_risc_stopper(struct pci_dev *pci, struct btcx_riscmem *risc,
  507. u32 reg, u32 mask, u32 value);
  508. extern void
  509. cx88_free_buffer(struct videobuf_queue *q, struct cx88_buffer *buf);
  510. extern void cx88_risc_disasm(struct cx88_core *core,
  511. struct btcx_riscmem *risc);
  512. extern int cx88_sram_channel_setup(struct cx88_core *core,
  513. const struct sram_channel *ch,
  514. unsigned int bpl, u32 risc);
  515. extern void cx88_sram_channel_dump(struct cx88_core *core,
  516. const struct sram_channel *ch);
  517. extern int cx88_set_scale(struct cx88_core *core, unsigned int width,
  518. unsigned int height, enum v4l2_field field);
  519. extern int cx88_set_tvnorm(struct cx88_core *core, v4l2_std_id norm);
  520. extern struct video_device *cx88_vdev_init(struct cx88_core *core,
  521. struct pci_dev *pci,
  522. const struct video_device *template_,
  523. const char *type);
  524. extern struct cx88_core* cx88_core_get(struct pci_dev *pci);
  525. extern void cx88_core_put(struct cx88_core *core,
  526. struct pci_dev *pci);
  527. extern int cx88_start_audio_dma(struct cx88_core *core);
  528. extern int cx88_stop_audio_dma(struct cx88_core *core);
  529. /* ----------------------------------------------------------- */
  530. /* cx88-vbi.c */
  531. /* Can be used as g_vbi_fmt, try_vbi_fmt and s_vbi_fmt */
  532. int cx8800_vbi_fmt (struct file *file, void *priv,
  533. struct v4l2_format *f);
  534. /*
  535. int cx8800_start_vbi_dma(struct cx8800_dev *dev,
  536. struct cx88_dmaqueue *q,
  537. struct cx88_buffer *buf);
  538. */
  539. int cx8800_stop_vbi_dma(struct cx8800_dev *dev);
  540. int cx8800_restart_vbi_queue(struct cx8800_dev *dev,
  541. struct cx88_dmaqueue *q);
  542. void cx8800_vbi_timeout(unsigned long data);
  543. extern const struct videobuf_queue_ops cx8800_vbi_qops;
  544. /* ----------------------------------------------------------- */
  545. /* cx88-i2c.c */
  546. extern int cx88_i2c_init(struct cx88_core *core, struct pci_dev *pci);
  547. /* ----------------------------------------------------------- */
  548. /* cx88-cards.c */
  549. extern int cx88_tuner_callback(void *dev, int component, int command, int arg);
  550. extern int cx88_get_resources(const struct cx88_core *core,
  551. struct pci_dev *pci);
  552. extern struct cx88_core *cx88_core_create(struct pci_dev *pci, int nr);
  553. extern void cx88_setup_xc3028(struct cx88_core *core, struct xc2028_ctrl *ctl);
  554. /* ----------------------------------------------------------- */
  555. /* cx88-tvaudio.c */
  556. void cx88_set_tvaudio(struct cx88_core *core);
  557. void cx88_newstation(struct cx88_core *core);
  558. void cx88_get_stereo(struct cx88_core *core, struct v4l2_tuner *t);
  559. void cx88_set_stereo(struct cx88_core *core, u32 mode, int manual);
  560. int cx88_audio_thread(void *data);
  561. int cx8802_register_driver(struct cx8802_driver *drv);
  562. int cx8802_unregister_driver(struct cx8802_driver *drv);
  563. struct cx8802_driver * cx8802_get_driver(struct cx8802_dev *dev, enum cx88_board_type btype);
  564. /* ----------------------------------------------------------- */
  565. /* cx88-dsp.c */
  566. s32 cx88_dsp_detect_stereo_sap(struct cx88_core *core);
  567. /* ----------------------------------------------------------- */
  568. /* cx88-input.c */
  569. int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci);
  570. int cx88_ir_fini(struct cx88_core *core);
  571. void cx88_ir_irq(struct cx88_core *core);
  572. int cx88_ir_start(struct cx88_core *core);
  573. void cx88_ir_stop(struct cx88_core *core);
  574. extern void cx88_i2c_init_ir(struct cx88_core *core);
  575. /* ----------------------------------------------------------- */
  576. /* cx88-mpeg.c */
  577. int cx8802_buf_prepare(struct videobuf_queue *q,struct cx8802_dev *dev,
  578. struct cx88_buffer *buf, enum v4l2_field field);
  579. void cx8802_buf_queue(struct cx8802_dev *dev, struct cx88_buffer *buf);
  580. void cx8802_cancel_buffers(struct cx8802_dev *dev);
  581. /* ----------------------------------------------------------- */
  582. /* cx88-video.c*/
  583. extern const u32 cx88_user_ctrls[];
  584. extern int cx8800_ctrl_query(struct cx88_core *core,
  585. struct v4l2_queryctrl *qctrl);
  586. int cx88_enum_input (struct cx88_core *core,struct v4l2_input *i);
  587. int cx88_set_freq (struct cx88_core *core,struct v4l2_frequency *f);
  588. int cx88_get_control(struct cx88_core *core, struct v4l2_control *ctl);
  589. int cx88_set_control(struct cx88_core *core, struct v4l2_control *ctl);
  590. int cx88_video_mux(struct cx88_core *core, unsigned int input);