From patchwork Mon Mar 14 15:23:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Stach X-Patchwork-Id: 33457 Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.84_2) (envelope-from ) id 1afULQ-0004hA-QU; Mon, 14 Mar 2016 15:23:44 +0000 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.76/mailfrontend-6) with esmtp id 1afULO-0007Cp-5n; Mon, 14 Mar 2016 16:23:44 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934549AbcCNPXk (ORCPT + 1 other); Mon, 14 Mar 2016 11:23:40 -0400 Received: from metis.ext.4.pengutronix.de ([92.198.50.35]:32874 "EHLO metis.ext.4.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934470AbcCNPXj (ORCPT ); Mon, 14 Mar 2016 11:23:39 -0400 Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7] helo=dude.pengutronix.de.) by metis.ext.pengutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1afULJ-0003LL-Sw; Mon, 14 Mar 2016 16:23:37 +0100 From: Lucas Stach To: Mauro Carvalho Chehab , linux-media@vger.kernel.org Cc: kernel@pengutronix.de, patchwork-lst@pengutronix.de Subject: [PATCH v3 3/9] [media] tvp5150: determine BT.656 or YUV 4:2:2 mode from device tree Date: Mon, 14 Mar 2016 16:23:31 +0100 Message-Id: <1457969017-4088-3-git-send-email-l.stach@pengutronix.de> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1457969017-4088-1-git-send-email-l.stach@pengutronix.de> References: <1457969017-4088-1-git-send-email-l.stach@pengutronix.de> X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: l.stach@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-media@vger.kernel.org Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-PMX-Version: 6.0.0.2142326, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2016.3.14.151517 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' MULTIPLE_RCPTS 0.1, HTML_00_01 0.05, HTML_00_10 0.05, BODY_SIZE_3000_3999 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, NO_URI_HTTPS 0, REFERENCES 0, SINGLE_URI_IN_BODY 0, URI_ENDS_IN_HTML 0, __ANY_URI 0, __CP_MEDIA_BODY 0, __CP_URI_IN_BODY 0, __HAS_FROM 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __HAS_X_MAILING_LIST 0, __IN_REP_TO 0, __MIME_TEXT_ONLY 0, __MULTIPLE_RCPTS_CC_X2 0, __REFERENCES 0, __SANE_MSGID 0, __SINGLE_URI_TEXT 0, __SUBJ_ALPHA_END 0, __TO_MALFORMED_2 0, __URI_IN_BODY 0, __URI_NO_WWW 0, __URI_NS , __URI_WITH_PATH 0' From: Philipp Zabel By looking at the endpoint flags, it can be determined whether the link should be of V4L2_MBUS_PARALLEL or V4L2_MBUS_BT656 type. Disable the dedicated HSYNC/VSYNC outputs in BT.656 mode. For devices that are not instantiated through DT the current behavior is preserved. Signed-off-by: Philipp Zabel Signed-off-by: Lucas Stach --- drivers/media/i2c/tvp5150.c | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c index 67312c9d83c1..f6720d1d09ea 100644 --- a/drivers/media/i2c/tvp5150.c +++ b/drivers/media/i2c/tvp5150.c @@ -11,10 +11,12 @@ #include #include #include +#include #include #include #include #include +#include #include "tvp5150_reg.h" @@ -38,6 +40,7 @@ struct tvp5150 { struct v4l2_subdev sd; struct media_pad pad; struct v4l2_ctrl_handler hdl; + enum v4l2_mbus_type bus_type; struct v4l2_mbus_framefmt format; struct v4l2_rect rect; struct regmap *regmap; @@ -424,8 +427,6 @@ static const struct i2c_reg_value tvp5150_init_enable[] = { TVP5150_MISC_CTL, 0x6f },{ /* Activates video std autodetection for all standards */ TVP5150_AUTOSW_MSK, 0x0 - },{ /* Default format: 0x47. For 4:2:2: 0x40 */ - TVP5150_DATA_RATE_SEL, 0x47 },{ TVP5150_CHROMA_PROC_CTL_1, 0x0c },{ @@ -760,6 +761,25 @@ static int tvp5150_reset(struct v4l2_subdev *sd, u32 val) /* Initializes TVP5150 to stream enabled values */ tvp5150_write_inittab(sd, tvp5150_init_enable); + switch (decoder->bus_type) { + case V4L2_MBUS_BT656: + /* 8-bit ITU BT.656 */ + regmap_update_bits(decoder->regmap, TVP5150_DATA_RATE_SEL, + 0x7, 0x7); + /* disable HSYNC, VSYNC/PALI, AVID, and FID/GLCO */ + regmap_update_bits(decoder->regmap, TVP5150_MISC_CTL, 0x4, 0x0); + break; + case V4L2_MBUS_PARALLEL: + /* 8-bit YUV 4:2:2 */ + regmap_update_bits(decoder->regmap, TVP5150_DATA_RATE_SEL, + 0x7, 0x0); + /* enable HSYNC, VSYNC/PALI, AVID, and FID/GLCO */ + regmap_update_bits(decoder->regmap, TVP5150_MISC_CTL, 0x4, 0x4); + break; + default: + return -EINVAL; + } + /* Initialize image preferences */ v4l2_ctrl_handler_setup(&decoder->hdl); @@ -1332,6 +1352,8 @@ static struct regmap_config tvp5150_config = { static int tvp5150_probe(struct i2c_client *c, const struct i2c_device_id *id) { + struct v4l2_of_endpoint bus_cfg; + struct device_node *endpoint; struct tvp5150 *core; struct v4l2_subdev *sd; struct regmap *map; @@ -1398,6 +1420,14 @@ static int tvp5150_probe(struct i2c_client *c, } } + endpoint = of_graph_get_next_endpoint(c->dev.of_node, NULL); + if (endpoint) { + v4l2_of_parse_endpoint(endpoint, &bus_cfg); + core->bus_type = bus_cfg.bus_type; + } else { + core->bus_type = V4L2_MBUS_BT656; + } + core->norm = V4L2_STD_ALL; /* Default is autodetect */ core->input = TVP5150_COMPOSITE1; core->enable = 1;