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