From patchwork Fri Oct 23 09:59:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 7471331 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E3C5BBEEA4 for ; Fri, 23 Oct 2015 10:00:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 02806206E3 for ; Fri, 23 Oct 2015 10:00:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F212420585 for ; Fri, 23 Oct 2015 09:59:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751731AbbJWJ75 (ORCPT ); Fri, 23 Oct 2015 05:59:57 -0400 Received: from mga09.intel.com ([134.134.136.24]:23281 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751666AbbJWJ75 (ORCPT ); Fri, 23 Oct 2015 05:59:57 -0400 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 23 Oct 2015 02:59:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,186,1444719600"; d="scan'208";a="801005133" Received: from paasikivi.fi.intel.com ([10.237.72.42]) by orsmga001.jf.intel.com with ESMTP; 23 Oct 2015 02:59:55 -0700 Received: from nauris.fi.intel.com (nauris.localdomain [192.168.240.2]) by paasikivi.fi.intel.com (Postfix) with ESMTP id ACAA7208F9; Fri, 23 Oct 2015 12:59:54 +0300 (EEST) Received: by nauris.fi.intel.com (Postfix, from userid 1000) id 6A82E20175; Fri, 23 Oct 2015 12:59:25 +0300 (EEST) From: Sakari Ailus To: linux-media@vger.kernel.org Cc: laurent.pinchart@ideasonboard.com Subject: [yavta PATCH 1/1] libv4l2subdev: Add support for interlacing in format Date: Fri, 23 Oct 2015 12:59:25 +0300 Message-Id: <1445594365-13501-1-git-send-email-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.1.0.231.g7484e3b Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use '=' to tell the interlacing type in format. This is optional to maintain compatibility with existing users. For instance, the following can be used to select interlaced SGRBG8 format using size 1024x768: media-ctl -V 'entity:pad [fmt:SGRBG8=INTERLACED/1024x768]' Signed-off-by: Sakari Ailus --- Hi folks, What's missing so far is printing the field in media-ctl test program. Conversion functions could be added to libv4l2subdev API if needed, I'm not sure they are. utils/media-ctl/libv4l2subdev.c | 44 +++++++++++++++++++++++++++++++++++++++-- utils/media-ctl/options.c | 5 ++++- 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/utils/media-ctl/libv4l2subdev.c b/utils/media-ctl/libv4l2subdev.c index 8015330..84551d0 100644 --- a/utils/media-ctl/libv4l2subdev.c +++ b/utils/media-ctl/libv4l2subdev.c @@ -307,7 +307,7 @@ static int v4l2_subdev_parse_format(struct media_device *media, const char *p, char **endp) { enum v4l2_mbus_pixelcode code; - unsigned int width, height; + unsigned int width, height, field; char *end; /* @@ -316,7 +316,7 @@ static int v4l2_subdev_parse_format(struct media_device *media, */ for (; isspace(*p); ++p); for (end = (char *)p; - *end != '/' && *end != ' ' && *end != '\0'; ++end); + *end != '=' && *end != '/' && *end != ' ' && *end != '\0'; ++end); code = v4l2_subdev_string_to_pixelcode(p, end - p); if (code == (enum v4l2_mbus_pixelcode)-1) { @@ -324,6 +324,45 @@ static int v4l2_subdev_parse_format(struct media_device *media, return -EINVAL; } + /* Parse interlacing */ + if (*end == '=') { + static const struct { + unsigned int field; + char *str; + } __f[] = { + { V4L2_FIELD_ANY, "ANY", }, + { V4L2_FIELD_NONE, "NONE", }, + { V4L2_FIELD_TOP, "TOP", }, + { V4L2_FIELD_BOTTOM, "BOTTOM", }, + { V4L2_FIELD_INTERLACED, "INTERLACED", }, + { V4L2_FIELD_SEQ_TB, "SEQ_TB", }, + { V4L2_FIELD_SEQ_BT, "SEQ_BT", }, + { V4L2_FIELD_ALTERNATE, "ALTERNATE", }, + { V4L2_FIELD_INTERLACED_TB, "INTERLACED_TB", }, + { V4L2_FIELD_INTERLACED_BT, "INTERLACED_BT", }, + { 0 }, + }, *f = __f; + + + p = end + 1; + for (end = (char *)p; + *end != '/' && *end != ' ' && *end != '\0'; ++end); + + for (; f->str; f++) { + if (strlen(f->str) != end - p || + strncasecmp(f->str, p, end - p)) + continue; + field = f->field; + break; + } + + if (!f->str) { + media_dbg(media, "Invalid interlacing '%.*s'\n", + end - p, p); + return -EINVAL; + } + } + p = end + 1; width = strtoul(p, &end, 10); if (*end != 'x') { @@ -339,6 +378,7 @@ static int v4l2_subdev_parse_format(struct media_device *media, format->width = width; format->height = height; format->code = code; + format->field = field; return 0; } diff --git a/utils/media-ctl/options.c b/utils/media-ctl/options.c index ffaffcd..a241699 100644 --- a/utils/media-ctl/options.c +++ b/utils/media-ctl/options.c @@ -58,10 +58,13 @@ static void usage(const char *argv0) printf("\tv4l2-properties = v4l2-property { ',' v4l2-property } ;\n"); printf("\tv4l2-property = v4l2-mbusfmt | v4l2-crop | v4l2-interval\n"); printf("\t | v4l2-compose | v4l2-interval ;\n"); - printf("\tv4l2-mbusfmt = 'fmt:' fcc '/' size ;\n"); + printf("\tv4l2-mbusfmt = 'fmt:' fcc { '=' v4l2-interlace } '/' size ;\n"); printf("\tv4l2-crop = 'crop:' rectangle ;\n"); printf("\tv4l2-compose = 'compose:' rectangle ;\n"); printf("\tv4l2-interval = '@' numerator '/' denominator ;\n"); + printf("\tv4l2-interlace = 'ANY' | 'NONE' | 'TOP' | 'BOTTOM' | 'INTERLACED'\n"); + printf("\t | 'SEQ_TB' | 'SEQ_BT' | 'ALTERNATE'\n"); + printf("\t | 'INTERLACED_TB' | 'INTERLACED_BT'\n"); printf("\n"); printf("\trectangle = '(' left ',' top, ')' '/' size ;\n"); printf("\tsize = width 'x' height ;\n");