From patchwork Fri Jun 22 15:33:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Todor Tomov X-Patchwork-Id: 139690 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1017949lji; Fri, 22 Jun 2018 08:36:11 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJOg2/OOF7+UeQbJ0iRzZ+3rjB1ktGiCqpgsAht5qjGqnsM5Ro3uFWi7PgQlN8B1WwQbjZs X-Received: by 2002:a65:4e86:: with SMTP id b6-v6mr1903673pgs.322.1529681771269; Fri, 22 Jun 2018 08:36:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529681771; cv=none; d=google.com; s=arc-20160816; b=jSmHc3iDeVcNTHmwqONEsuizMGNb/F8BsflrfG0mz0Jk1dwka7NxXZUSfiGIe6+3yG 5JkqcmNhRd2HWqqGj+lUOLSksIuj7JmYtqJj6GKcI3fH7GPXKm/DtmwOYdg+VUsDxyom JGdxeFO5FvtRd1IDqrYnnxqtv9lTqJeJILUdN4ySOj5NVgSoR/aIq3CII7mEy+e/RHdg Xomyd/KOqG/UO+ZQ46u11Koz6prLUfIUy8sq64muTCUWBE5QcieqoYRBe/FgsFQZWTic LtoMsjBig+WnVp8oke12qvU88hkdl75TU+hUBTSza0VZcifGE7xcUSvIF19iE99Ob9XW euig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=tmIOUX/bu6oYbJ6P/Fox7wNuxxjvAz8qkvfSQPKyVtc=; b=mmphVjCFAsEw6zMBRcuMpQasy3CiOqbAaEiUz7UYCfpRgvFT5z85OLgOXDLj0CfROB PiyQIPvtRFw47mVGONJgQbOCC0jsNn57Xg45LagUlv9qowqXiSIfPjx1FGiw/f3cgvHR jy7cgAekBC4xZrPVZ8SE86w3una7jcvLUXYtK54UcopCHIcW0AurnQkkFN1qEKxVmzf9 vBQXDAAw+f8J3gY88mMc7p/dGcaWEuOjeHQzutC74AlbjvHieLxhgtXamgw/uMHpcHXI 8qpngVSCmfM+W1Its/s1NO/ff++7puYbYhLKyRL/CaFmqLfWXFeynhIr89qCOtRTDKRj Nruw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c13-v6si7892332plo.97.2018.06.22.08.36.10; Fri, 22 Jun 2018 08:36:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934129AbeFVPfl (ORCPT + 31 others); Fri, 22 Jun 2018 11:35:41 -0400 Received: from ns.mm-sol.com ([37.157.136.199]:46557 "EHLO extserv.mm-sol.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933995AbeFVPeJ (ORCPT ); Fri, 22 Jun 2018 11:34:09 -0400 Received: from mms-0439.qualcomm.mm-sol.com (unknown [37.157.136.206]) by extserv.mm-sol.com (Postfix) with ESMTPSA id E12D24F894; Fri, 22 Jun 2018 18:33:59 +0300 (EEST) From: Todor Tomov To: mchehab@kernel.org, sakari.ailus@linux.intel.com, hans.verkuil@cisco.com, laurent.pinchart+renesas@ideasonboard.com, linux-media@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Todor Tomov Subject: [PATCH 28/32] media: camss: csid: Different format support on source pad Date: Fri, 22 Jun 2018 18:33:37 +0300 Message-Id: <1529681621-9682-29-git-send-email-todor.tomov@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1529681621-9682-1-git-send-email-todor.tomov@linaro.org> References: <1529681621-9682-1-git-send-email-todor.tomov@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Usually the format on the source pad is the same as on the sink pad. However the CSID is able to do some format conversions. To support this make the format on the source pad selectable amongst a list of formats. This list can be different for each sink pad format. This is still not used but will be when the format conversions are implemented. Signed-off-by: Todor Tomov --- drivers/media/platform/qcom/camss/camss-csid.c | 65 ++++++++++++++++++++------ 1 file changed, 52 insertions(+), 13 deletions(-) -- 2.7.4 diff --git a/drivers/media/platform/qcom/camss/camss-csid.c b/drivers/media/platform/qcom/camss/camss-csid.c index 18420e3..9cfef98 100644 --- a/drivers/media/platform/qcom/camss/camss-csid.c +++ b/drivers/media/platform/qcom/camss/camss-csid.c @@ -300,6 +300,43 @@ static const struct csid_format csid_formats_8x96[] = { } }; +static u32 csid_find_code(u32 *code, unsigned int n_code, + unsigned int index, u32 req_code) +{ + int i; + + if (!req_code && (index >= n_code)) + return 0; + + for (i = 0; i < n_code; i++) + if (req_code) { + if (req_code == code[i]) + return req_code; + } else { + if (i == index) + return code[i]; + } + + return code[0]; +} + +static u32 csid_src_pad_code(struct csid_device *csid, u32 sink_code, + unsigned int index, u32 src_req_code) +{ + if (csid->camss->version == CAMSS_8x16) + return sink_code; + else if (csid->camss->version == CAMSS_8x96) + switch (sink_code) { + default: + if (index > 0) + return 0; + + return sink_code; + } + else + return 0; +} + static const struct csid_format *csid_get_fmt_entry( const struct csid_format *formats, unsigned int nformat, @@ -667,15 +704,15 @@ static void csid_try_format(struct csid_device *csid, case MSM_CSID_PAD_SRC: if (csid->testgen_mode->cur.val == 0) { - /* Test generator is disabled, keep pad formats */ - /* in sync - set and return a format same as sink pad */ - struct v4l2_mbus_framefmt format; + /* Test generator is disabled, */ + /* keep pad formats in sync */ + u32 code = fmt->code; - format = *__csid_get_format(csid, cfg, - MSM_CSID_PAD_SINK, which); - *fmt = format; + *fmt = *__csid_get_format(csid, cfg, + MSM_CSID_PAD_SINK, which); + fmt->code = csid_src_pad_code(csid, fmt->code, 0, code); } else { - /* Test generator is enabled, set format on source*/ + /* Test generator is enabled, set format on source */ /* pad to allow test generator usage */ for (i = 0; i < csid->nformats; i++) @@ -709,7 +746,6 @@ static int csid_enum_mbus_code(struct v4l2_subdev *sd, struct v4l2_subdev_mbus_code_enum *code) { struct csid_device *csid = v4l2_get_subdevdata(sd); - struct v4l2_mbus_framefmt *format; if (code->pad == MSM_CSID_PAD_SINK) { if (code->index >= csid->nformats) @@ -718,13 +754,16 @@ static int csid_enum_mbus_code(struct v4l2_subdev *sd, code->code = csid->formats[code->index].code; } else { if (csid->testgen_mode->cur.val == 0) { - if (code->index > 0) - return -EINVAL; + struct v4l2_mbus_framefmt *sink_fmt; - format = __csid_get_format(csid, cfg, MSM_CSID_PAD_SINK, - code->which); + sink_fmt = __csid_get_format(csid, cfg, + MSM_CSID_PAD_SINK, + code->which); - code->code = format->code; + code->code = csid_src_pad_code(csid, sink_fmt->code, + code->index, 0); + if (!code->code) + return -EINVAL; } else { if (code->index >= csid->nformats) return -EINVAL;