123599Smarkm/*
223599Smarkm * extensions to ioctl_meteor.h for the bt848 cards
339838Ssos *
450477Speter * $FreeBSD: releng/11.0/sys/dev/bktr/ioctl_bt848.h 205781 2010-03-28 00:10:09Z gibbs $
523599Smarkm */
623599Smarkm
7123688Sobrien#ifndef  _DEV_BKTR_IOCTL_BT848_H_
8123688Sobrien#define  _DEV_BKTR_IOCTL_BT848_H_
959013Sroger
1023599Smarkm/*
1124086Sfsmp * frequency sets
1223599Smarkm */
1324086Sfsmp#define CHNLSET_NABCST		1
1424086Sfsmp#define CHNLSET_CABLEIRC	2
1524086Sfsmp#define CHNLSET_CABLEHRC	3
1624086Sfsmp#define CHNLSET_WEUROPE		4
1730193Smarkm#define CHNLSET_JPNBCST         5
1830193Smarkm#define CHNLSET_JPNCABLE        6
1939040Ssos#define CHNLSET_XUSSR           7
2047297Sroger#define CHNLSET_AUSTRALIA       8
2156532Sroger#define CHNLSET_FRANCE          9
2230193Smarkm#define CHNLSET_MIN	        CHNLSET_NABCST
2356532Sroger#define CHNLSET_MAX	        CHNLSET_FRANCE
2423599Smarkm
2523599Smarkm
2623599Smarkm/*
2723936Sfsmp * constants for various tuner registers
2823936Sfsmp */
2923936Sfsmp#define BT848_HUEMIN		(-90)
3023936Sfsmp#define BT848_HUEMAX		90
3123936Sfsmp#define BT848_HUECENTER		0
3223936Sfsmp#define BT848_HUERANGE		179.3
3323936Sfsmp#define BT848_HUEREGMIN		(-128)
3423936Sfsmp#define BT848_HUEREGMAX		127
3523936Sfsmp#define BT848_HUESTEPS		256
3623936Sfsmp
3723936Sfsmp#define BT848_BRIGHTMIN		(-50)
3823936Sfsmp#define BT848_BRIGHTMAX		50
3923936Sfsmp#define BT848_BRIGHTCENTER	0
4023936Sfsmp#define BT848_BRIGHTRANGE	99.6
4123936Sfsmp#define BT848_BRIGHTREGMIN	(-128)
4223936Sfsmp#define BT848_BRIGHTREGMAX	127
4323936Sfsmp#define BT848_BRIGHTSTEPS	256
4423936Sfsmp
4523936Sfsmp#define BT848_CONTRASTMIN	0
4623936Sfsmp#define BT848_CONTRASTMAX	237
4723936Sfsmp#define BT848_CONTRASTCENTER	100
4823936Sfsmp#define BT848_CONTRASTRANGE	236.57
4923936Sfsmp#define BT848_CONTRASTREGMIN	0
5023936Sfsmp#define BT848_CONTRASTREGMAX	511
5123936Sfsmp#define BT848_CONTRASTSTEPS	512
5223936Sfsmp
5323936Sfsmp#define BT848_CHROMAMIN		0
5423936Sfsmp#define BT848_CHROMAMAX		284
5523936Sfsmp#define BT848_CHROMACENTER	100
5623936Sfsmp#define BT848_CHROMARANGE	283.89
5723936Sfsmp#define BT848_CHROMAREGMIN	0
5823936Sfsmp#define BT848_CHROMAREGMAX	511
5923936Sfsmp#define BT848_CHROMASTEPS	512
6023936Sfsmp
6123936Sfsmp#define BT848_SATUMIN		0
6223936Sfsmp#define BT848_SATUMAX		202
6323936Sfsmp#define BT848_SATUCENTER	100
6423936Sfsmp#define BT848_SATURANGE		201.18
6523936Sfsmp#define BT848_SATUREGMIN	0
6623936Sfsmp#define BT848_SATUREGMAX	511
6723936Sfsmp#define BT848_SATUSTEPS		512
6823936Sfsmp
6923936Sfsmp#define BT848_SATVMIN		0
7023936Sfsmp#define BT848_SATVMAX		284
7123936Sfsmp#define BT848_SATVCENTER	100
7223936Sfsmp#define BT848_SATVRANGE		283.89
7323936Sfsmp#define BT848_SATVREGMIN	0
7423936Sfsmp#define BT848_SATVREGMAX	511
7523936Sfsmp#define BT848_SATVSTEPS		512
7623936Sfsmp
7723936Sfsmp
7824086Sfsmp/*
7924086Sfsmp * audio stuff
8024086Sfsmp */
8124086Sfsmp#define AUDIO_TUNER		0x00	/* command for the audio routine */
8224086Sfsmp#define AUDIO_EXTERN		0x01	/* don't confuse them with bit */
8324086Sfsmp#define AUDIO_INTERN		0x02	/* settings */
8424086Sfsmp#define AUDIO_MUTE		0x80
8524086Sfsmp#define AUDIO_UNMUTE		0x81
8624086Sfsmp
8724086Sfsmp
8824086Sfsmp/*
8924086Sfsmp * EEProm stuff
9024086Sfsmp */
9124045Sfsmpstruct eeProm {
92205781Sgibbs	short		offset;
93205781Sgibbs	short		count;
94205781Sgibbs	unsigned char	bytes[ 256 ];
9524045Sfsmp};
9624045Sfsmp
9724045Sfsmp
9823936Sfsmp/*
9923599Smarkm * XXX: this is a hack, should be in ioctl_meteor.h
10023599Smarkm * here to avoid touching that file for now...
10123599Smarkm */
10223599Smarkm#define	TVTUNER_SETCHNL    _IOW('x', 32, unsigned int)	/* set channel */
10323599Smarkm#define	TVTUNER_GETCHNL    _IOR('x', 32, unsigned int)	/* get channel */
10423599Smarkm#define	TVTUNER_SETTYPE    _IOW('x', 33, unsigned int)	/* set tuner type */
10523599Smarkm#define	TVTUNER_GETTYPE    _IOR('x', 33, unsigned int)	/* get tuner type */
10623599Smarkm#define	TVTUNER_GETSTATUS  _IOR('x', 34, unsigned int)	/* get tuner status */
10723936Sfsmp#define	TVTUNER_SETFREQ    _IOW('x', 35, unsigned int)	/* set frequency */
10823936Sfsmp#define	TVTUNER_GETFREQ    _IOR('x', 36, unsigned int)	/* get frequency */
10943889Sroger
11023599Smarkm
11124086Sfsmp#define BT848_SHUE	_IOW('x', 37, int)		/* set hue */
11224086Sfsmp#define BT848_GHUE	_IOR('x', 37, int)		/* get hue */
11323936Sfsmp#define	BT848_SBRIG	_IOW('x', 38, int)		/* set brightness */
11424086Sfsmp#define BT848_GBRIG	_IOR('x', 38, int)		/* get brightness */
11523936Sfsmp#define	BT848_SCSAT	_IOW('x', 39, int)		/* set chroma sat */
11624086Sfsmp#define BT848_GCSAT	_IOR('x', 39, int)		/* get UV saturation */
11724086Sfsmp#define	BT848_SCONT	_IOW('x', 40, int)		/* set contrast */
11823936Sfsmp#define	BT848_GCONT	_IOR('x', 40, int)		/* get contrast */
11923936Sfsmp#define	BT848_SVSAT	_IOW('x', 41, int)		/* set chroma V sat */
12024086Sfsmp#define BT848_GVSAT	_IOR('x', 41, int)		/* get V saturation */
12123936Sfsmp#define	BT848_SUSAT	_IOW('x', 42, int)		/* set chroma U sat */
12224086Sfsmp#define BT848_GUSAT	_IOR('x', 42, int)		/* get U saturation */
12323936Sfsmp
12424045Sfsmp#define	BT848_SCBARS	_IOR('x', 43, int)		/* set colorbar */
12524045Sfsmp#define	BT848_CCBARS	_IOR('x', 44, int)		/* clear colorbar */
12623936Sfsmp
12724045Sfsmp
12824086Sfsmp#define	BT848_SAUDIO	_IOW('x', 46, int)		/* set audio channel */
12924086Sfsmp#define BT848_GAUDIO	_IOR('x', 47, int)		/* get audio channel */
13024086Sfsmp#define	BT848_SBTSC	_IOW('x', 48, int)		/* set audio channel */
13124086Sfsmp
13224244Sfsmp#define	BT848_GSTATUS	_IOR('x', 49, unsigned int)	/* reap status */
13324244Sfsmp
13424528Sfsmp#define	BT848_WEEPROM	_IOWR('x', 50, struct eeProm)	/* write to EEProm */
13524528Sfsmp#define	BT848_REEPROM	_IOWR('x', 51, struct eeProm)	/* read from EEProm */
13624244Sfsmp
13724528Sfsmp#define	BT848_SIGNATURE	_IOWR('x', 52, struct eeProm)	/* read card sig */
13824528Sfsmp
13924528Sfsmp#define	TVTUNER_SETAFC	_IOW('x', 53, int)		/* turn AFC on/off */
14024528Sfsmp#define TVTUNER_GETAFC	_IOR('x', 54, int)		/* query AFC on/off */
14129233Smarkm#define BT848_SLNOTCH	_IOW('x', 55, int)		/* set luma notch */
14229233Smarkm#define BT848_GLNOTCH	_IOR('x', 56, int)		/* get luma notch */
14324528Sfsmp
14444063Sroger/* Read/Write the BT848's I2C bus directly
14544063Sroger * b7-b0:    data (read/write)
14644063Sroger * b15-b8:   internal peripheral register (write)
14744063Sroger * b23-b16:  i2c addr (write)
14844063Sroger * b31-b24:  1 = write, 0 = read
14944063Sroger */
150205781Sgibbs#define BT848_I2CWR     _IOWR('x', 57, unsigned long)    /* i2c read-write */
15143889Sroger
15267641Srogerstruct bktr_msp_control {
15367641Sroger	unsigned char function;
15467641Sroger	unsigned int  address;
15567641Sroger	unsigned int  data;
15667641Sroger};
15767641Sroger
15867641Sroger#define BT848_MSP_RESET _IO('x', 76)				/* MSP chip reset */
15968077Sroger#define BT848_MSP_READ  _IOWR('x', 77, struct bktr_msp_control)	/* MSP chip read */
16068077Sroger#define BT848_MSP_WRITE _IOWR('x', 78, struct bktr_msp_control)	/* MSP chip write */
16167641Sroger
16244063Sroger/* Support for radio tuner */
16344063Sroger#define RADIO_SETMODE	 _IOW('x', 58, unsigned int)  /* set radio modes */
16444063Sroger#define RADIO_GETMODE	 _IOR('x', 58, unsigned char)  /* get radio modes */
16544063Sroger#define   RADIO_AFC	 0x01		/* These modes will probably not */
16644063Sroger#define   RADIO_MONO	 0x02		/*  work on the FRxxxx. It does	 */
16744063Sroger#define   RADIO_MUTE	 0x08		/*  work on the FMxxxx.	*/
16844063Sroger#define RADIO_SETFREQ    _IOW('x', 59, unsigned int)  /* set frequency   */
16944063Sroger#define RADIO_GETFREQ    _IOR('x', 59, unsigned int)  /* set frequency   */
17044063Sroger /*        Argument is frequency*100MHz  */
17143889Sroger
17223599Smarkm/*
17323599Smarkm * XXX: more bad magic,
17423599Smarkm *      we need to fix the METEORGINPUT to return something public
17523599Smarkm *      duplicate them here for now...
17623599Smarkm */
17723599Smarkm#define	METEOR_DEV0		0x00001000
17823599Smarkm#define	METEOR_DEV1		0x00002000
17923599Smarkm#define	METEOR_DEV2		0x00004000
18043348Sroger#define	METEOR_DEV3		0x00008000
18143348Sroger#define	METEOR_DEV_SVIDEO	0x00006000
18225328Sfsmp/*
18325328Sfsmp * right now I don't know were to put these, but as they are suppose to be
18425328Sfsmp * a part of a common video capture interface, these should be relocated to
18525328Sfsmp * another place.  Probably most of the METEOR_xxx defines need to be
18625328Sfsmp * renamed and moved to a common header
18725328Sfsmp */
18825328Sfsmp
18929233Smarkmtypedef enum { METEOR_PIXTYPE_RGB, METEOR_PIXTYPE_YUV,
19031186Sahasty	       METEOR_PIXTYPE_YUV_PACKED,
19131186Sahasty	       METEOR_PIXTYPE_YUV_12 } METEOR_PIXTYPE;
19225328Sfsmp
19331186Sahasty
19425328Sfsmpstruct meteor_pixfmt {
195205781Sgibbs	unsigned int   index;         /* Index in supported pixfmt list     */
19625328Sfsmp	METEOR_PIXTYPE type;          /* What's the board gonna feed us     */
197205781Sgibbs	unsigned int   Bpp;           /* Bytes per pixel                    */
198205781Sgibbs	unsigned long  masks[3];      /* R,G,B or Y,U,V masks, respectively */
19925328Sfsmp	unsigned       swap_bytes :1; /* Bytes  swapped within shorts       */
20025328Sfsmp	unsigned       swap_shorts:1; /* Shorts swapped within longs        */
20125328Sfsmp};
20225328Sfsmp
20325328Sfsmp
20425328Sfsmpstruct bktr_clip {
20525328Sfsmp    int          x_min;
20625328Sfsmp    int          x_max;
20725328Sfsmp    int          y_min;
20825328Sfsmp    int          y_max;
20925328Sfsmp};
21025328Sfsmp
21125328Sfsmp#define BT848_MAX_CLIP_NODE 100
21225328Sfsmpstruct _bktr_clip {
21325328Sfsmp    struct bktr_clip x[BT848_MAX_CLIP_NODE];
21425328Sfsmp};
21525328Sfsmp
21625328Sfsmp/*
21725328Sfsmp * I'm using METEOR_xxx just because that will be common to other interface
21825328Sfsmp * and less of a surprise
21925328Sfsmp */
22025328Sfsmp#define METEORSACTPIXFMT	_IOW('x', 64, int )
22125328Sfsmp#define METEORGACTPIXFMT	_IOR('x', 64, int )
22225328Sfsmp#define METEORGSUPPIXFMT	_IOWR('x', 65, struct meteor_pixfmt)
22325328Sfsmp
22425328Sfsmp/* set clip list */
22525328Sfsmp#define BT848SCLIP     _IOW('x', 66, struct _bktr_clip )
22625328Sfsmp#define BT848GCLIP     _IOR('x', 66, struct _bktr_clip )
22730193Smarkm
22830193Smarkm
22930193Smarkm/* set input format */
23030193Smarkm#define BT848SFMT		_IOW('x', 67, unsigned long )
23130193Smarkm#define BT848GFMT		_IOR('x', 67, unsigned long )
23230193Smarkm
23336090Sahasty/* set clear-buffer-on-start */
23436090Sahasty#define BT848SCBUF	_IOW('x', 68, int)
23536090Sahasty#define BT848GCBUF	_IOR('x', 68, int)
23636090Sahasty
23738706Ssos/* set capture area */
23838706Ssos/* The capture area is the area of the video image which is grabbed */
23938706Ssos/* Usually the capture area is 640x480 (768x576 PAL) pixels */
24038706Ssos/* This area is then scaled to the dimensions the user requires */
24138706Ssos/* using the METEORGEO ioctl */
24238706Ssos/* However, the capture area could be 400x300 pixels from the top right */
24338706Ssos/* corner of the video image */
24438706Ssosstruct bktr_capture_area {
24538706Ssos   int      x_offset;
24638706Ssos   int      y_offset;
24738706Ssos   int      x_size;
24838706Ssos   int      y_size;
24938706Ssos};
25038707Ssos#define BT848_SCAPAREA   _IOW('x', 69, struct bktr_capture_area)
25138707Ssos#define BT848_GCAPAREA   _IOR('x', 69, struct bktr_capture_area)
25236090Sahasty
25344063Sroger
25444063Sroger/* Get channel Set */
25544063Sroger#define BT848_MAX_CHNLSET_NAME_LEN 16
25644063Srogerstruct bktr_chnlset {
25744063Sroger       short   index;
25844063Sroger       short   max_channel;
25944063Sroger       char    name[BT848_MAX_CHNLSET_NAME_LEN];
26044063Sroger};
26144063Sroger#define	TVTUNER_GETCHNLSET _IOWR('x', 70, struct bktr_chnlset)
26244063Sroger
26344063Sroger
26444063Sroger
26544063Sroger/* Infra Red Remote Control */
26644063Srogerstruct bktr_remote {
26744063Sroger       unsigned char data[3];
26844063Sroger};
26944063Sroger#define	REMOTE_GETKEY      _IOR('x', 71, struct bktr_remote)/*read the remote */
27044063Sroger                                                            /*control receiver*/
27144063Sroger                                                            /*returns raw data*/
27244063Sroger
27344063Sroger
27444063Sroger/*
27544063Sroger * Direct access to GPIO pins. You must add BKTR_GPIO_ACCESS to your kernel
27644063Sroger * configuration file to use these
27730979Smarkm */
27844063Sroger#define BT848_GPIO_SET_EN      _IOW('x', 72, int)      /* set gpio_out_en */
27944063Sroger#define BT848_GPIO_GET_EN      _IOR('x', 73, int)      /* get gpio_out_en */
28044063Sroger#define BT848_GPIO_SET_DATA    _IOW('x', 74, int)      /* set gpio_data */
28144063Sroger#define BT848_GPIO_GET_DATA    _IOR('x', 75, int)      /* get gpio_data */
28230979Smarkm
28344063Sroger
28444063Sroger
28530193Smarkm/*  XXX - Copied from /sys/pci/brktree_reg.h  */
28630193Smarkm#define BT848_IFORM_FORMAT              (0x7<<0)
28730193Smarkm# define BT848_IFORM_F_RSVD             (0x7)
28830193Smarkm# define BT848_IFORM_F_SECAM            (0x6)
28930193Smarkm# define BT848_IFORM_F_PALN             (0x5)
29030193Smarkm# define BT848_IFORM_F_PALM             (0x4)
29130193Smarkm# define BT848_IFORM_F_PALBDGHI         (0x3)
29230193Smarkm# define BT848_IFORM_F_NTSCJ            (0x2)
29330193Smarkm# define BT848_IFORM_F_NTSCM            (0x1)
29430193Smarkm# define BT848_IFORM_F_AUTO             (0x0)
29530193Smarkm
29659013Sroger
297123688Sobrien#endif	/* _DEV_BKTR_IOCTL_BT848_H_ */
29859013Sroger
299