From patchwork Thu Jul 5 13:32:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Todor Tomov X-Patchwork-Id: 141153 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1949582ljj; Thu, 5 Jul 2018 06:34:43 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfFIfhpN9YKrS+Bzk9M9CMDswYEiyWGhlwlClxzbLUKaptfjww6pmOfmbt31OLaPC4NIoIr X-Received: by 2002:a17:902:246a:: with SMTP id m39-v6mr6232628plg.141.1530797683639; Thu, 05 Jul 2018 06:34:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530797683; cv=none; d=google.com; s=arc-20160816; b=B1IjuhTDFnrjl8FsW3MpGmUI9IkJViP6yZwPXFzkjhXpzKqERPW0rVTI0vu4ssrjTM zTLGaCtUyCPiQoVSeCBzltGemdtu8poPcfn4f8Oocky+DfBtFuquCKNcmtc915lYjwTY /e6URcg9C6ollxbjbE9lL6DCD8++WpDeniC8BY9mV80NaoZJ1WRzJiOVUVk2HuOLlnNi CPXE68qf+CiDtWG4yrhSW+uzUXA3QyjKdpKOToaoOkp0vHFOOyEnVX1dbw52y/xBzNHi AVfTgbos8KhQn+DEQXuhnVq9x9UJVv/b/sk7w45FFfhjPUvjKmMY4Y7Fy8PNBchRMjBK cHNA== 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=/0zbqYLNFsQQ3QU3eKP1MvJifNzJfL7MK+KdTdCNW30=; b=fMekmIuL7T3xOHJKzpnjRGPtAet2VVTf+PrzB/auXCKDok/DgQayZBXk+6Uq9shf4K wH+GIzjVmrtRiU6lJgM58vDM/tF3AJqVKX1OsQARd+CZ5CVMemOeHQKndrV5grTMPdQb wsROkMoT/+dTeROOy7aNJ5tV2cte2yYBZxyAW2qCX+dKdRSBMoFkxkkZOlODV0+poTK8 iDvoz8cbxj/FO8n47AQduqbuu7vFi/xeun8jAD8hlnFt7sNGFCgPmizjZkuXz642qtko W2Eumkqxqn72l3mrQuh9iy8af5yd6ONZWMnotfOyi+sWXVqX8w7cEQI4j014aKumEsg2 sbdA== 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 j10-v6si2900838pgi.500.2018.07.05.06.34.43; Thu, 05 Jul 2018 06:34:43 -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 S1754042AbeGENe3 (ORCPT + 31 others); Thu, 5 Jul 2018 09:34:29 -0400 Received: from ns.mm-sol.com ([37.157.136.199]:41376 "EHLO extserv.mm-sol.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753836AbeGENdX (ORCPT ); Thu, 5 Jul 2018 09:33:23 -0400 Received: from mms-0439.qualcomm.mm-sol.com (unknown [37.157.136.206]) by extserv.mm-sol.com (Postfix) with ESMTPSA id F11D7CD64; Thu, 5 Jul 2018 16:33:17 +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 v2 28/34] media: camss: csid: Different format support on source pad Date: Thu, 5 Jul 2018 16:32:59 +0300 Message-Id: <1530797585-8555-29-git-send-email-todor.tomov@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1530797585-8555-1-git-send-email-todor.tomov@linaro.org> References: <1530797585-8555-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 | 69 +++++++++++++++++++++----- 1 file changed, 56 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..8fd7909 100644 --- a/drivers/media/platform/qcom/camss/camss-csid.c +++ b/drivers/media/platform/qcom/camss/camss-csid.c @@ -300,6 +300,47 @@ 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) { + if (index > 0) + return 0; + + 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 +708,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 +750,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 +758,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;