From patchwork Thu Aug 29 08:38:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiro TSUKADA X-Patchwork-Id: 11120643 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F372814DE for ; Thu, 29 Aug 2019 08:39:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C983423404 for ; Thu, 29 Aug 2019 08:39:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dofKZck0" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727041AbfH2IjB (ORCPT ); Thu, 29 Aug 2019 04:39:01 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:45839 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726038AbfH2IjA (ORCPT ); Thu, 29 Aug 2019 04:39:00 -0400 Received: by mail-pl1-f193.google.com with SMTP id y8so1236213plr.12 for ; Thu, 29 Aug 2019 01:38:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kdMzQlPZh5Jt6vXf/A/c/+H+d76fPQ64s/j3DHXKw6g=; b=dofKZck0vH59gehcmJSOUqD+n06nqOg2xb744/Ysl+mLdpCE7A8gO1vddcKk3tKjUb 8HZn7Dbg1u/GbtbkdBfxRFLcnrvPV5lDuxvzMI4tGcCIftN0i44kqO7BUL1mUuk/JZlq G+YPlgIL5AUA8ZZYvZPV43OFamNfDkGk8LrC1PRlJGSCJTsEpIy4FrZIC54jb72KP3I6 AQpvjAFS8CVp6rkk9Y8ylh6TMCeDp8/gNMsBm15sYdkMY9yE+WFYq9c4h8weOl4GE1o0 GUApC3GDehftz2NvDHZuM6rtNkzUVvBHyH5nvTEGiB0d+PJgQmESWKaVhK9cnTTjqSGW UfxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kdMzQlPZh5Jt6vXf/A/c/+H+d76fPQ64s/j3DHXKw6g=; b=c8IRU5hpzku9p+j8FW5WpwozzAYJoIGsnk4I7U9M1BAYrNrAinVdsCPUqeNyyKE4hZ qwHSl+AtRSNxZOuvxuOHMLBp2P/+Dk99nWqNz7uhQ+LuW8Oudas7TMClWd13oeSElZmL kEYN45IWmvwvW89aMlr5Jgn8boZmke+XZaZD58Zp1rWw7XR1T3nvl8w2tmbM5lAUysnK yNB9CvCdYK//R/34a0lMsdgG3iEPMjVmJbO8tCMxIlSzvb5YnN94mKZD/bTGKoinXni9 IXkYvDbIfTyFkCc4XO7Ww7S459a22MEjvxjk6t3mtWqmMUz4PYa6mDZoISf9hLD2XoEe FtQQ== X-Gm-Message-State: APjAAAVVHhZPcevWKW91IF1K0/P4nnu6Hm7PrauVMo5qqeemVuj0QyYo e4yA/wo4OYYqYu4wnKaCOFIab8bN X-Google-Smtp-Source: APXvYqxyFOtllOnF1q3/Q8gV1zEKZJWoi1oqSX6ifJLEC2dzpVx4TA69WcZ8gj1zu8dZ44lt2CmUsw== X-Received: by 2002:a17:902:1a6:: with SMTP id b35mr8332821plb.228.1567067939191; Thu, 29 Aug 2019 01:38:59 -0700 (PDT) Received: from localhost.localdomain (softbank219203027033.bbtec.net. [219.203.27.33]) by smtp.googlemail.com with ESMTPSA id g10sm3498518pfb.95.2019.08.29.01.38.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2019 01:38:58 -0700 (PDT) From: tskd08@gmail.com To: linux-media@vger.kernel.org Cc: crope@iki.fi, sean@mess.org, mchehab@kernel.org, Akihiro Tsukada Subject: [PATCH v2 1/4] dvb-usb-v2/gl861: remove device-specific i2c algo Date: Thu, 29 Aug 2019 17:38:19 +0900 Message-Id: <20190829083822.3670-2-tskd08@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190829083822.3670-1-tskd08@gmail.com> References: <20190829083822.3670-1-tskd08@gmail.com> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Akihiro Tsukada For Friio dvb cards, a dintinct I2C algo was provided to support some "long" I2C messages used in relaying tuner I2C via demod. Since the other (generic) i2c algo in this module has been patched to support those messages in a more generic way, this patch replaces and integrates the device-specific i2c algo with the generic one and simplify the code. depends on the patch: "gl861: re-implement i2c adapter logic" https://patchwork.linuxtv.org/patch/58340/ Signed-off-by: Akihiro Tsukada --- drivers/media/usb/dvb-usb-v2/gl861.c | 234 +++------------------------ 1 file changed, 26 insertions(+), 208 deletions(-) diff --git a/drivers/media/usb/dvb-usb-v2/gl861.c b/drivers/media/usb/dvb-usb-v2/gl861.c index ead6268af7a..7e5bcf49896 100644 --- a/drivers/media/usb/dvb-usb-v2/gl861.c +++ b/drivers/media/usb/dvb-usb-v2/gl861.c @@ -21,7 +21,6 @@ struct gl861 { struct i2c_adapter *demod_sub_i2c; struct i2c_client *i2c_client_demod; struct i2c_client *i2c_client_tuner; - struct i2c_adapter tuner_adap; }; #define CMD_WRITE_SHORT 0x01 @@ -79,6 +78,12 @@ static int gl861_ctrl_msg(struct dvb_usb_device *d, u8 request, u16 value, return ret; } +static int gl861_short_write(struct dvb_usb_device *d, u8 addr, u8 reg, u8 val) +{ + return gl861_ctrl_msg(d, CMD_WRITE_SHORT, + (addr << 9) | val, reg, NULL, 0); +} + static int gl861_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num) { @@ -162,55 +167,6 @@ static struct i2c_algorithm gl861_i2c_algo = { .functionality = gl861_i2c_functionality, }; -static int gl861_i2c_msg(struct dvb_usb_device *d, u8 addr, - u8 *wbuf, u16 wlen, u8 *rbuf, u16 rlen) -{ - u16 index; - u16 value = addr << (8 + 1); - int wo = (rbuf == NULL || rlen == 0); /* write-only */ - u8 req, type; - u8 *buf; - int ret; - - if (wo) { - req = GL861_REQ_I2C_WRITE; - type = GL861_WRITE; - buf = kmemdup(wbuf, wlen, GFP_KERNEL); - } else { /* rw */ - req = GL861_REQ_I2C_READ; - type = GL861_READ; - buf = kmalloc(rlen, GFP_KERNEL); - } - if (!buf) - return -ENOMEM; - - switch (wlen) { - case 1: - index = wbuf[0]; - break; - case 2: - index = wbuf[0]; - value = value + wbuf[1]; - break; - default: - dev_err(&d->udev->dev, "%s: wlen=%d, aborting\n", - KBUILD_MODNAME, wlen); - kfree(buf); - return -EINVAL; - } - - usleep_range(1000, 2000); /* avoid I2C errors */ - - ret = usb_control_msg(d->udev, usb_rcvctrlpipe(d->udev, 0), req, type, - value, index, buf, rlen, 2000); - - if (!wo && ret > 0) - memcpy(rbuf, buf, rlen); - - kfree(buf); - return ret; -} - /* Callbacks for DVB USB */ static struct zl10353_config gl861_zl10353_config = { .demod_address = 0x0f, @@ -289,129 +245,6 @@ static const struct friio_config friio_config = { .tuner_info = { I2C_BOARD_INFO("tua6034_friio", 0x60), }, }; -/* For another type of I2C: - * message sent by a USB control-read/write transaction with data stage. - * Used in init/config of Friio. - */ -static int -gl861_i2c_write_ex(struct dvb_usb_device *d, u8 addr, u8 *wbuf, u16 wlen) -{ - u8 *buf; - int ret; - - buf = kmemdup(wbuf, wlen, GFP_KERNEL); - if (!buf) - return -ENOMEM; - - ret = usb_control_msg(d->udev, usb_sndctrlpipe(d->udev, 0), - GL861_REQ_I2C_RAW, GL861_WRITE, - addr << (8 + 1), 0x0100, buf, wlen, 2000); - kfree(buf); - return ret; -} - -static int -gl861_i2c_read_ex(struct dvb_usb_device *d, u8 addr, u8 *rbuf, u16 rlen) -{ - u8 *buf; - int ret; - - buf = kmalloc(rlen, GFP_KERNEL); - if (!buf) - return -ENOMEM; - - ret = usb_control_msg(d->udev, usb_rcvctrlpipe(d->udev, 0), - GL861_REQ_I2C_READ, GL861_READ, - addr << (8 + 1), 0x0100, buf, rlen, 2000); - if (ret > 0 && rlen > 0) - memcpy(buf, rbuf, rlen); - kfree(buf); - return ret; -} - -/* For I2C transactions to the tuner of Friio (dvb_pll). - * - * Friio uses irregular USB encapsulation for tuner i2c transactions: - * write transacions are encapsulated with a different USB 'request' value. - * - * Although all transactions are sent via the demod(tc90522) - * and the demod provides an i2c adapter for them, it cannot be used in Friio - * since it assumes using the same parent adapter with the demod, - * which does not use the request value and uses same one for both read/write. - * So we define a dedicated i2c adapter here. - */ - -static int -friio_i2c_tuner_read(struct dvb_usb_device *d, struct i2c_msg *msg) -{ - struct gl861 *priv; - u8 addr; - - priv = d_to_priv(d); - addr = priv->i2c_client_demod->addr; - return gl861_i2c_read_ex(d, addr, msg->buf, msg->len); -} - -static int -friio_i2c_tuner_write(struct dvb_usb_device *d, struct i2c_msg *msg) -{ - u8 *buf; - int ret; - struct gl861 *priv; - - priv = d_to_priv(d); - - if (msg->len < 1) - return -EINVAL; - - buf = kmalloc(msg->len + 1, GFP_KERNEL); - if (!buf) - return -ENOMEM; - buf[0] = msg->addr << 1; - memcpy(buf + 1, msg->buf, msg->len); - - ret = usb_control_msg(d->udev, usb_sndctrlpipe(d->udev, 0), - GL861_REQ_I2C_RAW, GL861_WRITE, - priv->i2c_client_demod->addr << (8 + 1), - 0xFE, buf, msg->len + 1, 2000); - kfree(buf); - return ret; -} - -static int friio_tuner_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], - int num) -{ - struct dvb_usb_device *d = i2c_get_adapdata(adap); - int i; - - if (num > 2) - return -EINVAL; - - if (mutex_lock_interruptible(&d->i2c_mutex) < 0) - return -EAGAIN; - - for (i = 0; i < num; i++) { - int ret; - - if (msg[i].flags & I2C_M_RD) - ret = friio_i2c_tuner_read(d, &msg[i]); - else - ret = friio_i2c_tuner_write(d, &msg[i]); - - if (ret < 0) - break; - - usleep_range(1000, 2000); /* avoid I2C errors */ - } - - mutex_unlock(&d->i2c_mutex); - return i; -} - -static struct i2c_algorithm friio_tuner_i2c_algo = { - .master_xfer = friio_tuner_i2c_xfer, - .functionality = gl861_i2c_functionality, -}; /* GPIO control in Friio */ @@ -479,9 +312,11 @@ static int friio_ext_ctl(struct dvb_usb_device *d, /* init/config of gl861 for Friio */ /* NOTE: * This function cannot be moved to friio_init()/dvb_usbv2_init(), - * because the init defined here must be done before any activities like I2C, + * because the init defined here includes a whole device reset, + * it must be run early before any activities like I2C, * but friio_init() is called by dvb-usbv2 after {_frontend, _tuner}_attach(), * where I2C communication is used. + * In addition, this reset is required in reset_resume() as well. * Thus this function is set to be called from _power_ctl(). * * Since it will be called on the early init stage @@ -491,7 +326,7 @@ static int friio_ext_ctl(struct dvb_usb_device *d, static int friio_reset(struct dvb_usb_device *d) { int i, ret; - u8 wbuf[2], rbuf[2]; + u8 wbuf[1], rbuf[2]; static const u8 friio_init_cmds[][2] = { {0x33, 0x08}, {0x37, 0x40}, {0x3a, 0x1f}, {0x3b, 0xff}, @@ -503,16 +338,12 @@ static int friio_reset(struct dvb_usb_device *d) if (ret < 0) return ret; - wbuf[0] = 0x11; - wbuf[1] = 0x02; - ret = gl861_i2c_msg(d, 0x00, wbuf, 2, NULL, 0); + ret = gl861_short_write(d, 0x00, 0x11, 0x02); if (ret < 0) return ret; usleep_range(2000, 3000); - wbuf[0] = 0x11; - wbuf[1] = 0x00; - ret = gl861_i2c_msg(d, 0x00, wbuf, 2, NULL, 0); + ret = gl861_short_write(d, 0x00, 0x11, 0x00); if (ret < 0) return ret; @@ -522,14 +353,13 @@ static int friio_reset(struct dvb_usb_device *d) */ usleep_range(1000, 2000); - wbuf[0] = 0x03; - wbuf[1] = 0x80; - ret = gl861_i2c_write_ex(d, 0x09, wbuf, 2); + wbuf[0] = 0x80; + ret = gl861_ctrl_msg(d, CMD_WRITE, 0x09 << 9, 0x03, wbuf, 1); if (ret < 0) return ret; usleep_range(2000, 3000); - ret = gl861_i2c_read_ex(d, 0x09, rbuf, 2); + ret = gl861_ctrl_msg(d, CMD_READ, 0x09 << 9, 0x0100, rbuf, 2); if (ret < 0) return ret; if (rbuf[0] != 0xff || rbuf[1] != 0xff) @@ -537,38 +367,33 @@ static int friio_reset(struct dvb_usb_device *d) usleep_range(1000, 2000); - ret = gl861_i2c_write_ex(d, 0x48, wbuf, 2); + wbuf[0] = 0x80; + ret = gl861_ctrl_msg(d, CMD_WRITE, 0x48 << 9, 0x03, wbuf, 1); if (ret < 0) return ret; usleep_range(2000, 3000); - ret = gl861_i2c_read_ex(d, 0x48, rbuf, 2); + ret = gl861_ctrl_msg(d, CMD_READ, 0x48 << 9, 0x0100, rbuf, 2); if (ret < 0) return ret; if (rbuf[0] != 0xff || rbuf[1] != 0xff) return -ENODEV; - wbuf[0] = 0x30; - wbuf[1] = 0x04; - ret = gl861_i2c_msg(d, 0x00, wbuf, 2, NULL, 0); + ret = gl861_short_write(d, 0x00, 0x30, 0x04); if (ret < 0) return ret; - wbuf[0] = 0x00; - wbuf[1] = 0x01; - ret = gl861_i2c_msg(d, 0x00, wbuf, 2, NULL, 0); + ret = gl861_short_write(d, 0x00, 0x00, 0x01); if (ret < 0) return ret; - wbuf[0] = 0x06; - wbuf[1] = 0x0f; - ret = gl861_i2c_msg(d, 0x00, wbuf, 2, NULL, 0); + ret = gl861_short_write(d, 0x00, 0x06, 0x0f); if (ret < 0) return ret; for (i = 0; i < ARRAY_SIZE(friio_init_cmds); i++) { - ret = gl861_i2c_msg(d, 0x00, (u8 *)friio_init_cmds[i], 2, - NULL, 0); + ret = gl861_short_write(d, 0x00, friio_init_cmds[i][0], + friio_init_cmds[i][1]); if (ret < 0) return ret; } @@ -593,6 +418,7 @@ static int friio_frontend_attach(struct dvb_usb_adapter *adap) struct gl861 *priv; info = &friio_config.demod_info; + cfg = friio_config.demod_cfg; d = adap_to_d(adap); cl = dvb_module_probe("tc90522", info->type, &d->i2c_adap, info->addr, &cfg); @@ -600,17 +426,10 @@ static int friio_frontend_attach(struct dvb_usb_adapter *adap) return -ENODEV; adap->fe[0] = cfg.fe; - /* ignore cfg.tuner_i2c and create new one */ priv = adap_to_priv(adap); priv->i2c_client_demod = cl; - priv->tuner_adap.algo = &friio_tuner_i2c_algo; - priv->tuner_adap.dev.parent = &d->udev->dev; - strscpy(priv->tuner_adap.name, d->name, sizeof(priv->tuner_adap.name)); - strlcat(priv->tuner_adap.name, "-tuner", sizeof(priv->tuner_adap.name)); - priv->demod_sub_i2c = &priv->tuner_adap; - i2c_set_adapdata(&priv->tuner_adap, d); - - return i2c_add_adapter(&priv->tuner_adap); + priv->demod_sub_i2c = cfg.tuner_i2c; + return 0; } static int friio_frontend_detach(struct dvb_usb_adapter *adap) @@ -618,7 +437,6 @@ static int friio_frontend_detach(struct dvb_usb_adapter *adap) struct gl861 *priv; priv = adap_to_priv(adap); - i2c_del_adapter(&priv->tuner_adap); dvb_module_release(priv->i2c_client_demod); return 0; } From patchwork Thu Aug 29 08:38:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiro TSUKADA X-Patchwork-Id: 11120645 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C111314DE for ; Thu, 29 Aug 2019 08:39:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A11A123404 for ; Thu, 29 Aug 2019 08:39:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="qG4NJMCI" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726889AbfH2IjF (ORCPT ); Thu, 29 Aug 2019 04:39:05 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:42790 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726038AbfH2IjD (ORCPT ); Thu, 29 Aug 2019 04:39:03 -0400 Received: by mail-pf1-f193.google.com with SMTP id i30so1571290pfk.9 for ; Thu, 29 Aug 2019 01:39:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yO2qDhPwGX7mB4VXosralsD40lCXHvpCucFOfhI0Egk=; b=qG4NJMCIQ8vat5zBTVCyEzkSTrZZigmx8/KCEv9E+6saKhvdSYaliX9UOhPr1MFLvO ihSUt7F3Hpr7gHgPlyIB3OGRbs1Y9cmMK1tCtXE95zPD3XKPhnQYjjEIhepDa6QcuLjT 2r9ODiI1q3PnVs81Yjk6XtXgOlCkjRD/YfDkLvL0Nufhql2hN+WS9bGG253s2bt1id/r PlLAvRzXelekb9OpBpQWynu8KL8H5fcgTnAStfCWI52TohupPBZqMns0DGWDGni8vyrT qe9JdvAyQ2XrOYqeVitUdDZZWSMfXYDyrql3gEXkep8ItYjOrtfzmIRpUeRqgs+LRKmR sT6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yO2qDhPwGX7mB4VXosralsD40lCXHvpCucFOfhI0Egk=; b=fumnxRek9LkiapWltlxhnSnPsQUFUmsPUk5ryjPTIy19BP9gU8i5aHPByLqxI6fq+Y EM1ZIEOnoylJZIJ+2Z+XLadQu+nWp7G/EhgH5mKCx9+xX9ivFMLjy9RW4/qvAYxE4DWC 3kHI4TXBPKGBrtYA5LuWvj4WZY8V2jSuyRJDWAmNOI+GcCyvBL8qUckUgCivrTwT7u8F nxkl7DC2dky74uz1E/OuJHiQe1oCI9qXuMVX0kztb4hh/1Suqk0Nd3HAUZ3t9axUry6k iQOxb28Posh0BCkGHS/+RkU0inX1tVOVMxYOmJ2uFrJWGlhVSmiEf7NVAkXt2U+u5xdI JDuA== X-Gm-Message-State: APjAAAX6/MPqlsp92XDzD/wHMw1DkwGhmVGfyWyS8st1JYn53DlLdeRQ MvslTHe9NUklR+yOl6awxb8wRswY X-Google-Smtp-Source: APXvYqwlAb5B4gJ+jb5BWS4ocXXYgb0HIRRFr82jV6K/koRkQnO3XlAKP7E/CI875aZYDZhdZ+n2WQ== X-Received: by 2002:a63:6ec1:: with SMTP id j184mr7230222pgc.232.1567067942455; Thu, 29 Aug 2019 01:39:02 -0700 (PDT) Received: from localhost.localdomain (softbank219203027033.bbtec.net. [219.203.27.33]) by smtp.googlemail.com with ESMTPSA id g10sm3498518pfb.95.2019.08.29.01.39.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2019 01:39:02 -0700 (PDT) From: tskd08@gmail.com To: linux-media@vger.kernel.org Cc: crope@iki.fi, sean@mess.org, mchehab@kernel.org, Akihiro Tsukada Subject: [PATCH v2 2/4] dvb-usb-v2/gl861: remove an un-used header file Date: Thu, 29 Aug 2019 17:38:20 +0900 Message-Id: <20190829083822.3670-3-tskd08@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190829083822.3670-1-tskd08@gmail.com> References: <20190829083822.3670-1-tskd08@gmail.com> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Akihiro Tsukada The header contained just internal definitions and they are not used anymore. Signed-off-by: Akihiro Tsukada --- drivers/media/usb/dvb-usb-v2/gl861.c | 2 +- drivers/media/usb/dvb-usb-v2/gl861.h | 14 -------------- 2 files changed, 1 insertion(+), 15 deletions(-) delete mode 100644 drivers/media/usb/dvb-usb-v2/gl861.h diff --git a/drivers/media/usb/dvb-usb-v2/gl861.c b/drivers/media/usb/dvb-usb-v2/gl861.c index 7e5bcf49896..e5dc1fc409f 100644 --- a/drivers/media/usb/dvb-usb-v2/gl861.c +++ b/drivers/media/usb/dvb-usb-v2/gl861.c @@ -5,7 +5,7 @@ */ #include -#include "gl861.h" +#include "dvb_usb.h" #include "zl10353.h" #include "qt1010.h" diff --git a/drivers/media/usb/dvb-usb-v2/gl861.h b/drivers/media/usb/dvb-usb-v2/gl861.h deleted file mode 100644 index 02c00e10748..00000000000 --- a/drivers/media/usb/dvb-usb-v2/gl861.h +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _DVB_USB_GL861_H_ -#define _DVB_USB_GL861_H_ - -#include "dvb_usb.h" - -#define GL861_WRITE 0x40 -#define GL861_READ 0xc0 - -#define GL861_REQ_I2C_WRITE 0x01 -#define GL861_REQ_I2C_READ 0x02 -#define GL861_REQ_I2C_RAW 0x03 - -#endif From patchwork Thu Aug 29 08:38:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiro TSUKADA X-Patchwork-Id: 11120647 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 40E7016B1 for ; Thu, 29 Aug 2019 08:39:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 20B8823404 for ; Thu, 29 Aug 2019 08:39:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="qLM37mh1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727045AbfH2IjI (ORCPT ); Thu, 29 Aug 2019 04:39:08 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:41352 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726038AbfH2IjI (ORCPT ); Thu, 29 Aug 2019 04:39:08 -0400 Received: by mail-pf1-f195.google.com with SMTP id 196so1572744pfz.8 for ; Thu, 29 Aug 2019 01:39:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0np3pNaGM9F636Uk9PvQlUNBrkizTVpSWtHNoilTc2M=; b=qLM37mh1wTkxgwBvBBhVky2EM5BfHCd2oAlj6WPU+0caLOG3o1ufxpwkUHakBbPzyy bEJxayLzLh0xyDuJbQ3eqsM1Pxa4dD1FtCJMAEeJp2bM7ufZk3MjttUQNwRMpGR67aqS f8I0KtmQWpTY/7xeD4dOK5k3PJ4/xSks79sis6tS/cl9DNn6vTOdzHJRAZ1dt7zwNqbQ oRNnad773Gt2a0IGdPUAr9AW6WLELRqKkg9IVF7hk+VK9nEguUzy6c9f6IVgQ7AVZ/Us GfUGkTTsESh1dtAfvmYQ3BN6DWfPpzLEBnvdckn0CUyO5jrs9S+x0zI/ClZKPiDG46RF nCHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0np3pNaGM9F636Uk9PvQlUNBrkizTVpSWtHNoilTc2M=; b=NzaAGkVLV/KzNT7gjFhJyQ7aOhE3J0kq19m5haWqRBn5PWC7vkyiKSAtHS214xgXkI orYvhKGO3qf5MP0NGlKzGs0PGyc2BcaERcQ6avRcR0Njqh1xq0Ibh7+7gLHecXeiaKWo pc8Z501nrX6FMvrJXsGx/bIhvMU9xmZH2Wbp7XbcIdDmMNNmaKHrY+9BCsnGNJ16mpu4 yrweeR9tVqSGdNsBRR8KKshHhfgMk+zrOy6sJmh0U+FOArUTJwg9vQ+5KOk7MDhH5DqZ JFrdGryGKra4OpXgqappRubbgihetb4scb+UEoGalr1vS5AMx0ikL+YAdB9eJ5nq3hpg oYGg== X-Gm-Message-State: APjAAAXW8EWVCj4rzm7hCPXkZe70qI5XBuZhY+nmmYZN1kS1Chwdas8E /59MqnvltnTvvWp7Wy2tBbntUmB/ X-Google-Smtp-Source: APXvYqzvR/mQMmDpZwOP8up3kItXMC0Tya2D0uFL4C34G0o8z3r7Rg3VATSkub5FiqgHoayutbeS6A== X-Received: by 2002:a63:b64:: with SMTP id a36mr7373431pgl.215.1567067947472; Thu, 29 Aug 2019 01:39:07 -0700 (PDT) Received: from localhost.localdomain (softbank219203027033.bbtec.net. [219.203.27.33]) by smtp.googlemail.com with ESMTPSA id g10sm3498518pfb.95.2019.08.29.01.39.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2019 01:39:07 -0700 (PDT) From: tskd08@gmail.com To: linux-media@vger.kernel.org Cc: crope@iki.fi, sean@mess.org, mchehab@kernel.org, Akihiro Tsukada Subject: [PATCH v2 3/4] dvb-frontends/tc90522: extend i2c algo to support some devices Date: Thu, 29 Aug 2019 17:38:21 +0900 Message-Id: <20190829083822.3670-4-tskd08@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190829083822.3670-1-tskd08@gmail.com> References: <20190829083822.3670-1-tskd08@gmail.com> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Akihiro Tsukada This demod implements an i2c adapter for attached tuner and relays i2c messages from users (dvb adapters / bridge chips). Some of them, such as Friio dvb card using gl861, require each pair of i2c messages for one read to be issued as two separate transactions. This patch adds a configuration option to enable this split. Signed-off-by: Akihiro Tsukada --- drivers/media/dvb-frontends/tc90522.c | 25 ++++++++++++++++++++++++- drivers/media/dvb-frontends/tc90522.h | 3 +++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/drivers/media/dvb-frontends/tc90522.c b/drivers/media/dvb-frontends/tc90522.c index 849d63dbc27..4c61b977466 100644 --- a/drivers/media/dvb-frontends/tc90522.c +++ b/drivers/media/dvb-frontends/tc90522.c @@ -687,8 +687,31 @@ tc90522_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) if (i < num) ret = -ENOMEM; - else + else if (!state->cfg.split_tuner_read_i2c || rd_num == 0) ret = i2c_transfer(state->i2c_client->adapter, new_msgs, j); + else { + /* + * Split transactions at each I2C_M_RD message. + * Some of the parent device require this, + * such as Friio (see. dvb-usb-gl861). + */ + int from, to; + + ret = 0; + from = 0; + do { + int r; + + to = from + 1; + while (to < j && !(new_msgs[to].flags & I2C_M_RD)) + to++; + r = i2c_transfer(state->i2c_client->adapter, + &new_msgs[from], to - from); + ret = (r <= 0) ? r : ret + r; + from = to; + } while (from < j && ret > 0); + } + if (ret >= 0 && ret < j) ret = -EIO; kfree(new_msgs); diff --git a/drivers/media/dvb-frontends/tc90522.h b/drivers/media/dvb-frontends/tc90522.h index ac0e2ab5192..07e3813bf59 100644 --- a/drivers/media/dvb-frontends/tc90522.h +++ b/drivers/media/dvb-frontends/tc90522.h @@ -28,6 +28,9 @@ struct tc90522_config { /* [OUT] tuner I2C adapter returned by driver */ struct i2c_adapter *tuner_i2c; + + /* [IN] use two separate I2C transactions for one tuner read */ + bool split_tuner_read_i2c; }; #endif /* TC90522_H */ From patchwork Thu Aug 29 08:38:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiro TSUKADA X-Patchwork-Id: 11120649 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8AEBF16B1 for ; Thu, 29 Aug 2019 08:39:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6B55423404 for ; Thu, 29 Aug 2019 08:39:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Bx9GH7iF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727063AbfH2IjO (ORCPT ); Thu, 29 Aug 2019 04:39:14 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:32833 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727046AbfH2IjN (ORCPT ); Thu, 29 Aug 2019 04:39:13 -0400 Received: by mail-pf1-f193.google.com with SMTP id g2so1602500pfq.0 for ; Thu, 29 Aug 2019 01:39:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oWWFjXBXV97k6e+KMOkhuMA9hkqjfziiYnJYOJoXUYc=; b=Bx9GH7iFCauvKnxOMKdCmuvU5FK8WVtDdHuYEirMO4asjjSAkqiJ9sZHUZl9KNI8b7 pSc9DRujs2pdm64MjQlhmPF4iwd+dkXp+dMLz6SRWN+u9k2f3Xke5wXbcBK57vlg69yE sQbeFZG3eZaosGhFz4boa7FBnE7JVWb5VOCUmny7MikvQHpMWUY93sjMX8ypkJKFIvq3 AWStymi86fE43OKPr8i/TrdsOupFikDF0PKVys/jLKlrinah7RGxAuSE+Y2rHycrjGOK 48q0A7z/3mqMJkD2J76cN1kkXJdOOAG2aO61CDOH3DKfODqxpEZy6QfIi1Cj5ryw18Uy 562g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oWWFjXBXV97k6e+KMOkhuMA9hkqjfziiYnJYOJoXUYc=; b=NUiVQCIOvdBhBxwXqaJ514uIe2nBZ9RQlJE2E51S0h+WTu6LEwzmHhJWB+hVxeESGL K87rJNKnowpHR4OQDz0GECNLe2CaaeCKdWtlbAHevO92Uud8++X1efyS0sdWgwp616S/ qnuqvqT+/RdjzR+XRjTsLs0sUvSv0rd2BZEUMSyjrrpQTJRO96Rwzt6Sc42FiwvdvJ8B f97rGFyFpvHhSzIxdUogvi0GJhEo7WiP7ALPiqNt7aE3g7sxkQJw4veBtqXZDd3gOOru w+rni9k8jNspFp9udIWPH+zahzX3kTtutFIAqLXxR2R6nqB+sHNu1+eBjHdPTTrkrN8s vNmA== X-Gm-Message-State: APjAAAUx4aKZyKw6sC7wrGryWIdGWM3UOZ2pN3Rtv5RaLmY7HLMAcWCh PQ5lGVz5B+l1xCn3F4TljnG7lSYQ X-Google-Smtp-Source: APXvYqzWDpQ0D7QkYd/0WicIt8Z45VvzzviaPdGSzMbJsZjPdyEr6BQOSYqDWf0CD2Z2WROrz22qsw== X-Received: by 2002:a65:64c6:: with SMTP id t6mr7383477pgv.323.1567067953000; Thu, 29 Aug 2019 01:39:13 -0700 (PDT) Received: from localhost.localdomain (softbank219203027033.bbtec.net. [219.203.27.33]) by smtp.googlemail.com with ESMTPSA id g10sm3498518pfb.95.2019.08.29.01.39.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2019 01:39:12 -0700 (PDT) From: tskd08@gmail.com To: linux-media@vger.kernel.org Cc: crope@iki.fi, sean@mess.org, mchehab@kernel.org, Akihiro Tsukada Subject: [PATCH v2 4/4] dvb-usb-gl861: support I2C read from tuner via demod Date: Thu, 29 Aug 2019 17:38:22 +0900 Message-Id: <20190829083822.3670-5-tskd08@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190829083822.3670-1-tskd08@gmail.com> References: <20190829083822.3670-1-tskd08@gmail.com> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Akihiro Tsukada Support Friio devices to read from tuner via demod tc90522, by enabling the config option. Signed-off-by: Akihiro Tsukada --- drivers/media/usb/dvb-usb-v2/gl861.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/media/usb/dvb-usb-v2/gl861.c b/drivers/media/usb/dvb-usb-v2/gl861.c index e5dc1fc409f..6d378aad1f0 100644 --- a/drivers/media/usb/dvb-usb-v2/gl861.c +++ b/drivers/media/usb/dvb-usb-v2/gl861.c @@ -242,6 +242,7 @@ struct friio_config { static const struct friio_config friio_config = { .demod_info = { I2C_BOARD_INFO(TC90522_I2C_DEV_TER, 0x18), }, + .demod_cfg = { .split_tuner_read_i2c = true, }, .tuner_info = { I2C_BOARD_INFO("tua6034_friio", 0x60), }, };