From patchwork Tue Jul 23 22:31:45 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Lee X-Patchwork-Id: 2832265 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 17669C0319 for ; Tue, 23 Jul 2013 22:32:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B93DF203E6 for ; Tue, 23 Jul 2013 22:32:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 58E4B203DD for ; Tue, 23 Jul 2013 22:32:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934382Ab3GWWb4 (ORCPT ); Tue, 23 Jul 2013 18:31:56 -0400 Received: from mail-pb0-f41.google.com ([209.85.160.41]:40835 "EHLO mail-pb0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934091Ab3GWWby (ORCPT ); Tue, 23 Jul 2013 18:31:54 -0400 Received: by mail-pb0-f41.google.com with SMTP id rp16so9003081pbb.14 for ; Tue, 23 Jul 2013 15:31:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer; bh=pOfKp0yrjvvrM1HtXFQG7lWyPcqHQo5tThEJvdMchZI=; b=XyfSip6ci6DO015MJbuXm+Dx57JlahDgnkGsXi+jmqFnu55CRiCsQjmCZHCqUwCqWf 3VXVGkAYGGZ73vBl+73Xmdah4AOZ4BXb1KYRMPFwagzUPHBdbomUjH3c4dfD5lEV5Jsi hYC0hw1l3fNbqkoACMTFwMFffKEjZG+zzvG6ZoHIe8Yxnd1X447ZWYYT0pQrGl4aHrmA Qr5f9wEqwy0wIWZbZ1FZDLpirgvxwFX2QQkwr/CZaVKmKjeWrDsQFkVKvpBK/4y8Ph4n O9Cm+im4FNtapm5SnTBxlYEyZz81ZAP7OInktGcnAc4N/RSlV8DcyDYExQAfy314Yadn EmZg== X-Received: by 10.66.164.71 with SMTP id yo7mr40399865pab.92.1374618713376; Tue, 23 Jul 2013 15:31:53 -0700 (PDT) Received: from dvb.updatelee.net (S0106c0c1c01263ff.ed.shawcable.net. [68.148.74.18]) by mx.google.com with ESMTPSA id ie3sm43927598pbc.13.2013.07.23.15.31.52 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 23 Jul 2013 15:31:52 -0700 (PDT) From: Chris Lee To: linux-media@vger.kernel.org Cc: Chris Lee Subject: [PATCH] gp8psk: add DSS/DCII tuning, fix turbofec fec values, add returning actual tuned values after lock Date: Tue, 23 Jul 2013 16:31:45 -0600 Message-Id: <1374618705-5155-1-git-send-email-updatelee@gmail.com> X-Mailer: git-send-email 1.8.1.2 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Revised patch, I seperated the DCII systems into their correct DCII system and 4x different modulations. Chris Lee --- drivers/media/usb/dvb-usb/gp8psk-fe.c | 263 +++++++++++++++++++++++++--------- drivers/media/usb/dvb-usb/gp8psk.h | 2 + include/uapi/linux/dvb/frontend.h | 6 + 3 files changed, 201 insertions(+), 70 deletions(-) diff --git a/drivers/media/usb/dvb-usb/gp8psk-fe.c b/drivers/media/usb/dvb-usb/gp8psk-fe.c index 67957dd..77ba995 100644 --- a/drivers/media/usb/dvb-usb/gp8psk-fe.c +++ b/drivers/media/usb/dvb-usb/gp8psk-fe.c @@ -53,7 +53,43 @@ static int gp8psk_fe_update_status(struct gp8psk_fe_state *st) static int gp8psk_fe_read_status(struct dvb_frontend* fe, fe_status_t *status) { + struct dtv_frontend_properties *c = &fe->dtv_property_cache; struct gp8psk_fe_state *st = fe->demodulator_priv; + + u8 buf[32]; + int frequency; + int carrier_error; + int carrier_offset; + int rate_error; + int rate_offset; + int symbol_rate; + + int fe_gp8psk_system_return[] = { + SYS_DVBS, + SYS_TURBO, + SYS_TURBO, + SYS_TURBO, + SYS_DCII, + SYS_DCII, + SYS_DCII, + SYS_DCII, + SYS_DSS, + SYS_UNDEFINED + }; + + int fe_gp8psk_modulation_return[] = { + QPSK, + QPSK, + PSK_8, + QAM_16, + C_QPSK, + I_QPSK, + Q_QPSK, + C_OQPSK, + QPSK, + QPSK, + }; + gp8psk_fe_update_status(st); if (st->lock) @@ -61,10 +97,79 @@ static int gp8psk_fe_read_status(struct dvb_frontend* fe, fe_status_t *status) else *status = 0; - if (*status & FE_HAS_LOCK) + if (*status & FE_HAS_LOCK) { + gp8psk_usb_in_op(st->d, GET_SIGNAL_STAT, 0, 0, buf, 32); + frequency = ((buf[11] << 24) + (buf[10] << 16) + (buf[9] << 8) + buf[8]) / 1000; + carrier_error = ((buf[15] << 24) + (buf[14] << 16) + (buf[13] << 8) + buf[12]) / 1000; + carrier_offset = (buf[19] << 24) + (buf[18] << 16) + (buf[17] << 8) + buf[16]; + rate_error = (buf[23] << 24) + (buf[22] << 16) + (buf[21] << 8) + buf[20]; + rate_offset = (buf[27] << 24) + (buf[26] << 16) + (buf[25] << 8) + buf[24]; + symbol_rate = (buf[31] << 24) + (buf[30] << 16) + (buf[29] << 8) + buf[28]; + + c->frequency = frequency - carrier_error; + c->symbol_rate = symbol_rate + rate_error; + + switch (c->delivery_system) { + case SYS_DSS: + case SYS_DVBS: + c->delivery_system = fe_gp8psk_system_return[buf[1]]; + c->modulation = fe_gp8psk_modulation_return[buf[1]]; + switch (buf[2]) { + case 0: c->fec_inner = FEC_1_2; break; + case 1: c->fec_inner = FEC_2_3; break; + case 2: c->fec_inner = FEC_3_4; break; + case 3: c->fec_inner = FEC_5_6; break; + case 4: c->fec_inner = FEC_6_7; break; + case 5: c->fec_inner = FEC_7_8; break; + default: c->fec_inner = FEC_AUTO; break; + } + break; + case SYS_TURBO: + c->delivery_system = fe_gp8psk_system_return[buf[1]]; + c->modulation = fe_gp8psk_modulation_return[buf[1]]; + if (c->modulation == QPSK) { + switch (buf[2]) { + case 0: c->fec_inner = FEC_7_8; break; + case 1: c->fec_inner = FEC_1_2; break; + case 2: c->fec_inner = FEC_3_4; break; + case 3: c->fec_inner = FEC_2_3; break; + case 4: c->fec_inner = FEC_5_6; break; + default: c->fec_inner = FEC_AUTO; break; + } + } else { + switch (buf[2]) { + case 0: c->fec_inner = FEC_2_3; break; + case 1: c->fec_inner = FEC_3_4; break; + case 2: c->fec_inner = FEC_3_4; break; + case 3: c->fec_inner = FEC_5_6; break; + case 4: c->fec_inner = FEC_8_9; break; + default: c->fec_inner = FEC_AUTO; break; + } + } + break; + case SYS_DCII: + c->modulation = fe_gp8psk_modulation_return[buf[1]]; + switch (buf[2]) { + case 0: c->fec_inner = FEC_5_11; break; + case 1: c->fec_inner = FEC_1_2; break; + case 2: c->fec_inner = FEC_3_5; break; + case 3: c->fec_inner = FEC_2_3; break; + case 4: c->fec_inner = FEC_3_4; break; + case 5: c->fec_inner = FEC_4_5; break; + case 6: c->fec_inner = FEC_5_6; break; + case 7: c->fec_inner = FEC_7_8; break; + default: c->fec_inner = FEC_AUTO; break; + } + break; + default: + c->fec_inner = FEC_AUTO; + break; + } + st->status_check_interval = 1000; - else + } else { st->status_check_interval = 100; + } return 0; } @@ -121,93 +226,111 @@ static int gp8psk_fe_set_frontend(struct dvb_frontend *fe) u32 freq = c->frequency * 1000; int gp_product_id = le16_to_cpu(state->d->udev->descriptor.idProduct); - deb_fe("%s()\n", __func__); + info("%s() freq: %d, sr: %d", __func__, freq, c->symbol_rate); + cmd[0] = c->symbol_rate & 0xff; + cmd[1] = (c->symbol_rate >> 8) & 0xff; + cmd[2] = (c->symbol_rate >> 16) & 0xff; + cmd[3] = (c->symbol_rate >> 24) & 0xff; cmd[4] = freq & 0xff; cmd[5] = (freq >> 8) & 0xff; cmd[6] = (freq >> 16) & 0xff; cmd[7] = (freq >> 24) & 0xff; - /* backwards compatibility: DVB-S + 8-PSK were used for Turbo-FEC */ - if (c->delivery_system == SYS_DVBS && c->modulation == PSK_8) + /* backwards compatibility: DVB-S2 used to be used for Turbo-FEC */ + if (c->delivery_system == SYS_DVBS2) c->delivery_system = SYS_TURBO; switch (c->delivery_system) { case SYS_DVBS: - if (c->modulation != QPSK) { - deb_fe("%s: unsupported modulation selected (%d)\n", - __func__, c->modulation); - return -EOPNOTSUPP; - } + info("%s: DVB-S delivery system selected w/fec %d", __func__, c->fec_inner); c->fec_inner = FEC_AUTO; - break; - case SYS_DVBS2: /* kept for backwards compatibility */ - deb_fe("%s: DVB-S2 delivery system selected\n", __func__); + cmd[8] = ADV_MOD_DVB_QPSK; + cmd[9] = 5; break; case SYS_TURBO: - deb_fe("%s: Turbo-FEC delivery system selected\n", __func__); + info("%s: Turbo-FEC delivery system selected", __func__); + switch (c->modulation) { + case QPSK: + info("%s: modulation QPSK selected w/fec %d", __func__, c->fec_inner); + cmd[8] = ADV_MOD_TURBO_QPSK; + switch (c->fec_inner) { + case FEC_1_2: cmd[9] = 1; break; + case FEC_2_3: cmd[9] = 3; break; + case FEC_3_4: cmd[9] = 2; break; + case FEC_5_6: cmd[9] = 4; break; + default: cmd[9] = 0; break; + } + break; + case PSK_8: + info("%s: modulation 8PSK selected w/fec %d", __func__, c->fec_inner); + cmd[8] = ADV_MOD_TURBO_8PSK; + switch (c->fec_inner) { + case FEC_2_3: cmd[9] = 0; break; + case FEC_3_4: cmd[9] = 1; break; + case FEC_3_5: cmd[9] = 2; break; + case FEC_5_6: cmd[9] = 3; break; + case FEC_8_9: cmd[9] = 4; break; + default: cmd[9] = 0; break; + } + break; + case QAM_16: /* QAM_16 is for compatibility with DN */ + info("%s: modulation QAM_16 selected w/fec %d", __func__, c->fec_inner); + cmd[8] = ADV_MOD_TURBO_16QAM; + cmd[9] = 0; + break; + default: /* Unknown modulation */ + info("%s: unsupported modulation selected (%d)", + __func__, c->modulation); + return -EOPNOTSUPP; + } break; - - default: - deb_fe("%s: unsupported delivery system selected (%d)\n", - __func__, c->delivery_system); - return -EOPNOTSUPP; - } - - cmd[0] = c->symbol_rate & 0xff; - cmd[1] = (c->symbol_rate >> 8) & 0xff; - cmd[2] = (c->symbol_rate >> 16) & 0xff; - cmd[3] = (c->symbol_rate >> 24) & 0xff; - switch (c->modulation) { - case QPSK: - if (gp_product_id == USB_PID_GENPIX_8PSK_REV_1_WARM) - if (gp8psk_tuned_to_DCII(fe)) - gp8psk_bcm4500_reload(state->d); + case SYS_DSS: + info("%s: DSS delivery system selected w/fec %d", __func__, c->fec_inner); + cmd[8] = ADV_MOD_DSS_QPSK; switch (c->fec_inner) { - case FEC_1_2: - cmd[9] = 0; break; - case FEC_2_3: - cmd[9] = 1; break; - case FEC_3_4: - cmd[9] = 2; break; - case FEC_5_6: - cmd[9] = 3; break; - case FEC_7_8: - cmd[9] = 4; break; - case FEC_AUTO: - cmd[9] = 5; break; - default: - cmd[9] = 5; break; + case FEC_1_2: cmd[9] = 0; break; + case FEC_2_3: cmd[9] = 1; break; + case FEC_3_4: cmd[9] = 2; break; + case FEC_5_6: cmd[9] = 3; break; + case FEC_7_8: cmd[9] = 4; break; + case FEC_AUTO: cmd[9] = 5; break; + case FEC_6_7: cmd[9] = 6; break; + default: cmd[9] = 5; break; } - if (c->delivery_system == SYS_TURBO) - cmd[8] = ADV_MOD_TURBO_QPSK; - else - cmd[8] = ADV_MOD_DVB_QPSK; break; - case PSK_8: /* PSK_8 is for compatibility with DN */ - cmd[8] = ADV_MOD_TURBO_8PSK; - switch (c->fec_inner) { - case FEC_2_3: - cmd[9] = 0; break; - case FEC_3_4: - cmd[9] = 1; break; - case FEC_3_5: - cmd[9] = 2; break; - case FEC_5_6: - cmd[9] = 3; break; - case FEC_8_9: - cmd[9] = 4; break; + case SYS_DCII: + info("%s: DCII delivery system selected w/fec %d", __func__, c->fec_inner); + switch (c->modulation) { + case C_QPSK: + cmd[8] = ADV_MOD_DCII_C_QPSK; + break; + case I_QPSK: + cmd[8] = ADV_MOD_DCII_I_QPSK; + break; + case Q_QPSK: + cmd[8] = ADV_MOD_DCII_Q_QPSK; + break; + case C_OQPSK: default: - cmd[9] = 0; break; + cmd[8] = ADV_MOD_DCII_C_OQPSK; + break; + } + switch (c->fec_inner) { + case FEC_5_11: cmd[9] = 0; break; + case FEC_1_2: cmd[9] = 1; break; + case FEC_3_5: cmd[9] = 2; break; + case FEC_2_3: cmd[9] = 3; break; + case FEC_3_4: cmd[9] = 4; break; + case FEC_4_5: cmd[9] = 5; break; + case FEC_5_6: cmd[9] = 6; break; + case FEC_7_8: cmd[9] = 7; break; + case FEC_AUTO: cmd[9] = 8; break; + default: cmd[9] = 8; break; } break; - case QAM_16: /* QAM_16 is for compatibility with DN */ - cmd[8] = ADV_MOD_TURBO_16QAM; - cmd[9] = 0; - break; - default: /* Unknown modulation */ - deb_fe("%s: unsupported modulation selected (%d)\n", - __func__, c->modulation); + default: + info("%s: unsupported delivery system selected (%d)", __func__, c->delivery_system); return -EOPNOTSUPP; } @@ -326,7 +449,7 @@ success: static struct dvb_frontend_ops gp8psk_fe_ops = { - .delsys = { SYS_DVBS }, + .delsys = { SYS_TURBO, SYS_DCII, SYS_DSS, SYS_DVBS }, .info = { .name = "Genpix DVB-S", .frequency_min = 800000, diff --git a/drivers/media/usb/dvb-usb/gp8psk.h b/drivers/media/usb/dvb-usb/gp8psk.h index ed32b9d..dbab86d 100644 --- a/drivers/media/usb/dvb-usb/gp8psk.h +++ b/drivers/media/usb/dvb-usb/gp8psk.h @@ -52,6 +52,8 @@ extern int dvb_usb_gp8psk_debug; #define GET_SERIAL_NUMBER 0x93 /* in */ #define USE_EXTRA_VOLT 0x94 #define GET_FPGA_VERS 0x95 +#define GET_SIGNAL_STAT 0x9A +#define GET_BER_RATE 0x9B #define CW3K_INIT 0x9d /* PSK_configuration bits */ diff --git a/include/uapi/linux/dvb/frontend.h b/include/uapi/linux/dvb/frontend.h index c56d77c..78b4df9 100644 --- a/include/uapi/linux/dvb/frontend.h +++ b/include/uapi/linux/dvb/frontend.h @@ -165,6 +165,7 @@ typedef enum fe_code_rate { FEC_3_5, FEC_9_10, FEC_2_5, + FEC_5_11, } fe_code_rate_t; @@ -183,6 +184,10 @@ typedef enum fe_modulation { APSK_32, DQPSK, QAM_4_NR, + C_QPSK, + I_QPSK, + Q_QPSK, + C_OQPSK, } fe_modulation_t; typedef enum fe_transmit_mode { @@ -410,6 +415,7 @@ typedef enum fe_delivery_system { SYS_DVBT2, SYS_TURBO, SYS_DVBC_ANNEX_C, + SYS_DCII, } fe_delivery_system_t; /* backward compatibility */