Re: [PATCH 2/4] media: em28xx: Add support for MyGica UTV3

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 03/02/2024 13:47, Nils Rothaug wrote:
> The MyGica UTV3 Analog USB2.0 TV Box is a USB video capture card
> that has analog TV, composite video, and FM radio inputs, an IR
> remote, and provides audio only as Line Out, but not over USB.
> Mine is prepared for an FM tuner, but not equipped with one.
> Support for FM radio is therefore missing. The device contains:
>  - Empia EM2860 USB bridge
>  - Philips SAA7113 video decoder
>  - NXP TDA9801T demodulator
>  - Tena TNF931D-DFDR1 tuner
>  - ST HCF4052 demux, switches input audio to Line Out
> 
> Signed-off-by: Nils Rothaug <nils.rothaug@xxxxxx>
> ---
>  drivers/media/rc/keymaps/Makefile         |  1 +
>  drivers/media/rc/keymaps/rc-mygica-utv3.c | 69 +++++++++++++++++++++++

Split off the rc changes into a separate patch. Those patches are independent of
the em28xx changes. Also, the rc changes are reviewed by Sean Young, not me, so
it is much easier to review if this is in a patch of its own.

Regards,

	Hans

>  drivers/media/usb/em28xx/em28xx-cards.c   | 52 +++++++++++++++++
>  drivers/media/usb/em28xx/em28xx.h         |  1 +
>  include/media/rc-map.h                    |  1 +
>  5 files changed, 124 insertions(+)
>  create mode 100644 drivers/media/rc/keymaps/rc-mygica-utv3.c
> 
> diff --git a/drivers/media/rc/keymaps/Makefile b/drivers/media/rc/keymaps/Makefile
> index f19558fdab0..7fdf0d9edbf 100644
> --- a/drivers/media/rc/keymaps/Makefile
> +++ b/drivers/media/rc/keymaps/Makefile
> @@ -84,6 +84,7 @@ obj-$(CONFIG_RC_MAP) += \
>  			rc-msi-digivox-ii.o \
>  			rc-msi-tvanywhere.o \
>  			rc-msi-tvanywhere-plus.o \
> +			rc-mygica-utv3.o \
>  			rc-nebula.o \
>  			rc-nec-terratec-cinergy-xs.o \
>  			rc-norwood.o \
> diff --git a/drivers/media/rc/keymaps/rc-mygica-utv3.c b/drivers/media/rc/keymaps/rc-mygica-utv3.c
> new file mode 100644
> index 00000000000..f32b8281459
> --- /dev/null
> +++ b/drivers/media/rc/keymaps/rc-mygica-utv3.c
> @@ -0,0 +1,69 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/* rc-mygica-utv3.c - Keytable for the MyGica UTV3 Analog USB2.0 TV Box
> + *
> + * Copyright (c) 2024 by Nils Rothaug
> + */
> +
> +#include <media/rc-map.h>
> +#include <linux/module.h>
> +
> +static struct rc_map_table mygica_utv3[] = {
> +	{ 0x0d, KEY_MUTE },
> +	{ 0x38, KEY_VIDEO },  /* Source */
> +	{ 0x14, KEY_RADIO },  /* FM Radio */
> +	{ 0x0c, KEY_POWER2 },
> +
> +	{ 0x01, KEY_NUMERIC_1},
> +	{ 0x02, KEY_NUMERIC_2},
> +	{ 0x03, KEY_NUMERIC_3},
> +	{ 0x04, KEY_NUMERIC_4},
> +	{ 0x05, KEY_NUMERIC_5},
> +	{ 0x06, KEY_NUMERIC_6},
> +	{ 0x07, KEY_NUMERIC_7},
> +	{ 0x08, KEY_NUMERIC_8},
> +	{ 0x09, KEY_NUMERIC_9},
> +	{ 0x00, KEY_NUMERIC_0},
> +
> +	{ 0x0a, KEY_DIGITS }, /* Single/double/triple digit */
> +	{ 0x0e, KEY_CAMERA }, /* Snapshot */
> +	{ 0x0f, KEY_ZOOM },   /* Full Screen */
> +	{ 0x29, KEY_LAST },   /* Recall (return to previous channel) */
> +
> +	{ 0x17, KEY_PLAY },
> +	{ 0x1f, KEY_RECORD },
> +	{ 0x0b, KEY_STOP },
> +	{ 0x16, KEY_PAUSE },
> +
> +	{ 0x20, KEY_CHANNELUP },
> +	{ 0x21, KEY_CHANNELDOWN },
> +	{ 0x10, KEY_VOLUMEUP },
> +	{ 0x11, KEY_VOLUMEDOWN },
> +	{ 0x26, KEY_REWIND },
> +	{ 0x27, KEY_FASTFORWARD },
> +};
> +
> +static struct rc_map_list mygica_utv3_map = {
> +	.map = {
> +		.scan     = mygica_utv3,
> +		.size     = ARRAY_SIZE(mygica_utv3),
> +		.rc_proto = RC_PROTO_RC5,
> +		.name     = RC_MAP_MYGICA_UTV3,
> +	}
> +};
> +
> +static int __init init_rc_map_mygica_utv3(void)
> +{
> +	return rc_map_register(&mygica_utv3_map);
> +}
> +
> +static void __exit exit_rc_map_mygica_utv3(void)
> +{
> +	rc_map_unregister(&mygica_utv3_map);
> +}
> +
> +module_init(init_rc_map_mygica_utv3)
> +module_exit(exit_rc_map_mygica_utv3)
> +
> +MODULE_LICENSE("GPL");
> +MODULE_AUTHOR("Nils Rothaug");
> +MODULE_DESCRIPTION("MyGica UTV3 Analog USB2.0 TV Box remote keytable");
> diff --git a/drivers/media/usb/em28xx/em28xx-cards.c b/drivers/media/usb/em28xx/em28xx-cards.c
> index 4d037c92af7..2c53063d69c 100644
> --- a/drivers/media/usb/em28xx/em28xx-cards.c
> +++ b/drivers/media/usb/em28xx/em28xx-cards.c
> @@ -554,6 +554,30 @@ static struct em28xx_reg_seq hauppauge_usb_quadhd_atsc_reg_seq[] = {
>  	{-1,                           -1,   -1,       -1},
>  };
> 
> +/*
> + * MyGica USB TV Box
> + * GPIO_1,0: 00=Composite audio
> + *           01=Tuner audio
> + *           10=Mute audio
> + *           11=FM radio? (if equipped)
> + * GPIO_2-6: Unused
> + * GPIO_7:   ??
> + */
> +static const struct em28xx_reg_seq mygica_utv3_composite_audio_gpio[] = {
> +	{EM2820_R08_GPIO_CTRL, 0xfc, 0xff, 0},
> +	{ -1, -1, -1, -1},
> +};
> +
> +static const struct em28xx_reg_seq mygica_utv3_tuner_audio_gpio[] = {
> +	{EM2820_R08_GPIO_CTRL, 0xfd, 0xff, 0},
> +	{ -1, -1, -1, -1},
> +};
> +
> +static const struct em28xx_reg_seq mygica_utv3_suspend_gpio[] = {
> +	{EM2820_R08_GPIO_CTRL, 0xfe, 0xff, 0},
> +	{ -1, -1, -1, -1},
> +};
> +
>  /*
>   *  Button definitions
>   */
> @@ -2578,6 +2602,32 @@ const struct em28xx_board em28xx_boards[] = {
>  		.tuner_gpio    = hauppauge_usb_quadhd_atsc_reg_seq,
>  		.leds          = hauppauge_usb_quadhd_leds,
>  	},
> +	/*
> +	 * eb1a:2860 MyGica UTV3 Analog USB2.0 TV Box
> +	 * Empia EM2860, Philips SAA7113, NXP TDA9801T demod,
> +	 * Tena TNF931D-DFDR1 tuner (contains NXP TDA6509A),
> +	 * ST HCF4052 demux (switches audio to line out),
> +	 * no audio over USB
> +	 */
> +	[EM2860_BOARD_MYGICA_UTV3] = {
> +		.name         = "MyGica UTV3 Analog USB2.0 TV Box",
> +		.xclk		  = EM28XX_XCLK_IR_RC5_MODE | EM28XX_XCLK_FREQUENCY_12MHZ,
> +		.tuner_type   = TUNER_TENA_TNF_931D_DFDR1,
> +		.ir_codes     = RC_MAP_MYGICA_UTV3,
> +		.decoder      = EM28XX_SAA711X,
> +		.suspend_gpio = mygica_utv3_suspend_gpio,
> +		.input        = { {
> +			.type     = EM28XX_VMUX_COMPOSITE,
> +			.vmux     = SAA7115_COMPOSITE0,
> +			.amux     = EM28XX_AMUX_VIDEO,
> +			.gpio     = mygica_utv3_composite_audio_gpio,
> +		}, {
> +			.type     = EM28XX_VMUX_TELEVISION,
> +			.vmux     = SAA7115_COMPOSITE2,
> +			.amux     = EM28XX_AMUX_VIDEO,
> +			.gpio     = mygica_utv3_tuner_audio_gpio,
> +		} },
> +	},
>  };
>  EXPORT_SYMBOL_GPL(em28xx_boards);
> 
> @@ -2819,6 +2869,7 @@ static const struct em28xx_hash_table em28xx_eeprom_hash[] = {
>  	{0x63f653bd, EM2870_BOARD_REDDO_DVB_C_USB_BOX, TUNER_ABSENT},
>  	{0x4e913442, EM2882_BOARD_DIKOM_DK300, TUNER_XC2028},
>  	{0x85dd871e, EM2882_BOARD_ZOLID_HYBRID_TV_STICK, TUNER_XC2028},
> +	{0x8f597549, EM2860_BOARD_MYGICA_UTV3, TUNER_TENA_TNF_931D_DFDR1},
>  };
> 
>  /* I2C devicelist hash table for devices with generic USB IDs */
> @@ -2831,6 +2882,7 @@ static const struct em28xx_hash_table em28xx_i2c_hash[] = {
>  	{0x4ba50080, EM2861_BOARD_GADMEI_UTV330PLUS, TUNER_TNF_5335MF},
>  	{0x6b800080, EM2874_BOARD_LEADERSHIP_ISDBT, TUNER_ABSENT},
>  	{0x27e10080, EM2882_BOARD_ZOLID_HYBRID_TV_STICK, TUNER_XC2028},
> +	{0x840d0484, EM2860_BOARD_MYGICA_UTV3, TUNER_TENA_TNF_931D_DFDR1},
>  };
> 
>  /* NOTE: introduce a separate hash table for devices with 16 bit eeproms */
> diff --git a/drivers/media/usb/em28xx/em28xx.h b/drivers/media/usb/em28xx/em28xx.h
> index db18dd814a6..f3449c240d2 100644
> --- a/drivers/media/usb/em28xx/em28xx.h
> +++ b/drivers/media/usb/em28xx/em28xx.h
> @@ -143,6 +143,7 @@
>  #define EM28178_BOARD_PCTV_461E_V2                104
>  #define EM2860_BOARD_MYGICA_IGRABBER              105
>  #define EM2874_BOARD_HAUPPAUGE_USB_QUADHD         106
> +#define EM2860_BOARD_MYGICA_UTV3                  107
> 
>  /* Limits minimum and default number of buffers */
>  #define EM28XX_MIN_BUF 4
> diff --git a/include/media/rc-map.h b/include/media/rc-map.h
> index 4676545ffd8..4867eb2f931 100644
> --- a/include/media/rc-map.h
> +++ b/include/media/rc-map.h
> @@ -290,6 +290,7 @@ struct rc_map *rc_map_get(const char *name);
>  #define RC_MAP_MSI_DIGIVOX_III           "rc-msi-digivox-iii"
>  #define RC_MAP_MSI_TVANYWHERE            "rc-msi-tvanywhere"
>  #define RC_MAP_MSI_TVANYWHERE_PLUS       "rc-msi-tvanywhere-plus"
> +#define RC_MAP_MYGICA_UTV3               "rc-mygica-utv3"
>  #define RC_MAP_NEBULA                    "rc-nebula"
>  #define RC_MAP_NEC_TERRATEC_CINERGY_XS   "rc-nec-terratec-cinergy-xs"
>  #define RC_MAP_NORWOOD                   "rc-norwood"
> --
> 2.34.1
> 
> 





[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux