From patchwork Tue May 4 22:53:50 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitri Belimov X-Patchwork-Id: 96931 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o44Mopp9007166 for ; Tue, 4 May 2010 22:50:51 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933660Ab0EDWuq (ORCPT ); Tue, 4 May 2010 18:50:46 -0400 Received: from mail-bw0-f225.google.com ([209.85.218.225]:56673 "EHLO mail-bw0-f225.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933589Ab0EDWup (ORCPT ); Tue, 4 May 2010 18:50:45 -0400 Received: by bwz25 with SMTP id 25so2539948bwz.28 for ; Tue, 04 May 2010 15:50:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:subject :message-id:x-mailer:mime-version:content-type; bh=46upyF0J8sjcCBY2RVfcJ9vrdm4LlZwS272HhEBrhz4=; b=DCYdxfL1FEUIuZBwQPuUNn6shuOXGBSEXmrSdKkHZ3+/bOdCNoflAY1dm5JhLcfoBQ 8/SEJm24l4NDe7v842kPE2WjW8oitgEln/DMOYgYeHcf80AF5qjd4JRDDkXKyowU23Od enHdbIryX3vaEt9aDtpOsx0pyZI/NIJCHSeoE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:subject:message-id:x-mailer:mime-version:content-type; b=FLcKRC6fjMbTKKGPQd67orxhE30FsX+CzVXvy+okb36kIpYHon810sQYhwKQcrEHpt uA5dxGXhcRgVfrgLNMwdV8OIAlRrmz9Sj5X/ipWyFLy2vss5SQfdrmRXZyAC83AkscSb QlfyyU8cnLPFzm+BnUxRlT3fTcITKrQHoTOFI= Received: by 10.204.80.36 with SMTP id r36mr5278246bkk.75.1273013443578; Tue, 04 May 2010 15:50:43 -0700 (PDT) Received: from glory.loctelecom.ru (ns2.openhardware.ru [84.19.183.172]) by mx.google.com with ESMTPS id 15sm2194975bwz.4.2010.05.04.15.50.39 (version=SSLv3 cipher=RC4-MD5); Tue, 04 May 2010 15:50:42 -0700 (PDT) Date: Wed, 5 May 2010 08:53:50 +1000 From: Dmitri Belimov To: Linux Media Mailing List , Stefan Ringel , Mauro Carvalho Chehab , Bee Hock Goh Subject: [PATCH] Rework for support xc5000 Message-ID: <20100505085350.1b4f023f@glory.loctelecom.ru> X-Mailer: Claws Mail 3.5.0 (GTK+ 2.16.1; i486-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-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Tue, 04 May 2010 22:50:52 +0000 (UTC) diff --git a/drivers/staging/tm6000/tm6000-cards.c b/drivers/staging/tm6000/tm6000-cards.c index f795a3e..17e3d4c 100644 --- a/drivers/staging/tm6000/tm6000-cards.c +++ b/drivers/staging/tm6000/tm6000-cards.c @@ -231,7 +231,9 @@ struct tm6000_board tm6000_boards[] = { .has_remote = 1, }, .gpio = { - .tuner_reset = TM6000_GPIO_2, + .tuner_reset = TM6010_GPIO_0, + .demod_reset = TM6010_GPIO_1, + .power_led = TM6010_GPIO_6, }, }, [TM6010_BOARD_BEHOLD_VOYAGER] = { @@ -247,7 +249,8 @@ struct tm6000_board tm6000_boards[] = { .has_remote = 1, }, .gpio = { - .tuner_reset = TM6000_GPIO_2, + .tuner_reset = TM6010_GPIO_0, + .power_led = TM6010_GPIO_6, }, }, [TM6010_BOARD_TERRATEC_CINERGY_HYBRID_XE] = { @@ -320,6 +323,31 @@ struct usb_device_id tm6000_id_table [] = { { }, }; +/* Tuner callback to provide the proper gpio changes needed for xc5000 */ +int tm6000_xc5000_callback(void *ptr, int component, int command, int arg) +{ + int rc = 0; + struct tm6000_core *dev = ptr; + + if (dev->tuner_type != TUNER_XC5000) + return 0; + + switch (command) { + case XC5000_TUNER_RESET: + tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN, + dev->gpio.tuner_reset, 0x01); + msleep(15); + tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN, + dev->gpio.tuner_reset, 0x00); + msleep(15); + tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN, + dev->gpio.tuner_reset, 0x01); + break; + } + return (rc); +} + + /* Tuner callback to provide the proper gpio changes needed for xc2028 */ int tm6000_tuner_callback(void *ptr, int component, int command, int arg) @@ -438,6 +466,21 @@ int tm6000_cards_setup(struct tm6000_core *dev) tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN, dev->gpio.demod_on, 0x00); msleep(15); break; + case TM6010_BOARD_BEHOLD_WANDER: + /* Power led on (blue) */ + tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN, dev->gpio.power_led, 0x01); + msleep(15); + /* Reset zarlink zl10353 */ + tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN, dev->gpio.demod_reset, 0x00); + msleep(50); + tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN, dev->gpio.demod_reset, 0x01); + msleep(15); + break; + case TM6010_BOARD_BEHOLD_VOYAGER: + /* Power led on (blue) */ + tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN, dev->gpio.power_led, 0x01); + msleep(15); + break; default: break; } @@ -449,42 +492,38 @@ int tm6000_cards_setup(struct tm6000_core *dev) * If a device uses a different sequence or different GPIO pins for * reset, just add the code at the board-specific part */ - for (i = 0; i < 2; i++) { - rc = tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN, - dev->gpio.tuner_reset, 0x00); - if (rc < 0) { - printk(KERN_ERR "Error %i doing GPIO1 reset\n", rc); - return rc; - } - - msleep(10); /* Just to be conservative */ - rc = tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN, - dev->gpio.tuner_reset, 0x01); - if (rc < 0) { - printk(KERN_ERR "Error %i doing GPIO1 reset\n", rc); - return rc; - } - msleep(10); - rc = tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN, TM6000_GPIO_4, 0); - if (rc < 0) { - printk(KERN_ERR "Error %i doing GPIO4 reset\n", rc); - return rc; - } + if (dev->gpio.tuner_reset) + { + for (i = 0; i < 2; i++) { + rc = tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN, + dev->gpio.tuner_reset, 0x00); + if (rc < 0) { + printk(KERN_ERR "Error %i doing tuner reset\n", rc); + return rc; + } - msleep(10); - rc = tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN, TM6000_GPIO_4, 1); - if (rc < 0) { - printk(KERN_ERR "Error %i doing GPIO4 reset\n", rc); - return rc; - } + msleep(10); /* Just to be conservative */ + rc = tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN, + dev->gpio.tuner_reset, 0x01); + if (rc < 0) { + printk(KERN_ERR "Error %i doing tuner reset\n", rc); + return rc; + } + msleep(10); - if (!i) { - rc = tm6000_get_reg32(dev, REQ_40_GET_VERSION, 0, 0); - if (rc >= 0) - printk(KERN_DEBUG "board=0x%08x\n", rc); + if (!i) { + rc = tm6000_get_reg32(dev, REQ_40_GET_VERSION, 0, 0); + if (rc >= 0) + printk(KERN_DEBUG "board=0x%08x\n", rc); + } } } + else + { + printk(KERN_ERR "Tuner reset is not configured\n"); + return -1; + } msleep(50); @@ -502,12 +541,30 @@ static void tm6000_config_tuner (struct tm6000_core *dev) memset(&tun_setup, 0, sizeof(tun_setup)); tun_setup.type = dev->tuner_type; tun_setup.addr = dev->tuner_addr; - tun_setup.mode_mask = T_ANALOG_TV | T_RADIO | T_DIGITAL_TV; - tun_setup.tuner_callback = tm6000_tuner_callback; + + tun_setup.mode_mask = 0; + if (dev->caps.has_tuner) + tun_setup.mode_mask |= (T_ANALOG_TV | T_RADIO); + if (dev->caps.has_dvb) + tun_setup.mode_mask |= T_DIGITAL_TV; + + switch (dev->tuner_type) + { + case TUNER_XC2028: + tun_setup.tuner_callback = tm6000_tuner_callback;; + break; + case TUNER_XC5000: + tun_setup.tuner_callback = tm6000_xc5000_callback; + break; + } + v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_type_addr, &tun_setup); - if (dev->tuner_type == TUNER_XC2028) { + switch (dev->tuner_type) + { + case TUNER_XC2028: + { struct v4l2_priv_tun_config xc2028_cfg; struct xc2028_ctrl ctl; @@ -537,9 +594,31 @@ static void tm6000_config_tuner (struct tm6000_core *dev) } printk(KERN_INFO "Setting firmware parameters for xc2028\n"); - v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_config, &xc2028_cfg); + + } + break; + case TUNER_XC5000: + { + struct v4l2_priv_tun_config xc5000_cfg; + struct xc5000_config ctl = { + .i2c_address = dev->tuner_addr, + .if_khz = 4570, + .radio_input = XC5000_RADIO_FM1, + }; + + xc5000_cfg.tuner = TUNER_XC5000; + xc5000_cfg.priv = &ctl; + + + v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_config, + &xc5000_cfg); + } + break; + default: + printk(KERN_INFO "Unknown tuner type. Tuner is not configured.\n"); + break; } } diff --git a/drivers/staging/tm6000/tm6000.h b/drivers/staging/tm6000/tm6000.h index 7aeded8..325a2b1 100644 --- a/drivers/staging/tm6000/tm6000.h +++ b/drivers/staging/tm6000/tm6000.h @@ -216,6 +216,7 @@ struct tm6000_fh { /* In tm6000-cards.c */ int tm6000_tuner_callback (void *ptr, int component, int command, int arg); +int tm6000_xc5000_callback (void *ptr, int component, int command, int arg); int tm6000_cards_setup(struct tm6000_core *dev); /* In tm6000-core.c */ Signed-off-by: Beholder Intl. Ltd. Dmitry Belimov