From patchwork Wed Mar 21 15:56:59 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Michael_B=C3=BCsch?= X-Patchwork-Id: 10445 Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from ) id 1SANuQ-0002bI-6Q for patchwork@linuxtv.org; Wed, 21 Mar 2012 16:57:10 +0100 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.75/mailfrontend-3) with esmtp for id 1SANuO-00038N-FS; Wed, 21 Mar 2012 16:57:10 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756071Ab2CUP5G (ORCPT ); Wed, 21 Mar 2012 11:57:06 -0400 Received: from bues.ch ([80.190.117.144]:51834 "EHLO bues.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755916Ab2CUP5E (ORCPT ); Wed, 21 Mar 2012 11:57:04 -0400 Received: by bues.ch with esmtpsa (Exim 4.72) (envelope-from ) id 1SANuJ-0006pl-Cx; Wed, 21 Mar 2012 16:57:03 +0100 Date: Wed, 21 Mar 2012 16:56:59 +0100 From: Michael =?UTF-8?B?QsO8c2No?= To: Hans-Frieder Vogt Cc: linux-media Subject: [PATCH 2/2] Integrate Fitipower fc0011 into af903x Message-ID: <20120321165659.4bc10e78@milhouse> In-Reply-To: <20120321160237.02193470@milhouse> References: <20120321160237.02193470@milhouse> X-Mailer: Claws Mail 3.8.0 (GTK+ 2.24.10; x86_64-pc-linux-gnu) Mime-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-PMX-Version: 5.6.1.2065439, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2012.3.21.154526 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' HTML_00_01 0.05, HTML_00_10 0.05, MIME_LOWER_CASE 0.05, MSGID_ADDED_BY_MTA 0.05, INVALID_MSGID_NO_FQDN 0, __ANY_URI 0, __CP_URI_IN_BODY 0, __CT 0, __CTYPE_HAS_BOUNDARY 0, __CTYPE_MULTIPART 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __HAS_X_MAILING_LIST 0, __MIME_VERSION 0, __SANE_MSGID 0, __SUBJ_ALPHA_END 0, __TO_MALFORMED_2 0, __URI_NO_WWW 0, __URI_NS , __URI_NS_NOANSWER ' This adds fc0011 support to the af903x driver. Signed-off-by: Michael Buesch Index: linux-source-3.2/drivers/media/dvb/dvb-usb/Kconfig =================================================================== --- linux-source-3.2.orig/drivers/media/dvb/dvb-usb/Kconfig 2012-03-20 22:48:14.025859279 +0100 +++ linux-source-3.2/drivers/media/dvb/dvb-usb/Kconfig 2012-03-21 15:31:43.266801632 +0100 @@ -342,6 +342,7 @@ config DVB_USB_AF903X tristate "Afatech AF903X DVB-T USB2.0 support" depends on DVB_USB && EXPERIMENTAL + select MEDIA_TUNER_FC0011 if !MEDIA_TUNER_CUSTOMISE select MEDIA_TUNER_FC0012 if !MEDIA_TUNER_CUSTOMISE select MEDIA_TUNER_MXL5007T if !MEDIA_TUNER_CUSTOMISE help Index: linux-source-3.2/drivers/media/dvb/dvb-usb/af903x-devices.c =================================================================== --- linux-source-3.2.orig/drivers/media/dvb/dvb-usb/af903x-devices.c 2012-03-20 22:48:14.025859279 +0100 +++ linux-source-3.2/drivers/media/dvb/dvb-usb/af903x-devices.c 2012-03-21 15:31:43.270801692 +0100 @@ -260,6 +260,7 @@ } extern struct tuner_desc tuner_af9007; +extern struct tuner_desc tuner_fc0011; extern struct tuner_desc tuner_fc0012; extern struct tuner_desc tuner_mxl5007t; @@ -273,6 +274,9 @@ case TUNER_AF9007: ctx->tuner_desc = &tuner_af9007; break; + case TUNER_FC0011: + ctx->tuner_desc = &tuner_fc0011; + break; case TUNER_FC0012: ctx->tuner_desc = &tuner_fc0012; break; Index: linux-source-3.2/drivers/media/dvb/dvb-usb/af903x-fe.c =================================================================== --- linux-source-3.2.orig/drivers/media/dvb/dvb-usb/af903x-fe.c 2012-03-20 22:48:14.025859279 +0100 +++ linux-source-3.2/drivers/media/dvb/dvb-usb/af903x-fe.c 2012-03-21 15:37:04.968319280 +0100 @@ -28,6 +28,7 @@ #include "af903x-fe.h" #include "af903x-fe-priv.h" #include "dvb_frontend.h" +#include "fc0011.h" #include "fc0012.h" #include "mxl5007t.h" @@ -1967,6 +1968,8 @@ } }; +extern int af903x_fc0011_reset(void *_ctx); + static struct dvb_frontend_ops af903x_ops; struct dvb_frontend *af903x_fe_attach(struct i2c_adapter *i2c_adap, int id, struct af903x_dev_ctx *ctx) @@ -1990,6 +1993,13 @@ switch(ctx->tuner_desc->tunerId) { case TUNER_AF9007: break; + case TUNER_FC0011: + ret = dvb_attach(fc0011_attach, frontend, i2c_adap, + id == 0 ? ctx->tuner_desc->tuner_addr : + ctx->tuner_desc->tuner_addr + 1, + af903x_fc0011_reset, ctx) + == NULL ? -ENODEV : 0; + break; case TUNER_FC0012: ret = dvb_attach(fc0012_attach, frontend, i2c_adap, id == 0 ? ctx->tuner_desc->tuner_addr : Index: linux-source-3.2/drivers/media/dvb/dvb-usb/af903x-tuners.c =================================================================== --- linux-source-3.2.orig/drivers/media/dvb/dvb-usb/af903x-tuners.c 2012-03-20 22:48:14.025859279 +0100 +++ linux-source-3.2/drivers/media/dvb/dvb-usb/af903x-tuners.c 2012-03-21 15:42:42.214115654 +0100 @@ -189,6 +189,69 @@ {0xf1e6, 0x00}, }; +static u16 fc0011_script_sets[] = { + 0x38, +}; + +static struct af903x_val_set fc0011_scripts[] = { + {0x0046, 0x28}, /* TUNER_ID */ + {0x0057, 0x00}, + {0x0058, 0x01}, + {0x005f, 0x00}, + {0x0060, 0x00}, + {0x0068, 0xa5}, + {0x006e, 0x01}, + {0x0071, 0x0A}, + {0x0072, 0x02}, + {0x0074, 0x01}, + {0x0079, 0x01}, + {0x0093, 0x00}, + {0x0094, 0x00}, + {0x0095, 0x00}, + {0x0096, 0x00}, + {0x009b, 0x2D}, + {0x009c, 0x60}, + {0x009d, 0x23}, + {0x00a4, 0x50}, + {0x00ad, 0x50}, + {0x00b3, 0x01}, + {0x00b7, 0x88}, + {0x00b8, 0xa6}, + {0x00c3, 0x01}, + {0x00c4, 0x01}, + {0x00c7, 0x69}, + {0xF007, 0x00}, + {0xF00A, 0x1B}, + {0xF00B, 0x1B}, + {0xF00C, 0x1B}, + {0xF00D, 0x1B}, + {0xF00E, 0xFF}, + {0xF00F, 0x01}, + {0xF010, 0x00}, + {0xF011, 0x02}, + {0xF012, 0xFF}, + {0xF013, 0x01}, + {0xF014, 0x00}, + {0xF015, 0x02}, + {0xF01B, 0xEF}, + {0xF01C, 0x01}, + {0xF01D, 0x0f}, + {0xF01E, 0x02}, + {0xF01F, 0x6E}, + {0xF020, 0x00}, + {0xF025, 0xDE}, + {0xF026, 0x00}, + {0xF027, 0x0A}, + {0xF028, 0x03}, + {0xF029, 0x6E}, + {0xF02A, 0x00}, + {0xF047, 0x00}, + {0xF054, 0x0}, + {0xF055, 0x0}, + {0xF077, 0x01}, + {0xF1E6, 0x00}, +}; + static int af903x_fc0012_init(struct af903x_dev_ctx *ctx, int chip) { int ret; @@ -338,6 +401,43 @@ TUNER_FC0012, }; +int af903x_fc0011_reset(void *_ctx) +{ + struct af903x_dev_ctx *ctx = _ctx; + struct usb_device *udev = ctx->udev; + int ret; + + ret = af9035_wr_reg(udev, 0, PRO_LINK, GPIOT3_ON, 1); + if (ret < 0) + return ret; + ret = af9035_wr_reg(udev, 0, PRO_LINK, GPIOT3_EN, 1); + if (ret < 0) + return ret; + ret = af9035_wr_reg(udev, 0, PRO_LINK, GPIOT3_O, 1); + if (ret < 0) + return ret; + msleep(10); + ret = af9035_wr_reg(udev, 0, PRO_LINK, GPIOT3_O, 0); + if (ret < 0) + return ret; + msleep(10); + + return 0; +} + +struct tuner_desc tuner_fc0011 = { + af903x_fc0012_init, + af903x_fc0012_sleep, + af903x_fc0012_set, + fc0011_scripts, + fc0011_script_sets, + 0xc0, + 1, + 0, + true, + TUNER_FC0011, +}; + static u16 mxl5007t_script_sets[] = { 0x1e };