From patchwork Thu Jul 24 16:02:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shuah Khan X-Patchwork-Id: 4618711 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 03519C0514 for ; Thu, 24 Jul 2014 16:03:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 21D0D201ED for ; Thu, 24 Jul 2014 16:03:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 447E520160 for ; Thu, 24 Jul 2014 16:03:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934053AbaGXQCx (ORCPT ); Thu, 24 Jul 2014 12:02:53 -0400 Received: from qmta04.emeryville.ca.mail.comcast.net ([76.96.30.40]:59935 "EHLO qmta04.emeryville.ca.mail.comcast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933720AbaGXQCU (ORCPT ); Thu, 24 Jul 2014 12:02:20 -0400 Received: from omta22.emeryville.ca.mail.comcast.net ([76.96.30.89]) by qmta04.emeryville.ca.mail.comcast.net with comcast id WG1l1o0031vN32cA4G2L5M; Thu, 24 Jul 2014 16:02:20 +0000 Received: from mail.gonehiking.org ([50.134.149.16]) by omta22.emeryville.ca.mail.comcast.net with comcast id WG2K1o00A0MU7Qa8iG2KwB; Thu, 24 Jul 2014 16:02:20 +0000 Received: from lorien.sisa.samsung.com (lorien-wl.internal [192.168.1.40]) by mail.gonehiking.org (Postfix) with ESMTP id DE6DF444A5; Thu, 24 Jul 2014 10:02:18 -0600 (MDT) From: Shuah Khan To: m.chehab@samsung.com, olebowle@gmx.com, dheitmueller@kernellabs.com Cc: Shuah Khan , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] media: drx39xyj - add resume support Date: Thu, 24 Jul 2014 10:02:15 -0600 Message-Id: X-Mailer: git-send-email 1.9.1 In-Reply-To: References: In-Reply-To: References: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20140121; t=1406217740; bh=f6nJvTeufBhPzG9WK2png7+VfQRM2mZKD52xUvgINs8=; h=Received:Received:Received:From:To:Subject:Date:Message-Id; b=Gv20DwBnklpJEt6gZ2ByOV4u6OuiT0C32bUPhuLEjUK0WeiN1PMQK3ubaXqoI5wfS Q7s6C/1gSMF6gPZOg2PZjXQzdSodZ63+PaMYTPgpnsTfeTrR1mtepbLBni9ScsTjVB DQdpy2h70LDMv5KjeJWAsSUssa1v04a6UOtdKImKHsaEJ/mfiw/qxtakj9L6L47szf gnVP2VnfcrglNEXmlmlQBTZCQtEhYkKSF2JvK2kgoNmJX9Zw+PmtBaZ5Sz+I91Y4B1 gBJcn29tyXP5mx6SaNTNQ8WMXE4oHnq50rLfA5flwfZRKGJD+eGB39P9/xDp8CCypB S93LYwtOhx2Ww== 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_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable 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 drx39xyj driver lacks resume support. Add support by changing its fe ops init interface to detect the resume status by checking fe exit flag and do the necessary initialization. With this change, driver resume correctly in both dvb adapter is not in use and in use by an application cases. Signed-off-by: Shuah Khan --- drivers/media/dvb-frontends/drx39xyj/drxj.c | 65 +++++++++++++++++---------- 1 file changed, 42 insertions(+), 23 deletions(-) diff --git a/drivers/media/dvb-frontends/drx39xyj/drxj.c b/drivers/media/dvb-frontends/drx39xyj/drxj.c index c3931cc..31fee7b 100644 --- a/drivers/media/dvb-frontends/drx39xyj/drxj.c +++ b/drivers/media/dvb-frontends/drx39xyj/drxj.c @@ -11315,6 +11315,7 @@ rw_error: static int drx_ctrl_u_code(struct drx_demod_instance *demod, struct drxu_code_info *mc_info, enum drxu_code_action action); +static int drxj_set_lna_state(struct drx_demod_instance *demod, bool state); /** * \fn drxj_open() @@ -11527,6 +11528,7 @@ static int drxj_open(struct drx_demod_instance *demod) ext_attr->aud_data = drxj_default_aud_data_g; demod->my_common_attr->is_opened = true; + drxj_set_lna_state(demod, false); return 0; rw_error: common_attr->is_opened = false; @@ -11890,6 +11892,33 @@ release: return rc; } +/* caller is expeced to check if lna is supported before enabling */ +static int drxj_set_lna_state(struct drx_demod_instance *demod, bool state) +{ + struct drxuio_cfg uio_cfg; + struct drxuio_data uio_data; + int result; + + uio_cfg.uio = DRX_UIO1; + uio_cfg.mode = DRX_UIO_MODE_READWRITE; + /* Configure user-I/O #3: enable read/write */ + result = ctrl_set_uio_cfg(demod, &uio_cfg); + if (result) { + pr_err("Failed to setup LNA GPIO!\n"); + return result; + } + + uio_data.uio = DRX_UIO1; + uio_data.value = state; + result = ctrl_uio_write(demod, &uio_data); + if (result != 0) { + pr_err("Failed to %sable LNA!\n", + state ? "en" : "dis"); + return result; + } + return 0; +} + /* * The Linux DVB Driver for Micronas DRX39xx family (drx3933j) * @@ -12180,10 +12209,20 @@ static int drx39xxj_i2c_gate_ctrl(struct dvb_frontend *fe, int enable) static int drx39xxj_init(struct dvb_frontend *fe) { - /* Bring the demod out of sleep */ - drx39xxj_set_powerstate(fe, 1); + struct drx39xxj_state *state = fe->demodulator_priv; + struct drx_demod_instance *demod = state->demod; + int rc = 0; - return 0; + if (fe->exit == DVB_FE_DEVICE_RESUME) { + /* so drxj_open() does what it needs to do */ + demod->my_common_attr->is_opened = false; + rc = drxj_open(demod); + if (rc != 0) + pr_err("drx39xxj_init(): DRX open failed rc=%d!\n", rc); + } else + drx39xxj_set_powerstate(fe, 1); + + return rc; } static int drx39xxj_set_lna(struct dvb_frontend *fe) @@ -12261,8 +12300,6 @@ struct dvb_frontend *drx39xxj_attach(struct i2c_adapter *i2c) struct drxj_data *demod_ext_attr = NULL; struct drx_demod_instance *demod = NULL; struct dtv_frontend_properties *p; - struct drxuio_cfg uio_cfg; - struct drxuio_data uio_data; int result; /* allocate memory for the internal state */ @@ -12315,24 +12352,6 @@ struct dvb_frontend *drx39xxj_attach(struct i2c_adapter *i2c) goto error; } - /* Turn off the LNA */ - uio_cfg.uio = DRX_UIO1; - uio_cfg.mode = DRX_UIO_MODE_READWRITE; - /* Configure user-I/O #3: enable read/write */ - result = ctrl_set_uio_cfg(demod, &uio_cfg); - if (result) { - pr_err("Failed to setup LNA GPIO!\n"); - goto error; - } - - uio_data.uio = DRX_UIO1; - uio_data.value = false; - result = ctrl_uio_write(demod, &uio_data); - if (result != 0) { - pr_err("Failed to disable LNA!\n"); - goto error; - } - /* create dvb_frontend */ memcpy(&state->frontend.ops, &drx39xxj_ops, sizeof(struct dvb_frontend_ops));