From patchwork Tue Jan 10 03:14:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Cheng X-Patchwork-Id: 9506275 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BAD0660710 for ; Tue, 10 Jan 2017 03:14:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A900A28442 for ; Tue, 10 Jan 2017 03:14:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9C2D828540; Tue, 10 Jan 2017 03:14:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 10DB428442 for ; Tue, 10 Jan 2017 03:14:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1031841AbdAJDOd (ORCPT ); Mon, 9 Jan 2017 22:14:33 -0500 Received: from mail-qk0-f193.google.com ([209.85.220.193]:34209 "EHLO mail-qk0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936941AbdAJDOc (ORCPT ); Mon, 9 Jan 2017 22:14:32 -0500 Received: by mail-qk0-f193.google.com with SMTP id e1so18871908qkh.1 for ; Mon, 09 Jan 2017 19:14:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=RJJp62wb7gtrn37z4Ns+8pKS5cTRFB2UlALSMDb+Ohg=; b=NmBfTGHya4xhvlPYqqTxBN762rXwiELpTU0qUu1H8YHNAopcjJ4JvCN+6ZKl4iYb7s G2HzJvzP1bh8j7culwuHwGmKbw4IwUkaKX5H5LS7UvSFbfTsJhkhStil9v1F7KiD228x L7/qOENt6Z5/x5vEuGNv+FjIwy7ZvmFfgSuCeoR4IWLGClPELUpFB7SImh48tH8jSoPy 5dvIU/dYV1af+Q7Z/ocap1L0/jUTWp4EuZOJCXsNVWOA801NCX//E1j5HuwhstBeFYll Z5pTVqb1qRE/rZN+axZFRuWLPSJe0twJCLrORn+AUqN4a+3W2xVY5VzWSQ/QMtfrkfC8 vRGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=RJJp62wb7gtrn37z4Ns+8pKS5cTRFB2UlALSMDb+Ohg=; b=fsTLdIaRbf5IixMz6taiTW++bqTVTOy33FfXJEt8Oo155sn4aeWLutR6xRYn6OX/bx HPeEITigmyHFMWI/Ki3XCQLQU0fxoBKcAeaQO0aaBeDPa3azsqXNv4AovLf3124AHiQc +s1VM9Z77tLb7J7CW/4I2WWumFRK3RiEkvGc6MfB55m6HdNvasVCAWq8UfuJ8XXpf0Ir jBwTpa0KiX17J9FwnEyaTHUiqHCmFpy+GBZklX1DYdNpoC0fyuBQxTsb0rIO0LObP2Yl LrjtDQHOKa9OmHVEP/0VC4Yo8DIHithXRgTORTyUiUFasJvJMCdrtj/nVdGX9B9XjvkY QcoA== X-Gm-Message-State: AIkVDXI8Z9Kv6TzaCvop0VDlC0GNqothK1KJfnxLCUy7GHsLNXvWO5Dzbg9UrcsVgFGa9g== X-Received: by 10.55.163.17 with SMTP id m17mr765094qke.285.1484018071822; Mon, 09 Jan 2017 19:14:31 -0800 (PST) Received: from whisper (cpe-74-71-229-113.nyc.res.rr.com. [74.71.229.113]) by smtp.gmail.com with ESMTPSA id j9sm435174qtc.23.2017.01.09.19.14.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 09 Jan 2017 19:14:31 -0800 (PST) Date: Mon, 9 Jan 2017 22:14:29 -0500 From: Kevin Cheng To: hverkuil@xs4all.nl, linux-media@vger.kernel.org Cc: Linux Media Mailing List Subject: [PATCH v3 2/2] [media] em28xx: support for Hauppauge WinTV-dualHD 01595 ATSC/QAM Message-ID: <20170110031428.vcx2wex3ooxfdjoh@whisper> References: <693918b2-bfbe-9827-a11a-e1f73f4ac019@xs4all.nl> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <693918b2-bfbe-9827-a11a-e1f73f4ac019@xs4all.nl> User-Agent: Mutt/1.6.2-neo (2016-08-21) Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hauppauge WinTV-dualHD model 01595 is a USB 2.0 dual ATSC/QAM tuner with the following components: USB bridge: Empia em28274 Demodulator: 2x LG LGDT3306a at addresses 0xb2 and 0x1c Tuner: 2x Silicon Labs si2157 at addresses 0xc0 and 0xc4 This patch enables only the first tuner. Signed-off-by: Kevin Cheng --- drivers/media/usb/em28xx/em28xx-cards.c | 19 +++++++++ drivers/media/usb/em28xx/em28xx-dvb.c | 74 +++++++++++++++++++++++++++++++++ drivers/media/usb/em28xx/em28xx.h | 1 + 3 files changed, 94 insertions(+) diff --git a/drivers/media/usb/em28xx/em28xx-cards.c b/drivers/media/usb/em28xx/em28xx-cards.c index 23c6749..5f90d08 100644 --- a/drivers/media/usb/em28xx/em28xx-cards.c +++ b/drivers/media/usb/em28xx/em28xx-cards.c @@ -509,6 +509,7 @@ static struct em28xx_reg_seq plex_px_bcud[] = { /* * 2040:0265 Hauppauge WinTV-dualHD DVB + * 2040:026d Hauppauge WinTV-dualHD ATSC/QAM * reg 0x80/0x84: * GPIO_0: Yellow LED tuner 1, 0=on, 1=off * GPIO_1: Green LED tuner 1, 0=on, 1=off @@ -2389,6 +2390,21 @@ struct em28xx_board em28xx_boards[] = { .ir_codes = RC_MAP_HAUPPAUGE, .leds = hauppauge_dualhd_leds, }, + /* + * 2040:026d Hauppauge WinTV-dualHD (model 01595 - ATSC/QAM). + * Empia EM28274, 2x LG LGDT3306A, 2x Silicon Labs Si2157 + */ + [EM28174_BOARD_HAUPPAUGE_WINTV_DUALHD_01595] = { + .name = "Hauppauge WinTV-dualHD 01595 ATSC/QAM", + .def_i2c_bus = 1, + .i2c_speed = EM28XX_I2C_CLK_WAIT_ENABLE | + EM28XX_I2C_FREQ_400_KHZ, + .tuner_type = TUNER_ABSENT, + .tuner_gpio = hauppauge_dualhd_dvb, + .has_dvb = 1, + .ir_codes = RC_MAP_HAUPPAUGE, + .leds = hauppauge_dualhd_leds, + }, }; EXPORT_SYMBOL_GPL(em28xx_boards); @@ -2514,6 +2530,8 @@ struct usb_device_id em28xx_id_table[] = { .driver_info = EM2883_BOARD_HAUPPAUGE_WINTV_HVR_850 }, { USB_DEVICE(0x2040, 0x0265), .driver_info = EM28174_BOARD_HAUPPAUGE_WINTV_DUALHD_DVB }, + { USB_DEVICE(0x2040, 0x026d), + .driver_info = EM28174_BOARD_HAUPPAUGE_WINTV_DUALHD_01595 }, { USB_DEVICE(0x0438, 0xb002), .driver_info = EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600 }, { USB_DEVICE(0x2001, 0xf112), @@ -2945,6 +2963,7 @@ static void em28xx_card_setup(struct em28xx *dev) case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950: case EM2884_BOARD_HAUPPAUGE_WINTV_HVR_930C: case EM28174_BOARD_HAUPPAUGE_WINTV_DUALHD_DVB: + case EM28174_BOARD_HAUPPAUGE_WINTV_DUALHD_01595: { struct tveeprom tv; diff --git a/drivers/media/usb/em28xx/em28xx-dvb.c b/drivers/media/usb/em28xx/em28xx-dvb.c index 75a75da..82edd37 100644 --- a/drivers/media/usb/em28xx/em28xx-dvb.c +++ b/drivers/media/usb/em28xx/em28xx-dvb.c @@ -37,6 +37,7 @@ #include "lgdt330x.h" #include "lgdt3305.h" +#include "lgdt3306a.h" #include "zl10353.h" #include "s5h1409.h" #include "mt2060.h" @@ -920,6 +921,17 @@ static struct tda18271_config pinnacle_80e_dvb_config = { .role = TDA18271_MASTER, }; +static struct lgdt3306a_config hauppauge_01595_lgdt3306a_config = { + .qam_if_khz = 4000, + .vsb_if_khz = 3250, + .spectral_inversion = 0, + .deny_i2c_rptr = 0, + .mpeg_mode = LGDT3306A_MPEG_SERIAL, + .tpclk_edge = LGDT3306A_TPCLK_RISING_EDGE, + .tpvalid_polarity = LGDT3306A_TP_VALID_HIGH, + .xtalMHz = 25, +}; + /* ------------------------------------------------------------------ */ static int em28xx_attach_xc3028(u8 addr, struct em28xx *dev) @@ -1950,6 +1962,68 @@ static int em28xx_dvb_init(struct em28xx *dev) } break; + case EM28174_BOARD_HAUPPAUGE_WINTV_DUALHD_01595: + { + struct i2c_adapter *adapter; + struct i2c_client *client; + struct i2c_board_info info = {}; + struct lgdt3306a_config lgdt3306a_config; + struct si2157_config si2157_config = {}; + + /* attach demod */ + lgdt3306a_config = hauppauge_01595_lgdt3306a_config; + lgdt3306a_config.fe = &dvb->fe[0]; + lgdt3306a_config.i2c_adapter = &adapter; + strlcpy(info.type, "lgdt3306a", sizeof(info.type)); + info.addr = 0x59; + info.platform_data = &lgdt3306a_config; + request_module(info.type); + client = i2c_new_device(&dev->i2c_adap[dev->def_i2c_bus], + &info); + if (client == NULL || client->dev.driver == NULL) { + result = -ENODEV; + goto out_free; + } + + if (!try_module_get(client->dev.driver->owner)) { + i2c_unregister_device(client); + result = -ENODEV; + goto out_free; + } + + dvb->i2c_client_demod = client; + + /* attach tuner */ + si2157_config.fe = dvb->fe[0]; + si2157_config.if_port = 1; + si2157_config.inversion = 1; +#ifdef CONFIG_MEDIA_CONTROLLER_DVB + si2157_config.mdev = dev->media_dev; +#endif + memset(&info, 0, sizeof(struct i2c_board_info)); + strlcpy(info.type, "si2157", sizeof(info.type)); + info.addr = 0x60; + info.platform_data = &si2157_config; + request_module(info.type); + + client = i2c_new_device(adapter, &info); + if (client == NULL || client->dev.driver == NULL) { + module_put(dvb->i2c_client_demod->dev.driver->owner); + i2c_unregister_device(dvb->i2c_client_demod); + result = -ENODEV; + goto out_free; + } + if (!try_module_get(client->dev.driver->owner)) { + i2c_unregister_device(client); + module_put(dvb->i2c_client_demod->dev.driver->owner); + i2c_unregister_device(dvb->i2c_client_demod); + result = -ENODEV; + goto out_free; + } + + dvb->i2c_client_tuner = client; + } + break; default: dev_err(&dev->intf->dev, "The frontend of your DVB/ATSC card isn't supported yet\n"); diff --git a/drivers/media/usb/em28xx/em28xx.h b/drivers/media/usb/em28xx/em28xx.h index ca59e2d..e9f3799 100644 --- a/drivers/media/usb/em28xx/em28xx.h +++ b/drivers/media/usb/em28xx/em28xx.h @@ -147,6 +147,7 @@ #define EM2884_BOARD_ELGATO_EYETV_HYBRID_2008 97 #define EM28178_BOARD_PLEX_PX_BCUD 98 #define EM28174_BOARD_HAUPPAUGE_WINTV_DUALHD_DVB 99 +#define EM28174_BOARD_HAUPPAUGE_WINTV_DUALHD_01595 100 /* Limits minimum and default number of buffers */ #define EM28XX_MIN_BUF 4