// SPDX-License-Identifier: GPL-2.0-or-later /* gpio functions. Merging GPIO support into driver: Copyright (C) 2004 Chris Kennedy <[email protected]> Copyright (C) 2005-2007 Hans Verkuil <[email protected]> */ #include "ivtv-driver.h" #include "ivtv-cards.h" #include "ivtv-gpio.h" #include "xc2028.h" #include <media/tuner.h> #include <media/v4l2-ctrls.h> /* * GPIO assignment of Yuan MPG600/MPG160 * * bit 15 14 13 12 | 11 10 9 8 | 7 6 5 4 | 3 2 1 0 * OUTPUT IN1 IN0 AM3 AM2 AM1 AM0 * INPUT DM1 DM0 * * IN* : Input selection * IN1 IN0 * 1 1 N/A * 1 0 Line * 0 1 N/A * 0 0 Tuner * * AM* : Audio Mode * AM3 0: Normal 1: Mixed(Sub+Main channel) * AM2 0: Subchannel 1: Main channel * AM1 0: Stereo 1: Mono * AM0 0: Normal 1: Mute * * DM* : Detected tuner audio Mode * DM1 0: Stereo 1: Mono * DM0 0: Multiplex 1: Normal * * GPIO Initial Settings * MPG600 MPG160 * DIR 0x3080 0x7080 * OUTPUT 0x000C 0x400C * * Special thanks to Makoto Iguchi <[email protected]> and Mr. Anonymous * for analyzing GPIO of MPG160. * ***************************************************************************** * * GPIO assignment of Avermedia M179 (per information direct from AVerMedia) * * bit 15 14 13 12 | 11 10 9 8 | 7 6 5 4 | 3 2 1 0 * OUTPUT IN0 AM0 IN1 AM1 AM2 IN2 BR0 BR1 * INPUT * * IN* : Input selection * IN0 IN1 IN2 * * 1 * Mute * 0 0 0 Line-In * 1 0 0 TV Tuner Audio * 0 0 1 FM Audio * 1 0 1 Mute * * AM* : Audio Mode * AM0 AM1 AM2 * 0 0 0 TV Tuner Audio: L_OUT=(L+R)/2, R_OUT=SAP * 0 0 1 TV Tuner Audio: L_OUT=R_OUT=SAP (SAP) * 0 1 0 TV Tuner Audio: L_OUT=L, R_OUT=R (stereo) * 0 1 1 TV Tuner Audio: mute * 1 * * TV Tuner Audio: L_OUT=R_OUT=(L+R)/2 (mono) * * BR* : Audio Sample Rate (BR stands for bitrate for some reason) * BR0 BR1 * 0 0 32 kHz * 0 1 44.1 kHz * 1 0 48 kHz * * DM* : Detected tuner audio Mode * Unknown currently * * Special thanks to AVerMedia Technologies, Inc. and Jiun-Kuei Jung at * AVerMedia for providing the GPIO information used to add support * for the M179 cards. */ /********************* GPIO stuffs *********************/ /* GPIO registers */ #define IVTV_REG_GPIO_IN … #define IVTV_REG_GPIO_OUT … #define IVTV_REG_GPIO_DIR … void ivtv_reset_ir_gpio(struct ivtv *itv) { … } /* Xceive tuner reset function */ int ivtv_reset_tuner_gpio(void *dev, int component, int cmd, int value) { … } static inline struct ivtv *sd_to_ivtv(struct v4l2_subdev *sd) { … } static inline struct v4l2_subdev *to_sd(struct v4l2_ctrl *ctrl) { … } static int subdev_s_clock_freq(struct v4l2_subdev *sd, u32 freq) { … } static int subdev_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt) { … } static int subdev_s_tuner(struct v4l2_subdev *sd, const struct v4l2_tuner *vt) { … } static int subdev_s_radio(struct v4l2_subdev *sd) { … } static int subdev_s_audio_routing(struct v4l2_subdev *sd, u32 input, u32 output, u32 config) { … } static int subdev_s_ctrl(struct v4l2_ctrl *ctrl) { … } static int subdev_log_status(struct v4l2_subdev *sd) { … } static int subdev_s_video_routing(struct v4l2_subdev *sd, u32 input, u32 output, u32 config) { … } static const struct v4l2_ctrl_ops gpio_ctrl_ops = …; static const struct v4l2_subdev_core_ops subdev_core_ops = …; static const struct v4l2_subdev_tuner_ops subdev_tuner_ops = …; static const struct v4l2_subdev_audio_ops subdev_audio_ops = …; static const struct v4l2_subdev_video_ops subdev_video_ops = …; static const struct v4l2_subdev_ops subdev_ops = …; int ivtv_gpio_init(struct ivtv *itv) { … }