From patchwork Thu Jan 5 14:57:39 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Martin X-Patchwork-Id: 9375 Return-path: Envelope-to: mchehab@canuck.infradead.org Delivery-date: Thu, 05 Jan 2012 14:57:53 +0000 Received: from canuck.infradead.org [134.117.69.58] by gaivota with IMAP (fetchmail-6.3.20) for (single-drop); Thu, 05 Jan 2012 12:59:44 -0200 (BRST) Received: from casper.infradead.org ([2001:770:15f::2]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1RiolN-0003By-JR for mchehab@canuck.infradead.org; Thu, 05 Jan 2012 14:57:53 +0000 Received: from vger.kernel.org ([209.132.180.67]) by casper.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1RiolL-0005kL-VI; Thu, 05 Jan 2012 14:57:52 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753709Ab2AEO5t (ORCPT + 1 other); Thu, 5 Jan 2012 09:57:49 -0500 Received: from mail-ww0-f42.google.com ([74.125.82.42]:50199 "EHLO mail-ww0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753438Ab2AEO5t (ORCPT ); Thu, 5 Jan 2012 09:57:49 -0500 Received: by wgbds13 with SMTP id ds13so659477wgb.1 for ; Thu, 05 Jan 2012 06:57:48 -0800 (PST) Received: by 10.180.109.77 with SMTP id hq13mr876787wib.7.1325775467909; Thu, 05 Jan 2012 06:57:47 -0800 (PST) Received: from localhost.localdomain (220.51.18.95.dynamic.jazztel.es. [95.18.51.220]) by mx.google.com with ESMTPS id d9sm462698wiy.2.2012.01.05.06.57.45 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 05 Jan 2012 06:57:46 -0800 (PST) From: Javier Martin To: linux-media@vger.kernel.org Cc: mchehab@infradead.org, hverkuil@xs4all.nl, Javier Martin Subject: [PATCH v2] media: tvp5150: Add mbus_fmt callbacks. Date: Thu, 5 Jan 2012 15:57:39 +0100 Message-Id: <1325775459-22103-1-git-send-email-javier.martin@vista-silicon.com> X-Mailer: git-send-email 1.7.0.4 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org These callbacks allow a host video driver to poll video formats supported by tvp5150. --- Changes since v1: Fix standard handling in tvp5150_mbus_fmt() --- drivers/media/video/tvp5150.c | 67 +++++++++++++++++++++++++++++++++++++++++ 1 files changed, 67 insertions(+), 0 deletions(-) diff --git a/drivers/media/video/tvp5150.c b/drivers/media/video/tvp5150.c index 26cc75b..c58c8d5 100644 --- a/drivers/media/video/tvp5150.c +++ b/drivers/media/video/tvp5150.c @@ -778,6 +778,70 @@ static int tvp5150_s_ctrl(struct v4l2_ctrl *ctrl) return -EINVAL; } +static v4l2_std_id tvp5150_read_std(struct v4l2_subdev *sd) +{ + int val = tvp5150_read(sd, TVP5150_STATUS_REG_5); + + switch (val & 0x0F) { + case 0x01: + return V4L2_STD_NTSC; + case 0x03: + return V4L2_STD_PAL; + case 0x05: + return V4L2_STD_PAL_M; + case 0x07: + return V4L2_STD_PAL_N | V4L2_STD_PAL_Nc; + case 0x09: + return V4L2_STD_NTSC_443; + case 0xb: + return V4L2_STD_SECAM; + default: + return V4L2_STD_UNKNOWN; + } +} + +static int tvp5150_enum_mbus_fmt(struct v4l2_subdev *sd, unsigned index, + enum v4l2_mbus_pixelcode *code) +{ + if (index) + return -EINVAL; + + *code = V4L2_MBUS_FMT_YUYV8_2X8; + return 0; +} + +static int tvp5150_mbus_fmt(struct v4l2_subdev *sd, + struct v4l2_mbus_framefmt *f) +{ + struct tvp5150 *decoder = to_tvp5150(sd); + v4l2_std_id std; + + if (f == NULL) + return -EINVAL; + + tvp5150_reset(sd, 0); + + /* Calculate height and width based on current standard */ + if (decoder->norm == V4L2_STD_ALL) + std = tvp5150_read_std(sd); + else + std = decoder->norm; + + f->width = 720; + if (std & V4L2_STD_525_60) + f->height = 480; + else + f->height = 576; + + f->code = V4L2_MBUS_FMT_YUYV8_2X8; + f->field = V4L2_FIELD_SEQ_TB; + f->colorspace = V4L2_COLORSPACE_SMPTE170M; + + v4l2_dbg(1, debug, sd, "width = %d, height = %d\n", f->width, + f->height); + return 0; +} + /**************************************************************************** I2C Command ****************************************************************************/ @@ -930,6 +994,9 @@ static const struct v4l2_subdev_tuner_ops tvp5150_tuner_ops = { static const struct v4l2_subdev_video_ops tvp5150_video_ops = { .s_routing = tvp5150_s_routing, + .enum_mbus_fmt = tvp5150_enum_mbus_fmt, + .s_mbus_fmt = tvp5150_mbus_fmt, + .try_mbus_fmt = tvp5150_mbus_fmt, }; static const struct v4l2_subdev_vbi_ops tvp5150_vbi_ops = {