From patchwork Fri Jun 7 08:56:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 166073 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp368514ili; Fri, 7 Jun 2019 01:57:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqzyHdn6C+mffvtCE0kvk1t7Q/QNLD9fiVtzVqQ1vZpE9bDXBDd9RHREK0VcJX3wx4AZhk6e X-Received: by 2002:a63:3141:: with SMTP id x62mr1829828pgx.282.1559897837599; Fri, 07 Jun 2019 01:57:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559897837; cv=none; d=google.com; s=arc-20160816; b=NAL8D+BIQ4QyQUInLhytMO51ts/Z47oEXNGBeUkT6ymntysSPqVXuOeK7a7dfwhdu+ WHhIWJytYWsN1Ca/+vLm6V+3IrIMQ1qYTVn+UYMO5FLB1YKKbslEtZjyDznLECwa4XBh Keo+nVKazCQ+3LojgvXyFUY9UM5sNRmTBRMvUeT4owFIa+TxwCYvkL+qbMywVrrC8rcE 9xgot3C7I91pFZ0aHDDBqr7nC+mDfp864xPYrL+Zh9aVhKKVhou67+9o1csyCmex5Hmp 9Ntuo75hWFOHdT1rlB0SnTSfxkHrkK0gSjn/78au4T3HfDUWupOmFNQxBOSOu0Y1Pa7t DEMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=KUhboSAFmz5mtk8bqOkf7FrFn2o/dLGKQrpvRYoaznc=; b=eCTodi8vYTFDIKOs/9SH/fR0q1kFHulpjT1uC7G62y25SzPxGdBmeTgM+CXP9+OmpU +WmankqCjKmbBkdq6tiTeHoQN0FiTjbq2whrH4QGL6rOiXh41Sjf0sgJZGbX+teFWKi4 d839tuS4cKTMGpyT2qbfV7Fauwt4M+3UGjCjnPj0YJAmfDGL75b39EupW21Wi1AQs4i7 9tuej6kPQ6+5fe1M+Q4w1xoLQrym9QfJD5pqFkXt1piFfpNfS92f4z2OfYrYvyv7GUCo LOfvn+XzjnMDZMSW2hgl53vdDW9oENMonMlyJ7Fl05tJiKgtnCWlP8j3T5U26oDwDhfG 2lKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qzcDMMv6; 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=pass (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 c1si1391507pld.418.2019.06.07.01.57.17; Fri, 07 Jun 2019 01:57:17 -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; dkim=pass header.i=@linaro.org header.s=google header.b=qzcDMMv6; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727843AbfFGI5Q (ORCPT + 30 others); Fri, 7 Jun 2019 04:57:16 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:50365 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726819AbfFGI5L (ORCPT ); Fri, 7 Jun 2019 04:57:11 -0400 Received: by mail-wm1-f67.google.com with SMTP id c66so1191314wmf.0 for ; Fri, 07 Jun 2019 01:57:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KUhboSAFmz5mtk8bqOkf7FrFn2o/dLGKQrpvRYoaznc=; b=qzcDMMv6/dC+W88mLNVStn/1exwxI5WCsOypC3gl2r3+gaoDMIOQYEYcuG41mZg4K4 W1+wDi7jZIIjYFe0bNSdJb8dlG/Hdk64D0lQNdVEqzyU9mQixYMn/sVvGQUgfbOb4OqH n96hpVWConp+8aolrBLU5RAXiICd9cEHnv2TAUrcSEaayPHCnj6dJSpJrXjOzMRw5IA0 mBvyCeu658+xZPj40wPPTfT7en/Xiv5jINsfwExCLe7XtZ4ZG2ApUlR4ftF4W3DT1GzV tVPKkImfEiPpV3dHfL4xblmzzRC5VoTyVg0NLYHV3VcSB2vR8W52pxL4AhlnKiak1Hy5 V9qQ== 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:mime-version:content-transfer-encoding; bh=KUhboSAFmz5mtk8bqOkf7FrFn2o/dLGKQrpvRYoaznc=; b=inNOC4Gtk6bDrpwoymyraucovozfktxcLwFuiWvef0CYKovxL7pgM3RuT5kUx4SKum gV1837RVMwQFqU8XcICoeVJnrGWOJ1Gp3g+ScUCwj6hAeNRjEz3ij2Xw+BmeA1WBcgY0 4/+XW9U04XIc1+OHsdsrhJgv2W7xtmbawnfIYeexcwFed6yPEOkTHWmuo96GjiO/Riw6 OFzjgf8WA+wA5dv4nG6JC2MdREUjAqVRB4YwNKasUXo+mzAwuiE5ExKgu41srPro+dh6 tM4tgly1IhSG9kUNf01w00udvJtGT1Q06oyJGwKF04/EpqY5DOd7tsUv1caYcsXGFwJf fhyA== X-Gm-Message-State: APjAAAVgm68aABx96NQhyz+oDcnaqy7SqUdRNC0qUu/53ElnDwWzeU2N 0rJoIxYJq8CF5vCEwVbseNYyAQ== X-Received: by 2002:a1c:9a53:: with SMTP id c80mr2627868wme.173.1559897829451; Fri, 07 Jun 2019 01:57:09 -0700 (PDT) Received: from srini-hackbox.lan (cpc89974-aztw32-2-0-cust43.18-1.cable.virginm.net. [86.30.250.44]) by smtp.gmail.com with ESMTPSA id d10sm2035308wrh.91.2019.06.07.01.57.08 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 07 Jun 2019 01:57:08 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org, vkoul@kernel.org Cc: robh+dt@kernel.org, devicetree@vger.kernel.org, mark.rutland@arm.com, pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Srinivas Kandagatla Subject: [RFC PATCH 2/6] soundwire: Add compute_params callback Date: Fri, 7 Jun 2019 09:56:39 +0100 Message-Id: <20190607085643.932-3-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190607085643.932-1-srinivas.kandagatla@linaro.org> References: <20190607085643.932-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vinod Koul This callback allows masters to compute the bus parameters required. Signed-off-by: Vinod Koul Signed-off-by: Srinivas Kandagatla --- drivers/soundwire/stream.c | 9 +++++++++ include/linux/soundwire/sdw.h | 2 ++ 2 files changed, 11 insertions(+) -- 2.21.0 diff --git a/drivers/soundwire/stream.c b/drivers/soundwire/stream.c index 73c52cd4fec8..b86992145799 100644 --- a/drivers/soundwire/stream.c +++ b/drivers/soundwire/stream.c @@ -1485,6 +1485,15 @@ static int _sdw_prepare_stream(struct sdw_stream_runtime *stream) bus->params.bandwidth += m_rt->stream->params.rate * m_rt->ch_count * m_rt->stream->params.bps; + /* Compute params */ + if (bus->compute_params) { + ret = bus->compute_params(bus); + if (ret < 0) { + dev_err(bus->dev, "Compute params failed: %d", ret); + return ret; + } + } + /* Program params */ ret = sdw_program_params(bus); if (ret < 0) { diff --git a/include/linux/soundwire/sdw.h b/include/linux/soundwire/sdw.h index bea46bd8b6ce..aac68e879fae 100644 --- a/include/linux/soundwire/sdw.h +++ b/include/linux/soundwire/sdw.h @@ -718,6 +718,7 @@ struct sdw_master_ops { * Bit set implies used number, bit clear implies unused number. * @bus_lock: bus lock * @msg_lock: message lock + * @compute_params: points to Bus resource management implementation * @ops: Master callback ops * @port_ops: Master port callback ops * @params: Current bus parameters @@ -739,6 +740,7 @@ struct sdw_bus { DECLARE_BITMAP(assigned, SDW_MAX_DEVICES); struct mutex bus_lock; struct mutex msg_lock; + int (*compute_params)(struct sdw_bus *bus); const struct sdw_master_ops *ops; const struct sdw_master_port_ops *port_ops; struct sdw_bus_params params;