From patchwork Wed Sep 13 15:07:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 44102 X-Patchwork-Delegate: hverkuil@xs4all.nl Received: from vger.kernel.org ([209.132.180.67]) by www.linuxtv.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ds9HU-0008VG-KH; Wed, 13 Sep 2017 15:08:49 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751810AbdIMPIr (ORCPT + 1 other); Wed, 13 Sep 2017 11:08:47 -0400 Received: from mx07-00252a01.pphosted.com ([62.209.51.214]:2430 "EHLO mx07-00252a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751399AbdIMPIq (ORCPT ); Wed, 13 Sep 2017 11:08:46 -0400 Received: from pps.filterd (m0102628.ppops.net [127.0.0.1]) by mx07-00252a01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v8DF58Bp023539 for ; Wed, 13 Sep 2017 16:08:44 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.org; h=from : to : cc : subject : date : message-id : in-reply-to : references : in-reply-to : references; s=pp; bh=+rh2Kx1UCGsQ6wC4xSAYdVbylp+NfWORr4tiDHsJDLU=; b=kpFAaQdYvkv+Fl+m9+25Upx2xeOKyKTzngiZN6NhimJC1QLcWJHfX4bcOyy8tZ+wCIYj 4o7RT/PsjfpYEYo46t1ETRCSZb6DJgm0MGwcjAqGygOZD4NXArhnIPsVw4IPXeTKjB5p JnnE0K8aA9sGfB5W+ATAJGrh28drZnLDLylcenyZmQrXWhTR5a7tZhy2SIK7d3ScVmDB ckPkEzlre/WoGxvyFEloTB1swnIb3ar6WI03SPPlUNI20Y18+WRYhrD6+6bqdQbdkYm/ r4XzEQi9kVOC46ja+PdUDpH9ODPCzUomLNaR1DqE2vd6Fwt9gjMmaur1I3KKeUZImRnf dQ== Received: from mail-wr0-f199.google.com (mail-wr0-f199.google.com [209.85.128.199]) by mx07-00252a01.pphosted.com with ESMTP id 2cv5pysxkj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=OK) for ; Wed, 13 Sep 2017 16:08:44 +0100 Received: by mail-wr0-f199.google.com with SMTP id d6so490219wrd.7 for ; Wed, 13 Sep 2017 08:08:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=+rh2Kx1UCGsQ6wC4xSAYdVbylp+NfWORr4tiDHsJDLU=; b=JH5RVHE4/QhQVrRO9iA1AoZKb4fJUhorAFN60kOInn+wrwn4cgxPPrQ3RZLwgGJbws T2Z7tjEcsdLWngAM+lOaTLIbqfLVs2Cr1VFmu92uYwFqEGJFJsxNZSx0Tq4AWnFkWVEa Xndt9zWFMNJJqm6VDmNChjNR7XcUSQUrcg5L1bsLuHFFAuMyE3BipnXmJXXp1lcYynJW LNEvreSnxucxsCnDzT2IZqcoC0ybprGw58BzVNdlQD7WdAQSsg+DTE1SZ68dDBuVB+gI O3eoAo8ZmBfy3T8L+dxfsOBFTQg2YJT8TnK/fqRk6EFcyYONqWKqPs8rXwFNgNwwuoWX NyjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=+rh2Kx1UCGsQ6wC4xSAYdVbylp+NfWORr4tiDHsJDLU=; b=Qiiea0WTupuNVscm+DiPOwHSjeryQZpxroT7311j1U28c8VyIvEjRam7zinMWcX1LK I1/mOcVPOAIMKLWglD/6gtug7ZEjPARPpcy7EbM6oXcukThckWtJxyWOuCgXoxn8E/dq zyUoMtxAZqqUXWLPhhS+qEPUkwbuBXuam3O75IYUSn0ML03XOx0rm3xudM4xU/PNOkZz +d4ryg5T+JSNZ0OKbMXP2lmG3dCewPb3Z78dgSn0Pcl/zJXkdj0h0zASlaFMv/UUOSTl EPRbhsHwbtPMx0mxM0gee97cNmoa7Xx0q4TeBg+CnKxPx9zcpDxD7X2YKFMkXBLn/Isl P2qA== X-Gm-Message-State: AHPjjUgXJPCvCaOnEJBLGvoe4Qo5/GhSdDdJnTwevOeCkwL+3AHjBCAO yV8xraXsRU+tzTi/86LrsxaG/QdwIBl5uzoQlbNeXS11UwD58crvPNfxaBsu3gR15IpMg61l+ws KNIgRXUlQFQJ0Jg== X-Received: by 10.223.182.10 with SMTP id f10mr13482439wre.38.1505315323765; Wed, 13 Sep 2017 08:08:43 -0700 (PDT) X-Google-Smtp-Source: ADKCNb4hbnKneSP1Jqs337VNlbYvsiDCUqDbRhiQJ69HPv9dWSVPKao91CeevYmAKhraleJAUnMIWg== X-Received: by 10.223.182.10 with SMTP id f10mr13482426wre.38.1505315323523; Wed, 13 Sep 2017 08:08:43 -0700 (PDT) Received: from dave-VirtualBox.pitowers.org ([217.33.127.173]) by smtp.googlemail.com with ESMTPSA id n71sm1127985wmg.20.2017.09.13.08.08.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 13 Sep 2017 08:08:42 -0700 (PDT) From: Dave Stevenson To: Mauro Carvalho Chehab , Rob Herring , Hans Verkuil , Eric Anholt , Stefan Wahren , Sakari Ailus , linux-media@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, devicetree@vger.kernel.org Cc: Dave Stevenson Subject: [PATCH v2 1/4] [media] v4l2-common: Add helper function for fourcc to string Date: Wed, 13 Sep 2017 16:07:46 +0100 Message-Id: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: References: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-09-13_04:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_spam_notspam policy=outbound_spam score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1709130236 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org New helper function char *v4l2_fourcc2s(u32 fourcc, char *buf) that converts a fourcc into a nice printable version. Signed-off-by: Dave Stevenson --- drivers/media/v4l2-core/v4l2-common.c | 18 ++++++++++++++++++ include/media/v4l2-common.h | 3 +++ 2 files changed, 21 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c index a5ea1f5..0219895 100644 --- a/drivers/media/v4l2-core/v4l2-common.c +++ b/drivers/media/v4l2-core/v4l2-common.c @@ -405,3 +405,21 @@ void v4l2_get_timestamp(struct timeval *tv) tv->tv_usec = ts.tv_nsec / NSEC_PER_USEC; } EXPORT_SYMBOL_GPL(v4l2_get_timestamp); + +char *v4l2_fourcc2s(u32 fourcc, char *buf) +{ + buf[0] = fourcc & 0x7f; + buf[1] = (fourcc >> 8) & 0x7f; + buf[2] = (fourcc >> 16) & 0x7f; + buf[3] = (fourcc >> 24) & 0x7f; + if (fourcc & (1 << 31)) { + buf[4] = '-'; + buf[5] = 'B'; + buf[6] = 'E'; + buf[7] = '\0'; + } else { + buf[4] = '\0'; + } + return buf; +} +EXPORT_SYMBOL_GPL(v4l2_fourcc2s); diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h index aac8b7b..5b0fff9 100644 --- a/include/media/v4l2-common.h +++ b/include/media/v4l2-common.h @@ -264,4 +264,7 @@ const struct v4l2_frmsize_discrete *v4l2_find_nearest_format( void v4l2_get_timestamp(struct timeval *tv); +#define V4L2_FOURCC_MAX_SIZE 8 +char *v4l2_fourcc2s(u32 fourcc, char *buf); + #endif /* V4L2_COMMON_H_ */