162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * cx18 functions to query card hardware 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * Derived from ivtv-cards.c 662306a36Sopenharmony_ci * 762306a36Sopenharmony_ci * Copyright (C) 2007 Hans Verkuil <hverkuil@xs4all.nl> 862306a36Sopenharmony_ci * Copyright (C) 2008 Andy Walls <awalls@md.metrocast.net> 962306a36Sopenharmony_ci */ 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ci/* hardware flags */ 1262306a36Sopenharmony_ci#define CX18_HW_TUNER (1 << 0) 1362306a36Sopenharmony_ci#define CX18_HW_TVEEPROM (1 << 1) 1462306a36Sopenharmony_ci#define CX18_HW_CS5345 (1 << 2) 1562306a36Sopenharmony_ci#define CX18_HW_DVB (1 << 3) 1662306a36Sopenharmony_ci#define CX18_HW_418_AV (1 << 4) 1762306a36Sopenharmony_ci#define CX18_HW_GPIO_MUX (1 << 5) 1862306a36Sopenharmony_ci#define CX18_HW_GPIO_RESET_CTRL (1 << 6) 1962306a36Sopenharmony_ci#define CX18_HW_Z8F0811_IR_HAUP (1 << 7) 2062306a36Sopenharmony_ci 2162306a36Sopenharmony_ci/* video inputs */ 2262306a36Sopenharmony_ci#define CX18_CARD_INPUT_VID_TUNER 1 2362306a36Sopenharmony_ci#define CX18_CARD_INPUT_SVIDEO1 2 2462306a36Sopenharmony_ci#define CX18_CARD_INPUT_SVIDEO2 3 2562306a36Sopenharmony_ci#define CX18_CARD_INPUT_COMPOSITE1 4 2662306a36Sopenharmony_ci#define CX18_CARD_INPUT_COMPOSITE2 5 2762306a36Sopenharmony_ci#define CX18_CARD_INPUT_COMPONENT1 6 2862306a36Sopenharmony_ci 2962306a36Sopenharmony_ci/* audio inputs */ 3062306a36Sopenharmony_ci#define CX18_CARD_INPUT_AUD_TUNER 1 3162306a36Sopenharmony_ci#define CX18_CARD_INPUT_LINE_IN1 2 3262306a36Sopenharmony_ci#define CX18_CARD_INPUT_LINE_IN2 3 3362306a36Sopenharmony_ci 3462306a36Sopenharmony_ci#define CX18_CARD_MAX_VIDEO_INPUTS 6 3562306a36Sopenharmony_ci#define CX18_CARD_MAX_AUDIO_INPUTS 3 3662306a36Sopenharmony_ci#define CX18_CARD_MAX_TUNERS 2 3762306a36Sopenharmony_ci 3862306a36Sopenharmony_ci/* V4L2 capability aliases */ 3962306a36Sopenharmony_ci#define CX18_CAP_ENCODER (V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_TUNER | \ 4062306a36Sopenharmony_ci V4L2_CAP_AUDIO | V4L2_CAP_READWRITE | \ 4162306a36Sopenharmony_ci V4L2_CAP_STREAMING | V4L2_CAP_VBI_CAPTURE | \ 4262306a36Sopenharmony_ci V4L2_CAP_SLICED_VBI_CAPTURE) 4362306a36Sopenharmony_ci 4462306a36Sopenharmony_cistruct cx18_card_video_input { 4562306a36Sopenharmony_ci u8 video_type; /* video input type */ 4662306a36Sopenharmony_ci u8 audio_index; /* index in cx18_card_audio_input array */ 4762306a36Sopenharmony_ci u32 video_input; /* hardware video input */ 4862306a36Sopenharmony_ci}; 4962306a36Sopenharmony_ci 5062306a36Sopenharmony_cistruct cx18_card_audio_input { 5162306a36Sopenharmony_ci u8 audio_type; /* audio input type */ 5262306a36Sopenharmony_ci u32 audio_input; /* hardware audio input */ 5362306a36Sopenharmony_ci u16 muxer_input; /* hardware muxer input for boards with a 5462306a36Sopenharmony_ci multiplexer chip */ 5562306a36Sopenharmony_ci}; 5662306a36Sopenharmony_ci 5762306a36Sopenharmony_cistruct cx18_card_pci_info { 5862306a36Sopenharmony_ci u16 device; 5962306a36Sopenharmony_ci u16 subsystem_vendor; 6062306a36Sopenharmony_ci u16 subsystem_device; 6162306a36Sopenharmony_ci}; 6262306a36Sopenharmony_ci 6362306a36Sopenharmony_ci/* GPIO definitions */ 6462306a36Sopenharmony_ci 6562306a36Sopenharmony_ci/* The mask is the set of bits used by the operation */ 6662306a36Sopenharmony_ci 6762306a36Sopenharmony_cistruct cx18_gpio_init { /* set initial GPIO DIR and OUT values */ 6862306a36Sopenharmony_ci u32 direction; /* DIR setting. Leave to 0 if no init is needed */ 6962306a36Sopenharmony_ci u32 initial_value; 7062306a36Sopenharmony_ci}; 7162306a36Sopenharmony_ci 7262306a36Sopenharmony_cistruct cx18_gpio_i2c_slave_reset { 7362306a36Sopenharmony_ci u32 active_lo_mask; /* GPIO outputs that reset i2c chips when low */ 7462306a36Sopenharmony_ci u32 active_hi_mask; /* GPIO outputs that reset i2c chips when high */ 7562306a36Sopenharmony_ci int msecs_asserted; /* time period reset must remain asserted */ 7662306a36Sopenharmony_ci int msecs_recovery; /* time after deassert for chips to be ready */ 7762306a36Sopenharmony_ci u32 ir_reset_mask; /* GPIO to reset the Zilog Z8F0811 IR controller */ 7862306a36Sopenharmony_ci}; 7962306a36Sopenharmony_ci 8062306a36Sopenharmony_cistruct cx18_gpio_audio_input { /* select tuner/line in input */ 8162306a36Sopenharmony_ci u32 mask; /* leave to 0 if not supported */ 8262306a36Sopenharmony_ci u32 tuner; 8362306a36Sopenharmony_ci u32 linein; 8462306a36Sopenharmony_ci u32 radio; 8562306a36Sopenharmony_ci}; 8662306a36Sopenharmony_ci 8762306a36Sopenharmony_cistruct cx18_card_tuner { 8862306a36Sopenharmony_ci v4l2_std_id std; /* standard for which the tuner is suitable */ 8962306a36Sopenharmony_ci int tuner; /* tuner ID (from tuner.h) */ 9062306a36Sopenharmony_ci}; 9162306a36Sopenharmony_ci 9262306a36Sopenharmony_cistruct cx18_card_tuner_i2c { 9362306a36Sopenharmony_ci unsigned short radio[2];/* radio tuner i2c address to probe */ 9462306a36Sopenharmony_ci unsigned short demod[3];/* demodulator i2c address to probe */ 9562306a36Sopenharmony_ci unsigned short tv[4]; /* tv tuner i2c addresses to probe */ 9662306a36Sopenharmony_ci}; 9762306a36Sopenharmony_ci 9862306a36Sopenharmony_cistruct cx18_ddr { /* DDR config data */ 9962306a36Sopenharmony_ci u32 chip_config; 10062306a36Sopenharmony_ci u32 refresh; 10162306a36Sopenharmony_ci u32 timing1; 10262306a36Sopenharmony_ci u32 timing2; 10362306a36Sopenharmony_ci u32 tune_lane; 10462306a36Sopenharmony_ci u32 initial_emrs; 10562306a36Sopenharmony_ci}; 10662306a36Sopenharmony_ci 10762306a36Sopenharmony_ci/* for card information/parameters */ 10862306a36Sopenharmony_cistruct cx18_card { 10962306a36Sopenharmony_ci int type; 11062306a36Sopenharmony_ci char *name; 11162306a36Sopenharmony_ci char *comment; 11262306a36Sopenharmony_ci u32 v4l2_capabilities; 11362306a36Sopenharmony_ci u32 hw_audio_ctrl; /* hardware used for the V4L2 controls (only 11462306a36Sopenharmony_ci 1 dev allowed currently) */ 11562306a36Sopenharmony_ci u32 hw_muxer; /* hardware used to multiplex audio input */ 11662306a36Sopenharmony_ci u32 hw_all; /* all hardware used by the board */ 11762306a36Sopenharmony_ci struct cx18_card_video_input video_inputs[CX18_CARD_MAX_VIDEO_INPUTS]; 11862306a36Sopenharmony_ci struct cx18_card_audio_input audio_inputs[CX18_CARD_MAX_AUDIO_INPUTS]; 11962306a36Sopenharmony_ci struct cx18_card_audio_input radio_input; 12062306a36Sopenharmony_ci 12162306a36Sopenharmony_ci /* GPIO card-specific settings */ 12262306a36Sopenharmony_ci u8 xceive_pin; /* XCeive tuner GPIO reset pin */ 12362306a36Sopenharmony_ci struct cx18_gpio_init gpio_init; 12462306a36Sopenharmony_ci struct cx18_gpio_i2c_slave_reset gpio_i2c_slave_reset; 12562306a36Sopenharmony_ci struct cx18_gpio_audio_input gpio_audio_input; 12662306a36Sopenharmony_ci 12762306a36Sopenharmony_ci struct cx18_card_tuner tuners[CX18_CARD_MAX_TUNERS]; 12862306a36Sopenharmony_ci struct cx18_card_tuner_i2c *i2c; 12962306a36Sopenharmony_ci 13062306a36Sopenharmony_ci struct cx18_ddr ddr; 13162306a36Sopenharmony_ci 13262306a36Sopenharmony_ci /* list of device and subsystem vendor/devices that 13362306a36Sopenharmony_ci correspond to this card type. */ 13462306a36Sopenharmony_ci const struct cx18_card_pci_info *pci_list; 13562306a36Sopenharmony_ci}; 13662306a36Sopenharmony_ci 13762306a36Sopenharmony_ciint cx18_get_input(struct cx18 *cx, u16 index, struct v4l2_input *input); 13862306a36Sopenharmony_ciint cx18_get_audio_input(struct cx18 *cx, u16 index, struct v4l2_audio *input); 13962306a36Sopenharmony_ciconst struct cx18_card *cx18_get_card(u16 index); 140