From patchwork Fri Oct 21 19:35:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: CrazyCat X-Patchwork-Id: 9390013 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 44C5260231 for ; Fri, 21 Oct 2016 19:44:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3050F29FA7 for ; Fri, 21 Oct 2016 19:44:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 24B2D2A26C; Fri, 21 Oct 2016 19:44:32 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, 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 5242329FA7 for ; Fri, 21 Oct 2016 19:44:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935856AbcJUTo2 (ORCPT ); Fri, 21 Oct 2016 15:44:28 -0400 Received: from forward3h.cmail.yandex.net ([87.250.230.18]:37890 "EHLO forward3h.cmail.yandex.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934695AbcJUTo2 (ORCPT ); Fri, 21 Oct 2016 15:44:28 -0400 X-Greylist: delayed 451 seconds by postgrey-1.27 at vger.kernel.org; Fri, 21 Oct 2016 15:44:27 EDT Received: from smtp3m.mail.yandex.net (smtp3m.mail.yandex.net [IPv6:2a02:6b8:0:2519::125]) by forward3h.cmail.yandex.net (Yandex) with ESMTP id C43F32101F for ; Fri, 21 Oct 2016 22:36:53 +0300 (MSK) Received: from smtp3m.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp3m.mail.yandex.net (Yandex) with ESMTP id 9DBC2284048E for ; Fri, 21 Oct 2016 22:36:53 +0300 (MSK) Received: by smtp3m.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id mZedr3YcSe-apHGgRTu; Fri, 21 Oct 2016 22:36:51 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client certificate not present) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=narod.ru; s=mail; t=1477078612; bh=JnpHZH3IPFWgsFPehvYKaLc66sxfZOBa8en83lIhoSE=; h=From:To:Subject:Date:Message-ID; b=aFikpNLOnZrfz8xDsNALlfr4SLqAwA4Yl6pRoreQIQBuafvOPtCQ97JNQlpNgWp8M T4Dk+YK1NkXylruba/ycUPNVaT94Xsg5OG0nHVkGRZIUTI9MSVBlsEhQaHPRj44Sbw W9nTOSJMg1F8wHFPziRqmVPVs+d9QHFHTCpBwDSg= Authentication-Results: smtp3m.mail.yandex.net; dkim=pass header.i=@narod.ru X-Yandex-Suid-Status: 1 0 From: CrazyCat To: linux-media@vger.kernel.org Subject: [PATCH] dvb-usb-cxusb: Geniatech T230 - resync TS FIFO after lock Date: Fri, 21 Oct 2016 22:35:40 +0300 Message-ID: <1819823.msPEjJElp3@computer> User-Agent: KMail/4.13.3 (Linux/4.4.0-42-generic; KDE/4.13.3; x86_64; ; ) MIME-Version: 1.0 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 This patch fix streaming issue for Geniatech T230/PT360. Signed-off-by: CrazyCat --- drivers/media/usb/dvb-usb/cxusb.c | 26 ++++++++++++++++++++++++++ drivers/media/usb/dvb-usb/cxusb.h | 5 +++++ 2 files changed, 31 insertions(+) diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c index 3701f59..46b59c3 100644 --- a/drivers/media/usb/dvb-usb/cxusb.c +++ b/drivers/media/usb/dvb-usb/cxusb.c @@ -368,6 +368,26 @@ static int cxusb_aver_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff) return 0; } +static int cxusb_read_status(struct dvb_frontend *fe, + enum fe_status *status) +{ + struct dvb_usb_adapter *adap = (struct dvb_usb_adapter *)fe->dvb->priv; + struct cxusb_state *state = (struct cxusb_state *)adap->dev->priv; + int ret; + + ret = state->fe_read_status(fe, status); + + /* it need resync slave fifo when signal change from unlock to lock.*/ + if ((*status & FE_HAS_LOCK) && (!state->last_lock)) { + mutex_lock(&state->stream_mutex); + cxusb_streaming_ctrl(adap, 1); + mutex_unlock(&state->stream_mutex); + } + + state->last_lock = (*status & FE_HAS_LOCK) ? 1 : 0; + return ret; +} + static void cxusb_d680_dmb_drain_message(struct dvb_usb_device *d) { int ep = d->props.generic_bulk_ctrl_endpoint; @@ -1370,6 +1390,12 @@ static int cxusb_mygica_t230_frontend_attach(struct dvb_usb_adapter *adap) st->i2c_client_demod = client_demod; st->i2c_client_tuner = client_tuner; + /* hook fe: need to resync the slave fifo when signal locks. */ + mutex_init(&st->stream_mutex); + st->last_lock = 0; + st->fe_read_status = adap->fe_adap[0].fe->ops.read_status; + adap->fe_adap[0].fe->ops.read_status = cxusb_read_status; + return 0; } diff --git a/drivers/media/usb/dvb-usb/cxusb.h b/drivers/media/usb/dvb-usb/cxusb.h index 527ff79..22b3253 100644 --- a/drivers/media/usb/dvb-usb/cxusb.h +++ b/drivers/media/usb/dvb-usb/cxusb.h @@ -32,6 +32,11 @@ struct cxusb_state { u8 gpio_write_state[3]; struct i2c_client *i2c_client_demod; struct i2c_client *i2c_client_tuner; + + struct mutex stream_mutex; + u8 last_lock; + int (*fe_read_status)(struct dvb_frontend *fe, + enum fe_status *status); }; #endif