blob: ae9cf5bfdd591ea08714f1ded0ef25318f634b29 [file] [log] [blame]
Thomas Gleixnerc942fdd2019-05-27 08:55:06 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Hans Verkuil1c1e45d2008-04-28 20:24:33 -03002/*
3 * cx18 functions to query card hardware
4 *
5 * Derived from ivtv-cards.c
6 *
7 * Copyright (C) 2007 Hans Verkuil <hverkuil@xs4all.nl>
Andy Walls6afdeaf2010-05-23 18:53:35 -03008 * Copyright (C) 2008 Andy Walls <awalls@md.metrocast.net>
Hans Verkuil1c1e45d2008-04-28 20:24:33 -03009 */
10
11/* hardware flags */
Andy Walls8ca95562009-07-28 11:48:18 -030012#define CX18_HW_TUNER (1 << 0)
13#define CX18_HW_TVEEPROM (1 << 1)
14#define CX18_HW_CS5345 (1 << 2)
15#define CX18_HW_DVB (1 << 3)
16#define CX18_HW_418_AV (1 << 4)
17#define CX18_HW_GPIO_MUX (1 << 5)
18#define CX18_HW_GPIO_RESET_CTRL (1 << 6)
Sean Youngab5222e2017-10-12 18:02:57 -040019#define CX18_HW_Z8F0811_IR_HAUP (1 << 7)
Andy Walls83526192009-11-21 13:39:28 -030020
Hans Verkuil1c1e45d2008-04-28 20:24:33 -030021/* video inputs */
22#define CX18_CARD_INPUT_VID_TUNER 1
Mauro Carvalho Chehab6e6a8b52018-01-04 13:08:56 -050023#define CX18_CARD_INPUT_SVIDEO1 2
24#define CX18_CARD_INPUT_SVIDEO2 3
25#define CX18_CARD_INPUT_COMPOSITE1 4
26#define CX18_CARD_INPUT_COMPOSITE2 5
27#define CX18_CARD_INPUT_COMPONENT1 6
Hans Verkuil1c1e45d2008-04-28 20:24:33 -030028
Hans Verkuil1c1e45d2008-04-28 20:24:33 -030029/* audio inputs */
30#define CX18_CARD_INPUT_AUD_TUNER 1
Mauro Carvalho Chehab6e6a8b52018-01-04 13:08:56 -050031#define CX18_CARD_INPUT_LINE_IN1 2
32#define CX18_CARD_INPUT_LINE_IN2 3
Hans Verkuil1c1e45d2008-04-28 20:24:33 -030033
34#define CX18_CARD_MAX_VIDEO_INPUTS 6
35#define CX18_CARD_MAX_AUDIO_INPUTS 3
Mauro Carvalho Chehab6e6a8b52018-01-04 13:08:56 -050036#define CX18_CARD_MAX_TUNERS 2
Hans Verkuil1c1e45d2008-04-28 20:24:33 -030037
Hans Verkuil1c1e45d2008-04-28 20:24:33 -030038/* V4L2 capability aliases */
39#define CX18_CAP_ENCODER (V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_TUNER | \
Andy Wallsaf009cf2008-12-12 20:00:29 -030040 V4L2_CAP_AUDIO | V4L2_CAP_READWRITE | \
Hans Verkuildfdf7802014-11-24 06:37:21 -030041 V4L2_CAP_STREAMING | V4L2_CAP_VBI_CAPTURE | \
42 V4L2_CAP_SLICED_VBI_CAPTURE)
Hans Verkuil1c1e45d2008-04-28 20:24:33 -030043
44struct cx18_card_video_input {
Mauro Carvalho Chehab6e6a8b52018-01-04 13:08:56 -050045 u8 video_type; /* video input type */
Hans Verkuil1c1e45d2008-04-28 20:24:33 -030046 u8 audio_index; /* index in cx18_card_audio_input array */
Andy Wallsd9a325a2010-03-13 16:40:03 -030047 u32 video_input; /* hardware video input */
Hans Verkuil1c1e45d2008-04-28 20:24:33 -030048};
49
50struct cx18_card_audio_input {
51 u8 audio_type; /* audio input type */
52 u32 audio_input; /* hardware audio input */
53 u16 muxer_input; /* hardware muxer input for boards with a
54 multiplexer chip */
55};
56
57struct cx18_card_pci_info {
58 u16 device;
59 u16 subsystem_vendor;
60 u16 subsystem_device;
61};
62
63/* GPIO definitions */
64
65/* The mask is the set of bits used by the operation */
66
67struct cx18_gpio_init { /* set initial GPIO DIR and OUT values */
Mauro Carvalho Chehab6e6a8b52018-01-04 13:08:56 -050068 u32 direction; /* DIR setting. Leave to 0 if no init is needed */
Hans Verkuil9dcbf352008-05-12 13:57:18 -030069 u32 initial_value;
Hans Verkuil1c1e45d2008-04-28 20:24:33 -030070};
71
Andy Walls1f09e8a2008-06-22 01:27:00 -030072struct cx18_gpio_i2c_slave_reset {
73 u32 active_lo_mask; /* GPIO outputs that reset i2c chips when low */
74 u32 active_hi_mask; /* GPIO outputs that reset i2c chips when high */
75 int msecs_asserted; /* time period reset must remain asserted */
76 int msecs_recovery; /* time after deassert for chips to be ready */
Mauro Carvalho Chehab16790552019-02-18 14:28:59 -050077 u32 ir_reset_mask; /* GPIO to reset the Zilog Z8F0811 IR controller */
Andy Walls1f09e8a2008-06-22 01:27:00 -030078};
79
Mauro Carvalho Chehab6e6a8b52018-01-04 13:08:56 -050080struct cx18_gpio_audio_input { /* select tuner/line in input */
81 u32 mask; /* leave to 0 if not supported */
Sri Deevi03c28082008-06-21 11:06:44 -030082 u32 tuner;
83 u32 linein;
84 u32 radio;
85};
86
Hans Verkuil1c1e45d2008-04-28 20:24:33 -030087struct cx18_card_tuner {
Mauro Carvalho Chehab6e6a8b52018-01-04 13:08:56 -050088 v4l2_std_id std; /* standard for which the tuner is suitable */
89 int tuner; /* tuner ID (from tuner.h) */
Hans Verkuil1c1e45d2008-04-28 20:24:33 -030090};
91
92struct cx18_card_tuner_i2c {
93 unsigned short radio[2];/* radio tuner i2c address to probe */
Andy Walls2bfe2fa2011-03-27 00:20:37 -030094 unsigned short demod[3];/* demodulator i2c address to probe */
Hans Verkuil1c1e45d2008-04-28 20:24:33 -030095 unsigned short tv[4]; /* tv tuner i2c addresses to probe */
96};
97
98struct cx18_ddr { /* DDR config data */
99 u32 chip_config;
100 u32 refresh;
101 u32 timing1;
102 u32 timing2;
103 u32 tune_lane;
104 u32 initial_emrs;
105};
106
107/* for card information/parameters */
108struct cx18_card {
109 int type;
110 char *name;
111 char *comment;
112 u32 v4l2_capabilities;
113 u32 hw_audio_ctrl; /* hardware used for the V4L2 controls (only
Andy Wallsff2a2002009-02-20 23:52:13 -0300114 1 dev allowed currently) */
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300115 u32 hw_muxer; /* hardware used to multiplex audio input */
116 u32 hw_all; /* all hardware used by the board */
117 struct cx18_card_video_input video_inputs[CX18_CARD_MAX_VIDEO_INPUTS];
118 struct cx18_card_audio_input audio_inputs[CX18_CARD_MAX_AUDIO_INPUTS];
119 struct cx18_card_audio_input radio_input;
120
121 /* GPIO card-specific settings */
Mauro Carvalho Chehab6e6a8b52018-01-04 13:08:56 -0500122 u8 xceive_pin; /* XCeive tuner GPIO reset pin */
123 struct cx18_gpio_init gpio_init;
Andy Walls1f09e8a2008-06-22 01:27:00 -0300124 struct cx18_gpio_i2c_slave_reset gpio_i2c_slave_reset;
Hans Verkuilfdea5d62008-06-21 13:25:36 -0300125 struct cx18_gpio_audio_input gpio_audio_input;
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300126
127 struct cx18_card_tuner tuners[CX18_CARD_MAX_TUNERS];
128 struct cx18_card_tuner_i2c *i2c;
129
130 struct cx18_ddr ddr;
131
132 /* list of device and subsystem vendor/devices that
133 correspond to this card type. */
134 const struct cx18_card_pci_info *pci_list;
135};
136
137int cx18_get_input(struct cx18 *cx, u16 index, struct v4l2_input *input);
138int cx18_get_audio_input(struct cx18 *cx, u16 index, struct v4l2_audio *input);
139const struct cx18_card *cx18_get_card(u16 index);