162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci *
462306a36Sopenharmony_ci *  bttv - Bt848 frame grabber driver
562306a36Sopenharmony_ci *
662306a36Sopenharmony_ci *  card ID's and external interfaces of the bttv driver
762306a36Sopenharmony_ci *  basically stuff needed by other drivers (i2c, lirc, ...)
862306a36Sopenharmony_ci *  and is supported not to change much over time.
962306a36Sopenharmony_ci *
1062306a36Sopenharmony_ci *  Copyright (C) 1996,97 Ralph Metzler (rjkm@thp.uni-koeln.de)
1162306a36Sopenharmony_ci *  (c) 1999,2000 Gerd Knorr <kraxel@goldbach.in-berlin.de>
1262306a36Sopenharmony_ci *
1362306a36Sopenharmony_ci */
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci#ifndef _BTTV_H_
1662306a36Sopenharmony_ci#define _BTTV_H_
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ci#include <linux/videodev2.h>
1962306a36Sopenharmony_ci#include <linux/i2c.h>
2062306a36Sopenharmony_ci#include <media/v4l2-device.h>
2162306a36Sopenharmony_ci#include <media/tuner.h>
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_ci/* ---------------------------------------------------------- */
2462306a36Sopenharmony_ci/* exported by bttv-cards.c                                   */
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_ci#define BTTV_BOARD_UNKNOWN                 0x00
2762306a36Sopenharmony_ci#define BTTV_BOARD_MIRO                    0x01
2862306a36Sopenharmony_ci#define BTTV_BOARD_HAUPPAUGE               0x02
2962306a36Sopenharmony_ci#define BTTV_BOARD_STB                     0x03
3062306a36Sopenharmony_ci#define BTTV_BOARD_INTEL                   0x04
3162306a36Sopenharmony_ci#define BTTV_BOARD_DIAMOND                 0x05
3262306a36Sopenharmony_ci#define BTTV_BOARD_AVERMEDIA               0x06
3362306a36Sopenharmony_ci#define BTTV_BOARD_MATRIX_VISION           0x07
3462306a36Sopenharmony_ci#define BTTV_BOARD_FLYVIDEO                0x08
3562306a36Sopenharmony_ci#define BTTV_BOARD_TURBOTV                 0x09
3662306a36Sopenharmony_ci#define BTTV_BOARD_HAUPPAUGE878            0x0a
3762306a36Sopenharmony_ci#define BTTV_BOARD_MIROPRO                 0x0b
3862306a36Sopenharmony_ci#define BTTV_BOARD_ADSTECH_TV              0x0c
3962306a36Sopenharmony_ci#define BTTV_BOARD_AVERMEDIA98             0x0d
4062306a36Sopenharmony_ci#define BTTV_BOARD_VHX                     0x0e
4162306a36Sopenharmony_ci#define BTTV_BOARD_ZOLTRIX                 0x0f
4262306a36Sopenharmony_ci#define BTTV_BOARD_PIXVIEWPLAYTV           0x10
4362306a36Sopenharmony_ci#define BTTV_BOARD_WINVIEW_601             0x11
4462306a36Sopenharmony_ci#define BTTV_BOARD_AVEC_INTERCAP           0x12
4562306a36Sopenharmony_ci#define BTTV_BOARD_LIFE_FLYKIT             0x13
4662306a36Sopenharmony_ci#define BTTV_BOARD_CEI_RAFFLES             0x14
4762306a36Sopenharmony_ci#define BTTV_BOARD_CONFERENCETV            0x15
4862306a36Sopenharmony_ci#define BTTV_BOARD_PHOEBE_TVMAS            0x16
4962306a36Sopenharmony_ci#define BTTV_BOARD_MODTEC_205              0x17
5062306a36Sopenharmony_ci#define BTTV_BOARD_MAGICTVIEW061           0x18
5162306a36Sopenharmony_ci#define BTTV_BOARD_VOBIS_BOOSTAR           0x19
5262306a36Sopenharmony_ci#define BTTV_BOARD_HAUPPAUG_WCAM           0x1a
5362306a36Sopenharmony_ci#define BTTV_BOARD_MAXI                    0x1b
5462306a36Sopenharmony_ci#define BTTV_BOARD_TERRATV                 0x1c
5562306a36Sopenharmony_ci#define BTTV_BOARD_PXC200                  0x1d
5662306a36Sopenharmony_ci#define BTTV_BOARD_FLYVIDEO_98             0x1e
5762306a36Sopenharmony_ci#define BTTV_BOARD_IPROTV                  0x1f
5862306a36Sopenharmony_ci#define BTTV_BOARD_INTEL_C_S_PCI           0x20
5962306a36Sopenharmony_ci#define BTTV_BOARD_TERRATVALUE             0x21
6062306a36Sopenharmony_ci#define BTTV_BOARD_WINFAST2000             0x22
6162306a36Sopenharmony_ci#define BTTV_BOARD_CHRONOS_VS2             0x23
6262306a36Sopenharmony_ci#define BTTV_BOARD_TYPHOON_TVIEW           0x24
6362306a36Sopenharmony_ci#define BTTV_BOARD_PXELVWPLTVPRO           0x25
6462306a36Sopenharmony_ci#define BTTV_BOARD_MAGICTVIEW063           0x26
6562306a36Sopenharmony_ci#define BTTV_BOARD_PINNACLE                0x27
6662306a36Sopenharmony_ci#define BTTV_BOARD_STB2                    0x28
6762306a36Sopenharmony_ci#define BTTV_BOARD_AVPHONE98               0x29
6862306a36Sopenharmony_ci#define BTTV_BOARD_PV951                   0x2a
6962306a36Sopenharmony_ci#define BTTV_BOARD_ONAIR_TV                0x2b
7062306a36Sopenharmony_ci#define BTTV_BOARD_SIGMA_TVII_FM           0x2c
7162306a36Sopenharmony_ci#define BTTV_BOARD_MATRIX_VISION2          0x2d
7262306a36Sopenharmony_ci#define BTTV_BOARD_ZOLTRIX_GENIE           0x2e
7362306a36Sopenharmony_ci#define BTTV_BOARD_TERRATVRADIO            0x2f
7462306a36Sopenharmony_ci#define BTTV_BOARD_DYNALINK                0x30
7562306a36Sopenharmony_ci#define BTTV_BOARD_GVBCTV3PCI              0x31
7662306a36Sopenharmony_ci#define BTTV_BOARD_PXELVWPLTVPAK           0x32
7762306a36Sopenharmony_ci#define BTTV_BOARD_EAGLE                   0x33
7862306a36Sopenharmony_ci#define BTTV_BOARD_PINNACLEPRO             0x34
7962306a36Sopenharmony_ci#define BTTV_BOARD_TVIEW_RDS_FM            0x35
8062306a36Sopenharmony_ci#define BTTV_BOARD_LIFETEC_9415            0x36
8162306a36Sopenharmony_ci#define BTTV_BOARD_BESTBUY_EASYTV          0x37
8262306a36Sopenharmony_ci#define BTTV_BOARD_FLYVIDEO_98FM           0x38
8362306a36Sopenharmony_ci#define BTTV_BOARD_GRANDTEC                0x39
8462306a36Sopenharmony_ci#define BTTV_BOARD_ASKEY_CPH060            0x3a
8562306a36Sopenharmony_ci#define BTTV_BOARD_ASKEY_CPH03X            0x3b
8662306a36Sopenharmony_ci#define BTTV_BOARD_MM100PCTV               0x3c
8762306a36Sopenharmony_ci#define BTTV_BOARD_GMV1                    0x3d
8862306a36Sopenharmony_ci#define BTTV_BOARD_BESTBUY_EASYTV2         0x3e
8962306a36Sopenharmony_ci#define BTTV_BOARD_ATI_TVWONDER            0x3f
9062306a36Sopenharmony_ci#define BTTV_BOARD_ATI_TVWONDERVE          0x40
9162306a36Sopenharmony_ci#define BTTV_BOARD_FLYVIDEO2000            0x41
9262306a36Sopenharmony_ci#define BTTV_BOARD_TERRATVALUER            0x42
9362306a36Sopenharmony_ci#define BTTV_BOARD_GVBCTV4PCI              0x43
9462306a36Sopenharmony_ci#define BTTV_BOARD_VOODOOTV_FM             0x44
9562306a36Sopenharmony_ci#define BTTV_BOARD_AIMMS                   0x45
9662306a36Sopenharmony_ci#define BTTV_BOARD_PV_BT878P_PLUS          0x46
9762306a36Sopenharmony_ci#define BTTV_BOARD_FLYVIDEO98EZ            0x47
9862306a36Sopenharmony_ci#define BTTV_BOARD_PV_BT878P_9B            0x48
9962306a36Sopenharmony_ci#define BTTV_BOARD_SENSORAY311_611         0x49
10062306a36Sopenharmony_ci#define BTTV_BOARD_RV605                   0x4a
10162306a36Sopenharmony_ci#define BTTV_BOARD_POWERCLR_MTV878         0x4b
10262306a36Sopenharmony_ci#define BTTV_BOARD_WINDVR                  0x4c
10362306a36Sopenharmony_ci#define BTTV_BOARD_GRANDTEC_MULTI          0x4d
10462306a36Sopenharmony_ci#define BTTV_BOARD_KWORLD                  0x4e
10562306a36Sopenharmony_ci#define BTTV_BOARD_DSP_TCVIDEO             0x4f
10662306a36Sopenharmony_ci#define BTTV_BOARD_HAUPPAUGEPVR            0x50
10762306a36Sopenharmony_ci#define BTTV_BOARD_GVBCTV5PCI              0x51
10862306a36Sopenharmony_ci#define BTTV_BOARD_OSPREY1x0               0x52
10962306a36Sopenharmony_ci#define BTTV_BOARD_OSPREY1x0_848           0x53
11062306a36Sopenharmony_ci#define BTTV_BOARD_OSPREY101_848           0x54
11162306a36Sopenharmony_ci#define BTTV_BOARD_OSPREY1x1               0x55
11262306a36Sopenharmony_ci#define BTTV_BOARD_OSPREY1x1_SVID          0x56
11362306a36Sopenharmony_ci#define BTTV_BOARD_OSPREY2xx               0x57
11462306a36Sopenharmony_ci#define BTTV_BOARD_OSPREY2x0_SVID          0x58
11562306a36Sopenharmony_ci#define BTTV_BOARD_OSPREY2x0               0x59
11662306a36Sopenharmony_ci#define BTTV_BOARD_OSPREY500               0x5a
11762306a36Sopenharmony_ci#define BTTV_BOARD_OSPREY540               0x5b
11862306a36Sopenharmony_ci#define BTTV_BOARD_OSPREY2000              0x5c
11962306a36Sopenharmony_ci#define BTTV_BOARD_IDS_EAGLE               0x5d
12062306a36Sopenharmony_ci#define BTTV_BOARD_PINNACLESAT             0x5e
12162306a36Sopenharmony_ci#define BTTV_BOARD_FORMAC_PROTV            0x5f
12262306a36Sopenharmony_ci#define BTTV_BOARD_MACHTV                  0x60
12362306a36Sopenharmony_ci#define BTTV_BOARD_EURESYS_PICOLO          0x61
12462306a36Sopenharmony_ci#define BTTV_BOARD_PV150                   0x62
12562306a36Sopenharmony_ci#define BTTV_BOARD_AD_TVK503               0x63
12662306a36Sopenharmony_ci#define BTTV_BOARD_HERCULES_SM_TV          0x64
12762306a36Sopenharmony_ci#define BTTV_BOARD_PACETV                  0x65
12862306a36Sopenharmony_ci#define BTTV_BOARD_IVC200                  0x66
12962306a36Sopenharmony_ci#define BTTV_BOARD_XGUARD                  0x67
13062306a36Sopenharmony_ci#define BTTV_BOARD_NEBULA_DIGITV           0x68
13162306a36Sopenharmony_ci#define BTTV_BOARD_PV143                   0x69
13262306a36Sopenharmony_ci#define BTTV_BOARD_VD009X1_VD011_MINIDIN   0x6a
13362306a36Sopenharmony_ci#define BTTV_BOARD_VD009X1_VD011_COMBI     0x6b
13462306a36Sopenharmony_ci#define BTTV_BOARD_VD009_MINIDIN           0x6c
13562306a36Sopenharmony_ci#define BTTV_BOARD_VD009_COMBI             0x6d
13662306a36Sopenharmony_ci#define BTTV_BOARD_IVC100                  0x6e
13762306a36Sopenharmony_ci#define BTTV_BOARD_IVC120                  0x6f
13862306a36Sopenharmony_ci#define BTTV_BOARD_PC_HDTV                 0x70
13962306a36Sopenharmony_ci#define BTTV_BOARD_TWINHAN_DST             0x71
14062306a36Sopenharmony_ci#define BTTV_BOARD_WINFASTVC100            0x72
14162306a36Sopenharmony_ci#define BTTV_BOARD_TEV560                  0x73
14262306a36Sopenharmony_ci#define BTTV_BOARD_SIMUS_GVC1100           0x74
14362306a36Sopenharmony_ci#define BTTV_BOARD_NGSTV_PLUS              0x75
14462306a36Sopenharmony_ci#define BTTV_BOARD_LMLBT4                  0x76
14562306a36Sopenharmony_ci#define BTTV_BOARD_TEKRAM_M205             0x77
14662306a36Sopenharmony_ci#define BTTV_BOARD_CONTVFMI                0x78
14762306a36Sopenharmony_ci#define BTTV_BOARD_PICOLO_TETRA_CHIP       0x79
14862306a36Sopenharmony_ci#define BTTV_BOARD_SPIRIT_TV               0x7a
14962306a36Sopenharmony_ci#define BTTV_BOARD_AVDVBT_771              0x7b
15062306a36Sopenharmony_ci#define BTTV_BOARD_AVDVBT_761              0x7c
15162306a36Sopenharmony_ci#define BTTV_BOARD_MATRIX_VISIONSQ         0x7d
15262306a36Sopenharmony_ci#define BTTV_BOARD_MATRIX_VISIONSLC        0x7e
15362306a36Sopenharmony_ci#define BTTV_BOARD_APAC_VIEWCOMP           0x7f
15462306a36Sopenharmony_ci#define BTTV_BOARD_DVICO_DVBT_LITE         0x80
15562306a36Sopenharmony_ci#define BTTV_BOARD_VGEAR_MYVCD             0x81
15662306a36Sopenharmony_ci#define BTTV_BOARD_SUPER_TV                0x82
15762306a36Sopenharmony_ci#define BTTV_BOARD_TIBET_CS16              0x83
15862306a36Sopenharmony_ci#define BTTV_BOARD_KODICOM_4400R           0x84
15962306a36Sopenharmony_ci#define BTTV_BOARD_KODICOM_4400R_SL        0x85
16062306a36Sopenharmony_ci#define BTTV_BOARD_ADLINK_RTV24            0x86
16162306a36Sopenharmony_ci#define BTTV_BOARD_DVICO_FUSIONHDTV_5_LITE 0x87
16262306a36Sopenharmony_ci#define BTTV_BOARD_ACORP_Y878F             0x88
16362306a36Sopenharmony_ci#define BTTV_BOARD_CONCEPTRONIC_CTVFMI2    0x89
16462306a36Sopenharmony_ci#define BTTV_BOARD_PV_BT878P_2E            0x8a
16562306a36Sopenharmony_ci#define BTTV_BOARD_PV_M4900                0x8b
16662306a36Sopenharmony_ci#define BTTV_BOARD_OSPREY440               0x8c
16762306a36Sopenharmony_ci#define BTTV_BOARD_ASOUND_SKYEYE	   0x8d
16862306a36Sopenharmony_ci#define BTTV_BOARD_SABRENT_TVFM		   0x8e
16962306a36Sopenharmony_ci#define BTTV_BOARD_HAUPPAUGE_IMPACTVCB     0x8f
17062306a36Sopenharmony_ci#define BTTV_BOARD_MACHTV_MAGICTV          0x90
17162306a36Sopenharmony_ci#define BTTV_BOARD_SSAI_SECURITY	   0x91
17262306a36Sopenharmony_ci#define BTTV_BOARD_SSAI_ULTRASOUND	   0x92
17362306a36Sopenharmony_ci#define BTTV_BOARD_VOODOOTV_200		   0x93
17462306a36Sopenharmony_ci#define BTTV_BOARD_DVICO_FUSIONHDTV_2	   0x94
17562306a36Sopenharmony_ci#define BTTV_BOARD_TYPHOON_TVTUNERPCI	   0x95
17662306a36Sopenharmony_ci#define BTTV_BOARD_GEOVISION_GV600	   0x96
17762306a36Sopenharmony_ci#define BTTV_BOARD_KOZUMI_KTV_01C          0x97
17862306a36Sopenharmony_ci#define BTTV_BOARD_ENLTV_FM_2		   0x98
17962306a36Sopenharmony_ci#define BTTV_BOARD_VD012		   0x99
18062306a36Sopenharmony_ci#define BTTV_BOARD_VD012_X1		   0x9a
18162306a36Sopenharmony_ci#define BTTV_BOARD_VD012_X2		   0x9b
18262306a36Sopenharmony_ci#define BTTV_BOARD_IVCE8784		   0x9c
18362306a36Sopenharmony_ci#define BTTV_BOARD_GEOVISION_GV800S	   0x9d
18462306a36Sopenharmony_ci#define BTTV_BOARD_GEOVISION_GV800S_SL	   0x9e
18562306a36Sopenharmony_ci#define BTTV_BOARD_PV183                   0x9f
18662306a36Sopenharmony_ci#define BTTV_BOARD_TVT_TD3116		   0xa0
18762306a36Sopenharmony_ci#define BTTV_BOARD_APOSONIC_WDVR           0xa1
18862306a36Sopenharmony_ci#define BTTV_BOARD_ADLINK_MPG24            0xa2
18962306a36Sopenharmony_ci#define BTTV_BOARD_BT848_CAP_14            0xa3
19062306a36Sopenharmony_ci#define BTTV_BOARD_CYBERVISION_CV06        0xa4
19162306a36Sopenharmony_ci#define BTTV_BOARD_KWORLD_VSTREAM_XPERT    0xa5
19262306a36Sopenharmony_ci#define BTTV_BOARD_PCI_8604PW              0xa6
19362306a36Sopenharmony_ci
19462306a36Sopenharmony_ci/* more card-specific defines */
19562306a36Sopenharmony_ci#define PT2254_L_CHANNEL 0x10
19662306a36Sopenharmony_ci#define PT2254_R_CHANNEL 0x08
19762306a36Sopenharmony_ci#define PT2254_DBS_IN_2 0x400
19862306a36Sopenharmony_ci#define PT2254_DBS_IN_10 0x20000
19962306a36Sopenharmony_ci#define WINVIEW_PT2254_CLK  0x40
20062306a36Sopenharmony_ci#define WINVIEW_PT2254_DATA 0x20
20162306a36Sopenharmony_ci#define WINVIEW_PT2254_STROBE 0x80
20262306a36Sopenharmony_ci
20362306a36Sopenharmony_cistruct bttv_core {
20462306a36Sopenharmony_ci	/* device structs */
20562306a36Sopenharmony_ci	struct v4l2_device   v4l2_dev;
20662306a36Sopenharmony_ci	struct pci_dev       *pci;
20762306a36Sopenharmony_ci	struct i2c_adapter   i2c_adap;
20862306a36Sopenharmony_ci	struct list_head     subs;     /* struct bttv_sub_device */
20962306a36Sopenharmony_ci
21062306a36Sopenharmony_ci	/* device config */
21162306a36Sopenharmony_ci	unsigned int         nr;       /* dev nr (for printk("bttv%d: ...");  */
21262306a36Sopenharmony_ci	unsigned int         type;     /* card type (pointer into tvcards[])  */
21362306a36Sopenharmony_ci};
21462306a36Sopenharmony_ci
21562306a36Sopenharmony_cistruct bttv;
21662306a36Sopenharmony_ci
21762306a36Sopenharmony_cistruct tvcard {
21862306a36Sopenharmony_ci	char *name;
21962306a36Sopenharmony_ci	void (*volume_gpio)(struct bttv *btv, __u16 volume);
22062306a36Sopenharmony_ci	void (*audio_mode_gpio)(struct bttv *btv, struct v4l2_tuner *tuner, int set);
22162306a36Sopenharmony_ci	void (*muxsel_hook)(struct bttv *btv, unsigned int input);
22262306a36Sopenharmony_ci
22362306a36Sopenharmony_ci	/* MUX bits for each input, two bits per input starting with the LSB */
22462306a36Sopenharmony_ci	u32 muxsel; /* Use MUXSEL() to set */
22562306a36Sopenharmony_ci
22662306a36Sopenharmony_ci	u32 gpiomask;
22762306a36Sopenharmony_ci	u32 gpiomux[4];  /* Tuner, Radio, external, internal */
22862306a36Sopenharmony_ci	u32 gpiomute;    /* GPIO mute setting */
22962306a36Sopenharmony_ci	u32 gpiomask2;   /* GPIO MUX mask */
23062306a36Sopenharmony_ci
23162306a36Sopenharmony_ci	unsigned int tuner_type;
23262306a36Sopenharmony_ci	u8 tuner_addr;
23362306a36Sopenharmony_ci	u8 video_inputs;	/* Number of inputs */
23462306a36Sopenharmony_ci	unsigned int svhs:4;	/* Which input is s-video */
23562306a36Sopenharmony_ci#define NO_SVHS	15
23662306a36Sopenharmony_ci	unsigned int pll:2;
23762306a36Sopenharmony_ci#define PLL_NONE 0
23862306a36Sopenharmony_ci#define PLL_28   1
23962306a36Sopenharmony_ci#define PLL_35   2
24062306a36Sopenharmony_ci#define PLL_14   3
24162306a36Sopenharmony_ci
24262306a36Sopenharmony_ci	/* i2c audio flags */
24362306a36Sopenharmony_ci	unsigned int no_msp34xx:1;
24462306a36Sopenharmony_ci	unsigned int no_tda7432:1;
24562306a36Sopenharmony_ci	unsigned int msp34xx_alt:1;
24662306a36Sopenharmony_ci	/* Note: currently no card definition needs to mark the presence
24762306a36Sopenharmony_ci	   of a RDS saa6588 chip. If this is ever needed, then add a new
24862306a36Sopenharmony_ci	   'has_saa6588' bit here. */
24962306a36Sopenharmony_ci
25062306a36Sopenharmony_ci	unsigned int no_video:1; /* video pci function is unused */
25162306a36Sopenharmony_ci	unsigned int has_dvb:1;
25262306a36Sopenharmony_ci	unsigned int has_remote:1;
25362306a36Sopenharmony_ci	unsigned int has_radio:1;
25462306a36Sopenharmony_ci	unsigned int has_dig_in:1; /* Has digital input (always last input) */
25562306a36Sopenharmony_ci	unsigned int no_gpioirq:1;
25662306a36Sopenharmony_ci};
25762306a36Sopenharmony_ci
25862306a36Sopenharmony_ciextern struct tvcard bttv_tvcards[];
25962306a36Sopenharmony_ci
26062306a36Sopenharmony_ci/*
26162306a36Sopenharmony_ci * This bit of cpp voodoo is used to create a macro with a variable number of
26262306a36Sopenharmony_ci * arguments (1 to 16).  It will pack each argument into a word two bits at a
26362306a36Sopenharmony_ci * time.  It can't be a function because it needs to be compile time constant to
26462306a36Sopenharmony_ci * initialize structures.  Since each argument must fit in two bits, it's ok
26562306a36Sopenharmony_ci * that they are changed to octal.  One should not use hex number, macros, or
26662306a36Sopenharmony_ci * anything else with this macro.  Just use plain integers from 0 to 3.
26762306a36Sopenharmony_ci */
26862306a36Sopenharmony_ci#define _MUXSELf(a)		0##a << 30
26962306a36Sopenharmony_ci#define _MUXSELe(a, b...)	0##a << 28 | _MUXSELf(b)
27062306a36Sopenharmony_ci#define _MUXSELd(a, b...)	0##a << 26 | _MUXSELe(b)
27162306a36Sopenharmony_ci#define _MUXSELc(a, b...)	0##a << 24 | _MUXSELd(b)
27262306a36Sopenharmony_ci#define _MUXSELb(a, b...)	0##a << 22 | _MUXSELc(b)
27362306a36Sopenharmony_ci#define _MUXSELa(a, b...)	0##a << 20 | _MUXSELb(b)
27462306a36Sopenharmony_ci#define _MUXSEL9(a, b...)	0##a << 18 | _MUXSELa(b)
27562306a36Sopenharmony_ci#define _MUXSEL8(a, b...)	0##a << 16 | _MUXSEL9(b)
27662306a36Sopenharmony_ci#define _MUXSEL7(a, b...)	0##a << 14 | _MUXSEL8(b)
27762306a36Sopenharmony_ci#define _MUXSEL6(a, b...)	0##a << 12 | _MUXSEL7(b)
27862306a36Sopenharmony_ci#define _MUXSEL5(a, b...)	0##a << 10 | _MUXSEL6(b)
27962306a36Sopenharmony_ci#define _MUXSEL4(a, b...)	0##a << 8  | _MUXSEL5(b)
28062306a36Sopenharmony_ci#define _MUXSEL3(a, b...)	0##a << 6  | _MUXSEL4(b)
28162306a36Sopenharmony_ci#define _MUXSEL2(a, b...)	0##a << 4  | _MUXSEL3(b)
28262306a36Sopenharmony_ci#define _MUXSEL1(a, b...)	0##a << 2  | _MUXSEL2(b)
28362306a36Sopenharmony_ci#define MUXSEL(a, b...)		(a | _MUXSEL1(b))
28462306a36Sopenharmony_ci
28562306a36Sopenharmony_ci/* identification / initialization of the card */
28662306a36Sopenharmony_ciextern void bttv_idcard(struct bttv *btv);
28762306a36Sopenharmony_ciextern void bttv_init_card1(struct bttv *btv);
28862306a36Sopenharmony_ciextern void bttv_init_card2(struct bttv *btv);
28962306a36Sopenharmony_ciextern void bttv_init_tuner(struct bttv *btv);
29062306a36Sopenharmony_ci
29162306a36Sopenharmony_ci/* card-specific functions */
29262306a36Sopenharmony_ciextern u32 bttv_tda9880_setnorm(struct bttv *btv, u32 gpiobits);
29362306a36Sopenharmony_ci
29462306a36Sopenharmony_ci/* extra tweaks for some chipsets */
29562306a36Sopenharmony_ciextern void bttv_check_chipset(void);
29662306a36Sopenharmony_ciextern int bttv_handle_chipset(struct bttv *btv);
29762306a36Sopenharmony_ci
29862306a36Sopenharmony_ci/* ---------------------------------------------------------- */
29962306a36Sopenharmony_ci/* exported by bttv-if.c                                      */
30062306a36Sopenharmony_ci
30162306a36Sopenharmony_ci/* this obsolete -- please use the sysfs-based
30262306a36Sopenharmony_ci   interface below for new code */
30362306a36Sopenharmony_ci
30462306a36Sopenharmony_ciextern struct pci_dev* bttv_get_pcidev(unsigned int card);
30562306a36Sopenharmony_ci
30662306a36Sopenharmony_ci/* sets GPOE register (BT848_GPIO_OUT_EN) to new value:
30762306a36Sopenharmony_ci   data | (current_GPOE_value & ~mask)
30862306a36Sopenharmony_ci   returns negative value if error occurred
30962306a36Sopenharmony_ci*/
31062306a36Sopenharmony_ciextern int bttv_gpio_enable(unsigned int card,
31162306a36Sopenharmony_ci			    unsigned long mask, unsigned long data);
31262306a36Sopenharmony_ci
31362306a36Sopenharmony_ci/* fills data with GPDATA register contents
31462306a36Sopenharmony_ci   returns negative value if error occurred
31562306a36Sopenharmony_ci*/
31662306a36Sopenharmony_ciextern int bttv_read_gpio(unsigned int card, unsigned long *data);
31762306a36Sopenharmony_ci
31862306a36Sopenharmony_ci/* sets GPDATA register to new value:
31962306a36Sopenharmony_ci  (data & mask) | (current_GPDATA_value & ~mask)
32062306a36Sopenharmony_ci  returns negative value if error occurred
32162306a36Sopenharmony_ci*/
32262306a36Sopenharmony_ciextern int bttv_write_gpio(unsigned int card,
32362306a36Sopenharmony_ci			   unsigned long mask, unsigned long data);
32462306a36Sopenharmony_ci
32562306a36Sopenharmony_ci
32662306a36Sopenharmony_ci
32762306a36Sopenharmony_ci
32862306a36Sopenharmony_ci/* ---------------------------------------------------------- */
32962306a36Sopenharmony_ci/* sysfs/driver-moded based gpio access interface             */
33062306a36Sopenharmony_ci
33162306a36Sopenharmony_cistruct bttv_sub_device {
33262306a36Sopenharmony_ci	struct device    dev;
33362306a36Sopenharmony_ci	struct bttv_core *core;
33462306a36Sopenharmony_ci	struct list_head list;
33562306a36Sopenharmony_ci};
33662306a36Sopenharmony_ci#define to_bttv_sub_dev(x) container_of((x), struct bttv_sub_device, dev)
33762306a36Sopenharmony_ci
33862306a36Sopenharmony_cistruct bttv_sub_driver {
33962306a36Sopenharmony_ci	struct device_driver   drv;
34062306a36Sopenharmony_ci	char                   wanted[20];
34162306a36Sopenharmony_ci	int                    (*probe)(struct bttv_sub_device *sub);
34262306a36Sopenharmony_ci	void                   (*remove)(struct bttv_sub_device *sub);
34362306a36Sopenharmony_ci};
34462306a36Sopenharmony_ci#define to_bttv_sub_drv(x) container_of((x), struct bttv_sub_driver, drv)
34562306a36Sopenharmony_ci
34662306a36Sopenharmony_ciint bttv_sub_register(struct bttv_sub_driver *drv, char *wanted);
34762306a36Sopenharmony_ciint bttv_sub_unregister(struct bttv_sub_driver *drv);
34862306a36Sopenharmony_ci
34962306a36Sopenharmony_ci/* gpio access functions */
35062306a36Sopenharmony_civoid bttv_gpio_inout(struct bttv_core *core, u32 mask, u32 outbits);
35162306a36Sopenharmony_ciu32 bttv_gpio_read(struct bttv_core *core);
35262306a36Sopenharmony_civoid bttv_gpio_write(struct bttv_core *core, u32 value);
35362306a36Sopenharmony_civoid bttv_gpio_bits(struct bttv_core *core, u32 mask, u32 bits);
35462306a36Sopenharmony_ci
35562306a36Sopenharmony_ci#define gpio_inout(mask,bits)  bttv_gpio_inout(&btv->c, mask, bits)
35662306a36Sopenharmony_ci#define gpio_read()            bttv_gpio_read(&btv->c)
35762306a36Sopenharmony_ci#define gpio_write(value)      bttv_gpio_write(&btv->c, value)
35862306a36Sopenharmony_ci#define gpio_bits(mask,bits)   bttv_gpio_bits(&btv->c, mask, bits)
35962306a36Sopenharmony_ci
36062306a36Sopenharmony_ci
36162306a36Sopenharmony_ci/* ---------------------------------------------------------- */
36262306a36Sopenharmony_ci/* i2c                                                        */
36362306a36Sopenharmony_ci
36462306a36Sopenharmony_ci#define bttv_call_all(btv, o, f, args...) \
36562306a36Sopenharmony_ci	v4l2_device_call_all(&btv->c.v4l2_dev, 0, o, f, ##args)
36662306a36Sopenharmony_ci
36762306a36Sopenharmony_ci#define bttv_call_all_err(btv, o, f, args...) \
36862306a36Sopenharmony_ci	v4l2_device_call_until_err(&btv->c.v4l2_dev, 0, o, f, ##args)
36962306a36Sopenharmony_ci
37062306a36Sopenharmony_ciextern int bttv_I2CRead(struct bttv *btv, unsigned char addr, char *probe_for);
37162306a36Sopenharmony_ciextern int bttv_I2CWrite(struct bttv *btv, unsigned char addr, unsigned char b1,
37262306a36Sopenharmony_ci			 unsigned char b2, int both);
37362306a36Sopenharmony_ciextern void bttv_readee(struct bttv *btv, unsigned char *eedata, int addr);
37462306a36Sopenharmony_ci
37562306a36Sopenharmony_ciextern int bttv_input_init(struct bttv *dev);
37662306a36Sopenharmony_ciextern void bttv_input_fini(struct bttv *dev);
37762306a36Sopenharmony_ciextern void bttv_input_irq(struct bttv *dev);
37862306a36Sopenharmony_ci
37962306a36Sopenharmony_ci#endif /* _BTTV_H_ */
380