From patchwork Thu Nov 1 23:31:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 10664801 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1C13046E4 for ; Thu, 1 Nov 2018 23:33:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0F9C22C43C for ; Thu, 1 Nov 2018 23:33:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0369D2C451; Thu, 1 Nov 2018 23:33:19 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable 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 AF2DD2C532 for ; Thu, 1 Nov 2018 23:33:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728364AbeKBIiS (ORCPT ); Fri, 2 Nov 2018 04:38:18 -0400 Received: from bin-mail-out-05.binero.net ([195.74.38.228]:40306 "EHLO bin-mail-out-05.binero.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728360AbeKBIiS (ORCPT ); Fri, 2 Nov 2018 04:38:18 -0400 X-Halon-ID: 7a5ddcd8-de2e-11e8-9adf-005056917a89 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (unknown [89.233.230.99]) by bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA id 7a5ddcd8-de2e-11e8-9adf-005056917a89; Fri, 02 Nov 2018 00:33:04 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: Laurent Pinchart , Sakari Ailus , Benoit Parrot , linux-media@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, =?utf-8?q?Niklas_S=C3=B6derlund?= Subject: [PATCH v2 24/30] adv748x: csi2: add translation from pixelcode to CSI-2 datatype Date: Fri, 2 Nov 2018 00:31:38 +0100 Message-Id: <20181101233144.31507-25-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181101233144.31507-1-niklas.soderlund+renesas@ragnatech.se> References: <20181101233144.31507-1-niklas.soderlund+renesas@ragnatech.se> MIME-Version: 1.0 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 Prepare to implement frame descriptors to support multiplexed streams by adding a function to map pixelcode to CSI-2 datatype. This is needed to properly be able to fill out the struct v4l2_mbus_frame_desc. Signed-off-by: Niklas Söderlund --- drivers/media/i2c/adv748x/adv748x-csi2.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/media/i2c/adv748x/adv748x-csi2.c b/drivers/media/i2c/adv748x/adv748x-csi2.c index 6ce21542ed485811..8a7cc713c7adfcc1 100644 --- a/drivers/media/i2c/adv748x/adv748x-csi2.c +++ b/drivers/media/i2c/adv748x/adv748x-csi2.c @@ -14,6 +14,28 @@ #include "adv748x.h" +struct adv748x_csi2_format { + unsigned int code; + unsigned int datatype; +}; + +static const struct adv748x_csi2_format adv748x_csi2_formats[] = { + { .code = MEDIA_BUS_FMT_RGB888_1X24, .datatype = 0x24, }, + { .code = MEDIA_BUS_FMT_UYVY8_1X16, .datatype = 0x1e, }, + { .code = MEDIA_BUS_FMT_UYVY8_2X8, .datatype = 0x1e, }, + { .code = MEDIA_BUS_FMT_YUYV10_2X10, .datatype = 0x1e, }, +}; + +static unsigned int adv748x_csi2_code_to_datatype(unsigned int code) +{ + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(adv748x_csi2_formats); i++) + if (adv748x_csi2_formats[i].code == code) + return adv748x_csi2_formats[i].datatype; + return 0; +} + static int adv748x_csi2_set_virtual_channel(struct adv748x_csi2 *tx, unsigned int vc) {