Received: by 2002:a05:6a10:5594:0:0:0:0 with SMTP id ee20csp400612pxb; Mon, 25 Apr 2022 12:19:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwR1ZbT10b4rFQmFnjBeOSkmRLQfkmUydTWEmRTRy8ASifthtWO5pKaTuyAIIMVgwAhXgkN X-Received: by 2002:a05:6a00:1512:b0:505:da8c:26ba with SMTP id q18-20020a056a00151200b00505da8c26bamr20427516pfu.63.1650914356851; Mon, 25 Apr 2022 12:19:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650914356; cv=none; d=google.com; s=arc-20160816; b=mVpS3LV/NH7hmUl1taBbSxPbTEhljRjI5CH9gPiwe2zh7iJ+hTm9erWBe4cbhSF/WD ojJfOu5DWFAby3JjzwhkHDGxBQ5lwYEFE8ddE5vxtxu1M7QuFqAeaNcfMMC9uOoNb/nc 1sE+mjKVOedJeNuX/gTICj7dd9IFMhyj2pWFrs+FsrGQnNmyoNe4Brk70WDDejDfiahE IpaTQVXfg6Jzk8qQYi4Q71aOI/1xQ9KHChqfSd9dXV15WzX93D29Nadmb6Rb31uBYlAR sMoyIVos7lQQiuuYrmNRNzH2bqQyng/qS7fQx0HsJnFemBtvXbdCrH03wzHVw5sqy9CQ Xdog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=bXSnvoi7do4d0Cw+AqoAw/T18ZVUWnuc6GpNpfIH19c=; b=JLLzJKy0JUO4hc3Thio47m/sgTHjmQYZwckXcjdfEvPznlFxkLm43UGgCjYo8NwHnf 82y3ss1ycam9JOTohdbTnntVbN5hlpnLWvXDkRr0vpcdhhduyKQ72+zouYrcBYQh9uGg 9+t6xnFxnM/69nzogliZbDzTW/BSDqh4NopQy0OEdhPsiDHj0Bvtufvp+V+wDjQgDcw9 tqKiIdJbgiBcQ/RPBZwyhElK2RkP7Z75Jq285Kt5P6HtFpidVyUJTERJG31gucSSgb2U 1O/QisICvP34EKCC5l74UaB19WQDSU1NmY0OZkLJ9/IJnN/MF4Hg52JVuFl9NJuoD0Fo FdZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@raspberrypi.com header.s=google header.b=BR68WEsU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=raspberrypi.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 198-20020a6301cf000000b003aaa48035adsi13339598pgb.81.2022.04.25.12.19.00; Mon, 25 Apr 2022 12:19:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@raspberrypi.com header.s=google header.b=BR68WEsU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=raspberrypi.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239327AbiDYQK3 (ORCPT + 99 others); Mon, 25 Apr 2022 12:10:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240107AbiDYQK2 (ORCPT ); Mon, 25 Apr 2022 12:10:28 -0400 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8F6A3D4A7 for ; Mon, 25 Apr 2022 09:07:23 -0700 (PDT) Received: by mail-ed1-x533.google.com with SMTP id d6so13925510ede.8 for ; Mon, 25 Apr 2022 09:07:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=bXSnvoi7do4d0Cw+AqoAw/T18ZVUWnuc6GpNpfIH19c=; b=BR68WEsUU9ruE04R4C4gbsu8wC2yAPqXm017Rao0x8cacuQmHe1eOgwJYKQH0jzmJ4 oSoRBzz29bJ22lqPwFCiuv9ainoLDkhAoTNF70iaDOAtzBhgznhbLlCNdb9Hrycbb9EL 4ujvLSOQApuUAw63cRM6u13KDYE7yArbn4czXZ3YuO9FgPuZibXY9I2/GQ4Mb/1fKmBi TTFrbSSgUcVj1aNVfjRAHtZKI3FdxztPvsSAXKpAMZq688yfX6ERkW1zarAtgeHX58Zq GxdRR3qL4JXJx3KJpxrzpGshXdOwjVLhpaMlcKYb76RCssgP6EmhJLx/s1Y6NJRpkhY5 T2Kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=bXSnvoi7do4d0Cw+AqoAw/T18ZVUWnuc6GpNpfIH19c=; b=2nXaDVwmqMthq3rpbacvwNgekVDrMh9P7BAbEdNKvL2xT2sAtHtWty/QR+4+8QgS+7 NGK2+fYfIcWdvDZ6xl+EokTdEbHVEIJF02+98E5Upu+SliYKKXTIcczlddluY0i9MzqB RDDgIzB5+kViBk3GD07atGM4BrB8yb8Z+0EOLZze8HyWeJHZ1kY50hOaBzoBUbAb8WUL zHy0QpTR/EuT8+pxSwegmpz8b2zUKujrRjKKSw+obbf9BvcoBmYmw/wZfGj/L16are0x o8sv382D4aK8aBi1c8+k1+Ona2g9HY07WgvLnswEyON94wHJypSTO6G8jgcvYLMpuGAV 53PA== X-Gm-Message-State: AOAM533Dcvp1y96U4dgXelZCd/516kfB7HaiSRwLe5q5qU2kLWc2mLS4 7O8KyyKtuzvTNsJSURtKprwZiyRm78c8RGGrKv6zzA== X-Received: by 2002:a50:d08b:0:b0:425:eb86:f36d with SMTP id v11-20020a50d08b000000b00425eb86f36dmr5027784edd.235.1650902842151; Mon, 25 Apr 2022 09:07:22 -0700 (PDT) MIME-Version: 1.0 References: <20220412135534.2796158-1-aford173@gmail.com> <20220412135534.2796158-5-aford173@gmail.com> In-Reply-To: <20220412135534.2796158-5-aford173@gmail.com> From: Dave Stevenson Date: Mon, 25 Apr 2022 17:07:06 +0100 Message-ID: Subject: Re: [PATCH 4/4] media: i2c: imx219: Create DPHY helper function To: Adam Ford Cc: Linux Media Mailing List , Lad Prabhakar , Tim Harvey , cstevens@beaconembedded.com, aford@beaconembedded.com, Laurent Pinchart , Mauro Carvalho Chehab , LKML Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Adam On Tue, 12 Apr 2022 at 14:55, Adam Ford wrote: > > In the table of modes, each mode sets the DPHY to auto. > Create a helper function which does the same thing while > removing the entry for auto DPHY from ever mode entry. s/ever/every > > Signed-off-by: Adam Ford > --- > drivers/media/i2c/imx219.c | 24 ++++++++++++++++++++---- > 1 file changed, 20 insertions(+), 4 deletions(-) > > diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c > index 08e7d0e72430..bb0bc1b8d91c 100644 > --- a/drivers/media/i2c/imx219.c > +++ b/drivers/media/i2c/imx219.c > @@ -35,6 +35,10 @@ > #define IMX219_MODE_STANDBY 0x00 > #define IMX219_MODE_STREAMING 0x01 > > + > +#define IMX219_REG_DPHY_CTRL 0x0128 > +#define IMX219_DPHY_AUTO 0 > + > /* Chip ID */ > #define IMX219_REG_CHIP_ID 0x0000 > #define IMX219_CHIP_ID 0x0219 > @@ -183,7 +187,6 @@ static const struct imx219_reg pll_clk_table[] = { > * 3280x2464 = mode 2, 1920x1080 = mode 1, 1640x1232 = mode 4, 640x480 = mode 7. > */ > static const struct imx219_reg mode_3280x2464_regs[] = { > - {0x0128, 0x00}, > {0x012b, 0x00}, > {0x0164, 0x00}, > {0x0165, 0x00}, > @@ -222,7 +225,6 @@ static const struct imx219_reg mode_3280x2464_regs[] = { > }; > > static const struct imx219_reg mode_1920_1080_regs[] = { > - {0x0128, 0x00}, > {0x012b, 0x00}, > {0x0162, 0x0d}, > {0x0163, 0x78}, > @@ -261,7 +263,6 @@ static const struct imx219_reg mode_1920_1080_regs[] = { > }; > > static const struct imx219_reg mode_1640_1232_regs[] = { > - {0x0128, 0x00}, > {0x012b, 0x00}, > {0x0164, 0x00}, > {0x0165, 0x00}, > @@ -300,7 +301,6 @@ static const struct imx219_reg mode_1640_1232_regs[] = { > }; > > static const struct imx219_reg mode_640_480_regs[] = { > - {0x0128, 0x00}, > {0x012b, 0x00}, > {0x0162, 0x0d}, > {0x0163, 0x78}, > @@ -999,6 +999,15 @@ static int imx219_get_selection(struct v4l2_subdev *sd, > return -EINVAL; > } > > +static int imx219_enable_dphy(struct imx219 *imx219, u8 mode) > +{ > + int ret; > + > + ret = imx219_write_reg(imx219, IMX219_REG_DPHY_CTRL, > + IMX219_REG_VALUE_08BIT, mode); Is there a specific reason to extract this one register, but leave the block {0x455e, 0x00}, {0x471e, 0x4b}, {0x4767, 0x0f}, {0x4750, 0x14}, {0x4540, 0x00}, {0x47b4, 0x14}, {0x4713, 0x30}, {0x478b, 0x10}, {0x478f, 0x10}, {0x4793, 0x10}, {0x4797, 0x0e}, {0x479b, 0x0e}, {0x0162, 0x0d}, {0x0163, 0x78}, that appear to also be common to all modes. Other drivers break that lot out into a global registers array that is always sent, rather than individual register writes. Having this one register extra write as a new function is actually likely to increase the size of the module overall, instead of reducing it. Dave > + return ret; > +}; > + > static int imx219_configure_lanes(struct imx219 *imx219) > { > int ret; > @@ -1081,6 +1090,13 @@ static int imx219_start_streaming(struct imx219 *imx219) > goto err_rpm_put; > } > > + /* Setup DPHY */ > + ret = imx219_enable_dphy(imx219, IMX219_DPHY_AUTO); > + if (ret) { > + dev_err(&client->dev, "%s failed to configure dphy\n", __func__); > + goto err_rpm_put; > + } > + > /* Configure clock based on reference clock frequency */ > imx219_set_exck_freq(imx219); > > -- > 2.34.1 >