From patchwork Fri Aug 27 13:01:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 12462045 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5A608C432BE for ; Fri, 27 Aug 2021 13:02:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 340DB60F4F for ; Fri, 27 Aug 2021 13:02:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233662AbhH0NCx (ORCPT ); Fri, 27 Aug 2021 09:02:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231271AbhH0NCw (ORCPT ); Fri, 27 Aug 2021 09:02:52 -0400 Received: from mail-qk1-x734.google.com (mail-qk1-x734.google.com [IPv6:2607:f8b0:4864:20::734]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2320C061757 for ; Fri, 27 Aug 2021 06:02:03 -0700 (PDT) Received: by mail-qk1-x734.google.com with SMTP id ay33so6989809qkb.10 for ; Fri, 27 Aug 2021 06:02: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:mime-version :content-transfer-encoding; bh=+Gn3ssrTPiGbG5p9f9KeoHn60QMJHlHG0mXvevvyVP0=; b=LXPwZ9Car2S+sK3HSQaXfFOC3x1uNNmqOgJQXnihE67i7EwLbPxUaYCoVFAfbdevrY cSaKn3lyo12qM+UwTt/bOQXDWQLBiEAUpNFnekZ4VH0B7Xp5TCuTkfleG0ziA9C6QVwO Qt57/bodLB/dNC2fhzbYlEbxeBN/7XQGswjNHfPL+v82Md4GczvYqjeqmdHWqGqHnGkD xGA8aSwQ0qBtRsPZSKZOtbh5MSht8NvX5wgHwZMKfcKbs/VAFFXSvp++ODVcCUk5j4Nz SrWD0W6CzhQBgMAX+AySSC91Snq6KKUThyp8KcQLSd2bA6YsewfkX8jjpHlVO+0L0GPy JapQ== 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:mime-version :content-transfer-encoding; bh=+Gn3ssrTPiGbG5p9f9KeoHn60QMJHlHG0mXvevvyVP0=; b=FQcbV+5ZQNcU0JWrMM5DTWPfVQ5yzGW3yGUuOPDJAoAJldO6yx6lnD95zsA9y+6DyI PudftMQgtzxOtjqteMOZW1G61+Rh0lbttEsd8JWLjpbUYOJUbllnJoD4HWb5w4HOplZp u+do3O+MLdp7fjaaDb1yZnJvMoHEMXO4XWr0kqhOZ1/i+JuT4YrMXDcJt2sMiKDRx6BL qPvYaZJXJIf/tND5NeJ0QwBIwAPuGvkIzCLtju1p7jlSoXFtMlvT7sCLCXfe+qqb6h6n g5/jSX5scZaJ842LFQuk6FYbOZ66RTF9NRWU5YpCIuQZZBkcMJKRvQZOv1i8JX6EBfZq 0kOg== X-Gm-Message-State: AOAM533Qg2afpSBCNApLVMGK9f0hhnIUZr8R6XdZm9w5aZ3z+4+eqhyR BaNrMyrwJfO62t/xxuJvSWk= X-Google-Smtp-Source: ABdhPJxzJJKHJEF63Kis1F3WvWj0OeBh0UzUw1BFn8ibYDcidjo6eK6TFsEhBisjCOIWdF4/b33LOA== X-Received: by 2002:ae9:f70e:: with SMTP id s14mr9526006qkg.38.1630069321736; Fri, 27 Aug 2021 06:02:01 -0700 (PDT) Received: from localhost.localdomain ([2804:14c:485:504a:a04e:f46c:17c2:7e75]) by smtp.gmail.com with ESMTPSA id v14sm4676346qkb.88.2021.08.27.06.01.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Aug 2021 06:02:01 -0700 (PDT) From: Fabio Estevam To: laurent.pinchart@ideasonboard.com Cc: hverkuil-cisco@xs4all.nl, linux-media@vger.kernel.org, jacopo+renesas@jmondi.org, morimoto.kuninori@renesas.com, Fabio Estevam Subject: [RFC 1/3] media: tw9910: Allow to probe from device tree Date: Fri, 27 Aug 2021 10:01:48 -0300 Message-Id: <20210827130150.909695-1-festevam@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Currently the driver only probes via platform data passed from board file. Allow to probe from device tree too. Signed-off-by: Fabio Estevam --- Hi, I am currently sending this series as RFC because I was not able to get the TW9990 to work on a imx6sx board yet. # media-ctl -p Media controller API version 5.14.0 Media device information ------------------------ driver imx7-csi model imx-media serial bus info hw revision 0x0 driver version 5.14.0 Device topology - entity 1: csi (2 pads, 2 links) type V4L2 subdev subtype Unknown flags 0 device node name /dev/v4l-subdev0 pad0: Sink [fmt:UYVY8_2X8/800x600 field:none colorspace:srgb xfer:srgb ycbcr:601 quantization:lim-range] <- "tw9910 2-0044":0 [ENABLED,IMMUTABLE] pad1: Source [fmt:UYVY8_2X8/800x600 field:none colorspace:srgb xfer:srgb ycbcr:601 quantization:lim-range] -> "csi capture":0 [ENABLED,IMMUTABLE] - entity 4: csi capture (1 pad, 1 link) type Node subtype V4L flags 0 device node name /dev/video0 pad0: Sink <- "csi":1 [ENABLED,IMMUTABLE] - entity 10: tw9910 2-0044 (1 pad, 1 link) type V4L2 subdev subtype Decoder flags 0 device node name /dev/v4l-subdev1 pad0: Source [fmt:UYVY8_2X8/640x480 field:interlaced-bt colorspace:smpte170m crop.bounds:(0,0)/640x480 crop:(0,0)/640x480] -> "csi":0 [ENABLED,IMMUTABLE] I get the following error when setting up the pipeline: media-ctl -l "'tw9910 2-0044':0 -> 'csi':0[1]" media-ctl -l "'csi':1 -> 'csi capture':0[1]" media-ctl -v -V "'tw9910 2-0044':0 [fmt:UYVY8_2X8/800x480 field:any]" Opening media device /dev/media0 Enumerating entities Found 3 entities Enumerating pads and links Setting up format UYVY8_2X8 800x480 on pad tw9910 2-0044/0 Unable to set format: No such device or address (-6) Unable to setup formats: No such device or address (6) This -6 (ENXIO) error comes from: tw9910_set_frame() ---> tw9910_mask_set() ---> i2c_smbus_read_byte_data(): static int tw9910_mask_set(struct i2c_client *client, u8 command, u8 mask, u8 set) { s32 val = i2c_smbus_read_byte_data(client, command); I am able to dump TW9990 registers via i2cdetect and also via the probe function, so I2C access is OK. Not sure why I am getting these i2c_smbus_read_byte_data() errors. Any ideas? Thanks! drivers/media/i2c/tw9910.c | 47 ++++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 9 deletions(-) diff --git a/drivers/media/i2c/tw9910.c b/drivers/media/i2c/tw9910.c index 09f5b3986928..04f3c2dbc1cc 100644 --- a/drivers/media/i2c/tw9910.c +++ b/drivers/media/i2c/tw9910.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -928,22 +929,27 @@ static const struct v4l2_subdev_ops tw9910_subdev_ops = { * i2c_driver function */ +static int tw9910_parse_dt(struct i2c_client *client, struct tw9910_priv *priv) +{ + priv->info = devm_kzalloc(&client->dev, sizeof(*priv->info), GFP_KERNEL); + if (!priv->info) + return -ENOMEM; + + /* Use default for now. Will retrieve from dt later */ + priv->info->mpout = 0; + priv->info->buswidth = 8; + + return 0; +} + static int tw9910_probe(struct i2c_client *client, const struct i2c_device_id *did) { struct tw9910_priv *priv; - struct tw9910_video_info *info; struct i2c_adapter *adapter = client->adapter; int ret; - if (!client->dev.platform_data) { - dev_err(&client->dev, "TW9910: missing platform data!\n"); - return -EINVAL; - } - - info = client->dev.platform_data; - if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { dev_err(&client->dev, "I2C-Adapter doesn't support I2C_FUNC_SMBUS_BYTE_DATA\n"); @@ -954,7 +960,18 @@ static int tw9910_probe(struct i2c_client *client, if (!priv) return -ENOMEM; - priv->info = info; + if (IS_ENABLED(CONFIG_OF) && client->dev.of_node) { + ret = tw9910_parse_dt(client, priv); + if (ret < 0) { + v4l_err(client, "DT parsing error\n"); + return ret; + } + } else if (client->dev.platform_data) { + priv->info = client->dev.platform_data; + } else { + v4l_err(client, "No platform data!\n"); + return -ENODEV; + } v4l2_i2c_subdev_init(&priv->subdev, client, &tw9910_subdev_ops); @@ -1007,13 +1024,25 @@ static int tw9910_remove(struct i2c_client *client) static const struct i2c_device_id tw9910_id[] = { { "tw9910", 0 }, + { "tw9990", 0 }, { } }; MODULE_DEVICE_TABLE(i2c, tw9910_id); +#ifdef CONFIG_OF +static const struct of_device_id tw9910_of_id[] = { + { .compatible = "renesas,tw9910", }, + { .compatible = "renesas,tw9990", }, + { }, +}; + +MODULE_DEVICE_TABLE(of, tw9910_of_id); +#endif + static struct i2c_driver tw9910_i2c_driver = { .driver = { .name = "tw9910", + .of_match_table = of_match_ptr(tw9910_of_id), }, .probe = tw9910_probe, .remove = tw9910_remove, From patchwork Fri Aug 27 13:01:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 12462047 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 73A5EC4320E for ; Fri, 27 Aug 2021 13:02:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5184860F92 for ; Fri, 27 Aug 2021 13:02:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241169AbhH0NCy (ORCPT ); Fri, 27 Aug 2021 09:02:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231271AbhH0NCy (ORCPT ); Fri, 27 Aug 2021 09:02:54 -0400 Received: from mail-qk1-x72f.google.com (mail-qk1-x72f.google.com [IPv6:2607:f8b0:4864:20::72f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2EC20C061757 for ; Fri, 27 Aug 2021 06:02:05 -0700 (PDT) Received: by mail-qk1-x72f.google.com with SMTP id b64so7172448qkg.0 for ; Fri, 27 Aug 2021 06:02:05 -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=0Icy42hBjHJKD15VqasMXIGICEEBU5ZU+E5t7W6Lur0=; b=CU20T8S/kEW4dfMXs5/YUVoJVGKqQbnup7+BbeLWOl13y8wQtnOzigIeiA8K7NP8NR HEKXP/vawID6TRCgIF7yslJMIrtotrpdNIFy0Dcy/ItW4MCxWViCR13JcvsZOwRU23SE Wh3bUwM+SN9RejpOft9UgML6Nnsz3pSpppmVZ2GvlV+908Myus38v1bC3sQvEI3x4JLI RRSWQCP4waUUF3ISebnfTWpz9u5CQv8IB6uLQq6ITBL3kzuo48yC6CYjcD7tdl8ouAyf cuGDD1m6DKYjlYYlimcRadvcqHTznrywmyq/TE/U2Nb23uPHV7NS+hrLzN0BsANtFBO7 RkQw== 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=0Icy42hBjHJKD15VqasMXIGICEEBU5ZU+E5t7W6Lur0=; b=XQ1zkXAs2JCaSEG1sx/mpzwKS8bKR1WDsJqBUbe1huVUFYNPLnoapMtE5DdTddlm4q e2wMwg6zQzfx5+JY7c+bj3HYFC1GNvH+YamKNB/Oyu9VF7Lf+RQjLoZkuKlKvIRdhhyc v4YhOcdEkiGO/wjiDMvBSsh4t04u5kpngo6MCxv9IlAJS09pGj8N22C8jiAwhU6Klxei xxrV1809c8+s1X9lbvloOzq0AX5UhgZ0OWJyqspaW5KxVCJOOPM9FyC+cQQFQ8QWKaGR hCRW+byykxIZL+Shg5f0UaHM7/MSGBi+rJuUmRat0Qx1kZurlfgU4kJ2lVJHPKvVBJke wXag== X-Gm-Message-State: AOAM533Q6Isz++rVGm8dXj67S1fjaqLY8cT0pX5bDZ/SIMsOQhbXnIHP RKJivvTN1sW8aScspIHe1/8= X-Google-Smtp-Source: ABdhPJyZJAdb0xumrit5sNdDATaIX0pFhahzg+VNUHnWn5BFyTlthX5jde720WyXP26gXNbTMLknng== X-Received: by 2002:a37:391:: with SMTP id 139mr8896855qkd.356.1630069324386; Fri, 27 Aug 2021 06:02:04 -0700 (PDT) Received: from localhost.localdomain ([2804:14c:485:504a:a04e:f46c:17c2:7e75]) by smtp.gmail.com with ESMTPSA id v14sm4676346qkb.88.2021.08.27.06.02.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Aug 2021 06:02:03 -0700 (PDT) From: Fabio Estevam To: laurent.pinchart@ideasonboard.com Cc: hverkuil-cisco@xs4all.nl, linux-media@vger.kernel.org, jacopo+renesas@jmondi.org, morimoto.kuninori@renesas.com, Fabio Estevam Subject: [RFC 2/3] media: tw9910: Allow the TW9990 to probe Date: Fri, 27 Aug 2021 10:01:49 -0300 Message-Id: <20210827130150.909695-2-festevam@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210827130150.909695-1-festevam@gmail.com> References: <20210827130150.909695-1-festevam@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Currently the driver rejects to probe when the ID is different from the TW9910 one. Allow TW9990 to probe by allowing its ID too. Signed-off-by: Fabio Estevam --- drivers/media/i2c/tw9910.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/i2c/tw9910.c b/drivers/media/i2c/tw9910.c index 04f3c2dbc1cc..0411b8ea9bda 100644 --- a/drivers/media/i2c/tw9910.c +++ b/drivers/media/i2c/tw9910.c @@ -859,7 +859,7 @@ static int tw9910_video_probe(struct i2c_client *client) priv->revision = GET_REV(id); id = GET_ID(id); - if (id != 0x0b || priv->revision > 0x01) { + if ((id != 0x0b && id != 0x00) || priv->revision > 0x01) { dev_err(&client->dev, "Product ID error %x:%x\n", id, priv->revision); ret = -ENODEV; From patchwork Fri Aug 27 13:01:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 12462049 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A1C41C432BE for ; Fri, 27 Aug 2021 13:02:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 841FC60F92 for ; Fri, 27 Aug 2021 13:02:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245082AbhH0NC5 (ORCPT ); Fri, 27 Aug 2021 09:02:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231271AbhH0NC4 (ORCPT ); Fri, 27 Aug 2021 09:02:56 -0400 Received: from mail-qv1-xf31.google.com (mail-qv1-xf31.google.com [IPv6:2607:f8b0:4864:20::f31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCD69C061757 for ; Fri, 27 Aug 2021 06:02:07 -0700 (PDT) Received: by mail-qv1-xf31.google.com with SMTP id a5so3968698qvq.0 for ; Fri, 27 Aug 2021 06:02:07 -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=4Ae8tyBS3KayLakZimXmbRvK7esUJ0JfQs4VESpzB6c=; b=qQyi4jUXIlbzkXcEUou/3luwiYraJSRWYLxzpco8+W5LO/DqJdYevGGQ3XKrC/JVWt CXz2u0LQp41m1wmb5m0hF86aKy5SginUPfgRyTQdU/wYRl0tLdiLgxJ6ODpTxCOPNfUU gq04CSjKRCZ0alqYqXpQNfshPhNWTfa3KNOgo9og44Y9JNzJasKAt9nd6wV9RFvbcBdM XFFbaZRYiKQZ35TkPDXJ/HtBC9N0smYHMtY3PrnKHgTOU3tE0VjhTVnqbBASvNdekmsr dB+8uz9ehqtqS6fvE9j9979dkWtE+RrcQWKoghcpamEUaSinkB31qCYP4o/9mYNvA7+B bsQA== 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=4Ae8tyBS3KayLakZimXmbRvK7esUJ0JfQs4VESpzB6c=; b=T7vVk2Gms03FnGm88Sl4dMIBW05/2lMw4NfKzDKF7Gm+QW9GXQVPdQ+xR8Hf35nas4 Ps+ciSKyUteP8IE7CSjkeQwewk0wOzK3C/ffqwyKDV+yFt/se632Fpj8G2KzrgOGS5FK nLcdfxOj+uuwYKhX5YaqXK6WonM0/J21MNaYowKLOTpk2K23kZbi0a15EctuNn84Z2fy RaLCsSYGeGfAffxWjV5JVudaqjNeVhACv851JkP6C/Em+rWHImG46dO2h3qverzbMaRV PBWQLukB4ldAlwlQDPxMYRLOEzkUoGzlzFu8Fc1hjV6UE7qHSV7fcc0j/DDEG+yr/try JiHQ== X-Gm-Message-State: AOAM531vDcD/QgT16M0h6/khbuLN7VHVxfPgXp9VaJvdcP+uwOIN56p9 GHvJDM1vnHlvsm5Vzhlmj3M= X-Google-Smtp-Source: ABdhPJwYAAsyoHk/lk7kysDKFCLXR37au+4brVbaJHtLhEsLCG4fETxmlqZ1rElZ36w7rvuEoPSphA== X-Received: by 2002:a0c:e9c3:: with SMTP id q3mr9164339qvo.42.1630069326962; Fri, 27 Aug 2021 06:02:06 -0700 (PDT) Received: from localhost.localdomain ([2804:14c:485:504a:a04e:f46c:17c2:7e75]) by smtp.gmail.com with ESMTPSA id v14sm4676346qkb.88.2021.08.27.06.02.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Aug 2021 06:02:06 -0700 (PDT) From: Fabio Estevam To: laurent.pinchart@ideasonboard.com Cc: hverkuil-cisco@xs4all.nl, linux-media@vger.kernel.org, jacopo+renesas@jmondi.org, morimoto.kuninori@renesas.com, Fabio Estevam Subject: [RFC 3/3] media: tw9910: Initialize the entity type Date: Fri, 27 Aug 2021 10:01:50 -0300 Message-Id: <20210827130150.909695-3-festevam@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210827130150.909695-1-festevam@gmail.com> References: <20210827130150.909695-1-festevam@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Currently the following warning is seen: imx7-csi 2214000.csi: Entity type for entity tw9910 2-0044 was not initialized! Initialize the entity type accordingly. Signed-off-by: Fabio Estevam --- drivers/media/i2c/tw9910.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/media/i2c/tw9910.c b/drivers/media/i2c/tw9910.c index 0411b8ea9bda..ad4149073ba4 100644 --- a/drivers/media/i2c/tw9910.c +++ b/drivers/media/i2c/tw9910.c @@ -228,6 +228,7 @@ struct tw9910_scale_ctrl { struct tw9910_priv { struct v4l2_subdev subdev; + struct media_pad pad; struct clk *clk; struct tw9910_video_info *info; struct gpio_desc *pdn_gpio; @@ -948,6 +949,7 @@ static int tw9910_probe(struct i2c_client *client, { struct tw9910_priv *priv; struct i2c_adapter *adapter = client->adapter; + struct v4l2_subdev *sd; int ret; if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { @@ -973,14 +975,22 @@ static int tw9910_probe(struct i2c_client *client, return -ENODEV; } - v4l2_i2c_subdev_init(&priv->subdev, client, &tw9910_subdev_ops); + sd = &priv->subdev; + v4l2_i2c_subdev_init(sd, client, &tw9910_subdev_ops); + priv->pad.flags = MEDIA_PAD_FL_SOURCE; + sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS; + sd->entity.function = MEDIA_ENT_F_ATV_DECODER; + ret = media_entity_pads_init(&sd->entity, 1, &priv->pad); + if (ret) + return ret; priv->clk = clk_get(&client->dev, "xti"); if (PTR_ERR(priv->clk) == -ENOENT) { priv->clk = NULL; } else if (IS_ERR(priv->clk)) { dev_err(&client->dev, "Unable to get xti clock\n"); - return PTR_ERR(priv->clk); + ret = PTR_ERR(priv->clk); + goto media_entity_cleanup; } priv->pdn_gpio = gpiod_get_optional(&client->dev, "pdn", @@ -1006,7 +1016,9 @@ static int tw9910_probe(struct i2c_client *client, gpiod_put(priv->pdn_gpio); error_clk_put: clk_put(priv->clk); - + +media_entity_cleanup: + media_entity_cleanup(&sd->entity); return ret; }