11c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil/* 21c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil * cx18 functions to query card hardware 31c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil * 41c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil * Derived from ivtv-cards.c 51c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil * 61c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil * Copyright (C) 2007 Hans Verkuil <hverkuil@xs4all.nl> 76afdeaf865b729287e02aafc61d8d013b89996efAndy Walls * Copyright (C) 2008 Andy Walls <awalls@md.metrocast.net> 81c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil * 91c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil * This program is free software; you can redistribute it and/or modify 101c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil * it under the terms of the GNU General Public License as published by 111c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil * the Free Software Foundation; either version 2 of the License, or 121c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil * (at your option) any later version. 131c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil * 141c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil * This program is distributed in the hope that it will be useful, 151c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil * but WITHOUT ANY WARRANTY; without even the implied warranty of 161c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 171c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil * GNU General Public License for more details. 181c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil * 191c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil * You should have received a copy of the GNU General Public License 201c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil * along with this program; if not, write to the Free Software 211c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 221c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil */ 231c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil 241c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil/* hardware flags */ 258ca955689a957ecf956bb052f60412da2753a977Andy Walls#define CX18_HW_TUNER (1 << 0) 268ca955689a957ecf956bb052f60412da2753a977Andy Walls#define CX18_HW_TVEEPROM (1 << 1) 278ca955689a957ecf956bb052f60412da2753a977Andy Walls#define CX18_HW_CS5345 (1 << 2) 288ca955689a957ecf956bb052f60412da2753a977Andy Walls#define CX18_HW_DVB (1 << 3) 298ca955689a957ecf956bb052f60412da2753a977Andy Walls#define CX18_HW_418_AV (1 << 4) 308ca955689a957ecf956bb052f60412da2753a977Andy Walls#define CX18_HW_GPIO_MUX (1 << 5) 318ca955689a957ecf956bb052f60412da2753a977Andy Walls#define CX18_HW_GPIO_RESET_CTRL (1 << 6) 328ca955689a957ecf956bb052f60412da2753a977Andy Walls#define CX18_HW_Z8F0811_IR_TX_HAUP (1 << 7) 338ca955689a957ecf956bb052f60412da2753a977Andy Walls#define CX18_HW_Z8F0811_IR_RX_HAUP (1 << 8) 348ca955689a957ecf956bb052f60412da2753a977Andy Walls#define CX18_HW_Z8F0811_IR_HAUP (CX18_HW_Z8F0811_IR_RX_HAUP | \ 358ca955689a957ecf956bb052f60412da2753a977Andy Walls CX18_HW_Z8F0811_IR_TX_HAUP) 361c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil 378352619043a04785b8d20e438629b14e556fffceAndy Walls#define CX18_HW_IR_ANY (CX18_HW_Z8F0811_IR_RX_HAUP | \ 388352619043a04785b8d20e438629b14e556fffceAndy Walls CX18_HW_Z8F0811_IR_TX_HAUP) 398352619043a04785b8d20e438629b14e556fffceAndy Walls 401c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil/* video inputs */ 411c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil#define CX18_CARD_INPUT_VID_TUNER 1 421c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil#define CX18_CARD_INPUT_SVIDEO1 2 431c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil#define CX18_CARD_INPUT_SVIDEO2 3 441c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil#define CX18_CARD_INPUT_COMPOSITE1 4 451c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil#define CX18_CARD_INPUT_COMPOSITE2 5 46d9a325a865becc082d592d16a15f01a9684ef82eAndy Walls#define CX18_CARD_INPUT_COMPONENT1 6 471c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil 481c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil/* audio inputs */ 491c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil#define CX18_CARD_INPUT_AUD_TUNER 1 501c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil#define CX18_CARD_INPUT_LINE_IN1 2 511c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil#define CX18_CARD_INPUT_LINE_IN2 3 521c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil 531c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil#define CX18_CARD_MAX_VIDEO_INPUTS 6 541c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil#define CX18_CARD_MAX_AUDIO_INPUTS 3 551c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil#define CX18_CARD_MAX_TUNERS 2 561c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil 571c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil/* V4L2 capability aliases */ 581c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil#define CX18_CAP_ENCODER (V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_TUNER | \ 59af009cf635141858642864a26602e379e97bf7d6Andy Walls V4L2_CAP_AUDIO | V4L2_CAP_READWRITE | \ 60302df9702192a68578916ef922c33370cbba350dAndy Walls V4L2_CAP_VBI_CAPTURE | V4L2_CAP_SLICED_VBI_CAPTURE) 611c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil 621c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuilstruct cx18_card_video_input { 631c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil u8 video_type; /* video input type */ 641c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil u8 audio_index; /* index in cx18_card_audio_input array */ 65d9a325a865becc082d592d16a15f01a9684ef82eAndy Walls u32 video_input; /* hardware video input */ 661c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil}; 671c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil 681c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuilstruct cx18_card_audio_input { 691c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil u8 audio_type; /* audio input type */ 701c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil u32 audio_input; /* hardware audio input */ 711c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil u16 muxer_input; /* hardware muxer input for boards with a 721c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil multiplexer chip */ 731c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil}; 741c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil 751c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuilstruct cx18_card_pci_info { 761c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil u16 device; 771c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil u16 subsystem_vendor; 781c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil u16 subsystem_device; 791c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil}; 801c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil 811c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil/* GPIO definitions */ 821c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil 831c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil/* The mask is the set of bits used by the operation */ 841c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil 851c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuilstruct cx18_gpio_init { /* set initial GPIO DIR and OUT values */ 869dcbf35afb7359466efdf7fb81ee32f3ae2d56a3Hans Verkuil u32 direction; /* DIR setting. Leave to 0 if no init is needed */ 879dcbf35afb7359466efdf7fb81ee32f3ae2d56a3Hans Verkuil u32 initial_value; 881c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil}; 891c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil 901f09e8a25c9aaa4066b4593c1bf99a4cbcc38120Andy Wallsstruct cx18_gpio_i2c_slave_reset { 911f09e8a25c9aaa4066b4593c1bf99a4cbcc38120Andy Walls u32 active_lo_mask; /* GPIO outputs that reset i2c chips when low */ 921f09e8a25c9aaa4066b4593c1bf99a4cbcc38120Andy Walls u32 active_hi_mask; /* GPIO outputs that reset i2c chips when high */ 931f09e8a25c9aaa4066b4593c1bf99a4cbcc38120Andy Walls int msecs_asserted; /* time period reset must remain asserted */ 941f09e8a25c9aaa4066b4593c1bf99a4cbcc38120Andy Walls int msecs_recovery; /* time after deassert for chips to be ready */ 9502fa272fcb6edda9059d6dbaab20dfe919f4f4d2Andy Walls u32 ir_reset_mask; /* GPIO to reset the Zilog Z8F0811 IR contoller */ 961f09e8a25c9aaa4066b4593c1bf99a4cbcc38120Andy Walls}; 971f09e8a25c9aaa4066b4593c1bf99a4cbcc38120Andy Walls 98fdea5d69c1d335a639e39e83990de84e10fb2057Hans Verkuilstruct cx18_gpio_audio_input { /* select tuner/line in input */ 9903c2808503b102971226007070c57410267d0b9dSri Deevi u32 mask; /* leave to 0 if not supported */ 10003c2808503b102971226007070c57410267d0b9dSri Deevi u32 tuner; 10103c2808503b102971226007070c57410267d0b9dSri Deevi u32 linein; 10203c2808503b102971226007070c57410267d0b9dSri Deevi u32 radio; 10303c2808503b102971226007070c57410267d0b9dSri Deevi}; 10403c2808503b102971226007070c57410267d0b9dSri Deevi 1051c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuilstruct cx18_card_tuner { 1061c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil v4l2_std_id std; /* standard for which the tuner is suitable */ 1071c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil int tuner; /* tuner ID (from tuner.h) */ 1081c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil}; 1091c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil 1101c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuilstruct cx18_card_tuner_i2c { 1111c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil unsigned short radio[2];/* radio tuner i2c address to probe */ 1122bfe2fa43eb2122f200e83df7428391f33537ff2Andy Walls unsigned short demod[3];/* demodulator i2c address to probe */ 1131c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil unsigned short tv[4]; /* tv tuner i2c addresses to probe */ 1141c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil}; 1151c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil 1161c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuilstruct cx18_ddr { /* DDR config data */ 1171c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil u32 chip_config; 1181c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil u32 refresh; 1191c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil u32 timing1; 1201c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil u32 timing2; 1211c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil u32 tune_lane; 1221c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil u32 initial_emrs; 1231c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil}; 1241c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil 1251c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil/* for card information/parameters */ 1261c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuilstruct cx18_card { 1271c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil int type; 1281c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil char *name; 1291c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil char *comment; 1301c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil u32 v4l2_capabilities; 1311c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil u32 hw_audio_ctrl; /* hardware used for the V4L2 controls (only 132ff2a20018094c593a35f4887bbdabf8926ddb6e6Andy Walls 1 dev allowed currently) */ 1331c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil u32 hw_muxer; /* hardware used to multiplex audio input */ 1341c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil u32 hw_all; /* all hardware used by the board */ 1351c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil struct cx18_card_video_input video_inputs[CX18_CARD_MAX_VIDEO_INPUTS]; 1361c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil struct cx18_card_audio_input audio_inputs[CX18_CARD_MAX_AUDIO_INPUTS]; 1371c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil struct cx18_card_audio_input radio_input; 1381c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil 1391c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil /* GPIO card-specific settings */ 1409dcbf35afb7359466efdf7fb81ee32f3ae2d56a3Hans Verkuil u8 xceive_pin; /* XCeive tuner GPIO reset pin */ 1411f09e8a25c9aaa4066b4593c1bf99a4cbcc38120Andy Walls struct cx18_gpio_init gpio_init; 1421f09e8a25c9aaa4066b4593c1bf99a4cbcc38120Andy Walls struct cx18_gpio_i2c_slave_reset gpio_i2c_slave_reset; 143fdea5d69c1d335a639e39e83990de84e10fb2057Hans Verkuil struct cx18_gpio_audio_input gpio_audio_input; 1441c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil 1451c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil struct cx18_card_tuner tuners[CX18_CARD_MAX_TUNERS]; 1461c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil struct cx18_card_tuner_i2c *i2c; 1471c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil 1481c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil struct cx18_ddr ddr; 1491c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil 1501c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil /* list of device and subsystem vendor/devices that 1511c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil correspond to this card type. */ 1521c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil const struct cx18_card_pci_info *pci_list; 1531c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil}; 1541c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuil 1551c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuilint cx18_get_input(struct cx18 *cx, u16 index, struct v4l2_input *input); 1561c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuilint cx18_get_audio_input(struct cx18 *cx, u16 index, struct v4l2_audio *input); 1571c1e45d17b663d4749af456ab7c2fc1f36405ef8Hans Verkuilconst struct cx18_card *cx18_get_card(u16 index); 158