From patchwork Tue May 14 10:45:34 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 2565061 Return-Path: X-Original-To: patchwork-davinci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from comal.ext.ti.com (comal.ext.ti.com [198.47.26.152]) by patchwork2.kernel.org (Postfix) with ESMTP id C6255DF24C for ; Tue, 14 May 2013 10:47:44 +0000 (UTC) Received: from dflxv15.itg.ti.com ([128.247.5.124]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id r4EAliLn016418 for ; Tue, 14 May 2013 05:47:44 -0500 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id r4EAlive009282 for ; Tue, 14 May 2013 05:47:44 -0500 Received: from dlelxv23.itg.ti.com (172.17.1.198) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.2.342.3; Tue, 14 May 2013 05:47:43 -0500 Received: from linux.omap.com (dlelxs01.itg.ti.com [157.170.227.31]) by dlelxv23.itg.ti.com (8.13.8/8.13.8) with ESMTP id r4EAlioo005041 for ; Tue, 14 May 2013 05:47:44 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 15DE580626 for ; Tue, 14 May 2013 05:47:44 -0500 (CDT) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dflp53.itg.ti.com (dflp53.itg.ti.com [128.247.5.6]) by linux.omap.com (Postfix) with ESMTP id 92C9F80626 for ; Tue, 14 May 2013 05:47:19 -0500 (CDT) Received: from medina.ext.ti.com (medina.ext.ti.com [192.91.81.31]) by dflp53.itg.ti.com (8.13.8/8.13.8) with ESMTP id r4EAlJKe006189 for ; Tue, 14 May 2013 05:47:19 -0500 (CDT) Received: from mail6.bemta8.messagelabs.com (mail6.bemta8.messagelabs.com [216.82.243.55]) by medina.ext.ti.com (8.13.7/8.13.7) with ESMTP id r4EAlI9f032012 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 14 May 2013 05:47:19 -0500 Received: from [216.82.242.147:17177] by server-15.bemta-8.messagelabs.com id 11/4D-15247-63612915; Tue, 14 May 2013 10:47:18 +0000 X-Env-Sender: prabhakar.csengg@gmail.com X-Msg-Ref: server-12.tower-95.messagelabs.com!1368528436!23923963!1 X-Originating-IP: [209.85.210.44] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG, ML_RADAR_SPEW_LINKS_14,spamassassin: X-StarScan-Received: X-StarScan-Version: 6.8.6.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 10207 invoked from network); 14 May 2013 10:47:17 -0000 Received: from mail-da0-f44.google.com (HELO mail-da0-f44.google.com) (209.85.210.44) by server-12.tower-95.messagelabs.com with RC4-SHA encrypted SMTP; 14 May 2013 10:47:17 -0000 Received: by mail-da0-f44.google.com with SMTP id z8so237399daj.17 for ; Tue, 14 May 2013 03:47:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=7WRoO/yQBbzNtOZnDZBmr6UKCPfX84fTO5cI5jQ3L30=; b=ahiWROoIKhpe+79peTW/afkwaa5GNNECbQX+GmYLWl/08LyKXbuPGNg4mqforA781Q WKszwZjrsjOuoCYeY5k5a1zcgcKDMUIsegMxaEYEmgO8O+uenffaTBwRtr2pcC7zPTC0 mX/Y1hJ6IXqc9Oq9QfupRdpPRXxAJ6OlZfR0b8C9dSjLEpqFieubd0Fm5kqolme2Ffj1 Bwp9cWVk6q9k1KBjVS/tAJ7QqNUTAMmw17tJaRFCcqWG5ZLhjUGGeUHRh6o4JNWwo7rQ 7kJzXW0kkrx2aNf8+t4Iy51sNJUVn9MCowmJI5zqRwbKxnGfRpTOfD6dQB8k+eWr26tb 2BqA== X-Received: by 10.67.1.39 with SMTP id bd7mr33077994pad.194.1368528436497; Tue, 14 May 2013 03:47:16 -0700 (PDT) Received: from localhost.localdomain ([59.98.240.128]) by mx.google.com with ESMTPSA id nt2sm17784107pbc.17.2013.05.14.03.47.08 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 14 May 2013 03:47:15 -0700 (PDT) From: Lad Prabhakar To: LMML Subject: [PATCH 5/5] media: i2c: tvp7002: add OF support Date: Tue, 14 May 2013 16:15:34 +0530 Message-ID: <1368528334-13595-6-git-send-email-prabhakar.csengg@gmail.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1368528334-13595-1-git-send-email-prabhakar.csengg@gmail.com> References: <1368528334-13595-1-git-send-email-prabhakar.csengg@gmail.com> CC: Rob Landley , DLOS , Mauro Carvalho Chehab , , , LKML , Rob Herring , Grant Likely , Hans Verkuil , Laurent Pinchart , Sylwester Nawrocki , Sakari Ailus , Guennadi Liakhovetski X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: Errors-To: davinci-linux-open-source-bounces+patchwork-davinci=patchwork.kernel.org@linux.davincidsp.com From: Lad, Prabhakar add OF support for the tvp7002 driver. Signed-off-by: Lad, Prabhakar Cc: Hans Verkuil Cc: Laurent Pinchart Cc: Mauro Carvalho Chehab Cc: Guennadi Liakhovetski Cc: Sylwester Nawrocki Cc: Sakari Ailus Cc: Grant Likely Cc: Rob Herring Cc: Rob Landley Cc: devicetree-discuss@lists.ozlabs.org Cc: linux-doc@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: davinci-linux-open-source@linux.davincidsp.com --- .../devicetree/bindings/media/i2c/tvp7002.txt | 42 +++++++++++++ drivers/media/i2c/tvp7002.c | 64 +++++++++++++++++-- 2 files changed, 99 insertions(+), 7 deletions(-) create mode 100644 Documentation/devicetree/bindings/media/i2c/tvp7002.txt diff --git a/Documentation/devicetree/bindings/media/i2c/tvp7002.txt b/Documentation/devicetree/bindings/media/i2c/tvp7002.txt new file mode 100644 index 0000000..1ebd8b1 --- /dev/null +++ b/Documentation/devicetree/bindings/media/i2c/tvp7002.txt @@ -0,0 +1,42 @@ +* Texas Instruments TV7002 video decoder + +The TVP7002 device supports digitizing of video and graphics signal in RGB and +YPbPr color space. + +Required Properties : +- compatible : Must be "ti,tvp7002" + +- hsync-active: HSYNC Polarity configuration for endpoint. + +- vsync-active: VSYNC Polarity configuration for endpoint. + +- pclk-sample: Clock polarity of the endpoint. + +- ti,tvp7002-fid-polarity: Active-high Field ID polarity of the endpoint. + +- ti,tvp7002-sog-polarity: Sync on Green output polarity of the endpoint. + +For further reading of port node refer Documentation/devicetree/bindings/media/ +video-interfaces.txt. + +Example: + + i2c0@1c22000 { + ... + ... + tvp7002@5c { + compatible = "ti,tvp7002"; + reg = <0x5c>; + + port { + tvp7002_1: endpoint { + hsync-active = <1>; + vsync-active = <1>; + pclk-sample = <0>; + ti,tvp7002-fid-polarity; + ti,tvp7002-sog-polarity; + }; + }; + }; + ... + }; diff --git a/drivers/media/i2c/tvp7002.c b/drivers/media/i2c/tvp7002.c index d5113d1..942e0d8 100644 --- a/drivers/media/i2c/tvp7002.c +++ b/drivers/media/i2c/tvp7002.c @@ -35,6 +35,7 @@ #include #include #include +#include #include "tvp7002_reg.h" @@ -976,6 +977,46 @@ static const struct v4l2_subdev_ops tvp7002_ops = { .pad = &tvp7002_pad_ops, }; +static struct tvp7002_config * +tvp7002_get_pdata(struct i2c_client *client) +{ + struct v4l2_of_endpoint bus_cfg; + struct tvp7002_config *pdata; + struct device_node *endpoint; + unsigned int flags; + + if (!IS_ENABLED(CONFIG_OF) || !client->dev.of_node) + return client->dev.platform_data; + + endpoint = v4l2_of_get_next_endpoint(client->dev.of_node, NULL); + if (!endpoint) + return NULL; + + pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL); + if (!pdata) + return NULL; + + v4l2_of_parse_endpoint(endpoint, &bus_cfg); + flags = bus_cfg.bus.parallel.flags; + + if (flags & V4L2_MBUS_HSYNC_ACTIVE_HIGH) + pdata->hs_polarity = 1; + + if (flags & V4L2_MBUS_VSYNC_ACTIVE_HIGH) + pdata->vs_polarity = 1; + + if (flags & V4L2_MBUS_PCLK_SAMPLE_RISING) + pdata->clk_polarity = 1; + + pdata->fid_polarity = of_property_read_bool(endpoint, + "ti,tvp7002-fid-polarity"); + + pdata->sog_polarity = of_property_read_bool(endpoint, + "ti,tvp7002-sog-polarity"); + + return pdata; +} + /* * tvp7002_probe - Probe a TVP7002 device * @c: ptr to i2c_client struct @@ -987,32 +1028,32 @@ static const struct v4l2_subdev_ops tvp7002_ops = { */ static int tvp7002_probe(struct i2c_client *c, const struct i2c_device_id *id) { + struct tvp7002_config *pdata = tvp7002_get_pdata(c); struct v4l2_subdev *sd; struct tvp7002 *device; struct v4l2_dv_timings timings; int polarity_a; int polarity_b; u8 revision; - int error; + if (pdata == NULL) { + dev_err(&c->dev, "No platform data\n"); + return -EINVAL; + } + /* Check if the adapter supports the needed features */ if (!i2c_check_functionality(c->adapter, I2C_FUNC_SMBUS_READ_BYTE | I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) return -EIO; - if (!c->dev.platform_data) { - v4l_err(c, "No platform data!!\n"); - return -ENODEV; - } - device = devm_kzalloc(&c->dev, sizeof(struct tvp7002), GFP_KERNEL); if (!device) return -ENOMEM; sd = &device->sd; - device->pdata = c->dev.platform_data; + device->pdata = pdata; device->current_timings = tvp7002_timings; /* Tell v4l2 the device is ready */ @@ -1119,9 +1160,18 @@ static const struct i2c_device_id tvp7002_id[] = { }; MODULE_DEVICE_TABLE(i2c, tvp7002_id); +#if IS_ENABLED(CONFIG_OF) +static const struct of_device_id tvp7002_of_match[] = { + { .compatible = "ti,tvp7002", }, + { /* sentinel */ }, +}; +MODULE_DEVICE_TABLE(of, tvp7002_of_match); +#endif + /* I2C driver data */ static struct i2c_driver tvp7002_driver = { .driver = { + .of_match_table = of_match_ptr(tvp7002_of_match), .owner = THIS_MODULE, .name = TVP7002_MODULE_NAME, },