From patchwork Fri Sep 16 10:57:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 9335457 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1625E6077F for ; Fri, 16 Sep 2016 10:57:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 073D729EEA for ; Fri, 16 Sep 2016 10:57:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EDA5929F21; Fri, 16 Sep 2016 10:57:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9572729EEA for ; Fri, 16 Sep 2016 10:57:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933144AbcIPK5f (ORCPT ); Fri, 16 Sep 2016 06:57:35 -0400 Received: from lb1-smtp-cloud6.xs4all.net ([194.109.24.24]:60839 "EHLO lb1-smtp-cloud6.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932985AbcIPK5f (ORCPT ); Fri, 16 Sep 2016 06:57:35 -0400 Received: from tschai.lan ([90.149.38.145]) by smtp-cloud6.xs4all.net with ESMTP id kAxX1t00337uBN201AxaeY; Fri, 16 Sep 2016 12:57:34 +0200 Received: from durdane.fritz.box (marune.xs4all.nl [80.101.105.217]) by tschai.lan (Postfix) with ESMTPSA id 528EF181539; Fri, 16 Sep 2016 12:57:14 +0200 (CEST) From: Hans Verkuil To: linux-media@vger.kernel.org Cc: Hans Verkuil Subject: [PATCHv2 8/8] v4l2-dv-timings: add v4l2_dv_timings_cea861_aspect_ratio Date: Fri, 16 Sep 2016 12:57:11 +0200 Message-Id: <1474023431-32533-9-git-send-email-hverkuil@xs4all.nl> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1474023431-32533-1-git-send-email-hverkuil@xs4all.nl> References: <1474023431-32533-1-git-send-email-hverkuil@xs4all.nl> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Hans Verkuil This new function determines the picture aspect ratio from the DV timings and returns it in CEA-861 AVI InfoFrame format. Signed-off-by: Hans Verkuil --- drivers/media/v4l2-core/v4l2-dv-timings.c | 18 ++++++++++++++++++ include/media/v4l2-dv-timings.h | 8 ++++++++ 2 files changed, 26 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-dv-timings.c b/drivers/media/v4l2-core/v4l2-dv-timings.c index 98aa2fa..43203e9 100644 --- a/drivers/media/v4l2-core/v4l2-dv-timings.c +++ b/drivers/media/v4l2-core/v4l2-dv-timings.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -381,6 +382,23 @@ struct v4l2_fract v4l2_dv_timings_aspect_ratio(const struct v4l2_dv_timings *t) } EXPORT_SYMBOL_GPL(v4l2_dv_timings_aspect_ratio); +u8 v4l2_dv_timings_cea861_aspect_ratio(const struct v4l2_dv_timings *t) +{ + unsigned int w = t->bt.width; + unsigned int h = t->bt.height; + + if (t->bt.flags & V4L2_DV_FL_HAS_PICTURE_ASPECT) { + w = t->bt.picture_aspect.numerator; + h = t->bt.picture_aspect.denominator; + } + if (w * 3 == h * 4) + return HDMI_PICTURE_ASPECT_4_3; + if (w * 9 == h * 16) + return HDMI_PICTURE_ASPECT_16_9; + return HDMI_PICTURE_ASPECT_NONE; +} +EXPORT_SYMBOL_GPL(v4l2_dv_timings_cea861_aspect_ratio); + /* * CVT defines * Based on Coordinated Video Timings Standard diff --git a/include/media/v4l2-dv-timings.h b/include/media/v4l2-dv-timings.h index 3722ce8..efae7b1 100644 --- a/include/media/v4l2-dv-timings.h +++ b/include/media/v4l2-dv-timings.h @@ -203,6 +203,14 @@ struct v4l2_fract v4l2_calc_aspect_ratio(u8 hor_landscape, u8 vert_portrait); */ struct v4l2_fract v4l2_dv_timings_aspect_ratio(const struct v4l2_dv_timings *t); +/** + * v4l2_dv_timings_cea861_aspect_ratio() - return CEA-861 picture aspect ratio + * @t: the timings data. + * + * Returns the CEA-861 picture aspect ratio value (AVI InfoFrame bits M0+M1) + */ +u8 v4l2_dv_timings_cea861_aspect_ratio(const struct v4l2_dv_timings *t); + /* * reduce_fps - check if conditions for reduced fps are true. * bt - v4l2 timing structure