blob: b5f894c0afa907e1dbe0362bd4f333093b260238 [file] [log] [blame]
Hans Verkuil1c1e45d2008-04-28 20:24:33 -03001/*
2 * cx18 functions to query card hardware
3 *
4 * Derived from ivtv-cards.c
5 *
6 * Copyright (C) 2007 Hans Verkuil <hverkuil@xs4all.nl>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
23/* hardware flags */
24#define CX18_HW_TUNER (1 << 0)
25#define CX18_HW_TVEEPROM (1 << 1)
26#define CX18_HW_CS5345 (1 << 2)
27#define CX18_HW_GPIO (1 << 3)
28#define CX18_HW_CX23418 (1 << 4)
29#define CX18_HW_DVB (1 << 5)
30
31/* video inputs */
32#define CX18_CARD_INPUT_VID_TUNER 1
33#define CX18_CARD_INPUT_SVIDEO1 2
34#define CX18_CARD_INPUT_SVIDEO2 3
35#define CX18_CARD_INPUT_COMPOSITE1 4
36#define CX18_CARD_INPUT_COMPOSITE2 5
37#define CX18_CARD_INPUT_COMPOSITE3 6
38
Hans Verkuil1c1e45d2008-04-28 20:24:33 -030039/* audio inputs */
40#define CX18_CARD_INPUT_AUD_TUNER 1
41#define CX18_CARD_INPUT_LINE_IN1 2
42#define CX18_CARD_INPUT_LINE_IN2 3
43
44#define CX18_CARD_MAX_VIDEO_INPUTS 6
45#define CX18_CARD_MAX_AUDIO_INPUTS 3
46#define CX18_CARD_MAX_TUNERS 2
47
Hans Verkuil1c1e45d2008-04-28 20:24:33 -030048/* V4L2 capability aliases */
49#define CX18_CAP_ENCODER (V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_TUNER | \
50 V4L2_CAP_AUDIO | V4L2_CAP_READWRITE)
51/* | V4L2_CAP_VBI_CAPTURE | V4L2_CAP_SLICED_VBI_CAPTURE) not yet */
52
53struct cx18_card_video_input {
54 u8 video_type; /* video input type */
55 u8 audio_index; /* index in cx18_card_audio_input array */
56 u16 video_input; /* hardware video input */
57};
58
59struct cx18_card_audio_input {
60 u8 audio_type; /* audio input type */
61 u32 audio_input; /* hardware audio input */
62 u16 muxer_input; /* hardware muxer input for boards with a
63 multiplexer chip */
64};
65
66struct cx18_card_pci_info {
67 u16 device;
68 u16 subsystem_vendor;
69 u16 subsystem_device;
70};
71
72/* GPIO definitions */
73
74/* The mask is the set of bits used by the operation */
75
76struct cx18_gpio_init { /* set initial GPIO DIR and OUT values */
Hans Verkuil9dcbf352008-05-12 13:57:18 -030077 u32 direction; /* DIR setting. Leave to 0 if no init is needed */
78 u32 initial_value;
Hans Verkuil1c1e45d2008-04-28 20:24:33 -030079};
80
Andy Walls1f09e8a2008-06-22 01:27:00 -030081struct cx18_gpio_i2c_slave_reset {
82 u32 active_lo_mask; /* GPIO outputs that reset i2c chips when low */
83 u32 active_hi_mask; /* GPIO outputs that reset i2c chips when high */
84 int msecs_asserted; /* time period reset must remain asserted */
85 int msecs_recovery; /* time after deassert for chips to be ready */
86};
87
Sri Deevi03c28082008-06-21 11:06:44 -030088struct ivtv_gpio_audio_input { /* select tuner/line in input */
89 u32 mask; /* leave to 0 if not supported */
90 u32 tuner;
91 u32 linein;
92 u32 radio;
93};
94
Hans Verkuil1c1e45d2008-04-28 20:24:33 -030095struct cx18_card_tuner {
96 v4l2_std_id std; /* standard for which the tuner is suitable */
97 int tuner; /* tuner ID (from tuner.h) */
98};
99
100struct cx18_card_tuner_i2c {
101 unsigned short radio[2];/* radio tuner i2c address to probe */
102 unsigned short demod[2];/* demodulator i2c address to probe */
103 unsigned short tv[4]; /* tv tuner i2c addresses to probe */
104};
105
106struct cx18_ddr { /* DDR config data */
107 u32 chip_config;
108 u32 refresh;
109 u32 timing1;
110 u32 timing2;
111 u32 tune_lane;
112 u32 initial_emrs;
113};
114
115/* for card information/parameters */
116struct cx18_card {
117 int type;
118 char *name;
119 char *comment;
120 u32 v4l2_capabilities;
121 u32 hw_audio_ctrl; /* hardware used for the V4L2 controls (only
122 1 dev allowed) */
123 u32 hw_muxer; /* hardware used to multiplex audio input */
124 u32 hw_all; /* all hardware used by the board */
125 struct cx18_card_video_input video_inputs[CX18_CARD_MAX_VIDEO_INPUTS];
126 struct cx18_card_audio_input audio_inputs[CX18_CARD_MAX_AUDIO_INPUTS];
127 struct cx18_card_audio_input radio_input;
128
129 /* GPIO card-specific settings */
Hans Verkuil9dcbf352008-05-12 13:57:18 -0300130 u8 xceive_pin; /* XCeive tuner GPIO reset pin */
Andy Walls1f09e8a2008-06-22 01:27:00 -0300131 struct cx18_gpio_init gpio_init;
132 struct cx18_gpio_i2c_slave_reset gpio_i2c_slave_reset;
Sri Deevi03c28082008-06-21 11:06:44 -0300133 struct ivtv_gpio_audio_input gpio_audio_input;
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300134
135 struct cx18_card_tuner tuners[CX18_CARD_MAX_TUNERS];
136 struct cx18_card_tuner_i2c *i2c;
137
138 struct cx18_ddr ddr;
139
140 /* list of device and subsystem vendor/devices that
141 correspond to this card type. */
142 const struct cx18_card_pci_info *pci_list;
143};
144
145int cx18_get_input(struct cx18 *cx, u16 index, struct v4l2_input *input);
146int cx18_get_audio_input(struct cx18 *cx, u16 index, struct v4l2_audio *input);
147const struct cx18_card *cx18_get_card(u16 index);